tungsten 0.4.11 → 0.4.13

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 (449) hide show
  1. package/dist/.build-complete +1 -1
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/AnyComponent.d.ts.map +1 -1
  4. package/dist/AnyComponent.js +1 -1
  5. package/dist/Components.d.ts.map +1 -1
  6. package/dist/Components.js +25 -23
  7. package/dist/ContentNode.js +2 -2
  8. package/dist/DomPointer.js +1 -1
  9. package/dist/DomRegion.js +3 -3
  10. package/dist/Framework.d.ts +2 -1
  11. package/dist/Framework.d.ts.map +1 -1
  12. package/dist/Framework.js +44 -35
  13. package/dist/FrameworkConfig.d.ts +16 -0
  14. package/dist/FrameworkConfig.d.ts.map +1 -1
  15. package/dist/FunctionComponentStandIn.js +8 -8
  16. package/dist/Instance/Instance.js +12 -12
  17. package/dist/RenderedContentNode.d.ts.map +1 -1
  18. package/dist/RenderedContentNode.js +4 -3
  19. package/dist/RenderingNode.js +2 -2
  20. package/dist/Sass.d.ts.map +1 -1
  21. package/dist/Sass.js +1 -0
  22. package/dist/Script.js +1 -1
  23. package/dist/Servers/DevServer.d.ts.map +1 -1
  24. package/dist/Servers/DevServer.js +33 -32
  25. package/dist/Servers/ProdServer.js +15 -15
  26. package/dist/Servers/StaticSiteServer.js +4 -4
  27. package/dist/Servers/TungstenServer.js +5 -5
  28. package/dist/Servers/devErrorPageAutoRetry.js +1 -1
  29. package/dist/Servers/initStores.js +3 -3
  30. package/dist/Servers/loadEnvsDev.d.ts +1 -1
  31. package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
  32. package/dist/Servers/loadEnvsDev.js +10 -8
  33. package/dist/Servers/routing.d.ts.map +1 -1
  34. package/dist/Servers/routing.js +4 -4
  35. package/dist/Store/Store.js +1 -1
  36. package/dist/Store/TypeSafeStore.js +1 -1
  37. package/dist/Store/createStores.js +2 -2
  38. package/dist/Store/makeStore.js +3 -3
  39. package/dist/Store/registerStore.js +3 -3
  40. package/dist/TElement.js +1 -1
  41. package/dist/TungstenApp.js +9 -5
  42. package/dist/TungstenStyleObject.js +1 -1
  43. package/dist/__deproxy.js +2 -2
  44. package/dist/_client/client.js +3 -3
  45. package/dist/alive.js +1 -1
  46. package/dist/api/getApiRoutes.js +3 -3
  47. package/dist/api/getExport.d.ts.map +1 -1
  48. package/dist/api/getExport.js +5 -4
  49. package/dist/api/getExportDev.js +1 -1
  50. package/dist/appOutput.js +1 -1
  51. package/dist/auth/index.js +2 -2
  52. package/dist/babelPlugins/BabelAddDevCacheBust.d.ts.map +1 -1
  53. package/dist/babelPlugins/BabelAddDevCacheBust.js +4 -2
  54. package/dist/babelPlugins/BabelTransformBindDirect.js +4 -2
  55. package/dist/babelPlugins/BabelTransformBindVar.d.ts.map +1 -1
  56. package/dist/babelPlugins/BabelTransformBindVar.js +3 -3
  57. package/dist/babelPlugins/BabelTransformCjsToEsm.js +1 -1
  58. package/dist/babelPlugins/BabelTransformComponentState.d.ts.map +1 -1
  59. package/dist/babelPlugins/BabelTransformComponentState.js +2 -2
  60. package/dist/babelPlugins/BabelTransformComponentStyles.d.ts +2 -0
  61. package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
  62. package/dist/babelPlugins/BabelTransformComponentStyles.js +32 -15
  63. package/dist/babelPlugins/BabelTransformCssImports.d.ts.map +1 -1
  64. package/dist/babelPlugins/BabelTransformCssImports.js +3 -3
  65. package/dist/babelPlugins/BabelTransformDependencyImportsOld.js +1 -1
  66. package/dist/babelPlugins/BabelTransformDeproxyState.d.ts.map +1 -1
  67. package/dist/babelPlugins/BabelTransformDeproxyState.js +1 -1
  68. package/dist/babelPlugins/BabelTransformJsxExtensionsToJs.d.ts.map +1 -1
  69. package/dist/babelPlugins/BabelTransformJsxExtensionsToJs.js +6 -2
  70. package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
  71. package/dist/babelPlugins/BabelTransformPackageImports.js +75 -53
  72. package/dist/babelPlugins/BabelTransformReactive.js +1 -1
  73. package/dist/babelPlugins/BabelTransformReactiveSvelteStyle.js +1 -1
  74. package/dist/babelPlugins/BabelTransformRemoveBlocks.d.ts.map +1 -1
  75. package/dist/babelPlugins/BabelTransformSxyFrameworkImports.js +1 -1
  76. package/dist/babelPlugins/BabelTransformUniqueComponents.js +1 -1
  77. package/dist/babelPlugins/fixImportsInSassErrorMessage.js +1 -1
  78. package/dist/babelPlugins/test.js +1 -1
  79. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.d.ts.map +1 -1
  80. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.js +5 -4
  81. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.d.ts.map +1 -1
  82. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.js +3 -2
  83. package/dist/babelPlugins/transformPackageImports/getWebLocationOfPackageFile.js +2 -2
  84. package/dist/bin/args.js +2 -2
  85. package/dist/bin/commands/build.js +6 -6
  86. package/dist/bin/commands/buildHelp.js +1 -1
  87. package/dist/bin/commands/clean.js +4 -4
  88. package/dist/bin/commands/compile.d.ts.map +1 -1
  89. package/dist/bin/commands/compile.js +24 -17
  90. package/dist/bin/commands/compileSimplePackage.js +3 -2
  91. package/dist/bin/commands/dev.d.ts.map +1 -1
  92. package/dist/bin/commands/dev.js +16 -9
  93. package/dist/bin/commands/devmon.js +4 -4
  94. package/dist/bin/commands/help.js +2 -2
  95. package/dist/bin/commands/start.js +2 -2
  96. package/dist/bin/commands/static.js +3 -3
  97. package/dist/bin/index.d.ts.map +1 -1
  98. package/dist/bin/index.js +24 -16
  99. package/dist/bin/moduleLoadAnalysis.js +2 -2
  100. package/dist/bin/vendorHook.d.ts +3 -0
  101. package/dist/bin/vendorHook.d.ts.map +1 -0
  102. package/dist/bin/vendorHook.js +34 -0
  103. package/dist/browserStorage.js +6 -4
  104. package/dist/build/babel.user.common.config.d.ts +9 -2
  105. package/dist/build/babel.user.common.config.d.ts.map +1 -1
  106. package/dist/build/babel.user.common.config.js +21 -16
  107. package/dist/build/bundle.d.ts +1 -1
  108. package/dist/build/bundle.d.ts.map +1 -1
  109. package/dist/build/bundle.js +15 -7
  110. package/dist/build/bundleBabelOptions.d.ts +6 -0
  111. package/dist/build/bundleBabelOptions.d.ts.map +1 -0
  112. package/dist/build/bundleBabelOptions.js +23 -0
  113. package/dist/build/combineComponentCss.js +2 -2
  114. package/dist/build/compileJavascript.d.ts +4 -0
  115. package/dist/build/compileJavascript.d.ts.map +1 -1
  116. package/dist/build/compileJavascript.js +174 -103
  117. package/dist/build/compileStyles.js +8 -8
  118. package/dist/build/compileUserApp.d.ts +1 -1
  119. package/dist/build/compileUserApp.d.ts.map +1 -1
  120. package/dist/build/compileUserApp.js +15 -12
  121. package/dist/build/componentStylesCache.d.ts +10 -0
  122. package/dist/build/componentStylesCache.d.ts.map +1 -0
  123. package/dist/build/componentStylesCache.js +54 -0
  124. package/dist/build/copyAssets.js +4 -4
  125. package/dist/build/copyPackageModulesToPackagesFolder.js +4 -4
  126. package/dist/build/copyPublicFiles.js +4 -4
  127. package/dist/build/createClientFiles.js +3 -3
  128. package/dist/build/createInstanceConfigFile.js +2 -2
  129. package/dist/build/createPackageVirtualFileSystems.js +1 -1
  130. package/dist/build/devBundle.js +5 -5
  131. package/dist/build/devBundle.rollup.config.d.ts.map +1 -1
  132. package/dist/build/devBundle.rollup.config.js +0 -1
  133. package/dist/build/frameworkDestLocation.d.ts +1 -0
  134. package/dist/build/frameworkDestLocation.d.ts.map +1 -1
  135. package/dist/build/frameworkDestLocation.js +8 -4
  136. package/dist/build/frameworkStylesheets.js +2 -2
  137. package/dist/build/getAllSxyClientModules.d.ts.map +1 -1
  138. package/dist/build/getAllSxyClientModules.js +4 -28
  139. package/dist/build/getPackageDirForFile.js +1 -1
  140. package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
  141. package/dist/build/getSxyClientPackageAliases.js +4 -2
  142. package/dist/build/getTempDirForAppCompilation.js +1 -1
  143. package/dist/build/makeBabelRawConfig.d.ts +3 -0
  144. package/dist/build/makeBabelRawConfig.d.ts.map +1 -0
  145. package/dist/build/makeBabelRawConfig.js +12 -0
  146. package/dist/build/makeBabelUserDevConfig.d.ts +1 -1
  147. package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
  148. package/dist/build/makeBabelUserDevConfig.js +11 -8
  149. package/dist/build/makeBabelUserProdConfig.d.ts +1 -1
  150. package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
  151. package/dist/build/makeBabelUserProdConfig.js +10 -5
  152. package/dist/build/rollup.user.prod.config.d.ts.map +1 -1
  153. package/dist/build/rollup.user.prod.config.js +13 -11
  154. package/dist/build/rollupExtractComponentStylesheets.js +3 -3
  155. package/dist/build/sassImportParser.js +4 -4
  156. package/dist/build/tallyBabel.d.ts +3 -0
  157. package/dist/build/tallyBabel.d.ts.map +1 -0
  158. package/dist/build/tallyBabel.js +11 -0
  159. package/dist/calculateImportedStaticFileLocations.js +2 -2
  160. package/dist/calledFrom.js +2 -2
  161. package/dist/clone.js +4 -4
  162. package/dist/compat/context.d.ts.map +1 -1
  163. package/dist/compat/forwardRef.js +1 -1
  164. package/dist/compat/index.js +1 -1
  165. package/dist/compat/types.d.ts.map +1 -1
  166. package/dist/componentProxyHandlers.d.ts.map +1 -1
  167. package/dist/componentProxyHandlers.js +8 -12
  168. package/dist/components/Link.js +2 -2
  169. package/dist/components/PopMessages.js +3 -3
  170. package/dist/components/RawHtml.js +2 -2
  171. package/dist/components/Stylesheet.d.ts +1 -2
  172. package/dist/components/Stylesheet.d.ts.map +1 -1
  173. package/dist/components/Stylesheet.js +4 -4
  174. package/dist/components/bindable/BindableCheckbox.d.ts.map +1 -1
  175. package/dist/components/bindable/BindableCheckbox.js +1 -1
  176. package/dist/components/bindable/BindableInput.d.ts.map +1 -1
  177. package/dist/components/bindable/BindableInput.js +1 -1
  178. package/dist/components/bindable/BindableInputNonString.js +1 -1
  179. package/dist/components/bindable/BindableInputString.js +1 -1
  180. package/dist/components/bindable/BindableInputTyped.js +1 -1
  181. package/dist/components/bindable/BindableInputTypedLegacy.d.ts.map +1 -1
  182. package/dist/components/bindable/BindableInputTypedLegacy.js +1 -1
  183. package/dist/components/bindable/BindableRadio.d.ts.map +1 -1
  184. package/dist/components/bindable/BindableRadio.js +1 -1
  185. package/dist/components/bindable/BindableSelect.js +1 -1
  186. package/dist/components/bindable/BindableTextarea.d.ts.map +1 -1
  187. package/dist/components/bindable/BindableTextarea.js +1 -1
  188. package/dist/components/library/RichTextEditor/RichTextEditor.js +10 -10
  189. package/dist/components/library/RichTextEditor/contentTree.js +5 -5
  190. package/dist/components/library/RichTextEditor/sanitizeAuthoredHtml.js +2 -2
  191. package/dist/components/library/__StatefulMessage/StatefulMessage.js +2 -2
  192. package/dist/components/library/index.js +2 -2
  193. package/dist/concat.d.ts.map +1 -1
  194. package/dist/concat.js +2 -2
  195. package/dist/copy.d.ts.map +1 -1
  196. package/dist/createElement.js +1 -1
  197. package/dist/createRoutes.d.ts +1 -1
  198. package/dist/createRoutes.d.ts.map +1 -1
  199. package/dist/defaultConfig.d.ts +0 -1
  200. package/dist/defaultConfig.d.ts.map +1 -1
  201. package/dist/defaultConfig.js +2 -2
  202. package/dist/deleteDirs.js +1 -1
  203. package/dist/env/Env.js +2 -2
  204. package/dist/env/addToEnv.js +1 -1
  205. package/dist/env/funcs.js +4 -4
  206. package/dist/env/getEnvSchemas.d.ts +2 -2
  207. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  208. package/dist/env/getEnvSchemas.js +16 -10
  209. package/dist/env/privateEnv.js +2 -2
  210. package/dist/env/privateEnvOrThrow.js +1 -1
  211. package/dist/env/publicEnv.js +1 -1
  212. package/dist/env/publicEnvOrThrow.js +1 -1
  213. package/dist/env/windowGlobalEnvStatement.d.ts.map +1 -1
  214. package/dist/filePathFromUrl.js +1 -1
  215. package/dist/findProjectDir.d.ts.map +1 -1
  216. package/dist/findProjectDir.js +19 -5
  217. package/dist/findUserConfig.js +7 -7
  218. package/dist/fixExtension.d.ts.map +1 -1
  219. package/dist/fixExtension.js +5 -3
  220. package/dist/foreach.js +1 -0
  221. package/dist/frameworkConfigSchema.d.ts +16 -0
  222. package/dist/frameworkConfigSchema.d.ts.map +1 -1
  223. package/dist/frameworkConfigSchema.js +14 -2
  224. package/dist/getComponent.d.ts.map +1 -1
  225. package/dist/getComponent.js +5 -5
  226. package/dist/getComponentDev.d.ts.map +1 -1
  227. package/dist/getComponentDev.js +1 -1
  228. package/dist/getFrameworkDir.js +1 -1
  229. package/dist/getRoutes.d.ts.map +1 -1
  230. package/dist/getRoutes.js +18 -27
  231. package/dist/getRoutesDevs.d.ts.map +1 -1
  232. package/dist/getRoutesDevs.js +1 -1
  233. package/dist/getStackTrace.js +1 -1
  234. package/dist/getUserConfig.js +7 -7
  235. package/dist/glob.d.ts +5 -0
  236. package/dist/glob.d.ts.map +1 -0
  237. package/dist/glob.js +103 -0
  238. package/dist/hasValidKey.js +1 -1
  239. package/dist/helpers/getFetchCompatibleHeaders.js +2 -2
  240. package/dist/helpers/index.js +2 -2
  241. package/dist/hmr/applyHmrModule.js +10 -10
  242. package/dist/hmr/componentIdentity.js +3 -3
  243. package/dist/hmr/instanceRegistry.js +2 -2
  244. package/dist/hooks/clearCurrentComponent.js +1 -1
  245. package/dist/hooks/getCurrentComponent.js +3 -3
  246. package/dist/hooks/index.js +5 -5
  247. package/dist/hooks/setCurrentComponent.js +1 -1
  248. package/dist/hooks/useCallback.js +2 -2
  249. package/dist/hooks/useEffect.js +2 -2
  250. package/dist/hooks/useInstance.js +1 -1
  251. package/dist/hooks/useMemo.js +2 -2
  252. package/dist/hooks/useReducer.d.ts.map +1 -1
  253. package/dist/hooks/useState.d.ts.map +1 -1
  254. package/dist/hooks/useState.js +3 -9
  255. package/dist/hydrate/hydrate.d.ts +1 -1
  256. package/dist/hydrate/hydrate.d.ts.map +1 -1
  257. package/dist/hydrate/hydrate.js +56 -54
  258. package/dist/hydrate/reconcileHydratedAttributes.js +5 -5
  259. package/dist/index.js +2 -2
  260. package/dist/indexInner.d.ts +1 -1
  261. package/dist/indexInner.d.ts.map +1 -1
  262. package/dist/indexInner.js +45 -45
  263. package/dist/innerHtmlFromProps.js +1 -1
  264. package/dist/isBrowser.js +1 -1
  265. package/dist/isDev.js +1 -1
  266. package/dist/isProd.js +1 -1
  267. package/dist/isServer.js +1 -1
  268. package/dist/jsx-runtime.js +1 -1
  269. package/dist/jsxRuntime.d.ts.map +1 -1
  270. package/dist/jsxRuntime.js +12 -7
  271. package/dist/jsxRuntimeSignals.d.ts.map +1 -1
  272. package/dist/jsxRuntimeSignals.js +15 -8
  273. package/dist/makeFinalConfig.d.ts.map +1 -1
  274. package/dist/makeFinalConfig.js +3 -3
  275. package/dist/makeInstanceConfigFromFrameworkConfig.js +1 -1
  276. package/dist/makeServerRpc.js +3 -3
  277. package/dist/markOptionSelected.js +2 -2
  278. package/dist/mergeConfigs.d.ts.map +1 -1
  279. package/dist/mergeConfigs.js +11 -2
  280. package/dist/mutatingFunctions.js +3 -3
  281. package/dist/nbsp.js +1 -1
  282. package/dist/output.js +1 -1
  283. package/dist/pop.js +2 -2
  284. package/dist/postcssPlugins/TransformCssNames.js +8 -8
  285. package/dist/postcssPlugins/parseSelectors.js +1 -1
  286. package/dist/postcssPlugins/parseSelectorsRich.js +1 -1
  287. package/dist/postcssPlugins/scopeAnimationValue.js +2 -2
  288. package/dist/propsAreEqual.js +3 -3
  289. package/dist/rawHtml/filterContentNode.js +4 -4
  290. package/dist/rawHtml/parseHtml.js +5 -5
  291. package/dist/rawHtml/sanitizeHtml.js +3 -3
  292. package/dist/rawHtml/tokenizeHtml.js +2 -2
  293. package/dist/render/addImportMap.js +2 -2
  294. package/dist/render/classComponentNodeToRenderingTree.js +4 -4
  295. package/dist/render/componentNodeToRenderingTree.d.ts.map +1 -1
  296. package/dist/render/componentNodeToRenderingTree.js +13 -24
  297. package/dist/render/contentNodeToHtml.js +11 -11
  298. package/dist/render/contentToHtml.d.ts.map +1 -1
  299. package/dist/render/contentToHtml.js +5 -5
  300. package/dist/render/contentToHtmlDev.js +1 -1
  301. package/dist/render/contentTreeToRenderingTree.js +7 -7
  302. package/dist/render/functionComponentNodeToRenderingTree.js +4 -4
  303. package/dist/render/getFunctionBodyAsString.d.ts.map +1 -1
  304. package/dist/render/getFunctionBodyAsString.js +3 -6
  305. package/dist/render/instantiateClassComponent.js +2 -2
  306. package/dist/render/instantiateComponent.js +3 -3
  307. package/dist/render/instantiateFunctionComponent.js +2 -2
  308. package/dist/render/printComponentNameInSource.js +1 -1
  309. package/dist/render/processHead.js +5 -5
  310. package/dist/render/processHtmlNode.js +1 -1
  311. package/dist/render/processProps.js +4 -4
  312. package/dist/render/processRenderingNodeHtml.js +6 -6
  313. package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
  314. package/dist/render/renderingTreeToHtml.js +16 -16
  315. package/dist/render/rootToHtml.d.ts.map +1 -1
  316. package/dist/render/rootToHtml.js +2 -2
  317. package/dist/render/rootToHtmlDev.js +1 -1
  318. package/dist/requests/fetch/delete.js +2 -2
  319. package/dist/requests/fetch/get.js +3 -3
  320. package/dist/requests/fetch/patch.js +2 -2
  321. package/dist/requests/fetch/post.js +2 -2
  322. package/dist/requests/fetch/put.js +2 -2
  323. package/dist/requests/index.js +5 -5
  324. package/dist/routing/MatchedRoute.js +2 -2
  325. package/dist/routing/Route.js +1 -1
  326. package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
  327. package/dist/routing/RoutesWithSafeParams.js +1 -1
  328. package/dist/routing/WebRedirect.d.ts.map +1 -1
  329. package/dist/routing/compareRequestToRegex.js +2 -2
  330. package/dist/routing/getPathPriority.js +2 -2
  331. package/dist/routing/matchPath.js +3 -3
  332. package/dist/routing/patternToRegex.js +1 -1
  333. package/dist/server.js +3 -3
  334. package/dist/serverModuleLocation.d.ts +3 -0
  335. package/dist/serverModuleLocation.d.ts.map +1 -0
  336. package/dist/serverModuleLocation.js +12 -0
  337. package/dist/serverRpc.d.ts.map +1 -1
  338. package/dist/settings.d.ts +4 -0
  339. package/dist/settings.d.ts.map +1 -1
  340. package/dist/settings.js +9 -0
  341. package/dist/slash.d.ts +2 -0
  342. package/dist/slash.d.ts.map +1 -0
  343. package/dist/slash.js +5 -0
  344. package/dist/spawnShellCommand.js +1 -1
  345. package/dist/standardSchema.js +1 -1
  346. package/dist/staticGen/getAppRoutes.js +3 -3
  347. package/dist/staticGen/staticGen.d.ts.map +1 -1
  348. package/dist/staticGen/staticGen.js +16 -14
  349. package/dist/staticGen/staticGenFunctions.js +1 -1
  350. package/dist/style/jssToCss.d.ts.map +1 -1
  351. package/dist/style/jssToCss.js +13 -11
  352. package/dist/style/styleContent.js +1 -1
  353. package/dist/style/styleContentSxy.js +8 -8
  354. package/dist/style/unusedStyles.d.ts.map +1 -1
  355. package/dist/style/unusedStyles.js +1 -1
  356. package/dist/sync/index.js +1 -1
  357. package/dist/syncServer/preload.js +1 -1
  358. package/dist/testing/host.js +12 -12
  359. package/dist/testing/hydrateTestApp.d.ts.map +1 -1
  360. package/dist/testing/hydrateTestApp.js +18 -18
  361. package/dist/testing/index.d.ts.map +1 -1
  362. package/dist/testing/index.js +11 -11
  363. package/dist/testing/installTestStyleProcessors.js +2 -2
  364. package/dist/testing/loadEnv.d.ts +4 -1
  365. package/dist/testing/loadEnv.d.ts.map +1 -1
  366. package/dist/testing/loadEnv.js +5 -5
  367. package/dist/testing/temp/componentPackageMock.js +5 -5
  368. package/dist/testing/temp/contentHtmlElements.js +2 -2
  369. package/dist/throwError.js +2 -2
  370. package/dist/timeProfiler.d.ts +5 -1
  371. package/dist/timeProfiler.d.ts.map +1 -1
  372. package/dist/timeProfiler.js +76 -24
  373. package/dist/todo.js +2 -1
  374. package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
  375. package/dist/update/integrateUpdateVdom.js +44 -41
  376. package/dist/update/integrateUpdateVdomPrebuild.js +5 -5
  377. package/dist/validChildren.js +2 -2
  378. package/dist/warnOnFrameworkChange.js +2 -2
  379. package/dist/watch.js +2 -2
  380. package/dist/zones/react.js +3 -3
  381. package/package.json +27 -39
  382. package/types/modules.d.ts +2 -1
  383. package/vendor/babel-core.js +26 -0
  384. package/vendor/babel-parser.js +9 -0
  385. package/vendor/babel-plugin-syntax-import-assertions.js +50 -0
  386. package/vendor/babel-preset-react.js +872 -0
  387. package/vendor/babel-preset-typescript.js +26 -0
  388. package/vendor/babel-types.js +9 -0
  389. package/vendor/chalk-extensions.js +1994 -0
  390. package/vendor/chalk.js +647 -0
  391. package/vendor/chokidar.js +6889 -0
  392. package/vendor/chunk-1TN2rK3j.js +1218 -0
  393. package/vendor/chunk-1UuLTU0U.js +34 -0
  394. package/vendor/chunk-B_NeooyV.js +86 -0
  395. package/vendor/chunk-C12hSZn7.js +88 -0
  396. package/vendor/chunk-C3YkUGz5.js +19 -0
  397. package/vendor/chunk-C3fcZDjl.js +41964 -0
  398. package/vendor/chunk-C9FSKeSx.js +14603 -0
  399. package/vendor/chunk-CPArXGxa.js +14623 -0
  400. package/vendor/cjs-module-lexer.js +6 -0
  401. package/vendor/dotenv.js +412 -0
  402. package/vendor/express.js +40577 -0
  403. package/vendor/import-meta-resolve.js +2201 -0
  404. package/vendor/manifest.json +29 -0
  405. package/vendor/postcss.js +8546 -0
  406. package/vendor/serialize-javascript.js +293 -0
  407. package/vendor/sxy-lib-arrays.js +113 -0
  408. package/vendor/sxy-lib-object-copy.js +1781 -0
  409. package/vendor/sxy-lib-objects.js +156 -0
  410. package/vendor/sxy-lib-promises.js +47 -0
  411. package/vendor/sxy-package-investigator.js +202 -0
  412. package/vendor/valibot.js +7664 -0
  413. package/dist/Servers/hono/DevServerHono.d.ts +0 -2
  414. package/dist/Servers/hono/DevServerHono.d.ts.map +0 -1
  415. package/dist/Servers/hono/DevServerHono.js +0 -423
  416. package/dist/Servers/hono/ProdServerHono.d.ts +0 -2
  417. package/dist/Servers/hono/ProdServerHono.d.ts.map +0 -1
  418. package/dist/Servers/hono/ProdServerHono.js +0 -220
  419. package/dist/Servers/hono/TungstenServerHono.d.ts +0 -6
  420. package/dist/Servers/hono/TungstenServerHono.d.ts.map +0 -1
  421. package/dist/Servers/hono/TungstenServerHono.js +0 -36
  422. package/dist/api/ApiEndpointHono.d.ts +0 -3
  423. package/dist/api/ApiEndpointHono.d.ts.map +0 -1
  424. package/dist/api/ApiEndpointHono.js +0 -1
  425. package/dist/api/ApiRouteHono.d.ts +0 -7
  426. package/dist/api/ApiRouteHono.d.ts.map +0 -1
  427. package/dist/api/ApiRouteHono.js +0 -1
  428. package/dist/api/ApiRoutesHono.d.ts +0 -5
  429. package/dist/api/ApiRoutesHono.d.ts.map +0 -1
  430. package/dist/api/ApiRoutesHono.js +0 -1
  431. package/dist/api/getApiRoutesHono.d.ts +0 -6
  432. package/dist/api/getApiRoutesHono.d.ts.map +0 -1
  433. package/dist/api/getApiRoutesHono.js +0 -14
  434. package/dist/build/compilePackages.d.ts +0 -2
  435. package/dist/build/compilePackages.d.ts.map +0 -1
  436. package/dist/build/compilePackages.js +0 -89
  437. package/dist/build/findRequiredUserModule.d.ts +0 -2
  438. package/dist/build/findRequiredUserModule.d.ts.map +0 -1
  439. package/dist/build/findRequiredUserModule.js +0 -36
  440. package/dist/build/processPackage.d.ts +0 -4
  441. package/dist/build/processPackage.d.ts.map +0 -1
  442. package/dist/build/processPackage.js +0 -91
  443. package/dist/build/tallyBabelPlugins.d.ts +0 -3
  444. package/dist/build/tallyBabelPlugins.d.ts.map +0 -1
  445. package/dist/build/tallyBabelPlugins.js +0 -68
  446. package/dist/testing/loadEnvSetup.d.ts +0 -2
  447. package/dist/testing/loadEnvSetup.d.ts.map +0 -1
  448. package/dist/testing/loadEnvSetup.js +0 -7
  449. package/sxy-loader.config.js +0 -7
