@i18n-micro/types-generator 1.1.1 → 1.1.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/README.md CHANGED
@@ -20,10 +20,7 @@ Add to `nuxt.config.ts`:
20
20
 
21
21
  ```typescript
22
22
  export default defineNuxtConfig({
23
- modules: [
24
- 'nuxt-i18n-micro',
25
- '@i18n-micro/types-generator/nuxt',
26
- ],
23
+ modules: ['nuxt-i18n-micro', '@i18n-micro/types-generator/nuxt'],
27
24
  })
28
25
  ```
29
26
 
@@ -59,4 +56,3 @@ See [full documentation](../../docs/integrations/types-generator.md) for detaile
59
56
  ## License
60
57
 
61
58
  MIT
62
-
@@ -4,19 +4,19 @@ export interface GeneratorOptions {
4
4
  outputFile?: string;
5
5
  }
6
6
  /**
7
- * Генерирует строку с TypeScript типами для ключей переводов.
8
- * Не записывает файл, только возвращает содержимое.
7
+ * Generates a string with TypeScript types for translation keys.
8
+ * Does not write a file, only returns content.
9
9
  *
10
- * @param options - Опции генератора
11
- * @returns Строка с содержимым .d.ts файла
10
+ * @param options - Generator options
11
+ * @returns String with .d.ts file content
12
12
  */
13
13
  export declare function getTypesString(options: GeneratorOptions): Promise<string>;
14
14
  /**
15
- * Генерирует TypeScript типы для ключей переводов из JSON файлов.
16
- * Записывает результат в файл.
15
+ * Generates TypeScript types for translation keys from JSON files.
16
+ * Writes the result to a file.
17
17
  *
18
- * @param options - Опции генератора
19
- * @returns Путь к сгенерированному файлу
18
+ * @param options - Generator options
19
+ * @returns Path to the generated file
20
20
  */
21
21
  export declare function generateTypes(options: GeneratorOptions): Promise<string>;
22
22
  //# sourceMappingURL=generator.d.ts.map
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Рекурсивно обходит JSON объект и создает плоский список ключей через точку.
2
+ * Recursively traverses a JSON object and creates a flat list of dot-separated keys.
3
3
  *
4
- * @param obj - JSON объект с переводами
5
- * @param prefix - Префикс для вложенных ключей (используется рекурсивно)
6
- * @returns Массив строк с плоскими ключами (например, ['greeting', 'header.title', 'errors.404'])
4
+ * @param obj - JSON object with translations
5
+ * @param prefix - Prefix for nested keys (used recursively)
6
+ * @returns Array of strings with flat keys (e.g. ['greeting', 'header.title', 'errors.404'])
7
7
  *
8
8
  * @example
9
9
  * ```typescript
@@ -1,4 +1,4 @@
1
- import { mkdirSync as l, writeFileSync as f, readFileSync as p } from "node:fs";
1
+ import { readFileSync as l, mkdirSync as f, writeFileSync as p } from "node:fs";
2
2
  import { resolve as i, dirname as m } from "node:path";
3
3
  import { globby as d } from "globby";
4
4
  function a(e, o = "") {
@@ -18,7 +18,7 @@ async function g(e) {
18
18
  }), n = /* @__PURE__ */ new Set();
19
19
  for (const r of t)
20
20
  try {
21
- const c = JSON.parse(p(r, "utf-8")), y = a(c);
21
+ const c = JSON.parse(l(r, "utf-8")), y = a(c);
22
22
  for (const u of y)
23
23
  n.add(u);
24
24
  } catch (c) {
@@ -42,10 +42,10 @@ ${Array.from(n).sort().map((r) => ` '${r}': string;`).join(`
42
42
  async function h(e) {
43
43
  const o = await g(e), t = e.outputFile || i(e.srcDir, "i18n-micro.d.ts"), n = m(t);
44
44
  try {
45
- l(n, { recursive: !0 });
45
+ f(n, { recursive: !0 });
46
46
  } catch {
47
47
  }
48
- return f(t, o, "utf-8"), t;
48
+ return p(t, o, "utf-8"), t;
49
49
  }
