@next-core/runtime 1.17.7 → 1.18.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 +4 -4
- package/dist/cjs/CustomTemplates.js.map +1 -1
- package/dist/cjs/auth.js +4 -4
- package/dist/cjs/auth.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js +1 -1
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
- package/dist/cjs/internal/Renderer.js +3 -2
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js +9 -10
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/Router.js +6 -6
- package/dist/cjs/internal/Router.js.map +1 -1
- package/dist/cjs/internal/Runtime.js +16 -12
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/cjs/internal/bindListeners.js +1 -1
- package/dist/cjs/internal/bindListeners.js.map +1 -1
- package/dist/cjs/internal/compute/evaluate.js +3 -3
- package/dist/cjs/internal/compute/evaluate.js.map +1 -1
- package/dist/cjs/internal/compute/getGeneralGlobals.js +2 -2
- package/dist/cjs/internal/compute/getGeneralGlobals.js.map +1 -1
- package/dist/cjs/internal/data/getProviderBrick.js +1 -1
- package/dist/cjs/internal/data/getProviderBrick.js.map +1 -1
- package/dist/cjs/internal/data/resolveData.js +20 -5
- package/dist/cjs/internal/data/resolveData.js.map +1 -1
- package/dist/cjs/internal/fulfilStoryboard.js +1 -1
- package/dist/cjs/internal/fulfilStoryboard.js.map +1 -1
- package/dist/cjs/internal/matchStoryboard.js +2 -2
- package/dist/cjs/internal/matchStoryboard.js.map +1 -1
- package/dist/esm/CustomTemplates.js +4 -4
- package/dist/esm/CustomTemplates.js.map +1 -1
- package/dist/esm/auth.js +4 -4
- package/dist/esm/auth.js.map +1 -1
- package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js +1 -1
- package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
- package/dist/esm/internal/Renderer.js +3 -2
- package/dist/esm/internal/Renderer.js.map +1 -1
- package/dist/esm/internal/RendererContext.js +9 -10
- package/dist/esm/internal/RendererContext.js.map +1 -1
- package/dist/esm/internal/Router.js +6 -6
- package/dist/esm/internal/Router.js.map +1 -1
- package/dist/esm/internal/Runtime.js +14 -10
- package/dist/esm/internal/Runtime.js.map +1 -1
- package/dist/esm/internal/bindListeners.js +1 -1
- package/dist/esm/internal/bindListeners.js.map +1 -1
- package/dist/esm/internal/compute/evaluate.js +3 -3
- package/dist/esm/internal/compute/evaluate.js.map +1 -1
- package/dist/esm/internal/compute/getGeneralGlobals.js +2 -2
- package/dist/esm/internal/compute/getGeneralGlobals.js.map +1 -1
- package/dist/esm/internal/data/getProviderBrick.js +1 -1
- package/dist/esm/internal/data/getProviderBrick.js.map +1 -1
- package/dist/esm/internal/data/resolveData.js +19 -3
- package/dist/esm/internal/data/resolveData.js.map +1 -1
- package/dist/esm/internal/fulfilStoryboard.js +1 -1
- package/dist/esm/internal/fulfilStoryboard.js.map +1 -1
- package/dist/esm/internal/matchStoryboard.js +2 -2
- package/dist/esm/internal/matchStoryboard.js.map +1 -1
- package/dist/types/internal/Runtime.d.ts +2 -1
- package/package.json +13 -13
|
@@ -17,7 +17,7 @@ async function fulfilStoryboard(storyboard) {
|
|
|
17
17
|
}
|
|
18
18
|
async function doFulfilStoryboard(storyboard) {
|
|
19
19
|
var _hooks$fulfilStoryboa;
|
|
20
|
-
await (_Runtime.hooks === null || _Runtime.hooks === void 0
|
|
20
|
+
await (_Runtime.hooks === null || _Runtime.hooks === void 0 || (_hooks$fulfilStoryboa = _Runtime.hooks.fulfilStoryboard) === null || _hooks$fulfilStoryboa === void 0 ? void 0 : _hooks$fulfilStoryboa.call(_Runtime.hooks, storyboard));
|
|
21
21
|
(0, _registerAppI18n.registerAppI18n)(storyboard);
|
|
22
22
|
Object.assign(storyboard, {
|
|
23
23
|
$$fulfilled: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fulfilStoryboard.js","names":["_Runtime","require","_registerAppI18n","fulfilStoryboard","storyboard","$$fulfilled","$$fulfilling","doFulfilStoryboard","_hooks$fulfilStoryboa","hooks","call","registerAppI18n","Object","assign"],"sources":["../../../src/internal/fulfilStoryboard.ts"],"sourcesContent":["import type { RuntimeStoryboard } from \"@next-core/types\";\nimport { hooks } from \"./Runtime.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\n\nexport async function fulfilStoryboard(storyboard: RuntimeStoryboard) {\n if (storyboard.$$fulfilled) {\n return;\n }\n if (!storyboard.$$fulfilling) {\n storyboard.$$fulfilling = doFulfilStoryboard(storyboard);\n }\n return storyboard.$$fulfilling;\n}\n\nasync function doFulfilStoryboard(storyboard: RuntimeStoryboard) {\n await hooks?.fulfilStoryboard?.(storyboard);\n registerAppI18n(storyboard);\n Object.assign(storyboard, {\n $$fulfilled: true,\n $$fulfilling: null,\n });\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEO,eAAeE,gBAAgBA,CAACC,UAA6B,EAAE;EACpE,IAAIA,UAAU,CAACC,WAAW,EAAE;IAC1B;EACF;EACA,IAAI,CAACD,UAAU,CAACE,YAAY,EAAE;IAC5BF,UAAU,CAACE,YAAY,GAAGC,kBAAkB,CAACH,UAAU,CAAC;EAC1D;EACA,OAAOA,UAAU,CAACE,YAAY;AAChC;AAEA,eAAeC,kBAAkBA,CAACH,UAA6B,EAAE;EAAA,IAAAI,qBAAA;EAC/D,OAAMC,cAAK,aAALA,cAAK,
|
|
1
|
+
{"version":3,"file":"fulfilStoryboard.js","names":["_Runtime","require","_registerAppI18n","fulfilStoryboard","storyboard","$$fulfilled","$$fulfilling","doFulfilStoryboard","_hooks$fulfilStoryboa","hooks","call","registerAppI18n","Object","assign"],"sources":["../../../src/internal/fulfilStoryboard.ts"],"sourcesContent":["import type { RuntimeStoryboard } from \"@next-core/types\";\nimport { hooks } from \"./Runtime.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\n\nexport async function fulfilStoryboard(storyboard: RuntimeStoryboard) {\n if (storyboard.$$fulfilled) {\n return;\n }\n if (!storyboard.$$fulfilling) {\n storyboard.$$fulfilling = doFulfilStoryboard(storyboard);\n }\n return storyboard.$$fulfilling;\n}\n\nasync function doFulfilStoryboard(storyboard: RuntimeStoryboard) {\n await hooks?.fulfilStoryboard?.(storyboard);\n registerAppI18n(storyboard);\n Object.assign(storyboard, {\n $$fulfilled: true,\n $$fulfilling: null,\n });\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEO,eAAeE,gBAAgBA,CAACC,UAA6B,EAAE;EACpE,IAAIA,UAAU,CAACC,WAAW,EAAE;IAC1B;EACF;EACA,IAAI,CAACD,UAAU,CAACE,YAAY,EAAE;IAC5BF,UAAU,CAACE,YAAY,GAAGC,kBAAkB,CAACH,UAAU,CAAC;EAC1D;EACA,OAAOA,UAAU,CAACE,YAAY;AAChC;AAEA,eAAeC,kBAAkBA,CAACH,UAA6B,EAAE;EAAA,IAAAI,qBAAA;EAC/D,OAAMC,cAAK,aAALA,cAAK,gBAAAD,qBAAA,GAALC,cAAK,CAAEN,gBAAgB,cAAAK,qBAAA,uBAAvBA,qBAAA,CAAAE,IAAA,CAAAD,cAAK,EAAqBL,UAAU,CAAC;EAC3C,IAAAO,gCAAe,EAACP,UAAU,CAAC;EAC3BQ,MAAM,CAACC,MAAM,CAACT,UAAU,EAAE;IACxBC,WAAW,EAAE,IAAI;IACjBC,YAAY,EAAE;EAChB,CAAC,CAAC;AACJ"}
|
|
@@ -12,8 +12,8 @@ function matchStoryboard(storyboards, pathname) {
|
|
|
12
12
|
// E.g., `/legacy/tool` will match first before `/legacy`.
|
|
13
13
|
// This enables two apps with relationship of parent-child of homepage.
|
|
14
14
|
const sortedStoryboards = (0, _lodash.orderBy)(storyboards, storyboard => {
|
|
15
|
-
var _storyboard$app$homep, _storyboard$app
|
|
16
|
-
return (_storyboard$app$homep = (_storyboard$app = storyboard.app) === null || _storyboard$app === void 0
|
|
15
|
+
var _storyboard$app$homep, _storyboard$app;
|
|
16
|
+
return (_storyboard$app$homep = (_storyboard$app = storyboard.app) === null || _storyboard$app === void 0 || (_storyboard$app = _storyboard$app.homepage) === null || _storyboard$app === void 0 ? void 0 : _storyboard$app.length) !== null && _storyboard$app$homep !== void 0 ? _storyboard$app$homep : 0;
|
|
17
17
|
}, "desc");
|
|
18
18
|
for (const storyboard of sortedStoryboards) {
|
|
19
19
|
const homepage = storyboard.app.homepage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchStoryboard.js","names":["_lodash","require","_Runtime","matchStoryboard","storyboards","pathname","sortedStoryboards","orderBy","storyboard","_storyboard$app$homep","_storyboard$app","
|
|
1
|
+
{"version":3,"file":"matchStoryboard.js","names":["_lodash","require","_Runtime","matchStoryboard","storyboards","pathname","sortedStoryboards","orderBy","storyboard","_storyboard$app$homep","_storyboard$app","app","homepage","length","replace","startsWith","isOutsideApp","_getRuntime$getCurren","process","env","NODE_ENV","getRuntime","getCurrentApp","id","window","STANDALONE_MICRO_APPS","standaloneMode"],"sources":["../../../src/internal/matchStoryboard.ts"],"sourcesContent":["import type { RuntimeStoryboard } from \"@next-core/types\";\nimport { orderBy } from \"lodash\";\nimport { getRuntime } from \"./Runtime.js\";\n\nexport function matchStoryboard(\n storyboards: RuntimeStoryboard[],\n pathname: string\n): RuntimeStoryboard | undefined {\n // Put apps with longer homepage before shorter ones.\n // E.g., `/legacy/tool` will match first before `/legacy`.\n // This enables two apps with relationship of parent-child of homepage.\n const sortedStoryboards = orderBy(\n storyboards,\n (storyboard) => storyboard.app?.homepage?.length ?? 0,\n \"desc\"\n );\n for (const storyboard of sortedStoryboards) {\n const homepage = storyboard.app.homepage;\n if (typeof homepage === \"string\" && homepage[0] === \"/\") {\n if (\n homepage === \"/\"\n ? pathname === homepage\n : `${pathname.replace(/\\/+$/, \"\")}/`.startsWith(\n `${homepage.replace(/\\/+$/, \"\")}/`\n )\n ) {\n return storyboard;\n }\n }\n }\n}\n\n/**\n * We say it's an outside app when at least one of the below conditions are true:\n * - target app is not found.\n * - target app is not the current app.\n * - current app is non-standalone mode and target app is standalone mode.\n *\n * Note: when current app is standalone mode, other apps will not be found.\n */\nexport function isOutsideApp(\n storyboard: RuntimeStoryboard | undefined\n): boolean | undefined {\n if (process.env.NODE_ENV === \"test\") {\n return false;\n }\n return (\n !storyboard ||\n // Sometimes `storyboard.app.standaloneMode` is incorrect.\n (getRuntime().getCurrentApp()?.id !== storyboard.app.id &&\n !window.STANDALONE_MICRO_APPS &&\n storyboard.app.standaloneMode)\n );\n}\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,SAASE,eAAeA,CAC7BC,WAAgC,EAChCC,QAAgB,EACe;EAC/B;EACA;EACA;EACA,MAAMC,iBAAiB,GAAG,IAAAC,eAAO,EAC/BH,WAAW,EACVI,UAAU;IAAA,IAAAC,qBAAA,EAAAC,eAAA;IAAA,QAAAD,qBAAA,IAAAC,eAAA,GAAKF,UAAU,CAACG,GAAG,cAAAD,eAAA,gBAAAA,eAAA,GAAdA,eAAA,CAAgBE,QAAQ,cAAAF,eAAA,uBAAxBA,eAAA,CAA0BG,MAAM,cAAAJ,qBAAA,cAAAA,qBAAA,GAAI,CAAC;EAAA,GACrD,MACF,CAAC;EACD,KAAK,MAAMD,UAAU,IAAIF,iBAAiB,EAAE;IAC1C,MAAMM,QAAQ,GAAGJ,UAAU,CAACG,GAAG,CAACC,QAAQ;IACxC,IAAI,OAAOA,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;MACvD,IACEA,QAAQ,KAAK,GAAG,GACZP,QAAQ,KAAKO,QAAQ,GACpB,GAAEP,QAAQ,CAACS,OAAO,CAAC,MAAM,EAAE,EAAE,CAAE,GAAE,CAACC,UAAU,CAC1C,GAAEH,QAAQ,CAACE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAE,GAClC,CAAC,EACL;QACA,OAAON,UAAU;MACnB;IACF;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,YAAYA,CAC1BR,UAAyC,EACpB;EAAA,IAAAS,qBAAA;EACrB,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;IACnC,OAAO,KAAK;EACd;EACA,OACE,CAACZ,UAAU;EACX;EACC,EAAAS,qBAAA,OAAAI,mBAAU,EAAC,CAAC,CAACC,aAAa,CAAC,CAAC,cAAAL,qBAAA,uBAA5BA,qBAAA,CAA8BM,EAAE,MAAKf,UAAU,CAACG,GAAG,CAACY,EAAE,IACrD,CAACC,MAAM,CAACC,qBAAqB,IAC7BjB,UAAU,CAACG,GAAG,CAACe,cAAe;AAEpC"}
|
|
@@ -96,8 +96,8 @@ class CustomTemplateRegistry {
|
|
|
96
96
|
return methods;
|
|
97
97
|
}
|
|
98
98
|
$$getElementByRef(ref) {
|
|
99
|
-
var _this$$$tplStateStore
|
|
100
|
-
return (_this$$$tplStateStore = this.$$tplStateStore) === null || _this$$$tplStateStore === void 0
|
|
99
|
+
var _this$$$tplStateStore;
|
|
100
|
+
return (_this$$$tplStateStore = this.$$tplStateStore) === null || _this$$$tplStateStore === void 0 || (_this$$$tplStateStore = _this$$$tplStateStore.hostBrick) === null || _this$$$tplStateStore === void 0 || (_this$$$tplStateStore = _this$$$tplStateStore.tplHostMetadata) === null || _this$$$tplStateStore === void 0 || (_this$$$tplStateStore = _this$$$tplStateStore.internalBricksByRef.get(ref)) === null || _this$$$tplStateStore === void 0 ? void 0 : _this$$$tplStateStore.element;
|
|
101
101
|
}
|
|
102
102
|
connectedCallback() {
|
|
103
103
|
var shadowRoot = this.shadowRoot;
|
|
@@ -132,10 +132,10 @@ class CustomTemplateRegistry {
|
|
|
132
132
|
return this.$$tplStateStore.getValue(propName);
|
|
133
133
|
},
|
|
134
134
|
set(value) {
|
|
135
|
-
var _this$$$
|
|
135
|
+
var _this$$$tplStateStore2;
|
|
136
136
|
// 在 mount 过程中,先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,
|
|
137
137
|
// 避免初始化的一次 state update 操作及其 onChange 事件。
|
|
138
|
-
(_this$$$
|
|
138
|
+
(_this$$$tplStateStore2 = this.$$tplStateStore) === null || _this$$$tplStateStore2 === void 0 ? void 0 : _this$$$tplStateStore2.updateValue(propName, value, "replace");
|
|
139
139
|
},
|
|
140
140
|
enumerable: true
|
|
141
141
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTemplates.js","names":["uniq","isStrictMode","warnAboutStrictMode","allowedNativeProps","Set","_registry","WeakMap","CustomTemplateRegistry","constructor","_classPrivateFieldInitSpec","writable","value","Map","define","tagName","_constructor$proxy$pr","_constructor$proxy","_compatibleConstructo","_compatibleConstructo2","registered","_classPrivateFieldGet","has","console","warn","concat","customElements","get","strict","proxyProperties","proxy","properties","validProxyProps","legacyTplVariables","key","Object","entries","asVariable","push","mergeProperty","refTransform","error","ref","compatibleConstructor","_objectSpread","fromEntries","state","map","item","expose","tpl","name","set","exposedStates","getExposedStates","proxyMethods","methods","props","entry","nativeProps","filter","prop","HTMLElement","prototype","length","Error","p","join","TplElement","$$typeof","_dev_only_definedProperties","_dev_only_definedMethods","$$getElementByRef","_this$$$tplStateStore","_this$$$tplStateStore2","_this$$$tplStateStore3","_this$$$tplStateStore4","$$tplStateStore","hostBrick","tplHostMetadata","internalBricksByRef","element","connectedCallback","shadowRoot","attachShadow","mode","fragment","document","createDocumentFragment","style","createElement","textContent","slot","appendChild","disconnectedCallback","_loop","propName","some","defineProperty","getValue","_this$$$tplStateStore5","updateValue","enumerable","_ret","_loop2","from","to","_to$refProperty","refProperty","_this$$$getElementByR","call","_to$refProperty2","_loop3","_from","_to","_to$refMethod","refMethod","arguments","customTemplates","_state$filter$map"],"sources":["../../src/CustomTemplates.ts"],"sourcesContent":["import type {\n ContextConf,\n CustomTemplate,\n CustomTemplateConstructor,\n CustomTemplateProxyBasicProperty,\n} from \"@next-core/types\";\nimport { uniq } from \"lodash\";\nimport type { RuntimeBrickElement } from \"./internal/interfaces.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"./isStrictMode.js\";\n\n// Note: `prefix` is a native prop on Element, but it's only used in XML documents.\nconst allowedNativeProps = new Set([\"prefix\"]);\n\ninterface LegacyTplPropProxy extends CustomTemplateProxyBasicProperty {\n asVariable?: boolean;\n mergeProperty?: unknown;\n refTransform?: unknown;\n}\n\nclass CustomTemplateRegistry {\n readonly #registry = new Map<string, CustomTemplate>();\n\n define(tagName: string, constructor: CustomTemplateConstructor): void {\n let registered = this.#registry.has(tagName);\n if (registered) {\n // When open launchpad, the storyboard will be updated.\n // However, we can't *undefine* a custom element.\n // Just ignore re-registering custom templates.\n // eslint-disable-next-line no-console\n console.warn(`Custom template of \"${tagName}\" already registered.`);\n } else {\n registered = !!customElements.get(tagName);\n if (registered) {\n // eslint-disable-next-line no-console\n console.warn(\n `Custom template of \"${tagName}\" already defined by customElements.`\n );\n }\n }\n\n // Transform legacy `proxy.properties[].asVariable` as states.\n const strict = isStrictMode();\n const proxyProperties = (constructor.proxy?.properties ?? {}) as {\n [name: string]: LegacyTplPropProxy;\n };\n const validProxyProps: [string, CustomTemplateProxyBasicProperty][] = [];\n const legacyTplVariables: string[] = [];\n for (const [key, value] of Object.entries(proxyProperties)) {\n if (value.asVariable) {\n warnAboutStrictMode(strict, \"Template `asVariable`\", tagName, key);\n // istanbul ignore next\n if (!strict) {\n // For existed TPL usage, treat it as a STATE.\n legacyTplVariables.push(key);\n }\n } else if (value.mergeProperty || value.refTransform) {\n // eslint-disable-next-line no-console\n console.error(\n \"Template `mergeProperty` and `refTransform` are dropped in v3:\",\n tagName,\n key\n );\n } else if (value.ref) {\n validProxyProps.push([key, value]);\n }\n // Else: documentation only, for exposed states.\n }\n\n const compatibleConstructor = {\n ...constructor,\n proxy: {\n ...constructor.proxy,\n properties: Object.fromEntries(validProxyProps),\n },\n state: (constructor.state\n ? strict\n ? constructor.state\n : constructor.state.map((item) => ({\n // Make `expose` defaults to true in non-strict mode.\n expose: true,\n ...item,\n }))\n : []\n ).concat(legacyTplVariables.map((tpl) => ({ name: tpl, expose: true }))),\n };\n\n // Now we allow re-register custom template\n this.#registry.set(tagName, {\n ...compatibleConstructor,\n name: tagName,\n });\n\n const exposedStates = getExposedStates(compatibleConstructor.state);\n const proxyMethods = Object.entries(\n compatibleConstructor.proxy?.methods ?? {}\n );\n\n const props = exposedStates.concat(\n validProxyProps.map((entry) => entry[0])\n );\n const methods = proxyMethods.map((entry) => entry[0]);\n\n const nativeProps = props\n .concat(methods)\n .filter(\n (prop) => prop in HTMLElement.prototype && !allowedNativeProps.has(prop)\n );\n if (nativeProps.length > 0) {\n warnAboutStrictMode(\n strict,\n \"Using native HTMLElement properties as template properties or methods\",\n tagName,\n ...nativeProps\n );\n // istanbul ignore next\n if (strict) {\n throw new Error(\n `In custom template \"${tagName}\", ${nativeProps\n .map((p) => `\"${p}\"`)\n .join(\n \", \"\n )} are native HTMLElement properties, and should be avoid to be used as brick properties or methods.`\n );\n }\n }\n\n if (registered) {\n return;\n }\n\n class TplElement extends HTMLElement {\n get $$typeof() {\n return \"custom-template\" as const;\n }\n\n static get _dev_only_definedProperties(): string[] {\n return props;\n }\n\n static get _dev_only_definedMethods(): string[] {\n return methods;\n }\n\n $$getElementByRef(this: RuntimeBrickElement, ref: string) {\n return this.$$tplStateStore?.hostBrick?.tplHostMetadata?.internalBricksByRef.get(\n ref\n )?.element;\n }\n\n connectedCallback() {\n let shadowRoot = this.shadowRoot;\n if (!shadowRoot) {\n shadowRoot = this.attachShadow({ mode: \"open\" });\n }\n const fragment = document.createDocumentFragment();\n const style = document.createElement(\"style\");\n style.textContent = \":host{display:block}:host([hidden]){display:none}\";\n const slot = document.createElement(\"slot\");\n fragment.appendChild(style);\n fragment.appendChild(slot);\n shadowRoot.appendChild(fragment);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) {\n this.shadowRoot.textContent = \"\";\n }\n }\n }\n\n for (const propName of exposedStates) {\n if (validProxyProps.some((entry) => entry[0] === propName)) {\n // eslint-disable-next-line no-console\n console.error(\n `Cannot define an exposed state that is also a proxy property: \"${propName}\" in ${tagName}`\n );\n continue;\n }\n Object.defineProperty(TplElement.prototype, propName, {\n get(this: RuntimeBrickElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.$$tplStateStore!.getValue(propName);\n },\n set(this: RuntimeBrickElement, value: unknown) {\n // 在 mount 过程中,先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n this.$$tplStateStore?.updateValue(propName, value, \"replace\");\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of validProxyProps) {\n Object.defineProperty(TplElement.prototype, from, {\n get(this: TplElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n unknown\n >;\n return element[to.refProperty ?? from];\n },\n set(this: TplElement, value: unknown) {\n // 同上 exposedState.set\n const element = this.$$getElementByRef?.(to.ref) as unknown as Record<\n string,\n unknown\n >;\n if (element) {\n element[to.refProperty ?? from] = value;\n }\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of proxyMethods) {\n Object.defineProperty(TplElement.prototype, from, {\n value(this: TplElement, ...args: unknown[]) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n Function\n >;\n element[to.refMethod ?? from](...args);\n },\n enumerable: true,\n });\n }\n\n customElements.define(tagName, TplElement);\n }\n\n get(tagName: string) {\n return this.#registry.get(tagName);\n }\n}\n\nexport const customTemplates = new CustomTemplateRegistry();\n\nfunction getExposedStates(state: ContextConf[] | undefined): string[] {\n // Allow duplicated state names which maybe mutually exclusive.\n return uniq(\n state?.filter((item) => item.expose).map((item) => item.name) ?? []\n );\n}\n"],"mappings":";;;AAMA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,mBAAmB;;AAErE;AACA,IAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AAAC,IAAAC,SAAA,oBAAAC,OAAA;AAQ/C,MAAMC,sBAAsB,CAAC;EAAAC,YAAA;IAAAC,0BAAA,OAAAJ,SAAA;MAAAK,QAAA;MAAAC,KAAA,EACN,IAAIC,GAAG,CAAyB;IAAC;EAAA;EAEtDC,MAAMA,CAACC,OAAe,EAAEN,WAAsC,EAAQ;IAAA,IAAAO,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,sBAAA;IACpE,IAAIC,UAAU,GAAGC,qBAAA,KAAI,EAAAf,SAAA,EAAWgB,GAAG,CAACP,OAAO,CAAC;IAC5C,IAAIK,UAAU,EAAE;MACd;MACA;MACA;MACA;MACAG,OAAO,CAACC,IAAI,yBAAAC,MAAA,CAAwBV,OAAO,2BAAuB,CAAC;IACrE,CAAC,MAAM;MACLK,UAAU,GAAG,CAAC,CAACM,cAAc,CAACC,GAAG,CAACZ,OAAO,CAAC;MAC1C,IAAIK,UAAU,EAAE;QACd;QACAG,OAAO,CAACC,IAAI,yBAAAC,MAAA,CACaV,OAAO,0CAChC,CAAC;MACH;IACF;;IAEA;IACA,IAAMa,MAAM,GAAG1B,YAAY,CAAC,CAAC;IAC7B,IAAM2B,eAAe,IAAAb,qBAAA,IAAAC,kBAAA,GAAIR,WAAW,CAACqB,KAAK,cAAAb,kBAAA,uBAAjBA,kBAAA,CAAmBc,UAAU,cAAAf,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAE1D;IACD,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,MAAM,CAACC,OAAO,EAAEqD,UAAU,CAAC;EAC5C;EAEAzC,GAAGA,CAACZ,OAAe,EAAE;IACnB,OAAOM,qBAAA,KAAI,EAAAf,SAAA,EAAWqB,GAAG,CAACZ,OAAO,CAAC;EACpC;AACF;AAEA,OAAO,IAAMuG,eAAe,GAAG,IAAI9G,sBAAsB,CAAC,CAAC;AAE3D,SAAS8C,gBAAgBA,CAACR,KAAgC,EAAY;EAAA,IAAAyE,iBAAA;EACpE;EACA,OAAOtH,IAAI,EAAAsH,iBAAA,GACTzE,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEc,MAAM,CAAEZ,IAAI,IAAKA,IAAI,CAACC,MAAM,CAAC,CAACF,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACG,IAAI,CAAC,cAAAoE,iBAAA,cAAAA,iBAAA,GAAI,EACnE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"CustomTemplates.js","names":["uniq","isStrictMode","warnAboutStrictMode","allowedNativeProps","Set","_registry","WeakMap","CustomTemplateRegistry","constructor","_classPrivateFieldInitSpec","writable","value","Map","define","tagName","_constructor$proxy$pr","_constructor$proxy","_compatibleConstructo","_compatibleConstructo2","registered","_classPrivateFieldGet","has","console","warn","concat","customElements","get","strict","proxyProperties","proxy","properties","validProxyProps","legacyTplVariables","key","Object","entries","asVariable","push","mergeProperty","refTransform","error","ref","compatibleConstructor","_objectSpread","fromEntries","state","map","item","expose","tpl","name","set","exposedStates","getExposedStates","proxyMethods","methods","props","entry","nativeProps","filter","prop","HTMLElement","prototype","length","Error","p","join","TplElement","$$typeof","_dev_only_definedProperties","_dev_only_definedMethods","$$getElementByRef","_this$$$tplStateStore","$$tplStateStore","hostBrick","tplHostMetadata","internalBricksByRef","element","connectedCallback","shadowRoot","attachShadow","mode","fragment","document","createDocumentFragment","style","createElement","textContent","slot","appendChild","disconnectedCallback","_loop","propName","some","defineProperty","getValue","_this$$$tplStateStore2","updateValue","enumerable","_ret","_loop2","from","to","_to$refProperty","refProperty","_this$$$getElementByR","call","_to$refProperty2","_loop3","_from","_to","_to$refMethod","refMethod","arguments","customTemplates","_state$filter$map"],"sources":["../../src/CustomTemplates.ts"],"sourcesContent":["import type {\n ContextConf,\n CustomTemplate,\n CustomTemplateConstructor,\n CustomTemplateProxyBasicProperty,\n} from \"@next-core/types\";\nimport { uniq } from \"lodash\";\nimport type { RuntimeBrickElement } from \"./internal/interfaces.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"./isStrictMode.js\";\n\n// Note: `prefix` is a native prop on Element, but it's only used in XML documents.\nconst allowedNativeProps = new Set([\"prefix\"]);\n\ninterface LegacyTplPropProxy extends CustomTemplateProxyBasicProperty {\n asVariable?: boolean;\n mergeProperty?: unknown;\n refTransform?: unknown;\n}\n\nclass CustomTemplateRegistry {\n readonly #registry = new Map<string, CustomTemplate>();\n\n define(tagName: string, constructor: CustomTemplateConstructor): void {\n let registered = this.#registry.has(tagName);\n if (registered) {\n // When open launchpad, the storyboard will be updated.\n // However, we can't *undefine* a custom element.\n // Just ignore re-registering custom templates.\n // eslint-disable-next-line no-console\n console.warn(`Custom template of \"${tagName}\" already registered.`);\n } else {\n registered = !!customElements.get(tagName);\n if (registered) {\n // eslint-disable-next-line no-console\n console.warn(\n `Custom template of \"${tagName}\" already defined by customElements.`\n );\n }\n }\n\n // Transform legacy `proxy.properties[].asVariable` as states.\n const strict = isStrictMode();\n const proxyProperties = (constructor.proxy?.properties ?? {}) as {\n [name: string]: LegacyTplPropProxy;\n };\n const validProxyProps: [string, CustomTemplateProxyBasicProperty][] = [];\n const legacyTplVariables: string[] = [];\n for (const [key, value] of Object.entries(proxyProperties)) {\n if (value.asVariable) {\n warnAboutStrictMode(strict, \"Template `asVariable`\", tagName, key);\n // istanbul ignore next\n if (!strict) {\n // For existed TPL usage, treat it as a STATE.\n legacyTplVariables.push(key);\n }\n } else if (value.mergeProperty || value.refTransform) {\n // eslint-disable-next-line no-console\n console.error(\n \"Template `mergeProperty` and `refTransform` are dropped in v3:\",\n tagName,\n key\n );\n } else if (value.ref) {\n validProxyProps.push([key, value]);\n }\n // Else: documentation only, for exposed states.\n }\n\n const compatibleConstructor = {\n ...constructor,\n proxy: {\n ...constructor.proxy,\n properties: Object.fromEntries(validProxyProps),\n },\n state: (constructor.state\n ? strict\n ? constructor.state\n : constructor.state.map((item) => ({\n // Make `expose` defaults to true in non-strict mode.\n expose: true,\n ...item,\n }))\n : []\n ).concat(legacyTplVariables.map((tpl) => ({ name: tpl, expose: true }))),\n };\n\n // Now we allow re-register custom template\n this.#registry.set(tagName, {\n ...compatibleConstructor,\n name: tagName,\n });\n\n const exposedStates = getExposedStates(compatibleConstructor.state);\n const proxyMethods = Object.entries(\n compatibleConstructor.proxy?.methods ?? {}\n );\n\n const props = exposedStates.concat(\n validProxyProps.map((entry) => entry[0])\n );\n const methods = proxyMethods.map((entry) => entry[0]);\n\n const nativeProps = props\n .concat(methods)\n .filter(\n (prop) => prop in HTMLElement.prototype && !allowedNativeProps.has(prop)\n );\n if (nativeProps.length > 0) {\n warnAboutStrictMode(\n strict,\n \"Using native HTMLElement properties as template properties or methods\",\n tagName,\n ...nativeProps\n );\n // istanbul ignore next\n if (strict) {\n throw new Error(\n `In custom template \"${tagName}\", ${nativeProps\n .map((p) => `\"${p}\"`)\n .join(\n \", \"\n )} are native HTMLElement properties, and should be avoid to be used as brick properties or methods.`\n );\n }\n }\n\n if (registered) {\n return;\n }\n\n class TplElement extends HTMLElement {\n get $$typeof() {\n return \"custom-template\" as const;\n }\n\n static get _dev_only_definedProperties(): string[] {\n return props;\n }\n\n static get _dev_only_definedMethods(): string[] {\n return methods;\n }\n\n $$getElementByRef(this: RuntimeBrickElement, ref: string) {\n return this.$$tplStateStore?.hostBrick?.tplHostMetadata?.internalBricksByRef.get(\n ref\n )?.element;\n }\n\n connectedCallback() {\n let shadowRoot = this.shadowRoot;\n if (!shadowRoot) {\n shadowRoot = this.attachShadow({ mode: \"open\" });\n }\n const fragment = document.createDocumentFragment();\n const style = document.createElement(\"style\");\n style.textContent = \":host{display:block}:host([hidden]){display:none}\";\n const slot = document.createElement(\"slot\");\n fragment.appendChild(style);\n fragment.appendChild(slot);\n shadowRoot.appendChild(fragment);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) {\n this.shadowRoot.textContent = \"\";\n }\n }\n }\n\n for (const propName of exposedStates) {\n if (validProxyProps.some((entry) => entry[0] === propName)) {\n // eslint-disable-next-line no-console\n console.error(\n `Cannot define an exposed state that is also a proxy property: \"${propName}\" in ${tagName}`\n );\n continue;\n }\n Object.defineProperty(TplElement.prototype, propName, {\n get(this: RuntimeBrickElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.$$tplStateStore!.getValue(propName);\n },\n set(this: RuntimeBrickElement, value: unknown) {\n // 在 mount 过程中,先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n this.$$tplStateStore?.updateValue(propName, value, \"replace\");\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of validProxyProps) {\n Object.defineProperty(TplElement.prototype, from, {\n get(this: TplElement) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n unknown\n >;\n return element[to.refProperty ?? from];\n },\n set(this: TplElement, value: unknown) {\n // 同上 exposedState.set\n const element = this.$$getElementByRef?.(to.ref) as unknown as Record<\n string,\n unknown\n >;\n if (element) {\n element[to.refProperty ?? from] = value;\n }\n },\n enumerable: true,\n });\n }\n\n for (const [from, to] of proxyMethods) {\n Object.defineProperty(TplElement.prototype, from, {\n value(this: TplElement, ...args: unknown[]) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const element = this.$$getElementByRef!(to.ref) as unknown as Record<\n string,\n Function\n >;\n element[to.refMethod ?? from](...args);\n },\n enumerable: true,\n });\n }\n\n customElements.define(tagName, TplElement);\n }\n\n get(tagName: string) {\n return this.#registry.get(tagName);\n }\n}\n\nexport const customTemplates = new CustomTemplateRegistry();\n\nfunction getExposedStates(state: ContextConf[] | undefined): string[] {\n // Allow duplicated state names which maybe mutually exclusive.\n return uniq(\n state?.filter((item) => item.expose).map((item) => item.name) ?? []\n );\n}\n"],"mappings":";;;AAMA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,mBAAmB;;AAErE;AACA,IAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AAAC,IAAAC,SAAA,oBAAAC,OAAA;AAQ/C,MAAMC,sBAAsB,CAAC;EAAAC,YAAA;IAAAC,0BAAA,OAAAJ,SAAA;MAAAK,QAAA;MAAAC,KAAA,EACN,IAAIC,GAAG,CAAyB;IAAC;EAAA;EAEtDC,MAAMA,CAACC,OAAe,EAAEN,WAAsC,EAAQ;IAAA,IAAAO,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,sBAAA;IACpE,IAAIC,UAAU,GAAGC,qBAAA,KAAI,EAAAf,SAAA,EAAWgB,GAAG,CAACP,OAAO,CAAC;IAC5C,IAAIK,UAAU,EAAE;MACd;MACA;MACA;MACA;MACAG,OAAO,CAACC,IAAI,yBAAAC,MAAA,CAAwBV,OAAO,2BAAuB,CAAC;IACrE,CAAC,MAAM;MACLK,UAAU,GAAG,CAAC,CAACM,cAAc,CAACC,GAAG,CAACZ,OAAO,CAAC;MAC1C,IAAIK,UAAU,EAAE;QACd;QACAG,OAAO,CAACC,IAAI,yBAAAC,MAAA,CACaV,OAAO,0CAChC,CAAC;MACH;IACF;;IAEA;IACA,IAAMa,MAAM,GAAG1B,YAAY,CAAC,CAAC;IAC7B,IAAM2B,eAAe,IAAAb,qBAAA,IAAAC,kBAAA,GAAIR,WAAW,CAACqB,KAAK,cAAAb,kBAAA,uBAAjBA,kBAAA,CAAmBc,UAAU,cAAAf,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAE1D;IACD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;EAC5C;EAEAzC,GAAGA,CAACZ,OAAe,EAAE;IACnB,OAAOM,qBAAA,KAAI,EAAAf,SAAA,EAAWqB,GAAG,CAACZ,OAAO,CAAC;EACpC;AACF;AAEA,OAAO,IAAMoG,eAAe,GAAG,IAAI3G,sBAAsB,CAAC,CAAC;AAE3D,SAAS8C,gBAAgBA,CAACR,KAAgC,EAAY;EAAA,IAAAsE,iBAAA;EACpE;EACA,OAAOnH,IAAI,EAAAmH,iBAAA,GACTtE,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEc,MAAM,CAAEZ,IAAI,IAAKA,IAAI,CAACC,MAAM,CAAC,CAACF,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACG,IAAI,CAAC,cAAAiE,iBAAA,cAAAA,iBAAA,GAAI,EACnE,CAAC;AACH"}
|
package/dist/esm/auth.js
CHANGED
|
@@ -8,24 +8,24 @@ export function authenticate() {
|
|
|
8
8
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
9
|
args[_key] = arguments[_key];
|
|
10
10
|
}
|
|
11
|
-
hooks === null || hooks === void 0
|
|
11
|
+
hooks === null || hooks === void 0 || (_hooks$auth = hooks.auth) === null || _hooks$auth === void 0 || (_hooks$auth$authentic = _hooks$auth.authenticate) === null || _hooks$auth$authentic === void 0 ? void 0 : _hooks$auth$authentic.call(_hooks$auth, ...args);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/** @deprecated import it from "@next-core/easyops-runtime" instead */
|
|
15
15
|
export function getAuth() {
|
|
16
16
|
var _hooks$auth2;
|
|
17
|
-
return hooks === null || hooks === void 0
|
|
17
|
+
return hooks === null || hooks === void 0 || (_hooks$auth2 = hooks.auth) === null || _hooks$auth2 === void 0 ? void 0 : _hooks$auth2.getAuth();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/** @deprecated import it from "@next-core/easyops-runtime" instead */
|
|
21
21
|
export function logout() {
|
|
22
22
|
var _hooks$auth3, _hooks$auth3$logout;
|
|
23
|
-
return hooks === null || hooks === void 0
|
|
23
|
+
return hooks === null || hooks === void 0 || (_hooks$auth3 = hooks.auth) === null || _hooks$auth3 === void 0 || (_hooks$auth3$logout = _hooks$auth3.logout) === null || _hooks$auth3$logout === void 0 ? void 0 : _hooks$auth3$logout.call(_hooks$auth3);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/** @deprecated import it from "@next-core/easyops-runtime" instead */
|
|
27
27
|
export function isLoggedIn() {
|
|
28
28
|
var _hooks$auth4;
|
|
29
|
-
return hooks === null || hooks === void 0
|
|
29
|
+
return hooks === null || hooks === void 0 || (_hooks$auth4 = hooks.auth) === null || _hooks$auth4 === void 0 ? void 0 : _hooks$auth4.isLoggedIn();
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=auth.js.map
|
package/dist/esm/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":["hooks","authenticate","_hooks$auth","_hooks$auth$authentic","_len","arguments","length","args","Array","_key","auth","call","getAuth","_hooks$auth2","logout","_hooks$auth3","_hooks$auth3$logout","isLoggedIn","_hooks$auth4"],"sources":["../../src/auth.ts"],"sourcesContent":["// istanbul ignore file\n// Todo(steve): This file will be removed in the future.\nimport { hooks } from \"./internal/Runtime.js\";\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function authenticate(...args: unknown[]): void {\n hooks?.auth?.authenticate?.(...args);\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function getAuth() {\n return hooks?.auth?.getAuth();\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function logout() {\n return hooks?.auth?.logout?.();\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function isLoggedIn() {\n return hooks?.auth?.isLoggedIn();\n}\n"],"mappings":"AAAA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;;AAE7C;AACA,OAAO,SAASC,YAAYA,CAAA,EAA2B;EAAA,IAAAC,WAAA,EAAAC,qBAAA;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAvBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAClCT,KAAK,aAALA,KAAK,
|
|
1
|
+
{"version":3,"file":"auth.js","names":["hooks","authenticate","_hooks$auth","_hooks$auth$authentic","_len","arguments","length","args","Array","_key","auth","call","getAuth","_hooks$auth2","logout","_hooks$auth3","_hooks$auth3$logout","isLoggedIn","_hooks$auth4"],"sources":["../../src/auth.ts"],"sourcesContent":["// istanbul ignore file\n// Todo(steve): This file will be removed in the future.\nimport { hooks } from \"./internal/Runtime.js\";\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function authenticate(...args: unknown[]): void {\n hooks?.auth?.authenticate?.(...args);\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function getAuth() {\n return hooks?.auth?.getAuth();\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function logout() {\n return hooks?.auth?.logout?.();\n}\n\n/** @deprecated import it from \"@next-core/easyops-runtime\" instead */\nexport function isLoggedIn() {\n return hooks?.auth?.isLoggedIn();\n}\n"],"mappings":"AAAA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;;AAE7C;AACA,OAAO,SAASC,YAAYA,CAAA,EAA2B;EAAA,IAAAC,WAAA,EAAAC,qBAAA;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAvBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAClCT,KAAK,aAALA,KAAK,gBAAAE,WAAA,GAALF,KAAK,CAAEU,IAAI,cAAAR,WAAA,gBAAAC,qBAAA,GAAXD,WAAA,CAAaD,YAAY,cAAAE,qBAAA,uBAAzBA,qBAAA,CAAAQ,IAAA,CAAAT,WAAA,EAA4B,GAAGK,IAAI,CAAC;AACtC;;AAEA;AACA,OAAO,SAASK,OAAOA,CAAA,EAAG;EAAA,IAAAC,YAAA;EACxB,OAAOb,KAAK,aAALA,KAAK,gBAAAa,YAAA,GAALb,KAAK,CAAEU,IAAI,cAAAG,YAAA,uBAAXA,YAAA,CAAaD,OAAO,CAAC,CAAC;AAC/B;;AAEA;AACA,OAAO,SAASE,MAAMA,CAAA,EAAG;EAAA,IAAAC,YAAA,EAAAC,mBAAA;EACvB,OAAOhB,KAAK,aAALA,KAAK,gBAAAe,YAAA,GAALf,KAAK,CAAEU,IAAI,cAAAK,YAAA,gBAAAC,mBAAA,GAAXD,YAAA,CAAaD,MAAM,cAAAE,mBAAA,uBAAnBA,mBAAA,CAAAL,IAAA,CAAAI,YAAsB,CAAC;AAChC;;AAEA;AACA,OAAO,SAASE,UAAUA,CAAA,EAAG;EAAA,IAAAC,YAAA;EAC3B,OAAOlB,KAAK,aAALA,KAAK,gBAAAkB,YAAA,GAALlB,KAAK,CAAEU,IAAI,cAAAQ,YAAA,uBAAXA,YAAA,CAAaD,UAAU,CAAC,CAAC;AAClC"}
|
|
@@ -30,7 +30,7 @@ export function expandCustomTemplate(tplTagName, brickConf, hostBrick, asyncHost
|
|
|
30
30
|
state,
|
|
31
31
|
contracts
|
|
32
32
|
} = customTemplates.get(tplTagName);
|
|
33
|
-
hooks === null || hooks === void 0
|
|
33
|
+
hooks === null || hooks === void 0 || (_hooks$flowApi = hooks.flowApi) === null || _hooks$flowApi === void 0 ? void 0 : _hooks$flowApi.collectWidgetContract(contracts);
|
|
34
34
|
tplStateStore.define(state, runtimeContext, asyncHostProperties);
|
|
35
35
|
var {
|
|
36
36
|
slots: originalExternalSlots,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandCustomTemplate.js","names":["uniqueId","customTemplates","DataStore","setupTemplateProxy","setupUseBrickInTemplate","childrenToSlots","hooks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostProperties","rendererContext","_hooks$flowApi","tplStateStoreId","runtimeContext","_objectSpread","forEachItem","formStateStoreId","tplStateStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","get","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","_objectWithoutProperties","_excluded","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","type","map","item","expandBrickInTemplate","brickConfInTemplate","if","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","_excluded2","transpiledSlots","fromEntries","_ref","_slotConf$bricks","slotName","slotConf"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./constants.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncProperties,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostProperties: AsyncProperties,\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 `forEachItem` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\"STATE\", hostBrick, rendererContext);\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostProperties);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostProperties,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.map((item) => expandBrickInTemplate(item, hostContext)),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConfInTemplate,\n hostContext: TemplateHostContext\n): RuntimeBrickConfWithTplSymbols {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n const slots: SlotsConfOfBricks = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(hostContext, restBrickConfInTemplate.ref, slots),\n };\n}\n"],"mappings":";;;;AAOA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;AAEhD,SAASC,kBAAkB,QAAQ,yBAAyB;AAO5D,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,KAAK,QAAQ,eAAe;AAGrC,OAAO,SAASC,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,mBAAoC,EACpCC,eAAgC,EAC7B;EAAA,IAAAC,cAAA;EACH,IAAMC,eAAe,GAAGd,QAAQ,CAAC,YAAY,CAAC;EAC9C,IAAMe,cAAc,GAAAC,aAAA,CAAAA,aAAA,KACfN,SAAS,CAACK,cAAc;IAC3BD;EAAe,EAChB;;EAED;EACA,OAAOC,cAAc,CAACE,WAAW;EACjC,OAAOF,cAAc,CAACG,gBAAgB;EAEtC,IAAMC,aAAa,GAAG,IAAIjB,SAAS,CAAC,OAAO,EAAEQ,SAAS,EAAEE,eAAe,CAAC;EACxEG,cAAc,CAACK,gBAAgB,CAACC,GAAG,CAACP,eAAe,EAAEK,aAAa,CAAC;EACnE,IAAIJ,cAAc,CAACO,kBAAkB,EAAE;IACrCP,cAAc,CAACO,kBAAkB,CAACC,IAAI,CAACJ,aAAa,CAAC;EACvD;EAEA,IAAM;IAAEK,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAU,CAAC,GAAG1B,eAAe,CAAC2B,GAAG,CAACpB,UAAU,CAAE;EAC5EF,KAAK,aAALA,KAAK,
|
|
1
|
+
{"version":3,"file":"expandCustomTemplate.js","names":["uniqueId","customTemplates","DataStore","setupTemplateProxy","setupUseBrickInTemplate","childrenToSlots","hooks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostProperties","rendererContext","_hooks$flowApi","tplStateStoreId","runtimeContext","_objectSpread","forEachItem","formStateStoreId","tplStateStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","get","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","_objectWithoutProperties","_excluded","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","type","map","item","expandBrickInTemplate","brickConfInTemplate","if","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","_excluded2","transpiledSlots","fromEntries","_ref","_slotConf$bricks","slotName","slotConf"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./constants.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncProperties,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostProperties: AsyncProperties,\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 `forEachItem` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\"STATE\", hostBrick, rendererContext);\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostProperties);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostProperties,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.map((item) => expandBrickInTemplate(item, hostContext)),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConfInTemplate,\n hostContext: TemplateHostContext\n): RuntimeBrickConfWithTplSymbols {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n const slots: SlotsConfOfBricks = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(hostContext, restBrickConfInTemplate.ref, slots),\n };\n}\n"],"mappings":";;;;AAOA,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;AAEhD,SAASC,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A,cAAAA,gBAAA,GAAI,EAAE,EAAEZ,GAAG,CAAEC,IAAI,IACvCC,qBAAqB,CAACD,IAAI,EAAEJ,WAAW,CACzC;IACF,CAAC,CACF;EAAA,EACH,CAAC;EAED,OAAApC,aAAA,CAAAA,aAAA,KACK8C,uBAAuB;IAC1BjB,UAAU,EAAEzC,uBAAuB,CAACyC,UAAU,EAAEO,WAAW,CAAC;IAC5DpB;EAAK,GACF7B,kBAAkB,CAACiD,WAAW,EAAEU,uBAAuB,CAACX,GAAG,EAAEnB,KAAK,CAAC;AAE1E"}
|
|
@@ -50,7 +50,7 @@ function _renderRoutes() {
|
|
|
50
50
|
match: matched.match
|
|
51
51
|
});
|
|
52
52
|
runtimeContext.ctxStore.define(route.context, runtimeContext);
|
|
53
|
-
runtimeContext.pendingPermissionsPreCheck.push(hooks === null || hooks === void 0
|
|
53
|
+
runtimeContext.pendingPermissionsPreCheck.push(hooks === null || hooks === void 0 || (_hooks$checkPermissio = hooks.checkPermissions) === null || _hooks$checkPermissio === void 0 ? void 0 : _hooks$checkPermissio.preCheckPermissionsForBrickOrRoute(route, value => asyncComputeRealValue(value, runtimeContext)));
|
|
54
54
|
|
|
55
55
|
// Currently, this is only used for brick size-checking: these bricks
|
|
56
56
|
// will be loaded before page rendering, but they will NOT be rendered.
|
|
@@ -191,7 +191,7 @@ function _renderBrick() {
|
|
|
191
191
|
runtimeContext.ctxStore.define(context, runtimeContext);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
runtimeContext.pendingPermissionsPreCheck.push(hooks === null || hooks === void 0
|
|
194
|
+
runtimeContext.pendingPermissionsPreCheck.push(hooks === null || hooks === void 0 || (_hooks$checkPermissio2 = hooks.checkPermissions) === null || _hooks$checkPermissio2 === void 0 ? void 0 : _hooks$checkPermissio2.preCheckPermissionsForBrickOrRoute(brickConf, value => asyncComputeRealValue(value, runtimeContext)));
|
|
195
195
|
if (!(yield asyncCheckBrickIf(brickConf, runtimeContext))) {
|
|
196
196
|
return output;
|
|
197
197
|
}
|
|
@@ -454,6 +454,7 @@ function loadMenu(menuConf, runtimeContext) {
|
|
|
454
454
|
return asyncComputeRealValue(menuConf, runtimeContext);
|
|
455
455
|
}
|
|
456
456
|
function mergeRenderOutput(output, newOutput) {
|
|
457
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
457
458
|
var {
|
|
458
459
|
blockingList,
|
|
459
460
|
node,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.js","names":["enqueueStableLoadBricks","loadBricksImperatively","isTrackAll","hasOwnProperty","debounce","asyncCheckBrickIf","asyncComputeRealProperties","constructAsyncProperties","resolveData","asyncComputeRealValue","listenOnTrackingContext","matchRoutes","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachItem","symbolForTplStateStoreId","expandCustomTemplate","getTagNameOfCustomTemplate","getTplStateStore","customTemplates","getBrickPackages","hooks","RenderTag","getTracks","isStrictMode","warnAboutStrictMode","FORM_RENDERER","symbolForFormStateStoreId","expandFormRenderer","isPreEvaluated","getPreEvaluatedRaw","renderRoutes","_x","_x2","_x3","_x4","_x5","_renderRoutes","apply","arguments","_asyncToGenerator","returnNode","routes","_runtimeContext","rendererContext","slotId","matched","output","blockingList","menuRequests","unauthenticated","_hooks$checkPermissio","route","runtimeContext","_objectSpread","match","ctxStore","define","context","pendingPermissionsPreCheck","push","checkPermissions","preCheckPermissionsForBrickOrRoute","value","preLoadBricks","Array","isArray","type","redirectTo","redirect","resolved","transform","console","error","Error","concat","path","loadMenu","menu","newOutput","mergeRenderOutput","renderBricks","bricks","_x6","_x7","_x8","_x9","_x10","_x11","_x12","_renderBricks","tplStack","noMemoize","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoizeControlNode","node","_x13","_x14","_x15","_x16","_x17","_x18","_renderBrick","key","_hooks$checkPermissio2","_runtimeContext$app","length","undefined","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","_objectWithoutProperties","_excluded2","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","formStateStoreId","forEachItem","strict","brickName","startsWith","ensureValidControlBrick","renderControlNode","_ref","_slots$slot","computedDataSource","slot","String","childrenToSlots","children","renderForEach","controlledOutput","contextNames","stateNames","renderId","listener","_ref2","currentRenderId","tplStateStoreMap","values","formStateStoreMap","store","waitForAll","rerenderControlNode","debouncedListener","contextName","onChange","tplStateStore","test","get","catchLoadBrick","unknownBricks","tplTagName","app","id","_tplStack$get","tplCount","set","includes","customElements","FormRendererElement","HTMLElement","$$typeof","tag","BRICK","return","events","portal","iid","ref","formData","confProps","_brickConf$properties","_ref3","properties","_excluded3","trackingContextList","asyncProperties","loadProperties","_ref4","computedPropsFromHost","computed","propName","propValue","entries","registerBrickLifeCycle","lifeCycle","expandedBrickConf","childRuntimeContext","loadChildren","_ref5","_ref6","childSlotId","slotConf","childrenOutput","child","_x19","_x20","_x21","_x22","_x23","_x24","_x25","_renderForEach","i","j","flat","menuConf","warn","rest","_excluded","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","_child$slot","promise","catch","e"],"sources":["../../../src/internal/Renderer.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n ContextConf,\n MenuConf,\n RouteConf,\n SlotConfOfBricks,\n SlotsConf,\n StaticMenuConf,\n} from \"@next-core/types\";\nimport {\n enqueueStableLoadBricks,\n loadBricksImperatively,\n} from \"@next-core/loader\";\nimport { isTrackAll } from \"@next-core/cook\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { debounce } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealProperties,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoutes } from \"./matchRoutes.js\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachItem,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n RenderBrick,\n RenderNode,\n RuntimeBrickConfWithSymbols,\n RuntimeContext,\n} from \"./interfaces.js\";\nimport {\n getTagNameOfCustomTemplate,\n getTplStateStore,\n} from \"./CustomTemplates/utils.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport type { NextHistoryState } from \"./historyExtended.js\";\nimport { getBrickPackages, hooks } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport {\n FORM_RENDERER,\n RuntimeBrickConfOfFormSymbols,\n symbolForFormStateStoreId,\n} from \"./FormRenderer/constants.js\";\nimport { expandFormRenderer } from \"./FormRenderer/expandFormRenderer.js\";\nimport { isPreEvaluated } from \"./compute/evaluate.js\";\nimport { getPreEvaluatedRaw } from \"./compute/evaluate.js\";\nimport { RuntimeBrickConfOfTplSymbols } from \"./CustomTemplates/constants.js\";\n\nexport interface RenderOutput {\n node?: RenderBrick;\n unauthenticated?: boolean;\n redirect?: {\n path: string;\n state?: NextHistoryState;\n };\n route?: RouteConf;\n blockingList: (Promise<unknown> | undefined)[];\n menuRequests: (Promise<StaticMenuConf | undefined> | undefined)[];\n hasTrackingControls?: boolean;\n}\n\nexport async function renderRoutes(\n returnNode: RenderNode,\n routes: RouteConf[],\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string\n): Promise<RenderOutput> {\n const matched = await matchRoutes(routes, _runtimeContext);\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n switch (matched) {\n case \"missed\":\n break;\n case \"unauthenticated\":\n output.unauthenticated = true;\n break;\n default: {\n const route = (output.route = matched.route);\n const runtimeContext = {\n ..._runtimeContext,\n match: matched.match,\n };\n runtimeContext.ctxStore.define(route.context, runtimeContext);\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n route,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n // Currently, this is only used for brick size-checking: these bricks\n // will be loaded before page rendering, but they will NOT be rendered.\n const { preLoadBricks } = route as { preLoadBricks?: string[] };\n if (Array.isArray(preLoadBricks)) {\n output.blockingList.push(\n loadBricksImperatively(preLoadBricks, getBrickPackages())\n );\n }\n\n switch (route.type) {\n case \"redirect\": {\n let redirectTo: unknown;\n if (typeof route.redirect === \"string\") {\n redirectTo = await asyncComputeRealValue(\n route.redirect,\n runtimeContext\n );\n } else {\n const resolved = (await resolveData(\n {\n transform: \"redirect\",\n ...route.redirect,\n },\n runtimeContext\n )) as { redirect?: unknown };\n redirectTo = resolved.redirect;\n }\n if (typeof redirectTo !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected redirect result:\", redirectTo);\n throw new Error(\n `Unexpected type of redirect result: ${typeof redirectTo}`\n );\n }\n output.redirect = { path: redirectTo };\n break;\n }\n case \"routes\": {\n output.menuRequests.push(loadMenu(route.menu, runtimeContext));\n const newOutput = await renderRoutes(\n returnNode,\n route.routes,\n runtimeContext,\n rendererContext,\n slotId\n );\n mergeRenderOutput(output, newOutput);\n break;\n }\n default: {\n output.menuRequests.push(loadMenu(route.menu, runtimeContext));\n const newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n slotId\n );\n mergeRenderOutput(output, newOutput);\n }\n }\n }\n }\n return output;\n}\n\nexport async function renderBricks(\n returnNode: RenderNode,\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string,\n tplStack?: Map<string, number>,\n noMemoize?: boolean\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf, index) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n slotId,\n index,\n tplStack && new Map(tplStack)\n )\n )\n );\n\n rendered.forEach((item, index) => {\n if (!noMemoize && item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoizeControlNode(slotId, index, item.node, returnNode);\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport async function renderBrick(\n returnNode: RenderNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string,\n key?: number,\n tplStack = new Map<string, number>()\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n\n if (!brickConf.brick) {\n if ((brickConf as { template?: string }).template) {\n // eslint-disable-next-line no-console\n console.error(\"Legacy templates are dropped in v3:\", brickConf);\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Invalid brick:\", brickConf);\n }\n return output;\n }\n\n // Translate `if: \"<%= ... %>\"` to `brick: \":if\", dataSource: \"<%= ... %>\"`.\n // In other words, translate tracking if expressions to tracking control nodes of `:if`.\n const { if: brickIf, permissionsPreCheck, ...restBrickConf } = brickConf;\n if (isGeneralizedTrackAll(brickIf)) {\n return renderBrick(\n returnNode,\n {\n brick: \":if\",\n dataSource: brickIf,\n // `permissionsPreCheck` maybe required before computing `if`.\n permissionsPreCheck,\n slots: {\n \"\": {\n type: \"bricks\",\n bricks: [restBrickConf],\n },\n },\n // These symbols have to be copied to the new brick conf.\n ...Object.getOwnPropertySymbols(brickConf).reduce(\n (acc, symbol) => ({\n ...acc,\n [symbol]: (brickConf as any)[symbol],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n slotId,\n key,\n tplStack\n );\n }\n\n const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const formStateStoreId = brickConf[symbolForFormStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\n formStateStoreId,\n };\n\n if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {\n // The external bricks of a template should restore their `forEachItem`\n // from their host.\n runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];\n }\n\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\n const strict = isStrictMode(runtimeContext);\n warnAboutStrictMode(\n strict,\n \"Defining context on bricks\",\n \"check your brick:\",\n brickConf\n );\n if (!strict) {\n runtimeContext.ctxStore.define(context, runtimeContext);\n }\n }\n\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n brickConf,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {\n return output;\n }\n\n const brickName = brickConf.brick;\n if (brickName.startsWith(\":\")) {\n ensureValidControlBrick(brickName);\n\n const { dataSource } = brickConf;\n\n const renderControlNode = async () => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n // Then, get the matched slot.\n const slot =\n brickName === \":forEach\"\n ? \"\"\n : brickName === \":switch\"\n ? String(computedDataSource)\n : computedDataSource\n ? \"\"\n : \"else\";\n\n // Don't forget to transpile children to slots.\n const slots = childrenToSlots(brickConf.children, brickConf.slots);\n\n // Then, get the bricks in that matched slot.\n const bricks =\n slots &&\n hasOwnProperty(slots, slot) &&\n (slots[slot] as SlotConfOfBricks)?.bricks;\n\n if (!Array.isArray(bricks)) {\n return output;\n }\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n return output;\n }\n return renderForEach(\n returnNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n slotId,\n tplStack\n );\n }\n case \":if\":\n case \":switch\": {\n return renderBricks(\n returnNode,\n bricks,\n runtimeContext,\n rendererContext,\n slotId,\n tplStack,\n true\n );\n }\n }\n };\n\n const controlledOutput = await renderControlNode();\n\n const { contextNames, stateNames } = getTracks(dataSource);\n if (contextNames || stateNames) {\n controlledOutput.hasTrackingControls = true;\n let renderId = 0;\n const listener = async () => {\n const currentRenderId = ++renderId;\n const output = await renderControlNode();\n output.blockingList.push(\n ...[\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ].map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck\n );\n await Promise.all(output.blockingList);\n // Ignore stale renders\n if (renderId === currentRenderId) {\n rendererContext.rerenderControlNode(\n slotId,\n key as number,\n output.node,\n returnNode\n );\n }\n };\n const debouncedListener = debounce(listener);\n if (contextNames) {\n for (const contextName of contextNames) {\n runtimeContext.ctxStore.onChange(contextName, debouncedListener);\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n tplStateStore.onChange(contextName, debouncedListener);\n }\n }\n }\n\n return controlledOutput;\n }\n\n // Widgets need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await catchLoadBrick(\n loadBricksImperatively([brickName], getBrickPackages()),\n brickName,\n rendererContext.unknownBricks\n );\n }\n\n const tplTagName = getTagNameOfCustomTemplate(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n customElements.define(\n FORM_RENDERER,\n class FormRendererElement extends HTMLElement {\n get $$typeof(): string {\n return \"form-renderer\";\n }\n }\n );\n } else {\n output.blockingList.push(\n catchLoadBrick(\n enqueueStableLoadBricks([brickName], getBrickPackages()),\n brickName,\n rendererContext.unknownBricks\n )\n );\n }\n }\n\n const brick: RenderBrick = {\n tag: RenderTag.BRICK,\n type: tplTagName || brickName,\n return: returnNode,\n slotId,\n events: brickConf.events,\n runtimeContext,\n portal: brickConf.portal,\n iid: brickConf.iid,\n ref: (brickConf as BrickConfInTemplate).ref,\n };\n\n output.node = brick;\n\n // const confProps = brickConf.properties;\n let formData: unknown;\n let confProps: Record<string, unknown> | undefined;\n if (brickName === FORM_RENDERER) {\n ({ formData, ...confProps } = brickConf.properties ?? {});\n } else {\n confProps = brickConf.properties;\n }\n\n // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const trackingContextList: TrackingContextItem[] = [];\n const asyncProperties = asyncComputeRealProperties(\n confProps,\n runtimeContext,\n trackingContextList\n );\n const loadProperties = async () => {\n brick.properties = await constructAsyncProperties(asyncProperties);\n const computedPropsFromHost =\n brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n const computed = await computedPropsFromHost;\n for (const [propName, propValue] of Object.entries(computed)) {\n brick.properties[propName] = propValue;\n }\n }\n listenOnTrackingContext(brick, trackingContextList);\n return brick.properties;\n };\n blockingList.push(loadProperties());\n\n rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);\n\n let expandedBrickConf = brickConf;\n if (tplTagName) {\n expandedBrickConf = expandCustomTemplate(\n tplTagName,\n brickConf,\n brick,\n asyncProperties,\n rendererContext\n );\n } else if (brickName === FORM_RENDERER) {\n expandedBrickConf = expandFormRenderer(\n formData,\n brickConf,\n brick,\n asyncProperties,\n rendererContext\n );\n }\n\n if (expandedBrickConf.portal) {\n // A portal brick has no slotId.\n brick.slotId = undefined;\n }\n\n let childRuntimeContext: RuntimeContext;\n if (tplTagName) {\n // There is a boundary for `forEachItem` between template internals and externals.\n childRuntimeContext = {\n ...runtimeContext,\n };\n delete childRuntimeContext.forEachItem;\n } else {\n childRuntimeContext = runtimeContext;\n }\n\n const loadChildren = async () => {\n const slots = childrenToSlots(\n expandedBrickConf.children,\n expandedBrickConf.slots\n );\n if (!slots) {\n return;\n }\n const rendered = await Promise.all(\n Object.entries(slots).map(([childSlotId, slotConf]) =>\n slotConf.type !== \"routes\"\n ? renderBricks(\n brick,\n (slotConf as SlotConfOfBricks).bricks,\n childRuntimeContext,\n rendererContext,\n childSlotId,\n tplStack\n )\n : renderRoutes(\n brick,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n childSlotId\n )\n )\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n };\n for (const item of rendered) {\n mergeRenderOutput(childrenOutput, item);\n }\n if (childrenOutput.node) {\n brick.child = childrenOutput.node;\n }\n mergeRenderOutput(output, {\n ...childrenOutput,\n node: undefined,\n });\n };\n blockingList.push(loadChildren());\n\n await Promise.all(blockingList);\n\n return output;\n}\n\nfunction isGeneralizedTrackAll(brickIf: unknown): boolean {\n return typeof brickIf === \"string\"\n ? isTrackAll(brickIf)\n : isPreEvaluated(brickIf) &&\n // istanbul ignore next: covered by e2e tests\n isTrackAll(getPreEvaluatedRaw(brickIf));\n}\n\ntype ValidControlBrick = \":forEach\" | \":if\" | \":switch\";\n\nfunction ensureValidControlBrick(\n brick: string\n): asserts brick is ValidControlBrick {\n if (brick !== \":forEach\" && brick !== \":if\" && brick !== \":switch\") {\n throw new Error(`Unknown storyboard control node: \"${brick}\"`);\n }\n}\n\nasync function renderForEach(\n returnNode: RenderNode,\n dataSource: unknown[],\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId: string | undefined,\n tplStack?: Map<string, number>\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n\n const rendered = await Promise.all(\n dataSource.map((item, i) =>\n Promise.all(\n bricks.map((brickConf, j) =>\n renderBrick(\n returnNode,\n brickConf,\n {\n ...runtimeContext,\n forEachItem: item,\n },\n rendererContext,\n slotId,\n i * j,\n tplStack && new Map(tplStack)\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n for (const item of rendered.flat()) {\n mergeRenderOutput(output, item);\n }\n return output;\n}\n\nfunction loadMenu(\n menuConf: MenuConf | undefined,\n runtimeContext: RuntimeContext\n) {\n if (!menuConf) {\n return;\n }\n\n // istanbul ignore next\n if ((menuConf as { type?: \"brick\" }).type === \"brick\") {\n // eslint-disable-next-line no-console\n console.error(\"Set menu with brick is dropped in v3:\", menuConf);\n throw new Error(\"Set menu with brick is dropped in v3\");\n }\n\n // istanbul ignore next\n if (menuConf.type === \"resolve\") {\n // eslint-disable-next-line no-console\n console.warn(\"Set menu with resolve is not supported in v3 yet:\", menuConf);\n return;\n }\n\n return asyncComputeRealValue(\n menuConf,\n runtimeContext\n ) as Promise<StaticMenuConf>;\n}\n\nfunction mergeRenderOutput(\n output: RenderOutput,\n newOutput: RenderOutput\n): void {\n const { blockingList, node, menuRequests, hasTrackingControls, ...rest } =\n newOutput;\n output.blockingList.push(...blockingList);\n output.menuRequests.push(...menuRequests);\n\n if (node) {\n if (output.node) {\n let last = output.node;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = node;\n } else {\n output.node = node;\n }\n }\n\n Object.assign(output, rest);\n}\n\nexport function childrenToSlots(\n children: BrickConf[] | undefined,\n originalSlots: SlotsConf | undefined\n) {\n let newSlots = originalSlots;\n // istanbul ignore next\n if (\n process.env.NODE_ENV === \"development\" &&\n children &&\n !Array.isArray(children)\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Specified brick children but not array:\",\n `<${typeof children}>`,\n children\n );\n }\n if (Array.isArray(children) && !newSlots) {\n newSlots = {};\n for (const child of children) {\n const slot = child.slot ?? \"\";\n if (!hasOwnProperty(newSlots, slot)) {\n newSlots[slot] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n (newSlots[slot] as SlotConfOfBricks).bricks.push(child);\n }\n }\n return newSlots;\n}\n\nfunction catchLoadBrick(\n promise: Promise<unknown>,\n brickName: string,\n unknownBricks: RendererContext[\"unknownBricks\"]\n) {\n return unknownBricks === \"silent\"\n ? promise.catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Load brick \"${brickName}\" failed:`, e);\n })\n : promise;\n}\n"],"mappings":";;;;;;AAUA,SACEA,uBAAuB,EACvBC,sBAAsB,QACjB,mBAAmB;AAC1B,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SACEC,0BAA0B,EAC1BC,wBAAwB,QACnB,oCAAoC;AAC3C,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SAEEC,uBAAuB,QAClB,sCAAsC;AAE7C,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SACEC,mCAAmC,EACnCC,+BAA+B,EAC/BC,wBAAwB,QACnB,gCAAgC;AACvC,SAASC,oBAAoB,QAAQ,2CAA2C;AAOhF,SACEC,0BAA0B,EAC1BC,gBAAgB,QACX,4BAA4B;AACnC,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,gBAAgB,EAAEC,KAAK,QAAQ,cAAc;AACtD,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,oBAAoB;AACtE,SACEC,aAAa,EAEbC,yBAAyB,QACpB,6BAA6B;AACpC,SAASC,kBAAkB,QAAQ,sCAAsC;AACzE,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,kBAAkB,QAAQ,uBAAuB;AAgB1D,gBAAsBC,YAAYA,CAAAC,EAAA,EAAAC,GAAA,EAAAC,GAAA,EAAAC,GAA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I,CACV,yCAAyC,MAAAxJ,MAAA,CACrC,OAAOyE,QAAQ,QACnBA,QACF,CAAC;EACH;EACA,IAAInF,KAAK,CAACC,OAAO,CAACkF,QAAQ,CAAC,IAAI,CAACsF,QAAQ,EAAE;IACxCA,QAAQ,GAAG,CAAC,CAAC;IACb,KAAK,IAAMpB,KAAK,IAAIlE,QAAQ,EAAE;MAAA,IAAA0F,WAAA;MAC5B,IAAM7F,IAAI,IAAA6F,WAAA,GAAGxB,KAAK,CAACrE,IAAI,cAAA6F,WAAA,cAAAA,WAAA,GAAI,EAAE;MAC7B,IAAI,CAAC1O,cAAc,CAACsO,QAAQ,EAAEzF,IAAI,CAAC,EAAE;QACnCyF,QAAQ,CAACzF,IAAI,CAAC,GAAG;UACf9E,IAAI,EAAE,QAAQ;UACde,MAAM,EAAE;QACV,CAAC;MACH;MACCwJ,QAAQ,CAACzF,IAAI,CAAC,CAAsB/D,MAAM,CAACtB,IAAI,CAAC0J,KAAK,CAAC;IACzD;EACF;EACA,OAAOoB,QAAQ;AACjB;AAEA,SAASjE,cAAcA,CACrBsE,OAAyB,EACzBrG,SAAiB,EACjBgC,aAA+C,EAC/C;EACA,OAAOA,aAAa,KAAK,QAAQ,GAC7BqE,OAAO,CAACC,KAAK,CAAEC,CAAC,IAAK;IACnB;IACAzK,OAAO,CAACC,KAAK,iBAAAE,MAAA,CAAgB+D,SAAS,iBAAauG,CAAC,CAAC;EACvD,CAAC,CAAC,GACFF,OAAO;AACb"}
|
|
1
|
+
{"version":3,"file":"Renderer.js","names":["enqueueStableLoadBricks","loadBricksImperatively","isTrackAll","hasOwnProperty","debounce","asyncCheckBrickIf","asyncComputeRealProperties","constructAsyncProperties","resolveData","asyncComputeRealValue","listenOnTrackingContext","matchRoutes","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachItem","symbolForTplStateStoreId","expandCustomTemplate","getTagNameOfCustomTemplate","getTplStateStore","customTemplates","getBrickPackages","hooks","RenderTag","getTracks","isStrictMode","warnAboutStrictMode","FORM_RENDERER","symbolForFormStateStoreId","expandFormRenderer","isPreEvaluated","getPreEvaluatedRaw","renderRoutes","_x","_x2","_x3","_x4","_x5","_renderRoutes","apply","arguments","_asyncToGenerator","returnNode","routes","_runtimeContext","rendererContext","slotId","matched","output","blockingList","menuRequests","unauthenticated","_hooks$checkPermissio","route","runtimeContext","_objectSpread","match","ctxStore","define","context","pendingPermissionsPreCheck","push","checkPermissions","preCheckPermissionsForBrickOrRoute","value","preLoadBricks","Array","isArray","type","redirectTo","redirect","resolved","transform","console","error","Error","concat","path","loadMenu","menu","newOutput","mergeRenderOutput","renderBricks","bricks","_x6","_x7","_x8","_x9","_x10","_x11","_x12","_renderBricks","tplStack","noMemoize","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoizeControlNode","node","_x13","_x14","_x15","_x16","_x17","_x18","_renderBrick","key","_hooks$checkPermissio2","_runtimeContext$app","length","undefined","brick","template","if","brickIf","permissionsPreCheck","restBrickConf","_objectWithoutProperties","_excluded2","isGeneralizedTrackAll","dataSource","slots","Object","getOwnPropertySymbols","reduce","acc","symbol","tplStateStoreId","formStateStoreId","forEachItem","strict","brickName","startsWith","ensureValidControlBrick","renderControlNode","_ref","_slots$slot","computedDataSource","slot","String","childrenToSlots","children","renderForEach","controlledOutput","contextNames","stateNames","renderId","listener","_ref2","currentRenderId","tplStateStoreMap","values","formStateStoreMap","store","waitForAll","rerenderControlNode","debouncedListener","contextName","onChange","tplStateStore","test","get","catchLoadBrick","unknownBricks","tplTagName","app","id","_tplStack$get","tplCount","set","includes","customElements","FormRendererElement","HTMLElement","$$typeof","tag","BRICK","return","events","portal","iid","ref","formData","confProps","_brickConf$properties","_ref3","properties","_excluded3","trackingContextList","asyncProperties","loadProperties","_ref4","computedPropsFromHost","computed","propName","propValue","entries","registerBrickLifeCycle","lifeCycle","expandedBrickConf","childRuntimeContext","loadChildren","_ref5","_ref6","childSlotId","slotConf","childrenOutput","child","_x19","_x20","_x21","_x22","_x23","_x24","_x25","_renderForEach","i","j","flat","menuConf","warn","rest","_excluded","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","_child$slot","promise","catch","e"],"sources":["../../../src/internal/Renderer.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n ContextConf,\n MenuConf,\n RouteConf,\n SlotConfOfBricks,\n SlotsConf,\n StaticMenuConf,\n} from \"@next-core/types\";\nimport {\n enqueueStableLoadBricks,\n loadBricksImperatively,\n} from \"@next-core/loader\";\nimport { isTrackAll } from \"@next-core/cook\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { debounce } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport {\n asyncComputeRealProperties,\n constructAsyncProperties,\n} from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoutes } from \"./matchRoutes.js\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachItem,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type {\n RenderBrick,\n RenderNode,\n RuntimeBrickConfWithSymbols,\n RuntimeContext,\n} from \"./interfaces.js\";\nimport {\n getTagNameOfCustomTemplate,\n getTplStateStore,\n} from \"./CustomTemplates/utils.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport type { NextHistoryState } from \"./historyExtended.js\";\nimport { getBrickPackages, hooks } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.js\";\nimport {\n FORM_RENDERER,\n RuntimeBrickConfOfFormSymbols,\n symbolForFormStateStoreId,\n} from \"./FormRenderer/constants.js\";\nimport { expandFormRenderer } from \"./FormRenderer/expandFormRenderer.js\";\nimport { isPreEvaluated } from \"./compute/evaluate.js\";\nimport { getPreEvaluatedRaw } from \"./compute/evaluate.js\";\nimport { RuntimeBrickConfOfTplSymbols } from \"./CustomTemplates/constants.js\";\n\nexport interface RenderOutput {\n node?: RenderBrick;\n unauthenticated?: boolean;\n redirect?: {\n path: string;\n state?: NextHistoryState;\n };\n route?: RouteConf;\n blockingList: (Promise<unknown> | undefined)[];\n menuRequests: (Promise<StaticMenuConf | undefined> | undefined)[];\n hasTrackingControls?: boolean;\n}\n\nexport async function renderRoutes(\n returnNode: RenderNode,\n routes: RouteConf[],\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string\n): Promise<RenderOutput> {\n const matched = await matchRoutes(routes, _runtimeContext);\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n switch (matched) {\n case \"missed\":\n break;\n case \"unauthenticated\":\n output.unauthenticated = true;\n break;\n default: {\n const route = (output.route = matched.route);\n const runtimeContext = {\n ..._runtimeContext,\n match: matched.match,\n };\n runtimeContext.ctxStore.define(route.context, runtimeContext);\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n route,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n // Currently, this is only used for brick size-checking: these bricks\n // will be loaded before page rendering, but they will NOT be rendered.\n const { preLoadBricks } = route as { preLoadBricks?: string[] };\n if (Array.isArray(preLoadBricks)) {\n output.blockingList.push(\n loadBricksImperatively(preLoadBricks, getBrickPackages())\n );\n }\n\n switch (route.type) {\n case \"redirect\": {\n let redirectTo: unknown;\n if (typeof route.redirect === \"string\") {\n redirectTo = await asyncComputeRealValue(\n route.redirect,\n runtimeContext\n );\n } else {\n const resolved = (await resolveData(\n {\n transform: \"redirect\",\n ...route.redirect,\n },\n runtimeContext\n )) as { redirect?: unknown };\n redirectTo = resolved.redirect;\n }\n if (typeof redirectTo !== \"string\") {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected redirect result:\", redirectTo);\n throw new Error(\n `Unexpected type of redirect result: ${typeof redirectTo}`\n );\n }\n output.redirect = { path: redirectTo };\n break;\n }\n case \"routes\": {\n output.menuRequests.push(loadMenu(route.menu, runtimeContext));\n const newOutput = await renderRoutes(\n returnNode,\n route.routes,\n runtimeContext,\n rendererContext,\n slotId\n );\n mergeRenderOutput(output, newOutput);\n break;\n }\n default: {\n output.menuRequests.push(loadMenu(route.menu, runtimeContext));\n const newOutput = await renderBricks(\n returnNode,\n route.bricks,\n runtimeContext,\n rendererContext,\n slotId\n );\n mergeRenderOutput(output, newOutput);\n }\n }\n }\n }\n return output;\n}\n\nexport async function renderBricks(\n returnNode: RenderNode,\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string,\n tplStack?: Map<string, number>,\n noMemoize?: boolean\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n // 多个构件并行异步转换,但转换的结果按原顺序串行合并。\n const rendered = await Promise.all(\n bricks.map((brickConf, index) =>\n renderBrick(\n returnNode,\n brickConf,\n runtimeContext,\n rendererContext,\n slotId,\n index,\n tplStack && new Map(tplStack)\n )\n )\n );\n\n rendered.forEach((item, index) => {\n if (!noMemoize && item.hasTrackingControls) {\n // Memoize a render node before it's been merged.\n rendererContext.memoizeControlNode(slotId, index, item.node, returnNode);\n }\n mergeRenderOutput(output, item);\n });\n\n return output;\n}\n\nexport async function renderBrick(\n returnNode: RenderNode,\n brickConf: RuntimeBrickConfWithSymbols,\n _runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId?: string,\n key?: number,\n tplStack = new Map<string, number>()\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n\n if (!brickConf.brick) {\n if ((brickConf as { template?: string }).template) {\n // eslint-disable-next-line no-console\n console.error(\"Legacy templates are dropped in v3:\", brickConf);\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Invalid brick:\", brickConf);\n }\n return output;\n }\n\n // Translate `if: \"<%= ... %>\"` to `brick: \":if\", dataSource: \"<%= ... %>\"`.\n // In other words, translate tracking if expressions to tracking control nodes of `:if`.\n const { if: brickIf, permissionsPreCheck, ...restBrickConf } = brickConf;\n if (isGeneralizedTrackAll(brickIf)) {\n return renderBrick(\n returnNode,\n {\n brick: \":if\",\n dataSource: brickIf,\n // `permissionsPreCheck` maybe required before computing `if`.\n permissionsPreCheck,\n slots: {\n \"\": {\n type: \"bricks\",\n bricks: [restBrickConf],\n },\n },\n // These symbols have to be copied to the new brick conf.\n ...Object.getOwnPropertySymbols(brickConf).reduce(\n (acc, symbol) => ({\n ...acc,\n [symbol]: (brickConf as any)[symbol],\n }),\n {} as RuntimeBrickConfOfTplSymbols & RuntimeBrickConfOfFormSymbols\n ),\n },\n _runtimeContext,\n rendererContext,\n slotId,\n key,\n tplStack\n );\n }\n\n const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const formStateStoreId = brickConf[symbolForFormStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\n formStateStoreId,\n };\n\n if (hasOwnProperty(brickConf, symbolForTPlExternalForEachItem)) {\n // The external bricks of a template should restore their `forEachItem`\n // from their host.\n runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];\n }\n\n const { context } = brickConf as { context?: ContextConf[] };\n // istanbul ignore next\n if (Array.isArray(context) && context.length > 0) {\n const strict = isStrictMode(runtimeContext);\n warnAboutStrictMode(\n strict,\n \"Defining context on bricks\",\n \"check your brick:\",\n brickConf\n );\n if (!strict) {\n runtimeContext.ctxStore.define(context, runtimeContext);\n }\n }\n\n runtimeContext.pendingPermissionsPreCheck.push(\n hooks?.checkPermissions?.preCheckPermissionsForBrickOrRoute(\n brickConf,\n (value) => asyncComputeRealValue(value, runtimeContext)\n )\n );\n\n if (!(await asyncCheckBrickIf(brickConf, runtimeContext))) {\n return output;\n }\n\n const brickName = brickConf.brick;\n if (brickName.startsWith(\":\")) {\n ensureValidControlBrick(brickName);\n\n const { dataSource } = brickConf;\n\n const renderControlNode = async () => {\n // First, compute the `dataSource`\n const computedDataSource = await asyncComputeRealValue(\n dataSource,\n runtimeContext\n );\n\n // Then, get the matched slot.\n const slot =\n brickName === \":forEach\"\n ? \"\"\n : brickName === \":switch\"\n ? String(computedDataSource)\n : computedDataSource\n ? \"\"\n : \"else\";\n\n // Don't forget to transpile children to slots.\n const slots = childrenToSlots(brickConf.children, brickConf.slots);\n\n // Then, get the bricks in that matched slot.\n const bricks =\n slots &&\n hasOwnProperty(slots, slot) &&\n (slots[slot] as SlotConfOfBricks)?.bricks;\n\n if (!Array.isArray(bricks)) {\n return output;\n }\n\n switch (brickName) {\n case \":forEach\": {\n if (!Array.isArray(computedDataSource)) {\n return output;\n }\n return renderForEach(\n returnNode,\n computedDataSource,\n bricks,\n runtimeContext,\n rendererContext,\n slotId,\n tplStack\n );\n }\n case \":if\":\n case \":switch\": {\n return renderBricks(\n returnNode,\n bricks,\n runtimeContext,\n rendererContext,\n slotId,\n tplStack,\n true\n );\n }\n }\n };\n\n const controlledOutput = await renderControlNode();\n\n const { contextNames, stateNames } = getTracks(dataSource);\n if (contextNames || stateNames) {\n controlledOutput.hasTrackingControls = true;\n let renderId = 0;\n const listener = async () => {\n const currentRenderId = ++renderId;\n const output = await renderControlNode();\n output.blockingList.push(\n ...[\n ...runtimeContext.tplStateStoreMap.values(),\n ...runtimeContext.formStateStoreMap.values(),\n ].map((store) => store.waitForAll()),\n ...runtimeContext.pendingPermissionsPreCheck\n );\n await Promise.all(output.blockingList);\n // Ignore stale renders\n if (renderId === currentRenderId) {\n rendererContext.rerenderControlNode(\n slotId,\n key as number,\n output.node,\n returnNode\n );\n }\n };\n const debouncedListener = debounce(listener);\n if (contextNames) {\n for (const contextName of contextNames) {\n runtimeContext.ctxStore.onChange(contextName, debouncedListener);\n }\n }\n if (stateNames) {\n for (const contextName of stateNames) {\n const tplStateStore = getTplStateStore(\n runtimeContext,\n \"STATE\",\n `: \"${dataSource}\"`\n );\n tplStateStore.onChange(contextName, debouncedListener);\n }\n }\n }\n\n return controlledOutput;\n }\n\n // Widgets need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await catchLoadBrick(\n loadBricksImperatively([brickName], getBrickPackages()),\n brickName,\n rendererContext.unknownBricks\n );\n }\n\n const tplTagName = getTagNameOfCustomTemplate(\n brickName,\n runtimeContext.app?.id\n );\n\n if (tplTagName) {\n const tplCount = tplStack.get(tplTagName) ?? 0;\n if (tplCount >= 10) {\n throw new Error(\n `Maximum custom template stack overflowed: \"${tplTagName}\"`\n );\n }\n tplStack.set(tplTagName, tplCount + 1);\n } else if (brickName.includes(\"-\") && !customElements.get(brickName)) {\n if (brickName === FORM_RENDERER) {\n customElements.define(\n FORM_RENDERER,\n class FormRendererElement extends HTMLElement {\n get $$typeof(): string {\n return \"form-renderer\";\n }\n }\n );\n } else {\n output.blockingList.push(\n catchLoadBrick(\n enqueueStableLoadBricks([brickName], getBrickPackages()),\n brickName,\n rendererContext.unknownBricks\n )\n );\n }\n }\n\n const brick: RenderBrick = {\n tag: RenderTag.BRICK,\n type: tplTagName || brickName,\n return: returnNode,\n slotId,\n events: brickConf.events,\n runtimeContext,\n portal: brickConf.portal,\n iid: brickConf.iid,\n ref: (brickConf as BrickConfInTemplate).ref,\n };\n\n output.node = brick;\n\n // const confProps = brickConf.properties;\n let formData: unknown;\n let confProps: Record<string, unknown> | undefined;\n if (brickName === FORM_RENDERER) {\n ({ formData, ...confProps } = brickConf.properties ?? {});\n } else {\n confProps = brickConf.properties;\n }\n\n // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const trackingContextList: TrackingContextItem[] = [];\n const asyncProperties = asyncComputeRealProperties(\n confProps,\n runtimeContext,\n trackingContextList\n );\n const loadProperties = async () => {\n brick.properties = await constructAsyncProperties(asyncProperties);\n const computedPropsFromHost =\n brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n const computed = await computedPropsFromHost;\n for (const [propName, propValue] of Object.entries(computed)) {\n brick.properties[propName] = propValue;\n }\n }\n listenOnTrackingContext(brick, trackingContextList);\n return brick.properties;\n };\n blockingList.push(loadProperties());\n\n rendererContext.registerBrickLifeCycle(brick, brickConf.lifeCycle);\n\n let expandedBrickConf = brickConf;\n if (tplTagName) {\n expandedBrickConf = expandCustomTemplate(\n tplTagName,\n brickConf,\n brick,\n asyncProperties,\n rendererContext\n );\n } else if (brickName === FORM_RENDERER) {\n expandedBrickConf = expandFormRenderer(\n formData,\n brickConf,\n brick,\n asyncProperties,\n rendererContext\n );\n }\n\n if (expandedBrickConf.portal) {\n // A portal brick has no slotId.\n brick.slotId = undefined;\n }\n\n let childRuntimeContext: RuntimeContext;\n if (tplTagName) {\n // There is a boundary for `forEachItem` between template internals and externals.\n childRuntimeContext = {\n ...runtimeContext,\n };\n delete childRuntimeContext.forEachItem;\n } else {\n childRuntimeContext = runtimeContext;\n }\n\n const loadChildren = async () => {\n const slots = childrenToSlots(\n expandedBrickConf.children,\n expandedBrickConf.slots\n );\n if (!slots) {\n return;\n }\n const rendered = await Promise.all(\n Object.entries(slots).map(([childSlotId, slotConf]) =>\n slotConf.type !== \"routes\"\n ? renderBricks(\n brick,\n (slotConf as SlotConfOfBricks).bricks,\n childRuntimeContext,\n rendererContext,\n childSlotId,\n tplStack\n )\n : renderRoutes(\n brick,\n slotConf.routes,\n childRuntimeContext,\n rendererContext,\n childSlotId\n )\n )\n );\n\n const childrenOutput: RenderOutput = {\n ...output,\n node: undefined,\n blockingList: [],\n };\n for (const item of rendered) {\n mergeRenderOutput(childrenOutput, item);\n }\n if (childrenOutput.node) {\n brick.child = childrenOutput.node;\n }\n mergeRenderOutput(output, {\n ...childrenOutput,\n node: undefined,\n });\n };\n blockingList.push(loadChildren());\n\n await Promise.all(blockingList);\n\n return output;\n}\n\nfunction isGeneralizedTrackAll(brickIf: unknown): boolean {\n return typeof brickIf === \"string\"\n ? isTrackAll(brickIf)\n : isPreEvaluated(brickIf) &&\n // istanbul ignore next: covered by e2e tests\n isTrackAll(getPreEvaluatedRaw(brickIf));\n}\n\ntype ValidControlBrick = \":forEach\" | \":if\" | \":switch\";\n\nfunction ensureValidControlBrick(\n brick: string\n): asserts brick is ValidControlBrick {\n if (brick !== \":forEach\" && brick !== \":if\" && brick !== \":switch\") {\n throw new Error(`Unknown storyboard control node: \"${brick}\"`);\n }\n}\n\nasync function renderForEach(\n returnNode: RenderNode,\n dataSource: unknown[],\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n rendererContext: RendererContext,\n slotId: string | undefined,\n tplStack?: Map<string, number>\n): Promise<RenderOutput> {\n const output: RenderOutput = {\n blockingList: [],\n menuRequests: [],\n };\n\n const rendered = await Promise.all(\n dataSource.map((item, i) =>\n Promise.all(\n bricks.map((brickConf, j) =>\n renderBrick(\n returnNode,\n brickConf,\n {\n ...runtimeContext,\n forEachItem: item,\n },\n rendererContext,\n slotId,\n i * j,\n tplStack && new Map(tplStack)\n )\n )\n )\n )\n );\n\n // 多层构件并行异步转换,但转换的结果按原顺序串行合并。\n for (const item of rendered.flat()) {\n mergeRenderOutput(output, item);\n }\n return output;\n}\n\nfunction loadMenu(\n menuConf: MenuConf | undefined,\n runtimeContext: RuntimeContext\n) {\n if (!menuConf) {\n return;\n }\n\n // istanbul ignore next\n if ((menuConf as { type?: \"brick\" }).type === \"brick\") {\n // eslint-disable-next-line no-console\n console.error(\"Set menu with brick is dropped in v3:\", menuConf);\n throw new Error(\"Set menu with brick is dropped in v3\");\n }\n\n // istanbul ignore next\n if (menuConf.type === \"resolve\") {\n // eslint-disable-next-line no-console\n console.warn(\"Set menu with resolve is not supported in v3 yet:\", menuConf);\n return;\n }\n\n return asyncComputeRealValue(\n menuConf,\n runtimeContext\n ) as Promise<StaticMenuConf>;\n}\n\nfunction mergeRenderOutput(\n output: RenderOutput,\n newOutput: RenderOutput\n): void {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { blockingList, node, menuRequests, hasTrackingControls, ...rest } =\n newOutput;\n output.blockingList.push(...blockingList);\n output.menuRequests.push(...menuRequests);\n\n if (node) {\n if (output.node) {\n let last = output.node;\n while (last.sibling) {\n last = last.sibling;\n }\n last.sibling = node;\n } else {\n output.node = node;\n }\n }\n\n Object.assign(output, rest);\n}\n\nexport function childrenToSlots(\n children: BrickConf[] | undefined,\n originalSlots: SlotsConf | undefined\n) {\n let newSlots = originalSlots;\n // istanbul ignore next\n if (\n process.env.NODE_ENV === \"development\" &&\n children &&\n !Array.isArray(children)\n ) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Specified brick children but not array:\",\n `<${typeof children}>`,\n children\n );\n }\n if (Array.isArray(children) && !newSlots) {\n newSlots = {};\n for (const child of children) {\n const slot = child.slot ?? \"\";\n if (!hasOwnProperty(newSlots, slot)) {\n newSlots[slot] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n (newSlots[slot] as SlotConfOfBricks).bricks.push(child);\n }\n }\n return newSlots;\n}\n\nfunction catchLoadBrick(\n promise: Promise<unknown>,\n brickName: string,\n unknownBricks: RendererContext[\"unknownBricks\"]\n) {\n return unknownBricks === \"silent\"\n ? promise.catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Load brick \"${brickName}\" failed:`, e);\n })\n : promise;\n}\n"],"mappings":";;;;;;AAUA,SACEA,uBAAuB,EACvBC,sBAAsB,QACjB,mBAAmB;AAC1B,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SACEC,0BAA0B,EAC1BC,wBAAwB,QACnB,oCAAoC;AAC3C,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,qBAA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AAC,CAAsB/D,MAAM,CAACtB,IAAI,CAAC0J,KAAK,CAAC;IACzD;EACF;EACA,OAAOoB,QAAQ;AACjB;AAEA,SAASjE,cAAcA,CACrBsE,OAAyB,EACzBrG,SAAiB,EACjBgC,aAA+C,EAC/C;EACA,OAAOA,aAAa,KAAK,QAAQ,GAC7BqE,OAAO,CAACC,KAAK,CAAEC,CAAC,IAAK;IACnB;IACAzK,OAAO,CAACC,KAAK,iBAAAE,MAAA,CAAgB+D,SAAS,iBAAauG,CAAC,CAAC;EACvD,CAAC,CAAC,GACFF,OAAO;AACb"}
|
|
@@ -25,11 +25,6 @@ var _initializeRerenderBricks = /*#__PURE__*/new WeakSet();
|
|
|
25
25
|
var _dispatchGeneralLifeCycle = /*#__PURE__*/new WeakSet();
|
|
26
26
|
var _addObserver = /*#__PURE__*/new WeakSet();
|
|
27
27
|
export class RendererContext {
|
|
28
|
-
/**
|
|
29
|
-
* - page: render as whole page, triggering page life cycles.
|
|
30
|
-
* - fragment: render as fragment, not triggering page life cycles.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
28
|
constructor(scope, options) {
|
|
34
29
|
var _options$unknownBrick;
|
|
35
30
|
_classPrivateMethodInitSpec(this, _addObserver);
|
|
@@ -37,6 +32,10 @@ export class RendererContext {
|
|
|
37
32
|
_classPrivateMethodInitSpec(this, _dispatchGeneralLifeCycle);
|
|
38
33
|
_classPrivateMethodInitSpec(this, _initializeRerenderBricks);
|
|
39
34
|
_classPrivateMethodInitSpec(this, _unmountBricks);
|
|
35
|
+
/**
|
|
36
|
+
* - page: render as whole page, triggering page life cycles.
|
|
37
|
+
* - fragment: render as fragment, not triggering page life cycles.
|
|
38
|
+
*/
|
|
40
39
|
_defineProperty(this, "scope", void 0);
|
|
41
40
|
_defineProperty(this, "unknownBricks", void 0);
|
|
42
41
|
_classPrivateFieldInitSpec(this, _memoizedLifeCycle, {
|
|
@@ -131,8 +130,8 @@ export class RendererContext {
|
|
|
131
130
|
lastNormal: prevLastNormal,
|
|
132
131
|
lastPortal: prevLastPortal
|
|
133
132
|
} = memoized;
|
|
134
|
-
var insertBeforeChild = (_prevLastNormal$eleme = prevLastNormal === null || prevLastNormal === void 0
|
|
135
|
-
var insertPortalBeforeChild = (_prevLastPortal$eleme = prevLastPortal === null || prevLastPortal === void 0
|
|
133
|
+
var insertBeforeChild = (_prevLastNormal$eleme = prevLastNormal === null || prevLastNormal === void 0 || (_prevLastNormal$eleme2 = prevLastNormal.element) === null || _prevLastNormal$eleme2 === void 0 ? void 0 : _prevLastNormal$eleme2.nextSibling) !== null && _prevLastNormal$eleme !== void 0 ? _prevLastNormal$eleme : null;
|
|
134
|
+
var insertPortalBeforeChild = (_prevLastPortal$eleme = prevLastPortal === null || prevLastPortal === void 0 || (_prevLastPortal$eleme2 = prevLastPortal.element) === null || _prevLastPortal$eleme2 === void 0 ? void 0 : _prevLastPortal$eleme2.nextSibling) !== null && _prevLastPortal$eleme !== void 0 ? _prevLastPortal$eleme : null;
|
|
136
135
|
var last = getLastNode(node);
|
|
137
136
|
memoized.node = node;
|
|
138
137
|
memoized.last = last;
|
|
@@ -279,7 +278,7 @@ export class RendererContext {
|
|
|
279
278
|
var _loop = function (brick) {
|
|
280
279
|
var _loop2 = function (conf) {
|
|
281
280
|
var _hooks$messageDispatc2;
|
|
282
|
-
hooks === null || hooks === void 0
|
|
281
|
+
hooks === null || hooks === void 0 || (_hooks$messageDispatc2 = hooks.messageDispatcher) === null || _hooks$messageDispatc2 === void 0 ? void 0 : _hooks$messageDispatc2.onMessage(conf.channel, detail => {
|
|
283
282
|
listenerFactory(conf.handlers, brick.runtimeContext, brick)(new CustomEvent("message.push", {
|
|
284
283
|
detail
|
|
285
284
|
}));
|
|
@@ -295,7 +294,7 @@ export class RendererContext {
|
|
|
295
294
|
} of _classPrivateFieldGet(this, _memoizedLifeCycle).onMessage) {
|
|
296
295
|
_loop(brick);
|
|
297
296
|
}
|
|
298
|
-
hooks === null || hooks === void 0
|
|
297
|
+
hooks === null || hooks === void 0 || (_hooks$messageDispatc = hooks.messageDispatcher) === null || _hooks$messageDispatc === void 0 ? void 0 : _hooks$messageDispatc.onClose(() => {
|
|
299
298
|
_classPrivateMethodGet(this, _dispatchGeneralLifeCycle, _dispatchGeneralLifeCycle2).call(this, "onMessageClose", new CustomEvent("message.close"));
|
|
300
299
|
});
|
|
301
300
|
}
|
|
@@ -330,7 +329,7 @@ function _unmountBricks2(bricks) {
|
|
|
330
329
|
_classPrivateFieldGet(this, _observers).delete(brick);
|
|
331
330
|
}
|
|
332
331
|
unbindTemplateProxy(brick);
|
|
333
|
-
(_brick$element = brick.element) === null || _brick$element === void 0
|
|
332
|
+
(_brick$element = brick.element) === null || _brick$element === void 0 || delete _brick$element.$$tplStateStore;
|
|
334
333
|
|
|
335
334
|
// Also remove the element
|
|
336
335
|
(_brick$element2 = brick.element) === null || _brick$element2 === void 0 ? void 0 : _brick$element2.remove();
|