@next-core/runtime 1.3.1 → 1.3.2

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.
@@ -10,27 +10,23 @@ var __secret_internals = _interopRequireWildcard(require("./internal/secret_inte
10
10
  let brick;
11
11
  function show(options) {
12
12
  if (brick) {
13
- brick.resolve(options);
13
+ return brick.resolve(options);
14
14
  } else {
15
15
  if (options.type === "confirm") {
16
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);
17
+ return new Promise(resolve => setTimeout(() => {
18
+ resolve();
19
+ }, 1));
21
20
  } 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);
21
+ return new Promise((resolve, reject) => setTimeout(() => {
22
+ reject();
23
+ }, 1));
26
24
  }
27
25
  } else {
28
26
  alert(options.content);
29
- if (options.onOk) {
30
- setTimeout(() => {
31
- options.onOk();
32
- }, 1000);
33
- }
27
+ return new Promise(resolve => setTimeout(() => {
28
+ resolve();
29
+ }, 1000));
34
30
  }
35
31
  }
36
32
  }
@@ -1 +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"}
1
+ {"version":3,"file":"Dialog.js","names":["__secret_internals","_interopRequireWildcard","require","brick","show","options","resolve","type","confirm","content","Promise","setTimeout","reject","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): Promise<void>;\n};\n\nfunction show(options: DialogOptions): Promise<void> {\n if (brick) {\n return brick.resolve(options);\n } else {\n if (options.type === \"confirm\") {\n if (confirm(options.content)) {\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\n }, 1)\n );\n } else {\n return new Promise((resolve, reject) =>\n setTimeout(() => {\n reject();\n }, 1)\n );\n }\n } else {\n alert(options.content);\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\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 contentStyle?: object;\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,EAAiB;EACnD,IAAIF,KAAK,EAAE;IACT,OAAOA,KAAK,CAACG,OAAO,CAACD,OAAO,CAAC;EAC/B,CAAC,MAAM;IACL,IAAIA,OAAO,CAACE,IAAI,KAAK,SAAS,EAAE;MAC9B,IAAIC,OAAO,CAACH,OAAO,CAACI,OAAO,CAAC,EAAE;QAC5B,OAAO,IAAIC,OAAO,CAAEJ,OAAO,IACzBK,UAAU,CAAC,MAAM;UACfL,OAAO,EAAE;QACX,CAAC,EAAE,CAAC,CAAC,CACN;MACH,CAAC,MAAM;QACL,OAAO,IAAII,OAAO,CAAC,CAACJ,OAAO,EAAEM,MAAM,KACjCD,UAAU,CAAC,MAAM;UACfC,MAAM,EAAE;QACV,CAAC,EAAE,CAAC,CAAC,CACN;MACH;IACF,CAAC,MAAM;MACLC,KAAK,CAACR,OAAO,CAACI,OAAO,CAAC;MACtB,OAAO,IAAIC,OAAO,CAAEJ,OAAO,IACzBK,UAAU,CAAC,MAAM;QACfL,OAAO,EAAE;MACX,CAAC,EAAE,IAAI,CAAC,CACT;IACH;EACF;AACF;AAEO,SAASQ,iBAAiBA,CAACC,OAAe,EAAE;EACjDf,kBAAkB,CAACgB,UAAU,CAAC,CAACD,OAAO,CAAC,CAAC,CAACE,IAAI,CAC3C,MAAM;IACJd,KAAK,GAAGe,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;AASO,MAAME,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;EAClCpB;AACF,CAAC,CAAC;AAACqB,OAAA,CAAAH,MAAA,GAAAA,MAAA"}
@@ -28,8 +28,7 @@ function httpErrorToString(error) {
28
28
  return error.target.src;
29
29
  }
30
30
  if (error instanceof _http.HttpFetchError) {
31
- // return i18next.t(`${NS_BRICK_KIT}:${K.NETWORK_ERROR}`);
32
- return "网络错误,请检查您的网络连接。";
31
+ return _i18n.i18n.t(`${_i18n2.NS}:${_i18n2.K.NETWORK_ERROR}`);
33
32
  }
34
33
  if (error instanceof _http.HttpResponseError) {
35
34
  if (error.responseJson) {
@@ -70,14 +69,12 @@ function handleHttpError(error) {
70
69
  unauthenticatedConfirming = true;
71
70
  _Dialog.Dialog.show({
72
71
  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
- }
72
+ content: _i18n.i18n.t(`${_i18n2.NS}:${_i18n2.K.LOGIN_TIMEOUT_MESSAGE}`)
73
+ }).then(() => {
74
+ redirectToLogin();
75
+ unauthenticatedConfirming = false;
76
+ }, () => {
77
+ unauthenticatedConfirming = false;
81
78
  });
82
79
  return;
83
80
  }
@@ -91,10 +88,11 @@ function handleHttpError(error) {
91
88
  type: "error",
92
89
  title: _i18n.i18n.t(`${_i18n2.NS}:${_i18n2.K.REQUEST_FAILED}`),
93
90
  content: message,
94
- whiteSpace: "pre-wrap",
95
- onOk() {
96
- lastErrorMessage = undefined;
91
+ contentStyle: {
92
+ whiteSpace: "pre-wrap"
97
93
  }
94
+ }).then(() => {
95
+ lastErrorMessage = undefined;
98
96
  });
99
97
  }
100
98
  return;
@@ -1 +1 @@
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,Y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yBAAyB,GAAG,KAAK;MACnC;IACF,CAAC,CAAC;IACF;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;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"}
1
+ {"version":3,"file":"handleHttpError.js","names":["_http","require","_i18n","_Runtime","_history","_i18n2","_Dialog","httpErrorToString","error","Event","target","HTMLScriptElement","src","HttpFetchError","i18n","t","NS","K","NETWORK_ERROR","HttpResponseError","responseJson","msg","toString","isUnauthenticatedError","response","status","code","unauthenticatedConfirming","lastErrorMessage","handleHttpError","HttpAbortError","window","NO_AUTH_GUARD","Dialog","show","type","content","LOGIN_TIMEOUT_MESSAGE","then","redirectToLogin","console","message","title","REQUEST_FAILED","contentStyle","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 i18n.t(`${NS}:${K.NETWORK_ERROR}`);\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 }).then(\n () => {\n redirectToLogin();\n unauthenticatedConfirming = false;\n },\n () => {\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 contentStyle: {\n whiteSpace: \"pre-wrap\",\n },\n }).then(() => {\n lastErrorMessage = undefined;\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,OAAOC,UAAI,CAACC,CAAC,CAAE,GAAEC,SAAG,IAAGC,QAAC,CAACC,aAAc,EAAC,CAAC;EAC3C;EACA,IAAIV,KAAK,YAAYW,uBAAiB,EAAE;IACtC,IAAIX,KAAK,CAACY,YAAY,EAAE;MACtB,IAAI,OAAOZ,KAAK,CAACY,YAAY,CAACZ,KAAK,KAAK,QAAQ,EAAE;QAChD,OAAOA,KAAK,CAACY,YAAY,CAAC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IiC,OAAO,KAAKb,gBAAgB,EAAE;IAChCA,gBAAgB,GAAGa,OAAO;IAC1BR,cAAM,CAACC,IAAI,CAAC;MACVC,IAAI,EAAE,OAAO;MACbO,KAAK,EAAE5B,UAAI,CAACC,CAAC,CAAE,GAAEC,SAAG,IAAGC,QAAC,CAAC0B,cAAe,EAAC,CAAC;MAC1CP,OAAO,EAAEK,OAAO;MAChBG,YAAY,EAAE;QACZC,UAAU,EAAE;MACd;IACF,CAAC,CAAC,CAACP,IAAI,CAAC,MAAM;MACZV,gBAAgB,GAAGkB,SAAS;IAC9B,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"}
@@ -8,18 +8,21 @@ let K = /*#__PURE__*/function (K) {
8
8
  K["REQUEST_FAILED"] = "REQUEST_FAILED";
9
9
  K["SOMETHING_WENT_WRONG"] = "SOMETHING_WENT_WRONG";
10
10
  K["LOGIN_TIMEOUT_MESSAGE"] = "LOGIN_TIMEOUT_MESSAGE";
11
+ K["NETWORK_ERROR"] = "NETWORK_ERROR";
11
12
  return K;
12
13
  }({});
13
14
  exports.K = K;
14
15
  const en = {
15
16
  [K.REQUEST_FAILED]: "Request Failed",
16
17
  [K.SOMETHING_WENT_WRONG]: "Something went wrong!",
17
- [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?"
18
+ [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
19
+ [K.NETWORK_ERROR]: "Network error, please check your network."
18
20
  };
19
21
  const zh = {
20
22
  [K.REQUEST_FAILED]: "请求失败",
21
23
  [K.SOMETHING_WENT_WRONG]: "出现了一些问题!",
22
- [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?"
24
+ [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
25
+ [K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。"
23
26
  };
24
27
  const NS = "core/runtime";
25
28
  exports.NS = NS;
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","names":["K","exports","en","REQUEST_FAILED","SOMETHING_WENT_WRONG","LOGIN_TIMEOUT_MESSAGE","zh","NS","locales"],"sources":["../../../src/internal/i18n.ts"],"sourcesContent":["export enum K {\n REQUEST_FAILED = \"REQUEST_FAILED\",\n SOMETHING_WENT_WRONG = \"SOMETHING_WENT_WRONG\",\n LOGIN_TIMEOUT_MESSAGE = \"LOGIN_TIMEOUT_MESSAGE\",\n}\n\nconst en: Locale = {\n [K.REQUEST_FAILED]: \"Request Failed\",\n [K.SOMETHING_WENT_WRONG]: \"Something went wrong!\",\n [K.LOGIN_TIMEOUT_MESSAGE]:\n \"You haven't logged in or your login session has expired. Login right now?\",\n};\n\nconst zh: Locale = {\n [K.REQUEST_FAILED]: \"请求失败\",\n [K.SOMETHING_WENT_WRONG]: \"出现了一些问题!\",\n [K.LOGIN_TIMEOUT_MESSAGE]: \"您还未登录或登录信息已过期,现在重新登录?\",\n};\n\nexport const NS = \"core/runtime\";\n\nexport const locales = { en, zh };\n\ntype Locale = { [key in K]: string };\n"],"mappings":";;;;;;IAAYA,CAAC,0BAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAAA,OAADA,CAAC;AAAA;AAAAC,OAAA,CAAAD,CAAA,GAAAA,CAAA;AAMb,MAAME,EAAU,GAAG;EACjB,CAACF,CAAC,CAACG,cAAc,GAAG,gBAAgB;EACpC,CAACH,CAAC,CAACI,oBAAoB,GAAG,uBAAuB;EACjD,CAACJ,CAAC,CAACK,qBAAqB,GACtB;AACJ,CAAC;AAED,MAAMC,EAAU,GAAG;EACjB,CAACN,CAAC,CAACG,cAAc,GAAG,MAAM;EAC1B,CAACH,CAAC,CAACI,oBAAoB,GAAG,UAAU;EACpC,CAACJ,CAAC,CAACK,qBAAqB,GAAG;AAC7B,CAAC;AAEM,MAAME,EAAE,GAAG,cAAc;AAACN,OAAA,CAAAM,EAAA,GAAAA,EAAA;AAE1B,MAAMC,OAAO,GAAG;EAAEN,EAAE;EAAEI;AAAG,CAAC;AAACL,OAAA,CAAAO,OAAA,GAAAA,OAAA"}
1
+ {"version":3,"file":"i18n.js","names":["K","exports","en","REQUEST_FAILED","SOMETHING_WENT_WRONG","LOGIN_TIMEOUT_MESSAGE","NETWORK_ERROR","zh","NS","locales"],"sources":["../../../src/internal/i18n.ts"],"sourcesContent":["export enum K {\n REQUEST_FAILED = \"REQUEST_FAILED\",\n SOMETHING_WENT_WRONG = \"SOMETHING_WENT_WRONG\",\n LOGIN_TIMEOUT_MESSAGE = \"LOGIN_TIMEOUT_MESSAGE\",\n NETWORK_ERROR = \"NETWORK_ERROR\",\n}\n\nconst en: Locale = {\n [K.REQUEST_FAILED]: \"Request Failed\",\n [K.SOMETHING_WENT_WRONG]: \"Something went wrong!\",\n [K.LOGIN_TIMEOUT_MESSAGE]:\n \"You haven't logged in or your login session has expired. Login right now?\",\n [K.NETWORK_ERROR]: \"Network error, please check your network.\",\n};\n\nconst zh: Locale = {\n [K.REQUEST_FAILED]: \"请求失败\",\n [K.SOMETHING_WENT_WRONG]: \"出现了一些问题!\",\n [K.LOGIN_TIMEOUT_MESSAGE]: \"您还未登录或登录信息已过期,现在重新登录?\",\n [K.NETWORK_ERROR]: \"网络错误,请检查您的网络连接。\",\n};\n\nexport const NS = \"core/runtime\";\n\nexport const locales = { en, zh };\n\ntype Locale = { [key in K]: string };\n"],"mappings":";;;;;;IAAYA,CAAC,0BAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAAA,OAADA,CAAC;AAAA;AAAAC,OAAA,CAAAD,CAAA,GAAAA,CAAA;AAOb,MAAME,EAAU,GAAG;EACjB,CAACF,CAAC,CAACG,cAAc,GAAG,gBAAgB;EACpC,CAACH,CAAC,CAACI,oBAAoB,GAAG,uBAAuB;EACjD,CAACJ,CAAC,CAACK,qBAAqB,GACtB,2EAA2E;EAC7E,CAACL,CAAC,CAACM,aAAa,GAAG;AACrB,CAAC;AAED,MAAMC,EAAU,GAAG;EACjB,CAACP,CAAC,CAACG,cAAc,GAAG,MAAM;EAC1B,CAACH,CAAC,CAACI,oBAAoB,GAAG,UAAU;EACpC,CAACJ,CAAC,CAACK,qBAAqB,GAAG,uBAAuB;EAClD,CAACL,CAAC,CAACM,aAAa,GAAG;AACrB,CAAC;AAEM,MAAME,EAAE,GAAG,cAAc;AAACP,OAAA,CAAAO,EAAA,GAAAA,EAAA;AAE1B,MAAMC,OAAO,GAAG;EAAEP,EAAE;EAAEK;AAAG,CAAC;AAACN,OAAA,CAAAQ,OAAA,GAAAA,OAAA"}
@@ -2,27 +2,23 @@ import * as __secret_internals from "./internal/secret_internals.js";
2
2
  var brick;
3
3
  function show(options) {
4
4
  if (brick) {
5
- brick.resolve(options);
5
+ return brick.resolve(options);
6
6
  } else {
7
7
  if (options.type === "confirm") {
8
8
  if (confirm(options.content)) {
9
- setTimeout(() => {
10
- var _options$onOk;
11
- (_options$onOk = options.onOk) === null || _options$onOk === void 0 ? void 0 : _options$onOk.call(options);
12
- }, 1);
9
+ return new Promise(resolve => setTimeout(() => {
10
+ resolve();
11
+ }, 1));
13
12
  } else {
14
- setTimeout(() => {
15
- var _options$onCancel;
16
- (_options$onCancel = options.onCancel) === null || _options$onCancel === void 0 ? void 0 : _options$onCancel.call(options);
17
- }, 1);
13
+ return new Promise((resolve, reject) => setTimeout(() => {
14
+ reject();
15
+ }, 1));
18
16
  }
19
17
  } else {
20
18
  alert(options.content);
21
- if (options.onOk) {
22
- setTimeout(() => {
23
- options.onOk();
24
- }, 1000);
25
- }
19
+ return new Promise(resolve => setTimeout(() => {
20
+ resolve();
21
+ }, 1000));
26
22
  }
27
23
  }
28
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","names":["__secret_internals","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"],"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,OAAO,KAAKA,kBAAkB,MAAM,gCAAgC;AAEpE,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;AAEA,OAAO,SAASK,iBAAiBA,CAACC,OAAe,EAAE;EACjDhB,kBAAkB,CAACiB,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;AAWA,OAAO,IAAME,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;EAClCvB;AACF,CAAC,CAAC"}
1
+ {"version":3,"file":"Dialog.js","names":["__secret_internals","brick","show","options","resolve","type","confirm","content","Promise","setTimeout","reject","alert","loadDialogService","tagName","loadBricks","then","document","createElement","error","console","Dialog","Object","freeze"],"sources":["../../src/Dialog.ts"],"sourcesContent":["import * as __secret_internals from \"./internal/secret_internals.js\";\n\nlet brick: {\n resolve(options: DialogOptions): Promise<void>;\n};\n\nfunction show(options: DialogOptions): Promise<void> {\n if (brick) {\n return brick.resolve(options);\n } else {\n if (options.type === \"confirm\") {\n if (confirm(options.content)) {\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\n }, 1)\n );\n } else {\n return new Promise((resolve, reject) =>\n setTimeout(() => {\n reject();\n }, 1)\n );\n }\n } else {\n alert(options.content);\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\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 contentStyle?: object;\n}\n\nexport const Dialog = Object.freeze({\n show,\n});\n"],"mappings":"AAAA,OAAO,KAAKA,kBAAkB,MAAM,gCAAgC;AAEpE,IAAIC,KAEH;AAED,SAASC,IAAIA,CAACC,OAAsB,EAAiB;EACnD,IAAIF,KAAK,EAAE;IACT,OAAOA,KAAK,CAACG,OAAO,CAACD,OAAO,CAAC;EAC/B,CAAC,MAAM;IACL,IAAIA,OAAO,CAACE,IAAI,KAAK,SAAS,EAAE;MAC9B,IAAIC,OAAO,CAACH,OAAO,CAACI,OAAO,CAAC,EAAE;QAC5B,OAAO,IAAIC,OAAO,CAAEJ,OAAO,IACzBK,UAAU,CAAC,MAAM;UACfL,OAAO,EAAE;QACX,CAAC,EAAE,CAAC,CAAC,CACN;MACH,CAAC,MAAM;QACL,OAAO,IAAII,OAAO,CAAC,CAACJ,OAAO,EAAEM,MAAM,KACjCD,UAAU,CAAC,MAAM;UACfC,MAAM,EAAE;QACV,CAAC,EAAE,CAAC,CAAC,CACN;MACH;IACF,CAAC,MAAM;MACLC,KAAK,CAACR,OAAO,CAACI,OAAO,CAAC;MACtB,OAAO,IAAIC,OAAO,CAAEJ,OAAO,IACzBK,UAAU,CAAC,MAAM;QACfL,OAAO,EAAE;MACX,CAAC,EAAE,IAAI,CAAC,CACT;IACH;EACF;AACF;AAEA,OAAO,SAASQ,iBAAiBA,CAACC,OAAe,EAAE;EACjDb,kBAAkB,CAACc,UAAU,CAAC,CAACD,OAAO,CAAC,CAAC,CAACE,IAAI,CAC3C,MAAM;IACJd,KAAK,GAAGe,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;AASA,OAAO,IAAME,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;EAClCpB;AACF,CAAC,CAAC"}
@@ -22,8 +22,7 @@ export function httpErrorToString(error) {
22
22
  return error.target.src;
23
23
  }
24
24
  if (error instanceof HttpFetchError) {
25
- // return i18next.t(`${NS_BRICK_KIT}:${K.NETWORK_ERROR}`);
26
- return "网络错误,请检查您的网络连接。";
25
+ return i18n.t("".concat(NS, ":").concat(K.NETWORK_ERROR));
27
26
  }
28
27
  if (error instanceof HttpResponseError) {
29
28
  if (error.responseJson) {
@@ -64,14 +63,12 @@ export function handleHttpError(error) {
64
63
  unauthenticatedConfirming = true;
65
64
  Dialog.show({
66
65
  type: "confirm",
67
- content: i18n.t("".concat(NS, ":").concat(K.LOGIN_TIMEOUT_MESSAGE)),
68
- onOk() {
69
- redirectToLogin();
70
- unauthenticatedConfirming = false;
71
- },
72
- onCancel() {
73
- unauthenticatedConfirming = false;
74
- }
66
+ content: i18n.t("".concat(NS, ":").concat(K.LOGIN_TIMEOUT_MESSAGE))
67
+ }).then(() => {
68
+ redirectToLogin();
69
+ unauthenticatedConfirming = false;
70
+ }, () => {
71
+ unauthenticatedConfirming = false;
75
72
  });
76
73
  return;
77
74
  }
@@ -85,10 +82,11 @@ export function handleHttpError(error) {
85
82
  type: "error",
86
83
  title: i18n.t("".concat(NS, ":").concat(K.REQUEST_FAILED)),
87
84
  content: message,
88
- whiteSpace: "pre-wrap",
89
- onOk() {
90
- lastErrorMessage = undefined;
85
+ contentStyle: {
86
+ whiteSpace: "pre-wrap"
91
87
  }
88
+ }).then(() => {
89
+ lastErrorMessage = undefined;
92
90
  });
93
91
  }
94
92
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"handleHttpError.js","names":["HttpAbortError","HttpFetchError","HttpResponseError","i18n","getRuntime","getHistory","K","NS","Dialog","httpErrorToString","error","Event","target","HTMLScriptElement","src","responseJson","msg","toString","isUnauthenticatedError","response","status","code","unauthenticatedConfirming","lastErrorMessage","handleHttpError","window","NO_AUTH_GUARD","show","type","content","t","concat","LOGIN_TIMEOUT_MESSAGE","onOk","redirectToLogin","onCancel","console","message","title","REQUEST_FAILED","whiteSpace","undefined","ssoEnabled","getFeatureFlags","history","push","from","_objectSpread","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,SACEA,cAAc,EACdC,cAAc,EACdC,iBAAiB,QACZ,iBAAiB;AACxB,SAASC,IAAI,QAAQ,iBAAiB;AACtC,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,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3DI,IAAI,EAAAC,aAAA,CAAAA,aAAA,KACCH,OAAO,CAACI,QAAQ;MACnBC,KAAK,EAAER;IAAS;EAEpB,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"handleHttpError.js","names":["HttpAbortError","HttpFetchError","HttpResponseError","i18n","getRuntime","getHistory","K","NS","Dialog","httpErrorToString","error","Event","target","HTMLScriptElement","src","t","concat","NETWORK_ERROR","responseJson","msg","toString","isUnauthenticatedError","response","status","code","unauthenticatedConfirming","lastErrorMessage","handleHttpError","window","NO_AUTH_GUARD","show","type","content","LOGIN_TIMEOUT_MESSAGE","then","redirectToLogin","console","message","title","REQUEST_FAILED","contentStyle","whiteSpace","undefined","ssoEnabled","getFeatureFlags","history","push","from","_objectSpread","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 i18n.t(`${NS}:${K.NETWORK_ERROR}`);\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 }).then(\n () => {\n redirectToLogin();\n unauthenticatedConfirming = false;\n },\n () => {\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 contentStyle: {\n whiteSpace: \"pre-wrap\",\n },\n }).then(() => {\n lastErrorMessage = undefined;\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,SACEA,cAAc,EACdC,cAAc,EACdC,iBAAiB,QACZ,iBAAiB;AACxB,SAASC,IAAI,QAAQ,iBAAiB;AACtC,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,CAAC,EAAEC,EAAE,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,aAAa;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AAQ;MACnBC,KAAK,EAAER;IAAS;EAEpB,CAAC,CAAC;AACJ"}
@@ -2,17 +2,20 @@ export var K = /*#__PURE__*/function (K) {
2
2
  K["REQUEST_FAILED"] = "REQUEST_FAILED";
3
3
  K["SOMETHING_WENT_WRONG"] = "SOMETHING_WENT_WRONG";
4
4
  K["LOGIN_TIMEOUT_MESSAGE"] = "LOGIN_TIMEOUT_MESSAGE";
5
+ K["NETWORK_ERROR"] = "NETWORK_ERROR";
5
6
  return K;
6
7
  }({});
7
8
  var en = {
8
9
  [K.REQUEST_FAILED]: "Request Failed",
9
10
  [K.SOMETHING_WENT_WRONG]: "Something went wrong!",
10
- [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?"
11
+ [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
12
+ [K.NETWORK_ERROR]: "Network error, please check your network."
11
13
  };
12
14
  var zh = {
13
15
  [K.REQUEST_FAILED]: "请求失败",
14
16
  [K.SOMETHING_WENT_WRONG]: "出现了一些问题!",
15
- [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?"
17
+ [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
18
+ [K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。"
16
19
  };
17
20
  export var NS = "core/runtime";
18
21
  export var locales = {
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","names":["K","en","REQUEST_FAILED","SOMETHING_WENT_WRONG","LOGIN_TIMEOUT_MESSAGE","zh","NS","locales"],"sources":["../../../src/internal/i18n.ts"],"sourcesContent":["export enum K {\n REQUEST_FAILED = \"REQUEST_FAILED\",\n SOMETHING_WENT_WRONG = \"SOMETHING_WENT_WRONG\",\n LOGIN_TIMEOUT_MESSAGE = \"LOGIN_TIMEOUT_MESSAGE\",\n}\n\nconst en: Locale = {\n [K.REQUEST_FAILED]: \"Request Failed\",\n [K.SOMETHING_WENT_WRONG]: \"Something went wrong!\",\n [K.LOGIN_TIMEOUT_MESSAGE]:\n \"You haven't logged in or your login session has expired. Login right now?\",\n};\n\nconst zh: Locale = {\n [K.REQUEST_FAILED]: \"请求失败\",\n [K.SOMETHING_WENT_WRONG]: \"出现了一些问题!\",\n [K.LOGIN_TIMEOUT_MESSAGE]: \"您还未登录或登录信息已过期,现在重新登录?\",\n};\n\nexport const NS = \"core/runtime\";\n\nexport const locales = { en, zh };\n\ntype Locale = { [key in K]: string };\n"],"mappings":"AAAA,WAAYA,CAAC,0BAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAAA,OAADA,CAAC;AAAA;AAMb,IAAMC,EAAU,GAAG;EACjB,CAACD,CAAC,CAACE,cAAc,GAAG,gBAAgB;EACpC,CAACF,CAAC,CAACG,oBAAoB,GAAG,uBAAuB;EACjD,CAACH,CAAC,CAACI,qBAAqB,GACtB;AACJ,CAAC;AAED,IAAMC,EAAU,GAAG;EACjB,CAACL,CAAC,CAACE,cAAc,GAAG,MAAM;EAC1B,CAACF,CAAC,CAACG,oBAAoB,GAAG,UAAU;EACpC,CAACH,CAAC,CAACI,qBAAqB,GAAG;AAC7B,CAAC;AAED,OAAO,IAAME,EAAE,GAAG,cAAc;AAEhC,OAAO,IAAMC,OAAO,GAAG;EAAEN,EAAE;EAAEI;AAAG,CAAC"}
1
+ {"version":3,"file":"i18n.js","names":["K","en","REQUEST_FAILED","SOMETHING_WENT_WRONG","LOGIN_TIMEOUT_MESSAGE","NETWORK_ERROR","zh","NS","locales"],"sources":["../../../src/internal/i18n.ts"],"sourcesContent":["export enum K {\n REQUEST_FAILED = \"REQUEST_FAILED\",\n SOMETHING_WENT_WRONG = \"SOMETHING_WENT_WRONG\",\n LOGIN_TIMEOUT_MESSAGE = \"LOGIN_TIMEOUT_MESSAGE\",\n NETWORK_ERROR = \"NETWORK_ERROR\",\n}\n\nconst en: Locale = {\n [K.REQUEST_FAILED]: \"Request Failed\",\n [K.SOMETHING_WENT_WRONG]: \"Something went wrong!\",\n [K.LOGIN_TIMEOUT_MESSAGE]:\n \"You haven't logged in or your login session has expired. Login right now?\",\n [K.NETWORK_ERROR]: \"Network error, please check your network.\",\n};\n\nconst zh: Locale = {\n [K.REQUEST_FAILED]: \"请求失败\",\n [K.SOMETHING_WENT_WRONG]: \"出现了一些问题!\",\n [K.LOGIN_TIMEOUT_MESSAGE]: \"您还未登录或登录信息已过期,现在重新登录?\",\n [K.NETWORK_ERROR]: \"网络错误,请检查您的网络连接。\",\n};\n\nexport const NS = \"core/runtime\";\n\nexport const locales = { en, zh };\n\ntype Locale = { [key in K]: string };\n"],"mappings":"AAAA,WAAYA,CAAC,0BAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAADA,CAAC;EAAA,OAADA,CAAC;AAAA;AAOb,IAAMC,EAAU,GAAG;EACjB,CAACD,CAAC,CAACE,cAAc,GAAG,gBAAgB;EACpC,CAACF,CAAC,CAACG,oBAAoB,GAAG,uBAAuB;EACjD,CAACH,CAAC,CAACI,qBAAqB,GACtB,2EAA2E;EAC7E,CAACJ,CAAC,CAACK,aAAa,GAAG;AACrB,CAAC;AAED,IAAMC,EAAU,GAAG;EACjB,CAACN,CAAC,CAACE,cAAc,GAAG,MAAM;EAC1B,CAACF,CAAC,CAACG,oBAAoB,GAAG,UAAU;EACpC,CAACH,CAAC,CAACI,qBAAqB,GAAG,uBAAuB;EAClD,CAACJ,CAAC,CAACK,aAAa,GAAG;AACrB,CAAC;AAED,OAAO,IAAME,EAAE,GAAG,cAAc;AAEhC,OAAO,IAAMC,OAAO,GAAG;EAAEP,EAAE;EAAEK;AAAG,CAAC"}
@@ -1,12 +1,10 @@
1
- declare function show(options: DialogOptions): void;
1
+ declare function show(options: DialogOptions): Promise<void>;
2
2
  export declare function loadDialogService(tagName: string): void;
3
3
  export interface DialogOptions {
4
4
  type?: "success" | "error" | "warn" | "info" | "confirm";
5
5
  title?: string | null;
6
6
  content: string;
7
- whiteSpace?: string;
8
- onOk?: () => void;
9
- onCancel?: () => void;
7
+ contentStyle?: object;
10
8
  }
11
9
  export declare const Dialog: Readonly<{
12
10
  show: typeof show;
@@ -1,7 +1,8 @@
1
1
  export declare enum K {
2
2
  REQUEST_FAILED = "REQUEST_FAILED",
3
3
  SOMETHING_WENT_WRONG = "SOMETHING_WENT_WRONG",
4
- LOGIN_TIMEOUT_MESSAGE = "LOGIN_TIMEOUT_MESSAGE"
4
+ LOGIN_TIMEOUT_MESSAGE = "LOGIN_TIMEOUT_MESSAGE",
5
+ NETWORK_ERROR = "NETWORK_ERROR"
5
6
  }
6
7
  export declare const NS = "core/runtime";
7
8
  export declare const locales: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/runtime",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "homepage": "https://github.com/easyops-cn/next-core/tree/master/packages/runtime",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -67,5 +67,5 @@
67
67
  "@next-core/build-next-libs": "^1.0.3",
68
68
  "@next-core/test-next": "^1.0.4"
69
69
  },
70
- "gitHead": "21be51ee07f9a5a80364e5e0eb84beebc52c410b"
70
+ "gitHead": "84c3c2f1f0005925fec82076bf7327e6e5e4e50e"
71
71
  }