@umijs/bundler-webpack 3.5.20 → 4.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/bin/bundler-webpack.js +1 -2
- package/client/client/client.js +202 -0
- package/client/constants.js +12 -0
- package/client/utils/formatWebpackMessages.js +92 -0
- package/compiled/@svgr/webpack/.svgo.yml +75 -0
- package/compiled/@svgr/webpack/LICENSE +7 -0
- package/compiled/@svgr/webpack/index.js +343 -0
- package/compiled/@svgr/webpack/package.json +1 -0
- package/compiled/autoprefixer/LICENSE +20 -0
- package/compiled/autoprefixer/browserslist/index.d.ts +172 -0
- package/compiled/autoprefixer/index.js +9 -0
- package/compiled/autoprefixer/lib/autoprefixer.d.ts +95 -0
- package/compiled/autoprefixer/package.json +1 -0
- package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +106 -0
- package/compiled/autoprefixer/postcss/lib/comment.d.ts +56 -0
- package/compiled/autoprefixer/postcss/lib/container.d.ts +442 -0
- package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +192 -0
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +124 -0
- package/compiled/autoprefixer/postcss/lib/document.d.ts +57 -0
- package/compiled/autoprefixer/postcss/lib/input.d.ts +130 -0
- package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +175 -0
- package/compiled/autoprefixer/postcss/lib/list.d.ts +51 -0
- package/compiled/autoprefixer/postcss/lib/node.d.ts +444 -0
- package/compiled/autoprefixer/postcss/lib/postcss.d.ts +472 -0
- package/compiled/autoprefixer/postcss/lib/previous-map.d.ts +72 -0
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +101 -0
- package/compiled/autoprefixer/postcss/lib/result.d.ts +195 -0
- package/compiled/autoprefixer/postcss/lib/root.d.ts +73 -0
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +104 -0
- package/compiled/autoprefixer/postcss/lib/warning.d.ts +104 -0
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +98 -0
- package/compiled/babel-loader/LICENSE +22 -0
- package/compiled/babel-loader/index.js +3 -0
- package/compiled/babel-loader/package.json +1 -0
- package/compiled/compression/LICENSE +23 -0
- package/compiled/compression/index.js +57 -0
- package/compiled/compression/package.json +1 -0
- package/compiled/connect-history-api-fallback/LICENSE +21 -0
- package/compiled/connect-history-api-fallback/index.js +1 -0
- package/compiled/connect-history-api-fallback/package.json +1 -0
- package/{lib/webpack/plugins/mini-css-extract-plugin → compiled/copy-webpack-plugin}/LICENSE +0 -0
- package/compiled/copy-webpack-plugin/index.js +46 -0
- package/compiled/copy-webpack-plugin/package.json +1 -0
- package/{lib/webpack/plugins/terser-webpack-plugin → compiled/css-loader}/LICENSE +0 -0
- package/compiled/css-loader/api.js +102 -0
- package/compiled/css-loader/getUrl.js +29 -0
- package/compiled/css-loader/index.js +2 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +22 -0
- package/compiled/css-minimizer-webpack-plugin/LICENSE +20 -0
- package/compiled/css-minimizer-webpack-plugin/index.js +3 -0
- package/compiled/css-minimizer-webpack-plugin/minify.js +72 -0
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -0
- package/compiled/css-minimizer-webpack-plugin/utils.js +166 -0
- package/compiled/cssnano/index.js +192 -0
- package/compiled/cssnano/package.json +1 -0
- package/compiled/express/LICENSE +24 -0
- package/compiled/express/body-parser/index.d.ts +104 -0
- package/compiled/express/connect/index.d.ts +93 -0
- package/compiled/express/express-serve-static-core/index.d.ts +1252 -0
- package/compiled/express/index.d.ts +133 -0
- package/compiled/express/index.js +338 -0
- package/compiled/express/mime/index.d.ts +35 -0
- package/compiled/express/package.json +1 -0
- package/compiled/express/qs/index.d.ts +62 -0
- package/compiled/express/range-parser/index.d.ts +35 -0
- package/compiled/express/serve-static/index.d.ts +108 -0
- package/compiled/http-proxy-middleware/LICENSE +22 -0
- package/compiled/http-proxy-middleware/dist/index.d.ts +4 -0
- package/compiled/http-proxy-middleware/dist/types.d.ts +54 -0
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +226 -0
- package/compiled/http-proxy-middleware/index.js +66 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/less/index.js +31 -0
- package/compiled/less/package.json +1 -0
- package/compiled/less-loader/LICENSE +20 -0
- package/compiled/less-loader/index.js +1 -0
- package/compiled/less-loader/package.json +1 -0
- package/compiled/mini-css-extract-plugin/LICENSE +20 -0
- package/{lib/webpack/plugins/mini-css-extract-plugin/src → compiled/mini-css-extract-plugin}/hmr/hotModuleReplacement.js +50 -52
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +35 -0
- package/compiled/mini-css-extract-plugin/index.js +11606 -0
- package/compiled/mini-css-extract-plugin/loader-options.json +32 -0
- package/compiled/mini-css-extract-plugin/loader.js +315 -0
- package/compiled/mini-css-extract-plugin/package.json +1 -0
- package/compiled/mini-css-extract-plugin/utils.js +154 -0
- package/compiled/postcss-flexbugs-fixes/LICENSE +20 -0
- package/compiled/postcss-flexbugs-fixes/index.js +1 -0
- package/compiled/postcss-flexbugs-fixes/package.json +1 -0
- package/compiled/postcss-loader/LICENSE +20 -0
- package/compiled/postcss-loader/index.js +1 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/purgecss-webpack-plugin/LICENSE +21 -0
- package/compiled/purgecss-webpack-plugin/index.js +7781 -0
- package/compiled/purgecss-webpack-plugin/package.json +1 -0
- package/compiled/react-refresh/index.js +19 -0
- package/compiled/sass-loader/LICENSE +20 -0
- package/compiled/sass-loader/index.js +1 -0
- package/compiled/sass-loader/package.json +1 -0
- package/compiled/schema-utils/LICENSE +20 -0
- package/compiled/schema-utils/ajv/lib/ajv.d.ts +397 -0
- package/compiled/schema-utils/declarations/ValidationError.d.ts +74 -0
- package/compiled/schema-utils/declarations/index.d.ts +3 -0
- package/compiled/schema-utils/declarations/validate.d.ts +37 -0
- package/compiled/schema-utils/index.js +3 -0
- package/compiled/schema-utils/json-schema/index.d.ts +751 -0
- package/compiled/schema-utils/package.json +1 -0
- package/compiled/speed-measure-webpack-plugin/LICENSE +21 -0
- package/compiled/speed-measure-webpack-plugin/index.js +1 -0
- package/compiled/speed-measure-webpack-plugin/package.json +1 -0
- package/compiled/style-loader/LICENSE +20 -0
- package/compiled/style-loader/index.js +1 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +104 -0
- package/compiled/style-loader/runtime/insertBySelector.js +39 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +11 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +35 -0
- package/compiled/style-loader/runtime/isOldIE.js +19 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +16 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +10 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +12 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +93 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +70 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +16 -0
- package/compiled/svgo-loader/LICENSE +22 -0
- package/compiled/svgo-loader/index.js +4 -0
- package/compiled/svgo-loader/package.json +1 -0
- package/compiled/swc-loader/LICENSE +25 -0
- package/compiled/swc-loader/index.js +1 -0
- package/compiled/swc-loader/package.json +1 -0
- package/compiled/tapable/LICENSE +21 -0
- package/compiled/tapable/index.js +1 -0
- package/compiled/tapable/package.json +1 -0
- package/compiled/tapable/tapable.d.ts +116 -0
- package/compiled/terser/LICENSE +29 -0
- package/compiled/terser/index.js +1 -0
- package/compiled/terser/mappings.wasm +0 -0
- package/compiled/terser/package.json +1 -0
- package/compiled/terser/source-map/source-map.d.ts +369 -0
- package/compiled/terser/tools/terser.d.ts +207 -0
- package/compiled/terser-webpack-plugin/LICENSE +20 -0
- package/compiled/terser-webpack-plugin/ajv/lib/ajv.d.ts +397 -0
- package/compiled/terser-webpack-plugin/index.js +15142 -0
- package/compiled/terser-webpack-plugin/jest-worker/build/index.d.ts +49 -0
- package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +142 -0
- package/compiled/terser-webpack-plugin/json-schema/index.d.ts +751 -0
- package/compiled/terser-webpack-plugin/minify.js +43 -0
- package/compiled/terser-webpack-plugin/package.json +1 -0
- package/compiled/terser-webpack-plugin/schema-utils/declarations/ValidationError.d.ts +74 -0
- package/compiled/terser-webpack-plugin/schema-utils/declarations/index.d.ts +3 -0
- package/compiled/terser-webpack-plugin/schema-utils/declarations/validate.d.ts +37 -0
- package/compiled/terser-webpack-plugin/source-map/source-map.d.ts +98 -0
- package/compiled/terser-webpack-plugin/types/cjs.d.ts +3 -0
- package/compiled/terser-webpack-plugin/types/index.d.ts +295 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +105 -0
- package/compiled/terser-webpack-plugin/utils.js +594 -0
- package/compiled/url-loader/LICENSE +20 -0
- package/compiled/url-loader/index.js +15 -0
- package/compiled/url-loader/package.json +1 -0
- package/compiled/webpack/Chunk.js +1 -0
- package/compiled/webpack/Compilation.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +394 -0
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +462 -0
- package/compiled/webpack/LICENSE +20 -0
- package/compiled/webpack/LibraryTemplatePlugin.js +1 -0
- package/compiled/webpack/LoaderTargetPlugin.js +1 -0
- package/compiled/webpack/ModuleFilenameHelpers.js +1 -0
- package/compiled/webpack/NormalModule.js +1 -0
- package/compiled/webpack/RuntimeGlobals.js +1 -0
- package/compiled/webpack/RuntimeModule.js +1 -0
- package/compiled/webpack/SingleEntryPlugin.js +1 -0
- package/compiled/webpack/Template.js +1 -0
- package/compiled/webpack/ajv/lib/ajv.d.ts +397 -0
- package/compiled/webpack/deepImports.json +12 -0
- package/compiled/webpack/index.js +162861 -0
- package/compiled/webpack/json-schema/index.d.ts +751 -0
- package/compiled/webpack/lazy-compilation-node.js +40 -0
- package/compiled/webpack/lazy-compilation-web.js +74 -0
- package/compiled/webpack/package.json +5 -0
- package/compiled/webpack/schema-utils/declarations/ValidationError.d.ts +74 -0
- package/compiled/webpack/schema-utils/declarations/index.d.ts +3 -0
- package/compiled/webpack/schema-utils/declarations/validate.d.ts +37 -0
- package/compiled/webpack/types.d.ts +12664 -0
- package/compiled/webpack-5-chain/LICENSE +373 -0
- package/compiled/webpack-5-chain/index.js +1 -0
- package/compiled/webpack-5-chain/package.json +1 -0
- package/compiled/webpack-5-chain/types/index.d.ts +543 -0
- package/compiled/webpack-bundle-analyzer/LICENSE +20 -0
- package/compiled/webpack-bundle-analyzer/index.js +30 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -0
- package/compiled/webpack-dev-middleware/LICENSE +20 -0
- package/compiled/webpack-dev-middleware/index.js +21 -0
- package/compiled/webpack-dev-middleware/package.json +1 -0
- package/compiled/webpack-sources/LICENSE +21 -0
- package/compiled/webpack-sources/index.d.ts +20 -0
- package/compiled/webpack-sources/index.js +1 -0
- package/compiled/webpack-sources/lib/CachedSource.d.ts +18 -0
- package/compiled/webpack-sources/lib/CompatSource.d.ts +9 -0
- package/compiled/webpack-sources/lib/ConcatSource.d.ts +22 -0
- package/compiled/webpack-sources/lib/OriginalSource.d.ts +18 -0
- package/compiled/webpack-sources/lib/PrefixSource.d.ts +12 -0
- package/compiled/webpack-sources/lib/RawSource.d.ts +13 -0
- package/compiled/webpack-sources/lib/ReplaceSource.d.ts +35 -0
- package/compiled/webpack-sources/lib/SizeOnlySource.d.ts +7 -0
- package/compiled/webpack-sources/lib/Source.d.ts +45 -0
- package/compiled/webpack-sources/lib/SourceMapSource.d.ts +22 -0
- package/compiled/webpack-sources/lib/index.d.ts +60 -0
- package/compiled/webpack-sources/package.json +1 -0
- package/compiled/webpack-sources/source-list-map/index.d.ts +91 -0
- package/compiled/webpack-sources/source-map/source-map.d.ts +369 -0
- package/compiled/ws/LICENSE +19 -0
- package/compiled/ws/index.d.ts +359 -0
- package/compiled/ws/index.js +1 -0
- package/compiled/ws/package.json +1 -0
- package/dist/build.d.ts +16 -0
- package/dist/build.js +71 -0
- package/{lib → dist}/cli.d.ts +0 -0
- package/dist/cli.js +113 -0
- package/{lib/webpackHotDevClient/webpackHotDevClient.d.ts → dist/client/client.d.ts} +0 -0
- package/dist/client/client.js +239 -0
- package/dist/config/_sampleFeature.d.ts +10 -0
- package/dist/config/_sampleFeature.js +22 -0
- package/dist/config/assetRules.d.ts +11 -0
- package/dist/config/assetRules.js +57 -0
- package/dist/config/bundleAnalyzerPlugin.d.ts +10 -0
- package/dist/config/bundleAnalyzerPlugin.js +30 -0
- package/dist/config/compressPlugin.d.ts +10 -0
- package/dist/config/compressPlugin.js +77 -0
- package/dist/config/config.d.ts +19 -0
- package/dist/config/config.js +171 -0
- package/dist/config/copyPlugin.d.ts +10 -0
- package/dist/config/copyPlugin.js +49 -0
- package/dist/config/cssRules.d.ts +11 -0
- package/dist/config/cssRules.js +98 -0
- package/dist/config/definePlugin.d.ts +15 -0
- package/dist/config/definePlugin.js +45 -0
- package/dist/config/fastRefreshPlugin.d.ts +12 -0
- package/dist/config/fastRefreshPlugin.js +34 -0
- package/dist/config/ignorePlugin.d.ts +10 -0
- package/dist/config/ignorePlugin.js +27 -0
- package/dist/config/javaScriptRules.d.ts +14 -0
- package/dist/config/javaScriptRules.js +150 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +10 -0
- package/dist/config/miniCSSExtractPlugin.js +34 -0
- package/dist/config/nodePolyfill.d.ts +10 -0
- package/dist/config/nodePolyfill.js +34 -0
- package/dist/config/progressPlugin.d.ts +11 -0
- package/dist/config/progressPlugin.js +27 -0
- package/dist/config/purgecssWebpackPlugin.d.ts +10 -0
- package/dist/config/purgecssWebpackPlugin.js +32 -0
- package/dist/config/speedMeasureWebpackPlugin.d.ts +6 -0
- package/dist/config/speedMeasureWebpackPlugin.js +34 -0
- package/dist/config/svgRules.d.ts +11 -0
- package/dist/config/svgRules.js +56 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +15 -0
- package/dist/dev.d.ts +18 -0
- package/dist/dev.js +80 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +16 -0
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +11 -0
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +65 -0
- package/dist/plugins/ProgressPlugin.d.ts +15 -0
- package/dist/plugins/ProgressPlugin.js +44 -0
- package/dist/plugins/_SamplePlugin.d.ts +9 -0
- package/dist/plugins/_SamplePlugin.js +14 -0
- package/dist/requireHook.d.ts +1 -0
- package/dist/requireHook.js +31 -0
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +68 -0
- package/dist/server/server.d.ts +16 -0
- package/dist/server/server.js +157 -0
- package/dist/server/ws.d.ts +8 -0
- package/dist/server/ws.js +42 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.js +29 -0
- package/dist/utils/browsersList.d.ts +5 -0
- package/dist/utils/browsersList.js +10 -0
- package/dist/utils/depMatch.d.ts +6 -0
- package/dist/utils/depMatch.js +46 -0
- package/dist/utils/formatWebpackMessages.d.ts +12 -0
- package/dist/utils/formatWebpackMessages.js +100 -0
- package/package.json +163 -35
- package/bundled/css/hotModuleReplacement.js +0 -1203
- package/bundled/js/webpackHotDevClient.js +0 -13386
- package/lib/DevCompileDonePlugin.d.ts +0 -10
- package/lib/DevCompileDonePlugin.js +0 -53
- package/lib/cli.js +0 -184
- package/lib/getConfig/css.d.ts +0 -22
- package/lib/getConfig/css.js +0 -186
- package/lib/getConfig/getConfig.d.ts +0 -26
- package/lib/getConfig/getConfig.js +0 -578
- package/lib/getConfig/nodeModulesTransform.d.ts +0 -13
- package/lib/getConfig/nodeModulesTransform.js +0 -141
- package/lib/getConfig/pkgMatch.d.ts +0 -2
- package/lib/getConfig/pkgMatch.js +0 -58
- package/lib/getConfig/resolveDefine.d.ts +0 -5
- package/lib/getConfig/resolveDefine.js +0 -53
- package/lib/getConfig/runtimePublicPathEntry.d.ts +0 -1
- package/lib/getConfig/runtimePublicPathEntry.js +0 -3
- package/lib/getConfig/terserOptions.d.ts +0 -41
- package/lib/getConfig/terserOptions.js +0 -64
- package/lib/index.d.ts +0 -34
- package/lib/index.js +0 -314
- package/lib/requireHook.d.ts +0 -3
- package/lib/requireHook.js +0 -51
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssDependency.js +0 -94
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssDependencyTemplate.js +0 -26
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssLoadingRuntimeModule.js +0 -93
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssModule.js +0 -164
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssModuleFactory.js +0 -32
- package/lib/webpack/plugins/mini-css-extract-plugin/src/cjs.js +0 -15
- package/lib/webpack/plugins/mini-css-extract-plugin/src/index.js +0 -542
- package/lib/webpack/plugins/mini-css-extract-plugin/src/loader.js +0 -319
- package/lib/webpack/plugins/mini-css-extract-plugin/src/utils.js +0 -97
- package/lib/webpack/plugins/mini-css-extract-plugin.d.ts +0 -1
- package/lib/webpack/plugins/mini-css-extract-plugin.js +0 -15
- package/lib/webpack/plugins/terser-webpack-plugin/package.json +0 -3
- package/lib/webpack/plugins/terser-webpack-plugin/src/Webpack4Cache.js +0 -187
- package/lib/webpack/plugins/terser-webpack-plugin/src/Webpack5Cache.js +0 -61
- package/lib/webpack/plugins/terser-webpack-plugin/src/index.js +0 -683
- package/lib/webpack/plugins/terser-webpack-plugin/src/minify.js +0 -197
- package/lib/webpack/plugins/terser-webpack-plugin.d.ts +0 -1
- package/lib/webpack/plugins/terser-webpack-plugin.js +0 -15
- package/lib/webpackHotDevClient/formatWebpackMessages.d.ts +0 -11
- package/lib/webpackHotDevClient/formatWebpackMessages.js +0 -127
- package/lib/webpackHotDevClient/webpackHotDevClient.js +0 -311
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Plugin } from '../postcss'
|
|
2
|
+
import { Stats } from '../browserslist'
|
|
3
|
+
|
|
4
|
+
declare function autoprefixer<T extends string[]>(
|
|
5
|
+
...args: [...T, autoprefixer.Options]
|
|
6
|
+
): Plugin & autoprefixer.ExportedAPI
|
|
7
|
+
|
|
8
|
+
declare function autoprefixer(
|
|
9
|
+
browsers: string[],
|
|
10
|
+
options?: autoprefixer.Options
|
|
11
|
+
): Plugin & autoprefixer.ExportedAPI
|
|
12
|
+
|
|
13
|
+
declare function autoprefixer(
|
|
14
|
+
options?: autoprefixer.Options
|
|
15
|
+
): Plugin & autoprefixer.ExportedAPI
|
|
16
|
+
|
|
17
|
+
declare namespace autoprefixer {
|
|
18
|
+
type GridValue = 'autoplace' | 'no-autoplace'
|
|
19
|
+
|
|
20
|
+
interface Options {
|
|
21
|
+
/** environment for `Browserslist` */
|
|
22
|
+
env?: string
|
|
23
|
+
|
|
24
|
+
/** should Autoprefixer use Visual Cascade, if CSS is uncompressed */
|
|
25
|
+
cascade?: boolean
|
|
26
|
+
|
|
27
|
+
/** should Autoprefixer add prefixes. */
|
|
28
|
+
add?: boolean
|
|
29
|
+
|
|
30
|
+
/** should Autoprefixer [remove outdated] prefixes */
|
|
31
|
+
remove?: boolean
|
|
32
|
+
|
|
33
|
+
/** should Autoprefixer add prefixes for @supports parameters. */
|
|
34
|
+
supports?: boolean
|
|
35
|
+
|
|
36
|
+
/** should Autoprefixer add prefixes for flexbox properties */
|
|
37
|
+
flexbox?: boolean | 'no-2009'
|
|
38
|
+
|
|
39
|
+
/** should Autoprefixer add IE 10-11 prefixes for Grid Layout properties */
|
|
40
|
+
grid?: boolean | GridValue
|
|
41
|
+
|
|
42
|
+
/** custom usage statistics for > 10% in my stats browsers query */
|
|
43
|
+
stats?: Stats
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* list of queries for target browsers.
|
|
47
|
+
* Try to not use it.
|
|
48
|
+
* The best practice is to use `.browserslistrc` config or `browserslist` key in `package.json`
|
|
49
|
+
* to share target browsers with Babel, ESLint and Stylelint
|
|
50
|
+
*/
|
|
51
|
+
overrideBrowserslist?: string | string[]
|
|
52
|
+
|
|
53
|
+
/** do not raise error on unknown browser version in `Browserslist` config. */
|
|
54
|
+
ignoreUnknownVersions?: boolean
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface ExportedAPI {
|
|
58
|
+
/** Autoprefixer data */
|
|
59
|
+
data: {
|
|
60
|
+
browsers: { [browser: string]: object | undefined }
|
|
61
|
+
prefixes: { [prefixName: string]: object | undefined }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Autoprefixer default browsers */
|
|
65
|
+
defaults: string[]
|
|
66
|
+
|
|
67
|
+
/** Inspect with default Autoprefixer */
|
|
68
|
+
info(options?: { from?: string }): string
|
|
69
|
+
|
|
70
|
+
options: Options
|
|
71
|
+
|
|
72
|
+
browsers: string | string[]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Autoprefixer data */
|
|
76
|
+
let data: ExportedAPI['data']
|
|
77
|
+
|
|
78
|
+
/** Autoprefixer default browsers */
|
|
79
|
+
let defaults: ExportedAPI['defaults']
|
|
80
|
+
|
|
81
|
+
/** Inspect with default Autoprefixer */
|
|
82
|
+
let info: ExportedAPI['info']
|
|
83
|
+
|
|
84
|
+
let postcss: true
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare global {
|
|
88
|
+
namespace NodeJS {
|
|
89
|
+
interface ProcessEnv {
|
|
90
|
+
AUTOPREFIXER_GRID?: autoprefixer.GridValue
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export = autoprefixer
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"autoprefixer","author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT","types":"lib/autoprefixer.d.ts"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import Container, { ContainerProps } from './container'
|
|
2
|
+
|
|
3
|
+
interface AtRuleRaws {
|
|
4
|
+
/**
|
|
5
|
+
* The space symbols before the node. It also stores `*`
|
|
6
|
+
* and `_` symbols before the declaration (IE hack).
|
|
7
|
+
*/
|
|
8
|
+
before?: string
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The space symbols after the last child of the node to the end of the node.
|
|
12
|
+
*/
|
|
13
|
+
after?: string
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The space between the at-rule name and its parameters.
|
|
17
|
+
*/
|
|
18
|
+
afterName?: string
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The symbols between the last parameter and `{` for rules.
|
|
22
|
+
*/
|
|
23
|
+
between?: string
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Contains `true` if the last child has an (optional) semicolon.
|
|
27
|
+
*/
|
|
28
|
+
semicolon?: boolean
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The rule’s selector with comments.
|
|
32
|
+
*/
|
|
33
|
+
params?: {
|
|
34
|
+
value: string
|
|
35
|
+
raw: string
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface AtRuleProps extends ContainerProps {
|
|
40
|
+
/** Name of the at-rule. */
|
|
41
|
+
name: string
|
|
42
|
+
/** Parameters following the name of the at-rule. */
|
|
43
|
+
params?: string | number
|
|
44
|
+
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
|
45
|
+
raws?: AtRuleRaws
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Represents an at-rule.
|
|
50
|
+
*
|
|
51
|
+
* ```js
|
|
52
|
+
* Once (root, { AtRule }) {
|
|
53
|
+
* let media = new AtRule({ name: 'media', params: 'print' })
|
|
54
|
+
* media.append(…)
|
|
55
|
+
* root.append(media)
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* If it’s followed in the CSS by a {} block, this node will have
|
|
60
|
+
* a nodes property representing its children.
|
|
61
|
+
*
|
|
62
|
+
* ```js
|
|
63
|
+
* const root = postcss.parse('@charset "UTF-8"; @media print {}')
|
|
64
|
+
*
|
|
65
|
+
* const charset = root.first
|
|
66
|
+
* charset.type //=> 'atrule'
|
|
67
|
+
* charset.nodes //=> undefined
|
|
68
|
+
*
|
|
69
|
+
* const media = root.last
|
|
70
|
+
* media.nodes //=> []
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export default class AtRule extends Container {
|
|
74
|
+
type: 'atrule'
|
|
75
|
+
parent: Container | undefined
|
|
76
|
+
raws: AtRuleRaws
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The at-rule’s name immediately follows the `@`.
|
|
80
|
+
*
|
|
81
|
+
* ```js
|
|
82
|
+
* const root = postcss.parse('@media print {}')
|
|
83
|
+
* media.name //=> 'media'
|
|
84
|
+
* const media = root.first
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
name: string
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The at-rule’s parameters, the values that follow the at-rule’s name
|
|
91
|
+
* but precede any {} block.
|
|
92
|
+
*
|
|
93
|
+
* ```js
|
|
94
|
+
* const root = postcss.parse('@media print, screen {}')
|
|
95
|
+
* const media = root.first
|
|
96
|
+
* media.params //=> 'print, screen'
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
params: string
|
|
100
|
+
|
|
101
|
+
constructor(defaults?: AtRuleProps)
|
|
102
|
+
assign(overrides: object | AtRuleProps): this
|
|
103
|
+
clone(overrides?: Partial<AtRuleProps>): this
|
|
104
|
+
cloneBefore(overrides?: Partial<AtRuleProps>): this
|
|
105
|
+
cloneAfter(overrides?: Partial<AtRuleProps>): this
|
|
106
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Container from './container'
|
|
2
|
+
import Node, { NodeProps } from './node'
|
|
3
|
+
|
|
4
|
+
interface CommentRaws {
|
|
5
|
+
/**
|
|
6
|
+
* The space symbols before the node.
|
|
7
|
+
*/
|
|
8
|
+
before?: string
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The space symbols between `/*` and the comment’s text.
|
|
12
|
+
*/
|
|
13
|
+
left?: string
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The space symbols between the comment’s text.
|
|
17
|
+
*/
|
|
18
|
+
right?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CommentProps extends NodeProps {
|
|
22
|
+
/** Content of the comment. */
|
|
23
|
+
text: string
|
|
24
|
+
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
|
25
|
+
raws?: CommentRaws
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Represents a comment between declarations or statements (rule and at-rules).
|
|
30
|
+
*
|
|
31
|
+
* ```js
|
|
32
|
+
* Once (root, { Comment }) {
|
|
33
|
+
* let note = new Comment({ text: 'Note: …' })
|
|
34
|
+
* root.append(note)
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Comments inside selectors, at-rule parameters, or declaration values
|
|
39
|
+
* will be stored in the `raws` properties explained above.
|
|
40
|
+
*/
|
|
41
|
+
export default class Comment extends Node {
|
|
42
|
+
type: 'comment'
|
|
43
|
+
parent: Container | undefined
|
|
44
|
+
raws: CommentRaws
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The comment's text.
|
|
48
|
+
*/
|
|
49
|
+
text: string
|
|
50
|
+
|
|
51
|
+
constructor(defaults?: CommentProps)
|
|
52
|
+
assign(overrides: object | CommentProps): this
|
|
53
|
+
clone(overrides?: Partial<CommentProps>): this
|
|
54
|
+
cloneBefore(overrides?: Partial<CommentProps>): this
|
|
55
|
+
cloneAfter(overrides?: Partial<CommentProps>): this
|
|
56
|
+
}
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import Node, { ChildNode, NodeProps, ChildProps } from './node'
|
|
2
|
+
import Declaration from './declaration'
|
|
3
|
+
import Comment from './comment'
|
|
4
|
+
import AtRule from './at-rule'
|
|
5
|
+
import Rule from './rule'
|
|
6
|
+
|
|
7
|
+
interface ValueOptions {
|
|
8
|
+
/**
|
|
9
|
+
* An array of property names.
|
|
10
|
+
*/
|
|
11
|
+
props?: string[]
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* String that’s used to narrow down values and speed up the regexp search.
|
|
15
|
+
*/
|
|
16
|
+
fast?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ContainerProps extends NodeProps {
|
|
20
|
+
nodes?: (ChildNode | ChildProps)[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The `Root`, `AtRule`, and `Rule` container nodes
|
|
25
|
+
* inherit some common methods to help work with their children.
|
|
26
|
+
*
|
|
27
|
+
* Note that all containers can store any content. If you write a rule inside
|
|
28
|
+
* a rule, PostCSS will parse it.
|
|
29
|
+
*/
|
|
30
|
+
export default abstract class Container<
|
|
31
|
+
Child extends Node = ChildNode
|
|
32
|
+
> extends Node {
|
|
33
|
+
/**
|
|
34
|
+
* An array containing the container’s children.
|
|
35
|
+
*
|
|
36
|
+
* ```js
|
|
37
|
+
* const root = postcss.parse('a { color: black }')
|
|
38
|
+
* root.nodes.length //=> 1
|
|
39
|
+
* root.nodes[0].selector //=> 'a'
|
|
40
|
+
* root.nodes[0].nodes[0].prop //=> 'color'
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
nodes: Child[]
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The container’s first child.
|
|
47
|
+
*
|
|
48
|
+
* ```js
|
|
49
|
+
* rule.first === rules.nodes[0]
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
get first(): Child | undefined
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The container’s last child.
|
|
56
|
+
*
|
|
57
|
+
* ```js
|
|
58
|
+
* rule.last === rule.nodes[rule.nodes.length - 1]
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
get last(): Child | undefined
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Iterates through the container’s immediate children,
|
|
65
|
+
* calling `callback` for each child.
|
|
66
|
+
*
|
|
67
|
+
* Returning `false` in the callback will break iteration.
|
|
68
|
+
*
|
|
69
|
+
* This method only iterates through the container’s immediate children.
|
|
70
|
+
* If you need to recursively iterate through all the container’s descendant
|
|
71
|
+
* nodes, use `Container#walk`.
|
|
72
|
+
*
|
|
73
|
+
* Unlike the for `{}`-cycle or `Array#forEach` this iterator is safe
|
|
74
|
+
* if you are mutating the array of child nodes during iteration.
|
|
75
|
+
* PostCSS will adjust the current index to match the mutations.
|
|
76
|
+
*
|
|
77
|
+
* ```js
|
|
78
|
+
* const root = postcss.parse('a { color: black; z-index: 1 }')
|
|
79
|
+
* const rule = root.first
|
|
80
|
+
*
|
|
81
|
+
* for (const decl of rule.nodes) {
|
|
82
|
+
* decl.cloneBefore({ prop: '-webkit-' + decl.prop })
|
|
83
|
+
* // Cycle will be infinite, because cloneBefore moves the current node
|
|
84
|
+
* // to the next index
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* rule.each(decl => {
|
|
88
|
+
* decl.cloneBefore({ prop: '-webkit-' + decl.prop })
|
|
89
|
+
* // Will be executed only for color and z-index
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param callback Iterator receives each node and index.
|
|
94
|
+
* @return Returns `false` if iteration was broke.
|
|
95
|
+
*/
|
|
96
|
+
each(
|
|
97
|
+
callback: (node: Child, index: number) => false | void
|
|
98
|
+
): false | undefined
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Traverses the container’s descendant nodes, calling callback
|
|
102
|
+
* for each node.
|
|
103
|
+
*
|
|
104
|
+
* Like container.each(), this method is safe to use
|
|
105
|
+
* if you are mutating arrays during iteration.
|
|
106
|
+
*
|
|
107
|
+
* If you only need to iterate through the container’s immediate children,
|
|
108
|
+
* use `Container#each`.
|
|
109
|
+
*
|
|
110
|
+
* ```js
|
|
111
|
+
* root.walk(node => {
|
|
112
|
+
* // Traverses all descendant nodes.
|
|
113
|
+
* })
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @param callback Iterator receives each node and index.
|
|
117
|
+
* @return Returns `false` if iteration was broke.
|
|
118
|
+
*/
|
|
119
|
+
walk(
|
|
120
|
+
callback: (node: ChildNode, index: number) => false | void
|
|
121
|
+
): false | undefined
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Traverses the container’s descendant nodes, calling callback
|
|
125
|
+
* for each declaration node.
|
|
126
|
+
*
|
|
127
|
+
* If you pass a filter, iteration will only happen over declarations
|
|
128
|
+
* with matching properties.
|
|
129
|
+
*
|
|
130
|
+
* ```js
|
|
131
|
+
* root.walkDecls(decl => {
|
|
132
|
+
* checkPropertySupport(decl.prop)
|
|
133
|
+
* })
|
|
134
|
+
*
|
|
135
|
+
* root.walkDecls('border-radius', decl => {
|
|
136
|
+
* decl.remove()
|
|
137
|
+
* })
|
|
138
|
+
*
|
|
139
|
+
* root.walkDecls(/^background/, decl => {
|
|
140
|
+
* decl.value = takeFirstColorFromGradient(decl.value)
|
|
141
|
+
* })
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* Like `Container#each`, this method is safe
|
|
145
|
+
* to use if you are mutating arrays during iteration.
|
|
146
|
+
*
|
|
147
|
+
* @param prop String or regular expression to filter declarations
|
|
148
|
+
* by property name.
|
|
149
|
+
* @param callback Iterator receives each node and index.
|
|
150
|
+
* @return Returns `false` if iteration was broke.
|
|
151
|
+
*/
|
|
152
|
+
walkDecls(
|
|
153
|
+
propFilter: string | RegExp,
|
|
154
|
+
callback: (decl: Declaration, index: number) => false | void
|
|
155
|
+
): false | undefined
|
|
156
|
+
walkDecls(
|
|
157
|
+
callback: (decl: Declaration, index: number) => false | void
|
|
158
|
+
): false | undefined
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Traverses the container’s descendant nodes, calling callback
|
|
162
|
+
* for each rule node.
|
|
163
|
+
*
|
|
164
|
+
* If you pass a filter, iteration will only happen over rules
|
|
165
|
+
* with matching selectors.
|
|
166
|
+
*
|
|
167
|
+
* Like `Container#each`, this method is safe
|
|
168
|
+
* to use if you are mutating arrays during iteration.
|
|
169
|
+
*
|
|
170
|
+
* ```js
|
|
171
|
+
* const selectors = []
|
|
172
|
+
* root.walkRules(rule => {
|
|
173
|
+
* selectors.push(rule.selector)
|
|
174
|
+
* })
|
|
175
|
+
* console.log(`Your CSS uses ${ selectors.length } selectors`)
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @param selector String or regular expression to filter rules by selector.
|
|
179
|
+
* @param callback Iterator receives each node and index.
|
|
180
|
+
* @return Returns `false` if iteration was broke.
|
|
181
|
+
*/
|
|
182
|
+
walkRules(
|
|
183
|
+
selectorFilter: string | RegExp,
|
|
184
|
+
callback: (atRule: Rule, index: number) => false | void
|
|
185
|
+
): false | undefined
|
|
186
|
+
walkRules(
|
|
187
|
+
callback: (atRule: Rule, index: number) => false | void
|
|
188
|
+
): false | undefined
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Traverses the container’s descendant nodes, calling callback
|
|
192
|
+
* for each at-rule node.
|
|
193
|
+
*
|
|
194
|
+
* If you pass a filter, iteration will only happen over at-rules
|
|
195
|
+
* that have matching names.
|
|
196
|
+
*
|
|
197
|
+
* Like `Container#each`, this method is safe
|
|
198
|
+
* to use if you are mutating arrays during iteration.
|
|
199
|
+
*
|
|
200
|
+
* ```js
|
|
201
|
+
* root.walkAtRules(rule => {
|
|
202
|
+
* if (isOld(rule.name)) rule.remove()
|
|
203
|
+
* })
|
|
204
|
+
*
|
|
205
|
+
* let first = false
|
|
206
|
+
* root.walkAtRules('charset', rule => {
|
|
207
|
+
* if (!first) {
|
|
208
|
+
* first = true
|
|
209
|
+
* } else {
|
|
210
|
+
* rule.remove()
|
|
211
|
+
* }
|
|
212
|
+
* })
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @param name String or regular expression to filter at-rules by name.
|
|
216
|
+
* @param callback Iterator receives each node and index.
|
|
217
|
+
* @return Returns `false` if iteration was broke.
|
|
218
|
+
*/
|
|
219
|
+
walkAtRules(
|
|
220
|
+
nameFilter: string | RegExp,
|
|
221
|
+
callback: (atRule: AtRule, index: number) => false | void
|
|
222
|
+
): false | undefined
|
|
223
|
+
walkAtRules(
|
|
224
|
+
callback: (atRule: AtRule, index: number) => false | void
|
|
225
|
+
): false | undefined
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Traverses the container’s descendant nodes, calling callback
|
|
229
|
+
* for each comment node.
|
|
230
|
+
*
|
|
231
|
+
* Like `Container#each`, this method is safe
|
|
232
|
+
* to use if you are mutating arrays during iteration.
|
|
233
|
+
*
|
|
234
|
+
* ```js
|
|
235
|
+
* root.walkComments(comment => {
|
|
236
|
+
* comment.remove()
|
|
237
|
+
* })
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @param callback Iterator receives each node and index.
|
|
241
|
+
* @return Returns `false` if iteration was broke.
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
walkComments(
|
|
245
|
+
callback: (comment: Comment, indexed: number) => false | void
|
|
246
|
+
): false | undefined
|
|
247
|
+
walkComments(
|
|
248
|
+
callback: (comment: Comment, indexed: number) => false | void
|
|
249
|
+
): false | undefined
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Inserts new nodes to the end of the container.
|
|
253
|
+
*
|
|
254
|
+
* ```js
|
|
255
|
+
* const decl1 = new Declaration({ prop: 'color', value: 'black' })
|
|
256
|
+
* const decl2 = new Declaration({ prop: 'background-color', value: 'white' })
|
|
257
|
+
* rule.append(decl1, decl2)
|
|
258
|
+
*
|
|
259
|
+
* root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
|
|
260
|
+
* root.append({ selector: 'a' }) // rule
|
|
261
|
+
* rule.append({ prop: 'color', value: 'black' }) // declaration
|
|
262
|
+
* rule.append({ text: 'Comment' }) // comment
|
|
263
|
+
*
|
|
264
|
+
* root.append('a {}')
|
|
265
|
+
* root.first.append('color: black; z-index: 1')
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @param nodes New nodes.
|
|
269
|
+
* @return This node for methods chain.
|
|
270
|
+
*/
|
|
271
|
+
append(
|
|
272
|
+
...nodes: (Node | Node[] | ChildProps | ChildProps[] | string | string[])[]
|
|
273
|
+
): this
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Inserts new nodes to the start of the container.
|
|
277
|
+
*
|
|
278
|
+
* ```js
|
|
279
|
+
* const decl1 = new Declaration({ prop: 'color', value: 'black' })
|
|
280
|
+
* const decl2 = new Declaration({ prop: 'background-color', value: 'white' })
|
|
281
|
+
* rule.prepend(decl1, decl2)
|
|
282
|
+
*
|
|
283
|
+
* root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
|
|
284
|
+
* root.append({ selector: 'a' }) // rule
|
|
285
|
+
* rule.append({ prop: 'color', value: 'black' }) // declaration
|
|
286
|
+
* rule.append({ text: 'Comment' }) // comment
|
|
287
|
+
*
|
|
288
|
+
* root.append('a {}')
|
|
289
|
+
* root.first.append('color: black; z-index: 1')
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* @param nodes New nodes.
|
|
293
|
+
* @return This node for methods chain.
|
|
294
|
+
*/
|
|
295
|
+
prepend(
|
|
296
|
+
...nodes: (Node | Node[] | ChildProps | ChildProps[] | string | string[])[]
|
|
297
|
+
): this
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Add child to the end of the node.
|
|
301
|
+
*
|
|
302
|
+
* ```js
|
|
303
|
+
* rule.push(new Declaration({ prop: 'color', value: 'black' }))
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* @param child New node.
|
|
307
|
+
* @return This node for methods chain.
|
|
308
|
+
*/
|
|
309
|
+
push(child: Child): this
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Insert new node before old node within the container.
|
|
313
|
+
*
|
|
314
|
+
* ```js
|
|
315
|
+
* rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* @param oldNode Child or child’s index.
|
|
319
|
+
* @param newNode New node.
|
|
320
|
+
* @return This node for methods chain.
|
|
321
|
+
*/
|
|
322
|
+
insertBefore(
|
|
323
|
+
oldNode: Child | number,
|
|
324
|
+
newNode: Child | ChildProps | string | Child[] | ChildProps[] | string[]
|
|
325
|
+
): this
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Insert new node after old node within the container.
|
|
329
|
+
*
|
|
330
|
+
* @param oldNode Child or child’s index.
|
|
331
|
+
* @param newNode New node.
|
|
332
|
+
* @return This node for methods chain.
|
|
333
|
+
*/
|
|
334
|
+
insertAfter(
|
|
335
|
+
oldNode: Child | number,
|
|
336
|
+
newNode: Child | ChildProps | string | Child[] | ChildProps[] | string[]
|
|
337
|
+
): this
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Removes node from the container and cleans the parent properties
|
|
341
|
+
* from the node and its children.
|
|
342
|
+
*
|
|
343
|
+
* ```js
|
|
344
|
+
* rule.nodes.length //=> 5
|
|
345
|
+
* rule.removeChild(decl)
|
|
346
|
+
* rule.nodes.length //=> 4
|
|
347
|
+
* decl.parent //=> undefined
|
|
348
|
+
* ```
|
|
349
|
+
*
|
|
350
|
+
* @param child Child or child’s index.
|
|
351
|
+
* @return This node for methods chain.
|
|
352
|
+
*/
|
|
353
|
+
removeChild(child: Child | number): this
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Removes all children from the container
|
|
357
|
+
* and cleans their parent properties.
|
|
358
|
+
*
|
|
359
|
+
* ```js
|
|
360
|
+
* rule.removeAll()
|
|
361
|
+
* rule.nodes.length //=> 0
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
364
|
+
* @return This node for methods chain.
|
|
365
|
+
*/
|
|
366
|
+
removeAll(): this
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Passes all declaration values within the container that match pattern
|
|
370
|
+
* through callback, replacing those values with the returned result
|
|
371
|
+
* of callback.
|
|
372
|
+
*
|
|
373
|
+
* This method is useful if you are using a custom unit or function
|
|
374
|
+
* and need to iterate through all values.
|
|
375
|
+
*
|
|
376
|
+
* ```js
|
|
377
|
+
* root.replaceValues(/\d+rem/, { fast: 'rem' }, string => {
|
|
378
|
+
* return 15 * parseInt(string) + 'px'
|
|
379
|
+
* })
|
|
380
|
+
* ```
|
|
381
|
+
*
|
|
382
|
+
* @param pattern Replace pattern.
|
|
383
|
+
* @param {object} opts Options to speed up the search.
|
|
384
|
+
* @param callback String to replace pattern or callback
|
|
385
|
+
* that returns a new value. The callback
|
|
386
|
+
* will receive the same arguments
|
|
387
|
+
* as those passed to a function parameter
|
|
388
|
+
* of `String#replace`.
|
|
389
|
+
* @return This node for methods chain.
|
|
390
|
+
*/
|
|
391
|
+
replaceValues(
|
|
392
|
+
pattern: string | RegExp,
|
|
393
|
+
options: ValueOptions,
|
|
394
|
+
replaced: string | { (substring: string, ...args: any[]): string }
|
|
395
|
+
): this
|
|
396
|
+
replaceValues(
|
|
397
|
+
pattern: string | RegExp,
|
|
398
|
+
replaced: string | { (substring: string, ...args: any[]): string }
|
|
399
|
+
): this
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Returns `true` if callback returns `true`
|
|
403
|
+
* for all of the container’s children.
|
|
404
|
+
*
|
|
405
|
+
* ```js
|
|
406
|
+
* const noPrefixes = rule.every(i => i.prop[0] !== '-')
|
|
407
|
+
* ```
|
|
408
|
+
*
|
|
409
|
+
* @param condition Iterator returns true or false.
|
|
410
|
+
* @return Is every child pass condition.
|
|
411
|
+
*/
|
|
412
|
+
every(
|
|
413
|
+
condition: (node: Child, index: number, nodes: Child[]) => boolean
|
|
414
|
+
): boolean
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Returns `true` if callback returns `true` for (at least) one
|
|
418
|
+
* of the container’s children.
|
|
419
|
+
*
|
|
420
|
+
* ```js
|
|
421
|
+
* const hasPrefix = rule.some(i => i.prop[0] === '-')
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* @param condition Iterator returns true or false.
|
|
425
|
+
* @return Is some child pass condition.
|
|
426
|
+
*/
|
|
427
|
+
some(
|
|
428
|
+
condition: (node: Child, index: number, nodes: Child[]) => boolean
|
|
429
|
+
): boolean
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Returns a `child`’s index within the `Container#nodes` array.
|
|
433
|
+
*
|
|
434
|
+
* ```js
|
|
435
|
+
* rule.index( rule.nodes[2] ) //=> 2
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* @param child Child of the current container.
|
|
439
|
+
* @return Child index.
|
|
440
|
+
*/
|
|
441
|
+
index(child: Child | number): number
|
|
442
|
+
}
|