prettier-plugin-embed 0.0.6 → 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 (47) 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 +901 -338
  35. package/dist/options.d.ts +135 -5
  36. package/dist/prettier-plugin-embed-wide-dark.svg +309 -0
  37. package/dist/prettier-plugin-embed-wide-light.svg +309 -0
  38. package/dist/types.d.ts +1 -1
  39. package/package.json +17 -13
  40. package/dist/embedded/noop/name.d.ts +0 -6
  41. package/dist/embedded/noop/option.d.ts +0 -11
  42. package/dist/embedded/php/name.d.ts +0 -6
  43. package/dist/embedded/php/option.d.ts +0 -20
  44. package/dist/embedded/sql/name.d.ts +0 -6
  45. package/dist/embedded/sql/option.d.ts +0 -21
  46. package/dist/embedded/xml/name.d.ts +0 -6
  47. package/dist/embedded/xml/option.d.ts +0 -21
package/dist/index.js CHANGED
@@ -1,147 +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 V from "prettier/parser-meriyah";
6
- import { builders as q, utils as T } from "prettier/doc";
7
- import { parse as J } from "@xml-tools/parser";
8
- import { printers as K } from "prettier/plugins/estree.mjs";
9
- const M = "embeddedNoop", Y = {
10
- category: "Global",
11
- type: "string",
12
- array: !0,
13
- default: [{ value: [] }],
14
- description: "Specify embedded languages that will not be formatted."
15
- }, Z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
16
- __proto__: null,
17
- name: M,
18
- option: Y
19
- }, Symbol.toStringTag, { value: "Module" })), ee = "embeddedPhp", { group: te, indent: ne, softline: j, lineSuffixBoundary: re } = q;
20
- function oe(e, t) {
21
- var r;
22
- const { node: n } = e;
23
- let o = t();
24
- return (r = n == null ? void 0 : n.comments) != null && r.length && (o = te([ne([j, o]), j])), ["${", o, re, "}"];
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, "}"];
25
203
  }
