@next-core/runtime 1.2.2 → 1.3.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.
Files changed (45) hide show
  1. package/dist/cjs/Dialog.js +49 -0
  2. package/dist/cjs/Dialog.js.map +1 -0
  3. package/dist/cjs/Notification.js +30 -0
  4. package/dist/cjs/Notification.js.map +1 -0
  5. package/dist/cjs/handleHttpError.js +33 -18
  6. package/dist/cjs/handleHttpError.js.map +1 -1
  7. package/dist/cjs/index.js +17 -1
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/internal/CustomTemplates/utils.js +1 -1
  10. package/dist/cjs/internal/CustomTemplates/utils.js.map +1 -1
  11. package/dist/cjs/internal/Renderer.js +2 -3
  12. package/dist/cjs/internal/Renderer.js.map +1 -1
  13. package/dist/cjs/internal/Runtime.js +7 -1
  14. package/dist/cjs/internal/Runtime.js.map +1 -1
  15. package/dist/cjs/internal/bindListeners.js +7 -2
  16. package/dist/cjs/internal/bindListeners.js.map +1 -1
  17. package/dist/cjs/internal/i18n.js +31 -0
  18. package/dist/cjs/internal/i18n.js.map +1 -0
  19. package/dist/cjs/internal/secret_internals.js +5 -0
  20. package/dist/cjs/internal/secret_internals.js.map +1 -1
  21. package/dist/esm/Dialog.js +40 -0
  22. package/dist/esm/Dialog.js.map +1 -0
  23. package/dist/esm/Notification.js +21 -0
  24. package/dist/esm/Notification.js.map +1 -0
  25. package/dist/esm/handleHttpError.js +32 -17
  26. package/dist/esm/handleHttpError.js.map +1 -1
  27. package/dist/esm/index.js +2 -0
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/internal/CustomTemplates/utils.js +1 -1
  30. package/dist/esm/internal/CustomTemplates/utils.js.map +1 -1
  31. package/dist/esm/internal/Renderer.js +2 -3
  32. package/dist/esm/internal/Renderer.js.map +1 -1
  33. package/dist/esm/internal/Runtime.js +7 -1
  34. package/dist/esm/internal/Runtime.js.map +1 -1
  35. package/dist/esm/internal/bindListeners.js +7 -2
  36. package/dist/esm/internal/bindListeners.js.map +1 -1
  37. package/dist/esm/internal/i18n.js +22 -0
  38. package/dist/esm/internal/i18n.js.map +1 -0
  39. package/dist/esm/internal/secret_internals.js +5 -0
  40. package/dist/esm/internal/secret_internals.js.map +1 -1
  41. package/dist/types/Dialog.d.ts +14 -0
  42. package/dist/types/Notification.d.ts +10 -0
  43. package/dist/types/index.d.ts +2 -0
  44. package/dist/types/internal/i18n.d.ts +14 -0
  45. package/package.json +7 -7
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Dialog = void 0;
8
+ exports.loadDialogService = loadDialogService;
9
+ var __secret_internals = _interopRequireWildcard(require("./internal/secret_internals.js"));
10
+ let brick;
11
+ function show(options) {
12
+ if (brick) {
13
+ brick.resolve(options);
14
+ } else {
15
+ if (options.type === "confirm") {
16
+ if (confirm(options.content)) {
17
+ setTimeout(() => {
18
+ var _options$onOk;
19
+ (_options$onOk = options.onOk) === null || _options$onOk === void 0 ? void 0 : _options$onOk.call(options);
20
+ }, 1);
21
+ } else {
22
+ setTimeout(() => {
23
+ var _options$onCancel;
24
+ (_options$onCancel = options.onCancel) === null || _options$onCancel === void 0 ? void 0 : _options$onCancel.call(options);
25
+ }, 1);
26
+ }
27
+ } else {
28
+ alert(options.content);
29
+ if (options.onOk) {
30
+ setTimeout(() => {
31
+ options.onOk();
32
+ }, 1000);
33
+ }
34
+ }
35
+ }
36
+ }
37
+ function loadDialogService(tagName) {
38
+ __secret_internals.loadBricks([tagName]).then(() => {
39
+ brick = document.createElement(tagName);
40
+ }, error => {
41
+ // eslint-disable-next-line no-console
42
+ console.error("Load dialog service failed:", error);
43
+ });
44
+ }
45
+ const Dialog = Object.freeze({
46
+ show
47
+ });
48
+ exports.Dialog = Dialog;
49
+ //# sourceMappingURL=Dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.js","names":["__secret_internals","_interopRequireWildcard","require","brick","show","options","resolve","type","confirm","content","setTimeout","_options$onOk","onOk","call","_options$onCancel","onCancel","alert","loadDialogService","tagName","loadBricks","then","document","createElement","error","console","Dialog","Object","freeze","exports"],"sources":["../../src/Dialog.ts"],"sourcesContent":["import * as __secret_internals from \"./internal/secret_internals.js\";\n\nlet brick: {\n resolve(options: DialogOptions): void;\n};\n\nfunction show(options: DialogOptions) {\n if (brick) {\n brick.resolve(options);\n } else {\n if (options.type === \"confirm\") {\n if (confirm(options.content)) {\n setTimeout(() => {\n options.onOk?.();\n }, 1);\n } else {\n setTimeout(() => {\n options.onCancel?.();\n }, 1);\n }\n } else {\n alert(options.content);\n if (options.onOk) {\n setTimeout(() => {\n options.onOk!();\n }, 1000);\n }\n }\n }\n}\n\nexport function loadDialogService(tagName: string) {\n __secret_internals.loadBricks([tagName]).then(\n () => {\n brick = document.createElement(tagName) as any;\n },\n (error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Load dialog service failed:\", error);\n }\n );\n}\n\nexport interface DialogOptions {\n type?: \"success\" | \"error\" | \"warn\" | \"info\" | \"confirm\";\n title?: string | null;\n content: string;\n whiteSpace?: string;\n onOk?: () => void;\n onCancel?: () => void;\n}\n\nexport const Dialog = Object.freeze({\n show,\n});\n"],"mappings":";;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAIC,KAEH;AAED,SAASC,IAAIA,CAACC,OAAsB,EAAE;EACpC,IAAIF,KAAK,EAAE;IACTA,KAAK,CAACG,OAAO,CAACD,OAAO,CAAC;EACxB,CAAC,MAAM;IACL,IAAIA,OAAO,CAACE,IAAI,KAAK,SAAS,EAAE;MAC9B,IAAIC,OAAO,CAACH,OAAO,CAACI,OAAO,CAAC,EAAE;QAC5BC,UAAU,CAAC,MAAM;UAAA,IAAAC,aAAA;UACf,CAAAA,aAAA,GAAAN,OAAO,CAACO,IAAI,cAAAD,aAAA,uBAAZA,aAAA,CAAAE,IAAA,CAAAR,OAAO,CAAS;QAClB,CAAC,EAAE,CAAC,CAAC;MACP,CAAC,MAAM;QACLK,UAAU,CAAC,MAAM;UAAA,IAAAI,iBAAA;UACf,CAAAA,iBAAA,GAAAT,OAAO,CAACU,QAAQ,cAAAD,iBAAA,uBAAhBA,iBAAA,CAAAD,IAAA,CAAAR,OAAO,CAAa;QACtB,CAAC,EAAE,CAAC,CAAC;MACP;IACF,CAAC,MAAM;MACLW,KAAK,CAACX,OAAO,CAACI,OAAO,CAAC;MACtB,IAAIJ,OAAO,CAACO,IAAI,EAAE;QAChBF,UAAU,CAAC,MAAM;UACfL,OAAO,CAACO,IAAI,EAAG;QACjB,CAAC,EAAE,IAAI,CAAC;MACV;IACF;EACF;AACF;AAEO,SAASK,iBAAiBA,CAACC,OAAe,EAAE;EACjDlB,kBAAkB,CAACmB,UAAU,CAAC,CAACD,OAAO,CAAC,CAAC,CAACE,IAAI,CAC3C,MAAM;IACJjB,KAAK,GAAGkB,QAAQ,CAACC,aAAa,CAACJ,OAAO,CAAQ;EAChD,CAAC,EACAK,KAAc,IAAK;IAClB;IACAC,OAAO,CAACD,KAAK,CAAC,6BAA6B,EAAEA,KAAK,CAAC;EACrD,CAAC,CACF;AACH;AAWO,MAAME,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;EAClCvB;AACF,CAAC,CAAC;AAACwB,OAAA,CAAAH,MAAA,GAAAA,MAAA"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Notification = void 0;
8
+ exports.loadNotificationService = loadNotificationService;
9
+ var __secret_internals = _interopRequireWildcard(require("./internal/secret_internals.js"));
10
+ let brick;
11
+ function show(options) {
12
+ if (brick) {
13
+ brick.resolve(options);
14
+ } else {
15
+ alert(options.message);
16
+ }
17
+ }
18
+ function loadNotificationService(tagName) {
19
+ __secret_internals.loadBricks([tagName]).then(() => {
20
+ brick = document.createElement(tagName);
21
+ }, error => {
22
+ // eslint-disable-next-line no-console
23
+ console.error("Load notification service failed:", error);
24
+ });
25
+ }
26
+ const Notification = Object.freeze({
27
+ show
28
+ });
29
+ exports.Notification = Notification;
30
+ //# sourceMappingURL=Notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notification.js","names":["__secret_internals","_interopRequireWildcard","require","brick","show","options","resolve","alert","message","loadNotificationService","tagName","loadBricks","then","document","createElement","error","console","Notification","Object","freeze","exports"],"sources":["../../src/Notification.ts"],"sourcesContent":["import * as __secret_internals from \"./internal/secret_internals.js\";\n\nlet brick: {\n resolve(options: NotificationOptions): void;\n};\n\nfunction show(options: NotificationOptions) {\n if (brick) {\n brick.resolve(options);\n } else {\n alert(options.message);\n }\n}\n\nexport function loadNotificationService(tagName: string) {\n __secret_internals.loadBricks([tagName]).then(\n () => {\n brick = document.createElement(tagName) as any;\n },\n (error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Load notification service failed:\", error);\n }\n );\n}\n\nexport interface NotificationOptions {\n type?: \"success\" | \"error\" | \"warn\" | \"info\";\n message: string;\n}\n\nexport const Notification = Object.freeze({\n show,\n});\n"],"mappings":";;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAIC,KAEH;AAED,SAASC,IAAIA,CAACC,OAA4B,EAAE;EAC1C,IAAIF,KAAK,EAAE;IACTA,KAAK,CAACG,OAAO,CAACD,OAAO,CAAC;EACxB,CAAC,MAAM;IACLE,KAAK,CAACF,OAAO,CAACG,OAAO,CAAC;EACxB;AACF;AAEO,SAASC,uBAAuBA,CAACC,OAAe,EAAE;EACvDV,kBAAkB,CAACW,UAAU,CAAC,CAACD,OAAO,CAAC,CAAC,CAACE,IAAI,CAC3C,MAAM;IACJT,KAAK,GAAGU,QAAQ,CAACC,aAAa,CAACJ,OAAO,CAAQ;EAChD,CAAC,EACAK,KAAc,IAAK;IAClB;IACAC,OAAO,CAACD,KAAK,CAAC,mCAAmC,EAAEA,KAAK,CAAC;EAC3D,CAAC,CACF;AACH;AAOO,MAAME,YAAY,GAAGC,MAAM,CAACC,MAAM,CAAC;EACxCf;AACF,CAAC,CAAC;AAACgB,OAAA,CAAAH,YAAA,GAAAA,YAAA"}
@@ -7,8 +7,11 @@ exports.handleHttpError = handleHttpError;
7
7
  exports.httpErrorToString = httpErrorToString;
