@fluenti/vite-plugin 0.3.4 → 0.4.0-rc.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/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createFilter as e } from "vite";
2
2
  import { hashMessage as t, resolveLocaleCodes as n } from "@fluenti/core/internal";
3
- import { join as r, resolve as i } from "node:path";
4
- import { createRequire as a } from "node:module";
3
+ import { createRequire as r } from "node:module";
4
+ import { join as i, resolve as a } from "node:path";
5
5
  import { createRuntimeGenerator as o, createTransformPipeline as s, hasScopeTransformCandidate as c, parseSourceModule as l, walkSourceAst as u } from "@fluenti/core/transform";
6
- import { validateLocale as d } from "@fluenti/core";
7
- import { readFileSync as f } from "node:fs";
6
+ import { existsSync as d } from "node:fs";
7
+ import { validateLocale as f } from "@fluenti/core";
8
8
  //#region src/mode-detect.ts
9
9
  var p = "dev";
10
10
  function m(e) {
@@ -24,7 +24,7 @@ function g(e) {
24
24
  async function _(e) {
25
25
  if (!(e.onBeforeCompile && await e.onBeforeCompile() === !1)) {
26
26
  if (e.compileOnly) try {
27
- let { runCompile: t } = a(r(e.cwd, "package.json"))("@fluenti/cli");
27
+ let { runCompile: t } = r(i(e.cwd, "package.json"))("@fluenti/cli");
28
28
  await t(e.cwd), console.log("[fluenti] Compiling... done"), e.onAfterCompile && await e.onAfterCompile(), e.onSuccess?.();
29
29
  return;
30
30
  } catch (t) {
@@ -34,7 +34,7 @@ async function _(e) {
34
34
  return;
35
35
  }
36
36
  try {
37
- let { runExtract: t, runCompile: n } = a(r(e.cwd, "package.json"))("@fluenti/cli");
37
+ let { runExtract: t, runCompile: n } = r(i(e.cwd, "package.json"))("@fluenti/cli");
38
38
  await t(e.cwd), await n(e.cwd, { parallel: e.parallelCompile }), console.log("[fluenti] Extracting and compiling... done"), e.onAfterCompile && await e.onAfterCompile(), e.onSuccess?.();
39
39
  return;
40
40
  } catch (t) {
@@ -50,7 +50,7 @@ async function _(e) {
50
50
  }
51
51
  }
52
52
  }
53
- function v(e, t = 300) {
53
+ function ee(e, t = 300) {
54
54
  let n = null, r = !1, i = !1;
55
55
  async function a() {
56
56
  r = !0;
@@ -69,27 +69,27 @@ function v(e, t = 300) {
69
69
  }
70
70
  //#endregion
71
71
  //#region src/build-transform.ts
72
- function ee(e, t) {
73
- return y(e, "dynamic", t);
74
- }
75
72
  function te(e, t) {
76
- return y(e, "static", t);
73
+ return v(e, "dynamic", t);
74
+ }
75
+ function ne(e, t) {
76
+ return v(e, "static", t);
77
77
  }
78
- function y(e, n, r) {
78
+ function v(e, n, r) {
79
79
  let i = r?.hashFn ?? t, a = l(e);
80
80
  if (!a || a.type !== "Program") return {
81
81
  code: e,
82
82
  needsCatalogImport: !1,
83
83
  usedHashes: /* @__PURE__ */ new Set()
84
84
  };
85
- let o = b(a), s = [], c = /* @__PURE__ */ new Set();
85
+ let o = y(a), s = [], c = /* @__PURE__ */ new Set();
86
86
  if (u(a, (t) => {
87
- let r = S(e, t, o, n, c, i);
87
+ let r = x(e, t, o, n, c, i);
88
88
  if (r) {
89
89
  s.push(r);
90
90
  return;
91
91
  }
92
- ne(t, c, i);
92
+ re(t, c, i);
93
93
  }), s.length === 0) return {
94
94
  code: e,
95
95
  needsCatalogImport: !1,
@@ -106,32 +106,32 @@ function y(e, n, r) {
106
106
  usedHashes: c
107
107
  };
108
108
  }
109
- function b(e) {
109
+ function y(e) {
110
110
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
111
- for (let t of e.body) if (se(t)) for (let e of t.specifiers) {
112
- if (!ce(e)) continue;
113
- let t = B(e);
111
+ for (let t of e.body) if (N(t)) for (let e of t.specifiers) {
112
+ if (!P(e)) continue;
113
+ let t = W(e);
114
114
  t && (t === "useI18n" && n.add(e.local.name), t === "getI18n" && r.add(e.local.name), t === "unref" && i.add(e.local.name));
115
115
  }
116
116
  return u(e, (e) => {
117
- if (!le(e) || !e.init || !ue(e.id)) return;
118
- if (F(e.init) && L(e.init.callee) && n.has(e.init.callee.name)) {
119
- x(e.id, t);
117
+ if (!F(e) || !e.init || !I(e.id)) return;
118
+ if (z(e.init) && V(e.init.callee) && n.has(e.init.callee.name)) {
119
+ b(e.id, t);
120
120
  return;
121
121
  }
122
122
  let i = e.init.type === "AwaitExpression" ? e.init.argument : null;
123
- i && F(i) && L(i.callee) && r.has(i.callee.name) && x(e.id, t);
123
+ i && z(i) && V(i.callee) && r.has(i.callee.name) && b(e.id, t);
124
124
  }), {
125
125
  tracked: t,
126
126
  unref: i
127
127
  };
128
128
  }
129
- function x(e, t) {
130
- for (let n of e.properties) !P(n) || n.computed || !L(n.key) || n.key.name !== "t" || L(n.value) && t.add(n.value.name);
129
+ function b(e, t) {
130
+ for (let n of e.properties) !R(n) || n.computed || !V(n.key) || n.key.name !== "t" || V(n.value) && t.add(n.value.name);
131
131
  }
132
- function S(e, t, n, r, i, a) {
133
- if (!F(t) || t.start == null || t.end == null) return;
134
- let o = C(e, t, n, a);
132
+ function x(e, t, n, r, i, a) {
133
+ if (!z(t) || t.start == null || t.end == null) return;
134
+ let o = S(e, t, n, a);
135
135
  if (!o) return;
136
136
  let { catalogId: s } = o;
137
137
  i.add(s);
@@ -142,11 +142,11 @@ function S(e, t, n, r, i, a) {
142
142
  replacement: u
143
143
  };
144
144
  }
145
- function C(e, t, n, r) {
145
+ function S(e, t, n, r) {
146
146
  if (t.arguments.length === 0) return;
147
- let i = t.callee, a = L(i) && (n.tracked.has(i.name) || i.name === "$t"), o = I(i) && !i.computed && L(i.property) && (i.property.name === "$t" || i.property.name === "t" && L(i.object) && (i.object.name === "_ctx" || i.object.name === "$setup")), s = F(i) && L(i.callee) && n.unref.has(i.callee.name) && i.arguments.length === 1 && L(i.arguments[0]) && n.tracked.has(i.arguments[0].name);
147
+ let i = t.callee, a = V(i) && (n.tracked.has(i.name) || i.name === "$t"), o = B(i) && !i.computed && V(i.property) && (i.property.name === "$t" || i.property.name === "t" && V(i.object) && (i.object.name === "_ctx" || i.object.name === "$setup")), s = z(i) && V(i.callee) && n.unref.has(i.callee.name) && i.arguments.length === 1 && V(i.arguments[0]) && n.tracked.has(i.arguments[0].name);
148
148
  if (!a && !o && !s) return;
149
- let c = w(t.arguments[0], r);
149
+ let c = C(t.arguments[0], r);
150
150
  if (!c) return;
151
151
  let l = t.arguments[1] && t.arguments[1].start != null && t.arguments[1].end != null ? e.slice(t.arguments[1].start, t.arguments[1].end) : void 0;
152
152
  return l === void 0 ? { catalogId: c } : {
@@ -154,13 +154,13 @@ function C(e, t, n, r) {
154
154
  valuesSource: l
155
155
  };
156
156
  }
157
- function w(e, t) {
157
+ function C(e, t) {
158
158
  let n = j(e);
159
159
  if (n !== void 0) return t(n);
160
- if (!N(e)) return;
160
+ if (!L(e)) return;
161
161
  let r, i, a;
162
162
  for (let t of e.properties) {
163
- if (!P(t) || t.computed) continue;
163
+ if (!R(t) || t.computed) continue;
164
164
  let e = M(t.key);
165
165
  if (!e) continue;
166
166
  let n = j(t.value);
@@ -169,8 +169,8 @@ function w(e, t) {
169
169
  if (r) return r;
170
170
  if (i) return t(i, a);
171
171
  }
172
- function ne(e, t, n) {
173
- if (!R(e)) return;
172
+ function re(e, t, n) {
173
+ if (!H(e)) return;
174
174
  let r = oe(e.openingElement.name);
175
175
  if (r) {
176
176
  if (r === "Trans") {
@@ -184,17 +184,17 @@ function ne(e, t, n) {
184
184
  return;
185
185
  }
186
186
  if (r === "Plural") {
187
- let r = re(e.openingElement, n);
187
+ let r = ie(e.openingElement, n);
188
188
  r && t.add(r);
189
189
  return;
190
190
  }
191
191
  if (r === "Select") {
192
- let r = ie(e.openingElement, n);
192
+ let r = w(e.openingElement, n);
193
193
  r && t.add(r);
194
194
  }
195
195
  }
196
196
  }
197
- function re(e, t) {
197
+ function ie(e, t) {
198
198
  let n = O(e, "id");
199
199
  if (n) return n;
200
200
  let r = O(e, "context"), i = ae(e, "offset"), a = [
@@ -207,7 +207,7 @@ function re(e, t) {
207
207
  ].filter(Boolean);
208
208
  if (a.length !== 0) return t(`{count, plural,${typeof i == "number" ? ` offset:${i}` : ""} ${a.join(" ")}}`, r);
209
209
  }
210
- function ie(e, t) {
210
+ function w(e, t) {
211
211
  let n = O(e, "id");
212
212
  if (n) return n;
213
213
  let r = O(e, "context"), i = T(e);
@@ -224,7 +224,7 @@ function T(e) {
224
224
  }
225
225
  let n = {};
226
226
  for (let t of e.attributes) {
227
- if (!z(t)) continue;
227
+ if (!U(t)) continue;
228
228
  let e = t.name.name;
229
229
  if ([
230
230
  "value",
@@ -239,10 +239,10 @@ function T(e) {
239
239
  return Object.keys(n).length > 0 ? n : void 0;
240
240
  }
241
241
  function E(e) {
242
- if (!N(e)) return;
242
+ if (!L(e)) return;
243
243
  let t = {};
244
244
  for (let n of e.properties) {
245
- if (!P(n) || n.computed) return;
245
+ if (!R(n) || n.computed) return;
246
246
  let e = M(n.key), r = j(n.value);
247
247
  if (!e || r === void 0) return;
248
248
  t[e] = r;
@@ -263,7 +263,7 @@ function ae(e, t) {
263
263
  return r.type === "NumericLiteral" ? r.value : void 0;
264
264
  }
265
265
  function k(e, t) {
266
- return e.attributes.find((e) => z(e) && e.name.name === t);
266
+ return e.attributes.find((e) => U(e) && e.name.name === t);
267
267
  }
268
268
  function A(e) {
269
269
  if (e?.value) {
@@ -282,91 +282,83 @@ function j(e) {
282
282
  }
283
283
  }
284
284
  function M(e) {
285
- if (L(e)) return e.name;
285
+ if (V(e)) return e.name;
286
286
  if (e.type === "StringLiteral") return e.value;
287
287
  }
288
- function se(e) {
288
+ function N(e) {
289
289
  return e.type === "ImportDeclaration";
290
290
  }
291
- function ce(e) {
291
+ function P(e) {
292
292
  return e.type === "ImportSpecifier";
293
293
  }
294
- function le(e) {
294
+ function F(e) {
295
295
  return e.type === "VariableDeclarator";
296
296
  }
297
- function ue(e) {
297
+ function I(e) {
298
298
  return e.type === "ObjectPattern";
299
299
  }
300
- function N(e) {
300
+ function L(e) {
301
301
  return e.type === "ObjectExpression";
302
302
  }
303
- function P(e) {
303
+ function R(e) {
304
304
  return e.type === "ObjectProperty";
305
305
  }
306
- function F(e) {
306
+ function z(e) {
307
307
  return e.type === "CallExpression";
308
308
  }
309
- function I(e) {
309
+ function B(e) {
310
310
  return e.type === "MemberExpression";
311
311
  }
312
- function L(e) {
312
+ function V(e) {
313
313
  return e?.type === "Identifier";
314
314
  }
315
- function R(e) {
315
+ function H(e) {
316
316
  return e.type === "JSXElement";
317
317
  }
318
- function z(e) {
318
+ function U(e) {
319
319
  return e.type === "JSXAttribute";
320
320
  }
321
- function B(e) {
321
+ function W(e) {
322
322
  let t = e.imported;
323
323
  if (t.type === "Identifier") return t.name;
324
324
  if (t.type === "StringLiteral") return t.value;
325
325
  }
326
- function V(e, n, r, i) {
326
+ function G(e, n, r, i) {
327
327
  if (n === "dynamic") return `import { __catalog } from 'virtual:fluenti/runtime';\n${e}`;
328
- if (n === "per-route") return `import { __catalog } from 'virtual:fluenti/route-runtime';\n${e}`;
329
328
  let a = i ?? t;
330
329
  return `import { ${[...r].map((e) => `_${a(e)}`).join(", ")} } from 'virtual:fluenti/messages';\n${e}`;
331
330
  }
332
331
  //#endregion
333
332
  //#region src/virtual-modules.ts
334
- function H(e) {
333
+ function K(e) {
335
334
  return JSON.stringify(e);
336
335
  }
337
- function U(e) {
336
+ function q(e) {
338
337
  if (e.includes("`") || e.includes("$")) throw Error(`[fluenti] vite-plugin: catalogDir must not contain backticks or $ characters, got ${JSON.stringify(e)}`);
339
338
  }
340
- var de = "virtual:fluenti/runtime", fe = "virtual:fluenti/messages", pe = "virtual:fluenti/route-runtime", W = "\0virtual:fluenti/runtime", G = "\0virtual:fluenti/messages", K = "\0virtual:fluenti/route-runtime";
341
- function q(e) {
342
- if (e === de) return W;
343
- if (e === fe) return G;
344
- if (e === pe) return K;
339
+ var se = "virtual:fluenti/runtime", ce = "virtual:fluenti/messages", J = "\0virtual:fluenti/runtime", Y = "\0virtual:fluenti/messages";
340
+ function X(e) {
341
+ if (e === se) return J;
342
+ if (e === ce) return Y;
345
343
  }
346
- function J(e, t) {
347
- if (e === W) return me(t);
348
- if (e === G) return he(t);
349
- if (e === K) return ge(t);
344
+ function Z(e, t) {
345
+ if (e === J) return le(t);
346
+ if (e === Y) return ue(t);
350
347
  }
351
- function me(e) {
348
+ function le(e) {
352
349
  let { locales: t, runtimeGenerator: n, catalogDir: r } = e;
353
- U(r);
354
- for (let e of t) d(e, "vite-plugin");
350
+ q(r);
351
+ for (let e of t) f(e, "vite-plugin");
355
352
  if (!n) throw Error("[fluenti] vite-plugin: runtimeGenerator is required. Use a framework-specific plugin (e.g. @fluenti/vue/vite-plugin).");
356
- return n.generateRuntime(Y(e));
357
- }
358
- function he(e) {
359
- let { rootDir: t, catalogDir: n, catalogExtension: r, defaultBuildLocale: a, sourceLocale: o } = e, s = a || o;
360
- return d(s, "vite-plugin"), U(n), `export * from ${H(i(t, n) + "/" + s + r)}\n`;
353
+ return n.generateRuntime(de(e));
361
354
  }
362
- function ge(e) {
363
- let { locales: t, runtimeGenerator: n, catalogDir: r } = e;
364
- U(r);
365
- for (let e of t) d(e, "vite-plugin");
366
- if (!n) throw Error("[fluenti] vite-plugin: runtimeGenerator is required. Use a framework-specific plugin (e.g. @fluenti/vue/vite-plugin).");
367
- return n.generateRouteRuntime(Y(e));
355
+ function ue(e) {
356
+ let { rootDir: t, catalogDir: n, catalogExtension: r, defaultBuildLocale: i, sourceLocale: o } = e, s = i || o;
357
+ f(s, "vite-plugin"), q(n);
358
+ let c = a(a(t, n), s + r);
359
+ return d(c) || console.warn(`[fluenti] Compiled catalog for locale "${s}" not found at ${c}. Run "fluenti compile" first.`), `export * from ${K(c)}\n`;
368
360
  }
369
- function Y(e) {
361
+ function de(e) {
370
362
  let { rootDir: t, catalogDir: n, catalogExtension: r, locales: i, sourceLocale: a, defaultBuildLocale: o } = e;
371
363
  return {
372
364
  rootDir: t,
@@ -378,49 +370,8 @@ function Y(e) {
378
370
  };
379
371
  }
380
372
  //#endregion
381
- //#region src/route-resolve.ts
382
- function X(e) {
383
- let t = (e.includes("/") ? e.slice(e.lastIndexOf("/") + 1) : e).replace(/\.[^.]+$/, "");
384
- return t.replace(/-[a-zA-Z0-9]{4,}$/, "") || t;
385
- }
386
- function _e(e) {
387
- let t = /* @__PURE__ */ new Map(), n = e.split("\n");
388
- for (let e = 0; e < n.length; e++) {
389
- let r = n[e], i = r.match(/^(?:\/\*.*?\*\/\s*)?export\s+const\s+_([a-z0-9]+)\s*=\s*/);
390
- if (!i) continue;
391
- let a = i[1], o = r, s = 0, c = 0, l = 0;
392
- for (let e of r.slice(i[0].length)) e === "{" && s++, e === "}" && s--, e === "(" && c++, e === ")" && c--, e === "`" && (l = l === 0 ? 1 : 0);
393
- for (; (s > 0 || c > 0 || l > 0) && e + 1 < n.length;) {
394
- e++;
395
- let t = n[e];
396
- o += "\n" + t;
397
- for (let e of t) e === "{" && s++, e === "}" && s--, e === "(" && c++, e === ")" && c--, e === "`" && (l = l === 0 ? 1 : 0);
398
- }
399
- t.set(a, o);
400
- }
401
- return t;
402
- }
403
- function Z(e, n) {
404
- let r = [], i = [];
405
- for (let a of e) {
406
- let e = t(a), o = n.get(e);
407
- o && (r.push(o), i.push(` '${ye(a)}': _${e},`));
408
- }
409
- return i.length > 0 && r.push("", "export default {", ...i, "}"), r.join("\n") + "\n";
410
- }
411
- function ve(e, t) {
412
- try {
413
- return f(i(e, `${t}.js`), "utf-8");
414
- } catch {
415
- return;
416
- }
417
- }
418
- function ye(e) {
419
- return e.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\r/g, "\\r").replace(/\n/g, "\\n");
420
- }
421
- //#endregion
422
373
  //#region src/index.ts
423
- var Q = a(typeof __filename < "u" ? __filename : import.meta.url), be = "virtual:fluenti/messages/", xe = "\0virtual:fluenti/messages/";
374
+ var Q = r(typeof __filename < "u" ? __filename : import.meta.url), fe = "virtual:fluenti/messages/", pe = "\0virtual:fluenti/messages/";
424
375
  function $(e, t) {
425
376
  if (typeof e == "object") {
426
377
  let { DEFAULT_FLUENTI_CONFIG: t } = Q("@fluenti/core/config");
@@ -432,67 +383,72 @@ function $(e, t) {
432
383
  let { loadConfigSync: n } = Q("@fluenti/core/config");
433
384
  return n(typeof e == "string" ? e : void 0, t);
434
385
  }
435
- function Se(t, r, a) {
436
- let o, l = process.cwd();
437
- function u(e) {
438
- let n = e ?? l;
439
- return o ||= $(t.config, n), o;
386
+ function me(t, r, i) {
387
+ let a, o = process.cwd();
388
+ function l(e) {
389
+ let n = e ?? o;
390
+ return a ||= $(t.config, n), a;
440
391
  }
441
- let d = t.framework;
442
- function f(e) {
443
- let t = u(e), r = t.compileOutDir.replace(/^\.\//, ""), i = t.catalogExtension ?? ".js", a = t.splitting ?? !1, o = t.sourceLocale;
392
+ let u = t.framework;
393
+ function d(e) {
394
+ let t = l(e), r = t.compileOutDir.replace(/^\.\//, ""), i = t.catalogExtension ?? ".js", a = t.splitting ?? !1;
395
+ a && a !== "dynamic" && a !== "static" && console.warn(`[fluenti] Invalid splitting value "${a}". Expected 'dynamic', 'static', or false. Falling back to 'dynamic'.`);
396
+ let o = a === "static" ? "static" : a ? "dynamic" : !1, s = t.sourceLocale;
444
397
  return {
445
398
  config: t,
446
399
  catalogDir: r,
447
400
  catalogExtension: i,
448
- splitting: a,
449
- sourceLocale: o,
401
+ splitting: o,
402
+ sourceLocale: s,
450
403
  localeCodes: n(t.locales),
451
- defaultBuildLocale: t.defaultBuildLocale ?? o
404
+ defaultBuildLocale: t.defaultBuildLocale ?? s
452
405
  };
453
406
  }
454
- let p = {
407
+ let f = {
455
408
  name: "fluenti:virtual",
456
409
  configResolved(e) {
457
- l = e.root, o = $(t.config, l), m(e.command);
410
+ o = e.root, a = $(t.config, o), m(e.command);
458
411
  },
459
412
  resolveId(e) {
460
- if (e.startsWith(be)) return "\0" + e;
461
- let { splitting: t } = f();
413
+ if (e.startsWith(fe)) return "\0" + e;
414
+ let { splitting: t } = d();
462
415
  if (t) {
463
- let t = q(e);
416
+ let t = X(e);
464
417
  if (t) return t;
465
418
  }
466
419
  },
467
420
  load(e) {
468
- let { catalogDir: t, catalogExtension: n, splitting: r, localeCodes: i, sourceLocale: o, defaultBuildLocale: s } = f();
469
- if (e.startsWith(xe)) return `export { default } from '${`${t}/${e.slice(26)}${n}`}'`;
421
+ let { catalogDir: t, catalogExtension: n, splitting: r, localeCodes: a, sourceLocale: s, defaultBuildLocale: c } = d();
422
+ if (e.startsWith(pe)) {
423
+ let r = e.slice(26);
424
+ return a.includes(r) ? `export { default } from '${`${t}/${r}${n}`}'` : void 0;
425
+ }
470
426
  if (r) {
471
- let r = J(e, {
472
- rootDir: l,
427
+ let r = Z(e, {
428
+ rootDir: o,
473
429
  catalogDir: t,
474
430
  catalogExtension: n,
475
- locales: i,
476
- sourceLocale: o,
477
- defaultBuildLocale: s,
478
- framework: d,
479
- runtimeGenerator: a
431
+ locales: a,
432
+ sourceLocale: s,
433
+ defaultBuildLocale: c,
434
+ framework: u,
435
+ runtimeGenerator: i
480
436
  });
481
437
  if (r) return r;
482
438
  }
483
439
  }
484
- }, y = s({ framework: d }), b = {
440
+ }, p = s({ framework: u }), v = {
485
441
  name: "fluenti:script-transform",
486
442
  enforce: "pre",
487
443
  transform(e, t) {
488
444
  if (t.includes("node_modules") || !t.match(/\.(vue|tsx|jsx|ts|js)(\?|$)/) || t.includes(".vue") && !t.includes("type=script")) return;
489
- let n = d === "vue" && t.includes(".vue"), r = e, i = !1;
445
+ let n = u === "vue" && t.includes(".vue"), r = e, i = !1;
490
446
  if (t.match(/\.[jt]sx(\?|$)/) && /<Trans[\s>]/.test(r)) {
491
- let e = y.transformTrans(r);
447
+ let e = p.transformTrans(r);
492
448
  e.transformed && (r = e.code, i = !0);
493
449
  }
494
450
  if (c(r)) {
495
- let e = y.transformScope(r, n ? { allowTopLevelImportedT: !0 } : void 0);
451
+ let e = p.transformScope(r, n ? { allowTopLevelImportedT: !0 } : void 0);
496
452
  if (e.transformed) return {
497
453
  code: e.code,
498
454
  map: null
@@ -503,84 +459,31 @@ function Se(t, r, a) {
503
459
  map: null
504
460
  } : void 0;
505
461
  }
506
- }, x = /* @__PURE__ */ new Map(), S = {
462
+ }, y = {
507
463
  name: "fluenti:build-split",
508
464
  transform(e, t) {
509
- let { splitting: n, config: r } = f();
465
+ let { splitting: n, config: r } = d();
510
466
  if (!n || !g(h(this)) || t.includes("node_modules") || !t.match(/\.(vue|tsx|jsx|ts|js)(\?|$)/)) return;
511
- let i = n === "static" ? "static" : "dynamic", a = r.idGenerator ? { hashFn: r.idGenerator } : void 0, o = i === "static" ? te(e, a) : ee(e, a);
512
- if (n === "per-route" && o.usedHashes.size > 0 && x.set(t, o.usedHashes), !o.needsCatalogImport) return;
513
- let s = n === "per-route" ? "per-route" : i;
514
- return {
515
- code: V(o.code, s, o.usedHashes, r.idGenerator),
467
+ let i = n === "static" ? "static" : "dynamic", a = r.idGenerator ? { hashFn: r.idGenerator } : void 0, o = i === "static" ? ne(e, a) : te(e, a);
468
+ if (o.needsCatalogImport) return {
469
+ code: G(o.code, i, o.usedHashes, r.idGenerator),
516
470
  map: null
517
471
  };
518
- },
519
- generateBundle(e, t) {
520
- let { splitting: n, localeCodes: r, catalogDir: a } = f();
521
- if (n !== "per-route" || x.size === 0) return;
522
- let o = /* @__PURE__ */ new Map();
523
- for (let [e, n] of Object.entries(t)) {
524
- if (n.type !== "chunk") continue;
525
- let t = /* @__PURE__ */ new Set();
526
- for (let e of Object.keys(n.modules)) {
527
- let n = x.get(e);
528
- if (n) for (let e of n) t.add(e);
529
- }
530
- t.size > 0 && o.set(e, t);
531
- }
532
- if (o.size === 0) return;
533
- let s = /* @__PURE__ */ new Map();
534
- for (let [e, t] of o) for (let n of t) {
535
- let t = s.get(n) ?? [];
536
- t.push(e), s.set(n, t);
537
- }
538
- let c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map();
539
- for (let [e, t] of s) if (t.length > 1) c.add(e);
540
- else {
541
- let n = X(t[0]), r = u.get(n) ?? /* @__PURE__ */ new Set();
542
- r.add(e), u.set(n, r);
543
- }
544
- let d = i(l, a);
545
- for (let e of r) {
546
- let t = ve(d, e);
547
- if (!t) {
548
- this.warn(`[fluenti] per-route splitting: compiled catalog for locale "${e}" not found in ${d} — skipping chunk generation`);
549
- continue;
550
- }
551
- let n = _e(t);
552
- if (c.size > 0) {
553
- let t = Z(c, n);
554
- this.emitFile({
555
- type: "asset",
556
- fileName: `_fluenti/shared-${e}.js`,
557
- source: t
558
- });
559
- }
560
- for (let [t, r] of u) {
561
- let i = Z(r, n);
562
- this.emitFile({
563
- type: "asset",
564
- fileName: `_fluenti/${t}-${e}.js`,
565
- source: i
566
- });
567
- }
568
- }
569
472
  }
570
- }, C = {
473
+ }, b = {
571
474
  name: "fluenti:build-compile",
572
475
  async buildStart() {
573
- let { config: e } = f();
476
+ let { config: e } = d();
574
477
  g(h(this)) && (e.buildAutoCompile ?? !0) && (e.onBeforeCompile && await e.onBeforeCompile() === !1 || (await _({
575
- cwd: l,
478
+ cwd: o,
576
479
  throwOnError: !0,
577
480
  compileOnly: !0
578
481
  }), e.onAfterCompile && await e.onAfterCompile()));
579
482
  }
580
- }, w = {
483
+ }, x = {
581
484
  name: "fluenti:dev",
582
485
  configureServer(t) {
583
- let { config: n, catalogDir: r } = f(t.config.root);
486
+ let { config: n, catalogDir: r } = d(t.config.root);
584
487
  if (!(n.devAutoCompile ?? !0)) return;
585
488
  let i = e(n.include ?? ["src/**/*.{vue,tsx,jsx,ts,js}"], [
586
489
  ...n.exclude ?? [],
@@ -591,13 +494,13 @@ function Se(t, r, a) {
591
494
  onSuccess: () => {}
592
495
  };
593
496
  n.parallelCompile && (a.parallelCompile = !0), n.onBeforeCompile && (a.onBeforeCompile = n.onBeforeCompile), n.onAfterCompile && (a.onAfterCompile = n.onAfterCompile);
594
- let o = v(a, n.devAutoCompileDelay ?? 500);
497
+ let o = ee(a, n.devAutoCompileDelay ?? 500);
595
498
  o(), t.watcher.on("change", (e) => {
596
499
  i(e) && o();
597
500
  });
598
501
  },
599
502
  hotUpdate({ file: e }) {
600
- let { catalogDir: t } = f();
503
+ let { catalogDir: t } = d();
601
504
  if (e.includes(t)) {
602
505
  let e = [...this.environment.moduleGraph.urlToModuleMap.entries()].filter(([e]) => e.includes("virtual:fluenti")).map(([, e]) => e);
603
506
  if (e.length > 0) return e;
@@ -605,15 +508,15 @@ function Se(t, r, a) {
605
508
  }
606
509
  };
607
510
  return [
608
- p,
511
+ f,
609
512
  ...r,
513
+ v,
610
514
  b,
611
- C,
612
- S,
613
- w
515
+ y,
516
+ x
614
517
  ];
615
518
  }
616
519
  //#endregion
617
- export { Se as createFluentiPlugins, o as createRuntimeGenerator, h as getPluginEnvironment, g as isBuildMode, J as loadVirtualSplitModule, q as resolveVirtualSplitId, m as setResolvedMode };
520
+ export { me as createFluentiPlugins, o as createRuntimeGenerator, h as getPluginEnvironment, g as isBuildMode, Z as loadVirtualSplitModule, X as resolveVirtualSplitId, m as setResolvedMode };
618
521
 
619
522
  //# sourceMappingURL=index.js.map