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,341 +0,0 @@
1
- import { TungstenBaseComponent, TungstenBaseSimpleStoreComponent, TungstenBaseStatefulStoreComponent, TungstenBaseStoreComponent, TungstenSimpleComponent } from "../Components.js";
2
- import { ContentNodeComponentIsClassComponent, ContentNodeElementIsComponent } from '../ContentNode.js';
3
- import { $props, $type } from '../contentNodeSymbols.js';
4
- import { componentTypeIdentityKey } from '../hmr/componentIdentity.js';
5
- import { makeStore } from '../Store/makeStore.js';
6
- import { routing } from "../Servers/routing.js";
7
- import { resolveContent } from './resolveContent.js';
8
- import { missingStoreValue, testingComponentPackage } from './testingComponentPackage.js';
9
- const isPromise = value => value instanceof Promise || typeof value === 'object' && value !== null && 'then' in value;
10
- // The same list at runtime. Underscore-prefixed members are excluded by rule
11
- // (the framework's naming scheme), so only the plain-named ones are listed, and
12
- // frameworkMembersAreComplete below fails to compile if one is ever missed.
13
- const frameworkMemberNames = ['props', 'routeParams', 'routeData', 'parentComponent', 'childComponents', 'globalData', 'state', 'storeData', 'style', 'title', 'content', 'render', 'init', 'clientInit', 'serverInit', 'componentDidMount', 'componentDidHydrate', 'componentDidUpdate', 'componentDidRender', 'componentWillUnmount', 'componentDidUnmount', 'shouldStoreComponentUpdate', 'setState', 'triggerUpdate', 'pickProps', 'pickState', 'using', 'reactive', 'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval', 'tungsten'];
14
- const frameworkMembers = new Set(frameworkMemberNames);
15
- // a key the store does not hold names itself when it is read, rather than coming back undefined
16
- const namingMissingKeys = store => new Proxy(store, {
17
- get: (target, key) => typeof key === 'symbol' || key in target ? Reflect.get(target, key) : missingStoreValue(`store.${key}`)
18
- });
19
- const isStoreComponent = component => component instanceof TungstenBaseStoreComponent || component instanceof TungstenBaseSimpleStoreComponent || component instanceof TungstenBaseStatefulStoreComponent;
20
- // Runs routing only when asked: a unit test otherwise states the route itself.
21
- async function hostedRouting(options, context, networkedData) {
22
- if (options.routing === true) {
23
- const routes = typeof options.routes === 'function' ? options.routes(null, context, networkedData) : options.routes;
24
- return {
25
- routes,
26
- internalStore: {
27
- location: options.location,
28
- matchedRouteInfo: await routing(options.location, routes, context, networkedData),
29
- popMessages: []
30
- }
31
- };
32
- }
33
- const {
34
- location,
35
- matchedRoute
36
- } = options;
37
- const matchedRouteInfo = matchedRoute === undefined ? undefined : {
38
- key: matchedRoute.key,
39
- params: matchedRoute.params ?? {},
40
- content: null,
41
- ...('data' in matchedRoute ? {
42
- data: matchedRoute.data
43
- } : {})
44
- };
45
- return {
46
- routes: options.routes,
47
- internalStore: {
48
- ...(location !== undefined ? {
49
- location
50
- } : {}),
51
- ...(matchedRouteInfo !== undefined ? {
52
- matchedRouteInfo
53
- } : {}),
54
- popMessages: []
55
- }
56
- };
57
- }
58
- /**
59
- * Constructs a component outside of any app and drives it the way the framework
60
- * does - init, then the mount lifecycles - calling its content function with
61
- * whatever arguments its flavour takes, so tests don't have to match the
62
- * (props) / (props, state) signature themselves.
63
- *
64
- * No DOM: content is returned as a content node tree, unstyled, and never
65
- * reconciled. createTestApp() is the harness for anything that needs a document
66
- * or app state. Lifecycle failures are thrown rather than only reported, so a
67
- * test can't pass over one.
68
- *
69
- * State is not proxied (the construct package is marked `hosted`), so nothing
70
- * re-renders on its own: updateProps() and updateState() are the renders.
71
- *
72
- * Store components have a structural overload: Schema is its own parameter, inferred from
73
- * the class, so a generic wrapper (`Component extends { store: ComponentStore<S> }`) can
74
- * call through without a cast. HostArgs is a conditional on Component, and a conditional
75
- * on a type parameter is deferred, so nothing is assignable to it inside such a wrapper.
76
- */
77
- // resolve: false has its own overloads, the content coming back as the component's own function
78
- // returns it; the rest resolve, so the content is always a promise
79
- // export async function host<
80
- // Props extends TungstenComponentPropsBase,
81
- // Schema extends object,
82
- // Component extends TungstenBaseComponent<any, any> & { store: ComponentStore<Schema> },
83
- // >(
84
- // ComponentType: TungstenComponentClass<Props, Component> & (new (...args: any) => { store: ComponentStore<Schema> }),
85
- // props: Props,
86
- // options: NoInfer<
87
- // [Schema] extends [InternalStoreSchema] ? never : HostStoreOptions<Schema> & Unresolved
88
- // >,
89
- // ): Promise<Hosted<Component>>
90
- // export async function host<
91
- // Props extends TungstenComponentPropsBase,
92
- // Component extends TungstenBaseComponent<any, any>,
93
- // >(
94
- // ComponentType: TungstenComponentClass<Props, Component>,
95
- // props: Props | undefined,
96
- // options: HostOptions<Component> & Unresolved,
97
- // ): Promise<Hosted<Component>>
98
- // export async function host<
99
- // Props extends TungstenComponentPropsBase,
100
- // Schema extends object,
101
- // Component extends TungstenBaseComponent<any, any> & { store: ComponentStore<Schema> },
102
- // >(
103
- // ComponentType: TungstenComponentClass<Props, Component> & (new (...args: any) => { store: ComponentStore<Schema> }),
104
- // props: Props,
105
- // // NoInfer: Schema comes from the class alone, so a partial storeData can't widen it
106
- // options: NoInfer<
107
- // [Schema] extends [InternalStoreSchema] ? never : HostStoreOptions<Schema> & Resolved
108
- // >,
109
- // ): Promise<HostedResolved<Component>>
110
- // // The general form: props optional only when none are required, options only without a store.
111
- // export async function host<
112
- // Props extends TungstenComponentPropsBase,
113
- // // not <Props, any>: the base is invariant in Props, so that rejects props narrower than the component's
114
- // Component extends TungstenBaseComponent<any, any>,
115
- // >(
116
- // ComponentType: TungstenComponentClass<Props, Component>,
117
- // ...[props, options]: HostArgs<Props, Component>
118
- // ): Promise<HostedResolved<Component>>
119
- // actual
120
- export async function hostPipeline(ComponentType, props,
121
- // unknown, not a loose object type: the general overload's rest tuple can't be related to one
122
- options) {
123
- const stored = options ?? {};
124
- const storeData = stored.storeData ?? stored.partialStoreData;
125
- const store = stored.store ?? stored.partialStore ?? (storeData === undefined ? undefined : makeStore(storeData, new Map()));
126
- const partial = stored.partialStore !== undefined || stored.partialStoreData !== undefined;
127
- // a partial store holds only the keys supplied, so name any other one read. On the store the
128
- // instance shares, so a component resolve: true constructs is named it the same way
129
- const shared = partial && store !== undefined ? namingMissingKeys(store) : store;
130
- // one object each, so the routes function, the data function and the component see the same
131
- // ones, as a request's do. Branded here, as the framework brands what it builds
132
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
133
- const context = stored.context ?? {};
134
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
135
- const networkedData = stored.networkedData ?? {};
136
- const route = await hostedRouting(stored, context, networkedData);
137
- const pending = [];
138
- const failures = [];
139
- // Instance.trackWork's no-scheduler path, except the work is kept so host
140
- // can await it and the failure is re-thrown rather than logged.
141
- const trackWork = (task, description) => {
142
- const fail = error => {
143
- failures.push(error instanceof Error ? new Error(`${description}: ${error.message}`, {
144
- cause: error
145
- }) : error);
146
- };
147
- let result;
148
- try {
149
- result = task();
150
- } catch (error) {
151
- fail(error);
152
- return;
153
- }
154
- if (isPromise(result)) pending.push(Promise.resolve(result).catch(fail));
155
- };
156
- const settle = async () => {
157
- while (pending.length > 0) await Promise.all(pending.splice(0));
158
- if (failures.length > 0) throw failures[0];
159
- };
160
- let title;
161
- const navigations = [];
162
- // kept, not inlined: its instance is what resolving renders the rest of the tree against
163
- const constructPackage = testingComponentPackage(
164
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- an absent props object is only reachable when Props allows {}
165
- props ?? {}, {
166
- ...(shared !== undefined ? {
167
- store: shared
168
- } : {}),
169
- ...(route.routes !== undefined ? {
170
- routes: route.routes
171
- } : {}),
172
- internalStore: route.internalStore,
173
- context,
174
- networkedData,
175
- ...(stored.globalData !== undefined ? {
176
- globalData: stored.globalData
177
- } : {}),
178
- trackWork,
179
- // setState's work, run and awaited here rather than left to a timer
180
- queueTask: (task, description) => {
181
- trackWork(task, description);
182
- return true;
183
- },
184
- setTitle: newTitle => {
185
- title = newTitle;
186
- },
187
- // recorded, not carried out - navigating needs an app
188
- goto: async to => {
189
- navigations.push({
190
- kind: 'goto',
191
- to
192
- });
193
- },
194
- redirect: to => {
195
- navigations.push({
196
- kind: 'redirect',
197
- to
198
- });
199
- }
200
- });
201
- const component = new ComponentType(constructPackage);
202
- // the component's own store is built at construction, from the keys there were: guard it too
203
- if (partial && isStoreComponent(component)) component.store = namingMissingKeys(component.store);
204
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- state isn't on the base class, see StateOf
205
- const stateful = component;
206
- const simple = component instanceof TungstenSimpleComponent;
207
- // Not awaited here: what the component's own content function returns is
208
- // what comes back, so its declared type tells a test whether to await.
209
- const ownContent = () => {
210
- const contentFunction = component.content ?? component.render;
211
- if (contentFunction === undefined) {
212
- throw new Error(`host(): ${ComponentType.name} has no content or render function.`);
213
- }
214
- const call = contentFunction;
215
- const result = simple ? call(component.props) : call(component.props, stateful.state);
216
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- ContentOf recovers the concrete component's own return type
217
- return result;
218
- };
219
- // resolve: the tree the app would render - every component in it constructed and asked for its
220
- // content - so it is awaited whatever the hosted component's own content function returns
221
- const guardPartialStore = built => {
222
- if (isStoreComponent(built)) built.store = namingMissingKeys(built.store);
223
- };
224
- const resolved = async () => resolveContent(
225
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- ContentOf stays unresolved inside the generic; a content function returns a content tree
226
- await ownContent(), component, constructPackage.instance, partial ? guardPartialStore : undefined);
227
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- resolving has its own overloads, whose content this is
228
- const content = stored.resolve === false ? ownContent : resolved;
229
- await component.__init();
230
- component.__didMount();
231
- await settle();
232
- const core = {
233
- get component() {
234
- return component;
235
- },
236
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- any from the constraint, see above
237
- get props() {
238
- return component.props;
239
- },
240
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- as above
241
- get state() {
242
- return stateful.state;
243
- },
244
- get title() {
245
- return title;
246
- },
247
- get navigations() {
248
- return navigations;
249
- },
250
- content,
251
- updateProps: async newProps => {
252
- component.props = newProps;
253
- // content first, then the completion lifecycles - the order
254
- // __updateAndReturnContent() and its complete() callback run in.
255
- const rendered = await content();
256
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- see UpdateCompletion
257
- const completion = component;
258
- // the framework passes the props the render saw, not the previous
259
- // ones, despite componentDidUpdate's parameter name
260
- if (simple) completion.__newUpdateCompleted(component.props);else completion.__newUpdateCompleted(component.props, stateful.state);
261
- await settle();
262
- return rendered;
263
- },
264
- updateState: async setter => {
265
- if (stateful.state === undefined) {
266
- throw new Error(`host(): ${ComponentType.name} has no state to update.`);
267
- }
268
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- as above
269
- const next = setter(stateful.state);
270
- // a setter that mutated and returned nothing has already done the work
271
- if (next !== undefined) {
272
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- StateOf is the component's own state type
273
- stateful.state = next;
274
- }
275
- const rendered = await content();
276
- await settle();
277
- return rendered;
278
- }
279
- };
280
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- componentApi() collects exactly the members ComponentApi describes
281
- return Object.assign(core, componentApi(component, core));
282
- }
283
- // export function hostPipelineGeneric<
284
- // Props extends TungstenComponentPropsBase,
285
- // Component extends TungstenBaseComponent<any, any>,
286
- // >(
287
- // ComponentType: TungstenComponentClass<Props, Component>,
288
- // ...args: HostGenericArgs<Component>
289
- // ): (props: Props) => Promise<HostedResolved<Component>>
290
- export function hostPipelineGeneric(ComponentType, options) {
291
- // host()'s args are a conditional on Component, which stays deferred in a generic
292
- // wrapper, so nothing is assignable to it here - the implementation signature is
293
- // what this is calling
294
- const call = hostPipeline;
295
- return async props => call(ComponentType, props, options);
296
- }
297
- export async function hostPipelineJsx(element,
298
- // unknown: the overloads' options are conditional on Component, which nothing satisfies here
299
- options) {
300
- if (!ContentNodeElementIsComponent(element) || !ContentNodeComponentIsClassComponent(element)) {
301
- throw new Error(`hostJsx(): ${described(element)} is not a class component element.` + ' Give host() a component class; a function component is a function - call it.');
302
- }
303
- const ComponentType = element[$type]; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- the element's own class, which the call names when it wants the wrapper typed
304
- return hostPipeline(ComponentType, element[$props], options); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
305
- }
306
- // an html tag as written, a fragment as <>, a function component by name
307
- function described(element) {
308
- const type = element[$type];
309
- if (typeof type === 'string') return `<${type}>`;
310
- if (typeof type === 'function') return `<${componentTypeIdentityKey(type)}>`;
311
- return '<>';
312
- }
313
- // the variants hang off host() too, so a test reaches for one name
314
- hostPipeline.generic = hostPipelineGeneric;
315
- hostPipeline.jsx = hostPipelineJsx;
316
- // The component's own function members, bound and ready to call. Framework
317
- // members and anything the wrapper already provides are left out; the framework
318
- // keeps its internals under an underscore, which is the rest of the rule.
319
- function componentApi(component, core) {
320
- const api = {};
321
- const add = (name, descriptor) => {
322
- if (descriptor === undefined || typeof descriptor.value !== 'function') return;
323
- if (name.startsWith('_') || frameworkMembers.has(name)) return;
324
- if (name in core || name in api) return;
325
- const method = descriptor.value; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- guarded by the typeof above
326
- // looked up only when called: a proxy field (a tRPC client) reads .bind as a procedure
327
- api[name] = (...args) => Reflect.apply(method, component, args);
328
- };
329
- for (const name of Object.getOwnPropertyNames(component)) {
330
- add(name, Object.getOwnPropertyDescriptor(component, name));
331
- }
332
- let prototype = Object.getPrototypeOf(component); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
333
- while (prototype !== null && prototype !== TungstenBaseComponent.prototype) {
334
- for (const name of Object.getOwnPropertyNames(prototype)) {
335
- if (name === 'constructor') continue;
336
- add(name, Object.getOwnPropertyDescriptor(prototype, name));
337
- }
338
- prototype = Object.getPrototypeOf(prototype); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
339
- }
340
- return api;
341
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"hydrateTestPipelineApp.d.ts","sourceRoot":"","sources":["../../src/testing/hydrateTestPipelineApp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAAE,qBAAqB,EAAE,0BAA0B,EACtE,MAAM,mBAAmB,CAAA;AAI1B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAI1C,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAyBzD,MAAM,MAAM,6BAA6B,CAAC,KAAK,SAAS,MAAM,IAAI;IAC9D,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;IAEb,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,SAAS,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAA;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,GAAG,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,sBAAsB,CAAC,SAAS,SAAS,qBAAqB,IACpE,cAAc,CAAC,SAAS,CAAC,CAAA;AAE/B,KAAK,0BAA0B,CAAC,KAAK,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,GACtE,CAAC,OAAO,CAAC,EAAE,6BAA6B,CAAC,KAAK,CAAC,CAAC,GAChD,MAAM,KAAK,SAAS,KAAK,GACrB,CAAC,OAAO,CAAC,EAAE,6BAA6B,CAAC,KAAK,CAAC,CAAC,GAChD,CAAC,OAAO,EAAE,6BAA6B,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAA;AAiB5E;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CACxC,KAAK,SAAS,0BAA0B,EACxC,SAAS,SAAS,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EACjD,SAAS,GAAG,SAAS,EAErB,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,EACrB,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,CA+I5C"}