@quartz-community/syntax-highlighting 1.0.1 → 1.0.3

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 CHANGED
@@ -1,6 +1,5 @@
1
- import default2 from 'path';
2
- import default3 from 'process';
3
- import { fileURLToPath } from 'url';
1
+ import { unified } from 'unified';
2
+ import { VFile } from 'vfile';
4
3
 
5
4
  var __create = Object.create;
6
5
  var __defProp = Object.defineProperty;
@@ -5059,96 +5058,6 @@ var require_parse_numeric_range = __commonJS({
5059
5058
  }
5060
5059
  });
5061
5060
 
5062
- // node_modules/extend/index.js
5063
- var require_extend = __commonJS({
5064
- "node_modules/extend/index.js"(exports, module) {
5065
- var hasOwn = Object.prototype.hasOwnProperty;
5066
- var toStr = Object.prototype.toString;
5067
- var defineProperty = Object.defineProperty;
5068
- var gOPD = Object.getOwnPropertyDescriptor;
5069
- var isArray = function isArray2(arr) {
5070
- if (typeof Array.isArray === "function") {
5071
- return Array.isArray(arr);
5072
- }
5073
- return toStr.call(arr) === "[object Array]";
5074
- };
5075
- var isPlainObject2 = function isPlainObject3(obj) {
5076
- if (!obj || toStr.call(obj) !== "[object Object]") {
5077
- return false;
5078
- }
5079
- var hasOwnConstructor = hasOwn.call(obj, "constructor");
5080
- var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
5081
- if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
5082
- return false;
5083
- }
5084
- var key2;
5085
- for (key2 in obj) {
5086
- }
5087
- return typeof key2 === "undefined" || hasOwn.call(obj, key2);
5088
- };
5089
- var setProperty = function setProperty2(target, options) {
5090
- if (defineProperty && options.name === "__proto__") {
5091
- defineProperty(target, options.name, {
5092
- enumerable: true,
5093
- configurable: true,
5094
- value: options.newValue,
5095
- writable: true
5096
- });
5097
- } else {
5098
- target[options.name] = options.newValue;
5099
- }
5100
- };
5101
- var getProperty = function getProperty2(obj, name) {
5102
- if (name === "__proto__") {
5103
- if (!hasOwn.call(obj, name)) {
5104
- return void 0;
5105
- } else if (gOPD) {
5106
- return gOPD(obj, name).value;
5107
- }
5108
- }
5109
- return obj[name];
5110
- };
5111
- module.exports = function extend2() {
5112
- var options, name, src, copy, copyIsArray, clone2;
5113
- var target = arguments[0];
5114
- var i2 = 1;
5115
- var length = arguments.length;
5116
- var deep = false;
5117
- if (typeof target === "boolean") {
5118
- deep = target;
5119
- target = arguments[1] || {};
5120
- i2 = 2;
5121
- }
5122
- if (target == null || typeof target !== "object" && typeof target !== "function") {
5123
- target = {};
5124
- }
5125
- for (; i2 < length; ++i2) {
5126
- options = arguments[i2];
5127
- if (options != null) {
5128
- for (name in options) {
5129
- src = getProperty(target, name);
5130
- copy = getProperty(options, name);
5131
- if (target !== copy) {
5132
- if (deep && copy && (isPlainObject2(copy) || (copyIsArray = isArray(copy)))) {
5133
- if (copyIsArray) {
5134
- copyIsArray = false;
5135
- clone2 = src && isArray(src) ? src : [];
5136
- } else {
5137
- clone2 = src && isPlainObject2(src) ? src : {};
5138
- }
5139
- setProperty(target, { name, newValue: extend2(deep, clone2, copy) });
5140
- } else if (typeof copy !== "undefined") {
5141
- setProperty(target, { name, newValue: copy });
5142
- }
5143
- }
5144
- }
5145
- }
5146
- }
5147
- return target;
5148
- };
5149
- }
5150
- });
5151
-
5152
5061
  // node_modules/shiki/dist/rolldown-runtime-BBjsoOtd.mjs
5153
5062
  var __defProp2 = Object.defineProperty;
