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.
- package/dist/.build-complete +1 -1
- package/dist/.tsbuildinfo +1 -0
- package/dist/AnyComponent.d.ts.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +11 -8
- package/dist/DomPointer.js +1 -1
- package/dist/DomRegion.js +2 -2
- package/dist/Framework.js +1 -1
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/Instance/Instance.js +1 -1
- package/dist/RenderedContentNode.d.ts.map +1 -1
- package/dist/RenderedContentNode.js +2 -1
- package/dist/Sass.d.ts.map +1 -1
- package/dist/Sass.js +1 -0
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +4 -3
- package/dist/Servers/ProdServer.js +1 -1
- package/dist/Servers/StaticSiteServer.js +1 -1
- package/dist/Servers/loadEnvsDev.d.ts +1 -1
- package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
- package/dist/Servers/loadEnvsDev.js +4 -2
- package/dist/Servers/routing.d.ts.map +1 -1
- package/dist/Servers/routing.js +1 -1
- package/dist/Store/Store.js +1 -1
- package/dist/Store/TypeSafeStore.js +1 -1
- package/dist/Store/makeStore.js +1 -1
- package/dist/Store/registerStore.js +1 -1
- package/dist/TElement.js +1 -1
- package/dist/TungstenApp.js +6 -2
- package/dist/api/getExport.d.ts.map +1 -1
- package/dist/api/getExport.js +1 -0
- package/dist/babelPlugins/BabelTransformBindDirect.js +2 -0
- package/dist/babelPlugins/BabelTransformBindVar.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentState.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentStyles.js +5 -4
- package/dist/babelPlugins/BabelTransformCssImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformCssImports.js +2 -2
- package/dist/babelPlugins/BabelTransformDependencyImportsOld.js +1 -1
- package/dist/babelPlugins/BabelTransformDeproxyState.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +10 -5
- package/dist/babelPlugins/BabelTransformRemoveBlocks.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.js +2 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.js +2 -1
- package/dist/bin/args.js +1 -1
- package/dist/bin/commands/build.js +1 -1
- package/dist/bin/commands/compileSimplePackage.js +1 -0
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +11 -3
- package/dist/bin/vendorHook.d.ts +3 -0
- package/dist/bin/vendorHook.d.ts.map +1 -0
- package/dist/bin/vendorHook.js +34 -0
- package/dist/browserStorage.js +4 -2
- package/dist/build/babel.user.common.config.d.ts +2 -0
- package/dist/build/babel.user.common.config.d.ts.map +1 -1
- package/dist/build/babel.user.common.config.js +10 -4
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +40 -27
- package/dist/build/compileStyles.js +4 -4
- package/dist/build/copyAssets.js +3 -3
- package/dist/build/copyPublicFiles.js +3 -3
- package/dist/build/frameworkStylesheets.js +1 -1
- package/dist/build/getAllSxyClientModules.d.ts.map +1 -1
- package/dist/build/getAllSxyClientModules.js +4 -28
- package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
- package/dist/build/rollupExtractComponentStylesheets.js +1 -1
- package/dist/build/sassImportParser.js +2 -2
- package/dist/build/tallyBabel.d.ts +3 -0
- package/dist/build/tallyBabel.d.ts.map +1 -0
- package/dist/build/tallyBabel.js +11 -0
- package/dist/clone.js +4 -4
- package/dist/compat/context.d.ts.map +1 -1
- package/dist/compat/types.d.ts.map +1 -1
- package/dist/componentProxyHandlers.d.ts.map +1 -1
- package/dist/componentProxyHandlers.js +5 -9
- package/dist/components/Stylesheet.d.ts +1 -2
- package/dist/components/Stylesheet.d.ts.map +1 -1
- package/dist/components/Stylesheet.js +1 -1
- package/dist/components/bindable/BindableCheckbox.d.ts.map +1 -1
- package/dist/components/bindable/BindableInput.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputTypedLegacy.d.ts.map +1 -1
- package/dist/components/bindable/BindableRadio.d.ts.map +1 -1
- package/dist/components/bindable/BindableTextarea.d.ts.map +1 -1
- package/dist/components/library/RichTextEditor/RichTextEditor.js +2 -2
- package/dist/components/library/RichTextEditor/contentTree.js +1 -1
- package/dist/concat.d.ts.map +1 -1
- package/dist/concat.js +2 -2
- package/dist/copy.d.ts.map +1 -1
- package/dist/createRoutes.d.ts +1 -1
- package/dist/createRoutes.d.ts.map +1 -1
- package/dist/env/Env.js +2 -2
- package/dist/env/getEnvSchemas.d.ts +2 -2
- package/dist/env/getEnvSchemas.d.ts.map +1 -1
- package/dist/env/getEnvSchemas.js +7 -5
- package/dist/env/windowGlobalEnvStatement.d.ts.map +1 -1
- package/dist/findProjectDir.d.ts.map +1 -1
- package/dist/findProjectDir.js +18 -4
- package/dist/findUserConfig.js +2 -2
- package/dist/foreach.js +1 -0
- package/dist/frameworkConfigSchema.js +2 -2
- package/dist/getComponent.d.ts.map +1 -1
- package/dist/getComponentDev.d.ts.map +1 -1
- package/dist/getRoutes.d.ts.map +1 -1
- package/dist/getRoutes.js +13 -22
- package/dist/getRoutesDevs.d.ts.map +1 -1
- package/dist/getStackTrace.js +1 -1
- package/dist/glob.d.ts +5 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +103 -0
- package/dist/helpers/getFetchCompatibleHeaders.js +2 -2
- package/dist/hmr/applyHmrModule.js +5 -5
- package/dist/hmr/componentIdentity.js +1 -1
- package/dist/hmr/instanceRegistry.js +2 -2
- package/dist/hooks/useReducer.d.ts.map +1 -1
- package/dist/hooks/useState.d.ts.map +1 -1
- package/dist/hooks/useState.js +2 -8
- package/dist/hydrate/hydrate.d.ts +1 -1
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +26 -24
- package/dist/hydrate/reconcileHydratedAttributes.js +2 -2
- package/dist/makeFinalConfig.d.ts.map +1 -1
- package/dist/makeFinalConfig.js +2 -2
- package/dist/markOptionSelected.js +1 -1
- package/dist/mergeConfigs.d.ts.map +1 -1
- package/dist/mergeConfigs.js +11 -2
- package/dist/mutatingFunctions.js +3 -3
- package/dist/postcssPlugins/TransformCssNames.js +2 -2
- package/dist/rawHtml/parseHtml.js +1 -1
- package/dist/render/componentNodeToRenderingTree.d.ts.map +1 -1
- package/dist/render/componentNodeToRenderingTree.js +6 -17
- package/dist/render/contentToHtml.d.ts.map +1 -1
- package/dist/render/contentToHtml.js +1 -1
- package/dist/render/getFunctionBodyAsString.d.ts.map +1 -1
- package/dist/render/getFunctionBodyAsString.js +2 -5
- package/dist/render/processProps.js +2 -2
- package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
- package/dist/render/rootToHtml.d.ts.map +1 -1
- package/dist/routing/Route.js +1 -1
- package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
- package/dist/routing/RoutesWithSafeParams.js +1 -1
- package/dist/routing/WebRedirect.d.ts.map +1 -1
- package/dist/routing/compareRequestToRegex.js +2 -2
- package/dist/routing/getPathPriority.js +1 -1
- package/dist/serverRpc.d.ts.map +1 -1
- package/dist/slash.d.ts +2 -0
- package/dist/slash.d.ts.map +1 -0
- package/dist/slash.js +5 -0
- package/dist/spawnShellCommand.js +1 -1
- package/dist/staticGen/staticGen.d.ts.map +1 -1
- package/dist/staticGen/staticGen.js +9 -7
- package/dist/staticGen/staticGenFunctions.js +1 -1
- package/dist/style/jssToCss.d.ts.map +1 -1
- package/dist/style/jssToCss.js +11 -9
- package/dist/style/unusedStyles.d.ts.map +1 -1
- package/dist/testing/host.js +11 -11
- package/dist/testing/hydrateTestApp.d.ts.map +1 -1
- package/dist/testing/hydrateTestApp.js +9 -9
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/installTestStyleProcessors.js +1 -1
- package/dist/testing/loadEnv.d.ts +4 -1
- package/dist/testing/loadEnv.d.ts.map +1 -1
- package/dist/testing/loadEnv.js +2 -2
- package/dist/testing/temp/componentPackageMock.js +3 -3
- package/dist/timeProfiler.d.ts +4 -0
- package/dist/timeProfiler.d.ts.map +1 -1
- package/dist/timeProfiler.js +16 -0
- package/dist/todo.js +2 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +17 -14
- package/dist/update/integrateUpdateVdomPrebuild.js +5 -5
- package/dist/watch.js +2 -2
- package/package.json +10 -29
- package/types/modules.d.ts +0 -1
- package/vendor/babel-core.js +26 -0
- package/vendor/babel-parser.js +9 -0
- package/vendor/babel-plugin-syntax-import-assertions.js +50 -0
- package/vendor/babel-preset-react.js +872 -0
- package/vendor/babel-preset-typescript.js +26 -0
- package/vendor/babel-types.js +9 -0
- package/vendor/chalk-extensions.js +1994 -0
- package/vendor/chalk.js +647 -0
- package/vendor/chokidar.js +6889 -0
- package/vendor/chunk-1TN2rK3j.js +1218 -0
- package/vendor/chunk-1UuLTU0U.js +34 -0
- package/vendor/chunk-B_NeooyV.js +86 -0
- package/vendor/chunk-C12hSZn7.js +88 -0
- package/vendor/chunk-C3YkUGz5.js +19 -0
- package/vendor/chunk-C3fcZDjl.js +41964 -0
- package/vendor/chunk-C9FSKeSx.js +14603 -0
- package/vendor/chunk-CPArXGxa.js +14623 -0
- package/vendor/cjs-module-lexer.js +6 -0
- package/vendor/dotenv.js +412 -0
- package/vendor/express.js +40577 -0
- package/vendor/import-meta-resolve.js +2201 -0
- package/vendor/manifest.json +29 -0
- package/vendor/postcss.js +8546 -0
- package/vendor/serialize-javascript.js +293 -0
- package/vendor/sxy-lib-arrays.js +113 -0
- package/vendor/sxy-lib-object-copy.js +1781 -0
- package/vendor/sxy-lib-objects.js +156 -0
- package/vendor/sxy-lib-promises.js +47 -0
- package/vendor/sxy-package-investigator.js +202 -0
- package/vendor/valibot.js +7664 -0
- package/dist/Servers/hono/DevServerHono.d.ts +0 -2
- package/dist/Servers/hono/DevServerHono.d.ts.map +0 -1
- package/dist/Servers/hono/DevServerHono.js +0 -423
- package/dist/Servers/hono/ProdServerHono.d.ts +0 -2
- package/dist/Servers/hono/ProdServerHono.d.ts.map +0 -1
- package/dist/Servers/hono/ProdServerHono.js +0 -220
- package/dist/Servers/hono/TungstenServerHono.d.ts +0 -6
- package/dist/Servers/hono/TungstenServerHono.d.ts.map +0 -1
- package/dist/Servers/hono/TungstenServerHono.js +0 -36
- package/dist/api/ApiEndpointHono.d.ts +0 -3
- package/dist/api/ApiEndpointHono.d.ts.map +0 -1
- package/dist/api/ApiEndpointHono.js +0 -1
- package/dist/api/ApiRouteHono.d.ts +0 -7
- package/dist/api/ApiRouteHono.d.ts.map +0 -1
- package/dist/api/ApiRouteHono.js +0 -1
- package/dist/api/ApiRoutesHono.d.ts +0 -5
- package/dist/api/ApiRoutesHono.d.ts.map +0 -1
- package/dist/api/ApiRoutesHono.js +0 -1
- package/dist/api/getApiRoutesHono.d.ts +0 -6
- package/dist/api/getApiRoutesHono.d.ts.map +0 -1
- package/dist/api/getApiRoutesHono.js +0 -14
- package/dist/build/compilePackages.d.ts +0 -2
- package/dist/build/compilePackages.d.ts.map +0 -1
- package/dist/build/compilePackages.js +0 -89
- package/dist/build/findRequiredUserModule.d.ts +0 -2
- package/dist/build/findRequiredUserModule.d.ts.map +0 -1
- package/dist/build/findRequiredUserModule.js +0 -36
- package/dist/build/processPackage.d.ts +0 -4
- package/dist/build/processPackage.d.ts.map +0 -1
- package/dist/build/processPackage.js +0 -91
- package/dist/build/tallyBabelPlugins.d.ts +0 -3
- package/dist/build/tallyBabelPlugins.d.ts.map +0 -1
- package/dist/build/tallyBabelPlugins.js +0 -63
- package/dist/testing/loadEnvSetup.d.ts +0 -2
- package/dist/testing/loadEnvSetup.d.ts.map +0 -1
- package/dist/testing/loadEnvSetup.js +0 -7
- 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
46
|
-
: await hotSwapClassComponent(anyComponent, NewType); // eslint-disable-line
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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":"
|
|
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":"
|
|
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"}
|
package/dist/hooks/useState.js
CHANGED
|
@@ -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
|
|
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
|
|
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;
|
|
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"}
|
package/dist/hydrate/hydrate.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
713
|
+
bindObject[bindKey] = event.target.value; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
712
714
|
};
|
|
713
715
|
//}
|
|
714
|
-
// eslint-disable-next-line
|
|
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
|
|
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
|
|
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":"
|
|
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"}
|
package/dist/makeFinalConfig.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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":"
|
|
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"}
|
package/dist/mergeConfigs.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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;
|
|
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
|
|
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,
|
|
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
|
|
21
|
-
if (
|
|
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;
|