@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveDataStore.js","names":["_storyboard","require","resolveDataStore","contextConfs","resolveContext","keyword","dependencyMap","getDependencyMapOfContext","pendingDeps","Map","contextName","Array","from","keys","map","contextConf","name","_pendingDeps$get","set","get","hasNonStaticUsage","values","some","stats","processed","WeakSet","deferredContexts","pendingContexts","Set","Promise","resolve","reject","wrapResolve","_pendingDeps$get2","add","resolved","delete","left","Error","scheduleNext","scheduleAsSerial","readyContexts","entries","filter","predicateNextResolveFactory","entry","has","all","pendingResult","then","size","detectCircularContexts","deferred","catch","error","index","usedProperties","dep","depsMap","collectMemberUsage","if","value","duplicatedMap","next","processedAtLeastOne","ReferenceError","join"],"sources":["../../../../src/internal/data/resolveDataStore.ts"],"sourcesContent":["import { ContextConf } from \"@next-core/types\";\nimport { collectMemberUsage, MemberUsage } from \"@next-core/utils/storyboard\";\n\nexport interface DeferredContext {\n resolve(): void;\n reject(e: unknown): void;\n}\n\nexport function resolveDataStore(\n contextConfs: ContextConf[],\n resolveContext: (contextConf: ContextConf) => Promise<boolean>,\n keyword = \"CTX\"\n): {\n pendingResult: Promise<void>;\n pendingContexts: Map<string, Promise<void>>;\n} {\n const dependencyMap = getDependencyMapOfContext(contextConfs, keyword);\n // There maybe multiple context confs for a specific name, since there are conditional contexts.\n // This is a map of how many pending context confs for each context name.\n const pendingDeps = new Map<string, number>();\n for (const contextName of Array.from(dependencyMap.keys()).map(\n (contextConf) => contextConf.name\n )) {\n pendingDeps.set(contextName, (pendingDeps.get(contextName) ?? 0) + 1);\n }\n const hasNonStaticUsage = Array.from(dependencyMap.values()).some(\n (stats) => stats.hasNonStaticUsage\n );\n const processed = new WeakSet<ContextConf>();\n\n const deferredContexts = new Map<string, DeferredContext>();\n const pendingContexts = new Map(\n [...new Set(contextConfs.map((contextConf) => contextConf.name))].map(\n (contextName) => [\n contextName,\n new Promise<void>((resolve, reject) => {\n deferredContexts.set(contextName, { resolve, reject });\n }),\n ]\n )\n );\n\n const wrapResolve = async (contextConf: ContextConf): Promise<void> => {\n processed.add(contextConf);\n const resolved = await resolveContext(contextConf);\n dependencyMap.delete(contextConf);\n const left = pendingDeps.get(contextConf.name) ?? 0;\n if (resolved) {\n // Assert: contextConf.name exists in deferredContexts\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n deferredContexts.get(contextConf.name)!.resolve();\n pendingDeps.delete(contextConf.name);\n if (left === 0) {\n throw new Error(`Duplicated context defined: ${contextConf.name}`);\n }\n } else {\n // Assert: left >= 1\n if (left === 1) {\n // Assert: contextConf.name exists in deferredContexts\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n deferredContexts.get(contextConf.name)!.resolve();\n pendingDeps.delete(contextConf.name);\n } else {\n pendingDeps.set(contextConf.name, left - 1);\n }\n }\n await scheduleNext();\n };\n\n let scheduleAsSerial = hasNonStaticUsage;\n\n async function scheduleNext(): Promise<void> {\n const readyContexts = Array.from(dependencyMap.entries())\n .filter(predicateNextResolveFactory(pendingDeps, scheduleAsSerial))\n .map((entry) => entry[0])\n .filter((contextConf) => !processed.has(contextConf));\n await Promise.all(readyContexts.map(wrapResolve));\n }\n\n const pendingResult = scheduleNext()\n .then(async () => {\n // If there are still contexts left, it implies one of these situations:\n // - Circular contexts.\n // Such as: a depends on b, while b depends on a.\n // - Related contexts are all ignored.\n // Such as: a depends on b,\n // while both them are ignore by a falsy result of `if`.\n if (dependencyMap.size > 0) {\n // This will throw if circular contexts detected.\n detectCircularContexts(dependencyMap, keyword);\n scheduleAsSerial = true;\n await scheduleNext();\n }\n // There maybe ignored contexts which are still not fulfilled.\n // We treat them as RESOLVED.\n for (const deferred of deferredContexts.values()) {\n deferred.resolve();\n }\n })\n .catch((error) => {\n // There maybe contexts left not fulfilled, when an error occurred.\n // We treat them as REJECTED.\n for (const deferred of deferredContexts.values()) {\n deferred.reject(error);\n }\n throw error;\n });\n return { pendingResult, pendingContexts };\n}\n\nfunction predicateNextResolveFactory(\n pendingDeps: Map<string, number>,\n scheduleAsSerial: boolean\n): (entry: [ContextConf, MemberUsage], index: number) => boolean {\n return (entry, index) =>\n // When contexts contain computed CTX accesses, it implies a dynamic dependency map.\n // So make them process sequentially, keep the same behavior as before.\n scheduleAsSerial\n ? index === 0\n : // A context is ready when it has no pending dependencies.\n ![...entry[1].usedProperties].some((dep) => pendingDeps.has(dep));\n}\n\nexport function getDependencyMapOfContext(\n contextConfs: ContextConf[],\n keyword = \"CTX\"\n): Map<ContextConf, MemberUsage> {\n const depsMap = new Map<ContextConf, MemberUsage>();\n for (const contextConf of contextConfs) {\n const stats = collectMemberUsage(\n [contextConf.if, contextConf.value, contextConf.resolve],\n keyword\n );\n depsMap.set(contextConf, stats);\n }\n return depsMap;\n}\n\nfunction detectCircularContexts(\n dependencyMap: Map<ContextConf, MemberUsage>,\n keyword: string\n): void {\n const duplicatedMap = new Map(dependencyMap);\n const pendingDeps = new Set<string>(\n Array.from(duplicatedMap.keys()).map((contextConf) => contextConf.name)\n );\n const next = (): void => {\n let processedAtLeastOne = false;\n for (const [contextConf, stats] of duplicatedMap.entries()) {\n if (![...stats.usedProperties].some((dep) => pendingDeps.has(dep))) {\n duplicatedMap.delete(contextConf);\n pendingDeps.delete(contextConf.name);\n processedAtLeastOne = true;\n }\n }\n if (processedAtLeastOne) {\n next();\n }\n };\n next();\n\n if (duplicatedMap.size > 0) {\n throw new ReferenceError(\n `Circular ${keyword} detected: ${Array.from(duplicatedMap.keys())\n .map((contextConf) => contextConf.name)\n .join(\", \")}`\n );\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAOO,SAASC,gBAAgBA,CAC9BC,YAA2B,EAC3BC,cAA8D,EAC9DC,OAAO,GAAG,KAAK,EAIf;EACA,MAAMC,aAAa,GAAGC,yBAAyB,CAACJ,YAAY,EAAEE,OAAO,CAAC;EACtE;EACA;EACA,MAAMG,WAAW,GAAG,IAAIC,GAAG,EAAkB;EAC7C,KAAK,MAAMC,WAAW,IAAIC,KAAK,CAACC,IAAI,CAACN,aAAa,CAACO,IAAI,EAAE,CAAC,CAACC,GAAG,CAC3DC,WAAW,IAAKA,WAAW,CAACC,IAAI,CAClC,EAAE;IAAA,IAAAC,gBAAA;IACDT,WAAW,CAACU,GAAG,CAACR,WAAW,EAAE,EAAAO,gBAAA,GAACT,WAAW,CAACW,GAAG,CAACT,WAAW,CAAC,cAAAO,gBAAA,cAAAA,gBAAA,GAAI,CAAC,IAAI,CAAC,CAAC;EACvE;EACA,MAAMG,iBAAiB,GAAGT,KAAK,CAACC,IAAI,CAACN,aAAa,CAACe,MAAM,EAAE,CAAC,CAACC,IAAI,CAC9DC,KAAK,IAAKA,KAAK,CAACH,iBAAiB,CACnC;EACD,MAAMI,SAAS,GAAG,IAAIC,OAAO,EAAe;EAE5C,MAAMC,gBAAgB,GAAG,IAAIjB,GAAG,EAA2B;EAC3D,MAAMkB,eAAe,GAAG,IAAIlB,GAAG,CAC7B,CAAC,GAAG,IAAImB,GAAG,CAACzB,YAAY,CAACW,GAAG,CAAEC,WAAW,IAAKA,WAAW,CAACC,IAAI,CAAC,CAAC,CAAC,CAACF,GAAG,CAClEJ,WAAW,IAAK,CACfA,WAAW,EACX,IAAImB,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IACrCL,gBAAgB,CAACR,GAAG,CAACR,WAAW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IACR;EACF,CAAC;EACDA,IAAI,EAAE;EAEN,IAAID,aAAa,CAACZ,IAAI,GAAG,CAAC,EAAE;IAC1B,MAAM,IAAIe,cAAc,CACrB,YAAW5D,OAAQ,cAAaM,KAAK,CAACC,IAAI,CAACkD,aAAa,CAACjD,IAAI,EAAE,CAAC,CAC9DC,GAAG,CAAEC,WAAW,IAAKA,WAAW,CAACC,IAAI,CAAC,CACtCkD,IAAI,CAAC,IAAI,CAAE,EAAC,CAChB;EACH;AACF"}
|
|
1
|
+
{"version":3,"file":"resolveDataStore.js","names":["_storyboard","require","resolveDataStore","contextConfs","resolveContext","keyword","dependencyMap","getDependencyMapOfContext","pendingDeps","Map","contextName","Array","from","keys","map","contextConf","name","_pendingDeps$get","set","get","hasNonStaticUsage","values","some","stats","processed","WeakSet","deferredContexts","pendingContexts","Set","Promise","resolve","reject","wrapResolve","_pendingDeps$get2","add","resolved","delete","left","Error","scheduleNext","scheduleAsSerial","readyContexts","entries","filter","predicateNextResolveFactory","entry","has","all","pendingResult","then","size","detectCircularContexts","deferred","catch","error","index","usedProperties","dep","depsMap","collectMemberUsage","if","value","duplicatedMap","next","processedAtLeastOne","ReferenceError","join"],"sources":["../../../../src/internal/data/resolveDataStore.ts"],"sourcesContent":["import { ContextConf } from \"@next-core/types\";\nimport { collectMemberUsage, MemberUsage } from \"@next-core/utils/storyboard\";\n\nexport interface DeferredContext {\n resolve(): void;\n reject(e: unknown): void;\n}\n\nexport function resolveDataStore(\n contextConfs: ContextConf[],\n resolveContext: (contextConf: ContextConf) => Promise<boolean>,\n keyword = \"CTX\"\n): {\n pendingResult: Promise<void>;\n pendingContexts: Map<string, Promise<void>>;\n} {\n const dependencyMap = getDependencyMapOfContext(contextConfs, keyword);\n // There maybe multiple context confs for a specific name, since there are conditional contexts.\n // This is a map of how many pending context confs for each context name.\n const pendingDeps = new Map<string, number>();\n for (const contextName of Array.from(dependencyMap.keys()).map(\n (contextConf) => contextConf.name\n )) {\n pendingDeps.set(contextName, (pendingDeps.get(contextName) ?? 0) + 1);\n }\n const hasNonStaticUsage = Array.from(dependencyMap.values()).some(\n (stats) => stats.hasNonStaticUsage\n );\n const processed = new WeakSet<ContextConf>();\n\n const deferredContexts = new Map<string, DeferredContext>();\n const pendingContexts = new Map(\n [...new Set(contextConfs.map((contextConf) => contextConf.name))].map(\n (contextName) => [\n contextName,\n new Promise<void>((resolve, reject) => {\n deferredContexts.set(contextName, { resolve, reject });\n }),\n ]\n )\n );\n\n const wrapResolve = async (contextConf: ContextConf): Promise<void> => {\n processed.add(contextConf);\n const resolved = await resolveContext(contextConf);\n dependencyMap.delete(contextConf);\n const left = pendingDeps.get(contextConf.name) ?? 0;\n if (resolved) {\n // Assert: contextConf.name exists in deferredContexts\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n deferredContexts.get(contextConf.name)!.resolve();\n pendingDeps.delete(contextConf.name);\n if (left === 0) {\n throw new Error(`Duplicated context defined: ${contextConf.name}`);\n }\n } else {\n // Assert: left >= 1\n if (left === 1) {\n // Assert: contextConf.name exists in deferredContexts\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n deferredContexts.get(contextConf.name)!.resolve();\n pendingDeps.delete(contextConf.name);\n } else {\n pendingDeps.set(contextConf.name, left - 1);\n }\n }\n await scheduleNext();\n };\n\n let scheduleAsSerial = hasNonStaticUsage;\n\n async function scheduleNext(): Promise<void> {\n const readyContexts = Array.from(dependencyMap.entries())\n .filter(predicateNextResolveFactory(pendingDeps, scheduleAsSerial))\n .map((entry) => entry[0])\n .filter((contextConf) => !processed.has(contextConf));\n await Promise.all(readyContexts.map(wrapResolve));\n }\n\n const pendingResult = scheduleNext()\n .then(async () => {\n // If there are still contexts left, it implies one of these situations:\n // - Circular contexts.\n // Such as: a depends on b, while b depends on a.\n // - Related contexts are all ignored.\n // Such as: a depends on b,\n // while both them are ignore by a falsy result of `if`.\n if (dependencyMap.size > 0) {\n // This will throw if circular contexts detected.\n detectCircularContexts(dependencyMap, keyword);\n scheduleAsSerial = true;\n await scheduleNext();\n }\n // There maybe ignored contexts which are still not fulfilled.\n // We treat them as RESOLVED.\n for (const deferred of deferredContexts.values()) {\n deferred.resolve();\n }\n })\n .catch((error) => {\n // There maybe contexts left not fulfilled, when an error occurred.\n // We treat them as REJECTED.\n for (const deferred of deferredContexts.values()) {\n deferred.reject(error);\n }\n throw error;\n });\n return { pendingResult, pendingContexts };\n}\n\nfunction predicateNextResolveFactory(\n pendingDeps: Map<string, number>,\n scheduleAsSerial: boolean\n): (entry: [ContextConf, MemberUsage], index: number) => boolean {\n return (entry, index) =>\n // When contexts contain computed CTX accesses, it implies a dynamic dependency map.\n // So make them process sequentially, keep the same behavior as before.\n scheduleAsSerial\n ? index === 0\n : // A context is ready when it has no pending dependencies.\n ![...entry[1].usedProperties].some((dep) => pendingDeps.has(dep));\n}\n\nexport function getDependencyMapOfContext(\n contextConfs: ContextConf[],\n keyword = \"CTX\"\n): Map<ContextConf, MemberUsage> {\n const depsMap = new Map<ContextConf, MemberUsage>();\n for (const contextConf of contextConfs) {\n const stats = collectMemberUsage(\n [contextConf.if, contextConf.value, contextConf.resolve],\n keyword\n );\n depsMap.set(contextConf, stats);\n }\n return depsMap;\n}\n\nfunction detectCircularContexts(\n dependencyMap: Map<ContextConf, MemberUsage>,\n keyword: string\n): void {\n const duplicatedMap = new Map(dependencyMap);\n const pendingDeps = new Set<string>(\n Array.from(duplicatedMap.keys()).map((contextConf) => contextConf.name)\n );\n const next = (): void => {\n let processedAtLeastOne = false;\n for (const [contextConf, stats] of duplicatedMap.entries()) {\n if (![...stats.usedProperties].some((dep) => pendingDeps.has(dep))) {\n duplicatedMap.delete(contextConf);\n pendingDeps.delete(contextConf.name);\n processedAtLeastOne = true;\n }\n }\n if (processedAtLeastOne) {\n next();\n }\n };\n next();\n\n if (duplicatedMap.size > 0) {\n throw new ReferenceError(\n `Circular ${keyword} detected: ${Array.from(duplicatedMap.keys())\n .map((contextConf) => contextConf.name)\n .join(\", \")}`\n );\n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,CAAC;IACR;EACF,CAAC;EACDA,IAAI,CAAC,CAAC;EAEN,IAAID,aAAa,CAACZ,IAAI,GAAG,CAAC,EAAE;IAC1B,MAAM,IAAIe,cAAc,CACrB,YAAW5D,OAAQ,cAAaM,KAAK,CAACC,IAAI,CAACkD,aAAa,CAACjD,IAAI,CAAC,CAAC,CAAC,CAC9DC,GAAG,CAAEC,WAAW,IAAKA,WAAW,CAACC,IAAI,CAAC,CACtCkD,IAAI,CAAC,IAAI,CAAE,EAChB,CAAC;EACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasInstalledApp.js","names":["_compareVersions","require","_Runtime","hasInstalledApp","appId","matchVersion","app","_internalApiGetAppInBootstrapData","hooks","checkInstalledApps","getCheckedApp","installStatus","currentVersion","matches","match","TypeError","compare","error","console"],"sources":["../../../src/internal/hasInstalledApp.ts"],"sourcesContent":["import type { MicroApp } from \"@next-core/types\";\nimport { type CompareOperator, compare } from \"compare-versions\";\nimport { _internalApiGetAppInBootstrapData, hooks } from \"./Runtime.js\";\n\nexport type AppForCheck = Pick<\n MicroApp,\n \"id\" | \"currentVersion\" | \"installStatus\"\n>;\n\nexport function hasInstalledApp(appId: string, matchVersion?: string): boolean {\n // First, check whether the app is in bootstrap already.\n let app = _internalApiGetAppInBootstrapData(appId) as AppForCheck | undefined;\n if (!app && hooks?.checkInstalledApps) {\n app = hooks.checkInstalledApps.getCheckedApp(appId);\n }\n if (!app || app.installStatus === \"running\") {\n return false;\n }\n // Todo: `currentVersion` maybe `\"\"`\n if (!matchVersion || !app.currentVersion) {\n return true;\n }\n // Valid `matchVersion`:\n // >=1.2.3\n // >1.2.3\n // =1.2.3\n // <=1.2.3\n // <1.2.3\n const matches = matchVersion.match(/^([><]=?|=)(.*)$/);\n try {\n if (!matches) {\n throw new TypeError(`Invalid match version: ${matchVersion}`);\n }\n return compare(\n app.currentVersion,\n matches[2],\n matches[1] as CompareOperator\n );\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n }\n return false;\n}\n"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOO,SAASE,eAAeA,CAACC,KAAa,EAAEC,YAAqB,EAAW;EAC7E;EACA,IAAIC,GAAG,GAAG,IAAAC,0CAAiC,EAACH,KAAK,CAA4B;EAC7E,IAAI,CAACE,GAAG,IAAIE,cAAK,aAALA,cAAK,eAALA,cAAK,CAAEC,kBAAkB,EAAE;IACrCH,GAAG,GAAGE,cAAK,CAACC,kBAAkB,CAACC,aAAa,CAACN,KAAK,CAAC;EACrD;EACA,IAAI,CAACE,GAAG,IAAIA,GAAG,CAACK,aAAa,KAAK,SAAS,EAAE;IAC3C,OAAO,KAAK;EACd;EACA;EACA,IAAI,CAACN,YAAY,IAAI,CAACC,GAAG,CAACM,cAAc,EAAE;IACxC,OAAO,IAAI;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMC,OAAO,GAAGR,YAAY,CAACS,KAAK,CAAC,kBAAkB,CAAC;EACtD,IAAI;IACF,IAAI,CAACD,OAAO,EAAE;MACZ,MAAM,IAAIE,SAAS,CAAE,0BAAyBV,YAAa,EAAC,CAAC;IAC/D;IACA,OAAO,IAAAW,wBAAO,EACZV,GAAG,CAACM,cAAc,EAClBC,OAAO,CAAC,CAAC,CAAC,EACVA,OAAO,CAAC,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"hasInstalledApp.js","names":["_compareVersions","require","_Runtime","hasInstalledApp","appId","matchVersion","app","_internalApiGetAppInBootstrapData","hooks","checkInstalledApps","getCheckedApp","installStatus","currentVersion","matches","match","TypeError","compare","error","console"],"sources":["../../../src/internal/hasInstalledApp.ts"],"sourcesContent":["import type { MicroApp } from \"@next-core/types\";\nimport { type CompareOperator, compare } from \"compare-versions\";\nimport { _internalApiGetAppInBootstrapData, hooks } from \"./Runtime.js\";\n\nexport type AppForCheck = Pick<\n MicroApp,\n \"id\" | \"currentVersion\" | \"installStatus\"\n>;\n\nexport function hasInstalledApp(appId: string, matchVersion?: string): boolean {\n // First, check whether the app is in bootstrap already.\n let app = _internalApiGetAppInBootstrapData(appId) as AppForCheck | undefined;\n if (!app && hooks?.checkInstalledApps) {\n app = hooks.checkInstalledApps.getCheckedApp(appId);\n }\n if (!app || app.installStatus === \"running\") {\n return false;\n }\n // Todo: `currentVersion` maybe `\"\"`\n if (!matchVersion || !app.currentVersion) {\n return true;\n }\n // Valid `matchVersion`:\n // >=1.2.3\n // >1.2.3\n // =1.2.3\n // <=1.2.3\n // <1.2.3\n const matches = matchVersion.match(/^([><]=?|=)(.*)$/);\n try {\n if (!matches) {\n throw new TypeError(`Invalid match version: ${matchVersion}`);\n }\n return compare(\n app.currentVersion,\n matches[2],\n matches[1] as CompareOperator\n );\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n }\n return false;\n}\n"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOO,SAASE,eAAeA,CAACC,KAAa,EAAEC,YAAqB,EAAW;EAC7E;EACA,IAAIC,GAAG,GAAG,IAAAC,0CAAiC,EAACH,KAAK,CAA4B;EAC7E,IAAI,CAACE,GAAG,IAAIE,cAAK,aAALA,cAAK,eAALA,cAAK,CAAEC,kBAAkB,EAAE;IACrCH,GAAG,GAAGE,cAAK,CAACC,kBAAkB,CAACC,aAAa,CAACN,KAAK,CAAC;EACrD;EACA,IAAI,CAACE,GAAG,IAAIA,GAAG,CAACK,aAAa,KAAK,SAAS,EAAE;IAC3C,OAAO,KAAK;EACd;EACA;EACA,IAAI,CAACN,YAAY,IAAI,CAACC,GAAG,CAACM,cAAc,EAAE;IACxC,OAAO,IAAI;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMC,OAAO,GAAGR,YAAY,CAACS,KAAK,CAAC,kBAAkB,CAAC;EACtD,IAAI;IACF,IAAI,CAACD,OAAO,EAAE;MACZ,MAAM,IAAIE,SAAS,CAAE,0BAAyBV,YAAa,EAAC,CAAC;IAC/D;IACA,OAAO,IAAAW,wBAAO,EACZV,GAAG,CAACM,cAAc,EAClBC,OAAO,CAAC,CAAC,CAAC,EACVA,OAAO,CAAC,CAAC,CACX,CAAC;EACH,CAAC,CAAC,OAAOI,KAAK,EAAE;IACd;IACAC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;EACtB;EACA,OAAO,KAAK;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"historyExtended.js","names":["_history","require","_getBasePath","_Runtime","_matchStoryboard","blocked","getUserConfirmation","message","callback","confirm","historyExtended","browserHistory","push","originalPush","replace","originalReplace","location","state","updateQueryFactory","method","updateQuery","query","options","extraQuery","clear","keepHash","urlSearchParams","URLSearchParams","search","params","Object","assign","key","value","entries","Array","isArray","delete","item","append","undefined","set","toString","hash","pushAnchor","notify","reload","blockMessage","setBlockMessage","getBlockMessage","unblock","pushQuery","replaceQuery","historyOverridden","updateFactory","update","path","pathname","pathIsString","parsePath","startsWith","isOutsideApp","_internalApiMatchStoryboard","getBasePath","substring","createHref"],"sources":["../../../src/internal/historyExtended.ts"],"sourcesContent":["import {\n History,\n LocationDescriptor,\n LocationDescriptorObject,\n parsePath,\n} from \"history\";\nimport { getBasePath } from \"../getBasePath.js\";\nimport { _internalApiMatchStoryboard } from \"./Runtime.js\";\nimport { isOutsideApp } from \"./matchStoryboard.js\";\n\nlet blocked = false;\nexport function getUserConfirmation(\n message: string,\n callback: (result: boolean) => void\n): void {\n blocked = !confirm(message);\n callback(!blocked);\n}\n\nexport function historyExtended(\n browserHistory: History<NextHistoryState>\n): ExtendedHistory {\n const { push: originalPush, replace: originalReplace } = browserHistory;\n\n function push(\n location: LocationDescriptor<NextHistoryState>,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ): void {\n blocked = false;\n originalPush(location, state);\n callback?.(blocked);\n }\n\n function replace(\n location: LocationDescriptor<NextHistoryState>,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ): void {\n blocked = false;\n originalReplace(location, state);\n callback?.(blocked);\n }\n\n function updateQueryFactory(method: \"push\" | \"replace\"): UpdateQueryFunction {\n return function updateQuery(query, options = {}, callback?): void {\n const { extraQuery, clear, keepHash, ...state } = options;\n const urlSearchParams = new URLSearchParams(\n clear ? \"\" : browserHistory.location.search\n );\n const params: Record<string, string | string[]> = {};\n Object.assign(params, query, extraQuery);\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n urlSearchParams.delete(key);\n for (const item of value) {\n urlSearchParams.append(key, item);\n }\n } else if (value === undefined || value === null || value === \"\") {\n urlSearchParams.delete(key);\n } else {\n urlSearchParams.set(key, value);\n }\n }\n (method === \"push\" ? push : replace)(\n `?${urlSearchParams.toString()}${\n keepHash ? browserHistory.location.hash : \"\"\n }`,\n state,\n callback\n );\n };\n }\n\n function pushAnchor(\n hash: string,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ): void {\n push(\n {\n ...browserHistory.location,\n key: undefined,\n hash,\n state: {\n // The default notify is false\n notify: false,\n ...state,\n },\n },\n undefined,\n callback\n );\n }\n\n function reload(callback?: (blocked: boolean) => void): void {\n replace(\n {\n ...browserHistory.location,\n state: {\n ...browserHistory.location.state,\n // Always notify\n notify: true,\n },\n },\n undefined,\n callback\n );\n }\n\n let blockMessage: string | undefined;\n\n function setBlockMessage(message: string | undefined): void {\n blockMessage = message;\n }\n\n function getBlockMessage(): string | undefined {\n return blockMessage;\n }\n\n function unblock(): void {\n blockMessage = undefined;\n }\n\n return {\n pushQuery: updateQueryFactory(\"push\"),\n replaceQuery: updateQueryFactory(\"replace\"),\n pushAnchor: pushAnchor,\n reload,\n setBlockMessage,\n getBlockMessage,\n unblock,\n ...historyOverridden({ ...browserHistory, push, replace }),\n };\n}\n\n/**\n * Override history for standalone micro apps.\n *\n * when `push` or `replace` to other apps, force page refresh.\n */\nfunction historyOverridden(\n browserHistory: History<NextHistoryState> &\n Pick<ExtendedHistory, \"push\" | \"replace\">\n): Pick<ExtendedHistory, \"push\" | \"replace\"> {\n const { push: originalPush, replace: originalReplace } = browserHistory;\n function updateFactory(method: \"push\" | \"replace\"): ExtendedHistory[\"push\"] {\n return function update(path, state?, callback?) {\n let pathname: string | undefined;\n const pathIsString = typeof path === \"string\";\n if (pathIsString) {\n pathname = parsePath(path).pathname;\n } else {\n pathname = path.pathname;\n }\n\n // When history.push or history.replace is performing with an absolute pathname,\n // force load the target page when it is a page of an outside app.\n if (\n typeof pathname === \"string\" &&\n pathname.startsWith(\"/\") &&\n isOutsideApp(_internalApiMatchStoryboard(pathname))\n ) {\n // Going to outside apps.\n return location[method === \"push\" ? \"assign\" : \"replace\"](\n pathIsString\n ? getBasePath() + path.substring(1)\n : browserHistory.createHref(\n path as LocationDescriptorObject<NextHistoryState>\n )\n );\n }\n\n return (method === \"push\" ? originalPush : originalReplace)(\n path as string,\n state,\n callback\n );\n };\n }\n return {\n push: updateFactory(\"push\"),\n replace: updateFactory(\"replace\"),\n };\n}\n\nexport interface NextHistoryState {\n notify?: boolean;\n from?: LocationDescriptor<NextHistoryState>;\n}\n\n/**\n * 扩展的系统会话对象。\n */\nexport interface ExtendedHistory {\n /**\n * 更新指定的 query 参数,会保留当前其它 query 参数,往浏览器会话历史栈中推入一条新记录。\n */\n pushQuery: UpdateQueryFunction;\n\n /**\n * 更新指定的 query 参数,会保留当前其它 query 参数,替换浏览器会话历史栈中最新的一条记录。\n */\n replaceQuery: UpdateQueryFunction;\n\n /** {@inheritDoc UpdateAnchorFunction} */\n pushAnchor: UpdateAnchorFunction;\n\n /** 重载当前会话,即触发页面重新渲染。与 location.reload() 不同,它不会触发浏览器页面的重载。 */\n reload: (callback?: (blocked: boolean) => void) => void;\n\n /** @internal */\n setBlockMessage: (message: string | undefined) => void;\n\n /** @internal */\n getBlockMessage: () => string | undefined;\n\n /** 取消之前设置的阻止页面离开信息的设置。 */\n unblock: () => void;\n\n /** 推入一条记录。*/\n push: (\n location: LocationDescriptor<NextHistoryState>,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ) => void;\n\n /** 替换一条记录。*/\n replace: (\n location: LocationDescriptor<NextHistoryState>,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ) => void;\n}\n\n/**\n * 更新指定的 query 参数。\n *\n * @param query - 要更新的 query 参数。\n * @param options - 选项。\n */\nexport type UpdateQueryFunction = (\n query: Record<string, unknown>,\n options?: UpdateQueryOptions,\n callback?: (blocked: boolean) => void\n) => void;\n\n/** 更新 query 参数时的选项 */\nexport interface UpdateQueryOptions extends NextHistoryState {\n /** 额外要更新的 query 参数。 */\n extraQuery?: Record<string, unknown>;\n /** 是否同时清除当前的所有其它 query 参数。 */\n clear?: boolean;\n /** 是否保留当前 hash 参数。 */\n keepHash?: boolean;\n}\n\n/**\n * 设置指定的 anchor (URL hash)地址,此方法默认不会触发页面重新渲染。\n * 往浏览器会话历史栈中推入一条新记录。\n *\n * @param hash - Hash 地址。\n * @param state - 会话状态设置。\n */\nexport type UpdateAnchorFunction = (\n hash: string,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n) => void;\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAII,OAAO,GAAG,KAAK;AACZ,SAASC,mBAAmBA,CACjCC,OAAe,EACfC,QAAmC,EAC7B;EACNH,OAAO,GAAG,CAACI,OAAO,CAACF,OAAO,CAAC;EAC3BC,QAAQ,CAAC,CAACH,OAAO,CAAC;AACpB;AAEO,SAASK,eAAeA,CAC7BC,cAAyC,EACxB;EACjB,MAAM;IAAEC,IAAI,EAAEC,YAAY;IAAEC,OAAO,EAAEC;EAAgB,CAAC,GAAGJ,cAAc;EAEvE,SAASC,IAAIA,CACXI,QAA8C,EAC9CC,KAAwB,EACxBT,QAAqC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;AAOA;AACA;AACA;;AA0CA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"historyExtended.js","names":["_history","require","_getBasePath","_Runtime","_matchStoryboard","blocked","getUserConfirmation","message","callback","confirm","historyExtended","browserHistory","push","originalPush","replace","originalReplace","location","state","updateQueryFactory","method","updateQuery","query","options","extraQuery","clear","keepHash","urlSearchParams","URLSearchParams","search","params","Object","assign","key","value","entries","Array","isArray","delete","item","append","undefined","set","toString","hash","pushAnchor","notify","reload","blockMessage","setBlockMessage","getBlockMessage","unblock","pushQuery","replaceQuery","historyOverridden","updateFactory","update","path","pathname","pathIsString","parsePath","startsWith","isOutsideApp","_internalApiMatchStoryboard","getBasePath","substring","createHref"],"sources":["../../../src/internal/historyExtended.ts"],"sourcesContent":["import {\n History,\n LocationDescriptor,\n LocationDescriptorObject,\n parsePath,\n} from \"history\";\nimport { getBasePath } from \"../getBasePath.js\";\nimport { _internalApiMatchStoryboard } from \"./Runtime.js\";\nimport { isOutsideApp } from \"./matchStoryboard.js\";\n\nlet blocked = false;\nexport function getUserConfirmation(\n message: string,\n callback: (result: boolean) => void\n): void {\n blocked = !confirm(message);\n callback(!blocked);\n}\n\nexport function historyExtended(\n browserHistory: History<NextHistoryState>\n): ExtendedHistory {\n const { push: originalPush, replace: originalReplace } = browserHistory;\n\n function push(\n location: LocationDescriptor<NextHistoryState>,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ): void {\n blocked = false;\n originalPush(location, state);\n callback?.(blocked);\n }\n\n function replace(\n location: LocationDescriptor<NextHistoryState>,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ): void {\n blocked = false;\n originalReplace(location, state);\n callback?.(blocked);\n }\n\n function updateQueryFactory(method: \"push\" | \"replace\"): UpdateQueryFunction {\n return function updateQuery(query, options = {}, callback?): void {\n const { extraQuery, clear, keepHash, ...state } = options;\n const urlSearchParams = new URLSearchParams(\n clear ? \"\" : browserHistory.location.search\n );\n const params: Record<string, string | string[]> = {};\n Object.assign(params, query, extraQuery);\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n urlSearchParams.delete(key);\n for (const item of value) {\n urlSearchParams.append(key, item);\n }\n } else if (value === undefined || value === null || value === \"\") {\n urlSearchParams.delete(key);\n } else {\n urlSearchParams.set(key, value);\n }\n }\n (method === \"push\" ? push : replace)(\n `?${urlSearchParams.toString()}${\n keepHash ? browserHistory.location.hash : \"\"\n }`,\n state,\n callback\n );\n };\n }\n\n function pushAnchor(\n hash: string,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ): void {\n push(\n {\n ...browserHistory.location,\n key: undefined,\n hash,\n state: {\n // The default notify is false\n notify: false,\n ...state,\n },\n },\n undefined,\n callback\n );\n }\n\n function reload(callback?: (blocked: boolean) => void): void {\n replace(\n {\n ...browserHistory.location,\n state: {\n ...browserHistory.location.state,\n // Always notify\n notify: true,\n },\n },\n undefined,\n callback\n );\n }\n\n let blockMessage: string | undefined;\n\n function setBlockMessage(message: string | undefined): void {\n blockMessage = message;\n }\n\n function getBlockMessage(): string | undefined {\n return blockMessage;\n }\n\n function unblock(): void {\n blockMessage = undefined;\n }\n\n return {\n pushQuery: updateQueryFactory(\"push\"),\n replaceQuery: updateQueryFactory(\"replace\"),\n pushAnchor: pushAnchor,\n reload,\n setBlockMessage,\n getBlockMessage,\n unblock,\n ...historyOverridden({ ...browserHistory, push, replace }),\n };\n}\n\n/**\n * Override history for standalone micro apps.\n *\n * when `push` or `replace` to other apps, force page refresh.\n */\nfunction historyOverridden(\n browserHistory: History<NextHistoryState> &\n Pick<ExtendedHistory, \"push\" | \"replace\">\n): Pick<ExtendedHistory, \"push\" | \"replace\"> {\n const { push: originalPush, replace: originalReplace } = browserHistory;\n function updateFactory(method: \"push\" | \"replace\"): ExtendedHistory[\"push\"] {\n return function update(path, state?, callback?) {\n let pathname: string | undefined;\n const pathIsString = typeof path === \"string\";\n if (pathIsString) {\n pathname = parsePath(path).pathname;\n } else {\n pathname = path.pathname;\n }\n\n // When history.push or history.replace is performing with an absolute pathname,\n // force load the target page when it is a page of an outside app.\n if (\n typeof pathname === \"string\" &&\n pathname.startsWith(\"/\") &&\n isOutsideApp(_internalApiMatchStoryboard(pathname))\n ) {\n // Going to outside apps.\n return location[method === \"push\" ? \"assign\" : \"replace\"](\n pathIsString\n ? getBasePath() + path.substring(1)\n : browserHistory.createHref(\n path as LocationDescriptorObject<NextHistoryState>\n )\n );\n }\n\n return (method === \"push\" ? originalPush : originalReplace)(\n path as string,\n state,\n callback\n );\n };\n }\n return {\n push: updateFactory(\"push\"),\n replace: updateFactory(\"replace\"),\n };\n}\n\nexport interface NextHistoryState {\n notify?: boolean;\n from?: LocationDescriptor<NextHistoryState>;\n}\n\n/**\n * 扩展的系统会话对象。\n */\nexport interface ExtendedHistory {\n /**\n * 更新指定的 query 参数,会保留当前其它 query 参数,往浏览器会话历史栈中推入一条新记录。\n */\n pushQuery: UpdateQueryFunction;\n\n /**\n * 更新指定的 query 参数,会保留当前其它 query 参数,替换浏览器会话历史栈中最新的一条记录。\n */\n replaceQuery: UpdateQueryFunction;\n\n /** {@inheritDoc UpdateAnchorFunction} */\n pushAnchor: UpdateAnchorFunction;\n\n /** 重载当前会话,即触发页面重新渲染。与 location.reload() 不同,它不会触发浏览器页面的重载。 */\n reload: (callback?: (blocked: boolean) => void) => void;\n\n /** @internal */\n setBlockMessage: (message: string | undefined) => void;\n\n /** @internal */\n getBlockMessage: () => string | undefined;\n\n /** 取消之前设置的阻止页面离开信息的设置。 */\n unblock: () => void;\n\n /** 推入一条记录。*/\n push: (\n location: LocationDescriptor<NextHistoryState>,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ) => void;\n\n /** 替换一条记录。*/\n replace: (\n location: LocationDescriptor<NextHistoryState>,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n ) => void;\n}\n\n/**\n * 更新指定的 query 参数。\n *\n * @param query - 要更新的 query 参数。\n * @param options - 选项。\n */\nexport type UpdateQueryFunction = (\n query: Record<string, unknown>,\n options?: UpdateQueryOptions,\n callback?: (blocked: boolean) => void\n) => void;\n\n/** 更新 query 参数时的选项 */\nexport interface UpdateQueryOptions extends NextHistoryState {\n /** 额外要更新的 query 参数。 */\n extraQuery?: Record<string, unknown>;\n /** 是否同时清除当前的所有其它 query 参数。 */\n clear?: boolean;\n /** 是否保留当前 hash 参数。 */\n keepHash?: boolean;\n}\n\n/**\n * 设置指定的 anchor (URL hash)地址,此方法默认不会触发页面重新渲染。\n * 往浏览器会话历史栈中推入一条新记录。\n *\n * @param hash - Hash 地址。\n * @param state - 会话状态设置。\n */\nexport type UpdateAnchorFunction = (\n hash: string,\n state?: NextHistoryState,\n callback?: (blocked: boolean) => void\n) => void;\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAII,OAAO,GAAG,KAAK;AACZ,SAASC,mBAAmBA,CACjCC,OAAe,EACfC,QAAmC,EAC7B;EACNH,OAAO,GAAG,CAACI,OAAO,CAACF,OAAO,CAAC;EAC3BC,QAAQ,CAAC,CAACH,OAAO,CAAC;AACpB;AAEO,SAASK,eAAeA,CAC7BC,cAAyC,EACxB;EACjB,MAAM;IAAEC,IAAI,EAAEC,YAAY;IAAEC,OAAO,EAAEC;EAAgB,CAAC,GAAGJ,cAAc;EAEvE,SAASC,IAAIA,CACXI,QAA8C,EAC9CC,KAAwB,EACxBT,QAAqC,EAC/B;IACNH,OAAO,GAAG,KAAK;IACfQ,YAAY,CAACG,QAAQ,EAAEC,KAAK,CAAC;IAC7BT,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAGH,OAAO,CAAC;EACrB;EAEA,SAASS,OAAOA,CACdE,QAA8C,EAC9CC,KAAwB,EACxBT,QAAqC,E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AAEC,OAAO,EAAEC;EAAgB,CAAC,GAAGJ,cAAc;EACvE,SAAS2C,aAAaA,CAACnC,MAA0B,EAA2B;IAC1E,OAAO,SAASoC,MAAMA,CAACC,IAAI,EAAEvC,KAAM,EAAET,QAAS,EAAE;MAC9C,IAAIiD,QAA4B;MAChC,MAAMC,YAAY,GAAG,OAAOF,IAAI,KAAK,QAAQ;MAC7C,IAAIE,YAAY,EAAE;QAChBD,QAAQ,GAAG,IAAAE,kBAAS,EAACH,IAAI,CAAC,CAACC,QAAQ;MACrC,CAAC,MAAM;QACLA,QAAQ,GAAGD,IAAI,CAACC,QAAQ;MAC1B;;MAEA;MACA;MACA,IACE,OAAOA,QAAQ,KAAK,QAAQ,IAC5BA,QAAQ,CAACG,UAAU,CAAC,GAAG,CAAC,IACxB,IAAAC,6BAAY,EAAC,IAAAC,oCAA2B,EAACL,QAAQ,CAAC,CAAC,EACnD;QACA;QACA,OAAOzC,QAAQ,CAACG,MAAM,KAAK,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CACvDuC,YAAY,GACR,IAAAK,wBAAW,EAAC,CAAC,GAAGP,IAAI,CAACQ,SAAS,CAAC,CAAC,CAAC,GACjCrD,cAAc,CAACsD,UAAU,CACvBT,IACF,CACN,CAAC;MACH;MAEA,OAAO,CAACrC,MAAM,KAAK,MAAM,GAAGN,YAAY,GAAGE,eAAe,EACxDyC,IAAI,EACJvC,KAAK,EACLT,QACF,CAAC;IACH,CAAC;EACH;EACA,OAAO;IACLI,IAAI,EAAE0C,aAAa,CAAC,MAAM,CAAC;IAC3BxC,OAAO,EAAEwC,aAAa,CAAC,SAAS;EAClC,CAAC;AACH;;AAOA;AACA;AACA;;AA0CA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertPreviewRoutes.js","names":["_lodash","require","insertPreviewRoutes","routes","window","parent","mergedRoutes","specificTemplatePreviewIndex","findLastIndex","route","path","startsWith","slice","bricks","brick","menu","exact","specificSnippetPreviewIndex"],"sources":["../../../src/internal/insertPreviewRoutes.ts"],"sourcesContent":["import { findLastIndex } from \"lodash\";\nimport type { RouteConf } from \"@next-core/types\";\n\nexport function insertPreviewRoutes(routes: RouteConf[]): RouteConf[] {\n // Insert preview routes for iframe only.\n if (window.parent === window) {\n return routes;\n }\n\n let mergedRoutes = routes;\n\n const specificTemplatePreviewIndex = findLastIndex(mergedRoutes, (route) =>\n route.path.startsWith(\"${APP.homepage}/_dev_only_/template-preview/\")\n );\n mergedRoutes = [\n ...mergedRoutes.slice(0, specificTemplatePreviewIndex + 1),\n {\n path: \"${APP.homepage}/_dev_only_/template-preview/:templateId\",\n bricks: [{ brick: \"span\" }],\n menu: false,\n exact: true,\n } as RouteConf,\n ...mergedRoutes.slice(specificTemplatePreviewIndex + 1),\n ];\n\n const specificSnippetPreviewIndex = findLastIndex(mergedRoutes, (route) =>\n route.path.startsWith(\"${APP.homepage}/_dev_only_/snippet-preview/\")\n );\n mergedRoutes = [\n ...mergedRoutes.slice(0, specificSnippetPreviewIndex + 1),\n {\n path: \"${APP.homepage}/_dev_only_/snippet-preview/:snippetId\",\n bricks: [{ brick: \"span\" }],\n menu: false,\n exact: true,\n } as RouteConf,\n ...mergedRoutes.slice(specificSnippetPreviewIndex + 1),\n ];\n\n return mergedRoutes;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGO,SAASC,mBAAmBA,CAACC,MAAmB,EAAe;EACpE;EACA,IAAIC,MAAM,CAACC,MAAM,KAAKD,MAAM,EAAE;IAC5B,OAAOD,MAAM;EACf;EAEA,IAAIG,YAAY,GAAGH,MAAM;EAEzB,MAAMI,4BAA4B,GAAG,IAAAC,qBAAa,EAACF,YAAY,EAAGG,KAAK,IACrEA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,8CAA8C,CAAC
|
|
1
|
+
{"version":3,"file":"insertPreviewRoutes.js","names":["_lodash","require","insertPreviewRoutes","routes","window","parent","mergedRoutes","specificTemplatePreviewIndex","findLastIndex","route","path","startsWith","slice","bricks","brick","menu","exact","specificSnippetPreviewIndex"],"sources":["../../../src/internal/insertPreviewRoutes.ts"],"sourcesContent":["import { findLastIndex } from \"lodash\";\nimport type { RouteConf } from \"@next-core/types\";\n\nexport function insertPreviewRoutes(routes: RouteConf[]): RouteConf[] {\n // Insert preview routes for iframe only.\n if (window.parent === window) {\n return routes;\n }\n\n let mergedRoutes = routes;\n\n const specificTemplatePreviewIndex = findLastIndex(mergedRoutes, (route) =>\n route.path.startsWith(\"${APP.homepage}/_dev_only_/template-preview/\")\n );\n mergedRoutes = [\n ...mergedRoutes.slice(0, specificTemplatePreviewIndex + 1),\n {\n path: \"${APP.homepage}/_dev_only_/template-preview/:templateId\",\n bricks: [{ brick: \"span\" }],\n menu: false,\n exact: true,\n } as RouteConf,\n ...mergedRoutes.slice(specificTemplatePreviewIndex + 1),\n ];\n\n const specificSnippetPreviewIndex = findLastIndex(mergedRoutes, (route) =>\n route.path.startsWith(\"${APP.homepage}/_dev_only_/snippet-preview/\")\n );\n mergedRoutes = [\n ...mergedRoutes.slice(0, specificSnippetPreviewIndex + 1),\n {\n path: \"${APP.homepage}/_dev_only_/snippet-preview/:snippetId\",\n bricks: [{ brick: \"span\" }],\n menu: false,\n exact: true,\n } as RouteConf,\n ...mergedRoutes.slice(specificSnippetPreviewIndex + 1),\n ];\n\n return mergedRoutes;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGO,SAASC,mBAAmBA,CAACC,MAAmB,EAAe;EACpE;EACA,IAAIC,MAAM,CAACC,MAAM,KAAKD,MAAM,EAAE;IAC5B,OAAOD,MAAM;EACf;EAEA,IAAIG,YAAY,GAAGH,MAAM;EAEzB,MAAMI,4BAA4B,GAAG,IAAAC,qBAAa,EAACF,YAAY,EAAGG,KAAK,IACrEA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,8CAA8C,CACtE,CAAC;EACDL,YAAY,GAAG,CACb,GAAGA,YAAY,CAACM,KAAK,CAAC,CAAC,EAAEL,4BAA4B,GAAG,CAAC,CAAC,EAC1D;IACEG,IAAI,EAAE,yDAAyD;IAC/DG,MAAM,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAO,CAAC,CAAC;IAC3BC,IAAI,EAAE,KAAK;IACXC,KAAK,EAAE;EACT,CAAC,EACD,GAAGV,YAAY,CAACM,KAAK,CAACL,4BAA4B,GAAG,CAAC,CAAC,CACxD;EAED,MAAMU,2BAA2B,GAAG,IAAAT,qBAAa,EAACF,YAAY,EAAGG,KAAK,IACpEA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,6CAA6C,CACrE,CAAC;EACDL,YAAY,GAAG,CACb,GAAGA,YAAY,CAACM,KAAK,CAAC,CAAC,EAAEK,2BAA2B,GAAG,CAAC,CAAC,EACzD;IACEP,IAAI,EAAE,uDAAuD;IAC7DG,MAAM,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAO,CAAC,CAAC;IAC3BC,IAAI,EAAE,KAAK;IACXC,KAAK,EAAE;EACT,CAAC,EACD,GAAGV,YAAY,CAACM,KAAK,CAACK,2BAA2B,GAAG,CAAC,CAAC,CACvD;EAED,OAAOX,YAAY;AACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchPath.js","names":["_pathToRegexp","require","cache","Map","cacheLimit","cacheCount","compilePath","path","options","cacheKey","end","strict","sensitive","pathCache","get","set","cacheResult","keys","regexp","pathToRegexp","result","matchPath","pathname","p","exact","paths","Array","isArray","reduce","matched","match","exec","url","values","isExact","initialParams","params","memo","key","index","name","toPath","pathParams","compile"],"sources":["../../../src/internal/matchPath.ts"],"sourcesContent":["// Ref https://github.com/ReactTraining/react-router/blob/master/packages/react-router/modules/matchPath.js\nimport type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport { pathToRegexp, Key, compile } from \"path-to-regexp\";\n\nconst cache: Map<string, Map<string, CompileResult>> = new Map();\nconst cacheLimit = 10000;\nlet cacheCount = 0;\n\nfunction compilePath(path: string, options: CompileOptions): CompileResult {\n const cacheKey = `${options.end}${options.strict}${options.sensitive}`;\n let pathCache = cache.get(cacheKey);\n if (!pathCache) {\n cache.set(cacheKey, (pathCache = new Map()));\n }\n\n const cacheResult = pathCache.get(path);\n if (cacheResult) {\n return cacheResult;\n }\n\n const keys: Key[] = [];\n const regexp = pathToRegexp(path, keys, options);\n const result = { regexp, keys };\n\n if (cacheCount < cacheLimit) {\n pathCache.set(path, result);\n cacheCount++;\n }\n\n return result;\n}\n\n/**\n * Public API for matching a URL pathname to a path.\n */\nexport function matchPath(\n pathname: string,\n options: MatchPathOptions\n): MatchResult | null {\n const { path: p, exact = false, strict = false, sensitive = true } = options;\n\n const paths = Array.isArray(p) ? p : [p];\n\n return paths.reduce<MatchResult | null>((matched, path) => {\n if (matched) {\n return matched;\n }\n const { regexp, keys } = compilePath(path, {\n end: exact,\n strict,\n sensitive,\n });\n const match = regexp.exec(pathname);\n\n if (!match) {\n return null;\n }\n\n const [url, ...values] = match;\n const isExact = pathname === url;\n\n if (exact && !isExact) {\n return null;\n }\n\n const initialParams: MatchResult[\"params\"] = {};\n const result = {\n path, // the path used to match\n url: path === \"/\" && url === \"\" ? \"/\" : url, // the matched portion of the URL\n isExact, // whether or not we matched exactly\n params: keys.reduce((memo, key, index) => {\n memo[key.name] = values[index];\n return memo;\n }, initialParams),\n };\n\n return result;\n }, null);\n}\n\nexport function toPath(\n path: string,\n pathParams?: Record<string, unknown>\n): string {\n return compile(path)(pathParams);\n}\n\ninterface CompileOptions {\n end?: boolean;\n strict?: boolean;\n sensitive?: boolean;\n}\n\ninterface CompileResult {\n regexp: RegExp;\n keys: Key[];\n}\n\ninterface MatchOptions {\n path: string | string[];\n exact?: boolean;\n}\n\nexport type MatchPathOptions = MatchOptions & CompileOptions;\n\nexport type MatchResult = Exclude<\n LegacyCompatibleRuntimeContext[\"match\"],\n undefined\n>;\n"],"mappings":";;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAFA;;AAIA,MAAMC,KAA8C,GAAG,IAAIC,GAAG,
|
|
1
|
+
{"version":3,"file":"matchPath.js","names":["_pathToRegexp","require","cache","Map","cacheLimit","cacheCount","compilePath","path","options","cacheKey","end","strict","sensitive","pathCache","get","set","cacheResult","keys","regexp","pathToRegexp","result","matchPath","pathname","p","exact","paths","Array","isArray","reduce","matched","match","exec","url","values","isExact","initialParams","params","memo","key","index","name","toPath","pathParams","compile"],"sources":["../../../src/internal/matchPath.ts"],"sourcesContent":["// Ref https://github.com/ReactTraining/react-router/blob/master/packages/react-router/modules/matchPath.js\nimport type { LegacyCompatibleRuntimeContext } from \"@next-core/inject\";\nimport { pathToRegexp, Key, compile } from \"path-to-regexp\";\n\nconst cache: Map<string, Map<string, CompileResult>> = new Map();\nconst cacheLimit = 10000;\nlet cacheCount = 0;\n\nfunction compilePath(path: string, options: CompileOptions): CompileResult {\n const cacheKey = `${options.end}${options.strict}${options.sensitive}`;\n let pathCache = cache.get(cacheKey);\n if (!pathCache) {\n cache.set(cacheKey, (pathCache = new Map()));\n }\n\n const cacheResult = pathCache.get(path);\n if (cacheResult) {\n return cacheResult;\n }\n\n const keys: Key[] = [];\n const regexp = pathToRegexp(path, keys, options);\n const result = { regexp, keys };\n\n if (cacheCount < cacheLimit) {\n pathCache.set(path, result);\n cacheCount++;\n }\n\n return result;\n}\n\n/**\n * Public API for matching a URL pathname to a path.\n */\nexport function matchPath(\n pathname: string,\n options: MatchPathOptions\n): MatchResult | null {\n const { path: p, exact = false, strict = false, sensitive = true } = options;\n\n const paths = Array.isArray(p) ? p : [p];\n\n return paths.reduce<MatchResult | null>((matched, path) => {\n if (matched) {\n return matched;\n }\n const { regexp, keys } = compilePath(path, {\n end: exact,\n strict,\n sensitive,\n });\n const match = regexp.exec(pathname);\n\n if (!match) {\n return null;\n }\n\n const [url, ...values] = match;\n const isExact = pathname === url;\n\n if (exact && !isExact) {\n return null;\n }\n\n const initialParams: MatchResult[\"params\"] = {};\n const result = {\n path, // the path used to match\n url: path === \"/\" && url === \"\" ? \"/\" : url, // the matched portion of the URL\n isExact, // whether or not we matched exactly\n params: keys.reduce((memo, key, index) => {\n memo[key.name] = values[index];\n return memo;\n }, initialParams),\n };\n\n return result;\n }, null);\n}\n\nexport function toPath(\n path: string,\n pathParams?: Record<string, unknown>\n): string {\n return compile(path)(pathParams);\n}\n\ninterface CompileOptions {\n end?: boolean;\n strict?: boolean;\n sensitive?: boolean;\n}\n\ninterface CompileResult {\n regexp: RegExp;\n keys: Key[];\n}\n\ninterface MatchOptions {\n path: string | string[];\n exact?: boolean;\n}\n\nexport type MatchPathOptions = MatchOptions & CompileOptions;\n\nexport type MatchResult = Exclude<\n LegacyCompatibleRuntimeContext[\"match\"],\n undefined\n>;\n"],"mappings":";;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAFA;;AAIA,MAAMC,KAA8C,GAAG,IAAIC,GAAG,CAAC,CAAC;AAChE,MAAMC,UAAU,GAAG,KAAK;AACxB,IAAIC,UAAU,GAAG,CAAC;AAElB,SAASC,WAAWA,CAACC,IAAY,EAAEC,OAAuB,EAAiB;EACzE,MAAMC,QAAQ,GAAI,GAAED,OAAO,CAACE,GAAI,GAAEF,OAAO,CAACG,MAAO,GAAEH,OAAO,CAACI,SAAU,EAAC;EACtE,IAAIC,SAAS,GAAGX,KAAK,CAACY,GAAG,CAACL,QAAQ,CAAC;EACnC,IAAI,CAACI,SAAS,EAAE;IACdX,KAAK,CAACa,GAAG,CAACN,QAAQ,EAAGI,SAAS,GAAG,IAAIV,GAAG,CAAC,CAAE,CAAC;EAC9C;EAEA,MAAMa,WAAW,GAAGH,SAAS,CAACC,GAAG,CAACP,IAAI,CAAC;EACvC,IAAIS,WAAW,EAAE;IACf,OAAOA,WAAW;EACpB;EAEA,MAAMC,IAAW,GAAG,EAAE;EACtB,MAAMC,MAAM,GAAG,IAAA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AAK,GAAG,IAAIyB,GAAG,KAAK,EAAE,GAAG,GAAG,GAAGA,GAAG;MAAE;MAC7CE,OAAO;MAAE;MACTE,MAAM,EAAEnB,IAAI,CAACW,MAAM,CAAC,CAACS,IAAI,EAAEC,GAAG,EAAEC,KAAK,KAAK;QACxCF,IAAI,CAACC,GAAG,CAACE,IAAI,CAAC,GAAGP,MAAM,CAACM,KAAK,CAAC;QAC9B,OAAOF,IAAI;MACb,CAAC,EAAEF,aAAa;IAClB,CAAC;IAED,OAAOf,MAAM;EACf,CAAC,EAAE,IAAI,CAAC;AACV;AAEO,SAASqB,MAAMA,CACpBlC,IAAY,EACZmC,UAAoC,EAC5B;EACR,OAAO,IAAAC,qBAAO,EAACpC,IAAI,CAAC,CAACmC,UAAU,CAAC;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchRoutes.js","names":["_matchPath","require","_checkIf","_Runtime","matchRoutes","routes","runtimeContext","route","path","console","error","Error","routePath","replace","app","homepage","match","matchPath","location","pathname","exact","asyncCheckIf","noAuthGuard","public","hooks","auth","isLoggedIn"],"sources":["../../../src/internal/matchRoutes.ts"],"sourcesContent":["import type { RouteConf } from \"@next-core/types\";\nimport { MatchResult, matchPath } from \"./matchPath.js\";\nimport { asyncCheckIf } from \"./compute/checkIf.js\";\nimport type { RuntimeContext } from \"./interfaces.js\";\nimport { hooks } from \"./Runtime.js\";\n\ntype MatchRoutesResult =\n | {\n match: MatchResult;\n route: RouteConf;\n }\n | \"missed\"\n | \"unauthenticated\";\n\nexport async function matchRoutes(\n routes: RouteConf[],\n runtimeContext: RuntimeContext\n): Promise<MatchRoutesResult> {\n for (const route of routes) {\n if (typeof route.path !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Invalid route with invalid path:\", route);\n throw new Error(\n `Invalid route with invalid type of path: ${typeof route.path}`\n );\n }\n const routePath = route.path.replace(\n /^\\$\\{APP.homepage\\}/,\n runtimeContext.app.homepage\n );\n const match = matchPath(runtimeContext.location.pathname, {\n path: routePath,\n exact: route.exact,\n });\n if (match && (await asyncCheckIf(route, runtimeContext))) {\n if (\n runtimeContext.app.noAuthGuard ||\n route.public ||\n !hooks?.auth ||\n hooks.auth.isLoggedIn()\n ) {\n return { match, route };\n }\n return \"unauthenticated\";\n }\n }\n return \"missed\";\n}\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAUO,eAAeG,WAAWA,CAC/BC,MAAmB,EACnBC,cAA8B,EACF;EAC5B,KAAK,MAAMC,KAAK,IAAIF,MAAM,EAAE;IAC1B,IAAI,OAAOE,KAAK,CAACC,IAAI,KAAK,QAAQ,EAAE;MAClC;MACAC,OAAO,CAACC,KAAK,CAAC,kCAAkC,EAAEH,KAAK,CAAC;MACxD,MAAM,IAAII,KAAK,CACZ,4CAA2C,OAAOJ,KAAK,CAACC,IAAK,
|
|
1
|
+
{"version":3,"file":"matchRoutes.js","names":["_matchPath","require","_checkIf","_Runtime","matchRoutes","routes","runtimeContext","route","path","console","error","Error","routePath","replace","app","homepage","match","matchPath","location","pathname","exact","asyncCheckIf","noAuthGuard","public","hooks","auth","isLoggedIn"],"sources":["../../../src/internal/matchRoutes.ts"],"sourcesContent":["import type { RouteConf } from \"@next-core/types\";\nimport { MatchResult, matchPath } from \"./matchPath.js\";\nimport { asyncCheckIf } from \"./compute/checkIf.js\";\nimport type { RuntimeContext } from \"./interfaces.js\";\nimport { hooks } from \"./Runtime.js\";\n\ntype MatchRoutesResult =\n | {\n match: MatchResult;\n route: RouteConf;\n }\n | \"missed\"\n | \"unauthenticated\";\n\nexport async function matchRoutes(\n routes: RouteConf[],\n runtimeContext: RuntimeContext\n): Promise<MatchRoutesResult> {\n for (const route of routes) {\n if (typeof route.path !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Invalid route with invalid path:\", route);\n throw new Error(\n `Invalid route with invalid type of path: ${typeof route.path}`\n );\n }\n const routePath = route.path.replace(\n /^\\$\\{APP.homepage\\}/,\n runtimeContext.app.homepage\n );\n const match = matchPath(runtimeContext.location.pathname, {\n path: routePath,\n exact: route.exact,\n });\n if (match && (await asyncCheckIf(route, runtimeContext))) {\n if (\n runtimeContext.app.noAuthGuard ||\n route.public ||\n !hooks?.auth ||\n hooks.auth.isLoggedIn()\n ) {\n return { match, route };\n }\n return \"unauthenticated\";\n }\n }\n return \"missed\";\n}\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAUO,eAAeG,WAAWA,CAC/BC,MAAmB,EACnBC,cAA8B,EACF;EAC5B,KAAK,MAAMC,KAAK,IAAIF,MAAM,EAAE;IAC1B,IAAI,OAAOE,KAAK,CAACC,IAAI,KAAK,QAAQ,EAAE;MAClC;MACAC,OAAO,CAACC,KAAK,CAAC,kCAAkC,EAAEH,KAAK,CAAC;MACxD,MAAM,IAAII,KAAK,CACZ,4CAA2C,OAAOJ,KAAK,CAACC,IAAK,EAChE,CAAC;IACH;IACA,MAAMI,SAAS,GAAGL,KAAK,CAACC,IAAI,CAACK,OAAO,CAClC,qBAAqB,EACrBP,cAAc,CAACQ,GAAG,CAACC,QACrB,CAAC;IACD,MAAMC,KAAK,GAAG,IAAAC,oBAAS,EAACX,cAAc,CAACY,QAAQ,CAACC,QAAQ,EAAE;MACxDX,IAAI,EAAEI,SAAS;MACfQ,KAAK,EAAEb,KAAK,CAACa;IACf,CAAC,CAAC;IACF,IAAIJ,KAAK,KAAK,MAAM,IAAAK,qBAAY,EAACd,KAAK,EAAED,cAAc,CAAC,CAAC,EAAE;MACxD,IACEA,cAAc,CAACQ,GAAG,CAACQ,WAAW,IAC9Bf,KAAK,CAACgB,MAAM,IACZ,EAACC,cAAK,aAALA,cAAK,eAALA,cAAK,CAAEC,IAAI,KACZD,cAAK,CAACC,IAAI,CAACC,UAAU,CAAC,CAAC,EACvB;QACA,OAAO;UAAEV,KAAK;UAAET;QAAM,CAAC;MACzB;MACA,OAAO,iBAAiB;IAC1B;EACF;EACA,OAAO,QAAQ;AACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchStoryboard.js","names":["_lodash","require","_Runtime","matchStoryboard","storyboards","pathname","sortedStoryboards","orderBy","storyboard","_storyboard$app$homep","_storyboard$app","_storyboard$app$homep2","app","homepage","length","replace","startsWith","isOutsideApp","_getRuntime$getCurren","process","env","NODE_ENV","getRuntime","getCurrentApp","id","window","STANDALONE_MICRO_APPS","standaloneMode"],"sources":["../../../src/internal/matchStoryboard.ts"],"sourcesContent":["import type { RuntimeStoryboard } from \"@next-core/types\";\nimport { orderBy } from \"lodash\";\nimport { getRuntime } from \"./Runtime.js\";\n\nexport function matchStoryboard(\n storyboards: RuntimeStoryboard[],\n pathname: string\n): RuntimeStoryboard | undefined {\n // Put apps with longer homepage before shorter ones.\n // E.g., `/legacy/tool` will match first before `/legacy`.\n // This enables two apps with relationship of parent-child of homepage.\n const sortedStoryboards = orderBy(\n storyboards,\n (storyboard) => storyboard.app?.homepage?.length ?? 0,\n \"desc\"\n );\n for (const storyboard of sortedStoryboards) {\n const homepage = storyboard.app.homepage;\n if (typeof homepage === \"string\" && homepage[0] === \"/\") {\n if (\n homepage === \"/\"\n ? pathname === homepage\n : `${pathname.replace(/\\/+$/, \"\")}/`.startsWith(\n `${homepage.replace(/\\/+$/, \"\")}/`\n )\n ) {\n return storyboard;\n }\n }\n }\n}\n\n/**\n * We say it's an outside app when at least one of the below conditions are true:\n * - target app is not found.\n * - target app is not the current app.\n * - current app is non-standalone mode and target app is standalone mode.\n *\n * Note: when current app is standalone mode, other apps will not be found.\n */\nexport function isOutsideApp(\n storyboard: RuntimeStoryboard | undefined\n): boolean | undefined {\n if (process.env.NODE_ENV === \"test\") {\n return false;\n }\n return (\n !storyboard ||\n // Sometimes `storyboard.app.standaloneMode` is incorrect.\n (getRuntime().getCurrentApp()?.id !== storyboard.app.id &&\n !window.STANDALONE_MICRO_APPS &&\n storyboard.app.standaloneMode)\n );\n}\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,SAASE,eAAeA,CAC7BC,WAAgC,EAChCC,QAAgB,EACe;EAC/B;EACA;EACA;EACA,MAAMC,iBAAiB,GAAG,IAAAC,eAAO,EAC/BH,WAAW,EACVI,UAAU;IAAA,IAAAC,qBAAA,EAAAC,eAAA,EAAAC,sBAAA;IAAA,QAAAF,qBAAA,IAAAC,eAAA,GAAKF,UAAU,CAACI,GAAG,cAAAF,eAAA,wBAAAC,sBAAA,GAAdD,eAAA,CAAgBG,QAAQ,cAAAF,sBAAA,uBAAxBA,sBAAA,CAA0BG,MAAM,cAAAL,qBAAA,cAAAA,qBAAA,GAAI,CAAC;EAAA,GACrD,
|
|
1
|
+
{"version":3,"file":"matchStoryboard.js","names":["_lodash","require","_Runtime","matchStoryboard","storyboards","pathname","sortedStoryboards","orderBy","storyboard","_storyboard$app$homep","_storyboard$app","_storyboard$app$homep2","app","homepage","length","replace","startsWith","isOutsideApp","_getRuntime$getCurren","process","env","NODE_ENV","getRuntime","getCurrentApp","id","window","STANDALONE_MICRO_APPS","standaloneMode"],"sources":["../../../src/internal/matchStoryboard.ts"],"sourcesContent":["import type { RuntimeStoryboard } from \"@next-core/types\";\nimport { orderBy } from \"lodash\";\nimport { getRuntime } from \"./Runtime.js\";\n\nexport function matchStoryboard(\n storyboards: RuntimeStoryboard[],\n pathname: string\n): RuntimeStoryboard | undefined {\n // Put apps with longer homepage before shorter ones.\n // E.g., `/legacy/tool` will match first before `/legacy`.\n // This enables two apps with relationship of parent-child of homepage.\n const sortedStoryboards = orderBy(\n storyboards,\n (storyboard) => storyboard.app?.homepage?.length ?? 0,\n \"desc\"\n );\n for (const storyboard of sortedStoryboards) {\n const homepage = storyboard.app.homepage;\n if (typeof homepage === \"string\" && homepage[0] === \"/\") {\n if (\n homepage === \"/\"\n ? pathname === homepage\n : `${pathname.replace(/\\/+$/, \"\")}/`.startsWith(\n `${homepage.replace(/\\/+$/, \"\")}/`\n )\n ) {\n return storyboard;\n }\n }\n }\n}\n\n/**\n * We say it's an outside app when at least one of the below conditions are true:\n * - target app is not found.\n * - target app is not the current app.\n * - current app is non-standalone mode and target app is standalone mode.\n *\n * Note: when current app is standalone mode, other apps will not be found.\n */\nexport function isOutsideApp(\n storyboard: RuntimeStoryboard | undefined\n): boolean | undefined {\n if (process.env.NODE_ENV === \"test\") {\n return false;\n }\n return (\n !storyboard ||\n // Sometimes `storyboard.app.standaloneMode` is incorrect.\n (getRuntime().getCurrentApp()?.id !== storyboard.app.id &&\n !window.STANDALONE_MICRO_APPS &&\n storyboard.app.standaloneMode)\n );\n}\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,SAASE,eAAeA,CAC7BC,WAAgC,EAChCC,QAAgB,EACe;EAC/B;EACA;EACA;EACA,MAAMC,iBAAiB,GAAG,IAAAC,eAAO,EAC/BH,WAAW,EACVI,UAAU;IAAA,IAAAC,qBAAA,EAAAC,eAAA,EAAAC,sBAAA;IAAA,QAAAF,qBAAA,IAAAC,eAAA,GAAKF,UAAU,CAACI,GAAG,cAAAF,eAAA,wBAAAC,sBAAA,GAAdD,eAAA,CAAgBG,QAAQ,cAAAF,sBAAA,uBAAxBA,sBAAA,CAA0BG,MAAM,cAAAL,qBAAA,cAAAA,qBAAA,GAAI,CAAC;EAAA,GACrD,MACF,CAAC;EACD,KAAK,MAAMD,UAAU,IAAIF,iBAAiB,EAAE;IAC1C,MAAMO,QAAQ,GAAGL,UAAU,CAACI,GAAG,CAACC,QAAQ;IACxC,IAAI,OAAOA,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;MACvD,IACEA,QAAQ,KAAK,GAAG,GACZR,QAAQ,KAAKQ,QAAQ,GACpB,GAAER,QAAQ,CAACU,OAAO,CAAC,MAAM,EAAE,EAAE,CAAE,GAAE,CAACC,UAAU,CAC1C,GAAEH,QAAQ,CAACE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAE,GAClC,CAAC,EACL;QACA,OAAOP,UAAU;MACnB;IACF;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,YAAYA,CAC1BT,UAAyC,EACpB;EAAA,IAAAU,qBAAA;EACrB,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;IACnC,OAAO,KAAK;EACd;EACA,OACE,CAACb,UAAU;EACX;EACC,EAAAU,qBAAA,OAAAI,mBAAU,EAAC,CAAC,CAACC,aAAa,CAAC,CAAC,cAAAL,qBAAA,uBAA5BA,qBAAA,CAA8BM,EAAE,MAAKhB,UAAU,CAACI,GAAG,CAACY,EAAE,IACrD,CAACC,MAAM,CAACC,qBAAqB,IAC7BlB,UAAU,CAACI,GAAG,CAACe,cAAe;AAEpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediaQuery.js","names":["_eventTarget","_interopRequireDefault","require","MediaBreakpoint","exports","mediaBreakpointMinWidthMap","Map","xLarge","large","medium","small","xSmall","mediaEventTarget","EventTarget","breakpointMatchesMap","MEDIA","handleMatchesChange","data","breakpoint","changed","matches","dispatchEvent","CustomEvent","detail","forEach","minWidth","mediaQueryList","window","matchMedia","addEventListener","event","addListener","getMedia"],"sources":["../../../src/internal/mediaQuery.ts"],"sourcesContent":["import EventTarget from \"@ungap/event-target\";\n\nexport interface Media {\n breakpoint?: MediaBreakpoint;\n}\n\nexport enum MediaBreakpoint {\n xLarge = \"xLarge\",\n large = \"large\",\n medium = \"medium\",\n small = \"small\",\n xSmall = \"xSmall\",\n}\n\nexport const mediaBreakpointMinWidthMap = new Map<\n MediaBreakpoint,\n string | number\n>([\n [MediaBreakpoint.xLarge, \"1920px\"],\n [MediaBreakpoint.large, \"1600px\"],\n [MediaBreakpoint.medium, \"1280px\"],\n [MediaBreakpoint.small, \"1024px\"],\n [MediaBreakpoint.xSmall, 0],\n]);\nexport const mediaEventTarget = new EventTarget();\n\nconst breakpointMatchesMap: Partial<Record<MediaBreakpoint, boolean>> = {};\nconst MEDIA: Media = {};\n\nfunction handleMatchesChange(\n data: { readonly matches: boolean; readonly media: string },\n breakpoint: MediaBreakpoint\n): void {\n let changed = false;\n breakpointMatchesMap[breakpoint] = data.matches;\n\n for (const [breakpoint] of mediaBreakpointMinWidthMap) {\n if (breakpointMatchesMap[breakpoint] && MEDIA.breakpoint !== breakpoint) {\n MEDIA.breakpoint = breakpoint;\n changed = true;\n break;\n }\n }\n\n if (changed) {\n mediaEventTarget.dispatchEvent(\n new CustomEvent(\"change\", { detail: MEDIA })\n );\n }\n}\n\nmediaBreakpointMinWidthMap.forEach((minWidth, breakpoint) => {\n const mediaQueryList = window.matchMedia(`(min-width: ${minWidth})`);\n\n handleMatchesChange(mediaQueryList, breakpoint);\n\n if (mediaQueryList.addEventListener) {\n mediaQueryList.addEventListener(\"change\", (event) => {\n handleMatchesChange(event, breakpoint);\n });\n } else {\n mediaQueryList.addListener((event) => {\n handleMatchesChange(event, breakpoint);\n });\n }\n});\n\nexport const getMedia = (): Media => MEDIA;\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,IAMlCC,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAAAC,OAAA,CAAAD,eAAA,GAAAA,eAAA;AAQpB,MAAME,0BAA0B,GAAG,IAAIC,GAAG,CAG/C,CACA,CAACH,eAAe,CAACI,MAAM,EAAE,QAAQ,CAAC,EAClC,CAACJ,eAAe,CAACK,KAAK,EAAE,QAAQ,CAAC,EACjC,CAACL,eAAe,CAACM,MAAM,EAAE,QAAQ,CAAC,EAClC,CAACN,eAAe,CAACO,KAAK,EAAE,QAAQ,CAAC,EACjC,CAACP,eAAe,CAACQ,MAAM,EAAE,CAAC,CAAC,CAC5B,CAAC;AAACP,OAAA,CAAAC,0BAAA,GAAAA,0BAAA;AACI,MAAMO,gBAAgB,GAAG,IAAIC,oBAAW,
|
|
1
|
+
{"version":3,"file":"mediaQuery.js","names":["_eventTarget","_interopRequireDefault","require","MediaBreakpoint","exports","mediaBreakpointMinWidthMap","Map","xLarge","large","medium","small","xSmall","mediaEventTarget","EventTarget","breakpointMatchesMap","MEDIA","handleMatchesChange","data","breakpoint","changed","matches","dispatchEvent","CustomEvent","detail","forEach","minWidth","mediaQueryList","window","matchMedia","addEventListener","event","addListener","getMedia"],"sources":["../../../src/internal/mediaQuery.ts"],"sourcesContent":["import EventTarget from \"@ungap/event-target\";\n\nexport interface Media {\n breakpoint?: MediaBreakpoint;\n}\n\nexport enum MediaBreakpoint {\n xLarge = \"xLarge\",\n large = \"large\",\n medium = \"medium\",\n small = \"small\",\n xSmall = \"xSmall\",\n}\n\nexport const mediaBreakpointMinWidthMap = new Map<\n MediaBreakpoint,\n string | number\n>([\n [MediaBreakpoint.xLarge, \"1920px\"],\n [MediaBreakpoint.large, \"1600px\"],\n [MediaBreakpoint.medium, \"1280px\"],\n [MediaBreakpoint.small, \"1024px\"],\n [MediaBreakpoint.xSmall, 0],\n]);\nexport const mediaEventTarget = new EventTarget();\n\nconst breakpointMatchesMap: Partial<Record<MediaBreakpoint, boolean>> = {};\nconst MEDIA: Media = {};\n\nfunction handleMatchesChange(\n data: { readonly matches: boolean; readonly media: string },\n breakpoint: MediaBreakpoint\n): void {\n let changed = false;\n breakpointMatchesMap[breakpoint] = data.matches;\n\n for (const [breakpoint] of mediaBreakpointMinWidthMap) {\n if (breakpointMatchesMap[breakpoint] && MEDIA.breakpoint !== breakpoint) {\n MEDIA.breakpoint = breakpoint;\n changed = true;\n break;\n }\n }\n\n if (changed) {\n mediaEventTarget.dispatchEvent(\n new CustomEvent(\"change\", { detail: MEDIA })\n );\n }\n}\n\nmediaBreakpointMinWidthMap.forEach((minWidth, breakpoint) => {\n const mediaQueryList = window.matchMedia(`(min-width: ${minWidth})`);\n\n handleMatchesChange(mediaQueryList, breakpoint);\n\n if (mediaQueryList.addEventListener) {\n mediaQueryList.addEventListener(\"change\", (event) => {\n handleMatchesChange(event, breakpoint);\n });\n } else {\n mediaQueryList.addListener((event) => {\n handleMatchesChange(event, breakpoint);\n });\n }\n});\n\nexport const getMedia = (): Media => MEDIA;\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,IAMlCC,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAAAC,OAAA,CAAAD,eAAA,GAAAA,eAAA;AAQpB,MAAME,0BAA0B,GAAG,IAAIC,GAAG,CAG/C,CACA,CAACH,eAAe,CAACI,MAAM,EAAE,QAAQ,CAAC,EAClC,CAACJ,eAAe,CAACK,KAAK,EAAE,QAAQ,CAAC,EACjC,CAACL,eAAe,CAACM,MAAM,EAAE,QAAQ,CAAC,EAClC,CAACN,eAAe,CAACO,KAAK,EAAE,QAAQ,CAAC,EACjC,CAACP,eAAe,CAACQ,MAAM,EAAE,CAAC,CAAC,CAC5B,CAAC;AAACP,OAAA,CAAAC,0BAAA,GAAAA,0BAAA;AACI,MAAMO,gBAAgB,GAAG,IAAIC,oBAAW,CAAC,CAAC;AAACT,OAAA,CAAAQ,gBAAA,GAAAA,gBAAA;AAElD,MAAME,oBAA+D,GAAG,CAAC,CAAC;AAC1E,MAAMC,KAAY,GAAG,CAAC,CAAC;AAEvB,SAASC,mBAAmBA,CAC1BC,IAA2D,EAC3DC,UAA2B,EACrB;EACN,IAAIC,OAAO,GAAG,KAAK;EACnBL,oBAAoB,CAACI,UAAU,CAAC,GAAGD,IAAI,CAACG,OAAO;EAE/C,KAAK,MAAM,CAACF,UAAU,CAAC,IAAIb,0BAA0B,EAAE;IACrD,IAAIS,oBAAoB,CAACI,UAAU,CAAC,IAAIH,KAAK,CAACG,UAAU,KAAKA,UAAU,EAAE;MACvEH,KAAK,CAACG,UAAU,GAAGA,UAAU;MAC7BC,OAAO,GAAG,IAAI;MACd;IACF;EACF;EAEA,IAAIA,OAAO,EAAE;IACXP,gBAAgB,CAACS,aAAa,CAC5B,IAAIC,WAAW,CAAC,QAAQ,EAAE;MAAEC,MAAM,EAAER;IAAM,CAAC,CAC7C,CAAC;EACH;AACF;AAEAV,0BAA0B,CAACmB,OAAO,CAAC,CAACC,QAAQ,EAAEP,UAAU,KAAK;EAC3D,MAAMQ,cAAc,GAAGC,MAAM,CAACC,UAAU,CAAE,eAAcH,QAAS,GAAE,CAAC;EAEpET,mBAAmB,CAACU,cAAc,EAAER,UAAU,CAAC;EAE/C,IAAIQ,cAAc,CAACG,gBAAgB,EAAE;IACnCH,cAAc,CAACG,gBAAgB,CAAC,QAAQ,EAAGC,KAAK,IAAK;MACnDd,mBAAmB,CAACc,KAAK,EAAEZ,UAAU,CAAC;IACxC,CAAC,CAAC;EACJ,CAAC,MAAM;IACLQ,cAAc,CAACK,WAAW,CAAED,KAAK,IAAK;MACpCd,mBAAmB,CAACc,KAAK,EAAEZ,UAAU,CAAC;IACxC,CAAC,CAAC;EACJ;AACF,CAAC,CAAC;AAEK,MAAMc,QAAQ,GAAGA,CAAA,KAAajB,KAAK;AAACX,OAAA,CAAA4B,QAAA,GAAAA,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","names":["_bindTemplateProxy","require","_utils","_bindListeners","_setRealProperties","_enums","unmountTree","mountPoint","innerHTML","mountTree","root","initializedElement","current","child","portalElements","tagName","type","includes","customElements","get","console","error","warn","element","document","createElement","slotId","setAttribute","iid","dataset","setRealProperties","properties","bindListeners","events","runtimeContext","tplHostMetadata","$$tplStateStore","getTplStateStore","tplStateStoreId","tplStateStoreMap","bindTemplateProxy","portal","push","return","childElements","sibling","_currentReturn","currentReturn","tag","RenderTag","ROOT","_currentReturn$contai","container","append","undefined","length","createPortal"],"sources":["../../../src/internal/mount.ts"],"sourcesContent":["import { bindTemplateProxy } from \"./CustomTemplates/bindTemplateProxy.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport { bindListeners } from \"./bindListeners.js\";\nimport { setRealProperties } from \"./compute/setRealProperties.js\";\nimport { RenderTag } from \"./enums.js\";\nimport type {\n RenderNode,\n RenderRoot,\n RuntimeBrickElement,\n} from \"./interfaces.js\";\n\nexport function unmountTree(mountPoint: HTMLElement) {\n mountPoint.innerHTML = \"\";\n}\n\nexport function mountTree(\n root: RenderRoot,\n initializedElement?: RuntimeBrickElement\n): void {\n let current = root.child;\n const portalElements: RuntimeBrickElement[] = [];\n while (current) {\n const tagName = current.type;\n\n if (tagName.includes(\"-\") && !customElements.get(tagName)) {\n // eslint-disable-next-line no-console\n console.error(`Undefined custom element: ${tagName}`);\n }\n\n // istanbul ignore if\n if (tagName === \"basic-bricks.script-brick\") {\n // eslint-disable-next-line no-console\n console.warn(\n \"`basic-bricks.script-brick` is deprecated, please take caution when using it\"\n );\n }\n\n const element: RuntimeBrickElement =\n initializedElement && current === root.child\n ? initializedElement\n : document.createElement(tagName);\n current.element = element;\n\n if (current.slotId) {\n element.setAttribute(\"slot\", current.slotId);\n }\n if (current.iid) {\n element.dataset.iid = current.iid;\n }\n setRealProperties(element, current.properties);\n bindListeners(element, current.events, current.runtimeContext);\n if (current.tplHostMetadata) {\n // 先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n element.$$tplStateStore = getTplStateStore(\n {\n tplStateStoreId: current.tplHostMetadata.tplStateStoreId,\n tplStateStoreMap: current.runtimeContext.tplStateStoreMap,\n },\n \"mount\"\n );\n }\n bindTemplateProxy(current);\n\n if (current.portal) {\n portalElements.push(element);\n } else if (current.return) {\n if (!current.return.childElements) {\n current.return.childElements = [];\n }\n current.return.childElements.push(element);\n }\n\n if (current.child) {\n current = current.child;\n } else if (current.sibling) {\n current = current.sibling;\n } else {\n let currentReturn: RenderNode | null | undefined = current.return;\n while (currentReturn) {\n // Append elements inside out\n if (currentReturn.childElements) {\n if (currentReturn.tag === RenderTag.ROOT) {\n currentReturn.container?.append(...currentReturn.childElements);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n currentReturn.element!.append(...currentReturn.childElements);\n }\n currentReturn.childElements = undefined;\n }\n\n if (currentReturn.tag === RenderTag.ROOT && portalElements.length > 0) {\n const portal =\n typeof currentReturn.createPortal === \"function\"\n ? currentReturn.createPortal()\n : currentReturn.createPortal;\n portal.append(...portalElements);\n }\n\n if (currentReturn.sibling) {\n break;\n }\n currentReturn = currentReturn.return;\n }\n current = currentReturn?.sibling;\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAOO,SAASK,WAAWA,CAACC,UAAuB,EAAE;EACnDA,UAAU,CAACC,SAAS,GAAG,EAAE;AAC3B;AAEO,SAASC,SAASA,CACvBC,IAAgB,EAChBC,kBAAwC,EAClC;EACN,IAAIC,OAAO,GAAGF,IAAI,CAACG,KAAK;EACxB,MAAMC,cAAqC,GAAG,EAAE;EAChD,OAAOF,OAAO,EAAE;IACd,MAAMG,OAAO,GAAGH,OAAO,CAACI,IAAI;IAE5B,IAAID,OAAO,CAACE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAACC,cAAc,CAACC,GAAG,CAACJ,OAAO,CAAC,EAAE;MACzD;MACAK,OAAO,CAACC,KAAK,CAAE,6BAA4BN,OAAQ,EAAC,CAAC;IACvD;;IAEA;IACA,IAAIA,OAAO,KAAK,2BAA2B,EAAE;MAC3C;MACAK,OAAO,CAACE,IAAI,CACV,
|
|
1
|
+
{"version":3,"file":"mount.js","names":["_bindTemplateProxy","require","_utils","_bindListeners","_setRealProperties","_enums","unmountTree","mountPoint","innerHTML","mountTree","root","initializedElement","current","child","portalElements","tagName","type","includes","customElements","get","console","error","warn","element","document","createElement","slotId","setAttribute","iid","dataset","setRealProperties","properties","bindListeners","events","runtimeContext","tplHostMetadata","$$tplStateStore","getTplStateStore","tplStateStoreId","tplStateStoreMap","bindTemplateProxy","portal","push","return","childElements","sibling","_currentReturn","currentReturn","tag","RenderTag","ROOT","_currentReturn$contai","container","append","undefined","length","createPortal"],"sources":["../../../src/internal/mount.ts"],"sourcesContent":["import { bindTemplateProxy } from \"./CustomTemplates/bindTemplateProxy.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport { bindListeners } from \"./bindListeners.js\";\nimport { setRealProperties } from \"./compute/setRealProperties.js\";\nimport { RenderTag } from \"./enums.js\";\nimport type {\n RenderNode,\n RenderRoot,\n RuntimeBrickElement,\n} from \"./interfaces.js\";\n\nexport function unmountTree(mountPoint: HTMLElement) {\n mountPoint.innerHTML = \"\";\n}\n\nexport function mountTree(\n root: RenderRoot,\n initializedElement?: RuntimeBrickElement\n): void {\n let current = root.child;\n const portalElements: RuntimeBrickElement[] = [];\n while (current) {\n const tagName = current.type;\n\n if (tagName.includes(\"-\") && !customElements.get(tagName)) {\n // eslint-disable-next-line no-console\n console.error(`Undefined custom element: ${tagName}`);\n }\n\n // istanbul ignore if\n if (tagName === \"basic-bricks.script-brick\") {\n // eslint-disable-next-line no-console\n console.warn(\n \"`basic-bricks.script-brick` is deprecated, please take caution when using it\"\n );\n }\n\n const element: RuntimeBrickElement =\n initializedElement && current === root.child\n ? initializedElement\n : document.createElement(tagName);\n current.element = element;\n\n if (current.slotId) {\n element.setAttribute(\"slot\", current.slotId);\n }\n if (current.iid) {\n element.dataset.iid = current.iid;\n }\n setRealProperties(element, current.properties);\n bindListeners(element, current.events, current.runtimeContext);\n if (current.tplHostMetadata) {\n // 先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n element.$$tplStateStore = getTplStateStore(\n {\n tplStateStoreId: current.tplHostMetadata.tplStateStoreId,\n tplStateStoreMap: current.runtimeContext.tplStateStoreMap,\n },\n \"mount\"\n );\n }\n bindTemplateProxy(current);\n\n if (current.portal) {\n portalElements.push(element);\n } else if (current.return) {\n if (!current.return.childElements) {\n current.return.childElements = [];\n }\n current.return.childElements.push(element);\n }\n\n if (current.child) {\n current = current.child;\n } else if (current.sibling) {\n current = current.sibling;\n } else {\n let currentReturn: RenderNode | null | undefined = current.return;\n while (currentReturn) {\n // Append elements inside out\n if (currentReturn.childElements) {\n if (currentReturn.tag === RenderTag.ROOT) {\n currentReturn.container?.append(...currentReturn.childElements);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n currentReturn.element!.append(...currentReturn.childElements);\n }\n currentReturn.childElements = undefined;\n }\n\n if (currentReturn.tag === RenderTag.ROOT && portalElements.length > 0) {\n const portal =\n typeof currentReturn.createPortal === \"function\"\n ? currentReturn.createPortal()\n : currentReturn.createPortal;\n portal.append(...portalElements);\n }\n\n if (currentReturn.sibling) {\n break;\n }\n currentReturn = currentReturn.return;\n }\n current = currentReturn?.sibling;\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAOO,SAASK,WAAWA,CAACC,UAAuB,EAAE;EACnDA,UAAU,CAACC,SAAS,GAAG,EAAE;AAC3B;AAEO,SAASC,SAASA,CACvBC,IAAgB,EAChBC,kBAAwC,EAClC;EACN,I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AC,CAAC,GAC5BT,aAAa,CAACS,YAAY;UAChCf,MAAM,CAACY,MAAM,CAAC,GAAGvC,cAAc,CAAC;QAClC;QAEA,IAAIiC,aAAa,CAACF,OAAO,EAAE;UACzB;QACF;QACAE,aAAa,GAAGA,aAAa,CAACJ,MAAM;MACtC;MACA/B,OAAO,IAAAkC,cAAA,GAAGC,aAAa,cAAAD,cAAA,uBAAbA,cAAA,CAAeD,OAAO;IAClC;EACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","names":["_Runtime","require","timeoutIdList","Set","startPoll","task","progress","success","error","finally","finallyCallback","interval","leadingRequestDelay","continueOnError","delegateLoadingBar","expectPollEnd","expectPollStopImmediately","currentRenderId","_internalApiGetRenderId","currentTimeoutId","poll","delete","shouldStop","result","window","dispatchEvent","Event","delayedPoll","e","delay","setTimeout","add","clearPollTimeout","timeoutId","clearTimeout","clear"],"sources":["../../../src/internal/poll.ts"],"sourcesContent":["import type { ProviderPollOptions } from \"@next-core/types\";\nimport { _internalApiGetRenderId } from \"./Runtime.js\";\n\nexport type PollableCallbackFunction = (result?: unknown) => unknown;\n\nexport interface PollableCallback {\n progress?: PollableCallbackFunction;\n success?: PollableCallbackFunction;\n error?: PollableCallbackFunction;\n finally?: PollableCallbackFunction;\n}\n\nconst timeoutIdList = new Set<number>();\n\nexport function startPoll(\n task: () => unknown,\n { progress, success, error, finally: finallyCallback }: PollableCallback,\n {\n interval,\n leadingRequestDelay,\n continueOnError,\n delegateLoadingBar,\n expectPollEnd,\n expectPollStopImmediately,\n }: ProviderPollOptions\n): void {\n const currentRenderId = _internalApiGetRenderId();\n let currentTimeoutId: number;\n async function poll(): Promise<void> {\n timeoutIdList.delete(currentTimeoutId);\n let shouldStop: boolean | undefined;\n try {\n shouldStop = expectPollStopImmediately?.();\n // Stop polling immediately when the expectation is match before task.\n if (!shouldStop) {\n const result = await task();\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediately?.() ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n progress?.(result);\n if (expectPollEnd?.(result)) {\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n success?.(result);\n finallyCallback?.();\n } else {\n delayedPoll(interval ?? 3000);\n }\n }\n }\n } catch (e) {\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediately?.() ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n error?.(e);\n if (continueOnError) {\n delayedPoll(interval ?? 3000);\n } else {\n finallyCallback?.();\n }\n }\n } finally {\n // Manually dispatch an event of `request.end` when the polling is stopped immediately.\n if (delegateLoadingBar && shouldStop) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n }\n }\n\n function delayedPoll(delay: number): void {\n currentTimeoutId = setTimeout(poll, delay) as unknown as number;\n timeoutIdList.add(currentTimeoutId);\n }\n\n delayedPoll(leadingRequestDelay ?? 0);\n\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.start\"));\n }\n}\n\nexport function clearPollTimeout(): void {\n for (const timeoutId of timeoutIdList) {\n clearTimeout(timeoutId);\n }\n timeoutIdList.clear();\n}\n"],"mappings":";;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAWA,MAAMC,aAAa,GAAG,IAAIC,GAAG,
|
|
1
|
+
{"version":3,"file":"poll.js","names":["_Runtime","require","timeoutIdList","Set","startPoll","task","progress","success","error","finally","finallyCallback","interval","leadingRequestDelay","continueOnError","delegateLoadingBar","expectPollEnd","expectPollStopImmediately","currentRenderId","_internalApiGetRenderId","currentTimeoutId","poll","delete","shouldStop","result","window","dispatchEvent","Event","delayedPoll","e","delay","setTimeout","add","clearPollTimeout","timeoutId","clearTimeout","clear"],"sources":["../../../src/internal/poll.ts"],"sourcesContent":["import type { ProviderPollOptions } from \"@next-core/types\";\nimport { _internalApiGetRenderId } from \"./Runtime.js\";\n\nexport type PollableCallbackFunction = (result?: unknown) => unknown;\n\nexport interface PollableCallback {\n progress?: PollableCallbackFunction;\n success?: PollableCallbackFunction;\n error?: PollableCallbackFunction;\n finally?: PollableCallbackFunction;\n}\n\nconst timeoutIdList = new Set<number>();\n\nexport function startPoll(\n task: () => unknown,\n { progress, success, error, finally: finallyCallback }: PollableCallback,\n {\n interval,\n leadingRequestDelay,\n continueOnError,\n delegateLoadingBar,\n expectPollEnd,\n expectPollStopImmediately,\n }: ProviderPollOptions\n): void {\n const currentRenderId = _internalApiGetRenderId();\n let currentTimeoutId: number;\n async function poll(): Promise<void> {\n timeoutIdList.delete(currentTimeoutId);\n let shouldStop: boolean | undefined;\n try {\n shouldStop = expectPollStopImmediately?.();\n // Stop polling immediately when the expectation is match before task.\n if (!shouldStop) {\n const result = await task();\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediately?.() ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n progress?.(result);\n if (expectPollEnd?.(result)) {\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n success?.(result);\n finallyCallback?.();\n } else {\n delayedPoll(interval ?? 3000);\n }\n }\n }\n } catch (e) {\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediately?.() ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n error?.(e);\n if (continueOnError) {\n delayedPoll(interval ?? 3000);\n } else {\n finallyCallback?.();\n }\n }\n } finally {\n // Manually dispatch an event of `request.end` when the polling is stopped immediately.\n if (delegateLoadingBar && shouldStop) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n }\n }\n\n function delayedPoll(delay: number): void {\n currentTimeoutId = setTimeout(poll, delay) as unknown as number;\n timeoutIdList.add(currentTimeoutId);\n }\n\n delayedPoll(leadingRequestDelay ?? 0);\n\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.start\"));\n }\n}\n\nexport function clearPollTimeout(): void {\n for (const timeoutId of timeoutIdList) {\n clearTimeout(timeoutId);\n }\n timeoutIdList.clear();\n}\n"],"mappings":";;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAWA,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAS,CAAC;AAEhC,SAASC,SAASA,CACvBC,IAAmB,EACnB;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,KAAK;EAAEC,OAAO,EAAEC;AAAkC,CAAC,EACxE;EACEC,QAAQ;EACRC,mBAAmB;EACnBC,eAAe;EACfC,kBAAkB;EAClBC,aAAa;EACbC;AACmB,CAAC,EAChB;EACN,MAAMC,eAAe,GAAG,IAAAC,gCAAuB,EAAC,CAAC;EACjD,IAAIC,gBAAwB;EAC5B,eAAeC,IAAIA,CAAA,EAAkB;IACnClB,aAAa,CAACmB,MAAM,CAACF,gBAAgB,CAAC;IACtC,IAAIG,UAA+B;IACnC,IAAI;MACFA,UAAU,GAAGN,yBAAyB,aAAzBA,yBAAyB,uBAAzBA,yBAAyB,CAAG,CAAC;MAC1C;MACA,IAAI,CAACM,UAAU,EAAE;QACf,MAAMC,MAAM,GAAG,MAAMlB,IAAI,CAAC,CAAC;QAC3B;QACA;QACAiB,UAAU,GACR,CAAAN,yBAAyB,aAAzBA,yBAAyB,uBAAzBA,yBAAyB,CAAG,CAAC,KAC7BC,eAAe,KAAK,IAAAC,gCAAuB,EAAC,CAAC;QAC/C,IAAI,CAACI,UAAU,EAAE;UACfhB,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAGiB,MAAM,CAAC;UAClB,IAAIR,aAAa,aAAbA,aAAa,eAAbA,aAAa,CAAGQ,MAAM,CAAC,EAAE;YAC3B,IAAIT,kBAAkB,EAAE;cACtBU,MAAM,CAACC,aAAa,CAAC,IAAIC,KAAK,CAAC,aAAa,CAAC,CAAC;YAChD;YACAnB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAGgB,MAAM,CAAC;Y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K,CAAC,CAAC;AACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyFactories.js","names":["_devtools","require","THROW","Error","readOnlyHandler","set","defineProperty","deleteProperty","setPrototypeOf","getReadOnlyProxy","object","Proxy","getDynamicReadOnlyProxy","get","ownKeys","getDevHook","target","Object","fromEntries","map","key","freeze"],"sources":["../../../src/internal/proxyFactories.ts"],"sourcesContent":["import { getDevHook } from \"./devtools.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst THROW = (): any => {\n throw new Error(\"Can't modify read-only proxy object\");\n};\n\nconst readOnlyHandler: ProxyHandler<object> = {\n set: THROW,\n defineProperty: THROW,\n deleteProperty: THROW,\n setPrototypeOf: THROW,\n};\n\nexport function getReadOnlyProxy<T extends object>(object: T): T {\n return new Proxy<T>(object, readOnlyHandler);\n}\n\n// First, we want to make accessing property of globals lazy,\n// So we use *Proxy* to make a dynamic accessor for each of these globals.\n// But we also want to keep them working in devtools.\nexport function getDynamicReadOnlyProxy({\n get,\n ownKeys,\n}: Required<Pick<ProxyHandler<object>, \"get\" | \"ownKeys\">>): unknown {\n if (getDevHook()) {\n // In devtools, we extract them at beginning.\n const target = Object.fromEntries(\n (ownKeys(null!) as string[]).map((key) => [key, get(null!, key, null)])\n );\n return getReadOnlyProxy(target);\n }\n return new Proxy(Object.freeze({}), { get });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA;AACA,MAAMC,KAAK,GAAGA,CAAA,KAAW;EACvB,MAAM,IAAIC,KAAK,CAAC,qCAAqC,CAAC;AACxD,CAAC;AAED,MAAMC,eAAqC,GAAG;EAC5CC,GAAG,EAAEH,KAAK;EACVI,cAAc,EAAEJ,KAAK;EACrBK,cAAc,EAAEL,KAAK;EACrBM,cAAc,EAAEN;AAClB,CAAC;AAEM,SAASO,gBAAgBA,CAAmBC,MAAS,EAAK;EAC/D,OAAO,IAAIC,KAAK,CAAID,MAAM,EAAEN,eAAe,CAAC;AAC9C;;AAEA;AACA;AACA;AACO,SAASQ,uBAAuBA,CAAC;EACtCC,GAAG;EACHC;AACuD,CAAC,EAAW;EACnE,IAAI,IAAAC,oBAAU,
|
|
1
|
+
{"version":3,"file":"proxyFactories.js","names":["_devtools","require","THROW","Error","readOnlyHandler","set","defineProperty","deleteProperty","setPrototypeOf","getReadOnlyProxy","object","Proxy","getDynamicReadOnlyProxy","get","ownKeys","getDevHook","target","Object","fromEntries","map","key","freeze"],"sources":["../../../src/internal/proxyFactories.ts"],"sourcesContent":["import { getDevHook } from \"./devtools.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst THROW = (): any => {\n throw new Error(\"Can't modify read-only proxy object\");\n};\n\nconst readOnlyHandler: ProxyHandler<object> = {\n set: THROW,\n defineProperty: THROW,\n deleteProperty: THROW,\n setPrototypeOf: THROW,\n};\n\nexport function getReadOnlyProxy<T extends object>(object: T): T {\n return new Proxy<T>(object, readOnlyHandler);\n}\n\n// First, we want to make accessing property of globals lazy,\n// So we use *Proxy* to make a dynamic accessor for each of these globals.\n// But we also want to keep them working in devtools.\nexport function getDynamicReadOnlyProxy({\n get,\n ownKeys,\n}: Required<Pick<ProxyHandler<object>, \"get\" | \"ownKeys\">>): unknown {\n if (getDevHook()) {\n // In devtools, we extract them at beginning.\n const target = Object.fromEntries(\n (ownKeys(null!) as string[]).map((key) => [key, get(null!, key, null)])\n );\n return getReadOnlyProxy(target);\n }\n return new Proxy(Object.freeze({}), { get });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA;AACA,MAAMC,KAAK,GAAGA,CAAA,KAAW;EACvB,MAAM,IAAIC,KAAK,CAAC,qCAAqC,CAAC;AACxD,CAAC;AAED,MAAMC,eAAqC,GAAG;EAC5CC,GAAG,EAAEH,KAAK;EACVI,cAAc,EAAEJ,KAAK;EACrBK,cAAc,EAAEL,KAAK;EACrBM,cAAc,EAAEN;AAClB,CAAC;AAEM,SAASO,gBAAgBA,CAAmBC,MAAS,EAAK;EAC/D,OAAO,IAAIC,KAAK,CAAID,MAAM,EAAEN,eAAe,CAAC;AAC9C;;AAEA;AACA;AACA;AACO,SAASQ,uBAAuBA,CAAC;EACtCC,GAAG;EACHC;AACuD,CAAC,EAAW;EACnE,IAAI,IAAAC,oBAAU,EAAC,CAAC,EAAE;IAChB;IACA,MAAMC,MAAM,GAAGC,MAAM,CAACC,WAAW,CAC9BJ,OAAO,CAAC,IAAK,CAAC,CAAcK,GAAG,CAAEC,GAAG,IAAK,CAACA,GAAG,EAAEP,GAAG,CAAC,IAAI,EAAGO,GAAG,EAAE,IAAI,CAAC,CAAC,CACxE,CAAC;IACD,OAAOX,gBAAgB,CAACO,MAAM,CAAC;EACjC;EACA,OAAO,IAAIL,KAAK,CAACM,MAAM,CAACI,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IAAER;EAAI,CAAC,CAAC;AAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["_loader","require","_lodash","_Runtime","_Renderer","_RendererContext","_mount","_enums","_computeRealValue","_isStrictMode","_CustomTemplates","_registerAppI18n","renderUseBrick","useBrick","data","_runtimeContext$tplSt","_runtimeContext$formS","_output$node","tplStateStoreScope","formStateStoreScope","runtimeContext","_internalApiGetRuntimeContext","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","RendererContext","renderRoot","tag","RenderTag","ROOT","createPortal","transform","strict","isStrictMode","warnAboutStrictMode","output","renderBrick","properties","flushStableLoadBricks","Promise","all","blockingList","map","store","waitForAll","node","portal","Error","child","tagName","type","mountUseBrick","element","portalRoot","document","querySelector","createElement","appendChild","mountTree","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","unmountUseBrick","mountResult","unmountTree","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","computeRealValue","noInject","updateStoryboard","appId","storyboardPatch","storyboard","_internalApiGetStoryboardInBootstrapData","Object","assign","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","registerAppI18n","updateStoryboardByRoute","newRoute","match","getKey","route","path","exact","replaceRoute","routes","key","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","customTemplates","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","pick","updateStoryboardBySnippet","snippetData","_snippetData$bricks","snippetId","length","updateSnippetPreviewSettings","exports","previewRouteIndex","findIndex","newPreviewRoute","menu","splice"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n} from \"./Runtime.js\";\nimport { renderBrick } from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\n\nexport type { RuntimeContext } from \"./interfaces.js\";\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n}\n\nexport async function renderUseBrick(\n useBrick: UseSingleBrickConf,\n data: unknown\n): Promise<RenderUseBrickResult> {\n const tplStateStoreScope: DataStore<\"STATE\">[] = [];\n const formStateStoreScope: DataStore<\"FORM_STATE\">[] = [];\n const runtimeContext: RuntimeContext = {\n ..._internalApiGetRuntimeContext()!,\n data,\n pendingPermissionsPreCheck: [],\n tplStateStoreScope,\n formStateStoreScope,\n };\n\n runtimeContext.tplStateStoreMap ??= new Map();\n runtimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const transform = (useBrick as { transform?: Record<string, unknown> })\n .transform;\n const strict = isStrictMode();\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n useBrick\n );\n }\n\n const output = await renderBrick(\n renderRoot,\n strict\n ? useBrick\n : {\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n runtimeContext,\n rendererContext\n );\n\n flushStableLoadBricks();\n\n await Promise.all([\n ...output.blockingList,\n // Wait for local tpl state stores belong to current `useBrick` only.\n ...[...tplStateStoreScope, ...formStateStoreScope].map((store) =>\n store.waitForAll()\n ),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let match = false;\n const getKey = (route: RouteConf): string => `${route.path}.${route.exact}`;\n const replaceRoute = (routes: RouteConf[], key: string): RouteConf[] => {\n return routes.map((route) => {\n const routeKey = getKey(route);\n if (route.type === \"routes\") {\n route.routes = replaceRoute(route.routes, key);\n return route;\n } else if (routeKey === key) {\n match = true;\n return newRoute;\n } else {\n return route;\n }\n });\n };\n storyboard.routes = replaceRoute(storyboard.routes, getKey(newRoute));\n if (!match) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(settings, \"properties\", \"events\", \"lifeCycle\", \"context\"),\n },\n ]\n );\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetData.snippetId}`,\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }]\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAIA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AAUO,eAAeW,cAAcA,CAClCC,QAA4B,EAC5BC,IAAa,EACkB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA,EAAAC,YAAA;EAC/B,MAAMC,kBAAwC,GAAG,EAAE;EACnD,MAAMC,mBAA8C,GAAG,EAAE;EACzD,MAAMC,cAA8B,GAAG;IACrC,GAAG,IAAAC,sCAA6B,GAAG;IACnC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EAAE;EAAO,CAAC,CAAC,CACtE;AACH;AAEO,MAAMO,4BAA4B,GAAGL,yBAAyB;AAACM,OAAA,CAAAD,4BAAA,GAAAA,4BAAA;AAEtE,SAASR,sBAAsBA,CAC7BlC,KAAa,EACbe,IAAY,EACZc,MAAmB,EACnB;EACA,MAAM;IAAEX;EAAO,CAAC,GAAG,IAAAf,iDAAwC,EAACH,KAAK,CAAE;EACnE,MAAM4C,iBAAiB,GAAG1B,MAAM,CAAC2B,SAAS,CAAE/B,KAAK,IAAKA,KAAK,CAACC,IAAI,KAAKA,IAAI,CAAC;EAC1E,MAAM+B,eAA0B,GAAG;IACjC/B,IAAI;IACJc,MAAM;IACNkB,IAAI,EAAE,KAAK;IACX/B,KAAK,EAAE;EACT,CAAC;EACD,IAAI4B,iBAAiB,KAAK,CAAC,CAAC,EAAE;IAC5B1B,MAAM,CAACG,OAAO,CAACyB,eAAe,CAAC;EACjC,CAAC,MAAM;IACL5B,MAAM,CAAC8B,MAAM,CAACJ,iBAAiB,EAAE,CAAC,EAAEE,eAAe,CAAC;EACtD;AACF"}
|
|
1
|
+
{"version":3,"file":"secret_internals.js","names":["_loader","require","_lodash","_Runtime","_Renderer","_RendererContext","_mount","_enums","_computeRealValue","_isStrictMode","_CustomTemplates","_registerAppI18n","renderUseBrick","useBrick","data","_runtimeContext$tplSt","_runtimeContext$formS","_output$node","tplStateStoreScope","formStateStoreScope","runtimeContext","_internalApiGetRuntimeContext","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","rendererContext","RendererContext","renderRoot","tag","RenderTag","ROOT","createPortal","transform","strict","isStrictMode","warnAboutStrictMode","output","renderBrick","properties","flushStableLoadBricks","Promise","all","blockingList","map","store","waitForAll","node","portal","Error","child","tagName","type","mountUseBrick","element","portalRoot","document","querySelector","createElement","appendChild","mountTree","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","unmountUseBrick","mountResult","unmountTree","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","computeRealValue","noInject","updateStoryboard","appId","storyboardPatch","storyboard","_internalApiGetStoryboardInBootstrapData","Object","assign","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","registerAppI18n","updateStoryboardByRoute","newRoute","match","getKey","route","path","exact","replaceRoute","routes","key","routeKey","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","customTemplates","define","bricks","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","brick","pick","updateStoryboardBySnippet","snippetData","_snippetData$bricks","snippetId","length","updateSnippetPreviewSettings","exports","previewRouteIndex","findIndex","newPreviewRoute","menu","splice"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { flushStableLoadBricks } from \"@next-core/loader\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n} from \"./Runtime.js\";\nimport { renderBrick } from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\n\nexport type { RuntimeContext } from \"./interfaces.js\";\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n}\n\nexport async function renderUseBrick(\n useBrick: UseSingleBrickConf,\n data: unknown\n): Promise<RenderUseBrickResult> {\n const tplStateStoreScope: DataStore<\"STATE\">[] = [];\n const formStateStoreScope: DataStore<\"FORM_STATE\">[] = [];\n const runtimeContext: RuntimeContext = {\n ..._internalApiGetRuntimeContext()!,\n data,\n pendingPermissionsPreCheck: [],\n tplStateStoreScope,\n formStateStoreScope,\n };\n\n runtimeContext.tplStateStoreMap ??= new Map();\n runtimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const transform = (useBrick as { transform?: Record<string, unknown> })\n .transform;\n const strict = isStrictMode();\n if (transform) {\n warnAboutStrictMode(\n strict,\n \"`useBrick.transform`\",\n 'please use \"properties\" instead, check your useBrick:',\n useBrick\n );\n }\n\n const output = await renderBrick(\n renderRoot,\n strict\n ? useBrick\n : {\n ...useBrick,\n properties: {\n ...useBrick.properties,\n ...transform,\n },\n },\n runtimeContext,\n rendererContext\n );\n\n flushStableLoadBricks();\n\n await Promise.all([\n ...output.blockingList,\n // Wait for local tpl state stores belong to current `useBrick` only.\n ...[...tplStateStoreScope, ...formStateStoreScope].map((store) =>\n store.waitForAll()\n ),\n ...runtimeContext.pendingPermissionsPreCheck,\n ]);\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let match = false;\n const getKey = (route: RouteConf): string => `${route.path}.${route.exact}`;\n const replaceRoute = (routes: RouteConf[], key: string): RouteConf[] => {\n return routes.map((route) => {\n const routeKey = getKey(route);\n if (route.type === \"routes\") {\n route.routes = replaceRoute(route.routes, key);\n return route;\n } else if (routeKey === key) {\n match = true;\n return newRoute;\n } else {\n return route;\n }\n });\n };\n storyboard.routes = replaceRoute(storyboard.routes, getKey(newRoute));\n if (!match) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(settings, \"properties\", \"events\", \"lifeCycle\", \"context\"),\n },\n ]\n );\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetData.snippetId}`,\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }]\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAIA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AAUO,eAAeW,cAAcA,CAClCC,QAA4B,EAC5BC,IAAa,EACkB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA,EAAAC,YAAA;EAC/B,MAAMC,kBAAwC,GAAG,EAAE;EACnD,MAAMC,mBAA8C,GAAG,EAA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AAC,EACtE,CAAAD,mBAAA,GAAAD,WAAW,CAACT,MAAM,cAAAU,mBAAA,eAAlBA,mBAAA,CAAoBE,MAAM,GAAGH,WAAW,CAACT,MAAM,GAAG,CAAC;IAAEM,KAAK,EAAE;EAAO,CAAC,CACtE,CAAC;AACH;AAEO,MAAMO,4BAA4B,GAAGL,yBAAyB;AAACM,OAAA,CAAAD,4BAAA,GAAAA,4BAAA;AAEtE,SAASR,sBAAsBA,CAC7BlC,KAAa,EACbe,IAAY,EACZc,MAAmB,EACnB;EACA,MAAM;IAAEX;EAAO,CAAC,GAAG,IAAAf,iDAAwC,EAACH,KAAK,CAAE;EACnE,MAAM4C,iBAAiB,GAAG1B,MAAM,CAAC2B,SAAS,CAAE/B,KAAK,IAAKA,KAAK,CAACC,IAAI,KAAKA,IAAI,CAAC;EAC1E,MAAM+B,eAA0B,GAAG;IACjC/B,IAAI;IACJc,MAAM;IACNkB,IAAI,EAAE,KAAK;IACX/B,KAAK,EAAE;EACT,CAAC;EACD,IAAI4B,iBAAiB,KAAK,CAAC,CAAC,EAAE;IAC5B1B,MAAM,CAACG,OAAO,CAACyB,eAAe,CAAC;EACjC,CAAC,MAAM;IACL5B,MAAM,CAAC8B,MAAM,CAACJ,iBAAiB,EAAE,CAAC,EAAEE,eAAe,CAAC;EACtD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isStrictMode.js","names":["_index","require","isStrictMode","runtimeContext","_ref","_getRuntime","flags","getRuntime","getFeatureFlags","warnAboutStrictMode","strict","message","extraLogs","punctuation","length","console","error","warn"],"sources":["../../src/isStrictMode.ts"],"sourcesContent":["import { getRuntime } from \"./index.js\";\nimport type { RuntimeContext } from \"./internal/interfaces.js\";\n\nexport function isStrictMode(runtimeContext?: RuntimeContext) {\n return !!(\n runtimeContext ? runtimeContext.flags : getRuntime()?.getFeatureFlags()\n )?.[\"brick-next-v3-strict-mode\"];\n}\n\nexport function warnAboutStrictMode(\n strict: boolean,\n message: string,\n ...extraLogs: unknown[]\n) {\n const punctuation = extraLogs.length === 0 ? \"\" : \",\";\n if (strict) {\n // eslint-disable-next-line no-console\n console.error(\n `${message} is dropped in v3 strict mode${punctuation}`,\n ...extraLogs\n );\n } else {\n // eslint-disable-next-line no-console\n console.warn(\n `${message} is deprecated in v3 and will be dropped in strict mode${punctuation}`,\n ...extraLogs\n );\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,SAASC,YAAYA,CAACC,cAA+B,EAAE;EAAA,IAAAC,IAAA,EAAAC,WAAA;EAC5D,OAAO,CAAC,GAAAD,IAAA,GACND,cAAc,GAAGA,cAAc,CAACG,KAAK,IAAAD,WAAA,GAAG,IAAAE,iBAAU,
|
|
1
|
+
{"version":3,"file":"isStrictMode.js","names":["_index","require","isStrictMode","runtimeContext","_ref","_getRuntime","flags","getRuntime","getFeatureFlags","warnAboutStrictMode","strict","message","extraLogs","punctuation","length","console","error","warn"],"sources":["../../src/isStrictMode.ts"],"sourcesContent":["import { getRuntime } from \"./index.js\";\nimport type { RuntimeContext } from \"./internal/interfaces.js\";\n\nexport function isStrictMode(runtimeContext?: RuntimeContext) {\n return !!(\n runtimeContext ? runtimeContext.flags : getRuntime()?.getFeatureFlags()\n )?.[\"brick-next-v3-strict-mode\"];\n}\n\nexport function warnAboutStrictMode(\n strict: boolean,\n message: string,\n ...extraLogs: unknown[]\n) {\n const punctuation = extraLogs.length === 0 ? \"\" : \",\";\n if (strict) {\n // eslint-disable-next-line no-console\n console.error(\n `${message} is dropped in v3 strict mode${punctuation}`,\n ...extraLogs\n );\n } else {\n // eslint-disable-next-line no-console\n console.warn(\n `${message} is deprecated in v3 and will be dropped in strict mode${punctuation}`,\n ...extraLogs\n );\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,SAASC,YAAYA,CAACC,cAA+B,EAAE;EAAA,IAAAC,IAAA,EAAAC,WAAA;EAC5D,OAAO,CAAC,GAAAD,IAAA,GACND,cAAc,GAAGA,cAAc,CAACG,KAAK,IAAAD,WAAA,GAAG,IAAAE,iBAAU,EAAC,CAAC,cAAAF,WAAA,uBAAZA,WAAA,CAAcG,eAAe,CAAC,CAAC,cAAAJ,IAAA,eADhEA,IAAA,CAEL,2BAA2B,CAAC;AAClC;AAEO,SAASK,mBAAmBA,CACjCC,MAAe,EACfC,OAAe,EACf,GAAGC,SAAoB,EACvB;EACA,MAAMC,WAAW,GAAGD,SAAS,CAACE,MAAM,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG;EACrD,IAAIJ,MAAM,EAAE;IACV;IACAK,OAAO,CAACC,KAAK,CACV,GAAEL,OAAQ,gCAA+BE,WAAY,EAAC,EACvD,GAAGD,SACL,CAAC;EACH,CAAC,MAAM;IACL;IACAG,OAAO,CAACE,IAAI,CACT,GAAEN,OAAQ,0DAAyDE,WAAY,EAAC,EACjF,GAAGD,SACL,CAAC;EACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeAndMode.js","names":["_general","require","theme","storage","JsonStorage","localStorage","LOCAL_STORAGE_APPS_THEME_KEY","setTheme","value","Error","getTheme","getCurrentTheme","document","documentElement","dataset","applyTheme","window","dispatchEvent","CustomEvent","detail","batchSetAppsLocalTheme","appsTheme","setItem","getLocalAppsTheme","_result","result","getItem","console","error","mode","setMode","getMode","getCurrentMode","applyMode","getCssPropertyValue","name","el","_window$getComputedSt","getComputedStyle","getPropertyValue"],"sources":["../../src/themeAndMode.ts"],"sourcesContent":["import type { SiteMode, SiteTheme } from \"@next-core/types\";\nimport { JsonStorage } from \"@next-core/utils/general\";\n\ninterface AppThemes {\n [appId: string]: SiteTheme;\n}\n\n// Themes.\nlet theme: SiteTheme = \"light\";\nconst storage = new JsonStorage<Record<string, AppThemes>>(localStorage);\nconst LOCAL_STORAGE_APPS_THEME_KEY = \"apps-theme\";\n\nexport function setTheme(value: SiteTheme): void {\n if (value !== \"dark\" && value !== \"light\" && value !== \"dark-v2\") {\n throw new Error(`Unsupported theme: ${value}`);\n }\n theme = value;\n}\n\nexport function getTheme(): SiteTheme {\n return theme;\n}\n\nexport function getCurrentTheme(): SiteTheme {\n return document.documentElement.dataset.theme as SiteTheme;\n}\n\nexport function applyTheme(value?: SiteTheme): void {\n if (value) {\n setTheme(value);\n } else {\n value = getTheme();\n }\n if (value !== getCurrentTheme()) {\n document.documentElement.dataset.theme = value;\n window.dispatchEvent(\n new CustomEvent<SiteTheme>(\"theme.change\", {\n detail: value,\n })\n );\n }\n}\n\nexport function batchSetAppsLocalTheme(appsTheme: AppThemes): void {\n storage.setItem(LOCAL_STORAGE_APPS_THEME_KEY, {\n ...getLocalAppsTheme(),\n ...appsTheme,\n });\n}\n\nexport function getLocalAppsTheme(): AppThemes {\n let result: AppThemes | undefined;\n try {\n result = storage.getItem(LOCAL_STORAGE_APPS_THEME_KEY);\n } catch {\n // eslint-disable-next-line no-console\n console.error(\"JSON parse error inside `getLocalAppsTheme()`\");\n }\n\n return result ?? {};\n}\n\n// Modes.\nlet mode: SiteMode = \"default\";\n\nexport function setMode(value: SiteMode): void {\n if (value !== \"dashboard\" && value !== \"default\") {\n throw new Error(`Unsupported mode: ${value}`);\n }\n mode = value;\n}\n\nexport function getMode(): SiteMode {\n return mode;\n}\n\nexport function getCurrentMode(): SiteMode {\n return document.documentElement.dataset.mode as SiteMode;\n}\n\nexport function applyMode(value?: SiteMode): void {\n if (value) {\n setMode(value);\n } else {\n value = getMode();\n }\n if (value !== getCurrentMode()) {\n document.documentElement.dataset.mode = value;\n window.dispatchEvent(\n new CustomEvent<SiteMode>(\"mode.change\", {\n detail: value,\n })\n );\n }\n}\n\nexport function getCssPropertyValue(\n name: string,\n el = document.documentElement\n): string {\n if (!el) return \"\";\n return window.getComputedStyle(el)?.getPropertyValue(name) || \"\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMA;AACA,IAAIC,KAAgB,GAAG,OAAO;AAC9B,MAAMC,OAAO,GAAG,IAAIC,oBAAW,CAA4BC,YAAY,CAAC;AACxE,MAAMC,4BAA4B,GAAG,YAAY;AAE1C,SAASC,QAAQA,CAACC,KAAgB,EAAQ;EAC/C,IAAIA,KAAK,KAAK,MAAM,IAAIA,KAAK,KAAK,OAAO,IAAIA,KAAK,KAAK,SAAS,EAAE;IAChE,MAAM,IAAIC,KAAK,CAAE,sBAAqBD,KAAM,EAAC,CAAC;EAChD;EACAN,KAAK,GAAGM,KAAK;AACf;AAEO,SAASE,QAAQA,CAAA,EAAc;EACpC,OAAOR,KAAK;AACd;AAEO,SAASS,eAAeA,CAAA,EAAc;EAC3C,OAAOC,QAAQ,CAACC,eAAe,CAACC,OAAO,CAACZ,KAAK;AAC/C;AAEO,SAASa,UAAUA,CAACP,KAAiB,EAAQ;EAClD,IAAIA,KAAK,EAAE;IACTD,QAAQ,CAACC,KAAK,CAAC;EACjB,CAAC,MAAM;IACLA,KAAK,GAAGE,QAAQ,
|
|
1
|
+
{"version":3,"file":"themeAndMode.js","names":["_general","require","theme","storage","JsonStorage","localStorage","LOCAL_STORAGE_APPS_THEME_KEY","setTheme","value","Error","getTheme","getCurrentTheme","document","documentElement","dataset","applyTheme","window","dispatchEvent","CustomEvent","detail","batchSetAppsLocalTheme","appsTheme","setItem","getLocalAppsTheme","_result","result","getItem","console","error","mode","setMode","getMode","getCurrentMode","applyMode","getCssPropertyValue","name","el","_window$getComputedSt","getComputedStyle","getPropertyValue"],"sources":["../../src/themeAndMode.ts"],"sourcesContent":["import type { SiteMode, SiteTheme } from \"@next-core/types\";\nimport { JsonStorage } from \"@next-core/utils/general\";\n\ninterface AppThemes {\n [appId: string]: SiteTheme;\n}\n\n// Themes.\nlet theme: SiteTheme = \"light\";\nconst storage = new JsonStorage<Record<string, AppThemes>>(localStorage);\nconst LOCAL_STORAGE_APPS_THEME_KEY = \"apps-theme\";\n\nexport function setTheme(value: SiteTheme): void {\n if (value !== \"dark\" && value !== \"light\" && value !== \"dark-v2\") {\n throw new Error(`Unsupported theme: ${value}`);\n }\n theme = value;\n}\n\nexport function getTheme(): SiteTheme {\n return theme;\n}\n\nexport function getCurrentTheme(): SiteTheme {\n return document.documentElement.dataset.theme as SiteTheme;\n}\n\nexport function applyTheme(value?: SiteTheme): void {\n if (value) {\n setTheme(value);\n } else {\n value = getTheme();\n }\n if (value !== getCurrentTheme()) {\n document.documentElement.dataset.theme = value;\n window.dispatchEvent(\n new CustomEvent<SiteTheme>(\"theme.change\", {\n detail: value,\n })\n );\n }\n}\n\nexport function batchSetAppsLocalTheme(appsTheme: AppThemes): void {\n storage.setItem(LOCAL_STORAGE_APPS_THEME_KEY, {\n ...getLocalAppsTheme(),\n ...appsTheme,\n });\n}\n\nexport function getLocalAppsTheme(): AppThemes {\n let result: AppThemes | undefined;\n try {\n result = storage.getItem(LOCAL_STORAGE_APPS_THEME_KEY);\n } catch {\n // eslint-disable-next-line no-console\n console.error(\"JSON parse error inside `getLocalAppsTheme()`\");\n }\n\n return result ?? {};\n}\n\n// Modes.\nlet mode: SiteMode = \"default\";\n\nexport function setMode(value: SiteMode): void {\n if (value !== \"dashboard\" && value !== \"default\") {\n throw new Error(`Unsupported mode: ${value}`);\n }\n mode = value;\n}\n\nexport function getMode(): SiteMode {\n return mode;\n}\n\nexport function getCurrentMode(): SiteMode {\n return document.documentElement.dataset.mode as SiteMode;\n}\n\nexport function applyMode(value?: SiteMode): void {\n if (value) {\n setMode(value);\n } else {\n value = getMode();\n }\n if (value !== getCurrentMode()) {\n document.documentElement.dataset.mode = value;\n window.dispatchEvent(\n new CustomEvent<SiteMode>(\"mode.change\", {\n detail: value,\n })\n );\n }\n}\n\nexport function getCssPropertyValue(\n name: string,\n el = document.documentElement\n): string {\n if (!el) return \"\";\n return window.getComputedStyle(el)?.getPropertyValue(name) || \"\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMA;AACA,IAAIC,KAAgB,G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
|
|
|
1
|
-
{"version":3,"file":"CustomProcessors.js","names":["CustomProcessorRegistry","constructor","_classPrivateFieldInitSpec","_registry","writable","value","Map","define","processorFullName","processorFunc","namespace","processorName","split","pkg","_classPrivateFieldGet","get","set","has","Error","concat","customProcessors"],"sources":["../../src/CustomProcessors.ts"],"sourcesContent":["class CustomProcessorRegistry {\n readonly #registry = new Map<string, Map<string, Function>>();\n\n define(processorFullName: string, processorFunc: Function) {\n // `namespace` should be the camelCase of the package name.\n const [namespace, processorName] = processorFullName.split(\".\");\n let pkg = this.#registry.get(namespace);\n if (!pkg) {\n pkg = new Map();\n this.#registry.set(namespace, pkg);\n }\n if (pkg.has(processorName)) {\n // eslint-disable-next-line no-console\n throw new Error(\n `Custom processor of \"${processorFullName}\" already registered`\n );\n }\n pkg.set(processorName, processorFunc);\n }\n\n get(namespace: string) {\n return this.#registry.get(namespace);\n }\n}\n\nexport const customProcessors = new CustomProcessorRegistry();\n"],"mappings":";;;AAAA,MAAMA,uBAAuB,CAAC;EAAAC,YAAA;IAAAC,0BAAA,OAAAC,SAAA;MAAAC,QAAA;MAAAC,KAAA,EACP,IAAIC,GAAG;
|
|
1
|
+
{"version":3,"file":"CustomProcessors.js","names":["CustomProcessorRegistry","constructor","_classPrivateFieldInitSpec","_registry","writable","value","Map","define","processorFullName","processorFunc","namespace","processorName","split","pkg","_classPrivateFieldGet","get","set","has","Error","concat","customProcessors"],"sources":["../../src/CustomProcessors.ts"],"sourcesContent":["class CustomProcessorRegistry {\n readonly #registry = new Map<string, Map<string, Function>>();\n\n define(processorFullName: string, processorFunc: Function) {\n // `namespace` should be the camelCase of the package name.\n const [namespace, processorName] = processorFullName.split(\".\");\n let pkg = this.#registry.get(namespace);\n if (!pkg) {\n pkg = new Map();\n this.#registry.set(namespace, pkg);\n }\n if (pkg.has(processorName)) {\n // eslint-disable-next-line no-console\n throw new Error(\n `Custom processor of \"${processorFullName}\" already registered`\n );\n }\n pkg.set(processorName, processorFunc);\n }\n\n get(namespace: string) {\n return this.#registry.get(namespace);\n }\n}\n\nexport const customProcessors = new CustomProcessorRegistry();\n"],"mappings":";;;AAAA,MAAMA,uBAAuB,CAAC;EAAAC,YAAA;IAAAC,0BAAA,OAAAC,SAAA;MAAAC,QAAA;MAAAC,KAAA,EACP,IAAIC,GAAG,CAAgC;IAAC;EAAA;EAE7DC,MAAMA,CAACC,iBAAyB,EAAEC,aAAuB,EAAE;IACzD;IACA,IAAM,CAACC,SAAS,EAAEC,aAAa,CAAC,GAAGH,iBAAiB,CAACI,KAAK,CAAC,GAAG,CAAC;IAC/D,IAAIC,GAAG,GAAGC,qBAAA,KAAI,EAAAX,SAAA,EAAWY,GAAG,CAACL,SAAS,CAAC;IACvC,IAAI,CAACG,GAAG,EAAE;MACRA,GAAG,GAAG,IAAIP,GAAG,CAAC,CAAC;MACfQ,qBAAA,KAAI,EAAAX,SAAA,EAAWa,GAAG,CAACN,SAAS,EAAEG,GAAG,CAAC;IACpC;IACA,IAAIA,GAAG,CAACI,GAAG,CAACN,aAAa,CAAC,EAAE;MAC1B;MACA,MAAM,IAAIO,KAAK,0BAAAC,MAAA,CACWX,iBAAiB,0BAC3C,CAAC;IACH;IACAK,GAAG,CAACG,GAAG,CAACL,aAAa,EAAEF,aAAa,CAAC;EACvC;EAEAM,GAAGA,CAACL,SAAiB,EAAE;IACrB,OAAOI,qBAAA,KAAI,EAAAX,SAAA,EAAWY,GAAG,CAACL,SAAS,CAAC;EACtC;AACF;AAEA,OAAO,IAAMU,gBAAgB,GAAG,IAAIpB,uBAAuB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTemplates.js","names":["uniq","isStrictMode","warnAboutStrictMode","allowedNativeProps","Set","_registry","WeakMap","CustomTemplateRegistry","constructor","_classPrivateFieldInitSpec","writable","value","Map","define","tagName","_constructor$proxy$pr","_constructor$proxy","_compatibleConstructo","_compatibleConstructo2","registered","_classPrivateFieldGet","has","console","warn","concat","customElements","get","strict","proxyProperties","proxy","properties","validProxyProps","legacyTplVariables","key","Object","entries","asVariable","push","mergeProperty","refTransform","error","ref","compatibleConstructor","_objectSpread","fromEntries","state","map","item","expose","tpl","name","set","exposedStates","getExposedStates","proxyMethods","methods","props","entry","nativeProps","filter","prop","HTMLElement","prototype","length","Error","p","join","TplElement","$$typeof","_dev_only_definedProperties","_dev_only_definedMethods","$$getElementByRef","_this$$$tplStateStore","_this$$$tplStateStore2","_this$$$tplStateStore3","_this$$$tplStateStore4","$$tplStateStore","hostBrick","tplHostMetadata","internalBricksByRef","element","connectedCallback","shadowRoot","attachShadow","mode","fragment","document","createDocumentFragment","style","createElement","textContent","slot","appendChild","disconnectedCallback","_loop","propName","some","defineProperty","getValue","_this$$$tplStateStore5","updateValue","enumerable","_ret","_loop2","from","to","_to$refProperty","refProperty","_this$$$getElementByR","call","_to$refProperty2","_loop3","_from","_to","_to$refMethod","refMethod","arguments","customTemplates","_state$filter$map"],"sources":["../../src/CustomTemplates.ts"],"sourcesContent":["import type {\n ContextConf,\n CustomTemplate,\n CustomTemplateConstructor,\n CustomTemplateProxyBasicProperty,\n} from \"@next-core/types\";\nimport { uniq } from \"lodash\";\nimport type { RuntimeBrickElement } from \"./internal/interfaces.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"./isStrictMode.js\";\n\n// Note: `prefix` is a native prop on Element, but it's only used in XML documents.\nconst allowedNativeProps = new Set([\"prefix\"]);\n\ninterface LegacyTplPropProxy extends CustomTemplateProxyBasicProperty {\n asVariable?: boolean;\n mergeProperty?: unknown;\n refTransform?: unknown;\n}\n\nclass CustomTemplateRegistry {\n readonly #registry = new Map<string, CustomTemplate>();\n\n define(tagName: string, constructor: CustomTemplateConstructor): void {\n let registered = this.#registry.has(tagName);\n if (registered) {\n // When open launchpad, the storyboard will be updated.\n // However, we can't *undefine* a custom element.\n // Just ignore re-registering custom templates.\n // eslint-disable-next-line no-console\n console.warn(`Custom template of \"${tagName}\" already registered.`);\n } else {\n registered = !!customElements.get(tagName);\n if (registered) {\n // eslint-disable-next-line no-console\n console.warn(\n `Custom template of \"${tagName}\" already defined by customElements.`\n );\n }\n }\n\n // Transform legacy `proxy.properties[].asVariable` as states.\n const strict = isStrictMode();\n const proxyProperties = (constructor.proxy?.properties ?? {}) as {\n [name: string]: LegacyTplPropProxy;\n };\n const validProxyProps: [string, CustomTemplateProxyBasicProperty][] = [];\n const legacyTplVariables: string[] = [];\n for (const [key, value] of Object.entries(proxyProperties)) {\n if (value.asVariable) {\n warnAboutStrictMode(strict, \"Template `asVariable`\", tagName, key);\n // istanbul ignore next\n if (!strict) {\n // For existed TPL usage, treat it as a STATE.\n legacyTplVariables.push(key);\n }\n } else if (value.mergeProperty || value.refTransform) {\n // eslint-disable-next-line no-console\n console.error(\n \"Template `mergeProperty` and `refTransform` are dropped in v3:\",\n tagName,\n key\n );\n } else if (value.ref) {\n validProxyProps.push([key, value]);\n }\n // Else: documentation only, for exposed states.\n }\n\n const compatibleConstructor = {\n ...constructor,\n proxy: {\n ...constructor.proxy,\n properties: Object.fromEntries(validProxyProps),\n },\n state: (constructor.state\n ? strict\n ? constructor.state\n : constructor.state.map((item) => ({\n // Make `expose` defaults to true in non-strict mode.\n expose: true,\n ...item,\n }))\n : []\n ).concat(legacyTplVariables.map((tpl) => ({ name: tpl, expose: true }))),\n };\n\n // Now we allow re-register custom template\n this.#registry.set(tagName, {\n ...compatibleConstructor,\n name: tagName,\n });\n\n const exposedStates = getExposedStates(compatibleConstructor.state);\n const proxyMethods = Object.entries(\n compatibleConstructor.proxy?.methods ?? {}\n );\n\n const props = exposedStates.concat(\n validProxyProps.map((entry) => entry[0])\n );\n const methods = proxyMethods.map((entry) => entry[0]);\n\n const nativeProps = props\n .concat(methods)\n .filter(\n (prop) => prop in HTMLElement.prototype && !allowedNativeProps.has(prop)\n );\n if (nativeProps.length > 0) {\n warnAboutStrictMode(\n strict,\n \"Using native HTMLElement properties as template properties or methods\",\n tagName,\n ...nativeProps\n );\n // istanbul ignore next\n if (strict) {\n throw new Error(\n `In custom template \"${tagName}\", ${nativeProps\n .map((p) => `\"${p}\"`)\n .join(\n \", \"\n )} are native HTMLElement properties, and should be avoid to be used as brick properties or methods.`\n );\n }\n }\n\n if (registered) {\n return;\n }\n\n class TplElement extends HTMLElement {\n get $$typeof() {\n return \"custom-template\" as const;\n }\n\n static get _dev_only_definedProperties(): string[] {\n return props;\n }\n\n static get _dev_only_definedMethods(): string[] {\n return methods;\n }\n\n $$getElementByRef(this: RuntimeBrickElement, ref: string) {\n return this.$$tplStateStore?.hostBrick?.tplHostMetadata?.internalBricksByRef.get(\n ref\n )?.element;\n }\n\n connectedCallback() {\n let shadowRoot = this.shadowRoot;\n if (!shadowRoot) {\n shadowRoot = this.attachShadow({ mode: \"open\" });\n }\n const fragment = document.createDocumentFragment();\n const style = document.createElement(\"style\");\n style.textContent = \":host{display:block}:host([hidden]){display:none}\";\n const slot = document.createElement(\"slot\");\n fragment.appendChild(style);\n fragment.appendChild(slot);\n shadowRoot.appendChild(fragment);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) {\n this.shadowRoot.textContent = \"\";\n }\n }\n }\n\n for (const propName of exposedStates) {\n if (validProxyProps.some((entry) => entry[0] === propName)) {\n // eslint-disable-next-line no-console\n console.error(\n `Cannot define an exposed state that is also a proxy property: \"${propName}\" in ${tagName}`\n );\n continue;\n }\n Object.defineProperty(TplElement.prototype, propName, {\n get(this: RuntimeBrickElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.$$tplStateStore!.getValue(propName);\n },\n set(this: RuntimeBrickElement, value: unknown) {\n // 在 mount 过程中,先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n this.$$tplStateStore?.updateValue(propName, value, \"replace\");\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of validProxyProps) {\n Object.defineProperty(TplElement.prototype, from, {\n get(this: TplElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n unknown\n >;\n return element[to.refProperty ?? from];\n },\n set(this: TplElement, value: unknown) {\n // 同上 exposedState.set\n const element = this.$$getElementByRef?.(to.ref) as unknown as Record<\n string,\n unknown\n >;\n if (element) {\n element[to.refProperty ?? from] = value;\n }\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of proxyMethods) {\n Object.defineProperty(TplElement.prototype, from, {\n value(this: TplElement, ...args: unknown[]) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n Function\n >;\n element[to.refMethod ?? from](...args);\n },\n enumerable: true,\n });\n }\n\n customElements.define(tagName, TplElement);\n }\n\n get(tagName: string) {\n return this.#registry.get(tagName);\n }\n}\n\nexport const customTemplates = new CustomTemplateRegistry();\n\nfunction getExposedStates(state: ContextConf[] | undefined): string[] {\n // Allow duplicated state names which maybe mutually exclusive.\n return uniq(\n state?.filter((item) => item.expose).map((item) => item.name) ?? []\n );\n}\n"],"mappings":";;;AAMA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,mBAAmB;;AAErE;AACA,IAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AAAC,IAAAC,SAAA,oBAAAC,OAAA;AAQ/C,MAAMC,sBAAsB,CAAC;EAAAC,YAAA;IAAAC,0BAAA,OAAAJ,SAAA;MAAAK,QAAA;MAAAC,KAAA,EACN,IAAIC,GAAG;IAA0B;EAAA;EAEtDC,MAAMA,CAACC,OAAe,EAAEN,WAAsC,EAAQ;IAAA,IAAAO,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,sBAAA;IACpE,IAAIC,UAAU,GAAGC,qBAAA,KAAI,EAAAf,SAAA,EAAWgB,GAAG,CAACP,OAAO,CAAC;IAC5C,IAAIK,UAAU,EAAE;MACd;MACA;MACA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AAE;QAChD7F,KAAKA,CAAA,EAAuC;UAAA,IAAAuG,aAAA;UAC1C;UACA,IAAMlC,OAAO,GAAG,IAAI,CAACT,iBAAiB,CAAEkC,GAAE,CAAChE,GAAG,CAG7C;UACDuC,OAAO,EAAAkC,aAAA,GAACT,GAAE,CAACU,SAAS,cAAAD,aAAA,cAAAA,aAAA,GAAIV,KAAI,CAAC,CAAC,GAAAY,SAAO,CAAC;QACxC,CAAC;QACDf,UAAU,EAAE;MACd,CAAC,CAAC;IACJ,CAAC;IAZD,KAAK,IAAM,CAACG,KAAI,EAAEC,GAAE,CAAC,IAAInD,YAAY;MAAAyD,MAAA,CAAAC,KAAA,EAAAC,GAAA;IAAA;IAcrCxF,cAAc,CAACZ,MAAM,CAACC,OAAO,EAAEqD,UAAU,CAAC;EAC5C;EAEAzC,GAAGA,CAACZ,OAAe,EAAE;IACnB,OAAOM,qBAAA,KAAI,EAAAf,SAAA,EAAWqB,GAAG,CAACZ,OAAO,CAAC;EACpC;AACF;AAEA,OAAO,IAAMuG,eAAe,GAAG,IAAI9G,sBAAsB,EAAE;AAE3D,SAAS8C,gBAAgBA,CAACR,KAAgC,EAAY;EAAA,IAAAyE,iBAAA;EACpE;EACA,OAAOtH,IAAI,EAAAsH,iBAAA,GACTzE,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEc,MAAM,CAAEZ,IAAI,IAAKA,IAAI,CAACC,MAAM,CAAC,CAACF,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACG,IAAI,CAAC,cAAAoE,iBAAA,cAAAA,iBAAA,GAAI,EAAE,CACpE;AACH"}
|
|
1
|
+
{"version":3,"file":"CustomTemplates.js","names":["uniq","isStrictMode","warnAboutStrictMode","allowedNativeProps","Set","_registry","WeakMap","CustomTemplateRegistry","constructor","_classPrivateFieldInitSpec","writable","value","Map","define","tagName","_constructor$proxy$pr","_constructor$proxy","_compatibleConstructo","_compatibleConstructo2","registered","_classPrivateFieldGet","has","console","warn","concat","customElements","get","strict","proxyProperties","proxy","properties","validProxyProps","legacyTplVariables","key","Object","entries","asVariable","push","mergeProperty","refTransform","error","ref","compatibleConstructor","_objectSpread","fromEntries","state","map","item","expose","tpl","name","set","exposedStates","getExposedStates","proxyMethods","methods","props","entry","nativeProps","filter","prop","HTMLElement","prototype","length","Error","p","join","TplElement","$$typeof","_dev_only_definedProperties","_dev_only_definedMethods","$$getElementByRef","_this$$$tplStateStore","_this$$$tplStateStore2","_this$$$tplStateStore3","_this$$$tplStateStore4","$$tplStateStore","hostBrick","tplHostMetadata","internalBricksByRef","element","connectedCallback","shadowRoot","attachShadow","mode","fragment","document","createDocumentFragment","style","createElement","textContent","slot","appendChild","disconnectedCallback","_loop","propName","some","defineProperty","getValue","_this$$$tplStateStore5","updateValue","enumerable","_ret","_loop2","from","to","_to$refProperty","refProperty","_this$$$getElementByR","call","_to$refProperty2","_loop3","_from","_to","_to$refMethod","refMethod","arguments","customTemplates","_state$filter$map"],"sources":["../../src/CustomTemplates.ts"],"sourcesContent":["import type {\n ContextConf,\n CustomTemplate,\n CustomTemplateConstructor,\n CustomTemplateProxyBasicProperty,\n} from \"@next-core/types\";\nimport { uniq } from \"lodash\";\nimport type { RuntimeBrickElement } from \"./internal/interfaces.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"./isStrictMode.js\";\n\n// Note: `prefix` is a native prop on Element, but it's only used in XML documents.\nconst allowedNativeProps = new Set([\"prefix\"]);\n\ninterface LegacyTplPropProxy extends CustomTemplateProxyBasicProperty {\n asVariable?: boolean;\n mergeProperty?: unknown;\n refTransform?: unknown;\n}\n\nclass CustomTemplateRegistry {\n readonly #registry = new Map<string, CustomTemplate>();\n\n define(tagName: string, constructor: CustomTemplateConstructor): void {\n let registered = this.#registry.has(tagName);\n if (registered) {\n // When open launchpad, the storyboard will be updated.\n // However, we can't *undefine* a custom element.\n // Just ignore re-registering custom templates.\n // eslint-disable-next-line no-console\n console.warn(`Custom template of \"${tagName}\" already registered.`);\n } else {\n registered = !!customElements.get(tagName);\n if (registered) {\n // eslint-disable-next-line no-console\n console.warn(\n `Custom template of \"${tagName}\" already defined by customElements.`\n );\n }\n }\n\n // Transform legacy `proxy.properties[].asVariable` as states.\n const strict = isStrictMode();\n const proxyProperties = (constructor.proxy?.properties ?? {}) as {\n [name: string]: LegacyTplPropProxy;\n };\n const validProxyProps: [string, CustomTemplateProxyBasicProperty][] = [];\n const legacyTplVariables: string[] = [];\n for (const [key, value] of Object.entries(proxyProperties)) {\n if (value.asVariable) {\n warnAboutStrictMode(strict, \"Template `asVariable`\", tagName, key);\n // istanbul ignore next\n if (!strict) {\n // For existed TPL usage, treat it as a STATE.\n legacyTplVariables.push(key);\n }\n } else if (value.mergeProperty || value.refTransform) {\n // eslint-disable-next-line no-console\n console.error(\n \"Template `mergeProperty` and `refTransform` are dropped in v3:\",\n tagName,\n key\n );\n } else if (value.ref) {\n validProxyProps.push([key, value]);\n }\n // Else: documentation only, for exposed states.\n }\n\n const compatibleConstructor = {\n ...constructor,\n proxy: {\n ...constructor.proxy,\n properties: Object.fromEntries(validProxyProps),\n },\n state: (constructor.state\n ? strict\n ? constructor.state\n : constructor.state.map((item) => ({\n // Make `expose` defaults to true in non-strict mode.\n expose: true,\n ...item,\n }))\n : []\n ).concat(legacyTplVariables.map((tpl) => ({ name: tpl, expose: true }))),\n };\n\n // Now we allow re-register custom template\n this.#registry.set(tagName, {\n ...compatibleConstructor,\n name: tagName,\n });\n\n const exposedStates = getExposedStates(compatibleConstructor.state);\n const proxyMethods = Object.entries(\n compatibleConstructor.proxy?.methods ?? {}\n );\n\n const props = exposedStates.concat(\n validProxyProps.map((entry) => entry[0])\n );\n const methods = proxyMethods.map((entry) => entry[0]);\n\n const nativeProps = props\n .concat(methods)\n .filter(\n (prop) => prop in HTMLElement.prototype && !allowedNativeProps.has(prop)\n );\n if (nativeProps.length > 0) {\n warnAboutStrictMode(\n strict,\n \"Using native HTMLElement properties as template properties or methods\",\n tagName,\n ...nativeProps\n );\n // istanbul ignore next\n if (strict) {\n throw new Error(\n `In custom template \"${tagName}\", ${nativeProps\n .map((p) => `\"${p}\"`)\n .join(\n \", \"\n )} are native HTMLElement properties, and should be avoid to be used as brick properties or methods.`\n );\n }\n }\n\n if (registered) {\n return;\n }\n\n class TplElement extends HTMLElement {\n get $$typeof() {\n return \"custom-template\" as const;\n }\n\n static get _dev_only_definedProperties(): string[] {\n return props;\n }\n\n static get _dev_only_definedMethods(): string[] {\n return methods;\n }\n\n $$getElementByRef(this: RuntimeBrickElement, ref: string) {\n return this.$$tplStateStore?.hostBrick?.tplHostMetadata?.internalBricksByRef.get(\n ref\n )?.element;\n }\n\n connectedCallback() {\n let shadowRoot = this.shadowRoot;\n if (!shadowRoot) {\n shadowRoot = this.attachShadow({ mode: \"open\" });\n }\n const fragment = document.createDocumentFragment();\n const style = document.createElement(\"style\");\n style.textContent = \":host{display:block}:host([hidden]){display:none}\";\n const slot = document.createElement(\"slot\");\n fragment.appendChild(style);\n fragment.appendChild(slot);\n shadowRoot.appendChild(fragment);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) {\n this.shadowRoot.textContent = \"\";\n }\n }\n }\n\n for (const propName of exposedStates) {\n if (validProxyProps.some((entry) => entry[0] === propName)) {\n // eslint-disable-next-line no-console\n console.error(\n `Cannot define an exposed state that is also a proxy property: \"${propName}\" in ${tagName}`\n );\n continue;\n }\n Object.defineProperty(TplElement.prototype, propName, {\n get(this: RuntimeBrickElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.$$tplStateStore!.getValue(propName);\n },\n set(this: RuntimeBrickElement, value: unknown) {\n // 在 mount 过程中,先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n this.$$tplStateStore?.updateValue(propName, value, \"replace\");\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of validProxyProps) {\n Object.defineProperty(TplElement.prototype, from, {\n get(this: TplElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n unknown\n >;\n return element[to.refProperty ?? from];\n },\n set(this: TplElement, value: unknown) {\n // 同上 exposedState.set\n const element = this.$$getElementByRef?.(to.ref) as unknown as Record<\n string,\n unknown\n >;\n if (element) {\n element[to.refProperty ?? from] = value;\n }\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of proxyMethods) {\n Object.defineProperty(TplElement.prototype, from, {\n value(this: TplElement, ...args: unknown[]) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n Function\n >;\n element[to.refMethod ?? from](...args);\n },\n enumerable: true,\n });\n }\n\n customElements.define(tagName, TplElement);\n }\n\n get(tagName: string) {\n return this.#registry.get(tagName);\n }\n}\n\nexport const customTemplates = new CustomTemplateRegistry();\n\nfunction getExposedStates(state: ContextConf[] | undefined): string[] {\n // Allow duplicated state names which maybe mutually exclusive.\n return uniq(\n state?.filter((item) => item.expose).map((item) => item.name) ?? []\n );\n}\n"],"mappings":";;;AAMA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,mBAAmB;;AAErE;AACA,IAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AAAC,IAAAC,SAAA,oBAAAC,OAAA;AAQ/C,MAAMC,sBAAsB,CAAC;EAAAC,YAAA;IAAAC,0BAAA,OAAAJ,SAAA;MAAAK,QAAA;MAAAC,KAAA,EACN,IAAIC,GAAG,CAAyB;IAAC;EAAA;EAEtDC,MAAMA,CAACC,OAAe,EAAEN,WAAsC,EAAQ;IAAA,IAAAO,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,sBAAA;IACpE,IAAIC,UAAU,GAAGC,qBAAA,KAAI,EAAAf,SAAA,EAAWgB,GAAG,CAACP,OAAO,CAAC;IAC5C,IAAIK,UAAU,EAAE;MACd;MACA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