@next-core/runtime 1.62.1 → 1.62.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/internal/Renderer.js +72 -51
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js +122 -121
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/enums.js +1 -1
- package/dist/cjs/internal/enums.js.map +1 -1
- package/dist/cjs/internal/interfaces.js.map +1 -1
- package/dist/cjs/internal/mount.js +12 -5
- package/dist/cjs/internal/mount.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js +10 -7
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/esm/internal/Renderer.js +74 -54
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/esm/internal/RendererContext.js +122 -121
- package/dist/esm/internal/RendererContext.js.map +1 -1
- package/dist/esm/internal/enums.js +1 -1
- package/dist/esm/internal/enums.js.map +1 -1
- package/dist/esm/internal/interfaces.js.map +1 -1
- package/dist/esm/internal/mount.js +12 -5
- package/dist/esm/internal/mount.js.map +1 -1
- package/dist/esm/internal/secret_internals.js +10 -7
- package/dist/esm/internal/secret_internals.js.map +1 -1
- package/dist/types/internal/Renderer.d.ts +2 -3
- package/dist/types/internal/RendererContext.d.ts +1 -2
- package/dist/types/internal/enums.d.ts +1 -1
- package/dist/types/internal/interfaces.d.ts +7 -7
- package/package.json +2 -2
|
@@ -112,7 +112,7 @@ async function renderRoutes(returnNode, routes, _runtimeContext, rendererContext
|
|
|
112
112
|
if (route.type === "routes") {
|
|
113
113
|
newOutput = await renderRoutes(returnNode, route.routes, runtimeContext, rendererContext, routePath, menuRequestNode, slotId, undefined, initialTracker);
|
|
114
114
|
} else {
|
|
115
|
-
newOutput = await renderBricks(returnNode, route.bricks, runtimeContext, rendererContext, routePath, menuRequestNode, slotId, undefined,
|
|
115
|
+
newOutput = await renderBricks(returnNode, route.bricks, runtimeContext, rendererContext, routePath, menuRequestNode, slotId, undefined, initialTracker);
|
|
116
116
|
}
|
|
117
117
|
mergeRenderOutput(output, newOutput);
|
|
118
118
|
appendMenuRequestNode(menuRequestNode, newOutput.menuRequestNode);
|
|
@@ -121,24 +121,19 @@ async function renderRoutes(returnNode, routes, _runtimeContext, rendererContext
|
|
|
121
121
|
}
|
|
122
122
|
return output;
|
|
123
123
|
}
|
|
124
|
-
async function renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack,
|
|
124
|
+
async function renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, initialTracker) {
|
|
125
125
|
(0, _setupRootRuntimeContext.setupRootRuntimeContext)(bricks, runtimeContext, true);
|
|
126
126
|
const output = getEmptyRenderOutput();
|
|
127
|
-
const kPath = keyPath ?? [];
|
|
128
127
|
// 多个构件并行异步转换,但转换的结果按原顺序串行合并。
|
|
129
|
-
const rendered = await Promise.all(bricks.map(
|
|
130
|
-
rendered.forEach(
|
|
131
|
-
if (item.hasTrackingControls) {
|
|
132
|
-
// Memoize a render node before it's been merged.
|
|
133
|
-
rendererContext.memoize(slotId, kPath.concat(index), item.node, returnNode);
|
|
134
|
-
}
|
|
128
|
+
const rendered = await Promise.all(bricks.map(brickConf => renderBrick(returnNode, brickConf, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack && new Map(tplStack), initialTracker)));
|
|
129
|
+
rendered.forEach(item => {
|
|
135
130
|
mergeRenderOutput(output, item);
|
|
136
131
|
});
|
|
137
132
|
return output;
|
|
138
133
|
}
|
|
139
|
-
async function renderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId,
|
|
134
|
+
async function renderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack = new Map(), initialTracker) {
|
|
140
135
|
try {
|
|
141
|
-
return await legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId,
|
|
136
|
+
return await legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, initialTracker);
|
|
142
137
|
} catch (error) {
|
|
143
138
|
if (brickConf.errorBoundary) {
|
|
144
139
|
// eslint-disable-next-line no-console
|
|
@@ -152,7 +147,7 @@ async function renderBrick(returnNode, brickConf, _runtimeContext, rendererConte
|
|
|
152
147
|
}
|
|
153
148
|
}
|
|
154
149
|
}
|
|
155
|
-
async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId,
|
|
150
|
+
async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, initialTracker) {
|
|
156
151
|
var _hooks$checkPermissio2, _runtimeContext$app;
|
|
157
152
|
const output = getEmptyRenderOutput();
|
|
158
153
|
if (!brickConf.brick) {
|
|
@@ -176,6 +171,7 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
176
171
|
if (isGeneralizedTrackAll(brickIf)) {
|
|
177
172
|
return renderBrick(returnNode, {
|
|
178
173
|
brick: ":if",
|
|
174
|
+
iid: brickConf.iid,
|
|
179
175
|
dataSource: brickIf,
|
|
180
176
|
// `permissionsPreCheck` maybe required before computing `if`.
|
|
181
177
|
permissionsPreCheck,
|
|
@@ -190,7 +186,7 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
190
186
|
...acc,
|
|
191
187
|
[symbol]: brickConf[symbol]
|
|
192
188
|
}), {})
|
|
193
|
-
}, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId,
|
|
189
|
+
}, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, initialTracker);
|
|
194
190
|
}
|
|
195
191
|
const tplStateStoreId = brickConf[_constants.symbolForTplStateStoreId];
|
|
196
192
|
const formStateStoreId = brickConf[_constants2.symbolForFormStateStoreId];
|
|
@@ -251,23 +247,40 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
251
247
|
|
|
252
248
|
// Then, get the bricks in that matched slot.
|
|
253
249
|
const bricks = slots && (0, _general.hasOwnProperty)(slots, slot) && ((_slots$slot = slots[slot]) === null || _slots$slot === void 0 ? void 0 : _slots$slot.bricks);
|
|
250
|
+
const output = getEmptyRenderOutput();
|
|
251
|
+
const abstractNode = {
|
|
252
|
+
tag: _enums.RenderTag.ABSTRACT,
|
|
253
|
+
return: returnNode,
|
|
254
|
+
iid: brickConf.iid
|
|
255
|
+
};
|
|
256
|
+
output.node = abstractNode;
|
|
254
257
|
if (!Array.isArray(bricks)) {
|
|
255
|
-
return
|
|
258
|
+
return output;
|
|
256
259
|
}
|
|
260
|
+
let childrenOutput;
|
|
257
261
|
switch (brickName) {
|
|
258
262
|
case ":forEach":
|
|
259
263
|
{
|
|
260
264
|
if (!Array.isArray(computedDataSource)) {
|
|
261
|
-
|
|
265
|
+
break;
|
|
262
266
|
}
|
|
263
|
-
|
|
267
|
+
childrenOutput = await renderForEach(abstractNode, computedDataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, tracker);
|
|
268
|
+
break;
|
|
264
269
|
}
|
|
265
270
|
case ":if":
|
|
266
271
|
case ":switch":
|
|
267
272
|
{
|
|
268
|
-
|
|
273
|
+
childrenOutput = await renderBricks(abstractNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, tracker);
|
|
269
274
|
}
|
|
270
275
|
}
|
|
276
|
+
if (childrenOutput) {
|
|
277
|
+
abstractNode.child = childrenOutput.node;
|
|
278
|
+
mergeRenderOutput(output, {
|
|
279
|
+
...childrenOutput,
|
|
280
|
+
node: undefined
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return output;
|
|
271
284
|
};
|
|
272
285
|
const renderControlNode = async ({
|
|
273
286
|
type,
|
|
@@ -275,7 +288,6 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
275
288
|
tplStateStoreScope,
|
|
276
289
|
formStateStoreScope
|
|
277
290
|
}) => {
|
|
278
|
-
var _ref;
|
|
279
291
|
let changedAfterInitial = false;
|
|
280
292
|
const tracker = {
|
|
281
293
|
disposes: [],
|
|
@@ -310,14 +322,9 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
310
322
|
throw new Error(`Maximum rerender stack overflowed (iid: ${brickConf.iid})`);
|
|
311
323
|
}
|
|
312
324
|
}
|
|
313
|
-
(_ref = rawOutput).node ?? (_ref.node = {
|
|
314
|
-
tag: _enums.RenderTag.PLACEHOLDER,
|
|
315
|
-
return: returnNode,
|
|
316
|
-
tracking
|
|
317
|
-
});
|
|
318
325
|
return rawOutput;
|
|
319
326
|
};
|
|
320
|
-
|
|
327
|
+
let controlledOutput = await renderControlNode({
|
|
321
328
|
type: "initial",
|
|
322
329
|
runtimeContext
|
|
323
330
|
});
|
|
@@ -326,7 +333,6 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
326
333
|
onUnmount
|
|
327
334
|
} = brickConf.lifeCycle ?? {};
|
|
328
335
|
if (tracking) {
|
|
329
|
-
controlledOutput.hasTrackingControls = true;
|
|
330
336
|
let renderId = 0;
|
|
331
337
|
const listener = async () => {
|
|
332
338
|
const currentRenderId = ++renderId;
|
|
@@ -347,7 +353,8 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
347
353
|
}
|
|
348
354
|
}));
|
|
349
355
|
}
|
|
350
|
-
rendererContext.reRender(
|
|
356
|
+
rendererContext.reRender(returnNode, reControlledOutput.node, controlledOutput.node);
|
|
357
|
+
controlledOutput = reControlledOutput;
|
|
351
358
|
if (onMount) {
|
|
352
359
|
(0, _bindListeners.listenerFactory)(onMount, scopedRuntimeContext)(new CustomEvent("mount", {
|
|
353
360
|
detail: {
|
|
@@ -365,7 +372,7 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
365
372
|
leading: true,
|
|
366
373
|
trailing: true
|
|
367
374
|
});
|
|
368
|
-
const runtimeBrick = returnNode.tag === _enums.RenderTag.
|
|
375
|
+
const runtimeBrick = returnNode.tag === _enums.RenderTag.ROOT ? null : returnNode;
|
|
369
376
|
const disposes = runtimeBrick ? runtimeBrick.disposes ?? (runtimeBrick.disposes = []) : [];
|
|
370
377
|
if (contextNames) {
|
|
371
378
|
for (const contextName of contextNames) {
|
|
@@ -530,10 +537,16 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
530
537
|
return;
|
|
531
538
|
}
|
|
532
539
|
const routeSlotFromIndexToSlotId = new Map();
|
|
533
|
-
const rendered = await Promise.all(Object.entries(slots).map(([childSlotId, slotConf], index) => {
|
|
540
|
+
const rendered = await Promise.all(Object.entries(slots).map(async ([childSlotId, slotConf], index) => {
|
|
534
541
|
if (slotConf.type !== "routes") {
|
|
535
|
-
return renderBricks(brick, slotConf.bricks, childRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, tplStack,
|
|
542
|
+
return renderBricks(brick, slotConf.bricks, childRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, tplStack, initialTracker);
|
|
536
543
|
}
|
|
544
|
+
let lastOutput = getEmptyRenderOutput();
|
|
545
|
+
const abstractNode = {
|
|
546
|
+
tag: _enums.RenderTag.ABSTRACT,
|
|
547
|
+
return: brick
|
|
548
|
+
};
|
|
549
|
+
lastOutput.node = abstractNode;
|
|
537
550
|
const parentRoute = parentRoutes[parentRoutes.length - 1];
|
|
538
551
|
if (parentRoute !== null && parentRoute !== void 0 && parentRoute.incrementalSubRoutes) {
|
|
539
552
|
routeSlotFromIndexToSlotId.set(index, childSlotId);
|
|
@@ -560,8 +573,14 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
560
573
|
let failed = false;
|
|
561
574
|
let incrementalOutput;
|
|
562
575
|
let scopedStores = [];
|
|
576
|
+
const newOutput = getEmptyRenderOutput();
|
|
577
|
+
const newControlNode = {
|
|
578
|
+
tag: _enums.RenderTag.ABSTRACT,
|
|
579
|
+
return: brick
|
|
580
|
+
};
|
|
581
|
+
newOutput.node = newControlNode;
|
|
563
582
|
try {
|
|
564
|
-
incrementalOutput = await renderRoutes(
|
|
583
|
+
incrementalOutput = await renderRoutes(newControlNode, slotConf.routes, scopedRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, true);
|
|
565
584
|
|
|
566
585
|
// Do not ignore incremental rendering even if all sub-routes are missed.
|
|
567
586
|
// Since parent route is matched.
|
|
@@ -573,11 +592,10 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
573
592
|
scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
574
593
|
await postAsyncRender(incrementalOutput, scopedRuntimeContext, [scopedRuntimeContext.ctxStore, ...scopedStores]);
|
|
575
594
|
}
|
|
576
|
-
await rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
577
595
|
} catch (error) {
|
|
578
596
|
// eslint-disable-next-line no-console
|
|
579
597
|
console.error("Incremental sub-router failed:", error);
|
|
580
|
-
const result = await rendererContext.reCatch(error,
|
|
598
|
+
const result = await rendererContext.reCatch(error, newControlNode);
|
|
581
599
|
if (!result) {
|
|
582
600
|
return true;
|
|
583
601
|
}
|
|
@@ -585,11 +603,16 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
585
603
|
failed,
|
|
586
604
|
output: incrementalOutput
|
|
587
605
|
} = result);
|
|
588
|
-
|
|
589
|
-
// Assert: no errors will be throw
|
|
590
|
-
await rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
591
606
|
}
|
|
592
|
-
|
|
607
|
+
newControlNode.child = incrementalOutput.node;
|
|
608
|
+
mergeRenderOutput(newOutput, {
|
|
609
|
+
...incrementalOutput,
|
|
610
|
+
node: undefined
|
|
611
|
+
});
|
|
612
|
+
// Assert: no errors will be throw
|
|
613
|
+
await rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
614
|
+
rendererContext.reRender(brick, newControlNode, lastOutput.node);
|
|
615
|
+
lastOutput = newOutput;
|
|
593
616
|
if (!failed) {
|
|
594
617
|
scopedRuntimeContext.ctxStore.mountAsyncData(incrementalOutput.route);
|
|
595
618
|
for (const store of scopedStores) {
|
|
@@ -601,7 +624,14 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
601
624
|
return true;
|
|
602
625
|
});
|
|
603
626
|
}
|
|
604
|
-
|
|
627
|
+
const routesOutput = await renderRoutes(abstractNode, slotConf.routes, childRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, undefined, initialTracker);
|
|
628
|
+
abstractNode.child = routesOutput.node;
|
|
629
|
+
mergeRenderOutput(output, {
|
|
630
|
+
...routesOutput,
|
|
631
|
+
node: undefined
|
|
632
|
+
});
|
|
633
|
+
appendMenuRequestNode(menuRequestReturnNode, output.menuRequestNode = routesOutput.menuRequestNode);
|
|
634
|
+
return lastOutput;
|
|
605
635
|
}));
|
|
606
636
|
const childrenOutput = {
|
|
607
637
|
...output,
|
|
@@ -609,11 +639,7 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
609
639
|
blockingList: [],
|
|
610
640
|
menuRequestNode: undefined
|
|
611
641
|
};
|
|
612
|
-
rendered.forEach(
|
|
613
|
-
if (routeSlotFromIndexToSlotId.has(index)) {
|
|
614
|
-
// Memoize a render node before it's been merged.
|
|
615
|
-
rendererContext.memoize(routeSlotFromIndexToSlotId.get(index), [], item.node, brick);
|
|
616
|
-
}
|
|
642
|
+
rendered.forEach(item => {
|
|
617
643
|
mergeRenderOutput(childrenOutput, item);
|
|
618
644
|
mergeSiblingRenderMenuRequest(childrenOutput, item);
|
|
619
645
|
});
|
|
@@ -640,22 +666,18 @@ function ensureValidControlBrick(brick) {
|
|
|
640
666
|
throw new Error(`Unknown storyboard control node: "${brick}"`);
|
|
641
667
|
}
|
|
642
668
|
}
|
|
643
|
-
async function renderForEach(returnNode, dataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack,
|
|
669
|
+
async function renderForEach(returnNode, dataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, initialTracker) {
|
|
644
670
|
const output = getEmptyRenderOutput();
|
|
645
671
|
const size = dataSource.length;
|
|
646
|
-
const rendered = await Promise.all(dataSource.map((item, i) => Promise.all(bricks.map(
|
|
672
|
+
const rendered = await Promise.all(dataSource.map((item, i) => Promise.all(bricks.map(brickConf => renderBrick(returnNode, brickConf, {
|
|
647
673
|
...runtimeContext,
|
|
648
674
|
forEachItem: item,
|
|
649
675
|
forEachIndex: i,
|
|
650
676
|
forEachSize: size
|
|
651
|
-
}, rendererContext, parentRoutes, menuRequestReturnNode, slotId,
|
|
677
|
+
}, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack && new Map(tplStack), initialTracker)))));
|
|
652
678
|
|
|
653
679
|
// 多层构件并行异步转换,但转换的结果按原顺序串行合并。
|
|
654
|
-
rendered.flat().forEach(
|
|
655
|
-
if (item.hasTrackingControls) {
|
|
656
|
-
// Memoize a render node before it's been merged.
|
|
657
|
-
rendererContext.memoize(slotId, keyPath.concat(index), item.node, returnNode);
|
|
658
|
-
}
|
|
680
|
+
rendered.flat().forEach(item => {
|
|
659
681
|
mergeRenderOutput(output, item);
|
|
660
682
|
});
|
|
661
683
|
return output;
|
|
@@ -702,7 +724,6 @@ function mergeRenderOutput(output, newOutput) {
|
|
|
702
724
|
blockingList,
|
|
703
725
|
node,
|
|
704
726
|
menuRequestNode,
|
|
705
|
-
hasTrackingControls,
|
|
706
727
|
...rest
|
|
707
728
|
} = newOutput;
|
|
708
729
|
output.blockingList.push(...blockingList);
|