@next-core/runtime 1.58.2 → 1.58.3
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 +11 -7
- package/dist/cjs/CustomTemplates.js.map +1 -1
- package/dist/cjs/ModalStack.js +2 -1
- package/dist/cjs/ModalStack.js.map +1 -1
- package/dist/cjs/StoryboardFunctionRegistry.js +2 -1
- package/dist/cjs/StoryboardFunctionRegistry.js.map +1 -1
- package/dist/cjs/createRoot.js +4 -4
- package/dist/cjs/createRoot.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/bindTemplateProxy.js +5 -4
- package/dist/cjs/internal/CustomTemplates/bindTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js +7 -4
- package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/replaceSlotWithSlottedBricks.js +5 -4
- package/dist/cjs/internal/CustomTemplates/replaceSlotWithSlottedBricks.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js +21 -18
- package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js +7 -4
- package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js.map +1 -1
- package/dist/cjs/internal/CustomTemplates/utils.js +3 -3
- package/dist/cjs/internal/CustomTemplates/utils.js.map +1 -1
- package/dist/cjs/internal/ErrorNode.js +2 -1
- package/dist/cjs/internal/ErrorNode.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/expandFormRenderer.js +3 -3
- package/dist/cjs/internal/FormRenderer/expandFormRenderer.js.map +1 -1
- package/dist/cjs/internal/FormRenderer/utils.js +2 -2
- package/dist/cjs/internal/FormRenderer/utils.js.map +1 -1
- package/dist/cjs/internal/Renderer.js +18 -13
- package/dist/cjs/internal/Renderer.js.map +1 -1
- package/dist/cjs/internal/RendererContext.js +10 -8
- package/dist/cjs/internal/RendererContext.js.map +1 -1
- package/dist/cjs/internal/Runtime.js +15 -16
- package/dist/cjs/internal/Runtime.js.map +1 -1
- package/dist/cjs/internal/bindListeners.js +3 -2
- package/dist/cjs/internal/bindListeners.js.map +1 -1
- package/dist/cjs/internal/compute/evaluate.js +4 -4
- package/dist/cjs/internal/compute/evaluate.js.map +1 -1
- package/dist/cjs/internal/compute/getStorageItem.js +2 -1
- package/dist/cjs/internal/compute/getStorageItem.js.map +1 -1
- package/dist/cjs/internal/compute/listenOnTrackingContext.js +2 -1
- package/dist/cjs/internal/compute/listenOnTrackingContext.js.map +1 -1
- package/dist/cjs/internal/data/resolveDataStore.js +4 -2
- package/dist/cjs/internal/data/resolveDataStore.js.map +1 -1
- package/dist/cjs/internal/matchStoryboard.js +2 -2
- package/dist/cjs/internal/matchStoryboard.js.map +1 -1
- package/dist/cjs/internal/poll.js +3 -3
- package/dist/cjs/internal/poll.js.map +1 -1
- package/dist/cjs/internal/secret_internals.js +7 -6
- package/dist/cjs/internal/secret_internals.js.map +1 -1
- package/dist/cjs/internal/setupRootRuntimeContext.js +3 -2
- package/dist/cjs/internal/setupRootRuntimeContext.js.map +1 -1
- package/dist/cjs/setWatermark.js +4 -4
- package/dist/cjs/setWatermark.js.map +1 -1
- package/dist/cjs/themeAndMode.js +2 -1
- package/dist/cjs/themeAndMode.js.map +1 -1
- package/package.json +9 -9
|
@@ -13,8 +13,8 @@ function matchStoryboard(storyboards, pathname) {
|
|
|
13
13
|
// E.g., `/legacy/tool` will match first before `/legacy`.
|
|
14
14
|
// This enables two apps with relationship of parent-child of homepage.
|
|
15
15
|
const sortedStoryboards = (0, _lodash.orderBy)(storyboards, storyboard => {
|
|
16
|
-
var _storyboard$app$homep;
|
|
17
|
-
return (
|
|
16
|
+
var _storyboard$app$homep, _storyboard$app$homep2;
|
|
17
|
+
return (_storyboard$app$homep = (_storyboard$app$homep2 = storyboard.app.homepage) === null || _storyboard$app$homep2 === void 0 ? void 0 : _storyboard$app$homep2.length) !== null && _storyboard$app$homep !== void 0 ? _storyboard$app$homep : 0;
|
|
18
18
|
}, "desc");
|
|
19
19
|
for (const storyboard of sortedStoryboards) {
|
|
20
20
|
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","app","homepage","length","matchHomepage","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 (matchHomepage(homepage, pathname)) {\n return storyboard;\n }\n }\n }\n}\n\nexport function matchHomepage(homepage: string, pathname: string) {\n return homepage === \"/\"\n ? pathname === homepage\n : `${pathname.replace(/\\/+$/, \"\")}/`.startsWith(\n `${homepage.replace(/\\/+$/, \"\")}/`\n );\n}\n\n// istanbul ignore next\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;IAAA,
|
|
1
|
+
{"version":3,"file":"matchStoryboard.js","names":["_lodash","require","_Runtime","matchStoryboard","storyboards","pathname","sortedStoryboards","orderBy","storyboard","_storyboard$app$homep","_storyboard$app$homep2","app","homepage","length","matchHomepage","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 (matchHomepage(homepage, pathname)) {\n return storyboard;\n }\n }\n }\n}\n\nexport function matchHomepage(homepage: string, pathname: string) {\n return homepage === \"/\"\n ? pathname === homepage\n : `${pathname.replace(/\\/+$/, \"\")}/`.startsWith(\n `${homepage.replace(/\\/+$/, \"\")}/`\n );\n}\n\n// istanbul ignore next\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,sBAAA;IAAA,QAAAD,qBAAA,IAAAC,sBAAA,GAAKF,UAAU,CAACG,GAAG,CAACC,QAAQ,cAAAF,sBAAA,uBAAvBA,sBAAA,CAAyBG,MAAM,cAAAJ,qBAAA,cAAAA,qBAAA,GAAI,CAAC;EAAA,GACpD,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,IAAIE,aAAa,CAACF,QAAQ,EAAEP,QAAQ,CAAC,EAAE;QACrC,OAAOG,UAAU;MACnB;IACF;EACF;AACF;AAEO,SAASM,aAAaA,CAACF,QAAgB,EAAEP,QAAgB,EAAE;EAChE,OAAOO,QAAQ,KAAK,GAAG,GACnBP,QAAQ,KAAKO,QAAQ,GACrB,GAAGP,QAAQ,CAACU,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAACC,UAAU,CAC3C,GAAGJ,QAAQ,CAACG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GACjC,CAAC;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAC1BT,UAAyC,EACpB;EAAA,IAAAU,qBAAA;EACrB,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;IACnC,OAAO,KAAK;EACd;EACA,OACE,CAACb,UAAU;EACX;EACC,EAAAU,qBAAA,OAAAI,mBAAU,EAAC,CAAC,CAACC,aAAa,CAAC,CAAC,cAAAL,qBAAA,uBAA5BA,qBAAA,CAA8BM,EAAE,MAAKhB,UAAU,CAACG,GAAG,CAACa,EAAE,IACrD,CAACC,MAAM,CAACC,qBAAqB,IAC7BlB,UAAU,CAACG,GAAG,CAACgB,cAAe;AAEpC","ignoreList":[]}
|
|
@@ -51,7 +51,7 @@ function startPoll(task, {
|
|
|
51
51
|
success === null || success === void 0 || success(result);
|
|
52
52
|
finallyCallback === null || finallyCallback === void 0 || finallyCallback();
|
|
53
53
|
} else {
|
|
54
|
-
delayedPoll(interval
|
|
54
|
+
delayedPoll(interval !== null && interval !== void 0 ? interval : 3000);
|
|
55
55
|
}
|
|
56
56
|
} else if (expectPollStopImmediatelyResult) {
|
|
57
57
|
finallyCallback === null || finallyCallback === void 0 || finallyCallback();
|
|
@@ -68,7 +68,7 @@ function startPoll(task, {
|
|
|
68
68
|
if (!shouldStop) {
|
|
69
69
|
error === null || error === void 0 || error(e);
|
|
70
70
|
if (continueOnError) {
|
|
71
|
-
delayedPoll(interval
|
|
71
|
+
delayedPoll(interval !== null && interval !== void 0 ? interval : 3000);
|
|
72
72
|
} else {
|
|
73
73
|
finallyCallback === null || finallyCallback === void 0 || finallyCallback();
|
|
74
74
|
}
|
|
@@ -86,7 +86,7 @@ function startPoll(task, {
|
|
|
86
86
|
currentTimeoutId = setTimeout(poll, delay);
|
|
87
87
|
timeoutIdList.add(currentTimeoutId);
|
|
88
88
|
}
|
|
89
|
-
delayedPoll(leadingRequestDelay
|
|
89
|
+
delayedPoll(leadingRequestDelay !== null && leadingRequestDelay !== void 0 ? leadingRequestDelay : 0);
|
|
90
90
|
if (delegateLoadingBar) {
|
|
91
91
|
window.dispatchEvent(new Event("request.start"));
|
|
92
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","names":["_lodash","require","_Runtime","_computeRealValue5","timeoutIdList","Set","startPoll","task","progress","success","error","finally","finallyCallback","pollOptions","runtimeContext","expectPollStopImmediately","expectPollEnd","interval","leadingRequestDelay","continueOnError","delegateLoadingBar","computeRealValue","pick","currentRenderId","_internalApiGetRenderId","currentTimeoutId","poll","delete","shouldStop","_computeRealValue","_computeRealValue2","result","expectPollStopImmediatelyResult","_computeRealValue3","window","dispatchEvent","Event","delayedPoll","e","_computeRealValue4","delay","setTimeout","add","clearPollTimeout","timeoutId","clearTimeout","clear"],"sources":["../../../src/internal/poll.ts"],"sourcesContent":["import type { ProviderPollOptions } from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport { _internalApiGetRenderId } from \"./Runtime.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { RuntimeContext } from \"./interfaces.js\";\n\nexport type PollableCallbackFunction = (result?: unknown) => unknown;\n\nexport interface PollableCallback {\n progress?: PollableCallbackFunction;\n success?: PollableCallbackFunction;\n error?: PollableCallbackFunction;\n finally?: PollableCallbackFunction;\n}\n\nconst timeoutIdList = new Set<number>();\n\nexport function startPoll(\n task: () => unknown,\n { progress, success, error, finally: finallyCallback }: PollableCallback,\n pollOptions: ProviderPollOptions,\n runtimeContext: RuntimeContext\n): void {\n const { expectPollStopImmediately, expectPollEnd } = pollOptions;\n const { interval, leadingRequestDelay, continueOnError, delegateLoadingBar } =\n computeRealValue(\n pick(pollOptions, [\n \"interval\",\n \"leadingRequestDelay\",\n \"continueOnError\",\n \"delegateLoadingBar\",\n ]),\n runtimeContext\n ) as ProviderPollOptions;\n const currentRenderId = _internalApiGetRenderId();\n let currentTimeoutId: number;\n async function poll(): Promise<void> {\n timeoutIdList.delete(currentTimeoutId);\n let shouldStop: boolean | undefined;\n try {\n shouldStop = (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.();\n // Stop polling immediately when the expectation is match before task.\n if (!shouldStop) {\n const result = await task();\n const expectPollStopImmediatelyResult = (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.();\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediatelyResult ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n progress?.(result);\n if (\n (\n computeRealValue(expectPollEnd, runtimeContext) as\n | ((result: unknown) => boolean)\n | undefined\n )?.(result)\n ) {\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n success?.(result);\n finallyCallback?.();\n } else {\n delayedPoll(interval ?? 3000);\n }\n } else if (expectPollStopImmediatelyResult) {\n finallyCallback?.();\n }\n } else {\n finallyCallback?.();\n }\n } catch (e) {\n const expectPollStopImmediatelyResult = (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.();\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediatelyResult ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n error?.(e);\n if (continueOnError) {\n delayedPoll(interval ?? 3000);\n } else {\n finallyCallback?.();\n }\n } else if (expectPollStopImmediatelyResult) {\n finallyCallback?.();\n }\n } finally {\n // Manually dispatch an event of `request.end` when the polling is stopped immediately.\n if (delegateLoadingBar && shouldStop) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n }\n }\n\n function delayedPoll(delay: number): void {\n currentTimeoutId = setTimeout(poll, delay) as unknown as number;\n timeoutIdList.add(currentTimeoutId);\n }\n\n delayedPoll(leadingRequestDelay ?? 0);\n\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.start\"));\n }\n}\n\nexport function clearPollTimeout(): void {\n for (const timeoutId of timeoutIdList) {\n clearTimeout(timeoutId);\n }\n timeoutIdList.clear();\n}\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAYA,MAAMG,aAAa,GAAG,IAAIC,GAAG,CAAS,CAAC;AAEhC,SAASC,SAASA,CACvBC,IAAmB,EACnB;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,KAAK;EAAEC,OAAO,EAAEC;AAAkC,CAAC,EACxEC,WAAgC,EAChCC,cAA8B,EACxB;EACN,MAAM;IAAEC,yBAAyB;IAAEC;EAAc,CAAC,GAAGH,WAAW;EAChE,MAAM;IAAEI,QAAQ;IAAEC,mBAAmB;IAAEC,eAAe;IAAEC;EAAmB,CAAC,GAC1E,IAAAC,mCAAgB,EACd,IAAAC,YAAI,EAACT,WAAW,EAAE,CAChB,UAAU,EACV,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,CACrB,CAAC,EACFC,cACF,CAAwB;EAC1B,MAAMS,eAAe,GAAG,IAAAC,gCAAuB,EAAC,CAAC;EACjD,IAAIC,gBAAwB;EAC5B,eAAeC,IAAIA,CAAA,EAAkB;IACnCtB,aAAa,CAACuB,MAAM,CAACF,gBAAgB,CAAC;IACtC,IAAIG,UAA+B;IACnC,IAAI;MAAA,IAAAC,iBAAA;MACFD,UAAU,IAAAC,iBAAA,GACR,IAAAR,mCAAgB,EAACN,yBAAyB,EAAED,cAAc,CAAC,cAAAe,iBAAA,uBADhDA,iBAAA,CAIT,CAAC;MACL;MACA,IAAI,CAACD,UAAU,EAAE;QAAA,IAAAE,kBAAA;QACf,MAAMC,MAAM,GAAG,MAAMxB,IAAI,CAAC,CAAC;QAC3B,MAAMyB,+BAA+B,IAAAF,kBAAA,GACnC,IAAAT,mCAAgB,EAACN,yBAAyB,EAAED,cAAc,CAAC,cAAAgB,kBAAA,uBADrBA,kBAAA,CAIpC,CAAC;QACL;QACA;QACAF,UAAU,GACRI,+BAA+B,IAC/BT,eAAe,KAAK,IAAAC,gCAAuB,EAAC,CAAC;QAC/C,IAAI,CAACI,UAAU,EAAE;UAAA,IAAAK,kBAAA;UACfzB,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAGuB,MAAM,CAAC;UAClB,KAAAE,kBAAA,GAEI,IAAAZ,mCAAgB,EAACL,aAAa,EAAEF,cAAc,CAAC,cAAAmB,kBAAA,eADjDA,kBAAA,CAIIF,MAAM,CAAC,EACX;YACA,IAAIX,kBAAkB,EAAE;cACtBc,MAAM,CAACC,aAAa,CAAC,IAAIC,KAAK,CAAC,aAAa,CAAC,CAAC;YAChD;YACA3B,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAGsB,MAAM,CAAC;YACjBnB,eAAe,aAAfA,eAAe,eAAfA,eAAe,CAAG,CAAC;UACrB,CAAC,MAAM;YACLyB,WAAW,CAACpB,QAAQ,
|
|
1
|
+
{"version":3,"file":"poll.js","names":["_lodash","require","_Runtime","_computeRealValue5","timeoutIdList","Set","startPoll","task","progress","success","error","finally","finallyCallback","pollOptions","runtimeContext","expectPollStopImmediately","expectPollEnd","interval","leadingRequestDelay","continueOnError","delegateLoadingBar","computeRealValue","pick","currentRenderId","_internalApiGetRenderId","currentTimeoutId","poll","delete","shouldStop","_computeRealValue","_computeRealValue2","result","expectPollStopImmediatelyResult","_computeRealValue3","window","dispatchEvent","Event","delayedPoll","e","_computeRealValue4","delay","setTimeout","add","clearPollTimeout","timeoutId","clearTimeout","clear"],"sources":["../../../src/internal/poll.ts"],"sourcesContent":["import type { ProviderPollOptions } from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport { _internalApiGetRenderId } from \"./Runtime.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { RuntimeContext } from \"./interfaces.js\";\n\nexport type PollableCallbackFunction = (result?: unknown) => unknown;\n\nexport interface PollableCallback {\n progress?: PollableCallbackFunction;\n success?: PollableCallbackFunction;\n error?: PollableCallbackFunction;\n finally?: PollableCallbackFunction;\n}\n\nconst timeoutIdList = new Set<number>();\n\nexport function startPoll(\n task: () => unknown,\n { progress, success, error, finally: finallyCallback }: PollableCallback,\n pollOptions: ProviderPollOptions,\n runtimeContext: RuntimeContext\n): void {\n const { expectPollStopImmediately, expectPollEnd } = pollOptions;\n const { interval, leadingRequestDelay, continueOnError, delegateLoadingBar } =\n computeRealValue(\n pick(pollOptions, [\n \"interval\",\n \"leadingRequestDelay\",\n \"continueOnError\",\n \"delegateLoadingBar\",\n ]),\n runtimeContext\n ) as ProviderPollOptions;\n const currentRenderId = _internalApiGetRenderId();\n let currentTimeoutId: number;\n async function poll(): Promise<void> {\n timeoutIdList.delete(currentTimeoutId);\n let shouldStop: boolean | undefined;\n try {\n shouldStop = (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.();\n // Stop polling immediately when the expectation is match before task.\n if (!shouldStop) {\n const result = await task();\n const expectPollStopImmediatelyResult = (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.();\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediatelyResult ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n progress?.(result);\n if (\n (\n computeRealValue(expectPollEnd, runtimeContext) as\n | ((result: unknown) => boolean)\n | undefined\n )?.(result)\n ) {\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n success?.(result);\n finallyCallback?.();\n } else {\n delayedPoll(interval ?? 3000);\n }\n } else if (expectPollStopImmediatelyResult) {\n finallyCallback?.();\n }\n } else {\n finallyCallback?.();\n }\n } catch (e) {\n const expectPollStopImmediatelyResult = (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.();\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediatelyResult ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n error?.(e);\n if (continueOnError) {\n delayedPoll(interval ?? 3000);\n } else {\n finallyCallback?.();\n }\n } else if (expectPollStopImmediatelyResult) {\n finallyCallback?.();\n }\n } finally {\n // Manually dispatch an event of `request.end` when the polling is stopped immediately.\n if (delegateLoadingBar && shouldStop) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n }\n }\n\n function delayedPoll(delay: number): void {\n currentTimeoutId = setTimeout(poll, delay) as unknown as number;\n timeoutIdList.add(currentTimeoutId);\n }\n\n delayedPoll(leadingRequestDelay ?? 0);\n\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.start\"));\n }\n}\n\nexport function clearPollTimeout(): void {\n for (const timeoutId of timeoutIdList) {\n clearTimeout(timeoutId);\n }\n timeoutIdList.clear();\n}\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAYA,MAAMG,aAAa,GAAG,IAAIC,GAAG,CAAS,CAAC;AAEhC,SAASC,SAASA,CACvBC,IAAmB,EACnB;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,KAAK;EAAEC,OAAO,EAAEC;AAAkC,CAAC,EACxEC,WAAgC,EAChCC,cAA8B,EACxB;EACN,MAAM;IAAEC,yBAAyB;IAAEC;EAAc,CAAC,GAAGH,WAAW;EAChE,MAAM;IAAEI,QAAQ;IAAEC,mBAAmB;IAAEC,eAAe;IAAEC;EAAmB,CAAC,GAC1E,IAAAC,mCAAgB,EACd,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mBAAmB,aAAnBA,mBAAmB,cAAnBA,mBAAmB,GAAI,CAAC,CAAC;EAErC,IAAIE,kBAAkB,EAAE;IACtBc,MAAM,CAACC,aAAa,CAAC,IAAIC,KAAK,CAAC,eAAe,CAAC,CAAC;EAClD;AACF;AAEO,SAASO,gBAAgBA,CAAA,EAAS;EACvC,KAAK,MAAMC,SAAS,IAAIxC,aAAa,EAAE;IACrCyC,YAAY,CAACD,SAAS,CAAC;EACzB;EACAxC,aAAa,CAAC0C,KAAK,CAAC,CAAC;AACvB","ignoreList":[]}
|
|
@@ -52,15 +52,15 @@ var _routeMatchedMap = require("./routeMatchedMap.js");
|
|
|
52
52
|
var _realTimeDataInspect = require("./data/realTimeDataInspect.js");
|
|
53
53
|
const symbolForRootRuntimeContext = exports.symbolForRootRuntimeContext = Symbol.for("root.runtimeContext");
|
|
54
54
|
async function renderUseBrick(useBrick, data, errorBoundary) {
|
|
55
|
-
var _output$node, _output$node2;
|
|
55
|
+
var _useBrick$symbolForRo, _scopedRuntimeContext, _scopedRuntimeContext2, _output$node, _output$node2;
|
|
56
56
|
const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] = (0, _Renderer.createScopedRuntimeContext)({
|
|
57
|
-
...(useBrick[symbolForRootRuntimeContext]
|
|
57
|
+
...((_useBrick$symbolForRo = useBrick[symbolForRootRuntimeContext]) !== null && _useBrick$symbolForRo !== void 0 ? _useBrick$symbolForRo : (0, _Runtime._internalApiGetRuntimeContext)()),
|
|
58
58
|
data,
|
|
59
59
|
pendingPermissionsPreCheck: []
|
|
60
60
|
});
|
|
61
61
|
scopedRuntimeContext.inUseBrick = true;
|
|
62
|
-
scopedRuntimeContext.tplStateStoreMap
|
|
63
|
-
scopedRuntimeContext.formStateStoreMap
|
|
62
|
+
(_scopedRuntimeContext = scopedRuntimeContext.tplStateStoreMap) !== null && _scopedRuntimeContext !== void 0 ? _scopedRuntimeContext : scopedRuntimeContext.tplStateStoreMap = new Map();
|
|
63
|
+
(_scopedRuntimeContext2 = scopedRuntimeContext.formStateStoreMap) !== null && _scopedRuntimeContext2 !== void 0 ? _scopedRuntimeContext2 : scopedRuntimeContext.formStateStoreMap = new Map();
|
|
64
64
|
const rendererContext = new _RendererContext.RendererContext("fragment");
|
|
65
65
|
const renderRoot = {
|
|
66
66
|
tag: _enums.RenderTag.ROOT,
|
|
@@ -280,7 +280,7 @@ function loadBricks(bricks) {
|
|
|
280
280
|
* Try the brick packages passed in, before using from bootstrap.
|
|
281
281
|
*/
|
|
282
282
|
function loadEditors(editors, brickPackages) {
|
|
283
|
-
return (0, _loader.loadEditorsImperatively)(editors, brickPackages
|
|
283
|
+
return (0, _loader.loadEditorsImperatively)(editors, brickPackages !== null && brickPackages !== void 0 ? brickPackages : (0, _Runtime.getBrickPackages)());
|
|
284
284
|
}
|
|
285
285
|
function getRenderId() {
|
|
286
286
|
return (0, _Runtime._internalApiGetRenderId)();
|
|
@@ -344,9 +344,10 @@ async function debugDataValue(debugData, {
|
|
|
344
344
|
return (0, _computeRealValue.asyncComputeRealValue)(debugData.value, runtimeContext);
|
|
345
345
|
}
|
|
346
346
|
function getLegalRuntimeValue(options) {
|
|
347
|
+
var _runtimeContext$overr;
|
|
347
348
|
const runtimeContext = (0, _Runtime._internalApiGetRuntimeContext)();
|
|
348
349
|
return {
|
|
349
|
-
app: (runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.overrideApp)
|
|
350
|
+
app: (_runtimeContext$overr = runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.overrideApp) !== null && _runtimeContext$overr !== void 0 ? _runtimeContext$overr : runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.app,
|
|
350
351
|
location: (0, _lodash.pick)(location, ["href", "origin", "hostname", "host"]),
|
|
351
352
|
...(0, _lodash.pick)(runtimeContext, ["query", "sys"]),
|
|
352
353
|
match: (0, _routeMatchedMap.getMatchedRoute)(options === null || options === void 0 ? void 0 : options.routeId)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret_internals.js","names":["_lodash","require","_Runtime","_Renderer","_RendererContext","_resolveData","_computeRealValue","_mount","_enums","_isStrictMode","_CustomTemplates","_registerAppI18n","_utils","_loader","_routeMatchedMap","_realTimeDataInspect","symbolForRootRuntimeContext","exports","Symbol","for","renderUseBrick","useBrick","data","errorBoundary","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","_internalApiGetRuntimeContext","pendingPermissionsPreCheck","inUseBrick","tplStateStoreMap","Map","formStateStoreMap","rendererContext","RendererContext","renderRoot","tag","RenderTag","ROOT","createPortal","strict","isStrictMode","output","renderBrick","scopedStores","postAsyncRender","node","PLACEHOLDER","tracking","Error","undefined","portal","child","tagName","type","mountUseBrick","element","portalRoot","document","querySelector","createElement","appendChild","mountTree","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","mountResult","unmountTree","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","computeRealValue","noInject","updateStoryboard","appId","storyboardPatch","storyboard","_internalApiGetStoryboardInBootstrapData","Object","assign","meta","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","registerAppI18n","updateStoryboardByRoute","newRoute","matched","matchRoute","route","path","exact","replaceRoutes","routes","forEach","index","Array","isArray","bricks","replaceBricks","brick","slots","slotConf","values","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","customTemplates","define","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","pick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","tplStateStoreId","runtimeContext","tplStateStore","getTplStateStore","getValue","ctxStore","getAllContextValues","getAllValues","getBrickPackagesById","id","getBrickPackages","find","pkg","filePath","startsWith","loadBricks","loadBricksImperatively","loadEditors","editors","brickPackages","loadEditorsImperatively","getRenderId","_internalApiGetRenderId","getAddedContracts","updateStoryboardType","collectUsedContracts","updatedStoryboard","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","api","_storyboard$meta","_","namespaceId","match","contracts","some","contract","push","debugDataValue","debugData","routeId","getMatchedRoute","resolve","resolveData","cache","asyncComputeRealValue","value","getLegalRuntimeValue","app","overrideApp","location"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n RuntimeSnippet,\n ContextConf,\n BrickPackage,\n RouteConfOfBricks,\n} from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport {\n createScopedRuntimeContext,\n postAsyncRender,\n renderBrick,\n} from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\n RuntimeContext,\n DebugDataValue,\n RuntimeDataVale,\n RuntimeDataValueOption,\n} from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport {\n loadBricksImperatively,\n loadEditorsImperatively,\n} from \"@next-core/loader\";\nimport { getMatchedRoute } from \"./routeMatchedMap.js\";\n\nexport type { DataValueOption, RuntimeContext };\n\nexport const symbolForRootRuntimeContext = Symbol.for(\"root.runtimeContext\");\n\nexport interface RuntimeUseBrickConfWithRootSymbols extends UseSingleBrickConf {\n [symbolForRootRuntimeContext]?: RuntimeContext;\n}\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[];\n}\n\nexport async function renderUseBrick(\n useBrick: RuntimeUseBrickConfWithRootSymbols,\n data: unknown,\n errorBoundary?: boolean\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\n ...(useBrick[symbolForRootRuntimeContext] ??\n _internalApiGetRuntimeContext()!),\n data,\n pendingPermissionsPreCheck: [],\n });\n\n scopedRuntimeContext.inUseBrick = true;\n scopedRuntimeContext.tplStateStoreMap ??= new Map();\n scopedRuntimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const strict = isStrictMode();\n\n const output = await renderBrick(\n renderRoot,\n strict && !errorBoundary\n ? useBrick\n : {\n errorBoundary,\n ...useBrick,\n },\n scopedRuntimeContext,\n rendererContext,\n [],\n {}\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\n\n if (output.node?.tag === RenderTag.PLACEHOLDER) {\n if (output.node.tracking) {\n throw new Error(\n \"The root brick of useBrick cannot be an ignored tracking control node\"\n );\n }\n output.node = undefined;\n }\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext, scopedStores };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext, scopedStores }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n meta: {\n // Keep runtime fields such as `injectMenus`\n ...storyboard.meta,\n ...storyboardPatch.meta,\n },\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let matched = false;\n\n function matchRoute(route: RouteConf) {\n return route.path === newRoute.path && !route.exact === !newRoute.exact;\n }\n\n function replaceRoutes(routes: RouteConf[]) {\n routes.forEach((route, index) => {\n if (route.type === \"routes\") {\n replaceRoutes(route.routes);\n } else {\n if (matchRoute(route)) {\n matched = true;\n routes[index] = newRoute;\n } else if (Array.isArray((route as RouteConfOfBricks).bricks)) {\n replaceBricks((route as RouteConfOfBricks).bricks);\n }\n }\n });\n }\n\n function replaceBricks(bricks: BrickConf[]) {\n bricks.forEach((brick) => {\n if (brick.slots) {\n for (const slotConf of Object.values(brick.slots)) {\n if (slotConf.type === \"routes\") {\n replaceRoutes(slotConf.routes);\n } else {\n replaceBricks(slotConf.bricks);\n }\n }\n }\n });\n }\n\n replaceRoutes(storyboard.routes);\n\n if (!matched) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(\n settings,\n \"properties\",\n \"events\",\n \"lifeCycle\",\n \"context\",\n \"slots\",\n \"children\"\n ),\n },\n ]\n );\n}\n\nfunction getSnippetPreviewPath(snippetId: string): string {\n return `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n context?: ContextConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }],\n snippetData.context\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[],\n context?: ContextConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n context,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n\nexport function getContextValue(\n name: string,\n { tplStateStoreId }: DataValueOption\n): unknown {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getValue(name);\n }\n\n return runtimeContext.ctxStore.getValue(name);\n}\n\nexport function getAllContextValues({\n tplStateStoreId,\n}: DataValueOption): Record<string, unknown> {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getAllValues();\n }\n\n return runtimeContext.ctxStore.getAllValues();\n}\n\nexport function getBrickPackagesById(id: string) {\n return getBrickPackages().find((pkg) =>\n pkg.id ? pkg.id === id : pkg.filePath.startsWith(`${id}/`)\n );\n}\n\n/**\n * Support loading v3 bricks only.\n */\nexport function loadBricks(bricks: string[]) {\n return loadBricksImperatively(bricks, getBrickPackages());\n}\n\n/**\n * Try the brick packages passed in, before using from bootstrap.\n */\nexport function loadEditors(\n editors: string[] | Set<string>,\n brickPackages?: BrickPackage[]\n) {\n return loadEditorsImperatively(editors, brickPackages ?? getBrickPackages());\n}\n\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n { appId, updateStoryboardType, collectUsedContracts }: PreviewOption\n): Promise<string[]> {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId);\n let updatedStoryboard;\n\n // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts\n if (updateStoryboardType === \"route\") {\n updatedStoryboard = {\n routes: [storyboardPatch as RouteConf],\n } as Storyboard;\n } else if (updateStoryboardType === \"template\") {\n updatedStoryboard = {\n meta: {\n customTemplates: [storyboardPatch as CustomTemplate],\n },\n } as Storyboard;\n } else if (updateStoryboardType === \"snippet\") {\n // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route\n const snippetPreviewPath = getSnippetPreviewPath(\n (storyboardPatch as RuntimeSnippet).snippetId\n );\n const currentRoute = storyboard?.routes?.find(\n (route) => route.path === snippetPreviewPath\n );\n\n updatedStoryboard = {\n routes: [currentRoute],\n } as Storyboard;\n }\n\n const addedContracts: string[] = [];\n\n if (updatedStoryboard && collectUsedContracts) {\n const contractApis = await collectUsedContracts(updatedStoryboard);\n\n contractApis.forEach((api: string) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, namespaceId, name] = api.match(\n /(.*)@(.*):\\d\\.\\d\\.\\d/\n ) as string[];\n\n if (\n !storyboard?.meta?.contracts?.some(\n (contract) =>\n contract.namespaceId === namespaceId && contract.name === name\n )\n ) {\n addedContracts.push(api);\n }\n });\n }\n\n return addedContracts;\n}\n\nexport async function debugDataValue(\n debugData: DebugDataValue,\n { tplStateStoreId, routeId }: DataValueOption\n): Promise<any> {\n const runtimeContext = {\n ..._internalApiGetRuntimeContext()!,\n tplStateStoreId,\n match: getMatchedRoute(routeId as string),\n };\n\n if (debugData.resolve) {\n return resolveData(debugData.resolve!, runtimeContext, { cache: \"reload\" });\n }\n\n return asyncComputeRealValue(debugData.value, runtimeContext);\n}\n\nexport function getLegalRuntimeValue(\n options?: RuntimeDataValueOption\n): RuntimeDataVale {\n const runtimeContext = _internalApiGetRuntimeContext();\n\n return {\n app: runtimeContext?.overrideApp ?? runtimeContext?.app,\n location: pick(location, [\"href\", \"origin\", \"hostname\", \"host\"]),\n ...pick(runtimeContext, [\"query\", \"sys\"]),\n match: getMatchedRoute(options?.routeId as string),\n } as RuntimeDataVale;\n}\n\nexport {\n setRealTimeDataInspectRoot,\n addRealTimeDataInspectHook,\n} from \"./data/realTimeDataInspect.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAWA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAEA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AAIA,IAAAa,gBAAA,GAAAb,OAAA;AAocA,IAAAc,oBAAA,GAAAd,OAAA;AAhcO,MAAMe,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAGE,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAarE,eAAeC,cAAcA,CAClCC,QAA4C,EAC5CC,IAAa,EACbC,aAAuB,EACQ;EAAA,IAAAC,YAAA,EAAAC,aAAA;EAC/B,MAAM,CAACC,oBAAoB,EAAEC,kBAAkB,EAAEC,mBAAmB,CAAC,GACnE,IAAAC,oCAA0B,EAAC;IACzB,IAAIR,QAAQ,CAACL,2BAA2B,CAAC,IACvC,IAAAc,sCAA6B,EAAC,CAAE,CAAC;IACnCR,IAAI;IACJS,0BAA0B,EAAE;EAC9B,CAAC,CAAC;EAEJL,oBAAoB,CAACM,UAAU,GAAG,IAAI;EACtCN,oBAAoB,CAACO,gBAAgB,KAArCP,oBAAoB,CAACO,gBAAgB,GAAK,IAAIC,GAAG,CAAC,C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AAEkD,GAAG;IACvDE,QAAQ,EAAE,IAAApE,YAAI,EAACoE,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAChE,GAAG,IAAApE,YAAI,EAACgB,cAAc,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzCmC,KAAK,EAAE,IAAAQ,gCAAe,EAAC1G,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEyG,OAAiB;EACnD,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"secret_internals.js","names":["_lodash","require","_Runtime","_Renderer","_RendererContext","_resolveData","_computeRealValue","_mount","_enums","_isStrictMode","_CustomTemplates","_registerAppI18n","_utils","_loader","_routeMatchedMap","_realTimeDataInspect","symbolForRootRuntimeContext","exports","Symbol","for","renderUseBrick","useBrick","data","errorBoundary","_useBrick$symbolForRo","_scopedRuntimeContext","_scopedRuntimeContext2","_output$node","_output$node2","scopedRuntimeContext","tplStateStoreScope","formStateStoreScope","createScopedRuntimeContext","_internalApiGetRuntimeContext","pendingPermissionsPreCheck","inUseBrick","tplStateStoreMap","Map","formStateStoreMap","rendererContext","RendererContext","renderRoot","tag","RenderTag","ROOT","createPortal","strict","isStrictMode","output","renderBrick","scopedStores","postAsyncRender","node","PLACEHOLDER","tracking","Error","undefined","portal","child","tagName","type","mountUseBrick","element","portalRoot","document","querySelector","createElement","appendChild","mountTree","dispatchOnMount","initializeScrollIntoView","initializeMediaChange","initializeMessageDispatcher","store","mountAsyncData","unmountUseBrick","mountResult","unmountTree","remove","dispatchOnUnmount","dispose","legacyDoTransform","to","options","computeRealValue","noInject","updateStoryboard","appId","storyboardPatch","storyboard","_internalApiGetStoryboardInBootstrapData","Object","assign","meta","$$fulfilling","$$fulfilled","$$registerCustomTemplateProcessed","registerAppI18n","updateStoryboardByRoute","newRoute","matched","matchRoute","route","path","exact","replaceRoutes","routes","forEach","index","Array","isArray","bricks","replaceBricks","brick","slots","slotConf","values","unshift","updateStoryboardByTemplate","newTemplate","settings","tplName","name","customTemplates","define","proxy","state","updateTemplatePreviewSettings","templateId","_updatePreviewSettings","pick","getSnippetPreviewPath","snippetId","updateStoryboardBySnippet","snippetData","_snippetData$bricks","length","context","updateSnippetPreviewSettings","previewRouteIndex","findIndex","newPreviewRoute","menu","splice","getContextValue","tplStateStoreId","runtimeContext","tplStateStore","getTplStateStore","getValue","ctxStore","getAllContextValues","getAllValues","getBrickPackagesById","id","getBrickPackages","find","pkg","filePath","startsWith","loadBricks","loadBricksImperatively","loadEditors","editors","brickPackages","loadEditorsImperatively","getRenderId","_internalApiGetRenderId","getAddedContracts","updateStoryboardType","collectUsedContracts","updatedStoryboard","_storyboard$routes","snippetPreviewPath","currentRoute","addedContracts","contractApis","api","_storyboard$meta","_","namespaceId","match","contracts","some","contract","push","debugDataValue","debugData","routeId","getMatchedRoute","resolve","resolveData","cache","asyncComputeRealValue","value","getLegalRuntimeValue","_runtimeContext$overr","app","overrideApp","location"],"sources":["../../../src/internal/secret_internals.ts"],"sourcesContent":["import type {\n BrickConf,\n CustomTemplate,\n RouteConf,\n Storyboard,\n UseSingleBrickConf,\n RuntimeSnippet,\n ContextConf,\n BrickPackage,\n RouteConfOfBricks,\n} from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport {\n _internalApiGetRenderId,\n _internalApiGetRuntimeContext,\n _internalApiGetStoryboardInBootstrapData,\n getBrickPackages,\n} from \"./Runtime.js\";\nimport {\n createScopedRuntimeContext,\n postAsyncRender,\n renderBrick,\n} from \"./Renderer.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport type { DataStore } from \"./data/DataStore.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport type {\n DataValueOption,\n PreviewOption,\n PreviewStoryboardPatch,\n RenderRoot,\n RuntimeContext,\n DebugDataValue,\n RuntimeDataVale,\n RuntimeDataValueOption,\n} from \"./interfaces.js\";\nimport { mountTree, unmountTree } from \"./mount.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { isStrictMode } from \"../isStrictMode.js\";\nimport { customTemplates } from \"../CustomTemplates.js\";\nimport { registerAppI18n } from \"./registerAppI18n.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport {\n loadBricksImperatively,\n loadEditorsImperatively,\n} from \"@next-core/loader\";\nimport { getMatchedRoute } from \"./routeMatchedMap.js\";\n\nexport type { DataValueOption, RuntimeContext };\n\nexport const symbolForRootRuntimeContext = Symbol.for(\"root.runtimeContext\");\n\nexport interface RuntimeUseBrickConfWithRootSymbols extends UseSingleBrickConf {\n [symbolForRootRuntimeContext]?: RuntimeContext;\n}\n\nexport interface RenderUseBrickResult {\n tagName: string | null;\n renderRoot: RenderRoot;\n rendererContext: RendererContext;\n scopedStores: DataStore<\"STATE\" | \"FORM_STATE\">[];\n}\n\nexport async function renderUseBrick(\n useBrick: RuntimeUseBrickConfWithRootSymbols,\n data: unknown,\n errorBoundary?: boolean\n): Promise<RenderUseBrickResult> {\n const [scopedRuntimeContext, tplStateStoreScope, formStateStoreScope] =\n createScopedRuntimeContext({\n ...(useBrick[symbolForRootRuntimeContext] ??\n _internalApiGetRuntimeContext()!),\n data,\n pendingPermissionsPreCheck: [],\n });\n\n scopedRuntimeContext.inUseBrick = true;\n scopedRuntimeContext.tplStateStoreMap ??= new Map();\n scopedRuntimeContext.formStateStoreMap ??= new Map();\n\n const rendererContext = new RendererContext(\"fragment\");\n\n const renderRoot: RenderRoot = {\n tag: RenderTag.ROOT,\n // Will set during `mountUseBrick`\n createPortal: null!,\n };\n\n const strict = isStrictMode();\n\n const output = await renderBrick(\n renderRoot,\n strict && !errorBoundary\n ? useBrick\n : {\n errorBoundary,\n ...useBrick,\n },\n scopedRuntimeContext,\n rendererContext,\n [],\n {}\n );\n\n const scopedStores = [...tplStateStoreScope, ...formStateStoreScope];\n\n await postAsyncRender(output, scopedRuntimeContext, scopedStores);\n\n if (output.node?.tag === RenderTag.PLACEHOLDER) {\n if (output.node.tracking) {\n throw new Error(\n \"The root brick of useBrick cannot be an ignored tracking control node\"\n );\n }\n output.node = undefined;\n }\n\n if (output.node?.portal) {\n throw new Error(\"The root brick of useBrick cannot be a portal brick\");\n }\n\n renderRoot.child = output.node;\n\n const tagName = output.node ? output.node.type : null;\n\n return { tagName, renderRoot, rendererContext, scopedStores };\n}\n\nexport interface MountUseBrickResult {\n portal?: HTMLElement;\n}\n\nexport function mountUseBrick(\n { renderRoot, rendererContext, scopedStores }: RenderUseBrickResult,\n element: HTMLElement\n): MountUseBrickResult {\n let portal: HTMLElement | undefined;\n renderRoot.createPortal = () => {\n const portalRoot = document.querySelector(\n \"#portal-mount-point\"\n ) as HTMLElement;\n portal = document.createElement(\"div\");\n portalRoot.appendChild(portal);\n return portal;\n };\n\n mountTree(renderRoot, element);\n\n rendererContext.dispatchOnMount();\n rendererContext.initializeScrollIntoView();\n rendererContext.initializeMediaChange();\n rendererContext.initializeMessageDispatcher();\n\n for (const store of scopedStores) {\n store.mountAsyncData();\n }\n\n return {\n portal,\n };\n}\n\nexport function unmountUseBrick(\n { rendererContext }: RenderUseBrickResult,\n mountResult: MountUseBrickResult\n): void {\n // if (mountResult.mainBrick) {\n // mountResult.mainBrick.unmount();\n // }\n if (mountResult.portal) {\n unmountTree(mountResult.portal);\n mountResult.portal.remove();\n }\n rendererContext.dispatchOnUnmount();\n rendererContext.dispose();\n}\n\n/** For v2 compatibility of `doTransform` from brick-kit. */\nexport function legacyDoTransform(\n data: unknown,\n to: unknown,\n options?: unknown\n) {\n if (options) {\n throw new Error(\"Legacy doTransform does not support options in v3\");\n }\n return computeRealValue(\n to,\n {\n ..._internalApiGetRuntimeContext()!,\n data,\n },\n {\n noInject: true,\n }\n );\n}\n\nexport function updateStoryboard(\n appId: string,\n storyboardPatch: Partial<Storyboard>\n): void {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n Object.assign(storyboard, {\n ...storyboardPatch,\n meta: {\n // Keep runtime fields such as `injectMenus`\n ...storyboard.meta,\n ...storyboardPatch.meta,\n },\n $$fulfilling: null,\n $$fulfilled: true,\n $$registerCustomTemplateProcessed: false,\n });\n registerAppI18n(storyboard);\n}\n\nexport function updateStoryboardByRoute(appId: string, newRoute: RouteConf) {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId)!;\n let matched = false;\n\n function matchRoute(route: RouteConf) {\n return route.path === newRoute.path && !route.exact === !newRoute.exact;\n }\n\n function replaceRoutes(routes: RouteConf[]) {\n routes.forEach((route, index) => {\n if (route.type === \"routes\") {\n replaceRoutes(route.routes);\n } else {\n if (matchRoute(route)) {\n matched = true;\n routes[index] = newRoute;\n } else if (Array.isArray((route as RouteConfOfBricks).bricks)) {\n replaceBricks((route as RouteConfOfBricks).bricks);\n }\n }\n });\n }\n\n function replaceBricks(bricks: BrickConf[]) {\n bricks.forEach((brick) => {\n if (brick.slots) {\n for (const slotConf of Object.values(brick.slots)) {\n if (slotConf.type === \"routes\") {\n replaceRoutes(slotConf.routes);\n } else {\n replaceBricks(slotConf.bricks);\n }\n }\n }\n });\n }\n\n replaceRoutes(storyboard.routes);\n\n if (!matched) {\n storyboard.routes.unshift(newRoute);\n }\n}\n\nexport function updateStoryboardByTemplate(\n appId: string,\n newTemplate: CustomTemplate,\n settings: unknown\n): void {\n const tplName = `${appId}.${newTemplate.name}`;\n // customTemplateRegistry.delete(tplName);\n customTemplates.define(tplName, {\n bricks: newTemplate.bricks,\n proxy: newTemplate.proxy,\n state: newTemplate.state,\n });\n updateTemplatePreviewSettings(appId, newTemplate.name, settings);\n}\n\nexport function updateTemplatePreviewSettings(\n appId: string,\n templateId: string,\n settings?: unknown\n): void {\n _updatePreviewSettings(\n appId,\n `\\${APP.homepage}/_dev_only_/template-preview/${templateId}`,\n [\n {\n brick: templateId,\n ...pick(\n settings,\n \"properties\",\n \"events\",\n \"lifeCycle\",\n \"context\",\n \"slots\",\n \"children\"\n ),\n },\n ]\n );\n}\n\nfunction getSnippetPreviewPath(snippetId: string): string {\n return `\\${APP.homepage}/_dev_only_/snippet-preview/${snippetId}`;\n}\n\nexport function updateStoryboardBySnippet(\n appId: string,\n snippetData: {\n snippetId: string;\n bricks?: BrickConf[];\n context?: ContextConf[];\n }\n): void {\n _updatePreviewSettings(\n appId,\n getSnippetPreviewPath(snippetData.snippetId),\n snippetData.bricks?.length ? snippetData.bricks : [{ brick: \"span\" }],\n snippetData.context\n );\n}\n\nexport const updateSnippetPreviewSettings = updateStoryboardBySnippet;\n\nfunction _updatePreviewSettings(\n appId: string,\n path: string,\n bricks: BrickConf[],\n context?: ContextConf[]\n) {\n const { routes } = _internalApiGetStoryboardInBootstrapData(appId)!;\n const previewRouteIndex = routes.findIndex((route) => route.path === path);\n const newPreviewRoute: RouteConf = {\n path,\n bricks,\n context,\n menu: false,\n exact: true,\n };\n if (previewRouteIndex === -1) {\n routes.unshift(newPreviewRoute);\n } else {\n routes.splice(previewRouteIndex, 1, newPreviewRoute);\n }\n}\n\nexport function getContextValue(\n name: string,\n { tplStateStoreId }: DataValueOption\n): unknown {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getValue(name);\n }\n\n return runtimeContext.ctxStore.getValue(name);\n}\n\nexport function getAllContextValues({\n tplStateStoreId,\n}: DataValueOption): Record<string, unknown> {\n const runtimeContext = _internalApiGetRuntimeContext()!;\n\n if (tplStateStoreId) {\n const tplStateStore = getTplStateStore(\n {\n ...runtimeContext,\n tplStateStoreId,\n },\n \"STATE\"\n );\n return tplStateStore.getAllValues();\n }\n\n return runtimeContext.ctxStore.getAllValues();\n}\n\nexport function getBrickPackagesById(id: string) {\n return getBrickPackages().find((pkg) =>\n pkg.id ? pkg.id === id : pkg.filePath.startsWith(`${id}/`)\n );\n}\n\n/**\n * Support loading v3 bricks only.\n */\nexport function loadBricks(bricks: string[]) {\n return loadBricksImperatively(bricks, getBrickPackages());\n}\n\n/**\n * Try the brick packages passed in, before using from bootstrap.\n */\nexport function loadEditors(\n editors: string[] | Set<string>,\n brickPackages?: BrickPackage[]\n) {\n return loadEditorsImperatively(editors, brickPackages ?? getBrickPackages());\n}\n\nexport function getRenderId() {\n return _internalApiGetRenderId();\n}\n\nexport async function getAddedContracts(\n storyboardPatch: PreviewStoryboardPatch,\n { appId, updateStoryboardType, collectUsedContracts }: PreviewOption\n): Promise<string[]> {\n const storyboard = _internalApiGetStoryboardInBootstrapData(appId);\n let updatedStoryboard;\n\n // 拿到更新部分的 storyboard 配置,然后扫描一遍,找到新增的 contracts\n if (updateStoryboardType === \"route\") {\n updatedStoryboard = {\n routes: [storyboardPatch as RouteConf],\n } as Storyboard;\n } else if (updateStoryboardType === \"template\") {\n updatedStoryboard = {\n meta: {\n customTemplates: [storyboardPatch as CustomTemplate],\n },\n } as Storyboard;\n } else if (updateStoryboardType === \"snippet\") {\n // snippet 是放在挂载 route 里预览,通过 previewPath 拿到当前修改 route\n const snippetPreviewPath = getSnippetPreviewPath(\n (storyboardPatch as RuntimeSnippet).snippetId\n );\n const currentRoute = storyboard?.routes?.find(\n (route) => route.path === snippetPreviewPath\n );\n\n updatedStoryboard = {\n routes: [currentRoute],\n } as Storyboard;\n }\n\n const addedContracts: string[] = [];\n\n if (updatedStoryboard && collectUsedContracts) {\n const contractApis = await collectUsedContracts(updatedStoryboard);\n\n contractApis.forEach((api: string) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, namespaceId, name] = api.match(\n /(.*)@(.*):\\d\\.\\d\\.\\d/\n ) as string[];\n\n if (\n !storyboard?.meta?.contracts?.some(\n (contract) =>\n contract.namespaceId === namespaceId && contract.name === name\n )\n ) {\n addedContracts.push(api);\n }\n });\n }\n\n return addedContracts;\n}\n\nexport async function debugDataValue(\n debugData: DebugDataValue,\n { tplStateStoreId, routeId }: DataValueOption\n): Promise<any> {\n const runtimeContext = {\n ..._internalApiGetRuntimeContext()!,\n tplStateStoreId,\n match: getMatchedRoute(routeId as string),\n };\n\n if (debugData.resolve) {\n return resolveData(debugData.resolve!, runtimeContext, { cache: \"reload\" });\n }\n\n return asyncComputeRealValue(debugData.value, runtimeContext);\n}\n\nexport function getLegalRuntimeValue(\n options?: RuntimeDataValueOption\n): RuntimeDataVale {\n const runtimeContext = _internalApiGetRuntimeContext();\n\n return {\n app: runtimeContext?.overrideApp ?? runtimeContext?.app,\n location: pick(location, [\"href\", \"origin\", \"hostname\", \"host\"]),\n ...pick(runtimeContext, [\"query\", \"sys\"]),\n match: getMatchedRoute(options?.routeId as string),\n } as RuntimeDataVale;\n}\n\nexport {\n setRealTimeDataInspectRoot,\n addRealTimeDataInspectHook,\n} from \"./data/realTimeDataInspect.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAWA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAEA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AAIA,IAAAa,gBAAA,GAAAb,OAAA;AAocA,IAAAc,oBAAA,GAAAd,OAAA;AAhcO,MAAMe,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAGE,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAarE,eAAeC,cAAcA,CAClCC,QAA4C,EAC5CC,IAAa,EACbC,aA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,EAC/B;EACd,MAAM1C,cAAc,GAAG;IACrB,GAAG,IAAAjH,sCAA6B,EAAC,CAAE;IACnCgH,eAAe;IACfoC,KAAK,EAAE,IAAAQ,gCAAe,EAACD,OAAiB;EAC1C,CAAC;EAED,IAAID,SAAS,CAACG,OAAO,EAAE;IACrB,OAAO,IAAAC,wBAAW,EAACJ,SAAS,CAACG,OAAO,EAAG5C,cAAc,EAAE;MAAE8C,KAAK,EAAE;IAAS,CAAC,CAAC;EAC7E;EAEA,OAAO,IAAAC,uCAAqB,EAACN,SAAS,CAACO,KAAK,EAAEhD,cAAc,CAAC;AAC/D;AAEO,SAASiD,oBAAoBA,CAClChH,OAAgC,EACf;EAAA,IAAAiH,qBAAA;EACjB,MAAMlD,cAAc,GAAG,IAAAjH,sCAA6B,EAAC,CAAC;EAEtD,OAAO;IACLoK,GAAG,GAAAD,qBAAA,GAAElD,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEoD,WAAW,cAAAF,qBAAA,cAAAA,qBAAA,GAAIlD,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEmD,GAAG;IACvDE,QAAQ,EAAE,IAAArE,YAAI,EAACqE,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAChE,GAAG,IAAArE,YAAI,EAACgB,cAAc,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzCmC,KAAK,EAAE,IAAAQ,gCAAe,EAAC1G,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEyG,OAAiB;EACnD,CAAC;AACH","ignoreList":[]}
|
|
@@ -39,8 +39,9 @@ function setupRootRuntimeContext(bricks, runtimeContext, shallow) {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
const transpiledSlots = (0, _Renderer.childrenToSlots)(brick.children, brick.slots);
|
|
42
|
-
for (const slotConf of Object.values(transpiledSlots
|
|
43
|
-
for (const brick of slotConf.bricks
|
|
42
|
+
for (const slotConf of Object.values(transpiledSlots !== null && transpiledSlots !== void 0 ? transpiledSlots : {})) {
|
|
43
|
+
for (const brick of (_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []) {
|
|
44
|
+
var _slotConf$bricks;
|
|
44
45
|
setupBrick(brick, inUseBrick);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupRootRuntimeContext.js","names":["_general","require","_secret_internals","_Renderer","setupRootRuntimeContext","bricks","runtimeContext","shallow","walk","props","isObject","Array","isArray","map","key","value","Object","entries","forEach","v","setupBrick","brick","inUseBrick","forceRecursive","symbolForRootRuntimeContext","properties","transpiledSlots","childrenToSlots","children","slots","slotConf","values"],"sources":["../../../src/internal/setupRootRuntimeContext.ts"],"sourcesContent":["import { isObject } from \"@next-core/utils/general\";\nimport type {\n BrickConf,\n UseBrickSlotsConf,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport {\n RuntimeContext,\n RuntimeUseBrickConfWithRootSymbols,\n symbolForRootRuntimeContext,\n} from \"./secret_internals.js\";\nimport { childrenToSlots } from \"./Renderer.js\";\n\nexport function setupRootRuntimeContext(\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n shallow?: boolean\n) {\n function walk(props: unknown) {\n if (!isObject(props) || typeof props === \"function\") {\n return;\n }\n\n if (Array.isArray(props)) {\n props.map(walk);\n return;\n }\n\n for (const [key, value] of Object.entries(props)) {\n if (isObject(value) && key === \"useBrick\") {\n if (Array.isArray(value)) {\n value.forEach((v) => setupBrick(v, true));\n } else {\n setupBrick(\n value as UseSingleBrickConf as RuntimeUseBrickConfWithRootSymbols,\n true,\n // For inside useBrick, we always need to setup recursively.\n true\n );\n }\n } else {\n walk(value);\n }\n }\n }\n\n function setupBrick(\n brick: BrickConf,\n inUseBrick?: boolean,\n forceRecursive?: boolean\n ) {\n if (inUseBrick) {\n (brick as RuntimeUseBrickConfWithRootSymbols)[\n symbolForRootRuntimeContext\n ] = runtimeContext;\n }\n\n walk(brick.properties);\n\n if (shallow && !forceRecursive) {\n return;\n }\n\n const transpiledSlots = childrenToSlots(brick.children, brick.slots) as\n | UseBrickSlotsConf\n | undefined;\n\n for (const slotConf of Object.values(transpiledSlots ?? {})) {\n for (const brick of slotConf.bricks ?? []) {\n setupBrick(brick, inUseBrick);\n }\n }\n }\n\n for (const brick of bricks) {\n setupBrick(brick);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,iBAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAF,OAAA;AAEO,SAASG,uBAAuBA,CACrCC,MAAmB,EACnBC,cAA8B,EAC9BC,OAAiB,EACjB;EACA,SAASC,IAAIA,CAACC,KAAc,EAAE;IAC5B,IAAI,CAAC,IAAAC,iBAAQ,EAACD,KAAK,CAAC,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MACnD;IACF;IAEA,IAAIE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;MACxBA,KAAK,CAACI,GAAG,CAACL,IAAI,CAAC;MACf;IACF;IAEA,KAAK,MAAM,CAACM,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACR,KAAK,CAAC,EAAE;MAChD,IAAI,IAAAC,iBAAQ,EAACK,KAAK,CAAC,IAAID,GAAG,KAAK,UAAU,EAAE;QACzC,IAAIH,KAAK,CAACC,OAAO,CAACG,KAAK,CAAC,EAAE;UACxBA,KAAK,CAACG,OAAO,CAAEC,CAAC,IAAKC,UAAU,CAACD,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC,MAAM;UACLC,UAAU,CACRL,KAAK,EACL,IAAI;UACJ;UACA,IACF,CAAC;QACH;MACF,CAAC,MAAM;QACLP,IAAI,CAACO,KAAK,CAAC;MACb;IACF;EACF;EAEA,SAASK,UAAUA,CACjBC,KAAgB,EAChBC,UAAoB,EACpBC,cAAwB,EACxB;IACA,IAAID,UAAU,EAAE;MACbD,KAAK,CACJG,6CAA2B,CAC5B,GAAGlB,cAAc;IACpB;IAEAE,IAAI,CAACa,KAAK,CAACI,UAAU,CAAC;IAEtB,IAAIlB,OAAO,IAAI,CAACgB,cAAc,EAAE;MAC9B;IACF;IAEA,MAAMG,eAAe,GAAG,IAAAC,yBAAe,EAACN,KAAK,CAACO,QAAQ,EAAEP,KAAK,CAACQ,KAAK,CAEtD;IAEb,KAAK,MAAMC,QAAQ,IAAId,MAAM,CAACe,MAAM,CAACL,eAAe,
|
|
1
|
+
{"version":3,"file":"setupRootRuntimeContext.js","names":["_general","require","_secret_internals","_Renderer","setupRootRuntimeContext","bricks","runtimeContext","shallow","walk","props","isObject","Array","isArray","map","key","value","Object","entries","forEach","v","setupBrick","brick","inUseBrick","forceRecursive","symbolForRootRuntimeContext","properties","transpiledSlots","childrenToSlots","children","slots","slotConf","values","_slotConf$bricks"],"sources":["../../../src/internal/setupRootRuntimeContext.ts"],"sourcesContent":["import { isObject } from \"@next-core/utils/general\";\nimport type {\n BrickConf,\n UseBrickSlotsConf,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport {\n RuntimeContext,\n RuntimeUseBrickConfWithRootSymbols,\n symbolForRootRuntimeContext,\n} from \"./secret_internals.js\";\nimport { childrenToSlots } from \"./Renderer.js\";\n\nexport function setupRootRuntimeContext(\n bricks: BrickConf[],\n runtimeContext: RuntimeContext,\n shallow?: boolean\n) {\n function walk(props: unknown) {\n if (!isObject(props) || typeof props === \"function\") {\n return;\n }\n\n if (Array.isArray(props)) {\n props.map(walk);\n return;\n }\n\n for (const [key, value] of Object.entries(props)) {\n if (isObject(value) && key === \"useBrick\") {\n if (Array.isArray(value)) {\n value.forEach((v) => setupBrick(v, true));\n } else {\n setupBrick(\n value as UseSingleBrickConf as RuntimeUseBrickConfWithRootSymbols,\n true,\n // For inside useBrick, we always need to setup recursively.\n true\n );\n }\n } else {\n walk(value);\n }\n }\n }\n\n function setupBrick(\n brick: BrickConf,\n inUseBrick?: boolean,\n forceRecursive?: boolean\n ) {\n if (inUseBrick) {\n (brick as RuntimeUseBrickConfWithRootSymbols)[\n symbolForRootRuntimeContext\n ] = runtimeContext;\n }\n\n walk(brick.properties);\n\n if (shallow && !forceRecursive) {\n return;\n }\n\n const transpiledSlots = childrenToSlots(brick.children, brick.slots) as\n | UseBrickSlotsConf\n | undefined;\n\n for (const slotConf of Object.values(transpiledSlots ?? {})) {\n for (const brick of slotConf.bricks ?? []) {\n setupBrick(brick, inUseBrick);\n }\n }\n }\n\n for (const brick of bricks) {\n setupBrick(brick);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,iBAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAF,OAAA;AAEO,SAASG,uBAAuBA,CACrCC,MAAmB,EACnBC,cAA8B,EAC9BC,OAAiB,EACjB;EACA,SAASC,IAAIA,CAACC,KAAc,EAAE;IAC5B,IAAI,CAAC,IAAAC,iBAAQ,EAACD,KAAK,CAAC,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MACnD;IACF;IAEA,IAAIE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;MACxBA,KAAK,CAACI,GAAG,CAACL,IAAI,CAAC;MACf;IACF;IAEA,KAAK,MAAM,CAACM,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACR,KAAK,CAAC,EAAE;MAChD,IAAI,IAAAC,iBAAQ,EAACK,KAAK,CAAC,IAAID,GAAG,KAAK,UAAU,EAAE;QACzC,IAAIH,KAAK,CAACC,OAAO,CAACG,KAAK,CAAC,EAAE;UACxBA,KAAK,CAACG,OAAO,CAAEC,CAAC,IAAKC,UAAU,CAACD,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC,MAAM;UACLC,UAAU,CACRL,KAAK,EACL,IAAI;UACJ;UACA,IACF,CAAC;QACH;MACF,CAAC,MAAM;QACLP,IAAI,CAACO,KAAK,CAAC;MACb;IACF;EACF;EAEA,SAASK,UAAUA,CACjBC,KAAgB,EAChBC,UAAoB,EACpBC,cAAwB,EACxB;IACA,IAAID,UAAU,EAAE;MACbD,KAAK,CACJG,6CAA2B,CAC5B,GAAGlB,cAAc;IACpB;IAEAE,IAAI,CAACa,KAAK,CAACI,UAAU,CAAC;IAEtB,IAAIlB,OAAO,IAAI,CAACgB,cAAc,EAAE;MAC9B;IACF;IAEA,MAAMG,eAAe,GAAG,IAAAC,yBAAe,EAACN,KAAK,CAACO,QAAQ,EAAEP,KAAK,CAACQ,KAAK,CAEtD;IAEb,KAAK,MAAMC,QAAQ,IAAId,MAAM,CAACe,MAAM,CAACL,eAAe,aAAfA,eAAe,cAAfA,eAAe,GAAI,CAAC,CAAC,CAAC,EAAE;MAC3D,KAAK,MAAML,KAAK,KAAAW,gBAAA,GAAIF,QAAQ,CAACzB,MAAM,cAAA2B,gBAAA,cAAAA,gBAAA,GAAI,EAAE,EAAE;QAAA,IAAAA,gBAAA;QACzCZ,UAAU,CAACC,KAAK,EAAEC,UAAU,CAAC;MAC/B;IACF;EACF;EAEA,KAAK,MAAMD,KAAK,IAAIhB,MAAM,EAAE;IAC1Be,UAAU,CAACC,KAAK,CAAC;EACnB;AACF","ignoreList":[]}
|
package/dist/cjs/setWatermark.js
CHANGED
|
@@ -11,18 +11,18 @@ var _lodash = require("lodash");
|
|
|
11
11
|
let brick;
|
|
12
12
|
const WATEMARK_BRICKNAME = exports.WATEMARK_BRICKNAME = "basic.show-watermark";
|
|
13
13
|
function setWatermark() {
|
|
14
|
-
var _window$APP_ROOT, _window$APP_ROOT2, _hooks$auth, _watermarkConfig$flag, _watermarkConfig$flag2;
|
|
14
|
+
var _window$APP_ROOT, _window$APP_ROOT2, _username, _hooks$auth, _settings$watermarkCo, _watermarkConfig$cont, _watermarkConfig$flag, _watermarkConfig$flag2;
|
|
15
15
|
const flags = (0, _Runtime.getRuntime)().getFeatureFlags();
|
|
16
16
|
const settings = (0, _Runtime.getRuntime)().getMiscSettings();
|
|
17
17
|
if (!flags["show-watermark"]) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
const isDeveloper = ((_window$APP_ROOT = window.APP_ROOT) === null || _window$APP_ROOT === void 0 || (_window$APP_ROOT = _window$APP_ROOT.match(/versions\/([^/]+)\//)) === null || _window$APP_ROOT === void 0 ? void 0 : _window$APP_ROOT[1]) === "0.0.0" || ((_window$APP_ROOT2 = window.APP_ROOT) === null || _window$APP_ROOT2 === void 0 || (_window$APP_ROOT2 = _window$APP_ROOT2.match(/micro-apps\/(?:v2|v3)\/[^/]+\/([^/]+)/)) === null || _window$APP_ROOT2 === void 0 ? void 0 : _window$APP_ROOT2[1]) === "0.0.0";
|
|
21
|
-
const username = (_Runtime.hooks === null || _Runtime.hooks === void 0 || (_hooks$auth = _Runtime.hooks.auth) === null || _hooks$auth === void 0 || (_hooks$auth = _hooks$auth.getAuth()) === null || _hooks$auth === void 0 ? void 0 : _hooks$auth.username)
|
|
22
|
-
const watermarkConfig = settings.watermarkConfig
|
|
21
|
+
const username = (_username = _Runtime.hooks === null || _Runtime.hooks === void 0 || (_hooks$auth = _Runtime.hooks.auth) === null || _hooks$auth === void 0 || (_hooks$auth = _hooks$auth.getAuth()) === null || _hooks$auth === void 0 ? void 0 : _hooks$auth.username) !== null && _username !== void 0 ? _username : "";
|
|
22
|
+
const watermarkConfig = (_settings$watermarkCo = settings.watermarkConfig) !== null && _settings$watermarkCo !== void 0 ? _settings$watermarkCo : {
|
|
23
23
|
flags: {}
|
|
24
24
|
};
|
|
25
|
-
const content = [...(typeof watermarkConfig.content === "string" ? [watermarkConfig.content] : watermarkConfig.content
|
|
25
|
+
const content = [...(typeof watermarkConfig.content === "string" ? [watermarkConfig.content] : (_watermarkConfig$cont = watermarkConfig.content) !== null && _watermarkConfig$cont !== void 0 ? _watermarkConfig$cont : []), (_watermarkConfig$flag = watermarkConfig.flags) !== null && _watermarkConfig$flag !== void 0 && _watermarkConfig$flag["show-development"] && isDeveloper ? "Development" : "", (_watermarkConfig$flag2 = watermarkConfig.flags) !== null && _watermarkConfig$flag2 !== void 0 && _watermarkConfig$flag2["show-user"] ? username : ""].filter(Boolean);
|
|
26
26
|
|
|
27
27
|
// Do not call showWatermark if there is no content
|
|
28
28
|
if (content.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setWatermark.js","names":["_loader","require","_Runtime","_lodash","brick","WATEMARK_BRICKNAME","exports","setWatermark","_window$APP_ROOT","_window$APP_ROOT2","_hooks$auth","_watermarkConfig$flag","_watermarkConfig$flag2","flags","getRuntime","getFeatureFlags","settings","getMiscSettings","isDeveloper","window","APP_ROOT","match","username","hooks","auth","getAuth","watermarkConfig","content","filter","Boolean","length","defaultProps","zIndex","width","font","fontSize","gap","omit","resolve","loadBricksImperatively","getBrickPackages","then","document","createElement","error","console"],"sources":["../../src/setWatermark.ts"],"sourcesContent":["import { loadBricksImperatively } from \"@next-core/loader\";\nimport { getBrickPackages, getRuntime, hooks } from \"./internal/Runtime.js\";\nimport { omit } from \"lodash\";\n\ninterface WaterMarkProps {\n container?: HTMLElement;\n content?: string | string[];\n zIndex?: number;\n rotate?: number;\n width?: number;\n height?: number;\n image?: string;\n font?: {\n color?: CanvasFillStrokeStyles[\"fillStyle\"];\n fontSize?: number | string;\n fontWeight?: \"normal\" | \"light\" | \"weight\" | number;\n fontStyle?: \"none\" | \"normal\" | \"italic\" | \"oblique\";\n fontFamily?: string;\n textAlign?: CanvasTextAlign;\n };\n style?: React.CSSProperties;\n gap?: [number, number];\n offset?: [number, number];\n}\n\nlet brick: {\n resolve(options: WaterMarkProps): void;\n};\n\nexport const WATEMARK_BRICKNAME = \"basic.show-watermark\";\n\nexport function setWatermark() {\n const flags = getRuntime().getFeatureFlags();\n const settings = getRuntime().getMiscSettings();\n if (!flags[\"show-watermark\"]) {\n return;\n }\n const isDeveloper =\n window.APP_ROOT?.match(/versions\\/([^/]+)\\//)?.[1] === \"0.0.0\" ||\n window.APP_ROOT?.match(/micro-apps\\/(?:v2|v3)\\/[^/]+\\/([^/]+)/)?.[1] ===\n \"0.0.0\";\n const username =\n (hooks?.auth?.getAuth() as Record<string, any>)?.username ?? \"\";\n const watermarkConfig = (settings.watermarkConfig ?? {\n flags: {},\n }) as WaterMarkProps & {\n flags: {\n \"show-development\"?: boolean;\n \"show-user\"?: boolean;\n };\n };\n\n const content = [\n ...(typeof watermarkConfig.content === \"string\"\n ? [watermarkConfig.content]\n : watermarkConfig.content ?? []),\n watermarkConfig.flags?.[\"show-development\"] && isDeveloper\n ? \"Development\"\n : \"\",\n watermarkConfig.flags?.[\"show-user\"] ? username : \"\",\n ].filter(Boolean);\n\n // Do not call showWatermark if there is no content\n if (content.length === 0) {\n return;\n }\n\n const defaultProps: WaterMarkProps = {\n content,\n zIndex: 1001,\n width: 200,\n font: {\n fontSize: 28,\n },\n gap: [190, 190],\n ...omit(watermarkConfig, [\"content\", \"flags\"]),\n };\n if (brick) {\n brick.resolve(defaultProps);\n } else {\n loadBricksImperatively([WATEMARK_BRICKNAME], getBrickPackages()).then(\n () => {\n brick = document.createElement(WATEMARK_BRICKNAME) as any;\n\n brick.resolve(defaultProps);\n },\n // istanbul ignore next\n (error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Load watermark service failed:\", error);\n }\n );\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAuBA,IAAIG,KAEH;AAEM,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,sBAAsB;AAEjD,SAASE,YAAYA,CAAA,EAAG;EAAA,IAAAC,gBAAA,EAAAC,iBAAA,EAAAC,WAAA,EAAAC,qBAAA,EAAAC,sBAAA;EAC7B,MAAMC,KAAK,GAAG,IAAAC,mBAAU,EAAC,CAAC,CAACC,eAAe,CAAC,CAAC;EAC5C,MAAMC,QAAQ,GAAG,IAAAF,mBAAU,EAAC,CAAC,CAACG,eAAe,CAAC,CAAC;EAC/C,IAAI,CAACJ,KAAK,CAAC,gBAAgB,CAAC,EAAE;IAC5B;EACF;EACA,MAAMK,WAAW,GACf,
|
|
1
|
+
{"version":3,"file":"setWatermark.js","names":["_loader","require","_Runtime","_lodash","brick","WATEMARK_BRICKNAME","exports","setWatermark","_window$APP_ROOT","_window$APP_ROOT2","_username","_hooks$auth","_settings$watermarkCo","_watermarkConfig$cont","_watermarkConfig$flag","_watermarkConfig$flag2","flags","getRuntime","getFeatureFlags","settings","getMiscSettings","isDeveloper","window","APP_ROOT","match","username","hooks","auth","getAuth","watermarkConfig","content","filter","Boolean","length","defaultProps","zIndex","width","font","fontSize","gap","omit","resolve","loadBricksImperatively","getBrickPackages","then","document","createElement","error","console"],"sources":["../../src/setWatermark.ts"],"sourcesContent":["import { loadBricksImperatively } from \"@next-core/loader\";\nimport { getBrickPackages, getRuntime, hooks } from \"./internal/Runtime.js\";\nimport { omit } from \"lodash\";\n\ninterface WaterMarkProps {\n container?: HTMLElement;\n content?: string | string[];\n zIndex?: number;\n rotate?: number;\n width?: number;\n height?: number;\n image?: string;\n font?: {\n color?: CanvasFillStrokeStyles[\"fillStyle\"];\n fontSize?: number | string;\n fontWeight?: \"normal\" | \"light\" | \"weight\" | number;\n fontStyle?: \"none\" | \"normal\" | \"italic\" | \"oblique\";\n fontFamily?: string;\n textAlign?: CanvasTextAlign;\n };\n style?: React.CSSProperties;\n gap?: [number, number];\n offset?: [number, number];\n}\n\nlet brick: {\n resolve(options: WaterMarkProps): void;\n};\n\nexport const WATEMARK_BRICKNAME = \"basic.show-watermark\";\n\nexport function setWatermark() {\n const flags = getRuntime().getFeatureFlags();\n const settings = getRuntime().getMiscSettings();\n if (!flags[\"show-watermark\"]) {\n return;\n }\n const isDeveloper =\n window.APP_ROOT?.match(/versions\\/([^/]+)\\//)?.[1] === \"0.0.0\" ||\n window.APP_ROOT?.match(/micro-apps\\/(?:v2|v3)\\/[^/]+\\/([^/]+)/)?.[1] ===\n \"0.0.0\";\n const username =\n (hooks?.auth?.getAuth() as Record<string, any>)?.username ?? \"\";\n const watermarkConfig = (settings.watermarkConfig ?? {\n flags: {},\n }) as WaterMarkProps & {\n flags: {\n \"show-development\"?: boolean;\n \"show-user\"?: boolean;\n };\n };\n\n const content = [\n ...(typeof watermarkConfig.content === \"string\"\n ? [watermarkConfig.content]\n : watermarkConfig.content ?? []),\n watermarkConfig.flags?.[\"show-development\"] && isDeveloper\n ? \"Development\"\n : \"\",\n watermarkConfig.flags?.[\"show-user\"] ? username : \"\",\n ].filter(Boolean);\n\n // Do not call showWatermark if there is no content\n if (content.length === 0) {\n return;\n }\n\n const defaultProps: WaterMarkProps = {\n content,\n zIndex: 1001,\n width: 200,\n font: {\n fontSize: 28,\n },\n gap: [190, 190],\n ...omit(watermarkConfig, [\"content\", \"flags\"]),\n };\n if (brick) {\n brick.resolve(defaultProps);\n } else {\n loadBricksImperatively([WATEMARK_BRICKNAME], getBrickPackages()).then(\n () => {\n brick = document.createElement(WATEMARK_BRICKNAME) as any;\n\n brick.resolve(defaultProps);\n },\n // istanbul ignore next\n (error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Load watermark service failed:\", error);\n }\n );\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAuBA,IAAIG,KAEH;AAEM,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,sBAAsB;AAEjD,SAASE,YAAYA,CAAA,EAAG;EAAA,IAAAC,gBAAA,EAAAC,iBAAA,EAAAC,SAAA,EAAAC,WAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,sBAAA;EAC7B,MAAMC,KAAK,GAAG,IAAAC,mBAAU,EAAC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A,CAAwB,kBAAkB,CAAC,IAAIO,WAAW,GACtD,aAAa,GACb,EAAE,EACN,CAAAN,sBAAA,GAAAc,eAAe,CAACb,KAAK,cAAAD,sBAAA,eAArBA,sBAAA,CAAwB,WAAW,CAAC,GAAGU,QAAQ,GAAG,EAAE,CACrD,CAACM,MAAM,CAACC,OAAO,CAAC;;EAEjB;EACA,IAAIF,OAAO,CAACG,MAAM,KAAK,CAAC,EAAE;IACxB;EACF;EAEA,MAAMC,YAA4B,GAAG;IACnCJ,OAAO;IACPK,MAAM,EAAE,IAAI;IACZC,KAAK,EAAE,GAAG;IACVC,IAAI,EAAE;MACJC,QAAQ,EAAE;IACZ,CAAC;IACDC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;IACf,GAAG,IAAAC,YAAI,EAACX,eAAe,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC;EAC/C,CAAC;EACD,IAAIzB,KAAK,EAAE;IACTA,KAAK,CAACqC,OAAO,CAACP,YAAY,CAAC;EAC7B,CAAC,MAAM;IACL,IAAAQ,8BAAsB,EAAC,CAACrC,kBAAkB,CAAC,EAAE,IAAAsC,yBAAgB,EAAC,CAAC,CAAC,CAACC,IAAI,CACnE,MAAM;MACJxC,KAAK,GAAGyC,QAAQ,CAACC,aAAa,CAACzC,kBAAkB,CAAQ;MAEzDD,KAAK,CAACqC,OAAO,CAACP,YAAY,CAAC;IAC7B,CAAC;IACD;IACCa,KAAc,IAAK;MAClB;MACAC,OAAO,CAACD,KAAK,CAAC,gCAAgC,EAAEA,KAAK,CAAC;IACxD,CACF,CAAC;EACH;AACF","ignoreList":[]}
|
package/dist/cjs/themeAndMode.js
CHANGED
|
@@ -51,6 +51,7 @@ function batchSetAppsLocalTheme(appsTheme) {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
function getLocalAppsTheme() {
|
|
54
|
+
var _result;
|
|
54
55
|
let result;
|
|
55
56
|
try {
|
|
56
57
|
result = storage.getItem(LOCAL_STORAGE_APPS_THEME_KEY);
|
|
@@ -58,7 +59,7 @@ function getLocalAppsTheme() {
|
|
|
58
59
|
// eslint-disable-next-line no-console
|
|
59
60
|
console.error("JSON parse error inside `getLocalAppsTheme()`");
|
|
60
61
|
}
|
|
61
|
-
return result
|
|
62
|
+
return (_result = result) !== null && _result !== void 0 ? _result : {};
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
// Modes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeAndMode.js","names":["_general","require","theme","storage","JsonStorage","localStorage","LOCAL_STORAGE_APPS_THEME_KEY","setTheme","value","Error","getTheme","getCurrentTheme","document","documentElement","dataset","applyTheme","window","dispatchEvent","CustomEvent","detail","batchSetAppsLocalTheme","appsTheme","setItem","getLocalAppsTheme","result","getItem","console","error","mode","setMode","getMode","getCurrentMode","applyMode","getCssPropertyValue","name","el","_window$getComputedSt","getComputedStyle","getPropertyValue"],"sources":["../../src/themeAndMode.ts"],"sourcesContent":["import type { SiteMode, SiteTheme } from \"@next-core/types\";\nimport { JsonStorage } from \"@next-core/utils/general\";\n\ninterface AppThemes {\n [appId: string]: SiteTheme;\n}\n\n// Themes.\nlet theme: SiteTheme = \"light\";\nconst storage = new JsonStorage<Record<string, AppThemes>>(localStorage);\nconst LOCAL_STORAGE_APPS_THEME_KEY = \"apps-theme\";\n\nexport function setTheme(value: SiteTheme): void {\n if (value !== \"dark\" && value !== \"light\" && value !== \"dark-v2\") {\n throw new Error(`Unsupported theme: ${value}`);\n }\n theme = value;\n}\n\nexport function getTheme(): SiteTheme {\n return theme;\n}\n\nexport function getCurrentTheme(): SiteTheme {\n return document.documentElement.dataset.theme as SiteTheme;\n}\n\nexport function applyTheme(value?: SiteTheme): void {\n if (value) {\n setTheme(value);\n } else {\n value = getTheme();\n }\n if (value !== getCurrentTheme()) {\n document.documentElement.dataset.theme = value;\n window.dispatchEvent(\n new CustomEvent<SiteTheme>(\"theme.change\", {\n detail: value,\n })\n );\n }\n}\n\nexport function batchSetAppsLocalTheme(appsTheme: AppThemes): void {\n storage.setItem(LOCAL_STORAGE_APPS_THEME_KEY, {\n ...getLocalAppsTheme(),\n ...appsTheme,\n });\n}\n\nexport function getLocalAppsTheme(): AppThemes {\n let result: AppThemes | undefined;\n try {\n result = storage.getItem(LOCAL_STORAGE_APPS_THEME_KEY);\n } catch {\n // eslint-disable-next-line no-console\n console.error(\"JSON parse error inside `getLocalAppsTheme()`\");\n }\n\n return result ?? {};\n}\n\n// Modes.\nlet mode: SiteMode = \"default\";\n\nexport function setMode(value: SiteMode): void {\n if (value !== \"dashboard\" && value !== \"default\") {\n throw new Error(`Unsupported mode: ${value}`);\n }\n mode = value;\n}\n\nexport function getMode(): SiteMode {\n return mode;\n}\n\nexport function getCurrentMode(): SiteMode {\n return document.documentElement.dataset.mode as SiteMode;\n}\n\nexport function applyMode(value?: SiteMode): void {\n if (value) {\n setMode(value);\n } else {\n value = getMode();\n }\n if (value !== getCurrentMode()) {\n document.documentElement.dataset.mode = value;\n window.dispatchEvent(\n new CustomEvent<SiteMode>(\"mode.change\", {\n detail: value,\n })\n );\n }\n}\n\nexport function getCssPropertyValue(\n name: string,\n el = document.documentElement\n): string {\n if (!el) return \"\";\n return window.getComputedStyle(el)?.getPropertyValue(name) || \"\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMA;AACA,IAAIC,KAAgB,GAAG,OAAO;AAC9B,MAAMC,OAAO,GAAG,IAAIC,oBAAW,CAA4BC,YAAY,CAAC;AACxE,MAAMC,4BAA4B,GAAG,YAAY;AAE1C,SAASC,QAAQA,CAACC,KAAgB,EAAQ;EAC/C,IAAIA,KAAK,KAAK,MAAM,IAAIA,KAAK,KAAK,OAAO,IAAIA,KAAK,KAAK,SAAS,EAAE;IAChE,MAAM,IAAIC,KAAK,CAAC,sBAAsBD,KAAK,EAAE,CAAC;EAChD;EACAN,KAAK,GAAGM,KAAK;AACf;AAEO,SAASE,QAAQA,CAAA,EAAc;EACpC,OAAOR,KAAK;AACd;AAEO,SAASS,eAAeA,CAAA,EAAc;EAC3C,OAAOC,QAAQ,CAACC,eAAe,CAACC,OAAO,CAACZ,KAAK;AAC/C;AAEO,SAASa,UAAUA,CAACP,KAAiB,EAAQ;EAClD,IAAIA,KAAK,EAAE;IACTD,QAAQ,CAACC,KAAK,CAAC;EACjB,CAAC,MAAM;IACLA,KAAK,GAAGE,QAAQ,CAAC,CAAC;EACpB;EACA,IAAIF,KAAK,KAAKG,eAAe,CAAC,CAAC,EAAE;IAC/BC,QAAQ,CAACC,eAAe,CAACC,OAAO,CAACZ,KAAK,GAAGM,KAAK;IAC9CQ,MAAM,CAACC,aAAa,CAClB,IAAIC,WAAW,CAAY,cAAc,EAAE;MACzCC,MAAM,EAAEX;IACV,CAAC,CACH,CAAC;EACH;AACF;AAEO,SAASY,sBAAsBA,CAACC,SAAoB,EAAQ;EACjElB,OAAO,CAACmB,OAAO,CAAChB,4BAA4B,EAAE;IAC5C,GAAGiB,iBAAiB,CAAC,CAAC;IACtB,GAAGF;EACL,CAAC,CAAC;AACJ;AAEO,SAASE,iBAAiBA,CAAA,EAAc;EAC7C,IAAIC,MAA6B;EACjC,IAAI;IACFA,MAAM,
|
|
1
|
+
{"version":3,"file":"themeAndMode.js","names":["_general","require","theme","storage","JsonStorage","localStorage","LOCAL_STORAGE_APPS_THEME_KEY","setTheme","value","Error","getTheme","getCurrentTheme","document","documentElement","dataset","applyTheme","window","dispatchEvent","CustomEvent","detail","batchSetAppsLocalTheme","appsTheme","setItem","getLocalAppsTheme","_result","result","getItem","console","error","mode","setMode","getMode","getCurrentMode","applyMode","getCssPropertyValue","name","el","_window$getComputedSt","getComputedStyle","getPropertyValue"],"sources":["../../src/themeAndMode.ts"],"sourcesContent":["import type { SiteMode, SiteTheme } from \"@next-core/types\";\nimport { JsonStorage } from \"@next-core/utils/general\";\n\ninterface AppThemes {\n [appId: string]: SiteTheme;\n}\n\n// Themes.\nlet theme: SiteTheme = \"light\";\nconst storage = new JsonStorage<Record<string, AppThemes>>(localStorage);\nconst LOCAL_STORAGE_APPS_THEME_KEY = \"apps-theme\";\n\nexport function setTheme(value: SiteTheme): void {\n if (value !== \"dark\" && value !== \"light\" && value !== \"dark-v2\") {\n throw new Error(`Unsupported theme: ${value}`);\n }\n theme = value;\n}\n\nexport function getTheme(): SiteTheme {\n return theme;\n}\n\nexport function getCurrentTheme(): SiteTheme {\n return document.documentElement.dataset.theme as SiteTheme;\n}\n\nexport function applyTheme(value?: SiteTheme): void {\n if (value) {\n setTheme(value);\n } else {\n value = getTheme();\n }\n if (value !== getCurrentTheme()) {\n document.documentElement.dataset.theme = value;\n window.dispatchEvent(\n new CustomEvent<SiteTheme>(\"theme.change\", {\n detail: value,\n })\n );\n }\n}\n\nexport function batchSetAppsLocalTheme(appsTheme: AppThemes): void {\n storage.setItem(LOCAL_STORAGE_APPS_THEME_KEY, {\n ...getLocalAppsTheme(),\n ...appsTheme,\n });\n}\n\nexport function getLocalAppsTheme(): AppThemes {\n let result: AppThemes | undefined;\n try {\n result = storage.getItem(LOCAL_STORAGE_APPS_THEME_KEY);\n } catch {\n // eslint-disable-next-line no-console\n console.error(\"JSON parse error inside `getLocalAppsTheme()`\");\n }\n\n return result ?? {};\n}\n\n// Modes.\nlet mode: SiteMode = \"default\";\n\nexport function setMode(value: SiteMode): void {\n if (value !== \"dashboard\" && value !== \"default\") {\n throw new Error(`Unsupported mode: ${value}`);\n }\n mode = value;\n}\n\nexport function getMode(): SiteMode {\n return mode;\n}\n\nexport function getCurrentMode(): SiteMode {\n return document.documentElement.dataset.mode as SiteMode;\n}\n\nexport function applyMode(value?: SiteMode): void {\n if (value) {\n setMode(value);\n } else {\n value = getMode();\n }\n if (value !== getCurrentMode()) {\n document.documentElement.dataset.mode = value;\n window.dispatchEvent(\n new CustomEvent<SiteMode>(\"mode.change\", {\n detail: value,\n })\n );\n }\n}\n\nexport function getCssPropertyValue(\n name: string,\n el = document.documentElement\n): string {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AAM,CAACsB,gBAAgB,CAACF,EAAE,CAAC,cAAAC,qBAAA,uBAA3BA,qBAAA,CAA6BE,gBAAgB,CAACJ,IAAI,CAAC,KAAI,EAAE;AAClE","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/runtime",
|
|
3
|
-
"version": "1.58.
|
|
3
|
+
"version": "1.58.3",
|
|
4
4
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/runtime",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"repository": {
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@next-core/color-theme": "^0.4.8",
|
|
48
|
-
"@next-core/cook": "^2.5.
|
|
49
|
-
"@next-core/http": "^1.2.
|
|
50
|
-
"@next-core/i18n": "^1.0.
|
|
51
|
-
"@next-core/inject": "^1.0.
|
|
52
|
-
"@next-core/loader": "^1.6.
|
|
53
|
-
"@next-core/supply": "^2.3.
|
|
48
|
+
"@next-core/cook": "^2.5.4",
|
|
49
|
+
"@next-core/http": "^1.2.9",
|
|
50
|
+
"@next-core/i18n": "^1.0.71",
|
|
51
|
+
"@next-core/inject": "^1.0.49",
|
|
52
|
+
"@next-core/loader": "^1.6.12",
|
|
53
|
+
"@next-core/supply": "^2.3.1",
|
|
54
54
|
"@next-core/types": "^1.14.0",
|
|
55
55
|
"@next-core/utils": "^1.7.28",
|
|
56
56
|
"@ungap/event-target": "^0.2.4",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"@microsoft/api-extractor": "^7.47.9",
|
|
65
65
|
"@next-api-sdk/api-gateway-sdk": "^1.1.0",
|
|
66
66
|
"@next-api-sdk/micro-app-sdk": "^1.2.1",
|
|
67
|
-
"@next-core/build-next-libs": "^1.0.
|
|
67
|
+
"@next-core/build-next-libs": "^1.0.21",
|
|
68
68
|
"@next-core/test-next": "^1.1.7"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "a66abb00c5ef6e134f4b864bee87d54b1ddb136b"
|
|
71
71
|
}
|