@next-core/runtime 1.58.4 → 1.59.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/CustomTemplates.js +7 -11
- package/dist/cjs/CustomTemplates.js.map +1 -1
- package/dist/cjs/ModalStack.js +1 -2
- package/dist/cjs/ModalStack.js.map +1 -1
- package/dist/cjs/StoryboardFunctionRegistry.js +1 -2
- package/dist/cjs/StoryboardFunctionRegistry.js.map +1 -1
- package/dist/cjs/createRoot.js +4 -4
- package/dist/cjs/createRoot.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/bindTemplateProxy.js +4 -5
- package/dist/cjs/internal/CustomTemplates/bindTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js +4 -7
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/replaceSlotWithSlottedBricks.js +4 -5
- package/dist/cjs/internal/CustomTemplates/replaceSlotWithSlottedBricks.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js +18 -21
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js +4 -7
- package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/utils.js +3 -3
- package/dist/cjs/internal/CustomTemplates/utils.js.map +1 -1
- package/dist/cjs/internal/ErrorNode.js +11 -8
- package/dist/cjs/internal/ErrorNode.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/expandFormRenderer.js +3 -3
- package/dist/cjs/internal/FormRenderer/expandFormRenderer.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/utils.js +2 -2
- package/dist/cjs/internal/FormRenderer/utils.js.map +1 -1
- package/dist/cjs/internal/Renderer.js +13 -18
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js +8 -10
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/Router.js +7 -6
- package/dist/cjs/internal/Router.js.map +1 -1
- package/dist/cjs/internal/Runtime.js +16 -15
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/cjs/internal/bindListeners.js +2 -3
- package/dist/cjs/internal/bindListeners.js.map +1 -1
- package/dist/cjs/internal/compute/evaluate.js +4 -4
- package/dist/cjs/internal/compute/evaluate.js.map +1 -1
- package/dist/cjs/internal/compute/getStorageItem.js +1 -2
- package/dist/cjs/internal/compute/getStorageItem.js.map +1 -1
- package/dist/cjs/internal/compute/listenOnTrackingContext.js +1 -2
- package/dist/cjs/internal/compute/listenOnTrackingContext.js.map +1 -1
- package/dist/cjs/internal/data/resolveDataStore.js +2 -4
- package/dist/cjs/internal/data/resolveDataStore.js.map +1 -1
- package/dist/cjs/internal/i18n.js +3 -0
- package/dist/cjs/internal/i18n.js.map +1 -1
- package/dist/cjs/internal/matchStoryboard.js +2 -2
- package/dist/cjs/internal/matchStoryboard.js.map +1 -1
- package/dist/cjs/internal/poll.js +3 -3
- package/dist/cjs/internal/poll.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js +6 -7
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/cjs/internal/setupRootRuntimeContext.js +2 -3
- package/dist/cjs/internal/setupRootRuntimeContext.js.map +1 -1
- package/dist/cjs/setWatermark.js +4 -4
- package/dist/cjs/setWatermark.js.map +1 -1
- package/dist/cjs/shouldReloadForError.js +1 -2
- package/dist/cjs/shouldReloadForError.js.map +1 -1
- package/dist/cjs/themeAndMode.js +1 -2
- package/dist/cjs/themeAndMode.js.map +1 -1
- package/dist/esm/internal/ErrorNode.js +8 -4
- package/dist/esm/internal/ErrorNode.js.map +1 -1
- package/dist/esm/internal/Router.js +8 -7
- package/dist/esm/internal/Router.js.map +1 -1
- package/dist/esm/internal/Runtime.js.map +1 -1
- package/dist/esm/internal/i18n.js +3 -0
- package/dist/esm/internal/i18n.js.map +1 -1
- package/dist/types/internal/ErrorNode.d.ts +2 -2
- package/dist/types/internal/Runtime.d.ts +2 -1
- package/dist/types/internal/i18n.d.ts +1 -0
- package/package.json +10 -10
|
@@ -12,7 +12,7 @@ const allowedNativeProps = new Set(["prefix"]);
|
|
|
12
12
|
class CustomTemplateRegistry {
|
|
13
13
|
#registry = new Map();
|
|
14
14
|
define(tagName, constructor) {
|
|
15
|
-
var _constructor$proxy
|
|
15
|
+
var _constructor$proxy, _compatibleConstructo;
|
|
16
16
|
let registered = this.#registry.has(tagName);
|
|
17
17
|
if (registered) {
|
|
18
18
|
// When open launchpad, the storyboard will be updated.
|
|
@@ -30,7 +30,7 @@ class CustomTemplateRegistry {
|
|
|
30
30
|
|
|
31
31
|
// Transform legacy `proxy.properties[].asVariable` as states.
|
|
32
32
|
const strict = (0, _isStrictMode.isStrictMode)();
|
|
33
|
-
const proxyProperties = (
|
|
33
|
+
const proxyProperties = ((_constructor$proxy = constructor.proxy) === null || _constructor$proxy === void 0 ? void 0 : _constructor$proxy.properties) ?? {};
|
|
34
34
|
const validProxyProps = [];
|
|
35
35
|
const legacyTplVariables = [];
|
|
36
36
|
for (const [key, value] of Object.entries(proxyProperties)) {
|
|
@@ -71,7 +71,7 @@ class CustomTemplateRegistry {
|
|
|
71
71
|
name: tagName
|
|
72
72
|
});
|
|
73
73
|
const exposedStates = getExposedStates(compatibleConstructor.state);
|
|
74
|
-
const proxyMethods = Object.entries((_compatibleConstructo =
|
|
74
|
+
const proxyMethods = Object.entries(((_compatibleConstructo = compatibleConstructor.proxy) === null || _compatibleConstructo === void 0 ? void 0 : _compatibleConstructo.methods) ?? {});
|
|
75
75
|
const props = exposedStates.concat(validProxyProps.map(entry => entry[0]));
|
|
76
76
|
const methods = proxyMethods.map(entry => entry[0]);
|
|
77
77
|
const nativeProps = props.concat(methods).filter(prop => prop in HTMLElement.prototype && !allowedNativeProps.has(prop));
|
|
@@ -143,18 +143,16 @@ class CustomTemplateRegistry {
|
|
|
143
143
|
for (const [from, to] of validProxyProps) {
|
|
144
144
|
Object.defineProperty(TplElement.prototype, from, {
|
|
145
145
|
get() {
|
|
146
|
-
var _to$refProperty;
|
|
147
146
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
148
147
|
const element = this.$$getElementByRef(to.ref);
|
|
149
|
-
return element[
|
|
148
|
+
return element[to.refProperty ?? from];
|
|
150
149
|
},
|
|
151
150
|
set(value) {
|
|
152
151
|
var _this$$$getElementByR;
|
|
153
152
|
// 同上 exposedState.set
|
|
154
153
|
const element = (_this$$$getElementByR = this.$$getElementByRef) === null || _this$$$getElementByR === void 0 ? void 0 : _this$$$getElementByR.call(this, to.ref);
|
|
155
154
|
if (element) {
|
|
156
|
-
|
|
157
|
-
element[(_to$refProperty2 = to.refProperty) !== null && _to$refProperty2 !== void 0 ? _to$refProperty2 : from] = value;
|
|
155
|
+
element[to.refProperty ?? from] = value;
|
|
158
156
|
}
|
|
159
157
|
},
|
|
160
158
|
enumerable: true
|
|
@@ -163,10 +161,9 @@ class CustomTemplateRegistry {
|
|
|
163
161
|
for (const [from, to] of proxyMethods) {
|
|
164
162
|
Object.defineProperty(TplElement.prototype, from, {
|
|
165
163
|
value(...args) {
|
|
166
|
-
var _to$refMethod;
|
|
167
164
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
168
165
|
const element = this.$$getElementByRef(to.ref);
|
|
169
|
-
return element[
|
|
166
|
+
return element[to.refMethod ?? from](...args);
|
|
170
167
|
},
|
|
171
168
|
enumerable: true
|
|
172
169
|
});
|
|
@@ -178,9 +175,8 @@ class CustomTemplateRegistry {
|
|
|
178
175
|
}
|
|
179
176
|
}
|
|
180
177
|
function getExposedStates(state) {
|
|
181
|
-
var _state$filter$map;
|
|
182
178
|
// Allow duplicated state names which maybe mutually exclusive.
|
|
183
|
-
return (0, _lodash.uniq)((
|
|
179
|
+
return (0, _lodash.uniq)((state === null || state === void 0 ? void 0 : state.filter(item => item.expose).map(item => item.name)) ?? []);
|
|
184
180
|
}
|
|
185
181
|
|
|
186
182
|
// istanbul ignore next
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTemplates.js","names":["_lodash","require","_isStrictMode","_getV2RuntimeFromDll","allowedNativeProps","Set","CustomTemplateRegistry","registry","Map","define","tagName","constructor","_constructor$proxy$pr","_constructor$proxy","_compatibleConstructo","_compatibleConstructo2","registered","has","console","warn","customElements","get","strict","isStrictMode","proxyProperties","proxy","properties","validProxyProps","legacyTplVariables","key","value","Object","entries","asVariable","warnAboutStrictMode","push","mergeProperty","refTransform","error","ref","compatibleConstructor","fromEntries","state","map","item","expose","concat","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","propName","some","defineProperty","getValue","_this$$$tplStateStore2","updateValue","enumerable","from","to","_to$refProperty","refProperty","_this$$$getElementByR","call","_to$refProperty2","args","_to$refMethod","refMethod","_state$filter$map","uniq","getCustomTemplatesV2","v2Kit","getV2RuntimeFromDll","freeze","getRuntime","registerCustomTemplate","customTemplates","exports"],"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 return 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 C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K,CAACG,UAAU,CAAC,CAAC,CAACC,sBAAsB,CAACvG,OAAO,EAAEC,WAAW,CAAC;MACxE;IACF,CAAC,CAAC;EACJ;AACF;;AAEA;AACO,MAAMuG,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAC1BN,oBAAoB,CAAC,CAAC,IAAI,IAAItG,sBAAsB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"CustomTemplates.js","names":["_lodash","require","_isStrictMode","_getV2RuntimeFromDll","allowedNativeProps","Set","CustomTemplateRegistry","registry","Map","define","tagName","constructor","_constructor$proxy","_compatibleConstructo","registered","has","console","warn","customElements","get","strict","isStrictMode","proxyProperties","proxy","properties","validProxyProps","legacyTplVariables","key","value","Object","entries","asVariable","warnAboutStrictMode","push","mergeProperty","refTransform","error","ref","compatibleConstructor","fromEntries","state","map","item","expose","concat","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","propName","some","defineProperty","getValue","_this$$$tplStateStore2","updateValue","enumerable","from","to","refProperty","_this$$$getElementByR","call","args","refMethod","uniq","getCustomTemplatesV2","v2Kit","getV2RuntimeFromDll","freeze","getRuntime","registerCustomTemplate","customTemplates","exports"],"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 return 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,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAEA;AACA,MAAMG,kBAAkB,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AAQ9C,MAAMC,sBAAsB,CAAC;EAClB,CAACC,QAAQ,GAAG,IAAIC,GAAG,CAAyB,CAAC;EAEtDC,MAAMA,CAACC,OAAe,EAAEC,WAAsC,EAAQ;IAAA,IAAAC,kBAAA,EAAAC,qBAAA;IACpE,IAAIC,UAAU,GAAG,IAAI,CAAC,CAACP,QAAQ,CAACQ,GAAG,CAACL,OAAO,CAAC;IAC5C,IAAII,UAAU,EAAE;MACd;MACA;MACA;MACA;MACAE,OAAO,CAACC,IAAI,CAAC,uBAAuBP,OAAO,uBAAuB,CAAC;IACrE,CAAC,MAAM;MACLI,UAAU,GAAG,CAAC,CAACI,cAAc,CAACC,GAAG,CAACT,OAAO,CAAC;MAC1C,IAAII,UAAU,EAAE;QACd;QACAE,OAAO,CAACC,IAAI,CACV,uBAAuBP,OAAO,sCAChC,CAAC;MACH;IACF;;IAEA;IACA,MAAMU,MAAM,GAAG,IAAAC,0BAAY,EAAC,CAAC;IAC7B,MAAMC,eAAe,GAAI,EAAAV,kBAAA,GAAAD,WAAW,CAACY,KAAK,cAAAX,kBAAA,uBAAjBA,kBAAA,CAAmBY,UAAU,KAAI,CAAC,CAE1D;IACD,MAAMC,eAA6D,GAAG,EAAE;IACxE,MAAMC,kBAA4B,GAAG,EAAE;IACvC,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACR,eAAe,CAAC,EAAE;MAC1D,IAAIM,KAAK,CAACG,UAAU,EAAE;QACpB,IAAAC,iCAAmB,EAACZ,MAAM,EAAE,uBAAu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ialIndex = 1000) {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
const push = () => {
|
|
21
|
-
var _stack;
|
|
22
21
|
// Handle pushes without pull
|
|
23
22
|
pull();
|
|
24
23
|
// Find the next available index
|
|
25
|
-
index = (
|
|
24
|
+
index = (stack[stack.length - 1] ?? -1) + 1;
|
|
26
25
|
stack.push(index);
|
|
27
26
|
return index + initialIndex;
|
|
28
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalStack.js","names":["stack","instantiateModalStack","initialIndex","index","pull","found","indexOf","splice","push","
|
|
1
|
+
{"version":3,"file":"ModalStack.js","names":["stack","instantiateModalStack","initialIndex","index","pull","found","indexOf","splice","push","length"],"sources":["../../src/ModalStack.ts"],"sourcesContent":["const stack: number[] = [];\n\nexport interface ModalStack {\n push: () => number;\n pull: () => void;\n}\n\nexport function instantiateModalStack(initialIndex = 1000): ModalStack {\n let index = -1;\n const pull = (): void => {\n if (index > -1) {\n const found = stack.indexOf(index);\n // Assert: found should always be greater than -1\n // istanbul ignore else\n if (found > -1) {\n stack.splice(found, 1);\n }\n }\n };\n const push = (): number => {\n // Handle pushes without pull\n pull();\n // Find the next available index\n index = (stack[stack.length - 1] ?? -1) + 1;\n stack.push(index);\n return index + initialIndex;\n };\n return { push, pull };\n}\n"],"mappings":";;;;;;AAAA,MAAMA,KAAe,GAAG,EAAE;AAOnB,SAASC,qBAAqBA,CAACC,YAAY,GAAG,IAAI,EAAc;EACrE,IAAIC,KAAK,GAAG,CAAC,CAAC;EACd,MAAMC,IAAI,GAAGA,CAAA,KAAY;IACvB,IAAID,KAAK,GAAG,CAAC,CAAC,EAAE;MACd,MAAME,KAAK,GAAGL,KAAK,CAACM,OAAO,CAACH,KAAK,CAAC;MAClC;MACA;MACA,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;QACdL,KAAK,CAACO,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;MACxB;IACF;EACF,CAAC;EACD,MAAMG,IAAI,GAAGA,CAAA,KAAc;IACzB;IACAJ,IAAI,CAAC,CAAC;IACN;IACAD,KAAK,GAAG,CAACH,KAAK,CAACA,KAAK,CAACS,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IAC3CT,KAAK,CAACQ,IAAI,CAACL,KAAK,CAAC;IACjB,OAAOA,KAAK,GAAGD,YAAY;EAC7B,CAAC;EACD,OAAO;IAAEM,IAAI;IAAEJ;EAAK,CAAC;AACvB","ignoreList":[]}
|
|
@@ -51,13 +51,12 @@ function StoryboardFunctionRegistryFactory({
|
|
|
51
51
|
registeredFunctions.clear();
|
|
52
52
|
if (Array.isArray(functions)) {
|
|
53
53
|
for (const fn of functions) {
|
|
54
|
-
var _fn$perm;
|
|
55
54
|
let deps = fn.deps;
|
|
56
55
|
if (deps == null) {
|
|
57
56
|
deps = (0, _storyboard.collectMemberUsageInFunction)(fn, "FN", !!collectCoverage);
|
|
58
57
|
deps.delete(fn.name);
|
|
59
58
|
}
|
|
60
|
-
const hasPermissionsCheck =
|
|
59
|
+
const hasPermissionsCheck = fn.perm ?? (0, _storyboard.collectMemberUsageInFunction)(fn, "PERMISSIONS", !!collectCoverage).has("check");
|
|
61
60
|
registeredFunctions.set(fn.name, {
|
|
62
61
|
source: fn.source,
|
|
63
62
|
typescript: fn.typescript,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoryboardFunctionRegistry.js","names":["_cook","require","_supply","_storyboard","_general","_getGeneralGlobals","StoryboardFunctionRegistryFactory","widgetId","widgetVersion","collectCoverage","debuggerOverrides","registeredFunctions","Map","overrides","precookFunction","cook","supply","storyboardFunctions","Proxy","Object","freeze","get","_target","key","getStoryboardFunction","currentApp","registerStoryboardFunctions","functions","app","clear","Array","isArray","fn","_fn$perm","deps","collectMemberUsageInFunction","delete","name","hasPermissionsCheck","perm","has","set","source","typescript","transformed","getGlobalVariables","globals","getGeneralGlobals","isStoryboardFunction","undefined","processed","cooked","collector","createCollector","globalVariables","Function","map","hasOwnProperty","precooked","hooks","beforeVisit","cacheKey","attemptToVisitGlobals","function","rules","noVar","LodashWithStaticFields","_","ArrayConstructor","ObjectWithStaticFields","beforeEvaluate","beforeCall","beforeBranch","debug","updateStoryboardFunction","data","newFn","checkPermissionsUsage","functionNames","checkedFunctions","Set","add","some","clearGlobalExecutionContextStack","__dev_only_clearGlobalExecutionContextStack","getGlobalExecutionContextStack","__dev_only_getGlobalExecutionContextStack"],"sources":["../../src/StoryboardFunctionRegistry.ts"],"sourcesContent":["import type {\n MicroApp,\n StoryboardFunction,\n TransformedFunction,\n} from \"@next-core/types\";\nimport {\n cook,\n precookFunction,\n EstreeNode,\n __dev_only_clearGlobalExecutionContextStack,\n __dev_only_getGlobalExecutionContextStack,\n} from \"@next-core/cook\";\nimport { supply } from \"@next-core/supply\";\nimport { collectMemberUsageInFunction } from \"@next-core/utils/storyboard\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport type _ from \"lodash\";\nimport { getGeneralGlobals } from \"./internal/compute/getGeneralGlobals.js\";\n\n/** @internal */\nexport type ReadonlyStoryboardFunctions = Readonly<Record<string, Function>>;\n\n/** @internal */\nexport type StoryboardFunctionPatch = Pick<\n StoryboardFunction,\n \"source\" | \"typescript\" | \"transformed\"\n>;\n\n/** @internal */\nexport interface StoryboardFunctionRegistry {\n /** A readonly proxy for accessing cooked storyboard functions. */\n storyboardFunctions: ReadonlyStoryboardFunctions;\n\n /** Register storyboard functions. */\n registerStoryboardFunctions(\n functions: StoryboardFunction[] | undefined,\n app?: PartialMicroApp\n ): void;\n\n /** Update a storyboard function during debugging. */\n updateStoryboardFunction(name: string, data: StoryboardFunctionPatch): void;\n\n checkPermissionsUsage(functionNames: string[]): boolean;\n\n clearGlobalExecutionContextStack(): void;\n getGlobalExecutionContextStack(): ReturnType<\n typeof __dev_only_getGlobalExecutionContextStack\n >;\n}\n\n/** @internal */\nexport interface RuntimeStoryboardFunction {\n source: string;\n typescript?: boolean;\n processed?: boolean;\n cooked?: Function;\n deps: Set<string> | string[];\n hasPermissionsCheck: boolean;\n transformed?: TransformedFunction;\n}\n\n/** @internal */\nexport interface FunctionCoverageCollector {\n beforeVisit(node: EstreeNode): void;\n beforeEvaluate(node: EstreeNode): void;\n beforeCall(node: EstreeNode): void;\n beforeBranch(node: EstreeNode, branch: string): void;\n}\n\n/** @internal */\nexport interface FunctionCoverageSettings {\n createCollector(name: string): FunctionCoverageCollector;\n}\n\n/** @internal */\nexport type PartialMicroApp = Pick<MicroApp, \"id\" | \"isBuildPush\" | \"config\">;\n\n/** @internal */\nexport function StoryboardFunctionRegistryFactory({\n widgetId,\n widgetVersion,\n collectCoverage,\n debuggerOverrides,\n}: {\n widgetId?: string;\n widgetVersion?: string;\n collectCoverage?: FunctionCoverageSettings;\n debuggerOverrides?: (ctx: {\n precookFunction: typeof precookFunction;\n cook: typeof cook;\n supply: typeof supply;\n }) => {\n LodashWithStaticFields?: Partial<typeof _>;\n ArrayConstructor?: typeof Array;\n ObjectWithStaticFields?: Partial<typeof Object>;\n };\n} = {}): StoryboardFunctionRegistry {\n const registeredFunctions = new Map<string, RuntimeStoryboardFunction>();\n\n const overrides = debuggerOverrides?.({\n precookFunction,\n cook,\n supply,\n });\n\n // Use `Proxy` with a frozen target, to make a readonly function registry.\n const storyboardFunctions = new Proxy(Object.freeze({}), {\n get(_target, key) {\n return getStoryboardFunction(key as string);\n },\n }) as ReadonlyStoryboardFunctions;\n\n let currentApp: PartialMicroApp | undefined;\n\n function registerStoryboardFunctions(\n functions: StoryboardFunction[],\n app?: PartialMicroApp\n ): void {\n if (app) {\n currentApp = app;\n }\n registeredFunctions.clear();\n if (Array.isArray(functions)) {\n for (const fn of functions) {\n let deps: Set<string> | string[] | undefined = fn.deps;\n if (deps == null) {\n deps = collectMemberUsageInFunction(fn, \"FN\", !!collectCoverage);\n (deps as Set<string>).delete(fn.name);\n }\n const hasPermissionsCheck =\n fn.perm ??\n collectMemberUsageInFunction(\n fn,\n \"PERMISSIONS\",\n !!collectCoverage\n ).has(\"check\");\n registeredFunctions.set(fn.name, {\n source: fn.source,\n typescript: fn.typescript,\n transformed: fn.transformed,\n deps,\n hasPermissionsCheck,\n });\n }\n }\n }\n\n function getGlobalVariables(globals: Set<string> | string[]) {\n return supply(\n globals,\n getGeneralGlobals(globals, {\n collectCoverage,\n widgetId,\n widgetVersion,\n app: currentApp,\n storyboardFunctions,\n isStoryboardFunction: true,\n }),\n !!collectCoverage\n );\n }\n\n function getStoryboardFunction(name: string): Function | undefined {\n const fn = registeredFunctions.get(name);\n if (!fn) {\n return undefined;\n }\n if (fn.processed) {\n return fn.cooked;\n }\n let collector: FunctionCoverageCollector | undefined;\n if (collectCoverage) {\n collector = collectCoverage.createCollector(name);\n }\n\n // Do not use transformed functions when debugging.\n const transformed = !overrides && !collector && fn.transformed;\n if (transformed) {\n const globalVariables = getGlobalVariables(transformed.globals);\n // Spread globals as params to prevent accessing forbidden globals.\n // NOTE: in native mode, forbidden globals are declared as `undefined`,\n // thus accessing them will not throw a ReferenceError.\n fn.cooked = new Function(\n ...transformed.globals,\n `\"use strict\";return (${transformed.source})`\n )(\n ...transformed.globals.map((key) =>\n hasOwnProperty(globalVariables, key)\n ? globalVariables[key]\n : undefined\n )\n );\n } else {\n const precooked = precookFunction(fn.source, {\n typescript: fn.typescript,\n hooks: collector && {\n beforeVisit: collector.beforeVisit,\n },\n cacheKey: fn,\n });\n const globalVariables = getGlobalVariables(\n precooked.attemptToVisitGlobals\n );\n fn.cooked = cook(precooked.function, fn.source, {\n rules: {\n noVar: true,\n },\n globalVariables: overrides\n ? {\n ...globalVariables,\n ...(overrides?.LodashWithStaticFields &&\n precooked.attemptToVisitGlobals.has(\"_\")\n ? {\n _: {\n ...(globalVariables._ as typeof _),\n ...overrides.LodashWithStaticFields,\n },\n }\n : null),\n ...(overrides?.ArrayConstructor &&\n precooked.attemptToVisitGlobals.has(\"Array\")\n ? {\n Array: overrides.ArrayConstructor,\n }\n : null),\n ...(overrides?.ObjectWithStaticFields &&\n precooked.attemptToVisitGlobals.has(\"Object\")\n ? {\n Object: {\n ...(globalVariables.Object as typeof Object),\n ...overrides.ObjectWithStaticFields,\n },\n }\n : null),\n }\n : globalVariables,\n ArrayConstructor: overrides?.ArrayConstructor,\n hooks: collector && {\n beforeEvaluate: collector.beforeEvaluate,\n beforeCall: collector.beforeCall,\n beforeBranch: collector.beforeBranch,\n },\n debug: !!debuggerOverrides,\n }) as Function;\n }\n fn.processed = true;\n return fn.cooked;\n }\n\n return {\n storyboardFunctions,\n registerStoryboardFunctions,\n updateStoryboardFunction(\n name: string,\n data: StoryboardFunctionPatch\n ): void {\n const newFn = {\n ...data,\n name,\n };\n const deps = collectMemberUsageInFunction(newFn, \"FN\", true);\n const hasPermissionsCheck = collectMemberUsageInFunction(\n newFn,\n \"PERMISSIONS\",\n true\n ).has(\"check\");\n registeredFunctions.set(name, {\n source: data.source,\n typescript: data.typescript,\n transformed: data.transformed,\n deps,\n hasPermissionsCheck,\n });\n },\n /**\n * Check whether listed functions attempt to call `PERMISSIONS.check()`,\n * includes in nested `FN.*()` calls.\n */\n checkPermissionsUsage(functionNames) {\n const checkedFunctions = new Set<string>();\n const hasPermissionsCheck = (name: string): boolean => {\n if (!checkedFunctions.has(name)) {\n checkedFunctions.add(name);\n const fn = registeredFunctions.get(name);\n return (\n !!fn &&\n (fn.hasPermissionsCheck || [...fn.deps].some(hasPermissionsCheck))\n );\n }\n return false;\n };\n return functionNames.some(hasPermissionsCheck);\n },\n clearGlobalExecutionContextStack() {\n __dev_only_clearGlobalExecutionContextStack();\n },\n getGlobalExecutionContextStack() {\n return __dev_only_getGlobalExecutionContextStack();\n },\n };\n}\n"],"mappings":";;;;;;AAKA,IAAAA,KAAA,GAAAC,OAAA;AAOA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA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C,GAAG,CAAS,CAAC;MAC1C,MAAM1C,mBAAmB,GAAID,IAAY,IAAc;QACrD,IAAI,CAAC0C,gBAAgB,CAACvC,GAAG,CAACH,IAAI,CAAC,EAAE;UAC/B0C,gBAAgB,CAACE,GAAG,CAAC5C,IAAI,CAAC;UAC1B,MAAML,EAAE,GAAGrB,mBAAmB,CAACU,GAAG,CAACgB,IAAI,CAAC;UACxC,OACE,CAAC,CAACL,EAAE,KACHA,EAAE,CAACM,mBAAmB,IAAI,CAAC,GAAGN,EAAE,CAACE,IAAI,CAAC,CAACgD,IAAI,CAAC5C,mBAAmB,CAAC,CAAC;QAEtE;QACA,OAAO,KAAK;MACd,CAAC;MACD,OAAOwC,aAAa,CAACI,IAAI,CAAC5C,mBAAmB,CAAC;IAChD,CAAC;IACD6C,gCAAgCA,CAAA,EAAG;MACjC,IAAAC,iDAA2C,EAAC,CAAC;IAC/C,CAAC;IACDC,8BAA8BA,CAAA,EAAG;MAC/B,OAAO,IAAAC,+CAAyC,EAAC,CAAC;IACpD;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"StoryboardFunctionRegistry.js","names":["_cook","require","_supply","_storyboard","_general","_getGeneralGlobals","StoryboardFunctionRegistryFactory","widgetId","widgetVersion","collectCoverage","debuggerOverrides","registeredFunctions","Map","overrides","precookFunction","cook","supply","storyboardFunctions","Proxy","Object","freeze","get","_target","key","getStoryboardFunction","currentApp","registerStoryboardFunctions","functions","app","clear","Array","isArray","fn","deps","collectMemberUsageInFunction","delete","name","hasPermissionsCheck","perm","has","set","source","typescript","transformed","getGlobalVariables","globals","getGeneralGlobals","isStoryboardFunction","undefined","processed","cooked","collector","createCollector","globalVariables","Function","map","hasOwnProperty","precooked","hooks","beforeVisit","cacheKey","attemptToVisitGlobals","function","rules","noVar","LodashWithStaticFields","_","ArrayConstructor","ObjectWithStaticFields","beforeEvaluate","beforeCall","beforeBranch","debug","updateStoryboardFunction","data","newFn","checkPermissionsUsage","functionNames","checkedFunctions","Set","add","some","clearGlobalExecutionContextStack","__dev_only_clearGlobalExecutionContextStack","getGlobalExecutionContextStack","__dev_only_getGlobalExecutionContextStack"],"sources":["../../src/StoryboardFunctionRegistry.ts"],"sourcesContent":["import type {\n MicroApp,\n StoryboardFunction,\n TransformedFunction,\n} from \"@next-core/types\";\nimport {\n cook,\n precookFunction,\n EstreeNode,\n __dev_only_clearGlobalExecutionContextStack,\n __dev_only_getGlobalExecutionContextStack,\n} from \"@next-core/cook\";\nimport { supply } from \"@next-core/supply\";\nimport { collectMemberUsageInFunction } from \"@next-core/utils/storyboard\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport type _ from \"lodash\";\nimport { getGeneralGlobals } from \"./internal/compute/getGeneralGlobals.js\";\n\n/** @internal */\nexport type ReadonlyStoryboardFunctions = Readonly<Record<string, Function>>;\n\n/** @internal */\nexport type StoryboardFunctionPatch = Pick<\n StoryboardFunction,\n \"source\" | \"typescript\" | \"transformed\"\n>;\n\n/** @internal */\nexport interface StoryboardFunctionRegistry {\n /** A readonly proxy for accessing cooked storyboard functions. */\n storyboardFunctions: ReadonlyStoryboardFunctions;\n\n /** Register storyboard functions. */\n registerStoryboardFunctions(\n functions: StoryboardFunction[] | undefined,\n app?: PartialMicroApp\n ): void;\n\n /** Update a storyboard function during debugging. */\n updateStoryboardFunction(name: string, data: StoryboardFunctionPatch): void;\n\n checkPermissionsUsage(functionNames: string[]): boolean;\n\n clearGlobalExecutionContextStack(): void;\n getGlobalExecutionContextStack(): ReturnType<\n typeof __dev_only_getGlobalExecutionContextStack\n >;\n}\n\n/** @internal */\nexport interface RuntimeStoryboardFunction {\n source: string;\n typescript?: boolean;\n processed?: boolean;\n cooked?: Function;\n deps: Set<string> | string[];\n hasPermissionsCheck: boolean;\n transformed?: TransformedFunction;\n}\n\n/** @internal */\nexport interface FunctionCoverageCollector {\n beforeVisit(node: EstreeNode): void;\n beforeEvaluate(node: EstreeNode): void;\n beforeCall(node: EstreeNode): void;\n beforeBranch(node: EstreeNode, branch: string): void;\n}\n\n/** @internal */\nexport interface FunctionCoverageSettings {\n createCollector(name: string): FunctionCoverageCollector;\n}\n\n/** @internal */\nexport type PartialMicroApp = Pick<MicroApp, \"id\" | \"isBuildPush\" | \"config\">;\n\n/** @internal */\nexport function StoryboardFunctionRegistryFactory({\n widgetId,\n widgetVersion,\n collectCoverage,\n debuggerOverrides,\n}: {\n widgetId?: string;\n widgetVersion?: string;\n collectCoverage?: FunctionCoverageSettings;\n debuggerOverrides?: (ctx: {\n precookFunction: typeof precookFunction;\n cook: typeof cook;\n supply: typeof supply;\n }) => {\n LodashWithStaticFields?: Partial<typeof _>;\n ArrayConstructor?: typeof Array;\n ObjectWithStaticFields?: Partial<typeof Object>;\n };\n} = {}): StoryboardFunctionRegistry {\n const registeredFunctions = new Map<string, RuntimeStoryboardFunction>();\n\n const overrides = debuggerOverrides?.({\n precookFunction,\n cook,\n supply,\n });\n\n // Use `Proxy` with a frozen target, to make a readonly function registry.\n const storyboardFunctions = new Proxy(Object.freeze({}), {\n get(_target, key) {\n return getStoryboardFunction(key as string);\n },\n }) as ReadonlyStoryboardFunctions;\n\n let currentApp: PartialMicroApp | undefined;\n\n function registerStoryboardFunctions(\n functions: StoryboardFunction[],\n app?: PartialMicroApp\n ): void {\n if (app) {\n currentApp = app;\n }\n registeredFunctions.clear();\n if (Array.isArray(functions)) {\n for (const fn of functions) {\n let deps: Set<string> | string[] | undefined = fn.deps;\n if (deps == null) {\n deps = collectMemberUsageInFunction(fn, \"FN\", !!collectCoverage);\n (deps as Set<string>).delete(fn.name);\n }\n const hasPermissionsCheck =\n fn.perm ??\n collectMemberUsageInFunction(\n fn,\n \"PERMISSIONS\",\n !!collectCoverage\n ).has(\"check\");\n registeredFunctions.set(fn.name, {\n source: fn.source,\n typescript: fn.typescript,\n transformed: fn.transformed,\n deps,\n hasPermissionsCheck,\n });\n }\n }\n }\n\n function getGlobalVariables(globals: Set<string> | string[]) {\n return supply(\n globals,\n getGeneralGlobals(globals, {\n collectCoverage,\n widgetId,\n widgetVersion,\n app: currentApp,\n storyboardFunctions,\n isStoryboardFunction: true,\n }),\n !!collectCoverage\n );\n }\n\n function getStoryboardFunction(name: string): Function | undefined {\n const fn = registeredFunctions.get(name);\n if (!fn) {\n return undefined;\n }\n if (fn.processed) {\n return fn.cooked;\n }\n let collector: FunctionCoverageCollector | undefined;\n if (collectCoverage) {\n collector = collectCoverage.createCollector(name);\n }\n\n // Do not use transformed functions when debugging.\n const transformed = !overrides && !collector && fn.transformed;\n if (transformed) {\n const globalVariables = getGlobalVariables(transformed.globals);\n // Spread globals as params to prevent accessing forbidden globals.\n // NOTE: in native mode, forbidden globals are declared as `undefined`,\n // thus accessing them will not throw a ReferenceError.\n fn.cooked = new Function(\n ...transformed.globals,\n `\"use strict\";return (${transformed.source})`\n )(\n ...transformed.globals.map((key) =>\n hasOwnProperty(globalVariables, key)\n ? globalVariables[key]\n : undefined\n )\n );\n } else {\n const precooked = precookFunction(fn.source, {\n typescript: fn.typescript,\n hooks: collector && {\n beforeVisit: collector.beforeVisit,\n },\n cacheKey: fn,\n });\n const globalVariables = getGlobalVariables(\n precooked.attemptToVisitGlobals\n );\n fn.cooked = cook(precooked.function, fn.source, {\n rules: {\n noVar: true,\n },\n globalVariables: overrides\n ? {\n ...globalVariables,\n ...(overrides?.LodashWithStaticFields &&\n precooked.attemptToVisitGlobals.has(\"_\")\n ? {\n _: {\n ...(globalVariables._ as typeof _),\n ...overrides.LodashWithStaticFields,\n },\n }\n : null),\n ...(overrides?.ArrayConstructor &&\n precooked.attemptToVisitGlobals.has(\"Array\")\n ? {\n Array: overrides.ArrayConstructor,\n }\n : null),\n ...(overrides?.ObjectWithStaticFields &&\n precooked.attemptToVisitGlobals.has(\"Object\")\n ? {\n Object: {\n ...(globalVariables.Object as typeof Object),\n ...overrides.ObjectWithStaticFields,\n },\n }\n : null),\n }\n : globalVariables,\n ArrayConstructor: overrides?.ArrayConstructor,\n hooks: collector && {\n beforeEvaluate: collector.beforeEvaluate,\n beforeCall: collector.beforeCall,\n beforeBranch: collector.beforeBranch,\n },\n debug: !!debuggerOverrides,\n }) as Function;\n }\n fn.processed = true;\n return fn.cooked;\n }\n\n return {\n storyboardFunctions,\n registerStoryboardFunctions,\n updateStoryboardFunction(\n name: string,\n data: StoryboardFunctionPatch\n ): void {\n const newFn = {\n ...data,\n name,\n };\n const deps = collectMemberUsageInFunction(newFn, \"FN\", true);\n const hasPermissionsCheck = collectMemberUsageInFunction(\n newFn,\n \"PERMISSIONS\",\n true\n ).has(\"check\");\n registeredFunctions.set(name, {\n source: data.source,\n typescript: data.typescript,\n transformed: data.transformed,\n deps,\n hasPermissionsCheck,\n });\n },\n /**\n * Check whether listed functions attempt to call `PERMISSIONS.check()`,\n * includes in nested `FN.*()` calls.\n */\n checkPermissionsUsage(functionNames) {\n const checkedFunctions = new Set<string>();\n const hasPermissionsCheck = (name: string): boolean => {\n if (!checkedFunctions.has(name)) {\n checkedFunctions.add(name);\n const fn = registeredFunctions.get(name);\n return (\n !!fn &&\n (fn.hasPermissionsCheck || [...fn.deps].some(hasPermissionsCheck))\n );\n }\n return false;\n };\n return functionNames.some(hasPermissionsCheck);\n },\n clearGlobalExecutionContextStack() {\n __dev_only_clearGlobalExecutionContextStack();\n },\n getGlobalExecutionContextStack() {\n return __dev_only_getGlobalExecutionContextStack();\n },\n };\n}\n"],"mappings":";;;;;;AAKA,IAAAA,KAAA,GAAAC,OAAA;AAOA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AAEA;;AAGA;;AAMA;;AAsBA;;AAWA;;AAQA;;AAKA;;AAGA;AACO,SAASK,iCAAiCA,CAAC;EAChDC,QAAQ;EACRC,aAAa;EACbC,eAAe;EACfC;AAcF,CAAC,GAAG,CAAC,CAAC,EAA8B;EAClC,MAAMC,mBAAmB,GAAG,IAA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AAC,CAACJ,EAAE,KACHA,EAAE,CAACK,mBAAmB,IAAI,CAAC,GAAGL,EAAE,CAACC,IAAI,CAAC,CAACgD,IAAI,CAAC5C,mBAAmB,CAAC,CAAC;QAEtE;QACA,OAAO,KAAK;MACd,CAAC;MACD,OAAOwC,aAAa,CAACI,IAAI,CAAC5C,mBAAmB,CAAC;IAChD,CAAC;IACD6C,gCAAgCA,CAAA,EAAG;MACjC,IAAAC,iDAA2C,EAAC,CAAC;IAC/C,CAAC;IACDC,8BAA8BA,CAAA,EAAG;MAC/B,OAAO,IAAAC,+CAAyC,EAAC,CAAC;IACpD;EACF,CAAC;AACH","ignoreList":[]}
|
package/dist/cjs/createRoot.js
CHANGED
|
@@ -83,17 +83,17 @@ function unstable_createRoot(container, {
|
|
|
83
83
|
createPortal
|
|
84
84
|
};
|
|
85
85
|
if (scope === "page") {
|
|
86
|
-
var
|
|
87
|
-
(0, _themeAndMode.setTheme)(theme
|
|
86
|
+
var _clearI18nBundles;
|
|
87
|
+
(0, _themeAndMode.setTheme)(theme ?? "light");
|
|
88
88
|
(0, _themeAndMode.setMode)("default");
|
|
89
89
|
(0, _setUIVersion.setUIVersion)(uiVersion);
|
|
90
90
|
if (language) {
|
|
91
91
|
await _i18n.i18n.changeLanguage(language);
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
app ?? (app = {
|
|
94
94
|
id: "demo",
|
|
95
95
|
homepage: "/demo"
|
|
96
|
-
};
|
|
96
|
+
});
|
|
97
97
|
runtimeContext.app = app;
|
|
98
98
|
const demoStoryboard = {
|
|
99
99
|
app,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoot.js","names":["_i18n","require","_lodash","_Renderer","_RendererContext","_DataStore","_mount","_themeAndMode","_enums","_StoryboardFunctions","_registerAppI18n","_registerCustomTemplates","_setUIVersion","_ErrorNode","unstable_createRoot","container","portal","_portal","scope","unknownBricks","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","theme","uiVersion","language","context","functions","templates","i18n","i18nData","url","app","Error","bricks","concat","previousRendererContext","renderId","uniqueId","RendererContext","runtimeContext","ctxStore","DataStore","undefined","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","urlObj","URL","query","searchParams","location","pathname","search","hash","state","renderRoot","tag","RenderTag","ROOT","_app","_clearI18nBundles","setTheme","setMode","setUIVersion","changeLanguage","id","homepage","demoStoryboard","meta","customTemplates","registerAppI18n","registerCustomTemplates","registerStoryboardFunctions","define","failed","output","stores","renderBricks","getDataStores","postAsyncRender","error","node","ErrorNode","blockingList","child","dispatchOnUnmount","dispose","unmountTree","dispatchBeforePageLoad","applyTheme","applyMode","mountTree","window","scrollTo","store","mountAsyncData","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { i18n } from \"@next-core/i18n\";\nimport { uniqueId } from \"lodash\";\nimport {\n RenderOutput,\n getDataStores,\n postAsyncRender,\n renderBricks,\n} from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\nimport { setUIVersion } from \"./setUIVersion.js\";\nimport { ErrorNode } from \"./internal/ErrorNode.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n uiVersion?: string;\n language?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n url?: string;\n app?: MicroApp;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | DocumentFragment,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n uiVersion,\n language,\n context,\n functions,\n templates,\n i18n: i18nData,\n url,\n app,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n const renderId = uniqueId(\"render-id-\");\n rendererContext = new RendererContext(scope, { unknownBricks, renderId });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n if (url) {\n const urlObj = new URL(url);\n runtimeContext.query = urlObj.searchParams;\n runtimeContext.location = {\n pathname: urlObj.pathname,\n search: urlObj.search,\n hash: urlObj.hash,\n state: undefined,\n };\n }\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n setUIVersion(uiVersion);\n if (language) {\n await i18n.changeLanguage(language);\n }\n\n app ??= {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = app;\n const demoStoryboard = {\n app,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, app);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext,\n [],\n {}\n );\n\n stores = getDataStores(runtimeContext);\n await postAsyncRender(output, runtimeContext, stores);\n } catch (error) {\n failed = true;\n output = {\n node: await ErrorNode(error, renderRoot, scope === \"page\"),\n blockingList: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.mountAsyncData();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";;;;;;AAUA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,wBAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AACA,IAAAY,UAAA,GAAAZ,OAAA;AA+BO,SAASa,mBAAmBA,CACjCC,SAAyC,EACzC;EAAEC,MAAM,EAAEC,OAAO;EAAEC,KAAK,GAAG,UAAU;EAAEC;AAAiC,CAAC,GAAG,CAAC,CAAC,EAC9E;EACA,IAAIH,MAAM,GAAGC,OAAO;EACpB,IAAIG,YAAwC;EAC5C,IAAIH,OAAO,EAAE;IACXG,YAAY,GAAGH,OAAO;EACxB,CAAC,MAAM;IACL;IACAG,YAAY,GAAGA,CAAA,KAAM;MACnBJ,MAAM,GAAGK,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;MACtCN,MAAM,CAACO,KAAK,CAACC,QAAQ,GAAG,UAAU;MAClCR,MAAM,CAACO,KAAK,CAACE,KAAK,GAAGT,MAAM,CAACO,KAAK,CAACG,MAAM,GAAG,GAAG;MAC9CL,QAAQ,CAACM,IAAI,CAACC,MAAM,CAACZ,MAAM,CAAC;MA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Ae,CAACgF,eAAe,CAAC,CAAC;QACjChF,eAAe,CAACiF,wBAAwB,CAAC,CAAC;QAC1CjF,eAAe,CAACkF,qBAAqB,CAAC,CAAC;QACvClF,eAAe,CAACmF,2BAA2B,CAAC,CAAC;MAC/C;IACF,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAIrF,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB,IAAAuE,kBAAW,EAACrF,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACV,IAAAoF,kBAAW,EAACpF,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAACmG,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createRoot.js","names":["_i18n","require","_lodash","_Renderer","_RendererContext","_DataStore","_mount","_themeAndMode","_enums","_StoryboardFunctions","_registerAppI18n","_registerCustomTemplates","_setUIVersion","_ErrorNode","unstable_createRoot","container","portal","_portal","scope","unknownBricks","createPortal","document","createElement","style","position","width","height","body","append","unmounted","rendererContext","clearI18nBundles","render","brick","theme","uiVersion","language","context","functions","templates","i18n","i18nData","url","app","Error","bricks","concat","previousRendererContext","renderId","uniqueId","RendererContext","runtimeContext","ctxStore","DataStore","undefined","pendingPermissionsPreCheck","tplStateStoreMap","Map","formStateStoreMap","urlObj","URL","query","searchParams","location","pathname","search","hash","state","renderRoot","tag","RenderTag","ROOT","_clearI18nBundles","setTheme","setMode","setUIVersion","changeLanguage","id","homepage","demoStoryboard","meta","customTemplates","registerAppI18n","registerCustomTemplates","registerStoryboardFunctions","define","failed","output","stores","renderBricks","getDataStores","postAsyncRender","error","node","ErrorNode","blockingList","child","dispatchOnUnmount","dispose","unmountTree","dispatchBeforePageLoad","applyTheme","applyMode","mountTree","window","scrollTo","store","mountAsyncData","dispatchPageLoad","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","unmount","remove"],"sources":["../../src/createRoot.ts"],"sourcesContent":["import type {\n BrickConf,\n ContextConf,\n CustomTemplate,\n MetaI18n,\n MicroApp,\n SiteTheme,\n Storyboard,\n StoryboardFunction,\n} from \"@next-core/types\";\nimport { i18n } from \"@next-core/i18n\";\nimport { uniqueId } from \"lodash\";\nimport {\n RenderOutput,\n getDataStores,\n postAsyncRender,\n renderBricks,\n} from \"./internal/Renderer.js\";\nimport { RendererContext } from \"./internal/RendererContext.js\";\nimport { DataStore } from \"./internal/data/DataStore.js\";\nimport type { RenderRoot, RuntimeContext } from \"./internal/interfaces.js\";\nimport { mountTree, unmountTree } from \"./internal/mount.js\";\nimport { applyMode, applyTheme, setMode, setTheme } from \"./themeAndMode.js\";\nimport { RenderTag } from \"./internal/enums.js\";\nimport { registerStoryboardFunctions } from \"./internal/compute/StoryboardFunctions.js\";\nimport { registerAppI18n } from \"./internal/registerAppI18n.js\";\nimport { registerCustomTemplates } from \"./internal/registerCustomTemplates.js\";\nimport { setUIVersion } from \"./setUIVersion.js\";\nimport { ErrorNode } from \"./internal/ErrorNode.js\";\n\nexport interface CreateRootOptions {\n portal?: HTMLElement;\n /**\n * Defaults to \"fragment\", only set it to \"page\" when the root is in a standalone iframe.\n * - page: render as whole page, triggering page life cycles, and enable register of functions/templates/i18n.\n * - fragment: render as fragment, not triggering page life cycles, and disable register of functions/templates/i18n.\n */\n scope?: \"page\" | \"fragment\";\n\n /**\n * Whether to throw error when encountering unknown bricks.\n *\n * Defaults to \"throw\".\n */\n unknownBricks?: \"silent\" | \"throw\";\n}\n\nexport interface RenderOptions {\n theme?: SiteTheme;\n uiVersion?: string;\n language?: string;\n context?: ContextConf[];\n functions?: StoryboardFunction[];\n templates?: CustomTemplate[];\n i18n?: MetaI18n;\n url?: string;\n app?: MicroApp;\n}\n\nexport function unstable_createRoot(\n container: HTMLElement | DocumentFragment,\n { portal: _portal, scope = \"fragment\", unknownBricks }: CreateRootOptions = {}\n) {\n let portal = _portal;\n let createPortal: RenderRoot[\"createPortal\"];\n if (_portal) {\n createPortal = _portal;\n } else {\n // Create portal container when necessary.\n createPortal = () => {\n portal = document.createElement(\"div\");\n portal.style.position = \"absolute\";\n portal.style.width = portal.style.height = \"0\";\n document.body.append(portal);\n return portal;\n };\n }\n let unmounted = false;\n let rendererContext: RendererContext | undefined;\n let clearI18nBundles: Function | undefined;\n\n return {\n async render(\n brick: BrickConf | BrickConf[],\n {\n theme,\n uiVersion,\n language,\n context,\n functions,\n templates,\n i18n: i18nData,\n url,\n app,\n }: RenderOptions = {}\n ) {\n if (unmounted) {\n throw new Error(\n \"The root is unmounted and cannot be rendered any more\"\n );\n }\n const bricks = ([] as BrickConf[]).concat(brick);\n\n const previousRendererContext = rendererContext;\n const renderId = uniqueId(\"render-id-\");\n rendererContext = new RendererContext(scope, { unknownBricks, renderId });\n\n const runtimeContext = {\n ctxStore: new DataStore(\"CTX\", undefined, rendererContext),\n pendingPermissionsPreCheck: [],\n tplStateStoreMap: new Map<string, DataStore<\"STATE\">>(),\n formStateStoreMap: new Map<string, DataStore<\"FORM_STATE\">>(),\n } as Partial<RuntimeContext> as RuntimeContext;\n\n if (url) {\n const urlObj = new URL(url);\n runtimeContext.query = urlObj.searchParams;\n runtimeContext.location = {\n pathname: urlObj.pathname,\n search: urlObj.search,\n hash: urlObj.hash,\n state: undefined,\n };\n }\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n container,\n createPortal,\n };\n\n if (scope === \"page\") {\n setTheme(theme ?? \"light\");\n setMode(\"default\");\n setUIVersion(uiVersion);\n if (language) {\n await i18n.changeLanguage(language);\n }\n\n app ??= {\n id: \"demo\",\n homepage: \"/demo\",\n } as MicroApp;\n runtimeContext.app = app;\n const demoStoryboard = {\n app,\n meta: {\n i18n: i18nData,\n customTemplates: templates,\n },\n } as Storyboard;\n\n // Register i18n.\n clearI18nBundles?.();\n clearI18nBundles = registerAppI18n(demoStoryboard);\n\n // Register custom templates.\n registerCustomTemplates(demoStoryboard);\n\n // Register functions.\n registerStoryboardFunctions(functions, app);\n }\n\n runtimeContext.ctxStore.define(context, runtimeContext);\n\n let failed = false;\n let output: RenderOutput;\n let stores: DataStore<\"CTX\" | \"STATE\" | \"FORM_STATE\">[] = [];\n\n try {\n output = await renderBricks(\n renderRoot,\n bricks,\n runtimeContext,\n rendererContext,\n [],\n {}\n );\n\n stores = getDataStores(runtimeContext);\n await postAsyncRender(output, runtimeContext, stores);\n } catch (error) {\n failed = true;\n output = {\n node: await ErrorNode(error, renderRoot, scope === \"page\"),\n blockingList: [],\n };\n }\n\n renderRoot.child = output.node;\n\n previousRendererContext?.dispatchOnUnmount();\n previousRendererContext?.dispose();\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n }\n\n if (scope === \"page\") {\n if (!failed) {\n rendererContext.dispatchBeforePageLoad();\n }\n\n applyTheme();\n applyMode();\n }\n\n mountTree(renderRoot);\n\n if (scope === \"page\") {\n window.scrollTo(0, 0);\n }\n\n if (!failed) {\n for (const store of stores) {\n store.mountAsyncData();\n }\n\n if (scope === \"page\") {\n rendererContext.dispatchPageLoad();\n // rendererContext.dispatchAnchorLoad();\n }\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n }\n },\n unmount() {\n if (unmounted) {\n return;\n }\n unmounted = true;\n unmountTree(container);\n if (portal) {\n unmountTree(portal);\n // Only remove the portal from its parent when it's dynamic created.\n if (!_portal) {\n portal.remove();\n }\n }\n },\n };\n}\n"],"mappings":";;;;;;AAUA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,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AAIC,MAAM,EAAE;QACV,IAAAmF,kBAAW,EAACnF,MAAM,CAAC;MACrB;MAEA,IAAIE,KAAK,KAAK,MAAM,EAAE;QACpB,IAAI,CAACoE,MAAM,EAAE;UACXxD,eAAe,CAACsE,sBAAsB,CAAC,CAAC;QAC1C;QAEA,IAAAC,wBAAU,EAAC,CAAC;QACZ,IAAAC,uBAAS,EAAC,CAAC;MACb;MAEA,IAAAC,gBAAS,EAACnC,UAAU,CAAC;MAErB,IAAIlD,KAAK,KAAK,MAAM,EAAE;QACpBsF,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;MACvB;MAEA,IAAI,CAACnB,MAAM,EAAE;QACX,KAAK,MAAMoB,KAAK,IAAIlB,MAAM,EAAE;UAC1BkB,KAAK,CAACC,cAAc,CAAC,CAAC;QACxB;QAEA,IAAIzF,KAAK,KAAK,MAAM,EAAE;UACpBY,eAAe,CAAC8E,gBAAgB,CAAC,CAAC;UAClC;QACF;QACA9E,eAAe,CAAC+E,eAAe,CAAC,CAAC;QACjC/E,eAAe,CAACgF,wBAAwB,CAAC,CAAC;QAC1ChF,eAAe,CAACiF,qBAAqB,CAAC,CAAC;QACvCjF,eAAe,CAACkF,2BAA2B,CAAC,CAAC;MAC/C;IACF,CAAC;IACDC,OAAOA,CAAA,EAAG;MACR,IAAIpF,SAAS,EAAE;QACb;MACF;MACAA,SAAS,GAAG,IAAI;MAChB,IAAAsE,kBAAW,EAACpF,SAAS,CAAC;MACtB,IAAIC,MAAM,EAAE;QACV,IAAAmF,kBAAW,EAACnF,MAAM,CAAC;QACnB;QACA,IAAI,CAACC,OAAO,EAAE;UACZD,MAAM,CAACkG,MAAM,CAAC,CAAC;QACjB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -28,7 +28,7 @@ function bindTemplateProxy(brick) {
|
|
|
28
28
|
if (events) {
|
|
29
29
|
for (const [from, to] of Object.entries(events)) {
|
|
30
30
|
if (to.ref === ref) {
|
|
31
|
-
var
|
|
31
|
+
var _ref;
|
|
32
32
|
const listener = e => {
|
|
33
33
|
if (e.bubbles) {
|
|
34
34
|
e.stopPropagation();
|
|
@@ -40,9 +40,9 @@ function bindTemplateProxy(brick) {
|
|
|
40
40
|
composed: e.composed
|
|
41
41
|
}));
|
|
42
42
|
};
|
|
43
|
-
const eventType =
|
|
43
|
+
const eventType = to.refEvent ?? from;
|
|
44
44
|
element.addEventListener(eventType, listener);
|
|
45
|
-
(_ref
|
|
45
|
+
(_ref = element).$$proxyListeners ?? (_ref.$$proxyListeners = []);
|
|
46
46
|
element.$$proxyListeners.push([eventType, listener]);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -63,8 +63,7 @@ function unbindTemplateProxy(brick) {
|
|
|
63
63
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
64
64
|
const tplHostMetadata = hostBrick.tplHostMetadata;
|
|
65
65
|
tplHostMetadata.internalBricksByRef.delete(ref);
|
|
66
|
-
for (const [type, fn] of
|
|
67
|
-
var _$$proxyListeners;
|
|
66
|
+
for (const [type, fn] of element.$$proxyListeners ?? []) {
|
|
68
67
|
element.removeEventListener(type, fn);
|
|
69
68
|
}
|
|
70
69
|
delete element.$$proxyListeners;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindTemplateProxy.js","names":["_utils","require","bindTemplateProxy","brick","_tplHostMetadata$prox","ref","runtimeContext","element","tplStateStoreId","hostBrick","getTplStateStore","tplHostMetadata","internalBricksByRef","set","events","proxy","from","to","Object","entries","
|
|
1
|
+
{"version":3,"file":"bindTemplateProxy.js","names":["_utils","require","bindTemplateProxy","brick","_tplHostMetadata$prox","ref","runtimeContext","element","tplStateStoreId","hostBrick","getTplStateStore","tplHostMetadata","internalBricksByRef","set","events","proxy","from","to","Object","entries","_ref","listener","e","bubbles","stopPropagation","dispatchEvent","CustomEvent","detail","cancelable","composed","eventType","refEvent","addEventListener","$$proxyListeners","push","unbindTemplateProxy","delete","type","fn","removeEventListener"],"sources":["../../../../src/internal/CustomTemplates/bindTemplateProxy.ts"],"sourcesContent":["import type { RuntimeBrick } from \"../interfaces.js\";\nimport { getTplStateStore } from \"./utils.js\";\n\nexport function bindTemplateProxy(brick: RuntimeBrick) {\n const { ref, runtimeContext, element } = brick;\n\n // Error recovering brick may have no runtimeContext.\n if (!ref || !runtimeContext.tplStateStoreId) {\n return;\n }\n\n const { hostBrick } = getTplStateStore(runtimeContext, \"bindTemplateProxy\");\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const tplHostMetadata = hostBrick!.tplHostMetadata!;\n\n tplHostMetadata.internalBricksByRef.set(ref, brick);\n\n const events = tplHostMetadata.proxy?.events;\n if (events) {\n for (const [from, to] of Object.entries(events)) {\n if (to.ref === ref) {\n const listener = (e: Event) => {\n if (e.bubbles) {\n e.stopPropagation();\n }\n hostBrick!.element!.dispatchEvent(\n new CustomEvent(from, {\n detail: (e as CustomEvent).detail,\n bubbles: e.bubbles,\n cancelable: e.cancelable,\n composed: e.composed,\n })\n );\n };\n const eventType = to.refEvent ?? from;\n element!.addEventListener(eventType, listener);\n element!.$$proxyListeners ??= [];\n element!.$$proxyListeners.push([eventType, listener]);\n }\n }\n }\n}\n\nexport function unbindTemplateProxy(brick: RuntimeBrick) {\n const { ref, runtimeContext, element } = brick;\n\n if (!runtimeContext?.tplStateStoreId || !ref) {\n return;\n }\n\n const { hostBrick } = getTplStateStore(runtimeContext, \"unbindTemplateProxy\");\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const tplHostMetadata = hostBrick!.tplHostMetadata!;\n\n tplHostMetadata.internalBricksByRef.delete(ref);\n\n for (const [type, fn] of element!.$$proxyListeners ?? []) {\n element!.removeEventListener(type, fn);\n }\n delete element!.$$proxyListeners;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,iBAAiBA,CAACC,KAAmB,EAAE;EAAA,IAAAC,qBAAA;EACrD,MAAM;IAAEC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AK,EAAE;QAChC1B,OAAO,CAAE0B,gBAAgB,CAACC,IAAI,CAAC,CAACJ,SAAS,EAAET,QAAQ,CAAC,CAAC;MACvD;IACF;EACF;AACF;AAEO,SAASc,mBAAmBA,CAAChC,KAAmB,EAAE;EACvD,MAAM;IAAEE,GAAG;IAAEC,cAAc;IAAEC;EAAQ,CAAC,GAAGJ,KAAK;EAE9C,IAAI,EAACG,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAEE,eAAe,KAAI,CAACH,GAAG,EAAE;IAC5C;EACF;EAEA,MAAM;IAAEI;EAAU,CAAC,GAAG,IAAAC,uBAAgB,EAACJ,cAAc,EAAE,qBAAqB,CAAC;EAC7E;EACA,MAAMK,eAAe,GAAGF,SAAS,CAAEE,eAAgB;EAEnDA,eAAe,CAACC,mBAAmB,CAACwB,MAAM,CAAC/B,GAAG,CAAC;EAE/C,KAAK,MAAM,CAACgC,IAAI,EAAEC,EAAE,CAAC,IAAI/B,OAAO,CAAE0B,gBAAgB,IAAI,EAAE,EAAE;IACxD1B,OAAO,CAAEgC,mBAAmB,CAACF,IAAI,EAAEC,EAAE,CAAC;EACxC;EACA,OAAO/B,OAAO,CAAE0B,gBAAgB;AAClC","ignoreList":[]}
|
|
@@ -121,13 +121,10 @@ function expandBrickInTemplate(brickConfInTemplate, hostContext, markSlotted) {
|
|
|
121
121
|
const markChild = () => {
|
|
122
122
|
slotted = true;
|
|
123
123
|
};
|
|
124
|
-
const slots = Object.fromEntries(Object.entries(transpiledSlots
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).flatMap(item => expandBrickInTemplate(item, hostContext, markChild))
|
|
129
|
-
}];
|
|
130
|
-
}));
|
|
124
|
+
const slots = Object.fromEntries(Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [slotName, {
|
|
125
|
+
type: "bricks",
|
|
126
|
+
bricks: (slotConf.bricks ?? []).flatMap(item => expandBrickInTemplate(item, hostContext, markChild))
|
|
127
|
+
}]));
|
|
131
128
|
return {
|
|
132
129
|
...restBrickConfInTemplate,
|
|
133
130
|
properties: (0, _setupUseBrickInTemplate.setupUseBrickInTemplate)(properties, hostContext),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandCustomTemplate.js","names":["_lodash","require","_CustomTemplates","_DataStore","_setupTemplateProxy","_setupUseBrickInTemplate","_Renderer","_Runtime","_replaceSlotWithSlottedBricks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostPropertyEntries","rendererContext","_hooks$flowApi","tplStateStoreId","uniqueId","runtimeContext","forEachItem","forEachIndex","forEachSize","formStateStoreId","tplStateStore","DataStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","customTemplates","get","hooks","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","childrenToSlots","usedSlots","Set","type","flatMap","item","expandBrickInTemplate","brickConfInTemplate","markSlotted","if","replaceSlotWithSlottedBricks","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","transpiledSlots","slotted","markChild","fromEntries","map","slotName","slotConf","_slotConf$bricks","setupUseBrickInTemplate","setupTemplateProxy"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotConfOfBricks,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncPropertyEntry,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\nimport { replaceSlotWithSlottedBricks } from \"./replaceSlotWithSlottedBricks.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostPropertyEntries: AsyncPropertyEntry[],\n rendererContext: RendererContext\n): T {\n const tplStateStoreId = uniqueId(\"tpl-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n tplStateStoreId,\n };\n\n // There is a boundary for `forEach*` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\n \"STATE\",\n hostBrick,\n rendererContext,\n tplStateStoreId\n );\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostPropertyEntries);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n usedSlots: new Set(),\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.flatMap((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConf,\n hostContext: TemplateHostContext,\n markSlotted?: () => void\n): BrickConf | BrickConf[] {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n\n if (brickConfInTemplate.brick === \"slot\") {\n markSlotted?.();\n return replaceSlotWithSlottedBricks(\n brickConfInTemplate,\n hostContext,\n expandBrickInTemplate\n );\n }\n\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate as BrickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n let slotted = false;\n const markChild = () => {\n slotted = true;\n };\n const slots = Object.fromEntries<SlotConfOfBricks>(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).flatMap((item) =>\n expandBrickInTemplate(item, hostContext, markChild)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(\n hostContext,\n restBrickConfInTemplate.ref,\n slots,\n slotted\n ),\n };\n}\n"],"mappings":";;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAOA,IAAAI,wBAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAEA,IAAAO,6BAAA,GAAAP,OAAA;AAEO,SAASQ,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,wBAA8C,EAC9CC,eAAgC,EAC7B;EAAA,IAAAC,cAAA;EACH,MAAMC,eAAe,GAAG,IAAAC,gBAAQ,EAAC,YAAY,CAAC;EAC9C,MAAMC,cAAc,GAAG;IACrB,GAAGN,SAAS,CAACM,cAAc;IAC3BF;EACF,CAAC;;EAED;EACA,OAAOE,cAAc,CAACC,WAAW;EACjC,OAAOD,cAAc,CAACE,YAAY;EAClC,OAAOF,cAAc,CAACG,WAAW;EACjC,OAAOH,cAAc,CAACI,gBAAgB;EAEtC,MAAMC,aAAa,GAAG,IAAIC,oBAAS,CACjC,OAAO,EACPZ,SAAS,EACTE,eAAe,EACfE,eACF,CAAC;EACDE,cAAc,CAACO,gBAAgB,CAACC,GAAG,CAACV,eAAe,EAAEO,aAAa,CAAC;EACnE,IAAIL,cAAc,CAACS,kBAAkB,EAAE;IACrCT,cAAc,CAACS,kBAAkB,CAACC,IAAI,CAACL,aAAa,CAAC;EACvD;EAEA,MAAM;IAAEM,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAU,CAAC,GAAGC,gCAAe,CAACC,GAAG,CAACxB,UAAU,CAAE;EAC5EyB,cAAK,aAALA,cAAK,gBAAApB,cAAA,GAALoB,cAAK,CAAEC,OAAO,cAAArB,cAAA,eAAdA,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AG,IAAAd,yBAAe,EACrCY,kBAAkB,EAClBD,eACF,CAAoC;EAEpC,IAAII,OAAO,GAAG,KAAK;EACnB,MAAMC,SAAS,GAAGA,CAAA,KAAM;IACtBD,OAAO,GAAG,IAAI;EAChB,CAAC;EACD,MAAMnC,KAAK,GAAGc,MAAM,CAACuB,WAAW,CAC9BvB,MAAM,CAACC,OAAO,CAACmB,eAAe,aAAfA,eAAe,cAAfA,eAAe,GAAI,CAAC,CAAC,CAAC,CAACI,GAAG,CAAC,CAAC,CAACC,QAAQ,EAAEC,QAAQ,CAAC;IAAA,IAAAC,gBAAA;IAAA,OAAK,CAClEF,QAAQ,EACR;MACEhB,IAAI,EAAE,QAAQ;MACdjC,MAAM,EAAE,EAAAmD,gBAAA,GAACD,QAAQ,CAAClD,MAAM,cAAAmD,gBAAA,cAAAA,gBAAA,GAAI,EAAE,EAAEjB,OAAO,CAAEC,IAAI,IAC3CC,qBAAqB,CAACD,IAAI,EAAEP,WAAW,EAAEkB,SAAS,CACpD;IACF,CAAC,CACF;EAAA,EACH,CAAC;EAED,OAAO;IACL,GAAGH,uBAAuB;IAC1BtB,UAAU,EAAE,IAAA+B,gDAAuB,EAAC/B,UAAU,EAAEO,WAAW,CAAC;IAC5DlB,KAAK;IACL,GAAG,IAAA2C,sCAAkB,EACnBzB,WAAW,EACXe,uBAAuB,CAAChB,GAAG,EAC3BjB,KAAK,EACLmC,OACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"expandCustomTemplate.js","names":["_lodash","require","_CustomTemplates","_DataStore","_setupTemplateProxy","_setupUseBrickInTemplate","_Renderer","_Runtime","_replaceSlotWithSlottedBricks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostPropertyEntries","rendererContext","_hooks$flowApi","tplStateStoreId","uniqueId","runtimeContext","forEachItem","forEachIndex","forEachSize","formStateStoreId","tplStateStore","DataStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","customTemplates","get","hooks","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","childrenToSlots","usedSlots","Set","type","flatMap","item","expandBrickInTemplate","brickConfInTemplate","markSlotted","if","replaceSlotWithSlottedBricks","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","transpiledSlots","slotted","markChild","fromEntries","map","slotName","slotConf","setupUseBrickInTemplate","setupTemplateProxy"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotConfOfBricks,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncPropertyEntry,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\nimport { replaceSlotWithSlottedBricks } from \"./replaceSlotWithSlottedBricks.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostPropertyEntries: AsyncPropertyEntry[],\n rendererContext: RendererContext\n): T {\n const tplStateStoreId = uniqueId(\"tpl-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n tplStateStoreId,\n };\n\n // There is a boundary for `forEach*` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\n \"STATE\",\n hostBrick,\n rendererContext,\n tplStateStoreId\n );\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostPropertyEntries);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n usedSlots: new Set(),\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.flatMap((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConf,\n hostContext: TemplateHostContext,\n markSlotted?: () => void\n): BrickConf | BrickConf[] {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n\n if (brickConfInTemplate.brick === \"slot\") {\n markSlotted?.();\n return replaceSlotWithSlottedBricks(\n brickConfInTemplate,\n hostContext,\n expandBrickInTemplate\n );\n }\n\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate as BrickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n let slotted = false;\n const markChild = () => {\n slotted = true;\n };\n const slots = Object.fromEntries<SlotConfOfBricks>(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).flatMap((item) =>\n expandBrickInTemplate(item, hostContext, markChild)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(\n hostContext,\n restBrickConfInTemplate.ref,\n slots,\n slotted\n ),\n };\n}\n"],"mappings":";;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAOA,IAAAI,wBAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAEA,IAAAO,6BAAA,GAAAP,OAAA;AAEO,SAASQ,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,wBAA8C,EAC9CC,eAAgC,EAC7B;EAAA,IAAAC,cAAA;EACH,MAAMC,eAAe,GAAG,IAAAC,gBAAQ,EAAC,YA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CACF,CACH,CAAC;EAED,OAAO;IACL,GAAGH,uBAAuB;IAC1BtB,UAAU,EAAE,IAAA8B,gDAAuB,EAAC9B,UAAU,EAAEO,WAAW,CAAC;IAC5DlB,KAAK;IACL,GAAG,IAAA0C,sCAAkB,EACnBxB,WAAW,EACXe,uBAAuB,CAAChB,GAAG,EAC3BjB,KAAK,EACLmC,OACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -9,12 +9,12 @@ var _cook = require("@next-core/cook");
|
|
|
9
9
|
var _setupTemplateProxy = require("./setupTemplateProxy.js");
|
|
10
10
|
var _Renderer = require("../Renderer.js");
|
|
11
11
|
function replaceSlotWithSlottedBricks(brickConf, hostContext, expand) {
|
|
12
|
-
var _brickConf$properties,
|
|
12
|
+
var _brickConf$properties, _defaultSlots$;
|
|
13
13
|
// Currently, no support for `if` in a slot.
|
|
14
14
|
if (brickConf.if != null && !brickConf.if || typeof brickConf.if === "string") {
|
|
15
15
|
throw new Error(`Can not use "if" in a slot currently, check your template "${hostContext.hostBrick.type}"`);
|
|
16
16
|
}
|
|
17
|
-
const slot = String((_brickConf$properties =
|
|
17
|
+
const slot = String(((_brickConf$properties = brickConf.properties) === null || _brickConf$properties === void 0 ? void 0 : _brickConf$properties.name) ?? "");
|
|
18
18
|
|
|
19
19
|
// Currently, no support for expression as slot name.
|
|
20
20
|
if ((0, _cook.isEvaluable)(slot)) {
|
|
@@ -27,8 +27,7 @@ function replaceSlotWithSlottedBricks(brickConf, hostContext, expand) {
|
|
|
27
27
|
}
|
|
28
28
|
hostContext.usedSlots.add(slot);
|
|
29
29
|
if (hostContext.externalSlots && (0, _general.hasOwnProperty)(hostContext.externalSlots, slot)) {
|
|
30
|
-
|
|
31
|
-
const insertBricks = (_hostContext$external = hostContext.externalSlots[slot].bricks) !== null && _hostContext$external !== void 0 ? _hostContext$external : [];
|
|
30
|
+
const insertBricks = hostContext.externalSlots[slot].bricks ?? [];
|
|
32
31
|
if (insertBricks.length > 0) {
|
|
33
32
|
const hostCtx = hostContext.hostBrick.runtimeContext;
|
|
34
33
|
// External bricks of a template, should not access the template internal forEach `ITEM`.
|
|
@@ -38,6 +37,6 @@ function replaceSlotWithSlottedBricks(brickConf, hostContext, expand) {
|
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
const defaultSlots = (0, _Renderer.childrenToSlots)(brickConf.children, brickConf.slots);
|
|
41
|
-
return ((
|
|
40
|
+
return ((defaultSlots === null || defaultSlots === void 0 || (_defaultSlots$ = defaultSlots[""]) === null || _defaultSlots$ === void 0 ? void 0 : _defaultSlots$.bricks) ?? []).flatMap(item => expand(item, hostContext));
|
|
42
41
|
}
|
|
43
42
|
//# sourceMappingURL=replaceSlotWithSlottedBricks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replaceSlotWithSlottedBricks.js","names":["_general","require","_cook","_setupTemplateProxy","_Renderer","replaceSlotWithSlottedBricks","brickConf","hostContext","expand","_brickConf$properties","
|
|
1
|
+
{"version":3,"file":"replaceSlotWithSlottedBricks.js","names":["_general","require","_cook","_setupTemplateProxy","_Renderer","replaceSlotWithSlottedBricks","brickConf","hostContext","expand","_brickConf$properties","_defaultSlots$","if","Error","hostBrick","type","slot","String","properties","name","isEvaluable","usedSlots","has","add","externalSlots","hasOwnProperty","insertBricks","bricks","length","hostCtx","runtimeContext","hostHasForEach","setupTemplateExternalBricksWithForEach","forEachItem","forEachIndex","forEachSize","defaultSlots","childrenToSlots","children","slots","flatMap","item"],"sources":["../../../../src/internal/CustomTemplates/replaceSlotWithSlottedBricks.ts"],"sourcesContent":["import type {\n BrickConf,\n SlotsConfInTemplate,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { isEvaluable } from \"@next-core/cook\";\nimport type { TemplateHostContext } from \"../interfaces.js\";\nimport { setupTemplateExternalBricksWithForEach } from \"./setupTemplateProxy.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function replaceSlotWithSlottedBricks<\n T extends BrickConf | UseSingleBrickConf,\n>(\n brickConf: T,\n hostContext: TemplateHostContext,\n expand: (item: T, hostContext: TemplateHostContext) => T | T[]\n): T[] {\n // Currently, no support for `if` in a slot.\n if (\n (brickConf.if != null && !brickConf.if) ||\n typeof brickConf.if === \"string\"\n ) {\n throw new Error(\n `Can not use \"if\" in a slot currently, check your template \"${hostContext.hostBrick.type}\"`\n );\n }\n\n const slot = String(brickConf.properties?.name ?? \"\");\n\n // Currently, no support for expression as slot name.\n if (isEvaluable(slot)) {\n throw new Error(\n `Can not use an expression as slot name \"${slot}\" currently, check your template \"${hostContext.hostBrick.type}\"`\n );\n }\n\n // Do not repeat the same slot name in a template.\n if (hostContext.usedSlots.has(slot)) {\n throw new Error(\n `Can not have multiple slots with the same name \"${slot}\", check your template \"${hostContext.hostBrick.type}\"`\n );\n }\n hostContext.usedSlots.add(slot);\n\n if (\n hostContext.externalSlots &&\n hasOwnProperty(hostContext.externalSlots, slot)\n ) {\n const insertBricks = hostContext.externalSlots[slot].bricks ?? [];\n if (insertBricks.length > 0) {\n const hostCtx = hostContext.hostBrick.runtimeContext;\n // External bricks of a template, should not access the template internal forEach `ITEM`.\n // For some existing templates who is *USING* this bug, we keep the old behavior.\n const hostHasForEach = hasOwnProperty(hostCtx, \"forEachItem\");\n return (\n hostHasForEach\n ? setupTemplateExternalBricksWithForEach(\n insertBricks,\n hostCtx.forEachItem,\n hostCtx.forEachIndex!,\n hostCtx.forEachSize!\n )\n : insertBricks\n ) as T[];\n }\n }\n\n const defaultSlots = childrenToSlots(brickConf.children, brickConf.slots) as\n | SlotsConfInTemplate\n | undefined;\n return (defaultSlots?.[\"\"]?.bricks ?? []).flatMap((item) =>\n expand(item as T, hostContext)\n );\n}\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,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