@next-core/runtime 1.12.0 → 1.12.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/CustomProcessors.js.map +1 -1
- package/dist/cjs/CustomTemplates.js.map +1 -1
- package/dist/cjs/Dialog.js.map +1 -1
- package/dist/cjs/Notification.js.map +1 -1
- package/dist/cjs/StoryboardFunctionRegistry.js.map +1 -1
- package/dist/cjs/auth.js.map +1 -1
- package/dist/cjs/createRoot.js.map +1 -1
- package/dist/cjs/getPageInfo.js.map +1 -1
- package/dist/cjs/handleHttpError.js.map +1 -1
- package/dist/cjs/history.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/bindTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/constants.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/utils.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/expandFormRenderer.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/getDefaultProperties.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/utils.js.map +1 -1
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/Router.js.map +1 -1
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/cjs/internal/abortController.js.map +1 -1
- package/dist/cjs/internal/bindListeners.js.map +1 -1
- package/dist/cjs/internal/compute/StoryboardFunctions.js.map +1 -1
- package/dist/cjs/internal/compute/WidgetFunctions.js.map +1 -1
- package/dist/cjs/internal/compute/checkIf.js.map +1 -1
- package/dist/cjs/internal/compute/computeRealProperties.js.map +1 -1
- package/dist/cjs/internal/compute/computeRealValue.js.map +1 -1
- package/dist/cjs/internal/compute/evaluate.js.map +1 -1
- package/dist/cjs/internal/compute/getGeneralGlobals.js.map +1 -1
- package/dist/cjs/internal/compute/getNextStateOfUseBrick.js.map +1 -1
- package/dist/cjs/internal/compute/getTracks.js.map +1 -1
- package/dist/cjs/internal/compute/images.js.map +1 -1
- package/dist/cjs/internal/compute/listenOnTrackingContext.js.map +1 -1
- package/dist/cjs/internal/compute/markAsComputed.js.map +1 -1
- package/dist/cjs/internal/compute/setRealProperties.js.map +1 -1
- package/dist/cjs/internal/data/DataStore.js.map +1 -1
- package/dist/cjs/internal/data/getProviderBrick.js.map +1 -1
- package/dist/cjs/internal/data/resolveData.js.map +1 -1
- package/dist/cjs/internal/data/resolveDataStore.js.map +1 -1
- package/dist/cjs/internal/hasInstalledApp.js.map +1 -1
- package/dist/cjs/internal/historyExtended.js.map +1 -1
- package/dist/cjs/internal/insertPreviewRoutes.js.map +1 -1
- package/dist/cjs/internal/matchPath.js.map +1 -1
- package/dist/cjs/internal/matchRoutes.js.map +1 -1
- package/dist/cjs/internal/matchStoryboard.js.map +1 -1
- package/dist/cjs/internal/mediaQuery.js.map +1 -1
- package/dist/cjs/internal/mount.js.map +1 -1
- package/dist/cjs/internal/poll.js.map +1 -1
- package/dist/cjs/internal/proxyFactories.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/cjs/isStrictMode.js.map +1 -1
- package/dist/cjs/themeAndMode.js.map +1 -1
- package/dist/esm/CustomProcessors.js.map +1 -1
- package/dist/esm/CustomTemplates.js.map +1 -1
- package/dist/esm/Dialog.js.map +1 -1
- package/dist/esm/Notification.js.map +1 -1
- package/dist/esm/StoryboardFunctionRegistry.js.map +1 -1
- package/dist/esm/auth.js.map +1 -1
- package/dist/esm/createRoot.js.map +1 -1
- package/dist/esm/getPageInfo.js.map +1 -1
- package/dist/esm/handleHttpError.js.map +1 -1
- package/dist/esm/history.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/bindTemplateProxy.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/constants.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/setupUseBrickInTemplate.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/utils.js.map +1 -1
- package/dist/esm/internal/FormRenderer/expandFormRenderer.js.map +1 -1
- package/dist/esm/internal/FormRenderer/getDefaultProperties.js.map +1 -1
- package/dist/esm/internal/FormRenderer/utils.js.map +1 -1
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/esm/internal/RendererContext.js.map +1 -1
- package/dist/esm/internal/Router.js.map +1 -1
- package/dist/esm/internal/Runtime.js.map +1 -1
- package/dist/esm/internal/abortController.js.map +1 -1
- package/dist/esm/internal/bindListeners.js.map +1 -1
- package/dist/esm/internal/compute/StoryboardFunctions.js.map +1 -1
- package/dist/esm/internal/compute/WidgetFunctions.js.map +1 -1
- package/dist/esm/internal/compute/checkIf.js.map +1 -1
- package/dist/esm/internal/compute/computeRealProperties.js.map +1 -1
- package/dist/esm/internal/compute/computeRealValue.js.map +1 -1
- package/dist/esm/internal/compute/evaluate.js.map +1 -1
- package/dist/esm/internal/compute/getGeneralGlobals.js.map +1 -1
- package/dist/esm/internal/compute/getNextStateOfUseBrick.js.map +1 -1
- package/dist/esm/internal/compute/getTracks.js.map +1 -1
- package/dist/esm/internal/compute/images.js.map +1 -1
- package/dist/esm/internal/compute/listenOnTrackingContext.js.map +1 -1
- package/dist/esm/internal/compute/markAsComputed.js.map +1 -1
- package/dist/esm/internal/compute/setRealProperties.js.map +1 -1
- package/dist/esm/internal/data/DataStore.js.map +1 -1
- package/dist/esm/internal/data/getProviderBrick.js.map +1 -1
- package/dist/esm/internal/data/resolveData.js.map +1 -1
- package/dist/esm/internal/data/resolveDataStore.js.map +1 -1
- package/dist/esm/internal/hasInstalledApp.js.map +1 -1
- package/dist/esm/internal/historyExtended.js.map +1 -1
- package/dist/esm/internal/insertPreviewRoutes.js.map +1 -1
- package/dist/esm/internal/matchPath.js.map +1 -1
- package/dist/esm/internal/matchRoutes.js.map +1 -1
- package/dist/esm/internal/matchStoryboard.js.map +1 -1
- package/dist/esm/internal/mediaQuery.js.map +1 -1
- package/dist/esm/internal/mount.js.map +1 -1
- package/dist/esm/internal/poll.js.map +1 -1
- package/dist/esm/internal/proxyFactories.js.map +1 -1
- package/dist/esm/internal/secret_internals.js.map +1 -1
- package/dist/esm/isStrictMode.js.map +1 -1
- package/dist/esm/themeAndMode.js.map +1 -1
- package/dist/types/tsdoc-metadata.json +1 -1
- package/package.json +13 -13
package/dist/esm/Dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["brick","show","options","resolve","type","confirm","content","Promise","setTimeout","reject","alert","loadDialogService","tagName","loader","then","document","createElement","error","console","Dialog","Object","freeze"],"sources":["../../src/Dialog.ts"],"sourcesContent":["let brick: {\n resolve(options: DialogOptions): Promise<void>;\n};\n\nfunction show(options: DialogOptions): Promise<void> {\n if (brick) {\n return brick.resolve(options);\n } else {\n if (options.type === \"confirm\") {\n if (confirm(options.content)) {\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\n }, 1)\n );\n } else {\n return new Promise((resolve, reject) =>\n setTimeout(() => {\n reject();\n }, 1)\n );\n }\n } else {\n alert(options.content);\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\n }, 1000)\n );\n }\n }\n}\n\nexport function loadDialogService(\n tagName: string,\n loader: (bricks: string[]) => Promise<void>\n) {\n loader([tagName]).then(\n () => {\n brick = document.createElement(tagName) as any;\n },\n (error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Load dialog service failed:\", error);\n }\n );\n}\n\nexport interface DialogOptions {\n type?: \"success\" | \"error\" | \"warn\" | \"info\" | \"confirm\";\n title?: string | null;\n content: string;\n contentStyle?: object;\n}\n\nexport const Dialog = Object.freeze({\n show,\n});\n"],"mappings":"AAAA,IAAIA,KAEH;AAED,SAASC,IAAIA,CAACC,OAAsB,EAAiB;EACnD,IAAIF,KAAK,EAAE;IACT,OAAOA,KAAK,CAACG,OAAO,CAACD,OAAO,CAAC;EAC/B,CAAC,MAAM;IACL,IAAIA,OAAO,CAACE,IAAI,KAAK,SAAS,EAAE;MAC9B,IAAIC,OAAO,CAACH,OAAO,CAACI,OAAO,CAAC,EAAE;QAC5B,OAAO,IAAIC,OAAO,CAAEJ,OAAO,IACzBK,UAAU,CAAC,MAAM;UACfL,OAAO,
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["brick","show","options","resolve","type","confirm","content","Promise","setTimeout","reject","alert","loadDialogService","tagName","loader","then","document","createElement","error","console","Dialog","Object","freeze"],"sources":["../../src/Dialog.ts"],"sourcesContent":["let brick: {\n resolve(options: DialogOptions): Promise<void>;\n};\n\nfunction show(options: DialogOptions): Promise<void> {\n if (brick) {\n return brick.resolve(options);\n } else {\n if (options.type === \"confirm\") {\n if (confirm(options.content)) {\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\n }, 1)\n );\n } else {\n return new Promise((resolve, reject) =>\n setTimeout(() => {\n reject();\n }, 1)\n );\n }\n } else {\n alert(options.content);\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\n }, 1000)\n );\n }\n }\n}\n\nexport function loadDialogService(\n tagName: string,\n loader: (bricks: string[]) => Promise<void>\n) {\n loader([tagName]).then(\n () => {\n brick = document.createElement(tagName) as any;\n },\n (error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Load dialog service failed:\", error);\n }\n );\n}\n\nexport interface DialogOptions {\n type?: \"success\" | \"error\" | \"warn\" | \"info\" | \"confirm\";\n title?: string | null;\n content: string;\n contentStyle?: object;\n}\n\nexport const Dialog = Object.freeze({\n show,\n});\n"],"mappings":"AAAA,IAAIA,KAEH;AAED,SAASC,IAAIA,CAACC,OAAsB,EAAiB;EACnD,IAAIF,KAAK,EAAE;IACT,OAAOA,KAAK,CAACG,OAAO,CAACD,OAAO,CAAC;EAC/B,CAAC,MAAM;IACL,IAAIA,OAAO,CAACE,IAAI,KAAK,SAAS,EAAE;MAC9B,IAAIC,OAAO,CAACH,OAAO,CAACI,OAAO,CAAC,EAAE;QAC5B,OAAO,IAAIC,OAAO,CAAEJ,OAAO,IACzBK,UAAU,CAAC,MAAM;UACfL,OAAO,CAAC,CAAC;QACX,CAAC,EAAE,CAAC,CACN,CAAC;MACH,CAAC,MAAM;QACL,OAAO,IAAII,OAAO,CAAC,CAACJ,OAAO,EAAEM,MAAM,KACjCD,UAAU,CAAC,MAAM;UACfC,MAAM,CAAC,CAAC;QACV,CAAC,EAAE,CAAC,CACN,CAAC;MACH;IACF,CAAC,MAAM;MACLC,KAAK,CAACR,OAAO,CAACI,OAAO,CAAC;MACtB,OAAO,IAAIC,OAAO,CAAEJ,OAAO,IACzBK,UAAU,CAAC,MAAM;QACfL,OAAO,CAAC,CAAC;MACX,CAAC,EAAE,IAAI,CACT,CAAC;IACH;EACF;AACF;AAEA,OAAO,SAASQ,iBAAiBA,CAC/BC,OAAe,EACfC,MAA2C,EAC3C;EACAA,MAAM,CAAC,CAACD,OAAO,CAAC,CAAC,CAACE,IAAI,CACpB,MAAM;IACJd,KAAK,GAAGe,QAAQ,CAACC,aAAa,CAACJ,OAAO,CAAQ;EAChD,CAAC,EACAK,KAAc,IAAK;IAClB;IACAC,OAAO,CAACD,KAAK,CAAC,6BAA6B,EAAEA,KAAK,CAAC;EACrD,CACF,CAAC;AACH;AASA,OAAO,IAAME,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;EAClCpB;AACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notification.js","names":["brick","show","options","resolve","alert","message","loadNotificationService","tagName","loader","then","document","createElement","error","console","Notification","Object","freeze"],"sources":["../../src/Notification.ts"],"sourcesContent":["let brick: {\n resolve(options: NotificationOptions): void;\n};\n\nfunction show(options: NotificationOptions) {\n if (brick) {\n brick.resolve(options);\n } else {\n alert(options.message);\n }\n}\n\nexport function loadNotificationService(\n tagName: string,\n loader: (bricks: string[]) => Promise<void>\n) {\n loader([tagName]).then(\n () => {\n brick = document.createElement(tagName) as any;\n },\n (error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Load notification service failed:\", error);\n }\n );\n}\n\nexport interface NotificationOptions {\n type?: \"success\" | \"error\" | \"warn\" | \"info\";\n message: string;\n}\n\nexport const Notification = Object.freeze({\n show,\n});\n"],"mappings":"AAAA,IAAIA,KAEH;AAED,SAASC,IAAIA,CAACC,OAA4B,EAAE;EAC1C,IAAIF,KAAK,EAAE;IACTA,KAAK,CAACG,OAAO,CAACD,OAAO,CAAC;EACxB,CAAC,MAAM;IACLE,KAAK,CAACF,OAAO,CAACG,OAAO,CAAC;EACxB;AACF;AAEA,OAAO,SAASC,uBAAuBA,CACrCC,OAAe,EACfC,MAA2C,EAC3C;EACAA,MAAM,CAAC,CAACD,OAAO,CAAC,CAAC,CAACE,IAAI,CACpB,MAAM;IACJT,KAAK,GAAGU,QAAQ,CAACC,aAAa,CAACJ,OAAO,CAAQ;EAChD,CAAC,EACAK,KAAc,IAAK;IAClB;IACAC,OAAO,CAACD,KAAK,CAAC,mCAAmC,EAAEA,KAAK,CAAC;EAC3D,CAAC
|
|
1
|
+
{"version":3,"file":"Notification.js","names":["brick","show","options","resolve","alert","message","loadNotificationService","tagName","loader","then","document","createElement","error","console","Notification","Object","freeze"],"sources":["../../src/Notification.ts"],"sourcesContent":["let brick: {\n resolve(options: NotificationOptions): void;\n};\n\nfunction show(options: NotificationOptions) {\n if (brick) {\n brick.resolve(options);\n } else {\n alert(options.message);\n }\n}\n\nexport function loadNotificationService(\n tagName: string,\n loader: (bricks: string[]) => Promise<void>\n) {\n loader([tagName]).then(\n () => {\n brick = document.createElement(tagName) as any;\n },\n (error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Load notification service failed:\", error);\n }\n );\n}\n\nexport interface NotificationOptions {\n type?: \"success\" | \"error\" | \"warn\" | \"info\";\n message: string;\n}\n\nexport const Notification = Object.freeze({\n show,\n});\n"],"mappings":"AAAA,IAAIA,KAEH;AAED,SAASC,IAAIA,CAACC,OAA4B,EAAE;EAC1C,IAAIF,KAAK,EAAE;IACTA,KAAK,CAACG,OAAO,CAACD,OAAO,CAAC;EACxB,CAAC,MAAM;IACLE,KAAK,CAACF,OAAO,CAACG,OAAO,CAAC;EACxB;AACF;AAEA,OAAO,SAASC,uBAAuBA,CACrCC,OAAe,EACfC,MAA2C,EAC3C;EACAA,MAAM,CAAC,CAACD,OAAO,CAAC,CAAC,CAACE,IAAI,CACpB,MAAM;IACJT,KAAK,GAAGU,QAAQ,CAACC,aAAa,CAACJ,OAAO,CAAQ;EAChD,CAAC,EACAK,KAAc,IAAK;IAClB;IACAC,OAAO,CAACD,KAAK,CAAC,mCAAmC,EAAEA,KAAK,CAAC;EAC3D,CACF,CAAC;AACH;AAOA,OAAO,IAAME,YAAY,GAAGC,MAAM,CAACC,MAAM,CAAC;EACxCf;AACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoryboardFunctionRegistry.js","names":["cook","precookFunction","supply","strictCollectMemberUsageInFunction","getGeneralGlobals","StoryboardFunctionRegistryFactory","widgetId","widgetVersion","collectCoverage","arguments","length","undefined","registeredFunctions","Map","storyboardFunctions","Proxy","Object","freeze","get","target","key","getStoryboardFunction","currentApp","registerStoryboardFunctions","functions","app","clear","Array","isArray","fn","deps","hasPermissionsCheck","has","set","name","source","typescript","processed","cooked","collector","createCollector","precooked","hooks","beforeVisit","function","rules","noVar","globalVariables","attemptToVisitGlobals","isStoryboardFunction","beforeEvaluate","beforeCall","beforeBranch","updateStoryboardFunction","data","newFn","_objectSpread","checkPermissionsUsage","functionNames","checkedFunctions","Set","add","some"],"sources":["../../src/StoryboardFunctionRegistry.ts"],"sourcesContent":["import type { MicroApp, StoryboardFunction } from \"@next-core/types\";\nimport { cook, precookFunction, EstreeNode } from \"@next-core/cook\";\nimport { supply } from \"@next-core/supply\";\nimport { strictCollectMemberUsageInFunction } from \"@next-core/utils/storyboard\";\nimport { getGeneralGlobals } from \"./internal/compute/getGeneralGlobals.js\";\n\n/** @internal */\nexport type ReadonlyStoryboardFunctions = Readonly<Record<string, Function>>;\n\n/** @internal */\nexport type StoryboardFunctionPatch = Pick<\n StoryboardFunction,\n \"source\" | \"typescript\"\n>;\n\n/** @internal */\nexport interface StoryboardFunctionRegistry {\n /** A readonly proxy for accessing cooked storyboard functions. */\n storyboardFunctions: ReadonlyStoryboardFunctions;\n\n /** Register storyboard functions. */\n registerStoryboardFunctions(\n functions: StoryboardFunction[] | undefined,\n app?: PartialMicroApp\n ): void;\n\n /** Update a storyboard function during debugging. */\n updateStoryboardFunction(name: string, data: StoryboardFunctionPatch): void;\n\n checkPermissionsUsage(functionNames: string[]): boolean;\n}\n\n/** @internal */\nexport interface RuntimeStoryboardFunction {\n source: string;\n typescript?: boolean;\n processed?: boolean;\n cooked?: Function;\n deps: Set<string>;\n hasPermissionsCheck: boolean;\n}\n\n/** @internal */\nexport interface FunctionCoverageCollector {\n beforeVisit(node: EstreeNode): void;\n beforeEvaluate(node: EstreeNode): void;\n beforeCall(node: EstreeNode): void;\n beforeBranch(node: EstreeNode, branch: string): void;\n}\n\n/** @internal */\nexport interface FunctionCoverageSettings {\n createCollector(name: string): FunctionCoverageCollector;\n}\n\n/** @internal */\nexport type PartialMicroApp = Pick<MicroApp, \"id\" | \"isBuildPush\">;\n\n/** @internal */\nexport function StoryboardFunctionRegistryFactory({\n widgetId,\n widgetVersion,\n collectCoverage,\n}: {\n widgetId?: string;\n widgetVersion?: string;\n collectCoverage?: FunctionCoverageSettings;\n} = {}): StoryboardFunctionRegistry {\n const registeredFunctions = new Map<string, RuntimeStoryboardFunction>();\n\n // Use `Proxy` with a frozen target, to make a readonly function registry.\n const storyboardFunctions = new Proxy(Object.freeze({}), {\n get(target, key) {\n return getStoryboardFunction(key as string);\n },\n }) as ReadonlyStoryboardFunctions;\n\n let currentApp: PartialMicroApp | undefined;\n\n function registerStoryboardFunctions(\n functions: StoryboardFunction[],\n app?: PartialMicroApp\n ): void {\n if (app) {\n currentApp = app;\n }\n registeredFunctions.clear();\n if (Array.isArray(functions)) {\n for (const fn of functions) {\n const deps = strictCollectMemberUsageInFunction(fn, \"FN\");\n const hasPermissionsCheck = strictCollectMemberUsageInFunction(\n fn,\n \"PERMISSIONS\"\n ).has(\"check\");\n registeredFunctions.set(fn.name, {\n source: fn.source,\n typescript: fn.typescript,\n deps,\n hasPermissionsCheck,\n });\n }\n }\n }\n\n function getStoryboardFunction(name: string): Function | undefined {\n const fn = registeredFunctions.get(name);\n if (!fn) {\n return undefined;\n }\n if (fn.processed) {\n return fn.cooked;\n }\n let collector: FunctionCoverageCollector | undefined;\n if (collectCoverage) {\n collector = collectCoverage.createCollector(name);\n }\n const precooked = precookFunction(fn.source, {\n typescript: fn.typescript,\n hooks: collector && {\n beforeVisit: collector.beforeVisit,\n },\n });\n fn.cooked = cook(precooked.function, fn.source, {\n rules: {\n noVar: true,\n },\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n collectCoverage,\n widgetId,\n widgetVersion,\n app: currentApp,\n storyboardFunctions,\n isStoryboardFunction: true,\n }),\n !!collectCoverage\n ),\n hooks: collector && {\n beforeEvaluate: collector.beforeEvaluate,\n beforeCall: collector.beforeCall,\n beforeBranch: collector.beforeBranch,\n },\n }) as Function;\n fn.processed = true;\n return fn.cooked;\n }\n\n return {\n storyboardFunctions,\n registerStoryboardFunctions,\n updateStoryboardFunction(\n name: string,\n data: StoryboardFunctionPatch\n ): void {\n const newFn = {\n ...data,\n name,\n };\n const deps = strictCollectMemberUsageInFunction(newFn, \"FN\");\n const hasPermissionsCheck = strictCollectMemberUsageInFunction(\n newFn,\n \"PERMISSIONS\"\n ).has(\"check\");\n registeredFunctions.set(name, {\n source: data.source,\n typescript: data.typescript,\n deps,\n hasPermissionsCheck,\n });\n },\n /**\n * Check whether listed functions attempt to call `PERMISSIONS.check()`,\n * includes in nested `FN.*()` calls.\n */\n checkPermissionsUsage(functionNames) {\n const checkedFunctions = new Set<string>();\n const hasPermissionsCheck = (name: string): boolean => {\n if (!checkedFunctions.has(name)) {\n checkedFunctions.add(name);\n const fn = registeredFunctions.get(name);\n return (\n !!fn &&\n (fn.hasPermissionsCheck || [...fn.deps].some(hasPermissionsCheck))\n );\n }\n return false;\n };\n return functionNames.some(hasPermissionsCheck);\n },\n };\n}\n"],"mappings":";AACA,SAASA,IAAI,EAAEC,eAAe,QAAoB,iBAAiB;AACnE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,kCAAkC,QAAQ,6BAA6B;AAChF,SAASC,iBAAiB,QAAQ,yCAAyC;;AAE3E;;AAGA;;AAMA;;AAiBA;;AAUA;;AAQA;;AAKA;;AAGA;AACA,OAAO,SAASC,iCAAiCA,CAAA,EAQb;EAAA,IARc;IAChDC,QAAQ;IACRC,aAAa;IACbC;EAKF,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACJ,IAAMG,mBAAmB,GAAG,IAAIC,GAAG,
|
|
1
|
+
{"version":3,"file":"StoryboardFunctionRegistry.js","names":["cook","precookFunction","supply","strictCollectMemberUsageInFunction","getGeneralGlobals","StoryboardFunctionRegistryFactory","widgetId","widgetVersion","collectCoverage","arguments","length","undefined","registeredFunctions","Map","storyboardFunctions","Proxy","Object","freeze","get","target","key","getStoryboardFunction","currentApp","registerStoryboardFunctions","functions","app","clear","Array","isArray","fn","deps","hasPermissionsCheck","has","set","name","source","typescript","processed","cooked","collector","createCollector","precooked","hooks","beforeVisit","function","rules","noVar","globalVariables","attemptToVisitGlobals","isStoryboardFunction","beforeEvaluate","beforeCall","beforeBranch","updateStoryboardFunction","data","newFn","_objectSpread","checkPermissionsUsage","functionNames","checkedFunctions","Set","add","some"],"sources":["../../src/StoryboardFunctionRegistry.ts"],"sourcesContent":["import type { MicroApp, StoryboardFunction } from \"@next-core/types\";\nimport { cook, precookFunction, EstreeNode } from \"@next-core/cook\";\nimport { supply } from \"@next-core/supply\";\nimport { strictCollectMemberUsageInFunction } from \"@next-core/utils/storyboard\";\nimport { getGeneralGlobals } from \"./internal/compute/getGeneralGlobals.js\";\n\n/** @internal */\nexport type ReadonlyStoryboardFunctions = Readonly<Record<string, Function>>;\n\n/** @internal */\nexport type StoryboardFunctionPatch = Pick<\n StoryboardFunction,\n \"source\" | \"typescript\"\n>;\n\n/** @internal */\nexport interface StoryboardFunctionRegistry {\n /** A readonly proxy for accessing cooked storyboard functions. */\n storyboardFunctions: ReadonlyStoryboardFunctions;\n\n /** Register storyboard functions. */\n registerStoryboardFunctions(\n functions: StoryboardFunction[] | undefined,\n app?: PartialMicroApp\n ): void;\n\n /** Update a storyboard function during debugging. */\n updateStoryboardFunction(name: string, data: StoryboardFunctionPatch): void;\n\n checkPermissionsUsage(functionNames: string[]): boolean;\n}\n\n/** @internal */\nexport interface RuntimeStoryboardFunction {\n source: string;\n typescript?: boolean;\n processed?: boolean;\n cooked?: Function;\n deps: Set<string>;\n hasPermissionsCheck: boolean;\n}\n\n/** @internal */\nexport interface FunctionCoverageCollector {\n beforeVisit(node: EstreeNode): void;\n beforeEvaluate(node: EstreeNode): void;\n beforeCall(node: EstreeNode): void;\n beforeBranch(node: EstreeNode, branch: string): void;\n}\n\n/** @internal */\nexport interface FunctionCoverageSettings {\n createCollector(name: string): FunctionCoverageCollector;\n}\n\n/** @internal */\nexport type PartialMicroApp = Pick<MicroApp, \"id\" | \"isBuildPush\">;\n\n/** @internal */\nexport function StoryboardFunctionRegistryFactory({\n widgetId,\n widgetVersion,\n collectCoverage,\n}: {\n widgetId?: string;\n widgetVersion?: string;\n collectCoverage?: FunctionCoverageSettings;\n} = {}): StoryboardFunctionRegistry {\n const registeredFunctions = new Map<string, RuntimeStoryboardFunction>();\n\n // Use `Proxy` with a frozen target, to make a readonly function registry.\n const storyboardFunctions = new Proxy(Object.freeze({}), {\n get(target, key) {\n return getStoryboardFunction(key as string);\n },\n }) as ReadonlyStoryboardFunctions;\n\n let currentApp: PartialMicroApp | undefined;\n\n function registerStoryboardFunctions(\n functions: StoryboardFunction[],\n app?: PartialMicroApp\n ): void {\n if (app) {\n currentApp = app;\n }\n registeredFunctions.clear();\n if (Array.isArray(functions)) {\n for (const fn of functions) {\n const deps = strictCollectMemberUsageInFunction(fn, \"FN\");\n const hasPermissionsCheck = strictCollectMemberUsageInFunction(\n fn,\n \"PERMISSIONS\"\n ).has(\"check\");\n registeredFunctions.set(fn.name, {\n source: fn.source,\n typescript: fn.typescript,\n deps,\n hasPermissionsCheck,\n });\n }\n }\n }\n\n function getStoryboardFunction(name: string): Function | undefined {\n const fn = registeredFunctions.get(name);\n if (!fn) {\n return undefined;\n }\n if (fn.processed) {\n return fn.cooked;\n }\n let collector: FunctionCoverageCollector | undefined;\n if (collectCoverage) {\n collector = collectCoverage.createCollector(name);\n }\n const precooked = precookFunction(fn.source, {\n typescript: fn.typescript,\n hooks: collector && {\n beforeVisit: collector.beforeVisit,\n },\n });\n fn.cooked = cook(precooked.function, fn.source, {\n rules: {\n noVar: true,\n },\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n collectCoverage,\n widgetId,\n widgetVersion,\n app: currentApp,\n storyboardFunctions,\n isStoryboardFunction: true,\n }),\n !!collectCoverage\n ),\n hooks: collector && {\n beforeEvaluate: collector.beforeEvaluate,\n beforeCall: collector.beforeCall,\n beforeBranch: collector.beforeBranch,\n },\n }) as Function;\n fn.processed = true;\n return fn.cooked;\n }\n\n return {\n storyboardFunctions,\n registerStoryboardFunctions,\n updateStoryboardFunction(\n name: string,\n data: StoryboardFunctionPatch\n ): void {\n const newFn = {\n ...data,\n name,\n };\n const deps = strictCollectMemberUsageInFunction(newFn, \"FN\");\n const hasPermissionsCheck = strictCollectMemberUsageInFunction(\n newFn,\n \"PERMISSIONS\"\n ).has(\"check\");\n registeredFunctions.set(name, {\n source: data.source,\n typescript: data.typescript,\n deps,\n hasPermissionsCheck,\n });\n },\n /**\n * Check whether listed functions attempt to call `PERMISSIONS.check()`,\n * includes in nested `FN.*()` calls.\n */\n checkPermissionsUsage(functionNames) {\n const checkedFunctions = new Set<string>();\n const hasPermissionsCheck = (name: string): boolean => {\n if (!checkedFunctions.has(name)) {\n checkedFunctions.add(name);\n const fn = registeredFunctions.get(name);\n return (\n !!fn &&\n (fn.hasPermissionsCheck || [...fn.deps].some(hasPermissionsCheck))\n );\n }\n return false;\n };\n return functionNames.some(hasPermissionsCheck);\n },\n };\n}\n"],"mappings":";AACA,SAASA,IAAI,EAAEC,eAAe,QAAoB,iBAAiB;AACnE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,kCAAkC,QAAQ,6BAA6B;AAChF,SAASC,iBAAiB,QAAQ,yCAAyC;;AAE3E;;AAGA;;AAMA;;AAiBA;;AAUA;;AAQA;;AAKA;;AAGA;AACA,OAAO,SAASC,iCAAiCA,CAAA,EAQb;EAAA,IARc;IAChDC,QAAQ;IACRC,aAAa;IACbC;EAKF,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACJ,IAAMG,mBAAmB,GAAG,IAAIC,GAAG,CAAoC,CAAC;;EAExE;EACA,IAAMC,mBAAmB,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IACvDC,GAAGA,CAACC,MAAM,EAAEC,GAAG,EAAE;MACf,OAAOC,qBAAqB,CAACD,GAAa,CAAC;IAC7C;EACF,CAAC,CAAgC;EAEjC,IAAIE,UAAuC;EAE3C,SAASC,2BAA2BA,CAClCC,SAA+B,EAC/BC,GAAqB,EACf;IACN,IAAIA,GAAG,EAA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;UAC/ByB,gBAAgB,CAACE,GAAG,CAAC3B,IAAI,CAAC;UAC1B,IAAML,EAAE,GAAGjB,mBAAmB,CAACM,GAAG,CAACgB,IAAI,CAAC;UACxC,OACE,CAAC,CAACL,EAAE,KACHA,EAAE,CAACE,mBAAmB,IAAI,CAAC,GAAGF,EAAE,CAACC,IAAI,CAAC,CAACgC,IAAI,CAAC/B,mBAAmB,CAAC,CAAC;QAEtE;QACA,OAAO,KAAK;MACd,CAAC;MACD,OAAO2B,aAAa,CAACI,IAAI,CAAC/B,mBAAmB,CAAC;IAChD;EACF,CAAC;AACH"}
|
package/dist/esm/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":["hooks","authenticate","_hooks$auth","_hooks$auth$authentic","_len","arguments","length","args","Array","_key","auth","call","getAuth","_hooks$auth2","logout","_hooks$auth3","_hooks$auth3$logout","isLoggedIn","_hooks$auth4"],"sources":["../../src/auth.ts"],"sourcesContent":["// istanbul ignore file\n// Todo(steve): This file will be removed in the future.\nimport { hooks } from \"./internal/Runtime.js\";\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function authenticate(...args: unknown[]): void {\n hooks?.auth?.authenticate?.(...args);\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function getAuth() {\n return hooks?.auth?.getAuth();\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function logout() {\n return hooks?.auth?.logout?.();\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function isLoggedIn() {\n return hooks?.auth?.isLoggedIn();\n}\n"],"mappings":"AAAA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;;AAE7C;AACA,OAAO,SAASC,YAAYA,CAAA,EAA2B;EAAA,IAAAC,WAAA,EAAAC,qBAAA;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAvBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAClCT,KAAK,aAALA,KAAK,wBAAAE,WAAA,GAALF,KAAK,CAAEU,IAAI,cAAAR,WAAA,wBAAAC,qBAAA,GAAXD,WAAA,CAAaD,YAAY,cAAAE,qBAAA,uBAAzBA,qBAAA,CAAAQ,IAAA,CAAAT,WAAA,EAA4B,GAAGK,IAAI,CAAC;AACtC;;AAEA;AACA,OAAO,SAASK,OAAOA,CAAA,EAAG;EAAA,IAAAC,YAAA;EACxB,OAAOb,KAAK,aAALA,KAAK,wBAAAa,YAAA,GAALb,KAAK,CAAEU,IAAI,cAAAG,YAAA,uBAAXA,YAAA,CAAaD,OAAO,
|
|
1
|
+
{"version":3,"file":"auth.js","names":["hooks","authenticate","_hooks$auth","_hooks$auth$authentic","_len","arguments","length","args","Array","_key","auth","call","getAuth","_hooks$auth2","logout","_hooks$auth3","_hooks$auth3$logout","isLoggedIn","_hooks$auth4"],"sources":["../../src/auth.ts"],"sourcesContent":["// istanbul ignore file\n// Todo(steve): This file will be removed in the future.\nimport { hooks } from \"./internal/Runtime.js\";\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function authenticate(...args: unknown[]): void {\n hooks?.auth?.authenticate?.(...args);\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function getAuth() {\n return hooks?.auth?.getAuth();\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function logout() {\n return hooks?.auth?.logout?.();\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function isLoggedIn() {\n return hooks?.auth?.isLoggedIn();\n}\n"],"mappings":"AAAA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;;AAE7C;AACA,OAAO,SAASC,YAAYA,CAAA,EAA2B;EAAA,IAAAC,WAAA,EAAAC,qBAAA;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAvBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAClCT,KAAK,aAALA,KAAK,wBAAAE,WAAA,GAALF,KAAK,CAAEU,IAAI,cAAAR,WAAA,wBAAAC,qBAAA,GAAXD,WAAA,CAAaD,YAAY,cAAAE,qBAAA,uBAAzBA,qBAAA,CAAAQ,IAAA,CAAAT,WAAA,EAA4B,GAAGK,IAAI,CAAC;AACtC;;AAEA;AACA,OAAO,SAASK,OAAOA,CAAA,EAAG;EAAA,IAAAC,YAAA;EACxB,OAAOb,KAAK,aAALA,KAAK,wBAAAa,YAAA,GAALb,KAAK,CAAEU,IAAI,cAAAG,YAAA,uBAAXA,YAAA,CAAaD,OAAO,CAAC,CAAC;AAC/B;;AAEA;AACA,OAAO,SAASE,MAAMA,CAAA,EAAG;EAAA,IAAAC,YAAA,EAAAC,mBAAA;EACvB,OAAOhB,KAAK,aAALA,KAAK,wBAAAe,YAAA,GAALf,KAAK,CAAEU,IAAI,cAAAK,YAAA,wBAAAC,mBAAA,GAAXD,YAAA,CAAaD,MAAM,cAAAE,mBAAA,uBAAnBA,mBAAA,CAAAL,IAAA,CAAAI,YAAsB,CAAC;AAChC;;AAEA;AACA,OAAO,SAASE,UAAUA,CAAA,EAAG;EAAA,IAAAC,YAAA;EAC3B,OAAOlB,KAAK,aAALA,KAAK,wBAAAkB,YAAA,GAALlB,KAAK,CAAEU,IAAI,cAAAQ,YAAA,uBAAXA,YAAA,CAAaD,UAAU,CAAC,CAAC;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoot.js","names":["flushStableLoadBricks","renderBricks","RendererContext","DataStore","mountTree","unmountTree","httpErrorToString","applyMode","applyTheme","setMode","setTheme","RenderTag","registerStoryboardFunctions","registerAppI18n","registerCustomTemplates","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","context","functions","templates","i18n","i18nData","Error","bricks","concat","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","previousRendererContext","renderRoot","tag","ROOT","_clearI18nBundles","demoApp","id","homepage","app","demoStoryboard","meta","customTemplates","define","failed","output","Promise","all","blockingList","waitForAll","values","map","store","error","node","BRICK","type","properties","textContent","return","menuRequests","child","dispatchOnUnmount","dispose","dispatchBeforePageLoad","window","scrollTo","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport { RenderOutput, renderBricks } from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n context,\n functions,\n templates,\n i18n: i18nData,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\"),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n const previousRendererContext = rendererContext;\n rendererContext = new RendererContext(scope, { unknownBricks });\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n const demoApp = {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = demoApp;\n const demoStoryboard = {\n app: demoApp,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, demoApp);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext\n );\n\n flushStableLoadBricks();\n\n await Promise.all([\n ...output.blockingList,\n runtimeContext.ctxStore.waitForAll(),\n ...[\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ].map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";AAUA,SAASA,qBAAqB,QAAQ,mBAAmB;AACzD,SAAuBC,YAAY,QAAQ,wBAAwB;AACnE,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B,IAAIC,MAAM,EAAE;UACVZ,WAAW,CAACY,MAAM,CAAC;QACrB;QAEA,IAAIE,KAAK,KAAK,MAAM,EAAE;UACpBT,QAAQ,CAAC8B,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,OAAO,CAAC;UAC1B/B,OAAO,CAAC,SAAS,CAAC;UAElB,IAAI,CAAC2D,MAAM,EAAE;YACXlC,eAAe,CAACsD,sBAAsB,EAAE;UAC1C;UAEAhF,UAAU,EAAE;UACZD,SAAS,EAAE;QACb;QAEAH,SAAS,CAACoD,UAAU,CAAC;QAErB,IAAIrC,KAAK,KAAK,MAAM,EAAE;UACpBsE,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB;QAEA,IAAI,CAACtB,MAAM,EAAE;UACX,IAAIjD,KAAK,KAAK,MAAM,EAAE;YACpBe,eAAe,CAACyD,gBAAgB,EAAE;YAClC;UACF;;UACAzD,eAAe,CAAC0D,eAAe,EAAE;UACjC1D,eAAe,CAAC2D,wBAAwB,EAAE;UAC1C3D,eAAe,CAAC4D,qBAAqB,EAAE;QACzC;MAAC;IACH,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAI9D,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB5B,WAAW,CAACW,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACVZ,WAAW,CAACY,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAAC+E,MAAM,EAAE;QACjB;MACF;IACF;EACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"createRoot.js","names":["flushStableLoadBricks","renderBricks","RendererContext","DataStore","mountTree","unmountTree","httpErrorToString","applyMode","applyTheme","setMode","setTheme","RenderTag","registerStoryboardFunctions","registerAppI18n","registerCustomTemplates","unstable_createRoot","container","portal","_portal","scope","unknownBricks","arguments","length","undefined","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","_arguments","_asyncToGenerator","theme","context","functions","templates","i18n","i18nData","Error","bricks","concat","runtimeContext","ctxStore","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","previousRendererContext","renderRoot","tag","ROOT","_clearI18nBundles","demoApp","id","homepage","app","demoStoryboard","meta","customTemplates","define","failed","output","Promise","all","blockingList","waitForAll","values","map","store","error","node","BRICK","type","properties","textContent","return","menuRequests","child","dispatchOnUnmount","dispose","dispatchBeforePageLoad","window","scrollTo","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport { RenderOutput, renderBricks } from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { httpErrorToString } from \"./handleHttpError.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n context,\n functions,\n templates,\n i18n: i18nData,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\"),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n const previousRendererContext = rendererContext;\n rendererContext = new RendererContext(scope, { unknownBricks });\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n const demoApp = {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = demoApp;\n const demoStoryboard = {\n app: demoApp,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, demoApp);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext\n );\n\n flushStableLoadBricks();\n\n await Promise.all([\n ...output.blockingList,\n runtimeContext.ctxStore.waitForAll(),\n ...[\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ].map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n } catch (error) {\n failed = true;\n output = {\n node: {\n tag: RenderTag.BRICK,\n type: \"div\",\n properties: {\n textContent: httpErrorToString(error),\n },\n return: renderRoot,\n runtimeContext: null!,\n },\n blockingList: [],\n menuRequests: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";AAUA,SAASA,qBAAqB,QAAQ,mBAAmB;AACzD,SAAuBC,YAAY,QAAQ,wBAAwB;AACnE,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,SAAS,QAAQ,8BAA8B;AAExD,SAASC,SAAS,EAAEC,WAAW,QAAQ,qBAAqB;AAC5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B;QAEA,IAAIE,KAAK,KAAK,MAAM,EAAE;UACpBT,QAAQ,CAAC8B,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,OAAO,CAAC;UAC1B/B,OAAO,CAAC,SAAS,CAAC;UAElB,IAAI,CAAC2D,MAAM,EAAE;YACXlC,eAAe,CAACsD,sBAAsB,CAAC,CAAC;UAC1C;UAEAhF,UAAU,CAAC,CAAC;UACZD,SAAS,CAAC,CAAC;QACb;QAEAH,SAAS,CAACoD,UAAU,CAAC;QAErB,IAAIrC,KAAK,KAAK,MAAM,EAAE;UACpBsE,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB;QAEA,IAAI,CAACtB,MAAM,EAAE;UACX,IAAIjD,KAAK,KAAK,MAAM,EAAE;YACpBe,eAAe,CAACyD,gBAAgB,CAAC,CAAC;YAClC;UACF;;UACAzD,eAAe,CAAC0D,eAAe,CAAC,CAAC;UACjC1D,eAAe,CAAC2D,wBAAwB,CAAC,CAAC;UAC1C3D,eAAe,CAAC4D,qBAAqB,CAAC,CAAC;QACzC;MAAC;IACH,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAI9D,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB5B,WAAW,CAACW,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACVZ,WAAW,CAACY,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAAC+E,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPageInfo.js","names":["getBasePath","misc","getPageInfo","isInIframe","isInIframeOfSameSite","isInIframeOfNext","isInIframeOfVisualBuilder","isInIframeOfLegacyConsole","window","parent","origin","selfIsNext","parentPathname","location","pathname","parentIsNext","startsWith","Number","concat","e","Object","freeze"],"sources":["../../src/getPageInfo.ts"],"sourcesContent":["import { getBasePath } from \"./getBasePath.js\";\n\nlet misc: PageInfo;\n\n/** 运行时页面信息。*/\nexport interface PageInfo {\n /** 当前是否处于 iframe 模式。 */\n isInIframe: boolean;\n\n /** 当前是否处于同域的 iframe 模式。 */\n isInIframeOfSameSite: boolean;\n\n /** 当前是否处于新框架下的 iframe 模式。 */\n isInIframeOfNext: boolean;\n\n /** 当前是否处于 Visual Builder 预览的 iframe 模式。 */\n isInIframeOfVisualBuilder: boolean;\n\n /** 当前是否处于老 console 下的 iframe 模式。 */\n isInIframeOfLegacyConsole: boolean;\n}\n\nexport function getPageInfo(): PageInfo {\n if (!misc) {\n misc = {\n isInIframe: false,\n isInIframeOfSameSite: false,\n isInIframeOfNext: false,\n isInIframeOfVisualBuilder: false,\n isInIframeOfLegacyConsole: false,\n };\n\n if (window !== window.parent) {\n misc.isInIframe = true;\n try {\n // Handle:\n // - Previewing in visual builder by iframe.\n // - Nesting next in next.\n // - Nesting console in next.\n if (window.origin === window.parent.origin) {\n misc.isInIframeOfSameSite = true;\n const selfIsNext = getBasePath() === \"/next/\";\n const parentPathname = window.parent.location.pathname;\n const parentIsNext = parentPathname.startsWith(\"/next/\");\n misc.isInIframeOfNext =\n (Number(selfIsNext) ^ Number(parentIsNext)) === 0;\n misc.isInIframeOfVisualBuilder = parentPathname.startsWith(\n `${parentIsNext ? \"/next\" : \"\"}/visual-builder/`\n );\n misc.isInIframeOfLegacyConsole = selfIsNext && !parentIsNext;\n }\n } catch (e) {\n // do nothing\n }\n }\n\n Object.freeze(misc);\n }\n\n return misc;\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,kBAAkB;AAE9C,IAAIC,IAAc;;AAElB;;AAkBA,OAAO,SAASC,WAAWA,CAAA,EAAa;EACtC,IAAI,CAACD,IAAI,EAAE;IACTA,IAAI,GAAG;MACLE,UAAU,EAAE,KAAK;MACjBC,oBAAoB,EAAE,KAAK;MAC3BC,gBAAgB,EAAE,KAAK;MACvBC,yBAAyB,EAAE,KAAK;MAChCC,yBAAyB,EAAE;IAC7B,CAAC;IAED,IAAIC,MAAM,KAAKA,MAAM,CAACC,MAAM,EAAE;MAC5BR,IAAI,CAACE,UAAU,GAAG,IAAI;MACtB,IAAI;QACF;QACA;QACA;QACA;QACA,IAAIK,MAAM,CAACE,MAAM,KAAKF,MAAM,CAACC,MAAM,CAACC,MAAM,EAAE;UAC1CT,IAAI,CAACG,oBAAoB,GAAG,IAAI;UAChC,IAAMO,UAAU,GAAGX,WAAW,
|
|
1
|
+
{"version":3,"file":"getPageInfo.js","names":["getBasePath","misc","getPageInfo","isInIframe","isInIframeOfSameSite","isInIframeOfNext","isInIframeOfVisualBuilder","isInIframeOfLegacyConsole","window","parent","origin","selfIsNext","parentPathname","location","pathname","parentIsNext","startsWith","Number","concat","e","Object","freeze"],"sources":["../../src/getPageInfo.ts"],"sourcesContent":["import { getBasePath } from \"./getBasePath.js\";\n\nlet misc: PageInfo;\n\n/** 运行时页面信息。*/\nexport interface PageInfo {\n /** 当前是否处于 iframe 模式。 */\n isInIframe: boolean;\n\n /** 当前是否处于同域的 iframe 模式。 */\n isInIframeOfSameSite: boolean;\n\n /** 当前是否处于新框架下的 iframe 模式。 */\n isInIframeOfNext: boolean;\n\n /** 当前是否处于 Visual Builder 预览的 iframe 模式。 */\n isInIframeOfVisualBuilder: boolean;\n\n /** 当前是否处于老 console 下的 iframe 模式。 */\n isInIframeOfLegacyConsole: boolean;\n}\n\nexport function getPageInfo(): PageInfo {\n if (!misc) {\n misc = {\n isInIframe: false,\n isInIframeOfSameSite: false,\n isInIframeOfNext: false,\n isInIframeOfVisualBuilder: false,\n isInIframeOfLegacyConsole: false,\n };\n\n if (window !== window.parent) {\n misc.isInIframe = true;\n try {\n // Handle:\n // - Previewing in visual builder by iframe.\n // - Nesting next in next.\n // - Nesting console in next.\n if (window.origin === window.parent.origin) {\n misc.isInIframeOfSameSite = true;\n const selfIsNext = getBasePath() === \"/next/\";\n const parentPathname = window.parent.location.pathname;\n const parentIsNext = parentPathname.startsWith(\"/next/\");\n misc.isInIframeOfNext =\n (Number(selfIsNext) ^ Number(parentIsNext)) === 0;\n misc.isInIframeOfVisualBuilder = parentPathname.startsWith(\n `${parentIsNext ? \"/next\" : \"\"}/visual-builder/`\n );\n misc.isInIframeOfLegacyConsole = selfIsNext && !parentIsNext;\n }\n } catch (e) {\n // do nothing\n }\n }\n\n Object.freeze(misc);\n }\n\n return misc;\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,kBAAkB;AAE9C,IAAIC,IAAc;;AAElB;;AAkBA,OAAO,SAASC,WAAWA,CAAA,EAAa;EACtC,IAAI,CAACD,IAAI,EAAE;IACTA,IAAI,GAAG;MACLE,UAAU,EAAE,KAAK;MACjBC,oBAAoB,EAAE,KAAK;MAC3BC,gBAAgB,EAAE,KAAK;MACvBC,yBAAyB,EAAE,KAAK;MAChCC,yBAAyB,EAAE;IAC7B,CAAC;IAED,IAAIC,MAAM,KAAKA,MAAM,CAACC,MAAM,EAAE;MAC5BR,IAAI,CAACE,UAAU,GAAG,IAAI;MACtB,IAAI;QACF;QACA;QACA;QACA;QACA,IAAIK,MAAM,CAACE,MAAM,KAAKF,MAAM,CAACC,MAAM,CAACC,MAAM,EAAE;UAC1CT,IAAI,CAACG,oBAAoB,GAAG,IAAI;UAChC,IAAMO,UAAU,GAAGX,WAAW,CAAC,CAAC,KAAK,QAAQ;UAC7C,IAAMY,cAAc,GAAGJ,MAAM,CAACC,MAAM,CAACI,QAAQ,CAACC,QAAQ;UACtD,IAAMC,YAAY,GAAGH,cAAc,CAACI,UAAU,CAAC,QAAQ,CAAC;UACxDf,IAAI,CAACI,gBAAgB,GACnB,CAACY,MAAM,CAACN,UAAU,CAAC,GAAGM,MAAM,CAACF,YAAY,CAAC,MAAM,CAAC;UACnDd,IAAI,CAACK,yBAAyB,GAAGM,cAAc,CAACI,UAAU,IAAAE,MAAA,CACrDH,YAAY,GAAG,OAAO,GAAG,EAAE,qBAChC,CAAC;UACDd,IAAI,CAACM,yBAAyB,GAAGI,UAAU,IAAI,CAACI,YAAY;QAC9D;MACF,CAAC,CAAC,OAAOI,CAAC,EAAE;QACV;MAAA;IAEJ;IAEAC,MAAM,CAACC,MAAM,CAACpB,IAAI,CAAC;EACrB;EAEA,OAAOA,IAAI;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleHttpError.js","names":["HttpAbortError","HttpFetchError","HttpResponseError","i18n","getRuntime","getHistory","K","NS","Dialog","httpErrorToString","error","Event","target","HTMLScriptElement","src","t","concat","NETWORK_ERROR","responseJson","msg","toString","isUnauthenticatedError","response","status","code","unauthenticatedConfirming","lastErrorMessage","handleHttpError","window","NO_AUTH_GUARD","show","type","content","LOGIN_TIMEOUT_MESSAGE","then","redirectToLogin","console","message","title","REQUEST_FAILED","contentStyle","whiteSpace","undefined","ssoEnabled","getFeatureFlags","history","push","from","_objectSpread","location","state"],"sources":["../../src/handleHttpError.ts"],"sourcesContent":["import {\n HttpAbortError,\n HttpFetchError,\n HttpResponseError,\n} from \"@next-core/http\";\nimport { i18n } from \"@next-core/i18n\";\nimport { getRuntime } from \"./internal/Runtime.js\";\nimport { getHistory } from \"./history.js\";\nimport { K, NS } from \"./internal/i18n.js\";\nimport { Dialog } from \"./Dialog.js\";\n\n/**\n * 将 http 请求错误转换为可读的字符串。\n *\n * @remarks\n *\n * 将依次尝试读取返回的 JSON 格式数据的字符串类型的 `error` 和 `msg` 字段,如果没有找到则返回 `error.toString()` 的结果。\n *\n * @param error - 错误对象。\n *\n * @returns 转换为字符串的错误信息。\n */\nexport function httpErrorToString(error: unknown): string {\n if (error instanceof Event && error.target instanceof HTMLScriptElement) {\n return error.target.src;\n }\n if (error instanceof HttpFetchError) {\n return i18n.t(`${NS}:${K.NETWORK_ERROR}`);\n }\n if (error instanceof HttpResponseError) {\n if (error.responseJson) {\n if (typeof error.responseJson.error === \"string\") {\n return error.responseJson.error;\n } else if (typeof error.responseJson.msg === \"string\") {\n return error.responseJson.msg;\n }\n }\n }\n if (error == null) {\n return \"Unknown error\";\n }\n return error.toString();\n}\n\nexport function isUnauthenticatedError(error: unknown): boolean {\n return (\n error instanceof HttpResponseError &&\n error.response.status === 401 &&\n !!error.responseJson &&\n error.responseJson.code === 100003\n );\n}\n\nlet unauthenticatedConfirming = false;\n\nlet lastErrorMessage: string | undefined;\n\n/**\n * 处理 http 请求错误(使用 AntDesign 模态框弹出错误信息)。\n *\n * @param error - 错误对象。\n */\nexport function handleHttpError(error: unknown) {\n // Do nothing if aborted http requests\n if (error instanceof HttpAbortError) {\n return;\n }\n\n // Redirect to login page if not logged in.\n if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {\n if (unauthenticatedConfirming) {\n return;\n }\n unauthenticatedConfirming = true;\n Dialog.show({\n type: \"confirm\",\n content: i18n.t(`${NS}:${K.LOGIN_TIMEOUT_MESSAGE}`),\n }).then(\n () => {\n redirectToLogin();\n unauthenticatedConfirming = false;\n },\n () => {\n unauthenticatedConfirming = false;\n }\n );\n return;\n }\n\n // eslint-disable-next-line no-console\n console.error(error);\n\n const message = httpErrorToString(error);\n if (message !== lastErrorMessage) {\n lastErrorMessage = message;\n Dialog.show({\n type: \"error\",\n title: i18n.t(`${NS}:${K.REQUEST_FAILED}`),\n content: message,\n contentStyle: {\n whiteSpace: \"pre-wrap\",\n },\n }).then(() => {\n lastErrorMessage = undefined;\n });\n }\n return;\n}\n\nfunction redirectToLogin() {\n const ssoEnabled = getRuntime().getFeatureFlags()[\"sso-enabled\"];\n const history = getHistory();\n history.push(ssoEnabled ? \"/sso-auth/login\" : \"/auth/login\", {\n from: {\n ...history.location,\n state: undefined,\n },\n });\n}\n"],"mappings":";AAAA,SACEA,cAAc,EACdC,cAAc,EACdC,iBAAiB,QACZ,iBAAiB;AACxB,SAASC,IAAI,QAAQ,iBAAiB;AACtC,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,CAAC,EAAEC,EAAE,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,aAAa;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,KAAc,EAAU;EACxD,IAAIA,KAAK,YAAYC,KAAK,IAAID,KAAK,CAACE,MAAM,YAAYC,iBAAiB,EAAE;IACvE,OAAOH,KAAK,CAACE,MAAM,CAACE,GAAG;EACzB;EACA,IAAIJ,KAAK,YAAYT,cAAc,EAAE;IACnC,OAAOE,IAAI,CAACY,CAAC,IAAAC,MAAA,CAAIT,EAAE,OAAAS,MAAA,CAAIV,CAAC,CAACW,aAAa,
|
|
1
|
+
{"version":3,"file":"handleHttpError.js","names":["HttpAbortError","HttpFetchError","HttpResponseError","i18n","getRuntime","getHistory","K","NS","Dialog","httpErrorToString","error","Event","target","HTMLScriptElement","src","t","concat","NETWORK_ERROR","responseJson","msg","toString","isUnauthenticatedError","response","status","code","unauthenticatedConfirming","lastErrorMessage","handleHttpError","window","NO_AUTH_GUARD","show","type","content","LOGIN_TIMEOUT_MESSAGE","then","redirectToLogin","console","message","title","REQUEST_FAILED","contentStyle","whiteSpace","undefined","ssoEnabled","getFeatureFlags","history","push","from","_objectSpread","location","state"],"sources":["../../src/handleHttpError.ts"],"sourcesContent":["import {\n HttpAbortError,\n HttpFetchError,\n HttpResponseError,\n} from \"@next-core/http\";\nimport { i18n } from \"@next-core/i18n\";\nimport { getRuntime } from \"./internal/Runtime.js\";\nimport { getHistory } from \"./history.js\";\nimport { K, NS } from \"./internal/i18n.js\";\nimport { Dialog } from \"./Dialog.js\";\n\n/**\n * 将 http 请求错误转换为可读的字符串。\n *\n * @remarks\n *\n * 将依次尝试读取返回的 JSON 格式数据的字符串类型的 `error` 和 `msg` 字段,如果没有找到则返回 `error.toString()` 的结果。\n *\n * @param error - 错误对象。\n *\n * @returns 转换为字符串的错误信息。\n */\nexport function httpErrorToString(error: unknown): string {\n if (error instanceof Event && error.target instanceof HTMLScriptElement) {\n return error.target.src;\n }\n if (error instanceof HttpFetchError) {\n return i18n.t(`${NS}:${K.NETWORK_ERROR}`);\n }\n if (error instanceof HttpResponseError) {\n if (error.responseJson) {\n if (typeof error.responseJson.error === \"string\") {\n return error.responseJson.error;\n } else if (typeof error.responseJson.msg === \"string\") {\n return error.responseJson.msg;\n }\n }\n }\n if (error == null) {\n return \"Unknown error\";\n }\n return error.toString();\n}\n\nexport function isUnauthenticatedError(error: unknown): boolean {\n return (\n error instanceof HttpResponseError &&\n error.response.status === 401 &&\n !!error.responseJson &&\n error.responseJson.code === 100003\n );\n}\n\nlet unauthenticatedConfirming = false;\n\nlet lastErrorMessage: string | undefined;\n\n/**\n * 处理 http 请求错误(使用 AntDesign 模态框弹出错误信息)。\n *\n * @param error - 错误对象。\n */\nexport function handleHttpError(error: unknown) {\n // Do nothing if aborted http requests\n if (error instanceof HttpAbortError) {\n return;\n }\n\n // Redirect to login page if not logged in.\n if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {\n if (unauthenticatedConfirming) {\n return;\n }\n unauthenticatedConfirming = true;\n Dialog.show({\n type: \"confirm\",\n content: i18n.t(`${NS}:${K.LOGIN_TIMEOUT_MESSAGE}`),\n }).then(\n () => {\n redirectToLogin();\n unauthenticatedConfirming = false;\n },\n () => {\n unauthenticatedConfirming = false;\n }\n );\n return;\n }\n\n // eslint-disable-next-line no-console\n console.error(error);\n\n const message = httpErrorToString(error);\n if (message !== lastErrorMessage) {\n lastErrorMessage = message;\n Dialog.show({\n type: \"error\",\n title: i18n.t(`${NS}:${K.REQUEST_FAILED}`),\n content: message,\n contentStyle: {\n whiteSpace: \"pre-wrap\",\n },\n }).then(() => {\n lastErrorMessage = undefined;\n });\n }\n return;\n}\n\nfunction redirectToLogin() {\n const ssoEnabled = getRuntime().getFeatureFlags()[\"sso-enabled\"];\n const history = getHistory();\n history.push(ssoEnabled ? \"/sso-auth/login\" : \"/auth/login\", {\n from: {\n ...history.location,\n state: undefined,\n },\n });\n}\n"],"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AAS;IAC9B,CAAC,CAAC;EACJ;EACA;AACF;AAEA,SAASP,eAAeA,CAAA,EAAG;EACzB,IAAMQ,UAAU,GAAGvC,UAAU,CAAC,CAAC,CAACwC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC;EAChE,IAAMC,OAAO,GAAGxC,UAAU,CAAC,CAAC;EAC5BwC,OAAO,CAACC,IAAI,CAACH,UAAU,GAAG,iBAAiB,GAAG,aAAa,EAAE;IAC3DI,IAAI,EAAAC,aAAA,CAAAA,aAAA,KACCH,OAAO,CAACI,QAAQ;MACnBC,KAAK,EAAER;IAAS;EAEpB,CAAC,CAAC;AACJ"}
|
package/dist/esm/history.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","names":["createBrowserHistory","getBasePath","getUserConfirmation","historyExtended","history","createHistory","browserHistory","basename","replace","Object","assign","getHistory"],"sources":["../../src/history.ts"],"sourcesContent":["import { History, Location, createBrowserHistory } from \"history\";\nimport { getBasePath } from \"./getBasePath.js\";\nimport {\n type ExtendedHistory,\n getUserConfirmation,\n historyExtended,\n NextHistoryState,\n} from \"./internal/historyExtended.js\";\n\nexport type NextHistory = History<NextHistoryState> & ExtendedHistory;\n\nlet history: NextHistory;\n\nexport function createHistory(): NextHistory {\n if (!history) {\n // https://github.com/remix-run/history/issues/810\n const browserHistory = createBrowserHistory<NextHistoryState>({\n basename: getBasePath().replace(/\\/$/, \"\"),\n getUserConfirmation,\n });\n Object.assign(browserHistory, historyExtended(browserHistory));\n history = browserHistory as NextHistory;\n }\n return history;\n}\n\nexport function getHistory(): NextHistory {\n return history;\n}\n\nexport type NextLocation = Location<NextHistoryState>;\n\nexport type { NextHistoryState };\n"],"mappings":"AAAA,SAA4BA,oBAAoB,QAAQ,SAAS;AACjE,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAEEC,mBAAmB,EACnBC,eAAe,QAEV,+BAA+B;AAItC,IAAIC,OAAoB;AAExB,OAAO,SAASC,aAAaA,CAAA,EAAgB;EAC3C,IAAI,CAACD,OAAO,EAAE;IACZ;IACA,IAAME,cAAc,GAAGN,oBAAoB,CAAmB;MAC5DO,QAAQ,EAAEN,WAAW,
|
|
1
|
+
{"version":3,"file":"history.js","names":["createBrowserHistory","getBasePath","getUserConfirmation","historyExtended","history","createHistory","browserHistory","basename","replace","Object","assign","getHistory"],"sources":["../../src/history.ts"],"sourcesContent":["import { History, Location, createBrowserHistory } from \"history\";\nimport { getBasePath } from \"./getBasePath.js\";\nimport {\n type ExtendedHistory,\n getUserConfirmation,\n historyExtended,\n NextHistoryState,\n} from \"./internal/historyExtended.js\";\n\nexport type NextHistory = History<NextHistoryState> & ExtendedHistory;\n\nlet history: NextHistory;\n\nexport function createHistory(): NextHistory {\n if (!history) {\n // https://github.com/remix-run/history/issues/810\n const browserHistory = createBrowserHistory<NextHistoryState>({\n basename: getBasePath().replace(/\\/$/, \"\"),\n getUserConfirmation,\n });\n Object.assign(browserHistory, historyExtended(browserHistory));\n history = browserHistory as NextHistory;\n }\n return history;\n}\n\nexport function getHistory(): NextHistory {\n return history;\n}\n\nexport type NextLocation = Location<NextHistoryState>;\n\nexport type { NextHistoryState };\n"],"mappings":"AAAA,SAA4BA,oBAAoB,QAAQ,SAAS;AACjE,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAEEC,mBAAmB,EACnBC,eAAe,QAEV,+BAA+B;AAItC,IAAIC,OAAoB;AAExB,OAAO,SAASC,aAAaA,CAAA,EAAgB;EAC3C,IAAI,CAACD,OAAO,EAAE;IACZ;IACA,IAAME,cAAc,GAAGN,oBAAoB,CAAmB;MAC5DO,QAAQ,EAAEN,WAAW,CAAC,CAAC,CAACO,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;MAC1CN;IACF,CAAC,CAAC;IACFO,MAAM,CAACC,MAAM,CAACJ,cAAc,EAAEH,eAAe,CAACG,cAAc,CAAC,CAAC;IAC9DF,OAAO,GAAGE,cAA6B;EACzC;EACA,OAAOF,OAAO;AAChB;AAEA,OAAO,SAASO,UAAUA,CAAA,EAAgB;EACxC,OAAOP,OAAO;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindTemplateProxy.js","names":["getTplStateStore","bindTemplateProxy","brick","_tplHostMetadata$prox","ref","runtimeContext","element","tplStateStoreId","hostBrick","tplHostMetadata","internalBricksByRef","set","events","proxy","_loop","from","to","_to$refEvent","_ref","_ref$$$proxyListeners","listener","e","bubbles","stopPropagation","dispatchEvent","CustomEvent","detail","cancelable","composed","eventType","refEvent","addEventListener","$$proxyListeners","push","Object","entries","unbindTemplateProxy","delete","type","fn","_$$proxyListeners","removeEventListener"],"sources":["../../../../src/internal/CustomTemplates/bindTemplateProxy.ts"],"sourcesContent":["import type { RuntimeBrick } from \"../interfaces.js\";\nimport { getTplStateStore } from \"./utils.js\";\n\nexport function bindTemplateProxy(brick: RuntimeBrick) {\n const { ref, runtimeContext, element } = brick;\n\n // Error recovering brick may have no runtimeContext.\n if (!ref || !runtimeContext.tplStateStoreId) {\n return;\n }\n\n const { hostBrick } = getTplStateStore(runtimeContext, \"bindTemplateProxy\");\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const tplHostMetadata = hostBrick!.tplHostMetadata!;\n\n tplHostMetadata.internalBricksByRef.set(ref, brick);\n\n const events = tplHostMetadata.proxy?.events;\n if (events) {\n for (const [from, to] of Object.entries(events)) {\n if (to.ref === ref) {\n const listener = (e: Event) => {\n if (e.bubbles) {\n e.stopPropagation();\n }\n hostBrick!.element!.dispatchEvent(\n new CustomEvent(from, {\n detail: (e as CustomEvent).detail,\n bubbles: e.bubbles,\n cancelable: e.cancelable,\n composed: e.composed,\n })\n );\n };\n const eventType = to.refEvent ?? from;\n element!.addEventListener(eventType, listener);\n element!.$$proxyListeners ??= [];\n element!.$$proxyListeners.push([eventType, listener]);\n }\n }\n }\n}\n\nexport function unbindTemplateProxy(brick: RuntimeBrick) {\n const { ref, runtimeContext, element } = brick;\n\n if (!runtimeContext.tplStateStoreId || !ref) {\n return;\n }\n\n const { hostBrick } = getTplStateStore(runtimeContext, \"unbindTemplateProxy\");\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const tplHostMetadata = hostBrick!.tplHostMetadata!;\n\n tplHostMetadata.internalBricksByRef.delete(ref);\n\n for (const [type, fn] of element!.$$proxyListeners ?? []) {\n element!.removeEventListener(type, fn);\n }\n delete element!.$$proxyListeners;\n}\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,YAAY;AAE7C,OAAO,SAASC,iBAAiBA,CAACC,KAAmB,EAAE;EAAA,IAAAC,qBAAA;EACrD,IAAM;IAAEC,GAAG;IAAEC,cAAc;IAAEC;EAAQ,CAAC,GAAGJ,KAAK;;EAE9C;EACA,IAAI,CAACE,GAAG,IAAI,CAACC,cAAc,CAACE,eAAe,EAAE;IAC3C;EACF;EAEA,IAAM;IAAEC;EAAU,CAAC,GAAGR,gBAAgB,CAACK,cAAc,EAAE,mBAAmB,CAAC;EAC3E;EACA,IAAMI,eAAe,GAAGD,SAAS,CAAEC,eAAgB;EAEnDA,eAAe,CAACC,mBAAmB,CAACC,GAAG,CAACP,GAAG,EAAEF,KAAK,CAAC;EAEnD,IAAMU,MAAM,IAAAT,qBAAA,GAAGM,eAAe,CAACI,KAAK,cAAAV,qBAAA,uBAArBA,qBAAA,CAAuBS,MAAM;EAC5C,IAAIA,MAAM,EAAE;IAAA,IAAAE,KAAA,YAAAA,CAAAC,IAAA,EACuC;MAC/C,IAAIC,EAAE,CAACZ,GAAG,KAAKA,GAAG,EAAE;QAAA,IAAAa,YAAA,EAAAC,IAAA,EAAAC,qBAAA;QAClB,IAAMC,QAAQ,GAAIC,CAAQ,IAAK;UAC7B,IAAIA,CAAC,CAACC,OAAO,EAAE;YACbD,CAAC,CAACE,eAAe,
|
|
1
|
+
{"version":3,"file":"bindTemplateProxy.js","names":["getTplStateStore","bindTemplateProxy","brick","_tplHostMetadata$prox","ref","runtimeContext","element","tplStateStoreId","hostBrick","tplHostMetadata","internalBricksByRef","set","events","proxy","_loop","from","to","_to$refEvent","_ref","_ref$$$proxyListeners","listener","e","bubbles","stopPropagation","dispatchEvent","CustomEvent","detail","cancelable","composed","eventType","refEvent","addEventListener","$$proxyListeners","push","Object","entries","unbindTemplateProxy","delete","type","fn","_$$proxyListeners","removeEventListener"],"sources":["../../../../src/internal/CustomTemplates/bindTemplateProxy.ts"],"sourcesContent":["import type { RuntimeBrick } from \"../interfaces.js\";\nimport { getTplStateStore } from \"./utils.js\";\n\nexport function bindTemplateProxy(brick: RuntimeBrick) {\n const { ref, runtimeContext, element } = brick;\n\n // Error recovering brick may have no runtimeContext.\n if (!ref || !runtimeContext.tplStateStoreId) {\n return;\n }\n\n const { hostBrick } = getTplStateStore(runtimeContext, \"bindTemplateProxy\");\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const tplHostMetadata = hostBrick!.tplHostMetadata!;\n\n tplHostMetadata.internalBricksByRef.set(ref, brick);\n\n const events = tplHostMetadata.proxy?.events;\n if (events) {\n for (const [from, to] of Object.entries(events)) {\n if (to.ref === ref) {\n const listener = (e: Event) => {\n if (e.bubbles) {\n e.stopPropagation();\n }\n hostBrick!.element!.dispatchEvent(\n new CustomEvent(from, {\n detail: (e as CustomEvent).detail,\n bubbles: e.bubbles,\n cancelable: e.cancelable,\n composed: e.composed,\n })\n );\n };\n const eventType = to.refEvent ?? from;\n element!.addEventListener(eventType, listener);\n element!.$$proxyListeners ??= [];\n element!.$$proxyListeners.push([eventType, listener]);\n }\n }\n }\n}\n\nexport function unbindTemplateProxy(brick: RuntimeBrick) {\n const { ref, runtimeContext, element } = brick;\n\n if (!runtimeContext.tplStateStoreId || !ref) {\n return;\n }\n\n const { hostBrick } = getTplStateStore(runtimeContext, \"unbindTemplateProxy\");\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const tplHostMetadata = hostBrick!.tplHostMetadata!;\n\n tplHostMetadata.internalBricksByRef.delete(ref);\n\n for (const [type, fn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names":["symbolForAsyncComputedPropsFromHost","Symbol","for","symbolForTplStateStoreId","symbolForTPlExternalForEachItem"],"sources":["../../../../src/internal/CustomTemplates/constants.ts"],"sourcesContent":["import type { BrickConf } from \"@next-core/types\";\nimport type { AsyncProperties } 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]?: AsyncProperties;\n [symbolForTplStateStoreId]?: string;\n [symbolForTPlExternalForEachItem]?: unknown;\n}\n"],"mappings":"AAGA,OAAO,IAAMA,mCAAmC,GAAGC,MAAM,CAACC,GAAG,CAC3D,
|
|
1
|
+
{"version":3,"file":"constants.js","names":["symbolForAsyncComputedPropsFromHost","Symbol","for","symbolForTplStateStoreId","symbolForTPlExternalForEachItem"],"sources":["../../../../src/internal/CustomTemplates/constants.ts"],"sourcesContent":["import type { BrickConf } from \"@next-core/types\";\nimport type { AsyncProperties } 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]?: AsyncProperties;\n [symbolForTplStateStoreId]?: string;\n [symbolForTPlExternalForEachItem]?: unknown;\n}\n"],"mappings":"AAGA,OAAO,IAAMA,mCAAmC,GAAGC,MAAM,CAACC,GAAG,CAC3D,gCACF,CAAC;AACD,OAAO,IAAMC,wBAAwB,GAAGF,MAAM,CAACC,GAAG,CAAC,kBAAkB,CAAC;AACtE,OAAO,IAAME,+BAA+B,GAAGH,MAAM,CAACC,GAAG,CACvD,yBACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandCustomTemplate.js","names":["uniqueId","customTemplates","DataStore","setupTemplateProxy","setupUseBrickInTemplate","childrenToSlots","hooks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostProperties","_hooks$flowApi","tplStateStoreId","runtimeContext","_objectSpread","forEachItem","formStateStoreId","tplStateStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","get","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","_objectWithoutProperties","_excluded","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","type","map","item","expandBrickInTemplate","brickConfInTemplate","if","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","_excluded2","transpiledSlots","fromEntries","_ref","_slotConf$bricks","slotName","slotConf"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./constants.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncProperties,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostProperties: AsyncProperties\n): T {\n const tplStateStoreId = uniqueId(\"tpl-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n tplStateStoreId,\n };\n\n // There is a boundary for `forEachItem` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\"STATE\", hostBrick);\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostProperties);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostProperties,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.map((item) => expandBrickInTemplate(item, hostContext)),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConfInTemplate,\n hostContext: TemplateHostContext\n): RuntimeBrickConfWithTplSymbols {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n const slots: SlotsConfOfBricks = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(hostContext, restBrickConfInTemplate.ref, slots),\n };\n}\n"],"mappings":";;;;AAOA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;AAEhD,SAASC,kBAAkB,QAAQ,yBAAyB;AAO5D,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,KAAK,QAAQ,eAAe;AAErC,OAAO,SAASC,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,mBAAoC,EACjC;EAAA,IAAAC,cAAA;EACH,IAAMC,eAAe,GAAGb,QAAQ,CAAC,YAAY,CAAC;EAC9C,IAAMc,cAAc,GAAAC,aAAA,CAAAA,aAAA,KACfL,SAAS,CAACI,cAAc;IAC3BD;EAAe,EAChB;;EAED;EACA,OAAOC,cAAc,CAACE,WAAW;EACjC,OAAOF,cAAc,CAACG,gBAAgB;EAEtC,IAAMC,aAAa,GAAG,IAAIhB,SAAS,CAAC,OAAO,EAAEQ,SAAS,CAAC;EACvDI,cAAc,CAACK,gBAAgB,CAACC,GAAG,CAACP,eAAe,EAAEK,aAAa,CAAC;EACnE,IAAIJ,cAAc,CAACO,kBAAkB,EAAE;IACrCP,cAAc,CAACO,kBAAkB,CAACC,IAAI,CAACJ,aAAa,CAAC;EACvD;EAEA,IAAM;IAAEK,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAU,CAAC,GAAGzB,eAAe,CAAC0B,GAAG,CAACnB,UAAU,CAAE;EAC5EF,KAAK,aAALA,KAAK,wBAAAM,cAAA,GAALN,KAAK,CAAEsB,OAAO,cAAAhB,cAAA,uBAAdA,cAAA,CAAgBiB,qBAAqB,CAACH,SAAS,CAAC;EAChDR,aAAa,CAACY,MAAM,CAACL,KAAK,EAAEX,cAAc,EAAEH,mBAAmB,CAAC;EAEhE,IAAM;MACJoB,KAAK,EAAEC,qBAAqB;MAC5BC,QAAQ,EAAEC;IAEZ,CAAC,GAAGzB,SAAS;IADR0B,aAAa,GAAAC,wBAAA,CACd3B,SAAS,EAAA4B,SAAA;EAEb,IAAMC,YAAY,GAAAvB,aAAA,CAAAA,aAAA,KACboB,aAAa;IAChBI,KAAK,EAAE/B;EAAU,EACb;EAENE,SAAS,CAAC8B,eAAe,GAAG;IAC1BC,mBAAmB,EAAE,IAAIC,GAAG,
|
|
1
|
+
{"version":3,"file":"expandCustomTemplate.js","names":["uniqueId","customTemplates","DataStore","setupTemplateProxy","setupUseBrickInTemplate","childrenToSlots","hooks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostProperties","_hooks$flowApi","tplStateStoreId","runtimeContext","_objectSpread","forEachItem","formStateStoreId","tplStateStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","get","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","_objectWithoutProperties","_excluded","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","type","map","item","expandBrickInTemplate","brickConfInTemplate","if","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","_excluded2","transpiledSlots","fromEntries","_ref","_slotConf$bricks","slotName","slotConf"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./constants.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncProperties,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostProperties: AsyncProperties\n): T {\n const tplStateStoreId = uniqueId(\"tpl-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n tplStateStoreId,\n };\n\n // There is a boundary for `forEachItem` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\"STATE\", hostBrick);\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostProperties);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostProperties,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.map((item) => expandBrickInTemplate(item, hostContext)),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConfInTemplate,\n hostContext: TemplateHostContext\n): RuntimeBrickConfWithTplSymbols {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n const slots: SlotsConfOfBricks = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(hostContext, restBrickConfInTemplate.ref, slots),\n };\n}\n"],"mappings":";;;;AAOA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;AAEhD,SAASC,kBAAkB,QAAQ,yBAAyB;AAO5D,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,KAAK,QAAQ,eAAe;AAErC,OAAO,SAASC,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,mBAAoC,EACjC;EAAA,IAAAC,cAAA;EACH,IAAMC,eAAe,GAAGb,QAAQ,CAAC,YAAY,CAAC;EAC9C,IAAMc,cAAc,GAAAC,aAAA,CAAAA,aAAA,KACfL,SAAS,CAACI,cAAc;IAC3BD;EAAe,EAChB;;EAED;EACA,OAAOC,cAAc,CAACE,WAAW;EACjC,OAAOF,cAAc,CAACG,gBAAgB;EAEtC,IAAMC,aAAa,GAAG,IAAIhB,SAAS,CAAC,OAAO,EAAEQ,SAAS,CAAC;EACvDI,cAAc,CAACK,gBAAgB,CAACC,GAAG,CAACP,eAAe,EAAEK,aAAa,CAAC;EACnE,IAAIJ,cAAc,CAACO,kBAAkB,EAAE;IACrCP,cAAc,CAACO,kBAAkB,CAACC,IAAI,CAACJ,aAAa,CAAC;EACv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I,uBAAuB,GAAAzB,wBAAA,CACxBqB,mBAAmB,EAAAK,UAAA;EAEvB,IAAMC,eAAe,GAAG1D,eAAe,CACrCuD,kBAAkB,EAClBD,eACF,CAAoC;EAEpC,IAAM5B,KAAwB,GAAGgB,MAAM,CAACiB,WAAW,CACjDjB,MAAM,CAACC,OAAO,CAACe,eAAe,aAAfA,eAAe,cAAfA,eAAe,GAAI,CAAC,CAAC,CAAC,CAACT,GAAG,CAACW,IAAA;IAAA,IAAAC,gBAAA;IAAA,IAAC,CAACC,QAAQ,EAAEC,QAAQ,CAAC,GAAAH,IAAA;IAAA,OAAK,CAClEE,QAAQ,EACR;MACEd,IAAI,EAAE,QAAQ;MACd9B,MAAM,EAAE,EAAA2C,gBAAA,GAACE,QAAQ,CAAC7C,MAAM,cAAA2C,gBAAA,cAAAA,gBAAA,GAAI,EAAE,EAAEZ,GAAG,CAAEC,IAAI,IACvCC,qBAAqB,CAACD,IAAI,EAAEJ,WAAW,CACzC;IACF,CAAC,CACF;EAAA,EACH,CAAC;EAED,OAAApC,aAAA,CAAAA,aAAA,KACK8C,uBAAuB;IAC1BjB,UAAU,EAAExC,uBAAuB,CAACwC,UAAU,EAAEO,WAAW,CAAC;IAC5DpB;EAAK,GACF5B,kBAAkB,CAACgD,WAAW,EAAEU,uBAAuB,CAACX,GAAG,EAAEnB,KAAK,CAAC;AAE1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupTemplateProxy.js","names":["hasOwnProperty","clamp","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachItem","symbolForTplStateStoreId","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostProperties","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","hostProps","props","from","to","propValue","undefined","refProperty","then","slotProxies","quasisMap","Map","_externalSlots$from$b","_externalSlots$from","_to$refSlot","_to$refPosition","insertBricks","bricks","length","refToSlot","refSlot","expandableSlot","size","i","push","set","refPosition","runtimeContext","setupTemplateExternalBricks","forEachItem","_loop","slotName","type","slotConf","quasis","flatMap","index","concat","entries","map","brick","_brick$slots","_objectSpread","Object","fromEntries","_ref","_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 { AsyncProperties, TemplateHostContext } 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: AsyncProperties | undefined;\n\n if (ref && reversedProxies) {\n const propertyProxies = reversedProxies.properties.get(ref);\n if (propertyProxies) {\n const getComputedProps = (hostProps: Record<string, unknown>) => {\n const props: Record<string, unknown> = {};\n for (const { from, to } of propertyProxies) {\n const propValue = hostProps[from];\n if (propValue !== undefined && to.refProperty) {\n props[to.refProperty] = propValue;\n }\n }\n return props;\n };\n\n asyncComputedProps = (asyncHostProperties as AsyncProperties).then(\n getComputedProps\n );\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,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,QAAQ,QAAQ;AAC9B,SACEC,mCAAmC,EACnCC,+BAA+B,EAC/BC,wBAAwB,QACnB,gBAAgB;AAGvB,OAAO,SAASC,kBAAkBA,CAChCC,WAAgC,EAChCC,GAAuB,EACvBC,KAAwB,EACxB;EACA,IAAM;IACJC,eAAe;IACfC,mBAAmB;IACnBC,aAAa;IACbC,eAAe;IACfC;EACF,CAAC,GAAGP,WAAW;EAEf,IAAIQ,kBAA+C;EAEnD,IAAIP,GAAG,IAAIE,eAAe,EAAE;IAC1B,IAAMM,eAAe,GAAGN,eAAe,CAACO,UAAU,CAACC,GAAG,CAACV,GAAG,CAAC;IAC3D,IAAIQ,eAAe,EAAE;MACnB,IAAMG,gBAAgB,GAAIC,SAAkC,IAAK;QAC/D,IAAMC,KAA8B,GAAG,CAAC,CAAC;QACzC,KAAK,IAAM;UAAEC,IAAI;UAAEC;QAAG,CAAC,IAAIP,eAAe,EAAE;UAC1C,IAAMQ,SAAS,GAAGJ,SAAS,CAACE,IAAI,CAAC;UACjC,IAAIE,SAAS,KAAKC,SAAS,IAAIF,EAAE,CAACG,WAAW,EAAE;YAC7CL,KAAK,CAACE,EAAE,CAACG,WAAW,CAAC,GAAGF,SAAS;UACnC;QACF;QACA,OAAOH,KAAK;MACd,CAAC;MAEDN,kBAAkB,GAAIJ,mBAAmB,CAAqBgB,IAAI,CAChER,
|
|
1
|
+
{"version":3,"file":"setupTemplateProxy.js","names":["hasOwnProperty","clamp","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachItem","symbolForTplStateStoreId","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostProperties","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","hostProps","props","from","to","propValue","undefined","refProperty","then","slotProxies","quasisMap","Map","_externalSlots$from$b","_externalSlots$from","_to$refSlot","_to$refPosition","insertBricks","bricks","length","refToSlot","refSlot","expandableSlot","size","i","push","set","refPosition","runtimeContext","setupTemplateExternalBricks","forEachItem","_loop","slotName","type","slotConf","quasis","flatMap","index","concat","entries","map","brick","_brick$slots","_objectSpread","Object","fromEntries","_ref","_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 { AsyncProperties, TemplateHostContext } 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: AsyncProperties | undefined;\n\n if (ref && reversedProxies) {\n const propertyProxies = reversedProxies.properties.get(ref);\n if (propertyProxies) {\n const getComputedProps = (hostProps: Record<string, unknown>) => {\n const props: Record<string, unknown> = {};\n for (const { from, to } of propertyProxies) {\n const propValue = hostProps[from];\n if (propValue !== undefined && to.refProperty) {\n props[to.refProperty] = propValue;\n }\n }\n return props;\n };\n\n asyncComputedProps = (asyncHostProperties as AsyncProperties).then(\n getComputedProps\n );\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,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,QAAQ,QAAQ;AAC9B,SACEC,mCAAmC,EACnCC,+BAA+B,EAC/BC,wBAAwB,QACnB,gBAAgB;AAGvB,OAAO,SAASC,kBAAkBA,CAChCC,WAAgC,EAChCC,GAAuB,EACvBC,KAAwB,EACxB;EACA,IAAM;IACJC,eAAe;IACfC,mBAAmB;IACnBC,aAAa;IACbC,eAAe;IACfC;EACF,CAAC,GAAGP,WAAW;EAEf,IAAIQ,kBAA+C;EAEnD,IAAIP,GAAG,IAAIE,eAAe,EAAE;IAC1B,IAAMM,eAAe,GAAGN,eAAe,CAACO,UAAU,CAACC,GAAG,CAACV,GAAG,CAAC;IAC3D,IAAIQ,eAAe,EAAE;MACnB,IAAMG,gBAAgB,GAAIC,SAAkC,IAAK;QAC/D,IAAMC,KAA8B,GAAG,CAAC,CAAC;QACzC,KAAK,IAAM;UAAEC,IAAI;UAAEC;QAAG,CAAC,IAAIP,eAAe,EAAE;UAC1C,IAAMQ,SAAS,GAAGJ,SAAS,CAACE,IAAI,CAAC;UACjC,IAAIE,SAAS,KAAKC,SAAS,IAAIF,EAAE,CAACG,WAAW,EAAE;YAC7CL,KAAK,CAACE,EAAE,CAACG,WAAW,CAAC,GAAGF,SAAS;UACnC;QACF;QACA,OAAOH,KAAK;MACd,CAAC;MAEDN,kBAAkB,GAAIJ,mBAAmB,CAAqBgB,IAAI,CAChER,gBACF,CAAC;IACH;IAEA,IAAMS,WAAW,GAAGlB,eAAe,CAACD,KAAK,CAACS,GAAG,CAACV,GAAG,CAAC;IAClD,IAAIoB,WAAW,IAAIhB,aAAa,EAAE;MAChC;MACA;MACA;MACA,IAAMiB,SAA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AAW;MAC9CvC,KAAK,EAAEqD,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACL,OAAO,EAAAG,YAAA,GAACD,KAAK,CAAClD,KAAK,cAAAmD,YAAA,cAAAA,YAAA,GAAI,CAAC,CAAC,CAAC,CAACF,GAAG,CAACM,IAAA;QAAA,IAAAC,gBAAA;QAAA,IAAC,CAACf,QAAQ,EAAEE,QAAQ,CAAC,GAAAY,IAAA;QAAA,OAAK,CAC9Dd,QAAQ,EACRE,QAAQ,CAACD,IAAI,KAAK,QAAQ,GACtB;UACEA,IAAI,EAAE,QAAQ;UACde,MAAM,EAAEC,2BAA2B,CAACf,QAAQ,CAACc,MAAM,EAAElB,WAAW;QAClE,CAAC,GACD;UACEG,IAAI,EAAE,QAAQ;UACdf,MAAM,EAAEW,2BAA2B,EAAAkB,gBAAA,GACjCb,QAAQ,CAAChB,MAAM,cAAA6B,gBAAA,cAAAA,gBAAA,GAAI,EAAE,EACrBjB,WACF;QACF,CAAC,CACN;MAAA,EACH;IAAC;EAAA,CACD,CAAC;AACL;AAEA,SAASmB,2BAA2BA,CAClCD,MAAmB,EACnBlB,WAAoB,EACP;EACb,OAAOkB,MAAM,CAACR,GAAG,CAAEU,KAAK,IACtBA,KAAK,CAACjB,IAAI,IAAIiB,KAAK,CAACjB,IAAI,KAAK,QAAQ,GACjCiB,KAAK,GAAAP,aAAA,CAAAA,aAAA,KAEAO,KAAK;IACRhC,MAAM,EAAEW,2BAA2B,CAACqB,KAAK,CAAChC,MAAM,EAAEY,WAAW;EAAC,EAEtE,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupUseBrickInTemplate.js","names":["isObject","setupTemplateProxy","childrenToSlots","setupUseBrickInTemplate","props","hostContext","walk","Array","isArray","map","Object","fromEntries","entries","_ref","key","value","setup","concat","getOwnPropertySymbols","k","item","properties","slots","originalSlots","children","restConf","_objectWithoutProperties","_excluded","transpiledSlots","_ref2","_slotConf$bricks","slotName","slotConf","type","bricks","_objectSpread","ref"],"sources":["../../../../src/internal/CustomTemplates/setupUseBrickInTemplate.ts"],"sourcesContent":["import type { UseBrickSlotsConf, UseSingleBrickConf } from \"@next-core/types\";\nimport { isObject } from \"@next-core/utils/general\";\nimport type { TemplateHostContext } from \"../interfaces.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function setupUseBrickInTemplate<T>(\n props: T,\n hostContext: TemplateHostContext\n): T {\n function walk<P>(props: P): P {\n if (!isObject(props)) {\n return props;\n }\n\n if (Array.isArray(props)) {\n return props.map(walk) as P;\n }\n\n return Object.fromEntries(\n Object.entries(props)\n .map(([key, value]) =>\n isObject(value) && key === \"useBrick\"\n ? Array.isArray(value)\n ? [key, value.map(setup)]\n : [key, setup(value as UseSingleBrickConf)]\n : [key, walk(value)]\n )\n .concat(\n Object.getOwnPropertySymbols(props).map((k) => [\n k,\n (props as Record<string | symbol, unknown>)[k],\n ])\n )\n ) as P;\n }\n\n function setup(item: UseSingleBrickConf): UseSingleBrickConf {\n const { properties, slots: originalSlots, children, ...restConf } = item;\n\n const transpiledSlots = childrenToSlots(children, originalSlots) as\n | UseBrickSlotsConf\n | undefined;\n\n const slots = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map(setup),\n },\n ])\n ) as UseBrickSlotsConf;\n\n return {\n ...restConf,\n properties: walk(properties),\n slots,\n ...setupTemplateProxy(hostContext, restConf.ref, slots),\n };\n }\n\n return walk(props);\n}\n"],"mappings":";;;AACA,SAASA,QAAQ,QAAQ,0BAA0B;AAEnD,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,eAAe,QAAQ,gBAAgB;AAEhD,OAAO,SAASC,uBAAuBA,CACrCC,KAAQ,EACRC,WAAgC,EAC7B;EACH,SAASC,IAAIA,CAAIF,KAAQ,EAAK;IAC5B,IAAI,CAACJ,QAAQ,CAACI,KAAK,CAAC,EAAE;MACpB,OAAOA,KAAK;IACd;IAEA,IAAIG,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE;MACxB,OAAOA,KAAK,CAACK,GAAG,CAACH,IAAI,CAAC;IACxB;IAEA,OAAOI,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACR,KAAK,CAAC,CAClBK,GAAG,CAACI,IAAA;MAAA,IAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;MAAA,OAChBb,QAAQ,CAACe,KAAK,CAAC,IAAID,GAAG,KAAK,UAAU,GACjCP,KAAK,CAACC,OAAO,CAACO,KAAK,CAAC,GAClB,CAACD,GAAG,EAAEC,KAAK,CAACN,GAAG,CAACO,KAAK,CAAC,CAAC,GACvB,CAACF,GAAG,EAAEE,KAAK,CAACD,
|
|
1
|
+
{"version":3,"file":"setupUseBrickInTemplate.js","names":["isObject","setupTemplateProxy","childrenToSlots","setupUseBrickInTemplate","props","hostContext","walk","Array","isArray","map","Object","fromEntries","entries","_ref","key","value","setup","concat","getOwnPropertySymbols","k","item","properties","slots","originalSlots","children","restConf","_objectWithoutProperties","_excluded","transpiledSlots","_ref2","_slotConf$bricks","slotName","slotConf","type","bricks","_objectSpread","ref"],"sources":["../../../../src/internal/CustomTemplates/setupUseBrickInTemplate.ts"],"sourcesContent":["import type { UseBrickSlotsConf, UseSingleBrickConf } from \"@next-core/types\";\nimport { isObject } from \"@next-core/utils/general\";\nimport type { TemplateHostContext } from \"../interfaces.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function setupUseBrickInTemplate<T>(\n props: T,\n hostContext: TemplateHostContext\n): T {\n function walk<P>(props: P): P {\n if (!isObject(props)) {\n return props;\n }\n\n if (Array.isArray(props)) {\n return props.map(walk) as P;\n }\n\n return Object.fromEntries(\n Object.entries(props)\n .map(([key, value]) =>\n isObject(value) && key === \"useBrick\"\n ? Array.isArray(value)\n ? [key, value.map(setup)]\n : [key, setup(value as UseSingleBrickConf)]\n : [key, walk(value)]\n )\n .concat(\n Object.getOwnPropertySymbols(props).map((k) => [\n k,\n (props as Record<string | symbol, unknown>)[k],\n ])\n )\n ) as P;\n }\n\n function setup(item: UseSingleBrickConf): UseSingleBrickConf {\n const { properties, slots: originalSlots, children, ...restConf } = item;\n\n const transpiledSlots = childrenToSlots(children, originalSlots) as\n | UseBrickSlotsConf\n | undefined;\n\n const slots = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map(setup),\n },\n ])\n ) as UseBrickSlotsConf;\n\n return {\n ...restConf,\n properties: walk(properties),\n slots,\n ...setupTemplateProxy(hostContext, restConf.ref, slots),\n };\n }\n\n return walk(props);\n}\n"],"mappings":";;;AACA,SAASA,QAAQ,QAAQ,0BAA0B;AAEnD,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,eAAe,QAAQ,gBAAgB;AAEhD,OAAO,SAASC,uBAAuBA,CACrCC,KAAQ,EACRC,WAAgC,EAC7B;EACH,SAASC,IAAIA,CAAIF,KAAQ,EAAK;IAC5B,IAAI,CAACJ,QAAQ,CAACI,KAAK,CAAC,EAAE;MACpB,OAAOA,KAAK;IACd;IAEA,IAAIG,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE;MACxB,OAAOA,KAAK,CAACK,GAAG,CAACH,IAAI,CAAC;IACxB;IAEA,OAAOI,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACR,KAAK,CAAC,CAClBK,GAAG,CAACI,IAAA;MAAA,IAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;MAAA,OAChBb,QAAQ,CAACe,KAAK,CAAC,IAAID,GAAG,KAAK,UAAU,GACjCP,KAAK,CAACC,OAAO,CAACO,KAAK,CAAC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AAG,EAAEd,KAAK,CAAC;EAE3D;EAEA,OAAOhB,IAAI,CAACF,KAAK,CAAC;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["customTemplates","getTplStateStore","_ref","using","extraInfo","tplStateStoreId","tplStateStoreMap","Error","concat","store","get","getTplHostElement","runtimeContext","hostElement","hostBrick","element","getTagNameOfCustomTemplate","brick","appId","includes","startsWith","tagName"],"sources":["../../../../src/internal/CustomTemplates/utils.ts"],"sourcesContent":["import type { DataStore } from \"../data/DataStore.js\";\nimport type { RuntimeBrickElement, RuntimeContext } from \"../interfaces.js\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\n\ntype MinimalTplStateStoreContext = Pick<\n RuntimeContext,\n \"tplStateStoreId\" | \"tplStateStoreMap\"\n>;\n\nexport function getTplStateStore(\n { tplStateStoreId, tplStateStoreMap }: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): DataStore<\"STATE\"> {\n if (!tplStateStoreId) {\n throw new Error(\n `Using \"${using}\" outside of a custom template${extraInfo ?? \"\"}`\n );\n }\n const store = tplStateStoreMap.get(tplStateStoreId);\n if (!store) {\n throw new Error(\n `Template state store is not found when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return store;\n}\n\nexport function getTplHostElement(\n runtimeContext: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): RuntimeBrickElement {\n const store = getTplStateStore(runtimeContext, using, extraInfo);\n const hostElement = store.hostBrick!.element;\n if (!hostElement) {\n throw new Error(\n `Template host element is gone when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return hostElement;\n}\n\nexport function getTagNameOfCustomTemplate(\n brick: string,\n appId?: string\n): false | string {\n // When a template is registered by an app, it's namespace maybe missed.\n if (!brick.includes(\".\") && brick.startsWith(\"tpl-\") && appId) {\n const tagName = `${appId}.${brick}`;\n if (customTemplates.get(tagName)) {\n return tagName;\n }\n }\n if (customTemplates.get(brick)) {\n return brick;\n }\n return false;\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ,0BAA0B;AAO1D,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAE9BC,KAAa,EACbC,SAAkB,EACE;EAAA,IAHpB;IAAEC,eAAe;IAAEC;EAA8C,CAAC,GAAAJ,IAAA;EAIlE,IAAI,CAACG,eAAe,EAAE;IACpB,MAAM,IAAIE,KAAK,YAAAC,MAAA,CACHL,KAAK,qCAAAK,MAAA,CAAiCJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.js","names":["customTemplates","getTplStateStore","_ref","using","extraInfo","tplStateStoreId","tplStateStoreMap","Error","concat","store","get","getTplHostElement","runtimeContext","hostElement","hostBrick","element","getTagNameOfCustomTemplate","brick","appId","includes","startsWith","tagName"],"sources":["../../../../src/internal/CustomTemplates/utils.ts"],"sourcesContent":["import type { DataStore } from \"../data/DataStore.js\";\nimport type { RuntimeBrickElement, RuntimeContext } from \"../interfaces.js\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\n\ntype MinimalTplStateStoreContext = Pick<\n RuntimeContext,\n \"tplStateStoreId\" | \"tplStateStoreMap\"\n>;\n\nexport function getTplStateStore(\n { tplStateStoreId, tplStateStoreMap }: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): DataStore<\"STATE\"> {\n if (!tplStateStoreId) {\n throw new Error(\n `Using \"${using}\" outside of a custom template${extraInfo ?? \"\"}`\n );\n }\n const store = tplStateStoreMap.get(tplStateStoreId);\n if (!store) {\n throw new Error(\n `Template state store is not found when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return store;\n}\n\nexport function getTplHostElement(\n runtimeContext: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): RuntimeBrickElement {\n const store = getTplStateStore(runtimeContext, using, extraInfo);\n const hostElement = store.hostBrick!.element;\n if (!hostElement) {\n throw new Error(\n `Template host element is gone when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return hostElement;\n}\n\nexport function getTagNameOfCustomTemplate(\n brick: string,\n appId?: string\n): false | string {\n // When a template is registered by an app, it's namespace maybe missed.\n if (!brick.includes(\".\") && brick.startsWith(\"tpl-\") && appId) {\n const tagName = `${appId}.${brick}`;\n if (customTemplates.get(tagName)) {\n return tagName;\n }\n }\n if (customTemplates.get(brick)) {\n return brick;\n }\n return false;\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ,0BAA0B;AAO1D,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAE9BC,KAAa,EACbC,SAAkB,EACE;EAAA,IAHpB;IAAEC,eAAe;IAAEC;EAA8C,CAAC,GAAAJ,IAAA;EAIlE,IAAI,CAACG,eAAe,EAAE;IACpB,MAAM,IAAIE,KAAK,YAAAC,MAAA,CACHL,KAAK,qCAAAK,MAAA,CAAiCJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CACjE,CAAC;EACH;EACA,IAAMK,KAAK,GAAGH,gBAAgB,CAACI,GAAG,CAACL,eAAe,CAAC;EACnD,IAAI,CAACI,KAAK,EAAE;IACV,MAAM,IAAIF,KAAK,mDAAAC,MAAA,CACoCL,KAAK,QAAAK,MAAA,CACpDJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,sDAEnB,CAAC;EACH;EACA,OAAOK,KAAK;AACd;AAEA,OAAO,SAASE,iBAAiBA,CAC/BC,cAA2C,EAC3CT,KAAa,EACbC,SAAkB,EACG;EACrB,IAAMK,KAAK,GAAGR,gBAAgB,CAACW,cAAc,EAAET,KAAK,EAAEC,SAAS,CAAC;EAChE,IAAMS,WAAW,GAAGJ,KAAK,CAACK,SAAS,CAAEC,OAAO;EAC5C,IAAI,CAACF,WAAW,EAAE;IAChB,MAAM,IAAIN,KAAK,+CAAAC,MAAA,CACgCL,KAAK,QAAAK,MAAA,CAChDJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,sDAEnB,CAAC;EACH;EACA,OAAOS,WAAW;AACpB;AAEA,OAAO,SAASG,0BAA0BA,CACxCC,KAAa,EACbC,KAAc,EACE;EAChB;EACA,IAAI,CAACD,KAAK,CAACE,QAAQ,CAAC,GAAG,CAAC,IAAIF,KAAK,CAACG,UAAU,CAAC,MAAM,CAAC,IAAIF,KAAK,EAAE;IAC7D,IAAMG,OAAO,MAAAb,MAAA,CAAMU,KAAK,OAAAV,MAAA,CAAIS,KAAK,CAAE;IACnC,IAAIjB,eAAe,CAACU,GAAG,CAACW,OAAO,CAAC,EAAE;MAChC,OAAOA,OAAO;IAChB;EACF;EACA,IAAIrB,eAAe,CAACU,GAAG,CAACO,KAAK,CAAC,EAAE;IAC9B,OAAOA,KAAK;EACd;EACA,OAAO,KAAK;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandFormRenderer.js","names":["hasOwnProperty","uniqueId","DataStore","getDefaultProperties","symbolForFormStateStoreId","expandFormRenderer","formData","hostBrickConf","hostBrick","asyncHostProperties","_normalizedFormData$c","_hostBrickConf$proper","normalizedFormData","JSON","parse","formStateStoreId","runtimeContext","_objectSpread","forEachItem","tplStateStoreId","formStateStore","formStateStoreMap","set","formStateStoreScope","push","context","some","ctx","name","define","formConf","formSchemaToBrick","formSchema","fields","brick","events","mergeEvents","renderRoot","properties","slots","undefined","children","style","padding","content","bricks","type","schema","id","mountPoint","instanceId","iid","field","find","item","fieldId","defaults","brickConf","slot","formSchemasToBricks","if","schemas","Array","isArray","map","targetEvents","sourceEvents","eventType","handlers","Object","entries","flat"],"sources":["../../../../src/internal/FormRenderer/expandFormRenderer.ts"],"sourcesContent":["import type { BrickConf, BrickEventsMap } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { uniqueId } from \"lodash\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport type { AsyncProperties, RuntimeBrick } from \"../interfaces.js\";\nimport type {\n FieldProperties,\n FormDataProperties,\n FormSchemaProperties,\n} from \"./interfaces.js\";\nimport { getDefaultProperties } from \"./getDefaultProperties.js\";\nimport { symbolForFormStateStoreId } from \"./constants.js\";\n\nexport function expandFormRenderer(\n formData: unknown,\n hostBrickConf: BrickConf,\n hostBrick: RuntimeBrick,\n asyncHostProperties: AsyncProperties\n): BrickConf {\n const normalizedFormData = (\n typeof formData === \"string\" ? JSON.parse(formData) : formData\n ) as FormDataProperties;\n\n const formStateStoreId = uniqueId(\"form-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n formStateStoreId,\n };\n\n // There is a boundary for `forEachItem` and `STATE` between form internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.tplStateStoreId;\n\n const formStateStore = new DataStore(\"FORM_STATE\");\n runtimeContext.formStateStoreMap.set(formStateStoreId, formStateStore);\n if (runtimeContext.formStateStoreScope) {\n runtimeContext.formStateStoreScope.push(formStateStore);\n }\n\n // Always add a state of `params`.\n const context = normalizedFormData.context ?? [];\n if (!context.some((ctx) => ctx.name === \"params\")) {\n context.push({ name: \"params\" });\n }\n\n formStateStore.define(context, runtimeContext, asyncHostProperties);\n\n const formConf = formSchemaToBrick(\n normalizedFormData.formSchema,\n normalizedFormData.fields,\n formStateStoreId\n );\n\n if (formConf.brick === \"forms.general-form\" && hostBrickConf.events) {\n formConf.events = mergeEvents(formConf.events, hostBrickConf.events);\n }\n\n const renderRoot =\n typeof hostBrickConf.properties?.renderRoot !== \"boolean\" ||\n hostBrickConf.properties.renderRoot;\n\n if (renderRoot) {\n return {\n ...hostBrickConf,\n slots: undefined,\n children: [\n {\n brick: \"basic-bricks.micro-view\",\n properties: { style: { padding: \"12px\" } },\n slots: {\n content: { bricks: [formConf], type: \"bricks\" },\n },\n },\n ],\n };\n }\n\n return {\n ...hostBrickConf,\n slots: undefined,\n children: [formConf],\n };\n}\n\nfunction formSchemaToBrick(\n schema: FormSchemaProperties,\n fields: FieldProperties[],\n formStateStoreId: string\n): BrickConf {\n const { id, bricks, events, context, mountPoint, instanceId: iid } = schema;\n let { brick, properties } = schema;\n\n // 根据字段类型获取默认配置\n const field = fields.find((item: FieldProperties) => item.fieldId === id);\n if (field) {\n const defaults = getDefaultProperties(field);\n if (!brick) {\n brick = defaults.brick;\n }\n properties = {\n ...defaults.properties,\n ...properties,\n };\n }\n\n const brickConf = {\n brick,\n properties,\n iid,\n slot: mountPoint,\n events,\n context,\n children: formSchemasToBricks(bricks, fields, formStateStoreId),\n [symbolForFormStateStoreId]: formStateStoreId,\n } as BrickConf;\n\n if (hasOwnProperty(schema, \"if\")) {\n brickConf.if = schema.if;\n }\n\n return brickConf;\n}\n\nfunction formSchemasToBricks(\n schemas: FormSchemaProperties[] | undefined,\n fields: FieldProperties[],\n formStateStoreId: string\n): BrickConf[] | undefined {\n if (Array.isArray(schemas)) {\n return schemas.map((schema) =>\n formSchemaToBrick(schema, fields, formStateStoreId)\n );\n }\n}\n\nfunction mergeEvents(\n targetEvents: BrickEventsMap | undefined,\n sourceEvents: BrickEventsMap\n): BrickEventsMap {\n const events = targetEvents ?? {};\n\n for (const [eventType, handlers] of Object.entries(sourceEvents)) {\n events[eventType] = hasOwnProperty(events, eventType)\n ? [events[eventType], handlers].flat()\n : handlers;\n }\n\n return events;\n}\n"],"mappings":";AACA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,SAAS,QAAQ,sBAAsB;AAOhD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,yBAAyB,QAAQ,gBAAgB;AAE1D,OAAO,SAASC,kBAAkBA,CAChCC,QAAiB,EACjBC,aAAwB,EACxBC,SAAuB,EACvBC,mBAAoC,EACzB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EACX,IAAMC,kBAAkB,GACtB,OAAON,QAAQ,KAAK,QAAQ,GAAGO,IAAI,CAACC,KAAK,CAACR,QAAQ,CAAC,GAAGA,QACjC;EAEvB,IAAMS,gBAAgB,GAAGd,QAAQ,CAAC,aAAa,CAAC;EAChD,IAAMe,cAAc,GAAAC,aAAA,CAAAA,aAAA,KACfT,SAAS,CAACQ,cAAc;IAC3BD;EAAgB,EACjB;;EAED;EACA,OAAOC,cAAc,CAACE,WAAW;EACjC,OAAOF,cAAc,CAACG,eAAe;EAErC,IAAMC,cAAc,GAAG,IAAIlB,SAAS,CAAC,YAAY,CAAC;EAClDc,cAAc,CAACK,iBAAiB,CAACC,GAAG,CAACP,gBAAgB,EAAEK,cAAc,CAAC;EACtE,IAAIJ,cAAc,CAACO,mBAAmB,EAAE;IACtCP,cAAc,CAACO,mBAAmB,CAACC,IAAI,CAACJ,cAAc,CAAC;EACzD;;EAEA;EACA,IAAMK,OAAO,IAAAf,qBAAA,GAAGE,kBAAkB,CAACa,OAAO,cAAAf,qBAAA,cAAAA,qBAAA,GAAI,EAAE;EAChD,IAAI,CAACe,OAAO,CAACC,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,KAAK,QAAQ,CAAC,EAAE;IACjDH,OAAO,CAACD,IAAI,CAAC;MAAEI,IAAI,EAAE;IAAS,CAAC,CAAC;EAClC;EAEAR,cAAc,CAACS,MAAM,CAACJ,OAAO,EAAET,cAAc,EAAEP,mBAAmB,CAAC;EAEnE,IAAMqB,QAAQ,GAAGC,iBAAiB,CAChCnB,kBAAkB,CAACoB,UAAU,EAC7BpB,kBAAkB,CAACqB,MAAM,EACzBlB,
|
|
1
|
+
{"version":3,"file":"expandFormRenderer.js","names":["hasOwnProperty","uniqueId","DataStore","getDefaultProperties","symbolForFormStateStoreId","expandFormRenderer","formData","hostBrickConf","hostBrick","asyncHostProperties","_normalizedFormData$c","_hostBrickConf$proper","normalizedFormData","JSON","parse","formStateStoreId","runtimeContext","_objectSpread","forEachItem","tplStateStoreId","formStateStore","formStateStoreMap","set","formStateStoreScope","push","context","some","ctx","name","define","formConf","formSchemaToBrick","formSchema","fields","brick","events","mergeEvents","renderRoot","properties","slots","undefined","children","style","padding","content","bricks","type","schema","id","mountPoint","instanceId","iid","field","find","item","fieldId","defaults","brickConf","slot","formSchemasToBricks","if","schemas","Array","isArray","map","targetEvents","sourceEvents","eventType","handlers","Object","entries","flat"],"sources":["../../../../src/internal/FormRenderer/expandFormRenderer.ts"],"sourcesContent":["import type { BrickConf, BrickEventsMap } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { uniqueId } from \"lodash\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport type { AsyncProperties, RuntimeBrick } from \"../interfaces.js\";\nimport type {\n FieldProperties,\n FormDataProperties,\n FormSchemaProperties,\n} from \"./interfaces.js\";\nimport { getDefaultProperties } from \"./getDefaultProperties.js\";\nimport { symbolForFormStateStoreId } from \"./constants.js\";\n\nexport function expandFormRenderer(\n formData: unknown,\n hostBrickConf: BrickConf,\n hostBrick: RuntimeBrick,\n asyncHostProperties: AsyncProperties\n): BrickConf {\n const normalizedFormData = (\n typeof formData === \"string\" ? JSON.parse(formData) : formData\n ) as FormDataProperties;\n\n const formStateStoreId = uniqueId(\"form-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n formStateStoreId,\n };\n\n // There is a boundary for `forEachItem` and `STATE` between form internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.tplStateStoreId;\n\n const formStateStore = new DataStore(\"FORM_STATE\");\n runtimeContext.formStateStoreMap.set(formStateStoreId, formStateStore);\n if (runtimeContext.formStateStoreScope) {\n runtimeContext.formStateStoreScope.push(formStateStore);\n }\n\n // Always add a state of `params`.\n const context = normalizedFormData.context ?? [];\n if (!context.some((ctx) => ctx.name === \"params\")) {\n context.push({ name: \"params\" });\n }\n\n formStateStore.define(context, runtimeContext, asyncHostProperties);\n\n const formConf = formSchemaToBrick(\n normalizedFormData.formSchema,\n normalizedFormData.fields,\n formStateStoreId\n );\n\n if (formConf.brick === \"forms.general-form\" && hostBrickConf.events) {\n formConf.events = mergeEvents(formConf.events, hostBrickConf.events);\n }\n\n const renderRoot =\n typeof hostBrickConf.properties?.renderRoot !== \"boolean\" ||\n hostBrickConf.properties.renderRoot;\n\n if (renderRoot) {\n return {\n ...hostBrickConf,\n slots: undefined,\n children: [\n {\n brick: \"basic-bricks.micro-view\",\n properties: { style: { padding: \"12px\" } },\n slots: {\n content: { bricks: [formConf], type: \"bricks\" },\n },\n },\n ],\n };\n }\n\n return {\n ...hostBrickConf,\n slots: undefined,\n children: [formConf],\n };\n}\n\nfunction formSchemaToBrick(\n schema: FormSchemaProperties,\n fields: FieldProperties[],\n formStateStoreId: string\n): BrickConf {\n const { id, bricks, events, context, mountPoint, instanceId: iid } = schema;\n let { brick, properties } = schema;\n\n // 根据字段类型获取默认配置\n const field = fields.find((item: FieldProperties) => item.fieldId === id);\n if (field) {\n const defaults = getDefaultProperties(field);\n if (!brick) {\n brick = defaults.brick;\n }\n properties = {\n ...defaults.properties,\n ...properties,\n };\n }\n\n const brickConf = {\n brick,\n properties,\n iid,\n slot: mountPoint,\n events,\n context,\n children: formSchemasToBricks(bricks, fields, formStateStoreId),\n [symbolForFormStateStoreId]: formStateStoreId,\n } as BrickConf;\n\n if (hasOwnProperty(schema, \"if\")) {\n brickConf.if = schema.if;\n }\n\n return brickConf;\n}\n\nfunction formSchemasToBricks(\n schemas: FormSchemaProperties[] | undefined,\n fields: FieldProperties[],\n formStateStoreId: string\n): BrickConf[] | undefined {\n if (Array.isArray(schemas)) {\n return schemas.map((schema) =>\n formSchemaToBrick(schema, fields, formStateStoreId)\n );\n }\n}\n\nfunction mergeEvents(\n targetEvents: BrickEventsMap | undefined,\n sourceEvents: BrickEventsMap\n): BrickEventsMap {\n const events = targetEvents ?? {};\n\n for (const [eventType, handlers] of Object.entries(sourceEvents)) {\n events[eventType] = hasOwnProperty(events, eventType)\n ? [events[eventType], handlers].flat()\n : handlers;\n }\n\n return events;\n}\n"],"mappings":";A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C,GAAGnE,cAAc,CAACmC,MAAM,EAAEgC,SAAS,CAAC,GACjD,CAAChC,MAAM,CAACgC,SAAS,CAAC,EAAEC,QAAQ,CAAC,CAACG,IAAI,CAAC,CAAC,GACpCH,QAAQ;EACd;EAEA,OAAOjC,MAAM;AACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultProperties.js","names":["getDefaultProperties","field","defaultValue","commonProps","id","fieldId","name","label","dataset","testid","getReadOnlyAndRequired","_field$limit","_field$limit2","readOnly","limit","includes","required","fieldType","brick","properties","_objectSpread","placeholder","description","precision","inputBoxStyle","width","options","value","mode","pattern","message"],"sources":["../../../../src/internal/FormRenderer/getDefaultProperties.ts"],"sourcesContent":["import type { DefaultFieldProperties, FieldProperties } from \"./interfaces.js\";\n\nexport function getDefaultProperties(\n field: FieldProperties\n): DefaultFieldProperties {\n let defaultValue: DefaultFieldProperties;\n const commonProps = {\n id: field.fieldId,\n name: field.fieldId,\n label: field.name,\n dataset: {\n testid: field.fieldId,\n },\n };\n const getReadOnlyAndRequired = () => ({\n readOnly: field.limit?.includes(\"READONLY\"),\n required: field.limit?.includes(\"REQUIRED\"),\n });\n switch (field.fieldType) {\n case \"INT\":\n defaultValue = {\n brick: \"forms.general-input-number\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n precision: 0,\n inputBoxStyle: { width: \"100%\" },\n },\n };\n break;\n case \"BOOLEAN\":\n defaultValue = {\n brick: \"forms.general-switch\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n },\n };\n break;\n case \"FLOAT\":\n defaultValue = {\n brick: \"forms.general-input-number\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n inputBoxStyle: { width: \"100%\" },\n },\n };\n break;\n case \"ENUM\":\n defaultValue = {\n brick: \"forms.general-select\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n options: [\n { label: \"选项一\", value: 1 },\n { label: \"选项二\", value: 2 },\n ],\n placeholder: field.description,\n inputBoxStyle: { width: \"100%\" },\n },\n };\n break;\n case \"ENUMS\":\n defaultValue = {\n brick: \"forms.general-select\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n mode: \"multiple\",\n options: [\n { label: \"选项一\", value: 1 },\n { label: \"选项二\", value: 2 },\n ],\n placeholder: field.description,\n inputBoxStyle: { width: \"100%\" },\n },\n };\n break;\n case \"DATE\":\n case \"TIME\":\n defaultValue = {\n brick: \"forms.general-date-picker\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n },\n };\n break;\n case \"IP\":\n defaultValue = {\n brick: \"forms.general-input\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n pattern:\n \"((^s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))s*$)|(^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*$))\",\n message: {\n pattern: \"输入字符不匹配IP格式\",\n },\n },\n };\n break;\n case \"JSON\":\n defaultValue = {\n brick: \"forms.general-textarea\",\n properties: {\n ...commonProps,\n },\n };\n break;\n case \"ARRAY\":\n defaultValue = {\n brick: \"forms.general-select\",\n properties: {\n ...commonProps,\n },\n };\n break;\n case \"STRUCTURE\":\n case \"STRUCTURE_ARRAY\":\n defaultValue = {\n brick: \"forms.cmdb-instance-select-panel\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n },\n };\n break;\n default:\n defaultValue = {\n brick: \"forms.general-input\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n },\n };\n }\n return defaultValue;\n}\n"],"mappings":";AAEA,OAAO,SAASA,oBAAoBA,CAClCC,KAAsB,EACE;EACxB,IAAIC,YAAoC;EACxC,IAAMC,WAAW,GAAG;IAClBC,EAAE,EAAEH,KAAK,CAACI,OAAO;IACjBC,IAAI,EAAEL,KAAK,CAACI,OAAO;IACnBE,KAAK,EAAEN,KAAK,CAACK,IAAI;IACjBE,OAAO,EAAE;MACPC,MAAM,EAAER,KAAK,CAACI;IAChB;EACF,CAAC;EACD,IAAMK,sBAAsB,GAAGA,CAAA;IAAA,IAAAC,YAAA,EAAAC,aAAA;IAAA,OAAO;MACpCC,QAAQ,GAAAF,YAAA,GAAEV,KAAK,CAACa,KAAK,cAAAH,YAAA,uBAAXA,YAAA,CAAaI,QAAQ,CAAC,UAAU,CAAC;MAC3CC,QAAQ,GAAAJ,aAAA,GAAEX,KAAK,CAACa,KAAK,cAAAF,aAAA,uBAAXA,aAAA,CAAaG,QAAQ,CAAC,UAAU;IAC5C,CAAC;EAAA,CAAC;EACF,QAAQd,KAAK,CAACgB,SAAS;IACrB,KAAK,KAAK;MACRf,YAAY,GAAG;QACbgB,KAAK,EAAE,4BAA4B;QACnCC,UAAU,EAAAC,aAAA,CAAAA,aAAA,CAAAA,aAAA,KACLjB,WAAW,GACXO,sBAAsB,
|
|
1
|
+
{"version":3,"file":"getDefaultProperties.js","names":["getDefaultProperties","field","defaultValue","commonProps","id","fieldId","name","label","dataset","testid","getReadOnlyAndRequired","_field$limit","_field$limit2","readOnly","limit","includes","required","fieldType","brick","properties","_objectSpread","placeholder","description","precision","inputBoxStyle","width","options","value","mode","pattern","message"],"sources":["../../../../src/internal/FormRenderer/getDefaultProperties.ts"],"sourcesContent":["import type { DefaultFieldProperties, FieldProperties } from \"./interfaces.js\";\n\nexport function getDefaultProperties(\n field: FieldProperties\n): DefaultFieldProperties {\n let defaultValue: DefaultFieldProperties;\n const commonProps = {\n id: field.fieldId,\n name: field.fieldId,\n label: field.name,\n dataset: {\n testid: field.fieldId,\n },\n };\n const getReadOnlyAndRequired = () => ({\n readOnly: field.limit?.includes(\"READONLY\"),\n required: field.limit?.includes(\"REQUIRED\"),\n });\n switch (field.fieldType) {\n case \"INT\":\n defaultValue = {\n brick: \"forms.general-input-number\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n precision: 0,\n inputBoxStyle: { width: \"100%\" },\n },\n };\n break;\n case \"BOOLEAN\":\n defaultValue = {\n brick: \"forms.general-switch\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n },\n };\n break;\n case \"FLOAT\":\n defaultValue = {\n brick: \"forms.general-input-number\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n inputBoxStyle: { width: \"100%\" },\n },\n };\n break;\n case \"ENUM\":\n defaultValue = {\n brick: \"forms.general-select\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n options: [\n { label: \"选项一\", value: 1 },\n { label: \"选项二\", value: 2 },\n ],\n placeholder: field.description,\n inputBoxStyle: { width: \"100%\" },\n },\n };\n break;\n case \"ENUMS\":\n defaultValue = {\n brick: \"forms.general-select\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n mode: \"multiple\",\n options: [\n { label: \"选项一\", value: 1 },\n { label: \"选项二\", value: 2 },\n ],\n placeholder: field.description,\n inputBoxStyle: { width: \"100%\" },\n },\n };\n break;\n case \"DATE\":\n case \"TIME\":\n defaultValue = {\n brick: \"forms.general-date-picker\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n },\n };\n break;\n case \"IP\":\n defaultValue = {\n brick: \"forms.general-input\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n pattern:\n \"((^s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))s*$)|(^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*$))\",\n message: {\n pattern: \"输入字符不匹配IP格式\",\n },\n },\n };\n break;\n case \"JSON\":\n defaultValue = {\n brick: \"forms.general-textarea\",\n properties: {\n ...commonProps,\n },\n };\n break;\n case \"ARRAY\":\n defaultValue = {\n brick: \"forms.general-select\",\n properties: {\n ...commonProps,\n },\n };\n break;\n case \"STRUCTURE\":\n case \"STRUCTURE_ARRAY\":\n defaultValue = {\n brick: \"forms.cmdb-instance-select-panel\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n },\n };\n break;\n default:\n defaultValue = {\n brick: \"forms.general-input\",\n properties: {\n ...commonProps,\n ...getReadOnlyAndRequired(),\n placeholder: field.description,\n },\n };\n }\n return defaultValue;\n}\n"],"mappings":";AAEA,OAAO,SAASA,oBAAoBA,CAClCC,KAAsB,EACE;EACxB,IAAIC,YAAoC;EACxC,IAAMC,WAAW,GAAG;IAClBC,EAAE,EAAEH,KAAK,CAACI,OAAO;IACjBC,IAAI,EAAEL,KAAK,CAACI,OAAO;IACnBE,KAAK,EAAEN,KAAK,CAACK,IAAI;IACjBE,OAAO,EAAE;MACPC,MAAM,EAAER,KAAK,CAACI;IAChB;EACF,CAAC;EACD,IAAMK,sBAAsB,GAAGA,CAAA;IAAA,IAAAC,YAAA,EAAAC,aAAA;IAAA,OAAO;MACpCC,QAAQ,GAAAF,YAAA,GAAEV,KAAK,CAACa,KAAK,cAAAH,YAAA,uBAAXA,YAAA,CAAaI,QAAQ,CAAC,UAAU,CAAC;MAC3CC,QAAQ,GAAAJ,aAAA,GAAEX,KAAK,CAACa,KAAK,cAAAF,aAAA,uBAAXA,aAAA,CAAaG,QAAQ,CAAC,UAAU;IAC5C,CAAC;EAAA,CAAC;EACF,QAAQd,KAAK,CAACgB,SAAS;IACrB,KAAK,KAAK;MACRf,YAAY,GAAG;QACbgB,KAAK,EAAE,4BAA4B;QACnCC,UAAU,EAAAC,aAAA,CAAAA,aAAA,CAAAA,aAAA,KACLjB,WAAW,GACXO,sBAAsB,CAAC,CAAC;UAC3BW,WAAW,EAAEpB,KAAK,CAACqB,WAAW;UAC9BC,SAAS,EAAE,CAAC;UACZC,aAAa,EAAE;YAAEC,KAAK,EAAE;UAAO;QAAC;MAEpC,CAAC;MACD;IACF,KAAK,SAAS;MACZvB,YAAY,GAAG;QACbgB,KAAK,EAAE,sBAAsB;QAC7BC,UAAU,EAAAC,aAAA,CAAAA,aAAA,KACLjB,WAAW,GACXO,sBAAsB,CAAC,CAAC;MAE/B,CAAC;MACD;IACF,KAAK,OAAO;MACVR,YAAY,GAAG;QACbgB,KAAK,EAAE,4B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W,GACXO,sBAAsB,CAAC,CAAC;UAC3BW,WAAW,EAAEpB,KAAK,CAACqB;QAAW;MAElC,CAAC;MACD;IACF,KAAK,IAAI;MACPpB,YAAY,GAAG;QACbgB,KAAK,EAAE,qBAAqB;QAC5BC,UAAU,EAAAC,aAAA,CAAAA,aAAA,CAAAA,aAAA,KACLjB,WAAW,GACXO,sBAAsB,CAAC,CAAC;UAC3BW,WAAW,EAAEpB,KAAK,CAACqB,WAAW;UAC9BO,OAAO,EACL,6mCAA6mC;UAC/mCC,OAAO,EAAE;YACPD,OAAO,EAAE;UACX;QAAC;MAEL,CAAC;MACD;IACF,KAAK,MAAM;MACT3B,YAAY,GAAG;QACbgB,KAAK,EAAE,wBAAwB;QAC/BC,UAAU,EAAAC,aAAA,KACLjB,WAAW;MAElB,CAAC;MACD;IACF,KAAK,OAAO;MACVD,YAAY,GAAG;QACbgB,KAAK,EAAE,sBAAsB;QAC7BC,UAAU,EAAAC,aAAA,KACLjB,WAAW;MAElB,CAAC;MACD;IACF,KAAK,WAAW;IAChB,KAAK,iBAAiB;MACpBD,YAAY,GAAG;QACbgB,KAAK,EAAE,kCAAkC;QACzCC,UAAU,EAAAC,aAAA,CAAAA,aAAA,KACLjB,WAAW,GACXO,sBAAsB,CAAC,CAAC;MAE/B,CAAC;MACD;IACF;MACER,YAAY,GAAG;QACbgB,KAAK,EAAE,qBAAqB;QAC5BC,UAAU,EAAAC,aAAA,CAAAA,aAAA,CAAAA,aAAA,KACLjB,WAAW,GACXO,sBAAsB,CAAC,CAAC;UAC3BW,WAAW,EAAEpB,KAAK,CAACqB;QAAW;MAElC,CAAC;EACL;EACA,OAAOpB,YAAY;AACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["getFormStateStore","_ref","using","extraInfo","formStateStoreId","formStateStoreMap","Error","concat","store","get"],"sources":["../../../../src/internal/FormRenderer/utils.ts"],"sourcesContent":["import type { DataStore } from \"../data/DataStore.js\";\nimport type { RuntimeContext } from \"../interfaces.js\";\n\ntype MinimalTplStateStoreContext = Pick<\n RuntimeContext,\n \"formStateStoreId\" | \"formStateStoreMap\"\n>;\n\nexport function getFormStateStore(\n { formStateStoreId, formStateStoreMap }: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): DataStore<\"FORM_STATE\"> {\n if (!formStateStoreId) {\n throw new Error(\n `Using \"${using}\" outside of form renderer${extraInfo ?? \"\"}`\n );\n }\n const store = formStateStoreMap.get(formStateStoreId);\n if (!store) {\n throw new Error(\n `Form state store is not found when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return store;\n}\n"],"mappings":"AAQA,OAAO,SAASA,iBAAiBA,CAAAC,IAAA,EAE/BC,KAAa,EACbC,SAAkB,EACO;EAAA,IAHzB;IAAEC,gBAAgB;IAAEC;EAA+C,CAAC,GAAAJ,IAAA;EAIpE,IAAI,CAACG,gBAAgB,EAAE;IACrB,MAAM,IAAIE,KAAK,YAAAC,MAAA,CACHL,KAAK,iCAAAK,MAAA,CAA6BJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getFormStateStore","_ref","using","extraInfo","formStateStoreId","formStateStoreMap","Error","concat","store","get"],"sources":["../../../../src/internal/FormRenderer/utils.ts"],"sourcesContent":["import type { DataStore } from \"../data/DataStore.js\";\nimport type { RuntimeContext } from \"../interfaces.js\";\n\ntype MinimalTplStateStoreContext = Pick<\n RuntimeContext,\n \"formStateStoreId\" | \"formStateStoreMap\"\n>;\n\nexport function getFormStateStore(\n { formStateStoreId, formStateStoreMap }: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): DataStore<\"FORM_STATE\"> {\n if (!formStateStoreId) {\n throw new Error(\n `Using \"${using}\" outside of form renderer${extraInfo ?? \"\"}`\n );\n }\n const store = formStateStoreMap.get(formStateStoreId);\n if (!store) {\n throw new Error(\n `Form state store is not found when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return store;\n}\n"],"mappings":"AAQA,OAAO,SAASA,iBAAiBA,CAAAC,IAAA,EAE/BC,KAAa,EACbC,SAAkB,EACO;EAAA,IAHzB;IAAEC,gBAAgB;IAAEC;EAA+C,CAAC,GAAAJ,IAAA;EAIpE,IAAI,CAACG,gBAAgB,EAAE;IACrB,MAAM,IAAIE,KAAK,YAAAC,MAAA,CACHL,KAAK,iCAAAK,MAAA,CAA6BJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAC7D,CAAC;EACH;EACA,IAAMK,KAAK,GAAGH,iBAAiB,CAACI,GAAG,CAACL,gBAAgB,CAAC;EACrD,IAAI,CAACI,KAAK,EAAE;IACV,MAAM,IAAIF,KAAK,+CAAAC,MAAA,CACgCL,KAAK,QAAAK,MAAA,CAChDJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,sDAEnB,CAAC;EACH;EACA,OAAOK,KAAK;AACd"}
|