prettier-plugin-embed 0.4.2 → 0.4.3

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 (2) hide show
  1. package/dist/index.js +21 -19
  2. package/package.json +1 -1
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,7 +76,7 @@ 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
81
  "g"
80
82
  );
@@ -83,7 +85,7 @@ function L(t = "p", n = "") {
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 = {
@@ -427,7 +429,7 @@ function jn() {
427
429
  placeholderRegex: e
428
430
  };
429
431
  }
430
- const ne = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify", "json5"], Bn = V(ne), Un = S(ne), Cn = {
432
+ const re = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify", "json5"], Bn = V(re), Un = S(re), Cn = {
431
433
  [Un]: {
432
434
  category: "Embed",
433
435
  type: "string",
@@ -448,7 +450,7 @@ const ne = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify
448
450
  }, Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
449
451
  __proto__: null,
450
452
  embedder: Rn,
451
- language: ne,
453
+ language: re,
452
454
  options: Cn
453
455
  }, Symbol.toStringTag, { value: "Module" })), { line: Oe, group: w, indent: Me, softline: ke } = I, Gn = async (t, n, r, e, { identifier: o, embeddedOverrideOptions: s }) => {
454
456
  M("prettier-plugin-latex", e, o), e = {
@@ -544,7 +546,7 @@ const ne = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify
544
546
  embedder: Jn,
545
547
  language: bt,
546
548
  options: Qn
547
- }, Symbol.toStringTag, { value: "Module" })), re = "embeddedNoop", Zn = S(re), er = {
549
+ }, Symbol.toStringTag, { value: "Module" })), oe = "embeddedNoop", Zn = S(oe), er = {
548
550
  [Zn]: {
549
551
  category: "Embed",
550
552
  type: "string",
@@ -554,7 +556,7 @@ const ne = "embeddedJson", Fn = ["json", "jsonl"], wn = ["json", "json-stringify
554
556
  }
555
557
  }, tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
556
558
  __proto__: null,
557
- language: re,
559
+ language: oe,
558
560
  options: er
559
561
  }, Symbol.toStringTag, { value: "Module" })), { line: Re, group: U, indent: je, softline: Fe } = I, nr = async (t, n, r, e, { identifier: o, embeddedOverrideOptions: s }) => {
560
562
  M("@prettier/plugin-php", e, o), e = {
@@ -1014,7 +1016,7 @@ const { hardline: Mr, group: q, line: Xe, softline: Ye, indent: Qe } = I, { mapD
1014
1016
  v,
1015
1017
  "`"
1016
1018
  ]);
1017
- }, oe = "embeddedTs", Xr = ["ts", "tsx", "cts", "mts", "typescript"], Yr = ["typescript", "babel-ts"], Qr = V(oe), Vr = S(oe), Zr = {
1019
+ }, se = "embeddedTs", Xr = ["ts", "tsx", "cts", "mts", "typescript"], Yr = ["typescript", "babel-ts"], Qr = V(se), Vr = S(se), Zr = {
1018
1020
  [Vr]: {
1019
1021
  category: "Embed",
1020
1022
  type: "string",
@@ -1035,9 +1037,9 @@ const { hardline: Mr, group: q, line: Xe, softline: Ye, indent: Qe } = I, { mapD
1035
1037
  }, eo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1036
1038
  __proto__: null,
1037
1039
  embedder: Jr,
1038
- language: oe,
1040
+ language: se,
1039
1041
  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 }) => {
1042
+ }, 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
1043
  M("@prettier/plugin-xml", e, o), e = {
1042
1044
  ...e,
1043
1045
  ...s
@@ -1059,7 +1061,7 @@ const { hardline: Mr, group: q, line: Xe, softline: Ye, indent: Qe } = I, { mapD
1059
1061
  );
1060
1062
  let f = await t(g, {
1061
1063
  ...e,
1062
- parser: se
1064
+ parser: ie
1063
1065
  });
1064
1066
  const [$, _] = e.__embeddedXmlFragmentRecoverIndex ?? [];
1065
1067
  $ === void 0 ? i = void 0 : _ === void 0 ? i += $ : (f = g.slice($, _ + 1), i += _ + 1), E.push(f);
@@ -1080,7 +1082,7 @@ const { hardline: Mr, group: q, line: Xe, softline: Ye, indent: Qe } = I, { mapD
1080
1082
  m,
1081
1083
  "`"
1082
1084
  ]);
1083
- }, no = ["xml", "opml", "rss", "svg"], ro = S(se), oo = {
1085
+ }, no = ["xml", "opml", "rss", "svg"], ro = S(ie), oo = {
1084
1086
  [ro]: {
1085
1087
  category: "Embed",
1086
1088
  type: "string",
@@ -1216,7 +1218,7 @@ function co(t) {
1216
1218
  const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1217
1219
  __proto__: null,
1218
1220
  embedder: to,
1219
- language: se,
1221
+ language: ie,
1220
1222
  options: oo,
1221
1223
  parser: io
1222
1224
  }, 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 +1285,7 @@ const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1283
1285
  "./yaml/index.ts": mo
1284
1286
  });
1285
1287
  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);
1288
+ Zt(Lt, t, oe), n && (Tt[t] = n), r && (Ot[t] = r), Object.assign(Mt, e);
1287
1289
  });
1288
1290
  const fo = "noEmbeddedIdentificationByComment", Eo = "noEmbeddedIdentificationByTag", bo = "preserveEmbeddedExteriorWhitespaces", yo = "noEmbeddedMultiLineIndentation", _o = "embeddedOverrides", Ho = {
1289
1291
  ...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.3",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "./dist"