@next-core/runtime 1.22.6 → 1.22.7
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/internal/interfaces.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js +3 -6
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/esm/internal/interfaces.js.map +1 -1
- package/dist/esm/internal/secret_internals.js +3 -6
- package/dist/esm/internal/secret_internals.js.map +1 -1
- package/dist/types/internal/interfaces.d.ts +2 -2
- package/dist/types/internal/secret_internals.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","names":[],"sources":["../../../src/internal/interfaces.ts"],"sourcesContent":["import type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport type {\n BrickEventHandler,\n BrickEventsMap,\n CustomTemplate,\n RouteConf,\n RuntimeSnippet,\n CustomTemplateProxy,\n CustomTemplateProxyBasicProperty,\n CustomTemplateProxySlot,\n SlotsConfOfBricks,\n} from \"@next-core/types\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { RuntimeBrickConfOfFormSymbols } from \"./FormRenderer/constants.js\";\n\nexport interface RuntimeContext extends LegacyCompatibleRuntimeContext {\n ctxStore: DataStore<\"CTX\">;\n tplStateStoreMap: Map<string, DataStore<\"STATE\">>;\n pendingPermissionsPreCheck: (Promise<unknown> | undefined)[];\n tplStateStoreId?: string;\n // `useBrick` has a local tpl state store scope\n tplStateStoreScope?: DataStore<\"STATE\">[];\n forEachItem?: unknown;\n forEachIndex?: number;\n appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncPropertyEntry = [\n name: string,\n value: Promise<unknown>,\n ignoreUndefined?: boolean,\n];\n\nexport interface ElementHolder {\n element?: HTMLElement | null;\n}\n\nexport interface RenderRoot extends BaseRenderNode {\n tag: RenderTag.ROOT;\n container?: HTMLElement | DocumentFragment;\n createPortal:\n | HTMLElement\n | DocumentFragment\n | (() => HTMLElement | DocumentFragment);\n}\n\nexport interface RenderBrick extends BaseRenderNode, RuntimeBrick {\n tag: RenderTag.BRICK;\n return: RenderReturnNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface RenderPlaceholder extends BaseRenderNode {\n tag: RenderTag.PLACEHOLDER;\n return: RenderReturnNode;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderChildNode;\n sibling?: RenderChildNode;\n return?: RenderReturnNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = RenderRoot | RenderBrick | RenderPlaceholder;\n\nexport type RenderChildNode = RenderBrick | RenderPlaceholder;\nexport type RenderReturnNode = RenderRoot | RenderBrick;\n\nexport interface RuntimeBrick {\n type: string;\n properties?: Record<string, unknown>;\n events?: BrickEventsMap;\n slotId?: string;\n element?: RuntimeBrickElement | null;\n iid?: string;\n runtimeContext: RuntimeContext;\n tplHostMetadata?: TemplateHostMetadata;\n portal?: boolean;\n ref?: string;\n}\n\nexport type MetaInfoOfEventListener = [\n string,\n // For compatibility of devtools, leave the second argument there.\n null | undefined,\n BrickEventHandler,\n];\n\nexport type RememberedEventListener = [string, EventListener];\n\nexport interface RuntimeBrickElement extends HTMLElement {\n $$typeof?: \"brick\" | \"provider\" | \"custom-template\" | \"native\" | \"invalid\";\n /** Meta info of listeners, for devtools only */\n $$eventListeners?: MetaInfoOfEventListener[];\n /** Remembered listeners for unbinding */\n $$listeners?: RememberedEventListener[];\n /** Remembered proxy listeners for unbinding */\n $$proxyListeners?: RememberedEventListener[];\n /** Find element by ref in a custom template */\n $$getElementByRef?: (ref: string) => HTMLElement | null | undefined;\n $$tplStateStore?: DataStore<\"STATE\">;\n}\n\nexport interface TemplateHostMetadata {\n internalBricksByRef: Map<string, RuntimeBrick>;\n tplStateStoreId: string;\n proxy?: CustomTemplateProxy;\n}\n\nexport type TemplateHostBrick = RuntimeBrick & {\n tplHostMetadata: TemplateHostMetadata;\n};\n\nexport interface TemplateHostContext {\n reversedProxies: ReversedProxies;\n asyncHostPropertyEntries: AsyncPropertyEntry[];\n externalSlots?: SlotsConfOfBricks;\n tplStateStoreId: string;\n hostBrick: TemplateHostBrick;\n}\n\ninterface ReversedProxies {\n properties: Map<string, ReversedPropertyProxy[]>;\n slots: Map<string, ReversedSlotProxy[]>;\n}\n\ninterface ReversedPropertyProxy {\n from: string;\n to: CustomTemplateProxyBasicProperty;\n}\n\ninterface ReversedSlotProxy {\n from: string;\n to: CustomTemplateProxySlot;\n}\n\nexport type RuntimeBrickConfWithSymbols = RuntimeBrickConfWithTplSymbols &\n RuntimeBrickConfOfFormSymbols;\n\nexport interface DataValueOption {\n tplStateStoreId?: string;\n}\n\nexport type PreviewStoryboardPatch =\n | CustomTemplate\n | RouteConf\n | RuntimeSnippet;\n\nexport interface PreviewOption {\n appId: string;\n formId?: string;\n updateStoryboardType?: \"route\" | \"template\" | \"snippet\";\n
|
|
1
|
+
{"version":3,"file":"interfaces.js","names":[],"sources":["../../../src/internal/interfaces.ts"],"sourcesContent":["import type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport type {\n BrickEventHandler,\n BrickEventsMap,\n CustomTemplate,\n RouteConf,\n RuntimeSnippet,\n CustomTemplateProxy,\n CustomTemplateProxyBasicProperty,\n CustomTemplateProxySlot,\n SlotsConfOfBricks,\n Storyboard,\n} from \"@next-core/types\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { RuntimeBrickConfOfFormSymbols } from \"./FormRenderer/constants.js\";\n\nexport interface RuntimeContext extends LegacyCompatibleRuntimeContext {\n ctxStore: DataStore<\"CTX\">;\n tplStateStoreMap: Map<string, DataStore<\"STATE\">>;\n pendingPermissionsPreCheck: (Promise<unknown> | undefined)[];\n tplStateStoreId?: string;\n // `useBrick` has a local tpl state store scope\n tplStateStoreScope?: DataStore<\"STATE\">[];\n forEachItem?: unknown;\n forEachIndex?: number;\n appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncPropertyEntry = [\n name: string,\n value: Promise<unknown>,\n ignoreUndefined?: boolean,\n];\n\nexport interface ElementHolder {\n element?: HTMLElement | null;\n}\n\nexport interface RenderRoot extends BaseRenderNode {\n tag: RenderTag.ROOT;\n container?: HTMLElement | DocumentFragment;\n createPortal:\n | HTMLElement\n | DocumentFragment\n | (() => HTMLElement | DocumentFragment);\n}\n\nexport interface RenderBrick extends BaseRenderNode, RuntimeBrick {\n tag: RenderTag.BRICK;\n return: RenderReturnNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface RenderPlaceholder extends BaseRenderNode {\n tag: RenderTag.PLACEHOLDER;\n return: RenderReturnNode;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderChildNode;\n sibling?: RenderChildNode;\n return?: RenderReturnNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = RenderRoot | RenderBrick | RenderPlaceholder;\n\nexport type RenderChildNode = RenderBrick | RenderPlaceholder;\nexport type RenderReturnNode = RenderRoot | RenderBrick;\n\nexport interface RuntimeBrick {\n type: string;\n properties?: Record<string, unknown>;\n events?: BrickEventsMap;\n slotId?: string;\n element?: RuntimeBrickElement | null;\n iid?: string;\n runtimeContext: RuntimeContext;\n tplHostMetadata?: TemplateHostMetadata;\n portal?: boolean;\n ref?: string;\n}\n\nexport type MetaInfoOfEventListener = [\n string,\n // For compatibility of devtools, leave the second argument there.\n null | undefined,\n BrickEventHandler,\n];\n\nexport type RememberedEventListener = [string, EventListener];\n\nexport interface RuntimeBrickElement extends HTMLElement {\n $$typeof?: \"brick\" | \"provider\" | \"custom-template\" | \"native\" | \"invalid\";\n /** Meta info of listeners, for devtools only */\n $$eventListeners?: MetaInfoOfEventListener[];\n /** Remembered listeners for unbinding */\n $$listeners?: RememberedEventListener[];\n /** Remembered proxy listeners for unbinding */\n $$proxyListeners?: RememberedEventListener[];\n /** Find element by ref in a custom template */\n $$getElementByRef?: (ref: string) => HTMLElement | null | undefined;\n $$tplStateStore?: DataStore<\"STATE\">;\n}\n\nexport interface TemplateHostMetadata {\n internalBricksByRef: Map<string, RuntimeBrick>;\n tplStateStoreId: string;\n proxy?: CustomTemplateProxy;\n}\n\nexport type TemplateHostBrick = RuntimeBrick & {\n tplHostMetadata: TemplateHostMetadata;\n};\n\nexport interface TemplateHostContext {\n reversedProxies: ReversedProxies;\n asyncHostPropertyEntries: AsyncPropertyEntry[];\n externalSlots?: SlotsConfOfBricks;\n tplStateStoreId: string;\n hostBrick: TemplateHostBrick;\n}\n\ninterface ReversedProxies {\n properties: Map<string, ReversedPropertyProxy[]>;\n slots: Map<string, ReversedSlotProxy[]>;\n}\n\ninterface ReversedPropertyProxy {\n from: string;\n to: CustomTemplateProxyBasicProperty;\n}\n\ninterface ReversedSlotProxy {\n from: string;\n to: CustomTemplateProxySlot;\n}\n\nexport type RuntimeBrickConfWithSymbols = RuntimeBrickConfWithTplSymbols &\n RuntimeBrickConfOfFormSymbols;\n\nexport interface DataValueOption {\n tplStateStoreId?: string;\n}\n\nexport type PreviewStoryboardPatch =\n | CustomTemplate\n | RouteConf\n | RuntimeSnippet;\n\nexport interface PreviewOption {\n appId: string;\n formId?: string;\n updateStoryboardType?: \"route\" | \"template\" | \"snippet\";\n collectUsedContracts?(storyboard: Storyboard): string[] | Promise<string[]>;\n}\n"],"mappings":""}
|
|
@@ -18,7 +18,6 @@ exports.updateStoryboardByRoute = updateStoryboardByRoute;
|
|
|
18
18
|
exports.updateStoryboardBySnippet = updateStoryboardBySnippet;
|
|
19
19
|
exports.updateStoryboardByTemplate = updateStoryboardByTemplate;
|
|
20
20
|
exports.updateTemplatePreviewSettings = updateTemplatePreviewSettings;
|
|
21
|
-
var _loader = require("@next-core/loader");
|
|
22
21
|
var _lodash = require("lodash");
|
|
23
22
|
var _Runtime = require("./Runtime.js");
|
|
24
23
|
var _Renderer = require("./Renderer.js");
|
|
@@ -237,7 +236,7 @@ function getRenderId() {
|
|
|
237
236
|
async function getAddedContracts(storyboardPatch, {
|
|
238
237
|
appId,
|
|
239
238
|
updateStoryboardType,
|
|
240
|
-
|
|
239
|
+
collectUsedContracts
|
|
241
240
|
}) {
|
|
242
241
|
const storyboard = (0, _Runtime._internalApiGetStoryboardInBootstrapData)(appId);
|
|
243
242
|
let updatedStoryboard;
|
|
@@ -263,10 +262,8 @@ async function getAddedContracts(storyboardPatch, {
|
|
|
263
262
|
};
|
|
264
263
|
}
|
|
265
264
|
const addedContracts = [];
|
|
266
|
-
if (updatedStoryboard &&
|
|
267
|
-
|
|
268
|
-
const provider = document.createElement(collectContractProvider);
|
|
269
|
-
const contractApis = await provider.resolve(updatedStoryboard);
|
|
265
|
+
if (updatedStoryboard && collectUsedContracts) {
|
|
266
|
+
const contractApis = await collectUsedContracts(updatedStoryboard);
|
|
270
267
|
contractApis.forEach(api => {
|
|
271
268
|
var _storyboard$meta;
|
|
272
269
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["_loader","require","_lodash","_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","provider","collectContractProvider","updatedStoryboard","meta","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","loadBricksImperatively","contractApis","resolve","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 { loadBricksImperatively } from \"@next-core/loader\";\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(settings, \"properties\", \"events\", \"lifeCycle\", \"context\"),\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 {\n appId,\n updateStoryboardType,\n provider: collectContractProvider,\n }: 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 && collectContractProvider) {\n await loadBricksImperatively([collectContractProvider], getBrickPackages());\n\n const provider = document.createElement(collectContractProvider) as any;\n const contractApis = await provider.resolve(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,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,gBAAA,GAAAJ,OAAA;AAQA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAWO,eAAeY,cAAcA,CAClCC,QAA4B,EAC5BC,IAAa,EACkB;EAAA,IAAAC,qBAAA,EAAA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UAAU,gBAAAmF,gBAAA,GAAVnF,UAAU,CAAEyE,IAAI,cAAAU,gBAAA,gBAAAA,gBAAA,GAAhBA,gBAAA,CAAkBG,SAAS,cAAAH,gBAAA,eAA3BA,gBAAA,CAA6BI,IAAI,CAC/BC,QAAQ,IACPA,QAAQ,CAACH,WAAW,KAAKA,WAAW,IAAIG,QAAQ,CAAC/D,IAAI,KAAKA,IAC9D,CAAC,GACD;QACAoD,cAAc,CAACY,IAAI,CAACP,GAAG,CAAC;MAC1B;IACF,CAAC,CAAC;EACJ;EAEA,OAAOL,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","$$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(settings, \"properties\", \"events\", \"lifeCycle\", \"context\"),\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.namespace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e;EACjB;EAEA,MAAMC,cAAwB,GAAG,EAAE;EAEnC,IAAIL,iBAAiB,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","names":[],"sources":["../../../src/internal/interfaces.ts"],"sourcesContent":["import type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport type {\n BrickEventHandler,\n BrickEventsMap,\n CustomTemplate,\n RouteConf,\n RuntimeSnippet,\n CustomTemplateProxy,\n CustomTemplateProxyBasicProperty,\n CustomTemplateProxySlot,\n SlotsConfOfBricks,\n} from \"@next-core/types\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { RuntimeBrickConfOfFormSymbols } from \"./FormRenderer/constants.js\";\n\nexport interface RuntimeContext extends LegacyCompatibleRuntimeContext {\n ctxStore: DataStore<\"CTX\">;\n tplStateStoreMap: Map<string, DataStore<\"STATE\">>;\n pendingPermissionsPreCheck: (Promise<unknown> | undefined)[];\n tplStateStoreId?: string;\n // `useBrick` has a local tpl state store scope\n tplStateStoreScope?: DataStore<\"STATE\">[];\n forEachItem?: unknown;\n forEachIndex?: number;\n appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncPropertyEntry = [\n name: string,\n value: Promise<unknown>,\n ignoreUndefined?: boolean,\n];\n\nexport interface ElementHolder {\n element?: HTMLElement | null;\n}\n\nexport interface RenderRoot extends BaseRenderNode {\n tag: RenderTag.ROOT;\n container?: HTMLElement | DocumentFragment;\n createPortal:\n | HTMLElement\n | DocumentFragment\n | (() => HTMLElement | DocumentFragment);\n}\n\nexport interface RenderBrick extends BaseRenderNode, RuntimeBrick {\n tag: RenderTag.BRICK;\n return: RenderReturnNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface RenderPlaceholder extends BaseRenderNode {\n tag: RenderTag.PLACEHOLDER;\n return: RenderReturnNode;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderChildNode;\n sibling?: RenderChildNode;\n return?: RenderReturnNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = RenderRoot | RenderBrick | RenderPlaceholder;\n\nexport type RenderChildNode = RenderBrick | RenderPlaceholder;\nexport type RenderReturnNode = RenderRoot | RenderBrick;\n\nexport interface RuntimeBrick {\n type: string;\n properties?: Record<string, unknown>;\n events?: BrickEventsMap;\n slotId?: string;\n element?: RuntimeBrickElement | null;\n iid?: string;\n runtimeContext: RuntimeContext;\n tplHostMetadata?: TemplateHostMetadata;\n portal?: boolean;\n ref?: string;\n}\n\nexport type MetaInfoOfEventListener = [\n string,\n // For compatibility of devtools, leave the second argument there.\n null | undefined,\n BrickEventHandler,\n];\n\nexport type RememberedEventListener = [string, EventListener];\n\nexport interface RuntimeBrickElement extends HTMLElement {\n $$typeof?: \"brick\" | \"provider\" | \"custom-template\" | \"native\" | \"invalid\";\n /** Meta info of listeners, for devtools only */\n $$eventListeners?: MetaInfoOfEventListener[];\n /** Remembered listeners for unbinding */\n $$listeners?: RememberedEventListener[];\n /** Remembered proxy listeners for unbinding */\n $$proxyListeners?: RememberedEventListener[];\n /** Find element by ref in a custom template */\n $$getElementByRef?: (ref: string) => HTMLElement | null | undefined;\n $$tplStateStore?: DataStore<\"STATE\">;\n}\n\nexport interface TemplateHostMetadata {\n internalBricksByRef: Map<string, RuntimeBrick>;\n tplStateStoreId: string;\n proxy?: CustomTemplateProxy;\n}\n\nexport type TemplateHostBrick = RuntimeBrick & {\n tplHostMetadata: TemplateHostMetadata;\n};\n\nexport interface TemplateHostContext {\n reversedProxies: ReversedProxies;\n asyncHostPropertyEntries: AsyncPropertyEntry[];\n externalSlots?: SlotsConfOfBricks;\n tplStateStoreId: string;\n hostBrick: TemplateHostBrick;\n}\n\ninterface ReversedProxies {\n properties: Map<string, ReversedPropertyProxy[]>;\n slots: Map<string, ReversedSlotProxy[]>;\n}\n\ninterface ReversedPropertyProxy {\n from: string;\n to: CustomTemplateProxyBasicProperty;\n}\n\ninterface ReversedSlotProxy {\n from: string;\n to: CustomTemplateProxySlot;\n}\n\nexport type RuntimeBrickConfWithSymbols = RuntimeBrickConfWithTplSymbols &\n RuntimeBrickConfOfFormSymbols;\n\nexport interface DataValueOption {\n tplStateStoreId?: string;\n}\n\nexport type PreviewStoryboardPatch =\n | CustomTemplate\n | RouteConf\n | RuntimeSnippet;\n\nexport interface PreviewOption {\n appId: string;\n formId?: string;\n updateStoryboardType?: \"route\" | \"template\" | \"snippet\";\n
|
|
1
|
+
{"version":3,"file":"interfaces.js","names":[],"sources":["../../../src/internal/interfaces.ts"],"sourcesContent":["import type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport type {\n BrickEventHandler,\n BrickEventsMap,\n CustomTemplate,\n RouteConf,\n RuntimeSnippet,\n CustomTemplateProxy,\n CustomTemplateProxyBasicProperty,\n CustomTemplateProxySlot,\n SlotsConfOfBricks,\n Storyboard,\n} from \"@next-core/types\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./CustomTemplates/constants.js\";\nimport { RuntimeBrickConfOfFormSymbols } from \"./FormRenderer/constants.js\";\n\nexport interface RuntimeContext extends LegacyCompatibleRuntimeContext {\n ctxStore: DataStore<\"CTX\">;\n tplStateStoreMap: Map<string, DataStore<\"STATE\">>;\n pendingPermissionsPreCheck: (Promise<unknown> | undefined)[];\n tplStateStoreId?: string;\n // `useBrick` has a local tpl state store scope\n tplStateStoreScope?: DataStore<\"STATE\">[];\n forEachItem?: unknown;\n forEachIndex?: number;\n appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncPropertyEntry = [\n name: string,\n value: Promise<unknown>,\n ignoreUndefined?: boolean,\n];\n\nexport interface ElementHolder {\n element?: HTMLElement | null;\n}\n\nexport interface RenderRoot extends BaseRenderNode {\n tag: RenderTag.ROOT;\n container?: HTMLElement | DocumentFragment;\n createPortal:\n | HTMLElement\n | DocumentFragment\n | (() => HTMLElement | DocumentFragment);\n}\n\nexport interface RenderBrick extends BaseRenderNode, RuntimeBrick {\n tag: RenderTag.BRICK;\n return: RenderReturnNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface RenderPlaceholder extends BaseRenderNode {\n tag: RenderTag.PLACEHOLDER;\n return: RenderReturnNode;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderChildNode;\n sibling?: RenderChildNode;\n return?: RenderReturnNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = RenderRoot | RenderBrick | RenderPlaceholder;\n\nexport type RenderChildNode = RenderBrick | RenderPlaceholder;\nexport type RenderReturnNode = RenderRoot | RenderBrick;\n\nexport interface RuntimeBrick {\n type: string;\n properties?: Record<string, unknown>;\n events?: BrickEventsMap;\n slotId?: string;\n element?: RuntimeBrickElement | null;\n iid?: string;\n runtimeContext: RuntimeContext;\n tplHostMetadata?: TemplateHostMetadata;\n portal?: boolean;\n ref?: string;\n}\n\nexport type MetaInfoOfEventListener = [\n string,\n // For compatibility of devtools, leave the second argument there.\n null | undefined,\n BrickEventHandler,\n];\n\nexport type RememberedEventListener = [string, EventListener];\n\nexport interface RuntimeBrickElement extends HTMLElement {\n $$typeof?: \"brick\" | \"provider\" | \"custom-template\" | \"native\" | \"invalid\";\n /** Meta info of listeners, for devtools only */\n $$eventListeners?: MetaInfoOfEventListener[];\n /** Remembered listeners for unbinding */\n $$listeners?: RememberedEventListener[];\n /** Remembered proxy listeners for unbinding */\n $$proxyListeners?: RememberedEventListener[];\n /** Find element by ref in a custom template */\n $$getElementByRef?: (ref: string) => HTMLElement | null | undefined;\n $$tplStateStore?: DataStore<\"STATE\">;\n}\n\nexport interface TemplateHostMetadata {\n internalBricksByRef: Map<string, RuntimeBrick>;\n tplStateStoreId: string;\n proxy?: CustomTemplateProxy;\n}\n\nexport type TemplateHostBrick = RuntimeBrick & {\n tplHostMetadata: TemplateHostMetadata;\n};\n\nexport interface TemplateHostContext {\n reversedProxies: ReversedProxies;\n asyncHostPropertyEntries: AsyncPropertyEntry[];\n externalSlots?: SlotsConfOfBricks;\n tplStateStoreId: string;\n hostBrick: TemplateHostBrick;\n}\n\ninterface ReversedProxies {\n properties: Map<string, ReversedPropertyProxy[]>;\n slots: Map<string, ReversedSlotProxy[]>;\n}\n\ninterface ReversedPropertyProxy {\n from: string;\n to: CustomTemplateProxyBasicProperty;\n}\n\ninterface ReversedSlotProxy {\n from: string;\n to: CustomTemplateProxySlot;\n}\n\nexport type RuntimeBrickConfWithSymbols = RuntimeBrickConfWithTplSymbols &\n RuntimeBrickConfOfFormSymbols;\n\nexport interface DataValueOption {\n tplStateStoreId?: string;\n}\n\nexport type PreviewStoryboardPatch =\n | CustomTemplate\n | RouteConf\n | RuntimeSnippet;\n\nexport interface PreviewOption {\n appId: string;\n formId?: string;\n updateStoryboardType?: \"route\" | \"template\" | \"snippet\";\n collectUsedContracts?(storyboard: Storyboard): string[] | Promise<string[]>;\n}\n"],"mappings":""}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import { loadBricksImperatively } from "@next-core/loader";
|
|
4
3
|
import { pick } from "lodash";
|
|
5
4
|
import { _internalApiGetRenderId, _internalApiGetRuntimeContext, _internalApiGetStoryboardInBootstrapData, getBrickPackages } from "./Runtime.js";
|
|
6
5
|
import { createScopedRuntimeContext, postAsyncRender, renderBrick } from "./Renderer.js";
|
|
@@ -223,7 +222,7 @@ function _getAddedContracts() {
|
|
|
223
222
|
var {
|
|
224
223
|
appId,
|
|
225
224
|
updateStoryboardType,
|
|
226
|
-
|
|
225
|
+
collectUsedContracts
|
|
227
226
|
} = _ref5;
|
|
228
227
|
var storyboard = _internalApiGetStoryboardInBootstrapData(appId);
|
|
229
228
|
var updatedStoryboard;
|
|
@@ -249,10 +248,8 @@ function _getAddedContracts() {
|
|
|
249
248
|
};
|
|
250
249
|
}
|
|
251
250
|
var addedContracts = [];
|
|
252
|
-
if (updatedStoryboard &&
|
|
253
|
-
yield
|
|
254
|
-
var provider = document.createElement(collectContractProvider);
|
|
255
|
-
var contractApis = yield provider.resolve(updatedStoryboard);
|
|
251
|
+
if (updatedStoryboard && collectUsedContracts) {
|
|
252
|
+
var contractApis = yield collectUsedContracts(updatedStoryboard);
|
|
256
253
|
contractApis.forEach(api => {
|
|
257
254
|
var _storyboard$meta;
|
|
258
255
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["loadBricksImperatively","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","provider","collectContractProvider","updatedStoryboard","meta","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","resolve","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 { loadBricksImperatively } from \"@next-core/loader\";\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(settings, \"properties\", \"events\", \"lifeCycle\", \"context\"),\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 {\n appId,\n updateStoryboardType,\n provider: collectContractProvider,\n }: 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 && collectContractProvider) {\n await loadBricksImperatively([collectContractProvider], getBrickPackages());\n\n const provider = document.createElement(collectContractProvider) as any;\n const contractApis = await provider.resolve(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,sBAAsB,QAAQ,mBAAmB;AAC1D,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SACEC,uBAAuB,EACvBC,6BAA6B,EAC7BC,wCAAwC,EACxCC,gBAAgB,QACX,cAAc;AACrB,SAC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,IAAI,KAAKA,IAC9D,CAAC,GACD;UACAoD,cAAc,CAACW,IAAI,CAACP,GAAG,CAAC;QAC1B;MACF,CAAC,CAAC;IACJ;IAEA,OAAOJ,cAAc;EACvB,CAAC;EAAA,OAAAV,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","$$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(settings, \"properties\", \"events\", \"lifeCycle\", \"context\"),\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,w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AA,OAAAT,kBAAA,CAAA/H,KAAA,OAAAC,SAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LegacyCompatibleRuntimeContext } from "@next-core/inject";
|
|
2
|
-
import type { BrickEventHandler, BrickEventsMap, CustomTemplate, RouteConf, RuntimeSnippet, CustomTemplateProxy, CustomTemplateProxyBasicProperty, CustomTemplateProxySlot, SlotsConfOfBricks } from "@next-core/types";
|
|
2
|
+
import type { BrickEventHandler, BrickEventsMap, CustomTemplate, RouteConf, RuntimeSnippet, CustomTemplateProxy, CustomTemplateProxyBasicProperty, CustomTemplateProxySlot, SlotsConfOfBricks, Storyboard } from "@next-core/types";
|
|
3
3
|
import type { DataStore } from "./data/DataStore.js";
|
|
4
4
|
import { RenderTag } from "./enums.js";
|
|
5
5
|
import { RuntimeBrickConfWithTplSymbols } from "./CustomTemplates/constants.js";
|
|
@@ -115,6 +115,6 @@ export interface PreviewOption {
|
|
|
115
115
|
appId: string;
|
|
116
116
|
formId?: string;
|
|
117
117
|
updateStoryboardType?: "route" | "template" | "snippet";
|
|
118
|
-
|
|
118
|
+
collectUsedContracts?(storyboard: Storyboard): string[] | Promise<string[]>;
|
|
119
119
|
}
|
|
120
120
|
export {};
|
|
@@ -31,4 +31,4 @@ export declare function getContextValue(name: string, { tplStateStoreId }: DataV
|
|
|
31
31
|
export declare function getAllContextValues({ tplStateStoreId, }: DataValueOption): Record<string, unknown>;
|
|
32
32
|
export declare function getBrickPackagesById(id: string): import("@next-core/types").BrickPackage | undefined;
|
|
33
33
|
export declare function getRenderId(): string | undefined;
|
|
34
|
-
export declare function getAddedContracts(storyboardPatch: PreviewStoryboardPatch, { appId, updateStoryboardType,
|
|
34
|
+
export declare function getAddedContracts(storyboardPatch: PreviewStoryboardPatch, { appId, updateStoryboardType, collectUsedContracts }: PreviewOption): Promise<string[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/runtime",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.7",
|
|
4
4
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/runtime",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"repository": {
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"@next-core/build-next-libs": "^1.0.7",
|
|
66
66
|
"@next-core/test-next": "^1.0.9"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "0ff39700a261a82c4b018c9ca0bb89811f50e0a0"
|
|
69
69
|
}
|