You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
10 KiB
JavaScript

9 months ago
"use strict";
/*
* ATTENTION: An "eval-source-map" devtool has been used.
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
exports.id = "vendor-chunks/vfile-location";
exports.ids = ["vendor-chunks/vfile-location"];
exports.modules = {
/***/ "(ssr)/./node_modules/vfile-location/lib/index.js":
/*!**************************************************!*\
!*** ./node_modules/vfile-location/lib/index.js ***!
\**************************************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ location: () => (/* binding */ location)\n/* harmony export */ });\n/**\n * @typedef {import('vfile').VFile} VFile\n * @typedef {import('vfile').Value} Value\n */ /**\n * @typedef Point\n * unist point, where `line` and `column` can be `undefined`.\n * @property {number | undefined} line\n * Line.\n * @property {number | undefined} column\n * Column.\n * @property {number | undefined} [offset]\n * Offset.\n *\n * @typedef PointLike\n * unist point, allowed as input.\n * @property {number | null | undefined} [line]\n * Line.\n * @property {number | null | undefined} [column]\n * Column.\n * @property {number | null | undefined} [offset]\n * Offset.\n *\n * @callback ToPoint\n * Get a line/column-based `point` from `offset`.\n * @param {number | null | undefined} [offset]\n * Something that should be an `offset.\n * @returns {Point}\n * Point, line/column are undefined for invalid or out of bounds input.\n *\n * @callback ToOffset\n * Get an offset from a line/column-based `point`.\n * @param {Point | null | undefined} [point]\n * Something that should be a `point.\n * @returns {number}\n * Offset or `-1` for invalid or out of bounds input.\n *\n * @typedef Location\n * Accessors for index.\n * @property {ToPoint} toPoint\n * Get a line/column-based `point` from `offset`.\n * @property {ToOffset} toOffset\n * Get an offset from a line/column-based `point`.\n */ /**\n * Index the given document so you can translate between line/column and offset\n * based positional info.\n *\n * @param {VFile | Value} file\n * File to index.\n * @returns {Location}\n * Accessors for index.\n */ function location(file) {\n const value = String(file);\n /** @type {Array<number>} */ const indices = [];\n const search = /\\r?\\n|\\r/g;\n while(search.test(value)){\n indices.push(search.lastIndex);\n }\n indices.push(value.length + 1);\n return {\n toPoint,\n toOffset\n };\n /** @type {ToPoint} */ function toPoint(offset) {\n let index = -1;\n if (typeof offset === \"number\" && offset > -1 && offset < indices[indices.length - 1]) {\n while(++index < indices.length){\n if (indices[index] > offset) {\n return {\n line: index + 1,\n column: offset - (index > 0 ? indices[index - 1] : 0) + 1,\n offset\n };\n }\n }\n }\n return {\n line: undefined,\n column: undefined,\n offset: undefined\n };\n }\n /** @type {ToOffset} */ function toOffset(point) {\n const line = point && point.line;\n const column = point && point.column;\n if (typeof line === \"number\" && typeof column === \"number\" && !Number.isNaN(line) && !Number.isNaN(column) && line - 1 in indices) {\n const offset = (indices[line - 2] || 0) + column - 1 || 0;\n if (offset > -1 && offset < indices[indices.length - 1]) {\n return offset;\n }\n }\n return -1;\n }\n}\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiKHNzcikvLi9ub2RlX21vZHVsZXMvdmZpbGUtbG9jYXRpb24vbGliL2luZGV4LmpzIiwibWFwcGluZ3MiOiI7Ozs7QUFBQTs7O0NBR0MsR0FFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0NBdUNDLEdBRUQ7Ozs7Ozs7O0NBUUMsR0FDTSxTQUFTQSxTQUFTQyxJQUFJO0lBQzNCLE1BQU1DLFFBQVFDLE9BQU9GO0lBQ3JCLDBCQUEwQixHQUMxQixNQUFNRyxVQUFVLEVBQUU7SUFDbEIsTUFBTUMsU0FBUztJQUVmLE1BQU9BLE9BQU9DLElBQUksQ0FBQ0osT0FBUTtRQUN6QkUsUUFBUUcsSUFBSSxDQUFDRixPQUFPRyxTQUFTO0lBQy9CO0lBRUFKLFFBQVFHLElBQUksQ0FBQ0wsTUFBTU8sTUFBTSxHQUFHO0lBRTVCLE9BQU87UUFBQ0M7UUFBU0M7SUFBUTtJQUV6QixvQkFBb0IsR0FDcEIsU0FBU0QsUUFBUUUsTUFBTTtRQUNyQixJQUFJQyxRQUFRLENBQUM7UUFFYixJQUNFLE9BQU9ELFdBQVcsWUFDbEJBLFNBQVMsQ0FBQyxLQUNWQSxTQUFTUixPQUFPLENBQUNBLFFBQVFLLE1BQU0sR0F
/***/ })
};
;