@next-core/runtime 1.71.3 → 1.71.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.js","names":["_cook","require","_loader","_supply","_general","_storyboard","_lodash","_CustomProcessors","_StoryboardFunctions","_getGeneralGlobals","_proxyFactories","_devtools","_mediaQuery","_getStorageItem","_Runtime","_utils","_WidgetFunctions","_WidgetI18n","_hasInstalledApp","_isStrictMode","_utils2","_resolveData","_computeRealValue","symbolForRaw","Symbol","for","symbolForContext","isPreEvaluated","raw","getPreEvaluatedRaw","pre","shouldDismissMarkingComputed","shouldAllowRecursiveEvaluations","possibleErrorConstructs","WeakSet","SyntaxError","TypeError","ReferenceError","getCookErrorConstructor","error","has","constructor","asyncEvaluate","runtimeContext","options","blockingList","run","lowLevelEvaluate","Promise","all","evaluate","isAsync","passByRuntimeContext","omit","menuUsage","usedArgs","Set","hasAppUsage","precooked","preevaluate","cache","withParent","hooks","beforeVisitGlobal","node","parent","collectAppGetMenuUsage","collectInstalledAppsHasUsage","message","errorConstructor","hasNonStaticUsage","Error","globalVariables","attemptToVisitGlobals","lazy","hasOwnProperty","Object","keys","length","usedCtx","usedProcessors","usedStates","tplStateStore","strict","isStrictMode","getTplStateStore","usedFormStates","formStateStore","getFormStateStore","devHook","getDevHook","strictCollectMemberUsage","push","ctxStore","waitFor","usedTpls","tpl","add","loadProcessorsImperatively","getBrickPackages","attemptToCheckPermissions","usedFunctions","checkPermissionsUsage","pendingPermissionsPreCheck","size","menu","usedMenuIds","map","menuId","fetchMenuById","getStoryboardByAppId","_internalApiGetStoryboardInBootstrapData","resolveData","asyncComputeRealValue","_hooks$checkInstalled","checkInstalledApps","waitForCheckingApps","_hooks$menu","_hooks$images","data","event","unsafe_penetrate","penetrableCtx","_internalApiGetRuntimeContext","app","currentApp","location","query","match","flags","sys","overrideApp","variableName","hash","substring","cloneDeep","getMenu","getMenuById","getDynamicReadOnlyProxy","get","_target","key","_internalApiGetRuntim","internalCtxStore","getValue","ownKeys","Array","from","getReadOnlyProxy","hasInstalledApp","property","console","getItem","getStorageItem","getMedia","getRuntime","getMiscSettings","URLSearchParams","params","pathname","pkg","customProcessors","_t","k","processor","namespace","split","fromEntries","getAll","warnAboutStrictMode","widgetFunctions","images","widgetImagesFactory","widgetI18nFactory","assign","getGeneralGlobals","storyboardFunctions","appendI18nNamespace","isolatedRoot","result","cook","expression","source","supply","detail","context","devtoolsHookEmit"],"sources":["../../../../src/internal/compute/evaluate.ts"],"sourcesContent":["import {\n cook,\n preevaluate,\n PreevaluateResult,\n shouldAllowRecursiveEvaluations,\n} from \"@next-core/cook\";\nimport { loadProcessorsImperatively } from \"@next-core/loader\";\nimport { supply } from \"@next-core/supply\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport {\n strictCollectMemberUsage,\n collectAppGetMenuUsage,\n collectInstalledAppsHasUsage,\n MemberCallUsage,\n} from \"@next-core/utils/storyboard\";\nimport { cloneDeep, omit } from \"lodash\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { customProcessors } from \"../../CustomProcessors.js\";\nimport {\n checkPermissionsUsage,\n storyboardFunctions,\n} from \"./StoryboardFunctions.js\";\nimport { getGeneralGlobals } from \"./getGeneralGlobals.js\";\nimport {\n getDynamicReadOnlyProxy,\n getReadOnlyProxy,\n} from \"../proxyFactories.js\";\nimport { devtoolsHookEmit, getDevHook } from \"../devtools.js\";\nimport { getMedia } from \"../mediaQuery.js\";\nimport { getStorageItem } from \"./getStorageItem.js\";\nimport {\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n getRuntime,\n hooks,\n} from \"../Runtime.js\";\nimport type { DataStore } from \"../data/DataStore.js\";\nimport { getTplStateStore } from \"../CustomTemplates/utils.js\";\nimport { widgetFunctions } from \"./WidgetFunctions.js\";\nimport { widgetI18nFactory } from \"./WidgetI18n.js\";\nimport { hasInstalledApp } from \"../hasInstalledApp.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../../isStrictMode.js\";\nimport { getFormStateStore } from \"../FormRenderer/utils.js\";\nimport { resolveData } from \"../data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./computeRealValue.js\";\n\nconst symbolForRaw = Symbol.for(\"pre.evaluated.raw\");\nconst symbolForContext = Symbol.for(\"pre.evaluated.context\");\n\nexport interface PreEvaluated {\n [symbolForRaw]: string;\n [symbolForContext]: RuntimeContext;\n}\n\nexport interface EvaluateOptions {\n lazy?: boolean;\n evaluationId?: number;\n}\n\nexport function isPreEvaluated(raw: unknown): raw is PreEvaluated {\n return !!(raw as PreEvaluated)?.[symbolForRaw];\n}\n\nexport function getPreEvaluatedRaw(pre: PreEvaluated): string {\n return pre[symbolForRaw];\n}\n\nexport function shouldDismissMarkingComputed(\n raw: string | PreEvaluated\n): boolean {\n if (typeof raw === \"string\") {\n return shouldAllowRecursiveEvaluations(raw);\n }\n return shouldAllowRecursiveEvaluations(raw[symbolForRaw]);\n}\n\nconst possibleErrorConstructs = new WeakSet<ErrorConstructor>([\n SyntaxError,\n TypeError,\n ReferenceError,\n]);\n\nexport function getCookErrorConstructor(error: any): ErrorConstructor {\n return possibleErrorConstructs.has(error.constructor)\n ? error.constructor\n : TypeError;\n}\n\nexport async function asyncEvaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options?: EvaluateOptions\n): Promise<unknown> {\n const { blockingList, run } = lowLevelEvaluate(\n raw,\n runtimeContext,\n options,\n true\n );\n await Promise.all(blockingList);\n return run();\n}\n\nexport function evaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options?: EvaluateOptions\n): Promise<unknown> {\n const { run } = lowLevelEvaluate(raw, runtimeContext, options, false);\n return run();\n}\n\nfunction lowLevelEvaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options: EvaluateOptions = {},\n isAsync?: boolean\n): {\n blockingList: (Promise<unknown> | undefined)[];\n run: Function;\n} {\n const blockingList: (Promise<unknown> | undefined)[] = [];\n if (typeof raw !== \"string\") {\n // If the `raw` is not a string, it must be a pre-evaluated object.\n // Then fulfil the context, and restore the original `raw`.\n\n const passByRuntimeContext = omit(runtimeContext, [\n \"pendingPermissionsPreCheck\",\n \"tplStateStoreMap\",\n \"tplStateStoreScope\",\n \"formStateStoreMap\",\n \"formStateStoreScope\",\n ]);\n\n runtimeContext = {\n ...raw[symbolForContext],\n ...passByRuntimeContext,\n };\n raw = raw[symbolForRaw];\n }\n\n // Collect `APP.getMenu(...)` usage before evaluating.\n const menuUsage: MemberCallUsage = {\n usedArgs: new Set(),\n };\n const hasAppUsage: MemberCallUsage = {\n usedArgs: new Set(),\n };\n\n // A `SyntaxError` maybe thrown.\n let precooked: PreevaluateResult;\n try {\n precooked = preevaluate(raw, {\n cache: true,\n withParent: true,\n hooks: {\n beforeVisitGlobal(node, parent) {\n collectAppGetMenuUsage(menuUsage, node, parent!);\n collectInstalledAppsHasUsage(hasAppUsage, node, parent!);\n },\n },\n });\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n }\n\n if (menuUsage.hasNonStaticUsage) {\n throw new Error(\n `Non-static usage of \"APP.getMenu\" is prohibited in v3, check your expression: \"${raw}\"`\n );\n }\n\n if (hasAppUsage.hasNonStaticUsage) {\n throw new Error(\n `Non-static usage of \"INSTALLED_APPS.has\" is prohibited in v3, check your expression: \"${raw}\"`\n );\n }\n\n const globalVariables: Record<string, unknown> = {};\n const { attemptToVisitGlobals } = precooked;\n\n // Ignore evaluating if required `event/DATA` is missing in\n // context. Since they are are provided in different context, whenever\n // missing one of them, memorize the current context for later consuming.\n if (\n options.lazy ||\n (attemptToVisitGlobals.has(\"EVENT\") &&\n !hasOwnProperty(runtimeContext, \"event\")) ||\n (attemptToVisitGlobals.has(\"DATA\") &&\n !hasOwnProperty(runtimeContext, \"data\"))\n ) {\n return {\n blockingList,\n run() {\n return Object.keys(runtimeContext).length > 0\n ? ({\n [symbolForRaw]: raw,\n [symbolForContext]: runtimeContext,\n } as PreEvaluated)\n : raw;\n },\n };\n }\n\n let usedCtx: Set<string> | undefined;\n let usedProcessors: Set<string>;\n let usedStates: Set<string>;\n let tplStateStore: DataStore<\"STATE\"> | undefined;\n const strict = isStrictMode(runtimeContext);\n\n // For existed TPL usage, treat it as a STATE.\n if (\n attemptToVisitGlobals.has(\"STATE\") ||\n (!strict && attemptToVisitGlobals.has(\"TPL\"))\n ) {\n tplStateStore = getTplStateStore(runtimeContext, \"STATE\", `: \"${raw}\"`);\n }\n\n let usedFormStates: Set<string>;\n let formStateStore: DataStore<\"FORM_STATE\"> | undefined;\n if (attemptToVisitGlobals.has(\"FORM_STATE\")) {\n formStateStore = getFormStateStore(\n runtimeContext,\n \"FORM_STATE\",\n `: \"${raw}\"`\n );\n }\n\n const devHook = getDevHook();\n if (isAsync || devHook) {\n if (attemptToVisitGlobals.has(\"CTX\")) {\n usedCtx = strictCollectMemberUsage(raw, \"CTX\");\n isAsync && blockingList.push(runtimeContext.ctxStore.waitFor(usedCtx));\n }\n\n if (tplStateStore) {\n usedStates = strictCollectMemberUsage(raw, \"STATE\");\n // istanbul ignore if\n if (!strict) {\n const usedTpls = strictCollectMemberUsage(raw, \"TPL\");\n for (const tpl of usedTpls) {\n usedStates.add(tpl);\n }\n }\n isAsync && blockingList.push(tplStateStore.waitFor(usedStates));\n }\n\n if (formStateStore) {\n usedFormStates = strictCollectMemberUsage(raw, \"FORM_STATE\");\n isAsync && blockingList.push(formStateStore.waitFor(usedFormStates));\n }\n\n if (attemptToVisitGlobals.has(\"PROCESSORS\")) {\n usedProcessors = strictCollectMemberUsage(raw, \"PROCESSORS\", 2);\n isAsync &&\n blockingList.push(\n loadProcessorsImperatively(usedProcessors, getBrickPackages())\n );\n }\n }\n\n if (isAsync) {\n let attemptToCheckPermissions = attemptToVisitGlobals.has(\"PERMISSIONS\");\n // There maybe `PERMISSIONS.check()` usage in functions\n if (!attemptToCheckPermissions && attemptToVisitGlobals.has(\"FN\")) {\n const usedFunctions = [...strictCollectMemberUsage(raw, \"FN\")];\n attemptToCheckPermissions = checkPermissionsUsage(usedFunctions);\n }\n\n if (attemptToCheckPermissions) {\n blockingList.push(...runtimeContext.pendingPermissionsPreCheck);\n }\n\n if (menuUsage.usedArgs.size > 0 && hooks?.menu) {\n // Block evaluating if has `APP.getMenu(...)` usage.\n const usedMenuIds = [...menuUsage.usedArgs];\n blockingList.push(\n Promise.all(\n usedMenuIds.map((menuId) =>\n hooks!.menu!.fetchMenuById(menuId, runtimeContext, {\n getStoryboardByAppId: _internalApiGetStoryboardInBootstrapData,\n resolveData,\n asyncComputeRealValue,\n })\n )\n )\n );\n }\n\n if (hasAppUsage.usedArgs.size > 0) {\n // Only wait for specific apps\n blockingList.push(\n hooks?.checkInstalledApps?.waitForCheckingApps([\n ...hasAppUsage.usedArgs,\n ])\n );\n }\n }\n\n return {\n blockingList,\n run() {\n const { ctxStore, data, event, unsafe_penetrate } = runtimeContext;\n\n const penetrableCtx = unsafe_penetrate\n ? _internalApiGetRuntimeContext()!\n : runtimeContext;\n\n const {\n app: currentApp,\n location,\n query,\n match,\n flags,\n sys,\n } = penetrableCtx;\n const app = penetrableCtx.overrideApp ?? currentApp;\n\n for (const variableName of attemptToVisitGlobals) {\n switch (variableName) {\n // case \"ALIAS\":\n case \"ANCHOR\":\n globalVariables[variableName] = location.hash\n ? location.hash.substring(1)\n : null;\n break;\n case \"APP\":\n if (app == null) {\n throw new ReferenceError(`APP is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = {\n ...cloneDeep(app),\n getMenu: hooks?.menu?.getMenuById,\n };\n break;\n case \"CTX\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n // Allow accessing global `CTX.DS` from an isolated root such as dashboard.\n if (key === \"DS\" && !ctxStore.has(key)) {\n const internalCtxStore =\n _internalApiGetRuntimeContext()?.ctxStore;\n if (internalCtxStore?.has(key)) {\n return internalCtxStore.getValue(key);\n }\n }\n return ctxStore.getValue(key as string);\n },\n ownKeys() {\n return usedCtx ? Array.from(usedCtx) : [];\n },\n });\n break;\n case \"DATA\":\n globalVariables[variableName] = data;\n break;\n case \"EVENT\":\n globalVariables[variableName] = event;\n break;\n case \"FLAGS\":\n globalVariables[variableName] = getReadOnlyProxy(flags);\n break;\n case \"FORM_STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n return formStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedFormStates);\n },\n });\n break;\n case \"HASH\":\n globalVariables[variableName] = location.hash;\n break;\n case \"INSTALLED_APPS\":\n globalVariables[variableName] = getReadOnlyProxy({\n has: hasInstalledApp,\n });\n break;\n case \"ITEM\":\n case \"INDEX\":\n case \"SIZE\": {\n const property =\n variableName === \"ITEM\"\n ? \"forEachItem\"\n : variableName === \"INDEX\"\n ? \"forEachIndex\"\n : \"forEachSize\";\n if (!hasOwnProperty(runtimeContext, property)) {\n // eslint-disable-next-line no-console\n console.error(\n `Using \\`${variableName}\\` but no \\`:forEach\\` is found, check your expression: \"${raw}\"`\n );\n } else {\n globalVariables[variableName] = runtimeContext[property];\n }\n break;\n }\n case \"LOCAL_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"local\"),\n });\n break;\n case \"MEDIA\":\n globalVariables[variableName] = getReadOnlyProxy(getMedia());\n break;\n case \"MISC\":\n globalVariables[variableName] = getRuntime().getMiscSettings();\n break;\n case \"PARAMS\":\n if (query == null) {\n throw new ReferenceError(`PARAMS is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = new URLSearchParams(query);\n break;\n case \"PATH\":\n globalVariables[variableName] = getReadOnlyProxy(\n match?.params ?? {}\n );\n break;\n case \"PATH_NAME\":\n globalVariables[variableName] = location.pathname;\n break;\n case \"PROCESSORS\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n const pkg = customProcessors.get(key as string);\n if (!pkg) {\n throw new Error(\n `'PROCESSORS.${\n key as string\n }' is not registered! Have you installed the relevant brick package?`\n );\n }\n return getDynamicReadOnlyProxy({\n get(_t, k) {\n return pkg.get(k as string);\n },\n ownKeys() {\n return Array.from(pkg.keys());\n },\n });\n },\n ownKeys() {\n const keys = new Set<string>();\n for (const processor of usedProcessors) {\n const namespace = processor.split(\".\")[0];\n keys.add(namespace);\n }\n return Array.from(keys);\n },\n });\n break;\n case \"QUERY\":\n if (query == null) {\n throw new ReferenceError(`QUERY is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.get(key)])\n );\n break;\n case \"QUERY_ARRAY\":\n if (query == null) {\n throw new ReferenceError(\n `QUERY_ARRAY is not defined, in \"${raw}\"`\n );\n }\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.getAll(key)])\n );\n // case \"SEGUE\":\n break;\n case \"SESSION_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"session\"),\n });\n break;\n // istanbul ignore next\n case \"TPL\":\n warnAboutStrictMode(\n strict,\n 'Using \"TPL\" in expression',\n `check your expression: \"${raw}\"`\n );\n if (strict) {\n break;\n }\n // eslint-disable-next-line no-fallthrough\n case \"STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n return tplStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedStates);\n },\n });\n break;\n case \"SYS\":\n globalVariables[variableName] = getReadOnlyProxy(sys ?? {});\n break;\n case \"__WIDGET_FN__\":\n globalVariables[variableName] = widgetFunctions;\n break;\n case \"__WIDGET_IMG__\":\n globalVariables[variableName] = hooks?.images?.widgetImagesFactory;\n break;\n case \"__WIDGET_I18N__\":\n globalVariables[variableName] = widgetI18nFactory;\n break;\n }\n }\n\n Object.assign(\n globalVariables,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n storyboardFunctions,\n app: app,\n appendI18nNamespace: runtimeContext.appendI18nNamespace,\n isolatedRoot: runtimeContext.isolatedRoot,\n })\n );\n\n try {\n const result = cook(precooked.expression, precooked.source, {\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n globalVariables\n ),\n });\n const detail = { raw, context: globalVariables, result };\n devtoolsHookEmit(\"evaluation\", detail);\n return result;\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AAIA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AAIA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,eAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AAQA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,gBAAA,GAAAf,OAAA;AACA,IAAAgB,WAAA,GAAAhB,OAAA;AACA,IAAAiB,gBAAA,GAAAjB,OAAA;AACA,IAAAkB,aAAA,GAAAlB,OAAA;AACA,IAAAmB,OAAA,GAAAnB,OAAA;AACA,IAAAoB,YAAA,GAAApB,OAAA;AACA,IAAAqB,iBAAA,GAAArB,OAAA;AAEA,MAAMsB,YAAY,GAAGC,MAAM,CAACC,GAAG,CAAC,mBAAmB,CAAC;AACpD,MAAMC,gBAAgB,GAAGF,MAAM,C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;MACrC;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"evaluate.js","names":["_cook","require","_loader","_supply","_general","_storyboard","_lodash","_CustomProcessors","_StoryboardFunctions","_getGeneralGlobals","_proxyFactories","_devtools","_mediaQuery","_getStorageItem","_Runtime","_utils","_WidgetFunctions","_WidgetI18n","_hasInstalledApp","_isStrictMode","_utils2","_resolveData","_computeRealValue","symbolForRaw","Symbol","for","symbolForContext","isPreEvaluated","raw","getPreEvaluatedRaw","pre","shouldDismissMarkingComputed","shouldAllowRecursiveEvaluations","possibleErrorConstructs","WeakSet","SyntaxError","TypeError","ReferenceError","getCookErrorConstructor","error","has","constructor","asyncEvaluate","runtimeContext","options","blockingList","run","lowLevelEvaluate","Promise","all","evaluate","isAsync","passByRuntimeContext","omit","menuUsage","usedArgs","Set","hasAppUsage","precooked","preevaluate","cache","withParent","hooks","beforeVisitGlobal","node","parent","collectAppGetMenuUsage","collectInstalledAppsHasUsage","message","errorConstructor","hasNonStaticUsage","Error","globalVariables","attemptToVisitGlobals","lazy","hasOwnProperty","Object","keys","length","usedCtx","usedProcessors","usedStates","tplStateStore","strict","isStrictMode","getTplStateStore","usedFormStates","formStateStore","getFormStateStore","devHook","getDevHook","strictCollectMemberUsage","push","ctxStore","waitFor","usedTpls","tpl","add","loadProcessorsImperatively","getBrickPackages","attemptToCheckPermissions","usedFunctions","checkPermissionsUsage","pendingPermissionsPreCheck","size","menu","usedMenuIds","map","menuId","fetchMenuById","getStoryboardByAppId","_internalApiGetStoryboardInBootstrapData","resolveData","asyncComputeRealValue","_hooks$checkInstalled","checkInstalledApps","waitForCheckingApps","_hooks$menu","_hooks$images","data","event","unsafe_penetrate","penetrableCtx","_internalApiGetRuntimeContext","app","currentApp","location","query","match","flags","sys","overrideApp","variableName","hash","substring","cloneDeep","getMenu","getMenuById","getDynamicReadOnlyProxy","get","_target","key","_internalApiGetRuntim","internalCtxStore","getValue","ownKeys","Array","from","getReadOnlyProxy","hasInstalledApp","property","console","getItem","getStorageItem","getMedia","getRuntime","getMiscSettings","URLSearchParams","params","pathname","pkg","customProcessors","_t","k","processor","namespace","split","fromEntries","getAll","warnAboutStrictMode","constants","widgetFunctions","images","widgetImagesFactory","widgetI18nFactory","assign","getGeneralGlobals","storyboardFunctions","appendI18nNamespace","isolatedRoot","result","cook","expression","source","supply","detail","context","devtoolsHookEmit"],"sources":["../../../../src/internal/compute/evaluate.ts"],"sourcesContent":["import {\n cook,\n preevaluate,\n PreevaluateResult,\n shouldAllowRecursiveEvaluations,\n} from \"@next-core/cook\";\nimport { loadProcessorsImperatively } from \"@next-core/loader\";\nimport { supply } from \"@next-core/supply\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport {\n strictCollectMemberUsage,\n collectAppGetMenuUsage,\n collectInstalledAppsHasUsage,\n MemberCallUsage,\n} from \"@next-core/utils/storyboard\";\nimport { cloneDeep, omit } from \"lodash\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { customProcessors } from \"../../CustomProcessors.js\";\nimport {\n checkPermissionsUsage,\n storyboardFunctions,\n} from \"./StoryboardFunctions.js\";\nimport { getGeneralGlobals } from \"./getGeneralGlobals.js\";\nimport {\n getDynamicReadOnlyProxy,\n getReadOnlyProxy,\n} from \"../proxyFactories.js\";\nimport { devtoolsHookEmit, getDevHook } from \"../devtools.js\";\nimport { getMedia } from \"../mediaQuery.js\";\nimport { getStorageItem } from \"./getStorageItem.js\";\nimport {\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n getRuntime,\n hooks,\n} from \"../Runtime.js\";\nimport type { DataStore } from \"../data/DataStore.js\";\nimport { getTplStateStore } from \"../CustomTemplates/utils.js\";\nimport { widgetFunctions } from \"./WidgetFunctions.js\";\nimport { widgetI18nFactory } from \"./WidgetI18n.js\";\nimport { hasInstalledApp } from \"../hasInstalledApp.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../../isStrictMode.js\";\nimport { getFormStateStore } from \"../FormRenderer/utils.js\";\nimport { resolveData } from \"../data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./computeRealValue.js\";\n\nconst symbolForRaw = Symbol.for(\"pre.evaluated.raw\");\nconst symbolForContext = Symbol.for(\"pre.evaluated.context\");\n\nexport interface PreEvaluated {\n [symbolForRaw]: string;\n [symbolForContext]: RuntimeContext;\n}\n\nexport interface EvaluateOptions {\n lazy?: boolean;\n evaluationId?: number;\n}\n\nexport function isPreEvaluated(raw: unknown): raw is PreEvaluated {\n return !!(raw as PreEvaluated)?.[symbolForRaw];\n}\n\nexport function getPreEvaluatedRaw(pre: PreEvaluated): string {\n return pre[symbolForRaw];\n}\n\nexport function shouldDismissMarkingComputed(\n raw: string | PreEvaluated\n): boolean {\n if (typeof raw === \"string\") {\n return shouldAllowRecursiveEvaluations(raw);\n }\n return shouldAllowRecursiveEvaluations(raw[symbolForRaw]);\n}\n\nconst possibleErrorConstructs = new WeakSet<ErrorConstructor>([\n SyntaxError,\n TypeError,\n ReferenceError,\n]);\n\nexport function getCookErrorConstructor(error: any): ErrorConstructor {\n return possibleErrorConstructs.has(error.constructor)\n ? error.constructor\n : TypeError;\n}\n\nexport async function asyncEvaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options?: EvaluateOptions\n): Promise<unknown> {\n const { blockingList, run } = lowLevelEvaluate(\n raw,\n runtimeContext,\n options,\n true\n );\n await Promise.all(blockingList);\n return run();\n}\n\nexport function evaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options?: EvaluateOptions\n): Promise<unknown> {\n const { run } = lowLevelEvaluate(raw, runtimeContext, options, false);\n return run();\n}\n\nfunction lowLevelEvaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options: EvaluateOptions = {},\n isAsync?: boolean\n): {\n blockingList: (Promise<unknown> | undefined)[];\n run: Function;\n} {\n const blockingList: (Promise<unknown> | undefined)[] = [];\n if (typeof raw !== \"string\") {\n // If the `raw` is not a string, it must be a pre-evaluated object.\n // Then fulfil the context, and restore the original `raw`.\n\n const passByRuntimeContext = omit(runtimeContext, [\n \"pendingPermissionsPreCheck\",\n \"tplStateStoreMap\",\n \"tplStateStoreScope\",\n \"formStateStoreMap\",\n \"formStateStoreScope\",\n ]);\n\n runtimeContext = {\n ...raw[symbolForContext],\n ...passByRuntimeContext,\n };\n raw = raw[symbolForRaw];\n }\n\n // Collect `APP.getMenu(...)` usage before evaluating.\n const menuUsage: MemberCallUsage = {\n usedArgs: new Set(),\n };\n const hasAppUsage: MemberCallUsage = {\n usedArgs: new Set(),\n };\n\n // A `SyntaxError` maybe thrown.\n let precooked: PreevaluateResult;\n try {\n precooked = preevaluate(raw, {\n cache: true,\n withParent: true,\n hooks: {\n beforeVisitGlobal(node, parent) {\n collectAppGetMenuUsage(menuUsage, node, parent!);\n collectInstalledAppsHasUsage(hasAppUsage, node, parent!);\n },\n },\n });\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n }\n\n if (menuUsage.hasNonStaticUsage) {\n throw new Error(\n `Non-static usage of \"APP.getMenu\" is prohibited in v3, check your expression: \"${raw}\"`\n );\n }\n\n if (hasAppUsage.hasNonStaticUsage) {\n throw new Error(\n `Non-static usage of \"INSTALLED_APPS.has\" is prohibited in v3, check your expression: \"${raw}\"`\n );\n }\n\n const globalVariables: Record<string, unknown> = {};\n const { attemptToVisitGlobals } = precooked;\n\n // Ignore evaluating if required `event/DATA` is missing in\n // context. Since they are are provided in different context, whenever\n // missing one of them, memorize the current context for later consuming.\n if (\n options.lazy ||\n (attemptToVisitGlobals.has(\"EVENT\") &&\n !hasOwnProperty(runtimeContext, \"event\")) ||\n (attemptToVisitGlobals.has(\"DATA\") &&\n !hasOwnProperty(runtimeContext, \"data\"))\n ) {\n return {\n blockingList,\n run() {\n return Object.keys(runtimeContext).length > 0\n ? ({\n [symbolForRaw]: raw,\n [symbolForContext]: runtimeContext,\n } as PreEvaluated)\n : raw;\n },\n };\n }\n\n let usedCtx: Set<string> | undefined;\n let usedProcessors: Set<string>;\n let usedStates: Set<string>;\n let tplStateStore: DataStore<\"STATE\"> | undefined;\n const strict = isStrictMode(runtimeContext);\n\n // For existed TPL usage, treat it as a STATE.\n if (\n attemptToVisitGlobals.has(\"STATE\") ||\n (!strict && attemptToVisitGlobals.has(\"TPL\"))\n ) {\n tplStateStore = getTplStateStore(runtimeContext, \"STATE\", `: \"${raw}\"`);\n }\n\n let usedFormStates: Set<string>;\n let formStateStore: DataStore<\"FORM_STATE\"> | undefined;\n if (attemptToVisitGlobals.has(\"FORM_STATE\")) {\n formStateStore = getFormStateStore(\n runtimeContext,\n \"FORM_STATE\",\n `: \"${raw}\"`\n );\n }\n\n const devHook = getDevHook();\n if (isAsync || devHook) {\n if (attemptToVisitGlobals.has(\"CTX\")) {\n usedCtx = strictCollectMemberUsage(raw, \"CTX\");\n isAsync && blockingList.push(runtimeContext.ctxStore.waitFor(usedCtx));\n }\n\n if (tplStateStore) {\n usedStates = strictCollectMemberUsage(raw, \"STATE\");\n // istanbul ignore if\n if (!strict) {\n const usedTpls = strictCollectMemberUsage(raw, \"TPL\");\n for (const tpl of usedTpls) {\n usedStates.add(tpl);\n }\n }\n isAsync && blockingList.push(tplStateStore.waitFor(usedStates));\n }\n\n if (formStateStore) {\n usedFormStates = strictCollectMemberUsage(raw, \"FORM_STATE\");\n isAsync && blockingList.push(formStateStore.waitFor(usedFormStates));\n }\n\n if (attemptToVisitGlobals.has(\"PROCESSORS\")) {\n usedProcessors = strictCollectMemberUsage(raw, \"PROCESSORS\", 2);\n isAsync &&\n blockingList.push(\n loadProcessorsImperatively(usedProcessors, getBrickPackages())\n );\n }\n }\n\n if (isAsync) {\n let attemptToCheckPermissions = attemptToVisitGlobals.has(\"PERMISSIONS\");\n // There maybe `PERMISSIONS.check()` usage in functions\n if (!attemptToCheckPermissions && attemptToVisitGlobals.has(\"FN\")) {\n const usedFunctions = [...strictCollectMemberUsage(raw, \"FN\")];\n attemptToCheckPermissions = checkPermissionsUsage(usedFunctions);\n }\n\n if (attemptToCheckPermissions) {\n blockingList.push(...runtimeContext.pendingPermissionsPreCheck);\n }\n\n if (menuUsage.usedArgs.size > 0 && hooks?.menu) {\n // Block evaluating if has `APP.getMenu(...)` usage.\n const usedMenuIds = [...menuUsage.usedArgs];\n blockingList.push(\n Promise.all(\n usedMenuIds.map((menuId) =>\n hooks!.menu!.fetchMenuById(menuId, runtimeContext, {\n getStoryboardByAppId: _internalApiGetStoryboardInBootstrapData,\n resolveData,\n asyncComputeRealValue,\n })\n )\n )\n );\n }\n\n if (hasAppUsage.usedArgs.size > 0) {\n // Only wait for specific apps\n blockingList.push(\n hooks?.checkInstalledApps?.waitForCheckingApps([\n ...hasAppUsage.usedArgs,\n ])\n );\n }\n }\n\n return {\n blockingList,\n run() {\n const { ctxStore, data, event, unsafe_penetrate } = runtimeContext;\n\n const penetrableCtx = unsafe_penetrate\n ? _internalApiGetRuntimeContext()!\n : runtimeContext;\n\n const {\n app: currentApp,\n location,\n query,\n match,\n flags,\n sys,\n } = penetrableCtx;\n const app = penetrableCtx.overrideApp ?? currentApp;\n\n for (const variableName of attemptToVisitGlobals) {\n switch (variableName) {\n // case \"ALIAS\":\n case \"ANCHOR\":\n globalVariables[variableName] = location.hash\n ? location.hash.substring(1)\n : null;\n break;\n case \"APP\":\n if (app == null) {\n throw new ReferenceError(`APP is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = {\n ...cloneDeep(app),\n getMenu: hooks?.menu?.getMenuById,\n };\n break;\n case \"CTX\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n // Allow accessing global `CTX.DS` from an isolated root such as dashboard.\n if (key === \"DS\" && !ctxStore.has(key)) {\n const internalCtxStore =\n _internalApiGetRuntimeContext()?.ctxStore;\n if (internalCtxStore?.has(key)) {\n return internalCtxStore.getValue(key);\n }\n }\n return ctxStore.getValue(key as string);\n },\n ownKeys() {\n return usedCtx ? Array.from(usedCtx) : [];\n },\n });\n break;\n case \"DATA\":\n globalVariables[variableName] = data;\n break;\n case \"EVENT\":\n globalVariables[variableName] = event;\n break;\n case \"FLAGS\":\n globalVariables[variableName] = getReadOnlyProxy(flags);\n break;\n case \"FORM_STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n return formStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedFormStates);\n },\n });\n break;\n case \"HASH\":\n globalVariables[variableName] = location.hash;\n break;\n case \"INSTALLED_APPS\":\n globalVariables[variableName] = getReadOnlyProxy({\n has: hasInstalledApp,\n });\n break;\n case \"ITEM\":\n case \"INDEX\":\n case \"SIZE\": {\n const property =\n variableName === \"ITEM\"\n ? \"forEachItem\"\n : variableName === \"INDEX\"\n ? \"forEachIndex\"\n : \"forEachSize\";\n if (!hasOwnProperty(runtimeContext, property)) {\n // eslint-disable-next-line no-console\n console.error(\n `Using \\`${variableName}\\` but no \\`:forEach\\` is found, check your expression: \"${raw}\"`\n );\n } else {\n globalVariables[variableName] = runtimeContext[property];\n }\n break;\n }\n case \"LOCAL_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"local\"),\n });\n break;\n case \"MEDIA\":\n globalVariables[variableName] = getReadOnlyProxy(getMedia());\n break;\n case \"MISC\":\n globalVariables[variableName] = getRuntime().getMiscSettings();\n break;\n case \"PARAMS\":\n if (query == null) {\n throw new ReferenceError(`PARAMS is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = new URLSearchParams(query);\n break;\n case \"PATH\":\n globalVariables[variableName] = getReadOnlyProxy(\n match?.params ?? {}\n );\n break;\n case \"PATH_NAME\":\n globalVariables[variableName] = location.pathname;\n break;\n case \"PROCESSORS\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n const pkg = customProcessors.get(key as string);\n if (!pkg) {\n throw new Error(\n `'PROCESSORS.${\n key as string\n }' is not registered! Have you installed the relevant brick package?`\n );\n }\n return getDynamicReadOnlyProxy({\n get(_t, k) {\n return pkg.get(k as string);\n },\n ownKeys() {\n return Array.from(pkg.keys());\n },\n });\n },\n ownKeys() {\n const keys = new Set<string>();\n for (const processor of usedProcessors) {\n const namespace = processor.split(\".\")[0];\n keys.add(namespace);\n }\n return Array.from(keys);\n },\n });\n break;\n case \"QUERY\":\n if (query == null) {\n throw new ReferenceError(`QUERY is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.get(key)])\n );\n break;\n case \"QUERY_ARRAY\":\n if (query == null) {\n throw new ReferenceError(\n `QUERY_ARRAY is not defined, in \"${raw}\"`\n );\n }\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.getAll(key)])\n );\n // case \"SEGUE\":\n break;\n case \"SESSION_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"session\"),\n });\n break;\n // istanbul ignore next\n case \"TPL\":\n warnAboutStrictMode(\n strict,\n 'Using \"TPL\" in expression',\n `check your expression: \"${raw}\"`\n );\n if (strict) {\n break;\n }\n // eslint-disable-next-line no-fallthrough\n case \"STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n return tplStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedStates);\n },\n });\n break;\n case \"SYS\":\n globalVariables[variableName] = getReadOnlyProxy(sys ?? {});\n break;\n case \"CONSTANTS\":\n // globalVariables[variableName] = getReadOnlyProxy(app?.constants ?? {});\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n if (!app?.constants || !hasOwnProperty(app.constants, key)) {\n throw new ReferenceError(\n `CONSTANTS.${key as string} is not defined`\n );\n }\n return app.constants[key as string];\n },\n ownKeys() {\n return app?.constants ? Object.keys(app.constants) : [];\n },\n });\n break;\n case \"__WIDGET_FN__\":\n globalVariables[variableName] = widgetFunctions;\n break;\n case \"__WIDGET_IMG__\":\n globalVariables[variableName] = hooks?.images?.widgetImagesFactory;\n break;\n case \"__WIDGET_I18N__\":\n globalVariables[variableName] = widgetI18nFactory;\n break;\n }\n }\n\n Object.assign(\n globalVariables,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n storyboardFunctions,\n app,\n appendI18nNamespace: runtimeContext.appendI18nNamespace,\n isolatedRoot: runtimeContext.isolatedRoot,\n })\n );\n\n try {\n const result = cook(precooked.expression, precooked.source, {\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n globalVariables\n ),\n });\n const detail = { raw, context: globalVariables, result };\n devtoolsHookEmit(\"evaluation\", detail);\n return result;\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AAIA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AAIA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,eAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AAQA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,gBAAA,GAAAf,OAAA;AACA,IAAAgB,WAAA,GAAAhB,OAAA;AACA,IAAAiB,gBAAA,GAAAjB,OAAA;AACA,IAAAkB,aAAA,GAAAlB,OAAA;AACA,IAAAmB,OAAA,GAAAnB,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SAAS,CAACe,qBAAqB,EAAE;QACjDwG,mBAAmB,EAAnBA,wCAAmB;QACnBrD,GAAG;QACHsD,mBAAmB,EAAEvI,cAAc,CAACuI,mBAAmB;QACvDC,YAAY,EAAExI,cAAc,CAACwI;MAC/B,CAAC,CACH,CAAC;MAED,IAAI;QACF,MAAMC,MAAM,GAAG,IAAAC,UAAI,EAAC3H,SAAS,CAAC4H,UAAU,EAAE5H,SAAS,CAAC6H,MAAM,EAAE;UAC1D/G,eAAe,EAAE,IAAAgH,cAAM,EACrB9H,SAAS,CAACe,qBAAqB,EAC/BD,eACF;QACF,CAAC,CAAC;QACF,MAAMiH,MAAM,GAAG;UAAE7J,GAAG;UAAE8J,OAAO,EAAElH,eAAe;UAAE4G;QAAO,CAAC;QACxD,IAAAO,0BAAgB,EAAC,YAAY,EAAEF,MAAM,CAAC;QACtC,OAAOL,MAAM;MACf,CAAC,CAAC,OAAO7I,KAAU,EAAE;QACnB,MAAM6B,OAAO,GAAG,GAAG7B,KAAK,CAAC6B,OAAO,SAASxC,GAAG,GAAG;QAC/C,MAAMyC,gBAAgB,GAAG/B,uBAAuB,CAACC,KAAK,CAAC;QACvD,MAAM,IAAI8B,gBAAgB,CAACD,OAAO,CAAC;MACrC;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -794,13 +794,19 @@ export function childrenToSlots(children, originalSlots) {
794
794
  ...child
