@next-core/runtime 1.52.0 → 1.53.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.
@@ -187,12 +187,13 @@ class Runtime {
187
187
  document.body.classList.toggle("launchpad-open", open);
188
188
  }
189
189
  applyPageTitle(pageTitle) {
190
+ var _router5;
190
191
  const baseTitle = this.getBrandSettings().base_title;
191
- document.title = pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle;
192
+ document.title = pageTitle ? ((_router5 = router) === null || _router5 === void 0 || (_router5 = _router5.getRecentApps().currentApp) === null || _router5 === void 0 ? void 0 : _router5.localeTitle) || `${pageTitle} - ${baseTitle}` : baseTitle;
192
193
  }
193
194
  getNavConfig() {
194
- var _router5;
195
- return (_router5 = router) === null || _router5 === void 0 ? void 0 : _router5.getNavConfig();
195
+ var _router6;
196
+ return (_router6 = router) === null || _router6 === void 0 ? void 0 : _router6.getNavConfig();
196
197
  }
197
198
  loadBricks(bricks) {
198
199
  return (0, _loader.loadBricksImperatively)(bricks, getBrickPackages());
@@ -233,16 +234,16 @@ function getBrickPackages() {
233
234
  );
234
235
  }
235
236
  function _internalApiGetRenderId() {
236
- var _router6;
237
- return (_router6 = router) === null || _router6 === void 0 ? void 0 : _router6.getRenderId();
237
+ var _router7;
238
+ return (_router7 = router) === null || _router7 === void 0 ? void 0 : _router7.getRenderId();
238
239
  }
239
240
  function _internalApiMatchStoryboard(pathname) {
240
241
  var _bootstrapData8;
241
242
  return (0, _matchStoryboard.matchStoryboard)(((_bootstrapData8 = bootstrapData) === null || _bootstrapData8 === void 0 ? void 0 : _bootstrapData8.storyboards) ?? [], pathname);
242
243
  }
243
244
  function _internalApiGetRuntimeContext() {
244
- var _router7;
245
- return (_router7 = router) === null || _router7 === void 0 ? void 0 : _router7.getRuntimeContext();
245
+ var _router8;
246
+ return (_router8 = router) === null || _router8 === void 0 ? void 0 : _router8.getRuntimeContext();
246
247
  }
