From 156b608d48900b9489bd31aff03189a6c18f9040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 7 Nov 2022 17:50:59 +0100 Subject: [PATCH 01/21] Falback to printing inner comments as trailing (#15144) Fixes https://github.com/babel/babel/issues/15138#issuecomment-1304570362 --- packages/babel-generator/src/printer.ts | 31 ++++++++++++----- .../types-with-comments-retainLines/output.js | 4 +-- packages/babel-generator/test/index.js | 34 +++++++++++++++++++ .../fixtures/enum/mix-references/output.js | 2 +- 4 files changed, 59 insertions(+), 12 deletions(-) diff --git a/packages/babel-generator/src/printer.ts b/packages/babel-generator/src/printer.ts index 9a11289bad77..401e19294d4f 100644 --- a/packages/babel-generator/src/printer.ts +++ b/packages/babel-generator/src/printer.ts @@ -787,15 +787,28 @@ class Printer { } _printTrailingComments(node: t.Node, parent?: t.Node, lineOffset?: number) { - const comments = node.trailingComments; - if (!comments?.length) return; - this._printComments( - COMMENT_TYPE.TRAILING, - comments, - node, - parent, - lineOffset, - ); + const { innerComments, trailingComments } = node; + // We print inner comments here, so that if for some reason they couldn't + // be printed in earlier locations they are still printed *somehwere*, + // even if at the end of the node. + if (innerComments?.length) { + this._printComments( + COMMENT_TYPE.TRAILING, + innerComments, + node, + parent, + lineOffset, + ); + } + if (trailingComments?.length) { + this._printComments( + COMMENT_TYPE.TRAILING, + trailingComments, + node, + parent, + lineOffset, + ); + } } _printLeadingComments(node: t.Node, parent: t.Node) { diff --git a/packages/babel-generator/test/fixtures/typescript/types-with-comments-retainLines/output.js b/packages/babel-generator/test/fixtures/typescript/types-with-comments-retainLines/output.js index 1238e16f7699..7647b84b9eda 100644 --- a/packages/babel-generator/test/fixtures/typescript/types-with-comments-retainLines/output.js +++ b/packages/babel-generator/test/fixtures/typescript/types-with-comments-retainLines/output.js @@ -6,8 +6,8 @@ C /* 2 */[ type T2 = U. /* 1 */ -C /* 2 */[]; - +C /* 2 */[] +/* 3 */; type T3 = U. diff --git a/packages/babel-generator/test/index.js b/packages/babel-generator/test/index.js index 68e043eb7a70..913325f21df5 100644 --- a/packages/babel-generator/test/index.js +++ b/packages/babel-generator/test/index.js @@ -1133,6 +1133,40 @@ describe("programmatic generation", function () { expect(output).toBe("for ((let)[x];;);"); }); }); + + describe("should print inner comments even if there are no suitable inner locations", () => { + it("atomic node", () => { + const id = t.identifier("foo"); + id.innerComments = [{ type: "CommentBlock", value: "foo" }]; + expect(generate(id).code).toMatchInlineSnapshot(`"foo /*foo*/"`); + }); + + it("node without inner locations", () => { + const expr = t.binaryExpression( + "+", + t.numericLiteral(1), + t.numericLiteral(2), + ); + expr.innerComments = [{ type: "CommentBlock", value: "foo" }]; + expect(generate(expr).code).toMatchInlineSnapshot(`"1 + 2 /*foo*/"`); + }); + + it("comment skipped because of newlines", () => { + const arrow = t.arrowFunctionExpression( + [t.identifier("x"), t.identifier("y")], + t.identifier("z"), + ); + arrow.innerComments = [ + { type: "CommentBlock", value: "foo" }, + { type: "CommentBlock", value: "new\nline" }, + ]; + expect(generate(arrow).code).toMatchInlineSnapshot(` + "(x, y) /*foo*/ => z + /*new + line*/" + `); + }); + }); }); describe("CodeGenerator", function () { diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/enum/mix-references/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/enum/mix-references/output.js index 551584e44474..1f38322e0d4c 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/enum/mix-references/output.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/enum/mix-references/output.js @@ -18,7 +18,7 @@ var Baz; Baz[Baz["b"] = 1] = "b"; Baz[Baz["x"] = Baz.a.toString()] = "x"; })(Baz || (Baz = {})); -var A; +var A; // a refers to A.a (function (A) { A[A["a"] = 0] = "a"; A[A["b"] = (() => { From 4285d5fad81839bdcfe62906f83bef5def5c9623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 8 Nov 2022 17:45:06 +0100 Subject: [PATCH 02/21] Fix printing of comments before `=>` (#15160) Fixes https://github.com/babel/babel/issues/15161 --- .../babel-generator/src/generators/methods.ts | 5 ++++- .../test/fixtures/regression/15161/input.js | 3 +++ .../fixtures/regression/15161/options.json | 3 +++ .../test/fixtures/regression/15161/output.js | 3 +++ packages/babel-generator/test/index.js | 19 ++++++++++++++++++- 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 packages/babel-generator/test/fixtures/regression/15161/input.js create mode 100644 packages/babel-generator/test/fixtures/regression/15161/options.json create mode 100644 packages/babel-generator/test/fixtures/regression/15161/output.js diff --git a/packages/babel-generator/src/generators/methods.ts b/packages/babel-generator/src/generators/methods.ts index 5d30ac98453d..e8a94da32898 100644 --- a/packages/babel-generator/src/generators/methods.ts +++ b/packages/babel-generator/src/generators/methods.ts @@ -11,7 +11,10 @@ export function _params( this._parameters(node.params, node); this.token(")"); - this.print(node.returnType, node, node.type === "ArrowFunctionExpression"); + const noLineTerminator = node.type === "ArrowFunctionExpression"; + this.print(node.returnType, node, noLineTerminator); + + this._noLineTerminator = noLineTerminator; } export function _parameters( diff --git a/packages/babel-generator/test/fixtures/regression/15161/input.js b/packages/babel-generator/test/fixtures/regression/15161/input.js new file mode 100644 index 000000000000..7e0951ac0169 --- /dev/null +++ b/packages/babel-generator/test/fixtures/regression/15161/input.js @@ -0,0 +1,3 @@ +var test = (/* placeholder */) => { + /* Unused */ +} diff --git a/packages/babel-generator/test/fixtures/regression/15161/options.json b/packages/babel-generator/test/fixtures/regression/15161/options.json new file mode 100644 index 000000000000..893844304ade --- /dev/null +++ b/packages/babel-generator/test/fixtures/regression/15161/options.json @@ -0,0 +1,3 @@ +{ + "comments": false +} diff --git a/packages/babel-generator/test/fixtures/regression/15161/output.js b/packages/babel-generator/test/fixtures/regression/15161/output.js new file mode 100644 index 000000000000..ef5f61e62396 --- /dev/null +++ b/packages/babel-generator/test/fixtures/regression/15161/output.js @@ -0,0 +1,3 @@ +var test = ( +) => { +}; \ No newline at end of file diff --git a/packages/babel-generator/test/index.js b/packages/babel-generator/test/index.js index 913325f21df5..a5493e1ee858 100644 --- a/packages/babel-generator/test/index.js +++ b/packages/babel-generator/test/index.js @@ -1151,7 +1151,7 @@ describe("programmatic generation", function () { expect(generate(expr).code).toMatchInlineSnapshot(`"1 + 2 /*foo*/"`); }); - it("comment skipped because of newlines", () => { + it("comment skipped in arrow function because of newlines", () => { const arrow = t.arrowFunctionExpression( [t.identifier("x"), t.identifier("y")], t.identifier("z"), @@ -1166,6 +1166,23 @@ describe("programmatic generation", function () { line*/" `); }); + + it("comment in arrow function with return type", () => { + const arrow = t.arrowFunctionExpression( + [t.identifier("x"), t.identifier("y")], + t.identifier("z"), + ); + arrow.returnType = t.tsTypeAnnotation(t.tsAnyKeyword()); + arrow.returnType.trailingComments = [ + { type: "CommentBlock", value: "foo" }, + // This comment is dropped. There is no way to safely print it + // as a trailingComment of the return type. + { type: "CommentBlock", value: "new\nline" }, + ]; + expect(generate(arrow).code).toMatchInlineSnapshot( + `"(x, y): any /*foo*/ => z"`, + ); + }); }); }); From f971ad3b31b2a1b1d7e3e6125929eac5066e0313 Mon Sep 17 00:00:00 2001 From: Babel Bot Date: Tue, 8 Nov 2022 21:48:59 +0000 Subject: [PATCH 03/21] v7.20.4 --- package.json | 2 +- packages/babel-generator/package.json | 2 +- packages/babel-standalone/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b99e44143935..4b3fe728f21c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "babel", - "version": "7.20.3", + "version": "7.20.4", "private": true, "type": "commonjs", "scripts": { diff --git a/packages/babel-generator/package.json b/packages/babel-generator/package.json index 785d481cb373..bd27d8074244 100644 --- a/packages/babel-generator/package.json +++ b/packages/babel-generator/package.json @@ -1,6 +1,6 @@ { "name": "@babel/generator", - "version": "7.20.3", + "version": "7.20.4", "description": "Turns an AST into code.", "author": "The Babel Team (https://babel.dev/team)", "license": "MIT", diff --git a/packages/babel-standalone/package.json b/packages/babel-standalone/package.json index 1e2c42fb825a..b35f362f2cb8 100644 --- a/packages/babel-standalone/package.json +++ b/packages/babel-standalone/package.json @@ -1,6 +1,6 @@ { "name": "@babel/standalone", - "version": "7.20.3", + "version": "7.20.4", "description": "Standalone build of Babel for use in non-Node.js environments.", "main": "./babel.js", "files": [ From 7ed57c077c40f65f129852928a9d1401a33610f2 Mon Sep 17 00:00:00 2001 From: Babel Bot Date: Tue, 8 Nov 2022 22:35:09 +0000 Subject: [PATCH 04/21] Add v7.20.4 to CHANGELOG.md [skip ci] --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 204a8a7029bb..bcd1b50d6802 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,13 @@ See [`eslint-plugin-babel`'s releases](https://github.com/babel/eslint-plugin-ba +## v7.20.4 (2022-11-08) + +#### :bug: Bug Fix +* `babel-generator` + * [#15160](https://github.com/babel/babel/pull/15160) Fix printing of comments before `=>` ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-generator`, `babel-plugin-transform-typescript` + * [#15144](https://github.com/babel/babel/pull/15144) Falback to printing inner comments as trailing ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ## v7.20.3 (2022-11-07) #### :bug: Bug Fix From 7272f2351c964ed0890954080347b6b990bcb180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 9 Nov 2022 16:10:55 +0100 Subject: [PATCH 05/21] Register `switch`'s `discriminant` in the outer scope (#15167) * Add failing test * Register `switch`'s `discriminant` in the outer scope --- .../test/fixtures/general/switch-shadow/input.js | 3 +++ .../test/fixtures/general/switch-shadow/output.js | 4 ++++ .../test/fixtures/tdz/switch-shadow/input.js | 4 ++++ .../test/fixtures/tdz/switch-shadow/output.js | 5 +++++ packages/babel-traverse/src/path/context.ts | 8 +++++--- packages/babel-traverse/test/scope.js | 8 ++++++++ 6 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/general/switch-shadow/input.js create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/general/switch-shadow/output.js create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/switch-shadow/input.js create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/switch-shadow/output.js diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/general/switch-shadow/input.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/general/switch-shadow/input.js new file mode 100644 index 000000000000..7a7a289aba67 --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/general/switch-shadow/input.js @@ -0,0 +1,3 @@ +switch (x) { + default: let x; +} diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/general/switch-shadow/output.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/general/switch-shadow/output.js new file mode 100644 index 000000000000..95cdac755c6b --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/general/switch-shadow/output.js @@ -0,0 +1,4 @@ +switch (x) { + default: + var _x; +} diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/switch-shadow/input.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/switch-shadow/input.js new file mode 100644 index 000000000000..1ba4bd251964 --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/switch-shadow/input.js @@ -0,0 +1,4 @@ +let x; +switch (x) { + default: let x; +} diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/switch-shadow/output.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/switch-shadow/output.js new file mode 100644 index 000000000000..36f5e171d618 --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/switch-shadow/output.js @@ -0,0 +1,5 @@ +var x; +switch (x) { + default: + var _x; +} diff --git a/packages/babel-traverse/src/path/context.ts b/packages/babel-traverse/src/path/context.ts index de5d4bbc7d35..6fb9f5047ddc 100644 --- a/packages/babel-traverse/src/path/context.ts +++ b/packages/babel-traverse/src/path/context.ts @@ -133,10 +133,12 @@ export function setScope(this: NodePath) { let path = this.parentPath; - // Skip method scope if is computed method key or decorator expression if ( - (this.key === "key" || this.listKey === "decorators") && - path.isMethod() + // Skip method scope if is computed method key or decorator expression + ((this.key === "key" || this.listKey === "decorators") && + path.isMethod()) || + // Skip switch scope if for discriminant (`x` in `switch (x) {}`). + (this.key === "discriminant" && path.isSwitchStatement()) ) { path = path.parentPath; } diff --git a/packages/babel-traverse/test/scope.js b/packages/babel-traverse/test/scope.js index 612e7046b3d4..30aacd61566b 100644 --- a/packages/babel-traverse/test/scope.js +++ b/packages/babel-traverse/test/scope.js @@ -282,6 +282,14 @@ describe("scope", () => { }); }); + it("switch discriminant scope", () => { + expect( + getPath(`let a = "outside"; switch (a) { default: let a = "inside" }`) + .get("body.1.discriminant") + .scope.getBinding("a").path.node.init.value, + ).toBe("outside"); + }); + it("variable declaration", function () { expect(getPath("var foo = null;").scope.getBinding("foo").path.type).toBe( "VariableDeclarator", From 4511a961a5bbdc748601cf71fe80069bfc034bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 9 Nov 2022 10:23:28 -0500 Subject: [PATCH 06/21] build: improve artifacts IO (#15165) * build: improve artifacts io * simplify babel 8 artifact name --- .github/workflows/ci.yml | 50 ++++++++++++++++++++--------------- scripts/get-artifact-files.sh | 17 ++++++++++++ 2 files changed, 45 insertions(+), 22 deletions(-) create mode 100755 scripts/get-artifact-files.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad380ecab7c5..e06668ed1068 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,15 +125,14 @@ jobs: - name: Ensure cwd does not contain uncommitted changes run: | node ./scripts/assert-dir-git-clean.js build + - name: Prepare artifacts + run: | + ./scripts/get-artifact-files.sh | tar --null -cvf babel-artifact.tar --files-from=- - uses: actions/upload-artifact@v3 with: name: babel-artifact - path: | - codemods/*/lib/**/* - eslint/*/lib/**/* - packages/*/lib/**/* - packages/babel-standalone/*.js - !**/node_modules/** + path: babel-artifact.tar + retention-days: 5 build-windows: name: Build Babel Artifacts On Windows @@ -179,6 +178,8 @@ jobs: - uses: actions/download-artifact@v3 with: name: babel-artifact + - name: Extract artifacts + run: tar -xf babel-artifact.tar; rm babel-artifact.tar - name: Lint run: make -j tscheck lint-ci - name: Ensure cwd does not contain uncommitted changes @@ -223,9 +224,8 @@ jobs: - uses: actions/download-artifact@v3 with: name: babel-artifact - - name: Generate runtime helpers - run: | - make build-plugin-transform-runtime-dist + - name: Extract artifacts + run: tar -xf babel-artifact.tar; rm babel-artifact.tar - name: Use Node.js ${{ matrix.node-version }} # Checkout node version for test executor uses: actions/setup-node@v3 with: @@ -272,15 +272,14 @@ jobs: BABEL_ENV: test BABEL_8_BREAKING: true BABEL_TYPES_8_BREAKING: true + - name: Prepare artifacts + run: | + ./scripts/get-artifact-files.sh | tar --null -cvf babel-artifact.tar --files-from=- - uses: actions/upload-artifact@v3 with: - name: babel8-test-artifact - path: | - codemods/*/lib/**/* - eslint/*/lib/**/* - packages/*/lib/**/* - packages/babel-standalone/*.js - !**/node_modules/** + name: babel8-artifact + path: babel-artifact.tar + retention-days: 5 test-babel-8-breaking: name: Test Babel 8 breaking changes on @@ -302,7 +301,9 @@ jobs: yarn install - uses: actions/download-artifact@v3 with: - name: babel8-test-artifact + name: babel8-artifact + - name: Extract artifacts + run: tar -xf babel-artifact.tar; rm babel-artifact.tar - name: Generate runtime helpers run: make build-plugin-transform-runtime-dist - name: Test @@ -334,8 +335,8 @@ jobs: - uses: actions/download-artifact@v3 with: name: babel-artifact - - name: Generate runtime helpers - run: make build-plugin-transform-runtime-dist + - name: Extract artifacts + run: tar -xf babel-artifact.tar; rm babel-artifact.tar - name: Test on Windows # Hack: --color has supports-color@5 returned true for GitHub CI # Remove once `chalk` is bumped to 4.0. @@ -361,6 +362,8 @@ jobs: - uses: actions/download-artifact@v3 with: name: babel-artifact + - name: Extract artifacts + run: tar -xf babel-artifact.tar; rm babel-artifact.tar - name: Download tests run: make -j bootstrap-flow bootstrap-typescript bootstrap-test262 - name: Run Test262 Tests @@ -407,9 +410,8 @@ jobs: - uses: actions/download-artifact@v3 with: name: babel-artifact - - name: Generate runtime helpers - run: | - make build-plugin-transform-runtime-dist + - name: Extract artifacts + run: tar -xf babel-artifact.tar; rm babel-artifact.tar - name: Generate absoluteRuntime tests run: yarn test:runtime:generate-absolute-runtime - name: Test bundlers @@ -495,6 +497,8 @@ jobs: - uses: actions/download-artifact@v3 with: name: babel-artifact + - name: Extract artifacts + run: tar -xf babel-artifact.tar; rm babel-artifact.tar - name: Downgrade ESLint to 7.5.0 run: yarn up eslint@7.5.0 - name: Run babel/eslint tests @@ -553,6 +557,8 @@ jobs: - uses: actions/download-artifact@v3 with: name: babel-artifact + - name: Extract artifacts + run: tar -xf babel-artifact.tar; rm babel-artifact.tar - name: Checkout test runner uses: actions/checkout@v3 with: diff --git a/scripts/get-artifact-files.sh b/scripts/get-artifact-files.sh new file mode 100755 index 000000000000..6094be163895 --- /dev/null +++ b/scripts/get-artifact-files.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# The artifact files will be packed into an archive shared among CI runners +# usage: +# $ get-artifact-files.sh | tar --null -cvf babel-artifact.tar --files-from=- +find . \ + -type d -name "*node_modules*" -prune -false \ + -o \( \ + -type f -path "./codemods/*/lib/*" \ + -o -type f -path "./eslint/*/lib/*" \ + -o -type f -path "./packages/*/lib/*" \ + -o -type f -path "./packages/babel-standalone/*" \ + -o -type f -path "./packages/babel-runtime/*" -name "*.js" \ + -o -type f -path "./packages/babel-runtime-corejs2/*" -name "*.js" \ + -o -type f -path "./packages/babel-runtime-corejs3/*" -name "*.js" \ + \) \ + -print0 From 9862d4273d12383b14934a1b1ec8424f1d3a00f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 9 Nov 2022 17:35:57 +0100 Subject: [PATCH 07/21] Only extract IDs for TDZ checks in assign when necessary (#15164) --- .../src/index.ts | 5 +- .../src/tdz.ts | 152 ++++++++++-------- .../fixtures/tdz/simple-assign-no-tdz/exec.js | 2 + .../tdz/simple-assign-no-tdz/input.js | 2 + .../tdz/simple-assign-no-tdz/output.js | 2 + .../fixtures/tdz/update-expression/input.js | 13 ++ .../fixtures/tdz/update-expression/output.js | 15 ++ 7 files changed, 124 insertions(+), 67 deletions(-) create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/exec.js create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/input.js create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/output.js create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/update-expression/input.js create mode 100644 packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/update-expression/output.js diff --git a/packages/babel-plugin-transform-block-scoping/src/index.ts b/packages/babel-plugin-transform-block-scoping/src/index.ts index c1a42966e16c..d0cc2d707794 100644 --- a/packages/babel-plugin-transform-block-scoping/src/index.ts +++ b/packages/babel-plugin-transform-block-scoping/src/index.ts @@ -1,6 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; import type { NodePath, Visitor, Scope, Binding } from "@babel/traverse"; -import { visitor as tdzVisitor } from "./tdz"; +import { skipTDZChecks, visitor as tdzVisitor } from "./tdz"; import type { TDZVisitorState } from "./tdz"; import { traverse, template, types as t } from "@babel/core"; import type { PluginPass } from "@babel/core"; @@ -43,8 +43,7 @@ export default declare((api, opts: Options) => { t.cloneNode(decl.id), decl.init || scope.buildUndefinedNode(), ); - // @ts-expect-error todo(flow->ts): avoid mutations - assign._ignoreBlockScopingTDZ = true; + skipTDZChecks.add(assign); nodes.push(t.expressionStatement(assign)); decl.init = this.addHelper("temporalUndefined"); } diff --git a/packages/babel-plugin-transform-block-scoping/src/tdz.ts b/packages/babel-plugin-transform-block-scoping/src/tdz.ts index 5f3bdcbcb0d2..b329d4df6cd9 100644 --- a/packages/babel-plugin-transform-block-scoping/src/tdz.ts +++ b/packages/babel-plugin-transform-block-scoping/src/tdz.ts @@ -1,10 +1,7 @@ -import { types as t, template, type PluginPass } from "@babel/core"; +import { types as t, type PluginPass } from "@babel/core"; import type { NodePath, Scope, Visitor } from "@babel/traverse"; -function getTDZStatus( - refPath: NodePath, - bindingPath: NodePath, -) { +function getTDZStatus(refPath: NodePath, bindingPath: NodePath) { const executionStatus = bindingPath._guessExecutionStatusRelativeTo(refPath); if (executionStatus === "before") { @@ -16,15 +13,26 @@ function getTDZStatus( } } +export const skipTDZChecks = new WeakSet(); + function buildTDZAssert( + status: "maybe" | "inside", node: t.Identifier | t.JSXIdentifier, state: TDZVisitorState, ) { - return t.callExpression(state.addHelper("temporalRef"), [ - // @ts-expect-error Fixme: we may need to handle JSXIdentifier - node, - t.stringLiteral(node.name), - ]); + if (status === "maybe") { + const clone = t.cloneNode(node); + skipTDZChecks.add(clone); + return t.callExpression(state.addHelper("temporalRef"), [ + // @ts-expect-error Fixme: we may need to handle JSXIdentifier + clone, + t.stringLiteral(node.name), + ]); + } else { + return t.callExpression(state.addHelper("tdz"), [ + t.stringLiteral(node.name), + ]); + } } function isReference( @@ -39,7 +47,41 @@ function isReference( return scope.getBindingIdentifier(node.name) === declared; } -const visitedMaybeTDZNodes = new WeakSet(); +type TDZReplacement = { status: "maybe" | "inside"; node: t.Expression }; +function getTDZReplacement( + path: NodePath, + state: TDZVisitorState, +): TDZReplacement | undefined; +function getTDZReplacement( + path: NodePath, + state: TDZVisitorState, + id: t.Identifier | t.JSXIdentifier, +): TDZReplacement | undefined; +function getTDZReplacement( + path: NodePath, + state: TDZVisitorState, + id: t.Identifier | t.JSXIdentifier = path.node as any, +): TDZReplacement | undefined { + if (!isReference(id, path.scope, state)) return; + + if (skipTDZChecks.has(id)) return; + skipTDZChecks.add(id); + + const bindingPath = path.scope.getBinding(id.name).path; + + if (bindingPath.isFunctionDeclaration()) return; + + const status = getTDZStatus(path, bindingPath); + if (status === "outside") return; + + if (status === "maybe") { + // add tdzThis to parent variable declarator so it's exploded + // @ts-expect-error todo(flow->ts): avoid mutations + bindingPath.parent._tdzThis = true; + } + + return { status, node: buildTDZAssert(status, id, state) }; +} export interface TDZVisitorState { tdzEnabled: boolean; @@ -50,72 +92,54 @@ export interface TDZVisitorState { export const visitor: Visitor = { ReferencedIdentifier(path, state) { if (!state.tdzEnabled) return; + if (path.parentPath.isUpdateExpression()) return; + // It will be handled after transforming the loop + if (path.parentPath.isFor({ left: path.node })) return; - const { node, parent, scope } = path; + const replacement = getTDZReplacement(path, state); + if (!replacement) return; - if (path.parentPath.isFor({ left: node })) return; - if (!isReference(node, scope, state)) return; + path.replaceWith(replacement.node); + }, - const bindingPath = scope.getBinding(node.name).path; + UpdateExpression(path, state) { + if (!state.tdzEnabled) return; - if (bindingPath.isFunctionDeclaration()) return; + const { node } = path; + if (skipTDZChecks.has(node)) return; + skipTDZChecks.add(node); - const status = getTDZStatus(path, bindingPath); - if (status === "outside") return; + const arg = path.get("argument"); + if (!arg.isIdentifier()) return; - if (status === "maybe") { - if (visitedMaybeTDZNodes.has(node)) { - return; - } - visitedMaybeTDZNodes.add(node); - const assert = buildTDZAssert(node, state); - - // add tdzThis to parent variable declarator so it's exploded - // @ts-expect-error todo(flow->ts): avoid mutations - bindingPath.parent._tdzThis = true; - - if (path.parentPath.isUpdateExpression()) { - // @ts-expect-error todo(flow->ts): avoid node mutations - if (parent._ignoreBlockScopingTDZ) return; - path.parentPath.replaceWith( - t.sequenceExpression([assert, parent as t.UpdateExpression]), - ); - } else { - path.replaceWith(assert); - } - } else if (status === "inside") { - path.replaceWith( - template.ast`${state.addHelper("tdz")}("${node.name}")` as t.Statement, - ); + const replacement = getTDZReplacement(path, state, arg.node); + if (!replacement) return; + + if (replacement.status === "maybe") { + path.insertBefore(replacement.node); + } else { + path.replaceWith(replacement.node); } }, - AssignmentExpression: { - exit(path, state) { - if (!state.tdzEnabled) return; - - const { node } = path; - - // @ts-expect-error todo(flow->ts): avoid node mutations - if (node._ignoreBlockScopingTDZ) return; + AssignmentExpression(path, state) { + if (!state.tdzEnabled) return; - const nodes = []; - const ids = path.getBindingIdentifiers(); + const { node } = path; + if (skipTDZChecks.has(node)) return; + skipTDZChecks.add(node); - for (const name of Object.keys(ids)) { - const id = ids[name]; + const nodes = []; + const ids = path.getBindingIdentifiers(); - if (isReference(id, path.scope, state)) { - nodes.push(id); - } + for (const name of Object.keys(ids)) { + const replacement = getTDZReplacement(path, state, ids[name]); + if (replacement) { + nodes.push(t.expressionStatement(replacement.node)); + if (replacement.status === "inside") break; } + } - if (nodes.length) { - // @ts-expect-error todo(flow->ts): avoid mutations - node._ignoreBlockScopingTDZ = true; - nodes.push(node); - path.replaceWithMultiple(nodes.map(n => t.expressionStatement(n))); - } - }, + if (nodes.length > 0) path.insertBefore(nodes); }, }; diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/exec.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/exec.js new file mode 100644 index 000000000000..6a90c9c28fbd --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/exec.js @@ -0,0 +1,2 @@ +let i +i = 2; diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/input.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/input.js new file mode 100644 index 000000000000..6a90c9c28fbd --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/input.js @@ -0,0 +1,2 @@ +let i +i = 2; diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/output.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/output.js new file mode 100644 index 000000000000..a39a71d895e8 --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-assign-no-tdz/output.js @@ -0,0 +1,2 @@ +var i; +i = 2; diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/update-expression/input.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/update-expression/input.js new file mode 100644 index 000000000000..346d2bf0c6bb --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/update-expression/input.js @@ -0,0 +1,13 @@ +maybeCallLater(function f() { + x++; + ++x; + x.p++; + ++x.p; +}); + +x++; +++x; +x.p++; +++x.p; + +let x; diff --git a/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/update-expression/output.js b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/update-expression/output.js new file mode 100644 index 000000000000..8e99961fe95c --- /dev/null +++ b/packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/update-expression/output.js @@ -0,0 +1,15 @@ +var x = babelHelpers.temporalUndefined; +maybeCallLater(function f() { + babelHelpers.temporalRef(x, "x") + x++; + babelHelpers.temporalRef(x, "x") + ++x; + babelHelpers.temporalRef(x, "x").p++; + ++babelHelpers.temporalRef(x, "x").p; +}); +babelHelpers.tdz("x"); +babelHelpers.tdz("x"); +babelHelpers.tdz("x").p++; +++babelHelpers.tdz("x").p; +x = void 0; +void 0; From 64c03d6d2bbe140f1f0ae5a8ce934e6847a957ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 10 Nov 2022 08:05:02 +0100 Subject: [PATCH 08/21] Don't print inner comments as leading when wrapping in `(``)` (#15143) * Don't print inner comments as leading when wrapping in `(``)` * Fix if there is a previous token --- packages/babel-generator/src/printer.ts | 5 ++++- .../fixtures/comments/inner-comments-auto-parens/input.js | 3 +++ .../fixtures/comments/inner-comments-auto-parens/output.js | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 packages/babel-generator/test/fixtures/comments/inner-comments-auto-parens/input.js create mode 100644 packages/babel-generator/test/fixtures/comments/inner-comments-auto-parens/output.js diff --git a/packages/babel-generator/src/printer.ts b/packages/babel-generator/src/printer.ts index 401e19294d4f..764016365bea 100644 --- a/packages/babel-generator/src/printer.ts +++ b/packages/babel-generator/src/printer.ts @@ -637,7 +637,10 @@ class Printer { } else { shouldPrintParens = needsParens(node, parent, this._printStack); } - if (shouldPrintParens) this.token("("); + if (shouldPrintParens) { + this.token("("); + this._endsWithInnerRaw = false; + } this._lastCommentLine = 0; diff --git a/packages/babel-generator/test/fixtures/comments/inner-comments-auto-parens/input.js b/packages/babel-generator/test/fixtures/comments/inner-comments-auto-parens/input.js new file mode 100644 index 000000000000..a609b593e45a --- /dev/null +++ b/packages/babel-generator/test/fixtures/comments/inner-comments-auto-parens/input.js @@ -0,0 +1,3 @@ +1 + ((/* c */) => {}); + +(function /* c */ () {}); diff --git a/packages/babel-generator/test/fixtures/comments/inner-comments-auto-parens/output.js b/packages/babel-generator/test/fixtures/comments/inner-comments-auto-parens/output.js new file mode 100644 index 000000000000..9d47d48492d4 --- /dev/null +++ b/packages/babel-generator/test/fixtures/comments/inner-comments-auto-parens/output.js @@ -0,0 +1,2 @@ +1 + (( /* c */) => {}); +(function /* c */ () {}); \ No newline at end of file From becd6fd9996821e6bd809fd5d12d6f7674fa7c73 Mon Sep 17 00:00:00 2001 From: Babel Bot Date: Fri, 11 Nov 2022 02:11:37 +0100 Subject: [PATCH 09/21] Update compat data (#15184) chore: update compat data to df6221d77a402a47f3650df8a9895ff8b8ab05f4 --- packages/babel-compat-data/scripts/download-compat-table.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-compat-data/scripts/download-compat-table.sh b/packages/babel-compat-data/scripts/download-compat-table.sh index 5ccd9aea4a88..6998a2073332 100755 --- a/packages/babel-compat-data/scripts/download-compat-table.sh +++ b/packages/babel-compat-data/scripts/download-compat-table.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -COMPAT_TABLE_COMMIT=181d4e9e5b5f918cfe0d956a570bfb8a38b4f453 +COMPAT_TABLE_COMMIT=df6221d77a402a47f3650df8a9895ff8b8ab05f4 GIT_HEAD=build/compat-table/.git/HEAD if [ -d "build/compat-table" ]; then From 641f67773b0b5b8e552b0ffd1a07e0b7625202b0 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:50:34 +0800 Subject: [PATCH 10/21] chore: Tweak `IS_PUBLISH` environment variable (#15174) --- Gulpfile.mjs | 4 +--- Makefile.js | 2 +- Makefile.source.mjs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Gulpfile.mjs b/Gulpfile.mjs index b46f664da6e1..ba28e13f7445 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -259,8 +259,6 @@ function createWorker(useWorker) { } async function buildBabel(useWorker, ignore = []) { - const enableSourceMap = !process.env.IS_PUBLISH; - const worker = createWorker(useWorker); const files = await new Promise((resolve, reject) => { glob( @@ -281,7 +279,7 @@ async function buildBabel(useWorker, ignore = []) { const dest = "./" + mapSrcToLib(file.slice(2)); promises.push( worker.transform(file, dest, { - sourceMaps: enableSourceMap && !file.endsWith(".d.ts"), + sourceMaps: !file.endsWith(".d.ts"), }) ); } diff --git a/Makefile.js b/Makefile.js index ff9fc0293cd4..c1d35ca626fb 100644 --- a/Makefile.js +++ b/Makefile.js @@ -1,3 +1,3 @@ /* eslint-disable */ // prettier-ignore -"use strict";var e=require("os"),t=require("fs"),r=require("path"),n=require("events"),i=require("assert"),o=require("util"),s=require("child_process");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=c(e),u=c(t),l=c(r),f=c(n),p=c(i),h=c(o),d=c(s),v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},y=function(e){return e&&e.Math==Math&&e},g=y("object"==typeof globalThis&&globalThis)||y("object"==typeof window&&window)||y("object"==typeof self&&self)||y("object"==typeof v&&v)||function(){return this}()||Function("return this")(),m={},b=function(e){try{return!!e()}catch(e){return!0}},w=!b((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),E=!b((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),S=E,x=Function.prototype.call,O=S?x.bind(x):function(){return x.apply(x,arguments)},k={},j={}.propertyIsEnumerable,_=Object.getOwnPropertyDescriptor,A=_&&!j.call({1:2},1);k.f=A?function(e){var t=_(this,e);return!!t&&t.enumerable}:j;var R,I,F=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},L=E,P=Function.prototype,T=P.bind,D=P.call,C=L&&T.bind(D,D),N=L?function(e){return e&&C(e)}:function(e){return e&&function(){return D.apply(e,arguments)}},M=N,G=M({}.toString),$=M("".slice),B=function(e){return $(G(e),8,-1)},U=b,W=B,q=Object,z=N("".split),X=U((function(){return!q("z").propertyIsEnumerable(0)}))?function(e){return"String"==W(e)?z(e,""):q(e)}:q,V=function(e){return null==e},Y=V,K=TypeError,H=function(e){if(Y(e))throw K("Can't call method on "+e);return e},Q=X,J=H,Z=function(e){return Q(J(e))},ee=function(e){return"function"==typeof e},te=ee,re="object"==typeof document&&document.all,ne=void 0===re&&void 0!==re?function(e){return"object"==typeof e?null!==e:te(e)||e===re}:function(e){return"object"==typeof e?null!==e:te(e)},ie=g,oe=ee,se=function(e){return oe(e)?e:void 0},ce=function(e,t){return arguments.length<2?se(ie[e]):ie[e]&&ie[e][t]},ae=N({}.isPrototypeOf),ue=ce("navigator","userAgent")||"",le=g,fe=ue,pe=le.process,he=le.Deno,de=pe&&pe.versions||he&&he.version,ve=de&&de.v8;ve&&(I=(R=ve.split("."))[0]>0&&R[0]<4?1:+(R[0]+R[1])),!I&&fe&&(!(R=fe.match(/Edge\/(\d+)/))||R[1]>=74)&&(R=fe.match(/Chrome\/(\d+)/))&&(I=+R[1]);var ye=I,ge=ye,me=b,be=!!Object.getOwnPropertySymbols&&!me((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ge&&ge<41})),we=be&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ee=ce,Se=ee,xe=ae,Oe=Object,ke=we?function(e){return"symbol"==typeof e}:function(e){var t=Ee("Symbol");return Se(t)&&xe(t.prototype,Oe(e))},je=String,_e=function(e){try{return je(e)}catch(e){return"Object"}},Ae=ee,Re=_e,Ie=TypeError,Fe=function(e){if(Ae(e))return e;throw Ie(Re(e)+" is not a function")},Le=Fe,Pe=V,Te=function(e,t){var r=e[t];return Pe(r)?void 0:Le(r)},De=O,Ce=ee,Ne=ne,Me=TypeError,Ge={exports:{}},$e=g,Be=Object.defineProperty,Ue=function(e,t){try{Be($e,e,{value:t,configurable:!0,writable:!0})}catch(r){$e[e]=t}return t},We=Ue,qe=g["__core-js_shared__"]||We("__core-js_shared__",{}),ze=qe;(Ge.exports=function(e,t){return ze[e]||(ze[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.25.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Xe=H,Ve=Object,Ye=function(e){return Ve(Xe(e))},Ke=Ye,He=N({}.hasOwnProperty),Qe=Object.hasOwn||function(e,t){return He(Ke(e),t)},Je=N,Ze=0,et=Math.random(),tt=Je(1..toString),rt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+tt(++Ze+et,36)},nt=g,it=Ge.exports,ot=Qe,st=rt,ct=be,at=we,ut=it("wks"),lt=nt.Symbol,ft=lt&<.for,pt=at?lt:lt&<.withoutSetter||st,ht=function(e){if(!ot(ut,e)||!ct&&"string"!=typeof ut[e]){var t="Symbol."+e;ct&&ot(lt,e)?ut[e]=lt[e]:ut[e]=at&&ft?ft(t):pt(t)}return ut[e]},dt=O,vt=ne,yt=ke,gt=Te,mt=function(e,t){var r,n;if("string"===t&&Ce(r=e.toString)&&!Ne(n=De(r,e)))return n;if(Ce(r=e.valueOf)&&!Ne(n=De(r,e)))return n;if("string"!==t&&Ce(r=e.toString)&&!Ne(n=De(r,e)))return n;throw Me("Can't convert object to primitive value")},bt=TypeError,wt=ht("toPrimitive"),Et=function(e,t){if(!vt(e)||yt(e))return e;var r,n=gt(e,wt);if(n){if(void 0===t&&(t="default"),r=dt(n,e,t),!vt(r)||yt(r))return r;throw bt("Can't convert object to primitive value")}return void 0===t&&(t="number"),mt(e,t)},St=ke,xt=function(e){var t=Et(e,"string");return St(t)?t:t+""},Ot=ne,kt=g.document,jt=Ot(kt)&&Ot(kt.createElement),_t=function(e){return jt?kt.createElement(e):{}},At=_t,Rt=!w&&!b((function(){return 7!=Object.defineProperty(At("div"),"a",{get:function(){return 7}}).a})),It=w,Ft=O,Lt=k,Pt=F,Tt=Z,Dt=xt,Ct=Qe,Nt=Rt,Mt=Object.getOwnPropertyDescriptor;m.f=It?Mt:function(e,t){if(e=Tt(e),t=Dt(t),Nt)try{return Mt(e,t)}catch(e){}if(Ct(e,t))return Pt(!Ft(Lt.f,e,t),e[t])};var Gt={},$t=w&&b((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Bt=ne,Ut=String,Wt=TypeError,qt=function(e){if(Bt(e))return e;throw Wt(Ut(e)+" is not an object")},zt=w,Xt=Rt,Vt=$t,Yt=qt,Kt=xt,Ht=TypeError,Qt=Object.defineProperty,Jt=Object.getOwnPropertyDescriptor;Gt.f=zt?Vt?function(e,t,r){if(Yt(e),t=Kt(t),Yt(r),"function"==typeof e&&"prototype"===t&&"value"in r&&"writable"in r&&!r.writable){var n=Jt(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:"configurable"in r?r.configurable:n.configurable,enumerable:"enumerable"in r?r.enumerable:n.enumerable,writable:!1})}return Qt(e,t,r)}:Qt:function(e,t,r){if(Yt(e),t=Kt(t),Yt(r),Xt)try{return Qt(e,t,r)}catch(e){}if("get"in r||"set"in r)throw Ht("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var Zt=Gt,er=F,tr=w?function(e,t,r){return Zt.f(e,t,er(1,r))}:function(e,t,r){return e[t]=r,e},rr={exports:{}},nr=w,ir=Qe,or=Function.prototype,sr=nr&&Object.getOwnPropertyDescriptor,cr=ir(or,"name"),ar={EXISTS:cr,PROPER:cr&&"something"===function(){}.name,CONFIGURABLE:cr&&(!nr||nr&&sr(or,"name").configurable)},ur=ee,lr=qe,fr=N(Function.toString);ur(lr.inspectSource)||(lr.inspectSource=function(e){return fr(e)});var pr,hr,dr,vr=lr.inspectSource,yr=ee,gr=g.WeakMap,mr=yr(gr)&&/native code/.test(String(gr)),br=Ge.exports,wr=rt,Er=br("keys"),Sr=function(e){return Er[e]||(Er[e]=wr(e))},xr={},Or=mr,kr=g,jr=N,_r=ne,Ar=tr,Rr=Qe,Ir=qe,Fr=Sr,Lr=xr,Pr=kr.TypeError,Tr=kr.WeakMap;if(Or||Ir.state){var Dr=Ir.state||(Ir.state=new Tr),Cr=jr(Dr.get),Nr=jr(Dr.has),Mr=jr(Dr.set);pr=function(e,t){if(Nr(Dr,e))throw Pr("Object already initialized");return t.facade=e,Mr(Dr,e,t),t},hr=function(e){return Cr(Dr,e)||{}},dr=function(e){return Nr(Dr,e)}}else{var Gr=Fr("state");Lr[Gr]=!0,pr=function(e,t){if(Rr(e,Gr))throw Pr("Object already initialized");return t.facade=e,Ar(e,Gr,t),t},hr=function(e){return Rr(e,Gr)?e[Gr]:{}},dr=function(e){return Rr(e,Gr)}}var $r={set:pr,get:hr,has:dr,enforce:function(e){return dr(e)?hr(e):pr(e,{})},getterFor:function(e){return function(t){var r;if(!_r(t)||(r=hr(t)).type!==e)throw Pr("Incompatible receiver, "+e+" required");return r}}},Br=b,Ur=ee,Wr=Qe,qr=w,zr=ar.CONFIGURABLE,Xr=vr,Vr=$r.enforce,Yr=$r.get,Kr=Object.defineProperty,Hr=qr&&!Br((function(){return 8!==Kr((function(){}),"length",{value:8}).length})),Qr=String(String).split("String"),Jr=rr.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Wr(e,"name")||zr&&e.name!==t)&&(qr?Kr(e,"name",{value:t,configurable:!0}):e.name=t),Hr&&r&&Wr(r,"arity")&&e.length!==r.arity&&Kr(e,"length",{value:r.arity});try{r&&Wr(r,"constructor")&&r.constructor?qr&&Kr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var n=Vr(e);return Wr(n,"source")||(n.source=Qr.join("string"==typeof t?t:"")),e};Function.prototype.toString=Jr((function(){return Ur(this)&&Yr(this).source||Xr(this)}),"toString");var Zr=ee,en=Gt,tn=rr.exports,rn=Ue,nn=function(e,t,r,n){n||(n={});var i=n.enumerable,o=void 0!==n.name?n.name:t;if(Zr(r)&&tn(r,o,n),n.global)i?e[t]=r:rn(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch(e){}i?e[t]=r:en.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},on={},sn=Math.ceil,cn=Math.floor,an=Math.trunc||function(e){var t=+e;return(t>0?cn:sn)(t)},un=function(e){var t=+e;return t!=t||0===t?0:an(t)},ln=un,fn=Math.max,pn=Math.min,hn=function(e,t){var r=ln(e);return r<0?fn(r+t,0):pn(r,t)},dn=un,vn=Math.min,yn=function(e){return e>0?vn(dn(e),9007199254740991):0},gn=yn,mn=function(e){return gn(e.length)},bn=Z,wn=hn,En=mn,Sn=function(e){return function(t,r,n){var i,o=bn(t),s=En(o),c=wn(n,s);if(e&&r!=r){for(;s>c;)if((i=o[c++])!=i)return!0}else for(;s>c;c++)if((e||c in o)&&o[c]===r)return e||c||0;return!e&&-1}},xn={includes:Sn(!0),indexOf:Sn(!1)},On=Qe,kn=Z,jn=xn.indexOf,_n=xr,An=N([].push),Rn=function(e,t){var r,n=kn(e),i=0,o=[];for(r in n)!On(_n,r)&&On(n,r)&&An(o,r);for(;t.length>i;)On(n,r=t[i++])&&(~jn(o,r)||An(o,r));return o},In=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Fn=Rn,Ln=In.concat("length","prototype");on.f=Object.getOwnPropertyNames||function(e){return Fn(e,Ln)};var Pn={};Pn.f=Object.getOwnPropertySymbols;var Tn=ce,Dn=on,Cn=Pn,Nn=qt,Mn=N([].concat),Gn=Tn("Reflect","ownKeys")||function(e){var t=Dn.f(Nn(e)),r=Cn.f;return r?Mn(t,r(e)):t},$n=Qe,Bn=Gn,Un=m,Wn=Gt,qn=function(e,t,r){for(var n=Bn(t),i=Wn.f,o=Un.f,s=0;ss;)wi.f(e,r=i[s++],n[r]);return e};var Oi,ki=ce("document","documentElement"),ji=qt,_i=di,Ai=In,Ri=xr,Ii=ki,Fi=_t,Li=Sr("IE_PROTO"),Pi=function(){},Ti=function(e){return"