795
795
  } of children) {
796
796
  const slot = sl !== null && sl !== void 0 ? sl : "";
797
- if (!hasOwnProperty(newSlots, slot)) {
797
+ const type = isRouteConf(child) ? "routes" : "bricks";
798
+ if (hasOwnProperty(newSlots, slot)) {
799
+ const slotConf = newSlots[slot];
800
+ if (slotConf.type !== type) {
801
+ throw new Error(`Slot "${slot}" conflict between bricks and routes.`);
802
+ }
803
+ slotConf[type].push(child);
804
+ } else {
798
805
  newSlots[slot] = {
799
- type: "bricks",
800
- bricks: []
806
+ type: type,
807
+ [type]: [child]
801
808
  };
802
809
  }
803
- newSlots[slot].bricks.push(child);
804
810
  }
805
811
  }
806
812
  return newSlots;
@@ -822,4 +828,7 @@ function isRouteParamsEqual(a, b) {
822
828
  const d = omitBy(b, omitNumericKeys);
823
829
  return isEqual(c, d);
824
830
  }
831
+ function isRouteConf(child) {
832
+ return !!child.path && !child.brick;
833
+ }
825
834
  //# sourceMappingURL=Renderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Renderer.js","names":["enqueueStableLoadBricks","flushStableLoadBricks","loadBricksImperatively","loadProcessorsImperatively","loadScript","loadStyle","isTrackAll","hasOwnProperty","strictCollectMemberUsage","debounce","isEqual","omitBy","asyncCheckBrickIf","asyncComputeRealPropertyEntries","constructAsyncProperties","clearResolveCache","resolveData","asyncComputeRealValue","listenOnTrackingContext","trackAfterInitial","matchRoute","matchRoutes","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachSize","symbolForTplStateStoreId","expandCustomTemplate","getTagNameOfCustomTemplate","getTplStateStore","customTemplates","getBrickPackages","hooks","RenderTag","getTracks","isStrictMode","warnAboutStrictMode","FORM_RENDERER","symbolForFormStateStoreId","expandFormRenderer","registerFormRenderer","isPreEvaluated","getPreEvaluatedRaw","matchHomepage","listenerFactory","setupRootRuntimeContext","setMatchedRoute","ErrorNode","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","parentRoutes","menuRequestReturnNode","slotId","isIncremental","initialTracker","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","usedProcessors","size","catchLoad","join","unknownBricks","newOutput","renderBricks","bricks","mergeRenderOutput","appendMenuRequestNode","tplStack","rendered","Promise","all","map","brickConf","renderBrick","Map","forEach","item","arguments","length","legacyRenderBrick","errorBoundary","node","_hooks$checkPermissio2","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","formStateStoreId","forEachItem","forEachIndex","forEachSize","strict","brickName","startsWith","_brickConf$lifeCycle","ensureValidControlBrick","contextNames","stateNames","tracking","lowerLevelRenderControlNode","tracker","trackDataSource","_slots$slot","computedDataSource","propValue","slot","String","childrenToSlots","children","abstractNode","tag","ABSTRACT","childrenOutput","renderForEach","child","renderControlNode","_ref","tplStateStoreScope","formStateStoreScope","changedAfterInitial","disposes","listener","rerenderCount","rawOutput","uninitialized","scopedStores","postAsyncRender","dispose","controlledOutput","onMount","onUnmount","lifeCycle","_runtimeBrick$dispose","renderId","mounted","disposed","currentRenderId","scopedRuntimeContext","createScopedRuntimeContext","reControlledOutput","CustomEvent","detail","rerender","reRender","store","mountAsyncData","debouncedListener","leading","trailing","runtimeBrick","ROOT","contextName","onChange","tplStateStore","registerArbitraryLifeCycle","test","get","tplTagName","_tplStack$get","tplCount","set","includes","customElements","formData","confProps","_brickConf$properties","_brickConf$properties2","properties","compute","inUseBrick","trackingContextList","asyncPropertyEntries","computedPropsFromHost","isScript","props","src","rel","href","_window$PUBLIC_ROOT","prefix","window","PUBLIC_ROOT","attrs","BRICK","events","portal","ref","loadProperties","registerBrickLifeCycle","expandedBrickConf","childRuntimeContext","loadChildren","routeSlotFromIndexToSlotId","entries","_ref2","index","childSlotId","slotConf","lastOutput","parentRoute","incrementalSubRoutes","performIncrementalRender","location","prevLocation","homepage","app","pathname","every","prevMatch","newMatch","isRouteParamsEqual","params","query","URLSearchParams","search","failed","incrementalOutput","newControlNode","reBailout","result","reCatch","reMergeMenuRequestNodes","routesOutput","mergeSiblingRenderMenuRequest","i","flat","getDataStores","tplStateStoreMap","values","formStateStoreMap","stores","waitForAll","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","sl","promise","name","unknownPolicy","catch","e","a","b","omitNumericKeys","v","k","Number","c","d"],"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, omitBy } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealPropertyEntries,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { clearResolveCache, resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n trackAfterInitial,\n type InitialTracker,\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 symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n MenuRequestNode,\n RenderBrick,\n RenderChildNode,\n RenderAbstract,\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 { registerFormRenderer } from \"./FormRenderer/registerFormRenderer.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 { setMatchedRoute } from \"./routeMatchedMap.js\";\nimport { ErrorNode } from \"./ErrorNode.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}\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 initialTracker?: InitialTracker\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 const usedProcessors = strictCollectMemberUsage(\n route.context,\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 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 undefined,\n initialTracker\n );\n } else {\n newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId,\n undefined,\n initialTracker\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 initialTracker?: InitialTracker\n): Promise<RenderOutput> {\n setupRootRuntimeContext(bricks, runtimeContext, true);\n const output = getEmptyRenderOutput();\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack && new Map(tplStack),\n initialTracker\n )\n )\n );\n\n rendered.forEach((item) => {\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 tplStack = new Map<string, number>(),\n initialTracker?: InitialTracker\n): Promise<RenderOutput> {\n try {\n return await legacyRenderBrick(\n returnNode,\n brickConf,\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n initialTracker\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: await ErrorNode(error, returnNode),\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 tplStack: Map<string, number>,\n initialTracker?: InitialTracker\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 iid: brickConf.iid,\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[symbol as typeof symbolForTplStateStoreId],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n initialTracker\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 }\n\n const strict = isStrictMode(runtimeContext);\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\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 const { contextNames, stateNames } = getTracks(dataSource);\n const tracking = !!(contextNames || stateNames);\n\n const lowerLevelRenderControlNode = async (\n runtimeContext: RuntimeContext,\n tracker: InitialTracker,\n trackDataSource: boolean\n ) => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n if (trackDataSource) {\n trackAfterInitial(\n runtimeContext,\n [{ contextNames, stateNames, propValue: dataSource }],\n tracker\n );\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 const output = getEmptyRenderOutput();\n const abstractNode: RenderAbstract = {\n tag: RenderTag.ABSTRACT,\n return: returnNode,\n iid: brickConf.iid,\n };\n output.node = abstractNode;\n\n if (!Array.isArray(bricks)) {\n return output;\n }\n\n let childrenOutput: RenderOutput | undefined;\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n break;\n }\n childrenOutput = await renderForEach(\n abstractNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n tracker\n );\n break;\n }\n case \":if\":\n case \":switch\": {\n childrenOutput = await renderBricks(\n abstractNode,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n tracker\n );\n }\n }\n\n if (childrenOutput) {\n abstractNode.child = childrenOutput.node;\n mergeRenderOutput(output, { ...childrenOutput, node: undefined });\n }\n\n return output;\n };\n\n type RenderControlNodeOptions =\n | {\n type: \"initial\";\n runtimeContext: RuntimeContext;\n tplStateStoreScope?: undefined;\n formStateStoreScope?: undefined;\n }\n | {\n type: \"rerender\";\n runtimeContext: RuntimeContext;\n tplStateStoreScope: DataStore<\"STATE\">[];\n formStateStoreScope: DataStore<\"FORM_STATE\">[];\n };\n\n const renderControlNode = async ({\n type,\n runtimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n }: RenderControlNodeOptions) => {\n let changedAfterInitial = false;\n const tracker: InitialTracker = {\n disposes: [],\n listener: () => {\n changedAfterInitial = true;\n },\n };\n let rerenderCount = 0;\n let rawOutput: RenderOutput;\n let uninitialized = true;\n\n // When perform an incremental sub-route render, for control nodes,\n // context maybe changed just after their data source being computed,\n // as well as props of their children bricks being computed, and before\n // bricks being mounted. Thus these changes may not take any effects.\n // So we need to track the context changes after the initial render,\n // and perform re-renders for these control nodes if necessary.\n while (uninitialized || changedAfterInitial) {\n changedAfterInitial = false;\n rawOutput = await lowerLevelRenderControlNode(\n runtimeContext,\n tracker,\n uninitialized && type === \"initial\"\n );\n\n // Changes may happen during `postAsyncRender`.\n if (!changedAfterInitial && type === \"rerender\") {\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n await postAsyncRender(rawOutput, runtimeContext, [\n runtimeContext.ctxStore,\n ...scopedStores,\n ]);\n }\n\n tracker.disposes.forEach((dispose) => dispose());\n tracker.disposes.length = 0;\n uninitialized = false;\n // istanbul ignore next\n if (++rerenderCount > 10) {\n throw new Error(\n `Maximum rerender stack overflowed (iid: ${brickConf.iid})`\n );\n }\n }\n\n return rawOutput!;\n };\n\n let controlledOutput = await renderControlNode({\n type: \"initial\",\n runtimeContext,\n });\n const { onMount, onUnmount } = brickConf.lifeCycle ?? {};\n\n if (tracking) {\n let renderId = 0;\n const listener = async () => {\n // TODO(steve): start listeners when mounting, and handle changes between rendering and mounting.\n if (!returnNode.mounted || returnNode.disposed) {\n return;\n }\n\n const currentRenderId = ++renderId;\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext(runtimeContext);\n\n const reControlledOutput = await renderControlNode({\n type: \"rerender\",\n runtimeContext: scopedRuntimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n });\n\n // Ignore stale renders\n if (\n renderId === currentRenderId &&\n returnNode.mounted &&\n !returnNode.disposed\n ) {\n if (onUnmount) {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: true } }));\n }\n\n rendererContext.reRender(\n returnNode,\n reControlledOutput.node!,\n controlledOutput.node!\n );\n controlledOutput = reControlledOutput;\n\n if (onMount) {\n listenerFactory(\n onMount,\n scopedRuntimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: true } }));\n }\n\n for (const store of [...tplStateStoreScope, ...formStateStoreScope]) {\n store.mountAsyncData();\n }\n }\n };\n // Enable leading invocation, to keep tracking orders.\n const debouncedListener = debounce(listener, 0, {\n leading: true,\n trailing: true,\n });\n const runtimeBrick =\n returnNode.tag === RenderTag.ROOT ? null : returnNode;\n const disposes = runtimeBrick ? (runtimeBrick.disposes ??= []) : [];\n if (contextNames) {\n for (const contextName of contextNames) {\n disposes.push(\n runtimeContext.ctxStore.onChange(contextName, debouncedListener)\n );\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n disposes.push(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(brickName, runtimeContext);\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 registerFormRenderer();\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 if (runtimeContext.inUseBrick) {\n // Keep v2 behavior for `useBrick`: treat `transform` as `properties`.\n const transform = (brickConf as { transform?: Record<string, unknown> })\n .transform;\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n brickConf\n );\n\n if (!strict) {\n confProps = {\n ...brickConf.properties,\n ...transform,\n };\n }\n }\n }\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 // Note: properties here has already been initialized.\n trackAfterInitial(runtimeContext, trackingContextList, initialTracker);\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(async ([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 initialTracker\n );\n }\n\n let lastOutput = getEmptyRenderOutput();\n const abstractNode: RenderAbstract = {\n tag: RenderTag.ABSTRACT,\n return: brick,\n };\n lastOutput.node = abstractNode;\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 isRouteParamsEqual(prevMatch.params, newMatch.params))\n );\n })\n ) {\n return false;\n }\n\n clearResolveCache();\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 const newOutput = getEmptyRenderOutput();\n const newControlNode: RenderAbstract = {\n tag: RenderTag.ABSTRACT,\n return: brick,\n };\n newOutput.node = newControlNode;\n\n try {\n incrementalOutput = await renderRoutes(\n newControlNode,\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 } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Incremental sub-router failed:\", error);\n\n const result = await rendererContext.reCatch(\n error,\n newControlNode\n );\n if (!result) {\n return true;\n }\n ({ failed, output: incrementalOutput } = result);\n }\n\n // istanbul ignore next: covered by e2e tests\n if (brick.disposed) {\n return true;\n }\n\n newControlNode.child = incrementalOutput.node;\n mergeRenderOutput(newOutput, {\n ...incrementalOutput,\n node: undefined,\n });\n // Assert: no errors will be throw\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n\n rendererContext.reRender(brick, newControlNode, lastOutput.node!);\n\n lastOutput = newOutput;\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 // Even if all sub-routes missed, treat the incremental rendering as performed.\n return true;\n }\n );\n }\n\n const routesOutput = await renderRoutes(\n abstractNode,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n undefined,\n initialTracker\n );\n\n abstractNode.child = routesOutput.node;\n mergeRenderOutput(output, { ...routesOutput, node: undefined });\n appendMenuRequestNode(\n menuRequestReturnNode,\n (output.menuRequestNode = routesOutput.menuRequestNode)\n );\n\n return lastOutput;\n })\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n menuRequestNode: undefined,\n };\n rendered.forEach((item) => {\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 initialTracker?: InitialTracker\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) =>\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 tplStack && new Map(tplStack),\n initialTracker\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n rendered.flat().forEach((item) => {\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 const { blockingList, node, menuRequestNode, ...rest } = 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 { slot: sl, ...child } of children) {\n const slot = sl ?? \"\";\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\nfunction isRouteParamsEqual(\n a: Record<string, string>,\n b: Record<string, string>\n) {\n if (isEqual(a, b)) {\n return true;\n }\n const omitNumericKeys = (v: unknown, k: string) => {\n return String(Number(k)) === k;\n };\n const c = omitBy(a, omitNumericKeys);\n const d = omitBy(b, omitNumericKeys);\n return isEqual(c, d);\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;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,CAAC0S,CAAC,EAAEC,CAAC,CAAC;AACtB","ignoreList":[]}
