prettier-plugin-embed 0.0.5 → 0.1.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.
Files changed (48) hide show
  1. package/README.md +183 -3
  2. package/dist/embedded/es/embedded-language.d.ts +6 -0
  3. package/dist/embedded/es/embedder.d.ts +9 -0
  4. package/dist/embedded/es/index.d.ts +3 -0
  5. package/dist/embedded/es/options.d.ts +44 -0
  6. package/dist/embedded/html/embedded-language.d.ts +6 -0
  7. package/dist/embedded/html/embedder.d.ts +9 -0
  8. package/dist/embedded/html/index.d.ts +3 -0
  9. package/dist/embedded/html/options.d.ts +33 -0
  10. package/dist/embedded/index.d.ts +1 -1
  11. package/dist/embedded/noop/embedded-language.d.ts +6 -0
  12. package/dist/embedded/noop/index.d.ts +2 -2
  13. package/dist/embedded/noop/options.d.ts +21 -0
  14. package/dist/embedded/php/embedded-language.d.ts +6 -0
  15. package/dist/embedded/php/embedder.d.ts +2 -2
  16. package/dist/embedded/php/index.d.ts +2 -2
  17. package/dist/embedded/php/options.d.ts +36 -0
  18. package/dist/embedded/register.d.ts +9 -6
  19. package/dist/embedded/sql/embedded-language.d.ts +6 -0
  20. package/dist/embedded/sql/embedder.d.ts +2 -2
  21. package/dist/embedded/sql/index.d.ts +2 -2
  22. package/dist/embedded/sql/options.d.ts +35 -0
  23. package/dist/embedded/ts/embedded-language.d.ts +6 -0
  24. package/dist/embedded/ts/embedder.d.ts +9 -0
  25. package/dist/embedded/ts/index.d.ts +3 -0
  26. package/dist/embedded/ts/options.d.ts +44 -0
  27. package/dist/embedded/types.d.ts +10 -9
  28. package/dist/embedded/utils.d.ts +15 -4
  29. package/dist/embedded/xml/embedded-language.d.ts +6 -0
  30. package/dist/embedded/xml/embedder.d.ts +3 -3
  31. package/dist/embedded/xml/index.d.ts +2 -2
  32. package/dist/embedded/xml/options.d.ts +47 -0
  33. package/dist/embedded/xml/parser.d.ts +3 -5
  34. package/dist/index.js +908 -336
  35. package/dist/options.d.ts +135 -5
  36. package/dist/parsers.d.ts +1 -0
  37. package/dist/prettier-plugin-embed-wide-dark.svg +309 -0
  38. package/dist/prettier-plugin-embed-wide-light.svg +309 -0
  39. package/dist/types.d.ts +1 -1
  40. package/package.json +17 -13
  41. package/dist/embedded/noop/name.d.ts +0 -6
  42. package/dist/embedded/noop/option.d.ts +0 -11
  43. package/dist/embedded/php/name.d.ts +0 -6
  44. package/dist/embedded/php/option.d.ts +0 -20
  45. package/dist/embedded/sql/name.d.ts +0 -6
  46. package/dist/embedded/sql/option.d.ts +0 -21
  47. package/dist/embedded/xml/name.d.ts +0 -6
  48. package/dist/embedded/xml/option.d.ts +0 -21
