Update babel to v8.0.0-rc.1 (#18822)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: fisker Cheung <lionkay@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
21 files changed
+301
-177
No files matched your search
@@ -107,5 +107,5 @@ jobs:
|
|||||||
- name: Knip
|
- name: Knip
|
||||||
run: yarn lint:knip
|
run: yarn lint:knip
|
||||||
|
|
||||||
- name: Check File Changes
|
- name: Ensure not files changed
|
||||||
run: echo "Listing changed files:" && git diff --name-only --exit-code && echo "No files changed during lint."
|
run: node ./scripts/ensure-no-files-changed.js
|
||||||
@@ -127,21 +127,11 @@ jobs:
|
|||||||
path: dist
|
path: dist
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
if: matrix.node != '14'
|
|
||||||
run: yarn test:production
|
run: yarn test:production
|
||||||
|
|
||||||
- name: Run Tests (Node.js 14)
|
|
||||||
if: matrix.node == '14'
|
|
||||||
run: yarn test:production-node14
|
|
||||||
|
|
||||||
- name: Run Format Tests (standalone)
|
- name: Run Format Tests (standalone)
|
||||||
if: matrix.node != '14'
|
|
||||||
run: yarn test:production-standalone
|
run: yarn test:production-standalone
|
||||||
|
|
||||||
- name: Run Format Tests (standalone, Node.js 14)
|
|
||||||
if: matrix.node == '14'
|
|
||||||
run: yarn test:production-standalone-node14
|
|
||||||
|
|
||||||
- name: "`--debug-benchmark` flag"
|
- name: "`--debug-benchmark` flag"
|
||||||
if: ${{ matrix.node != '14' && matrix.os != 'windows-latest' }}
|
if: ${{ matrix.node != '14' && matrix.os != 'windows-latest' }}
|
||||||
working-directory: dist/prettier
|
working-directory: dist/prettier
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
**/.yarn/*
|
**/.yarn/**/*.*
|
||||||
|
!/.yarn/plugins/plugin-prepare.cjs
|
||||||
|
vendors/**
|
||||||
|
|
||||||
# Ignore directories and files in 'tests/format'
|
# Ignore directories and files in 'tests/format'
|
||||||
/tests/format/**/*.*
|
/tests/format/**/*.*
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"[javascript][typescript][javascriptreact][typescriptreact][json][jsonc][json5][markdown][yaml][css][html][vue]": {
|
"[javascript][typescript][javascriptreact][typescriptreact][json][jsonc][json5][markdown][yaml][css][html][vue][github-actions-workflow]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
},
|
},
|
||||||
|
|||||||
Vendored
+36
@@ -0,0 +1,36 @@
|
|||||||
|
const fs = require("node:fs");
|
||||||
|
const path = require("node:path");
|
||||||
|
|
||||||
|
function setupVscode() {
|
||||||
|
const settingsFile = path.join(__dirname, "../../.vscode/settings.json");
|
||||||
|
|
||||||
|
const settingsExampleFile = path.join(
|
||||||
|
__dirname,
|
||||||
|
"../../.vscode/settings.example.json",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fs.existsSync(settingsFile) || !fs.existsSync(settingsExampleFile)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.copyFileSync(settingsExampleFile, settingsFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function buildBabelCodeFrameForTest() {
|
||||||
|
const { buildBabelCodeFrameForTest } =
|
||||||
|
await import("../../scripts/build-babel-code-frame-for-test.js");
|
||||||
|
|
||||||
|
await buildBabelCodeFrameForTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "plugin-prepare",
|
||||||
|
factory: () => ({
|
||||||
|
hooks: {
|
||||||
|
async afterAllInstalled() {
|
||||||
|
setupVscode();
|
||||||
|
await buildBabelCodeFrameForTest();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
const fs = require("node:fs");
|
|
||||||
const path = require("node:path");
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: "plugin-setup-editor",
|
|
||||||
factory: () => ({
|
|
||||||
hooks: {
|
|
||||||
afterAllInstalled() {
|
|
||||||
const settingsFile = path.join(
|
|
||||||
__dirname,
|
|
||||||
"../../.vscode/settings.json",
|
|
||||||
);
|
|
||||||
|
|
||||||
const settingsExampleFile = path.join(
|
|
||||||
__dirname,
|
|
||||||
"../../.vscode/settings.example.json",
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
fs.existsSync(settingsFile) ||
|
|
||||||
!fs.existsSync(settingsExampleFile)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.copyFileSync(settingsExampleFile, settingsFile);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
+1
-1
@@ -7,6 +7,6 @@ enableGlobalCache: true
|
|||||||
nodeLinker: node-modules
|
nodeLinker: node-modules
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- .yarn/plugins/plugin-setup-editor.cjs
|
- .yarn/plugins/plugin-prepare.cjs
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-4.12.0.cjs
|
yarnPath: .yarn/releases/yarn-4.12.0.cjs
|
||||||
@@ -35,6 +35,7 @@ website/.docusaurus
|
|||||||
scripts/benchmark/*/
|
scripts/benchmark/*/
|
||||||
**/.yarn/**
|
**/.yarn/**
|
||||||
**/.pnp.*
|
**/.pnp.*
|
||||||
|
vendors/**
|
||||||
`
|
`
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.filter((pattern) => pattern && !pattern.startsWith("#"));
|
.filter((pattern) => pattern && !pattern.startsWith("#"));
|
||||||
|
|||||||
+4
-7
@@ -43,9 +43,9 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/compiler": "21.1.1",
|
"@angular/compiler": "21.1.1",
|
||||||
"@babel/code-frame": "8.0.0-beta.4",
|
"@babel/code-frame": "8.0.0-rc.1",
|
||||||
"@babel/parser": "8.0.0-beta.4",
|
"@babel/parser": "8.0.0-rc.1",
|
||||||
"@babel/types": "8.0.0-beta.4",
|
"@babel/types": "8.0.0-rc.1",
|
||||||
"@glimmer/syntax": "0.95.0",
|
"@glimmer/syntax": "0.95.0",
|
||||||
"@prettier/cli": "0.10.0",
|
"@prettier/cli": "0.10.0",
|
||||||
"@prettier/html-event-attributes": "0.0.1",
|
"@prettier/html-event-attributes": "0.0.1",
|
||||||
@@ -135,7 +135,7 @@
|
|||||||
"yaml-unist-parser": "2.2.1"
|
"yaml-unist-parser": "2.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/generator": "8.0.0-beta.4",
|
"@babel/generator": "8.0.0-rc.1",
|
||||||
"@eslint/js": "9.39.2",
|
"@eslint/js": "9.39.2",
|
||||||
"@stylistic/eslint-plugin": "5.7.0",
|
"@stylistic/eslint-plugin": "5.7.0",
|
||||||
"@types/jsesc": "3.0.3",
|
"@types/jsesc": "3.0.3",
|
||||||
@@ -197,12 +197,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:node14": "cross-env NODE_OPTIONS=\"--experimental-loader=$PWD/scripts/nodejs-14-test-loader.js --no-warnings=ExperimentalWarning\" jest --runInBand",
|
|
||||||
"test:dev-package": "cross-env INSTALL_PACKAGE=1 yarn test",
|
"test:dev-package": "cross-env INSTALL_PACKAGE=1 yarn test",
|
||||||
"test:production": "cross-env NODE_ENV=production yarn test",
|
"test:production": "cross-env NODE_ENV=production yarn test",
|
||||||
"test:production-node14": "cross-env NODE_ENV=production yarn test:node14",
|
|
||||||
"test:production-standalone": "cross-env TEST_STANDALONE=1 yarn test:production",
|
"test:production-standalone": "cross-env TEST_STANDALONE=1 yarn test:production",
|
||||||
"test:production-standalone-node14": "cross-env TEST_STANDALONE=1 yarn test:production-node14",
|
|
||||||
"test:production:browser": "cross-env TEST_RUNTIME=browser yarn test:production",
|
"test:production:browser": "cross-env TEST_RUNTIME=browser yarn test:production",
|
||||||
"test:production:browser:chrome": "cross-env TEST_RUNTIME_BROWSER=chrome yarn test:production:browser",
|
"test:production:browser:chrome": "cross-env TEST_RUNTIME_BROWSER=chrome yarn test:production:browser",
|
||||||
"test:production:browser:firefox": "cross-env TEST_RUNTIME_BROWSER=firefox yarn test:production:browser",
|
"test:production:browser:firefox": "cross-env TEST_RUNTIME_BROWSER=firefox yarn test:production:browser",
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import url from "node:url";
|
||||||
|
import esbuild from "esbuild";
|
||||||
|
import {
|
||||||
|
PRODUCTION_MINIMAL_NODE_JS_VERSION,
|
||||||
|
PROJECT_ROOT,
|
||||||
|
} from "./utilities/index.js";
|
||||||
|
|
||||||
|
const file = url.fileURLToPath(
|
||||||
|
new URL("../vendors/babel-code-frame-for-test.js", import.meta.url),
|
||||||
|
);
|
||||||
|
|
||||||
|
async function buildBabelCodeFrameForTest() {
|
||||||
|
await esbuild.build({
|
||||||
|
entryPoints: ["@babel/code-frame"],
|
||||||
|
bundle: true,
|
||||||
|
target: [`node${PRODUCTION_MINIMAL_NODE_JS_VERSION}`],
|
||||||
|
format: "esm",
|
||||||
|
outfile: file,
|
||||||
|
mainFields: ["browser"],
|
||||||
|
absWorkingDir: PROJECT_ROOT,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export { buildBabelCodeFrameForTest };
|
||||||
@@ -4,7 +4,10 @@ import browserslistToEsbuild from "browserslist-to-esbuild";
|
|||||||
import esbuild from "esbuild";
|
import esbuild from "esbuild";
|
||||||
import createEsmUtils from "esm-utils";
|
import createEsmUtils from "esm-utils";
|
||||||
import projectPackageJson from "../../../package.json" with { type: "json" };
|
import projectPackageJson from "../../../package.json" with { type: "json" };
|
||||||
import { PRODUCTION_MINIMAL_NODE_JS_VERSION } from "../../utilities/index.js";
|
import {
|
||||||
|
PRODUCTION_MINIMAL_NODE_JS_VERSION,
|
||||||
|
PROJECT_ROOT,
|
||||||
|
} from "../../utilities/index.js";
|
||||||
import esbuildPluginAddDefaultExport from "../esbuild-plugins/add-default-export.js";
|
import esbuildPluginAddDefaultExport from "../esbuild-plugins/add-default-export.js";
|
||||||
import esbuildPluginEvaluate from "../esbuild-plugins/evaluate.js";
|
import esbuildPluginEvaluate from "../esbuild-plugins/evaluate.js";
|
||||||
import esbuildPluginPrimitiveDefine from "../esbuild-plugins/primitive-define.js";
|
import esbuildPluginPrimitiveDefine from "../esbuild-plugins/primitive-define.js";
|
||||||
@@ -223,6 +226,7 @@ function getEsbuildOptions({ packageConfig, file, cliOptions, buildOptions }) {
|
|||||||
"class-private-method": true,
|
"class-private-method": true,
|
||||||
},
|
},
|
||||||
packages: "bundle",
|
packages: "bundle",
|
||||||
|
absWorkingDir: PROJECT_ROOT,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (buildOptions.platform === "universal") {
|
if (buildOptions.platform === "universal") {
|
||||||
|
|||||||
@@ -75,6 +75,16 @@ const mainModule = {
|
|||||||
find: "export default lib;",
|
find: "export default lib;",
|
||||||
replacement: "export default { parse };",
|
replacement: "export default { parse };",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
module: require.resolve("@babel/code-frame"),
|
||||||
|
process(text) {
|
||||||
|
text = text.replace(
|
||||||
|
"from 'node:util'",
|
||||||
|
`from ${JSON.stringify(path.join(dirname, "../shims/node-util.js"))}`,
|
||||||
|
);
|
||||||
|
return text;
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
addDefaultExport: true,
|
addDefaultExport: true,
|
||||||
reuseDocModule: true,
|
reuseDocModule: true,
|
||||||
@@ -85,45 +95,6 @@ const mainModule = {
|
|||||||
input: "src/standalone.js",
|
input: "src/standalone.js",
|
||||||
umdVariableName: "prettier",
|
umdVariableName: "prettier",
|
||||||
replaceModule: [
|
replaceModule: [
|
||||||
{
|
|
||||||
module: require.resolve("@babel/code-frame"),
|
|
||||||
process(text) {
|
|
||||||
text = text.replaceAll(
|
|
||||||
/(?<=\n)let tokenize;\n\{\n.*?\n\}(?=\n)/gs,
|
|
||||||
"",
|
|
||||||
);
|
|
||||||
|
|
||||||
text = text.replaceAll(
|
|
||||||
/(?<=\n)function highlight\(text\) \{\n.*?\n\}(?=\n)/gs,
|
|
||||||
"function highlight(text) {return text}",
|
|
||||||
);
|
|
||||||
|
|
||||||
text = text.replaceAll(
|
|
||||||
/(?<=\n)function getDefs\(enabled\) \{\n.*?\n\}(?=\n)/gs,
|
|
||||||
outdent`
|
|
||||||
function getDefs() {
|
|
||||||
return new Proxy({}, {get: () => (text) => text})
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
);
|
|
||||||
|
|
||||||
text = text.replaceAll(
|
|
||||||
"const defsOn = buildDefs(picocolors.createColors(true));",
|
|
||||||
"",
|
|
||||||
);
|
|
||||||
text = text.replaceAll(
|
|
||||||
"const defsOff = buildDefs(picocolors.createColors(false));",
|
|
||||||
"",
|
|
||||||
);
|
|
||||||
|
|
||||||
text = text.replaceAll(
|
|
||||||
"const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;",
|
|
||||||
"const shouldHighlight = false;",
|
|
||||||
);
|
|
||||||
|
|
||||||
return text;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Smaller size
|
// Smaller size
|
||||||
{
|
{
|
||||||
module: getPackageFile("picocolors/picocolors.browser.js"),
|
module: getPackageFile("picocolors/picocolors.browser.js"),
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import * as util from "node:util";
|
||||||
|
|
||||||
|
export const styleText =
|
||||||
|
util.styleText ?? ((format, text /* , options*/) => text);
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import spawn from "nano-spawn";
|
||||||
|
|
||||||
|
async function getChangedFiles() {
|
||||||
|
const { stdout } = await spawn("git", ["diff", "--name-only"]);
|
||||||
|
return stdout.split("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ensureNoFilesChanged() {
|
||||||
|
const changedFiles = await getChangedFiles();
|
||||||
|
|
||||||
|
if (changedFiles.length === 0) {
|
||||||
|
console.log("✅ No files changed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`❌ ${changedFiles.length} file${changedFiles.length === 1 ? "" : "s"} changed:`,
|
||||||
|
);
|
||||||
|
console.log(changedFiles.map((file) => ` - ${file}`).join("\n"));
|
||||||
|
console.log();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await spawn("git", ["diff", "--exit-code"], { stdio: "inherit" });
|
||||||
|
} catch (error) {
|
||||||
|
process.exitCode = error.exitCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await ensureNoFilesChanged();
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import { readFile } from "node:fs/promises";
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
import esbuild from "esbuild";
|
|
||||||
|
|
||||||
// `@babel/code-frame` and `@babel/highlight` use syntax that is not available in Node.js 14,
|
|
||||||
// such as `??=`. When bundled into dist/ they are compiled to be compatible with Node.js 14,
|
|
||||||
// however we also need to load them at runtime from node_modules to run our tests.
|
|
||||||
// We can use an `--experimental-loader` to compile them on-the-fly with esbuild.
|
|
||||||
|
|
||||||
export async function getSource(url, context, defaultGetSource) {
|
|
||||||
if (context.format === "module") {
|
|
||||||
if (url.includes("/node_modules/js-tokens/")) {
|
|
||||||
const text = await readFile(fileURLToPath(url), "utf8");
|
|
||||||
const commonJsExport = 'export { jsTokens as "module.exports" };';
|
|
||||||
if (text.includes(commonJsExport)) {
|
|
||||||
return { source: text.replace(commonJsExport, "") };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
url.includes("/node_modules/@babel/code-frame/") ||
|
|
||||||
url.includes("/node_modules/@babel/highlight/")
|
|
||||||
) {
|
|
||||||
const raw = await readFile(fileURLToPath(url));
|
|
||||||
try {
|
|
||||||
const result = await esbuild.transform(raw, { target: "node14" });
|
|
||||||
return { source: result.code };
|
|
||||||
} catch (error) {
|
|
||||||
error.message += ` (in ${url})`;
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultGetSource(url, context, defaultGetSource);
|
|
||||||
}
|
|
||||||
@@ -85,7 +85,7 @@ const jestDependencies = [
|
|||||||
"pretty-format",
|
"pretty-format",
|
||||||
];
|
];
|
||||||
|
|
||||||
let content = JSON.stringify(
|
const content = JSON.stringify(
|
||||||
{
|
{
|
||||||
...packageJson,
|
...packageJson,
|
||||||
resolutions: {
|
resolutions: {
|
||||||
@@ -99,8 +99,4 @@ let content = JSON.stringify(
|
|||||||
2,
|
2,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
|
||||||
content = content.replace("$PWD/", new URL("../", import.meta.url).href);
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(packageJsonFile, content);
|
fs.writeFileSync(packageJsonFile, content);
|
||||||
@@ -33,7 +33,6 @@ const excludeVisitorKeys = {
|
|||||||
DeclareOpaqueType: ["impltype"],
|
DeclareOpaqueType: ["impltype"],
|
||||||
|
|
||||||
// Legacy properties
|
// Legacy properties
|
||||||
ExportAllDeclaration: ["assertions"],
|
|
||||||
ImportDeclaration: ["assertions"],
|
ImportDeclaration: ["assertions"],
|
||||||
|
|
||||||
// Flow node from Babel
|
// Flow node from Babel
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { codeFrameColumns } from "@babel/code-frame";
|
|
||||||
import indexToPosition from "index-to-position";
|
import indexToPosition from "index-to-position";
|
||||||
|
import { codeFrameColumns } from "../../../vendors/babel-code-frame-for-test.js";
|
||||||
const codeFrameColumnsOptions = {
|
const codeFrameColumnsOptions = {
|
||||||
linesAbove: Number.POSITIVE_INFINITY,
|
linesAbove: Number.POSITIVE_INFINITY,
|
||||||
linesBelow: Number.POSITIVE_INFINITY,
|
linesBelow: Number.POSITIVE_INFINITY,
|
||||||
|
|||||||
@@ -722,13 +722,6 @@ exports[`visitor keys estree 1`] = `
|
|||||||
"ParenthesizedExpression": [
|
"ParenthesizedExpression": [
|
||||||
"expression",
|
"expression",
|
||||||
],
|
],
|
||||||
"PipelineBareFunction": [
|
|
||||||
"callee",
|
|
||||||
],
|
|
||||||
"PipelinePrimaryTopicReference": [],
|
|
||||||
"PipelineTopicExpression": [
|
|
||||||
"expression",
|
|
||||||
],
|
|
||||||
"Placeholder": [],
|
"Placeholder": [],
|
||||||
"PrivateIdentifier": [],
|
"PrivateIdentifier": [],
|
||||||
"PrivateName": [
|
"PrivateName": [
|
||||||
|
|||||||
Vendored
+143
@@ -0,0 +1,143 @@
|
|||||||
|
// node_modules/@babel/code-frame/lib/common-BO7XIBW3.js
|
||||||
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
||||||
|
function getMarkerLines(loc, source, opts, startLineBaseZero) {
|
||||||
|
const startLoc = {
|
||||||
|
column: 0,
|
||||||
|
line: -1,
|
||||||
|
...loc.start
|
||||||
|
};
|
||||||
|
const endLoc = {
|
||||||
|
...startLoc,
|
||||||
|
...loc.end
|
||||||
|
};
|
||||||
|
const {
|
||||||
|
linesAbove = 2,
|
||||||
|
linesBelow = 3
|
||||||
|
} = opts || {};
|
||||||
|
const startLine = startLoc.line - startLineBaseZero;
|
||||||
|
const startColumn = startLoc.column;
|
||||||
|
const endLine = endLoc.line - startLineBaseZero;
|
||||||
|
const endColumn = endLoc.column;
|
||||||
|
let start = Math.max(startLine - (linesAbove + 1), 0);
|
||||||
|
let end = Math.min(source.length, endLine + linesBelow);
|
||||||
|
if (startLine === -1) {
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
|
if (endLine === -1) {
|
||||||
|
end = source.length;
|
||||||
|
}
|
||||||
|
const lineDiff = endLine - startLine;
|
||||||
|
const markerLines = {};
|
||||||
|
if (lineDiff) {
|
||||||
|
for (let i = 0; i <= lineDiff; i++) {
|
||||||
|
const lineNumber = i + startLine;
|
||||||
|
if (!startColumn) {
|
||||||
|
markerLines[lineNumber] = true;
|
||||||
|
} else if (i === 0) {
|
||||||
|
const sourceLength = source[lineNumber - 1].length;
|
||||||
|
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
|
||||||
|
} else if (i === lineDiff) {
|
||||||
|
markerLines[lineNumber] = [0, endColumn];
|
||||||
|
} else {
|
||||||
|
const sourceLength = source[lineNumber - i].length;
|
||||||
|
markerLines[lineNumber] = [0, sourceLength];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (startColumn === endColumn) {
|
||||||
|
if (startColumn) {
|
||||||
|
markerLines[startLine] = [startColumn, 0];
|
||||||
|
} else {
|
||||||
|
markerLines[startLine] = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
markerLines[startLine] = [startColumn, endColumn - startColumn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
markerLines
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function _codeFrameColumns(rawLines, loc, opts = {}, colorOpts) {
|
||||||
|
const {
|
||||||
|
defs,
|
||||||
|
highlight: highlight2
|
||||||
|
} = colorOpts || {
|
||||||
|
defs: {
|
||||||
|
gutter: String,
|
||||||
|
marker: String,
|
||||||
|
message: String,
|
||||||
|
reset: String
|
||||||
|
},
|
||||||
|
highlight: String
|
||||||
|
};
|
||||||
|
const startLineBaseZero = (opts.startLine || 1) - 1;
|
||||||
|
const lines = rawLines.split(NEWLINE);
|
||||||
|
const {
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
markerLines
|
||||||
|
} = getMarkerLines(loc, lines, opts, startLineBaseZero);
|
||||||
|
const hasColumns = loc.start && typeof loc.start.column === "number";
|
||||||
|
const numberMaxWidth = String(end + startLineBaseZero).length;
|
||||||
|
const highlightedLines = highlight2(rawLines);
|
||||||
|
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
|
||||||
|
const number = start + 1 + index;
|
||||||
|
const paddedNumber = ` ${number + startLineBaseZero}`.slice(-numberMaxWidth);
|
||||||
|
const gutter = ` ${paddedNumber} |`;
|
||||||
|
const hasMarker = markerLines[number];
|
||||||
|
const lastMarkerLine = !markerLines[number + 1];
|
||||||
|
if (hasMarker) {
|
||||||
|
let markerLine = "";
|
||||||
|
if (Array.isArray(hasMarker)) {
|
||||||
|
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
||||||
|
const numberOfMarkers = hasMarker[1] || 1;
|
||||||
|
markerLine = ["\n ", defs.gutter(gutter.replace(/\d/g, " ")), " ", markerSpacing, defs.marker("^").repeat(numberOfMarkers)].join("");
|
||||||
|
if (lastMarkerLine && opts.message) {
|
||||||
|
markerLine += " " + defs.message(opts.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [defs.marker(">"), defs.gutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
|
||||||
|
} else {
|
||||||
|
return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
|
||||||
|
}
|
||||||
|
}).join("\n");
|
||||||
|
if (opts.message && !hasColumns) {
|
||||||
|
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}
|
||||||
|
${frame}`;
|
||||||
|
}
|
||||||
|
return defs.reset(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
// node_modules/@babel/code-frame/lib/browser.js
|
||||||
|
var deprecationWarningShown = false;
|
||||||
|
function codeFrameColumns(rawLines, loc, opts = {}) {
|
||||||
|
return _codeFrameColumns(rawLines, loc, opts);
|
||||||
|
}
|
||||||
|
function browser(rawLines, lineNumber, colNumber, opts = {}) {
|
||||||
|
if (!deprecationWarningShown) {
|
||||||
|
deprecationWarningShown = true;
|
||||||
|
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
|
||||||
|
const deprecationError = new Error(message);
|
||||||
|
deprecationError.name = "DeprecationWarning";
|
||||||
|
console.warn(new Error(message));
|
||||||
|
}
|
||||||
|
colNumber = Math.max(colNumber, 0);
|
||||||
|
const location = {
|
||||||
|
start: {
|
||||||
|
column: colNumber,
|
||||||
|
line: lineNumber
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return codeFrameColumns(rawLines, location, opts);
|
||||||
|
}
|
||||||
|
function highlight(code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
export {
|
||||||
|
codeFrameColumns,
|
||||||
|
browser as default,
|
||||||
|
highlight
|
||||||
|
};
|
||||||
@@ -23,14 +23,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/code-frame@npm:8.0.0-beta.4":
|
"@babel/code-frame@npm:8.0.0-rc.1":
|
||||||
version: 8.0.0-beta.4
|
version: 8.0.0-rc.1
|
||||||
resolution: "@babel/code-frame@npm:8.0.0-beta.4"
|
resolution: "@babel/code-frame@npm:8.0.0-rc.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/helper-validator-identifier": "npm:^8.0.0-beta.4"
|
"@babel/helper-validator-identifier": "npm:^8.0.0-rc.1"
|
||||||
js-tokens: "npm:^10.0.0"
|
js-tokens: "npm:^10.0.0"
|
||||||
picocolors: "npm:^1.1.1"
|
checksum: 10/a1a43ab10cfd6d6f2b2f4aa7b83a6c8765bd79733dff4885ece77068444e54a8c67f40a576eeac1ba0c389b47bf1497b48ab93594bd59686043177651f85308f
|
||||||
checksum: 10/11bfcf81136ee40a4ed74e9ed363c798415196b0ca5b1636364819f0fcb2425ef729732536f0145a75d8db3297f2ea7913a17e331ba29cc3d3775967bc9fb4e4
|
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -75,17 +74,17 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/generator@npm:8.0.0-beta.4":
|
"@babel/generator@npm:8.0.0-rc.1":
|
||||||
version: 8.0.0-beta.4
|
version: 8.0.0-rc.1
|
||||||
resolution: "@babel/generator@npm:8.0.0-beta.4"
|
resolution: "@babel/generator@npm:8.0.0-rc.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/parser": "npm:^8.0.0-beta.4"
|
"@babel/parser": "npm:^8.0.0-rc.1"
|
||||||
"@babel/types": "npm:^8.0.0-beta.4"
|
"@babel/types": "npm:^8.0.0-rc.1"
|
||||||
"@jridgewell/gen-mapping": "npm:^0.3.12"
|
"@jridgewell/gen-mapping": "npm:^0.3.12"
|
||||||
"@jridgewell/trace-mapping": "npm:^0.3.28"
|
"@jridgewell/trace-mapping": "npm:^0.3.28"
|
||||||
"@types/jsesc": "npm:^2.5.0"
|
"@types/jsesc": "npm:^2.5.0"
|
||||||
jsesc: "npm:^3.0.2"
|
jsesc: "npm:^3.0.2"
|
||||||
checksum: 10/79a2130a454f43f80c4d4289eaa3b83afd7ed27e62878c0b070108ee321a3602e3edbcff213a80b16c2b0a7913ef3150ccb14cef3cdccc155c296d0fbb96cac6
|
checksum: 10/1949ed7a0731e2825b263b8095be9fba0ed6fc1bb4dc1c6ea9fa554cb6d34aed3f9bf72ff1ce343bc31dbe604ebb0138b98f4b77c496ae31e6576ef6a9c0dd20
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -159,10 +158,10 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/helper-string-parser@npm:^8.0.0-beta.4":
|
"@babel/helper-string-parser@npm:^8.0.0-rc.1":
|
||||||
version: 8.0.0-beta.4
|
version: 8.0.0-rc.1
|
||||||
resolution: "@babel/helper-string-parser@npm:8.0.0-beta.4"
|
resolution: "@babel/helper-string-parser@npm:8.0.0-rc.1"
|
||||||
checksum: 10/39fe9a7a2fcb7418d40248e515e7e40bc63a9f4320d7dc5e748094fa96cc20646a4e48e8492d507bdefcb94c558fefeb4acdc29cd510a1fd87c7a33f3f77d0d7
|
checksum: 10/9c7b34ecce6a1a03a3a2fbd2f09f46bb47a961f432ee2c279e120855c40258b1715cd1bf2ed27618c03ee13d4310356381ad123ec37648d2756c5594bd128682
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -173,10 +172,10 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/helper-validator-identifier@npm:^8.0.0-beta.4":
|
"@babel/helper-validator-identifier@npm:^8.0.0-rc.1":
|
||||||
version: 8.0.0-beta.4
|
version: 8.0.0-rc.1
|
||||||
resolution: "@babel/helper-validator-identifier@npm:8.0.0-beta.4"
|
resolution: "@babel/helper-validator-identifier@npm:8.0.0-rc.1"
|
||||||
checksum: 10/f011422956084af1f4ce51a1453083b77b20abb48eb95aef33df52d3328460c95848aaa92e59b618a9f334f58fb50d27f3fd66235fbfdd77e0a382c2a9aa650c
|
checksum: 10/75d6d5201c64fec916b539210b77f41585b3fc31f197c17a874e1ace818014080dba5909eb24f84daad451810f2e9b7f09a2b3f23978b9c9c9875ed63d3f83fb
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -209,14 +208,14 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/parser@npm:8.0.0-beta.4, @babel/parser@npm:^8.0.0-beta.4":
|
"@babel/parser@npm:8.0.0-rc.1, @babel/parser@npm:^8.0.0-rc.1":
|
||||||
version: 8.0.0-beta.4
|
version: 8.0.0-rc.1
|
||||||
resolution: "@babel/parser@npm:8.0.0-beta.4"
|
resolution: "@babel/parser@npm:8.0.0-rc.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/types": "npm:^8.0.0-beta.4"
|
"@babel/types": "npm:^8.0.0-rc.1"
|
||||||
bin:
|
bin:
|
||||||
parser: ./bin/babel-parser.js
|
parser: ./bin/babel-parser.js
|
||||||
checksum: 10/41ea150c87ad2153efa245013fc6f6fa5be303403e2de0c4f2547f8529b92f242ae7a8a19f076a0bf63c494595fe40924421a6fbf4bc944378570d9df7849b82
|
checksum: 10/d0c5baf877a0ee9e0b0626f21f22d4911405abf66504b102c7544aff8a0925e33d8841934ceb834f3d989f7992fffcaff7be8d433b5779ed1924e1692c182016
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -451,13 +450,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/types@npm:8.0.0-beta.4, @babel/types@npm:^8.0.0-beta.4":
|
"@babel/types@npm:8.0.0-rc.1, @babel/types@npm:^8.0.0-rc.1":
|
||||||
version: 8.0.0-beta.4
|
version: 8.0.0-rc.1
|
||||||
resolution: "@babel/types@npm:8.0.0-beta.4"
|
resolution: "@babel/types@npm:8.0.0-rc.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/helper-string-parser": "npm:^8.0.0-beta.4"
|
"@babel/helper-string-parser": "npm:^8.0.0-rc.1"
|
||||||
"@babel/helper-validator-identifier": "npm:^8.0.0-beta.4"
|
"@babel/helper-validator-identifier": "npm:^8.0.0-rc.1"
|
||||||
checksum: 10/31222a70050c3845c44c1339a7bc75bc6bcea48da754f8e8d59e36605d3bac9ce29707078a6ef44ddb102f6493aea508e73e35ea849683d3844cb412f35f85ce
|
checksum: 10/34def05264164b579c8648a9b44449b567a79c4f34b285353d1e225c0d012a2931747547f05781a41ce99806f43920e2ca6319bd628be09b44ae9dce77576ec3
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -8358,10 +8357,10 @@ __metadata:
|
|||||||
resolution: "prettier@workspace:."
|
resolution: "prettier@workspace:."
|
||||||
dependencies:
|
dependencies:
|
||||||
"@angular/compiler": "npm:21.1.1"
|
"@angular/compiler": "npm:21.1.1"
|
||||||
"@babel/code-frame": "npm:8.0.0-beta.4"
|
"@babel/code-frame": "npm:8.0.0-rc.1"
|
||||||
"@babel/generator": "npm:8.0.0-beta.4"
|
"@babel/generator": "npm:8.0.0-rc.1"
|
||||||
"@babel/parser": "npm:8.0.0-beta.4"
|
"@babel/parser": "npm:8.0.0-rc.1"
|
||||||
"@babel/types": "npm:8.0.0-beta.4"
|
"@babel/types": "npm:8.0.0-rc.1"
|
||||||
"@eslint/js": "npm:9.39.2"
|
"@eslint/js": "npm:9.39.2"
|
||||||
"@glimmer/syntax": "npm:0.95.0"
|
"@glimmer/syntax": "npm:0.95.0"
|
||||||
"@prettier/cli": "npm:0.10.0"
|
"@prettier/cli": "npm:0.10.0"
|
||||||
|
|||||||
Reference in new issue
Block a user