1
+ {"version":3,"file":"Renderer.js","names":["enqueueStableLoadBricks","flushStableLoadBricks","loadBricksImperatively","loadProcessorsImperatively","loadScript","loadStyle","isTrackAll","hasOwnProperty","strictCollectMemberUsage","debounce","isEqual","omitBy","asyncCheckBrickIf","asyncComputeRealPropertyEntries","constructAsyncProperties","clearResolveCache","resolveData","asyncComputeRealValue","listenOnTrackingContext","trackAfterInitial","matchRoute","matchRoutes","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachSize","symbolForTplStateStoreId","expandCustomTemplate","getTagNameOfCustomTemplate","getTplStateStore","customTemplates","getBrickPackages","hooks","RenderTag","getTracks","isStrictMode","warnAboutStrictMode","FORM_RENDERER","symbolForFormStateStoreId","expandFormRenderer","registerFormRenderer","isPreEvaluated","getPreEvaluatedRaw","matchHomepage","listenerFactory","setupRootRuntimeContext","setMatchedRoute","ErrorNode","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","parentRoutes","menuRequestReturnNode","slotId","isIncremental","initialTracker","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","usedProcessors","size","catchLoad","join","unknownBricks","newOutput","renderBricks","bricks","mergeRenderOutput","appendMenuRequestNode","tplStack","rendered","Promise","all","map","brickConf","renderBrick","Map","forEach","item","arguments","length","legacyRenderBrick","errorBoundary","node","_hooks$checkPermissio2","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","formStateStoreId","forEachItem","forEachIndex","forEachSize","strict","brickName","startsWith","_brickConf$lifeCycle","ensureValidControlBrick","contextNames","stateNames","tracking","lowerLevelRenderControlNode","tracker","trackDataSource","_slots$slot","computedDataSource","propValue","slot","String","childrenToSlots","children","abstractNode","tag","ABSTRACT","childrenOutput","renderForEach","child","renderControlNode","_ref","tplStateStoreScope","formStateStoreScope","changedAfterInitial","disposes","listener","rerenderCount","rawOutput","uninitialized","scopedStores","postAsyncRender","dispose","controlledOutput","onMount","onUnmount","lifeCycle","_runtimeBrick$dispose","renderId","mounted","disposed","currentRenderId","scopedRuntimeContext","createScopedRuntimeContext","reControlledOutput","CustomEvent","detail","rerender","reRender","store","mountAsyncData","debouncedListener","leading","trailing","runtimeBrick","ROOT","contextName","onChange","tplStateStore","registerArbitraryLifeCycle","test","get","tplTagName","_tplStack$get","tplCount","set","includes","customElements","formData","confProps","_brickConf$properties","_brickConf$properties2","properties","compute","inUseBrick","trackingContextList","asyncPropertyEntries","computedPropsFromHost","isScript","props","src","rel","href","_window$PUBLIC_ROOT","prefix","window","PUBLIC_ROOT","attrs","BRICK","events","portal","ref","loadProperties","registerBrickLifeCycle","expandedBrickConf","childRuntimeContext","loadChildren","routeSlotFromIndexToSlotId","entries","_ref2","index","childSlotId","slotConf","lastOutput","parentRoute","incrementalSubRoutes","performIncrementalRender","location","prevLocation","homepage","app","pathname","every","prevMatch","newMatch","isRouteParamsEqual","params","query","URLSearchParams","search","failed","incrementalOutput","newControlNode","reBailout","result","reCatch","reMergeMenuRequestNodes","routesOutput","mergeSiblingRenderMenuRequest","i","flat","getDataStores","tplStateStoreMap","values","formStateStoreMap","stores","waitForAll","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","sl","isRouteConf","promise","name","unknownPolicy","catch","e","a","b","omitNumericKeys","v","k","Number","c","d"],"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, omitBy } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealPropertyEntries,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { clearResolveCache, resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n trackAfterInitial,\n type InitialTracker,\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 symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n MenuRequestNode,\n RenderBrick,\n RenderChildNode,\n RenderAbstract,\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 { registerFormRenderer } from \"./FormRenderer/registerFormRenderer.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 { setMatchedRoute } from \"./routeMatchedMap.js\";\nimport { ErrorNode } from \"./ErrorNode.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}\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 initialTracker?: InitialTracker\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 const usedProcessors = strictCollectMemberUsage(\n route.context,\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 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 undefined,\n initialTracker\n );\n } else {\n newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n routePath,\n menuRequestNode,\n slotId,\n undefined,\n initialTracker\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 initialTracker?: InitialTracker\n): Promise<RenderOutput> {\n setupRootRuntimeContext(bricks, runtimeContext, true);\n const output = getEmptyRenderOutput();\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack && new Map(tplStack),\n initialTracker\n )\n )\n );\n\n rendered.forEach((item) => {\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 tplStack = new Map<string, number>(),\n initialTracker?: InitialTracker\n): Promise<RenderOutput> {\n try {\n return await legacyRenderBrick(\n returnNode,\n brickConf,\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n initialTracker\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: await ErrorNode(error, returnNode),\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 tplStack: Map<string, number>,\n initialTracker?: InitialTracker\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 iid: brickConf.iid,\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[symbol as typeof symbolForTplStateStoreId],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n initialTracker\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 }\n\n const strict = isStrictMode(runtimeContext);\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\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 const { contextNames, stateNames } = getTracks(dataSource);\n const tracking = !!(contextNames || stateNames);\n\n const lowerLevelRenderControlNode = async (\n runtimeContext: RuntimeContext,\n tracker: InitialTracker,\n trackDataSource: boolean\n ) => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n if (trackDataSource) {\n trackAfterInitial(\n runtimeContext,\n [{ contextNames, stateNames, propValue: dataSource }],\n tracker\n );\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 const output = getEmptyRenderOutput();\n const abstractNode: RenderAbstract = {\n tag: RenderTag.ABSTRACT,\n return: returnNode,\n iid: brickConf.iid,\n };\n output.node = abstractNode;\n\n if (!Array.isArray(bricks)) {\n return output;\n }\n\n let childrenOutput: RenderOutput | undefined;\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n break;\n }\n childrenOutput = await renderForEach(\n abstractNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n tracker\n );\n break;\n }\n case \":if\":\n case \":switch\": {\n childrenOutput = await renderBricks(\n abstractNode,\n bricks,\n runtimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n slotId,\n tplStack,\n tracker\n );\n }\n }\n\n if (childrenOutput) {\n abstractNode.child = childrenOutput.node;\n mergeRenderOutput(output, { ...childrenOutput, node: undefined });\n }\n\n return output;\n };\n\n type RenderControlNodeOptions =\n | {\n type: \"initial\";\n runtimeContext: RuntimeContext;\n tplStateStoreScope?: undefined;\n formStateStoreScope?: undefined;\n }\n | {\n type: \"rerender\";\n runtimeContext: RuntimeContext;\n tplStateStoreScope: DataStore<\"STATE\">[];\n formStateStoreScope: DataStore<\"FORM_STATE\">[];\n };\n\n const renderControlNode = async ({\n type,\n runtimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n }: RenderControlNodeOptions) => {\n let changedAfterInitial = false;\n const tracker: InitialTracker = {\n disposes: [],\n listener: () => {\n changedAfterInitial = true;\n },\n };\n let rerenderCount = 0;\n let rawOutput: RenderOutput;\n let uninitialized = true;\n\n // When perform an incremental sub-route render, for control nodes,\n // context maybe changed just after their data source being computed,\n // as well as props of their children bricks being computed, and before\n // bricks being mounted. Thus these changes may not take any effects.\n // So we need to track the context changes after the initial render,\n // and perform re-renders for these control nodes if necessary.\n while (uninitialized || changedAfterInitial) {\n changedAfterInitial = false;\n rawOutput = await lowerLevelRenderControlNode(\n runtimeContext,\n tracker,\n uninitialized && type === \"initial\"\n );\n\n // Changes may happen during `postAsyncRender`.\n if (!changedAfterInitial && type === \"rerender\") {\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n await postAsyncRender(rawOutput, runtimeContext, [\n runtimeContext.ctxStore,\n ...scopedStores,\n ]);\n }\n\n tracker.disposes.forEach((dispose) => dispose());\n tracker.disposes.length = 0;\n uninitialized = false;\n // istanbul ignore next\n if (++rerenderCount > 10) {\n throw new Error(\n `Maximum rerender stack overflowed (iid: ${brickConf.iid})`\n );\n }\n }\n\n return rawOutput!;\n };\n\n let controlledOutput = await renderControlNode({\n type: \"initial\",\n runtimeContext,\n });\n const { onMount, onUnmount } = brickConf.lifeCycle ?? {};\n\n if (tracking) {\n let renderId = 0;\n const listener = async () => {\n // TODO(steve): start listeners when mounting, and handle changes between rendering and mounting.\n if (!returnNode.mounted || returnNode.disposed) {\n return;\n }\n\n const currentRenderId = ++renderId;\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext(runtimeContext);\n\n const reControlledOutput = await renderControlNode({\n type: \"rerender\",\n runtimeContext: scopedRuntimeContext,\n tplStateStoreScope,\n formStateStoreScope,\n });\n\n // Ignore stale renders\n if (\n renderId === currentRenderId &&\n returnNode.mounted &&\n !returnNode.disposed\n ) {\n if (onUnmount) {\n listenerFactory(\n onUnmount,\n runtimeContext\n )(new CustomEvent(\"unmount\", { detail: { rerender: true } }));\n }\n\n rendererContext.reRender(\n returnNode,\n reControlledOutput.node!,\n controlledOutput.node!\n );\n controlledOutput = reControlledOutput;\n\n if (onMount) {\n listenerFactory(\n onMount,\n scopedRuntimeContext\n )(new CustomEvent(\"mount\", { detail: { rerender: true } }));\n }\n\n for (const store of [...tplStateStoreScope, ...formStateStoreScope]) {\n store.mountAsyncData();\n }\n }\n };\n // Enable leading invocation, to keep tracking orders.\n const debouncedListener = debounce(listener, 0, {\n leading: true,\n trailing: true,\n });\n const runtimeBrick =\n returnNode.tag === RenderTag.ROOT ? null : returnNode;\n const disposes = runtimeBrick ? (runtimeBrick.disposes ??= []) : [];\n if (contextNames) {\n for (const contextName of contextNames) {\n disposes.push(\n runtimeContext.ctxStore.onChange(contextName, debouncedListener)\n );\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n disposes.push(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(brickName, runtimeContext);\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 registerFormRenderer();\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 if (runtimeContext.inUseBrick) {\n // Keep v2 behavior for `useBrick`: treat `transform` as `properties`.\n const transform = (brickConf as { transform?: Record<string, unknown> })\n .transform;\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n brickConf\n );\n\n if (!strict) {\n confProps = {\n ...brickConf.properties,\n ...transform,\n };\n }\n }\n }\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 // Note: properties here has already been initialized.\n trackAfterInitial(runtimeContext, trackingContextList, initialTracker);\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(async ([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 initialTracker\n );\n }\n\n let lastOutput = getEmptyRenderOutput();\n const abstractNode: RenderAbstract = {\n tag: RenderTag.ABSTRACT,\n return: brick,\n };\n lastOutput.node = abstractNode;\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 isRouteParamsEqual(prevMatch.params, newMatch.params))\n );\n })\n ) {\n return false;\n }\n\n clearResolveCache();\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 const newOutput = getEmptyRenderOutput();\n const newControlNode: RenderAbstract = {\n tag: RenderTag.ABSTRACT,\n return: brick,\n };\n newOutput.node = newControlNode;\n\n try {\n incrementalOutput = await renderRoutes(\n newControlNode,\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 } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Incremental sub-router failed:\", error);\n\n const result = await rendererContext.reCatch(\n error,\n newControlNode\n );\n if (!result) {\n return true;\n }\n ({ failed, output: incrementalOutput } = result);\n }\n\n // istanbul ignore next: covered by e2e tests\n if (brick.disposed) {\n return true;\n }\n\n newControlNode.child = incrementalOutput.node;\n mergeRenderOutput(newOutput, {\n ...incrementalOutput,\n node: undefined,\n });\n // Assert: no errors will be throw\n await rendererContext.reMergeMenuRequestNodes(\n menuRequestReturnNode,\n slotConf.routes,\n incrementalOutput.menuRequestNode\n );\n\n rendererContext.reRender(brick, newControlNode, lastOutput.node!);\n\n lastOutput = newOutput;\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 // Even if all sub-routes missed, treat the incremental rendering as performed.\n return true;\n }\n );\n }\n\n const routesOutput = await renderRoutes(\n abstractNode,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n parentRoutes,\n menuRequestReturnNode,\n childSlotId,\n undefined,\n initialTracker\n );\n\n abstractNode.child = routesOutput.node;\n mergeRenderOutput(output, { ...routesOutput, node: undefined });\n appendMenuRequestNode(\n menuRequestReturnNode,\n (output.menuRequestNode = routesOutput.menuRequestNode)\n );\n\n return lastOutput;\n })\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n menuRequestNode: undefined,\n };\n rendered.forEach((item) => {\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 initialTracker?: InitialTracker\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) =>\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 tplStack && new Map(tplStack),\n initialTracker\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n rendered.flat().forEach((item) => {\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 const { blockingList, node, menuRequestNode, ...rest } = 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 | RouteConf)[] | 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 { slot: sl, ...child } of children) {\n const slot = sl ?? \"\";\n const type = isRouteConf(child) ? \"routes\" : \"bricks\";\n if (hasOwnProperty(newSlots, slot)) {\n const slotConf = newSlots[slot];\n if (slotConf.type !== type) {\n throw new Error(`Slot \"${slot}\" conflict between bricks and routes.`);\n }\n (slotConf as SlotConfOfBricks)[type as \"bricks\"].push(\n child as BrickConf\n );\n } else {\n newSlots[slot] = {\n type: type as \"bricks\",\n [type as \"bricks\"]: [child as BrickConf],\n };\n }\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\nfunction isRouteParamsEqual(\n a: Record<string, string>,\n b: Record<string, string>\n) {\n if (isEqual(a, b)) {\n return true;\n }\n const omitNumericKeys = (v: unknown, k: string) => {\n return String(Number(k)) === k;\n };\n const c = omitBy(a, omitNumericKeys);\n const d = omitBy(b, omitNumericKeys);\n return isEqual(c, d);\n}\n\nfunction isRouteConf(child: BrickConf | RouteConf): child is RouteConf {\n return !!(child as RouteConf).path && !(child as BrickConf).brick;\n}\n"],"mappings":"AAWA,SACEA,uBAAuB,EACvBC,qBAAqB,EACrBC,sBAAsB,EACtBC,0BAA0B,EAC1BC,UAAU,EACVC,SAAS,QACJ,mBAAmB;AAC1B,SAASC,UAAU,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