@@ -1,15 +1,26 @@
1
1
  import { MakeBabelTransformJsxExtensionsToJs } from "../babelPlugins/BabelTransformJsxExtensionsToJs.js";
2
2
  import { buildFolder } from "../settings.js";
3
+ import { createRequire } from "module";
3
4
  import babelPresetReactModule from "@babel/preset-react";
4
5
  const babelPresetReact = babelPresetReactModule.default;
5
- import babelPluginSxyModuleResolve from "babel-plugin-sxy-module-resolver";
6
- import babelPluginCssToJs from "babel-plugin-css-to-js";
7
- import babelPluginProposalClassPropertiesModule from "@babel/plugin-transform-class-properties";
8
- const babelPluginProposalClassProperties = babelPluginProposalClassPropertiesModule.default;
6
+ const require = createRequire(import.meta.url);
7
+ // config `typescript: true`: appended after preset-react so babel runs it first (presets run last
8
+ // to first). allowDeclareFields matches tsc's useDefineForClassFields: `x: T` stays a field,
9
+ // `declare x: T` is erased - without it babel erases both.
10
+ // required on demand: ~95 modules that only this flag needs
11
+ export function typescriptPreset() {
12
+ const babelPresetTypescript = require("@babel/preset-typescript").default;
13
+ return [babelPresetTypescript, {
14
+ allowDeclareFields: true
15
+ }];
16
+ }
9
17
  const regexEscape = r => r.replaceAll(".", "\\.");
