@next-core/runtime 1.39.0 → 1.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,9 @@ function unstable_createRoot(container, {
45
45
  context,
46
46
  functions,
47
47
  templates,
48
- i18n: i18nData
48
+ i18n: i18nData,
49
+ url,
50
+ app
49
51
  } = {}) {
50
52
  if (unmounted) {
51
53
  throw new Error("The root is unmounted and cannot be rendered any more");
@@ -63,23 +65,33 @@ function unstable_createRoot(container, {
63
65
  tplStateStoreMap: new Map(),
64
66
  formStateStoreMap: new Map()
65
67
  };
68
+ if (url) {
69
+ const urlObj = new URL(url);
70
+ runtimeContext.query = urlObj.searchParams;
71
+ runtimeContext.location = {
72
+ pathname: urlObj.pathname,
73
+ search: urlObj.search,
74
+ hash: urlObj.hash,
75
+ state: undefined
76
+ };
77
+ }
66
78
  const renderRoot = {
67
79
  tag: _enums.RenderTag.ROOT,
68
80
  container,
69
81
  createPortal
70
82
  };
71
83
  if (scope === "page") {
72
- var _clearI18nBundles;
84
+ var _app, _clearI18nBundles;
73
85
  (0, _themeAndMode.setTheme)(theme !== null && theme !== void 0 ? theme : "light");
74
86
  (0, _themeAndMode.setMode)("default");
75
87
  (0, _setUIVersion.setUIVersion)(uiVersion);
76
- const demoApp = {
88
+ (_app = app) !== null && _app !== void 0 ? _app : app = {
77
89
  id: "demo",
78
90
  homepage: "/demo"
79
91
  };
80
- runtimeContext.app = demoApp;
92
+ runtimeContext.app = app;
81
93
  const demoStoryboard = {
82
- app: demoApp,
94
+ app,
83
95
  meta: {
84
96
  i18n: i18nData,
85
97
  customTemplates: templates
@@ -94,7 +106,7 @@ function unstable_createRoot(container, {
94
106
  (0, _registerCustomTemplates.registerCustomTemplates)(demoStoryboard);
95
107
 
96
108
  // Register functions.
97
- (0, _StoryboardFunctions.registerStoryboardFunctions)(functions, demoApp);
109
+ (0, _StoryboardFunctions.registerStoryboardFunctions)(functions, app);
98
110
  }
99
111
  runtimeContext.ctxStore.define(context, runtimeContext);
100
112
  let failed = false;
@@ -1 +1 @@
1
- {"version":3,"file":"createRoot.js","names":["_lodash","require","_Renderer","_RendererContext","_DataStore","_mount","_handleHttpError","_themeAndMode","_enums","_StoryboardFunctions","_registerAppI18n","_registerCustomTemplates","_setUIVersion","unstable_createRoot","container","portal","_portal","scope","unknownBricks","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","theme","uiVersion","context","functions","templates","i18n","i18nData","Error","bricks","concat","previousRendererContext","renderId","uniqueId","RendererContext","runtimeContext","ctxStore","DataStore","undefined","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","renderRoot","tag","RenderTag","ROOT","_clearI18nBundles","setTheme","setMode","setUIVersion","demoApp","id","homepage","app","demoStoryboard","meta","customTemplates","registerAppI18n","registerCustomTemplates","registerStoryboardFunctions","define","failed","output","stores","renderBricks","getDataStores","postAsyncRender","error","node","BRICK","type","properties","textContent","httpErrorToString","return","blockingList","child","dispatchOnUnmount","dispose","unmountTree","dispatchBeforePageLoad","applyTheme","applyMode","mountTree","window","scrollTo","store","mountAsyncData","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport {\n RenderOutput,\n getDataStores,\n postAsyncRender,\n renderBricks,\n} from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\nimport { setUIVersion } from \"./setUIVersion.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n uiVersion?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | DocumentFragment,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n uiVersion,\n context,\n functions,\n templates,\n i18n: i18nData,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n const renderId = uniqueId(\"render-id-\");\n rendererContext = new RendererContext(scope, { unknownBricks, renderId });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n setUIVersion(uiVersion);\n\n 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 );\n\n stores = getDataStores(runtimeContext);\n await postAsyncRender(output, runtimeContext, stores);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.mountAsyncData();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAMA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,wBAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AA4BO,SAASY,mBAAmBA,CACjCC,SAAyC,EACzC;EAAEC,MAAM,EAAEC,OAAO;EAAEC,KAAK,GAAG,UAAU;EAAEC;AAAiC,CAAC,GAAG,CAAC,CAAC,EAC9E;EACA,IAAIH,MAAM,GAAGC,OAAO;EACpB,IAAIG,YAAwC;EAC5C,IAAIH,OAAO,EAAE;IACXG,YAAY,GAAGH,OAAO;EACxB,CAAC,MAAM;IACL;IACAG,YAAY,GAAGA,CAAA,KAAM;MACnBJ,MAAM,GAAGK,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;MACtCN,MAAM,CAACO,KAAK,CAACC,QAAQ,GAAG,UAAU;MAClCR,MAAM,CAACO,KAAK,CAACE,KAAK,GAAGT,MAAM,CAACO,KAAK,CAACG,MAAM,GAAG,GAA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EAAE;QACV,IAAA6E,kBAAW,EAAC7E,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAAC4F,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"createRoot.js","names":["_lodash","require","_Renderer","_RendererContext","_DataStore","_mount","_handleHttpError","_themeAndMode","_enums","_StoryboardFunctions","_registerAppI18n","_registerCustomTemplates","_setUIVersion","unstable_createRoot","container","portal","_portal","scope","unknownBricks","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","theme","uiVersion","context","functions","templates","i18n","i18nData","url","app","Error","bricks","concat","previousRendererContext","renderId","uniqueId","RendererContext","runtimeContext","ctxStore","DataStore","undefined","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","urlObj","URL","query","searchParams","location","pathname","search","hash","state","renderRoot","tag","RenderTag","ROOT","_app","_clearI18nBundles","setTheme","setMode","setUIVersion","id","homepage","demoStoryboard","meta","customTemplates","registerAppI18n","registerCustomTemplates","registerStoryboardFunctions","define","failed","output","stores","renderBricks","getDataStores","postAsyncRender","error","node","BRICK","type","properties","textContent","httpErrorToString","return","blockingList","child","dispatchOnUnmount","dispose","unmountTree","dispatchBeforePageLoad","applyTheme","applyMode","mountTree","window","scrollTo","store","mountAsyncData","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport {\n RenderOutput,\n getDataStores,\n postAsyncRender,\n renderBricks,\n} from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\nimport { setUIVersion } from \"./setUIVersion.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n uiVersion?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n url?: string;\n app?: MicroApp;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | DocumentFragment,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n uiVersion,\n context,\n functions,\n templates,\n i18n: i18nData,\n url,\n app,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n const renderId = uniqueId(\"render-id-\");\n rendererContext = new RendererContext(scope, { unknownBricks, renderId });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n if (url) {\n const urlObj = new URL(url);\n runtimeContext.query = urlObj.searchParams;\n runtimeContext.location = {\n pathname: urlObj.pathname,\n search: urlObj.search,\n hash: urlObj.hash,\n state: undefined,\n };\n }\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n setUIVersion(uiVersion);\n\n app ??= {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = app;\n const demoStoryboard = {\n app,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, app);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext,\n [],\n {}\n );\n\n stores = getDataStores(runtimeContext);\n await postAsyncRender(output, runtimeContext, stores);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.mountAsyncData();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAMA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,wBAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AA8BO,SAASY,mBAAmBA,CACjCC,SAAyC,EACzC;EAAEC,MAAM,EAAEC,OAAO;EAAEC,KAAK,GAAG,UAAU;EAAEC;AAAiC,CAAC,GAAG,CAAC,CAAC,EAC9E;EACA,IAAIH,MAAM,GAAGC,OAAO;EACpB,IAAIG,YAAwC;EAC5C,IAAIH,O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AC;MACb;MAEA,IAAAC,gBAAS,EAACxC,UAAU,CAAC;MAErB,IAAIjD,KAAK,KAAK,MAAM,EAAE;QACpB0F,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;MACvB;MAEA,IAAI,CAACxB,MAAM,EAAE;QACX,KAAK,MAAMyB,KAAK,IAAIvB,MAAM,EAAE;UAC1BuB,KAAK,CAACC,cAAc,CAAC,CAAC;QACxB;QAEA,IAAI7F,KAAK,KAAK,MAAM,EAAE;UACpBY,eAAe,CAACkF,gBAAgB,CAAC,CAAC;UAClC;QACF;QACAlF,eAAe,CAACmF,eAAe,CAAC,CAAC;QACjCnF,eAAe,CAACoF,wBAAwB,CAAC,CAAC;QAC1CpF,eAAe,CAACqF,qBAAqB,CAAC,CAAC;QACvCrF,eAAe,CAACsF,2BAA2B,CAAC,CAAC;MAC/C;IACF,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAIxF,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB,IAAA0E,kBAAW,EAACxF,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACV,IAAAuF,kBAAW,EAACvF,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAACsG,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -222,6 +222,9 @@ runtimeContext, options = {}, isAsync) {
222
222
  globalVariables[variableName] = location.hash ? location.hash.substring(1) : null;
223
223
  break;
224
224
  case "APP":
225
+ if (app == null) {
226
+ throw new ReferenceError(`APP is not defined, in "${raw}"`);
227
+ }
225
228
  globalVariables[variableName] = {
226
229
  ...(0, _lodash.cloneDeep)(app),
227
230
  getMenu: _Runtime.hooks === null || _Runtime.hooks === void 0 || (_hooks$menu = _Runtime.hooks.menu) === null || _hooks$menu === void 0 ? void 0 : _hooks$menu.getMenuById
@@ -229,7 +232,7 @@ runtimeContext, options = {}, isAsync) {
229
232
  break;
230
233
  case "CTX":
231
234
  globalVariables[variableName] = (0, _proxyFactories.getDynamicReadOnlyProxy)({
232
- get(target, key) {
235
+ get(_target, key) {
233
236
  return ctxStore.getValue(key);
234
237
  },
235
238
  ownKeys() {
@@ -248,7 +251,7 @@ runtimeContext, options = {}, isAsync) {
248
251
  break;
249
252
  case "FORM_STATE":
250
253
  globalVariables[variableName] = (0, _proxyFactories.getDynamicReadOnlyProxy)({
251
- get(target, key) {
254
+ get(_target, key) {
252
255
  return formStateStore.getValue(key);
253
256
  },
254
257
  ownKeys() {
@@ -288,6 +291,9 @@ runtimeContext, options = {}, isAsync) {
288
291
  globalVariables[variableName] = (0, _Runtime.getRuntime)().getMiscSettings();
289
292
  break;
290
293
  case "PARAMS":
294
+ if (query == null) {
295
+ throw new ReferenceError(`PARAMS is not defined, in "${raw}"`);
296
+ }
291
297
  globalVariables[variableName] = new URLSearchParams(query);
292
298
  break;
293
299
  case "PATH":
@@ -298,13 +304,13 @@ runtimeContext, options = {}, isAsync) {
298
304
  break;
299
305
  case "PROCESSORS":
300
306
  globalVariables[variableName] = (0, _proxyFactories.getDynamicReadOnlyProxy)({
301
- get(target, key) {
307
+ get(_target, key) {
302
308
  const pkg = _CustomProcessors.customProcessors.get(key);
303
309
  if (!pkg) {
304
310
  throw new Error(`'PROCESSORS.${key}' is not registered! Have you installed the relevant brick package?`);
305
311
  }
306
312
  return (0, _proxyFactories.getDynamicReadOnlyProxy)({
307
- get(t, k) {
313
+ get(_t, k) {
308
314
  return pkg.get(k);
309
315
  },
310
316
  ownKeys() {
@@ -323,9 +329,15 @@ runtimeContext, options = {}, isAsync) {
323
329
  });
324
330
  break;
325
331
  case "QUERY":
332
+ if (query == null) {
333
+ throw new ReferenceError(`QUERY is not defined, in "${raw}"`);
334
+ }
326
335
  globalVariables[variableName] = Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
327
336
  break;
328
337
  case "QUERY_ARRAY":
338
+ if (query == null) {
339
+ throw new ReferenceError(`QUERY_ARRAY is not defined, in "${raw}"`);
340
+ }
329
341
  globalVariables[variableName] = Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
330
342
  // case "SEGUE":
331
343
  break;
@@ -343,7 +355,7 @@ runtimeContext, options = {}, isAsync) {
343
355
  // eslint-disable-next-line no-fallthrough
344
356
  case "STATE":
345
357
  globalVariables[variableName] = (0, _proxyFactories.getDynamicReadOnlyProxy)({
346
- get(target, key) {
358
+ get(_target, key) {
347
359
  return tplStateStore.getValue(key);
348
360
  },
349
361
  ownKeys() {
@@ -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","property","console","getItem","getStorageItem","getMedia","getRuntime","getMiscSettings","URLSearchParams","params","pathname","pkg","customProcessors","t","k","processor","namespace","split","fromEntries","getAll","warnAboutStrictMode","widgetFunctions","images","widgetImagesFactory","widgetI18nFactory","assign","getGeneralGlobals","storyboardFunctions","appendI18nNamespace","result","cook","expression","source","supply","detail","context","devtoolsHookEmit"],"sources":["../../../../src/internal/compute/evaluate.ts"],"sourcesContent":["import {\n cook,\n preevaluate,\n PreevaluateResult,\n shouldAllowRecursiveEvaluations,\n} from \"@next-core/cook\";\nimport { loadProcessorsImperatively } from \"@next-core/loader\";\nimport { supply } from \"@next-core/supply\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport {\n strictCollectMemberUsage,\n collectAppGetMenuUsage,\n collectInstalledAppsHasUsage,\n MemberCallUsage,\n} from \"@next-core/utils/storyboard\";\nimport { cloneDeep, omit } from \"lodash\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { customProcessors } from \"../../CustomProcessors.js\";\nimport {\n checkPermissionsUsage,\n storyboardFunctions,\n} from \"./StoryboardFunctions.js\";\nimport { getGeneralGlobals } from \"./getGeneralGlobals.js\";\nimport {\n getDynamicReadOnlyProxy,\n getReadOnlyProxy,\n} from \"../proxyFactories.js\";\nimport { devtoolsHookEmit, getDevHook } from \"../devtools.js\";\nimport { getMedia } from \"../mediaQuery.js\";\nimport { getStorageItem } from \"./getStorageItem.js\";\nimport {\n _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 case \"INDEX\": {\n const property =\n variableName === \"ITEM\" ? \"forEachItem\" : \"forEachIndex\";\n if (!hasOwnProperty(runtimeContext, property)) {\n // eslint-disable-next-line no-console\n console.error(\n `Using \\`${variableName}\\` but no \\`:forEach\\` is found, check your expression: \"${raw}\"`\n );\n } else {\n globalVariables[variableName] = runtimeContext[property];\n }\n break;\n }\n case \"LOCAL_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"local\"),\n });\n break;\n case \"MEDIA\":\n globalVariables[variableName] = getReadOnlyProxy(getMedia());\n break;\n case \"MISC\":\n globalVariables[variableName] = getRuntime().getMiscSettings();\n break;\n case \"PARAMS\":\n globalVariables[variableName] = new URLSearchParams(query);\n break;\n case \"PATH\":\n globalVariables[variableName] = getReadOnlyProxy(\n match?.params ?? {}\n );\n break;\n case \"PATH_NAME\":\n globalVariables[variableName] = location.pathname;\n break;\n case \"PROCESSORS\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n const pkg = customProcessors.get(key as string);\n if (!pkg) {\n throw new Error(\n `'PROCESSORS.${\n key as string\n }' is not registered! Have you installed the relevant brick package?`\n );\n }\n return getDynamicReadOnlyProxy({\n get(t, k) {\n return pkg.get(k as string);\n },\n ownKeys() {\n return Array.from(pkg.keys());\n },\n });\n },\n ownKeys() {\n const keys = new Set<string>();\n for (const processor of usedProcessors) {\n const namespace = processor.split(\".\")[0];\n keys.add(namespace);\n }\n return Array.from(keys);\n },\n });\n break;\n case \"QUERY\":\n 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: 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,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,KAAK,gBAAgB;YACnB/F,eAAe,CAAC2D,YAAY,CAAC,GAAGrE,cAAK,aAALA,cAAK,gBAAA0D,aAAA,GAAL1D,cAAK,CAAE0G,MAAM,cAAAhD,aAAA,uBAAbA,aAAA,CAAeiD,mBAAmB;YAClE;UACF,KAAK,iBAAiB;YACpBjG,eAAe,CAAC2D,YAAY,CAAC,GAAGuC,6BAAiB;YACjD;QACJ;MACF;MAEA9F,MAAM,CAAC+F,MAAM,CACXnG,eAAe,EACf,IAAAoG,oCAAiB,EAACjH,SAAS,CAACc,qBAAqB,EAAE;QACjDoG,mBAAmB,EAAnBA,wCAAmB;QACnBpD,GAAG,EAAEA,GAAG;QACRqD,mBAAmB,EAAElI,cAAc,CAACkI;MACtC,CAAC,CACH,CAAC;MAED,IAAI;QACF,MAAMC,MAAM,GAAG,IAAAC,UAAI,EAACrH,SAAS,CAACsH,UAAU,EAAEtH,SAAS,CAACuH,MAAM,EAAE;UAC1D1G,eAAe,EAAE,IAAA2G,cAAM,EACrBxH,SAAS,CAACc,qBAAqB,EAC/BD,eACF;QACF,CAAC,CAAC;QACF,MAAM4G,MAAM,GAAG;UAAEvJ,GAAG;UAAEwJ,OAAO,EAAE7G,eAAe;UAAEuG;QAAO,CAAC;QACxD,IAAAO,0BAAgB,EAAC,YAAY,EAAEF,MAAM,CAAC;QACtC,OAAOL,MAAM;MACf,CAAC,CAAC,OAAOvI,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","ignoreList":[]}
1
+ {"version":3,"file":"evaluate.js","names":["_cook","require","_loader","_supply","_general","_storyboard","_lodash","_CustomProcessors","_StoryboardFunctions","_getGeneralGlobals","_proxyFactories","_devtools","_mediaQuery","_getStorageItem","_Runtime","_utils","_WidgetFunctions","_WidgetI18n","_hasInstalledApp","_isStrictMode","_utils2","_resolveData","_computeRealValue","symbolForRaw","Symbol","for","symbolForContext","isPreEvaluated","raw","getPreEvaluatedRaw","pre","shouldDismissMarkingComputed","shouldAllowRecursiveEvaluations","possibleErrorConstructs","WeakSet","SyntaxError","TypeError","ReferenceError","getCookErrorConstructor","error","has","constructor","asyncEvaluate","runtimeContext","options","blockingList","run","lowLevelEvaluate","Promise","all","evaluate","isAsync","passByRuntimeContext","omit","menuUsage","usedArgs","Set","hasAppUsage","precooked","preevaluate","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","property","console","getItem","getStorageItem","getMedia","getRuntime","getMiscSettings","URLSearchParams","params","pathname","pkg","customProcessors","_t","k","processor","namespace","split","fromEntries","getAll","warnAboutStrictMode","widgetFunctions","images","widgetImagesFactory","widgetI18nFactory","assign","getGeneralGlobals","storyboardFunctions","appendI18nNamespace","result","cook","expression","source","supply","detail","context","devtoolsHookEmit"],"sources":["../../../../src/internal/compute/evaluate.ts"],"sourcesContent":["import {\n cook,\n preevaluate,\n PreevaluateResult,\n shouldAllowRecursiveEvaluations,\n} from \"@next-core/cook\";\nimport { loadProcessorsImperatively } from \"@next-core/loader\";\nimport { supply } from \"@next-core/supply\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport {\n strictCollectMemberUsage,\n collectAppGetMenuUsage,\n collectInstalledAppsHasUsage,\n MemberCallUsage,\n} from \"@next-core/utils/storyboard\";\nimport { cloneDeep, omit } from \"lodash\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { customProcessors } from \"../../CustomProcessors.js\";\nimport {\n checkPermissionsUsage,\n storyboardFunctions,\n} from \"./StoryboardFunctions.js\";\nimport { getGeneralGlobals } from \"./getGeneralGlobals.js\";\nimport {\n getDynamicReadOnlyProxy,\n getReadOnlyProxy,\n} from \"../proxyFactories.js\";\nimport { devtoolsHookEmit, getDevHook } from \"../devtools.js\";\nimport { getMedia } from \"../mediaQuery.js\";\nimport { getStorageItem } from \"./getStorageItem.js\";\nimport {\n _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 if (app == null) {\n throw new ReferenceError(`APP is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = {\n ...cloneDeep(app),\n getMenu: hooks?.menu?.getMenuById,\n };\n break;\n case \"CTX\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n 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 case \"INDEX\": {\n const property =\n variableName === \"ITEM\" ? \"forEachItem\" : \"forEachIndex\";\n if (!hasOwnProperty(runtimeContext, property)) {\n // eslint-disable-next-line no-console\n console.error(\n `Using \\`${variableName}\\` but no \\`:forEach\\` is found, check your expression: \"${raw}\"`\n );\n } else {\n globalVariables[variableName] = runtimeContext[property];\n }\n break;\n }\n case \"LOCAL_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"local\"),\n });\n break;\n case \"MEDIA\":\n globalVariables[variableName] = getReadOnlyProxy(getMedia());\n break;\n case \"MISC\":\n globalVariables[variableName] = getRuntime().getMiscSettings();\n break;\n case \"PARAMS\":\n if (query == null) {\n throw new ReferenceError(`PARAMS is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = new URLSearchParams(query);\n break;\n case \"PATH\":\n globalVariables[variableName] = getReadOnlyProxy(\n match?.params ?? {}\n );\n break;\n case \"PATH_NAME\":\n globalVariables[variableName] = location.pathname;\n break;\n case \"PROCESSORS\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n const pkg = customProcessors.get(key as string);\n if (!pkg) {\n throw new Error(\n `'PROCESSORS.${\n key as string\n }' is not registered! Have you installed the relevant brick package?`\n );\n }\n return getDynamicReadOnlyProxy({\n get(_t, k) {\n return pkg.get(k as string);\n },\n ownKeys() {\n return Array.from(pkg.keys());\n },\n });\n },\n ownKeys() {\n const keys = new Set<string>();\n for (const processor of usedProcessors) {\n const namespace = processor.split(\".\")[0];\n keys.add(namespace);\n }\n return Array.from(keys);\n },\n });\n break;\n case \"QUERY\":\n if (query == null) {\n throw new ReferenceError(`QUERY is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.get(key)])\n );\n break;\n case \"QUERY_ARRAY\":\n if (query == null) {\n throw new ReferenceError(\n `QUERY_ARRAY is not defined, in \"${raw}\"`\n );\n }\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.getAll(key)])\n );\n // case \"SEGUE\":\n break;\n case \"SESSION_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"session\"),\n });\n break;\n // istanbul ignore next\n case \"TPL\":\n warnAboutStrictMode(\n strict,\n 'Using \"TPL\" in expression',\n `check your expression: \"${raw}\"`\n );\n if (strict) {\n break;\n }\n // eslint-disable-next-line no-fallthrough\n case \"STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n return tplStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedStates);\n },\n });\n break;\n case \"SYS\":\n globalVariables[variableName] = getReadOnlyProxy(sys ?? {});\n break;\n case \"__WIDGET_FN__\":\n globalVariables[variableName] = widgetFunctions;\n break;\n case \"__WIDGET_IMG__\":\n globalVariables[variableName] = hooks?.images?.widgetImagesFactory;\n break;\n case \"__WIDGET_I18N__\":\n globalVariables[variableName] = widgetI18nFactory;\n break;\n }\n }\n\n Object.assign(\n globalVariables,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n storyboardFunctions,\n app: app,\n appendI18nNamespace: runtimeContext.appendI18nNamespace,\n })\n );\n\n try {\n const result = cook(precooked.expression, precooked.source, {\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n globalVariables\n ),\n });\n const detail = { raw, context: globalVariables, result };\n devtoolsHookEmit(\"evaluation\", detail);\n return result;\n } catch (error: any) {\n const message = `${error.message}, in \"${raw}\"`;\n const errorConstructor = getCookErrorConstructor(error);\n throw new errorConstructor(message);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AAIA,IAAAQ,kB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ACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -44,7 +44,9 @@ export function unstable_createRoot(container) {
44
44
  context,
45
45
  functions,
46
46
  templates,
47
- i18n: i18nData
47
+ i18n: i18nData,
48
+ url,
49
+ app
48
50
  } = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
49
51
  if (unmounted) {
50
52
  throw new Error("The root is unmounted and cannot be rendered any more");
@@ -62,23 +64,33 @@ export function unstable_createRoot(container) {
62
64
  tplStateStoreMap: new Map(),
63
65
  formStateStoreMap: new Map()
64
66
  };
67
+ if (url) {
68
+ var urlObj = new URL(url);
69
+ runtimeContext.query = urlObj.searchParams;
70
+ runtimeContext.location = {
71
+ pathname: urlObj.pathname,
72
+ search: urlObj.search,
73
+ hash: urlObj.hash,
74
+ state: undefined
75
+ };
76
+ }
65
77
  var renderRoot = {
66
78
  tag: RenderTag.ROOT,
67
79
  container,
68
80
  createPortal
69
81
  };
70
82
  if (scope === "page") {
71
- var _clearI18nBundles;
83
+ var _app, _clearI18nBundles;
72
84
  setTheme(theme !== null && theme !== void 0 ? theme : "light");
73
85
  setMode("default");
74
86
  setUIVersion(uiVersion);
75
- var demoApp = {
87
+ (_app = app) !== null && _app !== void 0 ? _app : app = {
76
88
  id: "demo",
77
89
  homepage: "/demo"
78
90
  };
79
- runtimeContext.app = demoApp;
91
+ runtimeContext.app = app;
80
92
  var demoStoryboard = {
81
- app: demoApp,
93
+ app,
82
94
  meta: {
83
95
  i18n: i18nData,
84
96
  customTemplates: templates
@@ -93,7 +105,7 @@ export function unstable_createRoot(container) {
93
105
  registerCustomTemplates(demoStoryboard);
94
106
 
95
107
  // Register functions.
96
- registerStoryboardFunctions(functions, demoApp);
108
+ registerStoryboardFunctions(functions, app);
97
109
  }
98
110
  runtimeContext.ctxStore.define(context, runtimeContext);
99
111
  var failed = false;
@@ -1 +1 @@
1
- {"version":3,"file":"createRoot.js","names":["uniqueId","getDataStores","postAsyncRender","renderBricks","RendererContext","DataStore","mountTree","unmountTree","httpErrorToString","applyMode","applyTheme","setMode","setTheme","RenderTag","registerStoryboardFunctions","registerAppI18n","registerCustomTemplates","setUIVersion","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","uiVersion","context","functions","templates","i18n","i18nData","Error","bricks","concat","previousRendererContext","renderId","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","renderRoot","tag","ROOT","_clearI18nBundles","demoApp","id","homepage","app","demoStoryboard","meta","customTemplates","define","failed","output","stores","error","node","BRICK","type","properties","textContent","return","blockingList","child","dispatchOnUnmount","dispose","dispatchBeforePageLoad","window","scrollTo","store","mountAsyncData","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport {\n RenderOutput,\n getDataStores,\n postAsyncRender,\n renderBricks,\n} from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\nimport { setUIVersion } from \"./setUIVersion.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n uiVersion?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | DocumentFragment,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n uiVersion,\n context,\n functions,\n templates,\n i18n: i18nData,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n const renderId = uniqueId(\"render-id-\");\n rendererContext = new RendererContext(scope, { unknownBricks, renderId });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n setUIVersion(uiVersion);\n\n 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 );\n\n stores = getDataStores(runtimeContext);\n await postAsyncRender(output, runtimeContext, stores);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.mountAsyncData();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";AAUA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAEEC,aAAa,EACbC,eAAe,EACfC,YAAY,QACP,wBAAwB;AAC/B,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,SAAS,QAAQ,8BAA8B;AAExD,SAASC,SAAS,EAAEC,WAAW,QAAQ,qBAAqB;AAC5D,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,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;AAC/E,SAASC,YAAY,QAAQ,mBAAmB;AA4BhD,OAAO,SAASC,mBAAmBA,CACjCC,SAAyC,EAEzC;EAAA,IADA;IAAEC,MAAM,EAAEC,OAAO;IAAEC,KAAK,GAAG,UAAU;IAAEC;EAAiC,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE9E,IAAIJ,MAAM,GAAGC,OAAO;EACpB,IAAIM,YAAwC;EAC5C,IAAIN,OAAO,EAAE;IACXM,YAAY,GAAGN,OAAO;EACxB,CAAC,MAAM;IACL;IACAM,YAAY,GAAGA,CAAA,KAAM;MACnBP,MAAM,GAAGQ,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;MACtCT,MAAM,CAACU,KAAK,CAACC,QAAQ,GAAG,UAAU;MAClCX,MAAM,CAACU,KAAK,CAACE,KAAK,GAAGZ,MAAM,CAACU,KAAK,CAACG,MAAM,GAAG,GAAG;MAC9CL,QAAQ,CAACM,IAAI,CAACC,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CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAAC8E,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"createRoot.js","names":["uniqueId","getDataStores","postAsyncRender","renderBricks","RendererContext","DataStore","mountTree","unmountTree","httpErrorToString","applyMode","applyTheme","setMode","setTheme","RenderTag","registerStoryboardFunctions","registerAppI18n","registerCustomTemplates","setUIVersion","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","uiVersion","context","functions","templates","i18n","i18nData","url","app","Error","bricks","concat","previousRendererContext","renderId","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","urlObj","URL","query","searchParams","location","pathname","search","hash","state","renderRoot","tag","ROOT","_app","_clearI18nBundles","id","homepage","demoStoryboard","meta","customTemplates","define","failed","output","stores","error","node","BRICK","type","properties","textContent","return","blockingList","child","dispatchOnUnmount","dispose","dispatchBeforePageLoad","window","scrollTo","store","mountAsyncData","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport {\n RenderOutput,\n getDataStores,\n postAsyncRender,\n renderBricks,\n} from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\nimport { setUIVersion } from \"./setUIVersion.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n uiVersion?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n url?: string;\n app?: MicroApp;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | DocumentFragment,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n uiVersion,\n context,\n functions,\n templates,\n i18n: i18nData,\n url,\n app,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n const renderId = uniqueId(\"render-id-\");\n rendererContext = new RendererContext(scope, { unknownBricks, renderId });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n if (url) {\n const urlObj = new URL(url);\n runtimeContext.query = urlObj.searchParams;\n runtimeContext.location = {\n pathname: urlObj.pathname,\n search: urlObj.search,\n hash: urlObj.hash,\n state: undefined,\n };\n }\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n setUIVersion(uiVersion);\n\n app ??= {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = app;\n const demoStoryboard = {\n app,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, app);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext,\n [],\n {}\n );\n\n stores = getDataStores(runtimeContext);\n await postAsyncRender(output, runtimeContext, stores);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.mountAsyncData();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";AAUA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAEEC,aAAa,EACbC,eAAe,EACfC,YAAY,QACP,wBAAwB;AAC/B,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,SAAS,QAAQ,8BAA8B;AAExD,SAASC,SAAS,EAAEC,WAAW,QAAQ,qBAAqB;AAC5D,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,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;AAC/E,SAASC,YAAY,QAAQ,mBAAmB;AA8BhD,OAAO,SAASC,mBAAmBA,CACjCC,SAAyC,EAEzC;EAAA,IADA;IAAEC,MAAM,EAAEC,OAAO;IAAEC,KAAK,GAAG,UAAU;IAAEC;EAAiC,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE9E,I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9C,eAAe,CAAC4D,sBAAsB,CAAC,CAAC;UAC1C;UAEAvF,UAAU,CAAC,CAAC;UACZD,SAAS,CAAC,CAAC;QACb;QAEAH,SAAS,CAACkE,UAAU,CAAC;QAErB,IAAIlD,KAAK,KAAK,MAAM,EAAE;UACpB4E,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB;QAEA,IAAI,CAAChB,MAAM,EAAE;UACX,KAAK,IAAMiB,KAAK,IAAIf,MAAM,EAAE;YAC1Be,KAAK,CAACC,cAAc,CAAC,CAAC;UACxB;UAEA,IAAI/E,KAAK,KAAK,MAAM,EAAE;YACpBe,eAAe,CAACiE,gBAAgB,CAAC,CAAC;YAClC;UACF;UACAjE,eAAe,CAACkE,eAAe,CAAC,CAAC;UACjClE,eAAe,CAACmE,wBAAwB,CAAC,CAAC;UAC1CnE,eAAe,CAACoE,qBAAqB,CAAC,CAAC;UACvCpE,eAAe,CAACqE,2BAA2B,CAAC,CAAC;QAC/C;MAAC;IACH,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAIvE,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB7B,WAAW,CAACY,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACVb,WAAW,CAACa,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAACwF,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -218,13 +218,16 @@ runtimeContext) {
218
218
  globalVariables[variableName] = location.hash ? location.hash.substring(1) : null;
219
219
  break;
220
220
  case "APP":
221
+ if (app == null) {
222
+ throw new ReferenceError("APP is not defined, in \"".concat(raw, "\""));
223
+ }
221
224
  globalVariables[variableName] = _objectSpread(_objectSpread({}, cloneDeep(app)), {}, {
222
225
  getMenu: hooks === null || hooks === void 0 || (_hooks$menu = hooks.menu) === null || _hooks$menu === void 0 ? void 0 : _hooks$menu.getMenuById
223
226
  });
224
227
  break;
225
228
  case "CTX":
226
229
  globalVariables[variableName] = getDynamicReadOnlyProxy({
227
- get(target, key) {
230
+ get(_target, key) {
228
231
  return ctxStore.getValue(key);
229
232
  },
230
233
  ownKeys() {
@@ -243,7 +246,7 @@ runtimeContext) {
243
246
  break;
244
247
  case "FORM_STATE":
245
248
  globalVariables[variableName] = getDynamicReadOnlyProxy({
246
- get(target, key) {
249
+ get(_target, key) {
247
250
  return formStateStore.getValue(key);
248
251
  },
249
252
  ownKeys() {
@@ -283,6 +286,9 @@ runtimeContext) {
283
286
  globalVariables[variableName] = getRuntime().getMiscSettings();
284
287
  break;
285
288
  case "PARAMS":
289
+ if (query == null) {
290
+ throw new ReferenceError("PARAMS is not defined, in \"".concat(raw, "\""));
291
+ }
286
292
  globalVariables[variableName] = new URLSearchParams(query);
287
293
  break;
288
294
  case "PATH":
@@ -293,13 +299,13 @@ runtimeContext) {
293
299
  break;
294
300
  case "PROCESSORS":
295
301
  globalVariables[variableName] = getDynamicReadOnlyProxy({
296
- get(target, key) {
302
+ get(_target, key) {
297
303
  var pkg = customProcessors.get(key);
298
304
  if (!pkg) {
299
305
  throw new Error("'PROCESSORS.".concat(key, "' is not registered! Have you installed the relevant brick package?"));
300
306
  }
301
307
  return getDynamicReadOnlyProxy({
302
- get(t, k) {
308
+ get(_t, k) {
303
309
  return pkg.get(k);
304
310
  },
305
311
  ownKeys() {
@@ -318,9 +324,15 @@ runtimeContext) {
318
324
  });
319
325
  break;
320
326
  case "QUERY":
327
+ if (query == null) {
328
+ throw new ReferenceError("QUERY is not defined, in \"".concat(raw, "\""));
329
+ }
321
330
  globalVariables[variableName] = Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
322
331
  break;
323
332
  case "QUERY_ARRAY":
333
+ if (query == null) {
334
+ throw new ReferenceError("QUERY_ARRAY is not defined, in \"".concat(raw, "\""));
335
+ }
324
336
  globalVariables[variableName] = Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
325
337
  // case "SEGUE":
326
338
  break;
@@ -338,7 +350,7 @@ runtimeContext) {
338
350
  // eslint-disable-next-line no-fallthrough
339
351
  case "STATE":
340
352
  globalVariables[variableName] = getDynamicReadOnlyProxy({
341
- get(target, key) {
353
+ get(_target, key) {
342
354
  return tplStateStore.getValue(key);
343
355
  },
344
356
  ownKeys() {
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.js","names":["cook","preevaluate","shouldAllowRecursiveEvaluations","loadProcessorsImperatively","supply","hasOwnProperty","strictCollectMemberUsage","collectAppGetMenuUsage","collectInstalledAppsHasUsage","cloneDeep","omit","customProcessors","checkPermissionsUsage","storyboardFunctions","getGeneralGlobals","getDynamicReadOnlyProxy","getReadOnlyProxy","devtoolsHookEmit","getDevHook","getMedia","getStorageItem","_internalApiGetStoryboardInBootstrapData","getBrickPackages","getRuntime","hooks","getTplStateStore","widgetFunctions","widgetI18nFactory","hasInstalledApp","isStrictMode","warnAboutStrictMode","getFormStateStore","resolveData","asyncComputeRealValue","symbolForRaw","Symbol","for","symbolForContext","isPreEvaluated","raw","getPreEvaluatedRaw","pre","shouldDismissMarkingComputed","possibleErrorConstructs","WeakSet","SyntaxError","TypeError","ReferenceError","getCookErrorConstructor","error","has","constructor","asyncEvaluate","_x","_x2","_x3","_asyncEvaluate","apply","arguments","_asyncToGenerator","runtimeContext","options","blockingList","run","lowLevelEvaluate","Promise","all","evaluate","length","undefined","isAsync","passByRuntimeContext","_objectSpread","menuUsage","usedArgs","Set","hasAppUsage","precooked","withParent","beforeVisitGlobal","node","parent","message","concat","errorConstructor","hasNonStaticUsage","Error","globalVariables","attemptToVisitGlobals","lazy","Object","keys","usedCtx","usedProcessors","usedStates","tplStateStore","strict","usedFormStates","formStateStore","devHook","push","ctxStore","waitFor","usedTpls","tpl","add","attemptToCheckPermissions","usedFunctions","pendingPermissionsPreCheck","size","menu","usedMenuIds","map","menuId","fetchMenuById","getStoryboardByAppId","_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","getMenu","getMenuById","get","target","key","getValue","ownKeys","Array","from","property","console","getItem","getMiscSettings","URLSearchParams","params","pathname","pkg","t","k","processor","namespace","split","fromEntries","getAll","images","widgetImagesFactory","assign","appendI18nNamespace","result","expression","source","detail","context"],"sources":["../../../../src/internal/compute/evaluate.ts"],"sourcesContent":["import {\n cook,\n preevaluate,\n PreevaluateResult,\n shouldAllowRecursiveEvaluations,\n} from \"@next-core/cook\";\nimport { loadProcessorsImperatively } from \"@next-core/loader\";\nimport { supply } from \"@next-core/supply\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport {\n strictCollectMemberUsage,\n collectAppGetMenuUsage,\n collectInstalledAppsHasUsage,\n MemberCallUsage,\n} from \"@next-core/utils/storyboard\";\nimport { cloneDeep, omit } from \"lodash\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { customProcessors } from \"../../CustomProcessors.js\";\nimport {\n checkPermissionsUsage,\n storyboardFunctions,\n} from \"./StoryboardFunctions.js\";\nimport { getGeneralGlobals } from \"./getGeneralGlobals.js\";\nimport {\n getDynamicReadOnlyProxy,\n getReadOnlyProxy,\n} from \"../proxyFactories.js\";\nimport { devtoolsHookEmit, getDevHook } from \"../devtools.js\";\nimport { getMedia } from \"../mediaQuery.js\";\nimport { getStorageItem } from \"./getStorageItem.js\";\nimport {\n _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 case \"INDEX\": {\n const property =\n variableName === \"ITEM\" ? \"forEachItem\" : \"forEachIndex\";\n if (!hasOwnProperty(runtimeContext, property)) {\n // eslint-disable-next-line no-console\n console.error(\n `Using \\`${variableName}\\` but no \\`:forEach\\` is found, check your expression: \"${raw}\"`\n );\n } else {\n globalVariables[variableName] = runtimeContext[property];\n }\n break;\n }\n case \"LOCAL_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"local\"),\n });\n break;\n case \"MEDIA\":\n globalVariables[variableName] = getReadOnlyProxy(getMedia());\n break;\n case \"MISC\":\n globalVariables[variableName] = getRuntime().getMiscSettings();\n break;\n case \"PARAMS\":\n globalVariables[variableName] = new URLSearchParams(query);\n break;\n case \"PATH\":\n globalVariables[variableName] = getReadOnlyProxy(\n match?.params ?? {}\n );\n break;\n case \"PATH_NAME\":\n globalVariables[variableName] = location.pathname;\n break;\n case \"PROCESSORS\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(target, key) {\n const pkg = customProcessors.get(key as string);\n if (!pkg) {\n throw new Error(\n `'PROCESSORS.${\n key as string\n }' is not registered! Have you installed the relevant brick package?`\n );\n }\n return getDynamicReadOnlyProxy({\n get(t, k) {\n return pkg.get(k as string);\n },\n ownKeys() {\n return Array.from(pkg.keys());\n },\n });\n },\n ownKeys() {\n const keys = new Set<string>();\n for (const processor of usedProcessors) {\n const namespace = processor.split(\".\")[0];\n keys.add(namespace);\n }\n return Array.from(keys);\n },\n });\n break;\n case \"QUERY\":\n 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: 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,SACEA,IAAI,EACJC,WAAW,EAEXC,+BAA+B,QAC1B,iBAAiB;AACxB,SAASC,0BAA0B,QAAQ,mBAAmB;AAC9D,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SACEC,wBAAwB,EACxBC,sBAAsB,EACtBC,4BAA4B,QAEvB,6BAA6B;AACpC,SAASC,SAAS,EAAEC,IAAI,QAAQ,QAAQ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QAAO,CAAC;MACrC;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"evaluate.js","names":["cook","preevaluate","shouldAllowRecursiveEvaluations","loadProcessorsImperatively","supply","hasOwnProperty","strictCollectMemberUsage","collectAppGetMenuUsage","collectInstalledAppsHasUsage","cloneDeep","omit","customProcessors","checkPermissionsUsage","storyboardFunctions","getGeneralGlobals","getDynamicReadOnlyProxy","getReadOnlyProxy","devtoolsHookEmit","getDevHook","getMedia","getStorageItem","_internalApiGetStoryboardInBootstrapData","getBrickPackages","getRuntime","hooks","getTplStateStore","widgetFunctions","widgetI18nFactory","hasInstalledApp","isStrictMode","warnAboutStrictMode","getFormStateStore","resolveData","asyncComputeRealValue","symbolForRaw","Symbol","for","symbolForContext","isPreEvaluated","raw","getPreEvaluatedRaw","pre","shouldDismissMarkingComputed","possibleErrorConstructs","WeakSet","SyntaxError","TypeError","ReferenceError","getCookErrorConstructor","error","has","constructor","asyncEvaluate","_x","_x2","_x3","_asyncEvaluate","apply","arguments","_asyncToGenerator","runtimeContext","options","blockingList","run","lowLevelEvaluate","Promise","all","evaluate","length","undefined","isAsync","passByRuntimeContext","_objectSpread","menuUsage","usedArgs","Set","hasAppUsage","precooked","withParent","beforeVisitGlobal","node","parent","message","concat","errorConstructor","hasNonStaticUsage","Error","globalVariables","attemptToVisitGlobals","lazy","Object","keys","usedCtx","usedProcessors","usedStates","tplStateStore","strict","usedFormStates","formStateStore","devHook","push","ctxStore","waitFor","usedTpls","tpl","add","attemptToCheckPermissions","usedFunctions","pendingPermissionsPreCheck","size","menu","usedMenuIds","map","menuId","fetchMenuById","getStoryboardByAppId","_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","getMenu","getMenuById","get","_target","key","getValue","ownKeys","Array","from","property","console","getItem","getMiscSettings","URLSearchParams","params","pathname","pkg","_t","k","processor","namespace","split","fromEntries","getAll","images","widgetImagesFactory","assign","appendI18nNamespace","result","expression","source","detail","context"],"sources":["../../../../src/internal/compute/evaluate.ts"],"sourcesContent":["import {\n cook,\n preevaluate,\n PreevaluateResult,\n shouldAllowRecursiveEvaluations,\n} from \"@next-core/cook\";\nimport { loadProcessorsImperatively } from \"@next-core/loader\";\nimport { supply } from \"@next-core/supply\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport {\n strictCollectMemberUsage,\n collectAppGetMenuUsage,\n collectInstalledAppsHasUsage,\n MemberCallUsage,\n} from \"@next-core/utils/storyboard\";\nimport { cloneDeep, omit } from \"lodash\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { customProcessors } from \"../../CustomProcessors.js\";\nimport {\n checkPermissionsUsage,\n storyboardFunctions,\n} from \"./StoryboardFunctions.js\";\nimport { getGeneralGlobals } from \"./getGeneralGlobals.js\";\nimport {\n getDynamicReadOnlyProxy,\n getReadOnlyProxy,\n} from \"../proxyFactories.js\";\nimport { devtoolsHookEmit, getDevHook } from \"../devtools.js\";\nimport { getMedia } from \"../mediaQuery.js\";\nimport { getStorageItem } from \"./getStorageItem.js\";\nimport {\n _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 if (app == null) {\n throw new ReferenceError(`APP is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = {\n ...cloneDeep(app),\n getMenu: hooks?.menu?.getMenuById,\n };\n break;\n case \"CTX\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n 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 case \"INDEX\": {\n const property =\n variableName === \"ITEM\" ? \"forEachItem\" : \"forEachIndex\";\n if (!hasOwnProperty(runtimeContext, property)) {\n // eslint-disable-next-line no-console\n console.error(\n `Using \\`${variableName}\\` but no \\`:forEach\\` is found, check your expression: \"${raw}\"`\n );\n } else {\n globalVariables[variableName] = runtimeContext[property];\n }\n break;\n }\n case \"LOCAL_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"local\"),\n });\n break;\n case \"MEDIA\":\n globalVariables[variableName] = getReadOnlyProxy(getMedia());\n break;\n case \"MISC\":\n globalVariables[variableName] = getRuntime().getMiscSettings();\n break;\n case \"PARAMS\":\n if (query == null) {\n throw new ReferenceError(`PARAMS is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = new URLSearchParams(query);\n break;\n case \"PATH\":\n globalVariables[variableName] = getReadOnlyProxy(\n match?.params ?? {}\n );\n break;\n case \"PATH_NAME\":\n globalVariables[variableName] = location.pathname;\n break;\n case \"PROCESSORS\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n const pkg = customProcessors.get(key as string);\n if (!pkg) {\n throw new Error(\n `'PROCESSORS.${\n key as string\n }' is not registered! Have you installed the relevant brick package?`\n );\n }\n return getDynamicReadOnlyProxy({\n get(_t, k) {\n return pkg.get(k as string);\n },\n ownKeys() {\n return Array.from(pkg.keys());\n },\n });\n },\n ownKeys() {\n const keys = new Set<string>();\n for (const processor of usedProcessors) {\n const namespace = processor.split(\".\")[0];\n keys.add(namespace);\n }\n return Array.from(keys);\n },\n });\n break;\n case \"QUERY\":\n if (query == null) {\n throw new ReferenceError(`QUERY is not defined, in \"${raw}\"`);\n }\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.get(key)])\n );\n break;\n case \"QUERY_ARRAY\":\n if (query == null) {\n throw new ReferenceError(\n `QUERY_ARRAY is not defined, in \"${raw}\"`\n );\n }\n globalVariables[variableName] = Object.fromEntries(\n Array.from(query.keys()).map((key) => [key, query.getAll(key)])\n );\n // case \"SEGUE\":\n break;\n case \"SESSION_STORAGE\":\n globalVariables[variableName] = getReadOnlyProxy({\n getItem: getStorageItem(\"session\"),\n });\n break;\n // istanbul ignore next\n case \"TPL\":\n warnAboutStrictMode(\n strict,\n 'Using \"TPL\" in expression',\n `check your expression: \"${raw}\"`\n );\n if (strict) {\n break;\n }\n // eslint-disable-next-line no-fallthrough\n case \"STATE\":\n globalVariables[variableName] = getDynamicReadOnlyProxy({\n get(_target, key) {\n return tplStateStore!.getValue(key as string);\n },\n ownKeys() {\n return Array.from(usedStates);\n },\n });\n break;\n case \"SYS\":\n globalVariables[variableName] = getReadOnlyProxy(sys ?? {});\n break;\n case \"__WIDGET_FN__\":\n globalVariables[variableName] = widgetFunctions;\n break;\n case \"__WIDGET_IMG__\":\n globalVariables[variableName] = hooks?.images?.widgetImagesFactory;\n break;\n case \"__WIDGET_I18N__\":\n globalVariables[variableName] = widgetI18nFactory;\n break;\n }\n }\n\n Object.assign(\n globalVariables,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n storyboardFunctions,\n app: app,\n appendI18nNamespace: runtimeContext.appendI18nNamespace,\n })\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,SACEA,IAAI,EACJC,WAAW,EAEXC,+BAA+B,QAC1B,iBAAiB;AACxB,SAASC,0BAA0B,QAAQ,mBAAmB;AAC9D,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SACEC,wBAAwB,EACxBC,sBAAsB,EACtBC,4BAA4B,QAEvB,6BAA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SAAS,CAACyF,MAAM,EAAE;UAC1D/E,eAAe,EAAEnF,MAAM,CACrByE,SAAS,CAACW,qBAAqB,EAC/BD,eACF;QACF,CAAC,CAAC;QACF,IAAMgF,MAAM,GAAG;UAAEhI,GAAG;UAAEiI,OAAO,EAAEjF,eAAe;UAAE6E;QAAO,CAAC;QACxDnJ,gBAAgB,CAAC,YAAY,EAAEsJ,MAAM,CAAC;QACtC,OAAOH,MAAM;MACf,CAAC,CAAC,OAAOnH,KAAU,EAAE;QACnB,IAAMiC,QAAO,MAAAC,MAAA,CAAMlC,KAAK,CAACiC,OAAO,aAAAC,MAAA,CAAS5C,GAAG,OAAG;QAC/C,IAAM6C,iBAAgB,GAAGpC,uBAAuB,CAACC,KAAK,CAAC;QACvD,MAAM,IAAImC,iBAAgB,CAACF,QAAO,CAAC;MACrC;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { BrickConf, ContextConf, CustomTemplate, MetaI18n, SiteTheme, StoryboardFunction } from "@next-core/types";
1
+ import type { BrickConf, ContextConf, CustomTemplate, MetaI18n, MicroApp, SiteTheme, StoryboardFunction } from "@next-core/types";
2
2
  export interface CreateRootOptions {
3
3
  portal?: HTMLElement;
4
4
  /**
@@ -21,8 +21,10 @@ export interface RenderOptions {
21
21
  functions?: StoryboardFunction[];
22
22
  templates?: CustomTemplate[];
23
23
  i18n?: MetaI18n;
24
+ url?: string;
25
+ app?: MicroApp;
24
26
  }
25
27
  export declare function unstable_createRoot(container: HTMLElement | DocumentFragment, { portal: _portal, scope, unknownBricks }?: CreateRootOptions): {
26
- render(brick: BrickConf | BrickConf[], { theme, uiVersion, context, functions, templates, i18n: i18nData, }?: RenderOptions): Promise<void>;
28
+ render(brick: BrickConf | BrickConf[], { theme, uiVersion, context, functions, templates, i18n: i18nData, url, app, }?: RenderOptions): Promise<void>;
27
29
  unmount(): void;
28
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/runtime",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/runtime",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -66,5 +66,5 @@
66
66
  "@next-core/build-next-libs": "^1.0.14",
67
67
  "@next-core/test-next": "^1.0.17"
68
68
  },
69
- "gitHead": "c81ce313a872c4a80dee78f1cbe583abc150310b"
69
+ "gitHead": "d831c6464ee42dd0a3557360214de93a2b25a860"
70
70
  }