@next-core/runtime 1.19.3 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/internal/CustomTemplates/constants.js.map +1 -1
  2. package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js +3 -3
  3. package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
  4. package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js +10 -13
  5. package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
  6. package/dist/cjs/internal/FormRenderer/expandFormRenderer.js +2 -2
  7. package/dist/cjs/internal/FormRenderer/expandFormRenderer.js.map +1 -1
  8. package/dist/cjs/internal/Renderer.js +8 -11
  9. package/dist/cjs/internal/Renderer.js.map +1 -1
  10. package/dist/cjs/internal/compute/computeRealProperties.js +24 -10
  11. package/dist/cjs/internal/compute/computeRealProperties.js.map +1 -1
  12. package/dist/cjs/internal/data/DataStore.js +6 -5
  13. package/dist/cjs/internal/data/DataStore.js.map +1 -1
  14. package/dist/cjs/internal/interfaces.js.map +1 -1
  15. package/dist/cjs/internal/secret_internals.js +49 -1
  16. package/dist/cjs/internal/secret_internals.js.map +1 -1
  17. package/dist/esm/internal/CustomTemplates/constants.js.map +1 -1
  18. package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js +3 -3
  19. package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
  20. package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js +12 -20
  21. package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
  22. package/dist/esm/internal/FormRenderer/expandFormRenderer.js +2 -2
  23. package/dist/esm/internal/FormRenderer/expandFormRenderer.js.map +1 -1
  24. package/dist/esm/internal/Renderer.js +9 -12
  25. package/dist/esm/internal/Renderer.js.map +1 -1
  26. package/dist/esm/internal/compute/computeRealProperties.js +32 -19
  27. package/dist/esm/internal/compute/computeRealProperties.js.map +1 -1
  28. package/dist/esm/internal/data/DataStore.js +6 -5
  29. package/dist/esm/internal/data/DataStore.js.map +1 -1
  30. package/dist/esm/internal/interfaces.js.map +1 -1
  31. package/dist/esm/internal/secret_internals.js +56 -2
  32. package/dist/esm/internal/secret_internals.js.map +1 -1
  33. package/dist/types/internal/CustomTemplates/constants.d.ts +2 -2
  34. package/dist/types/internal/CustomTemplates/expandCustomTemplate.d.ts +2 -2
  35. package/dist/types/internal/CustomTemplates/setupTemplateProxy.d.ts +2 -2
  36. package/dist/types/internal/FormRenderer/expandFormRenderer.d.ts +2 -2
  37. package/dist/types/internal/compute/computeRealProperties.d.ts +4 -3
  38. package/dist/types/internal/data/DataStore.d.ts +2 -2
  39. package/dist/types/internal/interfaces.d.ts +14 -4
  40. package/dist/types/internal/secret_internals.d.ts +2 -1
  41. package/package.json +6 -6
@@ -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 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 appendI18nNamespace?: string;\n\n formStateStoreMap: Map<string, DataStore<\"FORM_STATE\">>;\n formStateStoreId?: string;\n formStateStoreScope?: DataStore<\"FORM_STATE\">[];\n}\n\nexport type AsyncComputedProperties = Promise<Record<string, unknown>>;\n\nexport type AsyncProperties = Record<string, Promise<unknown>>;\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: RenderNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderBrick;\n sibling?: RenderBrick;\n return?: RenderNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = 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 asyncHostProperties: AsyncProperties;\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"],"mappings":""}
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 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: RenderNode;\n hasTrackingControls?: boolean;\n}\n\nexport interface BaseRenderNode {\n tag: RenderTag;\n child?: RenderBrick;\n sibling?: RenderBrick;\n return?: RenderNode | null;\n childElements?: HTMLElement[];\n}\n\nexport type RenderNode = 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 provider?: string;\n}\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import { flushStableLoadBricks } from "@next-core/loader";
3
+ import { flushStableLoadBricks, loadBricksImperatively } from "@next-core/loader";
4
4
  import { pick } from "lodash";
