new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
Allan Lei https://github.com/allanlei
|
||||
|
||||
Check adapted from https://github.com/brandonaaron/jquery-cssHooks/blob/master/bgpos.js
|
||||
|
||||
Test: http://jsfiddle.net/allanlei/R8AYS/
|
||||
*/
|
||||
Modernizr.addTest('bgpositionxy', function() {
|
||||
return Modernizr.testStyles('#modernizr {background-position: 3px 5px;}', function(elem) {
|
||||
var cssStyleDeclaration = window.getComputedStyle ? getComputedStyle(elem, null) : elem.currentStyle;
|
||||
var xSupport = (cssStyleDeclaration.backgroundPositionX == '3px') || (cssStyleDeclaration['background-position-x'] == '3px');
|
||||
var ySupport = (cssStyleDeclaration.backgroundPositionY == '5px') || (cssStyleDeclaration['background-position-y'] == '5px');
|
||||
return xSupport && ySupport;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t","2":"C K L H M N O P Q R"},C:{"2":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC"},D:{"1":"S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC","2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R"},E:{"2":"I u J E F G A B C K L H GC zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC"},F:{"1":"hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d","2":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB OC PC QC RC qB 9B SC rB"},G:{"2":"F zB TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B"},H:{"2":"nC"},I:{"1":"D","2":"tB I oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"1":"e","2":"A B C qB 9B rB"},L:{"1":"D"},M:{"2":"D"},N:{"2":"A B"},O:{"2":"uC"},P:{"1":"2C 3C 4C sB 5C 6C 7C","2":"I vC wC xC yC zC 0B 0C 1C"},Q:{"2":"1B"},R:{"1":"8C"},S:{"2":"9C"}},B:7,C:"Trusted Types for DOM manipulation"};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"zip.js","sources":["../../../src/internal/operators/zip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAsCrD,MAAM,UAAU,GAAG;IAAO,qBAA4E;SAA5E,UAA4E,EAA5E,qBAA4E,EAA5E,IAA4E;QAA5E,gCAA4E;;IACpG,OAAO,SAAS,mBAAmB,CAAC,MAAqB;QACvD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,gBAAI,MAAM,SAAK,WAAW,GAAE,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0.00715,"48":0,"49":0,"50":0,"51":0.00238,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0.00477,"68":1.15386,"69":0.00477,"70":0.00238,"71":0,"72":0.00954,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0.00477,"86":0.00477,"87":0.00477,"88":0,"89":0,"90":0,"91":0.04053,"92":0,"93":0,"94":0.00238,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0.00238,"104":0,"105":0,"106":0.00238,"107":0.00715,"108":0.13827,"109":0.05483,"110":0,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0.00238,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0.00954,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0.00715,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0.00238,"65":0.00238,"66":0,"67":0,"68":0,"69":0.00238,"70":0,"71":0.00238,"72":0.00477,"73":0.00954,"74":0.00238,"75":0,"76":0,"77":0.00238,"78":0.08344,"79":0.04291,"80":0.00715,"81":0.00238,"83":0.00477,"84":0.00238,"85":0.00238,"86":0.00954,"87":0,"88":0.00715,"89":0.00238,"90":0,"91":0.00954,"92":0.00238,"93":0,"94":0.00477,"95":0,"96":0.01669,"97":0.00477,"98":0.00954,"99":0.00238,"100":0.03814,"101":0.00715,"102":0.00715,"103":0.03338,"104":0.01669,"105":0.01669,"106":0.02384,"107":0.08344,"108":1.44947,"109":1.4304,"110":0.00238,"111":0,"112":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0.00238,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0.00477,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0.00477,"77":0,"78":0,"79":0,"80":0.00238,"81":0,"82":0,"83":0,"84":0,"85":0.00238,"86":0.00238,"87":0,"88":0,"89":0.00715,"90":0.00477,"91":0,"92":0,"93":0.00954,"94":0.01907,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0.00238},B:{"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"79":0,"80":0.00477,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0.00477,"90":0.00715,"91":0,"92":0.00477,"93":0,"94":0,"95":0,"96":0.00238,"97":0,"98":0,"99":0.00715,"100":0.00238,"101":0,"102":0.00238,"103":0.00238,"104":0,"105":0.00238,"106":0.00477,"107":0,"108":0.02861,"109":0.02384},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0,"13.1":0,"14.1":0,"15.1":0,"15.2-15.3":0,"15.4":0,"15.5":0,"15.6":0.00477,"16.0":0.00238,"16.1":0.00477,"16.2":0.01669,"16.3":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0,"8.1-8.4":0,"9.0-9.2":0,"9.3":0,"10.0-10.2":0,"10.3":0,"11.0-11.2":0,"11.3-11.4":0,"12.0-12.1":0.01572,"12.2-12.5":0.1933,"13.0-13.1":0,"13.2":0,"13.3":0.00805,"13.4-13.7":0.00767,"14.0-14.4":0.01572,"14.5-14.8":0.01151,"15.0-15.1":0.01994,"15.2-15.3":1.25068,"15.4":0.03145,"15.5":0.07479,"15.6":0.28419,"16.0":0.44182,"16.1":0.71796,"16.2":0.3237,"16.3":0.10662},P:{"4":0.05925,"5.0-5.4":0,"6.2-6.4":0.00987,"7.2-7.4":0.22711,"8.2":0,"9.2":0.01975,"10.1":0,"11.1-11.2":0.0395,"12.0":0,"13.0":0.24686,"14.0":0.05925,"15.0":0.0395,"16.0":0.23698,"17.0":0.08887,"18.0":0.04937,"19.0":0.62208},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00925,"4.4":0,"4.4.3-4.4.4":0.01028},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},S:{"2.5":0},R:{_:"0"},M:{"0":0.09139},Q:{"13.1":0},O:{"0":0.21325},H:{"0":0.21631},L:{"0":87.44651}};
|
||||
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
const url = require('url');
|
||||
const prependHttp = require('prepend-http');
|
||||
|
||||
module.exports = (input, options) => {
|
||||
if (typeof input !== 'string') {
|
||||
throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof input}\` instead.`);
|
||||
}
|
||||
|
||||
const finalUrl = prependHttp(input, Object.assign({https: true}, options));
|
||||
return url.parse(finalUrl);
|
||||
};
|
||||
@@ -0,0 +1,533 @@
|
||||
# PostCSS [![Gitter][chat-img]][chat]
|
||||
|
||||
<img align="right" width="95" height="95"
|
||||
alt="Philosopher’s stone, logo of PostCSS"
|
||||
src="https://postcss.org/logo.svg">
|
||||
|
||||
[chat-img]: https://img.shields.io/badge/Gitter-Join_the_PostCSS_chat-brightgreen.svg
|
||||
[chat]: https://gitter.im/postcss/postcss
|
||||
|
||||
PostCSS is a tool for transforming styles with JS plugins.
|
||||
These plugins can lint your CSS, support variables and mixins,
|
||||
transpile future CSS syntax, inline images, and more.
|
||||
|
||||
PostCSS is used by industry leaders including Wikipedia, Twitter, Alibaba,
|
||||
and JetBrains. The [Autoprefixer] PostCSS plugin is one of the most popular
|
||||
CSS processors.
|
||||
|
||||
PostCSS takes a CSS file and provides an API to analyze and modify its rules
|
||||
(by transforming them into an [Abstract Syntax Tree]).
|
||||
This API can then be used by [plugins] to do a lot of useful things,
|
||||
e.g., to find errors automatically, or to insert vendor prefixes.
|
||||
|
||||
**Support / Discussion:** [Gitter](https://gitter.im/postcss/postcss)<br>
|
||||
**Twitter account:** [@postcss](https://twitter.com/postcss)<br>
|
||||
**VK.com page:** [postcss](https://vk.com/postcss)<br>
|
||||
**中文翻译**: [`docs/README-cn.md`](./docs/README-cn.md)
|
||||
|
||||
For PostCSS commercial support (consulting, improving the front-end culture
|
||||
of your company, PostCSS plugins), contact [Evil Martians]
|
||||
at <postcss@evilmartians.com>.
|
||||
|
||||
[Abstract Syntax Tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
|
||||
[Evil Martians]: https://evilmartians.com/?utm_source=postcss
|
||||
[Autoprefixer]: https://github.com/postcss/autoprefixer
|
||||
[plugins]: https://github.com/postcss/postcss#plugins
|
||||
|
||||
<a href="https://evilmartians.com/?utm_source=postcss">
|
||||
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
|
||||
alt="Sponsored by Evil Martians" width="236" height="54">
|
||||
</a>
|
||||
|
||||
|
||||
## Sponsorship
|
||||
|
||||
PostCSS needs your support. We are accepting donations
|
||||
[at Open Collective](https://opencollective.com/postcss/).
|
||||
|
||||
<a href="https://tailwindcss.com/">
|
||||
<img src="https://refactoringui.nyc3.cdn.digitaloceanspaces.com/tailwind-logo.svg"
|
||||
alt="Sponsored by Tailwind CSS" width="213" height="50">
|
||||
</a> <a href="https://themeisle.com/">
|
||||
<img src="https://mllj2j8xvfl0.i.optimole.com/d0cOXWA.3970~373ad/w:auto/h:auto/q:90/https://s30246.pcdn.co/wp-content/uploads/2019/03/logo.png"
|
||||
alt="Sponsored by ThemeIsle" width="171" height="56">
|
||||
</a>
|
||||
|
||||
|
||||
## Plugins
|
||||
|
||||
Currently, PostCSS has more than 200 plugins. You can find all of the plugins
|
||||
in the [plugins list] or in the [searchable catalog]. Below is a list
|
||||
of our favorite plugins — the best demonstrations of what can be built
|
||||
on top of PostCSS.
|
||||
|
||||
If you have any new ideas, [PostCSS plugin development] is really easy.
|
||||
|
||||
[searchable catalog]: https://www.postcss.parts/
|
||||
[plugins list]: https://github.com/postcss/postcss/blob/main/docs/plugins.md
|
||||
|
||||
|
||||
### Solve Global CSS Problem
|
||||
|
||||
* [`postcss-use`] allows you to explicitly set PostCSS plugins within CSS
|
||||
and execute them only for the current file.
|
||||
* [`postcss-modules`] and [`react-css-modules`] automatically isolate
|
||||
selectors within components.
|
||||
* [`postcss-autoreset`] is an alternative to using a global reset
|
||||
that is better for isolatable components.
|
||||
* [`postcss-initial`] adds `all: initial` support, which resets
|
||||
all inherited styles.
|
||||
* [`cq-prolyfill`] adds container query support, allowing styles that respond
|
||||
to the width of the parent.
|
||||
|
||||
|
||||
### Use Future CSS, Today
|
||||
|
||||
* [`autoprefixer`] adds vendor prefixes, using data from Can I Use.
|
||||
* [`postcss-preset-env`] allows you to use future CSS features today.
|
||||
|
||||
|
||||
### Better CSS Readability
|
||||
|
||||
* [`precss`] contains plugins for Sass-like features, like variables, nesting,
|
||||
and mixins.
|
||||
* [`postcss-sorting`] sorts the content of rules and at-rules.
|
||||
* [`postcss-utilities`] includes the most commonly used shortcuts and helpers.
|
||||
* [`short`] adds and extends numerous shorthand properties.
|
||||
|
||||
|
||||
### Images and Fonts
|
||||
|
||||
* [`postcss-assets`] inserts image dimensions and inlines files.
|
||||
* [`postcss-sprites`] generates image sprites.
|
||||
* [`font-magician`] generates all the `@font-face` rules needed in CSS.
|
||||
* [`postcss-inline-svg`] allows you to inline SVG and customize its styles.
|
||||
* [`postcss-write-svg`] allows you to write simple SVG directly in your CSS.
|
||||
* [`webp-in-css`] to use WebP image format in CSS background.
|
||||
* [`avif-in-css`] to use AVIF image format in CSS background.
|
||||
|
||||
### Linters
|
||||
|
||||
* [`stylelint`] is a modular stylesheet linter.
|
||||
* [`stylefmt`] is a tool that automatically formats CSS
|
||||
according `stylelint` rules.
|
||||
* [`doiuse`] lints CSS for browser support, using data from Can I Use.
|
||||
* [`colorguard`] helps you maintain a consistent color palette.
|
||||
|
||||
|
||||
### Other
|
||||
|
||||
* [`postcss-rtl`] combines both-directional (left-to-right and right-to-left) styles in one CSS file.
|
||||
* [`cssnano`] is a modular CSS minifier.
|
||||
* [`lost`] is a feature-rich `calc()` grid system.
|
||||
* [`rtlcss`] mirrors styles for right-to-left locales.
|
||||
|
||||
[PostCSS plugin development]: https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md
|
||||
[`postcss-inline-svg`]: https://github.com/TrySound/postcss-inline-svg
|
||||
[`postcss-preset-env`]: https://github.com/jonathantneal/postcss-preset-env
|
||||
[`react-css-modules`]: https://github.com/gajus/react-css-modules
|
||||
[`postcss-autoreset`]: https://github.com/maximkoretskiy/postcss-autoreset
|
||||
[`postcss-write-svg`]: https://github.com/jonathantneal/postcss-write-svg
|
||||
[`postcss-utilities`]: https://github.com/ismamz/postcss-utilities
|
||||
[`postcss-initial`]: https://github.com/maximkoretskiy/postcss-initial
|
||||
[`postcss-sprites`]: https://github.com/2createStudio/postcss-sprites
|
||||
[`postcss-modules`]: https://github.com/outpunk/postcss-modules
|
||||
[`postcss-sorting`]: https://github.com/hudochenkov/postcss-sorting
|
||||
[`postcss-assets`]: https://github.com/assetsjs/postcss-assets
|
||||
[`font-magician`]: https://github.com/jonathantneal/postcss-font-magician
|
||||
[`autoprefixer`]: https://github.com/postcss/autoprefixer
|
||||
[`cq-prolyfill`]: https://github.com/ausi/cq-prolyfill
|
||||
[`postcss-rtl`]: https://github.com/vkalinichev/postcss-rtl
|
||||
[`postcss-use`]: https://github.com/postcss/postcss-use
|
||||
[`css-modules`]: https://github.com/css-modules/css-modules
|
||||
[`webp-in-css`]: https://github.com/ai/webp-in-css
|
||||
[`avif-in-css`]: https://github.com/nucliweb/avif-in-css
|
||||
[`colorguard`]: https://github.com/SlexAxton/css-colorguard
|
||||
[`stylelint`]: https://github.com/stylelint/stylelint
|
||||
[`stylefmt`]: https://github.com/morishitter/stylefmt
|
||||
[`cssnano`]: https://cssnano.co/
|
||||
[`precss`]: https://github.com/jonathantneal/precss
|
||||
[`doiuse`]: https://github.com/anandthakker/doiuse
|
||||
[`rtlcss`]: https://github.com/MohammadYounes/rtlcss
|
||||
[`short`]: https://github.com/jonathantneal/postcss-short
|
||||
[`lost`]: https://github.com/peterramsing/lost
|
||||
|
||||
## Syntaxes
|
||||
|
||||
PostCSS can transform styles in any syntax, not just CSS.
|
||||
If there is not yet support for your favorite syntax,
|
||||
you can write a parser and/or stringifier to extend PostCSS.
|
||||
|
||||
* [`sugarss`] is a indent-based syntax like Sass or Stylus.
|
||||
* [`postcss-syntax`] switch syntax automatically by file extensions.
|
||||
* [`postcss-html`] parsing styles in `<style>` tags of HTML-like files.
|
||||
* [`postcss-markdown`] parsing styles in code blocks of Markdown files.
|
||||
* [`postcss-jsx`] parsing CSS in template / object literals of source files.
|
||||
* [`postcss-styled`] parsing CSS in template literals of source files.
|
||||
* [`postcss-scss`] allows you to work with SCSS
|
||||
*(but does not compile SCSS to CSS)*.
|
||||
* [`postcss-sass`] allows you to work with Sass
|
||||
*(but does not compile Sass to CSS)*.
|
||||
* [`postcss-less`] allows you to work with Less
|
||||
*(but does not compile LESS to CSS)*.
|
||||
* [`postcss-less-engine`] allows you to work with Less
|
||||
*(and DOES compile LESS to CSS using true Less.js evaluation)*.
|
||||
* [`postcss-js`] allows you to write styles in JS or transform
|
||||
React Inline Styles, Radium or JSS.
|
||||
* [`postcss-safe-parser`] finds and fixes CSS syntax errors.
|
||||
* [`midas`] converts a CSS string to highlighted HTML.
|
||||
|
||||
[`postcss-less-engine`]: https://github.com/Crunch/postcss-less
|
||||
[`postcss-safe-parser`]: https://github.com/postcss/postcss-safe-parser
|
||||
[`postcss-syntax`]: https://github.com/gucong3000/postcss-syntax
|
||||
[`postcss-html`]: https://github.com/gucong3000/postcss-html
|
||||
[`postcss-markdown`]: https://github.com/gucong3000/postcss-markdown
|
||||
[`postcss-jsx`]: https://github.com/gucong3000/postcss-jsx
|
||||
[`postcss-styled`]: https://github.com/gucong3000/postcss-styled
|
||||
[`postcss-scss`]: https://github.com/postcss/postcss-scss
|
||||
[`postcss-sass`]: https://github.com/AleshaOleg/postcss-sass
|
||||
[`postcss-less`]: https://github.com/webschik/postcss-less
|
||||
[`postcss-js`]: https://github.com/postcss/postcss-js
|
||||
[`sugarss`]: https://github.com/postcss/sugarss
|
||||
[`midas`]: https://github.com/ben-eb/midas
|
||||
|
||||
|
||||
## Articles
|
||||
|
||||
* [Some things you may think about PostCSS… and you might be wrong](http://julian.io/some-things-you-may-think-about-postcss-and-you-might-be-wrong)
|
||||
* [What PostCSS Really Is; What It Really Does](https://davidtheclark.com/its-time-for-everyone-to-learn-about-postcss/)
|
||||
* [PostCSS Guides](https://webdesign.tutsplus.com/series/postcss-deep-dive--cms-889)
|
||||
|
||||
More articles and videos you can find on [awesome-postcss](https://github.com/jjaderg/awesome-postcss) list.
|
||||
|
||||
|
||||
## Books
|
||||
|
||||
* [Mastering PostCSS for Web Design](https://www.packtpub.com/web-development/mastering-postcss-web-design) by Alex Libby, Packt. (June 2016)
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
You can start using PostCSS in just two steps:
|
||||
|
||||
1. Find and add PostCSS extensions for your build tool.
|
||||
2. [Select plugins] and add them to your PostCSS process.
|
||||
|
||||
[Select plugins]: https://www.postcss.parts/
|
||||
|
||||
|
||||
### CSS-in-JS
|
||||
|
||||
The best way to use PostCSS with CSS-in-JS is [`astroturf`].
|
||||
Add its loader to your `webpack.config.js`:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ['style-loader', 'postcss-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
use: ['babel-loader', 'astroturf/loader'],
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then create `postcss.config.js`:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('autoprefixer'),
|
||||
require('postcss-nested')
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[`astroturf`]: https://github.com/4Catalyzer/astroturf
|
||||
|
||||
|
||||
### Parcel
|
||||
|
||||
[Parcel] has built-in PostCSS support. It already uses Autoprefixer
|
||||
and cssnano. If you want to change plugins, create `postcss.config.js`
|
||||
in project’s root:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('autoprefixer'),
|
||||
require('postcss-nested')
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Parcel will even automatically install these plugins for you.
|
||||
|
||||
> Please, be aware of [the several issues in Version 1](https://github.com/parcel-bundler/parcel/labels/CSS%20Preprocessing). Notice, [Version 2](https://github.com/parcel-bundler/parcel/projects/5) may resolve the issues via [issue #2157](https://github.com/parcel-bundler/parcel/issues/2157).
|
||||
|
||||
[Parcel]: https://parceljs.org
|
||||
|
||||
|
||||
### Webpack
|
||||
|
||||
Use [`postcss-loader`] in `webpack.config.js`:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
loader: 'style-loader',
|
||||
},
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
importLoaders: 1,
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then create `postcss.config.js`:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('precss'),
|
||||
require('autoprefixer')
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[`postcss-loader`]: https://github.com/postcss/postcss-loader
|
||||
|
||||
|
||||
### Gulp
|
||||
|
||||
Use [`gulp-postcss`] and [`gulp-sourcemaps`].
|
||||
|
||||
```js
|
||||
gulp.task('css', () => {
|
||||
const postcss = require('gulp-postcss')
|
||||
const sourcemaps = require('gulp-sourcemaps')
|
||||
|
||||
return gulp.src('src/**/*.css')
|
||||
.pipe( sourcemaps.init() )
|
||||
.pipe( postcss([ require('precss'), require('autoprefixer') ]) )
|
||||
.pipe( sourcemaps.write('.') )
|
||||
.pipe( gulp.dest('build/') )
|
||||
})
|
||||
```
|
||||
|
||||
[`gulp-sourcemaps`]: https://github.com/floridoo/gulp-sourcemaps
|
||||
[`gulp-postcss`]: https://github.com/postcss/gulp-postcss
|
||||
|
||||
|
||||
### npm Scripts
|
||||
|
||||
To use PostCSS from your command-line interface or with npm scripts
|
||||
there is [`postcss-cli`].
|
||||
|
||||
```sh
|
||||
postcss --use autoprefixer -o main.css css/*.css
|
||||
```
|
||||
|
||||
[`postcss-cli`]: https://github.com/postcss/postcss-cli
|
||||
|
||||
|
||||
### Browser
|
||||
|
||||
If you want to compile CSS string in browser (for instance, in live edit
|
||||
tools like CodePen), just use [Browserify] or [webpack]. They will pack
|
||||
PostCSS and plugins files into a single file.
|
||||
|
||||
To apply PostCSS plugins to React Inline Styles, JSS, Radium
|
||||
and other [CSS-in-JS], you can use [`postcss-js`] and transforms style objects.
|
||||
|
||||
```js
|
||||
const postcss = require('postcss-js')
|
||||
const prefixer = postcss.sync([ require('autoprefixer') ])
|
||||
|
||||
prefixer({ display: 'flex' }) //=> { display: ['-webkit-box', '-webkit-flex', '-ms-flexbox', 'flex'] }
|
||||
```
|
||||
|
||||
[`postcss-js`]: https://github.com/postcss/postcss-js
|
||||
[Browserify]: http://browserify.org/
|
||||
[CSS-in-JS]: https://github.com/MicheleBertoli/css-in-js
|
||||
[webpack]: https://webpack.github.io/
|
||||
|
||||
|
||||
### Deno
|
||||
|
||||
PostCSS also supports [Deno]:
|
||||
|
||||
```js
|
||||
import postcss from 'https://deno.land/x/postcss/mod.js'
|
||||
import autoprefixer from 'https://jspm.dev/autoprefixer'
|
||||
|
||||
const result = await postcss([autoprefixer]).process(css)
|
||||
```
|
||||
|
||||
[Deno]: https://deno.land/
|
||||
|
||||
|
||||
### Runners
|
||||
|
||||
* **Grunt**: [`@lodder/grunt-postcss`](https://github.com/C-Lodder/grunt-postcss)
|
||||
* **HTML**: [`posthtml-postcss`](https://github.com/posthtml/posthtml-postcss)
|
||||
* **Stylus**: [`poststylus`](https://github.com/seaneking/poststylus)
|
||||
* **Rollup**: [`rollup-plugin-postcss`](https://github.com/egoist/rollup-plugin-postcss)
|
||||
* **Brunch**: [`postcss-brunch`](https://github.com/brunch/postcss-brunch)
|
||||
* **Broccoli**: [`broccoli-postcss`](https://github.com/jeffjewiss/broccoli-postcss)
|
||||
* **Meteor**: [`postcss`](https://atmospherejs.com/juliancwirko/postcss)
|
||||
* **ENB**: [`enb-postcss`](https://github.com/awinogradov/enb-postcss)
|
||||
* **Taskr**: [`taskr-postcss`](https://github.com/lukeed/taskr/tree/master/packages/postcss)
|
||||
* **Start**: [`start-postcss`](https://github.com/start-runner/postcss)
|
||||
* **Connect/Express**: [`postcss-middleware`](https://github.com/jedmao/postcss-middleware)
|
||||
|
||||
|
||||
### JS API
|
||||
|
||||
For other environments, you can use the JS API:
|
||||
|
||||
```js
|
||||
const autoprefixer = require('autoprefixer')
|
||||
const postcss = require('postcss')
|
||||
const precss = require('precss')
|
||||
const fs = require('fs')
|
||||
|
||||
fs.readFile('src/app.css', (err, css) => {
|
||||
postcss([precss, autoprefixer])
|
||||
.process(css, { from: 'src/app.css', to: 'dest/app.css' })
|
||||
.then(result => {
|
||||
fs.writeFile('dest/app.css', result.css, () => true)
|
||||
if ( result.map ) {
|
||||
fs.writeFile('dest/app.css.map', result.map.toString(), () => true)
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
Read the [PostCSS API documentation] for more details about the JS API.
|
||||
|
||||
All PostCSS runners should pass [PostCSS Runner Guidelines].
|
||||
|
||||
[PostCSS Runner Guidelines]: https://github.com/postcss/postcss/blob/main/docs/guidelines/runner.md
|
||||
[PostCSS API documentation]: https://postcss.org/api/
|
||||
|
||||
|
||||
### Options
|
||||
|
||||
Most PostCSS runners accept two parameters:
|
||||
|
||||
* An array of plugins.
|
||||
* An object of options.
|
||||
|
||||
Common options:
|
||||
|
||||
* `syntax`: an object providing a syntax parser and a stringifier.
|
||||
* `parser`: a special syntax parser (for example, [SCSS]).
|
||||
* `stringifier`: a special syntax output generator (for example, [Midas]).
|
||||
* `map`: [source map options].
|
||||
* `from`: the input file name (most runners set it automatically).
|
||||
* `to`: the output file name (most runners set it automatically).
|
||||
|
||||
[source map options]: https://postcss.org/api/#sourcemapoptions
|
||||
[Midas]: https://github.com/ben-eb/midas
|
||||
[SCSS]: https://github.com/postcss/postcss-scss
|
||||
|
||||
|
||||
### Treat Warnings as Errors
|
||||
|
||||
In some situations it might be helpful to fail the build on any warning
|
||||
from PostCSS or one of its plugins. This guarantees that no warnings
|
||||
go unnoticed, and helps to avoid bugs. While there is no option to enable
|
||||
treating warnings as errors, it can easily be done
|
||||
by adding `postcss-fail-on-warn` plugin in the end of PostCSS plugins:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('autoprefixer'),
|
||||
require('postcss-fail-on-warn')
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Editors & IDE Integration
|
||||
|
||||
|
||||
### VS Code
|
||||
|
||||
* [`csstools.postcss`] adds support for PostCSS, `postcss-preset-env`
|
||||
and CSS Modules.
|
||||
|
||||
[`csstools.postcss`]: https://marketplace.visualstudio.com/items?itemName=csstools.postcss
|
||||
|
||||
|
||||
### Atom
|
||||
|
||||
* [`language-postcss`] adds PostCSS and [SugarSS] highlight.
|
||||
* [`source-preview-postcss`] previews your output CSS in a separate, live pane.
|
||||
|
||||
[SugarSS]: https://github.com/postcss/sugarss
|
||||
|
||||
|
||||
### Sublime Text
|
||||
|
||||
* [`Syntax-highlighting-for-PostCSS`] adds PostCSS highlight.
|
||||
|
||||
[`Syntax-highlighting-for-PostCSS`]: https://github.com/hudochenkov/Syntax-highlighting-for-PostCSS
|
||||
[`source-preview-postcss`]: https://atom.io/packages/source-preview-postcss
|
||||
[`language-postcss`]: https://atom.io/packages/language-postcss
|
||||
|
||||
|
||||
### Vim
|
||||
|
||||
* [`postcss.vim`] adds PostCSS highlight.
|
||||
|
||||
[`postcss.vim`]: https://github.com/stephenway/postcss.vim
|
||||
|
||||
|
||||
### WebStorm
|
||||
|
||||
WebStorm 2016.3 [has] built-in PostCSS support.
|
||||
|
||||
[has]: https://blog.jetbrains.com/webstorm/2016/08/webstorm-2016-3-early-access-preview/
|
||||
|
||||
|
||||
## Security Contact
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact].
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
[Tidelift security contact]: https://tidelift.com/security
|
||||
|
||||
|
||||
## For Enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of `postcss` and thousands of other packages are working
|
||||
with Tidelift to deliver commercial support and maintenance for the open source
|
||||
dependencies you use to build your applications. Save time, reduce risk,
|
||||
and improve code health, while paying the maintainers of the exact dependencies
|
||||
you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-postcss?utm_source=npm-postcss&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
@@ -0,0 +1,387 @@
|
||||
import { Subject, AnonymousSubject } from '../../Subject';
|
||||
import { Subscriber } from '../../Subscriber';
|
||||
import { Observable } from '../../Observable';
|
||||
import { Subscription } from '../../Subscription';
|
||||
import { Operator } from '../../Operator';
|
||||
import { ReplaySubject } from '../../ReplaySubject';
|
||||
import { Observer, NextObserver } from '../../types';
|
||||
|
||||
/**
|
||||
* WebSocketSubjectConfig is a plain Object that allows us to make our
|
||||
* webSocket configurable.
|
||||
*
|
||||
* <span class="informal">Provides flexibility to {@link webSocket}</span>
|
||||
*
|
||||
* It defines a set of properties to provide custom behavior in specific
|
||||
* moments of the socket's lifecycle. When the connection opens we can
|
||||
* use `openObserver`, when the connection is closed `closeObserver`, if we
|
||||
* are interested in listening for data comming from server: `deserializer`,
|
||||
* which allows us to customize the deserialization strategy of data before passing it
|
||||
* to the socket client. By default `deserializer` is going to apply `JSON.parse` to each message comming
|
||||
* from the Server.
|
||||
*
|
||||
* ## Example
|
||||
* **deserializer**, the default for this property is `JSON.parse` but since there are just two options
|
||||
* for incomming data, either be text or binarydata. We can apply a custom deserialization strategy
|
||||
* or just simply skip the default behaviour.
|
||||
* ```ts
|
||||
* import { webSocket } from 'rxjs/webSocket';
|
||||
*
|
||||
* const wsSubject = webSocket({
|
||||
* url: 'ws://localhost:8081',
|
||||
* //Apply any transformation of your choice.
|
||||
* deserializer: ({data}) => data
|
||||
* });
|
||||
*
|
||||
* wsSubject.subscribe(console.log);
|
||||
*
|
||||
* // Let's suppose we have this on the Server: ws.send("This is a msg from the server")
|
||||
* //output
|
||||
* //
|
||||
* // This is a msg from the server
|
||||
* ```
|
||||
*
|
||||
* **serializer** allows us tom apply custom serialization strategy but for the outgoing messages
|
||||
* ```ts
|
||||
* import { webSocket } from 'rxjs/webSocket';
|
||||
*
|
||||
* const wsSubject = webSocket({
|
||||
* url: 'ws://localhost:8081',
|
||||
* //Apply any transformation of your choice.
|
||||
* serializer: msg => JSON.stringify({channel: "webDevelopment", msg: msg})
|
||||
* });
|
||||
*
|
||||
* wsSubject.subscribe(() => subject.next("msg to the server"));
|
||||
*
|
||||
* // Let's suppose we have this on the Server: ws.send("This is a msg from the server")
|
||||
* //output
|
||||
* //
|
||||
* // {"channel":"webDevelopment","msg":"msg to the server"}
|
||||
* ```
|
||||
*
|
||||
* **closeObserver** allows us to set a custom error when an error raise up.
|
||||
* ```ts
|
||||
* import { webSocket } from 'rxjs/webSocket';
|
||||
*
|
||||
* const wsSubject = webSocket({
|
||||
* url: 'ws://localhost:8081',
|
||||
* closeObserver: {
|
||||
next(closeEvent) {
|
||||
const customError = { code: 6666, reason: "Custom evil reason" }
|
||||
console.log(`code: ${customError.code}, reason: ${customError.reason}`);
|
||||
}
|
||||
}
|
||||
* });
|
||||
*
|
||||
* //output
|
||||
* // code: 6666, reason: Custom evil reason
|
||||
* ```
|
||||
*
|
||||
* **openObserver**, Let's say we need to make some kind of init task before sending/receiving msgs to the
|
||||
* webSocket or sending notification that the connection was successful, this is when
|
||||
* openObserver is usefull for.
|
||||
* ```ts
|
||||
* import { webSocket } from 'rxjs/webSocket';
|
||||
*
|
||||
* const wsSubject = webSocket({
|
||||
* url: 'ws://localhost:8081',
|
||||
* openObserver: {
|
||||
* next: () => {
|
||||
* console.log('connetion ok');
|
||||
* }
|
||||
* },
|
||||
* });
|
||||
*
|
||||
* //output
|
||||
* // connetion ok`
|
||||
* ```
|
||||
* */
|
||||
|
||||
export interface WebSocketSubjectConfig<T> {
|
||||
/** The url of the socket server to connect to */
|
||||
url: string;
|
||||
/** The protocol to use to connect */
|
||||
protocol?: string | Array<string>;
|
||||
/** @deprecated use {@link deserializer} */
|
||||
resultSelector?: (e: MessageEvent) => T;
|
||||
/**
|
||||
* A serializer used to create messages from passed values before the
|
||||
* messages are sent to the server. Defaults to JSON.stringify.
|
||||
*/
|
||||
serializer?: (value: T) => WebSocketMessage;
|
||||
/**
|
||||
* A deserializer used for messages arriving on the socket from the
|
||||
* server. Defaults to JSON.parse.
|
||||
*/
|
||||
deserializer?: (e: MessageEvent) => T;
|
||||
/**
|
||||
* An Observer that watches when open events occur on the underlying web socket.
|
||||
*/
|
||||
openObserver?: NextObserver<Event>;
|
||||
/**
|
||||
* An Observer than watches when close events occur on the underlying webSocket
|
||||
*/
|
||||
closeObserver?: NextObserver<CloseEvent>;
|
||||
/**
|
||||
* An Observer that watches when a close is about to occur due to
|
||||
* unsubscription.
|
||||
*/
|
||||
closingObserver?: NextObserver<void>;
|
||||
/**
|
||||
* A WebSocket constructor to use. This is useful for situations like using a
|
||||
* WebSocket impl in Node (WebSocket is a DOM API), or for mocking a WebSocket
|
||||
* for testing purposes
|
||||
*/
|
||||
WebSocketCtor?: { new(url: string, protocols?: string|string[]): WebSocket };
|
||||
/** Sets the `binaryType` property of the underlying WebSocket. */
|
||||
binaryType?: 'blob' | 'arraybuffer';
|
||||
}
|
||||
|
||||
const DEFAULT_WEBSOCKET_CONFIG: WebSocketSubjectConfig<any> = {
|
||||
url: '',
|
||||
deserializer: (e: MessageEvent) => JSON.parse(e.data),
|
||||
serializer: (value: any) => JSON.stringify(value),
|
||||
};
|
||||
|
||||
const WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT =
|
||||
'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
|
||||
|
||||
export type WebSocketMessage = string | ArrayBuffer | Blob | ArrayBufferView;
|
||||
|
||||
export class WebSocketSubject<T> extends AnonymousSubject<T> {
|
||||
|
||||
private _config: WebSocketSubjectConfig<T>;
|
||||
|
||||
/** @deprecated This is an internal implementation detail, do not use. */
|
||||
_output: Subject<T>;
|
||||
|
||||
private _socket: WebSocket;
|
||||
|
||||
constructor(urlConfigOrSource: string | WebSocketSubjectConfig<T> | Observable<T>, destination?: Observer<T>) {
|
||||
super();
|
||||
if (urlConfigOrSource instanceof Observable) {
|
||||
this.destination = destination;
|
||||
this.source = urlConfigOrSource as Observable<T>;
|
||||
} else {
|
||||
const config = this._config = { ...DEFAULT_WEBSOCKET_CONFIG };
|
||||
this._output = new Subject<T>();
|
||||
if (typeof urlConfigOrSource === 'string') {
|
||||
config.url = urlConfigOrSource;
|
||||
} else {
|
||||
for (let key in urlConfigOrSource) {
|
||||
if (urlConfigOrSource.hasOwnProperty(key)) {
|
||||
config[key] = urlConfigOrSource[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.WebSocketCtor && WebSocket) {
|
||||
config.WebSocketCtor = WebSocket;
|
||||
} else if (!config.WebSocketCtor) {
|
||||
throw new Error('no WebSocket constructor can be found');
|
||||
}
|
||||
this.destination = new ReplaySubject();
|
||||
}
|
||||
}
|
||||
|
||||
lift<R>(operator: Operator<T, R>): WebSocketSubject<R> {
|
||||
const sock = new WebSocketSubject<R>(this._config as WebSocketSubjectConfig<any>, <any> this.destination);
|
||||
sock.operator = operator;
|
||||
sock.source = this;
|
||||
return sock;
|
||||
}
|
||||
|
||||
private _resetState() {
|
||||
this._socket = null;
|
||||
if (!this.source) {
|
||||
this.destination = new ReplaySubject();
|
||||
}
|
||||
this._output = new Subject<T>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link Observable}, that when subscribed to, sends a message,
|
||||
* defined by the `subMsg` function, to the server over the socket to begin a
|
||||
* subscription to data over that socket. Once data arrives, the
|
||||
* `messageFilter` argument will be used to select the appropriate data for
|
||||
* the resulting Observable. When teardown occurs, either due to
|
||||
* unsubscription, completion or error, a message defined by the `unsubMsg`
|
||||
* argument will be send to the server over the WebSocketSubject.
|
||||
*
|
||||
* @param subMsg A function to generate the subscription message to be sent to
|
||||
* the server. This will still be processed by the serializer in the
|
||||
* WebSocketSubject's config. (Which defaults to JSON serialization)
|
||||
* @param unsubMsg A function to generate the unsubscription message to be
|
||||
* sent to the server at teardown. This will still be processed by the
|
||||
* serializer in the WebSocketSubject's config.
|
||||
* @param messageFilter A predicate for selecting the appropriate messages
|
||||
* from the server for the output stream.
|
||||
*/
|
||||
multiplex(subMsg: () => any, unsubMsg: () => any, messageFilter: (value: T) => boolean) {
|
||||
const self = this;
|
||||
return new Observable((observer: Observer<any>) => {
|
||||
try {
|
||||
self.next(subMsg());
|
||||
} catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
|
||||
const subscription = self.subscribe(x => {
|
||||
try {
|
||||
if (messageFilter(x)) {
|
||||
observer.next(x);
|
||||
}
|
||||
} catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
},
|
||||
err => observer.error(err),
|
||||
() => observer.complete());
|
||||
|
||||
return () => {
|
||||
try {
|
||||
self.next(unsubMsg());
|
||||
} catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
subscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private _connectSocket() {
|
||||
const { WebSocketCtor, protocol, url, binaryType } = this._config;
|
||||
const observer = this._output;
|
||||
|
||||
let socket: WebSocket = null;
|
||||
try {
|
||||
socket = protocol ?
|
||||
new WebSocketCtor(url, protocol) :
|
||||
new WebSocketCtor(url);
|
||||
this._socket = socket;
|
||||
if (binaryType) {
|
||||
this._socket.binaryType = binaryType;
|
||||
}
|
||||
} catch (e) {
|
||||
observer.error(e);
|
||||
return;
|
||||
}
|
||||
|
||||
const subscription = new Subscription(() => {
|
||||
this._socket = null;
|
||||
if (socket && socket.readyState === 1) {
|
||||
socket.close();
|
||||
}
|
||||
});
|
||||
|
||||
socket.onopen = (e: Event) => {
|
||||
const { _socket } = this;
|
||||
if (!_socket) {
|
||||
socket.close();
|
||||
this._resetState();
|
||||
return;
|
||||
}
|
||||
const { openObserver } = this._config;
|
||||
if (openObserver) {
|
||||
openObserver.next(e);
|
||||
}
|
||||
|
||||
const queue = this.destination;
|
||||
|
||||
this.destination = Subscriber.create<T>(
|
||||
(x) => {
|
||||
if (socket.readyState === 1) {
|
||||
try {
|
||||
const { serializer } = this._config;
|
||||
socket.send(serializer(x));
|
||||
} catch (e) {
|
||||
this.destination.error(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
(e) => {
|
||||
const { closingObserver } = this._config;
|
||||
if (closingObserver) {
|
||||
closingObserver.next(undefined);
|
||||
}
|
||||
if (e && e.code) {
|
||||
socket.close(e.code, e.reason);
|
||||
} else {
|
||||
observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
|
||||
}
|
||||
this._resetState();
|
||||
},
|
||||
() => {
|
||||
const { closingObserver } = this._config;
|
||||
if (closingObserver) {
|
||||
closingObserver.next(undefined);
|
||||
}
|
||||
socket.close();
|
||||
this._resetState();
|
||||
}
|
||||
) as Subscriber<any>;
|
||||
|
||||
if (queue && queue instanceof ReplaySubject) {
|
||||
subscription.add((<ReplaySubject<T>>queue).subscribe(this.destination));
|
||||
}
|
||||
};
|
||||
|
||||
socket.onerror = (e: Event) => {
|
||||
this._resetState();
|
||||
observer.error(e);
|
||||
};
|
||||
|
||||
socket.onclose = (e: CloseEvent) => {
|
||||
this._resetState();
|
||||
const { closeObserver } = this._config;
|
||||
if (closeObserver) {
|
||||
closeObserver.next(e);
|
||||
}
|
||||
if (e.wasClean) {
|
||||
observer.complete();
|
||||
} else {
|
||||
observer.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
socket.onmessage = (e: MessageEvent) => {
|
||||
try {
|
||||
const { deserializer } = this._config;
|
||||
observer.next(deserializer(e));
|
||||
} catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** @deprecated This is an internal implementation detail, do not use. */
|
||||
_subscribe(subscriber: Subscriber<T>): Subscription {
|
||||
const { source } = this;
|
||||
if (source) {
|
||||
return source.subscribe(subscriber);
|
||||
}
|
||||
if (!this._socket) {
|
||||
this._connectSocket();
|
||||
}
|
||||
this._output.subscribe(subscriber);
|
||||
subscriber.add(() => {
|
||||
const { _socket } = this;
|
||||
if (this._output.observers.length === 0) {
|
||||
if (_socket && _socket.readyState === 1) {
|
||||
_socket.close();
|
||||
}
|
||||
this._resetState();
|
||||
}
|
||||
});
|
||||
return subscriber;
|
||||
}
|
||||
|
||||
unsubscribe() {
|
||||
const { _socket } = this;
|
||||
if (_socket && _socket.readyState === 1) {
|
||||
_socket.close();
|
||||
}
|
||||
this._resetState();
|
||||
super.unsubscribe();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"8":"J E F G A B BC"},B:{"1":"L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t","2":"C K"},C:{"1":"NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB","8":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB DC EC"},D:{"1":"UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC","8":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB"},E:{"1":"B C K L H 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","8":"I u J E F G A GC zB HC IC JC KC"},F:{"1":"HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d","8":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB OC PC QC RC qB 9B SC rB"},G:{"1":"bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","8":"F zB TC AC UC VC WC XC YC ZC aC"},H:{"8":"nC"},I:{"1":"D","8":"tB I oC pC qC rC AC sC tC"},J:{"8":"E A"},K:{"1":"e","8":"A B C qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"8":"A B"},O:{"1":"uC"},P:{"1":"wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C","8":"I vC"},Q:{"1":"1B"},R:{"1":"8C"},S:{"1":"9C"}},B:6,C:"Object.values method"};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"F G A B","8":"J E BC"},B:{"1":"C K L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},C:{"1":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB EC","8":"CC tB DC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC","8":"I"},E:{"1":"u J E F G A B C K L H HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","8":"I GC zB"},F:{"1":"0 1 2 3 4 5 6 7 8 9 B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d RC qB 9B SC rB","8":"G OC PC QC"},G:{"1":"F TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","2":"zB"},H:{"2":"nC"},I:{"1":"tB I D pC qC rC AC sC tC","2":"oC"},J:{"1":"E A"},K:{"1":"B C e qB 9B rB","8":"A"},L:{"1":"D"},M:{"1":"D"},N:{"1":"A B"},O:{"1":"uC"},P:{"1":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"1":"1B"},R:{"1":"8C"},S:{"1":"9C"}},B:1,C:"Hashchange event"};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"from.js","sources":["../../src/add/observable/from.ts"],"names":[],"mappings":";;AAAA,2CAAyC"}
|
||||
@@ -0,0 +1,56 @@
|
||||
let flexSpec = require('./flex-spec')
|
||||
let Declaration = require('../declaration')
|
||||
|
||||
class AlignSelf extends Declaration {
|
||||
check (decl) {
|
||||
return (
|
||||
decl.parent &&
|
||||
!decl.parent.some(i => {
|
||||
return i.prop && i.prop.startsWith('grid-')
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Change property name for 2012 specs
|
||||
*/
|
||||
prefixed (prop, prefix) {
|
||||
let spec
|
||||
;[spec, prefix] = flexSpec(prefix)
|
||||
if (spec === 2012) {
|
||||
return prefix + 'flex-item-align'
|
||||
}
|
||||
return super.prefixed(prop, prefix)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return property name by final spec
|
||||
*/
|
||||
normalize () {
|
||||
return 'align-self'
|
||||
}
|
||||
|
||||
/**
|
||||
* Change value for 2012 spec and ignore prefix for 2009
|
||||
*/
|
||||
set (decl, prefix) {
|
||||
let spec = flexSpec(prefix)[0]
|
||||
if (spec === 2012) {
|
||||
decl.value = AlignSelf.oldValues[decl.value] || decl.value
|
||||
return super.set(decl, prefix)
|
||||
}
|
||||
if (spec === 'final') {
|
||||
return super.set(decl, prefix)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
AlignSelf.names = ['align-self', 'flex-item-align']
|
||||
|
||||
AlignSelf.oldValues = {
|
||||
'flex-end': 'end',
|
||||
'flex-start': 'start'
|
||||
}
|
||||
|
||||
module.exports = AlignSelf
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bufferTime.js","sources":["../../src/add/operator/bufferTime.ts"],"names":[],"mappings":";;AAAA,+CAA6C"}
|
||||
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "2.21.3";
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TimeoutError.js","sources":["../src/util/TimeoutError.ts"],"names":[],"mappings":";;;;;AAAA,mDAA8C"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"G A B","132":"J E F BC"},B:{"1":"C K L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},C:{"1":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC","2":"CC tB"},D:{"1":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC"},E:{"1":"I u J E F G A B C K L H zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"GC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d PC QC RC qB 9B SC rB","2":"G OC"},G:{"1":"F AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","260":"zB TC"},H:{"2":"nC"},I:{"1":"I D rC AC sC tC","2":"oC","4":"tB pC qC"},J:{"1":"A","4":"E"},K:{"1":"A B C e qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"1":"A B"},O:{"1":"uC"},P:{"1":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"1":"1B"},R:{"1":"8C"},S:{"1":"9C"}},B:2,C:"@font-face Web fonts"};
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"parse-url","version":"6.0.5","files":{"LICENSE":{"checkedAt":1678887829715,"integrity":"sha512-MxcHemlXy0/XT7Z7XOdGO5HMlpsILyyDFzQns5buxsaJTyxhoMT1w5c8cQfoxY4rFYtEeNXIh36yjE2LP7ieEg==","mode":420,"size":1134},"lib/index.js":{"checkedAt":1678887829724,"integrity":"sha512-YGmHFmndhYRFByGcTEFs6bGpVacXwjM5kWOElNBcGreTEPWzuCmO+Sttageds6qOsABUPHJ3c7Kw+1YXGe7zEg==","mode":420,"size":2166},"package.json":{"checkedAt":1678887829724,"integrity":"sha512-ijgFjeHXjryc+5p22uRp/wODVUVb0XRE3ZQFVuiuZs/yBAg84488zI6JvgLzkqWsth8WbkK5FwYPJ5nIMd/xoA==","mode":420,"size":1304},"README.md":{"checkedAt":1678887829724,"integrity":"sha512-o/ZjFIZymn6Vdy+saul24CSvuQxgrCaT+LXlovivA33XPIpz9vY8NPE36IbAiFxO0WwENX2ZlsoNtMKnGJ5oaw==","mode":420,"size":8389},"lib/index.d.ts":{"checkedAt":1678887829735,"integrity":"sha512-Wb6zhSBePMi1h2XV0NxO8ksvu59OsMcfCO1HA+f7wuGX3994B9NAl22YifVUPVyh4gTUO7g6RdDH6bqt6at/lw==","mode":420,"size":370}}}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.00799,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0.02398,"74":0,"75":0,"76":0,"77":0,"78":0.00799,"79":0.004,"80":0.004,"81":0.004,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0.004,"100":0,"101":0,"102":0.00799,"103":0,"104":0.10792,"105":0,"106":0.004,"107":0.01199,"108":0.2638,"109":0.1399,"110":0,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0.004,"48":0.00799,"49":0.01999,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0.004,"64":0.004,"65":0.00799,"66":0,"67":0,"68":0.004,"69":0.004,"70":0.004,"71":0,"72":0.004,"73":0,"74":0.004,"75":0.01599,"76":0.01599,"77":0.004,"78":0.00799,"79":0.02398,"80":0.004,"81":0.01999,"83":0.01599,"84":0.02798,"85":0.04397,"86":0.01999,"87":0.03997,"88":0.00799,"89":0.01199,"90":0.00799,"91":0.01599,"92":0.00799,"93":0.02398,"94":0.04796,"95":0.004,"96":0.01199,"97":0.01199,"98":0.00799,"99":0.01199,"100":0.01599,"101":0.00799,"102":0.01599,"103":0.11591,"104":0.03597,"105":0.06395,"106":0.06395,"107":0.15988,"108":5.05221,"109":4.5286,"110":0.004,"111":0.004,"112":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0.004,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0.004,"70":0,"71":0,"72":0,"73":0.004,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0.00799,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0.004,"91":0,"92":0.004,"93":0.33175,"94":0.36772,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0,"15":0.004,"16":0,"17":0,"18":0.02398,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0.004,"86":0.004,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.01199,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0.004,"100":0,"101":0,"102":0,"103":0.004,"104":0.004,"105":0.00799,"106":0.004,"107":0.02398,"108":0.70347,"109":0.63952},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.004,"14":0.04397,"15":0.00799,_:"0","3.1":0,"3.2":0,"5.1":0.01999,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0.004,"13.1":0.07195,"14.1":0.05596,"15.1":0.00799,"15.2-15.3":0.00799,"15.4":0.02398,"15.5":0.07195,"15.6":0.30377,"16.0":0.04397,"16.1":0.11591,"16.2":0.46765,"16.3":0.01599},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.00314,"6.0-6.1":0,"7.0-7.1":0.05334,"8.1-8.4":0,"9.0-9.2":0,"9.3":0.05962,"10.0-10.2":0,"10.3":0.03765,"11.0-11.2":0.00314,"11.3-11.4":0.01255,"12.0-12.1":0.01569,"12.2-12.5":0.65265,"13.0-13.1":0.02196,"13.2":0.00628,"13.3":0.05962,"13.4-13.7":0.20395,"14.0-14.4":0.62755,"14.5-14.8":1.41198,"15.0-15.1":0.30436,"15.2-15.3":0.37025,"15.4":0.52714,"15.5":1.06055,"15.6":3.9504,"16.0":4.07591,"16.1":8.34321,"16.2":5.5475,"16.3":0.54283},P:{"4":0.12432,"5.0-5.4":0.01036,"6.2-6.4":0.01036,"7.2-7.4":0.09324,"8.2":0,"9.2":0.01036,"10.1":0,"11.1-11.2":0.06216,"12.0":0.01036,"13.0":0.02072,"14.0":0.03108,"15.0":0.02072,"16.0":0.08288,"17.0":0.0518,"18.0":0.1036,"19.0":1.28464},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.01599,"4.2-4.3":0.06396,"4.4":0,"4.4.3-4.4.4":0.43173},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0.00492,"7":0.00492,"8":0.01476,"9":0.00492,"10":0.00492,"11":0.02952,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},R:{_:"0"},M:{"0":0.32416},Q:{"13.1":0},O:{"0":0.06003},H:{"0":0.2046},L:{"0":52.92747},S:{"2.5":0}};
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/operator/pluck';
|
||||
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (string, separator) => {
|
||||
if (!(typeof string === 'string' && typeof separator === 'string')) {
|
||||
throw new TypeError('Expected the arguments to be of type `string`');
|
||||
}
|
||||
|
||||
if (separator === '') {
|
||||
return [string];
|
||||
}
|
||||
|
||||
const separatorIndex = string.indexOf(separator);
|
||||
|
||||
if (separatorIndex === -1) {
|
||||
return [string];
|
||||
}
|
||||
|
||||
return [
|
||||
string.slice(0, separatorIndex),
|
||||
string.slice(separatorIndex + separator.length)
|
||||
];
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import assertString from './util/assertString';
|
||||
var hslcomma = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s*)(\s*,\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(,\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i;
|
||||
var hslspace = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s)(\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(\/\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i;
|
||||
export default function isHSL(str) {
|
||||
assertString(str);
|
||||
return hslcomma.test(str) || hslspace.test(str);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
const test = require('ava');
|
||||
const sinon = require('sinon');
|
||||
const Version = require('../lib/plugin/version/Version');
|
||||
const { factory, runTasks } = require('./util');
|
||||
|
||||
test('isValidVersion', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.isValid('1.0.0'), true);
|
||||
t.is(v.isValid(1.0), false);
|
||||
});
|
||||
|
||||
test('isPreRelease', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.isPreRelease('1.0.0-beta.0'), true);
|
||||
t.is(v.isPreRelease('1.0.0'), false);
|
||||
});
|
||||
|
||||
test('should return the same version in both interactive and ci mode', async t => {
|
||||
const v = factory(Version);
|
||||
const options = { latestVersion: '2.0.0-beta.1', increment: null, preReleaseId: 'rc', isPreRelease: true };
|
||||
const resultInteractiveMode = await v.getIncrementedVersion(options);
|
||||
t.is(resultInteractiveMode, '2.0.0-rc.0');
|
||||
const resultCiMode = v.getIncrementedVersionCI(options);
|
||||
t.is(resultInteractiveMode, resultCiMode);
|
||||
});
|
||||
|
||||
test('should increment latest version', t => {
|
||||
const v = factory(Version);
|
||||
const latestVersion = '1.0.0';
|
||||
t.is(v.incrementVersion({ latestVersion, increment: false }), '1.0.0');
|
||||
t.is(v.incrementVersion({ latestVersion, increment: 'foo' }), undefined);
|
||||
t.is(v.incrementVersion({ latestVersion, increment: 'patsj' }), undefined);
|
||||
t.is(v.incrementVersion({ latestVersion, increment: 'a.b.c' }), undefined);
|
||||
t.is(v.incrementVersion({ latestVersion, increment: '0.9.0' }), undefined);
|
||||
t.is(v.incrementVersion({ latestVersion, increment: '1.1.0' }), '1.1.0');
|
||||
t.is(v.incrementVersion({ latestVersion, increment: 'major' }), '2.0.0');
|
||||
t.is(v.incrementVersion({ latestVersion, increment: '2.0.0-beta.1' }), '2.0.0-beta.1');
|
||||
});
|
||||
|
||||
test('should not increment latest version in interactive mode', t => {
|
||||
const v = factory(Version, { options: { ci: false } });
|
||||
const latestVersion = '1.0.0';
|
||||
t.is(v.incrementVersion({ latestVersion, increment: null }), undefined);
|
||||
t.is(v.incrementVersion({ latestVersion, increment: false }), '1.0.0');
|
||||
});
|
||||
|
||||
test('should always set increment version in CI mode', t => {
|
||||
const v = factory(Version, { options: { ci: true } });
|
||||
const latestVersion = '1.0.0';
|
||||
t.is(v.getIncrementedVersionCI({ latestVersion, increment: false }), '1.0.0');
|
||||
t.is(v.getIncrementedVersionCI({ latestVersion, increment: null }), '1.0.1');
|
||||
t.is(v.getIncrementedVersionCI({ latestVersion, increment: '1.1.0' }), '1.1.0');
|
||||
t.is(v.getIncrementedVersionCI({ latestVersion, increment: 'major' }), '2.0.0');
|
||||
});
|
||||
|
||||
test('should increment latest version (coerce)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.incrementVersion({ increment: '1.2' }), '1.2.0');
|
||||
t.is(v.incrementVersion({ increment: '1' }), '1.0.0');
|
||||
t.is(v.incrementVersion({ increment: 'v1.2.0.0' }), '1.2.0');
|
||||
});
|
||||
|
||||
test('should increment version (pre-release continuation)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.0', increment: 'prepatch' }), '1.2.4-0');
|
||||
});
|
||||
|
||||
test('should increment version (prepatch)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.incrementVersion({ latestVersion: '1.2.3', increment: 'prepatch', preReleaseId: 'alpha' }), '1.2.4-alpha.0');
|
||||
});
|
||||
|
||||
test('should increment version (normalized)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(
|
||||
v.incrementVersion({ latestVersion: '1.2.3', increment: 'patch', preReleaseId: 'alpha', isPreRelease: true }),
|
||||
'1.2.4-alpha.0'
|
||||
);
|
||||
});
|
||||
|
||||
test('should increment version (prepatch on prerelease version)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(
|
||||
v.incrementVersion({ latestVersion: '1.2.3-alpha.5', increment: 'prepatch', preReleaseId: 'next' }),
|
||||
'1.2.4-next.0'
|
||||
);
|
||||
});
|
||||
|
||||
test('should increment version (normalized on prerelease version)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(
|
||||
v.incrementVersion({
|
||||
latestVersion: '1.2.3-alpha.5',
|
||||
increment: 'patch',
|
||||
preReleaseId: 'next',
|
||||
isPreRelease: true
|
||||
}),
|
||||
'1.2.4-next.0'
|
||||
);
|
||||
});
|
||||
|
||||
test('should increment version (prerelease)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.incrementVersion({ latestVersion: '1.2.3', increment: 'prerelease', preReleaseId: 'alpha' }), '1.2.4-alpha.0');
|
||||
});
|
||||
|
||||
test('should increment version (prerelease cont.)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.0', increment: 'prerelease' }), '1.2.3-alpha.1');
|
||||
});
|
||||
|
||||
test('should increment version (preReleaseId continuation)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(
|
||||
v.incrementVersion({ latestVersion: '1.2.3-alpha.0', increment: 'prerelease', preReleaseId: 'alpha' }),
|
||||
'1.2.3-alpha.1'
|
||||
);
|
||||
});
|
||||
|
||||
test('should increment version (prepatch/preReleaseId continuation)', t => {
|
||||
const v = factory(Version);
|
||||
const options = { latestVersion: '1.2.3-beta.0', increment: 'prerelease', preReleaseId: 'beta', isPreRelease: true };
|
||||
t.is(v.incrementVersion(options), '1.2.3-beta.1');
|
||||
});
|
||||
|
||||
test('should increment version (preReleaseId w/o preRelease)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.0', increment: 'patch', preReleaseId: 'alpha' }), '1.2.3');
|
||||
});
|
||||
|
||||
test('should increment version (non-numeric prepatch continuation)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha', increment: 'prerelease' }), '1.2.3-alpha.0');
|
||||
});
|
||||
|
||||
test('should increment version (patch release after pre-release)', t => {
|
||||
const v = factory(Version);
|
||||
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.1', increment: 'patch' }), '1.2.3');
|
||||
});
|
||||
|
||||
test('should run tasks without errors', async t => {
|
||||
const options = { version: { increment: 'minor' } };
|
||||
const v = factory(Version, { options });
|
||||
const getIncrement = sinon.spy(v, 'getIncrement');
|
||||
const getIncrementedVersionCI = sinon.spy(v, 'getIncrementedVersionCI');
|
||||
const incrementVersion = sinon.spy(v, 'incrementVersion');
|
||||
|
||||
await runTasks(v);
|
||||
|
||||
t.is(getIncrement.callCount, 1);
|
||||
t.deepEqual(getIncrement.firstCall.args[0], {
|
||||
latestVersion: '0.0.0',
|
||||
increment: 'minor',
|
||||
isPreRelease: false,
|
||||
preReleaseId: null
|
||||
});
|
||||
t.is(getIncrementedVersionCI.callCount, 1);
|
||||
t.deepEqual(getIncrementedVersionCI.firstCall.args[0], { latestVersion: '0.0.0', increment: 'minor' });
|
||||
t.is(await incrementVersion.firstCall.returnValue, '0.1.0');
|
||||
t.is(incrementVersion.callCount, 1);
|
||||
t.deepEqual(incrementVersion.firstCall.args[0], { latestVersion: '0.0.0', increment: 'minor' });
|
||||
t.is(incrementVersion.firstCall.returnValue, '0.1.0');
|
||||
const { latestVersion, version, isPreRelease, preReleaseId } = v.config.getContext();
|
||||
t.is(latestVersion, '0.0.0');
|
||||
t.is(version, '0.1.0');
|
||||
t.is(isPreRelease, false);
|
||||
t.is(preReleaseId, null);
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Subscription } from './Subscription';
|
||||
export class SubjectSubscription extends Subscription {
|
||||
constructor(subject, subscriber) {
|
||||
super();
|
||||
this.subject = subject;
|
||||
this.subscriber = subscriber;
|
||||
this.closed = false;
|
||||
}
|
||||
unsubscribe() {
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
this.closed = true;
|
||||
const subject = this.subject;
|
||||
const observers = subject.observers;
|
||||
this.subject = null;
|
||||
if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
|
||||
return;
|
||||
}
|
||||
const subscriberIndex = observers.indexOf(this.subscriber);
|
||||
if (subscriberIndex !== -1) {
|
||||
observers.splice(subscriberIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SubjectSubscription.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"lodash.uniqby","version":"4.7.0","files":{"package.json":{"checkedAt":1678887829116,"integrity":"sha512-b82sQ/6IGc3lG/L4fs7fTbEyldQwOZ6Y+rzUXiezM5l13AHQXY6GSZ83E8B6ZJse/KYPrVp2+RenV79U/1cdAw==","mode":420,"size":743},"LICENSE":{"checkedAt":1678887829116,"integrity":"sha512-t/YCqTo2Om0BuHE/C+C/HnDEMbbFc+Iw7HdZ5m3+Ixv6eAFUYHuaWfDgMyL3zt9X0qvXoIPA8u8qq8i8IVvbMg==","mode":420,"size":1951},"README.md":{"checkedAt":1678887829116,"integrity":"sha512-1BgjvBPH6o+lkgXJM38/EDL+0AX/oakCUfXmTy/NBfGgAXQCxkwHv4guILVjcdcnrr9wcdzm/xcPmfKEIQDPyA==","mode":420,"size":453},"index.js":{"checkedAt":1678887829145,"integrity":"sha512-eEmHngSnNU6nPpimFU52RydvWsnfyjxEgMXFQWi49ozcxNLsIXvObDrpVccOJyU7iIUnUyJ6qR9em+yUg0g5PQ==","mode":420,"size":64735}}}
|
||||
Reference in New Issue
Block a user