@xyd-js/cli 0.1.0-xyd.2 → 0.1.0-xyd.21

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 (83) hide show
  1. package/.cli/bin.js +3 -0
  2. package/.cli/index.js +24939 -0
  3. package/.cli/package-lock.json +7943 -0
  4. package/.cli/package.json +37 -0
  5. package/.cli/plugins/xyd-plugin-zero/src/pages/api-reference.tsx +79 -202
  6. package/.cli/plugins/xyd-plugin-zero/src/pages/docs.tsx +12 -3
  7. package/package.json +15 -17
  8. package/postinstall.js +15 -0
  9. package/.cli/dist/index.js +0 -12417
  10. package/.cli/host/.react-router/types/app/+types/root.ts +0 -40
  11. package/.cli/host/node_modules/.vite/deps/@mdx-js_mdx.js +0 -81
  12. package/.cli/host/node_modules/.vite/deps/@mdx-js_mdx.js.map +0 -7
  13. package/.cli/host/node_modules/.vite/deps/@mdx-js_rollup.js +0 -4003
  14. package/.cli/host/node_modules/.vite/deps/@mdx-js_rollup.js.map +0 -7
  15. package/.cli/host/node_modules/.vite/deps/@radix-ui_react-icons.js +0 -7531
  16. package/.cli/host/node_modules/.vite/deps/@radix-ui_react-icons.js.map +0 -7
  17. package/.cli/host/node_modules/.vite/deps/@radix-ui_react-tabs.js +0 -917
  18. package/.cli/host/node_modules/.vite/deps/@radix-ui_react-tabs.js.map +0 -7
  19. package/.cli/host/node_modules/.vite/deps/_metadata.json +0 -157
  20. package/.cli/host/node_modules/.vite/deps/chunk-2TUXWMP5.js +0 -46
  21. package/.cli/host/node_modules/.vite/deps/chunk-2TUXWMP5.js.map +0 -7
  22. package/.cli/host/node_modules/.vite/deps/chunk-DNIFH2K7.js +0 -3461
  23. package/.cli/host/node_modules/.vite/deps/chunk-DNIFH2K7.js.map +0 -7
  24. package/.cli/host/node_modules/.vite/deps/chunk-ERHH4CDL.js +0 -23875
  25. package/.cli/host/node_modules/.vite/deps/chunk-ERHH4CDL.js.map +0 -7
  26. package/.cli/host/node_modules/.vite/deps/chunk-ETJV5QNK.js +0 -27
  27. package/.cli/host/node_modules/.vite/deps/chunk-ETJV5QNK.js.map +0 -7
  28. package/.cli/host/node_modules/.vite/deps/chunk-GPEJJ3KZ.js +0 -1906
  29. package/.cli/host/node_modules/.vite/deps/chunk-GPEJJ3KZ.js.map +0 -7
  30. package/.cli/host/node_modules/.vite/deps/chunk-IVP26VTC.js +0 -21
  31. package/.cli/host/node_modules/.vite/deps/chunk-IVP26VTC.js.map +0 -7
  32. package/.cli/host/node_modules/.vite/deps/chunk-MJUUSK53.js +0 -894
  33. package/.cli/host/node_modules/.vite/deps/chunk-MJUUSK53.js.map +0 -7
  34. package/.cli/host/node_modules/.vite/deps/chunk-NHN7DW4J.js +0 -928
  35. package/.cli/host/node_modules/.vite/deps/chunk-NHN7DW4J.js.map +0 -7
  36. package/.cli/host/node_modules/.vite/deps/chunk-OO6QDGMA.js +0 -10609
  37. package/.cli/host/node_modules/.vite/deps/chunk-OO6QDGMA.js.map +0 -7
  38. package/.cli/host/node_modules/.vite/deps/chunk-OUN4SSIE.js +0 -205
  39. package/.cli/host/node_modules/.vite/deps/chunk-OUN4SSIE.js.map +0 -7
  40. package/.cli/host/node_modules/.vite/deps/chunk-TKNG6GUJ.js +0 -894
  41. package/.cli/host/node_modules/.vite/deps/chunk-TKNG6GUJ.js.map +0 -7
  42. package/.cli/host/node_modules/.vite/deps/chunk-TM4FKLNO.js +0 -21628
  43. package/.cli/host/node_modules/.vite/deps/chunk-TM4FKLNO.js.map +0 -7
  44. package/.cli/host/node_modules/.vite/deps/chunk-V2IF7L2E.js +0 -12
  45. package/.cli/host/node_modules/.vite/deps/chunk-V2IF7L2E.js.map +0 -7
  46. package/.cli/host/node_modules/.vite/deps/gray-matter.js +0 -3492
  47. package/.cli/host/node_modules/.vite/deps/gray-matter.js.map +0 -7
  48. package/.cli/host/node_modules/.vite/deps/lucide-react.js +0 -34742
  49. package/.cli/host/node_modules/.vite/deps/lucide-react.js.map +0 -7
  50. package/.cli/host/node_modules/.vite/deps/package.json +0 -3
  51. package/.cli/host/node_modules/.vite/deps/react-dom.js +0 -7
  52. package/.cli/host/node_modules/.vite/deps/react-dom.js.map +0 -7
  53. package/.cli/host/node_modules/.vite/deps/react-dom_client.js +0 -39
  54. package/.cli/host/node_modules/.vite/deps/react-dom_client.js.map +0 -7
  55. package/.cli/host/node_modules/.vite/deps/react-router.js +0 -243
  56. package/.cli/host/node_modules/.vite/deps/react-router.js.map +0 -7
  57. package/.cli/host/node_modules/.vite/deps/react-router_dom.js +0 -212
  58. package/.cli/host/node_modules/.vite/deps/react-router_dom.js.map +0 -7
  59. package/.cli/host/node_modules/.vite/deps/react.js +0 -6
  60. package/.cli/host/node_modules/.vite/deps/react.js.map +0 -7
  61. package/.cli/host/node_modules/.vite/deps/react_jsx-dev-runtime.js +0 -913
  62. package/.cli/host/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +0 -7
  63. package/.cli/host/node_modules/.vite/deps/react_jsx-runtime.js +0 -7
  64. package/.cli/host/node_modules/.vite/deps/react_jsx-runtime.js.map +0 -7
  65. package/.cli/host/node_modules/.vite/deps/remark-frontmatter.js +0 -428
  66. package/.cli/host/node_modules/.vite/deps/remark-frontmatter.js.map +0 -7
  67. package/.cli/host/node_modules/.vite/deps/remark-gfm.js +0 -3122
  68. package/.cli/host/node_modules/.vite/deps/remark-gfm.js.map +0 -7
  69. package/.cli/host/node_modules/.vite/deps/remark-mdx-frontmatter.js +0 -10482
  70. package/.cli/host/node_modules/.vite/deps/remark-mdx-frontmatter.js.map +0 -7
  71. package/.cli/host/node_modules/.vite/deps/unist-util-visit.js +0 -14
  72. package/.cli/host/node_modules/.vite/deps/unist-util-visit.js.map +0 -7
  73. package/.cli/host/node_modules/.vite/deps/vfile.js +0 -8
  74. package/.cli/host/node_modules/.vite/deps/vfile.js.map +0 -7
  75. package/.cli/host/package.json +0 -43
  76. package/bin.js +0 -3
  77. /package/.cli/{host/app → app}/root.tsx +0 -0
  78. /package/.cli/{host/app → app}/routes.ts +0 -0
  79. /package/.cli/{dist/index.d.ts → index.d.ts} +0 -0
  80. /package/.cli/{host/postcss.config.cjs → postcss.config.cjs} +0 -0
  81. /package/.cli/{host/react-router.config.ts → react-router.config.ts} +0 -0
  82. /package/.cli/{host/tsconfig.json → tsconfig.json} +0 -0
  83. /package/.cli/{host/vite.config.ts → vite.config.ts} +0 -0
