From dd1b8fd20b6f6de6940fa0566e045b2aefa80f4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 01:47:33 +0000 Subject: [PATCH 1/2] Build(deps): Bump leven from 3.1.0 to 4.0.0 Bumps [leven](https://github.com/sindresorhus/leven) from 3.1.0 to 4.0.0. - [Release notes](https://github.com/sindresorhus/leven/releases) - [Commits](https://github.com/sindresorhus/leven/compare/v3.1.0...v4.0.0) --- updated-dependencies: - dependency-name: leven dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b4667bd2a697..112ed80ccf99 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "ignore": "5.2.0", "jest-docblock": "27.5.1", "json5": "2.2.1", - "leven": "3.1.0", + "leven": "4.0.0", "lines-and-columns": "2.0.3", "linguist-languages": "7.15.0", "lodash": "4.17.21", diff --git a/yarn.lock b/yarn.lock index c9dde1cec733..c40f4b70e630 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4659,16 +4659,21 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== -leven@3.1.0, leven@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" - integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== +leven@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/leven/-/leven-4.0.0.tgz#b9c39c803f835950fabef9e122a9b47b95708710" + integrity sha512-puehA3YKku3osqPlNuzGDUHq8WpwXupUg1V6NXdV38G+gr+gkBwFC8g1b/+YcIvp8gnqVIus+eJCH/eGsRmJNw== leven@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580" integrity sha1-wuep93IJTe6dNCAq6KzORoeHVYA= +leven@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" + integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== + levn@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" From 629838e003ac7b6aaa6d8c2b8146cd58d7e22305 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sat, 2 Apr 2022 19:08:19 +0800 Subject: [PATCH 2/2] Bundle `leven` --- scripts/vendors/vendor-meta.json | 17 ++++++ scripts/vendors/vendors.mjs | 1 + src/cli/options/normalize-cli-options.js | 5 +- vendors/leven.d.ts | 3 + vendors/leven.js | 76 ++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 vendors/leven.d.ts create mode 100644 vendors/leven.js diff --git a/scripts/vendors/vendor-meta.json b/scripts/vendors/vendor-meta.json index 0631c4c21b0b..da431f86e90b 100644 --- a/scripts/vendors/vendor-meta.json +++ b/scripts/vendors/vendor-meta.json @@ -388,6 +388,23 @@ } ] }, + { + "name": "leven", + "maintainers": [], + "version": "4.0.0", + "description": "Measure the difference between two strings using the Levenshtein distance algorithm", + "repository": "sindresorhus/leven", + "homepage": null, + "private": false, + "license": "MIT", + "licenseText": "MIT License\n\nCopyright (c) Sindre Sorhus (https://sindresorhus.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "https://sindresorhus.com" + }, + "contributors": [] + }, { "name": "mimic-fn", "maintainers": [], diff --git a/scripts/vendors/vendors.mjs b/scripts/vendors/vendors.mjs index dc00c233c782..aa811aade409 100644 --- a/scripts/vendors/vendors.mjs +++ b/scripts/vendors/vendors.mjs @@ -5,6 +5,7 @@ const vendors = [ "html-element-attributes", "html-tag-names", "html-void-elements", + "leven", "mem", "string-width", "tempy", diff --git a/src/cli/options/normalize-cli-options.js b/src/cli/options/normalize-cli-options.js index 6e063f69ee08..b0a9d378de96 100644 --- a/src/cli/options/normalize-cli-options.js +++ b/src/cli/options/normalize-cli-options.js @@ -1,9 +1,10 @@ "use strict"; -const leven = require("leven"); -const { optionsNormalizer } = require("../prettier-internal.js"); // eslint-disable-next-line no-restricted-modules const { default: chalk } = require("../../../vendors/chalk.js"); +// eslint-disable-next-line no-restricted-modules +const { default: leven } = require("../../../vendors/leven.js"); +const { optionsNormalizer } = require("../prettier-internal.js"); function normalizeCliOptions(options, optionInfos, opts) { return optionsNormalizer.normalizeCliOptions(options, optionInfos, { diff --git a/vendors/leven.d.ts b/vendors/leven.d.ts new file mode 100644 index 000000000000..31a132da699c --- /dev/null +++ b/vendors/leven.d.ts @@ -0,0 +1,3 @@ +// This file is generated automatically. +export {default} from "leven"; +export * from "leven"; diff --git a/vendors/leven.js b/vendors/leven.js new file mode 100644 index 000000000000..b22ff5a5960b --- /dev/null +++ b/vendors/leven.js @@ -0,0 +1,76 @@ +// @ts-nocheck +// This file is generated automatically +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// node_modules/leven/index.js +var leven_exports = {}; +__export(leven_exports, { + default: () => leven +}); +module.exports = __toCommonJS(leven_exports); +var array = []; +var characterCodeCache = []; +function leven(first, second) { + if (first === second) { + return 0; + } + const swap = first; + if (first.length > second.length) { + first = second; + second = swap; + } + let firstLength = first.length; + let secondLength = second.length; + while (firstLength > 0 && first.charCodeAt(~-firstLength) === second.charCodeAt(~-secondLength)) { + firstLength--; + secondLength--; + } + let start = 0; + while (start < firstLength && first.charCodeAt(start) === second.charCodeAt(start)) { + start++; + } + firstLength -= start; + secondLength -= start; + if (firstLength === 0) { + return secondLength; + } + let bCharacterCode; + let result; + let temporary; + let temporary2; + let index = 0; + let index2 = 0; + while (index < firstLength) { + characterCodeCache[index] = first.charCodeAt(start + index); + array[index] = ++index; + } + while (index2 < secondLength) { + bCharacterCode = second.charCodeAt(start + index2); + temporary = index2++; + result = index2; + for (index = 0; index < firstLength; index++) { + temporary2 = bCharacterCode === characterCodeCache[index] ? temporary : temporary + 1; + temporary = array[index]; + result = array[index] = temporary > result ? temporary2 > result ? result + 1 : temporary2 : temporary2 > temporary ? temporary + 1 : temporary2; + } + } + return result; +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = {});