@verbaly/nuxt 0.28.0 → 0.29.0

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/module.d.ts CHANGED
@@ -7,9 +7,17 @@ interface VerbalyNuxtOptions extends ViteVerbalyOptions$1 {
7
7
  interface ViteConfigLike {
8
8
  plugins?: unknown[];
9
9
  }
10
+ interface PrepareTypesLike {
11
+ references: Array<{
12
+ path: string;
13
+ } | {
14
+ types: string;
15
+ }>;
16
+ }
10
17
  interface NuxtLike {
11
18
  options: {
12
19
  rootDir: string;
20
+ buildDir: string;
13
21
  plugins: unknown[];
14
22
  build: {
15
23
  transpile: unknown[];
@@ -20,6 +28,7 @@ interface NuxtLike {
20
28
  verbaly?: VerbalyNuxtOptions;
21
29
  };
22
30
  hook(name: 'vite:extendConfig', fn: (config: ViteConfigLike) => void): void;
31
+ hook(name: 'prepare:types', fn: (options: PrepareTypesLike) => Promise<void>): void;
23
32
  }
24
33
  declare function verbalyModule(inlineOptions: VerbalyNuxtOptions | undefined, nuxt: NuxtLike): void;
25
34
  declare namespace verbalyModule {
package/dist/module.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { loadCatalogs, loadConfig, writeDts } from "@verbaly/compiler";
1
2
  import verbalyVite from "@verbaly/vite";
2
3
  import { dirname, join } from "node:path";
3
4
  import { fileURLToPath } from "node:url";
@@ -12,12 +13,20 @@ function verbalyModule(inlineOptions, nuxt) {
12
13
  ...cookie !== void 0 && { cookie },
13
14
  ...fallback !== void 0 && { fallback }
14
15
  };
16
+ vite.dts ??= join(nuxt.options.buildDir, "verbaly.d.ts");
15
17
  nuxt.hook("vite:extendConfig", (config) => {
16
18
  (config.plugins ??= []).push(verbalyVite({
17
19
  root: nuxt.options.rootDir,
18
20
  ...vite
19
21
  }));
20
22
  });
23
+ nuxt.hook("prepare:types", async ({ references }) => {
24
+ const cfg = await loadConfig(nuxt.options.rootDir, vite);
25
+ if (cfg.dts === false) return;
26
+ const file = cfg.dts ?? join(cfg.root, "verbaly.d.ts");
27
+ writeDts(cfg, loadCatalogs(cfg)[cfg.sourceLocale] ?? {}, file);
28
+ references.push({ path: file });
29
+ });
21
30
  nuxt.options.build.transpile.push(runtimeDir);
22
31
  nuxt.options.plugins.unshift(join(runtimeDir, "plugin.js"));
23
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","names":[],"sources":["../src/module.ts"],"sourcesContent":["import verbalyVite, { type ViteVerbalyOptions } from '@verbaly/vite';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport type { ViteVerbalyOptions } from '@verbaly/vite';\n\nexport interface VerbalyNuxtOptions extends ViteVerbalyOptions {\n cookie?: string | false;\n fallback?: string;\n}\n\n// structural subset of Nuxt: no runtime or type dependency on nuxt/@nuxt/kit\ninterface ViteConfigLike {\n plugins?: unknown[];\n}\nexport interface NuxtLike {\n options: {\n rootDir: string;\n plugins: unknown[];\n build: { transpile: unknown[] };\n runtimeConfig: { public: Record<string, unknown> };\n verbaly?: VerbalyNuxtOptions;\n };\n hook(name: 'vite:extendConfig', fn: (config: ViteConfigLike) => void): void;\n}\n\nconst runtimeDir = join(dirname(fileURLToPath(import.meta.url)), 'runtime');\n\n// plain-function Nuxt module: configKey `verbaly`, inline options win\nfunction verbalyModule(inlineOptions: VerbalyNuxtOptions | undefined, nuxt: NuxtLike): void {\n const { cookie, fallback, ...vite } = { ...nuxt.options.verbaly, ...inlineOptions };\n\n // negotiation options ride runtimeConfig to the runtime plugin\n nuxt.options.runtimeConfig.public.verbaly = {\n ...(cookie !== undefined && { cookie }),\n ...(fallback !== undefined && { fallback }),\n };\n\n // fresh plugin instance per Vite build: client and server builds never share state.\n // root pinned to the project dir: Nuxt's Vite root is srcDir (app/), where no verbaly.config lives\n nuxt.hook('vite:extendConfig', (config) => {\n (config.plugins ??= []).push(verbalyVite({ root: nuxt.options.rootDir, ...vite }));\n });\n\n nuxt.options.build.transpile.push(runtimeDir);\n // prepend: the instance must exist before app plugins and components run\n nuxt.options.plugins.unshift(join(runtimeDir, 'plugin.js'));\n}\n\nverbalyModule.meta = { name: '@verbaly/nuxt', configKey: 'verbaly' };\n\n// same merge as the body; also the anchor Nuxt's generated nuxt.config typing infers the\n// options type from (the plain call signature alone degrades the inference to Record)\nverbalyModule.getOptions = async (\n inlineOptions?: Partial<VerbalyNuxtOptions>,\n nuxt?: NuxtLike,\n): Promise<VerbalyNuxtOptions> => ({ ...nuxt?.options.verbaly, ...inlineOptions });\n\nexport default verbalyModule;\n"],"mappings":";;;;AA0BA,MAAM,aAAa,KAAK,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC,GAAG,SAAS;AAG1E,SAAS,cAAc,eAA+C,MAAsB;CAC1F,MAAM,EAAE,QAAQ,UAAU,GAAG,SAAS;EAAE,GAAG,KAAK,QAAQ;EAAS,GAAG;CAAc;CAGlF,KAAK,QAAQ,cAAc,OAAO,UAAU;EAC1C,GAAI,WAAW,KAAA,KAAa,EAAE,OAAO;EACrC,GAAI,aAAa,KAAA,KAAa,EAAE,SAAS;CAC3C;CAIA,KAAK,KAAK,sBAAsB,WAAW;EACzC,CAAC,OAAO,YAAY,CAAC,EAAA,CAAG,KAAK,YAAY;GAAE,MAAM,KAAK,QAAQ;GAAS,GAAG;EAAK,CAAC,CAAC;CACnF,CAAC;CAED,KAAK,QAAQ,MAAM,UAAU,KAAK,UAAU;CAE5C,KAAK,QAAQ,QAAQ,QAAQ,KAAK,YAAY,WAAW,CAAC;AAC5D;AAEA,cAAc,OAAO;CAAE,MAAM;CAAiB,WAAW;AAAU;AAInE,cAAc,aAAa,OACzB,eACA,UACiC;CAAE,GAAG,MAAM,QAAQ;CAAS,GAAG;AAAc"}
1
+ {"version":3,"file":"module.js","names":[],"sources":["../src/module.ts"],"sourcesContent":["import { loadCatalogs, loadConfig, writeDts } from '@verbaly/compiler';\nimport verbalyVite, { type ViteVerbalyOptions } from '@verbaly/vite';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport type { ViteVerbalyOptions } from '@verbaly/vite';\n\nexport interface VerbalyNuxtOptions extends ViteVerbalyOptions {\n cookie?: string | false;\n fallback?: string;\n}\n\n// structural subset of Nuxt: no runtime or type dependency on nuxt/@nuxt/kit\ninterface ViteConfigLike {\n plugins?: unknown[];\n}\ninterface PrepareTypesLike {\n references: Array<{ path: string } | { types: string }>;\n}\nexport interface NuxtLike {\n options: {\n rootDir: string;\n buildDir: string;\n plugins: unknown[];\n build: { transpile: unknown[] };\n runtimeConfig: { public: Record<string, unknown> };\n verbaly?: VerbalyNuxtOptions;\n };\n hook(name: 'vite:extendConfig', fn: (config: ViteConfigLike) => void): void;\n hook(name: 'prepare:types', fn: (options: PrepareTypesLike) => Promise<void>): void;\n}\n\nconst runtimeDir = join(dirname(fileURLToPath(import.meta.url)), 'runtime');\n\n// plain-function Nuxt module: configKey `verbaly`, inline options win\nfunction verbalyModule(inlineOptions: VerbalyNuxtOptions | undefined, nuxt: NuxtLike): void {\n const { cookie, fallback, ...vite } = { ...nuxt.options.verbaly, ...inlineOptions };\n\n // negotiation options ride runtimeConfig to the runtime plugin\n nuxt.options.runtimeConfig.public.verbaly = {\n ...(cookie !== undefined && { cookie }),\n ...(fallback !== undefined && { fallback }),\n };\n\n // types live in Nuxt's own slot (.nuxt/), no file in the project root; set before the\n // hooks fire so the vite plugin keeps that same file fresh as messages change in dev\n vite.dts ??= join(nuxt.options.buildDir, 'verbaly.d.ts');\n\n // fresh plugin instance per Vite build: client and server builds never share state.\n // root pinned to the project dir: Nuxt's Vite root is srcDir (app/), where no verbaly.config lives\n nuxt.hook('vite:extendConfig', (config) => {\n (config.plugins ??= []).push(verbalyVite({ root: nuxt.options.rootDir, ...vite }));\n });\n\n // prepare:types fires on prepare/dev/build, before anything compiles: the file must\n // exist when the reference lands in .nuxt/nuxt.d.ts or TS reports it missing\n nuxt.hook('prepare:types', async ({ references }) => {\n const cfg = await loadConfig(nuxt.options.rootDir, vite);\n if (cfg.dts === false) return;\n const file = cfg.dts ?? join(cfg.root, 'verbaly.d.ts');\n writeDts(cfg, loadCatalogs(cfg)[cfg.sourceLocale] ?? {}, file);\n references.push({ path: file });\n });\n\n nuxt.options.build.transpile.push(runtimeDir);\n // prepend: the instance must exist before app plugins and components run\n nuxt.options.plugins.unshift(join(runtimeDir, 'plugin.js'));\n}\n\nverbalyModule.meta = { name: '@verbaly/nuxt', configKey: 'verbaly' };\n\n// same merge as the body; also the anchor Nuxt's generated nuxt.config typing infers the\n// options type from (the plain call signature alone degrades the inference to Record)\nverbalyModule.getOptions = async (\n inlineOptions?: Partial<VerbalyNuxtOptions>,\n nuxt?: NuxtLike,\n): Promise<VerbalyNuxtOptions> => ({ ...nuxt?.options.verbaly, ...inlineOptions });\n\nexport default verbalyModule;\n"],"mappings":";;;;;AAgCA,MAAM,aAAa,KAAK,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC,GAAG,SAAS;AAG1E,SAAS,cAAc,eAA+C,MAAsB;CAC1F,MAAM,EAAE,QAAQ,UAAU,GAAG,SAAS;EAAE,GAAG,KAAK,QAAQ;EAAS,GAAG;CAAc;CAGlF,KAAK,QAAQ,cAAc,OAAO,UAAU;EAC1C,GAAI,WAAW,KAAA,KAAa,EAAE,OAAO;EACrC,GAAI,aAAa,KAAA,KAAa,EAAE,SAAS;CAC3C;CAIA,KAAK,QAAQ,KAAK,KAAK,QAAQ,UAAU,cAAc;CAIvD,KAAK,KAAK,sBAAsB,WAAW;EACzC,CAAC,OAAO,YAAY,CAAC,EAAA,CAAG,KAAK,YAAY;GAAE,MAAM,KAAK,QAAQ;GAAS,GAAG;EAAK,CAAC,CAAC;CACnF,CAAC;CAID,KAAK,KAAK,iBAAiB,OAAO,EAAE,iBAAiB;EACnD,MAAM,MAAM,MAAM,WAAW,KAAK,QAAQ,SAAS,IAAI;EACvD,IAAI,IAAI,QAAQ,OAAO;EACvB,MAAM,OAAO,IAAI,OAAO,KAAK,IAAI,MAAM,cAAc;EACrD,SAAS,KAAK,aAAa,GAAG,CAAC,CAAC,IAAI,iBAAiB,CAAC,GAAG,IAAI;EAC7D,WAAW,KAAK,EAAE,MAAM,KAAK,CAAC;CAChC,CAAC;CAED,KAAK,QAAQ,MAAM,UAAU,KAAK,UAAU;CAE5C,KAAK,QAAQ,QAAQ,QAAQ,KAAK,YAAY,WAAW,CAAC;AAC5D;AAEA,cAAc,OAAO;CAAE,MAAM;CAAiB,WAAW;AAAU;AAInE,cAAc,aAAa,OACzB,eACA,UACiC;CAAE,GAAG,MAAM,QAAQ;CAAS,GAAG;AAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/nuxt",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Nuxt integration for Verbaly: zero-config module with per-request locale negotiation and flash-free hydration.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -41,19 +41,20 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@verbaly/vite": "^0.28.0"
44
+ "@verbaly/compiler": "^0.29.0",
45
+ "@verbaly/vite": "^0.29.0"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "vue": "^3.4.0",
48
- "@verbaly/vue": "^0.28.0",
49
- "verbaly": "^0.28.0"
49
+ "verbaly": "^0.29.0",
50
+ "@verbaly/vue": "^0.29.0"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@nuxt/schema": "^4.5.0",
53
54
  "happy-dom": "^20.11.0",
54
55
  "vue": "^3.5.40",
55
- "verbaly": "0.28.0",
56
- "@verbaly/vue": "0.28.0"
56
+ "@verbaly/vue": "0.29.0",
57
+ "verbaly": "0.29.0"
57
58
  },
58
59
  "scripts": {
59
60
  "build": "tsdown",