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