From b5a4d9d9c8dbd28f5047dea449f2b58add2b5ed0 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 23 Nov 2021 16:23:54 +0800 Subject: [PATCH] chore: add sass-loader --- .eslintignore | 1 + packages/vue-cli-plugin-uni/lib/env.js | 4 +- .../packages/sass-loader/CHANGELOG.md | 436 +++++ .../packages/sass-loader/LICENSE | 20 + .../packages/sass-loader/README.md | 606 +++++++ .../packages/sass-loader/dist/SassError.js | 33 + .../packages/sass-loader/dist/cjs.js | 5 + .../dist/getDefaultSassImplementation.js | 28 + ...getRenderFunctionFromSassImplementation.js | 39 + .../sass-loader/dist/getSassImplementation.js | 56 + .../sass-loader/dist/getSassOptions.js | 116 ++ .../sass-loader/dist/importsToResolve.js | 88 + .../packages/sass-loader/dist/index.js | 114 ++ .../packages/sass-loader/dist/options.json | 41 + .../sass-loader/dist/proxyCustomImporters.js | 31 + .../sass-loader/dist/webpackImporter.js | 75 + .../node_modules/schema-utils/CHANGELOG.md | 279 +++ .../node_modules/schema-utils/LICENSE | 20 + .../node_modules/schema-utils/README.md | 276 +++ .../declarations/ValidationError.d.ts | 88 + .../schema-utils/declarations/index.d.ts | 2 + .../declarations/keywords/absolutePath.d.ts | 12 + .../schema-utils/declarations/util/Range.d.ts | 82 + .../schema-utils/declarations/util/hints.d.ts | 6 + .../schema-utils/declarations/validate.d.ts | 44 + .../schema-utils/dist/ValidationError.js | 1261 +++++++++++++ .../node_modules/schema-utils/dist/index.js | 5 + .../dist/keywords/absolutePath.js | 93 + .../schema-utils/dist/util/Range.js | 163 ++ .../schema-utils/dist/util/hints.js | 105 ++ .../schema-utils/dist/validate.js | 160 ++ .../node_modules/schema-utils/package.json | 109 ++ .../node_modules/semver/CHANGELOG.md | 70 + .../sass-loader/node_modules/semver/LICENSE | 15 + .../sass-loader/node_modules/semver/README.md | 443 +++++ .../node_modules/semver/bin/semver.js | 174 ++ .../node_modules/semver/package.json | 60 + .../sass-loader/node_modules/semver/range.bnf | 16 + .../sass-loader/node_modules/semver/semver.js | 1596 +++++++++++++++++ .../packages/sass-loader/package.json | 144 ++ 40 files changed, 6915 insertions(+), 1 deletion(-) create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/CHANGELOG.md create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/LICENSE create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/README.md create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/SassError.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/getDefaultSassImplementation.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/getRenderFunctionFromSassImplementation.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/getSassImplementation.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/getSassOptions.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/importsToResolve.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/index.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/options.json create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/proxyCustomImporters.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/dist/webpackImporter.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/CHANGELOG.md create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/LICENSE create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/README.md create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/ValidationError.d.ts create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/index.d.ts create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/keywords/absolutePath.d.ts create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/util/Range.d.ts create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/util/hints.d.ts create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/validate.d.ts create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/ValidationError.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/index.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/keywords/absolutePath.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/util/Range.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/util/hints.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/validate.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/package.json create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/CHANGELOG.md create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/LICENSE create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/README.md create mode 100755 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/bin/semver.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/package.json create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/range.bnf create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/semver.js create mode 100644 packages/vue-cli-plugin-uni/packages/sass-loader/package.json diff --git a/.eslintignore b/.eslintignore index aea9a83fb..c548fb5a5 100644 --- a/.eslintignore +++ b/.eslintignore @@ -25,6 +25,7 @@ packages/*/packages/uni-cloud packages/*/packages/vue-loader packages/*/packages/vue-template-compiler packages/*/packages/webpack-preprocess-loader/preprocess +packages/*/packages/sass-loader packages/*/packages/vuex packages/*/packages/vuex3 packages/*/template/**/* diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index d51237e08..70cbc481e 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -401,7 +401,9 @@ moduleAlias.addAlias('vue-template-compiler', '@dcloudio/vue-cli-plugin-uni/pack moduleAlias.addAlias('@megalo/template-compiler', '@dcloudio/vue-cli-plugin-uni/packages/@megalo/template-compiler') moduleAlias.addAlias('mpvue-template-compiler', '@dcloudio/vue-cli-plugin-uni/packages/mpvue-template-compiler') // vue-loader -moduleAlias.addAlias('vue-loader', '@dcloudio/vue-cli-plugin-uni/packages/vue-loader') +moduleAlias.addAlias('vue-loader', '@dcloudio/vue-cli-plugin-uni/packages/vue-loader') +// sass-loader +moduleAlias.addAlias('sass-loader', '@dcloudio/vue-cli-plugin-uni/packages/sass-loader') if (process.env.UNI_USING_V3 && process.env.UNI_PLATFORM === 'app-plus') { moduleAlias.addAlias('./runtime/getUrl.js', '@dcloudio/vue-cli-plugin-uni/lib/app-plus/getUrl.js') diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/CHANGELOG.md b/packages/vue-cli-plugin-uni/packages/sass-loader/CHANGELOG.md new file mode 100644 index 000000000..1d2d17c01 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/CHANGELOG.md @@ -0,0 +1,436 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +### [8.0.2](https://github.com/webpack-contrib/sass-loader/compare/v8.0.1...v8.0.2) (2020-01-13) + + +### Bug Fixes + +* compatibility with node@8 ([#798](https://github.com/webpack-contrib/sass-loader/issues/798)) ([6f3852f](https://github.com/webpack-contrib/sass-loader/commit/6f3852f7d393dd0bc8f8d264d81ecc941bc72511)) + +### [8.0.1](https://github.com/webpack-contrib/sass-loader/compare/v8.0.0...v8.0.1) (2020-01-10) + + +### Bug Fixes + +* support webpack@5 ([#794](https://github.com/webpack-contrib/sass-loader/issues/794)) ([6c59e37](https://github.com/webpack-contrib/sass-loader/commit/6c59e37e3f67668d7a3908444ddfc0176bc5601f)) + +## [8.0.0](https://github.com/webpack-contrib/sass-loader/compare/v7.3.1...v8.0.0) (2019-08-29) + + +### ⚠ BREAKING CHANGES + +* minimum required `webpack` version is `4.36.0` +* minimum required `node.js` version is `8.9.0` +* move all sass (`includePaths`, `importer`, `functions`, `outputStyle`) options to the `sassOptions` option. The `functions` option can't be used as `Function`, you should use `sassOption` as `Function` to achieve this. +* the `data` option was renamed to the `prependData` option +* default value of the `sourceMap` option depends on the `devtool` value (`eval`/`false` values don't enable source map generation) + + +### Features + +* automatically use the `fibers` package if it is possible ([#744](https://github.com/webpack-contrib/sass-loader/issues/744)) ([96184e1](https://github.com/webpack-contrib/sass-loader/commit/96184e1)) +* source map generation depends on the `devtool` option ([#743](https://github.com/webpack-contrib/sass-loader/issues/743)) ([fcea88e](https://github.com/webpack-contrib/sass-loader/commit/fcea88e)) +* validate loader options ([#737](https://github.com/webpack-contrib/sass-loader/issues/737)) ([7b543fc](https://github.com/webpack-contrib/sass-loader/commit/7b543fc)) +* reworked error handling from `node-sass`/`sass` +* improve resolution for `@import` (including support `_index` and `index` files in a directory) + +### Bug Fixes + +* compatibility with `pnp` + + +### [7.3.1](https://github.com/webpack-contrib/sass-loader/compare/v7.3.0...v7.3.1) (2019-08-20) + + +### Bug Fixes + +* minimum `node` version in `package.json` ([#733](https://github.com/webpack-contrib/sass-loader/issues/733)) ([1175920](https://github.com/webpack-contrib/sass-loader/commit/1175920)) + +## [7.3.0](https://github.com/webpack-contrib/sass-loader/compare/v7.2.0...v7.3.0) (2019-08-20) + + +### Bug Fixes + +* handle module import ending `/` as module ([#728](https://github.com/webpack-contrib/sass-loader/issues/728)) ([997a255](https://github.com/webpack-contrib/sass-loader/commit/997a255)) +* resolution algorithm ([#720](https://github.com/webpack-contrib/sass-loader/issues/720)) ([0e94940](https://github.com/webpack-contrib/sass-loader/commit/0e94940)) +* use "compressed" output when mode is "production" ([#723](https://github.com/webpack-contrib/sass-loader/issues/723)) ([b2af379](https://github.com/webpack-contrib/sass-loader/commit/b2af379)) + + +### Features + +* `webpackImporter` option ([#732](https://github.com/webpack-contrib/sass-loader/issues/732)) ([6f4ea37](https://github.com/webpack-contrib/sass-loader/commit/6f4ea37)) + + +# [7.2.0](https://github.com/webpack-contrib/sass-loader/compare/v7.1.0...v7.2.0) (2019-08-08) + + +### Bug Fixes + +* better handle stdin in sources ([#681](https://github.com/webpack-contrib/sass-loader/issues/681)) ([e279f2a](https://github.com/webpack-contrib/sass-loader/commit/e279f2a)) +* prefer `sass`/`scss`/`css` extensions ([#711](https://github.com/webpack-contrib/sass-loader/issues/711)) ([6fc9d4e](https://github.com/webpack-contrib/sass-loader/commit/6fc9d4e)) +* relax node engine ([#708](https://github.com/webpack-contrib/sass-loader/issues/708)) ([2a51502](https://github.com/webpack-contrib/sass-loader/commit/2a51502)) + + +### Features + +* allow passing `functions` option as function ([#651](https://github.com/webpack-contrib/sass-loader/issues/651)) ([6c9654d](https://github.com/webpack-contrib/sass-loader/commit/6c9654d)) +* support `data` as `Function` ([#648](https://github.com/webpack-contrib/sass-loader/issues/648)) ([aa64e1b](https://github.com/webpack-contrib/sass-loader/commit/aa64e1b)) +* support `sass` and `style` fields in `package.json` ([#647](https://github.com/webpack-contrib/sass-loader/issues/647)) ([a8709c9](https://github.com/webpack-contrib/sass-loader/commit/a8709c9)) +* support auto resolving `dart-sass` ([ff90dd6](https://github.com/webpack-contrib/sass-loader/commit/ff90dd6)) + + + + +# [7.1.0](https://github.com/webpack-contrib/sass-loader/compare/v7.0.3...v7.1.0) (2018-08-01) + + +### Features + +* Make this package implementation-agnostic (#573) ([bed9fb5](https://github.com/webpack-contrib/sass-loader/commit/bed9fb5)), closes [#435](https://github.com/webpack-contrib/sass-loader/issues/435) + + + + +## [7.0.3](https://github.com/webpack-contrib/sass-loader/compare/v7.0.2...v7.0.3) (2018-06-05) + + +### Bug Fixes + +* Bare imports not working sometimes (#579) ([c348281](https://github.com/webpack-contrib/sass-loader/commit/c348281)), closes [#566](https://github.com/webpack-contrib/sass-loader/issues/566) + + + + +## [7.0.2](https://github.com/webpack-contrib/sass-loader/compare/v7.0.1...v7.0.2) (2018-06-02) + + +### Bug Fixes + +* Errors being swallowed when trying to load node-sass (#576) ([6dfb274](https://github.com/webpack-contrib/sass-loader/commit/6dfb274)), closes [#563](https://github.com/webpack-contrib/sass-loader/issues/563) +* Report error to user for problems loading node-sass (#562) ([2529c07](https://github.com/webpack-contrib/sass-loader/commit/2529c07)) + + + + +## [7.0.1](https://github.com/webpack-contrib/sass-loader/compare/v7.0.0...v7.0.1) (2018-04-13) + + +### Bug Fixes + +* Wrong import precedence (#557) ([f4eeff1](https://github.com/webpack-contrib/sass-loader/commit/f4eeff1)) + + + + +# [7.0.0](https://github.com/webpack-contrib/sass-loader/compare/v6.0.7...v7.0.0) (2018-04-13) + + +### Features + +* Refactor resolving and simplify webpack config aliases (#479) ([e0fde1a](https://github.com/webpack-contrib/sass-loader/commit/e0fde1a)) +* Remove `node-sass` from `peerDependencies` (#533) ([6439cef](https://github.com/webpack-contrib/sass-loader/commit/6439cef)) + + +### BREAKING CHANGES + +* Drop official node 4 support +* This slightly changes the resolving algorithm. Should not break in normal usage, but might break in complex configurations. +* The sass-loader throws an error at runtime now and refuses to compile if the peer dependency is wrong. This could break applications where npm's peer dependency warning was just ignored. + + + + +## [6.0.7](https://github.com/webpack-contrib/sass-loader/compare/v6.0.6...v6.0.7) (2018-03-03) + + +### Bug Fixes + +* **package:** add `webpack >= v4.0.0` (`peerDependencies`) ([#541](https://github.com/webpack-contrib/sass-loader/issues/541)) ([620bdd4](https://github.com/webpack-contrib/sass-loader/commit/620bdd4)) + + +### Performance Improvements + +* use `neo-async` instead `async` ([#538](https://github.com/webpack-contrib/sass-loader/issues/538)) ([fab89dc](https://github.com/webpack-contrib/sass-loader/commit/fab89dc)) + + + + +## [6.0.6](https://github.com/webpack-contrib/sass-loader/compare/v6.0.5...v6.0.6) (2017-06-14) + +### Chore + +* Adds Webpack 3.x version range to peerDependencies + + + +# [6.0.5](https://github.com/webpack-contrib/sass-loader/compare/v6.0.5...v6.0.4) (2017-05-10) + +### Bug Fixes + +* importing file directly from scoped npm package [#450](https://github.com/webpack-contrib/sass-loader/pull/450) ([5d06e9d](https://github.com/webpack-contrib/sass-loader/commit/5d06e9d)) + + + +# [6.0.4](https://github.com/webpack-contrib/sass-loader/compare/v6.0.4...v6.0.3) (2017-05-09) + +### Bug Fixes + +* fix: Resolving of scoped npm packages [#447](https://github.com/webpack-contrib/sass-loader/pull/447) + + + +# [6.0.3](https://github.com/webpack-contrib/sass-loader/compare/v6.0.3...v6.0.2) (2017-03-07) + +### Bug Fixes + +* Fix regression with empty files [#398](https://github.com/webpack-contrib/sass-loader/pull/398) + + +### Chore + +* Reduce npm package size by using the [files](https://docs.npmjs.com/files/package.json#files) property in the `package.json` + + + +# [6.0.2](https://github.com/webpack-contrib/sass-loader/compare/v6.0.2...v6.0.1) (2017-02-21) + +### Chore + +* Update dependencies [#383](https://github.com/webpack-contrib/sass-loader/pull/383) + + + +# [6.0.1](https://github.com/webpack-contrib/sass-loader/compare/v6.0.1...v6.0.0) (2017-02-17) + +### Bug Fixes + +* Fix source maps in certain CWDs. [#377](https://github.com/webpack-contrib/sass-loader/pull/377) + + + +# [6.0.0](https://github.com/webpack-contrib/sass-loader/compare/v6.0.0...v5.0.1) (2017-02-13) + +### Bug Fixes + +* Improve source map support. [#374](https://github.com/webpack-contrib/sass-loader/issues/374) + + +### BREAKING CHANGES + +* This is breaking for the resolve-url-loader + + + +# [5.0.1](https://github.com/webpack-contrib/sass-loader/compare/v5.0.1...v5.0.0) (2017-02-13) + +### Bug Fixes + +* Fix bug where multiple compilations interfered with each other. [#369](https://github.com/webpack-contrib/sass-loader/pull/369) + + + +# [5.0.0](https://github.com/webpack-contrib/sass-loader/compare/v5.0.0...v4.1.1) (2017-02-13) + +### Code Refactoring + +* Remove synchronous compilation support [#334](https://github.com/webpack-contrib/sass-loader/pull/334) + + +### BREAKING CHANGES + +* Remove node 0.12 support. [29b30755021a834e622bf4b5bb9db4d6e5913905](https://github.com/webpack-contrib/sass-loader/commit/29b30755021a834e622bf4b5bb9db4d6e5913905) +* Remove official node-sass@3 and webpack@1 support. [5a6bcb96d8bd7a7a11c33252ba739ffe09ca38c5](https://github.com/webpack-contrib/sass-loader/commit/5a6bcb96d8bd7a7a11c33252ba739ffe09ca38c5) +* Remove synchronous compilation support. [#334](https://github.com/webpack-contrib/sass-loader/pull/334) + + + +# [4.1.1](https://github.com/webpack-contrib/sass-loader/compare/v4.1.1...v4.1.0) (2016-12-21) + +### Chore + +* Update webpack peer dependency to support 2.2.0rc. [#330](https://github.com/webpack-contrib/sass-loader/pull/330) + + + +# [4.1.0](https://github.com/webpack-contrib/sass-loader/compare/v4.1.0...v4.0.2) (2016-12-14) + +### Features + +* Update `node-sass@4.0.0` [#319](https://github.com/webpack-contrib/sass-loader/pull/319) + + + +# [4.0.2](https://github.com/webpack-contrib/sass-loader/compare/v4.0.2...v4.0.1) (2016-07-07) + +### Bug Fixes + +* Fix wrong context in customImporters [#281](https://github.com/webpack-contrib/sass-loader/pull/281) + + + +# [4.0.1](https://github.com/webpack-contrib/sass-loader/compare/v4.0.1...v4.0.0) (2016-07-01) + +### Bug Fixes + +* Fix custom importers receiving `'stdin'` as second argument instead of the actual `resourcePath` [#267](https://github.com/webpack-contrib/sass-loader/pull/267) + + + +# [4.0.0](https://github.com/webpack-contrib/sass-loader/compare/v4.0.0...v3.2.2) (2016-06-27) + +### Bug Fixes + +* Fix incorrect source map paths [#250](https://github.com/webpack-contrib/sass-loader/pull/250) + + +### BREAKING CHANGES + +* Release new major version because the previous release was a breaking change in certain scenarios + See: https://github.com/webpack-contrib/sass-loader/pull/250#issuecomment-228663059 + + + +# [3.2.2](https://github.com/webpack-contrib/sass-loader/compare/v3.2.2...v3.2.1) (2016-06-26) + +### Bug Fixes + +* Fix incorrect source map paths [#250](https://github.com/webpack-contrib/sass-loader/pull/250) + + + +# [3.2.1](https://github.com/webpack-contrib/sass-loader/compare/v3.2.1...v3.2.0) (2016-06-19) + +### Bug Fixes + +* Add `webpack@^2.1.0-beta` as peer dependency [#233](https://github.com/webpack-contrib/sass-loader/pull/233) + + + +# [3.2.0](https://github.com/webpack-contrib/sass-loader/compare/v3.2.0...v3.1.2) (2016-03-12) + +### Features + +* Append file content instead of overwriting when `data`-option is already present [#216](https://github.com/webpack-contrib/sass-loader/pull/216) +* Make `indentedSyntax` option a bit smarter [#196](https://github.com/webpack-contrib/sass-loader/pull/196) + + + +# [3.1.2](https://github.com/webpack-contrib/sass-loader/compare/v3.1.2...v3.1.1) (2015-11-22) + +### Bug Fixes + +* Fix loader query not overriding webpack config [#189](https://github.com/webpack-contrib/sass-loader/pull/189) +* Update peer-dependencies [#182](https://github.com/webpack-contrib/sass-loader/pull/182) + - `node-sass^3.4.2` + - `webpack^1.12.6` + + + +# [3.1.1](https://github.com/webpack-contrib/sass-loader/compare/v3.1.1...v3.1.0) (2015-10-26) + +### Bug Fixes + +* Fix missing module `object-assign` [#178](https://github.com/webpack-contrib/sass-loader/issues/178) + + + +# [3.1.0](https://github.com/webpack-contrib/sass-loader/compare/v3.1.0...v3.0.0) (2015-10-25) + +### Bug Fixes + +* Fix a problem where modules with a `.` in their names were not resolved [#167](https://github.com/webpack-contrib/sass-loader/issues/167) + + +### Features + +* Add possibility to also define all options in your `webpack.config.js` [#152](https://github.com/webpack-contrib/sass-loader/pull/152) [#170](https://github.com/webpack-contrib/sass-loader/pull/170) + + + +# [3.0.0](https://github.com/webpack-contrib/sass-loader/compare/v3.0.0...v2.0.1) (2015-09-29) + +### Bug Fixes + +* Fix crash when Sass reported an error without `file` [#158](https://github.com/webpack-contrib/sass-loader/pull/158) + + +### BREAKING CHANGES + +* Add `node-sass@^3.3.3` and `webpack@^1.12.2` as peer-dependency [#165](https://github.com/webpack-contrib/sass-loader/pull/165) [#166](https://github.com/webpack-contrib/sass-loader/pull/166) [#169](https://github.com/webpack-contrib/sass-loader/pull/169) + + + +# [2.0.1](https://github.com/webpack-contrib/sass-loader/compare/v2.0.1...v2.0.0) (2015-08-14) + +### Bug Fixes + +* Add missing path normalization (fixes [#141](https://github.com/webpack-contrib/sass-loader/pull/141)) + + + +# [2.0.0](https://github.com/webpack-contrib/sass-loader/compare/v2.0.0...v1.0.4) (2015-08-06) + +### Bug Fixes + +* Add temporary fix for stuck processes (see [sass/node-sass#857](https://github.com/sass/node-sass/issues/857)) [#100](https://github.com/webpack-contrib/sass-loader/issues/100) [#119](https://github.com/webpack-contrib/sass-loader/issues/119) [#132](https://github.com/webpack-contrib/sass-loader/pull/132) +* Fix path resolving on Windows [#108](https://github.com/webpack-contrib/sass-loader/issues/108) +* Fix file watchers on Windows [#102](https://github.com/webpack-contrib/sass-loader/issues/102) +* Fix file watchers for files with errors [#134](https://github.com/webpack-contrib/sass-loader/pull/134) + + +### Code Refactoring + +* Refactor [import resolving algorithm](https://github.com/webpack-contrib/sass-loader/blob/089c52dc9bd02ec67fb5c65c2c226f43710f231c/index.js#L293-L348). ([#138](https://github.com/webpack-contrib/sass-loader/issues/138)) ([c8621a1](https://github.com/webpack-contrib/sass-loader/commit/80944ccf09cd9716a100160c068d255c5d742338)) + + +### BREAKING CHANGES + +* The new algorithm is aligned to libsass' way of resolving files. This yields to different results if two files with the same path and filename but with different extensions are present. Though this change should be no problem for most users, we must flag it as breaking change. [#135](https://github.com/webpack-contrib/sass-loader/issues/135) [#138](https://github.com/webpack-contrib/sass-loader/issues/138) + + + +# [1.0.4](https://github.com/webpack-contrib/sass-loader/compare/v1.0.4...v1.0.3) (2015-08-03) + +### Bug Fixes + +* Fix wrong source-map urls [#123](https://github.com/webpack-contrib/sass-loader/pull/123) +* Include source-map contents by default [#104](https://github.com/webpack-contrib/sass-loader/pull/104) + + + +# [1.0.3](https://github.com/webpack-contrib/sass-loader/compare/v1.0.3...v1.0.2) (2015-07-22) + +### Bug Fixes + +* Fix importing css files from scss/sass [#101](https://github.com/webpack-contrib/sass-loader/issues/101) +* Fix importing Sass partials from includePath [#98](https://github.com/webpack-contrib/sass-loader/issues/98) [#110](https://github.com/webpack-contrib/sass-loader/issues/110) + + + +# [1.0.2](https://github.com/webpack-contrib/sass-loader/compare/v1.0.2...v1.0.1) (2015-04-15) + +### Bug Fixes + +* Fix a bug where files could not be imported across language styles [#73](https://github.com/webpack-contrib/sass-loader/issues/73) +* Update peer-dependency `node-sass` to `3.1.0` + + + +# [1.0.1](https://github.com/webpack-contrib/sass-loader/compare/v1.0.1...v1.0.0) (2015-03-31) + +### Bug Fixes + +* Fix Sass partials not being resolved anymore [#68](https://github.com/webpack-contrib/sass-loader/issues/68) +* Update peer-dependency `node-sass` to `3.0.0-beta.4` + + + +# [1.0.0](https://github.com/webpack-contrib/sass-loader/compare/v1.0.0...v0.3.1) (2015-03-22) + +### Bug Fixes + +* Moved `node-sass^3.0.0-alpha.0` to `peerDependencies` [#28](https://github.com/webpack-contrib/sass-loader/issues/28) +* Using webpack's module resolver as custom importer [#39](https://github.com/webpack-contrib/sass-loader/issues/31) +* Add synchronous compilation support for usage with [enhanced-require](https://github.com/webpack/enhanced-require) [#39](https://github.com/webpack-contrib/sass-loader/pull/39) diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/LICENSE b/packages/vue-cli-plugin-uni/packages/sass-loader/LICENSE new file mode 100644 index 000000000..3d5fa7325 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/LICENSE @@ -0,0 +1,20 @@ +Copyright JS Foundation and other contributors + +Permission 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: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE 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. \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/README.md b/packages/vue-cli-plugin-uni/packages/sass-loader/README.md new file mode 100644 index 000000000..c2c3f6313 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/README.md @@ -0,0 +1,606 @@ +
+ + + + +
+ +[![npm][npm]][npm-url] +[![node][node]][node-url] +[![deps][deps]][deps-url] +[![tests][tests]][tests-url] +[![coverage][cover]][cover-url] +[![chat][chat]][chat-url] +[![size][size]][size-url] + +# sass-loader + +Loads a Sass/SCSS file and compiles it to CSS. + +## Getting Started + +To begin, you'll need to install `sass-loader`: + +```console +npm install sass-loader node-sass webpack --save-dev +``` + +`sass-loader` requires you to install either [Node Sass](https://github.com/sass/node-sass) or [Dart Sass](https://github.com/sass/dart-sass) on your own (more documentation can be found below). +This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use. + +Chain the `sass-loader` with the [css-loader](https://github.com/webpack-contrib/css-loader) and the [style-loader](https://github.com/webpack-contrib/style-loader) to immediately apply all styles to the DOM or the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract it into a separate file. + +Then add the loader to your Webpack configuration. For example: + +**app.js** + +```js +import './style.scss'; +``` + +**style.scss** + +```scss +$body-color: red; + +body { + color: $body-color; +} +``` + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + // Creates `style` nodes from JS strings + 'style-loader', + // Translates CSS into CommonJS + 'css-loader', + // Compiles Sass to CSS + 'sass-loader', + ], + }, + ], + }, +}; +``` + +Finally run `webpack` via your preferred method. + +### Resolving `import` at-rules + +Webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/). + +The `sass-loader` uses Sass's custom importer feature to pass all queries to the Webpack resolving engine. Thus you can import your Sass modules from `node_modules`. Just prepend them with a `~` to tell Webpack that this is not a relative import: + +```scss +@import '~bootstrap'; +``` + +It's important to only prepend it with `~`, because `~/` resolves to the home directory. +Webpack needs to distinguish between `bootstrap` and `~bootstrap` because CSS and Sass files have no special syntax for importing relative files. +Writing `@import "style.scss"` is the same as `@import "./style.scss";` + +### Problems with `url(...)` + +Since Sass implementations don't provide [url rewriting](https://github.com/sass/libsass/issues/532), all linked assets must be relative to the output. + +- If you pass the generated CSS on to the `css-loader`, all urls must be relative to the entry-file (e.g. `main.scss`). +- If you're just generating CSS without passing it to the `css-loader`, it must be relative to your web root. + +You will be disrupted by this first issue. It is natural to expect relative references to be resolved against the `.sass`/`.scss` file in which they are specified (like in regular `.css` files). + +Thankfully there are a two solutions to this problem: + +- Add the missing url rewriting using the [resolve-url-loader](https://github.com/bholloway/resolve-url-loader). Place it before `sass-loader` in the loader chain. +- Library authors usually provide a variable to modify the asset path. [bootstrap-sass](https://github.com/twbs/bootstrap-sass) for example has an `$icon-font-path`. + +## Options + +### `implementation` + +The special `implementation` option determines which implementation of Sass to use. + +By default the loader resolve the implementation based on your dependencies. +Just add required implementation to `package.json` (`node-sass` or `sass` package) and install dependencies. + +Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementation: + +**package.json** + +```json +{ + "devDependencies": { + "sass-loader": "^7.2.0", + "sass": "^1.22.10" + } +} +``` + +Example where the `sass-loader` loader uses the `node-sass` implementation: + +**package.json** + +```json +{ + "devDependencies": { + "sass-loader": "^7.2.0", + "node-sass": "^4.0.0" + } +} +``` + +Beware the situation when `node-sass` and `sass` were installed! By default the `sass-loader` prefers `node-sass`. In order to avoid this situation you can use the `implementation` option. + +The `implementation` options either accepts `node-sass` or `sass` (`Dart Sass`) as a module. + +For example, to use Dart Sass, you'd pass: + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + options: { + // Prefer `dart-sass` + implementation: require('sass'), + }, + }, + ], + }, + ], + }, +}; +``` + +Note that when using `sass` (`Dart Sass`), **synchronous compilation is twice as fast as asynchronous compilation** by default, due to the overhead of asynchronous callbacks. +To avoid this overhead, you can use the [fibers](https://www.npmjs.com/package/fibers) package to call asynchronous importers from the synchronous code path. + +We automatically inject the [`fibers`](https://github.com/laverdet/node-fibers) package (setup `sassOptions.fiber`) if is possible (i.e. you need install the [`fibers`](https://github.com/laverdet/node-fibers) package). + +**package.json** + +```json +{ + "devDependencies": { + "sass-loader": "^7.2.0", + "sass": "^1.22.10", + "fibers": "^4.0.1" + } +} +``` + +You can disable automatically injecting the [`fibers`](https://github.com/laverdet/node-fibers) package by passing a `false` value for the `sassOptions.fiber` option. + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + options: { + implementation: require('sass'), + sassOptions: { + fiber: false, + }, + }, + }, + ], + }, + ], + }, +}; +``` + +You can also pass the `fiber` value using this code: + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + options: { + implementation: require('sass'), + sassOptions: { + fiber: require('fibers'), + }, + }, + }, + ], + }, + ], + }, +}; +``` + +### `sassOptions` + +Type: `Object|Function` + +Options for [Node Sass](https://github.com/sass/node-sass) or [Dart Sass](http://sass-lang.com/dart-sass) implementation. + +> ℹ️ The `indentedSyntax` option has `true` value for the `sass` extension. + +> ℹ️ Options such as `file` and `outFile` are unavailable. + +> ℹ We recommend not to use the `sourceMapContents`, `sourceMapEmbed`, `sourceMapRoot` options because `sass-loader` automatically sets these options. + +There is a slight difference between the `node-sass` and `sass` (`Dart Sass`) options. +Please consult documentation before using them: + +- [Node Sass documentation](https://github.com/sass/node-sass/#options) for all available `node-sass` options. +- [Dart Sass documentation](https://github.com/sass/dart-sass#javascript-api) for all available `sass` options. + +#### `Object` + +Use and object for the Sass implementation setup. + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + options: { + sassOptions: { + indentWidth: 4, + includePaths: ['absolute/path/a', 'absolute/path/b'], + }, + }, + }, + ], + }, + ], + }, +}; +``` + +#### `Function` + +Allows to setup the Sass implementation by setting different options based on the loader context. + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + options: { + sassOptions: (loaderContext) => { + // More information about available properties https://webpack.js.org/api/loaders/ + const { resourcePath, rootContext } = loaderContext; + const relativePath = path.relative(rootContext, resourcePath); + + if (relativePath === 'styles/foo.scss') { + return { + includePaths: ['absolute/path/c', 'absolute/path/d'], + }; + } + + return { + includePaths: ['absolute/path/a', 'absolute/path/b'], + }; + }, + }, + }, + ], + }, + ], + }, +}; +``` + +### `prependData` + +Type: `String|Function` +Default: `undefined` + +Prepends `Sass`/`SCSS` code before the actual entry file. +In this case, the `sass-loader` will not override the `data` option but just append the entry's content. + +This is especially useful when some of your Sass variables depend on the environment: + +> ℹ Since you're injecting code, this will break the source mappings in your entry file. Often there's a simpler solution than this, like multiple Sass entry files. + +#### `String` + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + options: { + prependData: '$env: ' + process.env.NODE_ENV + ';', + }, + }, + ], + }, + ], + }, +}; +``` + +#### `Function` + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + options: { + prependData: (loaderContext) => { + // More information about available properties https://webpack.js.org/api/loaders/ + const { resourcePath, rootContext } = loaderContext; + const relativePath = path.relative(rootContext, resourcePath); + + if (relativePath === 'styles/foo.scss') { + return '$value: 100px;'; + } + + return '$value: 200px;'; + }, + }, + }, + ], + }, + ], + }, +}; +``` + +### `sourceMap` + +Type: `Boolean` +Default: depends on the `compiler.devtool` value + +Enables/Disables generation of source maps. + +By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option. All values enable source map generation except `eval` and `false` value. + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + { + loader: 'css-loader', + options: { + sourceMap: true, + }, + }, + { + loader: 'sass-loader', + options: { + sourceMap: true, + }, + }, + ], + }, + ], + }, +}; +``` + +> ℹ In some rare cases `node-sass` can output invalid source maps (it is a `node-sass` bug). +> In order to avoid this, you can try to update `node-sass` to latest version or you can try to set within `sassOptions` the `outputStyle` option to `compressed`. + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + sourceMap: true, + sassOptions: { + outputStyle: 'compressed', + }, + }, + ], + }, + ], + }, +}; +``` + +### `webpackImporter` + +Type: `Boolean` +Default: `true` + +Enables/Disables the default Webpack importer. + +This can improve performance in some cases. Use it with caution because aliases and `@import` at-rules starting with `~` will not work. You can pass own `importer` to solve this (see [`importer docs`](https://github.com/sass/node-sass#importer--v200---experimental)). + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'sass-loader', + options: { + webpackImporter: false, + }, + }, + ], + }, + ], + }, +}; +``` + +## Examples + +### Extracts CSS into separate files + +For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. + +There are two possibilities to extract a style sheet from the bundle: + +- [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) (use this, when using webpack 4 configuration. Works in all use-cases) +- [extract-loader](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output) + +**webpack.config.js** + +```js +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); + +module.exports = { + module: { + rules: [ + { + test: /\.s[ac]ss$/i, + use: [ + // fallback to style-loader in development + process.env.NODE_ENV !== 'production' + ? 'style-loader' + : MiniCssExtractPlugin.loader, + 'css-loader', + 'sass-loader', + ], + }, + ], + }, + plugins: [ + new MiniCssExtractPlugin({ + // Options similar to the same options in webpackOptions.output + // both options are optional + filename: '[name].css', + chunkFilename: '[id].css', + }), + ], +}; +``` + +### Source maps + +Enables/Disables generation of source maps. + +To enable CSS source maps, you'll need to pass the `sourceMap` option to the `sass-loader` _and_ the css-loader. + +**webpack.config.js** + +```javascript +module.exports = { + devtool: 'source-map', // any "source-map"-like devtool is possible + module: { + rules: [ + { + test: /\.scss$/, + use: [ + 'style-loader', + { + loader: 'css-loader', + options: { + sourceMap: true, + }, + }, + { + loader: 'sass-loader', + options: { + sourceMap: true, + }, + }, + ], + }, + ], + }, +}; +``` + +If you want to edit the original Sass files inside Chrome, [there's a good blog post](https://medium.com/@toolmantim/getting-started-with-css-sourcemaps-and-in-browser-sass-editing-b4daab987fb0). Checkout [test/sourceMap](https://github.com/webpack-contrib/sass-loader/tree/master/test) for a running example. + +## Contributing + +Please take a moment to read our contributing guidelines if you haven't yet done so. + +[CONTRIBUTING](./.github/CONTRIBUTING.md) + +## License + +[MIT](./LICENSE) + +[npm]: https://img.shields.io/npm/v/sass-loader.svg +[npm-url]: https://npmjs.com/package/sass-loader +[node]: https://img.shields.io/node/v/sass-loader.svg +[node-url]: https://nodejs.org +[deps]: https://david-dm.org/webpack-contrib/sass-loader.svg +[deps-url]: https://david-dm.org/webpack-contrib/sass-loader +[tests]: https://dev.azure.com/webpack-contrib/sass-loader/_apis/build/status/webpack-contrib.sass-loader?branchName=master +[tests-url]: https://dev.azure.com/webpack-contrib/sass-loader/_build/latest?definitionId=21&branchName=master +[cover]: https://codecov.io/gh/webpack-contrib/sass-loader/branch/master/graph/badge.svg +[cover-url]: https://codecov.io/gh/webpack-contrib/sass-loader +[chat]: https://badges.gitter.im/webpack/webpack.svg +[chat-url]: https://gitter.im/webpack/webpack +[size]: https://packagephobia.now.sh/badge?p=css-loader +[size-url]: https://packagephobia.now.sh/result?p=css-loader diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/SassError.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/SassError.js new file mode 100644 index 000000000..49cd96d4f --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/SassError.js @@ -0,0 +1,33 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +class SassError extends Error { + constructor(sassError, resourcePath) { + super(); + this.name = 'SassError'; + this.originalSassError = sassError; + this.loc = { + line: sassError.line, + column: sassError.column + }; // Keep original error if `sassError.formatted` is unavailable + + this.message = `${this.name}: ${this.originalSassError.message}`; + + if (this.originalSassError.formatted) { + this.message = `${this.name}: ${this.originalSassError.formatted.replace(/^Error: /, '').replace(/(\s*)stdin(\s*)/, `$1${resourcePath}$2`)}`; // Instruct webpack to hide the JS stack from the console. + // Usually you're only interested in the SASS stack in this case. + // eslint-disable-next-line no-param-reassign + + this.hideStack = true; + Error.captureStackTrace(this, this.constructor); + } + } + +} + +var _default = SassError; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js new file mode 100644 index 000000000..7b9557399 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js @@ -0,0 +1,5 @@ +"use strict"; + +const loader = require('./index'); + +module.exports = loader.default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getDefaultSassImplementation.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getDefaultSassImplementation.js new file mode 100644 index 000000000..0cfd8ba53 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getDefaultSassImplementation.js @@ -0,0 +1,28 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function getDefaultSassImplementation() { + let sassImplPkg = 'node-sass'; + + try { + require.resolve('node-sass'); + } catch (error) { + try { + require.resolve('sass'); + + sassImplPkg = 'sass'; + } catch (ignoreError) { + sassImplPkg = 'node-sass'; + } + } // eslint-disable-next-line import/no-dynamic-require, global-require + + + return require(sassImplPkg); +} + +var _default = getDefaultSassImplementation; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getRenderFunctionFromSassImplementation.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getRenderFunctionFromSassImplementation.js new file mode 100644 index 000000000..02d866da1 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getRenderFunctionFromSassImplementation.js @@ -0,0 +1,39 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _neoAsync = _interopRequireDefault(require("neo-async")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +let nodeSassJobQueue = null; +/** + * Verifies that the implementation and version of Sass is supported by this loader. + * + * @param {Object} implementation + * @returns {Function} + */ + +function getRenderFunctionFromSassImplementation(implementation) { + const isDartSass = implementation.info.includes('dart-sass'); + + if (isDartSass) { + return implementation.render.bind(implementation); + } // There is an issue with node-sass when async custom importers are used + // See https://github.com/sass/node-sass/issues/857#issuecomment-93594360 + // We need to use a job queue to make sure that one thread is always available to the UV lib + + + if (nodeSassJobQueue === null) { + const threadPoolSize = Number(process.env.UV_THREADPOOL_SIZE || 4); + nodeSassJobQueue = _neoAsync.default.queue(implementation.render.bind(implementation), threadPoolSize - 1); + } + + return nodeSassJobQueue.push.bind(nodeSassJobQueue); +} + +var _default = getRenderFunctionFromSassImplementation; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getSassImplementation.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getSassImplementation.js new file mode 100644 index 000000000..32828911f --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getSassImplementation.js @@ -0,0 +1,56 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _semver = _interopRequireDefault(require("semver")); + +var _getDefaultSassImplementation = _interopRequireDefault(require("./getDefaultSassImplementation")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function getSassImplementation(implementation) { + let resolvedImplementation = implementation; + + if (!resolvedImplementation) { + // eslint-disable-next-line no-param-reassign + resolvedImplementation = (0, _getDefaultSassImplementation.default)(); + } + + const { + info + } = resolvedImplementation; + + if (!info) { + throw new Error('Unknown Sass implementation.'); + } + + const infoParts = info.split('\t'); + + if (infoParts.length < 2) { + throw new Error(`Unknown Sass implementation "${info}".`); + } + + const [implementationName, version] = infoParts; + + if (implementationName === 'dart-sass') { + if (!_semver.default.satisfies(version, '^1.3.0')) { + throw new Error(`Dart Sass version ${version} is incompatible with ^1.3.0.`); + } + + return resolvedImplementation; + } else if (implementationName === 'node-sass') { + if (!_semver.default.satisfies(version, '^4.0.0')) { + throw new Error(`Node Sass version ${version} is incompatible with ^4.0.0.`); + } + + return resolvedImplementation; + } + + throw new Error(`Unknown Sass implementation "${implementationName}".`); +} + +var _default = getSassImplementation; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getSassOptions.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getSassOptions.js new file mode 100644 index 000000000..dee95cd79 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/getSassOptions.js @@ -0,0 +1,116 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _os = _interopRequireDefault(require("os")); + +var _path = _interopRequireDefault(require("path")); + +var _cloneDeep = _interopRequireDefault(require("clone-deep")); + +var _proxyCustomImporters = _interopRequireDefault(require("./proxyCustomImporters")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function isProductionLikeMode(loaderContext) { + return loaderContext.mode === 'production' || !loaderContext.mode || loaderContext.minimize; +} +/** + * Derives the sass options from the loader context and normalizes its values with sane defaults. + * + * @param {object} loaderContext + * @param {object} loaderOptions + * @param {string} content + * @param {object} implementation + * @returns {Object} + */ + + +function getSassOptions(loaderContext, loaderOptions, content, implementation) { + const options = (0, _cloneDeep.default)(loaderOptions.sassOptions ? typeof loaderOptions.sassOptions === 'function' ? loaderOptions.sassOptions(loaderContext) || {} : loaderOptions.sassOptions : {}); + const isDartSass = implementation.info.includes('dart-sass'); + + if (isDartSass) { + const shouldTryToResolveFibers = !options.fiber && options.fiber !== false; + + if (shouldTryToResolveFibers) { + let fibers; + + try { + fibers = require.resolve('fibers'); + } catch (_error) {// Nothing + } + + if (fibers) { + // eslint-disable-next-line global-require, import/no-dynamic-require + options.fiber = require(fibers); + } + } else if (options.fiber === false) { + // Don't pass the `fiber` option for `sass` (`Dart Sass`) + delete options.fiber; + } + } else { + // Don't pass the `fiber` option for `node-sass` + delete options.fiber; + } + + options.data = loaderOptions.prependData ? typeof loaderOptions.prependData === 'function' ? loaderOptions.prependData(loaderContext) + _os.default.EOL + content : loaderOptions.prependData + _os.default.EOL + content : content; // opt.outputStyle + + if (!options.outputStyle && isProductionLikeMode(loaderContext)) { + options.outputStyle = 'compressed'; + } + + const useSourceMap = typeof loaderOptions.sourceMap === 'boolean' ? loaderOptions.sourceMap : loaderContext.sourceMap; // opt.sourceMap + // Not using the `this.sourceMap` flag because css source maps are different + // @see https://github.com/webpack/css-loader/pull/40 + + if (useSourceMap) { + // Deliberately overriding the sourceMap option here. + // node-sass won't produce source maps if the data option is used and options.sourceMap is not a string. + // In case it is a string, options.sourceMap should be a path where the source map is written. + // But since we're using the data option, the source map will not actually be written, but + // all paths in sourceMap.sources will be relative to that path. + // Pretty complicated... :( + options.sourceMap = _path.default.join(process.cwd(), '/sass.map'); + + if ('sourceMapRoot' in options === false) { + options.sourceMapRoot = process.cwd(); + } + + if ('omitSourceMapUrl' in options === false) { + // The source map url doesn't make sense because we don't know the output path + // The css-loader will handle that for us + options.omitSourceMapUrl = true; + } + + if ('sourceMapContents' in options === false) { + // If sourceMapContents option is not set, set it to true otherwise maps will be empty/null + // when exported by webpack-extract-text-plugin. + options.sourceMapContents = true; + } + } + + const { + resourcePath + } = loaderContext; + + const ext = _path.default.extname(resourcePath); // If we are compiling sass and indentedSyntax isn't set, automatically set it. + + + if (ext && ext.toLowerCase() === '.sass' && 'indentedSyntax' in options === false) { + options.indentedSyntax = true; + } else { + options.indentedSyntax = Boolean(options.indentedSyntax); + } // Allow passing custom importers to `node-sass`. Accepts `Function` or an array of `Function`s. + + + options.importer = options.importer ? (0, _proxyCustomImporters.default)(options.importer, resourcePath) : []; + options.includePaths = (options.includePaths || []).concat(_path.default.dirname(resourcePath)); + return options; +} + +var _default = getSassOptions; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/importsToResolve.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/importsToResolve.js new file mode 100644 index 000000000..b68acd498 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/importsToResolve.js @@ -0,0 +1,88 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _loaderUtils = _interopRequireDefault(require("loader-utils")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Examples: +// - ~package +// - ~package/ +// - ~@org +// - ~@org/ +// - ~@org/package +// - ~@org/package/ +const matchModuleImport = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/; +/** + * When libsass tries to resolve an import, it uses a special algorithm. + * Since the sass-loader uses webpack to resolve the modules, we need to simulate that algorithm. This function + * returns an array of import paths to try. The last entry in the array is always the original url + * to enable straight-forward webpack.config aliases. + * + * @param {string} url + * @returns {Array} + */ + +function importsToResolve(url) { + const request = _loaderUtils.default.urlToRequest(url); // Keep in mind: ext can also be something like '.datepicker' when the true extension is omitted and the filename contains a dot. + // @see https://github.com/webpack-contrib/sass-loader/issues/167 + + + const ext = _path.default.extname(request).toLowerCase(); // In case there is module request, send this to webpack resolver + + + if (matchModuleImport.test(url)) { + return [request, url]; + } // Because @import is also defined in CSS, Sass needs a way of compiling plain CSS @imports without trying to import the files at compile time. + // To accomplish this, and to ensure SCSS is as much of a superset of CSS as possible, Sass will compile any @imports with the following characteristics to plain CSS imports: + // - imports where the URL ends with .css. + // - imports where the URL begins http:// or https://. + // - imports where the URL is written as a url(). + // - imports that have media queries. + // + // The `node-sass` package sends `@import` ending on `.css` to importer, it is bug, so we skip resolve + + + if (ext === '.css') { + return []; + } + + const dirname = _path.default.dirname(request); + + const basename = _path.default.basename(request); // In case there is file extension: + // + // 1. Try to resolve `_` file. + // 2. Try to resolve file without `_`. + // 3. Send a original url to webpack resolver, maybe it is alias. + + + if (['.scss', '.sass'].includes(ext)) { + return [`${dirname}/_${basename}`, `${dirname}/${basename}`, url]; + } // In case there is no file extension and filename starts with `_`: + // + // 1. Try to resolve files with `scss`, `sass` and `css` extensions. + // 2. Try to resolve directory with `_index` or `index` filename. + // 3. Send the original url to webpack resolver, maybe it's alias. + + + if (basename.startsWith('_')) { + return [`${request}.scss`, `${request}.sass`, `${request}.css`, request, url]; + } // In case there is no file extension and filename doesn't start with `_`: + // + // 1. Try to resolve file starts with `_` and with extensions + // 2. Try to resolve file with extensions + // 3. Try to resolve directory with `_index` or `index` filename. + // 4. Send a original url to webpack resolver, maybe it is alias. + + + return [`${dirname}/_${basename}.scss`, `${dirname}/_${basename}.sass`, `${dirname}/_${basename}.css`, `${request}.scss`, `${request}.sass`, `${request}.css`, request, url]; +} + +var _default = importsToResolve; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/index.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/index.js new file mode 100644 index 000000000..bfdb5e076 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/index.js @@ -0,0 +1,114 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _schemaUtils = _interopRequireDefault(require("schema-utils")); + +var _loaderUtils = require("loader-utils"); + +var _options = _interopRequireDefault(require("./options.json")); + +var _getSassImplementation = _interopRequireDefault(require("./getSassImplementation")); + +var _getSassOptions = _interopRequireDefault(require("./getSassOptions")); + +var _webpackImporter = _interopRequireDefault(require("./webpackImporter")); + +var _getRenderFunctionFromSassImplementation = _interopRequireDefault(require("./getRenderFunctionFromSassImplementation")); + +var _SassError = _interopRequireDefault(require("./SassError")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * The sass-loader makes node-sass and dart-sass available to webpack modules. + * + * @this {object} + * @param {string} content + */ +function loader(content) { + const options = (0, _loaderUtils.getOptions)(this) || {}; + (0, _schemaUtils.default)(_options.default, options, { + name: 'Sass Loader', + baseDataPath: 'options' + }); + const implementation = (0, _getSassImplementation.default)(options.implementation); + const callback = this.async(); + + const addNormalizedDependency = file => { + // node-sass returns POSIX paths + this.addDependency(_path.default.normalize(file)); + }; + + const sassOptions = (0, _getSassOptions.default)(this, options, content, implementation); + const shouldUseWebpackImporter = typeof options.webpackImporter === 'boolean' ? options.webpackImporter : true; + + if (shouldUseWebpackImporter) { + const resolve = this.getResolve({ + mainFields: ['sass', 'style', 'main', '...'], + mainFiles: ['_index', 'index', '...'], + extensions: ['.scss', '.sass', '.css', '...'] + }); + sassOptions.importer.push((0, _webpackImporter.default)(this.resourcePath, resolve, addNormalizedDependency)); + } // Skip empty files, otherwise it will stop webpack, see issue #21 + + + if (sassOptions.data.trim() === '') { + callback(null, ''); + return; + } + + const render = (0, _getRenderFunctionFromSassImplementation.default)(implementation); + render(sassOptions, (error, result) => { + if (error) { + if (error.file) { + addNormalizedDependency(error.file); + } + + callback(new _SassError.default(error, this.resourcePath)); + return; + } + + if (result.map && result.map !== '{}') { + // eslint-disable-next-line no-param-reassign + result.map = JSON.parse(result.map); // result.map.file is an optional property that provides the output filename. + // Since we don't know the final filename in the webpack build chain yet, it makes no sense to have it. + // eslint-disable-next-line no-param-reassign + + delete result.map.file; // One of the sources is 'stdin' according to dart-sass/node-sass because we've used the data input. + // Now let's override that value with the correct relative path. + // Since we specified options.sourceMap = path.join(process.cwd(), "/sass.map"); in getSassOptions, + // we know that this path is relative to process.cwd(). This is how node-sass works. + // eslint-disable-next-line no-param-reassign + + const stdinIndex = result.map.sources.findIndex(source => source.includes('stdin')); + + if (stdinIndex !== -1) { + // eslint-disable-next-line no-param-reassign + result.map.sources[stdinIndex] = _path.default.relative(process.cwd(), this.resourcePath); + } // node-sass returns POSIX paths, that's why we need to transform them back to native paths. + // This fixes an error on windows where the source-map module cannot resolve the source maps. + // @see https://github.com/webpack-contrib/sass-loader/issues/366#issuecomment-279460722 + // eslint-disable-next-line no-param-reassign + + + result.map.sourceRoot = _path.default.normalize(result.map.sourceRoot); // eslint-disable-next-line no-param-reassign + + result.map.sources = result.map.sources.map(_path.default.normalize); + } else { + // eslint-disable-next-line no-param-reassign + result.map = null; + } + + result.stats.includedFiles.forEach(addNormalizedDependency); + callback(null, result.css.toString(), result.map); + }); +} + +var _default = loader; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/options.json b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/options.json new file mode 100644 index 000000000..3430c7d8e --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/options.json @@ -0,0 +1,41 @@ +{ + "type": "object", + "properties": { + "implementation": { + "description": "The implementation of the sass to be used (https://github.com/webpack-contrib/sass-loader#implementation).", + "type": "object" + }, + "sassOptions": { + "description": "Options for `node-sass` or `sass` (`Dart Sass`) implementation. (https://github.com/webpack-contrib/sass-loader#implementation).", + "anyOf": [ + { + "type": "object", + "additionalProperties": true + }, + { + "instanceof": "Function" + } + ] + }, + "prependData": { + "description": "Prepends `Sass`/`SCSS` code before the actual entry file (https://github.com/webpack-contrib/sass-loader#prependdata).", + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Function" + } + ] + }, + "sourceMap": { + "description": "Enables/Disables generation of source maps (https://github.com/webpack-contrib/sass-loader#sourcemap).", + "type": "boolean" + }, + "webpackImporter": { + "description": "Enables/Disables default `webpack` importer (https://github.com/webpack-contrib/sass-loader#webpackimporter).", + "type": "boolean" + } + }, + "additionalProperties": false +} diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/proxyCustomImporters.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/proxyCustomImporters.js new file mode 100644 index 000000000..504a5d7ca --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/proxyCustomImporters.js @@ -0,0 +1,31 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +/** + * Creates new custom importers that use the given `resourcePath` if libsass calls the custom importer with `prev` + * being 'stdin'. + * + * Why do we need this? We have to use the `data` option of node-sass in order to compile our sass because + * the `resourcePath` might not be an actual file on disk. When using the `data` option, libsass uses the string + * 'stdin' instead of a filename. + * + * We have to fix this behavior in order to provide a consistent experience to the webpack user. + * + * @param {Function|Array} importer + * @param {string} resourcePath + * @returns {Array} + */ +function proxyCustomImporters(importer, resourcePath) { + return [].concat(importer).map( // eslint-disable-next-line no-shadow + importer => function customImporter() { + return importer.apply(this, // eslint-disable-next-line prefer-rest-params + Array.from(arguments).map((arg, i) => i === 1 && arg === 'stdin' ? resourcePath : arg)); + }); +} + +var _default = proxyCustomImporters; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/dist/webpackImporter.js b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/webpackImporter.js new file mode 100644 index 000000000..07a7ebd8c --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/dist/webpackImporter.js @@ -0,0 +1,75 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _importsToResolve = _interopRequireDefault(require("./importsToResolve")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * @name PromisedResolve + * @type {Function} + * @param {string} dir + * @param {string} request + * @returns Promise + */ + +/** + * @name Importer + * @type {Function} + * @param {string} url + * @param {string} prev + * @param {Function} done + */ +const matchCss = /\.css$/i; +/** + * Returns an importer that uses webpack's resolving algorithm. + * + * It's important that the returned function has the correct number of arguments + * (based on whether the call is sync or async) because otherwise node-sass doesn't exit. + * + * @param {string} resourcePath + * @param {PromisedResolve} resolve + * @param {Function} addNormalizedDependency + * @returns {Importer} + */ + +function webpackImporter(resourcePath, resolve, addNormalizedDependency) { + function dirContextFrom(fileContext) { + return _path.default.dirname( // The first file is 'stdin' when we're using the data option + fileContext === 'stdin' ? resourcePath : fileContext); + } // eslint-disable-next-line no-shadow + + + function startResolving(dir, importsToResolve) { + return importsToResolve.length === 0 ? Promise.reject() : resolve(dir, importsToResolve[0]).then(resolvedFile => { + // Add the resolvedFilename as dependency. Although we're also using stats.includedFiles, this might come + // in handy when an error occurs. In this case, we don't get stats.includedFiles from node-sass. + addNormalizedDependency(resolvedFile); + return { + // By removing the CSS file extension, we trigger node-sass to include the CSS file instead of just linking it. + file: resolvedFile.replace(matchCss, '') + }; + }, () => { + const [, ...tailResult] = importsToResolve; + return startResolving(dir, tailResult); + }); + } + + return (url, prev, done) => { + startResolving(dirContextFrom(prev), (0, _importsToResolve.default)(url)) // Catch all resolving errors, return the original file and pass responsibility back to other custom importers + .catch(() => { + return { + file: url + }; + }).then(done); + }; +} + +var _default = webpackImporter; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/CHANGELOG.md b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/CHANGELOG.md new file mode 100644 index 000000000..5295866f5 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/CHANGELOG.md @@ -0,0 +1,279 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [2.7.0](https://github.com/webpack/schema-utils/compare/v2.6.6...v2.7.0) (2020-05-29) + + +### Features + +* improve hints ([a36e535](https://github.com/webpack/schema-utils/commit/a36e535faca1b01e27c3bfa3c8bee9227c3f836c)) +* smart not case ([#101](https://github.com/webpack/schema-utils/issues/101)) ([698d8b0](https://github.com/webpack/schema-utils/commit/698d8b05462d86aadb217e25a45c7b953a79a52e)) + + +### Bug Fixes + +* move @types/json-schema from devDependencies to dependencies ([#97](https://github.com/webpack/schema-utils/issues/97)) ([#98](https://github.com/webpack/schema-utils/issues/98)) ([945e67d](https://github.com/webpack/schema-utils/commit/945e67db5e19baf7ec7df72813b0739dd56f950d)) + +### [2.6.6](https://github.com/webpack/schema-utils/compare/v2.6.5...v2.6.6) (2020-04-17) + + +### Bug Fixes + +* improve perf + +### [2.6.5](https://github.com/webpack/schema-utils/compare/v2.6.4...v2.6.5) (2020-03-11) + + +### Bug Fixes + +* correct dots at end of sentence ([7284beb](https://github.com/webpack/schema-utils/commit/7284bebe00cd570f1bef2c15951a07b9794038e6)) + +### [2.6.4](https://github.com/webpack/schema-utils/compare/v2.6.3...v2.6.4) (2020-01-17) + + +### Bug Fixes + +* change `initialised` to `initialized` ([#87](https://github.com/webpack/schema-utils/issues/87)) ([70f12d3](https://github.com/webpack/schema-utils/commit/70f12d33a8eaa27249bc9c1a27f886724cf91ea7)) + +### [2.6.3](https://github.com/webpack/schema-utils/compare/v2.6.2...v2.6.3) (2020-01-17) + + +### Bug Fixes + +* prefer the `baseDataPath` option from arguments ([#86](https://github.com/webpack/schema-utils/issues/86)) ([e236859](https://github.com/webpack/schema-utils/commit/e236859e85b28e35e1294f86fc1ff596a5031cea)) + +### [2.6.2](https://github.com/webpack/schema-utils/compare/v2.6.1...v2.6.2) (2020-01-14) + + +### Bug Fixes + +* better handle Windows absolute paths ([#85](https://github.com/webpack/schema-utils/issues/85)) ([1fa2930](https://github.com/webpack/schema-utils/commit/1fa2930a161e907b9fc53a7233d605910afdb883)) + +### [2.6.1](https://github.com/webpack/schema-utils/compare/v2.6.0...v2.6.1) (2019-11-28) + + +### Bug Fixes + +* typescript declarations ([#84](https://github.com/webpack/schema-utils/issues/84)) ([89d55a9](https://github.com/webpack/schema-utils/commit/89d55a9a8edfa6a8ac8b112f226bb3154e260319)) + +## [2.6.0](https://github.com/webpack/schema-utils/compare/v2.5.0...v2.6.0) (2019-11-27) + + +### Features + +* support configuration via title ([#81](https://github.com/webpack/schema-utils/issues/81)) ([afddc10](https://github.com/webpack/schema-utils/commit/afddc109f6891cd37a9f1835d50862d119a072bf)) + + +### Bug Fixes + +* typescript definitions ([#70](https://github.com/webpack/schema-utils/issues/70)) ([f38158d](https://github.com/webpack/schema-utils/commit/f38158d6d040e2c701622778ae8122fb26a4f990)) + +## [2.5.0](https://github.com/webpack/schema-utils/compare/v2.4.1...v2.5.0) (2019-10-15) + + +### Bug Fixes + +* rework format for maxLength, minLength ([#67](https://github.com/webpack/schema-utils/issues/67)) ([0d12259](https://github.com/webpack/schema-utils/commit/0d12259)) +* support all cases with one number in range ([#64](https://github.com/webpack/schema-utils/issues/64)) ([7fc8069](https://github.com/webpack/schema-utils/commit/7fc8069)) +* typescript definition and export naming ([#69](https://github.com/webpack/schema-utils/issues/69)) ([a435b79](https://github.com/webpack/schema-utils/commit/a435b79)) + + +### Features + +* "smart" numbers range ([62fb107](https://github.com/webpack/schema-utils/commit/62fb107)) + +### [2.4.1](https://github.com/webpack/schema-utils/compare/v2.4.0...v2.4.1) (2019-09-27) + + +### Bug Fixes + +* publish definitions ([#58](https://github.com/webpack/schema-utils/issues/58)) ([1885faa](https://github.com/webpack/schema-utils/commit/1885faa)) + +## [2.4.0](https://github.com/webpack/schema-utils/compare/v2.3.0...v2.4.0) (2019-09-26) + + +### Features + +* better errors when the `type` keyword doesn't exist ([0988be2](https://github.com/webpack/schema-utils/commit/0988be2)) +* support $data reference ([#56](https://github.com/webpack/schema-utils/issues/56)) ([d2f11d6](https://github.com/webpack/schema-utils/commit/d2f11d6)) +* types definitions ([#52](https://github.com/webpack/schema-utils/issues/52)) ([facb431](https://github.com/webpack/schema-utils/commit/facb431)) + +## [2.3.0](https://github.com/webpack/schema-utils/compare/v2.2.0...v2.3.0) (2019-09-26) + + +### Features + +* support `not` keyword ([#53](https://github.com/webpack/schema-utils/issues/53)) ([765f458](https://github.com/webpack/schema-utils/commit/765f458)) + +## [2.2.0](https://github.com/webpack/schema-utils/compare/v2.1.0...v2.2.0) (2019-09-02) + + +### Features + +* better error output for `oneOf` and `anyOf` ([#48](https://github.com/webpack/schema-utils/issues/48)) ([#50](https://github.com/webpack/schema-utils/issues/50)) ([332242f](https://github.com/webpack/schema-utils/commit/332242f)) + +## [2.1.0](https://github.com/webpack-contrib/schema-utils/compare/v2.0.1...v2.1.0) (2019-08-07) + + +### Bug Fixes + +* throw error on sparse arrays ([#47](https://github.com/webpack-contrib/schema-utils/issues/47)) ([b85ac38](https://github.com/webpack-contrib/schema-utils/commit/b85ac38)) + + +### Features + +* export `ValidateError` ([#46](https://github.com/webpack-contrib/schema-utils/issues/46)) ([ff781d7](https://github.com/webpack-contrib/schema-utils/commit/ff781d7)) + + + +### [2.0.1](https://github.com/webpack-contrib/schema-utils/compare/v2.0.0...v2.0.1) (2019-07-18) + + +### Bug Fixes + +* error message for empty object ([#44](https://github.com/webpack-contrib/schema-utils/issues/44)) ([0b4b4a2](https://github.com/webpack-contrib/schema-utils/commit/0b4b4a2)) + + + +### [2.0.0](https://github.com/webpack-contrib/schema-utils/compare/v1.0.0...v2.0.0) (2019-07-17) + + +### BREAKING CHANGES + +* drop support for Node.js < 8.9.0 +* drop support `errorMessage`, please use `description` for links. +* api was changed, please look documentation. +* error messages was fully rewritten. + + + +# [1.0.0](https://github.com/webpack-contrib/schema-utils/compare/v0.4.7...v1.0.0) (2018-08-07) + + +### Features + +* **src:** add support for custom error messages ([#33](https://github.com/webpack-contrib/schema-utils/issues/33)) ([1cbe4ef](https://github.com/webpack-contrib/schema-utils/commit/1cbe4ef)) + + + + +## [0.4.7](https://github.com/webpack-contrib/schema-utils/compare/v0.4.6...v0.4.7) (2018-08-07) + + +### Bug Fixes + +* **src:** `node >= v4.0.0` support ([#32](https://github.com/webpack-contrib/schema-utils/issues/32)) ([cb13dd4](https://github.com/webpack-contrib/schema-utils/commit/cb13dd4)) + + + + +## [0.4.6](https://github.com/webpack-contrib/schema-utils/compare/v0.4.5...v0.4.6) (2018-08-06) + + +### Bug Fixes + +* **package:** remove lockfile ([#28](https://github.com/webpack-contrib/schema-utils/issues/28)) ([69f1a81](https://github.com/webpack-contrib/schema-utils/commit/69f1a81)) +* **package:** remove unnecessary `webpack` dependency ([#26](https://github.com/webpack-contrib/schema-utils/issues/26)) ([532eaa5](https://github.com/webpack-contrib/schema-utils/commit/532eaa5)) + + + + +## [0.4.5](https://github.com/webpack-contrib/schema-utils/compare/v0.4.4...v0.4.5) (2018-02-13) + + +### Bug Fixes + +* **CHANGELOG:** update broken links ([4483b9f](https://github.com/webpack-contrib/schema-utils/commit/4483b9f)) +* **package:** update broken links ([f2494ba](https://github.com/webpack-contrib/schema-utils/commit/f2494ba)) + + + + +## [0.4.4](https://github.com/webpack-contrib/schema-utils/compare/v0.4.3...v0.4.4) (2018-02-13) + + +### Bug Fixes + +* **package:** update `dependencies` ([#22](https://github.com/webpack-contrib/schema-utils/issues/22)) ([3aecac6](https://github.com/webpack-contrib/schema-utils/commit/3aecac6)) + + + + +## [0.4.3](https://github.com/webpack-contrib/schema-utils/compare/v0.4.2...v0.4.3) (2017-12-14) + + +### Bug Fixes + +* **validateOptions:** throw `err` instead of `process.exit(1)` ([#17](https://github.com/webpack-contrib/schema-utils/issues/17)) ([c595eda](https://github.com/webpack-contrib/schema-utils/commit/c595eda)) +* **ValidationError:** never return `this` in the ctor ([#16](https://github.com/webpack-contrib/schema-utils/issues/16)) ([c723791](https://github.com/webpack-contrib/schema-utils/commit/c723791)) + + + + +## [0.4.2](https://github.com/webpack-contrib/schema-utils/compare/v0.4.1...v0.4.2) (2017-11-09) + + +### Bug Fixes + +* **validateOptions:** catch `ValidationError` and handle it internally ([#15](https://github.com/webpack-contrib/schema-utils/issues/15)) ([9c5ef5e](https://github.com/webpack-contrib/schema-utils/commit/9c5ef5e)) + + + + +## [0.4.1](https://github.com/webpack-contrib/schema-utils/compare/v0.4.0...v0.4.1) (2017-11-03) + + +### Bug Fixes + +* **ValidationError:** use `Error.captureStackTrace` for `err.stack` handling ([#14](https://github.com/webpack-contrib/schema-utils/issues/14)) ([a6fb974](https://github.com/webpack-contrib/schema-utils/commit/a6fb974)) + + + + +# [0.4.0](https://github.com/webpack-contrib/schema-utils/compare/v0.3.0...v0.4.0) (2017-10-28) + + +### Features + +* add support for `typeof`, `instanceof` (`{Function\|RegExp}`) ([#10](https://github.com/webpack-contrib/schema-utils/issues/10)) ([9f01816](https://github.com/webpack-contrib/schema-utils/commit/9f01816)) + + + + +# [0.3.0](https://github.com/webpack-contrib/schema-utils/compare/v0.2.1...v0.3.0) (2017-04-29) + + +### Features + +* add ValidationError ([#8](https://github.com/webpack-contrib/schema-utils/issues/8)) ([d48f0fb](https://github.com/webpack-contrib/schema-utils/commit/d48f0fb)) + + + + +## [0.2.1](https://github.com/webpack-contrib/schema-utils/compare/v0.2.0...v0.2.1) (2017-03-13) + + +### Bug Fixes + +* Include .babelrc to `files` ([28f0363](https://github.com/webpack-contrib/schema-utils/commit/28f0363)) +* Include source to `files` ([43b0f2f](https://github.com/webpack-contrib/schema-utils/commit/43b0f2f)) + + + + +# [0.2.0](https://github.com/webpack-contrib/schema-utils/compare/v0.1.0...v0.2.0) (2017-03-12) + + +# 0.1.0 (2017-03-07) + + +### Features + +* **validations:** add validateOptions module ([ae9b47b](https://github.com/webpack-contrib/schema-utils/commit/ae9b47b)) + + + +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/LICENSE b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/LICENSE new file mode 100644 index 000000000..8c11fc728 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/LICENSE @@ -0,0 +1,20 @@ +Copyright JS Foundation and other contributors + +Permission 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: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE 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. diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/README.md b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/README.md new file mode 100644 index 000000000..18fb3b944 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/README.md @@ -0,0 +1,276 @@ + + +[![npm][npm]][npm-url] +[![node][node]][node-url] +[![deps][deps]][deps-url] +[![tests][tests]][tests-url] +[![coverage][cover]][cover-url] +[![chat][chat]][chat-url] +[![size][size]][size-url] + +# schema-utils + +Package for validate options in loaders and plugins. + +## Getting Started + +To begin, you'll need to install `schema-utils`: + +```console +npm install schema-utils +``` + +## API + +**schema.json** + +```json +{ + "type": "object", + "properties": { + "option": { + "type": ["boolean"] + } + }, + "additionalProperties": false +} +``` + +```js +import schema from './path/to/schema.json'; +import validate from 'schema-utils'; + +const options = { option: true }; +const configuration = { name: 'Loader Name/Plugin Name/Name' }; + +validate(schema, options, configuration); +``` + +### `schema` + +Type: `String` + +JSON schema. + +Simple example of schema: + +```json +{ + "type": "object", + "properties": { + "name": { + "description": "This is description of option.", + "type": "string" + } + }, + "additionalProperties": false +} +``` + +### `options` + +Type: `Object` + +Object with options. + +```js +validate( + schema, + { + name: 123, + }, + { name: 'MyPlugin' } +); +``` + +### `configuration` + +Allow to configure validator. + +There is an alternative method to configure the `name` and`baseDataPath` options via the `title` property in the schema. +For example: + +```json +{ + "title": "My Loader options", + "type": "object", + "properties": { + "name": { + "description": "This is description of option.", + "type": "string" + } + }, + "additionalProperties": false +} +``` + +The last word used for the `baseDataPath` option, other words used for the `name` option. +Based on the example above the `name` option equals `My Loader`, the `baseDataPath` option equals `options`. + +#### `name` + +Type: `Object` +Default: `"Object"` + +Allow to setup name in validation errors. + +```js +validate(schema, options, { name: 'MyPlugin' }); +``` + +```shell +Invalid configuration object. MyPlugin has been initialised using a configuration object that does not match the API schema. + - configuration.optionName should be a integer. +``` + +#### `baseDataPath` + +Type: `String` +Default: `"configuration"` + +Allow to setup base data path in validation errors. + +```js +validate(schema, options, { name: 'MyPlugin', baseDataPath: 'options' }); +``` + +```shell +Invalid options object. MyPlugin has been initialised using an options object that does not match the API schema. + - options.optionName should be a integer. +``` + +#### `postFormatter` + +Type: `Function` +Default: `undefined` + +Allow to reformat errors. + +```js +validate(schema, options, { + name: 'MyPlugin', + postFormatter: (formattedError, error) => { + if (error.keyword === 'type') { + return `${formattedError}\nAdditional Information.`; + } + + return formattedError; + }, +}); +``` + +```shell +Invalid options object. MyPlugin has been initialized using an options object that does not match the API schema. + - options.optionName should be a integer. + Additional Information. +``` + +## Examples + +**schema.json** + +```json +{ + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "test": { + "anyOf": [ + { "type": "array" }, + { "type": "string" }, + { "instanceof": "RegExp" } + ] + }, + "transform": { + "instanceof": "Function" + }, + "sourceMap": { + "type": "boolean" + } + }, + "additionalProperties": false +} +``` + +### `Loader` + +```js +import { getOptions } from 'loader-utils'; +import validateOptions from 'schema-utils'; + +import schema from 'path/to/schema.json'; + +function loader(src, map) { + const options = getOptions(this) || {}; + + validateOptions(schema, options, { + name: 'Loader Name', + baseDataPath: 'options', + }); + + // Code... +} + +export default loader; +``` + +### `Plugin` + +```js +import validateOptions from 'schema-utils'; + +import schema from 'path/to/schema.json'; + +class Plugin { + constructor(options) { + validateOptions(schema, options, { + name: 'Plugin Name', + baseDataPath: 'options', + }); + + this.options = options; + } + + apply(compiler) { + // Code... + } +} + +export default Plugin; +``` + +## Contributing + +Please take a moment to read our contributing guidelines if you haven't yet done so. + +[CONTRIBUTING](./.github/CONTRIBUTING.md) + +## License + +[MIT](./LICENSE) + +[npm]: https://img.shields.io/npm/v/schema-utils.svg +[npm-url]: https://npmjs.com/package/schema-utils +[node]: https://img.shields.io/node/v/schema-utils.svg +[node-url]: https://nodejs.org +[deps]: https://david-dm.org/webpack/schema-utils.svg +[deps-url]: https://david-dm.org/webpack/schema-utils +[tests]: https://github.com/webpack/schema-utils/workflows/schema-utils/badge.svg +[tests-url]: https://github.com/webpack/schema-utils/actions +[cover]: https://codecov.io/gh/webpack/schema-utils/branch/master/graph/badge.svg +[cover-url]: https://codecov.io/gh/webpack/schema-utils +[chat]: https://badges.gitter.im/webpack/webpack.svg +[chat-url]: https://gitter.im/webpack/webpack +[size]: https://packagephobia.now.sh/badge?p=schema-utils +[size-url]: https://packagephobia.now.sh/result?p=schema-utils diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/ValidationError.d.ts b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/ValidationError.d.ts new file mode 100644 index 000000000..1b53f70fe --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/ValidationError.d.ts @@ -0,0 +1,88 @@ +export default ValidationError; +export type JSONSchema6 = import('json-schema').JSONSchema6; +export type JSONSchema7 = import('json-schema').JSONSchema7; +export type Schema = + | (import('json-schema').JSONSchema4 & import('./validate').Extend) + | (import('json-schema').JSONSchema6 & import('./validate').Extend) + | (import('json-schema').JSONSchema7 & import('./validate').Extend); +export type ValidationErrorConfiguration = { + name?: string | undefined; + baseDataPath?: string | undefined; + postFormatter?: import('./validate').PostFormatter | undefined; +}; +export type PostFormatter = ( + formattedError: string, + error: import('ajv').ErrorObject & { + children?: import('ajv').ErrorObject[] | undefined; + } +) => string; +export type SchemaUtilErrorObject = import('ajv').ErrorObject & { + children?: import('ajv').ErrorObject[] | undefined; +}; +export type SPECIFICITY = number; +declare class ValidationError extends Error { + /** + * @param {Array} errors + * @param {Schema} schema + * @param {ValidationErrorConfiguration} configuration + */ + constructor( + errors: Array, + schema: Schema, + configuration?: ValidationErrorConfiguration + ); + /** @type {Array} */ + errors: Array; + /** @type {Schema} */ + schema: Schema; + /** @type {string} */ + headerName: string; + /** @type {string} */ + baseDataPath: string; + /** @type {PostFormatter | null} */ + postFormatter: PostFormatter | null; + /** + * @param {string} path + * @returns {Schema} + */ + getSchemaPart(path: string): Schema; + /** + * @param {Schema} schema + * @param {boolean} logic + * @param {Array} prevSchemas + * @returns {string} + */ + formatSchema( + schema: Schema, + logic?: boolean, + prevSchemas?: Array + ): string; + /** + * @param {Schema=} schemaPart + * @param {(boolean | Array)=} additionalPath + * @param {boolean=} needDot + * @param {boolean=} logic + * @returns {string} + */ + getSchemaPartText( + schemaPart?: Schema | undefined, + additionalPath?: (boolean | Array) | undefined, + needDot?: boolean | undefined, + logic?: boolean | undefined + ): string; + /** + * @param {Schema=} schemaPart + * @returns {string} + */ + getSchemaPartDescription(schemaPart?: Schema | undefined): string; + /** + * @param {SchemaUtilErrorObject} error + * @returns {string} + */ + formatValidationError(error: SchemaUtilErrorObject): string; + /** + * @param {Array} errors + * @returns {string} + */ + formatValidationErrors(errors: Array): string; +} diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/index.d.ts b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/index.d.ts new file mode 100644 index 000000000..2ee7d9e93 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/index.d.ts @@ -0,0 +1,2 @@ +declare const _exports: typeof import('./validate').default; +export = _exports; diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/keywords/absolutePath.d.ts b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/keywords/absolutePath.d.ts new file mode 100644 index 000000000..6843dd638 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/keywords/absolutePath.d.ts @@ -0,0 +1,12 @@ +export default addAbsolutePathKeyword; +export type Ajv = import('ajv').Ajv; +export type ValidateFunction = import('ajv').ValidateFunction; +export type SchemaUtilErrorObject = import('ajv').ErrorObject & { + children?: import('ajv').ErrorObject[] | undefined; +}; +/** + * + * @param {Ajv} ajv + * @returns {Ajv} + */ +declare function addAbsolutePathKeyword(ajv: Ajv): Ajv; diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/util/Range.d.ts b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/util/Range.d.ts new file mode 100644 index 000000000..2f50521ba --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/util/Range.d.ts @@ -0,0 +1,82 @@ +export = Range; +/** + * @typedef {[number, boolean]} RangeValue + */ +/** + * @callback RangeValueCallback + * @param {RangeValue} rangeValue + * @returns {boolean} + */ +declare class Range { + /** + * @param {"left" | "right"} side + * @param {boolean} exclusive + * @returns {">" | ">=" | "<" | "<="} + */ + static getOperator( + side: 'left' | 'right', + exclusive: boolean + ): '>' | '>=' | '<' | '<='; + /** + * @param {number} value + * @param {boolean} logic is not logic applied + * @param {boolean} exclusive is range exclusive + * @returns {string} + */ + static formatRight(value: number, logic: boolean, exclusive: boolean): string; + /** + * @param {number} value + * @param {boolean} logic is not logic applied + * @param {boolean} exclusive is range exclusive + * @returns {string} + */ + static formatLeft(value: number, logic: boolean, exclusive: boolean): string; + /** + * @param {number} start left side value + * @param {number} end right side value + * @param {boolean} startExclusive is range exclusive from left side + * @param {boolean} endExclusive is range exclusive from right side + * @param {boolean} logic is not logic applied + * @returns {string} + */ + static formatRange( + start: number, + end: number, + startExclusive: boolean, + endExclusive: boolean, + logic: boolean + ): string; + /** + * @param {Array} values + * @param {boolean} logic is not logic applied + * @return {RangeValue} computed value and it's exclusive flag + */ + static getRangeValue( + values: Array, + logic: boolean + ): [number, boolean]; + /** @type {Array} */ + _left: Array; + /** @type {Array} */ + _right: Array; + /** + * @param {number} value + * @param {boolean=} exclusive + */ + left(value: number, exclusive?: boolean | undefined): void; + /** + * @param {number} value + * @param {boolean=} exclusive + */ + right(value: number, exclusive?: boolean | undefined): void; + /** + * @param {boolean} logic is not logic applied + * @return {string} "smart" range string representation + */ + format(logic?: boolean): string; +} +declare namespace Range { + export { RangeValue, RangeValueCallback }; +} +type RangeValue = [number, boolean]; +type RangeValueCallback = (rangeValue: [number, boolean]) => boolean; diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/util/hints.d.ts b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/util/hints.d.ts new file mode 100644 index 000000000..39412aa59 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/util/hints.d.ts @@ -0,0 +1,6 @@ +export function stringHints(schema: Schema, logic: boolean): string[]; +export function numberHints(schema: Schema, logic: boolean): string[]; +export type Schema = + | (import('json-schema').JSONSchema4 & import('../validate').Extend) + | (import('json-schema').JSONSchema6 & import('../validate').Extend) + | (import('json-schema').JSONSchema7 & import('../validate').Extend); diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/validate.d.ts b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/validate.d.ts new file mode 100644 index 000000000..995c2c8b4 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/declarations/validate.d.ts @@ -0,0 +1,44 @@ +export default validate; +export type JSONSchema4 = import('json-schema').JSONSchema4; +export type JSONSchema6 = import('json-schema').JSONSchema6; +export type JSONSchema7 = import('json-schema').JSONSchema7; +export type ErrorObject = Ajv.ErrorObject; +export type Extend = { + formatMinimum?: number | undefined; + formatMaximum?: number | undefined; + formatExclusiveMinimum?: boolean | undefined; + formatExclusiveMaximum?: boolean | undefined; +}; +export type Schema = + | (import('json-schema').JSONSchema4 & Extend) + | (import('json-schema').JSONSchema6 & Extend) + | (import('json-schema').JSONSchema7 & Extend); +export type SchemaUtilErrorObject = Ajv.ErrorObject & { + children?: Ajv.ErrorObject[] | undefined; +}; +export type PostFormatter = ( + formattedError: string, + error: SchemaUtilErrorObject +) => string; +export type ValidationErrorConfiguration = { + name?: string | undefined; + baseDataPath?: string | undefined; + postFormatter?: PostFormatter | undefined; +}; +/** + * @param {Schema} schema + * @param {Array | object} options + * @param {ValidationErrorConfiguration=} configuration + * @returns {void} + */ +declare function validate( + schema: Schema, + options: Array | object, + configuration?: ValidationErrorConfiguration | undefined +): void; +declare namespace validate { + export { ValidationError }; + export { ValidationError as ValidateError }; +} +import Ajv from 'ajv'; +import ValidationError from './ValidationError'; diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/ValidationError.js b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/ValidationError.js new file mode 100644 index 000000000..ae5bd94c8 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/ValidationError.js @@ -0,0 +1,1261 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +const { + stringHints, + numberHints +} = require('./util/hints'); +/** @typedef {import("json-schema").JSONSchema6} JSONSchema6 */ + +/** @typedef {import("json-schema").JSONSchema7} JSONSchema7 */ + +/** @typedef {import("./validate").Schema} Schema */ + +/** @typedef {import("./validate").ValidationErrorConfiguration} ValidationErrorConfiguration */ + +/** @typedef {import("./validate").PostFormatter} PostFormatter */ + +/** @typedef {import("./validate").SchemaUtilErrorObject} SchemaUtilErrorObject */ + +/** @enum {number} */ + + +const SPECIFICITY = { + type: 1, + not: 1, + oneOf: 1, + anyOf: 1, + if: 1, + enum: 1, + const: 1, + instanceof: 1, + required: 2, + pattern: 2, + patternRequired: 2, + format: 2, + formatMinimum: 2, + formatMaximum: 2, + minimum: 2, + exclusiveMinimum: 2, + maximum: 2, + exclusiveMaximum: 2, + multipleOf: 2, + uniqueItems: 2, + contains: 2, + minLength: 2, + maxLength: 2, + minItems: 2, + maxItems: 2, + minProperties: 2, + maxProperties: 2, + dependencies: 2, + propertyNames: 2, + additionalItems: 2, + additionalProperties: 2, + absolutePath: 2 +}; +/** + * + * @param {Array} array + * @param {(item: SchemaUtilErrorObject) => number} fn + * @returns {Array} + */ + +function filterMax(array, fn) { + const evaluatedMax = array.reduce((max, item) => Math.max(max, fn(item)), 0); + return array.filter(item => fn(item) === evaluatedMax); +} +/** + * + * @param {Array} children + * @returns {Array} + */ + + +function filterChildren(children) { + let newChildren = children; + newChildren = filterMax(newChildren, + /** + * + * @param {SchemaUtilErrorObject} error + * @returns {number} + */ + error => error.dataPath ? error.dataPath.length : 0); + newChildren = filterMax(newChildren, + /** + * @param {SchemaUtilErrorObject} error + * @returns {number} + */ + error => SPECIFICITY[ + /** @type {keyof typeof SPECIFICITY} */ + error.keyword] || 2); + return newChildren; +} +/** + * Find all children errors + * @param {Array} children + * @param {Array} schemaPaths + * @return {number} returns index of first child + */ + + +function findAllChildren(children, schemaPaths) { + let i = children.length - 1; + + const predicate = + /** + * @param {string} schemaPath + * @returns {boolean} + */ + schemaPath => children[i].schemaPath.indexOf(schemaPath) !== 0; + + while (i > -1 && !schemaPaths.every(predicate)) { + if (children[i].keyword === 'anyOf' || children[i].keyword === 'oneOf') { + const refs = extractRefs(children[i]); + const childrenStart = findAllChildren(children.slice(0, i), refs.concat(children[i].schemaPath)); + i = childrenStart - 1; + } else { + i -= 1; + } + } + + return i + 1; +} +/** + * Extracts all refs from schema + * @param {SchemaUtilErrorObject} error + * @return {Array} + */ + + +function extractRefs(error) { + const { + schema + } = error; + + if (!Array.isArray(schema)) { + return []; + } + + return schema.map(({ + $ref + }) => $ref).filter(s => s); +} +/** + * Groups children by their first level parent (assuming that error is root) + * @param {Array} children + * @return {Array} + */ + + +function groupChildrenByFirstChild(children) { + const result = []; + let i = children.length - 1; + + while (i > 0) { + const child = children[i]; + + if (child.keyword === 'anyOf' || child.keyword === 'oneOf') { + const refs = extractRefs(child); + const childrenStart = findAllChildren(children.slice(0, i), refs.concat(child.schemaPath)); + + if (childrenStart !== i) { + result.push(Object.assign({}, child, { + children: children.slice(childrenStart, i) + })); + i = childrenStart; + } else { + result.push(child); + } + } else { + result.push(child); + } + + i -= 1; + } + + if (i === 0) { + result.push(children[i]); + } + + return result.reverse(); +} +/** + * @param {string} str + * @param {string} prefix + * @returns {string} + */ + + +function indent(str, prefix) { + return str.replace(/\n(?!$)/g, `\n${prefix}`); +} +/** + * @param {Schema} schema + * @returns {schema is (Schema & {not: Schema})} + */ + + +function hasNotInSchema(schema) { + return !!schema.not; +} +/** + * @param {Schema} schema + * @return {Schema} + */ + + +function findFirstTypedSchema(schema) { + if (hasNotInSchema(schema)) { + return findFirstTypedSchema(schema.not); + } + + return schema; +} +/** + * @param {Schema} schema + * @return {boolean} + */ + + +function canApplyNot(schema) { + const typedSchema = findFirstTypedSchema(schema); + return likeNumber(typedSchema) || likeInteger(typedSchema) || likeString(typedSchema) || likeNull(typedSchema) || likeBoolean(typedSchema); +} +/** + * @param {any} maybeObj + * @returns {boolean} + */ + + +function isObject(maybeObj) { + return typeof maybeObj === 'object' && maybeObj !== null; +} +/** + * @param {Schema} schema + * @returns {boolean} + */ + + +function likeNumber(schema) { + return schema.type === 'number' || typeof schema.minimum !== 'undefined' || typeof schema.exclusiveMinimum !== 'undefined' || typeof schema.maximum !== 'undefined' || typeof schema.exclusiveMaximum !== 'undefined' || typeof schema.multipleOf !== 'undefined'; +} +/** + * @param {Schema} schema + * @returns {boolean} + */ + + +function likeInteger(schema) { + return schema.type === 'integer' || typeof schema.minimum !== 'undefined' || typeof schema.exclusiveMinimum !== 'undefined' || typeof schema.maximum !== 'undefined' || typeof schema.exclusiveMaximum !== 'undefined' || typeof schema.multipleOf !== 'undefined'; +} +/** + * @param {Schema} schema + * @returns {boolean} + */ + + +function likeString(schema) { + return schema.type === 'string' || typeof schema.minLength !== 'undefined' || typeof schema.maxLength !== 'undefined' || typeof schema.pattern !== 'undefined' || typeof schema.format !== 'undefined' || typeof schema.formatMinimum !== 'undefined' || typeof schema.formatMaximum !== 'undefined'; +} +/** + * @param {Schema} schema + * @returns {boolean} + */ + + +function likeBoolean(schema) { + return schema.type === 'boolean'; +} +/** + * @param {Schema} schema + * @returns {boolean} + */ + + +function likeArray(schema) { + return schema.type === 'array' || typeof schema.minItems === 'number' || typeof schema.maxItems === 'number' || typeof schema.uniqueItems !== 'undefined' || typeof schema.items !== 'undefined' || typeof schema.additionalItems !== 'undefined' || typeof schema.contains !== 'undefined'; +} +/** + * @param {Schema & {patternRequired?: Array}} schema + * @returns {boolean} + */ + + +function likeObject(schema) { + return schema.type === 'object' || typeof schema.minProperties !== 'undefined' || typeof schema.maxProperties !== 'undefined' || typeof schema.required !== 'undefined' || typeof schema.properties !== 'undefined' || typeof schema.patternProperties !== 'undefined' || typeof schema.additionalProperties !== 'undefined' || typeof schema.dependencies !== 'undefined' || typeof schema.propertyNames !== 'undefined' || typeof schema.patternRequired !== 'undefined'; +} +/** + * @param {Schema} schema + * @returns {boolean} + */ + + +function likeNull(schema) { + return schema.type === 'null'; +} +/** + * @param {string} type + * @returns {string} + */ + + +function getArticle(type) { + if (/^[aeiou]/i.test(type)) { + return 'an'; + } + + return 'a'; +} +/** + * @param {Schema=} schema + * @returns {string} + */ + + +function getSchemaNonTypes(schema) { + if (!schema) { + return ''; + } + + if (!schema.type) { + if (likeNumber(schema) || likeInteger(schema)) { + return ' | should be any non-number'; + } + + if (likeString(schema)) { + return ' | should be any non-string'; + } + + if (likeArray(schema)) { + return ' | should be any non-array'; + } + + if (likeObject(schema)) { + return ' | should be any non-object'; + } + } + + return ''; +} +/** + * @param {Array} hints + * @returns {string} + */ + + +function formatHints(hints) { + return hints.length > 0 ? `(${hints.join(', ')})` : ''; +} +/** + * @param {Schema} schema + * @param {boolean} logic + * @returns {string[]} + */ + + +function getHints(schema, logic) { + if (likeNumber(schema) || likeInteger(schema)) { + return numberHints(schema, logic); + } else if (likeString(schema)) { + return stringHints(schema, logic); + } + + return []; +} + +class ValidationError extends Error { + /** + * @param {Array} errors + * @param {Schema} schema + * @param {ValidationErrorConfiguration} configuration + */ + constructor(errors, schema, configuration = {}) { + super(); + /** @type {string} */ + + this.name = 'ValidationError'; + /** @type {Array} */ + + this.errors = errors; + /** @type {Schema} */ + + this.schema = schema; + let headerNameFromSchema; + let baseDataPathFromSchema; + + if (schema.title && (!configuration.name || !configuration.baseDataPath)) { + const splittedTitleFromSchema = schema.title.match(/^(.+) (.+)$/); + + if (splittedTitleFromSchema) { + if (!configuration.name) { + [, headerNameFromSchema] = splittedTitleFromSchema; + } + + if (!configuration.baseDataPath) { + [,, baseDataPathFromSchema] = splittedTitleFromSchema; + } + } + } + /** @type {string} */ + + + this.headerName = configuration.name || headerNameFromSchema || 'Object'; + /** @type {string} */ + + this.baseDataPath = configuration.baseDataPath || baseDataPathFromSchema || 'configuration'; + /** @type {PostFormatter | null} */ + + this.postFormatter = configuration.postFormatter || null; + const header = `Invalid ${this.baseDataPath} object. ${this.headerName} has been initialized using ${getArticle(this.baseDataPath)} ${this.baseDataPath} object that does not match the API schema.\n`; + /** @type {string} */ + + this.message = `${header}${this.formatValidationErrors(errors)}`; + Error.captureStackTrace(this, this.constructor); + } + /** + * @param {string} path + * @returns {Schema} + */ + + + getSchemaPart(path) { + const newPath = path.split('/'); + let schemaPart = this.schema; + + for (let i = 1; i < newPath.length; i++) { + const inner = schemaPart[ + /** @type {keyof Schema} */ + newPath[i]]; + + if (!inner) { + break; + } + + schemaPart = inner; + } + + return schemaPart; + } + /** + * @param {Schema} schema + * @param {boolean} logic + * @param {Array} prevSchemas + * @returns {string} + */ + + + formatSchema(schema, logic = true, prevSchemas = []) { + let newLogic = logic; + + const formatInnerSchema = + /** + * + * @param {Object} innerSchema + * @param {boolean=} addSelf + * @returns {string} + */ + (innerSchema, addSelf) => { + if (!addSelf) { + return this.formatSchema(innerSchema, newLogic, prevSchemas); + } + + if (prevSchemas.includes(innerSchema)) { + return '(recursive)'; + } + + return this.formatSchema(innerSchema, newLogic, prevSchemas.concat(schema)); + }; + + if (hasNotInSchema(schema) && !likeObject(schema)) { + if (canApplyNot(schema.not)) { + newLogic = !logic; + return formatInnerSchema(schema.not); + } + + const needApplyLogicHere = !schema.not.not; + const prefix = logic ? '' : 'non '; + newLogic = !logic; + return needApplyLogicHere ? prefix + formatInnerSchema(schema.not) : formatInnerSchema(schema.not); + } + + if ( + /** @type {Schema & {instanceof: string | Array}} */ + schema.instanceof) { + const { + instanceof: value + } = + /** @type {Schema & {instanceof: string | Array}} */ + schema; + const values = !Array.isArray(value) ? [value] : value; + return values.map( + /** + * @param {string} item + * @returns {string} + */ + item => item === 'Function' ? 'function' : item).join(' | '); + } + + if (schema.enum) { + return ( + /** @type {Array} */ + schema.enum.map(item => JSON.stringify(item)).join(' | ') + ); + } + + if (typeof schema.const !== 'undefined') { + return JSON.stringify(schema.const); + } + + if (schema.oneOf) { + return ( + /** @type {Array} */ + schema.oneOf.map(item => formatInnerSchema(item, true)).join(' | ') + ); + } + + if (schema.anyOf) { + return ( + /** @type {Array} */ + schema.anyOf.map(item => formatInnerSchema(item, true)).join(' | ') + ); + } + + if (schema.allOf) { + return ( + /** @type {Array} */ + schema.allOf.map(item => formatInnerSchema(item, true)).join(' & ') + ); + } + + if ( + /** @type {JSONSchema7} */ + schema.if) { + const { + if: ifValue, + then: thenValue, + else: elseValue + } = + /** @type {JSONSchema7} */ + schema; + return `${ifValue ? `if ${formatInnerSchema(ifValue)}` : ''}${thenValue ? ` then ${formatInnerSchema(thenValue)}` : ''}${elseValue ? ` else ${formatInnerSchema(elseValue)}` : ''}`; + } + + if (schema.$ref) { + return formatInnerSchema(this.getSchemaPart(schema.$ref), true); + } + + if (likeNumber(schema) || likeInteger(schema)) { + const [type, ...hints] = getHints(schema, logic); + const str = `${type}${hints.length > 0 ? ` ${formatHints(hints)}` : ''}`; + return logic ? str : hints.length > 0 ? `non-${type} | ${str}` : `non-${type}`; + } + + if (likeString(schema)) { + const [type, ...hints] = getHints(schema, logic); + const str = `${type}${hints.length > 0 ? ` ${formatHints(hints)}` : ''}`; + return logic ? str : str === 'string' ? 'non-string' : `non-string | ${str}`; + } + + if (likeBoolean(schema)) { + return `${logic ? '' : 'non-'}boolean`; + } + + if (likeArray(schema)) { + // not logic already applied in formatValidationError + newLogic = true; + const hints = []; + + if (typeof schema.minItems === 'number') { + hints.push(`should not have fewer than ${schema.minItems} item${schema.minItems > 1 ? 's' : ''}`); + } + + if (typeof schema.maxItems === 'number') { + hints.push(`should not have more than ${schema.maxItems} item${schema.maxItems > 1 ? 's' : ''}`); + } + + if (schema.uniqueItems) { + hints.push('should not have duplicate items'); + } + + const hasAdditionalItems = typeof schema.additionalItems === 'undefined' || Boolean(schema.additionalItems); + let items = ''; + + if (schema.items) { + if (Array.isArray(schema.items) && schema.items.length > 0) { + items = `${ + /** @type {Array} */ + schema.items.map(item => formatInnerSchema(item)).join(', ')}`; + + if (hasAdditionalItems) { + if (schema.additionalItems && isObject(schema.additionalItems) && Object.keys(schema.additionalItems).length > 0) { + hints.push(`additional items should be ${formatInnerSchema(schema.additionalItems)}`); + } + } + } else if (schema.items && Object.keys(schema.items).length > 0) { + // "additionalItems" is ignored + items = `${formatInnerSchema(schema.items)}`; + } else { + // Fallback for empty `items` value + items = 'any'; + } + } else { + // "additionalItems" is ignored + items = 'any'; + } + + if (schema.contains && Object.keys(schema.contains).length > 0) { + hints.push(`should contains at least one ${this.formatSchema(schema.contains)} item`); + } + + return `[${items}${hasAdditionalItems ? ', ...' : ''}]${hints.length > 0 ? ` (${hints.join(', ')})` : ''}`; + } + + if (likeObject(schema)) { + // not logic already applied in formatValidationError + newLogic = true; + const hints = []; + + if (typeof schema.minProperties === 'number') { + hints.push(`should not have fewer than ${schema.minProperties} ${schema.minProperties > 1 ? 'properties' : 'property'}`); + } + + if (typeof schema.maxProperties === 'number') { + hints.push(`should not have more than ${schema.maxProperties} ${schema.minProperties && schema.minProperties > 1 ? 'properties' : 'property'}`); + } + + if (schema.patternProperties && Object.keys(schema.patternProperties).length > 0) { + const patternProperties = Object.keys(schema.patternProperties); + hints.push(`additional property names should match pattern${patternProperties.length > 1 ? 's' : ''} ${patternProperties.map(pattern => JSON.stringify(pattern)).join(' | ')}`); + } + + const properties = schema.properties ? Object.keys(schema.properties) : []; + const required = schema.required ? schema.required : []; + const allProperties = [...new Set( + /** @type {Array} */ + [].concat(required).concat(properties))]; + const objectStructure = allProperties.map(property => { + const isRequired = required.includes(property); // Some properties need quotes, maybe we should add check + // Maybe we should output type of property (`foo: string`), but it is looks very unreadable + + return `${property}${isRequired ? '' : '?'}`; + }).concat(typeof schema.additionalProperties === 'undefined' || Boolean(schema.additionalProperties) ? schema.additionalProperties && isObject(schema.additionalProperties) ? [`: ${formatInnerSchema(schema.additionalProperties)}`] : ['…'] : []).join(', '); + const { + dependencies, + propertyNames, + patternRequired + } = + /** @type {Schema & {patternRequired?: Array;}} */ + schema; + + if (dependencies) { + Object.keys(dependencies).forEach(dependencyName => { + const dependency = dependencies[dependencyName]; + + if (Array.isArray(dependency)) { + hints.push(`should have ${dependency.length > 1 ? 'properties' : 'property'} ${dependency.map(dep => `'${dep}'`).join(', ')} when property '${dependencyName}' is present`); + } else { + hints.push(`should be valid according to the schema ${formatInnerSchema(dependency)} when property '${dependencyName}' is present`); + } + }); + } + + if (propertyNames && Object.keys(propertyNames).length > 0) { + hints.push(`each property name should match format ${JSON.stringify(schema.propertyNames.format)}`); + } + + if (patternRequired && patternRequired.length > 0) { + hints.push(`should have property matching pattern ${patternRequired.map( + /** + * @param {string} item + * @returns {string} + */ + item => JSON.stringify(item))}`); + } + + return `object {${objectStructure ? ` ${objectStructure} ` : ''}}${hints.length > 0 ? ` (${hints.join(', ')})` : ''}`; + } + + if (likeNull(schema)) { + return `${logic ? '' : 'non-'}null`; + } + + if (Array.isArray(schema.type)) { + // not logic already applied in formatValidationError + return `${schema.type.join(' | ')}`; + } // Fallback for unknown keywords + // not logic already applied in formatValidationError + + /* istanbul ignore next */ + + + return JSON.stringify(schema, null, 2); + } + /** + * @param {Schema=} schemaPart + * @param {(boolean | Array)=} additionalPath + * @param {boolean=} needDot + * @param {boolean=} logic + * @returns {string} + */ + + + getSchemaPartText(schemaPart, additionalPath, needDot = false, logic = true) { + if (!schemaPart) { + return ''; + } + + if (Array.isArray(additionalPath)) { + for (let i = 0; i < additionalPath.length; i++) { + /** @type {Schema | undefined} */ + const inner = schemaPart[ + /** @type {keyof Schema} */ + additionalPath[i]]; + + if (inner) { + // eslint-disable-next-line no-param-reassign + schemaPart = inner; + } else { + break; + } + } + } + + while (schemaPart.$ref) { + // eslint-disable-next-line no-param-reassign + schemaPart = this.getSchemaPart(schemaPart.$ref); + } + + let schemaText = `${this.formatSchema(schemaPart, logic)}${needDot ? '.' : ''}`; + + if (schemaPart.description) { + schemaText += `\n-> ${schemaPart.description}`; + } + + return schemaText; + } + /** + * @param {Schema=} schemaPart + * @returns {string} + */ + + + getSchemaPartDescription(schemaPart) { + if (!schemaPart) { + return ''; + } + + while (schemaPart.$ref) { + // eslint-disable-next-line no-param-reassign + schemaPart = this.getSchemaPart(schemaPart.$ref); + } + + if (schemaPart.description) { + return `\n-> ${schemaPart.description}`; + } + + return ''; + } + /** + * @param {SchemaUtilErrorObject} error + * @returns {string} + */ + + + formatValidationError(error) { + const { + keyword, + dataPath: errorDataPath + } = error; + const dataPath = `${this.baseDataPath}${errorDataPath}`; + + switch (keyword) { + case 'type': + { + const { + parentSchema, + params + } = error; // eslint-disable-next-line default-case + + switch ( + /** @type {import("ajv").TypeParams} */ + params.type) { + case 'number': + return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; + + case 'integer': + return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; + + case 'string': + return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; + + case 'boolean': + return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; + + case 'array': + return `${dataPath} should be an array:\n${this.getSchemaPartText(parentSchema)}`; + + case 'object': + return `${dataPath} should be an object:\n${this.getSchemaPartText(parentSchema)}`; + + case 'null': + return `${dataPath} should be a ${this.getSchemaPartText(parentSchema, false, true)}`; + + default: + return `${dataPath} should be:\n${this.getSchemaPartText(parentSchema)}`; + } + } + + case 'instanceof': + { + const { + parentSchema + } = error; + return `${dataPath} should be an instance of ${this.getSchemaPartText(parentSchema, false, true)}`; + } + + case 'pattern': + { + const { + params, + parentSchema + } = error; + const { + pattern + } = + /** @type {import("ajv").PatternParams} */ + params; + return `${dataPath} should match pattern ${JSON.stringify(pattern)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'format': + { + const { + params, + parentSchema + } = error; + const { + format + } = + /** @type {import("ajv").FormatParams} */ + params; + return `${dataPath} should match format ${JSON.stringify(format)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'formatMinimum': + case 'formatMaximum': + { + const { + params, + parentSchema + } = error; + const { + comparison, + limit + } = + /** @type {import("ajv").ComparisonParams} */ + params; + return `${dataPath} should be ${comparison} ${JSON.stringify(limit)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'minimum': + case 'maximum': + case 'exclusiveMinimum': + case 'exclusiveMaximum': + { + const { + parentSchema, + params + } = error; + const { + comparison, + limit + } = + /** @type {import("ajv").ComparisonParams} */ + params; + const [, ...hints] = getHints( + /** @type {Schema} */ + parentSchema, true); + + if (hints.length === 0) { + hints.push(`should be ${comparison} ${limit}`); + } + + return `${dataPath} ${hints.join(' ')}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'multipleOf': + { + const { + params, + parentSchema + } = error; + const { + multipleOf + } = + /** @type {import("ajv").MultipleOfParams} */ + params; + return `${dataPath} should be multiple of ${multipleOf}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'patternRequired': + { + const { + params, + parentSchema + } = error; + const { + missingPattern + } = + /** @type {import("ajv").PatternRequiredParams} */ + params; + return `${dataPath} should have property matching pattern ${JSON.stringify(missingPattern)}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'minLength': + { + const { + params, + parentSchema + } = error; + const { + limit + } = + /** @type {import("ajv").LimitParams} */ + params; + + if (limit === 1) { + return `${dataPath} should be an non-empty string${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + const length = limit - 1; + return `${dataPath} should be longer than ${length} character${length > 1 ? 's' : ''}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'minItems': + { + const { + params, + parentSchema + } = error; + const { + limit + } = + /** @type {import("ajv").LimitParams} */ + params; + + if (limit === 1) { + return `${dataPath} should be an non-empty array${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + return `${dataPath} should not have fewer than ${limit} items${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'minProperties': + { + const { + params, + parentSchema + } = error; + const { + limit + } = + /** @type {import("ajv").LimitParams} */ + params; + + if (limit === 1) { + return `${dataPath} should be an non-empty object${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + return `${dataPath} should not have fewer than ${limit} properties${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'maxLength': + { + const { + params, + parentSchema + } = error; + const { + limit + } = + /** @type {import("ajv").LimitParams} */ + params; + const max = limit + 1; + return `${dataPath} should be shorter than ${max} character${max > 1 ? 's' : ''}${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'maxItems': + { + const { + params, + parentSchema + } = error; + const { + limit + } = + /** @type {import("ajv").LimitParams} */ + params; + return `${dataPath} should not have more than ${limit} items${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'maxProperties': + { + const { + params, + parentSchema + } = error; + const { + limit + } = + /** @type {import("ajv").LimitParams} */ + params; + return `${dataPath} should not have more than ${limit} properties${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'uniqueItems': + { + const { + params, + parentSchema + } = error; + const { + i + } = + /** @type {import("ajv").UniqueItemsParams} */ + params; + return `${dataPath} should not contain the item '${error.data[i]}' twice${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'additionalItems': + { + const { + params, + parentSchema + } = error; + const { + limit + } = + /** @type {import("ajv").LimitParams} */ + params; + return `${dataPath} should not have more than ${limit} items${getSchemaNonTypes(parentSchema)}. These items are valid:\n${this.getSchemaPartText(parentSchema)}`; + } + + case 'contains': + { + const { + parentSchema + } = error; + return `${dataPath} should contains at least one ${this.getSchemaPartText(parentSchema, ['contains'])} item${getSchemaNonTypes(parentSchema)}.`; + } + + case 'required': + { + const { + parentSchema, + params + } = error; + const missingProperty = + /** @type {import("ajv").DependenciesParams} */ + params.missingProperty.replace(/^\./, ''); + const hasProperty = parentSchema && Boolean( + /** @type {Schema} */ + parentSchema.properties && + /** @type {Schema} */ + parentSchema.properties[missingProperty]); + return `${dataPath} misses the property '${missingProperty}'${getSchemaNonTypes(parentSchema)}.${hasProperty ? ` Should be:\n${this.getSchemaPartText(parentSchema, ['properties', missingProperty])}` : this.getSchemaPartDescription(parentSchema)}`; + } + + case 'additionalProperties': + { + const { + params, + parentSchema + } = error; + const { + additionalProperty + } = + /** @type {import("ajv").AdditionalPropertiesParams} */ + params; + return `${dataPath} has an unknown property '${additionalProperty}'${getSchemaNonTypes(parentSchema)}. These properties are valid:\n${this.getSchemaPartText(parentSchema)}`; + } + + case 'dependencies': + { + const { + params, + parentSchema + } = error; + const { + property, + deps + } = + /** @type {import("ajv").DependenciesParams} */ + params; + const dependencies = deps.split(',').map( + /** + * @param {string} dep + * @returns {string} + */ + dep => `'${dep.trim()}'`).join(', '); + return `${dataPath} should have properties ${dependencies} when property '${property}' is present${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'propertyNames': + { + const { + params, + parentSchema, + schema + } = error; + const { + propertyName + } = + /** @type {import("ajv").PropertyNamesParams} */ + params; + return `${dataPath} property name '${propertyName}' is invalid${getSchemaNonTypes(parentSchema)}. Property names should be match format ${JSON.stringify(schema.format)}.${this.getSchemaPartDescription(parentSchema)}`; + } + + case 'enum': + { + const { + parentSchema + } = error; + + if (parentSchema && + /** @type {Schema} */ + parentSchema.enum && + /** @type {Schema} */ + parentSchema.enum.length === 1) { + return `${dataPath} should be ${this.getSchemaPartText(parentSchema, false, true)}`; + } + + return `${dataPath} should be one of these:\n${this.getSchemaPartText(parentSchema)}`; + } + + case 'const': + { + const { + parentSchema + } = error; + return `${dataPath} should be equal to constant ${this.getSchemaPartText(parentSchema, false, true)}`; + } + + case 'not': + { + const postfix = likeObject( + /** @type {Schema} */ + error.parentSchema) ? `\n${this.getSchemaPartText(error.parentSchema)}` : ''; + const schemaOutput = this.getSchemaPartText(error.schema, false, false, false); + + if (canApplyNot(error.schema)) { + return `${dataPath} should be any ${schemaOutput}${postfix}.`; + } + + const { + schema, + parentSchema + } = error; + return `${dataPath} should not be ${this.getSchemaPartText(schema, false, true)}${parentSchema && likeObject(parentSchema) ? `\n${this.getSchemaPartText(parentSchema)}` : ''}`; + } + + case 'oneOf': + case 'anyOf': + { + const { + parentSchema, + children + } = error; + + if (children && children.length > 0) { + if (error.schema.length === 1) { + const lastChild = children[children.length - 1]; + const remainingChildren = children.slice(0, children.length - 1); + return this.formatValidationError(Object.assign({}, lastChild, { + children: remainingChildren, + parentSchema: Object.assign({}, parentSchema, lastChild.parentSchema) + })); + } + + let filteredChildren = filterChildren(children); + + if (filteredChildren.length === 1) { + return this.formatValidationError(filteredChildren[0]); + } + + filteredChildren = groupChildrenByFirstChild(filteredChildren); + return `${dataPath} should be one of these:\n${this.getSchemaPartText(parentSchema)}\nDetails:\n${filteredChildren.map( + /** + * @param {SchemaUtilErrorObject} nestedError + * @returns {string} + */ + nestedError => ` * ${indent(this.formatValidationError(nestedError), ' ')}`).join('\n')}`; + } + + return `${dataPath} should be one of these:\n${this.getSchemaPartText(parentSchema)}`; + } + + case 'if': + { + const { + params, + parentSchema + } = error; + const { + failingKeyword + } = + /** @type {import("ajv").IfParams} */ + params; + return `${dataPath} should match "${failingKeyword}" schema:\n${this.getSchemaPartText(parentSchema, [failingKeyword])}`; + } + + case 'absolutePath': + { + const { + message, + parentSchema + } = error; + return `${dataPath}: ${message}${this.getSchemaPartDescription(parentSchema)}`; + } + + /* istanbul ignore next */ + + default: + { + const { + message, + parentSchema + } = error; + const ErrorInJSON = JSON.stringify(error, null, 2); // For `custom`, `false schema`, `$ref` keywords + // Fallback for unknown keywords + + return `${dataPath} ${message} (${ErrorInJSON}).\n${this.getSchemaPartText(parentSchema, false)}`; + } + } + } + /** + * @param {Array} errors + * @returns {string} + */ + + + formatValidationErrors(errors) { + return errors.map(error => { + let formattedError = this.formatValidationError(error); + + if (this.postFormatter) { + formattedError = this.postFormatter(formattedError, error); + } + + return ` - ${indent(formattedError, ' ')}`; + }).join('\n'); + } + +} + +var _default = ValidationError; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/index.js b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/index.js new file mode 100644 index 000000000..e7c679174 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/index.js @@ -0,0 +1,5 @@ +"use strict"; + +const validate = require('./validate'); + +module.exports = validate.default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/keywords/absolutePath.js b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/keywords/absolutePath.js new file mode 100644 index 000000000..1ff958f25 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/keywords/absolutePath.js @@ -0,0 +1,93 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +/** @typedef {import("ajv").Ajv} Ajv */ + +/** @typedef {import("ajv").ValidateFunction} ValidateFunction */ + +/** @typedef {import("../validate").SchemaUtilErrorObject} SchemaUtilErrorObject */ + +/** + * @param {string} message + * @param {object} schema + * @param {string} data + * @returns {SchemaUtilErrorObject} + */ +function errorMessage(message, schema, data) { + return { + // @ts-ignore + // eslint-disable-next-line no-undefined + dataPath: undefined, + // @ts-ignore + // eslint-disable-next-line no-undefined + schemaPath: undefined, + keyword: 'absolutePath', + params: { + absolutePath: data + }, + message, + parentSchema: schema + }; +} +/** + * @param {boolean} shouldBeAbsolute + * @param {object} schema + * @param {string} data + * @returns {SchemaUtilErrorObject} + */ + + +function getErrorFor(shouldBeAbsolute, schema, data) { + const message = shouldBeAbsolute ? `The provided value ${JSON.stringify(data)} is not an absolute path!` : `A relative path is expected. However, the provided value ${JSON.stringify(data)} is an absolute path!`; + return errorMessage(message, schema, data); +} +/** + * + * @param {Ajv} ajv + * @returns {Ajv} + */ + + +function addAbsolutePathKeyword(ajv) { + ajv.addKeyword('absolutePath', { + errors: true, + type: 'string', + + compile(schema, parentSchema) { + /** @type {ValidateFunction} */ + const callback = data => { + let passes = true; + const isExclamationMarkPresent = data.includes('!'); + + if (isExclamationMarkPresent) { + callback.errors = [errorMessage(`The provided value ${JSON.stringify(data)} contains exclamation mark (!) which is not allowed because it's reserved for loader syntax.`, parentSchema, data)]; + passes = false; + } // ?:[A-Za-z]:\\ - Windows absolute path + // \\\\ - Windows network absolute path + // \/ - Unix-like OS absolute path + + + const isCorrectAbsolutePath = schema === /^(?:[A-Za-z]:(\\|\/)|\\\\|\/)/.test(data); + + if (!isCorrectAbsolutePath) { + callback.errors = [getErrorFor(schema, parentSchema, data)]; + passes = false; + } + + return passes; + }; + + callback.errors = []; + return callback; + } + + }); + return ajv; +} + +var _default = addAbsolutePathKeyword; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/util/Range.js b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/util/Range.js new file mode 100644 index 000000000..74bb05724 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/util/Range.js @@ -0,0 +1,163 @@ +"use strict"; + +/** + * @typedef {[number, boolean]} RangeValue + */ + +/** + * @callback RangeValueCallback + * @param {RangeValue} rangeValue + * @returns {boolean} + */ +class Range { + /** + * @param {"left" | "right"} side + * @param {boolean} exclusive + * @returns {">" | ">=" | "<" | "<="} + */ + static getOperator(side, exclusive) { + if (side === 'left') { + return exclusive ? '>' : '>='; + } + + return exclusive ? '<' : '<='; + } + /** + * @param {number} value + * @param {boolean} logic is not logic applied + * @param {boolean} exclusive is range exclusive + * @returns {string} + */ + + + static formatRight(value, logic, exclusive) { + if (logic === false) { + return Range.formatLeft(value, !logic, !exclusive); + } + + return `should be ${Range.getOperator('right', exclusive)} ${value}`; + } + /** + * @param {number} value + * @param {boolean} logic is not logic applied + * @param {boolean} exclusive is range exclusive + * @returns {string} + */ + + + static formatLeft(value, logic, exclusive) { + if (logic === false) { + return Range.formatRight(value, !logic, !exclusive); + } + + return `should be ${Range.getOperator('left', exclusive)} ${value}`; + } + /** + * @param {number} start left side value + * @param {number} end right side value + * @param {boolean} startExclusive is range exclusive from left side + * @param {boolean} endExclusive is range exclusive from right side + * @param {boolean} logic is not logic applied + * @returns {string} + */ + + + static formatRange(start, end, startExclusive, endExclusive, logic) { + let result = 'should be'; + result += ` ${Range.getOperator(logic ? 'left' : 'right', logic ? startExclusive : !startExclusive)} ${start} `; + result += logic ? 'and' : 'or'; + result += ` ${Range.getOperator(logic ? 'right' : 'left', logic ? endExclusive : !endExclusive)} ${end}`; + return result; + } + /** + * @param {Array} values + * @param {boolean} logic is not logic applied + * @return {RangeValue} computed value and it's exclusive flag + */ + + + static getRangeValue(values, logic) { + let minMax = logic ? Infinity : -Infinity; + let j = -1; + const predicate = logic ? + /** @type {RangeValueCallback} */ + ([value]) => value <= minMax : + /** @type {RangeValueCallback} */ + ([value]) => value >= minMax; + + for (let i = 0; i < values.length; i++) { + if (predicate(values[i])) { + [minMax] = values[i]; + j = i; + } + } + + if (j > -1) { + return values[j]; + } + + return [Infinity, true]; + } + + constructor() { + /** @type {Array} */ + this._left = []; + /** @type {Array} */ + + this._right = []; + } + /** + * @param {number} value + * @param {boolean=} exclusive + */ + + + left(value, exclusive = false) { + this._left.push([value, exclusive]); + } + /** + * @param {number} value + * @param {boolean=} exclusive + */ + + + right(value, exclusive = false) { + this._right.push([value, exclusive]); + } + /** + * @param {boolean} logic is not logic applied + * @return {string} "smart" range string representation + */ + + + format(logic = true) { + const [start, leftExclusive] = Range.getRangeValue(this._left, logic); + const [end, rightExclusive] = Range.getRangeValue(this._right, !logic); + + if (!Number.isFinite(start) && !Number.isFinite(end)) { + return ''; + } + + const realStart = leftExclusive ? start + 1 : start; + const realEnd = rightExclusive ? end - 1 : end; // e.g. 5 < x < 7, 5 < x <= 6, 6 <= x <= 6 + + if (realStart === realEnd) { + return `should be ${logic ? '' : '!'}= ${realStart}`; + } // e.g. 4 < x < ∞ + + + if (Number.isFinite(start) && !Number.isFinite(end)) { + return Range.formatLeft(start, logic, leftExclusive); + } // e.g. ∞ < x < 4 + + + if (!Number.isFinite(start) && Number.isFinite(end)) { + return Range.formatRight(end, logic, rightExclusive); + } + + return Range.formatRange(start, end, leftExclusive, rightExclusive, logic); + } + +} + +module.exports = Range; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/util/hints.js b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/util/hints.js new file mode 100644 index 000000000..afa00d543 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/util/hints.js @@ -0,0 +1,105 @@ +"use strict"; + +const Range = require('./Range'); +/** @typedef {import("../validate").Schema} Schema */ + +/** + * @param {Schema} schema + * @param {boolean} logic + * @return {string[]} + */ + + +module.exports.stringHints = function stringHints(schema, logic) { + const hints = []; + let type = 'string'; + const currentSchema = { ...schema + }; + + if (!logic) { + const tmpLength = currentSchema.minLength; + const tmpFormat = currentSchema.formatMinimum; + const tmpExclusive = currentSchema.formatExclusiveMaximum; + currentSchema.minLength = currentSchema.maxLength; + currentSchema.maxLength = tmpLength; + currentSchema.formatMinimum = currentSchema.formatMaximum; + currentSchema.formatMaximum = tmpFormat; + currentSchema.formatExclusiveMaximum = !currentSchema.formatExclusiveMinimum; + currentSchema.formatExclusiveMinimum = !tmpExclusive; + } + + if (typeof currentSchema.minLength === 'number') { + if (currentSchema.minLength === 1) { + type = 'non-empty string'; + } else { + const length = Math.max(currentSchema.minLength - 1, 0); + hints.push(`should be longer than ${length} character${length > 1 ? 's' : ''}`); + } + } + + if (typeof currentSchema.maxLength === 'number') { + if (currentSchema.maxLength === 0) { + type = 'empty string'; + } else { + const length = currentSchema.maxLength + 1; + hints.push(`should be shorter than ${length} character${length > 1 ? 's' : ''}`); + } + } + + if (currentSchema.pattern) { + hints.push(`should${logic ? '' : ' not'} match pattern ${JSON.stringify(currentSchema.pattern)}`); + } + + if (currentSchema.format) { + hints.push(`should${logic ? '' : ' not'} match format ${JSON.stringify(currentSchema.format)}`); + } + + if (currentSchema.formatMinimum) { + hints.push(`should be ${currentSchema.formatExclusiveMinimum ? '>' : '>='} ${JSON.stringify(currentSchema.formatMinimum)}`); + } + + if (currentSchema.formatMaximum) { + hints.push(`should be ${currentSchema.formatExclusiveMaximum ? '<' : '<='} ${JSON.stringify(currentSchema.formatMaximum)}`); + } + + return [type].concat(hints); +}; +/** + * @param {Schema} schema + * @param {boolean} logic + * @return {string[]} + */ + + +module.exports.numberHints = function numberHints(schema, logic) { + const hints = [schema.type === 'integer' ? 'integer' : 'number']; + const range = new Range(); + + if (typeof schema.minimum === 'number') { + range.left(schema.minimum); + } + + if (typeof schema.exclusiveMinimum === 'number') { + range.left(schema.exclusiveMinimum, true); + } + + if (typeof schema.maximum === 'number') { + range.right(schema.maximum); + } + + if (typeof schema.exclusiveMaximum === 'number') { + range.right(schema.exclusiveMaximum, true); + } + + const rangeFormat = range.format(logic); + + if (rangeFormat) { + hints.push(rangeFormat); + } + + if (typeof schema.multipleOf === 'number') { + hints.push(`should${logic ? '' : ' not'} be multiple of ${schema.multipleOf}`); + } + + return hints; +}; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/validate.js b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/validate.js new file mode 100644 index 000000000..ebc660f3f --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/dist/validate.js @@ -0,0 +1,160 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _ajv = _interopRequireDefault(require("ajv")); + +var _ajvKeywords = _interopRequireDefault(require("ajv-keywords")); + +var _absolutePath = _interopRequireDefault(require("./keywords/absolutePath")); + +var _ValidationError = _interopRequireDefault(require("./ValidationError")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @typedef {import("json-schema").JSONSchema4} JSONSchema4 */ + +/** @typedef {import("json-schema").JSONSchema6} JSONSchema6 */ + +/** @typedef {import("json-schema").JSONSchema7} JSONSchema7 */ + +/** @typedef {import("ajv").ErrorObject} ErrorObject */ + +/** + * @typedef {Object} Extend + * @property {number=} formatMinimum + * @property {number=} formatMaximum + * @property {boolean=} formatExclusiveMinimum + * @property {boolean=} formatExclusiveMaximum + */ + +/** @typedef {(JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend} Schema */ + +/** @typedef {ErrorObject & { children?: Array}} SchemaUtilErrorObject */ + +/** + * @callback PostFormatter + * @param {string} formattedError + * @param {SchemaUtilErrorObject} error + * @returns {string} + */ + +/** + * @typedef {Object} ValidationErrorConfiguration + * @property {string=} name + * @property {string=} baseDataPath + * @property {PostFormatter=} postFormatter + */ +const ajv = new _ajv.default({ + allErrors: true, + verbose: true, + $data: true +}); +(0, _ajvKeywords.default)(ajv, ['instanceof', 'formatMinimum', 'formatMaximum', 'patternRequired']); // Custom keywords + +(0, _absolutePath.default)(ajv); +/** + * @param {Schema} schema + * @param {Array | object} options + * @param {ValidationErrorConfiguration=} configuration + * @returns {void} + */ + +function validate(schema, options, configuration) { + let errors = []; + + if (Array.isArray(options)) { + errors = Array.from(options, nestedOptions => validateObject(schema, nestedOptions)); + errors.forEach((list, idx) => { + const applyPrefix = + /** + * @param {SchemaUtilErrorObject} error + */ + error => { + // eslint-disable-next-line no-param-reassign + error.dataPath = `[${idx}]${error.dataPath}`; + + if (error.children) { + error.children.forEach(applyPrefix); + } + }; + + list.forEach(applyPrefix); + }); + errors = errors.reduce((arr, items) => { + arr.push(...items); + return arr; + }, []); + } else { + errors = validateObject(schema, options); + } + + if (errors.length > 0) { + throw new _ValidationError.default(errors, schema, configuration); + } +} +/** + * @param {Schema} schema + * @param {Array | object} options + * @returns {Array} + */ + + +function validateObject(schema, options) { + const compiledSchema = ajv.compile(schema); + const valid = compiledSchema(options); + if (valid) return []; + return compiledSchema.errors ? filterErrors(compiledSchema.errors) : []; +} +/** + * @param {Array} errors + * @returns {Array} + */ + + +function filterErrors(errors) { + /** @type {Array} */ + let newErrors = []; + + for (const error of + /** @type {Array} */ + errors) { + const { + dataPath + } = error; + /** @type {Array} */ + + let children = []; + newErrors = newErrors.filter(oldError => { + if (oldError.dataPath.includes(dataPath)) { + if (oldError.children) { + children = children.concat(oldError.children.slice(0)); + } // eslint-disable-next-line no-undefined, no-param-reassign + + + oldError.children = undefined; + children.push(oldError); + return false; + } + + return true; + }); + + if (children.length) { + error.children = children; + } + + newErrors.push(error); + } + + return newErrors; +} // TODO change after resolve https://github.com/microsoft/TypeScript/issues/34994 + + +validate.ValidationError = _ValidationError.default; +validate.ValidateError = _ValidationError.default; +var _default = validate; +exports.default = _default; \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/package.json b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/package.json new file mode 100644 index 000000000..27dc74069 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/schema-utils/package.json @@ -0,0 +1,109 @@ +{ + "_from": "schema-utils@^2.6.1", + "_id": "schema-utils@2.7.0", + "_inBundle": false, + "_integrity": "sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==", + "_location": "/sass-loader/schema-utils", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "schema-utils@^2.6.1", + "name": "schema-utils", + "escapedName": "schema-utils", + "rawSpec": "^2.6.1", + "saveSpec": null, + "fetchSpec": "^2.6.1" + }, + "_requiredBy": [ + "/sass-loader" + ], + "_resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz", + "_shasum": "17151f76d8eae67fbbf77960c33c676ad9f4efc7", + "_spec": "schema-utils@^2.6.1", + "_where": "/Users/fxy/Documents/DCloud/HbuilderX-plugins/alpha/uniapp-cli/node_modules/sass-loader", + "author": { + "name": "webpack Contrib", + "url": "https://github.com/webpack-contrib" + }, + "bugs": { + "url": "https://github.com/webpack/schema-utils/issues" + }, + "bundleDependencies": false, + "dependencies": { + "@types/json-schema": "^7.0.4", + "ajv": "^6.12.2", + "ajv-keywords": "^3.4.1" + }, + "deprecated": false, + "description": "webpack Validation Utils", + "devDependencies": { + "@babel/cli": "^7.10.1", + "@babel/core": "^7.10.1", + "@babel/preset-env": "^7.10.1", + "@commitlint/cli": "^8.3.5", + "@commitlint/config-conventional": "^8.3.4", + "@webpack-contrib/defaults": "^6.3.0", + "@webpack-contrib/eslint-config-webpack": "^3.0.0", + "babel-jest": "^25.5.1", + "cross-env": "^6.0.3", + "del": "^5.1.0", + "del-cli": "^3.0.1", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-import": "^2.20.2", + "husky": "^4.2.5", + "jest": "^25.5.4", + "lint-staged": "^10.2.7", + "npm-run-all": "^4.1.5", + "prettier": "^1.19.1", + "standard-version": "^8.0.0", + "typescript": "^3.9.3" + }, + "engines": { + "node": ">= 8.9.0" + }, + "files": [ + "dist", + "declarations" + ], + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "homepage": "https://github.com/webpack/schema-utils", + "keywords": [ + "webpack" + ], + "license": "MIT", + "main": "dist/index.js", + "name": "schema-utils", + "repository": { + "type": "git", + "url": "git+https://github.com/webpack/schema-utils.git" + }, + "scripts": { + "build": "npm-run-all -p \"build:**\"", + "build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files", + "build:types": "tsc --declaration --emitDeclarationOnly --outDir declarations && prettier \"declarations/**/*.ts\" --write", + "clean": "del-cli dist declarations", + "commitlint": "commitlint --from=master", + "defaults": "webpack-defaults", + "lint": "npm-run-all -l -p \"lint:**\"", + "lint:js": "eslint --cache .", + "lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different", + "lint:types": "tsc --pretty --noEmit", + "prebuild": "npm run clean", + "prepare": "npm run build", + "pretest": "npm run lint", + "release": "standard-version", + "security": "npm audit", + "start": "npm run build -- -w", + "test": "npm run test:coverage", + "test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage", + "test:only": "cross-env NODE_ENV=test jest", + "test:watch": "npm run test:only -- --watch" + }, + "types": "declarations/index.d.ts", + "version": "2.7.0" +} diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/CHANGELOG.md b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/CHANGELOG.md new file mode 100644 index 000000000..f567dd3fe --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/CHANGELOG.md @@ -0,0 +1,70 @@ +# changes log + +## 6.2.0 + +* Coerce numbers to strings when passed to semver.coerce() +* Add `rtl` option to coerce from right to left + +## 6.1.3 + +* Handle X-ranges properly in includePrerelease mode + +## 6.1.2 + +* Do not throw when testing invalid version strings + +## 6.1.1 + +* Add options support for semver.coerce() +* Handle undefined version passed to Range.test + +## 6.1.0 + +* Add semver.compareBuild function +* Support `*` in semver.intersects + +## 6.0 + +* Fix `intersects` logic. + + This is technically a bug fix, but since it is also a change to behavior + that may require users updating their code, it is marked as a major + version increment. + +## 5.7 + +* Add `minVersion` method + +## 5.6 + +* Move boolean `loose` param to an options object, with + backwards-compatibility protection. +* Add ability to opt out of special prerelease version handling with + the `includePrerelease` option flag. + +## 5.5 + +* Add version coercion capabilities + +## 5.4 + +* Add intersection checking + +## 5.3 + +* Add `minSatisfying` method + +## 5.2 + +* Add `prerelease(v)` that returns prerelease components + +## 5.1 + +* Add Backus-Naur for ranges +* Remove excessively cute inspection methods + +## 5.0 + +* Remove AMD/Browserified build artifacts +* Fix ltr and gtr when using the `*` range +* Fix for range `*` with a prerelease identifier diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/LICENSE b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/LICENSE new file mode 100644 index 000000000..19129e315 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/README.md b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/README.md new file mode 100644 index 000000000..2293a14fd --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/README.md @@ -0,0 +1,443 @@ +semver(1) -- The semantic versioner for npm +=========================================== + +## Install + +```bash +npm install semver +```` + +## Usage + +As a node module: + +```js +const semver = require('semver') + +semver.valid('1.2.3') // '1.2.3' +semver.valid('a.b.c') // null +semver.clean(' =v1.2.3 ') // '1.2.3' +semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true +semver.gt('1.2.3', '9.8.7') // false +semver.lt('1.2.3', '9.8.7') // true +semver.minVersion('>=1.0.0') // '1.0.0' +semver.valid(semver.coerce('v2')) // '2.0.0' +semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7' +``` + +As a command-line utility: + +``` +$ semver -h + +A JavaScript implementation of the https://semver.org/ specification +Copyright Isaac Z. Schlueter + +Usage: semver [options] [ [...]] +Prints valid versions sorted by SemVer precedence + +Options: +-r --range + Print versions that match the specified range. + +-i --increment [] + Increment a version by the specified level. Level can + be one of: major, minor, patch, premajor, preminor, + prepatch, or prerelease. Default level is 'patch'. + Only one version may be specified. + +--preid + Identifier to be used to prefix premajor, preminor, + prepatch or prerelease version increments. + +-l --loose + Interpret versions and ranges loosely + +-p --include-prerelease + Always include prerelease versions in range matching + +-c --coerce + Coerce a string into SemVer if possible + (does not imply --loose) + +--rtl + Coerce version strings right to left + +--ltr + Coerce version strings left to right (default) + +Program exits successfully if any valid version satisfies +all supplied ranges, and prints all satisfying versions. + +If no satisfying versions are found, then exits failure. + +Versions are printed in ascending order, so supplying +multiple versions to the utility will just sort them. +``` + +## Versions + +A "version" is described by the `v2.0.0` specification found at +. + +A leading `"="` or `"v"` character is stripped off and ignored. + +## Ranges + +A `version range` is a set of `comparators` which specify versions +that satisfy the range. + +A `comparator` is composed of an `operator` and a `version`. The set +of primitive `operators` is: + +* `<` Less than +* `<=` Less than or equal to +* `>` Greater than +* `>=` Greater than or equal to +* `=` Equal. If no operator is specified, then equality is assumed, + so this operator is optional, but MAY be included. + +For example, the comparator `>=1.2.7` would match the versions +`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6` +or `1.1.0`. + +Comparators can be joined by whitespace to form a `comparator set`, +which is satisfied by the **intersection** of all of the comparators +it includes. + +A range is composed of one or more comparator sets, joined by `||`. A +version matches a range if and only if every comparator in at least +one of the `||`-separated comparator sets is satisfied by the version. + +For example, the range `>=1.2.7 <1.3.0` would match the versions +`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`, +or `1.1.0`. + +The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`, +`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`. + +### Prerelease Tags + +If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then +it will only be allowed to satisfy comparator sets if at least one +comparator with the same `[major, minor, patch]` tuple also has a +prerelease tag. + +For example, the range `>1.2.3-alpha.3` would be allowed to match the +version `1.2.3-alpha.7`, but it would *not* be satisfied by +`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater +than" `1.2.3-alpha.3` according to the SemVer sort rules. The version +range only accepts prerelease tags on the `1.2.3` version. The +version `3.4.5` *would* satisfy the range, because it does not have a +prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`. + +The purpose for this behavior is twofold. First, prerelease versions +frequently are updated very quickly, and contain many breaking changes +that are (by the author's design) not yet fit for public consumption. +Therefore, by default, they are excluded from range matching +semantics. + +Second, a user who has opted into using a prerelease version has +clearly indicated the intent to use *that specific* set of +alpha/beta/rc versions. By including a prerelease tag in the range, +the user is indicating that they are aware of the risk. However, it +is still not appropriate to assume that they have opted into taking a +similar risk on the *next* set of prerelease versions. + +Note that this behavior can be suppressed (treating all prerelease +versions as if they were normal versions, for the purpose of range +matching) by setting the `includePrerelease` flag on the options +object to any +[functions](https://github.com/npm/node-semver#functions) that do +range matching. + +#### Prerelease Identifiers + +The method `.inc` takes an additional `identifier` string argument that +will append the value of the string as a prerelease identifier: + +```javascript +semver.inc('1.2.3', 'prerelease', 'beta') +// '1.2.4-beta.0' +``` + +command-line example: + +```bash +$ semver 1.2.3 -i prerelease --preid beta +1.2.4-beta.0 +``` + +Which then can be used to increment further: + +```bash +$ semver 1.2.4-beta.0 -i prerelease +1.2.4-beta.1 +``` + +### Advanced Range Syntax + +Advanced range syntax desugars to primitive comparators in +deterministic ways. + +Advanced ranges may be combined in the same way as primitive +comparators using white space or `||`. + +#### Hyphen Ranges `X.Y.Z - A.B.C` + +Specifies an inclusive set. + +* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4` + +If a partial version is provided as the first version in the inclusive +range, then the missing pieces are replaced with zeroes. + +* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4` + +If a partial version is provided as the second version in the +inclusive range, then all versions that start with the supplied parts +of the tuple are accepted, but nothing that would be greater than the +provided tuple parts. + +* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0` +* `1.2.3 - 2` := `>=1.2.3 <3.0.0` + +#### X-Ranges `1.2.x` `1.X` `1.2.*` `*` + +Any of `X`, `x`, or `*` may be used to "stand in" for one of the +numeric values in the `[major, minor, patch]` tuple. + +* `*` := `>=0.0.0` (Any version satisfies) +* `1.x` := `>=1.0.0 <2.0.0` (Matching major version) +* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions) + +A partial version range is treated as an X-Range, so the special +character is in fact optional. + +* `""` (empty string) := `*` := `>=0.0.0` +* `1` := `1.x.x` := `>=1.0.0 <2.0.0` +* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0` + +#### Tilde Ranges `~1.2.3` `~1.2` `~1` + +Allows patch-level changes if a minor version is specified on the +comparator. Allows minor-level changes if not. + +* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0` +* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`) +* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`) +* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0` +* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`) +* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`) +* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in + the `1.2.3` version will be allowed, if they are greater than or + equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but + `1.2.4-beta.2` would not, because it is a prerelease of a + different `[major, minor, patch]` tuple. + +#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4` + +Allows changes that do not modify the left-most non-zero element in the +`[major, minor, patch]` tuple. In other words, this allows patch and +minor updates for versions `1.0.0` and above, patch updates for +versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`. + +Many authors treat a `0.x` version as if the `x` were the major +"breaking-change" indicator. + +Caret ranges are ideal when an author may make breaking changes +between `0.2.4` and `0.3.0` releases, which is a common practice. +However, it presumes that there will *not* be breaking changes between +`0.2.4` and `0.2.5`. It allows for changes that are presumed to be +additive (but non-breaking), according to commonly observed practices. + +* `^1.2.3` := `>=1.2.3 <2.0.0` +* `^0.2.3` := `>=0.2.3 <0.3.0` +* `^0.0.3` := `>=0.0.3 <0.0.4` +* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in + the `1.2.3` version will be allowed, if they are greater than or + equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but + `1.2.4-beta.2` would not, because it is a prerelease of a + different `[major, minor, patch]` tuple. +* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the + `0.0.3` version *only* will be allowed, if they are greater than or + equal to `beta`. So, `0.0.3-pr.2` would be allowed. + +When parsing caret ranges, a missing `patch` value desugars to the +number `0`, but will allow flexibility within that value, even if the +major and minor versions are both `0`. + +* `^1.2.x` := `>=1.2.0 <2.0.0` +* `^0.0.x` := `>=0.0.0 <0.1.0` +* `^0.0` := `>=0.0.0 <0.1.0` + +A missing `minor` and `patch` values will desugar to zero, but also +allow flexibility within those values, even if the major version is +zero. + +* `^1.x` := `>=1.0.0 <2.0.0` +* `^0.x` := `>=0.0.0 <1.0.0` + +### Range Grammar + +Putting all this together, here is a Backus-Naur grammar for ranges, +for the benefit of parser authors: + +```bnf +range-set ::= range ( logical-or range ) * +logical-or ::= ( ' ' ) * '||' ( ' ' ) * +range ::= hyphen | simple ( ' ' simple ) * | '' +hyphen ::= partial ' - ' partial +simple ::= primitive | partial | tilde | caret +primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial +partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? +xr ::= 'x' | 'X' | '*' | nr +nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) * +tilde ::= '~' partial +caret ::= '^' partial +qualifier ::= ( '-' pre )? ( '+' build )? +pre ::= parts +build ::= parts +parts ::= part ( '.' part ) * +part ::= nr | [-0-9A-Za-z]+ +``` + +## Functions + +All methods and classes take a final `options` object argument. All +options in this object are `false` by default. The options supported +are: + +- `loose` Be more forgiving about not-quite-valid semver strings. + (Any resulting output will always be 100% strict compliant, of + course.) For backwards compatibility reasons, if the `options` + argument is a boolean value instead of an object, it is interpreted + to be the `loose` param. +- `includePrerelease` Set to suppress the [default + behavior](https://github.com/npm/node-semver#prerelease-tags) of + excluding prerelease tagged versions from ranges unless they are + explicitly opted into. + +Strict-mode Comparators and Ranges will be strict about the SemVer +strings that they parse. + +* `valid(v)`: Return the parsed version, or null if it's not valid. +* `inc(v, release)`: Return the version incremented by the release + type (`major`, `premajor`, `minor`, `preminor`, `patch`, + `prepatch`, or `prerelease`), or null if it's not valid + * `premajor` in one call will bump the version up to the next major + version and down to a prerelease of that major version. + `preminor`, and `prepatch` work the same way. + * If called from a non-prerelease version, the `prerelease` will work the + same as `prepatch`. It increments the patch version, then makes a + prerelease. If the input version is already a prerelease it simply + increments it. +* `prerelease(v)`: Returns an array of prerelease components, or null + if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]` +* `major(v)`: Return the major version number. +* `minor(v)`: Return the minor version number. +* `patch(v)`: Return the patch version number. +* `intersects(r1, r2, loose)`: Return true if the two supplied ranges + or comparators intersect. +* `parse(v)`: Attempt to parse a string as a semantic version, returning either + a `SemVer` object or `null`. + +### Comparison + +* `gt(v1, v2)`: `v1 > v2` +* `gte(v1, v2)`: `v1 >= v2` +* `lt(v1, v2)`: `v1 < v2` +* `lte(v1, v2)`: `v1 <= v2` +* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent, + even if they're not the exact same string. You already know how to + compare strings. +* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`. +* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call + the corresponding function above. `"==="` and `"!=="` do simple + string comparison, but are included for completeness. Throws if an + invalid comparison string is provided. +* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if + `v2` is greater. Sorts in ascending order if passed to `Array.sort()`. +* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions + in descending order when passed to `Array.sort()`. +* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions + are equal. Sorts in ascending order if passed to `Array.sort()`. + `v2` is greater. Sorts in ascending order if passed to `Array.sort()`. +* `diff(v1, v2)`: Returns difference between two versions by the release type + (`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`), + or null if the versions are the same. + +### Comparators + +* `intersects(comparator)`: Return true if the comparators intersect + +### Ranges + +* `validRange(range)`: Return the valid range or null if it's not valid +* `satisfies(version, range)`: Return true if the version satisfies the + range. +* `maxSatisfying(versions, range)`: Return the highest version in the list + that satisfies the range, or `null` if none of them do. +* `minSatisfying(versions, range)`: Return the lowest version in the list + that satisfies the range, or `null` if none of them do. +* `minVersion(range)`: Return the lowest version that can possibly match + the given range. +* `gtr(version, range)`: Return `true` if version is greater than all the + versions possible in the range. +* `ltr(version, range)`: Return `true` if version is less than all the + versions possible in the range. +* `outside(version, range, hilo)`: Return true if the version is outside + the bounds of the range in either the high or low direction. The + `hilo` argument must be either the string `'>'` or `'<'`. (This is + the function called by `gtr` and `ltr`.) +* `intersects(range)`: Return true if any of the ranges comparators intersect + +Note that, since ranges may be non-contiguous, a version might not be +greater than a range, less than a range, *or* satisfy a range! For +example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9` +until `2.0.0`, so the version `1.2.10` would not be greater than the +range (because `2.0.1` satisfies, which is higher), nor less than the +range (since `1.2.8` satisfies, which is lower), and it also does not +satisfy the range. + +If you want to know if a version satisfies or does not satisfy a +range, use the `satisfies(version, range)` function. + +### Coercion + +* `coerce(version, options)`: Coerces a string to semver if possible + +This aims to provide a very forgiving translation of a non-semver string to +semver. It looks for the first digit in a string, and consumes all +remaining characters which satisfy at least a partial semver (e.g., `1`, +`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer +versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All +surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes +`3.4.0`). Only text which lacks digits will fail coercion (`version one` +is not valid). The maximum length for any semver component considered for +coercion is 16 characters; longer components will be ignored +(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any +semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value +components are invalid (`9999999999999999.4.7.4` is likely invalid). + +If the `options.rtl` flag is set, then `coerce` will return the right-most +coercible tuple that does not share an ending index with a longer coercible +tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not +`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of +any other overlapping SemVer tuple. + +### Clean + +* `clean(version)`: Clean a string to be a valid semver if possible + +This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges. + +ex. +* `s.clean(' = v 2.1.5foo')`: `null` +* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'` +* `s.clean(' = v 2.1.5-foo')`: `null` +* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'` +* `s.clean('=v2.1.5')`: `'2.1.5'` +* `s.clean(' =v2.1.5')`: `2.1.5` +* `s.clean(' 2.1.5 ')`: `'2.1.5'` +* `s.clean('~1.0.0')`: `null` diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/bin/semver.js b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/bin/semver.js new file mode 100755 index 000000000..666034a75 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/bin/semver.js @@ -0,0 +1,174 @@ +#!/usr/bin/env node +// Standalone semver comparison program. +// Exits successfully and prints matching version(s) if +// any supplied version is valid and passes all tests. + +var argv = process.argv.slice(2) + +var versions = [] + +var range = [] + +var inc = null + +var version = require('../package.json').version + +var loose = false + +var includePrerelease = false + +var coerce = false + +var rtl = false + +var identifier + +var semver = require('../semver') + +var reverse = false + +var options = {} + +main() + +function main () { + if (!argv.length) return help() + while (argv.length) { + var a = argv.shift() + var indexOfEqualSign = a.indexOf('=') + if (indexOfEqualSign !== -1) { + a = a.slice(0, indexOfEqualSign) + argv.unshift(a.slice(indexOfEqualSign + 1)) + } + switch (a) { + case '-rv': case '-rev': case '--rev': case '--reverse': + reverse = true + break + case '-l': case '--loose': + loose = true + break + case '-p': case '--include-prerelease': + includePrerelease = true + break + case '-v': case '--version': + versions.push(argv.shift()) + break + case '-i': case '--inc': case '--increment': + switch (argv[0]) { + case 'major': case 'minor': case 'patch': case 'prerelease': + case 'premajor': case 'preminor': case 'prepatch': + inc = argv.shift() + break + default: + inc = 'patch' + break + } + break + case '--preid': + identifier = argv.shift() + break + case '-r': case '--range': + range.push(argv.shift()) + break + case '-c': case '--coerce': + coerce = true + break + case '--rtl': + rtl = true + break + case '--ltr': + rtl = false + break + case '-h': case '--help': case '-?': + return help() + default: + versions.push(a) + break + } + } + + var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl } + + versions = versions.map(function (v) { + return coerce ? (semver.coerce(v, options) || { version: v }).version : v + }).filter(function (v) { + return semver.valid(v) + }) + if (!versions.length) return fail() + if (inc && (versions.length !== 1 || range.length)) { return failInc() } + + for (var i = 0, l = range.length; i < l; i++) { + versions = versions.filter(function (v) { + return semver.satisfies(v, range[i], options) + }) + if (!versions.length) return fail() + } + return success(versions) +} + +function failInc () { + console.error('--inc can only be used on a single version with no range') + fail() +} + +function fail () { process.exit(1) } + +function success () { + var compare = reverse ? 'rcompare' : 'compare' + versions.sort(function (a, b) { + return semver[compare](a, b, options) + }).map(function (v) { + return semver.clean(v, options) + }).map(function (v) { + return inc ? semver.inc(v, inc, options, identifier) : v + }).forEach(function (v, i, _) { console.log(v) }) +} + +function help () { + console.log(['SemVer ' + version, + '', + 'A JavaScript implementation of the https://semver.org/ specification', + 'Copyright Isaac Z. Schlueter', + '', + 'Usage: semver [options] [ [...]]', + 'Prints valid versions sorted by SemVer precedence', + '', + 'Options:', + '-r --range ', + ' Print versions that match the specified range.', + '', + '-i --increment []', + ' Increment a version by the specified level. Level can', + ' be one of: major, minor, patch, premajor, preminor,', + " prepatch, or prerelease. Default level is 'patch'.", + ' Only one version may be specified.', + '', + '--preid ', + ' Identifier to be used to prefix premajor, preminor,', + ' prepatch or prerelease version increments.', + '', + '-l --loose', + ' Interpret versions and ranges loosely', + '', + '-p --include-prerelease', + ' Always include prerelease versions in range matching', + '', + '-c --coerce', + ' Coerce a string into SemVer if possible', + ' (does not imply --loose)', + '', + '--rtl', + ' Coerce version strings right to left', + '', + '--ltr', + ' Coerce version strings left to right (default)', + '', + 'Program exits successfully if any valid version satisfies', + 'all supplied ranges, and prints all satisfying versions.', + '', + 'If no satisfying versions are found, then exits failure.', + '', + 'Versions are printed in ascending order, so supplying', + 'multiple versions to the utility will just sort them.' + ].join('\n')) +} diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/package.json b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/package.json new file mode 100644 index 000000000..006695f34 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/package.json @@ -0,0 +1,60 @@ +{ + "_from": "semver@^6.3.0", + "_id": "semver@6.3.0", + "_inBundle": false, + "_integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "_location": "/sass-loader/semver", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "semver@^6.3.0", + "name": "semver", + "escapedName": "semver", + "rawSpec": "^6.3.0", + "saveSpec": null, + "fetchSpec": "^6.3.0" + }, + "_requiredBy": [ + "/sass-loader" + ], + "_resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "_shasum": "ee0a64c8af5e8ceea67687b133761e1becbd1d3d", + "_spec": "semver@^6.3.0", + "_where": "/Users/fxy/Documents/DCloud/HbuilderX-plugins/alpha/uniapp-cli/node_modules/sass-loader", + "bin": { + "semver": "bin/semver.js" + }, + "bugs": { + "url": "https://github.com/npm/node-semver/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "The semantic version parser used by npm.", + "devDependencies": { + "tap": "^14.3.1" + }, + "files": [ + "bin", + "range.bnf", + "semver.js" + ], + "homepage": "https://github.com/npm/node-semver#readme", + "license": "ISC", + "main": "semver.js", + "name": "semver", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/node-semver.git" + }, + "scripts": { + "postpublish": "git push origin --follow-tags", + "postversion": "npm publish", + "preversion": "npm test", + "test": "tap" + }, + "tap": { + "check-coverage": true + }, + "version": "6.3.0" +} diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/range.bnf b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/range.bnf new file mode 100644 index 000000000..d4c6ae0d7 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/range.bnf @@ -0,0 +1,16 @@ +range-set ::= range ( logical-or range ) * +logical-or ::= ( ' ' ) * '||' ( ' ' ) * +range ::= hyphen | simple ( ' ' simple ) * | '' +hyphen ::= partial ' - ' partial +simple ::= primitive | partial | tilde | caret +primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial +partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? +xr ::= 'x' | 'X' | '*' | nr +nr ::= '0' | [1-9] ( [0-9] ) * +tilde ::= '~' partial +caret ::= '^' partial +qualifier ::= ( '-' pre )? ( '+' build )? +pre ::= parts +build ::= parts +parts ::= part ( '.' part ) * +part ::= nr | [-0-9A-Za-z]+ diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/semver.js b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/semver.js new file mode 100644 index 000000000..636fa4365 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/node_modules/semver/semver.js @@ -0,0 +1,1596 @@ +exports = module.exports = SemVer + +var debug +/* istanbul ignore next */ +if (typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG)) { + debug = function () { + var args = Array.prototype.slice.call(arguments, 0) + args.unshift('SEMVER') + console.log.apply(console, args) + } +} else { + debug = function () {} +} + +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +exports.SEMVER_SPEC_VERSION = '2.0.0' + +var MAX_LENGTH = 256 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16 + +// The actual regexps go on exports.re +var re = exports.re = [] +var src = exports.src = [] +var t = exports.tokens = {} +var R = 0 + +function tok (n) { + t[n] = R++ +} + +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. + +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. + +tok('NUMERICIDENTIFIER') +src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' +tok('NUMERICIDENTIFIERLOOSE') +src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+' + +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. + +tok('NONNUMERICIDENTIFIER') +src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' + +// ## Main Version +// Three dot-separated numeric identifiers. + +tok('MAINVERSION') +src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')' + +tok('MAINVERSIONLOOSE') +src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +tok('PRERELEASEIDENTIFIER') +src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' + +tok('PRERELEASEIDENTIFIERLOOSE') +src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +tok('PRERELEASE') +src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' + +tok('PRERELEASELOOSE') +src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +tok('BUILDIDENTIFIER') +src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +tok('BUILD') +src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))' + +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. + +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. + +tok('FULL') +tok('FULLPLAIN') +src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + + src[t.PRERELEASE] + '?' + + src[t.BUILD] + '?' + +src[t.FULL] = '^' + src[t.FULLPLAIN] + '$' + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +tok('LOOSEPLAIN') +src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + + src[t.PRERELEASELOOSE] + '?' + + src[t.BUILD] + '?' + +tok('LOOSE') +src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' + +tok('GTLT') +src[t.GTLT] = '((?:<|>)?=?)' + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +tok('XRANGEIDENTIFIERLOOSE') +src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' +tok('XRANGEIDENTIFIER') +src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' + +tok('XRANGEPLAIN') +src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:' + src[t.PRERELEASE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' + +tok('XRANGEPLAINLOOSE') +src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:' + src[t.PRERELEASELOOSE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' + +tok('XRANGE') +src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' +tok('XRANGELOOSE') +src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' + +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +tok('COERCE') +src[t.COERCE] = '(^|[^\\d])' + + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:$|[^\\d])' +tok('COERCERTL') +re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g') + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +tok('LONETILDE') +src[t.LONETILDE] = '(?:~>?)' + +tok('TILDETRIM') +src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' +re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') +var tildeTrimReplace = '$1~' + +tok('TILDE') +src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' +tok('TILDELOOSE') +src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +tok('LONECARET') +src[t.LONECARET] = '(?:\\^)' + +tok('CARETTRIM') +src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' +re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') +var caretTrimReplace = '$1^' + +tok('CARET') +src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' +tok('CARETLOOSE') +src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +tok('COMPARATORLOOSE') +src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$' +tok('COMPARATOR') +src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$' + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +tok('COMPARATORTRIM') +src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + + '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')' + +// this one has to use the /g flag +re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') +var comparatorTrimReplace = '$1$2$3' + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +tok('HYPHENRANGE') +src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAIN] + ')' + + '\\s*$' + +tok('HYPHENRANGELOOSE') +src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s*$' + +// Star ranges basically just allow anything at all. +tok('STAR') +src[t.STAR] = '(<|>)?=?\\s*\\*' + +// Compile to actual regexp objects. +// All are flag-free, unless they were created above with a flag. +for (var i = 0; i < R; i++) { + debug(i, src[i]) + if (!re[i]) { + re[i] = new RegExp(src[i]) + } +} + +exports.parse = parse +function parse (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (version instanceof SemVer) { + return version + } + + if (typeof version !== 'string') { + return null + } + + if (version.length > MAX_LENGTH) { + return null + } + + var r = options.loose ? re[t.LOOSE] : re[t.FULL] + if (!r.test(version)) { + return null + } + + try { + return new SemVer(version, options) + } catch (er) { + return null + } +} + +exports.valid = valid +function valid (version, options) { + var v = parse(version, options) + return v ? v.version : null +} + +exports.clean = clean +function clean (version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} + +exports.SemVer = SemVer + +function SemVer (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + if (version instanceof SemVer) { + if (version.loose === options.loose) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError('Invalid Version: ' + version) + } + + if (version.length > MAX_LENGTH) { + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') + } + + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } + + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + + var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) + + if (!m) { + throw new TypeError('Invalid Version: ' + version) + } + + this.raw = version + + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] + + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } + + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } + + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } + + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() +} + +SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version +} + +SemVer.prototype.toString = function () { + return this.version +} + +SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return this.compareMain(other) || this.comparePre(other) +} + +SemVer.prototype.compareMain = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) +} + +SemVer.prototype.comparePre = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } + + var i = 0 + do { + var a = this.prerelease[i] + var b = other.prerelease[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) +} + +SemVer.prototype.compareBuild = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + var i = 0 + do { + var a = this.build[i] + var b = other.build[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) +} + +// preminor will bump the version up to the next minor release, and immediately +// down to pre-release. premajor and prepatch work the same way. +SemVer.prototype.inc = function (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0 + this.inc('patch', identifier) + this.inc('pre', identifier) + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier) + } + this.inc('pre', identifier) + break + + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if (this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0) { + this.major++ + } + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++ + } + this.patch = 0 + this.prerelease = [] + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++ + } + this.prerelease = [] + break + // This probably shouldn't be used publicly. + // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction. + case 'pre': + if (this.prerelease.length === 0) { + this.prerelease = [0] + } else { + var i = this.prerelease.length + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) + } + } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0] + } + } else { + this.prerelease = [identifier, 0] + } + } + break + + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this +} + +exports.inc = inc +function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } + + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } +} + +exports.diff = diff +function diff (version1, version2) { + if (eq(version1, version2)) { + return null + } else { + var v1 = parse(version1) + var v2 = parse(version2) + var prefix = '' + if (v1.prerelease.length || v2.prerelease.length) { + prefix = 'pre' + var defaultResult = 'prerelease' + } + for (var key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } + } + } + return defaultResult // may be undefined + } +} + +exports.compareIdentifiers = compareIdentifiers + +var numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + var anum = numeric.test(a) + var bnum = numeric.test(b) + + if (anum && bnum) { + a = +a + b = +b + } + + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} + +exports.rcompareIdentifiers = rcompareIdentifiers +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} + +exports.major = major +function major (a, loose) { + return new SemVer(a, loose).major +} + +exports.minor = minor +function minor (a, loose) { + return new SemVer(a, loose).minor +} + +exports.patch = patch +function patch (a, loose) { + return new SemVer(a, loose).patch +} + +exports.compare = compare +function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) +} + +exports.compareLoose = compareLoose +function compareLoose (a, b) { + return compare(a, b, true) +} + +exports.compareBuild = compareBuild +function compareBuild (a, b, loose) { + var versionA = new SemVer(a, loose) + var versionB = new SemVer(b, loose) + return versionA.compare(versionB) || versionA.compareBuild(versionB) +} + +exports.rcompare = rcompare +function rcompare (a, b, loose) { + return compare(b, a, loose) +} + +exports.sort = sort +function sort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(a, b, loose) + }) +} + +exports.rsort = rsort +function rsort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(b, a, loose) + }) +} + +exports.gt = gt +function gt (a, b, loose) { + return compare(a, b, loose) > 0 +} + +exports.lt = lt +function lt (a, b, loose) { + return compare(a, b, loose) < 0 +} + +exports.eq = eq +function eq (a, b, loose) { + return compare(a, b, loose) === 0 +} + +exports.neq = neq +function neq (a, b, loose) { + return compare(a, b, loose) !== 0 +} + +exports.gte = gte +function gte (a, b, loose) { + return compare(a, b, loose) >= 0 +} + +exports.lte = lte +function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} + +exports.cmp = cmp +function cmp (a, op, b, loose) { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b + + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b + + case '': + case '=': + case '==': + return eq(a, b, loose) + + case '!=': + return neq(a, b, loose) + + case '>': + return gt(a, b, loose) + + case '>=': + return gte(a, b, loose) + + case '<': + return lt(a, b, loose) + + case '<=': + return lte(a, b, loose) + + default: + throw new TypeError('Invalid operator: ' + op) + } +} + +exports.Comparator = Comparator +function Comparator (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } + + if (!(this instanceof Comparator)) { + return new Comparator(comp, options) + } + + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) + + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } + + debug('comp', this) +} + +var ANY = {} +Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var m = comp.match(r) + + if (!m) { + throw new TypeError('Invalid comparator: ' + comp) + } + + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } + + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } +} + +Comparator.prototype.toString = function () { + return this.value +} + +Comparator.prototype.test = function (version) { + debug('Comparator.test', version, this.options.loose) + + if (this.semver === ANY || version === ANY) { + return true + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + return cmp(version, this.operator, this.semver, this.options) +} + +Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + var rangeTmp + + if (this.operator === '') { + if (this.value === '') { + return true + } + rangeTmp = new Range(comp.value, options) + return satisfies(this.value, rangeTmp, options) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + rangeTmp = new Range(this.value, options) + return satisfies(comp.semver, rangeTmp, options) + } + + var sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>') + var sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<') + var sameSemVer = this.semver.version === comp.semver.version + var differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<=') + var oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + ((this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<')) + var oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + ((this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>')) + + return sameDirectionIncreasing || sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || oppositeDirectionsGreaterThan +} + +exports.Range = Range +function Range (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (range instanceof Range) { + if (range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease) { + return range + } else { + return new Range(range.raw, options) + } + } + + if (range instanceof Comparator) { + return new Range(range.value, options) + } + + if (!(this instanceof Range)) { + return new Range(range, options) + } + + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease + + // First, split based on boolean or || + this.raw = range + this.set = range.split(/\s*\|\|\s*/).map(function (range) { + return this.parseRange(range.trim()) + }, this).filter(function (c) { + // throw out any that are not relevant for whatever reason + return c.length + }) + + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } + + this.format() +} + +Range.prototype.format = function () { + this.range = this.set.map(function (comps) { + return comps.join(' ').trim() + }).join('||').trim() + return this.range +} + +Range.prototype.toString = function () { + return this.range +} + +Range.prototype.parseRange = function (range) { + var loose = this.options.loose + range = range.trim() + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] + range = range.replace(hr, hyphenReplace) + debug('hyphen replace', range) + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[t.COMPARATORTRIM]) + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[t.CARETTRIM], caretTrimReplace) + + // normalize spaces + range = range.split(/\s+/).join(' ') + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var set = range.split(' ').map(function (comp) { + return parseComparator(comp, this.options) + }, this).join(' ').split(/\s+/) + if (this.options.loose) { + // in loose mode, throw out any that are not valid comparators + set = set.filter(function (comp) { + return !!comp.match(compRe) + }) + } + set = set.map(function (comp) { + return new Comparator(comp, this.options) + }, this) + + return set +} + +Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + return this.set.some(function (thisComparators) { + return ( + isSatisfiable(thisComparators, options) && + range.set.some(function (rangeComparators) { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every(function (thisComparator) { + return rangeComparators.every(function (rangeComparator) { + return thisComparator.intersects(rangeComparator, options) + }) + }) + ) + }) + ) + }) +} + +// take a set of comparators and determine whether there +// exists a version which can satisfy it +function isSatisfiable (comparators, options) { + var result = true + var remainingComparators = comparators.slice() + var testComparator = remainingComparators.pop() + + while (result && remainingComparators.length) { + result = remainingComparators.every(function (otherComparator) { + return testComparator.intersects(otherComparator, options) + }) + + testComparator = remainingComparators.pop() + } + + return result +} + +// Mostly just for testing and legacy API reasons +exports.toComparators = toComparators +function toComparators (range, options) { + return new Range(range, options).set.map(function (comp) { + return comp.map(function (c) { + return c.value + }).join(' ').trim().split(' ') + }) +} + +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +function parseComparator (comp, options) { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} + +function isX (id) { + return !id || id.toLowerCase() === 'x' || id === '*' +} + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 +function replaceTildes (comp, options) { + return comp.trim().split(/\s+/).map(function (comp) { + return replaceTilde(comp, options) + }).join(' ') +} + +function replaceTilde (comp, options) { + var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] + return comp.replace(r, function (_, M, m, p, pr) { + debug('tilde', comp, _, M, m, p, pr) + var ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0 + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else if (pr) { + debug('replaceTilde pr', pr) + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + } else { + // ~1.2.3 == >=1.2.3 <1.3.0 + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + (+m + 1) + '.0' + } + + debug('tilde return', ret) + return ret + }) +} + +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 +// ^1.2.3 --> >=1.2.3 <2.0.0 +// ^1.2.0 --> >=1.2.0 <2.0.0 +function replaceCarets (comp, options) { + return comp.trim().split(/\s+/).map(function (comp) { + return replaceCaret(comp, options) + }).join(' ') +} + +function replaceCaret (comp, options) { + debug('caret', comp, options) + var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + return comp.replace(r, function (_, M, m, p, pr) { + debug('caret', comp, _, M, m, p, pr) + var ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + if (M === '0') { + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else { + ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + m + '.' + (+p + 1) + } else { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + } + } else { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + (+M + 1) + '.0.0' + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + m + '.' + (+p + 1) + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + (+m + 1) + '.0' + } + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + (+M + 1) + '.0.0' + } + } + + debug('caret return', ret) + return ret + }) +} + +function replaceXRanges (comp, options) { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map(function (comp) { + return replaceXRange(comp, options) + }).join(' ') +} + +function replaceXRange (comp, options) { + comp = comp.trim() + var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] + return comp.replace(r, function (ret, gtlt, M, m, p, pr) { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + var xM = isX(M) + var xm = xM || isX(m) + var xp = xm || isX(p) + var anyX = xp + + if (gtlt === '=' && anyX) { + gtlt = '' + } + + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : '' + + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0' + } else { + // nothing is forbidden + ret = '*' + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 + } + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + // >1.2.3 => >= 1.2.4 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 + } + } + + ret = gtlt + M + '.' + m + '.' + p + pr + } else if (xm) { + ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr + } else if (xp) { + ret = '>=' + M + '.' + m + '.0' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + pr + } + + debug('xRange return', ret) + + return ret + }) +} + +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +function replaceStars (comp, options) { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[t.STAR], '') +} + +// This function is passed to string.replace(re[t.HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0 +function hyphenReplace ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = '>=' + fM + '.0.0' + } else if (isX(fp)) { + from = '>=' + fM + '.' + fm + '.0' + } else { + from = '>=' + from + } + + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = '<' + (+tM + 1) + '.0.0' + } else if (isX(tp)) { + to = '<' + tM + '.' + (+tm + 1) + '.0' + } else if (tpr) { + to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr + } else { + to = '<=' + to + } + + return (from + ' ' + to).trim() +} + +// if ANY of the sets match ALL of its comparators, then pass +Range.prototype.test = function (version) { + if (!version) { + return false + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false +} + +function testSet (set, version, options) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } + + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === ANY) { + continue + } + + if (set[i].semver.prerelease.length > 0) { + var allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true +} + +exports.satisfies = satisfies +function satisfies (version, range, options) { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) +} + +exports.maxSatisfying = maxSatisfying +function maxSatisfying (versions, range, options) { + var max = null + var maxSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach(function (v) { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max +} + +exports.minSatisfying = minSatisfying +function minSatisfying (versions, range, options) { + var min = null + var minSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach(function (v) { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) + } + } + }) + return min +} + +exports.minVersion = minVersion +function minVersion (range, loose) { + range = new Range(range, loose) + + var minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } + + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } + + minver = null + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] + + comparators.forEach(function (comparator) { + // Clone to avoid manipulating the comparator's semver object. + var compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!minver || gt(minver, compver)) { + minver = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error('Unexpected operation: ' + comparator.operator) + } + }) + } + + if (minver && range.test(minver)) { + return minver + } + + return null +} + +exports.validRange = validRange +function validRange (range, options) { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } +} + +// Determine if version is less than all the versions possible in the range +exports.ltr = ltr +function ltr (version, range, options) { + return outside(version, range, '<', options) +} + +// Determine if version is greater than all the versions possible in the range. +exports.gtr = gtr +function gtr (version, range, options) { + return outside(version, range, '>', options) +} + +exports.outside = outside +function outside (version, range, hilo, options) { + version = new SemVer(version, options) + range = new Range(range, options) + + var gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } + + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] + + var high = null + var low = null + + comparators.forEach(function (comparator) { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') + } + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator + } + }) + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false + } + } + return true +} + +exports.prerelease = prerelease +function prerelease (version, options) { + var parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} + +exports.intersects = intersects +function intersects (r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} + +exports.coerce = coerce +function coerce (version, options) { + if (version instanceof SemVer) { + return version + } + + if (typeof version === 'number') { + version = String(version) + } + + if (typeof version !== 'string') { + return null + } + + options = options || {} + + var match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + var next + while ((next = re[t.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if (!match || + next.index + next[0].length !== match.index + match[0].length) { + match = next + } + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + } + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } + + if (match === null) { + return null + } + + return parse(match[2] + + '.' + (match[3] || '0') + + '.' + (match[4] || '0'), options) +} diff --git a/packages/vue-cli-plugin-uni/packages/sass-loader/package.json b/packages/vue-cli-plugin-uni/packages/sass-loader/package.json new file mode 100644 index 000000000..e4b42f7f6 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/sass-loader/package.json @@ -0,0 +1,144 @@ +{ + "_from": "sass-loader@^8.0.2", + "_id": "sass-loader@8.0.2", + "_inBundle": false, + "_integrity": "sha512-7o4dbSK8/Ol2KflEmSco4jTjQoV988bM82P9CZdmo9hR3RLnvNc0ufMNdMrB0caq38JQ/FgF4/7RcbcfKzxoFQ==", + "_location": "/sass-loader", + "_phantomChildren": { + "@types/json-schema": "7.0.5", + "ajv": "6.12.2", + "ajv-keywords": "3.4.1" + }, + "_requested": { + "type": "range", + "registry": true, + "raw": "sass-loader@^8.0.2", + "name": "sass-loader", + "escapedName": "sass-loader", + "rawSpec": "^8.0.2", + "saveSpec": null, + "fetchSpec": "^8.0.2" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-8.0.2.tgz", + "_shasum": "debecd8c3ce243c76454f2e8290482150380090d", + "_spec": "sass-loader@^8.0.2", + "_where": "/Users/fxy/Documents/DCloud/HbuilderX-plugins/alpha/uniapp-cli", + "author": { + "name": "J. Tangelder" + }, + "bugs": { + "url": "https://github.com/webpack-contrib/sass-loader/issues" + }, + "bundleDependencies": false, + "dependencies": { + "clone-deep": "^4.0.1", + "loader-utils": "^1.2.3", + "neo-async": "^2.6.1", + "schema-utils": "^2.6.1", + "semver": "^6.3.0" + }, + "deprecated": false, + "description": "Sass loader for webpack", + "devDependencies": { + "@babel/cli": "^7.8.0", + "@babel/core": "^7.8.0", + "@babel/preset-env": "^7.8.2", + "@commitlint/cli": "^8.3.4", + "@commitlint/config-conventional": "^8.3.4", + "@webpack-contrib/defaults": "^6.3.0", + "@webpack-contrib/eslint-config-webpack": "^3.0.0", + "babel-jest": "^24.9.0", + "bootstrap": "^4.4.1", + "bootstrap-sass": "^3.4.1", + "commitlint-azure-pipelines-cli": "^1.0.3", + "cross-env": "^6.0.3", + "css-loader": "^3.4.2", + "del": "^5.1.0", + "del-cli": "^3.0.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.9.0", + "eslint-plugin-import": "^2.20.0", + "fibers": "^4.0.2", + "file-loader": "^5.0.2", + "husky": "^4.0.7", + "jest": "^24.9.0", + "jest-junit": "^10.0.0", + "jquery": "^3.4.1", + "lint-staged": "^9.5.0", + "memfs": "^3.0.3", + "node-sass": "^4.13.0", + "npm-run-all": "^4.1.5", + "prettier": "^1.19.1", + "sass": "^1.24.4", + "standard-version": "^7.0.1", + "style-loader": "^1.1.2", + "webpack": "^4.41.5", + "webpack-cli": "^3.3.10", + "webpack-dev-server": "^3.10.1" + }, + "engines": { + "node": ">= 8.9.0" + }, + "files": [ + "dist" + ], + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "homepage": "https://github.com/webpack-contrib/sass-loader", + "keywords": [ + "sass", + "libsass", + "webpack", + "loader" + ], + "license": "MIT", + "main": "dist/cjs.js", + "name": "sass-loader", + "peerDependencies": { + "webpack": "^4.36.0 || ^5.0.0", + "node-sass": "^4.0.0", + "sass": "^1.3.0", + "fibers": ">= 3.1.0" + }, + "peerDependenciesMeta": { + "node-sass": { + "optional": true + }, + "sass": { + "optional": true + }, + "fibers": { + "optional": true + } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/webpack-contrib/sass-loader.git" + }, + "scripts": { + "build": "cross-env NODE_ENV=production babel src -d dist --copy-files", + "clean": "del-cli dist", + "commitlint": "commitlint --from=master", + "defaults": "webpack-defaults", + "lint": "npm-run-all -l -p \"lint:**\"", + "lint:js": "eslint --cache .", + "lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different", + "prebuild": "npm run clean", + "prepare": "npm run build", + "pretest": "npm run lint", + "release": "standard-version", + "security": "npm audit", + "start": "npm run build -- -w", + "test": "npm run test:coverage", + "test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage", + "test:manual": "npm run build && webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js", + "test:only": "cross-env NODE_ENV=test jest", + "test:watch": "npm run test:only -- --watch" + }, + "version": "8.0.2" +} -- GitLab