@aidc-toolkit/core 0.9.14-beta → 0.9.16-beta

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/index.d.ts CHANGED
@@ -1,60 +1,18 @@
1
- import { i18n, Resource } from 'i18next';
2
-
3
- /**
4
- * Internationalization operating environment.
5
- */
6
- declare enum I18NEnvironment {
7
- /**
8
- * Command-line interface (e.g., unit tests).
9
- */
10
- CLI = 0,
11
- /**
12
- * Web server.
13
- */
14
- Server = 1,
15
- /**
16
- * Web browser.
17
- */
18
- Browser = 2
19
- }
20
- /**
21
- * Assert that language resources are a type match for English (default) resources.
22
- *
23
- * @param enResources
24
- * English resources.
25
- *
26
- * @param lng
27
- * Language.
28
- *
29
- * @param lngResources
30
- * Language resources.
31
- *
32
- * @param parent
33
- * Parent key name (set recursively).
34
- */
35
- declare function i18nAssertValidResources(enResources: object, lng: string, lngResources: object, parent?: string): void;
36
- /**
37
- * Initialize internationalization.
38
- *
39
- * @param i18next
40
- * Internationalization object. As multiple objects exists, this parameter represents the one for the module for which
41
- * internationalization is being initialized.
42
- *
43
- * @param environment
44
- * Environment in which the application is running.
45
- *
46
- * @param debug
47
- * Debug setting.
1
+ /*!
2
+ * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
3
+ * contributors
48
4
  *
49
- * @param defaultNS
50
- * Default namespace.
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
51
8
  *
52
- * @param resources
53
- * Resources.
9
+ * https://www.apache.org/licenses/LICENSE-2.0
54
10
  *
55
- * @returns
56
- * Void promise.
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
57
16
  */
58
- declare function i18nCoreInit(i18next: i18n, environment: I18NEnvironment, debug: boolean, defaultNS: string, ...resources: Resource[]): Promise<void>;
59
-
60
- export { I18NEnvironment, i18nAssertValidResources, i18nCoreInit };
17
+ export * from "./locale/i18n.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import l from"i18next-browser-languagedetector";import p from"i18next-cli-language-detector";var w=(e=>(e[e.CLI=0]="CLI",e[e.Server=1]="Server",e[e.Browser=2]="Browser",e))(w||{});function $(s,r,g,e){let u=new Map(Object.entries(s)),t=new Map(Object.entries(g)),i=r.includes("-");for(let[o,n]of u){let c=t.get(o);if(c!==void 0){let a=typeof n,f=typeof c;if(f!==a)throw new Error(`Invalid value type ${f} for key ${e===void 0?"":`${e}.`}${o} in ${r} resources`);a==="object"&&$(n,r,c,`${e===void 0?"":`${e}.`}${o}`)}else if(!i)throw new Error(`Missing key ${e===void 0?"":`${e}.`}${o} from ${r} resources`)}for(let[o]of t)if(!u.has(o))throw new Error(`Extraneous key ${e===void 0?"":`${e}.`}${o} in ${r} resources`)}function y(s){return s.split(" ").map(r=>/[a-z]/.test(r)?r.toLowerCase():r).join(" ")}async function b(s,r,g,e,...u){if(!s.isInitialized){let t={};for(let o of u)for(let[n,c]of Object.entries(o)){n in t||(t[n]={});let a=t[n];for(let[f,d]of Object.entries(c))a[f]=d}let i;switch(r){case 0:i=p;break;case 2:i=l;break;default:throw new Error("Not supported")}await s.use(i).init({debug:g,resources:t,fallbackLng:"en",defaultNS:e}).then(()=>{s.services.formatter?.add("toLowerCase",o=>typeof o=="string"?y(o):String(o))})}}export{w as I18NEnvironment,$ as i18nAssertValidResources,b as i18nCoreInit};
2
1
  /*!
3
2
  * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
4
3
  * contributors
@@ -15,3 +14,5 @@ import l from"i18next-browser-languagedetector";import p from"i18next-cli-langua
15
14
  * See the License for the specific language governing permissions and
16
15
  * limitations under the License.
17
16
  */
