@next-core/runtime 1.17.0 → 1.17.1
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/CustomTemplates/constants.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js +7 -5
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/Renderer.js +3 -5
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/cjs/internal/compute/computeRealProperties.js +27 -38
- package/dist/cjs/internal/compute/computeRealProperties.js.map +1 -1
- package/dist/cjs/internal/data/DataStore.js +2 -5
- package/dist/cjs/internal/data/DataStore.js.map +1 -1
- package/dist/cjs/internal/interfaces.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/constants.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js +23 -15
- package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
- package/dist/esm/internal/Renderer.js +4 -6
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/esm/internal/Runtime.js.map +1 -1
- package/dist/esm/internal/compute/computeRealProperties.js +47 -58
- package/dist/esm/internal/compute/computeRealProperties.js.map +1 -1
- package/dist/esm/internal/data/DataStore.js +2 -5
- package/dist/esm/internal/data/DataStore.js.map +1 -1
- package/dist/esm/internal/interfaces.js.map +1 -1
- package/dist/types/internal/CustomTemplates/constants.d.ts +2 -2
- package/dist/types/internal/CustomTemplates/setupTemplateProxy.d.ts +2 -2
- package/dist/types/internal/Runtime.d.ts +2 -2
- package/dist/types/internal/compute/computeRealProperties.d.ts +4 -3
- package/dist/types/internal/interfaces.d.ts +3 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["symbolForAsyncComputedPropsFromHost","Symbol","for","exports","symbolForTplStateStoreId","symbolForTPlExternalForEachItem"],"sources":["../../../../src/internal/CustomTemplates/constants.ts"],"sourcesContent":["import type { BrickConf } from \"@next-core/types\";\nimport type {
|
|
1
|
+
{"version":3,"file":"constants.js","names":["symbolForAsyncComputedPropsFromHost","Symbol","for","exports","symbolForTplStateStoreId","symbolForTPlExternalForEachItem"],"sources":["../../../../src/internal/CustomTemplates/constants.ts"],"sourcesContent":["import type { BrickConf } from \"@next-core/types\";\nimport type { AsyncComputedProperties } from \"../interfaces.js\";\n\nexport const symbolForAsyncComputedPropsFromHost = Symbol.for(\n \"tpl.asyncComputedPropsFromHost\"\n);\nexport const symbolForTplStateStoreId = Symbol.for(\"tpl.stateStoreId\");\nexport const symbolForTPlExternalForEachItem = Symbol.for(\n \"tpl.externalForEachItem\"\n);\n\nexport type RuntimeBrickConfWithTplSymbols = BrickConf &\n RuntimeBrickConfOfTplSymbols;\n\nexport interface RuntimeBrickConfOfTplSymbols {\n [symbolForAsyncComputedPropsFromHost]?: AsyncComputedProperties;\n [symbolForTplStateStoreId]?: string;\n [symbolForTPlExternalForEachItem]?: unknown;\n}\n"],"mappings":";;;;;;AAGO,MAAMA,mCAAmC,GAAGC,MAAM,CAACC,GAAG,CAC3D,gCACF,CAAC;AAACC,OAAA,CAAAH,mCAAA,GAAAA,mCAAA;AACK,MAAMI,wBAAwB,GAAGH,MAAM,CAACC,GAAG,CAAC,kBAAkB,CAAC;AAACC,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AAChE,MAAMC,+BAA+B,GAAGJ,MAAM,CAACC,GAAG,CACvD,yBACF,CAAC;AAACC,OAAA,CAAAE,+BAAA,GAAAA,+BAAA"}
|
|
@@ -19,20 +19,22 @@ function setupTemplateProxy(hostContext, ref, slots) {
|
|
|
19
19
|
if (ref && reversedProxies) {
|
|
20
20
|
const propertyProxies = reversedProxies.properties.get(ref);
|
|
21
21
|
if (propertyProxies) {
|
|
22
|
-
const getComputedProps =
|
|
22
|
+
const getComputedProps = async asyncHostProps => {
|
|
23
23
|
const props = {};
|
|
24
24
|
for (const {
|
|
25
25
|
from,
|
|
26
26
|
to
|
|
27
27
|
} of propertyProxies) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if ((0, _general.hasOwnProperty)(asyncHostProps, from) && to.refProperty) {
|
|
29
|
+
const propValue = await asyncHostProps[from];
|
|
30
|
+
if (propValue !== undefined) {
|
|
31
|
+
props[to.refProperty] = propValue;
|
|
32
|
+
}
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
return props;
|
|
34
36
|
};
|
|
35
|
-
asyncComputedProps = asyncHostProperties
|
|
37
|
+
asyncComputedProps = getComputedProps(asyncHostProperties);
|
|
36
38
|
}
|
|
37
39
|
const slotProxies = reversedProxies.slots.get(ref);
|
|
38
40
|
if (slotProxies && externalSlots) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupTemplateProxy.js","names":["_general","require","_lodash","_constants","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostProperties","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","
|
|
1
|
+
{"version":3,"file":"setupTemplateProxy.js","names":["_general","require","_lodash","_constants","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostProperties","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","asyncHostProps","props","from","to","hasOwnProperty","refProperty","propValue","undefined","slotProxies","quasisMap","Map","_externalSlots$from$b","_externalSlots$from","_to$refSlot","_to$refPosition","insertBricks","bricks","length","refToSlot","refSlot","expandableSlot","size","i","push","set","refPosition","clamp","runtimeContext","setupTemplateExternalBricks","forEachItem","slotName","quasis","entries","type","slotConf","flatMap","index","concat","symbolForAsyncComputedPropsFromHost","symbolForTplStateStoreId","map","brick","_brick$slots","symbolForTPlExternalForEachItem","Object","fromEntries","_slotConf$bricks","routes","setupTemplateExternalRoutes","route"],"sources":["../../../../src/internal/CustomTemplates/setupTemplateProxy.ts"],"sourcesContent":["import type { BrickConf, RouteConf, SlotsConfOfBricks } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { clamp } from \"lodash\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachItem,\n symbolForTplStateStoreId,\n} from \"./constants.js\";\nimport type {\n AsyncComputedProperties,\n AsyncProperties,\n TemplateHostContext,\n} from \"../interfaces.js\";\n\nexport function setupTemplateProxy(\n hostContext: TemplateHostContext,\n ref: string | undefined,\n slots: SlotsConfOfBricks\n) {\n const {\n reversedProxies,\n asyncHostProperties,\n externalSlots,\n tplStateStoreId,\n hostBrick,\n } = hostContext;\n\n let asyncComputedProps: AsyncComputedProperties | undefined;\n\n if (ref && reversedProxies) {\n const propertyProxies = reversedProxies.properties.get(ref);\n if (propertyProxies) {\n const getComputedProps = async (\n asyncHostProps: AsyncProperties\n ): AsyncComputedProperties => {\n const props: Record<string, unknown> = {};\n for (const { from, to } of propertyProxies) {\n if (hasOwnProperty(asyncHostProps, from) && to.refProperty) {\n const propValue = await asyncHostProps[from];\n if (propValue !== undefined) {\n props[to.refProperty] = propValue;\n }\n }\n }\n return props;\n };\n\n asyncComputedProps = getComputedProps(asyncHostProperties);\n }\n\n const slotProxies = reversedProxies.slots.get(ref);\n if (slotProxies && externalSlots) {\n // Use an approach like template-literal's quasis:\n // `quasi0${0}quais1${1}quasi2...`\n // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.\n const quasisMap = new Map<string, BrickConf[][]>();\n\n for (const { from, to } of slotProxies) {\n const insertBricks = externalSlots[from]?.bricks ?? [];\n if (!insertBricks.length) {\n continue;\n }\n const refToSlot = to.refSlot ?? from;\n let expandableSlot = quasisMap.get(refToSlot);\n if (!expandableSlot) {\n expandableSlot = [];\n // The size of quasis should be the existed slotted bricks' size plus one.\n const size = hasOwnProperty(slots, refToSlot)\n ? slots[refToSlot].bricks.length + 1\n : 1;\n for (let i = 0; i < size; i += 1) {\n expandableSlot.push([]);\n }\n quasisMap.set(refToSlot, expandableSlot);\n }\n const refPosition = to.refPosition ?? -1;\n expandableSlot[\n clamp(\n refPosition < 0 ? expandableSlot.length + refPosition : refPosition,\n 0,\n expandableSlot.length - 1\n )\n ].push(\n ...(hasOwnProperty(hostBrick.runtimeContext, \"forEachItem\")\n ? setupTemplateExternalBricks(\n insertBricks,\n hostBrick.runtimeContext.forEachItem\n )\n : insertBricks)\n );\n }\n\n for (const [slotName, quasis] of quasisMap.entries()) {\n if (!hasOwnProperty(slots, slotName)) {\n slots[slotName] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n const slotConf = slots[slotName];\n slotConf.bricks = quasis.flatMap((bricks, index) =>\n index < slotConf.bricks.length\n ? bricks.concat(slotConf.bricks[index])\n : bricks\n );\n\n if (slotConf.bricks.length === 0) {\n delete slots[slotName];\n }\n }\n }\n }\n\n return {\n [symbolForAsyncComputedPropsFromHost]: asyncComputedProps,\n [symbolForTplStateStoreId]: tplStateStoreId,\n };\n}\n\n// External bricks of a template, have the same forEachItem context as their host.\nfunction setupTemplateExternalBricks(\n bricks: BrickConf[],\n forEachItem: unknown\n): BrickConf[] {\n return bricks.map((brick) => ({\n ...brick,\n [symbolForTPlExternalForEachItem]: forEachItem,\n slots: Object.fromEntries(\n Object.entries(brick.slots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n slotConf.type === \"routes\"\n ? {\n type: \"routes\",\n routes: setupTemplateExternalRoutes(slotConf.routes, forEachItem),\n }\n : {\n type: \"bricks\",\n bricks: setupTemplateExternalBricks(\n slotConf.bricks ?? [],\n forEachItem\n ),\n },\n ])\n ),\n }));\n}\n\nfunction setupTemplateExternalRoutes(\n routes: RouteConf[],\n forEachItem: unknown\n): RouteConf[] {\n return routes.map((route) =>\n route.type && route.type !== \"bricks\"\n ? route\n : {\n ...route,\n bricks: setupTemplateExternalBricks(route.bricks, forEachItem),\n }\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,O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,CAC9DhB,QAAQ,EACRI,QAAQ,CAACD,IAAI,KAAK,QAAQ,GACtB;UACEA,IAAI,EAAE,QAAQ;UACdc,MAAM,EAAEC,2BAA2B,CAACd,QAAQ,CAACa,MAAM,EAAElB,WAAW;QAClE,CAAC,GACD;UACEI,IAAI,EAAE,QAAQ;UACdjB,MAAM,EAAEY,2BAA2B,EAAAkB,gBAAA,GACjCZ,QAAQ,CAAClB,MAAM,cAAA8B,gBAAA,cAAAA,gBAAA,GAAI,EAAE,EACrBjB,WACF;QACF,CAAC,CACN;MAAA,EACH;IACF,CAAC;EAAA,CAAC,CAAC;AACL;AAEA,SAASmB,2BAA2BA,CAClCD,MAAmB,EACnBlB,WAAoB,EACP;EACb,OAAOkB,MAAM,CAACP,GAAG,CAAES,KAAK,IACtBA,KAAK,CAAChB,IAAI,IAAIgB,KAAK,CAAChB,IAAI,KAAK,QAAQ,GACjCgB,KAAK,GACL;IACE,GAAGA,KAAK;IACRjC,MAAM,EAAEY,2BAA2B,CAACqB,KAAK,CAACjC,MAAM,EAAEa,WAAW;EAC/D,CACN,CAAC;AACH"}
|
|
@@ -309,12 +309,11 @@ async function renderBrick(returnNode, brickConf, _runtimeContext, rendererConte
|
|
|
309
309
|
// 加载构件属性和加载子构件等任务,可以并行。
|
|
310
310
|
const blockingList = [];
|
|
311
311
|
const trackingContextList = [];
|
|
312
|
+
const asyncProperties = (0, _computeRealProperties.asyncComputeRealProperties)(confProps, runtimeContext, trackingContextList);
|
|
312
313
|
const loadProperties = async () => {
|
|
313
|
-
brick.properties = await (0, _computeRealProperties.
|
|
314
|
+
brick.properties = await (0, _computeRealProperties.constructAsyncProperties)(asyncProperties);
|
|
314
315
|
const computedPropsFromHost = brickConf[_constants.symbolForAsyncComputedPropsFromHost];
|
|
315
316
|
if (computedPropsFromHost) {
|
|
316
|
-
var _brick$properties;
|
|
317
|
-
(_brick$properties = brick.properties) !== null && _brick$properties !== void 0 ? _brick$properties : brick.properties = {};
|
|
318
317
|
const computed = await computedPropsFromHost;
|
|
319
318
|
for (const [propName, propValue] of Object.entries(computed)) {
|
|
320
319
|
brick.properties[propName] = propValue;
|
|
@@ -323,8 +322,7 @@ async function renderBrick(returnNode, brickConf, _runtimeContext, rendererConte
|
|
|
323
322
|
(0, _listenOnTrackingContext.listenOnTrackingContext)(brick, trackingContextList);
|
|
324
323
|
return brick.properties;
|
|
325
324
|
};
|
|
326
|
-
|
|
327
|
-
blockingList.push(asyncProperties);
|
|
325
|
+
blockingList.push(loadProperties());
|
|
328
326
|
rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);
|
|
329
327
|
let expandedBrickConf = brickConf;
|
|
330
328
|
if (tplTagName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.js","names":["_loader","require","_cook","_general","_lodash","_checkIf","_computeRealProperties","_resolveData","_computeRealValue","_listenOnTrackingContext","_matchRoutes","_constants","_expandCustomTemplate","_utils","_CustomTemplates","_Runtime","_enums","_getTracks","_isStrictMode","_constants2","_expandFormRenderer","_evaluate","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","slotId","matched","matchRoutes","output","blockingList","menuRequests","unauthenticated","_hooks$checkPermissio","route","runtimeContext","match","ctxStore","define","context","pendingPermissionsPreCheck","push","hooks","checkPermissions","preCheckPermissionsForBrickOrRoute","value","asyncComputeRealValue","preLoadBricks","Array","isArray","loadBricksImperatively","getBrickPackages","type","redirectTo","redirect","resolved","resolveData","transform","console","error","Error","path","loadMenu","menu","newOutput","mergeRenderOutput","renderBricks","bricks","tplStack","noMemoize","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoizeControlNode","node","key","_hooks$checkPermissio2","_runtimeContext$app","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","symbolForTplStateStoreId","formStateStoreId","symbolForFormStateStoreId","hasOwnProperty","symbolForTPlExternalForEachItem","forEachItem","length","strict","isStrictMode","warnAboutStrictMode","asyncCheckBrickIf","brickName","startsWith","ensureValidControlBrick","renderControlNode","_slots$slot","computedDataSource","slot","String","childrenToSlots","children","renderForEach","controlledOutput","contextNames","stateNames","getTracks","renderId","listener","currentRenderId","tplStateStoreMap","values","formStateStoreMap","store","waitForAll","rerenderControlNode","debouncedListener","debounce","contextName","onChange","tplStateStore","getTplStateStore","test","customTemplates","get","catchLoadBrick","unknownBricks","tplTagName","getTagNameOfCustomTemplate","app","id","_tplStack$get","tplCount","set","includes","customElements","FORM_RENDERER","FormRendererElement","HTMLElement","$$typeof","enqueueStableLoadBricks","tag","RenderTag","BRICK","return","events","portal","iid","ref","formData","confProps","_brickConf$properties","properties","trackingContextList","loadProperties","asyncComputeRealProperties","computedPropsFromHost","symbolForAsyncComputedPropsFromHost","_brick$properties","computed","propName","propValue","entries","listenOnTrackingContext","asyncProperties","registerBrickLifeCycle","lifeCycle","expandedBrickConf","expandCustomTemplate","expandFormRenderer","undefined","childRuntimeContext","loadChildren","childSlotId","slotConf","childrenOutput","child","isTrackAll","isPreEvaluated","getPreEvaluatedRaw","i","j","flat","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","_child$slot","promise","catch","e"],"sources":["../../../src/internal/Renderer.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n ContextConf,\n MenuConf,\n RouteConf,\n SlotConfOfBricks,\n SlotsConf,\n StaticMenuConf,\n} from \"@next-core/types\";\nimport {\n enqueueStableLoadBricks,\n loadBricksImperatively,\n} from \"@next-core/loader\";\nimport { isTrackAll } from \"@next-core/cook\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { debounce } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport { asyncComputeRealProperties } from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoutes } from \"./matchRoutes.js\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachItem,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n RenderBrick,\n RenderNode,\n RuntimeBrickConfWithSymbols,\n RuntimeContext,\n} from \"./interfaces.js\";\nimport {\n getTagNameOfCustomTemplate,\n getTplStateStore,\n} from \"./CustomTemplates/utils.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport type { NextHistoryState } from \"./historyExtended.js\";\nimport { getBrickPackages, hooks } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport {\n FORM_RENDERER,\n RuntimeBrickConfOfFormSymbols,\n symbolForFormStateStoreId,\n} from \"./FormRenderer/constants.js\";\nimport { expandFormRenderer } from \"./FormRenderer/expandFormRenderer.js\";\nimport { isPreEvaluated } from \"./compute/evaluate.js\";\nimport { getPreEvaluatedRaw } from \"./compute/evaluate.js\";\nimport { RuntimeBrickConfOfTplSymbols } from \"./CustomTemplates/constants.js\";\n\nexport interface RenderOutput {\n node?: RenderBrick;\n unauthenticated?: boolean;\n redirect?: {\n path: string;\n state?: NextHistoryState;\n };\n route?: RouteConf;\n blockingList: (Promise<unknown> | undefined)[];\n menuRequests: (Promise<StaticMenuConf | undefined> | undefined)[];\n hasTrackingControls?: boolean;\n}\n\nexport async function renderRoutes(\n returnNode: RenderNode,\n routes: RouteConf[],\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string\n): Promise<RenderOutput> {\n const matched = await matchRoutes(routes, _runtimeContext);\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n switch (matched) {\n case \"missed\":\n break;\n case \"unauthenticated\":\n output.unauthenticated = true;\n break;\n default: {\n const route = (output.route = matched.route);\n const runtimeContext = {\n ..._runtimeContext,\n match: matched.match,\n };\n runtimeContext.ctxStore.define(route.context, runtimeContext);\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n route,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n // Currently, this is only used for brick size-checking: these bricks\n // will be loaded before page rendering, but they will NOT be rendered.\n const { preLoadBricks } = route as { preLoadBricks?: string[] };\n if (Array.isArray(preLoadBricks)) {\n output.blockingList.push(\n loadBricksImperatively(preLoadBricks, getBrickPackages())\n );\n }\n\n switch (route.type) {\n case \"redirect\": {\n let redirectTo: unknown;\n if (typeof route.redirect === \"string\") {\n redirectTo = await asyncComputeRealValue(\n route.redirect,\n runtimeContext\n );\n } else {\n const resolved = (await resolveData(\n {\n transform: \"redirect\",\n ...route.redirect,\n },\n runtimeContext\n )) as { redirect?: unknown };\n redirectTo = resolved.redirect;\n }\n if (typeof redirectTo !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected redirect result:\", redirectTo);\n throw new Error(\n `Unexpected type of redirect result: ${typeof redirectTo}`\n );\n }\n output.redirect = { path: redirectTo };\n break;\n }\n case \"routes\": {\n output.menuRequests.push(loadMenu(route.menu, runtimeContext));\n const newOutput = await renderRoutes(\n returnNode,\n route.routes,\n runtimeContext,\n rendererContext,\n slotId\n );\n mergeRenderOutput(output, newOutput);\n break;\n }\n default: {\n output.menuRequests.push(loadMenu(route.menu, runtimeContext));\n const newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n slotId\n );\n mergeRenderOutput(output, newOutput);\n }\n }\n }\n }\n return output;\n}\n\nexport async function renderBricks(\n returnNode: RenderNode,\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string,\n tplStack?: Map<string, number>,\n noMemoize?: boolean\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf, index) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n slotId,\n index,\n tplStack && new Map(tplStack)\n )\n )\n );\n\n rendered.forEach((item, index) => {\n if (!noMemoize && item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoizeControlNode(slotId, index, item.node, returnNode);\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport async function renderBrick(\n returnNode: RenderNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string,\n key?: number,\n tplStack = new Map<string, number>()\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n\n if (!brickConf.brick) {\n if ((brickConf as { template?: string }).template) {\n // eslint-disable-next-line no-console\n console.error(\"Legacy templates are dropped in v3:\", brickConf);\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Invalid brick:\", brickConf);\n }\n return output;\n }\n\n // Translate `if: \"<%= ... %>\"` to `brick: \":if\", dataSource: \"<%= ... %>\"`.\n // In other words, translate tracking if expressions to tracking control nodes of `:if`.\n const { if: brickIf, permissionsPreCheck, ...restBrickConf } = brickConf;\n if (isGeneralizedTrackAll(brickIf)) {\n return renderBrick(\n returnNode,\n {\n brick: \":if\",\n dataSource: brickIf,\n // `permissionsPreCheck` maybe required before computing `if`.\n permissionsPreCheck,\n slots: {\n \"\": {\n type: \"bricks\",\n bricks: [restBrickConf],\n },\n },\n // These symbols have to be copied to the new brick conf.\n ...Object.getOwnPropertySymbols(brickConf).reduce(\n (acc, symbol) => ({\n ...acc,\n [symbol]: (brickConf as any)[symbol],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n slotId,\n key,\n tplStack\n );\n }\n\n const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const formStateStoreId = brickConf[symbolForFormStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\n formStateStoreId,\n };\n\n if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {\n // The external bricks of a template should restore their `forEachItem`\n // from their host.\n runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];\n }\n\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\n const strict = isStrictMode(runtimeContext);\n warnAboutStrictMode(\n strict,\n \"Defining context on bricks\",\n \"check your brick:\",\n brickConf\n );\n if (!strict) {\n runtimeContext.ctxStore.define(context, runtimeContext);\n }\n }\n\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n brickConf,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {\n return output;\n }\n\n const brickName = brickConf.brick;\n if (brickName.startsWith(\":\")) {\n ensureValidControlBrick(brickName);\n\n const { dataSource } = brickConf;\n\n const renderControlNode = async () => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n // Then, get the matched slot.\n const slot =\n brickName === \":forEach\"\n ? \"\"\n : brickName === \":switch\"\n ? String(computedDataSource)\n : computedDataSource\n ? \"\"\n : \"else\";\n\n // Don't forget to transpile children to slots.\n const slots = childrenToSlots(brickConf.children, brickConf.slots);\n\n // Then, get the bricks in that matched slot.\n const bricks =\n slots &&\n hasOwnProperty(slots, slot) &&\n (slots[slot] as SlotConfOfBricks)?.bricks;\n\n if (!Array.isArray(bricks)) {\n return output;\n }\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n return output;\n }\n return renderForEach(\n returnNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n slotId,\n tplStack\n );\n }\n case \":if\":\n case \":switch\": {\n return renderBricks(\n returnNode,\n bricks,\n runtimeContext,\n rendererContext,\n slotId,\n tplStack,\n true\n );\n }\n }\n };\n\n const controlledOutput = await renderControlNode();\n\n const { contextNames, stateNames } = getTracks(dataSource);\n if (contextNames || stateNames) {\n controlledOutput.hasTrackingControls = true;\n let renderId = 0;\n const listener = async () => {\n const currentRenderId = ++renderId;\n const output = await renderControlNode();\n output.blockingList.push(\n ...[\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ].map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck\n );\n await Promise.all(output.blockingList);\n // Ignore stale renders\n if (renderId === currentRenderId) {\n rendererContext.rerenderControlNode(\n slotId,\n key as number,\n output.node,\n returnNode\n );\n }\n };\n const debouncedListener = debounce(listener);\n if (contextNames) {\n for (const contextName of contextNames) {\n runtimeContext.ctxStore.onChange(contextName, debouncedListener);\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n tplStateStore.onChange(contextName, debouncedListener);\n }\n }\n }\n\n return controlledOutput;\n }\n\n // Widgets need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await catchLoadBrick(\n loadBricksImperatively([brickName], getBrickPackages()),\n brickName,\n rendererContext.unknownBricks\n );\n }\n\n const tplTagName = getTagNameOfCustomTemplate(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n customElements.define(\n FORM_RENDERER,\n class FormRendererElement extends HTMLElement {\n get $$typeof(): string {\n return \"form-renderer\";\n }\n }\n );\n } else {\n output.blockingList.push(\n catchLoadBrick(\n enqueueStableLoadBricks([brickName], getBrickPackages()),\n brickName,\n rendererContext.unknownBricks\n )\n );\n }\n }\n\n const brick: RenderBrick = {\n tag: RenderTag.BRICK,\n type: tplTagName || brickName,\n return: returnNode,\n slotId,\n events: brickConf.events,\n runtimeContext,\n portal: brickConf.portal,\n iid: brickConf.iid,\n ref: (brickConf as BrickConfInTemplate).ref,\n };\n\n output.node = brick;\n\n // const confProps = brickConf.properties;\n let formData: unknown;\n let confProps: Record<string, unknown> | undefined;\n if (brickName === FORM_RENDERER) {\n ({ formData, ...confProps } = brickConf.properties ?? {});\n } else {\n confProps = brickConf.properties;\n }\n\n // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const trackingContextList: TrackingContextItem[] = [];\n const loadProperties = async () => {\n brick.properties = await asyncComputeRealProperties(\n confProps,\n runtimeContext,\n trackingContextList\n );\n const computedPropsFromHost =\n brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n brick.properties ??= {};\n const computed = await computedPropsFromHost;\n for (const [propName, propValue] of Object.entries(computed)) {\n brick.properties[propName] = propValue;\n }\n }\n listenOnTrackingContext(brick, trackingContextList);\n return brick.properties;\n };\n const asyncProperties = loadProperties();\n blockingList.push(asyncProperties);\n\n rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);\n\n let expandedBrickConf = brickConf;\n if (tplTagName) {\n expandedBrickConf = expandCustomTemplate(\n tplTagName,\n brickConf,\n brick,\n asyncProperties,\n rendererContext\n );\n } else if (brickName === FORM_RENDERER) {\n expandedBrickConf = expandFormRenderer(\n formData,\n brickConf,\n brick,\n asyncProperties,\n rendererContext\n );\n }\n\n if (expandedBrickConf.portal) {\n // A portal brick has no slotId.\n brick.slotId = undefined;\n }\n\n let childRuntimeContext: RuntimeContext;\n if (tplTagName) {\n // There is a boundary for `forEachItem` between template internals and externals.\n childRuntimeContext = {\n ...runtimeContext,\n };\n delete childRuntimeContext.forEachItem;\n } else {\n childRuntimeContext = runtimeContext;\n }\n\n const loadChildren = async () => {\n const slots = childrenToSlots(\n expandedBrickConf.children,\n expandedBrickConf.slots\n );\n if (!slots) {\n return;\n }\n const rendered = await Promise.all(\n Object.entries(slots).map(([childSlotId, slotConf]) =>\n slotConf.type !== \"routes\"\n ? renderBricks(\n brick,\n (slotConf as SlotConfOfBricks).bricks,\n childRuntimeContext,\n rendererContext,\n childSlotId,\n tplStack\n )\n : renderRoutes(\n brick,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n childSlotId\n )\n )\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n };\n for (const item of rendered) {\n mergeRenderOutput(childrenOutput, item);\n }\n if (childrenOutput.node) {\n brick.child = childrenOutput.node;\n }\n mergeRenderOutput(output, {\n ...childrenOutput,\n node: undefined,\n });\n };\n blockingList.push(loadChildren());\n\n await Promise.all(blockingList);\n\n return output;\n}\n\nfunction isGeneralizedTrackAll(brickIf: unknown): boolean {\n return typeof brickIf === \"string\"\n ? isTrackAll(brickIf)\n : isPreEvaluated(brickIf) &&\n // istanbul ignore next: covered by e2e tests\n isTrackAll(getPreEvaluatedRaw(brickIf));\n}\n\ntype ValidControlBrick = \":forEach\" | \":if\" | \":switch\";\n\nfunction ensureValidControlBrick(\n brick: string\n): asserts brick is ValidControlBrick {\n if (brick !== \":forEach\" && brick !== \":if\" && brick !== \":switch\") {\n throw new Error(`Unknown storyboard control node: \"${brick}\"`);\n }\n}\n\nasync function renderForEach(\n returnNode: RenderNode,\n dataSource: unknown[],\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId: string | undefined,\n tplStack?: Map<string, number>\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n\n const rendered = await Promise.all(\n dataSource.map((item, i) =>\n Promise.all(\n bricks.map((brickConf, j) =>\n renderBrick(\n returnNode,\n brickConf,\n {\n ...runtimeContext,\n forEachItem: item,\n },\n rendererContext,\n slotId,\n i * j,\n tplStack && new Map(tplStack)\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n for (const item of rendered.flat()) {\n mergeRenderOutput(output, item);\n }\n return output;\n}\n\nfunction loadMenu(\n menuConf: MenuConf | undefined,\n runtimeContext: RuntimeContext\n) {\n if (!menuConf) {\n return;\n }\n\n // istanbul ignore next\n if ((menuConf as { type?: \"brick\" }).type === \"brick\") {\n // eslint-disable-next-line no-console\n console.error(\"Set menu with brick is dropped in v3:\", menuConf);\n throw new Error(\"Set menu with brick is dropped in v3\");\n }\n\n // istanbul ignore next\n if (menuConf.type === \"resolve\") {\n // eslint-disable-next-line no-console\n console.warn(\"Set menu with resolve is not supported in v3 yet:\", menuConf);\n return;\n }\n\n return asyncComputeRealValue(\n menuConf,\n runtimeContext\n ) as Promise<StaticMenuConf>;\n}\n\nfunction mergeRenderOutput(\n output: RenderOutput,\n newOutput: RenderOutput\n): void {\n const { blockingList, node, menuRequests, hasTrackingControls, ...rest } =\n newOutput;\n output.blockingList.push(...blockingList);\n output.menuRequests.push(...menuRequests);\n\n if (node) {\n if (output.node) {\n let last = output.node;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = node;\n } else {\n output.node = node;\n }\n }\n\n Object.assign(output, rest);\n}\n\nexport function childrenToSlots(\n children: BrickConf[] | undefined,\n originalSlots: SlotsConf | undefined\n) {\n let newSlots = originalSlots;\n // istanbul ignore next\n if (\n process.env.NODE_ENV === \"development\" &&\n children &&\n !Array.isArray(children)\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Specified brick children but not array:\",\n `<${typeof children}>`,\n children\n );\n }\n if (Array.isArray(children) && !newSlots) {\n newSlots = {};\n for (const child of children) {\n const slot = child.slot ?? \"\";\n if (!hasOwnProperty(newSlots, slot)) {\n newSlots[slot] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n (newSlots[slot] as SlotConfOfBricks).bricks.push(child);\n }\n }\n return newSlots;\n}\n\nfunction catchLoadBrick(\n promise: Promise<unknown>,\n brickName: string,\n unknownBricks: RendererContext[\"unknownBricks\"]\n) {\n return unknownBricks === \"silent\"\n ? promise.catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Load brick \"${brickName}\" failed:`, e);\n })\n : promise;\n}\n"],"mappings":";;;;;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,wBAAA,GAAAR,OAAA;AAKA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AAKA,IAAAW,qBAAA,GAAAX,OAAA;AAOA,IAAAY,MAAA,GAAAZ,OAAA;AAIA,IAAAa,gBAAA,GAAAb,OAAA;AAEA,IAAAc,QAAA,GAAAd,OAAA;AACA,IAAAe,MAAA,GAAAf,OAAA;AACA,IAAAgB,UAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,OAAA;AACA,IAAAkB,WAAA,GAAAlB,OAAA;AAKA,IAAAmB,mBAAA,GAAAnB,OAAA;AACA,IAAAoB,SAAA,GAAApB,OAAA;AAiBO,eAAeqB,YAAYA,CAChCC,UAAsB,EACtBC,MAAmB,EACnBC,eAA+B,EAC/BC,eAAgC,EAChCC,MAAe,EACQ;EACvB,MAAMC,OAAO,GAAG,MAAM,IAAAC,wBAAW,EAACL,MAAM,EAAEC,eAAe,CAAC;EAC1D,MAAMK,MAAoB,GAAG;IAC3BC,YAA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QAAQ;UACde,MAAM,EAAE;QACV,CAAC;MACH;MACC+I,QAAQ,CAAC5F,IAAI,CAAC,CAAsBnD,MAAM,CAAC1B,IAAI,CAAC2J,KAAK,CAAC;IACzD;EACF;EACA,OAAOc,QAAQ;AACjB;AAEA,SAASjE,cAAcA,CACrBsE,OAAyB,EACzBvG,SAAiB,EACjBkC,aAA+C,EAC/C;EACA,OAAOA,aAAa,KAAK,QAAQ,GAC7BqE,OAAO,CAACC,KAAK,CAAEC,CAAC,IAAK;IACnB;IACA/J,OAAO,CAACC,KAAK,CAAE,eAAcqD,SAAU,WAAU,EAAEyG,CAAC,CAAC;EACvD,CAAC,CAAC,GACFF,OAAO;AACb"}
|
|
1
|
+
{"version":3,"file":"Renderer.js","names":["_loader","require","_cook","_general","_lodash","_checkIf","_computeRealProperties","_resolveData","_computeRealValue","_listenOnTrackingContext","_matchRoutes","_constants","_expandCustomTemplate","_utils","_CustomTemplates","_Runtime","_enums","_getTracks","_isStrictMode","_constants2","_expandFormRenderer","_evaluate","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","slotId","matched","matchRoutes","output","blockingList","menuRequests","unauthenticated","_hooks$checkPermissio","route","runtimeContext","match","ctxStore","define","context","pendingPermissionsPreCheck","push","hooks","checkPermissions","preCheckPermissionsForBrickOrRoute","value","asyncComputeRealValue","preLoadBricks","Array","isArray","loadBricksImperatively","getBrickPackages","type","redirectTo","redirect","resolved","resolveData","transform","console","error","Error","path","loadMenu","menu","newOutput","mergeRenderOutput","renderBricks","bricks","tplStack","noMemoize","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoizeControlNode","node","key","_hooks$checkPermissio2","_runtimeContext$app","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","symbolForTplStateStoreId","formStateStoreId","symbolForFormStateStoreId","hasOwnProperty","symbolForTPlExternalForEachItem","forEachItem","length","strict","isStrictMode","warnAboutStrictMode","asyncCheckBrickIf","brickName","startsWith","ensureValidControlBrick","renderControlNode","_slots$slot","computedDataSource","slot","String","childrenToSlots","children","renderForEach","controlledOutput","contextNames","stateNames","getTracks","renderId","listener","currentRenderId","tplStateStoreMap","values","formStateStoreMap","store","waitForAll","rerenderControlNode","debouncedListener","debounce","contextName","onChange","tplStateStore","getTplStateStore","test","customTemplates","get","catchLoadBrick","unknownBricks","tplTagName","getTagNameOfCustomTemplate","app","id","_tplStack$get","tplCount","set","includes","customElements","FORM_RENDERER","FormRendererElement","HTMLElement","$$typeof","enqueueStableLoadBricks","tag","RenderTag","BRICK","return","events","portal","iid","ref","formData","confProps","_brickConf$properties","properties","trackingContextList","asyncProperties","asyncComputeRealProperties","loadProperties","constructAsyncProperties","computedPropsFromHost","symbolForAsyncComputedPropsFromHost","computed","propName","propValue","entries","listenOnTrackingContext","registerBrickLifeCycle","lifeCycle","expandedBrickConf","expandCustomTemplate","expandFormRenderer","undefined","childRuntimeContext","loadChildren","childSlotId","slotConf","childrenOutput","child","isTrackAll","isPreEvaluated","getPreEvaluatedRaw","i","j","flat","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","_child$slot","promise","catch","e"],"sources":["../../../src/internal/Renderer.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n ContextConf,\n MenuConf,\n RouteConf,\n SlotConfOfBricks,\n SlotsConf,\n StaticMenuConf,\n} from \"@next-core/types\";\nimport {\n enqueueStableLoadBricks,\n loadBricksImperatively,\n} from \"@next-core/loader\";\nimport { isTrackAll } from \"@next-core/cook\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { debounce } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealProperties,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoutes } from \"./matchRoutes.js\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachItem,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n RenderBrick,\n RenderNode,\n RuntimeBrickConfWithSymbols,\n RuntimeContext,\n} from \"./interfaces.js\";\nimport {\n getTagNameOfCustomTemplate,\n getTplStateStore,\n} from \"./CustomTemplates/utils.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport type { NextHistoryState } from \"./historyExtended.js\";\nimport { getBrickPackages, hooks } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport {\n FORM_RENDERER,\n RuntimeBrickConfOfFormSymbols,\n symbolForFormStateStoreId,\n} from \"./FormRenderer/constants.js\";\nimport { expandFormRenderer } from \"./FormRenderer/expandFormRenderer.js\";\nimport { isPreEvaluated } from \"./compute/evaluate.js\";\nimport { getPreEvaluatedRaw } from \"./compute/evaluate.js\";\nimport { RuntimeBrickConfOfTplSymbols } from \"./CustomTemplates/constants.js\";\n\nexport interface RenderOutput {\n node?: RenderBrick;\n unauthenticated?: boolean;\n redirect?: {\n path: string;\n state?: NextHistoryState;\n };\n route?: RouteConf;\n blockingList: (Promise<unknown> | undefined)[];\n menuRequests: (Promise<StaticMenuConf | undefined> | undefined)[];\n hasTrackingControls?: boolean;\n}\n\nexport async function renderRoutes(\n returnNode: RenderNode,\n routes: RouteConf[],\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string\n): Promise<RenderOutput> {\n const matched = await matchRoutes(routes, _runtimeContext);\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n switch (matched) {\n case \"missed\":\n break;\n case \"unauthenticated\":\n output.unauthenticated = true;\n break;\n default: {\n const route = (output.route = matched.route);\n const runtimeContext = {\n ..._runtimeContext,\n match: matched.match,\n };\n runtimeContext.ctxStore.define(route.context, runtimeContext);\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n route,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n // Currently, this is only used for brick size-checking: these bricks\n // will be loaded before page rendering, but they will NOT be rendered.\n const { preLoadBricks } = route as { preLoadBricks?: string[] };\n if (Array.isArray(preLoadBricks)) {\n output.blockingList.push(\n loadBricksImperatively(preLoadBricks, getBrickPackages())\n );\n }\n\n switch (route.type) {\n case \"redirect\": {\n let redirectTo: unknown;\n if (typeof route.redirect === \"string\") {\n redirectTo = await asyncComputeRealValue(\n route.redirect,\n runtimeContext\n );\n } else {\n const resolved = (await resolveData(\n {\n transform: \"redirect\",\n ...route.redirect,\n },\n runtimeContext\n )) as { redirect?: unknown };\n redirectTo = resolved.redirect;\n }\n if (typeof redirectTo !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected redirect result:\", redirectTo);\n throw new Error(\n `Unexpected type of redirect result: ${typeof redirectTo}`\n );\n }\n output.redirect = { path: redirectTo };\n break;\n }\n case \"routes\": {\n output.menuRequests.push(loadMenu(route.menu, runtimeContext));\n const newOutput = await renderRoutes(\n returnNode,\n route.routes,\n runtimeContext,\n rendererContext,\n slotId\n );\n mergeRenderOutput(output, newOutput);\n break;\n }\n default: {\n output.menuRequests.push(loadMenu(route.menu, runtimeContext));\n const newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n slotId\n );\n mergeRenderOutput(output, newOutput);\n }\n }\n }\n }\n return output;\n}\n\nexport async function renderBricks(\n returnNode: RenderNode,\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string,\n tplStack?: Map<string, number>,\n noMemoize?: boolean\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf, index) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n slotId,\n index,\n tplStack && new Map(tplStack)\n )\n )\n );\n\n rendered.forEach((item, index) => {\n if (!noMemoize && item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoizeControlNode(slotId, index, item.node, returnNode);\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport async function renderBrick(\n returnNode: RenderNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string,\n key?: number,\n tplStack = new Map<string, number>()\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n\n if (!brickConf.brick) {\n if ((brickConf as { template?: string }).template) {\n // eslint-disable-next-line no-console\n console.error(\"Legacy templates are dropped in v3:\", brickConf);\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Invalid brick:\", brickConf);\n }\n return output;\n }\n\n // Translate `if: \"<%= ... %>\"` to `brick: \":if\", dataSource: \"<%= ... %>\"`.\n // In other words, translate tracking if expressions to tracking control nodes of `:if`.\n const { if: brickIf, permissionsPreCheck, ...restBrickConf } = brickConf;\n if (isGeneralizedTrackAll(brickIf)) {\n return renderBrick(\n returnNode,\n {\n brick: \":if\",\n dataSource: brickIf,\n // `permissionsPreCheck` maybe required before computing `if`.\n permissionsPreCheck,\n slots: {\n \"\": {\n type: \"bricks\",\n bricks: [restBrickConf],\n },\n },\n // These symbols have to be copied to the new brick conf.\n ...Object.getOwnPropertySymbols(brickConf).reduce(\n (acc, symbol) => ({\n ...acc,\n [symbol]: (brickConf as any)[symbol],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n slotId,\n key,\n tplStack\n );\n }\n\n const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const formStateStoreId = brickConf[symbolForFormStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\n formStateStoreId,\n };\n\n if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {\n // The external bricks of a template should restore their `forEachItem`\n // from their host.\n runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];\n }\n\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\n const strict = isStrictMode(runtimeContext);\n warnAboutStrictMode(\n strict,\n \"Defining context on bricks\",\n \"check your brick:\",\n brickConf\n );\n if (!strict) {\n runtimeContext.ctxStore.define(context, runtimeContext);\n }\n }\n\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n brickConf,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {\n return output;\n }\n\n const brickName = brickConf.brick;\n if (brickName.startsWith(\":\")) {\n ensureValidControlBrick(brickName);\n\n const { dataSource } = brickConf;\n\n const renderControlNode = async () => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n // Then, get the matched slot.\n const slot =\n brickName === \":forEach\"\n ? \"\"\n : brickName === \":switch\"\n ? String(computedDataSource)\n : computedDataSource\n ? \"\"\n : \"else\";\n\n // Don't forget to transpile children to slots.\n const slots = childrenToSlots(brickConf.children, brickConf.slots);\n\n // Then, get the bricks in that matched slot.\n const bricks =\n slots &&\n hasOwnProperty(slots, slot) &&\n (slots[slot] as SlotConfOfBricks)?.bricks;\n\n if (!Array.isArray(bricks)) {\n return output;\n }\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n return output;\n }\n return renderForEach(\n returnNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n slotId,\n tplStack\n );\n }\n case \":if\":\n case \":switch\": {\n return renderBricks(\n returnNode,\n bricks,\n runtimeContext,\n rendererContext,\n slotId,\n tplStack,\n true\n );\n }\n }\n };\n\n const controlledOutput = await renderControlNode();\n\n const { contextNames, stateNames } = getTracks(dataSource);\n if (contextNames || stateNames) {\n controlledOutput.hasTrackingControls = true;\n let renderId = 0;\n const listener = async () => {\n const currentRenderId = ++renderId;\n const output = await renderControlNode();\n output.blockingList.push(\n ...[\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ].map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck\n );\n await Promise.all(output.blockingList);\n // Ignore stale renders\n if (renderId === currentRenderId) {\n rendererContext.rerenderControlNode(\n slotId,\n key as number,\n output.node,\n returnNode\n );\n }\n };\n const debouncedListener = debounce(listener);\n if (contextNames) {\n for (const contextName of contextNames) {\n runtimeContext.ctxStore.onChange(contextName, debouncedListener);\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n tplStateStore.onChange(contextName, debouncedListener);\n }\n }\n }\n\n return controlledOutput;\n }\n\n // Widgets need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await catchLoadBrick(\n loadBricksImperatively([brickName], getBrickPackages()),\n brickName,\n rendererContext.unknownBricks\n );\n }\n\n const tplTagName = getTagNameOfCustomTemplate(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n customElements.define(\n FORM_RENDERER,\n class FormRendererElement extends HTMLElement {\n get $$typeof(): string {\n return \"form-renderer\";\n }\n }\n );\n } else {\n output.blockingList.push(\n catchLoadBrick(\n enqueueStableLoadBricks([brickName], getBrickPackages()),\n brickName,\n rendererContext.unknownBricks\n )\n );\n }\n }\n\n const brick: RenderBrick = {\n tag: RenderTag.BRICK,\n type: tplTagName || brickName,\n return: returnNode,\n slotId,\n events: brickConf.events,\n runtimeContext,\n portal: brickConf.portal,\n iid: brickConf.iid,\n ref: (brickConf as BrickConfInTemplate).ref,\n };\n\n output.node = brick;\n\n // const confProps = brickConf.properties;\n let formData: unknown;\n let confProps: Record<string, unknown> | undefined;\n if (brickName === FORM_RENDERER) {\n ({ formData, ...confProps } = brickConf.properties ?? {});\n } else {\n confProps = brickConf.properties;\n }\n\n // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const trackingContextList: TrackingContextItem[] = [];\n const asyncProperties = asyncComputeRealProperties(\n confProps,\n runtimeContext,\n trackingContextList\n );\n const loadProperties = async () => {\n brick.properties = await constructAsyncProperties(asyncProperties);\n const computedPropsFromHost =\n brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n const computed = await computedPropsFromHost;\n for (const [propName, propValue] of Object.entries(computed)) {\n brick.properties[propName] = propValue;\n }\n }\n listenOnTrackingContext(brick, trackingContextList);\n return brick.properties;\n };\n blockingList.push(loadProperties());\n\n rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);\n\n let expandedBrickConf = brickConf;\n if (tplTagName) {\n expandedBrickConf = expandCustomTemplate(\n tplTagName,\n brickConf,\n brick,\n asyncProperties,\n rendererContext\n );\n } else if (brickName === FORM_RENDERER) {\n expandedBrickConf = expandFormRenderer(\n formData,\n brickConf,\n brick,\n asyncProperties,\n rendererContext\n );\n }\n\n if (expandedBrickConf.portal) {\n // A portal brick has no slotId.\n brick.slotId = undefined;\n }\n\n let childRuntimeContext: RuntimeContext;\n if (tplTagName) {\n // There is a boundary for `forEachItem` between template internals and externals.\n childRuntimeContext = {\n ...runtimeContext,\n };\n delete childRuntimeContext.forEachItem;\n } else {\n childRuntimeContext = runtimeContext;\n }\n\n const loadChildren = async () => {\n const slots = childrenToSlots(\n expandedBrickConf.children,\n expandedBrickConf.slots\n );\n if (!slots) {\n return;\n }\n const rendered = await Promise.all(\n Object.entries(slots).map(([childSlotId, slotConf]) =>\n slotConf.type !== \"routes\"\n ? renderBricks(\n brick,\n (slotConf as SlotConfOfBricks).bricks,\n childRuntimeContext,\n rendererContext,\n childSlotId,\n tplStack\n )\n : renderRoutes(\n brick,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n childSlotId\n )\n )\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n };\n for (const item of rendered) {\n mergeRenderOutput(childrenOutput, item);\n }\n if (childrenOutput.node) {\n brick.child = childrenOutput.node;\n }\n mergeRenderOutput(output, {\n ...childrenOutput,\n node: undefined,\n });\n };\n blockingList.push(loadChildren());\n\n await Promise.all(blockingList);\n\n return output;\n}\n\nfunction isGeneralizedTrackAll(brickIf: unknown): boolean {\n return typeof brickIf === \"string\"\n ? isTrackAll(brickIf)\n : isPreEvaluated(brickIf) &&\n // istanbul ignore next: covered by e2e tests\n isTrackAll(getPreEvaluatedRaw(brickIf));\n}\n\ntype ValidControlBrick = \":forEach\" | \":if\" | \":switch\";\n\nfunction ensureValidControlBrick(\n brick: string\n): asserts brick is ValidControlBrick {\n if (brick !== \":forEach\" && brick !== \":if\" && brick !== \":switch\") {\n throw new Error(`Unknown storyboard control node: \"${brick}\"`);\n }\n}\n\nasync function renderForEach(\n returnNode: RenderNode,\n dataSource: unknown[],\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId: string | undefined,\n tplStack?: Map<string, number>\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n\n const rendered = await Promise.all(\n dataSource.map((item, i) =>\n Promise.all(\n bricks.map((brickConf, j) =>\n renderBrick(\n returnNode,\n brickConf,\n {\n ...runtimeContext,\n forEachItem: item,\n },\n rendererContext,\n slotId,\n i * j,\n tplStack && new Map(tplStack)\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n for (const item of rendered.flat()) {\n mergeRenderOutput(output, item);\n }\n return output;\n}\n\nfunction loadMenu(\n menuConf: MenuConf | undefined,\n runtimeContext: RuntimeContext\n) {\n if (!menuConf) {\n return;\n }\n\n // istanbul ignore next\n if ((menuConf as { type?: \"brick\" }).type === \"brick\") {\n // eslint-disable-next-line no-console\n console.error(\"Set menu with brick is dropped in v3:\", menuConf);\n throw new Error(\"Set menu with brick is dropped in v3\");\n }\n\n // istanbul ignore next\n if (menuConf.type === \"resolve\") {\n // eslint-disable-next-line no-console\n console.warn(\"Set menu with resolve is not supported in v3 yet:\", menuConf);\n return;\n }\n\n return asyncComputeRealValue(\n menuConf,\n runtimeContext\n ) as Promise<StaticMenuConf>;\n}\n\nfunction mergeRenderOutput(\n output: RenderOutput,\n newOutput: RenderOutput\n): void {\n const { blockingList, node, menuRequests, hasTrackingControls, ...rest } =\n newOutput;\n output.blockingList.push(...blockingList);\n output.menuRequests.push(...menuRequests);\n\n if (node) {\n if (output.node) {\n let last = output.node;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = node;\n } else {\n output.node = node;\n }\n }\n\n Object.assign(output, rest);\n}\n\nexport function childrenToSlots(\n children: BrickConf[] | undefined,\n originalSlots: SlotsConf | undefined\n) {\n let newSlots = originalSlots;\n // istanbul ignore next\n if (\n process.env.NODE_ENV === \"development\" &&\n children &&\n !Array.isArray(children)\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Specified brick children but not array:\",\n `<${typeof children}>`,\n children\n );\n }\n if (Array.isArray(children) && !newSlots) {\n newSlots = {};\n for (const child of children) {\n const slot = child.slot ?? \"\";\n if (!hasOwnProperty(newSlots, slot)) {\n newSlots[slot] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n (newSlots[slot] as SlotConfOfBricks).bricks.push(child);\n }\n }\n return newSlots;\n}\n\nfunction catchLoadBrick(\n promise: Promise<unknown>,\n brickName: string,\n unknownBricks: RendererContext[\"unknownBricks\"]\n) {\n return unknownBricks === \"silent\"\n ? promise.catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Load brick \"${brickName}\" failed:`, e);\n })\n : promise;\n}\n"],"mappings":";;;;;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAIA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,wBAAA,GAAAR,OAAA;AAKA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AAKA,IAAAW,qBAAA,GAAAX,OAAA;AAOA,IAAAY,MAAA,GAAAZ,OAAA;AAIA,IAAAa,gBAAA,GAAAb,OAAA;AAEA,IAAAc,QAAA,GAAAd,OAAA;AACA,IAAAe,MAAA,GAAAf,OAAA;AACA,IAAAgB,UAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,OAAA;AACA,IAAAkB,WAAA,GAAAlB,OAAA;AAKA,IAAAmB,mBAAA,GAAAnB,OAAA;AACA,IAAAoB,SAAA,GAAApB,OAAA;AAiBO,eAAeqB,YAAYA,CAChCC,UAAsB,EACtBC,MAAmB,EACnBC,eAA+B,EAC/BC,eAAgC,EAChCC,MAAe,EACQ;EACvB,MAAMC,OAAO,GAAG,MAAM,IAAAC,wBAAW,EAACL,MAAM,EAAEC,eAAe,CAAC;EAC1D,MAAMK,MAAoB,GAAG;IAC3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C2J,KAAK,CAAC;IACzD;EACF;EACA,OAAOc,QAAQ;AACjB;AAEA,SAASjE,cAAcA,CACrBsE,OAAyB,EACzBvG,SAAiB,EACjBkC,aAA+C,EAC/C;EACA,OAAOA,aAAa,KAAK,QAAQ,GAC7BqE,OAAO,CAACC,KAAK,CAAEC,CAAC,IAAK;IACnB;IACA/J,OAAO,CAACC,KAAK,CAAE,eAAcqD,SAAU,WAAU,EAAEyG,CAAC,CAAC;EACvD,CAAC,CAAC,GACFF,OAAO;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Runtime.js","names":["_i18n","require","_loader","_general","_moment","_interopRequireDefault","_history","_matchStoryboard","_Router","_i18n2","_Notification","_Dialog","_injected","runtime","bootstrapData","router","hooks","exports","createRuntime","options","Error","initializeI18n","NS","locales","moment","locale","i18n","language","on","createHistory","Runtime","getRuntime","initialized","bootstrapped","initialize","data","_data$settings$preset","_data$settings","normalizeBootstrapData","notification","dialog","settings","presetBricks","loadNotificationService","loadBricks","loadDialogService","bootstrap","Router","storyboards","getRecentApps","_router$getRecentApps","_router","getCurrentApp","_router2","currentApp","getFeatureFlags","_bootstrapData","_bootstrapData$settin","_router3","_router3$getRecentApp","_router3$getRecentApp2","_router3$getRecentApp3","featureFlags","config","getMiscSettings","_bootstrapData2","_bootstrapData2$setti","_router4","_router4$getRecentApp","_router4$getRecentApp2","_router4$getRecentApp3","misc","getBrandSettings","_bootstrapData3","_bootstrapData3$setti","base_title","brand","getLaunchpadSettings","_bootstrapData4","_bootstrapData4$setti","columns","rows","launchpad","getDesktops","_bootstrapData$deskto","_bootstrapData5","desktops","getLaunchpadSiteMap","_bootstrapData$siteSo","_bootstrapData6","siteSort","toggleLaunchpadEffect","open","document","body","classList","toggle","applyPageTitle","pageTitle","baseTitle","title","getNavConfig","_router5","bricks","loadBricksImperatively","getBrickPackages","Array","isArray","app","ns","id","Object","entries","forEach","lang","resources","addResourceBundle","localeName","getFixedT","name","keys","removeResourceBundle","isObject","deepFreeze","brickPackages","_bootstrapData$brickP","_bootstrapData7","injectedBrickPackages","_internalApiLoadBricks","_internalApiGetRenderId","_router6","getRenderId","_internalApiMatchStoryboard","pathname","_bootstrapData$storyb","_bootstrapData8","matchStoryboard","_internalApiGetRuntimeContext","_router7","getRuntimeContext","_internalApiGetStoryboardInBootstrapData","appId","_bootstrapData9","_bootstrapData9$story","find","storyboard","_internalApiGetAppInBootstrapData","_internalApiGetStoryb","_test_only_setBootstrapData","process","env","NODE_ENV"],"sources":["../../../src/internal/Runtime.ts"],"sourcesContent":["import type {\n RuntimeStoryboard,\n BootstrapSettings,\n FeatureFlags,\n BootstrapData,\n Contract,\n Storyboard,\n BrickConf,\n RouteConf,\n ResolveConf,\n} from \"@next-core/types\";\nimport { i18n, initializeI18n } from \"@next-core/i18n\";\nimport { loadBricksImperatively } from \"@next-core/loader\";\nimport { deepFreeze, isObject } from \"@next-core/utils/general\";\nimport type { PermissionApi_validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\nimport moment from \"moment\";\nimport \"moment/locale/zh-cn.js\";\nimport { createHistory } from \"../history.js\";\nimport { matchStoryboard } from \"./matchStoryboard.js\";\nimport { Router } from \"./Router.js\";\nimport { NS, locales } from \"./i18n.js\";\nimport { loadNotificationService } from \"../Notification.js\";\nimport { loadDialogService } from \"../Dialog.js\";\nimport { injectedBrickPackages } from \"./injected.js\";\nimport type { AppForCheck } from \"./hasInstalledApp.js\";\nimport type { RuntimeContext } from \"./interfaces.js\";\n\nlet runtime: Runtime;\n\n// Allow inject bootstrap data in a runtime other than Brick Next.\nlet bootstrapData: BootstrapData | undefined;\nlet router: Router | undefined;\n\nexport interface RuntimeOptions {\n hooks?: RuntimeHooks;\n}\n\nexport interface ImagesFactory {\n get(name: string): string;\n}\n\nexport interface RuntimeHooks {\n auth?: {\n getAuth(): object;\n isLoggedIn(): boolean;\n authenticate?(...args: unknown[]): unknown;\n logout?(...args: unknown[]): unknown;\n };\n fulfilStoryboard?: (storyboard: RuntimeStoryboard) => Promise<void>;\n validatePermissions?: typeof PermissionApi_validatePermissions;\n checkPermissions?: {\n checkPermissions(...actions: string[]): boolean;\n preCheckPermissions(storyboard: Storyboard): Promise<void> | undefined;\n preCheckPermissionsForBrickOrRoute(\n container: BrickConf | RouteConf,\n asyncComputeRealValue: (value: unknown) => Promise<unknown>\n ): Promise<void> | undefined;\n };\n checkInstalledApps?: {\n preCheckInstalledApps(\n storyboard: Storyboard,\n hasAppInBootstrap: (appId: string) => boolean\n ): void;\n waitForCheckingApps(appIds: string[]): Promise<void>;\n getCheckedApp(appId: string): AppForCheck | undefined;\n };\n flowApi?: {\n FLOW_API_PROVIDER: string;\n registerFlowApiProvider(): void;\n isFlowApiProvider(provider: string): boolean;\n getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string\n ): Promise<unknown[]>;\n collectContract(contracts: Contract[] | undefined): void;\n collectWidgetContract(contracts: Contract[] | undefined): void;\n clearCollectWidgetContract(): void;\n };\n menu?: {\n getMenuById(menuId: string): unknown;\n fetchMenuById(\n menuId: string,\n runtimeContext: RuntimeContext,\n runtimeHelpers: RuntimeHooksMenuHelpers\n ): Promise<unknown>;\n };\n images?: {\n imagesFactory(\n appId: string,\n isBuildPush?: boolean,\n version?: string\n ): ImagesFactory;\n widgetImagesFactory(\n widgetId: string,\n widgetVersion?: string\n ): ImagesFactory;\n };\n messageDispatcher?: {\n subscribe(...args: unknown[]): Promise<Event>;\n unsubscribe(...args: unknown[]): Promise<Event>;\n onMessage(channel: string, listener: (data: unknown) => void): void;\n onClose(listener: () => void): void;\n reset(): void;\n };\n}\n\nexport interface RuntimeHooksMenuHelpers {\n getStoryboardByAppId(appId: string): Storyboard | undefined;\n resolveData(\n resolveConf: ResolveConf,\n runtimeContext: RuntimeContext\n ): Promise<unknown>;\n asyncComputeRealValue(\n value: unknown,\n runtimeContext: RuntimeContext,\n options?: { ignoreSymbols?: boolean; noInject?: boolean }\n ): Promise<unknown>;\n}\n\nexport let hooks: RuntimeHooks | undefined;\n\nexport function createRuntime(options?: RuntimeOptions) {\n if (runtime) {\n throw new Error(\"Cannot create multiple runtimes\");\n }\n hooks = options?.hooks;\n initializeI18n(NS, locales);\n moment.locale(i18n.language);\n i18n.on(\"languageChanged\", () => {\n moment.locale(i18n.language);\n });\n createHistory();\n runtime = new Runtime();\n return runtime;\n}\n\nexport function getRuntime() {\n return runtime;\n}\n\nexport class Runtime {\n #initialized = false;\n #bootstrapped = false;\n\n initialize(data: BootstrapData) {\n if (this.#initialized) {\n throw new Error(\"The runtime cannot be initialized more than once\");\n }\n this.#initialized = true;\n normalizeBootstrapData(data);\n bootstrapData = data;\n const { notification, dialog } = (data.settings?.presetBricks ?? {}) as {\n notification?: string | false;\n dialog?: string | false;\n };\n if (notification !== false) {\n loadNotificationService(\n notification ?? \"basic.show-notification\",\n this.loadBricks\n );\n }\n if (dialog !== false) {\n loadDialogService(dialog ?? \"basic.show-dialog\", this.loadBricks);\n }\n }\n\n async bootstrap(data?: BootstrapData) {\n if (data) {\n this.initialize(data);\n }\n if (this.#bootstrapped) {\n throw new Error(\"The runtime cannot be bootstrapped more than once\");\n }\n this.#bootstrapped = true;\n router = new Router(bootstrapData!.storyboards!);\n await router.bootstrap();\n }\n\n getRecentApps() {\n return router?.getRecentApps() ?? {};\n }\n\n getCurrentApp() {\n return router?.getRecentApps().currentApp;\n }\n\n getFeatureFlags(): FeatureFlags {\n return {\n ...bootstrapData?.settings?.featureFlags,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.featureFlags,\n \"migrate-to-brick-next-v3\": true,\n };\n }\n\n getMiscSettings() {\n return {\n ...bootstrapData?.settings?.misc,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.misc,\n };\n }\n\n getBrandSettings(): Record<string, string> {\n return {\n base_title: \"DevOps 管理专家\",\n ...(bootstrapData?.settings?.brand as Record<string, string>),\n };\n }\n\n getLaunchpadSettings() {\n return {\n columns: 7,\n rows: 4,\n ...bootstrapData?.settings?.launchpad,\n };\n }\n\n getDesktops(): unknown[] {\n return bootstrapData?.desktops ?? [];\n }\n\n getLaunchpadSiteMap(): unknown[] {\n return bootstrapData?.siteSort ?? [];\n }\n\n toggleLaunchpadEffect(open: boolean): void {\n document.body.classList.toggle(\"launchpad-open\", open);\n }\n\n applyPageTitle(pageTitle: string): void {\n const baseTitle = this.getBrandSettings().base_title;\n document.title = pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle;\n }\n\n getNavConfig() {\n return router?.getNavConfig();\n }\n\n loadBricks(bricks: string[] | Set<string>) {\n return loadBricksImperatively(bricks, getBrickPackages());\n }\n}\n\nfunction normalizeBootstrapData(data: BootstrapData) {\n if (Array.isArray(data.storyboards)) {\n for (const { app } of data.storyboards) {\n if (app.locales) {\n // Prefix to avoid conflict between brick package's i18n namespace.\n const ns = `tmp/${app.id}`;\n // Support any languages in `app.locales`.\n Object.entries(app.locales).forEach(([lang, resources]) => {\n i18n.addResourceBundle(lang, ns, resources);\n });\n // Use `app.name` as the fallback `app.localeName`.\n app.localeName = i18n.getFixedT(null, ns)(\"name\", app.name) as string;\n // Remove the temporary i18n resource bundles.\n Object.keys(app.locales).forEach((lang) => {\n i18n.removeResourceBundle(lang, ns);\n });\n } else {\n app.localeName = app.name;\n }\n }\n }\n if (isObject(data.settings)) {\n deepFreeze(data.settings);\n }\n if (data.brickPackages) {\n deepFreeze(data.brickPackages);\n }\n}\n\nexport function getBrickPackages() {\n return bootstrapData?.brickPackages ?? injectedBrickPackages;\n}\n\nexport function _internalApiLoadBricks(bricks: string[] | Set<string>) {\n return loadBricksImperatively(bricks, getBrickPackages());\n}\n\nexport function _internalApiGetRenderId(): string | undefined {\n return router?.getRenderId();\n}\n\nexport function _internalApiMatchStoryboard(\n pathname: string\n): RuntimeStoryboard | undefined {\n return matchStoryboard(bootstrapData?.storyboards ?? [], pathname);\n}\n\nexport function _internalApiGetRuntimeContext() {\n return router?.getRuntimeContext();\n}\n\nexport function _internalApiGetStoryboardInBootstrapData(appId: string) {\n return bootstrapData?.storyboards?.find(\n (storyboard) => storyboard.app.id === appId\n );\n}\n\nexport function _internalApiGetAppInBootstrapData(appId: string) {\n return _internalApiGetStoryboardInBootstrapData(appId)?.app;\n}\n\nexport let _test_only_setBootstrapData: (data: BootstrapData) => void;\n\n// istanbul ignore next\nif (process.env.NODE_ENV === \"test\") {\n _test_only_setBootstrapData = (data) => {\n bootstrapData = data as BootstrapData;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAWA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACAA,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,SAAA,GAAAX,OAAA;AAIA,IAAIY,OAAgB;;AAEpB;AACA,IAAIC,aAAwC;AAC5C,IAAIC,MAA0B;AAyFvB,IAAIC,KAA+B;AAACC,OAAA,CAAAD,KAAA,GAAAA,KAAA;AAEpC,SAASE,aAAaA,CAACC,OAAwB,EAAE;EACtD,IAAIN,OAAO,EAAE;IACX,MAAM,IAAIO,KAAK,CAAC,iCAAiC,CAAC;EACpD;EACAH,OAAA,CAAAD,KAAA,GAAAA,KAAK,GAAGG,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEH,KAAK;EACtB,IAAAK,oBAAc,EAACC,SAAE,EAAEC,cAAO,CAAC;EAC3BC,eAAM,CAACC,MAAM,CAACC,UAAI,CAACC,QAAQ,CAAC;EAC5BD,UAAI,CAACE,EAAE,CAAC,iBAAiB,EAAE,MAAM;IAC/BJ,eA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e;EAAA,IAAAC,qBAAA,EAAAC,eAAA;EAC/B,OAAO,IAAAC,gCAAe,GAAAF,qBAAA,IAAAC,eAAA,GAACzH,aAAa,cAAAyH,eAAA,uBAAbA,eAAA,CAAevF,WAAW,cAAAsF,qBAAA,cAAAA,qBAAA,GAAI,EAAE,EAAED,QAAQ,CAAC;AACpE;AAEO,SAASI,6BAA6BA,CAAA,EAAG;EAAA,IAAAC,QAAA;EAC9C,QAAAA,QAAA,GAAO3H,MAAM,cAAA2H,QAAA,uBAANA,QAAA,CAAQC,iBAAiB,CAAC,CAAC;AACpC;AAEO,SAASC,wCAAwCA,CAACC,KAAa,EAAE;EAAA,IAAAC,eAAA,EAAAC,qBAAA;EACtE,QAAAD,eAAA,GAAOhI,aAAa,cAAAgI,eAAA,wBAAAC,qBAAA,GAAbD,eAAA,CAAe9F,WAAW,cAAA+F,qBAAA,uBAA1BA,qBAAA,CAA4BC,IAAI,CACpCC,UAAU,IAAKA,UAAU,CAACrC,GAAG,CAACE,EAAE,KAAK+B,KACxC,CAAC;AACH;AAEO,SAASK,iCAAiCA,CAACL,KAAa,EAAE;EAAA,IAAAM,qBAAA;EAC/D,QAAAA,qBAAA,GAAOP,wCAAwC,CAACC,KAAK,CAAC,cAAAM,qBAAA,uBAA/CA,qBAAA,CAAiDvC,GAAG;AAC7D;AAEO,IAAIwC,2BAA0D;;AAErE;AAAAnI,OAAA,CAAAmI,2BAAA,GAAAA,2BAAA;AACA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;EACnCtI,OAAA,CAAAmI,2BAAA,GAAAA,2BAA2B,GAAIjH,IAAI,IAAK;IACtCrB,aAAa,GAAGqB,IAAqB;EACvC,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"Runtime.js","names":["_i18n","require","_loader","_general","_moment","_interopRequireDefault","_history","_matchStoryboard","_Router","_i18n2","_Notification","_Dialog","_injected","runtime","bootstrapData","router","hooks","exports","createRuntime","options","Error","initializeI18n","NS","locales","moment","locale","i18n","language","on","createHistory","Runtime","getRuntime","initialized","bootstrapped","initialize","data","_data$settings$preset","_data$settings","normalizeBootstrapData","notification","dialog","settings","presetBricks","loadNotificationService","loadBricks","loadDialogService","bootstrap","Router","storyboards","getRecentApps","_router$getRecentApps","_router","getCurrentApp","_router2","currentApp","getFeatureFlags","_bootstrapData","_bootstrapData$settin","_router3","_router3$getRecentApp","_router3$getRecentApp2","_router3$getRecentApp3","featureFlags","config","getMiscSettings","_bootstrapData2","_bootstrapData2$setti","_router4","_router4$getRecentApp","_router4$getRecentApp2","_router4$getRecentApp3","misc","getBrandSettings","_bootstrapData3","_bootstrapData3$setti","base_title","brand","getLaunchpadSettings","_bootstrapData4","_bootstrapData4$setti","columns","rows","launchpad","getDesktops","_bootstrapData$deskto","_bootstrapData5","desktops","getLaunchpadSiteMap","_bootstrapData$siteSo","_bootstrapData6","siteSort","toggleLaunchpadEffect","open","document","body","classList","toggle","applyPageTitle","pageTitle","baseTitle","title","getNavConfig","_router5","bricks","loadBricksImperatively","getBrickPackages","Array","isArray","app","ns","id","Object","entries","forEach","lang","resources","addResourceBundle","localeName","getFixedT","name","keys","removeResourceBundle","isObject","deepFreeze","brickPackages","_bootstrapData$brickP","_bootstrapData7","injectedBrickPackages","_internalApiLoadBricks","_internalApiGetRenderId","_router6","getRenderId","_internalApiMatchStoryboard","pathname","_bootstrapData$storyb","_bootstrapData8","matchStoryboard","_internalApiGetRuntimeContext","_router7","getRuntimeContext","_internalApiGetStoryboardInBootstrapData","appId","_bootstrapData9","_bootstrapData9$story","find","storyboard","_internalApiGetAppInBootstrapData","_internalApiGetStoryb","_test_only_setBootstrapData","process","env","NODE_ENV"],"sources":["../../../src/internal/Runtime.ts"],"sourcesContent":["import type {\n RuntimeStoryboard,\n BootstrapSettings,\n FeatureFlags,\n BootstrapData,\n Contract,\n Storyboard,\n BrickConf,\n RouteConf,\n ResolveConf,\n} from \"@next-core/types\";\nimport { i18n, initializeI18n } from \"@next-core/i18n\";\nimport { loadBricksImperatively } from \"@next-core/loader\";\nimport { deepFreeze, isObject } from \"@next-core/utils/general\";\nimport type { PermissionApi_validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\nimport moment from \"moment\";\nimport \"moment/locale/zh-cn.js\";\nimport { createHistory } from \"../history.js\";\nimport { matchStoryboard } from \"./matchStoryboard.js\";\nimport { Router } from \"./Router.js\";\nimport { NS, locales } from \"./i18n.js\";\nimport { loadNotificationService } from \"../Notification.js\";\nimport { loadDialogService } from \"../Dialog.js\";\nimport { injectedBrickPackages } from \"./injected.js\";\nimport type { AppForCheck } from \"./hasInstalledApp.js\";\nimport type { RuntimeContext } from \"./interfaces.js\";\n\nlet runtime: Runtime;\n\n// Allow inject bootstrap data in a runtime other than Brick Next.\nlet bootstrapData: BootstrapData | undefined;\nlet router: Router | undefined;\n\nexport interface RuntimeOptions {\n hooks?: RuntimeHooks;\n}\n\nexport interface ImagesFactory {\n get(name: string): string;\n}\n\nexport interface RuntimeHooks {\n auth?: {\n getAuth(): object;\n isLoggedIn(): boolean;\n authenticate?(...args: unknown[]): unknown;\n logout?(...args: unknown[]): unknown;\n };\n fulfilStoryboard?: (storyboard: RuntimeStoryboard) => Promise<void>;\n validatePermissions?: typeof PermissionApi_validatePermissions;\n checkPermissions?: {\n checkPermissions(...actions: string[]): boolean;\n preCheckPermissions(storyboard: Storyboard): Promise<void> | undefined;\n preCheckPermissionsForBrickOrRoute(\n container: BrickConf | RouteConf,\n asyncComputeRealValue: (value: unknown) => Promise<unknown>\n ): Promise<void> | undefined;\n };\n checkInstalledApps?: {\n preCheckInstalledApps(\n storyboard: Storyboard,\n hasAppInBootstrap: (appId: string) => boolean\n ): void;\n waitForCheckingApps(appIds: string[]): Promise<void>;\n getCheckedApp(appId: string): AppForCheck | undefined;\n };\n flowApi?: {\n FLOW_API_PROVIDER: string;\n registerFlowApiProvider(): void;\n isFlowApiProvider(provider: string): boolean;\n getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string\n ): Promise<unknown[]>;\n collectContract(contracts: Contract[] | undefined): void;\n collectWidgetContract(contracts: Contract[] | undefined): void;\n clearCollectWidgetContract(): void;\n };\n menu?: {\n getMenuById(menuId: string): unknown;\n fetchMenuById(\n menuId: string,\n runtimeContext: RuntimeContext,\n runtimeHelpers: RuntimeHooksMenuHelpers\n ): Promise<unknown>;\n };\n images?: {\n imagesFactory(\n appId: string,\n isBuildPush?: boolean,\n version?: string\n ): ImagesFactory;\n widgetImagesFactory(\n widgetId: string,\n widgetVersion?: string\n ): ImagesFactory;\n };\n messageDispatcher?: {\n subscribe(...args: unknown[]): Promise<unknown>;\n unsubscribe(...args: unknown[]): Promise<unknown>;\n onMessage(channel: string, listener: (data: unknown) => void): void;\n onClose(listener: () => void): void;\n reset(): void;\n };\n}\n\nexport interface RuntimeHooksMenuHelpers {\n getStoryboardByAppId(appId: string): Storyboard | undefined;\n resolveData(\n resolveConf: ResolveConf,\n runtimeContext: RuntimeContext\n ): Promise<unknown>;\n asyncComputeRealValue(\n value: unknown,\n runtimeContext: RuntimeContext,\n options?: { ignoreSymbols?: boolean; noInject?: boolean }\n ): Promise<unknown>;\n}\n\nexport let hooks: RuntimeHooks | undefined;\n\nexport function createRuntime(options?: RuntimeOptions) {\n if (runtime) {\n throw new Error(\"Cannot create multiple runtimes\");\n }\n hooks = options?.hooks;\n initializeI18n(NS, locales);\n moment.locale(i18n.language);\n i18n.on(\"languageChanged\", () => {\n moment.locale(i18n.language);\n });\n createHistory();\n runtime = new Runtime();\n return runtime;\n}\n\nexport function getRuntime() {\n return runtime;\n}\n\nexport class Runtime {\n #initialized = false;\n #bootstrapped = false;\n\n initialize(data: BootstrapData) {\n if (this.#initialized) {\n throw new Error(\"The runtime cannot be initialized more than once\");\n }\n this.#initialized = true;\n normalizeBootstrapData(data);\n bootstrapData = data;\n const { notification, dialog } = (data.settings?.presetBricks ?? {}) as {\n notification?: string | false;\n dialog?: string | false;\n };\n if (notification !== false) {\n loadNotificationService(\n notification ?? \"basic.show-notification\",\n this.loadBricks\n );\n }\n if (dialog !== false) {\n loadDialogService(dialog ?? \"basic.show-dialog\", this.loadBricks);\n }\n }\n\n async bootstrap(data?: BootstrapData) {\n if (data) {\n this.initialize(data);\n }\n if (this.#bootstrapped) {\n throw new Error(\"The runtime cannot be bootstrapped more than once\");\n }\n this.#bootstrapped = true;\n router = new Router(bootstrapData!.storyboards!);\n await router.bootstrap();\n }\n\n getRecentApps() {\n return router?.getRecentApps() ?? {};\n }\n\n getCurrentApp() {\n return router?.getRecentApps().currentApp;\n }\n\n getFeatureFlags(): FeatureFlags {\n return {\n ...bootstrapData?.settings?.featureFlags,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.featureFlags,\n \"migrate-to-brick-next-v3\": true,\n };\n }\n\n getMiscSettings() {\n return {\n ...bootstrapData?.settings?.misc,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.misc,\n };\n }\n\n getBrandSettings(): Record<string, string> {\n return {\n base_title: \"DevOps 管理专家\",\n ...(bootstrapData?.settings?.brand as Record<string, string>),\n };\n }\n\n getLaunchpadSettings() {\n return {\n columns: 7,\n rows: 4,\n ...bootstrapData?.settings?.launchpad,\n };\n }\n\n getDesktops(): unknown[] {\n return bootstrapData?.desktops ?? [];\n }\n\n getLaunchpadSiteMap(): unknown[] {\n return bootstrapData?.siteSort ?? [];\n }\n\n toggleLaunchpadEffect(open: boolean): void {\n document.body.classList.toggle(\"launchpad-open\", open);\n }\n\n applyPageTitle(pageTitle: string): void {\n const baseTitle = this.getBrandSettings().base_title;\n document.title = pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle;\n }\n\n getNavConfig() {\n return router?.getNavConfig();\n }\n\n loadBricks(bricks: string[] | Set<string>) {\n return loadBricksImperatively(bricks, getBrickPackages());\n }\n}\n\nfunction normalizeBootstrapData(data: BootstrapData) {\n if (Array.isArray(data.storyboards)) {\n for (const { app } of data.storyboards) {\n if (app.locales) {\n // Prefix to avoid conflict between brick package's i18n namespace.\n const ns = `tmp/${app.id}`;\n // Support any languages in `app.locales`.\n Object.entries(app.locales).forEach(([lang, resources]) => {\n i18n.addResourceBundle(lang, ns, resources);\n });\n // Use `app.name` as the fallback `app.localeName`.\n app.localeName = i18n.getFixedT(null, ns)(\"name\", app.name) as string;\n // Remove the temporary i18n resource bundles.\n Object.keys(app.locales).forEach((lang) => {\n i18n.removeResourceBundle(lang, ns);\n });\n } else {\n app.localeName = app.name;\n }\n }\n }\n if (isObject(data.settings)) {\n deepFreeze(data.settings);\n }\n if (data.brickPackages) {\n deepFreeze(data.brickPackages);\n }\n}\n\nexport function getBrickPackages() {\n return bootstrapData?.brickPackages ?? injectedBrickPackages;\n}\n\nexport function _internalApiLoadBricks(bricks: string[] | Set<string>) {\n return loadBricksImperatively(bricks, getBrickPackages());\n}\n\nexport function _internalApiGetRenderId(): string | undefined {\n return router?.getRenderId();\n}\n\nexport function _internalApiMatchStoryboard(\n pathname: string\n): RuntimeStoryboard | undefined {\n return matchStoryboard(bootstrapData?.storyboards ?? [], pathname);\n}\n\nexport function _internalApiGetRuntimeContext() {\n return router?.getRuntimeContext();\n}\n\nexport function _internalApiGetStoryboardInBootstrapData(appId: string) {\n return bootstrapData?.storyboards?.find(\n (storyboard) => storyboard.app.id === appId\n );\n}\n\nexport function _internalApiGetAppInBootstrapData(appId: string) {\n return _internalApiGetStoryboardInBootstrapData(appId)?.app;\n}\n\nexport let _test_only_setBootstrapData: (data: BootstrapData) => void;\n\n// istanbul ignore next\nif (process.env.NODE_ENV === \"test\") {\n _test_only_setBootstrapData = (data) => {\n bootstrapData = data as BootstrapData;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAWA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACAA,OAAA;AAC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,GAAbD,eAAA,CAAe9F,WAAW,cAAA+F,qBAAA,uBAA1BA,qBAAA,CAA4BC,IAAI,CACpCC,UAAU,IAAKA,UAAU,CAACrC,GAAG,CAACE,EAAE,KAAK+B,KACxC,CAAC;AACH;AAEO,SAASK,iCAAiCA,CAACL,KAAa,EAAE;EAAA,IAAAM,qBAAA;EAC/D,QAAAA,qBAAA,GAAOP,wCAAwC,CAACC,KAAK,CAAC,cAAAM,qBAAA,uBAA/CA,qBAAA,CAAiDvC,GAAG;AAC7D;AAEO,IAAIwC,2BAA0D;;AAErE;AAAAnI,OAAA,CAAAmI,2BAAA,GAAAA,2BAAA;AACA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;EACnCtI,OAAA,CAAAmI,2BAAA,GAAAA,2BAA2B,GAAIjH,IAAI,IAAK;IACtCrB,aAAa,GAAGqB,IAAqB;EACvC,CAAC;AACH"}
|
|
@@ -5,61 +5,50 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.asyncComputeRealProperties = asyncComputeRealProperties;
|
|
7
7
|
exports.computeRealProperties = computeRealProperties;
|
|
8
|
+
exports.constructAsyncProperties = constructAsyncProperties;
|
|
8
9
|
var _general = require("@next-core/utils/general");
|
|
9
10
|
var _computeRealValue = require("./computeRealValue.js");
|
|
10
11
|
var _getNextStateOfUseBrick = require("./getNextStateOfUseBrick.js");
|
|
11
12
|
var _getTracks = require("./getTracks.js");
|
|
12
|
-
|
|
13
|
+
function asyncComputeRealProperties(properties, runtimeContext, trackingContextList) {
|
|
13
14
|
if ((0, _general.isObject)(properties)) {
|
|
14
|
-
return Object.fromEntries(
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
return Object.fromEntries(Object.entries(properties).map(([propName, propValue]) => {
|
|
16
|
+
const {
|
|
17
|
+
contextNames,
|
|
18
|
+
stateNames,
|
|
19
|
+
formStateNames
|
|
20
|
+
} = (0, _getTracks.getTracks)(propValue);
|
|
21
|
+
if (contextNames || stateNames || formStateNames) {
|
|
22
|
+
trackingContextList.push({
|
|
17
23
|
contextNames,
|
|
18
24
|
stateNames,
|
|
19
|
-
formStateNames
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
contextNames,
|
|
24
|
-
stateNames,
|
|
25
|
-
formStateNames,
|
|
26
|
-
propName,
|
|
27
|
-
propValue
|
|
28
|
-
});
|
|
29
|
-
}
|
|
25
|
+
formStateNames,
|
|
26
|
+
propName,
|
|
27
|
+
propValue
|
|
28
|
+
});
|
|
30
29
|
}
|
|
31
30
|
// Related: https://github.com/facebook/react/issues/11347
|
|
32
|
-
const
|
|
31
|
+
const asyncValue = (0, _computeRealValue.asyncComputeRealValue)(propValue, runtimeContext, {
|
|
33
32
|
$$lazyForUseBrick: true,
|
|
34
33
|
$$stateOfUseBrick: propName === "useBrick" ? _getNextStateOfUseBrick.StateOfUseBrick.USE_BRICK : _getNextStateOfUseBrick.StateOfUseBrick.INITIAL
|
|
35
34
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return [propName, realValue];
|
|
39
|
-
}
|
|
40
|
-
}))).filter(Boolean));
|
|
35
|
+
return [propName, asyncValue];
|
|
36
|
+
}));
|
|
41
37
|
}
|
|
42
38
|
return {};
|
|
43
39
|
}
|
|
44
|
-
function
|
|
40
|
+
async function constructAsyncProperties(asyncProperties) {
|
|
41
|
+
return Object.fromEntries((await Promise.all(Object.entries(asyncProperties).map(async ([propName, asyncValue]) => {
|
|
42
|
+
const value = await asyncValue;
|
|
43
|
+
// For `style` and `dataset`, only object is acceptable.
|
|
44
|
+
if (propName !== "style" && propName !== "dataset" || (0, _general.isObject)(value)) {
|
|
45
|
+
return [propName, value];
|
|
46
|
+
}
|
|
47
|
+
}))).filter(Boolean));
|
|
48
|
+
}
|
|
49
|
+
function computeRealProperties(properties, runtimeContext) {
|
|
45
50
|
if ((0, _general.isObject)(properties)) {
|
|
46
51
|
return Object.fromEntries(Object.entries(properties).map(([propName, propValue]) => {
|
|
47
|
-
if (Array.isArray(trackingContextList)) {
|
|
48
|
-
const {
|
|
49
|
-
contextNames,
|
|
50
|
-
stateNames,
|
|
51
|
-
formStateNames
|
|
52
|
-
} = (0, _getTracks.getTracks)(propValue);
|
|
53
|
-
if (contextNames || stateNames || formStateNames) {
|
|
54
|
-
trackingContextList.push({
|
|
55
|
-
contextNames,
|
|
56
|
-
stateNames,
|
|
57
|
-
formStateNames,
|
|
58
|
-
propName,
|
|
59
|
-
propValue
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
52
|
// Related: https://github.com/facebook/react/issues/11347
|
|
64
53
|
const realValue = (0, _computeRealValue.computeRealValue)(propValue, runtimeContext, {
|
|
65
54
|
$$lazyForUseBrick: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeRealProperties.js","names":["_general","require","_computeRealValue","_getNextStateOfUseBrick","_getTracks","asyncComputeRealProperties","properties","runtimeContext","trackingContextList","isObject","Object","fromEntries","
|
|
1
|
+
{"version":3,"file":"computeRealProperties.js","names":["_general","require","_computeRealValue","_getNextStateOfUseBrick","_getTracks","asyncComputeRealProperties","properties","runtimeContext","trackingContextList","isObject","Object","fromEntries","entries","map","propName","propValue","contextNames","stateNames","formStateNames","getTracks","push","asyncValue","asyncComputeRealValue","$$lazyForUseBrick","$$stateOfUseBrick","StateOfUseBrick","USE_BRICK","INITIAL","constructAsyncProperties","asyncProperties","Promise","all","value","filter","Boolean","computeRealProperties","realValue","computeRealValue"],"sources":["../../../../src/internal/compute/computeRealProperties.ts"],"sourcesContent":["import { isObject } from \"@next-core/utils/general\";\nimport { asyncComputeRealValue, computeRealValue } from \"./computeRealValue.js\";\nimport { TrackingContextItem } from \"./listenOnTrackingContext.js\";\nimport type { AsyncProperties, RuntimeContext } from \"../interfaces.js\";\nimport { StateOfUseBrick } from \"./getNextStateOfUseBrick.js\";\nimport { getTracks } from \"./getTracks.js\";\n\nexport function asyncComputeRealProperties(\n properties: Record<string, unknown> | undefined,\n runtimeContext: RuntimeContext,\n trackingContextList: TrackingContextItem[]\n): AsyncProperties {\n if (isObject(properties)) {\n return Object.fromEntries(\n Object.entries(properties).map<[string, Promise<unknown>]>(\n ([propName, propValue]) => {\n const { contextNames, stateNames, formStateNames } =\n getTracks(propValue);\n if (contextNames || stateNames || formStateNames) {\n trackingContextList.push({\n contextNames,\n stateNames,\n formStateNames,\n propName,\n propValue,\n });\n }\n // Related: https://github.com/facebook/react/issues/11347\n const asyncValue = asyncComputeRealValue(propValue, runtimeContext, {\n $$lazyForUseBrick: true,\n $$stateOfUseBrick:\n propName === \"useBrick\"\n ? StateOfUseBrick.USE_BRICK\n : StateOfUseBrick.INITIAL,\n });\n return [propName, asyncValue];\n }\n )\n );\n }\n\n return {};\n}\n\nexport async function constructAsyncProperties(\n asyncProperties: AsyncProperties\n): Promise<Record<string, unknown>> {\n return Object.fromEntries(\n (\n await Promise.all(\n Object.entries(asyncProperties).map(async ([propName, asyncValue]) => {\n const value = await asyncValue;\n // For `style` and `dataset`, only object is acceptable.\n if (\n (propName !== \"style\" && propName !== \"dataset\") ||\n isObject(value)\n ) {\n return [propName, value];\n }\n })\n )\n ).filter(Boolean) as [string, unknown][]\n );\n}\n\nexport function computeRealProperties(\n properties: Record<string, unknown> | undefined,\n runtimeContext: RuntimeContext\n): Record<string, unknown> {\n if (isObject(properties)) {\n return Object.fromEntries(\n Object.entries(properties)\n .map<[string, unknown] | undefined>(([propName, propValue]) => {\n // Related: https://github.com/facebook/react/issues/11347\n const realValue = computeRealValue(propValue, runtimeContext, {\n $$lazyForUseBrick: true,\n $$stateOfUseBrick:\n propName === \"useBrick\"\n ? StateOfUseBrick.USE_BRICK\n : StateOfUseBrick.INITIAL,\n });\n // For `style` and `dataset`, only object is acceptable.\n if (\n (propName !== \"style\" && propName !== \"dataset\") ||\n isObject(realValue)\n ) {\n return [propName, realValue];\n }\n })\n .filter(Boolean) as [string, unknown][]\n );\n }\n\n return {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K,GAAG,MAAMX,UAAU;IAC9B;IACA,IACGP,QAAQ,KAAK,OAAO,IAAIA,QAAQ,KAAK,SAAS,IAC/C,IAAAL,iBAAQ,EAACuB,KAAK,CAAC,EACf;MACA,OAAO,CAAClB,QAAQ,EAAEkB,KAAK,CAAC;IAC1B;EACF,CAAC,CACH,CAAC,EACDC,MAAM,CAACC,OAAO,CAClB,CAAC;AACH;AAEO,SAASC,qBAAqBA,CACnC7B,UAA+C,EAC/CC,cAA8B,EACL;EACzB,IAAI,IAAAE,iBAAQ,EAACH,UAAU,CAAC,EAAE;IACxB,OAAOI,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACN,UAAU,CAAC,CACvBO,GAAG,CAAgC,CAAC,CAACC,QAAQ,EAAEC,SAAS,CAAC,KAAK;MAC7D;MACA,MAAMqB,SAAS,GAAG,IAAAC,kCAAgB,EAACtB,SAAS,EAAER,cAAc,EAAE;QAC5DgB,iBAAiB,EAAE,IAAI;QACvBC,iBAAiB,EACfV,QAAQ,KAAK,UAAU,GACnBW,uCAAe,CAACC,SAAS,GACzBD,uCAAe,CAACE;MACxB,CAAC,CAAC;MACF;MACA,IACGb,QAAQ,KAAK,OAAO,IAAIA,QAAQ,KAAK,SAAS,IAC/C,IAAAL,iBAAQ,EAAC2B,SAAS,CAAC,EACnB;QACA,OAAO,CAACtB,QAAQ,EAAEsB,SAAS,CAAC;MAC9B;IACF,CAAC,CAAC,CACDH,MAAM,CAACC,OAAO,CACnB,CAAC;EACH;EAEA,OAAO,CAAC,CAAC;AACX"}
|
|
@@ -198,11 +198,8 @@ class DataStore {
|
|
|
198
198
|
return false;
|
|
199
199
|
}
|
|
200
200
|
let value;
|
|
201
|
-
if (asyncHostProperties && (this.type === "STATE" ? dataConf.expose : this.type === "FORM_STATE")) {
|
|
202
|
-
|
|
203
|
-
if ((0, _general.hasOwnProperty)(hostProps, dataConf.name)) {
|
|
204
|
-
value = hostProps[dataConf.name];
|
|
205
|
-
}
|
|
201
|
+
if (asyncHostProperties && (this.type === "STATE" ? dataConf.expose : this.type === "FORM_STATE") && (0, _general.hasOwnProperty)(asyncHostProperties, dataConf.name)) {
|
|
202
|
+
value = await asyncHostProperties[dataConf.name];
|
|
206
203
|
}
|
|
207
204
|
let load;
|
|
208
205
|
let loading;
|