@next-core/runtime 1.44.1 → 1.44.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/CustomProcessors.js.map +1 -1
- package/dist/cjs/CustomTemplates.js +7 -11
- package/dist/cjs/CustomTemplates.js.map +1 -1
- package/dist/cjs/createRoot.js +11 -5
- package/dist/cjs/createRoot.js.map +1 -1
- package/dist/cjs/getPageInfo.js.map +1 -1
- package/dist/cjs/handleHttpError.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/bindTemplateProxy.js +4 -5
- package/dist/cjs/internal/CustomTemplates/bindTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js +4 -7
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js +21 -24
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js +4 -7
- package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/utils.js +3 -3
- package/dist/cjs/internal/CustomTemplates/utils.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/expandFormRenderer.js +3 -3
- package/dist/cjs/internal/FormRenderer/expandFormRenderer.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/utils.js +2 -2
- package/dist/cjs/internal/FormRenderer/utils.js.map +1 -1
- package/dist/cjs/internal/Renderer.js +11 -14
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js +8 -10
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/Router.js +3 -0
- package/dist/cjs/internal/Router.js.map +1 -1
- package/dist/cjs/internal/Runtime.js +14 -14
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/cjs/internal/bindListeners.js +2 -3
- package/dist/cjs/internal/bindListeners.js.map +1 -1
- package/dist/cjs/internal/compute/WidgetFunctions.js.map +1 -1
- package/dist/cjs/internal/compute/evaluate.js +4 -4
- package/dist/cjs/internal/compute/evaluate.js.map +1 -1
- package/dist/cjs/internal/compute/getGeneralGlobals.js.map +1 -1
- package/dist/cjs/internal/compute/getStorageItem.js +1 -2
- package/dist/cjs/internal/compute/getStorageItem.js.map +1 -1
- package/dist/cjs/internal/compute/listenOnTrackingContext.js.map +1 -1
- package/dist/cjs/internal/compute/setRealProperties.js.map +1 -1
- package/dist/cjs/internal/data/DataStore.js.map +1 -1
- package/dist/cjs/internal/data/getProviderBrick.js.map +1 -1
- package/dist/cjs/internal/data/realTimeDataInspect.js.map +1 -1
- package/dist/cjs/internal/data/resolveData.js.map +1 -1
- package/dist/cjs/internal/data/resolveDataStore.js +2 -4
- package/dist/cjs/internal/data/resolveDataStore.js.map +1 -1
- package/dist/cjs/internal/hasInstalledApp.js.map +1 -1
- package/dist/cjs/internal/historyExtended.js.map +1 -1
- package/dist/cjs/internal/matchPath.js.map +1 -1
- package/dist/cjs/internal/matchRoutes.js.map +1 -1
- package/dist/cjs/internal/matchStoryboard.js +2 -2
- package/dist/cjs/internal/matchStoryboard.js.map +1 -1
- package/dist/cjs/internal/mediaQuery.js.map +1 -1
- package/dist/cjs/internal/mount.js.map +1 -1
- package/dist/cjs/internal/poll.js +3 -3
- package/dist/cjs/internal/poll.js.map +1 -1
- package/dist/cjs/internal/registerAppI18n.js.map +1 -1
- package/dist/cjs/internal/registerCustomTemplates.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js +4 -4
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/cjs/internal/setupRootRuntimeContext.js +2 -3
- package/dist/cjs/internal/setupRootRuntimeContext.js.map +1 -1
- package/dist/cjs/isStrictMode.js.map +1 -1
- package/dist/cjs/setLoginStateCookie.js.map +1 -1
- package/dist/cjs/setWatermark.js +4 -4
- package/dist/cjs/setWatermark.js.map +1 -1
- package/dist/cjs/themeAndMode.js +1 -2
- package/dist/cjs/themeAndMode.js.map +1 -1
- package/dist/esm/CustomProcessors.js +5 -5
- package/dist/esm/CustomProcessors.js.map +1 -1
- package/dist/esm/CustomTemplates.js +48 -58
- package/dist/esm/CustomTemplates.js.map +1 -1
- package/dist/esm/Dialog.js +3 -3
- package/dist/esm/Dialog.js.map +1 -1
- package/dist/esm/Notification.js +2 -2
- package/dist/esm/Notification.js.map +1 -1
- package/dist/esm/StoryboardFunctionRegistry.js +18 -18
- package/dist/esm/StoryboardFunctionRegistry.js.map +1 -1
- package/dist/esm/createRoot.js +125 -123
- package/dist/esm/createRoot.js.map +1 -1
- package/dist/esm/fetchByProvider.js +3 -10
- package/dist/esm/fetchByProvider.js.map +1 -1
- package/dist/esm/getBasePath.js +2 -2
- package/dist/esm/getBasePath.js.map +1 -1
- package/dist/esm/getPageInfo.js +5 -5
- package/dist/esm/getPageInfo.js.map +1 -1
- package/dist/esm/getRealValue.js +7 -6
- package/dist/esm/getRealValue.js.map +1 -1
- package/dist/esm/getV2RuntimeFromDll.js +1 -1
- package/dist/esm/getV2RuntimeFromDll.js.map +1 -1
- package/dist/esm/handleHttpError.js +11 -11
- package/dist/esm/handleHttpError.js.map +1 -1
- package/dist/esm/history.js +4 -4
- package/dist/esm/history.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/bindTemplateProxy.js +13 -17
- package/dist/esm/internal/CustomTemplates/bindTemplateProxy.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/constants.js +5 -5
- package/dist/esm/internal/CustomTemplates/constants.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js +41 -42
- package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js +43 -46
- package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/setupUseBrickInTemplate.js +16 -18
- package/dist/esm/internal/CustomTemplates/setupUseBrickInTemplate.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/utils.js +8 -8
- package/dist/esm/internal/CustomTemplates/utils.js.map +1 -1
- package/dist/esm/internal/FormRenderer/constants.js +2 -2
- package/dist/esm/internal/FormRenderer/constants.js.map +1 -1
- package/dist/esm/internal/FormRenderer/expandFormRenderer.js +28 -23
- package/dist/esm/internal/FormRenderer/expandFormRenderer.js.map +1 -1
- package/dist/esm/internal/FormRenderer/getDefaultProperties.js +45 -22
- package/dist/esm/internal/FormRenderer/getDefaultProperties.js.map +1 -1
- package/dist/esm/internal/FormRenderer/utils.js +4 -4
- package/dist/esm/internal/FormRenderer/utils.js.map +1 -1
- package/dist/esm/internal/Renderer.js +517 -577
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/esm/internal/RendererContext.js +132 -148
- package/dist/esm/internal/RendererContext.js.map +1 -1
- package/dist/esm/internal/Router.js +325 -343
- package/dist/esm/internal/Router.js.map +1 -1
- package/dist/esm/internal/Runtime.js +53 -51
- package/dist/esm/internal/Runtime.js.map +1 -1
- package/dist/esm/internal/abortController.js +7 -6
- package/dist/esm/internal/abortController.js.map +1 -1
- package/dist/esm/internal/bindListeners.js +136 -156
- package/dist/esm/internal/bindListeners.js.map +1 -1
- package/dist/esm/internal/compute/StoryboardFunctions.js +1 -1
- package/dist/esm/internal/compute/StoryboardFunctions.js.map +1 -1
- package/dist/esm/internal/compute/WidgetFunctions.js +6 -6
- package/dist/esm/internal/compute/WidgetFunctions.js.map +1 -1
- package/dist/esm/internal/compute/WidgetI18n.js +4 -4
- package/dist/esm/internal/compute/WidgetI18n.js.map +1 -1
- package/dist/esm/internal/compute/checkIf.js +10 -23
- package/dist/esm/internal/compute/checkIf.js.map +1 -1
- package/dist/esm/internal/compute/computeRealProperties.js +22 -35
- package/dist/esm/internal/compute/computeRealProperties.js.map +1 -1
- package/dist/esm/internal/compute/computeRealValue.js +42 -49
- package/dist/esm/internal/compute/computeRealValue.js.map +1 -1
- package/dist/esm/internal/compute/evaluate.js +71 -75
- package/dist/esm/internal/compute/evaluate.js.map +1 -1
- package/dist/esm/internal/compute/getGeneralGlobals.js +5 -5
- package/dist/esm/internal/compute/getGeneralGlobals.js.map +1 -1
- package/dist/esm/internal/compute/getNextStateOfUseBrick.js +1 -1
- package/dist/esm/internal/compute/getStorageItem.js +2 -3
- package/dist/esm/internal/compute/getStorageItem.js.map +1 -1
- package/dist/esm/internal/compute/getTracks.js +5 -5
- package/dist/esm/internal/compute/getTracks.js.map +1 -1
- package/dist/esm/internal/compute/listenOnTrackingContext.js +8 -11
- package/dist/esm/internal/compute/listenOnTrackingContext.js.map +1 -1
- package/dist/esm/internal/compute/markAsComputed.js +2 -2
- package/dist/esm/internal/compute/markAsComputed.js.map +1 -1
- package/dist/esm/internal/compute/setProperties.js +1 -1
- package/dist/esm/internal/compute/setProperties.js.map +1 -1
- package/dist/esm/internal/compute/setRealProperties.js +3 -3
- package/dist/esm/internal/compute/setRealProperties.js.map +1 -1
- package/dist/esm/internal/customizeColorTheme.js +15 -13
- package/dist/esm/internal/customizeColorTheme.js.map +1 -1
- package/dist/esm/internal/data/DataStore.js +161 -177
- package/dist/esm/internal/data/DataStore.js.map +1 -1
- package/dist/esm/internal/data/getProviderBrick.js +21 -28
- package/dist/esm/internal/data/getProviderBrick.js.map +1 -1
- package/dist/esm/internal/data/realTimeDataInspect.js +5 -5
- package/dist/esm/internal/data/realTimeDataInspect.js.map +1 -1
- package/dist/esm/internal/data/resolveData.js +89 -103
- package/dist/esm/internal/data/resolveData.js.map +1 -1
- package/dist/esm/internal/data/resolveDataStore.js +53 -67
- package/dist/esm/internal/data/resolveDataStore.js.map +1 -1
- package/dist/esm/internal/devtools.js +9 -9
- package/dist/esm/internal/devtools.js.map +1 -1
- package/dist/esm/internal/enums.js +1 -1
- package/dist/esm/internal/fulfilStoryboard.js +15 -28
- package/dist/esm/internal/fulfilStoryboard.js.map +1 -1
- package/dist/esm/internal/hasInstalledApp.js +3 -3
- package/dist/esm/internal/hasInstalledApp.js.map +1 -1
- package/dist/esm/internal/historyExtended.js +40 -37
- package/dist/esm/internal/historyExtended.js.map +1 -1
- package/dist/esm/internal/i18n.js +5 -5
- package/dist/esm/internal/i18n.js.map +1 -1
- package/dist/esm/internal/injected.js +1 -1
- package/dist/esm/internal/injected.js.map +1 -1
- package/dist/esm/internal/insertPreviewRoutes.js +3 -3
- package/dist/esm/internal/insertPreviewRoutes.js.map +1 -1
- package/dist/esm/internal/matchPath.js +17 -17
- package/dist/esm/internal/matchPath.js.map +1 -1
- package/dist/esm/internal/matchRoutes.js +18 -25
- package/dist/esm/internal/matchRoutes.js.map +1 -1
- package/dist/esm/internal/matchStoryboard.js +6 -6
- package/dist/esm/internal/matchStoryboard.js.map +1 -1
- package/dist/esm/internal/mediaQuery.js +11 -11
- package/dist/esm/internal/mediaQuery.js.map +1 -1
- package/dist/esm/internal/mount.js +7 -7
- package/dist/esm/internal/mount.js.map +1 -1
- package/dist/esm/internal/poll.js +53 -60
- package/dist/esm/internal/poll.js.map +1 -1
- package/dist/esm/internal/proxyFactories.js +4 -4
- package/dist/esm/internal/proxyFactories.js.map +1 -1
- package/dist/esm/internal/registerAppI18n.js +6 -6
- package/dist/esm/internal/registerAppI18n.js.map +1 -1
- package/dist/esm/internal/registerCustomTemplates.js +3 -3
- package/dist/esm/internal/registerCustomTemplates.js.map +1 -1
- package/dist/esm/internal/secret_internals.js +140 -146
- package/dist/esm/internal/secret_internals.js.map +1 -1
- package/dist/esm/internal/setupRootRuntimeContext.js +6 -7
- package/dist/esm/internal/setupRootRuntimeContext.js.map +1 -1
- package/dist/esm/internal/sse.js +24 -53
- package/dist/esm/internal/sse.js.map +1 -1
- package/dist/esm/internal/test_only.js +1 -1
- package/dist/esm/isStrictMode.js +3 -3
- package/dist/esm/isStrictMode.js.map +1 -1
- package/dist/esm/setAppVariable.js +1 -1
- package/dist/esm/setAppVariable.js.map +1 -1
- package/dist/esm/setLoginStateCookie.js +5 -5
- package/dist/esm/setLoginStateCookie.js.map +1 -1
- package/dist/esm/setUIVersion.js +1 -1
- package/dist/esm/setWatermark.js +13 -13
- package/dist/esm/setWatermark.js.map +1 -1
- package/dist/esm/themeAndMode.js +14 -13
- package/dist/esm/themeAndMode.js.map +1 -1
- package/dist/types/tsdoc-metadata.json +1 -1
- package/package.json +12 -12
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
var _excluded = ["blockingList", "node", "menuRequestNode", "hasTrackingControls"],
|
|
5
|
-
_excluded2 = ["if", "permissionsPreCheck"],
|
|
6
|
-
_excluded3 = ["formData"],
|
|
7
|
-
_excluded4 = ["src"],
|
|
8
|
-
_excluded5 = ["href"];
|
|
9
1
|
import { enqueueStableLoadBricks, flushStableLoadBricks, loadBricksImperatively, loadProcessorsImperatively, loadScript, loadStyle } from "@next-core/loader";
|
|
10
2
|
import { isTrackAll } from "@next-core/cook";
|
|
11
3
|
import { hasOwnProperty } from "@next-core/utils/general";
|
|
@@ -33,581 +25,534 @@ import { matchHomepage } from "./matchStoryboard.js";
|
|
|
33
25
|
import { listenerFactory } from "./bindListeners.js";
|
|
34
26
|
import { setupRootRuntimeContext } from "./setupRootRuntimeContext.js";
|
|
35
27
|
import { httpErrorToString } from "../handleHttpError.js";
|
|
36
|
-
export function renderRoutes(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var routePath = parentRoutes.concat(route);
|
|
64
|
-
runtimeContext.ctxStore.define(route.context, runtimeContext, undefined, routePath);
|
|
65
|
-
runtimeContext.pendingPermissionsPreCheck.push(hooks === null || hooks === void 0 || (_hooks$checkPermissio = hooks.checkPermissions) === null || _hooks$checkPermissio === void 0 ? void 0 : _hooks$checkPermissio.preCheckPermissionsForBrickOrRoute(route, value => asyncComputeRealValue(value, runtimeContext)));
|
|
28
|
+
export async function renderRoutes(returnNode, routes, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, isIncremental) {
|
|
29
|
+
const matched = await matchRoutes(routes, _runtimeContext);
|
|
30
|
+
const output = getEmptyRenderOutput();
|
|
31
|
+
const menuRequestNode = output.menuRequestNode = {
|
|
32
|
+
return: menuRequestReturnNode
|
|
33
|
+
};
|
|
34
|
+
switch (matched) {
|
|
35
|
+
case "missed":
|
|
36
|
+
break;
|
|
37
|
+
case "unauthenticated":
|
|
38
|
+
output.unauthenticated = true;
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
{
|
|
42
|
+
var _hooks$checkPermissio;
|
|
43
|
+
const route = output.route = matched.route;
|
|
44
|
+
output.path = matched.match.path;
|
|
45
|
+
const runtimeContext = {
|
|
46
|
+
..._runtimeContext,
|
|
47
|
+
match: matched.match
|
|
48
|
+
};
|
|
49
|
+
if (isIncremental) {
|
|
50
|
+
runtimeContext.ctxStore.disposeDataInRoutes(routes);
|
|
51
|
+
}
|
|
52
|
+
const routePath = parentRoutes.concat(route);
|
|
53
|
+
runtimeContext.ctxStore.define(route.context, runtimeContext, undefined, routePath);
|
|
54
|
+
runtimeContext.pendingPermissionsPreCheck.push(hooks === null || hooks === void 0 || (_hooks$checkPermissio = hooks.checkPermissions) === null || _hooks$checkPermissio === void 0 ? void 0 : _hooks$checkPermissio.preCheckPermissionsForBrickOrRoute(route, value => asyncComputeRealValue(value, runtimeContext)));
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
// Currently, this is only used for brick size-checking: these bricks
|
|
57
|
+
// will be loaded before page rendering, but they will NOT be rendered.
|
|
58
|
+
const {
|
|
59
|
+
preLoadBricks
|
|
60
|
+
} = route;
|
|
61
|
+
if (Array.isArray(preLoadBricks)) {
|
|
62
|
+
output.blockingList.push(loadBricksImperatively(preLoadBricks, getBrickPackages()));
|
|
63
|
+
}
|
|
64
|
+
if (route.type === "redirect") {
|
|
65
|
+
let redirectTo;
|
|
66
|
+
if (typeof route.redirect === "string") {
|
|
67
|
+
redirectTo = await asyncComputeRealValue(route.redirect, runtimeContext);
|
|
68
|
+
} else {
|
|
69
|
+
const resolved = await resolveData({
|
|
70
|
+
transform: "redirect",
|
|
71
|
+
...route.redirect
|
|
72
|
+
}, runtimeContext);
|
|
73
|
+
redirectTo = resolved.redirect;
|
|
74
74
|
}
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
75
|
+
if (typeof redirectTo !== "string") {
|
|
76
|
+
// eslint-disable-next-line no-console
|
|
77
|
+
console.error("Unexpected redirect result:", redirectTo);
|
|
78
|
+
throw new Error(`Unexpected type of redirect result: ${typeof redirectTo}`);
|
|
79
|
+
}
|
|
80
|
+
output.redirect = {
|
|
81
|
+
path: redirectTo
|
|
82
|
+
};
|
|
83
|
+
} else {
|
|
84
|
+
const menuRequest = loadMenu(route.menu, runtimeContext);
|
|
85
|
+
if (menuRequest) {
|
|
86
|
+
menuRequestNode.request = menuRequest;
|
|
87
|
+
}
|
|
88
|
+
if (!isIncremental) {
|
|
89
|
+
rendererContext.memoizeMenuRequestNode(routes, menuRequestNode);
|
|
90
|
+
}
|
|
91
|
+
let newOutput;
|
|
92
|
+
if (route.type === "routes") {
|
|
93
|
+
newOutput = await renderRoutes(returnNode, route.routes, runtimeContext, rendererContext, routePath, menuRequestNode, slotId);
|
|
93
94
|
} else {
|
|
94
|
-
|
|
95
|
-
if (menuRequest) {
|
|
96
|
-
menuRequestNode.request = menuRequest;
|
|
97
|
-
}
|
|
98
|
-
if (!isIncremental) {
|
|
99
|
-
rendererContext.memoizeMenuRequestNode(routes, menuRequestNode);
|
|
100
|
-
}
|
|
101
|
-
var newOutput;
|
|
102
|
-
if (route.type === "routes") {
|
|
103
|
-
newOutput = yield renderRoutes(returnNode, route.routes, runtimeContext, rendererContext, routePath, menuRequestNode, slotId);
|
|
104
|
-
} else {
|
|
105
|
-
newOutput = yield renderBricks(returnNode, route.bricks, runtimeContext, rendererContext, routePath, menuRequestNode, slotId);
|
|
106
|
-
}
|
|
107
|
-
mergeRenderOutput(output, newOutput);
|
|
108
|
-
appendMenuRequestNode(menuRequestNode, newOutput.menuRequestNode);
|
|
95
|
+
newOutput = await renderBricks(returnNode, route.bricks, runtimeContext, rendererContext, routePath, menuRequestNode, slotId);
|
|
109
96
|
}
|
|
97
|
+
mergeRenderOutput(output, newOutput);
|
|
98
|
+
appendMenuRequestNode(menuRequestNode, newOutput.menuRequestNode);
|
|
110
99
|
}
|
|
111
|
-
}
|
|
112
|
-
return output;
|
|
113
|
-
});
|
|
114
|
-
return _renderRoutes.apply(this, arguments);
|
|
115
|
-
}
|
|
116
|
-
export function renderBricks(_x9, _x10, _x11, _x12, _x13, _x14, _x15, _x16, _x17) {
|
|
117
|
-
return _renderBricks.apply(this, arguments);
|
|
118
|
-
}
|
|
119
|
-
function _renderBricks() {
|
|
120
|
-
_renderBricks = _asyncToGenerator(function* (returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath) {
|
|
121
|
-
setupRootRuntimeContext(bricks, runtimeContext, true);
|
|
122
|
-
var output = getEmptyRenderOutput();
|
|
123
|
-
var kPath = keyPath !== null && keyPath !== void 0 ? keyPath : [];
|
|
124
|
-
// 多个构件并行异步转换,但转换的结果按原顺序串行合并。
|
|
125
|
-
var rendered = yield Promise.all(bricks.map((brickConf, index) => renderBrick(returnNode, brickConf, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, kPath.concat(index), tplStack && new Map(tplStack))));
|
|
126
|
-
rendered.forEach((item, index) => {
|
|
127
|
-
if (item.hasTrackingControls) {
|
|
128
|
-
// Memoize a render node before it's been merged.
|
|
129
|
-
rendererContext.memoize(slotId, kPath.concat(index), item.node, returnNode);
|
|
130
100
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return output;
|
|
134
|
-
});
|
|
135
|
-
return _renderBricks.apply(this, arguments);
|
|
101
|
+
}
|
|
102
|
+
return output;
|
|
136
103
|
}
|
|
137
|
-
export function
|
|
138
|
-
|
|
104
|
+
export async function renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath) {
|
|
105
|
+
setupRootRuntimeContext(bricks, runtimeContext, true);
|
|
106
|
+
const output = getEmptyRenderOutput();
|
|
107
|
+
const kPath = keyPath ?? [];
|
|
108
|
+
// 多个构件并行异步转换,但转换的结果按原顺序串行合并。
|
|
109
|
+
const rendered = await Promise.all(bricks.map((brickConf, index) => renderBrick(returnNode, brickConf, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, kPath.concat(index), tplStack && new Map(tplStack))));
|
|
110
|
+
rendered.forEach((item, index) => {
|
|
111
|
+
if (item.hasTrackingControls) {
|
|
112
|
+
// Memoize a render node before it's been merged.
|
|
113
|
+
rendererContext.memoize(slotId, kPath.concat(index), item.node, returnNode);
|
|
114
|
+
}
|
|
115
|
+
mergeRenderOutput(output, item);
|
|
116
|
+
});
|
|
117
|
+
return output;
|
|
139
118
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
color: "var(--color-error)"
|
|
158
|
-
}
|
|
119
|
+
export async function renderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId) {
|
|
120
|
+
let keyPath = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : [];
|
|
121
|
+
let tplStack = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : new Map();
|
|
122
|
+
try {
|
|
123
|
+
return await legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, keyPath, tplStack);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (brickConf.errorBoundary) {
|
|
126
|
+
// eslint-disable-next-line no-console
|
|
127
|
+
console.error("Error caught by error boundary:", error);
|
|
128
|
+
return {
|
|
129
|
+
node: {
|
|
130
|
+
tag: RenderTag.BRICK,
|
|
131
|
+
type: "div",
|
|
132
|
+
properties: {
|
|
133
|
+
textContent: httpErrorToString(error),
|
|
134
|
+
dataset: {
|
|
135
|
+
errorBoundary: ""
|
|
159
136
|
},
|
|
160
|
-
|
|
161
|
-
|
|
137
|
+
style: {
|
|
138
|
+
color: "var(--color-error)"
|
|
139
|
+
}
|
|
162
140
|
},
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
141
|
+
runtimeContext: null,
|
|
142
|
+
return: returnNode
|
|
143
|
+
},
|
|
144
|
+
blockingList: []
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
throw error;
|
|
168
148
|
}
|
|
169
|
-
}
|
|
170
|
-
return _renderBrick.apply(this, arguments);
|
|
171
|
-
}
|
|
172
|
-
function legacyRenderBrick(_x25, _x26, _x27, _x28, _x29, _x30, _x31, _x32, _x33) {
|
|
173
|
-
return _legacyRenderBrick.apply(this, arguments);
|
|
149
|
+
}
|
|
174
150
|
}
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
console.error("Invalid brick:", brickConf);
|
|
186
|
-
}
|
|
187
|
-
return output;
|
|
151
|
+
async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, keyPath, tplStack) {
|
|
152
|
+
var _hooks$checkPermissio2, _runtimeContext$app;
|
|
153
|
+
const output = getEmptyRenderOutput();
|
|
154
|
+
if (!brickConf.brick) {
|
|
155
|
+
if (brickConf.template) {
|
|
156
|
+
// eslint-disable-next-line no-console
|
|
157
|
+
console.error("Legacy templates are dropped in v3:", brickConf);
|
|
158
|
+
} else {
|
|
159
|
+
// eslint-disable-next-line no-console
|
|
160
|
+
console.error("Invalid brick:", brickConf);
|
|
188
161
|
}
|
|
162
|
+
return output;
|
|
163
|
+
}
|
|
189
164
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
165
|
+
// Translate `if: "<%= ... %>"` to `brick: ":if", dataSource: "<%= ... %>"`.
|
|
166
|
+
// In other words, translate tracking if expressions to tracking control nodes of `:if`.
|
|
167
|
+
const {
|
|
168
|
+
if: brickIf,
|
|
169
|
+
permissionsPreCheck,
|
|
170
|
+
...restBrickConf
|
|
171
|
+
} = brickConf;
|
|
172
|
+
if (isGeneralizedTrackAll(brickIf)) {
|
|
173
|
+
return renderBrick(returnNode, {
|
|
174
|
+
brick: ":if",
|
|
175
|
+
dataSource: brickIf,
|
|
176
|
+
// `permissionsPreCheck` maybe required before computing `if`.
|
|
177
|
+
permissionsPreCheck,
|
|
178
|
+
slots: {
|
|
179
|
+
"": {
|
|
180
|
+
type: "bricks",
|
|
181
|
+
bricks: [restBrickConf]
|
|
208
182
|
}
|
|
209
|
-
},
|
|
183
|
+
},
|
|
184
|
+
// These symbols have to be copied to the new brick conf.
|
|
185
|
+
...Object.getOwnPropertySymbols(brickConf).reduce((acc, symbol) => ({
|
|
186
|
+
...acc,
|
|
210
187
|
[symbol]: brickConf[symbol]
|
|
211
|
-
}), {})
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
188
|
+
}), {})
|
|
189
|
+
}, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, keyPath, tplStack);
|
|
190
|
+
}
|
|
191
|
+
const tplStateStoreId = brickConf[symbolForTplStateStoreId];
|
|
192
|
+
const formStateStoreId = brickConf[symbolForFormStateStoreId];
|
|
193
|
+
const runtimeContext = {
|
|
194
|
+
..._runtimeContext,
|
|
195
|
+
tplStateStoreId,
|
|
196
|
+
formStateStoreId
|
|
197
|
+
};
|
|
198
|
+
if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {
|
|
199
|
+
// The external bricks of a template should restore their `forEachItem` and
|
|
200
|
+
// `forEachIndex` from their host.
|
|
201
|
+
runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];
|
|
202
|
+
runtimeContext.forEachIndex = brickConf[symbolForTPlExternalForEachIndex];
|
|
203
|
+
} else if (brickConf[symbolForTPlExternalNoForEach]) {
|
|
204
|
+
delete runtimeContext.forEachItem;
|
|
205
|
+
delete runtimeContext.forEachIndex;
|
|
206
|
+
}
|
|
207
|
+
const {
|
|
208
|
+
context
|
|
209
|
+
} = brickConf;
|
|
210
|
+
// istanbul ignore next
|
|
211
|
+
if (Array.isArray(context) && context.length > 0) {
|
|
212
|
+
const strict = isStrictMode(runtimeContext);
|
|
213
|
+
warnAboutStrictMode(strict, "Defining context on bricks", "check your brick:", brickConf);
|
|
214
|
+
if (!strict) {
|
|
215
|
+
runtimeContext.ctxStore.define(context, runtimeContext);
|
|
227
216
|
}
|
|
228
|
-
|
|
229
|
-
|
|
217
|
+
}
|
|
218
|
+
runtimeContext.pendingPermissionsPreCheck.push(hooks === null || hooks === void 0 || (_hooks$checkPermissio2 = hooks.checkPermissions) === null || _hooks$checkPermissio2 === void 0 ? void 0 : _hooks$checkPermissio2.preCheckPermissionsForBrickOrRoute(brickConf, value => asyncComputeRealValue(value, runtimeContext)));
|
|
219
|
+
if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {
|
|
220
|
+
return output;
|
|
221
|
+
}
|
|
222
|
+
const brickName = brickConf.brick;
|
|
223
|
+
if (brickName.startsWith(":")) {
|
|
224
|
+
ensureValidControlBrick(brickName);
|
|
225
|
+
const {
|
|
226
|
+
dataSource
|
|
230
227
|
} = brickConf;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (!strict) {
|
|
236
|
-
runtimeContext.ctxStore.define(context, runtimeContext);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
runtimeContext.pendingPermissionsPreCheck.push(hooks === null || hooks === void 0 || (_hooks$checkPermissio2 = hooks.checkPermissions) === null || _hooks$checkPermissio2 === void 0 ? void 0 : _hooks$checkPermissio2.preCheckPermissionsForBrickOrRoute(brickConf, value => asyncComputeRealValue(value, runtimeContext)));
|
|
240
|
-
if (!(yield asyncCheckBrickIf(brickConf, runtimeContext))) {
|
|
241
|
-
return output;
|
|
242
|
-
}
|
|
243
|
-
var brickName = brickConf.brick;
|
|
244
|
-
if (brickName.startsWith(":")) {
|
|
245
|
-
var _brickConf$lifeCycle;
|
|
246
|
-
ensureValidControlBrick(brickName);
|
|
247
|
-
var {
|
|
248
|
-
dataSource
|
|
249
|
-
} = brickConf;
|
|
250
|
-
var lowerLevelRenderControlNode = /*#__PURE__*/function () {
|
|
251
|
-
var _ref = _asyncToGenerator(function* (runtimeContext) {
|
|
252
|
-
var _slots$slot;
|
|
253
|
-
// First, compute the `dataSource`
|
|
254
|
-
var computedDataSource = yield asyncComputeRealValue(dataSource, runtimeContext);
|
|
228
|
+
const lowerLevelRenderControlNode = async runtimeContext => {
|
|
229
|
+
var _slots$slot;
|
|
230
|
+
// First, compute the `dataSource`
|
|
231
|
+
const computedDataSource = await asyncComputeRealValue(dataSource, runtimeContext);
|
|
255
232
|
|
|
256
|
-
|
|
257
|
-
|
|
233
|
+
// Then, get the matched slot.
|
|
234
|
+
const slot = brickName === ":forEach" ? "" : brickName === ":switch" ? String(computedDataSource) : computedDataSource ? "" : "else";
|
|
258
235
|
|
|
259
|
-
|
|
260
|
-
|
|
236
|
+
// Don't forget to transpile children to slots.
|
|
237
|
+
const slots = childrenToSlots(brickConf.children, brickConf.slots);
|
|
261
238
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
239
|
+
// Then, get the bricks in that matched slot.
|
|
240
|
+
const bricks = slots && hasOwnProperty(slots, slot) && ((_slots$slot = slots[slot]) === null || _slots$slot === void 0 ? void 0 : _slots$slot.bricks);
|
|
241
|
+
if (!Array.isArray(bricks)) {
|
|
242
|
+
return getEmptyRenderOutput();
|
|
243
|
+
}
|
|
244
|
+
switch (brickName) {
|
|
245
|
+
case ":forEach":
|
|
246
|
+
{
|
|
247
|
+
if (!Array.isArray(computedDataSource)) {
|
|
248
|
+
return getEmptyRenderOutput();
|
|
249
|
+
}
|
|
250
|
+
return renderForEach(returnNode, computedDataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
266
251
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return getEmptyRenderOutput();
|
|
272
|
-
}
|
|
273
|
-
return renderForEach(returnNode, computedDataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
274
|
-
}
|
|
275
|
-
case ":if":
|
|
276
|
-
case ":switch":
|
|
277
|
-
{
|
|
278
|
-
return renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
279
|
-
}
|
|
252
|
+
case ":if":
|
|
253
|
+
case ":switch":
|
|
254
|
+
{
|
|
255
|
+
return renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
280
256
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (contextNames || stateNames) {
|
|
310
|
-
controlledOutput.hasTrackingControls = true;
|
|
311
|
-
var renderId = 0;
|
|
312
|
-
var listener = /*#__PURE__*/function () {
|
|
313
|
-
var _ref3 = _asyncToGenerator(function* () {
|
|
314
|
-
var currentRenderId = ++renderId;
|
|
315
|
-
var [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext(runtimeContext);
|
|
316
|
-
var reControlledOutput = yield renderControlNode(scopedRuntimeContext);
|
|
317
|
-
var scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
318
|
-
yield postAsyncRender(reControlledOutput, scopedRuntimeContext, scopedStores);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const renderControlNode = async runtimeContext => {
|
|
260
|
+
const rawOutput = await lowerLevelRenderControlNode(runtimeContext);
|
|
261
|
+
rawOutput.node ?? (rawOutput.node = {
|
|
262
|
+
tag: RenderTag.PLACEHOLDER,
|
|
263
|
+
return: returnNode
|
|
264
|
+
});
|
|
265
|
+
return rawOutput;
|
|
266
|
+
};
|
|
267
|
+
const controlledOutput = await renderControlNode(runtimeContext);
|
|
268
|
+
const {
|
|
269
|
+
onMount,
|
|
270
|
+
onUnmount
|
|
271
|
+
} = brickConf.lifeCycle ?? {};
|
|
272
|
+
const {
|
|
273
|
+
contextNames,
|
|
274
|
+
stateNames
|
|
275
|
+
} = getTracks(dataSource);
|
|
276
|
+
if (contextNames || stateNames) {
|
|
277
|
+
controlledOutput.hasTrackingControls = true;
|
|
278
|
+
let renderId = 0;
|
|
279
|
+
const listener = async () => {
|
|
280
|
+
const currentRenderId = ++renderId;
|
|
281
|
+
const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext(runtimeContext);
|
|
282
|
+
const reControlledOutput = await renderControlNode(scopedRuntimeContext);
|
|
283
|
+
const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
284
|
+
await postAsyncRender(reControlledOutput, scopedRuntimeContext, scopedStores);
|
|
319
285
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
}));
|
|
286
|
+
// Ignore stale renders
|
|
287
|
+
if (renderId === currentRenderId) {
|
|
288
|
+
if (onUnmount) {
|
|
289
|
+
listenerFactory(onUnmount, runtimeContext)(new CustomEvent("unmount", {
|
|
290
|
+
detail: {
|
|
291
|
+
rerender: true
|
|
328
292
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
for (var store of scopedStores) {
|
|
338
|
-
store.mountAsyncData();
|
|
293
|
+
}));
|
|
294
|
+
}
|
|
295
|
+
rendererContext.reRender(slotId, keyPath, reControlledOutput.node, returnNode);
|
|
296
|
+
if (onMount) {
|
|
297
|
+
listenerFactory(onMount, scopedRuntimeContext)(new CustomEvent("mount", {
|
|
298
|
+
detail: {
|
|
299
|
+
rerender: true
|
|
339
300
|
}
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
return function listener() {
|
|
343
|
-
return _ref3.apply(this, arguments);
|
|
344
|
-
};
|
|
345
|
-
}();
|
|
346
|
-
var debouncedListener = debounce(listener);
|
|
347
|
-
if (contextNames) {
|
|
348
|
-
for (var contextName of contextNames) {
|
|
349
|
-
runtimeContext.ctxStore.onChange(contextName, debouncedListener);
|
|
301
|
+
}));
|
|
350
302
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
for (var _contextName of stateNames) {
|
|
354
|
-
var tplStateStore = getTplStateStore(runtimeContext, "STATE", ": \"".concat(dataSource, "\""));
|
|
355
|
-
tplStateStore.onChange(_contextName, debouncedListener);
|
|
303
|
+
for (const store of scopedStores) {
|
|
304
|
+
store.mountAsyncData();
|
|
356
305
|
}
|
|
357
306
|
}
|
|
307
|
+
};
|
|
308
|
+
const debouncedListener = debounce(listener);
|
|
309
|
+
if (contextNames) {
|
|
310
|
+
for (const contextName of contextNames) {
|
|
311
|
+
runtimeContext.ctxStore.onChange(contextName, debouncedListener);
|
|
312
|
+
}
|
|
358
313
|
}
|
|
359
|
-
if (
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
}));
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
if (onUnmount) {
|
|
369
|
-
rendererContext.registerArbitraryLifeCycle("onUnmount", () => {
|
|
370
|
-
listenerFactory(onUnmount, runtimeContext)(new CustomEvent("unmount", {
|
|
371
|
-
detail: {
|
|
372
|
-
rerender: false
|
|
373
|
-
}
|
|
374
|
-
}));
|
|
375
|
-
});
|
|
314
|
+
if (stateNames) {
|
|
315
|
+
for (const contextName of stateNames) {
|
|
316
|
+
const tplStateStore = getTplStateStore(runtimeContext, "STATE", `: "${dataSource}"`);
|
|
317
|
+
tplStateStore.onChange(contextName, debouncedListener);
|
|
318
|
+
}
|
|
376
319
|
}
|
|
377
|
-
return controlledOutput;
|
|
378
320
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
321
|
+
if (onMount) {
|
|
322
|
+
rendererContext.registerArbitraryLifeCycle("onMount", () => {
|
|
323
|
+
listenerFactory(onMount, runtimeContext)(new CustomEvent("mount", {
|
|
324
|
+
detail: {
|
|
325
|
+
rerender: false
|
|
326
|
+
}
|
|
327
|
+
}));
|
|
328
|
+
});
|
|
383
329
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
throw new Error("Maximum custom template stack overflowed: \"".concat(tplTagName, "\""));
|
|
390
|
-
}
|
|
391
|
-
tplStack.set(tplTagName, tplCount + 1);
|
|
392
|
-
} else if (brickName.includes("-") && !customElements.get(brickName)) {
|
|
393
|
-
if (brickName === FORM_RENDERER) {
|
|
394
|
-
customElements.define(FORM_RENDERER, class FormRendererElement extends HTMLElement {
|
|
395
|
-
get $$typeof() {
|
|
396
|
-
return "form-renderer";
|
|
330
|
+
if (onUnmount) {
|
|
331
|
+
rendererContext.registerArbitraryLifeCycle("onUnmount", () => {
|
|
332
|
+
listenerFactory(onUnmount, runtimeContext)(new CustomEvent("unmount", {
|
|
333
|
+
detail: {
|
|
334
|
+
rerender: false
|
|
397
335
|
}
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
336
|
+
}));
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
return controlledOutput;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Widgets need to be defined before rendering.
|
|
343
|
+
if (/\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {
|
|
344
|
+
await catchLoad(loadBricksImperatively([brickName], getBrickPackages()), "brick", brickName, rendererContext.unknownBricks);
|
|
345
|
+
}
|
|
346
|
+
const tplTagName = getTagNameOfCustomTemplate(brickName, (_runtimeContext$app = runtimeContext.app) === null || _runtimeContext$app === void 0 ? void 0 : _runtimeContext$app.id);
|
|
347
|
+
if (tplTagName) {
|
|
348
|
+
const tplCount = tplStack.get(tplTagName) ?? 0;
|
|
349
|
+
if (tplCount >= 10) {
|
|
350
|
+
throw new Error(`Maximum custom template stack overflowed: "${tplTagName}"`);
|
|
402
351
|
}
|
|
403
|
-
|
|
404
|
-
|
|
352
|
+
tplStack.set(tplTagName, tplCount + 1);
|
|
353
|
+
} else if (brickName.includes("-") && !customElements.get(brickName)) {
|
|
405
354
|
if (brickName === FORM_RENDERER) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
confProps = _objectWithoutProperties(_ref4, _excluded3);
|
|
412
|
-
_ref4;
|
|
355
|
+
customElements.define(FORM_RENDERER, class FormRendererElement extends HTMLElement {
|
|
356
|
+
get $$typeof() {
|
|
357
|
+
return "form-renderer";
|
|
358
|
+
}
|
|
359
|
+
});
|
|
413
360
|
} else {
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
var trackingContextList = [];
|
|
417
|
-
var asyncPropertyEntries = asyncComputeRealPropertyEntries(confProps, runtimeContext, trackingContextList);
|
|
418
|
-
var computedPropsFromHost = brickConf[symbolForAsyncComputedPropsFromHost];
|
|
419
|
-
if (computedPropsFromHost) {
|
|
420
|
-
asyncPropertyEntries.push(...computedPropsFromHost);
|
|
361
|
+
output.blockingList.push(catchLoad(enqueueStableLoadBricks([brickName], getBrickPackages()), "brick", brickName, rendererContext.unknownBricks));
|
|
421
362
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
363
|
+
}
|
|
364
|
+
let formData;
|
|
365
|
+
let confProps;
|
|
366
|
+
if (brickName === FORM_RENDERER) {
|
|
367
|
+
({
|
|
368
|
+
formData,
|
|
369
|
+
...confProps
|
|
370
|
+
} = brickConf.properties ?? {});
|
|
371
|
+
} else {
|
|
372
|
+
confProps = brickConf.properties;
|
|
373
|
+
}
|
|
374
|
+
const trackingContextList = [];
|
|
375
|
+
const asyncPropertyEntries = asyncComputeRealPropertyEntries(confProps, runtimeContext, trackingContextList);
|
|
376
|
+
const computedPropsFromHost = brickConf[symbolForAsyncComputedPropsFromHost];
|
|
377
|
+
if (computedPropsFromHost) {
|
|
378
|
+
asyncPropertyEntries.push(...computedPropsFromHost);
|
|
379
|
+
}
|
|
380
|
+
const isScript = brickName === "script";
|
|
381
|
+
if (isScript || brickName === "link") {
|
|
382
|
+
const props = await constructAsyncProperties(asyncPropertyEntries);
|
|
383
|
+
if (isScript ? props.src : props.rel === "stylesheet" && props.href) {
|
|
384
|
+
const prefix = window.PUBLIC_ROOT ?? "";
|
|
385
|
+
if (isScript) {
|
|
386
|
+
const {
|
|
387
|
+
src,
|
|
388
|
+
...attrs
|
|
389
|
+
} = props;
|
|
390
|
+
await catchLoad(loadScript(src, prefix, attrs), "script", src, "silent");
|
|
391
|
+
} else {
|
|
392
|
+
const {
|
|
393
|
+
href,
|
|
394
|
+
...attrs
|
|
395
|
+
} = props;
|
|
396
|
+
await catchLoad(loadStyle(href, prefix, attrs), "stylesheet", href, "silent");
|
|
442
397
|
}
|
|
398
|
+
return output;
|
|
443
399
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
400
|
+
}
|
|
401
|
+
const brick = {
|
|
402
|
+
tag: RenderTag.BRICK,
|
|
403
|
+
type: tplTagName || brickName,
|
|
404
|
+
return: returnNode,
|
|
405
|
+
slotId,
|
|
406
|
+
events: brickConf.events,
|
|
407
|
+
runtimeContext,
|
|
408
|
+
portal: brickConf.portal,
|
|
409
|
+
iid: brickConf.iid,
|
|
410
|
+
ref: brickConf.ref
|
|
411
|
+
};
|
|
412
|
+
output.node = brick;
|
|
456
413
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
414
|
+
// 在最终挂载前,先加载所有可能用到的 processors。
|
|
415
|
+
const usedProcessors = strictCollectMemberUsage([brickConf.events, brickConf.lifeCycle], "PROCESSORS", 2);
|
|
416
|
+
if (usedProcessors.size > 0) {
|
|
417
|
+
output.blockingList.push(catchLoad(loadProcessorsImperatively(usedProcessors, getBrickPackages()), "processors", [...usedProcessors].join(", "), rendererContext.unknownBricks));
|
|
418
|
+
}
|
|
462
419
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
420
|
+
// 加载构件属性和加载子构件等任务,可以并行。
|
|
421
|
+
const blockingList = [];
|
|
422
|
+
const loadProperties = async () => {
|
|
423
|
+
brick.properties = await constructAsyncProperties(asyncPropertyEntries);
|
|
424
|
+
listenOnTrackingContext(brick, trackingContextList);
|
|
425
|
+
};
|
|
426
|
+
blockingList.push(loadProperties());
|
|
427
|
+
rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);
|
|
428
|
+
let expandedBrickConf = brickConf;
|
|
429
|
+
if (tplTagName) {
|
|
430
|
+
expandedBrickConf = expandCustomTemplate(tplTagName, brickConf, brick, asyncPropertyEntries, rendererContext);
|
|
431
|
+
} else if (brickName === FORM_RENDERER) {
|
|
432
|
+
expandedBrickConf = expandFormRenderer(formData, brickConf, brick, asyncPropertyEntries, rendererContext);
|
|
433
|
+
}
|
|
434
|
+
if (expandedBrickConf.portal) {
|
|
435
|
+
// A portal brick has no slotId.
|
|
436
|
+
brick.slotId = undefined;
|
|
437
|
+
}
|
|
438
|
+
let childRuntimeContext;
|
|
439
|
+
if (tplTagName) {
|
|
440
|
+
// There is a boundary for `forEachItem` between template internals and externals.
|
|
441
|
+
childRuntimeContext = {
|
|
442
|
+
...runtimeContext
|
|
443
|
+
};
|
|
444
|
+
delete childRuntimeContext.forEachItem;
|
|
445
|
+
delete childRuntimeContext.forEachIndex;
|
|
446
|
+
} else {
|
|
447
|
+
childRuntimeContext = runtimeContext;
|
|
448
|
+
}
|
|
449
|
+
const loadChildren = async () => {
|
|
450
|
+
const slots = childrenToSlots(expandedBrickConf.children, expandedBrickConf.slots);
|
|
451
|
+
if (!slots) {
|
|
452
|
+
return;
|
|
494
453
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
454
|
+
const routeSlotFromIndexToSlotId = new Map();
|
|
455
|
+
const rendered = await Promise.all(Object.entries(slots).map((_ref, index) => {
|
|
456
|
+
let [childSlotId, slotConf] = _ref;
|
|
457
|
+
if (slotConf.type !== "routes") {
|
|
458
|
+
return renderBricks(brick, slotConf.bricks, childRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, tplStack);
|
|
459
|
+
}
|
|
460
|
+
const parentRoute = parentRoutes[parentRoutes.length - 1];
|
|
461
|
+
if (parentRoute !== null && parentRoute !== void 0 && parentRoute.incrementalSubRoutes) {
|
|
462
|
+
routeSlotFromIndexToSlotId.set(index, childSlotId);
|
|
463
|
+
rendererContext.performIncrementalRender(slotConf, parentRoutes, async (location, prevLocation) => {
|
|
464
|
+
const {
|
|
465
|
+
homepage
|
|
466
|
+
} = childRuntimeContext.app;
|
|
467
|
+
const {
|
|
468
|
+
pathname
|
|
469
|
+
} = location;
|
|
470
|
+
// Ignore if any one of homepage and parent routes not matched.
|
|
471
|
+
if (!matchHomepage(homepage, pathname) || !parentRoutes.every(route => {
|
|
472
|
+
let prevMatch;
|
|
473
|
+
let newMatch;
|
|
474
|
+
return (prevMatch = matchRoute(route, homepage, prevLocation.pathname)) && (newMatch = matchRoute(route, homepage, pathname)) && (route !== parentRoute || isEqual(prevMatch.params, newMatch.params));
|
|
475
|
+
})) {
|
|
476
|
+
return false;
|
|
506
477
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
} = location;
|
|
518
|
-
// Ignore if any one of homepage and parent routes not matched.
|
|
519
|
-
if (!matchHomepage(homepage, pathname) || !parentRoutes.every(route => {
|
|
520
|
-
var prevMatch;
|
|
521
|
-
var newMatch;
|
|
522
|
-
return (prevMatch = matchRoute(route, homepage, prevLocation.pathname)) && (newMatch = matchRoute(route, homepage, pathname)) && (route !== parentRoute || isEqual(prevMatch.params, newMatch.params));
|
|
523
|
-
})) {
|
|
524
|
-
return false;
|
|
525
|
-
}
|
|
526
|
-
var [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext(_objectSpread(_objectSpread({}, childRuntimeContext), {}, {
|
|
527
|
-
location,
|
|
528
|
-
query: new URLSearchParams(location.search)
|
|
529
|
-
}));
|
|
530
|
-
var failed = false;
|
|
531
|
-
var incrementalOutput;
|
|
532
|
-
var scopedStores = [];
|
|
533
|
-
try {
|
|
534
|
-
incrementalOutput = yield renderRoutes(brick, slotConf.routes, scopedRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, true);
|
|
535
|
-
|
|
536
|
-
// Do not ignore incremental rendering even if all sub-routes are missed.
|
|
537
|
-
// Since parent route is matched.
|
|
538
|
-
if (incrementalOutput.route) {
|
|
539
|
-
// Bailout if redirect or unauthenticated is set
|
|
540
|
-
if (rendererContext.reBailout(incrementalOutput)) {
|
|
541
|
-
return true;
|
|
542
|
-
}
|
|
543
|
-
scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
544
|
-
yield postAsyncRender(incrementalOutput, scopedRuntimeContext, [scopedRuntimeContext.ctxStore, ...scopedStores]);
|
|
545
|
-
}
|
|
546
|
-
yield rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
547
|
-
} catch (error) {
|
|
548
|
-
// eslint-disable-next-line no-console
|
|
549
|
-
console.error("Incremental sub-router failed:", error);
|
|
550
|
-
var result = rendererContext.reCatch(error, brick);
|
|
551
|
-
if (!result) {
|
|
552
|
-
return true;
|
|
553
|
-
}
|
|
554
|
-
({
|
|
555
|
-
failed,
|
|
556
|
-
output: incrementalOutput
|
|
557
|
-
} = result);
|
|
478
|
+
const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext({
|
|
479
|
+
...childRuntimeContext,
|
|
480
|
+
location,
|
|
481
|
+
query: new URLSearchParams(location.search)
|
|
482
|
+
});
|
|
483
|
+
let failed = false;
|
|
484
|
+
let incrementalOutput;
|
|
485
|
+
let scopedStores = [];
|
|
486
|
+
try {
|
|
487
|
+
incrementalOutput = await renderRoutes(brick, slotConf.routes, scopedRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, true);
|
|
558
488
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
489
|
+
// Do not ignore incremental rendering even if all sub-routes are missed.
|
|
490
|
+
// Since parent route is matched.
|
|
491
|
+
if (incrementalOutput.route) {
|
|
492
|
+
// Bailout if redirect or unauthenticated is set
|
|
493
|
+
if (rendererContext.reBailout(incrementalOutput)) {
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
497
|
+
await postAsyncRender(incrementalOutput, scopedRuntimeContext, [scopedRuntimeContext.ctxStore, ...scopedStores]);
|
|
498
|
+
}
|
|
499
|
+
await rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
500
|
+
} catch (error) {
|
|
501
|
+
// eslint-disable-next-line no-console
|
|
502
|
+
console.error("Incremental sub-router failed:", error);
|
|
503
|
+
const result = rendererContext.reCatch(error, brick);
|
|
504
|
+
if (!result) {
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
({
|
|
508
|
+
failed,
|
|
509
|
+
output: incrementalOutput
|
|
510
|
+
} = result);
|
|
569
511
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
return incrementalOutput.route ? true : null;
|
|
573
|
-
});
|
|
574
|
-
return function (_x46, _x47) {
|
|
575
|
-
return _ref8.apply(this, arguments);
|
|
576
|
-
};
|
|
577
|
-
}());
|
|
512
|
+
// Assert: no errors will be throw
|
|
513
|
+
await rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
578
514
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
});
|
|
586
|
-
rendered.forEach((item, index) => {
|
|
587
|
-
if (routeSlotFromIndexToSlotId.has(index)) {
|
|
588
|
-
// Memoize a render node before it's been merged.
|
|
589
|
-
rendererContext.memoize(routeSlotFromIndexToSlotId.get(index), [], item.node, brick);
|
|
515
|
+
rendererContext.reRender(childSlotId, [], incrementalOutput.node, brick);
|
|
516
|
+
if (!failed) {
|
|
517
|
+
scopedRuntimeContext.ctxStore.mountAsyncData(incrementalOutput.route);
|
|
518
|
+
for (const store of scopedStores) {
|
|
519
|
+
store.mountAsyncData();
|
|
520
|
+
}
|
|
590
521
|
}
|
|
591
|
-
|
|
592
|
-
|
|
522
|
+
|
|
523
|
+
// When result is null, it means the incremental rendering is tried but routes missed.
|
|
524
|
+
// In this case, we should continue to re-render the parent routes.
|
|
525
|
+
return incrementalOutput.route ? true : null;
|
|
593
526
|
});
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
527
|
+
}
|
|
528
|
+
return renderRoutes(brick, slotConf.routes, childRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId);
|
|
529
|
+
}));
|
|
530
|
+
const childrenOutput = {
|
|
531
|
+
...output,
|
|
532
|
+
node: undefined,
|
|
533
|
+
blockingList: [],
|
|
534
|
+
menuRequestNode: undefined
|
|
535
|
+
};
|
|
536
|
+
rendered.forEach((item, index) => {
|
|
537
|
+
if (routeSlotFromIndexToSlotId.has(index)) {
|
|
538
|
+
// Memoize a render node before it's been merged.
|
|
539
|
+
rendererContext.memoize(routeSlotFromIndexToSlotId.get(index), [], item.node, brick);
|
|
540
|
+
}
|
|
541
|
+
mergeRenderOutput(childrenOutput, item);
|
|
542
|
+
mergeSiblingRenderMenuRequest(childrenOutput, item);
|
|
543
|
+
});
|
|
544
|
+
if (childrenOutput.node) {
|
|
545
|
+
brick.child = childrenOutput.node;
|
|
546
|
+
}
|
|
547
|
+
mergeRenderOutput(output, {
|
|
548
|
+
...childrenOutput,
|
|
549
|
+
node: undefined
|
|
550
|
+
});
|
|
551
|
+
appendMenuRequestNode(menuRequestReturnNode, output.menuRequestNode = childrenOutput.menuRequestNode);
|
|
552
|
+
};
|
|
553
|
+
blockingList.push(loadChildren());
|
|
554
|
+
await Promise.all(blockingList);
|
|
555
|
+
return output;
|
|
611
556
|
}
|
|
612
557
|
function isGeneralizedTrackAll(brickIf) {
|
|
613
558
|
return typeof brickIf === "string" ? isTrackAll(brickIf) : isPreEvaluated(brickIf) &&
|
|
@@ -616,32 +561,27 @@ function isGeneralizedTrackAll(brickIf) {
|
|
|
616
561
|
}
|
|
617
562
|
function ensureValidControlBrick(brick) {
|
|
618
563
|
if (brick !== ":forEach" && brick !== ":if" && brick !== ":switch") {
|
|
619
|
-
throw new Error(
|
|
564
|
+
throw new Error(`Unknown storyboard control node: "${brick}"`);
|
|
620
565
|
}
|
|
621
566
|
}
|
|
622
|
-
function renderForEach(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
forEachItem: item,
|
|
631
|
-
forEachIndex: i
|
|
632
|
-
}), rendererContext, parentRoutes, menuRequestReturnNode, slotId, keyPath.concat(i * rows + j), tplStack && new Map(tplStack))))));
|
|
567
|
+
async function renderForEach(returnNode, dataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath) {
|
|
568
|
+
const output = getEmptyRenderOutput();
|
|
569
|
+
const rows = dataSource.length;
|
|
570
|
+
const rendered = await Promise.all(dataSource.map((item, i) => Promise.all(bricks.map((brickConf, j) => renderBrick(returnNode, brickConf, {
|
|
571
|
+
...runtimeContext,
|
|
572
|
+
forEachItem: item,
|
|
573
|
+
forEachIndex: i
|
|
574
|
+
}, rendererContext, parentRoutes, menuRequestReturnNode, slotId, keyPath.concat(i * rows + j), tplStack && new Map(tplStack))))));
|
|
633
575
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
});
|
|
642
|
-
return output;
|
|
576
|
+
// 多层构件并行异步转换,但转换的结果按原顺序串行合并。
|
|
577
|
+
rendered.flat().forEach((item, index) => {
|
|
578
|
+
if (item.hasTrackingControls) {
|
|
579
|
+
// Memoize a render node before it's been merged.
|
|
580
|
+
rendererContext.memoize(slotId, keyPath.concat(index), item.node, returnNode);
|
|
581
|
+
}
|
|
582
|
+
mergeRenderOutput(output, item);
|
|
643
583
|
});
|
|
644
|
-
return
|
|
584
|
+
return output;
|
|
645
585
|
}
|
|
646
586
|
export function getDataStores(runtimeContext) {
|
|
647
587
|
return [runtimeContext.ctxStore, ...runtimeContext.tplStateStoreMap.values(), ...runtimeContext.formStateStoreMap.values()];
|
|
@@ -651,12 +591,13 @@ export function postAsyncRender(output, runtimeContext, stores) {
|
|
|
651
591
|
return Promise.all([...output.blockingList, ...stores.map(store => store.waitForAll()), ...runtimeContext.pendingPermissionsPreCheck]);
|
|
652
592
|
}
|
|
653
593
|
export function createScopedRuntimeContext(runtimeContext) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
594
|
+
const tplStateStoreScope = [];
|
|
595
|
+
const formStateStoreScope = [];
|
|
596
|
+
const scopedRuntimeContext = {
|
|
597
|
+
...runtimeContext,
|
|
657
598
|
tplStateStoreScope,
|
|
658
599
|
formStateStoreScope
|
|
659
|
-
}
|
|
600
|
+
};
|
|
660
601
|
return [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope];
|
|
661
602
|
}
|
|
662
603
|
function loadMenu(menuConf, runtimeContext) {
|
|
@@ -681,17 +622,17 @@ function loadMenu(menuConf, runtimeContext) {
|
|
|
681
622
|
}
|
|
682
623
|
function mergeRenderOutput(output, newOutput) {
|
|
683
624
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
625
|
+
const {
|
|
626
|
+
blockingList,
|
|
627
|
+
node,
|
|
628
|
+
menuRequestNode,
|
|
629
|
+
hasTrackingControls,
|
|
630
|
+
...rest
|
|
631
|
+
} = newOutput;
|
|
691
632
|
output.blockingList.push(...blockingList);
|
|
692
633
|
if (node) {
|
|
693
634
|
if (output.node) {
|
|
694
|
-
|
|
635
|
+
let last = output.node;
|
|
695
636
|
while (last.sibling) {
|
|
696
637
|
last = last.sibling;
|
|
697
638
|
}
|
|
@@ -703,10 +644,10 @@ function mergeRenderOutput(output, newOutput) {
|
|
|
703
644
|
Object.assign(output, rest);
|
|
704
645
|
}
|
|
705
646
|
function mergeSiblingRenderMenuRequest(output, newOutput) {
|
|
706
|
-
|
|
647
|
+
const menuRequestNode = newOutput.menuRequestNode;
|
|
707
648
|
if (menuRequestNode) {
|
|
708
649
|
if (output.menuRequestNode) {
|
|
709
|
-
|
|
650
|
+
let last = output.menuRequestNode;
|
|
710
651
|
while (last.sibling) {
|
|
711
652
|
last = last.sibling;
|
|
712
653
|
}
|
|
@@ -721,7 +662,7 @@ function appendMenuRequestNode(menuRequestReturnNode, menuRequestNode) {
|
|
|
721
662
|
return;
|
|
722
663
|
}
|
|
723
664
|
if (menuRequestReturnNode.child) {
|
|
724
|
-
|
|
665
|
+
let last = menuRequestReturnNode.child;
|
|
725
666
|
while (last.sibling) {
|
|
726
667
|
last = last.sibling;
|
|
727
668
|
}
|
|
@@ -736,17 +677,16 @@ function getEmptyRenderOutput() {
|
|
|
736
677
|
};
|
|
737
678
|
}
|
|
738
679
|
export function childrenToSlots(children, originalSlots) {
|
|
739
|
-
|
|
680
|
+
let newSlots = originalSlots;
|
|
740
681
|
// istanbul ignore next
|
|
741
682
|
if (process.env.NODE_ENV === "development" && children && !Array.isArray(children)) {
|
|
742
683
|
// eslint-disable-next-line no-console
|
|
743
|
-
console.warn("Specified brick children but not array:",
|
|
684
|
+
console.warn("Specified brick children but not array:", `<${typeof children}>`, children);
|
|
744
685
|
}
|
|
745
686
|
if (Array.isArray(children) && !newSlots) {
|
|
746
687
|
newSlots = {};
|
|
747
|
-
for (
|
|
748
|
-
|
|
749
|
-
var slot = (_child$slot = child.slot) !== null && _child$slot !== void 0 ? _child$slot : "";
|
|
688
|
+
for (const child of children) {
|
|
689
|
+
const slot = child.slot ?? "";
|
|
750
690
|
if (!hasOwnProperty(newSlots, slot)) {
|
|
751
691
|
newSlots[slot] = {
|
|
752
692
|
type: "bricks",
|
|
@@ -761,7 +701,7 @@ export function childrenToSlots(children, originalSlots) {
|
|
|
761
701
|
function catchLoad(promise, type, name, unknownPolicy) {
|
|
762
702
|
return unknownPolicy === "silent" ? promise.catch(e => {
|
|
763
703
|
// eslint-disable-next-line no-console
|
|
764
|
-
console.error(
|
|
704
|
+
console.error(`Load %s "%s" failed:`, type, name, e);
|
|
765
705
|
}) : promise;
|
|
766
706
|
}
|
|
767
707
|
//# sourceMappingURL=Renderer.js.map
|