@e280/sly 0.2.4 → 0.3.0-1
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 +302 -614
- package/package.json +6 -8
- package/s/_archive/README.md +1221 -0
- package/s/{base → _archive/base}/element.ts +5 -2
- package/s/_archive/view/index.ts +7 -0
- package/s/_archive/view/types.ts +45 -0
- package/s/{view → _archive/view}/utils/parts/capsule.ts +9 -2
- package/s/demo/demo.bundle.ts +2 -9
- 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 -18
- package/s/demo/views/loaders.ts +7 -7
- package/s/index.html.ts +30 -33
- package/s/index.ts +0 -2
- package/s/loaders/make.ts +1 -1
- package/s/loaders/parts/ascii-anim.ts +6 -8
- package/s/loaders/parts/error-display.ts +9 -9
- package/s/tests.test.ts +1 -4
- package/s/view/common/css-reset.ts +19 -0
- package/s/view/hooks/plumbing/hooks.ts +28 -0
- package/s/view/hooks/plumbing/hookscope.ts +12 -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 +17 -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/parts/sly-shadow.ts +8 -0
- package/s/view/shadow.ts +93 -0
- package/s/view/types.ts +15 -34
- package/x/demo/demo.bundle.js +2 -8
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +45 -58
- 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 +23 -18
- package/x/demo/views/demo.js.map +1 -1
- package/x/demo/views/loaders.d.ts +1 -1
- package/x/demo/views/loaders.js +7 -7
- package/x/demo/views/loaders.js.map +1 -1
- package/x/index.d.ts +0 -2
- 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 +0 -2
- package/x/index.js.map +1 -1
- package/x/loaders/make.d.ts +1 -1
- package/x/loaders/parts/ascii-anim.d.ts +1 -1
- package/x/loaders/parts/ascii-anim.js +6 -7
- package/x/loaders/parts/ascii-anim.js.map +1 -1
- package/x/loaders/parts/error-display.d.ts +1 -1
- package/x/loaders/parts/error-display.js +9 -9
- package/x/loaders/parts/error-display.js.map +1 -1
- package/x/tests.test.js +1 -4
- package/x/tests.test.js.map +1 -1
- package/x/view/common/css-reset.js +17 -0
- package/x/view/common/css-reset.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-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 +15 -4
- package/x/view/index.js +15 -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/parts/sly-shadow.d.ts +3 -0
- package/x/view/parts/sly-shadow.js +7 -0
- package/x/view/parts/sly-shadow.js.map +1 -0
- package/x/view/shadow.d.ts +6 -0
- package/x/view/shadow.js +72 -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/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 -52
- 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.d.ts +0 -374
- 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/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/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 -50
- 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}/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/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/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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../../s/spa/plumbing/primitives.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAE,EAAE,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,EAAE,EAAC,MAAM,iBAAiB,CAAA;AAGlC,MAAM,UAAU,eAAe;IAC9B,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAC,GAAG,MAAM,CAAC,QAAQ,CAAA;IAC1C,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;IAC9C,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,CAAA;AACR,CAAC;AAED,MAAM,OAAO,cAAc;IACP;IAAnB,YAAmB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEzC,IAAI,IAAI;QACP,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC9C,IAAI,IAAI,KAAK,IAAI;YAAE,eAAe,EAAE,CAAA;QACpC,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,IAAI,IAAI,CAAC,IAAY;QACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAA;IAC1B,CAAC;CACD;AAED,MAAM,OAAO,SAAS;IAeb;IACC;IACD;IAhBR,MAAM,CAAC,GAAG,CACR,MAAS,EACT,QAA4B,EAC5B,QAAkD;QAGnD,OAAO,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AA;AACpC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Content } from "../../view/types.js";
|
|
2
|
-
import { Hashbearer, Navigables, ResolvedRoute, Routes } from "./types.js";
|
|
3
|
-
export declare class RouterCore<R extends Routes> {
|
|
4
|
-
readonly routes: R;
|
|
5
|
-
readonly location: Hashbearer;
|
|
6
|
-
readonly nav: Navigables<R>;
|
|
7
|
-
readonly $resolved: import("@e280/strata").SignalFn<ResolvedRoute | null>;
|
|
8
|
-
constructor(routes: R, location: Hashbearer);
|
|
9
|
-
get hash(): string;
|
|
10
|
-
get content(): Content | null;
|
|
11
|
-
get route(): import("./types.js").Route<any[]> | null;
|
|
12
|
-
refresh(hash?: string): Promise<ResolvedRoute | null>;
|
|
13
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { signal } from "@e280/strata";
|
|
2
|
-
import { Navigable, normalizeHash, resolveRoute } from "./primitives.js";
|
|
3
|
-
export class RouterCore {
|
|
4
|
-
routes;
|
|
5
|
-
location;
|
|
6
|
-
nav;
|
|
7
|
-
$resolved = signal(null);
|
|
8
|
-
constructor(routes, location) {
|
|
9
|
-
this.routes = routes;
|
|
10
|
-
this.location = location;
|
|
11
|
-
this.nav = Navigable.all(routes, () => this.route, async (hash) => {
|
|
12
|
-
this.location.hash = hash;
|
|
13
|
-
const resolved = await this.refresh();
|
|
14
|
-
if (!resolved)
|
|
15
|
-
throw new Error(`route failed "${hash}"`);
|
|
16
|
-
return resolved;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
get hash() {
|
|
20
|
-
return normalizeHash(this.location.hash);
|
|
21
|
-
}
|
|
22
|
-
get content() {
|
|
23
|
-
return this.$resolved.get()?.op.value ?? null;
|
|
24
|
-
}
|
|
25
|
-
get route() {
|
|
26
|
-
return this.$resolved.get()?.route ?? null;
|
|
27
|
-
}
|
|
28
|
-
async refresh(hash) {
|
|
29
|
-
if (hash !== undefined)
|
|
30
|
-
this.location.hash = hash;
|
|
31
|
-
hash = this.hash;
|
|
32
|
-
const resolved = resolveRoute(hash, this.routes);
|
|
33
|
-
await this.$resolved.set(resolved);
|
|
34
|
-
await resolved?.op;
|
|
35
|
-
return resolved;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=router-core.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router-core.js","sourceRoot":"","sources":["../../../s/spa/plumbing/router-core.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAC,SAAS,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAGtE,MAAM,OAAO,UAAU;IAKJ;IACA;IALT,GAAG,CAAe;IAClB,SAAS,GAAG,MAAM,CAAuB,IAAI,CAAC,CAAA;IAEvD,YACkB,MAAS,EACT,QAAoB;QADpB,WAAM,GAAN,MAAM,CAAG;QACT,aAAQ,GAAR,QAAQ,CAAY;QAGrC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CACvB,MAAM,EACN,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAChB,KAAK,EAAC,IAAI,EAAC,EAAE;YACZ,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAA;YACzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;YACrC,IAAI,CAAC,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAA;YACxD,OAAO,QAAQ,CAAA;QAChB,CAAC,CACD,CAAA;IACF,CAAC;IAED,IAAI,IAAI;QACP,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAA;IAC9C,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,IAAI,IAAI,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAa;QAC1B,IAAI,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAA;QACjD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QAChB,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAChD,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAClC,MAAM,QAAQ,EAAE,EAAE,CAAA;QAClB,OAAO,QAAQ,CAAA;IAChB,CAAC;CACD"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Op } from "../../ops/op.js";
|
|
2
|
-
import type { Navigable } from "./primitives.js";
|
|
3
|
-
import type { Content } from "../../view/types.js";
|
|
4
|
-
import type { Loader } from "../../loaders/types.js";
|
|
5
|
-
export type RouterOptions<R extends Routes> = {
|
|
6
|
-
routes: R;
|
|
7
|
-
auto?: boolean;
|
|
8
|
-
location?: Hashbearer;
|
|
9
|
-
loader?: Loader;
|
|
10
|
-
notFound?: () => Content;
|
|
11
|
-
};
|
|
12
|
-
export type Hashbearer = {
|
|
13
|
-
hash: string;
|
|
14
|
-
};
|
|
15
|
-
export type Hasher<Params extends any[]> = {
|
|
16
|
-
parse: (hash: string) => (Params | null);
|
|
17
|
-
make: (...params: Params) => string;
|
|
18
|
-
};
|
|
19
|
-
export type Route<P extends any[] = any[]> = {
|
|
20
|
-
hasher: Hasher<P>;
|
|
21
|
-
fn: (...params: P) => Promise<Content>;
|
|
22
|
-
};
|
|
23
|
-
export type Routes = {
|
|
24
|
-
[key: string]: Route;
|
|
25
|
-
};
|
|
26
|
-
export type Params<X extends (Route | Navigable)> = (X extends Route<infer P> ? P : X extends Navigable<infer P> ? P : never);
|
|
27
|
-
export type ResolvedRoute<P extends any[] = any[]> = {
|
|
28
|
-
key: string;
|
|
29
|
-
route: Route<P>;
|
|
30
|
-
params: P;
|
|
31
|
-
op: Op<Content>;
|
|
32
|
-
};
|
|
33
|
-
export type Navigables<R extends Routes> = {
|
|
34
|
-
[K in keyof R]: Navigable<Params<R[K]>>;
|
|
35
|
-
};
|
package/x/spa/plumbing/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../s/spa/plumbing/types.ts"],"names":[],"mappings":""}
|
package/x/spa/router.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Content } from "../view/types.js";
|
|
2
|
-
import { Loader } from "../loaders/types.js";
|
|
3
|
-
import { RouterCore } from "./plumbing/router-core.js";
|
|
4
|
-
import { RouterOptions, Routes } from "./plumbing/types.js";
|
|
5
|
-
export declare class Router<R extends Routes> extends RouterCore<R> {
|
|
6
|
-
#private;
|
|
7
|
-
loader: Loader;
|
|
8
|
-
notFound: () => Content;
|
|
9
|
-
readonly dispose: import("@e280/stz").Disposer;
|
|
10
|
-
constructor(options: RouterOptions<R>);
|
|
11
|
-
render(): Content;
|
|
12
|
-
listen(): () => void;
|
|
13
|
-
}
|
package/x/spa/router.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { disposer } from "@e280/stz";
|
|
2
|
-
import { loaders } from "../loaders/index.js";
|
|
3
|
-
import { RouterCore } from "./plumbing/router-core.js";
|
|
4
|
-
import { HashNormalizer, onHashChange } from "./plumbing/primitives.js";
|
|
5
|
-
export class Router extends RouterCore {
|
|
6
|
-
loader;
|
|
7
|
-
notFound;
|
|
8
|
-
dispose = disposer();
|
|
9
|
-
#lastHash;
|
|
10
|
-
constructor(options) {
|
|
11
|
-
super(options.routes, options.location ?? new HashNormalizer(window.location));
|
|
12
|
-
const { auto = true } = options;
|
|
13
|
-
this.loader = options.loader ?? loaders.make();
|
|
14
|
-
this.notFound = options.notFound ?? (() => null);
|
|
15
|
-
this.#lastHash = this.hash;
|
|
16
|
-
if (auto) {
|
|
17
|
-
this.listen();
|
|
18
|
-
this.refresh();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
render() {
|
|
22
|
-
const resolved = this.$resolved.get();
|
|
23
|
-
return resolved === null
|
|
24
|
-
? this.notFound()
|
|
25
|
-
: this.loader(resolved.op, content => content);
|
|
26
|
-
}
|
|
27
|
-
listen() {
|
|
28
|
-
const dispose = onHashChange(() => {
|
|
29
|
-
const hash = this.hash;
|
|
30
|
-
const isChanged = hash !== this.#lastHash;
|
|
31
|
-
this.#lastHash = hash;
|
|
32
|
-
if (isChanged)
|
|
33
|
-
this.refresh();
|
|
34
|
-
});
|
|
35
|
-
this.dispose.schedule(dispose);
|
|
36
|
-
return dispose;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=router.js.map
|
package/x/spa/router.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../s/spa/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAGlC,OAAO,EAAC,OAAO,EAAC,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAA;AAEpD,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,0BAA0B,CAAA;AAErE,MAAM,OAAO,MAAyB,SAAQ,UAAa;IAC1D,MAAM,CAAQ;IACd,QAAQ,CAAe;IACd,OAAO,GAAG,QAAQ,EAAE,CAAA;IAC7B,SAAS,CAAQ;IAEjB,YAAY,OAAyB;QACpC,KAAK,CACJ,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CACvD,CAAA;QACD,MAAM,EAAC,IA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/world": Science.Test;
|
|
6
|
-
"#/item/a123": Science.Test;
|
|
7
|
-
"#/item/a123/lol should miss": Science.Test;
|
|
8
|
-
"#/left/{mid}/right extraction": Science.Test;
|
|
9
|
-
"#/not-found-lol": Science.Test;
|
|
10
|
-
};
|
|
11
|
-
nav: {
|
|
12
|
-
"home to item and back": Science.Test;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
package/x/spa/spa.test.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Science, test, expect } from "@e280/science";
|
|
2
|
-
import { route } from "./plumbing/braces.js";
|
|
3
|
-
import { RouterCore } from "./plumbing/router-core.js";
|
|
4
|
-
async function setup(routes) {
|
|
5
|
-
const location = { hash: "" };
|
|
6
|
-
const router = new RouterCore(routes, location);
|
|
7
|
-
return { location, router };
|
|
8
|
-
}
|
|
9
|
-
export default Science.suite({
|
|
10
|
-
inits: Science.suite({
|
|
11
|
-
"#/": test(async () => {
|
|
12
|
-
const { location, router } = await setup({
|
|
13
|
-
home: route("#/", async () => "123"),
|
|
14
|
-
});
|
|
15
|
-
expect(router.content).is(null);
|
|
16
|
-
location.hash = "#/";
|
|
17
|
-
await router.refresh();
|
|
18
|
-
expect(router.content).is("123");
|
|
19
|
-
}),
|
|
20
|
-
"#/hello/world": test(async () => {
|
|
21
|
-
const { location, router } = await setup({
|
|
22
|
-
helloWorld: route("#/hello/world", async () => "123"),
|
|
23
|
-
});
|
|
24
|
-
expect(router.content).is(null);
|
|
25
|
-
location.hash = "#/hello/world";
|
|
26
|
-
await router.refresh();
|
|
27
|
-
expect(router.content).is("123");
|
|
28
|
-
}),
|
|
29
|
-
"#/item/a123": test(async () => {
|
|
30
|
-
const { location, router } = await setup({
|
|
31
|
-
item: route("#/item/{id}", async ({ id }) => `content ${id}`),
|
|
32
|
-
});
|
|
33
|
-
location.hash = "#/item/a123";
|
|
34
|
-
await router.refresh();
|
|
35
|
-
expect(router.content).is("content a123");
|
|
36
|
-
}),
|
|
37
|
-
"#/item/a123/lol should miss": test(async () => {
|
|
38
|
-
const { location, router } = await setup({
|
|
39
|
-
item: route("#/item/{id}", async ({ id }) => `content ${id}`),
|
|
40
|
-
});
|
|
41
|
-
location.hash = "#/item/a123/lol";
|
|
42
|
-
await router.refresh();
|
|
43
|
-
expect(router.content).is(null);
|
|
44
|
-
}),
|
|
45
|
-
"#/left/{mid}/right extraction": test(async () => {
|
|
46
|
-
const { location, router } = await setup({
|
|
47
|
-
item: route("#/left/{mid}/right", async ({ mid }) => `content ${mid}`),
|
|
48
|
-
});
|
|
49
|
-
location.hash = "#/left/middle/right";
|
|
50
|
-
await router.refresh();
|
|
51
|
-
expect(router.content).is("content middle");
|
|
52
|
-
}),
|
|
53
|
-
"#/not-found-lol": test(async () => {
|
|
54
|
-
const { location, router } = await setup({
|
|
55
|
-
helloWorld: route("#/hello/world", async () => "123"),
|
|
56
|
-
});
|
|
57
|
-
location.hash = "#/not-found-lol";
|
|
58
|
-
await router.refresh();
|
|
59
|
-
expect(router.content).is(null);
|
|
60
|
-
}),
|
|
61
|
-
}),
|
|
62
|
-
nav: Science.suite({
|
|
63
|
-
"home to item and back": test(async () => {
|
|
64
|
-
const { location, router } = await setup({
|
|
65
|
-
home: route("#/", async () => `home`),
|
|
66
|
-
item: route("#/item/{id}", async ({ id }) => `item ${id}`),
|
|
67
|
-
});
|
|
68
|
-
location.hash = "#/";
|
|
69
|
-
await router.refresh();
|
|
70
|
-
expect(router.content).is("home");
|
|
71
|
-
await router.nav.item.go({ id: "x234" });
|
|
72
|
-
expect(router.content).is("item x234");
|
|
73
|
-
await router.nav.home.go();
|
|
74
|
-
expect(router.content).is("home");
|
|
75
|
-
}),
|
|
76
|
-
}),
|
|
77
|
-
});
|
|
78
|
-
//# sourceMappingURL=spa.test.js.map
|
package/x/spa/spa.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spa.test.js","sourceRoot":"","sources":["../../s/spa/spa.test.ts"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AAM,CAAC,CAAA;YAEjC,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAC,EAAE,EAAE,MAAM,EAAC,CAAC,CAAA;YACtC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;YAEtC,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAA;YAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;QAClC,CAAC,CAAC;KACF,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DropFirst } from "@e280/stz";
|
|
2
|
-
import { ComponentClass, View, ViewProps } from "../types.js";
|
|
3
|
-
export declare function contextualizeView<C, V extends View<any>>(context: C, view: V): View<DropFirst<ViewProps<V>>>;
|
|
4
|
-
export declare function contextualizeViews<C, Vs extends Record<string, View<any>>>(context: C, views: Vs): {
|
|
5
|
-
[K in keyof Vs]: View<DropFirst<ViewProps<Vs[K]>>>;
|
|
6
|
-
};
|
|
7
|
-
export declare function getViews<Cs extends Record<string, ComponentClass<any, any>>>(components: Cs): { [K in keyof Cs]: Cs[K]["view"]; };
|
|
8
|
-
export declare function contextualizeComponents<C, Cs extends Record<string, ComponentClass<any, any>>>(context: C, originalComponents: Cs): { [K in keyof Cs]: {
|
|
9
|
-
view: View<DropFirst<ViewProps<Cs[K]["view"]>>>;
|
|
10
|
-
new (): InstanceType<{
|
|
11
|
-
context: C;
|
|
12
|
-
} & Cs[K]>;
|
|
13
|
-
} & Cs[K]; };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ob } from "@e280/stz";
|
|
2
|
-
export function contextualizeView(context, view) {
|
|
3
|
-
return view.transmute((...p) => [context, ...p]);
|
|
4
|
-
}
|
|
5
|
-
export function contextualizeViews(context, views) {
|
|
6
|
-
return ob(views)
|
|
7
|
-
.map(view => contextualizeView(context, view));
|
|
8
|
-
}
|
|
9
|
-
export function getViews(components) {
|
|
10
|
-
return ob(components).map(C => C.view);
|
|
11
|
-
}
|
|
12
|
-
export function contextualizeComponents(context, originalComponents) {
|
|
13
|
-
return ob(originalComponents).map((Cons) => class extends Cons {
|
|
14
|
-
context = context;
|
|
15
|
-
static view = contextualizeView(context, super.view);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=contextualize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contextualize.js","sourceRoot":"","sources":["../../../s/view/utils/contextualize.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,EAAE,EAAC,MAAM,WAAW,CAAA;AAGvC,MAAM,UAAU,iBAAiB,CAC/B,OAAU,EACV,IAAO;IAER,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAQ,CAAA;AAC/D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAU,EACV,KAAS;IAGV,OAAO,EAAE,CAAC,KAAK,CAAC;SACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,QAAQ,CAErB,UAAc;IAEhB,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAW,CAE3C,CAAA;AACF,CAAC;AAED,MAAM,UAAU,uBAAuB,CAGpC,OAAU,EAAE,kBAAsB;IAEpC,OAAO,EAAE,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,KAAM,SAAQ,IAAI;QAClE,OAAO,GAAG,OAAO,CAAA;QACjB,MAAM,CAAC,IAAI,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAQ,CAAA;KAC3D,CAKA,CAAA;AACF,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Constructor } from "@e280/stz";
|
|
2
|
-
import { BaseElement } from "../../base/element.js";
|
|
3
|
-
import { ComponentClass, ViewFn } from "../types.js";
|
|
4
|
-
/** make a component from a BaseElement and a view. */
|
|
5
|
-
export declare function makeComponent<B extends Constructor<BaseElement>, Props extends any[]>(settings: ShadowRootInit, Base: B, propFn: (component: InstanceType<B>) => Props, viewFn: ViewFn<Props>): ComponentClass<B, Props>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { makeView } from "./make-view.js";
|
|
2
|
-
import { Reactor } from "../../base/utils/reactor.js";
|
|
3
|
-
/** make a component from a BaseElement and a view. */
|
|
4
|
-
export function makeComponent(settings, Base, propFn, viewFn) {
|
|
5
|
-
return class Component extends Base {
|
|
6
|
-
static view = makeView(viewFn, settings);
|
|
7
|
-
#reactor = new Reactor();
|
|
8
|
-
createShadow() {
|
|
9
|
-
return this.attachShadow(settings);
|
|
10
|
-
}
|
|
11
|
-
render(use) {
|
|
12
|
-
// reactor is tracking the propFn
|
|
13
|
-
return viewFn(use)(...this.#reactor.effect(() => propFn(this), () => this.update()));
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=make-component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-component.js","sourceRoot":"","sources":["../../../s/view/utils/make-component.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AAEvC,OAAO,EAAC,OAAO,EAAC,MAAM,6BAA6B,CAAA;AAGnD,sDAAsD;AACtD,MAAM,UAAU,aAAa,CAC3B,QAAwB,EACxB,IAAO,EACP,MAA6C,EAC7C,MAAqB;IAGtB,OAAO,MAAM,SAAU,SAAQ,IAAI;QAClC,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QACxC,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAA;QAExB,YAAY;YACX,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QACnC,CAAC;QAED,MAAM,CAAC,GAAQ;YACd,iCAAiC;YACjC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CACzC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAW,CAAC,EACzB,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CACnB,CAAC,CAAA;QACH,CAAC;KACkC,CAAA;AACrC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ViewChain } from "./parts/chain.js";
|
|
2
|
-
import { ViewContext } from "./parts/context.js";
|
|
3
|
-
import { BaseElement } from "../../base/element.js";
|
|
4
|
-
import { makeComponent } from "./make-component.js";
|
|
5
|
-
import { makeViewDirective } from "./parts/directive.js";
|
|
6
|
-
import { NakedContext, NakedCapsule } from "./parts/naked.js";
|
|
7
|
-
export function makeView(viewFn, settings) {
|
|
8
|
-
const renderDirective = makeViewDirective(viewFn, settings);
|
|
9
|
-
function v(...props) {
|
|
10
|
-
return renderDirective(new ViewContext(props));
|
|
11
|
-
}
|
|
12
|
-
v.props = (...props) => new ViewChain(new ViewContext(props), renderDirective);
|
|
13
|
-
v.transmute = (convert) => {
|
|
14
|
-
const viewFnB = use => {
|
|
15
|
-
const viewFnA2 = viewFn(use);
|
|
16
|
-
return (...propsB) => viewFnA2(...convert(...propsB));
|
|
17
|
-
};
|
|
18
|
-
return makeView(viewFnB, settings);
|
|
19
|
-
};
|
|
20
|
-
v.component = (Base = BaseElement) => ({
|
|
21
|
-
props: (propFn) => (makeComponent(settings, Base, propFn, viewFn))
|
|
22
|
-
});
|
|
23
|
-
v.naked = (host) => {
|
|
24
|
-
const naked = new NakedCapsule(host, viewFn, settings);
|
|
25
|
-
return {
|
|
26
|
-
host,
|
|
27
|
-
render: (...props) => naked.update(new NakedContext(props)),
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
return v;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=make-view.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-view.js","sourceRoot":"","sources":["../../../s/view/utils/make-view.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAA;AAE3D,MAAM,UAAU,QAAQ,CACtB,MAAqB,EACrB,QAAwB;IAGzB,MAAM,eAAe,GAAG,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAE3D,SAAS,CAAC,CAAC,GAAG,KAAY;QACzB,OAAO,eAAe,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/C,CAAC;IAED,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,KAAY,EAAE,EAAE,CAAC,IAAI,SAAS,CAC3C,IAAI,WAAW,CAAC,KAAK,CAAC,EACtB,eAAe,CACf,CAAA;IAED,CAAC,CAAC,SAAS,GAAG,CAAuB,OAAqC,EAAE,EAAE;QAC7E,MAAM,OAAO,GAAmB,GAAG,CAAC,EAAE;YACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;YAC5B,OAAO,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAA;QACtD,CAAC,CAAA;QACD,OAAO,QAAQ,CAAS,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC3C,CAAC,CAAA;IAED,CAAC,CAAC,SAAS,GAAG,CAAqC,OAAU,WAAkB,EAAE,EAAE,CAAC,CAAC;QACpF,KAAK,EAAE,CAAC,MAA6C,EAAE,EAAE,CAAC,CACzD,aAAa,CACZ,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,CACN,CACD;KACD,CAAC,CAAA;IAEF,CAAC,CAAC,KAAK,GAAG,CAAC,IAAiB,EAAoB,EAAE;QACjD,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;QACtD,OAAO;YACN,IAAI;YACJ,MAAM,EAAE,CAAC,GAAG,KAAY,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;SAClE,CAAA;IACF,CAAC,CAAA;IAED,OAAO,CAAC,CAAA;AACT,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ViewFn } from "../../types.js";
|
|
2
|
-
import { ViewContext } from "./context.js";
|
|
3
|
-
/** controls the rendering of view context into an element. */
|
|
4
|
-
export declare class ViewCapsule<Props extends any[]> {
|
|
5
|
-
#private;
|
|
6
|
-
private viewFn;
|
|
7
|
-
private settings;
|
|
8
|
-
constructor(host: HTMLElement, viewFn: ViewFn<Props>, settings: ShadowRootInit);
|
|
9
|
-
update(context: ViewContext<Props>): HTMLElement;
|
|
10
|
-
disconnected(): void;
|
|
11
|
-
reconnected(): void;
|
|
12
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { debounce } from "@e280/stz";
|
|
2
|
-
import { dom } from "../../../dom/dom.js";
|
|
3
|
-
import { Reactor } from "../../../base/utils/reactor.js";
|
|
4
|
-
import { attrSet } from "../../../dom/attrs/parts/attr-fns.js";
|
|
5
|
-
import { AttrWatcher } from "../../../base/utils/attr-watcher.js";
|
|
6
|
-
import { _disconnect, _reconnect, _wrap, Use } from "../../../base/use.js";
|
|
7
|
-
/** controls the rendering of view context into an element. */
|
|
8
|
-
export class ViewCapsule {
|
|
9
|
-
viewFn;
|
|
10
|
-
settings;
|
|
11
|
-
#element;
|
|
12
|
-
#reactor = new Reactor();
|
|
13
|
-
#use;
|
|
14
|
-
#shadow;
|
|
15
|
-
#context;
|
|
16
|
-
#attrWatcher;
|
|
17
|
-
constructor(host, viewFn, settings) {
|
|
18
|
-
this.viewFn = viewFn;
|
|
19
|
-
this.settings = settings;
|
|
20
|
-
this.#element = host;
|
|
21
|
-
this.#shadow = this.#element.attachShadow(this.settings);
|
|
22
|
-
this.#use = new Use(this.#element, this.#shadow, this.#renderNow, this.#renderDebounced);
|
|
23
|
-
this.#attrWatcher = new AttrWatcher(this.#element, () => this.#renderDebounced());
|
|
24
|
-
}
|
|
25
|
-
update(context) {
|
|
26
|
-
this.#context = context;
|
|
27
|
-
this.#renderNow();
|
|
28
|
-
return this.#element;
|
|
29
|
-
}
|
|
30
|
-
#renderNow = () => {
|
|
31
|
-
this.#use[_wrap](() => {
|
|
32
|
-
const content = this.#reactor.effect(() => this.viewFn(this.#use)(...this.#context.props), () => this.#renderDebounced());
|
|
33
|
-
attrSet.entries(this.#element, this.#context.attrs);
|
|
34
|
-
dom.render(this.#shadow, content);
|
|
35
|
-
dom.render(this.#element, this.#context.children);
|
|
36
|
-
this.#attrWatcher.start();
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
#renderDebounced = debounce(0, this.#renderNow);
|
|
40
|
-
disconnected() {
|
|
41
|
-
this.#use[_disconnect]();
|
|
42
|
-
this.#reactor.clear();
|
|
43
|
-
this.#attrWatcher.stop();
|
|
44
|
-
}
|
|
45
|
-
reconnected() {
|
|
46
|
-
this.#use[_reconnect]();
|
|
47
|
-
this.#attrWatcher.start();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=capsule.js.map
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
|
2
|
-
import { ViewContext } from "./context.js";
|
|
3
|
-
import { AttrValue } from "../../../dom/types.js";
|
|
4
|
-
import { DirectiveResult } from "lit/async-directive.js";
|
|
5
|
-
/** provides fluent chaining interface for adding context to rendering a view, think view.props().attr().children().render() */
|
|
6
|
-
export declare class ViewChain<Props extends any[]> {
|
|
7
|
-
#private;
|
|
8
|
-
constructor(context: ViewContext<Props>, renderDirective: (context: ViewContext<Props>) => DirectiveResult);
|
|
9
|
-
attr(key: string, value?: AttrValue): this;
|
|
10
|
-
attrs(record: Record<string, AttrValue>): this;
|
|
11
|
-
children(...contents: Content[]): this;
|
|
12
|
-
render(): DirectiveResult<import("lit-html/directive.js").DirectiveClass>;
|
|
13
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** provides fluent chaining interface for adding context to rendering a view, think view.props().attr().children().render() */
|
|
2
|
-
export class ViewChain {
|
|
3
|
-
#render;
|
|
4
|
-
#context;
|
|
5
|
-
constructor(context, renderDirective) {
|
|
6
|
-
this.#context = context;
|
|
7
|
-
this.#render = renderDirective;
|
|
8
|
-
}
|
|
9
|
-
attr(key, value = true) {
|
|
10
|
-
this.#context.attrs.set(key, value);
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
attrs(record) {
|
|
14
|
-
for (const [key, value] of Object.entries(record))
|
|
15
|
-
this.#context.attrs.set(key, value);
|
|
16
|
-
return this;
|
|
17
|
-
}
|
|
18
|
-
children(...contents) {
|
|
19
|
-
this.#context.children.push(...contents);
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
render() {
|
|
23
|
-
return this.#render(this.#context);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=chain.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../../s/view/utils/parts/chain.ts"],"names":[],"mappings":"AAMA,+HAA+H;AAC/H,MAAM,OAAO,SAAS;IACrB,OAAO,CAAkD;IACzD,QAAQ,CAAoB;IAE5B,YACE,OAA2B,EAC3B,eAAiE;QAElE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,OAAO,GAAG,eAAe,CAAA;IAC/B,CAAC;IAED,IAAI,CAAC,GAAW,EAAE,QAAmB,IAAI;QACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,MAAiC;QACtC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YAChD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACpC,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,QAAQ,CAAC,GAAG,QAAmB;QAC9B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAA;QACxC,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACnC,CAAC;CACD"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Content } from "../../types.js";
|
|
2
|
-
import { AttrValue } from "../../../dom/types.js";
|
|
3
|
-
/** the information we need to render a view. */
|
|
4
|
-
export declare class ViewContext<Props extends any[]> {
|
|
5
|
-
props: Props;
|
|
6
|
-
attrs: Map<string, AttrValue>;
|
|
7
|
-
children: Content[];
|
|
8
|
-
constructor(props: Props);
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../s/view/utils/parts/context.ts"],"names":[],"mappings":"AAIA,gDAAgD;AAChD,MAAM,OAAO,WAAW;IAGJ;IAFnB,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAA;IACpC,QAAQ,GAAc,EAAE,CAAA;IACxB,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;CACnC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { DirectiveResult } from "lit/async-directive.js";
|
|
2
|
-
import { ViewFn } from "../../types.js";
|
|
3
|
-
import { ViewContext } from "./context.js";
|
|
4
|
-
/** creates a lit directive fn, which when called, emits a funky lit thing to inject in your html templates. */
|
|
5
|
-
export declare function makeViewDirective<Props extends any[]>(viewFn: ViewFn<Props>, settings: ShadowRootInit): (context: ViewContext<Props>) => DirectiveResult;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AsyncDirective, directive } from "lit/async-directive.js";
|
|
2
|
-
import { SlyView } from "./sly-view.js";
|
|
3
|
-
import { ViewCapsule } from "./capsule.js";
|
|
4
|
-
/** creates a lit directive fn, which when called, emits a funky lit thing to inject in your html templates. */
|
|
5
|
-
export function makeViewDirective(viewFn, settings) {
|
|
6
|
-
return directive(class ViewDirective extends AsyncDirective {
|
|
7
|
-
#host = SlyView.make();
|
|
8
|
-
#capsule = new ViewCapsule(this.#host, viewFn, settings);
|
|
9
|
-
render(context) {
|
|
10
|
-
return this.#capsule.update(context);
|
|
11
|
-
}
|
|
12
|
-
disconnected() {
|
|
13
|
-
this.#capsule.disconnected();
|
|
14
|
-
}
|
|
15
|
-
reconnected() {
|
|
16
|
-
this.#capsule.reconnected();
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=directive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../../s/view/utils/parts/directive.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAE,SAAS,EAAkB,MAAM,wBAAwB,CAAA;AAEjF,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAA;AAGxC,+GAA+G;AAC/G,MAAM,UAAU,iBAAiB,CAC/B,MAAqB,EACrB,QAAwB;IAGzB,OAAO,SAAS,CAAC,MAAM,aAAc,SAAQ,cAAc;QAC1D,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAA;QACtB,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;QAExD,MAAM,CAAC,OAA2B;YACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACrC,CAAC;QAED,YAAY;YACX,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAA;QAC7B,CAAC;QAED,WAAW;YACV,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAA;QAC5B,CAAC;KACD,CAAqD,CAAA;AACvD,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ViewFn } from "../../types.js";
|
|
2
|
-
import { AttrValue } from "../../../dom/types.js";
|
|
3
|
-
/** the information we need to render a view. */
|
|
4
|
-
export declare class NakedContext<Props extends any[]> {
|
|
5
|
-
props: Props;
|
|
6
|
-
attrs: Map<string, AttrValue>;
|
|
7
|
-
constructor(props: Props);
|
|
8
|
-
}
|
|
9
|
-
/** controls the rendering of view context into an element. */
|
|
10
|
-
export declare class NakedCapsule<Props extends any[]> {
|
|
11
|
-
#private;
|
|
12
|
-
private viewFn;
|
|
13
|
-
private settings;
|
|
14
|
-
constructor(host: HTMLElement, viewFn: ViewFn<Props>, settings: ShadowRootInit);
|
|
15
|
-
update(context: NakedContext<Props>): HTMLElement;
|
|
16
|
-
disconnected(): void;
|
|
17
|
-
reconnected(): void;
|
|
18
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { debounce } from "@e280/stz";
|
|
2
|
-
import { dom } from "../../../dom/dom.js";
|
|
3
|
-
import { Reactor } from "../../../base/utils/reactor.js";
|
|
4
|
-
import { attrSet } from "../../../dom/attrs/parts/attr-fns.js";
|
|
5
|
-
import { AttrWatcher } from "../../../base/utils/attr-watcher.js";
|
|
6
|
-
import { _disconnect, _reconnect, _wrap, Use } from "../../../base/use.js";
|
|
7
|
-
/** the information we need to render a view. */
|
|
8
|
-
export class NakedContext {
|
|
9
|
-
props;
|
|
10
|
-
attrs = new Map();
|
|
11
|
-
constructor(props) {
|
|
12
|
-
this.props = props;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/** controls the rendering of view context into an element. */
|
|
16
|
-
export class NakedCapsule {
|
|
17
|
-
viewFn;
|
|
18
|
-
settings;
|
|
19
|
-
#element;
|
|
20
|
-
#reactor = new Reactor();
|
|
21
|
-
#use;
|
|
22
|
-
#shadow;
|
|
23
|
-
#context;
|
|
24
|
-
#attrWatcher;
|
|
25
|
-
constructor(host, viewFn, settings) {
|
|
26
|
-
this.viewFn = viewFn;
|
|
27
|
-
this.settings = settings;
|
|
28
|
-
this.#element = host;
|
|
29
|
-
this.#shadow = this.#element.attachShadow(this.settings);
|
|
30
|
-
this.#use = new Use(this.#element, this.#shadow, this.#renderNow, this.#renderDebounced);
|
|
31
|
-
this.#attrWatcher = new AttrWatcher(this.#element, () => this.#renderDebounced());
|
|
32
|
-
}
|
|
33
|
-
update(context) {
|
|
34
|
-
this.#context = context;
|
|
35
|
-
this.#renderNow();
|
|
36
|
-
return this.#element;
|
|
37
|
-
}
|
|
38
|
-
#renderNow = () => {
|
|
39
|
-
this.#use[_wrap](() => {
|
|
40
|
-
const content = this.#reactor.effect(() => this.viewFn(this.#use)(...this.#context.props), () => this.#renderDebounced());
|
|
41
|
-
attrSet.entries(this.#element, this.#context.attrs);
|
|
42
|
-
dom.render(this.#shadow, content);
|
|
43
|
-
this.#attrWatcher.start();
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
#renderDebounced = debounce(0, this.#renderNow);
|
|
47
|
-
disconnected() {
|
|
48
|
-
this.#use[_disconnect]();
|
|
49
|
-
this.#reactor.clear();
|
|
50
|
-
this.#attrWatcher.stop();
|
|
51
|
-
}
|
|
52
|
-
reconnected() {
|
|
53
|
-
this.#use[_reconnect]();
|
|
54
|
-
this.#attrWatcher.start();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=naked.js.map
|