@next-core/runtime 1.22.4 → 1.22.6
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/index.js.map +1 -1
- package/dist/cjs/internal/Renderer.js +26 -22
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js +36 -7
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/Router.js +19 -8
- package/dist/cjs/internal/Router.js.map +1 -1
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/cjs/internal/enums.js +1 -0
- package/dist/cjs/internal/enums.js.map +1 -1
- package/dist/cjs/internal/interfaces.js.map +1 -1
- package/dist/cjs/internal/mount.js +41 -39
- package/dist/cjs/internal/mount.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js +5 -2
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/Renderer.js +47 -38
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/esm/internal/RendererContext.js +36 -7
- package/dist/esm/internal/RendererContext.js.map +1 -1
- package/dist/esm/internal/Router.js +19 -7
- package/dist/esm/internal/Router.js.map +1 -1
- package/dist/esm/internal/Runtime.js.map +1 -1
- package/dist/esm/internal/enums.js +1 -0
- package/dist/esm/internal/enums.js.map +1 -1
- package/dist/esm/internal/interfaces.js.map +1 -1
- package/dist/esm/internal/mount.js +41 -39
- package/dist/esm/internal/mount.js.map +1 -1
- package/dist/esm/internal/secret_internals.js +5 -2
- package/dist/esm/internal/secret_internals.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/Renderer.d.ts +6 -5
- package/dist/types/internal/RendererContext.d.ts +5 -5
- package/dist/types/internal/Runtime.d.ts +8 -0
- package/dist/types/internal/enums.d.ts +2 -1
- package/dist/types/internal/interfaces.d.ts +11 -5
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","names":[],"sources":["../../../src/internal/interfaces.ts"],"sourcesContent":["import type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport type {\n BrickEventHandler,\n BrickEventsMap,\n CustomTemplate,\n RouteConf,\n RuntimeSnippet,\n CustomTemplateProxy,\n CustomTemplateProxyBasicProperty,\n CustomTemplateProxySlot,\n SlotsConfOfBricks,\n} from \"@next-core/types\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { RuntimeBrickConfOfFormSymbols } from \"./FormRenderer/constants.js\";\n\nexport interface RuntimeContext extends LegacyCompatibleRuntimeContext {\n ctxStore: DataStore<\"CTX\">;\n tplStateStoreMap: Map<string, DataStore<\"STATE\">>;\n pendingPermissionsPreCheck: (Promise<unknown> | undefined)[];\n tplStateStoreId?: string;\n // `useBrick` has a local tpl state store scope\n tplStateStoreScope?: DataStore<\"STATE\">[];\n forEachItem?: unknown;\n forEachIndex?: number;\n appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncPropertyEntry = [\n name: string,\n value: Promise<unknown>,\n ignoreUndefined?: boolean,\n];\n\nexport interface ElementHolder {\n element?: HTMLElement | null;\n}\n\nexport interface RenderRoot extends BaseRenderNode {\n tag: RenderTag.ROOT;\n container?: HTMLElement | DocumentFragment;\n createPortal:\n | HTMLElement\n | DocumentFragment\n | (() => HTMLElement | DocumentFragment);\n}\n\nexport interface RenderBrick extends BaseRenderNode, RuntimeBrick {\n tag: RenderTag.BRICK;\n return:
|
|
1
|
+
{"version":3,"file":"interfaces.js","names":[],"sources":["../../../src/internal/interfaces.ts"],"sourcesContent":["import type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport type {\n BrickEventHandler,\n BrickEventsMap,\n CustomTemplate,\n RouteConf,\n RuntimeSnippet,\n CustomTemplateProxy,\n CustomTemplateProxyBasicProperty,\n CustomTemplateProxySlot,\n SlotsConfOfBricks,\n} from \"@next-core/types\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { RuntimeBrickConfOfFormSymbols } from \"./FormRenderer/constants.js\";\n\nexport interface RuntimeContext extends LegacyCompatibleRuntimeContext {\n ctxStore: DataStore<\"CTX\">;\n tplStateStoreMap: Map<string, DataStore<\"STATE\">>;\n pendingPermissionsPreCheck: (Promise<unknown> | undefined)[];\n tplStateStoreId?: string;\n // `useBrick` has a local tpl state store scope\n tplStateStoreScope?: DataStore<\"STATE\">[];\n forEachItem?: unknown;\n forEachIndex?: number;\n appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncPropertyEntry = [\n name: string,\n value: Promise<unknown>,\n ignoreUndefined?: boolean,\n];\n\nexport interface ElementHolder {\n element?: HTMLElement | null;\n}\n\nexport interface RenderRoot extends BaseRenderNode {\n tag: RenderTag.ROOT;\n container?: HTMLElement | DocumentFragment;\n createPortal:\n | HTMLElement\n | DocumentFragment\n | (() => HTMLElement | DocumentFragment);\n}\n\nexport interface RenderBrick extends BaseRenderNode, RuntimeBrick {\n tag: RenderTag.BRICK;\n return: RenderReturnNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface RenderPlaceholder extends BaseRenderNode {\n tag: RenderTag.PLACEHOLDER;\n return: RenderReturnNode;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderChildNode;\n sibling?: RenderChildNode;\n return?: RenderReturnNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = RenderRoot | RenderBrick | RenderPlaceholder;\n\nexport type RenderChildNode = RenderBrick | RenderPlaceholder;\nexport type RenderReturnNode = RenderRoot | RenderBrick;\n\nexport interface RuntimeBrick {\n type: string;\n properties?: Record<string, unknown>;\n events?: BrickEventsMap;\n slotId?: string;\n element?: RuntimeBrickElement | null;\n iid?: string;\n runtimeContext: RuntimeContext;\n tplHostMetadata?: TemplateHostMetadata;\n portal?: boolean;\n ref?: string;\n}\n\nexport type MetaInfoOfEventListener = [\n string,\n // For compatibility of devtools, leave the second argument there.\n null | undefined,\n BrickEventHandler,\n];\n\nexport type RememberedEventListener = [string, EventListener];\n\nexport interface RuntimeBrickElement extends HTMLElement {\n $$typeof?: \"brick\" | \"provider\" | \"custom-template\" | \"native\" | \"invalid\";\n /** Meta info of listeners, for devtools only */\n $$eventListeners?: MetaInfoOfEventListener[];\n /** Remembered listeners for unbinding */\n $$listeners?: RememberedEventListener[];\n /** Remembered proxy listeners for unbinding */\n $$proxyListeners?: RememberedEventListener[];\n /** Find element by ref in a custom template */\n $$getElementByRef?: (ref: string) => HTMLElement | null | undefined;\n $$tplStateStore?: DataStore<\"STATE\">;\n}\n\nexport interface TemplateHostMetadata {\n internalBricksByRef: Map<string, RuntimeBrick>;\n tplStateStoreId: string;\n proxy?: CustomTemplateProxy;\n}\n\nexport type TemplateHostBrick = RuntimeBrick & {\n tplHostMetadata: TemplateHostMetadata;\n};\n\nexport interface TemplateHostContext {\n reversedProxies: ReversedProxies;\n asyncHostPropertyEntries: AsyncPropertyEntry[];\n externalSlots?: SlotsConfOfBricks;\n tplStateStoreId: string;\n hostBrick: TemplateHostBrick;\n}\n\ninterface ReversedProxies {\n properties: Map<string, ReversedPropertyProxy[]>;\n slots: Map<string, ReversedSlotProxy[]>;\n}\n\ninterface ReversedPropertyProxy {\n from: string;\n to: CustomTemplateProxyBasicProperty;\n}\n\ninterface ReversedSlotProxy {\n from: string;\n to: CustomTemplateProxySlot;\n}\n\nexport type RuntimeBrickConfWithSymbols = RuntimeBrickConfWithTplSymbols &\n RuntimeBrickConfOfFormSymbols;\n\nexport interface DataValueOption {\n tplStateStoreId?: string;\n}\n\nexport type PreviewStoryboardPatch =\n | CustomTemplate\n | RouteConf\n | RuntimeSnippet;\n\nexport interface PreviewOption {\n appId: string;\n formId?: string;\n updateStoryboardType?: \"route\" | \"template\" | \"snippet\";\n provider?: string;\n}\n"],"mappings":""}
|
|
@@ -17,47 +17,49 @@ function mountTree(root, initializedElement) {
|
|
|
17
17
|
let current = root.child;
|
|
18
18
|
const portalElements = [];
|
|
19
19
|
while (current) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (current.tag === _enums.RenderTag.BRICK) {
|
|
21
|
+
var _current$tplHostMetad;
|
|
22
|
+
const tagName = current.type;
|
|
23
|
+
if (tagName.includes("-") && !customElements.get(tagName)) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error(`Undefined custom element: ${tagName}`);
|
|
26
|
+
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
28
|
+
// istanbul ignore if
|
|
29
|
+
if (tagName === "basic-bricks.script-brick") {
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.warn("`basic-bricks.script-brick` is deprecated, please take caution when using it");
|
|
32
|
+
}
|
|
33
|
+
const element = initializedElement && current === root.child ? initializedElement : document.createElement(tagName);
|
|
34
|
+
current.element = element;
|
|
35
|
+
if (current.slotId) {
|
|
36
|
+
element.setAttribute("slot", current.slotId);
|
|
37
|
+
}
|
|
38
|
+
if (current.iid) {
|
|
39
|
+
element.dataset.iid = current.iid;
|
|
40
|
+
}
|
|
41
|
+
if ((_current$tplHostMetad = current.tplHostMetadata) !== null && _current$tplHostMetad !== void 0 && _current$tplHostMetad.tplStateStoreId) {
|
|
42
|
+
element.dataset.tplStateStoreId = current.tplHostMetadata.tplStateStoreId;
|
|
43
|
+
}
|
|
44
|
+
(0, _setRealProperties.setRealProperties)(element, current.properties);
|
|
45
|
+
(0, _bindListeners.bindListeners)(element, current.events, current.runtimeContext);
|
|
46
|
+
if (current.tplHostMetadata) {
|
|
47
|
+
// 先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,
|
|
48
|
+
// 避免初始化的一次 state update 操作及其 onChange 事件。
|
|
49
|
+
element.$$tplStateStore = (0, _utils.getTplStateStore)({
|
|
50
|
+
tplStateStoreId: current.tplHostMetadata.tplStateStoreId,
|
|
51
|
+
tplStateStoreMap: current.runtimeContext.tplStateStoreMap
|
|
52
|
+
}, "mount");
|
|
53
|
+
}
|
|
54
|
+
(0, _bindTemplateProxy.bindTemplateProxy)(current);
|
|
55
|
+
if (current.portal) {
|
|
56
|
+
portalElements.push(element);
|
|
57
|
+
} else if (current.return) {
|
|
58
|
+
if (!current.return.childElements) {
|
|
59
|
+
current.return.childElements = [];
|
|
60
|
+
}
|
|
61
|
+
current.return.childElements.push(element);
|
|
59
62
|
}
|
|
60
|
-
current.return.childElements.push(element);
|
|
61
63
|
}
|
|
62
64
|
if (current.child) {
|
|
63
65
|
current = current.child;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","names":["_bindTemplateProxy","require","_utils","_bindListeners","_setRealProperties","_enums","unmountTree","mountPoint","replaceChildren","mountTree","root","initializedElement","current","child","portalElements","_current$tplHostMetad","tagName","type","includes","customElements","get","console","error","warn","element","document","createElement","slotId","setAttribute","iid","dataset","tplHostMetadata","tplStateStoreId","setRealProperties","properties","bindListeners","events","runtimeContext","$$tplStateStore","getTplStateStore","tplStateStoreMap","bindTemplateProxy","portal","push","return","childElements","sibling","_currentReturn","currentReturn","
|
|
1
|
+
{"version":3,"file":"mount.js","names":["_bindTemplateProxy","require","_utils","_bindListeners","_setRealProperties","_enums","unmountTree","mountPoint","replaceChildren","mountTree","root","initializedElement","current","child","portalElements","tag","RenderTag","BRICK","_current$tplHostMetad","tagName","type","includes","customElements","get","console","error","warn","element","document","createElement","slotId","setAttribute","iid","dataset","tplHostMetadata","tplStateStoreId","setRealProperties","properties","bindListeners","events","runtimeContext","$$tplStateStore","getTplStateStore","tplStateStoreMap","bindTemplateProxy","portal","push","return","childElements","sibling","_currentReturn","currentReturn","ROOT","_currentReturn$contai","container","append","undefined","length","createPortal"],"sources":["../../../src/internal/mount.ts"],"sourcesContent":["import { bindTemplateProxy } from \"./CustomTemplates/bindTemplateProxy.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport { bindListeners } from \"./bindListeners.js\";\nimport { setRealProperties } from \"./compute/setRealProperties.js\";\nimport { RenderTag } from \"./enums.js\";\nimport type {\n RenderReturnNode,\n RenderRoot,\n RuntimeBrickElement,\n} from \"./interfaces.js\";\n\nexport function unmountTree(mountPoint: HTMLElement | DocumentFragment) {\n mountPoint.replaceChildren();\n}\n\nexport function mountTree(\n root: RenderRoot,\n initializedElement?: RuntimeBrickElement\n): void {\n let current = root.child;\n const portalElements: RuntimeBrickElement[] = [];\n while (current) {\n if (current.tag === RenderTag.BRICK) {\n const tagName = current.type;\n\n if (tagName.includes(\"-\") && !customElements.get(tagName)) {\n // eslint-disable-next-line no-console\n console.error(`Undefined custom element: ${tagName}`);\n }\n\n // istanbul ignore if\n if (tagName === \"basic-bricks.script-brick\") {\n // eslint-disable-next-line no-console\n console.warn(\n \"`basic-bricks.script-brick` is deprecated, please take caution when using it\"\n );\n }\n\n const element: RuntimeBrickElement =\n initializedElement && current === root.child\n ? initializedElement\n : document.createElement(tagName);\n current.element = element;\n\n if (current.slotId) {\n element.setAttribute(\"slot\", current.slotId);\n }\n if (current.iid) {\n element.dataset.iid = current.iid;\n }\n if (current.tplHostMetadata?.tplStateStoreId) {\n element.dataset.tplStateStoreId =\n current.tplHostMetadata.tplStateStoreId;\n }\n setRealProperties(element, current.properties);\n bindListeners(element, current.events, current.runtimeContext);\n if (current.tplHostMetadata) {\n // 先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n element.$$tplStateStore = getTplStateStore(\n {\n tplStateStoreId: current.tplHostMetadata.tplStateStoreId,\n tplStateStoreMap: current.runtimeContext.tplStateStoreMap,\n },\n \"mount\"\n );\n }\n bindTemplateProxy(current);\n\n if (current.portal) {\n portalElements.push(element);\n } else if (current.return) {\n if (!current.return.childElements) {\n current.return.childElements = [];\n }\n current.return.childElements.push(element);\n }\n }\n\n if (current.child) {\n current = current.child;\n } else if (current.sibling) {\n current = current.sibling;\n } else {\n let currentReturn: RenderReturnNode | null | undefined = current.return;\n while (currentReturn) {\n // Append elements inside out\n if (currentReturn.childElements) {\n if (currentReturn.tag === RenderTag.ROOT) {\n currentReturn.container?.append(...currentReturn.childElements);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n currentReturn.element!.append(...currentReturn.childElements);\n }\n currentReturn.childElements = undefined;\n }\n\n if (currentReturn.tag === RenderTag.ROOT && portalElements.length > 0) {\n const portal =\n typeof currentReturn.createPortal === \"function\"\n ? currentReturn.createPortal()\n : currentReturn.createPortal;\n portal.append(...portalElements);\n }\n\n if (currentReturn.sibling) {\n break;\n }\n currentReturn = currentReturn.return;\n }\n current = currentReturn?.sibling;\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAA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AA,GAAAF,aAAa,CAACG,SAAS,cAAAD,qBAAA,eAAvBA,qBAAA,CAAyBE,MAAM,CAAC,GAAGJ,aAAa,CAACH,aAAa,CAAC;UACjE,CAAC,MAAM;YACL;YACAG,aAAa,CAACxB,OAAO,CAAE4B,MAAM,CAAC,GAAGJ,aAAa,CAACH,aAAa,CAAC;UAC/D;UACAG,aAAa,CAACH,aAAa,GAAGQ,SAAS;QACzC;QAEA,IAAIL,aAAa,CAACpC,GAAG,KAAKC,gBAAS,CAACoC,IAAI,IAAItC,cAAc,CAAC2C,MAAM,GAAG,CAAC,EAAE;UACrE,MAAMZ,MAAM,GACV,OAAOM,aAAa,CAACO,YAAY,KAAK,UAAU,GAC5CP,aAAa,CAACO,YAAY,CAAC,CAAC,GAC5BP,aAAa,CAACO,YAAY;UAChCb,MAAM,CAACU,MAAM,CAAC,GAAGzC,cAAc,CAAC;QAClC;QAEA,IAAIqC,aAAa,CAACF,OAAO,EAAE;UACzB;QACF;QACAE,aAAa,GAAGA,aAAa,CAACJ,MAAM;MACtC;MACAnC,OAAO,IAAAsC,cAAA,GAAGC,aAAa,cAAAD,cAAA,uBAAbA,cAAA,CAAeD,OAAO;IAClC;EACF;AACF"}
|
|
@@ -31,7 +31,7 @@ var _CustomTemplates = require("../CustomTemplates.js");
|
|
|
31
31
|
var _registerAppI18n = require("./registerAppI18n.js");
|
|
32
32
|
var _utils = require("./CustomTemplates/utils.js");
|
|
33
33
|
async function renderUseBrick(useBrick, data) {
|
|
34
|
-
var _scopedRuntimeContext, _scopedRuntimeContext2, _output$node;
|
|
34
|
+
var _scopedRuntimeContext, _scopedRuntimeContext2, _output$node, _output$node2;
|
|
35
35
|
const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = (0, _Renderer.createScopedRuntimeContext)({
|
|
36
36
|
...(0, _Runtime._internalApiGetRuntimeContext)(),
|
|
37
37
|
data,
|
|
@@ -59,7 +59,10 @@ async function renderUseBrick(useBrick, data) {
|
|
|
59
59
|
}, scopedRuntimeContext, rendererContext, []);
|
|
60
60
|
const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
61
61
|
await (0, _Renderer.postAsyncRender)(output, scopedRuntimeContext, scopedStores);
|
|
62
|
-
if ((_output$node = output.node)
|
|
62
|
+
if (((_output$node = output.node) === null || _output$node === void 0 ? void 0 : _output$node.tag) === _enums.RenderTag.PLACEHOLDER) {
|
|
63
|
+
throw new Error("The root brick of useBrick cannot be an ignored control node");
|
|
64
|
+
}
|
|
65
|
+
if ((_output$node2 = output.node) !== null && _output$node2 !== void 0 && _output$node2.portal) {
|
|
63
66
|
throw new Error("The root brick of useBrick cannot be a portal brick");
|
|
64
67
|
}
|
|
65
68
|
renderRoot.child = output.node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["_loader","require","_lodash","_Runtime","_Renderer","_RendererContext","_mount","_enums","_computeRealValue","_isStrictMode","_CustomTemplates","_registerAppI18n","_utils","renderUseBrick","useBrick","data","_scopedRuntimeContext","_scopedRuntimeContext2","_output$node","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","_internalApiGetRuntimeContext","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","RendererContext","renderRoot","tag","RenderTag","ROOT","createPortal","transform","strict","isStrictMode","warnAboutStrictMode","output","renderBrick","properties","scopedStores","postAsyncRender","node","portal","Error","child","tagName","type","mountUseBrick","element","portalRoot","document","querySelector","createElement","appendChild","mountTree","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","mountResult","unmountTree","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","computeRealValue","noInject","updateStoryboard","appId","storyboardPatch","storyboard","_internalApiGetStoryboardInBootstrapData","Object","assign","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","registerAppI18n","updateStoryboardByRoute","newRoute","match","getKey","route","path","exact","replaceRoute","routes","key","map","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","customTemplates","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","pick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","exports","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","tplStateStoreId","runtimeContext","tplStateStore","getTplStateStore","getValue","ctxStore","getAllContextValues","getAllValues","getBrickPackagesById","id","getBrickPackages","find","pkg","filePath","startsWith","getRenderId","_internalApiGetRenderId","getAddedContracts","updateStoryboardType","provider","collectContractProvider","updatedStoryboard","meta","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","loadBricksImperatively","contractApis","resolve","forEach","api","_storyboard$meta","_","namespaceId","contracts","some","contract","push"],"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 { loadBricksImperatively } from \"@next-core/loader\";\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 type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\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\";\n\nexport type { DataValueOption, RuntimeContext } from \"./interfaces.js\";\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: UseSingleBrickConf,\n data: unknown\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\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\n ? useBrick\n : {\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n scopedRuntimeContext,\n rendererContext,\n []\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\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 $$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(settings, \"properties\", \"events\", \"lifeCycle\", \"context\"),\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\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n {\n appId,\n updateStoryboardType,\n provider: collectContractProvider,\n }: 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 && collectContractProvider) {\n await loadBricksImperatively([collectContractProvider], getBrickPackages());\n\n const provider = document.createElement(collectContractProvider) as any;\n const contractApis = await provider.resolve(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"],"mappings":";;;;;;;;;;;;;;;;;;;;AASA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,gBAAA,GAAAJ,OAAA;AAQA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAWO,eAAeY,cAAcA,CAClCC,QAA4B,EAC5BC,IAAa,EACkB;EAAA,IAAAC,qBAAA,EAAAC,sBAAA,EAAAC,YAAA;EAC/B,MAAM,CAACC,oBAAoB,EAAEC,kBAAkB,EAAEC,mBAAmB,CAAC,GACnE,IAAAC,oCAA0B,EAAC;IACzB,GAAG,IAAAC,sCAA6B,EAAC,CAAE;IACnCR,IAAI;IACJS,0BAA0B,EAAE;EAC9B,CAAC,CAAC;EAEJ,CAAAR,qBAAA,GAAAG,oBAAoB,CAACM,gBAAgB,cAAAT,qBAAA,cAAAA,qBAAA,GAArCG,oBAAoB,CAACM,gBAAgB,GAAK,IAAIC,GAAG,CAAC,CAAC;EACnD,CAAAT,sBAAA,GAAAE,oBAAoB,CAACQ,iBAAiB,cAAAV,sBAAA,cAAAA,sBAAA,GAAtCE,oBAAoB,CAACQ,iBAAiB,GAAK,IAAID,GAAG,CAAC,CAAC;EAEpD,MAAME,eAAe,GAAG,IAAIC,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EAEA,MAAMC,cAAwB,GAAG,EAAE;EAEnC,IAAIL,iBAAiB,IAAID,uBAAuB,EAAE;IAChD,MAAM,IAAAO,8BAAsB,EAAC,CAACP,uBAAuB,CAAC,EAAE,IAAAV,yBAAgB,EAAC,CAAC,CAAC;IAE3E,MAAMS,QAAQ,GAAG/F,QAAQ,CAACE,aAAa,CAAC8F,uBAAuB,CAAQ;IACvE,MAAMQ,YAAY,GAAG,MAAMT,QAAQ,CAACU,OAAO,CAACR,iBAAiB,CAAC;IAE9DO,YAAY,CAACE,OAAO,CAAEC,GAAW,IAAK;MAAA,IAAAC,gBAAA;MACpC;MACA,MAAM,CAACC,CAAC,EAAEC,WAAW,EAAE5D,IAAI,CAAC,GAAGyD,GAAG,CAACxE,KAAK,CACtC,sBACF,CAAa;MAEb,IACE,EAACV,UAAU,aAAVA,UAAU,gBAAAmF,gBAAA,GAAVnF,UAAU,CAAEyE,IAAI,cAAAU,gBAAA,gBAAAA,gBAAA,GAAhBA,gBAAA,CAAkBG,SAAS,cAAAH,gBAAA,eAA3BA,gBAAA,CAA6BI,IAAI,CAC/BC,QAAQ,IACPA,QAAQ,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAAC/D,IAAI,KAAKA,IAC9D,CAAC,GACD;QACAoD,cAAc,CAACY,IAAI,CAACP,GAAG,CAAC;MAC1B;IACF,CAAC,CAAC;EACJ;EAEA,OAAOL,cAAc;AACvB"}
|
|
1
|
+
{"version":3,"file":"secret_internals.js","names":["_loader","require","_lodash","_Runtime","_Renderer","_RendererContext","_mount","_enums","_computeRealValue","_isStrictMode","_CustomTemplates","_registerAppI18n","_utils","renderUseBrick","useBrick","data","_scopedRuntimeContext","_scopedRuntimeContext2","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","_internalApiGetRuntimeContext","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","RendererContext","renderRoot","tag","RenderTag","ROOT","createPortal","transform","strict","isStrictMode","warnAboutStrictMode","output","renderBrick","properties","scopedStores","postAsyncRender","node","PLACEHOLDER","Error","portal","child","tagName","type","mountUseBrick","element","portalRoot","document","querySelector","createElement","appendChild","mountTree","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","mountResult","unmountTree","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","computeRealValue","noInject","updateStoryboard","appId","storyboardPatch","storyboard","_internalApiGetStoryboardInBootstrapData","Object","assign","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","registerAppI18n","updateStoryboardByRoute","newRoute","match","getKey","route","path","exact","replaceRoute","routes","key","map","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","customTemplates","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","pick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","exports","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","tplStateStoreId","runtimeContext","tplStateStore","getTplStateStore","getValue","ctxStore","getAllContextValues","getAllValues","getBrickPackagesById","id","getBrickPackages","find","pkg","filePath","startsWith","getRenderId","_internalApiGetRenderId","getAddedContracts","updateStoryboardType","provider","collectContractProvider","updatedStoryboard","meta","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","loadBricksImperatively","contractApis","resolve","forEach","api","_storyboard$meta","_","namespaceId","contracts","some","contract","push"],"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 { loadBricksImperatively } from \"@next-core/loader\";\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 type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\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\";\n\nexport type { DataValueOption, RuntimeContext } from \"./interfaces.js\";\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: UseSingleBrickConf,\n data: unknown\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\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\n ? useBrick\n : {\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n scopedRuntimeContext,\n rendererContext,\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 $$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(settings, \"properties\", \"events\", \"lifeCycle\", \"context\"),\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\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n {\n appId,\n updateStoryboardType,\n provider: collectContractProvider,\n }: 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 && collectContractProvider) {\n await loadBricksImperatively([collectContractProvider], getBrickPackages());\n\n const provider = document.createElement(collectContractProvider) as any;\n const contractApis = await provider.resolve(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"],"mappings":";;;;;;;;;;;;;;;;;;;;AASA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,gBAAA,GAAAJ,OAAA;AAQA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAWO,eAAeY,cAAcA,CAClCC,QAA4B,EAC5BC,IAAa,EACkB;EAAA,IAAAC,qBAAA,EAAAC,sBAAA,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AAmF,gBAAA,GAAVnF,UAAU,CAAEyE,IAAI,cAAAU,gBAAA,gBAAAA,gBAAA,GAAhBA,gBAAA,CAAkBG,SAAS,cAAAH,gBAAA,eAA3BA,gBAAA,CAA6BI,IAAI,CAC/BC,QAAQ,IACPA,QAAQ,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAAC/D,IAAI,KAAKA,IAC9D,CAAC,GACD;QACAoD,cAAc,CAACY,IAAI,CAACP,GAAG,CAAC;MAC1B;IACF,CAAC,CAAC;EACJ;EAEA,OAAOL,cAAc;AACvB"}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createRuntime","getRuntime","__secret_internals","__test_only","getCssPropertyValue","getCurrentTheme","getCurrentMode","batchSetAppsLocalTheme","applyTheme","checkIfOfComputed","checkIfByTransform","registerWidgetFunctions","registerWidgetI18n","StoryboardFunctionRegistryFactory","matchPath","Notification","Dialog"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport * from \"./createRoot.js\";\nexport {\n createRuntime,\n getRuntime,\n type RuntimeOptions,\n type RuntimeHooks,\n type RuntimeHooksMenuHelpers,\n type ImagesFactory,\n} from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport { __test_only } from \"./internal/test_only.js\";\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,SACEA,aAAa,EACbC,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","names":["createRuntime","getRuntime","__secret_internals","__test_only","getCssPropertyValue","getCurrentTheme","getCurrentMode","batchSetAppsLocalTheme","applyTheme","checkIfOfComputed","checkIfByTransform","registerWidgetFunctions","registerWidgetI18n","StoryboardFunctionRegistryFactory","matchPath","Notification","Dialog"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport * from \"./createRoot.js\";\nexport {\n createRuntime,\n getRuntime,\n type RuntimeOptions,\n type RuntimeHooks,\n type RuntimeHooksMenuHelpers,\n type ImagesFactory,\n type PageViewInfo,\n} from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport { __test_only } from \"./internal/test_only.js\";\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,SACEA,aAAa,EACbC,UAAU,QAML,uBAAuB;AAC9B,OAAO,KAAKC,kBAAkB,MAAM,gCAAgC;AACpE,SAASA,kBAAkB;AAC3B,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SACEC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,mBAAmB;AAC1B,SACEC,iBAAiB,EACjBC,kBAAkB,QACb,+BAA+B;AACtC,SAASC,uBAAuB,QAAQ,uCAAuC;AAC/E,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,iCAAiC,QAAQ,iCAAiC;AACnF,SAASC,SAAS,QAAQ,yBAAyB;AACnD,SAASC,YAAY,QAAkC,mBAAmB;AAC1E,SAASC,MAAM,QAA4B,aAAa"}
|
|
@@ -37,10 +37,7 @@ export function renderRoutes(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
|
|
|
37
37
|
function _renderRoutes() {
|
|
38
38
|
_renderRoutes = _asyncToGenerator(function* (returnNode, routes, _runtimeContext, rendererContext, parentRoutes, slotId, isIncremental) {
|
|
39
39
|
var matched = yield matchRoutes(routes, _runtimeContext);
|
|
40
|
-
var output =
|
|
41
|
-
blockingList: [],
|
|
42
|
-
menuRequests: []
|
|
43
|
-
};
|
|
40
|
+
var output = getEmptyRenderOutput();
|
|
44
41
|
switch (matched) {
|
|
45
42
|
case "missed":
|
|
46
43
|
break;
|
|
@@ -51,6 +48,7 @@ function _renderRoutes() {
|
|
|
51
48
|
{
|
|
52
49
|
var _hooks$checkPermissio;
|
|
53
50
|
var route = output.route = matched.route;
|
|
51
|
+
output.path = matched.match.path;
|
|
54
52
|
var runtimeContext = _objectSpread(_objectSpread({}, _runtimeContext), {}, {
|
|
55
53
|
match: matched.match
|
|
56
54
|
});
|
|
@@ -114,10 +112,7 @@ export function renderBricks(_x8, _x9, _x10, _x11, _x12, _x13, _x14, _x15) {
|
|
|
114
112
|
}
|
|
115
113
|
function _renderBricks() {
|
|
116
114
|
_renderBricks = _asyncToGenerator(function* (returnNode, bricks, runtimeContext, rendererContext, parentRoutes, slotId, tplStack, keyPath) {
|
|
117
|
-
var output =
|
|
118
|
-
blockingList: [],
|
|
119
|
-
menuRequests: []
|
|
120
|
-
};
|
|
115
|
+
var output = getEmptyRenderOutput();
|
|
121
116
|
var kPath = keyPath !== null && keyPath !== void 0 ? keyPath : [];
|
|
122
117
|
// 多个构件并行异步转换,但转换的结果按原顺序串行合并。
|
|
123
118
|
var rendered = yield Promise.all(bricks.map((brickConf, index) => renderBrick(returnNode, brickConf, runtimeContext, rendererContext, parentRoutes, slotId, kPath.concat(index), tplStack && new Map(tplStack))));
|
|
@@ -140,10 +135,7 @@ function _renderBrick() {
|
|
|
140
135
|
var _hooks$checkPermissio2, _runtimeContext$app;
|
|
141
136
|
var keyPath = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [];
|
|
142
137
|
var tplStack = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : new Map();
|
|
143
|
-
var output =
|
|
144
|
-
blockingList: [],
|
|
145
|
-
menuRequests: []
|
|
146
|
-
};
|
|
138
|
+
var output = getEmptyRenderOutput();
|
|
147
139
|
if (!brickConf.brick) {
|
|
148
140
|
if (brickConf.template) {
|
|
149
141
|
// eslint-disable-next-line no-console
|
|
@@ -212,7 +204,7 @@ function _renderBrick() {
|
|
|
212
204
|
var {
|
|
213
205
|
dataSource
|
|
214
206
|
} = brickConf;
|
|
215
|
-
var
|
|
207
|
+
var lowerLevelRenderControlNode = /*#__PURE__*/function () {
|
|
216
208
|
var _ref = _asyncToGenerator(function* (runtimeContext) {
|
|
217
209
|
var _slots$slot;
|
|
218
210
|
// First, compute the `dataSource`
|
|
@@ -227,13 +219,13 @@ function _renderBrick() {
|
|
|
227
219
|
// Then, get the bricks in that matched slot.
|
|
228
220
|
var bricks = slots && hasOwnProperty(slots, slot) && ((_slots$slot = slots[slot]) === null || _slots$slot === void 0 ? void 0 : _slots$slot.bricks);
|
|
229
221
|
if (!Array.isArray(bricks)) {
|
|
230
|
-
return
|
|
222
|
+
return getEmptyRenderOutput();
|
|
231
223
|
}
|
|
232
224
|
switch (brickName) {
|
|
233
225
|
case ":forEach":
|
|
234
226
|
{
|
|
235
227
|
if (!Array.isArray(computedDataSource)) {
|
|
236
|
-
return
|
|
228
|
+
return getEmptyRenderOutput();
|
|
237
229
|
}
|
|
238
230
|
return renderForEach(returnNode, computedDataSource, bricks, runtimeContext, rendererContext, parentRoutes, slotId, tplStack, keyPath);
|
|
239
231
|
}
|
|
@@ -244,10 +236,24 @@ function _renderBrick() {
|
|
|
244
236
|
}
|
|
245
237
|
}
|
|
246
238
|
});
|
|
247
|
-
return function
|
|
239
|
+
return function lowerLevelRenderControlNode(_x31) {
|
|
248
240
|
return _ref.apply(this, arguments);
|
|
249
241
|
};
|
|
250
242
|
}();
|
|
243
|
+
var renderControlNode = /*#__PURE__*/function () {
|
|
244
|
+
var _ref2 = _asyncToGenerator(function* (runtimeContext) {
|
|
245
|
+
var _rawOutput$node;
|
|
246
|
+
var rawOutput = yield lowerLevelRenderControlNode(runtimeContext);
|
|
247
|
+
(_rawOutput$node = rawOutput.node) !== null && _rawOutput$node !== void 0 ? _rawOutput$node : rawOutput.node = {
|
|
248
|
+
tag: RenderTag.PLACEHOLDER,
|
|
249
|
+
return: returnNode
|
|
250
|
+
};
|
|
251
|
+
return rawOutput;
|
|
252
|
+
});
|
|
253
|
+
return function renderControlNode(_x32) {
|
|
254
|
+
return _ref2.apply(this, arguments);
|
|
255
|
+
};
|
|
256
|
+
}();
|
|
251
257
|
var controlledOutput = yield renderControlNode(runtimeContext);
|
|
252
258
|
var {
|
|
253
259
|
onMount,
|
|
@@ -261,12 +267,12 @@ function _renderBrick() {
|
|
|
261
267
|
controlledOutput.hasTrackingControls = true;
|
|
262
268
|
var renderId = 0;
|
|
263
269
|
var listener = /*#__PURE__*/function () {
|
|
264
|
-
var
|
|
270
|
+
var _ref3 = _asyncToGenerator(function* () {
|
|
265
271
|
var currentRenderId = ++renderId;
|
|
266
272
|
var [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = createScopedRuntimeContext(runtimeContext);
|
|
267
|
-
var
|
|
273
|
+
var reControlledOutput = yield renderControlNode(scopedRuntimeContext);
|
|
268
274
|
var scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
269
|
-
yield postAsyncRender(
|
|
275
|
+
yield postAsyncRender(reControlledOutput, scopedRuntimeContext, scopedStores);
|
|
270
276
|
|
|
271
277
|
// Ignore stale renders
|
|
272
278
|
if (renderId === currentRenderId) {
|
|
@@ -277,7 +283,7 @@ function _renderBrick() {
|
|
|
277
283
|
}
|
|
278
284
|
}));
|
|
279
285
|
}
|
|
280
|
-
rendererContext.reRender(slotId, keyPath,
|
|
286
|
+
rendererContext.reRender(slotId, keyPath, reControlledOutput.node, returnNode);
|
|
281
287
|
if (onMount) {
|
|
282
288
|
listenerFactory(onMount, scopedRuntimeContext)(new CustomEvent("mount", {
|
|
283
289
|
detail: {
|
|
@@ -291,7 +297,7 @@ function _renderBrick() {
|
|
|
291
297
|
}
|
|
292
298
|
});
|
|
293
299
|
return function listener() {
|
|
294
|
-
return
|
|
300
|
+
return _ref3.apply(this, arguments);
|
|
295
301
|
};
|
|
296
302
|
}();
|
|
297
303
|
var debouncedListener = debounce(listener);
|
|
@@ -355,12 +361,12 @@ function _renderBrick() {
|
|
|
355
361
|
var confProps;
|
|
356
362
|
if (brickName === FORM_RENDERER) {
|
|
357
363
|
var _brickConf$properties;
|
|
358
|
-
var
|
|
364
|
+
var _ref4 = (_brickConf$properties = brickConf.properties) !== null && _brickConf$properties !== void 0 ? _brickConf$properties : {};
|
|
359
365
|
({
|
|
360
366
|
formData
|
|
361
|
-
} =
|
|
362
|
-
confProps = _objectWithoutProperties(
|
|
363
|
-
|
|
367
|
+
} = _ref4);
|
|
368
|
+
confProps = _objectWithoutProperties(_ref4, _excluded3);
|
|
369
|
+
_ref4;
|
|
364
370
|
} else {
|
|
365
371
|
confProps = brickConf.properties;
|
|
366
372
|
}
|
|
@@ -414,12 +420,12 @@ function _renderBrick() {
|
|
|
414
420
|
// 加载构件属性和加载子构件等任务,可以并行。
|
|
415
421
|
var blockingList = [];
|
|
416
422
|
var loadProperties = /*#__PURE__*/function () {
|
|
417
|
-
var
|
|
423
|
+
var _ref5 = _asyncToGenerator(function* () {
|
|
418
424
|
brick.properties = yield constructAsyncProperties(asyncPropertyEntries);
|
|
419
425
|
listenOnTrackingContext(brick, trackingContextList);
|
|
420
426
|
});
|
|
421
427
|
return function loadProperties() {
|
|
422
|
-
return
|
|
428
|
+
return _ref5.apply(this, arguments);
|
|
423
429
|
};
|
|
424
430
|
}();
|
|
425
431
|
blockingList.push(loadProperties());
|
|
@@ -444,21 +450,21 @@ function _renderBrick() {
|
|
|
444
450
|
childRuntimeContext = runtimeContext;
|
|
445
451
|
}
|
|
446
452
|
var loadChildren = /*#__PURE__*/function () {
|
|
447
|
-
var
|
|
453
|
+
var _ref6 = _asyncToGenerator(function* () {
|
|
448
454
|
var slots = childrenToSlots(expandedBrickConf.children, expandedBrickConf.slots);
|
|
449
455
|
if (!slots) {
|
|
450
456
|
return;
|
|
451
457
|
}
|
|
452
458
|
var routeSlotIndexes = new Set();
|
|
453
|
-
var rendered = yield Promise.all(Object.entries(slots).map((
|
|
454
|
-
var [childSlotId, slotConf] =
|
|
459
|
+
var rendered = yield Promise.all(Object.entries(slots).map((_ref7, index) => {
|
|
460
|
+
var [childSlotId, slotConf] = _ref7;
|
|
455
461
|
if (slotConf.type !== "routes") {
|
|
456
462
|
return renderBricks(brick, slotConf.bricks, childRuntimeContext, rendererContext, parentRoutes, childSlotId, tplStack);
|
|
457
463
|
}
|
|
458
464
|
if (runtimeContext.flags["incremental-sub-route-rendering"]) {
|
|
459
465
|
routeSlotIndexes.add(index);
|
|
460
466
|
rendererContext.performIncrementalRender( /*#__PURE__*/function () {
|
|
461
|
-
var
|
|
467
|
+
var _ref8 = _asyncToGenerator(function* (location) {
|
|
462
468
|
var {
|
|
463
469
|
homepage
|
|
464
470
|
} = childRuntimeContext.app;
|
|
@@ -515,8 +521,8 @@ function _renderBrick() {
|
|
|
515
521
|
}
|
|
516
522
|
return true;
|
|
517
523
|
});
|
|
518
|
-
return function (
|
|
519
|
-
return
|
|
524
|
+
return function (_x33) {
|
|
525
|
+
return _ref8.apply(this, arguments);
|
|
520
526
|
};
|
|
521
527
|
}());
|
|
522
528
|
}
|
|
@@ -542,7 +548,7 @@ function _renderBrick() {
|
|
|
542
548
|
}));
|
|
543
549
|
});
|
|
544
550
|
return function loadChildren() {
|
|
545
|
-
return
|
|
551
|
+
return _ref6.apply(this, arguments);
|
|
546
552
|
};
|
|
547
553
|
}();
|
|
548
554
|
blockingList.push(loadChildren());
|
|
@@ -566,10 +572,7 @@ function renderForEach(_x22, _x23, _x24, _x25, _x26, _x27, _x28, _x29, _x30) {
|
|
|
566
572
|
}
|
|
567
573
|
function _renderForEach() {
|
|
568
574
|
_renderForEach = _asyncToGenerator(function* (returnNode, dataSource, bricks, runtimeContext, rendererContext, parentRoutes, slotId, tplStack, keyPath) {
|
|
569
|
-
var output =
|
|
570
|
-
blockingList: [],
|
|
571
|
-
menuRequests: []
|
|
572
|
-
};
|
|
575
|
+
var output = getEmptyRenderOutput();
|
|
573
576
|
var rows = dataSource.length;
|
|
574
577
|
var rendered = yield Promise.all(dataSource.map((item, i) => Promise.all(bricks.map((brickConf, j) => renderBrick(returnNode, brickConf, _objectSpread(_objectSpread({}, runtimeContext), {}, {
|
|
575
578
|
forEachItem: item,
|
|
@@ -648,6 +651,12 @@ function mergeRenderOutput(output, newOutput) {
|
|
|
648
651
|
}
|
|
649
652
|
Object.assign(output, rest);
|
|
650
653
|
}
|
|
654
|
+
function getEmptyRenderOutput() {
|
|
655
|
+
return {
|
|
656
|
+
blockingList: [],
|
|
657
|
+
menuRequests: []
|
|
658
|
+
};
|
|
659
|
+
}
|
|
651
660
|
export function childrenToSlots(children, originalSlots) {
|
|
652
661
|
var newSlots = originalSlots;
|
|
653
662
|
// istanbul ignore next
|