tungsten 0.3.2 → 0.3.4

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 (397) hide show
  1. package/dist/.build-complete +1 -0
  2. package/dist/Components.d.ts +6 -1
  3. package/dist/Components.d.ts.map +1 -1
  4. package/dist/Components.js +103 -40
  5. package/dist/DomPointer.d.ts +11 -0
  6. package/dist/DomPointer.d.ts.map +1 -1
  7. package/dist/DomPointer.js +15 -0
  8. package/dist/DomRegion.d.ts +2 -0
  9. package/dist/DomRegion.d.ts.map +1 -1
  10. package/dist/DomRegion.js +23 -3
  11. package/dist/Framework.d.ts +2 -0
  12. package/dist/Framework.d.ts.map +1 -1
  13. package/dist/Framework.js +94 -61
  14. package/dist/FrameworkConfig.d.ts +4 -0
  15. package/dist/FrameworkConfig.d.ts.map +1 -1
  16. package/dist/Instance/Instance.d.ts +1 -1
  17. package/dist/Instance/Instance.d.ts.map +1 -1
  18. package/dist/Instance/Instance.js +18 -1
  19. package/dist/Instance/InstanceConfig.d.ts +1 -0
  20. package/dist/Instance/InstanceConfig.d.ts.map +1 -1
  21. package/dist/PopMessage.type.d.ts +6 -0
  22. package/dist/PopMessage.type.d.ts.map +1 -0
  23. package/dist/PopMessage.type.js +1 -0
  24. package/dist/Servers/DevServer.d.ts +2 -0
  25. package/dist/Servers/DevServer.d.ts.map +1 -1
  26. package/dist/Servers/DevServer.js +87 -11
  27. package/dist/Servers/MatchedRouteInfo.d.ts +1 -1
  28. package/dist/Servers/MatchedRouteInfo.d.ts.map +1 -1
  29. package/dist/Servers/ProdServer.d.ts +2 -1
  30. package/dist/Servers/ProdServer.d.ts.map +1 -1
  31. package/dist/Servers/ProdServer.js +92 -8
  32. package/dist/Servers/hono/DevServerHono.js +25 -29
  33. package/dist/Servers/hono/ProdServerHono.js +49 -142
  34. package/dist/Servers/hono/TungstenServerHono.d.ts +1 -1
  35. package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -1
  36. package/dist/Servers/hono/TungstenServerHono.js +12 -29
  37. package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
  38. package/dist/Servers/loadEnvsDev.js +16 -5
  39. package/dist/Servers/routing.d.ts.map +1 -1
  40. package/dist/Servers/routing.js +10 -6
  41. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +0 -3
  42. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -1
  43. package/dist/Servers/tungstenCorePrivateEnvSchema.js +3 -3
  44. package/dist/Servers/tungstenCorePublicEnvSchema.d.ts +8 -0
  45. package/dist/Servers/tungstenCorePublicEnvSchema.d.ts.map +1 -0
  46. package/dist/Servers/tungstenCorePublicEnvSchema.js +14 -0
  47. package/dist/Store/InternalStoreSchema.d.ts +2 -0
  48. package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
  49. package/dist/Store/InternalStoreSchema.js +1 -0
  50. package/dist/api/Request.d.ts +1 -1
  51. package/dist/api/Request.d.ts.map +1 -1
  52. package/dist/api/Response.d.ts +1 -1
  53. package/dist/api/Response.d.ts.map +1 -1
  54. package/dist/babelPlugins/BabelExtractComponentStylesheet.d.ts +13 -0
  55. package/dist/babelPlugins/BabelExtractComponentStylesheet.d.ts.map +1 -0
  56. package/dist/babelPlugins/BabelExtractComponentStylesheet.js +24 -0
  57. package/dist/babelPlugins/BabelTransformComponentStyles.d.ts +2 -0
  58. package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
  59. package/dist/babelPlugins/BabelTransformComponentStyles.js +21 -5
  60. package/dist/babelPlugins/BabelTransformPackageImports.d.ts +1 -0
  61. package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
  62. package/dist/babelPlugins/BabelTransformPackageImports.js +21 -9
  63. package/dist/babelPlugins/BabelTypes.d.ts +2 -2
  64. package/dist/babelPlugins/BabelTypes.d.ts.map +1 -1
  65. package/dist/babelPlugins/BabelTypes.js +0 -1
  66. package/dist/bin/commands/build.d.ts.map +1 -1
  67. package/dist/bin/commands/build.js +12 -2
  68. package/dist/bin/commands/compile.d.ts.map +1 -1
  69. package/dist/bin/commands/compile.js +7 -2
  70. package/dist/bin/commands/dev.d.ts.map +1 -1
  71. package/dist/bin/commands/dev.js +15 -4
  72. package/dist/bin/commands/devmon.d.ts +2 -0
  73. package/dist/bin/commands/devmon.d.ts.map +1 -0
  74. package/dist/bin/commands/devmon.js +66 -0
  75. package/dist/bin/index.d.ts.map +1 -1
  76. package/dist/bin/index.js +6 -0
  77. package/dist/booleanAttributeValue.d.ts +21 -0
  78. package/dist/booleanAttributeValue.d.ts.map +1 -0
  79. package/dist/booleanAttributeValue.js +23 -0
  80. package/dist/build/CompilationInfo.d.ts +1 -0
  81. package/dist/build/CompilationInfo.d.ts.map +1 -1
  82. package/dist/build/combineComponentCss.d.ts +1 -1
  83. package/dist/build/combineComponentCss.d.ts.map +1 -1
  84. package/dist/build/combineComponentCss.js +3 -3
  85. package/dist/build/compileJavascript.d.ts.map +1 -1
  86. package/dist/build/compileJavascript.js +3 -3
  87. package/dist/build/compileUserApp.d.ts +2 -1
  88. package/dist/build/compileUserApp.d.ts.map +1 -1
  89. package/dist/build/compileUserApp.js +18 -8
  90. package/dist/build/createInstanceConfigFile.js +1 -1
  91. package/dist/build/frameworkStylesheets.d.ts +5 -0
  92. package/dist/build/frameworkStylesheets.d.ts.map +1 -0
  93. package/dist/build/frameworkStylesheets.js +49 -0
  94. package/dist/build/getPackageDirForFile.d.ts +2 -0
  95. package/dist/build/getPackageDirForFile.d.ts.map +1 -0
  96. package/dist/build/getPackageDirForFile.js +11 -0
  97. package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
  98. package/dist/build/getSxyClientPackageAliases.js +3 -1
  99. package/dist/build/makeBabelUserDevConfig.d.ts +1 -1
  100. package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
  101. package/dist/build/makeBabelUserDevConfig.js +3 -2
  102. package/dist/build/makeBabelUserProdConfig.d.ts +1 -1
  103. package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
  104. package/dist/build/makeBabelUserProdConfig.js +4 -2
  105. package/dist/build/rollup.user.prod.config.d.ts.map +1 -1
  106. package/dist/build/rollup.user.prod.config.js +4 -1
  107. package/dist/build/rollupExtractComponentStylesheets.d.ts +12 -0
  108. package/dist/build/rollupExtractComponentStylesheets.d.ts.map +1 -0
  109. package/dist/build/rollupExtractComponentStylesheets.js +35 -0
  110. package/dist/compat/context.d.ts +1 -1
  111. package/dist/compat/context.d.ts.map +1 -1
  112. package/dist/compat/types.d.ts +1 -1
  113. package/dist/compat/types.d.ts.map +1 -1
  114. package/dist/componentCss/i/T-components-library-RichTextEditor-RichTextEditor.css +115 -0
  115. package/dist/componentCss/i/T-components-library-__StatefulMessage-StatefulMessage.css +25 -0
  116. package/dist/componentCss/tungsten.css +2 -0
  117. package/dist/componentProxyHandlers.d.ts +2 -1
  118. package/dist/componentProxyHandlers.d.ts.map +1 -1
  119. package/dist/componentProxyHandlers.js +45 -9
  120. package/dist/components/GoToComponent.d.ts +1 -1
  121. package/dist/components/GoToComponent.d.ts.map +1 -1
  122. package/dist/components/PopMessages.d.ts +12 -0
  123. package/dist/components/PopMessages.d.ts.map +1 -0
  124. package/dist/components/PopMessages.js +45 -0
  125. package/dist/components/_GoToComponent.d.ts +10 -0
  126. package/dist/components/_GoToComponent.d.ts.map +1 -0
  127. package/dist/components/_GoToComponent.js +13 -0
  128. package/dist/components/library/RichTextEditor/RichTextEditor.d.ts +50 -0
  129. package/dist/components/library/RichTextEditor/RichTextEditor.d.ts.map +1 -0
  130. package/dist/components/library/RichTextEditor/RichTextEditor.js +458 -0
  131. package/dist/components/library/RichTextEditor/StoredContentNode.d.ts +5 -0
  132. package/dist/components/library/RichTextEditor/StoredContentNode.d.ts.map +1 -0
  133. package/dist/components/library/RichTextEditor/StoredContentNode.js +1 -0
  134. package/dist/components/library/RichTextEditor/activeFormats.d.ts +20 -0
  135. package/dist/components/library/RichTextEditor/activeFormats.d.ts.map +1 -0
  136. package/dist/components/library/RichTextEditor/activeFormats.js +48 -0
  137. package/dist/components/library/RichTextEditor/contentTree.d.ts +30 -0
  138. package/dist/components/library/RichTextEditor/contentTree.d.ts.map +1 -0
  139. package/dist/components/library/RichTextEditor/contentTree.js +81 -0
  140. package/dist/components/library/RichTextEditor/sanitizeAuthoredHtml.d.ts +30 -0
  141. package/dist/components/library/RichTextEditor/sanitizeAuthoredHtml.d.ts.map +1 -0
  142. package/dist/components/library/RichTextEditor/sanitizeAuthoredHtml.js +97 -0
  143. package/dist/components/library/__StatefulMessage/MessageData.d.ts +7 -0
  144. package/dist/components/library/__StatefulMessage/MessageData.d.ts.map +1 -0
  145. package/dist/components/library/__StatefulMessage/MessageData.js +1 -0
  146. package/dist/components/library/__StatefulMessage/StatefulMessage.d.ts +22 -0
  147. package/dist/components/library/__StatefulMessage/StatefulMessage.d.ts.map +1 -0
  148. package/dist/components/library/__StatefulMessage/StatefulMessage.js +88 -0
  149. package/dist/components/library/index.d.ts +5 -0
  150. package/dist/components/library/index.d.ts.map +1 -0
  151. package/dist/components/library/index.js +7 -0
  152. package/dist/defaultConfig.d.ts +2 -0
  153. package/dist/defaultConfig.d.ts.map +1 -1
  154. package/dist/defaultConfig.js +3 -1
  155. package/dist/env/Interfaces.d.ts +2 -1
  156. package/dist/env/Interfaces.d.ts.map +1 -1
  157. package/dist/env/getEnvSchemas.d.ts +1 -1
  158. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  159. package/dist/env/injectEnv.d.ts +1 -1
  160. package/dist/env/injectEnv.d.ts.map +1 -1
  161. package/dist/env/injectEnv.js +16 -6
  162. package/dist/env/publicEnv.d.ts.map +1 -1
  163. package/dist/env/publicEnv.js +4 -1
  164. package/dist/findUserConfig.d.ts +1 -1
  165. package/dist/frameworkConfigSchema.d.ts +4 -0
  166. package/dist/frameworkConfigSchema.d.ts.map +1 -1
  167. package/dist/frameworkConfigSchema.js +2 -1
  168. package/dist/hooks/index.d.ts +1 -0
  169. package/dist/hooks/index.d.ts.map +1 -1
  170. package/dist/hooks/index.js +1 -0
  171. package/dist/hooks/useInstance.d.ts +3 -0
  172. package/dist/hooks/useInstance.d.ts.map +1 -0
  173. package/dist/hooks/useInstance.js +4 -0
  174. package/dist/hydrate/hydrate.d.ts +6 -4
  175. package/dist/hydrate/hydrate.d.ts.map +1 -1
  176. package/dist/hydrate/hydrate.js +51 -13
  177. package/dist/hydrate/reconcileHydratedAttributes.d.ts.map +1 -1
  178. package/dist/hydrate/reconcileHydratedAttributes.js +4 -3
  179. package/dist/hydrate/renderHydrationMismatchBanner.d.ts +7 -0
  180. package/dist/hydrate/renderHydrationMismatchBanner.d.ts.map +1 -0
  181. package/dist/hydrate/renderHydrationMismatchBanner.js +69 -0
  182. package/dist/indexInner.d.ts +13 -5
  183. package/dist/indexInner.d.ts.map +1 -1
  184. package/dist/indexInner.js +9 -2
  185. package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -1
  186. package/dist/makeInstanceConfigFromFrameworkConfig.js +2 -1
  187. package/dist/pop.d.ts +10 -0
  188. package/dist/pop.d.ts.map +1 -0
  189. package/dist/pop.js +49 -0
  190. package/dist/postcssPlugins/TransformCssNames.d.ts.map +1 -1
  191. package/dist/postcssPlugins/TransformCssNames.js +10 -2
  192. package/dist/propsAreEqual.d.ts +8 -0
  193. package/dist/propsAreEqual.d.ts.map +1 -0
  194. package/dist/propsAreEqual.js +97 -0
  195. package/dist/rawHtml/filterContentNode.d.ts +20 -0
  196. package/dist/rawHtml/filterContentNode.d.ts.map +1 -0
  197. package/dist/rawHtml/filterContentNode.js +96 -0
  198. package/dist/rawHtml/parseHtml.d.ts +14 -0
  199. package/dist/rawHtml/parseHtml.d.ts.map +1 -1
  200. package/dist/rawHtml/parseHtml.js +4 -4
  201. package/dist/rawHtml/sanitizeHtml.d.ts +17 -0
  202. package/dist/rawHtml/sanitizeHtml.d.ts.map +1 -0
  203. package/dist/rawHtml/sanitizeHtml.js +19 -0
  204. package/dist/render/HeadData.d.ts +2 -0
  205. package/dist/render/HeadData.d.ts.map +1 -1
  206. package/dist/render/contentNodeToHtml.d.ts +18 -0
  207. package/dist/render/contentNodeToHtml.d.ts.map +1 -0
  208. package/dist/render/contentNodeToHtml.js +66 -0
  209. package/dist/render/contentToHtml.d.ts.map +1 -1
  210. package/dist/render/contentToHtml.js +3 -1
  211. package/dist/render/instantiateClassComponent.d.ts.map +1 -1
  212. package/dist/render/instantiateClassComponent.js +4 -0
  213. package/dist/render/processHead.d.ts.map +1 -1
  214. package/dist/render/processHead.js +22 -3
  215. package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
  216. package/dist/render/renderingTreeToHtml.js +8 -1
  217. package/dist/routing/ErrorRouteType.d.ts +6 -0
  218. package/dist/routing/ErrorRouteType.d.ts.map +1 -0
  219. package/dist/routing/ErrorRouteType.js +1 -0
  220. package/dist/routing/RouteTypes.d.ts +2 -1
  221. package/dist/routing/RouteTypes.d.ts.map +1 -1
  222. package/dist/routing/Routes.d.ts +5 -0
  223. package/dist/routing/Routes.d.ts.map +1 -1
  224. package/dist/routing/TungstenErrorInfo.d.ts +6 -0
  225. package/dist/routing/TungstenErrorInfo.d.ts.map +1 -0
  226. package/dist/routing/TungstenErrorInfo.js +6 -0
  227. package/dist/settings.d.ts +2 -0
  228. package/dist/settings.d.ts.map +1 -1
  229. package/dist/settings.js +3 -0
  230. package/dist/stateTracking.d.ts +47 -0
  231. package/dist/stateTracking.d.ts.map +1 -0
  232. package/dist/stateTracking.js +83 -0
  233. package/dist/staticGen/staticGen.d.ts.map +1 -1
  234. package/dist/staticGen/staticGen.js +117 -107
  235. package/dist/style/styleContentSxy.js +21 -0
  236. package/dist/testing/hydrateTestApp.d.ts +38 -0
  237. package/dist/testing/hydrateTestApp.d.ts.map +1 -0
  238. package/dist/testing/hydrateTestApp.js +242 -0
  239. package/dist/testing/index.d.ts +4 -3
  240. package/dist/testing/index.d.ts.map +1 -1
  241. package/dist/testing/index.js +16 -2
  242. package/dist/testing/installTestStyleProcessors.d.ts +2 -0
  243. package/dist/testing/installTestStyleProcessors.d.ts.map +1 -0
  244. package/dist/testing/installTestStyleProcessors.js +21 -0
  245. package/dist/testing/temp/componentPackageMock.d.ts +18 -0
  246. package/dist/testing/temp/componentPackageMock.d.ts.map +1 -0
  247. package/dist/testing/temp/componentPackageMock.js +37 -0
  248. package/dist/testing/temp/contentHtmlElements.d.ts +3 -0
  249. package/dist/testing/temp/contentHtmlElements.d.ts.map +1 -0
  250. package/dist/testing/temp/contentHtmlElements.js +12 -0
  251. package/dist/timeProfiler.d.ts +6 -0
  252. package/dist/timeProfiler.d.ts.map +1 -0
  253. package/dist/timeProfiler.js +31 -0
  254. package/dist/update/integrateUpdateVdom.d.ts +11 -0
  255. package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
  256. package/dist/update/integrateUpdateVdom.js +169 -54
  257. package/dist/update/pendingMounts.d.ts +25 -0
  258. package/dist/update/pendingMounts.d.ts.map +1 -0
  259. package/dist/update/pendingMounts.js +55 -0
  260. package/dist/warnOnFrameworkChange.d.ts.map +1 -1
  261. package/dist/warnOnFrameworkChange.js +8 -8
  262. package/package.json +21 -17
  263. package/dist/FunctionComponentStandIn.sxyt.d.ts +0 -2
  264. package/dist/FunctionComponentStandIn.sxyt.d.ts.map +0 -1
  265. package/dist/FunctionComponentStandIn.sxyt.js +0 -52
  266. package/dist/Instance/gotoRedirect.sxyt.d.ts +0 -2
  267. package/dist/Instance/gotoRedirect.sxyt.d.ts.map +0 -1
  268. package/dist/Instance/gotoRedirect.sxyt.js +0 -148
  269. package/dist/Instance/runTrackedWork.sxyt.d.ts +0 -2
  270. package/dist/Instance/runTrackedWork.sxyt.d.ts.map +0 -1
  271. package/dist/Instance/runTrackedWork.sxyt.js +0 -35
  272. package/dist/Servers/devErrorPageAutoRetry.sxyt.d.ts +0 -2
  273. package/dist/Servers/devErrorPageAutoRetry.sxyt.d.ts.map +0 -1
  274. package/dist/Servers/devErrorPageAutoRetry.sxyt.js +0 -117
  275. package/dist/_client/cjsHelpers.sxyt.d.ts +0 -2
  276. package/dist/_client/cjsHelpers.sxyt.d.ts.map +0 -1
  277. package/dist/_client/cjsHelpers.sxyt.js +0 -45
  278. package/dist/auth/passwordHashing.sxyt.d.ts +0 -2
  279. package/dist/auth/passwordHashing.sxyt.d.ts.map +0 -1
  280. package/dist/auth/passwordHashing.sxyt.js +0 -46
  281. package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts +0 -2
  282. package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts.map +0 -1
  283. package/dist/auth/ref/checkPasswordResetToken.sxyt.js +0 -40
  284. package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts +0 -2
  285. package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts.map +0 -1
  286. package/dist/auth/ref/createPasswordResetToken.sxyt.js +0 -10
  287. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.d.ts +0 -2
  288. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.d.ts.map +0 -1
  289. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.js +0 -138
  290. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts +0 -2
  291. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts.map +0 -1
  292. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.js +0 -108
  293. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts +0 -2
  294. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts.map +0 -1
  295. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.js +0 -104
  296. package/dist/bin/commands/compile.sxyt.d.ts +0 -2
  297. package/dist/bin/commands/compile.sxyt.d.ts.map +0 -1
  298. package/dist/bin/commands/compile.sxyt.js +0 -255
  299. package/dist/build/modifySassImports.sxyt.d.ts +0 -2
  300. package/dist/build/modifySassImports.sxyt.d.ts.map +0 -1
  301. package/dist/build/modifySassImports.sxyt.js +0 -55
  302. package/dist/build/sassImportParser.sxyt.d.ts +0 -2
  303. package/dist/build/sassImportParser.sxyt.d.ts.map +0 -1
  304. package/dist/build/sassImportParser.sxyt.js +0 -110
  305. package/dist/build/scssImportParserChatgpt.sxyt.d.ts +0 -2
  306. package/dist/build/scssImportParserChatgpt.sxyt.d.ts.map +0 -1
  307. package/dist/build/scssImportParserChatgpt.sxyt.js +0 -120
  308. package/dist/clone.sxyt.d.ts +0 -2
  309. package/dist/clone.sxyt.d.ts.map +0 -1
  310. package/dist/clone.sxyt.js +0 -24
  311. package/dist/componentProxyHandlers.sxyt.d.ts +0 -2
  312. package/dist/componentProxyHandlers.sxyt.d.ts.map +0 -1
  313. package/dist/componentProxyHandlers.sxyt.js +0 -130
  314. package/dist/components/RawHtml.sxyt.d.ts +0 -2
  315. package/dist/components/RawHtml.sxyt.d.ts.map +0 -1
  316. package/dist/components/RawHtml.sxyt.js +0 -104
  317. package/dist/components/bindable/BindableSelect.sxyt.d.ts +0 -2
  318. package/dist/components/bindable/BindableSelect.sxyt.d.ts.map +0 -1
  319. package/dist/components/bindable/BindableSelect.sxyt.js +0 -186
  320. package/dist/env/injectEnv.sxyt.d.ts +0 -2
  321. package/dist/env/injectEnv.sxyt.d.ts.map +0 -1
  322. package/dist/env/injectEnv.sxyt.js +0 -20
  323. package/dist/env/parseEnv.d.ts +0 -2
  324. package/dist/env/parseEnv.d.ts.map +0 -1
  325. package/dist/env/parseEnv.js +0 -14
  326. package/dist/env/parseEnv.sxyt.d.ts +0 -2
  327. package/dist/env/parseEnv.sxyt.d.ts.map +0 -1
  328. package/dist/env/parseEnv.sxyt.js +0 -11
  329. package/dist/findProjectDir.sxyt.d.ts +0 -2
  330. package/dist/findProjectDir.sxyt.d.ts.map +0 -1
  331. package/dist/findProjectDir.sxyt.js +0 -82
  332. package/dist/hmr/applyHmrModule.sxyt.d.ts +0 -2
  333. package/dist/hmr/applyHmrModule.sxyt.d.ts.map +0 -1
  334. package/dist/hmr/applyHmrModule.sxyt.js +0 -182
  335. package/dist/hmr/instanceRegistry.sxyt.d.ts +0 -2
  336. package/dist/hmr/instanceRegistry.sxyt.d.ts.map +0 -1
  337. package/dist/hmr/instanceRegistry.sxyt.js +0 -24
  338. package/dist/hmr/refreshStylesheets.sxyt.d.ts +0 -2
  339. package/dist/hmr/refreshStylesheets.sxyt.d.ts.map +0 -1
  340. package/dist/hmr/refreshStylesheets.sxyt.js +0 -46
  341. package/dist/hydrate/hydrate.sxyt.d.ts +0 -2
  342. package/dist/hydrate/hydrate.sxyt.d.ts.map +0 -1
  343. package/dist/hydrate/hydrate.sxyt.js +0 -302
  344. package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts +0 -2
  345. package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts.map +0 -1
  346. package/dist/hydrate/reconcileHydratedAttributes.sxyt.js +0 -190
  347. package/dist/importDevModuleWithRetry.sxyt.d.ts +0 -2
  348. package/dist/importDevModuleWithRetry.sxyt.d.ts.map +0 -1
  349. package/dist/importDevModuleWithRetry.sxyt.js +0 -104
  350. package/dist/innerHtmlFromProps.sxyt.d.ts +0 -2
  351. package/dist/innerHtmlFromProps.sxyt.d.ts.map +0 -1
  352. package/dist/innerHtmlFromProps.sxyt.js +0 -99
  353. package/dist/postcssPlugins/parseSelectors.sxyt.d.ts +0 -2
  354. package/dist/postcssPlugins/parseSelectors.sxyt.d.ts.map +0 -1
  355. package/dist/postcssPlugins/parseSelectors.sxyt.js +0 -62
  356. package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts +0 -2
  357. package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts.map +0 -1
  358. package/dist/postcssPlugins/parseSelectorsRich.sxyt.js +0 -155
  359. package/dist/rawHtml/parseHtml.sxyt.d.ts +0 -2
  360. package/dist/rawHtml/parseHtml.sxyt.d.ts.map +0 -1
  361. package/dist/rawHtml/parseHtml.sxyt.js +0 -239
  362. package/dist/render/getFunctionBodyAsString.sxyt.d.ts +0 -2
  363. package/dist/render/getFunctionBodyAsString.sxyt.d.ts.map +0 -1
  364. package/dist/render/getFunctionBodyAsString.sxyt.js +0 -37
  365. package/dist/render/processHead.sxyt.d.ts +0 -2
  366. package/dist/render/processHead.sxyt.d.ts.map +0 -1
  367. package/dist/render/processHead.sxyt.js +0 -93
  368. package/dist/render/processProps.sxyt.d.ts +0 -2
  369. package/dist/render/processProps.sxyt.d.ts.map +0 -1
  370. package/dist/render/processProps.sxyt.js +0 -90
  371. package/dist/routing/compareRequestToRegex.sxyt.d.ts +0 -2
  372. package/dist/routing/compareRequestToRegex.sxyt.d.ts.map +0 -1
  373. package/dist/routing/compareRequestToRegex.sxyt.js +0 -65
  374. package/dist/routing/getPathPriority.sxyt.d.ts +0 -2
  375. package/dist/routing/getPathPriority.sxyt.d.ts.map +0 -1
  376. package/dist/routing/getPathPriority.sxyt.js +0 -24
  377. package/dist/routing/matchPath.sxyt.d.ts +0 -2
  378. package/dist/routing/matchPath.sxyt.d.ts.map +0 -1
  379. package/dist/routing/matchPath.sxyt.js +0 -41
  380. package/dist/routing/patternToRegex.sxyt.d.ts +0 -2
  381. package/dist/routing/patternToRegex.sxyt.d.ts.map +0 -1
  382. package/dist/routing/patternToRegex.sxyt.js +0 -69
  383. package/dist/routing/splitRequest.sxyt.d.ts +0 -2
  384. package/dist/routing/splitRequest.sxyt.d.ts.map +0 -1
  385. package/dist/routing/splitRequest.sxyt.js +0 -47
  386. package/dist/style/jssToCss.sxyt.d.ts +0 -2
  387. package/dist/style/jssToCss.sxyt.d.ts.map +0 -1
  388. package/dist/style/jssToCss.sxyt.js +0 -17
  389. package/dist/testing/createTestApp.sxyt.d.ts +0 -2
  390. package/dist/testing/createTestApp.sxyt.d.ts.map +0 -1
  391. package/dist/testing/createTestApp.sxyt.js +0 -470
  392. package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts +0 -2
  393. package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts.map +0 -1
  394. package/dist/testing/ensureTestEnvLoaded.sxyt.js +0 -20
  395. package/dist/update/hotSwap.sxyt.d.ts +0 -2
  396. package/dist/update/hotSwap.sxyt.d.ts.map +0 -1
  397. package/dist/update/hotSwap.sxyt.js +0 -252
