@i18n-micro/types-generator 1.1.0 → 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.
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/parser.d.ts.map +1 -1
- package/dist/{generator-D2pTueXl.cjs → generator-CAQjf5De.cjs} +2 -3
- package/dist/{generator-D56a37C-.js → generator-CUX1kjyj.js} +13 -14
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.d.ts.map +1 -1
- package/dist/nuxt.mjs +1 -1
- package/dist/unplugin.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
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,
|
|
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
|
|
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
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 =
|
|
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
|
|
22
|
-
for (const
|
|
23
|
-
n.add(
|
|
24
|
-
} catch (
|
|
25
|
-
console.warn(`[i18n-types] Failed to parse ${r}:`,
|
|
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 `/*
|
|
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 ||
|
|
43
|
+
const o = await g(e), t = e.outputFile || i(e.srcDir, "i18n-micro.d.ts"), n = m(t);
|
|
45
44
|
try {
|
|
46
|
-
|
|
45
|
+
l(n, { recursive: !0 });
|
|
47
46
|
} catch {
|
|
48
47
|
}
|
|
49
|
-
return
|
|
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
|
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
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 =
|
|
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 =
|
|
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 a=require("@nuxt/kit"),c=require("./generator-
|
|
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;
|
package/dist/nuxt.d.ts.map
CHANGED
|
@@ -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,
|
|
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
package/dist/unplugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../src/unplugin.ts"],"names":[],"mappings":"
|
|
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"}
|