@next-core/runtime 1.25.0 → 1.25.2
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.
- package/dist/cjs/createRoot.js +3 -0
- package/dist/cjs/createRoot.js.map +1 -1
- package/dist/cjs/index.js +9 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js +5 -0
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/esm/createRoot.js +3 -0
- package/dist/esm/createRoot.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/secret_internals.js +1 -0
- package/dist/esm/internal/secret_internals.js.map +1 -1
- package/dist/types/createRoot.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -2
package/dist/cjs/createRoot.js
CHANGED
|
@@ -15,6 +15,7 @@ var _enums = require("./internal/enums.js");
|
|
|
15
15
|
var _StoryboardFunctions = require("./internal/compute/StoryboardFunctions.js");
|
|
16
16
|
var _registerAppI18n = require("./internal/registerAppI18n.js");
|
|
17
17
|
var _registerCustomTemplates = require("./internal/registerCustomTemplates.js");
|
|
18
|
+
var _setUIVersion = require("./setUIVersion.js");
|
|
18
19
|
function unstable_createRoot(container, {
|
|
19
20
|
portal: _portal,
|
|
20
21
|
scope = "fragment",
|
|
@@ -40,6 +41,7 @@ function unstable_createRoot(container, {
|
|
|
40
41
|
return {
|
|
41
42
|
async render(brick, {
|
|
42
43
|
theme,
|
|
44
|
+
uiVersion,
|
|
43
45
|
context,
|
|
44
46
|
functions,
|
|
45
47
|
templates,
|
|
@@ -70,6 +72,7 @@ function unstable_createRoot(container, {
|
|
|
70
72
|
var _clearI18nBundles;
|
|
71
73
|
(0, _themeAndMode.setTheme)(theme !== null && theme !== void 0 ? theme : "light");
|
|
72
74
|
(0, _themeAndMode.setMode)("default");
|
|
75
|
+
(0, _setUIVersion.setUIVersion)(uiVersion);
|
|
73
76
|
const demoApp = {
|
|
74
77
|
id: "demo",
|
|
75
78
|
homepage: "/demo"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoot.js","names":["_lodash","require","_Renderer","_RendererContext","_DataStore","_mount","_handleHttpError","_themeAndMode","_enums","_StoryboardFunctions","_registerAppI18n","_registerCustomTemplates","unstable_createRoot","container","portal","_portal","scope","unknownBricks","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","theme","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","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","menuRequests","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\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | 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 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\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 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 menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.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;AA2BO,SAASW,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,GAAG;MAC9CL,QAAQ,CAACM,IAAI,CAACC,MAAM,CAACZ,MAAM,CAAC;MAC5B,OAAOA,MAAM;IACf,CAAC;EACH;EACA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AC;AACH"}
|
|
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","menuRequests","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 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 menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.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,GAAG;MAC9CL,QAAQ,CAACM,IAAI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8E,kBAAW,EAAC9E,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAAC6F,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,7 +21,8 @@ var _exportNames = {
|
|
|
21
21
|
StoryboardFunctionRegistryFactory: true,
|
|
22
22
|
matchPath: true,
|
|
23
23
|
Notification: true,
|
|
24
|
-
Dialog: true
|
|
24
|
+
Dialog: true,
|
|
25
|
+
setUIVersion: true
|
|
25
26
|
};
|
|
26
27
|
Object.defineProperty(exports, "Dialog", {
|
|
27
28
|
enumerable: true,
|
|
@@ -120,6 +121,12 @@ Object.defineProperty(exports, "registerWidgetI18n", {
|
|
|
120
121
|
return _WidgetI18n.registerWidgetI18n;
|
|
121
122
|
}
|
|
122
123
|
});
|
|
124
|
+
Object.defineProperty(exports, "setUIVersion", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () {
|
|
127
|
+
return _setUIVersion.setUIVersion;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
123
130
|
var _auth = require("./auth.js");
|
|
124
131
|
Object.keys(_auth).forEach(function (key) {
|
|
125
132
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -252,4 +259,5 @@ Object.keys(_getV2RuntimeFromDll).forEach(function (key) {
|
|
|
252
259
|
}
|
|
253
260
|
});
|
|
254
261
|
});
|
|
262
|
+
var _setUIVersion = require("./setUIVersion.js");
|
|
255
263
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_auth","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_CustomProcessors","_CustomTemplates","_fetchByProvider","_getBasePath","_getPageInfo","_handleHttpError","_history","_createRoot","_Runtime","__secret_internals","_interopRequireWildcard","_test_only","_themeAndMode","_checkIf","_WidgetFunctions","_WidgetI18n","_StoryboardFunctionRegistry","_matchPath","_Notification","_Dialog","_getV2RuntimeFromDll"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport * from \"./createRoot.js\";\nexport {\n createRuntime,\n getRuntime,\n type RuntimeOptions,\n type RuntimeHooks,\n type RuntimeHooksMenuHelpers,\n type ImagesFactory,\n type PageViewInfo,\n} from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport { __test_only } from \"./internal/test_only.js\";\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\nexport * from \"./getV2RuntimeFromDll.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_auth","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_CustomProcessors","_CustomTemplates","_fetchByProvider","_getBasePath","_getPageInfo","_handleHttpError","_history","_createRoot","_Runtime","__secret_internals","_interopRequireWildcard","_test_only","_themeAndMode","_checkIf","_WidgetFunctions","_WidgetI18n","_StoryboardFunctionRegistry","_matchPath","_Notification","_Dialog","_getV2RuntimeFromDll","_setUIVersion"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport * from \"./createRoot.js\";\nexport {\n createRuntime,\n getRuntime,\n type RuntimeOptions,\n type RuntimeHooks,\n type RuntimeHooksMenuHelpers,\n type ImagesFactory,\n type PageViewInfo,\n} from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport { __test_only } from \"./internal/test_only.js\";\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\nexport * from \"./getV2RuntimeFromDll.js\";\nexport { setUIVersion } from \"./setUIVersion.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA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
128
|
Object.assign(storyboard, {
|
|
129
129
|
...storyboardPatch,
|
|
130
|
+
meta: {
|
|
131
|
+
// Keep runtime fields such as `injectMenus`
|
|
132
|
+
...storyboard.meta,
|
|
133
|
+
...storyboardPatch.meta
|
|
134
|
+
},
|
|
130
135
|
$$fulfilling: null,
|
|
131
136
|
$$fulfilled: true,
|
|
132
137
|
$$registerCustomTemplateProcessed: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["_lodash","require","_Runtime","_Renderer","_RendererContext","_mount","_enums","_computeRealValue","_isStrictMode","_CustomTemplates","_registerAppI18n","_utils","renderUseBrick","useBrick","data","_scopedRuntimeContext","_scopedRuntimeContext2","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","_internalApiGetRuntimeContext","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","RendererContext","renderRoot","tag","RenderTag","ROOT","createPortal","transform","strict","isStrictMode","warnAboutStrictMode","output","renderBrick","properties","scopedStores","postAsyncRender","node","PLACEHOLDER","Error","portal","child","tagName","type","mountUseBrick","element","portalRoot","document","querySelector","createElement","appendChild","mountTree","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","mountResult","unmountTree","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","computeRealValue","noInject","updateStoryboard","appId","storyboardPatch","storyboard","_internalApiGetStoryboardInBootstrapData","Object","assign","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","registerAppI18n","updateStoryboardByRoute","newRoute","match","getKey","route","path","exact","replaceRoute","routes","key","map","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","customTemplates","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","pick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","exports","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","tplStateStoreId","runtimeContext","tplStateStore","getTplStateStore","getValue","ctxStore","getAllContextValues","getAllValues","getBrickPackagesById","id","getBrickPackages","find","pkg","filePath","startsWith","getRenderId","_internalApiGetRenderId","getAddedContracts","updateStoryboardType","collectUsedContracts","updatedStoryboard","meta","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","forEach","api","_storyboard$meta","_","namespaceId","contracts","some","contract","push"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n RuntimeSnippet,\n ContextConf,\n} from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport {\n createScopedRuntimeContext,\n postAsyncRender,\n renderBrick,\n} from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\n} from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\n\nexport type { DataValueOption, RuntimeContext } from \"./interfaces.js\";\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[];\n}\n\nexport async function renderUseBrick(\n useBrick: UseSingleBrickConf,\n data: unknown\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\n ..._internalApiGetRuntimeContext()!,\n data,\n pendingPermissionsPreCheck: [],\n });\n\n scopedRuntimeContext.tplStateStoreMap ??= new Map();\n scopedRuntimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const transform = (useBrick as { transform?: Record<string, unknown> })\n .transform;\n const strict = isStrictMode();\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n useBrick\n );\n }\n\n const output = await renderBrick(\n renderRoot,\n strict\n ? useBrick\n : {\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n scopedRuntimeContext,\n rendererContext,\n []\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\n\n if (output.node?.tag === RenderTag.PLACEHOLDER) {\n throw new Error(\n \"The root brick of useBrick cannot be an ignored control node\"\n );\n }\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext, scopedStores };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext, scopedStores }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let match = false;\n const getKey = (route: RouteConf): string => `${route.path}.${route.exact}`;\n const replaceRoute = (routes: RouteConf[], key: string): RouteConf[] => {\n return routes.map((route) => {\n const routeKey = getKey(route);\n if (route.type === \"routes\") {\n route.routes = replaceRoute(route.routes, key);\n return route;\n } else if (routeKey === key) {\n match = true;\n return newRoute;\n } else {\n return route;\n }\n });\n };\n storyboard.routes = replaceRoute(storyboard.routes, getKey(newRoute));\n if (!match) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(\n settings,\n \"properties\",\n \"events\",\n \"lifeCycle\",\n \"context\",\n \"slots\",\n \"children\"\n ),\n },\n ]\n );\n}\n\nfunction getSnippetPreviewPath(snippetId: string): string {\n return `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n context?: ContextConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }],\n snippetData.context\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[],\n context?: ContextConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n context,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n\nexport function getContextValue(\n name: string,\n { tplStateStoreId }: DataValueOption\n): unknown {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getValue(name);\n }\n\n return runtimeContext.ctxStore.getValue(name);\n}\n\nexport function getAllContextValues({\n tplStateStoreId,\n}: DataValueOption): Record<string, unknown> {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getAllValues();\n }\n\n return runtimeContext.ctxStore.getAllValues();\n}\n\nexport function getBrickPackagesById(id: string) {\n return getBrickPackages().find((pkg) =>\n pkg.id ? pkg.id === id : pkg.filePath.startsWith(id)\n );\n}\n\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n { appId, updateStoryboardType, collectUsedContracts }: PreviewOption\n): Promise<string[]> {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId);\n let updatedStoryboard;\n\n // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts\n if (updateStoryboardType === \"route\") {\n updatedStoryboard = {\n routes: [storyboardPatch as RouteConf],\n } as Storyboard;\n } else if (updateStoryboardType === \"template\") {\n updatedStoryboard = {\n meta: {\n customTemplates: [storyboardPatch as CustomTemplate],\n },\n } as Storyboard;\n } else if (updateStoryboardType === \"snippet\") {\n // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route\n const snippetPreviewPath = getSnippetPreviewPath(\n (storyboardPatch as RuntimeSnippet).snippetId\n );\n const currentRoute = storyboard?.routes?.find(\n (route) => route.path === snippetPreviewPath\n );\n\n updatedStoryboard = {\n routes: [currentRoute],\n } as Storyboard;\n }\n\n const addedContracts: string[] = [];\n\n if (updatedStoryboard && collectUsedContracts) {\n const contractApis = await collectUsedContracts(updatedStoryboard);\n\n contractApis.forEach((api: string) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, namespaceId, name] = api.match(\n /(.*)@(.*):\\d\\.\\d\\.\\d/\n ) as string[];\n\n if (\n !storyboard?.meta?.contracts?.some(\n (contract) =>\n contract.namespaceId === namespaceId && contract.name === name\n )\n ) {\n addedContracts.push(api);\n }\n });\n }\n\n return addedContrac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B,IAAID,oBAAoB,EAAE;IAC7C,MAAMO,YAAY,GAAG,MAAMP,oBAAoB,CAACC,iBAAiB,CAAC;IAElEM,YAAY,CAACC,OAAO,CAAEC,GAAW,IAAK;MAAA,IAAAC,gBAAA;MACpC;MACA,MAAM,CAACC,CAAC,EAAEC,WAAW,EAAEzD,IAAI,CAAC,GAAGsD,GAAG,CAACrE,KAAK,CACtC,sBACF,CAAa;MAEb,IACE,EAACV,UAAU,aAAVA,UAAU,gBAAAgF,gBAAA,GAAVhF,UAAU,CAAEwE,IAAI,cAAAQ,gBAAA,gBAAAA,gBAAA,GAAhBA,gBAAA,CAAkBG,SAAS,cAAAH,gBAAA,eAA3BA,gBAAA,CAA6BI,IAAI,CAC/BC,QAAQ,IACPA,QAAQ,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAAC5D,IAAI,KAAKA,IAC9D,CAAC,GACD;QACAmD,cAAc,CAACU,IAAI,CAACP,GAAG,CAAC;MAC1B;IACF,CAAC,CAAC;EACJ;EAEA,OAAOH,cAAc;AACvB"}
|
|
1
|
+
{"version":3,"file":"secret_internals.js","names":["_lodash","require","_Runtime","_Renderer","_RendererContext","_mount","_enums","_computeRealValue","_isStrictMode","_CustomTemplates","_registerAppI18n","_utils","renderUseBrick","useBrick","data","_scopedRuntimeContext","_scopedRuntimeContext2","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","_internalApiGetRuntimeContext","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","RendererContext","renderRoot","tag","RenderTag","ROOT","createPortal","transform","strict","isStrictMode","warnAboutStrictMode","output","renderBrick","properties","scopedStores","postAsyncRender","node","PLACEHOLDER","Error","portal","child","tagName","type","mountUseBrick","element","portalRoot","document","querySelector","createElement","appendChild","mountTree","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","mountResult","unmountTree","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","computeRealValue","noInject","updateStoryboard","appId","storyboardPatch","storyboard","_internalApiGetStoryboardInBootstrapData","Object","assign","meta","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","registerAppI18n","updateStoryboardByRoute","newRoute","match","getKey","route","path","exact","replaceRoute","routes","key","map","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","customTemplates","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","pick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","exports","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","tplStateStoreId","runtimeContext","tplStateStore","getTplStateStore","getValue","ctxStore","getAllContextValues","getAllValues","getBrickPackagesById","id","getBrickPackages","find","pkg","filePath","startsWith","getRenderId","_internalApiGetRenderId","getAddedContracts","updateStoryboardType","collectUsedContracts","updatedStoryboard","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","forEach","api","_storyboard$meta","_","namespaceId","contracts","some","contract","push"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n RuntimeSnippet,\n ContextConf,\n} from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport {\n createScopedRuntimeContext,\n postAsyncRender,\n renderBrick,\n} from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\n} from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\n\nexport type { DataValueOption, RuntimeContext } from \"./interfaces.js\";\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[];\n}\n\nexport async function renderUseBrick(\n useBrick: UseSingleBrickConf,\n data: unknown\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\n ..._internalApiGetRuntimeContext()!,\n data,\n pendingPermissionsPreCheck: [],\n });\n\n scopedRuntimeContext.tplStateStoreMap ??= new Map();\n scopedRuntimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const transform = (useBrick as { transform?: Record<string, unknown> })\n .transform;\n const strict = isStrictMode();\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n useBrick\n );\n }\n\n const output = await renderBrick(\n renderRoot,\n strict\n ? useBrick\n : {\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n scopedRuntimeContext,\n rendererContext,\n []\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\n\n if (output.node?.tag === RenderTag.PLACEHOLDER) {\n throw new Error(\n \"The root brick of useBrick cannot be an ignored control node\"\n );\n }\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext, scopedStores };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext, scopedStores }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n meta: {\n // Keep runtime fields such as `injectMenus`\n ...storyboard.meta,\n ...storyboardPatch.meta,\n },\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let match = false;\n const getKey = (route: RouteConf): string => `${route.path}.${route.exact}`;\n const replaceRoute = (routes: RouteConf[], key: string): RouteConf[] => {\n return routes.map((route) => {\n const routeKey = getKey(route);\n if (route.type === \"routes\") {\n route.routes = replaceRoute(route.routes, key);\n return route;\n } else if (routeKey === key) {\n match = true;\n return newRoute;\n } else {\n return route;\n }\n });\n };\n storyboard.routes = replaceRoute(storyboard.routes, getKey(newRoute));\n if (!match) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(\n settings,\n \"properties\",\n \"events\",\n \"lifeCycle\",\n \"context\",\n \"slots\",\n \"children\"\n ),\n },\n ]\n );\n}\n\nfunction getSnippetPreviewPath(snippetId: string): string {\n return `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n context?: ContextConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }],\n snippetData.context\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[],\n context?: ContextConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n context,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n\nexport function getContextValue(\n name: string,\n { tplStateStoreId }: DataValueOption\n): unknown {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getValue(name);\n }\n\n return runtimeContext.ctxStore.getValue(name);\n}\n\nexport function getAllContextValues({\n tplStateStoreId,\n}: DataValueOption): Record<string, unknown> {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getAllValues();\n }\n\n return runtimeContext.ctxStore.getAllValues();\n}\n\nexport function getBrickPackagesById(id: string) {\n return getBrickPackages().find((pkg) =>\n pkg.id ? pkg.id === id : pkg.filePath.startsWith(id)\n );\n}\n\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n { appId, updateStoryboardType, collectUsedContracts }: PreviewOption\n): Promise<string[]> {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId);\n let updatedStoryboard;\n\n // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts\n if (updateStoryboardType === \"route\") {\n updatedStoryboard = {\n routes: [storyboardPatch as RouteConf],\n } as Storyboard;\n } else if (updateStoryboardType === \"template\") {\n updatedStoryboard = {\n meta: {\n customTemplates: [storyboardPatch as CustomTemplate],\n },\n } as Storyboard;\n } else if (updateStoryboardType === \"snippet\") {\n // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route\n const snippetPreviewPath = getSnippetPreviewPath(\n (storyboardPatch as RuntimeSnippet).snippetId\n );\n const currentRoute = storyboard?.routes?.find(\n (route) => route.path === snippetPreviewPath\n );\n\n updatedStoryboard = {\n routes: [currentRoute],\n } as Storyboard;\n }\n\n const addedContracts: string[] = [];\n\n if (updatedStoryboard && collectUsedContracts) {\n const contractApis = await collectUsedContracts(updatedStoryboard);\n\n contractApis.forEach((api: string) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, namespaceId, name] = api.match(\n /(.*)@(.*):\\d\\.\\d\\.\\d/\n ) as string[];\n\n if (\n !storyboard?.meta?.contracts?.some(\n (contract) =>\n contract.namespaceId === namespaceId && contract.name === name\n )\n ) {\n addedContracts.push(api);\n }\n });\n }\n\n return addedContracts;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AASA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,gBAAA,GAAAH,OAAA;AAQA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,gBAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAWO,eAAeW,cAAcA,CAClCC,QAA4B,EAC5BC,IAAa,EACkB;EAAA,IAAAC,qBAAA,EAAAC,sBAAA,EAAAC,YAAA,EAAAC,aAAA;EAC/B,MAAM,CAACC,oBAAoB,EAAEC,kBAAkB,EAAEC,mBAAmB,CAAC,GACnE,IAAAC,oCAA0B,EAAC;IACzB,GAAG,IAAAC,sCAA6B,EAAC,CAAE;IACnCT,IAAI;IACJU,0BAA0B,EAAE;EAC9B,CAAC,CAAC;EAEJ,CAAAT,qBAAA,GAAAI,oBAAoB,CAACM,gBAAgB,cAAAV,qBAAA,cAAAA,qBAAA,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
@@ -10,6 +10,7 @@ import { RenderTag } from "./internal/enums.js";
|
|
|
10
10
|
import { registerStoryboardFunctions } from "./internal/compute/StoryboardFunctions.js";
|
|
11
11
|
import { registerAppI18n } from "./internal/registerAppI18n.js";
|
|
12
12
|
import { registerCustomTemplates } from "./internal/registerCustomTemplates.js";
|
|
13
|
+
import { setUIVersion } from "./setUIVersion.js";
|
|
13
14
|
export function unstable_createRoot(container) {
|
|
14
15
|
var {
|
|
15
16
|
portal: _portal,
|
|
@@ -39,6 +40,7 @@ export function unstable_createRoot(container) {
|
|
|
39
40
|
return _asyncToGenerator(function* () {
|
|
40
41
|
var {
|
|
41
42
|
theme,
|
|
43
|
+
uiVersion,
|
|
42
44
|
context,
|
|
43
45
|
functions,
|
|
44
46
|
templates,
|
|
@@ -69,6 +71,7 @@ export function unstable_createRoot(container) {
|
|
|
69
71
|
var _clearI18nBundles;
|
|
70
72
|
setTheme(theme !== null && theme !== void 0 ? theme : "light");
|
|
71
73
|
setMode("default");
|
|
74
|
+
setUIVersion(uiVersion);
|
|
72
75
|
var demoApp = {
|
|
73
76
|
id: "demo",
|
|
74
77
|
homepage: "/demo"
|
|
@@ -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","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","context","functions","templates","i18n","i18nData","Error","bricks","concat","previousRendererContext","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","menuRequests","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\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | 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 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\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 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 menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.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,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,CAAC;QAErB,IAAItC,KAAK,KAAK,MAAM,EAAE;UACpBkE,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB;QAEA,IAAI,CAACjB,MAAM,EAAE;UACX,KAAK,IAAMkB,KAAK,IAAIhB,MAAM,EAAE;YAC1BgB,KAAK,CAACC,cAAc,CAAC,CAAC;UACxB;UAEA,IAAIrE,KAAK,KAAK,MAAM,EAAE;YACpBe,eAAe,CAACuD,gBAAgB,CAAC,CAAC;YAClC;UACF;;UACAvD,eAAe,CAACwD,eAAe,CAAC,CAAC;UACjCxD,eAAe,CAACyD,wBAAwB,CAAC,CAAC;UAC1CzD,eAAe,CAAC0D,qBAAqB,CAAC,CAAC;UACvC1D,eAAe,CAAC2D,2BAA2B,CAAC,CAAC;QAC/C;MAAC;IACH,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAI7D,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB5B,WAAW,CAACW,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACVZ,WAAW,CAACY,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAAC8E,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH"}
|
|
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","menuRequests","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 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 menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.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;AAC5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AW,CAACa,MAAM,CAAC;QACrB;QAEA,IAAIE,KAAK,KAAK,MAAM,EAAE;UACpB,IAAI,CAACmD,MAAM,EAAE;YACXpC,eAAe,CAACmD,sBAAsB,CAAC,CAAC;UAC1C;UAEA9E,UAAU,CAAC,CAAC;UACZD,SAAS,CAAC,CAAC;QACb;QAEAH,SAAS,CAACuD,UAAU,CAAC;QAErB,IAAIvC,KAAK,KAAK,MAAM,EAAE;UACpBmE,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB;QAEA,IAAI,CAACjB,MAAM,EAAE;UACX,KAAK,IAAMkB,KAAK,IAAIhB,MAAM,EAAE;YAC1BgB,KAAK,CAACC,cAAc,CAAC,CAAC;UACxB;UAEA,IAAItE,KAAK,KAAK,MAAM,EAAE;YACpBe,eAAe,CAACwD,gBAAgB,CAAC,CAAC;YAClC;UACF;;UACAxD,eAAe,CAACyD,eAAe,CAAC,CAAC;UACjCzD,eAAe,CAAC0D,wBAAwB,CAAC,CAAC;UAC1C1D,eAAe,CAAC2D,qBAAqB,CAAC,CAAC;UACvC3D,eAAe,CAAC4D,2BAA2B,CAAC,CAAC;QAC/C;MAAC;IACH,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAI9D,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,CAAC+E,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH"}
|
package/dist/esm/index.js
CHANGED
|
@@ -20,4 +20,5 @@ export { matchPath } from "./internal/matchPath.js";
|
|
|
20
20
|
export { Notification } from "./Notification.js";
|
|
21
21
|
export { Dialog } from "./Dialog.js";
|
|
22
22
|
export * from "./getV2RuntimeFromDll.js";
|
|
23
|
+
export { setUIVersion } from "./setUIVersion.js";
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createRuntime","getRuntime","__secret_internals","__test_only","getCssPropertyValue","getCurrentTheme","getCurrentMode","batchSetAppsLocalTheme","applyTheme","checkIfOfComputed","checkIfByTransform","registerWidgetFunctions","registerWidgetI18n","StoryboardFunctionRegistryFactory","matchPath","Notification","Dialog"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport * from \"./createRoot.js\";\nexport {\n createRuntime,\n getRuntime,\n type RuntimeOptions,\n type RuntimeHooks,\n type RuntimeHooksMenuHelpers,\n type ImagesFactory,\n type PageViewInfo,\n} from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport { __test_only } from \"./internal/test_only.js\";\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\nexport * from \"./getV2RuntimeFromDll.js\";\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,SACEA,aAAa,EACbC,UAAU,QAML,uBAAuB;AAC9B,OAAO,KAAKC,kBAAkB,MAAM,gCAAgC;AACpE,SAASA,kBAAkB;AAC3B,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SACEC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,mBAAmB;AAC1B,SACEC,iBAAiB,EACjBC,kBAAkB,QACb,+BAA+B;AACtC,SAASC,uBAAuB,QAAQ,uCAAuC;AAC/E,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,iCAAiC,QAAQ,iCAAiC;AACnF,SAASC,SAAS,QAAQ,yBAAyB;AACnD,SAASC,YAAY,QAAkC,mBAAmB;AAC1E,SAASC,MAAM,QAA4B,aAAa;AACxD,cAAc,0BAA0B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["createRuntime","getRuntime","__secret_internals","__test_only","getCssPropertyValue","getCurrentTheme","getCurrentMode","batchSetAppsLocalTheme","applyTheme","checkIfOfComputed","checkIfByTransform","registerWidgetFunctions","registerWidgetI18n","StoryboardFunctionRegistryFactory","matchPath","Notification","Dialog","setUIVersion"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport * from \"./createRoot.js\";\nexport {\n createRuntime,\n getRuntime,\n type RuntimeOptions,\n type RuntimeHooks,\n type RuntimeHooksMenuHelpers,\n type ImagesFactory,\n type PageViewInfo,\n} from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport { __test_only } from \"./internal/test_only.js\";\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\nexport * from \"./getV2RuntimeFromDll.js\";\nexport { setUIVersion } from \"./setUIVersion.js\";\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,SACEA,aAAa,EACbC,UAAU,QAML,uBAAuB;AAC9B,OAAO,KAAKC,kBAAkB,MAAM,gCAAgC;AACpE,SAASA,kBAAkB;AAC3B,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SACEC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,mBAAmB;AAC1B,SACEC,iBAAiB,EACjBC,kBAAkB,QACb,+BAA+B;AACtC,SAASC,uBAAuB,QAAQ,uCAAuC;AAC/E,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,iCAAiC,QAAQ,iCAAiC;AACnF,SAASC,SAAS,QAAQ,yBAAyB;AACnD,SAASC,YAAY,QAAkC,mBAAmB;AAC1E,SAASC,MAAM,QAA4B,aAAa;AACxD,cAAc,0BAA0B;AACxC,SAASC,YAAY,QAAQ,mBAAmB"}
|
|
@@ -110,6 +110,7 @@ export function legacyDoTransform(data, to, options) {
|
|
|
110
110
|
export function updateStoryboard(appId, storyboardPatch) {
|
|
111
111
|
var storyboard = _internalApiGetStoryboardInBootstrapData(appId);
|
|
112
112
|
Object.assign(storyboard, _objectSpread(_objectSpread({}, storyboardPatch), {}, {
|
|
113
|
+
meta: _objectSpread(_objectSpread({}, storyboard.meta), storyboardPatch.meta),
|
|
113
114
|
$$fulfilling: null,
|
|
114
115
|
$$fulfilled: true,
|
|
115
116
|
$$registerCustomTemplateProcessed: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["pick","_internalApiGetRenderId","_internalApiGetRuntimeContext","_internalApiGetStoryboardInBootstrapData","getBrickPackages","createScopedRuntimeContext","postAsyncRender","renderBrick","RendererContext","mountTree","unmountTree","RenderTag","computeRealValue","isStrictMode","warnAboutStrictMode","customTemplates","registerAppI18n","getTplStateStore","renderUseBrick","_x","_x2","_renderUseBrick","apply","arguments","_asyncToGenerator","useBrick","data","_scopedRuntimeContext","_scopedRuntimeContext2","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","_objectSpread","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","renderRoot","tag","ROOT","createPortal","transform","strict","output","properties","scopedStores","node","PLACEHOLDER","Error","portal","child","tagName","type","mountUseBrick","_ref","element","portalRoot","document","querySelector","createElement","appendChild","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","_ref2","mountResult","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","noInject","updateStoryboard","appId","storyboardPatch","storyboard","Object","assign","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","updateStoryboardByRoute","newRoute","match","getKey","route","concat","path","exact","replaceRoute","routes","key","map","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","_ref3","tplStateStoreId","runtimeContext","tplStateStore","getValue","ctxStore","getAllContextValues","_ref4","getAllValues","getBrickPackagesById","id","find","pkg","filePath","startsWith","getRenderId","getAddedContracts","_x3","_x4","_getAddedContracts","_ref5","updateStoryboardType","collectUsedContracts","updatedStoryboard","meta","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","forEach","api","_storyboard$meta","_","namespaceId","contracts","some","contract","push"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n RuntimeSnippet,\n ContextConf,\n} from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport {\n createScopedRuntimeContext,\n postAsyncRender,\n renderBrick,\n} from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\n} from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\n\nexport type { DataValueOption, RuntimeContext } from \"./interfaces.js\";\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[];\n}\n\nexport async function renderUseBrick(\n useBrick: UseSingleBrickConf,\n data: unknown\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\n ..._internalApiGetRuntimeContext()!,\n data,\n pendingPermissionsPreCheck: [],\n });\n\n scopedRuntimeContext.tplStateStoreMap ??= new Map();\n scopedRuntimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const transform = (useBrick as { transform?: Record<string, unknown> })\n .transform;\n const strict = isStrictMode();\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n useBrick\n );\n }\n\n const output = await renderBrick(\n renderRoot,\n strict\n ? useBrick\n : {\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n scopedRuntimeContext,\n rendererContext,\n []\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\n\n if (output.node?.tag === RenderTag.PLACEHOLDER) {\n throw new Error(\n \"The root brick of useBrick cannot be an ignored control node\"\n );\n }\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext, scopedStores };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext, scopedStores }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let match = false;\n const getKey = (route: RouteConf): string => `${route.path}.${route.exact}`;\n const replaceRoute = (routes: RouteConf[], key: string): RouteConf[] => {\n return routes.map((route) => {\n const routeKey = getKey(route);\n if (route.type === \"routes\") {\n route.routes = replaceRoute(route.routes, key);\n return route;\n } else if (routeKey === key) {\n match = true;\n return newRoute;\n } else {\n return route;\n }\n });\n };\n storyboard.routes = replaceRoute(storyboard.routes, getKey(newRoute));\n if (!match) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(\n settings,\n \"properties\",\n \"events\",\n \"lifeCycle\",\n \"context\",\n \"slots\",\n \"children\"\n ),\n },\n ]\n );\n}\n\nfunction getSnippetPreviewPath(snippetId: string): string {\n return `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n context?: ContextConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }],\n snippetData.context\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[],\n context?: ContextConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n context,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n\nexport function getContextValue(\n name: string,\n { tplStateStoreId }: DataValueOption\n): unknown {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getValue(name);\n }\n\n return runtimeContext.ctxStore.getValue(name);\n}\n\nexport function getAllContextValues({\n tplStateStoreId,\n}: DataValueOption): Record<string, unknown> {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getAllValues();\n }\n\n return runtimeContext.ctxStore.getAllValues();\n}\n\nexport function getBrickPackagesById(id: string) {\n return getBrickPackages().find((pkg) =>\n pkg.id ? pkg.id === id : pkg.filePath.startsWith(id)\n );\n}\n\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n { appId, updateStoryboardType, collectUsedContracts }: PreviewOption\n): Promise<string[]> {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId);\n let updatedStoryboard;\n\n // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts\n if (updateStoryboardType === \"route\") {\n updatedStoryboard = {\n routes: [storyboardPatch as RouteConf],\n } as Storyboard;\n } else if (updateStoryboardType === \"template\") {\n updatedStoryboard = {\n meta: {\n customTemplates: [storyboardPatch as CustomTemplate],\n },\n } as Storyboard;\n } else if (updateStoryboardType === \"snippet\") {\n // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route\n const snippetPreviewPath = getSnippetPreviewPath(\n (storyboardPatch as RuntimeSnippet).snippetId\n );\n const currentRoute = storyboard?.routes?.find(\n (route) => route.path === snippetPreviewPath\n );\n\n updatedStoryboard = {\n routes: [currentRoute],\n } as Storyboard;\n }\n\n const addedContracts: string[] = [];\n\n if (updatedStoryboard && collectUsedContracts) {\n const contractApis = await collectUsedContracts(updatedStoryboard);\n\n contractApis.forEach((api: string) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, namespaceId, name] = api.match(\n /(.*)@(.*):\\d\\.\\d\\.\\d/\n ) as string[];\n\n if (\n !storyboard?.meta?.contracts?.some(\n (contract) =>\n contract.namespaceId === namespaceId && contract.name === name\n )\n ) {\n addedContracts.push(api);\n }\n });\n }\n\n return addedContracts;\n}\n"],"mappings":";;AASA,SAASA,IAAI,QAAQ,QAAQ;AAC7B,SACEC,uBAAuB,EACvBC,6BAA6B,EAC7BC,wCAAwC,EACxCC,gBAAgB,QACX,cAAc;AACrB,SACEC,0BAA0B,EAC1BC,eAAe,EACfC,WAAW,QACN,eAAe;AACtB,SAASC,eAAe,QAAQ,sBAAsB;AAQtD,SAASC,SAAS,EAAEC,WAAW,QAAQ,YAAY;AACnD,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,oBAAoB;AACtE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,gBAAgB,QAAQ,4BAA4B;AAW7D,gBAAsBC,cAAcA,CAAAC,EAAA,EAAAC,GAAA;EAAA,OAAAC,eAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAqEnC,SAAAF,gBAAA;EAAAA,eAAA,GAAAG,iBAAA,CArEM,WACLC,QAA4B,EAC5BC,IAAa,EACkB;IAAA,IAAAC,qBAAA,EAAAC,sBAAA,EAAAC,YAAA,EAAAC,aAAA;IAC/B,IAAM,CAACC,oBAAoB,EAAEC,kBAAkB,EAAEC,mBAAmB,CAAC,GACnE5B,0BAA0B,CAAA6B,aAAA,CAAAA,aAAA,KACrBhC,6BAA6B,CAAC,CAAC;MAClCwB,IAAI;MACJS,0BAA0B,EAAE;IAAE,EAC/B,CAAC;IAEJ,CAAAR,qBAAA,GAAAI,oBAAoB,CAACK,gBAAgB,cAAAT,qBAAA,cAAAA,qBAAA,GAArCI,oBAAoB,CAACK,gBAAgB,GAAK,IAAIC,GAAG,CAAC,CAAC;IACnD,CAAAT,sBAAA,GAAAG,oBAAoB,CAACO,iBAAiB,cAAAV,sBAAA,cAAAA,sBAAA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Q,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAAC5D,IAAI,KAAKA,IAC9D,CAAC,GACD;UACAmD,cAAc,CAACU,IAAI,CAACP,GAAG,CAAC;QAC1B;MACF,CAAC,CAAC;IACJ;IAEA,OAAOH,cAAc;EACvB,CAAC;EAAA,OAAAT,kBAAA,CAAA/H,KAAA,OAAAC,SAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"secret_internals.js","names":["pick","_internalApiGetRenderId","_internalApiGetRuntimeContext","_internalApiGetStoryboardInBootstrapData","getBrickPackages","createScopedRuntimeContext","postAsyncRender","renderBrick","RendererContext","mountTree","unmountTree","RenderTag","computeRealValue","isStrictMode","warnAboutStrictMode","customTemplates","registerAppI18n","getTplStateStore","renderUseBrick","_x","_x2","_renderUseBrick","apply","arguments","_asyncToGenerator","useBrick","data","_scopedRuntimeContext","_scopedRuntimeContext2","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","_objectSpread","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","renderRoot","tag","ROOT","createPortal","transform","strict","output","properties","scopedStores","node","PLACEHOLDER","Error","portal","child","tagName","type","mountUseBrick","_ref","element","portalRoot","document","querySelector","createElement","appendChild","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","_ref2","mountResult","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","noInject","updateStoryboard","appId","storyboardPatch","storyboard","Object","assign","meta","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","updateStoryboardByRoute","newRoute","match","getKey","route","concat","path","exact","replaceRoute","routes","key","map","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","_ref3","tplStateStoreId","runtimeContext","tplStateStore","getValue","ctxStore","getAllContextValues","_ref4","getAllValues","getBrickPackagesById","id","find","pkg","filePath","startsWith","getRenderId","getAddedContracts","_x3","_x4","_getAddedContracts","_ref5","updateStoryboardType","collectUsedContracts","updatedStoryboard","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","forEach","api","_storyboard$meta","_","namespaceId","contracts","some","contract","push"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n RuntimeSnippet,\n ContextConf,\n} from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport {\n createScopedRuntimeContext,\n postAsyncRender,\n renderBrick,\n} from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\n} from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\n\nexport type { DataValueOption, RuntimeContext } from \"./interfaces.js\";\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[];\n}\n\nexport async function renderUseBrick(\n useBrick: UseSingleBrickConf,\n data: unknown\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\n ..._internalApiGetRuntimeContext()!,\n data,\n pendingPermissionsPreCheck: [],\n });\n\n scopedRuntimeContext.tplStateStoreMap ??= new Map();\n scopedRuntimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const transform = (useBrick as { transform?: Record<string, unknown> })\n .transform;\n const strict = isStrictMode();\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n useBrick\n );\n }\n\n const output = await renderBrick(\n renderRoot,\n strict\n ? useBrick\n : {\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n scopedRuntimeContext,\n rendererContext,\n []\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\n\n if (output.node?.tag === RenderTag.PLACEHOLDER) {\n throw new Error(\n \"The root brick of useBrick cannot be an ignored control node\"\n );\n }\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext, scopedStores };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext, scopedStores }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n meta: {\n // Keep runtime fields such as `injectMenus`\n ...storyboard.meta,\n ...storyboardPatch.meta,\n },\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let match = false;\n const getKey = (route: RouteConf): string => `${route.path}.${route.exact}`;\n const replaceRoute = (routes: RouteConf[], key: string): RouteConf[] => {\n return routes.map((route) => {\n const routeKey = getKey(route);\n if (route.type === \"routes\") {\n route.routes = replaceRoute(route.routes, key);\n return route;\n } else if (routeKey === key) {\n match = true;\n return newRoute;\n } else {\n return route;\n }\n });\n };\n storyboard.routes = replaceRoute(storyboard.routes, getKey(newRoute));\n if (!match) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(\n settings,\n \"properties\",\n \"events\",\n \"lifeCycle\",\n \"context\",\n \"slots\",\n \"children\"\n ),\n },\n ]\n );\n}\n\nfunction getSnippetPreviewPath(snippetId: string): string {\n return `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n context?: ContextConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }],\n snippetData.context\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[],\n context?: ContextConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n context,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n\nexport function getContextValue(\n name: string,\n { tplStateStoreId }: DataValueOption\n): unknown {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getValue(name);\n }\n\n return runtimeContext.ctxStore.getValue(name);\n}\n\nexport function getAllContextValues({\n tplStateStoreId,\n}: DataValueOption): Record<string, unknown> {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getAllValues();\n }\n\n return runtimeContext.ctxStore.getAllValues();\n}\n\nexport function getBrickPackagesById(id: string) {\n return getBrickPackages().find((pkg) =>\n pkg.id ? pkg.id === id : pkg.filePath.startsWith(id)\n );\n}\n\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n { appId, updateStoryboardType, collectUsedContracts }: PreviewOption\n): Promise<string[]> {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId);\n let updatedStoryboard;\n\n // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts\n if (updateStoryboardType === \"route\") {\n updatedStoryboard = {\n routes: [storyboardPatch as RouteConf],\n } as Storyboard;\n } else if (updateStoryboardType === \"template\") {\n updatedStoryboard = {\n meta: {\n customTemplates: [storyboardPatch as CustomTemplate],\n },\n } as Storyboard;\n } else if (updateStoryboardType === \"snippet\") {\n // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route\n const snippetPreviewPath = getSnippetPreviewPath(\n (storyboardPatch as RuntimeSnippet).snippetId\n );\n const currentRoute = storyboard?.routes?.find(\n (route) => route.path === snippetPreviewPath\n );\n\n updatedStoryboard = {\n routes: [currentRoute],\n } as Storyboard;\n }\n\n const addedContracts: string[] = [];\n\n if (updatedStoryboard && collectUsedContracts) {\n const contractApis = await collectUsedContracts(updatedStoryboard);\n\n contractApis.forEach((api: string) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, namespaceId, name] = api.match(\n /(.*)@(.*):\\d\\.\\d\\.\\d/\n ) as string[];\n\n if (\n !storyboard?.meta?.contracts?.some(\n (contract) =>\n contract.namespaceId === namespaceId &&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,SAAS,cAAAH,gBAAA,eAA3BA,gBAAA,CAA6BI,IAAI,CAC/BC,QAAQ,IACPA,QAAQ,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAAC3D,IAAI,KAAKA,IAC9D,CAAC,GACD;UACAkD,cAAc,CAACU,IAAI,CAACP,GAAG,CAAC;QAC1B;MACF,CAAC,CAAC;IACJ;IAEA,OAAOH,cAAc;EACvB,CAAC;EAAA,OAAAR,kBAAA,CAAAhI,KAAA,OAAAC,SAAA;AAAA"}
|
|
@@ -16,12 +16,13 @@ export interface CreateRootOptions {
|
|
|
16
16
|
}
|
|
17
17
|
export interface RenderOptions {
|
|
18
18
|
theme?: SiteTheme;
|
|
19
|
+
uiVersion?: string;
|
|
19
20
|
context?: ContextConf[];
|
|
20
21
|
functions?: StoryboardFunction[];
|
|
21
22
|
templates?: CustomTemplate[];
|
|
22
23
|
i18n?: MetaI18n;
|
|
23
24
|
}
|
|
24
25
|
export declare function unstable_createRoot(container: HTMLElement | DocumentFragment, { portal: _portal, scope, unknownBricks }?: CreateRootOptions): {
|
|
25
|
-
render(brick: BrickConf | BrickConf[], { theme, context, functions, templates, i18n: i18nData, }?: RenderOptions): Promise<void>;
|
|
26
|
+
render(brick: BrickConf | BrickConf[], { theme, uiVersion, context, functions, templates, i18n: i18nData, }?: RenderOptions): Promise<void>;
|
|
26
27
|
unmount(): void;
|
|
27
28
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -20,3 +20,4 @@ export { matchPath } from "./internal/matchPath.js";
|
|
|
20
20
|
export { Notification, type NotificationOptions } from "./Notification.js";
|
|
21
21
|
export { Dialog, type DialogOptions } from "./Dialog.js";
|
|
22
22
|
export * from "./getV2RuntimeFromDll.js";
|
|
23
|
+
export { setUIVersion } from "./setUIVersion.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/runtime",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.2",
|
|
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.8",
|
|
67
67
|
"@next-core/test-next": "^1.0.11"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "3b2a41f4ae691591f0d90b878ae49ab2e4c9631c"
|
|
70
70
|
}
|