@e280/sly 0.2.0-7 → 0.2.0-9
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/README.md +87 -24
- package/package.json +1 -1
- package/s/demo/demo.bundle.ts +13 -1
- package/s/demo/views/counter.ts +13 -5
- package/s/demo/views/demo.ts +10 -0
- package/s/demo/views/divine.ts +22 -0
- package/s/demo/views/incredi.ts +2 -1
- package/s/dom/attrs/attrs.ts +21 -0
- package/s/dom/attrs/parts/attr-fns.ts +38 -0
- package/s/dom/attrs/parts/attr-proxies.ts +35 -0
- package/s/dom/attrs/parts/attr-spec.ts +29 -0
- package/s/dom/attrs/parts/on-attrs.ts +8 -0
- package/s/dom/dom.ts +6 -5
- package/s/dom/{register.ts → parts/register.ts} +2 -10
- package/s/dom/types.ts +45 -0
- package/s/index.html.ts +2 -1
- package/s/index.ts +1 -4
- package/s/views/base-element.ts +15 -31
- package/s/views/types.ts +15 -6
- package/s/views/use.ts +10 -11
- package/s/views/utils/attr-watcher.ts +22 -0
- package/s/views/utils/reactor.ts +23 -0
- package/s/views/view.ts +73 -38
- package/x/demo/demo.bundle.js +11 -1
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +19 -15
- package/x/demo/demo.bundle.min.js.map +4 -4
- package/x/demo/views/counter.d.ts +7 -1
- package/x/demo/views/counter.js +11 -5
- package/x/demo/views/counter.js.map +1 -1
- package/x/demo/views/demo.js +8 -0
- package/x/demo/views/demo.js.map +1 -1
- package/x/demo/views/divine.d.ts +8 -0
- package/x/demo/views/divine.js +19 -0
- package/x/demo/views/divine.js.map +1 -0
- package/x/demo/views/incredi.js +1 -1
- package/x/demo/views/incredi.js.map +1 -1
- package/x/dom/attrs/attrs.d.ts +20 -0
- package/x/dom/attrs/attrs.js +17 -0
- package/x/dom/attrs/attrs.js.map +1 -0
- package/x/dom/attrs/parts/attr-fns.d.ts +13 -0
- package/x/dom/attrs/parts/attr-fns.js +42 -0
- package/x/dom/attrs/parts/attr-fns.js.map +1 -0
- package/x/dom/attrs/parts/attr-proxies.d.ts +8 -0
- package/x/dom/attrs/parts/attr-proxies.js +21 -0
- package/x/dom/attrs/parts/attr-proxies.js.map +1 -0
- package/x/dom/attrs/parts/attr-spec.d.ts +3 -0
- package/x/dom/attrs/parts/attr-spec.js +21 -0
- package/x/dom/attrs/parts/attr-spec.js.map +1 -0
- package/x/dom/attrs/parts/on-attrs.d.ts +2 -0
- package/x/dom/attrs/parts/on-attrs.js +7 -0
- package/x/dom/attrs/parts/on-attrs.js.map +1 -0
- package/x/dom/dom.d.ts +10 -4
- package/x/dom/dom.js +5 -5
- package/x/dom/dom.js.map +1 -1
- package/x/dom/parts/dashify.js.map +1 -0
- package/x/dom/{register.d.ts → parts/register.d.ts} +2 -10
- package/x/dom/parts/register.js.map +1 -0
- package/x/dom/{attributes.d.ts → types.d.ts} +11 -2
- package/x/dom/types.js +2 -0
- package/x/dom/types.js.map +1 -0
- package/x/index.d.ts +1 -4
- package/x/index.html +4 -3
- package/x/index.html.js +2 -1
- package/x/index.html.js.map +1 -1
- package/x/index.js +1 -4
- package/x/index.js.map +1 -1
- package/x/views/base-element.js +9 -27
- package/x/views/base-element.js.map +1 -1
- package/x/views/types.d.ts +11 -6
- package/x/views/use.d.ts +2 -2
- package/x/views/use.js +2 -5
- package/x/views/use.js.map +1 -1
- package/x/views/utils/attr-watcher.d.ts +8 -0
- package/x/views/utils/attr-watcher.js +20 -0
- package/x/views/utils/attr-watcher.js.map +1 -0
- package/x/views/utils/reactor.d.ts +6 -0
- package/x/views/utils/reactor.js +18 -0
- package/x/views/utils/reactor.js.map +1 -0
- package/x/views/view.d.ts +8 -4
- package/x/views/view.js +59 -30
- package/x/views/view.js.map +1 -1
- package/s/dom/attributes.ts +0 -89
- package/x/dom/attributes.js +0 -46
- package/x/dom/attributes.js.map +0 -1
- package/x/dom/dashify.js.map +0 -1
- package/x/dom/register.js.map +0 -1
- /package/s/dom/{dashify.ts → parts/dashify.ts} +0 -0
- /package/x/dom/{dashify.d.ts → parts/dashify.d.ts} +0 -0
- /package/x/dom/{dashify.js → parts/dashify.js} +0 -0
- /package/x/dom/{register.js → parts/register.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-element.js","sourceRoot":"","sources":["../../s/views/base-element.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-element.js","sourceRoot":"","sources":["../../s/views/base-element.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAGlC,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAA;AAEjC,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,UAAU,CAAA;AAE5D,MAAM,OAAgB,WAAY,SAAQ,WAAW;IACpD,MAAM,CAAC,MAAM,CAA4B;IAChC,MAAM,CAAY;IAE3B,IAAI,CAAK;IACT,OAAO,GAAG,CAAC,CAAA;IACX,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAA;IACxB,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAEzD;QACC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC,CAAA;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAClB,IAAI,EACJ,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,CACX,CAAA;IACF,CAAC;IAID,SAAS,GAAG,GAAG,EAAE;QAChB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE;YACrB,GAAG,CAAC,MAAM,CACT,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,QAAQ,CAAC,MAAM,CACnB,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,IAAI,CAAC,MAAM,CACX,CACD,CAAA;QACF,CAAC,CAAC,CAAA;IACH,CAAC,CAAA;IAED,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IAEpC,iBAAiB;QAChB,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,MAAM,GAAI,IAAI,CAAC,WAAmB,CAAC,MAAM,CAAA;YAC/C,IAAI,MAAM;gBACT,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YACjC,IAAI,CAAC,SAAS,EAAE,CAAA;QACjB,CAAC;aACI,CAAC;YACL,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAA;QACxB,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QACzB,IAAI,CAAC,OAAO,EAAE,CAAA;IACf,CAAC;IAED,oBAAoB;QACnB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAA;QACxB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;QACrB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;IACzB,CAAC;CACD"}
|
package/x/views/types.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { Constructor } from "@e280/stz";
|
|
2
1
|
import { DirectiveResult } from "lit/directive.js";
|
|
3
2
|
import { CSSResultGroup, TemplateResult } from "lit";
|
|
4
3
|
import { Use } from "./use.js";
|
|
5
4
|
export type Content = TemplateResult | DirectiveResult | HTMLElement | string | null | undefined | void | Content[];
|
|
6
5
|
export type AttrValue = string | boolean | number | undefined | null | void;
|
|
7
|
-
export type Component<
|
|
8
|
-
|
|
6
|
+
export type Component<Mix extends {} = {}> = Mix & {
|
|
7
|
+
renderNow(): void;
|
|
8
|
+
render: () => void;
|
|
9
9
|
} & HTMLElement;
|
|
10
|
-
export type
|
|
11
|
-
|
|
10
|
+
export type ComponentClass<Mix extends {}, Props extends any[]> = {
|
|
11
|
+
view: View<Props>;
|
|
12
|
+
new (): Component<Mix>;
|
|
13
|
+
};
|
|
14
|
+
export type ViewRenderFn<Props extends any[]> = (use: Use) => (...props: Props) => Content;
|
|
12
15
|
export type BasicView<Props extends any[]> = (...props: Props) => DirectiveResult<any>;
|
|
13
16
|
export type View<Props extends any[]> = BasicView<Props> & {
|
|
14
17
|
props: (...props: Props) => ViewChain;
|
|
15
|
-
component: (
|
|
18
|
+
component: <Mix extends {}>(init?: (component: Component<Mix>) => void) => {
|
|
19
|
+
props: (fn: (component: Component<Mix>) => Props) => (ComponentClass<Mix, Props>);
|
|
20
|
+
};
|
|
16
21
|
};
|
|
17
22
|
export type ViewSettings = ShadowRootInit & {
|
|
18
23
|
tag?: string;
|
package/x/views/use.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSResultGroup } from "lit";
|
|
2
2
|
import { SignalOptions } from "@e280/strata/signals";
|
|
3
3
|
import { Op } from "../ops/op.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Attrs } from "../dom/types.js";
|
|
5
5
|
export declare const _wrap: unique symbol;
|
|
6
6
|
export declare const _disconnect: unique symbol;
|
|
7
7
|
export declare const _reconnect: unique symbol;
|
|
@@ -11,6 +11,7 @@ export declare class Use {
|
|
|
11
11
|
shadow: ShadowRoot;
|
|
12
12
|
renderNow: () => void;
|
|
13
13
|
render: () => Promise<void>;
|
|
14
|
+
attrs: Attrs;
|
|
14
15
|
[_wrap]<R>(fn: () => R): R;
|
|
15
16
|
[_disconnect](): void;
|
|
16
17
|
[_reconnect](): void;
|
|
@@ -21,7 +22,6 @@ export declare class Use {
|
|
|
21
22
|
styles(...styles: CSSResultGroup[]): void;
|
|
22
23
|
/** alias for 'styles' */
|
|
23
24
|
css(...styles: CSSResultGroup[]): void;
|
|
24
|
-
attrs<A extends AttrSpec>(spec: A): import("../dom/attributes.js").AttrTypes<A>;
|
|
25
25
|
once<V>(fn: () => V): V;
|
|
26
26
|
mount(fn: () => () => void): void;
|
|
27
27
|
life<V>(fn: () => [result: V, dispose: () => void]): V;
|
package/x/views/use.js
CHANGED
|
@@ -4,7 +4,6 @@ import { Op } from "../ops/op.js";
|
|
|
4
4
|
import { dom } from "../dom/dom.js";
|
|
5
5
|
import { Mounts } from "./utils/mounts.js";
|
|
6
6
|
import { applyStyles } from "./utils/apply-styles.js";
|
|
7
|
-
import { onAttrChange } from "../dom/attributes.js";
|
|
8
7
|
export const _wrap = Symbol();
|
|
9
8
|
export const _disconnect = Symbol();
|
|
10
9
|
export const _reconnect = Symbol();
|
|
@@ -13,6 +12,7 @@ export class Use {
|
|
|
13
12
|
shadow;
|
|
14
13
|
renderNow;
|
|
15
14
|
render;
|
|
15
|
+
attrs;
|
|
16
16
|
#runs = 0;
|
|
17
17
|
#position = 0;
|
|
18
18
|
#values = new MapG();
|
|
@@ -39,6 +39,7 @@ export class Use {
|
|
|
39
39
|
this.shadow = shadow;
|
|
40
40
|
this.renderNow = renderNow;
|
|
41
41
|
this.render = render;
|
|
42
|
+
this.attrs = dom.attrs(this.element);
|
|
42
43
|
}
|
|
43
44
|
get renderCount() {
|
|
44
45
|
return this.#runs;
|
|
@@ -56,10 +57,6 @@ export class Use {
|
|
|
56
57
|
css(...styles) {
|
|
57
58
|
return this.styles(...styles);
|
|
58
59
|
}
|
|
59
|
-
attrs(spec) {
|
|
60
|
-
this.mount(() => onAttrChange(this.element, this.render));
|
|
61
|
-
return this.once(() => dom.attrs(this.element, spec));
|
|
62
|
-
}
|
|
63
60
|
once(fn) {
|
|
64
61
|
return this.#values.guarantee(this.#position++, fn);
|
|
65
62
|
}
|
package/x/views/use.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../s/views/use.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AACrC,OAAO,EAAC,MAAM,EAAgB,MAAM,sBAAsB,CAAA;AAE1D,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAA;AAC/B,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../s/views/use.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AACrC,OAAO,EAAC,MAAM,EAAgB,MAAM,sBAAsB,CAAA;AAE1D,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAA;AAC/B,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAA;AAEjC,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAA;AAEnD,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAA;AAC7B,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,EAAE,CAAA;AACnC,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,EAAE,CAAA;AAElC,MAAM,OAAO,GAAG;IA2BN;IACA;IACA;IACA;IA7BT,KAAK,CAAO;IAEZ,KAAK,GAAG,CAAC,CAAA;IACT,SAAS,GAAG,CAAC,CAAA;IACb,OAAO,GAAG,IAAI,IAAI,EAAe,CAAA;IACjC,SAAS,GAAG,KAAK,EAAE,CAAA;IACnB,OAAO,GAAG,IAAI,MAAM,EAAE,CAErB;IAAA,CAAC,KAAK,CAAC,CAAI,EAAW;QACtB,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,IAAI,CAA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I,CAAA;QACjB,SAAS,GAAG,CAAI,KAAQ,EAAE,OAAgC;YACzD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAI,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;QAClD,CAAC;QACD,GAAG,CAAC,OAAO,GAAG,SAAS,OAAO,CAAI,OAAgB,EAAE,OAAgC;YACnF,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAI,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QAC5D,CAAC,CAAA;QACD,GAAG,CAAC,IAAI,GAAG,SAAS,IAAI,CAAI,OAAgB,EAAE,OAAgC;YAC7E,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAI,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QACzD,CAAC,CAAA;QACD,OAAO,GAAG,CAAA;IACX,CAAC,CAAC,EAAE,CAAA;IAEJ,OAAO,CAAI,OAAgB,EAAE,OAAgC;QAC5D,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAI,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,CAAI,OAAgB,EAAE,OAAgC;QACzD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAI,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IACzD,CAAC;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { dom } from "../../dom/dom.js";
|
|
2
|
+
export class AttrWatcher {
|
|
3
|
+
element;
|
|
4
|
+
response;
|
|
5
|
+
#stopper;
|
|
6
|
+
constructor(element, response) {
|
|
7
|
+
this.element = element;
|
|
8
|
+
this.response = response;
|
|
9
|
+
}
|
|
10
|
+
start() {
|
|
11
|
+
if (!this.#stopper)
|
|
12
|
+
this.#stopper = dom.attrs(this.element).on(this.response);
|
|
13
|
+
}
|
|
14
|
+
stop() {
|
|
15
|
+
if (this.#stopper)
|
|
16
|
+
this.#stopper();
|
|
17
|
+
this.#stopper = undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=attr-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attr-watcher.js","sourceRoot":"","sources":["../../../s/views/utils/attr-watcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,kBAAkB,CAAA;AAEpC,MAAM,OAAO,WAAW;IAId;IACA;IAJT,QAAQ,CAA0B;IAElC,YACS,OAAoB,EACpB,QAAoB;QADpB,YAAO,GAAP,OAAO,CAAa;QACpB,aAAQ,GAAR,QAAQ,CAAY;IAC1B,CAAC;IAEJ,KAAK;QACJ,IAAI,CAAC,IAAI,CAAC,QAAQ;YACjB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3D,CAAC;IAED,IAAI;QACH,IAAI,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,QAAQ,EAAE,CAAA;QAClC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;IAC1B,CAAC;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MapG } from "@e280/stz";
|
|
2
|
+
import { tracker } from "@e280/strata";
|
|
3
|
+
export class Reactor {
|
|
4
|
+
#map = new MapG();
|
|
5
|
+
constructor() { }
|
|
6
|
+
effect(collect, respond) {
|
|
7
|
+
const { seen, result } = tracker.observe(collect);
|
|
8
|
+
for (const item of seen)
|
|
9
|
+
this.#map.guarantee(item, () => tracker.subscribe(item, respond));
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
clear() {
|
|
13
|
+
for (const dispose of this.#map.values())
|
|
14
|
+
dispose();
|
|
15
|
+
this.#map.clear();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=reactor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactor.js","sourceRoot":"","sources":["../../../s/views/utils/reactor.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AAEpC,MAAM,OAAO,OAAO;IACnB,IAAI,GAAG,IAAI,IAAI,EAAmB,CAAA;IAElC,gBAAe,CAAC;IAEhB,MAAM,CAAI,OAAgB,EAAE,OAA4B;QACvD,MAAM,EAAC,IAAI,EAAE,MAAM,EAAC,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/C,KAAK,MAAM,IAAI,IAAI,IAAI;YACtB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;QAClE,OAAO,MAAM,CAAA;IACd,CAAC;IAED,KAAK;QACJ,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACvC,OAAO,EAAE,CAAA;QACV,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;IAClB,CAAC;CACD"}
|
package/x/views/view.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { View, ViewRenderFn, ViewSettings, Component, ComponentClass } from "./types.js";
|
|
2
2
|
export declare const view: {
|
|
3
|
-
<Props extends any[]>(fn:
|
|
4
|
-
|
|
3
|
+
<Props extends any[]>(fn: ViewRenderFn<Props>): View<Props>;
|
|
4
|
+
render: /*elided*/ any;
|
|
5
5
|
settings(settings2: Partial<ViewSettings>): /*elided*/ any;
|
|
6
|
-
component(
|
|
6
|
+
component<Mix extends {}>(initFn?: (component: Component<Mix>) => void): {
|
|
7
|
+
props: <Props extends any[]>(propsFn: (component: Component<Mix>) => Props) => {
|
|
8
|
+
render: (fn: ViewRenderFn<Props>) => ComponentClass<Mix, Props>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
7
11
|
};
|
|
8
12
|
export declare class SlyView extends HTMLElement {
|
|
9
13
|
}
|
package/x/views/view.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { render } from "lit";
|
|
2
|
-
import { debounce
|
|
2
|
+
import { debounce } from "@e280/stz";
|
|
3
3
|
import { directive } from "lit/directive.js";
|
|
4
|
-
import { tracker } from "@e280/strata/tracker";
|
|
5
4
|
import { AsyncDirective } from "lit/async-directive.js";
|
|
6
|
-
import {
|
|
5
|
+
import { Reactor } from "./utils/reactor.js";
|
|
6
|
+
import { register } from "../dom/parts/register.js";
|
|
7
7
|
import { applyAttrs } from "./utils/apply-attrs.js";
|
|
8
|
+
import { AttrWatcher } from "./utils/attr-watcher.js";
|
|
8
9
|
import { applyStyles } from "./utils/apply-styles.js";
|
|
9
10
|
import { Use, _wrap, _disconnect, _reconnect } from "./use.js";
|
|
10
11
|
export const view = setupView({ mode: "open" });
|
|
@@ -16,9 +17,14 @@ function setupView(settings) {
|
|
|
16
17
|
const make = (situation) => class ViewDirective extends AsyncDirective {
|
|
17
18
|
#element = situation.getElement();
|
|
18
19
|
#shadow = this.#element.attachShadow(settings);
|
|
20
|
+
#reactor = new Reactor();
|
|
19
21
|
#renderDebounced = debounce(0, () => this.#renderNow());
|
|
20
|
-
#tracking = new MapG;
|
|
21
22
|
#params;
|
|
23
|
+
#attrWatcher = new AttrWatcher(this.#element, () => {
|
|
24
|
+
const is_view_responsible_for_rerendering = (!situation.isComponent);
|
|
25
|
+
if (is_view_responsible_for_rerendering)
|
|
26
|
+
this.#renderDebounced();
|
|
27
|
+
});
|
|
22
28
|
#use = new Use(this.#element, this.#shadow, () => this.#renderNow(), this.#renderDebounced);
|
|
23
29
|
#fn = (() => {
|
|
24
30
|
const fn2 = fn(this.#use);
|
|
@@ -36,13 +42,10 @@ function setupView(settings) {
|
|
|
36
42
|
this.#use[_wrap](() => {
|
|
37
43
|
// apply html attributes
|
|
38
44
|
applyAttrs(this.#element, context.attrs);
|
|
39
|
-
// render the template
|
|
40
|
-
const
|
|
45
|
+
// render the template and track reactivity
|
|
46
|
+
const content = this.#reactor.effect(() => this.#fn(...props), this.#renderDebounced);
|
|
41
47
|
// inject the template
|
|
42
|
-
render(
|
|
43
|
-
// reacting to changes
|
|
44
|
-
for (const item of seen)
|
|
45
|
-
this.#tracking.guarantee(item, () => tracker.subscribe(item, async () => this.#renderDebounced()));
|
|
48
|
+
render(content, this.#shadow);
|
|
46
49
|
// inject content into light dom
|
|
47
50
|
if (!situation.isComponent)
|
|
48
51
|
render(context.children, this.#element);
|
|
@@ -51,16 +54,19 @@ function setupView(settings) {
|
|
|
51
54
|
render(context, props) {
|
|
52
55
|
this.#params = { context, props };
|
|
53
56
|
this.#renderNow();
|
|
54
|
-
|
|
57
|
+
this.#attrWatcher.start();
|
|
58
|
+
return situation.isComponent
|
|
59
|
+
? null
|
|
60
|
+
: this.#element;
|
|
55
61
|
}
|
|
56
62
|
disconnected() {
|
|
57
63
|
this.#use[_disconnect]();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.#tracking.clear();
|
|
64
|
+
this.#reactor.clear();
|
|
65
|
+
this.#attrWatcher.stop();
|
|
61
66
|
}
|
|
62
67
|
reconnected() {
|
|
63
68
|
this.#use[_reconnect]();
|
|
69
|
+
this.#attrWatcher.start();
|
|
64
70
|
}
|
|
65
71
|
};
|
|
66
72
|
const d = directive(make({
|
|
@@ -92,25 +98,48 @@ function setupView(settings) {
|
|
|
92
98
|
};
|
|
93
99
|
return chain;
|
|
94
100
|
};
|
|
95
|
-
rendy.component = (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
rendy.component = (init = () => { }) => ({
|
|
102
|
+
props: (propsFn) => {
|
|
103
|
+
return class VComponent extends HTMLElement {
|
|
104
|
+
static view = rendy;
|
|
105
|
+
#context = freshViewContext();
|
|
106
|
+
#directive = directive(make({
|
|
107
|
+
getElement: () => this,
|
|
108
|
+
isComponent: true,
|
|
109
|
+
}));
|
|
110
|
+
#attrWatcher = new AttrWatcher(this, () => this.render());
|
|
111
|
+
constructor() {
|
|
112
|
+
super();
|
|
113
|
+
init(this);
|
|
114
|
+
}
|
|
115
|
+
connectedCallback() {
|
|
116
|
+
this.#attrWatcher.start();
|
|
117
|
+
this.renderNow();
|
|
118
|
+
}
|
|
119
|
+
disconnectedCallback() {
|
|
120
|
+
this.#attrWatcher.stop();
|
|
121
|
+
this.#reactor.clear();
|
|
122
|
+
}
|
|
123
|
+
#reactor = new Reactor();
|
|
124
|
+
render = debounce(0, () => this.renderNow());
|
|
125
|
+
renderNow() {
|
|
126
|
+
if (this.isConnected) {
|
|
127
|
+
const props = this.#reactor.effect(() => propsFn(this), this.render);
|
|
128
|
+
render(this.#directive(this.#context, props), this);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
});
|
|
109
134
|
return rendy;
|
|
110
135
|
}
|
|
111
|
-
view.
|
|
136
|
+
view.render = view;
|
|
112
137
|
view.settings = (settings2) => setupView({ ...settings, ...settings2 });
|
|
113
|
-
view.component = (
|
|
138
|
+
view.component = (initFn) => ({
|
|
139
|
+
props: (propsFn) => ({
|
|
140
|
+
render: (fn) => view(fn).component(initFn).props(propsFn),
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
114
143
|
return view;
|
|
115
144
|
}
|
|
116
145
|
//# sourceMappingURL=view.js.map
|
package/x/views/view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../s/views/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../s/views/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAA;AAErD,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAC,MAAM,UAAU,CAAA;AAG5D,MAAM,CAAC,MAAM,IAAI,GAAG,SAAS,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC,CAAA;AAC7C,MAAM,OAAO,OAAQ,SAAQ,WAAW;CAAG;AAC3C,QAAQ,CAAC,EAAC,OAAO,EAAC,EAAE,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC,CAAA;AAEhD,SAAS,SAAS,CAAC,QAAsB;IACxC,SAAS,IAAI,CAAsB,EAAuB;QAMzD,MAAM,IAAI,GAAG,CAAC,SAAoB,EAAE,EAAE,CAAC,MAAM,aAAc,SAAQ,cAAc;YAChF,QAAQ,GAAG,SAAS,CAAC,UAAU,EAAE,CAAA;YACjC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY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CAAA;QAEF,OAAO,KAAK,CAAA;IACb,CAAC;IAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;IAClB,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAgC,EAAE,EAAE,CAAC,SAAS,CAAC,EAAC,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAC,CAAC,CAAA;IAC5F,IAAI,CAAC,SAAS,GAAG,CAAiB,MAA4C,EAAE,EAAE,CAAC,CAAC;QACnF,KAAK,EAAE,CAAsB,OAA6C,EAAE,EAAE,CAAC,CAAC;YAC/E,MAAM,EAAE,CAAC,EAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,CAAM,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;SACnF,CAAC;KACF,CAAC,CAAA;IACF,OAAO,IAAI,CAAA;AACZ,CAAC"}
|
package/s/dom/attributes.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export type AttrKind = (
|
|
3
|
-
| typeof String
|
|
4
|
-
| typeof Number
|
|
5
|
-
| typeof Boolean
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
export type AttrType<H extends AttrKind> = (
|
|
9
|
-
H extends typeof String
|
|
10
|
-
? string | undefined
|
|
11
|
-
|
|
12
|
-
: H extends typeof Number
|
|
13
|
-
? number | undefined
|
|
14
|
-
|
|
15
|
-
: H extends typeof Boolean
|
|
16
|
-
? boolean
|
|
17
|
-
|
|
18
|
-
: never
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
export type AttrSpec = {
|
|
22
|
-
[key: string]: AttrKind
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type AttrTypes<A extends AttrSpec> = {
|
|
26
|
-
[P in keyof A]: AttrType<A[P]>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function onAttrChange(element: HTMLElement, fn: () => void) {
|
|
30
|
-
const observer = new MutationObserver(fn)
|
|
31
|
-
observer.observe(element, {attributes: true})
|
|
32
|
-
return () => observer.disconnect()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const attributes = <A extends AttrSpec>(
|
|
36
|
-
element: HTMLElement,
|
|
37
|
-
spec: A,
|
|
38
|
-
) => new Proxy(spec, {
|
|
39
|
-
|
|
40
|
-
get: (_target, name: string) => {
|
|
41
|
-
const type = spec[name]
|
|
42
|
-
const raw = element.getAttribute(name)
|
|
43
|
-
|
|
44
|
-
switch (type) {
|
|
45
|
-
case String:
|
|
46
|
-
return raw ?? undefined
|
|
47
|
-
|
|
48
|
-
case Number:
|
|
49
|
-
return raw !== null
|
|
50
|
-
? Number(raw)
|
|
51
|
-
: undefined
|
|
52
|
-
|
|
53
|
-
case Boolean:
|
|
54
|
-
return raw !== null
|
|
55
|
-
|
|
56
|
-
default:
|
|
57
|
-
throw new Error(`invalid attribute type for "${name}"`)
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
set: (_target, name: string, value: any) => {
|
|
62
|
-
const type = spec[name]
|
|
63
|
-
|
|
64
|
-
switch (type) {
|
|
65
|
-
case String: {
|
|
66
|
-
element.setAttribute(name, value)
|
|
67
|
-
return true
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
case Number: {
|
|
71
|
-
element.setAttribute(name, value.toString())
|
|
72
|
-
return true
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
case Boolean: {
|
|
76
|
-
if (value)
|
|
77
|
-
element.setAttribute(name, "")
|
|
78
|
-
else
|
|
79
|
-
element.removeAttribute(name)
|
|
80
|
-
return true
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
default:
|
|
84
|
-
throw new Error(`invalid attribute type for "${name}"`)
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
}) as any as AttrTypes<A>
|
|
89
|
-
|
package/x/dom/attributes.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export function onAttrChange(element, fn) {
|
|
2
|
-
const observer = new MutationObserver(fn);
|
|
3
|
-
observer.observe(element, { attributes: true });
|
|
4
|
-
return () => observer.disconnect();
|
|
5
|
-
}
|
|
6
|
-
export const attributes = (element, spec) => new Proxy(spec, {
|
|
7
|
-
get: (_target, name) => {
|
|
8
|
-
const type = spec[name];
|
|
9
|
-
const raw = element.getAttribute(name);
|
|
10
|
-
switch (type) {
|
|
11
|
-
case String:
|
|
12
|
-
return raw ?? undefined;
|
|
13
|
-
case Number:
|
|
14
|
-
return raw !== null
|
|
15
|
-
? Number(raw)
|
|
16
|
-
: undefined;
|
|
17
|
-
case Boolean:
|
|
18
|
-
return raw !== null;
|
|
19
|
-
default:
|
|
20
|
-
throw new Error(`invalid attribute type for "${name}"`);
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
set: (_target, name, value) => {
|
|
24
|
-
const type = spec[name];
|
|
25
|
-
switch (type) {
|
|
26
|
-
case String: {
|
|
27
|
-
element.setAttribute(name, value);
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
case Number: {
|
|
31
|
-
element.setAttribute(name, value.toString());
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
case Boolean: {
|
|
35
|
-
if (value)
|
|
36
|
-
element.setAttribute(name, "");
|
|
37
|
-
else
|
|
38
|
-
element.removeAttribute(name);
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
default:
|
|
42
|
-
throw new Error(`invalid attribute type for "${name}"`);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=attributes.js.map
|
package/x/dom/attributes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../s/dom/attributes.ts"],"names":[],"mappings":"AA4BA,MAAM,UAAU,YAAY,CAAC,OAAoB,EAAE,EAAc;IAChE,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAA;IACzC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ED,KAAK,OAAO,CAAC,CAAC,CAAC;gBACd,IAAI,KAAK;oBACR,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;;oBAE9B,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;gBAC9B,OAAO,IAAI,CAAA;YACZ,CAAC;YAED;gBACC,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,GAAG,CAAC,CAAA;QACzD,CAAC;IACF,CAAC;CAED,CAAwB,CAAA"}
|
package/x/dom/dashify.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dashify.js","sourceRoot":"","sources":["../../s/dom/dashify.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;AAClE,CAAC"}
|
package/x/dom/register.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../s/dom/register.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AAWpC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CACtB,QAAW,EACX,UAAwC,EAAE;IAG3C,MAAM,EACL,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,IAAI,GACd,GAAG,OAAO,CAAA;IAEX,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;QACzB,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAEvC,IAAI,IAAI,IAAI,OAAO;YAClB,SAAQ;QAET,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAEnC,IAAI,OAAO;YACV,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;gBAChD,IAAI,OAAO,CAAC,WAAW,KAAK,WAAW;oBACtC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YACjC,CAAC,CAAC,CAAA;IACJ,CAAC;AACF,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|