@fluenti/vite-plugin 0.2.1 → 0.3.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/client.d.ts +3 -9
- package/dist/build-transform.d.ts +8 -3
- package/dist/build-transform.d.ts.map +1 -1
- package/dist/dev-runner.d.ts +6 -0
- package/dist/dev-runner.d.ts.map +1 -1
- package/dist/index.cjs +3 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +336 -555
- package/dist/index.js.map +1 -1
- package/dist/mode-detect.d.ts +9 -2
- package/dist/mode-detect.d.ts.map +1 -1
- package/dist/runtime-template.d.ts +3 -0
- package/dist/runtime-template.d.ts.map +1 -0
- package/dist/sfc-transform.cjs +1 -1
- package/dist/sfc-transform.cjs.map +1 -1
- package/dist/sfc-transform.d.ts +1 -0
- package/dist/sfc-transform.d.ts.map +1 -1
- package/dist/sfc-transform.js +288 -174
- package/dist/sfc-transform.js.map +1 -1
- package/dist/types.d.ts +10 -48
- package/dist/types.d.ts.map +1 -1
- package/dist/virtual-modules.d.ts +3 -1
- package/dist/virtual-modules.d.ts.map +1 -1
- package/llms-full.txt +124 -0
- package/llms.txt +57 -0
- package/package.json +4 -3
- package/dist/scope-transform.d.ts +0 -3
- package/dist/scope-transform.d.ts.map +0 -1
- package/dist/trans-transform.d.ts +0 -3
- package/dist/trans-transform.d.ts.map +0 -1
package/dist/sfc-transform.js
CHANGED
|
@@ -1,195 +1,309 @@
|
|
|
1
|
-
import { hashMessage as e } from "@fluenti/core";
|
|
1
|
+
import { hashMessage as e } from "@fluenti/core/internal";
|
|
2
|
+
import { parse as t } from "@vue/compiler-sfc";
|
|
2
3
|
//#region src/sfc-transform.ts
|
|
3
|
-
|
|
4
|
+
var n = 1, r = 2, i = 5, a = 6, o = 7;
|
|
5
|
+
function s(e) {
|
|
4
6
|
return e.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
5
7
|
}
|
|
6
|
-
function
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
function r(e) {
|
|
10
|
-
let t = e.match(/<template(\s[^>]*)?>/);
|
|
11
|
-
if (!t) return e;
|
|
12
|
-
let n = t.index + t[0].length, r = e.lastIndexOf("</template>");
|
|
13
|
-
if (r < 0) return e;
|
|
14
|
-
let a = e.slice(0, n), l = e.slice(n, r), u = e.slice(r), d = /\bv-t\b/.test(l), f = /<Trans[\s>]/.test(l), p = /<Plural[\s/>]/.test(l);
|
|
15
|
-
return !d && !f && !p ? e : (d && (l = i(l), l = o(l)), f && (l = s(l)), p && (l = c(l)), a + l + u);
|
|
16
|
-
}
|
|
17
|
-
function i(e) {
|
|
18
|
-
return e.replace(/<(\w+)(\s[^>]*?)\bv-t\.(\w+)\b([^>]*?)>/g, (e, t, r, i, a) => {
|
|
19
|
-
if (i === "plural") return e;
|
|
20
|
-
let o = r + a, s = RegExp(`\\b${i}="([^"]*)"`), c = o.match(s);
|
|
21
|
-
if (!c) return e;
|
|
22
|
-
let l = c[1], u = n(l), d = r.replace(/\s*\bv-t\.\w+\b/, ""), f = a.replace(/\s*\bv-t\.\w+\b/, ""), p = RegExp(`\\s*\\b${i}="[^"]*"`);
|
|
23
|
-
return d = d.replace(p, ""), f = f.replace(p, ""), `<${t}${d} :${i}="$t(${u})"${f}>`;
|
|
24
|
-
});
|
|
8
|
+
function c(e) {
|
|
9
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25
10
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
11
|
+
function l(e) {
|
|
12
|
+
return `[${e.map((e) => {
|
|
13
|
+
let t = s(e.rawAttrs).replace(/"/g, """);
|
|
14
|
+
return `{ tag: '${s(e.tag)}', rawAttrs: '${t}' }`;
|
|
15
|
+
}).join(", ")}]`;
|
|
16
|
+
}
|
|
17
|
+
function u(t, n) {
|
|
18
|
+
return `{ id: '${s(n?.id ?? e(t, n?.context))}', message: '${s(t)}' }`;
|
|
19
|
+
}
|
|
20
|
+
function d(e) {
|
|
21
|
+
return typeof e == "string" ? e : e.content ?? "";
|
|
22
|
+
}
|
|
23
|
+
function f(e, t) {
|
|
24
|
+
for (let n of e) {
|
|
25
|
+
if (n.type === o && n.name === "bind" && (typeof n.arg?.content == "string" ? n.arg.content : void 0) === t) return { kind: "dynamic" };
|
|
26
|
+
if (n.type === a && n.name === t) return {
|
|
27
|
+
kind: "static",
|
|
28
|
+
value: typeof n.value?.content == "string" ? n.value.content : ""
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return { kind: "missing" };
|
|
32
|
+
}
|
|
33
|
+
function p(e, t) {
|
|
34
|
+
for (let n of e) if (n.type === o && n.name === "bind" && (typeof n.arg?.content == "string" ? n.arg.content : void 0) === t) return typeof n.exp?.content == "string" ? n.exp.content : void 0;
|
|
35
|
+
}
|
|
36
|
+
function m(e) {
|
|
37
|
+
let t = [], a = "";
|
|
38
|
+
for (let o of e) if (o.type === r) a += typeof o.content == "string" ? o.content : "";
|
|
39
|
+
else if (o.type === i) a += o.loc.source;
|
|
40
|
+
else if (o.type === n && o.tag) {
|
|
41
|
+
let e = t.length, n = (o.props ?? []).map((e) => e.loc.source).join(" ");
|
|
42
|
+
if ((o.isSelfClosing ?? !1) || !o.children?.length) t.push({
|
|
43
|
+
tag: o.tag,
|
|
44
|
+
rawAttrs: n,
|
|
45
|
+
selfClosing: !0,
|
|
46
|
+
innerContent: ""
|
|
47
|
+
}), a += `<${e}/>`;
|
|
48
|
+
else {
|
|
49
|
+
let r = o.children[0], i = o.children[o.children.length - 1], s = o.loc.source.slice(r.loc.start.offset - o.loc.start.offset, i.loc.end.offset - o.loc.start.offset);
|
|
50
|
+
t.push({
|
|
51
|
+
tag: o.tag,
|
|
52
|
+
rawAttrs: n,
|
|
53
|
+
selfClosing: !1,
|
|
54
|
+
innerContent: s
|
|
55
|
+
}), a += `<${e}>${s}</${e}>`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
28
58
|
return {
|
|
29
|
-
message:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
else if (/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(r) && !r.endsWith(".")) {
|
|
33
|
-
let e = r.split(".");
|
|
34
|
-
i = e[e.length - 1];
|
|
35
|
-
} else i = String(t.length);
|
|
36
|
-
return t.push(`${i}: ${r}`), `{${i}}`;
|
|
37
|
-
}),
|
|
38
|
-
vars: t
|
|
59
|
+
message: a,
|
|
60
|
+
elements: t,
|
|
61
|
+
hasElements: t.length > 0
|
|
39
62
|
};
|
|
40
63
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return `<${r}${d}${f} v-html="$vtRich(${n(p.replace(/<(\w+)((?:\s[^>]*)?)>([\s\S]*?)<\/\1>/g, (t, n, r, a) => {
|
|
58
|
-
let o = i++, s = {}, c = /(\w+)="([^"]*)"/g, l;
|
|
59
|
-
for (; (l = c.exec(r)) !== null;) s[l[1]] = l[2];
|
|
60
|
-
return e.push({
|
|
61
|
-
tag: n,
|
|
62
|
-
attrs: s
|
|
63
|
-
}), `<${o}>${a}</${o}>`;
|
|
64
|
-
}), { id: o })}, ${`[${e.map((e) => {
|
|
65
|
-
let n = Object.entries(e.attrs).map(([e, n]) => `${e}: '${t(n)}'`).join(", ");
|
|
66
|
-
return `{ tag: '${e.tag}', attrs: { ${n} } }`;
|
|
67
|
-
}).join(", ")}]`})"></${r}>`;
|
|
68
|
-
}
|
|
69
|
-
let { message: m, vars: h } = a(p), g = n(m, { id: o });
|
|
70
|
-
return h.length > 0 ? `<${r}${d}${f}>{{ $t(${g}, { ${h.join(", ")} }) }}</${r}>` : `<${r}${d}${f}>{{ $t(${g}) }}</${r}>`;
|
|
71
|
-
});
|
|
64
|
+
function h(e) {
|
|
65
|
+
let t = [], n = "";
|
|
66
|
+
for (let a of e) if (a.type === r) n += typeof a.content == "string" ? a.content : "";
|
|
67
|
+
else if (a.type === i) {
|
|
68
|
+
let e = (typeof a.content == "object" && a.content && typeof a.content.content == "string" ? a.content.content : "").trim(), r;
|
|
69
|
+
if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)) r = e;
|
|
70
|
+
else if (/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(e) && !e.endsWith(".")) {
|
|
71
|
+
let t = e.split(".");
|
|
72
|
+
r = t[t.length - 1];
|
|
73
|
+
} else r = String(t.length);
|
|
74
|
+
t.push(`${r}: ${e}`), n += `{${r}}`;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
message: n,
|
|
78
|
+
vars: t
|
|
79
|
+
};
|
|
72
80
|
}
|
|
73
|
-
function
|
|
74
|
-
return e.
|
|
75
|
-
let a = r ?? "";
|
|
76
|
-
if (/\bmessage\s*=/.test(a)) return e;
|
|
77
|
-
let o = l(a, "id");
|
|
78
|
-
if (o.kind === "dynamic") return e;
|
|
79
|
-
let s = l(a, "context");
|
|
80
|
-
if (!o.value && s.kind === "dynamic") return e;
|
|
81
|
-
let c = a.match(/\btag\s*=\s*"([^"]*)"/)?.[1] ?? "span", u = a.replace(/\s*\btag\s*=\s*"[^"]*"/, "").replace(/\s*\bid\s*=\s*"[^"]*"/, "").replace(/\s*:id\s*=\s*"[^"]*"/, "").replace(/\s*\bcontext\s*=\s*"[^"]*"/, "").replace(/\s*:context\s*=\s*"[^"]*"/, "").replace(/\s*\bcomment\s*=\s*"[^"]*"/, "").replace(/\s*:comment\s*=\s*"[^"]*"/, ""), d = i.trim();
|
|
82
|
-
if (/<(\w+)(\s[^>]*)?>[\s\S]*?<\/\1>/g.test(d)) {
|
|
83
|
-
let e = [], r = 0;
|
|
84
|
-
return `<${c}${u} v-html="$vtRich(${n(d.replace(/<(\w+)((?:\s[^>]*)?)>([\s\S]*?)<\/\1>/g, (t, n, i, a) => {
|
|
85
|
-
let o = r++, s = {}, c = /(\w[\w-]*)="([^"]*)"/g, l;
|
|
86
|
-
for (; (l = c.exec(i)) !== null;) s[l[1]] = l[2];
|
|
87
|
-
return e.push({
|
|
88
|
-
tag: n,
|
|
89
|
-
attrs: s
|
|
90
|
-
}), `<${o}>${a}</${o}>`;
|
|
91
|
-
}), {
|
|
92
|
-
id: o.value,
|
|
93
|
-
context: s.value
|
|
94
|
-
})}, ${`[${e.map((e) => {
|
|
95
|
-
let n = Object.entries(e.attrs).map(([e, n]) => `${e}: '${t(n)}'`).join(", ");
|
|
96
|
-
return `{ tag: '${e.tag}', attrs: { ${n} } }`;
|
|
97
|
-
}).join(", ")}]`})"></${c}>`;
|
|
98
|
-
}
|
|
99
|
-
return `<${c}${u}>{{ $t(${n(d, {
|
|
100
|
-
id: o.value,
|
|
101
|
-
context: s.value
|
|
102
|
-
})}) }}</${c}>`;
|
|
103
|
-
});
|
|
81
|
+
function g(e, t) {
|
|
82
|
+
return e.filter((e) => !t.has(e)).map((e) => e.loc.source).join(" ");
|
|
104
83
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
84
|
+
var _ = new Set([
|
|
85
|
+
"tag",
|
|
86
|
+
"id",
|
|
87
|
+
"context",
|
|
88
|
+
"comment"
|
|
89
|
+
]);
|
|
90
|
+
function v(e, t) {
|
|
91
|
+
let n = e.props ?? [], r = n.find((e) => e.type === o && e.name === "t" && (e.modifiers ?? []).length > 0);
|
|
92
|
+
if (!r) return;
|
|
93
|
+
let i = (r.modifiers ?? []).map(d);
|
|
94
|
+
if (i.length === 1 && i[0] === "plural") return;
|
|
95
|
+
let s = i.find((e) => e !== "plural");
|
|
96
|
+
if (!s) return;
|
|
97
|
+
let c = n.find((e) => e.type === a && e.name === s);
|
|
98
|
+
if (!c) return;
|
|
99
|
+
let l = u(typeof c.value?.content == "string" ? c.value.content : ""), f = g(n, new Set([r, c])), p = f ? ` ${f}` : "", m = e.tag;
|
|
100
|
+
if (e.isSelfClosing) {
|
|
101
|
+
let n = `<${m}${p} :${s}="$t(${l})" />`;
|
|
102
|
+
t.push({
|
|
103
|
+
start: e.loc.start.offset,
|
|
104
|
+
end: e.loc.end.offset,
|
|
105
|
+
replacement: n
|
|
113
106
|
});
|
|
114
|
-
|
|
115
|
-
let
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
} else {
|
|
108
|
+
let n = e.children ?? [], r = n.length > 0 ? n[0].loc.start.offset : e.loc.source.indexOf(">") + e.loc.start.offset + 1, i = `<${m}${p} :${s}="$t(${l})">`;
|
|
109
|
+
t.push({
|
|
110
|
+
start: e.loc.start.offset,
|
|
111
|
+
end: r,
|
|
112
|
+
replacement: i
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function y(e, t) {
|
|
117
|
+
let n = e.props ?? [], i = n.find((e) => e.type === o && e.name === "t");
|
|
118
|
+
if (!i) return;
|
|
119
|
+
let s = (i.modifiers ?? []).map(d), c = s.filter((e) => e !== "plural");
|
|
120
|
+
if (c.length > 0) {
|
|
121
|
+
let e = c[0];
|
|
122
|
+
if (n.some((t) => t.type === a && t.name === e)) return;
|
|
123
|
+
}
|
|
124
|
+
let f = s.includes("plural"), p = typeof i.exp?.content == "string" ? i.exp.content : void 0, _ = new Set(["plural"]), v = s.filter((e) => !_.has(e)), y = typeof i.arg?.content == "string" ? i.arg.content : void 0, b = y ? [y, ...v].join(".") : void 0, x = e.tag, S = e.children ?? [], C = g(n, new Set([i])), w = C ? ` ${C}` : "";
|
|
125
|
+
if (f && p) {
|
|
126
|
+
let n = S.filter((e) => e.type === r).map((e) => (typeof e.content == "string" ? e.content : "").trim()).join("").split("|").map((e) => e.trim()), i = `<${x}${w}>{{ $t(${u(`{${p}, plural, ${(n.length === 2 ? ["one", "other"] : [
|
|
119
127
|
"one",
|
|
120
|
-
"
|
|
128
|
+
"other",
|
|
129
|
+
"zero",
|
|
121
130
|
"few",
|
|
122
|
-
"many"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
"many"
|
|
132
|
+
].slice(0, n.length)).map((e, t) => `${e} {${n[t] ?? ""}}`).join(" ")}}`, { id: b })}, { ${p} }) }}</${x}>`;
|
|
133
|
+
t.push({
|
|
134
|
+
start: e.loc.start.offset,
|
|
135
|
+
end: e.loc.end.offset,
|
|
136
|
+
replacement: i
|
|
137
|
+
});
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
let T = m(S);
|
|
141
|
+
if (T.hasElements) {
|
|
142
|
+
let n = `<${x}${w} v-html="$vtRich(${u(T.message.trim(), { id: b })}, ${l(T.elements)})"></${x}>`;
|
|
143
|
+
t.push({
|
|
144
|
+
start: e.loc.start.offset,
|
|
145
|
+
end: e.loc.end.offset,
|
|
146
|
+
replacement: n
|
|
147
|
+
});
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
let { message: E, vars: D } = h(S), O = u(E.trim(), { id: b }), k;
|
|
151
|
+
k = D.length > 0 ? `<${x}${w}>{{ $t(${O}, { ${D.join(", ")} }) }}</${x}>` : `<${x}${w}>{{ $t(${O}) }}</${x}>`, t.push({
|
|
152
|
+
start: e.loc.start.offset,
|
|
153
|
+
end: e.loc.end.offset,
|
|
154
|
+
replacement: k
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function b(e, t) {
|
|
158
|
+
if (e.tag !== "Trans") return;
|
|
159
|
+
let n = e.props ?? [], i = e.children ?? [];
|
|
160
|
+
if (i.length === 0 || !i.some((e) => e.type === r ? (typeof e.content == "string" ? e.content : "").trim().length > 0 : !0) || n.some((e) => e.type === a && e.name === "message")) return;
|
|
161
|
+
let s = f(n, "id");
|
|
162
|
+
if (s.kind === "dynamic") return;
|
|
163
|
+
let c = f(n, "context");
|
|
164
|
+
if (!s.value && c.kind === "dynamic") return;
|
|
165
|
+
let d = f(n, "tag").value ?? "span", p = /* @__PURE__ */ new Set();
|
|
166
|
+
for (let e of n) if (e.type === a && _.has(e.name) && p.add(e), e.type === o && e.name === "bind") {
|
|
167
|
+
let t = typeof e.arg?.content == "string" ? e.arg.content : void 0;
|
|
168
|
+
t && _.has(t) && p.add(e);
|
|
169
|
+
}
|
|
170
|
+
let h = g(n, p), v = h ? ` ${h}` : "", y = m(i);
|
|
171
|
+
if (y.hasElements) {
|
|
172
|
+
let n = `<${d}${v} v-html="$vtRich(${u(y.message.trim(), {
|
|
173
|
+
id: s.value,
|
|
174
|
+
context: c.value
|
|
175
|
+
})}, ${l(y.elements)})"></${d}>`;
|
|
176
|
+
t.push({
|
|
177
|
+
start: e.loc.start.offset,
|
|
178
|
+
end: e.loc.end.offset,
|
|
179
|
+
replacement: n
|
|
180
|
+
});
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
let b = `<${d}${v}>{{ $t(${u(i.map((e) => e.type === r && typeof e.content == "string" ? e.content : "").join("").trim(), {
|
|
184
|
+
id: s.value,
|
|
185
|
+
context: c.value
|
|
186
|
+
})}) }}</${d}>`;
|
|
187
|
+
t.push({
|
|
188
|
+
start: e.loc.start.offset,
|
|
189
|
+
end: e.loc.end.offset,
|
|
190
|
+
replacement: b
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
var x = [
|
|
194
|
+
"zero",
|
|
195
|
+
"one",
|
|
196
|
+
"two",
|
|
197
|
+
"few",
|
|
198
|
+
"many",
|
|
199
|
+
"other"
|
|
200
|
+
];
|
|
201
|
+
function S(e, t) {
|
|
202
|
+
if (e.tag !== "Plural") return;
|
|
203
|
+
let i = e.props ?? [], s = f(i, "id"), c = f(i, "context");
|
|
204
|
+
if (s.kind === "dynamic" || !s.value && c.kind === "dynamic") return;
|
|
205
|
+
let d = p(i, "value");
|
|
206
|
+
if (!d) return;
|
|
207
|
+
let h = f(i, "tag").value ?? "span", v = e.children ?? [], y = [];
|
|
208
|
+
for (let e of v) if (e.type === n && e.tag === "template") {
|
|
209
|
+
let t = (e.props ?? []).find((e) => e.type === o && e.name === "slot");
|
|
210
|
+
if (t) {
|
|
211
|
+
let n = typeof t.arg?.content == "string" ? t.arg.content : void 0;
|
|
212
|
+
n && y.push({
|
|
213
|
+
cat: n,
|
|
214
|
+
children: e.children ?? []
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (y.length > 0) {
|
|
219
|
+
let n = [], f = [];
|
|
220
|
+
for (let e of x) {
|
|
221
|
+
let t = y.find((t) => t.cat === e);
|
|
127
222
|
if (!t) continue;
|
|
128
|
-
let
|
|
129
|
-
if (
|
|
130
|
-
let e =
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
tag: r,
|
|
136
|
-
attrs: s
|
|
137
|
-
}), `<${o}>${a}</${o}>`;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
let a = e === "zero" ? "=0" : e;
|
|
141
|
-
_.push(`${a} {${i}}`);
|
|
223
|
+
let i = m(t.children), a;
|
|
224
|
+
if (i.hasElements) {
|
|
225
|
+
let e = n.length;
|
|
226
|
+
a = i.message.replace(/<(\d+)(\/?)>/g, (t, n, r) => `<${e + Number(n)}${r}>`).replace(/<\/(\d+)>/g, (t, n) => `</${e + Number(n)}>`), n.push(...i.elements);
|
|
227
|
+
} else a = t.children.map((e) => e.type === r && typeof e.content == "string" ? e.content : "").join("").trim();
|
|
228
|
+
let o = e === "zero" ? "=0" : e;
|
|
229
|
+
f.push(`${o} {${a}}`);
|
|
142
230
|
}
|
|
143
|
-
if (
|
|
144
|
-
let
|
|
145
|
-
id:
|
|
146
|
-
context:
|
|
147
|
-
}),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
let n = Object.entries(e.attrs).map(([e, n]) => `${e}: '${t(n)}'`).join(", ");
|
|
152
|
-
return `{ tag: '${e.tag}', attrs: { ${n} } }`;
|
|
153
|
-
}).join(", ")}]`}, { count: ${p} })"></${m}>` : `<${m}${b} v-text="$t(${v}, { count: ${p} })"></${m}>`;
|
|
154
|
-
}), e.replace(/<Plural(\s[^>]*?)\/?>(?:<\/Plural>)?/g, (e, t) => {
|
|
155
|
-
let r = t ?? "", i = l(r, "id"), a = l(r, "context");
|
|
156
|
-
if (i.kind === "dynamic" || !i.value && a.kind === "dynamic") return e;
|
|
157
|
-
let o = r.match(/:value\s*=\s*"([^"]*)"/);
|
|
158
|
-
if (!o) return e;
|
|
159
|
-
let s = o[1], c = r.match(/\btag\s*=\s*"([^"]*)"/)?.[1] ?? "span", u = [
|
|
160
|
-
"zero",
|
|
161
|
-
"one",
|
|
162
|
-
"two",
|
|
163
|
-
"few",
|
|
164
|
-
"many",
|
|
165
|
-
"other"
|
|
166
|
-
], d = [];
|
|
167
|
-
for (let e of u) {
|
|
168
|
-
let t = RegExp(`(?<!:)\\b${e}\\s*=\\s*"([^"]*)"`), n = r.match(t);
|
|
169
|
-
if (n) {
|
|
170
|
-
let t = e === "zero" ? "=0" : e;
|
|
171
|
-
d.push(`${t} {${n[1]}}`);
|
|
172
|
-
}
|
|
231
|
+
if (f.length === 0) return;
|
|
232
|
+
let p = u(`{count, plural, ${f.join(" ")}}`, {
|
|
233
|
+
id: s.value,
|
|
234
|
+
context: c.value
|
|
235
|
+
}), v = new Set([..._, "tag"]), b = /* @__PURE__ */ new Set();
|
|
236
|
+
for (let e of i) if (e.type === a && v.has(e.name) && b.add(e), e.type === o && e.name === "bind") {
|
|
237
|
+
let t = typeof e.arg?.content == "string" ? e.arg.content : void 0;
|
|
238
|
+
(t === "value" || t && v.has(t)) && b.add(e);
|
|
173
239
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
240
|
+
let S = g(i, b), C = S ? ` ${S}` : "", w;
|
|
241
|
+
w = n.length > 0 ? `<${h}${C} v-html="$vtRich(${p}, ${l(n)}, { count: ${d} })"></${h}>` : `<${h}${C} v-text="$t(${p}, { count: ${d} })"></${h}>`, t.push({
|
|
242
|
+
start: e.loc.start.offset,
|
|
243
|
+
end: e.loc.end.offset,
|
|
244
|
+
replacement: w
|
|
245
|
+
});
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
let b = [], S = /* @__PURE__ */ new Set();
|
|
249
|
+
for (let e of x) {
|
|
250
|
+
let t = i.find((t) => t.type === a && t.name === e);
|
|
251
|
+
if (t) {
|
|
252
|
+
let n = typeof t.value?.content == "string" ? t.value.content : "", r = e === "zero" ? "=0" : e;
|
|
253
|
+
b.push(`${r} {${n}}`), S.add(t);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (b.length === 0) return;
|
|
257
|
+
let C = u(`{count, plural, ${b.join(" ")}}`, {
|
|
258
|
+
id: s.value,
|
|
259
|
+
context: c.value
|
|
260
|
+
}), w = new Set(S);
|
|
261
|
+
for (let e of i) if (e.type === a && (e.name === "tag" || _.has(e.name)) && w.add(e), e.type === o && e.name === "bind") {
|
|
262
|
+
let t = typeof e.arg?.content == "string" ? e.arg.content : void 0;
|
|
263
|
+
(t === "value" || t && _.has(t)) && w.add(e);
|
|
264
|
+
}
|
|
265
|
+
let T = g(i, w), E = `<${h}${T ? ` ${T}` : ""} v-text="$t(${C}, { count: ${d} })"></${h}>`;
|
|
266
|
+
t.push({
|
|
267
|
+
start: e.loc.start.offset,
|
|
268
|
+
end: e.loc.end.offset,
|
|
269
|
+
replacement: E
|
|
182
270
|
});
|
|
183
271
|
}
|
|
184
|
-
function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
272
|
+
function C(e) {
|
|
273
|
+
let t = [];
|
|
274
|
+
function r(e) {
|
|
275
|
+
if (e.type === n) {
|
|
276
|
+
if (e.tag === "Trans") {
|
|
277
|
+
b(e, t);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (e.tag === "Plural") {
|
|
281
|
+
S(e, t);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if ((e.props ?? []).some((e) => e.type === o && e.name === "t")) {
|
|
285
|
+
v(e, t), y(e, t);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
for (let t of e.children ?? []) r(t);
|
|
290
|
+
}
|
|
291
|
+
return r(e), t;
|
|
292
|
+
}
|
|
293
|
+
function w(e) {
|
|
294
|
+
if (!/<template[\s>]/.test(e) || e.lastIndexOf("</template>") < 0) return e;
|
|
295
|
+
let n = /\bv-t\b/.test(e), r = /<Trans[\s>]/.test(e), i = /<Plural[\s/>]/.test(e);
|
|
296
|
+
if (!n && !r && !i) return e;
|
|
297
|
+
let { descriptor: a } = t(e, { pad: !1 });
|
|
298
|
+
if (!a.template?.ast) return e;
|
|
299
|
+
let o = C(a.template.ast);
|
|
300
|
+
if (o.length === 0) return e;
|
|
301
|
+
o.sort((e, t) => t.start - e.start);
|
|
302
|
+
let s = e;
|
|
303
|
+
for (let e of o) s = s.slice(0, e.start) + e.replacement + s.slice(e.end);
|
|
304
|
+
return s;
|
|
191
305
|
}
|
|
192
306
|
//#endregion
|
|
193
|
-
export {
|
|
307
|
+
export { c as escapeRegExp, w as transformVtDirectives };
|
|
194
308
|
|
|
195
309
|
//# sourceMappingURL=sfc-transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sfc-transform.js","names":[],"sources":["../src/sfc-transform.ts"],"sourcesContent":["// ─── SFC pre-transform fallback for v-t ──────────────────────────────────────\n// Used when the nodeTransform can't be injected into @vitejs/plugin-vue\n\nimport { hashMessage } from '@fluenti/core'\n\nfunction escapeSingleQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n}\n\nfunction buildDescriptorExpression(\n message: string,\n options?: {\n id?: string | undefined\n context?: string | undefined\n },\n): string {\n const id = options?.id ?? hashMessage(message, options?.context)\n return `{ id: '${escapeSingleQuotedString(id)}', message: '${escapeSingleQuotedString(message)}' }`\n}\n\nexport function transformVtDirectives(sfc: string): string {\n const tmplOpen = sfc.match(/<template(\\s[^>]*)?>/)\n if (!tmplOpen) return sfc\n\n const tmplStart = tmplOpen.index! + tmplOpen[0].length\n const tmplCloseIdx = sfc.lastIndexOf('</template>')\n if (tmplCloseIdx < 0) return sfc\n\n const beforeTemplate = sfc.slice(0, tmplStart)\n let template = sfc.slice(tmplStart, tmplCloseIdx)\n const afterTemplate = sfc.slice(tmplCloseIdx)\n\n const hasVt = /\\bv-t\\b/.test(template)\n const hasTrans = /<Trans[\\s>]/.test(template)\n const hasPlural = /<Plural[\\s/>]/.test(template)\n\n if (!hasVt && !hasTrans && !hasPlural) return sfc\n\n if (hasVt) {\n template = transformVtAttribute(template)\n template = transformVtContent(template)\n }\n if (hasTrans) {\n template = transformTransSFC(template)\n }\n if (hasPlural) {\n template = transformPluralSFC(template)\n }\n\n return beforeTemplate + template + afterTemplate\n}\n\nfunction transformVtAttribute(template: string): string {\n const vtAttrRegex = /<(\\w+)(\\s[^>]*?)\\bv-t\\.(\\w+)\\b([^>]*?)>/g\n\n return template.replace(vtAttrRegex, (_match, tag: string, before: string, attrName: string, after: string) => {\n if (attrName === 'plural') return _match\n\n const allAttrs = before + after\n const attrRegex = new RegExp(`\\\\b${attrName}=\"([^\"]*)\"`)\n const attrMatch = allAttrs.match(attrRegex)\n if (!attrMatch) return _match\n\n const attrValue = attrMatch[1]!\n const descriptor = buildDescriptorExpression(attrValue)\n\n let newBefore = before.replace(/\\s*\\bv-t\\.\\w+\\b/, '')\n let newAfter = after.replace(/\\s*\\bv-t\\.\\w+\\b/, '')\n\n const staticAttrPattern = new RegExp(`\\\\s*\\\\b${attrName}=\"[^\"]*\"`)\n newBefore = newBefore.replace(staticAttrPattern, '')\n newAfter = newAfter.replace(staticAttrPattern, '')\n\n return `<${tag}${newBefore} :${attrName}=\"$t(${descriptor})\"${newAfter}>`\n })\n}\n\n/**\n * Extract `{{ expr }}` interpolations from v-t content.\n * Returns the message with ICU `{var}` placeholders and a list of variable entries.\n */\nfunction extractTemplateVars(content: string): { message: string; vars: string[] } {\n const vars: string[] = []\n const message = content.replace(/\\{\\{\\s*([^}]+?)\\s*\\}\\}/g, (_m, expr: string) => {\n const trimmed = expr.trim()\n // Strategy B: simple ident → {name}, property → {lastSegment}, complex → {0}\n let varName: string\n if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(trimmed)) {\n varName = trimmed\n } else if (/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(trimmed) && !trimmed.endsWith('.')) {\n const parts = trimmed.split('.')\n varName = parts[parts.length - 1]!\n } else {\n varName = String(vars.length)\n }\n vars.push(`${varName}: ${trimmed}`)\n return `{${varName}}`\n })\n return { message, vars }\n}\n\nfunction transformVtContent(template: string): string {\n const vtContentRegex = /<(\\w+)(\\s[^>]*?)\\bv-t(?::([a-zA-Z0-9_.]+))?(?:\\.plural)?(?:=\"([^\"]*)\")?\\b([^>]*)>([\\s\\S]*?)<\\/\\1>/g\n\n return template.replace(vtContentRegex, (_match, tag: string, before: string, explicitId: string | undefined, bindExpr: string | undefined, after: string, content: string) => {\n const isPlural = _match.includes('v-t.plural')\n\n let cleanBefore = before.replace(/\\s*\\bv-t(?::[a-zA-Z0-9_.]+)?(?:\\.plural)?(?:=\"[^\"]*\")?\\b/, '')\n let cleanAfter = after.replace(/\\s*\\bv-t(?::[a-zA-Z0-9_.]+)?(?:\\.plural)?(?:=\"[^\"]*\")?\\b/, '')\n\n if (isPlural && bindExpr) {\n const forms = content.trim().split('|').map((s: string) => s.trim())\n const categories = forms.length === 2\n ? ['one', 'other']\n : ['one', 'other', 'zero', 'few', 'many'].slice(0, forms.length)\n const icuParts = categories.map((cat, i) => `${cat} {${forms[i] ?? ''}}`)\n const icuMessage = `{${bindExpr}, plural, ${icuParts.join(' ')}}`\n const descriptor = buildDescriptorExpression(icuMessage, { id: explicitId })\n return `<${tag}${cleanBefore}${cleanAfter}>{{ $t(${descriptor}, { ${bindExpr} }) }}</${tag}>`\n }\n\n const rawContent = content.trim()\n\n // Check for child HTML elements → rich text with $vtRich\n const childElementRegex = /<(\\w+)(\\s[^>]*)?>[\\s\\S]*?<\\/\\1>/g\n if (childElementRegex.test(rawContent)) {\n const elements: Array<{ tag: string; attrs: Record<string, string> }> = []\n let elemIdx = 0\n const richMessage = rawContent.replace(/<(\\w+)((?:\\s[^>]*)?)>([\\s\\S]*?)<\\/\\1>/g,\n (_m, childTag: string, attrStr: string, innerContent: string) => {\n const idx = elemIdx++\n const attrs: Record<string, string> = {}\n const attrRegex = /(\\w+)=\"([^\"]*)\"/g\n let attrMatch\n while ((attrMatch = attrRegex.exec(attrStr)) !== null) {\n attrs[attrMatch[1]!] = attrMatch[2]!\n }\n elements.push({ tag: childTag, attrs })\n return `<${idx}>${innerContent}</${idx}>`\n },\n )\n const descriptor = buildDescriptorExpression(richMessage, { id: explicitId })\n // Build elements as JS array literal to avoid JSON quote conflicts with v-html=\"...\"\n const elemEntries = elements.map(el => {\n const attrEntries = Object.entries(el.attrs)\n .map(([k, v]) => `${k}: '${escapeSingleQuotedString(v)}'`)\n .join(', ')\n return `{ tag: '${el.tag}', attrs: { ${attrEntries} } }`\n })\n const elementsLiteral = `[${elemEntries.join(', ')}]`\n return `<${tag}${cleanBefore}${cleanAfter} v-html=\"$vtRich(${descriptor}, ${elementsLiteral})\"></${tag}>`\n }\n\n const { message, vars } = extractTemplateVars(rawContent)\n const descriptor = buildDescriptorExpression(message, { id: explicitId })\n\n if (vars.length > 0) {\n return `<${tag}${cleanBefore}${cleanAfter}>{{ $t(${descriptor}, { ${vars.join(', ')} }) }}</${tag}>`\n }\n\n return `<${tag}${cleanBefore}${cleanAfter}>{{ $t(${descriptor}) }}</${tag}>`\n })\n}\n\n// ─── <Trans> SFC pre-transform ────────────────────────────────────────────────\n\nfunction transformTransSFC(template: string): string {\n // Match <Trans ...>content</Trans> — skip those with a `message` prop (old API)\n const transRegex = /<Trans(\\s[^>]*)?>(?!\\s*$)([\\s\\S]*?)<\\/Trans>/g\n\n return template.replace(transRegex, (_match, attrStr: string | undefined, content: string) => {\n const attrs = attrStr ?? ''\n\n // If <Trans> has a `message` prop, don't transform (old API)\n if (/\\bmessage\\s*=/.test(attrs)) return _match\n\n const explicitId = readStaticSfcAttr(attrs, 'id')\n if (explicitId.kind === 'dynamic') return _match\n\n const context = readStaticSfcAttr(attrs, 'context')\n if (!explicitId.value && context.kind === 'dynamic') return _match\n\n // Extract tag prop (default: 'span')\n const tagMatch = attrs.match(/\\btag\\s*=\\s*\"([^\"]*)\"/)\n const wrapperTag = tagMatch?.[1] ?? 'span'\n\n // Remove Trans-only props from the generated DOM element.\n const cleanAttrs = attrs\n .replace(/\\s*\\btag\\s*=\\s*\"[^\"]*\"/, '')\n .replace(/\\s*\\bid\\s*=\\s*\"[^\"]*\"/, '')\n .replace(/\\s*:id\\s*=\\s*\"[^\"]*\"/, '')\n .replace(/\\s*\\bcontext\\s*=\\s*\"[^\"]*\"/, '')\n .replace(/\\s*:context\\s*=\\s*\"[^\"]*\"/, '')\n .replace(/\\s*\\bcomment\\s*=\\s*\"[^\"]*\"/, '')\n .replace(/\\s*:comment\\s*=\\s*\"[^\"]*\"/, '')\n\n const rawContent = content.trim()\n\n // Check for child HTML elements → rich text with $vtRich\n const childElementRegex = /<(\\w+)(\\s[^>]*)?>[\\s\\S]*?<\\/\\1>/g\n if (childElementRegex.test(rawContent)) {\n const elements: Array<{ tag: string; attrs: Record<string, string> }> = []\n let elemIdx = 0\n const richMessage = rawContent.replace(/<(\\w+)((?:\\s[^>]*)?)>([\\s\\S]*?)<\\/\\1>/g,\n (_m, childTag: string, childAttrStr: string, innerContent: string) => {\n const idx = elemIdx++\n const childAttrs: Record<string, string> = {}\n const attrRegex = /(\\w[\\w-]*)=\"([^\"]*)\"/g\n let attrMatch\n while ((attrMatch = attrRegex.exec(childAttrStr)) !== null) {\n childAttrs[attrMatch[1]!] = attrMatch[2]!\n }\n elements.push({ tag: childTag, attrs: childAttrs })\n return `<${idx}>${innerContent}</${idx}>`\n },\n )\n const descriptor = buildDescriptorExpression(richMessage, {\n id: explicitId.value,\n context: context.value,\n })\n const elemEntries = elements.map(el => {\n const attrEntries = Object.entries(el.attrs)\n .map(([k, v]) => `${k}: '${escapeSingleQuotedString(v)}'`)\n .join(', ')\n return `{ tag: '${el.tag}', attrs: { ${attrEntries} } }`\n })\n const elementsLiteral = `[${elemEntries.join(', ')}]`\n return `<${wrapperTag}${cleanAttrs} v-html=\"$vtRich(${descriptor}, ${elementsLiteral})\"></${wrapperTag}>`\n }\n\n // Plain text\n const descriptor = buildDescriptorExpression(rawContent, {\n id: explicitId.value,\n context: context.value,\n })\n return `<${wrapperTag}${cleanAttrs}>{{ $t(${descriptor}) }}</${wrapperTag}>`\n })\n}\n\n// ─── <Plural> SFC pre-transform ──────────────────────────────────────────────\n\nfunction transformPluralSFC(template: string): string {\n // First handle <Plural> with template slot children (rich text)\n const pluralSlotRegex = /<Plural(\\s[^>]*?)>([\\s\\S]*?)<\\/Plural>/g\n template = template.replace(pluralSlotRegex, (_match, attrStr: string, content: string) => {\n const attrs = attrStr ?? ''\n const explicitId = readStaticSfcAttr(attrs, 'id')\n const context = readStaticSfcAttr(attrs, 'context')\n if (explicitId.kind === 'dynamic') return _match\n if (!explicitId.value && context.kind === 'dynamic') return _match\n\n // Check if content has template slots\n const templateSlotRegex = /<template\\s+#(\\w+)\\s*>([\\s\\S]*?)<\\/template>/g\n const slots: Array<{ cat: string; content: string }> = []\n let slotMatch\n while ((slotMatch = templateSlotRegex.exec(content)) !== null) {\n slots.push({ cat: slotMatch[1]!, content: slotMatch[2]!.trim() })\n }\n\n if (slots.length === 0) return _match\n\n // Extract :value binding\n const valueMatch = attrs.match(/:value\\s*=\\s*\"([^\"]*)\"/)\n if (!valueMatch) return _match\n const valueExpr = valueMatch[1]!\n\n // Extract tag prop (default: 'span')\n const tagMatch = attrs.match(/\\btag\\s*=\\s*\"([^\"]*)\"/)\n const wrapperTag = tagMatch?.[1] ?? 'span'\n\n const PLURAL_CATS = ['zero', 'one', 'two', 'few', 'many', 'other'] as const\n const allElements: Array<{ tag: string; attrs: Record<string, string> }> = []\n const icuParts: string[] = []\n\n for (const cat of PLURAL_CATS) {\n const slot = slots.find(s => s.cat === cat)\n if (!slot) continue\n\n const slotContent = slot.content\n // Check for child HTML elements → rich text\n const childElementRegex = /<(\\w+)((?:\\s[^>]*)?)>([\\s\\S]*?)<\\/\\1>/g\n let branchMessage = slotContent\n\n if (childElementRegex.test(slotContent)) {\n const baseIndex = allElements.length\n let elemIdx = 0\n branchMessage = slotContent.replace(/<(\\w+)((?:\\s[^>]*)?)>([\\s\\S]*?)<\\/\\1>/g,\n (_m, childTag: string, childAttrStr: string, innerContent: string) => {\n const globalIdx = baseIndex + elemIdx++\n const childAttrs: Record<string, string> = {}\n const attrRegex = /(\\w[\\w-]*)=\"([^\"]*)\"/g\n let attrMatch\n while ((attrMatch = attrRegex.exec(childAttrStr)) !== null) {\n childAttrs[attrMatch[1]!] = attrMatch[2]!\n }\n allElements.push({ tag: childTag, attrs: childAttrs })\n return `<${globalIdx}>${innerContent}</${globalIdx}>`\n },\n )\n }\n\n const icuKey = cat === 'zero' ? '=0' : cat\n icuParts.push(`${icuKey} {${branchMessage}}`)\n }\n\n if (icuParts.length === 0) return _match\n\n const icuMessage = `{count, plural, ${icuParts.join(' ')}}`\n const descriptor = buildDescriptorExpression(icuMessage, {\n id: explicitId.value,\n context: context.value,\n })\n\n // Collect remaining attrs (strip Plural-specific ones)\n let cleanAttrs = attrs\n cleanAttrs = cleanAttrs.replace(/:value\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\btag\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*\\bid\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*:id\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*\\bcontext\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*:context\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*\\bcomment\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*:comment\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s+/g, ' ').trim()\n const attrsPart = cleanAttrs ? ` ${cleanAttrs}` : ''\n\n if (allElements.length > 0) {\n const elemEntries = allElements.map(el => {\n const attrEntries = Object.entries(el.attrs)\n .map(([k, v]) => `${k}: '${escapeSingleQuotedString(v)}'`)\n .join(', ')\n return `{ tag: '${el.tag}', attrs: { ${attrEntries} } }`\n })\n const elementsLiteral = `[${elemEntries.join(', ')}]`\n return `<${wrapperTag}${attrsPart} v-html=\"$vtRich(${descriptor}, ${elementsLiteral}, { count: ${valueExpr} })\"></${wrapperTag}>`\n }\n\n return `<${wrapperTag}${attrsPart} v-text=\"$t(${descriptor}, { count: ${valueExpr} })\"></${wrapperTag}>`\n })\n\n // Then handle <Plural ... /> (self-closing) or <Plural ...></Plural> without slot content\n const pluralRegex = /<Plural(\\s[^>]*?)\\/?>(?:<\\/Plural>)?/g\n\n return template.replace(pluralRegex, (_match, attrStr: string) => {\n const attrs = attrStr ?? ''\n const explicitId = readStaticSfcAttr(attrs, 'id')\n const context = readStaticSfcAttr(attrs, 'context')\n if (explicitId.kind === 'dynamic') return _match\n if (!explicitId.value && context.kind === 'dynamic') return _match\n\n // Extract :value binding\n const valueMatch = attrs.match(/:value\\s*=\\s*\"([^\"]*)\"/)\n if (!valueMatch) return _match\n const valueExpr = valueMatch[1]!\n\n // Extract tag prop (default: 'span')\n const tagMatch = attrs.match(/\\btag\\s*=\\s*\"([^\"]*)\"/)\n const wrapperTag = tagMatch?.[1] ?? 'span'\n\n // Extract plural categories\n const PLURAL_CATEGORIES = ['zero', 'one', 'two', 'few', 'many', 'other'] as const\n const icuParts: string[] = []\n\n for (const cat of PLURAL_CATEGORIES) {\n // Match static prop only (not :zero=\"...\")\n const catRegex = new RegExp(`(?<!:)\\\\b${cat}\\\\s*=\\\\s*\"([^\"]*)\"`)\n const catMatch = attrs.match(catRegex)\n if (catMatch) {\n const icuKey = cat === 'zero' ? '=0' : cat\n icuParts.push(`${icuKey} {${catMatch[1]}}`)\n }\n }\n\n if (icuParts.length === 0) return _match\n\n const icuMessage = `{count, plural, ${icuParts.join(' ')}}`\n const descriptor = buildDescriptorExpression(icuMessage, {\n id: explicitId.value,\n context: context.value,\n })\n\n // Collect remaining attrs (strip Plural-specific ones)\n let cleanAttrs = attrs\n cleanAttrs = cleanAttrs.replace(/:value\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\btag\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*\\bid\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*:id\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*\\bcontext\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*:context\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*\\bcomment\\s*=\\s*\"[^\"]*\"/, '')\n cleanAttrs = cleanAttrs.replace(/\\s*:comment\\s*=\\s*\"[^\"]*\"/, '')\n for (const cat of PLURAL_CATEGORIES) {\n cleanAttrs = cleanAttrs.replace(new RegExp(`(?<!:)\\\\b${cat}\\\\s*=\\\\s*\"[^\"]*\"`), '')\n }\n cleanAttrs = cleanAttrs.replace(/\\s+/g, ' ').trim()\n const attrsPart = cleanAttrs ? ` ${cleanAttrs}` : ''\n\n return `<${wrapperTag}${attrsPart} v-text=\"$t(${descriptor}, { count: ${valueExpr} })\"></${wrapperTag}>`\n })\n}\n\ninterface StaticSfcAttrValue {\n kind: 'missing' | 'static' | 'dynamic'\n value?: string\n}\n\nfunction readStaticSfcAttr(attrs: string, name: string): StaticSfcAttrValue {\n if (new RegExp(`(?:^|\\\\s):${name}\\\\s*=`).test(attrs)) {\n return { kind: 'dynamic' }\n }\n\n const match = attrs.match(new RegExp(`\\\\b${name}\\\\s*=\\\\s*\"([^\"]*)\"`))\n if (!match) {\n return { kind: 'missing' }\n }\n\n return {\n kind: 'static',\n value: match[1] ?? '',\n }\n}\n"],"mappings":";;AAKA,SAAS,EAAyB,GAAuB;AACvD,QAAO,EAAM,QAAQ,OAAO,OAAO,CAAC,QAAQ,MAAM,MAAM;;AAG1D,SAAS,EACP,GACA,GAIQ;AAER,QAAO,UAAU,EADN,GAAS,MAAM,EAAY,GAAS,GAAS,QAAQ,CACnB,CAAC,eAAe,EAAyB,EAAQ,CAAC;;AAGjG,SAAgB,EAAsB,GAAqB;CACzD,IAAM,IAAW,EAAI,MAAM,uBAAuB;AAClD,KAAI,CAAC,EAAU,QAAO;CAEtB,IAAM,IAAY,EAAS,QAAS,EAAS,GAAG,QAC1C,IAAe,EAAI,YAAY,cAAc;AACnD,KAAI,IAAe,EAAG,QAAO;CAE7B,IAAM,IAAiB,EAAI,MAAM,GAAG,EAAU,EAC1C,IAAW,EAAI,MAAM,GAAW,EAAa,EAC3C,IAAgB,EAAI,MAAM,EAAa,EAEvC,IAAQ,UAAU,KAAK,EAAS,EAChC,IAAW,cAAc,KAAK,EAAS,EACvC,IAAY,gBAAgB,KAAK,EAAS;AAehD,QAbI,CAAC,KAAS,CAAC,KAAY,CAAC,IAAkB,KAE1C,MACF,IAAW,EAAqB,EAAS,EACzC,IAAW,EAAmB,EAAS,GAErC,MACF,IAAW,EAAkB,EAAS,GAEpC,MACF,IAAW,EAAmB,EAAS,GAGlC,IAAiB,IAAW;;AAGr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AAW,QAAQ,wBAAwB,GAAG,EAC3D,IAAa,EAAW,QAAQ,8BAA8B,GAAG,EACjE,IAAa,EAAW,QAAQ,6BAA6B,GAAG,EAChE,IAAa,EAAW,QAAQ,8BAA8B,GAAG,EACjE,IAAa,EAAW,QAAQ,6BAA6B,GAAG;AAChE,OAAK,IAAM,KAAO,EAChB,KAAa,EAAW,QAAY,OAAO,YAAY,EAAI,kBAAkB,EAAE,GAAG;AAKpF,SAHA,IAAa,EAAW,QAAQ,QAAQ,IAAI,CAAC,MAAM,EAG5C,IAAI,IAFO,IAAa,IAAI,MAAe,GAEhB,cAAc,EAAW,aAAa,EAAU,SAAS,EAAW;GACtG;;AAQJ,SAAS,EAAkB,GAAe,GAAkC;AAC1E,KAAQ,OAAO,aAAa,EAAK,OAAO,CAAC,KAAK,EAAM,CAClD,QAAO,EAAE,MAAM,WAAW;CAG5B,IAAM,IAAQ,EAAM,MAAU,OAAO,MAAM,EAAK,oBAAoB,CAAC;AAKrE,QAJK,IAIE;EACL,MAAM;EACN,OAAO,EAAM,MAAM;EACpB,GANQ,EAAE,MAAM,WAAW"}
|
|
1
|
+
{"version":3,"file":"sfc-transform.js","names":[],"sources":["../src/sfc-transform.ts"],"sourcesContent":["// ─── SFC pre-transform fallback for v-t ──────────────────────────────────────\n// Used when the nodeTransform can't be injected into @vitejs/plugin-vue\n// Uses @vue/compiler-sfc AST instead of regex for robust template parsing.\n\nimport { hashMessage } from '@fluenti/core/internal'\nimport { parse as parseSFC } from '@vue/compiler-sfc'\n\n// Vue compiler AST node types\nconst NT_ELEMENT = 1\nconst NT_TEXT = 2\nconst NT_INTERPOLATION = 5\nconst NT_ATTRIBUTE = 6\nconst NT_DIRECTIVE = 7\n\ninterface ASTNode {\n type: number\n tag?: string\n props?: ASTNode[]\n children?: ASTNode[]\n content?: string | ASTNode\n name?: string\n arg?: ASTNode\n exp?: ASTNode\n modifiers?: Array<string | ASTNode>\n value?: ASTNode\n isSelfClosing?: boolean\n loc: {\n source: string\n start: { offset: number; line: number; column: number }\n end: { offset: number; line: number; column: number }\n }\n}\n\n// ─── Preserved utility functions ──────────────────────────────────────────────\n\nfunction escapeSingleQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n}\n\nexport function escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\ninterface RichChild {\n tag: string\n rawAttrs: string\n selfClosing: boolean\n innerContent: string\n}\n\ninterface ExtractedRich {\n message: string\n elements: RichChild[]\n hasElements: boolean\n}\n\ninterface StaticSfcAttrValue {\n kind: 'missing' | 'static' | 'dynamic'\n value?: string\n}\n\ninterface ReplaceOp {\n start: number\n end: number\n replacement: string\n}\n\n// ─── Output helpers (no parsing, kept as-is) ──────────────────────────────────\n\nfunction serializeElements(elements: readonly RichChild[]): string {\n const entries = elements.map(el => {\n // Escape for JS string + HTML attribute context (v-html=\"...\"):\n // " is decoded by HTML parser before JS evaluates the expression\n const rawAttrsStr = escapeSingleQuotedString(el.rawAttrs).replace(/\"/g, '"')\n return `{ tag: '${escapeSingleQuotedString(el.tag)}', rawAttrs: '${rawAttrsStr}' }`\n })\n return `[${entries.join(', ')}]`\n}\n\nfunction buildDescriptorExpression(\n message: string,\n options?: {\n id?: string | undefined\n context?: string | undefined\n },\n): string {\n const id = options?.id ?? hashMessage(message, options?.context)\n return `{ id: '${escapeSingleQuotedString(id)}', message: '${escapeSingleQuotedString(message)}' }`\n}\n\n// ─── AST helper functions ─────────────────────────────────────────────────────\n\nfunction getModifierContent(mod: string | ASTNode): string {\n return typeof mod === 'string' ? mod : (mod.content as string) ?? ''\n}\n\nfunction readAttr(props: ASTNode[], name: string): StaticSfcAttrValue {\n for (const prop of props) {\n if (prop.type === NT_DIRECTIVE && prop.name === 'bind') {\n const argContent = typeof prop.arg?.content === 'string' ? prop.arg.content : undefined\n if (argContent === name) {\n return { kind: 'dynamic' }\n }\n }\n if (prop.type === NT_ATTRIBUTE && prop.name === name) {\n const value = typeof prop.value?.content === 'string' ? prop.value.content : ''\n return { kind: 'static', value }\n }\n }\n return { kind: 'missing' }\n}\n\nfunction getBindingExpr(props: ASTNode[], name: string): string | undefined {\n for (const prop of props) {\n if (prop.type === NT_DIRECTIVE && prop.name === 'bind') {\n const argContent = typeof prop.arg?.content === 'string' ? prop.arg.content : undefined\n if (argContent === name) {\n return typeof prop.exp?.content === 'string' ? prop.exp.content : undefined\n }\n }\n }\n return undefined\n}\n\n/**\n * Extract rich children from AST child nodes.\n * Converts ElementNodes to indexed placeholders, TextNodes to literal text,\n * and InterpolationNodes to their raw source ({{ expr }}).\n */\nfunction extractRichFromAST(children: ASTNode[]): ExtractedRich {\n const elements: RichChild[] = []\n let message = ''\n\n for (const child of children) {\n if (child.type === NT_TEXT) {\n message += typeof child.content === 'string' ? child.content : ''\n } else if (child.type === NT_INTERPOLATION) {\n message += child.loc.source\n } else if (child.type === NT_ELEMENT && child.tag) {\n const idx = elements.length\n const rawAttrs = (child.props ?? [])\n .map(p => p.loc.source)\n .join(' ')\n const isSelfClosing = child.isSelfClosing ?? false\n\n if (isSelfClosing || !child.children?.length) {\n elements.push({ tag: child.tag, rawAttrs, selfClosing: true, innerContent: '' })\n message += `<${idx}/>`\n } else {\n // Collect inner content from the original source between children range\n const firstChild = child.children[0]!\n const lastChild = child.children[child.children.length - 1]!\n const innerContent = child.loc.source.slice(\n firstChild.loc.start.offset - child.loc.start.offset,\n lastChild.loc.end.offset - child.loc.start.offset,\n )\n elements.push({ tag: child.tag, rawAttrs, selfClosing: false, innerContent })\n message += `<${idx}>${innerContent}</${idx}>`\n }\n }\n }\n\n return { message, elements, hasElements: elements.length > 0 }\n}\n\n/**\n * Extract {{ expr }} interpolations from AST children for v-t content.\n * Returns message with ICU {var} placeholders and variable entries.\n */\nfunction extractVarsFromAST(children: ASTNode[]): { message: string; vars: string[] } {\n const vars: string[] = []\n let message = ''\n\n for (const child of children) {\n if (child.type === NT_TEXT) {\n message += typeof child.content === 'string' ? child.content : ''\n } else if (child.type === NT_INTERPOLATION) {\n const expr = typeof child.content === 'object' && child.content\n ? typeof child.content.content === 'string' ? child.content.content : ''\n : ''\n const trimmed = expr.trim()\n\n let varName: string\n if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(trimmed)) {\n varName = trimmed\n } else if (/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(trimmed) && !trimmed.endsWith('.')) {\n const parts = trimmed.split('.')\n varName = parts[parts.length - 1]!\n } else {\n varName = String(vars.length)\n }\n vars.push(`${varName}: ${trimmed}`)\n message += `{${varName}}`\n }\n }\n\n return { message, vars }\n}\n\n/**\n * Build the list of remaining props for an element, excluding specific prop nodes.\n * Returns their raw source strings joined with spaces.\n */\nfunction buildCleanAttrs(props: ASTNode[], exclude: Set<ASTNode>): string {\n return props\n .filter(p => !exclude.has(p))\n .map(p => p.loc.source)\n .join(' ')\n}\n\n// ─── Transform collectors ─────────────────────────────────────────────────────\n\nconst TRANS_ONLY_PROPS = new Set(['tag', 'id', 'context', 'comment'])\n\nfunction collectVtAttrOps(node: ASTNode, ops: ReplaceOp[]): void {\n const props = node.props ?? []\n const vtDir = props.find(\n p => p.type === NT_DIRECTIVE && p.name === 't' && (p.modifiers ?? []).length > 0,\n )\n if (!vtDir) return\n\n const modifiers = (vtDir.modifiers ?? []).map(getModifierContent)\n // Skip v-t.plural — handled by collectVtContentOps\n if (modifiers.length === 1 && modifiers[0] === 'plural') return\n\n const attrName = modifiers.find(m => m !== 'plural')\n if (!attrName) return\n\n // Find the corresponding static attribute\n const staticAttr = props.find(\n p => p.type === NT_ATTRIBUTE && p.name === attrName,\n )\n if (!staticAttr) return\n const attrValue = typeof staticAttr.value?.content === 'string' ? staticAttr.value.content : ''\n\n const descriptor = buildDescriptorExpression(attrValue)\n\n // Build new opening tag: keep all props except v-t.X and the static attr, add :attrName=\"$t(...)\"\n const exclude = new Set([vtDir, staticAttr])\n const remainingAttrs = buildCleanAttrs(props, exclude)\n const newAttrsPart = remainingAttrs ? ` ${remainingAttrs}` : ''\n\n // Replace the opening tag portion of the element\n const tag = node.tag!\n if (node.isSelfClosing) {\n const replacement = `<${tag}${newAttrsPart} :${attrName}=\"$t(${descriptor})\" />`\n ops.push({ start: node.loc.start.offset, end: node.loc.end.offset, replacement })\n } else {\n // Find the end of the opening tag: start of first child or the inner content\n const children = node.children ?? []\n const openTagEnd = children.length > 0\n ? children[0]!.loc.start.offset\n : node.loc.source.indexOf('>') + node.loc.start.offset + 1\n const newOpenTag = `<${tag}${newAttrsPart} :${attrName}=\"$t(${descriptor})\">`\n ops.push({ start: node.loc.start.offset, end: openTagEnd, replacement: newOpenTag })\n }\n}\n\nfunction collectVtContentOps(node: ASTNode, ops: ReplaceOp[]): void {\n const props = node.props ?? []\n const vtDir = props.find(p => p.type === NT_DIRECTIVE && p.name === 't')\n if (!vtDir) return\n\n // Skip if this is a pure attribute binding (handled by collectVtAttrOps)\n const modifiers = (vtDir.modifiers ?? []).map(getModifierContent)\n const nonPluralMods = modifiers.filter(m => m !== 'plural')\n // If there's a non-plural modifier that corresponds to an attribute name, skip (attribute binding)\n if (nonPluralMods.length > 0) {\n const attrName = nonPluralMods[0]!\n const hasStaticAttr = props.some(p => p.type === NT_ATTRIBUTE && p.name === attrName)\n if (hasStaticAttr) return\n }\n\n const isPlural = modifiers.includes('plural')\n const bindExpr = typeof vtDir.exp?.content === 'string' ? vtDir.exp.content : undefined\n\n // Build explicit ID from arg + non-reserved modifiers\n const RESERVED_MODIFIERS = new Set(['plural'])\n const idSegments = modifiers.filter(m => !RESERVED_MODIFIERS.has(m))\n const argContent = typeof vtDir.arg?.content === 'string' ? vtDir.arg.content : undefined\n const explicitId = argContent ? [argContent, ...idSegments].join('.') : undefined\n\n const tag = node.tag!\n const children = node.children ?? []\n\n // Build clean attrs: remove v-t directive\n const exclude = new Set([vtDir])\n const remainingAttrs = buildCleanAttrs(props, exclude)\n const attrsPart = remainingAttrs ? ` ${remainingAttrs}` : ''\n\n if (isPlural && bindExpr) {\n // Collect text content from children\n const textContent = children\n .filter(c => c.type === NT_TEXT)\n .map(c => (typeof c.content === 'string' ? c.content : '').trim())\n .join('')\n const forms = textContent.split('|').map(s => s.trim())\n const categories = forms.length === 2\n ? ['one', 'other']\n : ['one', 'other', 'zero', 'few', 'many'].slice(0, forms.length)\n const icuParts = categories.map((cat, i) => `${cat} {${forms[i] ?? ''}}`)\n const icuMessage = `{${bindExpr}, plural, ${icuParts.join(' ')}}`\n const descriptor = buildDescriptorExpression(icuMessage, { id: explicitId })\n const replacement = `<${tag}${attrsPart}>{{ $t(${descriptor}, { ${bindExpr} }) }}</${tag}>`\n ops.push({ start: node.loc.start.offset, end: node.loc.end.offset, replacement })\n return\n }\n\n // Check for rich text (child elements)\n const extracted = extractRichFromAST(children)\n if (extracted.hasElements) {\n const message = extracted.message.trim()\n const descriptor = buildDescriptorExpression(message, { id: explicitId })\n const elementsLiteral = serializeElements(extracted.elements)\n const replacement = `<${tag}${attrsPart} v-html=\"$vtRich(${descriptor}, ${elementsLiteral})\"></${tag}>`\n ops.push({ start: node.loc.start.offset, end: node.loc.end.offset, replacement })\n return\n }\n\n // Plain text, possibly with interpolation\n const { message, vars } = extractVarsFromAST(children)\n const trimmedMessage = message.trim()\n const descriptor = buildDescriptorExpression(trimmedMessage, { id: explicitId })\n\n let replacement: string\n if (vars.length > 0) {\n replacement = `<${tag}${attrsPart}>{{ $t(${descriptor}, { ${vars.join(', ')} }) }}</${tag}>`\n } else {\n replacement = `<${tag}${attrsPart}>{{ $t(${descriptor}) }}</${tag}>`\n }\n ops.push({ start: node.loc.start.offset, end: node.loc.end.offset, replacement })\n}\n\nfunction collectTransOps(node: ASTNode, ops: ReplaceOp[]): void {\n if (node.tag !== 'Trans') return\n const props = node.props ?? []\n const children = node.children ?? []\n\n // Skip if empty content\n if (children.length === 0) return\n // Skip all-whitespace content\n const hasContent = children.some(c => {\n if (c.type === NT_TEXT) return (typeof c.content === 'string' ? c.content : '').trim().length > 0\n return true\n })\n if (!hasContent) return\n\n // Skip old API: <Trans message=\"...\">\n if (props.some(p => p.type === NT_ATTRIBUTE && p.name === 'message')) return\n\n const explicitId = readAttr(props, 'id')\n if (explicitId.kind === 'dynamic') return\n\n const context = readAttr(props, 'context')\n if (!explicitId.value && context.kind === 'dynamic') return\n\n // Extract tag prop (default: 'span')\n const tagAttr = readAttr(props, 'tag')\n const wrapperTag = tagAttr.value ?? 'span'\n\n // Build clean attrs: remove Trans-specific props\n const exclude = new Set<ASTNode>()\n for (const p of props) {\n if (p.type === NT_ATTRIBUTE && TRANS_ONLY_PROPS.has(p.name as string)) {\n exclude.add(p)\n }\n if (p.type === NT_DIRECTIVE && p.name === 'bind') {\n const argName = typeof p.arg?.content === 'string' ? p.arg.content : undefined\n if (argName && TRANS_ONLY_PROPS.has(argName)) {\n exclude.add(p)\n }\n }\n }\n const remainingAttrs = buildCleanAttrs(props, exclude)\n const cleanAttrsPart = remainingAttrs ? ` ${remainingAttrs}` : ''\n\n // Check for rich text\n const extracted = extractRichFromAST(children)\n if (extracted.hasElements) {\n const message = extracted.message.trim()\n const descriptor = buildDescriptorExpression(message, {\n id: explicitId.value,\n context: context.value,\n })\n const elementsLiteral = serializeElements(extracted.elements)\n const replacement = `<${wrapperTag}${cleanAttrsPart} v-html=\"$vtRich(${descriptor}, ${elementsLiteral})\"></${wrapperTag}>`\n ops.push({ start: node.loc.start.offset, end: node.loc.end.offset, replacement })\n return\n }\n\n // Plain text\n const rawContent = children\n .map(c => (c.type === NT_TEXT && typeof c.content === 'string') ? c.content : '')\n .join('')\n .trim()\n const descriptor = buildDescriptorExpression(rawContent, {\n id: explicitId.value,\n context: context.value,\n })\n const replacement = `<${wrapperTag}${cleanAttrsPart}>{{ $t(${descriptor}) }}</${wrapperTag}>`\n ops.push({ start: node.loc.start.offset, end: node.loc.end.offset, replacement })\n}\n\nconst PLURAL_CATS = ['zero', 'one', 'two', 'few', 'many', 'other'] as const\n\nfunction collectPluralOps(node: ASTNode, ops: ReplaceOp[]): void {\n if (node.tag !== 'Plural') return\n const props = node.props ?? []\n\n const explicitId = readAttr(props, 'id')\n const context = readAttr(props, 'context')\n if (explicitId.kind === 'dynamic') return\n if (!explicitId.value && context.kind === 'dynamic') return\n\n const valueExpr = getBindingExpr(props, 'value')\n if (!valueExpr) return\n\n const tagAttr = readAttr(props, 'tag')\n const wrapperTag = tagAttr.value ?? 'span'\n\n // Check for template slot children\n const children = node.children ?? []\n const slots: Array<{ cat: string; children: ASTNode[] }> = []\n for (const child of children) {\n if (child.type === NT_ELEMENT && child.tag === 'template') {\n const slotDir = (child.props ?? []).find(\n p => p.type === NT_DIRECTIVE && p.name === 'slot',\n )\n if (slotDir) {\n const slotName = typeof slotDir.arg?.content === 'string' ? slotDir.arg.content : undefined\n if (slotName) {\n slots.push({ cat: slotName, children: child.children ?? [] })\n }\n }\n }\n }\n\n if (slots.length > 0) {\n // Slot mode\n const allElements: RichChild[] = []\n const icuParts: string[] = []\n\n for (const cat of PLURAL_CATS) {\n const slot = slots.find(s => s.cat === cat)\n if (!slot) continue\n\n const extracted = extractRichFromAST(slot.children)\n let branchMessage: string\n\n if (extracted.hasElements) {\n const baseIndex = allElements.length\n branchMessage = extracted.message.replace(/<(\\d+)(\\/?)>/g, (_m, idxStr: string, slash: string) => {\n return `<${baseIndex + Number(idxStr)}${slash}>`\n }).replace(/<\\/(\\d+)>/g, (_m, idxStr: string) => {\n return `</${baseIndex + Number(idxStr)}>`\n })\n allElements.push(...extracted.elements)\n } else {\n // Plain text from slot children\n branchMessage = slot.children\n .map(c => (c.type === NT_TEXT && typeof c.content === 'string') ? c.content : '')\n .join('')\n .trim()\n }\n\n const icuKey = cat === 'zero' ? '=0' : cat\n icuParts.push(`${icuKey} {${branchMessage}}`)\n }\n\n if (icuParts.length === 0) return\n\n const icuMessage = `{count, plural, ${icuParts.join(' ')}}`\n const descriptor = buildDescriptorExpression(icuMessage, {\n id: explicitId.value,\n context: context.value,\n })\n\n // Build clean attrs\n const pluralOnlyProps = new Set([...TRANS_ONLY_PROPS, 'tag'])\n const exclude = new Set<ASTNode>()\n for (const p of props) {\n if (p.type === NT_ATTRIBUTE && pluralOnlyProps.has(p.name as string)) {\n exclude.add(p)\n }\n if (p.type === NT_DIRECTIVE && p.name === 'bind') {\n const argName = typeof p.arg?.content === 'string' ? p.arg.content : undefined\n if (argName === 'value' || (argName && pluralOnlyProps.has(argName))) {\n exclude.add(p)\n }\n }\n }\n const remainingAttrs = buildCleanAttrs(props, exclude)\n const attrsPart = remainingAttrs ? ` ${remainingAttrs}` : ''\n\n let replacement: string\n if (allElements.length > 0) {\n const elementsLiteral = serializeElements(allElements)\n replacement = `<${wrapperTag}${attrsPart} v-html=\"$vtRich(${descriptor}, ${elementsLiteral}, { count: ${valueExpr} })\"></${wrapperTag}>`\n } else {\n replacement = `<${wrapperTag}${attrsPart} v-text=\"$t(${descriptor}, { count: ${valueExpr} })\"></${wrapperTag}>`\n }\n ops.push({ start: node.loc.start.offset, end: node.loc.end.offset, replacement })\n return\n }\n\n // Prop mode: read zero/one/two/few/many/other static props\n const icuParts: string[] = []\n const catPropsToExclude = new Set<ASTNode>()\n\n for (const cat of PLURAL_CATS) {\n const catProp = props.find(p => p.type === NT_ATTRIBUTE && p.name === cat)\n if (catProp) {\n const value = typeof catProp.value?.content === 'string' ? catProp.value.content : ''\n const icuKey = cat === 'zero' ? '=0' : cat\n icuParts.push(`${icuKey} {${value}}`)\n catPropsToExclude.add(catProp)\n }\n }\n\n if (icuParts.length === 0) return\n\n const icuMessage = `{count, plural, ${icuParts.join(' ')}}`\n const descriptor = buildDescriptorExpression(icuMessage, {\n id: explicitId.value,\n context: context.value,\n })\n\n // Build clean attrs: remove :value, tag, id, context, comment, category props\n const exclude = new Set<ASTNode>(catPropsToExclude)\n for (const p of props) {\n if (p.type === NT_ATTRIBUTE && (p.name === 'tag' || TRANS_ONLY_PROPS.has(p.name as string))) {\n exclude.add(p)\n }\n if (p.type === NT_DIRECTIVE && p.name === 'bind') {\n const argName = typeof p.arg?.content === 'string' ? p.arg.content : undefined\n if (argName === 'value' || (argName && TRANS_ONLY_PROPS.has(argName))) {\n exclude.add(p)\n }\n }\n }\n const remainingAttrs = buildCleanAttrs(props, exclude)\n const attrsPart = remainingAttrs ? ` ${remainingAttrs}` : ''\n\n const replacement = `<${wrapperTag}${attrsPart} v-text=\"$t(${descriptor}, { count: ${valueExpr} })\"></${wrapperTag}>`\n ops.push({ start: node.loc.start.offset, end: node.loc.end.offset, replacement })\n}\n\n// ─── AST traversal ────────────────────────────────────────────────────────────\n\nfunction collectOps(root: ASTNode): ReplaceOp[] {\n const ops: ReplaceOp[] = []\n\n function walk(node: ASTNode): void {\n if (node.type === NT_ELEMENT) {\n if (node.tag === 'Trans') {\n collectTransOps(node, ops)\n return // Don't recurse into transformed nodes\n }\n if (node.tag === 'Plural') {\n collectPluralOps(node, ops)\n return\n }\n\n // v-t directive handling\n const hasVt = (node.props ?? []).some(p => p.type === NT_DIRECTIVE && p.name === 't')\n if (hasVt) {\n collectVtAttrOps(node, ops)\n collectVtContentOps(node, ops)\n return\n }\n }\n\n // Recurse into children\n for (const child of node.children ?? []) {\n walk(child)\n }\n }\n\n walk(root)\n return ops\n}\n\n// ─── Entry point ──────────────────────────────────────────────────────────────\n\nexport function transformVtDirectives(sfc: string): string {\n // Quick bail: check if there's anything to transform\n if (!/<template[\\s>]/.test(sfc)) return sfc\n if (sfc.lastIndexOf('</template>') < 0) return sfc\n\n const hasVt = /\\bv-t\\b/.test(sfc)\n const hasTrans = /<Trans[\\s>]/.test(sfc)\n const hasPlural = /<Plural[\\s/>]/.test(sfc)\n if (!hasVt && !hasTrans && !hasPlural) return sfc\n\n const { descriptor } = parseSFC(sfc, { pad: false })\n if (!descriptor.template?.ast) return sfc\n\n const ops = collectOps(descriptor.template.ast as unknown as ASTNode)\n if (ops.length === 0) return sfc\n\n // Apply replacements from end to start to avoid offset drift\n ops.sort((a, b) => b.start - a.start)\n let result = sfc\n for (const op of ops) {\n result = result.slice(0, op.start) + op.replacement + result.slice(op.end)\n }\n return result\n}\n"],"mappings":";;;AAQA,IAAM,IAAa,GACb,IAAU,GACV,IAAmB,GACnB,IAAe,GACf,IAAe;AAuBrB,SAAS,EAAyB,GAAuB;AACvD,QAAO,EAAM,QAAQ,OAAO,OAAO,CAAC,QAAQ,MAAM,MAAM;;AAG1D,SAAgB,EAAa,GAAqB;AAChD,QAAO,EAAI,QAAQ,uBAAuB,OAAO;;AA+BnD,SAAS,EAAkB,GAAwC;AAOjE,QAAO,IANS,EAAS,KAAI,MAAM;EAGjC,IAAM,IAAc,EAAyB,EAAG,SAAS,CAAC,QAAQ,MAAM,SAAS;AACjF,SAAO,WAAW,EAAyB,EAAG,IAAI,CAAC,gBAAgB,EAAY;GAC/E,CACiB,KAAK,KAAK,CAAC;;AAGhC,SAAS,EACP,GACA,GAIQ;AAER,QAAO,UAAU,EADN,GAAS,MAAM,EAAY,GAAS,GAAS,QAAQ,CACnB,CAAC,eAAe,EAAyB,EAAQ,CAAC;;AAKjG,SAAS,EAAmB,GAA+B;AACzD,QAAO,OAAO,KAAQ,WAAW,IAAO,EAAI,WAAsB;;AAGpE,SAAS,EAAS,GAAkB,GAAkC;AACpE,MAAK,IAAM,KAAQ,GAAO;AACxB,MAAI,EAAK,SAAS,KAAgB,EAAK,SAAS,WAC3B,OAAO,EAAK,KAAK,WAAY,WAAW,EAAK,IAAI,UAAU,KAAA,OAC3D,EACjB,QAAO,EAAE,MAAM,WAAW;AAG9B,MAAI,EAAK,SAAS,KAAgB,EAAK,SAAS,EAE9C,QAAO;GAAE,MAAM;GAAU,OADX,OAAO,EAAK,OAAO,WAAY,WAAW,EAAK,MAAM,UAAU;GAC7C;;AAGpC,QAAO,EAAE,MAAM,WAAW;;AAG5B,SAAS,EAAe,GAAkB,GAAkC;AAC1E,MAAK,IAAM,KAAQ,EACjB,KAAI,EAAK,SAAS,KAAgB,E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