50
50
  export {
51
51
  g as a,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./generator-CAQjf5De.cjs"),s=require("node:path"),c=require("chokidar"),u=require("unplugin");let r=null,e=null;function y(t,n){return function(...o){const a=()=>{e&&clearTimeout(e),e=null,t(...o)};e&&clearTimeout(e),e=setTimeout(a,n)}}const g=u.createUnplugin(t=>({name:"i18n-micro-types-generator",async buildStart(){try{await i.generateTypes(t)}catch(n){console.warn("[i18n-types] Failed to generate types:",n)}if(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production"){const n=s.resolve(t.srcDir,t.translationDir),l=y(async()=>{try{await i.generateTypes(t)}catch(o){console.warn("[i18n-types] Failed to regenerate types:",o)}},300);r=c.watch(n,{ignoreInitial:!0,ignored:["node_modules/**","dist/**",".nuxt/**"]}),r.on("all",async(o,a)=>{a.endsWith(".json")&&l()})}},buildEnd(){r&&(r.close(),r=null),e&&(clearTimeout(e),e=null)}}));exports.flattenKeys=i.flattenKeys;exports.generateTypes=i.generateTypes;exports.getTypesString=i.getTypesString;exports.I18nTypesPlugin=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./generator-CAQjf5De.cjs"),l=require("node:path"),c=require("chokidar"),u=require("unplugin");let i=null,e=null;function y(t,r){return function(...n){const a=()=>{e&&clearTimeout(e),e=null,t(...n)};e&&clearTimeout(e),e=setTimeout(a,r)}}const g=u.createUnplugin(t=>({name:"i18n-micro-types-generator",async buildStart(){try{await o.generateTypes(t)}catch(r){console.warn("[i18n-types] Failed to generate types:",r)}if(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production"){const r=l.resolve(t.srcDir,t.translationDir),s=y(async()=>{try{await o.generateTypes(t)}catch(n){console.warn("[i18n-types] Failed to regenerate types:",n)}},300);i=c.watch(r,{ignoreInitial:!0,ignored:n=>/(?:^|[/\\])(?:node_modules|dist|\.nuxt)(?:[/\\]|$)/.test(n)}),i.on("all",async(n,a)=>{a.endsWith(".json")&&s()})}},buildEnd(){i&&(i.close(),i=null),e&&(clearTimeout(e),e=null)}}));exports.flattenKeys=o.flattenKeys;exports.generateTypes=o.generateTypes;exports.getTypesString=o.getTypesString;exports.I18nTypesPlugin=g;
@@ -0,0 +1,5 @@
1
+ export type { GeneratorOptions } from './core/generator';
2
+ export { generateTypes, getTypesString } from './core/generator';
3
+ export { flattenKeys } from './core/parser';
4
+ export { I18nTypesPlugin } from './unplugin';
5
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import { g as l } from "./generator-CUX1kjyj.js";
2
- import { f as w, a as v } from "./generator-CUX1kjyj.js";
3
- import { resolve as c } from "node:path";
4
- import s from "chokidar";
1
+ import { g as l } from "./generator-CSjBe25p.js";
2
+ import { f as h, a as v } from "./generator-CSjBe25p.js";
3
+ import { resolve as s } from "node:path";
4
+ import { watch as c } from "chokidar";
5
5
  import { createUnplugin as u } from "unplugin";