@@ -1,894 +0,0 @@
1
- // ../node_modules/.pnpm/unist-util-stringify-position@4.0.0/node_modules/unist-util-stringify-position/lib/index.js
2
- function stringifyPosition(value) {
3
- if (!value || typeof value !== "object") {
4
- return "";
5
- }
6
- if ("position" in value || "type" in value) {
7
- return position(value.position);
8
- }
9
- if ("start" in value || "end" in value) {
10
- return position(value);
11
- }
12
- if ("line" in value || "column" in value) {
13
- return point(value);
14
- }
15
- return "";
16
- }
17
- function point(point2) {
18
- return index(point2 && point2.line) + ":" + index(point2 && point2.column);
19
- }
20
- function position(pos) {
21
- return point(pos && pos.start) + "-" + point(pos && pos.end);
22
- }
23
- function index(value) {
24
- return value && typeof value === "number" ? value : 1;
25
- }
26
-
27
- // ../node_modules/.pnpm/vfile-message@4.0.2/node_modules/vfile-message/lib/index.js
28
- var VFileMessage = class extends Error {
29
- /**
30
- * Create a message for `reason`.
31
- *
32
- * > 🪦 **Note**: also has obsolete signatures.
33
- *
34
- * @overload
35
- * @param {string} reason
36
- * @param {Options | null | undefined} [options]
37
- * @returns
38
- *
39
- * @overload
40
- * @param {string} reason
41
- * @param {Node | NodeLike | null | undefined} parent
42
- * @param {string | null | undefined} [origin]
43
- * @returns
44
- *
45
- * @overload
46
- * @param {string} reason
47
- * @param {Point | Position | null | undefined} place
48
- * @param {string | null | undefined} [origin]
49
- * @returns
50
- *
51
- * @overload
52
- * @param {string} reason
53
- * @param {string | null | undefined} [origin]
54
- * @returns
55
- *
56
- * @overload
57
- * @param {Error | VFileMessage} cause
58
- * @param {Node | NodeLike | null | undefined} parent
59
- * @param {string | null | undefined} [origin]
60
- * @returns
61
- *
62
- * @overload
63
- * @param {Error | VFileMessage} cause
64
- * @param {Point | Position | null | undefined} place
65
- * @param {string | null | undefined} [origin]
66
- * @returns
67
- *
68
- * @overload
69
- * @param {Error | VFileMessage} cause
70
- * @param {string | null | undefined} [origin]
71
- * @returns
72
- *
73
- * @param {Error | VFileMessage | string} causeOrReason
74
- * Reason for message, should use markdown.
75
- * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
76
- * Configuration (optional).
77
- * @param {string | null | undefined} [origin]
78
- * Place in code where the message originates (example:
79
- * `'my-package:my-rule'` or `'my-rule'`).
80
- * @returns
81
- * Instance of `VFileMessage`.
82
- */
83
- // eslint-disable-next-line complexity
84
- constructor(causeOrReason, optionsOrParentOrPlace, origin) {
85
- super();
86
- if (typeof optionsOrParentOrPlace === "string") {
87
- origin = optionsOrParentOrPlace;
88
- optionsOrParentOrPlace = void 0;
89
- }
90
- let reason = "";
91
- let options = {};
92
- let legacyCause = false;
93
- if (optionsOrParentOrPlace) {
94
- if ("line" in optionsOrParentOrPlace && "column" in optionsOrParentOrPlace) {
95
- options = { place: optionsOrParentOrPlace };
96
- } else if ("start" in optionsOrParentOrPlace && "end" in optionsOrParentOrPlace) {
97
- options = { place: optionsOrParentOrPlace };
98
- } else if ("type" in optionsOrParentOrPlace) {
99
- options = {
100
- ancestors: [optionsOrParentOrPlace],
101
- place: optionsOrParentOrPlace.position
102
- };
103
- } else {
104
- options = { ...optionsOrParentOrPlace };
105
- }
106
- }
107
- if (typeof causeOrReason === "string") {
108
- reason = causeOrReason;
109
- } else if (!options.cause && causeOrReason) {
110
- legacyCause = true;
111
- reason = causeOrReason.message;
112
- options.cause = causeOrReason;
113
- }
114
- if (!options.ruleId && !options.source && typeof origin === "string") {
115
- const index2 = origin.indexOf(":");
116
- if (index2 === -1) {
117
- options.ruleId = origin;
118
- } else {
119
- options.source = origin.slice(0, index2);
120
- options.ruleId = origin.slice(index2 + 1);
121
- }
122
- }
123
- if (!options.place && options.ancestors && options.ancestors) {
124
- const parent = options.ancestors[options.ancestors.length - 1];
125
- if (parent) {
126
- options.place = parent.position;
127
- }
128
- }
129
- const start = options.place && "start" in options.place ? options.place.start : options.place;
130
- this.ancestors = options.ancestors || void 0;
131
- this.cause = options.cause || void 0;
132
- this.column = start ? start.column : void 0;
133
- this.fatal = void 0;
134
- this.file;
135
- this.message = reason;
136
- this.line = start ? start.line : void 0;
137
- this.name = stringifyPosition(options.place) || "1:1";
138
- this.place = options.place || void 0;
139
- this.reason = this.message;
140
- this.ruleId = options.ruleId || void 0;
141
- this.source = options.source || void 0;
142
- this.stack = legacyCause && options.cause && typeof options.cause.stack === "string" ? options.cause.stack : "";
143
- this.actual;
144
- this.expected;
145
- this.note;
146
- this.url;
147
- }
148
- };
149
- VFileMessage.prototype.file = "";
150
- VFileMessage.prototype.name = "";
151
- VFileMessage.prototype.reason = "";
152
- VFileMessage.prototype.message = "";
153
- VFileMessage.prototype.stack = "";
154
- VFileMessage.prototype.column = void 0;
155
- VFileMessage.prototype.line = void 0;
156
- VFileMessage.prototype.ancestors = void 0;
157
- VFileMessage.prototype.cause = void 0;
158
- VFileMessage.prototype.fatal = void 0;
159
- VFileMessage.prototype.place = void 0;
160
- VFileMessage.prototype.ruleId = void 0;
161
- VFileMessage.prototype.source = void 0;
162
-
163
- // ../node_modules/.pnpm/vfile@6.0.3/node_modules/vfile/lib/minpath.browser.js
164
- var minpath = { basename, dirname, extname, join, sep: "/" };
165
- function basename(path, extname2) {
166
- if (extname2 !== void 0 && typeof extname2 !== "string") {
167
- throw new TypeError('"ext" argument must be a string');
168
- }
169
- assertPath(path);
170
- let start = 0;
171
- let end = -1;
172
- let index2 = path.length;
173
- let seenNonSlash;
174
- if (extname2 === void 0 || extname2.length === 0 || extname2.length > path.length) {
175
- while (index2--) {
176
- if (path.codePointAt(index2) === 47) {
177
- if (seenNonSlash) {
178
- start = index2 + 1;
179
- break;
180
- }
181
- } else if (end < 0) {
182
- seenNonSlash = true;
183
- end = index2 + 1;
184
- }
185
- }
186
- return end < 0 ? "" : path.slice(start, end);
187
- }
188
- if (extname2 === path) {
189
- return "";
190
- }
191
- let firstNonSlashEnd = -1;
192
- let extnameIndex = extname2.length - 1;
193
- while (index2--) {
194
- if (path.codePointAt(index2) === 47) {
195
- if (seenNonSlash) {
196
- start = index2 + 1;
197
- break;
198
- }
199
- } else {
200
- if (firstNonSlashEnd < 0) {
201
- seenNonSlash = true;
202
- firstNonSlashEnd = index2 + 1;
203
- }
204
- if (extnameIndex > -1) {
205
- if (path.codePointAt(index2) === extname2.codePointAt(extnameIndex--)) {
206
- if (extnameIndex < 0) {
207
- end = index2;
208
- }
209
- } else {
210
- extnameIndex = -1;
211
- end = firstNonSlashEnd;
212
- }
213
- }
214
- }
215
- }
216
- if (start === end) {
217
- end = firstNonSlashEnd;
218
- } else if (end < 0) {
219
- end = path.length;
220
- }
221
- return path.slice(start, end);
222
- }
223
- function dirname(path) {
224
- assertPath(path);
225
- if (path.length === 0) {
226
- return ".";
227
- }
228
- let end = -1;
229
- let index2 = path.length;
230
- let unmatchedSlash;
231
- while (--index2) {
232
- if (path.codePointAt(index2) === 47) {
233
- if (unmatchedSlash) {
234
- end = index2;
235
- break;
236
- }
237
- } else if (!unmatchedSlash) {
238
- unmatchedSlash = true;
239
- }
240
- }
241
- return end < 0 ? path.codePointAt(0) === 47 ? "/" : "." : end === 1 && path.codePointAt(0) === 47 ? "//" : path.slice(0, end);
242
- }
243
- function extname(path) {
244
- assertPath(path);
245
- let index2 = path.length;
246
- let end = -1;
247
- let startPart = 0;
248
- let startDot = -1;
249
- let preDotState = 0;
250
- let unmatchedSlash;
251
- while (index2--) {
252
- const code = path.codePointAt(index2);
253
- if (code === 47) {
254
- if (unmatchedSlash) {
255
- startPart = index2 + 1;
256
- break;
257
- }
258
- continue;
259
- }
260
- if (end < 0) {
261
- unmatchedSlash = true;
262
- end = index2 + 1;
263
- }
264
- if (code === 46) {
265
- if (startDot < 0) {
266
- startDot = index2;
267
- } else if (preDotState !== 1) {
268
- preDotState = 1;
269
- }
270
- } else if (startDot > -1) {
271
- preDotState = -1;
272
- }
273
- }
274
- if (startDot < 0 || end < 0 || // We saw a non-dot character immediately before the dot.
275
- preDotState === 0 || // The (right-most) trimmed path component is exactly `..`.
276
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
277
- return "";
278
- }
279
- return path.slice(startDot, end);
280
- }
281
- function join(...segments) {
282
- let index2 = -1;
283
- let joined;
284
- while (++index2 < segments.length) {
285
- assertPath(segments[index2]);
286
- if (segments[index2]) {
287
- joined = joined === void 0 ? segments[index2] : joined + "/" + segments[index2];
288
- }
289
- }
290
- return joined === void 0 ? "." : normalize(joined);
291
- }
292
- function normalize(path) {
293
- assertPath(path);
294
- const absolute = path.codePointAt(0) === 47;
295
- let value = normalizeString(path, !absolute);
296
- if (value.length === 0 && !absolute) {
297
- value = ".";
298
- }
299
- if (value.length > 0 && path.codePointAt(path.length - 1) === 47) {
300
- value += "/";
301
- }
302
- return absolute ? "/" + value : value;
303
- }
304
- function normalizeString(path, allowAboveRoot) {
305
- let result = "";
306
- let lastSegmentLength = 0;
307
- let lastSlash = -1;
308
- let dots = 0;
309
- let index2 = -1;
310
- let code;
311
- let lastSlashIndex;
312
- while (++index2 <= path.length) {
313
- if (index2 < path.length) {
314
- code = path.codePointAt(index2);
315
- } else if (code === 47) {
316
- break;
317
- } else {
318
- code = 47;
319
- }
320
- if (code === 47) {
321
- if (lastSlash === index2 - 1 || dots === 1) {
322
- } else if (lastSlash !== index2 - 1 && dots === 2) {
323
- if (result.length < 2 || lastSegmentLength !== 2 || result.codePointAt(result.length - 1) !== 46 || result.codePointAt(result.length - 2) !== 46) {
324
- if (result.length > 2) {
325
- lastSlashIndex = result.lastIndexOf("/");
326
- if (lastSlashIndex !== result.length - 1) {
327
- if (lastSlashIndex < 0) {
328
- result = "";
329
- lastSegmentLength = 0;
330
- } else {
331
- result = result.slice(0, lastSlashIndex);
332
- lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
333
- }
334
- lastSlash = index2;
335
- dots = 0;
336
- continue;
337
- }
338
- } else if (result.length > 0) {
339
- result = "";
340
- lastSegmentLength = 0;
341
- lastSlash = index2;
342
- dots = 0;
343
- continue;
344
- }
345
- }
346
- if (allowAboveRoot) {
347
- result = result.length > 0 ? result + "/.." : "..";
348
- lastSegmentLength = 2;
349
- }
350
- } else {
351
- if (result.length > 0) {
352
- result += "/" + path.slice(lastSlash + 1, index2);
353
- } else {
354
- result = path.slice(lastSlash + 1, index2);
355
- }
356
- lastSegmentLength = index2 - lastSlash - 1;
357
- }
358
- lastSlash = index2;
359
- dots = 0;
360
- } else if (code === 46 && dots > -1) {
361
- dots++;
362
- } else {
363
- dots = -1;
364
- }
365
- }
366
- return result;
367
- }
368
- function assertPath(path) {
369
- if (typeof path !== "string") {
370
- throw new TypeError(
371
- "Path must be a string. Received " + JSON.stringify(path)
372
- );
373
- }
374
- }
375
-
376
- // ../node_modules/.pnpm/vfile@6.0.3/node_modules/vfile/lib/minproc.browser.js
377
- var minproc = { cwd };
378
- function cwd() {
379
- return "/";
380
- }
381
-
382
- // ../node_modules/.pnpm/vfile@6.0.3/node_modules/vfile/lib/minurl.shared.js
383
- function isUrl(fileUrlOrPath) {
384
- return Boolean(
385
- fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && "href" in fileUrlOrPath && fileUrlOrPath.href && "protocol" in fileUrlOrPath && fileUrlOrPath.protocol && // @ts-expect-error: indexing is fine.
386
- fileUrlOrPath.auth === void 0
387
- );
388
- }
389
-
390
- // ../node_modules/.pnpm/vfile@6.0.3/node_modules/vfile/lib/minurl.browser.js
391
- function urlToPath(path) {
392
- if (typeof path === "string") {
393
- path = new URL(path);
394
- } else if (!isUrl(path)) {
395
- const error = new TypeError(
396
- 'The "path" argument must be of type string or an instance of URL. Received `' + path + "`"
397
- );
398
- error.code = "ERR_INVALID_ARG_TYPE";
399
- throw error;
400
- }
401
- if (path.protocol !== "file:") {
402
- const error = new TypeError("The URL must be of scheme file");
403
- error.code = "ERR_INVALID_URL_SCHEME";
404
- throw error;
405
- }
406
- return getPathFromURLPosix(path);
407
- }
408
- function getPathFromURLPosix(url) {
409
- if (url.hostname !== "") {
410
- const error = new TypeError(
411
- 'File URL host must be "localhost" or empty on darwin'
412
- );
413
- error.code = "ERR_INVALID_FILE_URL_HOST";
414
- throw error;
415
- }
416
- const pathname = url.pathname;
417
- let index2 = -1;
418
- while (++index2 < pathname.length) {
419
- if (pathname.codePointAt(index2) === 37 && pathname.codePointAt(index2 + 1) === 50) {
420
- const third = pathname.codePointAt(index2 + 2);
421
- if (third === 70 || third === 102) {
422
- const error = new TypeError(
423
- "File URL path must not include encoded / characters"
424
- );
425
- error.code = "ERR_INVALID_FILE_URL_PATH";
426
- throw error;
427
- }
428
- }
429
- }
430
- return decodeURIComponent(pathname);
431
- }
432
-
433
- // ../node_modules/.pnpm/vfile@6.0.3/node_modules/vfile/lib/index.js
434
- var order = (
435
- /** @type {const} */
436
- [
437
- "history",
438
- "path",
439
- "basename",
440
- "stem",
441
- "extname",
442
- "dirname"
443
- ]
444
- );
445
- var VFile = class {
446
- /**
447
- * Create a new virtual file.
448
- *
449
- * `options` is treated as:
450
- *
451
- * * `string` or `Uint8Array` — `{value: options}`
452
- * * `URL` — `{path: options}`
453
- * * `VFile` — shallow copies its data over to the new file
454
- * * `object` — all fields are shallow copied over to the new file
455
- *
456
- * Path related fields are set in the following order (least specific to
457
- * most specific): `history`, `path`, `basename`, `stem`, `extname`,
458
- * `dirname`.
459
- *
460
- * You cannot set `dirname` or `extname` without setting either `history`,
461
- * `path`, `basename`, or `stem` too.
462
- *
463
- * @param {Compatible | null | undefined} [value]
464
- * File value.
465
- * @returns
466
- * New instance.
467
- */
468
- constructor(value) {
469
- let options;
470
- if (!value) {
471
- options = {};
472
- } else if (isUrl(value)) {
473
- options = { path: value };
474
- } else if (typeof value === "string" || isUint8Array(value)) {
475
- options = { value };
476
- } else {
477
- options = value;
478
- }
479
- this.cwd = "cwd" in options ? "" : minproc.cwd();
480
- this.data = {};
481
- this.history = [];
482
- this.messages = [];
483
- this.value;
484
- this.map;
485
- this.result;
486
- this.stored;
487
- let index2 = -1;
488
- while (++index2 < order.length) {
489
- const field2 = order[index2];
490
- if (field2 in options && options[field2] !== void 0 && options[field2] !== null) {
491
- this[field2] = field2 === "history" ? [...options[field2]] : options[field2];
492
- }
493
- }
494
- let field;
495
- for (field in options) {
496
- if (!order.includes(field)) {
497
- this[field] = options[field];
498
- }
499
- }
500
- }
501
- /**
502
- * Get the basename (including extname) (example: `'index.min.js'`).
503
- *
504
- * @returns {string | undefined}
505
- * Basename.
506
- */
507
- get basename() {
508
- return typeof this.path === "string" ? minpath.basename(this.path) : void 0;
509
- }
510
- /**
511
- * Set basename (including extname) (`'index.min.js'`).
512
- *
513
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
514
- * on windows).
515
- * Cannot be nullified (use `file.path = file.dirname` instead).
516
- *
517
- * @param {string} basename
518
- * Basename.
519
- * @returns {undefined}
520
- * Nothing.
521
- */
522
- set basename(basename2) {
523
- assertNonEmpty(basename2, "basename");
524
- assertPart(basename2, "basename");
525
- this.path = minpath.join(this.dirname || "", basename2);
526
- }
527
- /**
528
- * Get the parent path (example: `'~'`).
529
- *
530
- * @returns {string | undefined}
531
- * Dirname.
532
- */
533
- get dirname() {
534
- return typeof this.path === "string" ? minpath.dirname(this.path) : void 0;
535
- }
536
- /**
537
- * Set the parent path (example: `'~'`).
538
- *
539
- * Cannot be set if there’s no `path` yet.
540
- *
541
- * @param {string | undefined} dirname
542
- * Dirname.
543
- * @returns {undefined}
544
- * Nothing.
545
- */
546
- set dirname(dirname2) {
547
- assertPath2(this.basename, "dirname");
548
- this.path = minpath.join(dirname2 || "", this.basename);
549
- }
550
- /**
551
- * Get the extname (including dot) (example: `'.js'`).
552
- *
553
- * @returns {string | undefined}
554
- * Extname.
555
- */
556
- get extname() {
557
- return typeof this.path === "string" ? minpath.extname(this.path) : void 0;
558
- }
559
- /**
560
- * Set the extname (including dot) (example: `'.js'`).
561
- *
562
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
563
- * on windows).
564
- * Cannot be set if there’s no `path` yet.
565
- *
566
- * @param {string | undefined} extname
567
- * Extname.
568
- * @returns {undefined}
569
- * Nothing.
570
- */
571
- set extname(extname2) {
572
- assertPart(extname2, "extname");
573
- assertPath2(this.dirname, "extname");
574
- if (extname2) {
575
- if (extname2.codePointAt(0) !== 46) {
576
- throw new Error("`extname` must start with `.`");
577
- }
578
- if (extname2.includes(".", 1)) {
579
- throw new Error("`extname` cannot contain multiple dots");
580
- }
581
- }
582
- this.path = minpath.join(this.dirname, this.stem + (extname2 || ""));
583
- }
584
- /**
585
- * Get the full path (example: `'~/index.min.js'`).
586
- *
587
- * @returns {string}
588
- * Path.
589
- */
590
- get path() {
591
- return this.history[this.history.length - 1];
592
- }
593
- /**
594
- * Set the full path (example: `'~/index.min.js'`).
595
- *
596
- * Cannot be nullified.
597
- * You can set a file URL (a `URL` object with a `file:` protocol) which will
598
- * be turned into a path with `url.fileURLToPath`.
599
- *
600
- * @param {URL | string} path
601
- * Path.
602
- * @returns {undefined}
603
- * Nothing.
604
- */
605
- set path(path) {
606
- if (isUrl(path)) {
607
- path = urlToPath(path);
608
- }
609
- assertNonEmpty(path, "path");
610
- if (this.path !== path) {
611
- this.history.push(path);
612
- }
613
- }
614
- /**
615
- * Get the stem (basename w/o extname) (example: `'index.min'`).
616
- *
617
- * @returns {string | undefined}
618
- * Stem.
619
- */
620
- get stem() {
621
- return typeof this.path === "string" ? minpath.basename(this.path, this.extname) : void 0;
622
- }
623
- /**
624
- * Set the stem (basename w/o extname) (example: `'index.min'`).
625
- *
626
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
627
- * on windows).
628
- * Cannot be nullified (use `file.path = file.dirname` instead).
629
- *
630
- * @param {string} stem
631
- * Stem.
632
- * @returns {undefined}
633
- * Nothing.
634
- */
635
- set stem(stem) {
636
- assertNonEmpty(stem, "stem");
637
- assertPart(stem, "stem");
638
- this.path = minpath.join(this.dirname || "", stem + (this.extname || ""));
639
- }
640
- // Normal prototypal methods.
641
- /**
642
- * Create a fatal message for `reason` associated with the file.
643
- *
644
- * The `fatal` field of the message is set to `true` (error; file not usable)
645
- * and the `file` field is set to the current file path.
646
- * The message is added to the `messages` field on `file`.
647
- *
648
- * > 🪦 **Note**: also has obsolete signatures.
649
- *
650
- * @overload
651
- * @param {string} reason
652
- * @param {MessageOptions | null | undefined} [options]
653
- * @returns {never}
654
- *
655
- * @overload
656
- * @param {string} reason
657
- * @param {Node | NodeLike | null | undefined} parent
658
- * @param {string | null | undefined} [origin]
659
- * @returns {never}
660
- *
661
- * @overload
662
- * @param {string} reason
663
- * @param {Point | Position | null | undefined} place
664
- * @param {string | null | undefined} [origin]
665
- * @returns {never}
666
- *
667
- * @overload
668
- * @param {string} reason
669
- * @param {string | null | undefined} [origin]
670
- * @returns {never}
671
- *
672
- * @overload
673
- * @param {Error | VFileMessage} cause
674
- * @param {Node | NodeLike | null | undefined} parent
675
- * @param {string | null | undefined} [origin]
676
- * @returns {never}
677
- *
678
- * @overload
679
- * @param {Error | VFileMessage} cause
680
- * @param {Point | Position | null | undefined} place
681
- * @param {string | null | undefined} [origin]
682
- * @returns {never}
683
- *
684
- * @overload
685
- * @param {Error | VFileMessage} cause
686
- * @param {string | null | undefined} [origin]
687
- * @returns {never}
688
- *
689
- * @param {Error | VFileMessage | string} causeOrReason
690
- * Reason for message, should use markdown.
691
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
692
- * Configuration (optional).
693
- * @param {string | null | undefined} [origin]
694
- * Place in code where the message originates (example:
695
- * `'my-package:my-rule'` or `'my-rule'`).
696
- * @returns {never}
697
- * Never.
698
- * @throws {VFileMessage}
699
- * Message.
700
- */
701
- fail(causeOrReason, optionsOrParentOrPlace, origin) {
702
- const message = this.message(causeOrReason, optionsOrParentOrPlace, origin);
703
- message.fatal = true;
704
- throw message;
705
- }
706
- /**
707
- * Create an info message for `reason` associated with the file.
708
- *
709
- * The `fatal` field of the message is set to `undefined` (info; change
710
- * likely not needed) and the `file` field is set to the current file path.
711
- * The message is added to the `messages` field on `file`.
712
- *
713
- * > 🪦 **Note**: also has obsolete signatures.
714
- *
715
- * @overload
716
- * @param {string} reason
717
- * @param {MessageOptions | null | undefined} [options]
718
- * @returns {VFileMessage}
719
- *
720
- * @overload
721
- * @param {string} reason
722
- * @param {Node | NodeLike | null | undefined} parent
723
- * @param {string | null | undefined} [origin]
724
- * @returns {VFileMessage}
725
- *
726
- * @overload
727
- * @param {string} reason
728
- * @param {Point | Position | null | undefined} place
729
- * @param {string | null | undefined} [origin]
730
- * @returns {VFileMessage}
731
- *
732
- * @overload
733
- * @param {string} reason
734
- * @param {string | null | undefined} [origin]
735
- * @returns {VFileMessage}
736
- *
737
- * @overload
738
- * @param {Error | VFileMessage} cause
739
- * @param {Node | NodeLike | null | undefined} parent
740
- * @param {string | null | undefined} [origin]
741
- * @returns {VFileMessage}
742
- *
743
- * @overload
744
- * @param {Error | VFileMessage} cause
745
- * @param {Point | Position | null | undefined} place
746
- * @param {string | null | undefined} [origin]
747
- * @returns {VFileMessage}
748
- *
749
- * @overload
750
- * @param {Error | VFileMessage} cause
751
- * @param {string | null | undefined} [origin]
752
- * @returns {VFileMessage}
753
- *
754
- * @param {Error | VFileMessage | string} causeOrReason
755
- * Reason for message, should use markdown.
756
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
757
- * Configuration (optional).
758
- * @param {string | null | undefined} [origin]
759
- * Place in code where the message originates (example:
760
- * `'my-package:my-rule'` or `'my-rule'`).
761
- * @returns {VFileMessage}
762
- * Message.
763
- */
764
- info(causeOrReason, optionsOrParentOrPlace, origin) {
765
- const message = this.message(causeOrReason, optionsOrParentOrPlace, origin);
766
- message.fatal = void 0;
767
- return message;
768
- }
769
- /**
770
- * Create a message for `reason` associated with the file.
771
- *
772
- * The `fatal` field of the message is set to `false` (warning; change may be
773
- * needed) and the `file` field is set to the current file path.
774
- * The message is added to the `messages` field on `file`.
775
- *
776
- * > 🪦 **Note**: also has obsolete signatures.
777
- *
778
- * @overload
779
- * @param {string} reason
780
- * @param {MessageOptions | null | undefined} [options]
781
- * @returns {VFileMessage}
782
- *
783
- * @overload
784
- * @param {string} reason
785
- * @param {Node | NodeLike | null | undefined} parent
786
- * @param {string | null | undefined} [origin]
787
- * @returns {VFileMessage}
788
- *
789
- * @overload
790
- * @param {string} reason
791
- * @param {Point | Position | null | undefined} place
792
- * @param {string | null | undefined} [origin]
793
- * @returns {VFileMessage}
794
- *
795
- * @overload
796
- * @param {string} reason
797
- * @param {string | null | undefined} [origin]
798
- * @returns {VFileMessage}
799
- *
800
- * @overload
801
- * @param {Error | VFileMessage} cause
802
- * @param {Node | NodeLike | null | undefined} parent
803
- * @param {string | null | undefined} [origin]
804
- * @returns {VFileMessage}
805
- *
806
- * @overload
807
- * @param {Error | VFileMessage} cause
808
- * @param {Point | Position | null | undefined} place
809
- * @param {string | null | undefined} [origin]
810
- * @returns {VFileMessage}
811
- *
812
- * @overload
813
- * @param {Error | VFileMessage} cause
814
- * @param {string | null | undefined} [origin]
815
- * @returns {VFileMessage}
816
- *
817
- * @param {Error | VFileMessage | string} causeOrReason
818
- * Reason for message, should use markdown.
819
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
820
- * Configuration (optional).
821
- * @param {string | null | undefined} [origin]
822
- * Place in code where the message originates (example:
823
- * `'my-package:my-rule'` or `'my-rule'`).
824
- * @returns {VFileMessage}
825
- * Message.
826
- */
827
- message(causeOrReason, optionsOrParentOrPlace, origin) {
828
- const message = new VFileMessage(
829
- // @ts-expect-error: the overloads are fine.
830
- causeOrReason,
831
- optionsOrParentOrPlace,
832
- origin
833
- );
834
- if (this.path) {
835
- message.name = this.path + ":" + message.name;
836
- message.file = this.path;
837
- }
838
- message.fatal = false;
839
- this.messages.push(message);
840
- return message;
841
- }
842
- /**
843
- * Serialize the file.
844
- *
845
- * > **Note**: which encodings are supported depends on the engine.
846
- * > For info on Node.js, see:
847
- * > <https://nodejs.org/api/util.html#whatwg-supported-encodings>.
848
- *
849
- * @param {string | null | undefined} [encoding='utf8']
850
- * Character encoding to understand `value` as when it’s a `Uint8Array`
851
- * (default: `'utf-8'`).
852
- * @returns {string}
853
- * Serialized file.
854
- */
855
- toString(encoding) {
856
- if (this.value === void 0) {
857
- return "";
858
- }
859
- if (typeof this.value === "string") {
860
- return this.value;
861
- }
862
- const decoder = new TextDecoder(encoding || void 0);
863
- return decoder.decode(this.value);
864
- }
865
- };
866
- function assertPart(part, name) {
867
- if (part && part.includes(minpath.sep)) {
868
- throw new Error(
869
- "`" + name + "` cannot be a path: did not expect `" + minpath.sep + "`"
870
- );
871
- }
872
- }
873
- function assertNonEmpty(part, name) {
874
- if (!part) {
875
- throw new Error("`" + name + "` cannot be empty");
876
- }
877
- }
878
- function assertPath2(path, name) {
879
- if (!path) {
880
- throw new Error("Setting `" + name + "` requires `path` to be set too");
881
- }
882
- }
883
- function isUint8Array(value) {
884
- return Boolean(
885
- value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
886
- );
887
- }
888
-
889
- export {
890
- stringifyPosition,
891
- VFileMessage,
892
- VFile
893
- };
894
- //# sourceMappingURL=chunk-TKNG6GUJ.js.map