tungsten 0.2.6 → 0.2.8
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/Components.d.ts +3 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +100 -51
- package/dist/DomNodes.js +2 -2
- package/dist/FrameworkConfig.d.ts +2 -0
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.d.ts +2 -0
- package/dist/FunctionComponentStandIn.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.js +16 -3
- package/dist/Instance/ClientRuntimeContext.d.ts +8 -0
- package/dist/Instance/ClientRuntimeContext.d.ts.map +1 -0
- package/dist/Instance/ClientRuntimeContext.js +1 -0
- package/dist/Instance/Instance.d.ts +20 -1
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +59 -11
- package/dist/Servers/loadEnvsDev.d.ts +1 -1
- package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
- package/dist/Servers/loadEnvsDev.js +18 -3
- package/dist/Store/makeStore.d.ts.map +1 -1
- package/dist/Store/makeStore.js +7 -14
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts +2 -0
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +111 -72
- package/dist/bin/commands/compile.d.ts.map +1 -1
- package/dist/bin/commands/compile.js +87 -13
- package/dist/bin/commands/compile.sxyt.d.ts +2 -0
- package/dist/bin/commands/compile.sxyt.d.ts.map +1 -0
- package/dist/bin/commands/compile.sxyt.js +136 -0
- package/dist/build/compileJavascript.d.ts +11 -1
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +89 -31
- package/dist/build/createClientFiles.d.ts +1 -1
- package/dist/build/createClientFiles.d.ts.map +1 -1
- package/dist/build/createClientFiles.js +7 -7
- package/dist/build/createInstanceConfigFile.d.ts +1 -1
- package/dist/build/createInstanceConfigFile.d.ts.map +1 -1
- package/dist/build/createInstanceConfigFile.js +3 -3
- package/dist/build/makeBabelUserDevConfig.d.ts +1 -1
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.js +3 -1
- package/dist/findUserConfig.d.ts +1 -1
- package/dist/findUserConfig.d.ts.map +1 -1
- package/dist/findUserConfig.js +2 -2
- package/dist/frameworkConfigSchema.d.ts +4 -0
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +1 -0
- package/dist/getUserConfig.d.ts +1 -1
- package/dist/getUserConfig.d.ts.map +1 -1
- package/dist/getUserConfig.js +2 -2
- package/dist/hooks/useState.js +1 -1
- package/dist/indexInner.d.ts +0 -1
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +1 -1
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.js +5 -2
- package/dist/testing/createTestApp.sxyt.d.ts +2 -0
- package/dist/testing/createTestApp.sxyt.d.ts.map +1 -0
- package/dist/testing/createTestApp.sxyt.js +424 -0
- package/dist/testing/ensureTestEnvLoaded.d.ts +2 -0
- package/dist/testing/ensureTestEnvLoaded.d.ts.map +1 -0
- package/dist/testing/ensureTestEnvLoaded.js +19 -0
- package/dist/testing/index.d.ts +36 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +156 -0
- package/dist/update/UpdateScheduler.d.ts +17 -0
- package/dist/update/UpdateScheduler.d.ts.map +1 -0
- package/dist/update/UpdateScheduler.js +113 -0
- package/dist/update/integrateUpdateVdom.d.ts +11 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +117 -59
- package/dist/{react-zone.d.ts → zones/react.d.ts} +5 -5
- package/dist/zones/react.d.ts.map +1 -0
- package/dist/{react-zone.js → zones/react.js} +3 -3
- package/package.json +4 -2
- package/readme.md +102 -1
- package/dist/react-zone.d.ts.map +0 -1
package/dist/findUserConfig.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findUserConfig.d.ts","sourceRoot":"","sources":["../src/findUserConfig.ts"],"names":[],"mappings":"AAaA,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM;;;;
|
|
1
|
+
{"version":3,"file":"findUserConfig.d.ts","sourceRoot":"","sources":["../src/findUserConfig.ts"],"names":[],"mappings":"AAaA,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAE,QAAQ,GAAG,OAAiB;;;;UAsE5F"}
|
package/dist/findUserConfig.js
CHANGED
|
@@ -6,7 +6,7 @@ import { cliNote, cliWarn } from "./cliOutput.js";
|
|
|
6
6
|
import { TungstenError } from "./TungstenError.js";
|
|
7
7
|
import { packageNameCapitalized } from "./settings.js";
|
|
8
8
|
//import { throwError } from './throwError.js'
|
|
9
|
-
export async function findUserConfig(projectDir) {
|
|
9
|
+
export async function findUserConfig(projectDir, volume = 'noisy') {
|
|
10
10
|
const packageConfig = await loadPackageDotJsonFromDir(projectDir); // eslint-disable-line no-type-assertion/no-type-assertion
|
|
11
11
|
if (packageConfig === null) {
|
|
12
12
|
throw new TungstenError(`findUserConfig() error: Could not find project tungsten config`);
|
|
@@ -14,7 +14,7 @@ export async function findUserConfig(projectDir) {
|
|
|
14
14
|
const configBases = [projectDir + '/' + configName, projectDir + '/config/' + configName].map(location => slash(location));
|
|
15
15
|
async function foundConfig(type, location) {
|
|
16
16
|
//const [configType, configLocation] = configInfo
|
|
17
|
-
cliNote(`${packageNameCapitalized} using user config at ${location}`);
|
|
17
|
+
if (volume !== 'silent') cliNote(`${packageNameCapitalized} using user config at ${location}`);
|
|
18
18
|
const config = (await import('file://' + location)).default;
|
|
19
19
|
return {
|
|
20
20
|
data: config,
|
|
@@ -38,6 +38,7 @@ declare const frameworkConfigWithRootComponentValidator: import("arktype/interna
|
|
|
38
38
|
packageSystem?: "rewrites" | "aliases";
|
|
39
39
|
ignoreDirs?: string[];
|
|
40
40
|
ignorePatterns?: string | string[];
|
|
41
|
+
skipPackageCompilation?: string | string[];
|
|
41
42
|
serverMiddleware?: [string, string, string];
|
|
42
43
|
apiRoutes?: string;
|
|
43
44
|
apiPath?: string;
|
|
@@ -82,6 +83,7 @@ declare const frameworkConfigWithoutRootComponentValidator: import("arktype/inte
|
|
|
82
83
|
packageSystem?: "rewrites" | "aliases";
|
|
83
84
|
ignoreDirs?: string[];
|
|
84
85
|
ignorePatterns?: string | string[];
|
|
86
|
+
skipPackageCompilation?: string | string[];
|
|
85
87
|
serverMiddleware?: [string, string, string];
|
|
86
88
|
apiRoutes?: string;
|
|
87
89
|
apiPath?: string;
|
|
@@ -125,6 +127,7 @@ export declare const frameworkConfigValidator: import("arktype/internal/variants
|
|
|
125
127
|
packageSystem?: "rewrites" | "aliases";
|
|
126
128
|
ignoreDirs?: string[];
|
|
127
129
|
ignorePatterns?: string | string[];
|
|
130
|
+
skipPackageCompilation?: string | string[];
|
|
128
131
|
serverMiddleware?: [string, string, string];
|
|
129
132
|
apiRoutes?: string;
|
|
130
133
|
apiPath?: string;
|
|
@@ -168,6 +171,7 @@ export declare const frameworkConfigValidator: import("arktype/internal/variants
|
|
|
168
171
|
packageSystem?: "rewrites" | "aliases";
|
|
169
172
|
ignoreDirs?: string[];
|
|
170
173
|
ignorePatterns?: string | string[];
|
|
174
|
+
skipPackageCompilation?: string | string[];
|
|
171
175
|
serverMiddleware?: [string, string, string];
|
|
172
176
|
apiRoutes?: string;
|
|
173
177
|
apiPath?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameworkConfigSchema.d.ts","sourceRoot":"","sources":["../src/frameworkConfigSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"frameworkConfigSchema.d.ts","sourceRoot":"","sources":["../src/frameworkConfigSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAyDnD,QAAA,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAK7C,CAAA;AAEF,QAAA,MAAM,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAIhD,CAAA;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEoB,CAAA;AAEzD,KAAK,mCAAmC,GAAG,OAAO,yCAAyC,CAAC,KAAK,CAAA;AACjG,KAAK,sCAAsC,GAAG,OAAO,4CAA4C,CAAC,KAAK,CAAA;AAIvG,UAAU,gCACN,SAAQ,IAAI,CAAC,mCAAmC,EAAE,cAAc,GAAG,cAAc,CAAC;IAClF,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CACpC;AAED,UAAU,mCACN,SAAQ,IAAI,CAAC,sCAAsC,EAAE,cAAc,GAAG,cAAc,CAAC;IACrF,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CACpC;AAED,MAAM,MAAM,eAAe,GAAG,gCAAgC,GAAG,mCAAmC,CAAA"}
|
|
@@ -47,6 +47,7 @@ const frameworkConfigBaseValidator = arkType({
|
|
|
47
47
|
'ignoreDirs?': 'string[]',
|
|
48
48
|
// rename to ignoreFolders?
|
|
49
49
|
'ignorePatterns?': 'string | string[]',
|
|
50
|
+
'skipPackageCompilation?': 'string | string[]',
|
|
50
51
|
'serverMiddleware?': ['string', 'string', 'string'],
|
|
51
52
|
'apiRoutes?': 'string',
|
|
52
53
|
'apiPath?': 'string'
|
package/dist/getUserConfig.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FrameworkConfigComplete } from './FrameworkConfig.js';
|
|
2
|
-
export declare function getUserConfig(): Promise<FrameworkConfigComplete>;
|
|
2
|
+
export declare function getUserConfig(volume?: 'silent' | 'noisy'): Promise<FrameworkConfigComplete>;
|
|
3
3
|
//# sourceMappingURL=getUserConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserConfig.d.ts","sourceRoot":"","sources":["../src/getUserConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAM9D,wBAAsB,aAAa,
|
|
1
|
+
{"version":3,"file":"getUserConfig.d.ts","sourceRoot":"","sources":["../src/getUserConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAM9D,wBAAsB,aAAa,CAAC,MAAM,GAAE,QAAQ,GAAG,OAAiB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAyB1G"}
|
package/dist/getUserConfig.js
CHANGED
|
@@ -5,8 +5,8 @@ import { frameworkConfigValidator } from "./frameworkConfigSchema.js";
|
|
|
5
5
|
import { makeFinalConfig } from "./makeFinalConfig.js";
|
|
6
6
|
import { throwError } from "./throwError.js";
|
|
7
7
|
import { cliOut } from "./cliOutput.js";
|
|
8
|
-
export async function getUserConfig() {
|
|
9
|
-
const userConfigOrNull = await findUserConfig(process.cwd());
|
|
8
|
+
export async function getUserConfig(volume = 'noisy') {
|
|
9
|
+
const userConfigOrNull = await findUserConfig(process.cwd(), volume);
|
|
10
10
|
//frameworkCon
|
|
11
11
|
if (userConfigOrNull !== null) {
|
|
12
12
|
const userConfig = userConfigOrNull;
|
package/dist/hooks/useState.js
CHANGED
|
@@ -24,7 +24,7 @@ export function useState(...defaultValue) {
|
|
|
24
24
|
// not just current state value
|
|
25
25
|
//if (newValue !== c.state[])
|
|
26
26
|
c.state[index] = newValue;
|
|
27
|
-
c.
|
|
27
|
+
c.__queueUpdate();
|
|
28
28
|
}
|
|
29
29
|
if (index.toString() in c.state) {
|
|
30
30
|
//console.log('useState re-run', c.state[index])
|
package/dist/indexInner.d.ts
CHANGED
|
@@ -36,7 +36,6 @@ export { isDev } from './isDev.js';
|
|
|
36
36
|
export { isProd } from './isProd.js';
|
|
37
37
|
export { logAndReturn } from './logAndReturn.js';
|
|
38
38
|
export * from './requests/index.js';
|
|
39
|
-
export * from './react-zone.jsx';
|
|
40
39
|
export { registerGlobalData, type GlobalData, type GlobalDataFunction } from './routing/registerGlobalData.js';
|
|
41
40
|
export * from './routing/MatchedRoute.jsx';
|
|
42
41
|
export * from './routing/RedirectCode.js';
|
package/dist/indexInner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexInner.d.ts","sourceRoot":"","sources":["../src/indexInner.ts"],"names":[],"mappings":"AAEA,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACH,uBAAuB,EAAE,uBAAuB,IAAI,eAAe,EAAE,mBAAmB;AACxF,yBAAyB,EAAE,yBAAyB,IAAI,iBAAiB,EAAE,qBAAqB;AAEhG,gCAAgC,EAAE,gCAAgC,IAAI,wBAAwB,EAC9F,kCAAkC,EAAE,kCAAkC,IAAI,0BAA0B,GACvG,MAAM,kBAAkB,CAAA;AAEzB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA;AACrC,cAAc,4CAA4C,CAAA;AAC1D,cAAc,yCAAyC,CAAA;AACvD,cAAc,8CAA8C,CAAA;AAC5D,cAAc,yCAAyC,CAAA;AACvD,cAAc,0CAA0C,CAAA;AACxD,cAAc,4CAA4C,CAAA;AAC1D,cAAc,gCAAgC,CAAA;AAC9C,cAAc,sBAAsB,CAAA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Y,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,YAAY,EACR,0BAA0B,EAAE,0BAA0B,IAAI,SAAS,EACnE,gCAAgC,EAAE,gCAAgC,IAAI,eAAe,EACrF,cAAc,EACjB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,mBAAmB,mBAAmB,CAAA"}
|
package/dist/indexInner.js
CHANGED
|
@@ -45,7 +45,7 @@ export { isProd } from "./isProd.js";
|
|
|
45
45
|
export { logAndReturn } from "./logAndReturn.js";
|
|
46
46
|
//export * from './RenderRoutes.js' // maybe we won't use render routes, instead Router and Route
|
|
47
47
|
export * from "./requests/index.js";
|
|
48
|
-
export * from
|
|
48
|
+
//export * from './zones/react.jsx'
|
|
49
49
|
export { registerGlobalData } from "./routing/registerGlobalData.js";
|
|
50
50
|
export * from "./routing/MatchedRoute.js";
|
|
51
51
|
export * from "./routing/RedirectCode.js";
|
|
@@ -53,8 +53,11 @@ describe('parseSelectorsRich()', ({
|
|
|
53
53
|
const input2 = 'html body';
|
|
54
54
|
it(`parses out two tag selectors from '${input2}'`, () => {
|
|
55
55
|
const selectors = parseSelectorsRich(input2);
|
|
56
|
-
console.log('selectors', selectors)
|
|
57
|
-
console.log('expected', [
|
|
56
|
+
// console.log('selectors', selectors)
|
|
57
|
+
// console.log('expected', [
|
|
58
|
+
// tagSelector('html'),
|
|
59
|
+
// tagSelector('body')
|
|
60
|
+
// ])
|
|
58
61
|
selectors.should.deep.equal([tagSelector('html'), whitespace(), tagSelector('body')]);
|
|
59
62
|
});
|
|
60
63
|
const input3 = '.foo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTestApp.sxyt.d.ts","sourceRoot":"","sources":["../../src/testing/createTestApp.sxyt.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,424 @@
|
|
|
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 { TungstenBaseSimpleStoreComponent, TungstenSimpleComponent, TungstenStatefulComponent } from "../Components.js";
|
|
8
|
+
import { registerStore } from "../Store/registerStore.js";
|
|
9
|
+
import { createTestApp, testStore } from "./index.js";
|
|
10
|
+
import { jsxs as _jsxs, jsx as _jsx } from "tungsten/jsxRuntime.js";
|
|
11
|
+
class Counter extends TungstenStatefulComponent {
|
|
12
|
+
constructor(...args) {
|
|
13
|
+
super(...args);
|
|
14
|
+
_defineProperty(this, "state", {
|
|
15
|
+
count: 0
|
|
16
|
+
});
|
|
17
|
+
_defineProperty(this, "clientInitialized", false);
|
|
18
|
+
_defineProperty(this, "clientInit", () => {
|
|
19
|
+
this.clientInitialized = true;
|
|
20
|
+
});
|
|
21
|
+
_defineProperty(this, "content", () => _jsxs("button", {
|
|
22
|
+
onClick: () => {
|
|
23
|
+
this.state.count++;
|
|
24
|
+
},
|
|
25
|
+
children: [this.props.label, ":", this.state.count]
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
class TestStoreSchema {
|
|
30
|
+
constructor() {
|
|
31
|
+
_defineProperty(this, "value", 0);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const testStoreRegistration = registerStore(TestStoreSchema);
|
|
35
|
+
class StoreRoot extends TungstenBaseSimpleStoreComponent {
|
|
36
|
+
constructor(...args) {
|
|
37
|
+
super(...args);
|
|
38
|
+
_defineProperty(this, "store", testStoreRegistration.getComponentStore(this));
|
|
39
|
+
_defineProperty(this, "init", () => {
|
|
40
|
+
this.store.value.subscribe();
|
|
41
|
+
});
|
|
42
|
+
_defineProperty(this, "content", () => _jsx("p", {
|
|
43
|
+
children: this.store.value.get()
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
describe('createTestApp()', ({
|
|
48
|
+
it
|
|
49
|
+
}) => {
|
|
50
|
+
it('mounts, resolves updates, preserves the root for props, and unmounts', async () => {
|
|
51
|
+
const window = new Window();
|
|
52
|
+
const document = window.document;
|
|
53
|
+
const testApp = await createTestApp(Counter, {
|
|
54
|
+
document,
|
|
55
|
+
props: {
|
|
56
|
+
label: 'Count'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const root = testApp.component;
|
|
60
|
+
expect(root.clientInitialized).to.equal(true);
|
|
61
|
+
expect(testApp.container.textContent).to.equal('Count:0');
|
|
62
|
+
const button = testApp.container.querySelector('button');
|
|
63
|
+
expect(button).not.to.equal(null);
|
|
64
|
+
button.dispatchEvent(new window.Event('click', {
|
|
65
|
+
bubbles: true
|
|
66
|
+
}));
|
|
67
|
+
await testApp.resolved();
|
|
68
|
+
expect(testApp.container.textContent).to.equal('Count:1');
|
|
69
|
+
await testApp.setProps({
|
|
70
|
+
label: 'Total'
|
|
71
|
+
});
|
|
72
|
+
expect(testApp.component).to.equal(root);
|
|
73
|
+
expect(testApp.container.textContent).to.equal('Total:1');
|
|
74
|
+
const container = testApp.container;
|
|
75
|
+
await testApp.unmount();
|
|
76
|
+
await testApp.unmount();
|
|
77
|
+
expect(container.isConnected).to.equal(false);
|
|
78
|
+
});
|
|
79
|
+
it('tracks asynchronous event work', async () => {
|
|
80
|
+
const window = new Window();
|
|
81
|
+
const document = window.document;
|
|
82
|
+
let release;
|
|
83
|
+
const released = new Promise(resolve => {
|
|
84
|
+
release = resolve;
|
|
85
|
+
});
|
|
86
|
+
class AsyncButton extends TungstenStatefulComponent {
|
|
87
|
+
constructor(...args) {
|
|
88
|
+
super(...args);
|
|
89
|
+
_defineProperty(this, "state", {
|
|
90
|
+
finished: false
|
|
91
|
+
});
|
|
92
|
+
_defineProperty(this, "content", () => _jsx("button", {
|
|
93
|
+
onClick: async () => {
|
|
94
|
+
await released;
|
|
95
|
+
this.state.finished = true;
|
|
96
|
+
},
|
|
97
|
+
children: this.state.finished ? 'finished' : 'waiting'
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const testApp = await createTestApp(AsyncButton, {
|
|
102
|
+
document
|
|
103
|
+
});
|
|
104
|
+
testApp.container.querySelector('button').dispatchEvent(new window.Event('click'));
|
|
105
|
+
release();
|
|
106
|
+
await testApp.resolved();
|
|
107
|
+
expect(testApp.container.textContent).to.equal('finished');
|
|
108
|
+
await testApp.unmount();
|
|
109
|
+
});
|
|
110
|
+
it('settles asynchronous lifecycle-triggered updates', async () => {
|
|
111
|
+
const window = new Window();
|
|
112
|
+
const document = window.document;
|
|
113
|
+
class LifecycleRoot extends TungstenStatefulComponent {
|
|
114
|
+
constructor(...args) {
|
|
115
|
+
super(...args);
|
|
116
|
+
_defineProperty(this, "state", {
|
|
117
|
+
phase: 'mounting'
|
|
118
|
+
});
|
|
119
|
+
_defineProperty(this, "componentDidMount", async () => {
|
|
120
|
+
await Promise.resolve();
|
|
121
|
+
this.state.phase = 'ready';
|
|
122
|
+
});
|
|
123
|
+
_defineProperty(this, "componentDidUpdate", async () => {
|
|
124
|
+
if (this.state.phase !== 'clicked') return;
|
|
125
|
+
await Promise.resolve();
|
|
126
|
+
this.state.phase = 'settled';
|
|
127
|
+
});
|
|
128
|
+
_defineProperty(this, "content", () => _jsx("button", {
|
|
129
|
+
onClick: () => {
|
|
130
|
+
this.state.phase = 'clicked';
|
|
131
|
+
},
|
|
132
|
+
children: this.state.phase
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const testApp = await createTestApp(LifecycleRoot, {
|
|
137
|
+
document
|
|
138
|
+
});
|
|
139
|
+
expect(testApp.container.textContent).to.equal('ready');
|
|
140
|
+
testApp.container.querySelector('button').dispatchEvent(new window.Event('click'));
|
|
141
|
+
await testApp.resolved();
|
|
142
|
+
expect(testApp.container.textContent).to.equal('settled');
|
|
143
|
+
await testApp.unmount();
|
|
144
|
+
});
|
|
145
|
+
it('initializes independent real stores before mounting', async () => {
|
|
146
|
+
const firstWindow = new Window();
|
|
147
|
+
const secondWindow = new Window();
|
|
148
|
+
const first = await createTestApp(StoreRoot, {
|
|
149
|
+
document: firstWindow.document,
|
|
150
|
+
stores: [testStore(testStoreRegistration, store => {
|
|
151
|
+
store.value.set(1);
|
|
152
|
+
})]
|
|
153
|
+
});
|
|
154
|
+
const second = await createTestApp(StoreRoot, {
|
|
155
|
+
document: secondWindow.document,
|
|
156
|
+
stores: [testStore(testStoreRegistration, store => {
|
|
157
|
+
store.value.set(2);
|
|
158
|
+
})]
|
|
159
|
+
});
|
|
160
|
+
expect(first.container.textContent).to.equal('1');
|
|
161
|
+
expect(second.container.textContent).to.equal('2');
|
|
162
|
+
first.component.store.value.set(3);
|
|
163
|
+
await first.resolved();
|
|
164
|
+
expect(first.container.textContent).to.equal('3');
|
|
165
|
+
expect(second.container.textContent).to.equal('2');
|
|
166
|
+
await first.unmount();
|
|
167
|
+
await second.unmount();
|
|
168
|
+
});
|
|
169
|
+
it('recursively unmounts components below HTML elements', async () => {
|
|
170
|
+
const window = new Window();
|
|
171
|
+
const document = window.document;
|
|
172
|
+
const lifecycle = [];
|
|
173
|
+
class Child extends TungstenSimpleComponent {
|
|
174
|
+
constructor(...args) {
|
|
175
|
+
super(...args);
|
|
176
|
+
_defineProperty(this, "content", () => _jsx("span", {
|
|
177
|
+
children: "child"
|
|
178
|
+
}));
|
|
179
|
+
_defineProperty(this, "componentWillUnmount", () => {
|
|
180
|
+
lifecycle.push('will');
|
|
181
|
+
});
|
|
182
|
+
_defineProperty(this, "componentDidUnmount", () => {
|
|
183
|
+
lifecycle.push('did');
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
class Root extends TungstenSimpleComponent {
|
|
188
|
+
constructor(...args) {
|
|
189
|
+
super(...args);
|
|
190
|
+
_defineProperty(this, "content", () => _jsx("main", {
|
|
191
|
+
children: _jsx(Child, {})
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const container = window.document.createElement('section');
|
|
196
|
+
window.document.body.appendChild(container);
|
|
197
|
+
const testApp = await createTestApp(Root, {
|
|
198
|
+
document,
|
|
199
|
+
container: container
|
|
200
|
+
});
|
|
201
|
+
await testApp.unmount();
|
|
202
|
+
expect(lifecycle).to.deep.equal(['will', 'did']);
|
|
203
|
+
expect(window.document.body.contains(container)).to.equal(true);
|
|
204
|
+
expect(container.childNodes.length).to.equal(0);
|
|
205
|
+
});
|
|
206
|
+
it('rejects a non-empty container without modifying it', async () => {
|
|
207
|
+
const window = new Window();
|
|
208
|
+
const document = window.document;
|
|
209
|
+
const container = window.document.createElement('div');
|
|
210
|
+
container.textContent = 'existing';
|
|
211
|
+
let error;
|
|
212
|
+
try {
|
|
213
|
+
await createTestApp(Counter, {
|
|
214
|
+
document,
|
|
215
|
+
container: container,
|
|
216
|
+
props: {
|
|
217
|
+
label: 'Count'
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
} catch (caught) {
|
|
221
|
+
error = caught;
|
|
222
|
+
}
|
|
223
|
+
expect(error).to.be.instanceOf(Error);
|
|
224
|
+
expect(container.textContent).to.equal('existing');
|
|
225
|
+
});
|
|
226
|
+
it('rolls back partially mounted descendants after an error', async () => {
|
|
227
|
+
const window = new Window();
|
|
228
|
+
const document = window.document;
|
|
229
|
+
const lifecycle = [];
|
|
230
|
+
class MountedChild extends TungstenSimpleComponent {
|
|
231
|
+
constructor(...args) {
|
|
232
|
+
super(...args);
|
|
233
|
+
_defineProperty(this, "content", () => _jsx("span", {
|
|
234
|
+
children: "mounted"
|
|
235
|
+
}));
|
|
236
|
+
_defineProperty(this, "componentDidMount", () => {
|
|
237
|
+
lifecycle.push('mount');
|
|
238
|
+
});
|
|
239
|
+
_defineProperty(this, "componentWillUnmount", () => {
|
|
240
|
+
lifecycle.push('will');
|
|
241
|
+
});
|
|
242
|
+
_defineProperty(this, "componentDidUnmount", () => {
|
|
243
|
+
lifecycle.push('did');
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
class BrokenChild extends TungstenSimpleComponent {
|
|
248
|
+
constructor(...args) {
|
|
249
|
+
super(...args);
|
|
250
|
+
_defineProperty(this, "content", () => {
|
|
251
|
+
throw new Error('broken child');
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
class BrokenRoot extends TungstenSimpleComponent {
|
|
256
|
+
constructor(...args) {
|
|
257
|
+
super(...args);
|
|
258
|
+
_defineProperty(this, "content", () => _jsxs("main", {
|
|
259
|
+
children: [_jsx(MountedChild, {}), _jsx(BrokenChild, {})]
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const originalBodyChildren = window.document.body.childNodes.length;
|
|
264
|
+
let error;
|
|
265
|
+
try {
|
|
266
|
+
await createTestApp(BrokenRoot, {
|
|
267
|
+
document
|
|
268
|
+
});
|
|
269
|
+
} catch (caught) {
|
|
270
|
+
error = caught;
|
|
271
|
+
}
|
|
272
|
+
expect(error).to.be.instanceOf(Error);
|
|
273
|
+
expect(lifecycle).to.deep.equal(['mount', 'will', 'did']);
|
|
274
|
+
expect(window.document.body.childNodes.length).to.equal(originalBodyChildren);
|
|
275
|
+
});
|
|
276
|
+
it('supports input, checkbox, and select bindings', async () => {
|
|
277
|
+
const window = new Window();
|
|
278
|
+
const document = window.document;
|
|
279
|
+
class FormRoot extends TungstenStatefulComponent {
|
|
280
|
+
constructor(...args) {
|
|
281
|
+
super(...args);
|
|
282
|
+
_defineProperty(this, "state", {
|
|
283
|
+
name: 'Robert',
|
|
284
|
+
checked: false,
|
|
285
|
+
choice: 'b'
|
|
286
|
+
});
|
|
287
|
+
_defineProperty(this, "content", () => _jsxs("form", {
|
|
288
|
+
children: [_jsx("input", {
|
|
289
|
+
name: "name",
|
|
290
|
+
bind: [this.state, 'name']
|
|
291
|
+
}), _jsx("input", {
|
|
292
|
+
name: "enabled",
|
|
293
|
+
type: "checkbox",
|
|
294
|
+
bindChecked: [this.state, 'checked']
|
|
295
|
+
}), _jsxs("select", {
|
|
296
|
+
name: "choice",
|
|
297
|
+
bind: [this.state, 'choice'],
|
|
298
|
+
children: [_jsx("option", {
|
|
299
|
+
value: "a",
|
|
300
|
+
children: "A"
|
|
301
|
+
}), _jsx("option", {
|
|
302
|
+
value: "b",
|
|
303
|
+
children: "B"
|
|
304
|
+
}), _jsx("option", {
|
|
305
|
+
value: "c",
|
|
306
|
+
children: "C"
|
|
307
|
+
})]
|
|
308
|
+
}), _jsxs("output", {
|
|
309
|
+
children: [this.state.name, ":", String(this.state.checked), ":", this.state.choice]
|
|
310
|
+
})]
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const testApp = await createTestApp(FormRoot, {
|
|
315
|
+
document
|
|
316
|
+
});
|
|
317
|
+
const name = testApp.container.querySelector('input[name="name"]');
|
|
318
|
+
const enabled = testApp.container.querySelector('input[name="enabled"]');
|
|
319
|
+
const choice = testApp.container.querySelector('select');
|
|
320
|
+
name.value = 'Alice';
|
|
321
|
+
name.dispatchEvent(new window.Event('input', {
|
|
322
|
+
bubbles: true
|
|
323
|
+
}));
|
|
324
|
+
enabled.checked = true;
|
|
325
|
+
enabled.dispatchEvent(new window.Event('change', {
|
|
326
|
+
bubbles: true
|
|
327
|
+
}));
|
|
328
|
+
choice.value = 'c';
|
|
329
|
+
choice.dispatchEvent(new window.Event('input', {
|
|
330
|
+
bubbles: true
|
|
331
|
+
}));
|
|
332
|
+
await testApp.resolved();
|
|
333
|
+
expect(testApp.component.state.name).to.equal('Alice');
|
|
334
|
+
expect(testApp.component.state.checked).to.equal(true);
|
|
335
|
+
expect(testApp.component.state.choice).to.equal('c');
|
|
336
|
+
expect(testApp.container.querySelector('output').textContent).to.equal('Alice:true:c');
|
|
337
|
+
await testApp.unmount();
|
|
338
|
+
});
|
|
339
|
+
it('preserves keyed nodes and controlled select values during reconciliation', async () => {
|
|
340
|
+
const window = new Window();
|
|
341
|
+
const document = window.document;
|
|
342
|
+
class ReconciliationRoot extends TungstenStatefulComponent {
|
|
343
|
+
constructor(...args) {
|
|
344
|
+
super(...args);
|
|
345
|
+
_defineProperty(this, "state", {
|
|
346
|
+
items: ['a', 'b', 'c'],
|
|
347
|
+
selected: 'b',
|
|
348
|
+
updates: 0
|
|
349
|
+
});
|
|
350
|
+
_defineProperty(this, "content", () => _jsxs("main", {
|
|
351
|
+
children: [_jsx("ul", {
|
|
352
|
+
children: this.state.items.map(item => _jsx("li", {
|
|
353
|
+
"data-key": item,
|
|
354
|
+
children: item
|
|
355
|
+
}, item))
|
|
356
|
+
}), _jsxs("select", {
|
|
357
|
+
value: this.state.selected,
|
|
358
|
+
children: [_jsx("option", {
|
|
359
|
+
value: "a",
|
|
360
|
+
children: "A"
|
|
361
|
+
}), _jsx("option", {
|
|
362
|
+
value: "b",
|
|
363
|
+
children: "B"
|
|
364
|
+
}), _jsx("option", {
|
|
365
|
+
value: "c",
|
|
366
|
+
children: "C"
|
|
367
|
+
})]
|
|
368
|
+
}), _jsx("button", {
|
|
369
|
+
onClick: () => {
|
|
370
|
+
this.state.updates++;
|
|
371
|
+
},
|
|
372
|
+
children: "update"
|
|
373
|
+
}), _jsx("output", {
|
|
374
|
+
children: this.state.updates
|
|
375
|
+
})]
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const testApp = await createTestApp(ReconciliationRoot, {
|
|
380
|
+
document
|
|
381
|
+
});
|
|
382
|
+
const nodeA = testApp.container.querySelector('[data-key="a"]');
|
|
383
|
+
const nodeB = testApp.container.querySelector('[data-key="b"]');
|
|
384
|
+
const select = testApp.container.querySelector('select');
|
|
385
|
+
testApp.component.state.items = ['c', 'a', 'b'];
|
|
386
|
+
await testApp.resolved();
|
|
387
|
+
expect(testApp.container.querySelector('[data-key="a"]')).to.equal(nodeA);
|
|
388
|
+
expect(testApp.container.querySelector('[data-key="b"]')).to.equal(nodeB);
|
|
389
|
+
expect(select.value).to.equal('b');
|
|
390
|
+
testApp.container.querySelector('button').dispatchEvent(new window.Event('click'));
|
|
391
|
+
await testApp.resolved();
|
|
392
|
+
expect(select.value).to.equal('b');
|
|
393
|
+
await testApp.unmount();
|
|
394
|
+
});
|
|
395
|
+
it('rejects resolved() when an asynchronous event handler fails', async () => {
|
|
396
|
+
const window = new Window();
|
|
397
|
+
const document = window.document;
|
|
398
|
+
class BrokenEventRoot extends TungstenSimpleComponent {
|
|
399
|
+
constructor(...args) {
|
|
400
|
+
super(...args);
|
|
401
|
+
_defineProperty(this, "content", () => _jsx("button", {
|
|
402
|
+
onClick: async () => {
|
|
403
|
+
await Promise.resolve();
|
|
404
|
+
throw new Error('event failed');
|
|
405
|
+
},
|
|
406
|
+
children: "break"
|
|
407
|
+
}));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const testApp = await createTestApp(BrokenEventRoot, {
|
|
411
|
+
document
|
|
412
|
+
});
|
|
413
|
+
testApp.container.querySelector('button').dispatchEvent(new window.Event('click'));
|
|
414
|
+
let error;
|
|
415
|
+
try {
|
|
416
|
+
await testApp.resolved();
|
|
417
|
+
} catch (caught) {
|
|
418
|
+
error = caught;
|
|
419
|
+
}
|
|
420
|
+
expect(error).to.be.instanceOf(Error);
|
|
421
|
+
expect(error.message).to.contain('BrokenEventRoot click event handler');
|
|
422
|
+
await testApp.unmount();
|
|
423
|
+
});
|
|
424
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureTestEnvLoaded.d.ts","sourceRoot":"","sources":["../../src/testing/ensureTestEnvLoaded.ts"],"names":[],"mappings":"AASA,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAWnD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getUserConfig } from "../getUserConfig.js";
|
|
2
|
+
import { loadEnvsDev } from "../Servers/loadEnvsDev.js";
|
|
3
|
+
let loadPromise;
|
|
4
|
+
// Populate global.tungstenPublicEnv / global.tungstenPrivateEnv for DOM component
|
|
5
|
+
// tests, exactly once per process. Compiled client component code reads these as
|
|
6
|
+
// bare globals, so they must exist before any component runs under the test runner.
|
|
7
|
+
// Test runs prefer .env.test* files (per-file replacement) via useTestEnvFiles.
|
|
8
|
+
export function ensureTestEnvLoaded() {
|
|
9
|
+
if (loadPromise === undefined) {
|
|
10
|
+
loadPromise = (async () => {
|
|
11
|
+
const config = await getUserConfig('silent');
|
|
12
|
+
// iteration 0: schemas are stable within a test run.
|
|
13
|
+
// _firstLoad = false: suppress the CLI boot output.
|
|
14
|
+
// useTestEnvFiles = true: prefer .env.test* files.
|
|
15
|
+
await loadEnvsDev(config, 0, process.env, false, true);
|
|
16
|
+
})();
|
|
17
|
+
}
|
|
18
|
+
return loadPromise;
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TungstenBaseComponent, TungstenBaseComponentType } from '../Components.jsx';
|
|
2
|
+
import type { TrueStore } from '../Store/makeStore.js';
|
|
3
|
+
export type ComponentProps<ComponentType extends TungstenBaseComponentType<any, any>> = InstanceType<ComponentType>['props'];
|
|
4
|
+
export type TestStoreRegistration<Schema extends object> = {
|
|
5
|
+
getStore: (stores: TrueStore<unknown>[]) => TrueStore<Schema>;
|
|
6
|
+
};
|
|
7
|
+
export type TestStore<Schema extends object> = TrueStore<Schema>;
|
|
8
|
+
export type TestStoreOverride<Schema extends object = object> = {
|
|
9
|
+
registration: TestStoreRegistration<Schema>;
|
|
10
|
+
initialize: (store: TrueStore<Schema>) => void | Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare function testStore<Schema extends object>(registration: TestStoreRegistration<Schema>, initialize: (store: TestStore<Schema>) => void | Promise<void>): TestStoreOverride<Schema>;
|
|
13
|
+
export type TestAppOptions<Props extends object> = {
|
|
14
|
+
document?: Document;
|
|
15
|
+
props?: Props;
|
|
16
|
+
container?: HTMLElement;
|
|
17
|
+
location?: string;
|
|
18
|
+
routeParams?: Record<string, string>;
|
|
19
|
+
routeData?: unknown;
|
|
20
|
+
globalData?: Record<string, unknown>;
|
|
21
|
+
stores?: readonly TestStoreOverride<any>[];
|
|
22
|
+
};
|
|
23
|
+
export type TestApp<Component extends TungstenBaseComponent> = {
|
|
24
|
+
readonly document: Document;
|
|
25
|
+
readonly container: HTMLElement;
|
|
26
|
+
readonly component: Component;
|
|
27
|
+
resolved(): Promise<void>;
|
|
28
|
+
setProps(props: Component['props']): Promise<void>;
|
|
29
|
+
unmount(): Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
type CreateTestAppArgs<Props extends object> = object extends Props ? [options?: TestAppOptions<Props>] : keyof Props extends never ? [options?: TestAppOptions<Props>] : [options: TestAppOptions<Props> & {
|
|
32
|
+
props: Props;
|
|
33
|
+
}];
|
|
34
|
+
export declare function createTestApp<ComponentType extends TungstenBaseComponentType<any, any>>(RootComponent: ComponentType, ...args: CreateTestAppArgs<ComponentProps<ComponentType>>): Promise<TestApp<InstanceType<ComponentType>>>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|