@i18n-micro/types-generator 1.0.1 → 1.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8C/E;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB9E"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4C/E;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/core/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,MAAM,SAAK,GACV,MAAM,EAAE,CAsBV"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/core/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,SAAK,GAAG,MAAM,EAAE,CAqB/E"}
@@ -1,5 +1,4 @@
1
- "use strict";const d=require("globby"),i=require("node:fs"),a=require("node:path");function y(e,s=""){const t=[];for(const n in e){if(!Object.hasOwn(e,n))continue;const o=e[n],r=s?`${s}.${n}`:n;typeof o=="object"&&o!==null&&!Array.isArray(o)?t.push(...y(o,r)):t.push(r)}return t}async function l(e){const s=a.resolve(e.srcDir,e.translationDir),t=await d.globby("**/*.json",{cwd:s,absolute:!0,ignore:["node_modules/**","dist/**",".nuxt/**"]}),n=new Set;for(const r of t)try{const c=JSON.parse(i.readFileSync(r,"utf-8")),u=y(c);for(const f of u)n.add(f)}catch(c){console.warn(`[i18n-types] Failed to parse ${r}:`,c)}return`/* eslint-disable */
2
- /* prettier-ignore */
1
+ "use strict";const i=require("node:fs"),a=require("node:path"),p=require("globby");function y(e,s=""){const t=[];for(const n in e){if(!Object.hasOwn(e,n))continue;const o=e[n],r=s?`${s}.${n}`:n;typeof o=="object"&&o!==null&&!Array.isArray(o)?t.push(...y(o,r)):t.push(r)}return t}async function u(e){const s=a.resolve(e.srcDir,e.translationDir),t=await p.globby("**/*.json",{cwd:s,absolute:!0,ignore:["node_modules/**","dist/**",".nuxt/**"]}),n=new Set;for(const r of t)try{const c=JSON.parse(i.readFileSync(r,"utf-8")),l=y(c);for(const f of l)n.add(f)}catch(c){console.warn(`[i18n-types] Failed to parse ${r}:`,c)}return`/* prettier-ignore */
3
2
  // @ts-nocheck
4
3
  // Generated by @i18n-micro/types-generator
5
4
  // DO NOT EDIT THIS FILE MANUALLY
@@ -12,4 +11,4 @@ ${Array.from(n).sort().map(r=>` '${r}': string;`).join(`
12
11
  `)}
13
12
  }
14
13
  }