247
248
  function _internalApiGetStoryboardInBootstrapData(appId) {
248
249
  var _bootstrapData9;
@@ -1 +1 @@
1
- {"version":3,"file":"Runtime.js","names":["_i18n","require","_loader","_general","_moment","_interopRequireDefault","_history","_matchStoryboard","_Router","_i18n2","_Notification","_Dialog","_injected","_hasInstalledApp","_devtools","_getV2RuntimeFromDll","_customizeColorTheme","runtime","bootstrapData","router","processedBrickPackages","hooks","exports","createRuntime","options","Error","listenDevtoolsEagerly","initializeI18n","NS","locales","moment","locale","i18n","language","on","createHistory","Runtime","getRuntimeV3","getRuntimeV2Factory","v2Kit","getV2RuntimeFromDll","getRuntimeV2","Proxy","getRuntime","get","args","key","Reflect","_initialized","WeakMap","_bootstrapped","_Runtime_brand","WeakSet","constructor","_classPrivateMethodInitSpec2","default","_classPrivateFieldInitSpec2","_defineProperty2","initialize","data","_data$settings","_classPrivateFieldGet2","_classPrivateFieldSet2","normalizeBootstrapData","notification","dialog","_assertClassBrand2","_getPresetBricks","call","loadNotificationService","loadBricks","loadDialogService","customizeColorTheme","settings","misc","theme","bootstrap","Router","storyboards","getRecentApps","_router","getCurrentApp","_router2","currentApp","hasInstalledApp","appId","matchVersion","getFeatureFlags","_bootstrapData","_router3","featureFlags","config","getMiscSettings","_bootstrapData2","_router4","getBrandSettings","_bootstrapData3","base_title","brand","getLaunchpadSettings","_bootstrapData4","columns","rows","launchpad","getDesktops","_bootstrapData5","desktops","getLaunchpadSiteMap","_bootstrapData6","siteSort","toggleLaunchpadEffect","open","document","body","classList","toggle","applyPageTitle","pageTitle","baseTitle","title","getNavConfig","_router5","bricks","loadBricksImperatively","getBrickPackages","_bootstrapData10","presetBricks","isObject","deepFreeze","brickPackages","processPublicDepsPackages","pubDeps","length","bricksMap","Map","forEach","pkg","pkgName","filePath","split","has","set","Array","from","values","_bootstrapData7","injectedBrickPackages","window","STANDALONE_BRICK_PACKAGES","PUBLIC_DEPS","_internalApiGetRenderId","_router6","getRenderId","_internalApiMatchStoryboard","pathname","_bootstrapData8","matchStoryboard","_internalApiGetRuntimeContext","_router7","getRuntimeContext","_internalApiGetStoryboardInBootstrapData","_bootstrapData9","find","storyboard","app","id","_internalApiGetAppInBootstrapData","_internalApiGetStoryb","_test_only_setBootstrapData","process","env","NODE_ENV"],"sources":["../../../src/internal/Runtime.ts"],"sourcesContent":["import type {\n RuntimeStoryboard,\n BootstrapSettings,\n FeatureFlags,\n BootstrapData,\n Contract,\n Storyboard,\n BrickConf,\n RouteConf,\n ResolveConf,\n BrickPackage,\n} from \"@next-core/types\";\nimport { i18n, initializeI18n } from \"@next-core/i18n\";\nimport { loadBricksImperatively } from \"@next-core/loader\";\nimport { deepFreeze, isObject } from \"@next-core/utils/general\";\nimport type { PermissionApi_validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\nimport moment from \"moment\";\nimport \"moment/locale/zh-cn.js\";\nimport { createHistory } from \"../history.js\";\nimport { matchStoryboard } from \"./matchStoryboard.js\";\nimport { Router } from \"./Router.js\";\nimport { NS, locales } from \"./i18n.js\";\nimport { loadNotificationService } from \"../Notification.js\";\nimport { loadDialogService } from \"../Dialog.js\";\nimport { injectedBrickPackages } from \"./injected.js\";\nimport { type AppForCheck, hasInstalledApp } from \"./hasInstalledApp.js\";\nimport type { RuntimeContext } from \"./interfaces.js\";\nimport { listenDevtoolsEagerly } from \"./devtools.js\";\nimport { getV2RuntimeFromDll } from \"../getV2RuntimeFromDll.js\";\nimport { ThemeSettings, customizeColorTheme } from \"./customizeColorTheme.js\";\n\nlet runtime: Runtime;\n\n// Allow inject bootstrap data in a runtime other than Brick Next.\nlet bootstrapData: BootstrapData | undefined;\nlet router: Router | undefined;\nlet processedBrickPackages: BrickPackage[] | undefined;\n\nexport interface RuntimeOptions {\n hooks?: RuntimeHooks;\n}\n\nexport interface ImagesFactory {\n get(name: string): string;\n}\n\nexport interface PageViewInfo {\n status: \"ok\" | \"failed\" | \"redirected\" | \"not-found\";\n path?: string;\n pageTitle?: string;\n}\n\nexport interface RuntimeHooks {\n auth?: {\n getAuth(): object;\n isLoggedIn(): boolean;\n authenticate?(...args: unknown[]): unknown;\n logout?(...args: unknown[]): unknown;\n };\n fulfilStoryboard?: (storyboard: RuntimeStoryboard) => Promise<void>;\n validatePermissions?: typeof PermissionApi_validatePermissions;\n checkPermissions?: {\n checkPermissions(...actions: string[]): boolean;\n preCheckPermissions(storyboard: Storyboard): Promise<void> | undefined;\n preCheckPermissionsForBrickOrRoute(\n container: BrickConf | RouteConf,\n asyncComputeRealValue: (value: unknown) => Promise<unknown>\n ): Promise<void> | undefined;\n };\n checkInstalledApps?: {\n preCheckInstalledApps(\n storyboard: Storyboard,\n hasAppInBootstrap: (appId: string) => boolean\n ): void;\n waitForCheckingApps(appIds: string[]): Promise<void>;\n getCheckedApp(appId: string): AppForCheck | undefined;\n };\n flowApi?: {\n FLOW_API_PROVIDER: string;\n registerFlowApiProvider(): void;\n isFlowApiProvider(provider: string): boolean;\n getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string,\n stream?: boolean\n ): Promise<unknown[]>;\n collectContract(contracts: Contract[] | undefined): void;\n collectWidgetContract(contracts: Contract[] | undefined): void;\n clearCollectWidgetContract(): void;\n };\n menu?: {\n getMenuById(menuId: string): unknown;\n fetchMenuById(\n menuId: string,\n runtimeContext: RuntimeContext,\n runtimeHelpers: RuntimeHooksMenuHelpers\n ): Promise<unknown>;\n };\n images?: {\n imagesFactory(\n appId: string,\n isBuildPush?: boolean,\n version?: string\n ): ImagesFactory;\n widgetImagesFactory(\n widgetId: string,\n widgetVersion?: string\n ): ImagesFactory;\n };\n messageDispatcher?: {\n subscribe(...args: unknown[]): Promise<unknown>;\n unsubscribe(...args: unknown[]): Promise<unknown>;\n onMessage(channel: string, listener: (data: unknown) => void): void;\n onClose(listener: () => void): void;\n reset(): void;\n };\n pageView?: {\n create(): (info: PageViewInfo) => void;\n };\n}\n\nexport interface RuntimeHooksMenuHelpers {\n getStoryboardByAppId(appId: string): Storyboard | undefined;\n resolveData(\n resolveConf: ResolveConf,\n runtimeContext: RuntimeContext\n ): Promise<unknown>;\n asyncComputeRealValue(\n value: unknown,\n runtimeContext: RuntimeContext,\n options?: { ignoreSymbols?: boolean; noInject?: boolean }\n ): Promise<unknown>;\n}\n\nexport let hooks: RuntimeHooks | undefined;\n\nexport function createRuntime(options?: RuntimeOptions) {\n if (runtime) {\n throw new Error(\"Cannot create multiple runtimes\");\n }\n listenDevtoolsEagerly();\n hooks = options?.hooks;\n initializeI18n(NS, locales);\n moment.locale(i18n.language);\n i18n.on(\"languageChanged\", () => {\n moment.locale(i18n.language);\n });\n createHistory();\n runtime = new Runtime();\n return runtime;\n}\n\nfunction getRuntimeV3() {\n return runtime;\n}\n\n// istanbul ignore next\nfunction getRuntimeV2Factory() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return function getRuntimeV2() {\n return new Proxy(v2Kit.getRuntime(), {\n get(...args) {\n const key = args[1];\n switch (key) {\n case \"getCurrentApp\":\n case \"getRecentApps\":\n case \"hasInstalledApp\":\n case \"getDesktops\":\n case \"getLaunchpadSettings\":\n case \"getLaunchpadSiteMap\":\n case \"toggleLaunchpadEffect\":\n case \"applyPageTitle\":\n case \"getNavConfig\":\n case \"getFeatureFlags\":\n case \"getMiscSettings\":\n case \"getBrandSettings\":\n return Reflect.get(...args);\n }\n },\n }) as unknown as Runtime;\n };\n }\n}\n\n// istanbul ignore next\nexport const getRuntime = getRuntimeV2Factory() || getRuntimeV3;\n\nexport class Runtime {\n #initialized = false;\n #bootstrapped = false;\n\n readonly version: number | undefined = 3;\n\n initialize(data: BootstrapData) {\n if (this.#initialized) {\n throw new Error(\"The runtime cannot be initialized more than once\");\n }\n this.#initialized = true;\n normalizeBootstrapData(data);\n bootstrapData = data;\n const { notification, dialog } = this.#getPresetBricks();\n if (notification !== false) {\n loadNotificationService(\n notification ?? \"basic.show-notification\",\n this.loadBricks\n );\n }\n if (dialog !== false) {\n loadDialogService(dialog ?? \"basic.show-dialog\", this.loadBricks);\n }\n customizeColorTheme(data.settings?.misc?.theme as ThemeSettings);\n }\n\n async bootstrap(data?: BootstrapData) {\n if (data) {\n this.initialize(data);\n }\n if (this.#bootstrapped) {\n throw new Error(\"The runtime cannot be bootstrapped more than once\");\n }\n this.#bootstrapped = true;\n router = new Router(bootstrapData!.storyboards!);\n await router.bootstrap();\n }\n\n getRecentApps() {\n return router?.getRecentApps() ?? {};\n }\n\n getCurrentApp() {\n return router?.getRecentApps().currentApp;\n }\n\n hasInstalledApp(appId: string, matchVersion?: string): boolean {\n return hasInstalledApp(appId, matchVersion);\n }\n\n getFeatureFlags(): FeatureFlags {\n return {\n ...bootstrapData?.settings?.featureFlags,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.featureFlags,\n \"migrate-to-brick-next-v3\": true,\n };\n }\n\n getMiscSettings() {\n return {\n ...bootstrapData?.settings?.misc,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.misc,\n };\n }\n\n getBrandSettings(): Record<string, string> {\n return {\n base_title: \"DevOps 管理专家\",\n ...(bootstrapData?.settings?.brand as Record<string, string>),\n };\n }\n\n getLaunchpadSettings() {\n return {\n columns: 7,\n rows: 4,\n ...bootstrapData?.settings?.launchpad,\n };\n }\n\n getDesktops(): unknown[] {\n return bootstrapData?.desktops ?? [];\n }\n\n getLaunchpadSiteMap(): unknown[] {\n return bootstrapData?.siteSort ?? [];\n }\n\n toggleLaunchpadEffect(open: boolean): void {\n document.body.classList.toggle(\"launchpad-open\", open);\n }\n\n applyPageTitle(pageTitle: string): void {\n const baseTitle = this.getBrandSettings().base_title;\n document.title = pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle;\n }\n\n getNavConfig() {\n return router?.getNavConfig();\n }\n\n loadBricks(bricks: string[] | Set<string>) {\n return loadBricksImperatively(bricks, getBrickPackages());\n }\n\n #getPresetBricks() {\n return (bootstrapData?.settings?.presetBricks ?? {}) as {\n notification?: string | false;\n dialog?: string | false;\n };\n }\n}\n\nfunction normalizeBootstrapData(data: BootstrapData) {\n if (isObject(data.settings)) {\n deepFreeze(data.settings);\n }\n if (data.brickPackages) {\n deepFreeze(data.brickPackages);\n }\n}\n\nfunction processPublicDepsPackages(\n brickPackages: BrickPackage[],\n pubDeps: BrickPackage[] | undefined\n): BrickPackage[] {\n if (!pubDeps?.length) return brickPackages;\n\n const bricksMap = new Map();\n\n // bootstrapData 数据和 pubDeps 中可能同时存在同一个包名,需要过滤去重, 以 pubDeps 中的包为准\n [...pubDeps, ...brickPackages].forEach((pkg) => {\n const pkgName = pkg.filePath.split(\"/\")[1];\n // 始终将 pubDeps 放在前面\n if (!bricksMap.has(pkgName)) {\n bricksMap.set(pkgName, pkg);\n }\n });\n\n return Array.from(bricksMap.values());\n}\n\nexport function getBrickPackages(): BrickPackage[] {\n return (\n // Not necessary to process brick packages multiple times.\n processedBrickPackages ??\n (processedBrickPackages = processPublicDepsPackages(\n bootstrapData?.brickPackages ??\n injectedBrickPackages ??\n (window.STANDALONE_BRICK_PACKAGES as BrickPackage[] | undefined) ??\n [],\n window.PUBLIC_DEPS as BrickPackage[] | undefined\n ))\n );\n}\n\nexport function _internalApiGetRenderId(): string | undefined {\n return router?.getRenderId();\n}\n\nexport function _internalApiMatchStoryboard(\n pathname: string\n): RuntimeStoryboard | undefined {\n return matchStoryboard(bootstrapData?.storyboards ?? [], pathname);\n}\n\nexport function _internalApiGetRuntimeContext() {\n return router?.getRuntimeContext();\n}\n\nexport function _internalApiGetStoryboardInBootstrapData(appId: string) {\n return bootstrapData?.storyboards?.find(\n (storyboard) => storyboard.app.id === appId\n );\n}\n\nexport function _internalApiGetAppInBootstrapData(appId: string) {\n return _internalApiGetStoryboardInBootstrapData(appId)?.app;\n}\n\nexport let _test_only_setBootstrapData: (data: BootstrapData) => void;\n\n// istanbul ignore next\nif (process.env.NODE_ENV === \"test\") {\n _test_only_setBootstrapData = (data) => {\n bootstrapData = data as BootstrapData;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA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A,gBAAAA,eAAA,GAAbA,eAAA,CAAenF,WAAW,cAAAmF,eAAA,uBAA1BA,eAAA,CAA4BC,IAAI,CACpCC,UAAU,IAAKA,UAAU,CAACC,GAAG,CAACC,EAAE,KAAKhF,KACxC,CAAC;AACH;AAEO,SAASiF,iCAAiCA,CAACjF,KAAa,EAAE;EAAA,IAAAkF,qBAAA;EAC/D,QAAAA,qBAAA,GAAOP,wCAAwC,CAAC3E,KAAK,CAAC,cAAAkF,qBAAA,uBAA/CA,qBAAA,CAAiDH,GAAG;AAC7D;AAEO,IAAII,2BAA0D,GAAAlJ,OAAA,CAAAkJ,2BAAA;;AAErE;AACA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;EACnCrJ,OAAA,CAAAkJ,2BAAA,GAAAA,2BAA2B,GAAI7G,IAAI,IAAK;IACtCzC,aAAa,GAAGyC,IAAqB;EACvC,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"Runtime.js","names":["_i18n","require","_loader","_general","_moment","_interopRequireDefault","_history","_matchStoryboard","_Router","_i18n2","_Notification","_Dialog","_injected","_hasInstalledApp","_devtools","_getV2RuntimeFromDll","_customizeColorTheme","runtime","bootstrapData","router","processedBrickPackages","hooks","exports","createRuntime","options","Error","listenDevtoolsEagerly","initializeI18n","NS","locales","moment","locale","i18n","language","on","createHistory","Runtime","getRuntimeV3","getRuntimeV2Factory","v2Kit","getV2RuntimeFromDll","getRuntimeV2","Proxy","getRuntime","get","args","key","Reflect","_initialized","WeakMap","_bootstrapped","_Runtime_brand","WeakSet","constructor","_classPrivateMethodInitSpec2","default","_classPrivateFieldInitSpec2","_defineProperty2","initialize","data","_data$settings","_classPrivateFieldGet2","_classPrivateFieldSet2","normalizeBootstrapData","notification","dialog","_assertClassBrand2","_getPresetBricks","call","loadNotificationService","loadBricks","loadDialogService","customizeColorTheme","settings","misc","theme","bootstrap","Router","storyboards","getRecentApps","_router","getCurrentApp","_router2","currentApp","hasInstalledApp","appId","matchVersion","getFeatureFlags","_bootstrapData","_router3","featureFlags","config","getMiscSettings","_bootstrapData2","_router4","getBrandSettings","_bootstrapData3","base_title","brand","getLaunchpadSettings","_bootstrapData4","columns","rows","launchpad","getDesktops","_bootstrapData5","desktops","getLaunchpadSiteMap","_bootstrapData6","siteSort","toggleLaunchpadEffect","open","document","body","classList","toggle","applyPageTitle","pageTitle","_router5","baseTitle","title","localeTitle","getNavConfig","_router6","bricks","loadBricksImperatively","getBrickPackages","_bootstrapData10","presetBricks","isObject","deepFreeze","brickPackages","processPublicDepsPackages","pubDeps","length","bricksMap","Map","forEach","pkg","pkgName","filePath","split","has","set","Array","from","values","_bootstrapData7","injectedBrickPackages","window","STANDALONE_BRICK_PACKAGES","PUBLIC_DEPS","_internalApiGetRenderId","_router7","getRenderId","_internalApiMatchStoryboard","pathname","_bootstrapData8","matchStoryboard","_internalApiGetRuntimeContext","_router8","getRuntimeContext","_internalApiGetStoryboardInBootstrapData","_bootstrapData9","find","storyboard","app","id","_internalApiGetAppInBootstrapData","_internalApiGetStoryb","_test_only_setBootstrapData","process","env","NODE_ENV"],"sources":["../../../src/internal/Runtime.ts"],"sourcesContent":["import type {\n RuntimeStoryboard,\n BootstrapSettings,\n FeatureFlags,\n BootstrapData,\n Contract,\n Storyboard,\n BrickConf,\n RouteConf,\n ResolveConf,\n BrickPackage,\n} from \"@next-core/types\";\nimport { i18n, initializeI18n } from \"@next-core/i18n\";\nimport { loadBricksImperatively } from \"@next-core/loader\";\nimport { deepFreeze, isObject } from \"@next-core/utils/general\";\nimport type { PermissionApi_validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\nimport moment from \"moment\";\nimport \"moment/locale/zh-cn.js\";\nimport { createHistory } from \"../history.js\";\nimport { matchStoryboard } from \"./matchStoryboard.js\";\nimport { Router } from \"./Router.js\";\nimport { NS, locales } from \"./i18n.js\";\nimport { loadNotificationService } from \"../Notification.js\";\nimport { loadDialogService } from \"../Dialog.js\";\nimport { injectedBrickPackages } from \"./injected.js\";\nimport { type AppForCheck, hasInstalledApp } from \"./hasInstalledApp.js\";\nimport type { RuntimeContext } from \"./interfaces.js\";\nimport { listenDevtoolsEagerly } from \"./devtools.js\";\nimport { getV2RuntimeFromDll } from \"../getV2RuntimeFromDll.js\";\nimport { ThemeSettings, customizeColorTheme } from \"./customizeColorTheme.js\";\n\nlet runtime: Runtime;\n\n// Allow inject bootstrap data in a runtime other than Brick Next.\nlet bootstrapData: BootstrapData | undefined;\nlet router: Router | undefined;\nlet processedBrickPackages: BrickPackage[] | undefined;\n\nexport interface RuntimeOptions {\n hooks?: RuntimeHooks;\n}\n\nexport interface ImagesFactory {\n get(name: string): string;\n}\n\nexport interface PageViewInfo {\n status: \"ok\" | \"failed\" | \"redirected\" | \"not-found\";\n path?: string;\n pageTitle?: string;\n}\n\nexport interface RuntimeHooks {\n auth?: {\n getAuth(): object;\n isLoggedIn(): boolean;\n authenticate?(...args: unknown[]): unknown;\n logout?(...args: unknown[]): unknown;\n };\n fulfilStoryboard?: (storyboard: RuntimeStoryboard) => Promise<void>;\n validatePermissions?: typeof PermissionApi_validatePermissions;\n checkPermissions?: {\n checkPermissions(...actions: string[]): boolean;\n preCheckPermissions(storyboard: Storyboard): Promise<void> | undefined;\n preCheckPermissionsForBrickOrRoute(\n container: BrickConf | RouteConf,\n asyncComputeRealValue: (value: unknown) => Promise<unknown>\n ): Promise<void> | undefined;\n };\n checkInstalledApps?: {\n preCheckInstalledApps(\n storyboard: Storyboard,\n hasAppInBootstrap: (appId: string) => boolean\n ): void;\n waitForCheckingApps(appIds: string[]): Promise<void>;\n getCheckedApp(appId: string): AppForCheck | undefined;\n };\n flowApi?: {\n FLOW_API_PROVIDER: string;\n registerFlowApiProvider(): void;\n isFlowApiProvider(provider: string): boolean;\n getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string,\n stream?: boolean\n ): Promise<unknown[]>;\n collectContract(contracts: Contract[] | undefined): void;\n collectWidgetContract(contracts: Contract[] | undefined): void;\n clearCollectWidgetContract(): void;\n };\n menu?: {\n getMenuById(menuId: string): unknown;\n fetchMenuById(\n menuId: string,\n runtimeContext: RuntimeContext,\n runtimeHelpers: RuntimeHooksMenuHelpers\n ): Promise<unknown>;\n };\n images?: {\n imagesFactory(\n appId: string,\n isBuildPush?: boolean,\n version?: string\n ): ImagesFactory;\n widgetImagesFactory(\n widgetId: string,\n widgetVersion?: string\n ): ImagesFactory;\n };\n messageDispatcher?: {\n subscribe(...args: unknown[]): Promise<unknown>;\n unsubscribe(...args: unknown[]): Promise<unknown>;\n onMessage(channel: string, listener: (data: unknown) => void): void;\n onClose(listener: () => void): void;\n reset(): void;\n };\n pageView?: {\n create(): (info: PageViewInfo) => void;\n };\n}\n\nexport interface RuntimeHooksMenuHelpers {\n getStoryboardByAppId(appId: string): Storyboard | undefined;\n resolveData(\n resolveConf: ResolveConf,\n runtimeContext: RuntimeContext\n ): Promise<unknown>;\n asyncComputeRealValue(\n value: unknown,\n runtimeContext: RuntimeContext,\n options?: { ignoreSymbols?: boolean; noInject?: boolean }\n ): Promise<unknown>;\n}\n\nexport let hooks: RuntimeHooks | undefined;\n\nexport function createRuntime(options?: RuntimeOptions) {\n if (runtime) {\n throw new Error(\"Cannot create multiple runtimes\");\n }\n listenDevtoolsEagerly();\n hooks = options?.hooks;\n initializeI18n(NS, locales);\n moment.locale(i18n.language);\n i18n.on(\"languageChanged\", () => {\n moment.locale(i18n.language);\n });\n createHistory();\n runtime = new Runtime();\n return runtime;\n}\n\nfunction getRuntimeV3() {\n return runtime;\n}\n\n// istanbul ignore next\nfunction getRuntimeV2Factory() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return function getRuntimeV2() {\n return new Proxy(v2Kit.getRuntime(), {\n get(...args) {\n const key = args[1];\n switch (key) {\n case \"getCurrentApp\":\n case \"getRecentApps\":\n case \"hasInstalledApp\":\n case \"getDesktops\":\n case \"getLaunchpadSettings\":\n case \"getLaunchpadSiteMap\":\n case \"toggleLaunchpadEffect\":\n case \"applyPageTitle\":\n case \"getNavConfig\":\n case \"getFeatureFlags\":\n case \"getMiscSettings\":\n case \"getBrandSettings\":\n return Reflect.get(...args);\n }\n },\n }) as unknown as Runtime;\n };\n }\n}\n\n// istanbul ignore next\nexport const getRuntime = getRuntimeV2Factory() || getRuntimeV3;\n\nexport class Runtime {\n #initialized = false;\n #bootstrapped = false;\n\n readonly version: number | undefined = 3;\n\n initialize(data: BootstrapData) {\n if (this.#initialized) {\n throw new Error(\"The runtime cannot be initialized more than once\");\n }\n this.#initialized = true;\n normalizeBootstrapData(data);\n bootstrapData = data;\n const { notification, dialog } = this.#getPresetBricks();\n if (notification !== false) {\n loadNotificationService(\n notification ?? \"basic.show-notification\",\n this.loadBricks\n );\n }\n if (dialog !== false) {\n loadDialogService(dialog ?? \"basic.show-dialog\", this.loadBricks);\n }\n customizeColorTheme(data.settings?.misc?.theme as ThemeSettings);\n }\n\n async bootstrap(data?: BootstrapData) {\n if (data) {\n this.initialize(data);\n }\n if (this.#bootstrapped) {\n throw new Error(\"The runtime cannot be bootstrapped more than once\");\n }\n this.#bootstrapped = true;\n router = new Router(bootstrapData!.storyboards!);\n await router.bootstrap();\n }\n\n getRecentApps() {\n return router?.getRecentApps() ?? {};\n }\n\n getCurrentApp() {\n return router?.getRecentApps().currentApp;\n }\n\n hasInstalledApp(appId: string, matchVersion?: string): boolean {\n return hasInstalledApp(appId, matchVersion);\n }\n\n getFeatureFlags(): FeatureFlags {\n return {\n ...bootstrapData?.settings?.featureFlags,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.featureFlags,\n \"migrate-to-brick-next-v3\": true,\n };\n }\n\n getMiscSettings() {\n return {\n ...bootstrapData?.settings?.misc,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.misc,\n };\n }\n\n getBrandSettings(): Record<string, string> {\n return {\n base_title: \"DevOps 管理专家\",\n ...(bootstrapData?.settings?.brand as Record<string, string>),\n };\n }\n\n getLaunchpadSettings() {\n return {\n columns: 7,\n rows: 4,\n ...bootstrapData?.settings?.launchpad,\n };\n }\n\n getDesktops(): unknown[] {\n return bootstrapData?.desktops ?? [];\n }\n\n getLaunchpadSiteMap(): unknown[] {\n return bootstrapData?.siteSort ?? [];\n }\n\n toggleLaunchpadEffect(open: boolean): void {\n document.body.classList.toggle(\"launchpad-open\", open);\n }\n\n applyPageTitle(pageTitle: string): void {\n const baseTitle = this.getBrandSettings().base_title;\n document.title = pageTitle\n ? (router?.getRecentApps().currentApp?.localeTitle as string) ||\n `${pageTitle} - ${baseTitle}`\n : baseTitle;\n }\n\n getNavConfig() {\n return router?.getNavConfig();\n }\n\n loadBricks(bricks: string[] | Set<string>) {\n return loadBricksImperatively(bricks, getBrickPackages());\n }\n\n #getPresetBricks() {\n return (bootstrapData?.settings?.presetBricks ?? {}) as {\n notification?: string | false;\n dialog?: string | false;\n };\n }\n}\n\nfunction normalizeBootstrapData(data: BootstrapData) {\n if (isObject(data.settings)) {\n deepFreeze(data.settings);\n }\n if (data.brickPackages) {\n deepFreeze(data.brickPackages);\n }\n}\n\nfunction processPublicDepsPackages(\n brickPackages: BrickPackage[],\n pubDeps: BrickPackage[] | undefined\n): BrickPackage[] {\n if (!pubDeps?.length) return brickPackages;\n\n const bricksMap = new Map();\n\n // bootstrapData 数据和 pubDeps 中可能同时存在同一个包名,需要过滤去重, 以 pubDeps 中的包为准\n [...pubDeps, ...brickPackages].forEach((pkg) => {\n const pkgName = pkg.filePath.split(\"/\")[1];\n // 始终将 pubDeps 放在前面\n if (!bricksMap.has(pkgName)) {\n bricksMap.set(pkgName, pkg);\n }\n });\n\n return Array.from(bricksMap.values());\n}\n\nexport function getBrickPackages(): BrickPackage[] {\n return (\n // Not necessary to process brick packages multiple times.\n processedBrickPackages ??\n (processedBrickPackages = processPublicDepsPackages(\n bootstrapData?.brickPackages ??\n injectedBrickPackages ??\n (window.STANDALONE_BRICK_PACKAGES as BrickPackage[] | undefined) ??\n [],\n window.PUBLIC_DEPS as BrickPackage[] | undefined\n ))\n );\n}\n\nexport function _internalApiGetRenderId(): string | undefined {\n return router?.getRenderId();\n}\n\nexport function _internalApiMatchStoryboard(\n pathname: string\n): RuntimeStoryboard | undefined {\n return matchStoryboard(bootstrapData?.storyboards ?? [], pathname);\n}\n\nexport function _internalApiGetRuntimeContext() {\n return router?.getRuntimeContext();\n}\n\nexport function _internalApiGetStoryboardInBootstrapData(appId: string) {\n return bootstrapData?.storyboards?.find(\n (storyboard) => storyboard.app.id === appId\n );\n}\n\nexport function _internalApiGetAppInBootstrapData(appId: string) {\n return _internalApiGetStoryboardInBootstrapData(appId)?.app;\n}\n\nexport let _test_only_setBootstrapData: (data: BootstrapData) => void;\n\n// istanbul ignore next\nif (process.env.NODE_ENV === \"test\") {\n _test_only_setBootstrapData = (data) => {\n bootstrapData = data as BootstrapData;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACAA,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,SAAA,GAAAX,OAAA;AACA,IAAAY,gBAAA,GAAAZ,OAAA;AAEA,IAAAa,SAAA,GAAAb,OAAA;AACA,IAAAc,oBAAA,GAAAd,OAAA;AACA,IAAAe,oBAAA,GAAAf,OAAA;AAEA,IAAIgB,OAAgB;;AAEpB;AACA,IAAIC,aAAwC;AAC5C,IAAIC,MAA0B;AAC9B,IAAIC,sBAAkD;AAmG/C,IAAIC,KAA+B,GAAAC,OAAA,C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EACnCvJ,OAAA,CAAAoJ,2BAAA,GAAAA,2BAA2B,GAAI/G,IAAI,IAAK;IACtCzC,aAAa,GAAGyC,IAAqB;EACvC,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","names":[],"sources":["../../../src/internal/interfaces.ts"],"sourcesContent":["import type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport type {\n BrickEventHandler,\n BrickEventsMap,\n CustomTemplate,\n RouteConf,\n RuntimeSnippet,\n CustomTemplateProxy,\n CustomTemplateProxyBasicProperty,\n CustomTemplateProxySlot,\n SlotsConfOfBricks,\n Storyboard,\n StaticMenuConf,\n UseProviderResolveConf,\n MicroApp,\n} from \"@next-core/types\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { RuntimeBrickConfOfFormSymbols } from \"./FormRenderer/constants.js\";\n\nexport interface RuntimeContext extends LegacyCompatibleRuntimeContext {\n ctxStore: DataStore<\"CTX\">;\n tplStateStoreMap: Map<string, DataStore<\"STATE\">>;\n pendingPermissionsPreCheck: (Promise<unknown> | undefined)[];\n tplStateStoreId?: string;\n // `useBrick` has a local tpl state store scope\n tplStateStoreScope?: DataStore<\"STATE\">[];\n forEachItem?: unknown;\n forEachIndex?: number;\n forEachSize?: number;\n appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncPropertyEntry = [\n name: string,\n value: Promise<unknown>,\n ignoreUndefined?: boolean,\n];\n\nexport interface ElementHolder {\n element?: HTMLElement | null;\n}\n\nexport interface RenderRoot extends BaseRenderNode {\n tag: RenderTag.ROOT;\n container?: HTMLElement | DocumentFragment;\n createPortal:\n | HTMLElement\n | DocumentFragment\n | (() => HTMLElement | DocumentFragment);\n}\n\nexport interface RenderBrick extends BaseRenderNode, RuntimeBrick {\n tag: RenderTag.BRICK;\n return: RenderReturnNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface RenderPlaceholder extends BaseRenderNode {\n tag: RenderTag.PLACEHOLDER;\n return: RenderReturnNode;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderChildNode;\n sibling?: RenderChildNode;\n return?: RenderReturnNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = RenderRoot | RenderBrick | RenderPlaceholder;\n\nexport type RenderChildNode = RenderBrick | RenderPlaceholder;\nexport type RenderReturnNode = RenderRoot | RenderBrick;\n\nexport interface RuntimeBrick {\n type: string;\n properties?: Record<string, unknown>;\n events?: BrickEventsMap;\n slotId?: string;\n element?: RuntimeBrickElement | null;\n iid?: string;\n runtimeContext: RuntimeContext;\n tplHostMetadata?: TemplateHostMetadata;\n portal?: boolean;\n ref?: string;\n}\n\nexport type MetaInfoOfEventListener = [\n string,\n // For compatibility of devtools, leave the second argument there.\n null | undefined,\n BrickEventHandler,\n];\n\nexport type RememberedEventListener = [string, EventListener];\n\nexport interface RuntimeBrickElement extends HTMLElement {\n $$typeof?: \"brick\" | \"provider\" | \"custom-template\" | \"native\" | \"invalid\";\n /** Meta info of listeners, for devtools only */\n $$eventListeners?: MetaInfoOfEventListener[];\n /** Remembered listeners for unbinding */\n $$listeners?: RememberedEventListener[];\n /** Remembered proxy listeners for unbinding */\n $$proxyListeners?: RememberedEventListener[];\n /** Find element by ref in a custom template */\n $$getElementByRef?: (ref: string) => HTMLElement | null | undefined;\n $$tplStateStore?: DataStore<\"STATE\">;\n}\n\nexport interface TemplateHostMetadata {\n internalBricksByRef: Map<string, RuntimeBrick>;\n tplStateStoreId: string;\n proxy?: CustomTemplateProxy;\n}\n\nexport type TemplateHostBrick = RuntimeBrick & {\n tplHostMetadata: TemplateHostMetadata;\n};\n\nexport interface TemplateHostContext {\n reversedProxies: ReversedProxies;\n asyncHostPropertyEntries: AsyncPropertyEntry[];\n externalSlots?: SlotsConfOfBricks;\n tplStateStoreId: string;\n hostBrick: TemplateHostBrick;\n __temporary_tpl_tag_name?: string;\n}\n\ninterface ReversedProxies {\n properties: Map<string, ReversedPropertyProxy[]>;\n slots: Map<string, ReversedSlotProxy[]>;\n}\n\ninterface ReversedPropertyProxy {\n from: string;\n to: CustomTemplateProxyBasicProperty;\n}\n\ninterface ReversedSlotProxy {\n from: string;\n to: CustomTemplateProxySlot;\n}\n\nexport type RuntimeBrickConfWithSymbols = RuntimeBrickConfWithTplSymbols &\n RuntimeBrickConfOfFormSymbols;\n\nexport interface DataValueOption {\n tplStateStoreId?: string;\n routeId?: string;\n}\n\nexport type PreviewStoryboardPatch =\n | CustomTemplate\n | RouteConf\n | RuntimeSnippet;\n\nexport interface PreviewOption {\n appId: string;\n formId?: string;\n updateStoryboardType?: \"route\" | \"template\" | \"snippet\";\n collectUsedContracts?(storyboard: Storyboard): string[] | Promise<string[]>;\n}\n\nexport interface MenuRequestNode {\n child?: MenuRequestNode;\n sibling?: MenuRequestNode;\n return?: MenuRequestNode;\n request?: Promise<StaticMenuConf>;\n}\n\nexport interface DebugDataValue {\n resolve?: UseProviderResolveConf;\n value?: unknown;\n}\n\nexport interface RuntimeDataVale\n extends Pick<LegacyCompatibleRuntimeContext, \"match\" | \"sys\" | \"query\"> {\n location: {\n href: string;\n origin: string;\n hostname: string;\n host: string;\n };\n app?: MicroApp;\n}\n\nexport interface RuntimeDataValueOption {\n routeId?: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"interfaces.js","names":[],"sources":["../../../src/internal/interfaces.ts"],"sourcesContent":["import type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport type {\n BrickEventHandler,\n BrickEventsMap,\n CustomTemplate,\n RouteConf,\n RuntimeSnippet,\n CustomTemplateProxy,\n CustomTemplateProxyBasicProperty,\n CustomTemplateProxySlot,\n SlotsConfOfBricks,\n Storyboard,\n StaticMenuConf,\n UseProviderResolveConf,\n MicroApp,\n} from \"@next-core/types\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { RuntimeBrickConfOfFormSymbols } from \"./FormRenderer/constants.js\";\n\nexport interface RuntimeContext extends LegacyCompatibleRuntimeContext {\n ctxStore: DataStore<\"CTX\">;\n tplStateStoreMap: Map<string, DataStore<\"STATE\">>;\n pendingPermissionsPreCheck: (Promise<unknown> | undefined)[];\n tplStateStoreId?: string;\n // `useBrick` has a local tpl state store scope\n tplStateStoreScope?: DataStore<\"STATE\">[];\n forEachItem?: unknown;\n forEachIndex?: number;\n forEachSize?: number;\n appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncPropertyEntry = [\n name: string,\n value: Promise<unknown>,\n ignoreUndefined?: boolean,\n];\n\nexport interface ElementHolder {\n element?: HTMLElement | null;\n}\n\nexport interface RenderRoot extends BaseRenderNode {\n tag: RenderTag.ROOT;\n container?: HTMLElement | DocumentFragment;\n createPortal:\n | HTMLElement\n | DocumentFragment\n | (() => HTMLElement | DocumentFragment);\n}\n\nexport interface RenderBrick extends BaseRenderNode, RuntimeBrick {\n tag: RenderTag.BRICK;\n return: RenderReturnNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface RenderPlaceholder extends BaseRenderNode {\n tag: RenderTag.PLACEHOLDER;\n return: RenderReturnNode;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderChildNode;\n sibling?: RenderChildNode;\n return?: RenderReturnNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = RenderRoot | RenderBrick | RenderPlaceholder;\n\nexport type RenderChildNode = RenderBrick | RenderPlaceholder;\nexport type RenderReturnNode = RenderRoot | RenderBrick;\n\nexport interface RuntimeBrick {\n type: string;\n properties?: Record<string, unknown>;\n events?: BrickEventsMap;\n slotId?: string;\n element?: RuntimeBrickElement | null;\n iid?: string;\n runtimeContext: RuntimeContext;\n tplHostMetadata?: TemplateHostMetadata;\n portal?: boolean;\n ref?: string;\n}\n\nexport type MetaInfoOfEventListener = [\n string,\n // For compatibility of devtools, leave the second argument there.\n null | undefined,\n BrickEventHandler,\n];\n\nexport type RememberedEventListener = [string, EventListener];\n\nexport interface RuntimeBrickElement extends HTMLElement {\n $$typeof?: \"brick\" | \"provider\" | \"custom-template\" | \"native\" | \"invalid\";\n /** Meta info of listeners, for devtools only */\n $$eventListeners?: MetaInfoOfEventListener[];\n /** Remembered listeners for unbinding */\n $$listeners?: RememberedEventListener[];\n /** Remembered proxy listeners for unbinding */\n $$proxyListeners?: RememberedEventListener[];\n /** Find element by ref in a custom template */\n $$getElementByRef?: (ref: string) => HTMLElement | null | undefined;\n $$tplStateStore?: DataStore<\"STATE\">;\n}\n\nexport interface TemplateHostMetadata {\n internalBricksByRef: Map<string, RuntimeBrick>;\n tplStateStoreId: string;\n proxy?: CustomTemplateProxy;\n}\n\nexport type TemplateHostBrick = RuntimeBrick & {\n tplHostMetadata: TemplateHostMetadata;\n};\n\nexport interface TemplateHostContext {\n reversedProxies: ReversedProxies;\n asyncHostPropertyEntries: AsyncPropertyEntry[];\n externalSlots?: SlotsConfOfBricks;\n tplStateStoreId: string;\n hostBrick: TemplateHostBrick;\n}\n\ninterface ReversedProxies {\n properties: Map<string, ReversedPropertyProxy[]>;\n slots: Map<string, ReversedSlotProxy[]>;\n}\n\ninterface ReversedPropertyProxy {\n from: string;\n to: CustomTemplateProxyBasicProperty;\n}\n\ninterface ReversedSlotProxy {\n from: string;\n to: CustomTemplateProxySlot;\n}\n\nexport type RuntimeBrickConfWithSymbols = RuntimeBrickConfWithTplSymbols &\n RuntimeBrickConfOfFormSymbols;\n\nexport interface DataValueOption {\n tplStateStoreId?: string;\n routeId?: string;\n}\n\nexport type PreviewStoryboardPatch =\n | CustomTemplate\n | RouteConf\n | RuntimeSnippet;\n\nexport interface PreviewOption {\n appId: string;\n formId?: string;\n updateStoryboardType?: \"route\" | \"template\" | \"snippet\";\n collectUsedContracts?(storyboard: Storyboard): string[] | Promise<string[]>;\n}\n\nexport interface MenuRequestNode {\n child?: MenuRequestNode;\n sibling?: MenuRequestNode;\n return?: MenuRequestNode;\n request?: Promise<StaticMenuConf>;\n}\n\nexport interface DebugDataValue {\n resolve?: UseProviderResolveConf;\n value?: unknown;\n}\n\nexport interface RuntimeDataVale\n extends Pick<LegacyCompatibleRuntimeContext, \"match\" | \"sys\" | \"query\"> {\n location: {\n href: string;\n origin: string;\n hostname: string;\n host: string;\n };\n app?: MicroApp;\n}\n\nexport interface RuntimeDataValueOption {\n routeId?: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -3,5 +3,4 @@ export const symbolForTplStateStoreId = Symbol.for("tpl.stateStoreId");
3
3
  export const symbolForTPlExternalForEachItem = Symbol.for("tpl.externalForEachItem");
4
4
  export const symbolForTPlExternalForEachIndex = Symbol.for("tpl.externalForEachIndex");
5
5
  export const symbolForTPlExternalForEachSize = Symbol.for("tpl.externalForEachSize");
6
- export const symbolForTPlExternalNoForEach = Symbol.for("tpl.externalNoForEach");
7
6
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["symbolForAsyncComputedPropsFromHost","Symbol","for","symbolForTplStateStoreId","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachSize","symbolForTPlExternalNoForEach"],"sources":["../../../../src/internal/CustomTemplates/constants.ts"],"sourcesContent":["import type { BrickConf } from \"@next-core/types\";\nimport type { AsyncPropertyEntry } from \"../interfaces.js\";\n\nexport const symbolForAsyncComputedPropsFromHost = Symbol.for(\n \"tpl.asyncComputedPropsFromHost\"\n);\nexport const symbolForTplStateStoreId = Symbol.for(\"tpl.stateStoreId\");\nexport const symbolForTPlExternalForEachItem = Symbol.for(\n \"tpl.externalForEachItem\"\n);\nexport const symbolForTPlExternalForEachIndex = Symbol.for(\n \"tpl.externalForEachIndex\"\n);\nexport const symbolForTPlExternalForEachSize = Symbol.for(\n \"tpl.externalForEachSize\"\n);\nexport const symbolForTPlExternalNoForEach = Symbol.for(\n \"tpl.externalNoForEach\"\n);\n\nexport type RuntimeBrickConfWithTplSymbols = BrickConf &\n RuntimeBrickConfOfTplSymbols;\n\nexport interface RuntimeBrickConfOfTplSymbols {\n [symbolForAsyncComputedPropsFromHost]?: AsyncPropertyEntry[];\n [symbolForTplStateStoreId]?: string;\n [symbolForTPlExternalForEachItem]?: unknown;\n [symbolForTPlExternalForEachIndex]?: number;\n [symbolForTPlExternalForEachSize]?: number;\n [symbolForTPlExternalNoForEach]?: boolean;\n}\n"],"mappings":"AAGA,OAAO,MAAMA,mCAAmC,GAAGC,MAAM,CAACC,GAAG,CAC3D,gCACF,CAAC;AACD,OAAO,MAAMC,wBAAwB,GAAGF,MAAM,CAACC,GAAG,CAAC,kBAAkB,CAAC;AACtE,OAAO,MAAME,+BAA+B,GAAGH,MAAM,CAACC,GAAG,CACvD,yBACF,CAAC;AACD,OAAO,MAAMG,gCAAgC,GAAGJ,MAAM,CAACC,GAAG,CACxD,0BACF,CAAC;AACD,OAAO,MAAMI,+BAA+B,GAAGL,MAAM,CAACC,GAAG,CACvD,yBACF,CAAC;AACD,OAAO,MAAMK,6BAA6B,GAAGN,MAAM,CAACC,GAAG,CACrD,uBACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"constants.js","names":["symbolForAsyncComputedPropsFromHost","Symbol","for","symbolForTplStateStoreId","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachSize"],"sources":["../../../../src/internal/CustomTemplates/constants.ts"],"sourcesContent":["import type { BrickConf } from \"@next-core/types\";\nimport type { AsyncPropertyEntry } from \"../interfaces.js\";\n\nexport const symbolForAsyncComputedPropsFromHost = Symbol.for(\n \"tpl.asyncComputedPropsFromHost\"\n);\nexport const symbolForTplStateStoreId = Symbol.for(\"tpl.stateStoreId\");\nexport const symbolForTPlExternalForEachItem = Symbol.for(\n \"tpl.externalForEachItem\"\n);\nexport const symbolForTPlExternalForEachIndex = Symbol.for(\n \"tpl.externalForEachIndex\"\n);\nexport const symbolForTPlExternalForEachSize = Symbol.for(\n \"tpl.externalForEachSize\"\n);\n\nexport type RuntimeBrickConfWithTplSymbols = BrickConf &\n RuntimeBrickConfOfTplSymbols;\n\nexport interface RuntimeBrickConfOfTplSymbols {\n [symbolForAsyncComputedPropsFromHost]?: AsyncPropertyEntry[];\n [symbolForTplStateStoreId]?: string;\n [symbolForTPlExternalForEachItem]?: unknown;\n [symbolForTPlExternalForEachIndex]?: number;\n [symbolForTPlExternalForEachSize]?: number;\n}\n"],"mappings":"AAGA,OAAO,MAAMA,mCAAmC,GAAGC,MAAM,CAACC,GAAG,CAC3D,gCACF,CAAC;AACD,OAAO,MAAMC,wBAAwB,GAAGF,MAAM,CAACC,GAAG,CAAC,kBAAkB,CAAC;AACtE,OAAO,MAAME,+BAA+B,GAAGH,MAAM,CAACC,GAAG,CACvD,yBACF,CAAC;AACD,OAAO,MAAMG,gCAAgC,GAAGJ,MAAM,CAACC,GAAG,CACxD,0BACF,CAAC;AACD,OAAO,MAAMI,+BAA+B,GAAGL,MAAM,CAACC,GAAG,CACvD,yBACF,CAAC","ignoreList":[]}
@@ -83,8 +83,7 @@ export function expandCustomTemplate(tplTagName, brickConf, hostBrick, asyncHost
83
83
  asyncHostPropertyEntries,
84
84
  externalSlots: childrenToSlots(externalChildren, originalExternalSlots),
85
85
  tplStateStoreId,
86
- hostBrick: hostBrick,
87
- __temporary_tpl_tag_name: tplTagName
86
+ hostBrick: hostBrick
88
87
  };
89
88
  newBrickConf.slots = {
90
89
  "": {
@@ -1 +1 @@
1
- {"version":3,"file":"expandCustomTemplate.js","names":["uniqueId","customTemplates","DataStore","setupTemplateProxy","setupUseBrickInTemplate","childrenToSlots","hooks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostPropertyEntries","rendererContext","_hooks$flowApi","tplStateStoreId","runtimeContext","forEachItem","forEachIndex","forEachSize","formStateStoreId","tplStateStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","get","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","__temporary_tpl_tag_name","type","map","item","expandBrickInTemplate","brickConfInTemplate","if","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","transpiledSlots","fromEntries","_ref","slotName","slotConf"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./constants.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncPropertyEntry,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostPropertyEntries: AsyncPropertyEntry[],\n rendererContext: RendererContext\n): T {\n const tplStateStoreId = uniqueId(\"tpl-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n tplStateStoreId,\n };\n\n // There is a boundary for `forEach*` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\n \"STATE\",\n hostBrick,\n rendererContext,\n tplStateStoreId\n );\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostPropertyEntries);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n __temporary_tpl_tag_name: tplTagName,\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.map((item) => expandBrickInTemplate(item, hostContext)),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConfInTemplate,\n hostContext: TemplateHostContext\n): RuntimeBrickConfWithTplSymbols {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n const slots: SlotsConfOfBricks = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(hostContext, restBrickConfInTemplate.ref, slots),\n };\n}\n"],"mappings":"AAOA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;AAEhD,SAASC,kBAAkB,QAAQ,yBAAyB;AAO5D,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,KAAK,QAAQ,eAAe;AAGrC,OAAO,SAASC,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,wBAA8C,EAC9CC,eAAgC,EAC7B;EAAA,IAAAC,cAAA;EACH,MAAMC,eAAe,GAAGd,QAAQ,CAAC,YAAY,CAAC;EAC9C,MAAMe,cAAc,GAAG;IACrB,GAAGL,SAAS,CAACK,cAAc;IAC3BD;EACF,CAAC;;EAED;EACA,OAAOC,cAAc,CAACC,WAAW;EACjC,OAAOD,cAAc,CAACE,YA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C;EAED,OAAOb,YAAY;AACrB;AAEA,SAASmB,qBAAqBA,CAC5BC,mBAAwC,EACxCP,WAAgC,EACA;EAChC;EACA,IAAIO,mBAAmB,CAACC,EAAE,KAAK,IAAI,EAAE;IACnC,OAAOD,mBAAmB,CAACC,EAAE;EAC/B;EACA,MAAM;IACJf,UAAU;IACVX,KAAK,EAAE2B,eAAe;IACtBzB,QAAQ,EAAE0B,kBAAkB;IAC5B,GAAGC;EACL,CAAC,GAAGJ,mBAAmB;EAEvB,MAAMK,eAAe,GAAG1D,eAAe,CACrCwD,kBAAkB,EAClBD,eACF,CAAoC;EAEpC,MAAM3B,KAAwB,GAAGc,MAAM,CAACiB,WAAW,CACjDjB,MAAM,CAACC,OAAO,CAACe,eAAe,IAAI,CAAC,CAAC,CAAC,CAACR,GAAG,CAACU,IAAA;IAAA,IAAC,CAACC,QAAQ,EAAEC,QAAQ,CAAC,GAAAF,IAAA;IAAA,OAAK,CAClEC,QAAQ,EACR;MACEZ,IAAI,EAAE,QAAQ;MACd7B,MAAM,EAAE,CAAC0C,QAAQ,CAAC1C,MAAM,IAAI,EAAE,EAAE8B,GAAG,CAAEC,IAAI,IACvCC,qBAAqB,CAACD,IAAI,EAAEL,WAAW,CACzC;IACF,CAAC,CACF;EAAA,EACH,CAAC;EAED,OAAO;IACL,GAAGW,uBAAuB;IAC1BlB,UAAU,EAAExC,uBAAuB,CAACwC,UAAU,EAAEO,WAAW,CAAC;IAC5DlB,KAAK;IACL,GAAG9B,kBAAkB,CAACgD,WAAW,EAAEW,uBAAuB,CAACZ,GAAG,EAAEjB,KAAK;EACvE,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"expandCustomTemplate.js","names":["uniqueId","customTemplates","DataStore","setupTemplateProxy","setupUseBrickInTemplate","childrenToSlots","hooks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostPropertyEntries","rendererContext","_hooks$flowApi","tplStateStoreId","runtimeContext","forEachItem","forEachIndex","forEachSize","formStateStoreId","tplStateStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","get","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","type","map","item","expandBrickInTemplate","brickConfInTemplate","if","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","transpiledSlots","fromEntries","_ref","slotName","slotConf"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./constants.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncPropertyEntry,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostPropertyEntries: AsyncPropertyEntry[],\n rendererContext: RendererContext\n): T {\n const tplStateStoreId = uniqueId(\"tpl-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n tplStateStoreId,\n };\n\n // There is a boundary for `forEach*` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\n \"STATE\",\n hostBrick,\n rendererContext,\n tplStateStoreId\n );\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostPropertyEntries);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.map((item) => expandBrickInTemplate(item, hostContext)),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConfInTemplate,\n hostContext: TemplateHostContext\n): RuntimeBrickConfWithTplSymbols {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n const slots: SlotsConfOfBricks = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(hostContext, restBrickConfInTemplate.ref, slots),\n };\n}\n"],"mappings":"AAOA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;AAEhD,SAASC,kBAAkB,QAAQ,yBAAyB;AAO5D,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,KAAK,QAAQ,eAAe;AAGrC,OAAO,SAASC,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,wBAA8C,EAC9CC,eAAgC,EAC7B;EAAA,IAAAC,cAAA;EACH,MAAMC,eAAe,GAAGd,QAAQ,CAAC,YAAY,CAAC;EAC9C,MAAMe,cAAc,GAAG;IACrB,GAAGL,SAAS,CAACK,cAAc;IAC3BD;EACF,CAAC;;EAED;EACA,OAAOC,cAAc,CAACC,WAAW;EACjC,OAAOD,cAAc,CAACE,YAAY;EAClC,OAAOF,cAAc,CAACG,WAAW;EACjC,OAAOH,cAAc,CAACI,gBAAgB;EAEtC,MAAMC,aAAa,GAAG,IAAIlB,SAAS,CACjC,OAAO,EACPQ,SAAS,EACTE,eAAe,EACfE,eAC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AAM;IACJd,UAAU;IACVX,KAAK,EAAE0B,eAAe;IACtBxB,QAAQ,EAAEyB,kBAAkB;IAC5B,GAAGC;EACL,CAAC,GAAGJ,mBAAmB;EAEvB,MAAMK,eAAe,GAAGzD,eAAe,CACrCuD,kBAAkB,EAClBD,eACF,CAAoC;EAEpC,MAAM1B,KAAwB,GAAGc,MAAM,CAACgB,WAAW,CACjDhB,MAAM,CAACC,OAAO,CAACc,eAAe,IAAI,CAAC,CAAC,CAAC,CAACR,GAAG,CAACU,IAAA;IAAA,IAAC,CAACC,QAAQ,EAAEC,QAAQ,CAAC,GAAAF,IAAA;IAAA,OAAK,CAClEC,QAAQ,EACR;MACEZ,IAAI,EAAE,QAAQ;MACd5B,MAAM,EAAE,CAACyC,QAAQ,CAACzC,MAAM,IAAI,EAAE,EAAE6B,GAAG,CAAEC,IAAI,IACvCC,qBAAqB,CAACD,IAAI,EAAEJ,WAAW,CACzC;IACF,CAAC,CACF;EAAA,EACH,CAAC;EAED,OAAO;IACL,GAAGU,uBAAuB;IAC1BjB,UAAU,EAAExC,uBAAuB,CAACwC,UAAU,EAAEO,WAAW,CAAC;IAC5DlB,KAAK;IACL,GAAG9B,kBAAkB,CAACgD,WAAW,EAAEU,uBAAuB,CAACX,GAAG,EAAEjB,KAAK;EACvE,CAAC;AACH","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import { hasOwnProperty } from "@next-core/utils/general";
2
2
  import { clamp } from "lodash";
3
- import { symbolForAsyncComputedPropsFromHost, symbolForTPlExternalForEachIndex, symbolForTPlExternalForEachItem, symbolForTPlExternalForEachSize, symbolForTPlExternalNoForEach, symbolForTplStateStoreId } from "./constants.js";
3
+ import { symbolForAsyncComputedPropsFromHost, symbolForTPlExternalForEachIndex, symbolForTPlExternalForEachItem, symbolForTPlExternalForEachSize, symbolForTplStateStoreId } from "./constants.js";
4
4
  import { computePropertyValue } from "../compute/computeRealProperties.js";
5
5
  import { childrenToSlots } from "../Renderer.js";
6
6
  export function setupTemplateProxy(hostContext, ref, slots) {
@@ -59,7 +59,7 @@ export function setupTemplateProxy(hostContext, ref, slots) {
59
59
  // External bricks of a template, should not access the template internal forEach `ITEM`.
60
60
  // For some existing templates who is *USING* this bug, we keep the old behavior.
61
61
  const hostHasForEach = hasOwnProperty(hostBrick.runtimeContext, "forEachItem");
62
- expandableSlot[clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((hostContext.__temporary_tpl_tag_name === "base-layout-v3.tpl-scroll-load-list" || hostContext.__temporary_tpl_tag_name === "shrcb-homepage.tpl-custom-scroll-load-list") && !hostHasForEach ? insertBricks : setupTemplateExternalBricks(insertBricks, hostHasForEach, hostBrick.runtimeContext.forEachItem, hostBrick.runtimeContext.forEachIndex, hostBrick.runtimeContext.forEachSize)));
62
+ expandableSlot[clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...(!hostHasForEach ? insertBricks : setupTemplateExternalBricksWithForEach(insertBricks, hostBrick.runtimeContext.forEachItem, hostBrick.runtimeContext.forEachIndex, hostBrick.runtimeContext.forEachSize)));
63
63
  }
64
64
  for (const [slotName, quasis] of quasisMap.entries()) {
65
65
  if (!hasOwnProperty(slots, slotName)) {
@@ -83,47 +83,39 @@ export function setupTemplateProxy(hostContext, ref, slots) {
83
83
  }
84
84
 
85
85
  // External bricks of a template, have the same forEachItem context as their host.
86
- function setupTemplateExternalBricks(bricks, hasForEach, forEachItem, forEachIndex, forEachSize) {
86
+ function setupTemplateExternalBricksWithForEach(bricks, forEachItem, forEachIndex, forEachSize) {
87
87
  return bricks.map(_ref2 => {
88
88
  let {
89
89
  children,
90
90
  slots,
91
- [symbolForTPlExternalForEachItem]: a,
92
- [symbolForTPlExternalForEachIndex]: b,
93
- [symbolForTPlExternalForEachSize]: c,
94
- [symbolForTPlExternalNoForEach]: d,
95
91
  ...brick
96
92
  } = _ref2;
97
93
  return {
98
94
  ...brick,
99
- ...(hasForEach ? {
100
- [symbolForTPlExternalForEachItem]: forEachItem,
101
- [symbolForTPlExternalForEachIndex]: forEachIndex,
102
- [symbolForTPlExternalForEachSize]: forEachSize
103
- } : {
104
- [symbolForTPlExternalNoForEach]: true
105
- }),
95
+ [symbolForTPlExternalForEachItem]: forEachItem,
96
+ [symbolForTPlExternalForEachIndex]: forEachIndex,
97
+ [symbolForTPlExternalForEachSize]: forEachSize,
106
98
  // Keep `:forEach` bricks as original, since they have their own forEachItem context.
107
99
  slots: brick.brick === ":forEach" ? childrenToSlots(children, slots) : Object.fromEntries(Object.entries(childrenToSlots(children, slots) ?? {}).map(_ref3 => {
108
100
  let [slotName, slotConf] = _ref3;
109
101
  return [slotName, slotConf.type === "routes" ? {
110
102
  type: "routes",
111
- routes: setupTemplateExternalRoutes(slotConf.routes, hasForEach, forEachItem, forEachIndex, forEachSize)
103
+ routes: setupTemplateExternalRoutesWithForEach(slotConf.routes, forEachItem, forEachIndex, forEachSize)
112
104
  } : {
113
105
  type: "bricks",
114
- bricks: setupTemplateExternalBricks(slotConf.bricks, hasForEach, forEachItem, forEachIndex, forEachSize)
106
+ bricks: setupTemplateExternalBricksWithForEach(slotConf.bricks, forEachItem, forEachIndex, forEachSize)
115
107
  }];
116
108
  }))
117
109
  };
118
110
  });
119
111
  }
120
- function setupTemplateExternalRoutes(routes, hasForEach, forEachItem, forEachIndex, forEachSize) {
112
+ function setupTemplateExternalRoutesWithForEach(routes, forEachItem, forEachIndex, forEachSize) {
121
113
  return routes.map(route => route.type === "routes" ? {
122
114
  ...route,
123
- routes: setupTemplateExternalRoutes(route.routes, hasForEach, forEachItem, forEachIndex, forEachSize)
115
+ routes: setupTemplateExternalRoutesWithForEach(route.routes, forEachItem, forEachIndex, forEachSize)
124
116
  } : route.type === "redirect" ? route : {
125
117
  ...route,
126
- bricks: setupTemplateExternalBricks(route.bricks, hasForEach, forEachItem, forEachIndex, forEachSize)
118
+ bricks: setupTemplateExternalBricksWithForEach(route.bricks, forEachItem, forEachIndex, forEachSize)
127
119
  });
128
120
  }
129
121
  //# sourceMappingURL=setupTemplateProxy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setupTemplateProxy.js","names":["hasOwnProperty","clamp","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachSize","symbolForTPlExternalNoForEach","symbolForTplStateStoreId","computePropertyValue","childrenToSlots","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostPropertyEntries","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","asyncHostProps","map","_ref","from","to","filtered","filter","entry","length","refProperty","Boolean","slotProxies","quasisMap","Map","_externalSlots$from","insertBricks","bricks","refToSlot","refSlot","expandableSlot","size","i","push","set","refPosition","hostHasForEach","runtimeContext","__temporary_tpl_tag_name","setupTemplateExternalBricks","forEachItem","forEachIndex","forEachSize","slotName","quasis","entries","type","slotConf","flatMap","index","concat","hasForEach","_ref2","children","a","b","c","d","brick","Object","fromEntries","_ref3","routes","setupTemplateExternalRoutes","route"],"sources":["../../../../src/internal/CustomTemplates/setupTemplateProxy.ts"],"sourcesContent":["import type { BrickConf, RouteConf, SlotsConfOfBricks } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { clamp } from \"lodash\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachIndex,\n symbolForTPlExternalForEachItem,\n symbolForTPlExternalForEachSize,\n symbolForTPlExternalNoForEach,\n symbolForTplStateStoreId,\n type RuntimeBrickConfWithTplSymbols,\n} from \"./constants.js\";\nimport type { AsyncPropertyEntry, TemplateHostContext } from \"../interfaces.js\";\nimport { computePropertyValue } from \"../compute/computeRealProperties.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function setupTemplateProxy(\n hostContext: TemplateHostContext,\n ref: string | undefined,\n slots: SlotsConfOfBricks\n) {\n const {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots,\n tplStateStoreId,\n hostBrick,\n } = hostContext;\n\n let asyncComputedProps: AsyncPropertyEntry[] | undefined;\n\n if (ref && reversedProxies) {\n const propertyProxies = reversedProxies.properties.get(ref);\n if (propertyProxies) {\n const getComputedProps = (\n asyncHostProps: AsyncPropertyEntry[]\n ): AsyncPropertyEntry[] => {\n return propertyProxies!\n .map(({ from, to }) => {\n const filtered = asyncHostProps.filter(\n (entry) => entry[0] === from\n );\n if (filtered.length > 0 && to.refProperty) {\n return [\n to.refProperty,\n computePropertyValue(filtered, from),\n true,\n ];\n }\n })\n .filter(Boolean) as [string, Promise<unknown>][];\n };\n\n asyncComputedProps = getComputedProps(asyncHostPropertyEntries);\n }\n\n const slotProxies = reversedProxies.slots.get(ref);\n if (slotProxies && externalSlots) {\n // Use an approach like template-literal's quasis:\n // `quasi0${0}quais1${1}quasi2...`\n // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.\n const quasisMap = new Map<string, BrickConf[][]>();\n\n for (const { from, to } of slotProxies) {\n const insertBricks = externalSlots[from]?.bricks ?? [];\n if (!insertBricks.length) {\n continue;\n }\n const refToSlot = to.refSlot ?? from;\n let expandableSlot = quasisMap.get(refToSlot);\n if (!expandableSlot) {\n expandableSlot = [];\n // The size of quasis should be the existed slotted bricks' size plus one.\n const size = hasOwnProperty(slots, refToSlot)\n ? slots[refToSlot].bricks.length + 1\n : 1;\n for (let i = 0; i < size; i += 1) {\n expandableSlot.push([]);\n }\n quasisMap.set(refToSlot, expandableSlot);\n }\n const refPosition = to.refPosition ?? -1;\n // External bricks of a template, should not access the template internal forEach `ITEM`.\n // For some existing templates who is *USING* this bug, we keep the old behavior.\n const hostHasForEach = hasOwnProperty(\n hostBrick.runtimeContext,\n \"forEachItem\"\n );\n expandableSlot[\n clamp(\n refPosition < 0 ? expandableSlot.length + refPosition : refPosition,\n 0,\n expandableSlot.length - 1\n )\n ].push(\n ...((hostContext.__temporary_tpl_tag_name ===\n \"base-layout-v3.tpl-scroll-load-list\" ||\n hostContext.__temporary_tpl_tag_name ===\n \"shrcb-homepage.tpl-custom-scroll-load-list\") &&\n !hostHasForEach\n ? insertBricks\n : setupTemplateExternalBricks(\n insertBricks,\n hostHasForEach,\n hostBrick.runtimeContext.forEachItem,\n hostBrick.runtimeContext.forEachIndex!,\n hostBrick.runtimeContext.forEachSize!\n ))\n );\n }\n\n for (const [slotName, quasis] of quasisMap.entries()) {\n if (!hasOwnProperty(slots, slotName)) {\n slots[slotName] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n const slotConf = slots[slotName];\n slotConf.bricks = quasis.flatMap((bricks, index) =>\n index < slotConf.bricks.length\n ? bricks.concat(slotConf.bricks[index])\n : bricks\n );\n\n if (slotConf.bricks.length === 0) {\n delete slots[slotName];\n }\n }\n }\n }\n\n return {\n [symbolForAsyncComputedPropsFromHost]: asyncComputedProps,\n [symbolForTplStateStoreId]: tplStateStoreId,\n };\n}\n\n// External bricks of a template, have the same forEachItem context as their host.\nfunction setupTemplateExternalBricks(\n bricks: BrickConf[],\n hasForEach: boolean,\n forEachItem: unknown,\n forEachIndex: number,\n forEachSize: number\n): BrickConf[] {\n return (bricks as RuntimeBrickConfWithTplSymbols[]).map(\n ({\n children,\n slots,\n [symbolForTPlExternalForEachItem]: a,\n [symbolForTPlExternalForEachIndex]: b,\n [symbolForTPlExternalForEachSize]: c,\n [symbolForTPlExternalNoForEach]: d,\n ...brick\n }) => ({\n ...brick,\n ...(hasForEach\n ? {\n [symbolForTPlExternalForEachItem]: forEachItem,\n [symbolForTPlExternalForEachIndex]: forEachIndex,\n [symbolForTPlExternalForEachSize]: forEachSize,\n }\n : {\n [symbolForTPlExternalNoForEach]: true,\n }),\n // Keep `:forEach` bricks as original, since they have their own forEachItem context.\n slots:\n brick.brick === \":forEach\"\n ? childrenToSlots(children, slots)\n : Object.fromEntries(\n Object.entries(childrenToSlots(children, slots) ?? {}).map(\n ([slotName, slotConf]) => [\n slotName,\n slotConf.type === \"routes\"\n ? {\n type: \"routes\",\n routes: setupTemplateExternalRoutes(\n slotConf.routes,\n hasForEach,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n : {\n type: \"bricks\",\n bricks: setupTemplateExternalBricks(\n slotConf.bricks,\n hasForEach,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n },\n ]\n )\n ),\n })\n );\n}\n\nfunction setupTemplateExternalRoutes(\n routes: RouteConf[],\n hasForEach: boolean,\n forEachItem: unknown,\n forEachIndex: number,\n forEachSize: number\n): RouteConf[] {\n return routes.map((route) =>\n route.type === \"routes\"\n ? {\n ...route,\n routes: setupTemplateExternalRoutes(\n route.routes,\n hasForEach,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n : route.type === \"redirect\"\n ? route\n : {\n ...route,\n bricks: setupTemplateExternalBricks(\n route.bricks,\n hasForEach,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n );\n}\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,QAAQ,QAAQ;AAC9B,SACEC,mCAAmC,EACnCC,gCAAgC,EAChCC,+BAA+B,EAC/BC,+BAA+B,EAC/BC,6BAA6B,EAC7BC,wBAAwB,QAEnB,gBAAgB;AAEvB,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,SAASC,eAAe,QAAQ,gBAAgB;AAEhD,OAAO,SAASC,kBAAkBA,CAChCC,WAAgC,EAChCC,GAAuB,EACvBC,KAAwB,EACxB;EACA,MAAM;IACJC,eAAe;IACfC,wBAAwB;IACxBC,aAAa;IACbC,eAAe;IACfC;EACF,CAAC,GAAGP,WAAW;EAEf,IAAIQ,kBAAoD;EAExD,IAAIP,GAAG,IAAIE,eAAe,EAAE;IAC1B,MAAMM,eAAe,GAAGN,eAAe,CAACO,UAAU,CAACC,GAAG,CAACV,GAAG,CAAC;IAC3D,IAAIQ,eAAe,EAAE;MACnB,MAAMG,gBAAgB,GACpBC,cAAoC,IACX;QACzB,OAAOJ,eAAe,CACnB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AErD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAACY,GAAG,CACxDiD,KAAA;QAAA,IAAC,CAAClB,QAAQ,EAAEI,QAAQ,CAAC,GAAAc,KAAA;QAAA,OAAK,CACxBlB,QAAQ,EACRI,QAAQ,CAACD,IAAI,KAAK,QAAQ,GACtB;UACEA,IAAI,EAAE,QAAQ;UACdgB,MAAM,EAAEC,2BAA2B,CACjChB,QAAQ,CAACe,MAAM,EACfX,UAAU,EACVX,WAAW,EACXC,YAAY,EACZC,WACF;QACF,CAAC,GACD;UACEI,IAAI,EAAE,QAAQ;UACdnB,MAAM,EAAEY,2BAA2B,CACjCQ,QAAQ,CAACpB,MAAM,EACfwB,UAAU,EACVX,WAAW,EACXC,YAAY,EACZC,WACF;QACF,CAAC,CACN;MAAA,CACH,CACF;IACR,CAAC;EAAA,CACH,CAAC;AACH;AAEA,SAASqB,2BAA2BA,CAClCD,MAAmB,EACnBX,UAAmB,EACnBX,WAAoB,EACpBC,YAAoB,EACpBC,WAAmB,EACN;EACb,OAAOoB,MAAM,CAAClD,GAAG,CAAEoD,KAAK,IACtBA,KAAK,CAAClB,IAAI,KAAK,QAAQ,GACnB;IACE,GAAGkB,KAAK;IACRF,MAAM,EAAEC,2BAA2B,CACjCC,KAAK,CAACF,MAAM,EACZX,UAAU,EACVX,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CAAC,GACDsB,KAAK,CAAClB,IAAI,KAAK,UAAU,GACvBkB,KAAK,GACL;IACE,GAAGA,KAAK;IACRrC,MAAM,EAAEY,2BAA2B,CACjCyB,KAAK,CAACrC,MAAM,EACZwB,UAAU,EACVX,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CACR,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"setupTemplateProxy.js","names":["hasOwnProperty","clamp","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachSize","symbolForTplStateStoreId","computePropertyValue","childrenToSlots","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostPropertyEntries","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","asyncHostProps","map","_ref","from","to","filtered","filter","entry","length","refProperty","Boolean","slotProxies","quasisMap","Map","_externalSlots$from","insertBricks","bricks","refToSlot","refSlot","expandableSlot","size","i","push","set","refPosition","hostHasForEach","runtimeContext","setupTemplateExternalBricksWithForEach","forEachItem","forEachIndex","forEachSize","slotName","quasis","entries","type","slotConf","flatMap","index","concat","_ref2","children","brick","Object","fromEntries","_ref3","routes","setupTemplateExternalRoutesWithForEach","route"],"sources":["../../../../src/internal/CustomTemplates/setupTemplateProxy.ts"],"sourcesContent":["import type { BrickConf, RouteConf, SlotsConfOfBricks } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { clamp } from \"lodash\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachIndex,\n symbolForTPlExternalForEachItem,\n symbolForTPlExternalForEachSize,\n symbolForTplStateStoreId,\n type RuntimeBrickConfWithTplSymbols,\n} from \"./constants.js\";\nimport type { AsyncPropertyEntry, TemplateHostContext } from \"../interfaces.js\";\nimport { computePropertyValue } from \"../compute/computeRealProperties.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function setupTemplateProxy(\n hostContext: TemplateHostContext,\n ref: string | undefined,\n slots: SlotsConfOfBricks\n) {\n const {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots,\n tplStateStoreId,\n hostBrick,\n } = hostContext;\n\n let asyncComputedProps: AsyncPropertyEntry[] | undefined;\n\n if (ref && reversedProxies) {\n const propertyProxies = reversedProxies.properties.get(ref);\n if (propertyProxies) {\n const getComputedProps = (\n asyncHostProps: AsyncPropertyEntry[]\n ): AsyncPropertyEntry[] => {\n return propertyProxies!\n .map(({ from, to }) => {\n const filtered = asyncHostProps.filter(\n (entry) => entry[0] === from\n );\n if (filtered.length > 0 && to.refProperty) {\n return [\n to.refProperty,\n computePropertyValue(filtered, from),\n true,\n ];\n }\n })\n .filter(Boolean) as [string, Promise<unknown>][];\n };\n\n asyncComputedProps = getComputedProps(asyncHostPropertyEntries);\n }\n\n const slotProxies = reversedProxies.slots.get(ref);\n if (slotProxies && externalSlots) {\n // Use an approach like template-literal's quasis:\n // `quasi0${0}quais1${1}quasi2...`\n // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.\n const quasisMap = new Map<string, BrickConf[][]>();\n\n for (const { from, to } of slotProxies) {\n const insertBricks = externalSlots[from]?.bricks ?? [];\n if (!insertBricks.length) {\n continue;\n }\n const refToSlot = to.refSlot ?? from;\n let expandableSlot = quasisMap.get(refToSlot);\n if (!expandableSlot) {\n expandableSlot = [];\n // The size of quasis should be the existed slotted bricks' size plus one.\n const size = hasOwnProperty(slots, refToSlot)\n ? slots[refToSlot].bricks.length + 1\n : 1;\n for (let i = 0; i < size; i += 1) {\n expandableSlot.push([]);\n }\n quasisMap.set(refToSlot, expandableSlot);\n }\n const refPosition = to.refPosition ?? -1;\n // External bricks of a template, should not access the template internal forEach `ITEM`.\n // For some existing templates who is *USING* this bug, we keep the old behavior.\n const hostHasForEach = hasOwnProperty(\n hostBrick.runtimeContext,\n \"forEachItem\"\n );\n expandableSlot[\n clamp(\n refPosition < 0 ? expandableSlot.length + refPosition : refPosition,\n 0,\n expandableSlot.length - 1\n )\n ].push(\n ...(!hostHasForEach\n ? insertBricks\n : setupTemplateExternalBricksWithForEach(\n insertBricks,\n hostBrick.runtimeContext.forEachItem,\n hostBrick.runtimeContext.forEachIndex!,\n hostBrick.runtimeContext.forEachSize!\n ))\n );\n }\n\n for (const [slotName, quasis] of quasisMap.entries()) {\n if (!hasOwnProperty(slots, slotName)) {\n slots[slotName] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n const slotConf = slots[slotName];\n slotConf.bricks = quasis.flatMap((bricks, index) =>\n index < slotConf.bricks.length\n ? bricks.concat(slotConf.bricks[index])\n : bricks\n );\n\n if (slotConf.bricks.length === 0) {\n delete slots[slotName];\n }\n }\n }\n }\n\n return {\n [symbolForAsyncComputedPropsFromHost]: asyncComputedProps,\n [symbolForTplStateStoreId]: tplStateStoreId,\n };\n}\n\n// External bricks of a template, have the same forEachItem context as their host.\nfunction setupTemplateExternalBricksWithForEach(\n bricks: BrickConf[],\n forEachItem: unknown,\n forEachIndex: number,\n forEachSize: number\n): BrickConf[] {\n return (bricks as RuntimeBrickConfWithTplSymbols[]).map(\n ({ children, slots, ...brick }) => ({\n ...brick,\n [symbolForTPlExternalForEachItem]: forEachItem,\n [symbolForTPlExternalForEachIndex]: forEachIndex,\n [symbolForTPlExternalForEachSize]: forEachSize,\n // Keep `:forEach` bricks as original, since they have their own forEachItem context.\n slots:\n brick.brick === \":forEach\"\n ? childrenToSlots(children, slots)\n : Object.fromEntries(\n Object.entries(childrenToSlots(children, slots) ?? {}).map(\n ([slotName, slotConf]) => [\n slotName,\n slotConf.type === \"routes\"\n ? {\n type: \"routes\",\n routes: setupTemplateExternalRoutesWithForEach(\n slotConf.routes,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n : {\n type: \"bricks\",\n bricks: setupTemplateExternalBricksWithForEach(\n slotConf.bricks,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n },\n ]\n )\n ),\n })\n );\n}\n\nfunction setupTemplateExternalRoutesWithForEach(\n routes: RouteConf[],\n forEachItem: unknown,\n forEachIndex: number,\n forEachSize: number\n): RouteConf[] {\n return routes.map((route) =>\n route.type === \"routes\"\n ? {\n ...route,\n routes: setupTemplateExternalRoutesWithForEach(\n route.routes,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n : route.type === \"redirect\"\n ? route\n : {\n ...route,\n bricks: setupTemplateExternalBricksWithForEach(\n route.bricks,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n );\n}\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,QAAQ,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CACR,CAAC;AACH","ignoreList":[]}
@@ -9,7 +9,7 @@ import { resolveData } from "./data/resolveData.js";
9
9
  import { asyncComputeRealValue } from "./compute/computeRealValue.js";
10
10
  import { listenOnTrackingContext } from "./compute/listenOnTrackingContext.js";
11
11
  import { matchRoute, matchRoutes } from "./matchRoutes.js";
12
- import { symbolForAsyncComputedPropsFromHost, symbolForTPlExternalForEachIndex, symbolForTPlExternalForEachItem, symbolForTPlExternalForEachSize, symbolForTPlExternalNoForEach, symbolForTplStateStoreId } from "./CustomTemplates/constants.js";
12
+ import { symbolForAsyncComputedPropsFromHost, symbolForTPlExternalForEachIndex, symbolForTPlExternalForEachItem, symbolForTPlExternalForEachSize, symbolForTplStateStoreId } from "./CustomTemplates/constants.js";
13
13
  import { expandCustomTemplate } from "./CustomTemplates/expandCustomTemplate.js";
14
14
  import { getTagNameOfCustomTemplate, getTplStateStore } from "./CustomTemplates/utils.js";
15
15
  import { customTemplates } from "../CustomTemplates.js";
@@ -204,10 +204,6 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
204
204
  runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];
205
205
  runtimeContext.forEachIndex = brickConf[symbolForTPlExternalForEachIndex];
206
206
  runtimeContext.forEachSize = brickConf[symbolForTPlExternalForEachSize];
207
- } else if (brickConf[symbolForTPlExternalNoForEach]) {
208
- delete runtimeContext.forEachItem;
209
- delete runtimeContext.forEachIndex;
210
- delete runtimeContext.forEachSize;
211
207
  }
212
208
  const {
213
209
  context
@@ -369,10 +365,14 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
369
365
  let formData;
370
366
  let confProps;
371
367
  if (brickName === FORM_RENDERER) {
368
+ var _brickConf$properties;
372
369
  ({
373
370
  formData,
374
371
  ...confProps
375
372
  } = brickConf.properties ?? {});
373
+ if ((_brickConf$properties = brickConf.properties) !== null && _brickConf$properties !== void 0 && _brickConf$properties.compute) {
374
+ formData = await asyncComputeRealValue(formData, runtimeContext);
375
+ }
376
376
  } else {
377
377
  confProps = brickConf.properties;
378
378
  }