Compare commits
10 Commits
3af495d458
...
04866b4d3a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
04866b4d3a | ||
![]() |
8bc3d9d793 | ||
![]() |
55adf223d2 | ||
![]() |
22b929225f | ||
![]() |
49ead642c4 | ||
![]() |
b55cea174d | ||
![]() |
c709932af2 | ||
![]() |
389b0d072c | ||
![]() |
0076ae6627 | ||
![]() |
301f00e9a4 |
15
TODO.md
15
TODO.md
@ -21,9 +21,22 @@ For example:
|
|||||||
- extensible
|
- extensible
|
||||||
- fp
|
- fp
|
||||||
- [ ] Remove gradle plugins and whatnot until we actually build the whole framework
|
- [ ] Remove gradle plugins and whatnot until we actually build the whole framework
|
||||||
|
- [ ] Get rid of wvc compiler dependency on di
|
||||||
|
|
||||||
|
## 0.1.3
|
||||||
|
- [ ] refactor tools/gradle start scripts to use dist instead of custom bin script
|
||||||
|
- [ ] have custom bin/* scripts which point to dist(s) for convenience
|
||||||
|
- [ ] di bug: @Singleton toSelf() causes stack overflow
|
||||||
|
- [ ] `OutletContainer` trait or interface for components which can contain an `<Outlet />` child.
|
||||||
|
- [ ] `Context` should have methods for simply finding an ancestor of a certain type without the need for a predicate.
|
||||||
|
|
||||||
## 0.1.2
|
## 0.1.2
|
||||||
- [ ] di bug: @Singleton toSelf() causes stack overflow
|
- [x] `Outlet` component for rendering children like so:
|
||||||
|
```
|
||||||
|
<Outlet children={children} />
|
||||||
|
```
|
||||||
|
- [x] `Render` component
|
||||||
|
- [x] `data-` attributes need to function correctly (really any attribute with hyphen).
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
- [x] `Switch` and `Case` components
|
- [x] `Switch` and `Case` components
|
||||||
|
@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'groowt'
|
group = 'groowt'
|
||||||
version = '0.1.1'
|
version = '0.1.2'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -22,7 +22,7 @@ groovy-console = { module = 'org.apache.groovy:groovy-console', version.ref = 'g
|
|||||||
groovy-templates = { module = 'org.apache.groovy:groovy-templates', version.ref = 'groovy' }
|
groovy-templates = { module = 'org.apache.groovy:groovy-templates', version.ref = 'groovy' }
|
||||||
jakarta-inject = 'jakarta.inject:jakarta.inject-api:2.0.1'
|
jakarta-inject = 'jakarta.inject:jakarta.inject-api:2.0.1'
|
||||||
jansi = 'org.fusesource.jansi:jansi:2.4.1'
|
jansi = 'org.fusesource.jansi:jansi:2.4.1'
|
||||||
jbarchiva = 'com.jessebrault.jbarchiva:jbarchiva:0.2.1'
|
jbarchiva = 'com.jessebrault.jbarchiva:jbarchiva:0.2.2'
|
||||||
jetbrains-anotations = 'org.jetbrains:annotations:24.1.0'
|
jetbrains-anotations = 'org.jetbrains:annotations:24.1.0'
|
||||||
junit-jupiter-api = { module = 'org.junit.jupiter:junit-jupiter-api', version.ref = 'junit' }
|
junit-jupiter-api = { module = 'org.junit.jupiter:junit-jupiter-api', version.ref = 'junit' }
|
||||||
kotlin-stdlib = { module = 'org.jetbrains.kotlin:kotlin-stdlib', version.ref = 'kotlin' }
|
kotlin-stdlib = { module = 'org.jetbrains.kotlin:kotlin-stdlib', version.ref = 'kotlin' }
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
7
gradlew
vendored
7
gradlew
vendored
@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@ -84,7 +86,8 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
@ -13,6 +13,8 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
@ -307,7 +307,7 @@ AttributeIdentifierStartChar
|
|||||||
|
|
||||||
fragment
|
fragment
|
||||||
AttributeIdentifierChar
|
AttributeIdentifierChar
|
||||||
: [\p{L}_$0-9]
|
: [-\p{L}_$0-9]
|
||||||
;
|
;
|
||||||
|
|
||||||
Equals
|
Equals
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
<test test-attr />
|
@ -0,0 +1 @@
|
|||||||
|
<test-type />
|
@ -0,0 +1,7 @@
|
|||||||
|
0: ComponentOpen[1,1](<)
|
||||||
|
1: StringIdentifier[1,2](test)
|
||||||
|
2: Nlws[1,6]( )
|
||||||
|
3: AttributeIdentifier[1,7](test-attr)
|
||||||
|
4: Nlws[1,16]( )
|
||||||
|
5: ComponentSelfClose[1,17](/>)
|
||||||
|
6: RawText[1,19](\n)
|
@ -0,0 +1,5 @@
|
|||||||
|
0: ComponentOpen[1,1](<)
|
||||||
|
1: StringIdentifier[1,2](test-type)
|
||||||
|
2: Nlws[1,11]( )
|
||||||
|
3: ComponentSelfClose[1,12](/>)
|
||||||
|
4: RawText[1,14](\n)
|
@ -1,8 +1,10 @@
|
|||||||
#/usr/bin/env bash
|
#/usr/bin/env bash
|
||||||
|
|
||||||
|
VERSION="0.1.2"
|
||||||
|
|
||||||
if [ "\$1" == "--debug" ]; then
|
if [ "\$1" == "--debug" ]; then
|
||||||
shift
|
shift
|
||||||
gradle -q toolsJar && java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8192 -cp build/libs/web-view-components-compiler-tools-0.1.0.jar $mainClassName "\$@"
|
gradle -q toolsJar && java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8192 -cp build/libs/web-view-components-compiler-tools-\$VERSION.jar $mainClassName "\$@"
|
||||||
else
|
else
|
||||||
gradle -q toolsJar && java -cp build/libs/web-view-components-compiler-tools-0.1.0.jar $mainClassName "\$@"
|
gradle -q toolsJar && java -cp build/libs/web-view-components-compiler-tools-\$VERSION.jar $mainClassName "\$@"
|
||||||
fi
|
fi
|
||||||
|
@ -14,6 +14,8 @@ class DefaultWebViewComponentScope extends DefaultComponentScope implements WebV
|
|||||||
addWithAttr(DefaultCase)
|
addWithAttr(DefaultCase)
|
||||||
addWithAttr(Each)
|
addWithAttr(Each)
|
||||||
addWithAttr(Echo)
|
addWithAttr(Echo)
|
||||||
|
addWithAttr(Outlet)
|
||||||
|
addWithAttr(Render)
|
||||||
addWithAttr(Switch)
|
addWithAttr(Switch)
|
||||||
addWithAttr(WhenNotEmpty)
|
addWithAttr(WhenNotEmpty)
|
||||||
addWithAttr(WhenNotNull)
|
addWithAttr(WhenNotNull)
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package groowt.view.component.web.lib
|
||||||
|
|
||||||
|
import groowt.view.View
|
||||||
|
import groowt.view.component.runtime.DefaultComponentWriter
|
||||||
|
|
||||||
|
class Outlet extends DelegatingWebViewComponent {
|
||||||
|
|
||||||
|
private final List givenChildren
|
||||||
|
|
||||||
|
Outlet(Map attr) {
|
||||||
|
givenChildren = attr.children ?: []
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View getDelegate() {
|
||||||
|
return { Writer w ->
|
||||||
|
def cw = new DefaultComponentWriter(w, context.renderContext, context)
|
||||||
|
givenChildren.each { cw << it }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package groowt.view.component.web.lib
|
||||||
|
|
||||||
|
import groowt.view.View
|
||||||
|
|
||||||
|
class Render extends DelegatingWebViewComponent {
|
||||||
|
|
||||||
|
private final Object item
|
||||||
|
|
||||||
|
Render(Map attr) {
|
||||||
|
item = Objects.requireNonNull(attr.item, "<Render> attribute 'item' must not be null.")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View getDelegate() {
|
||||||
|
return { Writer w ->
|
||||||
|
if (item.respondsTo('renderTo', [Writer] as Class[])) {
|
||||||
|
item.renderTo(w)
|
||||||
|
} else if (item.respondsTo('render')) {
|
||||||
|
w << item.render()
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
'<Render> must use an item which responds to either renderTo(Writer) or render().'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package groowt.view.component.web.lib
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class OutletTests extends AbstractWebViewComponentTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void smokeScreen() {
|
||||||
|
doTest('<Outlet />', '')
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void withChildren() {
|
||||||
|
doTest('<Echo items={[0, 1, 2]}><Outlet children={items} /></Echo>', '012')
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package groowt.view.component.web.lib
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class RenderTests extends AbstractWebViewComponentTests {
|
||||||
|
|
||||||
|
static final class RenderToExample {
|
||||||
|
|
||||||
|
void renderTo(Writer w) {
|
||||||
|
w << 'Hello, World!'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static final class RenderExample {
|
||||||
|
|
||||||
|
String render() {
|
||||||
|
'Hello, World!'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void renderToExample() {
|
||||||
|
doTest('''
|
||||||
|
---
|
||||||
|
package groowt.view.component.web.lib
|
||||||
|
---
|
||||||
|
<Render item={new RenderTests.RenderToExample()} />
|
||||||
|
'''.stripIndent().trim(),
|
||||||
|
'Hello, World!'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void renderExample() {
|
||||||
|
doTest('''
|
||||||
|
---
|
||||||
|
package groowt.view.component.web.lib
|
||||||
|
---
|
||||||
|
<Render item={new RenderTests.RenderExample()} />
|
||||||
|
'''.stripIndent().trim(),
|
||||||
|
'Hello, World!'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user