@next-core/runtime 1.51.0 → 1.52.1
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 +5 -0
- package/dist/cjs/createRoot.js.map +1 -1
- package/dist/cjs/internal/Renderer.js +4 -0
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/esm/createRoot.js +5 -0
- package/dist/esm/createRoot.js.map +1 -1
- package/dist/esm/internal/Renderer.js +4 -0
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/types/createRoot.d.ts +2 -1
- package/package.json +2 -2
package/dist/cjs/createRoot.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.unstable_createRoot = unstable_createRoot;
|
|
7
|
+
var _i18n = require("@next-core/i18n");
|
|
7
8
|
var _lodash = require("lodash");
|
|
8
9
|
var _Renderer = require("./internal/Renderer.js");
|
|
9
10
|
var _RendererContext = require("./internal/RendererContext.js");
|
|
@@ -42,6 +43,7 @@ function unstable_createRoot(container, {
|
|
|
42
43
|
async render(brick, {
|
|
43
44
|
theme,
|
|
44
45
|
uiVersion,
|
|
46
|
+
language,
|
|
45
47
|
context,
|
|
46
48
|
functions,
|
|
47
49
|
templates,
|
|
@@ -85,6 +87,9 @@ function unstable_createRoot(container, {
|
|
|
85
87
|
(0, _themeAndMode.setTheme)(theme ?? "light");
|
|
86
88
|
(0, _themeAndMode.setMode)("default");
|
|
87
89
|
(0, _setUIVersion.setUIVersion)(uiVersion);
|
|
90
|
+
if (language) {
|
|
91
|
+
await _i18n.i18n.changeLanguage(language);
|
|
92
|
+
}
|
|
88
93
|
app ?? (app = {
|
|
89
94
|
id: "demo",
|
|
90
95
|
homepage: "/demo"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoot.js","names":["_lodash","require","_Renderer","_RendererContext","_DataStore","_mount","_handleHttpError","_themeAndMode","_enums","_StoryboardFunctions","_registerAppI18n","_registerCustomTemplates","_setUIVersion","unstable_createRoot","container","portal","_portal","scope","unknownBricks","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","theme","uiVersion","context","functions","templates","i18n","i18nData","url","app","Error","bricks","concat","previousRendererContext","renderId","uniqueId","RendererContext","runtimeContext","ctxStore","DataStore","undefined","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","urlObj","URL","query","searchParams","location","pathname","search","hash","state","renderRoot","tag","RenderTag","ROOT","_clearI18nBundles","setTheme","setMode","setUIVersion","id","homepage","demoStoryboard","meta","customTemplates","registerAppI18n","registerCustomTemplates","registerStoryboardFunctions","define","failed","output","stores","renderBricks","getDataStores","postAsyncRender","error","node","BRICK","type","properties","textContent","httpErrorToString","dataset","errorBoundary","color","return","blockingList","child","dispatchOnUnmount","dispose","unmountTree","dispatchBeforePageLoad","applyTheme","applyMode","mountTree","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 url?: string;\n app?: MicroApp;\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 url,\n app,\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 if (url) {\n const urlObj = new URL(url);\n runtimeContext.query = urlObj.searchParams;\n runtimeContext.location = {\n pathname: urlObj.pathname,\n search: urlObj.search,\n hash: urlObj.hash,\n state: undefined,\n };\n }\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 app ??= {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = app;\n const demoStoryboard = {\n app,\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, app);\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 dataset: {\n errorBoundary: \"\",\n },\n style: {\n color: \"var(--color-error)\",\n },\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,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAMA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,wBAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AA8BO,SAASY,mBAAmBA,CACjCC,SAAyC,EACzC;EAAEC,MAAM,EAAEC,OAAO;EAAEC,KAAK,GAAG,UAAU;EAAEC;AAAiC,CAAC,GAAG,CAAC,CAAC,EAC9E;EACA,IAAIH,MAAM,GAAGC,OAAO;EACpB,IAAIG,YAAwC;EAC5C,IAAIH,OAAO,EAAE;IACXG,YAAY,GAAGH,OAAO;EACxB,CAAC,MAAM;IACL;IACAG,YAAY,GAAGA,CAAA,KAAM;MACnBJ,MAAM,GAAGK,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;MACtCN,MAAM,C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vB;MAEA,IAAI,CAAC3B,MAAM,EAAE;QACX,KAAK,MAAM4B,KAAK,IAAI1B,MAAM,EAAE;UAC1B0B,KAAK,CAACC,cAAc,CAAC,CAAC;QACxB;QAEA,IAAI/F,KAAK,KAAK,MAAM,EAAE;UACpBY,eAAe,CAACoF,gBAAgB,CAAC,CAAC;UAClC;QACF;QACApF,eAAe,CAACqF,eAAe,CAAC,CAAC;QACjCrF,eAAe,CAACsF,wBAAwB,CAAC,CAAC;QAC1CtF,eAAe,CAACuF,qBAAqB,CAAC,CAAC;QACvCvF,eAAe,CAACwF,2BAA2B,CAAC,CAAC;MAC/C;IACF,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAI1F,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB,IAAA4E,kBAAW,EAAC1F,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACV,IAAAyF,kBAAW,EAACzF,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAACwG,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createRoot.js","names":["_i18n","require","_lodash","_Renderer","_RendererContext","_DataStore","_mount","_handleHttpError","_themeAndMode","_enums","_StoryboardFunctions","_registerAppI18n","_registerCustomTemplates","_setUIVersion","unstable_createRoot","container","portal","_portal","scope","unknownBricks","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","theme","uiVersion","language","context","functions","templates","i18n","i18nData","url","app","Error","bricks","concat","previousRendererContext","renderId","uniqueId","RendererContext","runtimeContext","ctxStore","DataStore","undefined","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","urlObj","URL","query","searchParams","location","pathname","search","hash","state","renderRoot","tag","RenderTag","ROOT","_clearI18nBundles","setTheme","setMode","setUIVersion","changeLanguage","id","homepage","demoStoryboard","meta","customTemplates","registerAppI18n","registerCustomTemplates","registerStoryboardFunctions","define","failed","output","stores","renderBricks","getDataStores","postAsyncRender","error","node","BRICK","type","properties","textContent","httpErrorToString","dataset","errorBoundary","color","return","blockingList","child","dispatchOnUnmount","dispose","unmountTree","dispatchBeforePageLoad","applyTheme","applyMode","mountTree","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 { i18n } from \"@next-core/i18n\";\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 language?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n url?: string;\n app?: MicroApp;\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 language,\n context,\n functions,\n templates,\n i18n: i18nData,\n url,\n app,\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 if (url) {\n const urlObj = new URL(url);\n runtimeContext.query = urlObj.searchParams;\n runtimeContext.location = {\n pathname: urlObj.pathname,\n search: urlObj.search,\n hash: urlObj.hash,\n state: undefined,\n };\n }\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 if (language) {\n await i18n.changeLanguage(language);\n }\n\n app ??= {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = app;\n const demoStoryboard = {\n app,\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, app);\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 dataset: {\n errorBoundary: \"\",\n },\n style: {\n color: \"var(--color-error)\",\n },\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,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,oBAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AACA,IAAAW,wBAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AA+BO,SAASa,mBAAmBA,CACjCC,SAAyC,EACzC;EAAEC,MAAM,EAAEC,OAAO;EAAEC,KAAK,GAAG,UAAU;EAAEC;AAAiC,CAAC,GAAG,CAAC,CAAC,EAC9E;EACA,IAAIH,MAAM,GAAGC,OAAO;EACpB,IAAIG,YAAwC;EAC5C,IAAIH,OAAO,EAAE;IACXG,YAAY,GAAGH,OAAO;EACxB,CAAC,MAAM;IACL;IACAG,YAAY,GAAGA,CAAA,KAAM;MACnBJ,MAAM,GAAGK,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;MACtCN,MAAM,CAACO,KAAK,CAACC,QAAQ,GAAG,UAAU;MAClCR,MAAM,CAACO,KAAK,CAACE,KAAK,GAAGT,MAAM,CAACO,KAAK,CAACG,MAAM,GAAG,GAAG;MAC9CL,QAAQ,CAACM,IAAI,CAACC,MAAM,CAACZ,MAAM,CAAC;MAC5B,OAAOA,MAAM;IACf,CAAC;EACH;EACA,IAAIa,SAAS,GAAG,KAAK;EACrB,IAAIC,eAA4C;EAChD,IAAIC,gBAAsC;EAE1C,OAAO;IACL,MAAMC,MAAMA,CACVC,K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,eAAe,CAAC,CAAC;QACjCvF,eAAe,CAACwF,wBAAwB,CAAC,CAAC;QAC1CxF,eAAe,CAACyF,qBAAqB,CAAC,CAAC;QACvCzF,eAAe,CAAC0F,2BAA2B,CAAC,CAAC;MAC/C;IACF,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAI5F,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB,IAAA8E,kBAAW,EAAC5F,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACV,IAAA2F,kBAAW,EAAC3F,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAAC0G,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -378,10 +378,14 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
378
378
|
let formData;
|
|
379
379
|
let confProps;
|
|
380
380
|
if (brickName === _constants2.FORM_RENDERER) {
|
|
381
|
+
var _brickConf$properties;
|
|
381
382
|
({
|
|
382
383
|
formData,
|
|
383
384
|
...confProps
|
|
384
385
|
} = brickConf.properties ?? {});
|
|
386
|
+
if ((_brickConf$properties = brickConf.properties) !== null && _brickConf$properties !== void 0 && _brickConf$properties.compute) {
|
|
387
|
+
formData = await (0, _computeRealValue.asyncComputeRealValue)(formData, runtimeContext);
|
|
388
|
+
}
|
|
385
389
|
} else {
|
|
386
390
|
confProps = brickConf.properties;
|
|
387
391
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.js","names":["_loader","require","_cook","_general","_storyboard","_lodash","_checkIf","_computeRealProperties","_resolveData","_computeRealValue","_listenOnTrackingContext","_matchRoutes","_constants","_expandCustomTemplate","_utils","_CustomTemplates","_Runtime","_enums","_getTracks","_isStrictMode","_constants2","_expandFormRenderer","_evaluate","_matchStoryboard","_bindListeners","_setupRootRuntimeContext","_handleHttpError","_routeMatchedMap","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","parentRoutes","menuRequestReturnNode","slotId","isIncremental","matched","matchRoutes","output","getEmptyRenderOutput","menuRequestNode","return","unauthenticated","_hooks$checkPermissio","route","path","match","runtimeContext","iid","setMatchedRoute","ctxStore","disposeDataInRoutes","routePath","concat","define","context","undefined","pendingPermissionsPreCheck","push","hooks","checkPermissions","preCheckPermissionsForBrickOrRoute","value","asyncComputeRealValue","preLoadBricks","Array","isArray","blockingList","loadBricksImperatively","getBrickPackages","type","redirectTo","redirect","resolved","resolveData","transform","console","error","Error","menuRequest","loadMenu","menu","request","memoizeMenuRequestNode","newOutput","renderBricks","bricks","mergeRenderOutput","appendMenuRequestNode","tplStack","keyPath","setupRootRuntimeContext","kPath","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoize","node","legacyRenderBrick","errorBoundary","tag","RenderTag","BRICK","properties","textContent","httpErrorToString","dataset","style","color","_hooks$checkPermissio2","_runtimeContext$app","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","symbolForTplStateStoreId","formStateStoreId","symbolForFormStateStoreId","hasOwnProperty","symbolForTPlExternalForEachItem","forEachItem","forEachIndex","symbolForTPlExternalForEachIndex","forEachSize","symbolForTPlExternalForEachSize","symbolForTPlExternalNoForEach","length","strict","isStrictMode","warnAboutStrictMode","asyncCheckBrickIf","brickName","startsWith","ensureValidControlBrick","lowerLevelRenderControlNode","_slots$slot","computedDataSource","slot","String","childrenToSlots","children","renderForEach","renderControlNode","rawOutput","PLACEHOLDER","controlledOutput","onMount","onUnmount","lifeCycle","contextNames","stateNames","getTracks","renderId","listener","currentRenderId","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","reControlledOutput","scopedStores","postAsyncRender","listenerFactory","CustomEvent","detail","rerender","reRender","store","mountAsyncData","debouncedListener","debounce","contextName","onChange","tplStateStore","getTplStateStore","registerArbitraryLifeCycle","test","customTemplates","get","catchLoad","unknownBricks","tplTagName","getTagNameOfCustomTemplate","app","id","tplCount","set","includes","customElements","FORM_RENDERER","FormRendererElement","HTMLElement","$$typeof","enqueueStableLoadBricks","formData","confProps","trackingContextList","asyncPropertyEntries","asyncComputeRealPropertyEntries","computedPropsFromHost","symbolForAsyncComputedPropsFromHost","isScript","props","constructAsyncProperties","src","rel","href","prefix","window","PUBLIC_ROOT","attrs","loadScript","loadStyle","events","portal","ref","usedProcessors","strictCollectMemberUsage","size","loadProcessorsImperatively","join","loadProperties","listenOnTrackingContext","registerBrickLifeCycle","expandedBrickConf","expandCustomTemplate","expandFormRenderer","childRuntimeContext","loadChildren","routeSlotFromIndexToSlotId","entries","childSlotId","slotConf","parentRoute","incrementalSubRoutes","performIncrementalRender","location","prevLocation","homepage","pathname","matchHomepage","every","prevMatch","newMatch","matchRoute","isEqual","params","query","URLSearchParams","search","failed","incrementalOutput","reBailout","reMergeMenuRequestNodes","result","reCatch","childrenOutput","has","mergeSiblingRenderMenuRequest","child","isTrackAll","isPreEvaluated","getPreEvaluatedRaw","i","j","flat","getDataStores","tplStateStoreMap","values","formStateStoreMap","stores","flushStableLoadBricks","waitForAll","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","promise","name","unknownPolicy","catch","e"],"sources":["../../../src/internal/Renderer.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n ContextConf,\n MenuConf,\n RouteConf,\n RouteConfOfBricks,\n SlotConfOfBricks,\n SlotsConf,\n StaticMenuConf,\n} from \"@next-core/types\";\nimport {\n enqueueStableLoadBricks,\n flushStableLoadBricks,\n loadBricksImperatively,\n loadProcessorsImperatively,\n loadScript,\n loadStyle,\n} from \"@next-core/loader\";\nimport { isTrackAll } from \"@next-core/cook\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { strictCollectMemberUsage } from \"@next-core/utils/storyboard\";\nimport { debounce, isEqual } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealPropertyEntries,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoute, matchRoutes } from \"./matchRoutes.js\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachIndex,\n symbolForTPlExternalForEachItem,\n symbolForTPlExternalForEachSize,\n symbolForTPlExternalNoForEach,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n MenuRequestNode,\n RenderBrick,\n RenderChildNode,\n RenderReturnNode,\n RuntimeBrickConfWithSymbols,\n RuntimeContext,\n} from \"./interfaces.js\";\nimport {\n getTagNameOfCustomTemplate,\n getTplStateStore,\n} from \"./CustomTemplates/utils.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport type { NextHistoryState } from \"./historyExtended.js\";\nimport { getBrickPackages, hooks } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport {\n FORM_RENDERER,\n RuntimeBrickConfOfFormSymbols,\n symbolForFormStateStoreId,\n} from \"./FormRenderer/constants.js\";\nimport { expandFormRenderer } from \"./FormRenderer/expandFormRenderer.js\";\nimport { isPreEvaluated } from \"./compute/evaluate.js\";\nimport { getPreEvaluatedRaw } from \"./compute/evaluate.js\";\nimport { RuntimeBrickConfOfTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { matchHomepage } from \"./matchStoryboard.js\";\nimport type { DataStore, DataStoreType } from \"./data/DataStore.js\";\nimport { listenerFactory } from \"./bindListeners.js\";\nimport type { MatchResult } from \"./matchPath.js\";\nimport { setupRootRuntimeContext } from \"./setupRootRuntimeContext.js\";\nimport { httpErrorToString } from \"../handleHttpError.js\";\nimport { setMatchedRoute } from \"./routeMatchedMap.js\";\n\nexport interface RenderOutput {\n node?: RenderChildNode;\n unauthenticated?: boolean;\n redirect?: {\n path: string;\n state?: NextHistoryState;\n };\n route?: RouteConf;\n path?: string;\n blockingList: (Promise<unknown> | undefined)[];\n menuRequestNode?: MenuRequestNode;\n hasTrackingControls?: boolean;\n}\n\nexport async function renderRoutes(\n returnNode: RenderReturnNode,\n routes: RouteConf[],\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n isIncremental?: boolean\n): Promise<RenderOutput> {\n const matched = await matchRoutes(routes, _runtimeContext);\n const output = getEmptyRenderOutput();\n const menuRequestNode: MenuRequestNode = (output.menuRequestNode = {\n return: menuRequestReturnNode,\n });\n switch (matched) {\n case \"missed\":\n break;\n case \"unauthenticated\":\n output.unauthenticated = true;\n break;\n default: {\n const route = (output.route = matched.route);\n output.path = matched.match.path;\n const runtimeContext = {\n ..._runtimeContext,\n match: matched.match,\n };\n\n if (route.iid) {\n setMatchedRoute(route.iid, matched.match);\n }\n\n if (isIncremental) {\n runtimeContext.ctxStore.disposeDataInRoutes(routes);\n }\n const routePath = parentRoutes.concat(route);\n runtimeContext.ctxStore.define(\n route.context,\n runtimeContext,\n undefined,\n routePath\n );\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n route,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n // Currently, this is only used for brick size-checking: these bricks\n // will be loaded before page rendering, but they will NOT be rendered.\n const { preLoadBricks } = route as { preLoadBricks?: string[] };\n if (Array.isArray(preLoadBricks)) {\n output.blockingList.push(\n loadBricksImperatively(preLoadBricks, getBrickPackages())\n );\n }\n\n if (route.type === \"redirect\") {\n let redirectTo: unknown;\n if (typeof route.redirect === \"string\") {\n redirectTo = await asyncComputeRealValue(\n route.redirect,\n runtimeContext\n );\n } else {\n const resolved = (await resolveData(\n {\n transform: \"redirect\",\n ...route.redirect,\n },\n runtimeContext\n )) as { redirect?: unknown };\n redirectTo = resolved.redirect;\n }\n if (typeof redirectTo !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected redirect result:\", redirectTo);\n throw new Error(\n `Unexpected type of redirect result: ${typeof redirectTo}`\n );\n }\n output.redirect = { path: redirectTo };\n } else {\n const menuRequest = loadMenu(route.menu, runtimeContext);\n if (menuRequest) {\n menuRequestNode.request = menuRequest;\n }\n\n if (!isIncremental) {\n rendererContext.memoizeMenuRequestNode(routes, menuRequestNode);\n }\n\n let newOutput: RenderOutput;\n if (route.type === \"routes\") {\n newOutput = await renderRoutes(\n returnNode,\n route.routes,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId\n );\n } else {\n newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId\n );\n }\n\n mergeRenderOutput(output, newOutput);\n appendMenuRequestNode(menuRequestNode, newOutput.menuRequestNode);\n }\n }\n }\n\n return output;\n}\n\nexport async function renderBricks(\n returnNode: RenderReturnNode,\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n tplStack?: Map<string, number>,\n keyPath?: number[]\n): Promise<RenderOutput> {\n setupRootRuntimeContext(bricks, runtimeContext, true);\n const output = getEmptyRenderOutput();\n const kPath = keyPath ?? [];\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf, index) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n kPath.concat(index),\n tplStack && new Map(tplStack)\n )\n )\n );\n\n rendered.forEach((item, index) => {\n if (item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n slotId,\n kPath.concat(index),\n item.node,\n returnNode\n );\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport async function renderBrick(\n returnNode: RenderReturnNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n keyPath: number[] = [],\n tplStack = new Map<string, number>()\n): Promise<RenderOutput> {\n try {\n return await legacyRenderBrick(\n returnNode,\n brickConf,\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath,\n tplStack\n );\n } catch (error) {\n if (brickConf.errorBoundary) {\n // eslint-disable-next-line no-console\n console.error(\"Error caught by error boundary:\", error);\n return {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n dataset: {\n errorBoundary: \"\",\n },\n style: {\n color: \"var(--color-error)\",\n },\n },\n runtimeContext: null!,\n return: returnNode,\n },\n blockingList: [],\n };\n } else {\n throw error;\n }\n }\n}\n\nasync function legacyRenderBrick(\n returnNode: RenderReturnNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId: string | undefined,\n keyPath: number[],\n tplStack: Map<string, number>\n): Promise<RenderOutput> {\n const output = getEmptyRenderOutput();\n\n if (!brickConf.brick) {\n if ((brickConf as { template?: string }).template) {\n // eslint-disable-next-line no-console\n console.error(\"Legacy templates are dropped in v3:\", brickConf);\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Invalid brick:\", brickConf);\n }\n return output;\n }\n\n // Translate `if: \"<%= ... %>\"` to `brick: \":if\", dataSource: \"<%= ... %>\"`.\n // In other words, translate tracking if expressions to tracking control nodes of `:if`.\n const { if: brickIf, permissionsPreCheck, ...restBrickConf } = brickConf;\n if (isGeneralizedTrackAll(brickIf)) {\n return renderBrick(\n returnNode,\n {\n brick: \":if\",\n dataSource: brickIf,\n // `permissionsPreCheck` maybe required before computing `if`.\n permissionsPreCheck,\n slots: {\n \"\": {\n type: \"bricks\",\n bricks: [restBrickConf],\n },\n },\n // These symbols have to be copied to the new brick conf.\n ...Object.getOwnPropertySymbols(brickConf).reduce(\n (acc, symbol) => ({\n ...acc,\n [symbol]: (brickConf as any)[symbol],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath,\n tplStack\n );\n }\n\n const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const formStateStoreId = brickConf[symbolForFormStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\n formStateStoreId,\n };\n\n if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {\n // The external bricks of a template should restore their `forEach*` from their host.\n runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];\n runtimeContext.forEachIndex = brickConf[symbolForTPlExternalForEachIndex];\n runtimeContext.forEachSize = brickConf[symbolForTPlExternalForEachSize];\n } else if (brickConf[symbolForTPlExternalNoForEach]) {\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n }\n\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\n const strict = isStrictMode(runtimeContext);\n warnAboutStrictMode(\n strict,\n \"Defining context on bricks\",\n \"check your brick:\",\n brickConf\n );\n if (!strict) {\n runtimeContext.ctxStore.define(context, runtimeContext);\n }\n }\n\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n brickConf,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {\n return output;\n }\n\n const brickName = brickConf.brick;\n if (brickName.startsWith(\":\")) {\n ensureValidControlBrick(brickName);\n\n const { dataSource } = brickConf;\n\n const lowerLevelRenderControlNode = async (\n runtimeContext: RuntimeContext\n ) => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n // Then, get the matched slot.\n const slot =\n brickName === \":forEach\"\n ? \"\"\n : brickName === \":switch\"\n ? String(computedDataSource)\n : computedDataSource\n ? \"\"\n : \"else\";\n\n // Don't forget to transpile children to slots.\n const slots = childrenToSlots(brickConf.children, brickConf.slots);\n\n // Then, get the bricks in that matched slot.\n const bricks =\n slots &&\n hasOwnProperty(slots, slot) &&\n (slots[slot] as SlotConfOfBricks)?.bricks;\n\n if (!Array.isArray(bricks)) {\n return getEmptyRenderOutput();\n }\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n return getEmptyRenderOutput();\n }\n return renderForEach(\n returnNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n keyPath\n );\n }\n case \":if\":\n case \":switch\": {\n return renderBricks(\n returnNode,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n keyPath\n );\n }\n }\n };\n\n const renderControlNode = async (runtimeContext: RuntimeContext) => {\n const rawOutput = await lowerLevelRenderControlNode(runtimeContext);\n rawOutput.node ??= {\n tag: RenderTag.PLACEHOLDER,\n return: returnNode,\n };\n return rawOutput;\n };\n\n const controlledOutput = await renderControlNode(runtimeContext);\n const { onMount, onUnmount } = brickConf.lifeCycle ?? {};\n\n const { contextNames, stateNames } = getTracks(dataSource);\n if (contextNames || stateNames) {\n controlledOutput.hasTrackingControls = true;\n let renderId = 0;\n const listener = async () => {\n const currentRenderId = ++renderId;\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext(runtimeContext);\n\n const reControlledOutput =\n await renderControlNode(scopedRuntimeContext);\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n await postAsyncRender(\n reControlledOutput,\n scopedRuntimeContext,\n scopedStores\n );\n\n // Ignore stale renders\n if (renderId === currentRenderId) {\n if (onUnmount) {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: true } }));\n }\n\n rendererContext.reRender(\n slotId,\n keyPath,\n reControlledOutput.node,\n returnNode\n );\n\n if (onMount) {\n listenerFactory(\n onMount,\n scopedRuntimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: true } }));\n }\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n }\n };\n const debouncedListener = debounce(listener);\n if (contextNames) {\n for (const contextName of contextNames) {\n runtimeContext.ctxStore.onChange(contextName, debouncedListener);\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n tplStateStore.onChange(contextName, debouncedListener);\n }\n }\n }\n\n if (onMount) {\n rendererContext.registerArbitraryLifeCycle(\"onMount\", () => {\n listenerFactory(\n onMount,\n runtimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: false } }));\n });\n }\n\n if (onUnmount) {\n rendererContext.registerArbitraryLifeCycle(\"onUnmount\", () => {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: false } }));\n });\n }\n\n return controlledOutput;\n }\n\n // Widgets need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await catchLoad(\n loadBricksImperatively([brickName], getBrickPackages()),\n \"brick\",\n brickName,\n rendererContext.unknownBricks\n );\n }\n\n const tplTagName = getTagNameOfCustomTemplate(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n customElements.define(\n FORM_RENDERER,\n class FormRendererElement extends HTMLElement {\n get $$typeof(): string {\n return \"form-renderer\";\n }\n }\n );\n } else {\n output.blockingList.push(\n catchLoad(\n enqueueStableLoadBricks([brickName], getBrickPackages()),\n \"brick\",\n brickName,\n rendererContext.unknownBricks\n )\n );\n }\n }\n\n let formData: unknown;\n let confProps: Record<string, unknown> | undefined;\n if (brickName === FORM_RENDERER) {\n ({ formData, ...confProps } = brickConf.properties ?? {});\n } else {\n confProps = brickConf.properties;\n }\n\n const trackingContextList: TrackingContextItem[] = [];\n const asyncPropertyEntries = asyncComputeRealPropertyEntries(\n confProps,\n runtimeContext,\n trackingContextList\n );\n\n const computedPropsFromHost = brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n asyncPropertyEntries.push(...computedPropsFromHost);\n }\n\n const isScript = brickName === \"script\";\n if (isScript || brickName === \"link\") {\n const props = await constructAsyncProperties(asyncPropertyEntries);\n if (isScript ? props.src : props.rel === \"stylesheet\" && props.href) {\n const prefix = window.PUBLIC_ROOT ?? \"\";\n if (isScript) {\n const { src, ...attrs } = props;\n await catchLoad(\n loadScript(src as string, prefix, attrs),\n \"script\",\n src as string,\n \"silent\"\n );\n } else {\n const { href, ...attrs } = props;\n await catchLoad(\n loadStyle(href as string, prefix, attrs),\n \"stylesheet\",\n href as string,\n \"silent\"\n );\n }\n return output;\n }\n }\n\n const brick: RenderBrick = {\n tag: RenderTag.BRICK,\n type: tplTagName || brickName,\n return: returnNode,\n slotId,\n events: brickConf.events,\n runtimeContext,\n portal: brickConf.portal,\n iid: brickConf.iid,\n ref: (brickConf as BrickConfInTemplate).ref,\n };\n\n output.node = brick;\n\n // 在最终挂载前,先加载所有可能用到的 processors。\n const usedProcessors = strictCollectMemberUsage(\n [brickConf.events, brickConf.lifeCycle],\n \"PROCESSORS\",\n 2\n );\n if (usedProcessors.size > 0) {\n output.blockingList.push(\n catchLoad(\n loadProcessorsImperatively(usedProcessors, getBrickPackages()),\n \"processors\",\n [...usedProcessors].join(\", \"),\n rendererContext.unknownBricks\n )\n );\n }\n\n // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const loadProperties = async () => {\n brick.properties = await constructAsyncProperties(asyncPropertyEntries);\n listenOnTrackingContext(brick, trackingContextList);\n };\n blockingList.push(loadProperties());\n\n rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);\n\n let expandedBrickConf = brickConf;\n if (tplTagName) {\n expandedBrickConf = expandCustomTemplate(\n tplTagName,\n brickConf,\n brick,\n asyncPropertyEntries,\n rendererContext\n );\n } else if (brickName === FORM_RENDERER) {\n expandedBrickConf = expandFormRenderer(\n formData,\n brickConf,\n brick,\n asyncPropertyEntries,\n rendererContext\n );\n }\n\n if (expandedBrickConf.portal) {\n // A portal brick has no slotId.\n brick.slotId = undefined;\n }\n\n let childRuntimeContext: RuntimeContext;\n if (tplTagName) {\n // There is a boundary for `forEachItem` between template internals and externals.\n childRuntimeContext = {\n ...runtimeContext,\n };\n delete childRuntimeContext.forEachItem;\n delete childRuntimeContext.forEachIndex;\n delete childRuntimeContext.forEachSize;\n } else {\n childRuntimeContext = runtimeContext;\n }\n\n const loadChildren = async () => {\n const slots = childrenToSlots(\n expandedBrickConf.children,\n expandedBrickConf.slots\n );\n if (!slots) {\n return;\n }\n const routeSlotFromIndexToSlotId = new Map<number, string>();\n const rendered = await Promise.all(\n Object.entries(slots).map(([childSlotId, slotConf], index) => {\n if (slotConf.type !== \"routes\") {\n return renderBricks(\n brick,\n (slotConf as SlotConfOfBricks).bricks,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n tplStack\n );\n }\n\n const parentRoute = parentRoutes[parentRoutes.length - 1] as\n | RouteConfOfBricks\n | undefined;\n if (parentRoute?.incrementalSubRoutes) {\n routeSlotFromIndexToSlotId.set(index, childSlotId);\n rendererContext.performIncrementalRender(\n slotConf,\n parentRoutes,\n async (location, prevLocation) => {\n const { homepage } = childRuntimeContext.app;\n const { pathname } = location;\n // Ignore if any one of homepage and parent routes not matched.\n if (\n !matchHomepage(homepage, pathname) ||\n !parentRoutes.every((route) => {\n let prevMatch: MatchResult | null;\n let newMatch: MatchResult | null;\n return (\n (prevMatch = matchRoute(\n route,\n homepage,\n prevLocation.pathname\n )) &&\n (newMatch = matchRoute(route, homepage, pathname)) &&\n (route !== parentRoute ||\n isEqual(prevMatch.params, newMatch.params))\n );\n })\n ) {\n return false;\n }\n\n const [\n scopedRuntimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n ] = createScopedRuntimeContext({\n ...childRuntimeContext,\n location,\n query: new URLSearchParams(location.search),\n });\n\n let failed = false;\n let incrementalOutput: RenderOutput;\n let scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n incrementalOutput = await renderRoutes(\n brick,\n slotConf.routes,\n scopedRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n true\n );\n\n // Do not ignore incremental rendering even if all sub-routes are missed.\n // Since parent route is matched.\n if (incrementalOutput.route) {\n // Bailout if redirect or unauthenticated is set\n if (rendererContext.reBailout(incrementalOutput)) {\n return true;\n }\n\n scopedStores = [\n ...tplStateStoreScope,\n ...formStateStoreScope,\n ];\n await postAsyncRender(\n incrementalOutput,\n scopedRuntimeContext,\n [scopedRuntimeContext.ctxStore, ...scopedStores]\n );\n }\n\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Incremental sub-router failed:\", error);\n\n const result = rendererContext.reCatch(error, brick);\n if (!result) {\n return true;\n }\n ({ failed, output: incrementalOutput } = result);\n\n // Assert: no errors will be throw\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n }\n\n rendererContext.reRender(\n childSlotId,\n [],\n incrementalOutput.node,\n brick\n );\n\n if (!failed) {\n scopedRuntimeContext.ctxStore.mountAsyncData(\n incrementalOutput.route\n );\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n }\n\n // When result is null, it means the incremental rendering is tried but routes missed.\n // In this case, we should continue to re-render the parent routes.\n return incrementalOutput.route ? true : null;\n }\n );\n }\n\n return renderRoutes(\n brick,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId\n );\n })\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n menuRequestNode: undefined,\n };\n rendered.forEach((item, index) => {\n if (routeSlotFromIndexToSlotId.has(index)) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n routeSlotFromIndexToSlotId.get(index),\n [],\n item.node,\n brick\n );\n }\n mergeRenderOutput(childrenOutput, item);\n mergeSiblingRenderMenuRequest(childrenOutput, item);\n });\n if (childrenOutput.node) {\n brick.child = childrenOutput.node;\n }\n mergeRenderOutput(output, {\n ...childrenOutput,\n node: undefined,\n });\n\n appendMenuRequestNode(\n menuRequestReturnNode,\n (output.menuRequestNode = childrenOutput.menuRequestNode)\n );\n };\n blockingList.push(loadChildren());\n\n await Promise.all(blockingList);\n\n return output;\n}\n\nfunction isGeneralizedTrackAll(brickIf: unknown): boolean {\n return typeof brickIf === \"string\"\n ? isTrackAll(brickIf)\n : isPreEvaluated(brickIf) &&\n // istanbul ignore next: covered by e2e tests\n isTrackAll(getPreEvaluatedRaw(brickIf));\n}\n\ntype ValidControlBrick = \":forEach\" | \":if\" | \":switch\";\n\nfunction ensureValidControlBrick(\n brick: string\n): asserts brick is ValidControlBrick {\n if (brick !== \":forEach\" && brick !== \":if\" && brick !== \":switch\") {\n throw new Error(`Unknown storyboard control node: \"${brick}\"`);\n }\n}\n\nasync function renderForEach(\n returnNode: RenderReturnNode,\n dataSource: unknown[],\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId: string | undefined,\n tplStack: Map<string, number>,\n keyPath: number[]\n): Promise<RenderOutput> {\n const output = getEmptyRenderOutput();\n\n const size = dataSource.length;\n const rendered = await Promise.all(\n dataSource.map((item, i) =>\n Promise.all(\n bricks.map((brickConf, j) =>\n renderBrick(\n returnNode,\n brickConf,\n {\n ...runtimeContext,\n forEachItem: item,\n forEachIndex: i,\n forEachSize: size,\n },\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath.concat(i * size + j),\n tplStack && new Map(tplStack)\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n rendered.flat().forEach((item, index) => {\n if (item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n slotId,\n keyPath.concat(index),\n item.node,\n returnNode\n );\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport function getDataStores(runtimeContext: RuntimeContext) {\n return [\n runtimeContext.ctxStore,\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ];\n}\n\nexport function postAsyncRender(\n output: RenderOutput,\n runtimeContext: RuntimeContext,\n stores: DataStore<DataStoreType>[]\n) {\n flushStableLoadBricks();\n\n return Promise.all([\n ...output.blockingList,\n ...stores.map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n}\n\nexport function createScopedRuntimeContext(\n runtimeContext: RuntimeContext\n): [\n scopedRuntimeContext: RuntimeContext,\n tplStateStoreScope: DataStore<\"STATE\">[],\n formStateStoreScope: DataStore<\"FORM_STATE\">[],\n] {\n const tplStateStoreScope: DataStore<\"STATE\">[] = [];\n const formStateStoreScope: DataStore<\"FORM_STATE\">[] = [];\n const scopedRuntimeContext: RuntimeContext = {\n ...runtimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n };\n return [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope];\n}\n\nfunction loadMenu(\n menuConf: MenuConf | undefined,\n runtimeContext: RuntimeContext\n) {\n if (!menuConf) {\n return;\n }\n\n // istanbul ignore next\n if ((menuConf as { type?: \"brick\" }).type === \"brick\") {\n // eslint-disable-next-line no-console\n console.error(\"Set menu with brick is dropped in v3:\", menuConf);\n throw new Error(\"Set menu with brick is dropped in v3\");\n }\n\n // istanbul ignore next\n if (menuConf.type === \"resolve\") {\n // eslint-disable-next-line no-console\n console.warn(\"Set menu with resolve is not supported in v3 yet:\", menuConf);\n return;\n }\n\n return asyncComputeRealValue(\n menuConf,\n runtimeContext\n ) as Promise<StaticMenuConf>;\n}\n\nfunction mergeRenderOutput(\n output: RenderOutput,\n newOutput: RenderOutput\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { blockingList, node, menuRequestNode, hasTrackingControls, ...rest } =\n newOutput;\n output.blockingList.push(...blockingList);\n\n if (node) {\n if (output.node) {\n let last = output.node;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = node;\n } else {\n output.node = node;\n }\n }\n\n Object.assign(output, rest);\n}\n\nfunction mergeSiblingRenderMenuRequest(\n output: RenderOutput,\n newOutput: RenderOutput\n) {\n const menuRequestNode = newOutput.menuRequestNode;\n if (menuRequestNode) {\n if (output.menuRequestNode) {\n let last = output.menuRequestNode;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = menuRequestNode;\n } else {\n output.menuRequestNode = menuRequestNode;\n }\n }\n}\n\nfunction appendMenuRequestNode(\n menuRequestReturnNode: MenuRequestNode,\n menuRequestNode: MenuRequestNode | undefined\n) {\n if (!menuRequestNode) {\n return;\n }\n if (menuRequestReturnNode.child) {\n let last = menuRequestReturnNode.child;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = menuRequestNode;\n } else {\n menuRequestReturnNode.child = menuRequestNode;\n }\n}\n\nfunction getEmptyRenderOutput(): RenderOutput {\n return { blockingList: [] };\n}\n\nexport function childrenToSlots(\n children: BrickConf[] | undefined,\n originalSlots: SlotsConf | undefined\n) {\n let newSlots = originalSlots;\n // istanbul ignore next\n if (\n process.env.NODE_ENV === \"development\" &&\n children &&\n !Array.isArray(children)\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Specified brick children but not array:\",\n `<${typeof children}>`,\n children\n );\n }\n if (Array.isArray(children) && !newSlots) {\n newSlots = {};\n for (const child of children) {\n const slot = child.slot ?? \"\";\n if (!hasOwnProperty(newSlots, slot)) {\n newSlots[slot] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n (newSlots[slot] as SlotConfOfBricks).bricks.push(child);\n }\n }\n return newSlots;\n}\n\nfunction catchLoad(\n promise: Promise<unknown>,\n type: \"brick\" | \"processors\" | \"script\" | \"stylesheet\",\n name: string,\n unknownPolicy: RendererContext[\"unknownBricks\"]\n) {\n return unknownPolicy === \"silent\"\n ? promise.catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Load %s \"%s\" failed:`, type, name, e);\n })\n : promise;\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAAA,OAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AAIA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AACA,IAAAS,wBAAA,GAAAT,OAAA;AAKA,IAAAU,YAAA,GAAAV,OAAA;AAC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AQ,KAAK,aAAa,IACtC/I,QAAQ,IACR,CAAC9F,KAAK,CAACC,OAAO,CAAC6F,QAAQ,CAAC,EACxB;IACA;IACAnF,OAAO,CAACyN,IAAI,CACV,yCAAyC,EACzC,IAAI,OAAOtI,QAAQ,GAAG,EACtBA,QACF,CAAC;EACH;EACA,IAAI9F,KAAK,CAACC,OAAO,CAAC6F,QAAQ,CAAC,IAAI,CAAC4I,QAAQ,EAAE;IACxCA,QAAQ,GAAG,CAAC,CAAC;IACb,KAAK,MAAMrB,KAAK,IAAIvH,QAAQ,EAAE;MAC5B,MAAMH,IAAI,GAAG0H,KAAK,CAAC1H,IAAI,IAAI,EAAE;MAC7B,IAAI,CAAC,IAAAnB,uBAAc,EAACkK,QAAQ,EAAE/I,IAAI,CAAC,EAAE;QACnC+I,QAAQ,CAAC/I,IAAI,CAAC,GAAG;UACftF,IAAI,EAAE,QAAQ;UACdgB,MAAM,EAAE;QACV,CAAC;MACH;MACCqN,QAAQ,CAAC/I,IAAI,CAAC,CAAsBtE,MAAM,CAAC5B,IAAI,CAAC4N,KAAK,CAAC;IACzD;EACF;EACA,OAAOqB,QAAQ;AACjB;AAEA,SAASrG,SAASA,CAChByG,OAAyB,EACzBzO,IAAsD,EACtD0O,IAAY,EACZC,aAA+C,EAC/C;EACA,OAAOA,aAAa,KAAK,QAAQ,GAC7BF,OAAO,CAACG,KAAK,CAAEC,CAAC,IAAK;IACnB;IACAvO,OAAO,CAACC,KAAK,CAAC,sBAAsB,EAAEP,IAAI,EAAE0O,IAAI,EAAEG,CAAC,CAAC;EACtD,CAAC,CAAC,GACFJ,OAAO;AACb","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Renderer.js","names":["_loader","require","_cook","_general","_storyboard","_lodash","_checkIf","_computeRealProperties","_resolveData","_computeRealValue","_listenOnTrackingContext","_matchRoutes","_constants","_expandCustomTemplate","_utils","_CustomTemplates","_Runtime","_enums","_getTracks","_isStrictMode","_constants2","_expandFormRenderer","_evaluate","_matchStoryboard","_bindListeners","_setupRootRuntimeContext","_handleHttpError","_routeMatchedMap","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","parentRoutes","menuRequestReturnNode","slotId","isIncremental","matched","matchRoutes","output","getEmptyRenderOutput","menuRequestNode","return","unauthenticated","_hooks$checkPermissio","route","path","match","runtimeContext","iid","setMatchedRoute","ctxStore","disposeDataInRoutes","routePath","concat","define","context","undefined","pendingPermissionsPreCheck","push","hooks","checkPermissions","preCheckPermissionsForBrickOrRoute","value","asyncComputeRealValue","preLoadBricks","Array","isArray","blockingList","loadBricksImperatively","getBrickPackages","type","redirectTo","redirect","resolved","resolveData","transform","console","error","Error","menuRequest","loadMenu","menu","request","memoizeMenuRequestNode","newOutput","renderBricks","bricks","mergeRenderOutput","appendMenuRequestNode","tplStack","keyPath","setupRootRuntimeContext","kPath","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoize","node","legacyRenderBrick","errorBoundary","tag","RenderTag","BRICK","properties","textContent","httpErrorToString","dataset","style","color","_hooks$checkPermissio2","_runtimeContext$app","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","symbolForTplStateStoreId","formStateStoreId","symbolForFormStateStoreId","hasOwnProperty","symbolForTPlExternalForEachItem","forEachItem","forEachIndex","symbolForTPlExternalForEachIndex","forEachSize","symbolForTPlExternalForEachSize","symbolForTPlExternalNoForEach","length","strict","isStrictMode","warnAboutStrictMode","asyncCheckBrickIf","brickName","startsWith","ensureValidControlBrick","lowerLevelRenderControlNode","_slots$slot","computedDataSource","slot","String","childrenToSlots","children","renderForEach","renderControlNode","rawOutput","PLACEHOLDER","controlledOutput","onMount","onUnmount","lifeCycle","contextNames","stateNames","getTracks","renderId","listener","currentRenderId","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","reControlledOutput","scopedStores","postAsyncRender","listenerFactory","CustomEvent","detail","rerender","reRender","store","mountAsyncData","debouncedListener","debounce","contextName","onChange","tplStateStore","getTplStateStore","registerArbitraryLifeCycle","test","customTemplates","get","catchLoad","unknownBricks","tplTagName","getTagNameOfCustomTemplate","app","id","tplCount","set","includes","customElements","FORM_RENDERER","FormRendererElement","HTMLElement","$$typeof","enqueueStableLoadBricks","formData","confProps","_brickConf$properties","compute","trackingContextList","asyncPropertyEntries","asyncComputeRealPropertyEntries","computedPropsFromHost","symbolForAsyncComputedPropsFromHost","isScript","props","constructAsyncProperties","src","rel","href","prefix","window","PUBLIC_ROOT","attrs","loadScript","loadStyle","events","portal","ref","usedProcessors","strictCollectMemberUsage","size","loadProcessorsImperatively","join","loadProperties","listenOnTrackingContext","registerBrickLifeCycle","expandedBrickConf","expandCustomTemplate","expandFormRenderer","childRuntimeContext","loadChildren","routeSlotFromIndexToSlotId","entries","childSlotId","slotConf","parentRoute","incrementalSubRoutes","performIncrementalRender","location","prevLocation","homepage","pathname","matchHomepage","every","prevMatch","newMatch","matchRoute","isEqual","params","query","URLSearchParams","search","failed","incrementalOutput","reBailout","reMergeMenuRequestNodes","result","reCatch","childrenOutput","has","mergeSiblingRenderMenuRequest","child","isTrackAll","isPreEvaluated","getPreEvaluatedRaw","i","j","flat","getDataStores","tplStateStoreMap","values","formStateStoreMap","stores","flushStableLoadBricks","waitForAll","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","promise","name","unknownPolicy","catch","e"],"sources":["../../../src/internal/Renderer.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n ContextConf,\n MenuConf,\n RouteConf,\n RouteConfOfBricks,\n SlotConfOfBricks,\n SlotsConf,\n StaticMenuConf,\n} from \"@next-core/types\";\nimport {\n enqueueStableLoadBricks,\n flushStableLoadBricks,\n loadBricksImperatively,\n loadProcessorsImperatively,\n loadScript,\n loadStyle,\n} from \"@next-core/loader\";\nimport { isTrackAll } from \"@next-core/cook\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { strictCollectMemberUsage } from \"@next-core/utils/storyboard\";\nimport { debounce, isEqual } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealPropertyEntries,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoute, matchRoutes } from \"./matchRoutes.js\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachIndex,\n symbolForTPlExternalForEachItem,\n symbolForTPlExternalForEachSize,\n symbolForTPlExternalNoForEach,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n MenuRequestNode,\n RenderBrick,\n RenderChildNode,\n RenderReturnNode,\n RuntimeBrickConfWithSymbols,\n RuntimeContext,\n} from \"./interfaces.js\";\nimport {\n getTagNameOfCustomTemplate,\n getTplStateStore,\n} from \"./CustomTemplates/utils.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport type { NextHistoryState } from \"./historyExtended.js\";\nimport { getBrickPackages, hooks } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport {\n FORM_RENDERER,\n RuntimeBrickConfOfFormSymbols,\n symbolForFormStateStoreId,\n} from \"./FormRenderer/constants.js\";\nimport { expandFormRenderer } from \"./FormRenderer/expandFormRenderer.js\";\nimport { isPreEvaluated } from \"./compute/evaluate.js\";\nimport { getPreEvaluatedRaw } from \"./compute/evaluate.js\";\nimport { RuntimeBrickConfOfTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { matchHomepage } from \"./matchStoryboard.js\";\nimport type { DataStore, DataStoreType } from \"./data/DataStore.js\";\nimport { listenerFactory } from \"./bindListeners.js\";\nimport type { MatchResult } from \"./matchPath.js\";\nimport { setupRootRuntimeContext } from \"./setupRootRuntimeContext.js\";\nimport { httpErrorToString } from \"../handleHttpError.js\";\nimport { setMatchedRoute } from \"./routeMatchedMap.js\";\n\nexport interface RenderOutput {\n node?: RenderChildNode;\n unauthenticated?: boolean;\n redirect?: {\n path: string;\n state?: NextHistoryState;\n };\n route?: RouteConf;\n path?: string;\n blockingList: (Promise<unknown> | undefined)[];\n menuRequestNode?: MenuRequestNode;\n hasTrackingControls?: boolean;\n}\n\nexport async function renderRoutes(\n returnNode: RenderReturnNode,\n routes: RouteConf[],\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n isIncremental?: boolean\n): Promise<RenderOutput> {\n const matched = await matchRoutes(routes, _runtimeContext);\n const output = getEmptyRenderOutput();\n const menuRequestNode: MenuRequestNode = (output.menuRequestNode = {\n return: menuRequestReturnNode,\n });\n switch (matched) {\n case \"missed\":\n break;\n case \"unauthenticated\":\n output.unauthenticated = true;\n break;\n default: {\n const route = (output.route = matched.route);\n output.path = matched.match.path;\n const runtimeContext = {\n ..._runtimeContext,\n match: matched.match,\n };\n\n if (route.iid) {\n setMatchedRoute(route.iid, matched.match);\n }\n\n if (isIncremental) {\n runtimeContext.ctxStore.disposeDataInRoutes(routes);\n }\n const routePath = parentRoutes.concat(route);\n runtimeContext.ctxStore.define(\n route.context,\n runtimeContext,\n undefined,\n routePath\n );\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n route,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n // Currently, this is only used for brick size-checking: these bricks\n // will be loaded before page rendering, but they will NOT be rendered.\n const { preLoadBricks } = route as { preLoadBricks?: string[] };\n if (Array.isArray(preLoadBricks)) {\n output.blockingList.push(\n loadBricksImperatively(preLoadBricks, getBrickPackages())\n );\n }\n\n if (route.type === \"redirect\") {\n let redirectTo: unknown;\n if (typeof route.redirect === \"string\") {\n redirectTo = await asyncComputeRealValue(\n route.redirect,\n runtimeContext\n );\n } else {\n const resolved = (await resolveData(\n {\n transform: \"redirect\",\n ...route.redirect,\n },\n runtimeContext\n )) as { redirect?: unknown };\n redirectTo = resolved.redirect;\n }\n if (typeof redirectTo !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected redirect result:\", redirectTo);\n throw new Error(\n `Unexpected type of redirect result: ${typeof redirectTo}`\n );\n }\n output.redirect = { path: redirectTo };\n } else {\n const menuRequest = loadMenu(route.menu, runtimeContext);\n if (menuRequest) {\n menuRequestNode.request = menuRequest;\n }\n\n if (!isIncremental) {\n rendererContext.memoizeMenuRequestNode(routes, menuRequestNode);\n }\n\n let newOutput: RenderOutput;\n if (route.type === \"routes\") {\n newOutput = await renderRoutes(\n returnNode,\n route.routes,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId\n );\n } else {\n newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId\n );\n }\n\n mergeRenderOutput(output, newOutput);\n appendMenuRequestNode(menuRequestNode, newOutput.menuRequestNode);\n }\n }\n }\n\n return output;\n}\n\nexport async function renderBricks(\n returnNode: RenderReturnNode,\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n tplStack?: Map<string, number>,\n keyPath?: number[]\n): Promise<RenderOutput> {\n setupRootRuntimeContext(bricks, runtimeContext, true);\n const output = getEmptyRenderOutput();\n const kPath = keyPath ?? [];\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf, index) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n kPath.concat(index),\n tplStack && new Map(tplStack)\n )\n )\n );\n\n rendered.forEach((item, index) => {\n if (item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n slotId,\n kPath.concat(index),\n item.node,\n returnNode\n );\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport async function renderBrick(\n returnNode: RenderReturnNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n keyPath: number[] = [],\n tplStack = new Map<string, number>()\n): Promise<RenderOutput> {\n try {\n return await legacyRenderBrick(\n returnNode,\n brickConf,\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath,\n tplStack\n );\n } catch (error) {\n if (brickConf.errorBoundary) {\n // eslint-disable-next-line no-console\n console.error(\"Error caught by error boundary:\", error);\n return {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n dataset: {\n errorBoundary: \"\",\n },\n style: {\n color: \"var(--color-error)\",\n },\n },\n runtimeContext: null!,\n return: returnNode,\n },\n blockingList: [],\n };\n } else {\n throw error;\n }\n }\n}\n\nasync function legacyRenderBrick(\n returnNode: RenderReturnNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId: string | undefined,\n keyPath: number[],\n tplStack: Map<string, number>\n): Promise<RenderOutput> {\n const output = getEmptyRenderOutput();\n\n if (!brickConf.brick) {\n if ((brickConf as { template?: string }).template) {\n // eslint-disable-next-line no-console\n console.error(\"Legacy templates are dropped in v3:\", brickConf);\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Invalid brick:\", brickConf);\n }\n return output;\n }\n\n // Translate `if: \"<%= ... %>\"` to `brick: \":if\", dataSource: \"<%= ... %>\"`.\n // In other words, translate tracking if expressions to tracking control nodes of `:if`.\n const { if: brickIf, permissionsPreCheck, ...restBrickConf } = brickConf;\n if (isGeneralizedTrackAll(brickIf)) {\n return renderBrick(\n returnNode,\n {\n brick: \":if\",\n dataSource: brickIf,\n // `permissionsPreCheck` maybe required before computing `if`.\n permissionsPreCheck,\n slots: {\n \"\": {\n type: \"bricks\",\n bricks: [restBrickConf],\n },\n },\n // These symbols have to be copied to the new brick conf.\n ...Object.getOwnPropertySymbols(brickConf).reduce(\n (acc, symbol) => ({\n ...acc,\n [symbol]: (brickConf as any)[symbol],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath,\n tplStack\n );\n }\n\n const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const formStateStoreId = brickConf[symbolForFormStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\n formStateStoreId,\n };\n\n if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {\n // The external bricks of a template should restore their `forEach*` from their host.\n runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];\n runtimeContext.forEachIndex = brickConf[symbolForTPlExternalForEachIndex];\n runtimeContext.forEachSize = brickConf[symbolForTPlExternalForEachSize];\n } else if (brickConf[symbolForTPlExternalNoForEach]) {\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n }\n\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\n const strict = isStrictMode(runtimeContext);\n warnAboutStrictMode(\n strict,\n \"Defining context on bricks\",\n \"check your brick:\",\n brickConf\n );\n if (!strict) {\n runtimeContext.ctxStore.define(context, runtimeContext);\n }\n }\n\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n brickConf,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {\n return output;\n }\n\n const brickName = brickConf.brick;\n if (brickName.startsWith(\":\")) {\n ensureValidControlBrick(brickName);\n\n const { dataSource } = brickConf;\n\n const lowerLevelRenderControlNode = async (\n runtimeContext: RuntimeContext\n ) => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n // Then, get the matched slot.\n const slot =\n brickName === \":forEach\"\n ? \"\"\n : brickName === \":switch\"\n ? String(computedDataSource)\n : computedDataSource\n ? \"\"\n : \"else\";\n\n // Don't forget to transpile children to slots.\n const slots = childrenToSlots(brickConf.children, brickConf.slots);\n\n // Then, get the bricks in that matched slot.\n const bricks =\n slots &&\n hasOwnProperty(slots, slot) &&\n (slots[slot] as SlotConfOfBricks)?.bricks;\n\n if (!Array.isArray(bricks)) {\n return getEmptyRenderOutput();\n }\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n return getEmptyRenderOutput();\n }\n return renderForEach(\n returnNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n keyPath\n );\n }\n case \":if\":\n case \":switch\": {\n return renderBricks(\n returnNode,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n keyPath\n );\n }\n }\n };\n\n const renderControlNode = async (runtimeContext: RuntimeContext) => {\n const rawOutput = await lowerLevelRenderControlNode(runtimeContext);\n rawOutput.node ??= {\n tag: RenderTag.PLACEHOLDER,\n return: returnNode,\n };\n return rawOutput;\n };\n\n const controlledOutput = await renderControlNode(runtimeContext);\n const { onMount, onUnmount } = brickConf.lifeCycle ?? {};\n\n const { contextNames, stateNames } = getTracks(dataSource);\n if (contextNames || stateNames) {\n controlledOutput.hasTrackingControls = true;\n let renderId = 0;\n const listener = async () => {\n const currentRenderId = ++renderId;\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext(runtimeContext);\n\n const reControlledOutput =\n await renderControlNode(scopedRuntimeContext);\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n await postAsyncRender(\n reControlledOutput,\n scopedRuntimeContext,\n scopedStores\n );\n\n // Ignore stale renders\n if (renderId === currentRenderId) {\n if (onUnmount) {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: true } }));\n }\n\n rendererContext.reRender(\n slotId,\n keyPath,\n reControlledOutput.node,\n returnNode\n );\n\n if (onMount) {\n listenerFactory(\n onMount,\n scopedRuntimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: true } }));\n }\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n }\n };\n const debouncedListener = debounce(listener);\n if (contextNames) {\n for (const contextName of contextNames) {\n runtimeContext.ctxStore.onChange(contextName, debouncedListener);\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n tplStateStore.onChange(contextName, debouncedListener);\n }\n }\n }\n\n if (onMount) {\n rendererContext.registerArbitraryLifeCycle(\"onMount\", () => {\n listenerFactory(\n onMount,\n runtimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: false } }));\n });\n }\n\n if (onUnmount) {\n rendererContext.registerArbitraryLifeCycle(\"onUnmount\", () => {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: false } }));\n });\n }\n\n return controlledOutput;\n }\n\n // Widgets need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await catchLoad(\n loadBricksImperatively([brickName], getBrickPackages()),\n \"brick\",\n brickName,\n rendererContext.unknownBricks\n );\n }\n\n const tplTagName = getTagNameOfCustomTemplate(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n customElements.define(\n FORM_RENDERER,\n class FormRendererElement extends HTMLElement {\n get $$typeof(): string {\n return \"form-renderer\";\n }\n }\n );\n } else {\n output.blockingList.push(\n catchLoad(\n enqueueStableLoadBricks([brickName], getBrickPackages()),\n \"brick\",\n brickName,\n rendererContext.unknownBricks\n )\n );\n }\n }\n\n let formData: unknown;\n let confProps: Record<string, unknown> | undefined;\n if (brickName === FORM_RENDERER) {\n ({ formData, ...confProps } = brickConf.properties ?? {});\n\n if (brickConf.properties?.compute) {\n formData = await asyncComputeRealValue(formData, runtimeContext);\n }\n } else {\n confProps = brickConf.properties;\n }\n\n const trackingContextList: TrackingContextItem[] = [];\n const asyncPropertyEntries = asyncComputeRealPropertyEntries(\n confProps,\n runtimeContext,\n trackingContextList\n );\n\n const computedPropsFromHost = brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n asyncPropertyEntries.push(...computedPropsFromHost);\n }\n\n const isScript = brickName === \"script\";\n if (isScript || brickName === \"link\") {\n const props = await constructAsyncProperties(asyncPropertyEntries);\n if (isScript ? props.src : props.rel === \"stylesheet\" && props.href) {\n const prefix = window.PUBLIC_ROOT ?? \"\";\n if (isScript) {\n const { src, ...attrs } = props;\n await catchLoad(\n loadScript(src as string, prefix, attrs),\n \"script\",\n src as string,\n \"silent\"\n );\n } else {\n const { href, ...attrs } = props;\n await catchLoad(\n loadStyle(href as string, prefix, attrs),\n \"stylesheet\",\n href as string,\n \"silent\"\n );\n }\n return output;\n }\n }\n\n const brick: RenderBrick = {\n tag: RenderTag.BRICK,\n type: tplTagName || brickName,\n return: returnNode,\n slotId,\n events: brickConf.events,\n runtimeContext,\n portal: brickConf.portal,\n iid: brickConf.iid,\n ref: (brickConf as BrickConfInTemplate).ref,\n };\n\n output.node = brick;\n\n // 在最终挂载前,先加载所有可能用到的 processors。\n const usedProcessors = strictCollectMemberUsage(\n [brickConf.events, brickConf.lifeCycle],\n \"PROCESSORS\",\n 2\n );\n if (usedProcessors.size > 0) {\n output.blockingList.push(\n catchLoad(\n loadProcessorsImperatively(usedProcessors, getBrickPackages()),\n \"processors\",\n [...usedProcessors].join(\", \"),\n rendererContext.unknownBricks\n )\n );\n }\n\n // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const loadProperties = async () => {\n brick.properties = await constructAsyncProperties(asyncPropertyEntries);\n listenOnTrackingContext(brick, trackingContextList);\n };\n blockingList.push(loadProperties());\n\n rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);\n\n let expandedBrickConf = brickConf;\n if (tplTagName) {\n expandedBrickConf = expandCustomTemplate(\n tplTagName,\n brickConf,\n brick,\n asyncPropertyEntries,\n rendererContext\n );\n } else if (brickName === FORM_RENDERER) {\n expandedBrickConf = expandFormRenderer(\n formData,\n brickConf,\n brick,\n asyncPropertyEntries,\n rendererContext\n );\n }\n\n if (expandedBrickConf.portal) {\n // A portal brick has no slotId.\n brick.slotId = undefined;\n }\n\n let childRuntimeContext: RuntimeContext;\n if (tplTagName) {\n // There is a boundary for `forEachItem` between template internals and externals.\n childRuntimeContext = {\n ...runtimeContext,\n };\n delete childRuntimeContext.forEachItem;\n delete childRuntimeContext.forEachIndex;\n delete childRuntimeContext.forEachSize;\n } else {\n childRuntimeContext = runtimeContext;\n }\n\n const loadChildren = async () => {\n const slots = childrenToSlots(\n expandedBrickConf.children,\n expandedBrickConf.slots\n );\n if (!slots) {\n return;\n }\n const routeSlotFromIndexToSlotId = new Map<number, string>();\n const rendered = await Promise.all(\n Object.entries(slots).map(([childSlotId, slotConf], index) => {\n if (slotConf.type !== \"routes\") {\n return renderBricks(\n brick,\n (slotConf as SlotConfOfBricks).bricks,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n tplStack\n );\n }\n\n const parentRoute = parentRoutes[parentRoutes.length - 1] as\n | RouteConfOfBricks\n | undefined;\n if (parentRoute?.incrementalSubRoutes) {\n routeSlotFromIndexToSlotId.set(index, childSlotId);\n rendererContext.performIncrementalRender(\n slotConf,\n parentRoutes,\n async (location, prevLocation) => {\n const { homepage } = childRuntimeContext.app;\n const { pathname } = location;\n // Ignore if any one of homepage and parent routes not matched.\n if (\n !matchHomepage(homepage, pathname) ||\n !parentRoutes.every((route) => {\n let prevMatch: MatchResult | null;\n let newMatch: MatchResult | null;\n return (\n (prevMatch = matchRoute(\n route,\n homepage,\n prevLocation.pathname\n )) &&\n (newMatch = matchRoute(route, homepage, pathname)) &&\n (route !== parentRoute ||\n isEqual(prevMatch.params, newMatch.params))\n );\n })\n ) {\n return false;\n }\n\n const [\n scopedRuntimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n ] = createScopedRuntimeContext({\n ...childRuntimeContext,\n location,\n query: new URLSearchParams(location.search),\n });\n\n let failed = false;\n let incrementalOutput: RenderOutput;\n let scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n incrementalOutput = await renderRoutes(\n brick,\n slotConf.routes,\n scopedRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n true\n );\n\n // Do not ignore incremental rendering even if all sub-routes are missed.\n // Since parent route is matched.\n if (incrementalOutput.route) {\n // Bailout if redirect or unauthenticated is set\n if (rendererContext.reBailout(incrementalOutput)) {\n return true;\n }\n\n scopedStores = [\n ...tplStateStoreScope,\n ...formStateStoreScope,\n ];\n await postAsyncRender(\n incrementalOutput,\n scopedRuntimeContext,\n [scopedRuntimeContext.ctxStore, ...scopedStores]\n );\n }\n\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Incremental sub-router failed:\", error);\n\n const result = rendererContext.reCatch(error, brick);\n if (!result) {\n return true;\n }\n ({ failed, output: incrementalOutput } = result);\n\n // Assert: no errors will be throw\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n }\n\n rendererContext.reRender(\n childSlotId,\n [],\n incrementalOutput.node,\n brick\n );\n\n if (!failed) {\n scopedRuntimeContext.ctxStore.mountAsyncData(\n incrementalOutput.route\n );\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n }\n\n // When result is null, it means the incremental rendering is tried but routes missed.\n // In this case, we should continue to re-render the parent routes.\n return incrementalOutput.route ? true : null;\n }\n );\n }\n\n return renderRoutes(\n brick,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId\n );\n })\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n menuRequestNode: undefined,\n };\n rendered.forEach((item, index) => {\n if (routeSlotFromIndexToSlotId.has(index)) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n routeSlotFromIndexToSlotId.get(index),\n [],\n item.node,\n brick\n );\n }\n mergeRenderOutput(childrenOutput, item);\n mergeSiblingRenderMenuRequest(childrenOutput, item);\n });\n if (childrenOutput.node) {\n brick.child = childrenOutput.node;\n }\n mergeRenderOutput(output, {\n ...childrenOutput,\n node: undefined,\n });\n\n appendMenuRequestNode(\n menuRequestReturnNode,\n (output.menuRequestNode = childrenOutput.menuRequestNode)\n );\n };\n blockingList.push(loadChildren());\n\n await Promise.all(blockingList);\n\n return output;\n}\n\nfunction isGeneralizedTrackAll(brickIf: unknown): boolean {\n return typeof brickIf === \"string\"\n ? isTrackAll(brickIf)\n : isPreEvaluated(brickIf) &&\n // istanbul ignore next: covered by e2e tests\n isTrackAll(getPreEvaluatedRaw(brickIf));\n}\n\ntype ValidControlBrick = \":forEach\" | \":if\" | \":switch\";\n\nfunction ensureValidControlBrick(\n brick: string\n): asserts brick is ValidControlBrick {\n if (brick !== \":forEach\" && brick !== \":if\" && brick !== \":switch\") {\n throw new Error(`Unknown storyboard control node: \"${brick}\"`);\n }\n}\n\nasync function renderForEach(\n returnNode: RenderReturnNode,\n dataSource: unknown[],\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId: string | undefined,\n tplStack: Map<string, number>,\n keyPath: number[]\n): Promise<RenderOutput> {\n const output = getEmptyRenderOutput();\n\n const size = dataSource.length;\n const rendered = await Promise.all(\n dataSource.map((item, i) =>\n Promise.all(\n bricks.map((brickConf, j) =>\n renderBrick(\n returnNode,\n brickConf,\n {\n ...runtimeContext,\n forEachItem: item,\n forEachIndex: i,\n forEachSize: size,\n },\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath.concat(i * size + j),\n tplStack && new Map(tplStack)\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n rendered.flat().forEach((item, index) => {\n if (item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n slotId,\n keyPath.concat(index),\n item.node,\n returnNode\n );\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport function getDataStores(runtimeContext: RuntimeContext) {\n return [\n runtimeContext.ctxStore,\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ];\n}\n\nexport function postAsyncRender(\n output: RenderOutput,\n runtimeContext: RuntimeContext,\n stores: DataStore<DataStoreType>[]\n) {\n flushStableLoadBricks();\n\n return Promise.all([\n ...output.blockingList,\n ...stores.map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n}\n\nexport function createScopedRuntimeContext(\n runtimeContext: RuntimeContext\n): [\n scopedRuntimeContext: RuntimeContext,\n tplStateStoreScope: DataStore<\"STATE\">[],\n formStateStoreScope: DataStore<\"FORM_STATE\">[],\n] {\n const tplStateStoreScope: DataStore<\"STATE\">[] = [];\n const formStateStoreScope: DataStore<\"FORM_STATE\">[] = [];\n const scopedRuntimeContext: RuntimeContext = {\n ...runtimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n };\n return [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope];\n}\n\nfunction loadMenu(\n menuConf: MenuConf | undefined,\n runtimeContext: RuntimeContext\n) {\n if (!menuConf) {\n return;\n }\n\n // istanbul ignore next\n if ((menuConf as { type?: \"brick\" }).type === \"brick\") {\n // eslint-disable-next-line no-console\n console.error(\"Set menu with brick is dropped in v3:\", menuConf);\n throw new Error(\"Set menu with brick is dropped in v3\");\n }\n\n // istanbul ignore next\n if (menuConf.type === \"resolve\") {\n // eslint-disable-next-line no-console\n console.warn(\"Set menu with resolve is not supported in v3 yet:\", menuConf);\n return;\n }\n\n return asyncComputeRealValue(\n menuConf,\n runtimeContext\n ) as Promise<StaticMenuConf>;\n}\n\nfunction mergeRenderOutput(\n output: RenderOutput,\n newOutput: RenderOutput\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { blockingList, node, menuRequestNode, hasTrackingControls, ...rest } =\n newOutput;\n output.blockingList.push(...blockingList);\n\n if (node) {\n if (output.node) {\n let last = output.node;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = node;\n } else {\n output.node = node;\n }\n }\n\n Object.assign(output, rest);\n}\n\nfunction mergeSiblingRenderMenuRequest(\n output: RenderOutput,\n newOutput: RenderOutput\n) {\n const menuRequestNode = newOutput.menuRequestNode;\n if (menuRequestNode) {\n if (output.menuRequestNode) {\n let last = output.menuRequestNode;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = menuRequestNode;\n } else {\n output.menuRequestNode = menuRequestNode;\n }\n }\n}\n\nfunction appendMenuRequestNode(\n menuRequestReturnNode: MenuRequestNode,\n menuRequestNode: MenuRequestNode | undefined\n) {\n if (!menuRequestNode) {\n return;\n }\n if (menuRequestReturnNode.child) {\n let last = menuRequestReturnNode.child;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = menuRequestNode;\n } else {\n menuRequestReturnNode.child = menuRequestNode;\n }\n}\n\nfunction getEmptyRenderOutput(): RenderOutput {\n return { blockingList: [] };\n}\n\nexport function childrenToSlots(\n children: BrickConf[] | undefined,\n originalSlots: SlotsConf | undefined\n) {\n let newSlots = originalSlots;\n // istanbul ignore next\n if (\n process.env.NODE_ENV === \"development\" &&\n children &&\n !Array.isArray(children)\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Specified brick children but not array:\",\n `<${typeof children}>`,\n children\n );\n }\n if (Array.isArray(children) && !newSlots) {\n newSlots = {};\n for (const child of children) {\n const slot = child.slot ?? \"\";\n if (!hasOwnProperty(newSlots, slot)) {\n newSlots[slot] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n (newSlots[slot] as SlotConfOfBricks).bricks.push(child);\n }\n }\n return newSlots;\n}\n\nfunction catchLoad(\n promise: Promise<unknown>,\n type: \"brick\" | \"processors\" | \"script\" | \"stylesheet\",\n name: string,\n unknownPolicy: RendererContext[\"unknownBricks\"]\n) {\n return unknownPolicy === \"silent\"\n ? promise.catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Load %s \"%s\" failed:`, type, name, e);\n })\n : promise;\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAAA,OAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OA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O,OAAO,CAACC,KAAK,CAAC,sBAAsB,EAAEP,IAAI,EAAE4O,IAAI,EAAEG,CAAC,CAAC;EACtD,CAAC,CAAC,GACFJ,OAAO;AACb","ignoreList":[]}
|
package/dist/esm/createRoot.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i18n } from "@next-core/i18n";
|
|
1
2
|
import { uniqueId } from "lodash";
|
|
2
3
|
import { getDataStores, postAsyncRender, renderBricks } from "./internal/Renderer.js";
|
|
3
4
|
import { RendererContext } from "./internal/RendererContext.js";
|
|
@@ -38,6 +39,7 @@ export function unstable_createRoot(container) {
|
|
|
38
39
|
let {
|
|
39
40
|
theme,
|
|
40
41
|
uiVersion,
|
|
42
|
+
language,
|
|
41
43
|
context,
|
|
42
44
|
functions,
|
|
43
45
|
templates,
|
|
@@ -81,6 +83,9 @@ export function unstable_createRoot(container) {
|
|
|
81
83
|
setTheme(theme ?? "light");
|
|
82
84
|
setMode("default");
|
|
83
85
|
setUIVersion(uiVersion);
|
|
86
|
+
if (language) {
|
|
87
|
+
await i18n.changeLanguage(language);
|
|
88
|
+
}
|
|
84
89
|
app ?? (app = {
|
|
85
90
|
id: "demo",
|
|
86
91
|
homepage: "/demo"
|
|
@@ -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","theme","uiVersion","context","functions","templates","i18n","i18nData","url","app","Error","bricks","concat","previousRendererContext","renderId","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","urlObj","URL","query","searchParams","location","pathname","search","hash","state","renderRoot","tag","ROOT","_clearI18nBundles","id","homepage","demoStoryboard","meta","customTemplates","define","failed","output","stores","error","node","BRICK","type","properties","textContent","dataset","errorBoundary","color","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 url?: string;\n app?: MicroApp;\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 url,\n app,\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 if (url) {\n const urlObj = new URL(url);\n runtimeContext.query = urlObj.searchParams;\n runtimeContext.location = {\n pathname: urlObj.pathname,\n search: urlObj.search,\n hash: urlObj.hash,\n state: undefined,\n };\n }\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 app ??= {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = app;\n const demoStoryboard = {\n app,\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, app);\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 dataset: {\n errorBoundary: \"\",\n },\n style: {\n color: \"var(--color-error)\",\n },\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,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,qBAAqB,CAAC,CAAC;QACvCpE,eAAe,CAACqE,2BAA2B,CAAC,CAAC;MAC/C;IACF,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAIvE,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,CAACwF,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createRoot.js","names":["i18n","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","theme","uiVersion","language","context","functions","templates","i18nData","url","app","Error","bricks","concat","previousRendererContext","renderId","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","urlObj","URL","query","searchParams","location","pathname","search","hash","state","renderRoot","tag","ROOT","_clearI18nBundles","changeLanguage","id","homepage","demoStoryboard","meta","customTemplates","define","failed","output","stores","error","node","BRICK","type","properties","textContent","dataset","errorBoundary","color","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 { i18n } from \"@next-core/i18n\";\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 language?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n url?: string;\n app?: MicroApp;\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 language,\n context,\n functions,\n templates,\n i18n: i18nData,\n url,\n app,\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 if (url) {\n const urlObj = new URL(url);\n runtimeContext.query = urlObj.searchParams;\n runtimeContext.location = {\n pathname: urlObj.pathname,\n search: urlObj.search,\n hash: urlObj.hash,\n state: undefined,\n };\n }\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 if (language) {\n await i18n.changeLanguage(language);\n }\n\n app ??= {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = app;\n const demoStoryboard = {\n app,\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, app);\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 dataset: {\n errorBoundary: \"\",\n },\n style: {\n color: \"var(--color-error)\",\n },\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,IAAI,QAAQ,iBAAiB;AACtC,SAASC,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,sBAAsB;AACxD,SAASC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QA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AS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACVb,WAAW,CAACa,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAACyF,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -369,10 +369,14 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
|
|
|
369
369
|
let formData;
|
|
370
370
|
let confProps;
|
|
371
371
|
if (brickName === FORM_RENDERER) {
|
|
372
|
+
var _brickConf$properties;
|
|
372
373
|
({
|
|
373
374
|
formData,
|
|
374
375
|
...confProps
|
|
375
376
|
} = brickConf.properties ?? {});
|
|
377
|
+
if ((_brickConf$properties = brickConf.properties) !== null && _brickConf$properties !== void 0 && _brickConf$properties.compute) {
|
|
378
|
+
formData = await asyncComputeRealValue(formData, runtimeContext);
|
|
379
|
+
}
|
|
376
380
|
} else {
|
|
377
381
|
confProps = brickConf.properties;
|
|
378
382
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.js","names":["enqueueStableLoadBricks","flushStableLoadBricks","loadBricksImperatively","loadProcessorsImperatively","loadScript","loadStyle","isTrackAll","hasOwnProperty","strictCollectMemberUsage","debounce","isEqual","asyncCheckBrickIf","asyncComputeRealPropertyEntries","constructAsyncProperties","resolveData","asyncComputeRealValue","listenOnTrackingContext","matchRoute","matchRoutes","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachSize","symbolForTPlExternalNoForEach","symbolForTplStateStoreId","expandCustomTemplate","getTagNameOfCustomTemplate","getTplStateStore","customTemplates","getBrickPackages","hooks","RenderTag","getTracks","isStrictMode","warnAboutStrictMode","FORM_RENDERER","symbolForFormStateStoreId","expandFormRenderer","isPreEvaluated","getPreEvaluatedRaw","matchHomepage","listenerFactory","setupRootRuntimeContext","httpErrorToString","setMatchedRoute","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","parentRoutes","menuRequestReturnNode","slotId","isIncremental","matched","output","getEmptyRenderOutput","menuRequestNode","return","unauthenticated","_hooks$checkPermissio","route","path","match","runtimeContext","iid","ctxStore","disposeDataInRoutes","routePath","concat","define","context","undefined","pendingPermissionsPreCheck","push","checkPermissions","preCheckPermissionsForBrickOrRoute","value","preLoadBricks","Array","isArray","blockingList","type","redirectTo","redirect","resolved","transform","console","error","Error","menuRequest","loadMenu","menu","request","memoizeMenuRequestNode","newOutput","renderBricks","bricks","mergeRenderOutput","appendMenuRequestNode","tplStack","keyPath","kPath","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoize","node","arguments","length","legacyRenderBrick","errorBoundary","tag","BRICK","properties","textContent","dataset","style","color","_hooks$checkPermissio2","_runtimeContext$app","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","formStateStoreId","forEachItem","forEachIndex","forEachSize","strict","brickName","startsWith","ensureValidControlBrick","lowerLevelRenderControlNode","_slots$slot","computedDataSource","slot","String","childrenToSlots","children","renderForEach","renderControlNode","rawOutput","PLACEHOLDER","controlledOutput","onMount","onUnmount","lifeCycle","contextNames","stateNames","renderId","listener","currentRenderId","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","reControlledOutput","scopedStores","postAsyncRender","CustomEvent","detail","rerender","reRender","store","mountAsyncData","debouncedListener","contextName","onChange","tplStateStore","registerArbitraryLifeCycle","test","get","catchLoad","unknownBricks","tplTagName","app","id","tplCount","set","includes","customElements","FormRendererElement","HTMLElement","$$typeof","formData","confProps","trackingContextList","asyncPropertyEntries","computedPropsFromHost","isScript","props","src","rel","href","prefix","window","PUBLIC_ROOT","attrs","events","portal","ref","usedProcessors","size","join","loadProperties","registerBrickLifeCycle","expandedBrickConf","childRuntimeContext","loadChildren","routeSlotFromIndexToSlotId","entries","_ref","childSlotId","slotConf","parentRoute","incrementalSubRoutes","performIncrementalRender","location","prevLocation","homepage","pathname","every","prevMatch","newMatch","params","query","URLSearchParams","search","failed","incrementalOutput","reBailout","reMergeMenuRequestNodes","result","reCatch","childrenOutput","has","mergeSiblingRenderMenuRequest","child","i","j","flat","getDataStores","tplStateStoreMap","values","formStateStoreMap","stores","waitForAll","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","promise","name","unknownPolicy","catch","e"],"sources":["../../../src/internal/Renderer.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n ContextConf,\n MenuConf,\n RouteConf,\n RouteConfOfBricks,\n SlotConfOfBricks,\n SlotsConf,\n StaticMenuConf,\n} from \"@next-core/types\";\nimport {\n enqueueStableLoadBricks,\n flushStableLoadBricks,\n loadBricksImperatively,\n loadProcessorsImperatively,\n loadScript,\n loadStyle,\n} from \"@next-core/loader\";\nimport { isTrackAll } from \"@next-core/cook\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { strictCollectMemberUsage } from \"@next-core/utils/storyboard\";\nimport { debounce, isEqual } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealPropertyEntries,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoute, matchRoutes } from \"./matchRoutes.js\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachIndex,\n symbolForTPlExternalForEachItem,\n symbolForTPlExternalForEachSize,\n symbolForTPlExternalNoForEach,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n MenuRequestNode,\n RenderBrick,\n RenderChildNode,\n RenderReturnNode,\n RuntimeBrickConfWithSymbols,\n RuntimeContext,\n} from \"./interfaces.js\";\nimport {\n getTagNameOfCustomTemplate,\n getTplStateStore,\n} from \"./CustomTemplates/utils.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport type { NextHistoryState } from \"./historyExtended.js\";\nimport { getBrickPackages, hooks } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport {\n FORM_RENDERER,\n RuntimeBrickConfOfFormSymbols,\n symbolForFormStateStoreId,\n} from \"./FormRenderer/constants.js\";\nimport { expandFormRenderer } from \"./FormRenderer/expandFormRenderer.js\";\nimport { isPreEvaluated } from \"./compute/evaluate.js\";\nimport { getPreEvaluatedRaw } from \"./compute/evaluate.js\";\nimport { RuntimeBrickConfOfTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { matchHomepage } from \"./matchStoryboard.js\";\nimport type { DataStore, DataStoreType } from \"./data/DataStore.js\";\nimport { listenerFactory } from \"./bindListeners.js\";\nimport type { MatchResult } from \"./matchPath.js\";\nimport { setupRootRuntimeContext } from \"./setupRootRuntimeContext.js\";\nimport { httpErrorToString } from \"../handleHttpError.js\";\nimport { setMatchedRoute } from \"./routeMatchedMap.js\";\n\nexport interface RenderOutput {\n node?: RenderChildNode;\n unauthenticated?: boolean;\n redirect?: {\n path: string;\n state?: NextHistoryState;\n };\n route?: RouteConf;\n path?: string;\n blockingList: (Promise<unknown> | undefined)[];\n menuRequestNode?: MenuRequestNode;\n hasTrackingControls?: boolean;\n}\n\nexport async function renderRoutes(\n returnNode: RenderReturnNode,\n routes: RouteConf[],\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n isIncremental?: boolean\n): Promise<RenderOutput> {\n const matched = await matchRoutes(routes, _runtimeContext);\n const output = getEmptyRenderOutput();\n const menuRequestNode: MenuRequestNode = (output.menuRequestNode = {\n return: menuRequestReturnNode,\n });\n switch (matched) {\n case \"missed\":\n break;\n case \"unauthenticated\":\n output.unauthenticated = true;\n break;\n default: {\n const route = (output.route = matched.route);\n output.path = matched.match.path;\n const runtimeContext = {\n ..._runtimeContext,\n match: matched.match,\n };\n\n if (route.iid) {\n setMatchedRoute(route.iid, matched.match);\n }\n\n if (isIncremental) {\n runtimeContext.ctxStore.disposeDataInRoutes(routes);\n }\n const routePath = parentRoutes.concat(route);\n runtimeContext.ctxStore.define(\n route.context,\n runtimeContext,\n undefined,\n routePath\n );\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n route,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n // Currently, this is only used for brick size-checking: these bricks\n // will be loaded before page rendering, but they will NOT be rendered.\n const { preLoadBricks } = route as { preLoadBricks?: string[] };\n if (Array.isArray(preLoadBricks)) {\n output.blockingList.push(\n loadBricksImperatively(preLoadBricks, getBrickPackages())\n );\n }\n\n if (route.type === \"redirect\") {\n let redirectTo: unknown;\n if (typeof route.redirect === \"string\") {\n redirectTo = await asyncComputeRealValue(\n route.redirect,\n runtimeContext\n );\n } else {\n const resolved = (await resolveData(\n {\n transform: \"redirect\",\n ...route.redirect,\n },\n runtimeContext\n )) as { redirect?: unknown };\n redirectTo = resolved.redirect;\n }\n if (typeof redirectTo !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected redirect result:\", redirectTo);\n throw new Error(\n `Unexpected type of redirect result: ${typeof redirectTo}`\n );\n }\n output.redirect = { path: redirectTo };\n } else {\n const menuRequest = loadMenu(route.menu, runtimeContext);\n if (menuRequest) {\n menuRequestNode.request = menuRequest;\n }\n\n if (!isIncremental) {\n rendererContext.memoizeMenuRequestNode(routes, menuRequestNode);\n }\n\n let newOutput: RenderOutput;\n if (route.type === \"routes\") {\n newOutput = await renderRoutes(\n returnNode,\n route.routes,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId\n );\n } else {\n newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId\n );\n }\n\n mergeRenderOutput(output, newOutput);\n appendMenuRequestNode(menuRequestNode, newOutput.menuRequestNode);\n }\n }\n }\n\n return output;\n}\n\nexport async function renderBricks(\n returnNode: RenderReturnNode,\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n tplStack?: Map<string, number>,\n keyPath?: number[]\n): Promise<RenderOutput> {\n setupRootRuntimeContext(bricks, runtimeContext, true);\n const output = getEmptyRenderOutput();\n const kPath = keyPath ?? [];\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf, index) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n kPath.concat(index),\n tplStack && new Map(tplStack)\n )\n )\n );\n\n rendered.forEach((item, index) => {\n if (item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n slotId,\n kPath.concat(index),\n item.node,\n returnNode\n );\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport async function renderBrick(\n returnNode: RenderReturnNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n keyPath: number[] = [],\n tplStack = new Map<string, number>()\n): Promise<RenderOutput> {\n try {\n return await legacyRenderBrick(\n returnNode,\n brickConf,\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath,\n tplStack\n );\n } catch (error) {\n if (brickConf.errorBoundary) {\n // eslint-disable-next-line no-console\n console.error(\"Error caught by error boundary:\", error);\n return {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n dataset: {\n errorBoundary: \"\",\n },\n style: {\n color: \"var(--color-error)\",\n },\n },\n runtimeContext: null!,\n return: returnNode,\n },\n blockingList: [],\n };\n } else {\n throw error;\n }\n }\n}\n\nasync function legacyRenderBrick(\n returnNode: RenderReturnNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId: string | undefined,\n keyPath: number[],\n tplStack: Map<string, number>\n): Promise<RenderOutput> {\n const output = getEmptyRenderOutput();\n\n if (!brickConf.brick) {\n if ((brickConf as { template?: string }).template) {\n // eslint-disable-next-line no-console\n console.error(\"Legacy templates are dropped in v3:\", brickConf);\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Invalid brick:\", brickConf);\n }\n return output;\n }\n\n // Translate `if: \"<%= ... %>\"` to `brick: \":if\", dataSource: \"<%= ... %>\"`.\n // In other words, translate tracking if expressions to tracking control nodes of `:if`.\n const { if: brickIf, permissionsPreCheck, ...restBrickConf } = brickConf;\n if (isGeneralizedTrackAll(brickIf)) {\n return renderBrick(\n returnNode,\n {\n brick: \":if\",\n dataSource: brickIf,\n // `permissionsPreCheck` maybe required before computing `if`.\n permissionsPreCheck,\n slots: {\n \"\": {\n type: \"bricks\",\n bricks: [restBrickConf],\n },\n },\n // These symbols have to be copied to the new brick conf.\n ...Object.getOwnPropertySymbols(brickConf).reduce(\n (acc, symbol) => ({\n ...acc,\n [symbol]: (brickConf as any)[symbol],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath,\n tplStack\n );\n }\n\n const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const formStateStoreId = brickConf[symbolForFormStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\n formStateStoreId,\n };\n\n if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {\n // The external bricks of a template should restore their `forEach*` from their host.\n runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];\n runtimeContext.forEachIndex = brickConf[symbolForTPlExternalForEachIndex];\n runtimeContext.forEachSize = brickConf[symbolForTPlExternalForEachSize];\n } else if (brickConf[symbolForTPlExternalNoForEach]) {\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n }\n\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\n const strict = isStrictMode(runtimeContext);\n warnAboutStrictMode(\n strict,\n \"Defining context on bricks\",\n \"check your brick:\",\n brickConf\n );\n if (!strict) {\n runtimeContext.ctxStore.define(context, runtimeContext);\n }\n }\n\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n brickConf,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {\n return output;\n }\n\n const brickName = brickConf.brick;\n if (brickName.startsWith(\":\")) {\n ensureValidControlBrick(brickName);\n\n const { dataSource } = brickConf;\n\n const lowerLevelRenderControlNode = async (\n runtimeContext: RuntimeContext\n ) => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n // Then, get the matched slot.\n const slot =\n brickName === \":forEach\"\n ? \"\"\n : brickName === \":switch\"\n ? String(computedDataSource)\n : computedDataSource\n ? \"\"\n : \"else\";\n\n // Don't forget to transpile children to slots.\n const slots = childrenToSlots(brickConf.children, brickConf.slots);\n\n // Then, get the bricks in that matched slot.\n const bricks =\n slots &&\n hasOwnProperty(slots, slot) &&\n (slots[slot] as SlotConfOfBricks)?.bricks;\n\n if (!Array.isArray(bricks)) {\n return getEmptyRenderOutput();\n }\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n return getEmptyRenderOutput();\n }\n return renderForEach(\n returnNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n keyPath\n );\n }\n case \":if\":\n case \":switch\": {\n return renderBricks(\n returnNode,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n keyPath\n );\n }\n }\n };\n\n const renderControlNode = async (runtimeContext: RuntimeContext) => {\n const rawOutput = await lowerLevelRenderControlNode(runtimeContext);\n rawOutput.node ??= {\n tag: RenderTag.PLACEHOLDER,\n return: returnNode,\n };\n return rawOutput;\n };\n\n const controlledOutput = await renderControlNode(runtimeContext);\n const { onMount, onUnmount } = brickConf.lifeCycle ?? {};\n\n const { contextNames, stateNames } = getTracks(dataSource);\n if (contextNames || stateNames) {\n controlledOutput.hasTrackingControls = true;\n let renderId = 0;\n const listener = async () => {\n const currentRenderId = ++renderId;\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext(runtimeContext);\n\n const reControlledOutput =\n await renderControlNode(scopedRuntimeContext);\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n await postAsyncRender(\n reControlledOutput,\n scopedRuntimeContext,\n scopedStores\n );\n\n // Ignore stale renders\n if (renderId === currentRenderId) {\n if (onUnmount) {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: true } }));\n }\n\n rendererContext.reRender(\n slotId,\n keyPath,\n reControlledOutput.node,\n returnNode\n );\n\n if (onMount) {\n listenerFactory(\n onMount,\n scopedRuntimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: true } }));\n }\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n }\n };\n const debouncedListener = debounce(listener);\n if (contextNames) {\n for (const contextName of contextNames) {\n runtimeContext.ctxStore.onChange(contextName, debouncedListener);\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n tplStateStore.onChange(contextName, debouncedListener);\n }\n }\n }\n\n if (onMount) {\n rendererContext.registerArbitraryLifeCycle(\"onMount\", () => {\n listenerFactory(\n onMount,\n runtimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: false } }));\n });\n }\n\n if (onUnmount) {\n rendererContext.registerArbitraryLifeCycle(\"onUnmount\", () => {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: false } }));\n });\n }\n\n return controlledOutput;\n }\n\n // Widgets need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await catchLoad(\n loadBricksImperatively([brickName], getBrickPackages()),\n \"brick\",\n brickName,\n rendererContext.unknownBricks\n );\n }\n\n const tplTagName = getTagNameOfCustomTemplate(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n customElements.define(\n FORM_RENDERER,\n class FormRendererElement extends HTMLElement {\n get $$typeof(): string {\n return \"form-renderer\";\n }\n }\n );\n } else {\n output.blockingList.push(\n catchLoad(\n enqueueStableLoadBricks([brickName], getBrickPackages()),\n \"brick\",\n brickName,\n rendererContext.unknownBricks\n )\n );\n }\n }\n\n let formData: unknown;\n let confProps: Record<string, unknown> | undefined;\n if (brickName === FORM_RENDERER) {\n ({ formData, ...confProps } = brickConf.properties ?? {});\n } else {\n confProps = brickConf.properties;\n }\n\n const trackingContextList: TrackingContextItem[] = [];\n const asyncPropertyEntries = asyncComputeRealPropertyEntries(\n confProps,\n runtimeContext,\n trackingContextList\n );\n\n const computedPropsFromHost = brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n asyncPropertyEntries.push(...computedPropsFromHost);\n }\n\n const isScript = brickName === \"script\";\n if (isScript || brickName === \"link\") {\n const props = await constructAsyncProperties(asyncPropertyEntries);\n if (isScript ? props.src : props.rel === \"stylesheet\" && props.href) {\n const prefix = window.PUBLIC_ROOT ?? \"\";\n if (isScript) {\n const { src, ...attrs } = props;\n await catchLoad(\n loadScript(src as string, prefix, attrs),\n \"script\",\n src as string,\n \"silent\"\n );\n } else {\n const { href, ...attrs } = props;\n await catchLoad(\n loadStyle(href as string, prefix, attrs),\n \"stylesheet\",\n href as string,\n \"silent\"\n );\n }\n return output;\n }\n }\n\n const brick: RenderBrick = {\n tag: RenderTag.BRICK,\n type: tplTagName || brickName,\n return: returnNode,\n slotId,\n events: brickConf.events,\n runtimeContext,\n portal: brickConf.portal,\n iid: brickConf.iid,\n ref: (brickConf as BrickConfInTemplate).ref,\n };\n\n output.node = brick;\n\n // 在最终挂载前,先加载所有可能用到的 processors。\n const usedProcessors = strictCollectMemberUsage(\n [brickConf.events, brickConf.lifeCycle],\n \"PROCESSORS\",\n 2\n );\n if (usedProcessors.size > 0) {\n output.blockingList.push(\n catchLoad(\n loadProcessorsImperatively(usedProcessors, getBrickPackages()),\n \"processors\",\n [...usedProcessors].join(\", \"),\n rendererContext.unknownBricks\n )\n );\n }\n\n // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const loadProperties = async () => {\n brick.properties = await constructAsyncProperties(asyncPropertyEntries);\n listenOnTrackingContext(brick, trackingContextList);\n };\n blockingList.push(loadProperties());\n\n rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);\n\n let expandedBrickConf = brickConf;\n if (tplTagName) {\n expandedBrickConf = expandCustomTemplate(\n tplTagName,\n brickConf,\n brick,\n asyncPropertyEntries,\n rendererContext\n );\n } else if (brickName === FORM_RENDERER) {\n expandedBrickConf = expandFormRenderer(\n formData,\n brickConf,\n brick,\n asyncPropertyEntries,\n rendererContext\n );\n }\n\n if (expandedBrickConf.portal) {\n // A portal brick has no slotId.\n brick.slotId = undefined;\n }\n\n let childRuntimeContext: RuntimeContext;\n if (tplTagName) {\n // There is a boundary for `forEachItem` between template internals and externals.\n childRuntimeContext = {\n ...runtimeContext,\n };\n delete childRuntimeContext.forEachItem;\n delete childRuntimeContext.forEachIndex;\n delete childRuntimeContext.forEachSize;\n } else {\n childRuntimeContext = runtimeContext;\n }\n\n const loadChildren = async () => {\n const slots = childrenToSlots(\n expandedBrickConf.children,\n expandedBrickConf.slots\n );\n if (!slots) {\n return;\n }\n const routeSlotFromIndexToSlotId = new Map<number, string>();\n const rendered = await Promise.all(\n Object.entries(slots).map(([childSlotId, slotConf], index) => {\n if (slotConf.type !== \"routes\") {\n return renderBricks(\n brick,\n (slotConf as SlotConfOfBricks).bricks,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n tplStack\n );\n }\n\n const parentRoute = parentRoutes[parentRoutes.length - 1] as\n | RouteConfOfBricks\n | undefined;\n if (parentRoute?.incrementalSubRoutes) {\n routeSlotFromIndexToSlotId.set(index, childSlotId);\n rendererContext.performIncrementalRender(\n slotConf,\n parentRoutes,\n async (location, prevLocation) => {\n const { homepage } = childRuntimeContext.app;\n const { pathname } = location;\n // Ignore if any one of homepage and parent routes not matched.\n if (\n !matchHomepage(homepage, pathname) ||\n !parentRoutes.every((route) => {\n let prevMatch: MatchResult | null;\n let newMatch: MatchResult | null;\n return (\n (prevMatch = matchRoute(\n route,\n homepage,\n prevLocation.pathname\n )) &&\n (newMatch = matchRoute(route, homepage, pathname)) &&\n (route !== parentRoute ||\n isEqual(prevMatch.params, newMatch.params))\n );\n })\n ) {\n return false;\n }\n\n const [\n scopedRuntimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n ] = createScopedRuntimeContext({\n ...childRuntimeContext,\n location,\n query: new URLSearchParams(location.search),\n });\n\n let failed = false;\n let incrementalOutput: RenderOutput;\n let scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n incrementalOutput = await renderRoutes(\n brick,\n slotConf.routes,\n scopedRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n true\n );\n\n // Do not ignore incremental rendering even if all sub-routes are missed.\n // Since parent route is matched.\n if (incrementalOutput.route) {\n // Bailout if redirect or unauthenticated is set\n if (rendererContext.reBailout(incrementalOutput)) {\n return true;\n }\n\n scopedStores = [\n ...tplStateStoreScope,\n ...formStateStoreScope,\n ];\n await postAsyncRender(\n incrementalOutput,\n scopedRuntimeContext,\n [scopedRuntimeContext.ctxStore, ...scopedStores]\n );\n }\n\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Incremental sub-router failed:\", error);\n\n const result = rendererContext.reCatch(error, brick);\n if (!result) {\n return true;\n }\n ({ failed, output: incrementalOutput } = result);\n\n // Assert: no errors will be throw\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n }\n\n rendererContext.reRender(\n childSlotId,\n [],\n incrementalOutput.node,\n brick\n );\n\n if (!failed) {\n scopedRuntimeContext.ctxStore.mountAsyncData(\n incrementalOutput.route\n );\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n }\n\n // When result is null, it means the incremental rendering is tried but routes missed.\n // In this case, we should continue to re-render the parent routes.\n return incrementalOutput.route ? true : null;\n }\n );\n }\n\n return renderRoutes(\n brick,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId\n );\n })\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n menuRequestNode: undefined,\n };\n rendered.forEach((item, index) => {\n if (routeSlotFromIndexToSlotId.has(index)) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n routeSlotFromIndexToSlotId.get(index),\n [],\n item.node,\n brick\n );\n }\n mergeRenderOutput(childrenOutput, item);\n mergeSiblingRenderMenuRequest(childrenOutput, item);\n });\n if (childrenOutput.node) {\n brick.child = childrenOutput.node;\n }\n mergeRenderOutput(output, {\n ...childrenOutput,\n node: undefined,\n });\n\n appendMenuRequestNode(\n menuRequestReturnNode,\n (output.menuRequestNode = childrenOutput.menuRequestNode)\n );\n };\n blockingList.push(loadChildren());\n\n await Promise.all(blockingList);\n\n return output;\n}\n\nfunction isGeneralizedTrackAll(brickIf: unknown): boolean {\n return typeof brickIf === \"string\"\n ? isTrackAll(brickIf)\n : isPreEvaluated(brickIf) &&\n // istanbul ignore next: covered by e2e tests\n isTrackAll(getPreEvaluatedRaw(brickIf));\n}\n\ntype ValidControlBrick = \":forEach\" | \":if\" | \":switch\";\n\nfunction ensureValidControlBrick(\n brick: string\n): asserts brick is ValidControlBrick {\n if (brick !== \":forEach\" && brick !== \":if\" && brick !== \":switch\") {\n throw new Error(`Unknown storyboard control node: \"${brick}\"`);\n }\n}\n\nasync function renderForEach(\n returnNode: RenderReturnNode,\n dataSource: unknown[],\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId: string | undefined,\n tplStack: Map<string, number>,\n keyPath: number[]\n): Promise<RenderOutput> {\n const output = getEmptyRenderOutput();\n\n const size = dataSource.length;\n const rendered = await Promise.all(\n dataSource.map((item, i) =>\n Promise.all(\n bricks.map((brickConf, j) =>\n renderBrick(\n returnNode,\n brickConf,\n {\n ...runtimeContext,\n forEachItem: item,\n forEachIndex: i,\n forEachSize: size,\n },\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath.concat(i * size + j),\n tplStack && new Map(tplStack)\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n rendered.flat().forEach((item, index) => {\n if (item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n slotId,\n keyPath.concat(index),\n item.node,\n returnNode\n );\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport function getDataStores(runtimeContext: RuntimeContext) {\n return [\n runtimeContext.ctxStore,\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ];\n}\n\nexport function postAsyncRender(\n output: RenderOutput,\n runtimeContext: RuntimeContext,\n stores: DataStore<DataStoreType>[]\n) {\n flushStableLoadBricks();\n\n return Promise.all([\n ...output.blockingList,\n ...stores.map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n}\n\nexport function createScopedRuntimeContext(\n runtimeContext: RuntimeContext\n): [\n scopedRuntimeContext: RuntimeContext,\n tplStateStoreScope: DataStore<\"STATE\">[],\n formStateStoreScope: DataStore<\"FORM_STATE\">[],\n] {\n const tplStateStoreScope: DataStore<\"STATE\">[] = [];\n const formStateStoreScope: DataStore<\"FORM_STATE\">[] = [];\n const scopedRuntimeContext: RuntimeContext = {\n ...runtimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n };\n return [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope];\n}\n\nfunction loadMenu(\n menuConf: MenuConf | undefined,\n runtimeContext: RuntimeContext\n) {\n if (!menuConf) {\n return;\n }\n\n // istanbul ignore next\n if ((menuConf as { type?: \"brick\" }).type === \"brick\") {\n // eslint-disable-next-line no-console\n console.error(\"Set menu with brick is dropped in v3:\", menuConf);\n throw new Error(\"Set menu with brick is dropped in v3\");\n }\n\n // istanbul ignore next\n if (menuConf.type === \"resolve\") {\n // eslint-disable-next-line no-console\n console.warn(\"Set menu with resolve is not supported in v3 yet:\", menuConf);\n return;\n }\n\n return asyncComputeRealValue(\n menuConf,\n runtimeContext\n ) as Promise<StaticMenuConf>;\n}\n\nfunction mergeRenderOutput(\n output: RenderOutput,\n newOutput: RenderOutput\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { blockingList, node, menuRequestNode, hasTrackingControls, ...rest } =\n newOutput;\n output.blockingList.push(...blockingList);\n\n if (node) {\n if (output.node) {\n let last = output.node;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = node;\n } else {\n output.node = node;\n }\n }\n\n Object.assign(output, rest);\n}\n\nfunction mergeSiblingRenderMenuRequest(\n output: RenderOutput,\n newOutput: RenderOutput\n) {\n const menuRequestNode = newOutput.menuRequestNode;\n if (menuRequestNode) {\n if (output.menuRequestNode) {\n let last = output.menuRequestNode;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = menuRequestNode;\n } else {\n output.menuRequestNode = menuRequestNode;\n }\n }\n}\n\nfunction appendMenuRequestNode(\n menuRequestReturnNode: MenuRequestNode,\n menuRequestNode: MenuRequestNode | undefined\n) {\n if (!menuRequestNode) {\n return;\n }\n if (menuRequestReturnNode.child) {\n let last = menuRequestReturnNode.child;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = menuRequestNode;\n } else {\n menuRequestReturnNode.child = menuRequestNode;\n }\n}\n\nfunction getEmptyRenderOutput(): RenderOutput {\n return { blockingList: [] };\n}\n\nexport function childrenToSlots(\n children: BrickConf[] | undefined,\n originalSlots: SlotsConf | undefined\n) {\n let newSlots = originalSlots;\n // istanbul ignore next\n if (\n process.env.NODE_ENV === \"development\" &&\n children &&\n !Array.isArray(children)\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Specified brick children but not array:\",\n `<${typeof children}>`,\n children\n );\n }\n if (Array.isArray(children) && !newSlots) {\n newSlots = {};\n for (const child of children) {\n const slot = child.slot ?? \"\";\n if (!hasOwnProperty(newSlots, slot)) {\n newSlots[slot] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n (newSlots[slot] as SlotConfOfBricks).bricks.push(child);\n }\n }\n return newSlots;\n}\n\nfunction catchLoad(\n promise: Promise<unknown>,\n type: \"brick\" | \"processors\" | \"script\" | \"stylesheet\",\n name: string,\n unknownPolicy: RendererContext[\"unknownBricks\"]\n) {\n return unknownPolicy === \"silent\"\n ? promise.catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Load %s \"%s\" failed:`, type, name, e);\n })\n : promise;\n}\n"],"mappings":"AAWA,SACEA,uBAAuB,EACvBC,qBAAqB,EACrBC,sBAAsB,EACtBC,0BAA0B,EAC1BC,UAAU,EACVC,SAAS,QACJ,mBAAmB;AAC1B,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,wBAAwB,QAAQ,6BAA6B;AACtE,SAASC,QAAQ,EAAEC,OAAO,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SACEC,+BAA+B,EAC/BC,wBAAwB,QACnB,oCAAoC;AAC3C,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SAEEC,uBAAuB,QAClB,sCAAsC;AAE7C,SAASC,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SACEC,mCAAmC,EACnCC,gCAAgC,EAChCC,+BAA+B,EAC/BC,+BAA+B,EAC/BC,6BAA6B,EAC7BC,wBAAwB,QACnB,gCAAgC;AACvC,SAASC,oBAAoB,QAAQ,2CAA2C;AAShF,SACEC,0BAA0B,EAC1BC,gBAAgB,QACX,4BAA4B;AACnC,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,gBAAgB,EAAEC,KAAK,QAAQ,cAAc;AACtD,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,oBAAoB;AAC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AAI,CAACoH,QAAQ,EAAE;IACxCA,QAAQ,GAAG,CAAC,CAAC;IACb,KAAK,MAAMjB,KAAK,IAAInG,QAAQ,EAAE;MAC5B,MAAMH,IAAI,GAAGsG,KAAK,CAACtG,IAAI,IAAI,EAAE;MAC7B,IAAI,CAACpJ,cAAc,CAAC2Q,QAAQ,EAAEvH,IAAI,CAAC,EAAE;QACnCuH,QAAQ,CAACvH,IAAI,CAAC,GAAG;UACfzE,IAAI,EAAE,QAAQ;UACde,MAAM,EAAE;QACV,CAAC;MACH;MACCiL,QAAQ,CAACvH,IAAI,CAAC,CAAsB1D,MAAM,CAACvB,IAAI,CAACuL,KAAK,CAAC;IACzD;EACF;EACA,OAAOiB,QAAQ;AACjB;AAEA,SAASlF,SAASA,CAChBsF,OAAyB,EACzBpM,IAAsD,EACtDqM,IAAY,EACZC,aAA+C,EAC/C;EACA,OAAOA,aAAa,KAAK,QAAQ,GAC7BF,OAAO,CAACG,KAAK,CAAEC,CAAC,IAAK;IACnB;IACAnM,OAAO,CAACC,KAAK,CAAC,sBAAsB,EAAEN,IAAI,EAAEqM,IAAI,EAAEG,CAAC,CAAC;EACtD,CAAC,CAAC,GACFJ,OAAO;AACb","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Renderer.js","names":["enqueueStableLoadBricks","flushStableLoadBricks","loadBricksImperatively","loadProcessorsImperatively","loadScript","loadStyle","isTrackAll","hasOwnProperty","strictCollectMemberUsage","debounce","isEqual","asyncCheckBrickIf","asyncComputeRealPropertyEntries","constructAsyncProperties","resolveData","asyncComputeRealValue","listenOnTrackingContext","matchRoute","matchRoutes","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachSize","symbolForTPlExternalNoForEach","symbolForTplStateStoreId","expandCustomTemplate","getTagNameOfCustomTemplate","getTplStateStore","customTemplates","getBrickPackages","hooks","RenderTag","getTracks","isStrictMode","warnAboutStrictMode","FORM_RENDERER","symbolForFormStateStoreId","expandFormRenderer","isPreEvaluated","getPreEvaluatedRaw","matchHomepage","listenerFactory","setupRootRuntimeContext","httpErrorToString","setMatchedRoute","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","parentRoutes","menuRequestReturnNode","slotId","isIncremental","matched","output","getEmptyRenderOutput","menuRequestNode","return","unauthenticated","_hooks$checkPermissio","route","path","match","runtimeContext","iid","ctxStore","disposeDataInRoutes","routePath","concat","define","context","undefined","pendingPermissionsPreCheck","push","checkPermissions","preCheckPermissionsForBrickOrRoute","value","preLoadBricks","Array","isArray","blockingList","type","redirectTo","redirect","resolved","transform","console","error","Error","menuRequest","loadMenu","menu","request","memoizeMenuRequestNode","newOutput","renderBricks","bricks","mergeRenderOutput","appendMenuRequestNode","tplStack","keyPath","kPath","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoize","node","arguments","length","legacyRenderBrick","errorBoundary","tag","BRICK","properties","textContent","dataset","style","color","_hooks$checkPermissio2","_runtimeContext$app","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","formStateStoreId","forEachItem","forEachIndex","forEachSize","strict","brickName","startsWith","ensureValidControlBrick","lowerLevelRenderControlNode","_slots$slot","computedDataSource","slot","String","childrenToSlots","children","renderForEach","renderControlNode","rawOutput","PLACEHOLDER","controlledOutput","onMount","onUnmount","lifeCycle","contextNames","stateNames","renderId","listener","currentRenderId","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","reControlledOutput","scopedStores","postAsyncRender","CustomEvent","detail","rerender","reRender","store","mountAsyncData","debouncedListener","contextName","onChange","tplStateStore","registerArbitraryLifeCycle","test","get","catchLoad","unknownBricks","tplTagName","app","id","tplCount","set","includes","customElements","FormRendererElement","HTMLElement","$$typeof","formData","confProps","_brickConf$properties","compute","trackingContextList","asyncPropertyEntries","computedPropsFromHost","isScript","props","src","rel","href","prefix","window","PUBLIC_ROOT","attrs","events","portal","ref","usedProcessors","size","join","loadProperties","registerBrickLifeCycle","expandedBrickConf","childRuntimeContext","loadChildren","routeSlotFromIndexToSlotId","entries","_ref","childSlotId","slotConf","parentRoute","incrementalSubRoutes","performIncrementalRender","location","prevLocation","homepage","pathname","every","prevMatch","newMatch","params","query","URLSearchParams","search","failed","incrementalOutput","reBailout","reMergeMenuRequestNodes","result","reCatch","childrenOutput","has","mergeSiblingRenderMenuRequest","child","i","j","flat","getDataStores","tplStateStoreMap","values","formStateStoreMap","stores","waitForAll","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","promise","name","unknownPolicy","catch","e"],"sources":["../../../src/internal/Renderer.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n ContextConf,\n MenuConf,\n RouteConf,\n RouteConfOfBricks,\n SlotConfOfBricks,\n SlotsConf,\n StaticMenuConf,\n} from \"@next-core/types\";\nimport {\n enqueueStableLoadBricks,\n flushStableLoadBricks,\n loadBricksImperatively,\n loadProcessorsImperatively,\n loadScript,\n loadStyle,\n} from \"@next-core/loader\";\nimport { isTrackAll } from \"@next-core/cook\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { strictCollectMemberUsage } from \"@next-core/utils/storyboard\";\nimport { debounce, isEqual } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealPropertyEntries,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoute, matchRoutes } from \"./matchRoutes.js\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachIndex,\n symbolForTPlExternalForEachItem,\n symbolForTPlExternalForEachSize,\n symbolForTPlExternalNoForEach,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n MenuRequestNode,\n RenderBrick,\n RenderChildNode,\n RenderReturnNode,\n RuntimeBrickConfWithSymbols,\n RuntimeContext,\n} from \"./interfaces.js\";\nimport {\n getTagNameOfCustomTemplate,\n getTplStateStore,\n} from \"./CustomTemplates/utils.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport type { NextHistoryState } from \"./historyExtended.js\";\nimport { getBrickPackages, hooks } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport {\n FORM_RENDERER,\n RuntimeBrickConfOfFormSymbols,\n symbolForFormStateStoreId,\n} from \"./FormRenderer/constants.js\";\nimport { expandFormRenderer } from \"./FormRenderer/expandFormRenderer.js\";\nimport { isPreEvaluated } from \"./compute/evaluate.js\";\nimport { getPreEvaluatedRaw } from \"./compute/evaluate.js\";\nimport { RuntimeBrickConfOfTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { matchHomepage } from \"./matchStoryboard.js\";\nimport type { DataStore, DataStoreType } from \"./data/DataStore.js\";\nimport { listenerFactory } from \"./bindListeners.js\";\nimport type { MatchResult } from \"./matchPath.js\";\nimport { setupRootRuntimeContext } from \"./setupRootRuntimeContext.js\";\nimport { httpErrorToString } from \"../handleHttpError.js\";\nimport { setMatchedRoute } from \"./routeMatchedMap.js\";\n\nexport interface RenderOutput {\n node?: RenderChildNode;\n unauthenticated?: boolean;\n redirect?: {\n path: string;\n state?: NextHistoryState;\n };\n route?: RouteConf;\n path?: string;\n blockingList: (Promise<unknown> | undefined)[];\n menuRequestNode?: MenuRequestNode;\n hasTrackingControls?: boolean;\n}\n\nexport async function renderRoutes(\n returnNode: RenderReturnNode,\n routes: RouteConf[],\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n isIncremental?: boolean\n): Promise<RenderOutput> {\n const matched = await matchRoutes(routes, _runtimeContext);\n const output = getEmptyRenderOutput();\n const menuRequestNode: MenuRequestNode = (output.menuRequestNode = {\n return: menuRequestReturnNode,\n });\n switch (matched) {\n case \"missed\":\n break;\n case \"unauthenticated\":\n output.unauthenticated = true;\n break;\n default: {\n const route = (output.route = matched.route);\n output.path = matched.match.path;\n const runtimeContext = {\n ..._runtimeContext,\n match: matched.match,\n };\n\n if (route.iid) {\n setMatchedRoute(route.iid, matched.match);\n }\n\n if (isIncremental) {\n runtimeContext.ctxStore.disposeDataInRoutes(routes);\n }\n const routePath = parentRoutes.concat(route);\n runtimeContext.ctxStore.define(\n route.context,\n runtimeContext,\n undefined,\n routePath\n );\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n route,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n // Currently, this is only used for brick size-checking: these bricks\n // will be loaded before page rendering, but they will NOT be rendered.\n const { preLoadBricks } = route as { preLoadBricks?: string[] };\n if (Array.isArray(preLoadBricks)) {\n output.blockingList.push(\n loadBricksImperatively(preLoadBricks, getBrickPackages())\n );\n }\n\n if (route.type === \"redirect\") {\n let redirectTo: unknown;\n if (typeof route.redirect === \"string\") {\n redirectTo = await asyncComputeRealValue(\n route.redirect,\n runtimeContext\n );\n } else {\n const resolved = (await resolveData(\n {\n transform: \"redirect\",\n ...route.redirect,\n },\n runtimeContext\n )) as { redirect?: unknown };\n redirectTo = resolved.redirect;\n }\n if (typeof redirectTo !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected redirect result:\", redirectTo);\n throw new Error(\n `Unexpected type of redirect result: ${typeof redirectTo}`\n );\n }\n output.redirect = { path: redirectTo };\n } else {\n const menuRequest = loadMenu(route.menu, runtimeContext);\n if (menuRequest) {\n menuRequestNode.request = menuRequest;\n }\n\n if (!isIncremental) {\n rendererContext.memoizeMenuRequestNode(routes, menuRequestNode);\n }\n\n let newOutput: RenderOutput;\n if (route.type === \"routes\") {\n newOutput = await renderRoutes(\n returnNode,\n route.routes,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId\n );\n } else {\n newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId\n );\n }\n\n mergeRenderOutput(output, newOutput);\n appendMenuRequestNode(menuRequestNode, newOutput.menuRequestNode);\n }\n }\n }\n\n return output;\n}\n\nexport async function renderBricks(\n returnNode: RenderReturnNode,\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n tplStack?: Map<string, number>,\n keyPath?: number[]\n): Promise<RenderOutput> {\n setupRootRuntimeContext(bricks, runtimeContext, true);\n const output = getEmptyRenderOutput();\n const kPath = keyPath ?? [];\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf, index) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n kPath.concat(index),\n tplStack && new Map(tplStack)\n )\n )\n );\n\n rendered.forEach((item, index) => {\n if (item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n slotId,\n kPath.concat(index),\n item.node,\n returnNode\n );\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport async function renderBrick(\n returnNode: RenderReturnNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId?: string,\n keyPath: number[] = [],\n tplStack = new Map<string, number>()\n): Promise<RenderOutput> {\n try {\n return await legacyRenderBrick(\n returnNode,\n brickConf,\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath,\n tplStack\n );\n } catch (error) {\n if (brickConf.errorBoundary) {\n // eslint-disable-next-line no-console\n console.error(\"Error caught by error boundary:\", error);\n return {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n dataset: {\n errorBoundary: \"\",\n },\n style: {\n color: \"var(--color-error)\",\n },\n },\n runtimeContext: null!,\n return: returnNode,\n },\n blockingList: [],\n };\n } else {\n throw error;\n }\n }\n}\n\nasync function legacyRenderBrick(\n returnNode: RenderReturnNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId: string | undefined,\n keyPath: number[],\n tplStack: Map<string, number>\n): Promise<RenderOutput> {\n const output = getEmptyRenderOutput();\n\n if (!brickConf.brick) {\n if ((brickConf as { template?: string }).template) {\n // eslint-disable-next-line no-console\n console.error(\"Legacy templates are dropped in v3:\", brickConf);\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Invalid brick:\", brickConf);\n }\n return output;\n }\n\n // Translate `if: \"<%= ... %>\"` to `brick: \":if\", dataSource: \"<%= ... %>\"`.\n // In other words, translate tracking if expressions to tracking control nodes of `:if`.\n const { if: brickIf, permissionsPreCheck, ...restBrickConf } = brickConf;\n if (isGeneralizedTrackAll(brickIf)) {\n return renderBrick(\n returnNode,\n {\n brick: \":if\",\n dataSource: brickIf,\n // `permissionsPreCheck` maybe required before computing `if`.\n permissionsPreCheck,\n slots: {\n \"\": {\n type: \"bricks\",\n bricks: [restBrickConf],\n },\n },\n // These symbols have to be copied to the new brick conf.\n ...Object.getOwnPropertySymbols(brickConf).reduce(\n (acc, symbol) => ({\n ...acc,\n [symbol]: (brickConf as any)[symbol],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath,\n tplStack\n );\n }\n\n const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const formStateStoreId = brickConf[symbolForFormStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\n formStateStoreId,\n };\n\n if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {\n // The external bricks of a template should restore their `forEach*` from their host.\n runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];\n runtimeContext.forEachIndex = brickConf[symbolForTPlExternalForEachIndex];\n runtimeContext.forEachSize = brickConf[symbolForTPlExternalForEachSize];\n } else if (brickConf[symbolForTPlExternalNoForEach]) {\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n }\n\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\n const strict = isStrictMode(runtimeContext);\n warnAboutStrictMode(\n strict,\n \"Defining context on bricks\",\n \"check your brick:\",\n brickConf\n );\n if (!strict) {\n runtimeContext.ctxStore.define(context, runtimeContext);\n }\n }\n\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n brickConf,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {\n return output;\n }\n\n const brickName = brickConf.brick;\n if (brickName.startsWith(\":\")) {\n ensureValidControlBrick(brickName);\n\n const { dataSource } = brickConf;\n\n const lowerLevelRenderControlNode = async (\n runtimeContext: RuntimeContext\n ) => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n // Then, get the matched slot.\n const slot =\n brickName === \":forEach\"\n ? \"\"\n : brickName === \":switch\"\n ? String(computedDataSource)\n : computedDataSource\n ? \"\"\n : \"else\";\n\n // Don't forget to transpile children to slots.\n const slots = childrenToSlots(brickConf.children, brickConf.slots);\n\n // Then, get the bricks in that matched slot.\n const bricks =\n slots &&\n hasOwnProperty(slots, slot) &&\n (slots[slot] as SlotConfOfBricks)?.bricks;\n\n if (!Array.isArray(bricks)) {\n return getEmptyRenderOutput();\n }\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n return getEmptyRenderOutput();\n }\n return renderForEach(\n returnNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n keyPath\n );\n }\n case \":if\":\n case \":switch\": {\n return renderBricks(\n returnNode,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n keyPath\n );\n }\n }\n };\n\n const renderControlNode = async (runtimeContext: RuntimeContext) => {\n const rawOutput = await lowerLevelRenderControlNode(runtimeContext);\n rawOutput.node ??= {\n tag: RenderTag.PLACEHOLDER,\n return: returnNode,\n };\n return rawOutput;\n };\n\n const controlledOutput = await renderControlNode(runtimeContext);\n const { onMount, onUnmount } = brickConf.lifeCycle ?? {};\n\n const { contextNames, stateNames } = getTracks(dataSource);\n if (contextNames || stateNames) {\n controlledOutput.hasTrackingControls = true;\n let renderId = 0;\n const listener = async () => {\n const currentRenderId = ++renderId;\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext(runtimeContext);\n\n const reControlledOutput =\n await renderControlNode(scopedRuntimeContext);\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n await postAsyncRender(\n reControlledOutput,\n scopedRuntimeContext,\n scopedStores\n );\n\n // Ignore stale renders\n if (renderId === currentRenderId) {\n if (onUnmount) {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: true } }));\n }\n\n rendererContext.reRender(\n slotId,\n keyPath,\n reControlledOutput.node,\n returnNode\n );\n\n if (onMount) {\n listenerFactory(\n onMount,\n scopedRuntimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: true } }));\n }\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n }\n };\n const debouncedListener = debounce(listener);\n if (contextNames) {\n for (const contextName of contextNames) {\n runtimeContext.ctxStore.onChange(contextName, debouncedListener);\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n tplStateStore.onChange(contextName, debouncedListener);\n }\n }\n }\n\n if (onMount) {\n rendererContext.registerArbitraryLifeCycle(\"onMount\", () => {\n listenerFactory(\n onMount,\n runtimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: false } }));\n });\n }\n\n if (onUnmount) {\n rendererContext.registerArbitraryLifeCycle(\"onUnmount\", () => {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: false } }));\n });\n }\n\n return controlledOutput;\n }\n\n // Widgets need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await catchLoad(\n loadBricksImperatively([brickName], getBrickPackages()),\n \"brick\",\n brickName,\n rendererContext.unknownBricks\n );\n }\n\n const tplTagName = getTagNameOfCustomTemplate(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n customElements.define(\n FORM_RENDERER,\n class FormRendererElement extends HTMLElement {\n get $$typeof(): string {\n return \"form-renderer\";\n }\n }\n );\n } else {\n output.blockingList.push(\n catchLoad(\n enqueueStableLoadBricks([brickName], getBrickPackages()),\n \"brick\",\n brickName,\n rendererContext.unknownBricks\n )\n );\n }\n }\n\n let formData: unknown;\n let confProps: Record<string, unknown> | undefined;\n if (brickName === FORM_RENDERER) {\n ({ formData, ...confProps } = brickConf.properties ?? {});\n\n if (brickConf.properties?.compute) {\n formData = await asyncComputeRealValue(formData, runtimeContext);\n }\n } else {\n confProps = brickConf.properties;\n }\n\n const trackingContextList: TrackingContextItem[] = [];\n const asyncPropertyEntries = asyncComputeRealPropertyEntries(\n confProps,\n runtimeContext,\n trackingContextList\n );\n\n const computedPropsFromHost = brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n asyncPropertyEntries.push(...computedPropsFromHost);\n }\n\n const isScript = brickName === \"script\";\n if (isScript || brickName === \"link\") {\n const props = await constructAsyncProperties(asyncPropertyEntries);\n if (isScript ? props.src : props.rel === \"stylesheet\" && props.href) {\n const prefix = window.PUBLIC_ROOT ?? \"\";\n if (isScript) {\n const { src, ...attrs } = props;\n await catchLoad(\n loadScript(src as string, prefix, attrs),\n \"script\",\n src as string,\n \"silent\"\n );\n } else {\n const { href, ...attrs } = props;\n await catchLoad(\n loadStyle(href as string, prefix, attrs),\n \"stylesheet\",\n href as string,\n \"silent\"\n );\n }\n return output;\n }\n }\n\n const brick: RenderBrick = {\n tag: RenderTag.BRICK,\n type: tplTagName || brickName,\n return: returnNode,\n slotId,\n events: brickConf.events,\n runtimeContext,\n portal: brickConf.portal,\n iid: brickConf.iid,\n ref: (brickConf as BrickConfInTemplate).ref,\n };\n\n output.node = brick;\n\n // 在最终挂载前,先加载所有可能用到的 processors。\n const usedProcessors = strictCollectMemberUsage(\n [brickConf.events, brickConf.lifeCycle],\n \"PROCESSORS\",\n 2\n );\n if (usedProcessors.size > 0) {\n output.blockingList.push(\n catchLoad(\n loadProcessorsImperatively(usedProcessors, getBrickPackages()),\n \"processors\",\n [...usedProcessors].join(\", \"),\n rendererContext.unknownBricks\n )\n );\n }\n\n // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const loadProperties = async () => {\n brick.properties = await constructAsyncProperties(asyncPropertyEntries);\n listenOnTrackingContext(brick, trackingContextList);\n };\n blockingList.push(loadProperties());\n\n rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);\n\n let expandedBrickConf = brickConf;\n if (tplTagName) {\n expandedBrickConf = expandCustomTemplate(\n tplTagName,\n brickConf,\n brick,\n asyncPropertyEntries,\n rendererContext\n );\n } else if (brickName === FORM_RENDERER) {\n expandedBrickConf = expandFormRenderer(\n formData,\n brickConf,\n brick,\n asyncPropertyEntries,\n rendererContext\n );\n }\n\n if (expandedBrickConf.portal) {\n // A portal brick has no slotId.\n brick.slotId = undefined;\n }\n\n let childRuntimeContext: RuntimeContext;\n if (tplTagName) {\n // There is a boundary for `forEachItem` between template internals and externals.\n childRuntimeContext = {\n ...runtimeContext,\n };\n delete childRuntimeContext.forEachItem;\n delete childRuntimeContext.forEachIndex;\n delete childRuntimeContext.forEachSize;\n } else {\n childRuntimeContext = runtimeContext;\n }\n\n const loadChildren = async () => {\n const slots = childrenToSlots(\n expandedBrickConf.children,\n expandedBrickConf.slots\n );\n if (!slots) {\n return;\n }\n const routeSlotFromIndexToSlotId = new Map<number, string>();\n const rendered = await Promise.all(\n Object.entries(slots).map(([childSlotId, slotConf], index) => {\n if (slotConf.type !== \"routes\") {\n return renderBricks(\n brick,\n (slotConf as SlotConfOfBricks).bricks,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n tplStack\n );\n }\n\n const parentRoute = parentRoutes[parentRoutes.length - 1] as\n | RouteConfOfBricks\n | undefined;\n if (parentRoute?.incrementalSubRoutes) {\n routeSlotFromIndexToSlotId.set(index, childSlotId);\n rendererContext.performIncrementalRender(\n slotConf,\n parentRoutes,\n async (location, prevLocation) => {\n const { homepage } = childRuntimeContext.app;\n const { pathname } = location;\n // Ignore if any one of homepage and parent routes not matched.\n if (\n !matchHomepage(homepage, pathname) ||\n !parentRoutes.every((route) => {\n let prevMatch: MatchResult | null;\n let newMatch: MatchResult | null;\n return (\n (prevMatch = matchRoute(\n route,\n homepage,\n prevLocation.pathname\n )) &&\n (newMatch = matchRoute(route, homepage, pathname)) &&\n (route !== parentRoute ||\n isEqual(prevMatch.params, newMatch.params))\n );\n })\n ) {\n return false;\n }\n\n const [\n scopedRuntimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n ] = createScopedRuntimeContext({\n ...childRuntimeContext,\n location,\n query: new URLSearchParams(location.search),\n });\n\n let failed = false;\n let incrementalOutput: RenderOutput;\n let scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n incrementalOutput = await renderRoutes(\n brick,\n slotConf.routes,\n scopedRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n true\n );\n\n // Do not ignore incremental rendering even if all sub-routes are missed.\n // Since parent route is matched.\n if (incrementalOutput.route) {\n // Bailout if redirect or unauthenticated is set\n if (rendererContext.reBailout(incrementalOutput)) {\n return true;\n }\n\n scopedStores = [\n ...tplStateStoreScope,\n ...formStateStoreScope,\n ];\n await postAsyncRender(\n incrementalOutput,\n scopedRuntimeContext,\n [scopedRuntimeContext.ctxStore, ...scopedStores]\n );\n }\n\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Incremental sub-router failed:\", error);\n\n const result = rendererContext.reCatch(error, brick);\n if (!result) {\n return true;\n }\n ({ failed, output: incrementalOutput } = result);\n\n // Assert: no errors will be throw\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n }\n\n rendererContext.reRender(\n childSlotId,\n [],\n incrementalOutput.node,\n brick\n );\n\n if (!failed) {\n scopedRuntimeContext.ctxStore.mountAsyncData(\n incrementalOutput.route\n );\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n }\n\n // When result is null, it means the incremental rendering is tried but routes missed.\n // In this case, we should continue to re-render the parent routes.\n return incrementalOutput.route ? true : null;\n }\n );\n }\n\n return renderRoutes(\n brick,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId\n );\n })\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n menuRequestNode: undefined,\n };\n rendered.forEach((item, index) => {\n if (routeSlotFromIndexToSlotId.has(index)) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n routeSlotFromIndexToSlotId.get(index),\n [],\n item.node,\n brick\n );\n }\n mergeRenderOutput(childrenOutput, item);\n mergeSiblingRenderMenuRequest(childrenOutput, item);\n });\n if (childrenOutput.node) {\n brick.child = childrenOutput.node;\n }\n mergeRenderOutput(output, {\n ...childrenOutput,\n node: undefined,\n });\n\n appendMenuRequestNode(\n menuRequestReturnNode,\n (output.menuRequestNode = childrenOutput.menuRequestNode)\n );\n };\n blockingList.push(loadChildren());\n\n await Promise.all(blockingList);\n\n return output;\n}\n\nfunction isGeneralizedTrackAll(brickIf: unknown): boolean {\n return typeof brickIf === \"string\"\n ? isTrackAll(brickIf)\n : isPreEvaluated(brickIf) &&\n // istanbul ignore next: covered by e2e tests\n isTrackAll(getPreEvaluatedRaw(brickIf));\n}\n\ntype ValidControlBrick = \":forEach\" | \":if\" | \":switch\";\n\nfunction ensureValidControlBrick(\n brick: string\n): asserts brick is ValidControlBrick {\n if (brick !== \":forEach\" && brick !== \":if\" && brick !== \":switch\") {\n throw new Error(`Unknown storyboard control node: \"${brick}\"`);\n }\n}\n\nasync function renderForEach(\n returnNode: RenderReturnNode,\n dataSource: unknown[],\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n parentRoutes: RouteConf[],\n menuRequestReturnNode: MenuRequestNode,\n slotId: string | undefined,\n tplStack: Map<string, number>,\n keyPath: number[]\n): Promise<RenderOutput> {\n const output = getEmptyRenderOutput();\n\n const size = dataSource.length;\n const rendered = await Promise.all(\n dataSource.map((item, i) =>\n Promise.all(\n bricks.map((brickConf, j) =>\n renderBrick(\n returnNode,\n brickConf,\n {\n ...runtimeContext,\n forEachItem: item,\n forEachIndex: i,\n forEachSize: size,\n },\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n keyPath.concat(i * size + j),\n tplStack && new Map(tplStack)\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n rendered.flat().forEach((item, index) => {\n if (item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoize(\n slotId,\n keyPath.concat(index),\n item.node,\n returnNode\n );\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport function getDataStores(runtimeContext: RuntimeContext) {\n return [\n runtimeContext.ctxStore,\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ];\n}\n\nexport function postAsyncRender(\n output: RenderOutput,\n runtimeContext: RuntimeContext,\n stores: DataStore<DataStoreType>[]\n) {\n flushStableLoadBricks();\n\n return Promise.all([\n ...output.blockingList,\n ...stores.map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n}\n\nexport function createScopedRuntimeContext(\n runtimeContext: RuntimeContext\n): [\n scopedRuntimeContext: RuntimeContext,\n tplStateStoreScope: DataStore<\"STATE\">[],\n formStateStoreScope: DataStore<\"FORM_STATE\">[],\n] {\n const tplStateStoreScope: DataStore<\"STATE\">[] = [];\n const formStateStoreScope: DataStore<\"FORM_STATE\">[] = [];\n const scopedRuntimeContext: RuntimeContext = {\n ...runtimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n };\n return [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope];\n}\n\nfunction loadMenu(\n menuConf: MenuConf | undefined,\n runtimeContext: RuntimeContext\n) {\n if (!menuConf) {\n return;\n }\n\n // istanbul ignore next\n if ((menuConf as { type?: \"brick\" }).type === \"brick\") {\n // eslint-disable-next-line no-console\n console.error(\"Set menu with brick is dropped in v3:\", menuConf);\n throw new Error(\"Set menu with brick is dropped in v3\");\n }\n\n // istanbul ignore next\n if (menuConf.type === \"resolve\") {\n // eslint-disable-next-line no-console\n console.warn(\"Set menu with resolve is not supported in v3 yet:\", menuConf);\n return;\n }\n\n return asyncComputeRealValue(\n menuConf,\n runtimeContext\n ) as Promise<StaticMenuConf>;\n}\n\nfunction mergeRenderOutput(\n output: RenderOutput,\n newOutput: RenderOutput\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { blockingList, node, menuRequestNode, hasTrackingControls, ...rest } =\n newOutput;\n output.blockingList.push(...blockingList);\n\n if (node) {\n if (output.node) {\n let last = output.node;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = node;\n } else {\n output.node = node;\n }\n }\n\n Object.assign(output, rest);\n}\n\nfunction mergeSiblingRenderMenuRequest(\n output: RenderOutput,\n newOutput: RenderOutput\n) {\n const menuRequestNode = newOutput.menuRequestNode;\n if (menuRequestNode) {\n if (output.menuRequestNode) {\n let last = output.menuRequestNode;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = menuRequestNode;\n } else {\n output.menuRequestNode = menuRequestNode;\n }\n }\n}\n\nfunction appendMenuRequestNode(\n menuRequestReturnNode: MenuRequestNode,\n menuRequestNode: MenuRequestNode | undefined\n) {\n if (!menuRequestNode) {\n return;\n }\n if (menuRequestReturnNode.child) {\n let last = menuRequestReturnNode.child;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = menuRequestNode;\n } else {\n menuRequestReturnNode.child = menuRequestNode;\n }\n}\n\nfunction getEmptyRenderOutput(): RenderOutput {\n return { blockingList: [] };\n}\n\nexport function childrenToSlots(\n children: BrickConf[] | undefined,\n originalSlots: SlotsConf | undefined\n) {\n let newSlots = originalSlots;\n // istanbul ignore next\n if (\n process.env.NODE_ENV === \"development\" &&\n children &&\n !Array.isArray(children)\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Specified brick children but not array:\",\n `<${typeof children}>`,\n children\n );\n }\n if (Array.isArray(children) && !newSlots) {\n newSlots = {};\n for (const child of children) {\n const slot = child.slot ?? \"\";\n if (!hasOwnProperty(newSlots, slot)) {\n newSlots[slot] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n (newSlots[slot] as SlotConfOfBricks).bricks.push(child);\n }\n }\n return newSlots;\n}\n\nfunction catchLoad(\n promise: Promise<unknown>,\n type: \"brick\" | \"processors\" | \"script\" | \"stylesheet\",\n name: string,\n unknownPolicy: RendererContext[\"unknownBricks\"]\n) {\n return unknownPolicy === \"silent\"\n ? promise.catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Load %s \"%s\" failed:`, type, name, e);\n })\n : promise;\n}\n"],"mappings":"AAWA,SACEA,uBAAuB,EACvBC,qBAAqB,EACrBC,sBAAsB,EACtBC,0BAA0B,EAC1BC,UAAU,EACVC,SAAS,QACJ,mBAAmB;AAC1B,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,wBAAwB,QAAQ,6BAA6B;AACtE,SAASC,QAAQ,EAAEC,OAAO,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SACEC,+BAA+B,EAC/BC,wBAAwB,QACnB,oCAAoC;AAC3C,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SAEEC,uBAAuB,QAClB,sCAAsC;AAE7C,SAASC,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SACEC,mCAAmC,EACnCC,gCAAgC,EAChCC,+BAA+B,EAC/BC,+BAA+B,EAC/BC,6BAA6B,EAC7BC,wBAAwB,QACnB,gCAAgC;AACvC,SAASC,oBAAoB,QAAQ,2CAA2C;AAShF,SACEC,0BAA0B,EAC1BC,gBAAgB,QACX,4BAA4B;AACnC,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OAAO,SAAS4E,eAAeA,CAC7BC,QAAiC,EACjCqH,aAAoC,EACpC;EACA,IAAIC,QAAQ,GAAGD,aAAa;EAC5B;EACA,IACEE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,IACtCzH,QAAQ,IACR,CAAC/E,KAAK,CAACC,OAAO,CAAC8E,QAAQ,CAAC,EACxB;IACA;IACAvE,OAAO,CAACuL,IAAI,CACV,yCAAyC,EACzC,IAAI,OAAOhH,QAAQ,GAAG,EACtBA,QACF,CAAC;EACH;EACA,IAAI/E,KAAK,CAACC,OAAO,CAAC8E,QAAQ,CAAC,IAAI,CAACsH,QAAQ,EAAE;IACxCA,QAAQ,GAAG,CAAC,CAAC;IACb,KAAK,MAAMjB,KAAK,IAAIrG,QAAQ,EAAE;MAC5B,MAAMH,IAAI,GAAGwG,KAAK,CAACxG,IAAI,IAAI,EAAE;MAC7B,IAAI,CAACpJ,cAAc,CAAC6Q,QAAQ,EAAEzH,IAAI,CAAC,EAAE;QACnCyH,QAAQ,CAACzH,IAAI,CAAC,GAAG;UACfzE,IAAI,EAAE,QAAQ;UACde,MAAM,EAAE;QACV,CAAC;MACH;MACCmL,QAAQ,CAACzH,IAAI,CAAC,CAAsB1D,MAAM,CAACvB,IAAI,CAACyL,KAAK,CAAC;IACzD;EACF;EACA,OAAOiB,QAAQ;AACjB;AAEA,SAASpF,SAASA,CAChBwF,OAAyB,EACzBtM,IAAsD,EACtDuM,IAAY,EACZC,aAA+C,EAC/C;EACA,OAAOA,aAAa,KAAK,QAAQ,GAC7BF,OAAO,CAACG,KAAK,CAAEC,CAAC,IAAK;IACnB;IACArM,OAAO,CAACC,KAAK,CAAC,sBAAsB,EAAEN,IAAI,EAAEuM,IAAI,EAAEG,CAAC,CAAC;EACtD,CAAC,CAAC,GACFJ,OAAO;AACb","ignoreList":[]}
|
|
@@ -17,6 +17,7 @@ export interface CreateRootOptions {
|
|
|
17
17
|
export interface RenderOptions {
|
|
18
18
|
theme?: SiteTheme;
|
|
19
19
|
uiVersion?: string;
|
|
20
|
+
language?: string;
|
|
20
21
|
context?: ContextConf[];
|
|
21
22
|
functions?: StoryboardFunction[];
|
|
22
23
|
templates?: CustomTemplate[];
|
|
@@ -25,6 +26,6 @@ export interface RenderOptions {
|
|
|
25
26
|
app?: MicroApp;
|
|
26
27
|
}
|
|
27
28
|
export declare function unstable_createRoot(container: HTMLElement | DocumentFragment, { portal: _portal, scope, unknownBricks }?: CreateRootOptions): {
|
|
28
|
-
render(brick: BrickConf | BrickConf[], { theme, uiVersion, context, functions, templates, i18n: i18nData, url, app, }?: RenderOptions): Promise<void>;
|
|
29
|
+
render(brick: BrickConf | BrickConf[], { theme, uiVersion, language, context, functions, templates, i18n: i18nData, url, app, }?: RenderOptions): Promise<void>;
|
|
29
30
|
unmount(): void;
|
|
30
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.52.1",
|
|
4
4
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/runtime",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"repository": {
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"@next-core/build-next-libs": "^1.0.18",
|
|
68
68
|
"@next-core/test-next": "^1.1.5"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "e21a5eaf4d8b8ec3b6ccb9d284a1521223b83e89"
|
|
71
71
|
}
|