tungsten 0.4.12 → 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 (245) 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/Components.d.ts.map +1 -1
  5. package/dist/Components.js +11 -8
  6. package/dist/DomPointer.js +1 -1
  7. package/dist/DomRegion.js +2 -2
  8. package/dist/Framework.js +1 -1
  9. package/dist/FrameworkConfig.d.ts.map +1 -1
  10. package/dist/Instance/Instance.js +1 -1
  11. package/dist/RenderedContentNode.d.ts.map +1 -1
  12. package/dist/RenderedContentNode.js +2 -1
  13. package/dist/Sass.d.ts.map +1 -1
  14. package/dist/Sass.js +1 -0
  15. package/dist/Servers/DevServer.d.ts.map +1 -1
  16. package/dist/Servers/DevServer.js +4 -3
  17. package/dist/Servers/ProdServer.js +1 -1
  18. package/dist/Servers/StaticSiteServer.js +1 -1
  19. package/dist/Servers/loadEnvsDev.d.ts +1 -1
  20. package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
  21. package/dist/Servers/loadEnvsDev.js +4 -2
  22. package/dist/Servers/routing.d.ts.map +1 -1
  23. package/dist/Servers/routing.js +1 -1
  24. package/dist/Store/Store.js +1 -1
  25. package/dist/Store/TypeSafeStore.js +1 -1
  26. package/dist/Store/makeStore.js +1 -1
  27. package/dist/Store/registerStore.js +1 -1
  28. package/dist/TElement.js +1 -1
  29. package/dist/TungstenApp.js +6 -2
  30. package/dist/api/getExport.d.ts.map +1 -1
  31. package/dist/api/getExport.js +1 -0
  32. package/dist/babelPlugins/BabelTransformBindDirect.js +2 -0
  33. package/dist/babelPlugins/BabelTransformBindVar.d.ts.map +1 -1
  34. package/dist/babelPlugins/BabelTransformComponentState.d.ts.map +1 -1
  35. package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
  36. package/dist/babelPlugins/BabelTransformComponentStyles.js +5 -4
  37. package/dist/babelPlugins/BabelTransformCssImports.d.ts.map +1 -1
  38. package/dist/babelPlugins/BabelTransformCssImports.js +2 -2
  39. package/dist/babelPlugins/BabelTransformDependencyImportsOld.js +1 -1
  40. package/dist/babelPlugins/BabelTransformDeproxyState.d.ts.map +1 -1
  41. package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
  42. package/dist/babelPlugins/BabelTransformPackageImports.js +10 -5
  43. package/dist/babelPlugins/BabelTransformRemoveBlocks.d.ts.map +1 -1
  44. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.d.ts.map +1 -1
  45. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.js +2 -1
  46. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.d.ts.map +1 -1
  47. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.js +2 -1
  48. package/dist/bin/args.js +1 -1
  49. package/dist/bin/commands/build.js +1 -1
  50. package/dist/bin/commands/compileSimplePackage.js +1 -0
  51. package/dist/bin/index.d.ts.map +1 -1
  52. package/dist/bin/index.js +11 -3
  53. package/dist/bin/vendorHook.d.ts +3 -0
  54. package/dist/bin/vendorHook.d.ts.map +1 -0
  55. package/dist/bin/vendorHook.js +34 -0
  56. package/dist/browserStorage.js +4 -2
  57. package/dist/build/babel.user.common.config.d.ts +2 -0
  58. package/dist/build/babel.user.common.config.d.ts.map +1 -1
  59. package/dist/build/babel.user.common.config.js +10 -4
  60. package/dist/build/compileJavascript.d.ts.map +1 -1
  61. package/dist/build/compileJavascript.js +40 -27
  62. package/dist/build/compileStyles.js +4 -4
  63. package/dist/build/copyAssets.js +3 -3
  64. package/dist/build/copyPublicFiles.js +3 -3
  65. package/dist/build/frameworkStylesheets.js +1 -1
  66. package/dist/build/getAllSxyClientModules.d.ts.map +1 -1
  67. package/dist/build/getAllSxyClientModules.js +4 -28
  68. package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
  69. package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
  70. package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
  71. package/dist/build/rollupExtractComponentStylesheets.js +1 -1
  72. package/dist/build/sassImportParser.js +2 -2
  73. package/dist/build/tallyBabel.d.ts +3 -0
  74. package/dist/build/tallyBabel.d.ts.map +1 -0
  75. package/dist/build/tallyBabel.js +11 -0
  76. package/dist/clone.js +4 -4
  77. package/dist/compat/context.d.ts.map +1 -1
  78. package/dist/compat/types.d.ts.map +1 -1
  79. package/dist/componentProxyHandlers.d.ts.map +1 -1
  80. package/dist/componentProxyHandlers.js +5 -9
  81. package/dist/components/Stylesheet.d.ts +1 -2
  82. package/dist/components/Stylesheet.d.ts.map +1 -1
  83. package/dist/components/Stylesheet.js +1 -1
  84. package/dist/components/bindable/BindableCheckbox.d.ts.map +1 -1
  85. package/dist/components/bindable/BindableInput.d.ts.map +1 -1
  86. package/dist/components/bindable/BindableInputTypedLegacy.d.ts.map +1 -1
  87. package/dist/components/bindable/BindableRadio.d.ts.map +1 -1
  88. package/dist/components/bindable/BindableTextarea.d.ts.map +1 -1
  89. package/dist/components/library/RichTextEditor/RichTextEditor.js +2 -2
  90. package/dist/components/library/RichTextEditor/contentTree.js +1 -1
  91. package/dist/concat.d.ts.map +1 -1
  92. package/dist/concat.js +2 -2
  93. package/dist/copy.d.ts.map +1 -1
  94. package/dist/createRoutes.d.ts +1 -1
  95. package/dist/createRoutes.d.ts.map +1 -1
  96. package/dist/env/Env.js +2 -2
  97. package/dist/env/getEnvSchemas.d.ts +2 -2
  98. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  99. package/dist/env/getEnvSchemas.js +7 -5
  100. package/dist/env/windowGlobalEnvStatement.d.ts.map +1 -1
  101. package/dist/findProjectDir.d.ts.map +1 -1
  102. package/dist/findProjectDir.js +18 -4
  103. package/dist/findUserConfig.js +2 -2
  104. package/dist/foreach.js +1 -0
  105. package/dist/frameworkConfigSchema.js +2 -2
  106. package/dist/getComponent.d.ts.map +1 -1
  107. package/dist/getComponentDev.d.ts.map +1 -1
  108. package/dist/getRoutes.d.ts.map +1 -1
  109. package/dist/getRoutes.js +13 -22
  110. package/dist/getRoutesDevs.d.ts.map +1 -1
  111. package/dist/getStackTrace.js +1 -1
  112. package/dist/glob.d.ts +5 -0
  113. package/dist/glob.d.ts.map +1 -0
  114. package/dist/glob.js +103 -0
  115. package/dist/helpers/getFetchCompatibleHeaders.js +2 -2
  116. package/dist/hmr/applyHmrModule.js +5 -5
  117. package/dist/hmr/componentIdentity.js +1 -1
  118. package/dist/hmr/instanceRegistry.js +2 -2
  119. package/dist/hooks/useReducer.d.ts.map +1 -1
  120. package/dist/hooks/useState.d.ts.map +1 -1
  121. package/dist/hooks/useState.js +2 -8
  122. package/dist/hydrate/hydrate.d.ts +1 -1
  123. package/dist/hydrate/hydrate.d.ts.map +1 -1
  124. package/dist/hydrate/hydrate.js +26 -24
  125. package/dist/hydrate/reconcileHydratedAttributes.js +2 -2
  126. package/dist/makeFinalConfig.d.ts.map +1 -1
  127. package/dist/makeFinalConfig.js +2 -2
  128. package/dist/markOptionSelected.js +1 -1
  129. package/dist/mergeConfigs.d.ts.map +1 -1
  130. package/dist/mergeConfigs.js +11 -2
  131. package/dist/mutatingFunctions.js +3 -3
  132. package/dist/postcssPlugins/TransformCssNames.js +2 -2
  133. package/dist/rawHtml/parseHtml.js +1 -1
  134. package/dist/render/componentNodeToRenderingTree.d.ts.map +1 -1
  135. package/dist/render/componentNodeToRenderingTree.js +6 -17
  136. package/dist/render/contentToHtml.d.ts.map +1 -1
  137. package/dist/render/contentToHtml.js +1 -1
  138. package/dist/render/getFunctionBodyAsString.d.ts.map +1 -1
  139. package/dist/render/getFunctionBodyAsString.js +2 -5
  140. package/dist/render/processProps.js +2 -2
  141. package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
  142. package/dist/render/rootToHtml.d.ts.map +1 -1
  143. package/dist/routing/Route.js +1 -1
  144. package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
  145. package/dist/routing/RoutesWithSafeParams.js +1 -1
  146. package/dist/routing/WebRedirect.d.ts.map +1 -1
  147. package/dist/routing/compareRequestToRegex.js +2 -2
  148. package/dist/routing/getPathPriority.js +1 -1
  149. package/dist/serverRpc.d.ts.map +1 -1
  150. package/dist/slash.d.ts +2 -0
  151. package/dist/slash.d.ts.map +1 -0
  152. package/dist/slash.js +5 -0
  153. package/dist/spawnShellCommand.js +1 -1
  154. package/dist/staticGen/staticGen.d.ts.map +1 -1
  155. package/dist/staticGen/staticGen.js +9 -7
  156. package/dist/staticGen/staticGenFunctions.js +1 -1
  157. package/dist/style/jssToCss.d.ts.map +1 -1
  158. package/dist/style/jssToCss.js +11 -9
  159. package/dist/style/unusedStyles.d.ts.map +1 -1
  160. package/dist/testing/host.js +11 -11
  161. package/dist/testing/hydrateTestApp.d.ts.map +1 -1
  162. package/dist/testing/hydrateTestApp.js +9 -9
  163. package/dist/testing/index.d.ts.map +1 -1
  164. package/dist/testing/installTestStyleProcessors.js +1 -1
  165. package/dist/testing/loadEnv.d.ts +4 -1
  166. package/dist/testing/loadEnv.d.ts.map +1 -1
  167. package/dist/testing/loadEnv.js +2 -2
  168. package/dist/testing/temp/componentPackageMock.js +3 -3
  169. package/dist/timeProfiler.d.ts +4 -0
  170. package/dist/timeProfiler.d.ts.map +1 -1
  171. package/dist/timeProfiler.js +16 -0
  172. package/dist/todo.js +2 -1
  173. package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
  174. package/dist/update/integrateUpdateVdom.js +17 -14
  175. package/dist/update/integrateUpdateVdomPrebuild.js +5 -5
  176. package/dist/watch.js +2 -2
  177. package/package.json +10 -29
  178. package/types/modules.d.ts +0 -1
  179. package/vendor/babel-core.js +26 -0
  180. package/vendor/babel-parser.js +9 -0
  181. package/vendor/babel-plugin-syntax-import-assertions.js +50 -0
  182. package/vendor/babel-preset-react.js +872 -0
  183. package/vendor/babel-preset-typescript.js +26 -0
  184. package/vendor/babel-types.js +9 -0
  185. package/vendor/chalk-extensions.js +1994 -0
  186. package/vendor/chalk.js +647 -0
  187. package/vendor/chokidar.js +6889 -0
  188. package/vendor/chunk-1TN2rK3j.js +1218 -0
  189. package/vendor/chunk-1UuLTU0U.js +34 -0
  190. package/vendor/chunk-B_NeooyV.js +86 -0
  191. package/vendor/chunk-C12hSZn7.js +88 -0
  192. package/vendor/chunk-C3YkUGz5.js +19 -0
  193. package/vendor/chunk-C3fcZDjl.js +41964 -0
  194. package/vendor/chunk-C9FSKeSx.js +14603 -0
  195. package/vendor/chunk-CPArXGxa.js +14623 -0
  196. package/vendor/cjs-module-lexer.js +6 -0
  197. package/vendor/dotenv.js +412 -0
  198. package/vendor/express.js +40577 -0
  199. package/vendor/import-meta-resolve.js +2201 -0
  200. package/vendor/manifest.json +29 -0
  201. package/vendor/postcss.js +8546 -0
  202. package/vendor/serialize-javascript.js +293 -0
  203. package/vendor/sxy-lib-arrays.js +113 -0
  204. package/vendor/sxy-lib-object-copy.js +1781 -0
  205. package/vendor/sxy-lib-objects.js +156 -0
  206. package/vendor/sxy-lib-promises.js +47 -0
  207. package/vendor/sxy-package-investigator.js +202 -0
  208. package/vendor/valibot.js +7664 -0
  209. package/dist/Servers/hono/DevServerHono.d.ts +0 -2
  210. package/dist/Servers/hono/DevServerHono.d.ts.map +0 -1
  211. package/dist/Servers/hono/DevServerHono.js +0 -423
  212. package/dist/Servers/hono/ProdServerHono.d.ts +0 -2
  213. package/dist/Servers/hono/ProdServerHono.d.ts.map +0 -1
  214. package/dist/Servers/hono/ProdServerHono.js +0 -220
  215. package/dist/Servers/hono/TungstenServerHono.d.ts +0 -6
  216. package/dist/Servers/hono/TungstenServerHono.d.ts.map +0 -1
  217. package/dist/Servers/hono/TungstenServerHono.js +0 -36
  218. package/dist/api/ApiEndpointHono.d.ts +0 -3
  219. package/dist/api/ApiEndpointHono.d.ts.map +0 -1
  220. package/dist/api/ApiEndpointHono.js +0 -1
  221. package/dist/api/ApiRouteHono.d.ts +0 -7
  222. package/dist/api/ApiRouteHono.d.ts.map +0 -1
  223. package/dist/api/ApiRouteHono.js +0 -1
  224. package/dist/api/ApiRoutesHono.d.ts +0 -5
  225. package/dist/api/ApiRoutesHono.d.ts.map +0 -1
  226. package/dist/api/ApiRoutesHono.js +0 -1
  227. package/dist/api/getApiRoutesHono.d.ts +0 -6
  228. package/dist/api/getApiRoutesHono.d.ts.map +0 -1
  229. package/dist/api/getApiRoutesHono.js +0 -14
  230. package/dist/build/compilePackages.d.ts +0 -2
  231. package/dist/build/compilePackages.d.ts.map +0 -1
  232. package/dist/build/compilePackages.js +0 -89
  233. package/dist/build/findRequiredUserModule.d.ts +0 -2
  234. package/dist/build/findRequiredUserModule.d.ts.map +0 -1
  235. package/dist/build/findRequiredUserModule.js +0 -36
  236. package/dist/build/processPackage.d.ts +0 -4
  237. package/dist/build/processPackage.d.ts.map +0 -1
  238. package/dist/build/processPackage.js +0 -91
  239. package/dist/build/tallyBabelPlugins.d.ts +0 -3
  240. package/dist/build/tallyBabelPlugins.d.ts.map +0 -1
  241. package/dist/build/tallyBabelPlugins.js +0 -63
  242. package/dist/testing/loadEnvSetup.d.ts +0 -2
  243. package/dist/testing/loadEnvSetup.d.ts.map +0 -1
  244. package/dist/testing/loadEnvSetup.js +0 -7
  245. package/sxy-loader.config.js +0 -7