@@ -0,0 +1,83 @@
1
+ /**
2
+ * A monotonic clock for state writes, so a component can ask "has anything inside this
3
+ * object changed since I last rendered?".
4
+ *
5
+ * Needed because deep state is mutated in place: when a child's prop is the same array
6
+ * the parent already had, comparing before against after tells you nothing -- both sides
7
+ * are the one mutated object. Each proxy stamps the object it mutated with the current
8
+ * tick, and the props comparison walks down looking for a stamp newer than the child's
9
+ * last render.
10
+ *
11
+ * The stamp is stored under $changed on the object itself rather than in a side table
12
+ * keyed by identity, so it can be read straight back through the proxy -- the raw target
13
+ * is not always the object a caller holds, since adoption copies state shallowly.
14
+ * Symbols are invisible to Object.keys and JSON, so the stamp does not leak into user data.
15
+ *
16
+ * Stamps are deliberately not propagated to ancestors: a write would then have to touch
17
+ * every object above it. The cost is moved to update time, where the walk can stop at the
18
+ * first changed node it finds.
19
+ *
20
+ * No imports here on purpose -- the proxy handlers depend on this, so it must stay a leaf.
21
+ */
22
+ export const $changed = Symbol('changed');
23
+ /**
24
+ * Set `__TW_TRACE = true` in a console (or before load) to log the props-skip decisions.
25
+ * Off by default and cheap when off -- one global read per event.
26
+ */
27
+ let tracingCached = null;
28
+ /**
29
+ * Re-reads the global. Called once per update rather than per node: the global lookup is
30
+ * cheap in isolation but showed up as 12% of a 50k-row update when it ran for every dom
31
+ * node, which is the instrumentation distorting what it measures. Toggling __TW_TRACE from
32
+ * a console therefore takes effect on the next update rather than immediately.
33
+ */
34
+ export function refreshTracing() {
35
+ tracingCached = Reflect.get(globalThis, '__TW_TRACE') === true;
36
+ return tracingCached;
37
+ }
38
+ export function tracing() {
39
+ return tracingCached ?? refreshTracing();
40
+ }
41
+ let lastTraceAt = null;
42
+ /**
43
+ * Each line carries the time since page load and the time since the previous traced event,
44
+ * so a stall shows up as a large `+delta` on the line that follows it -- no need to diff
45
+ * timestamps by hand. The delta is reset whenever tracing is switched back on.
46
+ */
47
+ export function trace(...args) {
48
+ if (!tracing()) {
49
+ lastTraceAt = null;
50
+ return;
51
+ }
52
+ const now = performance.now();
53
+ const delta = lastTraceAt === null ? 0 : now - lastTraceAt;
54
+ lastTraceAt = now;
55
+ console.log(`[tungsten ${now.toFixed(1)}ms +${delta.toFixed(1)}]`, ...args);
56
+ }
57
+ let clock = 0;
58
+ const lastRender = new WeakMap();
59
+ /** current tick; read when recording a render */
60
+ export function stateClock() {
61
+ return clock;
62
+ }
63
+ /** called by the state proxies whenever the given object is mutated */
64
+ export function markChanged(target) {
65
+ Reflect.set(target, $changed, ++clock);
66
+ // commented out: args are built on every state write even when tracing is off
67
+ //trace('changed', Array.isArray(target) ? `array(len ${target.length})` : 'object', '-> tick', clock)
68
+ }
69
+ /** tick at which this object was last mutated; 0 means never */
70
+ export function changedAt(value) {
71
+ const stamp = Reflect.get(value, $changed);
72
+ return typeof stamp === 'number' ? stamp : 0;
73
+ }
74
+ /** record that a component has rendered with the state as it currently stands */
75
+ export function markRendered(element) {
76
+ lastRender.set(element, clock);
77
+ // commented out: args are built on every render even when tracing is off
78
+ //trace('rendered', element.constructor.name, 'baseline tick', clock)
79
+ }
80
+ /** tick at which this component last rendered, or undefined if it never has */
81
+ export function renderedAt(element) {
82
+ return lastRender.get(element);
83
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"staticGen.d.ts","sourceRoot":"","sources":["../../src/staticGen/staticGen.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAiBhD,wBAAsB,SAAS,CAAC,SAAS,EAAE,SAAS,iBA2LnD"}
1
+ {"version":3,"file":"staticGen.d.ts","sourceRoot":"","sources":["../../src/staticGen/staticGen.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAiBhD,wBAAsB,SAAS,CAAC,SAAS,EAAE,SAAS,iBA6MnD"}
@@ -2,7 +2,7 @@ import { existsSync, promises as fsPromises } from 'fs';
2
2
  import { join, dirname } from 'path';
3
3
  import fsExtra from 'fs-extra';
4
4
  //import type { SxyFrameworkConfigComplete } from '../FrameworkConfig.js'
5
- import { staticSiteFolder, staticFolder, assetsFolder, publicFolder, bundleFolder, componentCssFolder } from "../settings.js";
5
+ import { staticSiteFolder, staticFolder, assetsFolder, publicFolder, bundleFolder, componentCssFolder, frameworkCssFolder } from "../settings.js";
6
6
  import { getAppRoutes } from "./getAppRoutes.js";
7
7
  import { cliError, cliWarn } from "../cliOutput.js";
8
8
  import { matchPath } from "../routing/matchPath.js";
@@ -36,119 +36,129 @@ export async function staticGen(framework) {
36
36
  const buildLocation = framework.compilationInfo.location;
37
37
  const server = await framework.createProdServer();
38
38
  const serverLocation = await server.start(null, true); // port, mute
39
- // ensure the target folder exists
40
- await fsPromises.mkdir(join(projectDir, staticSiteFolder), {
41
- recursive: true
42
- });
43
- const rewriteMap = {};
44
- // if ( ! Array.isArray(appRoutes) ) {
45
- // appRoutes = Object.entries(appRoutes).map( ([path, route]) => {
46
- // route.path = path as keyof typeof appRoutes
47
- // return route
48
- // } )
49
- // }
50
- // for default and 404 routes we need to identify which one is in use, and then make sure the app renders it
51
- // appRoutes = appRoutes.map( route => {
52
- // if (route.path === 'default') {
53
- // route.path === '/__default'
54
- // cliWarn(`Static site gen turning default route into __default.html. It is possible that this could conflict with a real route.`)
55
- // } else if (route.path === '404') {
56
- // route.path === '/404'
57
- // cliWarn(`Static site gen turning 404 route into __404.html. It is possible that this could conflict with a real route.`)
58
- // }
59
- // return route
60
- // })
61
- const dynamicRoutes = [];
62
- const finalRoutes = objectFilter(appRoutes, (path, route) => {
63
- if (!path.startsWith('/')) {
64
- //cliWarn(`Static gen skipping route ${route.path}, because it does not start with /, and is not default or 404`)
65
- cliWarn(`Static gen skipping route ${path}, because it does not start with /`);
66
- return false;
39
+ // the server is only here to render the pages from - leaving it up holds the event loop
40
+ // open, which is what forced the caller to hard-exit (and abort mid-teardown) instead
41
+ try {
42
+ // ensure the target folder exists
43
+ await fsPromises.mkdir(join(projectDir, staticSiteFolder), {
44
+ recursive: true
45
+ });
46
+ const rewriteMap = {};
47
+ // if ( ! Array.isArray(appRoutes) ) {
48
+ // appRoutes = Object.entries(appRoutes).map( ([path, route]) => {
49
+ // route.path = path as keyof typeof appRoutes
50
+ // return route
51
+ // } )
52
+ // }
53
+ // for default and 404 routes we need to identify which one is in use, and then make sure the app renders it
54
+ // appRoutes = appRoutes.map( route => {
55
+ // if (route.path === 'default') {
56
+ // route.path === '/__default'
57
+ // cliWarn(`Static site gen turning default route into __default.html. It is possible that this could conflict with a real route.`)
58
+ // } else if (route.path === '404') {
59
+ // route.path === '/404'
60
+ // cliWarn(`Static site gen turning 404 route into __404.html. It is possible that this could conflict with a real route.`)
61
+ // }
62
+ // return route
63
+ // })
64
+ const dynamicRoutes = [];
65
+ const finalRoutes = objectFilter(appRoutes, (path, route) => {
66
+ if (!path.startsWith('/')) {
67
+ //cliWarn(`Static gen skipping route ${route.path}, because it does not start with /, and is not default or 404`)
68
+ cliWarn(`Static gen skipping route ${path}, because it does not start with /`);
69
+ return false;
70
+ }
71
+ if (path.includes(':')) {
72
+ // separate these out
73
+ dynamicRoutes.push([path, route]);
74
+ return false;
75
+ }
76
+ return true;
77
+ });
78
+ if (count(finalRoutes) === 0) {
79
+ cliWarn('Found no valid route!');
67
80
  }
68
- if (path.includes(':')) {
69
- // separate these out
70
- dynamicRoutes.push([path, route]);
71
- return false;
81
+ for (const [path, route] of Object.entries(finalRoutes)) {
82
+ // we need to develop the rewrite map over time, because we discover links during processing
83
+ rewriteMap[path] = pathToLink(path, siteBasePath);
72
84
  }
73
- return true;
74
- });
75
- if (count(finalRoutes) === 0) {
76
- cliWarn('Found no valid route!');
77
- }
78
- for (const [path, route] of Object.entries(finalRoutes)) {
79
- // we need to develop the rewrite map over time, because we discover links during processing
80
- rewriteMap[path] = pathToLink(path, siteBasePath);
81
- }
82
- //console.log('rewriteMap', rewriteMap)
83
- async function renderPath(path, siteBasePath) {
84
- const url = serverLocation + path;
85
- let links;
86
- try {
87
- console.log('get URL', url);
88
- const response = await fetch(url);
89
- // fetch, unlike axios, resolves on non-2xx - so check explicitly, or we'd
90
- // write error pages out as static HTML
91
- if (!response.ok) throwError('renderPath', `Get request to ${url} returned an invalid status: ${response.status}`);
92
- let result = await response.text();
93
- links = findLinks(result);
94
- const newPaths = [];
95
- for (const link of links) {
96
- if (!StringIsPath(link)) throwError('renderRoute', `Found a link '${link}' that did not start with /`);
97
- if (!(link in rewriteMap)) {
98
- for (const [path, dynamicRoute] of dynamicRoutes) {
99
- if (RouteKeyIsPath(path)) {
100
- if (matchPath(path, link)) {
101
- //console.log('link', link)
102
- //console.log('in?', link in rewriteMap)
103
- //console.log(`link ${link} matched dynamic route ${dynamicRoute.path}`)
104
- newPaths.push(link);
105
- rewriteMap[link] = pathToLink(link, siteBasePath);
85
+ //console.log('rewriteMap', rewriteMap)
86
+ const renderPath = async (path, siteBasePath) => {
87
+ const url = serverLocation + path;
88
+ let links;
89
+ try {
90
+ console.log('get URL', url);
91
+ const response = await fetch(url);
92
+ // fetch, unlike axios, resolves on non-2xx - so check explicitly, or we'd
93
+ // write error pages out as static HTML
94
+ if (!response.ok) throwError('renderPath', `Get request to ${url} returned an invalid status: ${response.status}`);
95
+ let result = await response.text();
96
+ links = findLinks(result);
97
+ const newPaths = [];
98
+ for (const link of links) {
99
+ if (link.startsWith('#')) continue; // ignore anchors/hash links
100
+ if (!StringIsPath(link)) {
101
+ throwError('renderRoute', `Found a link '${link}' that did not start with /`);
102
+ }
103
+ if (!(link in rewriteMap)) {
104
+ for (const [path, dynamicRoute] of dynamicRoutes) {
105
+ if (RouteKeyIsPath(path)) {
106
+ if (matchPath(path, link)) {
107
+ //console.log('link', link)
108
+ //console.log('in?', link in rewriteMap)
109
+ //console.log(`link ${link} matched dynamic route ${dynamicRoute.path}`)
110
+ newPaths.push(link);
111
+ rewriteMap[link] = pathToLink(link, siteBasePath);
112
+ }
113
+ } else {
114
+ // default
115
+ // 404
106
116
  }
107
- } else {
108
- // default
109
- // 404
110
117
  }
111
118
  }
112
119
  }
120
+ result = rewriteLinks(result, rewriteMap);
121
+ //const pageFileName = rewriteMap[path]
122
+ const pageFileName = pathToFileName(path);
123
+ const dest = join(projectDir, staticSiteFolder, pageFileName);
124
+ const dir = dirname(dest);
125
+ // ensure the target folder exists
126
+ // some duplication of effort here - oh well
127
+ await fsPromises.mkdir(dir, {
128
+ recursive: true
129
+ });
130
+ await fsPromises.writeFile(join(projectDir, staticSiteFolder, pageFileName), result);
131
+ // we can update the rewrite map here
132
+ // for (const route of appRoutes) { // we need to develop the rewrite map over time, because we discover links during processing
133
+ // const path = route.path
134
+ // rewriteMap[path] = pathToFileName(path)
135
+ // }
136
+ // awaited - otherwise staticGen() can return before these pages are written
137
+ for (const link of newPaths) {
138
+ await renderPath(link, siteBasePath);
139
+ }
140
+ } catch (e) {
141
+ const stack = typeof e === 'object' && e !== null && 'stack' in e ? e.stack : '';
142
+ cliError(`Static site gen - error generating path ${path} (full location ${url}): ${String(e)} ${String(stack)}`);
113
143
  }
114
- result = rewriteLinks(result, rewriteMap);
115
- //const pageFileName = rewriteMap[path]
116
- const pageFileName = pathToFileName(path);
117
- const dest = join(projectDir, staticSiteFolder, pageFileName);
118
- const dir = dirname(dest);
119
- // ensure the target folder exists
120
- // some duplication of effort here - oh well
121
- await fsPromises.mkdir(dir, {
122
- recursive: true
123
- });
124
- await fsPromises.writeFile(join(projectDir, staticSiteFolder, pageFileName), result);
125
- // we can update the rewrite map here
126
- // for (const route of appRoutes) { // we need to develop the rewrite map over time, because we discover links during processing
127
- // const path = route.path
128
- // rewriteMap[path] = pathToFileName(path)
129
- // }
130
- for (const link of newPaths) {
131
- renderPath(link, siteBasePath);
132
- }
133
- } catch (e) {
134
- const stack = typeof e === 'object' && e !== null && 'stack' in e ? e.stack : '';
135
- cliError(`Static site gen - error generating path ${path} (full location ${url}): ${String(e)} ${String(stack)}`);
144
+ };
145
+ for (const [path, route] of Object.entries(finalRoutes)) {
146
+ await renderPath(path, siteBasePath);
136
147
  }
148
+ console.log('rewriteMap', rewriteMap);
149
+ const copyPromises = [fsExtra.copy(join(buildLocation, staticFolder), join(projectDir, staticSiteFolder)),
150
+ // assets folder
151
+ existsSync(join(buildLocation, assetsFolder)) ? fsExtra.copy(join(buildLocation, assetsFolder), join(projectDir, staticSiteFolder, 'assets')) : null,
152
+ // public files
153
+ existsSync(join(buildLocation, publicFolder)) ? fsExtra.copy(join(buildLocation, publicFolder), join(projectDir, staticSiteFolder)) : null,
154
+ // copy in the bundle
155
+ fsExtra.copy(join(projectDir, bundleFolder), join(projectDir, staticSiteFolder, 'bundle')),
156
+ // copy the client.js to clientWithEnv.js, because the framework looks for this file instead.
157
+ //fsExtra.copy(join(projectDir, bundleFolder, 'client.js'), join(projectDir, bundleFolder, 'clientWithEnv.js')),
158
+ // copy in the css
159
+ fsExtra.copy(join(buildLocation, componentCssFolder), join(projectDir, staticSiteFolder, componentCssFolder)), ...(existsSync(join(buildLocation, frameworkCssFolder)) ? [fsExtra.copy(join(buildLocation, frameworkCssFolder), join(projectDir, staticSiteFolder, frameworkCssFolder))] : [])];
160
+ await Promise.all(copyPromises);
161
+ } finally {
162
+ await server.stop();
137
163
  }
138
- for (const [path, route] of Object.entries(finalRoutes)) {
139
- await renderPath(path, siteBasePath);
140
- }
141
- console.log('rewriteMap', rewriteMap);
142
- const copyPromises = [fsExtra.copy(join(buildLocation, staticFolder), join(projectDir, staticSiteFolder)),
143
- // assets folder
144
- existsSync(join(buildLocation, assetsFolder)) ? fsExtra.copy(join(buildLocation, assetsFolder), join(projectDir, staticSiteFolder, 'assets')) : null,
145
- // public files
146
- existsSync(join(buildLocation, publicFolder)) ? fsExtra.copy(join(buildLocation, publicFolder), join(projectDir, staticSiteFolder)) : null,
147
- // copy in the bundle
148
- fsExtra.copy(join(projectDir, bundleFolder), join(projectDir, staticSiteFolder, 'bundle')),
149
- // copy the client.js to clientWithEnv.js, because the framework looks for this file instead.
150
- //fsExtra.copy(join(projectDir, bundleFolder, 'client.js'), join(projectDir, bundleFolder, 'clientWithEnv.js')),
151
- // copy in the css
152
- fsExtra.copy(join(buildLocation, componentCssFolder), join(projectDir, staticSiteFolder, componentCssFolder))];
153
- await Promise.all(copyPromises);
154
164
  }
@@ -121,6 +121,27 @@ function processItem(element, styles, usage) {
121
121
  }
122
122
  newClassName = newClassName.trim();
123
123
  if (newClassName !== '') element[$props].className = newClassName;
124
+ // Any other *ClassName prop (e.g. messageClassName, handed to a child component to apply
125
+ // to one of its own elements) gets the same local-stylesheet lookup applied in place, so a
126
+ // classname threaded down through props can still be scoped against this component's own
127
+ // stylesheet, even though the child's own render tree is outside this walk - see
128
+ // styleContentSxy() above.
129
+ for (const key in element[$props]) {
130
+ if (key === 'className' || !key.endsWith('ClassName')) continue;
131
+ const value = element[$props][key];
132
+ if (value === undefined || value === null) continue;
133
+ if (typeof value !== 'string') {
134
+ throw new TungstenError(`styleContentSxy() error: ${ContentNodeElementIsHtml(element) ? element[$type] : getComponentName(element)}` + ` ${key} prop should be a string. Received ${typeof value}`);
135
+ }
136
+ let newValue = value;
137
+ for (const cn of value.split(' ')) {
138
+ if (cn in styles.classes) {
139
+ newValue += ` ${styles.classes[cn]}`;
140
+ usage?.usedClasses.add(cn);
141
+ }
142
+ }
143
+ if (newValue !== value) element[$props][key] = newValue;
144
+ }
124
145
  debug('element after mods', tagName, element);
125
146
  // apply this to both fragment and elements
126
147
  if (element[$props].children !== undefined) {
@@ -0,0 +1,38 @@
1
+ import type { ConstructPackage, TungstenBaseComponent, TungstenComponentPropsBase } from '../Components.jsx';
2
+ import type { TaggedAttributeMismatch } from '../hydrate/renderHydrationMismatchBanner.js';
3
+ import type { TestAppOptions } from './index.js';
4
+ export type HydrateTestAppOptions<Props extends object> = TestAppOptions<Props> & {
5
+ serverProps?: Props;
6
+ csr?: boolean;
7
+ };
8
+ type HydrateTestAppArgs<Props extends object> = object extends Props ? [options?: HydrateTestAppOptions<Props>] : keyof Props extends never ? [options?: HydrateTestAppOptions<Props>] : [options: HydrateTestAppOptions<Props> & {
9
+ props: Props;
10
+ }];
11
+ export type HydrateTestApp<Component extends TungstenBaseComponent> = {
12
+ readonly document: Document;
13
+ readonly container: HTMLElement;
14
+ readonly component: Component;
15
+ readonly html: string;
16
+ readonly mismatches: readonly TaggedAttributeMismatch[];
17
+ resolved(): Promise<void>;
18
+ setProps(props: Component['props']): Promise<void>;
19
+ unmount(): Promise<void>;
20
+ };
21
+ /**
22
+ * The hydration round trip createTestApp() deliberately doesn't cover: render a component to
23
+ * HTML the way a real server would, parse it with a real HTML parser, hydrate a fresh client
24
+ * instance against the result, and hand back the live, hydrated component - still fully usable
25
+ * via setProps()/resolved(), exactly like createTestApp()'s result.
26
+ *
27
+ * By default `props` renders on both sides, so a passing test proves an ordinary page hydrates
28
+ * clean (`mismatches` empty). Pass `serverProps` to diverge the two passes on purpose and assert
29
+ * on the resulting `mismatches` - the case a one-off "does the reconciler still agree with real
30
+ * served pages" script never could, because nothing fed it markup that didn't already match.
31
+ *
32
+ * A structural mismatch (a different tag, a different number of children) is not something
33
+ * reconcileHydratedAttributes() can fix - hydrateRootComponent() throws, exactly as the real
34
+ * client hydrator does, so a caller reproducing that class of bug should assert on the rejection.
35
+ */
36
+ export declare function hydrateTestApp<Props extends TungstenComponentPropsBase, Component extends TungstenBaseComponent<any, any>, RouteData = undefined>(RootComponent: new (pkg: ConstructPackage<NoInfer<Props>, RouteData>) => Component, ...args: HydrateTestAppArgs<Props>): Promise<HydrateTestApp<Component>>;
37
+ export {};
38
+ //# sourceMappingURL=hydrateTestApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrateTestApp.d.ts","sourceRoot":"","sources":["../../src/testing/hydrateTestApp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC7B,MAAM,mBAAmB,CAAA;AAO1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAA;AAa1F,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,YAAY,CAAA;AAEnE,MAAM,MAAM,qBAAqB,CAAC,KAAK,SAAS,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG;IAM9E,WAAW,CAAC,EAAE,KAAK,CAAA;IAEnB,GAAG,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,KAAK,kBAAkB,CAAC,KAAK,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,GAC9D,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC,GACxC,MAAM,KAAK,SAAS,KAAK,GACrB,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC,GACxC,CAAC,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAA;AAEpE,MAAM,MAAM,cAAc,CAAC,SAAS,SAAS,qBAAqB,IAAI;IAClE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAG7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAIrB,QAAQ,CAAC,UAAU,EAAE,SAAS,uBAAuB,EAAE,CAAA;IAEvD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B,CAAA;AAkGD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAChC,KAAK,SAAS,0BAA0B,EACxC,SAAS,SAAS,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EACjD,SAAS,GAAG,SAAS,EAErB,aAAa,EAAE,KAAK,GAAG,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,SAAS,EAClF,GAAG,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,GACnC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CA6HpC"}
@@ -0,0 +1,242 @@
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
+ 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; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ 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); }
6
+ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
7
+ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
8
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
9
+ import { $props, $type } from "../contentNodeSymbols.js";
10
+ import { Instance } from "../Instance/Instance.js";
11
+ import { hydrateRootComponent } from "../hydrate/hydrate.js";
12
+ import { contentTreeToRenderingTree } from "../render/contentTreeToRenderingTree.js";
13
+ import { renderingNodeToHtml } from "../render/renderingTreeToHtml.js";
14
+ import { initStores } from "../Servers/initStores.js";
15
+ import { deleteNodeIfRendered } from "../update/integrateUpdateVdom.js";
16
+ import { UpdateScheduler } from "../update/UpdateScheduler.js";
17
+ import { DomPointer } from "../DomPointer.js";
18
+ import { ensureTestEnvLoaded } from "./ensureTestEnvLoaded.js";
19
+ // hydrate.tsx references several DOM globals directly (Node.COMMENT_NODE, `instanceof Text`, the
20
+ // bare `document`) the way real browser code always can - happy-dom only puts these on its own
21
+ // Window, not on Node.js's global scope. Every hand-written hydration test before this harness
22
+ // bridged them manually; a caller of hydrateTestApp() shouldn't need to know that hydrate() was
23
+ // written assuming a real browser to begin with.
24
+ function bridgeHappyDomGlobals(document) {
25
+ const window = document.defaultView;
26
+ if (window === null) return;
27
+ const globals = globalThis; // eslint-disable-line no-type-assertion/no-type-assertion -- bridging happy-dom's globals onto the global scope
28
+ globals.Node = window.Node;
29
+ globals.Text = window.Text;
30
+ globals.Comment = window.Comment;
31
+ globals.Element = window.Element;
32
+ globals.HTMLElement = window.HTMLElement;
33
+ globals.Document = window.Document;
34
+ globals.document = document;
35
+ globals.window = window;
36
+ }
37
+ var _instance = /*#__PURE__*/new WeakMap();
38
+ var _scheduler = /*#__PURE__*/new WeakMap();
39
+ var _ownsContainer = /*#__PURE__*/new WeakMap();
40
+ var _unmounted = /*#__PURE__*/new WeakMap();
41
+ class HydrateTestAppImplementation {
42
+ constructor(document, container, component, instance, scheduler, ownsContainer, html, mismatches) {
43
+ _defineProperty(this, "document", void 0);
44
+ _defineProperty(this, "container", void 0);
45
+ _defineProperty(this, "component", void 0);
46
+ _defineProperty(this, "html", void 0);
47
+ _defineProperty(this, "mismatches", void 0);
48
+ _classPrivateFieldInitSpec(this, _instance, void 0);
49
+ _classPrivateFieldInitSpec(this, _scheduler, void 0);
50
+ _classPrivateFieldInitSpec(this, _ownsContainer, void 0);
51
+ _classPrivateFieldInitSpec(this, _unmounted, false);
52
+ _defineProperty(this, "resolved", async () => {
53
+ await _classPrivateFieldGet(_scheduler, this).resolved();
54
+ });
55
+ _defineProperty(this, "setProps", async props => {
56
+ if (_classPrivateFieldGet(_unmounted, this)) throw new Error('Cannot set props on an unmounted Tungsten HydrateTestApp.');
57
+ this.component.props = props;
58
+ _classPrivateFieldGet(_instance, this).queueUpdate(this.component);
59
+ await this.resolved();
60
+ });
61
+ _defineProperty(this, "unmount", async () => {
62
+ if (_classPrivateFieldGet(_unmounted, this)) return;
63
+ _classPrivateFieldSet(_unmounted, this, true);
64
+ _classPrivateFieldGet(_scheduler, this).cancelPending();
65
+ let cleanupError;
66
+ try {
67
+ this.component.__delete();
68
+ deleteNodeIfRendered(this.component.__currentContent);
69
+ this.component.__deleted();
70
+ _classPrivateFieldGet(_instance, this).disposeRegisteredComponents();
71
+ await _classPrivateFieldGet(_scheduler, this).resolved();
72
+ } catch (error) {
73
+ cleanupError = error;
74
+ try {
75
+ _classPrivateFieldGet(_instance, this).disposeRegisteredComponents();
76
+ } catch {
77
+ // Preserve the first cleanup failure.
78
+ }
79
+ } finally {
80
+ _classPrivateFieldGet(_scheduler, this).dispose();
81
+ if (_classPrivateFieldGet(_ownsContainer, this)) this.container.remove();else while (this.container.firstChild !== null) this.container.removeChild(this.container.firstChild);
82
+ }
83
+ if (cleanupError !== undefined) throw cleanupError;
84
+ });
85
+ this.document = document;
86
+ this.container = container;
87
+ this.component = component;
88
+ _classPrivateFieldSet(_instance, this, instance);
89
+ _classPrivateFieldSet(_scheduler, this, scheduler);
90
+ _classPrivateFieldSet(_ownsContainer, this, ownsContainer);
91
+ this.html = html;
92
+ this.mismatches = mismatches;
93
+ }
94
+ }
95
+ /**
96
+ * The hydration round trip createTestApp() deliberately doesn't cover: render a component to
97
+ * HTML the way a real server would, parse it with a real HTML parser, hydrate a fresh client
98
+ * instance against the result, and hand back the live, hydrated component - still fully usable
99
+ * via setProps()/resolved(), exactly like createTestApp()'s result.
100
+ *
101
+ * By default `props` renders on both sides, so a passing test proves an ordinary page hydrates
102
+ * clean (`mismatches` empty). Pass `serverProps` to diverge the two passes on purpose and assert
103
+ * on the resulting `mismatches` - the case a one-off "does the reconciler still agree with real
104
+ * served pages" script never could, because nothing fed it markup that didn't already match.
105
+ *
106
+ * A structural mismatch (a different tag, a different number of children) is not something
107
+ * reconcileHydratedAttributes() can fix - hydrateRootComponent() throws, exactly as the real
108
+ * client hydrator does, so a caller reproducing that class of bug should assert on the rejection.
109
+ */
110
+ export async function hydrateTestApp(RootComponent, ...args) {
111
+ await ensureTestEnvLoaded();
112
+ const options = args[0]; // eslint-disable-line no-type-assertion/no-type-assertion
113
+ const suppliedDocument = options?.document ?? globalThis.document; // eslint-disable-line no-type-assertion/no-type-assertion
114
+ if (suppliedDocument === undefined) {
115
+ // eslint-disable-line @typescript-eslint/no-unnecessary-condition
116
+ throw new Error('hydrateTestApp() requires options.document when no global document is available.');
117
+ }
118
+ const document = suppliedDocument;
119
+ const ownsContainer = options?.container === undefined;
120
+ const container = options?.container ?? document.createElement('div');
121
+ if (container.ownerDocument !== document) {
122
+ throw new Error('The HydrateTestApp container must belong to options.document.');
123
+ }
124
+ if (container.childNodes.length > 0) {
125
+ throw new Error('The HydrateTestApp container must be empty before hydrating.');
126
+ }
127
+ if (ownsContainer) {
128
+ if (document.body === null) {
129
+ // eslint-disable-line @typescript-eslint/no-unnecessary-condition
130
+ throw new Error('The supplied document must have a body element.');
131
+ }
132
+ document.body.appendChild(container);
133
+ }
134
+ const clientProps = options?.props ?? {}; // eslint-disable-line no-type-assertion/no-type-assertion
135
+ const serverProps = options?.serverProps ?? clientProps;
136
+ const location = options?.location ?? '/';
137
+ const globalData = options?.globalData ?? {}; // eslint-disable-line no-type-assertion/no-type-assertion
138
+ const matchedRouteInfo = {
139
+ key: null,
140
+ params: options?.routeParams ?? {},
141
+ content: null,
142
+ ...(options !== undefined && 'routeData' in options ? {
143
+ data: options.routeData
144
+ } : {})
145
+ };
146
+ const instanceConfig = {
147
+ prod: false,
148
+ useRootComponent: true,
149
+ clientSideNav: false,
150
+ siteBasePath: '/',
151
+ staticSite: false,
152
+ csr: options?.csr ?? false
153
+ };
154
+ const emptyRoutes = {}; // eslint-disable-line no-type-assertion/no-type-assertion -- not exercised by hydration tests
155
+ // eslint-disable-next-line no-type-assertion/no-type-assertion -- rootToHtml.ts builds a root content node the same way
156
+ const componentNode = {
157
+ [$type]: RootComponent,
158
+ [$props]: serverProps
159
+ };
160
+ // Server pass: a throwaway Instance whose only job is producing the HTML a real server would
161
+ // have sent for `serverProps`. Never returned, never touched again once `html` is captured.
162
+ const ssrScheduler = new UpdateScheduler();
163
+ let html;
164
+ try {
165
+ const {
166
+ internalStore,
167
+ stores,
168
+ storeSubscriptions
169
+ } = initStores(location, null, globalData, matchedRouteInfo);
170
+ const ssrInstance = new Instance(location, instanceConfig, null, emptyRoutes, emptyRoutes,
171
+ // eslint-disable-line no-type-assertion/no-type-assertion
172
+ internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo, {
173
+ document,
174
+ window: document.defaultView,
175
+ scheduler: ssrScheduler,
176
+ navigation: false
177
+ });
178
+ for (const override of options?.stores ?? []) {
179
+ const store = override.registration.getStore(ssrInstance.stores);
180
+ await override.initialize(store);
181
+ }
182
+ const renderingTree = await contentTreeToRenderingTree(componentNode, null, ssrInstance, false);
183
+ const headData = {
184
+ found: false,
185
+ instance: ssrInstance,
186
+ clientImportAliases: {},
187
+ importAliases: {},
188
+ compilationLocation: '',
189
+ dev: false,
190
+ tungstenPublicEnv: undefined,
191
+ siteBasePath: '',
192
+ hmr: true,
193
+ csr: instanceConfig.csr
194
+ };
195
+ html = await renderingNodeToHtml(renderingTree, false, headData, null);
196
+ } finally {
197
+ ssrScheduler.dispose();
198
+ }
199
+ // A real HTML parser - the same algorithm a browser runs before hydrate() ever sees the page
200
+ // - not a comparison against the string above, so browser parsing quirks (an auto-closed <p>,
201
+ // an inserted <tbody>) surface exactly as they would in production.
202
+ container.innerHTML = html;
203
+ bridgeHappyDomGlobals(document);
204
+ const scheduler = new UpdateScheduler();
205
+ const {
206
+ internalStore,
207
+ stores,
208
+ storeSubscriptions
209
+ } = initStores(location, null, globalData, matchedRouteInfo);
210
+ const runtimeContext = {
211
+ document,
212
+ window: document.defaultView,
213
+ scheduler,
214
+ navigation: false
215
+ };
216
+ const instance = new Instance(location, instanceConfig, null, emptyRoutes, emptyRoutes,
217
+ // eslint-disable-line no-type-assertion/no-type-assertion
218
+ internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo, runtimeContext);
219
+ try {
220
+ for (const override of options?.stores ?? []) {
221
+ const store = override.registration.getStore(instance.stores);
222
+ await override.initialize(store);
223
+ }
224
+ const meta = {
225
+ insideForm: false,
226
+ mismatches: []
227
+ };
228
+ const domPointer = new DomPointer(container, 0);
229
+ const component = await hydrateRootComponent(instance, RootComponent, domPointer, meta, clientProps, options?.routeParams, options?.routeData);
230
+ return new HydrateTestAppImplementation(document, container, component, instance, scheduler, ownsContainer, html, meta.mismatches);
231
+ } catch (error) {
232
+ try {
233
+ instance.disposeRegisteredComponents();
234
+ } catch {
235
+ // Preserve the mount failure.
236
+ }
237
+ scheduler.dispose();
238
+ while (container.firstChild !== null) container.removeChild(container.firstChild);
239
+ if (ownsContainer) container.remove();
240
+ throw error;
241
+ }
242
+ }