tungsten 0.4.13 → 0.5.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 (186) hide show
  1. package/dist/.build-complete +1 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/Components.d.ts +41 -0
  4. package/dist/Components.d.ts.map +1 -1
  5. package/dist/Components.js +60 -72
  6. package/dist/ContentNode.d.ts +8 -2
  7. package/dist/ContentNode.d.ts.map +1 -1
  8. package/dist/ContentNode.js +4 -1
  9. package/dist/Framework.js +4 -4
  10. package/dist/FrameworkConfig.d.ts +0 -2
  11. package/dist/FrameworkConfig.d.ts.map +1 -1
  12. package/dist/FunctionComponentStandIn.d.ts +1 -1
  13. package/dist/FunctionComponentStandIn.d.ts.map +1 -1
  14. package/dist/FunctionComponentStandIn.js +1 -0
  15. package/dist/Instance/Instance.js +2 -2
  16. package/dist/RenderingNode.d.ts +2 -2
  17. package/dist/RenderingNode.d.ts.map +1 -1
  18. package/dist/Script.d.ts +1 -1
  19. package/dist/Script.d.ts.map +1 -1
  20. package/dist/Servers/DevServer.d.ts.map +1 -1
  21. package/dist/Servers/DevServer.js +10 -0
  22. package/dist/Servers/loadEnvsDev.js +10 -10
  23. package/dist/Servers/routing.d.ts.map +1 -1
  24. package/dist/Servers/routing.js +8 -9
  25. package/dist/Store/makeStore.d.ts +4 -4
  26. package/dist/Store/makeStore.d.ts.map +1 -1
  27. package/dist/Store/makeStore.js +23 -57
  28. package/dist/_client/cjsHelpers.d.ts.map +1 -1
  29. package/dist/_client/cjsHelpers.js +4 -2
  30. package/dist/_client/client.js +0 -14
  31. package/dist/_client/hmr.d.ts +2 -0
  32. package/dist/_client/hmr.d.ts.map +1 -0
  33. package/dist/_client/hmr.js +65 -0
  34. package/dist/_client/liveReload.d.ts +2 -0
  35. package/dist/_client/liveReload.d.ts.map +1 -0
  36. package/dist/_client/liveReload.js +6 -0
  37. package/dist/_client/liveReloadSource.d.ts +3 -0
  38. package/dist/_client/liveReloadSource.d.ts.map +1 -0
  39. package/dist/_client/liveReloadSource.js +25 -0
  40. package/dist/babelPlugins/BabelTransformDocInit.d.ts +9 -0
  41. package/dist/babelPlugins/BabelTransformDocInit.d.ts.map +1 -0
  42. package/dist/babelPlugins/BabelTransformDocInit.js +201 -0
  43. package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
  44. package/dist/babelPlugins/BabelTransformPackageImports.js +1 -10
  45. package/dist/babelPlugins/transformPackageImports/getWebLocationOfPackageFile.js +1 -1
  46. package/dist/bin/index.d.ts.map +1 -1
  47. package/dist/bin/index.js +82 -75
  48. package/dist/browserStorage.d.ts +56 -18
  49. package/dist/browserStorage.d.ts.map +1 -1
  50. package/dist/browserStorage.js +172 -102
  51. package/dist/build/bundle.d.ts +1 -1
  52. package/dist/build/bundle.d.ts.map +1 -1
  53. package/dist/build/bundle.js +45 -31
  54. package/dist/build/compileJavascript.d.ts.map +1 -1
  55. package/dist/build/compileJavascript.js +0 -1
  56. package/dist/build/createClientFiles.d.ts.map +1 -1
  57. package/dist/build/createClientFiles.js +4 -8
  58. package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
  59. package/dist/build/getSxyClientPackageAliases.js +3 -1
  60. package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
  61. package/dist/build/makeBabelUserDevConfig.js +5 -1
  62. package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
  63. package/dist/build/makeBabelUserProdConfig.js +5 -1
  64. package/dist/cliOutput.d.ts +5 -0
  65. package/dist/cliOutput.d.ts.map +1 -1
  66. package/dist/cliOutput.js +22 -0
  67. package/dist/componentProxyHandlers.d.ts +20 -13
  68. package/dist/componentProxyHandlers.d.ts.map +1 -1
  69. package/dist/componentProxyHandlers.js +130 -86
  70. package/dist/components/Link.d.ts +1 -1
  71. package/dist/components/Link.d.ts.map +1 -1
  72. package/dist/components/NativeHtml.d.ts +10 -0
  73. package/dist/components/NativeHtml.d.ts.map +1 -0
  74. package/dist/components/NativeHtml.js +12 -0
  75. package/dist/components/PopMessages.d.ts +1 -1
  76. package/dist/components/PopMessages.d.ts.map +1 -1
  77. package/dist/components/Protected.d.ts +10 -0
  78. package/dist/components/Protected.d.ts.map +1 -0
  79. package/dist/components/Protected.js +12 -0
  80. package/dist/components/Stylesheet.d.ts +1 -1
  81. package/dist/components/Stylesheet.d.ts.map +1 -1
  82. package/dist/components/bindable/BindableCheckbox.d.ts +1 -1
  83. package/dist/components/bindable/BindableCheckbox.d.ts.map +1 -1
  84. package/dist/components/bindable/BindableInput.d.ts +1 -1
  85. package/dist/components/bindable/BindableInput.d.ts.map +1 -1
  86. package/dist/components/bindable/BindableInputNonString.d.ts +1 -1
  87. package/dist/components/bindable/BindableInputNonString.d.ts.map +1 -1
  88. package/dist/components/bindable/BindableInputString.d.ts +1 -1
  89. package/dist/components/bindable/BindableInputString.d.ts.map +1 -1
  90. package/dist/components/bindable/BindableInputTyped.d.ts +1 -1
  91. package/dist/components/bindable/BindableInputTyped.d.ts.map +1 -1
  92. package/dist/components/bindable/BindableInputTypedLegacy.d.ts +1 -1
  93. package/dist/components/bindable/BindableInputTypedLegacy.d.ts.map +1 -1
  94. package/dist/components/bindable/BindableRadio.d.ts +1 -1
  95. package/dist/components/bindable/BindableRadio.d.ts.map +1 -1
  96. package/dist/components/bindable/BindableSelect.d.ts +1 -1
  97. package/dist/components/bindable/BindableSelect.d.ts.map +1 -1
  98. package/dist/components/bindable/BindableTextarea.d.ts +1 -1
  99. package/dist/components/bindable/BindableTextarea.d.ts.map +1 -1
  100. package/dist/components/library/RichTextEditor/RichTextEditor.d.ts +1 -1
  101. package/dist/components/library/RichTextEditor/RichTextEditor.d.ts.map +1 -1
  102. package/dist/components/library/RichTextEditor/contentTree.d.ts.map +1 -1
  103. package/dist/components/library/RichTextEditor/contentTree.js +2 -1
  104. package/dist/components/library/__StatefulMessage/StatefulMessage.d.ts +1 -1
  105. package/dist/components/library/__StatefulMessage/StatefulMessage.d.ts.map +1 -1
  106. package/dist/defaultConfig.d.ts.map +1 -1
  107. package/dist/defaultConfig.js +0 -1
  108. package/dist/devBanner.d.ts +4 -0
  109. package/dist/devBanner.d.ts.map +1 -0
  110. package/dist/devBanner.js +50 -0
  111. package/dist/docInit.d.ts +16 -0
  112. package/dist/docInit.d.ts.map +1 -0
  113. package/dist/docInit.js +54 -0
  114. package/dist/env/getEnvSchemas.d.ts +1 -1
  115. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  116. package/dist/env/getEnvSchemas.js +21 -22
  117. package/dist/env/registerEnvSchemas.d.ts +13 -0
  118. package/dist/env/registerEnvSchemas.d.ts.map +1 -0
  119. package/dist/env/registerEnvSchemas.js +23 -0
  120. package/dist/frameworkConfigSchema.d.ts +0 -2
  121. package/dist/frameworkConfigSchema.d.ts.map +1 -1
  122. package/dist/frameworkConfigSchema.js +0 -1
  123. package/dist/hydrate/hydrate.d.ts.map +1 -1
  124. package/dist/hydrate/hydrate.js +14 -3
  125. package/dist/hydrate/renderHydrationMismatchBanner.d.ts +1 -0
  126. package/dist/hydrate/renderHydrationMismatchBanner.d.ts.map +1 -1
  127. package/dist/hydrate/renderHydrationMismatchBanner.js +11 -63
  128. package/dist/indexInner.d.ts +6 -2
  129. package/dist/indexInner.d.ts.map +1 -1
  130. package/dist/indexInner.js +6 -1
  131. package/dist/jsxRuntime.d.ts +1 -1
  132. package/dist/jsxRuntime.d.ts.map +1 -1
  133. package/dist/jsxRuntime.js +9 -7
  134. package/dist/jsxRuntimeSignals.d.ts +8 -4
  135. package/dist/jsxRuntimeSignals.d.ts.map +1 -1
  136. package/dist/jsxRuntimeSignals.js +8 -6
  137. package/dist/mutatingFunctions.d.ts +2 -1
  138. package/dist/mutatingFunctions.d.ts.map +1 -1
  139. package/dist/mutatingFunctions.js +7 -1
  140. package/dist/nbsp.d.ts +2 -2
  141. package/dist/nbsp.d.ts.map +1 -1
  142. package/dist/rawHtml/filterContentNode.d.ts.map +1 -1
  143. package/dist/rawHtml/filterContentNode.js +3 -1
  144. package/dist/render/HeadData.d.ts +1 -0
  145. package/dist/render/HeadData.d.ts.map +1 -1
  146. package/dist/render/contentNodeToHtml.d.ts.map +1 -1
  147. package/dist/render/contentNodeToHtml.js +2 -1
  148. package/dist/render/contentToHtml.d.ts.map +1 -1
  149. package/dist/render/contentToHtml.js +3 -1
  150. package/dist/render/contentTreeToRenderingTree.d.ts.map +1 -1
  151. package/dist/render/contentTreeToRenderingTree.js +5 -1
  152. package/dist/render/processHead.d.ts.map +1 -1
  153. package/dist/render/processHead.js +15 -34
  154. package/dist/render/readDocInitScript.d.ts +3 -0
  155. package/dist/render/readDocInitScript.d.ts.map +1 -0
  156. package/dist/render/readDocInitScript.js +15 -0
  157. package/dist/render/rootToHtmlDev.d.ts.map +1 -1
  158. package/dist/routing/Group.d.ts +1 -1
  159. package/dist/routing/Group.d.ts.map +1 -1
  160. package/dist/routing/MatchedRoute.d.ts +1 -1
  161. package/dist/routing/MatchedRoute.d.ts.map +1 -1
  162. package/dist/settings.d.ts +3 -0
  163. package/dist/settings.d.ts.map +1 -1
  164. package/dist/settings.js +4 -0
  165. package/dist/signals/tracking.d.ts +33 -0
  166. package/dist/signals/tracking.d.ts.map +1 -0
  167. package/dist/signals/tracking.js +87 -0
  168. package/dist/style/styleContentSxy.d.ts.map +1 -1
  169. package/dist/style/styleContentSxy.js +6 -1
  170. package/dist/testing/installTestDocInit.d.ts +2 -0
  171. package/dist/testing/installTestDocInit.d.ts.map +1 -0
  172. package/dist/testing/installTestDocInit.js +6 -0
  173. package/dist/throwError.d.ts.map +1 -1
  174. package/dist/throwError.js +4 -1
  175. package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
  176. package/dist/update/integrateUpdateVdom.js +39 -3
  177. package/dist/warnOnFrameworkChange.js +1 -1
  178. package/package.json +7 -6
  179. package/readme.md +2 -135
  180. package/types/assets.d.ts +21 -0
  181. package/types/index.d.ts +24 -29
  182. package/types/jsx/html.d.ts +0 -1
  183. package/types/jsx/html.global.d.ts +0 -1
  184. package/types/jsx/html.values.d.ts +0 -1
  185. package/types/jsx/jsx.d.ts +8 -8
  186. package/vendor/manifest.json +2 -2
