tungsten 0.3.2 → 0.3.3

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 (278) hide show
  1. package/dist/.build-complete +1 -0
  2. package/dist/Framework.d.ts +2 -0
  3. package/dist/Framework.d.ts.map +1 -1
  4. package/dist/Framework.js +68 -57
  5. package/dist/FrameworkConfig.d.ts +2 -0
  6. package/dist/FrameworkConfig.d.ts.map +1 -1
  7. package/dist/Instance/Instance.d.ts.map +1 -1
  8. package/dist/Instance/Instance.js +18 -1
  9. package/dist/Instance/InstanceConfig.d.ts +1 -0
  10. package/dist/Instance/InstanceConfig.d.ts.map +1 -1
  11. package/dist/PopMessage.type.d.ts +6 -0
  12. package/dist/PopMessage.type.d.ts.map +1 -0
  13. package/dist/PopMessage.type.js +1 -0
  14. package/dist/Servers/DevServer.d.ts +2 -0
  15. package/dist/Servers/DevServer.d.ts.map +1 -1
  16. package/dist/Servers/DevServer.js +84 -8
  17. package/dist/Servers/MatchedRouteInfo.d.ts +1 -1
  18. package/dist/Servers/MatchedRouteInfo.d.ts.map +1 -1
  19. package/dist/Servers/ProdServer.d.ts +1 -0
  20. package/dist/Servers/ProdServer.d.ts.map +1 -1
  21. package/dist/Servers/ProdServer.js +79 -5
  22. package/dist/Servers/hono/DevServerHono.js +25 -29
  23. package/dist/Servers/hono/ProdServerHono.js +49 -142
  24. package/dist/Servers/hono/TungstenServerHono.d.ts +1 -1
  25. package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -1
  26. package/dist/Servers/hono/TungstenServerHono.js +12 -29
  27. package/dist/Servers/routing.d.ts.map +1 -1
  28. package/dist/Servers/routing.js +10 -6
  29. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +0 -3
  30. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -1
  31. package/dist/Servers/tungstenCorePrivateEnvSchema.js +3 -3
  32. package/dist/Servers/tungstenCorePublicEnvSchema.d.ts +8 -0
  33. package/dist/Servers/tungstenCorePublicEnvSchema.d.ts.map +1 -0
  34. package/dist/Servers/tungstenCorePublicEnvSchema.js +14 -0
  35. package/dist/Store/InternalStoreSchema.d.ts +2 -0
  36. package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
  37. package/dist/Store/InternalStoreSchema.js +1 -0
  38. package/dist/api/Request.d.ts +1 -1
  39. package/dist/api/Request.d.ts.map +1 -1
  40. package/dist/api/Response.d.ts +1 -1
  41. package/dist/api/Response.d.ts.map +1 -1
  42. package/dist/babelPlugins/BabelTypes.d.ts +2 -2
  43. package/dist/babelPlugins/BabelTypes.d.ts.map +1 -1
  44. package/dist/babelPlugins/BabelTypes.js +0 -1
  45. package/dist/bin/commands/build.d.ts.map +1 -1
  46. package/dist/bin/commands/build.js +3 -0
  47. package/dist/bin/commands/dev.d.ts.map +1 -1
  48. package/dist/bin/commands/dev.js +15 -4
  49. package/dist/bin/commands/devmon.d.ts +2 -0
  50. package/dist/bin/commands/devmon.d.ts.map +1 -0
  51. package/dist/bin/commands/devmon.js +66 -0
  52. package/dist/bin/index.d.ts.map +1 -1
  53. package/dist/bin/index.js +6 -0
  54. package/dist/booleanAttributeValue.d.ts +21 -0
  55. package/dist/booleanAttributeValue.d.ts.map +1 -0
  56. package/dist/booleanAttributeValue.js +23 -0
  57. package/dist/build/compileJavascript.js +1 -1
  58. package/dist/build/compileUserApp.d.ts +2 -1
  59. package/dist/build/compileUserApp.d.ts.map +1 -1
  60. package/dist/build/compileUserApp.js +8 -7
  61. package/dist/build/createInstanceConfigFile.js +1 -1
  62. package/dist/compat/types.d.ts +1 -1
  63. package/dist/compat/types.d.ts.map +1 -1
  64. package/dist/components/PopMessages.d.ts +12 -0
  65. package/dist/components/PopMessages.d.ts.map +1 -0
  66. package/dist/components/PopMessages.js +45 -0
  67. package/dist/defaultConfig.d.ts +1 -0
  68. package/dist/defaultConfig.d.ts.map +1 -1
  69. package/dist/defaultConfig.js +2 -1
  70. package/dist/env/Interfaces.d.ts +2 -1
  71. package/dist/env/Interfaces.d.ts.map +1 -1
  72. package/dist/env/getEnvSchemas.d.ts +1 -1
  73. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  74. package/dist/env/publicEnv.d.ts.map +1 -1
  75. package/dist/env/publicEnv.js +4 -1
  76. package/dist/frameworkConfigSchema.d.ts +4 -0
  77. package/dist/frameworkConfigSchema.d.ts.map +1 -1
  78. package/dist/frameworkConfigSchema.js +2 -1
  79. package/dist/hooks/index.d.ts +1 -0
  80. package/dist/hooks/index.d.ts.map +1 -1
  81. package/dist/hooks/index.js +1 -0
  82. package/dist/hooks/useInstance.d.ts +3 -0
  83. package/dist/hooks/useInstance.d.ts.map +1 -0
  84. package/dist/hooks/useInstance.js +4 -0
  85. package/dist/hydrate/hydrate.d.ts +6 -4
  86. package/dist/hydrate/hydrate.d.ts.map +1 -1
  87. package/dist/hydrate/hydrate.js +51 -13
  88. package/dist/hydrate/reconcileHydratedAttributes.d.ts.map +1 -1
  89. package/dist/hydrate/reconcileHydratedAttributes.js +4 -3
  90. package/dist/hydrate/renderHydrationMismatchBanner.d.ts +7 -0
  91. package/dist/hydrate/renderHydrationMismatchBanner.d.ts.map +1 -0
  92. package/dist/hydrate/renderHydrationMismatchBanner.js +69 -0
  93. package/dist/indexInner.d.ts +8 -0
  94. package/dist/indexInner.d.ts.map +1 -1
  95. package/dist/indexInner.js +7 -1
  96. package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -1
  97. package/dist/makeInstanceConfigFromFrameworkConfig.js +2 -1
  98. package/dist/pop.d.ts +10 -0
  99. package/dist/pop.d.ts.map +1 -0
  100. package/dist/pop.js +49 -0
  101. package/dist/rawHtml/filterContentNode.d.ts +20 -0
  102. package/dist/rawHtml/filterContentNode.d.ts.map +1 -0
  103. package/dist/rawHtml/filterContentNode.js +96 -0
  104. package/dist/rawHtml/parseHtml.d.ts +14 -0
  105. package/dist/rawHtml/parseHtml.d.ts.map +1 -1
  106. package/dist/rawHtml/parseHtml.js +4 -4
  107. package/dist/rawHtml/sanitizeHtml.d.ts +17 -0
  108. package/dist/rawHtml/sanitizeHtml.d.ts.map +1 -0
  109. package/dist/rawHtml/sanitizeHtml.js +19 -0
  110. package/dist/render/HeadData.d.ts +1 -0
  111. package/dist/render/HeadData.d.ts.map +1 -1
  112. package/dist/render/contentNodeToHtml.d.ts +18 -0
  113. package/dist/render/contentNodeToHtml.d.ts.map +1 -0
  114. package/dist/render/contentNodeToHtml.js +66 -0
  115. package/dist/render/contentToHtml.d.ts.map +1 -1
  116. package/dist/render/contentToHtml.js +2 -1
  117. package/dist/render/processHead.d.ts.map +1 -1
  118. package/dist/render/processHead.js +8 -2
  119. package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
  120. package/dist/render/renderingTreeToHtml.js +8 -1
  121. package/dist/routing/ErrorRouteType.d.ts +6 -0
  122. package/dist/routing/ErrorRouteType.d.ts.map +1 -0
  123. package/dist/routing/ErrorRouteType.js +1 -0
  124. package/dist/routing/RouteTypes.d.ts +2 -1
  125. package/dist/routing/RouteTypes.d.ts.map +1 -1
  126. package/dist/routing/Routes.d.ts +5 -0
  127. package/dist/routing/Routes.d.ts.map +1 -1
  128. package/dist/routing/TungstenErrorInfo.d.ts +6 -0
  129. package/dist/routing/TungstenErrorInfo.d.ts.map +1 -0
  130. package/dist/routing/TungstenErrorInfo.js +6 -0
  131. package/dist/style/styleContentSxy.js +21 -0
  132. package/dist/testing/hydrateTestApp.d.ts +38 -0
  133. package/dist/testing/hydrateTestApp.d.ts.map +1 -0
  134. package/dist/testing/hydrateTestApp.js +242 -0
  135. package/dist/testing/index.d.ts +4 -3
  136. package/dist/testing/index.d.ts.map +1 -1
  137. package/dist/testing/index.js +16 -2
  138. package/dist/timeProfiler.d.ts +6 -0
  139. package/dist/timeProfiler.d.ts.map +1 -0
  140. package/dist/timeProfiler.js +31 -0
  141. package/dist/update/integrateUpdateVdom.d.ts +11 -0
  142. package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
  143. package/dist/update/integrateUpdateVdom.js +9 -3
  144. package/dist/warnOnFrameworkChange.d.ts.map +1 -1
  145. package/dist/warnOnFrameworkChange.js +8 -8
  146. package/package.json +18 -16
  147. package/dist/FunctionComponentStandIn.sxyt.d.ts +0 -2
  148. package/dist/FunctionComponentStandIn.sxyt.d.ts.map +0 -1
  149. package/dist/FunctionComponentStandIn.sxyt.js +0 -52
  150. package/dist/Instance/gotoRedirect.sxyt.d.ts +0 -2
  151. package/dist/Instance/gotoRedirect.sxyt.d.ts.map +0 -1
  152. package/dist/Instance/gotoRedirect.sxyt.js +0 -148
  153. package/dist/Instance/runTrackedWork.sxyt.d.ts +0 -2
  154. package/dist/Instance/runTrackedWork.sxyt.d.ts.map +0 -1
  155. package/dist/Instance/runTrackedWork.sxyt.js +0 -35
  156. package/dist/Servers/devErrorPageAutoRetry.sxyt.d.ts +0 -2
  157. package/dist/Servers/devErrorPageAutoRetry.sxyt.d.ts.map +0 -1
  158. package/dist/Servers/devErrorPageAutoRetry.sxyt.js +0 -117
  159. package/dist/_client/cjsHelpers.sxyt.d.ts +0 -2
  160. package/dist/_client/cjsHelpers.sxyt.d.ts.map +0 -1
  161. package/dist/_client/cjsHelpers.sxyt.js +0 -45
  162. package/dist/auth/passwordHashing.sxyt.d.ts +0 -2
  163. package/dist/auth/passwordHashing.sxyt.d.ts.map +0 -1
  164. package/dist/auth/passwordHashing.sxyt.js +0 -46
  165. package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts +0 -2
  166. package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts.map +0 -1
  167. package/dist/auth/ref/checkPasswordResetToken.sxyt.js +0 -40
  168. package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts +0 -2
  169. package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts.map +0 -1
  170. package/dist/auth/ref/createPasswordResetToken.sxyt.js +0 -10
  171. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.d.ts +0 -2
  172. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.d.ts.map +0 -1
  173. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.js +0 -138
  174. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts +0 -2
  175. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts.map +0 -1
  176. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.js +0 -108
  177. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts +0 -2
  178. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts.map +0 -1
  179. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.js +0 -104
  180. package/dist/bin/commands/compile.sxyt.d.ts +0 -2
  181. package/dist/bin/commands/compile.sxyt.d.ts.map +0 -1
  182. package/dist/bin/commands/compile.sxyt.js +0 -255
  183. package/dist/build/modifySassImports.sxyt.d.ts +0 -2
  184. package/dist/build/modifySassImports.sxyt.d.ts.map +0 -1
  185. package/dist/build/modifySassImports.sxyt.js +0 -55
  186. package/dist/build/sassImportParser.sxyt.d.ts +0 -2
  187. package/dist/build/sassImportParser.sxyt.d.ts.map +0 -1
  188. package/dist/build/sassImportParser.sxyt.js +0 -110
  189. package/dist/build/scssImportParserChatgpt.sxyt.d.ts +0 -2
  190. package/dist/build/scssImportParserChatgpt.sxyt.d.ts.map +0 -1
  191. package/dist/build/scssImportParserChatgpt.sxyt.js +0 -120
  192. package/dist/clone.sxyt.d.ts +0 -2
  193. package/dist/clone.sxyt.d.ts.map +0 -1
  194. package/dist/clone.sxyt.js +0 -24
  195. package/dist/componentProxyHandlers.sxyt.d.ts +0 -2
  196. package/dist/componentProxyHandlers.sxyt.d.ts.map +0 -1
  197. package/dist/componentProxyHandlers.sxyt.js +0 -130
  198. package/dist/components/RawHtml.sxyt.d.ts +0 -2
  199. package/dist/components/RawHtml.sxyt.d.ts.map +0 -1
  200. package/dist/components/RawHtml.sxyt.js +0 -104
  201. package/dist/components/bindable/BindableSelect.sxyt.d.ts +0 -2
  202. package/dist/components/bindable/BindableSelect.sxyt.d.ts.map +0 -1
  203. package/dist/components/bindable/BindableSelect.sxyt.js +0 -186
  204. package/dist/env/injectEnv.sxyt.d.ts +0 -2
  205. package/dist/env/injectEnv.sxyt.d.ts.map +0 -1
  206. package/dist/env/injectEnv.sxyt.js +0 -20
  207. package/dist/env/parseEnv.sxyt.d.ts +0 -2
  208. package/dist/env/parseEnv.sxyt.d.ts.map +0 -1
  209. package/dist/env/parseEnv.sxyt.js +0 -11
  210. package/dist/findProjectDir.sxyt.d.ts +0 -2
  211. package/dist/findProjectDir.sxyt.d.ts.map +0 -1
  212. package/dist/findProjectDir.sxyt.js +0 -82
  213. package/dist/hmr/applyHmrModule.sxyt.d.ts +0 -2
  214. package/dist/hmr/applyHmrModule.sxyt.d.ts.map +0 -1
  215. package/dist/hmr/applyHmrModule.sxyt.js +0 -182
  216. package/dist/hmr/instanceRegistry.sxyt.d.ts +0 -2
  217. package/dist/hmr/instanceRegistry.sxyt.d.ts.map +0 -1
  218. package/dist/hmr/instanceRegistry.sxyt.js +0 -24
  219. package/dist/hmr/refreshStylesheets.sxyt.d.ts +0 -2
  220. package/dist/hmr/refreshStylesheets.sxyt.d.ts.map +0 -1
  221. package/dist/hmr/refreshStylesheets.sxyt.js +0 -46
  222. package/dist/hydrate/hydrate.sxyt.d.ts +0 -2
  223. package/dist/hydrate/hydrate.sxyt.d.ts.map +0 -1
  224. package/dist/hydrate/hydrate.sxyt.js +0 -302
  225. package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts +0 -2
  226. package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts.map +0 -1
  227. package/dist/hydrate/reconcileHydratedAttributes.sxyt.js +0 -190
  228. package/dist/importDevModuleWithRetry.sxyt.d.ts +0 -2
  229. package/dist/importDevModuleWithRetry.sxyt.d.ts.map +0 -1
  230. package/dist/importDevModuleWithRetry.sxyt.js +0 -104
  231. package/dist/innerHtmlFromProps.sxyt.d.ts +0 -2
  232. package/dist/innerHtmlFromProps.sxyt.d.ts.map +0 -1
  233. package/dist/innerHtmlFromProps.sxyt.js +0 -99
  234. package/dist/postcssPlugins/parseSelectors.sxyt.d.ts +0 -2
  235. package/dist/postcssPlugins/parseSelectors.sxyt.d.ts.map +0 -1
  236. package/dist/postcssPlugins/parseSelectors.sxyt.js +0 -62
  237. package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts +0 -2
  238. package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts.map +0 -1
  239. package/dist/postcssPlugins/parseSelectorsRich.sxyt.js +0 -155
  240. package/dist/rawHtml/parseHtml.sxyt.d.ts +0 -2
  241. package/dist/rawHtml/parseHtml.sxyt.d.ts.map +0 -1
  242. package/dist/rawHtml/parseHtml.sxyt.js +0 -239
  243. package/dist/render/getFunctionBodyAsString.sxyt.d.ts +0 -2
  244. package/dist/render/getFunctionBodyAsString.sxyt.d.ts.map +0 -1
  245. package/dist/render/getFunctionBodyAsString.sxyt.js +0 -37
  246. package/dist/render/processHead.sxyt.d.ts +0 -2
  247. package/dist/render/processHead.sxyt.d.ts.map +0 -1
  248. package/dist/render/processHead.sxyt.js +0 -93
  249. package/dist/render/processProps.sxyt.d.ts +0 -2
  250. package/dist/render/processProps.sxyt.d.ts.map +0 -1
  251. package/dist/render/processProps.sxyt.js +0 -90
  252. package/dist/routing/compareRequestToRegex.sxyt.d.ts +0 -2
  253. package/dist/routing/compareRequestToRegex.sxyt.d.ts.map +0 -1
  254. package/dist/routing/compareRequestToRegex.sxyt.js +0 -65
  255. package/dist/routing/getPathPriority.sxyt.d.ts +0 -2
  256. package/dist/routing/getPathPriority.sxyt.d.ts.map +0 -1
  257. package/dist/routing/getPathPriority.sxyt.js +0 -24
  258. package/dist/routing/matchPath.sxyt.d.ts +0 -2
  259. package/dist/routing/matchPath.sxyt.d.ts.map +0 -1
  260. package/dist/routing/matchPath.sxyt.js +0 -41
  261. package/dist/routing/patternToRegex.sxyt.d.ts +0 -2
  262. package/dist/routing/patternToRegex.sxyt.d.ts.map +0 -1
  263. package/dist/routing/patternToRegex.sxyt.js +0 -69
  264. package/dist/routing/splitRequest.sxyt.d.ts +0 -2
  265. package/dist/routing/splitRequest.sxyt.d.ts.map +0 -1
  266. package/dist/routing/splitRequest.sxyt.js +0 -47
  267. package/dist/style/jssToCss.sxyt.d.ts +0 -2
  268. package/dist/style/jssToCss.sxyt.d.ts.map +0 -1
  269. package/dist/style/jssToCss.sxyt.js +0 -17
  270. package/dist/testing/createTestApp.sxyt.d.ts +0 -2
  271. package/dist/testing/createTestApp.sxyt.d.ts.map +0 -1
  272. package/dist/testing/createTestApp.sxyt.js +0 -470
  273. package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts +0 -2
  274. package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts.map +0 -1
  275. package/dist/testing/ensureTestEnvLoaded.sxyt.js +0 -20
  276. package/dist/update/hotSwap.sxyt.d.ts +0 -2
  277. package/dist/update/hotSwap.sxyt.d.ts.map +0 -1
  278. package/dist/update/hotSwap.sxyt.js +0 -252
