prettier-plugin-embed 0.4.2 → 0.4.4

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.
@@ -16,8 +16,8 @@ import * as __glob__0_9 from "./noop/index.js";
16
16
  import * as __glob__0_10 from "./php/index.js";
17
17
  import * as __glob__0_11 from "./properties/index.js";
18
18
  import * as __glob__0_12 from "./ruby/index.js";
19
- import * as __glob__0_13 from "./sh/index.js";
20
- import * as __glob__0_14 from "./sql/index.js";
19
+ import * as __glob__0_13 from "./sql/index.js";
20
+ import * as __glob__0_14 from "./sh/index.js";
21
21
  import * as __glob__0_15 from "./toml/index.js";
22
22
  import * as __glob__0_16 from "./ts/index.js";
23
23
  import * as __glob__0_17 from "./xml/index.js";
package/dist/index.js CHANGED
@@ -9,11 +9,11 @@ import { readFile as Ct } from "node:fs/promises";
9
9
  import { isAbsolute as Wt, dirname as Gt, resolve as qt, extname as zt } from "node:path";
10
10
  import { Worker as Kt } from "node:worker_threads";
11
11
  import { resolveConfigFile as Ht } from "prettier";
12
- const { group: Jt, indent: Xt, softline: ie, lineSuffixBoundary: Yt } = I, { mapDoc: Qt } = X;
12
+ const { group: Jt, indent: Xt, softline: ce, lineSuffixBoundary: Yt } = I, { mapDoc: Qt } = X;
13
13
  function Vt(t, n) {
14
14
  const { node: r } = t;
15
15
  let e = n();
16
- return r?.comments?.length && (e = Jt([Xt([ie, e]), ie])), ["${", e, Yt, "}"];
16
+ return r?.comments?.length && (e = Jt([Xt([ce, e]), ce])), ["${", e, Yt, "}"];
17
17
  }
