@pisell/core 0.0.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.
- package/README.md +1 -0
- package/es/app/app.d.ts +101 -0
- package/es/app/app.js +177 -0
- package/es/app/const.d.ts +4 -0
- package/es/app/const.js +6 -0
- package/es/app/index.d.ts +14 -0
- package/es/app/index.js +52 -0
- package/es/applicationManager/application.d.ts +197 -0
- package/es/applicationManager/application.js +469 -0
- package/es/applicationManager/index.d.ts +19 -0
- package/es/applicationManager/index.js +206 -0
- package/es/aws/index.d.ts +16 -0
- package/es/aws/index.js +76 -0
- package/es/cmd/const.d.ts +11 -0
- package/es/cmd/const.js +13 -0
- package/es/cmd/index.d.ts +13 -0
- package/es/cmd/index.js +91 -0
- package/es/cmd/type.d.ts +5 -0
- package/es/cmd/type.js +1 -0
- package/es/communicationManager/index.d.ts +59 -0
- package/es/communicationManager/index.js +174 -0
- package/es/config.d.ts +3 -0
- package/es/config.js +14 -0
- package/es/cookie/index.d.ts +13 -0
- package/es/cookie/index.js +47 -0
- package/es/css/global.less +73 -0
- package/es/css/index.less +31 -0
- package/es/css/variables.css +84 -0
- package/es/data/index.d.ts +8 -0
- package/es/data/index.js +16 -0
- package/es/history/config.d.ts +24 -0
- package/es/history/config.js +43 -0
- package/es/history/index.d.ts +26 -0
- package/es/history/index.js +80 -0
- package/es/history/type.d.ts +2 -0
- package/es/history/type.js +1 -0
- package/es/hooks/index.d.ts +12 -0
- package/es/hooks/index.js +13 -0
- package/es/hooks/useDelayedValue/index.d.ts +2 -0
- package/es/hooks/useDelayedValue/index.js +26 -0
- package/es/hooks/useDispatch/index.d.ts +2 -0
- package/es/hooks/useDispatch/index.js +2 -0
- package/es/hooks/useLowCode/index.d.ts +13 -0
- package/es/hooks/useLowCode/index.js +74 -0
- package/es/hooks/useStore/index.d.ts +6 -0
- package/es/hooks/useStore/index.js +11 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +10 -0
- package/es/indexDB/index.d.ts +296 -0
- package/es/indexDB/index.js +1619 -0
- package/es/locales/en.d.ts +3 -0
- package/es/locales/en.js +5 -0
- package/es/locales/index.d.ts +39 -0
- package/es/locales/index.js +199 -0
- package/es/locales/original.d.ts +3 -0
- package/es/locales/original.js +7 -0
- package/es/locales/type.d.ts +19 -0
- package/es/locales/type.js +1 -0
- package/es/locales/zh-CN.d.ts +3 -0
- package/es/locales/zh-CN.js +5 -0
- package/es/locales/zh-HK.d.ts +3 -0
- package/es/locales/zh-HK.js +5 -0
- package/es/logger/feishu.d.ts +11 -0
- package/es/logger/feishu.js +50 -0
- package/es/logger/index.d.ts +135 -0
- package/es/logger/index.js +870 -0
- package/es/menuManager/hooks.d.ts +17 -0
- package/es/menuManager/hooks.js +136 -0
- package/es/menuManager/index.d.ts +28 -0
- package/es/menuManager/index.js +165 -0
- package/es/models/global.d.ts +32 -0
- package/es/models/global.js +66 -0
- package/es/models/index.d.ts +45 -0
- package/es/models/index.js +65 -0
- package/es/models/type.d.ts +2 -0
- package/es/models/type.js +1 -0
- package/es/plugin/index.d.ts +0 -0
- package/es/plugin/index.js +0 -0
- package/es/pubsub/example.d.ts +5 -0
- package/es/pubsub/example.js +92 -0
- package/es/pubsub/index.d.ts +73 -0
- package/es/pubsub/index.js +166 -0
- package/es/render/index.d.ts +0 -0
- package/es/render/index.js +0 -0
- package/es/request/cache.d.ts +46 -0
- package/es/request/cache.js +372 -0
- package/es/request/cancelToken.d.ts +38 -0
- package/es/request/cancelToken.js +59 -0
- package/es/request/config.d.ts +3 -0
- package/es/request/config.js +63 -0
- package/es/request/constants.d.ts +2 -0
- package/es/request/constants.js +6 -0
- package/es/request/index.d.ts +24 -0
- package/es/request/index.js +267 -0
- package/es/request/pisell2Request.d.ts +6 -0
- package/es/request/pisell2Request.js +62 -0
- package/es/request/type.d.ts +57 -0
- package/es/request/type.js +10 -0
- package/es/request/utils.d.ts +46 -0
- package/es/request/utils.js +147 -0
- package/es/routes/config.d.ts +7 -0
- package/es/routes/config.js +17 -0
- package/es/routes/index.d.ts +28 -0
- package/es/routes/index.js +151 -0
- package/es/socket/components/SocketMonitorPage.d.ts +6 -0
- package/es/socket/components/SocketMonitorPage.js +485 -0
- package/es/socket/components/index.d.ts +2 -0
- package/es/socket/components/index.js +2 -0
- package/es/socket/constants.d.ts +33 -0
- package/es/socket/constants.js +39 -0
- package/es/socket/events.d.ts +31 -0
- package/es/socket/events.js +19 -0
- package/es/socket/heartbeat.d.ts +66 -0
- package/es/socket/heartbeat.js +184 -0
- package/es/socket/index.d.ts +61 -0
- package/es/socket/index.js +246 -0
- package/es/socket/monitor.d.ts +169 -0
- package/es/socket/monitor.js +448 -0
- package/es/socket/reconnect.d.ts +61 -0
- package/es/socket/reconnect.js +199 -0
- package/es/socket/socket.d.ts +130 -0
- package/es/socket/socket.js +613 -0
- package/es/socket/types.d.ts +85 -0
- package/es/socket/types.js +35 -0
- package/es/storage/index.d.ts +17 -0
- package/es/storage/index.js +46 -0
- package/es/tasks/index.d.ts +127 -0
- package/es/tasks/index.js +1119 -0
- package/es/tasks/scheduledTasksExample.d.ts +61 -0
- package/es/tasks/scheduledTasksExample.js +351 -0
- package/es/tasks/type.d.ts +100 -0
- package/es/tasks/type.js +1 -0
- package/es/tasks/useTasks.d.ts +5 -0
- package/es/tasks/useTasks.js +25 -0
- package/es/type.d.ts +2 -0
- package/es/type.js +1 -0
- package/es/utils/adaptiveThrottle/index.d.ts +36 -0
- package/es/utils/adaptiveThrottle/index.js +136 -0
- package/es/variables/VariablesProvider.d.ts +7 -0
- package/es/variables/VariablesProvider.js +12 -0
- package/es/variables/config.d.ts +3 -0
- package/es/variables/config.js +16 -0
- package/es/variables/index.d.ts +6 -0
- package/es/variables/index.js +5 -0
- package/es/variables/type.d.ts +2 -0
- package/es/variables/type.js +1 -0
- package/es/website/index.d.ts +6 -0
- package/es/website/index.js +65 -0
- package/lib/app/app.d.ts +101 -0
- package/lib/app/app.js +171 -0
- package/lib/app/const.d.ts +4 -0
- package/lib/app/const.js +33 -0
- package/lib/app/index.d.ts +14 -0
- package/lib/app/index.js +76 -0
- package/lib/applicationManager/application.d.ts +197 -0
- package/lib/applicationManager/application.js +280 -0
- package/lib/applicationManager/index.d.ts +19 -0
- package/lib/applicationManager/index.js +88 -0
- package/lib/aws/index.d.ts +16 -0
- package/lib/aws/index.js +67 -0
- package/lib/cmd/const.d.ts +11 -0
- package/lib/cmd/const.js +39 -0
- package/lib/cmd/index.d.ts +13 -0
- package/lib/cmd/index.js +96 -0
- package/lib/cmd/type.d.ts +5 -0
- package/lib/cmd/type.js +17 -0
- package/lib/communicationManager/index.d.ts +59 -0
- package/lib/communicationManager/index.js +102 -0
- package/lib/config.d.ts +3 -0
- package/lib/config.js +36 -0
- package/lib/cookie/index.d.ts +13 -0
- package/lib/cookie/index.js +62 -0
- package/lib/css/global.less +73 -0
- package/lib/css/index.less +31 -0
- package/lib/css/variables.css +84 -0
- package/lib/data/index.d.ts +8 -0
- package/lib/data/index.js +38 -0
- package/lib/history/config.d.ts +24 -0
- package/lib/history/config.js +41 -0
- package/lib/history/index.d.ts +26 -0
- package/lib/history/index.js +99 -0
- package/lib/history/type.d.ts +2 -0
- package/lib/history/type.js +17 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/hooks/index.js +44 -0
- package/lib/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/hooks/useDelayedValue/index.js +36 -0
- package/lib/hooks/useDispatch/index.d.ts +2 -0
- package/lib/hooks/useDispatch/index.js +26 -0
- package/lib/hooks/useLowCode/index.d.ts +13 -0
- package/lib/hooks/useLowCode/index.js +75 -0
- package/lib/hooks/useStore/index.d.ts +6 -0
- package/lib/hooks/useStore/index.js +33 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +58 -0
- package/lib/indexDB/index.d.ts +296 -0
- package/lib/indexDB/index.js +767 -0
- package/lib/locales/en.d.ts +3 -0
- package/lib/locales/en.js +29 -0
- package/lib/locales/index.d.ts +39 -0
- package/lib/locales/index.js +159 -0
- package/lib/locales/original.d.ts +3 -0
- package/lib/locales/original.js +31 -0
- package/lib/locales/type.d.ts +19 -0
- package/lib/locales/type.js +17 -0
- package/lib/locales/zh-CN.d.ts +3 -0
- package/lib/locales/zh-CN.js +29 -0
- package/lib/locales/zh-HK.d.ts +3 -0
- package/lib/locales/zh-HK.js +29 -0
- package/lib/logger/feishu.d.ts +11 -0
- package/lib/logger/feishu.js +52 -0
- package/lib/logger/index.d.ts +135 -0
- package/lib/logger/index.js +476 -0
- package/lib/menuManager/hooks.d.ts +17 -0
- package/lib/menuManager/hooks.js +135 -0
- package/lib/menuManager/index.d.ts +28 -0
- package/lib/menuManager/index.js +125 -0
- package/lib/models/global.d.ts +32 -0
- package/lib/models/global.js +62 -0
- package/lib/models/index.d.ts +45 -0
- package/lib/models/index.js +69 -0
- package/lib/models/type.d.ts +2 -0
- package/lib/models/type.js +17 -0
- package/lib/plugin/index.d.ts +0 -0
- package/lib/plugin/index.js +0 -0
- package/lib/pubsub/example.d.ts +5 -0
- package/lib/pubsub/example.js +61 -0
- package/lib/pubsub/index.d.ts +73 -0
- package/lib/pubsub/index.js +141 -0
- package/lib/render/index.d.ts +0 -0
- package/lib/render/index.js +0 -0
- package/lib/request/cache.d.ts +46 -0
- package/lib/request/cache.js +195 -0
- package/lib/request/cancelToken.d.ts +38 -0
- package/lib/request/cancelToken.js +59 -0
- package/lib/request/config.d.ts +3 -0
- package/lib/request/config.js +69 -0
- package/lib/request/constants.d.ts +2 -0
- package/lib/request/constants.js +34 -0
- package/lib/request/index.d.ts +24 -0
- package/lib/request/index.js +210 -0
- package/lib/request/pisell2Request.d.ts +6 -0
- package/lib/request/pisell2Request.js +75 -0
- package/lib/request/type.d.ts +57 -0
- package/lib/request/type.js +36 -0
- package/lib/request/utils.d.ts +46 -0
- package/lib/request/utils.js +113 -0
- package/lib/routes/config.d.ts +7 -0
- package/lib/routes/config.js +50 -0
- package/lib/routes/index.d.ts +28 -0
- package/lib/routes/index.js +121 -0
- package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/socket/components/SocketMonitorPage.js +340 -0
- package/lib/socket/components/index.d.ts +2 -0
- package/lib/socket/components/index.js +39 -0
- package/lib/socket/constants.d.ts +33 -0
- package/lib/socket/constants.js +62 -0
- package/lib/socket/events.d.ts +31 -0
- package/lib/socket/events.js +44 -0
- package/lib/socket/heartbeat.d.ts +66 -0
- package/lib/socket/heartbeat.js +157 -0
- package/lib/socket/index.d.ts +61 -0
- package/lib/socket/index.js +198 -0
- package/lib/socket/monitor.d.ts +169 -0
- package/lib/socket/monitor.js +350 -0
- package/lib/socket/reconnect.d.ts +61 -0
- package/lib/socket/reconnect.js +157 -0
- package/lib/socket/socket.d.ts +130 -0
- package/lib/socket/socket.js +426 -0
- package/lib/socket/types.d.ts +85 -0
- package/lib/socket/types.js +36 -0
- package/lib/storage/index.d.ts +17 -0
- package/lib/storage/index.js +64 -0
- package/lib/tasks/index.d.ts +127 -0
- package/lib/tasks/index.js +710 -0
- package/lib/tasks/scheduledTasksExample.d.ts +61 -0
- package/lib/tasks/scheduledTasksExample.js +267 -0
- package/lib/tasks/type.d.ts +100 -0
- package/lib/tasks/type.js +17 -0
- package/lib/tasks/useTasks.d.ts +5 -0
- package/lib/tasks/useTasks.js +37 -0
- package/lib/type.d.ts +2 -0
- package/lib/type.js +17 -0
- package/lib/utils/adaptiveThrottle/index.d.ts +36 -0
- package/lib/utils/adaptiveThrottle/index.js +121 -0
- package/lib/variables/VariablesProvider.d.ts +7 -0
- package/lib/variables/VariablesProvider.js +51 -0
- package/lib/variables/config.d.ts +3 -0
- package/lib/variables/config.js +38 -0
- package/lib/variables/index.d.ts +6 -0
- package/lib/variables/index.js +29 -0
- package/lib/variables/type.d.ts +2 -0
- package/lib/variables/type.js +17 -0
- package/lib/website/index.d.ts +6 -0
- package/lib/website/index.js +75 -0
- package/package.json +49 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/locales/en.ts
|
|
20
|
+
var en_exports = {};
|
|
21
|
+
__export(en_exports, {
|
|
22
|
+
default: () => en_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(en_exports);
|
|
25
|
+
var en_default = {
|
|
26
|
+
"locale": "en",
|
|
27
|
+
"name": "english",
|
|
28
|
+
"translations": {}
|
|
29
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Locale, LibraryItem, LoadLibraryByUrlParams } from "./type";
|
|
2
|
+
import App from "../app";
|
|
3
|
+
export interface LocalesOptions {
|
|
4
|
+
locale?: Locale;
|
|
5
|
+
library?: {
|
|
6
|
+
[key in Locale]: LibraryItem;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare class Locales {
|
|
10
|
+
private app;
|
|
11
|
+
locale: string;
|
|
12
|
+
library: {
|
|
13
|
+
[key in Locale]: LibraryItem;
|
|
14
|
+
};
|
|
15
|
+
constructor(app: App, options?: LocalesOptions);
|
|
16
|
+
getLocale: () => string;
|
|
17
|
+
getCurrentTexts: (locale?: Locale) => {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
};
|
|
20
|
+
setLocale: (locale: Locale, reload?: boolean) => void;
|
|
21
|
+
getText: (id: string, locale?: Locale) => string;
|
|
22
|
+
isCN: () => boolean;
|
|
23
|
+
loadLibraryByUrl: (urls: LoadLibraryByUrlParams) => Promise<{
|
|
24
|
+
[x: string]: LibraryItem;
|
|
25
|
+
}>;
|
|
26
|
+
loadLibraryByItems(libraryList: LibraryItem[]): void;
|
|
27
|
+
loadLibrary: (urls: LoadLibraryByUrlParams) => Promise<{
|
|
28
|
+
[x: string]: LibraryItem;
|
|
29
|
+
}>;
|
|
30
|
+
translation: (text: string | {
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
}, locale?: Locale) => string | number;
|
|
33
|
+
getLibraryByData: (data: LibraryItem[]) => LibraryItem;
|
|
34
|
+
createTextsByLibrary: (id: string, library?: {
|
|
35
|
+
[x: string]: LibraryItem;
|
|
36
|
+
} | undefined) => {
|
|
37
|
+
[x: string]: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/locales/index.ts
|
|
30
|
+
var locales_exports = {};
|
|
31
|
+
__export(locales_exports, {
|
|
32
|
+
Locales: () => Locales
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(locales_exports);
|
|
35
|
+
var import_lodash = __toESM(require("lodash"));
|
|
36
|
+
var import_utils = require("@pisell/utils");
|
|
37
|
+
var import_en = __toESM(require("./en"));
|
|
38
|
+
var import_zh_CN = __toESM(require("./zh-CN"));
|
|
39
|
+
var import_zh_HK = __toESM(require("./zh-HK"));
|
|
40
|
+
var import_original = __toESM(require("./original"));
|
|
41
|
+
var Locales = class {
|
|
42
|
+
app;
|
|
43
|
+
// 当前语言 本地语言 > 英文语言包
|
|
44
|
+
locale = import_en.default.locale;
|
|
45
|
+
// 语言包
|
|
46
|
+
library = [import_original.default, import_en.default, import_zh_CN.default, import_zh_HK.default].reduce((pre, cur) => {
|
|
47
|
+
pre[cur.locale] = cur;
|
|
48
|
+
return pre;
|
|
49
|
+
}, {});
|
|
50
|
+
constructor(app, options) {
|
|
51
|
+
this.app = app;
|
|
52
|
+
this.locale = (options == null ? void 0 : options.locale) || this.app.storage.getStorage("locale") || import_en.default.locale;
|
|
53
|
+
this.library = (options == null ? void 0 : options.library) || [import_original.default, import_en.default, import_zh_CN.default, import_zh_HK.default].reduce((pre, cur) => {
|
|
54
|
+
pre[cur.locale] = cur;
|
|
55
|
+
return pre;
|
|
56
|
+
}, {});
|
|
57
|
+
}
|
|
58
|
+
getLocale = () => {
|
|
59
|
+
return this.locale;
|
|
60
|
+
};
|
|
61
|
+
getCurrentTexts = (locale) => {
|
|
62
|
+
return this.library[locale || this.locale].translations;
|
|
63
|
+
};
|
|
64
|
+
setLocale = (locale, reload = false) => {
|
|
65
|
+
this.locale = locale;
|
|
66
|
+
if (reload) {
|
|
67
|
+
window.location.reload();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
getText = (id, locale) => {
|
|
72
|
+
var _a;
|
|
73
|
+
return ((_a = this.getCurrentTexts(locale)) == null ? void 0 : _a[id]) || id;
|
|
74
|
+
};
|
|
75
|
+
isCN = () => {
|
|
76
|
+
let locale = this.getLocale();
|
|
77
|
+
return locale === "zh-CN" || locale === "zh-HK";
|
|
78
|
+
};
|
|
79
|
+
loadLibraryByUrl = async (urls) => {
|
|
80
|
+
try {
|
|
81
|
+
let fetchList = urls.map((item) => {
|
|
82
|
+
if (typeof item === "string") {
|
|
83
|
+
return fetch(item);
|
|
84
|
+
}
|
|
85
|
+
if (typeof item === "function") {
|
|
86
|
+
return item();
|
|
87
|
+
}
|
|
88
|
+
if (typeof item === "object" && item !== null && "locale" in item) {
|
|
89
|
+
return Promise.resolve(item);
|
|
90
|
+
}
|
|
91
|
+
return item;
|
|
92
|
+
});
|
|
93
|
+
let res = await Promise.all(fetchList);
|
|
94
|
+
let library = { ...this.library };
|
|
95
|
+
for (const item of res) {
|
|
96
|
+
const _item = item instanceof Response ? await item.json() : item;
|
|
97
|
+
library = {
|
|
98
|
+
...library,
|
|
99
|
+
[_item.locale]: import_lodash.default.mergeWith(library[_item.locale] || {}, _item)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
this.library = library;
|
|
103
|
+
return library;
|
|
104
|
+
} catch (err) {
|
|
105
|
+
console.log(err);
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
loadLibraryByItems(libraryList) {
|
|
110
|
+
let library = { ...this.library };
|
|
111
|
+
libraryList.forEach((item) => {
|
|
112
|
+
library = {
|
|
113
|
+
...library,
|
|
114
|
+
[item.locale]: import_lodash.default.mergeWith(library[item.locale] || {}, item)
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
this.library = library;
|
|
118
|
+
}
|
|
119
|
+
loadLibrary = (urls) => {
|
|
120
|
+
return this.loadLibraryByUrl(urls);
|
|
121
|
+
};
|
|
122
|
+
translation = (text, locale) => {
|
|
123
|
+
if (!text) {
|
|
124
|
+
return "";
|
|
125
|
+
}
|
|
126
|
+
if ((0, import_utils.isString)(text) || (0, import_utils.isNumber)(text)) {
|
|
127
|
+
return text;
|
|
128
|
+
}
|
|
129
|
+
let primary = locale || this.getLocale();
|
|
130
|
+
if (typeof text === "string") {
|
|
131
|
+
return text;
|
|
132
|
+
}
|
|
133
|
+
return text[primary] || text["original"] || text["en"] || text["zh-CN"] || text["zh-HK"];
|
|
134
|
+
};
|
|
135
|
+
getLibraryByData = (data) => {
|
|
136
|
+
return data.reduce((pre, next) => {
|
|
137
|
+
return {
|
|
138
|
+
...pre,
|
|
139
|
+
[next.locale]: next
|
|
140
|
+
};
|
|
141
|
+
}, {});
|
|
142
|
+
};
|
|
143
|
+
createTextsByLibrary = (id, library) => {
|
|
144
|
+
const _library = library || this.library;
|
|
145
|
+
return Object.keys(_library).reduce((pre, next) => {
|
|
146
|
+
var _a;
|
|
147
|
+
let _pre = { ...pre };
|
|
148
|
+
let cur = (_a = _library[next].translations) == null ? void 0 : _a[id];
|
|
149
|
+
if (cur) {
|
|
150
|
+
_pre[_library[next].locale] = cur;
|
|
151
|
+
}
|
|
152
|
+
return _pre;
|
|
153
|
+
}, {});
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
157
|
+
0 && (module.exports = {
|
|
158
|
+
Locales
|
|
159
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/locales/original.ts
|
|
20
|
+
var original_exports = {};
|
|
21
|
+
__export(original_exports, {
|
|
22
|
+
default: () => original_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(original_exports);
|
|
25
|
+
var original_default = {
|
|
26
|
+
"locale": "original",
|
|
27
|
+
"name": "original",
|
|
28
|
+
"translations": {
|
|
29
|
+
"original": "Original"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare type Locale = 'original' | 'en' | 'zh-CN' | 'zh-HK' | string;
|
|
2
|
+
export declare type MultiLanguage = {
|
|
3
|
+
[key in Locale]: string;
|
|
4
|
+
};
|
|
5
|
+
export interface LibraryItem {
|
|
6
|
+
locale: Locale;
|
|
7
|
+
name: string;
|
|
8
|
+
translations: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface LocaleConfig {
|
|
14
|
+
locale: Locale;
|
|
15
|
+
library: {
|
|
16
|
+
[key in Locale]: LibraryItem;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare type LoadLibraryByUrlParams = (string | Promise<LibraryItem> | (() => Promise<LibraryItem>) | LibraryItem)[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/locales/type.ts
|
|
16
|
+
var type_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(type_exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/locales/zh-CN.ts
|
|
20
|
+
var zh_CN_exports = {};
|
|
21
|
+
__export(zh_CN_exports, {
|
|
22
|
+
default: () => zh_CN_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(zh_CN_exports);
|
|
25
|
+
var zh_CN_default = {
|
|
26
|
+
"locale": "zh-CN",
|
|
27
|
+
"name": "simplifiedChinese",
|
|
28
|
+
"translations": {}
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/locales/zh-HK.ts
|
|
20
|
+
var zh_HK_exports = {};
|
|
21
|
+
__export(zh_HK_exports, {
|
|
22
|
+
default: () => zh_HK_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(zh_HK_exports);
|
|
25
|
+
var zh_HK_default = {
|
|
26
|
+
"locale": "zh-HK",
|
|
27
|
+
"name": "chineseTraditional",
|
|
28
|
+
"translations": {}
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface contentItem {
|
|
2
|
+
key: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
interface sendWebhookProps {
|
|
6
|
+
title: string;
|
|
7
|
+
content: contentItem[];
|
|
8
|
+
webhook: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const sendWarningLog: ({ title, content, webhook }: sendWebhookProps) => Promise<any>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/logger/feishu.ts
|
|
20
|
+
var feishu_exports = {};
|
|
21
|
+
__export(feishu_exports, {
|
|
22
|
+
sendWarningLog: () => sendWarningLog
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(feishu_exports);
|
|
25
|
+
var createFeishuMessageContent = (contentArr) => {
|
|
26
|
+
return JSON.stringify(
|
|
27
|
+
contentArr.map((item) => {
|
|
28
|
+
return [
|
|
29
|
+
{ tag: "text", text: `${item.key}: ` },
|
|
30
|
+
{ tag: "text", text: `${item.value}` }
|
|
31
|
+
];
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
var sendWarningLog = async ({ title, content, webhook }) => {
|
|
36
|
+
const contentStr = createFeishuMessageContent(content);
|
|
37
|
+
const response = await fetch(webhook, {
|
|
38
|
+
headers: {
|
|
39
|
+
"Content-Type": "application/json"
|
|
40
|
+
},
|
|
41
|
+
method: "POST",
|
|
42
|
+
body: JSON.stringify({
|
|
43
|
+
msg_type: "post",
|
|
44
|
+
content: `{"post":{"zh_cn":{"title":"${title}","content":${contentStr}}}}`
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
return await response.json();
|
|
48
|
+
};
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
sendWarningLog
|
|
52
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import App from "../app";
|
|
2
|
+
export declare type LogConsoleType = "info" | "warning" | "error" | "debug";
|
|
3
|
+
/**
|
|
4
|
+
* 日志项接口
|
|
5
|
+
*/
|
|
6
|
+
interface LogItem {
|
|
7
|
+
logId?: string | number;
|
|
8
|
+
type: LogConsoleType;
|
|
9
|
+
title: string;
|
|
10
|
+
date?: string;
|
|
11
|
+
metadata?: any;
|
|
12
|
+
feishu?: any;
|
|
13
|
+
}
|
|
14
|
+
interface LogFile {
|
|
15
|
+
fileName: string;
|
|
16
|
+
date: string;
|
|
17
|
+
fileContent: LogFileContent;
|
|
18
|
+
}
|
|
19
|
+
interface LogFileContent {
|
|
20
|
+
metadata: any;
|
|
21
|
+
logs: LogItem[];
|
|
22
|
+
}
|
|
23
|
+
export interface LoggerOptions {
|
|
24
|
+
prefix?: string;
|
|
25
|
+
checkInterval?: number;
|
|
26
|
+
feishuConfig?: any;
|
|
27
|
+
retentionDays?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 日志管理器类
|
|
31
|
+
*/
|
|
32
|
+
declare class LoggerManager {
|
|
33
|
+
private logBuffer;
|
|
34
|
+
private timer;
|
|
35
|
+
private checkInterval;
|
|
36
|
+
private prefix;
|
|
37
|
+
private metadata;
|
|
38
|
+
private db;
|
|
39
|
+
private app;
|
|
40
|
+
private feishuConfig;
|
|
41
|
+
private retentionDays;
|
|
42
|
+
private metadataFunction;
|
|
43
|
+
private status;
|
|
44
|
+
/**
|
|
45
|
+
* 构造函数
|
|
46
|
+
* @param prefix 日志前缀
|
|
47
|
+
* @param checkInterval 检查间隔时间,默认5分钟
|
|
48
|
+
*/
|
|
49
|
+
constructor(app: App, options?: LoggerOptions);
|
|
50
|
+
init(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* 初始化 IndexDB
|
|
53
|
+
*/
|
|
54
|
+
private initDB;
|
|
55
|
+
/**
|
|
56
|
+
* 设置元数据
|
|
57
|
+
* @param metadata 元数据
|
|
58
|
+
*/
|
|
59
|
+
setMetadata(metadata: any): void;
|
|
60
|
+
setMetadataFunction(metadataFunction: () => any): void;
|
|
61
|
+
/**
|
|
62
|
+
* 初始化定时器
|
|
63
|
+
*/
|
|
64
|
+
initTimer(): void;
|
|
65
|
+
private setStatus;
|
|
66
|
+
stop(): void;
|
|
67
|
+
/**
|
|
68
|
+
* 添加日志
|
|
69
|
+
* @param log 日志项
|
|
70
|
+
*/
|
|
71
|
+
addLog(log: LogItem): void;
|
|
72
|
+
/**
|
|
73
|
+
* 发送飞书通知
|
|
74
|
+
* @param log 日志项
|
|
75
|
+
*/
|
|
76
|
+
private sendFeishuNotification;
|
|
77
|
+
/**
|
|
78
|
+
* 创建日志文件名
|
|
79
|
+
* @returns 日志文件名
|
|
80
|
+
*/
|
|
81
|
+
private createFileName;
|
|
82
|
+
/**
|
|
83
|
+
* 创建AWS日志文件名
|
|
84
|
+
* @param isManual 紧急上传
|
|
85
|
+
* @returns 日志文件名
|
|
86
|
+
*/
|
|
87
|
+
createAWSFileName(urgent?: boolean): Promise<any>;
|
|
88
|
+
/**
|
|
89
|
+
* 创建日志文件
|
|
90
|
+
* @param _fileName 文件名
|
|
91
|
+
* @returns 日志文件对象
|
|
92
|
+
*/
|
|
93
|
+
private createFile;
|
|
94
|
+
/**
|
|
95
|
+
* 存储日志到持久化存储
|
|
96
|
+
*/
|
|
97
|
+
storeLog(urgent?: boolean): Promise<void>;
|
|
98
|
+
uploadIndexDBLog(): Promise<void>;
|
|
99
|
+
private storeLogToIndexDB;
|
|
100
|
+
/**
|
|
101
|
+
* 清理旧日志,只保留最近指定天数的日志
|
|
102
|
+
*/
|
|
103
|
+
private cleanupOldLogs;
|
|
104
|
+
/**
|
|
105
|
+
* 获取日志文件列表
|
|
106
|
+
* @returns 日志文件列表
|
|
107
|
+
*/
|
|
108
|
+
getLogFiles(): Promise<LogFile[]>;
|
|
109
|
+
/**
|
|
110
|
+
* 获取指定日志文件的内容
|
|
111
|
+
* @param fileName 日志文件名
|
|
112
|
+
* @returns 日志文件内容
|
|
113
|
+
*/
|
|
114
|
+
getLogFile(fileName: string): Promise<LogFile | null>;
|
|
115
|
+
/**
|
|
116
|
+
* 清空指定日志文件
|
|
117
|
+
* @param fileName 日志文件名,不指定则清空所有日志
|
|
118
|
+
* @returns 是否成功
|
|
119
|
+
*/
|
|
120
|
+
clearLogs(fileName?: string): Promise<boolean>;
|
|
121
|
+
/**
|
|
122
|
+
* 设置日志保留天数
|
|
123
|
+
* @param days 保留天数
|
|
124
|
+
*/
|
|
125
|
+
setRetentionDays(days: number): void;
|
|
126
|
+
/**
|
|
127
|
+
* 手动触发清理旧日志
|
|
128
|
+
*/
|
|
129
|
+
manualCleanup(): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* 销毁实例
|
|
132
|
+
*/
|
|
133
|
+
destroy(): void;
|
|
134
|
+
}
|
|
135
|
+
export default LoggerManager;
|