@e280/sly 0.2.5 → 0.3.0-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +356 -626
- package/package.json +22 -30
- package/s/_archive/README.md +1221 -0
- package/s/_archive/view/index.ts +7 -0
- package/s/_archive/view/types.ts +45 -0
- package/s/demo/demo.bundle.ts +5 -8
- package/s/demo/views/counter-light.ts +13 -0
- package/s/demo/views/counter-shadow.ts +16 -0
- package/s/demo/views/demo.ts +24 -20
- package/s/demo/views/loaders.ts +9 -9
- package/s/demo/views/time-light.ts +19 -0
- package/s/demo/views/time-shadow.ts +22 -0
- package/s/dom/attrs/attrs.ts +3 -3
- package/s/dom/attrs/parts/attr-spec.ts +17 -5
- package/s/dom/attrs/parts/on-attrs.ts +1 -1
- package/s/dom/dom.ts +1 -1
- package/s/index.html.ts +30 -33
- package/s/index.ts +2 -4
- package/s/{loaders → loader}/index.barrel.ts +0 -1
- package/s/{loaders → loader}/index.ts +0 -1
- package/s/{loaders → loader}/make.ts +1 -1
- package/s/{loaders → loader}/parts/ascii-anim.ts +6 -8
- package/s/loader/parts/error-display.ts +26 -0
- package/s/{loaders → loader}/types.ts +1 -1
- package/s/test.ts +5 -0
- package/s/view/common/css-reset.ts +19 -0
- package/s/view/common/sly-shadow.ts +14 -0
- package/s/view/elements/light.ts +14 -0
- package/s/view/elements/shadow.ts +52 -0
- package/s/view/hooks/plumbing/hooks.ts +28 -0
- package/s/view/hooks/plumbing/hookscope.ts +12 -0
- package/s/view/hooks/use-attrs.ts +28 -0
- package/s/view/hooks/use-css.ts +14 -0
- package/s/view/hooks/use-cx.ts +41 -0
- package/s/view/hooks/use-life.ts +17 -0
- package/s/view/hooks/use-mount.ts +30 -0
- package/s/view/hooks/use-name.ts +10 -0
- package/s/view/hooks/use-once.ts +9 -0
- package/s/view/hooks/use-op.ts +12 -0
- package/s/view/hooks/use-ref.ts +11 -0
- package/s/view/hooks/use-signal.ts +16 -0
- package/s/view/hooks/use-state.ts +20 -0
- package/s/view/hooks/use-wake.ts +8 -0
- package/s/view/index.ts +22 -4
- package/s/view/light.ts +50 -0
- package/s/view/parts/apply-attrs.ts +22 -0
- package/s/view/parts/apply-styles.ts +21 -0
- package/s/view/parts/cx.ts +26 -0
- package/s/view/parts/reactivity.ts +22 -0
- package/s/view/shadow.ts +93 -0
- package/s/view/types.ts +15 -34
- package/x/demo/demo.bundle.js +5 -8
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +52 -63
- package/x/demo/demo.bundle.min.js.map +4 -4
- package/x/demo/views/counter-light.d.ts +1 -0
- package/x/demo/views/counter-light.js +10 -0
- package/x/demo/views/counter-light.js.map +1 -0
- package/x/demo/views/counter-shadow.d.ts +1 -0
- package/x/demo/views/counter-shadow.js +12 -0
- package/x/demo/views/counter-shadow.js.map +1 -0
- package/x/demo/views/demo.d.ts +1 -4
- package/x/demo/views/demo.js +24 -20
- package/x/demo/views/demo.js.map +1 -1
- package/x/demo/views/loaders.d.ts +1 -1
- package/x/demo/views/loaders.js +9 -9
- package/x/demo/views/loaders.js.map +1 -1
- package/x/demo/views/{counter.d.ts → time-light.d.ts} +3 -19
- package/x/demo/views/time-light.js +16 -0
- package/x/demo/views/time-light.js.map +1 -0
- package/x/demo/views/time-shadow.d.ts +365 -0
- package/x/demo/views/time-shadow.js +18 -0
- package/x/demo/views/time-shadow.js.map +1 -0
- package/x/dom/attrs/attrs.d.ts +3 -2
- package/x/dom/attrs/attrs.js +2 -2
- package/x/dom/attrs/attrs.js.map +1 -1
- package/x/dom/attrs/parts/attr-spec.d.ts +5 -1
- package/x/dom/attrs/parts/attr-spec.js +12 -6
- package/x/dom/attrs/parts/attr-spec.js.map +1 -1
- package/x/dom/attrs/parts/on-attrs.d.ts +1 -1
- package/x/dom/attrs/parts/on-attrs.js.map +1 -1
- package/x/dom/dom.d.ts +1 -1
- package/x/dom/dom.js.map +1 -1
- package/x/index.d.ts +2 -4
- package/x/index.html +30 -140
- package/x/index.html.js +31 -31
- package/x/index.html.js.map +1 -1
- package/x/index.js +2 -4
- package/x/index.js.map +1 -1
- package/x/{loaders → loader}/index.barrel.d.ts +0 -1
- package/x/loader/index.barrel.js.map +1 -0
- package/x/{loaders → loader}/index.d.ts +0 -1
- package/x/loader/index.js.map +1 -0
- package/x/{loaders → loader}/make.d.ts +1 -1
- package/x/loader/make.js.map +1 -0
- package/x/loader/mock.js.map +1 -0
- package/x/loader/parts/anims.js.map +1 -0
- package/x/{loaders → loader}/parts/ascii-anim.d.ts +1 -1
- package/x/{loaders → loader}/parts/ascii-anim.js +6 -7
- package/x/loader/parts/ascii-anim.js.map +1 -0
- package/x/loader/parts/error-display.d.ts +1 -0
- package/x/loader/parts/error-display.js +20 -0
- package/x/loader/parts/error-display.js.map +1 -0
- package/x/{loaders → loader}/types.d.ts +1 -1
- package/x/{loaders → loader}/types.js.map +1 -1
- package/x/loot/drag-and-drops.d.ts +2 -2
- package/x/loot/drops.d.ts +1 -1
- package/x/op/index.js.map +1 -0
- package/x/op/op.js.map +1 -0
- package/x/op/podium.js.map +1 -0
- package/x/{ops → op}/types.js.map +1 -1
- package/x/test.js +3 -0
- package/x/test.js.map +1 -0
- package/x/view/common/css-reset.js +17 -0
- package/x/view/common/css-reset.js.map +1 -0
- package/x/view/common/sly-shadow.d.ts +4 -0
- package/x/view/common/sly-shadow.js +11 -0
- package/x/view/common/sly-shadow.js.map +1 -0
- package/x/view/elements/light.d.ts +357 -0
- package/x/view/elements/light.js +10 -0
- package/x/view/elements/light.js.map +1 -0
- package/x/view/elements/shadow.d.ts +366 -0
- package/x/view/elements/shadow.js +42 -0
- package/x/view/elements/shadow.js.map +1 -0
- package/x/view/hooks/plumbing/hooks.d.ts +11 -0
- package/x/view/hooks/plumbing/hooks.js +26 -0
- package/x/view/hooks/plumbing/hooks.js.map +1 -0
- package/x/view/hooks/plumbing/hookscope.d.ts +10 -0
- package/x/view/hooks/plumbing/hookscope.js +12 -0
- package/x/view/hooks/plumbing/hookscope.js.map +1 -0
- package/x/view/hooks/use-attrs.d.ts +2 -0
- package/x/view/hooks/use-attrs.js +23 -0
- package/x/view/hooks/use-attrs.js.map +1 -0
- package/x/view/hooks/use-css.d.ts +4 -0
- package/x/view/hooks/use-css.js +10 -0
- package/x/view/hooks/use-css.js.map +1 -0
- package/x/view/hooks/use-cx.d.ts +10 -0
- package/x/view/hooks/use-cx.js +33 -0
- package/x/view/hooks/use-cx.js.map +1 -0
- package/x/view/hooks/use-life.d.ts +2 -0
- package/x/view/hooks/use-life.js +13 -0
- package/x/view/hooks/use-life.js.map +1 -0
- package/x/{base/utils/mounts.d.ts → view/hooks/use-mount.d.ts} +1 -0
- package/x/{base/utils/mounts.js → view/hooks/use-mount.js} +7 -1
- package/x/view/hooks/use-mount.js.map +1 -0
- package/x/view/hooks/use-name.d.ts +2 -0
- package/x/view/hooks/use-name.js +8 -0
- package/x/view/hooks/use-name.js.map +1 -0
- package/x/view/hooks/use-once.d.ts +2 -0
- package/x/view/hooks/use-once.js +7 -0
- package/x/view/hooks/use-once.js.map +1 -0
- package/x/view/hooks/use-op.d.ts +3 -0
- package/x/view/hooks/use-op.js +9 -0
- package/x/view/hooks/use-op.js.map +1 -0
- package/x/view/hooks/use-ref.d.ts +5 -0
- package/x/view/hooks/use-ref.js +11 -0
- package/x/view/hooks/use-ref.js.map +1 -0
- package/x/view/hooks/use-signal.d.ts +3 -0
- package/x/view/hooks/use-signal.js +12 -0
- package/x/view/hooks/use-signal.js.map +1 -0
- package/x/view/hooks/use-state.d.ts +1 -0
- package/x/view/hooks/use-state.js +17 -0
- package/x/view/hooks/use-state.js.map +1 -0
- package/x/view/hooks/use-wake.d.ts +2 -0
- package/x/view/hooks/use-wake.js +6 -0
- package/x/view/hooks/use-wake.js.map +1 -0
- package/x/view/index.d.ts +19 -4
- package/x/view/index.js +19 -4
- package/x/view/index.js.map +1 -1
- package/x/view/light.d.ts +2 -0
- package/x/view/light.js +41 -0
- package/x/view/light.js.map +1 -0
- package/x/view/parts/apply-attrs.d.ts +2 -0
- package/x/view/parts/apply-attrs.js +22 -0
- package/x/view/parts/apply-attrs.js.map +1 -0
- package/x/{base/utils → view/parts}/apply-styles.js.map +1 -1
- package/x/view/parts/cx.d.ts +12 -0
- package/x/view/parts/cx.js +24 -0
- package/x/view/parts/cx.js.map +1 -0
- package/x/view/parts/reactivity.d.ts +5 -0
- package/x/view/parts/reactivity.js +18 -0
- package/x/view/parts/reactivity.js.map +1 -0
- package/x/view/shadow.d.ts +6 -0
- package/x/view/shadow.js +71 -0
- package/x/view/shadow.js.map +1 -0
- package/x/view/types.d.ts +13 -21
- package/s/demo/views/counter.ts +0 -50
- package/s/demo/views/fastcount.ts +0 -29
- package/s/demo/views/mounting.ts +0 -36
- package/s/loaders/parts/error-display.ts +0 -26
- package/s/tests.test.ts +0 -8
- package/x/base/css-reset.js +0 -19
- package/x/base/css-reset.js.map +0 -1
- package/x/base/element.d.ts +0 -19
- package/x/base/element.js +0 -55
- package/x/base/element.js.map +0 -1
- package/x/base/index.d.ts +0 -5
- package/x/base/index.js +0 -6
- package/x/base/index.js.map +0 -1
- package/x/base/types.d.ts +0 -3
- package/x/base/types.js +0 -3
- package/x/base/types.js.map +0 -1
- package/x/base/use.d.ts +0 -59
- package/x/base/use.js +0 -129
- package/x/base/use.js.map +0 -1
- package/x/base/utils/attr-watcher.d.ts +0 -8
- package/x/base/utils/attr-watcher.js +0 -20
- package/x/base/utils/attr-watcher.js.map +0 -1
- package/x/base/utils/mounts.js.map +0 -1
- package/x/base/utils/reactor.d.ts +0 -5
- package/x/base/utils/reactor.js +0 -25
- package/x/base/utils/reactor.js.map +0 -1
- package/x/base/utils/states.d.ts +0 -13
- package/x/base/utils/states.js +0 -41
- package/x/base/utils/states.js.map +0 -1
- package/x/base/utils/use-attrs.d.ts +0 -11
- package/x/base/utils/use-attrs.js +0 -18
- package/x/base/utils/use-attrs.js.map +0 -1
- package/x/demo/views/counter.js +0 -42
- package/x/demo/views/counter.js.map +0 -1
- package/x/demo/views/fastcount.d.ts +0 -12
- package/x/demo/views/fastcount.js +0 -21
- package/x/demo/views/fastcount.js.map +0 -1
- package/x/demo/views/mounting.d.ts +0 -3
- package/x/demo/views/mounting.js +0 -28
- package/x/demo/views/mounting.js.map +0 -1
- package/x/loaders/index.barrel.js.map +0 -1
- package/x/loaders/index.js.map +0 -1
- package/x/loaders/make.js.map +0 -1
- package/x/loaders/mock.js.map +0 -1
- package/x/loaders/parts/anims.js.map +0 -1
- package/x/loaders/parts/ascii-anim.js.map +0 -1
- package/x/loaders/parts/error-display.d.ts +0 -1
- package/x/loaders/parts/error-display.js +0 -20
- package/x/loaders/parts/error-display.js.map +0 -1
- package/x/ops/index.js.map +0 -1
- package/x/ops/op.js.map +0 -1
- package/x/ops/podium.js.map +0 -1
- package/x/spa/index.barrel.d.ts +0 -4
- package/x/spa/index.barrel.js +0 -3
- package/x/spa/index.barrel.js.map +0 -1
- package/x/spa/index.d.ts +0 -2
- package/x/spa/index.js +0 -2
- package/x/spa/index.js.map +0 -1
- package/x/spa/plumbing/braces.d.ts +0 -12
- package/x/spa/plumbing/braces.js +0 -55
- package/x/spa/plumbing/braces.js.map +0 -1
- package/x/spa/plumbing/primitives.d.ts +0 -22
- package/x/spa/plumbing/primitives.js +0 -65
- package/x/spa/plumbing/primitives.js.map +0 -1
- package/x/spa/plumbing/router-core.d.ts +0 -13
- package/x/spa/plumbing/router-core.js +0 -38
- package/x/spa/plumbing/router-core.js.map +0 -1
- package/x/spa/plumbing/types.d.ts +0 -35
- package/x/spa/plumbing/types.js +0 -2
- package/x/spa/plumbing/types.js.map +0 -1
- package/x/spa/router.d.ts +0 -13
- package/x/spa/router.js +0 -39
- package/x/spa/router.js.map +0 -1
- package/x/spa/spa.test.d.ts +0 -15
- package/x/spa/spa.test.js +0 -78
- package/x/spa/spa.test.js.map +0 -1
- package/x/tests.test.js +0 -6
- package/x/tests.test.js.map +0 -1
- package/x/view/utils/contextualize.d.ts +0 -13
- package/x/view/utils/contextualize.js +0 -18
- package/x/view/utils/contextualize.js.map +0 -1
- package/x/view/utils/make-component.d.ts +0 -5
- package/x/view/utils/make-component.js +0 -17
- package/x/view/utils/make-component.js.map +0 -1
- package/x/view/utils/make-view.d.ts +0 -2
- package/x/view/utils/make-view.js +0 -32
- package/x/view/utils/make-view.js.map +0 -1
- package/x/view/utils/parts/capsule.d.ts +0 -12
- package/x/view/utils/parts/capsule.js +0 -56
- package/x/view/utils/parts/capsule.js.map +0 -1
- package/x/view/utils/parts/chain.d.ts +0 -13
- package/x/view/utils/parts/chain.js +0 -26
- package/x/view/utils/parts/chain.js.map +0 -1
- package/x/view/utils/parts/context.d.ts +0 -9
- package/x/view/utils/parts/context.js +0 -10
- package/x/view/utils/parts/context.js.map +0 -1
- package/x/view/utils/parts/directive.d.ts +0 -5
- package/x/view/utils/parts/directive.js +0 -20
- package/x/view/utils/parts/directive.js.map +0 -1
- package/x/view/utils/parts/naked.d.ts +0 -18
- package/x/view/utils/parts/naked.js +0 -57
- package/x/view/utils/parts/naked.js.map +0 -1
- package/x/view/utils/parts/sly-view.d.ts +0 -6
- package/x/view/utils/parts/sly-view.js +0 -16
- package/x/view/utils/parts/sly-view.js.map +0 -1
- package/x/view/view.d.ts +0 -11
- package/x/view/view.js +0 -15
- package/x/view/view.js.map +0 -1
- /package/s/{base → _archive/base}/css-reset.ts +0 -0
- /package/s/{base → _archive/base}/element.ts +0 -0
- /package/s/{base → _archive/base}/index.ts +0 -0
- /package/s/{base → _archive/base}/types.ts +0 -0
- /package/s/{base → _archive/base}/use.ts +0 -0
- /package/s/{base → _archive/base}/utils/apply-styles.ts +0 -0
- /package/s/{base → _archive/base}/utils/attr-watcher.ts +0 -0
- /package/s/{base → _archive/base}/utils/mounts.ts +0 -0
- /package/s/{base → _archive/base}/utils/reactor.ts +0 -0
- /package/s/{base → _archive/base}/utils/states.ts +0 -0
- /package/s/{base → _archive/base}/utils/use-attrs.ts +0 -0
- /package/s/{spa → _archive/spa}/index.barrel.ts +0 -0
- /package/s/{spa → _archive/spa}/index.ts +0 -0
- /package/s/{spa → _archive/spa}/plumbing/braces.ts +0 -0
- /package/s/{spa → _archive/spa}/plumbing/primitives.ts +0 -0
- /package/s/{spa → _archive/spa}/plumbing/router-core.ts +0 -0
- /package/s/{spa → _archive/spa}/plumbing/types.ts +0 -0
- /package/s/{spa → _archive/spa}/router.ts +0 -0
- /package/s/{spa → _archive/spa}/spa.test.ts +0 -0
- /package/s/{view → _archive/view}/utils/contextualize.ts +0 -0
- /package/s/{view → _archive/view}/utils/make-component.ts +0 -0
- /package/s/{view → _archive/view}/utils/make-view.ts +0 -0
- /package/s/{view → _archive/view}/utils/parts/capsule.ts +0 -0
- /package/s/{view → _archive/view}/utils/parts/chain.ts +0 -0
- /package/s/{view → _archive/view}/utils/parts/context.ts +0 -0
- /package/s/{view → _archive/view}/utils/parts/directive.ts +0 -0
- /package/s/{view → _archive/view}/utils/parts/naked.ts +0 -0
- /package/s/{view → _archive/view}/utils/parts/sly-view.ts +0 -0
- /package/s/{view → _archive/view}/view.ts +0 -0
- /package/s/{loaders → loader}/mock.ts +0 -0
- /package/s/{loaders → loader}/parts/anims.ts +0 -0
- /package/s/{ops → op}/index.ts +0 -0
- /package/s/{ops → op}/op.ts +0 -0
- /package/s/{ops → op}/podium.ts +0 -0
- /package/s/{ops → op}/types.ts +0 -0
- /package/x/{loaders → loader}/index.barrel.js +0 -0
- /package/x/{loaders → loader}/index.js +0 -0
- /package/x/{loaders → loader}/make.js +0 -0
- /package/x/{loaders → loader}/mock.d.ts +0 -0
- /package/x/{loaders → loader}/mock.js +0 -0
- /package/x/{loaders → loader}/parts/anims.d.ts +0 -0
- /package/x/{loaders → loader}/parts/anims.js +0 -0
- /package/x/{loaders → loader}/types.js +0 -0
- /package/x/{ops → op}/index.d.ts +0 -0
- /package/x/{ops → op}/index.js +0 -0
- /package/x/{ops → op}/op.d.ts +0 -0
- /package/x/{ops → op}/op.js +0 -0
- /package/x/{ops → op}/podium.d.ts +0 -0
- /package/x/{ops → op}/podium.js +0 -0
- /package/x/{ops → op}/types.d.ts +0 -0
- /package/x/{ops → op}/types.js +0 -0
- /package/x/{tests.test.d.ts → test.d.ts} +0 -0
- /package/x/{base → view/common}/css-reset.d.ts +0 -0
- /package/x/{base/utils → view/parts}/apply-styles.d.ts +0 -0
- /package/x/{base/utils → view/parts}/apply-styles.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useHost } from "./use-cx.js";
|
|
2
|
+
import { useOnce } from "./use-once.js";
|
|
3
|
+
/** sets the host element's "data-view" attribute */
|
|
4
|
+
export function useName(name = "") {
|
|
5
|
+
const host = useHost();
|
|
6
|
+
useOnce(() => host.setAttribute("view", name));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=use-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-name.js","sourceRoot":"","sources":["../../../s/view/hooks/use-name.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,oDAAoD;AACpD,MAAM,UAAU,OAAO,CAAC,IAAI,GAAG,EAAE;IAChC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IACtB,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-once.js","sourceRoot":"","sources":["../../../s/view/hooks/use-once.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAA;AAEzC,+BAA+B;AAC/B,MAAM,UAAU,OAAO,CAAQ,EAAe;IAC7C,MAAM,EAAC,KAAK,EAAE,QAAQ,EAAC,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAC3C,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAU,CAAA;AACrD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Op } from "../../op/op.js";
|
|
2
|
+
import { useOnce } from "./use-once.js";
|
|
3
|
+
export function useOp(fn) {
|
|
4
|
+
return useOnce(() => Op.load(fn));
|
|
5
|
+
}
|
|
6
|
+
export function useOpPromise(promise) {
|
|
7
|
+
return useOnce(() => Op.promise(promise));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=use-op.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-op.js","sourceRoot":"","sources":["../../../s/view/hooks/use-op.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,gBAAgB,CAAA;AACjC,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,MAAM,UAAU,KAAK,CAAQ,EAAwB;IACpD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,YAAY,CAAQ,OAAuB;IAC1D,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-ref.js","sourceRoot":"","sources":["../../../s/view/hooks/use-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,MAAM,UAAU,MAAM,CAAQ,OAAc;IAC3C,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,OAAO,GAAG;IACI;IAAnB,YAAmB,OAAc;QAAd,YAAO,GAAP,OAAO,CAAO;IAAG,CAAC;CACrC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function useSignal<Value>(value: Value): import("@e280/strata").Signal<Value>;
|
|
2
|
+
export declare function useDerived<Value>(fn: () => Value): import("@e280/strata").Derived<Value>;
|
|
3
|
+
export declare function useLazy<Value>(fn: () => Value): import("@e280/strata").Lazy<Value>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { signal } from "@e280/strata";
|
|
2
|
+
import { useOnce } from "./use-once.js";
|
|
3
|
+
export function useSignal(value) {
|
|
4
|
+
return useOnce(() => signal(value));
|
|
5
|
+
}
|
|
6
|
+
export function useDerived(fn) {
|
|
7
|
+
return useOnce(() => signal.derived(fn));
|
|
8
|
+
}
|
|
9
|
+
export function useLazy(fn) {
|
|
10
|
+
return useOnce(() => signal.lazy(fn));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=use-signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-signal.js","sourceRoot":"","sources":["../../../s/view/hooks/use-signal.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,MAAM,UAAU,SAAS,CAAQ,KAAY;IAC5C,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,UAAU,CAAQ,EAAe;IAChD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,OAAO,CAAQ,EAAe;IAC7C,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useState<Value>(value: Value): readonly [Value, (next: Value | ((prev: Value) => Value)) => void];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useRef } from "./use-ref.js";
|
|
2
|
+
import { useRender } from "./use-cx.js";
|
|
3
|
+
export function useState(value) {
|
|
4
|
+
const render = useRender();
|
|
5
|
+
const ref = useRef(value);
|
|
6
|
+
const set = (next) => {
|
|
7
|
+
const value = typeof next === "function"
|
|
8
|
+
? next(ref.current)
|
|
9
|
+
: next;
|
|
10
|
+
if (Object.is(value, ref.current))
|
|
11
|
+
return;
|
|
12
|
+
ref.current = value;
|
|
13
|
+
render();
|
|
14
|
+
};
|
|
15
|
+
return [ref.current, set];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=use-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-state.js","sourceRoot":"","sources":["../../../s/view/hooks/use-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AAErC,MAAM,UAAU,QAAQ,CAAQ,KAAY;IAC3C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAEzB,MAAM,GAAG,GAAG,CAAC,IAAsC,EAAE,EAAE;QACtD,MAAM,KAAK,GAAG,OAAO,IAAI,KAAK,UAAU;YACvC,CAAC,CAAE,IAA+B,CAAC,GAAG,CAAC,OAAO,CAAC;YAC/C,CAAC,CAAC,IAAI,CAAA;QACP,IAAI,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC;YAAE,OAAM;QACzC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;QACnB,MAAM,EAAE,CAAA;IACT,CAAC,CAAA;IAED,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAU,CAAA;AACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-wake.js","sourceRoot":"","sources":["../../../s/view/hooks/use-wake.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC,8CAA8C;AAC9C,MAAM,UAAU,OAAO,CAAQ,EAAe;IAC7C,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAA;AACvC,CAAC"}
|
package/x/view/index.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
1
|
+
export * from "./common/css-reset.js";
|
|
2
|
+
export * from "./common/sly-shadow.js";
|
|
3
|
+
export * from "./elements/light.js";
|
|
4
|
+
export * from "./elements/shadow.js";
|
|
5
|
+
export * from "./hooks/use-attrs.js";
|
|
6
|
+
export * from "./hooks/use-css.js";
|
|
7
|
+
export * from "./hooks/use-cx.js";
|
|
8
|
+
export * from "./hooks/use-life.js";
|
|
9
|
+
export * from "./hooks/use-mount.js";
|
|
10
|
+
export * from "./hooks/use-name.js";
|
|
11
|
+
export * from "./hooks/use-once.js";
|
|
12
|
+
export * from "./hooks/use-op.js";
|
|
13
|
+
export * from "./hooks/use-ref.js";
|
|
14
|
+
export * from "./hooks/use-signal.js";
|
|
15
|
+
export * from "./hooks/use-state.js";
|
|
16
|
+
export * from "./hooks/use-cx.js";
|
|
17
|
+
export * from "./hooks/use-wake.js";
|
|
18
|
+
export * from "./light.js";
|
|
19
|
+
export * from "./shadow.js";
|
|
4
20
|
export * from "./types.js";
|
|
5
|
-
export * from "./view.js";
|
package/x/view/index.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
1
|
+
export * from "./common/css-reset.js";
|
|
2
|
+
export * from "./common/sly-shadow.js";
|
|
3
|
+
export * from "./elements/light.js";
|
|
4
|
+
export * from "./elements/shadow.js";
|
|
5
|
+
export * from "./hooks/use-attrs.js";
|
|
6
|
+
export * from "./hooks/use-css.js";
|
|
7
|
+
export * from "./hooks/use-cx.js";
|
|
8
|
+
export * from "./hooks/use-life.js";
|
|
9
|
+
export * from "./hooks/use-mount.js";
|
|
10
|
+
export * from "./hooks/use-name.js";
|
|
11
|
+
export * from "./hooks/use-once.js";
|
|
12
|
+
export * from "./hooks/use-op.js";
|
|
13
|
+
export * from "./hooks/use-ref.js";
|
|
14
|
+
export * from "./hooks/use-signal.js";
|
|
15
|
+
export * from "./hooks/use-state.js";
|
|
16
|
+
export * from "./hooks/use-cx.js";
|
|
17
|
+
export * from "./hooks/use-wake.js";
|
|
18
|
+
export * from "./light.js";
|
|
19
|
+
export * from "./shadow.js";
|
|
4
20
|
export * from "./types.js";
|
|
5
|
-
export * from "./view.js";
|
|
6
21
|
//# sourceMappingURL=index.js.map
|
package/x/view/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../s/view/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../s/view/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AAEtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AAEnC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
package/x/view/light.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { microbounce } from "@e280/stz";
|
|
2
|
+
import { LightCx } from "./parts/cx.js";
|
|
3
|
+
import { hooks } from "./hooks/plumbing/hooks.js";
|
|
4
|
+
import { Reactivity } from "./parts/reactivity.js";
|
|
5
|
+
import { Hookscope } from "./hooks/plumbing/hookscope.js";
|
|
6
|
+
import { AsyncDirective, directive } from "lit/async-directive.js";
|
|
7
|
+
export function light(view) {
|
|
8
|
+
return directive(class D extends AsyncDirective {
|
|
9
|
+
#props;
|
|
10
|
+
#cx = new LightCx(microbounce(() => {
|
|
11
|
+
if (!this.#props)
|
|
12
|
+
throw new Error("cannot render before props");
|
|
13
|
+
if (this.isConnected) {
|
|
14
|
+
const content = this.render(...this.#props);
|
|
15
|
+
this.setValue(content);
|
|
16
|
+
this.#cx.doneRender();
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
#hookscope = new Hookscope(this.#cx);
|
|
20
|
+
#reactivity = new Reactivity();
|
|
21
|
+
update(part, props) {
|
|
22
|
+
const ret = super.update(part, props);
|
|
23
|
+
if (this.isConnected)
|
|
24
|
+
this.#cx.doneRender();
|
|
25
|
+
return ret;
|
|
26
|
+
}
|
|
27
|
+
render(...props) {
|
|
28
|
+
this.#props = props;
|
|
29
|
+
return this.#reactivity.observe(() => hooks.wrap(this.#hookscope, () => view(...this.#props)), this.#cx.render);
|
|
30
|
+
}
|
|
31
|
+
disconnected() {
|
|
32
|
+
this.#hookscope.mounts.unmountAll();
|
|
33
|
+
this.#reactivity.clear();
|
|
34
|
+
}
|
|
35
|
+
reconnected() {
|
|
36
|
+
this.#hookscope.mounts.remountAll();
|
|
37
|
+
this.#cx.render();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
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AAE,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAA;YAC3C,OAAO,GAAG,CAAA;QACX,CAAC;QAED,MAAM,CAAC,GAAG,KAAY;YACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;YACnB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAC9B,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAC7D,IAAI,CAAC,GAAG,CAAC,MAAM,CACf,CAAA;QACF,CAAC;QAED,YAAY;YACX,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAA;YACnC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;QACzB,CAAC;QAED,WAAW;YACV,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAA;YACnC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;QAClB,CAAC;KACD,CAAgB,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function applyAttrs(element, attrs) {
|
|
2
|
+
for (const [name, value] of Object.entries(attrs))
|
|
3
|
+
applyAttr(element, name, value);
|
|
4
|
+
}
|
|
5
|
+
function applyAttr(element, name, value) {
|
|
6
|
+
const existing = element.getAttribute(name);
|
|
7
|
+
const v = coerce(value);
|
|
8
|
+
if (v === existing)
|
|
9
|
+
return;
|
|
10
|
+
if (v === null)
|
|
11
|
+
element.removeAttribute(name);
|
|
12
|
+
else
|
|
13
|
+
element.setAttribute(name, v);
|
|
14
|
+
}
|
|
15
|
+
function coerce(value) {
|
|
16
|
+
if (typeof value === "string")
|
|
17
|
+
return value;
|
|
18
|
+
else if (typeof value === "number")
|
|
19
|
+
return value.toString();
|
|
20
|
+
return value ? "" : null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=apply-attrs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-attrs.js","sourceRoot":"","sources":["../../../s/view/parts/apply-attrs.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,KAAgB;IAChE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAChD,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;AACjC,CAAC;AAED,SAAS,SAAS,CAAC,OAAoB,EAAE,IAAY,EAAE,KAAe;IACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAC3C,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACvB,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAM;IAC1B,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;;QACxC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;AACnC,CAAC;AAED,SAAS,MAAM,CAAC,KAAe;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;SACtC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;IAC3D,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-styles.js","sourceRoot":"","sources":["../../../s/
|
|
1
|
+
{"version":3,"file":"apply-styles.js","sourceRoot":"","sources":["../../../s/view/parts/apply-styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAqC,kBAAkB,EAAC,MAAM,KAAK,CAAA;AAEtF,MAAM,UAAU,WAAW,CAAC,MAAkB,EAAE,MAAuB;IACtE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,aAAa,CAAC,MAAuB;IAC7C,MAAM,aAAa,GAAG,EAAE,CAAA;IAExB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAE,MAAyB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QACxE,KAAK,MAAM,CAAC,IAAI,GAAG;YAClB,aAAa,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAsB,CAAC,CAAC,CAAA;IACnE,CAAC;SACI,IAAI,MAAM,KAAK,SAAS;QAC5B,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAA;IAE/C,OAAO,aAAa,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class LightCx {
|
|
2
|
+
render: () => Promise<void>;
|
|
3
|
+
count: number;
|
|
4
|
+
rendered: import("@e280/stz").Deferred<void>;
|
|
5
|
+
constructor(render: () => Promise<void>);
|
|
6
|
+
doneRender(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class ShadowCx extends LightCx {
|
|
9
|
+
host: HTMLElement;
|
|
10
|
+
shadow: ShadowRoot;
|
|
11
|
+
constructor(render: () => Promise<void>, host: HTMLElement, shadow: ShadowRoot);
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defer } from "@e280/stz";
|
|
2
|
+
export class LightCx {
|
|
3
|
+
render;
|
|
4
|
+
count = 0;
|
|
5
|
+
rendered = defer();
|
|
6
|
+
constructor(render) {
|
|
7
|
+
this.render = render;
|
|
8
|
+
}
|
|
9
|
+
doneRender() {
|
|
10
|
+
this.count++;
|
|
11
|
+
this.rendered.resolve();
|
|
12
|
+
this.rendered = defer();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class ShadowCx extends LightCx {
|
|
16
|
+
host;
|
|
17
|
+
shadow;
|
|
18
|
+
constructor(render, host, shadow) {
|
|
19
|
+
super(render);
|
|
20
|
+
this.host = host;
|
|
21
|
+
this.shadow = shadow;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=cx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cx.js","sourceRoot":"","sources":["../../../s/view/parts/cx.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAE/B,MAAM,OAAO,OAAO;IAIA;IAHnB,KAAK,GAAG,CAAC,CAAA;IACT,QAAQ,GAAG,KAAK,EAAQ,CAAA;IAExB,YAAmB,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAG,CAAC;IAElD,UAAU;QACT,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;QACvB,IAAI,CAAC,QAAQ,GAAG,KAAK,EAAE,CAAA;IACxB,CAAC;CACD;AAED,MAAM,OAAO,QAAS,SAAQ,OAAO;IAG3B;IACA;IAHT,YACE,MAA2B,EACpB,IAAiB,EACjB,MAAkB;QAE1B,KAAK,CAAC,MAAM,CAAC,CAAA;QAHL,SAAI,GAAJ,IAAI,CAAa;QACjB,WAAM,GAAN,MAAM,CAAY;IAG3B,CAAC;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tracker } from "@e280/strata";
|
|
2
|
+
export class Reactivity {
|
|
3
|
+
#stoppers = [];
|
|
4
|
+
clear() {
|
|
5
|
+
this.#stoppers.forEach(stop => stop());
|
|
6
|
+
this.#stoppers = [];
|
|
7
|
+
}
|
|
8
|
+
observe(fn, rerender) {
|
|
9
|
+
const { seen, result } = tracker.observe(fn);
|
|
10
|
+
this.clear();
|
|
11
|
+
for (const item of seen) {
|
|
12
|
+
const stop = tracker.subscribe(item, rerender);
|
|
13
|
+
this.#stoppers.push(stop);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=reactivity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactivity.js","sourceRoot":"","sources":["../../../s/view/parts/reactivity.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AAEpC,MAAM,OAAO,UAAU;IACtB,SAAS,GAAmB,EAAE,CAAA;IAE9B,KAAK;QACJ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;QACtC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;IACpB,CAAC;IAED,OAAO,CAAI,EAAW,EAAE,QAA6B;QACpD,MAAM,EAAC,IAAI,EAAE,MAAM,EAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC1C,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YAC9C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC1B,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { View, ShadowSetup, ShadowView } from "./types.js";
|
|
2
|
+
export declare function shadowSetup(): ShadowSetup;
|
|
3
|
+
export declare function shadow<Props extends any[]>(view: View<Props>): ShadowView<Props>;
|
|
4
|
+
export declare namespace shadow {
|
|
5
|
+
var setup: (setup: () => ShadowSetup) => <Props extends any[]>(view: View<Props>) => ShadowView<Props>;
|
|
6
|
+
}
|
package/x/view/shadow.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { microbounce } from "@e280/stz";
|
|
2
|
+
import { render as litRender } from "lit";
|
|
3
|
+
import { ShadowCx } from "./parts/cx.js";
|
|
4
|
+
import { hooks } from "./hooks/plumbing/hooks.js";
|
|
5
|
+
import { SlyShadow } from "./common/sly-shadow.js";
|
|
6
|
+
import { Reactivity } from "./parts/reactivity.js";
|
|
7
|
+
import { applyAttrs } from "./parts/apply-attrs.js";
|
|
8
|
+
import { Hookscope } from "./hooks/plumbing/hookscope.js";
|
|
9
|
+
import { AsyncDirective, directive } from "lit/async-directive.js";
|
|
10
|
+
export function shadowSetup() {
|
|
11
|
+
SlyShadow.register();
|
|
12
|
+
const host = document.createElement("sly-shadow");
|
|
13
|
+
const shadow = host.attachShadow({ mode: "open" });
|
|
14
|
+
return { host, shadow };
|
|
15
|
+
}
|
|
16
|
+
export function shadow(view) {
|
|
17
|
+
return rawShadow(shadowSetup, view);
|
|
18
|
+
}
|
|
19
|
+
shadow.setup = (setup) => ((view) => (rawShadow(setup, view)));
|
|
20
|
+
function rawShadow(setup, view) {
|
|
21
|
+
const directiveFn = directive(class extends AsyncDirective {
|
|
22
|
+
#cx;
|
|
23
|
+
#hookscope;
|
|
24
|
+
#props;
|
|
25
|
+
#reactivity = new Reactivity();
|
|
26
|
+
constructor(part) {
|
|
27
|
+
super(part);
|
|
28
|
+
const { host, shadow } = setup();
|
|
29
|
+
const rerender = microbounce(() => {
|
|
30
|
+
if (!this.#props)
|
|
31
|
+
throw new Error("cannot render before props");
|
|
32
|
+
if (!this.isConnected)
|
|
33
|
+
return;
|
|
34
|
+
const content = this.#renderContent(this.#props);
|
|
35
|
+
litRender(content, this.#cx.shadow);
|
|
36
|
+
this.#cx.doneRender();
|
|
37
|
+
});
|
|
38
|
+
this.#cx = new ShadowCx(rerender, host, shadow);
|
|
39
|
+
this.#hookscope = new Hookscope(this.#cx);
|
|
40
|
+
}
|
|
41
|
+
#renderContent(props) {
|
|
42
|
+
this.#props = props;
|
|
43
|
+
return this.#reactivity.observe(() => hooks.wrap(this.#hookscope, () => view(...this.#props)), this.#cx.render);
|
|
44
|
+
}
|
|
45
|
+
render({ props, children, attrs }) {
|
|
46
|
+
const { host } = this.#cx;
|
|
47
|
+
if (!this.isConnected)
|
|
48
|
+
return host;
|
|
49
|
+
if (attrs)
|
|
50
|
+
applyAttrs(host, attrs);
|
|
51
|
+
litRender(children, this.#cx.host);
|
|
52
|
+
litRender(this.#renderContent(props), this.#cx.shadow);
|
|
53
|
+
this.#cx.doneRender();
|
|
54
|
+
return host;
|
|
55
|
+
}
|
|
56
|
+
disconnected() {
|
|
57
|
+
this.#hookscope.mounts.unmountAll();
|
|
58
|
+
this.#reactivity.clear();
|
|
59
|
+
}
|
|
60
|
+
reconnected() {
|
|
61
|
+
this.#hookscope.mounts.remountAll();
|
|
62
|
+
this.#cx.render();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
function shadowView(...props) {
|
|
66
|
+
return directiveFn({ props });
|
|
67
|
+
}
|
|
68
|
+
shadowView.with = directiveFn;
|
|
69
|
+
return shadowView;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=shadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow.js","sourceRoot":"","sources":["../../s/view/shadow.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAA;AACrC,OAAO,EAAC,MAAM,IAAI,SAAS,EAAC,MAAM,KAAK,CAAA;AAEvC,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,KAAK,EAAC,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAC,SAAS,EAAC,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KAAK,EAAE,CAAA;QACzB,CAAC;QAED,WAAW;YACV,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAA;YACnC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;QAClB,CAAC;KACD,CAAmC,CAAA;IAEpC,SAAS,UAAU,CAAC,GAAG,KAAY;QAClC,OAAO,WAAW,CAAC,EAAC,KAAK,EAAC,CAAC,CAAA;IAC5B,CAAC;IAED,UAAU,CAAC,IAAI,GAAG,WAAW,CAAA;IAE7B,OAAO,UAA+B,CAAA;AACvC,CAAC"}
|
package/x/view/types.d.ts
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { TemplateResult } from "lit";
|
|
2
|
-
import {
|
|
3
|
-
import { DirectiveResult } from "lit/directive.js";
|
|
4
|
-
import { Use } from "../base/use.js";
|
|
5
|
-
import { BaseElement } from "../base/element.js";
|
|
6
|
-
import { ViewChain } from "./utils/parts/chain.js";
|
|
2
|
+
import { DirectiveResult } from "lit/async-directive.js";
|
|
7
3
|
export type Content = TemplateResult | DirectiveResult | HTMLElement | string | null | undefined | void | Content[];
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
naked: (host: HTMLElement) => NakedView<Props>;
|
|
4
|
+
export type View<Props extends any[]> = (...props: Props) => Content;
|
|
5
|
+
export type ViewAttr = string | number | boolean;
|
|
6
|
+
export type ViewAttrs = Record<string, ViewAttr>;
|
|
7
|
+
export type Placement<Props extends any[]> = {
|
|
8
|
+
props: Props;
|
|
9
|
+
children?: Content;
|
|
10
|
+
attrs?: ViewAttrs;
|
|
17
11
|
};
|
|
18
|
-
export type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} & B;
|
|
23
|
-
export type NakedView<Props extends any[]> = {
|
|
12
|
+
export type ShadowView<Props extends any[]> = View<Props> & {
|
|
13
|
+
with: (placement: Placement<Props>) => Content;
|
|
14
|
+
};
|
|
15
|
+
export type ShadowSetup = {
|
|
24
16
|
host: HTMLElement;
|
|
25
|
-
|
|
17
|
+
shadow: ShadowRoot;
|
|
26
18
|
};
|
package/s/demo/views/counter.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {css, html} from "lit"
|
|
3
|
-
|
|
4
|
-
import {dom} from "../../dom/dom.js"
|
|
5
|
-
import {view} from "../../view/view.js"
|
|
6
|
-
import {cssReset} from "../../base/css-reset.js"
|
|
7
|
-
import {BaseElement} from "../../base/element.js"
|
|
8
|
-
|
|
9
|
-
export const CounterView = view(use => (start: number, step: number) => {
|
|
10
|
-
use.name("counter")
|
|
11
|
-
use.styles(cssReset, styles)
|
|
12
|
-
|
|
13
|
-
const $count = use.signal(start)
|
|
14
|
-
const increment = () => { $count.value += step }
|
|
15
|
-
|
|
16
|
-
return html`
|
|
17
|
-
<slot></slot>
|
|
18
|
-
<div>
|
|
19
|
-
<span>${$count()}</span>
|
|
20
|
-
</div>
|
|
21
|
-
<div>
|
|
22
|
-
<button @click="${increment}">++</button>
|
|
23
|
-
</div>
|
|
24
|
-
`
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
// convert a view into a web component
|
|
28
|
-
export class CounterComponent extends (
|
|
29
|
-
CounterView
|
|
30
|
-
.component(class extends BaseElement {
|
|
31
|
-
attrs = dom.attrs(this).spec({
|
|
32
|
-
start: Number,
|
|
33
|
-
step: Number,
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
.props(c => [c.attrs.start ?? 0, c.attrs.step ?? 1])
|
|
37
|
-
) {}
|
|
38
|
-
|
|
39
|
-
const styles = css`
|
|
40
|
-
:host {
|
|
41
|
-
display: flex;
|
|
42
|
-
justify-content: center;
|
|
43
|
-
gap: 1em;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
button {
|
|
47
|
-
padding: 0.2em 0.5em;
|
|
48
|
-
}
|
|
49
|
-
`
|
|
50
|
-
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {css, html} from "lit"
|
|
3
|
-
import {nap, cycle} from "@e280/stz"
|
|
4
|
-
|
|
5
|
-
import {dom} from "../../dom/dom.js"
|
|
6
|
-
import {Use} from "../../base/use.js"
|
|
7
|
-
import {BaseElement} from "../../base/element.js"
|
|
8
|
-
|
|
9
|
-
export class FastcountElement extends BaseElement {
|
|
10
|
-
static styles = css`span{color:orange}`
|
|
11
|
-
|
|
12
|
-
attrs = dom.attrs(this).spec({value: Number})
|
|
13
|
-
something = {whatever: "rofl"}
|
|
14
|
-
|
|
15
|
-
render(use: Use) {
|
|
16
|
-
const {value = 1} = this.attrs
|
|
17
|
-
const $count = use.signal(0)
|
|
18
|
-
|
|
19
|
-
use.mount(() => cycle(async() => {
|
|
20
|
-
await nap(10)
|
|
21
|
-
await $count($count() + 1)
|
|
22
|
-
}))
|
|
23
|
-
|
|
24
|
-
return html`
|
|
25
|
-
<span>${$count() * value}</span>
|
|
26
|
-
`
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
package/s/demo/views/mounting.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {html} from "lit"
|
|
3
|
-
import {cycle, nap} from "@e280/stz"
|
|
4
|
-
import {view} from "../../view/view.js"
|
|
5
|
-
|
|
6
|
-
export const MountingTest = view(use => () => {
|
|
7
|
-
const $toggle = use.signal(false)
|
|
8
|
-
|
|
9
|
-
use.mount(() => cycle(async() => {
|
|
10
|
-
await nap(1000)
|
|
11
|
-
$toggle(!$toggle())
|
|
12
|
-
}))
|
|
13
|
-
|
|
14
|
-
return $toggle()
|
|
15
|
-
? TestAlpha()
|
|
16
|
-
: html`bravo`
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
export const TestAlpha = view(() => () => {
|
|
20
|
-
return html`
|
|
21
|
-
<span>${TestCharlie()}</span>
|
|
22
|
-
`
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export const TestCharlie = view(use => () => {
|
|
27
|
-
use.mount(() => {
|
|
28
|
-
// console.log("mount")
|
|
29
|
-
return () => {
|
|
30
|
-
// console.log("unmount")
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
return html`charlie`
|
|
35
|
-
})
|
|
36
|
-
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {css, html} from "lit"
|
|
3
|
-
import {view} from "../../view/view.js"
|
|
4
|
-
import {cssReset} from "../../base/css-reset.js"
|
|
5
|
-
|
|
6
|
-
export const ErrorDisplay = view(use => (error: any) => {
|
|
7
|
-
use.name("error")
|
|
8
|
-
use.styles(cssReset, style)
|
|
9
|
-
|
|
10
|
-
if (typeof error === "string")
|
|
11
|
-
return error
|
|
12
|
-
|
|
13
|
-
else if (error instanceof Error)
|
|
14
|
-
return html`<strong>${error.name}:</strong> <span>${error.message}</span>`
|
|
15
|
-
|
|
16
|
-
else
|
|
17
|
-
return `error`
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const style = css`
|
|
21
|
-
:host {
|
|
22
|
-
font-family: monospace;
|
|
23
|
-
color: red;
|
|
24
|
-
}
|
|
25
|
-
`
|
|
26
|
-
|