@next-core/runtime 1.17.1 → 1.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.js","names":["_cook","require","_loader","_supply","_general","_storyboard","_lodash","_CustomProcessors","_StoryboardFunctions","_getGeneralGlobals","_proxyFactories","_devtools","_mediaQuery","_getStorageItem","_Runtime","_utils","_WidgetFunctions","_WidgetI18n","_hasInstalledApp","_isStrictMode","_utils2","_resolveData","_computeRealValue","symbolForRaw","Symbol","for","symbolForContext","isPreEvaluated","raw","getPreEvaluatedRaw","pre","shouldDismissMarkingComputed","shouldAllowRecursiveEvaluations","possibleErrorConstructs","WeakSet","SyntaxError","TypeError","ReferenceError","getCookErrorConstructor","error","has","constructor","asyncEvaluate","runtimeContext","options","blockingList","run","lowLevelEvaluate","Promise","all","evaluate","isAsync","passByRuntimeContext","omit","menuUsage","usedArgs","Set","hasAppUsage","precooked","preevaluate","withParent","hooks","beforeVisitGlobal","node","parent","collectAppGetMenuUsage","collectInstalledAppsHasUsage","message","errorConstructor","hasNonStaticUsage","Error","globalVariables","attemptToVisitGlobals","lazy","hasOwnProperty","Object","keys","length","usedCtx","usedProcessors","usedStates","tplStateStore","strict","isStrictMode","getTplStateStore","usedFormStates","formStateStore","getFormStateStore","devHook","getDevHook","strictCollectMemberUsage","push","ctxStore","waitFor","usedTpls","tpl","add","loadProcessorsImperatively","getBrickPackages","attemptToCheckPermissions","usedFunctions","checkPermissionsUsage","pendingPermissionsPreCheck","size","menu","usedMenuIds","map","menuId","fetchMenuById","getStoryboardByAppId","_internalApiGetStoryboardInBootstrapData","resolveData","asyncComputeRealValue","_hooks$checkInstalled","checkInstalledApps","waitForCheckingApps","_runtimeContext$overr","_hooks$menu","_match$params","_hooks$images","app","currentApp","location","query","match","flags","sys","data","event","overrideApp","variableName","hash","substring","cloneDeep","getMenu","getMenuById","getDynamicReadOnlyProxy","get","target","key","getValue","ownKeys","Array","from","getReadOnlyProxy","hasInstalledApp","console","forEachItem","getItem","getStorageItem","getMedia","getRuntime","getMiscSettings","URLSearchParams","params","pathname","pkg","customProcessors","t","k","fromEntries","getAll","warnAboutStrictMode","widgetFunctions","images","widgetImagesFactory","widgetI18nFactory","assign","getGeneralGlobals","storyboardFunctions","appendI18nNamespace","result","cook","expression","source","supply"],"sources":["../../../../src/internal/compute/evaluate.ts"],"sourcesContent":["import {\n cook,\n preevaluate,\n PreevaluateResult,\n shouldAllowRecursiveEvaluations,\n} from \"@next-core/cook\";\nimport { loadProcessorsImperatively } from \"@next-core/loader\";\nimport { supply } from \"@next-core/supply\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport {\n strictCollectMemberUsage,\n collectAppGetMenuUsage,\n collectInstalledAppsHasUsage,\n MemberCallUsage,\n} from \"@next-core/utils/storyboard\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { cloneDeep, omit } from \"lodash\";\nimport { customProcessors } from \"../../CustomProcessors.js\";\nimport {\n checkPermissionsUsage,\n storyboardFunctions,\n} from \"./StoryboardFunctions.js\";\nimport { getGeneralGlobals } from \"./getGeneralGlobals.js\";\nimport {\n getDynamicReadOnlyProxy,\n getReadOnlyProxy,\n} from \"../proxyFactories.js\";\nimport { getDevHook } from \"../devtools.js\";\nimport { getMedia } from \"../mediaQuery.js\";\nimport { getStorageItem } from \"./getStorageItem.js\";\nimport {\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n getRuntime,\n hooks,\n} from \"../Runtime.js\";\nimport type { DataStore } from \"../data/DataStore.js\";\nimport { getTplStateStore } from \"../CustomTemplates/utils.js\";\nimport { widgetFunctions } from \"./WidgetFunctions.js\";\nimport { widgetI18nFactory } from \"./WidgetI18n.js\";\nimport { hasInstalledApp } from \"../hasInstalledApp.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../../isStrictMode.js\";\nimport { getFormStateStore } from \"../FormRenderer/utils.js\";\nimport { resolveData } from \"../data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./computeRealValue.js\";\n\nconst symbolForRaw = Symbol.for(\"pre.evaluated.raw\");\nconst symbolForContext = Symbol.for(\"pre.evaluated.context\");\n\nexport interface PreEvaluated {\n [symbolForRaw]: string;\n [symbolForContext]: RuntimeContext;\n}\n\nexport interface EvaluateOptions {\n lazy?: boolean;\n isReEvaluation?: boolean;\n evaluationId?: number;\n}\n\nexport function isPreEvaluated(raw: unknown): raw is PreEvaluated {\n return !!(raw as PreEvaluated)?.[symbolForRaw];\n}\n\nexport function getPreEvaluatedRaw(pre: PreEvaluated): string {\n return pre[symbolForRaw];\n}\n\nexport function shouldDismissMarkingComputed(\n raw: string | PreEvaluated\n): boolean {\n if (typeof raw === \"string\") {\n return shouldAllowRecursiveEvaluations(raw);\n }\n return shouldAllowRecursiveEvaluations(raw[symbolForRaw]);\n}\n\nconst possibleErrorConstructs = new WeakSet<ErrorConstructor>([\n SyntaxError,\n TypeError,\n ReferenceError,\n]);\n\nexport function getCookErrorConstructor(error: any): ErrorConstructor {\n return possibleErrorConstructs.has(error.constructor)\n ? error.constructor\n : TypeError;\n}\n\nexport async function asyncEvaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options?: EvaluateOptions\n): Promise<unknown> {\n const { blockingList, run } = lowLevelEvaluate(\n raw,\n runtimeContext,\n options,\n true\n );\n await Promise.all(blockingList);\n return run();\n}\n\nexport function evaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options?: EvaluateOptions\n): Promise<unknown> {\n const { run } = lowLevelEvaluate(raw, runtimeContext, options, false);\n return run();\n}\n\nfunction lowLevelEvaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options: EvaluateOptions = {},\n isAsync?: boolean\n): {\n blockingList: (Promise<unknown> | undefined)[];\n run: Function;\n} {\n const blockingList: (Promise<unknown> | undefined)[] = [];\n if (typeof raw !== \"string\") {\n // If the `raw` is not a string, it must be a pre-evaluated object.\n // Then fulfil the context, and restore the original `raw`.\n\n const passByRuntimeContext = omit(runtimeContext, [\n \"pendingPermissionsPreCheck\",\n \"tplStateStoreMap\",\n \"tplStateStoreScope\",\n \"formStateStoreMap\",\n \"formStateStoreScope\",\n ]);\n\n runtimeContext = {\n ...raw[symbolForContext],\n ...passByRuntimeContext,\n };\n raw = raw[symbolForRaw];\n }\n\n // Collect `APP.getMenu(...)` usage before evaluating.\n const menuUsage: MemberCallUsage = {\n usedArgs: new Set(),\n };\n const hasAppUsage: MemberCallUsage = {\n usedArgs: new Set(),\n };\n\n // A `SyntaxError` maybe thrown.\n let precooked: PreevaluateResult;\n try {\n precooked = preevaluate(raw, {\n withParent: true,\n hooks: {\n beforeVisitGlobal(node, parent) {\n collectAppGetMenuUsage(menuUsage, node, parent!);\n collectInstalledAppsHasUsage(hasAppUsage, node, parent!);\n },\n },\n });\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n // if (options.isReEvaluation) {\n // devtoolsHookEmit(\"re-evaluation\", {\n // id: options.evaluationId,\n // detail: { raw, context: {} },\n // error: message,\n // });\n // return;\n // } else {\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n // }\n }\n\n if (menuUsage.hasNonStaticUsage) {\n throw new Error(\n `Non-static usage of \"APP.getMenu\" is prohibited in v3, check your expression: \"${raw}\"`\n );\n }\n\n if (hasAppUsage.hasNonStaticUsage) {\n throw new Error(\n `Non-static usage of \"INSTALLED_APPS.has\" is prohibited in v3, check your expression: \"${raw}\"`\n );\n }\n\n const globalVariables: Record<string, unknown> = {};\n const { attemptToVisitGlobals } = precooked;\n\n // Ignore evaluating if required `event/DATA` is missing in\n // context. Since they are are provided in different context, whenever\n // missing one of them, memorize the current context for later consuming.\n if (\n options.lazy ||\n (attemptToVisitGlobals.has(\"EVENT\") &&\n !hasOwnProperty(runtimeContext, \"event\")) ||\n (attemptToVisitGlobals.has(\"DATA\") &&\n !hasOwnProperty(runtimeContext, \"data\"))\n ) {\n return {\n blockingList,\n run() {\n return Object.keys(runtimeContext).length > 0\n ? ({\n [symbolForRaw]: raw,\n [symbolForContext]: runtimeContext,\n } as PreEvaluated)\n : raw;\n },\n };\n }\n\n let usedCtx: Set<string>;\n let usedProcessors: Set<string>;\n let usedStates: Set<string>;\n let tplStateStore: DataStore<\"STATE\"> | undefined;\n const strict = isStrictMode(runtimeContext);\n\n // For existed TPL usage, treat it as a STATE.\n if (\n attemptToVisitGlobals.has(\"STATE\") ||\n (!strict && attemptToVisitGlobals.has(\"TPL\"))\n ) {\n tplStateStore = getTplStateStore(runtimeContext, \"STATE\", `: \"${raw}\"`);\n }\n\n let usedFormStates: Set<string>;\n let formStateStore: DataStore<\"FORM_STATE\"> | undefined;\n if (attemptToVisitGlobals.has(\"FORM_STATE\")) {\n formStateStore = getFormStateStore(\n runtimeContext,\n \"FORM_STATE\",\n `: \"${raw}\"`\n );\n }\n\n const devHook = getDevHook();\n if (isAsync || devHook) {\n if (attemptToVisitGlobals.has(\"CTX\")) {\n usedCtx = strictCollectMemberUsage(raw, \"CTX\");\n isAsync && blockingList.push(runtimeContext.ctxStore.waitFor(usedCtx));\n }\n\n if (tplStateStore) {\n usedStates = strictCollectMemberUsage(raw, \"STATE\");\n // istanbul ignore if\n if (!strict) {\n const usedTpls = strictCollectMemberUsage(raw, \"TPL\");\n for (const tpl of usedTpls) {\n usedStates.add(tpl);\n }\n }\n isAsync && blockingList.push(tplStateStore.waitFor(usedStates));\n }\n\n if (formStateStore) {\n usedFormStates = strictCollectMemberUsage(raw, \"FORM_STATE\");\n isAsync && blockingList.push(formStateStore.waitFor(usedFormStates));\n }\n\n if (attemptToVisitGlobals.has(\"PROCESSORS\")) {\n usedProcessors = strictCollectMemberUsage(raw, \"PROCESSORS\", 2);\n isAsync &&\n blockingList.push(\n loadProcessorsImperatively(usedProcessors, getBrickPackages())\n );\n }\n }\n\n if (isAsync) {\n let attemptToCheckPermissions = attemptToVisitGlobals.has(\"PERMISSIONS\");\n // There maybe `PERMISSIONS.check()` usage in functions\n if (!attemptToCheckPermissions && attemptToVisitGlobals.has(\"FN\")) {\n const usedFunctions = [...strictCollectMemberUsage(raw, \"FN\")];\n attemptToCheckPermissions = checkPermissionsUsage(usedFunctions);\n }\n\n if (attemptToCheckPermissions) {\n blockingList.push(...runtimeContext.pendingPermissionsPreCheck);\n }\n\n if (menuUsage.usedArgs.size > 0 && hooks?.menu) {\n // Block evaluating if has `APP.getMenu(...)` usage.\n const usedMenuIds = [...menuUsage.usedArgs];\n blockingList.push(\n Promise.all(\n usedMenuIds.map((menuId) =>\n hooks!.menu!.fetchMenuById(menuId, runtimeContext, {\n getStoryboardByAppId: _internalApiGetStoryboardInBootstrapData,\n resolveData,\n asyncComputeRealValue,\n })\n )\n )\n );\n }\n\n if (hasAppUsage.usedArgs.size > 0) {\n // Only wait for specific apps\n blockingList.push(\n hooks?.checkInstalledApps?.waitForCheckingApps([\n ...hasAppUsage.usedArgs,\n ])\n );\n }\n }\n\n return {\n blockingList,\n run() {\n const {\n app: currentApp,\n location,\n query,\n match,\n flags,\n sys,\n ctxStore,\n data,\n event,\n } = runtimeContext;\n const app = runtimeContext.overrideApp ?? currentApp;\n\n for (const variableName of attemptToVisitGlobals) {\n switch (variableName) {\n // case \"ALIAS\":\n case \"ANCHOR\":\n globalVariables[variableName] = location.hash\n ? location.hash.substring(1)\n : null;\n break;\n case \"APP\":\n globalVariables[variableName] = {\n ...cloneDeep(app),\n getMenu: hooks?.menu?.getMenuById,\n };\n break;\n case \"CTX\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n return ctxStore.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedCtx);\n },\n });\n break;\n case \"DATA\":\n globalVariables[variableName] = data;\n break;\n case \"EVENT\":\n globalVariables[variableName] = event;\n break;\n case \"FLAGS\":\n globalVariables[variableName] = getReadOnlyProxy(flags);\n break;\n case \"FORM_STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n return formStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedFormStates);\n },\n });\n break;\n case \"HASH\":\n globalVariables[variableName] = location.hash;\n break;\n case \"INSTALLED_APPS\":\n globalVariables[variableName] = getReadOnlyProxy({\n has: hasInstalledApp,\n });\n break;\n case \"ITEM\":\n if (!hasOwnProperty(runtimeContext, \"forEachItem\")) {\n // eslint-disable-next-line no-console\n console.error(\n `Using \\`ITEM\\` but no \\`:forEach\\` is found, check your expression: \"${raw}\"`\n );\n } else {\n globalVariables[variableName] = runtimeContext.forEachItem;\n }\n break;\n case \"LOCAL_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"local\"),\n });\n break;\n case \"MEDIA\":\n globalVariables[variableName] = getReadOnlyProxy(getMedia());\n break;\n case \"MISC\":\n globalVariables[variableName] = getRuntime().getMiscSettings();\n break;\n case \"PARAMS\":\n globalVariables[variableName] = new URLSearchParams(query);\n break;\n case \"PATH\":\n globalVariables[variableName] = getReadOnlyProxy(\n match?.params ?? {}\n );\n break;\n case \"PATH_NAME\":\n globalVariables[variableName] = location.pathname;\n break;\n case \"PROCESSORS\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n const pkg = customProcessors.get(key as string);\n if (!pkg) {\n throw new Error(\n `'PROCESSORS.${\n key as string\n }' is not registered! Have you installed the relevant brick package?`\n );\n }\n return getDynamicReadOnlyProxy({\n get(t, k) {\n return pkg.get(k as string);\n },\n ownKeys() {\n return Array.from(pkg.keys());\n },\n });\n },\n ownKeys() {\n return Array.from(usedProcessors);\n },\n });\n break;\n case \"QUERY\":\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.get(key)])\n );\n break;\n case \"QUERY_ARRAY\":\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.getAll(key)])\n );\n // case \"SEGUE\":\n break;\n case \"SESSION_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"session\"),\n });\n break;\n // istanbul ignore next\n case \"TPL\":\n warnAboutStrictMode(\n strict,\n 'Using \"TPL\" in expression',\n `check your expression: \"${raw}\"`\n );\n if (strict) {\n break;\n }\n // eslint-disable-next-line no-fallthrough\n case \"STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n return tplStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedStates);\n },\n });\n break;\n case \"SYS\":\n globalVariables[variableName] = getReadOnlyProxy(sys ?? {});\n break;\n case \"__WIDGET_FN__\":\n globalVariables[variableName] = widgetFunctions;\n break;\n case \"__WIDGET_IMG__\":\n globalVariables[variableName] = hooks?.images?.widgetImagesFactory;\n break;\n case \"__WIDGET_I18N__\":\n globalVariables[variableName] = widgetI18nFactory;\n break;\n }\n }\n\n Object.assign(\n globalVariables,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n storyboardFunctions,\n app: runtimeContext.app,\n appendI18nNamespace: runtimeContext.appendI18nNamespace,\n })\n );\n\n try {\n const result = cook(precooked.expression, precooked.source, {\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n globalVariables\n ),\n });\n // const detail = { raw, context: globalVariables, result };\n // if (options.isReEvaluation) {\n // devtoolsHookEmit(\"re-evaluation\", {\n // id: options.evaluationId,\n // detail,\n // });\n // } else {\n // devtoolsHookEmit(\"evaluation\", detail);\n // }\n return result;\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n // if (options.isReEvaluation) {\n // devtoolsHookEmit(\"re-evaluation\", {\n // id: options.evaluationId,\n // detail: { raw, context: globalVariables },\n // error: message,\n // });\n // } else {\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n // }\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OA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mB;QACnBjD,GAAG,EAAE7E,cAAc,CAAC6E,GAAG;QACvBkD,mBAAmB,EAAE/H,cAAc,CAAC+H;MACtC,CAAC,CACH,CAAC;MAED,IAAI;QACF,MAAMC,MAAM,GAAG,IAAAC,UAAI,EAAClH,SAAS,CAACmH,UAAU,EAAEnH,SAAS,CAACoH,MAAM,EAAE;UAC1DvG,eAAe,EAAE,IAAAwG,cAAM,EACrBrH,SAAS,CAACc,qBAAqB,EAC/BD,eACF;QACF,CAAC,CAAC;QACF;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,OAAOoG,MAAM;MACf,CAAC,CAAC,OAAOpI,KAAU,EAAE;QACnB,MAAM4B,OAAO,GAAI,GAAE5B,KAAK,CAAC4B,OAAQ,SAAQvC,GAAI,GAAE;QAC/C;QACA;QACA;QACA;QACA;QACA;QACA;QACA,MAAMwC,gBAAgB,GAAG9B,uBAAuB,CAACC,KAAK,CAAC;QACvD,MAAM,IAAI6B,gBAAgB,CAACD,OAAO,CAAC;QACnC;MACF;IACF;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"evaluate.js","names":["_cook","require","_loader","_supply","_general","_storyboard","_lodash","_CustomProcessors","_StoryboardFunctions","_getGeneralGlobals","_proxyFactories","_devtools","_mediaQuery","_getStorageItem","_Runtime","_utils","_WidgetFunctions","_WidgetI18n","_hasInstalledApp","_isStrictMode","_utils2","_resolveData","_computeRealValue","symbolForRaw","Symbol","for","symbolForContext","isPreEvaluated","raw","getPreEvaluatedRaw","pre","shouldDismissMarkingComputed","shouldAllowRecursiveEvaluations","possibleErrorConstructs","WeakSet","SyntaxError","TypeError","ReferenceError","getCookErrorConstructor","error","has","constructor","asyncEvaluate","runtimeContext","options","blockingList","run","lowLevelEvaluate","Promise","all","evaluate","isAsync","passByRuntimeContext","omit","menuUsage","usedArgs","Set","hasAppUsage","precooked","preevaluate","withParent","hooks","beforeVisitGlobal","node","parent","collectAppGetMenuUsage","collectInstalledAppsHasUsage","message","errorConstructor","hasNonStaticUsage","Error","globalVariables","attemptToVisitGlobals","lazy","hasOwnProperty","Object","keys","length","usedCtx","usedProcessors","usedStates","tplStateStore","strict","isStrictMode","getTplStateStore","usedFormStates","formStateStore","getFormStateStore","devHook","getDevHook","strictCollectMemberUsage","push","ctxStore","waitFor","usedTpls","tpl","add","loadProcessorsImperatively","getBrickPackages","attemptToCheckPermissions","usedFunctions","checkPermissionsUsage","pendingPermissionsPreCheck","size","menu","usedMenuIds","map","menuId","fetchMenuById","getStoryboardByAppId","_internalApiGetStoryboardInBootstrapData","resolveData","asyncComputeRealValue","_hooks$checkInstalled","checkInstalledApps","waitForCheckingApps","_runtimeContext$overr","_hooks$menu","_match$params","_hooks$images","app","currentApp","location","query","match","flags","sys","data","event","overrideApp","variableName","hash","substring","cloneDeep","getMenu","getMenuById","getDynamicReadOnlyProxy","get","target","key","getValue","ownKeys","Array","from","getReadOnlyProxy","hasInstalledApp","console","forEachItem","getItem","getStorageItem","getMedia","getRuntime","getMiscSettings","URLSearchParams","params","pathname","pkg","customProcessors","t","k","fromEntries","getAll","warnAboutStrictMode","widgetFunctions","images","widgetImagesFactory","widgetI18nFactory","assign","getGeneralGlobals","storyboardFunctions","appendI18nNamespace","result","cook","expression","source","supply","detail","context","devtoolsHookEmit"],"sources":["../../../../src/internal/compute/evaluate.ts"],"sourcesContent":["import {\n cook,\n preevaluate,\n PreevaluateResult,\n shouldAllowRecursiveEvaluations,\n} from \"@next-core/cook\";\nimport { loadProcessorsImperatively } from \"@next-core/loader\";\nimport { supply } from \"@next-core/supply\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport {\n strictCollectMemberUsage,\n collectAppGetMenuUsage,\n collectInstalledAppsHasUsage,\n MemberCallUsage,\n} from \"@next-core/utils/storyboard\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { cloneDeep, omit } from \"lodash\";\nimport { customProcessors } from \"../../CustomProcessors.js\";\nimport {\n checkPermissionsUsage,\n storyboardFunctions,\n} from \"./StoryboardFunctions.js\";\nimport { getGeneralGlobals } from \"./getGeneralGlobals.js\";\nimport {\n getDynamicReadOnlyProxy,\n getReadOnlyProxy,\n} from \"../proxyFactories.js\";\nimport { devtoolsHookEmit, getDevHook } from \"../devtools.js\";\nimport { getMedia } from \"../mediaQuery.js\";\nimport { getStorageItem } from \"./getStorageItem.js\";\nimport {\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n getRuntime,\n hooks,\n} from \"../Runtime.js\";\nimport type { DataStore } from \"../data/DataStore.js\";\nimport { getTplStateStore } from \"../CustomTemplates/utils.js\";\nimport { widgetFunctions } from \"./WidgetFunctions.js\";\nimport { widgetI18nFactory } from \"./WidgetI18n.js\";\nimport { hasInstalledApp } from \"../hasInstalledApp.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../../isStrictMode.js\";\nimport { getFormStateStore } from \"../FormRenderer/utils.js\";\nimport { resolveData } from \"../data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./computeRealValue.js\";\n\nconst symbolForRaw = Symbol.for(\"pre.evaluated.raw\");\nconst symbolForContext = Symbol.for(\"pre.evaluated.context\");\n\nexport interface PreEvaluated {\n [symbolForRaw]: string;\n [symbolForContext]: RuntimeContext;\n}\n\nexport interface EvaluateOptions {\n lazy?: boolean;\n evaluationId?: number;\n}\n\nexport function isPreEvaluated(raw: unknown): raw is PreEvaluated {\n return !!(raw as PreEvaluated)?.[symbolForRaw];\n}\n\nexport function getPreEvaluatedRaw(pre: PreEvaluated): string {\n return pre[symbolForRaw];\n}\n\nexport function shouldDismissMarkingComputed(\n raw: string | PreEvaluated\n): boolean {\n if (typeof raw === \"string\") {\n return shouldAllowRecursiveEvaluations(raw);\n }\n return shouldAllowRecursiveEvaluations(raw[symbolForRaw]);\n}\n\nconst possibleErrorConstructs = new WeakSet<ErrorConstructor>([\n SyntaxError,\n TypeError,\n ReferenceError,\n]);\n\nexport function getCookErrorConstructor(error: any): ErrorConstructor {\n return possibleErrorConstructs.has(error.constructor)\n ? error.constructor\n : TypeError;\n}\n\nexport async function asyncEvaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options?: EvaluateOptions\n): Promise<unknown> {\n const { blockingList, run } = lowLevelEvaluate(\n raw,\n runtimeContext,\n options,\n true\n );\n await Promise.all(blockingList);\n return run();\n}\n\nexport function evaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options?: EvaluateOptions\n): Promise<unknown> {\n const { run } = lowLevelEvaluate(raw, runtimeContext, options, false);\n return run();\n}\n\nfunction lowLevelEvaluate(\n raw: string | PreEvaluated, // string or pre-evaluated object.\n runtimeContext: RuntimeContext,\n options: EvaluateOptions = {},\n isAsync?: boolean\n): {\n blockingList: (Promise<unknown> | undefined)[];\n run: Function;\n} {\n const blockingList: (Promise<unknown> | undefined)[] = [];\n if (typeof raw !== \"string\") {\n // If the `raw` is not a string, it must be a pre-evaluated object.\n // Then fulfil the context, and restore the original `raw`.\n\n const passByRuntimeContext = omit(runtimeContext, [\n \"pendingPermissionsPreCheck\",\n \"tplStateStoreMap\",\n \"tplStateStoreScope\",\n \"formStateStoreMap\",\n \"formStateStoreScope\",\n ]);\n\n runtimeContext = {\n ...raw[symbolForContext],\n ...passByRuntimeContext,\n };\n raw = raw[symbolForRaw];\n }\n\n // Collect `APP.getMenu(...)` usage before evaluating.\n const menuUsage: MemberCallUsage = {\n usedArgs: new Set(),\n };\n const hasAppUsage: MemberCallUsage = {\n usedArgs: new Set(),\n };\n\n // A `SyntaxError` maybe thrown.\n let precooked: PreevaluateResult;\n try {\n precooked = preevaluate(raw, {\n withParent: true,\n hooks: {\n beforeVisitGlobal(node, parent) {\n collectAppGetMenuUsage(menuUsage, node, parent!);\n collectInstalledAppsHasUsage(hasAppUsage, node, parent!);\n },\n },\n });\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n }\n\n if (menuUsage.hasNonStaticUsage) {\n throw new Error(\n `Non-static usage of \"APP.getMenu\" is prohibited in v3, check your expression: \"${raw}\"`\n );\n }\n\n if (hasAppUsage.hasNonStaticUsage) {\n throw new Error(\n `Non-static usage of \"INSTALLED_APPS.has\" is prohibited in v3, check your expression: \"${raw}\"`\n );\n }\n\n const globalVariables: Record<string, unknown> = {};\n const { attemptToVisitGlobals } = precooked;\n\n // Ignore evaluating if required `event/DATA` is missing in\n // context. Since they are are provided in different context, whenever\n // missing one of them, memorize the current context for later consuming.\n if (\n options.lazy ||\n (attemptToVisitGlobals.has(\"EVENT\") &&\n !hasOwnProperty(runtimeContext, \"event\")) ||\n (attemptToVisitGlobals.has(\"DATA\") &&\n !hasOwnProperty(runtimeContext, \"data\"))\n ) {\n return {\n blockingList,\n run() {\n return Object.keys(runtimeContext).length > 0\n ? ({\n [symbolForRaw]: raw,\n [symbolForContext]: runtimeContext,\n } as PreEvaluated)\n : raw;\n },\n };\n }\n\n let usedCtx: Set<string>;\n let usedProcessors: Set<string>;\n let usedStates: Set<string>;\n let tplStateStore: DataStore<\"STATE\"> | undefined;\n const strict = isStrictMode(runtimeContext);\n\n // For existed TPL usage, treat it as a STATE.\n if (\n attemptToVisitGlobals.has(\"STATE\") ||\n (!strict && attemptToVisitGlobals.has(\"TPL\"))\n ) {\n tplStateStore = getTplStateStore(runtimeContext, \"STATE\", `: \"${raw}\"`);\n }\n\n let usedFormStates: Set<string>;\n let formStateStore: DataStore<\"FORM_STATE\"> | undefined;\n if (attemptToVisitGlobals.has(\"FORM_STATE\")) {\n formStateStore = getFormStateStore(\n runtimeContext,\n \"FORM_STATE\",\n `: \"${raw}\"`\n );\n }\n\n const devHook = getDevHook();\n if (isAsync || devHook) {\n if (attemptToVisitGlobals.has(\"CTX\")) {\n usedCtx = strictCollectMemberUsage(raw, \"CTX\");\n isAsync && blockingList.push(runtimeContext.ctxStore.waitFor(usedCtx));\n }\n\n if (tplStateStore) {\n usedStates = strictCollectMemberUsage(raw, \"STATE\");\n // istanbul ignore if\n if (!strict) {\n const usedTpls = strictCollectMemberUsage(raw, \"TPL\");\n for (const tpl of usedTpls) {\n usedStates.add(tpl);\n }\n }\n isAsync && blockingList.push(tplStateStore.waitFor(usedStates));\n }\n\n if (formStateStore) {\n usedFormStates = strictCollectMemberUsage(raw, \"FORM_STATE\");\n isAsync && blockingList.push(formStateStore.waitFor(usedFormStates));\n }\n\n if (attemptToVisitGlobals.has(\"PROCESSORS\")) {\n usedProcessors = strictCollectMemberUsage(raw, \"PROCESSORS\", 2);\n isAsync &&\n blockingList.push(\n loadProcessorsImperatively(usedProcessors, getBrickPackages())\n );\n }\n }\n\n if (isAsync) {\n let attemptToCheckPermissions = attemptToVisitGlobals.has(\"PERMISSIONS\");\n // There maybe `PERMISSIONS.check()` usage in functions\n if (!attemptToCheckPermissions && attemptToVisitGlobals.has(\"FN\")) {\n const usedFunctions = [...strictCollectMemberUsage(raw, \"FN\")];\n attemptToCheckPermissions = checkPermissionsUsage(usedFunctions);\n }\n\n if (attemptToCheckPermissions) {\n blockingList.push(...runtimeContext.pendingPermissionsPreCheck);\n }\n\n if (menuUsage.usedArgs.size > 0 && hooks?.menu) {\n // Block evaluating if has `APP.getMenu(...)` usage.\n const usedMenuIds = [...menuUsage.usedArgs];\n blockingList.push(\n Promise.all(\n usedMenuIds.map((menuId) =>\n hooks!.menu!.fetchMenuById(menuId, runtimeContext, {\n getStoryboardByAppId: _internalApiGetStoryboardInBootstrapData,\n resolveData,\n asyncComputeRealValue,\n })\n )\n )\n );\n }\n\n if (hasAppUsage.usedArgs.size > 0) {\n // Only wait for specific apps\n blockingList.push(\n hooks?.checkInstalledApps?.waitForCheckingApps([\n ...hasAppUsage.usedArgs,\n ])\n );\n }\n }\n\n return {\n blockingList,\n run() {\n const {\n app: currentApp,\n location,\n query,\n match,\n flags,\n sys,\n ctxStore,\n data,\n event,\n } = runtimeContext;\n const app = runtimeContext.overrideApp ?? currentApp;\n\n for (const variableName of attemptToVisitGlobals) {\n switch (variableName) {\n // case \"ALIAS\":\n case \"ANCHOR\":\n globalVariables[variableName] = location.hash\n ? location.hash.substring(1)\n : null;\n break;\n case \"APP\":\n globalVariables[variableName] = {\n ...cloneDeep(app),\n getMenu: hooks?.menu?.getMenuById,\n };\n break;\n case \"CTX\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n return ctxStore.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedCtx);\n },\n });\n break;\n case \"DATA\":\n globalVariables[variableName] = data;\n break;\n case \"EVENT\":\n globalVariables[variableName] = event;\n break;\n case \"FLAGS\":\n globalVariables[variableName] = getReadOnlyProxy(flags);\n break;\n case \"FORM_STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n return formStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedFormStates);\n },\n });\n break;\n case \"HASH\":\n globalVariables[variableName] = location.hash;\n break;\n case \"INSTALLED_APPS\":\n globalVariables[variableName] = getReadOnlyProxy({\n has: hasInstalledApp,\n });\n break;\n case \"ITEM\":\n if (!hasOwnProperty(runtimeContext, \"forEachItem\")) {\n // eslint-disable-next-line no-console\n console.error(\n `Using \\`ITEM\\` but no \\`:forEach\\` is found, check your expression: \"${raw}\"`\n );\n } else {\n globalVariables[variableName] = runtimeContext.forEachItem;\n }\n break;\n case \"LOCAL_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"local\"),\n });\n break;\n case \"MEDIA\":\n globalVariables[variableName] = getReadOnlyProxy(getMedia());\n break;\n case \"MISC\":\n globalVariables[variableName] = getRuntime().getMiscSettings();\n break;\n case \"PARAMS\":\n globalVariables[variableName] = new URLSearchParams(query);\n break;\n case \"PATH\":\n globalVariables[variableName] = getReadOnlyProxy(\n match?.params ?? {}\n );\n break;\n case \"PATH_NAME\":\n globalVariables[variableName] = location.pathname;\n break;\n case \"PROCESSORS\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n const pkg = customProcessors.get(key as string);\n if (!pkg) {\n throw new Error(\n `'PROCESSORS.${\n key as string\n }' is not registered! Have you installed the relevant brick package?`\n );\n }\n return getDynamicReadOnlyProxy({\n get(t, k) {\n return pkg.get(k as string);\n },\n ownKeys() {\n return Array.from(pkg.keys());\n },\n });\n },\n ownKeys() {\n return Array.from(usedProcessors);\n },\n });\n break;\n case \"QUERY\":\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.get(key)])\n );\n break;\n case \"QUERY_ARRAY\":\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.getAll(key)])\n );\n // case \"SEGUE\":\n break;\n case \"SESSION_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"session\"),\n });\n break;\n // istanbul ignore next\n case \"TPL\":\n warnAboutStrictMode(\n strict,\n 'Using \"TPL\" in expression',\n `check your expression: \"${raw}\"`\n );\n if (strict) {\n break;\n }\n // eslint-disable-next-line no-fallthrough\n case \"STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n return tplStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedStates);\n },\n });\n break;\n case \"SYS\":\n globalVariables[variableName] = getReadOnlyProxy(sys ?? {});\n break;\n case \"__WIDGET_FN__\":\n globalVariables[variableName] = widgetFunctions;\n break;\n case \"__WIDGET_IMG__\":\n globalVariables[variableName] = hooks?.images?.widgetImagesFactory;\n break;\n case \"__WIDGET_I18N__\":\n globalVariables[variableName] = widgetI18nFactory;\n break;\n }\n }\n\n Object.assign(\n globalVariables,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n storyboardFunctions,\n app: runtimeContext.app,\n appendI18nNamespace: runtimeContext.appendI18nNamespace,\n })\n );\n\n try {\n const result = cook(precooked.expression, precooked.source, {\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n globalVariables\n ),\n });\n const detail = { raw, context: globalVariables, result };\n devtoolsHookEmit(\"evaluation\", detail);\n return result;\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAOA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AAIA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AAIA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,eAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AAOA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,gBAAA,GAAAf,OAAA;AACA,IAAAgB,WAAA,GAAAhB,OAAA;AACA,IAAAiB,gBAAA,GAAAjB,OAAA;AACA,IAAAkB,aAAA,GAAAlB,OAAA;AACA,IAAAmB,OAAA,GAAAnB,OAAA;AACA,IAAAoB,YAAA,GAAApB,OAAA;AACA,IAAAqB,iBAAA,GAAArB,OAAA;AAEA,MAAMsB,YAAY,GAAGC,MAAM,CAACC,GAAG,CAAC,mBAAmB,CAAC;AACpD,MAAMC,gBAAgB,GAAGF,MAAM,CAACC,GAAG,CAAC,uBAAuB,CAAC;AAYrD,SAASE,cAAcA,CAACC,GAAY,EAAuB;EAChE,OAAO,CAAC,EAAEA,GAAG,aAAHA,GAAG,eAAHA,GAAG,CAAoBL,YAAY,CAAC;AAChD;AAEO,SAASM,kBAAkBA,CAACC,GAAiB,EAAU;EAC5D,OAAOA,GAAG,CAACP,YAAY,CAAC;AAC1B;AAEO,SAASQ,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9F,eAAe,CAAC2D,YAAY,CAAC,GAAGoC,6BAAiB;YACjD;QACJ;MACF;MAEA3F,MAAM,CAAC4F,MAAM,CACXhG,eAAe,EACf,IAAAiG,oCAAiB,EAAC9G,SAAS,CAACc,qBAAqB,EAAE;QACjDiG,mBAAmB,EAAnBA,wCAAmB;QACnBjD,GAAG,EAAE7E,cAAc,CAAC6E,GAAG;QACvBkD,mBAAmB,EAAE/H,cAAc,CAAC+H;MACtC,CAAC,CACH,CAAC;MAED,IAAI;QACF,MAAMC,MAAM,GAAG,IAAAC,UAAI,EAAClH,SAAS,CAACmH,UAAU,EAAEnH,SAAS,CAACoH,MAAM,EAAE;UAC1DvG,eAAe,EAAE,IAAAwG,cAAM,EACrBrH,SAAS,CAACc,qBAAqB,EAC/BD,eACF;QACF,CAAC,CAAC;QACF,MAAMyG,MAAM,GAAG;UAAEpJ,GAAG;UAAEqJ,OAAO,EAAE1G,eAAe;UAAEoG;QAAO,CAAC;QACxD,IAAAO,0BAAgB,EAAC,YAAY,EAAEF,MAAM,CAAC;QACtC,OAAOL,MAAM;MACf,CAAC,CAAC,OAAOpI,KAAU,EAAE;QACnB,MAAM4B,OAAO,GAAI,GAAE5B,KAAK,CAAC4B,OAAQ,SAAQvC,GAAI,GAAE;QAC/C,MAAMwC,gBAAgB,GAAG9B,uBAAuB,CAACC,KAAK,CAAC;QACvD,MAAM,IAAI6B,gBAAgB,CAACD,OAAO,CAAC;MACrC;IACF;EACF,CAAC;AACH"}
@@ -3,7 +3,62 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.PANEL_CHANGE = exports.MESSAGE_SOURCE_PANEL = exports.FRAME_ACTIVE_CHANGE = void 0;
7
+ exports.devtoolsHookEmit = devtoolsHookEmit;
6
8
  exports.getDevHook = getDevHook;