5154
5063
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -17921,1581 +17830,197 @@ function all2(node) {
17921
17830
  // node_modules/rehype-pretty-code/dist/index.js
17922
17831
  var import_parse_numeric_range = __toESM(require_parse_numeric_range());
17923
17832
 
17924
- // node_modules/bail/index.js
17925
- function bail(error) {
17926
- if (error) {
17927
- throw error;
17928
- }
17929
- }
17930
-
17931
- // node_modules/unified/lib/index.js
17932
- var import_extend = __toESM(require_extend());
17933
-
17934
17833
  // node_modules/devlop/lib/default.js
17935
17834
  function ok2() {
17936
17835
  }
17937
17836
 
17938
- // node_modules/is-plain-obj/index.js
17939
- function isPlainObject(value) {
17940
- if (typeof value !== "object" || value === null) {
17941
- return false;
17942
- }
17943
- const prototype = Object.getPrototypeOf(value);
17944
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
17945
- }
17946
-
17947
- // node_modules/trough/lib/index.js
17948
- function trough() {
17949
- const fns = [];
17950
- const pipeline = { run, use };
17951
- return pipeline;
17952
- function run(...values) {
17953
- let middlewareIndex = -1;
17954
- const callback = values.pop();
17955
- if (typeof callback !== "function") {
17956
- throw new TypeError("Expected function as last argument, not " + callback);
17957
- }
17958
- next2(null, ...values);
17959
- function next2(error, ...output) {
17960
- const fn = fns[++middlewareIndex];
17961
- let index2 = -1;
17962
- if (error) {
17963
- callback(error);
17964
- return;
17965
- }
17966
- while (++index2 < values.length) {
17967
- if (output[index2] === null || output[index2] === void 0) {
17968
- output[index2] = values[index2];
17969
- }
17970
- }
17971
- values = output;
17972
- if (fn) {
17973
- wrap(fn, next2)(...output);
17837
+ // node_modules/hast-util-parse-selector/lib/index.js
17838
+ var search = /[#.]/g;
17839
+ function parseSelector(selector, defaultTagName) {
17840
+ const value = selector || "";
17841
+ const props = {};
17842
+ let start = 0;
17843
+ let previous;
17844
+ let tagName;
17845
+ while (start < value.length) {
17846
+ search.lastIndex = start;
17847
+ const match = search.exec(value);
17848
+ const subvalue = value.slice(start, match ? match.index : value.length);
17849
+ if (subvalue) {
17850
+ if (!previous) {
17851
+ tagName = subvalue;
17852
+ } else if (previous === "#") {
17853
+ props.id = subvalue;
17854
+ } else if (Array.isArray(props.className)) {
17855
+ props.className.push(subvalue);
17974
17856
  } else {
17975
- callback(null, ...output);
17857
+ props.className = [subvalue];
17976
17858
  }
17859
+ start += subvalue.length;
17977
17860
  }
17978
- }
17979
- function use(middelware) {
17980
- if (typeof middelware !== "function") {
17981
- throw new TypeError(
17982
- "Expected `middelware` to be a function, not " + middelware
17983
- );
17861
+ if (match) {
17862
+ previous = match[0];
17863
+ start++;
17984
17864
  }
17985
- fns.push(middelware);
17986
- return pipeline;
17987
17865
  }
17866
+ return {
17867
+ type: "element",
17868
+ // @ts-expect-error: tag name is parsed.
17869
+ tagName: tagName || defaultTagName || "div",
17870
+ properties: props,
17871
+ children: []
17872
+ };
17988
17873
  }
17989
- function wrap(middleware, callback) {
17990
- let called;
17991
- return wrapped;
17992
- function wrapped(...parameters) {
17993
- const fnExpectsCallback = middleware.length > parameters.length;
17994
- let result;
17995
- if (fnExpectsCallback) {
17996
- parameters.push(done);
17997
- }
17998
- try {
17999
- result = middleware.apply(this, parameters);
18000
- } catch (error) {
18001
- const exception = (
18002
- /** @type {Error} */
18003
- error
17874
+
17875
+ // node_modules/hastscript/lib/create-h.js
17876
+ function createH(schema, defaultTagName, caseSensitive) {
17877
+ const adjust = caseSensitive ? createAdjustMap(caseSensitive) : void 0;
17878
+ function h3(selector, properties, ...children) {
17879
+ let node;
17880
+ if (selector === null || selector === void 0) {
17881
+ node = { type: "root", children: [] };
17882
+ const child = (
17883
+ /** @type {Child} */
17884
+ properties
18004
17885
  );
18005
- if (fnExpectsCallback && called) {
18006
- throw exception;
18007
- }
18008
- return done(exception);
18009
- }
18010
- if (!fnExpectsCallback) {
18011
- if (result && result.then && typeof result.then === "function") {
18012
- result.then(then, done);
18013
- } else if (result instanceof Error) {
18014
- done(result);
17886
+ children.unshift(child);
17887
+ } else {
17888
+ node = parseSelector(selector, defaultTagName);
17889
+ const lower = node.tagName.toLowerCase();
17890
+ const adjusted = adjust ? adjust.get(lower) : void 0;
17891
+ node.tagName = adjusted || lower;
17892
+ if (isChild(properties)) {
17893
+ children.unshift(properties);
18015
17894
  } else {
18016
- then(result);
17895
+ for (const [key2, value] of Object.entries(properties)) {
17896
+ addProperty(schema, node.properties, key2, value);
17897
+ }
18017
17898
  }
18018
17899
  }
17900
+ for (const child of children) {
17901
+ addChild(node.children, child);
17902
+ }
17903
+ if (node.type === "element" && node.tagName === "template") {
17904
+ node.content = { type: "root", children: node.children };
17905
+ node.children = [];
17906
+ }
17907
+ return node;
17908
+ }
17909
+ return h3;
17910
+ }
17911
+ function isChild(value) {
17912
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
17913
+ return true;
18019
17914
  }
18020
- function done(error, ...output) {
18021
- if (!called) {
18022
- called = true;
18023
- callback(error, ...output);
17915
+ if (typeof value.type !== "string") return false;
17916
+ const record = (
17917
+ /** @type {Record<string, unknown>} */
17918
+ value
17919
+ );
17920
+ const keys = Object.keys(value);
17921
+ for (const key2 of keys) {
17922
+ const value2 = record[key2];
17923
+ if (value2 && typeof value2 === "object") {
17924
+ if (!Array.isArray(value2)) return true;
17925
+ const list = (
17926
+ /** @type {ReadonlyArray<unknown>} */
17927
+ value2
17928
+ );
17929
+ for (const item of list) {
17930
+ if (typeof item !== "number" && typeof item !== "string") {
17931
+ return true;
17932
+ }
17933
+ }
18024
17934
  }
18025
17935
  }
18026
- function then(value) {
18027
- done(null, value);
17936
+ if ("children" in value && Array.isArray(value.children)) {
17937
+ return true;
18028
17938
  }
17939
+ return false;
18029
17940
  }
18030
-
18031
- // node_modules/unist-util-stringify-position/lib/index.js
18032
- function stringifyPosition(value) {
18033
- if (!value || typeof value !== "object") {
18034
- return "";
17941
+ function addProperty(schema, properties, key2, value) {
17942
+ const info = find(schema, key2);
17943
+ let result;
17944
+ if (value === null || value === void 0) return;
17945
+ if (typeof value === "number") {
17946
+ if (Number.isNaN(value)) return;
17947
+ result = value;
17948
+ } else if (typeof value === "boolean") {
17949
+ result = value;
17950
+ } else if (typeof value === "string") {
17951
+ if (info.spaceSeparated) {
17952
+ result = parse2(value);
17953
+ } else if (info.commaSeparated) {
17954
+ result = parse(value);
17955
+ } else if (info.commaOrSpaceSeparated) {
17956
+ result = parse2(parse(value).join(" "));
17957
+ } else {
17958
+ result = parsePrimitive(info, info.property, value);
17959
+ }
17960
+ } else if (Array.isArray(value)) {
17961
+ result = [...value];
17962
+ } else {
17963
+ result = info.property === "style" ? style(value) : String(value);
18035
17964
  }
18036
- if ("position" in value || "type" in value) {
18037
- return position(value.position);
17965
+ if (Array.isArray(result)) {
17966
+ const finalResult = [];
17967
+ for (const item of result) {
17968
+ finalResult.push(
17969
+ /** @type {number | string} */
17970
+ parsePrimitive(info, info.property, item)
17971
+ );
17972
+ }
17973
+ result = finalResult;
18038
17974
  }
18039
- if ("start" in value || "end" in value) {
18040
- return position(value);
17975
+ if (info.property === "className" && Array.isArray(properties.className)) {
17976
+ result = properties.className.concat(
17977
+ /** @type {Array<number | string> | number | string} */
17978
+ result
17979
+ );
18041
17980
  }
18042
- if ("line" in value || "column" in value) {
18043
- return point(value);
17981
+ properties[info.property] = result;
17982
+ }
17983
+ function addChild(nodes, value) {
17984
+ if (value === null || value === void 0) ; else if (typeof value === "number" || typeof value === "string") {
17985
+ nodes.push({ type: "text", value: String(value) });
17986
+ } else if (Array.isArray(value)) {
17987
+ for (const child of value) {
17988
+ addChild(nodes, child);
17989
+ }
17990
+ } else if (typeof value === "object" && "type" in value) {
17991
+ if (value.type === "root") {
17992
+ addChild(nodes, value.children);
17993
+ } else {
17994
+ nodes.push(value);
17995
+ }
17996
+ } else {
17997
+ throw new Error("Expected node, nodes, or string, got `" + value + "`");
18044
17998
  }
18045
- return "";
18046
17999
  }
18047
- function point(point3) {
18048
- return index(point3 && point3.line) + ":" + index(point3 && point3.column);
18000
+ function parsePrimitive(info, name, value) {
18001
+ if (typeof value === "string") {
18002
+ if (info.number && value && !Number.isNaN(Number(value))) {
18003
+ return Number(value);
18004
+ }
18005
+ if ((info.boolean || info.overloadedBoolean) && (value === "" || normalize(value) === normalize(name))) {
18006
+ return true;
18007
+ }
18008
+ }
18009
+ return value;
18049
18010
  }
18050
- function position(pos) {
18051
- return point(pos && pos.start) + "-" + point(pos && pos.end);
18011
+ function style(styles) {
18012
+ const result = [];
18013
+ for (const [key2, value] of Object.entries(styles)) {
18014
+ result.push([key2, value].join(": "));
18015
+ }
18016
+ return result.join("; ");
18052
18017
  }
18053
- function index(value) {
18054
- return value && typeof value === "number" ? value : 1;
18055
- }
18056
-
18057
- // node_modules/vfile-message/lib/index.js
18058
- var VFileMessage = class extends Error {
18059
- /**
18060
- * Create a message for `reason`.
18061
- *
18062
- * > 🪦 **Note**: also has obsolete signatures.
18063
- *
18064
- * @overload
18065
- * @param {string} reason
18066
- * @param {Options | null | undefined} [options]
18067
- * @returns
18068
- *
18069
- * @overload
18070
- * @param {string} reason
18071
- * @param {Node | NodeLike | null | undefined} parent
18072
- * @param {string | null | undefined} [origin]
18073
- * @returns
18074
- *
18075
- * @overload
18076
- * @param {string} reason
18077
- * @param {Point | Position | null | undefined} place
18078
- * @param {string | null | undefined} [origin]
18079
- * @returns
18080
- *
18081
- * @overload
18082
- * @param {string} reason
18083
- * @param {string | null | undefined} [origin]
18084
- * @returns
18085
- *
18086
- * @overload
18087
- * @param {Error | VFileMessage} cause
18088
- * @param {Node | NodeLike | null | undefined} parent
18089
- * @param {string | null | undefined} [origin]
18090
- * @returns
18091
- *
18092
- * @overload
18093
- * @param {Error | VFileMessage} cause
18094
- * @param {Point | Position | null | undefined} place
18095
- * @param {string | null | undefined} [origin]
18096
- * @returns
18097
- *
18098
- * @overload
18099
- * @param {Error | VFileMessage} cause
18100
- * @param {string | null | undefined} [origin]
18101
- * @returns
18102
- *
18103
- * @param {Error | VFileMessage | string} causeOrReason
18104
- * Reason for message, should use markdown.
18105
- * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
18106
- * Configuration (optional).
18107
- * @param {string | null | undefined} [origin]
18108
- * Place in code where the message originates (example:
18109
- * `'my-package:my-rule'` or `'my-rule'`).
18110
- * @returns
18111
- * Instance of `VFileMessage`.
18112
- */
18113
- // eslint-disable-next-line complexity
18114
- constructor(causeOrReason, optionsOrParentOrPlace, origin) {
18115
- super();
18116
- if (typeof optionsOrParentOrPlace === "string") {
18117
- origin = optionsOrParentOrPlace;
18118
- optionsOrParentOrPlace = void 0;
18119
- }
18120
- let reason = "";
18121
- let options = {};
18122
- let legacyCause = false;
18123
- if (optionsOrParentOrPlace) {
18124
- if ("line" in optionsOrParentOrPlace && "column" in optionsOrParentOrPlace) {
18125
- options = { place: optionsOrParentOrPlace };
18126
- } else if ("start" in optionsOrParentOrPlace && "end" in optionsOrParentOrPlace) {
18127
- options = { place: optionsOrParentOrPlace };
18128
- } else if ("type" in optionsOrParentOrPlace) {
18129
- options = {
18130
- ancestors: [optionsOrParentOrPlace],
18131
- place: optionsOrParentOrPlace.position
18132
- };
18133
- } else {
18134
- options = { ...optionsOrParentOrPlace };
18135
- }
18136
- }
18137
- if (typeof causeOrReason === "string") {
18138
- reason = causeOrReason;
18139
- } else if (!options.cause && causeOrReason) {
18140
- legacyCause = true;
18141
- reason = causeOrReason.message;
18142
- options.cause = causeOrReason;
18143
- }
18144
- if (!options.ruleId && !options.source && typeof origin === "string") {
18145
- const index2 = origin.indexOf(":");
18146
- if (index2 === -1) {
18147
- options.ruleId = origin;
18148
- } else {
18149
- options.source = origin.slice(0, index2);
18150
- options.ruleId = origin.slice(index2 + 1);
18151
- }
18152
- }
18153
- if (!options.place && options.ancestors && options.ancestors) {
18154
- const parent = options.ancestors[options.ancestors.length - 1];
18155
- if (parent) {
18156
- options.place = parent.position;
18157
- }
18158
- }
18159
- const start = options.place && "start" in options.place ? options.place.start : options.place;
18160
- this.ancestors = options.ancestors || void 0;
18161
- this.cause = options.cause || void 0;
18162
- this.column = start ? start.column : void 0;
18163
- this.fatal = void 0;
18164
- this.file = "";
18165
- this.message = reason;
18166
- this.line = start ? start.line : void 0;
18167
- this.name = stringifyPosition(options.place) || "1:1";
18168
- this.place = options.place || void 0;
18169
- this.reason = this.message;
18170
- this.ruleId = options.ruleId || void 0;
18171
- this.source = options.source || void 0;
18172
- this.stack = legacyCause && options.cause && typeof options.cause.stack === "string" ? options.cause.stack : "";
18173
- this.actual = void 0;
18174
- this.expected = void 0;
18175
- this.note = void 0;
18176
- this.url = void 0;
18177
- }
18178
- };
18179
- VFileMessage.prototype.file = "";
18180
- VFileMessage.prototype.name = "";
18181
- VFileMessage.prototype.reason = "";
18182
- VFileMessage.prototype.message = "";
18183
- VFileMessage.prototype.stack = "";
18184
- VFileMessage.prototype.column = void 0;
18185
- VFileMessage.prototype.line = void 0;
18186
- VFileMessage.prototype.ancestors = void 0;
18187
- VFileMessage.prototype.cause = void 0;
18188
- VFileMessage.prototype.fatal = void 0;
18189
- VFileMessage.prototype.place = void 0;
18190
- VFileMessage.prototype.ruleId = void 0;
18191
- VFileMessage.prototype.source = void 0;
18192
-
18193
- // node_modules/vfile/lib/minurl.shared.js
18194
- function isUrl(fileUrlOrPath) {
18195
- return Boolean(
18196
- fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && "href" in fileUrlOrPath && fileUrlOrPath.href && "protocol" in fileUrlOrPath && fileUrlOrPath.protocol && // @ts-expect-error: indexing is fine.
18197
- fileUrlOrPath.auth === void 0
18198
- );
18199
- }
18200
-
18201
- // node_modules/vfile/lib/index.js
18202
- var order = (
18203
- /** @type {const} */
18204
- [
18205
- "history",
18206
- "path",
18207
- "basename",
18208
- "stem",
18209
- "extname",
18210
- "dirname"
18211
- ]
18212
- );
18213
- var VFile = class {
18214
- /**
18215
- * Create a new virtual file.
18216
- *
18217
- * `options` is treated as:
18218
- *
18219
- * * `string` or `Uint8Array` — `{value: options}`
18220
- * * `URL` — `{path: options}`
18221
- * * `VFile` — shallow copies its data over to the new file
18222
- * * `object` — all fields are shallow copied over to the new file
18223
- *
18224
- * Path related fields are set in the following order (least specific to
18225
- * most specific): `history`, `path`, `basename`, `stem`, `extname`,
18226
- * `dirname`.
18227
- *
18228
- * You cannot set `dirname` or `extname` without setting either `history`,
18229
- * `path`, `basename`, or `stem` too.
18230
- *
18231
- * @param {Compatible | null | undefined} [value]
18232
- * File value.
18233
- * @returns
18234
- * New instance.
18235
- */
18236
- constructor(value) {
18237
- let options;
18238
- if (!value) {
18239
- options = {};
18240
- } else if (isUrl(value)) {
18241
- options = { path: value };
18242
- } else if (typeof value === "string" || isUint8Array(value)) {
18243
- options = { value };
18244
- } else {
18245
- options = value;
18246
- }
18247
- this.cwd = "cwd" in options ? "" : default3.cwd();
18248
- this.data = {};
18249
- this.history = [];
18250
- this.messages = [];
18251
- this.value;
18252
- this.map;
18253
- this.result;
18254
- this.stored;
18255
- let index2 = -1;
18256
- while (++index2 < order.length) {
18257
- const field2 = order[index2];
18258
- if (field2 in options && options[field2] !== void 0 && options[field2] !== null) {
18259
- this[field2] = field2 === "history" ? [...options[field2]] : options[field2];
18260
- }
18261
- }
18262
- let field;
18263
- for (field in options) {
18264
- if (!order.includes(field)) {
18265
- this[field] = options[field];
18266
- }
18267
- }
18268
- }
18269
- /**
18270
- * Get the basename (including extname) (example: `'index.min.js'`).
18271
- *
18272
- * @returns {string | undefined}
18273
- * Basename.
18274
- */
18275
- get basename() {
18276
- return typeof this.path === "string" ? default2.basename(this.path) : void 0;
18277
- }
18278
- /**
18279
- * Set basename (including extname) (`'index.min.js'`).
18280
- *
18281
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
18282
- * on windows).
18283
- * Cannot be nullified (use `file.path = file.dirname` instead).
18284
- *
18285
- * @param {string} basename
18286
- * Basename.
18287
- * @returns {undefined}
18288
- * Nothing.
18289
- */
18290
- set basename(basename2) {
18291
- assertNonEmpty(basename2, "basename");
18292
- assertPart(basename2, "basename");
18293
- this.path = default2.join(this.dirname || "", basename2);
18294
- }
18295
- /**
18296
- * Get the parent path (example: `'~'`).
18297
- *
18298
- * @returns {string | undefined}
18299
- * Dirname.
18300
- */
18301
- get dirname() {
18302
- return typeof this.path === "string" ? default2.dirname(this.path) : void 0;
18303
- }
18304
- /**
18305
- * Set the parent path (example: `'~'`).
18306
- *
18307
- * Cannot be set if there’s no `path` yet.
18308
- *
18309
- * @param {string | undefined} dirname
18310
- * Dirname.
18311
- * @returns {undefined}
18312
- * Nothing.
18313
- */
18314
- set dirname(dirname) {
18315
- assertPath(this.basename, "dirname");
18316
- this.path = default2.join(dirname || "", this.basename);
18317
- }
18318
- /**
18319
- * Get the extname (including dot) (example: `'.js'`).
18320
- *
18321
- * @returns {string | undefined}
18322
- * Extname.
18323
- */
18324
- get extname() {
18325
- return typeof this.path === "string" ? default2.extname(this.path) : void 0;
18326
- }
18327
- /**
18328
- * Set the extname (including dot) (example: `'.js'`).
18329
- *
18330
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
18331
- * on windows).
18332
- * Cannot be set if there’s no `path` yet.
18333
- *
18334
- * @param {string | undefined} extname
18335
- * Extname.
18336
- * @returns {undefined}
18337
- * Nothing.
18338
- */
18339
- set extname(extname) {
18340
- assertPart(extname, "extname");
18341
- assertPath(this.dirname, "extname");
18342
- if (extname) {
18343
- if (extname.codePointAt(0) !== 46) {
18344
- throw new Error("`extname` must start with `.`");
18345
- }
18346
- if (extname.includes(".", 1)) {
18347
- throw new Error("`extname` cannot contain multiple dots");
18348
- }
18349
- }
18350
- this.path = default2.join(this.dirname, this.stem + (extname || ""));
18351
- }
18352
- /**
18353
- * Get the full path (example: `'~/index.min.js'`).
18354
- *
18355
- * @returns {string}
18356
- * Path.
18357
- */
18358
- get path() {
18359
- return this.history[this.history.length - 1];
18360
- }
18361
- /**
18362
- * Set the full path (example: `'~/index.min.js'`).
18363
- *
18364
- * Cannot be nullified.
18365
- * You can set a file URL (a `URL` object with a `file:` protocol) which will
18366
- * be turned into a path with `url.fileURLToPath`.
18367
- *
18368
- * @param {URL | string} path
18369
- * Path.
18370
- * @returns {undefined}
18371
- * Nothing.
18372
- */
18373
- set path(path) {
18374
- if (isUrl(path)) {
18375
- path = fileURLToPath(path);
18376
- }
18377
- assertNonEmpty(path, "path");
18378
- if (this.path !== path) {
18379
- this.history.push(path);
18380
- }
18381
- }
18382
- /**
18383
- * Get the stem (basename w/o extname) (example: `'index.min'`).
18384
- *
18385
- * @returns {string | undefined}
18386
- * Stem.
18387
- */
18388
- get stem() {
18389
- return typeof this.path === "string" ? default2.basename(this.path, this.extname) : void 0;
18390
- }
18391
- /**
18392
- * Set the stem (basename w/o extname) (example: `'index.min'`).
18393
- *
18394
- * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
18395
- * on windows).
18396
- * Cannot be nullified (use `file.path = file.dirname` instead).
18397
- *
18398
- * @param {string} stem
18399
- * Stem.
18400
- * @returns {undefined}
18401
- * Nothing.
18402
- */
18403
- set stem(stem) {
18404
- assertNonEmpty(stem, "stem");
18405
- assertPart(stem, "stem");
18406
- this.path = default2.join(this.dirname || "", stem + (this.extname || ""));
18407
- }
18408
- // Normal prototypal methods.
18409
- /**
18410
- * Create a fatal message for `reason` associated with the file.
18411
- *
18412
- * The `fatal` field of the message is set to `true` (error; file not usable)
18413
- * and the `file` field is set to the current file path.
18414
- * The message is added to the `messages` field on `file`.
18415
- *
18416
- * > 🪦 **Note**: also has obsolete signatures.
18417
- *
18418
- * @overload
18419
- * @param {string} reason
18420
- * @param {MessageOptions | null | undefined} [options]
18421
- * @returns {never}
18422
- *
18423
- * @overload
18424
- * @param {string} reason
18425
- * @param {Node | NodeLike | null | undefined} parent
18426
- * @param {string | null | undefined} [origin]
18427
- * @returns {never}
18428
- *
18429
- * @overload
18430
- * @param {string} reason
18431
- * @param {Point | Position | null | undefined} place
18432
- * @param {string | null | undefined} [origin]
18433
- * @returns {never}
18434
- *
18435
- * @overload
18436
- * @param {string} reason
18437
- * @param {string | null | undefined} [origin]
18438
- * @returns {never}
18439
- *
18440
- * @overload
18441
- * @param {Error | VFileMessage} cause
18442
- * @param {Node | NodeLike | null | undefined} parent
18443
- * @param {string | null | undefined} [origin]
18444
- * @returns {never}
18445
- *
18446
- * @overload
18447
- * @param {Error | VFileMessage} cause
18448
- * @param {Point | Position | null | undefined} place
18449
- * @param {string | null | undefined} [origin]
18450
- * @returns {never}
18451
- *
18452
- * @overload
18453
- * @param {Error | VFileMessage} cause
18454
- * @param {string | null | undefined} [origin]
18455
- * @returns {never}
18456
- *
18457
- * @param {Error | VFileMessage | string} causeOrReason
18458
- * Reason for message, should use markdown.
18459
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
18460
- * Configuration (optional).
18461
- * @param {string | null | undefined} [origin]
18462
- * Place in code where the message originates (example:
18463
- * `'my-package:my-rule'` or `'my-rule'`).
18464
- * @returns {never}
18465
- * Never.
18466
- * @throws {VFileMessage}
18467
- * Message.
18468
- */
18469
- fail(causeOrReason, optionsOrParentOrPlace, origin) {
18470
- const message = this.message(causeOrReason, optionsOrParentOrPlace, origin);
18471
- message.fatal = true;
18472
- throw message;
18473
- }
18474
- /**
18475
- * Create an info message for `reason` associated with the file.
18476
- *
18477
- * The `fatal` field of the message is set to `undefined` (info; change
18478
- * likely not needed) and the `file` field is set to the current file path.
18479
- * The message is added to the `messages` field on `file`.
18480
- *
18481
- * > 🪦 **Note**: also has obsolete signatures.
18482
- *
18483
- * @overload
18484
- * @param {string} reason
18485
- * @param {MessageOptions | null | undefined} [options]
18486
- * @returns {VFileMessage}
18487
- *
18488
- * @overload
18489
- * @param {string} reason
18490
- * @param {Node | NodeLike | null | undefined} parent
18491
- * @param {string | null | undefined} [origin]
18492
- * @returns {VFileMessage}
18493
- *
18494
- * @overload
18495
- * @param {string} reason
18496
- * @param {Point | Position | null | undefined} place
18497
- * @param {string | null | undefined} [origin]
18498
- * @returns {VFileMessage}
18499
- *
18500
- * @overload
18501
- * @param {string} reason
18502
- * @param {string | null | undefined} [origin]
18503
- * @returns {VFileMessage}
18504
- *
18505
- * @overload
18506
- * @param {Error | VFileMessage} cause
18507
- * @param {Node | NodeLike | null | undefined} parent
18508
- * @param {string | null | undefined} [origin]
18509
- * @returns {VFileMessage}
18510
- *
18511
- * @overload
18512
- * @param {Error | VFileMessage} cause
18513
- * @param {Point | Position | null | undefined} place
18514
- * @param {string | null | undefined} [origin]
18515
- * @returns {VFileMessage}
18516
- *
18517
- * @overload
18518
- * @param {Error | VFileMessage} cause
18519
- * @param {string | null | undefined} [origin]
18520
- * @returns {VFileMessage}
18521
- *
18522
- * @param {Error | VFileMessage | string} causeOrReason
18523
- * Reason for message, should use markdown.
18524
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
18525
- * Configuration (optional).
18526
- * @param {string | null | undefined} [origin]
18527
- * Place in code where the message originates (example:
18528
- * `'my-package:my-rule'` or `'my-rule'`).
18529
- * @returns {VFileMessage}
18530
- * Message.
18531
- */
18532
- info(causeOrReason, optionsOrParentOrPlace, origin) {
18533
- const message = this.message(causeOrReason, optionsOrParentOrPlace, origin);
18534
- message.fatal = void 0;
18535
- return message;
18536
- }
18537
- /**
18538
- * Create a message for `reason` associated with the file.
18539
- *
18540
- * The `fatal` field of the message is set to `false` (warning; change may be
18541
- * needed) and the `file` field is set to the current file path.
18542
- * The message is added to the `messages` field on `file`.
18543
- *
18544
- * > 🪦 **Note**: also has obsolete signatures.
18545
- *
18546
- * @overload
18547
- * @param {string} reason
18548
- * @param {MessageOptions | null | undefined} [options]
18549
- * @returns {VFileMessage}
18550
- *
18551
- * @overload
18552
- * @param {string} reason
18553
- * @param {Node | NodeLike | null | undefined} parent
18554
- * @param {string | null | undefined} [origin]
18555
- * @returns {VFileMessage}
18556
- *
18557
- * @overload
18558
- * @param {string} reason
18559
- * @param {Point | Position | null | undefined} place
18560
- * @param {string | null | undefined} [origin]
18561
- * @returns {VFileMessage}
18562
- *
18563
- * @overload
18564
- * @param {string} reason
18565
- * @param {string | null | undefined} [origin]
18566
- * @returns {VFileMessage}
18567
- *
18568
- * @overload
18569
- * @param {Error | VFileMessage} cause
18570
- * @param {Node | NodeLike | null | undefined} parent
18571
- * @param {string | null | undefined} [origin]
18572
- * @returns {VFileMessage}
18573
- *
18574
- * @overload
18575
- * @param {Error | VFileMessage} cause
18576
- * @param {Point | Position | null | undefined} place
18577
- * @param {string | null | undefined} [origin]
18578
- * @returns {VFileMessage}
18579
- *
18580
- * @overload
18581
- * @param {Error | VFileMessage} cause
18582
- * @param {string | null | undefined} [origin]
18583
- * @returns {VFileMessage}
18584
- *
18585
- * @param {Error | VFileMessage | string} causeOrReason
18586
- * Reason for message, should use markdown.
18587
- * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
18588
- * Configuration (optional).
18589
- * @param {string | null | undefined} [origin]
18590
- * Place in code where the message originates (example:
18591
- * `'my-package:my-rule'` or `'my-rule'`).
18592
- * @returns {VFileMessage}
18593
- * Message.
18594
- */
18595
- message(causeOrReason, optionsOrParentOrPlace, origin) {
18596
- const message = new VFileMessage(
18597
- // @ts-expect-error: the overloads are fine.
18598
- causeOrReason,
18599
- optionsOrParentOrPlace,
18600
- origin
18601
- );
18602
- if (this.path) {
18603
- message.name = this.path + ":" + message.name;
18604
- message.file = this.path;
18605
- }
18606
- message.fatal = false;
18607
- this.messages.push(message);
18608
- return message;
18609
- }
18610
- /**
18611
- * Serialize the file.
18612
- *
18613
- * > **Note**: which encodings are supported depends on the engine.
18614
- * > For info on Node.js, see:
18615
- * > <https://nodejs.org/api/util.html#whatwg-supported-encodings>.
18616
- *
18617
- * @param {string | null | undefined} [encoding='utf8']
18618
- * Character encoding to understand `value` as when it’s a `Uint8Array`
18619
- * (default: `'utf-8'`).
18620
- * @returns {string}
18621
- * Serialized file.
18622
- */
18623
- toString(encoding) {
18624
- if (this.value === void 0) {
18625
- return "";
18626
- }
18627
- if (typeof this.value === "string") {
18628
- return this.value;
18629
- }
18630
- const decoder = new TextDecoder(encoding || void 0);
18631
- return decoder.decode(this.value);
18632
- }
18633
- };
18634
- function assertPart(part, name) {
18635
- if (part && part.includes(default2.sep)) {
18636
- throw new Error(
18637
- "`" + name + "` cannot be a path: did not expect `" + default2.sep + "`"
18638
- );
18639
- }
18640
- }
18641
- function assertNonEmpty(part, name) {
18642
- if (!part) {
18643
- throw new Error("`" + name + "` cannot be empty");
18644
- }
18645
- }
18646
- function assertPath(path, name) {
18647
- if (!path) {
18648
- throw new Error("Setting `" + name + "` requires `path` to be set too");
18649
- }
18650
- }
18651
- function isUint8Array(value) {
18652
- return Boolean(
18653
- value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
18654
- );
18655
- }
18656
-
18657
- // node_modules/unified/lib/callable-instance.js
18658
- var CallableInstance = (
18659
- /**
18660
- * @type {new <Parameters extends Array<unknown>, Result>(property: string | symbol) => (...parameters: Parameters) => Result}
18661
- */
18662
- /** @type {unknown} */
18663
- /**
18664
- * @this {Function}
18665
- * @param {string | symbol} property
18666
- * @returns {(...parameters: Array<unknown>) => unknown}
18667
- */
18668
- (function(property) {
18669
- const self = this;
18670
- const constr = self.constructor;
18671
- const proto2 = (
18672
- /** @type {Record<string | symbol, Function>} */
18673
- // Prototypes do exist.
18674
- // type-coverage:ignore-next-line
18675
- constr.prototype
18676
- );
18677
- const value = proto2[property];
18678
- const apply2 = function() {
18679
- return value.apply(apply2, arguments);
18680
- };
18681
- Object.setPrototypeOf(apply2, proto2);
18682
- return apply2;
18683
- })
18684
- );
18685
-
18686
- // node_modules/unified/lib/index.js
18687
- var own4 = {}.hasOwnProperty;
18688
- var Processor = class _Processor extends CallableInstance {
18689
- /**
18690
- * Create a processor.
18691
- */
18692
- constructor() {
18693
- super("copy");
18694
- this.Compiler = void 0;
18695
- this.Parser = void 0;
18696
- this.attachers = [];
18697
- this.compiler = void 0;
18698
- this.freezeIndex = -1;
18699
- this.frozen = void 0;
18700
- this.namespace = {};
18701
- this.parser = void 0;
18702
- this.transformers = trough();
18703
- }
18704
- /**
18705
- * Copy a processor.
18706
- *
18707
- * @deprecated
18708
- * This is a private internal method and should not be used.
18709
- * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
18710
- * New *unfrozen* processor ({@linkcode Processor}) that is
18711
- * configured to work the same as its ancestor.
18712
- * When the descendant processor is configured in the future it does not
18713
- * affect the ancestral processor.
18714
- */
18715
- copy() {
18716
- const destination = (
18717
- /** @type {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} */
18718
- new _Processor()
18719
- );
18720
- let index2 = -1;
18721
- while (++index2 < this.attachers.length) {
18722
- const attacher = this.attachers[index2];
18723
- destination.use(...attacher);
18724
- }
18725
- destination.data((0, import_extend.default)(true, {}, this.namespace));
18726
- return destination;
18727
- }
18728
- /**
18729
- * Configure the processor with info available to all plugins.
18730
- * Information is stored in an object.
18731
- *
18732
- * Typically, options can be given to a specific plugin, but sometimes it
18733
- * makes sense to have information shared with several plugins.
18734
- * For example, a list of HTML elements that are self-closing, which is
18735
- * needed during all phases.
18736
- *
18737
- * > **Note**: setting information cannot occur on *frozen* processors.
18738
- * > Call the processor first to create a new unfrozen processor.
18739
- *
18740
- * > **Note**: to register custom data in TypeScript, augment the
18741
- * > {@linkcode Data} interface.
18742
- *
18743
- * @example
18744
- * This example show how to get and set info:
18745
- *
18746
- * ```js
18747
- * import {unified} from 'unified'
18748
- *
18749
- * const processor = unified().data('alpha', 'bravo')
18750
- *
18751
- * processor.data('alpha') // => 'bravo'
18752
- *
18753
- * processor.data() // => {alpha: 'bravo'}
18754
- *
18755
- * processor.data({charlie: 'delta'})
18756
- *
18757
- * processor.data() // => {charlie: 'delta'}
18758
- * ```
18759
- *
18760
- * @template {keyof Data} Key
18761
- *
18762
- * @overload
18763
- * @returns {Data}
18764
- *
18765
- * @overload
18766
- * @param {Data} dataset
18767
- * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
18768
- *
18769
- * @overload
18770
- * @param {Key} key
18771
- * @returns {Data[Key]}
18772
- *
18773
- * @overload
18774
- * @param {Key} key
18775
- * @param {Data[Key]} value
18776
- * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
18777
- *
18778
- * @param {Data | Key} [key]
18779
- * Key to get or set, or entire dataset to set, or nothing to get the
18780
- * entire dataset (optional).
18781
- * @param {Data[Key]} [value]
18782
- * Value to set (optional).
18783
- * @returns {unknown}
18784
- * The current processor when setting, the value at `key` when getting, or
18785
- * the entire dataset when getting without key.
18786
- */
18787
- data(key2, value) {
18788
- if (typeof key2 === "string") {
18789
- if (arguments.length === 2) {
18790
- assertUnfrozen("data", this.frozen);
18791
- this.namespace[key2] = value;
18792
- return this;
18793
- }
18794
- return own4.call(this.namespace, key2) && this.namespace[key2] || void 0;
18795
- }
18796
- if (key2) {
18797
- assertUnfrozen("data", this.frozen);
18798
- this.namespace = key2;
18799
- return this;
18800
- }
18801
- return this.namespace;
18802
- }
18803
- /**
18804
- * Freeze a processor.
18805
- *
18806
- * Frozen processors are meant to be extended and not to be configured
18807
- * directly.
18808
- *
18809
- * When a processor is frozen it cannot be unfrozen.
18810
- * New processors working the same way can be created by calling the
18811
- * processor.
18812
- *
18813
- * It’s possible to freeze processors explicitly by calling `.freeze()`.
18814
- * Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`,
18815
- * `.stringify()`, `.process()`, or `.processSync()` are called.
18816
- *
18817
- * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
18818
- * The current processor.
18819
- */
18820
- freeze() {
18821
- if (this.frozen) {
18822
- return this;
18823
- }
18824
- const self = (
18825
- /** @type {Processor} */
18826
- /** @type {unknown} */
18827
- this
18828
- );
18829
- while (++this.freezeIndex < this.attachers.length) {
18830
- const [attacher, ...options] = this.attachers[this.freezeIndex];
18831
- if (options[0] === false) {
18832
- continue;
18833
- }
18834
- if (options[0] === true) {
18835
- options[0] = void 0;
18836
- }
18837
- const transformer = attacher.call(self, ...options);
18838
- if (typeof transformer === "function") {
18839
- this.transformers.use(transformer);
18840
- }
18841
- }
18842
- this.frozen = true;
18843
- this.freezeIndex = Number.POSITIVE_INFINITY;
18844
- return this;
18845
- }
18846
- /**
18847
- * Parse text to a syntax tree.
18848
- *
18849
- * > **Note**: `parse` freezes the processor if not already *frozen*.
18850
- *
18851
- * > **Note**: `parse` performs the parse phase, not the run phase or other
18852
- * > phases.
18853
- *
18854
- * @param {Compatible | undefined} [file]
18855
- * file to parse (optional); typically `string` or `VFile`; any value
18856
- * accepted as `x` in `new VFile(x)`.
18857
- * @returns {ParseTree extends undefined ? Node : ParseTree}
18858
- * Syntax tree representing `file`.
18859
- */
18860
- parse(file) {
18861
- this.freeze();
18862
- const realFile = vfile(file);
18863
- const parser = this.parser || this.Parser;
18864
- assertParser("parse", parser);
18865
- return parser(String(realFile), realFile);
18866
- }
18867
- /**
18868
- * Process the given file as configured on the processor.
18869
- *
18870
- * > **Note**: `process` freezes the processor if not already *frozen*.
18871
- *
18872
- * > **Note**: `process` performs the parse, run, and stringify phases.
18873
- *
18874
- * @overload
18875
- * @param {Compatible | undefined} file
18876
- * @param {ProcessCallback<VFileWithOutput<CompileResult>>} done
18877
- * @returns {undefined}
18878
- *
18879
- * @overload
18880
- * @param {Compatible | undefined} [file]
18881
- * @returns {Promise<VFileWithOutput<CompileResult>>}
18882
- *
18883
- * @param {Compatible | undefined} [file]
18884
- * File (optional); typically `string` or `VFile`]; any value accepted as
18885
- * `x` in `new VFile(x)`.
18886
- * @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done]
18887
- * Callback (optional).
18888
- * @returns {Promise<VFile> | undefined}
18889
- * Nothing if `done` is given.
18890
- * Otherwise a promise, rejected with a fatal error or resolved with the
18891
- * processed file.
18892
- *
18893
- * The parsed, transformed, and compiled value is available at
18894
- * `file.value` (see note).
18895
- *
18896
- * > **Note**: unified typically compiles by serializing: most
18897
- * > compilers return `string` (or `Uint8Array`).
18898
- * > Some compilers, such as the one configured with
18899
- * > [`rehype-react`][rehype-react], return other values (in this case, a
18900
- * > React tree).
18901
- * > If you’re using a compiler that doesn’t serialize, expect different
18902
- * > result values.
18903
- * >
18904
- * > To register custom results in TypeScript, add them to
18905
- * > {@linkcode CompileResultMap}.
18906
- *
18907
- * [rehype-react]: https://github.com/rehypejs/rehype-react
18908
- */
18909
- process(file, done) {
18910
- const self = this;
18911
- this.freeze();
18912
- assertParser("process", this.parser || this.Parser);
18913
- assertCompiler("process", this.compiler || this.Compiler);
18914
- return done ? executor(void 0, done) : new Promise(executor);
18915
- function executor(resolve, reject) {
18916
- const realFile = vfile(file);
18917
- const parseTree = (
18918
- /** @type {HeadTree extends undefined ? Node : HeadTree} */
18919
- /** @type {unknown} */
18920
- self.parse(realFile)
18921
- );
18922
- self.run(parseTree, realFile, function(error, tree, file2) {
18923
- if (error || !tree || !file2) {
18924
- return realDone(error);
18925
- }
18926
- const compileTree = (
18927
- /** @type {CompileTree extends undefined ? Node : CompileTree} */
18928
- /** @type {unknown} */
18929
- tree
18930
- );
18931
- const compileResult = self.stringify(compileTree, file2);
18932
- if (looksLikeAValue(compileResult)) {
18933
- file2.value = compileResult;
18934
- } else {
18935
- file2.result = compileResult;
18936
- }
18937
- realDone(
18938
- error,
18939
- /** @type {VFileWithOutput<CompileResult>} */
18940
- file2
18941
- );
18942
- });
18943
- function realDone(error, file2) {
18944
- if (error || !file2) {
18945
- reject(error);
18946
- } else if (resolve) {
18947
- resolve(file2);
18948
- } else {
18949
- done(void 0, file2);
18950
- }
18951
- }
18952
- }
18953
- }
18954
- /**
18955
- * Process the given file as configured on the processor.
18956
- *
18957
- * An error is thrown if asynchronous transforms are configured.
18958
- *
18959
- * > **Note**: `processSync` freezes the processor if not already *frozen*.
18960
- *
18961
- * > **Note**: `processSync` performs the parse, run, and stringify phases.
18962
- *
18963
- * @param {Compatible | undefined} [file]
18964
- * File (optional); typically `string` or `VFile`; any value accepted as
18965
- * `x` in `new VFile(x)`.
18966
- * @returns {VFileWithOutput<CompileResult>}
18967
- * The processed file.
18968
- *
18969
- * The parsed, transformed, and compiled value is available at
18970
- * `file.value` (see note).
18971
- *
18972
- * > **Note**: unified typically compiles by serializing: most
18973
- * > compilers return `string` (or `Uint8Array`).
18974
- * > Some compilers, such as the one configured with
18975
- * > [`rehype-react`][rehype-react], return other values (in this case, a
18976
- * > React tree).
18977
- * > If you’re using a compiler that doesn’t serialize, expect different
18978
- * > result values.
18979
- * >
18980
- * > To register custom results in TypeScript, add them to
18981
- * > {@linkcode CompileResultMap}.
18982
- *
18983
- * [rehype-react]: https://github.com/rehypejs/rehype-react
18984
- */
18985
- processSync(file) {
18986
- let complete = false;
18987
- let result;
18988
- this.freeze();
18989
- assertParser("processSync", this.parser || this.Parser);
18990
- assertCompiler("processSync", this.compiler || this.Compiler);
18991
- this.process(file, realDone);
18992
- assertDone("processSync", "process", complete);
18993
- return result;
18994
- function realDone(error, file2) {
18995
- complete = true;
18996
- bail(error);
18997
- result = file2;
18998
- }
18999
- }
19000
- /**
19001
- * Run *transformers* on a syntax tree.
19002
- *
19003
- * > **Note**: `run` freezes the processor if not already *frozen*.
19004
- *
19005
- * > **Note**: `run` performs the run phase, not other phases.
19006
- *
19007
- * @overload
19008
- * @param {HeadTree extends undefined ? Node : HeadTree} tree
19009
- * @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
19010
- * @returns {undefined}
19011
- *
19012
- * @overload
19013
- * @param {HeadTree extends undefined ? Node : HeadTree} tree
19014
- * @param {Compatible | undefined} file
19015
- * @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
19016
- * @returns {undefined}
19017
- *
19018
- * @overload
19019
- * @param {HeadTree extends undefined ? Node : HeadTree} tree
19020
- * @param {Compatible | undefined} [file]
19021
- * @returns {Promise<TailTree extends undefined ? Node : TailTree>}
19022
- *
19023
- * @param {HeadTree extends undefined ? Node : HeadTree} tree
19024
- * Tree to transform and inspect.
19025
- * @param {(
19026
- * RunCallback<TailTree extends undefined ? Node : TailTree> |
19027
- * Compatible
19028
- * )} [file]
19029
- * File associated with `node` (optional); any value accepted as `x` in
19030
- * `new VFile(x)`.
19031
- * @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
19032
- * Callback (optional).
19033
- * @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
19034
- * Nothing if `done` is given.
19035
- * Otherwise, a promise rejected with a fatal error or resolved with the
19036
- * transformed tree.
19037
- */
19038
- run(tree, file, done) {
19039
- assertNode(tree);
19040
- this.freeze();
19041
- const transformers = this.transformers;
19042
- if (!done && typeof file === "function") {
19043
- done = file;
19044
- file = void 0;
19045
- }
19046
- return done ? executor(void 0, done) : new Promise(executor);
19047
- function executor(resolve, reject) {
19048
- const realFile = vfile(file);
19049
- transformers.run(tree, realFile, realDone);
19050
- function realDone(error, outputTree, file2) {
19051
- const resultingTree = (
19052
- /** @type {TailTree extends undefined ? Node : TailTree} */
19053
- outputTree || tree
19054
- );
19055
- if (error) {
19056
- reject(error);
19057
- } else if (resolve) {
19058
- resolve(resultingTree);
19059
- } else {
19060
- done(void 0, resultingTree, file2);
19061
- }
19062
- }
19063
- }
19064
- }
19065
- /**
19066
- * Run *transformers* on a syntax tree.
19067
- *
19068
- * An error is thrown if asynchronous transforms are configured.
19069
- *
19070
- * > **Note**: `runSync` freezes the processor if not already *frozen*.
19071
- *
19072
- * > **Note**: `runSync` performs the run phase, not other phases.
19073
- *
19074
- * @param {HeadTree extends undefined ? Node : HeadTree} tree
19075
- * Tree to transform and inspect.
19076
- * @param {Compatible | undefined} [file]
19077
- * File associated with `node` (optional); any value accepted as `x` in
19078
- * `new VFile(x)`.
19079
- * @returns {TailTree extends undefined ? Node : TailTree}
19080
- * Transformed tree.
19081
- */
19082
- runSync(tree, file) {
19083
- let complete = false;
19084
- let result;
19085
- this.run(tree, file, realDone);
19086
- assertDone("runSync", "run", complete);
19087
- return result;
19088
- function realDone(error, tree2) {
19089
- bail(error);
19090
- result = tree2;
19091
- complete = true;
19092
- }
19093
- }
19094
- /**
19095
- * Compile a syntax tree.
19096
- *
19097
- * > **Note**: `stringify` freezes the processor if not already *frozen*.
19098
- *
19099
- * > **Note**: `stringify` performs the stringify phase, not the run phase
19100
- * > or other phases.
19101
- *
19102
- * @param {CompileTree extends undefined ? Node : CompileTree} tree
19103
- * Tree to compile.
19104
- * @param {Compatible | undefined} [file]
19105
- * File associated with `node` (optional); any value accepted as `x` in
19106
- * `new VFile(x)`.
19107
- * @returns {CompileResult extends undefined ? Value : CompileResult}
19108
- * Textual representation of the tree (see note).
19109
- *
19110
- * > **Note**: unified typically compiles by serializing: most compilers
19111
- * > return `string` (or `Uint8Array`).
19112
- * > Some compilers, such as the one configured with
19113
- * > [`rehype-react`][rehype-react], return other values (in this case, a
19114
- * > React tree).
19115
- * > If you’re using a compiler that doesn’t serialize, expect different
19116
- * > result values.
19117
- * >
19118
- * > To register custom results in TypeScript, add them to
19119
- * > {@linkcode CompileResultMap}.
19120
- *
19121
- * [rehype-react]: https://github.com/rehypejs/rehype-react
19122
- */
19123
- stringify(tree, file) {
19124
- this.freeze();
19125
- const realFile = vfile(file);
19126
- const compiler = this.compiler || this.Compiler;
19127
- assertCompiler("stringify", compiler);
19128
- assertNode(tree);
19129
- return compiler(tree, realFile);
19130
- }
19131
- /**
19132
- * Configure the processor to use a plugin, a list of usable values, or a
19133
- * preset.
19134
- *
19135
- * If the processor is already using a plugin, the previous plugin
19136
- * configuration is changed based on the options that are passed in.
19137
- * In other words, the plugin is not added a second time.
19138
- *
19139
- * > **Note**: `use` cannot be called on *frozen* processors.
19140
- * > Call the processor first to create a new unfrozen processor.
19141
- *
19142
- * @example
19143
- * There are many ways to pass plugins to `.use()`.
19144
- * This example gives an overview:
19145
- *
19146
- * ```js
19147
- * import {unified} from 'unified'
19148
- *
19149
- * unified()
19150
- * // Plugin with options:
19151
- * .use(pluginA, {x: true, y: true})
19152
- * // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
19153
- * .use(pluginA, {y: false, z: true})
19154
- * // Plugins:
19155
- * .use([pluginB, pluginC])
19156
- * // Two plugins, the second with options:
19157
- * .use([pluginD, [pluginE, {}]])
19158
- * // Preset with plugins and settings:
19159
- * .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
19160
- * // Settings only:
19161
- * .use({settings: {position: false}})
19162
- * ```
19163
- *
19164
- * @template {Array<unknown>} [Parameters=[]]
19165
- * @template {Node | string | undefined} [Input=undefined]
19166
- * @template [Output=Input]
19167
- *
19168
- * @overload
19169
- * @param {Preset | null | undefined} [preset]
19170
- * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
19171
- *
19172
- * @overload
19173
- * @param {PluggableList} list
19174
- * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
19175
- *
19176
- * @overload
19177
- * @param {Plugin<Parameters, Input, Output>} plugin
19178
- * @param {...(Parameters | [boolean])} parameters
19179
- * @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
19180
- *
19181
- * @param {PluggableList | Plugin | Preset | null | undefined} value
19182
- * Usable value.
19183
- * @param {...unknown} parameters
19184
- * Parameters, when a plugin is given as a usable value.
19185
- * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
19186
- * Current processor.
19187
- */
19188
- use(value, ...parameters) {
19189
- const attachers = this.attachers;
19190
- const namespace = this.namespace;
19191
- assertUnfrozen("use", this.frozen);
19192
- if (value === null || value === void 0) ; else if (typeof value === "function") {
19193
- addPlugin(value, parameters);
19194
- } else if (typeof value === "object") {
19195
- if (Array.isArray(value)) {
19196
- addList(value);
19197
- } else {
19198
- addPreset(value);
19199
- }
19200
- } else {
19201
- throw new TypeError("Expected usable value, not `" + value + "`");
19202
- }
19203
- return this;
19204
- function add(value2) {
19205
- if (typeof value2 === "function") {
19206
- addPlugin(value2, []);
19207
- } else if (typeof value2 === "object") {
19208
- if (Array.isArray(value2)) {
19209
- const [plugin, ...parameters2] = (
19210
- /** @type {PluginTuple<Array<unknown>>} */
19211
- value2
19212
- );
19213
- addPlugin(plugin, parameters2);
19214
- } else {
19215
- addPreset(value2);
19216
- }
19217
- } else {
19218
- throw new TypeError("Expected usable value, not `" + value2 + "`");
19219
- }
19220
- }
19221
- function addPreset(result) {
19222
- if (!("plugins" in result) && !("settings" in result)) {
19223
- throw new Error(
19224
- "Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither"
19225
- );
19226
- }
19227
- addList(result.plugins);
19228
- if (result.settings) {
19229
- namespace.settings = (0, import_extend.default)(true, namespace.settings, result.settings);
19230
- }
19231
- }
19232
- function addList(plugins) {
19233
- let index2 = -1;
19234
- if (plugins === null || plugins === void 0) ; else if (Array.isArray(plugins)) {
19235
- while (++index2 < plugins.length) {
19236
- const thing = plugins[index2];
19237
- add(thing);
19238
- }
19239
- } else {
19240
- throw new TypeError("Expected a list of plugins, not `" + plugins + "`");
19241
- }
19242
- }
19243
- function addPlugin(plugin, parameters2) {
19244
- let index2 = -1;
19245
- let entryIndex = -1;
19246
- while (++index2 < attachers.length) {
19247
- if (attachers[index2][0] === plugin) {
19248
- entryIndex = index2;
19249
- break;
19250
- }
19251
- }
19252
- if (entryIndex === -1) {
19253
- attachers.push([plugin, ...parameters2]);
19254
- } else if (parameters2.length > 0) {
19255
- let [primary, ...rest] = parameters2;
19256
- const currentPrimary = attachers[entryIndex][1];
19257
- if (isPlainObject(currentPrimary) && isPlainObject(primary)) {
19258
- primary = (0, import_extend.default)(true, currentPrimary, primary);
19259
- }
19260
- attachers[entryIndex] = [plugin, primary, ...rest];
19261
- }
19262
- }
19263
- }
19264
- };
19265
- var unified = new Processor().freeze();
19266
- function assertParser(name, value) {
19267
- if (typeof value !== "function") {
19268
- throw new TypeError("Cannot `" + name + "` without `parser`");
19269
- }
19270
- }
19271
- function assertCompiler(name, value) {
19272
- if (typeof value !== "function") {
19273
- throw new TypeError("Cannot `" + name + "` without `compiler`");
19274
- }
19275
- }
19276
- function assertUnfrozen(name, frozen) {
19277
- if (frozen) {
19278
- throw new Error(
19279
- "Cannot call `" + name + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`."
19280
- );
19281
- }
19282
- }
19283
- function assertNode(node) {
19284
- if (!isPlainObject(node) || typeof node.type !== "string") {
19285
- throw new TypeError("Expected node, got `" + node + "`");
19286
- }
19287
- }
19288
- function assertDone(name, asyncName, complete) {
19289
- if (!complete) {
19290
- throw new Error(
19291
- "`" + name + "` finished async. Use `" + asyncName + "` instead"
19292
- );
19293
- }
19294
- }
19295
- function vfile(value) {
19296
- return looksLikeAVFile(value) ? value : new VFile(value);
19297
- }
19298
- function looksLikeAVFile(value) {
19299
- return Boolean(
19300
- value && typeof value === "object" && "message" in value && "messages" in value
19301
- );
19302
- }
19303
- function looksLikeAValue(value) {
19304
- return typeof value === "string" || isUint8Array2(value);
19305
- }
19306
- function isUint8Array2(value) {
19307
- return Boolean(
19308
- value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
19309
- );
19310
- }
19311
-
19312
- // node_modules/hast-util-parse-selector/lib/index.js
19313
- var search = /[#.]/g;
19314
- function parseSelector(selector, defaultTagName) {
19315
- const value = selector || "";
19316
- const props = {};
19317
- let start = 0;
19318
- let previous;
19319
- let tagName;
19320
- while (start < value.length) {
19321
- search.lastIndex = start;
19322
- const match = search.exec(value);
19323
- const subvalue = value.slice(start, match ? match.index : value.length);
19324
- if (subvalue) {
19325
- if (!previous) {
19326
- tagName = subvalue;
19327
- } else if (previous === "#") {
19328
- props.id = subvalue;
19329
- } else if (Array.isArray(props.className)) {
19330
- props.className.push(subvalue);
19331
- } else {
19332
- props.className = [subvalue];
19333
- }
19334
- start += subvalue.length;
19335
- }
19336
- if (match) {
19337
- previous = match[0];
19338
- start++;
19339
- }
19340
- }
19341
- return {
19342
- type: "element",
19343
- // @ts-expect-error: tag name is parsed.
19344
- tagName: tagName || defaultTagName || "div",
19345
- properties: props,
19346
- children: []
19347
- };
19348
- }
19349
-
19350
- // node_modules/hastscript/lib/create-h.js
19351
- function createH(schema, defaultTagName, caseSensitive) {
19352
- const adjust = caseSensitive ? createAdjustMap(caseSensitive) : void 0;
19353
- function h3(selector, properties, ...children) {
19354
- let node;
19355
- if (selector === null || selector === void 0) {
19356
- node = { type: "root", children: [] };
19357
- const child = (
19358
- /** @type {Child} */
19359
- properties
19360
- );
19361
- children.unshift(child);
19362
- } else {
19363
- node = parseSelector(selector, defaultTagName);
19364
- const lower = node.tagName.toLowerCase();
19365
- const adjusted = adjust ? adjust.get(lower) : void 0;
19366
- node.tagName = adjusted || lower;
19367
- if (isChild(properties)) {
19368
- children.unshift(properties);
19369
- } else {
19370
- for (const [key2, value] of Object.entries(properties)) {
19371
- addProperty(schema, node.properties, key2, value);
19372
- }
19373
- }
19374
- }
19375
- for (const child of children) {
19376
- addChild(node.children, child);
19377
- }
19378
- if (node.type === "element" && node.tagName === "template") {
19379
- node.content = { type: "root", children: node.children };
19380
- node.children = [];
19381
- }
19382
- return node;
19383
- }
19384
- return h3;
19385
- }
19386
- function isChild(value) {
19387
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
19388
- return true;
19389
- }
19390
- if (typeof value.type !== "string") return false;
19391
- const record = (
19392
- /** @type {Record<string, unknown>} */
19393
- value
19394
- );
19395
- const keys = Object.keys(value);
19396
- for (const key2 of keys) {
19397
- const value2 = record[key2];
19398
- if (value2 && typeof value2 === "object") {
19399
- if (!Array.isArray(value2)) return true;
19400
- const list = (
19401
- /** @type {ReadonlyArray<unknown>} */
19402
- value2
19403
- );
19404
- for (const item of list) {
19405
- if (typeof item !== "number" && typeof item !== "string") {
19406
- return true;
19407
- }
19408
- }
19409
- }
19410
- }
19411
- if ("children" in value && Array.isArray(value.children)) {
19412
- return true;
19413
- }
19414
- return false;
19415
- }
19416
- function addProperty(schema, properties, key2, value) {
19417
- const info = find(schema, key2);
19418
- let result;
19419
- if (value === null || value === void 0) return;
19420
- if (typeof value === "number") {
19421
- if (Number.isNaN(value)) return;
19422
- result = value;
19423
- } else if (typeof value === "boolean") {
19424
- result = value;
19425
- } else if (typeof value === "string") {
19426
- if (info.spaceSeparated) {
19427
- result = parse2(value);
19428
- } else if (info.commaSeparated) {
19429
- result = parse(value);
19430
- } else if (info.commaOrSpaceSeparated) {
19431
- result = parse2(parse(value).join(" "));
19432
- } else {
19433
- result = parsePrimitive(info, info.property, value);
19434
- }
19435
- } else if (Array.isArray(value)) {
19436
- result = [...value];
19437
- } else {
19438
- result = info.property === "style" ? style(value) : String(value);
19439
- }
19440
- if (Array.isArray(result)) {
19441
- const finalResult = [];
19442
- for (const item of result) {
19443
- finalResult.push(
19444
- /** @type {number | string} */
19445
- parsePrimitive(info, info.property, item)
19446
- );
19447
- }
19448
- result = finalResult;
19449
- }
19450
- if (info.property === "className" && Array.isArray(properties.className)) {
19451
- result = properties.className.concat(
19452
- /** @type {Array<number | string> | number | string} */
19453
- result
19454
- );
19455
- }
19456
- properties[info.property] = result;
19457
- }
19458
- function addChild(nodes, value) {
19459
- if (value === null || value === void 0) ; else if (typeof value === "number" || typeof value === "string") {
19460
- nodes.push({ type: "text", value: String(value) });
19461
- } else if (Array.isArray(value)) {
19462
- for (const child of value) {
19463
- addChild(nodes, child);
19464
- }
19465
- } else if (typeof value === "object" && "type" in value) {
19466
- if (value.type === "root") {
19467
- addChild(nodes, value.children);
19468
- } else {
19469
- nodes.push(value);
19470
- }
19471
- } else {
19472
- throw new Error("Expected node, nodes, or string, got `" + value + "`");
19473
- }
19474
- }
19475
- function parsePrimitive(info, name, value) {
19476
- if (typeof value === "string") {
19477
- if (info.number && value && !Number.isNaN(Number(value))) {
19478
- return Number(value);
19479
- }
19480
- if ((info.boolean || info.overloadedBoolean) && (value === "" || normalize(value) === normalize(name))) {
19481
- return true;
19482
- }
19483
- }
19484
- return value;
19485
- }
19486
- function style(styles) {
19487
- const result = [];
19488
- for (const [key2, value] of Object.entries(styles)) {
19489
- result.push([key2, value].join(": "));
19490
- }
19491
- return result.join("; ");
19492
- }
19493
- function createAdjustMap(values) {
19494
- const result = /* @__PURE__ */ new Map();
19495
- for (const value of values) {
19496
- result.set(value.toLowerCase(), value);
19497
- }
19498
- return result;
18018
+ function createAdjustMap(values) {
18019
+ const result = /* @__PURE__ */ new Map();
18020
+ for (const value of values) {
18021
+ result.set(value.toLowerCase(), value);
18022
+ }
18023
+ return result;
19499
18024
  }
19500
18025
 
19501
18026
  // node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
@@ -19598,7 +18123,7 @@ var webNamespaces = {
19598
18123
  svg: "http://www.w3.org/2000/svg"};
19599
18124
 
19600
18125
  // node_modules/hast-util-from-parse5/lib/index.js
19601
- var own5 = {}.hasOwnProperty;
18126
+ var own4 = {}.hasOwnProperty;
19602
18127
  var proto = Object.prototype;
19603
18128
  function fromParse5(tree, options) {
19604
18129
  const settings = options || {};
@@ -19694,7 +18219,7 @@ function element2(state, node) {
19694
18219
  while (++index2 < node.attrs.length) {
19695
18220
  const attribute = node.attrs[index2];
19696
18221
  const name = (attribute.prefix ? attribute.prefix + ":" : "") + attribute.name;
19697
- if (!own5.call(proto, name)) {
18222
+ if (!own4.call(proto, name)) {
19698
18223
  properties[name] = attribute.value;
19699
18224
  }
19700
18225
  }
@@ -19707,8 +18232,8 @@ function element2(state, node) {
19707
18232
  node
19708
18233
  );
19709
18234
  const pos = reference.sourceCodeLocation;
19710
- const startTag = pos && pos.startTag && position2(pos.startTag);
19711
- const endTag = pos && pos.endTag && position2(pos.endTag);
18235
+ const startTag = pos && pos.startTag && position(pos.startTag);
18236
+ const endTag = pos && pos.endTag && position(pos.endTag);
19712
18237
  const content = (
19713
18238
  /** @type {Root} */
19714
18239
  one3(state, reference.content)
@@ -19731,7 +18256,7 @@ function patch(state, from, to) {
19731
18256
  }
19732
18257
  }
19733
18258
  function createLocation(state, node, location2) {
19734
- const result = position2(location2);
18259
+ const result = position(location2);
19735
18260
  if (node.type === "element") {
19736
18261
  const tail = node.children[node.children.length - 1];
19737
18262
  if (result && !location2.endTag && tail && tail.position && tail.position.end) {
@@ -19742,16 +18267,16 @@ function createLocation(state, node, location2) {
19742
18267
  let key2;
19743
18268
  if (location2.attrs) {
19744
18269
  for (key2 in location2.attrs) {
19745
- if (own5.call(location2.attrs, key2)) {
19746
- properties[find(state.schema, key2).property] = position2(
18270
+ if (own4.call(location2.attrs, key2)) {
18271
+ properties[find(state.schema, key2).property] = position(
19747
18272
  location2.attrs[key2]
19748
18273
  );
19749
18274
  }
19750
18275
  }
19751
18276
  }
19752
18277
  ok2(location2.startTag);
19753
- const opening2 = position2(location2.startTag);
19754
- const closing2 = location2.endTag ? position2(location2.endTag) : void 0;
18278
+ const opening2 = position(location2.startTag);
18279
+ const closing2 = location2.endTag ? position(location2.endTag) : void 0;
19755
18280
  const data = { opening: opening2 };
19756
18281
  if (closing2) data.closing = closing2;
19757
18282
  data.properties = properties;
@@ -19760,20 +18285,20 @@ function createLocation(state, node, location2) {
19760
18285
  }
19761
18286
  return result;
19762
18287
  }
19763
- function position2(loc) {
19764
- const start = point2({
18288
+ function position(loc) {
18289
+ const start = point({
19765
18290
  line: loc.startLine,
19766
18291
  column: loc.startCol,
19767
18292
  offset: loc.startOffset
19768
18293
  });
19769
- const end = point2({
18294
+ const end = point({
19770
18295
  line: loc.endLine,
19771
18296
  column: loc.endCol,
19772
18297
  offset: loc.endOffset
19773
18298
  });
19774
18299
  return start || end ? { start, end } : void 0;
19775
18300
  }
19776
- function point2(point3) {
18301
+ function point(point3) {
19777
18302
  return point3.line && point3.column ? point3 : void 0;
19778
18303
  }
19779
18304
 
@@ -27599,6 +26124,168 @@ function parseFragment2(fragmentContext, html5, options) {
27599
26124
  return parser.getFragment();
27600
26125
  }
27601
26126
 
26127
+ // node_modules/unist-util-stringify-position/lib/index.js
26128
+ function stringifyPosition(value) {
26129
+ if (!value || typeof value !== "object") {
26130
+ return "";
26131
+ }
26132
+ if ("position" in value || "type" in value) {
26133
+ return position2(value.position);
26134
+ }
26135
+ if ("start" in value || "end" in value) {
26136
+ return position2(value);
26137
+ }
26138
+ if ("line" in value || "column" in value) {
26139
+ return point2(value);
26140
+ }
26141
+ return "";
26142
+ }
26143
+ function point2(point3) {
26144
+ return index(point3 && point3.line) + ":" + index(point3 && point3.column);
26145
+ }
26146
+ function position2(pos) {
26147
+ return point2(pos && pos.start) + "-" + point2(pos && pos.end);
26148
+ }
26149
+ function index(value) {
26150
+ return value && typeof value === "number" ? value : 1;
26151
+ }
26152
+
26153
+ // node_modules/vfile-message/lib/index.js
26154
+ var VFileMessage = class extends Error {
26155
+ /**
26156
+ * Create a message for `reason`.
26157
+ *
26158
+ * > 🪦 **Note**: also has obsolete signatures.
26159
+ *
26160
+ * @overload
26161
+ * @param {string} reason
26162
+ * @param {Options | null | undefined} [options]
26163
+ * @returns
26164
+ *
26165
+ * @overload
26166
+ * @param {string} reason
26167
+ * @param {Node | NodeLike | null | undefined} parent
26168
+ * @param {string | null | undefined} [origin]
26169
+ * @returns
26170
+ *
26171
+ * @overload
26172
+ * @param {string} reason
26173
+ * @param {Point | Position | null | undefined} place
26174
+ * @param {string | null | undefined} [origin]
26175
+ * @returns
26176
+ *
26177
+ * @overload
26178
+ * @param {string} reason
26179
+ * @param {string | null | undefined} [origin]
26180
+ * @returns
26181
+ *
26182
+ * @overload
26183
+ * @param {Error | VFileMessage} cause
26184
+ * @param {Node | NodeLike | null | undefined} parent
26185
+ * @param {string | null | undefined} [origin]
26186
+ * @returns
26187
+ *
26188
+ * @overload
26189
+ * @param {Error | VFileMessage} cause
26190
+ * @param {Point | Position | null | undefined} place
26191
+ * @param {string | null | undefined} [origin]
26192
+ * @returns
26193
+ *
26194
+ * @overload
26195
+ * @param {Error | VFileMessage} cause
26196
+ * @param {string | null | undefined} [origin]
26197
+ * @returns
26198
+ *
26199
+ * @param {Error | VFileMessage | string} causeOrReason
26200
+ * Reason for message, should use markdown.
26201
+ * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
26202
+ * Configuration (optional).
26203
+ * @param {string | null | undefined} [origin]
26204
+ * Place in code where the message originates (example:
26205
+ * `'my-package:my-rule'` or `'my-rule'`).
26206
+ * @returns
26207
+ * Instance of `VFileMessage`.
26208
+ */
26209
+ // eslint-disable-next-line complexity
26210
+ constructor(causeOrReason, optionsOrParentOrPlace, origin) {
26211
+ super();
26212
+ if (typeof optionsOrParentOrPlace === "string") {
26213
+ origin = optionsOrParentOrPlace;
26214
+ optionsOrParentOrPlace = void 0;
26215
+ }
26216
+ let reason = "";
26217
+ let options = {};
26218
+ let legacyCause = false;
26219
+ if (optionsOrParentOrPlace) {
26220
+ if ("line" in optionsOrParentOrPlace && "column" in optionsOrParentOrPlace) {
26221
+ options = { place: optionsOrParentOrPlace };
26222
+ } else if ("start" in optionsOrParentOrPlace && "end" in optionsOrParentOrPlace) {
26223
+ options = { place: optionsOrParentOrPlace };
26224
+ } else if ("type" in optionsOrParentOrPlace) {
26225
+ options = {
26226
+ ancestors: [optionsOrParentOrPlace],
26227
+ place: optionsOrParentOrPlace.position
26228
+ };
26229
+ } else {
26230
+ options = { ...optionsOrParentOrPlace };
26231
+ }
26232
+ }
26233
+ if (typeof causeOrReason === "string") {
26234
+ reason = causeOrReason;
26235
+ } else if (!options.cause && causeOrReason) {
26236
+ legacyCause = true;
26237
+ reason = causeOrReason.message;
26238
+ options.cause = causeOrReason;
26239
+ }
26240
+ if (!options.ruleId && !options.source && typeof origin === "string") {
26241
+ const index2 = origin.indexOf(":");
26242
+ if (index2 === -1) {
26243
+ options.ruleId = origin;
26244
+ } else {
26245
+ options.source = origin.slice(0, index2);
26246
+ options.ruleId = origin.slice(index2 + 1);
26247
+ }
26248
+ }
26249
+ if (!options.place && options.ancestors && options.ancestors) {
26250
+ const parent = options.ancestors[options.ancestors.length - 1];
26251
+ if (parent) {
26252
+ options.place = parent.position;
26253
+ }
26254
+ }
26255
+ const start = options.place && "start" in options.place ? options.place.start : options.place;
26256
+ this.ancestors = options.ancestors || void 0;
26257
+ this.cause = options.cause || void 0;
26258
+ this.column = start ? start.column : void 0;
26259
+ this.fatal = void 0;
26260
+ this.file = "";
26261
+ this.message = reason;
26262
+ this.line = start ? start.line : void 0;
26263
+ this.name = stringifyPosition(options.place) || "1:1";
26264
+ this.place = options.place || void 0;
26265
+ this.reason = this.message;
26266
+ this.ruleId = options.ruleId || void 0;
26267
+ this.source = options.source || void 0;
26268
+ this.stack = legacyCause && options.cause && typeof options.cause.stack === "string" ? options.cause.stack : "";
26269
+ this.actual = void 0;
26270
+ this.expected = void 0;
26271
+ this.note = void 0;
26272
+ this.url = void 0;
26273
+ }
26274
+ };
26275
+ VFileMessage.prototype.file = "";
26276
+ VFileMessage.prototype.name = "";
26277
+ VFileMessage.prototype.reason = "";
26278
+ VFileMessage.prototype.message = "";
26279
+ VFileMessage.prototype.stack = "";
26280
+ VFileMessage.prototype.column = void 0;
26281
+ VFileMessage.prototype.line = void 0;
26282
+ VFileMessage.prototype.ancestors = void 0;
26283
+ VFileMessage.prototype.cause = void 0;
26284
+ VFileMessage.prototype.fatal = void 0;
26285
+ VFileMessage.prototype.place = void 0;
26286
+ VFileMessage.prototype.ruleId = void 0;
26287
+ VFileMessage.prototype.source = void 0;
26288
+
27602
26289
  // node_modules/hast-util-from-html/lib/errors.js
27603
26290
  var errors = {
27604
26291
  /** @type {ErrorInfo} */