tungsten 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/dist/.build-complete +1 -0
  2. package/dist/Framework.d.ts +2 -0
  3. package/dist/Framework.d.ts.map +1 -1
  4. package/dist/Framework.js +68 -57
  5. package/dist/FrameworkConfig.d.ts +2 -0
  6. package/dist/FrameworkConfig.d.ts.map +1 -1
  7. package/dist/Instance/Instance.d.ts.map +1 -1
  8. package/dist/Instance/Instance.js +18 -1
  9. package/dist/Instance/InstanceConfig.d.ts +1 -0
  10. package/dist/Instance/InstanceConfig.d.ts.map +1 -1
  11. package/dist/PopMessage.type.d.ts +6 -0
  12. package/dist/PopMessage.type.d.ts.map +1 -0
  13. package/dist/PopMessage.type.js +1 -0
  14. package/dist/Servers/DevServer.d.ts +2 -0
  15. package/dist/Servers/DevServer.d.ts.map +1 -1
  16. package/dist/Servers/DevServer.js +84 -8
  17. package/dist/Servers/MatchedRouteInfo.d.ts +1 -1
  18. package/dist/Servers/MatchedRouteInfo.d.ts.map +1 -1
  19. package/dist/Servers/ProdServer.d.ts +1 -0
  20. package/dist/Servers/ProdServer.d.ts.map +1 -1
  21. package/dist/Servers/ProdServer.js +79 -5
  22. package/dist/Servers/hono/DevServerHono.js +25 -29
  23. package/dist/Servers/hono/ProdServerHono.js +49 -142
  24. package/dist/Servers/hono/TungstenServerHono.d.ts +1 -1
  25. package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -1
  26. package/dist/Servers/hono/TungstenServerHono.js +12 -29
  27. package/dist/Servers/routing.d.ts.map +1 -1
  28. package/dist/Servers/routing.js +10 -6
  29. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +0 -3
  30. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -1
  31. package/dist/Servers/tungstenCorePrivateEnvSchema.js +3 -3
  32. package/dist/Servers/tungstenCorePublicEnvSchema.d.ts +8 -0
  33. package/dist/Servers/tungstenCorePublicEnvSchema.d.ts.map +1 -0
  34. package/dist/Servers/tungstenCorePublicEnvSchema.js +14 -0
  35. package/dist/Store/InternalStoreSchema.d.ts +2 -0
  36. package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
  37. package/dist/Store/InternalStoreSchema.js +1 -0
  38. package/dist/api/Request.d.ts +1 -1
  39. package/dist/api/Request.d.ts.map +1 -1
  40. package/dist/api/Response.d.ts +1 -1
  41. package/dist/api/Response.d.ts.map +1 -1
  42. package/dist/babelPlugins/BabelTypes.d.ts +2 -2
  43. package/dist/babelPlugins/BabelTypes.d.ts.map +1 -1
  44. package/dist/babelPlugins/BabelTypes.js +0 -1
  45. package/dist/bin/commands/build.d.ts.map +1 -1
  46. package/dist/bin/commands/build.js +3 -0
  47. package/dist/bin/commands/dev.d.ts.map +1 -1
  48. package/dist/bin/commands/dev.js +15 -4
  49. package/dist/bin/commands/devmon.d.ts +2 -0
  50. package/dist/bin/commands/devmon.d.ts.map +1 -0
  51. package/dist/bin/commands/devmon.js +66 -0
  52. package/dist/bin/index.d.ts.map +1 -1
  53. package/dist/bin/index.js +6 -0
  54. package/dist/booleanAttributeValue.d.ts +21 -0
  55. package/dist/booleanAttributeValue.d.ts.map +1 -0
  56. package/dist/booleanAttributeValue.js +23 -0
  57. package/dist/build/compileJavascript.js +1 -1
  58. package/dist/build/compileUserApp.d.ts +2 -1
  59. package/dist/build/compileUserApp.d.ts.map +1 -1
  60. package/dist/build/compileUserApp.js +8 -7
  61. package/dist/build/createInstanceConfigFile.js +1 -1
  62. package/dist/compat/types.d.ts +1 -1
  63. package/dist/compat/types.d.ts.map +1 -1
  64. package/dist/components/PopMessages.d.ts +12 -0
  65. package/dist/components/PopMessages.d.ts.map +1 -0
  66. package/dist/components/PopMessages.js +45 -0
  67. package/dist/defaultConfig.d.ts +1 -0
  68. package/dist/defaultConfig.d.ts.map +1 -1
  69. package/dist/defaultConfig.js +2 -1
  70. package/dist/env/Interfaces.d.ts +2 -1
  71. package/dist/env/Interfaces.d.ts.map +1 -1
  72. package/dist/env/getEnvSchemas.d.ts +1 -1
  73. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  74. package/dist/env/publicEnv.d.ts.map +1 -1
  75. package/dist/env/publicEnv.js +4 -1
  76. package/dist/frameworkConfigSchema.d.ts +4 -0
  77. package/dist/frameworkConfigSchema.d.ts.map +1 -1
  78. package/dist/frameworkConfigSchema.js +2 -1
  79. package/dist/hooks/index.d.ts +1 -0
  80. package/dist/hooks/index.d.ts.map +1 -1
  81. package/dist/hooks/index.js +1 -0
  82. package/dist/hooks/useInstance.d.ts +3 -0
  83. package/dist/hooks/useInstance.d.ts.map +1 -0
  84. package/dist/hooks/useInstance.js +4 -0
  85. package/dist/hydrate/hydrate.d.ts +6 -4
  86. package/dist/hydrate/hydrate.d.ts.map +1 -1
  87. package/dist/hydrate/hydrate.js +51 -13
  88. package/dist/hydrate/reconcileHydratedAttributes.d.ts.map +1 -1
  89. package/dist/hydrate/reconcileHydratedAttributes.js +4 -3
  90. package/dist/hydrate/renderHydrationMismatchBanner.d.ts +7 -0
  91. package/dist/hydrate/renderHydrationMismatchBanner.d.ts.map +1 -0
  92. package/dist/hydrate/renderHydrationMismatchBanner.js +69 -0
  93. package/dist/indexInner.d.ts +8 -0
  94. package/dist/indexInner.d.ts.map +1 -1
  95. package/dist/indexInner.js +7 -1
  96. package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -1
  97. package/dist/makeInstanceConfigFromFrameworkConfig.js +2 -1
  98. package/dist/pop.d.ts +10 -0
  99. package/dist/pop.d.ts.map +1 -0
  100. package/dist/pop.js +49 -0
  101. package/dist/rawHtml/filterContentNode.d.ts +20 -0
  102. package/dist/rawHtml/filterContentNode.d.ts.map +1 -0
  103. package/dist/rawHtml/filterContentNode.js +96 -0
  104. package/dist/rawHtml/parseHtml.d.ts +14 -0
  105. package/dist/rawHtml/parseHtml.d.ts.map +1 -1
  106. package/dist/rawHtml/parseHtml.js +4 -4
  107. package/dist/rawHtml/sanitizeHtml.d.ts +17 -0
  108. package/dist/rawHtml/sanitizeHtml.d.ts.map +1 -0
  109. package/dist/rawHtml/sanitizeHtml.js +19 -0
  110. package/dist/render/HeadData.d.ts +1 -0
  111. package/dist/render/HeadData.d.ts.map +1 -1
  112. package/dist/render/contentNodeToHtml.d.ts +18 -0
  113. package/dist/render/contentNodeToHtml.d.ts.map +1 -0
  114. package/dist/render/contentNodeToHtml.js +66 -0
  115. package/dist/render/contentToHtml.d.ts.map +1 -1
  116. package/dist/render/contentToHtml.js +2 -1
  117. package/dist/render/processHead.d.ts.map +1 -1
  118. package/dist/render/processHead.js +8 -2
  119. package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
  120. package/dist/render/renderingTreeToHtml.js +8 -1
  121. package/dist/routing/ErrorRouteType.d.ts +6 -0
  122. package/dist/routing/ErrorRouteType.d.ts.map +1 -0
  123. package/dist/routing/ErrorRouteType.js +1 -0
  124. package/dist/routing/RouteTypes.d.ts +2 -1
  125. package/dist/routing/RouteTypes.d.ts.map +1 -1
  126. package/dist/routing/Routes.d.ts +5 -0
  127. package/dist/routing/Routes.d.ts.map +1 -1
  128. package/dist/routing/TungstenErrorInfo.d.ts +6 -0
  129. package/dist/routing/TungstenErrorInfo.d.ts.map +1 -0
  130. package/dist/routing/TungstenErrorInfo.js +6 -0
  131. package/dist/style/styleContentSxy.js +21 -0
  132. package/dist/testing/hydrateTestApp.d.ts +38 -0
  133. package/dist/testing/hydrateTestApp.d.ts.map +1 -0
  134. package/dist/testing/hydrateTestApp.js +242 -0
  135. package/dist/testing/index.d.ts +4 -3
  136. package/dist/testing/index.d.ts.map +1 -1
  137. package/dist/testing/index.js +16 -2
  138. package/dist/timeProfiler.d.ts +6 -0
  139. package/dist/timeProfiler.d.ts.map +1 -0
  140. package/dist/timeProfiler.js +31 -0
  141. package/dist/update/integrateUpdateVdom.d.ts +11 -0
  142. package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
  143. package/dist/update/integrateUpdateVdom.js +9 -3
  144. package/dist/warnOnFrameworkChange.d.ts.map +1 -1
  145. package/dist/warnOnFrameworkChange.js +8 -8
  146. package/package.json +18 -16
  147. package/dist/FunctionComponentStandIn.sxyt.d.ts +0 -2
  148. package/dist/FunctionComponentStandIn.sxyt.d.ts.map +0 -1
  149. package/dist/FunctionComponentStandIn.sxyt.js +0 -52
  150. package/dist/Instance/gotoRedirect.sxyt.d.ts +0 -2
  151. package/dist/Instance/gotoRedirect.sxyt.d.ts.map +0 -1
  152. package/dist/Instance/gotoRedirect.sxyt.js +0 -148
  153. package/dist/Instance/runTrackedWork.sxyt.d.ts +0 -2
  154. package/dist/Instance/runTrackedWork.sxyt.d.ts.map +0 -1
  155. package/dist/Instance/runTrackedWork.sxyt.js +0 -35
  156. package/dist/Servers/devErrorPageAutoRetry.sxyt.d.ts +0 -2
  157. package/dist/Servers/devErrorPageAutoRetry.sxyt.d.ts.map +0 -1
  158. package/dist/Servers/devErrorPageAutoRetry.sxyt.js +0 -117
  159. package/dist/_client/cjsHelpers.sxyt.d.ts +0 -2
  160. package/dist/_client/cjsHelpers.sxyt.d.ts.map +0 -1
  161. package/dist/_client/cjsHelpers.sxyt.js +0 -45
  162. package/dist/auth/passwordHashing.sxyt.d.ts +0 -2
  163. package/dist/auth/passwordHashing.sxyt.d.ts.map +0 -1
  164. package/dist/auth/passwordHashing.sxyt.js +0 -46
  165. package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts +0 -2
  166. package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts.map +0 -1
  167. package/dist/auth/ref/checkPasswordResetToken.sxyt.js +0 -40
  168. package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts +0 -2
  169. package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts.map +0 -1
  170. package/dist/auth/ref/createPasswordResetToken.sxyt.js +0 -10
  171. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.d.ts +0 -2
  172. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.d.ts.map +0 -1
  173. package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.js +0 -138
  174. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts +0 -2
  175. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts.map +0 -1
  176. package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.js +0 -108
  177. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts +0 -2
  178. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts.map +0 -1
  179. package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.js +0 -104
  180. package/dist/bin/commands/compile.sxyt.d.ts +0 -2
  181. package/dist/bin/commands/compile.sxyt.d.ts.map +0 -1
  182. package/dist/bin/commands/compile.sxyt.js +0 -255
  183. package/dist/build/modifySassImports.sxyt.d.ts +0 -2
  184. package/dist/build/modifySassImports.sxyt.d.ts.map +0 -1
  185. package/dist/build/modifySassImports.sxyt.js +0 -55
  186. package/dist/build/sassImportParser.sxyt.d.ts +0 -2
  187. package/dist/build/sassImportParser.sxyt.d.ts.map +0 -1
  188. package/dist/build/sassImportParser.sxyt.js +0 -110
  189. package/dist/build/scssImportParserChatgpt.sxyt.d.ts +0 -2
  190. package/dist/build/scssImportParserChatgpt.sxyt.d.ts.map +0 -1
  191. package/dist/build/scssImportParserChatgpt.sxyt.js +0 -120
  192. package/dist/clone.sxyt.d.ts +0 -2
  193. package/dist/clone.sxyt.d.ts.map +0 -1
  194. package/dist/clone.sxyt.js +0 -24
  195. package/dist/componentProxyHandlers.sxyt.d.ts +0 -2
  196. package/dist/componentProxyHandlers.sxyt.d.ts.map +0 -1
  197. package/dist/componentProxyHandlers.sxyt.js +0 -130
  198. package/dist/components/RawHtml.sxyt.d.ts +0 -2
  199. package/dist/components/RawHtml.sxyt.d.ts.map +0 -1
  200. package/dist/components/RawHtml.sxyt.js +0 -104
  201. package/dist/components/bindable/BindableSelect.sxyt.d.ts +0 -2
  202. package/dist/components/bindable/BindableSelect.sxyt.d.ts.map +0 -1
  203. package/dist/components/bindable/BindableSelect.sxyt.js +0 -186
  204. package/dist/env/injectEnv.sxyt.d.ts +0 -2
  205. package/dist/env/injectEnv.sxyt.d.ts.map +0 -1
  206. package/dist/env/injectEnv.sxyt.js +0 -20
  207. package/dist/env/parseEnv.sxyt.d.ts +0 -2
  208. package/dist/env/parseEnv.sxyt.d.ts.map +0 -1
  209. package/dist/env/parseEnv.sxyt.js +0 -11
  210. package/dist/findProjectDir.sxyt.d.ts +0 -2
  211. package/dist/findProjectDir.sxyt.d.ts.map +0 -1
  212. package/dist/findProjectDir.sxyt.js +0 -82
  213. package/dist/hmr/applyHmrModule.sxyt.d.ts +0 -2
  214. package/dist/hmr/applyHmrModule.sxyt.d.ts.map +0 -1
  215. package/dist/hmr/applyHmrModule.sxyt.js +0 -182
  216. package/dist/hmr/instanceRegistry.sxyt.d.ts +0 -2
  217. package/dist/hmr/instanceRegistry.sxyt.d.ts.map +0 -1
  218. package/dist/hmr/instanceRegistry.sxyt.js +0 -24
  219. package/dist/hmr/refreshStylesheets.sxyt.d.ts +0 -2
  220. package/dist/hmr/refreshStylesheets.sxyt.d.ts.map +0 -1
  221. package/dist/hmr/refreshStylesheets.sxyt.js +0 -46
  222. package/dist/hydrate/hydrate.sxyt.d.ts +0 -2
  223. package/dist/hydrate/hydrate.sxyt.d.ts.map +0 -1
  224. package/dist/hydrate/hydrate.sxyt.js +0 -302
  225. package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts +0 -2
  226. package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts.map +0 -1
  227. package/dist/hydrate/reconcileHydratedAttributes.sxyt.js +0 -190
  228. package/dist/importDevModuleWithRetry.sxyt.d.ts +0 -2
  229. package/dist/importDevModuleWithRetry.sxyt.d.ts.map +0 -1
  230. package/dist/importDevModuleWithRetry.sxyt.js +0 -104
  231. package/dist/innerHtmlFromProps.sxyt.d.ts +0 -2
  232. package/dist/innerHtmlFromProps.sxyt.d.ts.map +0 -1
  233. package/dist/innerHtmlFromProps.sxyt.js +0 -99
  234. package/dist/postcssPlugins/parseSelectors.sxyt.d.ts +0 -2
  235. package/dist/postcssPlugins/parseSelectors.sxyt.d.ts.map +0 -1
  236. package/dist/postcssPlugins/parseSelectors.sxyt.js +0 -62
  237. package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts +0 -2
  238. package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts.map +0 -1
  239. package/dist/postcssPlugins/parseSelectorsRich.sxyt.js +0 -155
  240. package/dist/rawHtml/parseHtml.sxyt.d.ts +0 -2
  241. package/dist/rawHtml/parseHtml.sxyt.d.ts.map +0 -1
  242. package/dist/rawHtml/parseHtml.sxyt.js +0 -239
  243. package/dist/render/getFunctionBodyAsString.sxyt.d.ts +0 -2
  244. package/dist/render/getFunctionBodyAsString.sxyt.d.ts.map +0 -1
  245. package/dist/render/getFunctionBodyAsString.sxyt.js +0 -37
  246. package/dist/render/processHead.sxyt.d.ts +0 -2
  247. package/dist/render/processHead.sxyt.d.ts.map +0 -1
  248. package/dist/render/processHead.sxyt.js +0 -93
  249. package/dist/render/processProps.sxyt.d.ts +0 -2
  250. package/dist/render/processProps.sxyt.d.ts.map +0 -1
  251. package/dist/render/processProps.sxyt.js +0 -90
  252. package/dist/routing/compareRequestToRegex.sxyt.d.ts +0 -2
  253. package/dist/routing/compareRequestToRegex.sxyt.d.ts.map +0 -1
  254. package/dist/routing/compareRequestToRegex.sxyt.js +0 -65
  255. package/dist/routing/getPathPriority.sxyt.d.ts +0 -2
  256. package/dist/routing/getPathPriority.sxyt.d.ts.map +0 -1
  257. package/dist/routing/getPathPriority.sxyt.js +0 -24
  258. package/dist/routing/matchPath.sxyt.d.ts +0 -2
  259. package/dist/routing/matchPath.sxyt.d.ts.map +0 -1
  260. package/dist/routing/matchPath.sxyt.js +0 -41
  261. package/dist/routing/patternToRegex.sxyt.d.ts +0 -2
  262. package/dist/routing/patternToRegex.sxyt.d.ts.map +0 -1
  263. package/dist/routing/patternToRegex.sxyt.js +0 -69
  264. package/dist/routing/splitRequest.sxyt.d.ts +0 -2
  265. package/dist/routing/splitRequest.sxyt.d.ts.map +0 -1
  266. package/dist/routing/splitRequest.sxyt.js +0 -47
  267. package/dist/style/jssToCss.sxyt.d.ts +0 -2
  268. package/dist/style/jssToCss.sxyt.d.ts.map +0 -1
  269. package/dist/style/jssToCss.sxyt.js +0 -17
  270. package/dist/testing/createTestApp.sxyt.d.ts +0 -2
  271. package/dist/testing/createTestApp.sxyt.d.ts.map +0 -1
  272. package/dist/testing/createTestApp.sxyt.js +0 -470
  273. package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts +0 -2
  274. package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts.map +0 -1
  275. package/dist/testing/ensureTestEnvLoaded.sxyt.js +0 -20
  276. package/dist/update/hotSwap.sxyt.d.ts +0 -2
  277. package/dist/update/hotSwap.sxyt.d.ts.map +0 -1
  278. package/dist/update/hotSwap.sxyt.js +0 -252