@@ -1,186 +0,0 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
- import { expect } from 'chai';
5
- import { Window } from 'happy-dom';
6
- import { describe } from 'sxy-test-runner';
7
- import { TungstenStatefulComponent } from "../../Components.js";
8
- import { createTestApp } from "../../testing/index.js";
9
- import { BindableSelect } from "./BindableSelect.js";
10
- import { jsx as _jsx, jsxs as _jsxs } from "tungsten/jsxRuntime.js";
11
- const optionTexts = container => [...container.querySelectorAll('option')].map(option => option.textContent);
12
- describe('BindableSelect', ({
13
- it
14
- }) => {
15
- it('renders children when no options prop is given', async () => {
16
- const window = new Window();
17
- const document = window.document;
18
- class Root extends TungstenStatefulComponent {
19
- constructor(...args) {
20
- super(...args);
21
- _defineProperty(this, "state", {
22
- choice: 'b'
23
- });
24
- _defineProperty(this, "content", () => _jsxs(BindableSelect, {
25
- bind: [this.state, 'choice'],
26
- children: [_jsx("option", {
27
- value: "a",
28
- children: "A"
29
- }), _jsx("option", {
30
- value: "b",
31
- children: "B"
32
- })]
33
- }));
34
- }
35
- }
36
- const testApp = await createTestApp(Root, {
37
- document
38
- });
39
- expect(optionTexts(testApp.container)).to.deep.equal(['A', 'B']);
40
- await testApp.unmount();
41
- });
42
- // placeholder must behave exactly as it does on a plain <select>: it reaches the element as an
43
- // attribute and HTML ignores it. It deliberately does NOT synthesize a placeholder option —
44
- // that would make BindableSelect diverge from the plain element.
45
- it('passes placeholder to the element like a plain select, adding no option', async () => {
46
- const window = new Window();
47
- const document = window.document;
48
- class Root extends TungstenStatefulComponent {
49
- constructor(...args) {
50
- super(...args);
51
- _defineProperty(this, "state", {
52
- choice: ''
53
- });
54
- _defineProperty(this, "content", () => _jsxs("main", {
55
- children: [_jsx(BindableSelect, {
56
- placeholder: "Pick one",
57
- options: [{
58
- value: 'a',
59
- text: 'A'
60
- }, {
61
- value: 'b',
62
- text: 'B'
63
- }],
64
- bind: [this.state, 'choice']
65
- }), _jsxs("select", {
66
- placeholder: "Pick one",
67
- bind: [this.state, 'choice'],
68
- children: [_jsx("option", {
69
- value: "a",
70
- children: "A"
71
- }), _jsx("option", {
72
- value: "b",
73
- children: "B"
74
- })]
75
- })]
76
- }));
77
- }
78
- }
79
- const testApp = await createTestApp(Root, {
80
- document
81
- });
82
- const [bindable, plain] = [...testApp.container.querySelectorAll('select')];
83
- expect(bindable?.getAttribute('placeholder')).to.equal('Pick one');
84
- expect(bindable?.querySelectorAll('option').length).to.equal(2);
85
- // parity with the plain element it stands in for
86
- expect(bindable?.getAttribute('placeholder')).to.equal(plain?.getAttribute('placeholder'));
87
- expect(bindable?.innerHTML).to.equal(plain?.innerHTML);
88
- await testApp.unmount();
89
- });
90
- // text is ContentNode, not string — existing string call sites are unaffected (widening).
91
- it('accepts JSX as an option text as well as a plain string', async () => {
92
- const window = new Window();
93
- const document = window.document;
94
- class Root extends TungstenStatefulComponent {
95
- constructor(...args) {
96
- super(...args);
97
- _defineProperty(this, "state", {
98
- choice: 'a'
99
- });
100
- _defineProperty(this, "content", () => _jsx(BindableSelect, {
101
- options: [{
102
- value: 'a',
103
- text: 'Plain'
104
- }, {
105
- value: 'b',
106
- text: _jsx("em", {
107
- children: "Rich"
108
- })
109
- }, {
110
- value: 'c',
111
- text: 3
112
- }],
113
- bind: [this.state, 'choice']
114
- }));
115
- }
116
- }
117
- const testApp = await createTestApp(Root, {
118
- document
119
- });
120
- expect(optionTexts(testApp.container)).to.deep.equal(['Plain', 'Rich', '3']);
121
- expect(testApp.container.querySelector('option em')).not.to.equal(null);
122
- await testApp.unmount();
123
- });
124
- it('renders options then children when both are given', async () => {
125
- const window = new Window();
126
- const document = window.document;
127
- class Root extends TungstenStatefulComponent {
128
- constructor(...args) {
129
- super(...args);
130
- _defineProperty(this, "state", {
131
- choice: 'a'
132
- });
133
- _defineProperty(this, "content", () => _jsx(BindableSelect, {
134
- options: [{
135
- value: 'a',
136
- text: 'A'
137
- }],
138
- bind: [this.state, 'choice'],
139
- children: _jsx("option", {
140
- value: "z",
141
- children: "Z"
142
- })
143
- }));
144
- }
145
- }
146
- const testApp = await createTestApp(Root, {
147
- document
148
- });
149
- expect(optionTexts(testApp.container)).to.deep.equal(['A', 'Z']);
150
- await testApp.unmount();
151
- });
152
- it('still binds the selected value back to state', async () => {
153
- const window = new Window();
154
- const document = window.document;
155
- class Root extends TungstenStatefulComponent {
156
- constructor(...args) {
157
- super(...args);
158
- _defineProperty(this, "state", {
159
- choice: 'a'
160
- });
161
- _defineProperty(this, "content", () => _jsx(BindableSelect, {
162
- placeholder: "Pick one",
163
- options: [{
164
- value: 'a',
165
- text: 'A'
166
- }, {
167
- value: 'b',
168
- text: 'B'
169
- }],
170
- bind: [this.state, 'choice']
171
- }));
172
- }
173
- }
174
- const testApp = await createTestApp(Root, {
175
- document
176
- });
177
- const select = testApp.container.querySelector('select');
178
- select.value = 'b';
179
- select.dispatchEvent(new window.Event('input', {
180
- bubbles: true
181
- }));
182
- await testApp.resolved();
183
- expect(testApp.component.state.choice).to.equal('b');
184
- await testApp.unmount();
185
- });
186
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=injectEnv.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectEnv.sxyt.d.ts","sourceRoot":"","sources":["../../src/env/injectEnv.sxyt.ts"],"names":[],"mappings":""}
@@ -1,20 +0,0 @@
1
- import { describe } from 'sxy-test-runner';
2
- import { should as setupShould, expect } from 'chai';
3
- const should = setupShould(); // eslint-disable-line @typescript-eslint/no-unused-vars
4
- import { injectEnv } from "./injectEnv.js";
5
- describe('injectEnv()', ({
6
- it
7
- }) => {
8
- it('should inject key value pairs into process.env', () => {
9
- delete process.env.foo;
10
- delete process.env.bar;
11
- expect(process.env.foo).to.be.undefined;
12
- expect(process.env.bar).to.be.undefined;
13
- injectEnv({
14
- foo: 'FOO',
15
- bar: 'BAZ'
16
- });
17
- expect(process.env.foo).to.equal('FOO');
18
- expect(process.env.bar).to.equal('BAZ');
19
- });
20
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=parseEnv.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseEnv.sxyt.d.ts","sourceRoot":"","sources":["../../src/env/parseEnv.sxyt.ts"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- // import { describe } from 'sxy-test-runner'
2
- // import { should as setupShould } from 'chai'
3
- // const should = setupShould() // eslint-disable-line @typescript-eslint/no-unused-vars
4
- export {};
5
- // import { parseEnv } from './parseEnv.js'
6
- // describe('loadEnv()', ({it}) => {
7
- // it('should extra a key value pair from some text', () => {
8
- // const env = parseEnv(' foo = bar ')
9
- // env.should.deep.equal({ foo: 'bar' })
10
- // })
11
- // })
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=findProjectDir.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findProjectDir.sxyt.d.ts","sourceRoot":"","sources":["../src/findProjectDir.sxyt.ts"],"names":[],"mappings":""}
@@ -1,82 +0,0 @@
1
- import { describe } from 'sxy-test-runner';
2
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs';
3
- import { tmpdir } from 'os';
4
- import { join } from 'path';
5
- import { findProjectDir } from "./findProjectDir.js";
6
- // Build a fixture that mirrors zod v4 - a named package containing a sub folder with a
7
- // nameless marker package.json that only sets the module format and local entry points.
8
- function makeFixture() {
9
- const root = mkdtempSync(join(tmpdir(), 'tungsten-find-project-dir-'));
10
- const packageDir = join(root, 'fake-package');
11
- const markerDir = join(packageDir, 'v4', 'core');
12
- mkdirSync(markerDir, {
13
- recursive: true
14
- });
15
- writeFileSync(join(packageDir, 'package.json'), JSON.stringify({
16
- name: 'fake-package',
17
- version: '1.2.3',
18
- type: 'module'
19
- }));
20
- writeFileSync(join(markerDir, 'package.json'), JSON.stringify({
21
- type: 'module',
22
- main: './index.cjs',
23
- module: './index.js'
24
- }));
25
- writeFileSync(join(markerDir, 'index.js'), '');
26
- return {
27
- root,
28
- packageDir,
29
- markerDir
30
- };
31
- }
32
- describe('findProjectDir()', ({
33
- it
34
- }) => {
35
- it(`returns the nearest package.json dir, named or not, by default`, () => {
36
- const {
37
- root,
38
- markerDir
39
- } = makeFixture();
40
- try {
41
- findProjectDir(markerDir).should.equal(markerDir);
42
- } finally {
43
- rmSync(root, {
44
- recursive: true,
45
- force: true
46
- });
47
- }
48
- });
49
- it(`skips nameless package.json files when requireName is set`, () => {
50
- const {
51
- root,
52
- packageDir,
53
- markerDir
54
- } = makeFixture();
55
- try {
56
- findProjectDir(markerDir, {
57
- requireName: true
58
- }).should.equal(packageDir);
59
- } finally {
60
- rmSync(root, {
61
- recursive: true,
62
- force: true
63
- });
64
- }
65
- });
66
- it(`returns the named package dir when it is the nearest one`, () => {
67
- const {
68
- root,
69
- packageDir
70
- } = makeFixture();
71
- try {
72
- findProjectDir(packageDir, {
73
- requireName: true
74
- }).should.equal(packageDir);
75
- } finally {
76
- rmSync(root, {
77
- recursive: true,
78
- force: true
79
- });
80
- }
81
- });
82
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=applyHmrModule.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"applyHmrModule.sxyt.d.ts","sourceRoot":"","sources":["../../src/hmr/applyHmrModule.sxyt.tsx"],"names":[],"mappings":""}
@@ -1,182 +0,0 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
- import { expect } from 'chai';
5
- import { Window } from 'happy-dom';
6
- import { describe } from 'sxy-test-runner';
7
- import { TungstenSimpleComponent } from "../Components.js";
8
- import { createTestApp } from "../testing/index.js";
9
- import { WideRenderedContentNodeIsComponent } from "../RenderedContentNode.js";
10
- import { AnyComponentIsFunctionComponentStandIn } from "../AnyComponent.js";
11
- import { setCurrentInstance } from "./instanceRegistry.js";
12
- import { applyHmrModule } from "./applyHmrModule.js";
13
- import { jsxs as _jsxs, jsx as _jsx } from "tungsten/jsxRuntime.js";
14
- describe('applyHmrModule()', ({
15
- it
16
- }) => {
17
- it('matches and swaps a live component by name+kind', async () => {
18
- const window = new Window();
19
- const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
20
- const Greeting = ({
21
- name
22
- }) => {
23
- return _jsxs("div", {
24
- className: "greeting",
25
- children: ["Hello ", name]
26
- });
27
- };
28
- class Root extends TungstenSimpleComponent {
29
- constructor(...args) {
30
- super(...args);
31
- _defineProperty(this, "content", () => _jsx(Greeting, {
32
- name: "Ada"
33
- }));
34
- }
35
- }
36
- const testApp = await createTestApp(Root, {
37
- document
38
- });
39
- const wrapper = testApp.component.__currentContent;
40
- if (!WideRenderedContentNodeIsComponent(wrapper) || !AnyComponentIsFunctionComponentStandIn(wrapper.element)) {
41
- throw new Error('expected the root to directly render a single function component');
42
- }
43
- setCurrentInstance(wrapper.element.__instance);
44
- const NewGreeting = ({
45
- name
46
- }) => {
47
- return _jsxs("div", {
48
- className: "greeting",
49
- children: ["Hi there ", name]
50
- });
51
- };
52
- Object.defineProperty(NewGreeting, 'name', {
53
- value: 'Greeting'
54
- });
55
- const result = await applyHmrModule({
56
- Greeting: NewGreeting
57
- }, '/test/applyHmrModule-match.tsx');
58
- expect(result.matched).to.equal(true);
59
- expect(result.orphaned).to.equal(false);
60
- await testApp.unmount();
61
- });
62
- it('reports orphaned when a still-live component export disappears from the same file', async () => {
63
- const window = new Window();
64
- const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
65
- const Greeting = ({
66
- name
67
- }) => {
68
- return _jsxs("div", {
69
- className: "greeting",
70
- children: ["Hello ", name]
71
- });
72
- };
73
- class Root extends TungstenSimpleComponent {
74
- constructor(...args) {
75
- super(...args);
76
- _defineProperty(this, "content", () => _jsx(Greeting, {
77
- name: "Ada"
78
- }));
79
- }
80
- }
81
- const testApp = await createTestApp(Root, {
82
- document
83
- });
84
- const wrapper = testApp.component.__currentContent;
85
- if (!WideRenderedContentNodeIsComponent(wrapper) || !AnyComponentIsFunctionComponentStandIn(wrapper.element)) {
86
- throw new Error('expected the root to directly render a single function component');
87
- }
88
- setCurrentInstance(wrapper.element.__instance);
89
- const file = '/test/applyHmrModule-orphan.tsx';
90
- // first edit: file still exports Greeting - establishes the "previously exported" baseline
91
- const NewGreeting = ({
92
- name
93
- }) => {
94
- return _jsxs("div", {
95
- className: "greeting",
96
- children: ["Hi there ", name]
97
- });
98
- };
99
- Object.defineProperty(NewGreeting, 'name', {
100
- value: 'Greeting'
101
- });
102
- const firstResult = await applyHmrModule({
103
- Greeting: NewGreeting
104
- }, file);
105
- expect(firstResult.matched).to.equal(true);
106
- expect(firstResult.orphaned).to.equal(false);
107
- // second edit to the SAME file: Greeting has been renamed away - the live Greeting
108
- // instance (now running NewGreeting's code) is still there, but nothing in the fresh
109
- // module matches it any more
110
- const Renamed = ({
111
- name
112
- }) => {
113
- return _jsxs("div", {
114
- className: "greeting",
115
- children: ["Renamed ", name]
116
- });
117
- };
118
- Object.defineProperty(Renamed, 'name', {
119
- value: 'Renamed'
120
- });
121
- const secondResult = await applyHmrModule({
122
- Renamed
123
- }, file);
124
- expect(secondResult.matched).to.equal(false);
125
- expect(secondResult.orphaned).to.equal(true);
126
- await testApp.unmount();
127
- });
128
- it('hot-swaps a component moved to a different file, since identity matching is name+kind based, not file-scoped', async () => {
129
- const window = new Window();
130
- const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
131
- const Greeting = ({
132
- name
133
- }) => {
134
- return _jsxs("div", {
135
- className: "greeting",
136
- children: ["Hello ", name]
137
- });
138
- };
139
- class Root extends TungstenSimpleComponent {
140
- constructor(...args) {
141
- super(...args);
142
- _defineProperty(this, "content", () => _jsx(Greeting, {
143
- name: "Ada"
144
- }));
145
- }
146
- }
147
- const testApp = await createTestApp(Root, {
148
- document
149
- });
150
- const wrapper = testApp.component.__currentContent;
151
- if (!WideRenderedContentNodeIsComponent(wrapper) || !AnyComponentIsFunctionComponentStandIn(wrapper.element)) {
152
- throw new Error('expected the root to directly render a single function component');
153
- }
154
- setCurrentInstance(wrapper.element.__instance);
155
- // simulate a single edit that moves Greeting out of its original file into a brand new
156
- // one - both calls happen on the FIRST ever edit to each file, so neither has a
157
- // previously-exported baseline to compare against (previousFileExportIdentities starts
158
- // empty per file either way)
159
- const MovedGreeting = ({
160
- name
161
- }) => {
162
- return _jsxs("div", {
163
- className: "greeting",
164
- children: ["Moved hello ", name]
165
- });
166
- };
167
- Object.defineProperty(MovedGreeting, 'name', {
168
- value: 'Greeting'
169
- });
170
- const oldFileResult = await applyHmrModule({}, '/test/applyHmrModule-move-old-file.tsx');
171
- const newFileResult = await applyHmrModule({
172
- Greeting: MovedGreeting
173
- }, '/test/applyHmrModule-move-new-file.tsx');
174
- // the old file's own result correctly sees nothing to do (it's genuinely empty now) and
175
- // isn't where the swap happens - the new file's result is what should show the match,
176
- // since applyHmrModule matches by identity across the whole live registry, not per file
177
- expect(oldFileResult.matched).to.equal(false);
178
- expect(newFileResult.matched).to.equal(true);
179
- expect(newFileResult.orphaned).to.equal(false);
180
- await testApp.unmount();
181
- });
182
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=instanceRegistry.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instanceRegistry.sxyt.d.ts","sourceRoot":"","sources":["../../src/hmr/instanceRegistry.sxyt.ts"],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- import { expect } from 'chai';
2
- import { describe } from 'sxy-test-runner';
3
- describe('instanceRegistry() - cross module-graph visibility', ({
4
- it
5
- }) => {
6
- it('setCurrentInstance() is visible from a separately-instantiated copy of the module', async () => {
7
- // In the real dev client, hydrate.tsx (and its call to setCurrentInstance) is baked into
8
- // the rolled-up, single-file client.js bundle, while applyHmrModule.js (and whatever it
9
- // imports, including this module) is loaded completely separately - as a plain, unbundled
10
- // ES module fetched fresh from the package-copy location. Those are two distinct module
11
- // instantiations of this same source file, each with their own copy of any module-scope
12
- // state. A cache-busting query string reproduces exactly that split here: Node's ESM
13
- // loader treats these two specifiers as separate module records, the same way the browser
14
- // treats the bundle and the package-copy as unrelated.
15
- const moduleA = await import("./instanceRegistry.js");
16
- const copySpecifier = './instanceRegistry.js' + '?copy=1';
17
- const moduleB = await import(copySpecifier);
18
- const fakeInstance = {
19
- marker: 'fake-instance-for-test'
20
- }; // eslint-disable-line no-type-assertion/no-type-assertion, @typescript-eslint/no-explicit-any -- only the identity of this object matters for the test
21
- moduleA.setCurrentInstance(fakeInstance);
22
- expect(moduleB.getCurrentInstance()).to.equal(fakeInstance);
23
- });
24
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=refreshStylesheets.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"refreshStylesheets.sxyt.d.ts","sourceRoot":"","sources":["../../src/hmr/refreshStylesheets.sxyt.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- import { expect } from 'chai';
2
- import { Window } from 'happy-dom';
3
- import { describe } from 'sxy-test-runner';
4
- import { refreshStylesheets } from "./refreshStylesheets.js";
5
- describe('refreshStylesheets()', ({
6
- it
7
- }) => {
8
- it('adds the new stylesheet link and waits for it to load before removing the old one', async () => {
9
- const window = new Window();
10
- const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
11
- const oldLink = document.createElement('link');
12
- oldLink.rel = 'stylesheet';
13
- oldLink.href = '/.componentCss/ccss.css';
14
- document.head.appendChild(oldLink);
15
- const donePromises = refreshStylesheets(document);
16
- expect(donePromises).to.have.length(1);
17
- // give the (synchronous, in this test) DOM mutation a tick to land
18
- await Promise.resolve();
19
- const links = document.querySelectorAll('link[rel="stylesheet"]');
20
- expect(links.length).to.equal(2);
21
- expect(document.contains(oldLink)).to.equal(true);
22
- const newLink = [...links].find(link => link !== oldLink); // eslint-disable-line no-type-assertion/no-type-assertion -- narrowed by the length check above
23
- expect(newLink).to.not.equal(undefined);
24
- expect(newLink.getAttribute('href')).to.match(/^\/\.componentCss\/ccss\.css\?t=\d+$/);
25
- // simulate the browser finishing the fetch+parse of the new stylesheet
26
- newLink.dispatchEvent(new window.Event('load')); // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Event is structurally compatible
27
- await donePromises[0];
28
- expect(document.contains(oldLink)).to.equal(false);
29
- expect(document.querySelectorAll('link[rel="stylesheet"]').length).to.equal(1);
30
- });
31
- it('removes the old link even if the new stylesheet fails to load, rather than leaving both forever', async () => {
32
- const window = new Window();
33
- const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
34
- const oldLink = document.createElement('link');
35
- oldLink.rel = 'stylesheet';
36
- oldLink.href = '/.componentCss/ccss.css';
37
- document.head.appendChild(oldLink);
38
- const [done] = refreshStylesheets(document);
39
- await Promise.resolve();
40
- const newLink = [...document.querySelectorAll('link[rel="stylesheet"]')].find(link => link !== oldLink); // eslint-disable-line no-type-assertion/no-type-assertion -- there are exactly two links at this point, one of them is oldLink
41
- expect(newLink).to.not.equal(undefined);
42
- newLink.dispatchEvent(new window.Event('error')); // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Event is structurally compatible
43
- await done;
44
- expect(document.contains(oldLink)).to.equal(false);
45
- });
46
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hydrate.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hydrate.sxyt.d.ts","sourceRoot":"","sources":["../../src/hydrate/hydrate.sxyt.tsx"],"names":[],"mappings":""}