tungsten 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-complete +1 -0
- package/dist/Framework.d.ts +2 -0
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +68 -57
- package/dist/FrameworkConfig.d.ts +2 -0
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +18 -1
- package/dist/Instance/InstanceConfig.d.ts +1 -0
- package/dist/Instance/InstanceConfig.d.ts.map +1 -1
- package/dist/PopMessage.type.d.ts +6 -0
- package/dist/PopMessage.type.d.ts.map +1 -0
- package/dist/PopMessage.type.js +1 -0
- package/dist/Servers/DevServer.d.ts +2 -0
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +84 -8
- package/dist/Servers/MatchedRouteInfo.d.ts +1 -1
- package/dist/Servers/MatchedRouteInfo.d.ts.map +1 -1
- package/dist/Servers/ProdServer.d.ts +1 -0
- package/dist/Servers/ProdServer.d.ts.map +1 -1
- package/dist/Servers/ProdServer.js +79 -5
- package/dist/Servers/hono/DevServerHono.js +25 -29
- package/dist/Servers/hono/ProdServerHono.js +49 -142
- package/dist/Servers/hono/TungstenServerHono.d.ts +1 -1
- package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -1
- package/dist/Servers/hono/TungstenServerHono.js +12 -29
- package/dist/Servers/routing.d.ts.map +1 -1
- package/dist/Servers/routing.js +10 -6
- package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +0 -3
- package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -1
- package/dist/Servers/tungstenCorePrivateEnvSchema.js +3 -3
- package/dist/Servers/tungstenCorePublicEnvSchema.d.ts +8 -0
- package/dist/Servers/tungstenCorePublicEnvSchema.d.ts.map +1 -0
- package/dist/Servers/tungstenCorePublicEnvSchema.js +14 -0
- package/dist/Store/InternalStoreSchema.d.ts +2 -0
- package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
- package/dist/Store/InternalStoreSchema.js +1 -0
- package/dist/api/Request.d.ts +1 -1
- package/dist/api/Request.d.ts.map +1 -1
- package/dist/api/Response.d.ts +1 -1
- package/dist/api/Response.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTypes.d.ts +2 -2
- package/dist/babelPlugins/BabelTypes.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTypes.js +0 -1
- package/dist/bin/commands/build.d.ts.map +1 -1
- package/dist/bin/commands/build.js +3 -0
- package/dist/bin/commands/dev.d.ts.map +1 -1
- package/dist/bin/commands/dev.js +15 -4
- package/dist/bin/commands/devmon.d.ts +2 -0
- package/dist/bin/commands/devmon.d.ts.map +1 -0
- package/dist/bin/commands/devmon.js +66 -0
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +6 -0
- package/dist/booleanAttributeValue.d.ts +21 -0
- package/dist/booleanAttributeValue.d.ts.map +1 -0
- package/dist/booleanAttributeValue.js +23 -0
- package/dist/build/compileJavascript.js +1 -1
- package/dist/build/compileUserApp.d.ts +2 -1
- package/dist/build/compileUserApp.d.ts.map +1 -1
- package/dist/build/compileUserApp.js +8 -7
- package/dist/build/createInstanceConfigFile.js +1 -1
- package/dist/compat/types.d.ts +1 -1
- package/dist/compat/types.d.ts.map +1 -1
- package/dist/components/PopMessages.d.ts +12 -0
- package/dist/components/PopMessages.d.ts.map +1 -0
- package/dist/components/PopMessages.js +45 -0
- package/dist/defaultConfig.d.ts +1 -0
- package/dist/defaultConfig.d.ts.map +1 -1
- package/dist/defaultConfig.js +2 -1
- package/dist/env/Interfaces.d.ts +2 -1
- package/dist/env/Interfaces.d.ts.map +1 -1
- package/dist/env/getEnvSchemas.d.ts +1 -1
- package/dist/env/getEnvSchemas.d.ts.map +1 -1
- package/dist/env/publicEnv.d.ts.map +1 -1
- package/dist/env/publicEnv.js +4 -1
- package/dist/frameworkConfigSchema.d.ts +4 -0
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +2 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useInstance.d.ts +3 -0
- package/dist/hooks/useInstance.d.ts.map +1 -0
- package/dist/hooks/useInstance.js +4 -0
- package/dist/hydrate/hydrate.d.ts +6 -4
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +51 -13
- package/dist/hydrate/reconcileHydratedAttributes.d.ts.map +1 -1
- package/dist/hydrate/reconcileHydratedAttributes.js +4 -3
- package/dist/hydrate/renderHydrationMismatchBanner.d.ts +7 -0
- package/dist/hydrate/renderHydrationMismatchBanner.d.ts.map +1 -0
- package/dist/hydrate/renderHydrationMismatchBanner.js +69 -0
- package/dist/indexInner.d.ts +8 -0
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +7 -1
- package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -1
- package/dist/makeInstanceConfigFromFrameworkConfig.js +2 -1
- package/dist/pop.d.ts +10 -0
- package/dist/pop.d.ts.map +1 -0
- package/dist/pop.js +49 -0
- package/dist/rawHtml/filterContentNode.d.ts +20 -0
- package/dist/rawHtml/filterContentNode.d.ts.map +1 -0
- package/dist/rawHtml/filterContentNode.js +96 -0
- package/dist/rawHtml/parseHtml.d.ts +14 -0
- package/dist/rawHtml/parseHtml.d.ts.map +1 -1
- package/dist/rawHtml/parseHtml.js +4 -4
- package/dist/rawHtml/sanitizeHtml.d.ts +17 -0
- package/dist/rawHtml/sanitizeHtml.d.ts.map +1 -0
- package/dist/rawHtml/sanitizeHtml.js +19 -0
- package/dist/render/HeadData.d.ts +1 -0
- package/dist/render/HeadData.d.ts.map +1 -1
- package/dist/render/contentNodeToHtml.d.ts +18 -0
- package/dist/render/contentNodeToHtml.d.ts.map +1 -0
- package/dist/render/contentNodeToHtml.js +66 -0
- package/dist/render/contentToHtml.d.ts.map +1 -1
- package/dist/render/contentToHtml.js +2 -1
- package/dist/render/processHead.d.ts.map +1 -1
- package/dist/render/processHead.js +8 -2
- package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
- package/dist/render/renderingTreeToHtml.js +8 -1
- package/dist/routing/ErrorRouteType.d.ts +6 -0
- package/dist/routing/ErrorRouteType.d.ts.map +1 -0
- package/dist/routing/ErrorRouteType.js +1 -0
- package/dist/routing/RouteTypes.d.ts +2 -1
- package/dist/routing/RouteTypes.d.ts.map +1 -1
- package/dist/routing/Routes.d.ts +5 -0
- package/dist/routing/Routes.d.ts.map +1 -1
- package/dist/routing/TungstenErrorInfo.d.ts +6 -0
- package/dist/routing/TungstenErrorInfo.d.ts.map +1 -0
- package/dist/routing/TungstenErrorInfo.js +6 -0
- package/dist/style/styleContentSxy.js +21 -0
- package/dist/testing/hydrateTestApp.d.ts +38 -0
- package/dist/testing/hydrateTestApp.d.ts.map +1 -0
- package/dist/testing/hydrateTestApp.js +242 -0
- package/dist/testing/index.d.ts +4 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +16 -2
- package/dist/timeProfiler.d.ts +6 -0
- package/dist/timeProfiler.d.ts.map +1 -0
- package/dist/timeProfiler.js +31 -0
- package/dist/update/integrateUpdateVdom.d.ts +11 -0
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +9 -3
- package/dist/warnOnFrameworkChange.d.ts.map +1 -1
- package/dist/warnOnFrameworkChange.js +8 -8
- package/package.json +18 -16
- package/dist/FunctionComponentStandIn.sxyt.d.ts +0 -2
- package/dist/FunctionComponentStandIn.sxyt.d.ts.map +0 -1
- package/dist/FunctionComponentStandIn.sxyt.js +0 -52
- package/dist/Instance/gotoRedirect.sxyt.d.ts +0 -2
- package/dist/Instance/gotoRedirect.sxyt.d.ts.map +0 -1
- package/dist/Instance/gotoRedirect.sxyt.js +0 -148
- package/dist/Instance/runTrackedWork.sxyt.d.ts +0 -2
- package/dist/Instance/runTrackedWork.sxyt.d.ts.map +0 -1
- package/dist/Instance/runTrackedWork.sxyt.js +0 -35
- package/dist/Servers/devErrorPageAutoRetry.sxyt.d.ts +0 -2
- package/dist/Servers/devErrorPageAutoRetry.sxyt.d.ts.map +0 -1
- package/dist/Servers/devErrorPageAutoRetry.sxyt.js +0 -117
- package/dist/_client/cjsHelpers.sxyt.d.ts +0 -2
- package/dist/_client/cjsHelpers.sxyt.d.ts.map +0 -1
- package/dist/_client/cjsHelpers.sxyt.js +0 -45
- package/dist/auth/passwordHashing.sxyt.d.ts +0 -2
- package/dist/auth/passwordHashing.sxyt.d.ts.map +0 -1
- package/dist/auth/passwordHashing.sxyt.js +0 -46
- package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts +0 -2
- package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts.map +0 -1
- package/dist/auth/ref/checkPasswordResetToken.sxyt.js +0 -40
- package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts +0 -2
- package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts.map +0 -1
- package/dist/auth/ref/createPasswordResetToken.sxyt.js +0 -10
- package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.d.ts +0 -2
- package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.d.ts.map +0 -1
- package/dist/babelPlugins/BabelAddDevCacheBust.sxyt.js +0 -138
- package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts +0 -2
- package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts.map +0 -1
- package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.js +0 -108
- package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts +0 -2
- package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts.map +0 -1
- package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.js +0 -104
- package/dist/bin/commands/compile.sxyt.d.ts +0 -2
- package/dist/bin/commands/compile.sxyt.d.ts.map +0 -1
- package/dist/bin/commands/compile.sxyt.js +0 -255
- package/dist/build/modifySassImports.sxyt.d.ts +0 -2
- package/dist/build/modifySassImports.sxyt.d.ts.map +0 -1
- package/dist/build/modifySassImports.sxyt.js +0 -55
- package/dist/build/sassImportParser.sxyt.d.ts +0 -2
- package/dist/build/sassImportParser.sxyt.d.ts.map +0 -1
- package/dist/build/sassImportParser.sxyt.js +0 -110
- package/dist/build/scssImportParserChatgpt.sxyt.d.ts +0 -2
- package/dist/build/scssImportParserChatgpt.sxyt.d.ts.map +0 -1
- package/dist/build/scssImportParserChatgpt.sxyt.js +0 -120
- package/dist/clone.sxyt.d.ts +0 -2
- package/dist/clone.sxyt.d.ts.map +0 -1
- package/dist/clone.sxyt.js +0 -24
- package/dist/componentProxyHandlers.sxyt.d.ts +0 -2
- package/dist/componentProxyHandlers.sxyt.d.ts.map +0 -1
- package/dist/componentProxyHandlers.sxyt.js +0 -130
- package/dist/components/RawHtml.sxyt.d.ts +0 -2
- package/dist/components/RawHtml.sxyt.d.ts.map +0 -1
- package/dist/components/RawHtml.sxyt.js +0 -104
- package/dist/components/bindable/BindableSelect.sxyt.d.ts +0 -2
- package/dist/components/bindable/BindableSelect.sxyt.d.ts.map +0 -1
- package/dist/components/bindable/BindableSelect.sxyt.js +0 -186
- package/dist/env/injectEnv.sxyt.d.ts +0 -2
- package/dist/env/injectEnv.sxyt.d.ts.map +0 -1
- package/dist/env/injectEnv.sxyt.js +0 -20
- package/dist/env/parseEnv.sxyt.d.ts +0 -2
- package/dist/env/parseEnv.sxyt.d.ts.map +0 -1
- package/dist/env/parseEnv.sxyt.js +0 -11
- package/dist/findProjectDir.sxyt.d.ts +0 -2
- package/dist/findProjectDir.sxyt.d.ts.map +0 -1
- package/dist/findProjectDir.sxyt.js +0 -82
- package/dist/hmr/applyHmrModule.sxyt.d.ts +0 -2
- package/dist/hmr/applyHmrModule.sxyt.d.ts.map +0 -1
- package/dist/hmr/applyHmrModule.sxyt.js +0 -182
- package/dist/hmr/instanceRegistry.sxyt.d.ts +0 -2
- package/dist/hmr/instanceRegistry.sxyt.d.ts.map +0 -1
- package/dist/hmr/instanceRegistry.sxyt.js +0 -24
- package/dist/hmr/refreshStylesheets.sxyt.d.ts +0 -2
- package/dist/hmr/refreshStylesheets.sxyt.d.ts.map +0 -1
- package/dist/hmr/refreshStylesheets.sxyt.js +0 -46
- package/dist/hydrate/hydrate.sxyt.d.ts +0 -2
- package/dist/hydrate/hydrate.sxyt.d.ts.map +0 -1
- package/dist/hydrate/hydrate.sxyt.js +0 -302
- package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts +0 -2
- package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts.map +0 -1
- package/dist/hydrate/reconcileHydratedAttributes.sxyt.js +0 -190
- package/dist/importDevModuleWithRetry.sxyt.d.ts +0 -2
- package/dist/importDevModuleWithRetry.sxyt.d.ts.map +0 -1
- package/dist/importDevModuleWithRetry.sxyt.js +0 -104
- package/dist/innerHtmlFromProps.sxyt.d.ts +0 -2
- package/dist/innerHtmlFromProps.sxyt.d.ts.map +0 -1
- package/dist/innerHtmlFromProps.sxyt.js +0 -99
- package/dist/postcssPlugins/parseSelectors.sxyt.d.ts +0 -2
- package/dist/postcssPlugins/parseSelectors.sxyt.d.ts.map +0 -1
- package/dist/postcssPlugins/parseSelectors.sxyt.js +0 -62
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts +0 -2
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts.map +0 -1
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.js +0 -155
- package/dist/rawHtml/parseHtml.sxyt.d.ts +0 -2
- package/dist/rawHtml/parseHtml.sxyt.d.ts.map +0 -1
- package/dist/rawHtml/parseHtml.sxyt.js +0 -239
- package/dist/render/getFunctionBodyAsString.sxyt.d.ts +0 -2
- package/dist/render/getFunctionBodyAsString.sxyt.d.ts.map +0 -1
- package/dist/render/getFunctionBodyAsString.sxyt.js +0 -37
- package/dist/render/processHead.sxyt.d.ts +0 -2
- package/dist/render/processHead.sxyt.d.ts.map +0 -1
- package/dist/render/processHead.sxyt.js +0 -93
- package/dist/render/processProps.sxyt.d.ts +0 -2
- package/dist/render/processProps.sxyt.d.ts.map +0 -1
- package/dist/render/processProps.sxyt.js +0 -90
- package/dist/routing/compareRequestToRegex.sxyt.d.ts +0 -2
- package/dist/routing/compareRequestToRegex.sxyt.d.ts.map +0 -1
- package/dist/routing/compareRequestToRegex.sxyt.js +0 -65
- package/dist/routing/getPathPriority.sxyt.d.ts +0 -2
- package/dist/routing/getPathPriority.sxyt.d.ts.map +0 -1
- package/dist/routing/getPathPriority.sxyt.js +0 -24
- package/dist/routing/matchPath.sxyt.d.ts +0 -2
- package/dist/routing/matchPath.sxyt.d.ts.map +0 -1
- package/dist/routing/matchPath.sxyt.js +0 -41
- package/dist/routing/patternToRegex.sxyt.d.ts +0 -2
- package/dist/routing/patternToRegex.sxyt.d.ts.map +0 -1
- package/dist/routing/patternToRegex.sxyt.js +0 -69
- package/dist/routing/splitRequest.sxyt.d.ts +0 -2
- package/dist/routing/splitRequest.sxyt.d.ts.map +0 -1
- package/dist/routing/splitRequest.sxyt.js +0 -47
- package/dist/style/jssToCss.sxyt.d.ts +0 -2
- package/dist/style/jssToCss.sxyt.d.ts.map +0 -1
- package/dist/style/jssToCss.sxyt.js +0 -17
- package/dist/testing/createTestApp.sxyt.d.ts +0 -2
- package/dist/testing/createTestApp.sxyt.d.ts.map +0 -1
- package/dist/testing/createTestApp.sxyt.js +0 -470
- package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts +0 -2
- package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts.map +0 -1
- package/dist/testing/ensureTestEnvLoaded.sxyt.js +0 -20
- package/dist/update/hotSwap.sxyt.d.ts +0 -2
- package/dist/update/hotSwap.sxyt.d.ts.map +0 -1
- package/dist/update/hotSwap.sxyt.js +0 -252
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
import { expect } from 'chai';
|
|
5
|
-
import { Window } from 'happy-dom';
|
|
6
|
-
import { describe } from 'sxy-test-runner';
|
|
7
|
-
import { TungstenSimpleComponent } from "../Components.js";
|
|
8
|
-
import { createTestApp } from "../testing/index.js";
|
|
9
|
-
import { hotSwapFunctionComponent, hotSwapClassComponent } from "./integrateUpdateVdom.js";
|
|
10
|
-
import { TungstenStatefulComponent } from "../Components.js";
|
|
11
|
-
import { WideRenderedContentNodeIsComponent } from "../RenderedContentNode.js";
|
|
12
|
-
import { AnyComponentIsFunctionComponentStandIn } from "../AnyComponent.js";
|
|
13
|
-
import { jsxs as _jsxs, jsx as _jsx } from "tungsten/jsxRuntime.js";
|
|
14
|
-
const Greeting = ({
|
|
15
|
-
name
|
|
16
|
-
}) => {
|
|
17
|
-
return _jsxs("div", {
|
|
18
|
-
className: "greeting",
|
|
19
|
-
children: ["Hello ", name]
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
describe('hotSwapFunctionComponent', ({
|
|
23
|
-
it
|
|
24
|
-
}) => {
|
|
25
|
-
it('produces the same markup a normal render does - no leaked "children" attribute', async () => {
|
|
26
|
-
const window = new Window();
|
|
27
|
-
const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
|
|
28
|
-
class Root extends TungstenSimpleComponent {
|
|
29
|
-
constructor(...args) {
|
|
30
|
-
super(...args);
|
|
31
|
-
_defineProperty(this, "content", () => _jsx(Greeting, {
|
|
32
|
-
name: "Ada"
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const testApp = await createTestApp(Root, {
|
|
37
|
-
document
|
|
38
|
-
});
|
|
39
|
-
const before = testApp.container.innerHTML;
|
|
40
|
-
const wrapper = testApp.component.__currentContent;
|
|
41
|
-
if (!WideRenderedContentNodeIsComponent(wrapper) || !AnyComponentIsFunctionComponentStandIn(wrapper.element)) {
|
|
42
|
-
throw new Error('expected the root to directly render a single function component');
|
|
43
|
-
}
|
|
44
|
-
const oldElement = wrapper.element;
|
|
45
|
-
// a second, distinct function reference standing in for "the recompiled version"
|
|
46
|
-
const NewGreeting = ({
|
|
47
|
-
name
|
|
48
|
-
}) => {
|
|
49
|
-
return _jsxs("div", {
|
|
50
|
-
className: "greeting",
|
|
51
|
-
children: ["Hello ", name]
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const swapped = await hotSwapFunctionComponent(oldElement, NewGreeting);
|
|
55
|
-
expect(swapped).to.not.equal(null);
|
|
56
|
-
const after = testApp.container.innerHTML;
|
|
57
|
-
expect(before).to.not.contain('children=');
|
|
58
|
-
expect(after).to.not.contain('children=');
|
|
59
|
-
expect(after).to.equal(before);
|
|
60
|
-
await testApp.unmount();
|
|
61
|
-
});
|
|
62
|
-
it('actually renders the NEW function\'s output, not the old one', async () => {
|
|
63
|
-
const window = new Window();
|
|
64
|
-
const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
|
|
65
|
-
class Root extends TungstenSimpleComponent {
|
|
66
|
-
constructor(...args) {
|
|
67
|
-
super(...args);
|
|
68
|
-
_defineProperty(this, "content", () => _jsx(Greeting, {
|
|
69
|
-
name: "Ada"
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const testApp = await createTestApp(Root, {
|
|
74
|
-
document
|
|
75
|
-
});
|
|
76
|
-
const wrapper = testApp.component.__currentContent;
|
|
77
|
-
if (!WideRenderedContentNodeIsComponent(wrapper) || !AnyComponentIsFunctionComponentStandIn(wrapper.element)) {
|
|
78
|
-
throw new Error('expected the root to directly render a single function component');
|
|
79
|
-
}
|
|
80
|
-
const oldElement = wrapper.element;
|
|
81
|
-
// deliberately DIFFERENT markup - simulating an actual source edit
|
|
82
|
-
const NewGreeting = ({
|
|
83
|
-
name
|
|
84
|
-
}) => {
|
|
85
|
-
return _jsxs("div", {
|
|
86
|
-
className: "greeting",
|
|
87
|
-
children: ["Hi there ", name]
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
const swapped = await hotSwapFunctionComponent(oldElement, NewGreeting);
|
|
91
|
-
expect(swapped).to.not.equal(null);
|
|
92
|
-
expect(testApp.container.innerHTML).to.contain('Hi there Ada');
|
|
93
|
-
expect(testApp.container.innerHTML).to.not.contain('Hello Ada');
|
|
94
|
-
await testApp.unmount();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
describe('hotSwapClassComponent', ({
|
|
98
|
-
it
|
|
99
|
-
}) => {
|
|
100
|
-
it('hot-swaps a page-level component with several top-level children (h1, select/option, button)', async () => {
|
|
101
|
-
class Page extends TungstenStatefulComponent {
|
|
102
|
-
constructor(...args) {
|
|
103
|
-
super(...args);
|
|
104
|
-
_defineProperty(this, "state", {
|
|
105
|
-
value: 5
|
|
106
|
-
});
|
|
107
|
-
_defineProperty(this, "content", () => _jsxs("div", {
|
|
108
|
-
children: [_jsx("h1", {
|
|
109
|
-
children: "Welcome"
|
|
110
|
-
}), _jsx("p", {
|
|
111
|
-
children: "one"
|
|
112
|
-
}), _jsx("p", {
|
|
113
|
-
children: "two"
|
|
114
|
-
}), _jsxs("select", {
|
|
115
|
-
value: this.state.value,
|
|
116
|
-
children: [_jsx("option", {
|
|
117
|
-
children: " 2 "
|
|
118
|
-
}), _jsx("option", {
|
|
119
|
-
children: " 4 "
|
|
120
|
-
}), _jsx("option", {
|
|
121
|
-
children: _jsx("span", {
|
|
122
|
-
children: "5"
|
|
123
|
-
})
|
|
124
|
-
}), _jsx("option", {
|
|
125
|
-
children: " 8 "
|
|
126
|
-
})]
|
|
127
|
-
}), _jsx("button", {
|
|
128
|
-
onClick: () => {
|
|
129
|
-
this.state.value = 8;
|
|
130
|
-
},
|
|
131
|
-
children: "set"
|
|
132
|
-
})]
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const window = new Window();
|
|
137
|
-
const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
|
|
138
|
-
class Root extends TungstenSimpleComponent {
|
|
139
|
-
constructor(...args) {
|
|
140
|
-
super(...args);
|
|
141
|
-
_defineProperty(this, "content", () => _jsx(Page, {}));
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const testApp = await createTestApp(Root, {
|
|
145
|
-
document
|
|
146
|
-
});
|
|
147
|
-
const wrapper = testApp.component.__currentContent;
|
|
148
|
-
if (!WideRenderedContentNodeIsComponent(wrapper) || AnyComponentIsFunctionComponentStandIn(wrapper.element)) {
|
|
149
|
-
throw new Error('expected the root to directly render a single class component');
|
|
150
|
-
}
|
|
151
|
-
const oldElement = wrapper.element;
|
|
152
|
-
class NewPage extends TungstenStatefulComponent {
|
|
153
|
-
constructor(...args) {
|
|
154
|
-
super(...args);
|
|
155
|
-
_defineProperty(this, "state", {
|
|
156
|
-
value: 5
|
|
157
|
-
});
|
|
158
|
-
_defineProperty(this, "content", () => _jsxs("div", {
|
|
159
|
-
children: [_jsx("h1", {
|
|
160
|
-
children: "Welcome (edited)"
|
|
161
|
-
}), _jsx("p", {
|
|
162
|
-
children: "one"
|
|
163
|
-
}), _jsx("p", {
|
|
164
|
-
children: "two"
|
|
165
|
-
}), _jsxs("select", {
|
|
166
|
-
value: this.state.value,
|
|
167
|
-
children: [_jsx("option", {
|
|
168
|
-
children: " 2 "
|
|
169
|
-
}), _jsx("option", {
|
|
170
|
-
children: " 4 "
|
|
171
|
-
}), _jsx("option", {
|
|
172
|
-
children: _jsx("span", {
|
|
173
|
-
children: "5"
|
|
174
|
-
})
|
|
175
|
-
}), _jsx("option", {
|
|
176
|
-
children: " 8 "
|
|
177
|
-
})]
|
|
178
|
-
}), _jsx("button", {
|
|
179
|
-
onClick: () => {
|
|
180
|
-
this.state.value = 8;
|
|
181
|
-
},
|
|
182
|
-
children: "set"
|
|
183
|
-
})]
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const swapped = await hotSwapClassComponent(oldElement, NewPage);
|
|
188
|
-
expect(swapped).to.not.equal(null);
|
|
189
|
-
expect(testApp.container.innerHTML).to.contain('Welcome (edited)');
|
|
190
|
-
await testApp.unmount();
|
|
191
|
-
});
|
|
192
|
-
it('surfaces a clear error when swapped-in content references an undefined component', async () => {
|
|
193
|
-
// Investigating a "TungstenError: new DomRegion() error: first child is undefined" crash
|
|
194
|
-
// seen while live-testing HMR (hot-swapping Home, playground's page-level component, a
|
|
195
|
-
// moment after Home.tsx's import of `Orphan` became a dangling reference to a just-removed
|
|
196
|
-
// export). The previous test proves a clean multi-child page-level swap works fine, so
|
|
197
|
-
// that wasn't a general page-level-swap bug. This test rules out the other suspect: an
|
|
198
|
-
// undefined component reference does NOT reach DomRegion at all - it's caught much
|
|
199
|
-
// earlier, with a clear JSX runtime error. So the live DomRegion crash's exact trigger
|
|
200
|
-
// remains unconfirmed; what's confirmed is that the outer .catch() in applyHmrModule's
|
|
201
|
-
// caller safely falls back to a full reload either way (verified live), so it isn't a
|
|
202
|
-
// silent failure - just an unclear error message for a rare, transient mid-edit state.
|
|
203
|
-
const UndefinedComponent = undefined; // eslint-disable-line no-type-assertion/no-type-assertion -- simulating an import resolving to undefined, exactly like a removed export would
|
|
204
|
-
const window = new Window();
|
|
205
|
-
const document = window.document; // eslint-disable-line no-type-assertion/no-type-assertion -- happy-dom's Document is structurally compatible
|
|
206
|
-
class Page extends TungstenStatefulComponent {
|
|
207
|
-
constructor(...args) {
|
|
208
|
-
super(...args);
|
|
209
|
-
_defineProperty(this, "state", {});
|
|
210
|
-
_defineProperty(this, "content", () => _jsx("div", {
|
|
211
|
-
children: _jsx("h1", {
|
|
212
|
-
children: "Welcome"
|
|
213
|
-
})
|
|
214
|
-
}));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
class Root extends TungstenSimpleComponent {
|
|
218
|
-
constructor(...args) {
|
|
219
|
-
super(...args);
|
|
220
|
-
_defineProperty(this, "content", () => _jsx(Page, {}));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
const testApp = await createTestApp(Root, {
|
|
224
|
-
document
|
|
225
|
-
});
|
|
226
|
-
const wrapper = testApp.component.__currentContent;
|
|
227
|
-
if (!WideRenderedContentNodeIsComponent(wrapper) || AnyComponentIsFunctionComponentStandIn(wrapper.element)) {
|
|
228
|
-
throw new Error('expected the root to directly render a single class component');
|
|
229
|
-
}
|
|
230
|
-
const oldElement = wrapper.element;
|
|
231
|
-
class NewPage extends TungstenStatefulComponent {
|
|
232
|
-
constructor(...args) {
|
|
233
|
-
super(...args);
|
|
234
|
-
_defineProperty(this, "state", {});
|
|
235
|
-
_defineProperty(this, "content", () => _jsxs("div", {
|
|
236
|
-
children: [_jsx("h1", {
|
|
237
|
-
children: "Welcome (edited)"
|
|
238
|
-
}), _jsx(UndefinedComponent, {})]
|
|
239
|
-
}));
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
let caught;
|
|
243
|
-
try {
|
|
244
|
-
await hotSwapClassComponent(oldElement, NewPage);
|
|
245
|
-
} catch (error) {
|
|
246
|
-
caught = error;
|
|
247
|
-
}
|
|
248
|
-
expect(caught).to.not.equal(undefined);
|
|
249
|
-
expect(String(caught)).to.contain('did not recognize element');
|
|
250
|
-
await testApp.unmount();
|
|
251
|
-
});
|
|
252
|
-
});
|