8
8
  exports.isUnauthenticatedError = isUnauthenticatedError;
9
9
  var _http = require("@next-core/http");
10
+ var _i18n = require("@next-core/i18n");
10
11
  var _Runtime = require("./internal/Runtime.js");
11
12
  var _history = require("./history.js");
13
+ var _i18n2 = require("./internal/i18n.js");
14
+ var _Dialog = require("./Dialog.js");
12
15
  /**
13
16
  * 将 http 请求错误转换为可读的字符串。
14
17
  *
@@ -65,20 +68,17 @@ function handleHttpError(error) {
65
68
  return;
66
69
  }
67
70
  unauthenticatedConfirming = true;
68
- // i18next.t(`${NS_BRICK_KIT}:${K.LOGIN_TIMEOUT_MESSAGE}`)
69
- if (confirm("您还未登录或登录信息已过期,现在重新登录?")) {
70
- const ssoEnabled = (0, _Runtime.getRuntime)().getFeatureFlags()["sso-enabled"];
71
- const history = (0, _history.getHistory)();
72
- history.push(ssoEnabled ? "/sso-auth/login" : "/auth/login", {
73
- from: {
74
- ...history.location,
75
- state: undefined
76
- }
77
- });
78
- }
79
- setTimeout(() => {
80
- unauthenticatedConfirming = false;
81
- }, 1);
71
+ _Dialog.Dialog.show({
72
+ type: "confirm",
73
+ content: _i18n.i18n.t(`${_i18n2.NS}:${_i18n2.K.LOGIN_TIMEOUT_MESSAGE}`),
74
+ onOk() {
75
+ redirectToLogin();
76
+ unauthenticatedConfirming = false;
77
+ },
78
+ onCancel() {
79
+ unauthenticatedConfirming = false;
80
+ }
81
+ });
82
82
  return;
83
83
  }
84
84
 
@@ -87,11 +87,26 @@ function handleHttpError(error) {
87
87
  const message = httpErrorToString(error);
88
88
  if (message !== lastErrorMessage) {
89
89
  lastErrorMessage = message;
90
- alert(message);
91
- setTimeout(() => {
92
- lastErrorMessage = undefined;
93
- }, 1000);
90
+ _Dialog.Dialog.show({
91
+ type: "error",
92
+ title: _i18n.i18n.t(`${_i18n2.NS}:${_i18n2.K.REQUEST_FAILED}`),
93
+ content: message,
94
+ whiteSpace: "pre-wrap",
95
+ onOk() {
96
+ lastErrorMessage = undefined;
97
+ }
98
+ });
94
99
  }
95
100
  return;
96
101
  }
102
+ function redirectToLogin() {
103
+ const ssoEnabled = (0, _Runtime.getRuntime)().getFeatureFlags()["sso-enabled"];
104
+ const history = (0, _history.getHistory)();
105
+ history.push(ssoEnabled ? "/sso-auth/login" : "/auth/login", {
106
+ from: {
107
+ ...history.location,
108
+ state: undefined
109
+ }
110
+ });
111
+ }
97
112
  //# sourceMappingURL=handleHttpError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleHttpError.js","names":["_http","require","_Runtime","_history","httpErrorToString","error","Event","target","HTMLScriptElement","src","HttpFetchError","HttpResponseError","responseJson","msg","toString","isUnauthenticatedError","response","status","code","unauthenticatedConfirming","lastErrorMessage","handleHttpError","HttpAbortError","window","NO_AUTH_GUARD","confirm","ssoEnabled","getRuntime","getFeatureFlags","history","getHistory","push","from","location","state","undefined","setTimeout","console","message","alert"],"sources":["../../src/handleHttpError.ts"],"sourcesContent":["import {\n HttpAbortError,\n HttpFetchError,\n HttpResponseError,\n} from \"@next-core/http\";\nimport { getRuntime } from \"./internal/Runtime.js\";\nimport { getHistory } from \"./history.js\";\n\n/**\n * 将 http 请求错误转换为可读的字符串。\n *\n * @remarks\n *\n * 将依次尝试读取返回的 JSON 格式数据的字符串类型的 `error` 和 `msg` 字段,如果没有找到则返回 `error.toString()` 的结果。\n *\n * @param error - 错误对象。\n *\n * @returns 转换为字符串的错误信息。\n */\nexport function httpErrorToString(error: unknown): string {\n if (error instanceof Event && error.target instanceof HTMLScriptElement) {\n return error.target.src;\n }\n if (error instanceof HttpFetchError) {\n // return i18next.t(`${NS_BRICK_KIT}:${K.NETWORK_ERROR}`);\n return \"网络错误,请检查您的网络连接。\";\n }\n if (error instanceof HttpResponseError) {\n if (error.responseJson) {\n if (typeof error.responseJson.error === \"string\") {\n return error.responseJson.error;\n } else if (typeof error.responseJson.msg === \"string\") {\n return error.responseJson.msg;\n }\n }\n }\n if (error == null) {\n return \"Unknown error\";\n }\n return error.toString();\n}\n\nexport function isUnauthenticatedError(error: unknown): boolean {\n return (\n error instanceof HttpResponseError &&\n error.response.status === 401 &&\n !!error.responseJson &&\n error.responseJson.code === 100003\n );\n}\n\nlet unauthenticatedConfirming = false;\n\nlet lastErrorMessage: string | undefined;\n\n/**\n * 处理 http 请求错误(使用 AntDesign 模态框弹出错误信息)。\n *\n * @param error - 错误对象。\n */\nexport function handleHttpError(error: unknown) {\n // Do nothing if aborted http requests\n if (error instanceof HttpAbortError) {\n return;\n }\n\n // Redirect to login page if not logged in.\n if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {\n if (unauthenticatedConfirming) {\n return;\n }\n unauthenticatedConfirming = true;\n // i18next.t(`${NS_BRICK_KIT}:${K.LOGIN_TIMEOUT_MESSAGE}`)\n if (confirm(\"您还未登录或登录信息已过期,现在重新登录?\")) {\n const ssoEnabled = getRuntime().getFeatureFlags()[\"sso-enabled\"];\n const history = getHistory();\n history.push(ssoEnabled ? \"/sso-auth/login\" : \"/auth/login\", {\n from: {\n ...history.location,\n state: undefined,\n },\n });\n }\n setTimeout(() => {\n unauthenticatedConfirming = false;\n }, 1);\n return;\n }\n\n // eslint-disable-next-line no-console\n console.error(error);\n\n const message = httpErrorToString(error);\n if (message !== lastErrorMessage) {\n lastErrorMessage = message;\n alert(message);\n setTimeout(() => {\n lastErrorMessage = undefined;\n }, 1000);\n }\n return;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAA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kB,MAAM,CAACC,aAAa,EAAE;IAC1D,IAAIL,yBAAyB,EAAE;MAC7B;IACF;IACAA,yBAAyB,GAAG,IAAI;IAChC;IACA,IAAIM,OAAO,CAAC,uBAAuB,CAAC,EAAE;MACpC,MAAMC,UAAU,GAAG,IAAAC,mBAAU,GAAE,CAACC,eAAe,EAAE,CAAC,aAAa,CAAC;MAChE,MAAMC,OAAO,GAAG,IAAAC,mBAAU,GAAE;MAC5BD,OAAO,CAACE,IAAI,CAACL,UAAU,GAAG,iBAAiB,GAAG,aAAa,EAAE;QAC3DM,IAAI,EAAE;UACJ,GAAGH,OAAO,CAACI,QAAQ;UACnBC,KAAK,EAAEC;QACT;MACF,CAAC,CAAC;IACJ;IACAC,UAAU,CAAC,MAAM;MACfjB,yBAAyB,GAAG,KAAK;IACnC,CAAC,EAAE,CAAC,CAAC;IACL;EACF;;EAEA;EACAkB,OAAO,CAAChC,KAAK,CAACA,KAAK,CAAC;EAEpB,MAAMiC,OAAO,GAAGlC,iBAAiB,CAACC,KAAK,CAAC;EACxC,IAAIiC,OAAO,KAAKlB,gBAAgB,EAAE;IAChCA,gBAAgB,GAAGkB,OAAO;IAC1BC,KAAK,CAACD,OAAO,CAAC;IACdF,UAAU,CAAC,MAAM;MACfhB,gBAAgB,GAAGe,SAAS;IAC9B,CAAC,EAAE,IAAI,CAAC;EACV;EACA;AACF"}
1
+ {"version":3,"file":"handleHttpError.js","names":["_http","require","_i18n","_Runtime","_history","_i18n2","_Dialog","httpErrorToString","error","Event","target","HTMLScriptElement","src","HttpFetchError","HttpResponseError","responseJson","msg","toString","isUnauthenticatedError","response","status","code","unauthenticatedConfirming","lastErrorMessage","handleHttpError","HttpAbortError","window","NO_AUTH_GUARD","Dialog","show","type","content","i18n","t","NS","K","LOGIN_TIMEOUT_MESSAGE","onOk","redirectToLogin","onCancel","console","message","title","REQUEST_FAILED","whiteSpace","undefined","ssoEnabled","getRuntime","getFeatureFlags","history","getHistory","push","from","location","state"],"sources":["../../src/handleHttpError.ts"],"sourcesContent":["import {\n HttpAbortError,\n HttpFetchError,\n HttpResponseError,\n} from \"@next-core/http\";\nimport { i18n } from \"@next-core/i18n\";\nimport { getRuntime } from \"./internal/Runtime.js\";\nimport { getHistory } from \"./history.js\";\nimport { K, NS } from \"./internal/i18n.js\";\nimport { Dialog } from \"./Dialog.js\";\n\n/**\n * 将 http 请求错误转换为可读的字符串。\n *\n * @remarks\n *\n * 将依次尝试读取返回的 JSON 格式数据的字符串类型的 `error` 和 `msg` 字段,如果没有找到则返回 `error.toString()` 的结果。\n *\n * @param error - 错误对象。\n *\n * @returns 转换为字符串的错误信息。\n */\nexport function httpErrorToString(error: unknown): string {\n if (error instanceof Event && error.target instanceof HTMLScriptElement) {\n return error.target.src;\n }\n if (error instanceof HttpFetchError) {\n // return i18next.t(`${NS_BRICK_KIT}:${K.NETWORK_ERROR}`);\n return \"网络错误,请检查您的网络连接。\";\n }\n if (error instanceof HttpResponseError) {\n if (error.responseJson) {\n if (typeof error.responseJson.error === \"string\") {\n return error.responseJson.error;\n } else if (typeof error.responseJson.msg === \"string\") {\n return error.responseJson.msg;\n }\n }\n }\n if (error == null) {\n return \"Unknown error\";\n }\n return error.toString();\n}\n\nexport function isUnauthenticatedError(error: unknown): boolean {\n return (\n error instanceof HttpResponseError &&\n error.response.status === 401 &&\n !!error.responseJson &&\n error.responseJson.code === 100003\n );\n}\n\nlet unauthenticatedConfirming = false;\n\nlet lastErrorMessage: string | undefined;\n\n/**\n * 处理 http 请求错误(使用 AntDesign 模态框弹出错误信息)。\n *\n * @param error - 错误对象。\n */\nexport function handleHttpError(error: unknown) {\n // Do nothing if aborted http requests\n if (error instanceof HttpAbortError) {\n return;\n }\n\n // Redirect to login page if not logged in.\n if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {\n if (unauthenticatedConfirming) {\n return;\n }\n unauthenticatedConfirming = true;\n Dialog.show({\n type: \"confirm\",\n content: i18n.t(`${NS}:${K.LOGIN_TIMEOUT_MESSAGE}`),\n onOk() {\n redirectToLogin();\n unauthenticatedConfirming = false;\n },\n onCancel() {\n unauthenticatedConfirming = false;\n },\n });\n return;\n }\n\n // eslint-disable-next-line no-console\n console.error(error);\n\n const message = httpErrorToString(error);\n if (message !== lastErrorMessage) {\n lastErrorMessage = message;\n Dialog.show({\n type: \"error\",\n title: i18n.t(`${NS}:${K.REQUEST_FAILED}`),\n content: message,\n whiteSpace: \"pre-wrap\",\n onOk() {\n lastErrorMessage = undefined;\n },\n });\n }\n return;\n}\n\nfunction redirectToLogin() {\n const ssoEnabled = getRuntime().getFeatureFlags()[\"sso-enabled\"];\n const history = getHistory();\n history.push(ssoEnabled ? \"/sso-auth/login\" : \"/auth/login\", {\n from: {\n ...history.location,\n state: undefined,\n },\n });\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,iBAAiBA,CAACC,KAAc,EAAU;EACxD,IAAIA,KAAK,YAAYC,KAAK,IAAID,KAAK,CAACE,MAAM,YAAYC,iBAAiB,EAAE;IACvE,OAAOH,KAAK,CAACE,MAAM,CAACE,GAAG;EACzB;EACA,IAAIJ,KAAK,YAAYK,oBAAc,EAAE;IACnC;IACA,OAAO,iBAAiB;EAC1B;EACA,IAAIL,KAAK,YAAYM,uBAAiB,EAAE;IACtC,IAAIN,KAAK,CAACO,YAAY,EAAE;MACtB,IAAI,OAAOP,KAAK,CAACO,YAAY,CAACP,KAAK,KAAK,QAAQ,EAAE;QAChD,OAAOA,KAAK,CAACO,YAAY,CAACP,KAAK;MACjC,CAAC,MAAM,IAAI,OAAOA,KAAK,CAACO,YAAY,CAACC,GAAG,K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O;IAC1Bb,cAAM,CAACC,IAAI,CAAC;MACVC,IAAI,EAAE,OAAO;MACbY,KAAK,EAAEV,UAAI,CAACC,CAAC,CAAE,GAAEC,SAAG,IAAGC,QAAC,CAACQ,cAAe,EAAC,CAAC;MAC1CZ,OAAO,EAAEU,OAAO;MAChBG,UAAU,EAAE,UAAU;MACtBP,IAAIA,CAAA,EAAG;QACLd,gBAAgB,GAAGsB,SAAS;MAC9B;IACF,CAAC,CAAC;EACJ;EACA;AACF;AAEA,SAASP,eAAeA,CAAA,EAAG;EACzB,MAAMQ,UAAU,GAAG,IAAAC,mBAAU,GAAE,CAACC,eAAe,EAAE,CAAC,aAAa,CAAC;EAChE,MAAMC,OAAO,GAAG,IAAAC,mBAAU,GAAE;EAC5BD,OAAO,CAACE,IAAI,CAACL,UAAU,GAAG,iBAAiB,GAAG,aAAa,EAAE;IAC3DM,IAAI,EAAE;MACJ,GAAGH,OAAO,CAACI,QAAQ;MACnBC,KAAK,EAAET;IACT;EACF,CAAC,CAAC;AACJ"}
package/dist/cjs/index.js CHANGED
@@ -18,8 +18,22 @@ var _exportNames = {
18
18
  registerWidgetFunctions: true,
19
19
  registerWidgetI18n: true,
20
20
  StoryboardFunctionRegistryFactory: true,
21
- matchPath: true
21
+ matchPath: true,
22
+ Notification: true,
23
+ Dialog: true
22
24
  };
25
+ Object.defineProperty(exports, "Dialog", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _Dialog.Dialog;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "Notification", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _Notification.Notification;
35
+ }
36
+ });
23
37
  Object.defineProperty(exports, "StoryboardFunctionRegistryFactory", {
24
38
  enumerable: true,
25
39
  get: function () {
@@ -204,4 +218,6 @@ var _WidgetFunctions = require("./internal/compute/WidgetFunctions.js");
204
218
  var _WidgetI18n = require("./internal/compute/WidgetI18n.js");
205
219
  var _StoryboardFunctionRegistry = require("./StoryboardFunctionRegistry.js");
206
220
  var _matchPath = require("./internal/matchPath.js");
221
+ var _Notification = require("./Notification.js");
222
+ var _Dialog = require("./Dialog.js");
207
223
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_auth","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_CustomProcessors","_CustomTemplates","_fetchByProvider","_getBasePath","_getPageInfo","_handleHttpError","_history","_Runtime","__secret_internals","_interopRequireWildcard","_themeAndMode","_checkIf","_WidgetFunctions","_WidgetI18n","_StoryboardFunctionRegistry","_matchPath"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport { createRuntime, getRuntime } from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAA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AAzB,OAAA;AACA,IAAA0B,WAAA,GAAA1B,OAAA;AACA,IAAA2B,2BAAA,GAAA3B,OAAA;AACA,IAAA4B,UAAA,GAAA5B,OAAA"}
1
+ {"version":3,"file":"index.js","names":["_auth","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_CustomProcessors","_CustomTemplates","_fetchByProvider","_getBasePath","_getPageInfo","_handleHttpError","_history","_Runtime","__secret_internals","_interopRequireWildcard","_themeAndMode","_checkIf","_WidgetFunctions","_WidgetI18n","_StoryboardFunctionRegistry","_matchPath","_Notification","_Dialog"],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./auth.js\";\nexport * from \"./CustomProcessors.js\";\nexport * from \"./CustomTemplates.js\";\nexport * from \"./fetchByProvider.js\";\nexport * from \"./getBasePath.js\";\nexport * from \"./getPageInfo.js\";\nexport * from \"./handleHttpError.js\";\nexport * from \"./history.js\";\nexport { createRuntime, getRuntime } from \"./internal/Runtime.js\";\nimport * as __secret_internals from \"./internal/secret_internals.js\";\nexport { __secret_internals };\nexport {\n getCssPropertyValue,\n getCurrentTheme,\n getCurrentMode,\n batchSetAppsLocalTheme,\n applyTheme,\n} from \"./themeAndMode.js\";\nexport {\n checkIfOfComputed,\n checkIfByTransform,\n} from \"./internal/compute/checkIf.js\";\nexport { registerWidgetFunctions } from \"./internal/compute/WidgetFunctions.js\";\nexport { registerWidgetI18n } from \"./internal/compute/WidgetI18n.js\";\nexport { StoryboardFunctionRegistryFactory } from \"./StoryboardFunctionRegistry.js\";\nexport { matchPath } from \"./internal/matchPath.js\";\nexport { Notification, type NotificationOptions } from \"./Notification.js\";\nexport { Dialog, type DialogOptions } from \"./Dialog.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,G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AA,kBAAA;AAErE,IAAAE,aAAA,GAAAvB,OAAA;AAOA,IAAAwB,QAAA,GAAAxB,OAAA;AAIA,IAAAyB,gBAAA,GAAAzB,OAAA;AACA,IAAA0B,WAAA,GAAA1B,OAAA;AACA,IAAA2B,2BAAA,GAAA3B,OAAA;AACA,IAAA4B,UAAA,GAAA5B,OAAA;AACA,IAAA6B,aAAA,GAAA7B,OAAA;AACA,IAAA8B,OAAA,GAAA9B,OAAA"}
@@ -30,7 +30,7 @@ function getTplHostElement(runtimeContext, using, extraInfo) {
30
30
  }
31
31
  function getTagNameOfCustomTemplate(brick, appId) {
32
32
  // When a template is registered by an app, it's namespace maybe missed.
33
- if (!brick.includes(".") && appId) {
33
+ if (!brick.includes(".") && brick.startsWith("tpl-") && appId) {
34
34
  const tagName = `${appId}.${brick}`;
35
35
  if (_CustomTemplates.customTemplates.get(tagName)) {
36
36
  return tagName;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["_CustomTemplates","require","getTplStateStore","tplStateStoreId","tplStateStoreMap","using","extraInfo","Error","store","get","getTplHostElement","runtimeContext","hostElement","hostBrick","element","getTagNameOfCustomTemplate","brick","appId","includes","tagName","customTemplates"],"sources":["../../../../src/internal/CustomTemplates/utils.ts"],"sourcesContent":["import type { DataStore } from \"../data/DataStore.js\";\nimport type { RuntimeBrickElement, RuntimeContext } from \"../interfaces.js\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\n\ntype MinimalTplStateStoreContext = Pick<\n RuntimeContext,\n \"tplStateStoreId\" | \"tplStateStoreMap\"\n>;\n\nexport function getTplStateStore(\n { tplStateStoreId, tplStateStoreMap }: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): DataStore<\"STATE\"> {\n if (!tplStateStoreId) {\n throw new Error(\n `Using \"${using}\" outside of a custom template${extraInfo ?? \"\"}`\n );\n }\n const store = tplStateStoreMap.get(tplStateStoreId);\n if (!store) {\n throw new Error(\n `Template state store is not found when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return store!;\n}\n\nexport function getTplHostElement(\n runtimeContext: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): RuntimeBrickElement {\n const store = getTplStateStore(runtimeContext, using, extraInfo);\n const hostElement = store.hostBrick!.element;\n if (!hostElement) {\n throw new Error(\n `Template host element is gone when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return hostElement!;\n}\n\nexport function getTagNameOfCustomTemplate(\n brick: string,\n appId?: string\n): false | string {\n // When a template is registered by an app, it's namespace maybe missed.\n if (!brick.includes(\".\") && appId) {\n const tagName = `${appId}.${brick}`;\n if (customTemplates.get(tagName)) {\n return tagName;\n }\n }\n if (customTemplates.get(brick)) {\n return brick;\n }\n return false;\n}\n"],"mappings":";;;;;;;;AAEA,IAAAA,gBAAA,GAAAC,OAAA;AAOO,SAASC,gBAAgBA,CAC9B;EAAEC,eAAe;EAAEC;AAA8C,CAAC,EAClEC,KAAa,EACbC,SAAkB,EACE;EACpB,IAAI,CAACH,eAAe,EAAE;IACpB,MAAM,IAAII,KAAK,CACZ,UAASF,KAAM,iCAAgCC,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAG,EAAC,CAClE;EACH;EACA,MAAME,KAAK,GAAGJ,gBAAgB,CAACK,GAAG,CAACN,eAAe,CAAC;EACnD,IAAI,CAACK,KAAK,EAAE;IACV,MAAM,IAAID,KAAK,CACZ,iDAAgDF,KAAM,IACrDC,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EACd,mDAAkD,CACpD;EACH;EACA,OAAOE,KAAK;AACd;AAEO,SAASE,iBAAiBA,CAC/BC,cAA2C,EAC3CN,KAAa,EACbC,SAAkB,EACG;EACrB,MAAME,KAAK,GAAGN,gBAAgB,CAACS,cAAc,EAAEN,KAAK,EAAEC,SAAS,CAAC;EAChE,MAAMM,WAAW,GAAGJ,KAAK,CAACK,SAAS,CAAEC,OAAO;EAC5C,IAAI,CAACF,WAAW,EAAE;IAChB,MAAM,IAAIL,KAAK,CACZ,6CAA4CF,KAAM,IACjDC,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EACd,mDAAkD,CACpD;EACH;EACA,OAAOM,WAAW;AACpB;AAEO,SAASG,0BAA0BA,CACxCC,KAAa,EACbC,KAAc,EACE;EAChB;EACA,IAAI,CAACD,KAAK,CAACE,QAAQ,CAAC,GAAG,CAAC,IAAID,KAAK,EAAE;IACjC,MAAME,OAAO,GAAI,GAAEF,KAAM,IAAGD,KAAM,EAAC;IACnC,IAAII,gCAAe,CAACX,GAAG,CAACU,OAAO,CAAC,EAAE;MAChC,OAAOA,OAAO;IAChB;EACF;EACA,IAAIC,gCAAe,CAACX,GAAG,CAACO,KAAK,CAAC,EAAE;IAC9B,OAAOA,KAAK;EACd;EACA,OAAO,KAAK;AACd"}
1
+ {"version":3,"file":"utils.js","names":["_CustomTemplates","require","getTplStateStore","tplStateStoreId","tplStateStoreMap","using","extraInfo","Error","store","get","getTplHostElement","runtimeContext","hostElement","hostBrick","element","getTagNameOfCustomTemplate","brick","appId","includes","startsWith","tagName","customTemplates"],"sources":["../../../../src/internal/CustomTemplates/utils.ts"],"sourcesContent":["import type { DataStore } from \"../data/DataStore.js\";\nimport type { RuntimeBrickElement, RuntimeContext } from \"../interfaces.js\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\n\ntype MinimalTplStateStoreContext = Pick<\n RuntimeContext,\n \"tplStateStoreId\" | \"tplStateStoreMap\"\n>;\n\nexport function getTplStateStore(\n { tplStateStoreId, tplStateStoreMap }: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): DataStore<\"STATE\"> {\n if (!tplStateStoreId) {\n throw new Error(\n `Using \"${using}\" outside of a custom template${extraInfo ?? \"\"}`\n );\n }\n const store = tplStateStoreMap.get(tplStateStoreId);\n if (!store) {\n throw new Error(\n `Template state store is not found when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return store!;\n}\n\nexport function getTplHostElement(\n runtimeContext: MinimalTplStateStoreContext,\n using: string,\n extraInfo?: string\n): RuntimeBrickElement {\n const store = getTplStateStore(runtimeContext, using, extraInfo);\n const hostElement = store.hostBrick!.element;\n if (!hostElement) {\n throw new Error(\n `Template host element is gone when using \"${using}\"${\n extraInfo ?? \"\"\n }.\\nThis is a bug of Brick Next, please report it.`\n );\n }\n return hostElement!;\n}\n\nexport function getTagNameOfCustomTemplate(\n brick: string,\n appId?: string\n): false | string {\n // When a template is registered by an app, it's namespace maybe missed.\n if (!brick.includes(\".\") && brick.startsWith(\"tpl-\") && appId) {\n const tagName = `${appId}.${brick}`;\n if (customTemplates.get(tagName)) {\n return tagName;\n }\n }\n if (customTemplates.get(brick)) {\n return brick;\n }\n return false;\n}\n"],"mappings":";;;;;;;;AAEA,IAAAA,gBAAA,GAAAC,OAAA;AAOO,SAASC,gBAAgBA,CAC9B;EAAEC,eAAe;EAAEC;AAA8C,CAAC,EAClEC,KAAa,EACbC,SAAkB,EACE;EACpB,IAAI,CAACH,eAAe,EAAE;IACpB,MAAM,IAAII,KAAK,CACZ,UAASF,KAAM,iCAAgCC,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAG,EAAC,CAClE;EACH;EACA,MAAME,KAAK,GAAGJ,gBAAgB,CAACK,GAAG,CAACN,eAAe,CAAC;EACnD,IAAI,CAACK,KAAK,EAAE;IACV,MAAM,IAAID,KAAK,CACZ,iDAAgDF,KAAM,IACrDC,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EACd,mDAAkD,CACpD;EACH;EACA,OAAOE,KAAK;AACd;AAEO,SAASE,iBAAiBA,CAC/BC,cAA2C,EAC3CN,KAAa,EACbC,SAAkB,EACG;EACrB,MAAME,KAAK,GAAGN,gBAAgB,CAACS,cAAc,EAAEN,KAAK,EAAEC,SAAS,CAAC;EAChE,MAAMM,WAAW,GAAGJ,KAAK,CAACK,SAAS,CAAEC,OAAO;EAC5C,IAAI,CAACF,WAAW,EAAE;IAChB,MAAM,IAAIL,KAAK,CACZ,6CAA4CF,KAAM,IACjDC,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EACd,mDAAkD,CACpD;EACH;EACA,OAAOM,WAAW;AACpB;AAEO,SAASG,0BAA0BA,CACxCC,KAAa,EACbC,KAAc,EACE;EAChB;EACA,IAAI,CAACD,KAAK,CAACE,QAAQ,CAAC,GAAG,CAAC,IAAIF,KAAK,CAACG,UAAU,CAAC,MAAM,CAAC,IAAIF,KAAK,EAAE;IAC7D,MAAMG,OAAO,GAAI,GAAEH,KAAM,IAAGD,KAAM,EAAC;IACnC,IAAIK,gCAAe,CAACZ,GAAG,CAACW,OAAO,CAAC,EAAE;MAChC,OAAOA,OAAO;IAChB;EACF;EACA,IAAIC,gCAAe,CAACZ,GAAG,CAACO,KAAK,CAAC,EAAE;IAC9B,OAAOA,KAAK;EACd;EACA,OAAO,KAAK;AACd"}
@@ -215,7 +215,7 @@ async function renderBrick(returnNode, brickConf, _runtimeContext, rendererConte
215
215
  return controlledOutput;
216
216
  }
217
217
 
218
- // Custom templates need to be defined before rendering.
218
+ // Widgets need to be defined before rendering.
219
219
  if (/\.tpl-/.test(brickName) && !_CustomTemplates.customTemplates.get(brickName)) {
220
220
  await (0, _loader.loadBricksImperatively)([brickName], (0, _Runtime.getBrickPackages)());
221
221
  }
@@ -227,8 +227,7 @@ async function renderBrick(returnNode, brickConf, _runtimeContext, rendererConte
227
227
  throw new Error(`Maximum custom template stack overflowed: "${tplTagName}"`);
228
228
  }
229
229
  tplStack.set(tplTagName, tplCount + 1);
230
- }
231
- if (brickName.includes(".")) {
230
+ } else if (brickName.includes("-") && !customElements.get(brickName)) {
232
231
  output.blockingList.push((0, _loader.enqueueStableLoadBricks)([brickName], (0, _Runtime.getBrickPackages)()));
233
232
  }
234
233
  const brick = {
@@ -1 +1 @@
1
- {"version":3,"file":"Renderer.js","names":["_loader","require","_general","_lodash","_checkIf","_computeRealProperties","_resolveData","_computeRealValue","_checkPermissions","_listenOnTrackingContext","_matchRoutes","_constants","_expandCustomTemplate","_utils","_CustomTemplates","_Runtime","_enums","_getTracks","_isStrictMode","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","slotId","matched","matchRoutes","output","blockingList","menuRequests","unauthenticated","route","runtimeContext","match","ctxStore","define","context","pendingPermissionsPreCheck","push","preCheckPermissionsForBrickOrRoute","type","redirectTo","redirect","asyncComputeRealValue","resolved","resolveData","transform","console","error","Error","path","loadMenu","menu","newOutput","mergeRenderOutput","renderBricks","bricks","tplStack","noMemoize","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoizeControlNode","node","key","_runtimeContext$app","brick","template","tplStateStoreId","symbolForTplStateStoreId","hasOwnProperty","symbolForTPlExternalForEachItem","forEachItem","Array","isArray","length","strict","isStrictMode","warnAboutStrictMode","asyncCheckBrickIf","brickName","startsWith","ensureValidControlBrick","dataSource","renderControlNode","_slots$slot","computedDataSource","slot","String","slots","childrenToSlots","children","renderForEach","controlledOutput","contextNames","stateNames","getTracks","renderId","listener","currentRenderId","tplStateStoreMap","values","store","waitForAll","rerenderControlNode","debouncedListener","debounce","contextName","onChange","tplStateStore","getTplStateStore","test","customTemplates","get","loadBricksImperatively","getBrickPackages","tplTagName","getTagNameOfCustomTemplate","app","id","_tplStack$get","tplCount","set","includes","enqueueStableLoadBricks","tag","RenderTag","BRICK","return","events","portal","iid","ref","trackingContextList","loadProperties","properties","asyncComputeRealProperties","computedPropsFromHost","symbolForAsyncComputedPropsFromHost","_brick$properties","computed","propName","propValue","Object","entries","asyncProperties","then","listenOnTrackingContext","registerBrickLifeCycle","lifeCycle","expandedBrickConf","expandCustomTemplate","undefined","childRuntimeContext","loadChildren","childSlotId","slotConf","childrenOutput","child","i","j","flat","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","_child$slot"],"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 { hasOwnProperty } from \"@next-core/utils/general\";\nimport { debounce } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport { asyncComputeRealProperties } from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport { preCheckPermissionsForBrickOrRoute } from \"./checkPermissions.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoutes } from \"./matchRoutes.js\";\nimport {\n RuntimeBrickConfWithTplSymbols,\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachItem,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type { RenderBrick, RenderNode, RuntimeContext } 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 } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.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 preCheckPermissionsForBrickOrRoute(route, runtimeContext)\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: RuntimeBrickConfWithTplSymbols,\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 const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\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 preCheckPermissionsForBrickOrRoute(brickConf, runtimeContext)\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 ...[...runtimeContext.tplStateStoreMap.values()].map((store) =>\n store.waitForAll()\n ),\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 // Custom templates need to be defined before rendering.\n if (/\\.tpl-/.test(brickName) && !customTemplates.get(brickName)) {\n await loadBricksImperatively([brickName], getBrickPackages());\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 }\n\n if (brickName.includes(\".\")) {\n output.blockingList.push(\n enqueueStableLoadBricks([brickName], getBrickPackages())\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 // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const trackingContextList: TrackingContextItem[] = [];\n const loadProperties = async () => {\n brick.properties = await asyncComputeRealProperties(\n brickConf.properties,\n runtimeContext,\n trackingContextList\n );\n const computedPropsFromHost =\n brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n brick.properties ??= {};\n const computed = await computedPropsFromHost;\n for (const [propName, propValue] of Object.entries(computed)) {\n brick.properties[propName] = propValue;\n }\n }\n return brick.properties;\n };\n const asyncProperties = loadProperties();\n blockingList.push(asyncProperties);\n\n asyncProperties.then(() => {\n listenOnTrackingContext(brick, trackingContextList);\n });\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 );\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\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]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C,IAAI,GAAGA,IAAI;IACpB;EACF;EAEAgF,MAAM,CAACwB,MAAM,CAACpJ,MAAM,EAAEiJ,IAAI,CAAC;AAC7B;AAEO,SAAS1E,eAAeA,CAC7BC,QAAiC,EACjC6E,aAAoC,EACpC;EACA,IAAIC,QAAQ,GAAGD,aAAa;EAC5B;EACA,IACEE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,IACtCjF,QAAQ,IACR,CAAClB,KAAK,CAACC,OAAO,CAACiB,QAAQ,CAAC,EACxB;IACA;IACApD,OAAO,CAAC4H,IAAI,CACV,yCAAyC,EACxC,IAAG,OAAOxE,QAAS,GAAE,EACtBA,QAAQ,CACT;EACH;EACA,IAAIlB,KAAK,CAACC,OAAO,CAACiB,QAAQ,CAAC,IAAI,CAAC8E,QAAQ,EAAE;IACxCA,QAAQ,GAAG,CAAC,CAAC;IACb,KAAK,MAAMX,KAAK,IAAInE,QAAQ,EAAE;MAAA,IAAAkF,WAAA;MAC5B,MAAMtF,IAAI,IAAAsF,WAAA,GAAGf,KAAK,CAACvE,IAAI,cAAAsF,WAAA,cAAAA,WAAA,GAAI,EAAE;MAC7B,IAAI,CAAC,IAAAvG,uBAAc,EAACmG,QAAQ,EAAElF,IAAI,CAAC,EAAE;QACnCkF,QAAQ,CAAClF,IAAI,CAAC,GAAG;UACfvD,IAAI,EAAE,QAAQ;UACdgB,MAAM,EAAE;QACV,CAAC;MACH;MACCyH,QAAQ,CAAClF,IAAI,CAAC,CAAsBvC,MAAM,CAAClB,IAAI,CAACgI,KAAK,CAAC;IACzD;EACF;EACA,OAAOW,QAAQ;AACjB"}
1
+ {"version":3,"file":"Renderer.js","names":["_loader","require","_general","_lodash","_checkIf","_computeRealProperties","_resolveData","_computeRealValue","_checkPermissions","_listenOnTrackingContext","_matchRoutes","_constants","_expandCustomTemplate","_utils","_CustomTemplates","_Runtime","_enums","_getTracks","_isStrictMode","renderRoutes","returnNode","routes","_runtimeContext","rendererContext","slotId","matched","matchRoutes","output","blockingList","menuRequests","unauthenticated","route","runtimeContext","match","ctxStore","define","context","pendingPermissionsPreCheck","push","preCheckPermissionsForBrickOrRoute","type","redirectTo","redirect","asyncComputeRealValue","resolved","resolveData","transform","console","error","Error","path","loadMenu","menu","newOutput","mergeRenderOutput","renderBricks","bricks","tplStack","noMemoize","rendered","Promise","all","map","brickConf","index","renderBrick","Map","forEach","item","hasTrackingControls","memoizeControlNode","node","key","_runtimeContext$app","brick","template","tplStateStoreId","symbolForTplStateStoreId","hasOwnProperty","symbolForTPlExternalForEachItem","forEachItem","Array","isArray","length","strict","isStrictMode","warnAboutStrictMode","asyncCheckBrickIf","brickName","startsWith","ensureValidControlBrick","dataSource","renderControlNode","_slots$slot","computedDataSource","slot","String","slots","childrenToSlots","children","renderForEach","controlledOutput","contextNames","stateNames","getTracks","renderId","listener","currentRenderId","tplStateStoreMap","values","store","waitForAll","rerenderControlNode","debouncedListener","debounce","contextName","onChange","tplStateStore","getTplStateStore","test","customTemplates","get","loadBricksImperatively","getBrickPackages","tplTagName","getTagNameOfCustomTemplate","app","id","_tplStack$get","tplCount","set","includes","customElements","enqueueStableLoadBricks","tag","RenderTag","BRICK","return","events","portal","iid","ref","trackingContextList","loadProperties","properties","asyncComputeRealProperties","computedPropsFromHost","symbolForAsyncComputedPropsFromHost","_brick$properties","computed","propName","propValue","Object","entries","asyncProperties","then","listenOnTrackingContext","registerBrickLifeCycle","lifeCycle","expandedBrickConf","expandCustomTemplate","undefined","childRuntimeContext","loadChildren","childSlotId","slotConf","childrenOutput","child","i","j","flat","menuConf","warn","rest","last","sibling","assign","originalSlots","newSlots","process","env","NODE_ENV","_child$slot"],"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 { hasOwnProperty } from \"@next-core/utils/general\";\nimport { debounce } from \"lodash\";\nimport { asyncCheckBrickIf } from \"./compute/checkIf.js\";\nimport { asyncComputeRealProperties } from \"./compute/computeRealProperties.js\";\nimport { resolveData } from \"./data/resolveData.js\";\nimport { asyncComputeRealValue } from \"./compute/computeRealValue.js\";\nimport { preCheckPermissionsForBrickOrRoute } from \"./checkPermissions.js\";\nimport {\n TrackingContextItem,\n listenOnTrackingContext,\n} from \"./compute/listenOnTrackingContext.js\";\nimport { RendererContext } from \"./RendererContext.js\";\nimport { matchRoutes } from \"./matchRoutes.js\";\nimport {\n RuntimeBrickConfWithTplSymbols,\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachItem,\n symbolForTplStateStoreId,\n} from \"./CustomTemplates/constants.js\";\nimport { expandCustomTemplate } from \"./CustomTemplates/expandCustomTemplate.js\";\nimport type { RenderBrick, RenderNode, RuntimeContext } 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 } from \"./Runtime.js\";\nimport { RenderTag } from \"./enums.js\";\nimport { getTracks } from \"./compute/getTracks.js\";\nimport { isStrictMode, warnAboutStrictMode } from \"../isStrictMode.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 preCheckPermissionsForBrickOrRoute(route, runtimeContext)\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: RuntimeBrickConfWithTplSymbols,\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 const tplStateStoreId = brickConf[symbolForTplStateStoreId];\n const runtimeContext = {\n ..._runtimeContext,\n tplStateStoreId,\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 preCheckPermissionsForBrickOrRoute(brickConf, runtimeContext)\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 ...[...runtimeContext.tplStateStoreMap.values()].map((store) =>\n store.waitForAll()\n ),\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 loadBricksImperatively([brickName], getBrickPackages());\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 output.blockingList.push(\n enqueueStableLoadBricks([brickName], getBrickPackages())\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 // 加载构件属性和加载子构件等任务,可以并行。\n const blockingList: Promise<unknown>[] = [];\n\n const trackingContextList: TrackingContextItem[] = [];\n const loadProperties = async () => {\n brick.properties = await asyncComputeRealProperties(\n brickConf.properties,\n runtimeContext,\n trackingContextList\n );\n const computedPropsFromHost =\n brickConf[symbolForAsyncComputedPropsFromHost];\n if (computedPropsFromHost) {\n brick.properties ??= {};\n const computed = await computedPropsFromHost;\n for (const [propName, propValue] of Object.entries(computed)) {\n brick.properties[propName] = propValue;\n }\n }\n return brick.properties;\n };\n const asyncProperties = loadProperties();\n blockingList.push(asyncProperties);\n\n asyncProperties.then(() => {\n listenOnTrackingContext(brick, trackingContextList);\n });\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 );\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\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"],"mappings":";;;;;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAA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SAAS3E,eAAeA,CAC7BC,QAAiC,EACjC8E,aAAoC,EACpC;EACA,IAAIC,QAAQ,GAAGD,aAAa;EAC5B;EACA,IACEE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,IACtClF,QAAQ,IACR,CAAClB,KAAK,CAACC,OAAO,CAACiB,QAAQ,CAAC,EACxB;IACA;IACApD,OAAO,CAAC6H,IAAI,CACV,yCAAyC,EACxC,IAAG,OAAOzE,QAAS,GAAE,EACtBA,QAAQ,CACT;EACH;EACA,IAAIlB,KAAK,CAACC,OAAO,CAACiB,QAAQ,CAAC,IAAI,CAAC+E,QAAQ,EAAE;IACxCA,QAAQ,GAAG,CAAC,CAAC;IACb,KAAK,MAAMX,KAAK,IAAIpE,QAAQ,EAAE;MAAA,IAAAmF,WAAA;MAC5B,MAAMvF,IAAI,IAAAuF,WAAA,GAAGf,KAAK,CAACxE,IAAI,cAAAuF,WAAA,cAAAA,WAAA,GAAI,EAAE;MAC7B,IAAI,CAAC,IAAAxG,uBAAc,EAACoG,QAAQ,EAAEnF,IAAI,CAAC,EAAE;QACnCmF,QAAQ,CAACnF,IAAI,CAAC,GAAG;UACfvD,IAAI,EAAE,QAAQ;UACdgB,MAAM,EAAE;QACV,CAAC;MACH;MACC0H,QAAQ,CAACnF,IAAI,CAAC,CAAsBvC,MAAM,CAAClB,IAAI,CAACiI,KAAK,CAAC;IACzD;EACF;EACA,OAAOW,QAAQ;AACjB"}
@@ -22,6 +22,9 @@ var _matchStoryboard = require("./matchStoryboard.js");
22
22
  var _Router = require("./Router.js");
23
23
  var _loadCheckLogin = require("./loadCheckLogin.js");
24
24
  var _loadBootstrapData = require("./loadBootstrapData.js");
25
+ var _i18n2 = require("./i18n.js");
26
+ var _Notification = require("../Notification.js");
27
+ var _Dialog = require("../Dialog.js");
25
28
  let runtime;
26
29
  let bootstrapData;
27
30
  let router;
@@ -29,7 +32,7 @@ function createRuntime() {
29
32
  if (runtime) {
30
33
  throw new Error("Cannot create multiple runtimes");
31
34
  }
32
- (0, _i18n.initializeI18n)();
35
+ (0, _i18n.initializeI18n)(_i18n2.NS, _i18n2.locales);
33
36
  _moment.default.locale(_i18n.i18n.language);
34
37
  _i18n.i18n.on("languageChanged", () => {
35
38
  _moment.default.locale(_i18n.i18n.language);
@@ -44,6 +47,9 @@ function getRuntime() {
44
47
  class Runtime {
45
48
  async bootstrap() {
46
49
  const [, _bootstrapData] = await Promise.all([(0, _loadCheckLogin.loadCheckLogin)(), (0, _loadBootstrapData.loadBootstrapData)()]);
50
+ // Todo: allow configuration of notification bricks.
51
+ (0, _Notification.loadNotificationService)("shoelace.show-notification");
52
+ (0, _Dialog.loadDialogService)("shoelace.show-dialog");
47
53
  bootstrapData = _bootstrapData;
48
54
  router = new _Router.Router(_bootstrapData.storyboards);
49
55
  await router.bootstrap();
@@ -1 +1 @@
1
- {"version":3,"file":"Runtime.js","names":["_i18n","require","_moment","_interopRequireDefault","_history","_matchStoryboard","_Router","_loadCheckLogin","_loadBootstrapData","runtime","bootstrapData","router","createRuntime","Error","initializeI18n","moment","locale","i18n","language","on","createHistory","Runtime","getRuntime","bootstrap","_bootstrapData","Promise","all","loadCheckLogin","loadBootstrapData","Router","storyboards","getRecentApps","_router$getRecentApps","_router","getCurrentApp","_router2","currentApp","getFeatureFlags","_bootstrapData2","_bootstrapData2$setti","_router3","_router3$getRecentApp","_router3$getRecentApp2","_router3$getRecentApp3","settings","featureFlags","config","getMiscSettings","_bootstrapData3","_bootstrapData3$setti","_router4","_router4$getRecentApp","_router4$getRecentApp2","_router4$getRecentApp3","misc","getBrandSettings","_bootstrapData4","_bootstrapData4$setti","base_title","brand","getLaunchpadSettings","_bootstrapData5","_bootstrapData5$setti","columns","rows","launchpad","getDesktops","_bootstrapData$deskto","_bootstrapData6","desktops","getLaunchpadSiteMap","_bootstrapData$siteSo","_bootstrapData7","siteSort","toggleLaunchpadEffect","open","document","body","classList","toggle","applyPageTitle","pageTitle","baseTitle","title","getNavConfig","_router5","exports","_internalApiSetBootstrapData","data","getBrickPackages","_bootstrapData$brickP","_bootstrapData8","brickPackages","_internalApiGetRenderId","_router6","getRenderId","_internalApiMatchStoryboard","pathname","_bootstrapData$storyb","_bootstrapData9","matchStoryboard","_internalApiGetRuntimeContext","_router7","getRuntimeContext","_internalApiGetStoryboardInBootstrapData","appId","_bootstrapData10","_bootstrapData10$stor","find","storyboard","app","id","_internalApiGetAppInBootstrapData","_internalApiGetStoryb"],"sources":["../../../src/internal/Runtime.ts"],"sourcesContent":["import type {\n RuntimeStoryboard,\n BootstrapSettings,\n FeatureFlags,\n BootstrapData,\n} from \"@next-core/types\";\nimport { i18n, initializeI18n } from \"@next-core/i18n\";\nimport moment from \"moment\";\nimport \"moment/locale/zh-cn.js\";\nimport { createHistory } from \"../history.js\";\nimport { matchStoryboard } from \"./matchStoryboard.js\";\nimport { Router } from \"./Router.js\";\nimport { loadCheckLogin } from \"./loadCheckLogin.js\";\nimport { loadBootstrapData } from \"./loadBootstrapData.js\";\n\nlet runtime: Runtime;\n\nlet bootstrapData: Partial<BootstrapData> | undefined;\nlet router: Router | undefined;\n\nexport function createRuntime() {\n if (runtime) {\n throw new Error(\"Cannot create multiple runtimes\");\n }\n initializeI18n();\n moment.locale(i18n.language);\n i18n.on(\"languageChanged\", () => {\n moment.locale(i18n.language);\n });\n createHistory();\n runtime = new Runtime();\n return runtime;\n}\n\nexport function getRuntime() {\n return runtime;\n}\n\nexport class Runtime {\n async bootstrap() {\n const [, _bootstrapData] = await Promise.all([\n loadCheckLogin(),\n loadBootstrapData(),\n ]);\n bootstrapData = _bootstrapData;\n router = new Router(_bootstrapData.storyboards);\n await router.bootstrap();\n }\n\n getRecentApps() {\n return router?.getRecentApps() ?? {};\n }\n\n getCurrentApp() {\n return router?.getRecentApps().currentApp;\n }\n\n getFeatureFlags(): FeatureFlags {\n return {\n ...bootstrapData?.settings?.featureFlags,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.featureFlags,\n \"migrate-to-brick-next-v3\": true,\n };\n }\n\n getMiscSettings() {\n return {\n ...bootstrapData?.settings?.misc,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.misc,\n };\n }\n\n getBrandSettings(): Record<string, string> {\n return {\n base_title: \"DevOps 管理专家\",\n ...(bootstrapData?.settings?.brand as Record<string, string>),\n // ...(kernel.getOriginFaviconHref()\n // ? { favicon: kernel.getOriginFaviconHref() }\n // : {})\n };\n }\n\n getLaunchpadSettings() {\n return {\n columns: 7,\n rows: 4,\n ...bootstrapData?.settings?.launchpad,\n };\n }\n\n getDesktops(): unknown[] {\n return bootstrapData?.desktops ?? [];\n }\n\n getLaunchpadSiteMap(): unknown[] {\n return bootstrapData?.siteSort ?? [];\n }\n\n toggleLaunchpadEffect(open: boolean): void {\n document.body.classList.toggle(\"launchpad-open\", open);\n }\n\n applyPageTitle(pageTitle: string): void {\n const baseTitle = this.getBrandSettings().base_title;\n document.title = pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle;\n }\n\n getNavConfig() {\n return router?.getNavConfig();\n }\n}\n\nexport function _internalApiSetBootstrapData(data: Partial<BootstrapData>) {\n bootstrapData = data;\n}\n\nexport function getBrickPackages() {\n return bootstrapData?.brickPackages ?? [];\n}\n\nexport function _internalApiGetRenderId(): string | undefined {\n return router?.getRenderId();\n}\n\nexport function _internalApiMatchStoryboard(\n pathname: string\n): RuntimeStoryboard | undefined {\n return matchStoryboard(bootstrapData?.storyboards ?? [], pathname);\n}\n\nexport function _internalApiGetRuntimeContext() {\n return router?.getRuntimeContext();\n}\n\nexport function _internalApiGetStoryboardInBootstrapData(appId: string) {\n return bootstrapData?.storyboards?.find(\n (storyboard) => storyboard.app.id === appId\n );\n}\n\nexport function _internalApiGetAppInBootstrapData(appId: string) {\n return _internalApiGetStoryboardInBootstrapData(appId)?.app;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAMA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,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AAgG,gBAAA,wBAAAC,qBAAA,GAAbD,gBAAA,CAAe5E,WAAW,cAAA6E,qBAAA,uBAA1BA,qBAAA,CAA4BC,IAAI,CACpCC,UAAU,IAAKA,UAAU,CAACC,GAAG,CAACC,EAAE,KAAKN,KAAK,CAC5C;AACH;AAEO,SAASO,iCAAiCA,CAACP,KAAa,EAAE;EAAA,IAAAQ,qBAAA;EAC/D,QAAAA,qBAAA,GAAOT,wCAAwC,CAACC,KAAK,CAAC,cAAAQ,qBAAA,uBAA/CA,qBAAA,CAAiDH,GAAG;AAC7D"}
1
+ {"version":3,"file":"Runtime.js","names":["_i18n","require","_moment","_interopRequireDefault","_history","_matchStoryboard","_Router","_loadCheckLogin","_loadBootstrapData","_i18n2","_Notification","_Dialog","runtime","bootstrapData","router","createRuntime","Error","initializeI18n","NS","locales","moment","locale","i18n","language","on","createHistory","Runtime","getRuntime","bootstrap","_bootstrapData","Promise","all","loadCheckLogin","loadBootstrapData","loadNotificationService","loadDialogService","Router","storyboards","getRecentApps","_router$getRecentApps","_router","getCurrentApp","_router2","currentApp","getFeatureFlags","_bootstrapData2","_bootstrapData2$setti","_router3","_router3$getRecentApp","_router3$getRecentApp2","_router3$getRecentApp3","settings","featureFlags","config","getMiscSettings","_bootstrapData3","_bootstrapData3$setti","_router4","_router4$getRecentApp","_router4$getRecentApp2","_router4$getRecentApp3","misc","getBrandSettings","_bootstrapData4","_bootstrapData4$setti","base_title","brand","getLaunchpadSettings","_bootstrapData5","_bootstrapData5$setti","columns","rows","launchpad","getDesktops","_bootstrapData$deskto","_bootstrapData6","desktops","getLaunchpadSiteMap","_bootstrapData$siteSo","_bootstrapData7","siteSort","toggleLaunchpadEffect","open","document","body","classList","toggle","applyPageTitle","pageTitle","baseTitle","title","getNavConfig","_router5","exports","_internalApiSetBootstrapData","data","getBrickPackages","_bootstrapData$brickP","_bootstrapData8","brickPackages","_internalApiGetRenderId","_router6","getRenderId","_internalApiMatchStoryboard","pathname","_bootstrapData$storyb","_bootstrapData9","matchStoryboard","_internalApiGetRuntimeContext","_router7","getRuntimeContext","_internalApiGetStoryboardInBootstrapData","appId","_bootstrapData10","_bootstrapData10$stor","find","storyboard","app","id","_internalApiGetAppInBootstrapData","_internalApiGetStoryb"],"sources":["../../../src/internal/Runtime.ts"],"sourcesContent":["import type {\n RuntimeStoryboard,\n BootstrapSettings,\n FeatureFlags,\n BootstrapData,\n} from \"@next-core/types\";\nimport { i18n, initializeI18n } from \"@next-core/i18n\";\nimport moment from \"moment\";\nimport \"moment/locale/zh-cn.js\";\nimport { createHistory } from \"../history.js\";\nimport { matchStoryboard } from \"./matchStoryboard.js\";\nimport { Router } from \"./Router.js\";\nimport { loadCheckLogin } from \"./loadCheckLogin.js\";\nimport { loadBootstrapData } from \"./loadBootstrapData.js\";\nimport { NS, locales } from \"./i18n.js\";\nimport { loadNotificationService } from \"../Notification.js\";\nimport { loadDialogService } from \"../Dialog.js\";\n\nlet runtime: Runtime;\n\nlet bootstrapData: Partial<BootstrapData> | undefined;\nlet router: Router | undefined;\n\nexport function createRuntime() {\n if (runtime) {\n throw new Error(\"Cannot create multiple runtimes\");\n }\n initializeI18n(NS, locales);\n moment.locale(i18n.language);\n i18n.on(\"languageChanged\", () => {\n moment.locale(i18n.language);\n });\n createHistory();\n runtime = new Runtime();\n return runtime;\n}\n\nexport function getRuntime() {\n return runtime;\n}\n\nexport class Runtime {\n async bootstrap() {\n const [, _bootstrapData] = await Promise.all([\n loadCheckLogin(),\n loadBootstrapData(),\n ]);\n // Todo: allow configuration of notification bricks.\n loadNotificationService(\"shoelace.show-notification\");\n loadDialogService(\"shoelace.show-dialog\");\n bootstrapData = _bootstrapData;\n router = new Router(_bootstrapData.storyboards);\n await router.bootstrap();\n }\n\n getRecentApps() {\n return router?.getRecentApps() ?? {};\n }\n\n getCurrentApp() {\n return router?.getRecentApps().currentApp;\n }\n\n getFeatureFlags(): FeatureFlags {\n return {\n ...bootstrapData?.settings?.featureFlags,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.featureFlags,\n \"migrate-to-brick-next-v3\": true,\n };\n }\n\n getMiscSettings() {\n return {\n ...bootstrapData?.settings?.misc,\n ...(\n router?.getRecentApps().currentApp?.config\n ?.settings as BootstrapSettings\n )?.misc,\n };\n }\n\n getBrandSettings(): Record<string, string> {\n return {\n base_title: \"DevOps 管理专家\",\n ...(bootstrapData?.settings?.brand as Record<string, string>),\n // ...(kernel.getOriginFaviconHref()\n // ? { favicon: kernel.getOriginFaviconHref() }\n // : {})\n };\n }\n\n getLaunchpadSettings() {\n return {\n columns: 7,\n rows: 4,\n ...bootstrapData?.settings?.launchpad,\n };\n }\n\n getDesktops(): unknown[] {\n return bootstrapData?.desktops ?? [];\n }\n\n getLaunchpadSiteMap(): unknown[] {\n return bootstrapData?.siteSort ?? [];\n }\n\n toggleLaunchpadEffect(open: boolean): void {\n document.body.classList.toggle(\"launchpad-open\", open);\n }\n\n applyPageTitle(pageTitle: string): void {\n const baseTitle = this.getBrandSettings().base_title;\n document.title = pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle;\n }\n\n getNavConfig() {\n return router?.getNavConfig();\n }\n}\n\nexport function _internalApiSetBootstrapData(data: Partial<BootstrapData>) {\n bootstrapData = data;\n}\n\nexport function getBrickPackages() {\n return bootstrapData?.brickPackages ?? [];\n}\n\nexport function _internalApiGetRenderId(): string | undefined {\n return router?.getRenderId();\n}\n\nexport function _internalApiMatchStoryboard(\n pathname: string\n): RuntimeStoryboard | undefined {\n return matchStoryboard(bootstrapData?.storyboards ?? [], pathname);\n}\n\nexport function _internalApiGetRuntimeContext() {\n return router?.getRuntimeContext();\n}\n\nexport function _internalApiGetStoryboardInBootstrapData(appId: string) {\n return bootstrapData?.storyboards?.find(\n (storyboard) => storyboard.app.id === appId\n );\n}\n\nexport function _internalApiGetAppInBootstrapData(appId: string) {\n return _internalApiGetStoryboardInBootstrapData(appId)?.app;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAMA,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AEO,SAASI,6BAA6BA,CAAA,EAAG;EAAA,IAAAC,QAAA;EAC9C,QAAAA,QAAA,GAAO/F,MAAM,cAAA+F,QAAA,uBAANA,QAAA,CAAQC,iBAAiB,EAAE;AACpC;AAEO,SAASC,wCAAwCA,CAACC,KAAa,EAAE;EAAA,IAAAC,gBAAA,EAAAC,qBAAA;EACtE,QAAAD,gBAAA,GAAOpG,aAAa,cAAAoG,gBAAA,wBAAAC,qBAAA,GAAbD,gBAAA,CAAe5E,WAAW,cAAA6E,qBAAA,uBAA1BA,qBAAA,CAA4BC,IAAI,CACpCC,UAAU,IAAKA,UAAU,CAACC,GAAG,CAACC,EAAE,KAAKN,KAAK,CAC5C;AACH;AAEO,SAASO,iCAAiCA,CAACP,KAAa,EAAE;EAAA,IAAAQ,qBAAA;EAC/D,QAAAA,qBAAA,GAAOT,wCAAwC,CAACC,KAAK,CAAC,cAAAQ,qBAAA,uBAA/CA,qBAAA,CAAiDH,GAAG;AAC7D"}
@@ -24,6 +24,7 @@ var _themeAndMode = require("../themeAndMode.js");
24
24
  var _utils = require("./CustomTemplates/utils.js");
25
25
  var _handleHttpError = require("../handleHttpError.js");
26
26
  var _FlowApi = require("./data/FlowApi.js");
27
+ var _Notification = require("../Notification.js");
27
28
  function bindListeners(brick, eventsMap, runtimeContext) {
28
29
  if (!eventsMap) {
29
30
  return;
@@ -397,9 +398,13 @@ function handleConsoleAction(event, method, args, runtimeContext) {
397
398
  }));
398
399
  }
399
400
  function handleMessageAction(event, method, args, runtimeContext) {
400
- alert(...argsFactory(args, runtimeContext, event, {
401
+ const computedArgs = argsFactory(args, runtimeContext, event, {
401
402
  useEventAsDefault: true
402
- }));
403
+ });
404
+ _Notification.Notification.show({
405
+ type: method,
406
+ message: computedArgs[0]
407
+ });
403
408
  }
404
409
  function eventCallbackFactory(callback, runtimeContext, runtimeBrick) {
405
410
  return function callbackFactory(type) {