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.
Files changed (146) hide show
  1. package/dist/.build-complete +1 -1
  2. package/dist/FrameworkConfig.d.ts +2 -0
  3. package/dist/FrameworkConfig.d.ts.map +1 -1
  4. package/dist/FrameworkConfig.types.test.d.ts +2 -0
  5. package/dist/FrameworkConfig.types.test.d.ts.map +1 -0
  6. package/dist/FrameworkConfig.types.test.js +6 -0
  7. package/dist/Instance/Instance.d.ts.map +1 -1
  8. package/dist/Instance/Instance.js +6 -33
  9. package/dist/Instance/InstanceConfig.d.ts +1 -0
  10. package/dist/Instance/InstanceConfig.d.ts.map +1 -1
  11. package/dist/Servers/DevServer.d.ts.map +1 -1
  12. package/dist/Servers/DevServer.js +10 -1
  13. package/dist/Servers/ProdServer.d.ts +1 -0
  14. package/dist/Servers/ProdServer.d.ts.map +1 -1
  15. package/dist/Servers/ProdServer.js +18 -1
  16. package/dist/Servers/routing.d.ts.map +1 -1
  17. package/dist/Servers/routing.js +9 -5
  18. package/dist/Servers/stubInstance.d.ts +8 -0
  19. package/dist/Servers/stubInstance.d.ts.map +1 -0
  20. package/dist/Servers/stubInstance.js +40 -0
  21. package/dist/build/createInstanceConfigFile.d.ts.map +1 -1
  22. package/dist/build/createInstanceConfigFile.js +1 -1
  23. package/dist/build/rollupProdConstants.d.ts.map +1 -1
  24. package/dist/componentHelpers.d.ts +2 -1
  25. package/dist/componentHelpers.d.ts.map +1 -1
  26. package/dist/componentHelpers.js +3 -0
  27. package/dist/frameworkConfigSchema.d.ts +2 -0
  28. package/dist/frameworkConfigSchema.d.ts.map +1 -1
  29. package/dist/frameworkConfigSchema.js +4 -1
  30. package/dist/getUserConfig.d.ts.map +1 -1
  31. package/dist/hydrate/hydrate.d.ts.map +1 -1
  32. package/dist/hydrate/hydrate.js +31 -10
  33. package/dist/hydrate/stubRouting.d.ts +8 -0
  34. package/dist/hydrate/stubRouting.d.ts.map +1 -0
  35. package/dist/hydrate/stubRouting.js +25 -0
  36. package/dist/makeFinalConfig.d.ts.map +1 -1
  37. package/dist/makeFinalConfig.js +2 -0
  38. package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -1
  39. package/dist/makeInstanceConfigFromFrameworkConfig.js +1 -0
  40. package/dist/pipeline/PipelineRequestHandler.d.ts.map +1 -1
  41. package/dist/pipeline/PipelineRequestHandler.js +9 -1
  42. package/dist/pipeline/hydratePipeline.d.ts.map +1 -1
  43. package/dist/pipeline/hydratePipeline.js +28 -9
  44. package/dist/pipeline/pipeline.d.ts +35 -33
  45. package/dist/pipeline/pipeline.d.ts.map +1 -1
  46. package/dist/pipeline/pipeline.js +10 -5
  47. package/dist/pipeline/pipeline.types.test.d.ts +186 -76
  48. package/dist/pipeline/pipeline.types.test.d.ts.map +1 -1
  49. package/dist/pipeline/pipeline.types.test.js +2 -0
  50. package/dist/pipeline/pipelineDefinition.d.ts +20 -9
  51. package/dist/pipeline/pipelineDefinition.d.ts.map +1 -1
  52. package/dist/pipeline/pipelineSplit.types.test.d.ts +598 -124
  53. package/dist/pipeline/pipelineSplit.types.test.d.ts.map +1 -1
  54. package/dist/pipeline/runPipeline.d.ts +6 -8
  55. package/dist/pipeline/runPipeline.d.ts.map +1 -1
  56. package/dist/pipeline/runPipeline.js +8 -8
  57. package/dist/pipeline/runSplitPipeline.d.ts +3 -3
  58. package/dist/pipeline/runSplitPipeline.d.ts.map +1 -1
  59. package/dist/pipeline/runSplitPipeline.js +12 -8
  60. package/dist/pipeline/splitPipeline.d.ts +8 -8
  61. package/dist/pipeline/splitPipeline.d.ts.map +1 -1
  62. package/dist/render/contentTreeToRenderingTree.d.ts.map +1 -1
  63. package/dist/render/contentTreeToRenderingTree.js +4 -1
  64. package/dist/routing/MatchedRouteInfo.d.ts +2 -0
  65. package/dist/routing/MatchedRouteInfo.d.ts.map +1 -1
  66. package/dist/routing/MatchedRouteInfo.js +1 -1
  67. package/dist/routing/RouteContentFunction.d.ts +1 -1
  68. package/dist/routing/RouteContentFunction.d.ts.map +1 -1
  69. package/dist/routing/RouteTypes.d.ts +1 -1
  70. package/dist/routing/RouteTypes.d.ts.map +1 -1
  71. package/dist/routing/Routes.d.ts +6 -3
  72. package/dist/routing/Routes.d.ts.map +1 -1
  73. package/dist/routing/builder.d.ts +2 -1
  74. package/dist/routing/builder.d.ts.map +1 -1
  75. package/dist/routing/builder.js +6 -0
  76. package/dist/routing/redirectOf.d.ts +11 -0
  77. package/dist/routing/redirectOf.d.ts.map +1 -0
  78. package/dist/routing/redirectOf.js +32 -0
  79. package/dist/routing/routesArray.d.ts +2 -2
  80. package/dist/routing/routesArray.d.ts.map +1 -1
  81. package/dist/routing/routingBuilder.js +0 -1
  82. package/dist/testing/contentToString.d.ts +13 -0
  83. package/dist/testing/contentToString.d.ts.map +1 -0
  84. package/dist/testing/contentToString.js +105 -0
  85. package/dist/testing/display.d.ts +2 -0
  86. package/dist/testing/display.d.ts.map +1 -0
  87. package/dist/testing/display.js +37 -0
  88. package/dist/testing/ensure.d.ts +52 -41
  89. package/dist/testing/ensure.d.ts.map +1 -1
  90. package/dist/testing/ensure.js +204 -62
  91. package/dist/testing/ensure.types.test.d.ts +2 -0
  92. package/dist/testing/ensure.types.test.d.ts.map +1 -0
  93. package/dist/testing/ensure.types.test.js +34 -0
  94. package/dist/testing/host.d.ts +25 -25
  95. package/dist/testing/host.d.ts.map +1 -1
  96. package/dist/testing/host.js +1 -3
  97. package/dist/testing/host.types.test.d.ts +2 -0
  98. package/dist/testing/host.types.test.d.ts.map +1 -0
  99. package/dist/testing/host.types.test.js +81 -0
  100. package/dist/testing/hydrateTestApp.js +4 -3
  101. package/dist/testing/index.d.ts +2 -3
  102. package/dist/testing/index.d.ts.map +1 -1
  103. package/dist/testing/index.js +1 -2
  104. package/dist/testing/pipeline/createTestPacketApp.d.ts +30 -0
  105. package/dist/testing/pipeline/createTestPacketApp.d.ts.map +1 -0
  106. package/dist/testing/pipeline/createTestPacketApp.js +45 -0
  107. package/dist/testing/pipeline/createTestPacketApp.types.test.d.ts +3 -0
  108. package/dist/testing/pipeline/createTestPacketApp.types.test.d.ts.map +1 -0
  109. package/dist/testing/pipeline/createTestPacketApp.types.test.js +101 -0
  110. package/dist/testing/pipeline/createTestPipelineApp.d.ts +70 -0
  111. package/dist/testing/pipeline/createTestPipelineApp.d.ts.map +1 -0
  112. package/dist/testing/pipeline/createTestPipelineApp.js +90 -0
  113. package/dist/testing/pipeline/createTestPipelineApp.types.test.d.ts +6 -0
  114. package/dist/testing/pipeline/createTestPipelineApp.types.test.d.ts.map +1 -0
  115. package/dist/testing/pipeline/createTestPipelineApp.types.test.js +146 -0
  116. package/dist/testing/pipeline/hostPipeline.d.ts +25 -0
  117. package/dist/testing/pipeline/hostPipeline.d.ts.map +1 -0
  118. package/dist/testing/pipeline/hostPipeline.js +18 -0
  119. package/dist/testing/{hydrateTestPipelineApp.d.ts → pipeline/hydrateTestPipelineApp.d.ts} +6 -6
  120. package/dist/testing/pipeline/hydrateTestPipelineApp.d.ts.map +1 -0
  121. package/dist/testing/{hydrateTestPipelineApp.js → pipeline/hydrateTestPipelineApp.js} +22 -19
  122. package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.d.ts +2 -0
  123. package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.d.ts.map +1 -0
  124. package/dist/testing/pipeline/hydrateTestPipelineApp.types.test.js +27 -0
  125. package/dist/testing/pipeline/index.d.ts +5 -0
  126. package/dist/testing/pipeline/index.d.ts.map +1 -0
  127. package/dist/testing/pipeline/index.js +4 -0
  128. package/dist/testing/pipeline/pipelineTestApp.d.ts +34 -0
  129. package/dist/testing/pipeline/pipelineTestApp.d.ts.map +1 -0
  130. package/dist/testing/pipeline/pipelineTestApp.js +100 -0
  131. package/dist/testing/pipeline/testPipelineRoute.d.ts +2 -0
  132. package/dist/testing/pipeline/testPipelineRoute.d.ts.map +1 -0
  133. package/dist/testing/pipeline/testPipelineRoute.js +1 -0
  134. package/dist/testing/resolveContent.d.ts +2 -0
  135. package/dist/testing/resolveContent.d.ts.map +1 -1
  136. package/dist/testing/resolveContent.js +9 -1
  137. package/package.json +5 -3
  138. package/vendor/css-select.js +3383 -0
  139. package/vendor/manifest.json +4 -3
  140. package/dist/testing/createTestPipelineApp.d.ts +0 -25
  141. package/dist/testing/createTestPipelineApp.d.ts.map +0 -1
  142. package/dist/testing/createTestPipelineApp.js +0 -153
  143. package/dist/testing/hostPipeline.d.ts +0 -157
  144. package/dist/testing/hostPipeline.d.ts.map +0 -1
  145. package/dist/testing/hostPipeline.js +0 -341
  146. package/dist/testing/hydrateTestPipelineApp.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "lockfile": {
3
- "size": 237442,
4
- "mtimeMs": 1789980238522.3574
3
+ "size": 239726,
4
+ "mtimeMs": 1790613012060.566
5
5
  },