package/dist/index.js CHANGED
@@ -1,146 +1,463 @@
1
- import Q from "prettier/parser-babel";
2
- import U from "prettier/parser-espree";
3
- import X from "prettier/parser-flow";
4
- import H from "prettier/parser-typescript";
5
- import { builders as q, utils as T } from "prettier/doc";
6
- import { parse as V } from "@xml-tools/parser";
7
- import { printers as J } from "prettier/plugins/estree.mjs";
8
- const P = "embeddedNoop", K = {
9
- category: "Global",
10
- type: "string",
11
- array: !0,
12
- default: [{ value: [] }],
13
- description: "Specify embedded languages that will not be formatted."
14
- }, Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
15
- __proto__: null,
16
- name: P,
17
- option: K
18
- }, Symbol.toStringTag, { value: "Module" })), Z = "embeddedPhp", { group: ee, indent: te, softline: j, lineSuffixBoundary: ne } = q;
19
- function re(e, t) {
20
- var r;
21
- const { node: n } = e;
22
- let o = t();
23
- return (r = n == null ? void 0 : n.comments) != null && r.length && (o = ee([te([j, o]), j])), ["${", o, ne, "}"];
1
+ import Me from "prettier/parser-babel";
2
+ import je from "prettier/parser-espree";
3
+ import Be from "prettier/parser-flow";
4
+ import Fe from "prettier/parser-typescript";
5
+ import Ne from "prettier/parser-meriyah";
6
+ import { utils as Y, builders as M } from "prettier/doc";
7
+ import { parse as ke } from "@xml-tools/parser";
8
+ import { printers as Re } from "prettier/plugins/estree.mjs";
9
+ const Ie = "embeddedEs";
10
+ function Ce(e) {
11
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
12
+ }
13
+ var ve = { exports: {} };
14
+ (function(e) {
15
+ var n = (() => {
16
+ var s = Object.defineProperty, t = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, a = Object.getOwnPropertySymbols, h = Object.prototype.hasOwnProperty, p = Object.prototype.propertyIsEnumerable, c = (u, l, d) => l in u ? s(u, l, { enumerable: !0, configurable: !0, writable: !0, value: d }) : u[l] = d, x = (u, l) => {
17
+ for (var d in l || (l = {}))
18
+ h.call(l, d) && c(u, d, l[d]);
19
+ if (a)
20
+ for (var d of a(l))
21
+ p.call(l, d) && c(u, d, l[d]);
22
+ return u;
23
+ }, g = (u, l) => {
24
+ for (var d in l)
25
+ s(u, d, { get: l[d], enumerable: !0 });
26
+ }, D = (u, l, d, y) => {
27
+ if (l && typeof l == "object" || typeof l == "function")
28
+ for (let m of i(l))
29
+ !h.call(u, m) && m !== d && s(u, m, { get: () => l[m], enumerable: !(y = t(l, m)) || y.enumerable });
30
+ return u;
31
+ }, L = (u) => D(s({}, "__esModule", { value: !0 }), u), r = (u, l, d) => (c(u, typeof l != "symbol" ? l + "" : l, d), d), E = {};
32
+ g(E, {
33
+ DEFAULT_OPTIONS: () => T,
34
+ DEFAULT_UUID_LENGTH: () => w,
35
+ default: () => v
36
+ });
37
+ var I = "5.0.3", w = 6, T = {
38
+ dictionary: "alphanum",
39
+ shuffle: !0,
40
+ debug: !1,
41
+ length: w,
42
+ counter: 0
43
+ }, b = class {
44
+ constructor(l = {}) {
45
+ r(this, "counter"), r(this, "debug"), r(this, "dict"), r(this, "version"), r(this, "dictIndex", 0), r(this, "dictRange", []), r(this, "lowerBound", 0), r(this, "upperBound", 0), r(this, "dictLength", 0), r(this, "uuidLength"), r(this, "_digit_first_ascii", 48), r(this, "_digit_last_ascii", 58), r(this, "_alpha_lower_first_ascii", 97), r(this, "_alpha_lower_last_ascii", 123), r(this, "_hex_last_ascii", 103), r(this, "_alpha_upper_first_ascii", 65), r(this, "_alpha_upper_last_ascii", 91), r(this, "_number_dict_ranges", {
46
+ digits: [this._digit_first_ascii, this._digit_last_ascii]
47
+ }), r(this, "_alpha_dict_ranges", {
48
+ lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
49
+ upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
50
+ }), r(this, "_alpha_lower_dict_ranges", {
51
+ lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
52
+ }), r(this, "_alpha_upper_dict_ranges", {
53
+ upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
54
+ }), r(this, "_alphanum_dict_ranges", {
55
+ digits: [this._digit_first_ascii, this._digit_last_ascii],
56
+ lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
57
+ upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
58
+ }), r(this, "_alphanum_lower_dict_ranges", {
59
+ digits: [this._digit_first_ascii, this._digit_last_ascii],
60
+ lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
61
+ }), r(this, "_alphanum_upper_dict_ranges", {
62
+ digits: [this._digit_first_ascii, this._digit_last_ascii],
63
+ upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
64
+ }), r(this, "_hex_dict_ranges", {
65
+ decDigits: [this._digit_first_ascii, this._digit_last_ascii],
66
+ alphaDigits: [this._alpha_lower_first_ascii, this._hex_last_ascii]
67
+ }), r(this, "_dict_ranges", {
68
+ _number_dict_ranges: this._number_dict_ranges,
69
+ _alpha_dict_ranges: this._alpha_dict_ranges,
70
+ _alpha_lower_dict_ranges: this._alpha_lower_dict_ranges,
71
+ _alpha_upper_dict_ranges: this._alpha_upper_dict_ranges,
72
+ _alphanum_dict_ranges: this._alphanum_dict_ranges,
73
+ _alphanum_lower_dict_ranges: this._alphanum_lower_dict_ranges,
74
+ _alphanum_upper_dict_ranges: this._alphanum_upper_dict_ranges,
75
+ _hex_dict_ranges: this._hex_dict_ranges
76
+ }), r(this, "log", (...o) => {
77
+ const _ = [...o];
78
+ if (_[0] = `[short-unique-id] ${o[0]}`, this.debug === !0 && typeof console < "u" && console !== null)
79
+ return console.log(..._);
80
+ }), r(this, "setDictionary", (o, _) => {
81
+ let f;
82
+ if (o && Array.isArray(o) && o.length > 1)
83
+ f = o;
84
+ else {
85
+ f = [];
86
+ let S;
87
+ this.dictIndex = S = 0;
88
+ const q = `_${o}_dict_ranges`, O = this._dict_ranges[q];
89
+ Object.keys(O).forEach((P) => {
90
+ const z = P;
91
+ for (this.dictRange = O[z], this.lowerBound = this.dictRange[0], this.upperBound = this.dictRange[1], this.dictIndex = S = this.lowerBound; this.lowerBound <= this.upperBound ? S < this.upperBound : S > this.upperBound; this.dictIndex = this.lowerBound <= this.upperBound ? S += 1 : S -= 1)
92
+ f.push(String.fromCharCode(this.dictIndex));
93
+ });
94
+ }
95
+ _ && (f = f.sort(() => Math.random() - 0.5)), this.dict = f, this.dictLength = this.dict.length, this.setCounter(0);
96
+ }), r(this, "seq", () => this.sequentialUUID()), r(this, "sequentialUUID", () => {
97
+ let o, _, f = "";
98
+ o = this.counter;
99
+ do
100
+ _ = o % this.dictLength, o = Math.trunc(o / this.dictLength), f += this.dict[_];
101
+ while (o !== 0);
102
+ return this.counter += 1, f;
103
+ }), r(this, "rnd", (o = this.uuidLength || w) => this.randomUUID(o)), r(this, "randomUUID", (o = this.uuidLength || w) => {
104
+ let _, f, S;
105
+ if (o === null || typeof o > "u" || o < 1)
106
+ throw new Error("Invalid UUID Length Provided");
107
+ for (_ = "", S = 0; S < o; S += 1)
108
+ f = parseInt(
109
+ (Math.random() * this.dictLength).toFixed(0),
110
+ 10
111
+ ) % this.dictLength, _ += this.dict[f];
112
+ return _;
113
+ }), r(this, "fmt", (o, _) => this.formattedUUID(o, _)), r(this, "formattedUUID", (o, _) => {
114
+ const f = {
115
+ $r: this.randomUUID,
116
+ $s: this.sequentialUUID,
117
+ $t: this.stamp
118
+ };
119
+ return o.replace(
120
+ /\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
121
+ (q) => {
122
+ const O = q.slice(0, 2), P = parseInt(q.slice(2), 10);
123
+ return O === "$s" ? f[O]().padStart(P, "0") : O === "$t" && _ ? f[O](P, _) : f[O](P);
124
+ }
125
+ );
126
+ }), r(this, "availableUUIDs", (o = this.uuidLength) => parseFloat(
127
+ Math.pow([...new Set(this.dict)].length, o).toFixed(0)
128
+ )), r(this, "approxMaxBeforeCollision", (o = this.availableUUIDs(this.uuidLength)) => parseFloat(
129
+ Math.sqrt(Math.PI / 2 * o).toFixed(20)
130
+ )), r(this, "collisionProbability", (o = this.availableUUIDs(this.uuidLength), _ = this.uuidLength) => parseFloat(
131
+ (this.approxMaxBeforeCollision(o) / this.availableUUIDs(_)).toFixed(20)
132
+ )), r(this, "uniqueness", (o = this.availableUUIDs(this.uuidLength)) => {
133
+ const _ = parseFloat(
134
+ (1 - this.approxMaxBeforeCollision(o) / o).toFixed(20)
135
+ );
136
+ return _ > 1 ? 1 : _ < 0 ? 0 : _;
137
+ }), r(this, "getVersion", () => this.version), r(this, "stamp", (o, _) => {
138
+ const f = Math.floor(+(_ || /* @__PURE__ */ new Date()) / 1e3).toString(16);
139
+ if (typeof o == "number" && o === 0)
140
+ return f;
141
+ if (typeof o != "number" || o < 10)
142
+ throw new Error(
143
+ [
144
+ "Param finalLength must be a number greater than or equal to 10,",
145
+ "or 0 if you want the raw hexadecimal timestamp"
146
+ ].join(`
147
+ `)
148
+ );
149
+ const S = o - 9, q = Math.round(Math.random() * (S > 15 ? 15 : S)), O = this.randomUUID(S);
150
+ return `${O.substring(0, q)}${f}${O.substring(q)}${q.toString(16)}`;
151
+ }), r(this, "parseStamp", (o, _) => {
152
+ if (_ && !/t0|t[1-9]\d{1,}/.test(_))
153
+ throw new Error("Cannot extract date from a formated UUID with no timestamp in the format");
154
+ const f = _ ? _.replace(
155
+ /\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
156
+ (q) => {
157
+ const O = {
158
+ $r: (W) => [...Array(W)].map(() => "r").join(""),
159
+ $s: (W) => [...Array(W)].map(() => "s").join(""),
160
+ $t: (W) => [...Array(W)].map(() => "t").join("")
161
+ }, P = q.slice(0, 2), z = parseInt(q.slice(2), 10);
162
+ return O[P](z);
163
+ }
164
+ ).replace(
165
+ /^(.*?)(t{8,})(.*)$/g,
166
+ (q, O, P) => o.substring(O.length, O.length + P.length)
167
+ ) : o;
168
+ if (f.length === 8)
169
+ return new Date(parseInt(f, 16) * 1e3);
170
+ if (f.length < 10)
171
+ throw new Error("Stamp length invalid");
172
+ const S = parseInt(f.substring(f.length - 1), 16);
173
+ return new Date(parseInt(f.substring(S, S + 8), 16) * 1e3);
174
+ }), r(this, "setCounter", (o) => {
175
+ this.counter = o;
176
+ });
177
+ const d = x(x({}, T), l);
178
+ this.counter = 0, this.debug = !1, this.dict = [], this.version = I;
179
+ const {
180
+ dictionary: y,
181
+ shuffle: m,
182
+ length: $,
183
+ counter: U
184
+ } = d;
185
+ return this.uuidLength = $, this.setDictionary(y, m), this.setCounter(U), this.debug = d.debug, this.log(this.dict), this.log(
186
+ `Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`
187
+ ), this.log = this.log.bind(this), this.setDictionary = this.setDictionary.bind(this), this.setCounter = this.setCounter.bind(this), this.seq = this.seq.bind(this), this.sequentialUUID = this.sequentialUUID.bind(this), this.rnd = this.rnd.bind(this), this.randomUUID = this.randomUUID.bind(this), this.fmt = this.fmt.bind(this), this.formattedUUID = this.formattedUUID.bind(this), this.availableUUIDs = this.availableUUIDs.bind(this), this.approxMaxBeforeCollision = this.approxMaxBeforeCollision.bind(this), this.collisionProbability = this.collisionProbability.bind(this), this.uniqueness = this.uniqueness.bind(this), this.getVersion = this.getVersion.bind(this), this.stamp = this.stamp.bind(this), this.parseStamp = this.parseStamp.bind(this), this;
188
+ }
189
+ };
190
+ r(b, "default", b);
191
+ var v = b;
192
+ return L(E);
193
+ })();
194
+ e.exports = n.default, typeof window < "u" && (n = n.default);
195
+ })(ve);
196
+ var Ae = ve.exports;
197
+ const We = /* @__PURE__ */ Ce(Ae), { group: Ge, indent: Xe, softline: ee, lineSuffixBoundary: ze } = M, { mapDoc: He } = Y;
198
+ function Ve(e, n) {
199
+ var i;
200
+ const { node: s } = e;
201
+ let t = n();
202
+ return (i = s == null ? void 0 : s.comments) != null && i.length && (t = Ge([Xe([ee, t]), ee])), ["${", t, ze, "}"];
24
203
  }
25
- function D(e, t) {
204
+ function C(e, n) {
26
205
  return e.map(
27
- (n) => re(n, t),
206
+ (s) => Ve(s, n),
28
207
  "expressions"
29
208
  );
30
209
  }
31
- function N(e, t, n) {
32
- var o;
33
- if (!(((o = t.plugins) == null ? void 0 : o.some(
34
- (r) => {
35
- var s;
36
- return ((s = r.name) == null ? void 0 : s.includes(e)) ?? !1;
210
+ function X(e, n, s) {
211
+ return He(e, (i) => {
212
+ if (typeof i != "string")
213
+ return i;
214
+ const a = [], h = i.split(n);
215
+ for (let p = 0; p < h.length; p++) {
216
+ let c = h[p];
217
+ if (p % 2 == 0) {
218
+ if (!c)
219
+ continue;
220
+ c = c.replaceAll(/([\\`]|\${)/g, "\\$1"), a.push(c);
221
+ } else {
222
+ const x = Number(c);
223
+ a.push(s[x]);
224
+ }
225
+ }
226
+ return a;
227
+ });
228
+ }
229
+ function Q(e, n, s) {
230
+ var t;
231
+ if (!(((t = n.plugins) == null ? void 0 : t.some(
232
+ (i) => {
233
+ var a;
234
+ return ((a = i.name) == null ? void 0 : a.includes(e)) ?? !1;
37
235
  }
38
236
  )) ?? !1))
39
237
  throw new Error(
40
- `Cannot format embedded language "${n}" because plugin "${e}" is not loaded.`
238
+ `Cannot format embedded language identified by "${s}", because plugin "${e}" is not loaded.`
41
239
  );
42
240
  }
43
- function oe(e, t, n) {
44
- if (t === n) {
45
- e.unshift(t);
241
+ function Ye(e, n, s) {
242
+ if (n === s) {
243
+ e.unshift(n);
46
244
  return;
47
245
  }
48
- let o = 0, r = e.length;
49
- for (; o < r; ) {
50
- const s = o + r >>> 1;
51
- if (e[s] === n) {
52
- e.push(t);
246
+ let t = 0, i = e.length;
247
+ for (; t < i; ) {
248
+ const a = t + i >>> 1;
249
+ if (e[a] === s) {
250
+ e.push(n);
53
251
  return;
54
252
  }
55
- e[s] < t ? o = s + 1 : r = s;
253
+ e[a] < n ? t = a + 1 : i = a;
56
254
  }
57
- e.splice(o, 0, t);
255
+ e.splice(t, 0, n);
256
+ }
257
+ const { randomUUID: te } = new We({
258
+ length: 16,
259
+ dictionary: "alphanum_lower"
260
+ });
261
+ function A(e = "p", n = "") {
262
+ const s = te(), t = te(), i = ne(e), a = ne(n), h = (c) => `${e}${s}${c}${t}${n}`, p = new RegExp(
263
+ `${i}${s}(\\d+)${t}${a}`,
264
+ "g"
265
+ );
266
+ return {
267
+ createPlaceholder: h,
268
+ placeholderRegex: p
269
+ };
58
270
  }
59
- function k() {
60
- function e(n) {
61
- return t(Math.random() * (1 << (n << 2)) ^ Date.now()).slice(-n);
271
+ function ne(e) {
272
+ return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
273
+ }
274
+ const { line: se, group: j, indent: ie, softline: re } = M, Qe = async (e, n, s, t, i) => {
275
+ var a, h, p, c, x;
276
+ try {
277
+ const { node: g } = s, { createPlaceholder: D, placeholderRegex: L } = A(), r = g.quasis.map(
278
+ (l, d, { length: y }) => d === y - 1 ? l.value.cooked : l.value.cooked + D(d)
279
+ ).join(""), E = ((a = r.match(/^\s+/)) == null ? void 0 : a[0]) ?? "", I = ((h = r.match(/\s+$/)) == null ? void 0 : h[0]) ?? "", w = C(s, n), T = await e(r, {
280
+ parser: t.embeddedEsParser ?? "babel"
281
+ }), b = X(
282
+ T,
283
+ L,
284
+ w
285
+ );
286
+ if ((p = t.preserveEmbeddedExteriorWhitespaces) != null && p.includes(i))
287
+ return j([
288
+ "`",
289
+ E,
290
+ (c = t.noEmbeddedMultiLineIndentation) != null && c.includes(i) ? [j(b)] : ie([j(b)]),
291
+ I,
292
+ "`"
293
+ ]);
294
+ const v = E.length ? se : re, u = I.length ? se : re;
295
+ return j([
296
+ "`",
297
+ (x = t.noEmbeddedMultiLineIndentation) != null && x.includes(i) ? [v, j(b)] : ie([v, j(b)]),
298
+ u,
299
+ "`"
300
+ ]);
301
+ } catch (g) {
302
+ throw console.error(g), g;
62
303
  }
63
- function t(n) {
64
- return (n | 0).toString(16);
304
+ }, Je = [
305
+ "js",
306
+ "es",
307
+ "es6",
308
+ "mjs",
309
+ "cjs",
310
+ "pac",
311
+ "javascript"
312
+ ], Ke = "embeddedEsParser", Ze = {
313
+ [Ie]: {
314
+ category: "Global",
315
+ type: "string",
316
+ array: !0,
317
+ default: [{ value: [...Je] }],
318
+ description: "Specify embedded ES languages."
319
+ },
320
+ [Ke]: {
321
+ category: "Global",
322
+ type: "string",
323
+ array: !1,
324
+ default: "babel",
325
+ description: "Specify the parser for the embedded ES languages."
65
326
  }
66
- return [
67
- e(4) + e(4),
68
- e(4),
69
- "4" + e(3),
70
- // UUID version 4
71
- t(8 | Math.random() * 4) + e(3),
72
- // {8|9|A|B}xxx
73
- // s(4) + s(4) + s(4),
74
- Date.now().toString(16).slice(-10) + e(2)
75
- // Use timestamp to avoid collisions
76
- ].join("-");
77
- }
78
- const { label: se, hardline: ie, line: le, group: E, indent: ae } = q, { mapDoc: ce } = T, ue = async (e, t, n, o, r) => {
327
+ }, et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
328
+ __proto__: null,
329
+ embeddedLanguage: Ie,
330
+ embedder: Qe,
331
+ options: Ze
332
+ }, Symbol.toStringTag, { value: "Module" })), $e = "embeddedHtml", { line: oe, group: B, indent: ae, softline: le } = M, { mapDoc: tt } = Y, nt = async (e, n, s, t, i) => {
333
+ var a, h, p, c, x;
79
334
  try {
80
- N("@prettier/plugin-php", o, r);
81
- const s = "$p" + k().replaceAll("-", ""), { node: a } = n, g = a.quasis.map(
82
- (i, l, { length: p }) => l === p - 1 ? i.value.cooked : i.value.cooked + `${s}${l}`
83
- ).join("");
84
- let u = "", b = 0;
85
- const f = /^\s+/.exec(g);
86
- f && (b = f.index + f[0].length, u = " ");
87
- const $ = /\s$/.test(g) ? " " : "", _ = D(n, t), v = await e(g.slice(b), {
88
- parser: "php"
89
- });
90
- let h = !1;
91
- const y = ce(v, (i) => {
92
- if (typeof i != "string")
93
- return Array.isArray(i) || (i.type === "group" && i.break || i.type === "line" && (i.hard || i.literal)) && (h = !0), i;
94
- const l = [], p = i.split(new RegExp("\\" + s + "(\\d+)", "g"));
95
- for (let c = 0; c < p.length; c++) {
96
- let m = p[c];
97
- if (c % 2 == 0) {
98
- if (!m)
335
+ const { node: g } = s, { createPlaceholder: D, placeholderRegex: L } = A(), r = g.quasis.map(
336
+ (l, d, { length: y }) => d === y - 1 ? l.value.cooked : l.value.cooked + D(d)
337
+ ).join(""), E = ((a = r.match(/^\s+/)) == null ? void 0 : a[0]) ?? "", I = ((h = r.match(/\s+$/)) == null ? void 0 : h[0]) ?? "", w = C(s, n), T = await e(r, {
338
+ parser: "html"
339
+ }), b = tt(T, (l) => {
340
+ if (typeof l != "string")
341
+ return l;
342
+ const d = [], y = l.split(L);
343
+ for (let m = 0; m < y.length; m++) {
344
+ let $ = y[m];
345
+ if (m % 2 == 0) {
346
+ if (!$)
99
347
  continue;
100
- m = m.replaceAll(/([\\`]|\${)/g, "\\$1"), l.push(m);
348
+ $ = $.replaceAll(/([\\`]|\${)/g, "\\$1"), t.__embeddedInHtml && ($ = $.replaceAll(/<\/(?=script\b)/gi, "<\\/")), d.push($);
101
349
  } else {
102
- const x = Number(m);
103
- l.push(_[x]);
350
+ const U = Number($);
351
+ d.push(w[U]);
104
352
  }
105
353
  }
106
- return l;
107
- }), d = h ? ie : u && $ ? le : null;
108
- return d ? E([
354
+ return d;
355
+ });
356
+ if (t.htmlWhitespaceSensitivity === "strict" || // TODO: is css mode should be included here?
357
+ t.htmlWhitespaceSensitivity === "css" || (p = t.preserveEmbeddedExteriorWhitespaces) != null && p.includes(i))
358
+ return B([
359
+ "`",
360
+ E,
361
+ (c = t.noEmbeddedMultiLineIndentation) != null && c.includes(i) ? [B(b)] : ae([B(b)]),
362
+ I,
363
+ "`"
364
+ ]);
365
+ const v = E.length ? oe : le, u = I.length ? oe : le;
366
+ return B([
109
367
  "`",
110
- ae([d, E(y)]),
111
- d,
368
+ (x = t.noEmbeddedMultiLineIndentation) != null && x.includes(i) ? [v, B(b)] : ae([v, B(b)]),
369
+ u,
112
370
  "`"
113
- ]) : se(
114
- { hug: !1 },
115
- E([
371
+ ]);
372
+ } catch (g) {
373
+ throw console.error(g), g;
374
+ }
375
+ }, st = [
376
+ "html",
377
+ "htm",
378
+ "shtml",
379
+ "xhtml",
380
+ "xht",
381
+ "mdoc",
382
+ "jsp",
383
+ "asp",
384
+ "aspx",
385
+ "jshtm",
386
+ "volt",
387
+ "rhtml"
388
+ ], it = {
389
+ [$e]: {
390
+ category: "Global",
391
+ type: "string",
392
+ array: !0,
393
+ default: [{ value: [...st] }],
394
+ description: "Specify embedded HTML languages."
395
+ }
396
+ }, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
397
+ __proto__: null,
398
+ embeddedLanguage: $e,
399
+ embedder: nt,
400
+ options: it
401
+ }, Symbol.toStringTag, { value: "Module" })), J = "embeddedNoop", ot = {
402
+ [J]: {
403
+ category: "Global",
404
+ type: "string",
405
+ array: !0,
406
+ default: [{ value: [] }],
407
+ description: "Specify embedded languages that will not be formatted."
408
+ }
409
+ }, at = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
410
+ __proto__: null,
411
+ embeddedLanguage: J,
412
+ options: ot
413
+ }, Symbol.toStringTag, { value: "Module" })), De = "embeddedPhp", { line: ce, group: F, indent: de, softline: ue } = M, lt = async (e, n, s, t, i) => {
414
+ var a, h, p, c, x;
415
+ try {
416
+ Q("@prettier/plugin-php", t, i);
417
+ const { node: g } = s, { createPlaceholder: D, placeholderRegex: L } = A("$p"), r = g.quasis.map(
418
+ (d, y, { length: m }) => y === m - 1 ? d.value.cooked : d.value.cooked + D(y)
419
+ ).join(""), E = ((a = r.match(/^\s+/)) == null ? void 0 : a[0]) ?? "", I = ((h = r.match(/\s+$/)) == null ? void 0 : h[0]) ?? "", w = r.slice(
420
+ E.length,
421
+ -I.length || void 0
422
+ ), T = C(s, n), b = await e(w, {
423
+ parser: "php"
424
+ }), v = X(
425
+ b,
426
+ L,
427
+ T
428
+ );
429
+ if ((p = t.preserveEmbeddedExteriorWhitespaces) != null && p.includes(i))
430
+ return F([
116
431
  "`",
117
- u,
118
- E([y]),
119
- $,
432
+ E,
433
+ (c = t.noEmbeddedMultiLineIndentation) != null && c.includes(i) ? [F(v)] : de([F(v)]),
434
+ I,
120
435
  "`"
121
- ])
122
- );
123
- } catch (s) {
124
- throw console.error(s), s;
436
+ ]);
437
+ const u = E.length ? ce : ue, l = I.length ? ce : ue;
438
+ return F([
439
+ "`",
440
+ (x = t.noEmbeddedMultiLineIndentation) != null && x.includes(i) ? [u, F(v)] : de([u, F(v)]),
441
+ l,
442
+ "`"
443
+ ]);
444
+ } catch (g) {
445
+ throw console.error(g), g;
125
446
  }
126
- }, de = {
127
- category: "Global",
128
- type: "string",
129
- array: !0,
130
- default: [{ value: ["php"] }],
131
- description: "Specify embedded PHP languages. This requires @prettier/plugin-php"
132
- }, pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
447
+ }, ct = ["php", "php5", "phtml", "ctp"], dt = {
448
+ [De]: {
449
+ category: "Global",
450
+ type: "string",
451
+ array: !0,
452
+ default: [{ value: [...ct] }],
453
+ description: "Specify embedded PHP languages. This requires @prettier/plugin-php"
454
+ }
455
+ }, ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
133
456
  __proto__: null,
134
- embedder: ue,
135
- name: Z,
136
- option: de
137
- }, Symbol.toStringTag, { value: "Module" })), fe = "embeddedSql", me = {
138
- category: "Global",
139
- type: "string",
140
- array: !0,
141
- default: [{ value: ["sql"] }],
142
- description: "Specify embedded SQL languages. This requires prettier-plugin-sql"
143
- }, C = [
457
+ embeddedLanguage: De,
458
+ embedder: lt,
459
+ options: dt
460
+ }, Symbol.toStringTag, { value: "Module" })), we = "embeddedSql", K = [
144
461
  "sql",
145
462
  "bigquery",
146
463
  "hive",
@@ -157,7 +474,7 @@ const { label: se, hardline: ie, line: le, group: E, indent: ae } = q, { mapDoc:
157
474
  "transactsql",
158
475
  "tsql",
159
476
  "trino"
160
- ], G = [
477
+ ], Se = [
161
478
  "bigquery",
162
479
  "db2",
163
480
  "hive",
@@ -166,132 +483,267 @@ const { label: se, hardline: ie, line: le, group: E, indent: ae } = q, { mapDoc:
166
483
  "postgresql",
167
484
  "transactsql",
168
485
  "flinksql"
169
- ], { label: ge, hardline: A, group: S, line: be, indent: he } = q, { mapDoc: ye } = T, $e = async (e, t, n, o, r, s) => {
486
+ ], ht = {
487
+ [we]: {
488
+ category: "Global",
489
+ type: "string",
490
+ array: !0,
491
+ default: [{ value: [...K] }],
492
+ description: "Specify embedded SQL languages. This requires prettier-plugin-sql"
493
+ }
494
+ }, { hardline: pt, group: N, line: he, softline: pe, indent: _e } = M, { mapDoc: _t } = Y, gt = async (e, n, s, t, i, a) => {
495
+ var h, p, c, x, g;
170
496
  try {
171
- N("prettier-plugin-sql", o, r);
172
- const a = "p" + k().replaceAll("-", ""), { node: g } = n, u = g.quasis.map(
173
- (i, l, { length: p }) => l === p - 1 ? i.value.cooked : i.value.cooked + `${a}${l}`
174
- ).join(""), b = /^\s/.test(u) ? " " : "", f = /\s$/.test(u) ? " " : "", $ = D(n, t), _ = xe(o, r, s);
175
- if (typeof _ > "u")
176
- throw new SyntaxError(`Unrecognized language: ${r}`);
177
- const v = await e(u, {
497
+ Q("prettier-plugin-sql", t, i);
498
+ const { node: D } = s, { createPlaceholder: L, placeholderRegex: r } = A(), E = D.quasis.map(
499
+ (y, m, { length: $ }) => m === $ - 1 ? y.value.cooked : y.value.cooked + L(m)
500
+ ).join(""), I = ((h = E.match(/^\s+/)) == null ? void 0 : h[0]) ?? "", w = ((p = E.match(/\s+$/)) == null ? void 0 : p[0]) ?? "", T = C(s, n), b = ft(
501
+ t,
502
+ i,
503
+ a
504
+ );
505
+ if (typeof b > "u")
506
+ throw new SyntaxError(`Unrecognized language: ${i}`);
507
+ const v = await e(E, {
178
508
  parser: "sql",
179
- ..._
180
- });
181
- let h = !1;
182
- const y = ye(v, (i) => {
183
- if (typeof i != "string")
184
- return i;
185
- const l = [], p = i.split(new RegExp(a + "(\\d+)", "g"));
186
- for (let c = 0; c < p.length; c++) {
187
- let m = p[c];
188
- if (c % 2 == 0) {
189
- if (!m)
509
+ ...b
510
+ }), u = _t(v, (y) => {
511
+ if (typeof y != "string")
512
+ return y;
513
+ const m = [], $ = y.split(r);
514
+ for (let U = 0; U < $.length; U++) {
515
+ let o = $[U];
516
+ if (U % 2 == 0) {
517
+ if (!o)
190
518
  continue;
191
- m = m.replaceAll(/([\\`]|\${)/g, "\\$1"), m.split(/(\n)/).forEach(
192
- (x) => x === `
193
- ` ? (h = !0, l.push(A)) : l.push(x)
519
+ o = o.replaceAll(/([\\`]|\${)/g, "\\$1"), o.split(/(\n)/).forEach(
520
+ (_) => _ === `
521
+ ` ? m.push(pt) : m.push(_)
194
522
  );
195
523
  } else {
196
- const x = Number(m);
197
- l.push($[x]);
524
+ const _ = Number(o);
525
+ m.push(T[_]);
198
526
  }
199
527
  }
200
- return l;
201
- }), d = h ? A : b && f ? be : null;
202
- return d ? S([
528
+ return m;
529
+ });
530
+ if ((c = t.preserveEmbeddedExteriorWhitespaces) != null && c.includes(i))
531
+ return N([
532
+ "`",
533
+ I,
534
+ (x = t.noEmbeddedMultiLineIndentation) != null && x.includes(i) ? [N(u)] : _e([N(u)]),
535
+ w,
536
+ "`"
537
+ ]);
538
+ const l = I.length ? he : pe, d = w.length ? he : pe;
539
+ return N([
203
540
  "`",
204
- he([d, S(y)]),
541
+ (g = t.noEmbeddedMultiLineIndentation) != null && g.includes(i) ? [l, N(u)] : _e([l, N(u)]),
205
542
  d,
206
543
  "`"
207
- ]) : ge(
208
- { hug: !1 },
209
- S([
210
- "`",
211
- b,
212
- S(y),
213
- f,
214
- "`"
215
- ])
216
- );
217
- } catch (a) {
218
- throw console.error(a), a;
544
+ ]);
545
+ } catch (D) {
546
+ throw console.error(D), D;
219
547
  }
220
- }, _e = {
221
- "sql-formatter": (e) => C.includes(e),
222
- "node-sql-parser": (e) => G.includes(e)
548
+ }, mt = {
549
+ "sql-formatter": (e) => K.includes(e),
550
+ "node-sql-parser": (e) => Se.includes(e)
223
551
  };
224
- function L(e, t) {
225
- for (const n of t)
226
- if (_e[n](e))
227
- return {
228
- formatter: n,
229
- language: e
230
- };
552
+ function ge(e, n) {
553
+ for (const s of n)
554
+ if (mt[s](e))
555
+ switch (s) {
556
+ case "sql-formatter":
557
+ return {
558
+ formatter: s,
559
+ language: e
560
+ };
561
+ case "node-sql-parser":
562
+ return {
563
+ formatter: s,
564
+ database: e
565
+ };
566
+ }
231
567
  }
232
- function B(e, t, n) {
233
- let o = L(e, n);
234
- if (o)
235
- return o;
236
- const r = t.indexOf(e);
237
- for (let s = r - 1; s >= 0; --s)
238
- if (o = L(t[s], n), o)
239
- return o;
568
+ function H(e, n, s) {
569
+ let t = ge(e, s);
570
+ if (t)
571
+ return t;
572
+ const i = n.indexOf(e);
573
+ for (let a = i - 1; a >= 0; --a)
574
+ if (t = ge(
575
+ n[a],
576
+ s
577
+ ), t)
578
+ return t;
240
579
  }
241
- function xe(e, t, n) {
242
- return e.formatter === "sql-formatter" ? B(t, n, [
243
- "sql-formatter",
244
- "node-sql-parser"
245
- ]) : B(t, n, [
246
- "node-sql-parser",
247
- "sql-formatter"
248
- ]);
580
+ function ft(e, n, s) {
581
+ switch (e.formatter ?? "sql-formatter") {
582
+ case "sql-formatter":
583
+ return H(
584
+ n,
585
+ s,
586
+ ["sql-formatter", "node-sql-parser"]
587
+ );
588
+ case "node-sql-parser":
589
+ return H(
590
+ n,
591
+ s,
592
+ ["node-sql-parser", "sql-formatter"]
593
+ );
594
+ default:
595
+ return H(
596
+ n,
597
+ s,
598
+ ["sql-formatter", "node-sql-parser"]
599
+ );
600
+ }
249
601
  }
250
- const ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
602
+ const bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
251
603
  __proto__: null,
252
- NODE_SQL_PARSER_DATABASES: G,
253
- SQL_FORMATTER_LANGUAGES: C,
254
- embedder: $e,
255
- name: fe,
256
- option: me
257
- }, Symbol.toStringTag, { value: "Module" })), I = "embeddedXml";
258
- function F(e, t) {
259
- const n = new SyntaxError(
260
- e + " (" + t.loc.start.line + ":" + t.loc.start.column + ")"
604
+ NODE_SQL_PARSER_DATABASES: Se,
605
+ SQL_FORMATTER_LANGUAGES: K,
606
+ embeddedLanguage: we,
607
+ embedder: gt,
608
+ options: ht
609
+ }, Symbol.toStringTag, { value: "Module" })), Oe = "embeddedTs", { line: me, group: k, indent: fe, softline: be } = M, yt = async (e, n, s, t, i) => {
610
+ var a, h, p, c, x;
611
+ try {
612
+ const { node: g } = s, { createPlaceholder: D, placeholderRegex: L } = A(), r = g.quasis.map(
613
+ (l, d, { length: y }) => d === y - 1 ? l.value.cooked : l.value.cooked + D(d)
614
+ ).join(""), E = ((a = r.match(/^\s+/)) == null ? void 0 : a[0]) ?? "", I = ((h = r.match(/\s+$/)) == null ? void 0 : h[0]) ?? "", w = C(s, n), T = await e(r, {
615
+ parser: t.embeddedTsParser ?? "typescript"
616
+ }), b = X(
617
+ T,
618
+ L,
619
+ w
620
+ );
621
+ if ((p = t.preserveEmbeddedExteriorWhitespaces) != null && p.includes(i))
622
+ return k([
623
+ "`",
624
+ E,
625
+ (c = t.noEmbeddedMultiLineIndentation) != null && c.includes(i) ? [k(b)] : fe([k(b)]),
626
+ I,
627
+ "`"
628
+ ]);
629
+ const v = E.length ? me : be, u = I.length ? me : be;
630
+ return k([
631
+ "`",
632
+ (x = t.noEmbeddedMultiLineIndentation) != null && x.includes(i) ? [v, k(b)] : fe([v, k(b)]),
633
+ u,
634
+ "`"
635
+ ]);
636
+ } catch (g) {
637
+ throw console.error(g), g;
638
+ }
639
+ }, xt = ["ts", "cts", "mts", "typescript"], Et = "embeddedTsParser", It = {
640
+ [Oe]: {
641
+ category: "Global",
642
+ type: "string",
643
+ array: !0,
644
+ default: [{ value: [...xt] }],
645
+ description: "Specify embedded TS languages."
646
+ },
647
+ [Et]: {
648
+ category: "Global",
649
+ type: "string",
650
+ array: !1,
651
+ default: "typescript",
652
+ description: "Specify the parser for the embedded TS languages."
653
+ }
654
+ }, vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
655
+ __proto__: null,
656
+ embeddedLanguage: Oe,
657
+ embedder: yt,
658
+ options: It
659
+ }, Symbol.toStringTag, { value: "Module" })), Z = "embeddedXml";
660
+ function $t(e) {
661
+ const n = {
662
+ loc: {
663
+ start: {
664
+ line: e.line,
665
+ column: e.column
666
+ },
667
+ end: {
668
+ line: e.line,
669
+ column: e.column + e.length
670
+ }
671
+ }
672
+ }, s = new SyntaxError(
673
+ `${e.message} (${n.loc.start.line}:${n.loc.start.column})`,
674
+ {
675
+ cause: e
676
+ }
261
677
  );
262
- return Object.assign(n, t);
678
+ return Object.assign(s, n), s;
263
679
  }
264
- const qe = {
265
- parse(e) {
266
- const { lexErrors: t, parseErrors: n, cst: o } = V(e);
680
+ function ye(e) {
681
+ const n = {
682
+ loc: {
683
+ start: {
684
+ line: e.token.startLine ?? NaN,
685
+ column: e.token.startColumn ?? NaN
686
+ },
687
+ end: {
688
+ line: e.token.endLine ?? NaN,
689
+ column: e.token.endColumn ?? NaN
690
+ }
691
+ }
692
+ }, s = new SyntaxError(
693
+ `${e.message} (${n.loc.start.line}:${n.loc.start.column})`,
694
+ {
695
+ cause: e
696
+ }
697
+ );
698
+ return Object.assign(s, n), s;
699
+ }
700
+ const Dt = {
701
+ parse(e, n) {
702
+ var a, h;
703
+ const { lexErrors: s, parseErrors: t, cst: i } = ke(e);
704
+ if (s.length > 0) {
705
+ const p = s[0];
706
+ throw $t(p);
707
+ }
267
708
  if (t.length > 0) {
268
- const r = t[0];
269
- throw F(r.message, {
270
- loc: {
271
- start: { line: r.line, column: r.column },
272
- end: {
273
- line: r.line,
274
- column: r.column + r.length
275
- }
709
+ let p = !1;
710
+ for (const c of t) {
711
+ if (!["MismatchedTokenException", "NotAllInputParsedException"].includes(
712
+ c.name
713
+ ))
714
+ throw ye(c);
715
+ if (c.message === "Expecting token of type --> OPEN <-- but found --> '' <--") {
716
+ p = !0;
717
+ continue;
276
718
  }
277
- });
278
- }
279
- if (n.length > 0) {
280
- const r = n[0];
281
- throw F(r.message, {
282
- loc: {
283
- start: {
284
- line: r.token.startLine ?? NaN,
285
- column: r.token.startColumn ?? NaN
286
- },
287
- end: {
288
- line: r.token.endLine ?? NaN,
289
- column: r.token.endColumn ?? NaN
290
- }
719
+ if (/Expecting token of type --> EOF <-- but found --> '.+' <--/.test(
720
+ c.message
721
+ ) || /Redundant input, expecting EOF but found: /.test(c.message)) {
722
+ (a = n.__embeddedXmlFragmentRecoverIndex) == null || a.splice(
723
+ 0,
724
+ n.__embeddedXmlFragmentRecoverIndex.length,
725
+ c.token.startOffset
726
+ );
727
+ break;
291
728
  }
292
- });
729
+ if (/Expecting token of type --> OPEN <-- but found --> '.+' <--/.test(
730
+ c.message
731
+ )) {
732
+ if (c.token.endOffset === void 0 || Number.isNaN(c.token.endOffset))
733
+ break;
734
+ (h = n.__embeddedXmlFragmentRecoverIndex) == null || h.splice(
735
+ 0,
736
+ n.__embeddedXmlFragmentRecoverIndex.length,
737
+ c.token.startOffset,
738
+ c.token.endOffset
739
+ ), p = !0;
740
+ break;
741
+ }
742
+ throw ye(c);
743
+ }
744
+ p && Te(i);
293
745
  }
294
- return o;
746
+ return i;
295
747
  },
296
748
  astFormat: "xml",
297
749
  locStart(e) {
@@ -300,160 +752,280 @@ const qe = {
300
752
  locEnd(e) {
301
753
  return e.location.endOffset ?? NaN;
302
754
  }
303
- }, { label: Ee, hardline: Se, line: we, group: w, indent: Oe } = q, { mapDoc: Te } = T, De = async (e, t, n, o, r) => {
304
- try {
305
- N("@prettier/plugin-xml", o, r);
306
- const s = k(), { node: a } = n, g = a.quasis.map(
307
- (d, i, { length: l }) => i === l - 1 ? d.value.cooked : d.value.cooked + `${s}-${i}`
308
- ).join("");
309
- let u = "", b = 0;
310
- const f = /^\s+/.exec(g);
311
- f && (b = f.index + f[0].length, u = " ");
312
- const $ = /\s$/.test(g) ? " " : "", _ = D(n, t), v = await e(g.slice(b), {
313
- parser: I
314
- }), h = Te(v, (d) => {
315
- if (typeof d != "string")
316
- return d;
317
- const i = [], l = d.split(new RegExp(s + "-(\\d+)", "g"));
318
- for (let p = 0; p < l.length; p++) {
319
- let c = l[p];
320
- if (p % 2 == 0) {
321
- if (!c)
322
- continue;
323
- c = c.replaceAll(/([\\`]|\${)/g, "\\$1"), i.push(c);
324
- } else {
325
- const m = Number(c);
326
- i.push(_[m]);
755
+ };
756
+ function Te(e) {
757
+ const n = e.children;
758
+ for (const s in n) {
759
+ const t = n[s] ?? [];
760
+ for (let i = t.length - 1; i >= 0; --i) {
761
+ const a = t[i];
762
+ if (wt(a)) {
763
+ if (Object.keys(a.children).length === 0) {
764
+ t.splice(i, 1), t.length === 0 && delete n[s];
765
+ continue;
327
766
  }
767
+ Te(a);
328
768
  }
329
- return i;
330
- }), y = o.xmlWhitespaceSensitivity === "ignore" ? Se : u && $ ? we : null;
331
- return y ? w([
769
+ }
770
+ }
771
+ }
772
+ function wt(e) {
773
+ return "name" in e && "children" in e && "location" in e;
774
+ }
775
+ const { line: xe, group: R, indent: Ee, softline: V } = M, St = async (e, n, s, t, i) => {
776
+ var a, h, p, c, x, g;
777
+ try {
778
+ Q("@prettier/plugin-xml", t, i);
779
+ const { node: D } = s, { createPlaceholder: L, placeholderRegex: r } = A(), E = D.quasis.map(
780
+ (m, $, { length: U }) => $ === U - 1 ? m.value.cooked : m.value.cooked + L($)
781
+ ).join(""), I = ((a = E.match(/^\s+/)) == null ? void 0 : a[0]) ?? "", w = ((h = E.match(/\s+$/)) == null ? void 0 : h[0]) ?? "", T = E.slice(
782
+ I.length,
783
+ -w.length || void 0
784
+ ), b = C(s, n), v = [];
785
+ let u = 0;
786
+ for (; u !== void 0; ) {
787
+ const m = T.slice(u);
788
+ if (m.length === 0)
789
+ break;
790
+ u > 0 && t.xmlWhitespaceSensitivity !== "strict" && v.push(V), (p = t.__embeddedXmlFragmentRecoverIndex) == null || p.splice(
791
+ 0,
792
+ t.__embeddedXmlFragmentRecoverIndex.length
793
+ );
794
+ let $ = await e(m, {
795
+ parser: Z
796
+ });
797
+ const [U, o] = t.__embeddedXmlFragmentRecoverIndex ?? [];
798
+ U === void 0 ? u = void 0 : o === void 0 ? u += U : ($ = m.slice(U, o + 1), u += o + 1), v.push($);
799
+ }
800
+ const l = X(
801
+ v,
802
+ r,
803
+ b
804
+ );
805
+ if (t.xmlWhitespaceSensitivity === "strict" || (c = t.preserveEmbeddedExteriorWhitespaces) != null && c.includes(i))
806
+ return R([
807
+ "`",
808
+ I,
809
+ (x = t.noEmbeddedMultiLineIndentation) != null && x.includes(i) ? [R(l)] : Ee([R(l)]),
810
+ w,
811
+ "`"
812
+ ]);
813
+ const d = I.length ? xe : V, y = w.length ? xe : V;
814
+ return R([
332
815
  "`",
333
- Oe([y, w(h)]),
816
+ (g = t.noEmbeddedMultiLineIndentation) != null && g.includes(i) ? [d, R(l)] : Ee([d, R(l)]),
334
817
  y,
335
818
  "`"
336
- ]) : Ee(
337
- { hug: !1 },
338
- w([
339
- "`",
340
- u,
341
- w(h),
342
- $,
343
- "`"
344
- ])
345
- );
346
- } catch (s) {
347
- throw console.error(s), s;
819
+ ]);
820
+ } catch (D) {
821
+ throw console.error(D), D;
348
822
  }
349
- }, Ne = {
350
- category: "Global",
351
- type: "string",
352
- array: !0,
353
- default: [{ value: ["xml", "svg"] }],
354
- description: "Specify embedded XML languages. This requires @prettier/plugin-xml"
355
- }, ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
823
+ }, Ot = [
824
+ "xml",
825
+ "xsd",
826
+ "ascx",
827
+ "atom",
828
+ "axml",
829
+ "axaml",
830
+ "bpmn",
831
+ "cpt",
832
+ "csl",
833
+ "csproj",
834
+ "dita",
835
+ "ditamap",
836
+ "dtd",
837
+ "ent",
838
+ "mod",
839
+ "dtml",
840
+ "fsproj",
841
+ "fxml",
842
+ "iml",
843
+ "isml",
844
+ "jmx",
845
+ "launch",
846
+ "menu",
847
+ "mxml",
848
+ "nuspec",
849
+ "opml",
850
+ "owl",
851
+ "proj",
852
+ "props",
853
+ "pt",
854
+ "publishsettings",
855
+ "pubxml",
856
+ "rbxlx",
857
+ "rbxmx",
858
+ "rdf",
859
+ "rng",
860
+ "rss",
861
+ "shproj",
862
+ "storyboard",
863
+ "svg",
864
+ "targets",
865
+ "tld",
866
+ "tmx",
867
+ "vbproj",
868
+ "vcxproj",
869
+ "wsdl",
870
+ "wxi",
871
+ "wxl",
872
+ "wxs",
873
+ "xaml",
874
+ "xbl",
875
+ "xib",
876
+ "xlf",
877
+ "xliff",
878
+ "xpdl",
879
+ "xul",
880
+ "xoml"
881
+ ], Tt = {
882
+ [Z]: {
883
+ category: "Global",
884
+ type: "string",
885
+ array: !0,
886
+ default: [{ value: [...Ot] }],
887
+ description: "Specify embedded XML languages. This requires @prettier/plugin-xml"
888
+ },
889
+ /** @internal */
890
+ __embeddedXmlFragmentRecoverIndex: {
891
+ category: "Global",
892
+ type: "int",
893
+ array: !0,
894
+ default: [{ value: [] }],
895
+ description: "This option is read only and used as a workaround to support xml fragments"
896
+ }
897
+ }, Ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
356
898
  __proto__: null,
357
- embedder: De,
358
- name: I,
359
- option: Ne,
360
- parser: qe
361
- }, Symbol.toStringTag, { value: "Module" })), M = [], W = {}, R = {}, z = {}, je = /* @__PURE__ */ Object.assign({
362
- "./noop/index.ts": Y,
363
- "./php/index.ts": pe,
364
- "./sql/index.ts": ve,
365
- "./xml/index.ts": ke
366
- });
367
- Object.values(je).forEach(({ name: e, parser: t, embedder: n, option: o }) => {
368
- oe(M, e, P), t && (W[e] = t), n && (R[e] = n), z[e] = o;
899
+ embeddedLanguage: Z,
900
+ embedder: St,
901
+ options: Tt,
902
+ parser: Dt
903
+ }, Symbol.toStringTag, { value: "Module" })), Ue = [], Le = {}, qe = {}, Pe = {}, Lt = /* @__PURE__ */ Object.assign({
904
+ "./es/index.ts": et,
905
+ "./html/index.ts": rt,
906
+ "./noop/index.ts": at,
907
+ "./php/index.ts": ut,
908
+ "./sql/index.ts": bt,
909
+ "./ts/index.ts": vt,
910
+ "./xml/index.ts": Ut
369
911
  });
370
- const Re = {
912
+ Object.values(Lt).forEach(
913
+ ({ embeddedLanguage: e, parser: n, embedder: s, options: t }) => {
914
+ Ye(Ue, e, J), n && (Le[e] = n), s && (qe[e] = s), Object.assign(Pe, t);
915
+ }
916
+ );
917
+ const Vt = {
371
918
  // parsers from internal
372
- // TODO: find out which parsers are required and which are optional
373
- ...Q.parsers,
374
- ...U.parsers,
375
- ...X.parsers,
376
- ...H.parsers,
919
+ ...Me.parsers,
920
+ ...je.parsers,
921
+ ...Be.parsers,
922
+ ...Fe.parsers,
923
+ ...Ne.parsers,
377
924
  // parsers from this plugin
378
- ...W
379
- }, { estree: O } = J, Ae = function(e, t) {
380
- var o;
381
- const { node: n } = e;
382
- if (n.type !== "TemplateLiteral" || n.quasis.some(({ value: { cooked: r } }) => r === null))
925
+ ...Le
926
+ }, { estree: G } = Re, qt = function(e, n) {
927
+ var t;
928
+ const { node: s } = e;
929
+ if (s.type !== "TemplateLiteral" || s.quasis.some(({ value: { cooked: i } }) => i === null))
383
930
  return null;
384
- for (const r of M) {
385
- const s = t[r];
386
- if (!s)
931
+ for (const i of Ue) {
932
+ const a = n[i];
933
+ if (!a)
387
934
  continue;
388
- const a = Le(
935
+ const h = Pt(
936
+ e,
937
+ a,
938
+ n.noEmbeddedIdentificationByComment ?? []
939
+ ) ?? Mt(
389
940
  e,
390
- s,
391
- t.noEmbeddedDetectionByComment ?? []
392
- ) ?? Be(e, s, t.noEmbeddedDetectionByTag ?? []);
393
- if (a === void 0)
941
+ a,
942
+ n.noEmbeddedIdentificationByTag ?? []
943
+ );
944
+ if (h === void 0)
394
945
  continue;
395
- const g = R[r];
396
- if (!g)
946
+ const p = qe[i];
947
+ if (!p)
397
948
  return null;
398
- const u = e.node;
399
- return u.quasis.length === 1 && u.quasis[0].value.raw.trim() === "" ? "``" : async (...b) => {
400
- const f = await g(...b, a, s);
401
- return q.label(
402
- { embed: !0, ...f.label },
403
- f
949
+ const c = e.node;
950
+ return c.quasis.length === 1 && c.quasis[0].value.raw.trim() === "" ? "``" : async (...x) => {
951
+ const g = await p(...x, h, a);
952
+ return M.label(
953
+ { embed: !0, ...g.label },
954
+ g
404
955
  );
405
956
  };
406
957
  }
407
- return ((o = O.embed) == null ? void 0 : o.call(O, e, t)) ?? null;
958
+ return ((t = G.embed) == null ? void 0 : t.call(G, e, n)) ?? null;
408
959
  };
409
- function Le({ node: e, parent: t }, n, o) {
410
- if (n.length === 0 || e.type !== "TemplateLiteral")
960
+ function Pt({ node: e, parent: n }, s, t) {
961
+ if (s.length === 0 || e.type !== "TemplateLiteral")
411
962
  return;
412
- const r = e.comments ?? (t == null ? void 0 : t.comments);
413
- if (!r)
963
+ const i = e.comments ?? (n == null ? void 0 : n.comments);
964
+ if (!i)
414
965
  return;
415
- const s = r[r.length - 1];
416
- if (!(s.type !== "Block" || !s.leading)) {
417
- for (const a of n)
418
- if (` ${a} ` === s.value && !o.includes(a))
419
- return a;
966
+ const a = i[i.length - 1];
967
+ if (!(![
968
+ "MultiLine",
969
+ // meriyah
970
+ "Block",
971
+ // typescript, acorn, espree, flow
972
+ "CommentBlock"
973
+ // babel, babel-flow, babel-ts
974
+ ].includes(a.type) || !a.leading)) {
975
+ for (const h of s)
976
+ if (` ${h} ` === a.value && !t.includes(h))
977
+ return h;
420
978
  }
421
979
  }
422
- function Be({ node: e, parent: t }, n, o) {
423
- if (n.length !== 0 && !(e.type !== "TemplateLiteral" || (t == null ? void 0 : t.type) !== "TaggedTemplateExpression" || t.tag.type !== "Identifier")) {
424
- for (const r of n)
425
- if (t.tag.name === r && !o.includes(r))
426
- return r;
980
+ function Mt({ node: e, parent: n }, s, t) {
981
+ if (s.length !== 0 && !(e.type !== "TemplateLiteral" || (n == null ? void 0 : n.type) !== "TaggedTemplateExpression" || n.tag.type !== "Identifier")) {
982
+ for (const i of s)
983
+ if (n.tag.name === i && !t.includes(i))
984
+ return i;
427
985
  }
428
986
  }
429
- const ze = {
987
+ const Yt = {
430
988
  estree: {
431
- ...O,
432
- embed: Ae
989
+ ...G,
990
+ embed: qt
433
991
  }
434
- }, Qe = {
435
- ...z,
436
- noEmbeddedDetectionByComment: {
992
+ }, jt = "noEmbeddedIdentificationByComment", Bt = "noEmbeddedIdentificationByTag", Ft = "preserveEmbeddedExteriorWhitespaces", Nt = "noEmbeddedMultiLineIndentation", Qt = {
993
+ ...Pe,
994
+ [jt]: {
437
995
  category: "Global",
438
996
  type: "string",
439
997
  array: !0,
440
998
  default: [{ value: [] }],
441
- description: 'This option turns off "/* lang */`...`" comment-based language detection for the specified languages.'
999
+ description: 'This option turns off "/* identifier */ `...`" comment-based language identification for the specified identifiers.'
1000
+ },
1001
+ [Bt]: {
1002
+ category: "Global",
1003
+ type: "string",
1004
+ array: !0,
1005
+ default: [{ value: [] }],
1006
+ description: 'This option turns off "identifier`...`" tag-based language identification for the specified identifiers.'
1007
+ },
1008
+ [Ft]: {
1009
+ category: "Config",
1010
+ type: "string",
1011
+ array: !0,
1012
+ default: [{ value: [] }],
1013
+ description: "This option preserves leading and trailing whitespaces in the formatting results for the specified identifiers."
442
1014
  },
443
- noEmbeddedDetectionByTag: {
1015
+ [Nt]: {
444
1016
  category: "Global",
445
1017
  type: "string",
446
1018
  array: !0,
447
1019
  default: [{ value: [] }],
448
- description: 'This option turns off "lang`...`" tag-based language detection for the specified languages.'
1020
+ description: "This option turns off auto indentation in the formatting results for the specified identifiers when they are formatted to span multi lines."
449
1021
  }
450
1022
  };
451
1023
  export {
452
- R as embeddedEmbedders,
453
- M as embeddedNames,
454
- z as embeddedOptions,
455
- W as embeddedParsers,
456
- Qe as options,
457
- Re as parsers,
458
- ze as printers
1024
+ qe as embeddedEmbedders,
1025
+ Ue as embeddedLanguages,
1026
+ Pe as embeddedOptions,
1027
+ Le as embeddedParsers,
1028
+ Qt as options,
1029
+ Vt as parsers,
1030
+ Yt as printers
459
1031
  };