prettier-plugin-embed 0.0.3 → 0.0.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.
@@ -1,2 +1,2 @@
1
1
  export * from "./register.js";
2
- export type { EmbeddedNames, EmbeddedParsers, EmbeddedEmbedders, EmbeddedOptions, } from "./types.js";
2
+ export type { EmbeddedName, EmbeddedParsers, EmbeddedEmbedders, EmbeddedOptions, } from "./types.js";
@@ -1,4 +1,4 @@
1
- import { SupportOption } from "prettier";
1
+ import type { SupportOption } from "prettier";
2
2
  import { name } from "./name.js";
3
3
  export declare const option: SupportOption;
4
4
  declare module "../types.js" {
@@ -1,4 +1,4 @@
1
- import { SupportOption } from "prettier";
1
+ import type { SupportOption } from "prettier";
2
2
  import { name } from "./name.js";
3
3
  export declare const option: SupportOption;
4
4
  declare module "../types.js" {
@@ -1,5 +1,9 @@
1
- import type { EmbeddedEmbedders, EmbeddedNames, EmbeddedParsers, EmbeddedOptions } from "./types.js";
2
- export declare const embeddedNames: EmbeddedNames[];
1
+ import type { EmbeddedEmbedders, EmbeddedName, EmbeddedParsers, EmbeddedOptions } from "./types.js";
2
+ export declare const embeddedNames: EmbeddedName[];
3
3
  export declare const embeddedParsers: EmbeddedParsers;
4
4
  export declare const embeddedEmbedders: EmbeddedEmbedders;
5
5
  export declare const embeddedOptions: EmbeddedOptions;
6
+ import * as __glob__0_0 from "./noop/index.js";
7
+ import * as __glob__0_1 from "./sql/index.js";
8
+ import * as __glob__0_2 from "./php/index.js";
9
+ import * as __glob__0_3 from "./xml/index.js";
@@ -1,4 +1,4 @@
1
- import { SupportOption } from "prettier";
1
+ import type { SupportOption } from "prettier";
2
2
  import type { SqlBaseOptions as PrettierPluginDepsOptions } from "prettier-plugin-sql";
3
3
  import { name } from "./name.js";
4
4
  export declare const option: SupportOption;
@@ -1,5 +1,5 @@
1
- import { Parser, SupportOption, Options } from "prettier";
2
- import { Embedder } from "../types.js";
1
+ import type { Parser, SupportOption, Options } from "prettier";
2
+ import type { Embedder } from "../types.js";
3
3
  export interface EmbeddedParsers {
4
4
  [name: string]: Parser | undefined;
5
5
  }
@@ -11,4 +11,4 @@ export interface EmbeddedOptions {
11
11
  }
12
12
  export interface EmbeddedNamesHolder {
13
13
  }
14
- export type EmbeddedNames = keyof EmbeddedNamesHolder;
14
+ export type EmbeddedName = keyof EmbeddedNamesHolder;
@@ -1,7 +1,7 @@
1
- import { Expression, Comment, TemplateLiteral } from "estree";
2
- import { AstPath, Options } from "prettier";
1
+ import type { Expression, Comment, TemplateLiteral } from "estree";
2
+ import type { AstPath, Options } from "prettier";
3
3
  import { builders } from "prettier/doc";
4
- import { InternalPrintFun } from "../types.js";
4
+ import type { InternalPrintFun } from "../types.js";
5
5
  export declare function printTemplateExpression(path: AstPath<Expression & {
6
6
  comments?: Comment[];
7
7
  }>, print: InternalPrintFun): builders.Doc[];
@@ -1,4 +1,4 @@
1
- import { SupportOption } from "prettier";
1
+ import type { SupportOption } from "prettier";
2
2
  import { name } from "./name.js";
3
3
  export declare const option: SupportOption;
4
4
  declare module "../types.js" {
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import K from "prettier/parser-typescript";
5
5
  import { builders as E, utils as N } from "prettier/doc";
6
6
  import { parse as Y } from "@xml-tools/parser";
7
7
  import { printers as Z } from "prettier/plugins/estree.mjs";
8
- const C = "embeddedNoop", ee = {
8
+ const P = "embeddedNoop", ee = {
9
9
  category: "Global",
10
10
  type: "string",
11
11
  array: !0,
@@ -13,7 +13,7 @@ const C = "embeddedNoop", ee = {
13
13
  description: "Specify embedded languages that will not be formatted."
14
14
  }, te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
15
15
  __proto__: null,
16
- name: C,
16
+ name: P,
17
17
  option: ee
18
18
  }, Symbol.toStringTag, { value: "Module" })), ne = "embeddedPhp";
19
19
  let S;
@@ -29,12 +29,12 @@ for (let e = 0; e < 256; ++e)
29
29
  function se(e, t = 0) {
30
30
  return c[e[t + 0]] + c[e[t + 1]] + c[e[t + 2]] + c[e[t + 3]] + "-" + c[e[t + 4]] + c[e[t + 5]] + "-" + c[e[t + 6]] + c[e[t + 7]] + "-" + c[e[t + 8]] + c[e[t + 9]] + "-" + c[e[t + 10]] + c[e[t + 11]] + c[e[t + 12]] + c[e[t + 13]] + c[e[t + 14]] + c[e[t + 15]];
31
31
  }
32
- const ie = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), I = {
32
+ const ie = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), L = {
33
33
  randomUUID: ie
34
34
  };
35
35
  function k(e, t, n) {
36
- if (I.randomUUID && !t && !e)
37
- return I.randomUUID();
36
+ if (L.randomUUID && !t && !e)
37
+ return L.randomUUID();
38
38
  e = e || {};
39
39
  const o = e.random || (e.rng || oe)();
40
40
  if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, t) {
@@ -45,12 +45,12 @@ function k(e, t, n) {
45
45
  }
46
46
  return se(o);
47
47
  }
48
- const { group: le, indent: ce, softline: U, lineSuffixBoundary: ae } = E;
48
+ const { group: le, indent: ce, softline: I, lineSuffixBoundary: ae } = E;
49
49
  function ue(e, t) {
50
50
  var r;
51
51
  const { node: n } = e;
52
52
  let o = t();
53
- return (r = n == null ? void 0 : n.comments) != null && r.length && (o = le([ce([U, o]), U])), ["${", o, ae, "}"];
53
+ return (r = n == null ? void 0 : n.comments) != null && r.length && (o = le([ce([I, o]), I])), ["${", o, ae, "}"];
54
54
  }
55
55
  function j(e, t) {
56
56
  return e.map(
@@ -146,7 +146,7 @@ const { label: pe, hardline: me, line: ge, group: w, indent: fe } = E, { mapDoc:
146
146
  array: !0,
147
147
  default: [{ value: ["sql"] }],
148
148
  description: "Specify embedded SQL languages. This requires prettier-plugin-sql"
149
- }, G = [
149
+ }, C = [
150
150
  "sql",
151
151
  "bigquery",
152
152
  "hive",
@@ -163,7 +163,7 @@ const { label: pe, hardline: me, line: ge, group: w, indent: fe } = E, { mapDoc:
163
163
  "transactsql",
164
164
  "tsql",
165
165
  "trino"
166
- ], W = [
166
+ ], G = [
167
167
  "bigquery",
168
168
  "db2",
169
169
  "hive",
@@ -172,7 +172,7 @@ const { label: pe, hardline: me, line: ge, group: w, indent: fe } = E, { mapDoc:
172
172
  "postgresql",
173
173
  "transactsql",
174
174
  "flinksql"
175
- ], { label: ve, hardline: R, group: O, line: qe, indent: Ee } = E, { mapDoc: Se } = N, we = async (e, t, n, o, r, s) => {
175
+ ], { label: ve, hardline: U, group: O, line: qe, indent: Ee } = E, { mapDoc: Se } = N, we = async (e, t, n, o, r, s) => {
176
176
  try {
177
177
  A("prettier-plugin-sql", o, r);
178
178
  const a = "p" + k().replaceAll("-", ""), { node: b } = n, d = b.quasis.map(
@@ -196,7 +196,7 @@ const { label: pe, hardline: me, line: ge, group: w, indent: fe } = E, { mapDoc:
196
196
  continue;
197
197
  f = f.replaceAll(/([\\`]|\${)/g, "\\$1"), f.split(/(\n)/).forEach(
198
198
  (v) => v === `
199
- ` ? (h = !0, l.push(R)) : l.push(v)
199
+ ` ? (h = !0, l.push(U)) : l.push(v)
200
200
  );
201
201
  } else {
202
202
  const v = Number(f);
@@ -204,7 +204,7 @@ const { label: pe, hardline: me, line: ge, group: w, indent: fe } = E, { mapDoc:
204
204
  }
205
205
  }
206
206
  return l;
207
- }), p = h ? R : y && g ? qe : null;
207
+ }), p = h ? U : y && g ? qe : null;
208
208
  return p ? O([
209
209
  "`",
210
210
  Ee([p, O($)]),
@@ -224,10 +224,10 @@ const { label: pe, hardline: me, line: ge, group: w, indent: fe } = E, { mapDoc:
224
224
  throw console.error(a), a;
225
225
  }
226
226
  }, Oe = {
227
- "sql-formatter": (e) => G.includes(e),
228
- "node-sql-parser": (e) => W.includes(e)
227
+ "sql-formatter": (e) => C.includes(e),
228
+ "node-sql-parser": (e) => G.includes(e)
229
229
  };
230
- function B(e, t) {
230
+ function R(e, t) {
231
231
  for (const n of t)
232
232
  if (Oe[n](e))
233
233
  return {
@@ -235,33 +235,33 @@ function B(e, t) {
235
235
  language: e
236
236
  };
237
237
  }
238
- function F(e, t, n) {
239
- let o = B(e, n);
238
+ function B(e, t, n) {
239
+ let o = R(e, n);
240
240
  if (o)
241
241
  return o;
242
242
  const r = t.indexOf(e);
243
243
  for (let s = r - 1; s >= 0; --s)
244
- if (o = B(t[s], n), o)
244
+ if (o = R(t[s], n), o)
245
245
  return o;
246
246
  }
247
247
  function Te(e, t, n) {
248
- return e.formatter === "sql-formatter" ? F(t, n, [
248
+ return e.formatter === "sql-formatter" ? B(t, n, [
249
249
  "sql-formatter",
250
250
  "node-sql-parser"
251
- ]) : F(t, n, [
251
+ ]) : B(t, n, [
252
252
  "node-sql-parser",
253
253
  "sql-formatter"
254
254
  ]);
255
255
  }
256
256
  const De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
257
257
  __proto__: null,
258
- NODE_SQL_PARSER_DATABASES: W,
259
- SQL_FORMATTER_LANGUAGES: G,
258
+ NODE_SQL_PARSER_DATABASES: G,
259
+ SQL_FORMATTER_LANGUAGES: C,
260
260
  embedder: we,
261
261
  name: xe,
262
262
  option: _e
263
- }, Symbol.toStringTag, { value: "Module" })), M = "embeddedXml";
264
- function P(e, t) {
263
+ }, Symbol.toStringTag, { value: "Module" })), W = "embeddedXml";
264
+ function F(e, t) {
265
265
  const n = new SyntaxError(
266
266
  e + " (" + t.loc.start.line + ":" + t.loc.start.column + ")"
267
267
  );
@@ -272,7 +272,7 @@ const Ne = {
272
272
  const { lexErrors: t, parseErrors: n, cst: o } = Y(e);
273
273
  if (t.length > 0) {
274
274
  const r = t[0];
275
- throw P(r.message, {
275
+ throw F(r.message, {
276
276
  loc: {
277
277
  start: { line: r.line, column: r.column },
278
278
  end: {
@@ -284,7 +284,7 @@ const Ne = {
284
284
  }
285
285
  if (n.length > 0) {
286
286
  const r = n[0];
287
- throw P(r.message, {
287
+ throw F(r.message, {
288
288
  loc: {
289
289
  start: {
290
290
  line: r.token.startLine ?? NaN,
@@ -316,7 +316,7 @@ const Ne = {
316
316
  const g = /^\s+/.exec(b);
317
317
  g && (y = g.index + g[0].length, d = " ");
318
318
  const x = /\s$/.test(b) ? " " : "", _ = j(n, t), q = await e(b.slice(y), {
319
- parser: M
319
+ parser: W
320
320
  }), h = Ie(q, (p) => {
321
321
  if (typeof p != "string")
322
322
  return p;
@@ -361,17 +361,17 @@ const Ne = {
361
361
  }, Be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
362
362
  __proto__: null,
363
363
  embedder: Ue,
364
- name: M,
364
+ name: W,
365
365
  option: Re,
366
366
  parser: Ne
367
- }, Symbol.toStringTag, { value: "Module" })), L = [], z = {}, V = {}, Q = {}, Fe = /* @__PURE__ */ Object.assign({
367
+ }, Symbol.toStringTag, { value: "Module" })), M = [], z = {}, V = {}, Q = {}, Fe = /* @__PURE__ */ Object.assign({
368
368
  "./noop/index.ts": te,
369
369
  "./php/index.ts": $e,
370
370
  "./sql/index.ts": De,
371
371
  "./xml/index.ts": Be
372
372
  });
373
373
  Object.values(Fe).forEach(({ name: e, parser: t, embedder: n, option: o }) => {
374
- de(L, e, C), t && (z[e] = t), n && (V[e] = n), Q[e] = o;
374
+ de(M, e, P), t && (z[e] = t), n && (V[e] = n), Q[e] = o;
375
375
  });
376
376
  const Je = {
377
377
  // parsers from internal
@@ -382,22 +382,20 @@ const Je = {
382
382
  ...K.parsers,
383
383
  // parsers from this plugin
384
384
  ...z
385
- };
386
- console.log(L);
387
- const { estree: D } = Z, Pe = function(e, t) {
385
+ }, { estree: D } = Z, Pe = function(e, t) {
388
386
  var o;
389
387
  const { node: n } = e;
390
388
  if (n.type !== "TemplateLiteral" || n.quasis.some(({ value: { cooked: r } }) => r === null))
391
389
  return null;
392
- for (const r of L) {
390
+ for (const r of M) {
393
391
  const s = t[r];
394
392
  if (!s)
395
393
  continue;
396
394
  const a = Ce(
397
395
  e,
398
396
  s,
399
- t.disableEmbeddedDetectionByComment ?? []
400
- ) ?? Ge(e, s, t.disableEmbeddedDetectionByTag ?? []);
397
+ t.noEmbeddedDetectionByComment ?? []
398
+ ) ?? Ge(e, s, t.noEmbeddedDetectionByTag ?? []);
401
399
  if (a === void 0)
402
400
  continue;
403
401
  const b = V[r];
@@ -441,14 +439,14 @@ const Ke = {
441
439
  }
442
440
  }, Ye = {
443
441
  ...Q,
444
- disableEmbeddedDetectionByComment: {
442
+ noEmbeddedDetectionByComment: {
445
443
  category: "Global",
446
444
  type: "string",
447
445
  array: !0,
448
446
  default: [{ value: [] }],
449
447
  description: 'This option turns off "/* lang */`...`" comment-based language detection for the specified languages.'
450
448
  },
451
- disableEmbeddedDetectionByTag: {
449
+ noEmbeddedDetectionByTag: {
452
450
  category: "Global",
453
451
  type: "string",
454
452
  array: !0,
@@ -458,7 +456,7 @@ const Ke = {
458
456
  };
459
457
  export {
460
458
  V as embeddedEmbedders,
461
- L as embeddedNames,
459
+ M as embeddedNames,
462
460
  Q as embeddedOptions,
463
461
  z as embeddedParsers,
464
462
  Ye as options,
package/dist/options.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { SupportOptions } from "prettier";
2
2
  export declare const options: SupportOptions;
3
3
  declare module "prettier" {
4
4
  interface Options {
5
- disableEmbeddedDetectionByComment?: string[];
6
- disableEmbeddedDetectionByTag?: string[];
5
+ noEmbeddedDetectionByComment?: string[];
6
+ noEmbeddedDetectionByTag?: string[];
7
7
  }
8
8
  }
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options, Doc, AstPath } from "prettier";
1
+ import type { Options, Doc, AstPath } from "prettier";
2
2
  import type { Node as EsTreeNode, TemplateLiteral, Comment } from "estree";
3
3
  export type PrettierNode = EsTreeNode & {
4
4
  comments?: (Comment & {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "prettier-plugin-embed",
3
3
  "description": "A prettier plugin to format embedded languages in js/ts files.",
4
4
  "private": false,
5
- "version": "0.0.3",
5
+ "version": "0.0.4",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "./dist"
@@ -46,7 +46,8 @@
46
46
  "format": "prettier . --write",
47
47
  "prebuild": "npm run lint && npm run type-check && npm run format",
48
48
  "build": "vite build",
49
- "postbuild": "tsc",
49
+ "add-glob-import-types": "tsx ./scripts/add-glob-import-types.ts",
50
+ "postbuild": "tsc --project ./tsconfig.production.json && npm run add-glob-import-types",
50
51
  "test": "vitest",
51
52
  "test:ui": "vitest --ui",
52
53
  "preview": "vite preview",
@@ -72,10 +73,12 @@
72
73
  "@vitest/ui": "^0.34.6",
73
74
  "code-tag": "^1.1.0",
74
75
  "eslint": "^8.50.0",
76
+ "fast-glob": "^3.3.1",
75
77
  "npm-check-updates": "^16.14.5",
76
78
  "playwright": "^1.38.1",
77
79
  "prettier-plugin-sql": "^0.15.1",
78
80
  "semantic-release": "^22.0.5",
81
+ "tsx": "^3.13.0",
79
82
  "typescript": "^5.2.2",
80
83
  "vite": "^4.4.11",
81
84
  "vitest": "^0.34.6"