prettier-plugin-embed 0.3.0-rc.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/README.md +6 -19
- package/dist/embedded/register.d.ts +4 -4
- package/dist/index.js +614 -706
- package/package.json +6 -9
package/dist/index.js
CHANGED
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
import { utils as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { printers as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { Worker as
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const { node: r } = e;
|
|
18
|
-
let t = n();
|
|
19
|
-
return r?.comments?.length && (t = ht([bt([Z, t]), Z])), ["${", t, yt, "}"];
|
|
1
|
+
import { utils as G, builders as $ } from "prettier/doc";
|
|
2
|
+
import Xe from "prettier/parser-babel";
|
|
3
|
+
import Je from "prettier/parser-espree";
|
|
4
|
+
import Ye from "prettier/parser-flow";
|
|
5
|
+
import Ve from "prettier/parser-meriyah";
|
|
6
|
+
import Qe from "prettier/parser-typescript";
|
|
7
|
+
import { printers as Ze } from "prettier/plugins/estree.mjs";
|
|
8
|
+
import { readFile as et } from "node:fs/promises";
|
|
9
|
+
import { isAbsolute as tt, dirname as nt, resolve as rt, extname as st } from "node:path";
|
|
10
|
+
import { Worker as ot } from "node:worker_threads";
|
|
11
|
+
import { resolveConfigFile as it } from "prettier";
|
|
12
|
+
const we = "embeddedCss", { group: at, indent: dt, softline: Y, lineSuffixBoundary: ct } = $, { mapDoc: lt } = G;
|
|
13
|
+
function ut(t, n) {
|
|
14
|
+
const { node: r } = t;
|
|
15
|
+
let e = n();
|
|
16
|
+
return r?.comments?.length && (e = at([dt([Y, e]), Y])), ["${", e, ct, "}"];
|
|
20
17
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
23
|
-
(r) =>
|
|
18
|
+
function S(t, n) {
|
|
19
|
+
return t.map(
|
|
20
|
+
(r) => ut(r, n),
|
|
24
21
|
"expressions"
|
|
25
22
|
);
|
|
26
23
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
24
|
+
function k(t, n, r) {
|
|
25
|
+
return lt(t, (s) => {
|
|
29
26
|
if (typeof s != "string")
|
|
30
27
|
return s;
|
|
31
|
-
const o = [],
|
|
32
|
-
for (let
|
|
33
|
-
let c = i
|
|
34
|
-
if (
|
|
28
|
+
const o = [], a = s.split(n);
|
|
29
|
+
for (let i = 0; i < a.length; i++) {
|
|
30
|
+
let c = a[i];
|
|
31
|
+
if (i % 2 == 0) {
|
|
35
32
|
if (!c)
|
|
36
33
|
continue;
|
|
37
34
|
c = c.replaceAll(/([\\`]|\${)/g, "\\$1"), o.push(c);
|
|
@@ -43,124 +40,124 @@ function w(e, n, r) {
|
|
|
43
40
|
return o;
|
|
44
41
|
});
|
|
45
42
|
}
|
|
46
|
-
function
|
|
43
|
+
function A(t, n, r) {
|
|
47
44
|
if (!(n.plugins?.some(
|
|
48
|
-
(
|
|
45
|
+
(e) => e.name?.includes(t) ?? !1
|
|
49
46
|
) ?? !1))
|
|
50
47
|
throw new Error(
|
|
51
|
-
`Cannot format embedded language identified by "${r}", because plugin "${
|
|
48
|
+
`Cannot format embedded language identified by "${r}", because plugin "${t}" is not loaded.`
|
|
52
49
|
);
|
|
53
50
|
}
|
|
54
|
-
function
|
|
51
|
+
function mt(t, n, r) {
|
|
55
52
|
if (n === r) {
|
|
56
|
-
|
|
53
|
+
t.unshift(n);
|
|
57
54
|
return;
|
|
58
55
|
}
|
|
59
|
-
let
|
|
60
|
-
for (;
|
|
61
|
-
const o =
|
|
62
|
-
if (
|
|
63
|
-
|
|
56
|
+
let e = 0, s = t.length;
|
|
57
|
+
for (; e < s; ) {
|
|
58
|
+
const o = e + s >>> 1;
|
|
59
|
+
if (t[o] === r) {
|
|
60
|
+
t.push(n);
|
|
64
61
|
return;
|
|
65
62
|
}
|
|
66
|
-
|
|
63
|
+
t[o] < n ? e = o + 1 : s = o;
|
|
67
64
|
}
|
|
68
|
-
|
|
65
|
+
t.splice(e, 0, n);
|
|
69
66
|
}
|
|
70
|
-
const
|
|
71
|
-
const
|
|
67
|
+
const V = (() => {
|
|
68
|
+
const t = [...Array(26).keys()].map((n) => String.fromCharCode(n + 97)).concat([...Array(10).keys()].map((n) => `${n}`));
|
|
72
69
|
return () => {
|
|
73
70
|
let r = "";
|
|
74
|
-
for (let
|
|
75
|
-
r +=
|
|
71
|
+
for (let e = 0; e < 16; ++e)
|
|
72
|
+
r += t[parseInt((Math.random() * t.length).toFixed(0), 10) % t.length];
|
|
76
73
|
return r;
|
|
77
74
|
};
|
|
78
75
|
})();
|
|
79
|
-
function
|
|
80
|
-
const r =
|
|
81
|
-
`${s}${r}(\\d+)${
|
|
76
|
+
function L(t = "p", n = "") {
|
|
77
|
+
const r = V(), e = V(), s = Q(t), o = Q(n), a = (c) => `${t}${r}${c}${e}${n}`, i = new RegExp(
|
|
78
|
+
`${s}${r}(\\d+)${e}${o}`,
|
|
82
79
|
"g"
|
|
83
80
|
);
|
|
84
81
|
return {
|
|
85
|
-
createPlaceholder:
|
|
86
|
-
placeholderRegex:
|
|
82
|
+
createPlaceholder: a,
|
|
83
|
+
placeholderRegex: i
|
|
87
84
|
};
|
|
88
85
|
}
|
|
89
|
-
function
|
|
90
|
-
return
|
|
86
|
+
function Q(t) {
|
|
87
|
+
return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
91
88
|
}
|
|
92
|
-
function I(
|
|
93
|
-
return `${
|
|
89
|
+
function I(t) {
|
|
90
|
+
return `${t}Identifiers`;
|
|
94
91
|
}
|
|
95
|
-
function
|
|
96
|
-
return `${
|
|
92
|
+
function gt(t) {
|
|
93
|
+
return `${t}Parser`;
|
|
97
94
|
}
|
|
98
|
-
const { line:
|
|
99
|
-
|
|
100
|
-
...
|
|
95
|
+
const { line: Z, group: O, indent: ee, softline: te } = $, pt = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
96
|
+
e = {
|
|
97
|
+
...e,
|
|
101
98
|
...o
|
|
102
99
|
};
|
|
103
|
-
const { node:
|
|
104
|
-
(f,
|
|
105
|
-
).join(""),
|
|
106
|
-
...
|
|
100
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L("@p"), l = a.quasis.map(
|
|
101
|
+
(f, g, { length: h }) => g === h - 1 ? f.value.cooked : f.value.cooked + i(g)
|
|
102
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = S(r, n), b = await t(l, {
|
|
103
|
+
...e,
|
|
107
104
|
parser: "scss"
|
|
108
|
-
}), d =
|
|
109
|
-
if (
|
|
110
|
-
return
|
|
105
|
+
}), d = k(b, c, v);
|
|
106
|
+
if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
107
|
+
return O([
|
|
111
108
|
"`",
|
|
109
|
+
p,
|
|
110
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [O(d)] : ee([O(d)]),
|
|
112
111
|
u,
|
|
113
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [D(d)] : re([D(d)]),
|
|
114
|
-
m,
|
|
115
112
|
"`"
|
|
116
113
|
]);
|
|
117
|
-
const
|
|
118
|
-
return
|
|
114
|
+
const m = p.length ? Z : te, y = u.length ? Z : te;
|
|
115
|
+
return O([
|
|
119
116
|
"`",
|
|
120
|
-
|
|
117
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [m, O(d)] : ee([m, O(d)]),
|
|
121
118
|
y,
|
|
122
119
|
"`"
|
|
123
120
|
]);
|
|
124
|
-
},
|
|
125
|
-
[
|
|
121
|
+
}, ft = ["css"], ht = I(we), bt = {
|
|
122
|
+
[ht]: {
|
|
126
123
|
category: "Global",
|
|
127
124
|
type: "string",
|
|
128
125
|
array: !0,
|
|
129
|
-
default: [{ value: [...
|
|
126
|
+
default: [{ value: [...ft] }],
|
|
130
127
|
description: "Specify embedded CSS language identifiers."
|
|
131
128
|
}
|
|
132
|
-
},
|
|
129
|
+
}, yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
133
130
|
__proto__: null,
|
|
134
|
-
embeddedLanguage:
|
|
135
|
-
embedder:
|
|
136
|
-
options:
|
|
137
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
138
|
-
|
|
139
|
-
...
|
|
131
|
+
embeddedLanguage: we,
|
|
132
|
+
embedder: pt,
|
|
133
|
+
options: bt
|
|
134
|
+
}, Symbol.toStringTag, { value: "Module" })), H = "embeddedEs", { line: ne, group: T, indent: re, softline: se } = $, vt = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
135
|
+
e = {
|
|
136
|
+
...e,
|
|
140
137
|
...o
|
|
141
138
|
};
|
|
142
|
-
const { node:
|
|
143
|
-
(f,
|
|
144
|
-
).join(""),
|
|
145
|
-
...
|
|
146
|
-
parser:
|
|
147
|
-
}), d =
|
|
148
|
-
if (
|
|
149
|
-
return
|
|
139
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L(), l = a.quasis.map(
|
|
140
|
+
(f, g, { length: h }) => g === h - 1 ? f.value.cooked : f.value.cooked + i(g)
|
|
141
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = S(r, n), b = await t(l, {
|
|
142
|
+
...e,
|
|
143
|
+
parser: e.embeddedEsParser ?? "babel"
|
|
144
|
+
}), d = k(b, c, v);
|
|
145
|
+
if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
146
|
+
return T([
|
|
150
147
|
"`",
|
|
148
|
+
p,
|
|
149
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [T(d)] : re([T(d)]),
|
|
151
150
|
u,
|
|
152
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [P(d)] : ie([P(d)]),
|
|
153
|
-
m,
|
|
154
151
|
"`"
|
|
155
152
|
]);
|
|
156
|
-
const
|
|
157
|
-
return
|
|
153
|
+
const m = p.length ? ne : se, y = u.length ? ne : se;
|
|
154
|
+
return T([
|
|
158
155
|
"`",
|
|
159
|
-
|
|
156
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [m, T(d)] : re([m, T(d)]),
|
|
160
157
|
y,
|
|
161
158
|
"`"
|
|
162
159
|
]);
|
|
163
|
-
},
|
|
160
|
+
}, _t = [
|
|
164
161
|
"js",
|
|
165
162
|
"jsx",
|
|
166
163
|
"es",
|
|
@@ -169,56 +166,56 @@ const { line: ne, group: D, indent: re, softline: se } = $, $t = async (e, n, r,
|
|
|
169
166
|
"cjs",
|
|
170
167
|
"pac",
|
|
171
168
|
"javascript"
|
|
172
|
-
],
|
|
173
|
-
[
|
|
169
|
+
], Et = I(H), xt = gt(H), $t = {
|
|
170
|
+
[Et]: {
|
|
174
171
|
category: "Global",
|
|
175
172
|
type: "string",
|
|
176
173
|
array: !0,
|
|
177
|
-
default: [{ value: [...
|
|
174
|
+
default: [{ value: [..._t] }],
|
|
178
175
|
description: "Specify embedded ES language identifiers."
|
|
179
176
|
},
|
|
180
|
-
[
|
|
177
|
+
[xt]: {
|
|
181
178
|
category: "Global",
|
|
182
179
|
type: "string",
|
|
183
180
|
array: !1,
|
|
184
181
|
default: "babel",
|
|
185
182
|
description: "Specify the embedded ES language parser."
|
|
186
183
|
}
|
|
187
|
-
},
|
|
184
|
+
}, It = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
188
185
|
__proto__: null,
|
|
189
|
-
embeddedLanguage:
|
|
190
|
-
embedder:
|
|
191
|
-
options:
|
|
192
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
193
|
-
|
|
194
|
-
...
|
|
186
|
+
embeddedLanguage: H,
|
|
187
|
+
embedder: vt,
|
|
188
|
+
options: $t
|
|
189
|
+
}, Symbol.toStringTag, { value: "Module" })), Pe = "embeddedGlsl", { line: oe, group: D, indent: ie, softline: ae } = $, St = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
190
|
+
A("prettier-plugin-glsl", e, s), e = {
|
|
191
|
+
...e,
|
|
195
192
|
...o
|
|
196
193
|
};
|
|
197
|
-
const { node:
|
|
198
|
-
(
|
|
199
|
-
).join(""),
|
|
200
|
-
|
|
201
|
-
-
|
|
202
|
-
), b =
|
|
203
|
-
...
|
|
194
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L(), l = a.quasis.map(
|
|
195
|
+
(g, h, { length: _ }) => h === _ - 1 ? g.value.cooked : g.value.cooked + i(h)
|
|
196
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = l.slice(
|
|
197
|
+
p.length,
|
|
198
|
+
-u.length || void 0
|
|
199
|
+
), b = S(r, n), d = await t(v, {
|
|
200
|
+
...e,
|
|
204
201
|
parser: "glsl-parser"
|
|
205
|
-
}),
|
|
206
|
-
if (
|
|
207
|
-
return
|
|
202
|
+
}), m = k(d, c, b);
|
|
203
|
+
if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
204
|
+
return D([
|
|
208
205
|
"`",
|
|
206
|
+
p,
|
|
207
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [D(m)] : ie([D(m)]),
|
|
209
208
|
u,
|
|
210
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [R(g)] : ce([R(g)]),
|
|
211
|
-
m,
|
|
212
209
|
"`"
|
|
213
210
|
]);
|
|
214
|
-
const y =
|
|
215
|
-
return
|
|
211
|
+
const y = p.length ? oe : ae, f = u.length ? oe : ae;
|
|
212
|
+
return D([
|
|
216
213
|
"`",
|
|
217
|
-
|
|
214
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [y, D(m)] : ie([y, D(m)]),
|
|
218
215
|
f,
|
|
219
216
|
"`"
|
|
220
217
|
]);
|
|
221
|
-
},
|
|
218
|
+
}, Lt = [
|
|
222
219
|
"glsl",
|
|
223
220
|
"fp",
|
|
224
221
|
"frag",
|
|
@@ -241,63 +238,63 @@ const { line: ne, group: D, indent: re, softline: se } = $, $t = async (e, n, r,
|
|
|
241
238
|
"vrx",
|
|
242
239
|
"vsh",
|
|
243
240
|
"vshader"
|
|
244
|
-
],
|
|
245
|
-
[
|
|
241
|
+
], kt = I(Pe), Ot = {
|
|
242
|
+
[kt]: {
|
|
246
243
|
category: "Global",
|
|
247
244
|
type: "string",
|
|
248
245
|
array: !0,
|
|
249
|
-
default: [{ value: [...
|
|
246
|
+
default: [{ value: [...Lt] }],
|
|
250
247
|
description: 'Specify embedded GLSL language identifiers. This requires "prettier-plugin-glsl".'
|
|
251
248
|
}
|
|
252
|
-
},
|
|
249
|
+
}, Tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
253
250
|
__proto__: null,
|
|
254
|
-
embeddedLanguage:
|
|
255
|
-
embedder:
|
|
256
|
-
options:
|
|
257
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
258
|
-
|
|
259
|
-
...
|
|
251
|
+
embeddedLanguage: Pe,
|
|
252
|
+
embedder: St,
|
|
253
|
+
options: Ot
|
|
254
|
+
}, Symbol.toStringTag, { value: "Module" })), Re = "embeddedHtml", { line: de, group: w, indent: ce, softline: le } = $, { mapDoc: Dt } = G, wt = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
255
|
+
e = {
|
|
256
|
+
...e,
|
|
260
257
|
...o
|
|
261
258
|
};
|
|
262
|
-
const { node:
|
|
263
|
-
(f,
|
|
264
|
-
).join(""),
|
|
265
|
-
...
|
|
259
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L(), l = a.quasis.map(
|
|
260
|
+
(f, g, { length: h }) => g === h - 1 ? f.value.cooked : f.value.cooked + i(g)
|
|
261
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = S(r, n), b = await t(l, {
|
|
262
|
+
...e,
|
|
266
263
|
parser: "html"
|
|
267
|
-
}), d =
|
|
264
|
+
}), d = Dt(b, (f) => {
|
|
268
265
|
if (typeof f != "string")
|
|
269
266
|
return f;
|
|
270
|
-
const
|
|
271
|
-
for (let
|
|
272
|
-
let E =
|
|
273
|
-
if (
|
|
267
|
+
const g = [], h = f.split(c);
|
|
268
|
+
for (let _ = 0; _ < h.length; _++) {
|
|
269
|
+
let E = h[_];
|
|
270
|
+
if (_ % 2 == 0) {
|
|
274
271
|
if (!E)
|
|
275
272
|
continue;
|
|
276
|
-
E = E.replaceAll(/([\\`]|\${)/g, "\\$1"),
|
|
273
|
+
E = E.replaceAll(/([\\`]|\${)/g, "\\$1"), e.__embeddedInHtml && (E = E.replaceAll(/<\/(?=script\b)/gi, "<\\/")), g.push(E);
|
|
277
274
|
} else {
|
|
278
275
|
const x = Number(E);
|
|
279
|
-
|
|
276
|
+
g.push(v[x]);
|
|
280
277
|
}
|
|
281
278
|
}
|
|
282
|
-
return
|
|
279
|
+
return g;
|
|
283
280
|
});
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
return
|
|
281
|
+
if (e.htmlWhitespaceSensitivity === "strict" || // TODO: is css mode should be included here?
|
|
282
|
+
e.htmlWhitespaceSensitivity === "css" || e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
283
|
+
return w([
|
|
287
284
|
"`",
|
|
285
|
+
p,
|
|
286
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [w(d)] : ce([w(d)]),
|
|
288
287
|
u,
|
|
289
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [j(d)] : me([j(d)]),
|
|
290
|
-
m,
|
|
291
288
|
"`"
|
|
292
289
|
]);
|
|
293
|
-
const
|
|
294
|
-
return
|
|
290
|
+
const m = p.length ? de : le, y = u.length ? de : le;
|
|
291
|
+
return w([
|
|
295
292
|
"`",
|
|
296
|
-
|
|
293
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [m, w(d)] : ce([m, w(d)]),
|
|
297
294
|
y,
|
|
298
295
|
"`"
|
|
299
296
|
]);
|
|
300
|
-
},
|
|
297
|
+
}, Pt = [
|
|
301
298
|
"html",
|
|
302
299
|
"htm",
|
|
303
300
|
"shtml",
|
|
@@ -310,47 +307,47 @@ const { line: ne, group: D, indent: re, softline: se } = $, $t = async (e, n, r,
|
|
|
310
307
|
"jshtm",
|
|
311
308
|
"volt",
|
|
312
309
|
"rhtml"
|
|
313
|
-
],
|
|
314
|
-
[
|
|
310
|
+
], Rt = I(Re), Mt = {
|
|
311
|
+
[Rt]: {
|
|
315
312
|
category: "Global",
|
|
316
313
|
type: "string",
|
|
317
314
|
array: !0,
|
|
318
|
-
default: [{ value: [...
|
|
315
|
+
default: [{ value: [...Pt] }],
|
|
319
316
|
description: "Specify embedded HTML language identifiers."
|
|
320
317
|
}
|
|
321
|
-
},
|
|
318
|
+
}, Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
322
319
|
__proto__: null,
|
|
323
|
-
embeddedLanguage:
|
|
324
|
-
embedder:
|
|
325
|
-
options:
|
|
326
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
327
|
-
|
|
328
|
-
...
|
|
320
|
+
embeddedLanguage: Re,
|
|
321
|
+
embedder: wt,
|
|
322
|
+
options: Mt
|
|
323
|
+
}, Symbol.toStringTag, { value: "Module" })), Me = "embeddedMarkdown", { line: ue, group: P, indent: me, softline: ge } = $, Nt = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
324
|
+
e = {
|
|
325
|
+
...e,
|
|
329
326
|
...o
|
|
330
327
|
};
|
|
331
|
-
const { node:
|
|
332
|
-
(f,
|
|
333
|
-
).join(""),
|
|
334
|
-
...
|
|
328
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L(), l = a.quasis.map(
|
|
329
|
+
(f, g, { length: h }) => g === h - 1 ? f.value.cooked : f.value.cooked + i(g)
|
|
330
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = S(r, n), b = await t(l, {
|
|
331
|
+
...e,
|
|
335
332
|
parser: "markdown",
|
|
336
333
|
__inJsTemplate: !0
|
|
337
|
-
}), d =
|
|
338
|
-
if (
|
|
339
|
-
return
|
|
334
|
+
}), d = k(b, c, v);
|
|
335
|
+
if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
336
|
+
return P([
|
|
340
337
|
"`",
|
|
338
|
+
p,
|
|
339
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [P(d)] : me([P(d)]),
|
|
341
340
|
u,
|
|
342
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [M(d)] : fe([M(d)]),
|
|
343
|
-
m,
|
|
344
341
|
"`"
|
|
345
342
|
]);
|
|
346
|
-
const
|
|
347
|
-
return
|
|
343
|
+
const m = p.length ? ue : ge, y = u.length ? ue : ge;
|
|
344
|
+
return P([
|
|
348
345
|
"`",
|
|
349
|
-
|
|
346
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [m, P(d)] : me([m, P(d)]),
|
|
350
347
|
y,
|
|
351
348
|
"`"
|
|
352
349
|
]);
|
|
353
|
-
},
|
|
350
|
+
}, jt = [
|
|
354
351
|
"md",
|
|
355
352
|
"livemd",
|
|
356
353
|
"markdown",
|
|
@@ -362,74 +359,74 @@ const { line: ne, group: D, indent: re, softline: se } = $, $t = async (e, n, r,
|
|
|
362
359
|
"ronn",
|
|
363
360
|
"scd",
|
|
364
361
|
"workbook"
|
|
365
|
-
],
|
|
366
|
-
[
|
|
362
|
+
], Ft = I(Me), At = {
|
|
363
|
+
[Ft]: {
|
|
367
364
|
category: "Global",
|
|
368
365
|
type: "string",
|
|
369
366
|
array: !0,
|
|
370
|
-
default: [{ value: [...
|
|
367
|
+
default: [{ value: [...jt] }],
|
|
371
368
|
description: "Specify embedded Markdown language identifiers."
|
|
372
369
|
}
|
|
373
|
-
},
|
|
370
|
+
}, Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
374
371
|
__proto__: null,
|
|
375
|
-
embeddedLanguage:
|
|
376
|
-
embedder:
|
|
377
|
-
options:
|
|
378
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
379
|
-
[
|
|
372
|
+
embeddedLanguage: Me,
|
|
373
|
+
embedder: Nt,
|
|
374
|
+
options: At
|
|
375
|
+
}, Symbol.toStringTag, { value: "Module" })), X = "embeddedNoop", Wt = I(X), qt = {
|
|
376
|
+
[Wt]: {
|
|
380
377
|
category: "Global",
|
|
381
378
|
type: "string",
|
|
382
379
|
array: !0,
|
|
383
380
|
default: [{ value: [] }],
|
|
384
381
|
description: "Specify embedded language identifiers that will not be formatted."
|
|
385
382
|
}
|
|
386
|
-
},
|
|
383
|
+
}, Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
387
384
|
__proto__: null,
|
|
388
|
-
embeddedLanguage:
|
|
389
|
-
options:
|
|
390
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
391
|
-
|
|
392
|
-
...
|
|
385
|
+
embeddedLanguage: X,
|
|
386
|
+
options: qt
|
|
387
|
+
}, Symbol.toStringTag, { value: "Module" })), Ce = "embeddedPhp", { line: pe, group: R, indent: fe, softline: he } = $, Ut = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
388
|
+
A("@prettier/plugin-php", e, s), e = {
|
|
389
|
+
...e,
|
|
393
390
|
...o
|
|
394
391
|
};
|
|
395
|
-
const { node:
|
|
396
|
-
(
|
|
397
|
-
).join(""),
|
|
398
|
-
|
|
399
|
-
-
|
|
400
|
-
), b =
|
|
401
|
-
...
|
|
392
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L("$p"), l = a.quasis.map(
|
|
393
|
+
(g, h, { length: _ }) => h === _ - 1 ? g.value.cooked : g.value.cooked + i(h)
|
|
394
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = l.slice(
|
|
395
|
+
p.length,
|
|
396
|
+
-u.length || void 0
|
|
397
|
+
), b = S(r, n), d = await t(v, {
|
|
398
|
+
...e,
|
|
402
399
|
parser: "php"
|
|
403
|
-
}),
|
|
404
|
-
if (
|
|
405
|
-
return
|
|
400
|
+
}), m = k(d, c, b);
|
|
401
|
+
if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
402
|
+
return R([
|
|
406
403
|
"`",
|
|
404
|
+
p,
|
|
405
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [R(m)] : fe([R(m)]),
|
|
407
406
|
u,
|
|
408
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [F(g)] : ye([F(g)]),
|
|
409
|
-
m,
|
|
410
407
|
"`"
|
|
411
408
|
]);
|
|
412
|
-
const y =
|
|
413
|
-
return
|
|
409
|
+
const y = p.length ? pe : he, f = u.length ? pe : he;
|
|
410
|
+
return R([
|
|
414
411
|
"`",
|
|
415
|
-
|
|
412
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [y, R(m)] : fe([y, R(m)]),
|
|
416
413
|
f,
|
|
417
414
|
"`"
|
|
418
415
|
]);
|
|
419
|
-
},
|
|
420
|
-
[
|
|
416
|
+
}, zt = ["php", "php5", "phtml", "ctp"], Gt = I(Ce), Ht = {
|
|
417
|
+
[Gt]: {
|
|
421
418
|
category: "Global",
|
|
422
419
|
type: "string",
|
|
423
420
|
array: !0,
|
|
424
|
-
default: [{ value: [...
|
|
421
|
+
default: [{ value: [...zt] }],
|
|
425
422
|
description: 'Specify embedded PHP language identifiers. This requires "@prettier/plugin-php".'
|
|
426
423
|
}
|
|
427
|
-
},
|
|
424
|
+
}, Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
428
425
|
__proto__: null,
|
|
429
|
-
embeddedLanguage:
|
|
430
|
-
embedder:
|
|
431
|
-
options:
|
|
432
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
426
|
+
embeddedLanguage: Ce,
|
|
427
|
+
embedder: Ut,
|
|
428
|
+
options: Ht
|
|
429
|
+
}, Symbol.toStringTag, { value: "Module" })), Ne = "embeddedRuby", q = [
|
|
433
430
|
"ruby",
|
|
434
431
|
"arb",
|
|
435
432
|
"axlsx",
|
|
@@ -455,87 +452,130 @@ const { line: ne, group: D, indent: re, softline: se } = $, $t = async (e, n, r,
|
|
|
455
452
|
"ru",
|
|
456
453
|
"thor",
|
|
457
454
|
"watchr"
|
|
458
|
-
], K = ["rbs"],
|
|
459
|
-
...
|
|
455
|
+
], K = ["rbs"], U = ["haml"], Jt = [
|
|
456
|
+
...q,
|
|
460
457
|
...K,
|
|
461
|
-
...
|
|
462
|
-
],
|
|
463
|
-
[
|
|
458
|
+
...U
|
|
459
|
+
], Yt = "embeddedRubyParser", Vt = I(Ne), Qt = {
|
|
460
|
+
[Vt]: {
|
|
464
461
|
category: "Global",
|
|
465
462
|
type: "string",
|
|
466
463
|
array: !0,
|
|
467
|
-
default: [{ value: [...
|
|
464
|
+
default: [{ value: [...Jt] }],
|
|
468
465
|
description: 'Specify embedded Ruby language identifiers. This requires "@prettier/plugin-ruby".'
|
|
469
466
|
},
|
|
470
|
-
[
|
|
467
|
+
[Yt]: {
|
|
471
468
|
category: "Global",
|
|
472
469
|
type: "string",
|
|
473
470
|
array: !1,
|
|
474
471
|
default: void 0,
|
|
475
472
|
description: "Specify the embedded Ruby language parser."
|
|
476
473
|
}
|
|
477
|
-
}, { line:
|
|
478
|
-
|
|
479
|
-
...
|
|
480
|
-
...
|
|
474
|
+
}, { line: be, group: M, indent: ye, softline: ve } = $, Zt = async (t, n, r, e, { identifier: s, identifiers: o, embeddedOverrideOptions: a }) => {
|
|
475
|
+
A("@prettier/plugin-ruby", e, s), e = {
|
|
476
|
+
...e,
|
|
477
|
+
...a
|
|
481
478
|
};
|
|
482
|
-
const { node:
|
|
483
|
-
(
|
|
484
|
-
).join(""),
|
|
485
|
-
|
|
486
|
-
-
|
|
487
|
-
), d =
|
|
488
|
-
...
|
|
489
|
-
parser:
|
|
490
|
-
}), f =
|
|
491
|
-
if (
|
|
492
|
-
return
|
|
479
|
+
const { node: i } = r, { createPlaceholder: c, placeholderRegex: l } = L(), p = i.quasis.map(
|
|
480
|
+
(_, E, { length: x }) => E === x - 1 ? _.value.cooked : _.value.cooked + c(E)
|
|
481
|
+
).join(""), u = p.match(/^\s+/)?.[0] ?? "", v = p.match(/\s+$/)?.[0] ?? "", b = p.slice(
|
|
482
|
+
u.length,
|
|
483
|
+
-v.length || void 0
|
|
484
|
+
), d = S(r, n), m = en(e, s, o), y = await t(b, {
|
|
485
|
+
...e,
|
|
486
|
+
parser: m
|
|
487
|
+
}), f = k(y, l, d);
|
|
488
|
+
if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
489
|
+
return M([
|
|
493
490
|
"`",
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
491
|
+
u,
|
|
492
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [M(f)] : ye([M(f)]),
|
|
493
|
+
v,
|
|
497
494
|
"`"
|
|
498
495
|
]);
|
|
499
|
-
const
|
|
500
|
-
return
|
|
496
|
+
const g = u.length ? be : ve, h = v.length ? be : ve;
|
|
497
|
+
return M([
|
|
501
498
|
"`",
|
|
502
|
-
|
|
503
|
-
|
|
499
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [g, M(f)] : ye([g, M(f)]),
|
|
500
|
+
h,
|
|
504
501
|
"`"
|
|
505
502
|
]);
|
|
506
503
|
};
|
|
507
|
-
function
|
|
508
|
-
if (typeof
|
|
509
|
-
return
|
|
510
|
-
const
|
|
511
|
-
for (let s =
|
|
512
|
-
if (
|
|
513
|
-
return
|
|
514
|
-
if (
|
|
504
|
+
function en(t, n, r) {
|
|
505
|
+
if (typeof t.embeddedRubyParser == "string")
|
|
506
|
+
return t.embeddedRubyParser;
|
|
507
|
+
const e = r.indexOf(n);
|
|
508
|
+
for (let s = e; s >= 0; --s) {
|
|
509
|
+
if (tn(n))
|
|
510
|
+
return q[0];
|
|
511
|
+
if (nn(n))
|
|
515
512
|
return K[0];
|
|
516
|
-
if (
|
|
517
|
-
return
|
|
513
|
+
if (rn(n))
|
|
514
|
+
return U[0];
|
|
518
515
|
}
|
|
519
516
|
throw new SyntaxError(`Unrecognized ruby identifier: ${n}`);
|
|
520
517
|
}
|
|
521
|
-
function
|
|
522
|
-
return
|
|
518
|
+
function tn(t) {
|
|
519
|
+
return q.includes(t);
|
|
523
520
|
}
|
|
524
|
-
function
|
|
525
|
-
return K.includes(
|
|
521
|
+
function nn(t) {
|
|
522
|
+
return K.includes(t);
|
|
526
523
|
}
|
|
527
|
-
function
|
|
528
|
-
return
|
|
524
|
+
function rn(t) {
|
|
525
|
+
return U.includes(t);
|
|
529
526
|
}
|
|
530
|
-
const
|
|
527
|
+
const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
531
528
|
__proto__: null,
|
|
532
|
-
HAML_PARSER_IDENTIFIERS:
|
|
529
|
+
HAML_PARSER_IDENTIFIERS: U,
|
|
533
530
|
RBS_PARSER_IDENTIFIERS: K,
|
|
534
|
-
RUBY_PARSER_IDENTIFIERS:
|
|
535
|
-
embeddedLanguage:
|
|
536
|
-
embedder:
|
|
537
|
-
options:
|
|
538
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
531
|
+
RUBY_PARSER_IDENTIFIERS: q,
|
|
532
|
+
embeddedLanguage: Ne,
|
|
533
|
+
embedder: Zt,
|
|
534
|
+
options: Qt
|
|
535
|
+
}, Symbol.toStringTag, { value: "Module" })), je = "embeddedSql", { hardline: on, group: C, line: _e, softline: Ee, indent: xe } = $, { mapDoc: an } = G, dn = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
536
|
+
A("prettier-plugin-sql", e, s), e = {
|
|
537
|
+
...e,
|
|
538
|
+
...o
|
|
539
|
+
};
|
|
540
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L(), l = a.quasis.map(
|
|
541
|
+
(f, g, { length: h }) => g === h - 1 ? f.value.cooked : f.value.cooked + i(g)
|
|
542
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = S(r, n), b = await t(l, {
|
|
543
|
+
...e,
|
|
544
|
+
parser: "sql"
|
|
545
|
+
}), d = an(b, (f) => {
|
|
546
|
+
if (typeof f != "string")
|
|
547
|
+
return f;
|
|
548
|
+
const g = [], h = f.split(c);
|
|
549
|
+
for (let _ = 0; _ < h.length; _++) {
|
|
550
|
+
let E = h[_];
|
|
551
|
+
if (_ % 2 == 0) {
|
|
552
|
+
if (!E)
|
|
553
|
+
continue;
|
|
554
|
+
E = E.replaceAll(/([\\`]|\${)/g, "\\$1"), E.split(/(\n)/).forEach((x) => x === `
|
|
555
|
+
` ? g.push(on) : g.push(x));
|
|
556
|
+
} else {
|
|
557
|
+
const x = Number(E);
|
|
558
|
+
g.push(v[x]);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return g;
|
|
562
|
+
});
|
|
563
|
+
if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
564
|
+
return C([
|
|
565
|
+
"`",
|
|
566
|
+
p,
|
|
567
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [C(d)] : xe([C(d)]),
|
|
568
|
+
u,
|
|
569
|
+
"`"
|
|
570
|
+
]);
|
|
571
|
+
const m = p.length ? _e : Ee, y = u.length ? _e : Ee;
|
|
572
|
+
return C([
|
|
573
|
+
"`",
|
|
574
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [m, C(d)] : xe([m, C(d)]),
|
|
575
|
+
y,
|
|
576
|
+
"`"
|
|
577
|
+
]);
|
|
578
|
+
}, cn = [
|
|
539
579
|
"sql",
|
|
540
580
|
"bigquery",
|
|
541
581
|
"db2",
|
|
@@ -554,7 +594,7 @@ const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
554
594
|
"transactsql",
|
|
555
595
|
"tsql",
|
|
556
596
|
"trino"
|
|
557
|
-
],
|
|
597
|
+
], ln = [
|
|
558
598
|
"bigquery",
|
|
559
599
|
"db2",
|
|
560
600
|
"hive",
|
|
@@ -564,8 +604,8 @@ const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
564
604
|
"transactsql",
|
|
565
605
|
"flinksql",
|
|
566
606
|
"snowflake"
|
|
567
|
-
],
|
|
568
|
-
[
|
|
607
|
+
], un = I(je), mn = {
|
|
608
|
+
[un]: {
|
|
569
609
|
category: "Global",
|
|
570
610
|
type: "string",
|
|
571
611
|
array: !0,
|
|
@@ -573,208 +613,106 @@ const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
573
613
|
default: [{ value: ["sql", "mysql", "mariadb", "postgresql"] }],
|
|
574
614
|
description: 'Specify embedded SQL language identifiers. This requires "prettier-plugin-sql".'
|
|
575
615
|
}
|
|
576
|
-
},
|
|
577
|
-
B("prettier-plugin-sql", t, s), t = {
|
|
578
|
-
...t,
|
|
579
|
-
...i
|
|
580
|
-
};
|
|
581
|
-
const { node: a } = r, { createPlaceholder: c, placeholderRegex: l } = O(), u = a.quasis.map(
|
|
582
|
-
(p, v, { length: E }) => v === E - 1 ? p.value.cooked : p.value.cooked + c(v)
|
|
583
|
-
).join(""), m = u.match(/^\s+/)?.[0] ?? "", _ = u.match(/\s+$/)?.[0] ?? "", b = k(r, n), d = En(t, s, o);
|
|
584
|
-
if (typeof d > "u")
|
|
585
|
-
throw new SyntaxError(`Unrecognized identifier: ${s}`);
|
|
586
|
-
const g = await e(u, {
|
|
587
|
-
...t,
|
|
588
|
-
parser: "sql",
|
|
589
|
-
...d,
|
|
590
|
-
...i
|
|
591
|
-
}), y = yn(g, (p) => {
|
|
592
|
-
if (typeof p != "string")
|
|
593
|
-
return p;
|
|
594
|
-
const v = [], E = p.split(l);
|
|
595
|
-
for (let x = 0; x < E.length; x++) {
|
|
596
|
-
let S = E[x];
|
|
597
|
-
if (x % 2 == 0) {
|
|
598
|
-
if (!S)
|
|
599
|
-
continue;
|
|
600
|
-
S = S.replaceAll(/([\\`]|\${)/g, "\\$1"), S.split(/(\n)/).forEach((L) => L === `
|
|
601
|
-
` ? v.push(bn) : v.push(L));
|
|
602
|
-
} else {
|
|
603
|
-
const L = Number(S);
|
|
604
|
-
v.push(b[L]);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
return v;
|
|
608
|
-
});
|
|
609
|
-
if (t.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
610
|
-
return N([
|
|
611
|
-
"`",
|
|
612
|
-
m,
|
|
613
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [N(y)] : Se([N(y)]),
|
|
614
|
-
_,
|
|
615
|
-
"`"
|
|
616
|
-
]);
|
|
617
|
-
const f = m.length ? $e : Ie, h = _.length ? $e : Ie;
|
|
618
|
-
return N([
|
|
619
|
-
"`",
|
|
620
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [f, N(y)] : Se([f, N(y)]),
|
|
621
|
-
h,
|
|
622
|
-
"`"
|
|
623
|
-
]);
|
|
624
|
-
}, _n = {
|
|
625
|
-
"sql-formatter": (e) => Ue.includes(e),
|
|
626
|
-
"node-sql-parser": (e) => Ke.includes(e)
|
|
627
|
-
};
|
|
628
|
-
function Le(e, n) {
|
|
629
|
-
for (const r of n)
|
|
630
|
-
if (_n[r](e))
|
|
631
|
-
switch (r) {
|
|
632
|
-
case "sql-formatter":
|
|
633
|
-
return {
|
|
634
|
-
formatter: r,
|
|
635
|
-
language: e
|
|
636
|
-
};
|
|
637
|
-
case "node-sql-parser":
|
|
638
|
-
return {
|
|
639
|
-
formatter: r,
|
|
640
|
-
database: e
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
function G(e, n, r) {
|
|
645
|
-
let t = Le(e, r);
|
|
646
|
-
if (t)
|
|
647
|
-
return t;
|
|
648
|
-
const s = n.indexOf(e);
|
|
649
|
-
for (let o = s - 1; o >= 0; --o)
|
|
650
|
-
if (t = Le(
|
|
651
|
-
n[o],
|
|
652
|
-
r
|
|
653
|
-
), t)
|
|
654
|
-
return t;
|
|
655
|
-
}
|
|
656
|
-
function En(e, n, r) {
|
|
657
|
-
switch (e.formatter ?? "sql-formatter") {
|
|
658
|
-
case "sql-formatter":
|
|
659
|
-
return G(
|
|
660
|
-
n,
|
|
661
|
-
r,
|
|
662
|
-
["sql-formatter", "node-sql-parser"]
|
|
663
|
-
);
|
|
664
|
-
case "node-sql-parser":
|
|
665
|
-
return G(
|
|
666
|
-
n,
|
|
667
|
-
r,
|
|
668
|
-
["node-sql-parser", "sql-formatter"]
|
|
669
|
-
);
|
|
670
|
-
default:
|
|
671
|
-
return G(
|
|
672
|
-
n,
|
|
673
|
-
r,
|
|
674
|
-
["sql-formatter", "node-sql-parser"]
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
const xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
616
|
+
}, gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
679
617
|
__proto__: null,
|
|
680
|
-
NODE_SQL_PARSER_DATABASES:
|
|
681
|
-
SQL_FORMATTER_LANGUAGES:
|
|
682
|
-
embeddedLanguage:
|
|
683
|
-
embedder:
|
|
684
|
-
options:
|
|
685
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
686
|
-
|
|
687
|
-
...
|
|
618
|
+
NODE_SQL_PARSER_DATABASES: ln,
|
|
619
|
+
SQL_FORMATTER_LANGUAGES: cn,
|
|
620
|
+
embeddedLanguage: je,
|
|
621
|
+
embedder: dn,
|
|
622
|
+
options: mn
|
|
623
|
+
}, Symbol.toStringTag, { value: "Module" })), Fe = "embeddedTs", { line: $e, group: N, indent: Ie, softline: Se } = $, pn = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
624
|
+
e = {
|
|
625
|
+
...e,
|
|
688
626
|
...o
|
|
689
627
|
};
|
|
690
|
-
const { node:
|
|
691
|
-
(f,
|
|
692
|
-
).join(""),
|
|
693
|
-
...
|
|
694
|
-
parser:
|
|
628
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L(), l = a.quasis.map(
|
|
629
|
+
(f, g, { length: h }) => g === h - 1 ? f.value.cooked : f.value.cooked + i(g)
|
|
630
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = S(r, n), b = await t(l, {
|
|
631
|
+
...e,
|
|
632
|
+
parser: e.embeddedTsParser ?? "typescript",
|
|
695
633
|
// set filepath to undefined to enable jsx auto detection:
|
|
696
634
|
// https://github.com/prettier/prettier/blob/427a84d24203e2d54160cde153a1e6a6390fe65a/src/language-js/parse/typescript.js#L49-L53
|
|
697
635
|
filepath: void 0
|
|
698
|
-
}), d =
|
|
699
|
-
if (
|
|
700
|
-
return
|
|
636
|
+
}), d = k(b, c, v);
|
|
637
|
+
if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
638
|
+
return N([
|
|
701
639
|
"`",
|
|
640
|
+
p,
|
|
641
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [N(d)] : Ie([N(d)]),
|
|
702
642
|
u,
|
|
703
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [A(d)] : Oe([A(d)]),
|
|
704
|
-
m,
|
|
705
643
|
"`"
|
|
706
644
|
]);
|
|
707
|
-
const
|
|
708
|
-
return
|
|
645
|
+
const m = p.length ? $e : Se, y = u.length ? $e : Se;
|
|
646
|
+
return N([
|
|
709
647
|
"`",
|
|
710
|
-
|
|
648
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [m, N(d)] : Ie([m, N(d)]),
|
|
711
649
|
y,
|
|
712
650
|
"`"
|
|
713
651
|
]);
|
|
714
|
-
},
|
|
715
|
-
[
|
|
652
|
+
}, fn = ["ts", "tsx", "cts", "mts", "typescript"], hn = "embeddedTsParser", bn = I(Fe), yn = {
|
|
653
|
+
[bn]: {
|
|
716
654
|
category: "Global",
|
|
717
655
|
type: "string",
|
|
718
656
|
array: !0,
|
|
719
|
-
default: [{ value: [...
|
|
657
|
+
default: [{ value: [...fn] }],
|
|
720
658
|
description: "Specify embedded TS language parsers."
|
|
721
659
|
},
|
|
722
|
-
[
|
|
660
|
+
[hn]: {
|
|
723
661
|
category: "Global",
|
|
724
662
|
type: "string",
|
|
725
663
|
array: !1,
|
|
726
664
|
default: "typescript",
|
|
727
665
|
description: "Specify the embedded TS language parser."
|
|
728
666
|
}
|
|
729
|
-
},
|
|
667
|
+
}, vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
730
668
|
__proto__: null,
|
|
731
|
-
embeddedLanguage:
|
|
732
|
-
embedder:
|
|
733
|
-
options:
|
|
734
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
735
|
-
|
|
736
|
-
...
|
|
669
|
+
embeddedLanguage: Fe,
|
|
670
|
+
embedder: pn,
|
|
671
|
+
options: yn
|
|
672
|
+
}, Symbol.toStringTag, { value: "Module" })), J = "embeddedXml", { line: Le, group: j, indent: ke, softline: z } = $, _n = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
|
|
673
|
+
A("@prettier/plugin-xml", e, s), e = {
|
|
674
|
+
...e,
|
|
737
675
|
...o
|
|
738
676
|
};
|
|
739
|
-
const { node:
|
|
740
|
-
(
|
|
741
|
-
).join(""),
|
|
742
|
-
|
|
743
|
-
-
|
|
744
|
-
), b =
|
|
745
|
-
let
|
|
746
|
-
for (;
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
677
|
+
const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = L(), l = a.quasis.map(
|
|
678
|
+
(h, _, { length: E }) => _ === E - 1 ? h.value.cooked : h.value.cooked + i(_)
|
|
679
|
+
).join(""), p = l.match(/^\s+/)?.[0] ?? "", u = l.match(/\s+$/)?.[0] ?? "", v = l.slice(
|
|
680
|
+
p.length,
|
|
681
|
+
-u.length || void 0
|
|
682
|
+
), b = S(r, n), d = [];
|
|
683
|
+
let m = 0;
|
|
684
|
+
for (; m !== void 0; ) {
|
|
685
|
+
const h = v.slice(m);
|
|
686
|
+
if (h.length === 0)
|
|
749
687
|
break;
|
|
750
|
-
|
|
688
|
+
m > 0 && e.xmlWhitespaceSensitivity !== "strict" && d.push(z), e.__embeddedXmlFragmentRecoverIndex?.splice(
|
|
751
689
|
0,
|
|
752
|
-
|
|
690
|
+
e.__embeddedXmlFragmentRecoverIndex.length
|
|
753
691
|
);
|
|
754
|
-
let
|
|
755
|
-
...
|
|
756
|
-
parser:
|
|
692
|
+
let _ = await t(h, {
|
|
693
|
+
...e,
|
|
694
|
+
parser: J
|
|
757
695
|
});
|
|
758
|
-
const [E, x] =
|
|
759
|
-
E === void 0 ?
|
|
696
|
+
const [E, x] = e.__embeddedXmlFragmentRecoverIndex ?? [];
|
|
697
|
+
E === void 0 ? m = void 0 : x === void 0 ? m += E : (_ = h.slice(E, x + 1), m += x + 1), d.push(_);
|
|
760
698
|
}
|
|
761
|
-
const y =
|
|
762
|
-
if (
|
|
763
|
-
return
|
|
699
|
+
const y = k(d, c, b);
|
|
700
|
+
if (e.xmlWhitespaceSensitivity === "strict" || e.preserveEmbeddedExteriorWhitespaces?.includes(s))
|
|
701
|
+
return j([
|
|
764
702
|
"`",
|
|
703
|
+
p,
|
|
704
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [j(y)] : ke([j(y)]),
|
|
765
705
|
u,
|
|
766
|
-
t.noEmbeddedMultiLineIndentation?.includes(s) ? [q(y)] : De([q(y)]),
|
|
767
|
-
m,
|
|
768
706
|
"`"
|
|
769
707
|
]);
|
|
770
|
-
const f =
|
|
771
|
-
return
|
|
708
|
+
const f = p.length ? Le : z, g = u.length ? Le : z;
|
|
709
|
+
return j([
|
|
772
710
|
"`",
|
|
773
|
-
|
|
774
|
-
|
|
711
|
+
e.noEmbeddedMultiLineIndentation?.includes(s) ? [f, j(y)] : ke([f, j(y)]),
|
|
712
|
+
g,
|
|
775
713
|
"`"
|
|
776
714
|
]);
|
|
777
|
-
},
|
|
715
|
+
}, En = [
|
|
778
716
|
"xml",
|
|
779
717
|
"xsd",
|
|
780
718
|
"ascx",
|
|
@@ -831,12 +769,12 @@ const xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
831
769
|
"xpdl",
|
|
832
770
|
"xul",
|
|
833
771
|
"xoml"
|
|
834
|
-
],
|
|
835
|
-
[
|
|
772
|
+
], xn = I(J), $n = {
|
|
773
|
+
[xn]: {
|
|
836
774
|
category: "Global",
|
|
837
775
|
type: "string",
|
|
838
776
|
array: !0,
|
|
839
|
-
default: [{ value: [...
|
|
777
|
+
default: [{ value: [...En] }],
|
|
840
778
|
description: 'Specify embedded XML language identifiers. This requires "@prettier/plugin-xml".'
|
|
841
779
|
},
|
|
842
780
|
/** @internal */
|
|
@@ -848,192 +786,192 @@ const xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
848
786
|
description: "This option is read only and used as a workaround to support xml fragments"
|
|
849
787
|
}
|
|
850
788
|
};
|
|
851
|
-
function
|
|
789
|
+
function In(t) {
|
|
852
790
|
const n = {
|
|
853
791
|
loc: {
|
|
854
792
|
start: {
|
|
855
|
-
line:
|
|
856
|
-
column:
|
|
793
|
+
line: t.line,
|
|
794
|
+
column: t.column
|
|
857
795
|
},
|
|
858
796
|
end: {
|
|
859
|
-
line:
|
|
860
|
-
column:
|
|
797
|
+
line: t.line,
|
|
798
|
+
column: t.column + t.length
|
|
861
799
|
}
|
|
862
800
|
}
|
|
863
801
|
}, r = new SyntaxError(
|
|
864
|
-
`${
|
|
802
|
+
`${t.message} (${n.loc.start.line}:${n.loc.start.column})`,
|
|
865
803
|
{
|
|
866
|
-
cause:
|
|
804
|
+
cause: t
|
|
867
805
|
}
|
|
868
806
|
);
|
|
869
807
|
return Object.assign(r, n), r;
|
|
870
808
|
}
|
|
871
|
-
function
|
|
809
|
+
function Oe(t) {
|
|
872
810
|
const n = {
|
|
873
811
|
loc: {
|
|
874
812
|
start: {
|
|
875
|
-
line:
|
|
876
|
-
column:
|
|
813
|
+
line: t.token.startLine ?? NaN,
|
|
814
|
+
column: t.token.startColumn ?? NaN
|
|
877
815
|
},
|
|
878
816
|
end: {
|
|
879
|
-
line:
|
|
880
|
-
column:
|
|
817
|
+
line: t.token.endLine ?? NaN,
|
|
818
|
+
column: t.token.endColumn ?? NaN
|
|
881
819
|
}
|
|
882
820
|
}
|
|
883
821
|
}, r = new SyntaxError(
|
|
884
|
-
`${
|
|
822
|
+
`${t.message} (${n.loc.start.line}:${n.loc.start.column})`,
|
|
885
823
|
{
|
|
886
|
-
cause:
|
|
824
|
+
cause: t
|
|
887
825
|
}
|
|
888
826
|
);
|
|
889
827
|
return Object.assign(r, n), r;
|
|
890
828
|
}
|
|
891
|
-
const
|
|
892
|
-
async parse(
|
|
893
|
-
const { parse: r } = await import("@xml-tools/parser"), { lexErrors:
|
|
894
|
-
if (
|
|
895
|
-
const
|
|
896
|
-
throw
|
|
829
|
+
const Sn = {
|
|
830
|
+
async parse(t, n) {
|
|
831
|
+
const { parse: r } = await import("@xml-tools/parser"), { lexErrors: e, parseErrors: s, cst: o } = r(t);
|
|
832
|
+
if (e.length > 0) {
|
|
833
|
+
const a = e[0];
|
|
834
|
+
throw In(a);
|
|
897
835
|
}
|
|
898
836
|
if (s.length > 0) {
|
|
899
|
-
let
|
|
900
|
-
for (const
|
|
837
|
+
let a = !1;
|
|
838
|
+
for (const i of s) {
|
|
901
839
|
if (!["MismatchedTokenException", "NotAllInputParsedException"].includes(
|
|
902
|
-
|
|
840
|
+
i.name
|
|
903
841
|
))
|
|
904
|
-
throw
|
|
905
|
-
if (
|
|
906
|
-
|
|
842
|
+
throw Oe(i);
|
|
843
|
+
if (i.message === "Expecting token of type --> OPEN <-- but found --> '' <--") {
|
|
844
|
+
a = !0;
|
|
907
845
|
continue;
|
|
908
846
|
}
|
|
909
847
|
if (/Expecting token of type --> EOF <-- but found --> '[\s\S]+' <--/.test(
|
|
910
|
-
|
|
911
|
-
) || /Redundant input, expecting EOF but found: /.test(
|
|
848
|
+
i.message
|
|
849
|
+
) || /Redundant input, expecting EOF but found: /.test(i.message)) {
|
|
912
850
|
n.__embeddedXmlFragmentRecoverIndex?.splice(
|
|
913
851
|
0,
|
|
914
852
|
n.__embeddedXmlFragmentRecoverIndex.length,
|
|
915
|
-
|
|
853
|
+
i.token.startOffset
|
|
916
854
|
);
|
|
917
855
|
break;
|
|
918
856
|
}
|
|
919
857
|
if (/Expecting token of type --> OPEN <-- but found --> '[\s\S]+' <--/.test(
|
|
920
|
-
|
|
858
|
+
i.message
|
|
921
859
|
)) {
|
|
922
|
-
if (
|
|
860
|
+
if (i.token.endOffset === void 0 || Number.isNaN(i.token.endOffset))
|
|
923
861
|
break;
|
|
924
862
|
n.__embeddedXmlFragmentRecoverIndex?.splice(
|
|
925
863
|
0,
|
|
926
864
|
n.__embeddedXmlFragmentRecoverIndex.length,
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
),
|
|
865
|
+
i.token.startOffset,
|
|
866
|
+
i.token.endOffset
|
|
867
|
+
), a = !0;
|
|
930
868
|
break;
|
|
931
869
|
}
|
|
932
|
-
throw
|
|
870
|
+
throw Oe(i);
|
|
933
871
|
}
|
|
934
|
-
|
|
872
|
+
a && Ae(o);
|
|
935
873
|
}
|
|
936
874
|
return o;
|
|
937
875
|
},
|
|
938
876
|
astFormat: "xml",
|
|
939
|
-
locStart(
|
|
940
|
-
return
|
|
877
|
+
locStart(t) {
|
|
878
|
+
return t.location.startOffset;
|
|
941
879
|
},
|
|
942
|
-
locEnd(
|
|
943
|
-
return
|
|
880
|
+
locEnd(t) {
|
|
881
|
+
return t.location.endOffset ?? NaN;
|
|
944
882
|
}
|
|
945
883
|
};
|
|
946
|
-
function
|
|
947
|
-
const n =
|
|
884
|
+
function Ae(t) {
|
|
885
|
+
const n = t.children;
|
|
948
886
|
for (const r in n) {
|
|
949
|
-
const
|
|
950
|
-
for (let s =
|
|
951
|
-
const o =
|
|
952
|
-
if (
|
|
887
|
+
const e = n[r] ?? [];
|
|
888
|
+
for (let s = e.length - 1; s >= 0; --s) {
|
|
889
|
+
const o = e[s];
|
|
890
|
+
if (Ln(o)) {
|
|
953
891
|
if (Object.keys(o.children).length === 0) {
|
|
954
|
-
|
|
892
|
+
e.splice(s, 1), e.length === 0 && delete n[r];
|
|
955
893
|
continue;
|
|
956
894
|
}
|
|
957
|
-
|
|
895
|
+
Ae(o);
|
|
958
896
|
}
|
|
959
897
|
}
|
|
960
898
|
}
|
|
961
899
|
}
|
|
962
|
-
function
|
|
963
|
-
return "name" in
|
|
900
|
+
function Ln(t) {
|
|
901
|
+
return "name" in t && "children" in t && "location" in t;
|
|
964
902
|
}
|
|
965
|
-
const
|
|
903
|
+
const kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
966
904
|
__proto__: null,
|
|
967
|
-
embeddedLanguage:
|
|
968
|
-
embedder:
|
|
969
|
-
options:
|
|
970
|
-
parser:
|
|
971
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
972
|
-
"./css/index.ts":
|
|
973
|
-
"./es/index.ts":
|
|
974
|
-
"./glsl/index.ts":
|
|
975
|
-
"./html/index.ts":
|
|
976
|
-
"./markdown/index.ts":
|
|
977
|
-
"./noop/index.ts":
|
|
978
|
-
"./php/index.ts":
|
|
979
|
-
"./ruby/index.ts":
|
|
980
|
-
"./sql/index.ts":
|
|
981
|
-
"./ts/index.ts":
|
|
982
|
-
"./xml/index.ts":
|
|
905
|
+
embeddedLanguage: J,
|
|
906
|
+
embedder: _n,
|
|
907
|
+
options: $n,
|
|
908
|
+
parser: Sn
|
|
909
|
+
}, Symbol.toStringTag, { value: "Module" })), Be = [], We = {}, qe = {}, Ke = {}, On = /* @__PURE__ */ Object.assign({
|
|
910
|
+
"./css/index.ts": yt,
|
|
911
|
+
"./es/index.ts": It,
|
|
912
|
+
"./glsl/index.ts": Tt,
|
|
913
|
+
"./html/index.ts": Ct,
|
|
914
|
+
"./markdown/index.ts": Bt,
|
|
915
|
+
"./noop/index.ts": Kt,
|
|
916
|
+
"./php/index.ts": Xt,
|
|
917
|
+
"./ruby/index.ts": sn,
|
|
918
|
+
"./sql/index.ts": gn,
|
|
919
|
+
"./ts/index.ts": vn,
|
|
920
|
+
"./xml/index.ts": kn
|
|
983
921
|
});
|
|
984
|
-
Object.values(
|
|
985
|
-
({ embeddedLanguage:
|
|
986
|
-
|
|
922
|
+
Object.values(On).forEach(
|
|
923
|
+
({ embeddedLanguage: t, parser: n, embedder: r, options: e }) => {
|
|
924
|
+
mt(Be, t, X), n && (We[t] = n), r && (qe[t] = r), Object.assign(Ke, e);
|
|
987
925
|
}
|
|
988
926
|
);
|
|
989
|
-
const
|
|
990
|
-
...
|
|
991
|
-
[
|
|
927
|
+
const Tn = "noEmbeddedIdentificationByComment", Dn = "noEmbeddedIdentificationByTag", wn = "preserveEmbeddedExteriorWhitespaces", Pn = "noEmbeddedMultiLineIndentation", Rn = "embeddedOverrides", ir = {
|
|
928
|
+
...Ke,
|
|
929
|
+
[Tn]: {
|
|
992
930
|
category: "Global",
|
|
993
931
|
type: "string",
|
|
994
932
|
array: !0,
|
|
995
933
|
default: [{ value: [] }],
|
|
996
934
|
description: 'This option turns off "/* identifier */ `...`" comment-based language identification for the specified identifiers.'
|
|
997
935
|
},
|
|
998
|
-
[
|
|
936
|
+
[Dn]: {
|
|
999
937
|
category: "Global",
|
|
1000
938
|
type: "string",
|
|
1001
939
|
array: !0,
|
|
1002
940
|
default: [{ value: [] }],
|
|
1003
941
|
description: 'This option turns off "identifier`...`" tag-based language identification for the specified identifiers.'
|
|
1004
942
|
},
|
|
1005
|
-
[
|
|
943
|
+
[wn]: {
|
|
1006
944
|
category: "Config",
|
|
1007
945
|
type: "string",
|
|
1008
946
|
array: !0,
|
|
1009
947
|
default: [{ value: [] }],
|
|
1010
948
|
description: "This option preserves leading and trailing whitespaces in the formatting results for the specified identifiers."
|
|
1011
949
|
},
|
|
1012
|
-
[
|
|
950
|
+
[Pn]: {
|
|
1013
951
|
category: "Global",
|
|
1014
952
|
type: "string",
|
|
1015
953
|
array: !0,
|
|
1016
954
|
default: [{ value: [] }],
|
|
1017
955
|
description: "This option turns off auto indentation in the formatting results for the specified identifiers when they are formatted to span multi lines."
|
|
1018
956
|
},
|
|
1019
|
-
[
|
|
957
|
+
[Rn]: {
|
|
1020
958
|
category: "Global",
|
|
1021
959
|
type: "string",
|
|
1022
960
|
array: !1,
|
|
1023
961
|
default: void 0,
|
|
1024
962
|
description: "This option accepts option overrides for the specified identifiers. It should either be a stringified JSON or an absolute filepath to the option overrides file."
|
|
1025
963
|
}
|
|
1026
|
-
},
|
|
964
|
+
}, ar = {
|
|
1027
965
|
// parsers from internal
|
|
1028
|
-
...
|
|
1029
|
-
...
|
|
1030
|
-
...
|
|
1031
|
-
...
|
|
1032
|
-
...
|
|
966
|
+
...Xe.parsers,
|
|
967
|
+
...Je.parsers,
|
|
968
|
+
...Ye.parsers,
|
|
969
|
+
...Qe.parsers,
|
|
970
|
+
...Ve.parsers,
|
|
1033
971
|
// parsers from this plugin
|
|
1034
|
-
...
|
|
972
|
+
...We
|
|
1035
973
|
};
|
|
1036
|
-
var
|
|
974
|
+
var Mn = {
|
|
1037
975
|
isEqual: !0,
|
|
1038
976
|
isMatchingKey: !0,
|
|
1039
977
|
isPromise: !0,
|
|
@@ -1042,40 +980,40 @@ var Un = {
|
|
|
1042
980
|
onCacheChange: !0,
|
|
1043
981
|
onCacheHit: !0,
|
|
1044
982
|
transformKey: !0
|
|
1045
|
-
},
|
|
1046
|
-
function W(
|
|
1047
|
-
var n =
|
|
1048
|
-
return n ? n === 1 ? [
|
|
983
|
+
}, Cn = Array.prototype.slice;
|
|
984
|
+
function W(t) {
|
|
985
|
+
var n = t.length;
|
|
986
|
+
return n ? n === 1 ? [t[0]] : n === 2 ? [t[0], t[1]] : n === 3 ? [t[0], t[1], t[2]] : Cn.call(t, 0) : [];
|
|
1049
987
|
}
|
|
1050
|
-
function
|
|
988
|
+
function Nn(t) {
|
|
1051
989
|
var n = {};
|
|
1052
|
-
for (var r in
|
|
1053
|
-
|
|
990
|
+
for (var r in t)
|
|
991
|
+
Mn[r] || (n[r] = t[r]);
|
|
1054
992
|
return n;
|
|
1055
993
|
}
|
|
1056
|
-
function
|
|
1057
|
-
return typeof
|
|
994
|
+
function jn(t) {
|
|
995
|
+
return typeof t == "function" && t.isMemoized;
|
|
1058
996
|
}
|
|
1059
|
-
function
|
|
1060
|
-
return
|
|
997
|
+
function Fn(t, n) {
|
|
998
|
+
return t === n || t !== t && n !== n;
|
|
1061
999
|
}
|
|
1062
|
-
function
|
|
1000
|
+
function Te(t, n) {
|
|
1063
1001
|
var r = {};
|
|
1064
|
-
for (var
|
|
1065
|
-
r[
|
|
1066
|
-
for (var
|
|
1067
|
-
r[
|
|
1002
|
+
for (var e in t)
|
|
1003
|
+
r[e] = t[e];
|
|
1004
|
+
for (var e in n)
|
|
1005
|
+
r[e] = n[e];
|
|
1068
1006
|
return r;
|
|
1069
1007
|
}
|
|
1070
|
-
var
|
|
1008
|
+
var An = (
|
|
1071
1009
|
/** @class */
|
|
1072
1010
|
function() {
|
|
1073
|
-
function
|
|
1011
|
+
function t(n) {
|
|
1074
1012
|
this.keys = [], this.values = [], this.options = n;
|
|
1075
1013
|
var r = typeof n.isMatchingKey == "function";
|
|
1076
1014
|
r ? this.getKeyIndex = this._getKeyIndexFromMatchingKey : n.maxSize > 1 ? this.getKeyIndex = this._getKeyIndexForMany : this.getKeyIndex = this._getKeyIndexForSingle, this.canTransformKey = typeof n.transformKey == "function", this.shouldCloneArguments = this.canTransformKey || r, this.shouldUpdateOnAdd = typeof n.onCacheAdd == "function", this.shouldUpdateOnChange = typeof n.onCacheChange == "function", this.shouldUpdateOnHit = typeof n.onCacheHit == "function";
|
|
1077
1015
|
}
|
|
1078
|
-
return Object.defineProperty(
|
|
1016
|
+
return Object.defineProperty(t.prototype, "size", {
|
|
1079
1017
|
/**
|
|
1080
1018
|
* The number of cached [key,value] results.
|
|
1081
1019
|
*/
|
|
@@ -1084,7 +1022,7 @@ var Xn = (
|
|
|
1084
1022
|
},
|
|
1085
1023
|
enumerable: !1,
|
|
1086
1024
|
configurable: !0
|
|
1087
|
-
}), Object.defineProperty(
|
|
1025
|
+
}), Object.defineProperty(t.prototype, "snapshot", {
|
|
1088
1026
|
/**
|
|
1089
1027
|
* A copy of the cache at a moment in time. This is useful
|
|
1090
1028
|
* to compare changes over time, since the cache mutates
|
|
@@ -1099,218 +1037,188 @@ var Xn = (
|
|
|
1099
1037
|
},
|
|
1100
1038
|
enumerable: !1,
|
|
1101
1039
|
configurable: !0
|
|
1102
|
-
}),
|
|
1103
|
-
var r = this.options,
|
|
1104
|
-
if (!
|
|
1040
|
+
}), t.prototype._getKeyIndexFromMatchingKey = function(n) {
|
|
1041
|
+
var r = this.options, e = r.isMatchingKey, s = r.maxSize, o = this.keys, a = o.length;
|
|
1042
|
+
if (!a)
|
|
1105
1043
|
return -1;
|
|
1106
|
-
if (
|
|
1044
|
+
if (e(o[0], n))
|
|
1107
1045
|
return 0;
|
|
1108
1046
|
if (s > 1) {
|
|
1109
|
-
for (var
|
|
1110
|
-
if (
|
|
1111
|
-
return
|
|
1047
|
+
for (var i = 1; i < a; i++)
|
|
1048
|
+
if (e(o[i], n))
|
|
1049
|
+
return i;
|
|
1112
1050
|
}
|
|
1113
1051
|
return -1;
|
|
1114
|
-
},
|
|
1115
|
-
var r = this.options.isEqual,
|
|
1052
|
+
}, t.prototype._getKeyIndexForMany = function(n) {
|
|
1053
|
+
var r = this.options.isEqual, e = this.keys, s = e.length;
|
|
1116
1054
|
if (!s)
|
|
1117
1055
|
return -1;
|
|
1118
1056
|
if (s === 1)
|
|
1119
1057
|
return this._getKeyIndexForSingle(n);
|
|
1120
|
-
var o = n.length,
|
|
1058
|
+
var o = n.length, a, i;
|
|
1121
1059
|
if (o > 1) {
|
|
1122
1060
|
for (var c = 0; c < s; c++)
|
|
1123
|
-
if (
|
|
1124
|
-
for (
|
|
1061
|
+
if (a = e[c], a.length === o) {
|
|
1062
|
+
for (i = 0; i < o && r(a[i], n[i]); i++)
|
|
1125
1063
|
;
|
|
1126
|
-
if (
|
|
1064
|
+
if (i === o)
|
|
1127
1065
|
return c;
|
|
1128
1066
|
}
|
|
1129
1067
|
} else
|
|
1130
1068
|
for (var c = 0; c < s; c++)
|
|
1131
|
-
if (
|
|
1069
|
+
if (a = e[c], a.length === o && r(a[0], n[0]))
|
|
1132
1070
|
return c;
|
|
1133
1071
|
return -1;
|
|
1134
|
-
},
|
|
1072
|
+
}, t.prototype._getKeyIndexForSingle = function(n) {
|
|
1135
1073
|
var r = this.keys;
|
|
1136
1074
|
if (!r.length)
|
|
1137
1075
|
return -1;
|
|
1138
|
-
var
|
|
1076
|
+
var e = r[0], s = e.length;
|
|
1139
1077
|
if (n.length !== s)
|
|
1140
1078
|
return -1;
|
|
1141
1079
|
var o = this.options.isEqual;
|
|
1142
1080
|
if (s > 1) {
|
|
1143
|
-
for (var
|
|
1144
|
-
if (!o(
|
|
1081
|
+
for (var a = 0; a < s; a++)
|
|
1082
|
+
if (!o(e[a], n[a]))
|
|
1145
1083
|
return -1;
|
|
1146
1084
|
return 0;
|
|
1147
1085
|
}
|
|
1148
|
-
return o(
|
|
1149
|
-
},
|
|
1150
|
-
for (var s = this.keys, o = this.values,
|
|
1151
|
-
s[
|
|
1086
|
+
return o(e[0], n[0]) ? 0 : -1;
|
|
1087
|
+
}, t.prototype.orderByLru = function(n, r, e) {
|
|
1088
|
+
for (var s = this.keys, o = this.values, a = s.length, i = e; i--; )
|
|
1089
|
+
s[i + 1] = s[i], o[i + 1] = o[i];
|
|
1152
1090
|
s[0] = n, o[0] = r;
|
|
1153
1091
|
var c = this.options.maxSize;
|
|
1154
|
-
|
|
1155
|
-
},
|
|
1156
|
-
var r = this,
|
|
1157
|
-
this.values[0] =
|
|
1092
|
+
a === c && e === a ? (s.pop(), o.pop()) : e >= c && (s.length = o.length = c);
|
|
1093
|
+
}, t.prototype.updateAsyncCache = function(n) {
|
|
1094
|
+
var r = this, e = this.options, s = e.onCacheChange, o = e.onCacheHit, a = this.keys[0], i = this.values[0];
|
|
1095
|
+
this.values[0] = i.then(function(c) {
|
|
1158
1096
|
return r.shouldUpdateOnHit && o(r, r.options, n), r.shouldUpdateOnChange && s(r, r.options, n), c;
|
|
1159
1097
|
}, function(c) {
|
|
1160
|
-
var l = r.getKeyIndex(
|
|
1098
|
+
var l = r.getKeyIndex(a);
|
|
1161
1099
|
throw l !== -1 && (r.keys.splice(l, 1), r.values.splice(l, 1)), c;
|
|
1162
1100
|
});
|
|
1163
|
-
},
|
|
1101
|
+
}, t;
|
|
1164
1102
|
}()
|
|
1165
1103
|
);
|
|
1166
|
-
function
|
|
1167
|
-
if (n === void 0 && (n = {}),
|
|
1168
|
-
return
|
|
1169
|
-
if (typeof
|
|
1104
|
+
function Ue(t, n) {
|
|
1105
|
+
if (n === void 0 && (n = {}), jn(t))
|
|
1106
|
+
return Ue(t.fn, Te(t.options, n));
|
|
1107
|
+
if (typeof t != "function")
|
|
1170
1108
|
throw new TypeError("You must pass a function to `memoize`.");
|
|
1171
|
-
var r = n.isEqual,
|
|
1172
|
-
isEqual:
|
|
1109
|
+
var r = n.isEqual, e = r === void 0 ? Fn : r, s = n.isMatchingKey, o = n.isPromise, a = o === void 0 ? !1 : o, i = n.maxSize, c = i === void 0 ? 1 : i, l = n.onCacheAdd, p = n.onCacheChange, u = n.onCacheHit, v = n.transformKey, b = Te({
|
|
1110
|
+
isEqual: e,
|
|
1173
1111
|
isMatchingKey: s,
|
|
1174
|
-
isPromise:
|
|
1112
|
+
isPromise: a,
|
|
1175
1113
|
maxSize: c,
|
|
1176
1114
|
onCacheAdd: l,
|
|
1177
|
-
onCacheChange:
|
|
1178
|
-
onCacheHit:
|
|
1179
|
-
transformKey:
|
|
1180
|
-
},
|
|
1181
|
-
var
|
|
1182
|
-
f && (
|
|
1183
|
-
var
|
|
1184
|
-
if (
|
|
1185
|
-
E &&
|
|
1115
|
+
onCacheChange: p,
|
|
1116
|
+
onCacheHit: u,
|
|
1117
|
+
transformKey: v
|
|
1118
|
+
}, Nn(n)), d = new An(b), m = d.keys, y = d.values, f = d.canTransformKey, g = d.shouldCloneArguments, h = d.shouldUpdateOnAdd, _ = d.shouldUpdateOnChange, E = d.shouldUpdateOnHit, x = function() {
|
|
1119
|
+
var B = g ? W(arguments) : arguments;
|
|
1120
|
+
f && (B = v(B));
|
|
1121
|
+
var F = m.length ? d.getKeyIndex(B) : -1;
|
|
1122
|
+
if (F !== -1)
|
|
1123
|
+
E && u(d, b, x), F && (d.orderByLru(m[F], y[F], F), _ && p(d, b, x));
|
|
1186
1124
|
else {
|
|
1187
|
-
var
|
|
1188
|
-
d.orderByLru(
|
|
1125
|
+
var Ge = t.apply(this, arguments), He = g ? B : W(arguments);
|
|
1126
|
+
d.orderByLru(He, Ge, m.length), a && d.updateAsyncCache(x), h && l(d, b, x), _ && p(d, b, x);
|
|
1189
1127
|
}
|
|
1190
1128
|
return y[0];
|
|
1191
1129
|
};
|
|
1192
|
-
return x.cache = d, x.fn =
|
|
1193
|
-
}
|
|
1194
|
-
const je = (e) => e instanceof URL ? pt(e) : e;
|
|
1195
|
-
async function Jn(e, {
|
|
1196
|
-
cwd: n = Me.cwd(),
|
|
1197
|
-
type: r = "file",
|
|
1198
|
-
stopAt: t
|
|
1199
|
-
} = {}) {
|
|
1200
|
-
let s = T.resolve(je(n) ?? "");
|
|
1201
|
-
const { root: o } = T.parse(s);
|
|
1202
|
-
for (t = T.resolve(s, je(t ?? o)); s && s !== t && s !== o; ) {
|
|
1203
|
-
const i = T.isAbsolute(e) ? e : T.join(s, e);
|
|
1204
|
-
try {
|
|
1205
|
-
const a = await at.stat(i);
|
|
1206
|
-
if (r === "file" && a.isFile() || r === "directory" && a.isDirectory())
|
|
1207
|
-
return i;
|
|
1208
|
-
} catch {
|
|
1209
|
-
}
|
|
1210
|
-
s = T.dirname(s);
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
async function Yn({ cwd: e = Me.cwd() } = {}) {
|
|
1214
|
-
return Jn("package.json", { cwd: e });
|
|
1130
|
+
return x.cache = d, x.fn = t, x.isMemoized = !0, x.options = b, x;
|
|
1215
1131
|
}
|
|
1216
|
-
async function
|
|
1132
|
+
async function De(t) {
|
|
1217
1133
|
try {
|
|
1218
|
-
const n = await
|
|
1134
|
+
const n = await et(t, { encoding: "utf-8" });
|
|
1219
1135
|
return JSON.parse(n);
|
|
1220
1136
|
} catch {
|
|
1221
1137
|
}
|
|
1222
1138
|
}
|
|
1223
|
-
const
|
|
1224
|
-
"data:text/javascript," + encodeURIComponent(
|
|
1225
|
-
'import{workerData as r,parentPort as t}from"node:worker_threads";import{pathToFileURL as a}from"node:url";async function d({absolutePath:o}){try{const e=await import(a(o).href);t?.postMessage(e.embeddedOverrides??e.default??void 0)}catch{t?.postMessage(void 0)}}d(r);'
|
|
1226
|
-
)
|
|
1139
|
+
const Bn = /* @__PURE__ */ new URL(
|
|
1140
|
+
"data:text/javascript," + encodeURIComponent('import{pathToFileURL as r}from"node:url";import{parentPort as t,workerData as a}from"node:worker_threads";const s=async({absolutePath:o})=>{try{const e=await import(r(o).href);t?.postMessage(e.embeddedOverrides??e.default??void 0)}catch{t?.postMessage(void 0)}};s(a);')
|
|
1227
1141
|
);
|
|
1228
|
-
async function
|
|
1142
|
+
async function Wn(t) {
|
|
1229
1143
|
return new Promise((n) => {
|
|
1230
|
-
const r = new
|
|
1144
|
+
const r = new ot(Bn, {
|
|
1231
1145
|
workerData: {
|
|
1232
|
-
absolutePath:
|
|
1146
|
+
absolutePath: t
|
|
1233
1147
|
}
|
|
1234
1148
|
});
|
|
1235
|
-
r.once("message", (
|
|
1236
|
-
n(
|
|
1237
|
-
}), r.once("error", (
|
|
1238
|
-
console.error(
|
|
1149
|
+
r.once("message", (e) => {
|
|
1150
|
+
n(e);
|
|
1151
|
+
}), r.once("error", (e) => {
|
|
1152
|
+
console.error(e), n(void 0);
|
|
1239
1153
|
});
|
|
1240
1154
|
});
|
|
1241
1155
|
}
|
|
1242
|
-
async function
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
switch ((await X(n))?.type) {
|
|
1247
|
-
case "module":
|
|
1248
|
-
return "es";
|
|
1249
|
-
case "commonjs":
|
|
1250
|
-
return "cjs";
|
|
1251
|
-
default:
|
|
1252
|
-
return "cjs";
|
|
1253
|
-
}
|
|
1156
|
+
async function qn(t) {
|
|
1157
|
+
console.error(
|
|
1158
|
+
"Ts module type embeddedOverrides has not been implemented yet."
|
|
1159
|
+
);
|
|
1254
1160
|
}
|
|
1255
|
-
const
|
|
1256
|
-
async (
|
|
1257
|
-
if (
|
|
1258
|
-
return
|
|
1259
|
-
const r = await
|
|
1260
|
-
let
|
|
1261
|
-
return typeof r != "string" ?
|
|
1161
|
+
const Kn = Ue(
|
|
1162
|
+
async (t, n) => {
|
|
1163
|
+
if (tt(t))
|
|
1164
|
+
return t;
|
|
1165
|
+
const r = await it(n);
|
|
1166
|
+
let e;
|
|
1167
|
+
return typeof r != "string" ? e = process.env.PWD ?? process.cwd() : e = nt(r), rt(e, t);
|
|
1262
1168
|
}
|
|
1263
|
-
),
|
|
1264
|
-
const r =
|
|
1265
|
-
|
|
1169
|
+
), Un = async (t, n) => {
|
|
1170
|
+
const r = Kn(
|
|
1171
|
+
t,
|
|
1266
1172
|
n
|
|
1267
|
-
),
|
|
1268
|
-
if (
|
|
1269
|
-
const
|
|
1270
|
-
if (
|
|
1271
|
-
return
|
|
1272
|
-
console.error(`Failed to parse the json file: ${
|
|
1173
|
+
), e = st(t);
|
|
1174
|
+
if (e === ".json") {
|
|
1175
|
+
const s = await r, o = await De(s);
|
|
1176
|
+
if (o !== void 0)
|
|
1177
|
+
return o;
|
|
1178
|
+
console.error(`Failed to parse the json file: ${s}`);
|
|
1273
1179
|
return;
|
|
1274
|
-
} else if (
|
|
1275
|
-
const
|
|
1276
|
-
if (
|
|
1277
|
-
return
|
|
1278
|
-
console.error(`Failed to parse the js module file: ${
|
|
1180
|
+
} else if (e === ".mjs" || e === ".cjs" || e === ".js") {
|
|
1181
|
+
const s = await r, o = await Wn(s);
|
|
1182
|
+
if (o !== void 0)
|
|
1183
|
+
return o;
|
|
1184
|
+
console.error(`Failed to parse the js module file: ${s}`);
|
|
1279
1185
|
return;
|
|
1280
|
-
} else if (
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1186
|
+
} else if (e === ".mts" || e === ".cts" || e === ".ts") {
|
|
1187
|
+
const s = await r, o = await qn();
|
|
1188
|
+
if (o !== void 0)
|
|
1189
|
+
return o;
|
|
1190
|
+
console.error(`Failed to parse the ts module file: ${s}`);
|
|
1191
|
+
return;
|
|
1192
|
+
} else if (e === "") {
|
|
1193
|
+
const s = await r, o = await De(s);
|
|
1194
|
+
if (o !== void 0)
|
|
1195
|
+
return o;
|
|
1288
1196
|
}
|
|
1289
1197
|
try {
|
|
1290
|
-
return JSON.parse(
|
|
1198
|
+
return JSON.parse(t);
|
|
1291
1199
|
} catch {
|
|
1292
1200
|
console.error("Failed to parse embeddedOverrides as a json object");
|
|
1293
1201
|
}
|
|
1294
|
-
},
|
|
1295
|
-
if (
|
|
1202
|
+
}, zn = async (t, n, r) => {
|
|
1203
|
+
if (t === void 0)
|
|
1296
1204
|
return;
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1205
|
+
const e = await Un(
|
|
1206
|
+
t,
|
|
1299
1207
|
r
|
|
1300
1208
|
);
|
|
1301
|
-
if (
|
|
1209
|
+
if (e !== void 0)
|
|
1302
1210
|
try {
|
|
1303
|
-
for (const { identifiers: s, options: o } of
|
|
1211
|
+
for (const { identifiers: s, options: o } of e)
|
|
1304
1212
|
if (s.includes(n))
|
|
1305
1213
|
return o;
|
|
1306
1214
|
} catch {
|
|
1307
1215
|
console.error("Error parsing embedded override options.");
|
|
1308
1216
|
}
|
|
1309
1217
|
};
|
|
1310
|
-
function
|
|
1311
|
-
if (r.length === 0 ||
|
|
1218
|
+
function Gn({ node: t, parent: n }, r, e) {
|
|
1219
|
+
if (r.length === 0 || t.type !== "TemplateLiteral")
|
|
1312
1220
|
return;
|
|
1313
|
-
const s =
|
|
1221
|
+
const s = t.comments ?? n?.comments;
|
|
1314
1222
|
if (!s)
|
|
1315
1223
|
return;
|
|
1316
1224
|
const o = s[s.length - 1];
|
|
@@ -1322,52 +1230,52 @@ function rr({ node: e, parent: n }, r, t) {
|
|
|
1322
1230
|
"CommentBlock"
|
|
1323
1231
|
// babel, babel-flow, babel-ts
|
|
1324
1232
|
].includes(o.type) || !o.leading)) {
|
|
1325
|
-
for (const
|
|
1326
|
-
if (` ${
|
|
1327
|
-
return
|
|
1233
|
+
for (const a of r)
|
|
1234
|
+
if (` ${a} ` === o.value && !e.includes(a))
|
|
1235
|
+
return a;
|
|
1328
1236
|
}
|
|
1329
1237
|
}
|
|
1330
|
-
function
|
|
1331
|
-
if (r.length !== 0 && !(
|
|
1238
|
+
function Hn({ node: t, parent: n }, r, e) {
|
|
1239
|
+
if (r.length !== 0 && !(t.type !== "TemplateLiteral" || n?.type !== "TaggedTemplateExpression" || n.tag.type !== "Identifier")) {
|
|
1332
1240
|
for (const s of r)
|
|
1333
|
-
if (n.tag.name === s && !
|
|
1241
|
+
if (n.tag.name === s && !e.includes(s))
|
|
1334
1242
|
return s;
|
|
1335
1243
|
}
|
|
1336
1244
|
}
|
|
1337
|
-
const { estree:
|
|
1338
|
-
const { node: r } =
|
|
1339
|
-
if (r.type !== "TemplateLiteral" || r.quasis.some(({ value: { cooked:
|
|
1245
|
+
const { estree: ze } = Ze, Xn = function(t, n) {
|
|
1246
|
+
const { node: r } = t;
|
|
1247
|
+
if (r.type !== "TemplateLiteral" || r.quasis.some(({ value: { cooked: e } }) => e === null))
|
|
1340
1248
|
return null;
|
|
1341
|
-
for (const
|
|
1342
|
-
const s = n[I(
|
|
1249
|
+
for (const e of Be) {
|
|
1250
|
+
const s = n[I(e)];
|
|
1343
1251
|
if (!s)
|
|
1344
1252
|
continue;
|
|
1345
|
-
const o =
|
|
1346
|
-
|
|
1253
|
+
const o = Gn(
|
|
1254
|
+
t,
|
|
1347
1255
|
s,
|
|
1348
1256
|
n.noEmbeddedIdentificationByComment ?? []
|
|
1349
|
-
) ??
|
|
1350
|
-
|
|
1257
|
+
) ?? Hn(
|
|
1258
|
+
t,
|
|
1351
1259
|
s,
|
|
1352
1260
|
n.noEmbeddedIdentificationByTag ?? []
|
|
1353
1261
|
);
|
|
1354
1262
|
if (o === void 0)
|
|
1355
1263
|
continue;
|
|
1356
|
-
const
|
|
1357
|
-
if (!
|
|
1264
|
+
const a = qe[e];
|
|
1265
|
+
if (!a)
|
|
1358
1266
|
return null;
|
|
1359
|
-
const
|
|
1360
|
-
return
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1267
|
+
const i = t.node;
|
|
1268
|
+
return i.quasis.length === 1 && i.quasis[0].value.raw.trim() === "" ? "``" : async (c, l, p, u) => {
|
|
1269
|
+
const v = await zn(
|
|
1270
|
+
u.embeddedOverrides,
|
|
1363
1271
|
o,
|
|
1364
|
-
|
|
1272
|
+
u.filepath
|
|
1365
1273
|
);
|
|
1366
1274
|
try {
|
|
1367
|
-
const b = await
|
|
1275
|
+
const b = await a(c, l, p, u, {
|
|
1368
1276
|
identifier: o,
|
|
1369
1277
|
identifiers: s,
|
|
1370
|
-
embeddedOverrideOptions:
|
|
1278
|
+
embeddedOverrideOptions: v
|
|
1371
1279
|
});
|
|
1372
1280
|
return $.label(
|
|
1373
1281
|
{ embed: !0, ...b.label },
|
|
@@ -1378,20 +1286,20 @@ const { estree: Qe } = it, or = function(e, n) {
|
|
|
1378
1286
|
}
|
|
1379
1287
|
};
|
|
1380
1288
|
}
|
|
1381
|
-
return
|
|
1382
|
-
},
|
|
1289
|
+
return ze.embed?.(t, n) ?? null;
|
|
1290
|
+
}, dr = {
|
|
1383
1291
|
estree: {
|
|
1384
|
-
...
|
|
1385
|
-
embed:
|
|
1292
|
+
...ze,
|
|
1293
|
+
embed: Xn
|
|
1386
1294
|
}
|
|
1387
1295
|
};
|
|
1388
1296
|
export {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1297
|
+
qe as embeddedEmbedders,
|
|
1298
|
+
Be as embeddedLanguages,
|
|
1299
|
+
Ke as embeddedOptions,
|
|
1300
|
+
We as embeddedParsers,
|
|
1393
1301
|
I as makeIdentifiersOptionName,
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1302
|
+
ir as options,
|
|
1303
|
+
ar as parsers,
|
|
1304
|
+
dr as printers
|
|
1397
1305
|
};
|