6
- let r = null, e = null;
7
- function m(t, n) {
8
- return function(...o) {
6
+ let o = null, e = null;
7
+ function m(t, r) {
8
+ return function(...n) {
9
9
  const i = () => {
10
- e && clearTimeout(e), e = null, t(...o);
10
+ e && clearTimeout(e), e = null, t(...n);
11
11
  };
12
- e && clearTimeout(e), e = setTimeout(i, n);
12
+ e && clearTimeout(e), e = setTimeout(i, r);
13
13
  };
14
14
  }
15
15
  const g = u((t) => ({
@@ -17,32 +17,32 @@ const g = u((t) => ({
17
17
  async buildStart() {
18
18
  try {
19
19
  await l(t);
20
- } catch (n) {
21
- console.warn("[i18n-types] Failed to generate types:", n);
20
+ } catch (r) {
21
+ console.warn("[i18n-types] Failed to generate types:", r);
22
22
  }
23
23
  if (process.env.NODE_ENV === "development" || process.env.NODE_ENV !== "production") {
24
- const n = c(t.srcDir, t.translationDir), a = m(async () => {
24
+ const r = s(t.srcDir, t.translationDir), a = m(async () => {
25
25
  try {
26
26
  await l(t);
27
- } catch (o) {
28
- console.warn("[i18n-types] Failed to regenerate types:", o);
27
+ } catch (n) {
28
+ console.warn("[i18n-types] Failed to regenerate types:", n);
29
29
  }
30
30
  }, 300);
31
- r = s.watch(n, {
31
+ o = c(r, {
32
32
  ignoreInitial: !0,
33
- ignored: ["node_modules/**", "dist/**", ".nuxt/**"]
34
- }), r.on("all", async (o, i) => {
33
+ ignored: (n) => /(?:^|[/\\])(?:node_modules|dist|\.nuxt)(?:[/\\]|$)/.test(n)
34
+ }), o.on("all", async (n, i) => {
35
35
  i.endsWith(".json") && a();
36
36
  });
37
37
  }
38
38
  },
39
39
  buildEnd() {
40
- r && (r.close(), r = null), e && (clearTimeout(e), e = null);
40
+ o && (o.close(), o = null), e && (clearTimeout(e), e = null);
41
41
  }
42
42
  }));
43
43
  export {
44
44
  g as I18nTypesPlugin,
45
- w as flattenKeys,
45
+ h as flattenKeys,
46
46
  l as generateTypes,
47
47
  v as getTypesString
48
48
  };
@@ -0,0 +1,7 @@
1
+ export interface I18nTypesGeneratorOptions {
2
+ translationDir?: string;
3
+ outputFile?: string;
4
+ }
5
+ declare const _default: import('@nuxt/schema').NuxtModule<I18nTypesGeneratorOptions, I18nTypesGeneratorOptions, false>;
6
+ export default _default;
7
+ //# sourceMappingURL=nuxt.d.ts.map
package/dist/nuxt.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtModule as l, addTypeTemplate as c } from "@nuxt/kit";
2
- import { a as p } from "./generator-CUX1kjyj.js";
2
+ import { a as p } from "./generator-CSjBe25p.js";
3
3
  const g = l({
4
4
  meta: {
5
5
  name: "@i18n-micro/types-generator",
@@ -1 +1 @@
1
- {"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../src/unplugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,kBAAkB,CAAA;AAkBvE,eAAO,MAAM,eAAe,gEAgD1B,CAAA"}
1
+ {"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../src/unplugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,kBAAkB,CAAA;AAkBvE,eAAO,MAAM,eAAe,gEAiD1B,CAAA"}
package/package.json CHANGED
@@ -1,68 +1,89 @@
1
1
  {
2
2
  "name": "@i18n-micro/types-generator",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Type generator for i18n-micro translation keys",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.mjs",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.cjs"
14
- },
15
- "./nuxt": {
16
- "types": "./dist/nuxt.d.ts",
17
- "import": "./dist/nuxt.mjs",
18
- "require": "./dist/nuxt.cjs"
19
- }
20
- },
21
- "files": [
22
- "dist"
23
- ],
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
5
  "keywords": [
28
6
  "i18n",
29
- "typescript",
7
+ "nuxt",
8
+ "translation",
30
9
  "type-generator",
31
- "translation"
10
+ "typescript"
32
11
  ],
12
+ "homepage": "https://github.com/s00d/nuxt-i18n-micro/tree/main/packages/types-generator#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/s00d/nuxt-i18n-micro/issues"
15
+ },
16
+ "license": "MIT",
33
17
  "author": {
34
18
  "name": "s00d",
35
19
  "email": "Virus191288@gmail.com",
36
20
  "url": "https://s00d.github.io/"
37
21
  },
38
- "license": "MIT",
39
22
  "repository": {
40
23
  "type": "git",
41
- "url": "https://github.com/s00d/nuxt-i18n-micro"
24
+ "url": "git+https://github.com/s00d/nuxt-i18n-micro.git",
25
+ "directory": "packages/types-generator"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "type": "module",
33
+ "sideEffects": false,
34
+ "main": "./dist/index.cjs",
35
+ "types": "./dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "import": {
39
+ "types": "./dist/index.d.ts",
40
+ "default": "./dist/index.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.cts",
44
+ "default": "./dist/index.cjs"
45
+ },
46
+ "default": "./dist/index.mjs"
47
+ },
48
+ "./nuxt": {
49
+ "import": {
50
+ "types": "./dist/nuxt.d.ts",
51
+ "default": "./dist/nuxt.mjs"
52
+ },
53
+ "require": {
54
+ "types": "./dist/nuxt.d.cts",
55
+ "default": "./dist/nuxt.cjs"
56
+ },
57
+ "default": "./dist/nuxt.mjs"
58
+ },
59
+ "./package.json": "./package.json"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
42
63
  },
43
64
  "dependencies": {
65
+ "chokidar": "^4.0.3",
44
66
  "globby": "^14.1.0",
45
- "chokidar": "^3.6.0",
46
67
  "unplugin": "^1.16.1"
47
68
  },
69
+ "devDependencies": {
70
+ "@types/node": "^20.19.26",
71
+ "publint": "^0.3.17",
72
+ "typescript": "^5.9.3",
73
+ "vite": "^7.3.6",
74
+ "vite-plugin-dts": "^4.5.4",
75
+ "vitest": "^4.1.10"
76
+ },
48
77
  "peerDependencies": {
49
78
  "@nuxt/kit": "^3.18.1 || ^4.0.0"
50
79
  },
51
80
  "engines": {
52
81
  "node": ">=18.17.0"
53
82
  },
54
- "devDependencies": {
55
- "@types/node": "^20.19.26",
56
- "vite": "^7.3.1",
57
- "vite-plugin-dts": "^4.5.4",
58
- "typescript": "^5.9.3",
59
- "jest": "^29.7.0",
60
- "ts-jest": "^29.4.6",
61
- "@types/jest": "^29.5.14"
62
- },
63
83
  "scripts": {
64
84
  "build": "vite build",
65
- "test": "jest",
85
+ "check:package": "publint",
86
+ "test": "vitest run",
66
87
  "typecheck": "tsc --noEmit"
67
88
  }
68
89
  }