18
18
  function x(t, n) {
19
19
  return t.map(
@@ -42,7 +42,9 @@ function T(t, n, r) {
42
42
  }
43
43
  function M(t, n, r) {
44
44
  if (!(n.plugins?.some(
45
- (e) => e.name?.endsWith(t) ?? !1
45
+ (e) => e.name?.match(
46
+ new RegExp("(^|/)" + te(t) + "($|/)")
47
+ ) ?? !1
46
48
  ) ?? !1))
47
49
  throw new Error(
48
50
  `Cannot format embedded language identified by "${r}", because plugin "${t}" is not loaded.`
@@ -74,16 +76,16 @@ const Y = (() => {
74
76
  };
75
77
  })();
76
78
  function L(t = "p", n = "") {
77
- const r = Y(), e = Y(), o = ce(t), s = ce(n), l = (p) => `${t}${r}${p}${e}${n}`, d = new RegExp(
79
+ const r = Y(), e = Y(), o = te(t), s = te(n), l = (p) => `${t}${r}${p}${e}${n}`, d = new RegExp(
78
80
  `${o}${r}(\\d+)${e}${s}`,
79
- "g"
81
+ "ig"
80
82
  );
81
83
  return {
82
84
  createPlaceholder: l,
83
85
  placeholderRegex: d
84
86
  };
85
87
  }
86
- function ce(t) {
88
+ function te(t) {
87
89
  return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
88
90
  }
89
91
  function S(t) {
@@ -166,7 +168,7 @@ const { line: ae, group: k, indent: de, softline: le } = I, tn = async (t, n, r,
166
168
  v,
167
169
  "`"
168
170
  ]);
169
- }, te = "embeddedEs", an = [
171
+ }, ne = "embeddedEs", an = [
170
172
  "js",
171
173
  "jsx",
172
174
  "es",
@@ -182,7 +184,7 @@ const { line: ae, group: k, indent: de, softline: le } = I, tn = async (t, n, r,
182
184
  "espree",
183
185
  "flow",
184
186
  "meriyah"
185
- ], ln = S(te), un = V(te), gn = {
187
+ ], ln = S(ne), un = V(ne), gn = {
186
188
  [ln]: {
187
189
  category: "Embed",
188
190
  type: "string",
@@ -203,7 +205,7 @@ const { line: ae, group: k, indent: de, softline: le } = I, tn = async (t, n, r,
203
205
  }, pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
204
206
  __proto__: null,
205
207
  embedder: cn,
206
- language: te,
208
+ language: ne,
207
209
  options: gn
208
210
  }, Symbol.toStringTag, { value: "Module" })), { line: me, group: A, indent: he, softline: fe } = I, mn = async (t, n, r, e, { identifier: o, embeddedOverrideOptions: s }) => {
209
211
  M("prettier-plugin-glsl", e, o), e = {
@@ -421,13 +423,16 @@ const { line: ae, group: k, indent: de, softline: le } = I, tn = async (t, n, r,
421
423
  ]);
422
424
  };
423
425
  function jn() {
424
- const t = Y(), n = Y(), r = (o) => `'0${t}${o}${n}'`, e = new RegExp(`["']?0${t}(\\d+)${n}['"]?`, "g");
426
+ const t = Y(), n = Y(), r = (o) => `'0${t}${o}${n}'`, e = new RegExp(
427
+ `["']?0${t}(\\d+)${n}['"]?`,
428
+ "ig"
429
+ );
425
430
  return {
426
431
  createPlaceholder: r,
427
432
  placeholderRegex: e
428
433
  };
429
434
  }
430
- const ne = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify", "json5"], Bn = V(ne), Un = S(ne), Cn = {
435
+ const re = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify", "json5"], Bn = V(re), Un = S(re), Cn = {
431
436
  [Un]: {
432
437
  category: "Embed",
433
438
  type: "string",
@@ -448,7 +453,7 @@ const ne = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify
448
453
  }, Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
449
454
  __proto__: null,
450
455
  embedder: Rn,
451
- language: ne,
456
+ language: re,
452
457
  options: Cn
453
458
  }, Symbol.toStringTag, { value: "Module" })), { line: Oe, group: w, indent: Me, softline: ke } = I, Gn = async (t, n, r, e, { identifier: o, embeddedOverrideOptions: s }) => {
454
459
  M("prettier-plugin-latex", e, o), e = {
@@ -544,7 +549,7 @@ const ne = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify
544
549
  embedder: Jn,
545
550
  language: bt,
546
551
  options: Qn
547
- }, Symbol.toStringTag, { value: "Module" })), re = "embeddedNoop", Zn = S(re), er = {
552
+ }, Symbol.toStringTag, { value: "Module" })), oe = "embeddedNoop", Zn = S(oe), er = {
548
553
  [Zn]: {
549
554
  category: "Embed",
550
555
  type: "string",
@@ -554,7 +559,7 @@ const ne = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify
554
559
  }
555
560
  }, tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
556
561
  __proto__: null,
557
- language: re,
562
+ language: oe,
558
563
  options: er
