@next-core/runtime 1.44.2 → 1.44.4
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 +4 -4
- 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 +8 -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.map +1 -1
- package/dist/cjs/internal/Runtime.js +19 -16
- 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 -129
- 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 -580
- 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 -346
- package/dist/esm/internal/Router.js.map +1 -1
- package/dist/esm/internal/Runtime.js +58 -53
- 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,584 +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
|
-
errorBoundary: ""
|
|
158
|
-
},
|
|
159
|
-
style: {
|
|
160
|
-
color: "var(--color-error)"
|
|
161
|
-
}
|
|
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: ""
|
|
162
136
|
},
|
|
163
|
-
|
|
164
|
-
|
|
137
|
+
style: {
|
|
138
|
+
color: "var(--color-error)"
|
|
139
|
+
}
|
|
165
140
|
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
141
|
+
runtimeContext: null,
|
|
142
|
+
return: returnNode
|
|
143
|
+
},
|
|
144
|
+
blockingList: []
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
throw error;
|
|
171
148
|
}
|
|
172
|
-
}
|
|
173
|
-
return _renderBrick.apply(this, arguments);
|
|
174
|
-
}
|
|
175
|
-
function legacyRenderBrick(_x25, _x26, _x27, _x28, _x29, _x30, _x31, _x32, _x33) {
|
|
176
|
-
return _legacyRenderBrick.apply(this, arguments);
|
|
149
|
+
}
|
|
177
150
|
}
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
console.error("Invalid brick:", brickConf);
|
|
189
|
-
}
|
|
190
|
-
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);
|
|
191
161
|
}
|
|
162
|
+
return output;
|
|
163
|
+
}
|
|
192
164
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
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]
|
|
211
182
|
}
|
|
212
|
-
},
|
|
183
|
+
},
|
|
184
|
+
// These symbols have to be copied to the new brick conf.
|
|
185
|
+
...Object.getOwnPropertySymbols(brickConf).reduce((acc, symbol) => ({
|
|
186
|
+
...acc,
|
|
213
187
|
[symbol]: brickConf[symbol]
|
|
214
|
-
}), {})
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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);
|
|
230
216
|
}
|
|
231
|
-
|
|
232
|
-
|
|
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
|
|
233
227
|
} = brickConf;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (!strict) {
|
|
239
|
-
runtimeContext.ctxStore.define(context, runtimeContext);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
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)));
|
|
243
|
-
if (!(yield asyncCheckBrickIf(brickConf, runtimeContext))) {
|
|
244
|
-
return output;
|
|
245
|
-
}
|
|
246
|
-
var brickName = brickConf.brick;
|
|
247
|
-
if (brickName.startsWith(":")) {
|
|
248
|
-
var _brickConf$lifeCycle;
|
|
249
|
-
ensureValidControlBrick(brickName);
|
|
250
|
-
var {
|
|
251
|
-
dataSource
|
|
252
|
-
} = brickConf;
|
|
253
|
-
var lowerLevelRenderControlNode = /*#__PURE__*/function () {
|
|
254
|
-
var _ref = _asyncToGenerator(function* (runtimeContext) {
|
|
255
|
-
var _slots$slot;
|
|
256
|
-
// First, compute the `dataSource`
|
|
257
|
-
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);
|
|
258
232
|
|
|
259
|
-
|
|
260
|
-
|
|
233
|
+
// Then, get the matched slot.
|
|
234
|
+
const slot = brickName === ":forEach" ? "" : brickName === ":switch" ? String(computedDataSource) : computedDataSource ? "" : "else";
|
|
261
235
|
|
|
262
|
-
|
|
263
|
-
|
|
236
|
+
// Don't forget to transpile children to slots.
|
|
237
|
+
const slots = childrenToSlots(brickConf.children, brickConf.slots);
|
|
264
238
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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);
|
|
269
251
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
return getEmptyRenderOutput();
|
|
275
|
-
}
|
|
276
|
-
return renderForEach(returnNode, computedDataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
277
|
-
}
|
|
278
|
-
case ":if":
|
|
279
|
-
case ":switch":
|
|
280
|
-
{
|
|
281
|
-
return renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
282
|
-
}
|
|
252
|
+
case ":if":
|
|
253
|
+
case ":switch":
|
|
254
|
+
{
|
|
255
|
+
return renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
283
256
|
}
|
|
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
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (contextNames || stateNames) {
|
|
313
|
-
controlledOutput.hasTrackingControls = true;
|
|
314
|
-
var renderId = 0;
|
|
315
|
-
var listener = /*#__PURE__*/function () {
|
|
316
|
-
var _ref3 = _asyncToGenerator(function* () {
|
|
317
|
-
var currentRenderId = ++renderId;
|
|
318
|
-
var [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext(runtimeContext);
|
|
319
|
-
var reControlledOutput = yield renderControlNode(scopedRuntimeContext);
|
|
320
|
-
var scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
321
|
-
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);
|
|
322
285
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
}));
|
|
286
|
+
// Ignore stale renders
|
|
287
|
+
if (renderId === currentRenderId) {
|
|
288
|
+
if (onUnmount) {
|
|
289
|
+
listenerFactory(onUnmount, runtimeContext)(new CustomEvent("unmount", {
|
|
290
|
+
detail: {
|
|
291
|
+
rerender: true
|
|
331
292
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
for (var store of scopedStores) {
|
|
341
|
-
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
|
|
342
300
|
}
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
return function listener() {
|
|
346
|
-
return _ref3.apply(this, arguments);
|
|
347
|
-
};
|
|
348
|
-
}();
|
|
349
|
-
var debouncedListener = debounce(listener);
|
|
350
|
-
if (contextNames) {
|
|
351
|
-
for (var contextName of contextNames) {
|
|
352
|
-
runtimeContext.ctxStore.onChange(contextName, debouncedListener);
|
|
301
|
+
}));
|
|
353
302
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
for (var _contextName of stateNames) {
|
|
357
|
-
var tplStateStore = getTplStateStore(runtimeContext, "STATE", ": \"".concat(dataSource, "\""));
|
|
358
|
-
tplStateStore.onChange(_contextName, debouncedListener);
|
|
303
|
+
for (const store of scopedStores) {
|
|
304
|
+
store.mountAsyncData();
|
|
359
305
|
}
|
|
360
306
|
}
|
|
307
|
+
};
|
|
308
|
+
const debouncedListener = debounce(listener);
|
|
309
|
+
if (contextNames) {
|
|
310
|
+
for (const contextName of contextNames) {
|
|
311
|
+
runtimeContext.ctxStore.onChange(contextName, debouncedListener);
|
|
312
|
+
}
|
|
361
313
|
}
|
|
362
|
-
if (
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
}));
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
if (onUnmount) {
|
|
372
|
-
rendererContext.registerArbitraryLifeCycle("onUnmount", () => {
|
|
373
|
-
listenerFactory(onUnmount, runtimeContext)(new CustomEvent("unmount", {
|
|
374
|
-
detail: {
|
|
375
|
-
rerender: false
|
|
376
|
-
}
|
|
377
|
-
}));
|
|
378
|
-
});
|
|
314
|
+
if (stateNames) {
|
|
315
|
+
for (const contextName of stateNames) {
|
|
316
|
+
const tplStateStore = getTplStateStore(runtimeContext, "STATE", `: "${dataSource}"`);
|
|
317
|
+
tplStateStore.onChange(contextName, debouncedListener);
|
|
318
|
+
}
|
|
379
319
|
}
|
|
380
|
-
return controlledOutput;
|
|
381
320
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
321
|
+
if (onMount) {
|
|
322
|
+
rendererContext.registerArbitraryLifeCycle("onMount", () => {
|
|
323
|
+
listenerFactory(onMount, runtimeContext)(new CustomEvent("mount", {
|
|
324
|
+
detail: {
|
|
325
|
+
rerender: false
|
|
326
|
+
}
|
|
327
|
+
}));
|
|
328
|
+
});
|
|
386
329
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
throw new Error("Maximum custom template stack overflowed: \"".concat(tplTagName, "\""));
|
|
393
|
-
}
|
|
394
|
-
tplStack.set(tplTagName, tplCount + 1);
|
|
395
|
-
} else if (brickName.includes("-") && !customElements.get(brickName)) {
|
|
396
|
-
if (brickName === FORM_RENDERER) {
|
|
397
|
-
customElements.define(FORM_RENDERER, class FormRendererElement extends HTMLElement {
|
|
398
|
-
get $$typeof() {
|
|
399
|
-
return "form-renderer";
|
|
330
|
+
if (onUnmount) {
|
|
331
|
+
rendererContext.registerArbitraryLifeCycle("onUnmount", () => {
|
|
332
|
+
listenerFactory(onUnmount, runtimeContext)(new CustomEvent("unmount", {
|
|
333
|
+
detail: {
|
|
334
|
+
rerender: false
|
|
400
335
|
}
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
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}"`);
|
|
405
351
|
}
|
|
406
|
-
|
|
407
|
-
|
|
352
|
+
tplStack.set(tplTagName, tplCount + 1);
|
|
353
|
+
} else if (brickName.includes("-") && !customElements.get(brickName)) {
|
|
408
354
|
if (brickName === FORM_RENDERER) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
confProps = _objectWithoutProperties(_ref4, _excluded3);
|
|
415
|
-
_ref4;
|
|
355
|
+
customElements.define(FORM_RENDERER, class FormRendererElement extends HTMLElement {
|
|
356
|
+
get $$typeof() {
|
|
357
|
+
return "form-renderer";
|
|
358
|
+
}
|
|
359
|
+
});
|
|
416
360
|
} else {
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
var trackingContextList = [];
|
|
420
|
-
var asyncPropertyEntries = asyncComputeRealPropertyEntries(confProps, runtimeContext, trackingContextList);
|
|
421
|
-
var computedPropsFromHost = brickConf[symbolForAsyncComputedPropsFromHost];
|
|
422
|
-
if (computedPropsFromHost) {
|
|
423
|
-
asyncPropertyEntries.push(...computedPropsFromHost);
|
|
361
|
+
output.blockingList.push(catchLoad(enqueueStableLoadBricks([brickName], getBrickPackages()), "brick", brickName, rendererContext.unknownBricks));
|
|
424
362
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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");
|
|
445
397
|
}
|
|
398
|
+
return output;
|
|
446
399
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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;
|
|
459
413
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
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
|
+
}
|
|
465
419
|
|
|
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
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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;
|
|
497
453
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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;
|
|
509
477
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
} = location;
|
|
521
|
-
// Ignore if any one of homepage and parent routes not matched.
|
|
522
|
-
if (!matchHomepage(homepage, pathname) || !parentRoutes.every(route => {
|
|
523
|
-
var prevMatch;
|
|
524
|
-
var newMatch;
|
|
525
|
-
return (prevMatch = matchRoute(route, homepage, prevLocation.pathname)) && (newMatch = matchRoute(route, homepage, pathname)) && (route !== parentRoute || isEqual(prevMatch.params, newMatch.params));
|
|
526
|
-
})) {
|
|
527
|
-
return false;
|
|
528
|
-
}
|
|
529
|
-
var [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext(_objectSpread(_objectSpread({}, childRuntimeContext), {}, {
|
|
530
|
-
location,
|
|
531
|
-
query: new URLSearchParams(location.search)
|
|
532
|
-
}));
|
|
533
|
-
var failed = false;
|
|
534
|
-
var incrementalOutput;
|
|
535
|
-
var scopedStores = [];
|
|
536
|
-
try {
|
|
537
|
-
incrementalOutput = yield renderRoutes(brick, slotConf.routes, scopedRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, true);
|
|
538
|
-
|
|
539
|
-
// Do not ignore incremental rendering even if all sub-routes are missed.
|
|
540
|
-
// Since parent route is matched.
|
|
541
|
-
if (incrementalOutput.route) {
|
|
542
|
-
// Bailout if redirect or unauthenticated is set
|
|
543
|
-
if (rendererContext.reBailout(incrementalOutput)) {
|
|
544
|
-
return true;
|
|
545
|
-
}
|
|
546
|
-
scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
547
|
-
yield postAsyncRender(incrementalOutput, scopedRuntimeContext, [scopedRuntimeContext.ctxStore, ...scopedStores]);
|
|
548
|
-
}
|
|
549
|
-
yield rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
550
|
-
} catch (error) {
|
|
551
|
-
// eslint-disable-next-line no-console
|
|
552
|
-
console.error("Incremental sub-router failed:", error);
|
|
553
|
-
var result = rendererContext.reCatch(error, brick);
|
|
554
|
-
if (!result) {
|
|
555
|
-
return true;
|
|
556
|
-
}
|
|
557
|
-
({
|
|
558
|
-
failed,
|
|
559
|
-
output: incrementalOutput
|
|
560
|
-
} = 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);
|
|
561
488
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
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);
|
|
572
511
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
return incrementalOutput.route ? true : null;
|
|
576
|
-
});
|
|
577
|
-
return function (_x46, _x47) {
|
|
578
|
-
return _ref8.apply(this, arguments);
|
|
579
|
-
};
|
|
580
|
-
}());
|
|
512
|
+
// Assert: no errors will be throw
|
|
513
|
+
await rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
581
514
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
});
|
|
589
|
-
rendered.forEach((item, index) => {
|
|
590
|
-
if (routeSlotFromIndexToSlotId.has(index)) {
|
|
591
|
-
// Memoize a render node before it's been merged.
|
|
592
|
-
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
|
+
}
|
|
593
521
|
}
|
|
594
|
-
|
|
595
|
-
|
|
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;
|
|
596
526
|
});
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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;
|
|
614
556
|
}
|
|
615
557
|
function isGeneralizedTrackAll(brickIf) {
|
|
616
558
|
return typeof brickIf === "string" ? isTrackAll(brickIf) : isPreEvaluated(brickIf) &&
|
|
@@ -619,32 +561,27 @@ function isGeneralizedTrackAll(brickIf) {
|
|
|
619
561
|
}
|
|
620
562
|
function ensureValidControlBrick(brick) {
|
|
621
563
|
if (brick !== ":forEach" && brick !== ":if" && brick !== ":switch") {
|
|
622
|
-
throw new Error(
|
|
564
|
+
throw new Error(`Unknown storyboard control node: "${brick}"`);
|
|
623
565
|
}
|
|
624
566
|
}
|
|
625
|
-
function renderForEach(
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
forEachItem: item,
|
|
634
|
-
forEachIndex: i
|
|
635
|
-
}), 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))))));
|
|
636
575
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
});
|
|
645
|
-
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);
|
|
646
583
|
});
|
|
647
|
-
return
|
|
584
|
+
return output;
|
|
648
585
|
}
|
|
649
586
|
export function getDataStores(runtimeContext) {
|
|
650
587
|
return [runtimeContext.ctxStore, ...runtimeContext.tplStateStoreMap.values(), ...runtimeContext.formStateStoreMap.values()];
|
|
@@ -654,12 +591,13 @@ export function postAsyncRender(output, runtimeContext, stores) {
|
|
|
654
591
|
return Promise.all([...output.blockingList, ...stores.map(store => store.waitForAll()), ...runtimeContext.pendingPermissionsPreCheck]);
|
|
655
592
|
}
|
|
656
593
|
export function createScopedRuntimeContext(runtimeContext) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
594
|
+
const tplStateStoreScope = [];
|
|
595
|
+
const formStateStoreScope = [];
|
|
596
|
+
const scopedRuntimeContext = {
|
|
597
|
+
...runtimeContext,
|
|
660
598
|
tplStateStoreScope,
|
|
661
599
|
formStateStoreScope
|
|
662
|
-
}
|
|
600
|
+
};
|
|
663
601
|
return [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope];
|
|
664
602
|
}
|
|
665
603
|
function loadMenu(menuConf, runtimeContext) {
|
|
@@ -684,17 +622,17 @@ function loadMenu(menuConf, runtimeContext) {
|
|
|
684
622
|
}
|
|
685
623
|
function mergeRenderOutput(output, newOutput) {
|
|
686
624
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
625
|
+
const {
|
|
626
|
+
blockingList,
|
|
627
|
+
node,
|
|
628
|
+
menuRequestNode,
|
|
629
|
+
hasTrackingControls,
|
|
630
|
+
...rest
|
|
631
|
+
} = newOutput;
|
|
694
632
|
output.blockingList.push(...blockingList);
|
|
695
633
|
if (node) {
|
|
696
634
|
if (output.node) {
|
|
697
|
-
|
|
635
|
+
let last = output.node;
|
|
698
636
|
while (last.sibling) {
|
|
699
637
|
last = last.sibling;
|
|
700
638
|
}
|
|
@@ -706,10 +644,10 @@ function mergeRenderOutput(output, newOutput) {
|
|
|
706
644
|
Object.assign(output, rest);
|
|
707
645
|
}
|
|
708
646
|
function mergeSiblingRenderMenuRequest(output, newOutput) {
|
|
709
|
-
|
|
647
|
+
const menuRequestNode = newOutput.menuRequestNode;
|
|
710
648
|
if (menuRequestNode) {
|
|
711
649
|
if (output.menuRequestNode) {
|
|
712
|
-
|
|
650
|
+
let last = output.menuRequestNode;
|
|
713
651
|
while (last.sibling) {
|
|
714
652
|
last = last.sibling;
|
|
715
653
|
}
|
|
@@ -724,7 +662,7 @@ function appendMenuRequestNode(menuRequestReturnNode, menuRequestNode) {
|
|
|
724
662
|
return;
|
|
725
663
|
}
|
|
726
664
|
if (menuRequestReturnNode.child) {
|
|
727
|
-
|
|
665
|
+
let last = menuRequestReturnNode.child;
|
|
728
666
|
while (last.sibling) {
|
|
729
667
|
last = last.sibling;
|
|
730
668
|
}
|
|
@@ -739,17 +677,16 @@ function getEmptyRenderOutput() {
|
|
|
739
677
|
};
|
|
740
678
|
}
|
|
741
679
|
export function childrenToSlots(children, originalSlots) {
|
|
742
|
-
|
|
680
|
+
let newSlots = originalSlots;
|
|
743
681
|
// istanbul ignore next
|
|
744
682
|
if (process.env.NODE_ENV === "development" && children && !Array.isArray(children)) {
|
|
745
683
|
// eslint-disable-next-line no-console
|
|
746
|
-
console.warn("Specified brick children but not array:",
|
|
684
|
+
console.warn("Specified brick children but not array:", `<${typeof children}>`, children);
|
|
747
685
|
}
|
|
748
686
|
if (Array.isArray(children) && !newSlots) {
|
|
749
687
|
newSlots = {};
|
|
750
|
-
for (
|
|
751
|
-
|
|
752
|
-
var slot = (_child$slot = child.slot) !== null && _child$slot !== void 0 ? _child$slot : "";
|
|
688
|
+
for (const child of children) {
|
|
689
|
+
const slot = child.slot ?? "";
|
|
753
690
|
if (!hasOwnProperty(newSlots, slot)) {
|
|
754
691
|
newSlots[slot] = {
|
|
755
692
|
type: "bricks",
|
|
@@ -764,7 +701,7 @@ export function childrenToSlots(children, originalSlots) {
|
|
|
764
701
|
function catchLoad(promise, type, name, unknownPolicy) {
|
|
765
702
|
return unknownPolicy === "silent" ? promise.catch(e => {
|
|
766
703
|
// eslint-disable-next-line no-console
|
|
767
|
-
console.error(
|
|
704
|
+
console.error(`Load %s "%s" failed:`, type, name, e);
|
|
768
705
|
}) : promise;
|
|
769
706
|
}
|
|
770
707
|
//# sourceMappingURL=Renderer.js.map
|