@@ -21,6 +21,9 @@ export declare const componentCssFile = "ccss.css";
21
21
  export declare const frameworkCssFolder = ".tungstenCss";
22
22
  export declare const frameworkCssFile = "tungsten.css";
23
23
  export declare const packagesFolder = ".packages";
24
+ export declare const docInitFile = "docInit.js";
25
+ export declare const docInitWindowKey = "__t_docInit";
26
+ export declare const docInitErrorsWindowKey = "__t_docInitErrors";
24
27
  export declare const unusedStyleReporting: boolean;
25
28
  export declare const defaultBrowserTargets = "since 2020";
26
29
  export declare const packageName = "tungsten";
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,cAAc,CAAA;AACtC,eAAO,MAAM,gBAAgB,SAAS,CAAA;AACtC,eAAO,MAAM,mBAAmB,kBAAuB,CAAA;AACvD,eAAO,MAAM,cAAc,uBAA+C,CAAA;AAC1E,eAAO,MAAM,eAAe,mBAAwB,CAAA;AACpD,eAAO,MAAM,mBAAmB,wBAA2C,CAAA;AAG3E,eAAO,MAAM,iBAAiB,sBAA2B,CAAA;AACzD,eAAO,MAAM,kBAAkB,uBAA4B,CAAA;AAC3D,eAAO,MAAM,YAAY,2BAA+B,CAAA;AACxD,eAAO,MAAM,gBAAgB,yBAA8B,CAAA;AAC3D,eAAO,MAAM,mBAAmB,4BAAiC,CAAA;AACjE,eAAO,MAAM,qBAAqB,cAAc,CAAA;AAEhD,eAAO,MAAM,iBAAiB,0BAA+B,CAAA;AAC7D,eAAO,MAAM,YAAY,WAAW,CAAA;AAEpC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,kBAAkB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D,eAAO,MAAM,gBAAgB,aAAa,CAAA;AAE1C,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAChD,eAAO,MAAM,gBAAgB,iBAAiB,CAAA;AAC9C,eAAO,MAAM,cAAc,cAAc,CAAA;AAEzC,eAAO,MAAM,WAAW,eAAe,CAAA;AACvC,eAAO,MAAM,gBAAgB,gBAAgB,CAAA;AAC7C,eAAO,MAAM,sBAAsB,sBAAsB,CAAA;AAEzD,eAAO,MAAM,oBAAoB,EAAE,OAAe,CAAA;AAIlD,eAAO,MAAM,qBAAqB,eAAe,CAAA;AAEjD,eAAO,MAAM,WAAW,aAAa,CAAA;AACrC,eAAO,MAAM,sBAAsB,aAAa,CAAA;AAChD,eAAO,MAAM,qBAAqB,YAAY,CAAA;AAC9C,eAAO,MAAM,mBAAmB,SAAS,CAAA"}
package/dist/settings.js CHANGED
@@ -26,6 +26,10 @@ export const componentCssFile = 'ccss.css';
26
26
  export const frameworkCssFolder = '.tungstenCss';
