@nocobase/plugin-locale-tester 1.9.0-alpha.11 → 1.9.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/externalVersion.js +3 -3
- package/dist/node_modules/deepmerge/.editorconfig +7 -0
- package/dist/node_modules/deepmerge/.eslintcache +1 -0
- package/dist/node_modules/deepmerge/dist/cjs.js +1 -0
- package/dist/node_modules/deepmerge/dist/umd.js +139 -0
- package/dist/node_modules/deepmerge/index.d.ts +20 -0
- package/dist/node_modules/deepmerge/index.js +106 -0
- package/dist/node_modules/deepmerge/license.txt +21 -0
- package/dist/node_modules/deepmerge/package.json +1 -0
- package/dist/node_modules/deepmerge/rollup.config.js +22 -0
- package/dist/server/plugin.js +37 -2
- package/package.json +2 -2
package/dist/externalVersion.js
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
|
-
"@nocobase/client": "1.9.0-alpha.
|
|
12
|
+
"@nocobase/client": "1.9.0-alpha.13",
|
|
13
13
|
"antd": "5.24.2",
|
|
14
14
|
"react": "18.2.0",
|
|
15
|
-
"@nocobase/server": "1.9.0-alpha.
|
|
15
|
+
"@nocobase/server": "1.9.0-alpha.13",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
|
-
"@nocobase/database": "1.9.0-alpha.
|
|
17
|
+
"@nocobase/database": "1.9.0-alpha.13"
|
|
18
18
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"/Users/joshduff/code/deepmerge/test/custom-is-mergeable-object.js":"1"},{"size":1990,"mtime":1679007485753,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","suppressedMessages":"6","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"ktjd5k","/Users/joshduff/code/deepmerge/test/custom-is-mergeable-object.js",[],[]]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";var e={323:function(e){var r=function isMergeableObject(e){return isNonNullObject(e)&&!isSpecial(e)};function isNonNullObject(e){return!!e&&typeof e==="object"}function isSpecial(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||isReactElement(e)}var t=typeof Symbol==="function"&&Symbol.for;var n=t?Symbol.for("react.element"):60103;function isReactElement(e){return e.$$typeof===n}function emptyTarget(e){return Array.isArray(e)?[]:{}}function cloneUnlessOtherwiseSpecified(e,r){return r.clone!==false&&r.isMergeableObject(e)?deepmerge(emptyTarget(e),e,r):e}function defaultArrayMerge(e,r,t){return e.concat(r).map((function(e){return cloneUnlessOtherwiseSpecified(e,t)}))}function getMergeFunction(e,r){if(!r.customMerge){return deepmerge}var t=r.customMerge(e);return typeof t==="function"?t:deepmerge}function getEnumerableOwnPropertySymbols(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(r){return Object.propertyIsEnumerable.call(e,r)})):[]}function getKeys(e){return Object.keys(e).concat(getEnumerableOwnPropertySymbols(e))}function propertyIsOnObject(e,r){try{return r in e}catch(e){return false}}function propertyIsUnsafe(e,r){return propertyIsOnObject(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function mergeObject(e,r,t){var n={};if(t.isMergeableObject(e)){getKeys(e).forEach((function(r){n[r]=cloneUnlessOtherwiseSpecified(e[r],t)}))}getKeys(r).forEach((function(c){if(propertyIsUnsafe(e,c)){return}if(propertyIsOnObject(e,c)&&t.isMergeableObject(r[c])){n[c]=getMergeFunction(c,t)(e[c],r[c],t)}else{n[c]=cloneUnlessOtherwiseSpecified(r[c],t)}}));return n}function deepmerge(e,t,n){n=n||{};n.arrayMerge=n.arrayMerge||defaultArrayMerge;n.isMergeableObject=n.isMergeableObject||r;n.cloneUnlessOtherwiseSpecified=cloneUnlessOtherwiseSpecified;var c=Array.isArray(t);var i=Array.isArray(e);var o=c===i;if(!o){return cloneUnlessOtherwiseSpecified(t,n)}else if(c){return n.arrayMerge(e,t,n)}else{return mergeObject(e,t,n)}}deepmerge.all=function deepmergeAll(e,r){if(!Array.isArray(e)){throw new Error("first argument should be an array")}return e.reduce((function(e,t){return deepmerge(e,t,r)}),{})};var c=deepmerge;e.exports=c}};var r={};function __nccwpck_require__(t){var n=r[t];if(n!==undefined){return n.exports}var c=r[t]={exports:{}};var i=true;try{e[t](c,c.exports,__nccwpck_require__);i=false}finally{if(i)delete r[t]}return c.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(323);module.exports=t})();
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = global || self, global.deepmerge = factory());
|
|
5
|
+
}(this, function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
var isMergeableObject = function isMergeableObject(value) {
|
|
8
|
+
return isNonNullObject(value)
|
|
9
|
+
&& !isSpecial(value)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function isNonNullObject(value) {
|
|
13
|
+
return !!value && typeof value === 'object'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isSpecial(value) {
|
|
17
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
18
|
+
|
|
19
|
+
return stringValue === '[object RegExp]'
|
|
20
|
+
|| stringValue === '[object Date]'
|
|
21
|
+
|| isReactElement(value)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
25
|
+
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
26
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
27
|
+
|
|
28
|
+
function isReactElement(value) {
|
|
29
|
+
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function emptyTarget(val) {
|
|
33
|
+
return Array.isArray(val) ? [] : {}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
37
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
38
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
39
|
+
: value
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function defaultArrayMerge(target, source, options) {
|
|
43
|
+
return target.concat(source).map(function(element) {
|
|
44
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getMergeFunction(key, options) {
|
|
49
|
+
if (!options.customMerge) {
|
|
50
|
+
return deepmerge
|
|
51
|
+
}
|
|
52
|
+
var customMerge = options.customMerge(key);
|
|
53
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
57
|
+
return Object.getOwnPropertySymbols
|
|
58
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
59
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
60
|
+
})
|
|
61
|
+
: []
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getKeys(target) {
|
|
65
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function propertyIsOnObject(object, property) {
|
|
69
|
+
try {
|
|
70
|
+
return property in object
|
|
71
|
+
} catch(_) {
|
|
72
|
+
return false
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
77
|
+
function propertyIsUnsafe(target, key) {
|
|
78
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
79
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
80
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function mergeObject(target, source, options) {
|
|
84
|
+
var destination = {};
|
|
85
|
+
if (options.isMergeableObject(target)) {
|
|
86
|
+
getKeys(target).forEach(function(key) {
|
|
87
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
getKeys(source).forEach(function(key) {
|
|
91
|
+
if (propertyIsUnsafe(target, key)) {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
96
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
97
|
+
} else {
|
|
98
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return destination
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function deepmerge(target, source, options) {
|
|
105
|
+
options = options || {};
|
|
106
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
107
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
108
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
109
|
+
// implementations can use it. The caller may not replace it.
|
|
110
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
111
|
+
|
|
112
|
+
var sourceIsArray = Array.isArray(source);
|
|
113
|
+
var targetIsArray = Array.isArray(target);
|
|
114
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
115
|
+
|
|
116
|
+
if (!sourceAndTargetTypesMatch) {
|
|
117
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
118
|
+
} else if (sourceIsArray) {
|
|
119
|
+
return options.arrayMerge(target, source, options)
|
|
120
|
+
} else {
|
|
121
|
+
return mergeObject(target, source, options)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
126
|
+
if (!Array.isArray(array)) {
|
|
127
|
+
throw new Error('first argument should be an array')
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return array.reduce(function(prev, next) {
|
|
131
|
+
return deepmerge(prev, next, options)
|
|
132
|
+
}, {})
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
var deepmerge_1 = deepmerge;
|
|
136
|
+
|
|
137
|
+
return deepmerge_1;
|
|
138
|
+
|
|
139
|
+
}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare function deepmerge<T>(x: Partial<T>, y: Partial<T>, options?: deepmerge.Options): T;
|
|
2
|
+
declare function deepmerge<T1, T2>(x: Partial<T1>, y: Partial<T2>, options?: deepmerge.Options): T1 & T2;
|
|
3
|
+
|
|
4
|
+
declare namespace deepmerge {
|
|
5
|
+
export interface Options {
|
|
6
|
+
arrayMerge?(target: any[], source: any[], options?: ArrayMergeOptions): any[];
|
|
7
|
+
clone?: boolean;
|
|
8
|
+
customMerge?: (key: string, options?: Options) => ((x: any, y: any) => any) | undefined;
|
|
9
|
+
isMergeableObject?(value: object): boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ArrayMergeOptions {
|
|
12
|
+
isMergeableObject(value: object): boolean;
|
|
13
|
+
cloneUnlessOtherwiseSpecified(value: object, options?: Options): object;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function all (objects: object[], options?: Options): object;
|
|
17
|
+
export function all<T> (objects: Partial<T>[], options?: Options): T;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export = deepmerge;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var defaultIsMergeableObject = require('is-mergeable-object')
|
|
2
|
+
|
|
3
|
+
function emptyTarget(val) {
|
|
4
|
+
return Array.isArray(val) ? [] : {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
8
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
9
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
10
|
+
: value
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function defaultArrayMerge(target, source, options) {
|
|
14
|
+
return target.concat(source).map(function(element) {
|
|
15
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getMergeFunction(key, options) {
|
|
20
|
+
if (!options.customMerge) {
|
|
21
|
+
return deepmerge
|
|
22
|
+
}
|
|
23
|
+
var customMerge = options.customMerge(key)
|
|
24
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
28
|
+
return Object.getOwnPropertySymbols
|
|
29
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
30
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
31
|
+
})
|
|
32
|
+
: []
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getKeys(target) {
|
|
36
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function propertyIsOnObject(object, property) {
|
|
40
|
+
try {
|
|
41
|
+
return property in object
|
|
42
|
+
} catch(_) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
48
|
+
function propertyIsUnsafe(target, key) {
|
|
49
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
50
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
51
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function mergeObject(target, source, options) {
|
|
55
|
+
var destination = {}
|
|
56
|
+
if (options.isMergeableObject(target)) {
|
|
57
|
+
getKeys(target).forEach(function(key) {
|
|
58
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options)
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
getKeys(source).forEach(function(key) {
|
|
62
|
+
if (propertyIsUnsafe(target, key)) {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
67
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options)
|
|
68
|
+
} else {
|
|
69
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
return destination
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function deepmerge(target, source, options) {
|
|
76
|
+
options = options || {}
|
|
77
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge
|
|
78
|
+
options.isMergeableObject = options.isMergeableObject || defaultIsMergeableObject
|
|
79
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
80
|
+
// implementations can use it. The caller may not replace it.
|
|
81
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified
|
|
82
|
+
|
|
83
|
+
var sourceIsArray = Array.isArray(source)
|
|
84
|
+
var targetIsArray = Array.isArray(target)
|
|
85
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray
|
|
86
|
+
|
|
87
|
+
if (!sourceAndTargetTypesMatch) {
|
|
88
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
89
|
+
} else if (sourceIsArray) {
|
|
90
|
+
return options.arrayMerge(target, source, options)
|
|
91
|
+
} else {
|
|
92
|
+
return mergeObject(target, source, options)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
97
|
+
if (!Array.isArray(array)) {
|
|
98
|
+
throw new Error('first argument should be an array')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return array.reduce(function(prev, next) {
|
|
102
|
+
return deepmerge(prev, next, options)
|
|
103
|
+
}, {})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = deepmerge
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"deepmerge","description":"A library for deep (recursive) merging of Javascript objects","keywords":["merge","deep","extend","copy","clone","recursive"],"version":"4.3.1","homepage":"https://github.com/TehShrike/deepmerge","repository":{"type":"git","url":"git://github.com/TehShrike/deepmerge.git"},"main":"dist/cjs.js","engines":{"node":">=0.10.0"},"scripts":{"build":"rollup -c","test":"npm run build && tape test/*.js && jsmd readme.md && npm run test:typescript","test:typescript":"tsc --noEmit test/typescript.ts && ts-node test/typescript.ts","size":"npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"},"devDependencies":{"@types/node":"^8.10.54","is-mergeable-object":"1.1.0","is-plain-object":"^5.0.0","jsmd":"^1.0.2","rollup":"^1.23.1","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","tape":"^4.11.0","ts-node":"7.0.1","typescript":"=2.2.2","uglify-js":"^3.6.1"},"license":"MIT","_lastModified":"2025-09-09T04:53:47.713Z"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import resolve from 'rollup-plugin-node-resolve'
|
|
2
|
+
import commonjs from 'rollup-plugin-commonjs'
|
|
3
|
+
import pkg from './package.json'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
input: `index.js`,
|
|
7
|
+
plugins: [
|
|
8
|
+
commonjs(),
|
|
9
|
+
resolve(),
|
|
10
|
+
],
|
|
11
|
+
output: [
|
|
12
|
+
{
|
|
13
|
+
file: pkg.main,
|
|
14
|
+
format: `cjs`
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'deepmerge',
|
|
18
|
+
file: 'dist/umd.js',
|
|
19
|
+
format: `umd`
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
}
|
package/dist/server/plugin.js
CHANGED
|
@@ -41,7 +41,22 @@ __export(plugin_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(plugin_exports);
|
|
43
43
|
var import_server = require("@nocobase/server");
|
|
44
|
+
var import_deepmerge = __toESM(require("deepmerge"));
|
|
44
45
|
var import_lodash = __toESM(require("lodash"));
|
|
46
|
+
async function getLang(ctx) {
|
|
47
|
+
const SystemSetting = ctx.db.getRepository("systemSettings");
|
|
48
|
+
const systemSetting = await SystemSetting.findOne();
|
|
49
|
+
const enabledLanguages = systemSetting.get("enabledLanguages") || [];
|
|
50
|
+
const currentUser = ctx.state.currentUser;
|
|
51
|
+
let lang = (enabledLanguages == null ? void 0 : enabledLanguages[0]) || process.env.APP_LANG || "en-US";
|
|
52
|
+
if (enabledLanguages.includes(currentUser == null ? void 0 : currentUser.appLang)) {
|
|
53
|
+
lang = currentUser == null ? void 0 : currentUser.appLang;
|
|
54
|
+
}
|
|
55
|
+
if (ctx.request.query.locale && enabledLanguages.includes(ctx.request.query.locale)) {
|
|
56
|
+
lang = ctx.request.query.locale;
|
|
57
|
+
}
|
|
58
|
+
return lang;
|
|
59
|
+
}
|
|
45
60
|
class PluginLocaleTesterServer extends import_server.Plugin {
|
|
46
61
|
async afterAdd() {
|
|
47
62
|
}
|
|
@@ -55,7 +70,27 @@ class PluginLocaleTesterServer extends import_server.Plugin {
|
|
|
55
70
|
this.app.resourceManager.use(async (ctx, next) => {
|
|
56
71
|
await next();
|
|
57
72
|
const { resourceName, actionName } = ctx.action;
|
|
58
|
-
if (resourceName === "
|
|
73
|
+
if (resourceName === "localeTester" && actionName === "get") {
|
|
74
|
+
const lang = await getLang(ctx);
|
|
75
|
+
const data = await ctx.app.localeManager.get(lang);
|
|
76
|
+
const locale = {};
|
|
77
|
+
Object.keys(data.resources).forEach((key) => {
|
|
78
|
+
if (key.startsWith("@")) {
|
|
79
|
+
locale[key] = data.resources[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const merged = (0, import_deepmerge.default)(locale, ctx.body.locale || {});
|
|
83
|
+
if (!merged["cronstrue"]) {
|
|
84
|
+
merged["cronstrue"] = data.cronstrue;
|
|
85
|
+
}
|
|
86
|
+
if (!merged["react-js-cron"]) {
|
|
87
|
+
merged["react-js-cron"] = data["cron"];
|
|
88
|
+
}
|
|
89
|
+
ctx.body = {
|
|
90
|
+
...ctx.body.toJSON(),
|
|
91
|
+
locale: merged
|
|
92
|
+
};
|
|
93
|
+
} else if (resourceName === "app" && actionName === "getLang") {
|
|
59
94
|
const repository = this.db.getRepository("localeTester");
|
|
60
95
|
const record = await repository.findOne();
|
|
61
96
|
const locale = (record == null ? void 0 : record.locale) || {};
|
|
@@ -71,7 +106,7 @@ class PluginLocaleTesterServer extends import_server.Plugin {
|
|
|
71
106
|
}
|
|
72
107
|
const value = locale[key];
|
|
73
108
|
import_lodash.default.set(ctx.body, ["resources", key], value);
|
|
74
|
-
const k = key.replace("@nocobase/", "").replace("@nocobase/
|
|
109
|
+
const k = key.replace("@nocobase/plugin-", "").replace("@nocobase/", "");
|
|
75
110
|
import_lodash.default.set(ctx.body, ["resources", k], value);
|
|
76
111
|
});
|
|
77
112
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-locale-tester",
|
|
3
3
|
"displayName": "Locale tester",
|
|
4
4
|
"displayName.zh-CN": "翻译测试工具",
|
|
5
|
-
"version": "1.9.0-alpha.
|
|
5
|
+
"version": "1.9.0-alpha.13",
|
|
6
6
|
"homepage": "https://github.com/nocobase/locales",
|
|
7
7
|
"main": "dist/server/index.js",
|
|
8
8
|
"peerDependencies": {
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
"@nocobase/server": "1.x",
|
|
11
11
|
"@nocobase/test": "1.x"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "e981abb387c32b94e010424718df66283279d67d"
|
|
14
14
|
}
|