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