@next-core/runtime 1.22.9 → 1.22.11
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 +16 -1
- package/dist/cjs/CustomProcessors.js.map +1 -1
- package/dist/cjs/CustomTemplates.js +17 -2
- package/dist/cjs/CustomTemplates.js.map +1 -1
- package/dist/cjs/getV2RuntimeFromDll.js +16 -0
- package/dist/cjs/getV2RuntimeFromDll.js.map +1 -0
- package/dist/cjs/history.js +13 -14
- package/dist/cjs/history.js.map +1 -1
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/Runtime.js +35 -3
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/cjs/internal/compute/WidgetFunctions.js +15 -3
- package/dist/cjs/internal/compute/WidgetFunctions.js.map +1 -1
- package/dist/cjs/internal/compute/WidgetI18n.js +15 -4
- package/dist/cjs/internal/compute/WidgetI18n.js.map +1 -1
- package/dist/cjs/internal/compute/checkIf.js +15 -2
- package/dist/cjs/internal/compute/checkIf.js.map +1 -1
- package/dist/esm/CustomProcessors.js +16 -1
- package/dist/esm/CustomProcessors.js.map +1 -1
- package/dist/esm/CustomTemplates.js +16 -1
- package/dist/esm/CustomTemplates.js.map +1 -1
- package/dist/esm/getV2RuntimeFromDll.js +10 -0
- package/dist/esm/getV2RuntimeFromDll.js.map +1 -0
- package/dist/esm/history.js +9 -11
- package/dist/esm/history.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/Runtime.js +33 -1
- package/dist/esm/internal/Runtime.js.map +1 -1
- package/dist/esm/internal/compute/WidgetFunctions.js +13 -1
- package/dist/esm/internal/compute/WidgetFunctions.js.map +1 -1
- package/dist/esm/internal/compute/WidgetI18n.js +13 -2
- package/dist/esm/internal/compute/WidgetI18n.js.map +1 -1
- package/dist/esm/internal/compute/checkIf.js +13 -1
- package/dist/esm/internal/compute/checkIf.js.map +1 -1
- package/dist/types/getV2RuntimeFromDll.d.ts +21 -0
- package/dist/types/history.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/internal/Renderer.d.ts +1 -1
- package/dist/types/internal/Runtime.d.ts +1 -1
- package/dist/types/internal/compute/WidgetFunctions.d.ts +1 -1
- package/dist/types/internal/compute/WidgetI18n.d.ts +1 -1
- package/dist/types/internal/compute/checkIf.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkIf.js","names":["_general","require","_computeRealValue","_evaluate","_resolveData","asyncCheckIf","ifContainer","runtimeContext","hasOwnProperty","if","isPreEvaluated","asyncComputeRealValue","checkIf","computeRealValue","checkIfOfComputed","asyncCheckBrickIf","brickConf","isObject","resolved","resolveData","
|
|
1
|
+
{"version":3,"file":"checkIf.js","names":["_general","require","_computeRealValue","_evaluate","_resolveData","_getV2RuntimeFromDll","asyncCheckIf","ifContainer","runtimeContext","hasOwnProperty","if","isPreEvaluated","asyncComputeRealValue","checkIf","computeRealValue","checkIfOfComputed","asyncCheckBrickIf","brickConf","isObject","resolved","resolveData","checkIfByTransformV3","data","checkIfByTransformV2Factory","v2Kit","getV2RuntimeFromDll","looseCheckIfByTransform","checkIfByTransform","exports"],"sources":["../../../../src/internal/compute/checkIf.ts"],"sourcesContent":["import { hasOwnProperty, isObject } from \"@next-core/utils/general\";\nimport type { BrickConf, ResolveConf } from \"@next-core/types\";\nimport { asyncComputeRealValue, computeRealValue } from \"./computeRealValue.js\";\nimport { isPreEvaluated } from \"./evaluate.js\";\nimport { resolveData } from \"../data/resolveData.js\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { getV2RuntimeFromDll } from \"../../getV2RuntimeFromDll.js\";\n\n/**\n * 包含 `if` 条件判断的对象。\n */\nexport interface IfContainer {\n /**\n * 条件判断,可以为表达式字符串。\n *\n * @example\n *\n * ```yaml\n * - brick: your.any-brick\n * if: '<% FLAGS[\"your-feature-flag\"] %>'\n * ```\n */\n if?: unknown;\n}\n\nexport async function asyncCheckIf(\n ifContainer: IfContainer,\n runtimeContext: RuntimeContext\n): Promise<boolean> {\n return (\n !hasOwnProperty(ifContainer, \"if\") ||\n !!(typeof ifContainer.if === \"string\" || isPreEvaluated(ifContainer.if)\n ? await asyncComputeRealValue(ifContainer.if, runtimeContext)\n : ifContainer.if)\n );\n}\n\nexport function checkIf(\n ifContainer: IfContainer,\n runtimeContext: RuntimeContext\n): boolean {\n return (\n !hasOwnProperty(ifContainer, \"if\") ||\n !!(typeof ifContainer.if === \"string\" || isPreEvaluated(ifContainer.if)\n ? computeRealValue(ifContainer.if, runtimeContext)\n : ifContainer.if)\n );\n}\n\nexport function checkIfOfComputed(ifContainer: IfContainer): boolean {\n return !hasOwnProperty(ifContainer, \"if\") || !!ifContainer.if;\n}\n\nexport async function asyncCheckBrickIf(\n brickConf: BrickConf,\n runtimeContext: RuntimeContext\n): Promise<boolean> {\n if (isObject(brickConf.if) && !isPreEvaluated(brickConf.if)) {\n const resolved = (await resolveData(\n brickConf.if as ResolveConf,\n runtimeContext\n )) as { if?: unknown };\n return checkIfOfComputed(resolved);\n }\n return asyncCheckIf(brickConf, runtimeContext);\n}\n\nfunction checkIfByTransformV3(ifContainer: IfContainer, data: unknown) {\n return checkIf(ifContainer, { data } as RuntimeContext);\n}\n\n// istanbul ignore next\nfunction checkIfByTransformV2Factory() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return v2Kit.looseCheckIfByTransform;\n }\n}\n\n// istanbul ignore next\nexport const checkIfByTransform =\n checkIfByTransformV2Factory() || checkIfByTransformV3;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,oBAAA,GAAAJ,OAAA;AAEA;AACA;AACA;;AA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ACrE,OAAOT,OAAO,CAACN,WAAW,EAAE;IAAEe;EAAK,CAAmB,CAAC;AACzD;;AAEA;AACA,SAASC,2BAA2BA,CAAA,EAAG;EACrC,MAAMC,KAAK,GAAG,IAAAC,wCAAmB,EAAC,CAAC;EACnC,IAAID,KAAK,EAAE;IACT,OAAOA,KAAK,CAACE,uBAAuB;EACtC;AACF;;AAEA;AACO,MAAMC,kBAAkB,GAC7BJ,2BAA2B,CAAC,CAAC,IAAIF,oBAAoB;AAACO,OAAA,CAAAD,kBAAA,GAAAA,kBAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _classPrivateFieldInitSpec from "@babel/runtime/helpers/classPrivateFieldInitSpec";
|
|
2
2
|
import _classPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
|
|
3
|
+
import { getV2RuntimeFromDll } from "./getV2RuntimeFromDll.js";
|
|
3
4
|
var _registry = /*#__PURE__*/new WeakMap();
|
|
4
5
|
class CustomProcessorRegistry {
|
|
5
6
|
constructor() {
|
|
@@ -26,5 +27,19 @@ class CustomProcessorRegistry {
|
|
|
26
27
|
return _classPrivateFieldGet(this, _registry).get(namespace);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
|
|
31
|
+
// istanbul ignore next
|
|
32
|
+
function getCustomProcessorsV2() {
|
|
33
|
+
var v2Kit = getV2RuntimeFromDll();
|
|
34
|
+
if (v2Kit) {
|
|
35
|
+
return Object.freeze({
|
|
36
|
+
define(processorFullName, processorFunc) {
|
|
37
|
+
return v2Kit.getRuntime().registerCustomProcessor(processorFullName, processorFunc);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// istanbul ignore next
|
|
44
|
+
export var customProcessors = getCustomProcessorsV2() || new CustomProcessorRegistry();
|
|
30
45
|
//# sourceMappingURL=CustomProcessors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomProcessors.js","names":["CustomProcessorRegistry","constructor","_classPrivateFieldInitSpec","
|
|
1
|
+
{"version":3,"file":"CustomProcessors.js","names":["getV2RuntimeFromDll","_registry","WeakMap","CustomProcessorRegistry","constructor","_classPrivateFieldInitSpec","writable","value","Map","define","processorFullName","processorFunc","namespace","processorName","split","pkg","_classPrivateFieldGet","get","set","has","Error","concat","getCustomProcessorsV2","v2Kit","Object","freeze","getRuntime","registerCustomProcessor","customProcessors"],"sources":["../../src/CustomProcessors.ts"],"sourcesContent":["import { getV2RuntimeFromDll } from \"./getV2RuntimeFromDll.js\";\n\nclass 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\n// istanbul ignore next\nfunction getCustomProcessorsV2() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return Object.freeze({\n define(processorFullName: string, processorFunc: Function) {\n return v2Kit\n .getRuntime()\n .registerCustomProcessor(processorFullName, processorFunc);\n },\n }) as CustomProcessorRegistry;\n }\n}\n\n// istanbul ignore next\nexport const customProcessors =\n getCustomProcessorsV2() || new CustomProcessorRegistry();\n"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,0BAA0B;AAAC,IAAAC,SAAA,oBAAAC,OAAA;AAE/D,MAAMC,uBAAuB,CAAC;EAAAC,YAAA;IAAAC,0BAAA,OAAAJ,SAAA;MAAAK,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,EAAAf,SAAA,EAAWgB,GAAG,CAACL,SAAS,CAAC;IACvC,IAAI,CAACG,GAAG,EAAE;MACRA,GAAG,GAAG,IAAIP,GAAG,CAAC,CAAC;MACfQ,qBAAA,KAAI,EAAAf,SAAA,EAAWiB,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,EAAAf,SAAA,EAAWgB,GAAG,CAACL,SAAS,CAAC;EACtC;AACF;;AAEA;AACA,SAASU,qBAAqBA,CAAA,EAAG;EAC/B,IAAMC,KAAK,GAAGvB,mBAAmB,CAAC,CAAC;EACnC,IAAIuB,KAAK,EAAE;IACT,OAAOC,MAAM,CAACC,MAAM,CAAC;MACnBhB,MAAMA,CAACC,iBAAyB,EAAEC,aAAuB,EAAE;QACzD,OAAOY,KAAK,CACTG,UAAU,CAAC,CAAC,CACZC,uBAAuB,CAACjB,iBAAiB,EAAEC,aAAa,CAAC;MAC9D;IACF,CAAC,CAAC;EACJ;AACF;;AAEA;AACA,OAAO,IAAMiB,gBAAgB,GAC3BN,qBAAqB,CAAC,CAAC,IAAI,IAAInB,uBAAuB,CAAC,CAAC"}
|
|
@@ -3,6 +3,7 @@ import _classPrivateFieldInitSpec from "@babel/runtime/helpers/classPrivateField
|
|
|
3
3
|
import _classPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
|
|
4
4
|
import { uniq } from "lodash";
|
|
5
5
|
import { isStrictMode, warnAboutStrictMode } from "./isStrictMode.js";
|
|
6
|
+
import { getV2RuntimeFromDll } from "./getV2RuntimeFromDll.js";
|
|
6
7
|
|
|
7
8
|
// Note: `prefix` is a native prop on Element, but it's only used in XML documents.
|
|
8
9
|
var allowedNativeProps = new Set(["prefix"]);
|
|
@@ -186,10 +187,24 @@ class CustomTemplateRegistry {
|
|
|
186
187
|
return _classPrivateFieldGet(this, _registry).get(tagName);
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
|
-
export var customTemplates = new CustomTemplateRegistry();
|
|
190
190
|
function getExposedStates(state) {
|
|
191
191
|
var _state$filter$map;
|
|
192
192
|
// Allow duplicated state names which maybe mutually exclusive.
|
|
193
193
|
return uniq((_state$filter$map = state === null || state === void 0 ? void 0 : state.filter(item => item.expose).map(item => item.name)) !== null && _state$filter$map !== void 0 ? _state$filter$map : []);
|
|
194
194
|
}
|
|
195
|
+
|
|
196
|
+
// istanbul ignore next
|
|
197
|
+
function getCustomTemplatesV2() {
|
|
198
|
+
var v2Kit = getV2RuntimeFromDll();
|
|
199
|
+
if (v2Kit) {
|
|
200
|
+
return Object.freeze({
|
|
201
|
+
define(tagName, constructor) {
|
|
202
|
+
return v2Kit.getRuntime().registerCustomTemplate(tagName, constructor);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// istanbul ignore next
|
|
209
|
+
export var customTemplates = getCustomTemplatesV2() || new CustomTemplateRegistry();
|
|
195
210
|
//# sourceMappingURL=CustomTemplates.js.map
|
|
@@ -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","$$tplStateStore","hostBrick","tplHostMetadata","internalBricksByRef","element","connectedCallback","shadowRoot","attachShadow","mode","fragment","document","createDocumentFragment","style","createElement","textContent","slot","appendChild","disconnectedCallback","_loop","propName","some","defineProperty","getValue","_this$$$tplStateStore2","updateValue","enumerable","_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;MACA;MACA;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aAAA;UAC1C;UACA,IAAMjC,OAAO,GAAG,IAAI,CAACN,iBAAiB,CAAE8B,GAAE,CAAC5D,GAAG,CAG7C;UACDoC,OAAO,EAAAiC,aAAA,GAACT,GAAE,CAACU,SAAS,cAAAD,aAAA,cAAAA,aAAA,GAAIV,KAAI,CAAC,CAAC,GAAAY,SAAO,CAAC;QACxC,CAAC;QACDd,UAAU,EAAE;MACd,CAAC,CAAC;IACJ,CAAC;IAZD,KAAK,IAAM,CAACE,KAAI,EAAEC,GAAE,CAAC,IAAI/C,YAAY;MAAAqD,MAAA,CAAAC,KAAA,EAAAC,GAAA;IAAA;IAcrCpF,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,IAAMmG,eAAe,GAAG,IAAI1G,sBAAsB,CAAC,CAAC;AAE3D,SAAS8C,gBAAgBA,CAACR,KAAgC,EAAY;EAAA,IAAAqE,iBAAA;EACpE;EACA,OAAOlH,IAAI,EAAAkH,iBAAA,GACTrE,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEc,MAAM,CAAEZ,IAAI,IAAKA,IAAI,CAACC,MAAM,CAAC,CAACF,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACG,IAAI,CAAC,cAAAgE,iBAAA,cAAAA,iBAAA,GAAI,EACnE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"CustomTemplates.js","names":["uniq","isStrictMode","warnAboutStrictMode","getV2RuntimeFromDll","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","$$tplStateStore","hostBrick","tplHostMetadata","internalBricksByRef","element","connectedCallback","shadowRoot","attachShadow","mode","fragment","document","createDocumentFragment","style","createElement","textContent","slot","appendChild","disconnectedCallback","_loop","propName","some","defineProperty","getValue","_this$$$tplStateStore2","updateValue","enumerable","_loop2","from","to","_to$refProperty","refProperty","_this$$$getElementByR","call","_to$refProperty2","_loop3","_from","_to","_to$refMethod","refMethod","arguments","_state$filter$map","getCustomTemplatesV2","v2Kit","freeze","getRuntime","registerCustomTemplate","customTemplates"],"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\";\nimport { getV2RuntimeFromDll } from \"./getV2RuntimeFromDll.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\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\n// istanbul ignore next\nfunction getCustomTemplatesV2() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return Object.freeze({\n define(tagName: string, constructor: CustomTemplateConstructor) {\n return v2Kit.getRuntime().registerCustomTemplate(tagName, constructor);\n },\n }) as CustomTemplateRegistry;\n }\n}\n\n// istanbul ignore next\nexport const customTemplates =\n getCustomTemplatesV2() || new CustomTemplateRegistry();\n"],"mappings":";;;AAMA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,mBAAmB;AACrE,SAASC,mBAAmB,QAAQ,0BAA0B;;AAE9D;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,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AAK,GAAGjH,mBAAmB,CAAC,CAAC;EACnC,IAAIiH,KAAK,EAAE;IACT,OAAOjF,MAAM,CAACkF,MAAM,CAAC;MACnBvG,MAAMA,CAACC,OAAe,EAAEN,WAAsC,EAAE;QAC9D,OAAO2G,KAAK,CAACE,UAAU,CAAC,CAAC,CAACC,sBAAsB,CAACxG,OAAO,EAAEN,WAAW,CAAC;MACxE;IACF,CAAC,CAAC;EACJ;AACF;;AAEA;AACA,OAAO,IAAM+G,eAAe,GAC1BL,oBAAoB,CAAC,CAAC,IAAI,IAAI3G,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function getV2RuntimeFromDll() {
|
|
2
|
+
var _window$BRICK_NEXT_VE;
|
|
3
|
+
var {
|
|
4
|
+
dll
|
|
5
|
+
} = window;
|
|
6
|
+
if (dll && (_window$BRICK_NEXT_VE = window.BRICK_NEXT_VERSIONS) !== null && _window$BRICK_NEXT_VE !== void 0 && (_window$BRICK_NEXT_VE = _window$BRICK_NEXT_VE["brick-container"]) !== null && _window$BRICK_NEXT_VE !== void 0 && _window$BRICK_NEXT_VE.startsWith("2.")) {
|
|
7
|
+
return dll("tYg3");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=getV2RuntimeFromDll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getV2RuntimeFromDll.js","names":["getV2RuntimeFromDll","_window$BRICK_NEXT_VE","dll","window","BRICK_NEXT_VERSIONS","startsWith"],"sources":["../../src/getV2RuntimeFromDll.ts"],"sourcesContent":["import type {\n CustomTemplateConstructor,\n MetaI18n,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport type { NextHistory } from \"./history.js\";\nimport type { IfContainer } from \"./internal/compute/checkIf.js\";\n\ninterface DLL {\n (moduleId: \"tYg3\"): Kit;\n}\n\ninterface Kit {\n getRuntime(): {\n registerCustomTemplate(\n tagName: string,\n constructor: CustomTemplateConstructor\n ): void;\n registerCustomProcessor(\n processorFullName: string,\n processorFunc: Function\n ): void;\n };\n getHistory(): NextHistory;\n registerWidgetFunctions(\n widgetId: string,\n functions: StoryboardFunction[],\n widgetVersion?: string\n ): void;\n registerWidgetI18n(widgetId: string, i18nData: MetaI18n): void;\n looseCheckIfByTransform(ifContainer: IfContainer, data: unknown): boolean;\n SingleBrickAsComponentFactory: any;\n BrickAsComponentFactory: any;\n authenticate: any;\n getAuth: any;\n isLoggedIn: any;\n logout: any;\n}\n\nexport function getV2RuntimeFromDll() {\n const { dll } = window as { dll?: DLL };\n if (\n dll &&\n window.BRICK_NEXT_VERSIONS?.[\"brick-container\"]?.startsWith(\"2.\")\n ) {\n return dll(\"tYg3\");\n }\n}\n"],"mappings":"AAuCA,OAAO,SAASA,mBAAmBA,CAAA,EAAG;EAAA,IAAAC,qBAAA;EACpC,IAAM;IAAEC;EAAI,CAAC,GAAGC,MAAuB;EACvC,IACED,GAAG,KAAAD,qBAAA,GACHE,MAAM,CAACC,mBAAmB,cAAAH,qBAAA,gBAAAA,qBAAA,GAA1BA,qBAAA,CAA6B,iBAAiB,CAAC,cAAAA,qBAAA,eAA/CA,qBAAA,CAAiDI,UAAU,CAAC,IAAI,CAAC,EACjE;IACA,OAAOH,GAAG,CAAC,MAAM,CAAC;EACpB;AACF"}
|
package/dist/esm/history.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createBrowserHistory } from "history";
|
|
2
2
|
import { getBasePath } from "./getBasePath.js";
|
|
3
3
|
import { getUserConfirmation, historyExtended } from "./internal/historyExtended.js";
|
|
4
|
+
import { getV2RuntimeFromDll } from "./getV2RuntimeFromDll.js";
|
|
4
5
|
var history;
|
|
5
6
|
export function createHistory() {
|
|
6
7
|
if (!history) {
|
|
@@ -14,21 +15,18 @@ export function createHistory() {
|
|
|
14
15
|
}
|
|
15
16
|
return history;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return (_history = history) !== null && _history !== void 0 ? _history : getV2History();
|
|
18
|
+
function getHistoryV3() {
|
|
19
|
+
return history;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* When using v3 bricks in v2
|
|
23
|
+
* When using v3 bricks in v2 container, return history from v2 container.
|
|
24
24
|
*/
|
|
25
|
-
function
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (typeof dll === "function") {
|
|
30
|
-
var LegacyBrickKit = dll("tYg3");
|
|
31
|
-
return LegacyBrickKit.getHistory();
|
|
25
|
+
function getHistoryV2Factory() {
|
|
26
|
+
var v2Kit = getV2RuntimeFromDll();
|
|
27
|
+
if (v2Kit) {
|
|
28
|
+
return v2Kit.getHistory;
|
|
32
29
|
}
|
|
33
30
|
}
|
|
31
|
+
export var getHistory = getHistoryV2Factory() || getHistoryV3;
|
|
34
32
|
//# sourceMappingURL=history.js.map
|
package/dist/esm/history.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","names":["createBrowserHistory","getBasePath","getUserConfirmation","historyExtended","history","createHistory","browserHistory","basename","replace","Object","assign","
|
|
1
|
+
{"version":3,"file":"history.js","names":["createBrowserHistory","getBasePath","getUserConfirmation","historyExtended","getV2RuntimeFromDll","history","createHistory","browserHistory","basename","replace","Object","assign","getHistoryV3","getHistoryV2Factory","v2Kit","getHistory"],"sources":["../../src/history.ts"],"sourcesContent":["import { History, Location, createBrowserHistory } from \"history\";\nimport { getBasePath } from \"./getBasePath.js\";\nimport {\n type ExtendedHistory,\n getUserConfirmation,\n historyExtended,\n NextHistoryState,\n} from \"./internal/historyExtended.js\";\nimport { getV2RuntimeFromDll } from \"./getV2RuntimeFromDll.js\";\n\nexport type NextHistory = History<NextHistoryState> & ExtendedHistory;\n\nlet history: NextHistory;\n\nexport function createHistory(): NextHistory {\n if (!history) {\n // https://github.com/remix-run/history/issues/810\n const browserHistory = createBrowserHistory<NextHistoryState>({\n basename: getBasePath().replace(/\\/$/, \"\"),\n getUserConfirmation,\n });\n Object.assign(browserHistory, historyExtended(browserHistory));\n history = browserHistory as NextHistory;\n }\n return history;\n}\n\nfunction getHistoryV3(): NextHistory {\n return history;\n}\n\n/**\n * When using v3 bricks in v2 container, return history from v2 container.\n */\nfunction getHistoryV2Factory() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return v2Kit.getHistory;\n }\n}\n\nexport const getHistory = getHistoryV2Factory() || getHistoryV3;\n\nexport type NextLocation = Location<NextHistoryState>;\n\nexport type { NextHistoryState };\n"],"mappings":"AAAA,SAA4BA,oBAAoB,QAAQ,SAAS;AACjE,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAEEC,mBAAmB,EACnBC,eAAe,QAEV,+BAA+B;AACtC,SAASC,mBAAmB,QAAQ,0BAA0B;AAI9D,IAAIC,OAAoB;AAExB,OAAO,SAASC,aAAaA,CAAA,EAAgB;EAC3C,IAAI,CAACD,OAAO,EAAE;IACZ;IACA,IAAME,cAAc,GAAGP,oBAAoB,CAAmB;MAC5DQ,QAAQ,EAAEP,WAAW,CAAC,CAAC,CAACQ,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;MAC1CP;IACF,CAAC,CAAC;IACFQ,MAAM,CAACC,MAAM,CAACJ,cAAc,EAAEJ,eAAe,CAACI,cAAc,CAAC,CAAC;IAC9DF,OAAO,GAAGE,cAA6B;EACzC;EACA,OAAOF,OAAO;AAChB;AAEA,SAASO,YAAYA,CAAA,EAAgB;EACnC,OAAOP,OAAO;AAChB;;AAEA;AACA;AACA;AACA,SAASQ,mBAAmBA,CAAA,EAAG;EAC7B,IAAMC,KAAK,GAAGV,mBAAmB,CAAC,CAAC;EACnC,IAAIU,KAAK,EAAE;IACT,OAAOA,KAAK,CAACC,UAAU;EACzB;AACF;AAEA,OAAO,IAAMA,UAAU,GAAGF,mBAAmB,CAAC,CAAC,IAAID,YAAY"}
|
package/dist/esm/index.js
CHANGED
|
@@ -19,4 +19,5 @@ export { StoryboardFunctionRegistryFactory } from "./StoryboardFunctionRegistry.
|
|
|
19
19
|
export { matchPath } from "./internal/matchPath.js";
|
|
20
20
|
export { Notification } from "./Notification.js";
|
|
21
21
|
export { Dialog } from "./Dialog.js";
|
|
22
|
+
export * from "./getV2RuntimeFromDll.js";
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createRuntime","getRuntime","__secret_internals","__test_only","getCssPropertyValue","getCurrentTheme","getCurrentMode","batchSetAppsLocalTheme","applyTheme","checkIfOfComputed","checkIfByTransform","registerWidgetFunctions","registerWidgetI18n","StoryboardFunctionRegistryFactory","matchPath","Notification","Dialog"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport * from \"./createRoot.js\";\nexport {\n createRuntime,\n getRuntime,\n type RuntimeOptions,\n type RuntimeHooks,\n type RuntimeHooksMenuHelpers,\n type ImagesFactory,\n type PageViewInfo,\n} from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport { __test_only } from \"./internal/test_only.js\";\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,SACEA,aAAa,EACbC,UAAU,QAML,uBAAuB;AAC9B,OAAO,KAAKC,kBAAkB,MAAM,gCAAgC;AACpE,SAASA,kBAAkB;AAC3B,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SACEC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,mBAAmB;AAC1B,SACEC,iBAAiB,EACjBC,kBAAkB,QACb,+BAA+B;AACtC,SAASC,uBAAuB,QAAQ,uCAAuC;AAC/E,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,iCAAiC,QAAQ,iCAAiC;AACnF,SAASC,SAAS,QAAQ,yBAAyB;AACnD,SAASC,YAAY,QAAkC,mBAAmB;AAC1E,SAASC,MAAM,QAA4B,aAAa"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["createRuntime","getRuntime","__secret_internals","__test_only","getCssPropertyValue","getCurrentTheme","getCurrentMode","batchSetAppsLocalTheme","applyTheme","checkIfOfComputed","checkIfByTransform","registerWidgetFunctions","registerWidgetI18n","StoryboardFunctionRegistryFactory","matchPath","Notification","Dialog"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport * from \"./createRoot.js\";\nexport {\n createRuntime,\n getRuntime,\n type RuntimeOptions,\n type RuntimeHooks,\n type RuntimeHooksMenuHelpers,\n type ImagesFactory,\n type PageViewInfo,\n} from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport { __test_only } from \"./internal/test_only.js\";\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\nexport * from \"./getV2RuntimeFromDll.js\";\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,SACEA,aAAa,EACbC,UAAU,QAML,uBAAuB;AAC9B,OAAO,KAAKC,kBAAkB,MAAM,gCAAgC;AACpE,SAASA,kBAAkB;AAC3B,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SACEC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,mBAAmB;AAC1B,SACEC,iBAAiB,EACjBC,kBAAkB,QACb,+BAA+B;AACtC,SAASC,uBAAuB,QAAQ,uCAAuC;AAC/E,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,iCAAiC,QAAQ,iCAAiC;AACnF,SAASC,SAAS,QAAQ,yBAAyB;AACnD,SAASC,YAAY,QAAkC,mBAAmB;AAC1E,SAASC,MAAM,QAA4B,aAAa;AACxD,cAAc,0BAA0B"}
|
|
@@ -17,6 +17,7 @@ import { loadDialogService } from "../Dialog.js";
|
|
|
17
17
|
import { injectedBrickPackages } from "./injected.js";
|
|
18
18
|
import { hasInstalledApp } from "./hasInstalledApp.js";
|
|
19
19
|
import { listenDevtoolsEagerly } from "./devtools.js";
|
|
20
|
+
import { getV2RuntimeFromDll } from "../getV2RuntimeFromDll.js";
|
|
20
21
|
var runtime;
|
|
21
22
|
|
|
22
23
|
// Allow inject bootstrap data in a runtime other than Brick Next.
|
|
@@ -38,9 +39,40 @@ export function createRuntime(options) {
|
|
|
38
39
|
runtime = new Runtime();
|
|
39
40
|
return runtime;
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
function getRuntimeV3() {
|
|
42
43
|
return runtime;
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
// istanbul ignore next
|
|
47
|
+
function getRuntimeV2Factory() {
|
|
48
|
+
var v2Kit = getV2RuntimeFromDll();
|
|
49
|
+
if (v2Kit) {
|
|
50
|
+
return function getRuntimeV2() {
|
|
51
|
+
return new Proxy(v2Kit.getRuntime(), {
|
|
52
|
+
get() {
|
|
53
|
+
var key = arguments.length <= 1 ? undefined : arguments[1];
|
|
54
|
+
switch (key) {
|
|
55
|
+
case "getCurrentApp":
|
|
56
|
+
case "hasInstalledApp":
|
|
57
|
+
case "getDesktops":
|
|
58
|
+
case "getLaunchpadSettings":
|
|
59
|
+
case "getLaunchpadSiteMap":
|
|
60
|
+
case "toggleLaunchpadEffect":
|
|
61
|
+
case "applyPageTitle":
|
|
62
|
+
case "getNavConfig":
|
|
63
|
+
case "getFeatureFlags":
|
|
64
|
+
case "getMiscSettings":
|
|
65
|
+
case "getBrandSettings":
|
|
66
|
+
return Reflect.get(...arguments);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// istanbul ignore next
|
|
75
|
+
export var getRuntime = getRuntimeV2Factory() || getRuntimeV3;
|
|
44
76
|
var _initialized = /*#__PURE__*/new WeakMap();
|
|
45
77
|
var _bootstrapped = /*#__PURE__*/new WeakMap();
|
|
46
78
|
export class Runtime {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Runtime.js","names":["i18n","initializeI18n","loadBricksImperatively","deepFreeze","isObject","moment","createHistory","matchStoryboard","Router","NS","locales","loadNotificationService","loadDialogService","injectedBrickPackages","hasInstalledApp","listenDevtoolsEagerly","runtime","bootstrapData","router","hooks","createRuntime","options","Error","locale","language","on","Runtime","getRuntime","_initialized","WeakMap","_bootstrapped","constructor","_classPrivateFieldInitSpec","writable","value","initialize","data","_data$settings$preset","_data$settings","_classPrivateFieldGet","_classPrivateFieldSet","normalizeBootstrapData","notification","dialog","settings","presetBricks","loadBricks","bootstrap","_this","_asyncToGenerator","storyboards","getRecentApps","_router$getRecentApps","_router","getCurrentApp","_router2","currentApp","appId","matchVersion","getFeatureFlags","_bootstrapData","_router3","_objectSpread","featureFlags","config","getMiscSettings","_bootstrapData2","_router4","misc","getBrandSettings","_bootstrapData3","base_title","brand","getLaunchpadSettings","_bootstrapData4","columns","rows","launchpad","getDesktops","_bootstrapData$deskto","_bootstrapData5","desktops","getLaunchpadSiteMap","_bootstrapData$siteSo","_bootstrapData6","siteSort","toggleLaunchpadEffect","open","document","body","classList","toggle","applyPageTitle","pageTitle","baseTitle","title","concat","getNavConfig","_router5","bricks","getBrickPackages","Array","isArray","_loop","app","ns","id","Object","entries","forEach","_ref","lang","resources","addResourceBundle","localeName","getFixedT","name","keys","removeResourceBundle","brickPackages","_ref2","_ref3","_bootstrapData$brickP","_bootstrapData7","window","STANDALONE_BRICK_PACKAGES","_internalApiGetRenderId","_router6","getRenderId","_internalApiMatchStoryboard","pathname","_bootstrapData$storyb","_bootstrapData8","_internalApiGetRuntimeContext","_router7","getRuntimeContext","_internalApiGetStoryboardInBootstrapData","_bootstrapData9","find","storyboard","_internalApiGetAppInBootstrapData","_internalApiGetStoryb","_test_only_setBootstrapData","process","env","NODE_ENV"],"sources":["../../../src/internal/Runtime.ts"],"sourcesContent":["import type {\n RuntimeStoryboard,\n BootstrapSettings,\n FeatureFlags,\n BootstrapData,\n Contract,\n Storyboard,\n BrickConf,\n RouteConf,\n ResolveConf,\n BrickPackage,\n} from \"@next-core/types\";\nimport { i18n, initializeI18n } from \"@next-core/i18n\";\nimport { loadBricksImperatively } from \"@next-core/loader\";\nimport { deepFreeze, isObject } from \"@next-core/utils/general\";\nimport type { PermissionApi_validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\nimport moment from \"moment\";\nimport \"moment/locale/zh-cn.js\";\nimport { createHistory } from \"../history.js\";\nimport { matchStoryboard } from \"./matchStoryboard.js\";\nimport { Router } from \"./Router.js\";\nimport { NS, locales } from \"./i18n.js\";\nimport { loadNotificationService } from \"../Notification.js\";\nimport { loadDialogService } from \"../Dialog.js\";\nimport { injectedBrickPackages } from \"./injected.js\";\nimport { type AppForCheck, hasInstalledApp } from \"./hasInstalledApp.js\";\nimport type { RuntimeContext } from \"./interfaces.js\";\nimport { listenDevtoolsEagerly } from \"./devtools.js\";\n\nlet runtime: Runtime;\n\n// Allow inject bootstrap data in a runtime other than Brick Next.\nlet bootstrapData: BootstrapData | undefined;\nlet router: Router | undefined;\n\nexport interface RuntimeOptions {\n hooks?: RuntimeHooks;\n}\n\nexport interface ImagesFactory {\n get(name: string): string;\n}\n\nexport interface PageViewInfo {\n status: \"ok\" | \"failed\" | \"redirected\" | \"not-found\";\n path?: string;\n pageTitle?: string;\n}\n\nexport interface RuntimeHooks {\n auth?: {\n getAuth(): object;\n isLoggedIn(): boolean;\n authenticate?(...args: unknown[]): unknown;\n logout?(...args: unknown[]): unknown;\n };\n fulfilStoryboard?: (storyboard: RuntimeStoryboard) => Promise<void>;\n validatePermissions?: typeof PermissionApi_validatePermissions;\n checkPermissions?: {\n checkPermissions(...actions: string[]): boolean;\n preCheckPermissions(storyboard: Storyboard): Promise<void> | undefined;\n preCheckPermissionsForBrickOrRoute(\n container: BrickConf | RouteConf,\n asyncComputeRealValue: (value: unknown) => Promise<unknown>\n ): Promise<void> | undefined;\n };\n checkInstalledApps?: {\n preCheckInstalledApps(\n storyboard: Storyboard,\n hasAppInBootstrap: (appId: string) => boolean\n ): void;\n waitForCheckingApps(appIds: string[]): Promise<void>;\n getCheckedApp(appId: string): AppForCheck | undefined;\n };\n flowApi?: {\n FLOW_API_PROVIDER: string;\n registerFlowApiProvider(): void;\n isFlowApiProvider(provider: string): boolean;\n getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string\n ): Promise<unknown[]>;\n collectContract(contracts: Contract[] | undefined): void;\n collectWidgetContract(contracts: Contract[] | undefined): void;\n clearCollectWidgetContract(): void;\n };\n menu?: {\n getMenuById(menuId: string): unknown;\n fetchMenuById(\n menuId: string,\n runtimeContext: RuntimeContext,\n runtimeHelpers: RuntimeHooksMenuHelpers\n ): Promise<unknown>;\n };\n images?: {\n imagesFactory(\n appId: string,\n isBuildPush?: boolean,\n version?: string\n ): ImagesFactory;\n widgetImagesFactory(\n widgetId: string,\n widgetVersion?: string\n ): ImagesFactory;\n };\n messageDispatcher?: {\n subscribe(...args: unknown[]): Promise<unknown>;\n unsubscribe(...args: unknown[]): Promise<unknown>;\n onMessage(channel: string, listener: (data: unknown) => void): void;\n onClose(listener: () => void): void;\n reset(): void;\n };\n pageView?: {\n create(): (info: PageViewInfo) => void;\n };\n}\n\nexport interface RuntimeHooksMenuHelpers {\n getStoryboardByAppId(appId: string): Storyboard | undefined;\n resolveData(\n resolveConf: ResolveConf,\n runtimeContext: RuntimeContext\n ): Promise<unknown>;\n asyncComputeRealValue(\n value: unknown,\n runtimeContext: RuntimeContext,\n options?: { ignoreSymbols?: boolean; noInject?: boolean }\n ): Promise<unknown>;\n}\n\nexport let hooks: RuntimeHooks | undefined;\n\nexport function createRuntime(options?: RuntimeOptions) {\n if (runtime) {\n throw new Error(\"Cannot create multiple runtimes\");\n }\n listenDevtoolsEagerly();\n hooks = options?.hooks;\n initializeI18n(NS, locales);\n moment.locale(i18n.language);\n i18n.on(\"languageChanged\", () => {\n moment.locale(i18n.language);\n });\n createHistory();\n runtime = new Runtime();\n return runtime;\n}\n\nexport function getRuntime() {\n return runtime;\n}\n\nexport class Runtime {\n #initialized = false;\n #bootstrapped = false;\n\n initialize(data: BootstrapData) {\n if (this.#initialized) {\n throw new Error(\"The runtime cannot be initialized more than once\");\n }\n this.#initialized = true;\n normalizeBootstrapData(data);\n bootstrapData = data;\n const { notification, dialog } = (data.settings?.presetBricks ?? {}) as {\n notification?: string | false;\n dialog?: string | false;\n };\n if (notification !== false) {\n loadNotificationService(\n notification ?? \"basic.show-notification\",\n this.loadBricks\n );\n }\n if (dialog !== false) {\n loadDialogService(dialog ?? \"basic.show-dialog\", this.loadBricks);\n }\n }\n\n async bootstrap(data?: BootstrapData) {\n if (data) {\n this.initialize(data);\n }\n if (this.#bootstrapped) {\n throw new Error(\"The runtime cannot be bootstrapped more than once\");\n }\n this.#bootstrapped = true;\n router = new Router(bootstrapData!.storyboards!);\n await router.bootstrap();\n }\n\n getRecentApps() {\n return router?.getRecentApps() ?? {};\n }\n\n getCurrentApp() {\n return router?.getRecentApps().currentApp;\n }\n\n hasInstalledApp(appId: string, matchVersion?: string): boolean {\n return hasInstalledApp(appId, matchVersion);\n }\n\n getFeatureFlags(): FeatureFlags {\n return {\n ...bootstrapData?.settings?.featureFlags,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.featureFlags,\n \"migrate-to-brick-next-v3\": true,\n };\n }\n\n getMiscSettings() {\n return {\n ...bootstrapData?.settings?.misc,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.misc,\n };\n }\n\n getBrandSettings(): Record<string, string> {\n return {\n base_title: \"DevOps 管理专家\",\n ...(bootstrapData?.settings?.brand as Record<string, string>),\n };\n }\n\n getLaunchpadSettings() {\n return {\n columns: 7,\n rows: 4,\n ...bootstrapData?.settings?.launchpad,\n };\n }\n\n getDesktops(): unknown[] {\n return bootstrapData?.desktops ?? [];\n }\n\n getLaunchpadSiteMap(): unknown[] {\n return bootstrapData?.siteSort ?? [];\n }\n\n toggleLaunchpadEffect(open: boolean): void {\n document.body.classList.toggle(\"launchpad-open\", open);\n }\n\n applyPageTitle(pageTitle: string): void {\n const baseTitle = this.getBrandSettings().base_title;\n document.title = pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle;\n }\n\n getNavConfig() {\n return router?.getNavConfig();\n }\n\n loadBricks(bricks: string[] | Set<string>) {\n return loadBricksImperatively(bricks, getBrickPackages());\n }\n}\n\nfunction normalizeBootstrapData(data: BootstrapData) {\n if (Array.isArray(data.storyboards)) {\n for (const { app } of data.storyboards) {\n if (app.locales) {\n // Prefix to avoid conflict between brick package's i18n namespace.\n const ns = `tmp/${app.id}`;\n // Support any languages in `app.locales`.\n Object.entries(app.locales).forEach(([lang, resources]) => {\n i18n.addResourceBundle(lang, ns, resources);\n });\n // Use `app.name` as the fallback `app.localeName`.\n app.localeName = i18n.getFixedT(null, ns)(\"name\", app.name) as string;\n // Remove the temporary i18n resource bundles.\n Object.keys(app.locales).forEach((lang) => {\n i18n.removeResourceBundle(lang, ns);\n });\n } else {\n app.localeName = app.name;\n }\n }\n }\n if (isObject(data.settings)) {\n deepFreeze(data.settings);\n }\n if (data.brickPackages) {\n deepFreeze(data.brickPackages);\n }\n}\n\nexport function getBrickPackages() {\n return (\n bootstrapData?.brickPackages ??\n injectedBrickPackages ??\n (window.STANDALONE_BRICK_PACKAGES as BrickPackage[]) ??\n []\n );\n}\n\nexport function _internalApiGetRenderId(): string | undefined {\n return router?.getRenderId();\n}\n\nexport function _internalApiMatchStoryboard(\n pathname: string\n): RuntimeStoryboard | undefined {\n return matchStoryboard(bootstrapData?.storyboards ?? [], pathname);\n}\n\nexport function _internalApiGetRuntimeContext() {\n return router?.getRuntimeContext();\n}\n\nexport function _internalApiGetStoryboardInBootstrapData(appId: string) {\n return bootstrapData?.storyboards?.find(\n (storyboard) => storyboard.app.id === appId\n );\n}\n\nexport function _internalApiGetAppInBootstrapData(appId: string) {\n return _internalApiGetStoryboardInBootstrapData(appId)?.app;\n}\n\nexport let _test_only_setBootstrapData: (data: BootstrapData) => void;\n\n// istanbul ignore next\nif (process.env.NODE_ENV === \"test\") {\n _test_only_setBootstrapData = (data) => {\n bootstrapData = data as BootstrapData;\n };\n}\n"],"mappings":";;;;;AAYA,SAASA,IAAI,EAAEC,cAAc,QAAQ,iBAAiB;AACtD,SAASC,sBAAsB,QAAQ,mBAAmB;AAC1D,SAASC,UAAU,EAAEC,QAAQ,QAAQ,0BAA0B;AAE/D,OAAOC,MAAM,MAAM,QAAQ;AAC3B,OAAO,wBAAwB;AAC/B,SAASC,aAAa,QAAQ,eAAe;AAC7C,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,EAAE,EAAEC,OAAO,QAAQ,WAAW;AACvC,SAASC,uBAAuB,QAAQ,oBAAoB;AAC5D,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAA2BC,eAAe,QAAQ,sBAAsB;AAExE,SAASC,qBAAqB,QAAQ,eAAe;AAErD,IAAIC,OAAgB;;AAEpB;AACA,IAAIC,aAAwC;AAC5C,IAAIC,MAA0B;AAkG9B,OAAO,IAAIC,KAA+B;AAE1C,OAAO,SAASC,aAAaA,CAACC,OAAwB,EAAE;EACtD,IAAIL,OAAO,EAAE;IACX,MAAM,IAAIM,KAAK,CAAC,iCAAiC,CAAC;EACpD;EACAP,qBAAqB,CAAC,CAAC;EACvBI,KAAK,GAAGE,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEF,KAAK;EACtBlB,cAAc,CAACQ,EAAE,EAAEC,OAAO,CAAC;EAC3BL,MAAM,CAACkB,MAAM,CAACvB,IAAI,CA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CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;EACnCH,2BAA2B,GAAI1G,IAAI,IAAK;IACtCnB,aAAa,GAAGmB,IAAqB;EACvC,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"Runtime.js","names":["i18n","initializeI18n","loadBricksImperatively","deepFreeze","isObject","moment","createHistory","matchStoryboard","Router","NS","locales","loadNotificationService","loadDialogService","injectedBrickPackages","hasInstalledApp","listenDevtoolsEagerly","getV2RuntimeFromDll","runtime","bootstrapData","router","hooks","createRuntime","options","Error","locale","language","on","Runtime","getRuntimeV3","getRuntimeV2Factory","v2Kit","getRuntimeV2","Proxy","getRuntime","get","key","arguments","length","undefined","Reflect","_initialized","WeakMap","_bootstrapped","constructor","_classPrivateFieldInitSpec","writable","value","initialize","data","_data$settings$preset","_data$settings","_classPrivateFieldGet","_classPrivateFieldSet","normalizeBootstrapData","notification","dialog","settings","presetBricks","loadBricks","bootstrap","_this","_asyncToGenerator","storyboards","getRecentApps","_router$getRecentApps","_router","getCurrentApp","_router2","currentApp","appId","matchVersion","getFeatureFlags","_bootstrapData","_router3","_objectSpread","featureFlags","config","getMiscSettings","_bootstrapData2","_router4","misc","getBrandSettings","_bootstrapData3","base_title","brand","getLaunchpadSettings","_bootstrapData4","columns","rows","launchpad","getDesktops","_bootstrapData$deskto","_bootstrapData5","desktops","getLaunchpadSiteMap","_bootstrapData$siteSo","_bootstrapData6","siteSort","toggleLaunchpadEffect","open","document","body","classList","toggle","applyPageTitle","pageTitle","baseTitle","title","concat","getNavConfig","_router5","bricks","getBrickPackages","Array","isArray","_loop","app","ns","id","Object","entries","forEach","_ref","lang","resources","addResourceBundle","localeName","getFixedT","name","keys","removeResourceBundle","brickPackages","_ref2","_ref3","_bootstrapData$brickP","_bootstrapData7","window","STANDALONE_BRICK_PACKAGES","_internalApiGetRenderId","_router6","getRenderId","_internalApiMatchStoryboard","pathname","_bootstrapData$storyb","_bootstrapData8","_internalApiGetRuntimeContext","_router7","getRuntimeContext","_internalApiGetStoryboardInBootstrapData","_bootstrapData9","find","storyboard","_internalApiGetAppInBootstrapData","_internalApiGetStoryb","_test_only_setBootstrapData","process","env","NODE_ENV"],"sources":["../../../src/internal/Runtime.ts"],"sourcesContent":["import type {\n RuntimeStoryboard,\n BootstrapSettings,\n FeatureFlags,\n BootstrapData,\n Contract,\n Storyboard,\n BrickConf,\n RouteConf,\n ResolveConf,\n BrickPackage,\n} from \"@next-core/types\";\nimport { i18n, initializeI18n } from \"@next-core/i18n\";\nimport { loadBricksImperatively } from \"@next-core/loader\";\nimport { deepFreeze, isObject } from \"@next-core/utils/general\";\nimport type { PermissionApi_validatePermissions } from \"@next-api-sdk/micro-app-sdk\";\nimport moment from \"moment\";\nimport \"moment/locale/zh-cn.js\";\nimport { createHistory } from \"../history.js\";\nimport { matchStoryboard } from \"./matchStoryboard.js\";\nimport { Router } from \"./Router.js\";\nimport { NS, locales } from \"./i18n.js\";\nimport { loadNotificationService } from \"../Notification.js\";\nimport { loadDialogService } from \"../Dialog.js\";\nimport { injectedBrickPackages } from \"./injected.js\";\nimport { type AppForCheck, hasInstalledApp } from \"./hasInstalledApp.js\";\nimport type { RuntimeContext } from \"./interfaces.js\";\nimport { listenDevtoolsEagerly } from \"./devtools.js\";\nimport { getV2RuntimeFromDll } from \"../getV2RuntimeFromDll.js\";\n\nlet runtime: Runtime;\n\n// Allow inject bootstrap data in a runtime other than Brick Next.\nlet bootstrapData: BootstrapData | undefined;\nlet router: Router | undefined;\n\nexport interface RuntimeOptions {\n hooks?: RuntimeHooks;\n}\n\nexport interface ImagesFactory {\n get(name: string): string;\n}\n\nexport interface PageViewInfo {\n status: \"ok\" | \"failed\" | \"redirected\" | \"not-found\";\n path?: string;\n pageTitle?: string;\n}\n\nexport interface RuntimeHooks {\n auth?: {\n getAuth(): object;\n isLoggedIn(): boolean;\n authenticate?(...args: unknown[]): unknown;\n logout?(...args: unknown[]): unknown;\n };\n fulfilStoryboard?: (storyboard: RuntimeStoryboard) => Promise<void>;\n validatePermissions?: typeof PermissionApi_validatePermissions;\n checkPermissions?: {\n checkPermissions(...actions: string[]): boolean;\n preCheckPermissions(storyboard: Storyboard): Promise<void> | undefined;\n preCheckPermissionsForBrickOrRoute(\n container: BrickConf | RouteConf,\n asyncComputeRealValue: (value: unknown) => Promise<unknown>\n ): Promise<void> | undefined;\n };\n checkInstalledApps?: {\n preCheckInstalledApps(\n storyboard: Storyboard,\n hasAppInBootstrap: (appId: string) => boolean\n ): void;\n waitForCheckingApps(appIds: string[]): Promise<void>;\n getCheckedApp(appId: string): AppForCheck | undefined;\n };\n flowApi?: {\n FLOW_API_PROVIDER: string;\n registerFlowApiProvider(): void;\n isFlowApiProvider(provider: string): boolean;\n getArgsOfFlowApi(\n provider: string,\n originalArgs: unknown[],\n method?: string\n ): Promise<unknown[]>;\n collectContract(contracts: Contract[] | undefined): void;\n collectWidgetContract(contracts: Contract[] | undefined): void;\n clearCollectWidgetContract(): void;\n };\n menu?: {\n getMenuById(menuId: string): unknown;\n fetchMenuById(\n menuId: string,\n runtimeContext: RuntimeContext,\n runtimeHelpers: RuntimeHooksMenuHelpers\n ): Promise<unknown>;\n };\n images?: {\n imagesFactory(\n appId: string,\n isBuildPush?: boolean,\n version?: string\n ): ImagesFactory;\n widgetImagesFactory(\n widgetId: string,\n widgetVersion?: string\n ): ImagesFactory;\n };\n messageDispatcher?: {\n subscribe(...args: unknown[]): Promise<unknown>;\n unsubscribe(...args: unknown[]): Promise<unknown>;\n onMessage(channel: string, listener: (data: unknown) => void): void;\n onClose(listener: () => void): void;\n reset(): void;\n };\n pageView?: {\n create(): (info: PageViewInfo) => void;\n };\n}\n\nexport interface RuntimeHooksMenuHelpers {\n getStoryboardByAppId(appId: string): Storyboard | undefined;\n resolveData(\n resolveConf: ResolveConf,\n runtimeContext: RuntimeContext\n ): Promise<unknown>;\n asyncComputeRealValue(\n value: unknown,\n runtimeContext: RuntimeContext,\n options?: { ignoreSymbols?: boolean; noInject?: boolean }\n ): Promise<unknown>;\n}\n\nexport let hooks: RuntimeHooks | undefined;\n\nexport function createRuntime(options?: RuntimeOptions) {\n if (runtime) {\n throw new Error(\"Cannot create multiple runtimes\");\n }\n listenDevtoolsEagerly();\n hooks = options?.hooks;\n initializeI18n(NS, locales);\n moment.locale(i18n.language);\n i18n.on(\"languageChanged\", () => {\n moment.locale(i18n.language);\n });\n createHistory();\n runtime = new Runtime();\n return runtime;\n}\n\nfunction getRuntimeV3() {\n return runtime;\n}\n\n// istanbul ignore next\nfunction getRuntimeV2Factory() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return function getRuntimeV2() {\n return new Proxy(v2Kit.getRuntime(), {\n get(...args) {\n const key = args[1];\n switch (key) {\n case \"getCurrentApp\":\n case \"hasInstalledApp\":\n case \"getDesktops\":\n case \"getLaunchpadSettings\":\n case \"getLaunchpadSiteMap\":\n case \"toggleLaunchpadEffect\":\n case \"applyPageTitle\":\n case \"getNavConfig\":\n case \"getFeatureFlags\":\n case \"getMiscSettings\":\n case \"getBrandSettings\":\n return Reflect.get(...args);\n }\n },\n }) as unknown as Runtime;\n };\n }\n}\n\n// istanbul ignore next\nexport const getRuntime = getRuntimeV2Factory() || getRuntimeV3;\n\nexport class Runtime {\n #initialized = false;\n #bootstrapped = false;\n\n initialize(data: BootstrapData) {\n if (this.#initialized) {\n throw new Error(\"The runtime cannot be initialized more than once\");\n }\n this.#initialized = true;\n normalizeBootstrapData(data);\n bootstrapData = data;\n const { notification, dialog } = (data.settings?.presetBricks ?? {}) as {\n notification?: string | false;\n dialog?: string | false;\n };\n if (notification !== false) {\n loadNotificationService(\n notification ?? \"basic.show-notification\",\n this.loadBricks\n );\n }\n if (dialog !== false) {\n loadDialogService(dialog ?? \"basic.show-dialog\", this.loadBricks);\n }\n }\n\n async bootstrap(data?: BootstrapData) {\n if (data) {\n this.initialize(data);\n }\n if (this.#bootstrapped) {\n throw new Error(\"The runtime cannot be bootstrapped more than once\");\n }\n this.#bootstrapped = true;\n router = new Router(bootstrapData!.storyboards!);\n await router.bootstrap();\n }\n\n getRecentApps() {\n return router?.getRecentApps() ?? {};\n }\n\n getCurrentApp() {\n return router?.getRecentApps().currentApp;\n }\n\n hasInstalledApp(appId: string, matchVersion?: string): boolean {\n return hasInstalledApp(appId, matchVersion);\n }\n\n getFeatureFlags(): FeatureFlags {\n return {\n ...bootstrapData?.settings?.featureFlags,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.featureFlags,\n \"migrate-to-brick-next-v3\": true,\n };\n }\n\n getMiscSettings() {\n return {\n ...bootstrapData?.settings?.misc,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.misc,\n };\n }\n\n getBrandSettings(): Record<string, string> {\n return {\n base_title: \"DevOps 管理专家\",\n ...(bootstrapData?.settings?.brand as Record<string, string>),\n };\n }\n\n getLaunchpadSettings() {\n return {\n columns: 7,\n rows: 4,\n ...bootstrapData?.settings?.launchpad,\n };\n }\n\n getDesktops(): unknown[] {\n return bootstrapData?.desktops ?? [];\n }\n\n getLaunchpadSiteMap(): unknown[] {\n return bootstrapData?.siteSort ?? [];\n }\n\n toggleLaunchpadEffect(open: boolean): void {\n document.body.classList.toggle(\"launchpad-open\", open);\n }\n\n applyPageTitle(pageTitle: string): void {\n const baseTitle = this.getBrandSettings().base_title;\n document.title = pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle;\n }\n\n getNavConfig() {\n return router?.getNavConfig();\n }\n\n loadBricks(bricks: string[] | Set<string>) {\n return loadBricksImperatively(bricks, getBrickPackages());\n }\n}\n\nfunction normalizeBootstrapData(data: BootstrapData) {\n if (Array.isArray(data.storyboards)) {\n for (const { app } of data.storyboards) {\n if (app.locales) {\n // Prefix to avoid conflict between brick package's i18n namespace.\n const ns = `tmp/${app.id}`;\n // Support any languages in `app.locales`.\n Object.entries(app.locales).forEach(([lang, resources]) => {\n i18n.addResourceBundle(lang, ns, resources);\n });\n // Use `app.name` as the fallback `app.localeName`.\n app.localeName = i18n.getFixedT(null, ns)(\"name\", app.name) as string;\n // Remove the temporary i18n resource bundles.\n Object.keys(app.locales).forEach((lang) => {\n i18n.removeResourceBundle(lang, ns);\n });\n } else {\n app.localeName = app.name;\n }\n }\n }\n if (isObject(data.settings)) {\n deepFreeze(data.settings);\n }\n if (data.brickPackages) {\n deepFreeze(data.brickPackages);\n }\n}\n\nexport function getBrickPackages() {\n return (\n bootstrapData?.brickPackages ??\n injectedBrickPackages ??\n (window.STANDALONE_BRICK_PACKAGES as BrickPackage[]) ??\n []\n );\n}\n\nexport function _internalApiGetRenderId(): string | undefined {\n return router?.getRenderId();\n}\n\nexport function _internalApiMatchStoryboard(\n pathname: string\n): RuntimeStoryboard | undefined {\n return matchStoryboard(bootstrapData?.storyboards ?? [], pathname);\n}\n\nexport function _internalApiGetRuntimeContext() {\n return router?.getRuntimeContext();\n}\n\nexport function _internalApiGetStoryboardInBootstrapData(appId: string) {\n return bootstrapData?.storyboards?.find(\n (storyboard) => storyboard.app.id === appId\n );\n}\n\nexport function _internalApiGetAppInBootstrapData(appId: string) {\n return _internalApiGetStoryboardInBootstrapData(appId)?.app;\n}\n\nexport let _test_only_setBootstrapData: (data: BootstrapData) => void;\n\n// istanbul ignore next\nif (process.env.NODE_ENV === \"test\") {\n _test_only_setBootstrapData = (data) => {\n bootstrapData = data as BootstrapData;\n };\n}\n"],"mappings":";;;;;AAYA,SAASA,IAAI,EAAEC,cAAc,QAAQ,iBAAiB;AACtD,SAASC,sBAAsB,QAAQ,mBAAmB;AAC1D,SAASC,UAAU,EAAEC,QAAQ,QAAQ,0BAA0B;AAE/D,OAAOC,MAAM,MAAM,QAAQ;AAC3B,OAAO,wBAAwB;AAC/B,SAASC,aAAa,QAAQ,eAAe;AAC7C,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,EAAE,EAAEC,OAAO,QAAQ,WAAW;AACvC,SAASC,uBAAuB,QAAQ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oF,qBAAA,uBAA/CA,qBAAA,CAAiDrC,GAAG;AAC7D;AAEA,OAAO,IAAIsC,2BAA0D;;AAErE;AACA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;EACnCH,2BAA2B,GAAI1G,IAAI,IAAK;IACtC9B,aAAa,GAAG8B,IAAqB;EACvC,CAAC;AACH"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { StoryboardFunctionRegistryFactory } from "../../StoryboardFunctionRegistry.js";
|
|
2
|
+
import { getV2RuntimeFromDll } from "../../getV2RuntimeFromDll.js";
|
|
2
3
|
var widgetFunctionRegistry = new Map();
|
|
3
4
|
export var widgetFunctions = new Proxy(Object.freeze({}), {
|
|
4
5
|
get(target, key) {
|
|
5
6
|
return widgetFunctionRegistry.get(key);
|
|
6
7
|
}
|
|
7
8
|
});
|
|
8
|
-
|
|
9
|
+
function registerWidgetFunctionsV3(widgetId, functions, widgetVersion) {
|
|
9
10
|
if (widgetFunctionRegistry.has(widgetId)) {
|
|
10
11
|
// eslint-disable-next-line no-console
|
|
11
12
|
throw new Error("Widget functions of \"".concat(widgetId, "\" already registered"));
|
|
@@ -20,4 +21,15 @@ export function registerWidgetFunctions(widgetId, functions, widgetVersion) {
|
|
|
20
21
|
widgetFunctionRegistry.set(widgetId, storyboardFunctions);
|
|
21
22
|
registerStoryboardFunctions(functions);
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
// istanbul ignore next
|
|
26
|
+
function registerWidgetFunctionsV2Factory() {
|
|
27
|
+
var v2Kit = getV2RuntimeFromDll();
|
|
28
|
+
if (v2Kit) {
|
|
29
|
+
return v2Kit.registerWidgetFunctions;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// istanbul ignore next
|
|
34
|
+
export var registerWidgetFunctions = registerWidgetFunctionsV2Factory() || registerWidgetFunctionsV3;
|
|
23
35
|
//# sourceMappingURL=WidgetFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetFunctions.js","names":["StoryboardFunctionRegistryFactory","widgetFunctionRegistry","Map","widgetFunctions","Proxy","Object","freeze","get","target","key","
|
|
1
|
+
{"version":3,"file":"WidgetFunctions.js","names":["StoryboardFunctionRegistryFactory","getV2RuntimeFromDll","widgetFunctionRegistry","Map","widgetFunctions","Proxy","Object","freeze","get","target","key","registerWidgetFunctionsV3","widgetId","functions","widgetVersion","has","Error","concat","storyboardFunctions","registerStoryboardFunctions","set","registerWidgetFunctionsV2Factory","v2Kit","registerWidgetFunctions"],"sources":["../../../../src/internal/compute/WidgetFunctions.ts"],"sourcesContent":["import { StoryboardFunction } from \"@next-core/types\";\nimport {\n ReadonlyStoryboardFunctions,\n StoryboardFunctionRegistryFactory,\n} from \"../../StoryboardFunctionRegistry.js\";\nimport { getV2RuntimeFromDll } from \"../../getV2RuntimeFromDll.js\";\n\nconst widgetFunctionRegistry = new Map<string, ReadonlyStoryboardFunctions>();\n\nexport const widgetFunctions = new Proxy(Object.freeze({}), {\n get(target, key: string) {\n return widgetFunctionRegistry.get(key);\n },\n}) as Readonly<Record<string, ReadonlyStoryboardFunctions>>;\n\nfunction registerWidgetFunctionsV3(\n widgetId: string,\n functions: StoryboardFunction[],\n widgetVersion?: string\n): void {\n if (widgetFunctionRegistry.has(widgetId)) {\n // eslint-disable-next-line no-console\n throw new Error(`Widget functions of \"${widgetId}\" already registered`);\n }\n const { storyboardFunctions, registerStoryboardFunctions } =\n StoryboardFunctionRegistryFactory({ widgetId, widgetVersion });\n widgetFunctionRegistry.set(widgetId, storyboardFunctions);\n registerStoryboardFunctions(functions);\n}\n\n// istanbul ignore next\nfunction registerWidgetFunctionsV2Factory() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return v2Kit.registerWidgetFunctions;\n }\n}\n\n// istanbul ignore next\nexport const registerWidgetFunctions =\n registerWidgetFunctionsV2Factory() || registerWidgetFunctionsV3;\n"],"mappings":"AACA,SAEEA,iCAAiC,QAC5B,qCAAqC;AAC5C,SAASC,mBAAmB,QAAQ,8BAA8B;AAElE,IAAMC,sBAAsB,GAAG,IAAIC,GAAG,CAAsC,CAAC;AAE7E,OAAO,IAAMC,eAAe,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;EAC1DC,GAAGA,CAACC,MAAM,EAAEC,GAAW,EAAE;IACvB,OAAOR,sBAAsB,CAACM,GAAG,CAACE,GAAG,CAAC;EACxC;AACF,CAAC,CAA0D;AAE3D,SAASC,yBAAyBA,CAChCC,QAAgB,EAChBC,SAA+B,EAC/BC,aAAsB,EAChB;EACN,IAAIZ,sBAAsB,CAACa,GAAG,CAACH,QAAQ,CAAC,EAAE;IACxC;IACA,MAAM,IAAII,KAAK,0BAAAC,MAAA,CAAyBL,QAAQ,0BAAsB,CAAC;EACzE;EACA,IAAM;IAAEM,mBAAmB;IAAEC;EAA4B,CAAC,GACxDnB,iCAAiC,CAAC;IAAEY,QAAQ;IAAEE;EAAc,CAAC,CAAC;EAChEZ,sBAAsB,CAACkB,GAAG,CAACR,QAAQ,EAAEM,mBAAmB,CAAC;EACzDC,2BAA2B,CAACN,SAAS,CAAC;AACxC;;AAEA;AACA,SAASQ,gCAAgCA,CAAA,EAAG;EAC1C,IAAMC,KAAK,GAAGrB,mBAAmB,CAAC,CAAC;EACnC,IAAIqB,KAAK,EAAE;IACT,OAAOA,KAAK,CAACC,uBAAuB;EACtC;AACF;;AAEA;AACA,OAAO,IAAMA,uBAAuB,GAClCF,gCAAgC,CAAC,CAAC,IAAIV,yBAAyB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// import i18next, { getFixedT, TFunction } from "i18next";
|
|
2
1
|
import { i18n } from "@next-core/i18n";
|
|
3
2
|
import { getI18nNamespace } from "../registerAppI18n.js";
|
|
4
|
-
|
|
3
|
+
import { getV2RuntimeFromDll } from "../../getV2RuntimeFromDll.js";
|
|
4
|
+
function registerWidgetI18nV3(widgetId, i18nData) {
|
|
5
5
|
var ns = getI18nNamespace("widget", widgetId);
|
|
6
6
|
Object.entries(i18nData).forEach(_ref => {
|
|
7
7
|
var [lang, resources] = _ref;
|
|
@@ -11,4 +11,15 @@ export function registerWidgetI18n(widgetId, i18nData) {
|
|
|
11
11
|
export function widgetI18nFactory(widgetId) {
|
|
12
12
|
return i18n.getFixedT(null, getI18nNamespace("widget", widgetId));
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
// istanbul ignore next
|
|
16
|
+
function registerWidgetI18nV2Factory() {
|
|
17
|
+
var v2Kit = getV2RuntimeFromDll();
|
|
18
|
+
if (v2Kit) {
|
|
19
|
+
return v2Kit.registerWidgetI18n;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// istanbul ignore next
|
|
24
|
+
export var registerWidgetI18n = registerWidgetI18nV2Factory() || registerWidgetI18nV3;
|
|
14
25
|
//# sourceMappingURL=WidgetI18n.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetI18n.js","names":["i18n","getI18nNamespace","
|
|
1
|
+
{"version":3,"file":"WidgetI18n.js","names":["i18n","getI18nNamespace","getV2RuntimeFromDll","registerWidgetI18nV3","widgetId","i18nData","ns","Object","entries","forEach","_ref","lang","resources","addResourceBundle","widgetI18nFactory","getFixedT","registerWidgetI18nV2Factory","v2Kit","registerWidgetI18n"],"sources":["../../../../src/internal/compute/WidgetI18n.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport type { MetaI18n } from \"@next-core/types\";\nimport { getI18nNamespace } from \"../registerAppI18n.js\";\nimport { getV2RuntimeFromDll } from \"../../getV2RuntimeFromDll.js\";\n\nfunction registerWidgetI18nV3(widgetId: string, i18nData: MetaI18n): void {\n const ns = getI18nNamespace(\"widget\", widgetId);\n Object.entries(i18nData).forEach(([lang, resources]) => {\n i18n.addResourceBundle(lang, ns, resources);\n });\n}\n\nexport function widgetI18nFactory(widgetId: string) {\n return i18n.getFixedT(null, getI18nNamespace(\"widget\", widgetId));\n}\n\n// istanbul ignore next\nfunction registerWidgetI18nV2Factory() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return v2Kit.registerWidgetI18n;\n }\n}\n\n// istanbul ignore next\nexport const registerWidgetI18n =\n registerWidgetI18nV2Factory() || registerWidgetI18nV3;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AAEtC,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,mBAAmB,QAAQ,8BAA8B;AAElE,SAASC,oBAAoBA,CAACC,QAAgB,EAAEC,QAAkB,EAAQ;EACxE,IAAMC,EAAE,GAAGL,gBAAgB,CAAC,QAAQ,EAAEG,QAAQ,CAAC;EAC/CG,MAAM,CAACC,OAAO,CAACH,QAAQ,CAAC,CAACI,OAAO,CAACC,IAAA,IAAuB;IAAA,IAAtB,CAACC,IAAI,EAAEC,SAAS,CAAC,GAAAF,IAAA;IACjDV,IAAI,CAACa,iBAAiB,CAACF,IAAI,EAAEL,EAAE,EAAEM,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ;AAEA,OAAO,SAASE,iBAAiBA,CAACV,QAAgB,EAAE;EAClD,OAAOJ,IAAI,CAACe,SAAS,CAAC,IAAI,EAAEd,gBAAgB,CAAC,QAAQ,EAAEG,QAAQ,CAAC,CAAC;AACnE;;AAEA;AACA,SAASY,2BAA2BA,CAAA,EAAG;EACrC,IAAMC,KAAK,GAAGf,mBAAmB,CAAC,CAAC;EACnC,IAAIe,KAAK,EAAE;IACT,OAAOA,KAAK,CAACC,kBAAkB;EACjC;AACF;;AAEA;AACA,OAAO,IAAMA,kBAAkB,GAC7BF,2BAA2B,CAAC,CAAC,IAAIb,oBAAoB"}
|
|
@@ -3,6 +3,7 @@ import { hasOwnProperty, isObject } from "@next-core/utils/general";
|
|
|
3
3
|
import { asyncComputeRealValue, computeRealValue } from "./computeRealValue.js";
|
|
4
4
|
import { isPreEvaluated } from "./evaluate.js";
|
|
5
5
|
import { resolveData } from "../data/resolveData.js";
|
|
6
|
+
import { getV2RuntimeFromDll } from "../../getV2RuntimeFromDll.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* 包含 `if` 条件判断的对象。
|
|
@@ -36,9 +37,20 @@ function _asyncCheckBrickIf() {
|
|
|
36
37
|
});
|
|
37
38
|
return _asyncCheckBrickIf.apply(this, arguments);
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
function checkIfByTransformV3(ifContainer, data) {
|
|
40
41
|
return checkIf(ifContainer, {
|
|
41
42
|
data
|
|
42
43
|
});
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
// istanbul ignore next
|
|
47
|
+
function checkIfByTransformV2Factory() {
|
|
48
|
+
var v2Kit = getV2RuntimeFromDll();
|
|
49
|
+
if (v2Kit) {
|
|
50
|
+
return v2Kit.looseCheckIfByTransform;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// istanbul ignore next
|
|
55
|
+
export var checkIfByTransform = checkIfByTransformV2Factory() || checkIfByTransformV3;
|
|
44
56
|
//# sourceMappingURL=checkIf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkIf.js","names":["hasOwnProperty","isObject","asyncComputeRealValue","computeRealValue","isPreEvaluated","resolveData","asyncCheckIf","_x","_x2","_asyncCheckIf","apply","arguments","_asyncToGenerator","ifContainer","runtimeContext","if","checkIf","checkIfOfComputed","asyncCheckBrickIf","_x3","_x4","_asyncCheckBrickIf","brickConf","resolved","
|
|
1
|
+
{"version":3,"file":"checkIf.js","names":["hasOwnProperty","isObject","asyncComputeRealValue","computeRealValue","isPreEvaluated","resolveData","getV2RuntimeFromDll","asyncCheckIf","_x","_x2","_asyncCheckIf","apply","arguments","_asyncToGenerator","ifContainer","runtimeContext","if","checkIf","checkIfOfComputed","asyncCheckBrickIf","_x3","_x4","_asyncCheckBrickIf","brickConf","resolved","checkIfByTransformV3","data","checkIfByTransformV2Factory","v2Kit","looseCheckIfByTransform","checkIfByTransform"],"sources":["../../../../src/internal/compute/checkIf.ts"],"sourcesContent":["import { hasOwnProperty, isObject } from \"@next-core/utils/general\";\nimport type { BrickConf, ResolveConf } from \"@next-core/types\";\nimport { asyncComputeRealValue, computeRealValue } from \"./computeRealValue.js\";\nimport { isPreEvaluated } from \"./evaluate.js\";\nimport { resolveData } from \"../data/resolveData.js\";\nimport type { RuntimeContext } from \"../interfaces.js\";\nimport { getV2RuntimeFromDll } from \"../../getV2RuntimeFromDll.js\";\n\n/**\n * 包含 `if` 条件判断的对象。\n */\nexport interface IfContainer {\n /**\n * 条件判断,可以为表达式字符串。\n *\n * @example\n *\n * ```yaml\n * - brick: your.any-brick\n * if: '<% FLAGS[\"your-feature-flag\"] %>'\n * ```\n */\n if?: unknown;\n}\n\nexport async function asyncCheckIf(\n ifContainer: IfContainer,\n runtimeContext: RuntimeContext\n): Promise<boolean> {\n return (\n !hasOwnProperty(ifContainer, \"if\") ||\n !!(typeof ifContainer.if === \"string\" || isPreEvaluated(ifContainer.if)\n ? await asyncComputeRealValue(ifContainer.if, runtimeContext)\n : ifContainer.if)\n );\n}\n\nexport function checkIf(\n ifContainer: IfContainer,\n runtimeContext: RuntimeContext\n): boolean {\n return (\n !hasOwnProperty(ifContainer, \"if\") ||\n !!(typeof ifContainer.if === \"string\" || isPreEvaluated(ifContainer.if)\n ? computeRealValue(ifContainer.if, runtimeContext)\n : ifContainer.if)\n );\n}\n\nexport function checkIfOfComputed(ifContainer: IfContainer): boolean {\n return !hasOwnProperty(ifContainer, \"if\") || !!ifContainer.if;\n}\n\nexport async function asyncCheckBrickIf(\n brickConf: BrickConf,\n runtimeContext: RuntimeContext\n): Promise<boolean> {\n if (isObject(brickConf.if) && !isPreEvaluated(brickConf.if)) {\n const resolved = (await resolveData(\n brickConf.if as ResolveConf,\n runtimeContext\n )) as { if?: unknown };\n return checkIfOfComputed(resolved);\n }\n return asyncCheckIf(brickConf, runtimeContext);\n}\n\nfunction checkIfByTransformV3(ifContainer: IfContainer, data: unknown) {\n return checkIf(ifContainer, { data } as RuntimeContext);\n}\n\n// istanbul ignore next\nfunction checkIfByTransformV2Factory() {\n const v2Kit = getV2RuntimeFromDll();\n if (v2Kit) {\n return v2Kit.looseCheckIfByTransform;\n }\n}\n\n// istanbul ignore next\nexport const checkIfByTransform =\n checkIfByTransformV2Factory() || checkIfByTransformV3;\n"],"mappings":";AAAA,SAASA,cAAc,EAAEC,QAAQ,QAAQ,0BAA0B;AAEnE,SAASC,qBAAqB,EAAEC,gBAAgB,QAAQ,uBAAuB;AAC/E,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,SAASC,mBAAmB,QAAQ,8BAA8B;;AAElE;AACA;AACA;;AAeA,gBAAsBC,YAAYA,CAAAC,EAAA,EAAAC,GAAA;EAAA,OAAAC,aAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAUjC,SAAAF,cAAA;EAAAA,aAAA,GAAAG,iBAAA,CAVM,WACLC,WAAwB,EACxBC,cAA8B,EACZ;IAClB,OACE,CAACf,cAAc,CAACc,WAAW,EAAE,IAAI,CAAC,IAClC,CAAC,EAAE,OAAOA,WAAW,CAACE,EAAE,KAAK,QAAQ,IAAIZ,cAAc,CAACU,WAAW,CAACE,EAAE,CAAC,SAC7Dd,qBAAqB,CAACY,WAAW,CAACE,EAAE,EAAED,cAAc,CAAC,GAC3DD,WAAW,CAACE,EAAE,CAAC;EAEvB,CAAC;EAAA,OAAAN,aAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAED,OAAO,SAASK,OAAOA,CACrBH,WAAwB,EACxBC,cAA8B,EACrB;EACT,OACE,CAACf,cAAc,CAACc,WAAW,EAAE,IAAI,CAAC,IAClC,CAAC,EAAE,OAAOA,WAAW,CAACE,EAAE,KAAK,QAAQ,IAAIZ,cAAc,CAACU,WAAW,CAACE,EAAE,CAAC,GACn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