@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,5 +1,3 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
1
|
import { pick } from "lodash";
|
|
4
2
|
import { _internalApiGetRenderId, _internalApiGetRuntimeContext, _internalApiGetStoryboardInBootstrapData, getBrickPackages } from "./Runtime.js";
|
|
5
3
|
import { createScopedRuntimeContext, postAsyncRender, renderBrick } from "./Renderer.js";
|
|
@@ -14,63 +12,61 @@ import { customTemplates } from "../CustomTemplates.js";
|
|
|
14
12
|
import { registerAppI18n } from "./registerAppI18n.js";
|
|
15
13
|
import { getTplStateStore } from "./CustomTemplates/utils.js";
|
|
16
14
|
import { loadBricksImperatively } from "@next-core/loader";
|
|
17
|
-
export
|
|
18
|
-
export function renderUseBrick(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext(_objectSpread(_objectSpread({}, (_useBrick$symbolForRo = useBrick[symbolForRootRuntimeContext]) !== null && _useBrick$symbolForRo !== void 0 ? _useBrick$symbolForRo : _internalApiGetRuntimeContext()), {}, {
|
|
25
|
-
data,
|
|
26
|
-
pendingPermissionsPreCheck: []
|
|
27
|
-
}));
|
|
28
|
-
(_scopedRuntimeContext = scopedRuntimeContext.tplStateStoreMap) !== null && _scopedRuntimeContext !== void 0 ? _scopedRuntimeContext : scopedRuntimeContext.tplStateStoreMap = new Map();
|
|
29
|
-
(_scopedRuntimeContext2 = scopedRuntimeContext.formStateStoreMap) !== null && _scopedRuntimeContext2 !== void 0 ? _scopedRuntimeContext2 : scopedRuntimeContext.formStateStoreMap = new Map();
|
|
30
|
-
var rendererContext = new RendererContext("fragment");
|
|
31
|
-
var renderRoot = {
|
|
32
|
-
tag: RenderTag.ROOT,
|
|
33
|
-
// Will set during `mountUseBrick`
|
|
34
|
-
createPortal: null
|
|
35
|
-
};
|
|
36
|
-
var transform = useBrick.transform;
|
|
37
|
-
var strict = isStrictMode();
|
|
38
|
-
if (transform) {
|
|
39
|
-
warnAboutStrictMode(strict, "`useBrick.transform`", 'please use "properties" instead, check your useBrick:', useBrick);
|
|
40
|
-
}
|
|
41
|
-
var output = yield renderBrick(renderRoot, strict && !errorBoundary ? useBrick : _objectSpread(_objectSpread({
|
|
42
|
-
errorBoundary
|
|
43
|
-
}, useBrick), {}, {
|
|
44
|
-
properties: _objectSpread(_objectSpread({}, useBrick.properties), transform)
|
|
45
|
-
}), scopedRuntimeContext, rendererContext, [], {});
|
|
46
|
-
var scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
47
|
-
yield postAsyncRender(output, scopedRuntimeContext, scopedStores);
|
|
48
|
-
if (((_output$node = output.node) === null || _output$node === void 0 ? void 0 : _output$node.tag) === RenderTag.PLACEHOLDER) {
|
|
49
|
-
throw new Error("The root brick of useBrick cannot be an ignored control node");
|
|
50
|
-
}
|
|
51
|
-
if ((_output$node2 = output.node) !== null && _output$node2 !== void 0 && _output$node2.portal) {
|
|
52
|
-
throw new Error("The root brick of useBrick cannot be a portal brick");
|
|
53
|
-
}
|
|
54
|
-
renderRoot.child = output.node;
|
|
55
|
-
var tagName = output.node ? output.node.type : null;
|
|
56
|
-
return {
|
|
57
|
-
tagName,
|
|
58
|
-
renderRoot,
|
|
59
|
-
rendererContext,
|
|
60
|
-
scopedStores
|
|
61
|
-
};
|
|
15
|
+
export const symbolForRootRuntimeContext = Symbol.for("root.runtimeContext");
|
|
16
|
+
export async function renderUseBrick(useBrick, data, errorBoundary) {
|
|
17
|
+
var _output$node, _output$node2;
|
|
18
|
+
const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext({
|
|
19
|
+
...(useBrick[symbolForRootRuntimeContext] ?? _internalApiGetRuntimeContext()),
|
|
20
|
+
data,
|
|
21
|
+
pendingPermissionsPreCheck: []
|
|
62
22
|
});
|
|
63
|
-
|
|
23
|
+
scopedRuntimeContext.tplStateStoreMap ?? (scopedRuntimeContext.tplStateStoreMap = new Map());
|
|
24
|
+
scopedRuntimeContext.formStateStoreMap ?? (scopedRuntimeContext.formStateStoreMap = new Map());
|
|
25
|
+
const rendererContext = new RendererContext("fragment");
|
|
26
|
+
const renderRoot = {
|
|
27
|
+
tag: RenderTag.ROOT,
|
|
28
|
+
// Will set during `mountUseBrick`
|
|
29
|
+
createPortal: null
|
|
30
|
+
};
|
|
31
|
+
const transform = useBrick.transform;
|
|
32
|
+
const strict = isStrictMode();
|
|
33
|
+
if (transform) {
|
|
34
|
+
warnAboutStrictMode(strict, "`useBrick.transform`", 'please use "properties" instead, check your useBrick:', useBrick);
|
|
35
|
+
}
|
|
36
|
+
const output = await renderBrick(renderRoot, strict && !errorBoundary ? useBrick : {
|
|
37
|
+
errorBoundary,
|
|
38
|
+
...useBrick,
|
|
39
|
+
properties: {
|
|
40
|
+
...useBrick.properties,
|
|
41
|
+
...transform
|
|
42
|
+
}
|
|
43
|
+
}, scopedRuntimeContext, rendererContext, [], {});
|
|
44
|
+
const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
45
|
+
await postAsyncRender(output, scopedRuntimeContext, scopedStores);
|
|
46
|
+
if (((_output$node = output.node) === null || _output$node === void 0 ? void 0 : _output$node.tag) === RenderTag.PLACEHOLDER) {
|
|
47
|
+
throw new Error("The root brick of useBrick cannot be an ignored control node");
|
|
48
|
+
}
|
|
49
|
+
if ((_output$node2 = output.node) !== null && _output$node2 !== void 0 && _output$node2.portal) {
|
|
50
|
+
throw new Error("The root brick of useBrick cannot be a portal brick");
|
|
51
|
+
}
|
|
52
|
+
renderRoot.child = output.node;
|
|
53
|
+
const tagName = output.node ? output.node.type : null;
|
|
54
|
+
return {
|
|
55
|
+
tagName,
|
|
56
|
+
renderRoot,
|
|
57
|
+
rendererContext,
|
|
58
|
+
scopedStores
|
|
59
|
+
};
|
|
64
60
|
}
|
|
65
61
|
export function mountUseBrick(_ref, element) {
|
|
66
|
-
|
|
62
|
+
let {
|
|
67
63
|
renderRoot,
|
|
68
64
|
rendererContext,
|
|
69
65
|
scopedStores
|
|
70
66
|
} = _ref;
|
|
71
|
-
|
|
67
|
+
let portal;
|
|
72
68
|
renderRoot.createPortal = () => {
|
|
73
|
-
|
|
69
|
+
const portalRoot = document.querySelector("#portal-mount-point");
|
|
74
70
|
portal = document.createElement("div");
|
|
75
71
|
portalRoot.appendChild(portal);
|
|
76
72
|
return portal;
|
|
@@ -80,7 +76,7 @@ export function mountUseBrick(_ref, element) {
|
|
|
80
76
|
rendererContext.initializeScrollIntoView();
|
|
81
77
|
rendererContext.initializeMediaChange();
|
|
82
78
|
rendererContext.initializeMessageDispatcher();
|
|
83
|
-
for (
|
|
79
|
+
for (const store of scopedStores) {
|
|
84
80
|
store.mountAsyncData();
|
|
85
81
|
}
|
|
86
82
|
return {
|
|
@@ -88,7 +84,7 @@ export function mountUseBrick(_ref, element) {
|
|
|
88
84
|
};
|
|
89
85
|
}
|
|
90
86
|
export function unmountUseBrick(_ref2, mountResult) {
|
|
91
|
-
|
|
87
|
+
let {
|
|
92
88
|
rendererContext
|
|
93
89
|
} = _ref2;
|
|
94
90
|
// if (mountResult.mainBrick) {
|
|
@@ -107,29 +103,35 @@ export function legacyDoTransform(data, to, options) {
|
|
|
107
103
|
if (options) {
|
|
108
104
|
throw new Error("Legacy doTransform does not support options in v3");
|
|
109
105
|
}
|
|
110
|
-
return computeRealValue(to,
|
|
106
|
+
return computeRealValue(to, {
|
|
107
|
+
..._internalApiGetRuntimeContext(),
|
|
111
108
|
data
|
|
112
|
-
}
|
|
109
|
+
}, {
|
|
113
110
|
noInject: true
|
|
114
111
|
});
|
|
115
112
|
}
|
|
116
113
|
export function updateStoryboard(appId, storyboardPatch) {
|
|
117
|
-
|
|
118
|
-
Object.assign(storyboard,
|
|
119
|
-
|
|
114
|
+
const storyboard = _internalApiGetStoryboardInBootstrapData(appId);
|
|
115
|
+
Object.assign(storyboard, {
|
|
116
|
+
...storyboardPatch,
|
|
117
|
+
meta: {
|
|
118
|
+
// Keep runtime fields such as `injectMenus`
|
|
119
|
+
...storyboard.meta,
|
|
120
|
+
...storyboardPatch.meta
|
|
121
|
+
},
|
|
120
122
|
$$fulfilling: null,
|
|
121
123
|
$$fulfilled: true,
|
|
122
124
|
$$registerCustomTemplateProcessed: false
|
|
123
|
-
})
|
|
125
|
+
});
|
|
124
126
|
registerAppI18n(storyboard);
|
|
125
127
|
}
|
|
126
128
|
export function updateStoryboardByRoute(appId, newRoute) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
const storyboard = _internalApiGetStoryboardInBootstrapData(appId);
|
|
130
|
+
let match = false;
|
|
131
|
+
const getKey = route => `${route.path}.${route.exact}`;
|
|
132
|
+
const replaceRoute = (routes, key) => {
|
|
131
133
|
return routes.map(route => {
|
|
132
|
-
|
|
134
|
+
const routeKey = getKey(route);
|
|
133
135
|
if (route.type === "routes") {
|
|
134
136
|
route.routes = replaceRoute(route.routes, key);
|
|
135
137
|
return route;
|
|
@@ -147,7 +149,7 @@ export function updateStoryboardByRoute(appId, newRoute) {
|
|
|
147
149
|
}
|
|
148
150
|
}
|
|
149
151
|
export function updateStoryboardByTemplate(appId, newTemplate, settings) {
|
|
150
|
-
|
|
152
|
+
const tplName = `${appId}.${newTemplate.name}`;
|
|
151
153
|
// customTemplateRegistry.delete(tplName);
|
|
152
154
|
customTemplates.define(tplName, {
|
|
153
155
|
bricks: newTemplate.bricks,
|
|
@@ -157,12 +159,13 @@ export function updateStoryboardByTemplate(appId, newTemplate, settings) {
|
|
|
157
159
|
updateTemplatePreviewSettings(appId, newTemplate.name, settings);
|
|
158
160
|
}
|
|
159
161
|
export function updateTemplatePreviewSettings(appId, templateId, settings) {
|
|
160
|
-
_updatePreviewSettings(appId,
|
|
161
|
-
brick: templateId
|
|
162
|
-
|
|
162
|
+
_updatePreviewSettings(appId, `\${APP.homepage}/_dev_only_/template-preview/${templateId}`, [{
|
|
163
|
+
brick: templateId,
|
|
164
|
+
...pick(settings, "properties", "events", "lifeCycle", "context", "slots", "children")
|
|
165
|
+
}]);
|
|
163
166
|
}
|
|
164
167
|
function getSnippetPreviewPath(snippetId) {
|
|
165
|
-
return
|
|
168
|
+
return `\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;
|
|
166
169
|
}
|
|
167
170
|
export function updateStoryboardBySnippet(appId, snippetData) {
|
|
168
171
|
var _snippetData$bricks;
|
|
@@ -170,13 +173,13 @@ export function updateStoryboardBySnippet(appId, snippetData) {
|
|
|
170
173
|
brick: "span"
|
|
171
174
|
}], snippetData.context);
|
|
172
175
|
}
|
|
173
|
-
export
|
|
176
|
+
export const updateSnippetPreviewSettings = updateStoryboardBySnippet;
|
|
174
177
|
function _updatePreviewSettings(appId, path, bricks, context) {
|
|
175
|
-
|
|
178
|
+
const {
|
|
176
179
|
routes
|
|
177
180
|
} = _internalApiGetStoryboardInBootstrapData(appId);
|
|
178
|
-
|
|
179
|
-
|
|
181
|
+
const previewRouteIndex = routes.findIndex(route => route.path === path);
|
|
182
|
+
const newPreviewRoute = {
|
|
180
183
|
path,
|
|
181
184
|
bricks,
|
|
182
185
|
context,
|
|
@@ -190,27 +193,29 @@ function _updatePreviewSettings(appId, path, bricks, context) {
|
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
195
|
export function getContextValue(name, _ref3) {
|
|
193
|
-
|
|
196
|
+
let {
|
|
194
197
|
tplStateStoreId
|
|
195
198
|
} = _ref3;
|
|
196
|
-
|
|
199
|
+
const runtimeContext = _internalApiGetRuntimeContext();
|
|
197
200
|
if (tplStateStoreId) {
|
|
198
|
-
|
|
201
|
+
const tplStateStore = getTplStateStore({
|
|
202
|
+
...runtimeContext,
|
|
199
203
|
tplStateStoreId
|
|
200
|
-
}
|
|
204
|
+
}, "STATE");
|
|
201
205
|
return tplStateStore.getValue(name);
|
|
202
206
|
}
|
|
203
207
|
return runtimeContext.ctxStore.getValue(name);
|
|
204
208
|
}
|
|
205
209
|
export function getAllContextValues(_ref4) {
|
|
206
|
-
|
|
210
|
+
let {
|
|
207
211
|
tplStateStoreId
|
|
208
212
|
} = _ref4;
|
|
209
|
-
|
|
213
|
+
const runtimeContext = _internalApiGetRuntimeContext();
|
|
210
214
|
if (tplStateStoreId) {
|
|
211
|
-
|
|
215
|
+
const tplStateStore = getTplStateStore({
|
|
216
|
+
...runtimeContext,
|
|
212
217
|
tplStateStoreId
|
|
213
|
-
}
|
|
218
|
+
}, "STATE");
|
|
214
219
|
return tplStateStore.getAllValues();
|
|
215
220
|
}
|
|
216
221
|
return runtimeContext.ctxStore.getAllValues();
|
|
@@ -228,74 +233,63 @@ export function loadBricks(bricks) {
|
|
|
228
233
|
export function getRenderId() {
|
|
229
234
|
return _internalApiGetRenderId();
|
|
230
235
|
}
|
|
231
|
-
export function getAddedContracts(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
collectUsedContracts
|
|
240
|
-
} = _ref5;
|
|
241
|
-
var storyboard = _internalApiGetStoryboardInBootstrapData(appId);
|
|
242
|
-
var updatedStoryboard;
|
|
236
|
+
export async function getAddedContracts(storyboardPatch, _ref5) {
|
|
237
|
+
let {
|
|
238
|
+
appId,
|
|
239
|
+
updateStoryboardType,
|
|
240
|
+
collectUsedContracts
|
|
241
|
+
} = _ref5;
|
|
242
|
+
const storyboard = _internalApiGetStoryboardInBootstrapData(appId);
|
|
243
|
+
let updatedStoryboard;
|
|
243
244
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
});
|
|
278
|
-
return _getAddedContracts.apply(this, arguments);
|
|
279
|
-
}
|
|
280
|
-
export function debugDataValue(_x6, _x7) {
|
|
281
|
-
return _debugDataValue.apply(this, arguments);
|
|
245
|
+
// 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts
|
|
246
|
+
if (updateStoryboardType === "route") {
|
|
247
|
+
updatedStoryboard = {
|
|
248
|
+
routes: [storyboardPatch]
|
|
249
|
+
};
|
|
250
|
+
} else if (updateStoryboardType === "template") {
|
|
251
|
+
updatedStoryboard = {
|
|
252
|
+
meta: {
|
|
253
|
+
customTemplates: [storyboardPatch]
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
} else if (updateStoryboardType === "snippet") {
|
|
257
|
+
var _storyboard$routes;
|
|
258
|
+
// snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route
|
|
259
|
+
const snippetPreviewPath = getSnippetPreviewPath(storyboardPatch.snippetId);
|
|
260
|
+
const currentRoute = storyboard === null || storyboard === void 0 || (_storyboard$routes = storyboard.routes) === null || _storyboard$routes === void 0 ? void 0 : _storyboard$routes.find(route => route.path === snippetPreviewPath);
|
|
261
|
+
updatedStoryboard = {
|
|
262
|
+
routes: [currentRoute]
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const addedContracts = [];
|
|
266
|
+
if (updatedStoryboard && collectUsedContracts) {
|
|
267
|
+
const contractApis = await collectUsedContracts(updatedStoryboard);
|
|
268
|
+
contractApis.forEach(api => {
|
|
269
|
+
var _storyboard$meta;
|
|
270
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
271
|
+
const [_, namespaceId, name] = api.match(/(.*)@(.*):\d\.\d\.\d/);
|
|
272
|
+
if (!(storyboard !== null && storyboard !== void 0 && (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 && (_storyboard$meta = _storyboard$meta.contracts) !== null && _storyboard$meta !== void 0 && _storyboard$meta.some(contract => contract.namespaceId === namespaceId && contract.name === name))) {
|
|
273
|
+
addedContracts.push(api);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return addedContracts;
|
|
282
278
|
}
|
|
283
|
-
function
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
279
|
+
export async function debugDataValue(debugData, _ref6) {
|
|
280
|
+
let {
|
|
281
|
+
tplStateStoreId
|
|
282
|
+
} = _ref6;
|
|
283
|
+
const runtimeContext = {
|
|
284
|
+
..._internalApiGetRuntimeContext(),
|
|
285
|
+
tplStateStoreId
|
|
286
|
+
};
|
|
287
|
+
if (debugData.resolve) {
|
|
288
|
+
return resolveData(debugData.resolve, runtimeContext, {
|
|
289
|
+
cache: "reload"
|
|
290
290
|
});
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
cache: "reload"
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
return asyncComputeRealValue(debugData.value, runtimeContext);
|
|
297
|
-
});
|
|
298
|
-
return _debugDataValue.apply(this, arguments);
|
|
291
|
+
}
|
|
292
|
+
return asyncComputeRealValue(debugData.value, runtimeContext);
|
|
299
293
|
}
|
|
300
294
|
export { setRealTimeDataInspectRoot, addRealTimeDataInspectHook } from "./data/realTimeDataInspect.js";
|
|
301
295
|
//# sourceMappingURL=secret_internals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["pick","_internalApiGetRenderId","_internalApiGetRuntimeContext","_internalApiGetStoryboardInBootstrapData","getBrickPackages","createScopedRuntimeContext","postAsyncRender","renderBrick","RendererContext","resolveData","asyncComputeRealValue","mountTree","unmountTree","RenderTag","computeRealValue","isStrictMode","warnAboutStrictMode","customTemplates","registerAppI18n","getTplStateStore","loadBricksImperatively","symbolForRootRuntimeContext","Symbol","for","renderUseBrick","_x","_x2","_x3","_renderUseBrick","apply","arguments","_asyncToGenerator","useBrick","data","errorBoundary","_useBrick$symbolForRo","_scopedRuntimeContext","_scopedRuntimeContext2","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","_objectSpread","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","renderRoot","tag","ROOT","createPortal","transform","strict","output","properties","scopedStores","node","PLACEHOLDER","Error","portal","child","tagName","type","mountUseBrick","_ref","element","portalRoot","document","querySelector","createElement","appendChild","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","_ref2","mountResult","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","noInject","updateStoryboard","appId","storyboardPatch","storyboard","Object","assign","meta","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","updateStoryboardByRoute","newRoute","match","getKey","route","concat","path","exact","replaceRoute","routes","key","map","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","_ref3","tplStateStoreId","runtimeContext","tplStateStore","getValue","ctxStore","getAllContextValues","_ref4","getAllValues","getBrickPackagesById","id","find","pkg","filePath","startsWith","loadBricks","getRenderId","getAddedContracts","_x4","_x5","_getAddedContracts","_ref5","updateStoryboardType","collectUsedContracts","updatedStoryboard","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","forEach","api","_storyboard$meta","_","namespaceId","contracts","some","contract","push","debugDataValue","_x6","_x7","_debugDataValue","debugData","_ref6","resolve","cache","value","setRealTimeDataInspectRoot","addRealTimeDataInspectHook"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n RuntimeSnippet,\n ContextConf,\n} from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport {\n createScopedRuntimeContext,\n postAsyncRender,\n renderBrick,\n} from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\n RuntimeContext,\n DebugDataValue,\n} from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport { loadBricksImperatively } from \"@next-core/loader\";\n\nexport type { DataValueOption, RuntimeContext };\n\nexport const symbolForRootRuntimeContext = Symbol.for(\"root.runtimeContext\");\n\nexport interface RuntimeUseBrickConfWithRootSymbols extends UseSingleBrickConf {\n [symbolForRootRuntimeContext]?: RuntimeContext;\n}\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[];\n}\n\nexport async function renderUseBrick(\n useBrick: RuntimeUseBrickConfWithRootSymbols,\n data: unknown,\n errorBoundary?: boolean\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\n ...(useBrick[symbolForRootRuntimeContext] ??\n _internalApiGetRuntimeContext()!),\n data,\n pendingPermissionsPreCheck: [],\n });\n\n scopedRuntimeContext.tplStateStoreMap ??= new Map();\n scopedRuntimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const transform = (useBrick as { transform?: Record<string, unknown> })\n .transform;\n const strict = isStrictMode();\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n useBrick\n );\n }\n\n const output = await renderBrick(\n renderRoot,\n strict && !errorBoundary\n ? useBrick\n : {\n errorBoundary,\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n scopedRuntimeContext,\n rendererContext,\n [],\n {}\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\n\n if (output.node?.tag === RenderTag.PLACEHOLDER) {\n throw new Error(\n \"The root brick of useBrick cannot be an ignored control node\"\n );\n }\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext, scopedStores };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext, scopedStores }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n meta: {\n // Keep runtime fields such as `injectMenus`\n ...storyboard.meta,\n ...storyboardPatch.meta,\n },\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let match = false;\n const getKey = (route: RouteConf): string => `${route.path}.${route.exact}`;\n const replaceRoute = (routes: RouteConf[], key: string): RouteConf[] => {\n return routes.map((route) => {\n const routeKey = getKey(route);\n if (route.type === \"routes\") {\n route.routes = replaceRoute(route.routes, key);\n return route;\n } else if (routeKey === key) {\n match = true;\n return newRoute;\n } else {\n return route;\n }\n });\n };\n storyboard.routes = replaceRoute(storyboard.routes, getKey(newRoute));\n if (!match) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(\n settings,\n \"properties\",\n \"events\",\n \"lifeCycle\",\n \"context\",\n \"slots\",\n \"children\"\n ),\n },\n ]\n );\n}\n\nfunction getSnippetPreviewPath(snippetId: string): string {\n return `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n context?: ContextConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }],\n snippetData.context\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[],\n context?: ContextConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n context,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n\nexport function getContextValue(\n name: string,\n { tplStateStoreId }: DataValueOption\n): unknown {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getValue(name);\n }\n\n return runtimeContext.ctxStore.getValue(name);\n}\n\nexport function getAllContextValues({\n tplStateStoreId,\n}: DataValueOption): Record<string, unknown> {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getAllValues();\n }\n\n return runtimeContext.ctxStore.getAllValues();\n}\n\nexport function getBrickPackagesById(id: string) {\n return getBrickPackages().find((pkg) =>\n pkg.id ? pkg.id === id : pkg.filePath.startsWith(id)\n );\n}\n\n/**\n * Support loading v3 bricks only.\n */\nexport function loadBricks(bricks: string[]) {\n return loadBricksImperatively(bricks, getBrickPackages());\n}\n\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n { appId, updateStoryboardType, collectUsedContracts }: PreviewOption\n): Promise<string[]> {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId);\n let updatedStoryboard;\n\n // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts\n if (updateStoryboardType === \"route\") {\n updatedStoryboard = {\n routes: [storyboardPatch as RouteConf],\n } as Storyboard;\n } else if (updateStoryboardType === \"template\") {\n updatedStoryboard = {\n meta: {\n customTemplates: [storyboardPatch as CustomTemplate],\n },\n } as Storyboard;\n } else if (updateStoryboardType === \"snippet\") {\n // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route\n const snippetPreviewPath = getSnippetPreviewPath(\n (storyboardPatch as RuntimeSnippet).snippetId\n );\n const currentRoute = storyboard?.routes?.find(\n (route) => route.path === snippetPreviewPath\n );\n\n updatedStoryboard = {\n routes: [currentRoute],\n } as Storyboard;\n }\n\n const addedContracts: string[] = [];\n\n if (updatedStoryboard && collectUsedContracts) {\n const contractApis = await collectUsedContracts(updatedStoryboard);\n\n contractApis.forEach((api: string) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, namespaceId, name] = api.match(\n /(.*)@(.*):\\d\\.\\d\\.\\d/\n ) as string[];\n\n if (\n !storyboard?.meta?.contracts?.some(\n (contract) =>\n contract.namespaceId === namespaceId && contract.name === name\n )\n ) {\n addedContracts.push(api);\n }\n });\n }\n\n return addedContracts;\n}\n\nexport async function debugDataValue(\n debugData: DebugDataValue,\n { tplStateStoreId }: DataValueOption\n): Promise<any> {\n const runtimeContext = {\n ..._internalApiGetRuntimeContext()!,\n tplStateStoreId,\n };\n\n if (debugData.resolve) {\n return resolveData(debugData.resolve!, runtimeContext, { cache: \"reload\" });\n }\n\n return asyncComputeRealValue(debugData.value, runtimeContext);\n}\n\nexport {\n setRealTimeDataInspectRoot,\n addRealTimeDataInspectHook,\n} from \"./data/realTimeDataInspect.js\";\n"],"mappings":";;AASA,SAASA,IAAI,QAAQ,QAAQ;AAC7B,SACEC,uBAAuB,EACvBC,6BAA6B,EAC7BC,wCAAwC,EACxCC,gBAAgB,QACX,cAAc;AACrB,SACEC,0BAA0B,EAC1BC,eAAe,EACfC,WAAW,QACN,eAAe;AACtB,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,qBAAqB,QAAQ,+BAA+B;AASrE,SAASC,SAAS,EAAEC,WAAW,QAAQ,YAAY;AACnD,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,oBAAoB;AACtE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,eAAe,QAA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Q,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAAC5D,IAAI,KAAKA,IAC9D,CAAC,GACD;UACAmD,cAAc,CAACU,IAAI,CAACP,GAAG,CAAC;QAC1B;MACF,CAAC,CAAC;IACJ;IAEA,OAAOH,cAAc;EACvB,CAAC;EAAA,OAAAR,kBAAA,CAAAnI,KAAA,OAAAC,SAAA;AAAA;AAED,gBAAsBqJ,cAAcA,CAAAC,GAAA,EAAAC,GAAA;EAAA,OAAAC,eAAA,CAAAzJ,KAAA,OAAAC,SAAA;AAAA;AAcnC,SAAAwJ,gBAAA;EAAAA,eAAA,GAAAvJ,iBAAA,CAdM,WACLwJ,SAAyB,EAAAC,KAAA,EAEX;IAAA,IADd;MAAE3C;IAAiC,CAAC,GAAA2C,KAAA;IAEpC,IAAM1C,cAAc,GAAAnG,aAAA,CAAAA,aAAA,KACfzC,6BAA6B,CAAC,CAAC;MAClC2I;IAAe,EAChB;IAED,IAAI0C,SAAS,CAACE,OAAO,EAAE;MACrB,OAAOhL,WAAW,CAAC8K,SAAS,CAACE,OAAO,EAAG3C,cAAc,EAAE;QAAE4C,KAAK,EAAE;MAAS,CAAC,CAAC;IAC7E;IAEA,OAAOhL,qBAAqB,CAAC6K,SAAS,CAACI,KAAK,EAAE7C,cAAc,CAAC;EAC/D,CAAC;EAAA,OAAAwC,eAAA,CAAAzJ,KAAA,OAAAC,SAAA;AAAA;AAED,SACE8J,0BAA0B,EAC1BC,0BAA0B,QACrB,+BAA+B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"secret_internals.js","names":["pick","_internalApiGetRenderId","_internalApiGetRuntimeContext","_internalApiGetStoryboardInBootstrapData","getBrickPackages","createScopedRuntimeContext","postAsyncRender","renderBrick","RendererContext","resolveData","asyncComputeRealValue","mountTree","unmountTree","RenderTag","computeRealValue","isStrictMode","warnAboutStrictMode","customTemplates","registerAppI18n","getTplStateStore","loadBricksImperatively","symbolForRootRuntimeContext","Symbol","for","renderUseBrick","useBrick","data","errorBoundary","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","renderRoot","tag","ROOT","createPortal","transform","strict","output","properties","scopedStores","node","PLACEHOLDER","Error","portal","child","tagName","type","mountUseBrick","_ref","element","portalRoot","document","querySelector","createElement","appendChild","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","_ref2","mountResult","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","noInject","updateStoryboard","appId","storyboardPatch","storyboard","Object","assign","meta","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","updateStoryboardByRoute","newRoute","match","getKey","route","path","exact","replaceRoute","routes","key","map","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","_ref3","tplStateStoreId","runtimeContext","tplStateStore","getValue","ctxStore","getAllContextValues","_ref4","getAllValues","getBrickPackagesById","id","find","pkg","filePath","startsWith","loadBricks","getRenderId","getAddedContracts","_ref5","updateStoryboardType","collectUsedContracts","updatedStoryboard","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","forEach","api","_storyboard$meta","_","namespaceId","contracts","some","contract","push","debugDataValue","debugData","_ref6","resolve","cache","value","setRealTimeDataInspectRoot","addRealTimeDataInspectHook"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n RuntimeSnippet,\n ContextConf,\n} from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport {\n createScopedRuntimeContext,\n postAsyncRender,\n renderBrick,\n} from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\n RuntimeContext,\n DebugDataValue,\n} from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport { loadBricksImperatively } from \"@next-core/loader\";\n\nexport type { DataValueOption, RuntimeContext };\n\nexport const symbolForRootRuntimeContext = Symbol.for(\"root.runtimeContext\");\n\nexport interface RuntimeUseBrickConfWithRootSymbols extends UseSingleBrickConf {\n [symbolForRootRuntimeContext]?: RuntimeContext;\n}\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[];\n}\n\nexport async function renderUseBrick(\n useBrick: RuntimeUseBrickConfWithRootSymbols,\n data: unknown,\n errorBoundary?: boolean\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\n ...(useBrick[symbolForRootRuntimeContext] ??\n _internalApiGetRuntimeContext()!),\n data,\n pendingPermissionsPreCheck: [],\n });\n\n scopedRuntimeContext.tplStateStoreMap ??= new Map();\n scopedRuntimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const transform = (useBrick as { transform?: Record<string, unknown> })\n .transform;\n const strict = isStrictMode();\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n useBrick\n );\n }\n\n const output = await renderBrick(\n renderRoot,\n strict && !errorBoundary\n ? useBrick\n : {\n errorBoundary,\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n scopedRuntimeContext,\n rendererContext,\n [],\n {}\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\n\n if (output.node?.tag === RenderTag.PLACEHOLDER) {\n throw new Error(\n \"The root brick of useBrick cannot be an ignored control node\"\n );\n }\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext, scopedStores };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext, scopedStores }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n meta: {\n // Keep runtime fields such as `injectMenus`\n ...storyboard.meta,\n ...storyboardPatch.meta,\n },\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let match = false;\n const getKey = (route: RouteConf): string => `${route.path}.${route.exact}`;\n const replaceRoute = (routes: RouteConf[], key: string): RouteConf[] => {\n return routes.map((route) => {\n const routeKey = getKey(route);\n if (route.type === \"routes\") {\n route.routes = replaceRoute(route.routes, key);\n return route;\n } else if (routeKey === key) {\n match = true;\n return newRoute;\n } else {\n return route;\n }\n });\n };\n storyboard.routes = replaceRoute(storyboard.routes, getKey(newRoute));\n if (!match) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(\n settings,\n \"properties\",\n \"events\",\n \"lifeCycle\",\n \"context\",\n \"slots\",\n \"children\"\n ),\n },\n ]\n );\n}\n\nfunction getSnippetPreviewPath(snippetId: string): string {\n return `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n context?: ContextConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }],\n snippetData.context\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[],\n context?: ContextConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n context,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n\nexport function getContextValue(\n name: string,\n { tplStateStoreId }: DataValueOption\n): unknown {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getValue(name);\n }\n\n return runtimeContext.ctxStore.getValue(name);\n}\n\nexport function getAllContextValues({\n tplStateStoreId,\n}: DataValueOption): Record<string, unknown> {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getAllValues();\n }\n\n return runtimeContext.ctxStore.getAllValues();\n}\n\nexport function getBrickPackagesById(id: string) {\n return getBrickPackages().find((pkg) =>\n pkg.id ? pkg.id === id : pkg.filePath.startsWith(id)\n );\n}\n\n/**\n * Support loading v3 bricks only.\n */\nexport function loadBricks(bricks: string[]) {\n return loadBricksImperatively(bricks, getBrickPackages());\n}\n\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n { appId, updateStoryboardType, collectUsedContracts }: PreviewOption\n): Promise<string[]> {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId);\n let updatedStoryboard;\n\n // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts\n if (updateStoryboardType === \"route\") {\n updatedStoryboard = {\n routes: [storyboardPatch as RouteConf],\n } as Storyboard;\n } else if (updateStoryboardType === \"template\") {\n updatedStoryboard = {\n meta: {\n customTemplates: [storyboardPatch as CustomTemplate],\n },\n } as Storyboard;\n } else if (updateStoryboardType === \"snippet\") {\n // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route\n const snippetPreviewPath = getSnippetPreviewPath(\n (storyboardPatch as RuntimeSnippet).snippetId\n );\n const currentRoute = storyboard?.routes?.find(\n (route) => route.path === snippetPreviewPath\n );\n\n updatedStoryboard = {\n routes: [currentRoute],\n } as Storyboard;\n }\n\n const addedContracts: string[] = [];\n\n if (updatedStoryboard && collectUsedContracts) {\n const contractApis = await collectUsedContracts(updatedStoryboard);\n\n contractApis.forEach((api: string) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, namespaceId, name] = api.match(\n /(.*)@(.*):\\d\\.\\d\\.\\d/\n ) as string[];\n\n if (\n !storyboard?.meta?.contracts?.some(\n (contract) =>\n contract.namespaceId === namespaceId && contract.name === name\n )\n ) {\n addedContracts.push(api);\n }\n });\n }\n\n return addedContracts;\n}\n\nexport async function debugDataValue(\n debugData: DebugDataValue,\n { tplStateStoreId }: DataValueOption\n): Promise<any> {\n const runtimeContext = {\n ..._internalApiGetRuntimeContext()!,\n tplStateStoreId,\n };\n\n if (debugData.resolve) {\n return resolveData(debugData.resolve!, runtimeContext, { cache: \"reload\" });\n }\n\n return asyncComputeRealValue(debugData.value, runtimeContext);\n}\n\nexport {\n setRealTimeDataInspectRoot,\n addRealTimeDataInspectHook,\n} from \"./data/realTimeDataInspect.js\";\n"],"mappings":"AASA,SAASA,IAAI,QAAQ,QAAQ;AAC7B,SACEC,uBAAuB,EACvBC,6BAA6B,EAC7BC,wCAAwC,EACxCC,gBAAgB,QACX,cAAc;AACrB,SACEC,0BAA0B,EAC1BC,eAAe,EACfC,WAAW,QACN,eAAe;AACtB,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,qBAAqB,QAAQ,+BAA+B;AASrE,SAASC,SAAS,EAAEC,WAAW,QAAQ,YAAY;AACnD,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,oBAAoB;AACtE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,sBAAsB,QAAQ,mBAAmB;AAI1D,OAAO,MAAMC,2BAA2B,GAAGC,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAa5E,OAAO,eAAeC,cAAcA,CAClCC,QAA4C,EAC5CC,IAAa,EACbC,aAAuB,EACQ;EAAA,IAAAC,YAAA,EAAAC,aAAA;EAC/B,MAAM,CAACC,oBAAoB,EAAEC,kBAAkB,EAAEC,mBAAmB,CAAC,GACnE3B,0BAA0B,CAAC;IACzB,IAAIoB,QAAQ,CAACJ,2BAA2B,CAAC,IACvCnB,6BAA6B,CAAC,CAAE,CAAC;IACnCwB,IAAI;IACJO,0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AA,gBAAAA,gBAAA,GAAhBA,gBAAA,CAAkBG,SAAS,cAAAH,gBAAA,eAA3BA,gBAAA,CAA6BI,IAAI,CAC/BC,QAAQ,IACPA,QAAQ,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAACzD,IAAI,KAAKA,IAC9D,CAAC,GACD;QACAgD,cAAc,CAACU,IAAI,CAACP,GAAG,CAAC;MAC1B;IACF,CAAC,CAAC;EACJ;EAEA,OAAOH,cAAc;AACvB;AAEA,OAAO,eAAeW,cAAcA,CAClCC,SAAyB,EAAAC,KAAA,EAEX;EAAA,IADd;IAAErC;EAAiC,CAAC,GAAAqC,KAAA;EAEpC,MAAMpC,cAAc,GAAG;IACrB,GAAGhI,6BAA6B,CAAC,CAAE;IACnC+H;EACF,CAAC;EAED,IAAIoC,SAAS,CAACE,OAAO,EAAE;IACrB,OAAO9J,WAAW,CAAC4J,SAAS,CAACE,OAAO,EAAGrC,cAAc,EAAE;MAAEsC,KAAK,EAAE;IAAS,CAAC,CAAC;EAC7E;EAEA,OAAO9J,qBAAqB,CAAC2J,SAAS,CAACI,KAAK,EAAEvC,cAAc,CAAC;AAC/D;AAEA,SACEwC,0BAA0B,EAC1BC,0BAA0B,QACrB,+BAA+B","ignoreList":[]}
|
|
@@ -10,7 +10,7 @@ export function setupRootRuntimeContext(bricks, runtimeContext, shallow) {
|
|
|
10
10
|
props.map(walk);
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
for (
|
|
13
|
+
for (const [key, value] of Object.entries(props)) {
|
|
14
14
|
if (isObject(value) && key === "useBrick") {
|
|
15
15
|
if (Array.isArray(value)) {
|
|
16
16
|
value.forEach(v => setupBrick(v, true));
|
|
@@ -32,15 +32,14 @@ export function setupRootRuntimeContext(bricks, runtimeContext, shallow) {
|
|
|
32
32
|
if (shallow && !forceRecursive) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
for (
|
|
37
|
-
for (
|
|
38
|
-
|
|
39
|
-
setupBrick(_brick, inUseBrick);
|
|
35
|
+
const transpiledSlots = childrenToSlots(brick.children, brick.slots);
|
|
36
|
+
for (const slotConf of Object.values(transpiledSlots ?? {})) {
|
|
37
|
+
for (const brick of slotConf.bricks ?? []) {
|
|
38
|
+
setupBrick(brick, inUseBrick);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
|
-
for (
|
|
42
|
+
for (const brick of bricks) {
|
|
44
43
|
setupBrick(brick);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupRootRuntimeContext.js","names":["isObject","symbolForRootRuntimeContext","childrenToSlots","setupRootRuntimeContext","bricks","runtimeContext","shallow","walk","props","Array","isArray","map","key","value","Object","entries","forEach","v","setupBrick","brick","inUseBrick","forceRecursive","properties","transpiledSlots","children","slots","slotConf","values"
|
|
1
|
+
{"version":3,"file":"setupRootRuntimeContext.js","names":["isObject","symbolForRootRuntimeContext","childrenToSlots","setupRootRuntimeContext","bricks","runtimeContext","shallow","walk","props","Array","isArray","map","key","value","Object","entries","forEach","v","setupBrick","brick","inUseBrick","forceRecursive","properties","transpiledSlots","children","slots","slotConf","values"],"sources":["../../../src/internal/setupRootRuntimeContext.ts"],"sourcesContent":["import { isObject } from \"@next-core/utils/general\";\nimport type {\n BrickConf,\n UseBrickSlotsConf,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport {\n RuntimeContext,\n RuntimeUseBrickConfWithRootSymbols,\n symbolForRootRuntimeContext,\n} from \"./secret_internals.js\";\nimport { childrenToSlots } from \"./Renderer.js\";\n\nexport function setupRootRuntimeContext(\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n shallow?: boolean\n) {\n function walk(props: unknown) {\n if (!isObject(props) || typeof props === \"function\") {\n return;\n }\n\n if (Array.isArray(props)) {\n props.map(walk);\n return;\n }\n\n for (const [key, value] of Object.entries(props)) {\n if (isObject(value) && key === \"useBrick\") {\n if (Array.isArray(value)) {\n value.forEach((v) => setupBrick(v, true));\n } else {\n setupBrick(\n value as UseSingleBrickConf as RuntimeUseBrickConfWithRootSymbols,\n true,\n // For inside useBrick, we always need to setup recursively.\n true\n );\n }\n } else {\n walk(value);\n }\n }\n }\n\n function setupBrick(\n brick: BrickConf,\n inUseBrick?: boolean,\n forceRecursive?: boolean\n ) {\n if (inUseBrick) {\n (brick as RuntimeUseBrickConfWithRootSymbols)[\n symbolForRootRuntimeContext\n ] = runtimeContext;\n }\n\n walk(brick.properties);\n\n if (shallow && !forceRecursive) {\n return;\n }\n\n const transpiledSlots = childrenToSlots(brick.children, brick.slots) as\n | UseBrickSlotsConf\n | undefined;\n\n for (const slotConf of Object.values(transpiledSlots ?? {})) {\n for (const brick of slotConf.bricks ?? []) {\n setupBrick(brick, inUseBrick);\n }\n }\n }\n\n for (const brick of bricks) {\n setupBrick(brick);\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,0BAA0B;AAMnD,SAGEC,2BAA2B,QACtB,uBAAuB;AAC9B,SAASC,eAAe,QAAQ,eAAe;AAE/C,OAAO,SAASC,uBAAuBA,CACrCC,MAAmB,EACnBC,cAA8B,EAC9BC,OAAiB,EACjB;EACA,SAASC,IAAIA,CAACC,KAAc,EAAE;IAC5B,IAAI,CAACR,QAAQ,CAACQ,KAAK,CAAC,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MACnD;IACF;IAEA,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACxBA,KAAK,CAACG,GAAG,CAACJ,IAAI,CAAC;MACf;IACF;IAEA,KAAK,MAAM,CAACK,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACP,KAAK,CAAC,EAAE;MAChD,IAAIR,QAAQ,CAACa,KAAK,CAAC,IAAID,GAAG,KAAK,UAAU,EAAE;QACzC,IAAIH,KAAK,CAACC,OAAO,CAACG,KAAK,CAAC,EAAE;UACxBA,KAAK,CAACG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