26
- function k(e, t) {
204
+ function C(e, n) {
27
205
  return e.map(
28
- (n) => oe(n, t),
206
+ (s) => Ve(s, n),
29
207
  "expressions"
30
208
  );
31
209
  }
32
- function D(e, t, n) {
33
- var o;
34
- if (!(((o = t.plugins) == null ? void 0 : o.some(
35
- (r) => {
36
- var s;
37
- 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;
38
235
  }
39
236
  )) ?? !1))
40
237
  throw new Error(
41
- `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.`
42
239
  );
43
240
  }
44
- function se(e, t, n) {
45
- if (t === n) {
46
- e.unshift(t);
241
+ function Ye(e, n, s) {
242
+ if (n === s) {
243
+ e.unshift(n);
47
244
  return;
48
245
  }
49
- let o = 0, r = e.length;
50
- for (; o < r; ) {
51
- const s = o + r >>> 1;
52
- if (e[s] === n) {
53
- 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);
54
251
  return;
55
252
  }
56
- e[s] < t ? o = s + 1 : r = s;
253
+ e[a] < n ? t = a + 1 : i = a;
57
254
  }
58
- 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
+ };
59
270
  }
60
- function N() {
61
- function e(n) {
62
- 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;
63
303
  }
64
- function t(n) {
65
- 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."
66
326
  }
67
- return [
68
- e(4) + e(4),
69
- e(4),
70
- "4" + e(3),
71
- // UUID version 4
72
- t(8 | Math.random() * 4) + e(3),
73
- // {8|9|A|B}xxx
74
- // s(4) + s(4) + s(4),
75
- Date.now().toString(16).slice(-10) + e(2)
76
- // Use timestamp to avoid collisions
77
- ].join("-");
78
- }
79
- const { label: ie, hardline: le, line: ae, group: E, indent: ce } = q, { mapDoc: ue } = T, de = 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;
80
334
  try {
81
- D("@prettier/plugin-php", o, r);
82
- const s = "$p" + N().replaceAll("-", ""), { node: a } = n, g = a.quasis.map(
83
- (i, l, { length: p }) => l === p - 1 ? i.value.cooked : i.value.cooked + `${s}${l}`
84
- ).join("");
85
- let u = "", b = 0;
86
- const f = /^\s+/.exec(g);
87
- f && (b = f.index + f[0].length, u = " ");
88
- const $ = /\s$/.test(g) ? " " : "", _ = k(n, t), v = await e(g.slice(b), {
89
- parser: "php"
90
- });
91
- let h = !1;
92
- const y = ue(v, (i) => {
93
- if (typeof i != "string")
94
- return Array.isArray(i) || (i.type === "group" && i.break || i.type === "line" && (i.hard || i.literal)) && (h = !0), i;
95
- const l = [], p = i.split(new RegExp("\\" + s + "(\\d+)", "g"));
96
- for (let c = 0; c < p.length; c++) {
97
- let m = p[c];
98
- if (c % 2 == 0) {
99
- 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 (!$)
100
347
  continue;
101
- m = m.replaceAll(/([\\`]|\${)/g, "\\$1"), l.push(m);
348
+ $ = $.replaceAll(/([\\`]|\${)/g, "\\$1"), t.__embeddedInHtml && ($ = $.replaceAll(/<\/(?=script\b)/gi, "<\\/")), d.push($);
102
349
  } else {
103
- const x = Number(m);
104
- l.push(_[x]);
350
+ const U = Number($);
351
+ d.push(w[U]);
105
352
  }
106
353
  }
107
- return l;
108
- }), d = h ? le : u && $ ? ae : null;
109
- 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([
110
367
  "`",
111
- ce([d, E(y)]),
112
- d,
368
+ (x = t.noEmbeddedMultiLineIndentation) != null && x.includes(i) ? [v, B(b)] : ae([v, B(b)]),
369
+ u,
113
370
  "`"
114
- ]) : ie(
115
- { hug: !1 },
116
- 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([
117
431
  "`",
118
- u,
119
- E([y]),
120
- $,
432
+ E,
433
+ (c = t.noEmbeddedMultiLineIndentation) != null && c.includes(i) ? [F(v)] : de([F(v)]),
434
+ I,
121
435
  "`"
122
- ])
123
- );
124
- } catch (s) {
125
- 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;
126
446
  }
127
- }, pe = {
128
- category: "Global",
129
- type: "string",
130
- array: !0,
131
- default: [{ value: ["php"] }],
132
- description: "Specify embedded PHP languages. This requires @prettier/plugin-php"
133
- }, fe = /* @__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({
134
456
  __proto__: null,
135
- embedder: de,
136
- name: ee,
137
- option: pe
138
- }, Symbol.toStringTag, { value: "Module" })), me = "embeddedSql", ge = {
139
- category: "Global",
140
- type: "string",
141
- array: !0,
142
- default: [{ value: ["sql"] }],
143
- description: "Specify embedded SQL languages. This requires prettier-plugin-sql"
144
- }, P = [
457
+ embeddedLanguage: De,
458
+ embedder: lt,
459
+ options: dt
460
+ }, Symbol.toStringTag, { value: "Module" })), we = "embeddedSql", K = [
145
461
  "sql",
146
462
  "bigquery",
147
463
  "hive",
@@ -158,7 +474,7 @@ const { label: ie, hardline: le, line: ae, group: E, indent: ce } = q, { mapDoc:
158
474
  "transactsql",
159
475
  "tsql",
160
476
  "trino"
161
- ], C = [
477
+ ], Se = [
162
478
  "bigquery",
163
479
  "db2",
164
480
  "hive",
@@ -167,132 +483,267 @@ const { label: ie, hardline: le, line: ae, group: E, indent: ce } = q, { mapDoc:
167
483
  "postgresql",
168
484
  "transactsql",
169
485
  "flinksql"
170
- ], { label: be, hardline: L, group: S, line: he, indent: ye } = q, { mapDoc: $e } = 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;
171
496
  try {
172
- D("prettier-plugin-sql", o, r);
173
- const a = "p" + N().replaceAll("-", ""), { node: g } = n, u = g.quasis.map(
174
- (i, l, { length: p }) => l === p - 1 ? i.value.cooked : i.value.cooked + `${a}${l}`
175
- ).join(""), b = /^\s/.test(u) ? " " : "", f = /\s$/.test(u) ? " " : "", $ = k(n, t), _ = ve(o, r, s);
176
- if (typeof _ > "u")
177
- throw new SyntaxError(`Unrecognized language: ${r}`);
178
- 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, {
179
508
  parser: "sql",
180
- ..._
181
- });
182
- let h = !1;
183
- const y = $e(v, (i) => {
184
- if (typeof i != "string")
185
- return i;
186
- const l = [], p = i.split(new RegExp(a + "(\\d+)", "g"));
187
- for (let c = 0; c < p.length; c++) {
188
- let m = p[c];
189
- if (c % 2 == 0) {
190
- 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)
191
518
  continue;
192
- m = m.replaceAll(/([\\`]|\${)/g, "\\$1"), m.split(/(\n)/).forEach(
193
- (x) => x === `
194
- ` ? (h = !0, l.push(L)) : l.push(x)
519
+ o = o.replaceAll(/([\\`]|\${)/g, "\\$1"), o.split(/(\n)/).forEach(
520
+ (_) => _ === `
521
+ ` ? m.push(pt) : m.push(_)
195
522
  );
196
523
  } else {
197
- const x = Number(m);
198
- l.push($[x]);
524
+ const _ = Number(o);
525
+ m.push(T[_]);
199
526
  }
200
527
  }
201
- return l;
202
- }), d = h ? L : b && f ? he : null;
203
- 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([
204
540
  "`",
205
- ye([d, S(y)]),
541
+ (g = t.noEmbeddedMultiLineIndentation) != null && g.includes(i) ? [l, N(u)] : _e([l, N(u)]),
206
542
  d,
207
543
  "`"
208
- ]) : be(
209
- { hug: !1 },
210
- S([
211
- "`",
212
- b,
213
- S(y),
214
- f,
215
- "`"
216
- ])
217
- );
218
- } catch (a) {
219
- throw console.error(a), a;
544
+ ]);
545
+ } catch (D) {
546
+ throw console.error(D), D;
220
547
  }
221
- }, xe = {
222
- "sql-formatter": (e) => P.includes(e),
223
- "node-sql-parser": (e) => C.includes(e)
548
+ }, mt = {
549
+ "sql-formatter": (e) => K.includes(e),
550
+ "node-sql-parser": (e) => Se.includes(e)
224
551
  };
225
- function A(e, t) {
226
- for (const n of t)
227
- if (xe[n](e))
228
- return {
229
- formatter: n,
230
- language: e
231
- };
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
+ }
232
567
  }
233
- function B(e, t, n) {
234
- let o = A(e, n);
235
- if (o)
236
- return o;
237
- const r = t.indexOf(e);
238
- for (let s = r - 1; s >= 0; --s)
239
- if (o = A(t[s], n), o)
240
- 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;
241
579
  }
242
- function ve(e, t, n) {
243
- return e.formatter === "sql-formatter" ? B(t, n, [
244
- "sql-formatter",
245
- "node-sql-parser"
246
- ]) : B(t, n, [
247
- "node-sql-parser",
248
- "sql-formatter"
249
- ]);
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
+ }
250
601
  }
251
- const qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
602
+ const bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
252
603
  __proto__: null,
253
- NODE_SQL_PARSER_DATABASES: C,
254
- SQL_FORMATTER_LANGUAGES: P,
255
- embedder: _e,
256
- name: me,
257
- option: ge
258
- }, Symbol.toStringTag, { value: "Module" })), G = "embeddedXml";
259
- function F(e, t) {
260
- const n = new SyntaxError(
261
- 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
+ }
262
677
  );
263
- return Object.assign(n, t);
678
+ return Object.assign(s, n), s;
264
679
  }
265
- const Ee = {
266
- parse(e) {
267
- const { lexErrors: t, parseErrors: n, cst: o } = J(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
+ }
268
708
  if (t.length > 0) {
269
- const r = t[0];
270
- throw F(r.message, {
271
- loc: {
272
- start: { line: r.line, column: r.column },
273
- end: {
274
- line: r.line,
275
- column: r.column + r.length
276
- }
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;
277
718
  }
278
- });
279
- }
280
- if (n.length > 0) {
281
- const r = n[0];
282
- throw F(r.message, {
283
- loc: {
284
- start: {
285
- line: r.token.startLine ?? NaN,
286
- column: r.token.startColumn ?? NaN
287
- },
288
- end: {
289
- line: r.token.endLine ?? NaN,
290
- column: r.token.endColumn ?? NaN
291
- }
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;
292
728
  }
293
- });
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);
294
745
  }
295
- return o;
746
+ return i;
296
747
  },
297
748
  astFormat: "xml",
298
749
  locStart(e) {
@@ -301,120 +752,218 @@ const Ee = {
301
752
  locEnd(e) {
302
753
  return e.location.endOffset ?? NaN;
303
754
  }
304
- }, { label: Se, hardline: we, line: Oe, group: w, indent: Te } = q, { mapDoc: ke } = T, De = async (e, t, n, o, r) => {
305
- try {
306
- D("@prettier/plugin-xml", o, r);
307
- const s = N(), { node: a } = n, g = a.quasis.map(
308
- (d, i, { length: l }) => i === l - 1 ? d.value.cooked : d.value.cooked + `${s}-${i}`
309
- ).join("");
310
- let u = "", b = 0;
311
- const f = /^\s+/.exec(g);
312
- f && (b = f.index + f[0].length, u = " ");
313
- const $ = /\s$/.test(g) ? " " : "", _ = k(n, t), v = await e(g.slice(b), {
314
- parser: G
315
- }), h = ke(v, (d) => {
316
- if (typeof d != "string")
317
- return d;
318
- const i = [], l = d.split(new RegExp(s + "-(\\d+)", "g"));
319
- for (let p = 0; p < l.length; p++) {
320
- let c = l[p];
321
- if (p % 2 == 0) {
322
- if (!c)
323
- continue;
324
- c = c.replaceAll(/([\\`]|\${)/g, "\\$1"), i.push(c);
325
- } else {
326
- const m = Number(c);
327
- 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;
328
766
  }
767
+ Te(a);
329
768
  }
330
- return i;
331
- }), y = o.xmlWhitespaceSensitivity === "ignore" ? we : u && $ ? Oe : null;
332
- 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([
333
815
  "`",
334
- Te([y, w(h)]),
816
+ (g = t.noEmbeddedMultiLineIndentation) != null && g.includes(i) ? [d, R(l)] : Ee([d, R(l)]),
335
817
  y,
336
818
  "`"
337
- ]) : Se(
338
- { hug: !1 },
339
- w([
340
- "`",
341
- u,
342
- w(h),
343
- $,
344
- "`"
345
- ])
346
- );
347
- } catch (s) {
348
- throw console.error(s), s;
819
+ ]);
820
+ } catch (D) {
821
+ throw console.error(D), D;
349
822
  }
350
- }, Ne = {
351
- category: "Global",
352
- type: "string",
353
- array: !0,
354
- default: [{ value: ["xml", "svg"] }],
355
- description: "Specify embedded XML languages. This requires @prettier/plugin-xml"
356
- }, je = /* @__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({
357
898
  __proto__: null,
358
- embedder: De,
359
- name: G,
360
- option: Ne,
361
- parser: Ee
362
- }, Symbol.toStringTag, { value: "Module" })), I = [], W = {}, R = {}, z = {}, Le = /* @__PURE__ */ Object.assign({
363
- "./noop/index.ts": Z,
364
- "./php/index.ts": fe,
365
- "./sql/index.ts": qe,
366
- "./xml/index.ts": je
367
- });
368
- Object.values(Le).forEach(({ name: e, parser: t, embedder: n, option: o }) => {
369
- se(I, e, M), 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
370
911
  });
371
- const Qe = {
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 = {
372
918
  // parsers from internal
373
- // TODO: find out which parsers are required and which are optional
374
- ...Q.parsers,
375
- ...U.parsers,
376
- ...X.parsers,
377
- ...H.parsers,
378
- ...V.parsers,
919
+ ...Me.parsers,
920
+ ...je.parsers,
921
+ ...Be.parsers,
922
+ ...Fe.parsers,
923
+ ...Ne.parsers,
379
924
  // parsers from this plugin
380
- ...W
381
- }, { estree: O } = K, Ae = function(e, t) {
382
- var o;
383
- const { node: n } = e;
384
- 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))
385
930
  return null;
386
- for (const r of I) {
387
- const s = t[r];
388
- if (!s)
931
+ for (const i of Ue) {
932
+ const a = n[i];
933
+ if (!a)
389
934
  continue;
390
- const a = Be(
935
+ const h = Pt(
936
+ e,
937
+ a,
938
+ n.noEmbeddedIdentificationByComment ?? []
939
+ ) ?? Mt(
391
940
  e,
392
- s,
393
- t.noEmbeddedDetectionByComment ?? []
394
- ) ?? Fe(e, s, t.noEmbeddedDetectionByTag ?? []);
395
- if (a === void 0)
941
+ a,
942
+ n.noEmbeddedIdentificationByTag ?? []
943
+ );
944
+ if (h === void 0)
396
945
  continue;
397
- const g = R[r];
398
- if (!g)
946
+ const p = qe[i];
947
+ if (!p)
399
948
  return null;
400
- const u = e.node;
401
- return u.quasis.length === 1 && u.quasis[0].value.raw.trim() === "" ? "``" : async (...b) => {
402
- const f = await g(...b, a, s);
403
- return q.label(
404
- { embed: !0, ...f.label },
405
- 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
406
955
  );
407
956
  };
408
957
  }
409
- 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;
410
959
  };
411
- function Be({ node: e, parent: t }, n, o) {
412
- if (n.length === 0 || e.type !== "TemplateLiteral")
960
+ function Pt({ node: e, parent: n }, s, t) {
961
+ if (s.length === 0 || e.type !== "TemplateLiteral")
413
962
  return;
414
- const r = e.comments ?? (t == null ? void 0 : t.comments);
415
- if (!r)
963
+ const i = e.comments ?? (n == null ? void 0 : n.comments);
964
+ if (!i)
416
965
  return;
417
- const s = r[r.length - 1];
966
+ const a = i[i.length - 1];
418
967
  if (!(![
419
968
  "MultiLine",
420
969
  // meriyah
@@ -422,47 +971,61 @@ function Be({ node: e, parent: t }, n, o) {
422
971
  // typescript, acorn, espree, flow
423
972
  "CommentBlock"
424
973
  // babel, babel-flow, babel-ts
425
- ].includes(s.type) || !s.leading)) {
426
- for (const a of n)
427
- if (` ${a} ` === s.value && !o.includes(a))
428
- return a;
974
+ ].includes(a.type) || !a.leading)) {
975
+ for (const h of s)
976
+ if (` ${h} ` === a.value && !t.includes(h))
977
+ return h;
429
978
  }
430
979
  }
431
- function Fe({ node: e, parent: t }, n, o) {
432
- if (n.length !== 0 && !(e.type !== "TemplateLiteral" || (t == null ? void 0 : t.type) !== "TaggedTemplateExpression" || t.tag.type !== "Identifier")) {
433
- for (const r of n)
434
- if (t.tag.name === r && !o.includes(r))
435
- 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;
436
985
  }
437
986
  }
438
- const Ue = {
987
+ const Yt = {
439
988
  estree: {
440
- ...O,
441
- embed: Ae
989
+ ...G,
990
+ embed: qt
442
991
  }
443
- }, Xe = {
444
- ...z,
445
- noEmbeddedDetectionByComment: {
992
+ }, jt = "noEmbeddedIdentificationByComment", Bt = "noEmbeddedIdentificationByTag", Ft = "preserveEmbeddedExteriorWhitespaces", Nt = "noEmbeddedMultiLineIndentation", Qt = {
993
+ ...Pe,
994
+ [jt]: {
446
995
  category: "Global",
447
996
  type: "string",
448
997
  array: !0,
449
998
  default: [{ value: [] }],
450
- 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."
451
1014
  },
452
- noEmbeddedDetectionByTag: {
1015
+ [Nt]: {
453
1016
  category: "Global",
454
1017
  type: "string",
455
1018
  array: !0,
456
1019
  default: [{ value: [] }],
457
- 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."
458
1021
  }
459
1022
  };
460
1023
  export {
461
- R as embeddedEmbedders,
462
- I as embeddedNames,
463
- z as embeddedOptions,
464
- W as embeddedParsers,
465
- Xe as options,
466
- Qe as parsers,
467
- Ue 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
468
1031
  };