559
564
  }, Symbol.toStringTag, { value: "Module" })), { line: Re, group: U, indent: je, softline: Fe } = I, nr = async (t, n, r, e, { identifier: o, embeddedOverrideOptions: s }) => {
560
565
  M("@prettier/plugin-php", e, o), e = {
@@ -1014,7 +1019,7 @@ const { hardline: Mr, group: q, line: Xe, softline: Ye, indent: Qe } = I, { mapD
1014
1019
  v,
1015
1020
  "`"
1016
1021
  ]);
1017
- }, oe = "embeddedTs", Xr = ["ts", "tsx", "cts", "mts", "typescript"], Yr = ["typescript", "babel-ts"], Qr = V(oe), Vr = S(oe), Zr = {
1022
+ }, se = "embeddedTs", Xr = ["ts", "tsx", "cts", "mts", "typescript"], Yr = ["typescript", "babel-ts"], Qr = V(se), Vr = S(se), Zr = {
1018
1023
  [Vr]: {
1019
1024
  category: "Embed",
1020
1025
  type: "string",
@@ -1035,9 +1040,9 @@ const { hardline: Mr, group: q, line: Xe, softline: Ye, indent: Qe } = I, { mapD
1035
1040
  }, eo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1036
1041
  __proto__: null,
1037
1042
  embedder: Jr,
1038
- language: oe,
1043
+ language: se,
1039
1044
  options: Zr
1040
- }, Symbol.toStringTag, { value: "Module" })), se = "embeddedXml", { line: ot, group: H, indent: st, softline: ee } = I, to = async (t, n, r, e, { identifier: o, embeddedOverrideOptions: s }) => {
1045
+ }, Symbol.toStringTag, { value: "Module" })), ie = "embeddedXml", { line: ot, group: H, indent: st, softline: ee } = I, to = async (t, n, r, e, { identifier: o, embeddedOverrideOptions: s }) => {
1041
1046
  M("@prettier/plugin-xml", e, o), e = {
1042
1047
  ...e,
1043
1048
  ...s
@@ -1059,7 +1064,7 @@ const { hardline: Mr, group: q, line: Xe, softline: Ye, indent: Qe } = I, { mapD
1059
1064
  );
1060
1065
  let f = await t(g, {
1061
1066
  ...e,
1062
- parser: se
1067
+ parser: ie
1063
1068
  });
1064
1069
  const [$, _] = e.__embeddedXmlFragmentRecoverIndex ?? [];
1065
1070
  $ === void 0 ? i = void 0 : _ === void 0 ? i += $ : (f = g.slice($, _ + 1), i += _ + 1), E.push(f);
@@ -1080,7 +1085,7 @@ const { hardline: Mr, group: q, line: Xe, softline: Ye, indent: Qe } = I, { mapD
1080
1085
  m,
1081
1086
  "`"
1082
1087
  ]);
1083
- }, no = ["xml", "opml", "rss", "svg"], ro = S(se), oo = {
1088
+ }, no = ["xml", "opml", "rss", "svg"], ro = S(ie), oo = {
1084
1089
  [ro]: {
1085
1090
  category: "Embed",
1086
1091
  type: "string",
@@ -1216,7 +1221,7 @@ function co(t) {
1216
1221
  const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1217
1222
  __proto__: null,
1218
1223
  embedder: to,
1219
- language: se,
1224
+ language: ie,
1220
1225
  options: oo,
1221
1226
  parser: io
1222
1227
  }, Symbol.toStringTag, { value: "Module" })), { line: ct, group: J, indent: at, softline: dt } = I, lo = async (t, n, r, e, { identifier: o, embeddedOverrideOptions: s }) => {
@@ -1283,7 +1288,7 @@ const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1283
1288
  "./yaml/index.ts": mo
1284
1289
  });
1285
1290
  Object.values(ho).forEach(({ language: t, parser: n, embedder: r, options: e }) => {
1286
- Zt(Lt, t, re), n && (Tt[t] = n), r && (Ot[t] = r), Object.assign(Mt, e);
1291
+ Zt(Lt, t, oe), n && (Tt[t] = n), r && (Ot[t] = r), Object.assign(Mt, e);
1287
1292
  });
1288
1293
  const fo = "noEmbeddedIdentificationByComment", Eo = "noEmbeddedIdentificationByTag", bo = "preserveEmbeddedExteriorWhitespaces", yo = "noEmbeddedMultiLineIndentation", _o = "embeddedOverrides", Ho = {
1289
1294
  ...Mt,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "prettier-plugin-embed",
3
3
  "description": "A configurable Prettier plugin to format embedded languages in js/ts files.",
4
4
  "private": false,
5
- "version": "0.4.2",
5
+ "version": "0.4.4",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "./dist"