@next-core/runtime 1.67.0 → 1.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/cjs/CustomTemplates.js +11 -4
  2. package/dist/cjs/CustomTemplates.js.map +1 -1
  3. package/dist/cjs/StoryboardFunctionRegistry.js.map +1 -1
  4. package/dist/cjs/createRoot.js +4 -1
  5. package/dist/cjs/createRoot.js.map +1 -1
  6. package/dist/cjs/index.js +7 -11
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js +2 -1
  9. package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
  10. package/dist/cjs/internal/CustomTemplates/utils.js +12 -3
  11. package/dist/cjs/internal/CustomTemplates/utils.js.map +1 -1
  12. package/dist/cjs/internal/IsolatedTemplates.js +23 -0
  13. package/dist/cjs/internal/IsolatedTemplates.js.map +1 -0
  14. package/dist/cjs/internal/Renderer.js +2 -2
  15. package/dist/cjs/internal/Renderer.js.map +1 -1
  16. package/dist/cjs/internal/compute/IsolatedFunctions.js.map +1 -1
  17. package/dist/esm/CustomTemplates.js +11 -5
  18. package/dist/esm/CustomTemplates.js.map +1 -1
  19. package/dist/esm/StoryboardFunctionRegistry.js.map +1 -1
  20. package/dist/esm/createRoot.js +4 -1
  21. package/dist/esm/createRoot.js.map +1 -1
  22. package/dist/esm/index.js +1 -1
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js +2 -1
  25. package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
  26. package/dist/esm/internal/CustomTemplates/utils.js +12 -3
  27. package/dist/esm/internal/CustomTemplates/utils.js.map +1 -1
  28. package/dist/esm/internal/IsolatedTemplates.js +16 -0
  29. package/dist/esm/internal/IsolatedTemplates.js.map +1 -0
  30. package/dist/esm/internal/Renderer.js +2 -2
  31. package/dist/esm/internal/Renderer.js.map +1 -1
  32. package/dist/esm/internal/compute/IsolatedFunctions.js.map +1 -1
  33. package/dist/types/CustomTemplates.d.ts +3 -2
  34. package/dist/types/index.d.ts +1 -1
  35. package/dist/types/internal/CustomTemplates/utils.d.ts +1 -1
  36. package/dist/types/internal/IsolatedTemplates.d.ts +4 -0
  37. package/dist/types/internal/compute/IsolatedFunctions.d.ts +2 -2
  38. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Renderer.js","names":["_loader","require","_cook","_general","_storyboard","_lodash","_checkIf","_computeRealProperties","_resolveData","_computeRealValue","_listenOnTrackingContext","_matchRoutes","_constants","_expandCustomTemplate","_utils","_CustomTemplates","_Runtime","_enums","_getTracks","_isStrictMode","_constants2","_expandFormRenderer","_registerFormRenderer","_evaluate","_matchStoryboard","_bindListeners","_setupRootRuntimeContext","_routeMatchedMap","_ErrorNode","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","parentRoutes","menuRequestReturnNode","slotId","isIncremental","initialTracker","matched","matchRoutes","output","getEmptyRenderOutput","menuRequestNode","return","unauthenticated","_hooks$checkPermissio","route","path","match","runtimeContext","iid","setMatchedRoute","ctxStore","disposeDataInRoutes","routePath","concat","define","context","undefined","pendingPermissionsPreCheck","push","hooks","checkPermissions","preCheckPermissionsForBrickOrRoute","value","asyncComputeRealValue","preLoadBricks","Array","isArray","blockingList","loadBricksImperatively","getBrickPackages","type","redirectTo","redirect","resolved","resolveData","transform","console","error","Error","menuRequest","loadMenu","menu","request","memoizeMenuRequestNode","usedProcessors","strictCollectMemberUsage","size","catchLoad","loadProcessorsImperatively","join","unknownBricks","newOutput","renderBricks","bricks","mergeRenderOutput","appendMenuRequestNode","tplStack","setupRootRuntimeContext","rendered","Promise","all","map","brickConf","renderBrick","Map","forEach","item","legacyRenderBrick","errorBoundary","node","ErrorNode","_hooks$checkPermissio2","_runtimeContext$app","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","symbolForTplStateStoreId","formStateStoreId","symbolForFormStateStoreId","hasOwnProperty","symbolForTPlExternalForEachItem","forEachItem","forEachIndex","symbolForTPlExternalForEachIndex","forEachSize","symbolForTPlExternalForEachSize","strict","isStrictMode","length","warnAboutStrictMode","asyncCheckBrickIf","brickName","startsWith","ensureValidControlBrick","contextNames","stateNames","getTracks","tracking","lowerLevelRenderControlNode","tracker","trackDataSource","_slots$slot","computedDataSource","trackAfterInitial","propValue","slot","String","childrenToSlots","children","abstractNode","tag","RenderTag","ABSTRACT","childrenOutput","renderForEach","child","renderControlNode","tplStateStoreScope","formStateStoreScope","changedAfterInitial","disposes","listener","rerenderCount","rawOutput","uninitialized","scopedStores","postAsyncRender","dispose","controlledOutput","onMount","onUnmount","lifeCycle","renderId","mounted","disposed","currentRenderId","scopedRuntimeContext","createScopedRuntimeContext","reControlledOutput","listenerFactory","CustomEvent","detail","rerender","reRender","store","mountAsyncData","debouncedListener","debounce","leading","trailing","runtimeBrick","ROOT","contextName","onChange","tplStateStore","getTplStateStore","registerArbitraryLifeCycle","test","customTemplates","get","tplTagName","getTagNameOfCustomTemplate","app","id","tplCount","set","includes","customElements","FORM_RENDERER","registerFormRenderer","enqueueStableLoadBricks","formData","confProps","_brickConf$properties","properties","compute","inUseBrick","trackingContextList","asyncPropertyEntries","asyncComputeRealPropertyEntries","computedPropsFromHost","symbolForAsyncComputedPropsFromHost","isScript","props","constructAsyncProperties","src","rel","href","prefix","window","PUBLIC_ROOT","attrs","loadScript","loadStyle","BRICK","events","portal","ref","loadProperties","listenOnTrackingContext","registerBrickLifeCycle","expandedBrickConf","expandCustomTemplate","expandFormRenderer","childRuntimeContext","loadChildren","routeSlotFromIndexToSlotId","entries","childSlotId","slotConf","index","lastOutput","parentRoute","incrementalSubRoutes","performIncrementalRender","location","prevLocation","homepage","pathname","matchHomepage","every","prevMatch","newMatch","matchRoute","isRouteParamsEqual","params","query","URLSearchParams","search","failed","incrementalOutput","newControlNode","reBailout","result","reCatch","reMergeMenuRequestNodes","routesOutput","mergeSiblingRenderMenuRequest","isTrackAll","isPreEvaluated","getPreEvaluatedRaw","i","flat","getDataStores","tplStateStoreMap","values","formStateStoreMap","stores","flushStableLoadBricks","waitForAll","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","sl","promise","name","unknownPolicy","catch","e","a","b","isEqual","omitNumericKeys","v","k","Number","c","omitBy","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 { 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(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n 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 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":";;;;;;;;;;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QACV,CAAC;MACH;MACCwN,QAAQ,CAACxJ,IAAI,CAAC,CAAsBhE,MAAM,CAACnC,IAAI,CAAC6G,KAAK,CAAC;IACzD;EACF;EACA,OAAO8I,QAAQ;AACjB;AAEA,SAAS9N,SAASA,CAChBmO,OAAyB,EACzBpP,IAAsD,EACtDqP,IAAY,EACZC,aAA+C,EAC/C;EACA,OAAOA,aAAa,KAAK,QAAQ,GAC7BF,OAAO,CAACG,KAAK,CAAEC,CAAC,IAAK;IACnB;IACAlP,OAAO,CAACC,KAAK,CAAC,sBAAsB,EAAEP,IAAI,EAAEqP,IAAI,EAAEG,CAAC,CAAC;EACtD,CAAC,CAAC,GACFJ,OAAO;AACb;AAEA,SAAStC,kBAAkBA,CACzB2C,CAAyB,EACzBC,CAAyB,EACzB;EACA,IAAI,IAAAC,eAAO,EAACF,CAAC,EAAEC,CAAC,CAAC,EAAE;IACjB,OAAO,IAAI;EACb;EACA,MAAME,eAAe,GAAGA,CAACC,CAAU,EAAEC,CAAS,KAAK;IACjD,OAAOtK,MAAM,CAACuK,MAAM,CAACD,CAAC,CAAC,CAAC,KAAKA,CAAC;EAChC,CAAC;EACD,MAAME,CAAC,GAAG,IAAAC,cAAM,EAACR,CAAC,EAAEG,eAAe,CAAC;EACpC,MAAMM,CAAC,GAAG,IAAAD,cAAM,EAACP,CAAC,EAAEE,eAAe,CAAC;EACpC,OAAO,IAAAD,eAAO,EAACK,CAAC,EAAEE,CAAC,CAAC;AACtB","ignoreList":[]}
1
+ {"version":3,"file":"Renderer.js","names":["_loader","require","_cook","_general","_storyboard","_lodash","_checkIf","_computeRealProperties","_resolveData","_computeRealValue","_listenOnTrackingContext","_matchRoutes","_constants","_expandCustomTemplate","_utils","_CustomTemplates","_Runtime","_enums","_getTracks","_isStrictMode","_constants2","_expandFormRenderer","_registerFormRenderer","_evaluate","_matchStoryboard","_bindListeners","_setupRootRuntimeContext","_routeMatchedMap","_ErrorNode","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","parentRoutes","menuRequestReturnNode","slotId","isIncremental","initialTracker","matched","matchRoutes","output","getEmptyRenderOutput","menuRequestNode","return","unauthenticated","_hooks$checkPermissio","route","path","match","runtimeContext","iid","setMatchedRoute","ctxStore","disposeDataInRoutes","routePath","concat","define","context","undefined","pendingPermissionsPreCheck","push","hooks","checkPermissions","preCheckPermissionsForBrickOrRoute","value","asyncComputeRealValue","preLoadBricks","Array","isArray","blockingList","loadBricksImperatively","getBrickPackages","type","redirectTo","redirect","resolved","resolveData","transform","console","error","Error","menuRequest","loadMenu","menu","request","memoizeMenuRequestNode","usedProcessors","strictCollectMemberUsage","size","catchLoad","loadProcessorsImperatively","join","unknownBricks","newOutput","renderBricks","bricks","mergeRenderOutput","appendMenuRequestNode","tplStack","setupRootRuntimeContext","rendered","Promise","all","map","brickConf","renderBrick","Map","forEach","item","legacyRenderBrick","errorBoundary","node","ErrorNode","_hooks$checkPermissio2","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","symbolForTplStateStoreId","formStateStoreId","symbolForFormStateStoreId","hasOwnProperty","symbolForTPlExternalForEachItem","forEachItem","forEachIndex","symbolForTPlExternalForEachIndex","forEachSize","symbolForTPlExternalForEachSize","strict","isStrictMode","length","warnAboutStrictMode","asyncCheckBrickIf","brickName","startsWith","ensureValidControlBrick","contextNames","stateNames","getTracks","tracking","lowerLevelRenderControlNode","tracker","trackDataSource","_slots$slot","computedDataSource","trackAfterInitial","propValue","slot","String","childrenToSlots","children","abstractNode","tag","RenderTag","ABSTRACT","childrenOutput","renderForEach","child","renderControlNode","tplStateStoreScope","formStateStoreScope","changedAfterInitial","disposes","listener","rerenderCount","rawOutput","uninitialized","scopedStores","postAsyncRender","dispose","controlledOutput","onMount","onUnmount","lifeCycle","renderId","mounted","disposed","currentRenderId","scopedRuntimeContext","createScopedRuntimeContext","reControlledOutput","listenerFactory","CustomEvent","detail","rerender","reRender","store","mountAsyncData","debouncedListener","debounce","leading","trailing","runtimeBrick","ROOT","contextName","onChange","tplStateStore","getTplStateStore","registerArbitraryLifeCycle","test","customTemplates","get","tplTagName","getTagNameOfCustomTemplate","tplCount","set","includes","customElements","FORM_RENDERER","registerFormRenderer","enqueueStableLoadBricks","formData","confProps","_brickConf$properties","properties","compute","inUseBrick","trackingContextList","asyncPropertyEntries","asyncComputeRealPropertyEntries","computedPropsFromHost","symbolForAsyncComputedPropsFromHost","isScript","props","constructAsyncProperties","src","rel","href","prefix","window","PUBLIC_ROOT","attrs","loadScript","loadStyle","BRICK","events","portal","ref","loadProperties","listenOnTrackingContext","registerBrickLifeCycle","expandedBrickConf","expandCustomTemplate","expandFormRenderer","childRuntimeContext","loadChildren","routeSlotFromIndexToSlotId","entries","childSlotId","slotConf","index","lastOutput","parentRoute","incrementalSubRoutes","performIncrementalRender","location","prevLocation","homepage","app","pathname","matchHomepage","every","prevMatch","newMatch","matchRoute","isRouteParamsEqual","params","query","URLSearchParams","search","failed","incrementalOutput","newControlNode","reBailout","result","reCatch","reMergeMenuRequestNodes","routesOutput","mergeSiblingRenderMenuRequest","isTrackAll","isPreEvaluated","getPreEvaluatedRaw","i","flat","getDataStores","tplStateStoreMap","values","formStateStoreMap","stores","flushStableLoadBricks","waitForAll","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","sl","promise","name","unknownPolicy","catch","e","a","b","isEqual","omitNumericKeys","v","k","Number","c","omitBy","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 { 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 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,IAAAA,OAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AAIA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AACA,IAAAS,wBAAA,GAAAT,OAAA;AAOA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AAOA,IAAAY,qBAAA,GAAAZ,OAAA;AAUA,IAAAa,MAAA,GAAAb,OAAA;AAIA,IAAAc,gBAAA,GAAAd,OAAA;AAEA,IAAAe,QAAA,GAAAf,OAAA;AACA,IAAAgB,MAAA,GAAAhB,OAAA;AACA,IAAAiB,UAAA,GAAAjB,OAAA;AACA,IAAAkB,aAAA,GAA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AME,CAAC,GAAG,IAAAC,cAAM,EAACR,CAAC,EAAEG,eAAe,CAAC;EACpC,MAAMM,CAAC,GAAG,IAAAD,cAAM,EAACP,CAAC,EAAEE,eAAe,CAAC;EACpC,OAAO,IAAAD,eAAO,EAACK,CAAC,EAAEE,CAAC,CAAC;AACtB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"IsolatedFunctions.js","names":["_StoryboardFunctionRegistry","require","isolatedFunctionRegistry","exports","Map","registerIsolatedFunctions","isolatedRoot","functions","storyboardFunctions","registerStoryboardFunctions","StoryboardFunctionRegistryFactory","set"],"sources":["../../../../src/internal/compute/IsolatedFunctions.ts"],"sourcesContent":["import { StoryboardFunction } from \"@next-core/types\";\nimport {\n ReadonlyStoryboardFunctions,\n StoryboardFunctionRegistryFactory,\n} from \"../../StoryboardFunctionRegistry.js\";\n\nexport const isolatedFunctionRegistry = new Map<\n symbol,\n ReadonlyStoryboardFunctions\n>();\n\nexport function registerIsolatedFunctions(\n isolatedRoot: symbol,\n functions: StoryboardFunction[]\n): void {\n const { storyboardFunctions, registerStoryboardFunctions } =\n StoryboardFunctionRegistryFactory({ isolatedRoot });\n isolatedFunctionRegistry.set(isolatedRoot, storyboardFunctions);\n registerStoryboardFunctions(functions);\n}\n"],"mappings":";;;;;;;AACA,IAAAA,2BAAA,GAAAC,OAAA;AAKO,MAAMC,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,IAAIE,GAAG,CAG7C,CAAC;AAEI,SAASC,yBAAyBA,CACvCC,YAAoB,EACpBC,SAA+B,EACzB;EACN,MAAM;IAAEC,mBAAmB;IAAEC;EAA4B,CAAC,GACxD,IAAAC,6DAAiC,EAAC;IAAEJ;EAAa,CAAC,CAAC;EACrDJ,wBAAwB,CAACS,GAAG,CAACL,YAAY,EAAEE,mBAAmB,CAAC;EAC/DC,2BAA2B,CAACF,SAAS,CAAC;AACxC","ignoreList":[]}
1
+ {"version":3,"file":"IsolatedFunctions.js","names":["_StoryboardFunctionRegistry","require","isolatedFunctionRegistry","exports","Map","registerIsolatedFunctions","isolatedRoot","functions","storyboardFunctions","registerStoryboardFunctions","StoryboardFunctionRegistryFactory","set"],"sources":["../../../../src/internal/compute/IsolatedFunctions.ts"],"sourcesContent":["import type { StoryboardFunction } from \"@next-core/types\";\nimport {\n type ReadonlyStoryboardFunctions,\n StoryboardFunctionRegistryFactory,\n} from \"../../StoryboardFunctionRegistry.js\";\n\nexport const isolatedFunctionRegistry = new Map<\n symbol,\n ReadonlyStoryboardFunctions\n>();\n\nexport function registerIsolatedFunctions(\n isolatedRoot: symbol,\n functions: StoryboardFunction[] | undefined\n): void {\n const { storyboardFunctions, registerStoryboardFunctions } =\n StoryboardFunctionRegistryFactory({ isolatedRoot });\n isolatedFunctionRegistry.set(isolatedRoot, storyboardFunctions);\n registerStoryboardFunctions(functions);\n}\n"],"mappings":";;;;;;;AACA,IAAAA,2BAAA,GAAAC,OAAA;AAKO,MAAMC,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,IAAIE,GAAG,CAG7C,CAAC;AAEI,SAASC,yBAAyBA,CACvCC,YAAoB,EACpBC,SAA2C,EACrC;EACN,MAAM;IAAEC,mBAAmB;IAAEC;EAA4B,CAAC,GACxD,IAAAC,6DAAiC,EAAC;IAAEJ;EAAa,CAAC,CAAC;EACrDJ,wBAAwB,CAACS,GAAG,CAACL,YAAY,EAAEE,mBAAmB,CAAC;EAC/DC,2BAA2B,CAACF,SAAS,CAAC;AACxC","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import _classPrivateFieldInitSpec from "@babel/runtime/helpers/classPrivateFieldInitSpec";
2
2
  import _classPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet2";
3
+ import _classPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet2";
3
4
  import { uniq } from "lodash";
4
5
  import { isStrictMode, warnAboutStrictMode } from "./isStrictMode.js";
5
6
  import { getV2RuntimeFromDll } from "./getV2RuntimeFromDll.js";
@@ -7,9 +8,12 @@ import { getV2RuntimeFromDll } from "./getV2RuntimeFromDll.js";
7
8
  // Note: `prefix` is a native prop on Element, but it's only used in XML documents.
8
9
  const allowedNativeProps = new Set(["prefix"]);
9
10
  var _registry = /*#__PURE__*/new WeakMap();
10
- class CustomTemplateRegistry {
11
- constructor() {
11
+ var _isolated = /*#__PURE__*/new WeakMap();
12
+ export class CustomTemplateRegistry {
13
+ constructor(isolated) {
12
14
  _classPrivateFieldInitSpec(this, _registry, new Map());
15
+ _classPrivateFieldInitSpec(this, _isolated, void 0);
16
+ _classPrivateFieldSet(_isolated, this, isolated);
13
17
  }
14
18
  define(tagName, constructor) {
15
19
  var _constructor$proxy$pr, _constructor$proxy, _compatibleConstructo, _compatibleConstructo2;
@@ -128,7 +132,6 @@ class CustomTemplateRegistry {
128
132
  }
129
133
  Object.defineProperty(TplElement.prototype, propName, {
130
134
  get() {
131
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
132
135
  return this.$$tplStateStore.getValue(propName);
133
136
  },
134
137
  set(value) {
@@ -144,7 +147,6 @@ class CustomTemplateRegistry {
144
147
  Object.defineProperty(TplElement.prototype, from, {
145
148
  get() {
146
149
  var _to$refProperty;
147
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
148
150
  const element = this.$$getElementByRef(to.ref);
149
151
  return element[(_to$refProperty = to.refProperty) !== null && _to$refProperty !== void 0 ? _to$refProperty : from];
150
152
  },
@@ -164,7 +166,6 @@ class CustomTemplateRegistry {
164
166
  Object.defineProperty(TplElement.prototype, from, {
165
167
  value() {
166
168
  var _to$refMethod;
167
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
168
169
  const element = this.$$getElementByRef(to.ref);
169
170
  return element[(_to$refMethod = to.refMethod) !== null && _to$refMethod !== void 0 ? _to$refMethod : from](...arguments);
170
171
  },
@@ -176,6 +177,11 @@ class CustomTemplateRegistry {
176
177
  get(tagName) {
177
178
  return _classPrivateFieldGet(_registry, this).get(tagName);
178
179
  }
180
+ clearIsolatedRegistry() {
181
+ if (_classPrivateFieldGet(_isolated, this)) {
182
+ _classPrivateFieldGet(_registry, this).clear();
183
+ }
184
+ }
179
185
  }
180
186
  function getExposedStates(state) {
181
187
  var _state$filter$map;
@@ -1 +1 @@
1
- {"version":3,"file":"CustomTemplates.js","names":["uniq","isStrictMode","warnAboutStrictMode","getV2RuntimeFromDll","allowedNativeProps","Set","_registry","WeakMap","CustomTemplateRegistry","constructor","_classPrivateFieldInitSpec","Map","define","tagName","_constructor$proxy$pr","_constructor$proxy","_compatibleConstructo","_compatibleConstructo2","registered","_classPrivateFieldGet","has","console","warn","customElements","get","strict","proxyProperties","proxy","properties","validProxyProps","legacyTplVariables","key","value","Object","entries","asVariable","push","mergeProperty","refTransform","error","ref","compatibleConstructor","fromEntries","state","map","item","expose","concat","tpl","name","set","exposedStates","getExposedStates","proxyMethods","methods","props","entry","nativeProps","filter","prop","HTMLElement","prototype","length","Error","p","join","TplElement","$$typeof","_dev_only_definedProperties","_dev_only_definedMethods","$$getElementByRef","_this$$$tplStateStore","$$tplStateStore","hostBrick","tplHostMetadata","internalBricksByRef","element","connectedCallback","shadowRoot","attachShadow","mode","fragment","document","createDocumentFragment","style","createElement","textContent","slot","appendChild","disconnectedCallback","propName","some","defineProperty","getValue","_this$$$tplStateStore2","updateValue","enumerable","from","to","_to$refProperty","refProperty","_this$$$getElementByR","call","_to$refProperty2","_to$refMethod","refMethod","arguments","_state$filter$map","getCustomTemplatesV2","v2Kit","freeze","getRuntime","registerCustomTemplate","customTemplates"],"sources":["../../src/CustomTemplates.ts"],"sourcesContent":["import type {\n ContextConf,\n CustomTemplate,\n CustomTemplateConstructor,\n CustomTemplateProxyBasicProperty,\n} from \"@next-core/types\";\nimport { uniq } from \"lodash\";\nimport type { RuntimeBrickElement } from \"./internal/interfaces.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"./isStrictMode.js\";\nimport { getV2RuntimeFromDll } from \"./getV2RuntimeFromDll.js\";\n\n// Note: `prefix` is a native prop on Element, but it's only used in XML documents.\nconst allowedNativeProps = new Set([\"prefix\"]);\n\ninterface LegacyTplPropProxy extends CustomTemplateProxyBasicProperty {\n asVariable?: boolean;\n mergeProperty?: unknown;\n refTransform?: unknown;\n}\n\nclass CustomTemplateRegistry {\n readonly #registry = new Map<string, CustomTemplate>();\n\n define(tagName: string, constructor: CustomTemplateConstructor): void {\n let registered = this.#registry.has(tagName);\n if (registered) {\n // When open launchpad, the storyboard will be updated.\n // However, we can't *undefine* a custom element.\n // Just ignore re-registering custom templates.\n // eslint-disable-next-line no-console\n console.warn(`Custom template of \"${tagName}\" already registered.`);\n } else {\n registered = !!customElements.get(tagName);\n if (registered) {\n // eslint-disable-next-line no-console\n console.warn(\n `Custom template of \"${tagName}\" already defined by customElements.`\n );\n }\n }\n\n // Transform legacy `proxy.properties[].asVariable` as states.\n const strict = isStrictMode();\n const proxyProperties = (constructor.proxy?.properties ?? {}) as {\n [name: string]: LegacyTplPropProxy;\n };\n const validProxyProps: [string, CustomTemplateProxyBasicProperty][] = [];\n const legacyTplVariables: string[] = [];\n for (const [key, value] of Object.entries(proxyProperties)) {\n if (value.asVariable) {\n warnAboutStrictMode(strict, \"Template `asVariable`\", tagName, key);\n // istanbul ignore next\n if (!strict) {\n // For existed TPL usage, treat it as a STATE.\n legacyTplVariables.push(key);\n }\n } else if (value.mergeProperty || value.refTransform) {\n // eslint-disable-next-line no-console\n console.error(\n \"Template `mergeProperty` and `refTransform` are dropped in v3:\",\n tagName,\n key\n );\n } else if (value.ref) {\n validProxyProps.push([key, value]);\n }\n // Else: documentation only, for exposed states.\n }\n\n const compatibleConstructor = {\n ...constructor,\n proxy: {\n ...constructor.proxy,\n properties: Object.fromEntries(validProxyProps),\n },\n state: (constructor.state\n ? strict\n ? constructor.state\n : constructor.state.map((item) => ({\n // Make `expose` defaults to true in non-strict mode.\n expose: true,\n ...item,\n }))\n : []\n ).concat(legacyTplVariables.map((tpl) => ({ name: tpl, expose: true }))),\n };\n\n // Now we allow re-register custom template\n this.#registry.set(tagName, {\n ...compatibleConstructor,\n name: tagName,\n });\n\n const exposedStates = getExposedStates(compatibleConstructor.state);\n const proxyMethods = Object.entries(\n compatibleConstructor.proxy?.methods ?? {}\n );\n\n const props = exposedStates.concat(\n validProxyProps.map((entry) => entry[0])\n );\n const methods = proxyMethods.map((entry) => entry[0]);\n\n const nativeProps = props\n .concat(methods)\n .filter(\n (prop) => prop in HTMLElement.prototype && !allowedNativeProps.has(prop)\n );\n if (nativeProps.length > 0) {\n warnAboutStrictMode(\n strict,\n \"Using native HTMLElement properties as template properties or methods\",\n tagName,\n ...nativeProps\n );\n // istanbul ignore next\n if (strict) {\n throw new Error(\n `In custom template \"${tagName}\", ${nativeProps\n .map((p) => `\"${p}\"`)\n .join(\n \", \"\n )} are native HTMLElement properties, and should be avoid to be used as brick properties or methods.`\n );\n }\n }\n\n if (registered) {\n return;\n }\n\n class TplElement extends HTMLElement {\n get $$typeof() {\n return \"custom-template\" as const;\n }\n\n static get _dev_only_definedProperties(): string[] {\n return props;\n }\n\n static get _dev_only_definedMethods(): string[] {\n return methods;\n }\n\n $$getElementByRef(this: RuntimeBrickElement, ref: string) {\n return this.$$tplStateStore?.hostBrick?.tplHostMetadata?.internalBricksByRef.get(\n ref\n )?.element;\n }\n\n connectedCallback() {\n let shadowRoot = this.shadowRoot;\n if (!shadowRoot) {\n shadowRoot = this.attachShadow({ mode: \"open\" });\n }\n const fragment = document.createDocumentFragment();\n const style = document.createElement(\"style\");\n style.textContent = \":host{display:block}:host([hidden]){display:none}\";\n const slot = document.createElement(\"slot\");\n fragment.appendChild(style);\n fragment.appendChild(slot);\n shadowRoot.appendChild(fragment);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) {\n this.shadowRoot.textContent = \"\";\n }\n }\n }\n\n for (const propName of exposedStates) {\n if (validProxyProps.some((entry) => entry[0] === propName)) {\n // eslint-disable-next-line no-console\n console.error(\n `Cannot define an exposed state that is also a proxy property: \"${propName}\" in ${tagName}`\n );\n continue;\n }\n Object.defineProperty(TplElement.prototype, propName, {\n get(this: RuntimeBrickElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.$$tplStateStore!.getValue(propName);\n },\n set(this: RuntimeBrickElement, value: unknown) {\n // 在 mount 过程中,先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n this.$$tplStateStore?.updateValue(propName, value, \"replace\");\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of validProxyProps) {\n Object.defineProperty(TplElement.prototype, from, {\n get(this: TplElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n unknown\n >;\n return element[to.refProperty ?? from];\n },\n set(this: TplElement, value: unknown) {\n // 同上 exposedState.set\n const element = this.$$getElementByRef?.(to.ref) as unknown as Record<\n string,\n unknown\n >;\n if (element) {\n element[to.refProperty ?? from] = value;\n }\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of proxyMethods) {\n Object.defineProperty(TplElement.prototype, from, {\n value(this: TplElement, ...args: unknown[]) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n Function\n >;\n return element[to.refMethod ?? from](...args);\n },\n enumerable: true,\n });\n }\n\n customElements.define(tagName, TplElement);\n }\n\n get(tagName: string) {\n return this.#registry.get(tagName);\n }\n}\n\nfunction getExposedStates(state: ContextConf[] | undefined): string[] {\n // Allow duplicated state names which maybe mutually exclusive.\n return uniq(\n state?.filter((item) => item.expose).map((item) => item.name) ?? []\n );\n}\n\n// istanbul ignore next\nfunction getCustomTemplatesV2() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return Object.freeze({\n define(tagName: string, constructor: CustomTemplateConstructor) {\n return v2Kit.getRuntime().registerCustomTemplate(tagName, constructor);\n },\n }) as CustomTemplateRegistry;\n }\n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,CAAC;EACnC,IAAI0G,KAAK,EAAE;IACT,OAAO5E,MAAM,CAAC6E,MAAM,CAAC;MACnBlG,MAAMA,CAACC,OAAe,EAAEJ,WAAsC,EAAE;QAC9D,OAAOoG,KAAK,CAACE,UAAU,CAAC,CAAC,CAACC,sBAAsB,CAACnG,OAAO,EAAEJ,WAAW,CAAC;MACxE;IACF,CAAC,CAAC;EACJ;AACF;;AAEA;AACA,OAAO,MAAMwG,eAAe,GAC1BL,oBAAoB,CAAC,CAAC,IAAI,IAAIpG,sBAAsB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"CustomTemplates.js","names":["uniq","isStrictMode","warnAboutStrictMode","getV2RuntimeFromDll","allowedNativeProps","Set","_registry","WeakMap","_isolated","CustomTemplateRegistry","constructor","isolated","_classPrivateFieldInitSpec","Map","_classPrivateFieldSet","define","tagName","_constructor$proxy$pr","_constructor$proxy","_compatibleConstructo","_compatibleConstructo2","registered","_classPrivateFieldGet","has","console","warn","customElements","get","strict","proxyProperties","proxy","properties","validProxyProps","legacyTplVariables","key","value","Object","entries","asVariable","push","mergeProperty","refTransform","error","ref","compatibleConstructor","fromEntries","state","map","item","expose","concat","tpl","name","set","exposedStates","getExposedStates","proxyMethods","methods","props","entry","nativeProps","filter","prop","HTMLElement","prototype","length","Error","p","join","TplElement","$$typeof","_dev_only_definedProperties","_dev_only_definedMethods","$$getElementByRef","_this$$$tplStateStore","$$tplStateStore","hostBrick","tplHostMetadata","internalBricksByRef","element","connectedCallback","shadowRoot","attachShadow","mode","fragment","document","createDocumentFragment","style","createElement","textContent","slot","appendChild","disconnectedCallback","propName","some","defineProperty","getValue","_this$$$tplStateStore2","updateValue","enumerable","from","to","_to$refProperty","refProperty","_this$$$getElementByR","call","_to$refProperty2","_to$refMethod","refMethod","arguments","clearIsolatedRegistry","clear","_state$filter$map","getCustomTemplatesV2","v2Kit","freeze","getRuntime","registerCustomTemplate","customTemplates"],"sources":["../../src/CustomTemplates.ts"],"sourcesContent":["import type {\n ContextConf,\n CustomTemplate,\n CustomTemplateConstructor,\n CustomTemplateProxyBasicProperty,\n} from \"@next-core/types\";\nimport { uniq } from \"lodash\";\nimport type { RuntimeBrickElement } from \"./internal/interfaces.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"./isStrictMode.js\";\nimport { getV2RuntimeFromDll } from \"./getV2RuntimeFromDll.js\";\n\n// Note: `prefix` is a native prop on Element, but it's only used in XML documents.\nconst allowedNativeProps = new Set([\"prefix\"]);\n\ninterface LegacyTplPropProxy extends CustomTemplateProxyBasicProperty {\n asVariable?: boolean;\n mergeProperty?: unknown;\n refTransform?: unknown;\n}\n\nexport class CustomTemplateRegistry {\n readonly #registry = new Map<string, CustomTemplate>();\n readonly #isolated: boolean | undefined;\n\n constructor(isolated?: boolean) {\n this.#isolated = isolated;\n }\n\n define(tagName: string, constructor: CustomTemplateConstructor): void {\n let registered = this.#registry.has(tagName);\n if (registered) {\n // When open launchpad, the storyboard will be updated.\n // However, we can't *undefine* a custom element.\n // Just ignore re-registering custom templates.\n // eslint-disable-next-line no-console\n console.warn(`Custom template of \"${tagName}\" already registered.`);\n } else {\n registered = !!customElements.get(tagName);\n if (registered) {\n // eslint-disable-next-line no-console\n console.warn(\n `Custom template of \"${tagName}\" already defined by customElements.`\n );\n }\n }\n\n // Transform legacy `proxy.properties[].asVariable` as states.\n const strict = isStrictMode();\n const proxyProperties = (constructor.proxy?.properties ?? {}) as {\n [name: string]: LegacyTplPropProxy;\n };\n const validProxyProps: [string, CustomTemplateProxyBasicProperty][] = [];\n const legacyTplVariables: string[] = [];\n for (const [key, value] of Object.entries(proxyProperties)) {\n if (value.asVariable) {\n warnAboutStrictMode(strict, \"Template `asVariable`\", tagName, key);\n // istanbul ignore next\n if (!strict) {\n // For existed TPL usage, treat it as a STATE.\n legacyTplVariables.push(key);\n }\n } else if (value.mergeProperty || value.refTransform) {\n // eslint-disable-next-line no-console\n console.error(\n \"Template `mergeProperty` and `refTransform` are dropped in v3:\",\n tagName,\n key\n );\n } else if (value.ref) {\n validProxyProps.push([key, value]);\n }\n // Else: documentation only, for exposed states.\n }\n\n const compatibleConstructor = {\n ...constructor,\n proxy: {\n ...constructor.proxy,\n properties: Object.fromEntries(validProxyProps),\n },\n state: (constructor.state\n ? strict\n ? constructor.state\n : constructor.state.map((item) => ({\n // Make `expose` defaults to true in non-strict mode.\n expose: true,\n ...item,\n }))\n : []\n ).concat(legacyTplVariables.map((tpl) => ({ name: tpl, expose: true }))),\n };\n\n // Now we allow re-register custom template\n this.#registry.set(tagName, {\n ...compatibleConstructor,\n name: tagName,\n });\n\n const exposedStates = getExposedStates(compatibleConstructor.state);\n const proxyMethods = Object.entries(\n compatibleConstructor.proxy?.methods ?? {}\n );\n\n const props = exposedStates.concat(\n validProxyProps.map((entry) => entry[0])\n );\n const methods = proxyMethods.map((entry) => entry[0]);\n\n const nativeProps = props\n .concat(methods)\n .filter(\n (prop) => prop in HTMLElement.prototype && !allowedNativeProps.has(prop)\n );\n if (nativeProps.length > 0) {\n warnAboutStrictMode(\n strict,\n \"Using native HTMLElement properties as template properties or methods\",\n tagName,\n ...nativeProps\n );\n // istanbul ignore next\n if (strict) {\n throw new Error(\n `In custom template \"${tagName}\", ${nativeProps\n .map((p) => `\"${p}\"`)\n .join(\n \", \"\n )} are native HTMLElement properties, and should be avoid to be used as brick properties or methods.`\n );\n }\n }\n\n if (registered) {\n return;\n }\n\n class TplElement extends HTMLElement {\n get $$typeof() {\n return \"custom-template\" as const;\n }\n\n static get _dev_only_definedProperties(): string[] {\n return props;\n }\n\n static get _dev_only_definedMethods(): string[] {\n return methods;\n }\n\n $$getElementByRef(this: RuntimeBrickElement, ref: string) {\n return this.$$tplStateStore?.hostBrick?.tplHostMetadata?.internalBricksByRef.get(\n ref\n )?.element;\n }\n\n connectedCallback() {\n let shadowRoot = this.shadowRoot;\n if (!shadowRoot) {\n shadowRoot = this.attachShadow({ mode: \"open\" });\n }\n const fragment = document.createDocumentFragment();\n const style = document.createElement(\"style\");\n style.textContent = \":host{display:block}:host([hidden]){display:none}\";\n const slot = document.createElement(\"slot\");\n fragment.appendChild(style);\n fragment.appendChild(slot);\n shadowRoot.appendChild(fragment);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) {\n this.shadowRoot.textContent = \"\";\n }\n }\n }\n\n for (const propName of exposedStates) {\n if (validProxyProps.some((entry) => entry[0] === propName)) {\n // eslint-disable-next-line no-console\n console.error(\n `Cannot define an exposed state that is also a proxy property: \"${propName}\" in ${tagName}`\n );\n continue;\n }\n Object.defineProperty(TplElement.prototype, propName, {\n get(this: RuntimeBrickElement) {\n return this.$$tplStateStore!.getValue(propName);\n },\n set(this: RuntimeBrickElement, value: unknown) {\n // 在 mount 过程中,先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n this.$$tplStateStore?.updateValue(propName, value, \"replace\");\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of validProxyProps) {\n Object.defineProperty(TplElement.prototype, from, {\n get(this: TplElement) {\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n unknown\n >;\n return element[to.refProperty ?? from];\n },\n set(this: TplElement, value: unknown) {\n // 同上 exposedState.set\n const element = this.$$getElementByRef?.(to.ref) as unknown as Record<\n string,\n unknown\n >;\n if (element) {\n element[to.refProperty ?? from] = value;\n }\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of proxyMethods) {\n Object.defineProperty(TplElement.prototype, from, {\n value(this: TplElement, ...args: unknown[]) {\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n Function\n >;\n return element[to.refMethod ?? from](...args);\n },\n enumerable: true,\n });\n }\n\n customElements.define(tagName, TplElement);\n }\n\n get(tagName: string) {\n return this.#registry.get(tagName);\n }\n\n clearIsolatedRegistry() {\n if (this.#isolated) {\n this.#registry.clear();\n }\n }\n}\n\nfunction getExposedStates(state: ContextConf[] | undefined): string[] {\n // Allow duplicated state names which maybe mutually exclusive.\n return uniq(\n state?.filter((item) => item.expose).map((item) => item.name) ?? []\n );\n}\n\n// istanbul ignore next\nfunction getCustomTemplatesV2() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return Object.freeze({\n define(tagName: string, constructor: CustomTemplateConstructor) {\n return v2Kit.getRuntime().registerCustomTemplate(tagName, constructor);\n },\n }) as CustomTemplateRegistry;\n }\n}\n\n// istanbul ignore next\nexport const customTemplates =\n getCustomTemplatesV2() || new CustomTemplateRegistry();\n"],"mappings":";;;AAMA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,mBAAmB;AACrE,SAASC,mBAAmB,QAAQ,0BAA0B;;AAE9D;AACA,MAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AAAC,IAAAC,SAAA,oBAAAC,OAAA;AAAA,IAAAC,SAAA,oBAAAD,OAAA;AAQ/C,OAAO,MAAME,sBAAsB,CAAC;EAIlCC,WAAWA,CAACC,QAAkB,EAAE;IAHhCC,0BAAA,OAASN,SAAS,EAAG,IAAIO,GAAG,CAAyB,CAAC;IACtDD,0BAAA,OAASJ,SAAS;IAGhBM,qBAAA,CAAKN,SAAS,EAAd,IAAI,EAAaG,QAAJ,CAAC;EAChB;EAEAI,MAAMA,CAACC,OAAe,EAAEN,WAAsC,EAAQ;IAAA,IAAAO,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,sBAAA;IACpE,IAAIC,UAAU,GAAGC,qBAAA,CAAKhB,SAAS,EAAd,IAAa,CAAC,CAACiB,GAAG,CAACP,OAAO,CAAC;IAC5C,IAAIK,UAAU,EAAE;MACd;MACA;MACA;MACA;MACAG,OAAO,CAACC,IAAI,CAAC,uBAAuBT,OAAO,uBAAuB,CAAC;IACrE,CAAC,MAAM;MACLK,UAAU,GAAG,CAAC,CAACK,cAAc,CAACC,GAAG,CAACX,OAAO,CAAC;MAC1C,IAAIK,UAAU,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