@harbour-enterprises/superdoc 0.28.0-next.10 → 0.28.0-next.12

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