tungsten 0.7.0 → 0.7.1
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/FrameworkConfig.d.ts +2 -0
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FrameworkConfig.types.test.d.ts +2 -0
- package/dist/FrameworkConfig.types.test.d.ts.map +1 -0
- package/dist/FrameworkConfig.types.test.js +6 -0
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +6 -33
- package/dist/Instance/InstanceConfig.d.ts +1 -0
- package/dist/Instance/InstanceConfig.d.ts.map +1 -1
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +10 -1
- package/dist/Servers/ProdServer.d.ts +1 -0
- package/dist/Servers/ProdServer.d.ts.map +1 -1
- package/dist/Servers/ProdServer.js +18 -1
- package/dist/Servers/routing.d.ts.map +1 -1
- package/dist/Servers/routing.js +9 -5
- package/dist/Servers/stubInstance.d.ts +8 -0
- package/dist/Servers/stubInstance.d.ts.map +1 -0
- package/dist/Servers/stubInstance.js +40 -0
- package/dist/build/createInstanceConfigFile.d.ts.map +1 -1
- package/dist/build/createInstanceConfigFile.js +1 -1
- package/dist/build/rollupProdConstants.d.ts.map +1 -1
- package/dist/componentHelpers.d.ts +2 -1
- package/dist/componentHelpers.d.ts.map +1 -1
- package/dist/componentHelpers.js +3 -0
- package/dist/frameworkConfigSchema.d.ts +2 -0
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +4 -1
- package/dist/getUserConfig.d.ts.map +1 -1
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +31 -10
- package/dist/hydrate/stubRouting.d.ts +8 -0
- package/dist/hydrate/stubRouting.d.ts.map +1 -0
- package/dist/hydrate/stubRouting.js +25 -0
- package/dist/makeFinalConfig.d.ts.map +1 -1
- package/dist/makeFinalConfig.js +2 -0
- package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -1
- package/dist/makeInstanceConfigFromFrameworkConfig.js +1 -0
- package/dist/pipeline/PipelineRequestHandler.d.ts.map +1 -1
- package/dist/pipeline/PipelineRequestHandler.js +9 -1
- package/dist/pipeline/hydratePipeline.d.ts.map +1 -1
- package/dist/pipeline/hydratePipeline.js +28 -9
- package/dist/pipeline/pipeline.d.ts +35 -33
- package/dist/pipeline/pipeline.d.ts.map +1 -1
- package/dist/pipeline/pipeline.js +10 -5
- package/dist/pipeline/pipeline.types.test.d.ts +186 -76
- package/dist/pipeline/pipeline.types.test.d.ts.map +1 -1
- package/dist/pipeline/pipeline.types.test.js +2 -0
- package/dist/pipeline/pipelineDefinition.d.ts +20 -9
- package/dist/pipeline/pipelineDefinition.d.ts.map +1 -1
- package/dist/pipeline/pipelineSplit.types.test.d.ts +598 -124
- package/dist/pipeline/pipelineSplit.types.test.d.ts.map +1 -1
- package/dist/pipeline/runPipeline.d.ts +6 -8
- package/dist/pipeline/runPipeline.d.ts.map +1 -1
- package/dist/pipeline/runPipeline.js +8 -8
- package/dist/pipeline/runSplitPipeline.d.ts +3 -3
- package/dist/pipeline/runSplitPipeline.d.ts.map +1 -1
- package/dist/pipeline/runSplitPipeline.js +12 -8
- package/dist/pipeline/splitPipeline.d.ts +8 -8
- package/dist/pipeline/splitPipeline.d.ts.map +1 -1
- package/dist/render/contentTreeToRenderingTree.d.ts.map +1 -1
- package/dist/render/contentTreeToRenderingTree.js +4 -1
- package/dist/routing/MatchedRouteInfo.d.ts +2 -0
- package/dist/routing/MatchedRouteInfo.d.ts.map +1 -1
- package/dist/routing/MatchedRouteInfo.js +1 -1
- package/dist/routing/RouteContentFunction.d.ts +1 -1
- package/dist/routing/RouteContentFunction.d.ts.map +1 -1
- package/dist/routing/RouteTypes.d.ts +1 -1
- package/dist/routing/RouteTypes.d.ts.map +1 -1
- package/dist/routing/Routes.d.ts +6 -3
- package/dist/routing/Routes.d.ts.map +1 -1
- package/dist/routing/builder.d.ts +2 -1
- package/dist/routing/builder.d.ts.map +1 -1
- package/dist/routing/builder.js +6 -0
- package/dist/routing/redirectOf.d.ts +11 -0
- package/dist/routing/redirectOf.d.ts.map +1 -0
- package/dist/routing/redirectOf.js +32 -0
- package/dist/routing/routesArray.d.ts +2 -2
- package/dist/routing/routesArray.d.ts.map +1 -1
- package/dist/routing/routingBuilder.js +0 -1
- package/dist/testing/contentToString.d.ts +13 -0
- package/dist/testing/contentToString.d.ts.map +1 -0
- package/dist/testing/contentToString.js +105 -0
- package/dist/testing/display.d.ts +2 -0
- package/dist/testing/display.d.ts.map +1 -0
- package/dist/testing/display.js +37 -0
- package/dist/testing/ensure.d.ts +52 -41
- package/dist/testing/ensure.d.ts.map +1 -1
- package/dist/testing/ensure.js +204 -62
- package/dist/testing/ensure.types.test.d.ts +2 -0
- package/dist/testing/ensure.types.test.d.ts.map +1 -0
- package/dist/testing/ensure.types.test.js +34 -0
- package/dist/testing/host.d.ts +25 -25
- package/dist/testing/host.d.ts.map +1 -1
- package/dist/testing/host.js +1 -3
- package/dist/testing/host.types.test.d.ts +2 -0
- package/dist/testing/host.types.test.d.ts.map +1 -0
- package/dist/testing/host.types.test.js +81 -0
- package/dist/testing/hydrateTestApp.js +4 -3
- package/dist/testing/index.d.ts +2 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -2
- package/dist/testing/pipeline/createTestPacketApp.d.ts +30 -0
- package/dist/testing/pipeline/createTestPacketApp.d.ts.map +1 -0
- package/dist/testing/pipeline/createTestPacketApp.js +45 -0
- package/dist/testing/pipeline/createTestPacketApp.types.test.d.ts +3 -0
- package/dist/testing/pipeline/createTestPacketApp.types.test.d.ts.map +1 -0
- package/dist/testing/pipeline/createTestPacketApp.types.test.js +101 -0
- package/dist/testing/pipeline/createTestPipelineApp.d.ts +70 -0
- package/dist/testing/pipeline/createTestPipelineApp.d.ts.map +1 -0
- package/dist/testing/pipeline/createTestPipelineApp.js +90 -0
- package/dist/testing/pipeline/createTestPipelineApp.types.test.d.ts +6 -0
- package/dist/testing/pipeline/createTestPipelineApp.types.test.d.ts.map +1 -0
- package/dist/testing/pipeline/createTestPipelineApp.types.test.js +146 -0
- package/dist/testing/pipeline/hostPipeline.d.ts +25 -0
- package/dist/testing/pipeline/hostPipeline.d.ts.map +1 -0
- package/dist/testing/pipeline/hostPipeline.js +18 -0
- package/dist/testing/{hydrateTestPipelineApp.d.ts → pipeline/hydrateTestPipelineApp.d.ts} +6 -6
- package/dist/testing/pipeline/hydrateTestPipelineApp.d.ts.map +1 -0
- package/dist/testing/{hydrateTestPipelineApp.js → pipeline/hydrateTestPipelineApp.js} +22 -19
- package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.d.ts +2 -0
- package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.d.ts.map +1 -0
- package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.js +27 -0
- package/dist/testing/pipeline/index.d.ts +5 -0
- package/dist/testing/pipeline/index.d.ts.map +1 -0
- package/dist/testing/pipeline/index.js +4 -0
- package/dist/testing/pipeline/pipelineTestApp.d.ts +34 -0
- package/dist/testing/pipeline/pipelineTestApp.d.ts.map +1 -0
- package/dist/testing/pipeline/pipelineTestApp.js +100 -0
- package/dist/testing/pipeline/testPipelineRoute.d.ts +2 -0
- package/dist/testing/pipeline/testPipelineRoute.d.ts.map +1 -0
- package/dist/testing/pipeline/testPipelineRoute.js +1 -0
- package/dist/testing/resolveContent.d.ts +2 -0
- package/dist/testing/resolveContent.d.ts.map +1 -1
- package/dist/testing/resolveContent.js +9 -1
- package/package.json +5 -3
- package/vendor/css-select.js +3383 -0
- package/vendor/manifest.json +4 -3
- package/dist/testing/createTestPipelineApp.d.ts +0 -25
- package/dist/testing/createTestPipelineApp.d.ts.map +0 -1
- package/dist/testing/createTestPipelineApp.js +0 -153
- package/dist/testing/hostPipeline.d.ts +0 -157
- package/dist/testing/hostPipeline.d.ts.map +0 -1
- package/dist/testing/hostPipeline.js +0 -341
- package/dist/testing/hydrateTestPipelineApp.d.ts.map +0 -1
|
@@ -0,0 +1,146 @@
|
|
|
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 { TungstenSimpleComponent } from "../../Components.js";
|
|
5
|
+
import { contextStore } from '../../pipeline/contextStore.js';
|
|
6
|
+
import { pipeline } from '../../pipeline/pipeline.js';
|
|
7
|
+
import { splitPipeline } from '../../pipeline/splitPipeline.js';
|
|
8
|
+
import { createTestPipelineApp } from './createTestPipelineApp.js';
|
|
9
|
+
// Type tests: tsc is the assertion - nothing here runs. The root says what it reads, from its
|
|
10
|
+
// pipeline base; the app handed in must make it
|
|
11
|
+
const stage = pipeline.server('express').init(() => ({
|
|
12
|
+
api: 'client'
|
|
13
|
+
})).allRoutesData(() => ({
|
|
14
|
+
theme: 'dark'
|
|
15
|
+
}));
|
|
16
|
+
const app = stage.routes(() => []);
|
|
17
|
+
class Reads extends stage.SimpleComponent {
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
super(...args);
|
|
20
|
+
_defineProperty(this, "content", () => `${this.tungsten.context.api} ${this.tungsten.allRoutesData.theme}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const other = pipeline.server('express').init(() => ({
|
|
24
|
+
db: 1
|
|
25
|
+
}));
|
|
26
|
+
class ReadsOther extends other.SimpleComponent {
|
|
27
|
+
constructor(...args) {
|
|
28
|
+
super(...args);
|
|
29
|
+
_defineProperty(this, "content", () => String(this.tungsten.context.db));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class Plain extends TungstenSimpleComponent {
|
|
33
|
+
constructor(...args) {
|
|
34
|
+
super(...args);
|
|
35
|
+
_defineProperty(this, "content", () => null);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function checks() {
|
|
39
|
+
await createTestPipelineApp(app, Reads);
|
|
40
|
+
// not a pipeline component: it reads nothing of the app's
|
|
41
|
+
await createTestPipelineApp(app, Plain);
|
|
42
|
+
// @ts-expect-error -- ReadsOther reads a context this app does not make
|
|
43
|
+
await createTestPipelineApp(app, ReadsOther);
|
|
44
|
+
// the server's all-routes data, in the app's shape
|
|
45
|
+
await createTestPipelineApp(app, Reads, {
|
|
46
|
+
allRoutesData: {
|
|
47
|
+
theme: 'light'
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
// @ts-expect-error -- not the app's all-routes data
|
|
51
|
+
await createTestPipelineApp(app, Reads, {
|
|
52
|
+
allRoutesData: {
|
|
53
|
+
theme: 1
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const _mismatch = true;
|
|
58
|
+
const _fits = true;
|
|
59
|
+
// a stage in place of the app: the harness adds empty routes
|
|
60
|
+
export async function stageChecks() {
|
|
61
|
+
await createTestPipelineApp(stage, Reads);
|
|
62
|
+
// @ts-expect-error -- another pipeline's stage
|
|
63
|
+
await createTestPipelineApp(other, Reads);
|
|
64
|
+
await createTestPipelineApp(stage, Reads, {
|
|
65
|
+
allRoutesData: {
|
|
66
|
+
theme: 'light'
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// @ts-expect-error -- not the stage's all-routes data
|
|
70
|
+
await createTestPipelineApp(stage, Reads, {
|
|
71
|
+
allRoutesData: {
|
|
72
|
+
theme: 1
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// no Init: the stage's context is undefined, which its components read as Nothing
|
|
77
|
+
const bare = pipeline.server('express');
|
|
78
|
+
class ReadsNothing extends bare.SimpleComponent {
|
|
79
|
+
constructor(...args) {
|
|
80
|
+
super(...args);
|
|
81
|
+
_defineProperty(this, "content", () => null);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export async function bareChecks() {
|
|
85
|
+
await createTestPipelineApp(bare.routes(() => []), ReadsNothing);
|
|
86
|
+
}
|
|
87
|
+
// the split pipeline: the networked data the components read, this.tungsten.networked
|
|
88
|
+
const split = splitPipeline.server('express').serverInit(() => ({
|
|
89
|
+
networked: {
|
|
90
|
+
count: contextStore({
|
|
91
|
+
n: 0
|
|
92
|
+
}),
|
|
93
|
+
userId: 0
|
|
94
|
+
}
|
|
95
|
+
})).clientInit(networked => ({
|
|
96
|
+
context: {
|
|
97
|
+
userId: networked.userId
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
const splitApp = split.routes(() => []);
|
|
101
|
+
class ReadsNetworked extends split.SimpleComponent {
|
|
102
|
+
constructor(...args) {
|
|
103
|
+
super(...args);
|
|
104
|
+
_defineProperty(this, "content", () => String(this.tungsten.networked.count.n.get()));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const _networked = true;
|
|
108
|
+
export async function splitChecks() {
|
|
109
|
+
await createTestPipelineApp(splitApp, ReadsNetworked, {
|
|
110
|
+
networked: {
|
|
111
|
+
count: contextStore({
|
|
112
|
+
n: 3
|
|
113
|
+
}),
|
|
114
|
+
userId: 7
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
await createTestPipelineApp(splitApp, ReadsNetworked, {
|
|
118
|
+
// @ts-expect-error -- not the networked data the app makes
|
|
119
|
+
networked: {
|
|
120
|
+
count: 3,
|
|
121
|
+
userId: 7
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// the server makes all-routes data, so clientInit's stage has no .routes() until the client's is
|
|
126
|
+
// given: the error says so
|
|
127
|
+
const serverData = splitPipeline.server('express').serverInit(() => undefined).serverAllRoutesData(() => ({
|
|
128
|
+
theme: 'dark'
|
|
129
|
+
}));
|
|
130
|
+
const noClientData = serverData.clientInit(() => undefined);
|
|
131
|
+
const withClientData = noClientData.clientAllRoutesData(() => ({
|
|
132
|
+
theme: 'dark'
|
|
133
|
+
}));
|
|
134
|
+
class ReadsTheme extends withClientData.SimpleComponent {
|
|
135
|
+
constructor(...args) {
|
|
136
|
+
super(...args);
|
|
137
|
+
_defineProperty(this, "content", () => this.tungsten.allRoutesData.theme);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const _noClientData = true;
|
|
141
|
+
const _notAStage = true;
|
|
142
|
+
export async function clientDataChecks() {
|
|
143
|
+
await createTestPipelineApp(withClientData, ReadsTheme);
|
|
144
|
+
// @ts-expect-error -- no .routes() yet
|
|
145
|
+
await createTestPipelineApp(noClientData, ReadsTheme);
|
|
146
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TungstenBaseComponent, TungstenComponentClass, TungstenComponentPropsBase } from '../../Components.jsx';
|
|
2
|
+
import type { ContentNodeElement } from '../../ContentNode.js';
|
|
3
|
+
import type { AppDataOptions, DontResolve, Hosted, HostedResolved, Resolve, ResolveOption, RouteOptions } from '../host.js';
|
|
4
|
+
export type { ComponentApi, Hosted, HostedResolved, HostedRoute, HostStoreOptions, Navigation, StateSetter, } from '../host.js';
|
|
5
|
+
export type HostPipelineOptions = RouteOptions & ResolveOption & AppDataOptions;
|
|
6
|
+
export type HostPipelineResolveOptions = RouteOptions & AppDataOptions & Resolve;
|
|
7
|
+
export type HostPipelineDontResolveOptions = RouteOptions & AppDataOptions & DontResolve;
|
|
8
|
+
type AnyClassComponent = TungstenBaseComponent<any, any>;
|
|
9
|
+
/** host() for a pipeline component: its data comes from the context, so there is no store option */
|
|
10
|
+
export declare function hostPipeline<Props extends TungstenComponentPropsBase, Component extends AnyClassComponent>(ComponentType: TungstenComponentClass<Props, Component>, props?: Props, options?: HostPipelineResolveOptions): Promise<HostedResolved<Component>>;
|
|
11
|
+
export declare function hostPipeline<Props extends TungstenComponentPropsBase, Component extends AnyClassComponent>(ComponentType: TungstenComponentClass<Props, Component>, props?: Props, options?: HostPipelineDontResolveOptions): Promise<Hosted<Component>>;
|
|
12
|
+
export declare function hostPipeline<Props extends TungstenComponentPropsBase, Component extends AnyClassComponent>(ComponentType: TungstenComponentClass<Props, Component>, props?: Props, options?: HostPipelineOptions): Promise<HostedResolved<Component> | Hosted<Component>>;
|
|
13
|
+
export declare namespace hostPipeline {
|
|
14
|
+
var generic: typeof hostPipelineGeneric;
|
|
15
|
+
var jsx: typeof hostPipelineJsx;
|
|
16
|
+
}
|
|
17
|
+
/** host.generic() with hostPipeline()'s options */
|
|
18
|
+
export declare function hostPipelineGeneric<Props extends TungstenComponentPropsBase, Component extends AnyClassComponent>(ComponentType: TungstenComponentClass<Props, Component>, options?: HostPipelineResolveOptions): (props: Props) => Promise<HostedResolved<Component>>;
|
|
19
|
+
export declare function hostPipelineGeneric<Props extends TungstenComponentPropsBase, Component extends AnyClassComponent>(ComponentType: TungstenComponentClass<Props, Component>, options: HostPipelineDontResolveOptions): (props: Props) => Promise<Hosted<Component>>;
|
|
20
|
+
export declare function hostPipelineGeneric<Props extends TungstenComponentPropsBase, Component extends AnyClassComponent>(ComponentType: TungstenComponentClass<Props, Component>, options?: HostPipelineOptions): (props: Props) => Promise<Hosted<Component> | HostedResolved<Component>>;
|
|
21
|
+
/** host.jsx() with hostPipeline()'s options */
|
|
22
|
+
export declare function hostPipelineJsx<Component extends AnyClassComponent = AnyClassComponent>(element: ContentNodeElement, options?: HostPipelineResolveOptions): Promise<HostedResolved<Component>>;
|
|
23
|
+
export declare function hostPipelineJsx<Component extends AnyClassComponent = AnyClassComponent>(element: ContentNodeElement, options: HostPipelineDontResolveOptions): Promise<Hosted<Component>>;
|
|
24
|
+
export declare function hostPipelineJsx<Component extends AnyClassComponent = AnyClassComponent>(element: ContentNodeElement, options?: HostPipelineOptions): Promise<Hosted<Component> | HostedResolved<Component>>;
|
|
25
|
+
//# sourceMappingURL=hostPipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostPipeline.d.ts","sourceRoot":"","sources":["../../../src/testing/pipeline/hostPipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,qBAAqB,EAAE,sBAAsB,EAAE,0BAA0B,EAC5E,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,KAAK,EACR,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAC5F,MAAM,YAAY,CAAA;AAGnB,YAAY,EACR,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,GAC/F,MAAM,YAAY,CAAA;AAInB,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,CAAA;AAE/E,MAAM,MAAM,0BAA0B,GAAG,YAAY,GAAG,cAAc,GAAG,OAAO,CAAA;AAChF,MAAM,MAAM,8BAA8B,GAAG,YAAY,GAAG,cAAc,GAAG,WAAW,CAAA;AAExF,KAAK,iBAAiB,GAAG,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAOxD,oGAAoG;AAEpG,wBAAsB,YAAY,CAC9B,KAAK,SAAS,0BAA0B,EACxC,SAAS,SAAS,iBAAiB,EAEnC,aAAa,EAAE,sBAAsB,CAAC,KAAK,EAAE,SAAS,CAAC,EACvD,KAAK,CAAC,EAAE,KAAK,EACb,OAAO,CAAC,EAAE,0BAA0B,GACrC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA;AAErC,wBAAsB,YAAY,CAC9B,KAAK,SAAS,0BAA0B,EACxC,SAAS,SAAS,iBAAiB,EAEnC,aAA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AAC,SAAS,CAAC,CAAC,CAAA;AAY3E,+CAA+C;AAE/C,wBAAsB,eAAe,CAAC,SAAS,SAAS,iBAAiB,GAAG,iBAAiB,EACzF,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAClE,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA;AAErC,wBAAsB,eAAe,CAAC,SAAS,SAAS,iBAAiB,GAAG,iBAAiB,EACzF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,8BAA8B,GACrE,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;AAE7B,wBAAsB,eAAe,CAAC,SAAS,SAAS,iBAAiB,GAAG,iBAAiB,EACzF,OAAO,EAAE,kBAAkB,EAC3B,OAAO,CAAC,EAAE,mBAAmB,GAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { host, hostJsx } from '../host.js';
|
|
2
|
+
// host()'s implementation signature, which its overloads hide
|
|
3
|
+
const hostImplementation = host;
|
|
4
|
+
// Implementation
|
|
5
|
+
export async function hostPipeline(ComponentType, props, options) {
|
|
6
|
+
return hostImplementation(ComponentType, props, options);
|
|
7
|
+
}
|
|
8
|
+
// implementation
|
|
9
|
+
export function hostPipelineGeneric(ComponentType, options) {
|
|
10
|
+
return async props => hostImplementation(ComponentType, props, options);
|
|
11
|
+
}
|
|
12
|
+
// implementation
|
|
13
|
+
export async function hostPipelineJsx(element, options) {
|
|
14
|
+
return hostJsx(element, options); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- the overloads above type them
|
|
15
|
+
}
|
|
16
|
+
// the variants hang off hostPipeline() too, as host()'s do
|
|
17
|
+
hostPipeline.generic = hostPipelineGeneric;
|
|
18
|
+
hostPipeline.jsx = hostPipelineJsx;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ConstructPackage, TungstenBaseComponent, TungstenComponentPropsBase } from '
|
|
2
|
-
import type { ReqRes } from '
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { HydrateTestApp } from '
|
|
1
|
+
import type { ConstructPackage, TungstenBaseComponent, TungstenComponentPropsBase } from '../../Components.jsx';
|
|
2
|
+
import type { ReqRes } from '../../ReqRes.js';
|
|
3
|
+
import type { TestStoreOverride } from '../createTestApp.js';
|
|
4
|
+
import type { AppCheck } from './createTestPipelineApp.js';
|
|
5
|
+
import type { HydrateTestApp } from '../hydrateTestApp.js';
|
|
6
6
|
export type HydrateTestPipelineAppOptions<Props extends object> = {
|
|
7
7
|
document?: Document;
|
|
8
8
|
props?: Props;
|
|
@@ -25,6 +25,6 @@ type HydrateTestPipelineAppArgs<Props extends object> = object extends Props ? [
|
|
|
25
25
|
* hydrates the parsed HTML. So a component whose markup depends on a context only one side makes
|
|
26
26
|
* shows up in `mismatches`, or throws on a structural difference.
|
|
27
27
|
*/
|
|
28
|
-
export declare function hydrateTestPipelineApp<Props extends TungstenComponentPropsBase, Component extends TungstenBaseComponent<any, any>, RouteData = undefined>(
|
|
28
|
+
export declare function hydrateTestPipelineApp<Props extends TungstenComponentPropsBase, Component extends TungstenBaseComponent<any, any>, A extends object, RouteData = undefined>(pipelineOrApp: A & AppCheck<A, Component>, RootComponent: new (pkg: ConstructPackage<Props, RouteData>) => Component, ...args: HydrateTestPipelineAppArgs<Props>): Promise<HydrateTestPipelineApp<Component>>;
|
|
29
29
|
export {};
|
|
30
30
|
//# sourceMappingURL=hydrateTestPipelineApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrateTestPipelineApp.d.ts","sourceRoot":"","sources":["../../../src/testing/pipeline/hydrateTestPipelineApp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAAE,qBAAqB,EAAE,0BAA0B,EACtE,MAAM,sBAAsB,CAAA;AAI7B,OA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EAEjD,CAAC,SAAS,MAAM,EAChB,SAAS,GAAG,SAAS,EAErB,aAAa,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,EACzC,aAAa,EAAE,KAAK,GAAG,EAAE,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,SAAS,EACzE,GAAG,IAAI,EAAE,0BAA0B,CAAC,KAAK,CAAC,GAC3C,OAAO,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAiJ5C"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { $props, $type } from '
|
|
2
|
-
import { DomPointer } from '
|
|
3
|
-
import { hydrateRootComponent, hydrationRouting, makeDefaultHydrateMeta } from "
|
|
4
|
-
import { Instance } from '
|
|
5
|
-
import { JSONstringify } from '
|
|
6
|
-
import { NetworkedTransport } from '
|
|
7
|
-
import { afterRoutingFor, pipelineRoutes, routingContext, routingNetworkedData, symmetricServer } from '
|
|
8
|
-
import { clientRoute } from '
|
|
9
|
-
import { splitServer } from '
|
|
10
|
-
import { contentTreeToRenderingTree } from '
|
|
11
|
-
import { renderingNodeToHtml } from '
|
|
12
|
-
import { initStores } from '
|
|
13
|
-
import { UpdateScheduler } from '
|
|
14
|
-
import { bridgeHappyDomGlobals, HydrateTestAppImplementation, requireClient } from '
|
|
15
|
-
import {
|
|
1
|
+
import { $props, $type } from '../../contentNodeSymbols.js';
|
|
2
|
+
import { DomPointer } from '../../DomPointer.js';
|
|
3
|
+
import { hydrateRootComponent, hydrationRouting, makeDefaultHydrateMeta } from "../../hydrate/hydrate.js";
|
|
4
|
+
import { Instance } from '../../Instance/Instance.js';
|
|
5
|
+
import { JSONstringify } from '../../json.js';
|
|
6
|
+
import { NetworkedTransport } from '../../pipeline/networkedTransport.js';
|
|
7
|
+
import { afterRoutingFor, pipelineRoutes, routingContext, routingNetworkedData, symmetricServer } from '../../pipeline/runPipeline.js';
|
|
8
|
+
import { clientRoute } from '../../pipeline/pipelineDefinition.js';
|
|
9
|
+
import { splitServer } from '../../pipeline/runSplitPipeline.js';
|
|
10
|
+
import { contentTreeToRenderingTree } from '../../render/contentTreeToRenderingTree.js';
|
|
11
|
+
import { renderingNodeToHtml } from '../../render/renderingTreeToHtml.js';
|
|
12
|
+
import { initStores } from '../../Servers/initStores.js';
|
|
13
|
+
import { UpdateScheduler } from '../../update/UpdateScheduler.js';
|
|
14
|
+
import { bridgeHappyDomGlobals, HydrateTestAppImplementation, requireClient } from '../hydrateTestApp.js';
|
|
15
|
+
import { toApp } from './createTestPipelineApp.js';
|
|
16
|
+
import { waitForEnvIfLoading } from '../loadEnv.js';
|
|
16
17
|
// the framework brands what it builds
|
|
17
18
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
18
19
|
const asGlobalData = data => data;
|
|
@@ -31,9 +32,10 @@ const appRoutesFor = (app, init) => reqRes => pipelineRoutes(app, reqRes, init,
|
|
|
31
32
|
* hydrates the parsed HTML. So a component whose markup depends on a context only one side makes
|
|
32
33
|
* shows up in `mismatches`, or throws on a structural difference.
|
|
33
34
|
*/
|
|
34
|
-
export async function hydrateTestPipelineApp(
|
|
35
|
+
export async function hydrateTestPipelineApp(pipelineOrApp, RootComponent, ...args) {
|
|
35
36
|
requireClient('hydrateTestPipelineApp()');
|
|
36
37
|
await waitForEnvIfLoading();
|
|
38
|
+
const app = toApp(pipelineOrApp);
|
|
37
39
|
const options = args[0];
|
|
38
40
|
const suppliedDocument = options?.document ?? globalThis.document;
|
|
39
41
|
if (suppliedDocument === undefined) {
|
|
@@ -131,7 +133,7 @@ export async function hydrateTestPipelineApp(app, RootComponent, ...args) {
|
|
|
131
133
|
container.innerHTML = html;
|
|
132
134
|
bridgeHappyDomGlobals(document);
|
|
133
135
|
// Client pass: the app's own client run, with the page's data, as hydratePipeline() runs it
|
|
134
|
-
const ran = await app.client(app,
|
|
136
|
+
const ran = await app.client(app, fromPage);
|
|
135
137
|
const routes = pipelineRoutes(app, null, ran.init, true);
|
|
136
138
|
const {
|
|
137
139
|
key,
|
|
@@ -145,8 +147,9 @@ export async function hydrateTestPipelineApp(app, RootComponent, ...args) {
|
|
|
145
147
|
data
|
|
146
148
|
} : {})
|
|
147
149
|
}, routes);
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
+
const posted = await ran.post(serverGlobalData);
|
|
151
|
+
const afterRouting = afterRoutingFor(posted.afterRouting);
|
|
152
|
+
const context = afterRouting === undefined ? asContext(posted.context) : await afterRouting(clientRoute(matchedRouteInfo, location), serverGlobalData);
|
|
150
153
|
const networkedData = routingNetworkedData(ran.routingNetworkedData);
|
|
151
154
|
const scheduler = new UpdateScheduler();
|
|
152
155
|
const {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrateTestPipelineApp.types.test.d.ts","sourceRoot":"","sources":["../../../src/testing/pipeline/hydrateTestPipelineApp.types.test.ts"],"names":[],"mappings":"AAeA,wBAAsB,MAAM,kBAO3B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { pipeline } from '../../pipeline/pipeline.js';
|
|
5
|
+
import { hydrateTestPipelineApp } from './hydrateTestPipelineApp.js';
|
|
6
|
+
// Type tests: tsc is the assertion - nothing here runs. The app or stage must make what the root
|
|
7
|
+
// reads, as createTestPipelineApp()'s must
|
|
8
|
+
const stage = pipeline.server('express').init(() => ({
|
|
9
|
+
api: 'client'
|
|
10
|
+
}));
|
|
11
|
+
class Reads extends stage.SimpleComponent {
|
|
12
|
+
constructor(...args) {
|
|
13
|
+
super(...args);
|
|
14
|
+
_defineProperty(this, "content", () => this.tungsten.context.api);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const other = pipeline.server('express').init(() => ({
|
|
18
|
+
db: 1
|
|
19
|
+
}));
|
|
20
|
+
export async function checks() {
|
|
21
|
+
await hydrateTestPipelineApp(stage.routes(() => []), Reads);
|
|
22
|
+
await hydrateTestPipelineApp(stage, Reads);
|
|
23
|
+
// @ts-expect-error -- another pipeline's app
|
|
24
|
+
await hydrateTestPipelineApp(other.routes(() => []), Reads);
|
|
25
|
+
// @ts-expect-error -- another pipeline's stage
|
|
26
|
+
await hydrateTestPipelineApp(other, Reads);
|
|
27
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type AppCheck, type CreateTestPipelineAppArgs, type TestPipelineApp, type TestPipelineAppOptions, createTestPipelineApp, } from './createTestPipelineApp.js';
|
|
2
|
+
export { type CreateTestPacketAppArgs, type PacketForComponent, type TestPacketAppOptions, createTestPacketApp, } from './createTestPacketApp.js';
|
|
3
|
+
export { type HydrateTestPipelineApp, type HydrateTestPipelineAppOptions, hydrateTestPipelineApp, } from './hydrateTestPipelineApp.js';
|
|
4
|
+
export { type HostPipelineDontResolveOptions, type HostPipelineOptions, type HostPipelineResolveOptions, type HostStoreOptions, type Hosted, type HostedResolved, type HostedRoute, hostPipeline, hostPipelineGeneric, hostPipelineJsx, } from './hostPipeline.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/pipeline/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,QAAQ,EAAE,KAAK,yBAAyB,EAAE,KAAK,eAAe,EACnE,KAAK,sBAAsB,EAC3B,qBAAqB,GACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACH,KAAK,uBAAuB,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAChF,mBAAmB,GACtB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACH,KAAK,sBAAsB,EAAE,KAAK,6BAA6B,EAC/D,sBAAsB,GACzB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACH,KAAK,8BAA8B,EAAE,KAAK,mBAAmB,EAAE,KAAK,0BAA0B,EAC9F,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EACzE,YAAY,EAAE,mBAAmB,EAAE,eAAe,GACrD,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createTestPipelineApp } from './createTestPipelineApp.js';
|
|
2
|
+
export { createTestPacketApp } from './createTestPacketApp.js';
|
|
3
|
+
export { hydrateTestPipelineApp } from './hydrateTestPipelineApp.js';
|
|
4
|
+
export { hostPipeline, hostPipelineGeneric, hostPipelineJsx } from './hostPipeline.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ConstructPackage, TungstenBaseComponent } from '../../Components.jsx';
|
|
2
|
+
import type { AsGlobalData, BrandedContext, BrandedNetworkedData } from '../../Brands.js';
|
|
3
|
+
import type { InstancePipeline } from '../../Instance/Instance.js';
|
|
4
|
+
import type { AppRoutes } from '../../routing/AppRoutes.js';
|
|
5
|
+
import type { MatchedRouteInfo } from '../../routing/MatchedRouteInfo.js';
|
|
6
|
+
import type { RoutesWithSettings } from '../../routing/Routes.js';
|
|
7
|
+
import { type TestApp, type TestStoreOverride } from '../createTestApp.js';
|
|
8
|
+
export type PipelineTestAppOptions<Props extends object> = {
|
|
9
|
+
document?: Document;
|
|
10
|
+
props?: Props;
|
|
11
|
+
container?: HTMLElement;
|
|
12
|
+
location?: string;
|
|
13
|
+
stores?: readonly TestStoreOverride<any>[];
|
|
14
|
+
fileVersions?: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
export type PipelineTestTarget = {
|
|
17
|
+
document: Document;
|
|
18
|
+
container: HTMLElement;
|
|
19
|
+
ownsContainer: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type PipelineTestData = {
|
|
22
|
+
location: string;
|
|
23
|
+
routes: RoutesWithSettings<any>;
|
|
24
|
+
appRoutes: AppRoutes<any>;
|
|
25
|
+
matchedRouteInfo: MatchedRouteInfo;
|
|
26
|
+
allRoutesData: AsGlobalData;
|
|
27
|
+
context: BrandedContext;
|
|
28
|
+
networkedData: BrandedNetworkedData;
|
|
29
|
+
networked: object;
|
|
30
|
+
pipeline: InstancePipeline;
|
|
31
|
+
};
|
|
32
|
+
export declare function pipelineTestTarget(options: PipelineTestAppOptions<object> | undefined, name: string): PipelineTestTarget;
|
|
33
|
+
export declare function mountPipelineTestApp<Props extends object, Component extends TungstenBaseComponent, RouteData>(target: PipelineTestTarget, data: PipelineTestData, RootComponent: new (pkg: ConstructPackage<Props, RouteData>) => Component, options: PipelineTestAppOptions<Props> | undefined): Promise<TestApp<Component>>;
|
|
34
|
+
//# sourceMappingURL=pipelineTestApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipelineTestApp.d.ts","sourceRoot":"","sources":["../../../src/testing/pipeline/pipelineTestApp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAKjE,OAAO,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BAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,SAAS,EACzE,OAAO,EAAE,sBAAsB,CAAC,KAAK,CAAC,GAAG,SAAS,GACnD,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAkF7B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Instance } from '../../Instance/Instance.js';
|
|
2
|
+
import { initStores } from '../../Servers/initStores.js';
|
|
3
|
+
import { createTungstenRootComponent } from '../../update/integrateUpdateVdom.js';
|
|
4
|
+
import { UpdateScheduler } from '../../update/UpdateScheduler.js';
|
|
5
|
+
import { TestAppImplementation } from '../createTestApp.js';
|
|
6
|
+
// checked before anything runs
|
|
7
|
+
export function pipelineTestTarget(options, name) {
|
|
8
|
+
const suppliedDocument = options?.document ?? globalThis.document;
|
|
9
|
+
if (suppliedDocument === undefined) {
|
|
10
|
+
// eslint-disable-line @typescript-eslint/no-unnecessary-condition
|
|
11
|
+
throw new Error(`${name} requires options.document when no global document is available.`);
|
|
12
|
+
}
|
|
13
|
+
const document = suppliedDocument;
|
|
14
|
+
const ownsContainer = options?.container === undefined;
|
|
15
|
+
const container = options?.container ?? document.createElement('div');
|
|
16
|
+
if (container.ownerDocument !== document) {
|
|
17
|
+
throw new Error('The TestApp container must belong to options.document.');
|
|
18
|
+
}
|
|
19
|
+
if (container.childNodes.length > 0) {
|
|
20
|
+
throw new Error('The TestApp container must be empty before mounting.');
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
document,
|
|
24
|
+
container,
|
|
25
|
+
ownsContainer
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export async function mountPipelineTestApp(target, data, RootComponent, options) {
|
|
29
|
+
const {
|
|
30
|
+
document,
|
|
31
|
+
container,
|
|
32
|
+
ownsContainer
|
|
33
|
+
} = target;
|
|
34
|
+
const {
|
|
35
|
+
location,
|
|
36
|
+
allRoutesData,
|
|
37
|
+
matchedRouteInfo,
|
|
38
|
+
context,
|
|
39
|
+
networkedData
|
|
40
|
+
} = data;
|
|
41
|
+
if (ownsContainer) {
|
|
42
|
+
if (document.body === null) {
|
|
43
|
+
// eslint-disable-line @typescript-eslint/no-unnecessary-condition
|
|
44
|
+
throw new Error('The supplied document must have a body element.');
|
|
45
|
+
}
|
|
46
|
+
document.body.appendChild(container);
|
|
47
|
+
}
|
|
48
|
+
const scheduler = new UpdateScheduler();
|
|
49
|
+
const runtimeContext = {
|
|
50
|
+
document,
|
|
51
|
+
window: document.defaultView,
|
|
52
|
+
scheduler,
|
|
53
|
+
navigation: false
|
|
54
|
+
};
|
|
55
|
+
const {
|
|
56
|
+
internalStore,
|
|
57
|
+
stores,
|
|
58
|
+
storeSubscriptions
|
|
59
|
+
} = initStores(location, null, allRoutesData, matchedRouteInfo, null, context, networkedData);
|
|
60
|
+
const instanceConfig = {
|
|
61
|
+
prod: false,
|
|
62
|
+
useRootComponent: true,
|
|
63
|
+
clientSideNav: true,
|
|
64
|
+
siteBasePath: '/',
|
|
65
|
+
staticSite: false,
|
|
66
|
+
csr: false
|
|
67
|
+
};
|
|
68
|
+
const instance = new Instance(location, instanceConfig, null, data.appRoutes, data.routes, internalStore, stores, storeSubscriptions, allRoutesData, matchedRouteInfo, runtimeContext);
|
|
69
|
+
instance.fileVersions = options?.fileVersions;
|
|
70
|
+
instance.context = context;
|
|
71
|
+
instance.networkedData = networkedData;
|
|
72
|
+
instance.pipelineNetworked = data.networked;
|
|
73
|
+
instance.pipeline = data.pipeline;
|
|
74
|
+
try {
|
|
75
|
+
for (const override of options?.stores ?? []) {
|
|
76
|
+
const store = override.registration.getStore(instance.stores);
|
|
77
|
+
await override.initialize(store);
|
|
78
|
+
}
|
|
79
|
+
const props = options?.props ?? {};
|
|
80
|
+
const root = await createTungstenRootComponent(RootComponent, props, matchedRouteInfo.params, matchedRouteInfo.data, instance, container);
|
|
81
|
+
const testApp = new TestAppImplementation(document, container, root.component, instance, scheduler, root, ownsContainer);
|
|
82
|
+
try {
|
|
83
|
+
await testApp.resolved();
|
|
84
|
+
return testApp;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
await testApp.unmount();
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
try {
|
|
91
|
+
instance.disposeRegisteredComponents();
|
|
92
|
+
} catch {
|
|
93
|
+
// Preserve the mount failure.
|
|
94
|
+
}
|
|
95
|
+
scheduler.dispose();
|
|
96
|
+
while (container.firstChild !== null) container.removeChild(container.firstChild);
|
|
97
|
+
if (ownsContainer) container.remove();
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testPipelineRoute.d.ts","sourceRoot":"","sources":["../../../src/testing/pipeline/testPipelineRoute.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,5 +12,7 @@ import type { ContentNode } from '../ContentNode.js';
|
|
|
12
12
|
* by name and by prop as well as by what it put on the page.
|
|
13
13
|
*/
|
|
14
14
|
export declare function resolveContent(content: ContentNode, parentComponent: AnyComponent | null, instance: Instance, constructed?: Constructed): Promise<ContentNode>;
|
|
15
|
+
/** On a component node resolveContent resolved: the children it was passed, its own now output */
|
|
16
|
+
export declare const $passedChildren: unique symbol;
|
|
15
17
|
export type Constructed = (component: object) => void;
|
|
16
18
|
//# sourceMappingURL=resolveContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveContent.d.ts","sourceRoot":"","sources":["../../src/testing/resolveContent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAA4C,MAAM,mBAAmB,CAAA;AAa9F;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAChC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAG9E,WAAW,CAAC,EAAE,WAAW,GAC1B,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"resolveContent.d.ts","sourceRoot":"","sources":["../../src/testing/resolveContent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAA4C,MAAM,mBAAmB,CAAA;AAa9F;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAChC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAG9E,WAAW,CAAC,EAAE,WAAW,GAC1B,OAAO,CAAC,WAAW,CAAC,CAqBtB;AAED,kGAAkG;AAClG,eAAO,MAAM,eAAe,eAA2B,CAAA;AAEvD,MAAM,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA"}
|
|
@@ -32,8 +32,16 @@ constructed) {
|
|
|
32
32
|
if (!ContentNodeElementIsComponent(content)) {
|
|
33
33
|
return withChildren(content, await resolveContent(content[$props].children, parentComponent, instance, constructed));
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
const output = await rendered(content, parentComponent, instance, constructed);
|
|
36
|
+
const resolved = withChildren(content, output);
|
|
37
|
+
// non-enumerable, so a resolved node still deep-equals one written by hand
|
|
38
|
+
Object.defineProperty(resolved, $passedChildren, {
|
|
39
|
+
value: content[$props].children
|
|
40
|
+
});
|
|
41
|
+
return resolved;
|
|
36
42
|
}
|
|
43
|
+
/** On a component node resolveContent resolved: the children it was passed, its own now output */
|
|
44
|
+
export const $passedChildren = Symbol('passedChildren');
|
|
37
45
|
// what the component put on the page, resolved in its turn.
|
|
38
46
|
// As render/componentNodeToRenderingTree: a component the app renders on the client alone never
|
|
39
47
|
// runs its content here, so its placeholder stands for it
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tungsten",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"./library": "./dist/components/library/index.js",
|
|
14
14
|
"./react-zone": "./dist/zones/react.js",
|
|
15
15
|
"./testing": "./dist/testing/index.js",
|
|
16
|
+
"./testing/pipeline": "./dist/testing/pipeline/index.js",
|
|
16
17
|
"./jsx-runtime": "./dist/jsx-runtime.js",
|
|
17
18
|
"./*": "./dist/*",
|
|
18
19
|
"./types/*": "./types/*"
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"chalk-extensions": "^2.0.24",
|
|
52
53
|
"chokidar": "^3.6.0",
|
|
53
54
|
"cjs-module-lexer": "^1.4.3",
|
|
55
|
+
"css-select": "^7.0.0",
|
|
54
56
|
"csstype": "^3.2.3",
|
|
55
57
|
"deep-eql": "^4.1.4",
|
|
56
58
|
"dotenv": "^16.6.1",
|
|
@@ -120,8 +122,8 @@
|
|
|
120
122
|
},
|
|
121
123
|
"scripts": {
|
|
122
124
|
"__build": "pnpm clean && pnpm build-prep && pnpm build-watch",
|
|
123
|
-
"build": "run-s -c clean build-prep build-watch",
|
|
124
|
-
"build
|
|
125
|
+
"build-old": "run-s -c clean build-prep build-watch",
|
|
126
|
+
"build": "rimraf dist && tscmon --on-first-success \"pnpm build-babel\"",
|
|
125
127
|
"clean": "rimraf intermed dist",
|
|
126
128
|
"build-prep": "pnpm build-ts-once",
|
|
127
129
|
"build-watch": "run-p build-ts build-babel",
|