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,52 +0,0 @@
1
- import { expect } from 'chai';
2
- import { describe } from 'sxy-test-runner';
3
- import { Instance } from "./Instance/Instance.js";
4
- import { initStores } from "./Servers/initStores.js";
5
- import { FunctionElement } from "./FunctionComponentStandIn.js";
6
- describe('FunctionElement - client-side registration', ({
7
- it
8
- }) => {
9
- it('registers itself on instance.registeredComponents when instance.isClient is true, even with no runtimeContext', () => {
10
- // The real hydrate() entry point (hydrate.tsx) constructs its Instance with NO
11
- // runtimeContext argument at all - only the test harness (testing/index.ts) passes one.
12
- // isClient still ends up true there via Instance's own processIsClient fallback (see
13
- // isClient.ts), so the registration gate has to key off instance.isClient, not
14
- // "runtimeContext !== undefined" - the latter was always false in real hydration and
15
- // meant nothing ever got registered outside of tests. See tungsten/docs/hmr.md.
16
- //
17
- // isClient.ts's own `typeof window !== 'undefined'` snapshot is itself notoriously
18
- // order-dependent across a shared test process (see hydrate.sxyt.tsx's notes), so rather
19
- // than depend on that snapshot landing correctly here, isClient is forced directly - this
20
- // test is specifically about the registration gate's own logic, not about isClient
21
- // detection (which is a separate, pre-existing concern).
22
- const location = '/';
23
- const globalData = {};
24
- const matchedRouteInfo = {
25
- key: null,
26
- params: {},
27
- content: null
28
- };
29
- const {
30
- internalStore,
31
- stores,
32
- storeSubscriptions
33
- } = initStores(location, null, globalData, matchedRouteInfo);
34
- const instanceConfig = {
35
- prod: false,
36
- useRootComponent: true,
37
- clientSideNav: false,
38
- siteBasePath: '/',
39
- staticSite: false
40
- };
41
- const emptyRoutes = {}; // eslint-disable-line no-type-assertion/no-type-assertion -- not exercised by this test
42
- // deliberately no runtimeContext argument, matching hydrate()'s real call
43
- const instance = new Instance(location, instanceConfig, null, emptyRoutes, emptyRoutes,
44
- // eslint-disable-line no-type-assertion/no-type-assertion
45
- internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo);
46
- const mutableInstance = instance; // eslint-disable-line no-type-assertion/no-type-assertion -- forcing isClient for this test, see comment above
47
- mutableInstance.isClient = true;
48
- const Greeting = () => null;
49
- const element = new FunctionElement(Greeting, {}, undefined, undefined, instance, null);
50
- expect(instance.registeredComponents).to.contain(element);
51
- });
52
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=gotoRedirect.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gotoRedirect.sxyt.d.ts","sourceRoot":"","sources":["../../src/Instance/gotoRedirect.sxyt.ts"],"names":[],"mappings":""}
@@ -1,148 +0,0 @@
1
- import { describe } from 'sxy-test-runner';
2
- import { expect } from 'chai';
3
- // aliased: an unaliased `Window` would shadow the DOM Window type the
4
- // runtime context is declared with
5
- import { Window as HappyWindow } from 'happy-dom';
6
- import { Instance } from "./Instance.js";
7
- import { WebRedirect } from "../routing/WebRedirect.js";
8
- import { RoutingRedirect } from "../routing/RoutingRedirect.js";
9
- import { initStores } from "../Servers/initStores.js";
10
- import { UpdateScheduler } from "../update/UpdateScheduler.js";
11
- // A client-side Instance whose hard redirects are recorded rather than
12
- // performed. Only the routing and redirect paths are exercised, so the rest of
13
- // the runtime is left at its defaults.
14
- const makeInstance = routes => {
15
- const replaced = [];
16
- const pushed = [];
17
- const happyWindow = new HappyWindow();
18
- // Only the two things goto() reaches for: a hard redirect leaves through
19
- // location.replace, and an in-app navigation records history.
20
- const fakeWindow = {
21
- location: {
22
- replace: url => {
23
- replaced.push(url);
24
- }
25
- },
26
- history: {
27
- pushState: (_state, _title, url) => {
28
- pushed.push(url);
29
- }
30
- }
31
- };
32
- const runtimeContext = {
33
- // eslint-disable-next-line no-type-assertion/no-type-assertion
34
- document: happyWindow.document,
35
- // eslint-disable-next-line no-type-assertion/no-type-assertion
36
- window: fakeWindow,
37
- scheduler: new UpdateScheduler(),
38
- navigation: false
39
- };
40
- const matchedRouteInfo = {
41
- key: null,
42
- params: {},
43
- content: null
44
- };
45
- const globalData = {}; // eslint-disable-line no-type-assertion/no-type-assertion
46
- const {
47
- internalStore,
48
- stores,
49
- storeSubscriptions
50
- } = initStores('/', null, globalData, matchedRouteInfo);
51
- const config = {
52
- prod: false,
53
- useRootComponent: true,
54
- clientSideNav: false,
55
- siteBasePath: '/',
56
- staticSite: false
57
- };
58
- const instance = new Instance('/', config, null,
59
- // eslint-disable-next-line no-type-assertion/no-type-assertion
60
- routes, routes,
61
- // eslint-disable-line no-type-assertion/no-type-assertion
62
- internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo, runtimeContext);
63
- return {
64
- instance,
65
- replaced,
66
- pushed
67
- };
68
- };
69
- const legacyUrl = 'http://legacy.test/';
70
- describe('Instance.goto() redirects', ({
71
- it
72
- }) => {
73
- // A WebRedirect names a URL, not a route, so it has to leave the
74
- // application. Client-side navigation used to throw here, which meant a
75
- // session that expired between page load and a Link click hit an error
76
- // instead of the log in page.
77
- it('leaves the application for a WebRedirect returned by route data', async () => {
78
- const {
79
- instance,
80
- replaced
81
- } = makeInstance({
82
- '/gone': {
83
- content: null,
84
- data: async () => new WebRedirect(legacyUrl)
85
- },
86
- '404': {
87
- content: null
88
- }
89
- });
90
- await instance.goto('/gone');
91
- expect(replaced).to.deep.equal([legacyUrl]);
92
- });
93
- it('does not adopt the redirect as the current route', async () => {
94
- const {
95
- instance
96
- } = makeInstance({
97
- '/gone': {
98
- content: null,
99
- data: async () => new WebRedirect(legacyUrl)
100
- },
101
- '404': {
102
- content: null
103
- }
104
- });
105
- await instance.goto('/gone');
106
- // it left the app; the route it was heading for never became current
107
- expect(instance.matchedRouteInfo.key).to.not.equal('/gone');
108
- });
109
- it('still routes within the application for a RoutingRedirect', async () => {
110
- const {
111
- instance,
112
- replaced
113
- } = makeInstance({
114
- '/old': {
115
- content: null,
116
- data: async () => new RoutingRedirect('/new')
117
- },
118
- '/new': {
119
- content: null
120
- },
121
- '404': {
122
- content: null
123
- }
124
- });
125
- await instance.goto('/old');
126
- expect(replaced).to.deep.equal([]);
127
- expect(instance.matchedRouteInfo.key).to.equal('/new');
128
- });
129
- it('does not redirect for an ordinary data result', async () => {
130
- const {
131
- instance,
132
- replaced
133
- } = makeInstance({
134
- '/ok': {
135
- content: null,
136
- data: async () => ({
137
- value: 1
138
- })
139
- },
140
- '404': {
141
- content: null
142
- }
143
- });
144
- await instance.goto('/ok');
145
- expect(replaced).to.deep.equal([]);
146
- expect(instance.matchedRouteInfo.key).to.equal('/ok');
147
- });
148
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=runTrackedWork.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runTrackedWork.sxyt.d.ts","sourceRoot":"","sources":["../../src/Instance/runTrackedWork.sxyt.ts"],"names":[],"mappings":""}
@@ -1,35 +0,0 @@
1
- import { expect } from 'chai';
2
- import { describe } from 'sxy-test-runner';
3
- import { runTrackedWork } from "./Instance.js";
4
- describe('runTrackedWork() (no-scheduler tracked work fallback)', ({
5
- it
6
- }) => {
7
- it('reports a synchronous throw with its description', () => {
8
- const reports = [];
9
- runTrackedWork(() => {
10
- throw new Error('sync fail');
11
- }, 'Comp componentDidUpdate lifecycle', (error, description) => reports.push([error, description]));
12
- expect(reports).to.have.length(1);
13
- expect((reports[0]?.[0]).message).to.equal('sync fail');
14
- expect(reports[0]?.[1]).to.equal('Comp componentDidUpdate lifecycle');
15
- });
16
- it('reports an async rejection instead of leaving it unhandled', async () => {
17
- const reports = [];
18
- runTrackedWork(async () => {
19
- await Promise.resolve();
20
- throw new Error('async fail');
21
- }, 'Comp componentDidUpdate lifecycle', (error, description) => reports.push([error, description]));
22
- await new Promise(resolve => setTimeout(resolve, 0));
23
- expect(reports).to.have.length(1);
24
- expect((reports[0]?.[0]).message).to.equal('async fail');
25
- expect(reports[0]?.[1]).to.equal('Comp componentDidUpdate lifecycle');
26
- });
27
- it('reports nothing for successful sync and async work', async () => {
28
- const reports = [];
29
- const report = error => reports.push(error);
30
- runTrackedWork(() => 'ok', 'sync work', report);
31
- runTrackedWork(async () => 'ok', 'async work', report);
32
- await new Promise(resolve => setTimeout(resolve, 0));
33
- expect(reports).to.have.length(0);
34
- });
35
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=devErrorPageAutoRetry.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devErrorPageAutoRetry.sxyt.d.ts","sourceRoot":"","sources":["../../src/Servers/devErrorPageAutoRetry.sxyt.ts"],"names":[],"mappings":""}
@@ -1,117 +0,0 @@
1
- import { expect } from 'chai';
2
- import { describe } from 'sxy-test-runner';
3
- import { devErrorPageAutoRetryScript, devErrorPageClearRetryScript, maxAutoRetryAttempts } from "./devErrorPageAutoRetry.js";
4
- describe('devErrorPageAutoRetryScript()', ({
5
- it
6
- }) => {
7
- it('returns a script that reloads the page for a transient module-shape error', () => {
8
- const error = new SyntaxError(`The requested module './Button.js' does not provide an export named 'Button'`);
9
- const script = devErrorPageAutoRetryScript(error);
10
- expect(script).to.contain('sessionStorage');
11
- expect(script).to.contain('location.reload()');
12
- expect(script).to.contain(String(maxAutoRetryAttempts));
13
- });
14
- it('returns nothing for a genuine, unrelated error - so a real bug does not silently auto-reload forever', () => {
15
- const error = new Error('something else broke entirely');
16
- expect(devErrorPageAutoRetryScript(error)).to.equal('');
17
- });
18
- it('returns nothing for a non-Error thrown value', () => {
19
- expect(devErrorPageAutoRetryScript('a plain string was thrown')).to.equal('');
20
- });
21
- });
22
- describe('devErrorPageClearRetryScript', ({
23
- it
24
- }) => {
25
- it('clears the same sessionStorage key the retry script writes to', () => {
26
- const error = new SyntaxError(`does not provide an export named 'X'`);
27
- const retryScript = devErrorPageAutoRetryScript(error);
28
- const keyMatch = retryScript.match(/var key='([^']+)'/);
29
- expect(keyMatch).to.not.equal(null);
30
- expect(devErrorPageClearRetryScript).to.contain(keyMatch[1]);
31
- });
32
- });
33
- describe('devErrorPageAutoRetryScript() - executed in a sandbox', ({
34
- it
35
- }) => {
36
- function run(script, sessionStorage) {
37
- let reloaded = false;
38
- let threw = null;
39
- const location = {
40
- reload: () => {
41
- reloaded = true;
42
- }
43
- };
44
- const fakeSetTimeout = fn => fn(); // run "immediately" for the test
45
- try {
46
- // eslint-disable-next-line no-new-func -- executing the generated dev-page script is exactly what's under test
47
- const fn = new Function('sessionStorage', 'location', 'setTimeout', 'console', script);
48
- fn(sessionStorage, location, fakeSetTimeout, console);
49
- } catch (e) {
50
- threw = e;
51
- }
52
- return {
53
- reloaded,
54
- threw
55
- };
56
- }
57
- it('reloads once when sessionStorage works normally', () => {
58
- const store = new Map();
59
- const sessionStorage = {
60
- getItem: k => store.get(k) ?? null,
61
- setItem: (k, v) => {
62
- store.set(k, v);
63
- }
64
- };
65
- const script = devErrorPageAutoRetryScript(new SyntaxError(`does not provide an export named 'X'`));
66
- const {
67
- reloaded,
68
- threw
69
- } = run(script, sessionStorage);
70
- expect(threw).to.equal(null);
71
- expect(reloaded).to.equal(true);
72
- });
73
- it('does not reload (and does not throw) once the attempt cap is reached', () => {
74
- const store = new Map([['tungstenDevErrorRetryCount', String(maxAutoRetryAttempts)]]);
75
- const sessionStorage = {
76
- getItem: k => store.get(k) ?? null,
77
- setItem: (k, v) => {
78
- store.set(k, v);
79
- }
80
- };
81
- const script = devErrorPageAutoRetryScript(new SyntaxError(`does not provide an export named 'X'`));
82
- const {
83
- reloaded,
84
- threw
85
- } = run(script, sessionStorage);
86
- expect(threw).to.equal(null);
87
- expect(reloaded).to.equal(false);
88
- });
89
- it('degrades safely (no throw, no reload) when sessionStorage itself is blocked - e.g. some private-browsing modes', () => {
90
- const sessionStorage = {
91
- getItem: () => {
92
- throw new Error('SecurityError: sessionStorage is not available');
93
- },
94
- setItem: () => {
95
- throw new Error('SecurityError: sessionStorage is not available');
96
- }
97
- };
98
- const script = devErrorPageAutoRetryScript(new SyntaxError(`does not provide an export named 'X'`));
99
- const {
100
- reloaded,
101
- threw
102
- } = run(script, sessionStorage);
103
- expect(threw).to.equal(null);
104
- expect(reloaded).to.equal(false);
105
- });
106
- it('devErrorPageClearRetryScript also degrades safely when sessionStorage is blocked', () => {
107
- const sessionStorage = {
108
- removeItem: () => {
109
- throw new Error('SecurityError: sessionStorage is not available');
110
- }
111
- };
112
- const {
113
- threw
114
- } = run(devErrorPageClearRetryScript, sessionStorage);
115
- expect(threw).to.equal(null);
116
- });
117
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cjsHelpers.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cjsHelpers.sxyt.d.ts","sourceRoot":"","sources":["../../src/_client/cjsHelpers.sxyt.ts"],"names":[],"mappings":""}
@@ -1,45 +0,0 @@
1
- import { expect } from 'chai';
2
- import { describe } from 'sxy-test-runner';
3
- import { mkdtemp, rm, writeFile } from 'fs/promises';
4
- import { tmpdir } from 'os';
5
- import { join } from 'path';
6
- import { pathToFileURL } from 'url';
7
- // cjsHelpers is browser code - it installs a `process` shim and a window global as soon as
8
- // it is imported. Stub the window it expects and put node's own process back afterwards.
9
- const nodeProcess = Reflect.get(globalThis, 'process');
10
- Reflect.set(globalThis, 'window', {});
11
- const {
12
- loadDeps
13
- } = await import("./cjsHelpers.js");
14
- Reflect.set(globalThis, 'process', nodeProcess);
15
- // a converted CJS module exports its factory as the default and its dependencies as `deps`
16
- function moduleSource(deps) {
17
- return `export const deps = ${JSON.stringify(deps)}\n` + 'export default function (module) { module.exports = {} }\n';
18
- }
19
- describe('_client/cjsHelpers loadDeps()', ({
20
- it
21
- }) => {
22
- it(`loads a dependency cycle instead of hanging`, async () => {
23
- const dir = await mkdtemp(join(tmpdir(), 'tungsten-load-deps-'));
24
- try {
25
- // .mjs so that node does not have to guess the module type of a file in a
26
- // temp dir with no package.json
27
- const a = pathToFileURL(join(dir, 'a.mjs')).href;
28
- const b = pathToFileURL(join(dir, 'b.mjs')).href;
29
- const c = pathToFileURL(join(dir, 'c.mjs')).href;
30
- // a <-> b is circular, and both reach c
31
- await writeFile(join(dir, 'a.mjs'), moduleSource([b, c]));
32
- await writeFile(join(dir, 'b.mjs'), moduleSource([a, c]));
33
- await writeFile(join(dir, 'c.mjs'), moduleSource([]));
34
- const timeout = new Promise(resolve => setTimeout(() => resolve('timed out'), 5000).unref());
35
- const loaded = await Promise.race([loadDeps([a]), timeout]);
36
- expect(loaded).not.to.equal('timed out');
37
- expect(Object.keys(loaded).sort()).to.deep.equal([a, b, c].sort());
38
- } finally {
39
- await rm(dir, {
40
- recursive: true,
41
- force: true
42
- });
43
- }
44
- });
45
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=passwordHashing.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"passwordHashing.sxyt.d.ts","sourceRoot":"","sources":["../../src/auth/passwordHashing.sxyt.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- import { describe } from 'sxy-test-runner';
2
- import { expect } from 'chai';
3
- import { hashPassword, hashPasswordBytes } from "./hashPassword.js";
4
- import { checkPassword, checkPasswordBytes } from "./checkPassword.js";
5
- describe('hashPassword()', ({
6
- it
7
- }) => {
8
- it('hashes a password and returns a string', async () => {
9
- const hashed = await hashPassword('abcd');
10
- //console.log('hashed: ' + hashed)
11
- expect(hashed).to.be.a('string');
12
- expect(hashed.length).to.be.at.least(10);
13
- });
14
- });
15
- describe('hashPasswordBytes()', ({
16
- it
17
- }) => {
18
- it('hashes a password and returns an array of bytes', async () => {
19
- const hashedBytes = await hashPasswordBytes('abcd');
20
- expect(hashedBytes).to.be.an.instanceOf(Buffer);
21
- const hashedString = hashedBytes.toString();
22
- //console.log('hashedString: ' + hashedString)
23
- expect(hashedString).to.be.a('string');
24
- expect(hashedString.length).to.be.at.least(10);
25
- });
26
- });
27
- describe('checkPassword()', ({
28
- it
29
- }) => {
30
- it('It states whether a password matches the input', async () => {
31
- const password = 'xyz';
32
- const hashed = await hashPassword(password);
33
- expect(await checkPassword(password, hashed)).to.equal(true);
34
- expect(await checkPassword(password + 'NotOurPassword', hashed)).to.equal(false);
35
- });
36
- });
37
- describe('checkPasswordBytes()', ({
38
- it
39
- }) => {
40
- it('It states whether a password matches the input', async () => {
41
- const password = 'xyz';
42
- const hashed = await hashPasswordBytes(password);
43
- expect(await checkPasswordBytes(password, hashed)).to.equal(true);
44
- expect(await checkPasswordBytes(password + 'NotOurPassword', hashed)).to.equal(false);
45
- });
46
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=checkPasswordResetToken.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkPasswordResetToken.sxyt.d.ts","sourceRoot":"","sources":["../../../src/auth/ref/checkPasswordResetToken.sxyt.js"],"names":[],"mappings":""}
@@ -1,40 +0,0 @@
1
- // import { describe } from 'sxy-test-runner'
2
- // import crypto from 'crypto'
3
- export {};
4
- // import { PasswordResetToken } from '../models/PasswordResetToken'
5
- // import { prisma } from '../prisma/client'
6
- // import { checkPasswordResetToken } from './checkPasswordResetToken.js'
7
- // import { createPasswordResetToken } from './createPasswordResetToken.js'
8
- // describe('checkPasswordResetToken() function', async ({it}) => {
9
- // const user = await prisma.user.findFirst({ where: { id: 1 } })
10
- // it('fails with junk data', async () => {
11
- // const user = await prisma.user.findFirst({ where: { id: 1 } })
12
- // const result = await checkPasswordResetToken(user, 'junk')
13
- // result.success.should.equal(false)
14
- // result.reason.should.equal('Invalid')
15
- // })
16
- // it('succeeds with a valid token', async () => {
17
- // //const user = await prisma.user.findFirst({ where: { id: 1 } })
18
- // const token = await createPasswordResetToken(user)
19
- // //console.log('test token', token)
20
- // const result = await checkPasswordResetToken(user, token)
21
- // result.success.should.equal(true)
22
- // result.reason.should.equal('Valid')
23
- // })
24
- // it('fails with an outdated token', async () => {
25
- // //const user = await prisma.user.findFirst({ where: { id: 1 } })
26
- // const token = 'abcde'
27
- // const hash = crypto.createHash('sha256').update(user.id + token).digest('base64url')
28
- // const passwordResetToken = new PasswordResetToken
29
- // passwordResetToken.userId = user.id
30
- // passwordResetToken.hash = hash
31
- // passwordResetToken.expiresAt = new Date(Date.now() - 99999)
32
- // await passwordResetToken.create()
33
- // const result = await checkPasswordResetToken(user, token)
34
- // result.success.should.equal(false)
35
- // result.reason.should.equal('Expired')
36
- // await prisma.passwordResetToken.delete({ where: {
37
- // id: passwordResetToken.id
38
- // } })
39
- // })
40
- // })
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=createPasswordResetToken.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createPasswordResetToken.sxyt.d.ts","sourceRoot":"","sources":["../../../src/auth/ref/createPasswordResetToken.sxyt.js"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- // import { describe } from 'sxy-test-runner'
2
- // import { prisma } from '../prisma/client'
3
- // import { createPasswordResetToken } from './createPasswordResetToken.js'
4
- export {};
5
- // describe('createPasswordResetToken() function', ({it}) => {
6
- // it('creates a reset token and saves it to the database', async () => {
7
- // const user = await prisma.user.findFirst({ where: { id: 1 } })
8
- // createPasswordResetToken(user)
9
- // })
10
- // })
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=BabelAddDevCacheBust.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BabelAddDevCacheBust.sxyt.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/BabelAddDevCacheBust.sxyt.ts"],"names":[],"mappings":""}