9
+ exports.listenDevtoolsEagerly = listenDevtoolsEagerly;
10
+ const MESSAGE_SOURCE_PANEL = "brick-next-devtools-panel";
11
+ exports.MESSAGE_SOURCE_PANEL = MESSAGE_SOURCE_PANEL;
12
+ const FRAME_ACTIVE_CHANGE = "devtools-frame-active-change";
13
+ exports.FRAME_ACTIVE_CHANGE = FRAME_ACTIVE_CHANGE;
14
+ const PANEL_CHANGE = "devtools-panel-change";
15
+ exports.PANEL_CHANGE = PANEL_CHANGE;
16
+ let frameIsActive = true;
17
+ let selectedPanel;
18
+ function devtoolsHookEmit(type, payload) {
19
+ const devtools = getDevHook();
20
+ if (!devtools || type === "evaluation" && !(frameIsActive && (!selectedPanel || selectedPanel === "Evaluations"))) {
21
+ // Ignore messages if current devtools panel is not relevant.
22
+ return;
23
+ }
24
+ const emit = () => {
25
+ var _devtools$emit;
26
+ (_devtools$emit = devtools.emit) === null || _devtools$emit === void 0 ? void 0 : _devtools$emit.call(devtools, {
27
+ type,
28
+ payload
29
+ });
30
+ };
31
+
32
+ // Try to emit only in idle time.
33
+ // istanbul ignore next
34
+ if (typeof window.requestIdleCallback === "function") {
35
+ window.requestIdleCallback(emit);
36
+ } else {
37
+ setTimeout(emit, 0);
38
+ }
39
+ }
40
+ function listenDevtoolsEagerly() {
41
+ window.addEventListener("message", ({
42
+ data
43
+ }) => {
44
+ if ((data === null || data === void 0 ? void 0 : data.source) !== MESSAGE_SOURCE_PANEL) {
45
+ return;
46
+ }
47
+ const payload = data.payload;
48
+ switch (payload === null || payload === void 0 ? void 0 : payload.type) {
49
+ case FRAME_ACTIVE_CHANGE:
50
+ {
51
+ frameIsActive = payload.active;
52
+ break;
53
+ }
54
+ case PANEL_CHANGE:
55
+ {
56
+ selectedPanel = payload.panel;
57
+ break;
58
+ }
59
+ }
60
+ });
61
+ }
7
62
  function getDevHook() {
8
63
  return window.__BRICK_NEXT_DEVTOOLS_HOOK__;
9
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.js","names":["getDevHook","window","__BRICK_NEXT_DEVTOOLS_HOOK__"],"sources":["../../../src/internal/devtools.ts"],"sourcesContent":["interface DevtoolsHookContainer {\n __BRICK_NEXT_DEVTOOLS_HOOK__?: DevtoolsHook;\n}\n\ninterface DevtoolsHook {\n emit: (message: unknown) => void;\n restoreDehydrated: (value: unknown) => unknown;\n}\n\nexport function getDevHook(): DevtoolsHook | undefined {\n return (window as DevtoolsHookContainer).__BRICK_NEXT_DEVTOOLS_HOOK__;\n}\n"],"mappings":";;;;;;AASO,SAASA,UAAUA,CAAA,EAA6B;EACrD,OAAQC,MAAM,CAA2BC,4BAA4B;AACvE"}
1
+ {"version":3,"file":"devtools.js","names":["MESSAGE_SOURCE_PANEL","exports","FRAME_ACTIVE_CHANGE","PANEL_CHANGE","frameIsActive","selectedPanel","devtoolsHookEmit","type","payload","devtools","getDevHook","emit","_devtools$emit","call","window","requestIdleCallback","setTimeout","listenDevtoolsEagerly","addEventListener","data","source","active","panel","__BRICK_NEXT_DEVTOOLS_HOOK__"],"sources":["../../../src/internal/devtools.ts"],"sourcesContent":["export const MESSAGE_SOURCE_PANEL = \"brick-next-devtools-panel\";\nexport const FRAME_ACTIVE_CHANGE = \"devtools-frame-active-change\";\nexport const PANEL_CHANGE = \"devtools-panel-change\";\n\ninterface DevtoolsHookContainer {\n __BRICK_NEXT_DEVTOOLS_HOOK__?: DevtoolsHook;\n}\n\ninterface DevtoolsHook {\n emit: (message: unknown) => void;\n}\n\ntype DevtoolsMessagePayload = FrameActiveChangePayload | PanelChangePayload;\n\ninterface FrameActiveChangePayload {\n type: typeof FRAME_ACTIVE_CHANGE;\n active: boolean;\n panel: PanelType;\n}\n\ntype PanelType = \"Bricks\" | \"Evaluations\" | \"Transformations\";\n\ninterface PanelChangePayload {\n type: typeof PANEL_CHANGE;\n panel: PanelType;\n}\n\nlet frameIsActive = true;\nlet selectedPanel: PanelType;\n\nexport function devtoolsHookEmit(type: string, payload?: unknown): void {\n const devtools = getDevHook();\n if (\n !devtools ||\n (type === \"evaluation\" &&\n !(frameIsActive && (!selectedPanel || selectedPanel === \"Evaluations\")))\n ) {\n // Ignore messages if current devtools panel is not relevant.\n return;\n }\n\n const emit = (): void => {\n devtools.emit?.({\n type,\n payload,\n });\n };\n\n // Try to emit only in idle time.\n // istanbul ignore next\n if (typeof window.requestIdleCallback === \"function\") {\n window.requestIdleCallback(emit);\n } else {\n setTimeout(emit, 0);\n }\n}\n\nexport function listenDevtoolsEagerly(): void {\n window.addEventListener(\"message\", ({ data }: MessageEvent): void => {\n if (data?.source !== MESSAGE_SOURCE_PANEL) {\n return;\n }\n const payload: DevtoolsMessagePayload = data.payload;\n switch (payload?.type) {\n case FRAME_ACTIVE_CHANGE: {\n frameIsActive = payload.active;\n break;\n }\n case PANEL_CHANGE: {\n selectedPanel = payload.panel;\n break;\n }\n }\n });\n}\n\nexport function getDevHook(): DevtoolsHook | undefined {\n return (window as DevtoolsHookContainer).__BRICK_NEXT_DEVTOOLS_HOOK__;\n}\n"],"mappings":";;;;;;;;;AAAO,MAAMA,oBAAoB,GAAG,2BAA2B;AAACC,OAAA,CAAAD,oBAAA,GAAAA,oBAAA;AACzD,MAAME,mBAAmB,GAAG,8BAA8B;AAACD,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAC3D,MAAMC,YAAY,GAAG,uBAAuB;AAACF,OAAA,CAAAE,YAAA,GAAAA,YAAA;AAyBpD,IAAIC,aAAa,GAAG,IAAI;AACxB,IAAIC,aAAwB;AAErB,SAASC,gBAAgBA,CAACC,IAAY,EAAEC,OAAiB,EAAQ;EACtE,MAAMC,QAAQ,GAAGC,UAAU,CAAC,CAAC;EAC7B,IACE,CAACD,QAAQ,IACRF,IAAI,KAAK,YAAY,IACpB,EAAEH,aAAa,KAAK,CAACC,aAAa,IAAIA,aAAa,KAAK,aAAa,CAAC,CAAE,EAC1E;IACA;IACA;EACF;EAEA,MAAMM,IAAI,GAAGA,CAAA,KAAY;IAAA,IAAAC,cAAA;IACvB,CAAAA,cAAA,GAAAH,QAAQ,CAACE,IAAI,cAAAC,cAAA,uBAAbA,cAAA,CAAAC,IAAA,CAAAJ,QAAQ,EAAQ;MACdF,IAAI;MACJC;IACF,CAAC,CAAC;EACJ,CAAC;;EAED;EACA;EACA,IAAI,OAAOM,MAAM,CAACC,mBAAmB,KAAK,UAAU,EAAE;IACpDD,MAAM,CAACC,mBAAmB,CAACJ,IAAI,CAAC;EAClC,CAAC,MAAM;IACLK,UAAU,CAACL,IAAI,EAAE,CAAC,CAAC;EACrB;AACF;AAEO,SAASM,qBAAqBA,CAAA,EAAS;EAC5CH,MAAM,CAACI,gBAAgB,CAAC,SAAS,EAAE,CAAC;IAAEC;EAAmB,CAAC,KAAW;IACnE,IAAI,CAAAA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEC,MAAM,MAAKpB,oBAAoB,EAAE;MACzC;IACF;IACA,MAAMQ,OAA+B,GAAGW,IAAI,CAACX,OAAO;IACpD,QAAQA,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAED,IAAI;MACnB,KAAKL,mBAAmB;QAAE;UACxBE,aAAa,GAAGI,OAAO,CAACa,MAAM;UAC9B;QACF;MACA,KAAKlB,YAAY;QAAE;UACjBE,aAAa,GAAGG,OAAO,CAACc,KAAK;UAC7B;QACF;IACF;EACF,CAAC,CAAC;AACJ;AAEO,SAASZ,UAAUA,CAAA,EAA6B;EACrD,OAAQI,MAAM,CAA2BS,4BAA4B;AACvE"}
@@ -65,6 +65,8 @@ export function unstable_createRoot(container) {
65
65
  };
66
66
  if (scope === "page") {
67
67
  var _clearI18nBundles;
68
+ setTheme(theme !== null && theme !== void 0 ? theme : "light");
69
+ setMode("default");
68
70
  var demoApp = {
69
71
  id: "demo",
70
72
  homepage: "/demo"
@@ -96,7 +98,7 @@ export function unstable_createRoot(container) {
96
98
  output = yield renderBricks(renderRoot, bricks, runtimeContext, rendererContext);
97
99
  flushStableLoadBricks();
98
100
  stores = [runtimeContext.ctxStore, ...runtimeContext.tplStateStoreMap.values(), ...runtimeContext.formStateStoreMap.values()];
99
- yield Promise.all([...output.blockingList, runtimeContext.ctxStore.waitForAll(), ...stores.map(store => store.waitForAll()), ...runtimeContext.pendingPermissionsPreCheck]);
101
+ yield Promise.all([...output.blockingList, ...stores.map(store => store.waitForAll()), ...runtimeContext.pendingPermissionsPreCheck]);
100
102
  } catch (error) {
101
103
  failed = true;
102
104
  output = {
@@ -121,8 +123,6 @@ export function unstable_createRoot(container) {
121
123
  unmountTree(portal);
122
124
  }
123
125
  if (scope === "page") {
124
- setTheme(theme !== null && theme !== void 0 ? theme : "light");
125
- setMode("default");
126
126
  if (!failed) {
127
127
  rendererContext.dispatchBeforePageLoad();
128
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createRoot.js","names":["flushStableLoadBricks","renderBricks","RendererContext","DataStore","mountTree","unmountTree","httpErrorToString","applyMode","applyTheme","setMode","setTheme","RenderTag","registerStoryboardFunctions","registerAppI18n","registerCustomTemplates","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","context","functions","templates","i18n","i18nData","Error","bricks","concat","previousRendererContext","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","renderRoot","tag","ROOT","_clearI18nBundles","demoApp","id","homepage","app","demoStoryboard","meta","customTemplates","define","failed","output","stores","values","Promise","all","blockingList","waitForAll","map","store","error","node","BRICK","type","properties","textContent","return","menuRequests","child","dispatchOnUnmount","dispose","dispatchBeforePageLoad","window","scrollTo","handleAsyncAfterMount","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport { RenderOutput, renderBricks } from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n context,\n functions,\n templates,\n i18n: i18nData,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n rendererContext = new RendererContext(scope, { unknownBricks });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n const demoApp = {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = demoApp;\n const demoStoryboard = {\n app: demoApp,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, demoApp);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext\n );\n\n flushStableLoadBricks();\n\n stores = [\n runtimeContext.ctxStore,\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ];\n\n await Promise.all([\n ...output.blockingList,\n runtimeContext.ctxStore.waitForAll(),\n ...stores.map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.handleAsyncAfterMount();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";AAUA,SAASA,qBAAqB,QAAQ,mBAAmB;AACzD,SAAuBC,YAAY,QAAQ,wBAAwB;AACnE,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,SAAS,QAAQ,8BAA8B;AAExD,SAASC,SAAS,EAAEC,WAAW,QAAQ,qBAAqB;AAC5D,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,mBAAmB;AAC5E,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,2BAA2B,QAAQ,2CAA2C;AACvF,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,uBAAuB,QAAQ,uCAAuC;AA2B/E,OAAO,SAASC,mBAAmBA,CACjCC,SAAsB,EAEtB;EAAA,IADA;IAAEC,MAAM,EAAEC,OAAO;IAAEC,KAAK,GAAG,UAAU;IAAEC;EAAiC,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GA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IrC,KAAK,KAAK,MAAM,EAAE;UACpBuE,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB;QAEA,IAAI,CAACvB,MAAM,EAAE;UACX,KAAK,IAAMS,KAAK,IAAIP,MAAM,EAAE;YAC1BO,KAAK,CAACe,qBAAqB,CAAC,CAAC;UAC/B;UAEA,IAAIzE,KAAK,KAAK,MAAM,EAAE;YACpBe,eAAe,CAAC2D,gBAAgB,CAAC,CAAC;YAClC;UACF;;UACA3D,eAAe,CAAC4D,eAAe,CAAC,CAAC;UACjC5D,eAAe,CAAC6D,wBAAwB,CAAC,CAAC;UAC1C7D,eAAe,CAAC8D,qBAAqB,CAAC,CAAC;UACvC9D,eAAe,CAAC+D,2BAA2B,CAAC,CAAC;QAC/C;MAAC;IACH,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAIjE,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB5B,WAAW,CAACW,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACVZ,WAAW,CAACY,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAACkF,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"createRoot.js","names":["flushStableLoadBricks","renderBricks","RendererContext","DataStore","mountTree","unmountTree","httpErrorToString","applyMode","applyTheme","setMode","setTheme","RenderTag","registerStoryboardFunctions","registerAppI18n","registerCustomTemplates","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","context","functions","templates","i18n","i18nData","Error","bricks","concat","previousRendererContext","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","renderRoot","tag","ROOT","_clearI18nBundles","demoApp","id","homepage","app","demoStoryboard","meta","customTemplates","define","failed","output","stores","values","Promise","all","blockingList","map","store","waitForAll","error","node","BRICK","type","properties","textContent","return","menuRequests","child","dispatchOnUnmount","dispose","dispatchBeforePageLoad","window","scrollTo","handleAsyncAfterMount","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport { RenderOutput, renderBricks } from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n context,\n functions,\n templates,\n i18n: i18nData,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n rendererContext = new RendererContext(scope, { unknownBricks });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n\n const demoApp = {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = demoApp;\n const demoStoryboard = {\n app: demoApp,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, demoApp);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext\n );\n\n flushStableLoadBricks();\n\n stores = [\n runtimeContext.ctxStore,\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ];\n\n await Promise.all([\n ...output.blockingList,\n ...stores.map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.handleAsyncAfterMount();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";AAUA,SAASA,qBAAqB,QAAQ,mBAAmB;AACzD,SAAuBC,YAAY,QAAQ,wBAAwB;AACnE,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,SAAS,QAAQ,8BAA8B;AAExD,SAASC,SAAS,EAAEC,WAAW,QAAQ,qBAAqB;AAC5D,SAASC,iBAAiB,QAAQ,sBAAsB;AAC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,uBAAvBA,uBAAuB,CAAEuC,OAAO,CAAC,CAAC;QAClCnF,WAAW,CAACW,SAAS,CAAC;QACtB,IAAIC,MAAM,EAAE;UACVZ,WAAW,CAACY,MAAM,CAAC;QACrB;QAEA,IAAIE,KAAK,KAAK,MAAM,EAAE;UACpB,IAAI,CAACiD,MAAM,EAAE;YACXlC,eAAe,CAACuD,sBAAsB,CAAC,CAAC;UAC1C;UAEAjF,UAAU,CAAC,CAAC;UACZD,SAAS,CAAC,CAAC;QACb;QAEAH,SAAS,CAACoD,UAAU,CAAC;QAErB,IAAIrC,KAAK,KAAK,MAAM,EAAE;UACpBuE,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB;QAEA,IAAI,CAACvB,MAAM,EAAE;UACX,KAAK,IAAMQ,KAAK,IAAIN,MAAM,EAAE;YAC1BM,KAAK,CAACgB,qBAAqB,CAAC,CAAC;UAC/B;UAEA,IAAIzE,KAAK,KAAK,MAAM,EAAE;YACpBe,eAAe,CAAC2D,gBAAgB,CAAC,CAAC;YAClC;UACF;;UACA3D,eAAe,CAAC4D,eAAe,CAAC,CAAC;UACjC5D,eAAe,CAAC6D,wBAAwB,CAAC,CAAC;UAC1C7D,eAAe,CAAC8D,qBAAqB,CAAC,CAAC;UACvC9D,eAAe,CAAC+D,2BAA2B,CAAC,CAAC;QAC/C;MAAC;IACH,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAIjE,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB5B,WAAW,CAACW,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACVZ,WAAW,CAACY,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAACkF,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH"}
@@ -293,8 +293,6 @@ function _render3() {
293
293
  }
294
294
  _classPrivateFieldGet(this, _rendererContextTrashCan).clear();
295
295
  hooks === null || hooks === void 0 ? void 0 : (_hooks$messageDispatc = hooks.messageDispatcher) === null || _hooks$messageDispatc === void 0 ? void 0 : _hooks$messageDispatc.reset();
296
- setTheme(currentApp && (getLocalAppsTheme()[currentApp.id] || currentApp.theme) || "light");
297
- setMode("default");
298
296
  if (appChanged) {
299
297
  _classPrivateFieldSet(this, _previousApp, previousApp);
300
298
  window.dispatchEvent(new CustomEvent("app.change", {
@@ -305,6 +303,8 @@ function _render3() {
305
303
  }));
306
304
  }
307
305
  };
306
+ setTheme(currentApp && (getLocalAppsTheme()[currentApp.id] || currentApp.theme) || "light");
307
+ setMode("default");
308
308
  if (currentApp) {
309
309
  var _hooks$checkInstalled, _hooks$auth, _hooks$checkPermissio, _storyboard$meta, _hooks$flowApi2, _storyboard$meta2;
310
310
  hooks === null || hooks === void 0 ? void 0 : (_hooks$checkInstalled = hooks.checkInstalledApps) === null || _hooks$checkInstalled === void 0 ? void 0 : _hooks$checkInstalled.preCheckInstalledApps(storyboard, appId => !!_internalApiGetAppInBootstrapData(appId));
@@ -1 +1 @@
1
- {"version":3,"file":"Router.js","names":["locationsAreEqual","flushStableLoadBricks","HttpAbortError","uniqueId","getHistory","renderRoutes","DataStore","clearResolveCache","mountTree","unmountTree","isOutsideApp","matchStoryboard","registerStoryboardFunctions","RendererContext","applyMode","applyTheme","getLocalAppsTheme","setMode","setTheme","_internalApiGetAppInBootstrapData","getRuntime","hooks","getPageInfo","resetAllComputedMarks","handleHttpError","httpErrorToString","isUnauthenticatedError","abortPendingRequest","initAbortController","registerCustomTemplates","fulfilStoryboard","RenderTag","insertPreviewRoutes","_storyboards","WeakMap","_rendering","_prevLocation","_nextLocation","_runtimeContext","_rendererContext","_rendererContextTrashCan","_redirectCount","_renderId","_currentApp","_previousApp","_navConfig","_getBlockMessageBeforePageLave","WeakSet","_safeRedirect","_queuedRender","_render","Router","constructor","storyboards","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","writable","value","Set","_classPrivateFieldSet","history","window","addEventListener","event","message","_classPrivateMethodGet","_getBlockMessageBeforePageLave2","call","preventDefault","returnValue","block","location","action","getRenderId","_classPrivateFieldGet","getRuntimeContext","getRecentApps","currentApp","previousApp","getNavConfig","bootstrap","listen","_classPrivateFieldGet2","_location$state","_classPrivateFieldGet3","ignoreRendering","omittedLocationProps","hash","undefined","state","key","notify","_objectSpread","dispatchPageLeave","storyboard","pathname","reload","_queuedRender2","catch","detail","_classPrivateFieldGet4","previousMessage","getBlockMessage","dispatchBeforePageLeave","unblock","_safeRedirect2","to","from","_this$redirectCount","_this$redirectCount2","concat","search","process","env","NODE_ENV","console","error","Error","replace","_x","_queuedRender3","apply","arguments","_asyncToGenerator","_render2","nextLocation","_x2","_render3","_hooks$flowApi","_classPrivateFieldGet5","flowApi","clearCollectWidgetContract","app","appChanged","id","flags","getFeatureFlags","prevRendererContext","redirectTo","add","redirectToLogin","main","document","querySelector","portal","renderRoot","tag","ROOT","container","createPortal","cleanUpPreviousRender","_hooks$messageDispatc","item","dispatchOnUnmount","dispose","clear","messageDispatcher","reset","theme","dispatchEvent","CustomEvent","_hooks$checkInstalled","_hooks$auth","_hooks$checkPermissio","_storyboard$meta","_hooks$flowApi2","_storyboard$meta2","checkInstalledApps","preCheckInstalledApps","appId","rendererContext","runtimeContext","query","URLSearchParams","sys","auth","getAuth","settings","brand","getBrandSettings","ctxStore","pendingPermissionsPreCheck","checkPermissions","preCheckPermissions","tplStateStoreMap","Map","formStateStoreMap","meta","functions","collectContract","contracts","failed","output","stores","routes","unauthenticated","redirect","path","values","Promise","all","blockingList","map","store","waitForAll","menuConfs","menuRequests","mergeMenuConfs","NO_AUTH_GUARD","node","BRICK","type","properties","textContent","return","child","route","dispatchBeforePageLoad","scrollTo","handleAsyncAfterMount","dispatchPageLoad","dispatchAnchorLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","isLoggedIn","navConfig","breadcrumb","menuConf","overwrite","items","push"],"sources":["../../../src/internal/Router.ts"],"sourcesContent":["import { Action, locationsAreEqual } from \"history\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport type {\n BreadcrumbItemConf,\n MicroApp,\n StaticMenuConf,\n Storyboard,\n} from \"@next-core/types\";\nimport { HttpAbortError } from \"@next-core/http\";\nimport { uniqueId } from \"lodash\";\nimport { NextHistoryState, NextLocation, getHistory } from \"../history.js\";\nimport { RenderOutput, renderRoutes } from \"./Renderer.js\";\nimport { DataStore } from \"./data/DataStore.js\";\nimport { clearResolveCache } from \"./data/resolveData.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { isOutsideApp, matchStoryboard } from \"./matchStoryboard.js\";\nimport { registerStoryboardFunctions } from \"./compute/StoryboardFunctions.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport {\n applyMode,\n applyTheme,\n getLocalAppsTheme,\n setMode,\n setTheme,\n} from \"../themeAndMode.js\";\nimport {\n _internalApiGetAppInBootstrapData,\n getRuntime,\n hooks,\n} from \"./Runtime.js\";\nimport { getPageInfo } from \"../getPageInfo.js\";\nimport type { RenderBrick, RenderRoot, RuntimeContext } from \"./interfaces.js\";\nimport { resetAllComputedMarks } from \"./compute/markAsComputed.js\";\nimport {\n handleHttpError,\n httpErrorToString,\n isUnauthenticatedError,\n} from \"../handleHttpError.js\";\nimport { abortPendingRequest, initAbortController } from \"./abortController.js\";\nimport { registerCustomTemplates } from \"./registerCustomTemplates.js\";\nimport { fulfilStoryboard } from \"./fulfilStoryboard.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { insertPreviewRoutes } from \"./insertPreviewRoutes.js\";\n\nexport class Router {\n readonly #storyboards: Storyboard[];\n #rendering = false;\n #prevLocation!: NextLocation;\n #nextLocation?: NextLocation;\n #runtimeContext?: RuntimeContext;\n #rendererContext?: RendererContext;\n #rendererContextTrashCan = new Set<RendererContext | undefined>();\n #redirectCount = 0;\n #renderId?: string;\n #currentApp?: MicroApp;\n #previousApp?: MicroApp;\n #navConfig?: {\n breadcrumb?: BreadcrumbItemConf[];\n };\n\n constructor(storyboards: Storyboard[]) {\n this.#storyboards = storyboards;\n\n const history = getHistory();\n window.addEventListener(\"beforeunload\", (event) => {\n const message = this.#getBlockMessageBeforePageLave({});\n // See examples in https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload\n if (message) {\n // Cancel the event\n // If you prevent default behavior in Mozilla Firefox prompt will always be shown\n event.preventDefault();\n // Chrome requires returnValue to be set\n event.returnValue = \"\";\n } else {\n // the absence of a returnValue property on the event will guarantee the browser unload happens\n delete event.returnValue;\n }\n });\n\n history.block((location, action) =>\n this.#getBlockMessageBeforePageLave({ location, action })\n );\n }\n\n getRenderId() {\n return this.#renderId;\n }\n\n getRuntimeContext() {\n return this.#runtimeContext;\n }\n\n getRecentApps() {\n return {\n currentApp: this.#currentApp,\n previousApp: this.#previousApp,\n };\n }\n\n getNavConfig() {\n return this.#navConfig;\n }\n\n #getBlockMessageBeforePageLave(detail: {\n location?: NextLocation;\n action?: Action;\n }): string | undefined {\n const history = getHistory();\n const previousMessage = history.getBlockMessage();\n this.#rendererContext?.dispatchBeforePageLeave(detail);\n const message = history.getBlockMessage();\n if (!previousMessage && message) {\n // Auto unblock only if new block was introduced by `onBeforePageLeave`.\n history.unblock();\n }\n return message;\n }\n\n #safeRedirect(\n to: string,\n state: NextHistoryState | undefined,\n from: NextLocation\n ): void {\n if (this.#redirectCount++ > 10) {\n const message = `Infinite redirect detected: from \"${from.pathname}${from.search}${from.hash}\" to \"${to}\"`;\n // istanbul ignore else: error cannot be caught in test\n if (process.env.NODE_ENV === \"test\") {\n // eslint-disable-next-line no-console\n console.error(message);\n return;\n } else {\n throw new Error(message);\n }\n }\n getHistory().replace(to, state);\n }\n\n bootstrap() {\n initAbortController();\n const history = getHistory();\n this.#prevLocation = history.location;\n history.listen((location, action) => {\n let ignoreRendering = false;\n const omittedLocationProps: Partial<NextLocation> = {\n hash: undefined,\n state: undefined,\n };\n // Omit the \"key\" when checking whether locations are equal in certain situations.\n if (\n // When current location is triggered by browser action of hash link.\n location.key === undefined ||\n // When current location is triggered by browser action of non-push-or-replace,\n // such as goBack or goForward,\n (action === \"POP\" &&\n // and the previous location was triggered by hash link,\n (this.#prevLocation.key === undefined ||\n // or the previous location specified notify false.\n this.#prevLocation.state?.notify === false))\n ) {\n omittedLocationProps.key = undefined;\n }\n if (\n locationsAreEqual(\n { ...this.#prevLocation, ...omittedLocationProps },\n { ...location, ...omittedLocationProps }\n ) ||\n (action !== \"POP\" && location.state?.notify === false)\n ) {\n // Ignore rendering if location not changed except hash, state and optional key.\n // Ignore rendering if notify is `false`.\n ignoreRendering = true;\n }\n if (ignoreRendering) {\n this.#prevLocation = location;\n return;\n }\n abortPendingRequest();\n this.#prevLocation = location;\n this.#rendererContext?.dispatchPageLeave();\n\n if (action === \"POP\") {\n const storyboard = matchStoryboard(\n this.#storyboards,\n location.pathname\n );\n // When a browser action of goBack or goForward is performing,\n // force reload when the target page is a page of an outside app.\n if (isOutsideApp(storyboard)) {\n window.location.reload();\n return;\n }\n }\n\n if (this.#rendering) {\n this.#nextLocation = location;\n } else {\n // devtoolsHookEmit(\"locationChange\");\n this.#queuedRender(location).catch(handleHttpError);\n }\n });\n return this.#queuedRender(history.location);\n }\n\n async #queuedRender(location: NextLocation): Promise<void> {\n this.#rendering = true;\n try {\n await this.#render(location);\n } finally {\n this.#rendering = false;\n if (this.#nextLocation) {\n const nextLocation = this.#nextLocation;\n this.#nextLocation = undefined;\n await this.#queuedRender(nextLocation);\n }\n }\n }\n\n async #render(location: NextLocation): Promise<void> {\n this.#renderId = uniqueId(\"render-id-1\");\n\n resetAllComputedMarks();\n clearResolveCache();\n hooks?.flowApi?.clearCollectWidgetContract();\n\n const history = getHistory();\n history.unblock();\n\n const storyboard = matchStoryboard(this.#storyboards, location.pathname);\n\n const previousApp = this.#runtimeContext?.app;\n if (storyboard?.app) {\n await fulfilStoryboard(storyboard);\n }\n const currentApp = (this.#currentApp = storyboard?.app);\n\n // Storyboard maybe re-assigned, e.g. when open launchpad.\n const appChanged =\n previousApp && currentApp\n ? previousApp.id !== currentApp.id\n : previousApp !== currentApp;\n\n // TODO: handle favicon\n\n // Set `Router::#currentApp` before calling `getFeatureFlags()`\n const flags = getRuntime().getFeatureFlags();\n const prevRendererContext = this.#rendererContext;\n\n const redirectTo = (to: string, state?: NextHistoryState): void => {\n this.#rendererContextTrashCan.add(prevRendererContext);\n this.#safeRedirect(to, state, location);\n };\n\n const redirectToLogin = (): void => {\n const to = flags[\"sso-enabled\"] ? \"/sso-auth/login\" : \"/auth/login\";\n redirectTo(to, { from: location });\n };\n\n const main = document.querySelector(\"#main-mount-point\") as HTMLElement;\n const portal = document.querySelector(\"#portal-mount-point\") as HTMLElement;\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container: main,\n createPortal: portal,\n };\n\n const cleanUpPreviousRender = (): void => {\n unmountTree(main);\n unmountTree(portal);\n\n // Note: redirects can lead to multiple trash renderer contexts.\n this.#rendererContextTrashCan.add(prevRendererContext);\n for (const item of this.#rendererContextTrashCan) {\n if (item) {\n item.dispatchOnUnmount();\n item.dispose();\n }\n }\n this.#rendererContextTrashCan.clear();\n hooks?.messageDispatcher?.reset();\n\n setTheme(\n (currentApp &&\n (getLocalAppsTheme()[currentApp.id] || currentApp.theme)) ||\n \"light\"\n );\n setMode(\"default\");\n\n if (appChanged) {\n this.#previousApp = previousApp;\n window.dispatchEvent(\n new CustomEvent(\"app.change\", {\n detail: {\n previousApp,\n currentApp,\n },\n })\n );\n }\n };\n\n if (currentApp) {\n hooks?.checkInstalledApps?.preCheckInstalledApps(\n storyboard,\n (appId) => !!_internalApiGetAppInBootstrapData(appId)\n );\n\n const rendererContext = (this.#rendererContext = new RendererContext(\n \"page\"\n ));\n\n const runtimeContext: RuntimeContext = (this.#runtimeContext = {\n app: currentApp,\n location,\n query: new URLSearchParams(location.search),\n flags,\n sys: {\n ...hooks?.auth?.getAuth(),\n ...getPageInfo(),\n settings: {\n brand: getRuntime().getBrandSettings(),\n },\n },\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [\n hooks?.checkPermissions?.preCheckPermissions(storyboard),\n ],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n });\n\n this.#navConfig = undefined;\n\n registerCustomTemplates(storyboard);\n registerStoryboardFunctions(storyboard.meta?.functions, currentApp);\n hooks?.flowApi?.collectContract(storyboard.meta?.contracts);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderRoutes(\n renderRoot,\n insertPreviewRoutes(storyboard.routes),\n runtimeContext,\n rendererContext\n );\n if (output.unauthenticated) {\n redirectToLogin();\n return;\n }\n if (output.redirect) {\n redirectTo(output.redirect.path, output.redirect.state);\n return;\n }\n // Reset redirect count if no redirect is set.\n this.#redirectCount = 0;\n\n flushStableLoadBricks();\n\n stores = [\n runtimeContext.ctxStore,\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ];\n\n await Promise.all([\n ...output.blockingList,\n ...stores.map((store) => store.waitForAll()),\n // Todo: load processors only when they would used in current rendering.\n // loadProcessorsImperatively(\n // strictCollectMemberUsage(\n // [storyboard.routes, storyboard.meta?.customTemplates],\n // \"PROCESSORS\",\n // 2\n // ),\n // getBrickPackages()\n // ),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n\n const menuConfs = await Promise.all(output.menuRequests);\n this.#navConfig = mergeMenuConfs(menuConfs);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Router failed:\", error);\n\n if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {\n redirectToLogin();\n return;\n } else if (error instanceof HttpAbortError) {\n this.#rendererContextTrashCan.add(prevRendererContext);\n return;\n } else {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n runtimeContext: null!,\n return: renderRoot,\n },\n blockingList: [],\n menuRequests: [],\n };\n }\n }\n renderRoot.child = output.node;\n\n cleanUpPreviousRender();\n\n if ((output.route && output.route.type !== \"routes\") || failed) {\n if (!failed) {\n // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.\n rendererContext.dispatchBeforePageLoad();\n }\n applyTheme();\n applyMode();\n\n mountTree(renderRoot);\n\n // Scroll to top after each rendering.\n // See https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/guides/scroll-restoration.md\n window.scrollTo(0, 0);\n\n if (!failed) {\n for (const store of stores) {\n store.handleAsyncAfterMount();\n }\n\n rendererContext.dispatchPageLoad();\n rendererContext.dispatchAnchorLoad();\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n\n return;\n }\n } else if (\n !window.NO_AUTH_GUARD &&\n hooks?.auth &&\n !hooks.auth.isLoggedIn()\n ) {\n // Todo(steve): refine after api-gateway supports fetching storyboards before logged in.\n // Redirect to login if no storyboard is matched.\n redirectToLogin();\n return;\n } else {\n cleanUpPreviousRender();\n }\n\n applyTheme();\n applyMode();\n\n const node: RenderBrick = {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: \"Page not found\",\n },\n runtimeContext: null!,\n return: renderRoot,\n };\n renderRoot.child = node;\n\n mountTree(renderRoot);\n\n // Scroll to top after each rendering.\n window.scrollTo(0, 0);\n }\n}\n\nfunction mergeMenuConfs(menuConfs: (StaticMenuConf | undefined)[]) {\n const navConfig = {\n breadcrumb: [] as BreadcrumbItemConf[],\n };\n for (const menuConf of menuConfs) {\n if (menuConf) {\n const { breadcrumb } = menuConf;\n if (breadcrumb) {\n if (breadcrumb.overwrite) {\n navConfig.breadcrumb = breadcrumb.items;\n } else {\n navConfig.breadcrumb.push(...breadcrumb.items);\n }\n }\n }\n }\n return navConfig;\n}\n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;MACF;IACF;EACF;EACA,OAAOJ,SAAS;AAClB"}
1
+ {"version":3,"file":"Router.js","names":["locationsAreEqual","flushStableLoadBricks","HttpAbortError","uniqueId","getHistory","renderRoutes","DataStore","clearResolveCache","mountTree","unmountTree","isOutsideApp","matchStoryboard","registerStoryboardFunctions","RendererContext","applyMode","applyTheme","getLocalAppsTheme","setMode","setTheme","_internalApiGetAppInBootstrapData","getRuntime","hooks","getPageInfo","resetAllComputedMarks","handleHttpError","httpErrorToString","isUnauthenticatedError","abortPendingRequest","initAbortController","registerCustomTemplates","fulfilStoryboard","RenderTag","insertPreviewRoutes","_storyboards","WeakMap","_rendering","_prevLocation","_nextLocation","_runtimeContext","_rendererContext","_rendererContextTrashCan","_redirectCount","_renderId","_currentApp","_previousApp","_navConfig","_getBlockMessageBeforePageLave","WeakSet","_safeRedirect","_queuedRender","_render","Router","constructor","storyboards","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","writable","value","Set","_classPrivateFieldSet","history","window","addEventListener","event","message","_classPrivateMethodGet","_getBlockMessageBeforePageLave2","call","preventDefault","returnValue","block","location","action","getRenderId","_classPrivateFieldGet","getRuntimeContext","getRecentApps","currentApp","previousApp","getNavConfig","bootstrap","listen","_classPrivateFieldGet2","_location$state","_classPrivateFieldGet3","ignoreRendering","omittedLocationProps","hash","undefined","state","key","notify","_objectSpread","dispatchPageLeave","storyboard","pathname","reload","_queuedRender2","catch","detail","_classPrivateFieldGet4","previousMessage","getBlockMessage","dispatchBeforePageLeave","unblock","_safeRedirect2","to","from","_this$redirectCount","_this$redirectCount2","concat","search","process","env","NODE_ENV","console","error","Error","replace","_x","_queuedRender3","apply","arguments","_asyncToGenerator","_render2","nextLocation","_x2","_render3","_hooks$flowApi","_classPrivateFieldGet5","flowApi","clearCollectWidgetContract","app","appChanged","id","flags","getFeatureFlags","prevRendererContext","redirectTo","add","redirectToLogin","main","document","querySelector","portal","renderRoot","tag","ROOT","container","createPortal","cleanUpPreviousRender","_hooks$messageDispatc","item","dispatchOnUnmount","dispose","clear","messageDispatcher","reset","dispatchEvent","CustomEvent","theme","_hooks$checkInstalled","_hooks$auth","_hooks$checkPermissio","_storyboard$meta","_hooks$flowApi2","_storyboard$meta2","checkInstalledApps","preCheckInstalledApps","appId","rendererContext","runtimeContext","query","URLSearchParams","sys","auth","getAuth","settings","brand","getBrandSettings","ctxStore","pendingPermissionsPreCheck","checkPermissions","preCheckPermissions","tplStateStoreMap","Map","formStateStoreMap","meta","functions","collectContract","contracts","failed","output","stores","routes","unauthenticated","redirect","path","values","Promise","all","blockingList","map","store","waitForAll","menuConfs","menuRequests","mergeMenuConfs","NO_AUTH_GUARD","node","BRICK","type","properties","textContent","return","child","route","dispatchBeforePageLoad","scrollTo","handleAsyncAfterMount","dispatchPageLoad","dispatchAnchorLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","isLoggedIn","navConfig","breadcrumb","menuConf","overwrite","items","push"],"sources":["../../../src/internal/Router.ts"],"sourcesContent":["import { Action, locationsAreEqual } from \"history\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport type {\n BreadcrumbItemConf,\n MicroApp,\n StaticMenuConf,\n Storyboard,\n} from \"@next-core/types\";\nimport { HttpAbortError } from \"@next-core/http\";\nimport { uniqueId } from \"lodash\";\nimport { NextHistoryState, NextLocation, getHistory } from \"../history.js\";\nimport { RenderOutput, renderRoutes } from \"./Renderer.js\";\nimport { DataStore } from \"./data/DataStore.js\";\nimport { clearResolveCache } from \"./data/resolveData.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { isOutsideApp, matchStoryboard } from \"./matchStoryboard.js\";\nimport { registerStoryboardFunctions } from \"./compute/StoryboardFunctions.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport {\n applyMode,\n applyTheme,\n getLocalAppsTheme,\n setMode,\n setTheme,\n} from \"../themeAndMode.js\";\nimport {\n _internalApiGetAppInBootstrapData,\n getRuntime,\n hooks,\n} from \"./Runtime.js\";\nimport { getPageInfo } from \"../getPageInfo.js\";\nimport type { RenderBrick, RenderRoot, RuntimeContext } from \"./interfaces.js\";\nimport { resetAllComputedMarks } from \"./compute/markAsComputed.js\";\nimport {\n handleHttpError,\n httpErrorToString,\n isUnauthenticatedError,\n} from \"../handleHttpError.js\";\nimport { abortPendingRequest, initAbortController } from \"./abortController.js\";\nimport { registerCustomTemplates } from \"./registerCustomTemplates.js\";\nimport { fulfilStoryboard } from \"./fulfilStoryboard.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { insertPreviewRoutes } from \"./insertPreviewRoutes.js\";\n\nexport class Router {\n readonly #storyboards: Storyboard[];\n #rendering = false;\n #prevLocation!: NextLocation;\n #nextLocation?: NextLocation;\n #runtimeContext?: RuntimeContext;\n #rendererContext?: RendererContext;\n #rendererContextTrashCan = new Set<RendererContext | undefined>();\n #redirectCount = 0;\n #renderId?: string;\n #currentApp?: MicroApp;\n #previousApp?: MicroApp;\n #navConfig?: {\n breadcrumb?: BreadcrumbItemConf[];\n };\n\n constructor(storyboards: Storyboard[]) {\n this.#storyboards = storyboards;\n\n const history = getHistory();\n window.addEventListener(\"beforeunload\", (event) => {\n const message = this.#getBlockMessageBeforePageLave({});\n // See examples in https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload\n if (message) {\n // Cancel the event\n // If you prevent default behavior in Mozilla Firefox prompt will always be shown\n event.preventDefault();\n // Chrome requires returnValue to be set\n event.returnValue = \"\";\n } else {\n // the absence of a returnValue property on the event will guarantee the browser unload happens\n delete event.returnValue;\n }\n });\n\n history.block((location, action) =>\n this.#getBlockMessageBeforePageLave({ location, action })\n );\n }\n\n getRenderId() {\n return this.#renderId;\n }\n\n getRuntimeContext() {\n return this.#runtimeContext;\n }\n\n getRecentApps() {\n return {\n currentApp: this.#currentApp,\n previousApp: this.#previousApp,\n };\n }\n\n getNavConfig() {\n return this.#navConfig;\n }\n\n #getBlockMessageBeforePageLave(detail: {\n location?: NextLocation;\n action?: Action;\n }): string | undefined {\n const history = getHistory();\n const previousMessage = history.getBlockMessage();\n this.#rendererContext?.dispatchBeforePageLeave(detail);\n const message = history.getBlockMessage();\n if (!previousMessage && message) {\n // Auto unblock only if new block was introduced by `onBeforePageLeave`.\n history.unblock();\n }\n return message;\n }\n\n #safeRedirect(\n to: string,\n state: NextHistoryState | undefined,\n from: NextLocation\n ): void {\n if (this.#redirectCount++ > 10) {\n const message = `Infinite redirect detected: from \"${from.pathname}${from.search}${from.hash}\" to \"${to}\"`;\n // istanbul ignore else: error cannot be caught in test\n if (process.env.NODE_ENV === \"test\") {\n // eslint-disable-next-line no-console\n console.error(message);\n return;\n } else {\n throw new Error(message);\n }\n }\n getHistory().replace(to, state);\n }\n\n bootstrap() {\n initAbortController();\n const history = getHistory();\n this.#prevLocation = history.location;\n history.listen((location, action) => {\n let ignoreRendering = false;\n const omittedLocationProps: Partial<NextLocation> = {\n hash: undefined,\n state: undefined,\n };\n // Omit the \"key\" when checking whether locations are equal in certain situations.\n if (\n // When current location is triggered by browser action of hash link.\n location.key === undefined ||\n // When current location is triggered by browser action of non-push-or-replace,\n // such as goBack or goForward,\n (action === \"POP\" &&\n // and the previous location was triggered by hash link,\n (this.#prevLocation.key === undefined ||\n // or the previous location specified notify false.\n this.#prevLocation.state?.notify === false))\n ) {\n omittedLocationProps.key = undefined;\n }\n if (\n locationsAreEqual(\n { ...this.#prevLocation, ...omittedLocationProps },\n { ...location, ...omittedLocationProps }\n ) ||\n (action !== \"POP\" && location.state?.notify === false)\n ) {\n // Ignore rendering if location not changed except hash, state and optional key.\n // Ignore rendering if notify is `false`.\n ignoreRendering = true;\n }\n if (ignoreRendering) {\n this.#prevLocation = location;\n return;\n }\n abortPendingRequest();\n this.#prevLocation = location;\n this.#rendererContext?.dispatchPageLeave();\n\n if (action === \"POP\") {\n const storyboard = matchStoryboard(\n this.#storyboards,\n location.pathname\n );\n // When a browser action of goBack or goForward is performing,\n // force reload when the target page is a page of an outside app.\n if (isOutsideApp(storyboard)) {\n window.location.reload();\n return;\n }\n }\n\n if (this.#rendering) {\n this.#nextLocation = location;\n } else {\n // devtoolsHookEmit(\"locationChange\");\n this.#queuedRender(location).catch(handleHttpError);\n }\n });\n return this.#queuedRender(history.location);\n }\n\n async #queuedRender(location: NextLocation): Promise<void> {\n this.#rendering = true;\n try {\n await this.#render(location);\n } finally {\n this.#rendering = false;\n if (this.#nextLocation) {\n const nextLocation = this.#nextLocation;\n this.#nextLocation = undefined;\n await this.#queuedRender(nextLocation);\n }\n }\n }\n\n async #render(location: NextLocation): Promise<void> {\n this.#renderId = uniqueId(\"render-id-1\");\n\n resetAllComputedMarks();\n clearResolveCache();\n hooks?.flowApi?.clearCollectWidgetContract();\n\n const history = getHistory();\n history.unblock();\n\n const storyboard = matchStoryboard(this.#storyboards, location.pathname);\n\n const previousApp = this.#runtimeContext?.app;\n if (storyboard?.app) {\n await fulfilStoryboard(storyboard);\n }\n const currentApp = (this.#currentApp = storyboard?.app);\n\n // Storyboard maybe re-assigned, e.g. when open launchpad.\n const appChanged =\n previousApp && currentApp\n ? previousApp.id !== currentApp.id\n : previousApp !== currentApp;\n\n // TODO: handle favicon\n\n // Set `Router::#currentApp` before calling `getFeatureFlags()`\n const flags = getRuntime().getFeatureFlags();\n const prevRendererContext = this.#rendererContext;\n\n const redirectTo = (to: string, state?: NextHistoryState): void => {\n this.#rendererContextTrashCan.add(prevRendererContext);\n this.#safeRedirect(to, state, location);\n };\n\n const redirectToLogin = (): void => {\n const to = flags[\"sso-enabled\"] ? \"/sso-auth/login\" : \"/auth/login\";\n redirectTo(to, { from: location });\n };\n\n const main = document.querySelector(\"#main-mount-point\") as HTMLElement;\n const portal = document.querySelector(\"#portal-mount-point\") as HTMLElement;\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container: main,\n createPortal: portal,\n };\n\n const cleanUpPreviousRender = (): void => {\n unmountTree(main);\n unmountTree(portal);\n\n // Note: redirects can lead to multiple trash renderer contexts.\n this.#rendererContextTrashCan.add(prevRendererContext);\n for (const item of this.#rendererContextTrashCan) {\n if (item) {\n item.dispatchOnUnmount();\n item.dispose();\n }\n }\n this.#rendererContextTrashCan.clear();\n hooks?.messageDispatcher?.reset();\n\n if (appChanged) {\n this.#previousApp = previousApp;\n window.dispatchEvent(\n new CustomEvent(\"app.change\", {\n detail: {\n previousApp,\n currentApp,\n },\n })\n );\n }\n };\n\n setTheme(\n (currentApp &&\n (getLocalAppsTheme()[currentApp.id] || currentApp.theme)) ||\n \"light\"\n );\n setMode(\"default\");\n\n if (currentApp) {\n hooks?.checkInstalledApps?.preCheckInstalledApps(\n storyboard,\n (appId) => !!_internalApiGetAppInBootstrapData(appId)\n );\n\n const rendererContext = (this.#rendererContext = new RendererContext(\n \"page\"\n ));\n\n const runtimeContext: RuntimeContext = (this.#runtimeContext = {\n app: currentApp,\n location,\n query: new URLSearchParams(location.search),\n flags,\n sys: {\n ...hooks?.auth?.getAuth(),\n ...getPageInfo(),\n settings: {\n brand: getRuntime().getBrandSettings(),\n },\n },\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [\n hooks?.checkPermissions?.preCheckPermissions(storyboard),\n ],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n });\n\n this.#navConfig = undefined;\n\n registerCustomTemplates(storyboard);\n registerStoryboardFunctions(storyboard.meta?.functions, currentApp);\n hooks?.flowApi?.collectContract(storyboard.meta?.contracts);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderRoutes(\n renderRoot,\n insertPreviewRoutes(storyboard.routes),\n runtimeContext,\n rendererContext\n );\n if (output.unauthenticated) {\n redirectToLogin();\n return;\n }\n if (output.redirect) {\n redirectTo(output.redirect.path, output.redirect.state);\n return;\n }\n // Reset redirect count if no redirect is set.\n this.#redirectCount = 0;\n\n flushStableLoadBricks();\n\n stores = [\n runtimeContext.ctxStore,\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ];\n\n await Promise.all([\n ...output.blockingList,\n ...stores.map((store) => store.waitForAll()),\n // Todo: load processors only when they would used in current rendering.\n // loadProcessorsImperatively(\n // strictCollectMemberUsage(\n // [storyboard.routes, storyboard.meta?.customTemplates],\n // \"PROCESSORS\",\n // 2\n // ),\n // getBrickPackages()\n // ),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n\n const menuConfs = await Promise.all(output.menuRequests);\n this.#navConfig = mergeMenuConfs(menuConfs);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Router failed:\", error);\n\n if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {\n redirectToLogin();\n return;\n } else if (error instanceof HttpAbortError) {\n this.#rendererContextTrashCan.add(prevRendererContext);\n return;\n } else {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n runtimeContext: null!,\n return: renderRoot,\n },\n blockingList: [],\n menuRequests: [],\n };\n }\n }\n renderRoot.child = output.node;\n\n cleanUpPreviousRender();\n\n if ((output.route && output.route.type !== \"routes\") || failed) {\n if (!failed) {\n // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.\n rendererContext.dispatchBeforePageLoad();\n }\n applyTheme();\n applyMode();\n\n mountTree(renderRoot);\n\n // Scroll to top after each rendering.\n // See https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/guides/scroll-restoration.md\n window.scrollTo(0, 0);\n\n if (!failed) {\n for (const store of stores) {\n store.handleAsyncAfterMount();\n }\n\n rendererContext.dispatchPageLoad();\n rendererContext.dispatchAnchorLoad();\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n\n return;\n }\n } else if (\n !window.NO_AUTH_GUARD &&\n hooks?.auth &&\n !hooks.auth.isLoggedIn()\n ) {\n // Todo(steve): refine after api-gateway supports fetching storyboards before logged in.\n // Redirect to login if no storyboard is matched.\n redirectToLogin();\n return;\n } else {\n cleanUpPreviousRender();\n }\n\n applyTheme();\n applyMode();\n\n const node: RenderBrick = {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: \"Page not found\",\n },\n runtimeContext: null!,\n return: renderRoot,\n };\n renderRoot.child = node;\n\n mountTree(renderRoot);\n\n // Scroll to top after each rendering.\n window.scrollTo(0, 0);\n }\n}\n\nfunction mergeMenuConfs(menuConfs: (StaticMenuConf | undefined)[]) {\n const navConfig = {\n breadcrumb: [] as BreadcrumbItemConf[],\n };\n for (const menuConf of menuConfs) {\n if (menuConf) {\n const { breadcrumb } = menuConf;\n if (breadcrumb) {\n if (breadcrumb.overwrite) {\n navConfig.breadcrumb = breadcrumb.items;\n } else {\n navConfig.breadcrumb.push(...breadcrumb.items);\n }\n }\n }\n }\n return navConfig;\n}\n"],"mappings":";;;;;;;AAAA,SAAiBA,iBAAiB,QAAQ,SAAS;AACnD,SAASC,qBAAqB,QAAQ,mBAAmB;AAOzD,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAAyCC,UAAU,QAAQ,eAAe;AAC1E,SAAuBC,YAAY,QAAQ,eAAe;AAC1D,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,YAAY;AACnD,SAASC,YAAY,EAAEC,eAAe,QAAQ,sBAAsB;AACpE,SAASC,2BAA2B,QAAQ,kCAAkC;AAC9E,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SACEC,SAAS,EACTC,UAAU,EACVC,iBAAiB,EACjBC,OAAO,EACPC,QAAQ,QACH,oBAAoB;AAC3B,SACEC,iCAAiC,EACjCC,UAAU,EACVC,KAAK,QACA,cAAc;AACrB,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A,UAAU,CAACsE,KAAK,GAAGN,IAAI;IAEvBzM,SAAS,CAACyI,UAAU,CAAC;;IAErB;IACApF,MAAM,CAAC6J,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;EACvB,CAAC;EAAA,OAAA3F,QAAA,CAAAN,KAAA,OAAAC,SAAA;AAAA;AAGH,SAASqF,cAAcA,CAACF,SAAyC,EAAE;EACjE,IAAMsB,SAAS,GAAG;IAChBC,UAAU,EAAE;EACd,CAAC;EACD,KAAK,IAAMC,QAAQ,IAAIxB,SAAS,EAAE;IAChC,IAAIwB,QAAQ,EAAE;MACZ,IAAM;QAAED;MAAW,CAAC,GAAGC,QAAQ;MAC/B,IAAID,UAAU,EAAE;QACd,IAAIA,UAAU,CAACE,SAAS,EAAE;UACxBH,SAAS,CAACC,UAAU,GAAGA,UAAU,CAACG,KAAK;QACzC,CAAC,MAAM;UACLJ,SAAS,CAACC,UAAU,CAACI,IAAI,CAAC,GAAGJ,UAAU,CAACG,KAAK,CAAC;QAChD;MACF;IACF;EACF;EACA,OAAOJ,SAAS;AAClB"}
@@ -15,6 +15,7 @@ import { NS, locales } from "./i18n.js";
15
15
  import { loadNotificationService } from "../Notification.js";
16
16
  import { loadDialogService } from "../Dialog.js";
17
17
  import { injectedBrickPackages } from "./injected.js";
18
+ import { listenDevtoolsEagerly } from "./devtools.js";
18
19
  var runtime;
19
20
 
20
21
  // Allow inject bootstrap data in a runtime other than Brick Next.
@@ -25,6 +26,7 @@ export function createRuntime(options) {
25
26
  if (runtime) {
26
27
  throw new Error("Cannot create multiple runtimes");
27
28
  }
29
+ listenDevtoolsEagerly();
28
30
  hooks = options === null || options === void 0 ? void 0 : options.hooks;
29
31
  initializeI18n(NS, locales);
30
32
  moment.locale(i18n.language);