@next-core/runtime 1.36.1 → 1.37.0
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/createRoot.js +2 -3
- package/dist/cjs/createRoot.js.map +1 -1
- package/dist/cjs/internal/Renderer.js +72 -35
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js +76 -48
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/Router.js +5 -3
- package/dist/cjs/internal/Router.js.map +1 -1
- package/dist/cjs/internal/interfaces.js.map +1 -1
- package/dist/cjs/internal/poll.js +10 -2
- package/dist/cjs/internal/poll.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js +1 -1
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/esm/createRoot.js +2 -3
- package/dist/esm/createRoot.js.map +1 -1
- package/dist/esm/internal/Renderer.js +82 -45
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/esm/internal/RendererContext.js +76 -46
- package/dist/esm/internal/RendererContext.js.map +1 -1
- package/dist/esm/internal/Router.js +5 -3
- package/dist/esm/internal/Router.js.map +1 -1
- package/dist/esm/internal/interfaces.js.map +1 -1
- package/dist/esm/internal/poll.js +10 -2
- package/dist/esm/internal/poll.js.map +1 -1
- package/dist/esm/internal/secret_internals.js +1 -1
- package/dist/esm/internal/secret_internals.js.map +1 -1
- package/dist/types/internal/Renderer.d.ts +6 -6
- package/dist/types/internal/RendererContext.d.ts +8 -7
- package/dist/types/internal/interfaces.d.ts +7 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["_lodash","require","_Runtime","_Renderer","_RendererContext","_mount","_enums","_computeRealValue","_isStrictMode","_CustomTemplates","_registerAppI18n","_utils","_loader","_realTimeDataInspect","symbolForRootRuntimeContext","exports","Symbol","for","renderUseBrick","useBrick","data","_useBrick$symbolForRo","_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","meta","$$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","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","tplStateStoreId","runtimeContext","tplStateStore","getTplStateStore","getValue","ctxStore","getAllContextValues","getAllValues","getBrickPackagesById","id","getBrickPackages","find","pkg","filePath","startsWith","loadBricks","loadBricksImperatively","getRenderId","_internalApiGetRenderId","getAddedContracts","updateStoryboardType","collectUsedContracts","updatedStoryboard","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","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 { 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 RuntimeContext,\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): 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\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 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 {\n setRealTimeDataInspectRoot,\n addRealTimeDataInsp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"secret_internals.js","names":["_lodash","require","_Runtime","_Renderer","_RendererContext","_mount","_enums","_computeRealValue","_isStrictMode","_CustomTemplates","_registerAppI18n","_utils","_loader","_realTimeDataInspect","symbolForRootRuntimeContext","exports","Symbol","for","renderUseBrick","useBrick","data","_useBrick$symbolForRo","_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","meta","$$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","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","tplStateStoreId","runtimeContext","tplStateStore","getTplStateStore","getValue","ctxStore","getAllContextValues","getAllValues","getBrickPackagesById","id","getBrickPackages","find","pkg","filePath","startsWith","loadBricks","loadBricksImperatively","getRenderId","_internalApiGetRenderId","getAddedContracts","updateStoryboardType","collectUsedContracts","updatedStoryboard","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","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 { 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 RuntimeContext,\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): 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\n ? useBrick\n : {\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 {\n setRealTimeDataInspectRoot,\n addRealTimeDataInspectHook,\n} from \"./data/realTimeDataInspect.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,gBAAA,GAAAH,OAAA;AASA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,gBAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AAgZA,IAAAY,oBAAA,GAAAZ,OAAA;AA5YO,MAAMa,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAGE,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAarE,eAAeC,cAAcA,CAClCC,QAA4C,EAC5CC,IAAa,EACkB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA,EAAAC,sBAAA,EAAAC,YAAA,EAAAC,aAAA;EAC/B,MAAM,CAACC,oBAAoB,EAAEC,kBAAkB,EAAEC,mBAAmB,CAAC,GACnE,IAAAC,oCAA0B,EAAC;IACzB,KAAAR,qBAAA,GAAIF,QAAQ,CAACL,2BAA2B,CAAC,cAAAO,qBAAA,cAAAA,qBAAA,GACvC,IAAAS,sCAA6B,EAAC,CAAC,CAAE;IACnCV,IAAI;IACJW,0BAA0B,EAAE;EAC9B,CAAC,CAAC;EAEJ,CAAAT,qBAAA,GAAAI,oB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IACPA,QAAQ,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAAC5D,IAAI,KAAKA,IAC9D,CAAC,GACD;QACAmD,cAAc,CAACU,IAAI,CAACP,GAAG,CAAC;MAC1B;IACF,CAAC,CAAC;EACJ;EAEA,OAAOH,cAAc;AACvB"}
|
package/dist/esm/createRoot.js
CHANGED
|
@@ -100,7 +100,7 @@ export function unstable_createRoot(container) {
|
|
|
100
100
|
var output;
|
|
101
101
|
var stores = [];
|
|
102
102
|
try {
|
|
103
|
-
output = yield renderBricks(renderRoot, bricks, runtimeContext, rendererContext, []);
|
|
103
|
+
output = yield renderBricks(renderRoot, bricks, runtimeContext, rendererContext, [], {});
|
|
104
104
|
stores = getDataStores(runtimeContext);
|
|
105
105
|
yield postAsyncRender(output, runtimeContext, stores);
|
|
106
106
|
} catch (error) {
|
|
@@ -115,8 +115,7 @@ export function unstable_createRoot(container) {
|
|
|
115
115
|
return: renderRoot,
|
|
116
116
|
runtimeContext: null
|
|
117
117
|
},
|
|
118
|
-
blockingList: []
|
|
119
|
-
menuRequests: []
|
|
118
|
+
blockingList: []
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
121
|
renderRoot.child = output.node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoot.js","names":["uniqueId","getDataStores","postAsyncRender","renderBricks","RendererContext","DataStore","mountTree","unmountTree","httpErrorToString","applyMode","applyTheme","setMode","setTheme","RenderTag","registerStoryboardFunctions","registerAppI18n","registerCustomTemplates","setUIVersion","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","uiVersion","context","functions","templates","i18n","i18nData","Error","bricks","concat","previousRendererContext","renderId","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","renderRoot","tag","ROOT","_clearI18nBundles","demoApp","id","homepage","app","demoStoryboard","meta","customTemplates","define","failed","output","stores","error","node","BRICK","type","properties","textContent","return","blockingList","menuRequests","child","dispatchOnUnmount","dispose","dispatchBeforePageLoad","window","scrollTo","store","mountAsyncData","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport {\n RenderOutput,\n getDataStores,\n postAsyncRender,\n renderBricks,\n} from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\nimport { setUIVersion } from \"./setUIVersion.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n uiVersion?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | DocumentFragment,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n uiVersion,\n context,\n functions,\n templates,\n i18n: i18nData,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n const renderId = uniqueId(\"render-id-\");\n rendererContext = new RendererContext(scope, { unknownBricks, renderId });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n setUIVersion(uiVersion);\n\n const demoApp = {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = demoApp;\n const demoStoryboard = {\n app: demoApp,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, demoApp);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext,\n []\n );\n\n stores = getDataStores(runtimeContext);\n await postAsyncRender(output, runtimeContext, stores);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.mountAsyncData();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";AAUA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAEEC,aAAa,EACbC,eAAe,EACfC,YAAY,QACP,wBAAwB;AAC/B,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,SAAS,QAAQ,8BAA8B;AAExD,SAASC,SAAS,EAAEC,WAAW,QAAQ,qBAAqB;AAC5D,SAASC,iBAAiB,QAAQ,sB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;QAEA,IAAIE,KAAK,KAAK,MAAM,EAAE;UACpB,IAAI,CAACmD,MAAM,EAAE;YACXpC,eAAe,CAACmD,sBAAsB,CAAC,CAAC;UAC1C;UAEA9E,UAAU,CAAC,CAAC;UACZD,SAAS,CAAC,CAAC;QACb;QAEAH,SAAS,CAACuD,UAAU,CAAC;QAErB,IAAIvC,KAAK,KAAK,MAAM,EAAE;UACpBmE,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB;QAEA,IAAI,CAACjB,MAAM,EAAE;UACX,KAAK,IAAMkB,KAAK,IAAIhB,MAAM,EAAE;YAC1BgB,KAAK,CAACC,cAAc,CAAC,CAAC;UACxB;UAEA,IAAItE,KAAK,KAAK,MAAM,EAAE;YACpBe,eAAe,CAACwD,gBAAgB,CAAC,CAAC;YAClC;UACF;UACAxD,eAAe,CAACyD,eAAe,CAAC,CAAC;UACjCzD,eAAe,CAAC0D,wBAAwB,CAAC,CAAC;UAC1C1D,eAAe,CAAC2D,qBAAqB,CAAC,CAAC;UACvC3D,eAAe,CAAC4D,2BAA2B,CAAC,CAAC;QAC/C;MAAC;IACH,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAI9D,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB7B,WAAW,CAACY,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACVb,WAAW,CAACa,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAAC+E,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"createRoot.js","names":["uniqueId","getDataStores","postAsyncRender","renderBricks","RendererContext","DataStore","mountTree","unmountTree","httpErrorToString","applyMode","applyTheme","setMode","setTheme","RenderTag","registerStoryboardFunctions","registerAppI18n","registerCustomTemplates","setUIVersion","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","uiVersion","context","functions","templates","i18n","i18nData","Error","bricks","concat","previousRendererContext","renderId","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","renderRoot","tag","ROOT","_clearI18nBundles","demoApp","id","homepage","app","demoStoryboard","meta","customTemplates","define","failed","output","stores","error","node","BRICK","type","properties","textContent","return","blockingList","child","dispatchOnUnmount","dispose","dispatchBeforePageLoad","window","scrollTo","store","mountAsyncData","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport {\n RenderOutput,\n getDataStores,\n postAsyncRender,\n renderBricks,\n} from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\nimport { setUIVersion } from \"./setUIVersion.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n uiVersion?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | DocumentFragment,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n uiVersion,\n context,\n functions,\n templates,\n i18n: i18nData,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n const renderId = uniqueId(\"render-id-\");\n rendererContext = new RendererContext(scope, { unknownBricks, renderId });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n setUIVersion(uiVersion);\n\n const demoApp = {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = demoApp;\n const demoStoryboard = {\n app: demoApp,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, demoApp);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext,\n [],\n {}\n );\n\n stores = getDataStores(runtimeContext);\n await postAsyncRender(output, runtimeContext, stores);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.mountAsyncData();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";AAUA,SAASA,QAAQ,QAAQ,Q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import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
var _excluded = ["blockingList", "node", "
|
|
4
|
+
var _excluded = ["blockingList", "node", "menuRequestNode", "hasTrackingControls"],
|
|
5
5
|
_excluded2 = ["if", "permissionsPreCheck"],
|
|
6
6
|
_excluded3 = ["formData"],
|
|
7
7
|
_excluded4 = ["src"],
|
|
@@ -32,13 +32,17 @@ import { getPreEvaluatedRaw } from "./compute/evaluate.js";
|
|
|
32
32
|
import { matchHomepage } from "./matchStoryboard.js";
|
|
33
33
|
import { listenerFactory } from "./bindListeners.js";
|
|
34
34
|
import { setupRootRuntimeContext } from "./setupRootRuntimeContext.js";
|
|
35
|
-
export function renderRoutes(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
|
|
35
|
+
export function renderRoutes(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
|
|
36
36
|
return _renderRoutes.apply(this, arguments);
|
|
37
37
|
}
|
|
38
38
|
function _renderRoutes() {
|
|
39
|
-
_renderRoutes = _asyncToGenerator(function* (returnNode, routes, _runtimeContext, rendererContext, parentRoutes, slotId, isIncremental) {
|
|
39
|
+
_renderRoutes = _asyncToGenerator(function* (returnNode, routes, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, isIncremental) {
|
|
40
40
|
var matched = yield matchRoutes(routes, _runtimeContext);
|
|
41
41
|
var output = getEmptyRenderOutput();
|
|
42
|
+
var menuRequestNode = {
|
|
43
|
+
return: menuRequestReturnNode
|
|
44
|
+
};
|
|
45
|
+
output.menuRequestNode = menuRequestNode;
|
|
42
46
|
switch (matched) {
|
|
43
47
|
case "missed":
|
|
44
48
|
break;
|
|
@@ -89,18 +93,19 @@ function _renderRoutes() {
|
|
|
89
93
|
} else {
|
|
90
94
|
var menuRequest = loadMenu(route.menu, runtimeContext);
|
|
91
95
|
if (menuRequest) {
|
|
92
|
-
|
|
96
|
+
menuRequestNode.request = menuRequest;
|
|
97
|
+
}
|
|
98
|
+
if (!isIncremental) {
|
|
99
|
+
rendererContext.memoizeMenuRequestNode(routes, menuRequestNode);
|
|
93
100
|
}
|
|
101
|
+
var newOutput;
|
|
94
102
|
if (route.type === "routes") {
|
|
95
|
-
|
|
96
|
-
mergeRenderOutput(output, newOutput);
|
|
103
|
+
newOutput = yield renderRoutes(returnNode, route.routes, runtimeContext, rendererContext, routePath, menuRequestNode, slotId);
|
|
97
104
|
} else {
|
|
98
|
-
|
|
99
|
-
mergeRenderOutput(output, _newOutput);
|
|
100
|
-
}
|
|
101
|
-
if (returnNode.tag === RenderTag.BRICK) {
|
|
102
|
-
rendererContext.memoizeMenuRequests(route, output.menuRequests);
|
|
105
|
+
newOutput = yield renderBricks(returnNode, route.bricks, runtimeContext, rendererContext, routePath, menuRequestNode, slotId);
|
|
103
106
|
}
|
|
107
|
+
mergeRenderOutput(output, newOutput);
|
|
108
|
+
appendMenuRequestNode(menuRequestReturnNode, newOutput.menuRequestNode);
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
}
|
|
@@ -108,16 +113,16 @@ function _renderRoutes() {
|
|
|
108
113
|
});
|
|
109
114
|
return _renderRoutes.apply(this, arguments);
|
|
110
115
|
}
|
|
111
|
-
export function renderBricks(
|
|
116
|
+
export function renderBricks(_x9, _x10, _x11, _x12, _x13, _x14, _x15, _x16, _x17) {
|
|
112
117
|
return _renderBricks.apply(this, arguments);
|
|
113
118
|
}
|
|
114
119
|
function _renderBricks() {
|
|
115
|
-
_renderBricks = _asyncToGenerator(function* (returnNode, bricks, runtimeContext, rendererContext, parentRoutes, slotId, tplStack, keyPath) {
|
|
120
|
+
_renderBricks = _asyncToGenerator(function* (returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath) {
|
|
116
121
|
setupRootRuntimeContext(bricks, runtimeContext, true);
|
|
117
122
|
var output = getEmptyRenderOutput();
|
|
118
123
|
var kPath = keyPath !== null && keyPath !== void 0 ? keyPath : [];
|
|
119
124
|
// 多个构件并行异步转换,但转换的结果按原顺序串行合并。
|
|
120
|
-
var rendered = yield Promise.all(bricks.map((brickConf, index) => renderBrick(returnNode, brickConf, runtimeContext, rendererContext, parentRoutes, slotId, kPath.concat(index), tplStack && new Map(tplStack))));
|
|
125
|
+
var rendered = yield Promise.all(bricks.map((brickConf, index) => renderBrick(returnNode, brickConf, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, kPath.concat(index), tplStack && new Map(tplStack))));
|
|
121
126
|
rendered.forEach((item, index) => {
|
|
122
127
|
if (item.hasTrackingControls) {
|
|
123
128
|
// Memoize a render node before it's been merged.
|
|
@@ -129,14 +134,14 @@ function _renderBricks() {
|
|
|
129
134
|
});
|
|
130
135
|
return _renderBricks.apply(this, arguments);
|
|
131
136
|
}
|
|
132
|
-
export function renderBrick(
|
|
137
|
+
export function renderBrick(_x18, _x19, _x20, _x21, _x22, _x23, _x24) {
|
|
133
138
|
return _renderBrick.apply(this, arguments);
|
|
134
139
|
}
|
|
135
140
|
function _renderBrick() {
|
|
136
|
-
_renderBrick = _asyncToGenerator(function* (returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, slotId) {
|
|
141
|
+
_renderBrick = _asyncToGenerator(function* (returnNode, brickConf, _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId) {
|
|
137
142
|
var _hooks$checkPermissio2, _runtimeContext$app;
|
|
138
|
-
var keyPath = arguments.length >
|
|
139
|
-
var tplStack = arguments.length >
|
|
143
|
+
var keyPath = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : [];
|
|
144
|
+
var tplStack = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : new Map();
|
|
140
145
|
var output = getEmptyRenderOutput();
|
|
141
146
|
if (!brickConf.brick) {
|
|
142
147
|
if (brickConf.template) {
|
|
@@ -170,7 +175,7 @@ function _renderBrick() {
|
|
|
170
175
|
}
|
|
171
176
|
}, Object.getOwnPropertySymbols(brickConf).reduce((acc, symbol) => _objectSpread(_objectSpread({}, acc), {}, {
|
|
172
177
|
[symbol]: brickConf[symbol]
|
|
173
|
-
}), {})), _runtimeContext, rendererContext, parentRoutes, slotId, keyPath, tplStack);
|
|
178
|
+
}), {})), _runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, keyPath, tplStack);
|
|
174
179
|
}
|
|
175
180
|
var tplStateStoreId = brickConf[symbolForTplStateStoreId];
|
|
176
181
|
var formStateStoreId = brickConf[symbolForFormStateStoreId];
|
|
@@ -232,16 +237,16 @@ function _renderBrick() {
|
|
|
232
237
|
if (!Array.isArray(computedDataSource)) {
|
|
233
238
|
return getEmptyRenderOutput();
|
|
234
239
|
}
|
|
235
|
-
return renderForEach(returnNode, computedDataSource, bricks, runtimeContext, rendererContext, parentRoutes, slotId, tplStack, keyPath);
|
|
240
|
+
return renderForEach(returnNode, computedDataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
236
241
|
}
|
|
237
242
|
case ":if":
|
|
238
243
|
case ":switch":
|
|
239
244
|
{
|
|
240
|
-
return renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, slotId, tplStack, keyPath);
|
|
245
|
+
return renderBricks(returnNode, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath);
|
|
241
246
|
}
|
|
242
247
|
}
|
|
243
248
|
});
|
|
244
|
-
return function lowerLevelRenderControlNode(
|
|
249
|
+
return function lowerLevelRenderControlNode(_x35) {
|
|
245
250
|
return _ref.apply(this, arguments);
|
|
246
251
|
};
|
|
247
252
|
}();
|
|
@@ -255,7 +260,7 @@ function _renderBrick() {
|
|
|
255
260
|
};
|
|
256
261
|
return rawOutput;
|
|
257
262
|
});
|
|
258
|
-
return function renderControlNode(
|
|
263
|
+
return function renderControlNode(_x36) {
|
|
259
264
|
return _ref2.apply(this, arguments);
|
|
260
265
|
};
|
|
261
266
|
}();
|
|
@@ -464,12 +469,12 @@ function _renderBrick() {
|
|
|
464
469
|
var rendered = yield Promise.all(Object.entries(slots).map((_ref7, index) => {
|
|
465
470
|
var [childSlotId, slotConf] = _ref7;
|
|
466
471
|
if (slotConf.type !== "routes") {
|
|
467
|
-
return renderBricks(brick, slotConf.bricks, childRuntimeContext, rendererContext, parentRoutes, childSlotId, tplStack);
|
|
472
|
+
return renderBricks(brick, slotConf.bricks, childRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, tplStack);
|
|
468
473
|
}
|
|
469
474
|
var parentRoute = parentRoutes[parentRoutes.length - 1];
|
|
470
475
|
if (parentRoute !== null && parentRoute !== void 0 && parentRoute.incrementalSubRoutes) {
|
|
471
476
|
routeSlotFromIndexToSlotId.set(index, childSlotId);
|
|
472
|
-
rendererContext.performIncrementalRender( /*#__PURE__*/function () {
|
|
477
|
+
rendererContext.performIncrementalRender(slotConf, parentRoutes, /*#__PURE__*/function () {
|
|
473
478
|
var _ref8 = _asyncToGenerator(function* (location, prevLocation) {
|
|
474
479
|
var {
|
|
475
480
|
homepage
|
|
@@ -493,18 +498,19 @@ function _renderBrick() {
|
|
|
493
498
|
var incrementalOutput;
|
|
494
499
|
var scopedStores = [];
|
|
495
500
|
try {
|
|
496
|
-
incrementalOutput = yield renderRoutes(brick, slotConf.routes, scopedRuntimeContext, rendererContext, parentRoutes, childSlotId, true);
|
|
501
|
+
incrementalOutput = yield renderRoutes(brick, slotConf.routes, scopedRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId, true);
|
|
497
502
|
|
|
498
503
|
// Do not ignore incremental rendering even if all sub-routes are missed.
|
|
499
504
|
// Since parent route is matched.
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
505
|
+
if (incrementalOutput.route) {
|
|
506
|
+
// Bailout if redirect or unauthenticated is set
|
|
507
|
+
if (rendererContext.reBailout(incrementalOutput)) {
|
|
508
|
+
return true;
|
|
509
|
+
}
|
|
510
|
+
scopedStores = [...tplStateStoreScope, ...formStateStoreScope];
|
|
511
|
+
yield postAsyncRender(incrementalOutput, scopedRuntimeContext, [scopedRuntimeContext.ctxStore, ...scopedStores]);
|
|
504
512
|
}
|
|
505
|
-
|
|
506
|
-
yield postAsyncRender(incrementalOutput, scopedRuntimeContext, [scopedRuntimeContext.ctxStore, ...scopedStores]);
|
|
507
|
-
yield rendererContext.reMergeMenuRequests(slotConf.routes, incrementalOutput.route, incrementalOutput.menuRequests);
|
|
513
|
+
yield rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
508
514
|
} catch (error) {
|
|
509
515
|
// eslint-disable-next-line no-console
|
|
510
516
|
console.error("Incremental sub-router failed:", error);
|
|
@@ -518,7 +524,7 @@ function _renderBrick() {
|
|
|
518
524
|
} = result);
|
|
519
525
|
|
|
520
526
|
// Assert: no errors will be throw
|
|
521
|
-
yield rendererContext.
|
|
527
|
+
yield rendererContext.reMergeMenuRequestNodes(menuRequestReturnNode, slotConf.routes, incrementalOutput.menuRequestNode);
|
|
522
528
|
}
|
|
523
529
|
rendererContext.reRender(childSlotId, [], incrementalOutput.node, brick);
|
|
524
530
|
if (!failed) {
|
|
@@ -527,19 +533,22 @@ function _renderBrick() {
|
|
|
527
533
|
store.mountAsyncData();
|
|
528
534
|
}
|
|
529
535
|
}
|
|
530
|
-
|
|
536
|
+
|
|
537
|
+
// When result is null, it means the incremental rendering is tried but routes missed.
|
|
538
|
+
// In this case, we should continue to re-render the parent routes.
|
|
539
|
+
return incrementalOutput.route ? true : null;
|
|
531
540
|
});
|
|
532
|
-
return function (
|
|
541
|
+
return function (_x37, _x38) {
|
|
533
542
|
return _ref8.apply(this, arguments);
|
|
534
543
|
};
|
|
535
544
|
}());
|
|
536
545
|
}
|
|
537
|
-
return renderRoutes(brick, slotConf.routes, childRuntimeContext, rendererContext, parentRoutes, childSlotId);
|
|
546
|
+
return renderRoutes(brick, slotConf.routes, childRuntimeContext, rendererContext, parentRoutes, menuRequestReturnNode, childSlotId);
|
|
538
547
|
}));
|
|
539
548
|
var childrenOutput = _objectSpread(_objectSpread({}, output), {}, {
|
|
540
549
|
node: undefined,
|
|
541
550
|
blockingList: [],
|
|
542
|
-
|
|
551
|
+
menuRequestNode: undefined
|
|
543
552
|
});
|
|
544
553
|
rendered.forEach((item, index) => {
|
|
545
554
|
if (routeSlotFromIndexToSlotId.has(index)) {
|
|
@@ -547,6 +556,7 @@ function _renderBrick() {
|
|
|
547
556
|
rendererContext.memoize(routeSlotFromIndexToSlotId.get(index), [], item.node, brick);
|
|
548
557
|
}
|
|
549
558
|
mergeRenderOutput(childrenOutput, item);
|
|
559
|
+
mergeSiblingRenderMenuRequest(childrenOutput, item);
|
|
550
560
|
});
|
|
551
561
|
if (childrenOutput.node) {
|
|
552
562
|
brick.child = childrenOutput.node;
|
|
@@ -554,6 +564,7 @@ function _renderBrick() {
|
|
|
554
564
|
mergeRenderOutput(output, _objectSpread(_objectSpread({}, childrenOutput), {}, {
|
|
555
565
|
node: undefined
|
|
556
566
|
}));
|
|
567
|
+
appendMenuRequestNode(menuRequestReturnNode, output.menuRequestNode = childrenOutput.menuRequestNode);
|
|
557
568
|
});
|
|
558
569
|
return function loadChildren() {
|
|
559
570
|
return _ref6.apply(this, arguments);
|
|
@@ -575,17 +586,17 @@ function ensureValidControlBrick(brick) {
|
|
|
575
586
|
throw new Error("Unknown storyboard control node: \"".concat(brick, "\""));
|
|
576
587
|
}
|
|
577
588
|
}
|
|
578
|
-
function renderForEach(
|
|
589
|
+
function renderForEach(_x25, _x26, _x27, _x28, _x29, _x30, _x31, _x32, _x33, _x34) {
|
|
579
590
|
return _renderForEach.apply(this, arguments);
|
|
580
591
|
}
|
|
581
592
|
function _renderForEach() {
|
|
582
|
-
_renderForEach = _asyncToGenerator(function* (returnNode, dataSource, bricks, runtimeContext, rendererContext, parentRoutes, slotId, tplStack, keyPath) {
|
|
593
|
+
_renderForEach = _asyncToGenerator(function* (returnNode, dataSource, bricks, runtimeContext, rendererContext, parentRoutes, menuRequestReturnNode, slotId, tplStack, keyPath) {
|
|
583
594
|
var output = getEmptyRenderOutput();
|
|
584
595
|
var rows = dataSource.length;
|
|
585
596
|
var rendered = yield Promise.all(dataSource.map((item, i) => Promise.all(bricks.map((brickConf, j) => renderBrick(returnNode, brickConf, _objectSpread(_objectSpread({}, runtimeContext), {}, {
|
|
586
597
|
forEachItem: item,
|
|
587
598
|
forEachIndex: i
|
|
588
|
-
}), rendererContext, parentRoutes, slotId, keyPath.concat(i * rows + j), tplStack && new Map(tplStack))))));
|
|
599
|
+
}), rendererContext, parentRoutes, menuRequestReturnNode, slotId, keyPath.concat(i * rows + j), tplStack && new Map(tplStack))))));
|
|
589
600
|
|
|
590
601
|
// 多层构件并行异步转换,但转换的结果按原顺序串行合并。
|
|
591
602
|
rendered.flat().forEach((item, index) => {
|
|
@@ -640,12 +651,11 @@ function mergeRenderOutput(output, newOutput) {
|
|
|
640
651
|
var {
|
|
641
652
|
blockingList,
|
|
642
653
|
node,
|
|
643
|
-
|
|
654
|
+
menuRequestNode,
|
|
644
655
|
hasTrackingControls
|
|
645
656
|
} = newOutput,
|
|
646
657
|
rest = _objectWithoutProperties(newOutput, _excluded);
|
|
647
658
|
output.blockingList.push(...blockingList);
|
|
648
|
-
output.menuRequests.push(...menuRequests);
|
|
649
659
|
if (node) {
|
|
650
660
|
if (output.node) {
|
|
651
661
|
var last = output.node;
|
|
@@ -659,10 +669,37 @@ function mergeRenderOutput(output, newOutput) {
|
|
|
659
669
|
}
|
|
660
670
|
Object.assign(output, rest);
|
|
661
671
|
}
|
|
672
|
+
function mergeSiblingRenderMenuRequest(output, newOutput) {
|
|
673
|
+
var menuRequestNode = newOutput.menuRequestNode;
|
|
674
|
+
if (menuRequestNode) {
|
|
675
|
+
if (output.menuRequestNode) {
|
|
676
|
+
var last = output.menuRequestNode;
|
|
677
|
+
while (last.sibling) {
|
|
678
|
+
last = last.sibling;
|
|
679
|
+
}
|
|
680
|
+
last.sibling = menuRequestNode;
|
|
681
|
+
} else {
|
|
682
|
+
output.menuRequestNode = menuRequestNode;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
function appendMenuRequestNode(menuRequestReturnNode, menuRequestNode) {
|
|
687
|
+
if (!menuRequestNode) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
if (menuRequestReturnNode.child) {
|
|
691
|
+
var last = menuRequestReturnNode.child;
|
|
692
|
+
while (last.sibling) {
|
|
693
|
+
last = last.sibling;
|
|
694
|
+
}
|
|
695
|
+
last.sibling = menuRequestNode;
|
|
696
|
+
} else {
|
|
697
|
+
menuRequestReturnNode.child = menuRequestNode;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
662
700
|
function getEmptyRenderOutput() {
|
|
663
701
|
return {
|
|
664
|
-
blockingList: []
|
|
665
|
-
menuRequests: []
|
|
702
|
+
blockingList: []
|
|
666
703
|
};
|
|
667
704
|
}
|
|
668
705
|
export function childrenToSlots(children, originalSlots) {
|