10
18
  const ignoreRegex = new RegExp(`(node_modules|${regexEscape(buildFolder)})`);
11
19
  const userCommonConfig = {
12
20
  ignore: [ignoreRegex],
21
+ // the config is all here: no per-file search up the tree for .babelrc / babel.config.*
22
+ babelrc: false,
23
+ configFile: false,
13
24
  presets: [[babelPresetReact, {
14
25
  "runtime": "automatic",
15
26
  "importSource": "tungsten"
@@ -19,17 +30,11 @@ const userCommonConfig = {
19
30
  // "importSource": "tungsten",
20
31
  // }],
21
32
  ],
22
- plugins: [[babelPluginSxyModuleResolve, {
23
- // This alias is resolved after Tungsten rewrites package imports.
24
- "loglevel": "silent",
25
- "alias": {
26
- "tungsten/jsx-runtime": "tungsten/jsxRuntime.js" // fix the import location created by @babel/preset-react
27
- }
28
- }], MakeBabelTransformJsxExtensionsToJs(), [babelPluginCssToJs], [babelPluginProposalClassProperties]],
29
- "env": {
30
- "production": {
31
- "plugins": ["transform-react-remove-prop-types"]
32
- }
33
- }
33
+ // widen to allow pushing
34
+ // no alias plugin: preset-react's `tungsten/jsx-runtime` import resolves through the package's
35
+ // exports map (node, rollup, the packages plugin) and the dev import map has the same key
36
+ plugins: [MakeBabelTransformJsxExtensionsToJs()
37
+ // no css-to-js: the lowercase css`…` tag it compiled is not used; css="…" is a plain string prop
38
+ ] // widen to allow pushing
34
39
  };
35
40
  export default userCommonConfig;
@@ -1,2 +1,2 @@
1
- export declare function bundle(projectDir: string, quiet?: boolean): Promise<unknown>;
1
+ export declare function bundle(projectDir: string, quiet?: boolean, targets?: string | string[]): Promise<unknown>;
2
2
  //# sourceMappingURL=bundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/build/bundle.ts"],"names":[],"mappings":"AAUA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,UAAQ,oBAyC7D"}
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/build/bundle.ts"],"names":[],"mappings":"AAWA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,UAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,oBA8C1F"}
@@ -1,11 +1,12 @@
1
1
  import { join } from 'path';
2
2
  //import type { FrameworkConfigComplete } from '../FrameworkConfig.js'
3
- import { findProjectDir } from "../findProjectDir.js";
4
- import { spawnShellCommand } from "../spawnShellCommand.js";
5
- import { prodBuildFolder, bundleFolder, frameworkDistFolder, clientFolder } from "../settings.js";
6
- import { errorOut } from "../output.js";
7
- import { cliLog, cliOut } from "../cliOutput.js";
8
- export async function bundle(projectDir, quiet = false /*, appConfig: FrameworkConfigComplete*/) {
3
+ import { findProjectDir } from '../findProjectDir.js';
4
+ import { spawnShellCommand } from '../spawnShellCommand.js';
5
+ import { prodBuildFolder, bundleFolder, frameworkDistFolder, clientFolder } from '../settings.js';
6
+ import { errorOut } from '../output.js';
7
+ import { cliLog, cliOut } from '../cliOutput.js';
8
+ // targets: the config's browser floor for rollup's babel step, undefined for the framework default
9
+ export async function bundle(projectDir, quiet = false, targets) {
9
10
  return new Promise((resolve, reject) => {
10
11
  if (!quiet) cliOut('Bundling application');
11
12
  const frameworkDir = findProjectDir(import.meta.url);
@@ -18,8 +19,15 @@ export async function bundle(projectDir, quiet = false /*, appConfig: FrameworkC
18
19
  ];
19
20
  const command = `cd ${frameworkDir} && npx rollup` + ` --input "${join(projectDir, prodBuildFolder, clientFolder, 'client.js')}"` + ` --file "${join(projectDir, bundleFolder, 'client.js')}"` + ` --config "${join(frameworkDir, frameworkDistFolder, 'build/rollup.user.prod.config.js')}"` + (externalModules.length > 0 ? ` --external ${externalModules.join(',')}` : ``) + ` --inlineDynamicImports --format iife`;
20
21
  if (!quiet) cliLog('bundle command:', command);
22
+ // the rollup config reads this back; a browserslist query can hold commas, which rollup's own
23
+ // --environment flag would split on
24
+ const env = targets === undefined ? process.env : {
25
+ ...process.env,
26
+ TUNGSTEN_TARGETS: JSON.stringify(targets)
27
+ };
21
28
  const subProcess = spawnShellCommand(command, {
22
- cwd: frameworkDir /*cwd: projectDir*/ /*, stdio: 'inherit'*/
29
+ cwd: frameworkDir,
30
+ env
23
31
  });
24
32
  subProcess.on('data', data => {
25
33
  if (!quiet) cliLog(data);
@@ -0,0 +1,6 @@
1
+ import type { PluginItem } from '@babel/core';
2
+ export declare function bundleBabelOptions(targets?: string | string[]): {
3
+ presets: PluginItem[];
4
+ plugins: PluginItem[];
5
+ };
6
+ //# sourceMappingURL=bundleBabelOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundleBabelOptions.d.ts","sourceRoot":"","sources":["../../src/build/bundleBabelOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAa7C,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,MAAM,GAAG,MAAM,EAA0B;;;EAMpF"}
@@ -0,0 +1,23 @@
1
+ import presetEnvModule from '@babel/preset-env';
2
+ import { MakeBabelTransformRemoveServerBlocks } from '../babelPlugins/BabelTransformRemoveServerBlocks.js';
3
+ import { MakeBabelTransformRemoveDevBlocks } from '../babelPlugins/BabelTransformRemoveDevBlocks.js';
4
+ import { defaultBrowserTargets } from '../settings.js';
5
+ // babel 7 presets are cjs and arrive as { default }, babel 8's are esm and arrive as the function
6
+ const presetEnv = typeof presetEnvModule === 'function' ? presetEnvModule : presetEnvModule.default;
7
+ // The production bundle's babel pass: strips server and dev blocks and lowers syntax to the browser
8
+ // floor. Back-compat lives here and nowhere else - dev serves what tsc emits. Only the rollup
9
+ // config (a build-time subprocess) imports this, so preset-env never loads under dev.
10
+ export function bundleBabelOptions(targets = defaultBrowserTargets) {
11
+ // bugfixes: where a target has a feature with a known bug, apply the small fix instead of the
12
+ // full lowering (opt-in on babel 7, always on in 8)
13
+ const presets = [[presetEnv, {
14
+ targets,
15
+ bugfixes: true,
16
+ modules: false
17
+ }]];
18
+ const plugins = [MakeBabelTransformRemoveServerBlocks(), MakeBabelTransformRemoveDevBlocks()];
19
+ return {
20
+ presets,
21
+ plugins
22
+ };
23
+ }
@@ -1,7 +1,7 @@
1
1
  import { promises as fsPromises } from 'fs';
2
2
  import { isAbsolute, join, relative, resolve } from 'path';
3
- import { componentCssFile, componentCssFolder } from "../settings.js";
4
- import { TungstenError } from "../TungstenError.js";
3
+ import { componentCssFile, componentCssFolder } from '../settings.js';
4
+ import { TungstenError } from '../TungstenError.js';
5
5
  const componentImportPattern = /@import\s+["'](i\/[^"']+\.css)["']\s*;/g;
6
6
  const charsetPattern = /@charset\s+["']([^"']+)["']\s*;?/gi;
7
7
  function validateCharset(css, file) {
@@ -11,14 +11,18 @@ type CompileJavascriptResult = {
11
11
  export type JavascriptCompilationCycle = {
12
12
  success: boolean;
13
13
  file?: string;
14
+ client?: boolean;
14
15
  };
15
16
  export type CompileJavascriptOptions = {
16
17
  quiet?: boolean;
17
18
  packagesCacheLocation?: string;
19
+ stylesCacheLocation?: string;
20
+ rawBuildLocation?: string;
18
21
  packages?: boolean;
19
22
  hmr?: boolean;
20
23
  onCycleComplete?: ((cycle: JavascriptCompilationCycle) => void | Promise<void>) | undefined;
21
24
  tests?: boolean;
25
+ fresh?: boolean;
22
26
  };
23
27
  export declare function compileJavascript(projectDir: string, appConfig: FrameworkConfigComplete, codeLocation: string, sourceLocation: string, styleImportBase: string, buildLocation: string, buildCodeLocation: string, mode: Mode, watch?: boolean, options?: CompileJavascriptOptions): Promise<CompileJavascriptResult>;
24
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"compileJavascript.d.ts","sourceRoot":"","sources":["../../src/build/compileJavascript.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAO/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAiBtC,KAAK,uBAAuB,GAAG;IAC3B,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IAClC,WAAW,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IACtC,aAAa,EAAE,aAAa,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACnC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAE9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,0BAA0B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAA;IAE3F,KAAK,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAoBD,wBAAsB,iBAAiB,CACnC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EACtD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EACrE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,UAAO,EAC1E,OAAO,GAAE,wBAA6B,GACvC,OAAO,CAAC,uBAAuB,CAAC,CA+blC"}
1
+ {"version":3,"file":"compileJavascript.d.ts","sourceRoot":"","sources":["../../src/build/compileJavascript.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAO/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAmBtC,KAAK,uBAAuB,GAAG;IAC3B,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IAClC,WAAW,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IACtC,aAAa,EAAE,aAAa,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,MAAM,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACnC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAE5B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,0BAA0B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAA;IAE3F,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf,KAAK,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAuBD,wBAAsB,iBAAiB,CACnC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EACtD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EACrE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,UAAO,EAC1E,OAAO,GAAE,wBAA6B,GACvC,OAAO,CAAC,uBAAuB,CAAC,CA4gBlC"}
@@ -1,26 +1,31 @@
1
- import { join, dirname } from 'path';
1
+ import { join, dirname, isAbsolute } from 'path';
2
2
  import { pathToFileURL } from 'url';
3
3
  import chokidar from 'chokidar';
4
- import { transformFileSync as babelTransformFileSync } from '@babel/core';
4
+ import { transformSync as babelTransformSync } from '@babel/core';
5
5
  import fs, { promises as fsPromises } from 'fs';
6
- import slash from 'slash';
6
+ import slash from '../slash.js';
7
7
  import serializeJavascript from 'serialize-javascript';
8
- import { globby } from 'globby';
9
- import { packagesCacheFolder } from "../settings.js";
10
- import { makeBabelUserDevConfig } from "./makeBabelUserDevConfig.js";
11
- import { makeBabelUserProdConfig } from "./makeBabelUserProdConfig.js";
12
- import { cliOut, cliLog, cliError, cliWarn } from "../cliOutput.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
13
- import { createTimeProfiler, isProfiling, tally } from "../timeProfiler.js";
14
- import { tallyBabelPlugins } from "./tallyBabelPlugins.js";
15
- import { TungstenError } from "../TungstenError.js";
16
- import { getFrameworkDir } from "../getFrameworkDir.js";
8
+ import { glob } from '../glob.js';
9
+ import { devRawBuildFolder, packagesCacheFolder, prodRawBuildFolder, stylesCacheFolder } from '../settings.js';
10
+ import { frameworkVersion } from './frameworkDestLocation.js';
11
+ import { makeBabelUserDevConfig } from './makeBabelUserDevConfig.js';
12
+ import { makeBabelUserProdConfig } from './makeBabelUserProdConfig.js';
13
+ import { makeBabelRawConfig } from './makeBabelRawConfig.js';
14
+ import { cliOut, cliLog, cliError, cliWarn } from '../cliOutput.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import { createTimeProfiler, isProfiling, tallied } from '../timeProfiler.js';
16
+ import { tallyBabel } from './tallyBabel.js';
17
+ import { TungstenError } from '../TungstenError.js';
18
+ import { getFrameworkDir } from '../getFrameworkDir.js';
17
19
  // The graph writeDependencyGraph() left behind on the previous run, naming a compiled copy of every
18
20
  // package file in the packages cache. Missing or unreadable just means everything is compiled from
19
21
  // source, which is what happened on every run before this was read back.
22
+ // Nodes are keyed by package version only, so a graph another tungsten version wrote is discarded:
23
+ // the transform may have changed. frameworkVersion here is a free option - any stamp works.
20
24
  async function loadDependencyGraph(location) {
21
25
  if (!fs.existsSync(location)) return {};
22
26
  try {
23
27
  const graphModule = await import(pathToFileURL(location).href);
28
+ if (graphModule.version !== frameworkVersion) return {};
24
29
  return graphModule.graph ?? {};
25
30
  } catch (error) {
26
31
  cliWarn(`Could not read the package cache at ${location}, compiling packages from source`);
@@ -33,6 +38,9 @@ async function loadDependencyGraph(location) {
33
38
  export async function compileJavascript(projectDir, appConfig, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, mode, watch = true, options = {}) {
34
39
  if (options.quiet !== true) cliOut(`Compiling app code`);
35
40
  const compilePackages = options.packages !== false;
41
+ // codeLocation's .ts/.tsx are sources too, compiled to .js by babel; .d.ts is never one
42
+ const typescript = appConfig.typescript === true;
43
+ const rawBuildLocation = options.rawBuildLocation ?? join(projectDir, mode === 'dev' ? devRawBuildFolder : prodRawBuildFolder);
36
44
  let dependencyGraphDir = '';
37
45
  let dependencyGraphLocation = '';
38
46
  let oldDependencyGraph = {};
@@ -44,9 +52,8 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
44
52
  const skipPackageCompilationFiles = new Set();
45
53
  async function refreshSkipPackageCompilationFiles() {
46
54
  skipPackageCompilationFiles.clear();
47
- const matchingFiles = await globby(skipPackageCompilationPatterns, {
48
- cwd: codeLocation,
49
- absolute: true
55
+ const matchingFiles = await glob(skipPackageCompilationPatterns, {
56
+ cwd: codeLocation
50
57
  });
51
58
  for (const file of matchingFiles) skipPackageCompilationFiles.add(slash(file));
52
59
  }
@@ -54,35 +61,48 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
54
61
  if (mode === 'dev') {
55
62
  dependencyGraphDir = options.packagesCacheLocation ?? join(projectDir, packagesCacheFolder);
56
63
  dependencyGraphLocation = join(dependencyGraphDir, '.dependency-graph.js');
57
- oldDependencyGraph = await loadDependencyGraph(dependencyGraphLocation);
64
+ oldDependencyGraph = options.fresh === true ? {} : await loadDependencyGraph(dependencyGraphLocation);
58
65
  dependencyGraph = {};
59
66
  importAliases = {};
60
67
  promises = [];
61
- config = makeBabelUserDevConfig(projectDir, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, dependencyGraphDir, skipPackageCompilationFiles, oldDependencyGraph, dependencyGraph, importAliases, promises, watch, options.hmr === true, compilePackages);
68
+ config = makeBabelUserDevConfig(projectDir, codeLocation, sourceLocation, typescript, styleImportBase, buildLocation, buildCodeLocation, dependencyGraphDir, options.stylesCacheLocation ?? join(projectDir, stylesCacheFolder), options.fresh === true, skipPackageCompilationFiles, oldDependencyGraph, dependencyGraph, importAliases, promises, watch, options.hmr === true, compilePackages);
62
69
  } else {
63
- config = makeBabelUserProdConfig(projectDir, codeLocation, sourceLocation, styleImportBase, watch);
70
+ config = makeBabelUserProdConfig(projectDir, codeLocation, sourceLocation, typescript, styleImportBase, watch);
64
71
  }
65
72
  config.root = getFrameworkDir();
73
+ const rawConfig = makeBabelRawConfig(typescript);
74
+ rawConfig.root = config.root;
66
75
  // per-plugin attribution of the transform's time, only when someone is looking: the wrappers
67
76
  // run per AST node
68
77
  if (isProfiling()) {
69
- config.plugins = tallyBabelPlugins(config.plugins);
78
+ tallyBabel(config);
79
+ tallyBabel(rawConfig);
70
80
  if (mode === 'dev' && compilePackages) {
71
- cliWarn(`profiling serves linked packages from the packages cache -` + ` delete ${dependencyGraphDir} after rebuilding one, or this run compiles stale code`);
81
+ cliWarn(`profiling serves linked packages from the packages cache -` + ` pass --fresh after rebuilding one, or this run compiles stale code`);
72
82
  }
73
83
  }
74
84
  // compile with the API
75
85
  const codeLocationLength = codeLocation.length + 1;
86
+ // a source's path within the build: every compiled extension becomes .js
87
+ function outputRel(file) {
88
+ const rel = file.slice(codeLocationLength);
89
+ if (rel.endsWith('.jsx')) return rel.slice(0, -1);
90
+ if (typescript && rel.endsWith('.tsx')) return `${rel.slice(0, -3)}js`;
91
+ if (typescript && rel.endsWith('.ts')) return `${rel.slice(0, -2)}js`;
92
+ return rel;
93
+ }
76
94
  const transformPromises = [];
77
95
  const failedFiles = new Set();
78
96
  const pendingExportWipes = new Map();
79
97
  const exportWipeGraceMs = 5000;
98
+ // A source goes through the client pipeline, the raw one, both, or neither - see
99
+ // refreshSelections() below for what decides that
80
100
  async function transformFile(file) {
81
101
  //if (options.quiet !== true) console.log('transforming file', file)
102
+ const client = isClient(file);
103
+ const raw = isRaw(file);
104
+ if (!client && !raw) return;
82
105
  try {
83
- let rel = file.slice(codeLocationLength);
84
- if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
85
- const dest = join(buildCodeLocation, rel);
86
106
  // tsc's own watch/incremental emit can leave this file genuinely blank for a
87
107
  // stretch while it recomputes - not a write-in-progress chokidar's
88
108
  // awaitWriteFinish can wait out, but a real (if temporary) empty file on disk.
@@ -93,64 +113,15 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
93
113
  failedFiles.delete(file);
94
114
  return;
95
115
  }
96
- // Sync, so this can be tallied exactly - nothing else runs during it. Babel's work is
97
- // cpu-bound on one thread either way, so the async API's 291 concurrent calls bought
98
- // no parallelism, only scheduling. The plugins defer their async work into
99
- // opts.promises rather than awaiting in a visitor, which is what makes sync viable.
100
- const babelStart = performance.now();
101
- const result = babelTransformFileSync(file, config);
102
- tally('babel transform', performance.now() - babelStart);
103
- if (result === null) throw new TungstenError(`Err: babel transform on file ${file} returned null`);
104
- const {
105
- code
106
- } = result;
107
- if (code === null || code === undefined) {
108
- throw new TungstenError(`Err: code from babel transform on file ${file} was null or undefined: ${typeof code}`);
109
- }
110
- // tsc's incremental watch can, for one transient pass right after a save, emit
111
- // `export {};` for a file that previously had real exports - its own convention
112
- // for "this module has nothing to export", produced here as a self-correcting
113
- // glitch rather than a real edit (confirmed via tsc's own transient
114
- // "has no exported member" watch error). Quarantine it behind a timer rather than
115
- // overwrite the last-good compiled output immediately: tsc's follow-up pass moments
116
- // later normally retriggers this watcher with the real content, cancelling the
117
- // quarantine below. But if nothing ever corrects it (a genuine edit really does
118
- // remove every export), accept the quarantined content once the grace period lapses
119
- // instead of hiding it forever.
120
- if (code.trim() === 'export {};' && fs.existsSync(dest)) {
121
- const previousCode = fs.readFileSync(dest, 'utf8');
122
- if (previousCode.trim() !== 'export {};' && previousCode.trim() !== '') {
123
- if (!pendingExportWipes.has(file)) {
124
- const timer = setTimeout(() => {
125
- void acceptQuarantinedExportWipe(file);
126
- }, exportWipeGraceMs);
127
- pendingExportWipes.set(file, {
128
- dest,
129
- code,
130
- timer
131
- });
132
- } else {
133
- // keep the original timer (grace period counts from the first sighting),
134
- // just refresh the content that'll be written if it elapses
135
- const pending = pendingExportWipes.get(file);
136
- if (pending !== undefined) pending.code = code;
137
- }
138
- failedFiles.delete(file);
139
- return;
140
- }
116
+ // each transform runs synchronously up to its write, so both are in flight together
117
+ const writes = [];
118
+ if (client) {
119
+ writes.push(transformTo(file, sourceContent, config, join(buildCodeLocation, outputRel(file)), 'babel transform', true));
141
120
  }
142
- // real content arrived - cancel any quarantine still pending for this file
143
- const pendingWipe = pendingExportWipes.get(file);
144
- if (pendingWipe !== undefined) {
145
- clearTimeout(pendingWipe.timer);
146
- pendingExportWipes.delete(file);
121
+ if (raw) {
122
+ writes.push(transformTo(file, sourceContent, rawConfig, join(rawBuildLocation, outputRel(file)), 'babel transform (raw)', false));
147
123
  }
148
- await fsPromises.mkdir(dirname(dest), {
149
- recursive: true
150
- });
151
- //// Using the sync version here, because the promise version keeps bugging out - node bug?
152
- //await fsPromises.writeFile(dest, code)
153
- fs.writeFileSync(dest, code);
124
+ await Promise.all(writes);
154
125
  failedFiles.delete(file);
155
126
  } catch (e) {
156
127
  failedFiles.add(file);
@@ -159,28 +130,92 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
159
130
  throw e;
160
131
  }
161
132
  }
133
+ // One pipeline's transform and write. The transform is sync, so it can be tallied exactly -
134
+ // nothing else runs during it. Babel's work is cpu-bound on one thread either way, so the async
135
+ // API's 291 concurrent calls bought no parallelism, only scheduling. The plugins defer their
136
+ // async work into opts.promises rather than awaiting in a visitor, which is what makes sync
137
+ // viable. Async so the client and raw writes of one file could overlap; see the write below.
138
+ async function transformTo(file, sourceContent, babelConfig, dest, tallyName, guardExportWipe) {
139
+ // the content already read above: transformFileSync would read the file a second time
140
+ const result = tallied(tallyName, () => babelTransformSync(sourceContent, {
141
+ ...babelConfig,
142
+ filename: file
143
+ }));
144
+ if (result === null) throw new TungstenError(`Err: babel transform on file ${file} returned null`);
145
+ const {
146
+ code
147
+ } = result;
148
+ if (code === null || code === undefined) {
149
+ throw new TungstenError(`Err: code from babel transform on file ${file} was null or undefined: ${typeof code}`);
150
+ }
151
+ // tsc's incremental watch can, for one transient pass right after a save, emit
152
+ // `export {};` for a file that previously had real exports - its own convention
153
+ // for "this module has nothing to export", produced here as a self-correcting
154
+ // glitch rather than a real edit (confirmed via tsc's own transient
155
+ // "has no exported member" watch error). Quarantine it behind a timer rather than
156
+ // overwrite the last-good compiled output immediately: tsc's follow-up pass moments
157
+ // later normally retriggers this watcher with the real content, cancelling the
158
+ // quarantine below. But if nothing ever corrects it (a genuine edit really does
159
+ // remove every export), accept the quarantined content once the grace period lapses
160
+ // instead of hiding it forever. The client tree's guard only - the raw tree is not served.
161
+ if (guardExportWipe && code.trim() === 'export {};' && fs.existsSync(dest)) {
162
+ const previousCode = fs.readFileSync(dest, 'utf8');
163
+ if (previousCode.trim() !== 'export {};' && previousCode.trim() !== '') {
164
+ if (!pendingExportWipes.has(file)) {
165
+ const timer = setTimeout(() => {
166
+ void acceptQuarantinedExportWipe(file);
167
+ }, exportWipeGraceMs);
168
+ pendingExportWipes.set(file, {
169
+ dest,
170
+ code,
171
+ timer
172
+ });
173
+ } else {
174
+ // keep the original timer (grace period counts from the first sighting),
175
+ // just refresh the content that'll be written if it elapses
176
+ const pending = pendingExportWipes.get(file);
177
+ if (pending !== undefined) pending.code = code;
178
+ }
179
+ return;
180
+ }
181
+ }
182
+ // real content arrived - cancel any quarantine still pending for this file
183
+ if (guardExportWipe) {
184
+ const pendingWipe = pendingExportWipes.get(file);
185
+ if (pendingWipe !== undefined) {
186
+ clearTimeout(pendingWipe.timer);
187
+ pendingExportWipes.delete(file);
188
+ }
189
+ }
190
+ // Sync on purpose (measured 2026-09, qtc-2, 202 files, phase time minus babel's): sync
191
+ // ~400ms, fsPromises mkdir + writeFile ~520ms, memoising the mkdir no better. Babel saturates
192
+ // the main thread so completions only queue, and the promise api's open/write/close costs
193
+ // more there than a 1.5ms blocking write. Long ago the promise version also misbehaved.
194
+ fs.mkdirSync(dirname(dest), {
195
+ recursive: true
196
+ });
197
+ fs.writeFileSync(dest, code);
198
+ }
162
199
  async function deleteTransformedFile(file) {
163
- let rel = file.slice(codeLocationLength);
164
- if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
165
- const dest = join(buildCodeLocation, rel);
166
200
  const pendingWipe = pendingExportWipes.get(file);
167
201
  if (pendingWipe !== undefined) {
168
202
  clearTimeout(pendingWipe.timer);
169
203
  pendingExportWipes.delete(file);
170
204
  }
171
- try {
172
- await fsPromises.unlink(dest);
173
- } catch (error) {
174
- const fileError = error;
175
- if (fileError.code !== 'ENOENT') throw error;
205
+ // whichever trees hold it
206
+ for (const dest of [join(buildCodeLocation, outputRel(file)), join(rawBuildLocation, outputRel(file))]) {
207
+ try {
208
+ await fsPromises.unlink(dest);
209
+ } catch (error) {
210
+ const fileError = error;
211
+ if (fileError.code !== 'ENOENT') throw error;
212
+ }
176
213
  }
177
214
  failedFiles.delete(file);
178
215
  }
179
216
  async function copyFile(file) {
180
217
  try {
181
- let rel = file.slice(codeLocationLength);
182
- if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
183
- const dest = join(buildCodeLocation, rel);
218
+ const dest = join(buildCodeLocation, outputRel(file));
184
219
  await fsPromises.mkdir(dirname(dest), {
185
220
  recursive: true
186
221
  });
@@ -194,9 +229,7 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
194
229
  }
195
230
  async function deleteFile(file) {
196
231
  try {
197
- let rel = file.slice(codeLocationLength);
198
- if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
199
- const dest = join(buildCodeLocation, rel);
232
+ const dest = join(buildCodeLocation, outputRel(file));
200
233
  await fsPromises.unlink(dest);
201
234
  } catch (e) {
202
235
  cliError(`Tungsten: Error deleting file ${file}`);
@@ -205,22 +238,26 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
205
238
  }
206
239
  }
207
240
  // get a list of files
208
- const watchGlob = slash(`${codeLocation}/**/*.js{,x}`);
241
+ const watchGlob = slash(`${codeLocation}/**/*.{js,jsx${typescript ? ',ts,tsx' : ''}}`);
209
242
  // typed rather than inferred from the pushes: it is captured by a closure below, which stops
210
243
  // typescript widening it from the pushes
211
244
  const ignored = [];
212
245
  ignored.push(slash(`${buildLocation}/**`));
246
+ if (typescript) ignored.push(slash(`${codeLocation}/**/*.d.ts`));
213
247
  if (appConfig.ignoreDirs !== undefined && appConfig.ignoreDirs !== '') {
214
248
  const ignoreDirs = typeof appConfig.ignoreDirs === 'string' ? [appConfig.ignoreDirs] : appConfig.ignoreDirs;
215
249
  ignored.push(...ignoreDirs.map(folder => slash(`${codeLocation}/${folder}/**`)));
216
250
  }
251
+ // patterns are relative to the code dir, like the dirs above and the selections below; raw they
252
+ // resolved against the cwd, so `client/testing/**` never matched <code>/client/testing/…
253
+ const fromCodeDir = pattern => isAbsolute(pattern) ? slash(pattern) : slash(`${codeLocation}/${pattern}`);
217
254
  if (appConfig.ignorePatterns !== undefined && appConfig.ignorePatterns !== '') {
218
255
  if (Array.isArray(appConfig.ignorePatterns)) {
219
256
  for (const pattern of appConfig.ignorePatterns) {
220
- ignored.push(pattern);
257
+ ignored.push(fromCodeDir(pattern));
221
258
  }
222
259
  } else {
223
- ignored.push(appConfig.ignorePatterns);
260
+ ignored.push(fromCodeDir(appConfig.ignorePatterns));
224
261
  }
225
262
  }
226
263
  // test files are a category, not noise: excluded here like ignoreDirs/ignorePatterns, but a
@@ -231,10 +268,39 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
231
268
  ignored.push(...testDirs.map(folder => slash(`${codeLocation}/${folder}/**`)));
232
269
  }
233
270
  if (appConfig.testPatterns !== undefined && appConfig.testPatterns !== '') {
234
- ignored.push(...(Array.isArray(appConfig.testPatterns) ? appConfig.testPatterns : [appConfig.testPatterns]));
271
+ const testPatterns = Array.isArray(appConfig.testPatterns) ? appConfig.testPatterns : [appConfig.testPatterns];
272
+ ignored.push(...testPatterns.map(fromCodeDir));
235
273
  }
236
274
  }
237
275
  if (appConfig.exclude !== undefined) ignored.push(slash(`${codeLocation}/${appConfig.exclude}`));
276
+ // Which sources each pipeline compiles. Unset, client is everything and raw is nothing; a file
277
+ // may be in both. Dirs and patterns are relative to codeDir. The ignores are not applied
278
+ // here - every file that reaches isClient/isRaw has already passed them, in the initial glob
279
+ // or in the watcher - so "client minus ignores" holds. Sets rather than matchers, refreshed on
280
+ // the watcher's `add`, like skipPackageCompilationFiles.
281
+ const sourceExtensions = `*.{js,jsx${typescript ? ',ts,tsx' : ''}}`;
282
+ function selectionGlobs(dirs, patterns) {
283
+ if (dirs === undefined && patterns === undefined) return null;
284
+ const list = value => value === undefined || value === '' ? [] : typeof value === 'string' ? [value] : value;
285
+ return [...list(dirs).map(dir => `${dir}/**/${sourceExtensions}`), ...list(patterns)];
286
+ }
287
+ const clientSelection = selectionGlobs(appConfig.clientDirs, appConfig.clientPatterns);
288
+ const rawSelection = selectionGlobs(appConfig.rawDirs, appConfig.rawPatterns);
289
+ let clientFiles = null;
290
+ let rawFiles = new Set();
291
+ async function selectedFiles(selection) {
292
+ const files = await glob(selection, {
293
+ cwd: codeLocation
294
+ });
295
+ return new Set(files.map(file => slash(file)));
296
+ }
297
+ async function refreshSelections() {
298
+ clientFiles = clientSelection === null ? null : await selectedFiles(clientSelection);
299
+ rawFiles = rawSelection === null ? new Set() : await selectedFiles(rawSelection);
300
+ }
301
+ const isClient = file => clientFiles === null || clientFiles.has(file);
302
+ const isRaw = file => rawFiles.has(file);
303
+ await refreshSelections();
238
304
  //console.log('appConfig', appConfig)
239
305
  //console.log('ignored', ignored)
240
306
  //cliWarn(watchGlob)
@@ -245,7 +311,7 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
245
311
  // phases record into the profiler module's shared timeline, so this instance need not be the
246
312
  // one the command created - it only has to be enabled when --profile is
247
313
  const profiler = createTimeProfiler(isProfiling());
248
- const paths = await profiler.timeProfileAsync('find source files', () => globby([watchGlob, ...ignored.map(x => `!${x}`)]));
314
+ const paths = await profiler.timeProfileAsync('find source files', () => glob([watchGlob, ...ignored.map(x => `!${x}`)]));
249
315
  // the transforms are started inside the phase, not just awaited there: a resource is charged to
250
316
  // the phase that created it, so starting them outside credits all the work to the parent
251
317
  const transformResults = await profiler.timeProfileAsync(`transform ${paths.length} files`, () => {
@@ -276,7 +342,7 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
276
342
  recursive: true
277
343
  });
278
344
  }
279
- fs.writeFileSync(dependencyGraphLocation, `export const graph = ${serializeJavascript(dependencyGraph)}`);
345
+ fs.writeFileSync(dependencyGraphLocation, `export const version = ${serializeJavascript(frameworkVersion)}\n` + `export const graph = ${serializeJavascript(dependencyGraph)}`);
280
346
  }
281
347
  async function acceptQuarantinedExportWipe(file) {
282
348
  const pending = pendingExportWipes.get(file);
@@ -287,7 +353,7 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
287
353
  await fsPromises.mkdir(dirname(pending.dest), {
288
354
  recursive: true
289
355
  });
290
- fs.writeFileSync(pending.dest, pending.code);
356
+ await fsPromises.writeFile(pending.dest, pending.code);
291
357
  failedFiles.delete(file);
292
358
  const failures = await settleDeferredWork();
293
359
  success = failures.length === 0 && failedFiles.size === 0;
@@ -299,7 +365,8 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
299
365
  }
300
366
  await options.onCycleComplete?.({
301
367
  success,
302
- file
368
+ file,
369
+ client: true
303
370
  });
304
371
  }
305
372
  if (!watch) {
@@ -337,7 +404,10 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
337
404
  if (event === 'unlink') {
338
405
  await deleteTransformedFile(file);
339
406
  } else {
340
- if (event === 'add') await refreshSkipPackageCompilationFiles();
407
+ if (event === 'add') {
408
+ await refreshSkipPackageCompilationFiles();
409
+ await refreshSelections();
410
+ }
341
411
  await transformFile(file);
342
412
  }
343
413
  const failures = await settleDeferredWork();
@@ -348,7 +418,8 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
348
418
  }
349
419
  await options.onCycleComplete?.({
350
420
  success,
351
- file
421
+ file,
422
+ client: isClient(file)
352
423
  });
353
424
  }).catch(error => {
354
425
  cliError('Tungsten: Error completing JavaScript watch cycle');