@hyperbook/markdown 0.8.1 → 0.9.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.js +448 -0
- package/dist/index.js.map +7 -0
- package/package.json +10 -18
- package/dist/index.cjs.js +0 -1650
- package/dist/index.cjs.js.map +0 -7
- package/dist/index.esm.mjs +0 -1640
- package/dist/index.esm.mjs.map +0 -7
package/dist/index.cjs.js
DELETED
|
@@ -1,1650 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b ||= {})
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
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
|
-
};
|
|
28
|
-
var __export = (target, all) => {
|
|
29
|
-
for (var name in all)
|
|
30
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
31
|
-
};
|
|
32
|
-
var __copyProps = (to, from, except, desc) => {
|
|
33
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
34
|
-
for (let key of __getOwnPropNames(from))
|
|
35
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
36
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
37
|
-
}
|
|
38
|
-
return to;
|
|
39
|
-
};
|
|
40
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
41
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
42
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
43
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
44
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
45
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
46
|
-
mod
|
|
47
|
-
));
|
|
48
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
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
|
-
|
|
150
|
-
// src/index.ts
|
|
151
|
-
var src_exports = {};
|
|
152
|
-
__export(src_exports, {
|
|
153
|
-
Markdown: () => Markdown,
|
|
154
|
-
useToc: () => useToc
|
|
155
|
-
});
|
|
156
|
-
module.exports = __toCommonJS(src_exports);
|
|
157
|
-
|
|
158
|
-
// src/Markdown.tsx
|
|
159
|
-
var import_remark_directive = __toESM(require("remark-directive"));
|
|
160
|
-
var import_remark_directive_rehype = __toESM(require("remark-directive-rehype"));
|
|
161
|
-
var import_remark_gfm = __toESM(require("remark-gfm"));
|
|
162
|
-
var import_remark_math = __toESM(require("remark-math"));
|
|
163
|
-
var import_remark_gemoji = __toESM(require("remark-gemoji"));
|
|
164
|
-
var import_remark_unwrap_images = __toESM(require("remark-unwrap-images"));
|
|
165
|
-
var import_rehype_katex = __toESM(require("rehype-katex"));
|
|
166
|
-
var import_rehype_highlight = __toESM(require("rehype-highlight"));
|
|
167
|
-
var import_provider5 = require("@hyperbook/provider");
|
|
168
|
-
var import_drawer = require("@hyperbook/drawer");
|
|
169
|
-
|
|
170
|
-
// src/Code.tsx
|
|
171
|
-
var import_provider = require("@hyperbook/provider");
|
|
172
|
-
var import_react = require("react");
|
|
173
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
174
|
-
var MdContentCopy = () => {
|
|
175
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
176
|
-
"svg",
|
|
177
|
-
{
|
|
178
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
179
|
-
stroke: "currentColor",
|
|
180
|
-
fill: "currentColor",
|
|
181
|
-
strokeWidth: "0",
|
|
182
|
-
height: "1em",
|
|
183
|
-
width: "1em",
|
|
184
|
-
viewBox: "0 0 24 24",
|
|
185
|
-
children: [
|
|
186
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
|
|
187
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" })
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
);
|
|
191
|
-
};
|
|
192
|
-
var MdDone = () => {
|
|
193
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
194
|
-
"svg",
|
|
195
|
-
{
|
|
196
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
197
|
-
stroke: "currentColor",
|
|
198
|
-
fill: "currentColor",
|
|
199
|
-
strokeWidth: "0",
|
|
200
|
-
height: "1em",
|
|
201
|
-
width: "1em",
|
|
202
|
-
viewBox: "0 0 24 24",
|
|
203
|
-
children: [
|
|
204
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
|
|
205
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" })
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
);
|
|
209
|
-
};
|
|
210
|
-
var copyNoNavigator = (text) => {
|
|
211
|
-
const isIos = navigator.userAgent.match(/ipad|iphone/i);
|
|
212
|
-
const textarea = document.createElement("textarea");
|
|
213
|
-
textarea.value = text;
|
|
214
|
-
textarea.style.fontSize = "20px";
|
|
215
|
-
document.body.appendChild(textarea);
|
|
216
|
-
if (isIos) {
|
|
217
|
-
const range = document.createRange();
|
|
218
|
-
range.selectNodeContents(textarea);
|
|
219
|
-
const selection = window.getSelection();
|
|
220
|
-
if (selection) {
|
|
221
|
-
selection.removeAllRanges();
|
|
222
|
-
selection.addRange(range);
|
|
223
|
-
}
|
|
224
|
-
textarea.setSelectionRange(0, 999999);
|
|
225
|
-
} else {
|
|
226
|
-
textarea.select();
|
|
227
|
-
}
|
|
228
|
-
document.execCommand("copy");
|
|
229
|
-
document.body.removeChild(textarea);
|
|
230
|
-
};
|
|
231
|
-
var Code = ({
|
|
232
|
-
children,
|
|
233
|
-
className
|
|
234
|
-
}) => {
|
|
235
|
-
const directives = (0, import_provider.useDirectives)();
|
|
236
|
-
if (className === "language-mermaid" && directives["mermaid"]) {
|
|
237
|
-
const Mermaid = directives["mermaid"];
|
|
238
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Mermaid, { children });
|
|
239
|
-
}
|
|
240
|
-
const ref = (0, import_react.useRef)(null);
|
|
241
|
-
const [copied, setCopied] = (0, import_react.useState)(false);
|
|
242
|
-
const copyCode = () => {
|
|
243
|
-
if (ref.current) {
|
|
244
|
-
const text = ref.current.innerText;
|
|
245
|
-
if (navigator.clipboard) {
|
|
246
|
-
navigator.clipboard.writeText(text).then(() => {
|
|
247
|
-
setCopied(true);
|
|
248
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
249
|
-
}).catch(() => {
|
|
250
|
-
copyNoNavigator(text);
|
|
251
|
-
setCopied(true);
|
|
252
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
253
|
-
});
|
|
254
|
-
} else {
|
|
255
|
-
copyNoNavigator(text);
|
|
256
|
-
setCopied(true);
|
|
257
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
return !className ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "inline", children: [
|
|
262
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { ref, className, children }),
|
|
263
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "copy", onClick: copyCode, "aria-label": "Copy Code", children: copied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MdDone, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MdContentCopy, {}) })
|
|
264
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
265
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { ref, className, children }),
|
|
266
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "copy", onClick: copyCode, "aria-label": "Copy Code", children: copied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MdDone, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MdContentCopy, {}) })
|
|
267
|
-
] });
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
// src/Link.tsx
|
|
271
|
-
var import_provider2 = require("@hyperbook/provider");
|
|
272
|
-
var import_react2 = require("react");
|
|
273
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
274
|
-
function formatUrl(url) {
|
|
275
|
-
if (typeof url !== "string") {
|
|
276
|
-
return url;
|
|
277
|
-
}
|
|
278
|
-
var doubleSlash = url.split("//");
|
|
279
|
-
var formatted = doubleSlash.map(
|
|
280
|
-
(str) => (
|
|
281
|
-
// Insert a word break opportunity after a colon
|
|
282
|
-
str.replace(new RegExp("(?<after>:)", "giu"), "$1<wbr>").replace(new RegExp("(?<before>[/~.,\\-_?#%])", "giu"), "<wbr>$1").replace(new RegExp("(?<beforeAndAfter>[=&])", "giu"), "<wbr>$1<wbr>")
|
|
283
|
-
)
|
|
284
|
-
// Reconnect the strings with word break opportunities after double slashes
|
|
285
|
-
).join("//<wbr>");
|
|
286
|
-
return formatted;
|
|
287
|
-
}
|
|
288
|
-
var Link = ({
|
|
289
|
-
href,
|
|
290
|
-
title,
|
|
291
|
-
children
|
|
292
|
-
}) => {
|
|
293
|
-
const L = (0, import_provider2.useLink)();
|
|
294
|
-
const config = (0, import_provider2.useConfig)();
|
|
295
|
-
const [isExternal, setIsExternal] = (0, import_react2.useState)(false);
|
|
296
|
-
(0, import_react2.useEffect)(() => {
|
|
297
|
-
var _a;
|
|
298
|
-
if (href) {
|
|
299
|
-
const tmp = document.createElement("a");
|
|
300
|
-
tmp.href = href;
|
|
301
|
-
if (tmp.host !== window.location.host) {
|
|
302
|
-
setIsExternal(true);
|
|
303
|
-
} else if (config.basePath && !((_a = window.location.pathname) == null ? void 0 : _a.startsWith(config.basePath))) {
|
|
304
|
-
setIsExternal(true);
|
|
305
|
-
} else {
|
|
306
|
-
setIsExternal(false);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}, [href, config]);
|
|
310
|
-
if (isExternal) {
|
|
311
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(L, { href, title, target: "_blank", children: formatUrl(children) });
|
|
312
|
-
}
|
|
313
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(L, { href, title, children: formatUrl(children) });
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
// src/Table.tsx
|
|
317
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
318
|
-
var tableHeaders = [];
|
|
319
|
-
var tdIndex = 0;
|
|
320
|
-
var Table = ({
|
|
321
|
-
children,
|
|
322
|
-
style
|
|
323
|
-
}) => {
|
|
324
|
-
tableHeaders = [];
|
|
325
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("table", { style, children });
|
|
326
|
-
};
|
|
327
|
-
var Tr = ({
|
|
328
|
-
children,
|
|
329
|
-
style
|
|
330
|
-
}) => {
|
|
331
|
-
tdIndex = 0;
|
|
332
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { style, children });
|
|
333
|
-
};
|
|
334
|
-
var Td = ({
|
|
335
|
-
children,
|
|
336
|
-
style
|
|
337
|
-
}) => {
|
|
338
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { "data-label": tableHeaders[tdIndex++], style, children });
|
|
339
|
-
};
|
|
340
|
-
var Th = ({
|
|
341
|
-
children,
|
|
342
|
-
style
|
|
343
|
-
}) => {
|
|
344
|
-
tableHeaders.push(children);
|
|
345
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { style, children });
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
// src/Headings.tsx
|
|
349
|
-
var import_provider3 = require("@hyperbook/provider");
|
|
350
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
351
|
-
var makeAnchor = (heading) => {
|
|
352
|
-
let anchor = heading.toLowerCase();
|
|
353
|
-
anchor = anchor.replace(/[^a-zA-Z0-9 ]/g, "");
|
|
354
|
-
anchor = anchor.replace(/ /g, "-");
|
|
355
|
-
return anchor;
|
|
356
|
-
};
|
|
357
|
-
var Headings = (level) => ({ children, id }) => {
|
|
358
|
-
var _a;
|
|
359
|
-
const config = (0, import_provider3.useConfig)();
|
|
360
|
-
const bookmarksConfig = (_a = config == null ? void 0 : config.elements) == null ? void 0 : _a.bookmarks;
|
|
361
|
-
const heading = (children == null ? void 0 : children[0]) || "";
|
|
362
|
-
let anchor = typeof heading === "string" ? makeAnchor(heading) : "";
|
|
363
|
-
const label = typeof heading === "string" ? heading : anchor;
|
|
364
|
-
const [bookmark, toggleBookmark] = (0, import_provider3.useBookmark)(anchor, label);
|
|
365
|
-
const container = (children2) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
366
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { className: "heading", id: id != null ? id : anchor, href: `#${id != null ? id : anchor}`, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: children2 }) }),
|
|
367
|
-
bookmarksConfig !== false && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
368
|
-
"button",
|
|
369
|
-
{
|
|
370
|
-
className: bookmark ? "bookmark active" : "bookmark",
|
|
371
|
-
onClick: () => toggleBookmark(),
|
|
372
|
-
title: "Bookmark",
|
|
373
|
-
children: "\u{1F516}"
|
|
374
|
-
}
|
|
375
|
-
)
|
|
376
|
-
] });
|
|
377
|
-
switch (level) {
|
|
378
|
-
case 1:
|
|
379
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h1", { children: container(children) });
|
|
380
|
-
case 2:
|
|
381
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { children: container(children) });
|
|
382
|
-
case 3:
|
|
383
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { children: container(children) });
|
|
384
|
-
case 4:
|
|
385
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h4", { children: container(children) });
|
|
386
|
-
case 5:
|
|
387
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h5", { children: container(children) });
|
|
388
|
-
default:
|
|
389
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h6", { children: container(children) });
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
// src/Image.tsx
|
|
394
|
-
var import_provider4 = require("@hyperbook/provider");
|
|
395
|
-
var import_react3 = require("react");
|
|
396
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
397
|
-
var Image = ({
|
|
398
|
-
src,
|
|
399
|
-
title,
|
|
400
|
-
alt
|
|
401
|
-
}) => {
|
|
402
|
-
const makeUrl = (0, import_provider4.useMakeUrl)();
|
|
403
|
-
const [full, setFull] = (0, import_react3.useState)(false);
|
|
404
|
-
src = makeUrl(src, "public");
|
|
405
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("figure", { className: full ? "lightbox" : void 0, children: [
|
|
406
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src, alt, onClick: () => setFull((f) => !f) }),
|
|
407
|
-
title && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("figcaption", { children: title })
|
|
408
|
-
] });
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
// src/remarkRemoveComments.ts
|
|
412
|
-
var import_unist_util_visit = require("unist-util-visit");
|
|
413
|
-
var remarkRemoveComments = () => (tree) => {
|
|
414
|
-
const htmlCommentRegex = /<!--([\s\S]*?)-->/g;
|
|
415
|
-
const handler = (node, index2, parent) => {
|
|
416
|
-
const isComment = node.value.match(htmlCommentRegex);
|
|
417
|
-
if (isComment) {
|
|
418
|
-
parent.children.splice(index2, 1);
|
|
419
|
-
return [import_unist_util_visit.SKIP, index2];
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
(0, import_unist_util_visit.visit)(tree, "html", handler);
|
|
423
|
-
(0, import_unist_util_visit.visit)(tree, "jsx", handler);
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
// src/remarkCustomHeadingIds.ts
|
|
427
|
-
var import_unist_util_visit2 = require("unist-util-visit");
|
|
428
|
-
var remarkCustomHeadingIds = () => {
|
|
429
|
-
return function(node) {
|
|
430
|
-
(0, import_unist_util_visit2.visit)(node, "heading", (node2) => {
|
|
431
|
-
let lastChild = node2.children[node2.children.length - 1];
|
|
432
|
-
if (lastChild && lastChild.type === "text") {
|
|
433
|
-
let string = lastChild.value.replace(/ +$/, "");
|
|
434
|
-
let matched = string.match(/ {#([^]+?)}$/);
|
|
435
|
-
if (matched) {
|
|
436
|
-
let id = matched[1];
|
|
437
|
-
if (!!id.length) {
|
|
438
|
-
if (!node2.data) {
|
|
439
|
-
node2.data = {};
|
|
440
|
-
}
|
|
441
|
-
if (!node2.data.hProperties) {
|
|
442
|
-
node2.data.hProperties = {};
|
|
443
|
-
}
|
|
444
|
-
node2.data.id = node2.data.hProperties.id = id;
|
|
445
|
-
string = string.substring(0, matched.index);
|
|
446
|
-
lastChild.value = string;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
};
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
// src/useRemarkSync.ts
|
|
455
|
-
var import_react4 = require("react");
|
|
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
|
|
1517
|
-
var import_remark_parse = __toESM(require("remark-parse"));
|
|
1518
|
-
var import_remark_rehype = __toESM(require("remark-rehype"));
|
|
1519
|
-
var import_rehype_react = __toESM(require("rehype-react"));
|
|
1520
|
-
var useRemarkSync = (source, {
|
|
1521
|
-
remarkToRehypeOptions,
|
|
1522
|
-
rehypeReactOptions,
|
|
1523
|
-
remarkPlugins = [],
|
|
1524
|
-
rehypePlugins = []
|
|
1525
|
-
} = {}) => unified().use(import_remark_parse.default).use(remarkPlugins).use(import_remark_rehype.default, remarkToRehypeOptions).use(rehypePlugins).use(import_rehype_react.default, __spreadValues({
|
|
1526
|
-
createElement: import_react4.createElement,
|
|
1527
|
-
Fragment: import_react4.Fragment
|
|
1528
|
-
}, rehypeReactOptions)).processSync(source).result;
|
|
1529
|
-
|
|
1530
|
-
// src/useToc.ts
|
|
1531
|
-
var import_remark_parse2 = __toESM(require("remark-parse"));
|
|
1532
|
-
var import_remark_stringify = __toESM(require("remark-stringify"));
|
|
1533
|
-
|
|
1534
|
-
// src/remarkHeadings.ts
|
|
1535
|
-
var import_unist_util_visit3 = require("unist-util-visit");
|
|
1536
|
-
var import_mdast_util_to_string = require("mdast-util-to-string");
|
|
1537
|
-
var getAnchor = (heading) => {
|
|
1538
|
-
var _a;
|
|
1539
|
-
if ((_a = heading == null ? void 0 : heading.data) == null ? void 0 : _a.id) {
|
|
1540
|
-
return heading.data.id;
|
|
1541
|
-
}
|
|
1542
|
-
let anchor = (0, import_mdast_util_to_string.toString)(heading, { includeImageAlt: false }).toLowerCase();
|
|
1543
|
-
anchor = anchor.replace(/[^a-zA-Z0-9 ]/g, "");
|
|
1544
|
-
anchor = anchor.replace(/ /g, "-");
|
|
1545
|
-
return anchor;
|
|
1546
|
-
};
|
|
1547
|
-
var headings = (root) => {
|
|
1548
|
-
const headingList = [];
|
|
1549
|
-
(0, import_unist_util_visit3.visit)(root, "heading", (node) => {
|
|
1550
|
-
const heading = {
|
|
1551
|
-
level: node.depth,
|
|
1552
|
-
label: (0, import_mdast_util_to_string.toString)(node, { includeImageAlt: false }),
|
|
1553
|
-
anchor: getAnchor(node)
|
|
1554
|
-
};
|
|
1555
|
-
headingList.push(heading);
|
|
1556
|
-
});
|
|
1557
|
-
return headingList;
|
|
1558
|
-
};
|
|
1559
|
-
var remarkHeadings = () => {
|
|
1560
|
-
return (tree, file) => {
|
|
1561
|
-
file.data.headings = headings(tree);
|
|
1562
|
-
};
|
|
1563
|
-
};
|
|
1564
|
-
|
|
1565
|
-
// src/useToc.ts
|
|
1566
|
-
var useToc = (markdown) => {
|
|
1567
|
-
return unified().use(remarkCustomHeadingIds).use(import_remark_parse2.default).use(import_remark_stringify.default).use(remarkHeadings).processSync(markdown).data.headings;
|
|
1568
|
-
};
|
|
1569
|
-
|
|
1570
|
-
// src/Markdown.tsx
|
|
1571
|
-
var import_react5 = require("react");
|
|
1572
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1573
|
-
var Markdown = ({ children, showToc = true }) => {
|
|
1574
|
-
const directives = (0, import_provider5.useDirectives)();
|
|
1575
|
-
const toc = useToc(children);
|
|
1576
|
-
const [isTocOpen, setIsTocOpen] = (0, import_react5.useState)(false);
|
|
1577
|
-
const reactContent = useRemarkSync(children, {
|
|
1578
|
-
rehypeReactOptions: {
|
|
1579
|
-
passNode: true,
|
|
1580
|
-
components: __spreadProps(__spreadValues({}, directives), {
|
|
1581
|
-
a: Link,
|
|
1582
|
-
code: Code,
|
|
1583
|
-
td: Td,
|
|
1584
|
-
th: Th,
|
|
1585
|
-
table: Table,
|
|
1586
|
-
tr: Tr,
|
|
1587
|
-
h1: Headings(1),
|
|
1588
|
-
h2: Headings(2),
|
|
1589
|
-
h3: Headings(3),
|
|
1590
|
-
h4: Headings(4),
|
|
1591
|
-
h5: Headings(5),
|
|
1592
|
-
h6: Headings(6),
|
|
1593
|
-
img: Image
|
|
1594
|
-
})
|
|
1595
|
-
},
|
|
1596
|
-
remarkPlugins: [
|
|
1597
|
-
remarkRemoveComments,
|
|
1598
|
-
remarkCustomHeadingIds,
|
|
1599
|
-
import_remark_gfm.default,
|
|
1600
|
-
import_remark_directive.default,
|
|
1601
|
-
import_remark_directive_rehype.default,
|
|
1602
|
-
import_remark_math.default,
|
|
1603
|
-
import_remark_gemoji.default,
|
|
1604
|
-
import_remark_unwrap_images.default
|
|
1605
|
-
],
|
|
1606
|
-
rehypePlugins: [
|
|
1607
|
-
import_rehype_katex.default,
|
|
1608
|
-
[import_rehype_highlight.default, { ignoreMissing: true, plainText: ["mermaid"] }]
|
|
1609
|
-
]
|
|
1610
|
-
});
|
|
1611
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyperbook-markdown", children: [
|
|
1612
|
-
showToc && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react5.Fragment, { children: [
|
|
1613
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1614
|
-
"button",
|
|
1615
|
-
{
|
|
1616
|
-
className: isTocOpen ? "toc-toggle open" : "toc-toggle",
|
|
1617
|
-
onClick: () => setIsTocOpen(!isTocOpen),
|
|
1618
|
-
title: "Table of Contents",
|
|
1619
|
-
children: [
|
|
1620
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "bar1" }),
|
|
1621
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "bar2" }),
|
|
1622
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "bar3" }),
|
|
1623
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "bar4" })
|
|
1624
|
-
]
|
|
1625
|
-
}
|
|
1626
|
-
),
|
|
1627
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1628
|
-
import_drawer.Drawer,
|
|
1629
|
-
{
|
|
1630
|
-
isOpen: isTocOpen,
|
|
1631
|
-
onClose: () => setIsTocOpen(false),
|
|
1632
|
-
position: "right",
|
|
1633
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { id: "toc-sidebar", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("nav", { className: "toc", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { children: toc.map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { className: `level-${h.level}`, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: `#${h.anchor}`, children: h.label }) }, i)) }) }) })
|
|
1634
|
-
}
|
|
1635
|
-
)
|
|
1636
|
-
] }),
|
|
1637
|
-
reactContent
|
|
1638
|
-
] });
|
|
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
|
-
*/
|
|
1650
|
-
//# sourceMappingURL=index.cjs.js.map
|