649 lines
35 KiB
JavaScript
649 lines
35 KiB
JavaScript
|
"use strict";
|
||
|
var __create = Object.create;
|
||
|
var __defProp = Object.defineProperty;
|
||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
|
var __getProtoOf = Object.getPrototypeOf;
|
||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
|
var __esm = (fn, res) => function __init() {
|
||
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
||
|
};
|
||
|
var __commonJS = (cb, mod) => function __require() {
|
||
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||
|
};
|
||
|
var __export = (target, all) => {
|
||
|
for (var name in all)
|
||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||
|
};
|
||
|
var __copyProps = (to, from, except, desc) => {
|
||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||
|
for (let key of __getOwnPropNames(from))
|
||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||
|
}
|
||
|
return to;
|
||
|
};
|
||
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||
|
// If the importer is in node compatibility mode or this is not an ESM
|
||
|
// file that has been converted to a CommonJS file using a Babel-
|
||
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
||
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
||
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||
|
mod
|
||
|
));
|
||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||
|
|
||
|
// src/utils/skip.js
|
||
|
function skip(characters) {
|
||
|
return (text, startIndex, options) => {
|
||
|
const backwards = Boolean(options == null ? void 0 : options.backwards);
|
||
|
if (startIndex === false) {
|
||
|
return false;
|
||
|
}
|
||
|
const { length } = text;
|
||
|
let cursor = startIndex;
|
||
|
while (cursor >= 0 && cursor < length) {
|
||
|
const character = text.charAt(cursor);
|
||
|
if (characters instanceof RegExp) {
|
||
|
if (!characters.test(character)) {
|
||
|
return cursor;
|
||
|
}
|
||
|
} else if (!characters.includes(character)) {
|
||
|
return cursor;
|
||
|
}
|
||
|
backwards ? cursor-- : cursor++;
|
||
|
}
|
||
|
if (cursor === -1 || cursor === length) {
|
||
|
return cursor;
|
||
|
}
|
||
|
return false;
|
||
|
};
|
||
|
}
|
||
|
var skipWhitespace, skipSpaces, skipToLineEnd, skipEverythingButNewLine;
|
||
|
var init_skip = __esm({
|
||
|
"src/utils/skip.js"() {
|
||
|
skipWhitespace = skip(/\s/);
|
||
|
skipSpaces = skip(" ");
|
||
|
skipToLineEnd = skip(",; ");
|
||
|
skipEverythingButNewLine = skip(/[^\n\r]/);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/skip-inline-comment.js
|
||
|
function skipInlineComment(text, startIndex) {
|
||
|
if (startIndex === false) {
|
||
|
return false;
|
||
|
}
|
||
|
if (text.charAt(startIndex) === "/" && text.charAt(startIndex + 1) === "*") {
|
||
|
for (let i = startIndex + 2; i < text.length; ++i) {
|
||
|
if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
|
||
|
return i + 2;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return startIndex;
|
||
|
}
|
||
|
var skip_inline_comment_default;
|
||
|
var init_skip_inline_comment = __esm({
|
||
|
"src/utils/skip-inline-comment.js"() {
|
||
|
skip_inline_comment_default = skipInlineComment;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/skip-newline.js
|
||
|
function skipNewline(text, startIndex, options) {
|
||
|
const backwards = Boolean(options == null ? void 0 : options.backwards);
|
||
|
if (startIndex === false) {
|
||
|
return false;
|
||
|
}
|
||
|
const character = text.charAt(startIndex);
|
||
|
if (backwards) {
|
||
|
if (text.charAt(startIndex - 1) === "\r" && character === "\n") {
|
||
|
return startIndex - 2;
|
||
|
}
|
||
|
if (character === "\n" || character === "\r" || character === "\u2028" || character === "\u2029") {
|
||
|
return startIndex - 1;
|
||
|
}
|
||
|
} else {
|
||
|
if (character === "\r" && text.charAt(startIndex + 1) === "\n") {
|
||
|
return startIndex + 2;
|
||
|
}
|
||
|
if (character === "\n" || character === "\r" || character === "\u2028" || character === "\u2029") {
|
||
|
return startIndex + 1;
|
||
|
}
|
||
|
}
|
||
|
return startIndex;
|
||
|
}
|
||
|
var skip_newline_default;
|
||
|
var init_skip_newline = __esm({
|
||
|
"src/utils/skip-newline.js"() {
|
||
|
skip_newline_default = skipNewline;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/skip-trailing-comment.js
|
||
|
function skipTrailingComment(text, startIndex) {
|
||
|
if (startIndex === false) {
|
||
|
return false;
|
||
|
}
|
||
|
if (text.charAt(startIndex) === "/" && text.charAt(startIndex + 1) === "/") {
|
||
|
return skipEverythingButNewLine(text, startIndex);
|
||
|
}
|
||
|
return startIndex;
|
||
|
}
|
||
|
var skip_trailing_comment_default;
|
||
|
var init_skip_trailing_comment = __esm({
|
||
|
"src/utils/skip-trailing-comment.js"() {
|
||
|
init_skip();
|
||
|
skip_trailing_comment_default = skipTrailingComment;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/get-next-non-space-non-comment-character-index.js
|
||
|
function getNextNonSpaceNonCommentCharacterIndex(text, startIndex) {
|
||
|
let oldIdx = null;
|
||
|
let nextIdx = startIndex;
|
||
|
while (nextIdx !== oldIdx) {
|
||
|
oldIdx = nextIdx;
|
||
|
nextIdx = skipSpaces(text, nextIdx);
|
||
|
nextIdx = skip_inline_comment_default(text, nextIdx);
|
||
|
nextIdx = skip_trailing_comment_default(text, nextIdx);
|
||
|
nextIdx = skip_newline_default(text, nextIdx);
|
||
|
}
|
||
|
return nextIdx;
|
||
|
}
|
||
|
var get_next_non_space_non_comment_character_index_default;
|
||
|
var init_get_next_non_space_non_comment_character_index = __esm({
|
||
|
"src/utils/get-next-non-space-non-comment-character-index.js"() {
|
||
|
init_skip();
|
||
|
init_skip_inline_comment();
|
||
|
init_skip_newline();
|
||
|
init_skip_trailing_comment();
|
||
|
get_next_non_space_non_comment_character_index_default = getNextNonSpaceNonCommentCharacterIndex;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/has-newline.js
|
||
|
function hasNewline(text, startIndex, options = {}) {
|
||
|
const idx = skipSpaces(
|
||
|
text,
|
||
|
options.backwards ? startIndex - 1 : startIndex,
|
||
|
options
|
||
|
);
|
||
|
const idx2 = skip_newline_default(text, idx, options);
|
||
|
return idx !== idx2;
|
||
|
}
|
||
|
var has_newline_default;
|
||
|
var init_has_newline = __esm({
|
||
|
"src/utils/has-newline.js"() {
|
||
|
init_skip();
|
||
|
init_skip_newline();
|
||
|
has_newline_default = hasNewline;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/is-next-line-empty.js
|
||
|
function isNextLineEmpty(text, startIndex) {
|
||
|
let oldIdx = null;
|
||
|
let idx = startIndex;
|
||
|
while (idx !== oldIdx) {
|
||
|
oldIdx = idx;
|
||
|
idx = skipToLineEnd(text, idx);
|
||
|
idx = skip_inline_comment_default(text, idx);
|
||
|
idx = skipSpaces(text, idx);
|
||
|
}
|
||
|
idx = skip_trailing_comment_default(text, idx);
|
||
|
idx = skip_newline_default(text, idx);
|
||
|
return idx !== false && has_newline_default(text, idx);
|
||
|
}
|
||
|
var is_next_line_empty_default;
|
||
|
var init_is_next_line_empty = __esm({
|
||
|
"src/utils/is-next-line-empty.js"() {
|
||
|
init_has_newline();
|
||
|
init_skip();
|
||
|
init_skip_inline_comment();
|
||
|
init_skip_newline();
|
||
|
init_skip_trailing_comment();
|
||
|
is_next_line_empty_default = isNextLineEmpty;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/is-previous-line-empty.js
|
||
|
function isPreviousLineEmpty(text, startIndex) {
|
||
|
let idx = startIndex - 1;
|
||
|
idx = skipSpaces(text, idx, { backwards: true });
|
||
|
idx = skip_newline_default(text, idx, { backwards: true });
|
||
|
idx = skipSpaces(text, idx, { backwards: true });
|
||
|
const idx2 = skip_newline_default(text, idx, { backwards: true });
|
||
|
return idx !== idx2;
|
||
|
}
|
||
|
var is_previous_line_empty_default;
|
||
|
var init_is_previous_line_empty = __esm({
|
||
|
"src/utils/is-previous-line-empty.js"() {
|
||
|
init_skip();
|
||
|
init_skip_newline();
|
||
|
is_previous_line_empty_default = isPreviousLineEmpty;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/main/comments/utils.js
|
||
|
function describeNodeForDebugging(node) {
|
||
|
const nodeType = node.type || node.kind || "(unknown type)";
|
||
|
let nodeName = String(
|
||
|
node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || ""
|
||
|
);
|
||
|
if (nodeName.length > 20) {
|
||
|
nodeName = nodeName.slice(0, 19) + "\u2026";
|
||
|
}
|
||
|
return nodeType + (nodeName ? " " + nodeName : "");
|
||
|
}
|
||
|
function addCommentHelper(node, comment) {
|
||
|
const comments = node.comments ?? (node.comments = []);
|
||
|
comments.push(comment);
|
||
|
comment.printed = false;
|
||
|
comment.nodeDescription = describeNodeForDebugging(node);
|
||
|
}
|
||
|
function addLeadingComment(node, comment) {
|
||
|
comment.leading = true;
|
||
|
comment.trailing = false;
|
||
|
addCommentHelper(node, comment);
|
||
|
}
|
||
|
function addDanglingComment(node, comment, marker) {
|
||
|
comment.leading = false;
|
||
|
comment.trailing = false;
|
||
|
if (marker) {
|
||
|
comment.marker = marker;
|
||
|
}
|
||
|
addCommentHelper(node, comment);
|
||
|
}
|
||
|
function addTrailingComment(node, comment) {
|
||
|
comment.leading = false;
|
||
|
comment.trailing = true;
|
||
|
addCommentHelper(node, comment);
|
||
|
}
|
||
|
var init_utils = __esm({
|
||
|
"src/main/comments/utils.js"() {
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/get-alignment-size.js
|
||
|
function getAlignmentSize(text, tabWidth, startIndex = 0) {
|
||
|
let size = 0;
|
||
|
for (let i = startIndex; i < text.length; ++i) {
|
||
|
if (text[i] === " ") {
|
||
|
size = size + tabWidth - size % tabWidth;
|
||
|
} else {
|
||
|
size++;
|
||
|
}
|
||
|
}
|
||
|
return size;
|
||
|
}
|
||
|
var get_alignment_size_default;
|
||
|
var init_get_alignment_size = __esm({
|
||
|
"src/utils/get-alignment-size.js"() {
|
||
|
get_alignment_size_default = getAlignmentSize;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/get-indent-size.js
|
||
|
function getIndentSize(value, tabWidth) {
|
||
|
const lastNewlineIndex = value.lastIndexOf("\n");
|
||
|
if (lastNewlineIndex === -1) {
|
||
|
return 0;
|
||
|
}
|
||
|
return get_alignment_size_default(
|
||
|
// All the leading whitespaces
|
||
|
value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0],
|
||
|
tabWidth
|
||
|
);
|
||
|
}
|
||
|
var get_indent_size_default;
|
||
|
var init_get_indent_size = __esm({
|
||
|
"src/utils/get-indent-size.js"() {
|
||
|
init_get_alignment_size();
|
||
|
get_indent_size_default = getIndentSize;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// node_modules/escape-string-regexp/index.js
|
||
|
function escapeStringRegexp(string) {
|
||
|
if (typeof string !== "string") {
|
||
|
throw new TypeError("Expected a string");
|
||
|
}
|
||
|
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
||
|
}
|
||
|
var init_escape_string_regexp = __esm({
|
||
|
"node_modules/escape-string-regexp/index.js"() {
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/get-max-continuous-count.js
|
||
|
function getMaxContinuousCount(text, searchString) {
|
||
|
const results = text.match(
|
||
|
new RegExp(`(${escapeStringRegexp(searchString)})+`, "g")
|
||
|
);
|
||
|
if (results === null) {
|
||
|
return 0;
|
||
|
}
|
||
|
return results.reduce(
|
||
|
(maxCount, result) => Math.max(maxCount, result.length / searchString.length),
|
||
|
0
|
||
|
);
|
||
|
}
|
||
|
var get_max_continuous_count_default;
|
||
|
var init_get_max_continuous_count = __esm({
|
||
|
"src/utils/get-max-continuous-count.js"() {
|
||
|
init_escape_string_regexp();
|
||
|
get_max_continuous_count_default = getMaxContinuousCount;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/get-next-non-space-non-comment-character.js
|
||
|
function getNextNonSpaceNonCommentCharacter(text, startIndex) {
|
||
|
const index = get_next_non_space_non_comment_character_index_default(text, startIndex);
|
||
|
return index === false ? "" : text.charAt(index);
|
||
|
}
|
||
|
var get_next_non_space_non_comment_character_default;
|
||
|
var init_get_next_non_space_non_comment_character = __esm({
|
||
|
"src/utils/get-next-non-space-non-comment-character.js"() {
|
||
|
init_get_next_non_space_non_comment_character_index();
|
||
|
get_next_non_space_non_comment_character_default = getNextNonSpaceNonCommentCharacter;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// node_modules/emoji-regex/index.mjs
|
||
|
var emoji_regex_default;
|
||
|
var init_emoji_regex = __esm({
|
||
|
"node_modules/emoji-regex/index.mjs"() {
|
||
|
emoji_regex_default = () => {
|
||
|
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\u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DEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFF
|
||
|
};
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// node_modules/get-east-asian-width/lookup.js
|
||
|
function isFullWidth(x) {
|
||
|
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
||
|
}
|
||
|
function isWide(x) {
|
||
|
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
||
|
}
|
||
|
var init_lookup = __esm({
|
||
|
"node_modules/get-east-asian-width/lookup.js"() {
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// node_modules/get-east-asian-width/index.js
|
||
|
var _isNarrowWidth;
|
||
|
var init_get_east_asian_width = __esm({
|
||
|
"node_modules/get-east-asian-width/index.js"() {
|
||
|
init_lookup();
|
||
|
_isNarrowWidth = (codePoint) => !(isFullWidth(codePoint) || isWide(codePoint));
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/get-string-width.js
|
||
|
function getStringWidth(text) {
|
||
|
if (!text) {
|
||
|
return 0;
|
||
|
}
|
||
|
if (!notAsciiRegex.test(text)) {
|
||
|
return text.length;
|
||
|
}
|
||
|
text = text.replace(emoji_regex_default(), " ");
|
||
|
let width = 0;
|
||
|
for (const character of text) {
|
||
|
const codePoint = character.codePointAt(0);
|
||
|
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
||
|
continue;
|
||
|
}
|
||
|
if (codePoint >= 768 && codePoint <= 879) {
|
||
|
continue;
|
||
|
}
|
||
|
width += _isNarrowWidth(codePoint) ? 1 : 2;
|
||
|
}
|
||
|
return width;
|
||
|
}
|
||
|
var notAsciiRegex, get_string_width_default;
|
||
|
var init_get_string_width = __esm({
|
||
|
"src/utils/get-string-width.js"() {
|
||
|
init_emoji_regex();
|
||
|
init_get_east_asian_width();
|
||
|
notAsciiRegex = /[^\x20-\x7F]/;
|
||
|
get_string_width_default = getStringWidth;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/has-newline-in-range.js
|
||
|
function hasNewlineInRange(text, startIndex, endIndex) {
|
||
|
for (let i = startIndex; i < endIndex; ++i) {
|
||
|
if (text.charAt(i) === "\n") {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
var has_newline_in_range_default;
|
||
|
var init_has_newline_in_range = __esm({
|
||
|
"src/utils/has-newline-in-range.js"() {
|
||
|
has_newline_in_range_default = hasNewlineInRange;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/has-spaces.js
|
||
|
function hasSpaces(text, startIndex, options = {}) {
|
||
|
const idx = skipSpaces(
|
||
|
text,
|
||
|
options.backwards ? startIndex - 1 : startIndex,
|
||
|
options
|
||
|
);
|
||
|
return idx !== startIndex;
|
||
|
}
|
||
|
var has_spaces_default;
|
||
|
var init_has_spaces = __esm({
|
||
|
"src/utils/has-spaces.js"() {
|
||
|
init_skip();
|
||
|
has_spaces_default = hasSpaces;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// scripts/build/shims/string-replace-all.js
|
||
|
var stringReplaceAll, string_replace_all_default;
|
||
|
var init_string_replace_all = __esm({
|
||
|
"scripts/build/shims/string-replace-all.js"() {
|
||
|
stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
|
||
|
if (isOptionalObject && (original === void 0 || original === null)) {
|
||
|
return;
|
||
|
}
|
||
|
if (original.replaceAll) {
|
||
|
return original.replaceAll(pattern, replacement);
|
||
|
}
|
||
|
if (pattern.global) {
|
||
|
return original.replace(pattern, replacement);
|
||
|
}
|
||
|
return original.split(pattern).join(replacement);
|
||
|
};
|
||
|
string_replace_all_default = stringReplaceAll;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/make-string.js
|
||
|
function makeString(rawText, enclosingQuote, unescapeUnnecessaryEscapes) {
|
||
|
const otherQuote = enclosingQuote === '"' ? "'" : '"';
|
||
|
const regex = /\\(.)|(["'])/gs;
|
||
|
const raw = string_replace_all_default(
|
||
|
/* isOptionalObject */
|
||
|
false,
|
||
|
rawText,
|
||
|
regex,
|
||
|
(match, escaped, quote) => {
|
||
|
if (escaped === otherQuote) {
|
||
|
return escaped;
|
||
|
}
|
||
|
if (quote === enclosingQuote) {
|
||
|
return "\\" + quote;
|
||
|
}
|
||
|
if (quote) {
|
||
|
return quote;
|
||
|
}
|
||
|
return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
|
||
|
}
|
||
|
);
|
||
|
return enclosingQuote + raw + enclosingQuote;
|
||
|
}
|
||
|
var make_string_default;
|
||
|
var init_make_string = __esm({
|
||
|
"src/utils/make-string.js"() {
|
||
|
init_string_replace_all();
|
||
|
make_string_default = makeString;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/utils/public.js
|
||
|
var public_exports = {};
|
||
|
__export(public_exports, {
|
||
|
addDanglingComment: () => addDanglingComment,
|
||
|
addLeadingComment: () => addLeadingComment,
|
||
|
addTrailingComment: () => addTrailingComment,
|
||
|
getAlignmentSize: () => get_alignment_size_default,
|
||
|
getIndentSize: () => get_indent_size_default,
|
||
|
getMaxContinuousCount: () => get_max_continuous_count_default,
|
||
|
getNextNonSpaceNonCommentCharacter: () => get_next_non_space_non_comment_character_default,
|
||
|
getNextNonSpaceNonCommentCharacterIndex: () => getNextNonSpaceNonCommentCharacterIndex2,
|
||
|
getStringWidth: () => get_string_width_default,
|
||
|
hasNewline: () => has_newline_default,
|
||
|
hasNewlineInRange: () => has_newline_in_range_default,
|
||
|
hasSpaces: () => has_spaces_default,
|
||
|
isNextLineEmpty: () => isNextLineEmpty2,
|
||
|
isNextLineEmptyAfterIndex: () => is_next_line_empty_default,
|
||
|
isPreviousLineEmpty: () => isPreviousLineEmpty2,
|
||
|
makeString: () => make_string_default,
|
||
|
skip: () => skip,
|
||
|
skipEverythingButNewLine: () => skipEverythingButNewLine,
|
||
|
skipInlineComment: () => skip_inline_comment_default,
|
||
|
skipNewline: () => skip_newline_default,
|
||
|
skipSpaces: () => skipSpaces,
|
||
|
skipToLineEnd: () => skipToLineEnd,
|
||
|
skipTrailingComment: () => skip_trailing_comment_default,
|
||
|
skipWhitespace: () => skipWhitespace
|
||
|
});
|
||
|
function legacyGetNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
|
||
|
return get_next_non_space_non_comment_character_index_default(
|
||
|
text,
|
||
|
locEnd(node)
|
||
|
);
|
||
|
}
|
||
|
function getNextNonSpaceNonCommentCharacterIndex2(text, startIndex) {
|
||
|
return arguments.length === 2 || typeof startIndex === "number" ? get_next_non_space_non_comment_character_index_default(text, startIndex) : (
|
||
|
// @ts-expect-error -- expected
|
||
|
// eslint-disable-next-line prefer-rest-params
|
||
|
legacyGetNextNonSpaceNonCommentCharacterIndex(...arguments)
|
||
|
);
|
||
|
}
|
||
|
function legacyIsPreviousLineEmpty(text, node, locStart) {
|
||
|
return is_previous_line_empty_default(text, locStart(node));
|
||
|
}
|
||
|
function isPreviousLineEmpty2(text, startIndex) {
|
||
|
return arguments.length === 2 || typeof startIndex === "number" ? is_previous_line_empty_default(text, startIndex) : (
|
||
|
// @ts-expect-error -- expected
|
||
|
// eslint-disable-next-line prefer-rest-params
|
||
|
legacyIsPreviousLineEmpty(...arguments)
|
||
|
);
|
||
|
}
|
||
|
function legacyIsNextLineEmpty(text, node, locEnd) {
|
||
|
return is_next_line_empty_default(text, locEnd(node));
|
||
|
}
|
||
|
function isNextLineEmpty2(text, startIndex) {
|
||
|
return arguments.length === 2 || typeof startIndex === "number" ? is_next_line_empty_default(text, startIndex) : (
|
||
|
// @ts-expect-error -- expected
|
||
|
// eslint-disable-next-line prefer-rest-params
|
||
|
legacyIsNextLineEmpty(...arguments)
|
||
|
);
|
||
|
}
|
||
|
var init_public = __esm({
|
||
|
"src/utils/public.js"() {
|
||
|
init_get_next_non_space_non_comment_character_index();
|
||
|
init_is_next_line_empty();
|
||
|
init_is_previous_line_empty();
|
||
|
init_utils();
|
||
|
init_get_alignment_size();
|
||
|
init_get_indent_size();
|
||
|
init_get_max_continuous_count();
|
||
|
init_get_next_non_space_non_comment_character();
|
||
|
init_get_string_width();
|
||
|
init_has_newline();
|
||
|
init_has_newline_in_range();
|
||
|
init_has_spaces();
|
||
|
init_make_string();
|
||
|
init_skip();
|
||
|
init_skip_inline_comment();
|
||
|
init_skip_newline();
|
||
|
init_skip_trailing_comment();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/main/version.evaluate.cjs
|
||
|
var require_version_evaluate = __commonJS({
|
||
|
"src/main/version.evaluate.cjs"(exports2, module2) {
|
||
|
module2.exports = "3.3.2";
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// src/index.cjs
|
||
|
var prettierPromise = import("./index.mjs");
|
||
|
var functionNames = [
|
||
|
"formatWithCursor",
|
||
|
"format",
|
||
|
"check",
|
||
|
"resolveConfig",
|
||
|
"resolveConfigFile",
|
||
|
"clearConfigCache",
|
||
|
"getFileInfo",
|
||
|
"getSupportInfo"
|
||
|
];
|
||
|
var prettier = /* @__PURE__ */ Object.create(null);
|
||
|
for (const name of functionNames) {
|
||
|
prettier[name] = async (...args) => {
|
||
|
const prettier2 = await prettierPromise;
|
||
|
return prettier2[name](...args);
|
||
|
};
|
||
|
}
|
||
|
var debugApiFunctionNames = [
|
||
|
"parse",
|
||
|
"formatAST",
|
||
|
"formatDoc",
|
||
|
"printToDoc",
|
||
|
"printDocToString"
|
||
|
];
|
||
|
var debugApis = /* @__PURE__ */ Object.create(null);
|
||
|
for (const name of debugApiFunctionNames) {
|
||
|
debugApis[name] = async (...args) => {
|
||
|
const prettier2 = await prettierPromise;
|
||
|
return prettier2.__debug[name](...args);
|
||
|
};
|
||
|
}
|
||
|
prettier.__debug = debugApis;
|
||
|
if (true) {
|
||
|
prettier.util = (init_public(), __toCommonJS(public_exports));
|
||
|
prettier.doc = require("./doc.js");
|
||
|
} else {
|
||
|
Object.defineProperties(prettier, {
|
||
|
util: {
|
||
|
get() {
|
||
|
throw new Error(
|
||
|
"prettier.util is not available in development CommonJS version"
|
||
|
);
|
||
|
}
|
||
|
},
|
||
|
doc: {
|
||
|
get() {
|
||
|
throw new Error(
|
||
|
"prettier.doc is not available in development CommonJS version"
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
prettier.version = require_version_evaluate();
|
||
|
module.exports = prettier;
|