5
5
  import { _internalApiGetRenderId, _internalApiGetRuntimeContext, _internalApiGetStoryboardInBootstrapData, getBrickPackages } from "./Runtime.js";
6
6
  import { renderBrick } from "./Renderer.js";
@@ -159,9 +159,12 @@ export function updateTemplatePreviewSettings(appId, templateId, settings) {
159
159
  brick: templateId
160
160
  }, pick(settings, "properties", "events", "lifeCycle", "context"))]);
161
161
  }
162
+ function getSnippetPreviewPath(snippetId) {
163
+ return "${APP.homepage}/_dev_only_/snippet-preview/".concat(snippetId);
164
+ }
162
165
  export function updateStoryboardBySnippet(appId, snippetData) {
163
166
  var _snippetData$bricks;
164
- _updatePreviewSettings(appId, "${APP.homepage}/_dev_only_/snippet-preview/".concat(snippetData.snippetId), (_snippetData$bricks = snippetData.bricks) !== null && _snippetData$bricks !== void 0 && _snippetData$bricks.length ? snippetData.bricks : [{
167
+ _updatePreviewSettings(appId, getSnippetPreviewPath(snippetData.snippetId), (_snippetData$bricks = snippetData.bricks) !== null && _snippetData$bricks !== void 0 && _snippetData$bricks.length ? snippetData.bricks : [{
165
168
  brick: "span"
166
169
  }]);
167
170
  }
@@ -215,4 +218,55 @@ export function getBrickPackagesById(id) {
215
218
  export function getRenderId() {
216
219
  return _internalApiGetRenderId();
217
220
  }
221
+ export function getAddedContracts(_x3, _x4) {
222
+ return _getAddedContracts.apply(this, arguments);
223
+ }
224
+ function _getAddedContracts() {
225
+ _getAddedContracts = _asyncToGenerator(function* (storyboardPatch, _ref5) {
226
+ var {
227
+ appId,
228
+ updateStoryboardType,
229
+ provider: collectContractProvider
230
+ } = _ref5;
231
+ var storyboard = _internalApiGetStoryboardInBootstrapData(appId);
232
+ var updatedStoryboard;
233
+
234
+ // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts
235
+ if (updateStoryboardType === "route") {
236
+ updatedStoryboard = {
237
+ routes: [storyboardPatch]
238
+ };
239
+ } else if (updateStoryboardType === "template") {
240
+ updatedStoryboard = {
241
+ meta: {
242
+ customTemplates: [storyboardPatch]
243
+ }
244
+ };
245
+ } else if (updateStoryboardType === "snippet") {
246
+ var _storyboard$routes;
247
+ // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route
248
+ var snippetPreviewPath = getSnippetPreviewPath(storyboardPatch.snippetId);
249
+ var currentRoute = storyboard === null || storyboard === void 0 || (_storyboard$routes = storyboard.routes) === null || _storyboard$routes === void 0 ? void 0 : _storyboard$routes.find(route => route.path === snippetPreviewPath);
250
+ updatedStoryboard = {
251
+ routes: [currentRoute]
252
+ };
253
+ }
254
+ var addedContracts = [];
255
+ if (updatedStoryboard && collectContractProvider) {
256
+ yield loadBricksImperatively([collectContractProvider], getBrickPackages());
257
+ var provider = document.createElement(collectContractProvider);
258
+ var contractApis = yield provider.resolve(updatedStoryboard);
259
+ contractApis.forEach(api => {
260
+ var _storyboard$meta;
261
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
262
+ var [_, namespaceId, name] = api.match(/(.*)@(.*):\d\.\d\.\d/);
263
+ if (!(storyboard !== null && storyboard !== void 0 && (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 && (_storyboard$meta = _storyboard$meta.contracts) !== null && _storyboard$meta !== void 0 && _storyboard$meta.some(contract => contract.namespaceId === namespaceId && contract.name === name))) {
264
+ addedContracts.push(api);
265
+ }
266
+ });
267
+ }
268
+ return addedContracts;
269
+ });
270
+ return _getAddedContracts.apply(this, arguments);
271
+ }
218
272
  //# sourceMappingURL=secret_internals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"secret_internals.js","names":["flushStableLoadBricks","pick","_internalApiGetRenderId","_internalApiGetRuntimeContext","_internalApiGetStoryboardInBootstrapData","getBrickPackages","renderBrick","RendererContext","mountTree","unmountTree","RenderTag","computeRealValue","isStrictMode","warnAboutStrictMode","customTemplates","registerAppI18n","getTplStateStore","renderUseBrick","_x","_x2","_renderUseBrick","apply","arguments","_asyncToGenerator","useBrick","data","_runtimeContext$tplSt","_runtimeContext$formS","_output$node","tplStateStoreScope","formStateStoreScope","runtimeContext","_objectSpread","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","renderRoot","tag","ROOT","createPortal","transform","strict","output","properties","scopedStores","Promise","all","blockingList","map","store","waitForAll","node","portal","Error","child","tagName","type","mountUseBrick","_ref","element","portalRoot","document","querySelector","createElement","appendChild","handleAsyncAfterMount","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","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","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","updateStoryboardBySnippet","snippetData","_snippetData$bricks","snippetId","length","updateSnippetPreviewSettings","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","_ref3","tplStateStoreId","tplStateStore","getValue","ctxStore","getAllContextValues","_ref4","getAllValues","getBrickPackagesById","id","find","pkg","filePath","startsWith","getRenderId"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport { renderBrick } from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport type {\n DataValueOption,\n RenderRoot,\n RuntimeContext,\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 tplStateStoreScope: DataStore<\"STATE\">[] = [];\n const formStateStoreScope: DataStore<\"FORM_STATE\">[] = [];\n const runtimeContext: RuntimeContext = {\n ..._internalApiGetRuntimeContext()!,\n data,\n pendingPermissionsPreCheck: [],\n tplStateStoreScope,\n formStateStoreScope,\n };\n\n runtimeContext.tplStateStoreMap ??= new Map();\n runtimeContext.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 runtimeContext,\n rendererContext\n );\n\n flushStableLoadBricks();\n\n const scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[] = [\n ...tplStateStoreScope,\n ...formStateStoreScope,\n ];\n\n await Promise.all([\n ...output.blockingList,\n // Wait for local tpl state stores belong to current `useBrick` only.\n ...scopedStores.map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\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 for (const store of scopedStores) {\n store.handleAsyncAfterMount();\n }\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\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\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetData.snippetId}`,\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }]\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\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"],"mappings":";;AAOA,SAASA,qBAAqB,QAAQ,mBAAmB;AACzD,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SACEC,uBAAuB,EACvBC,6BAA6B,EAC7BC,wCAAwC,EACxCC,gBAAgB,QACX,cAAc;AACrB,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,eAAe,QAAQ,sBAAsB;AAOtD,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;AA2EnC,SAAAF,gBAAA;EAAAA,eAAA,GAAAG,iBAAA,CA3EM,WACLC,QAA4B,EAC5BC,IAAa,EACkB;IAAA,IAAAC,qBAAA,EAAAC,qBAAA,EAAAC,YAAA;IAC/B,IAAMC,kBAAwC,GAAG,EAAE;IACnD,IAAMC,mBAA8C,GAAG,EAAE;IACzD,IAAMC,cAA8B,GAAAC,aAAA,CAAAA,aAAA,KAC/B7B,6BAA6B,CAA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,IAAMlG,cAAc,GAAG5B,6BAA6B,CAAC,CAAE;EAEvD,IAAI+H,eAAe,EAAE;IACnB,IAAMC,aAAa,GAAGnH,gBAAgB,CAAAgB,aAAA,CAAAA,aAAA,KAE/BD,cAAc;MACjBmG;IAAe,IAEjB,OACF,CAAC;IACD,OAAOC,aAAa,CAACC,QAAQ,CAACxB,IAAI,CAAC;EACrC;EAEA,OAAO7E,cAAc,CAACsG,QAAQ,CAACD,QAAQ,CAACxB,IAAI,CAAC;AAC/C;AAEA,OAAO,SAAS0B,mBAAmBA,CAAAC,KAAA,EAEU;EAAA,IAFT;IAClCL;EACe,CAAC,GAAAK,KAAA;EAChB,IAAMxG,cAAc,GAAG5B,6BAA6B,CAAC,CAAE;EAEvD,IAAI+H,eAAe,EAAE;IACnB,IAAMC,aAAa,GAAGnH,gBAAgB,CAAAgB,aAAA,CAAAA,aAAA,KAE/BD,cAAc;MACjBmG;IAAe,IAEjB,OACF,CAAC;IACD,OAAOC,aAAa,CAACK,YAAY,CAAC,CAAC;EACrC;EAEA,OAAOzG,cAAc,CAACsG,QAAQ,CAACG,YAAY,CAAC,CAAC;AAC/C;AAEA,OAAO,SAASC,oBAAoBA,CAACC,EAAU,EAAE;EAC/C,OAAOrI,gBAAgB,CAAC,CAAC,CAACsI,IAAI,CAAEC,GAAG,IACjCA,GAAG,CAACF,EAAE,GAAGE,GAAG,CAACF,EAAE,KAAKA,EAAE,GAAGE,GAAG,CAACC,QAAQ,CAACC,UAAU,CAACJ,EAAE,CACrD,CAAC;AACH;AAEA,OAAO,SAASK,WAAWA,CAAA,EAAG;EAC5B,OAAO7I,uBAAuB,CAAC,CAAC;AAClC"}
1
+ {"version":3,"file":"secret_internals.js","names":["flushStableLoadBricks","loadBricksImperatively","pick","_internalApiGetRenderId","_internalApiGetRuntimeContext","_internalApiGetStoryboardInBootstrapData","getBrickPackages","renderBrick","RendererContext","mountTree","unmountTree","RenderTag","computeRealValue","isStrictMode","warnAboutStrictMode","customTemplates","registerAppI18n","getTplStateStore","renderUseBrick","_x","_x2","_renderUseBrick","apply","arguments","_asyncToGenerator","useBrick","data","_runtimeContext$tplSt","_runtimeContext$formS","_output$node","tplStateStoreScope","formStateStoreScope","runtimeContext","_objectSpread","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","renderRoot","tag","ROOT","createPortal","transform","strict","output","properties","scopedStores","Promise","all","blockingList","map","store","waitForAll","node","portal","Error","child","tagName","type","mountUseBrick","_ref","element","portalRoot","document","querySelector","createElement","appendChild","handleAsyncAfterMount","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","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","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","updateSnippetPreviewSettings","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","_ref3","tplStateStoreId","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} from \"@next-core/types\";\nimport {\n flushStableLoadBricks,\n loadBricksImperatively,\n} from \"@next-core/loader\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport { renderBrick } 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 RuntimeContext,\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 tplStateStoreScope: DataStore<\"STATE\">[] = [];\n const formStateStoreScope: DataStore<\"FORM_STATE\">[] = [];\n const runtimeContext: RuntimeContext = {\n ..._internalApiGetRuntimeContext()!,\n data,\n pendingPermissionsPreCheck: [],\n tplStateStoreScope,\n formStateStoreScope,\n };\n\n runtimeContext.tplStateStoreMap ??= new Map();\n runtimeContext.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 runtimeContext,\n rendererContext\n );\n\n flushStableLoadBricks();\n\n const scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[] = [\n ...tplStateStoreScope,\n ...formStateStoreScope,\n ];\n\n await Promise.all([\n ...output.blockingList,\n // Wait for local tpl state stores belong to current `useBrick` only.\n ...scopedStores.map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\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 for (const store of scopedStores) {\n store.handleAsyncAfterMount();\n }\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\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 }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }]\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\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":";;AAQA,SACEA,qBAAqB,EACrBC,sBAAsB,QACjB,mBAAmB;AAC1B,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SACEC,uBAAuB,EACvBC,6BAA6B,EAC7BC,wCAAwC,EACxCC,gBAAgB,QACX,cAAc;AACrB,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,eAAe,QAAQ,sBAAsB;AAStD,SAASC,SAAS,EAAEC,WAAW,QAAQ,YAAY;AACnD,SAASC,SAAS,QAAQ,YAAY;AACtC,SAAS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1
1
  import type { BrickConf } from "@next-core/types";
2
- import type { AsyncComputedProperties } from "../interfaces.js";
2
+ import type { AsyncPropertyEntry } from "../interfaces.js";
3
3
  export declare const symbolForAsyncComputedPropsFromHost: unique symbol;
4
4
  export declare const symbolForTplStateStoreId: unique symbol;
5
5
  export declare const symbolForTPlExternalForEachItem: unique symbol;
6
6
  export type RuntimeBrickConfWithTplSymbols = BrickConf & RuntimeBrickConfOfTplSymbols;
7
7
  export interface RuntimeBrickConfOfTplSymbols {
8
- [symbolForAsyncComputedPropsFromHost]?: AsyncComputedProperties;
8
+ [symbolForAsyncComputedPropsFromHost]?: AsyncPropertyEntry[];
9
9
  [symbolForTplStateStoreId]?: string;
10
10
  [symbolForTPlExternalForEachItem]?: unknown;
11
11
  }
@@ -1,4 +1,4 @@
1
1
  import type { BrickConf, UseSingleBrickConf } from "@next-core/types";
2
- import type { AsyncProperties, RuntimeBrick } from "../interfaces.js";
2
+ import type { AsyncPropertyEntry, RuntimeBrick } from "../interfaces.js";
3
3
  import type { RendererContext } from "../RendererContext.js";
4
- export declare function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(tplTagName: string, brickConf: T, hostBrick: RuntimeBrick, asyncHostProperties: AsyncProperties, rendererContext: RendererContext): T;
4
+ export declare function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(tplTagName: string, brickConf: T, hostBrick: RuntimeBrick, asyncHostPropertyEntries: AsyncPropertyEntry[], rendererContext: RendererContext): T;
@@ -1,7 +1,7 @@
1
1
  import type { SlotsConfOfBricks } from "@next-core/types";
2
2
  import { symbolForAsyncComputedPropsFromHost, symbolForTplStateStoreId } from "./constants.js";
3
- import type { AsyncComputedProperties, TemplateHostContext } from "../interfaces.js";
3
+ import type { AsyncPropertyEntry, TemplateHostContext } from "../interfaces.js";
4
4
  export declare function setupTemplateProxy(hostContext: TemplateHostContext, ref: string | undefined, slots: SlotsConfOfBricks): {
5
- [symbolForAsyncComputedPropsFromHost]: AsyncComputedProperties | undefined;
5
+ [symbolForAsyncComputedPropsFromHost]: AsyncPropertyEntry[] | undefined;
6
6
  [symbolForTplStateStoreId]: string;
7
7
  };
@@ -1,4 +1,4 @@
1
1
  import type { BrickConf } from "@next-core/types";
2
- import type { AsyncProperties, RuntimeBrick } from "../interfaces.js";
2
+ import type { AsyncPropertyEntry, RuntimeBrick } from "../interfaces.js";
3
3
  import type { RendererContext } from "../RendererContext.js";
4
- export declare function expandFormRenderer(formData: unknown, hostBrickConf: BrickConf, hostBrick: RuntimeBrick, asyncHostProperties: AsyncProperties, rendererContext: RendererContext): BrickConf;
4
+ export declare function expandFormRenderer(formData: unknown, hostBrickConf: BrickConf, hostBrick: RuntimeBrick, asyncHostPropertyEntries: AsyncPropertyEntry[], rendererContext: RendererContext): BrickConf;
@@ -1,5 +1,6 @@
1
1
  import { TrackingContextItem } from "./listenOnTrackingContext.js";
2
- import type { AsyncProperties, RuntimeContext } from "../interfaces.js";
3
- export declare function asyncComputeRealProperties(properties: Record<string, unknown> | undefined, runtimeContext: RuntimeContext, trackingContextList: TrackingContextItem[]): AsyncProperties;
4
- export declare function constructAsyncProperties(asyncProperties: AsyncProperties): Promise<Record<string, unknown>>;
2
+ import type { AsyncPropertyEntry, RuntimeContext } from "../interfaces.js";
3
+ export declare function asyncComputeRealPropertyEntries(properties: Record<string, unknown> | undefined, runtimeContext: RuntimeContext, trackingContextList: TrackingContextItem[]): AsyncPropertyEntry[];
4
+ export declare function computePropertyValue(asyncPropertyEntries: AsyncPropertyEntry[], propName: string): Promise<unknown>;
5
+ export declare function constructAsyncProperties(asyncPropertyEntries: AsyncPropertyEntry[]): Promise<Record<string, unknown>>;
5
6
  export declare function computeRealProperties(properties: Record<string, unknown> | undefined, runtimeContext: RuntimeContext): Record<string, unknown>;
@@ -1,6 +1,6 @@
1
1
  import type { BatchUpdateContextItem, BrickEventHandlerCallback, ContextConf } from "@next-core/types";
2
2
  import { ResolveOptions } from "./resolveData.js";
3
- import type { AsyncProperties, RuntimeBrick, RuntimeContext } from "../interfaces.js";
3
+ import type { AsyncPropertyEntry, RuntimeBrick, RuntimeContext } from "../interfaces.js";
4
4
  import type { RendererContext } from "../RendererContext.js";
5
5
  export type DataStoreType = "CTX" | "STATE" | "FORM_STATE";
6
6
  export interface DataStoreItem {
@@ -27,7 +27,7 @@ export declare class DataStore<T extends DataStoreType = "CTX"> {
27
27
  private getAffectListByContext;
28
28
  updateValues(values: BatchUpdateContextItem[], method: "assign" | "replace", argsFactory: (arg: unknown[]) => BatchUpdateContextItem): void;
29
29
  updateValue(name: string, value: unknown, method: "assign" | "replace" | "refresh" | "load", callback?: BrickEventHandlerCallback, callbackRuntimeContext?: RuntimeContext): void;
30
- define(dataConfs: ContextConf[] | undefined, runtimeContext: RuntimeContext, asyncHostProperties?: AsyncProperties): void;
30
+ define(dataConfs: ContextConf[] | undefined, runtimeContext: RuntimeContext, asyncHostPropertyEntries?: AsyncPropertyEntry[]): void;
31
31
  onChange(dataName: string, listener: EventListener): void;
32
32
  waitFor(dataNames: string[] | Set<string>): Promise<void>;
33
33
  waitForAll(): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { LegacyCompatibleRuntimeContext } from "@next-core/inject";
2
- import type { BrickEventHandler, BrickEventsMap, CustomTemplateProxy, CustomTemplateProxyBasicProperty, CustomTemplateProxySlot, SlotsConfOfBricks } from "@next-core/types";
2
+ import type { BrickEventHandler, BrickEventsMap, CustomTemplate, RouteConf, RuntimeSnippet, CustomTemplateProxy, CustomTemplateProxyBasicProperty, CustomTemplateProxySlot, SlotsConfOfBricks } 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";
@@ -16,8 +16,11 @@ export interface RuntimeContext extends LegacyCompatibleRuntimeContext {
16
16
  formStateStoreId?: string;
17
17
  formStateStoreScope?: DataStore<"FORM_STATE">[];
18
18
  }
19
- export type AsyncComputedProperties = Promise<Record<string, unknown>>;
20
- export type AsyncProperties = Record<string, Promise<unknown>>;
19
+ export type AsyncPropertyEntry = [
20
+ name: string,
21
+ value: Promise<unknown>,
22
+ ignoreUndefined?: boolean
23
+ ];
21
24
  export interface ElementHolder {
22
25
  element?: HTMLElement | null;
23
26
  }
@@ -79,7 +82,7 @@ export type TemplateHostBrick = RuntimeBrick & {
79
82
  };
80
83
  export interface TemplateHostContext {
81
84
  reversedProxies: ReversedProxies;
82
- asyncHostProperties: AsyncProperties;
85
+ asyncHostPropertyEntries: AsyncPropertyEntry[];
83
86
  externalSlots?: SlotsConfOfBricks;
84
87
  tplStateStoreId: string;
85
88
  hostBrick: TemplateHostBrick;
@@ -100,4 +103,11 @@ export type RuntimeBrickConfWithSymbols = RuntimeBrickConfWithTplSymbols & Runti
100
103
  export interface DataValueOption {
101
104
  tplStateStoreId?: string;
102
105
  }
106
+ export type PreviewStoryboardPatch = CustomTemplate | RouteConf | RuntimeSnippet;
107
+ export interface PreviewOption {
108
+ appId: string;
109
+ formId?: string;
110
+ updateStoryboardType?: "route" | "template" | "snippet";
111
+ provider?: string;
112
+ }
103
113
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { BrickConf, CustomTemplate, RouteConf, Storyboard, UseSingleBrickConf } from "@next-core/types";
2
2
  import { RendererContext } from "./RendererContext.js";
3
3
  import type { DataStore } from "./data/DataStore.js";
4
- import type { DataValueOption, RenderRoot } from "./interfaces.js";
4
+ import type { DataValueOption, PreviewOption, PreviewStoryboardPatch, RenderRoot } from "./interfaces.js";
5
5
  export type { DataValueOption, RuntimeContext } from "./interfaces.js";
6
6
  export interface RenderUseBrickResult {
7
7
  tagName: string | null;
@@ -30,3 +30,4 @@ export declare function getContextValue(name: string, { tplStateStoreId }: DataV
30
30
  export declare function getAllContextValues({ tplStateStoreId, }: DataValueOption): Record<string, unknown>;
31
31
  export declare function getBrickPackagesById(id: string): import("@next-core/types").BrickPackage | undefined;
32
32
  export declare function getRenderId(): string | undefined;
33
+ export declare function getAddedContracts(storyboardPatch: PreviewStoryboardPatch, { appId, updateStoryboardType, provider: collectContractProvider, }: PreviewOption): Promise<string[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/runtime",
3
- "version": "1.19.3",
3
+ "version": "1.20.0",
4
4
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/runtime",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -45,12 +45,12 @@
45
45
  "dependencies": {
46
46
  "@next-core/cook": "^2.2.4",
47
47
  "@next-core/http": "^1.0.8",
48
- "@next-core/i18n": "^1.0.23",
49
- "@next-core/inject": "^1.0.16",
48
+ "@next-core/i18n": "^1.0.24",
49
+ "@next-core/inject": "^1.0.17",
50
50
  "@next-core/loader": "^1.3.7",
51
51
  "@next-core/supply": "^2.1.3",
52
- "@next-core/types": "^1.5.1",
53
- "@next-core/utils": "^1.5.6",
52
+ "@next-core/types": "^1.6.0",
53
+ "@next-core/utils": "^1.5.7",
54
54
  "@ungap/event-target": "^0.2.4",
55
55
  "compare-versions": "^6.0.0",
56
56
  "history": "^4.10.1",
@@ -65,5 +65,5 @@
65
65
  "@next-core/build-next-libs": "^1.0.6",
66
66
  "@next-core/test-next": "^1.0.8"
67
67
  },
68
- "gitHead": "1cab4a07e7bcfc61b1fe19c655b572d36fc4a05d"
68
+ "gitHead": "bc4892a4ed95e4dce76f8e5152ed36dffa032029"
69
69
  }