synstate-dom 0.0.0-stage → 0.2.0

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.
Files changed (185) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +218 -2
  3. package/dist/bind/bind-props.d.mts +9 -0
  4. package/dist/bind/bind-props.d.mts.map +1 -0
  5. package/dist/bind/bind-props.mjs +117 -0
  6. package/dist/bind/bind-props.mjs.map +1 -0
  7. package/dist/bind/index.d.mts +2 -0
  8. package/dist/bind/index.d.mts.map +1 -0
  9. package/dist/bind/index.mjs +2 -0
  10. package/dist/bind/index.mjs.map +1 -0
  11. package/dist/constant/bindable.d.mts +11 -0
  12. package/dist/constant/bindable.d.mts.map +1 -0
  13. package/dist/constant/bindable.mjs +2 -0
  14. package/dist/constant/bindable.mjs.map +1 -0
  15. package/dist/constant/constant.d.mts +20 -0
  16. package/dist/constant/constant.d.mts.map +1 -0
  17. package/dist/constant/constant.mjs +10 -0
  18. package/dist/constant/constant.mjs.map +1 -0
  19. package/dist/constant/derive.d.mts +16 -0
  20. package/dist/constant/derive.d.mts.map +1 -0
  21. package/dist/constant/derive.mjs +28 -0
  22. package/dist/constant/derive.mjs.map +1 -0
  23. package/dist/constant/index.d.mts +7 -0
  24. package/dist/constant/index.d.mts.map +1 -0
  25. package/dist/constant/index.mjs +7 -0
  26. package/dist/constant/index.mjs.map +1 -0
  27. package/dist/constant/map-bindable.d.mts +10 -0
  28. package/dist/constant/map-bindable.d.mts.map +1 -0
  29. package/dist/constant/map-bindable.mjs +16 -0
  30. package/dist/constant/map-bindable.mjs.map +1 -0
  31. package/dist/constant/to-observable.d.mts +12 -0
  32. package/dist/constant/to-observable.d.mts.map +1 -0
  33. package/dist/constant/to-observable.mjs +16 -0
  34. package/dist/constant/to-observable.mjs.map +1 -0
  35. package/dist/constant/view.d.mts +25 -0
  36. package/dist/constant/view.d.mts.map +1 -0
  37. package/dist/constant/view.mjs +15 -0
  38. package/dist/constant/view.mjs.map +1 -0
  39. package/dist/control/for.d.mts +29 -0
  40. package/dist/control/for.d.mts.map +1 -0
  41. package/dist/control/for.mjs +201 -0
  42. package/dist/control/for.mjs.map +1 -0
  43. package/dist/control/if.d.mts +16 -0
  44. package/dist/control/if.d.mts.map +1 -0
  45. package/dist/control/if.mjs +12 -0
  46. package/dist/control/if.mjs.map +1 -0
  47. package/dist/control/index.d.mts +6 -0
  48. package/dist/control/index.d.mts.map +1 -0
  49. package/dist/control/index.mjs +6 -0
  50. package/dist/control/index.mjs.map +1 -0
  51. package/dist/control/longest-increasing-subsequence.d.mts +7 -0
  52. package/dist/control/longest-increasing-subsequence.d.mts.map +1 -0
  53. package/dist/control/longest-increasing-subsequence.mjs +37 -0
  54. package/dist/control/longest-increasing-subsequence.mjs.map +1 -0
  55. package/dist/control/match-optional.d.mts +19 -0
  56. package/dist/control/match-optional.d.mts.map +1 -0
  57. package/dist/control/match-optional.mjs +21 -0
  58. package/dist/control/match-optional.mjs.map +1 -0
  59. package/dist/control/match-result.d.mts +19 -0
  60. package/dist/control/match-result.d.mts.map +1 -0
  61. package/dist/control/match-result.mjs +27 -0
  62. package/dist/control/match-result.mjs.map +1 -0
  63. package/dist/control/mount-switch.d.mts +18 -0
  64. package/dist/control/mount-switch.d.mts.map +1 -0
  65. package/dist/control/mount-switch.mjs +51 -0
  66. package/dist/control/mount-switch.mjs.map +1 -0
  67. package/dist/control/portal.d.mts +15 -0
  68. package/dist/control/portal.d.mts.map +1 -0
  69. package/dist/control/portal.mjs +22 -0
  70. package/dist/control/portal.mjs.map +1 -0
  71. package/dist/index.d.mts +5 -0
  72. package/dist/index.d.mts.map +1 -0
  73. package/dist/index.mjs +5 -0
  74. package/dist/index.mjs.map +1 -0
  75. package/dist/internal/as-constant.d.mts +9 -0
  76. package/dist/internal/as-constant.d.mts.map +1 -0
  77. package/dist/internal/as-constant.mjs +10 -0
  78. package/dist/internal/as-constant.mjs.map +1 -0
  79. package/dist/internal/bind-value.d.mts +14 -0
  80. package/dist/internal/bind-value.d.mts.map +1 -0
  81. package/dist/internal/bind-value.mjs +39 -0
  82. package/dist/internal/bind-value.mjs.map +1 -0
  83. package/dist/internal/dom-tables.d.mts +30 -0
  84. package/dist/internal/dom-tables.d.mts.map +1 -0
  85. package/dist/internal/dom-tables.mjs +167 -0
  86. package/dist/internal/dom-tables.mjs.map +1 -0
  87. package/dist/internal/index.d.mts +7 -0
  88. package/dist/internal/index.d.mts.map +1 -0
  89. package/dist/internal/index.mjs +7 -0
  90. package/dist/internal/index.mjs.map +1 -0
  91. package/dist/internal/is-view.d.mts +3 -0
  92. package/dist/internal/is-view.d.mts.map +1 -0
  93. package/dist/internal/is-view.mjs +4 -0
  94. package/dist/internal/is-view.mjs.map +1 -0
  95. package/dist/internal/mountable-tag.d.mts +6 -0
  96. package/dist/internal/mountable-tag.d.mts.map +1 -0
  97. package/dist/internal/mountable-tag.mjs +6 -0
  98. package/dist/internal/mountable-tag.mjs.map +1 -0
  99. package/dist/internal/view-tag.d.mts +7 -0
  100. package/dist/internal/view-tag.d.mts.map +1 -0
  101. package/dist/internal/view-tag.mjs +7 -0
  102. package/dist/internal/view-tag.mjs.map +1 -0
  103. package/dist/jsx/child.d.mts +20 -0
  104. package/dist/jsx/child.d.mts.map +1 -0
  105. package/dist/jsx/child.mjs +33 -0
  106. package/dist/jsx/child.mjs.map +1 -0
  107. package/dist/jsx/element-props.d.mts +78 -0
  108. package/dist/jsx/element-props.d.mts.map +1 -0
  109. package/dist/jsx/element-props.mjs +2 -0
  110. package/dist/jsx/element-props.mjs.map +1 -0
  111. package/dist/jsx/event-prop-names.d.mts +120 -0
  112. package/dist/jsx/event-prop-names.d.mts.map +1 -0
  113. package/dist/jsx/event-prop-names.mjs +2 -0
  114. package/dist/jsx/event-prop-names.mjs.map +1 -0
  115. package/dist/jsx/index.d.mts +7 -0
  116. package/dist/jsx/index.d.mts.map +1 -0
  117. package/dist/jsx/index.mjs +7 -0
  118. package/dist/jsx/index.mjs.map +1 -0
  119. package/dist/jsx/jsx-namespace.d.mts +11 -0
  120. package/dist/jsx/jsx-namespace.d.mts.map +1 -0
  121. package/dist/jsx/jsx-namespace.mjs +2 -0
  122. package/dist/jsx/jsx-namespace.mjs.map +1 -0
  123. package/dist/jsx/jsx.d.mts +18 -0
  124. package/dist/jsx/jsx.d.mts.map +1 -0
  125. package/dist/jsx/jsx.mjs +46 -0
  126. package/dist/jsx/jsx.mjs.map +1 -0
  127. package/dist/jsx/mountable.d.mts +25 -0
  128. package/dist/jsx/mountable.d.mts.map +1 -0
  129. package/dist/jsx/mountable.mjs +7 -0
  130. package/dist/jsx/mountable.mjs.map +1 -0
  131. package/dist/jsx-dev-runtime.d.mts +7 -0
  132. package/dist/jsx-dev-runtime.d.mts.map +1 -0
  133. package/dist/jsx-dev-runtime.mjs +7 -0
  134. package/dist/jsx-dev-runtime.mjs.map +1 -0
  135. package/dist/jsx-runtime.d.mts +7 -0
  136. package/dist/jsx-runtime.d.mts.map +1 -0
  137. package/dist/jsx-runtime.mjs +7 -0
  138. package/dist/jsx-runtime.mjs.map +1 -0
  139. package/dist/render.d.mts +14 -0
  140. package/dist/render.d.mts.map +1 -0
  141. package/dist/render.mjs +25 -0
  142. package/dist/render.mjs.map +1 -0
  143. package/package.json +97 -3
  144. package/src/bind/bind-props.mts +174 -0
  145. package/src/bind/index.mts +1 -0
  146. package/src/constant/bindable.mts +19 -0
  147. package/src/constant/constant.mts +24 -0
  148. package/src/constant/constant.test.mts +70 -0
  149. package/src/constant/derive.mts +51 -0
  150. package/src/constant/derive.test.mts +64 -0
  151. package/src/constant/index.mts +6 -0
  152. package/src/constant/map-bindable.mts +23 -0
  153. package/src/constant/map-bindable.test.mts +63 -0
  154. package/src/constant/to-observable.mts +20 -0
  155. package/src/constant/to-observable.test.mts +37 -0
  156. package/src/constant/view.mts +35 -0
  157. package/src/constant/view.test.mts +40 -0
  158. package/src/control/for.mts +362 -0
  159. package/src/control/if.mts +28 -0
  160. package/src/control/index.mts +5 -0
  161. package/src/control/longest-increasing-subsequence.mts +59 -0
  162. package/src/control/longest-increasing-subsequence.test.mts +26 -0
  163. package/src/control/match-optional.mts +41 -0
  164. package/src/control/match-result.mts +48 -0
  165. package/src/control/mount-switch.mts +75 -0
  166. package/src/control/portal.mts +32 -0
  167. package/src/index.mts +4 -0
  168. package/src/internal/as-constant.mts +11 -0
  169. package/src/internal/bind-value.mts +58 -0
  170. package/src/internal/dom-tables.mts +176 -0
  171. package/src/internal/index.mts +6 -0
  172. package/src/internal/is-view.mts +6 -0
  173. package/src/internal/mountable-tag.mts +5 -0
  174. package/src/internal/view-tag.mts +6 -0
  175. package/src/jsx/child.mts +51 -0
  176. package/src/jsx/element-props.mts +132 -0
  177. package/src/jsx/element-props.test.mts +28 -0
  178. package/src/jsx/event-prop-names.mts +119 -0
  179. package/src/jsx/index.mts +6 -0
  180. package/src/jsx/jsx-namespace.mts +11 -0
  181. package/src/jsx/jsx.mts +63 -0
  182. package/src/jsx/mountable.mts +31 -0
  183. package/src/jsx-dev-runtime.mts +6 -0
  184. package/src/jsx-runtime.mts +11 -0
  185. package/src/render.mts +32 -0
