@nocobase/server 0.11.1-alpha.1 → 0.11.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/application.d.ts +3 -0
- package/lib/application.js +6 -0
- package/lib/locale/antd.d.ts +1 -0
- package/lib/locale/antd.js +16 -0
- package/lib/locale/cron.d.ts +1 -0
- package/lib/locale/cron.js +25 -0
- package/lib/locale/cronstrue.d.ts +1 -0
- package/lib/locale/cronstrue.js +63 -0
- package/lib/locale/index.d.ts +1 -0
- package/lib/locale/index.js +16 -0
- package/lib/locale/locale.d.ts +17 -0
- package/lib/locale/locale.js +106 -0
- package/lib/locale/resource.d.ts +1 -0
- package/lib/locale/resource.js +46 -0
- package/lib/plugin-manager/plugin-manager.js +4 -1
- package/package.json +9 -9
package/lib/application.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { Server } from 'http';
|
|
|
12
12
|
import { i18n, InitOptions } from 'i18next';
|
|
13
13
|
import Koa, { DefaultContext as KoaDefaultContext, DefaultState as KoaDefaultState } from 'koa';
|
|
14
14
|
import { AppManager } from './app-manager';
|
|
15
|
+
import { Locale } from './locale';
|
|
15
16
|
import { Plugin } from './plugin';
|
|
16
17
|
import { InstallOptions, PluginManager } from './plugin-manager';
|
|
17
18
|
export type PluginConfiguration = string | [string, any];
|
|
@@ -87,6 +88,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
87
88
|
protected _acl: ACL;
|
|
88
89
|
protected _appManager: AppManager;
|
|
89
90
|
protected _authManager: AuthManager;
|
|
91
|
+
protected _locales: Locale;
|
|
90
92
|
protected _version: ApplicationVersion;
|
|
91
93
|
protected plugins: Map<string, Plugin<any>>;
|
|
92
94
|
listenServer: Server;
|
|
@@ -105,6 +107,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
105
107
|
get authManager(): AuthManager;
|
|
106
108
|
get logger(): Logger;
|
|
107
109
|
get log(): Logger;
|
|
110
|
+
get locales(): Locale;
|
|
108
111
|
get name(): string;
|
|
109
112
|
protected init(): void;
|
|
110
113
|
private createDatabase;
|
package/lib/application.js
CHANGED
|
@@ -92,6 +92,7 @@ var _acl = require("./acl");
|
|
|
92
92
|
var _appManager = require("./app-manager");
|
|
93
93
|
var _commands = require("./commands");
|
|
94
94
|
var _helper = require("./helper");
|
|
95
|
+
var _locale = require("./locale");
|
|
95
96
|
var _pluginManager = require("./plugin-manager");
|
|
96
97
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
97
98
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -178,6 +179,7 @@ class Application extends _koa().default {
|
|
|
178
179
|
this._acl = void 0;
|
|
179
180
|
this._appManager = void 0;
|
|
180
181
|
this._authManager = void 0;
|
|
182
|
+
this._locales = void 0;
|
|
181
183
|
this._version = void 0;
|
|
182
184
|
this.plugins = new Map();
|
|
183
185
|
this.listenServer = void 0;
|
|
@@ -221,6 +223,9 @@ class Application extends _koa().default {
|
|
|
221
223
|
get log() {
|
|
222
224
|
return this._logger;
|
|
223
225
|
}
|
|
226
|
+
get locales() {
|
|
227
|
+
return this._locales;
|
|
228
|
+
}
|
|
224
229
|
get name() {
|
|
225
230
|
return this.options.name || 'main';
|
|
226
231
|
}
|
|
@@ -282,6 +287,7 @@ class Application extends _koa().default {
|
|
|
282
287
|
after: ['auth']
|
|
283
288
|
});
|
|
284
289
|
}
|
|
290
|
+
this._locales = new _locale.Locale(this);
|
|
285
291
|
(0, _helper.registerMiddlewares)(this, options);
|
|
286
292
|
if (options.registerActions !== false) {
|
|
287
293
|
(0, _actions().registerActions)(this);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getAntdLocale: (lang: any) => any;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAntdLocale = void 0;
|
|
7
|
+
const getAntdLocale = lang => {
|
|
8
|
+
const lng = lang.replace('-', '_');
|
|
9
|
+
try {
|
|
10
|
+
require.resolve(`antd/lib/locale/${lng}`);
|
|
11
|
+
return require(`antd/lib/locale/${lng}`).default;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return require(`antd/lib/locale/en_US`).default;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.getAntdLocale = getAntdLocale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCronLocale: (lang: string) => any;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCronLocale = void 0;
|
|
7
|
+
const getCronLocale = lang => {
|
|
8
|
+
const packageName = '@nocobase/client';
|
|
9
|
+
let locale = null;
|
|
10
|
+
try {
|
|
11
|
+
var _require$cron;
|
|
12
|
+
const file = `${packageName}/src/locale`;
|
|
13
|
+
require.resolve(file);
|
|
14
|
+
locale = (_require$cron = require(file).cron) === null || _require$cron === void 0 ? void 0 : _require$cron[lang];
|
|
15
|
+
} catch (error) {
|
|
16
|
+
try {
|
|
17
|
+
var _require$cron2;
|
|
18
|
+
const file = `${packageName}/lib/locale`;
|
|
19
|
+
require.resolve(file);
|
|
20
|
+
locale = (_require$cron2 = require(file).cron) === null || _require$cron2 === void 0 ? void 0 : _require$cron2[lang];
|
|
21
|
+
} catch (error) {}
|
|
22
|
+
}
|
|
23
|
+
return locale;
|
|
24
|
+
};
|
|
25
|
+
exports.getCronLocale = getCronLocale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCronstrueLocale: (lang: any) => {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCronstrueLocale = void 0;
|
|
7
|
+
const methods = ['atX0SecondsPastTheMinuteGt20', 'atX0MinutesPastTheHourGt20', 'commaMonthX0ThroughMonthX1', 'commaYearX0ThroughYearX1', 'use24HourTimeFormatByDefault', 'anErrorOccuredWhenGeneratingTheExpressionD', 'everyMinute', 'everyHour', 'atSpace', 'everyMinuteBetweenX0AndX1', 'at', 'spaceAnd', 'everySecond', 'everyX0Seconds', 'secondsX0ThroughX1PastTheMinute', 'atX0SecondsPastTheMinute', 'everyX0Minutes', 'minutesX0ThroughX1PastTheHour', 'atX0MinutesPastTheHour', 'everyX0Hours', 'betweenX0AndX1', 'atX0', 'commaEveryDay', 'commaEveryX0DaysOfTheWeek', 'commaX0ThroughX1', 'commaAndX0ThroughX1', 'first', 'second', 'third', 'fourth', 'fifth', 'commaOnThe', 'spaceX0OfTheMonth', 'lastDay', 'commaOnTheLastX0OfTheMonth', 'commaOnlyOnX0', 'commaAndOnX0', 'commaEveryX0Months', 'commaOnlyInX0', 'commaOnTheLastDayOfTheMonth', 'commaOnTheLastWeekdayOfTheMonth', 'commaDaysBeforeTheLastDayOfTheMonth', 'firstWeekday', 'weekdayNearestDayX0', 'commaOnTheX0OfTheMonth', 'commaEveryX0Days', 'commaBetweenDayX0AndX1OfTheMonth', 'commaOnDayX0OfTheMonth', 'commaEveryHour', 'commaEveryX0Years', 'commaStartingX0', 'daysOfTheWeek', 'monthsOfTheYear'];
|
|
8
|
+
const langs = {
|
|
9
|
+
af: 'af',
|
|
10
|
+
ar: 'ar',
|
|
11
|
+
be: 'be',
|
|
12
|
+
ca: 'ca',
|
|
13
|
+
cs: 'cs',
|
|
14
|
+
da: 'da',
|
|
15
|
+
de: 'de',
|
|
16
|
+
'en-US': 'en',
|
|
17
|
+
es: 'es',
|
|
18
|
+
fa: 'fa',
|
|
19
|
+
fi: 'fi',
|
|
20
|
+
fr: 'fr',
|
|
21
|
+
he: 'he',
|
|
22
|
+
hu: 'hu',
|
|
23
|
+
id: 'id',
|
|
24
|
+
it: 'it',
|
|
25
|
+
'ja-JP': 'ja',
|
|
26
|
+
ko: 'ko',
|
|
27
|
+
nb: 'nb',
|
|
28
|
+
nl: 'nl',
|
|
29
|
+
pl: 'pl',
|
|
30
|
+
pt_BR: 'pt_BR',
|
|
31
|
+
pt_PT: 'pt_PT',
|
|
32
|
+
ro: 'ro',
|
|
33
|
+
'ru-RU': 'ru',
|
|
34
|
+
sk: 'sk',
|
|
35
|
+
sl: 'sl',
|
|
36
|
+
sv: 'sv',
|
|
37
|
+
sw: 'sw',
|
|
38
|
+
'th-TH': 'th',
|
|
39
|
+
'tr-TR': 'tr',
|
|
40
|
+
uk: 'uk',
|
|
41
|
+
'zh-CN': 'zh_CN',
|
|
42
|
+
'zh-TW': 'zh_TW'
|
|
43
|
+
};
|
|
44
|
+
const getCronstrueLocale = lang => {
|
|
45
|
+
const lng = langs[lang] || 'en';
|
|
46
|
+
const Locale = require(`cronstrue/locales/${lng}`);
|
|
47
|
+
let locale;
|
|
48
|
+
if (Locale !== null && Locale !== void 0 && Locale.default) {
|
|
49
|
+
locale = Locale.default.locales[lng];
|
|
50
|
+
} else {
|
|
51
|
+
const L = Locale[lng];
|
|
52
|
+
locale = new L();
|
|
53
|
+
}
|
|
54
|
+
const items = {};
|
|
55
|
+
for (var _i = 0, _methods = methods; _i < _methods.length; _i++) {
|
|
56
|
+
const method = _methods[_i];
|
|
57
|
+
try {
|
|
58
|
+
items[method] = locale[method]();
|
|
59
|
+
} catch (error) {}
|
|
60
|
+
}
|
|
61
|
+
return items;
|
|
62
|
+
};
|
|
63
|
+
exports.getCronstrueLocale = getCronstrueLocale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './locale';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _locale = require("./locale");
|
|
7
|
+
Object.keys(_locale).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _locale[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _locale[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Cache } from '@nocobase/cache';
|
|
2
|
+
import Application from '../application';
|
|
3
|
+
export declare class Locale {
|
|
4
|
+
app: Application;
|
|
5
|
+
cache: Cache;
|
|
6
|
+
defaultLang: string;
|
|
7
|
+
constructor(app: Application);
|
|
8
|
+
load(): void;
|
|
9
|
+
get(lang: string): Promise<{
|
|
10
|
+
antd: any;
|
|
11
|
+
cronstrue: any;
|
|
12
|
+
resources: any;
|
|
13
|
+
}>;
|
|
14
|
+
wrapCache(key: string, fn: () => any): Promise<any>;
|
|
15
|
+
getCacheResources(lang: string): Promise<any>;
|
|
16
|
+
getResources(lang: string): {};
|
|
17
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Locale = void 0;
|
|
7
|
+
function _cache() {
|
|
8
|
+
const data = require("@nocobase/cache");
|
|
9
|
+
_cache = function _cache() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _utils() {
|
|
15
|
+
const data = require("@nocobase/utils");
|
|
16
|
+
_utils = function _utils() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
var _pluginManager = require("../plugin-manager");
|
|
22
|
+
var _antd = require("./antd");
|
|
23
|
+
var _cronstrue = require("./cronstrue");
|
|
24
|
+
var _resource = require("./resource");
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
29
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
30
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
31
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
32
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
33
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
34
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
35
|
+
class Locale {
|
|
36
|
+
constructor(app) {
|
|
37
|
+
this.app = void 0;
|
|
38
|
+
this.cache = void 0;
|
|
39
|
+
this.defaultLang = 'en-US';
|
|
40
|
+
this.app = app;
|
|
41
|
+
this.cache = (0, _cache().createCache)();
|
|
42
|
+
this.app.on('afterLoad', () => this.load());
|
|
43
|
+
}
|
|
44
|
+
load() {
|
|
45
|
+
this.getCacheResources(this.defaultLang);
|
|
46
|
+
}
|
|
47
|
+
get(lang) {
|
|
48
|
+
var _this = this;
|
|
49
|
+
return _asyncToGenerator(function* () {
|
|
50
|
+
return {
|
|
51
|
+
antd: yield _this.wrapCache(`locale:antd:${lang}`, () => (0, _antd.getAntdLocale)(lang)),
|
|
52
|
+
cronstrue: yield _this.wrapCache(`locale:cronstrue:${lang}`, () => (0, _cronstrue.getCronstrueLocale)(lang)),
|
|
53
|
+
resources: yield _this.getCacheResources(lang)
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
}
|
|
57
|
+
wrapCache(key, fn) {
|
|
58
|
+
var _this2 = this;
|
|
59
|
+
return _asyncToGenerator(function* () {
|
|
60
|
+
const result = yield _this2.cache.get(key);
|
|
61
|
+
if (result) {
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
const value = yield fn();
|
|
65
|
+
if (_utils().lodash.isEmpty(value)) {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
yield _this2.cache.set(key, value);
|
|
69
|
+
return value;
|
|
70
|
+
})();
|
|
71
|
+
}
|
|
72
|
+
getCacheResources(lang) {
|
|
73
|
+
var _this3 = this;
|
|
74
|
+
return _asyncToGenerator(function* () {
|
|
75
|
+
return yield _this3.wrapCache(`locale:resources:${lang}`, () => _this3.getResources(lang));
|
|
76
|
+
})();
|
|
77
|
+
}
|
|
78
|
+
getResources(lang) {
|
|
79
|
+
const resources = {};
|
|
80
|
+
const plugins = this.app.pm.getPlugins();
|
|
81
|
+
var _iterator = _createForOfIteratorHelper(plugins.keys()),
|
|
82
|
+
_step;
|
|
83
|
+
try {
|
|
84
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
85
|
+
const name = _step.value;
|
|
86
|
+
try {
|
|
87
|
+
const packageName = _pluginManager.PluginManager.getPackageName(name);
|
|
88
|
+
const res = (0, _resource.getResource)(packageName, lang);
|
|
89
|
+
if (res) {
|
|
90
|
+
resources[name] = _objectSpread({}, res);
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {}
|
|
93
|
+
}
|
|
94
|
+
} catch (err) {
|
|
95
|
+
_iterator.e(err);
|
|
96
|
+
} finally {
|
|
97
|
+
_iterator.f();
|
|
98
|
+
}
|
|
99
|
+
const res = (0, _resource.getResource)('@nocobase/client', lang);
|
|
100
|
+
if (res) {
|
|
101
|
+
resources['client'] = _objectSpread(_objectSpread({}, resources['client'] || {}), res);
|
|
102
|
+
}
|
|
103
|
+
return resources;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.Locale = Locale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getResource: (packageName: string, lang: string) => any;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getResource = void 0;
|
|
7
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
const arr2obj = items => {
|
|
11
|
+
const obj = {};
|
|
12
|
+
var _iterator = _createForOfIteratorHelper(items),
|
|
13
|
+
_step;
|
|
14
|
+
try {
|
|
15
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
16
|
+
const item = _step.value;
|
|
17
|
+
Object.assign(obj, item);
|
|
18
|
+
}
|
|
19
|
+
} catch (err) {
|
|
20
|
+
_iterator.e(err);
|
|
21
|
+
} finally {
|
|
22
|
+
_iterator.f();
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
};
|
|
26
|
+
const getResource = (packageName, lang) => {
|
|
27
|
+
const resources = [];
|
|
28
|
+
const prefixes = ['src', 'lib'];
|
|
29
|
+
for (var _i = 0, _prefixes = prefixes; _i < _prefixes.length; _i++) {
|
|
30
|
+
const prefix = _prefixes[_i];
|
|
31
|
+
try {
|
|
32
|
+
const file = `${packageName}/${prefix}/locale/${lang}`;
|
|
33
|
+
require.resolve(file);
|
|
34
|
+
const resource = require(file).default;
|
|
35
|
+
resources.push(resource);
|
|
36
|
+
} catch (error) {}
|
|
37
|
+
if (resources.length) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (resources.length === 0 && lang.replace('-', '_') !== lang) {
|
|
42
|
+
return getResource(packageName, lang.replace('-', '_'));
|
|
43
|
+
}
|
|
44
|
+
return arr2obj(resources);
|
|
45
|
+
};
|
|
46
|
+
exports.getResource = getResource;
|
|
@@ -448,7 +448,10 @@ class PluginManager {
|
|
|
448
448
|
if (!plugin) {
|
|
449
449
|
throw new Error(`${name} plugin does not exist`);
|
|
450
450
|
}
|
|
451
|
-
|
|
451
|
+
if (!plugin.options.installed) {
|
|
452
|
+
yield plugin.install();
|
|
453
|
+
plugin.options.installed = true;
|
|
454
|
+
}
|
|
452
455
|
yield plugin.afterEnable();
|
|
453
456
|
}
|
|
454
457
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "0.11.1-alpha.
|
|
3
|
+
"version": "0.11.1-alpha.3",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"@hapi/topo": "^6.0.0",
|
|
9
9
|
"@koa/cors": "^3.1.0",
|
|
10
10
|
"@koa/router": "^9.4.0",
|
|
11
|
-
"@nocobase/acl": "0.11.1-alpha.
|
|
12
|
-
"@nocobase/actions": "0.11.1-alpha.
|
|
13
|
-
"@nocobase/auth": "0.11.1-alpha.
|
|
14
|
-
"@nocobase/database": "0.11.1-alpha.
|
|
15
|
-
"@nocobase/logger": "0.11.1-alpha.
|
|
16
|
-
"@nocobase/resourcer": "0.11.1-alpha.
|
|
17
|
-
"@nocobase/utils": "0.11.1-alpha.
|
|
11
|
+
"@nocobase/acl": "0.11.1-alpha.3",
|
|
12
|
+
"@nocobase/actions": "0.11.1-alpha.3",
|
|
13
|
+
"@nocobase/auth": "0.11.1-alpha.3",
|
|
14
|
+
"@nocobase/database": "0.11.1-alpha.3",
|
|
15
|
+
"@nocobase/logger": "0.11.1-alpha.3",
|
|
16
|
+
"@nocobase/resourcer": "0.11.1-alpha.3",
|
|
17
|
+
"@nocobase/utils": "0.11.1-alpha.3",
|
|
18
18
|
"chalk": "^4.1.1",
|
|
19
19
|
"commander": "^9.2.0",
|
|
20
20
|
"dayjs": "^1.11.8",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/semver": "^7.3.9"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "5ed3bd7d5b16bd38d268961b34875d5cd45799ef"
|
|
34
34
|
}
|