27
27
  export const frameworkCssFile = 'tungsten.css';
28
28
  export const packagesFolder = '.packages';
29
+ // the head script BabelTransformDocInit generates, in clientFolder; the window key its entries live under
30
+ export const docInitFile = 'docInit.js';
31
+ export const docInitWindowKey = '__t_docInit';
32
+ export const docInitErrorsWindowKey = '__t_docInitErrors';
29
33
  export const unusedStyleReporting = false;
30
34
  // the production bundle's browser floor when the config sets no `targets`: a browserslist query
31
35
  // for every browser version released since 2020. Dev applies no floor at all.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Dependency tracking for signals components.
3
+ *
4
+ * Dependencies are keyed by (object identity, key) in a side table rather than by path, so a
5
+ * consumer is connected to whatever object it actually read, wherever that object sits in a
6
+ * state tree -- a child reading `props.item.name` subscribes to (item, 'name') directly.
7
+ * The state proxies call track() from their get traps and notify() from their write paths;
8
+ * an effect collects its dependencies while it runs and drops them all before each re-run.
9
+ *
10
+ * Only synchronous reads are tracked: the active effect is restored as soon as fn() returns,
11
+ * so reads after an `await` inside an async content() are not seen.
12
+ *
13
+ * No imports here on purpose -- the proxy handlers depend on this, so it must stay a leaf.
14
+ */
15
+ export type Effect = {
16
+ deps: Set<Set<Effect>>;
17
+ trigger: () => void;
18
+ };
19
+ export declare const ITERATE: unique symbol;
20
+ export declare function createEffect(trigger: () => void): Effect;
21
+ export declare function isTracking(): boolean;
22
+ /** called by the proxies on every read; a no-op unless an effect is running */
23
+ export declare function track(target: object, key: unknown): void;
24
+ /** wake every effect subscribed to any of the given keys, each at most once */
25
+ export declare function notify(target: object, ...keys: unknown[]): void;
26
+ /** wake every effect subscribed to anything on the target; for bulk mutations like splice */
27
+ export declare function notifyAll(target: object): void;
28
+ /** run fn with reads subscribing the effect; previous deps are dropped so they are re-collected */
29
+ export declare function runEffect<T>(effect: Effect, fn: () => T): T;
30
+ /** run fn without subscribing the current effect to anything it reads */
31
+ export declare function untracked<T>(fn: () => T): T;
32
+ export declare function disposeEffect(effect: Effect): void;
33
+ //# sourceMappingURL=tracking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracking.d.ts","sourceRoot":"","sources":["../../src/signals/tracking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,MAAM,GAAG;IAEjB,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACtB,OAAO,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAID,eAAO,MAAM,OAAO,eAAoB,CAAA;AAMxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,CAExD;AAED,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI,CAUxD;AAED,+EAA+E;AAC/E,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAS/D;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAM9C;AAOD,mGAAmG;AACnG,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAS3D;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQ3C;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAElD"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Dependency tracking for signals components.
3
+ *
4
+ * Dependencies are keyed by (object identity, key) in a side table rather than by path, so a
5
+ * consumer is connected to whatever object it actually read, wherever that object sits in a
6
+ * state tree -- a child reading `props.item.name` subscribes to (item, 'name') directly.
7
+ * The state proxies call track() from their get traps and notify() from their write paths;
8
+ * an effect collects its dependencies while it runs and drops them all before each re-run.
9
+ *
10
+ * Only synchronous reads are tracked: the active effect is restored as soon as fn() returns,
11
+ * so reads after an `await` inside an async content() are not seen.
12
+ *
13
+ * No imports here on purpose -- the proxy handlers depend on this, so it must stay a leaf.
14
+ */
15
+ // pseudo-key for reads that depend on the whole collection: Object.keys, for..in, Map/Set
16
+ // iteration and size. Array iteration reads 'length' and the indexes, so needs no pseudo-key.
17
+ export const ITERATE = Symbol('iterate');
18
+ const subscribers = new WeakMap();
19
+ let active = null;
20
+ export function createEffect(trigger) {
21
+ return {
22
+ deps: new Set(),
23
+ trigger
24
+ };
25
+ }
26
+ export function isTracking() {
27
+ return active !== null;
28
+ }
29
+ /** called by the proxies on every read; a no-op unless an effect is running */
30
+ export function track(target, key) {
31
+ if (active === null) return;
32
+ let keys = subscribers.get(target);
33
+ if (keys === undefined) subscribers.set(target, keys = new Map());
34
+ let subs = keys.get(key);
35
+ if (subs === undefined) keys.set(key, subs = new Set());
36
+ if (!subs.has(active)) {
37
+ subs.add(active);
38
+ active.deps.add(subs);
39
+ }
40
+ }
41
+ /** wake every effect subscribed to any of the given keys, each at most once */
42
+ export function notify(target, ...keys) {
43
+ const map = subscribers.get(target);
44
+ if (map === undefined) return;
45
+ const fired = new Set();
46
+ for (const key of keys) {
47
+ const subs = map.get(key);
48
+ if (subs !== undefined) for (const effect of subs) fired.add(effect);
49
+ }
50
+ for (const effect of fired) effect.trigger();
51
+ }
52
+ /** wake every effect subscribed to anything on the target; for bulk mutations like splice */
53
+ export function notifyAll(target) {
54
+ const map = subscribers.get(target);
55
+ if (map === undefined) return;
56
+ const fired = new Set();
57
+ for (const subs of map.values()) for (const effect of subs) fired.add(effect);
58
+ for (const effect of fired) effect.trigger();
59
+ }
60
+ function clearDeps(effect) {
61
+ for (const subs of effect.deps) subs.delete(effect);
62
+ effect.deps.clear();
63
+ }
64
+ /** run fn with reads subscribing the effect; previous deps are dropped so they are re-collected */
65
+ export function runEffect(effect, fn) {
66
+ clearDeps(effect);
67
+ const previous = active;
68
+ active = effect;
69
+ try {
70
+ return fn();
71
+ } finally {
72
+ active = previous;
73
+ }
74
+ }
75
+ /** run fn without subscribing the current effect to anything it reads */
76
+ export function untracked(fn) {
77
+ const previous = active;
78
+ active = null;
79
+ try {
80
+ return fn();
81
+ } finally {
82
+ active = previous;
83
+ }
84
+ }
85
+ export function disposeEffect(effect) {
86
+ clearDeps(effect);
87
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"styleContentSxy.d.ts","sourceRoot":"","sources":["../../src/style/styleContentSxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EACH,KAAK,WAAW,EACnB,MAAM,mBAAmB,CAAA;AAc1B,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,eAIrE"}
1
+ {"version":3,"file":"styleContentSxy.d.ts","sourceRoot":"","sources":["../../src/style/styleContentSxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EACH,KAAK,WAAW,EAEnB,MAAM,mBAAmB,CAAA;AAc1B,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,eAIrE"}
@@ -1,5 +1,5 @@
1
1
  import { count } from 'sxy-lib/objects.js';
2
- import { ContentNodeElementIsHtml, ContentNodeElementIsComponent } from '../ContentNode.js';
2
+ import { ContentNodeElementIsHtml, ContentNodeElementIsComponent, ContentNodeIsFragment } from '../ContentNode.js';
3
3
  import { warn } from '../output.js';
4
4
  import { TungstenError } from '../TungstenError.js';
5
5
  import { componentBumpClass } from '../componentClassName.js';
@@ -44,6 +44,11 @@ function processItem(element, styles, usage) {
44
44
  }
45
45
  return;
46
46
  }
47
+ // a fragment gets no class of its own; its children are styled as if they sat in its place
48
+ if (ContentNodeIsFragment(element)) {
49
+ processItem(element[$props].children, styles, usage);
50
+ return;
51
+ }
47
52
  debug('Element must be an element. Type: ', typeof element);
48
53
  // element is a ContentNodeElement
49
54
  let tagName;
@@ -0,0 +1,2 @@
1
+ export declare function installTestDocInit(): void;
2
+ //# sourceMappingURL=installTestDocInit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installTestDocInit.d.ts","sourceRoot":"","sources":["../../src/testing/installTestDocInit.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,IAAI,IAAI,CAGzC"}
@@ -0,0 +1,6 @@
1
+ // DocInit is compiled away by BabelTransformDocInit in an app build. Tests run tsc output, where
2
+ // the global is the throwing stand-in docInit.ts installs. This makes the same split the compiled
3
+ // form does: run the function where a document exists, else hand back the server value.
4
+ export function installTestDocInit() {
5
+ globalThis.DocInit = (fn, serverValue) => typeof document !== 'undefined' ? fn() : serverValue; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- the void overload has no server value
6
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"throwError.d.ts","sourceRoot":"","sources":["../src/throwError.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAEnE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAErE"}
1
+ {"version":3,"file":"throwError.d.ts","sourceRoot":"","sources":["../src/throwError.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAKnE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAErE"}
@@ -1,7 +1,10 @@
1
1
  import { TungstenError } from './TungstenError.js';
2
2
  import { packageNameCapitalized } from './settings.js';
3
3
  export function throwError(location, message) {
4
- throw new TungstenError(errorMessage(location, message));
4
+ const error = new TungstenError(errorMessage(location, message));
5
+ // V8 only (Chrome, Node): start the stack at the caller, not here. Elsewhere the frame stays.
6
+ Error.captureStackTrace?.(error, throwError); // eslint-disable-line @typescript-eslint/no-unnecessary-condition -- absent outside V8
7
+ throw error;
5
8
  }
6
9
  export function errorMessage(location, message) {
7
10
  return `${packageNameCapitalized} ${location} error: ${message}`;
@@ -1 +1 @@
1
- {"version":3,"file":"integrateUpdateVdom.d.ts","sourceRoot":"","sources":["../../src/update/integrateUpdateVdom.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EACH,WAAW,EAAw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er.js';
4
- import { ContentNodeComponentIsClassComponent, ContentNodeIsNonRendered, ContentNodeIsLiteral, ContentNodeIsHtml, ContentNodeIsComponent, ContentNodeIsArray, ContentNodeIsElement, ContentNodeElementHasValidKey } from '../ContentNode.js';
4
+ import { ContentNodeComponentIsClassComponent, ContentNodeIsNonRendered, ContentNodeIsLiteral, ContentNodeIsHtml, ContentNodeIsComponent, ContentNodeIsArray, ContentNodeIsFragment, ContentNodeIsElement, ContentNodeElementHasValidKey } from '../ContentNode.js';
5
5
  import { StringIsHtmlEvent, htmlEvents } from '../htmlEvents.js';
6
6
  import { out, warn } from '../appOutput.js';
7
7
  import { getStyledContentFromFunctionComponent } from '../getStyledContentFromFunctionComponent.js';
@@ -207,6 +207,17 @@ export async function applyUpdate({
207
207
  debug('DD delete node because current node is non rendered');
208
208
  deleteNodeIfRendered(oldNode);
209
209
  return makeRenderedContentNodeNonRendered();
210
+ } else if (ContentNodeIsFragment(newNode)) {
211
+ // a fragment is its children to the reconciler; the rendered side never holds one
212
+ return applyUpdate({
213
+ tungstenElement,
214
+ instance,
215
+ newNode: newNode[$props].children,
216
+ oldNode,
217
+ domRegion,
218
+ domPointer,
219
+ parentNode
220
+ });
210
221
  } else if (ContentNodeIsArray(newNode)) {
211
222
  //newNode
212
223
  debug('*** Content node is array');
@@ -417,7 +428,8 @@ export async function applyUpdate({
417
428
  if (WideRenderedContentNodeIsHtml(oldNode)) {
418
429
  debug('node types', newNode[$type].toLocaleLowerCase(), oldNode[$type].toLocaleLowerCase(), newNode[$type].toLocaleLowerCase() === oldNode[$type].toLocaleLowerCase());
419
430
  }
420
- if (WideRenderedContentNodeIsHtml(oldNode) && newNode[$type].toLocaleLowerCase() === oldNode[$type].toLocaleLowerCase()) {
431
+ if (WideRenderedContentNodeIsHtml(oldNode) && newNode[$type].toLocaleLowerCase() === oldNode[$type].toLocaleLowerCase() && oldNode[$key] === newNode[$key] // a changed, gained or lost key is a new element
432
+ ) {
421
433
  return updateHtmlElement(tungstenElement, instance, newNode, oldNode, domPointer);
422
434
  } else {
423
435
  //console.log('deleting node and creating html', newNode[$type], oldNode)
@@ -429,7 +441,12 @@ export async function applyUpdate({
429
441
  }
430
442
  } else if (ContentNodeIsComponent(newNode)) {
431
443
  //console.log('Comp A', WideRenderedContentNodeIsComponent(oldNode))
432
- if (WideRenderedContentNodeIsComponent(oldNode) && newNode[$type] === oldNode[$type] && (oldNode[$key] !== undefined && newNode[$key] !== undefined || oldNode[$key] === newNode[$key])) {
444
+ if (WideRenderedContentNodeIsComponent(oldNode) && newNode[$type] === oldNode[$type] &&
445
+ // this code survived for years without issue
446
+ // but probably the simple equality check below is right
447
+ // (oldNode[$key] !== undefined && newNode[$key] !== undefined)
448
+ // || oldNode[$key] === newNode[$key]
449
+ oldNode[$key] === newNode[$key]) {
433
450
  //console.log('updating tu el', newNode, oldNode[$key], newNode[$key])
434
451
  // update
435
452
  return updateComponent({
@@ -639,6 +656,14 @@ async function createNode({
639
656
  if (ContentNodeIsNonRendered(newNode)) {
640
657
  debug('node is NonRendered');
641
658
  return makeRenderedContentNodeNonRendered();
659
+ } else if (ContentNodeIsFragment(newNode)) {
660
+ return createNode({
661
+ tungstenElement,
662
+ instance,
663
+ newNode: newNode[$props].children,
664
+ domPointer,
665
+ parentNode
666
+ });
642
667
  } else if (ContentNodeIsArray(newNode)) {
643
668
  debug('node is array');
644
669
  const renderedNodes = [];
@@ -1293,6 +1318,17 @@ async function updateClassComponent({
1293
1318
  // not fire: the component did not update.
1294
1319
  //console.log('old props', element.props)
1295
1320
  //console.log('new props', newNode[$props])
1321
+ // an opaque class (static __opaque) renders once and then owns its dom: its parent never
1322
+ // re-renders it, and its region is measured live because hand-added nodes change its length
1323
+ if (element.constructor.__opaque === true) {
1324
+ // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- the static declared on TungstenBaseComponent
1325
+ markRendered(element);
1326
+ const length = element.__domRegion?.length();
1327
+ if (length !== undefined) {
1328
+ domPointer.increment(length);
1329
+ return oldNode;
1330
+ }
1331
+ }
1296
1332
  if (propsAreEqual(element.props, newNode[$props], renderedAt(element))) {
1297
1333
  if (tracing()) trace('SKIP', element.constructor.name, '(props unchanged since tick', renderedAt(element), ')');
1298
1334
  // the dom is current for these props, so the baseline moves with it -- otherwise a
@@ -8,7 +8,7 @@ import { cliWarn } from './cliOutput.js';
8
8
  // full process restart - this just tells the developer that's needed, rather than attempting it.
9
9
  //
10
10
  // Watches a single marker file (dist/.build-complete) rather than all of dist - tungsten's own
11
- // build scripts touch it as their last step (see scripts/writeBuildMarker.mjs), so one file
11
+ // build scripts touch it as their last step (see scripts/writeBuildMarker.ts), so one file
12
12
  // covers every file a build could have changed without chokidar scanning the whole tree. Watch
13
13
  // mode (build-babel --watch) does not yet write it on each cycle, only the one-shot builds do.
14
14
  export function warnOnFrameworkChange() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tungsten",
3
- "version": "0.4.13",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,6 +38,7 @@
38
38
  "@babel/preset-react": "^7.28.5",
39
39
  "@babel/preset-typescript": "^7.29.7",
40
40
  "@babel/types": "^7.29.0",
41
+ "@jridgewell/trace-mapping": "^0.3.31",
41
42
  "@rollup/plugin-babel": "^6.1.0",
42
43
  "@rollup/plugin-commonjs": "^28.0.9",
43
44
  "@rollup/plugin-json": "^6.1.0",
@@ -121,16 +122,16 @@
121
122
  "build": "run-s -c clean build-prep build-watch",
122
123
  "clean": "rimraf intermed dist",
123
124
  "build-once": "rimraf intermed dist && pnpm build-ts-once && pnpm build-babel-once && pnpm build-component-styles",
124
- "build-component-styles": "node scripts/buildComponentStyles.mjs",
125
- "build-vendor": "node scripts/bundleVendor.mjs",
126
- "build-once-nd": "rimraf intermed dist.building && pnpm build-ts-once && pnpm build-babel-staged && node scripts/syncDist.mjs && node scripts/writeBuildMarker.mjs",
125
+ "build-component-styles": "node scripts/buildComponentStyles.ts",
126
+ "build-vendor": "node scripts/bundleVendor.ts",
127
+ "build-once-nd": "rimraf intermed dist.building && pnpm build-ts-once && pnpm build-babel-staged && node scripts/syncDist.ts && node scripts/writeBuildMarker.ts",
127
128
  "build-quick": "pnpm build-watch",
128
129
  "build-prep": "pnpm build-ts-once",
129
130
  "build-watch": "run-p build-ts build-babel",
130
131
  "build-ts": "tsc --watch",
131
132
  "build-ts-once": "tsc",
132
- "build-babel": "node scripts/watchBabelAndMark.mjs",
133
- "build-babel-once": "babel intermed --out-dir dist --ignore \"**/*.cjs\" --copy-files --config-file ./babel.framework.config.js && node scripts/writeBuildMarker.mjs",
133
+ "build-babel": "node scripts/watchBabelAndMark.ts",
134
+ "build-babel-once": "babel intermed --out-dir dist --ignore \"**/*.cjs\" --copy-files --config-file ./babel.framework.config.js && node scripts/writeBuildMarker.ts",
134
135
  "build-babel-staged": "babel intermed --out-dir dist.building --ignore \"**/*.cjs\" --copy-files --config-file ./babel.framework.config.js",
135
136
  "test": "sxy-test-runner",
136
137
  "test-once": "sxy-test-runner once",
package/readme.md CHANGED
@@ -2,139 +2,6 @@
2
2
 
3
3
  [Docs](https://robertsandiford.co.uk/tungsten)
4
4
 
5
- ## Component testing
5
+ ## Agents
6
6
 
7
- Test-specific APIs are available from `tungsten/testing` and are not exported
8
- from Tungsten's main entry point. A test project supplies its own DOM
9
- implementation, such as happy-dom or jsdom:
10
-
11
- ```tsx
12
- import { Window } from 'happy-dom'
13
- import { createTestApp } from 'tungsten/testing'
14
-
15
- describe('RootComponent', () => {
16
- it('responds to a button click', async () => {
17
- const window = new Window()
18
- const testApp = await createTestApp(RootComponent, {
19
- document: window.document as unknown as Document,
20
- props: { initialName: 'Robert' },
21
- location: '/',
22
- })
23
-
24
- try {
25
- const button = testApp.container.querySelector('button')
26
- expect(button).not.toBeNull()
27
-
28
- button!.dispatchEvent(new window.Event('click') as unknown as Event)
29
- await testApp.resolved()
30
-
31
- expect(testApp.container.textContent).toContain('Robert')
32
- } finally {
33
- await testApp.unmount()
34
- }
35
- })
36
- })
37
- ```
38
-
39
- The casts are only needed when a DOM package publishes types which are not
40
- structurally compatible with the TypeScript DOM library version used by the
41
- test project.
42
-
43
- `createTestApp()` completes the initial client render before returning.
44
- `resolved()` subsequently waits for Tungsten updates, DOM reconciliation,
45
- lifecycle-triggered updates, and promises returned by registered event
46
- handlers. It does not wait for unrelated timers, network requests, or promises
47
- which the application has not returned to Tungsten.
48
-
49
- An automatically created container is appended to the supplied document body
50
- and removed by `unmount()`. A caller-supplied container must be empty; it is
51
- emptied but retained during unmount.
52
-
53
- Registered stores are created independently for each test application. Use
54
- `testStore()` to initialize one before the root component starts:
55
-
56
- ```ts
57
- import { createTestApp, testStore } from 'tungsten/testing'
58
-
59
- const testApp = await createTestApp(RootComponent, {
60
- document,
61
- stores: [testStore(userStore, store => {
62
- store.user.set(mockUser)
63
- })],
64
- })
65
- ```
66
-
67
- Tests containing Tungsten JSX must be compiled through `tungsten compile` so
68
- they use Tungsten's JSX runtime and application transforms.
69
-
70
- ## Preparing code for tests
71
-
72
- Run a one-shot development compilation without starting a server:
73
-
74
- ```sh
75
- tungsten compile
76
- ```
77
-
78
- By default this compiles JavaScript (including JSX and Tungsten's Babel
79
- transforms), stylesheets, client support files, assets, and public files into
80
- `.tungsten/dev`.
81
- Each selected target's existing generated output is cleaned before the initial
82
- compilation, including when watch mode is used. Pass `--no-clean` to preserve
83
- existing output.
84
-
85
- Use `--output` to select an independent output root. The layout below that root
86
- is the same as `.tungsten/dev`, including `code`, `.client`, `.static`,
87
- `.assets`, `.public`, `.componentCss`, and `.packages`:
88
-
89
- ```sh
90
- tungsten compile --output .tungsten/test
91
- tungsten compile --output .tungsten/test --watch
92
- ```
93
-
94
- Cleaning and generated package-cache data are scoped to the selected output.
95
- Limit the work with one or more options:
96
-
97
- ```sh
98
- tungsten compile --js
99
- tungsten compile --css
100
- tungsten compile --client
101
- tungsten compile --assets
102
- tungsten compile --public
103
- tungsten compile --js --css
104
- ```
105
-
106
- `--all` explicitly selects all five targets.
107
-
108
- Add `--watch` to keep the JavaScript, stylesheet, asset, and/or public-file
109
- compiler running after the initial pass. Client support files are still
110
- generated once:
111
-
112
- ```sh
113
- tungsten compile --watch
114
- tungsten compile --js --watch
115
- ```
116
-
117
- For process orchestration, `--ready-file <file>` writes a small JSON file only
118
- after the initial compilation succeeds. A failed JavaScript watch cycle removes
119
- the file, and a later successful cycle recreates it. `--quiet` suppresses
120
- per-file transformation messages while retaining errors and cycle status:
121
-
122
- ```sh
123
- tungsten compile --watch --output .tungsten/test \
124
- --ready-file .tungsten/test.ready --quiet
125
- ```
126
-
127
- ## Preserving package imports in selected files
128
-
129
- Use `skipPackageCompilation` in `tungsten.config.js` for files that should be
130
- transformed and emitted without Tungsten traversing or copying their package
131
- dependencies. Bare package imports in matching files are left unchanged:
132
-
133
- ```js
134
- export default {
135
- skipPackageCompilation: '**/*.domTest.js'
136
- }
137
- ```
138
-
139
- The option accepts one glob or an array of globs. Patterns match the actual
140
- JavaScript files received by Tungsten; extensions are not translated.
7
+ If you are an agent, read [AGENTS.md](AGENTS.md)
@@ -0,0 +1,21 @@
1
+ //// Importing a stylesheet gives the url of the compiled file, inserted at build. A string so the
2
+ //// value is a valid ContentNode and can be passed as children: `<Stylesheet>{globalStyles}</Stylesheet>`
3
+ //// No import or export in this file: as a script these are ambient declarations, where in a
4
+ //// module they would be augmentations, which cannot add exports
5
+
6
+ declare module '*.css' {
7
+ const href: string
8
+ export default href
9
+ }
10
+ declare module '*.sass' {
11
+ const href: string
12
+ export default href
13
+ }
14
+ declare module '*.scss' {
15
+ const href: string
16
+ export default href
17
+ }
18
+ declare module '*.less' {
19
+ const href: string
20
+ export default href
21
+ }
package/types/index.d.ts CHANGED
@@ -1,6 +1,15 @@
1
1
 
2
2
  /* eslint-disable no-var */
3
3
 
4
+ // the stylesheet module declarations live in a script file: this one is a module, and a
5
+ // `declare module '*.css'` here would augment the app's own '*.css' declaration, which cannot add exports.
6
+ // A reference, as an import of a script file is refused
7
+ // eslint-disable-next-line @typescript-eslint/triple-slash-reference
8
+ /// <reference path="./assets.d.ts" />
9
+ // Disposable and Symbol.dispose appear in the shipped types (component using(), browser storage), and in
10
+ // TS 6 that lib comes only with ESNext - so bring it in here rather than require it of every app's lib list
11
+ /// <reference lib="esnext.disposable" />
12
+
4
13
  import { CssNames } from 'tungsten/CssNames.js'
5
14
 
6
15
  //export type { JSX } from './jsx/jsx.d.js'
@@ -12,12 +21,27 @@ declare global {
12
21
  var Scss: (style: TemplateStringsArray) => CssNames
13
22
  var ReactZoneScss: (style: TemplateStringsArray) => CssNames
14
23
  //var Less: (style: TemplateStringsArray) => CssNames
24
+
25
+ //// Rewritten at build by BabelTransformDocInit: fn is inlined into the document head and runs
26
+ //// there before <body>; the call becomes a read of its result (the server gets serverValue).
27
+ //// fn must be self-contained - only globals like document and localStorage exist in the head.
28
+ var DocInit: {
29
+ <T>(fn: () => T, serverValue: NoInfer<T>): T
30
+ (fn: () => void): void
31
+ }
15
32
  }
16
33
 
34
+ //// Apps fill these by declaration merging in their env module: `interface TungstenPrivateEnv extends PrivateEnv {}`.
35
+ //// Empty here on purpose: a base that extended the core env types would collide with an app whose schema
36
+ //// makes a core field required (TS2320). Tungsten's own reads of the core fields come from src/env/Interfaces.ts
37
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
17
38
  declare global {
39
+ interface TungstenPrivateEnv {}
40
+ interface TungstenPublicEnv {}
18
41
  var tungstenPrivateEnv: TungstenPrivateEnv
19
42
  var tungstenPublicEnv: TungstenPublicEnv
20
43
  }
44
+ /* eslint-enable @typescript-eslint/no-empty-object-type */
21
45
 
22
46
  //// In dev, cjsHelpers.ts installs a partial `process` on the browser global so that converted
23
47
  //// CommonJS packages can read process.env.NODE_ENV. It flags itself with __tungstenCjsShim so
@@ -36,33 +60,4 @@ declare global {
36
60
  // var __T_CurrentElement: TElement // eslint-disable-line no-var
37
61
  // }
38
62
 
39
- //// Allow importing css files (treated as exporting the url of the final stylesheet file
40
- //// as a string, which is actually magically inserted by compilation)
41
- //// A string is used so that the value is a valid ContentNode and can be passed as children,
42
- //// e.g. `<Stylesheet>{globalStyles}</Stylesheet>`
43
- //// For some reason these declarions are recognised, but TS complains unless the project folder
44
- //// contains an additional `declare module '*.sass'` entry
45
-
46
- // declare module '*.css'
47
- // declare module '*.sass'
48
- // declare module '*.scss'
49
- // declare module '*.less'
50
-
51
- declare module '*.css' {
52
- const href: string
53
- export default href
54
- }
55
- declare module '*.sass' {
56
- const href: string
57
- export default href
58
- }
59
- declare module '*.scss' {
60
- const href: string
61
- export default href
62
- }
63
- declare module '*.less' {
64
- const href: string
65
- export default href
66
- }
67
-
68
63
  export {}
@@ -967,7 +967,6 @@ export interface LiHTMLAttributes<T, BO extends object> extends HTMLAttributes<T
967
967
  export interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
968
968
  as?: string | undefined;
969
969
  crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined;
970
- fetchpriority?: 'high' | 'low' | 'auto';
971
970
  href?: string | undefined;
972
971
  hrefLang?: string | undefined;
973
972
  integrity?: string | undefined;
@@ -15,7 +15,6 @@ interface WheelEvent extends Event { }
15
15
  interface EventTarget { }
16
16
  interface Document { }
17
17
  interface DataTransfer { }
18
- interface StyleMedia { }
19
18
 
20
19
  interface Element { }
21
20
  interface DocumentFragment { }
@@ -7,7 +7,6 @@ export type Booleanish = boolean | 'true' | 'false'
7
7
  // ----------------------------------------------------------------------
8
8
 
9
9
  export interface AbstractView {
10
- styleMedia: StyleMedia;
11
10
  document: Document;
12
11
  }
13
12