@@ -0,0 +1,27 @@
1
+ import { filter, map, withInitialValue, } from 'synstate';
2
+ import { Result } from 'ts-data-forge';
3
+ import { toObservable } from '../constant/index.mjs';
4
+ import { mountable } from '../jsx/index.mjs';
5
+ import { mountSwitch } from './mount-switch.mjs';
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ export const MatchResult = ({ value, ok, err, }) => mountable(() => mountSwitch(value, Result.isOk, (_isOk, current) => {
16
+ const value$ = toObservable(value);
17
+ return Result.isOk(current)
18
+ ? ok(value$
19
+ .pipe(filter(Result.isOk))
20
+ .pipe(map((r) => r.value))
21
+ .pipe(withInitialValue(current.value)))
22
+ : err(value$
23
+ .pipe(filter(Result.isErr))
24
+ .pipe(map((r) => r.value))
25
+ .pipe(withInitialValue(current.value)));
26
+ }));
27
+ //# sourceMappingURL=match-result.mjs.map
@@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C"}
@@ -0,0 +1,18 @@
1
+ import type { Bindable } from '../constant/index.mjs';
2
+ import { type Mountable, type MountedNodes } from '../jsx/index.mjs';
3
+ /**
4
+ * Mounts one branch at a time in front of an anchor comment, choosing it from
5
+ * the value of `value` (SPEC.md 8.1–8.3).
6
+ *
7
+ * The branch is rebuilt only when `keyOf` gives a different key: within the
8
+ * same key the branch keeps its nodes and its scope, and it is up to the
9
+ * branch to follow the value (`MatchOptional` hands it an observable derived
10
+ * from `value`). Each branch is mounted in a scope of its own, a child of the
11
+ * scope the switch was mounted in; disposing the branch's scope removes its
12
+ * nodes, so the switch's own nodes stay accurate however often it switches.
13
+ *
14
+ * `branch` runs inside the new scope, so whatever it creates belongs to the
15
+ * branch.
16
+ */
17
+ export declare const mountSwitch: <V, K>(value: Bindable<V>, keyOf: (current: V) => K, branch: (key: K, current: V) => Mountable | undefined) => MountedNodes;
18
+ //# sourceMappingURL=mount-switch.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount-switch.d.mts","sourceRoot":"","sources":["../../src/control/mount-switch.mts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAW,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE9E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,SACvB,QAAQ,CAAC,CAAC,CAAC,SACX,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,UAChB,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,SAAS,GAAG,SAAS,KACpD,YA6CF,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { createScope, getCurrentScope, onScopeDispose, } from 'synstate';
2
+ import { Arr } from 'ts-data-forge';
3
+ import { bindValue } from '../internal/index.mjs';
4
+ import { toNodes } from '../jsx/index.mjs';
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ export const mountSwitch = (value, keyOf, branch) => {
20
+ const parent = getCurrentScope();
21
+ const anchor = document.createComment('');
22
+ const mut_state = { current: undefined, initialNodes: [] };
23
+ bindValue(value, (v) => {
24
+ const key = keyOf(v);
25
+ if (mut_state.current !== undefined) {
26
+ if (Object.is(mut_state.current.key, key)) {
27
+ return;
28
+ }
29
+ mut_state.current.scope.dispose();
30
+ }
31
+ const scope = createScope(parent);
32
+ const nodes = scope.run(() => {
33
+ const mounted = toNodes(branch(key, v)?.mount() ?? []);
34
+ onScopeDispose(() => {
35
+ for (const node of mounted) {
36
+ node.remove();
37
+ }
38
+ });
39
+ return mounted;
40
+ });
41
+ mut_state.current = { key, scope };
42
+ if (anchor.parentNode === null) {
43
+ mut_state.initialNodes = nodes;
44
+ }
45
+ else {
46
+ anchor.before(...nodes);
47
+ }
48
+ });
49
+ return Arr.toPushed(mut_state.initialNodes, anchor);
50
+ };
51
+ //# sourceMappingURL=mount-switch.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount-switch.mjs","sourceRoot":"","sources":["../../src/control/mount-switch.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,GAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAqC,MAAM,kBAAkB,CAAC;AAE9E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAkB,EAClB,KAAwB,EACxB,MAAqD,EACvC,EAAE;IAChB,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IAEjC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAE1C,MAAM,SAAS,GAGX,EAAE,OAAO,EAAE,SAAS,E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type JSX } from '../jsx/index.mjs';
2
+ /**
3
+ * Mounts `children` into `target` (`document.body` when omitted) rather than
4
+ * where it is written (SPEC.md 8.6): for a modal, a tooltip or a toast that
5
+ * has to escape an ancestor's `overflow: hidden` or `z-index`.
6
+ *
7
+ * The children belong to the scope where `Portal` is written, so closing the
8
+ * enclosing `If` branch removes them too. Nothing is left in the place it is
9
+ * written.
10
+ */
11
+ export declare const Portal: ({ target, children, }: Readonly<{
12
+ target?: Element;
13
+ children: Child;
14
+ }>) => JSX.Element;
15
+ //# sourceMappingURL=portal.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal.d.mts","sourceRoot":"","sources":["../../src/control/portal.mts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,KAAK,EAAE,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE/E;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,0BAGhB,QAAQ,CAAC;IACV,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC;CACjB,CAAC,KAAG,GAAG,CAAC,OAaL,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { onScopeDispose } from 'synstate';
2
+ import { mountChild, mountable } from '../jsx/index.mjs';
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ export const Portal = ({ target, children, }) => mountable(() => {
13
+ const nodes = mountChild(children);
14
+ (target ?? document.body).append(...nodes);
15
+ onScopeDispose(() => {
16
+ for (const node of nodes) {
17
+ node.remove();
18
+ }
19
+ });
20
+ return [];
21
+ });
22
+ //# sourceMappingURL=portal.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal.mjs","sourceRoot":"","sources":["../../src/control/portal.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAwB,MAAM,kBAAkB,CAAC;AAE/E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,MAAM,EACN,QAAQ,GAIR,EAAe,EAAE,CACjB,SAAS,CAAC,GAAG,EAAE;IACb,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAEnC,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;IAE3C,cAAc,CAAC,GAAG,EAAE;QAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './constant/index.mjs';
2
+ export * from './control/index.mjs';
3
+ export * from './jsx/index.mjs';
4
+ export * from './render.mjs';
5
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ export * from './constant/index.mjs';
2
+ export * from './control/index.mjs';
3
+ export * from './jsx/index.mjs';
4
+ export * from './render.mjs';
5
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Constant } from '../constant/index.mjs';
2
+ /**
3
+ * The one type assertion in the library. `Constant<T>` is a brand that exists
4
+ * only in the type system, so marking a value as one changes nothing at run
5
+ * time; this is what {@link constant} and the helpers that derive one constant
6
+ * from another call.
7
+ */
8
+ export declare const asConstant: <T>(value: T) => Constant<T>;
9
+ //# sourceMappingURL=as-constant.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"as-constant.d.mts","sourceRoot":"","sources":["../../src/internal/as-constant.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAU,CAAC,KAAG,QAAQ,CAAC,CAAC,CAE9B,CAAC"}
@@ -0,0 +1,10 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+ export const asConstant = (value) =>
8
+
9
+ value;
10
+ //# sourceMappingURL=as-constant.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"as-constant.mjs","sourceRoot":"","sources":["../../src/internal/as-constant.mts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAK,KAAQ,EAAe,EAAE;AACtD,6GAA6G;AAC7G,KAAoB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Bindable } from '../constant/index.mjs';
2
+ /**
3
+ * Writes the value of a {@link Bindable} with `write`, and again on every
4
+ * update (SPEC.md 7.1).
5
+ *
6
+ * - A constant is written once.
7
+ * - A completed observable has its current value written once.
8
+ * - Any other observable is subscribed to, and the subscription is released
9
+ * when the current scope is disposed.
10
+ *
11
+ * A view is the same as its source, with its function applied before `write`.
12
+ */
13
+ export declare const bindValue: <T>(bindable: Bindable<T>, write: (value: T) => void) => void;
14
+ //# sourceMappingURL=bind-value.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind-value.d.mts","sourceRoot":"","sources":["../../src/internal/bind-value.mts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,YACf,QAAQ,CAAC,CAAC,CAAC,SACd,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KACxB,IAkBF,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { isObservable, onScopeDispose, } from 'synstate';
2
+ import { isView } from './is-view.mjs';
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ export const bindValue = (bindable, write) => {
15
+ if (isView(bindable)) {
16
+ bindable.open((source, fn) => {
17
+ subscribeInScope(source, (value) => {
18
+ write(fn(value));
19
+ });
20
+ });
21
+ return;
22
+ }
23
+ if (isObservable(bindable)) {
24
+ subscribeInScope(bindable, write);
25
+ return;
26
+ }
27
+ write(bindable);
28
+ };
29
+ const subscribeInScope = (source, write) => {
30
+ if (source.isCompleted) {
31
+ write(source.getSnapshot().value);
32
+ return;
33
+ }
34
+ const subscription = source.subscribe(write);
35
+ onScopeDispose(() => {
36
+ subscription.unsubscribe();
37
+ });
38
+ };
39
+ //# sourceMappingURL=bind-value.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind-value.mjs","sourceRoot":"","sources":["../../src/internal/bind-value.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,GAEf,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,QAAqB,EACrB,KAAyB,EACnB,EAAE;IACR,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrB,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;YAC3B,gBAAgB,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBACjC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO;IACT,CAAC;IAED,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAElC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACvB,MAAgC,EAChC,KAAyB,EACnB,EAAE;IACR,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC;QAElC,OAAO;IACT,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAE7C,cAAc,CAAC,GAAG,EAAE;QAClB,YAAY,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { ReadonlyRecord } from 'ts-type-forge';
2
+ /**
3
+ * The keys written as DOM properties (`element[key] = value`) rather than as
4
+ * attributes. These are the ones a user's input moves away from the attribute
5
+ * (`value`, `checked`, …), and the enumerated attributes whose `false` is a
6
+ * value rather than an absence (`draggable`, `spellcheck`, `translate`).
7
+ *
8
+ * The props types and the binding both read this table (SPEC.md 5.2).
9
+ */
10
+ export declare const propertyNames: readonly ['checked', 'defaultChecked', 'defaultValue', 'draggable', 'indeterminate', 'muted', 'selected', 'spellcheck', 'translate', 'value'];
11
+ /**
12
+ * DOM property names whose attribute is spelt differently. Every other name is
13
+ * passed to `setAttribute`, which lower-cases it for an HTML element
14
+ * (`tabIndex` becomes `tabindex`).
15
+ */
16
+ export declare const attributeNameOf: ReadonlyRecord<string, string>;
17
+ /**
18
+ * The tags created in the SVG namespace: those of `SVGElementTagNameMap` that
19
+ * HTML does not also have. `a`, `script`, `style` and `title` are created as
20
+ * HTML elements wherever they appear.
21
+ */
22
+ export declare const svgTagNames: readonly ["animate", "animateMotion", "animateTransform", "circle", "clipPath", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "set", "stop", "svg", "switch", "symbol", "text", "textPath", "tspan", "use", "view"];
23
+ export type SvgTagName = (typeof svgTagNames)[number];
24
+ /**
25
+ * The attributes an SVG element takes. SVG properties are animated values
26
+ * (`SVGAnimatedLength`), so unlike HTML they cannot be read off the element
27
+ * types; these are listed by hand and written with `setAttribute` as named.
28
+ */
29
+ export declare const svgAttributeNames: readonly ['clip-path', 'clip-rule', 'cx', 'cy', 'd', 'dominant-baseline', 'dx', 'dy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'font-family', 'font-size', 'font-weight', 'fx', 'fy', 'gradientTransform', 'gradientUnits', 'height', 'href', 'id', 'marker-end', 'marker-mid', 'marker-start', 'markerHeight', 'markerUnits', 'markerWidth', 'mask', 'offset', 'opacity', 'orient', 'pathLength', 'patternUnits', 'points', 'preserveAspectRatio', 'r', 'refX', 'refY', 'role', 'rx', 'ry', 'stop-color', 'stop-opacity', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-opacity', 'stroke-width', 'tabindex', 'text-anchor', 'transform', 'viewBox', 'visibility', 'width', 'x', 'x1', 'x2', 'y', 'y1', 'y2'];
30
+ //# sourceMappingURL=dom-tables.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-tables.d.mts","sourceRoot":"","sources":["../../src/internal/dom-tables.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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0 +1,167 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ export const propertyNames = [
10
+ 'checked',
11
+ 'defaultChecked',
12
+ 'defaultValue',
13
+ 'draggable',
14
+ 'indeterminate',
15
+ 'muted',
16
+ 'selected',
17
+ 'spellcheck',
18
+ 'translate',
19
+ 'value',
20
+ ];
21
+
22
+
23
+
24
+
25
+
26
+ export const attributeNameOf = {
27
+ acceptCharset: 'accept-charset',
28
+ htmlFor: 'for',
29
+ httpEquiv: 'http-equiv',
30
+ };
31
+
32
+
33
+
34
+
35
+
36
+ export const svgTagNames = [
37
+ 'animate',
38
+ 'animateMotion',
39
+ 'animateTransform',
40
+ 'circle',
41
+ 'clipPath',
42
+ 'defs',
43
+ 'desc',
44
+ 'ellipse',
45
+ 'feBlend',
46
+ 'feColorMatrix',
47
+ 'feComponentTransfer',
48
+ 'feComposite',
49
+ 'feConvolveMatrix',
50
+ 'feDiffuseLighting',
51
+ 'feDisplacementMap',
52
+ 'feDistantLight',
53
+ 'feDropShadow',
54
+ 'feFlood',
55
+ 'feFuncA',
56
+ 'feFuncB',
57
+ 'feFuncG',
58
+ 'feFuncR',
59
+ 'feGaussianBlur',
60
+ 'feImage',
61
+ 'feMerge',
62
+ 'feMergeNode',
63
+ 'feMorphology',
64
+ 'feOffset',
65
+ 'fePointLight',
66
+ 'feSpecularLighting',
67
+ 'feSpotLight',
68
+ 'feTile',
69
+ 'feTurbulence',
70
+ 'filter',
71
+ 'foreignObject',
72
+ 'g',
73
+ 'image',
74
+ 'line',
75
+ 'linearGradient',
76
+ 'marker',
77
+ 'mask',
78
+ 'metadata',
79
+ 'mpath',
80
+ 'path',
81
+ 'pattern',
82
+ 'polygon',
83
+ 'polyline',
84
+ 'radialGradient',
85
+ 'rect',
86
+ 'set',
87
+ 'stop',
88
+ 'svg',
89
+ 'switch',
90
+ 'symbol',
91
+ 'text',
92
+ 'textPath',
93
+ 'tspan',
94
+ 'use',
95
+ 'view',
96
+ ];
97
+
98
+
99
+
100
+
101
+
102
+ export const svgAttributeNames = [
103
+ 'clip-path',
104
+ 'clip-rule',
105
+ 'cx',
106
+ 'cy',
107
+ 'd',
108
+ 'dominant-baseline',
109
+ 'dx',
110
+ 'dy',
111
+ 'fill',
112
+ 'fill-opacity',
113
+ 'fill-rule',
114
+ 'filter',
115
+ 'font-family',
116
+ 'font-size',
117
+ 'font-weight',
118
+ 'fx',
119
+ 'fy',
120
+ 'gradientTransform',
121
+ 'gradientUnits',
122
+ 'height',
123
+ 'href',
124
+ 'id',
125
+ 'marker-end',
126
+ 'marker-mid',
127
+ 'marker-start',
128
+ 'markerHeight',
129
+ 'markerUnits',
130
+ 'markerWidth',
131
+ 'mask',
132
+ 'offset',
133
+ 'opacity',
134
+ 'orient',
135
+ 'pathLength',
136
+ 'patternUnits',
137
+ 'points',
138
+ 'preserveAspectRatio',
139
+ 'r',
140
+ 'refX',
141
+ 'refY',
142
+ 'role',
143
+ 'rx',
144
+ 'ry',
145
+ 'stop-color',
146
+ 'stop-opacity',
147
+ 'stroke',
148
+ 'stroke-dasharray',
149
+ 'stroke-dashoffset',
150
+ 'stroke-linecap',
151
+ 'stroke-linejoin',
152
+ 'stroke-opacity',
153
+ 'stroke-width',
154
+ 'tabindex',
155
+ 'text-anchor',
156
+ 'transform',
157
+ 'viewBox',
158
+ 'visibility',
159
+ 'width',
160
+ 'x',
161
+ 'x1',
162
+ 'x2',
163
+ 'y',
164
+ 'y1',
165
+ 'y2',
166
+ ];
167
+ //# sourceMappingURL=dom-tables.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-tables.mjs","sourceRoot":"","sources":["../../src/internal/dom-tables.mts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,SAAS;IACT,gBAAgB;IAChB,cAAc;IACd,WAAW;IACX,eAAe;IACf,OAAO;IACP,UAAU;IACV,YAAY;IACZ,WAAW;IACX,OAAO;CACC,CAAC;AAEX;;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Ac;IACd,aAAa;IACb,aAAa;IACb,MAAM;IACN,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,qBAAqB;IACrB,GAAG;IACH,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,cAAc;IACd,UAAU;IACV,aAAa;IACb,WAAW;IACX,SAAS;IACT,YAAY;IACZ,OAAO;IACP,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;CACI,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './as-constant.mjs';
2
+ export * from './bind-value.mjs';
3
+ export * from './dom-tables.mjs';
4
+ export * from './is-view.mjs';
5
+ export * from './mountable-tag.mjs';
6
+ export * from './view-tag.mjs';
7
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/internal/index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './as-constant.mjs';
2
+ export * from './bind-value.mjs';
3
+ export * from './dom-tables.mjs';
4
+ export * from './is-view.mjs';
5
+ export * from './mountable-tag.mjs';
6
+ export * from './view-tag.mjs';
7
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/internal/index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Bindable, View } from '../constant/index.mjs';
2
+ export declare const isView: <T>(bindable: Bindable<T>) => bindable is View<T>;
3
+ //# sourceMappingURL=is-view.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-view.d.mts","sourceRoot":"","sources":["../../src/internal/is-view.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG5D,eAAO,MAAM,MAAM,GAAI,CAAC,YAAa,QAAQ,CAAC,CAAC,CAAC,KAAG,QAAQ,IAAI,IAAI,CAAC,CAAC,CACpB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { hasKey, isRecord } from 'ts-data-forge';
2
+ import { viewTag } from './view-tag.mjs';
3
+ export const isView = (bindable) => isRecord(bindable) && hasKey(bindable, viewTag);
4
+ //# sourceMappingURL=is-view.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-view.mjs","sourceRoot":"","sources":["../../src/internal/is-view.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAK,QAAqB,EAAuB,EAAE,CACvE,QAAQ,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The key a {@link Mountable} carries, so that mounting a child can tell a
3
+ * description from a `Bindable` at run time.
4
+ */
5
+ export declare const mountableTag: unique symbol;
6
+ //# sourceMappingURL=mountable-tag.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mountable-tag.d.mts","sourceRoot":"","sources":["../../src/internal/mountable-tag.mts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,MAA6C,CAAC"}
@@ -0,0 +1,6 @@
1
+
2
+
3
+
4
+
5
+ export const mountableTag = Symbol.for('synstate-dom/mountable');
6
+ //# sourceMappingURL=mountable-tag.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mountable-tag.mjs","sourceRoot":"","sources":["../../src/internal/mountable-tag.mts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The key a {@link View} carries, so that binding can tell it from a constant
3
+ * at run time. `Symbol.for` rather than `Symbol`, matching the mark synstate
4
+ * puts on its observables: two copies of the module still agree.
5
+ */
6
+ export declare const viewTag: unique symbol;
7
+ //# sourceMappingURL=view-tag.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-tag.d.mts","sourceRoot":"","sources":["../../src/internal/view-tag.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,OAAO,MAAwC,CAAC"}
@@ -0,0 +1,7 @@
1
+
2
+
3
+
4
+
5
+
6
+ export const viewTag = Symbol.for('synstate-dom/view');
7
+ //# sourceMappingURL=view-tag.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-tag.mjs","sourceRoot":"","sources":["../../src/internal/view-tag.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkB,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Bindable } from '../constant/index.mjs';
2
+ import type { Mountable, MountedNodes } from './mountable.mjs';
3
+ /**
4
+ * What a JSX element accepts as a child. Text must be a `Bindable` like any
5
+ * other data: `<p>{constant('big')}</p>`, never `<p>big</p>` (SPEC.md 5.1).
6
+ */
7
+ export type Child = Bindable<number | string> | Mountable | readonly Child[];
8
+ /**
9
+ * Mounts a child in the current scope and returns its nodes in order: a
10
+ * description is mounted, a `Bindable` becomes a text node bound to it, and an
11
+ * array is flattened.
12
+ */
13
+ export declare const mountChild: (child: Child) => readonly ChildNode[];
14
+ export declare const toNodes: (nodes: MountedNodes) => readonly ChildNode[];
15
+ /**
16
+ * Tells a child from any other value, one level deep: the elements of an
17
+ * array are checked as they are mounted.
18
+ */
19
+ export declare const isChild: (value: unknown) => value is Child;
20
+ //# sourceMappingURL=child.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"child.d.mts","sourceRoot":"","sources":["../../src/jsx/child.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,GAAG,SAAS,KAAK,EAAE,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,UAAU,UAAW,KAAK,KAAG,SAAS,SAAS,EAgB3D,CAAC;AAEF,eAAO,MAAM,OAAO,UAAW,YAAY,KAAG,SAAS,SAAS,EACf,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,OAAO,UAAW,OAAO,KAAG,KAAK,IAAI,KAK4B,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { isObservable } from 'synstate';
2
+ import { Arr, hasKey, isNumber, isRecord, isString } from 'ts-data-forge';
3
+ import { bindValue, mountableTag, viewTag } from '../internal/index.mjs';
4
+
5
+
6
+
7
+
8
+
9
+ export const mountChild = (child) => {
10
+ if (Arr.isArray(child)) {
11
+ return child.flatMap(mountChild);
12
+ }
13
+ if (isMountable(child)) {
14
+ return toNodes(child.mount());
15
+ }
16
+ const mut_text = document.createTextNode('');
17
+ bindValue(child, (value) => {
18
+ mut_text.data = value.toString();
19
+ });
20
+ return [mut_text];
21
+ };
22
+ export const toNodes = (nodes) => Arr.isArray(nodes) ? nodes : [nodes];
23
+
24
+
25
+
26
+
27
+ export const isChild = (value) => Arr.isArray(value) ||
28
+ isString(value) ||
29
+ isNumber(value) ||
30
+ isObservable(value) ||
31
+ (isRecord(value) && (hasKey(value, mountableTag) || hasKey(value, viewTag)));
32
+ const isMountable = (child) => isRecord(child) && hasKey(child, mountableTag);
33
+ //# sourceMappingURL=child.mjs.map