@aidc-toolkit/core 0.9.0 → 0.9.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.
@@ -0,0 +1,12 @@
1
+ <component name="ProjectRunConfigurationManager">
2
+ <configuration default="false" name="build-dev" type="js.build_tools.npm" nameIsGenerated="true">
3
+ <package-json value="$PROJECT_DIR$/package.json" />
4
+ <command value="run" />
5
+ <scripts>
6
+ <script value="build-dev" />
7
+ </scripts>
8
+ <node-interpreter value="project" />
9
+ <envs />
10
+ <method v="2" />
11
+ </configuration>
12
+ </component>
package/eslint.config.js CHANGED
@@ -1,15 +1,13 @@
1
1
  import tseslint from "typescript-eslint";
2
- import js from "@eslint/js";
3
2
  import stylistic from "@stylistic/eslint-plugin";
4
3
  import jsdoc from "eslint-plugin-jsdoc";
5
4
  import esLintConfigLove from "eslint-config-love";
6
5
  import { esLintConfigAIDCToolkit } from "@aidc-toolkit/dev";
7
6
 
8
7
  export default tseslint.config(
9
- js.configs.recommended,
10
8
  ...tseslint.configs.strictTypeChecked,
11
9
  stylistic.configs["recommended-flat"],
12
10
  jsdoc.configs["flat/recommended-typescript"],
13
11
  esLintConfigLove,
14
- esLintConfigAIDCToolkit
12
+ ...esLintConfigAIDCToolkit
15
13
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/core",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Core functionality for AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,23 +20,21 @@
20
20
  },
21
21
  "scripts": {
22
22
  "eslint": "eslint .",
23
- "build": "tsup src/index.ts --format cjs,esm --dts",
24
- "test": "vitest run"
23
+ "build": "tsup src/index.ts --clean --format cjs,esm --dts",
24
+ "build-dev": "npm run build && tsc src/index.ts --outDir dist --target esnext --moduleResolution nodenext --module nodenext --emitDeclarationOnly --declaration --declarationMap"
25
25
  },
26
26
  "devDependencies": {
27
- "@aidc-toolkit/dev": "^0.9.0",
28
- "@eslint/js": "^9.10.0",
29
- "@stylistic/eslint-plugin": "^2.7.2",
30
- "eslint-config-love": "^64.0.0",
31
- "eslint-plugin-jsdoc": "^50.2.2",
27
+ "@aidc-toolkit/dev": "^0.9.2",
28
+ "@stylistic/eslint-plugin": "^2.10.1",
29
+ "eslint-config-love": "^98.0.2",
30
+ "eslint-plugin-jsdoc": "^50.5.0",
32
31
  "ts-node": "^10.9.2",
33
- "tsup": "^8.2.4",
34
- "typescript": "^5.5.4",
35
- "typescript-eslint": "^8.4.0",
36
- "vitest": "^2.0.5"
32
+ "tsup": "^8.3.5",
33
+ "typescript": "^5.6.3",
34
+ "typescript-eslint": "^8.14.0"
37
35
  },
38
36
  "dependencies": {
39
- "i18next": "^23.14.0",
37
+ "i18next": "^23.16.5",
40
38
  "i18next-browser-languagedetector": "^8.0.0",
41
39
  "i18next-cli-language-detector": "^1.1.8"
42
40
  }
@@ -1,5 +1,5 @@
1
1
  import i18next from "i18next";
2
- import I18nextBrowserLanguageDetector from "i18next-browser-languageDetector";
2
+ import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
3
3
  import I18nextCLILanguageDetector from "i18next-cli-language-detector";
4
4
 
5
5
  export default i18next;
@@ -46,9 +46,17 @@ export enum I18NEnvironment {
46
46
  *
47
47
  * @param debug
48
48
  * Debug setting.
49
+ *
50
+ * @returns
51
+ * True if initialization was completed, false if skipped (already initialized).
49
52
  */
50
- export async function i18nInit(environment: I18NEnvironment, debug = false): Promise<void> {
53
+ export async function i18nInit(environment: I18NEnvironment, debug = false): Promise<boolean> {
54
+ let initialized: boolean;
55
+
56
+ // Skip if initialization is not pending.
51
57
  if (pendingResourceBundles !== undefined) {
58
+ initialized = true;
59
+
52
60
  let module: object;
53
61
 
54
62
  switch (environment) {
@@ -64,25 +72,26 @@ export async function i18nInit(environment: I18NEnvironment, debug = false): Pro
64
72
  throw new Error("Not supported");
65
73
  }
66
74
 
75
+ const initResourceBundles = pendingResourceBundles;
76
+
77
+ // No need to manage pending resource bundles past this point.
78
+ pendingResourceBundles = undefined;
79
+
67
80
  await i18next.use(module as never).init({
68
81
  fallbackLng: "en",
69
82
  debug,
70
83
  resources: {}
71
84
  }).then(() => {
72
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
73
- const initResourceBundles = pendingResourceBundles!;
74
-
75
- // No need to manage pending resource bundles past this point.
76
- pendingResourceBundles = undefined;
77
-
78
85
  // Add pending resource bundles.
79
- initResourceBundles.forEach((initResourceBundle) => {
86
+ for (const initResourceBundle of initResourceBundles) {
80
87
  i18nAddResourceBundle(initResourceBundle.lng, initResourceBundle.ns, initResourceBundle.resources);
81
- });
88
+ }
82
89
  });
83
90
  } else {
84
- throw new Error("i18n already initialized");
91
+ initialized = false;
85
92
  }
93
+
94
+ return initialized;
86
95
  }
87
96
 
88
97
  /**
package/typedoc.json CHANGED
@@ -6,5 +6,6 @@
6
6
  "name": "Core",
7
7
  "entryPoints": [
8
8
  "src/index.ts"
9
- ]
9
+ ],
10
+ "gitRevision": "main"
10
11
  }