From fdb9540816b9a36c40d5053fa8a4bfd70dddc8d0 Mon Sep 17 00:00:00 2001 From: Wojciech Lewicki Date: Thu, 2 Jun 2022 11:20:36 +0200 Subject: [PATCH 01/10] chore: add CI for JS and iOS formatting --- .clang-format | 91 +++++++++++++ .github/workflows/main.yml | 32 +++++ .husky/pre-commit | 4 + README.md | 19 ++- package.json | 13 +- yarn.lock | 271 ++++++++++++++++++++++++++++++++++++- 6 files changed, 416 insertions(+), 14 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/main.yml create mode 100755 .husky/pre-commit diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..bc20b078f --- /dev/null +++ b/.clang-format @@ -0,0 +1,91 @@ +--- +AccessModifierOffset: -1 +AlignAfterOpenBracket: AlwaysBreak +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: true +AlignOperands: false +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: false +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ] +IncludeCategories: + - Regex: '^<.*\.h(pp)?>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IndentCaseLabels: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Right +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +--- +Language: ObjC +ColumnLimit: 120 +BreakBeforeBraces: WebKit +... diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..6dfe62073 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ + +name: Lint +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: +jobs: + install-and-lint: + runs-on: ubuntu-latest + concurrency: + group: install-and-lint-${{ github.ref }} + cancel-in-progress: true + steps: + - name: checkout + uses: actions/checkout@v2 + - name: Use Node.js 14 + uses: actions/setup-node@v2 + with: + node-version: 14 + cache: 'yarn' + - name: Install node dependencies + run: yarn + - name: Format code + run: | + yarn format + - name: Test and lint + run: | + yarn test \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..5a182ef10 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +yarn lint-staged diff --git a/README.md b/README.md index ad7d74724..260a2fd26 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,9 @@ Install the JavaScript with: - ```bash - expo install react-native-svg - ``` +```bash +expo install react-native-svg +``` 📚 See the [**Expo docs**](https://docs.expo.io/versions/latest/sdk/svg/) for more info or jump ahead to [Usage](#Usage). @@ -77,10 +77,13 @@ Install the JavaScript with: 1. Install library from npm + ```bash npm install react-native-svg ``` + from yarn + ```bash yarn add react-native-svg ``` @@ -358,16 +361,20 @@ import * as React from 'react'; import { SvgUri } from 'react-native-svg'; export default () => { - const [uri, setUri] = React.useState('https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/not_existing.svg') + const [uri, setUri] = React.useState( + 'https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/not_existing.svg', + ); return ( setUri('https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg')} + onError={() => + setUri('https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg') + } width="100%" height="100%" uri={uri} /> ); -} +}; ``` ### Use with svg files diff --git a/package.json b/package.json index a976b5c5d..7fb910f25 100644 --- a/package.json +++ b/package.json @@ -45,11 +45,12 @@ "flow": "flow src", "flowgen": "flowgen src/index.d.ts -o src/index.js.flow", "flowtyped": "flow-typed install", - "format": "prettier README.md CONTRIBUTING.md CODE_OF_CONDUCT.md './src/**/*.{ts,tsx}' src/index.d.ts --write", + "format-ios": "find apple/ -iname *.h -o -iname *.m -o -iname *.cpp -o -iname *.mm | xargs clang-format -i", + "format": "prettier README.md CONTRIBUTING.md CODE_OF_CONDUCT.md './src/**/*.{ts,tsx}' './Example/**/*.{ts,tsx}' src/index.d.ts --write && yarn format-ios", "jest": "jest", "lint": "eslint --ext .ts,.tsx src", "peg": "pegjs -o src/lib/extract/transform.js ./src/lib/extract/transform.peg", - "prepare": "npm run flowgen && npm run bob", + "prepare": "npm run flowgen && npm run bob && husky install", "release": "npm login && release-it", "test": "npm run lint && npm run tsc && npm run flow && npm run jest", "tsc": "tsc --noEmit" @@ -71,6 +72,7 @@ "@types/react-native": "^0.63.40", "babel-eslint": "^10.1.0", "babel-jest": "^25.1.0", + "clang-format": "^1.8.0", "eslint": "^6.8.0", "eslint-plugin-flowtype": "^4.6.0", "eslint-plugin-prettier": "^3.1.2", @@ -78,7 +80,9 @@ "flow-bin": "^0.119.1", "flow-typed": "^3.0.0", "flowgen": "^1.10.0", + "husky": "^8.0.1", "jest": "^25.1.0", + "lint-staged": "^13.0.0", "pegjs": "^0.10.0", "prettier": "^1.19.1", "react": "^16.13.0", @@ -90,5 +94,10 @@ "jest": { "preset": "react-native" }, + "lint-staged": { + "{src,Example}/**/*.{js,ts,tsx}": "yarn format", + "src/**/*.{js,ts,tsx}": "yarn lint", + "apple/**/*.{h,m,mm,cpp}": "yarn format-ios" + }, "nativePackage": true } diff --git a/yarn.lock b/yarn.lock index 63589cc48..a32969e46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2039,7 +2039,7 @@ ansi-escapes@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== -ansi-escapes@^4.2.1: +ansi-escapes@^4.2.1, ansi-escapes@^4.3.0: version "4.3.2" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== @@ -2084,6 +2084,11 @@ ansi-regex@^5.0.0, ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -2098,6 +2103,11 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" +ansi-styles@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.1.0.tgz#87313c102b8118abd57371afab34618bf7350ed3" + integrity sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ== + ansi-wrap@0.1.0, ansi-wrap@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" @@ -2260,6 +2270,11 @@ async@^2.4.0: dependencies: lodash "^4.17.14" +async@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" + integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -2545,7 +2560,7 @@ braces@^2.3.1: split-string "^3.0.2" to-regex "^3.0.1" -braces@^3.0.1: +braces@^3.0.1, braces@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -2773,6 +2788,15 @@ ci-info@^3.2.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.0.tgz#b4ed1fb6818dea4803a55c623041f9165d2066b2" integrity sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw== +clang-format@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.8.0.tgz#7779df1c5ce1bc8aac1b0b02b4e479191ef21d46" + integrity sha512-pK8gzfu55/lHzIpQ1givIbWfn3eXnU7SfxqIwVgnn5jEM6j4ZJYjpFqFs4iSBPNedzRMmfjYjuQhu657WAXHXw== + dependencies: + async "^3.2.3" + glob "^7.0.0" + resolve "^1.1.6" + class-utils@^0.3.5: version "0.3.6" resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" @@ -2812,6 +2836,22 @@ cli-spinners@^2.0.0, cli-spinners@^2.5.0: resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.6.1.tgz#adc954ebe281c37a6319bfa401e6dd2488ffb70d" integrity sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g== +cli-truncate@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-2.1.0.tgz#c39e28bf05edcde5be3b98992a22deed5a2b93c7" + integrity sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg== + dependencies: + slice-ansi "^3.0.0" + string-width "^4.2.0" + +cli-truncate@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-3.1.0.tgz#3f23ab12535e3d73e839bb43e73c9de487db1389" + integrity sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA== + dependencies: + slice-ansi "^5.0.0" + string-width "^5.0.0" + cli-width@^2.0.0: version "2.2.1" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.1.tgz#b0433d0b4e9c847ef18868a4ef16fd5fc8271c48" @@ -2913,6 +2953,11 @@ colorette@^1.0.7: resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40" integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g== +colorette@^2.0.16: + version "2.0.16" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" + integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g== + colors@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" @@ -2940,6 +2985,11 @@ commander@^6.1.0: resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== +commander@^9.3.0: + version "9.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.3.0.tgz#f619114a5a2d2054e0d9ff1b31d5ccf89255e26b" + integrity sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw== + commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -3207,6 +3257,13 @@ debug@4.3.3, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: dependencies: ms "2.1.2" +debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -3428,6 +3485,11 @@ duplexer3@^0.1.4: resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -3463,6 +3525,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" @@ -3913,6 +3980,21 @@ execa@^4.0.2: signal-exit "^3.0.2" strip-final-newline "^2.0.0" +execa@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-6.1.0.tgz#cea16dee211ff011246556388effa0818394fb20" + integrity sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.1" + human-signals "^3.0.1" + is-stream "^3.0.0" + merge-stream "^2.0.0" + npm-run-path "^5.1.0" + onetime "^6.0.0" + signal-exit "^3.0.7" + strip-final-newline "^3.0.0" + exit@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" @@ -4382,7 +4464,7 @@ get-stream@^5.0.0, get-stream@^5.1.0: dependencies: pump "^3.0.0" -get-stream@^6.0.0: +get-stream@^6.0.0, get-stream@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== @@ -4727,6 +4809,16 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +human-signals@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-3.0.1.tgz#c740920859dafa50e5a3222da9d3bf4bb0e5eef5" + integrity sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ== + +husky@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.1.tgz#511cb3e57de3e3190514ae49ed50f6bc3f50b3e9" + integrity sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw== + iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" @@ -5068,6 +5160,11 @@ is-fullwidth-code-point@^3.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== +is-fullwidth-code-point@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" + integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== + is-generator-fn@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" @@ -5195,6 +5292,11 @@ is-stream@^2.0.0: resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== +is-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-3.0.0.tgz#e6bfd7aa6bef69f4f472ce9bb681e3e57b4319ac" + integrity sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA== + is-string@^1.0.5, is-string@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.7.tgz#0dd12bf2006f255bb58f695110eff7491eebc0fd" @@ -6056,11 +6158,49 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" +lilconfig@2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.5.tgz#19e57fd06ccc3848fd1891655b5a447092225b25" + integrity sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg== + lines-and-columns@^1.1.6: version "1.2.4" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== +lint-staged@^13.0.0: + version "13.0.0" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-13.0.0.tgz#ce3526a844e6328814a3261fbfedc610a18856fa" + integrity sha512-vWban5utFt78VZohbosUxNIa46KKJ+KOQTDWTQ8oSl1DLEEVl9zhUtaQbiiydAmx+h2wKJK2d0+iMaRmknuWRQ== + dependencies: + cli-truncate "^3.1.0" + colorette "^2.0.16" + commander "^9.3.0" + debug "^4.3.4" + execa "^6.1.0" + lilconfig "2.0.5" + listr2 "^4.0.5" + micromatch "^4.0.5" + normalize-path "^3.0.0" + object-inspect "^1.12.2" + pidtree "^0.5.0" + string-argv "^0.3.1" + yaml "^2.1.1" + +listr2@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/listr2/-/listr2-4.0.5.tgz#9dcc50221583e8b4c71c43f9c7dfd0ef546b75d5" + integrity sha512-juGHV1doQdpNT3GSTs9IUN43QJb7KHdF9uqg7Vufs/tG9VTzpFphqF4pm/ICdAABGQxsyNn9CiYA3StkI6jpwA== + dependencies: + cli-truncate "^2.1.0" + colorette "^2.0.16" + log-update "^4.0.0" + p-map "^4.0.0" + rfdc "^1.3.0" + rxjs "^7.5.5" + through "^2.3.8" + wrap-ansi "^7.0.0" + locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -6121,6 +6261,16 @@ log-symbols@^4.1.0: chalk "^4.1.0" is-unicode-supported "^0.1.0" +log-update@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/log-update/-/log-update-4.0.0.tgz#589ecd352471f2a1c0c570287543a64dfd20e0a1" + integrity sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg== + dependencies: + ansi-escapes "^4.3.0" + cli-cursor "^3.1.0" + slice-ansi "^4.0.0" + wrap-ansi "^6.2.0" + logkitty@^0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/logkitty/-/logkitty-0.7.1.tgz#8e8d62f4085a826e8d38987722570234e33c6aa7" @@ -6586,6 +6736,14 @@ micromatch@^4.0.2, micromatch@^4.0.4: braces "^3.0.1" picomatch "^2.2.3" +micromatch@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + mime-db@1.51.0, "mime-db@>= 1.43.0 < 2": version "1.51.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.51.0.tgz#d9ff62451859b18342d960850dc3cfb77e63fb0c" @@ -6630,6 +6788,11 @@ mimic-fn@^2.1.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== +mimic-fn@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc" + integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== + mimic-response@^1.0.0, mimic-response@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" @@ -6838,6 +7001,13 @@ npm-run-path@^4.0.0, npm-run-path@^4.0.1: dependencies: path-key "^3.0.0" +npm-run-path@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-5.1.0.tgz#bc62f7f3f6952d9894bd08944ba011a6ee7b7e00" + integrity sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q== + dependencies: + path-key "^4.0.0" + nth-check@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2" @@ -6889,6 +7059,11 @@ object-inspect@^1.11.0, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0" integrity sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g== +object-inspect@^1.12.2: + version "1.12.2" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" + integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== + object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -6986,6 +7161,13 @@ onetime@^5.1.0, onetime@^5.1.2: dependencies: mimic-fn "^2.1.0" +onetime@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-6.0.0.tgz#7c24c18ed1fd2e9bca4bd26806a33613c77d34b4" + integrity sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ== + dependencies: + mimic-fn "^4.0.0" + open@7.4.2: version "7.4.2" resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321" @@ -7118,6 +7300,13 @@ p-map@^3.0.0: dependencies: aggregate-error "^3.0.0" +p-map@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" + integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== + dependencies: + aggregate-error "^3.0.0" + p-timeout@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-3.2.0.tgz#c7e17abc971d2a7962ef83626b35d635acf23dfe" @@ -7230,6 +7419,11 @@ path-key@^3.0.0, path-key@^3.1.0: resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== +path-key@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-4.0.0.tgz#295588dc3aee64154f877adb9d780b81c554bf18" + integrity sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ== + path-parse@^1.0.6, path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" @@ -7255,11 +7449,16 @@ picocolors@^1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.0.4, picomatch@^2.2.3: +picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== +pidtree@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.5.0.tgz#ad5fbc1de78b8a5f99d6fbdd4f6e4eee21d1aca1" + integrity sha512-9nxspIM7OpZuhBxPg73Zvyq7j1QMPMPsGKTqRc2XOaFQauDvoNz9fM1Wdkjmeo7l9GXOZiRs97sPkuayl39wjA== + pify@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" @@ -7896,6 +8095,11 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== +rfdc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" + integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== + rimraf@2.6.3: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" @@ -7965,6 +8169,13 @@ rxjs@^7.2.0: dependencies: tslib "^2.1.0" +rxjs@^7.5.5: + version "7.5.5" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.5.tgz#2ebad89af0f560f460ad5cc4213219e1f7dd4e9f" + integrity sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw== + dependencies: + tslib "^2.1.0" + safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -8197,7 +8408,7 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" -signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: +signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== @@ -8235,6 +8446,15 @@ slice-ansi@^2.0.0, slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" +slice-ansi@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-3.0.0.tgz#31ddc10930a1b7e0b67b08c96c2f49b77a789787" + integrity sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ== + dependencies: + ansi-styles "^4.0.0" + astral-regex "^2.0.0" + is-fullwidth-code-point "^3.0.0" + slice-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" @@ -8244,6 +8464,14 @@ slice-ansi@^4.0.0: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" +slice-ansi@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-5.0.0.tgz#b73063c57aa96f9cd881654b15294d95d285c42a" + integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== + dependencies: + ansi-styles "^6.0.0" + is-fullwidth-code-point "^4.0.0" + snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -8418,6 +8646,11 @@ strict-uri-encode@^2.0.0: resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY= +string-argv@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" + integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== + string-length@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/string-length/-/string-length-3.1.0.tgz#107ef8c23456e187a8abd4a61162ff4ac6e25837" @@ -8452,6 +8685,15 @@ string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2 is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" +string-width@^5.0.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + string.prototype.matchall@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.6.tgz#5abb5dabc94c7b0ea2380f65ba610b3a544b15fa" @@ -8517,6 +8759,13 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" +strip-ansi@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" + integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== + dependencies: + ansi-regex "^6.0.1" + strip-bom@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" @@ -8532,6 +8781,11 @@ strip-final-newline@^2.0.0: resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== +strip-final-newline@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-3.0.0.tgz#52894c313fbff318835280aed60ff71ebf12b8fd" + integrity sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw== + strip-json-comments@^3.0.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" @@ -8655,7 +8909,7 @@ through2@^2.0.0, through2@^2.0.1: readable-stream "~2.3.6" xtend "~4.0.1" -through@^2.3.6: +through@^2.3.6, through@^2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= @@ -9331,6 +9585,11 @@ yaml@1.10.2, yaml@^1.10.0, yaml@^1.7.2: resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== +yaml@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.1.1.tgz#1e06fb4ca46e60d9da07e4f786ea370ed3c3cfec" + integrity sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw== + yargs-parser@20.2.9: version "20.2.9" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" From 3ff853234d668110e6fe43280fc22d6804f78cb0 Mon Sep 17 00:00:00 2001 From: Wojciech Lewicki Date: Thu, 14 Jul 2022 16:29:41 +0200 Subject: [PATCH 02/10] chore: merge current main --- .flowconfig | 1 + README.md | 2 +- jest.config.ts | 9 + package.json | 35 +- src/ReactNativeSVG.web.ts | 92 +- src/css.tsx | 514 ++-- src/elements/Shape.tsx | 322 +-- src/lib/Matrix2D.ts | 62 +- src/lib/SvgTouchableMixin.ts | 46 +- src/lib/extract/extractBrush.ts | 17 +- src/lib/extract/extractGradient.ts | 80 +- src/lib/extract/extractLengthList.ts | 13 +- src/lib/extract/extractText.tsx | 193 +- src/lib/extract/extractTransform.ts | 124 +- src/lib/extract/extractViewBox.ts | 50 +- src/xml.tsx | 351 ++- yarn.lock | 3264 +++++++++++++------------- 17 files changed, 2586 insertions(+), 2589 deletions(-) create mode 100644 jest.config.ts diff --git a/.flowconfig b/.flowconfig index 0d2614028..ea77120bf 100644 --- a/.flowconfig +++ b/.flowconfig @@ -1,4 +1,5 @@ [ignore] +.*/node_modules/resolve/test/resolver/malformed_package_json/package.json [include] diff --git a/README.md b/README.md index 260a2fd26..d0fd0d47c 100644 --- a/README.md +++ b/README.md @@ -1110,7 +1110,7 @@ Code explanation: v10 adds experimental support for using masks together with native elements. If you had native elements inside any Svg root before (which was unsupported), -Then your content might change appearance when upgrading, +then your content might change appearance when upgrading, as e.g. transforms and masks now take effect. #### Pattern diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 000000000..cc826318d --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,9 @@ +import { Config } from '@jest/types'; + +const config: Config.InitialOptions = { + testPathIgnorePatterns: ['/node_modules/', '/Example/', '/TestsExample/'], + preset: 'react-native', + verbose: true, +}; + +export default config; diff --git a/package.json b/package.json index 7fb910f25..de8863e56 100644 --- a/package.json +++ b/package.json @@ -60,39 +60,42 @@ "react-native": ">=0.50.0" }, "dependencies": { - "css-select": "^4.2.1", - "css-tree": "^1.0.0-alpha.39" + "css-select": "^5.1.0", + "css-tree": "^1.1.3" }, "devDependencies": { + "@babel/core": "^7.18.2", + "@babel/plugin-syntax-flow": "^7.17.12", + "@babel/plugin-transform-react-jsx": "^7.17.12", "@react-native-community/bob": "^0.9.7", - "@react-native-community/eslint-config": "0.0.7", - "@react-native-community/eslint-plugin": "^1.0.0", + "@react-native-community/eslint-config": "^3.0.2", + "@react-native-community/eslint-plugin": "^1.2.0", "@types/css-tree": "^1.0.3", + "@types/jest": "^27.5.2", + "@types/node": "*", "@types/react": "^17.0.16", "@types/react-native": "^0.63.40", "babel-eslint": "^10.1.0", - "babel-jest": "^25.1.0", + "babel-jest": "^28.1.0", "clang-format": "^1.8.0", - "eslint": "^6.8.0", - "eslint-plugin-flowtype": "^4.6.0", - "eslint-plugin-prettier": "^3.1.2", - "eslint-plugin-react": "^7.18.3", + "eslint": "^8.16.0", + "eslint-plugin-flowtype": "^8.0.3", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-react": "^7.30.0", "flow-bin": "^0.119.1", "flow-typed": "^3.0.0", "flowgen": "^1.10.0", "husky": "^8.0.1", - "jest": "^25.1.0", - "lint-staged": "^13.0.0", + "jest": "^28.1.0", + "lint-staged": "^13.0.3", "pegjs": "^0.10.0", - "prettier": "^1.19.1", + "prettier": "^2.6.2", "react": "^16.13.0", "react-native": "^0.62.3", "react-test-renderer": "^16.13.0", "release-it": "^14.12.5", - "typescript": "^3.8.3" - }, - "jest": { - "preset": "react-native" + "ts-node": "^10.8.0", + "typescript": "^4.7.2" }, "lint-staged": { "{src,Example}/**/*.{js,ts,tsx}": "yarn format", diff --git a/src/ReactNativeSVG.web.ts b/src/ReactNativeSVG.web.ts index 6799725bd..2460e49d5 100644 --- a/src/ReactNativeSVG.web.ts +++ b/src/ReactNativeSVG.web.ts @@ -1,15 +1,16 @@ // @ts-ignore import * as React from 'react'; import { + // @ts-ignore + createElement as cE, GestureResponderEvent, // @ts-ignore unstable_createElement as ucE, - // @ts-ignore - createElement as cE, } from 'react-native'; -import { NumberArray, NumberProp } from './lib/extract/types'; + +import {NumberArray, NumberProp} from './lib/extract/types'; +import {resolve} from './lib/resolve'; import SvgTouchableMixin from './lib/SvgTouchableMixin'; -import { resolve } from './lib/resolve'; const createElement = cE || ucE; @@ -61,7 +62,7 @@ interface BaseProps { } const hasTouchableProperty = (props: BaseProps) => - props.onPress || props.onPressIn || props.onPressOut || props.onLongPress; + props.onPress || props.onPressIn || props.onPressOut || props.onLongPress; /** * `react-native-svg` supports additional props that aren't defined in the spec. @@ -73,9 +74,9 @@ const hasTouchableProperty = (props: BaseProps) => * @private */ const prepare = ( - self: WebShape, - props = self.props, -) => { + self: WebShape, + props = self.props, + ) => { const { translate, scale, @@ -105,18 +106,16 @@ const prepare = ( style?: {}; ref?: {}; } = { - ...(hasTouchableProperty(props) - ? { - onStartShouldSetResponder: - self.touchableHandleStartShouldSetResponder, - onResponderTerminationRequest: - self.touchableHandleResponderTerminationRequest, - onResponderGrant: self.touchableHandleResponderGrant, - onResponderMove: self.touchableHandleResponderMove, - onResponderRelease: self.touchableHandleResponderRelease, - onResponderTerminate: self.touchableHandleResponderTerminate, - } - : null), + ...(hasTouchableProperty(props) ? { + onStartShouldSetResponder : self.touchableHandleStartShouldSetResponder, + onResponderTerminationRequest : + self.touchableHandleResponderTerminationRequest, + onResponderGrant : self.touchableHandleResponderGrant, + onResponderMove : self.touchableHandleResponderMove, + onResponderRelease : self.touchableHandleResponderRelease, + onResponderTerminate : self.touchableHandleResponderTerminate, + } + : null), ...rest, }; @@ -131,7 +130,8 @@ const prepare = ( if (scale != null) { transform.push(`scale(${scale})`); } - // rotation maps to rotate, not to collide with the text rotate attribute (which acts per glyph rather than block) + // rotation maps to rotate, not to collide with the text rotate attribute + // (which acts per glyph rather than block) if (rotation != null) { transform.push(`rotate(${rotation})`); } @@ -142,7 +142,7 @@ const prepare = ( transform.push(`skewY(${skewY})`); } if (originX != null || originY != null) { - transform.push(`translate(${-originX || 0}, ${-originY || 0})`); + transform.push(`translate(${- originX || 0}, ${- originY || 0})`); } if (transform.length) { @@ -191,23 +191,23 @@ const getBoundingClientRect = (node: SVGElement) => { }; const measureLayout = ( - node: SVGElement, - callback: ( - x: number, - y: number, - width: number, - height: number, - left: number, - top: number, - ) => void, -) => { + node: SVGElement, + callback: ( + x: number, + y: number, + width: number, + height: number, + left: number, + top: number, + ) => void, + ) => { // @ts-ignore const relativeNode = node && node.parentNode; if (relativeNode) { setTimeout(() => { // @ts-ignore const relativeRect = getBoundingClientRect(relativeNode); - const { height, left, top, width } = getBoundingClientRect(node); + const {height, left, top, width} = getBoundingClientRect(node); const x = left - relativeRect.left; const y = top - relativeRect.top; callback(x, y, width, height, left, top); @@ -227,24 +227,25 @@ function remeasure() { export class WebShape< P extends BaseProps = BaseProps, - C = {} + C = {}, > extends React.Component { [x: string]: unknown; _remeasureMetricsOnActivation: () => void; touchableHandleStartShouldSetResponder?: ( - e: GestureResponderEvent, - ) => boolean; + e: GestureResponderEvent, + ) => boolean; touchableHandleResponderMove?: (e: GestureResponderEvent) => void; touchableHandleResponderGrant?: (e: GestureResponderEvent) => void; touchableHandleResponderRelease?: (e: GestureResponderEvent) => void; touchableHandleResponderTerminate?: (e: GestureResponderEvent) => void; touchableHandleResponderTerminationRequest?: ( - e: GestureResponderEvent, - ) => boolean; + e: GestureResponderEvent, + ) => boolean; constructor(props: P, context: C) { super(props, context); - // Do not attach touchable mixin handlers if SVG element doesn't have a touchable prop + // Do not attach touchable mixin handlers if SVG element doesn't have a + // touchable prop if (hasTouchableProperty(props)) { SvgTouchableMixin(this); } @@ -277,15 +278,14 @@ export class Ellipse extends WebShape { } } -export class G extends WebShape< - BaseProps & { - x?: NumberProp; - y?: NumberProp; - translate?: string; - } +export class G extends WebShape < BaseProps&{ + x?: NumberProp; + y?: NumberProp; + translate?: string; +} > { render(): JSX.Element { - const { x, y, ...rest } = this.props; + const {x, y, ...rest} = this.props; if ((x || y) && !rest.translate) { rest.translate = `${x || 0}, ${y || 0}`; diff --git a/src/css.tsx b/src/css.tsx index a7fdf5433..26e7cc22b 100644 --- a/src/css.tsx +++ b/src/css.tsx @@ -1,33 +1,21 @@ -import React, { Component, useEffect, useMemo, useState } from 'react'; -import { - camelCase, - err, - fetchText, - JsxAST, - Middleware, - parse, - Styles, - SvgAst, - UriProps, - UriState, - XmlAST, - XmlProps, - XmlState, +import React, {Component, useEffect, useMemo, useState } from 'react'; +import{ + camelCase, + err, + fetchText, + JsxAST, + Middleware, + parse, + Styles, + SvgAst, + UriProps, + UriState, + XmlAST, + XmlProps, + XmlState, } from './xml'; -import csstree, { - Atrule, - AtrulePrelude, - CssNode, - Declaration, - DeclarationList, - List, - ListItem, - PseudoClassSelector, - Rule, - Selector, - SelectorList, -} from 'css-tree'; -import cssSelect, { Options } from 'css-select'; +import csstree, {Atrule, AtrulePrelude, CssNode, Declaration, DeclarationList, List, ListItem, PseudoClassSelector, Rule, Selector, SelectorList, } from 'css-tree'; +import cssSelect, {Options } from 'css-select'; /* * Style element inlining experiment based on SVGO @@ -39,50 +27,49 @@ import cssSelect, { Options } from 'css-select'; */ // is the node a tag? // isTag: ( node:Node ) => isTag:Boolean -function isTag(node: XmlAST | string): node is XmlAST { - return typeof node === 'object'; +function isTag(node : XmlAST | string) : node is XmlAST { + return typeof node == = 'object'; } // get the parent of the node // getParent: ( node:Node ) => parentNode:Node // returns null when no parent exists -function getParent(node: XmlAST | string): XmlAST { - return ((typeof node === 'object' && node.parent) || null) as XmlAST; +function getParent(node : XmlAST | string) : XmlAST { + return ((typeof node == = 'object' && node.parent) || null) as XmlAST; } // get the node's children // getChildren: ( node:Node ) => children:[Node] -function getChildren(node: XmlAST | string): Array { - return (typeof node === 'object' && node.children) || []; +function getChildren(node : XmlAST | string) : Array { + return (typeof node == = 'object' && node.children) || []; } // get the name of the tag' // getName: ( elem:ElementNode ) => tagName:String -function getName(elem: XmlAST): string { +function getName(elem : XmlAST) : string { return elem.tag; } // get the text content of the node, and its children if it has any // getText: ( node:Node ) => text:String // returns empty string when there is no text -function getText(_node: XmlAST | string): string { +function getText(_node : XmlAST | string) : string { return ''; } // get the attribute value // getAttributeValue: ( elem:ElementNode, name:String ) => value:String // returns null when attribute doesn't exist -function getAttributeValue(elem: XmlAST, name: string): string { +function getAttributeValue(elem : XmlAST, name : string) : string { return (elem.props[name] || null) as string; } // takes an array of nodes, and removes any duplicates, as well as any nodes // whose ancestors are also in the array -function removeSubsets(nodes: Array): Array { - let idx = nodes.length, - node, - ancestor, - replace; +function removeSubsets(nodes + : Array) + : Array { + let idx = nodes.length, node, ancestor, replace; // Check if each node (or one of its ancestors) is already contained in the // array. @@ -99,7 +86,7 @@ function removeSubsets(nodes: Array): Array { nodes.splice(idx, 1); break; } - ancestor = (typeof ancestor === 'object' && ancestor.parent) || null; + ancestor = (typeof ancestor == = 'object' && ancestor.parent) || null; } // If the node has been found to be unique, re-insert it. @@ -112,47 +99,49 @@ function removeSubsets(nodes: Array): Array { } // does at least one of passed element nodes pass the test predicate? -function existsOne( - predicate: (v: XmlAST) => boolean, - elems: Array, -): boolean { +function existsOne(predicate + : (v + : XmlAST) = > boolean, + elems + : Array, ) + : boolean { return elems.some( - elem => - typeof elem === 'object' && - (predicate(elem) || existsOne(predicate, elem.children)), - ); + (elem) = > typeof elem == = 'object' && + (predicate(elem) || existsOne(predicate, elem.children)), ); } /* get the siblings of the node. Note that unlike jQuery's `siblings` method, this is expected to include the current node as well */ -function getSiblings(node: XmlAST | string): Array { - const parent = typeof node === 'object' && node.parent; +function getSiblings(node : XmlAST | string) : Array { + const parent = typeof node == = 'object' && node.parent; return (parent && parent.children) || []; } // does the element have the named attribute? -function hasAttrib(elem: XmlAST, name: string): boolean { +function hasAttrib(elem : XmlAST, name : string) : boolean { return elem.props.hasOwnProperty(name); } // finds the first node in the array that matches the test predicate, or one // of its children -function findOne( - predicate: (v: XmlAST) => boolean, - elems: Array, -): XmlAST | null { - let elem: XmlAST | null = null; +function findOne(predicate + : (v + : XmlAST) = > boolean, + elems + : Array, ) + : XmlAST | null { + let elem : XmlAST | null = null; for (let i = 0, l = elems.length; i < l && !elem; i++) { const node = elems[i]; - if (typeof node === 'string') { + if (typeof node == = 'string') { } else if (predicate(node)) { elem = node; } else { - const { children } = node; - if (children.length !== 0) { + const {children} = node; + if (children.length != = 0) { elem = findOne(predicate, children); } } @@ -163,21 +152,23 @@ function findOne( // finds all of the element nodes in the array that match the test predicate, // as well as any of their children that match it -function findAll( - predicate: (v: XmlAST) => boolean, - nodes: Array, - result: Array = [], -): Array { +function findAll(predicate + : (v + : XmlAST) = > boolean, + nodes + : Array, result + : Array = [], ) + : Array { for (let i = 0, j = nodes.length; i < j; i++) { const node = nodes[i]; - if (typeof node !== 'object') { + if (typeof node != = 'object') { continue; } if (predicate(node)) { result.push(node); } - const { children } = node; - if (children.length !== 0) { + const {children} = node; + if (children.length != = 0) { findAll(predicate, children, result); } } @@ -185,35 +176,35 @@ function findAll( return result; } -const cssSelectOpts: Options = { - xmlMode: true, - adapter: { - removeSubsets, - existsOne, - getSiblings, - hasAttrib, - findOne, - findAll, - isTag, - getParent, - getChildren, - getName, - getText, - getAttributeValue, +const cssSelectOpts : Options = { + xmlMode : true, + adapter : { + removeSubsets, + existsOne, + getSiblings, + hasAttrib, + findOne, + findAll, + isTag, + getParent, + getChildren, + getName, + getText, + getAttributeValue, }, }; -type FlatPseudoSelector = { - item: ListItem; - list: List; -}; +type FlatPseudoSelector = {item : ListItem; +list : List; +} +; type FlatPseudoSelectorList = FlatPseudoSelector[]; -type FlatSelector = { - item: ListItem; - atrule: Atrule | null; - rule: CssNode; - pseudos: FlatPseudoSelectorList; -}; +type FlatSelector = {item : ListItem; +atrule : Atrule | null; +rule : CssNode; +pseudos : FlatPseudoSelectorList; +} +; type FlatSelectorList = FlatSelector[]; /** @@ -222,38 +213,37 @@ type FlatSelectorList = FlatSelector[]; * @param {Object} cssAst css-tree AST to flatten * @param {Array} selectors */ -function flattenToSelectors(cssAst: CssNode, selectors: FlatSelectorList) { +function flattenToSelectors(cssAst : CssNode, selectors : FlatSelectorList) { csstree.walk(cssAst, { visit: 'Rule', enter(rule: CssNode) { const { type, prelude } = rule as Rule; if (type !== 'Rule') { - return; + return; } const atrule = this.atrule; (prelude as SelectorList).children.each((node, item) => { - const { children } = node as Selector; - const pseudos: FlatPseudoSelectorList = []; - selectors.push({ - item, - atrule, - rule, - pseudos, - }); - children.each(({ type: childType }, pseudoItem, list) => { - if ( - childType === 'PseudoClassSelector' || - childType === 'PseudoElementSelector' - ) { - pseudos.push({ - item: pseudoItem, - list, - }); - } + const {children} = node as Selector; + const pseudos : FlatPseudoSelectorList = []; + selectors.push({ + item, + atrule, + rule, + pseudos, + }); + children.each(({type : childType}, pseudoItem, list) = > { + if (childType == = 'PseudoClassSelector' || + childType == = 'PseudoElementSelector') { + pseudos.push({ + item : pseudoItem, + list, }); + } + }); }); - }, - }); +} +, +}); } /** @@ -262,62 +252,62 @@ function flattenToSelectors(cssAst: CssNode, selectors: FlatSelectorList) { * @param {Array} selectors to filter * @return {Array} Filtered selectors that match the passed media queries */ -function filterByMqs(selectors: FlatSelectorList) { - return selectors.filter(({ atrule }) => { - if (atrule === null) { +function filterByMqs(selectors : FlatSelectorList) { + return selectors.filter(({atrule}) = > { + if (atrule == = null) { return true; } - const { name, prelude } = atrule; + const {name, prelude} = atrule; const atPrelude = prelude as AtrulePrelude; const first = atPrelude && atPrelude.children.first(); - const mq = first && first.type === 'MediaQueryList'; + const mq = first &&first.type == = 'MediaQueryList'; const query = mq ? csstree.generate(atPrelude) : name; return useMqs.includes(query); }); } -// useMqs Array with strings of media queries that should pass ( ) -const useMqs = ['', 'screen']; +// useMqs Array with strings of media queries that should pass ( +// ) +const useMqs = ['', 'screen' ]; /** * Filter selectors by the pseudo-elements and/or -classes they contain. * * @param {Array} selectors to filter - * @return {Array} Filtered selectors that match the passed pseudo-elements and/or -classes + * @return {Array} Filtered selectors that match the passed pseudo-elements + * and/or -classes */ -function filterByPseudos(selectors: FlatSelectorList) { - return selectors.filter(({ pseudos }) => - usePseudos.includes( - csstree.generate({ - type: 'Selector', - children: new List().fromArray( - pseudos.map(pseudo => pseudo.item.data), - ), - }), - ), - ); -} -// usePseudos Array with strings of single or sequence of pseudo-elements and/or -classes that should pass +function filterByPseudos(selectors : FlatSelectorList) { + return selectors.filter(({pseudos}) = > usePseudos.includes(csstree.generate({ + type : 'Selector', + children : new List().fromArray( + pseudos.map((pseudo) = > pseudo.item.data), ), + }), ), ); +} +// usePseudos Array with strings of single or sequence of pseudo-elements and/or +// -classes that should pass const usePseudos = ['']; /** - * Remove pseudo-elements and/or -classes from the selectors for proper matching. + * Remove pseudo-elements and/or -classes from the selectors for proper + * matching. * * @param {Array} selectors to clean * @return {Array} Selectors without pseudo-elements and/or -classes */ -function cleanPseudos(selectors: FlatSelectorList) { - selectors.forEach(({ pseudos }) => - pseudos.forEach(pseudo => pseudo.list.remove(pseudo.item)), - ); +function cleanPseudos(selectors : FlatSelectorList) { + selectors.forEach( + ({pseudos}) = + > pseudos.forEach((pseudo) = > pseudo.list.remove(pseudo.item)), ); } -type Specificity = [number, number, number]; -function specificity(selector: Selector): Specificity { +type Specificity = [ number, number, number ]; +function specificity(selector : Selector) : Specificity { let A = 0; let B = 0; let C = 0; - selector.children.each(function walk(node: CssNode) { + selector.children.each(function walk(node + : CssNode) { switch (node.type) { case 'SelectorList': case 'Selector': @@ -337,7 +327,7 @@ function specificity(selector: Selector): Specificity { switch (node.name.toLowerCase()) { case 'not': const children = (node as PseudoClassSelector).children; - children && children.each(walk); + children &&children.each(walk); break; case 'before': @@ -347,7 +337,8 @@ function specificity(selector: Selector): Specificity { C++; break; - // TODO: support for :nth-*(.. of ), :matches(), :has() + // TODO: support for :nth-*(.. of ), :matches(), + // :has() default: B++; @@ -360,29 +351,31 @@ function specificity(selector: Selector): Specificity { case 'TypeSelector': // ignore universal selector - const { name } = node; - if (name.charAt(name.length - 1) !== '*') { + const {name} = node; + if (name.charAt(name.length - 1) != = '*') { C++; } break; } }); - return [A, B, C]; + return [ A, B, C ]; } /** * Compares two selector specificities. - * extracted from https://github.com/keeganstreet/specificity/blob/master/specificity.js#L211 + * extracted from + * https://github.com/keeganstreet/specificity/blob/master/specificity.js#L211 * * @param {Array} aSpecificity Specificity of selector A * @param {Array} bSpecificity Specificity of selector B - * @return {Number} Score of selector specificity A compared to selector specificity B + * @return {Number} Score of selector specificity A compared to selector + * specificity B */ -function compareSpecificity( - aSpecificity: Specificity, - bSpecificity: Specificity, -): number { +function compareSpecificity(aSpecificity + : Specificity, bSpecificity + : Specificity, ) + : number { for (let i = 0; i < 4; i += 1) { if (aSpecificity[i] < bSpecificity[i]) { return -1; @@ -393,14 +386,14 @@ function compareSpecificity( return 0; } -type Spec = { - selector: FlatSelector; - specificity: Specificity; -}; -function selectorWithSpecificity(selector: FlatSelector): Spec { +type Spec = {selector : FlatSelector; +specificity : Specificity; +} +; +function selectorWithSpecificity(selector : FlatSelector) : Spec { return { selector, - specificity: specificity(selector.item.data as Selector), + specificity : specificity(selector.item.data as Selector), }; } @@ -411,12 +404,12 @@ function selectorWithSpecificity(selector: FlatSelector): Spec { * @param {Object} b Simple selector B * @return {Number} Score of selector A compared to selector B */ -function bySelectorSpecificity(a: Spec, b: Spec): number { +function bySelectorSpecificity(a : Spec, b : Spec) : number { return compareSpecificity(a.specificity, b.specificity); } // Run a single pass with the given chunk size. -function pass(arr: Spec[], len: number, chk: number, result: Spec[]) { +function pass(arr : Spec[], len : number, chk : number, result : Spec[]) { // Step size / double chunk size. const dbl = chk * 2; // Bounds of the left and right chunks. @@ -466,7 +459,7 @@ function pass(arr: Spec[], len: number, chk: number, result: Spec[]) { // Execute the sort using the input array and a second buffer as work space. // Returns one of those two, containing the final result. -function exec(arr: Spec[], len: number): Spec[] { +function exec(arr : Spec[], len : number) : Spec[] { // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. // Chunks are the size of the left or right hand in merge sort. // Stop when the left-hand covers all of the array. @@ -486,22 +479,22 @@ function exec(arr: Spec[], len: number): Spec[] { * @param {Array} selectors to be sorted * @return {Array} Stable sorted selectors */ -function sortSelectors(selectors: FlatSelectorList) { +function sortSelectors(selectors : FlatSelectorList) { // Short-circuit when there's nothing to sort. const len = selectors.length; if (len <= 1) { return selectors; } const specs = selectors.map(selectorWithSpecificity); - return exec(specs, len).map(s => s.selector); + return exec(specs, len).map((s) = > s.selector); } const declarationParseProps = { - context: 'declarationList', - parseValue: false, + context : 'declarationList', + parseValue : false, }; -function CSSStyleDeclaration(ast: XmlAST) { - const { props, styles } = ast; +function CSSStyleDeclaration(ast : XmlAST) { + const {props, styles} = ast; if (!props.style) { props.style = {}; } @@ -509,42 +502,38 @@ function CSSStyleDeclaration(ast: XmlAST) { const priority = new Map(); ast.style = style; ast.priority = priority; - if (!styles || styles.length === 0) { + if (!styles || styles.length == = 0) { return; } try { - const declarations = csstree.parse( - styles, - declarationParseProps, - ) as DeclarationList; - declarations.children.each(node => { + const declarations = + csstree.parse(styles, declarationParseProps, ) as DeclarationList; + declarations.children.each((node) = > { try { - const { property, value, important } = node as Declaration; + const {property, value, important} = node as Declaration; const name = property.trim(); priority.set(name, important); style[camelCase(name)] = csstree.generate(value).trim(); } catch (styleError) { - if (styleError.message !== 'Unknown node type: undefined') { + if (styleError instanceof + Error &&styleError.message != = 'Unknown node type: undefined') { console.warn( - "Warning: Parse error when parsing inline styles, style properties of this element cannot be used. The raw styles can still be get/set using .attr('style').value. Error details: " + - styleError, - ); + "Warning: Parse error when parsing inline styles, style properties of this element cannot be used. The raw styles can still be get/set using .attr('style').value. Error details: " + + styleError, ); } } }); } catch (parseError) { console.warn( - "Warning: Parse error when parsing inline styles, style properties of this element cannot be used. The raw styles can still be get/set using .attr('style').value. Error details: " + - parseError, - ); + "Warning: Parse error when parsing inline styles, style properties of this element cannot be used. The raw styles can still be get/set using .attr('style').value. Error details: " + + parseError, ); } } interface StyledAST extends XmlAST { - style: Styles; - priority: Map; -} -function initStyle(selectedEl: XmlAST): StyledAST { + style : Styles; + priority : Map; +} function initStyle(selectedEl : XmlAST) : StyledAST { if (!selectedEl.style) { CSSStyleDeclaration(selectedEl); } @@ -557,15 +546,16 @@ function initStyle(selectedEl: XmlAST): StyledAST { * @param elemName * @return {?Object} */ -function closestElem(node: XmlAST, elemName: string) { - let elem: XmlAST | null = node; - while ((elem = elem.parent) && elem.tag !== elemName) {} +function closestElem(node : XmlAST, elemName : string) { + let elem : XmlAST | null = node; + while ((elem = elem.parent) &&elem.tag != = elemName) { + } return elem; } const parseProps = { - parseValue: false, - parseCustomProperty: false, + parseValue : false, + parseCustomProperty : false, }; /** @@ -585,21 +575,20 @@ const parseProps = { * @author strarsis * @author modified by: msand */ -export const inlineStyles: Middleware = function inlineStyles( - document: XmlAST, -) { +export const inlineStyles : Middleware = function inlineStyles(document + : XmlAST, ) { // collect