tungsten 0.4.1 → 0.4.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 -1
- package/dist/.tsbuildinfo +1 -0
- package/dist/FrameworkConfig.d.ts +1 -0
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/bin/commands/help.d.ts +2 -0
- package/dist/bin/commands/help.d.ts.map +1 -0
- package/dist/bin/commands/help.js +16 -0
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +11 -4
- package/dist/componentCss/tungsten.css +2 -2
- package/dist/testing/hydrateTestApp.js +2 -2
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +4 -3
- package/dist/testing/loadEnv.d.ts +3 -0
- package/dist/testing/loadEnv.d.ts.map +1 -0
- package/dist/testing/loadEnv.js +28 -0
- package/dist/testing/loadEnvSetup.d.ts +2 -0
- package/dist/testing/loadEnvSetup.d.ts.map +1 -0
- package/dist/testing/loadEnvSetup.js +7 -0
- package/dist/testing/{ensureTestEnvLoaded.d.ts → testEnvIsRequested.d.ts} +1 -2
- package/dist/testing/testEnvIsRequested.d.ts.map +1 -0
- package/dist/testing/testEnvIsRequested.js +7 -0
- package/package.json +1 -1
- package/dist/testing/ensureTestEnvLoaded.d.ts.map +0 -1
- package/dist/testing/ensureTestEnvLoaded.js +0 -32
|
@@ -32,6 +32,7 @@ export type FrameworkConfigBase = {
|
|
|
32
32
|
suppressEnvOverwriteWarnings?: boolean;
|
|
33
33
|
warnOnFrameworkChange?: boolean;
|
|
34
34
|
hmr?: boolean | 'reload';
|
|
35
|
+
csr?: boolean;
|
|
35
36
|
};
|
|
36
37
|
export type FrameworkConfigWithRootComponent = FrameworkConfigBase & {
|
|
37
38
|
useRootComponent?: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameworkConfig.d.ts","sourceRoot":"","sources":["../src/Framework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AAwC,GAAG,2CAA2C,CAAA;AAI5F,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAC3C,2BAA2B,EAC3B,YAAY,GAAG,gBAAgB,CAC9B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/help.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { cliOut } from "../../cliOutput.js";
|
|
2
|
+
const command = process.argv[2];
|
|
3
|
+
cliOut(`Usage: tungsten <command> [options]
|
|
4
|
+
|
|
5
|
+
Commands:
|
|
6
|
+
dev Start dev mode [--no-boot] [--profile]
|
|
7
|
+
devmon Dev mode, auto-restarts on framework rebuilds (same options as dev)
|
|
8
|
+
build Production build [--profile]
|
|
9
|
+
start Start production server
|
|
10
|
+
static Preview a static site build
|
|
11
|
+
clean Delete build assets
|
|
12
|
+
compile [targets] Compile targets in isolation; run "tungsten compile --help" for details
|
|
13
|
+
compile-simple-package <sourceFolder> <destFolder>
|
|
14
|
+
|
|
15
|
+
Run "tungsten <command> --help" where supported for command-specific options.`);
|
|
16
|
+
process.exit(command === undefined || command === '' ? 1 : 0);
|
package/dist/bin/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":"AAkEA,OAAO,EAAE,CAAA"}
|
package/dist/bin/index.js
CHANGED
|
@@ -2,10 +2,16 @@ import { cliOut, cliWarn } from "../cliOutput.js";
|
|
|
2
2
|
// get command line args
|
|
3
3
|
const args = process.argv.slice(2);
|
|
4
4
|
const command = args[0];
|
|
5
|
-
if (command === undefined || command === '') {
|
|
6
|
-
cliWarn(`Please choose a command, e.g. "tungsten dev"`);
|
|
7
|
-
}
|
|
8
5
|
switch (command) {
|
|
6
|
+
case undefined:
|
|
7
|
+
case '':
|
|
8
|
+
case 'help':
|
|
9
|
+
case '--help':
|
|
10
|
+
case '-h':
|
|
11
|
+
{
|
|
12
|
+
await import("./commands/help.js");
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
9
15
|
case 'dev':
|
|
10
16
|
{
|
|
11
17
|
cliOut(`Starting Tungsten dev mode`);
|
|
@@ -61,6 +67,7 @@ switch (command) {
|
|
|
61
67
|
}
|
|
62
68
|
default:
|
|
63
69
|
{
|
|
64
|
-
cliWarn(`tungsten: unknown command "${command}"`);
|
|
70
|
+
cliWarn(`tungsten: unknown command "${command}" (run "tungsten --help" for usage)`);
|
|
71
|
+
process.exit(1);
|
|
65
72
|
}
|
|
66
73
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@import "i/T-components-library-
|
|
2
|
-
@import "i/T-components-library-
|
|
1
|
+
@import "i/T-components-library-RichTextEditor-RichTextEditor.css";
|
|
2
|
+
@import "i/T-components-library-__StatefulMessage-StatefulMessage.css";
|
|
@@ -15,7 +15,7 @@ import { initStores } from "../Servers/initStores.js";
|
|
|
15
15
|
import { deleteNodeIfRendered } from "../update/integrateUpdateVdom.js";
|
|
16
16
|
import { UpdateScheduler } from "../update/UpdateScheduler.js";
|
|
17
17
|
import { DomPointer } from "../DomPointer.js";
|
|
18
|
-
import {
|
|
18
|
+
import { waitForEnvIfLoading } from "./loadEnv.js";
|
|
19
19
|
// hydrate.tsx references several DOM globals directly (Node.COMMENT_NODE, `instanceof Text`, the
|
|
20
20
|
// bare `document`) the way real browser code always can - happy-dom only puts these on its own
|
|
21
21
|
// Window, not on Node.js's global scope. Every hand-written hydration test before this harness
|
|
@@ -108,7 +108,7 @@ class HydrateTestAppImplementation {
|
|
|
108
108
|
* client hydrator does, so a caller reproducing that class of bug should assert on the rejection.
|
|
109
109
|
*/
|
|
110
110
|
export async function hydrateTestApp(RootComponent, ...args) {
|
|
111
|
-
await
|
|
111
|
+
await waitForEnvIfLoading();
|
|
112
112
|
const options = args[0]; // eslint-disable-line no-type-assertion/no-type-assertion
|
|
113
113
|
const suppliedDocument = options?.document ?? globalThis.document; // eslint-disable-line no-type-assertion/no-type-assertion
|
|
114
114
|
if (suppliedDocument === undefined) {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ConstructPackage, TungstenBaseComponent, TungstenBaseComponentType, TungstenComponentPropsBase } from '../Components.jsx';
|
|
2
|
-
export {
|
|
2
|
+
export { loadEnv } from './loadEnv.js';
|
|
3
|
+
export { testEnvVariableName } from './testEnvIsRequested.js';
|
|
3
4
|
export { hydrateTestApp, type HydrateTestApp, type HydrateTestAppOptions } from './hydrateTestApp.js';
|
|
4
5
|
import type { TrueStore } from '../Store/makeStore.js';
|
|
5
6
|
export type ComponentProps<ComponentType extends TungstenBaseComponentType<any, any>> = InstanceType<ComponentType>['props'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC7B,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC7B,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAErG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAWtD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(s, a),
|
|
|
8
8
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
9
9
|
import { Instance } from "../Instance/Instance.js";
|
|
10
10
|
import { initStores } from "../Servers/initStores.js";
|
|
11
|
-
import {
|
|
12
|
-
export {
|
|
11
|
+
import { waitForEnvIfLoading } from "./loadEnv.js";
|
|
12
|
+
export { loadEnv } from "./loadEnv.js";
|
|
13
|
+
export { testEnvVariableName } from "./testEnvIsRequested.js";
|
|
13
14
|
export { hydrateTestApp } from "./hydrateTestApp.js";
|
|
14
15
|
import { createTungstenRootComponent, deleteTungstenRoot } from "../update/integrateUpdateVdom.js";
|
|
15
16
|
import { UpdateScheduler } from "../update/UpdateScheduler.js";
|
|
@@ -87,7 +88,7 @@ export async function createTestApp(
|
|
|
87
88
|
// type arguments - so a generic component's own parameters collapse to
|
|
88
89
|
// their constraints before `props` is ever considered.
|
|
89
90
|
RootComponent, ...args) {
|
|
90
|
-
await
|
|
91
|
+
await waitForEnvIfLoading();
|
|
91
92
|
const options = args[0];
|
|
92
93
|
const suppliedDocument = options?.document ?? globalThis.document;
|
|
93
94
|
if (suppliedDocument === undefined) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadEnv.d.ts","sourceRoot":"","sources":["../../src/testing/loadEnv.ts"],"names":[],"mappings":"AAaA,wBAAgB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAWvC;AAID,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEnD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getUserConfig } from "../getUserConfig.js";
|
|
2
|
+
import { loadEnvsDev } from "../Servers/loadEnvsDev.js";
|
|
3
|
+
import { testEnvIsRequested, testEnvVariableName } from "./testEnvIsRequested.js";
|
|
4
|
+
let loadPromise;
|
|
5
|
+
// Populate global.tungstenPublicEnv / global.tungstenPrivateEnv for DOM component tests, once
|
|
6
|
+
// per process. Compiled client component code reads these as bare globals, so they must exist
|
|
7
|
+
// before any component runs under the test runner. Call this from the test runner setup hook.
|
|
8
|
+
//
|
|
9
|
+
// TUNGSTEN_TEST_ENV chooses which env files: set it to prefer .env.test* over the base files.
|
|
10
|
+
// A missing or invalid env schemas file is a hard error - an app that asked for env and did not
|
|
11
|
+
// get it must not run its tests regardless.
|
|
12
|
+
export function loadEnv() {
|
|
13
|
+
if (loadPromise === undefined) {
|
|
14
|
+
loadPromise = (async () => {
|
|
15
|
+
const config = await getUserConfig({}, 'silent');
|
|
16
|
+
const useTestEnvFiles = testEnvIsRequested(process.env[testEnvVariableName]);
|
|
17
|
+
// iteration 0: schemas are stable within a test run.
|
|
18
|
+
// _firstLoad = false: suppress the CLI boot output.
|
|
19
|
+
await loadEnvsDev(config, 0, process.env, false, useTestEnvFiles);
|
|
20
|
+
})();
|
|
21
|
+
}
|
|
22
|
+
return loadPromise;
|
|
23
|
+
}
|
|
24
|
+
// Passive companion for the test harness: wait for an in-progress loadEnv(), or do nothing if
|
|
25
|
+
// setup never started one. Never initiates a load, so it never fails on its own.
|
|
26
|
+
export function waitForEnvIfLoading() {
|
|
27
|
+
return loadPromise ?? Promise.resolve();
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadEnvSetup.d.ts","sourceRoot":"","sources":["../../src/testing/loadEnvSetup.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Side-effect setup module for the sxy-test-runner `setup` file-location form, which imports the
|
|
2
|
+
// file rather than calling an export. Reference it from an app's test config to load app env for
|
|
3
|
+
// component tests:
|
|
4
|
+
// setup: ['node_modules/tungsten/dist/testing/loadEnvSetup.js']
|
|
5
|
+
// (the path is resolved from the project dir). Or call loadEnv() directly in a setup function.
|
|
6
|
+
import { loadEnv } from "./loadEnv.js";
|
|
7
|
+
await loadEnv();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const testEnvVariableName = "TUNGSTEN_TEST_ENV";
|
|
2
2
|
export declare function testEnvIsRequested(value: string | undefined): boolean;
|
|
3
|
-
|
|
4
|
-
//# sourceMappingURL=ensureTestEnvLoaded.d.ts.map
|
|
3
|
+
//# sourceMappingURL=testEnvIsRequested.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testEnvIsRequested.d.ts","sourceRoot":"","sources":["../../src/testing/testEnvIsRequested.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB,sBAAsB,CAAA;AAEtD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIrE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Set this to prefer the .env.test* files over the base ones when test env is loaded.
|
|
2
|
+
export const testEnvVariableName = 'TUNGSTEN_TEST_ENV';
|
|
3
|
+
export function testEnvIsRequested(value) {
|
|
4
|
+
if (value === undefined) return false;
|
|
5
|
+
const normalized = value.trim().toLowerCase();
|
|
6
|
+
return normalized !== '' && normalized !== '0' && normalized !== 'false';
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ensureTestEnvLoaded.d.ts","sourceRoot":"","sources":["../../src/testing/ensureTestEnvLoaded.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,sBAAsB,CAAA;AAEtD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIrE;AAaD,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAYnD"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { getUserConfig } from "../getUserConfig.js";
|
|
2
|
-
import { loadEnvsDev } from "../Servers/loadEnvsDev.js";
|
|
3
|
-
// Set this in the test script or a runner hook to have component tests load app env.
|
|
4
|
-
export const testEnvVariableName = 'TUNGSTEN_TEST_ENV';
|
|
5
|
-
export function testEnvIsRequested(value) {
|
|
6
|
-
if (value === undefined) return false;
|
|
7
|
-
const normalized = value.trim().toLowerCase();
|
|
8
|
-
return normalized !== '' && normalized !== '0' && normalized !== 'false';
|
|
9
|
-
}
|
|
10
|
-
let loadPromise;
|
|
11
|
-
// Populate global.tungstenPublicEnv / global.tungstenPrivateEnv for DOM component tests,
|
|
12
|
-
// exactly once per process. Compiled client component code reads these as bare globals, so
|
|
13
|
-
// they must exist before any component runs under the test runner.
|
|
14
|
-
//
|
|
15
|
-
// Opt-in, via TUNGSTEN_TEST_ENV. An app that sets it gets its envs loaded with the .env.test*
|
|
16
|
-
// files preferred over the base ones, and a missing or invalid env schemas file is then a hard
|
|
17
|
-
// error — an app that asked for env and did not get it must not run its tests regardless.
|
|
18
|
-
// Without the variable nothing is loaded, which is what a package with no env schemas of its
|
|
19
|
-
// own (the framework itself, or a component library) needs.
|
|
20
|
-
export function ensureTestEnvLoaded() {
|
|
21
|
-
if (loadPromise === undefined) {
|
|
22
|
-
loadPromise = (async () => {
|
|
23
|
-
if (!testEnvIsRequested(process.env[testEnvVariableName])) return;
|
|
24
|
-
const config = await getUserConfig({}, 'silent');
|
|
25
|
-
// iteration 0: schemas are stable within a test run.
|
|
26
|
-
// _firstLoad = false: suppress the CLI boot output.
|
|
27
|
-
// useTestEnvFiles = true: prefer .env.test* files.
|
|
28
|
-
await loadEnvsDev(config, 0, process.env, false, true);
|
|
29
|
-
})();
|
|
30
|
-
}
|
|
31
|
-
return loadPromise;
|
|
32
|
-
}
|