@@ -1,138 +0,0 @@
1
- import { expect } from 'chai';
2
- import { describe } from 'sxy-test-runner';
3
- import { transformSync } from '@babel/core';
4
- import { mkdir, mkdtemp, rm, writeFile, utimes } from 'fs/promises';
5
- import { statSync, readFileSync } from 'fs';
6
- import { tmpdir } from 'os';
7
- import { join } from 'path';
8
- import { MakeBabelAddDevCacheBust } from "./BabelAddDevCacheBust.js";
9
- async function makeFixture() {
10
- const dir = await mkdtemp(join(tmpdir(), 'tungsten-add-dev-cache-bust-'));
11
- const components = join(dir, 'components');
12
- const pages = join(dir, 'pages');
13
- await mkdir(components, {
14
- recursive: true
15
- });
16
- await mkdir(pages, {
17
- recursive: true
18
- });
19
- const buttonPath = join(components, 'Button.jsx');
20
- await writeFile(buttonPath, `export function Button() { return null }\n`);
21
- const homePath = join(pages, 'Home.jsx');
22
- await writeFile(homePath, `import { Button } from '../components/Button.jsx'\nexport const x = Button\n`);
23
- return {
24
- dir,
25
- buttonPath,
26
- homePath,
27
- components,
28
- pages
29
- };
30
- }
31
- function transform(filename) {
32
- const result = transformSync(readFileSync(filename, 'utf8'), {
33
- filename,
34
- babelrc: false,
35
- configFile: false,
36
- plugins: [MakeBabelAddDevCacheBust()]
37
- });
38
- if (result === null || typeof result.code !== 'string') throw new Error('babel transform returned no code');
39
- return result.code;
40
- }
41
- describe('BabelAddDevCacheBust', ({
42
- it
43
- }) => {
44
- it(`appends the imported file's on-disk mtime as a '?v=' query to a relative import`, async () => {
45
- const {
46
- dir,
47
- buttonPath,
48
- homePath
49
- } = await makeFixture();
50
- try {
51
- const code = transform(homePath);
52
- const mtimeMs = statSync(buttonPath).mtimeMs;
53
- expect(code).to.contain(`../components/Button.jsx?v=${mtimeMs}`);
54
- } finally {
55
- await rm(dir, {
56
- recursive: true,
57
- force: true
58
- });
59
- }
60
- });
61
- it(`produces a different '?v=' value once the imported file is edited - so a fresh dependent refetch resolves a URL the browser has never cached`, async () => {
62
- const {
63
- dir,
64
- buttonPath,
65
- homePath
66
- } = await makeFixture();
67
- try {
68
- const before = transform(homePath);
69
- const beforeMatch = before.match(/\?v=([0-9.]+)["']/);
70
- expect(beforeMatch).to.not.equal(null);
71
- // simulate the developer editing Button.jsx a moment later
72
- const future = new Date(Date.now() + 5000);
73
- await utimes(buttonPath, future, future);
74
- const after = transform(homePath);
75
- const afterMatch = after.match(/\?v=([0-9.]+)["']/);
76
- expect(afterMatch).to.not.equal(null);
77
- expect(afterMatch[1]).to.not.equal(beforeMatch[1]);
78
- } finally {
79
- await rm(dir, {
80
- recursive: true,
81
- force: true
82
- });
83
- }
84
- });
85
- it(`resolves correctly even when the specifier's extension has already been rewritten from .jsx to .js by an earlier plugin`, async () => {
86
- const {
87
- dir,
88
- buttonPath,
89
- pages
90
- } = await makeFixture();
91
- try {
92
- const homeAlreadyJsPath = join(pages, 'HomeAlreadyJs.jsx');
93
- await writeFile(homeAlreadyJsPath, `import { Button } from '../components/Button.js'\nexport const x = Button\n`);
94
- const code = transform(homeAlreadyJsPath);
95
- const mtimeMs = statSync(buttonPath).mtimeMs;
96
- expect(code).to.contain(`../components/Button.js?v=${mtimeMs}`);
97
- } finally {
98
- await rm(dir, {
99
- recursive: true,
100
- force: true
101
- });
102
- }
103
- });
104
- it(`leaves a bare (package) import untouched`, async () => {
105
- const {
106
- dir,
107
- homePath
108
- } = await makeFixture();
109
- try {
110
- await writeFile(homePath, `import { StatefulComponent } from 'tungsten'\nexport const x = StatefulComponent\n`);
111
- const code = transform(homePath);
112
- expect(code).to.contain(`tungsten`);
113
- expect(code).to.not.contain(`?v=`);
114
- } finally {
115
- await rm(dir, {
116
- recursive: true,
117
- force: true
118
- });
119
- }
120
- });
121
- it(`leaves a relative import untouched when the target file cannot be found on disk`, async () => {
122
- const {
123
- dir,
124
- homePath
125
- } = await makeFixture();
126
- try {
127
- await writeFile(homePath, `import { Ghost } from '../components/Ghost.jsx'\nexport const x = Ghost\n`);
128
- const code = transform(homePath);
129
- expect(code).to.contain(`../components/Ghost.jsx`);
130
- expect(code).to.not.contain(`?v=`);
131
- } finally {
132
- await rm(dir, {
133
- recursive: true,
134
- force: true
135
- });
136
- }
137
- });
138
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=fixImportsInSassErrorMessage.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixImportsInSassErrorMessage.sxyt.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/fixImportsInSassErrorMessage.sxyt.ts"],"names":[],"mappings":""}
@@ -1,108 +0,0 @@
1
- import { describe } from 'sxy-test-runner';
2
- // TODO: add control chars to our tests
3
- // https://stackoverflow.com/questions/10170142/how-to-send-control-char-using-strict-mode-in-javascript
4
- import { fixImportsInSassErrorMessage } from "./fixImportsInSassErrorMessage.js";
5
- describe('fixImportInSassErrorMessage()', ({
6
- it
7
- }) => {
8
- const input = `@import '../foo'`;
9
- const map = [{
10
- target: 'foo',
11
- start: 9,
12
- to: '../foo'
13
- }];
14
- it(`modifies sass import 'foo' into 'C:/project/styles/foo' in content '${input}'`, () => {
15
- const result = fixImportsInSassErrorMessage(input, map);
16
- //console.log(`result:`, result.message)
17
- result.message.should.equal(`@import 'foo'`);
18
- });
19
- const input2 = `
20
- @import '../foo'
21
- ^^^^^^^^^^^^^^^^
22
- `;
23
- const map2 = [{
24
- target: 'foo',
25
- start: 10,
26
- to: '../foo'
27
- }];
28
- it(`corrects marking chevrons too using '${input2}'`, () => {
29
- const result = fixImportsInSassErrorMessage(input2, map2);
30
- //console.log('result:', result.message)
31
- result.message.should.equal(`
32
- @import 'foo'
33
- ^^^^^^^^^^^^^
34
- `);
35
- });
36
- const input3 = `
37
- @import '../foo'; @import '../bar';
38
- ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
39
- `;
40
- const map3 = [{
41
- target: 'foo',
42
- start: 10,
43
- to: '../foo'
44
- }, {
45
- target: 'bar',
46
- start: 29,
47
- // might be wrong
48
- to: '../bar'
49
- }];
50
- it(`handles a complex scenario with 2 imports on the same line (SCSS syntax) '${input3}'`, () => {
51
- const result = fixImportsInSassErrorMessage(input3, map3);
52
- //console.log('result:', result.message)
53
- result.message.should.equal(`
54
- @import 'foo'; @import 'bar';
55
- ^^^^^^^^^^^^^ ^^^^^^^^^^^^^
56
- `);
57
- });
58
- const input4 = `
59
- @import '../foo'; @import '../bar'; @import '../foo'; @import '../bar';
60
- ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
61
- `;
62
- const map4 = [{
63
- target: 'foo',
64
- start: 10,
65
- to: '../foo'
66
- }, {
67
- target: 'bar',
68
- start: 29,
69
- // might be wrong
70
- to: '../bar'
71
- }];
72
- it(`handles case where error comes after an import without error on the same line using '${input4}'`, () => {
73
- const result = fixImportsInSassErrorMessage(input4, map4);
74
- //console.log('result:', result.message)
75
- result.message.should.equal(`
76
- @import 'foo'; @import 'bar'; @import 'foo'; @import 'bar';
77
- ^^^^^^^^^^^^^ ^^^^^^^^^^^^^
78
- `);
79
- });
80
- const input5 = `
81
- 3 │ @use '../style/mixins'; @use '../style/variablesss';
82
- │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
83
- `;
84
- const map5 = [{
85
- target: 'mixins',
86
- start: 99,
87
- to: '../style/mixins'
88
- }, {
89
- target: 'variablesss',
90
- start: 99,
91
- // might be wrong
92
- to: '../style/variablesss'
93
- }];
94
- it(`handles this real world output '${input5}'`, () => {
95
- const result = fixImportsInSassErrorMessage(input5, map5);
96
- //console.log('result:', result.message)
97
- const expected = `
98
- 3 │ @use 'mixins'; @use 'variablesss';
99
- │ ^^^^^^^^^^^^^^^^^^
100
- `;
101
- //console.log('expect:', expected)
102
- //for (let i = 0; i <= 90; i++) {
103
- // console.log(i, result.message[i], expected[i])
104
- //}
105
- //console.log(result.message.length, expected.length)
106
- result.message.should.equal(expected);
107
- });
108
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=resolveBareImport.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveBareImport.sxyt.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/transformPackageImports/resolveBareImport.sxyt.ts"],"names":[],"mappings":""}
@@ -1,104 +0,0 @@
1
- import { expect } from 'chai';
2
- import { describe } from 'sxy-test-runner';
3
- import { mkdir, mkdtemp, rm, writeFile } from 'fs/promises';
4
- import { createRequire } from 'module';
5
- import { tmpdir } from 'os';
6
- import { join } from 'path';
7
- import { resolveBareImport } from "./resolveBareImport.js";
8
- async function makeFixture() {
9
- const dir = await mkdtemp(join(tmpdir(), 'tungsten-resolve-bare-import-'));
10
- const modules = join(dir, 'node_modules');
11
- const dual = join(modules, 'dual-package');
12
- await mkdir(dual, {
13
- recursive: true
14
- });
15
- await writeFile(join(dual, 'package.json'), JSON.stringify({
16
- name: 'dual-package',
17
- version: '1.0.0',
18
- exports: {
19
- '.': {
20
- import: './index.js',
21
- require: './index.cjs'
22
- }
23
- }
24
- }));
25
- await writeFile(join(dual, 'index.js'), 'export default 1');
26
- await writeFile(join(dual, 'index.cjs'), 'module.exports = 1');
27
- const cjsOnly = join(modules, 'cjs-package');
28
- await mkdir(cjsOnly, {
29
- recursive: true
30
- });
31
- await writeFile(join(cjsOnly, 'package.json'), JSON.stringify({
32
- name: 'cjs-package',
33
- version: '1.0.0',
34
- main: './main.js'
35
- }));
36
- await writeFile(join(cjsOnly, 'main.js'), 'module.exports = 1');
37
- return {
38
- dir,
39
- dual,
40
- cjsOnly
41
- };
42
- }
43
- describe('resolveBareImport()', ({
44
- it
45
- }) => {
46
- it(`takes the 'import' condition where require.resolve takes 'require'`, async () => {
47
- const {
48
- dir,
49
- dual
50
- } = await makeFixture();
51
- try {
52
- const require = createRequire(join(dir, '_'));
53
- expect(require.resolve('dual-package')).to.equal(join(dual, 'index.cjs'));
54
- expect(resolveBareImport('dual-package', [dir])).to.equal(join(dual, 'index.js'));
55
- } finally {
56
- await rm(dir, {
57
- recursive: true,
58
- force: true
59
- });
60
- }
61
- });
62
- it(`resolves a package that only has a legacy main`, async () => {
63
- const {
64
- dir,
65
- cjsOnly
66
- } = await makeFixture();
67
- try {
68
- expect(resolveBareImport('cjs-package', [dir])).to.equal(join(cjsOnly, 'main.js'));
69
- } finally {
70
- await rm(dir, {
71
- recursive: true,
72
- force: true
73
- });
74
- }
75
- });
76
- it(`returns undefined for a package it cannot resolve, so the caller can fall back`, async () => {
77
- const {
78
- dir
79
- } = await makeFixture();
80
- try {
81
- expect(resolveBareImport('not-installed', [dir])).to.equal(undefined);
82
- } finally {
83
- await rm(dir, {
84
- recursive: true,
85
- force: true
86
- });
87
- }
88
- });
89
- it(`tries each of the given directories in turn`, async () => {
90
- const {
91
- dir,
92
- dual
93
- } = await makeFixture();
94
- try {
95
- const missing = join(dir, 'no-such-dir');
96
- expect(resolveBareImport('dual-package', [missing, dir])).to.equal(join(dual, 'index.js'));
97
- } finally {
98
- await rm(dir, {
99
- recursive: true,
100
- force: true
101
- });
102
- }
103
- });
104
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=compile.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compile.sxyt.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/compile.sxyt.ts"],"names":[],"mappings":""}
@@ -1,255 +0,0 @@
1
- import { execFile } from 'child_process';
2
- import { mkdir, mkdtemp, readFile, rm, writeFile } from 'fs/promises';
3
- import { tmpdir } from 'os';
4
- import { join } from 'path';
5
- import { promisify } from 'util';
6
- import { expect } from 'chai';
7
- import { describe } from 'sxy-test-runner';
8
- import { findProjectDir } from "../../findProjectDir.js";
9
- const execFileAsync = promisify(execFile);
10
- describe('tungsten compile', ({
11
- it
12
- }) => {
13
- it('exits non-zero and does not report completion when Babel cannot transform a file', async () => {
14
- const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-test-'));
15
- const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
16
- try {
17
- await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
18
- await writeFile(join(projectDir, 'broken.jsx'), 'export const broken = <div>');
19
- let error;
20
- try {
21
- await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--quiet'], {
22
- cwd: projectDir
23
- });
24
- } catch (caught) {
25
- error = caught;
26
- }
27
- expect(error).not.to.equal(undefined);
28
- expect(error?.code).not.to.equal(0);
29
- expect(error?.stdout ?? '').not.to.contain('Compile complete');
30
- } finally {
31
- await rm(projectDir, {
32
- recursive: true,
33
- force: true
34
- });
35
- }
36
- });
37
- it('writes all JavaScript and readiness output beneath the selected locations', async () => {
38
- const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-output-test-'));
39
- const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
40
- try {
41
- await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
42
- await writeFile(join(projectDir, 'entry.jsx'), 'export const element = <div />');
43
- const {
44
- stdout
45
- } = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--ready-file', '.tungsten/test.ready', '--quiet'], {
46
- cwd: projectDir
47
- });
48
- const compiled = await readFile(join(projectDir, '.tungsten/test/code/entry.js'), 'utf8');
49
- const ready = JSON.parse(await readFile(join(projectDir, '.tungsten/test.ready'), 'utf8'));
50
- expect(stdout).to.contain('Compile complete');
51
- expect(compiled).to.contain('export const element');
52
- expect(ready.ready).to.equal(true);
53
- expect(ready.output).to.equal(join(projectDir, '.tungsten/test'));
54
- } finally {
55
- await rm(projectDir, {
56
- recursive: true,
57
- force: true
58
- });
59
- }
60
- });
61
- it('reports an unsupported node dependency once and continues compiling', async () => {
62
- const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-node-dependency-test-'));
63
- const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
64
- const packageDir = join(projectDir, 'node_modules', 'fixture-package');
65
- const sourceDir = join(projectDir, 'src');
66
- try {
67
- await mkdir(packageDir, {
68
- recursive: true
69
- });
70
- await mkdir(sourceDir, {
71
- recursive: true
72
- });
73
- await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
74
- await writeFile(join(projectDir, 'tungsten.config.js'), 'export default { codeDir: "src", useRootComponent: false }');
75
- await writeFile(join(sourceDir, 'entry.js'), 'import fixture from \'fixture-package\'; export { fixture }');
76
- await writeFile(join(packageDir, 'package.json'), '{"name":"fixture-package","version":"1.0.0","main":"index.js"}');
77
- await writeFile(join(packageDir, 'index.js'), 'module.exports = require(\'missing-native-module\')');
78
- const {
79
- stdout
80
- } = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
81
- cwd: projectDir
82
- });
83
- expect(stdout).to.contain('Your code that is compiled may depend on a node module - this is not allowed.');
84
- expect(stdout).to.contain('src/entry.js\n -> fixture-package/index.js\n -> missing-native-module (unresolved)');
85
- expect(stdout).not.to.contain('Require stack:');
86
- expect(stdout).not.to.contain('process file err');
87
- expect(stdout.split('Your code that is compiled may depend on a node module - this is not allowed.')).to.have.length(2);
88
- expect(stdout).to.contain('Compile complete');
89
- await readFile(join(projectDir, '.tungsten/test/code/entry.js'), 'utf8');
90
- } finally {
91
- await rm(projectDir, {
92
- recursive: true,
93
- force: true
94
- });
95
- }
96
- });
97
- it('takes the import build of a dual package for an import, and the require build for a require', async () => {
98
- const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-conditions-test-'));
99
- const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
100
- const sourceDir = join(projectDir, 'src');
101
- const dualDir = join(projectDir, 'node_modules', 'dual-package');
102
- const cjsDir = join(projectDir, 'node_modules', 'cjs-package');
103
- async function copiedToPackages(rel) {
104
- try {
105
- await readFile(join(projectDir, '.tungsten/test/.packages', rel), 'utf8');
106
- return true;
107
- } catch {
108
- return false;
109
- }
110
- }
111
- try {
112
- await mkdir(dualDir, {
113
- recursive: true
114
- });
115
- await mkdir(cjsDir, {
116
- recursive: true
117
- });
118
- await mkdir(sourceDir, {
119
- recursive: true
120
- });
121
- await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
122
- await writeFile(join(projectDir, 'tungsten.config.js'), 'export default { codeDir: "src", useRootComponent: false }');
123
- // ships both builds, as @trpc/server and zod do
124
- await writeFile(join(dualDir, 'package.json'), JSON.stringify({
125
- name: 'dual-package',
126
- version: '1.0.0',
127
- exports: {
128
- '.': {
129
- import: './index.mjs',
130
- require: './index.cjs'
131
- }
132
- }
133
- }));
134
- await writeFile(join(dualDir, 'index.mjs'), 'export const dual = "esm"');
135
- await writeFile(join(dualDir, 'index.cjs'), 'module.exports = { dual: "cjs" }');
136
- // a CJS package that require()s the dual package
137
- await writeFile(join(cjsDir, 'package.json'), JSON.stringify({
138
- name: 'cjs-package',
139
- version: '1.0.0',
140
- main: './index.js'
141
- }));
142
- await writeFile(join(cjsDir, 'index.js'), 'module.exports = require(\'dual-package\')');
143
- await writeFile(join(sourceDir, 'entry.js'), 'import { dual } from \'dual-package\'\n' + 'import viaCjs from \'cjs-package\'\n' + 'export { dual, viaCjs }');
144
- const {
145
- stdout
146
- } = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
147
- cwd: projectDir
148
- });
149
- expect(stdout).to.contain('Compile complete');
150
- // the ESM import took ./index.mjs
151
- expect(await copiedToPackages('dual-package@1.0.0/index.mjs')).to.equal(true);
152
- // and the require() inside the CJS package took ./index.cjs, so that the
153
- // converted require() shim can find it in its deps
154
- expect(await copiedToPackages('dual-package@1.0.0/index.cjs')).to.equal(true);
155
- } finally {
156
- await rm(projectDir, {
157
- recursive: true,
158
- force: true
159
- });
160
- }
161
- });
162
- it('overrides the ignoreDirs and ignorePatterns config entries from the command line', async () => {
163
- const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-ignore-test-'));
164
- const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
165
- const sourceDir = join(projectDir, 'src');
166
- async function compiled(rel) {
167
- try {
168
- await readFile(join(projectDir, '.tungsten/test/code', rel), 'utf8');
169
- return true;
170
- } catch {
171
- return false;
172
- }
173
- }
174
- try {
175
- await mkdir(join(sourceDir, 'server'), {
176
- recursive: true
177
- });
178
- await mkdir(join(sourceDir, 'tests'), {
179
- recursive: true
180
- });
181
- await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
182
- await writeFile(join(projectDir, 'tungsten.config.js'), 'export default {' + ' codeDir: "src",' + ' useRootComponent: false,' + ' ignoreDirs: "server",' + ' ignorePatterns: "**/*.domTest.js"' + ' }');
183
- await writeFile(join(sourceDir, 'entry.js'), 'export const entry = 1');
184
- await writeFile(join(sourceDir, 'server', 'api.js'), 'export const api = 1');
185
- await writeFile(join(sourceDir, 'tests', 'unit.js'), 'export const unit = 1');
186
- await writeFile(join(sourceDir, 'component.domTest.js'), 'export const domTest = 1');
187
- // the config entries alone - server/ and *.domTest.js are left out
188
- await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
189
- cwd: projectDir
190
- });
191
- expect(await compiled('entry.js')).to.equal(true);
192
- expect(await compiled('server/api.js')).to.equal(false);
193
- expect(await compiled('component.domTest.js')).to.equal(false);
194
- // blank values override both entries away, so everything is compiled
195
- await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet', '--ignore-dirs', '', '--ignore-patterns', ''], {
196
- cwd: projectDir
197
- });
198
- expect(await compiled('server/api.js')).to.equal(true);
199
- expect(await compiled('component.domTest.js')).to.equal(true);
200
- // repeating an option replaces the config entry with all of the given values
201
- await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet', '--ignore-dirs', 'tests', '--ignore-dirs', 'server'], {
202
- cwd: projectDir
203
- });
204
- expect(await compiled('entry.js')).to.equal(true);
205
- expect(await compiled('tests/unit.js')).to.equal(false);
206
- expect(await compiled('server/api.js')).to.equal(false);
207
- // ignorePatterns was not overridden, so it still applies
208
- expect(await compiled('component.domTest.js')).to.equal(false);
209
- } finally {
210
- await rm(projectDir, {
211
- recursive: true,
212
- force: true
213
- });
214
- }
215
- });
216
- it('skips package compilation for files selected by a JavaScript glob', async () => {
217
- const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-skip-package-compilation-test-'));
218
- const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
219
- const packageDir = join(projectDir, 'node_modules', 'fixture-package');
220
- const sourceDir = join(projectDir, 'src');
221
- try {
222
- await mkdir(packageDir, {
223
- recursive: true
224
- });
225
- await mkdir(sourceDir, {
226
- recursive: true
227
- });
228
- await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
229
- await writeFile(join(projectDir, 'tungsten.config.js'), 'export default {' + ' codeDir: "src",' + ' useRootComponent: false,' + ' skipPackageCompilation: "**/*.domTest.js"' + ' }');
230
- await writeFile(join(sourceDir, 'component.domTest.js'), "import fixture from 'fixture-package'; export { fixture }");
231
- await writeFile(join(packageDir, 'package.json'), '{"name":"fixture-package","version":"1.0.0","main":"index.js"}');
232
- await writeFile(join(packageDir, 'index.js'), 'module.exports = 1');
233
- const {
234
- stdout
235
- } = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
236
- cwd: projectDir
237
- });
238
- const compiled = await readFile(join(projectDir, '.tungsten/test/code/component.domTest.js'), 'utf8');
239
- expect(stdout).to.contain('Compile complete');
240
- expect(compiled).to.contain("from 'fixture-package'");
241
- let packageWasCopied = true;
242
- try {
243
- await readFile(join(projectDir, '.tungsten/test/.packages/fixture-package@1.0.0/index.js'), 'utf8');
244
- } catch {
245
- packageWasCopied = false;
246
- }
247
- expect(packageWasCopied).to.equal(false);
248
- } finally {
249
- await rm(projectDir, {
250
- recursive: true,
251
- force: true
252
- });
253
- }
254
- });
255
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=modifySassImports.sxyt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modifySassImports.sxyt.d.ts","sourceRoot":"","sources":["../../src/build/modifySassImports.sxyt.ts"],"names":[],"mappings":""}