6
6
  "specifiers": {
7
7
  "@babel/core": "babel-core",
@@ -25,6 +25,7 @@
25
25
  "sxy-lib/arrays.js": "sxy-lib-arrays",
26
26
  "sxy-lib/promises.js": "sxy-lib-promises",
27
27
  "sxy-lib-object-copy": "sxy-lib-object-copy",
28
- "sxy-package-investigator": "sxy-package-investigator"
28
+ "sxy-package-investigator": "sxy-package-investigator",
29
+ "css-select": "css-select"
29
30
  }
30
31
  }
@@ -1,25 +0,0 @@
1
- import type { ConstructPackage, TungstenBaseComponent, TungstenComponentPropsBase } from '../Components.jsx';
2
- import type { PipelineApp } from '../pipeline/pipelineDefinition.js';
3
- import { type TestApp, type TestStoreOverride } from './createTestApp.js';
4
- export type TestPipelineAppOptions<Props extends object> = {
5
- document?: Document;
6
- props?: Props;
7
- container?: HTMLElement;
8
- location?: string;
9
- stores?: readonly TestStoreOverride<any>[];
10
- fileVersions?: Record<string, string>;
11
- allRoutesData?: object;
12
- networked?: object;
13
- };
14
- export type TestPipelineApp<Component extends TungstenBaseComponent> = TestApp<Component>;
15
- export type CreateTestPipelineAppArgs<Props extends object> = object extends Props ? [options?: TestPipelineAppOptions<Props>] : keyof Props extends never ? [options?: TestPipelineAppOptions<Props>] : [options: TestPipelineAppOptions<Props> & {
16
- props: Props;
17
- }];
18
- /**
19
- * createTestApp() for an app built with pipeline() or splitPipeline(): the app's browser stages
20
- * run - Init, the all-routes data, Post - and the location is routed against its routes, so the
21
- * test sees the context, stores and route the app's own page would. The app is a .routes()
22
- * result: the app's own export, a smaller set of routes on the same pipeline, or another pipeline.
23
- */
24
- export declare function createTestPipelineApp<Props extends TungstenComponentPropsBase, Component extends TungstenBaseComponent<any, any>, RouteData = undefined>(app: PipelineApp<any>, RootComponent: new (pkg: ConstructPackage<Props, RouteData>) => Component, ...args: CreateTestPipelineAppArgs<Props>): Promise<TestPipelineApp<Component>>;
25
- //# sourceMappingURL=createTestPipelineApp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTestPipelineApp.d.ts","sourceRoot":"","sources":["../../src/testing/createTestPipelineApp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAAE,qBAAqB,EAAE,0BAA0B,EACtE,MAAM,mBAAmB,CAAA;AAM1B,OAAO,KAAK,EAAa,WAAW,EAAgB,MAAM,mCAAmC,CAAA;AAa7F,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,iBAAiB,EAAyB,MAAM,oBAAoB,CAAA;AAIhG,MAAM,MAAM,sBAAsB,CAAC,KAAK,SAAS,MAAM,IAAI;IACvD,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,SAAS,CAAC,EAAE,WAAW,CAAA;IAEvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,SAAS,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAA;IAE1C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAErC,aAAa,CAAC,EAAE,MAAM,CAAA;IAGtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,qBAAqB,IAAI,OAAO,CAAC,SAAS,CAAC,CAAA;AAEzF,MAAM,MAAM,yBAAyB,CAAC,KAAK,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,GAC5E,CAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,GACzC,MAAM,KAAK,SAAS,KAAK,GACrB,CAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,GACzC,CAAC,OAAO,EAAE,sBAAsB,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAA;AAoDrE;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACvC,KAAK,SAAS,0BAA0B,EACxC,SAAS,SAAS,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EACjD,SAAS,GAAG,SAAS,EAErB,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,EAErB,aAAa,EAAE,KAAK,GAAG,EAAE,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,SAAS,EACzE,GAAG,IAAI,EAAE,yBAAyB,CAAC,KAAK,CAAC,GAC1C,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CA+HrC"}
@@ -1,153 +0,0 @@
1
- import { clientRoute } from '../pipeline/pipelineDefinition.js';
2
- import { Instance } from '../Instance/Instance.js';
3
- import { JSONstringify } from '../json.js';
4
- import { initStores } from '../Servers/initStores.js';
5
- import { routing } from "../Servers/routing.js";
6
- import { fromTransport, NetworkedTransport } from '../pipeline/networkedTransport.js';
7
- import { afterRoutingFor, pipelineContext, pipelineRoutes, routingContext, routingNetworkedData } from '../pipeline/runPipeline.js';
8
- import { splitContext } from '../pipeline/runSplitPipeline.js';
9
- import { createTungstenRootComponent } from '../update/integrateUpdateVdom.js';
10
- import { UpdateScheduler } from '../update/UpdateScheduler.js';
11
- import { TestAppImplementation } from './createTestApp.js';
12
- import { waitForEnvIfLoading } from './loadEnv.js';
13
- // the symmetric pipeline's stages, with null for the request
14
- async function runSymmetric(app, allRoutesData) {
15
- const init = await app.init?.(null, undefined);
16
- const data = allRoutesData ?? (await app.allRoutesData?.(null, init)) ?? {};
17
- const post = await app.post?.(null, init, data);
18
- const rerun = app.allRoutesData;
19
- return {
20
- init,
21
- context: pipelineContext(init, post),
22
- routingContext: init,
23
- routingNetworkedData: undefined,
24
- networked: {},
25
- allRoutesData: data,
26
- rerunAllRoutesData: rerun && (async () => rerun(null, init)),
27
- afterRouting: undefined
28
- };
29
- }
30
- async function runSplit(app, allRoutesData, served) {
31
- const page = JSON.parse(JSONstringify(new NetworkedTransport(served))); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- toJSON gives an object
32
- const networked = fromTransport(page) ?? {};
33
- const init = await app.clientInit?.(networked);
34
- const data = allRoutesData ?? (await app.clientAllRoutesData?.(init)) ?? {};
35
- const post = await app.clientPost?.(init, data);
36
- const context = splitContext(init, post);
37
- const rerun = app.clientAllRoutesData;
38
- const afterRouting = app.clientAfterRouting;
39
- return {
40
- init,
41
- context,
42
- routingContext: init?.context,
43
- routingNetworkedData: init?.networked,
44
- networked,
45
- allRoutesData: data,
46
- rerunAllRoutesData: rerun && (async () => rerun(init)),
47
- afterRouting: afterRouting && (async (route, allRoutes) => splitContext(await afterRouting(context, route, allRoutes), undefined))
48
- };
49
- }
50
- /**
51
- * createTestApp() for an app built with pipeline() or splitPipeline(): the app's browser stages
52
- * run - Init, the all-routes data, Post - and the location is routed against its routes, so the
53
- * test sees the context, stores and route the app's own page would. The app is a .routes()
54
- * result: the app's own export, a smaller set of routes on the same pipeline, or another pipeline.
55
- */
56
- export async function createTestPipelineApp(app,
57
- // Props is inferred from both the class and `props`, so literal props are typed by the component
58
- RootComponent, ...args) {
59
- await waitForEnvIfLoading();
60
- const options = args[0];
61
- const suppliedDocument = options?.document ?? globalThis.document;
62
- if (suppliedDocument === undefined) {
63
- // eslint-disable-line @typescript-eslint/no-unnecessary-condition
64
- throw new Error('createTestPipelineApp() requires options.document when no global document is' + ' available.');
65
- }
66
- const document = suppliedDocument;
67
- const ownsContainer = options?.container === undefined;
68
- const container = options?.container ?? document.createElement('div');
69
- if (container.ownerDocument !== document) {
70
- throw new Error('The TestApp container must belong to options.document.');
71
- }
72
- if (container.childNodes.length > 0) {
73
- throw new Error('The TestApp container must be empty before mounting.');
74
- }
75
- const stages = app.split === true ? await runSplit(app, options?.allRoutesData, options?.networked ?? {}) : await runSymmetric(app, options?.allRoutesData);
76
- const location = options?.location ?? '/';
77
- const allRoutesData = stages.allRoutesData; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- the framework brands what it builds
78
- const routeContext = routingContext(stages.routingContext);
79
- const networkedData = routingNetworkedData(stages.routingNetworkedData);
80
- // dev, so a path given twice fails the test
81
- const routes = pipelineRoutes(app, null, stages.init, true);
82
- const matchedRouteInfo = await routing(location, routes, routeContext, networkedData);
83
- const afterRouting = afterRoutingFor(stages.afterRouting);
84
- const context = afterRouting === undefined ? stages.context // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- as above
85
- : await afterRouting(clientRoute(matchedRouteInfo, location), allRoutesData);
86
- if (ownsContainer) {
87
- if (document.body === null) {
88
- // eslint-disable-line @typescript-eslint/no-unnecessary-condition
89
- throw new Error('The supplied document must have a body element.');
90
- }
91
- document.body.appendChild(container);
92
- }
93
- const scheduler = new UpdateScheduler();
94
- const runtimeContext = {
95
- document,
96
- window: document.defaultView,
97
- scheduler,
98
- navigation: false
99
- };
100
- const {
101
- internalStore,
102
- stores,
103
- storeSubscriptions
104
- } = initStores(location, null, allRoutesData, matchedRouteInfo, null, context, networkedData);
105
- const instanceConfig = {
106
- prod: false,
107
- useRootComponent: true,
108
- clientSideNav: true,
109
- siteBasePath: '/',
110
- staticSite: false,
111
- csr: false
112
- };
113
- const appRoutes = reqRes => pipelineRoutes(app, reqRes, stages.init, true);
114
- const instance = new Instance(location, instanceConfig, null, appRoutes, routes, internalStore, stores, storeSubscriptions, allRoutesData, matchedRouteInfo, runtimeContext);
115
- instance.fileVersions = options?.fileVersions;
116
- instance.context = context;
117
- instance.networkedData = networkedData;
118
- instance.pipelineNetworked = stages.networked;
119
- const rerun = stages.rerunAllRoutesData;
120
- instance.pipeline = {
121
- routingContext: routeContext,
122
- routingNetworkedData: networkedData,
123
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- as above
124
- allRoutesData: rerun && (async () => await rerun()),
125
- afterRouting
126
- };
127
- try {
128
- for (const override of options?.stores ?? []) {
129
- const store = override.registration.getStore(instance.stores);
130
- await override.initialize(store);
131
- }
132
- const props = options?.props ?? {};
133
- const root = await createTungstenRootComponent(RootComponent, props, matchedRouteInfo.params, matchedRouteInfo.data, instance, container);
134
- const testApp = new TestAppImplementation(document, container, root.component, instance, scheduler, root, ownsContainer);
135
- try {
136
- await testApp.resolved();
137
- return testApp;
138
- } catch (error) {
139
- await testApp.unmount();
140
- throw error;
141
- }
142
- } catch (error) {
143
- try {
144
- instance.disposeRegisteredComponents();
145
- } catch {
146
- // Preserve the mount failure.
147
- }
148
- scheduler.dispose();
149
- while (container.firstChild !== null) container.removeChild(container.firstChild);
150
- if (ownsContainer) container.remove();
151
- throw error;
152
- }
153
- }
@@ -1,157 +0,0 @@
1
- import type { ContentNode, ContentNodeElement } from '../ContentNode.js';
2
- import type { TrueStore } from '../Store/makeStore.js';
3
- import type { Routes } from '../routing/Routes.js';
4
- import type { RoutesFunction } from '../routing/RoutesFunction.js';
5
- import type { Path, RouteKey } from '../routing/RouteTypes.js';
6
- import { type TungstenComponent, type TungstenComponentClass, type TungstenComponentPropsBase, type TungstenStatefulComponent, TungstenBaseComponent, TungstenSimpleComponent } from '../Components.jsx';
7
- type StateOf<Component> = Component extends {
8
- state?: infer State;
9
- } ? State : never;
10
- type ContentOf<Component extends TungstenBaseComponent<any, any>> = NonNullable<Component['content']> extends (...args: any[]) => infer Result ? Result : ContentNode | Promise<ContentNode>;
11
- type FrameworkMember = keyof TungstenSimpleComponent<any, any> | keyof TungstenComponent<any, any, any> | keyof TungstenStatefulComponent<any, any, any>;
12
- type ReservedMember = keyof HostedCore<TungstenBaseComponent<any, any>>;
13
- export type ComponentApi<Component extends TungstenBaseComponent<any, any>> = {
14
- [Key in keyof Component as Key extends FrameworkMember | ReservedMember ? never : NonNullable<Component[Key]> extends (...args: any[]) => any ? Key : never]: Component[Key];
15
- };
16
- export type Navigation = {
17
- kind: 'goto' | 'redirect';
18
- to: string;
19
- };
20
- export type StateSetter<Component extends TungstenBaseComponent<any, any>> = (state: StateOf<Component>) => StateOf<Component> | void;
21
- type HostedCore<Component extends TungstenBaseComponent<any, any>> = {
22
- readonly component: Component;
23
- readonly props: Component['props'];
24
- readonly state: StateOf<Component>;
25
- readonly title: string | undefined;
26
- readonly navigations: readonly Navigation[];
27
- content: () => ContentOf<Component>;
28
- updateProps: (props: Component['props']) => Promise<Awaited<ContentOf<Component>>>;
29
- updateState: (setter: StateSetter<Component>) => Promise<Awaited<ContentOf<Component>>>;
30
- };
31
- export type Hosted<Component extends TungstenBaseComponent<any, any>> = HostedCore<Component> & ComponentApi<Component>;
32
- export type HostedResolved<Component extends TungstenBaseComponent<any, any>> = Omit<HostedCore<Component>, 'content' | 'updateProps' | 'updateState'> & {
33
- content: () => Promise<ContentNode>;
34
- updateProps: (props: Component['props']) => Promise<ContentNode>;
35
- updateState: (setter: StateSetter<Component>) => Promise<ContentNode>;
36
- } & ComponentApi<Component>;
37
- export type HostedRoute = {
38
- key: RouteKey | null;
39
- params?: Record<string, string>;
40
- data?: unknown;
41
- };
42
- type RouteOptions = {
43
- routing: true;
44
- location: Path;
45
- routes: Routes<any> | RoutesFunction<any>;
46
- matchedRoute?: never;
47
- } | {
48
- routing?: false;
49
- location?: Path;
50
- routes?: Routes<any>;
51
- matchedRoute?: HostedRoute;
52
- };
53
- type StoreOptionsFor<Schema extends object> = {
54
- /** A real store (makeStore), used as-is: its cells keep state, so one can be shared between hosts. */
55
- store: TrueStore<Schema>;
56
- partialStore?: never;
57
- storeData?: never;
58
- partialStoreData?: never;
59
- } | {
60
- /** Some real cells. A key not given is missing, not defaulted: reading it throws, naming it. */
61
- partialStore: Partial<TrueStore<Schema>>;
62
- store?: never;
63
- storeData?: never;
64
- partialStoreData?: never;
65
- } | {
66
- /** Values for every key, each wrapped in a cell of its own. */
67
- storeData: Schema;
68
- store?: never;
69
- partialStore?: never;
70
- partialStoreData?: never;
71
- } | {
72
- /** Values for some keys. A key not given is missing, not defaulted: reading it throws, naming it. */
73
- partialStoreData: Partial<Schema>;
74
- store?: never;
75
- partialStore?: never;
76
- storeData?: never;
77
- };
78
- /**
79
- * Resolve the content through every component in the tree (the default). false: the hosted
80
- * component's own content alone, its child components unexpanded.
81
- */
82
- type ResolveOption = {
83
- resolve?: boolean;
84
- };
85
- type Resolved = {
86
- resolve?: true;
87
- };
88
- type Unresolved = {
89
- resolve: false;
90
- };
91
- type AppDataOptions = {
92
- /** What this.tungsten.context reads. An empty object when not given. */
93
- context?: object;
94
- /** What this.tungsten.networkedData reads. An empty object when not given. */
95
- networkedData?: object;
96
- /** What this.tungsten.globalData reads. An empty object when not given. */
97
- globalData?: object;
98
- };
99
- export type HostStoreOptions<Schema extends object> = (RouteOptions & ResolveOption & AppDataOptions & StoreOptionsFor<Schema>) extends infer Options ? Options extends unknown ? {
100
- [K in keyof Options]: Options[K];
101
- } : never : never;
102
- export type HostPipelineOptions = RouteOptions & ResolveOption & AppDataOptions;
103
- /**
104
- * Constructs a component outside of any app and drives it the way the framework
105
- * does - init, then the mount lifecycles - calling its content function with
106
- * whatever arguments its flavour takes, so tests don't have to match the
107
- * (props) / (props, state) signature themselves.
108
- *
109
- * No DOM: content is returned as a content node tree, unstyled, and never
110
- * reconciled. createTestApp() is the harness for anything that needs a document
111
- * or app state. Lifecycle failures are thrown rather than only reported, so a
112
- * test can't pass over one.
113
- *
114
- * State is not proxied (the construct package is marked `hosted`), so nothing
115
- * re-renders on its own: updateProps() and updateState() are the renders.
116
- *
117
- * Store components have a structural overload: Schema is its own parameter, inferred from
118
- * the class, so a generic wrapper (`Component extends { store: ComponentStore<S> }`) can
119
- * call through without a cast. HostArgs is a conditional on Component, and a conditional
120
- * on a type parameter is deferred, so nothing is assignable to it inside such a wrapper.
121
- */
122
- export declare function hostPipeline<Props extends TungstenComponentPropsBase, Component extends TungstenBaseComponent<any, any>>(ComponentType: TungstenComponentClass<Props, Component>, props?: Props, options?: HostPipelineOptions): Promise<Hosted<Component> | HostedResolved<Component>>;
123
- export declare namespace hostPipeline {
124
- var generic: typeof hostPipelineGeneric;
125
- var jsx: typeof hostPipelineJsx;
126
- }
127
- /**
128
- * host() for a generic component class, whose type arguments it cannot infer: passed as an
129
- * argument, the class's own parameters are erased to their constraints before the props are
130
- * looked at, so `bind: [form, 'value']` widens to an array and the class stops fitting.
131
- * Taking the class in a call of its own gets higher-order inference instead, so the props
132
- * are checked against the component the way JSX checks them.
133
- *
134
- * await hostGeneric(BoundValue)({ bind: [form, 'value'] })
135
- * await hostGeneric(BoundValue, { resolve: false })({ bind: [form, 'value'] })
136
- *
137
- * Options go on the first call because the returned signature has to stay a single plain
138
- * one: give it type parameters of its own, or a second call signature, and the inference
139
- * that makes this work is lost.
140
- */
141
- export declare function hostPipelineGeneric<Props extends TungstenComponentPropsBase, Component extends TungstenBaseComponent<any, any>>(ComponentType: TungstenComponentClass<Props, Component>, options: HostPipelineOptions & Unresolved): (props: Props) => Promise<Hosted<Component>>;
142
- type AnyClassComponent = TungstenBaseComponent<any, any>;
143
- /**
144
- * host(), given the element rather than the class and a props object:
145
- * `await hostJsx(<DataTable head={head} rows={rows} columns={2} />)`. The options are host()'s,
146
- * and everything else about it is the same - a class component, its init and mount lifecycles run.
147
- *
148
- * TypeScript types every JSX expression as `JSX.Element` (here `ContentNodeElement`), so the
149
- * element does not carry the component it names: the wrapper comes back as the base component
150
- * unless the call says which - `hostJsx<DataTable>(<DataTable … />)` - which is what gives back
151
- * `props`, `state` and the component's own methods. host() itself infers all of that from the
152
- * class, so a test that leans on the wrapper's api is better off with host().
153
- */
154
- export declare function hostPipelineJsx<Component extends AnyClassComponent = AnyClassComponent>(element: ContentNodeElement, options: HostPipelineOptions & Unresolved): Promise<Hosted<Component>>;
155
- export declare function hostPipelineJsx<Component extends AnyClassComponent = AnyClassComponent>(element: ContentNodeElement, options?: HostPipelineOptions & Resolved): Promise<HostedResolved<Component>>;
156
- export {};
157
- //# sourceMappingURL=hostPipeline.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostPipeline.d.ts","sourceRoot":"","sources":["../../src/testing/hostPipeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAKxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EACkB,KAAK,iBAAiB,EAAE,KAAK,sBAAsB,EACxE,KAAK,0BAA0B,EAAE,KAAK,yBAAyB,EAC/D,qBAAqB,EACO,uBAAuB,EACtD,MAAM,mBAAmB,CAAA;AAc1B,KAAK,OAAO,CAAC,SAAS,IAAI,SAAS,SAAS;IAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAA;CAAE,GAAG,KAAK,GAAG,KAAK,CAAA;AAInF,KAAK,SAAS,CAAC,SAAS,SAAS,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,IAC1D,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,MAAM,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