17
+ export * from "./locale/i18n.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,kBAAkB,CAAC"}
@@ -1,9 +1,14 @@
1
- import { i18n, Resource } from 'i18next';
2
-
1
+ import type { i18n, Resource } from "i18next";
2
+ /**
3
+ * Locale strings type for generic manipulation.
4
+ */
5
+ export interface LocaleStrings {
6
+ [key: string]: LocaleStrings | string;
7
+ }
3
8
  /**
4
9
  * Internationalization operating environment.
5
10
  */
6
- declare enum I18NEnvironment {
11
+ export declare enum I18NEnvironment {
7
12
  /**
8
13
  * Command-line interface (e.g., unit tests).
9
14
  */
@@ -32,7 +37,7 @@ declare enum I18NEnvironment {
32
37
  * @param parent
33
38
  * Parent key name (set recursively).
34
39
  */
35
- declare function i18nAssertValidResources(enResources: object, lng: string, lngResources: object, parent?: string): void;
40
+ export declare function i18nAssertValidResources(enResources: object, lng: string, lngResources: object, parent?: string): void;
36
41
  /**
37
42
  * Initialize internationalization.
38
43
  *
@@ -55,6 +60,5 @@ declare function i18nAssertValidResources(enResources: object, lng: string, lngR
55
60
  * @returns
56
61
  * Void promise.
57
62
  */
58
- declare function i18nCoreInit(i18next: i18n, environment: I18NEnvironment, debug: boolean, defaultNS: string, ...resources: Resource[]): Promise<void>;
59
-
60
- export { I18NEnvironment, i18nAssertValidResources, i18nCoreInit };
63
+ export declare function i18nCoreInit(i18next: i18n, environment: I18NEnvironment, debug: boolean, defaultNS: string, ...resources: Resource[]): Promise<void>;
64
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA0B,QAAQ,EAAE,MAAM,SAAS,CAAC;AAItE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;CACzC;AAED;;GAEG;AACH,oBAAY,eAAe;IACvB;;OAEG;IACH,GAAG,IAAA;IAEH;;OAEG;IACH,MAAM,IAAA;IAEN;;OAEG;IACH,OAAO,IAAA;CACV;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CA+BtH;AAgBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiD1J"}
@@ -0,0 +1,140 @@
1
+ import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
2
+ import I18nextCLILanguageDetector from "i18next-cli-language-detector";
3
+ /**
4
+ * Internationalization operating environment.
5
+ */
6
+ export var I18NEnvironment;
7
+ (function (I18NEnvironment) {
8
+ /**
9
+ * Command-line interface (e.g., unit tests).
10
+ */
11
+ I18NEnvironment[I18NEnvironment["CLI"] = 0] = "CLI";
12
+ /**
13
+ * Web server.
14
+ */
15
+ I18NEnvironment[I18NEnvironment["Server"] = 1] = "Server";
16
+ /**
17
+ * Web browser.
18
+ */
19
+ I18NEnvironment[I18NEnvironment["Browser"] = 2] = "Browser";
20
+ })(I18NEnvironment || (I18NEnvironment = {}));
21
+ /**
22
+ * Assert that language resources are a type match for English (default) resources.
23
+ *
24
+ * @param enResources
25
+ * English resources.
26
+ *
27
+ * @param lng
28
+ * Language.
29
+ *
30
+ * @param lngResources
31
+ * Language resources.
32
+ *
33
+ * @param parent
34
+ * Parent key name (set recursively).
35
+ */
36
+ export function i18nAssertValidResources(enResources, lng, lngResources, parent) {
37
+ const enResourcesMap = new Map(Object.entries(enResources));
38
+ const lngResourcesMap = new Map(Object.entries(lngResources));
39
+ const isLocale = lng.includes("-");
40
+ for (const [enKey, enValue] of enResourcesMap) {
41
+ const lngValue = lngResourcesMap.get(enKey);
42
+ if (lngValue !== undefined) {
43
+ const enValueType = typeof enValue;
44
+ const lngValueType = typeof lngValue;
45
+ if (lngValueType !== enValueType) {
46
+ throw new Error(`Invalid value type ${lngValueType} for key ${parent === undefined ? "" : `${parent}.`}${enKey} in ${lng} resources`);
47
+ }
48
+ if (enValueType === "object") {
49
+ i18nAssertValidResources(enValue, lng, lngValue, `${parent === undefined ? "" : `${parent}.`}${enKey}`);
50
+ }
51
+ // Locale falls back to raw language so ignore if missing.
52
+ }
53
+ else if (!isLocale) {
54
+ throw new Error(`Missing key ${parent === undefined ? "" : `${parent}.`}${enKey} from ${lng} resources`);
55
+ }
56
+ }
57
+ for (const [lngKey] of lngResourcesMap) {
58
+ if (!enResourcesMap.has(lngKey)) {
59
+ throw new Error(`Extraneous key ${parent === undefined ? "" : `${parent}.`}${lngKey} in ${lng} resources`);
60
+ }
61
+ }
62
+ }
63
+ /**
64
+ * Convert a string to lower case, skipping words that are all upper case.
65
+ *
66
+ * @param s
67
+ * String.
68
+ *
69
+ * @returns
70
+ * Lower case string.
71
+ */
72
+ function toLowerCase(s) {
73
+ // Words with no lower case letters are preserved as they are likely mnemonics.
74
+ return s.split(" ").map(word => /[a-z]/.test(word) ? word.toLowerCase() : word).join(" ");
75
+ }
76
+ /**
77
+ * Initialize internationalization.
78
+ *
79
+ * @param i18next
80
+ * Internationalization object. As multiple objects exists, this parameter represents the one for the module for which
81
+ * internationalization is being initialized.
82
+ *
83
+ * @param environment
84
+ * Environment in which the application is running.
85
+ *
86
+ * @param debug
87
+ * Debug setting.
88
+ *
89
+ * @param defaultNS
90
+ * Default namespace.
91
+ *
92
+ * @param resources
93
+ * Resources.
94
+ *
95
+ * @returns
96
+ * Void promise.
97
+ */
98
+ export async function i18nCoreInit(i18next, environment, debug, defaultNS, ...resources) {
99
+ // Initialization may be called more than once.
100
+ if (!i18next.isInitialized) {
101
+ const mergedResource = {};
102
+ // Merge resources.
103
+ for (const resource of resources) {
104
+ // Merge languages.
105
+ for (const [language, resourceLanguage] of Object.entries(resource)) {
106
+ if (!(language in mergedResource)) {
107
+ mergedResource[language] = {};
108
+ }
109
+ const mergedResourceLanguage = mergedResource[language];
110
+ // Merge namespaces.
111
+ for (const [namespace, resourceKey] of Object.entries(resourceLanguage)) {
112
+ mergedResourceLanguage[namespace] = resourceKey;
113
+ }
114
+ }
115
+ }
116
+ let module;
117
+ switch (environment) {
118
+ case I18NEnvironment.CLI:
119
+ // TODO Refactor when https://github.com/neet/i18next-cli-language-detector/issues/281 resolved.
120
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Per above.
121
+ module = I18nextCLILanguageDetector;
122
+ break;
123
+ case I18NEnvironment.Browser:
124
+ module = I18nextBrowserLanguageDetector;
125
+ break;
126
+ default:
127
+ throw new Error("Not supported");
128
+ }
129
+ await i18next.use(module).init({
130
+ debug,
131
+ resources: mergedResource,
132
+ fallbackLng: "en",
133
+ defaultNS
134
+ }).then(() => {
135
+ // Add toLowerCase function.
136
+ i18next.services.formatter?.add("toLowerCase", value => typeof value === "string" ? toLowerCase(value) : String(value));
137
+ });
138
+ }
139
+ }
140
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AACA,OAAO,8BAA8B,MAAM,kCAAkC,CAAC;AAC9E,OAAO,0BAA0B,MAAM,+BAA+B,CAAC;AASvE;;GAEG;AACH,MAAM,CAAN,I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AAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/core",
3
- "version": "0.9.14-beta",
3
+ "version": "0.9.16-beta",
4
4
  "description": "Core functionality for AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
- "homepage": "https://github.com/aidc-toolkit",
7
+ "homepage": "https://aidc-toolkit.com/",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/aidc-toolkit/core.git"
@@ -21,18 +21,18 @@
21
21
  "scripts": {
22
22
  "update-aidc-toolkit": "npm update @aidc-toolkit/dev",
23
23
  "lint": "eslint",
24
- "build:core": "tsup --config node_modules/@aidc-toolkit/dev/tsup.config.ts",
25
- "build:dev": "npm run build:core && tsc --project node_modules/@aidc-toolkit/dev/tsconfig-declaration.json",
26
- "build:release": "npm run build:core -- --minify",
24
+ "build:core": "rimraf dist && tsc --project",
25
+ "build:dev": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build-dev.json",
26
+ "build:release": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build.json",
27
27
  "build:doc": "npm run build:dev",
28
28
  "publish-dev": "publish-dev"
29
29
  },
30
30
  "devDependencies": {
31
- "@aidc-toolkit/dev": "^0.9.14-beta"
31
+ "@aidc-toolkit/dev": "^0.9.16-beta"
32
32
  },
33
33
  "dependencies": {
34
34
  "i18next": "^24.2.2",
35
- "i18next-browser-languagedetector": "^8.0.3",
35
+ "i18next-browser-languagedetector": "^8.0.4",
36
36
  "i18next-cli-language-detector": "^1.1.8"
37
37
  }
38
38
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -2,6 +2,13 @@ import type { i18n, LanguageDetectorModule, Resource } from "i18next";
2
2
  import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
3
3
  import I18nextCLILanguageDetector from "i18next-cli-language-detector";
4
4
 
5
+ /**
6
+ * Locale strings type for generic manipulation.
7
+ */
8
+ export interface LocaleStrings {
9
+ [key: string]: LocaleStrings | string;
10
+ }
11
+
5
12
  /**
6
13
  * Internationalization operating environment.
7
14
  */
package/dist/index.cjs DELETED
@@ -1,17 +0,0 @@
1
- "use strict";var b=Object.create;var d=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var x=(o,e)=>{for(var t in e)d(o,t,{get:e[t],enumerable:!0})},l=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R(e))!k.call(o,n)&&n!==t&&d(o,n,{get:()=>e[n],enumerable:!(r=j(e,n))||r.enumerable});return o};var p=(o,e,t)=>(t=o!=null?b(h(o)):{},l(e||!o||!o.__esModule?d(t,"default",{value:o,enumerable:!0}):t,o)),C=o=>l(d({},"__esModule",{value:!0}),o);var V={};x(V,{I18NEnvironment:()=>y,i18nAssertValidResources:()=>m,i18nCoreInit:()=>I});module.exports=C(V);var w=p(require("i18next-browser-languagedetector"),1),$=p(require("i18next-cli-language-detector"),1),y=(r=>(r[r.CLI=0]="CLI",r[r.Server=1]="Server",r[r.Browser=2]="Browser",r))(y||{});function m(o,e,t,r){let n=new Map(Object.entries(o)),i=new Map(Object.entries(t)),u=e.includes("-");for(let[s,c]of n){let a=i.get(s);if(a!==void 0){let f=typeof c,g=typeof a;if(g!==f)throw new Error(`Invalid value type ${g} for key ${r===void 0?"":`${r}.`}${s} in ${e} resources`);f==="object"&&m(c,e,a,`${r===void 0?"":`${r}.`}${s}`)}else if(!u)throw new Error(`Missing key ${r===void 0?"":`${r}.`}${s} from ${e} resources`)}for(let[s]of i)if(!n.has(s))throw new Error(`Extraneous key ${r===void 0?"":`${r}.`}${s} in ${e} resources`)}function M(o){return o.split(" ").map(e=>/[a-z]/.test(e)?e.toLowerCase():e).join(" ")}async function I(o,e,t,r,...n){if(!o.isInitialized){let i={};for(let s of n)for(let[c,a]of Object.entries(s)){c in i||(i[c]={});let f=i[c];for(let[g,L]of Object.entries(a))f[g]=L}let u;switch(e){case 0:u=$.default;break;case 2:u=w.default;break;default:throw new Error("Not supported")}await o.use(u).init({debug:t,resources:i,fallbackLng:"en",defaultNS:r}).then(()=>{o.services.formatter?.add("toLowerCase",s=>typeof s=="string"?M(s):String(s))})}}0&&(module.exports={I18NEnvironment,i18nAssertValidResources,i18nCoreInit});
2
- /*!
3
- * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
4
- * contributors
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * https://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
Binary file
Binary file
Binary file
Binary file
Binary file