package/dist/glob.js ADDED
@@ -0,0 +1,103 @@
1
+ import { readdirSync } from 'fs';
2
+ import { isAbsolute } from 'path';
3
+ import slash from './slash.js';
4
+ // globby's job for the patterns tungsten uses (`**`, `*`, `?`, `{a,b}`, `[…]`, `!` excludes):
5
+ // a sync walk from each pattern's static prefix, matched with precompiled regexes. Results are
6
+ // absolute forward-slash paths. Dot segments are skipped, node_modules is not - both as globby
7
+ // did. Sync on purpose: node's fs.glob and a promise-per-directory walk both sat behind the
8
+ // sync sass compile at startup (35ms standalone, ~380ms in dev), a sync walk cannot.
9
+ const globChars = /[*?{[]/;
10
+ function escapeRegExp(text) {
11
+ return text.replace(/[.+^$()|\\]/g, '\\$&');
12
+ }
13
+ // glob source -> regex source, no anchors
14
+ function convert(pattern) {
15
+ let out = '';
16
+ for (let i = 0; i < pattern.length; i++) {
17
+ const char = pattern[i];
18
+ if (char === '*') {
19
+ if (pattern[i + 1] === '*') {
20
+ if (pattern[i + 2] === '/') {
21
+ out += '(?:[^/]*/)*';
22
+ i += 2;
23
+ } // any depth, including none
24
+ else {
25
+ out += '.*';
26
+ i += 1;
27
+ }
28
+ } else out += '[^/]*';
29
+ } else if (char === '?') {
30
+ out += '[^/]';
31
+ } else if (char === '{') {
32
+ const end = pattern.indexOf('}', i);
33
+ if (end === -1) {
34
+ out += '\\{';
35
+ continue;
36
+ }
37
+ out += `(?:${pattern.slice(i + 1, end).split(',').map(convert).join('|')})`;
38
+ i = end;
39
+ } else if (char === '[') {
40
+ const end = pattern.indexOf(']', i);
41
+ if (end === -1) {
42
+ out += '\\[';
43
+ continue;
44
+ }
45
+ const body = pattern.slice(i + 1, end);
46
+ out += `[${body.startsWith('!') ? '^' + body.slice(1) : body}]`;
47
+ i = end;
48
+ } else {
49
+ out += escapeRegExp(char ?? '');
50
+ }
51
+ }
52
+ return out;
53
+ }
54
+ export function globToRegExp(pattern) {
55
+ return new RegExp(`^${convert(pattern)}$`);
56
+ }
57
+ // the directory to walk: the segments before the first one holding a glob character
58
+ function staticPrefix(pattern) {
59
+ const segments = pattern.split('/');
60
+ const firstGlob = segments.findIndex(segment => globChars.test(segment));
61
+ return (firstGlob === -1 ? segments.slice(0, -1) : segments.slice(0, firstGlob)).join('/');
62
+ }
63
+ function walk(dir, files = []) {
64
+ let entries;
65
+ try {
66
+ entries = readdirSync(dir, {
67
+ withFileTypes: true
68
+ });
69
+ } catch (error) {
70
+ if (error.code === 'ENOENT') return files; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- fs errors carry a code
71
+ throw error;
72
+ }
73
+ for (const entry of entries) {
74
+ if (entry.name.startsWith('.')) continue;
75
+ if (entry.isDirectory()) walk(`${dir}/${entry.name}`, files);else if (entry.isFile()) files.push(`${dir}/${entry.name}`);
76
+ }
77
+ return files;
78
+ }
79
+ export async function glob(patterns, options = {}) {
80
+ const cwd = slash(options.cwd ?? process.cwd());
81
+ const full = pattern => {
82
+ const normalised = slash(pattern);
83
+ return isAbsolute(normalised) ? normalised : `${cwd}/${normalised}`;
84
+ };
85
+ const list = (Array.isArray(patterns) ? patterns : [patterns]).map(slash);
86
+ const includes = list.filter(pattern => !pattern.startsWith('!')).map(full);
87
+ const excludes = list.filter(pattern => pattern.startsWith('!')).map(pattern => globToRegExp(full(pattern.slice(1))));
88
+ // one walk per distinct base, every include tested against each of its files
89
+ const byBase = new Map();
90
+ for (const pattern of includes) {
91
+ const base = staticPrefix(pattern);
92
+ byBase.set(base, [...(byBase.get(base) ?? []), globToRegExp(pattern)]);
93
+ }
94
+ const found = new Set();
95
+ for (const [base, matchers] of byBase) {
96
+ for (const file of walk(base)) {
97
+ if (!matchers.some(matcher => matcher.test(file))) continue;
98
+ if (excludes.some(matcher => matcher.test(file))) continue;
99
+ found.add(file);
100
+ }
101
+ }
102
+ return [...found];
103
+ }
@@ -11,10 +11,10 @@ export function getFetchCompatibleHeaders(req) {
11
11
  ...restHeaders
12
12
  } = req.headers;
13
13
  const headers = block(
14
- // eslint-disable-line no-type-assertion/no-type-assertion -- this refers to the typecast at the end of this block: recast it as a record to avoid difficulty getting required values of partials
14
+ // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- this refers to the typecast at the end of this block: recast it as a record to avoid difficulty getting required values of partials
15
15
  // Headers will all be strings, except for set-cookie, so we will override the types from @types/node here
16
16
  restHeaders,
17
- // eslint-disable-line no-type-assertion/no-type-assertion -- countering bad typing in @types/node for 'http' incoming headers
17
+ // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- countering bad typing in @types/node for 'http' incoming headers
18
18
  header => header === undefined);
19
19
  return new Headers({
20
20
  ...headers
@@ -32,18 +32,18 @@ export async function applyHmrModule(moduleExports, file) {
32
32
  for (const exportName in moduleExports) {
33
33
  const exported = moduleExports[exportName];
34
34
  if (typeof exported !== 'function') continue;
35
- const NewType = exported; // eslint-disable-line no-type-assertion/no-type-assertion -- narrowed by typeof above, definitively a function/class value
35
+ const NewType = exported; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- narrowed by typeof above, definitively a function/class value
36
36
  const newKind = componentTypeKind(NewType);
37
37
  const newKey = componentTypeIdentityKey(NewType);
38
38
  currentIdentities.add(identityToken(newKind, newKey));
39
39
  // snapshot: hot-swapping unregisters the old instance and registers its replacement,
40
40
  // mutating registeredComponents mid-loop otherwise
41
41
  for (const component of [...instance.registeredComponents]) {
42
- const anyComponent = component; // eslint-disable-line no-type-assertion/no-type-assertion -- every registered component is actually a class instance or FunctionElement stand-in
42
+ const anyComponent = component; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- every registered component is actually a class instance or FunctionElement stand-in
43
43
  if (liveComponentKind(anyComponent) !== newKind) continue;
44
44
  if (liveComponentIdentityKey(anyComponent) !== newKey) continue;
45
- const swapped = AnyComponentIsFunctionComponentStandIn(anyComponent) ? await hotSwapFunctionComponent(anyComponent, NewType) // eslint-disable-line no-type-assertion/no-type-assertion -- newKind === 'function' guaranteed by the kind check above
46
- : await hotSwapClassComponent(anyComponent, NewType); // eslint-disable-line no-type-assertion/no-type-assertion -- newKind === 'class' guaranteed by the kind check above
45
+ const swapped = AnyComponentIsFunctionComponentStandIn(anyComponent) ? await hotSwapFunctionComponent(anyComponent, NewType) // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- newKind === 'function' guaranteed by the kind check above
46
+ : await hotSwapClassComponent(anyComponent, NewType); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- newKind === 'class' guaranteed by the kind check above
47
47
  if (swapped !== null) matchedCount++;
48
48
  }
49
49
  }
@@ -56,7 +56,7 @@ export async function applyHmrModule(moduleExports, file) {
56
56
  const kind = tokenKind(previousToken);
57
57
  const key = tokenKey(previousToken);
58
58
  const stillLive = [...instance.registeredComponents].some(component => {
59
- const anyComponent = component; // eslint-disable-line no-type-assertion/no-type-assertion -- every registered component is actually a class instance or FunctionElement stand-in
59
+ const anyComponent = component; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- every registered component is actually a class instance or FunctionElement stand-in
60
60
  return liveComponentKind(anyComponent) === kind && liveComponentIdentityKey(anyComponent) === key;
61
61
  });
62
62
  if (stillLive) {
@@ -7,7 +7,7 @@ export function componentTypeKind(Type) {
7
7
  return AnyComponentTypeIsClassComponentType(Type) ? 'class' : 'function';
8
8
  }
9
9
  export function liveComponentType(component) {
10
- return AnyComponentIsFunctionComponentStandIn(component) ? component.func : component.constructor; // eslint-disable-line no-type-assertion/no-type-assertion -- constructor of a TungstenBaseComponent instance is its component type
10
+ return AnyComponentIsFunctionComponentStandIn(component) ? component.func : component.constructor; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- constructor of a TungstenBaseComponent instance is its component type
11
11
  }
12
12
  export function liveComponentKind(component) {
13
13
  return AnyComponentIsFunctionComponentStandIn(component) ? 'function' : 'class';
@@ -1,6 +1,6 @@
1
1
  export function setCurrentInstance(instance) {
2
- globalThis.__tungstenHmrInstance = instance; // eslint-disable-line no-type-assertion/no-type-assertion -- narrowing globalThis to add one optional dev-only field
2
+ globalThis.__tungstenHmrInstance = instance; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- narrowing globalThis to add one optional dev-only field
3
3
  }
4
4
  export function getCurrentInstance() {
5
- return globalThis.__tungstenHmrInstance; // eslint-disable-line no-type-assertion/no-type-assertion -- narrowing globalThis to add one optional dev-only field
5
+ return globalThis.__tungstenHmrInstance; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- narrowing globalThis to add one optional dev-only field
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useReducer.d.ts","sourceRoot":"","sources":["../../src/hooks/useReducer.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,YAAY,EAAE,GAAG,KAAK,GAAG,SAiCtH"}
1
+ {"version":3,"file":"useReducer.d.ts","sourceRoot":"","sources":["../../src/hooks/useReducer.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CACtB,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,GAAG,EAAE,UAAU,EAAE,GAAG,EAC1D,IAAI,EAAE,CAAC,YAAY,EAAE,GAAG,KAAK,GAAG,SAkCnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useState.d.ts","sourceRoot":"","sources":["../../src/hooks/useState.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAA;AASrD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,CAAC,SAAS,SAAS,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,GACnG,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC,CA4B/B"}
1
+ {"version":3,"file":"useState.d.ts","sourceRoot":"","sources":["../../src/hooks/useState.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAA;AAOrD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,CAAC,SAAS,SAAS,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,GACnG,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC,CAwB/B"}
@@ -1,7 +1,4 @@
1
1
  import { getCurrentComponent } from './getCurrentComponent.js';
2
- import { TungstenError, TungstenProductionError } from '../TungstenError.js';
3
- import { isDev } from '../isDev.js';
4
- const thisHook = 'useState';
5
2
  // overloads just so TS errs say defaultValue not args
6
3
  // export function useState<T extends undefined>(defaultValue?: T): [T, (newValue: T) => void]
7
4
  // export function useState<T>(defaultValue: T): [T, (newValue: T) => void]
@@ -9,10 +6,7 @@ const thisHook = 'useState';
9
6
  // : [T, (newValue: T) => void] {
10
7
  export function useState(...defaultValue) {
11
8
  // what do we do here?
12
- const c = getCurrentComponent();
13
- if (c === undefined) {
14
- if (isDev) throw new TungstenError(`Invalid call to ${thisHook} outside of a component`);else throw new TungstenProductionError();
15
- }
9
+ const c = getCurrentComponent(); // throws outside a component
16
10
  const index = c.useStateIndex++;
17
11
  //console.log('c.state', c.state)
18
12
  //console.log('looking for'. indexOf.toString(), 'in component')
@@ -32,6 +26,6 @@ export function useState(...defaultValue) {
32
26
  } else {
33
27
  //console.log('useState initial run')
34
28
  c.state[index] = defaultValue[0];
35
- return [defaultValue[0], update]; // eslint-disable-line no-type-assertion/no-type-assertion -- args[0] can only be undefined if T includes undefined
29
+ return [defaultValue[0], update]; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- args[0] can only be undefined if T includes undefined
36
30
  }
37
31
  }
@@ -12,6 +12,6 @@ export type HydrateMeta = {
12
12
  };
13
13
  export declare function makeDefaultHydrateMeta(): HydrateMeta;
14
14
  export declare function hydrate(appRoutes: AppRoutes, RootComponent: TungstenBaseComponentType | null, instanceConfig: InstanceConfig): Promise<void>;
15
- export declare function hydrateRootComponent<ComponentType extends TungstenBaseComponentType<any, any>>(instance: Instance, RootComponent: ComponentType, domPointer: DomPointer, meta: HydrateMeta, props?: InstanceType<ComponentType>['props'], // eslint-disable-line no-type-assertion/no-type-assertion -- default only reached when Props is empty, same as the hardcoded {} this replaces
15
+ export declare function hydrateRootComponent<ComponentType extends TungstenBaseComponentType<any, any>>(instance: Instance, RootComponent: ComponentType, domPointer: DomPointer, meta: HydrateMeta, props?: InstanceType<ComponentType>['props'], // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- default only reached when Props is empty, same as the hardcoded {} this replaces
16
16
  routeParams?: Record<string, string>, routeData?: unknown): Promise<InstanceType<ComponentType>>;
17
17
  //# sourceMappingURL=hydrate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../../src/hydrate/hydrate.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAQnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAoBxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAM7C,OAAO,EAAE,yBAAyB,EAAoD,MAAM,mBAAmB,CAAA;AAE/G,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAoBlD,OAAO,EAC4B,KAAK,uBAAuB,EAC9D,MAAM,oCAAoC,CAAA;AAQ3C,OAAO,0BAA0B,CAAA;AASjC,MAAM,MAAM,WAAW,GAAG;IACtB,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,uBAAuB,EAAE,CAAA;IAGrC,WAAW,EAAE,OAAO,CAAA;CACvB,CAAA;AACD,wBAAgB,sBAAsB,IAAI,WAAW,CAEpD;AAID,wBAAsB,OAAO,CACzB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,yBAAyB,GAAG,IAAI,EAC/C,cAAc,EAAE,cAAc,iBA2DjC;AAyBD,wBAAsB,oBAAoB,CACtC,aAAa,SAAS,yBAAyB,CAAC,GAAG,EAAE,GAAG,CAAC,EAEzD,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,WAAW,EAIjB,KAAK,GAAE,YAAY,CAAC,aAAa,CAAC,CAAC,OAAO,CAA8C,EAAE,8IAA8I;AACxO,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,SAAS,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CA6DtC"}
1
+ {"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../../src/hydrate/hydrate.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAQnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAmBxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAM7C,OAAO,EAAE,yBAAyB,EAAoD,MAAM,mBAAmB,CAAA;AAE/G,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAmBlD,OAAO,EAC4B,KAAK,uBAAuB,EAC9D,MAAM,oCAAoC,CAAA;AAQ3C,OAAO,0BAA0B,CAAA;AASjC,MAAM,MAAM,WAAW,GAAG;IACtB,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,uBAAuB,EAAE,CAAA;IAGrC,WAAW,EAAE,OAAO,CAAA;CACvB,CAAA;AACD,wBAAgB,sBAAsB,IAAI,WAAW,CAEpD;AAID,wBAAsB,OAAO,CACzB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,yBAAyB,GAAG,IAAI,EAC/C,cAAc,EAAE,cAAc,iBA2DjC;AAyBD,wBAAsB,oBAAoB,CACtC,aAAa,SAAS,yBAAyB,CAAC,GAAG,EAAE,GAAG,CAAC,EAEzD,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,WAAW,EAIjB,KAAK,GAAE,YAAY,CAAC,aAAa,CAAC,CAAC,OAAO,CAAM,EAAE,sJAAsJ;AACxM,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,SAAS,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CA6DtC"}
@@ -17,7 +17,6 @@ import { setCurrentComponent } from '../hooks/setCurrentComponent.js';
17
17
  import { clearCurrentComponent } from '../hooks/clearCurrentComponent.js';
18
18
  import { htmlEventHandlerKey } from '../htmlEventHandlerKey.js';
19
19
  import { packageNameCapitalized } from '../settings.js';
20
- import { todo } from '../todo.js';
21
20
  import { throwError } from '../throwError.js';
22
21
  import { $contentNull } from '../symbols.js';
23
22
  import { $props, $routeData, $routeParams, $type } from '../contentNodeSymbols.js';
@@ -107,7 +106,7 @@ routes) {
107
106
  } = matchedRouteInfo;
108
107
  if (key !== null) {
109
108
  if (!(key in routes)) throwError('hydrationRouting', `Route ${key} not found in routes ${routes}`);
110
- const content = routes[key].content; // eslint-disable-line no-type-assertion/no-type-assertion -- we just checked
109
+ const content = routes[key].content; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- we just checked
111
110
  return {
112
111
  ...matchedRouteInfo,
113
112
  content
@@ -124,11 +123,11 @@ export async function hydrateRootComponent(instance, RootComponent, domPointer,
124
123
  // route data comes through the store instead - so the default reproduces that. A test
125
124
  // harness hydrating an arbitrary component (see testing/hydrateTestApp.ts) passes its own.
126
125
  props = {},
127
- // eslint-disable-line no-type-assertion/no-type-assertion -- default only reached when Props is empty, same as the hardcoded {} this replaces
126
+ // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- default only reached when Props is empty, same as the hardcoded {} this replaces
128
127
  routeParams, routeData) {
129
128
  debug('hydrateRootComponent');
130
129
  // matches createTungstenRootComponent's identical cast, the create-path equivalent of this function
131
- // eslint-disable-next-line no-type-assertion/no-type-assertion
130
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
132
131
  const element = new RootComponent({
133
132
  props,
134
133
  routeParams,
@@ -145,7 +144,7 @@ routeParams, routeData) {
145
144
  if (openingNode.nodeType !== Node.COMMENT_NODE) {
146
145
  throwError('hydrateFunctionComponent', 'expected to find a comment, but instead found ' + openingNode.toString() + ' type ' + openingNode.nodeType.toString());
147
146
  }
148
- //const openingComment = openingNode as Comment // eslint-disable-line no-type-assertion/no-type-assertion
147
+ //const openingComment = openingNode as Comment // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
149
148
  domPointer.increment();
150
149
  const renderedTree = await hydrateNode(content, element, domPointer, instance, meta);
151
150
  debug('rendered tree after hydration', renderedTree);
@@ -153,7 +152,7 @@ routeParams, routeData) {
153
152
  if (closingNode.nodeType !== Node.COMMENT_NODE) {
154
153
  throwError('hydrateFunctionComponent', 'expected to find a comment, but instead found ' + closingNode.toString() + ' type ' + closingNode.nodeType.toString());
155
154
  }
156
- //const closingComment = closingNode as Comment // eslint-disable-line no-type-assertion/no-type-assertion
155
+ //const closingComment = closingNode as Comment // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
157
156
  domPointer.increment();
158
157
  const domIndexCount = domPointer.index - domIndexStart;
159
158
  element.__domRegion = new DomRegion(domPointer.parent, domIndexStart, domIndexCount);
@@ -198,7 +197,7 @@ async function hydrateClassComponent(node, parentElement, domPointer, instance,
198
197
  if (openingNode.nodeType !== Node.COMMENT_NODE) {
199
198
  throwError('hydrateFunctionComponent', 'expected to find a comment, but instead found ' + openingNode.toString() + ' type ' + openingNode.nodeType.toString());
200
199
  }
201
- const openingComment = openingNode; // eslint-disable-line no-type-assertion/no-type-assertion
200
+ const openingComment = openingNode; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
202
201
  domPointer.increment();
203
202
  //// InstantiateClassComponent???
204
203
  const element = new Component({
@@ -236,7 +235,7 @@ async function hydrateClassComponent(node, parentElement, domPointer, instance,
236
235
  if (closingNode.nodeType !== Node.COMMENT_NODE) {
237
236
  throwError('hydrateFunctionComponent', 'expected to find a comment, but instead found ' + closingNode.toString() + ' type ' + closingNode.nodeType.toString());
238
237
  }
239
- const closingComment = closingNode; // eslint-disable-line no-type-assertion/no-type-assertion
238
+ const closingComment = closingNode; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
240
239
  domPointer.increment();
241
240
  const domIndexCount = domPointer.index - domIndexStart;
242
241
  debug('DOM region', domPointer.parent, domIndexStart, domIndexCount);
@@ -261,7 +260,7 @@ async function hydrateClassComponent(node, parentElement, domPointer, instance,
261
260
  if (closingNode.nodeType !== Node.COMMENT_NODE) {
262
261
  throwError('hydrateFunctionComponent', 'expected to find a comment, but instead found ' + closingNode.toString() + ' type ' + closingNode.nodeType.toString());
263
262
  }
264
- const closingComment = closingNode; // eslint-disable-line no-type-assertion/no-type-assertion
263
+ const closingComment = closingNode; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
265
264
  domPointer.increment();
266
265
  const domIndexCount = domPointer.index - domIndexStart;
267
266
  debug('DOM region', domPointer.parent, domIndexStart, domIndexCount);
@@ -347,14 +346,14 @@ async function hydrateFunctionComponent(node, parentElement, domPointer, instanc
347
346
  if (openingNode.nodeType !== Node.COMMENT_NODE) {
348
347
  throwError('hydrateFunctionComponent', 'expected to find a comment, but instead found ' + openingNode.toString() + ' type ' + openingNode.nodeType.toString());
349
348
  }
350
- const openingComment = openingNode; // eslint-disable-line no-type-assertion/no-type-assertion
349
+ const openingComment = openingNode; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
351
350
  domPointer.increment();
352
351
  const renderedTree = await hydrateNode(content, functionComponentStandIn, domPointer, instance, meta);
353
352
  const closingNode = domPointer.get();
354
353
  if (closingNode.nodeType !== Node.COMMENT_NODE) {
355
354
  throwError('hydrateFunctionComponent', 'expected to find a comment, but instead found ' + closingNode.toString() + ' type ' + closingNode.nodeType.toString());
356
355
  }
357
- const closingComment = closingNode; // eslint-disable-line no-type-assertion/no-type-assertion
356
+ const closingComment = closingNode; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
358
357
  domPointer.increment();
359
358
  const domIndexCount = domPointer.index - domIndexStart;
360
359
  functionComponentStandIn.__domRegion = new DomRegion(domPointer.parent, domIndexStart, domIndexCount);
@@ -463,11 +462,11 @@ async function hydrateNodeSingle(node, parentElement, domPointer, instance, meta
463
462
  instance.persistentHeadChildren = persistentHeadChildren;
464
463
  debug('head node - skipping, because we add a lot to this during initial render, breaking matching');
465
464
  domPointer.increment();
466
- //return { [$type]: $head, domNode: node as HTMLElement } // eslint-disable-line no-type-assertion/no-type-assertion
465
+ //return { [$type]: $head, domNode: node as HTMLElement } // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
467
466
  return {
468
467
  [$type]: 'head',
469
468
  domNode: node
470
- }; // eslint-disable-line no-type-assertion/no-type-assertion
469
+ }; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
471
470
  }
472
471
  if (ContentNodeIsHtml(node)) {
473
472
  // HTML el
@@ -621,15 +620,18 @@ function hydrateAttributes(node, domNode, meta) {
621
620
  debug(`adding ${key} event handler for`, node);
622
621
  debug('domNode', domNode);
623
622
  const eventName = htmlEvents[key];
624
- //domNode.addEventListener(eventName as keyof HTMLElementEventMap, eventListener)
625
- todo('addAttributes() warning - ensure type safety of event name'); //
626
- todo('addAttributes() warning - ensure type safety of event listener'); //
627
623
  const handler = node[$props][key];
624
+ // JSX types the prop as a handler; a non-function is a spread of foreign props or a raw
625
+ // content tree, and addEventListener would throw a bare TypeError for it
626
+ if (isDev && typeof handler !== 'function') {
627
+ const tag = typeof node[$type] === 'string' ? node[$type] : '(component)';
628
+ throwError('hydrate', `<${tag}> ${key} is ${typeof handler}, not a function`);
629
+ }
628
630
  // // if its a button without type="submit", prevent default to stop it from submitting forms
629
631
  // const handler = (key === 'onClick' && node[$type] === 'button' && node[$props].type !== 'submit')
630
632
  // ? (event: Event) => { event.preventDefault(); return (node[$props][key] as EventListener)(event) }
631
633
  // : node[$props][key] as EventListener
632
- domNode.addEventListener(eventName, handler);
634
+ domNode.addEventListener(eventName, handler); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- a function is all the DOM checks
633
635
  domNode[htmlEventHandlerKey(eventName)] = handler;
634
636
  } else if (key === 'bind' && ContentNodeElementIsHtml(node)) {
635
637
  const eventName = 'input';
@@ -673,7 +675,7 @@ function hydrateAttributes(node, domNode, meta) {
673
675
  } else if (key === 'bindChecked' && ContentNodeElementIsHtml(node)) {
674
676
  // not checking that el is bindable, don't think its necessary
675
677
  debug('binding checked');
676
- const [bindObject, bindKey] = node[$props][key]; // eslint-disable-line no-type-assertion/no-type-assertion
678
+ const [bindObject, bindKey] = node[$props][key]; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
677
679
  domNode.checked = bindObject[bindKey];
678
680
  const eventName = 'input';
679
681
  //let handler
@@ -684,7 +686,7 @@ function hydrateAttributes(node, domNode, meta) {
684
686
  // }
685
687
  // } else {
686
688
  const handler = event => {
687
- bindObject[bindKey] = event.target.checked; // eslint-disable-line no-type-assertion/no-type-assertion
689
+ bindObject[bindKey] = event.target.checked; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
688
690
  };
689
691
  //}
690
692
  domNode.addEventListener(eventName, handler);
@@ -695,23 +697,23 @@ function hydrateAttributes(node, domNode, meta) {
695
697
  } else if (key === 'bindRadio' && ContentNodeElementIsHtml(node)) {
696
698
  // not checking that el is bindable, don't think its necessary
697
699
  debug('binding radio');
698
- const [bindObject, bindKey] = node[$props][key]; // eslint-disable-line no-type-assertion/no-type-assertion
700
+ const [bindObject, bindKey] = node[$props][key]; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
699
701
  domNode.checked = node[$props].value === bindObject[bindKey];
700
702
  const eventName = 'change';
701
703
  //let handler
702
704
  // if ('filter' in node[$props]) {
703
- // const filterFunc = node[$props].filter as FilterCheckedFunc<any, any> // eslint-disable-line no-type-assertion/no-type-assertion
705
+ // const filterFunc = node[$props].filter as FilterCheckedFunc<any, any> // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
704
706
  // handler = async (event: HTMLElementEventMap['change']) => {
705
707
  // console.log('radio changed handler')
706
- // bindObject[bindKey] = await filterFunc((event.target as HTMLCheckedBindableElement).checked, event) // eslint-disable-line no-type-assertion/no-type-assertion
708
+ // bindObject[bindKey] = await filterFunc((event.target as HTMLCheckedBindableElement).checked, event) // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
707
709
  // }
708
710
  // } else {
709
711
  const handler = event => {
710
712
  console.log('bound radio changed 1');
711
- bindObject[bindKey] = event.target.value; // eslint-disable-line no-type-assertion/no-type-assertion
713
+ bindObject[bindKey] = event.target.value; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
712
714
  };
713
715
  //}
714
- // eslint-disable-next-line no-type-assertion/no-type-assertion
716
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
715
717
  domNode.addEventListener(eventName, handler);
716
718
  domNode['onchange'] = handler;
717
719
  domNode[htmlEventHandlerKey(eventName)] = handler;
@@ -16,13 +16,13 @@ function attributeValue(name, value) {
16
16
  function removeAttribute(domNode, name) {
17
17
  // checked is both an attribute and live state, and the attribute alone only
18
18
  // sets the default. Clear both, or the box stays ticked.
19
- // eslint-disable-next-line no-type-assertion/no-type-assertion
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
20
20
  if (name === 'checked') domNode.checked = false;
21
21
  domNode.removeAttribute(name);
22
22
  }
23
23
  function setAttribute(domNode, name, value) {
24
24
  domNode.setAttribute(name, value);
25
- // eslint-disable-next-line no-type-assertion/no-type-assertion
25
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
26
26
  if (name === 'checked') domNode.checked = true;
27
27
  }
28
28
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"makeFinalConfig.d.ts","sourceRoot":"","sources":["../src/makeFinalConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,eAAe,EAAE,uBAAuB,EAAE,wBAAwB,EACrE,MAAM,sBAAsB,CAAA;AAG7B,wBAAgB,eAAe,CAC3B,UAAU,EAAE,eAAe,EAC3B,SAAS,GAAE,wBAAwB,GAAG,IAAW,GAClD,uBAAuB,CAiBzB"}
1
+ {"version":3,"file":"makeFinalConfig.d.ts","sourceRoot":"","sources":["../src/makeFinalConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,eAAe,EAAE,uBAAuB,EAAE,wBAAwB,EACrE,MAAM,sBAAsB,CAAA;AAG7B,wBAAgB,eAAe,CAC3B,UAAU,EAAE,eAAe,EAC3B,SAAS,GAAE,wBAAwB,GAAG,IAAW,GAClD,uBAAuB,CAiBzB"}
@@ -3,14 +3,14 @@ export function makeFinalConfig(userConfig, overrides = null) {
3
3
  const finalConfig = structuredClone(defaultConfig);
4
4
  for (const key in userConfig) {
5
5
  //if (Object.prototype.hasOwnProperty.call(userConfig, key)) { // github co-pilot suggestion, unsure if needed
6
- finalConfig[key] = userConfig[key]; // eslint-disable-line no-type-assertion/no-type-assertion
6
+ finalConfig[key] = userConfig[key]; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
7
7
  //}
8
8
  }
9
9
  // an override left undefined keeps the user config / default value
10
10
  for (const key in overrides) {
11
11
  const value = overrides[key];
12
12
  if (value === undefined) continue;
13
- finalConfig[key] = value; // eslint-disable-line no-type-assertion/no-type-assertion
13
+ finalConfig[key] = value; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
14
14
  }
15
15
  return finalConfig;
16
16
  }
@@ -10,7 +10,7 @@ function collectOptionText(node) {
10
10
  }
11
11
  if (typeof node === 'string' || typeof node === 'number') return String(node);
12
12
  if (typeof node !== 'object') return '';
13
- const element = node; // eslint-disable-line no-type-assertion/no-type-assertion -- content and rendering nodes are both { [$type], [$props] }
13
+ const element = node; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- content and rendering nodes are both { [$type], [$props] }
14
14
  if (element[$type] === 'script' || typeof element[$props]?.__html === 'string') return '';
15
15
  return collectOptionText(element[$props]?.children);
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mergeConfigs.d.ts","sourceRoot":"","sources":["../src/mergeConfigs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAI3D,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAU3H"}
1
+ {"version":3,"file":"mergeConfigs.d.ts","sourceRoot":"","sources":["../src/mergeConfigs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAc3D,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAU3H"}
@@ -1,5 +1,14 @@
1
- import cloneDeep from 'lodash.clonedeep';
2
- // can we use structured close?
1
+ // plain data is copied, anything else (functions, class instances) kept by reference - config
2
+ // carries babel plugins, which structuredClone would reject
3
+ function cloneDeep(value) {
4
+ if (Array.isArray(value)) return value.map(cloneDeep); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- array in, array out
5
+ if (typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype) {
6
+ const copy = {};
7
+ for (const [key, entry] of Object.entries(value)) copy[key] = cloneDeep(entry);
8
+ return copy; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- same shape as the input
9
+ }
10
+ return value;
11
+ }
3
12
  export function mergeConfigs(config1, config2) {
4
13
  const newConfig = cloneDeep(config1);
5
14
  for (const key in config2) {
@@ -2,14 +2,14 @@ export const arrayMutatingFunctions = ['push', 'pop', 'shift', 'unshift', 'sort'
2
2
  export const mapMutatingFunctions = ['set', 'delete', 'clear'];
3
3
  export const setMutatingFunctions = ['add', 'delete', 'clear'];
4
4
  export function KeyIsArrayMutatingFunction(key) {
5
- // eslint-disable-next-line no-type-assertion/no-type-assertion -- weird TS issue, won't let us search in a const array
5
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- weird TS issue, won't let us search in a const array
6
6
  return arrayMutatingFunctions.includes(key);
7
7
  }
8
8
  export function KeyIsMapMutatingFunction(key) {
9
- // eslint-disable-next-line no-type-assertion/no-type-assertion -- weird TS issue, won't let us search in a const array
9
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- weird TS issue, won't let us search in a const array
10
10
  return mapMutatingFunctions.includes(key);
11
11
  }
12
12
  export function KeyIsSetMutatingFunction(key) {
13
- // eslint-disable-next-line no-type-assertion/no-type-assertion -- weird TS issue, won't let us search in a const array
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- weird TS issue, won't let us search in a const array
14
14
  return setMutatingFunctions.includes(key);
15
15
  }
@@ -178,11 +178,11 @@ export const TransformCssNames = opts => {
178
178
  const pseudoClassRegex = /:([a-zA-Z0-9-_]+)(?:\((.*)\))?/;
179
179
  const results = pseudoClassRegex.exec(content);
180
180
  if (results === null) throwError('TransformCssNames -> walkRules', 'pseudo-class selector did not match pseudo-class regex');
181
- const label = results[1]; // eslint-disable-line no-type-assertion/no-type-assertion -- typings are incorrect
181
+ const label = results[1]; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- typings are incorrect
182
182
  // if it is :i(xxx) or :ignore(xxx), pass through the internal part
183
183
  // otherwise pass all through unaffected
184
184
  if (label === 'i' || label === 'ignore') {
185
- const inner = results[2]; // eslint-disable-line no-type-assertion/no-type-assertion -- typings are incorrect
185
+ const inner = results[2]; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- typings are incorrect
186
186
  if (inner !== undefined && inner !== '') {
187
187
  newSelectors.push(inner);
188
188
  }
@@ -134,7 +134,7 @@ export function parseHtml(html, options = {}) {
134
134
  const current = () => stack[stack.length - 1];
135
135
  const close = downTo => {
136
136
  while (stack.length > downTo) {
137
- const element = stack.pop(); // eslint-disable-line no-type-assertion/no-type-assertion -- guarded by the loop
137
+ const element = stack.pop(); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- guarded by the loop
138
138
  if (element.removal === 'drop') continue;
139
139
  if (element.removal === 'unwrap') current().children.push(...element.children);else current().children.push(toContentNode(element));
140
140
  }
@@ -1 +1 @@
1
- {"version":3,"file":"componentNodeToRenderingTree.d.ts","sourceRoot":"","sources":["../../src/render/componentNodeToRenderingTree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EACH,KAAK,sBAAsB,EAG9B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAqD,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAGhH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAKjD,wBAAsB,4BAA4B,CAC9C,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,YAAY,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GACjH,OAAO,CAAC,sBAAsB,CAAC,CA6CjC"}
1
+ {"version":3,"file":"componentNodeToRenderingTree.d.ts","sourceRoot":"","sources":["../../src/render/componentNodeToRenderingTree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EACH,KAAK,sBAAsB,EAG9B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAqD,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAGhH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAKjD,wBAAsB,4BAA4B,CAC9C,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,YAAY,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GACjH,OAAO,CAAC,sBAAsB,CAAC,CAmCjC"}
@@ -10,24 +10,13 @@ export async function componentNodeToRenderingTree(componentNode, parentComponen
10
10
  const render = componentNode[$type].render;
11
11
  //console.log('render', render)
12
12
  if (render) {
13
- let location;
14
- let placeholder = null;
15
- if (typeof render === 'string') {
16
- location = render;
13
+ // ComponentRenderInfo only knows the client location; the object form adds a placeholder
14
+ const placeholder = typeof render === 'object' && 'placeholder' in render ? render.placeholder : null;
15
+ const placeholderTree = await contentTreeToRenderingTree(placeholder, parentComponent, instance, noEscape);
16
+ if (ContentNodeComponentIsClassComponent(componentNode)) {
17
+ return makeRenderingNodeClassComponentFromContentNodeClassComponent(componentNode, null, placeholderTree, true);
17
18
  } else {
18
- location = render.location;
19
- if (typeof render === 'object' && 'placeholder') {
20
- // not sure what this is
21
- placeholder = render.placeholder;
22
- }
23
- }
24
- if (location === 'client') {
25
- const placeholderTree = await contentTreeToRenderingTree(placeholder, parentComponent, instance, noEscape);
26
- if (ContentNodeComponentIsClassComponent(componentNode)) {
27
- return makeRenderingNodeClassComponentFromContentNodeClassComponent(componentNode, null, placeholderTree, true);
28
- } else {
29
- return makeRenderingNodeFunctionComponentFromContentNodeFunctionComponent(componentNode, null, placeholderTree, true);
30
- }
19
+ return makeRenderingNodeFunctionComponentFromContentNodeFunctionComponent(componentNode, null, placeholderTree, true);
31
20
  }
32
21
  }
33
22
  //console.log('componentRenderToTree component', component)
@@ -1 +1 @@
1
- {"version":3,"file":"contentToHtml.d.ts","sourceRoot":"","sources":["../../src/render/contentToHtml.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAY,YAAY,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAMvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAI9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAGrE,wBAAsB,aAAa,CAC/B,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EACpE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EACxC,MAAM,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,YAAY,EACnE,iBAAiB,GAAE,sBAAkC,EAAE,GAAG,UAAQ,GACnE,OAAO,CAAC,MAAM,CAAC,CAuDjB"}
1
+ {"version":3,"file":"contentToHtml.d.ts","sourceRoot":"","sources":["../../src/render/contentToHtml.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAY,YAAY,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAIvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAG9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAGrE,wBAAsB,aAAa,CAC/B,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EACpE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EACxC,MAAM,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,YAAY,EACnE,iBAAiB,GAAE,sBAAkC,EAAE,GAAG,UAAQ,GACnE,OAAO,CAAC,MAAM,CAAC,CAuDjB"}
@@ -4,7 +4,7 @@ import { RenderingNodeIsElement } from '../RenderingNode.js';
4
4
  import { contentTreeToRenderingTree } from './contentTreeToRenderingTree.js';
5
5
  import { cliWarn } from 'tungsten/cliOutput.js';
6
6
  export async function contentToHtml(compilationInfo, clientImportAliases, content, instance, config, siteBasePathOverride, tungstenPublicEnv = undefined, dev = false) {
7
- // const rootNode = { // eslint-disable-line no-type-assertion/no-type-assertion
7
+ // const rootNode = { // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
8
8
  // [$type]: RootComponentClass, // TypeScript needs some help to understand that { type: AnyComponentType }
9
9
  // [$props]: {} // is equivalent to { type: ClassComponentTypeAny } | { type: FunctionComponentTypeAny } (type names simplified here)
10
10
  // } as ContentNodeComponent
@@ -1 +1 @@
1
- {"version":3,"file":"getFunctionBodyAsString.d.ts","sourceRoot":"","sources":["../../src/render/getFunctionBodyAsString.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,UAcrD;AAID,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAgBlE"}
1
+ {"version":3,"file":"getFunctionBodyAsString.d.ts","sourceRoot":"","sources":["../../src/render/getFunctionBodyAsString.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,UAcrD;AAID,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAYlE"}
@@ -17,11 +17,8 @@ export function getFunctionBodyAsString(func) {
17
17
  export function getArrowFunctionBody(func) {
18
18
  // Not sure about this RegEx, probably from google
19
19
  const regex = /^(?:\s*\(?(?:\s*\w*\s*,?\s*)*\)?\s*?=>\s*){?([\s\S]*)}?$/;
20
- const matches = func.toString().match(regex); // eslint-disable-line no-type-assertion/no-type-assertion -- regex has a capture group
21
- if (!matches) {
22
- return null;
23
- }
24
- const firstPass = matches[1];
20
+ const firstPass = func.toString().match(regex)?.[1];
21
+ if (firstPass === undefined) return null;
25
22
  // Needed because the RegExp doesn't handle the last '}'.
26
23
  const secondPass = (firstPass.match(/{/g) || []).length === (firstPass.match(/}/g) || []).length - 1 ? firstPass.slice(0, firstPass.lastIndexOf('}')) : firstPass;
27
24
  return secondPass;