@hyperbook/markdown 0.8.0 → 0.8.1

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.
package/dist/index.cjs.js CHANGED
@@ -22,6 +22,9 @@ var __spreadValues = (a, b) => {
22
22
  return a;
23
23
  };
24
24
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __commonJS = (cb, mod) => function __require() {
26
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
27
+ };
25
28
  var __export = (target, all) => {
26
29
  for (var name in all)
27
30
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -44,6 +47,106 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
44
47
  ));
45
48
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
49
 
50
+ // ../../node_modules/.pnpm/is-buffer@2.0.5/node_modules/is-buffer/index.js
51
+ var require_is_buffer = __commonJS({
52
+ "../../node_modules/.pnpm/is-buffer@2.0.5/node_modules/is-buffer/index.js"(exports, module2) {
53
+ module2.exports = function isBuffer2(obj) {
54
+ return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
55
+ };
56
+ }
57
+ });
58
+
59
+ // ../../node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js
60
+ var require_extend = __commonJS({
61
+ "../../node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js"(exports, module2) {
62
+ "use strict";
63
+ var hasOwn = Object.prototype.hasOwnProperty;
64
+ var toStr = Object.prototype.toString;
65
+ var defineProperty = Object.defineProperty;
66
+ var gOPD = Object.getOwnPropertyDescriptor;
67
+ var isArray = function isArray2(arr) {
68
+ if (typeof Array.isArray === "function") {
69
+ return Array.isArray(arr);
70
+ }
71
+ return toStr.call(arr) === "[object Array]";
72
+ };
73
+ var isPlainObject2 = function isPlainObject3(obj) {
74
+ if (!obj || toStr.call(obj) !== "[object Object]") {
75
+ return false;
76
+ }
77
+ var hasOwnConstructor = hasOwn.call(obj, "constructor");
78
+ var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
79
+ if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
80
+ return false;
81
+ }
82
+ var key;
83
+ for (key in obj) {
84
+ }
85
+ return typeof key === "undefined" || hasOwn.call(obj, key);
86
+ };
87
+ var setProperty = function setProperty2(target, options) {
88
+ if (defineProperty && options.name === "__proto__") {
89
+ defineProperty(target, options.name, {
90
+ enumerable: true,
91
+ configurable: true,
92
+ value: options.newValue,
93
+ writable: true
94
+ });
95
+ } else {
96
+ target[options.name] = options.newValue;
97
+ }
98
+ };
99
+ var getProperty = function getProperty2(obj, name) {
100
+ if (name === "__proto__") {
101
+ if (!hasOwn.call(obj, name)) {
102
+ return void 0;
103
+ } else if (gOPD) {
104
+ return gOPD(obj, name).value;
105
+ }
106
+ }
107
+ return obj[name];
108
+ };
109
+ module2.exports = function extend2() {
110
+ var options, name, src, copy, copyIsArray, clone;
111
+ var target = arguments[0];
112
+ var i = 1;
113
+ var length = arguments.length;
114
+ var deep = false;
115
+ if (typeof target === "boolean") {
116
+ deep = target;
117
+ target = arguments[1] || {};
118
+ i = 2;
119
+ }
120
+ if (target == null || typeof target !== "object" && typeof target !== "function") {
121
+ target = {};
122
+ }
123
+ for (; i < length; ++i) {
124
+ options = arguments[i];
125
+ if (options != null) {
126
+ for (name in options) {
127
+ src = getProperty(target, name);
128
+ copy = getProperty(options, name);
129
+ if (target !== copy) {
130
+ if (deep && copy && (isPlainObject2(copy) || (copyIsArray = isArray(copy)))) {
131
+ if (copyIsArray) {
132
+ copyIsArray = false;
133
+ clone = src && isArray(src) ? src : [];
134
+ } else {
135
+ clone = src && isPlainObject2(src) ? src : {};
136
+ }
137
+ setProperty(target, { name, newValue: extend2(deep, clone, copy) });
138
+ } else if (typeof copy !== "undefined") {
139
+ setProperty(target, { name, newValue: copy });
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ return target;
146
+ };
147
+ }
148
+ });
149
+
47
150
  // src/index.ts
48
151
  var src_exports = {};
49
152
  __export(src_exports, {
@@ -309,11 +412,11 @@ var Image = ({
309
412
  var import_unist_util_visit = require("unist-util-visit");
310
413
  var remarkRemoveComments = () => (tree) => {
311
414
  const htmlCommentRegex = /<!--([\s\S]*?)-->/g;
312
- const handler = (node, index, parent) => {
415
+ const handler = (node, index2, parent) => {
313
416
  const isComment = node.value.match(htmlCommentRegex);
314
417
  if (isComment) {
315
- parent.children.splice(index, 1);
316
- return [import_unist_util_visit.SKIP, index];
418
+ parent.children.splice(index2, 1);
419
+ return [import_unist_util_visit.SKIP, index2];
317
420
  }
318
421
  };
319
422
  (0, import_unist_util_visit.visit)(tree, "html", handler);
@@ -350,7 +453,1067 @@ var remarkCustomHeadingIds = () => {
350
453
 
351
454
  // src/useRemarkSync.ts
352
455
  var import_react4 = require("react");
353
- var import_unified = require("unified");
456
+
457
+ // ../../node_modules/.pnpm/bail@2.0.2/node_modules/bail/index.js
458
+ function bail(error) {
459
+ if (error) {
460
+ throw error;
461
+ }
462
+ }
463
+
464
+ // ../../node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js
465
+ var import_is_buffer2 = __toESM(require_is_buffer(), 1);
466
+ var import_extend = __toESM(require_extend(), 1);
467
+
468
+ // ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
469
+ function isPlainObject(value) {
470
+ if (typeof value !== "object" || value === null) {
471
+ return false;
472
+ }
473
+ const prototype = Object.getPrototypeOf(value);
474
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
475
+ }
476
+
477
+ // ../../node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js
478
+ function trough() {
479
+ const fns = [];
480
+ const pipeline = { run, use };
481
+ return pipeline;
482
+ function run(...values) {
483
+ let middlewareIndex = -1;
484
+ const callback = values.pop();
485
+ if (typeof callback !== "function") {
486
+ throw new TypeError("Expected function as last argument, not " + callback);
487
+ }
488
+ next(null, ...values);
489
+ function next(error, ...output) {
490
+ const fn = fns[++middlewareIndex];
491
+ let index2 = -1;
492
+ if (error) {
493
+ callback(error);
494
+ return;
495
+ }
496
+ while (++index2 < values.length) {
497
+ if (output[index2] === null || output[index2] === void 0) {
498
+ output[index2] = values[index2];
499
+ }
500
+ }
501
+ values = output;
502
+ if (fn) {
503
+ wrap(fn, next)(...output);
504
+ } else {
505
+ callback(null, ...output);
506
+ }
507
+ }
508
+ }
509
+ function use(middelware) {
510
+ if (typeof middelware !== "function") {
511
+ throw new TypeError(
512
+ "Expected `middelware` to be a function, not " + middelware
513
+ );
514
+ }
515
+ fns.push(middelware);
516
+ return pipeline;
517
+ }
518
+ }
519
+ function wrap(middleware, callback) {
520
+ let called;
521
+ return wrapped;
522
+ function wrapped(...parameters) {
523
+ const fnExpectsCallback = middleware.length > parameters.length;
524
+ let result;
525
+ if (fnExpectsCallback) {
526
+ parameters.push(done);
527
+ }
528
+ try {
529
+ result = middleware.apply(this, parameters);
530
+ } catch (error) {
531
+ const exception = (
532
+ /** @type {Error} */
533
+ error
534
+ );
535
+ if (fnExpectsCallback && called) {
536
+ throw exception;
537
+ }
538
+ return done(exception);
539
+ }
540
+ if (!fnExpectsCallback) {
541
+ if (result instanceof Promise) {
542
+ result.then(then, done);
543
+ } else if (result instanceof Error) {
544
+ done(result);
545
+ } else {
546
+ then(result);
547
+ }
548
+ }
549
+ }
550
+ function done(error, ...output) {
551
+ if (!called) {
552
+ called = true;
553
+ callback(error, ...output);
554
+ }
555
+ }
556
+ function then(value) {
557
+ done(null, value);
558
+ }
559
+ }
560
+
561
+ // ../../node_modules/.pnpm/vfile@5.3.7/node_modules/vfile/lib/index.js
562
+ var import_is_buffer = __toESM(require_is_buffer(), 1);
563
+
564
+ // ../../node_modules/.pnpm/unist-util-stringify-position@3.0.3/node_modules/unist-util-stringify-position/lib/index.js
565
+ function stringifyPosition(value) {
566
+ if (!value || typeof value !== "object") {
567
+ return "";
568
+ }
569
+ if ("position" in value || "type" in value) {
570
+ return position(value.position);
571
+ }
572
+ if ("start" in value || "end" in value) {
573
+ return position(value);
574
+ }
575
+ if ("line" in value || "column" in value) {
576
+ return point(value);
577
+ }
578
+ return "";
579
+ }
580
+ function point(point2) {
581
+ return index(point2 && point2.line) + ":" + index(point2 && point2.column);
582
+ }
583
+ function position(pos) {
584
+ return point(pos && pos.start) + "-" + point(pos && pos.end);
585
+ }
586
+ function index(value) {
587
+ return value && typeof value === "number" ? value : 1;
588
+ }
589
+
590
+ // ../../node_modules/.pnpm/vfile-message@3.1.4/node_modules/vfile-message/lib/index.js
591
+ var VFileMessage = class extends Error {
592
+ /**
593
+ * Create a message for `reason` at `place` from `origin`.
594
+ *
595
+ * When an error is passed in as `reason`, the `stack` is copied.
596
+ *
597
+ * @param {string | Error | VFileMessage} reason
598
+ * Reason for message, uses the stack and message of the error if given.
599
+ *
600
+ * > 👉 **Note**: you should use markdown.
601
+ * @param {Node | NodeLike | Position | Point | null | undefined} [place]
602
+ * Place in file where the message occurred.
603
+ * @param {string | null | undefined} [origin]
604
+ * Place in code where the message originates (example:
605
+ * `'my-package:my-rule'` or `'my-rule'`).
606
+ * @returns
607
+ * Instance of `VFileMessage`.
608
+ */
609
+ // To do: next major: expose `undefined` everywhere instead of `null`.
610
+ constructor(reason, place, origin) {
611
+ const parts = [null, null];
612
+ let position2 = {
613
+ // @ts-expect-error: we always follows the structure of `position`.
614
+ start: { line: null, column: null },
615
+ // @ts-expect-error: "
616
+ end: { line: null, column: null }
617
+ };
618
+ super();
619
+ if (typeof place === "string") {
620
+ origin = place;
621
+ place = void 0;
622
+ }
623
+ if (typeof origin === "string") {
624
+ const index2 = origin.indexOf(":");
625
+ if (index2 === -1) {
626
+ parts[1] = origin;
627
+ } else {
628
+ parts[0] = origin.slice(0, index2);
629
+ parts[1] = origin.slice(index2 + 1);
630
+ }
631
+ }
632
+ if (place) {
633
+ if ("type" in place || "position" in place) {
634
+ if (place.position) {
635
+ position2 = place.position;
636
+ }
637
+ } else if ("start" in place || "end" in place) {
638
+ position2 = place;
639
+ } else if ("line" in place || "column" in place) {
640
+ position2.start = place;
641
+ }
642
+ }
643
+ this.name = stringifyPosition(place) || "1:1";
644
+ this.message = typeof reason === "object" ? reason.message : reason;
645
+ this.stack = "";
646
+ if (typeof reason === "object" && reason.stack) {
647
+ this.stack = reason.stack;
648
+ }
649
+ this.reason = this.message;
650
+ this.fatal;
651
+ this.line = position2.start.line;
652
+ this.column = position2.start.column;
653
+ this.position = position2;
654
+ this.source = parts[0];
655
+ this.ruleId = parts[1];
656
+ this.file;
657
+ this.actual;
658
+ this.expected;
659
+ this.url;
660
+ this.note;
661
+ }
662
+ };
663
+ VFileMessage.prototype.file = "";
664
+ VFileMessage.prototype.name = "";
665
+ VFileMessage.prototype.reason = "";
666
+ VFileMessage.prototype.message = "";
667
+ VFileMessage.prototype.stack = "";
668
+ VFileMessage.prototype.fatal = null;
669
+ VFileMessage.prototype.column = null;
670
+ VFileMessage.prototype.line = null;
671
+ VFileMessage.prototype.source = null;
672
+ VFileMessage.prototype.ruleId = null;
673
+ VFileMessage.prototype.position = null;
674
+
675
+ // ../../node_modules/.pnpm/vfile@5.3.7/node_modules/vfile/lib/minpath.browser.js
676
+ var path = { basename, dirname, extname, join, sep: "/" };
677
+ function basename(path2, ext) {
678
+ if (ext !== void 0 && typeof ext !== "string") {
679
+ throw new TypeError('"ext" argument must be a string');
680
+ }
681
+ assertPath(path2);
682
+ let start = 0;
683
+ let end = -1;
684
+ let index2 = path2.length;
685
+ let seenNonSlash;
686
+ if (ext === void 0 || ext.length === 0 || ext.length > path2.length) {
687
+ while (index2--) {
688
+ if (path2.charCodeAt(index2) === 47) {
689
+ if (seenNonSlash) {
690
+ start = index2 + 1;
691
+ break;
692
+ }
693
+ } else if (end < 0) {
694
+ seenNonSlash = true;
695
+ end = index2 + 1;
696
+ }
697
+ }
698
+ return end < 0 ? "" : path2.slice(start, end);
699
+ }
700
+ if (ext === path2) {
701
+ return "";
702
+ }
703
+ let firstNonSlashEnd = -1;
704
+ let extIndex = ext.length - 1;
705
+ while (index2--) {
706
+ if (path2.charCodeAt(index2) === 47) {
707
+ if (seenNonSlash) {
708
+ start = index2 + 1;
709
+ break;
710
+ }
711
+ } else {
712
+ if (firstNonSlashEnd < 0) {
713
+ seenNonSlash = true;
714
+ firstNonSlashEnd = index2 + 1;
715
+ }
716
+ if (extIndex > -1) {
717
+ if (path2.charCodeAt(index2) === ext.charCodeAt(extIndex--)) {
718
+ if (extIndex < 0) {
719
+ end = index2;
720
+ }
721
+ } else {
722
+ extIndex = -1;
723
+ end = firstNonSlashEnd;
724
+ }
725
+ }
726
+ }
727
+ }
728
+ if (start === end) {
729
+ end = firstNonSlashEnd;
730
+ } else if (end < 0) {
731
+ end = path2.length;
732
+ }
733
+ return path2.slice(start, end);
734
+ }
735
+ function dirname(path2) {
736
+ assertPath(path2);
737
+ if (path2.length === 0) {
738
+ return ".";
739
+ }
740
+ let end = -1;
741
+ let index2 = path2.length;
742
+ let unmatchedSlash;
743
+ while (--index2) {
744
+ if (path2.charCodeAt(index2) === 47) {
745
+ if (unmatchedSlash) {
746
+ end = index2;
747
+ break;
748
+ }
749
+ } else if (!unmatchedSlash) {
750
+ unmatchedSlash = true;
751
+ }
752
+ }
753
+ return end < 0 ? path2.charCodeAt(0) === 47 ? "/" : "." : end === 1 && path2.charCodeAt(0) === 47 ? "//" : path2.slice(0, end);
754
+ }
755
+ function extname(path2) {
756
+ assertPath(path2);
757
+ let index2 = path2.length;
758
+ let end = -1;
759
+ let startPart = 0;
760
+ let startDot = -1;
761
+ let preDotState = 0;
762
+ let unmatchedSlash;
763
+ while (index2--) {
764
+ const code = path2.charCodeAt(index2);
765
+ if (code === 47) {
766
+ if (unmatchedSlash) {
767
+ startPart = index2 + 1;
768
+ break;
769
+ }
770
+ continue;
771
+ }
772
+ if (end < 0) {
773
+ unmatchedSlash = true;
774
+ end = index2 + 1;
775
+ }
776
+ if (code === 46) {
777
+ if (startDot < 0) {
778
+ startDot = index2;
779
+ } else if (preDotState !== 1) {
780
+ preDotState = 1;
781
+ }
782
+ } else if (startDot > -1) {
783
+ preDotState = -1;
784
+ }
785
+ }
786
+ if (startDot < 0 || end < 0 || // We saw a non-dot character immediately before the dot.
787
+ preDotState === 0 || // The (right-most) trimmed path component is exactly `..`.
788
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
789
+ return "";
790
+ }
791
+ return path2.slice(startDot, end);
792
+ }
793
+ function join(...segments) {
794
+ let index2 = -1;
795
+ let joined;
796
+ while (++index2 < segments.length) {
797
+ assertPath(segments[index2]);
798
+ if (segments[index2]) {
799
+ joined = joined === void 0 ? segments[index2] : joined + "/" + segments[index2];
800
+ }
801
+ }
802
+ return joined === void 0 ? "." : normalize(joined);
803
+ }
804
+ function normalize(path2) {
805
+ assertPath(path2);
806
+ const absolute = path2.charCodeAt(0) === 47;
807
+ let value = normalizeString(path2, !absolute);
808
+ if (value.length === 0 && !absolute) {
809
+ value = ".";
810
+ }
811
+ if (value.length > 0 && path2.charCodeAt(path2.length - 1) === 47) {
812
+ value += "/";
813
+ }
814
+ return absolute ? "/" + value : value;
815
+ }
816
+ function normalizeString(path2, allowAboveRoot) {
817
+ let result = "";
818
+ let lastSegmentLength = 0;
819
+ let lastSlash = -1;
820
+ let dots = 0;
821
+ let index2 = -1;
822
+ let code;
823
+ let lastSlashIndex;
824
+ while (++index2 <= path2.length) {
825
+ if (index2 < path2.length) {
826
+ code = path2.charCodeAt(index2);
827
+ } else if (code === 47) {
828
+ break;
829
+ } else {
830
+ code = 47;
831
+ }
832
+ if (code === 47) {
833
+ if (lastSlash === index2 - 1 || dots === 1) {
834
+ } else if (lastSlash !== index2 - 1 && dots === 2) {
835
+ if (result.length < 2 || lastSegmentLength !== 2 || result.charCodeAt(result.length - 1) !== 46 || result.charCodeAt(result.length - 2) !== 46) {
836
+ if (result.length > 2) {
837
+ lastSlashIndex = result.lastIndexOf("/");
838
+ if (lastSlashIndex !== result.length - 1) {
839
+ if (lastSlashIndex < 0) {
840
+ result = "";
841
+ lastSegmentLength = 0;
842
+ } else {
843
+ result = result.slice(0, lastSlashIndex);
844
+ lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
845
+ }
846
+ lastSlash = index2;
847
+ dots = 0;
848
+ continue;
849
+ }
850
+ } else if (result.length > 0) {
851
+ result = "";
852
+ lastSegmentLength = 0;
853
+ lastSlash = index2;
854
+ dots = 0;
855
+ continue;
856
+ }
857
+ }
858
+ if (allowAboveRoot) {
859
+ result = result.length > 0 ? result + "/.." : "..";
860
+ lastSegmentLength = 2;
861
+ }
862
+ } else {
863
+ if (result.length > 0) {
864
+ result += "/" + path2.slice(lastSlash + 1, index2);
865
+ } else {
866
+ result = path2.slice(lastSlash + 1, index2);
867
+ }
868
+ lastSegmentLength = index2 - lastSlash - 1;
869
+ }
870
+ lastSlash = index2;
871
+ dots = 0;
872
+ } else if (code === 46 && dots > -1) {
873
+ dots++;
874
+ } else {
875
+ dots = -1;
876
+ }
877
+ }
878
+ return result;
879
+ }
880
+ function assertPath(path2) {
881
+ if (typeof path2 !== "string") {
882
+ throw new TypeError(
883
+ "Path must be a string. Received " + JSON.stringify(path2)
884
+ );
885
+ }
886
+ }
887
+
888
+ // ../../node_modules/.pnpm/vfile@5.3.7/node_modules/vfile/lib/minproc.browser.js
889
+ var proc = { cwd };
890
+ function cwd() {
891
+ return "/";
892
+ }
893
+
894
+ // ../../node_modules/.pnpm/vfile@5.3.7/node_modules/vfile/lib/minurl.shared.js
895
+ function isUrl(fileUrlOrPath) {
896
+ return fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && // @ts-expect-error: indexable.
897
+ fileUrlOrPath.href && // @ts-expect-error: indexable.
898
+ fileUrlOrPath.origin;
899
+ }
900
+
901
+ // ../../node_modules/.pnpm/vfile@5.3.7/node_modules/vfile/lib/minurl.browser.js
902
+ function urlToPath(path2) {
903
+ if (typeof path2 === "string") {
904
+ path2 = new URL(path2);
905
+ } else if (!isUrl(path2)) {
906
+ const error = new TypeError(
907
+ 'The "path" argument must be of type string or an instance of URL. Received `' + path2 + "`"
908
+ );
909
+ error.code = "ERR_INVALID_ARG_TYPE";
910
+ throw error;
911
+ }
912
+ if (path2.protocol !== "file:") {
913
+ const error = new TypeError("The URL must be of scheme file");
914
+ error.code = "ERR_INVALID_URL_SCHEME";
915
+ throw error;
916
+ }
917
+ return getPathFromURLPosix(path2);
918
+ }
919
+ function getPathFromURLPosix(url) {
920
+ if (url.hostname !== "") {
921
+ const error = new TypeError(
922
+ 'File URL host must be "localhost" or empty on darwin'
923
+ );
924
+ error.code = "ERR_INVALID_FILE_URL_HOST";
925
+ throw error;
926
+ }
927
+ const pathname = url.pathname;
928
+ let index2 = -1;
929
+ while (++index2 < pathname.length) {
930
+ if (pathname.charCodeAt(index2) === 37 && pathname.charCodeAt(index2 + 1) === 50) {
931
+ const third = pathname.charCodeAt(index2 + 2);
932
+ if (third === 70 || third === 102) {
933
+ const error = new TypeError(
934
+ "File URL path must not include encoded / characters"
935
+ );
936
+ error.code = "ERR_INVALID_FILE_URL_PATH";
937
+ throw error;
938
+ }
939
+ }
940
+ }
941
+ return decodeURIComponent(pathname);
942
+ }
943
+
944
+ // ../../node_modules/.pnpm/vfile@5.3.7/node_modules/vfile/lib/index.js
945
+ var order = ["history", "path", "basename", "stem", "extname", "dirname"];
946
+ var VFile = class {
947
+ /**
948
+ * Create a new virtual file.
949
+ *
950
+ * `options` is treated as:
951
+ *
952
+ * * `string` or `Buffer` — `{value: options}`
953
+ * * `URL` — `{path: options}`
954
+ * * `VFile` — shallow copies its data over to the new file
955
+ * * `object` — all fields are shallow copied over to the new file
956
+ *
957
+ * Path related fields are set in the following order (least specific to
958
+ * most specific): `history`, `path`, `basename`, `stem`, `extname`,
959
+ * `dirname`.
960
+ *
961
+ * You cannot set `dirname` or `extname` without setting either `history`,
962
+ * `path`, `basename`, or `stem` too.
963
+ *
964
+ * @param {Compatible | null | undefined} [value]
965
+ * File value.
966
+ * @returns
967
+ * New instance.
968
+ */
969
+ constructor(value) {
970
+ let options;
971
+ if (!value) {
972
+ options = {};
973
+ } else if (typeof value === "string" || buffer(value)) {
974
+ options = { value };
975
+ } else if (isUrl(value)) {
976
+ options = { path: value };
977
+ } else {
978
+ options = value;
979
+ }
980
+ this.data = {};
981
+ this.messages = [];
982
+ this.history = [];
983
+ this.cwd = proc.cwd();
984
+ this.value;
985
+ this.stored;
986
+ this.result;
987
+ this.map;
988
+ let index2 = -1;
989
+ while (++index2 < order.length) {
990
+ const prop2 = order[index2];
991
+ if (prop2 in options && options[prop2] !== void 0 && options[prop2] !== null) {
992
+ this[prop2] = prop2 === "history" ? [...options[prop2]] : options[prop2];
993
+ }
994
+ }
995
+ let prop;
996
+ for (prop in options) {
997
+ if (!order.includes(prop)) {
998
+ this[prop] = options[prop];
999
+ }
1000
+ }
1001
+ }
1002
+ /**
1003
+ * Get the full path (example: `'~/index.min.js'`).
1004
+ *
1005
+ * @returns {string}
1006
+ */
1007
+ get path() {
1008
+ return this.history[this.history.length - 1];
1009
+ }
1010
+ /**
1011
+ * Set the full path (example: `'~/index.min.js'`).
1012
+ *
1013
+ * Cannot be nullified.
1014
+ * You can set a file URL (a `URL` object with a `file:` protocol) which will
1015
+ * be turned into a path with `url.fileURLToPath`.
1016
+ *
1017
+ * @param {string | URL} path
1018
+ */
1019
+ set path(path2) {
1020
+ if (isUrl(path2)) {
1021
+ path2 = urlToPath(path2);
1022
+ }
1023
+ assertNonEmpty(path2, "path");
1024
+ if (this.path !== path2) {
1025
+ this.history.push(path2);
1026
+ }
1027
+ }
1028
+ /**
1029
+ * Get the parent path (example: `'~'`).
1030
+ */
1031
+ get dirname() {
1032
+ return typeof this.path === "string" ? path.dirname(this.path) : void 0;
1033
+ }
1034
+ /**
1035
+ * Set the parent path (example: `'~'`).
1036
+ *
1037
+ * Cannot be set if there’s no `path` yet.
1038
+ */
1039
+ set dirname(dirname2) {
1040
+ assertPath2(this.basename, "dirname");
1041
+ this.path = path.join(dirname2 || "", this.basename);
1042
+ }
1043
+ /**
1044
+ * Get the basename (including extname) (example: `'index.min.js'`).
1045
+ */
1046
+ get basename() {
1047
+ return typeof this.path === "string" ? path.basename(this.path) : void 0;
1048
+ }
1049
+ /**
1050
+ * Set basename (including extname) (`'index.min.js'`).
1051
+ *
1052
+ * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
1053
+ * on windows).
1054
+ * Cannot be nullified (use `file.path = file.dirname` instead).
1055
+ */
1056
+ set basename(basename2) {
1057
+ assertNonEmpty(basename2, "basename");
1058
+ assertPart(basename2, "basename");
1059
+ this.path = path.join(this.dirname || "", basename2);
1060
+ }
1061
+ /**
1062
+ * Get the extname (including dot) (example: `'.js'`).
1063
+ */
1064
+ get extname() {
1065
+ return typeof this.path === "string" ? path.extname(this.path) : void 0;
1066
+ }
1067
+ /**
1068
+ * Set the extname (including dot) (example: `'.js'`).
1069
+ *
1070
+ * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
1071
+ * on windows).
1072
+ * Cannot be set if there’s no `path` yet.
1073
+ */
1074
+ set extname(extname2) {
1075
+ assertPart(extname2, "extname");
1076
+ assertPath2(this.dirname, "extname");
1077
+ if (extname2) {
1078
+ if (extname2.charCodeAt(0) !== 46) {
1079
+ throw new Error("`extname` must start with `.`");
1080
+ }
1081
+ if (extname2.includes(".", 1)) {
1082
+ throw new Error("`extname` cannot contain multiple dots");
1083
+ }
1084
+ }
1085
+ this.path = path.join(this.dirname, this.stem + (extname2 || ""));
1086
+ }
1087
+ /**
1088
+ * Get the stem (basename w/o extname) (example: `'index.min'`).
1089
+ */
1090
+ get stem() {
1091
+ return typeof this.path === "string" ? path.basename(this.path, this.extname) : void 0;
1092
+ }
1093
+ /**
1094
+ * Set the stem (basename w/o extname) (example: `'index.min'`).
1095
+ *
1096
+ * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
1097
+ * on windows).
1098
+ * Cannot be nullified (use `file.path = file.dirname` instead).
1099
+ */
1100
+ set stem(stem) {
1101
+ assertNonEmpty(stem, "stem");
1102
+ assertPart(stem, "stem");
1103
+ this.path = path.join(this.dirname || "", stem + (this.extname || ""));
1104
+ }
1105
+ /**
1106
+ * Serialize the file.
1107
+ *
1108
+ * @param {BufferEncoding | null | undefined} [encoding='utf8']
1109
+ * Character encoding to understand `value` as when it’s a `Buffer`
1110
+ * (default: `'utf8'`).
1111
+ * @returns {string}
1112
+ * Serialized file.
1113
+ */
1114
+ toString(encoding) {
1115
+ return (this.value || "").toString(encoding || void 0);
1116
+ }
1117
+ /**
1118
+ * Create a warning message associated with the file.
1119
+ *
1120
+ * Its `fatal` is set to `false` and `file` is set to the current file path.
1121
+ * Its added to `file.messages`.
1122
+ *
1123
+ * @param {string | Error | VFileMessage} reason
1124
+ * Reason for message, uses the stack and message of the error if given.
1125
+ * @param {Node | NodeLike | Position | Point | null | undefined} [place]
1126
+ * Place in file where the message occurred.
1127
+ * @param {string | null | undefined} [origin]
1128
+ * Place in code where the message originates (example:
1129
+ * `'my-package:my-rule'` or `'my-rule'`).
1130
+ * @returns {VFileMessage}
1131
+ * Message.
1132
+ */
1133
+ message(reason, place, origin) {
1134
+ const message = new VFileMessage(reason, place, origin);
1135
+ if (this.path) {
1136
+ message.name = this.path + ":" + message.name;
1137
+ message.file = this.path;
1138
+ }
1139
+ message.fatal = false;
1140
+ this.messages.push(message);
1141
+ return message;
1142
+ }
1143
+ /**
1144
+ * Create an info message associated with the file.
1145
+ *
1146
+ * Its `fatal` is set to `null` and `file` is set to the current file path.
1147
+ * Its added to `file.messages`.
1148
+ *
1149
+ * @param {string | Error | VFileMessage} reason
1150
+ * Reason for message, uses the stack and message of the error if given.
1151
+ * @param {Node | NodeLike | Position | Point | null | undefined} [place]
1152
+ * Place in file where the message occurred.
1153
+ * @param {string | null | undefined} [origin]
1154
+ * Place in code where the message originates (example:
1155
+ * `'my-package:my-rule'` or `'my-rule'`).
1156
+ * @returns {VFileMessage}
1157
+ * Message.
1158
+ */
1159
+ info(reason, place, origin) {
1160
+ const message = this.message(reason, place, origin);
1161
+ message.fatal = null;
1162
+ return message;
1163
+ }
1164
+ /**
1165
+ * Create a fatal error associated with the file.
1166
+ *
1167
+ * Its `fatal` is set to `true` and `file` is set to the current file path.
1168
+ * Its added to `file.messages`.
1169
+ *
1170
+ * > 👉 **Note**: a fatal error means that a file is no longer processable.
1171
+ *
1172
+ * @param {string | Error | VFileMessage} reason
1173
+ * Reason for message, uses the stack and message of the error if given.
1174
+ * @param {Node | NodeLike | Position | Point | null | undefined} [place]
1175
+ * Place in file where the message occurred.
1176
+ * @param {string | null | undefined} [origin]
1177
+ * Place in code where the message originates (example:
1178
+ * `'my-package:my-rule'` or `'my-rule'`).
1179
+ * @returns {never}
1180
+ * Message.
1181
+ * @throws {VFileMessage}
1182
+ * Message.
1183
+ */
1184
+ fail(reason, place, origin) {
1185
+ const message = this.message(reason, place, origin);
1186
+ message.fatal = true;
1187
+ throw message;
1188
+ }
1189
+ };
1190
+ function assertPart(part, name) {
1191
+ if (part && part.includes(path.sep)) {
1192
+ throw new Error(
1193
+ "`" + name + "` cannot be a path: did not expect `" + path.sep + "`"
1194
+ );
1195
+ }
1196
+ }
1197
+ function assertNonEmpty(part, name) {
1198
+ if (!part) {
1199
+ throw new Error("`" + name + "` cannot be empty");
1200
+ }
1201
+ }
1202
+ function assertPath2(path2, name) {
1203
+ if (!path2) {
1204
+ throw new Error("Setting `" + name + "` requires `path` to be set too");
1205
+ }
1206
+ }
1207
+ function buffer(value) {
1208
+ return (0, import_is_buffer.default)(value);
1209
+ }
1210
+
1211
+ // ../../node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js
1212
+ var unified = base().freeze();
1213
+ var own = {}.hasOwnProperty;
1214
+ function base() {
1215
+ const transformers = trough();
1216
+ const attachers = [];
1217
+ let namespace = {};
1218
+ let frozen;
1219
+ let freezeIndex = -1;
1220
+ processor.data = data;
1221
+ processor.Parser = void 0;
1222
+ processor.Compiler = void 0;
1223
+ processor.freeze = freeze;
1224
+ processor.attachers = attachers;
1225
+ processor.use = use;
1226
+ processor.parse = parse;
1227
+ processor.stringify = stringify;
1228
+ processor.run = run;
1229
+ processor.runSync = runSync;
1230
+ processor.process = process;
1231
+ processor.processSync = processSync;
1232
+ return processor;
1233
+ function processor() {
1234
+ const destination = base();
1235
+ let index2 = -1;
1236
+ while (++index2 < attachers.length) {
1237
+ destination.use(...attachers[index2]);
1238
+ }
1239
+ destination.data((0, import_extend.default)(true, {}, namespace));
1240
+ return destination;
1241
+ }
1242
+ function data(key, value) {
1243
+ if (typeof key === "string") {
1244
+ if (arguments.length === 2) {
1245
+ assertUnfrozen("data", frozen);
1246
+ namespace[key] = value;
1247
+ return processor;
1248
+ }
1249
+ return own.call(namespace, key) && namespace[key] || null;
1250
+ }
1251
+ if (key) {
1252
+ assertUnfrozen("data", frozen);
1253
+ namespace = key;
1254
+ return processor;
1255
+ }
1256
+ return namespace;
1257
+ }
1258
+ function freeze() {
1259
+ if (frozen) {
1260
+ return processor;
1261
+ }
1262
+ while (++freezeIndex < attachers.length) {
1263
+ const [attacher, ...options] = attachers[freezeIndex];
1264
+ if (options[0] === false) {
1265
+ continue;
1266
+ }
1267
+ if (options[0] === true) {
1268
+ options[0] = void 0;
1269
+ }
1270
+ const transformer = attacher.call(processor, ...options);
1271
+ if (typeof transformer === "function") {
1272
+ transformers.use(transformer);
1273
+ }
1274
+ }
1275
+ frozen = true;
1276
+ freezeIndex = Number.POSITIVE_INFINITY;
1277
+ return processor;
1278
+ }
1279
+ function use(value, ...options) {
1280
+ let settings;
1281
+ assertUnfrozen("use", frozen);
1282
+ if (value === null || value === void 0) {
1283
+ } else if (typeof value === "function") {
1284
+ addPlugin(value, ...options);
1285
+ } else if (typeof value === "object") {
1286
+ if (Array.isArray(value)) {
1287
+ addList(value);
1288
+ } else {
1289
+ addPreset(value);
1290
+ }
1291
+ } else {
1292
+ throw new TypeError("Expected usable value, not `" + value + "`");
1293
+ }
1294
+ if (settings) {
1295
+ namespace.settings = Object.assign(namespace.settings || {}, settings);
1296
+ }
1297
+ return processor;
1298
+ function add(value2) {
1299
+ if (typeof value2 === "function") {
1300
+ addPlugin(value2);
1301
+ } else if (typeof value2 === "object") {
1302
+ if (Array.isArray(value2)) {
1303
+ const [plugin, ...options2] = value2;
1304
+ addPlugin(plugin, ...options2);
1305
+ } else {
1306
+ addPreset(value2);
1307
+ }
1308
+ } else {
1309
+ throw new TypeError("Expected usable value, not `" + value2 + "`");
1310
+ }
1311
+ }
1312
+ function addPreset(result) {
1313
+ addList(result.plugins);
1314
+ if (result.settings) {
1315
+ settings = Object.assign(settings || {}, result.settings);
1316
+ }
1317
+ }
1318
+ function addList(plugins) {
1319
+ let index2 = -1;
1320
+ if (plugins === null || plugins === void 0) {
1321
+ } else if (Array.isArray(plugins)) {
1322
+ while (++index2 < plugins.length) {
1323
+ const thing = plugins[index2];
1324
+ add(thing);
1325
+ }
1326
+ } else {
1327
+ throw new TypeError("Expected a list of plugins, not `" + plugins + "`");
1328
+ }
1329
+ }
1330
+ function addPlugin(plugin, value2) {
1331
+ let index2 = -1;
1332
+ let entry;
1333
+ while (++index2 < attachers.length) {
1334
+ if (attachers[index2][0] === plugin) {
1335
+ entry = attachers[index2];
1336
+ break;
1337
+ }
1338
+ }
1339
+ if (entry) {
1340
+ if (isPlainObject(entry[1]) && isPlainObject(value2)) {
1341
+ value2 = (0, import_extend.default)(true, entry[1], value2);
1342
+ }
1343
+ entry[1] = value2;
1344
+ } else {
1345
+ attachers.push([...arguments]);
1346
+ }
1347
+ }
1348
+ }
1349
+ function parse(doc) {
1350
+ processor.freeze();
1351
+ const file = vfile(doc);
1352
+ const Parser = processor.Parser;
1353
+ assertParser("parse", Parser);
1354
+ if (newable(Parser, "parse")) {
1355
+ return new Parser(String(file), file).parse();
1356
+ }
1357
+ return Parser(String(file), file);
1358
+ }
1359
+ function stringify(node, doc) {
1360
+ processor.freeze();
1361
+ const file = vfile(doc);
1362
+ const Compiler = processor.Compiler;
1363
+ assertCompiler("stringify", Compiler);
1364
+ assertNode(node);
1365
+ if (newable(Compiler, "compile")) {
1366
+ return new Compiler(node, file).compile();
1367
+ }
1368
+ return Compiler(node, file);
1369
+ }
1370
+ function run(node, doc, callback) {
1371
+ assertNode(node);
1372
+ processor.freeze();
1373
+ if (!callback && typeof doc === "function") {
1374
+ callback = doc;
1375
+ doc = void 0;
1376
+ }
1377
+ if (!callback) {
1378
+ return new Promise(executor);
1379
+ }
1380
+ executor(null, callback);
1381
+ function executor(resolve, reject) {
1382
+ transformers.run(node, vfile(doc), done);
1383
+ function done(error, tree, file) {
1384
+ tree = tree || node;
1385
+ if (error) {
1386
+ reject(error);
1387
+ } else if (resolve) {
1388
+ resolve(tree);
1389
+ } else {
1390
+ callback(null, tree, file);
1391
+ }
1392
+ }
1393
+ }
1394
+ }
1395
+ function runSync(node, file) {
1396
+ let result;
1397
+ let complete;
1398
+ processor.run(node, file, done);
1399
+ assertDone("runSync", "run", complete);
1400
+ return result;
1401
+ function done(error, tree) {
1402
+ bail(error);
1403
+ result = tree;
1404
+ complete = true;
1405
+ }
1406
+ }
1407
+ function process(doc, callback) {
1408
+ processor.freeze();
1409
+ assertParser("process", processor.Parser);
1410
+ assertCompiler("process", processor.Compiler);
1411
+ if (!callback) {
1412
+ return new Promise(executor);
1413
+ }
1414
+ executor(null, callback);
1415
+ function executor(resolve, reject) {
1416
+ const file = vfile(doc);
1417
+ processor.run(processor.parse(file), file, (error, tree, file2) => {
1418
+ if (error || !tree || !file2) {
1419
+ done(error);
1420
+ } else {
1421
+ const result = processor.stringify(tree, file2);
1422
+ if (result === void 0 || result === null) {
1423
+ } else if (looksLikeAVFileValue(result)) {
1424
+ file2.value = result;
1425
+ } else {
1426
+ file2.result = result;
1427
+ }
1428
+ done(error, file2);
1429
+ }
1430
+ });
1431
+ function done(error, file2) {
1432
+ if (error || !file2) {
1433
+ reject(error);
1434
+ } else if (resolve) {
1435
+ resolve(file2);
1436
+ } else {
1437
+ callback(null, file2);
1438
+ }
1439
+ }
1440
+ }
1441
+ }
1442
+ function processSync(doc) {
1443
+ let complete;
1444
+ processor.freeze();
1445
+ assertParser("processSync", processor.Parser);
1446
+ assertCompiler("processSync", processor.Compiler);
1447
+ const file = vfile(doc);
1448
+ processor.process(file, done);
1449
+ assertDone("processSync", "process", complete);
1450
+ return file;
1451
+ function done(error) {
1452
+ complete = true;
1453
+ bail(error);
1454
+ }
1455
+ }
1456
+ }
1457
+ function newable(value, name) {
1458
+ return typeof value === "function" && // Prototypes do exist.
1459
+ // type-coverage:ignore-next-line
1460
+ value.prototype && // A function with keys in its prototype is probably a constructor.
1461
+ // Classes’ prototype methods are not enumerable, so we check if some value
1462
+ // exists in the prototype.
1463
+ // type-coverage:ignore-next-line
1464
+ (keys(value.prototype) || name in value.prototype);
1465
+ }
1466
+ function keys(value) {
1467
+ let key;
1468
+ for (key in value) {
1469
+ if (own.call(value, key)) {
1470
+ return true;
1471
+ }
1472
+ }
1473
+ return false;
1474
+ }
1475
+ function assertParser(name, value) {
1476
+ if (typeof value !== "function") {
1477
+ throw new TypeError("Cannot `" + name + "` without `Parser`");
1478
+ }
1479
+ }
1480
+ function assertCompiler(name, value) {
1481
+ if (typeof value !== "function") {
1482
+ throw new TypeError("Cannot `" + name + "` without `Compiler`");
1483
+ }
1484
+ }
1485
+ function assertUnfrozen(name, frozen) {
1486
+ if (frozen) {
1487
+ throw new Error(
1488
+ "Cannot call `" + name + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`."
1489
+ );
1490
+ }
1491
+ }
1492
+ function assertNode(node) {
1493
+ if (!isPlainObject(node) || typeof node.type !== "string") {
1494
+ throw new TypeError("Expected node, got `" + node + "`");
1495
+ }
1496
+ }
1497
+ function assertDone(name, asyncName, complete) {
1498
+ if (!complete) {
1499
+ throw new Error(
1500
+ "`" + name + "` finished async. Use `" + asyncName + "` instead"
1501
+ );
1502
+ }
1503
+ }
1504
+ function vfile(value) {
1505
+ return looksLikeAVFile(value) ? value : new VFile(value);
1506
+ }
1507
+ function looksLikeAVFile(value) {
1508
+ return Boolean(
1509
+ value && typeof value === "object" && "message" in value && "messages" in value
1510
+ );
1511
+ }
1512
+ function looksLikeAVFileValue(value) {
1513
+ return typeof value === "string" || (0, import_is_buffer2.default)(value);
1514
+ }
1515
+
1516
+ // src/useRemarkSync.ts
354
1517
  var import_remark_parse = __toESM(require("remark-parse"));
355
1518
  var import_remark_rehype = __toESM(require("remark-rehype"));
356
1519
  var import_rehype_react = __toESM(require("rehype-react"));
@@ -359,7 +1522,7 @@ var useRemarkSync = (source, {
359
1522
  rehypeReactOptions,
360
1523
  remarkPlugins = [],
361
1524
  rehypePlugins = []
362
- } = {}) => (0, import_unified.unified)().use(import_remark_parse.default).use(remarkPlugins).use(import_remark_rehype.default, remarkToRehypeOptions).use(rehypePlugins).use(import_rehype_react.default, __spreadValues({
1525
+ } = {}) => unified().use(import_remark_parse.default).use(remarkPlugins).use(import_remark_rehype.default, remarkToRehypeOptions).use(rehypePlugins).use(import_rehype_react.default, __spreadValues({
363
1526
  createElement: import_react4.createElement,
364
1527
  Fragment: import_react4.Fragment
365
1528
  }, rehypeReactOptions)).processSync(source).result;
@@ -367,7 +1530,6 @@ var useRemarkSync = (source, {
367
1530
  // src/useToc.ts
368
1531
  var import_remark_parse2 = __toESM(require("remark-parse"));
369
1532
  var import_remark_stringify = __toESM(require("remark-stringify"));
370
- var import_unified2 = require("unified");
371
1533
 
372
1534
  // src/remarkHeadings.ts
373
1535
  var import_unist_util_visit3 = require("unist-util-visit");
@@ -402,7 +1564,7 @@ var remarkHeadings = () => {
402
1564
 
403
1565
  // src/useToc.ts
404
1566
  var useToc = (markdown) => {
405
- return (0, import_unified2.unified)().use(remarkCustomHeadingIds).use(import_remark_parse2.default).use(import_remark_stringify.default).use(remarkHeadings).processSync(markdown).data.headings;
1567
+ return unified().use(remarkCustomHeadingIds).use(import_remark_parse2.default).use(import_remark_stringify.default).use(remarkHeadings).processSync(markdown).data.headings;
406
1568
  };
407
1569
 
408
1570
  // src/Markdown.tsx
@@ -475,4 +1637,14 @@ var Markdown = ({ children, showToc = true }) => {
475
1637
  reactContent
476
1638
  ] });
477
1639
  };
1640
+ /*! Bundled license information:
1641
+
1642
+ is-buffer/index.js:
1643
+ (*!
1644
+ * Determine if an object is a Buffer
1645
+ *
1646
+ * @author Feross Aboukhadijeh <https://feross.org>
1647
+ * @license MIT
1648
+ *)
1649
+ */
478
1650
  //# sourceMappingURL=index.cjs.js.map