15
- `}async function p(e){const s=await l(e),t=e.outputFile||a.resolve(e.srcDir,"i18n-micro.d.ts"),n=a.dirname(t);try{i.mkdirSync(n,{recursive:!0})}catch{}return i.writeFileSync(t,s,"utf-8"),t}exports.flattenKeys=y;exports.generateTypes=p;exports.getTypesString=l;
14
+ `}async function d(e){const s=await u(e),t=e.outputFile||a.resolve(e.srcDir,"i18n-micro.d.ts"),n=a.dirname(t);try{i.mkdirSync(n,{recursive:!0})}catch{}return i.writeFileSync(t,s,"utf-8"),t}exports.flattenKeys=y;exports.generateTypes=d;exports.getTypesString=u;
@@ -1,6 +1,6 @@
1
- import { globby as u } from "globby";
2
- import { mkdirSync as f, writeFileSync as p, readFileSync as m } from "node:fs";
3
- import { resolve as c, dirname as d } from "node:path";
1
+ import { mkdirSync as l, writeFileSync as f, readFileSync as p } from "node:fs";
2
+ import { resolve as i, dirname as m } from "node:path";
3
+ import { globby as d } from "globby";
4
4
  function a(e, o = "") {
5
5
  const t = [];
6
6
  for (const n in e) {
@@ -11,21 +11,20 @@ function a(e, o = "") {
11
11
  return t;
12
12
  }
13
13
  async function g(e) {
14
- const o = c(e.srcDir, e.translationDir), t = await u("**/*.json", {
14
+ const o = i(e.srcDir, e.translationDir), t = await d("**/*.json", {
15
15
  cwd: o,
16
16
  absolute: !0,
17
17
  ignore: ["node_modules/**", "dist/**", ".nuxt/**"]
18
18
  }), n = /* @__PURE__ */ new Set();
19
19
  for (const r of t)
20
20
  try {
21
- const i = JSON.parse(m(r, "utf-8")), l = a(i);
22
- for (const y of l)
23
- n.add(y);
24
- } catch (i) {
25
- console.warn(`[i18n-types] Failed to parse ${r}:`, i);
21
+ const c = JSON.parse(p(r, "utf-8")), y = a(c);
22
+ for (const u of y)
23
+ n.add(u);
24
+ } catch (c) {
25
+ console.warn(`[i18n-types] Failed to parse ${r}:`, c);
26
26
  }
27
- return `/* eslint-disable */
28
- /* prettier-ignore */
27
+ return `/* prettier-ignore */
29
28
  // @ts-nocheck
30
29
  // Generated by @i18n-micro/types-generator
31
30
  // DO NOT EDIT THIS FILE MANUALLY
@@ -41,12 +40,12 @@ ${Array.from(n).sort().map((r) => ` '${r}': string;`).join(`
41
40
  `;
42
41
  }
43
42
  async function h(e) {
44
- const o = await g(e), t = e.outputFile || c(e.srcDir, "i18n-micro.d.ts"), n = d(t);
43
+ const o = await g(e), t = e.outputFile || i(e.srcDir, "i18n-micro.d.ts"), n = m(t);
45
44
  try {
46
- f(n, { recursive: !0 });
45
+ l(n, { recursive: !0 });
47
46
  } catch {
48
47
  }
49
- return p(t, o, "utf-8"), t;
48
+ return f(t, o, "utf-8"), t;
50
49
  }
51
50
  export {
52
51
  g as a,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("unplugin"),i=require("./generator-D2pTueXl.cjs"),c=require("chokidar"),u=require("node:path");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=s.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=u.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 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;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { I18nTypesPlugin } from './unplugin';
2
- export { generateTypes, getTypesString } from './core/generator';
3
1
  export type { GeneratorOptions } from './core/generator';
2
+ export { generateTypes, getTypesString } from './core/generator';
4
3
  export { flattenKeys } from './core/parser';
4
+ export { I18nTypesPlugin } from './unplugin';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { createUnplugin as c } from "unplugin";
2
- import { g as l } from "./generator-D56a37C-.js";
3
- import { f as w, a as v } from "./generator-D56a37C-.js";
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
4
  import s from "chokidar";
5
- import { resolve as u } from "node:path";
5
+ import { createUnplugin as u } from "unplugin";
6
6
  let r = null, e = null;
7
7
  function m(t, n) {
8
8
  return function(...o) {
@@ -12,7 +12,7 @@ function m(t, n) {
12
12
  e && clearTimeout(e), e = setTimeout(i, n);
13
13
  };
14
14
  }
15
- const g = c((t) => ({
15
+ const g = u((t) => ({
16
16
  name: "i18n-micro-types-generator",
17
17
  async buildStart() {
18
18
  try {
@@ -21,7 +21,7 @@ const g = c((t) => ({
21
21
  console.warn("[i18n-types] Failed to generate types:", n);
22
22
  }
23
23
  if (process.env.NODE_ENV === "development" || process.env.NODE_ENV !== "production") {
24
- const n = u(t.srcDir, t.translationDir), a = m(async () => {
24
+ const n = c(t.srcDir, t.translationDir), a = m(async () => {
25
25
  try {
26
26
  await l(t);
27
27
  } catch (o) {
package/dist/nuxt.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@nuxt/kit"),c=require("./generator-D2pTueXl.cjs"),u=r.defineNuxtModule({meta:{name:"@i18n-micro/types-generator",configKey:"i18nTypes"},defaults:{translationDir:"locales"},async setup(o,t){const a=t.options.runtimeConfig?.public?.i18nConfig,n=o.translationDir||a?.translationDir||"locales";r.addTypeTemplate({filename:"types/i18n-micro.d.ts",getContents:async()=>{try{return await c.getTypesString({srcDir:t.options.rootDir,translationDir:n})}catch(e){return console.warn("[i18n-types] Failed to generate types:",e),`// Failed to generate types: ${e instanceof Error?e.message:String(e)}`}}}),t.hook("builder:watch",async(e,s)=>{const i=s.replace(/\\/g,"/"),l=n.replace(/\\/g,"/");i.includes(l)&&i.endsWith(".json")&&await t.callHook("builder:generateApp")})}});exports.default=u;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("@nuxt/kit"),c=require("./generator-CAQjf5De.cjs"),d=a.defineNuxtModule({meta:{name:"@i18n-micro/types-generator",configKey:"i18nTypes"},defaults:{translationDir:"locales"},async setup(o,t){const i=t.options.i18n,n=o.translationDir||i?.translationDir||"locales";a.addTypeTemplate({filename:"types/i18n-micro.d.ts",getContents:async()=>{try{return await c.getTypesString({srcDir:t.options.rootDir,translationDir:n})}catch(e){return console.warn("[i18n-types] Failed to generate types:",e),`// Failed to generate types: ${e instanceof Error?e.message:String(e)}`}}}),t.hook("builder:watch",async(e,s)=>{const r=s.replace(/\\/g,"/"),l=n.replace(/\\/g,"/");r.includes(l)&&r.endsWith(".json")&&await t.callHook("builder:generateApp")})}});exports.default=d;
@@ -1 +1 @@
1
- {"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../src/nuxt.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB;IACxC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;;AAED,wBAoDE"}
1
+ {"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../src/nuxt.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB;IACxC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;;AAED,wBA+CE"}
package/dist/nuxt.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineNuxtModule as l, addTypeTemplate as c } from "@nuxt/kit";
2
- import { a as p } from "./generator-D56a37C-.js";
3
- const u = l({
2
+ import { a as p } from "./generator-CUX1kjyj.js";
3
+ const g = l({
4
4
  meta: {
5
5
  name: "@i18n-micro/types-generator",
6
6
  configKey: "i18nTypes"
@@ -8,26 +8,26 @@ const u = l({
8
8
  defaults: {
9
9
  translationDir: "locales"
10
10
  },
11
- async setup(o, n) {
12
- const r = n.options.runtimeConfig?.public?.i18nConfig, t = o.translationDir || r?.translationDir || "locales";
11
+ async setup(r, t) {
12
+ const o = t.options.i18n, n = r.translationDir || o?.translationDir || "locales";
13
13
  c({
14
14
  filename: "types/i18n-micro.d.ts",
15
15
  getContents: async () => {
16
16
  try {
17
17
  return await p({
18
- srcDir: n.options.rootDir,
19
- translationDir: t
18
+ srcDir: t.options.rootDir,
19
+ translationDir: n
20
20
  });
21
21
  } catch (e) {
22
22
  return console.warn("[i18n-types] Failed to generate types:", e), `// Failed to generate types: ${e instanceof Error ? e.message : String(e)}`;
23
23
  }
24
24
  }
25
- }), n.hook("builder:watch", async (e, a) => {
26
- const i = a.replace(/\\/g, "/"), s = t.replace(/\\/g, "/");
27
- i.includes(s) && i.endsWith(".json") && await n.callHook("builder:generateApp");
25
+ }), t.hook("builder:watch", async (e, i) => {
26
+ const a = i.replace(/\\/g, "/"), s = n.replace(/\\/g, "/");
27
+ a.includes(s) && a.endsWith(".json") && await t.callHook("builder:generateApp");
28
28
  });
29
29
  }
30
30
  });
31
31
  export {
32
- u as default
32
+ g as default
33
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../src/unplugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAuBvE,eAAO,MAAM,eAAe,gEAkD1B,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,gEAgD1B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-micro/types-generator",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Type generator for i18n-micro translation keys",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -46,14 +46,14 @@
46
46
  "unplugin": "^1.16.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@nuxt/kit": "^3.0.0"
49
+ "@nuxt/kit": "^3.18.1 || ^4.0.0"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=18.17.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^20.19.26",
56
- "vite": "^7.2.7",
56
+ "vite": "^7.3.1",
57
57
  "vite-plugin-dts": "^4.5.4",
58
58
  "typescript": "^5.9.3",
59
59
  "jest": "^29.7.0",