├── .gitignore ├── test ├── 1.jpg └── 2.jpg ├── dist ├── blurify.min.js.map ├── blurify.es.min.js.map ├── blurify.es.js.map ├── blurify.js.map ├── blurify.es.min.js ├── blurify.min.js ├── blurify.es.js └── blurify.js ├── .npmignore ├── src ├── index.d.ts ├── common.ts └── index.ts ├── .babelrc ├── .travis.yml ├── CHANGELOG.md ├── bower.json ├── .eslintrc ├── index.html ├── LICENSE ├── README.md ├── package.json ├── rollup.config.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /test/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dabanlee/blurify/HEAD/test/1.jpg -------------------------------------------------------------------------------- /test/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dabanlee/blurify/HEAD/test/2.jpg -------------------------------------------------------------------------------- /dist/blurify.min.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"blurify.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""} -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | test 3 | index.html 4 | *.jpg 5 | bower.json 6 | rollup.config.js 7 | webpack.config.babel.js 8 | -------------------------------------------------------------------------------- /dist/blurify.es.min.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"blurify.es.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/blurify.es.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"blurify.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'common'; 2 | declare module 'rollup-plugin-alias'; 3 | declare module 'rollup-plugin-babel-minify'; 4 | declare module 'rollup-plugin-node-resolve'; 5 | declare module 'rollup-plugin-typescript'; -------------------------------------------------------------------------------- /dist/blurify.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"blurify.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false 7 | } 8 | ] 9 | ], 10 | "plugins": [ 11 | "transform-object-rest-spread" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "8" 5 | 6 | branches: 7 | only: 8 | - master 9 | 10 | cache: 11 | directories: 12 | - $HOME/.npm 13 | - $HOME/.yarn-cache 14 | - node_modules 15 | 16 | install: 17 | - yarn install 18 | 19 | script: 20 | - yarn run publish 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | - v1.1.0 4 | - refactor 5 | 6 | - v1.0.8 7 | - fixed [#2](https://github.com/JustClear/blurify/issues/2) 8 | 9 | - v1.0.7 10 | - fault-tolerance process 11 | - set globalAlpha dynamicly based on blur radius 12 | 13 | - v1.0.6 14 | - fixed `toArray` bugs 15 | 16 | - v1.0.5 17 | - add `auto` mode 18 | 19 | - v1.0.4 20 | - add `css` mode 21 | 22 | - v1.0.3 23 | - fixed image cross origin issue 24 | 25 | - v1.0.2 26 | - fixed images reference error 27 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blurify", 3 | "description": "Image blurify", 4 | "main": "dist/blurify.js", 5 | "authors": [ 6 | "JustClear" 7 | ], 8 | "license": "MIT", 9 | "keywords": [ 10 | "blurify", 11 | "library" 12 | ], 13 | "homepage": "https://github.com/JustClear/library", 14 | "ignore": [ 15 | "**/.*", 16 | ".*", 17 | "*.js", 18 | "*.json", 19 | "*.md", 20 | "*.yml", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "tests" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "ecmaFeatures": { 4 | "modules": true 5 | }, 6 | "env": { 7 | "es6": true, 8 | "browser": true, 9 | "node": true, 10 | "mocha": true, 11 | }, 12 | "globals": { 13 | "define": true 14 | }, 15 | "parser": "babel-eslint", 16 | "rules": { 17 | "semi": [2, "always"], 18 | "quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }], 19 | "comma-dangle": [2, "always-multiline"], 20 | "no-console": [0, { allow: ["warn", "error"] }], 21 | "no-multiple-empty-lines": [2, { "max": 1 }] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | blurify 8 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 大板栗 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # blurify 2 | 3 | ![npmsize](https://img.shields.io/bundlephobia/min/blurify) 4 | 5 | blurify.js is a tiny(~2kb) library to blur pictures, with graceful downgrade support from `css` mode to `canvas` mode. 6 | 7 | ## Installation 8 | 9 | ```sh 10 | $ npm i blurify 11 | ``` 12 | 13 | ## DEMO 14 | 15 | [Demo](https://dabanlee.github.io/blurify/) 16 | 17 | ## Usage 18 | 19 | ### blurify(options) 20 | 21 | blurify the images with given `options`: 22 | 23 | - `images` { Element }, blurify target elements. 24 | - `blur` { Int }, extent of blur, defaulting to `6`. 25 | - `mode` { String }, mode of blurify. 26 | - `css`: use `filter` property.(`default`) 27 | - `canvas`: use `canvas` export base64. 28 | - `auto`: use `css` mode firstly, otherwise switch to `canvas` mode by automatically. 29 | 30 | ```js 31 | import blurify from 'blurify'; 32 | 33 | new blurify({ 34 | images: document.querySelectorAll('.blurify'), 35 | blur: 6, 36 | mode: 'css', 37 | }); 38 | 39 | // or in shorthand 40 | 41 | blurify(6, document.querySelectorAll('.blurify')); 42 | ``` 43 | 44 | ### License 45 | 46 | Licensed under the [MIT License](https://github.com/dabanlee/blurify/blob/master/LICENSE) 47 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blurify", 3 | "version": "1.2.1", 4 | "description": "Image blurify.", 5 | "main": "dist/blurify.js", 6 | "moduleName": "blurify", 7 | "scripts": { 8 | "test": "mocha test/index.js", 9 | "start": "NODE_ENV=development rollup -w -c rollup.config.js", 10 | "dev": "NODE_ENV=development rollup -c rollup.config.js", 11 | "prod": "NODE_ENV=production rollup -c rollup.config.js", 12 | "build": "rm -rf dist && npm run dev && npm run prod" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/dabanlee/blurify.git" 17 | }, 18 | "keywords": [ 19 | "blurify", 20 | "library" 21 | ], 22 | "author": "大板栗", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/dabanlee/blurify/issues" 26 | }, 27 | "homepage": "https://github.com/dabanlee/blurify#readme", 28 | "devDependencies": { 29 | "expect.js": "^0.3.1", 30 | "mocha": "^5.2.0", 31 | "@rollup/plugin-commonjs": "^14.0.0", 32 | "@rollup/plugin-node-resolve": "^8.4.0", 33 | "rollup": "^2.26.4", 34 | "rollup-plugin-terser": "^7.0.0", 35 | "rollup-plugin-typescript2": "^0.27.1", 36 | "tslib": "^2.0.0", 37 | "typescript": "^3.9.3" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import { terser } from 'rollup-plugin-terser' 2 | import { nodeResolve } from '@rollup/plugin-node-resolve' 3 | import typescript from 'rollup-plugin-typescript2' 4 | import commonjs from '@rollup/plugin-commonjs' 5 | 6 | const isProd = process.env.NODE_ENV === 'production' 7 | const { moduleName, name } = require('./package.json') 8 | const fileName = name 9 | const getFilePath = (format = '') => `dist/${fileName}${format == '' ? '' : '.'}${format}.js` 10 | const output = options => ({ 11 | name: moduleName, 12 | sourcemap: true, 13 | ...options, 14 | globals: { 15 | // 16 | }, 17 | }) 18 | 19 | const configure = { 20 | input: 'src/index.ts', 21 | output: [output({ 22 | file: getFilePath(), 23 | format: 'umd', 24 | }), output({ 25 | file: getFilePath('es'), 26 | format: 'es', 27 | })], 28 | plugins: [ 29 | typescript(), 30 | commonjs(), 31 | nodeResolve(), 32 | ], 33 | external: [], 34 | } 35 | 36 | if (isProd) { 37 | configure.output = configure.output.map(output => { 38 | const format = output.format == 'umd' ? '' : `.${output.format}` 39 | output.file = `dist/${fileName}${format}.min.js` 40 | return output 41 | }) 42 | configure.plugins.push(terser()) 43 | } 44 | 45 | export default configure 46 | -------------------------------------------------------------------------------- /src/common.ts: -------------------------------------------------------------------------------- 1 | export function preload(images: HTMLImageElement[]) { 2 | const imageNodes: HTMLImageElement[] = []; 3 | let count = 0, doneAction = (images: any[]) => {}; 4 | 5 | images = (typeof images != 'object') ? [images] : images; 6 | 7 | images.length === 0 && doneAction(imageNodes); 8 | 9 | images.map((image: HTMLImageElement) => { 10 | const _image = new Image(); 11 | _image.crossOrigin = '*'; 12 | _image.src = image.dataset ? image.dataset.src : image.getAttribute('data-src'); 13 | _image.onload = imageLoad; 14 | _image.onerror = imageLoad; 15 | imageNodes.push(_image); 16 | }); 17 | 18 | function imageLoad() { 19 | count++; 20 | if (count == images.length) doneAction(imageNodes); 21 | } 22 | 23 | return { 24 | done(cb: (images: []) => void) { 25 | doneAction = arguments[0] || doneAction; 26 | }, 27 | }; 28 | } 29 | 30 | export function cssSupport(key: string, value: string) { 31 | const element: HTMLDivElement = document.createElement('div'); 32 | 33 | switch (arguments.length) { 34 | case 1: 35 | return key in element.style ? true : false; 36 | case 2: 37 | element.style[key] = value; 38 | return element.style[key] ? true : false; 39 | default: 40 | return false; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /dist/blurify.es.min.js: -------------------------------------------------------------------------------- 1 | function t(t,e){var s=document.createElement("div");switch(arguments.length){case 1:return t in s.style;case 2:return s.style[t]=e,!!s.style[t];default:return!1}}function e(s){if(void 0===s&&(s={blur:6,mode:"auto",images:[]}),!(this instanceof e))return new e(s);"number"==typeof s&&(s={blur:s,images:arguments[1],mode:"auto"}),this.options=s,this.blur=s.blur||6,this.mode=s.mode||"css",console.log(),this.$els=1==s.images.nodeType?[s.images]:[].slice.call(s.images),"auto"==this.mode?t("filter","blur(1px)")?this.useCSSMode():this.useCanvasMode():"css"==this.mode?(this.blur=this.blur/2,this.useCSSMode()):this.useCanvasMode()}e.prototype.useCSSMode=function(){var t=this;console.log(this.$els),this.$els.map((function(e){console.log("el",e),e.src=e.dataset?e.dataset.src:e.getAttribute("data-src"),e.style.filter=e.style["-webkit-filter"]="blur("+t.blur+"px)"}))},e.prototype.useCanvasMode=function(){var t=this;this.imageType=this.options.imageType||"image/jpeg",function(t){var e=[],s=0,o=function(t){};function a(){++s==t.length&&o(e)}return 0===(t="object"!=typeof t?[t]:t).length&&o(e),t.map((function(t){var s=new Image;s.crossOrigin="*",s.src=t.dataset?t.dataset.src:t.getAttribute("data-src"),s.onload=a,s.onerror=a,e.push(s)})),{done:function(t){o=arguments[0]||o}}}(this.$els).done((function(e){e.map((function(e,s){t.$els[s].src=t.getDataURL(e)}))}))},e.prototype.blurify=function(t,e){var s=t.getContext("2d");s.globalAlpha=1/(2*+e);for(var o=-e;o<=e;o+=2)for(var a=-e;a<=e;a+=2)s.drawImage(t,a,o),a>=0&&o>=0&&s.drawImage(t,-(a-1),-(o-1));s.globalAlpha=1},e.prototype.getDataURL=function(t){var e=document.createElement("canvas"),s=e.getContext("2d");return e.width=t.width,e.height=t.height,s.drawImage(t,0,0),this.blurify(e,this.blur),e.toDataURL(this.imageType)};export default e; 2 | //# sourceMappingURL=blurify.es.min.js.map 3 | -------------------------------------------------------------------------------- /dist/blurify.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).blurify=t()}(this,(function(){"use strict";function e(e,t){var o=document.createElement("div");switch(arguments.length){case 1:return e in o.style;case 2:return o.style[e]=t,!!o.style[e];default:return!1}}function t(o){if(void 0===o&&(o={blur:6,mode:"auto",images:[]}),!(this instanceof t))return new t(o);"number"==typeof o&&(o={blur:o,images:arguments[1],mode:"auto"}),this.options=o,this.blur=o.blur||6,this.mode=o.mode||"css",console.log(),this.$els=1==o.images.nodeType?[o.images]:[].slice.call(o.images),"auto"==this.mode?e("filter","blur(1px)")?this.useCSSMode():this.useCanvasMode():"css"==this.mode?(this.blur=this.blur/2,this.useCSSMode()):this.useCanvasMode()}return t.prototype.useCSSMode=function(){var e=this;console.log(this.$els),this.$els.map((function(t){console.log("el",t),t.src=t.dataset?t.dataset.src:t.getAttribute("data-src"),t.style.filter=t.style["-webkit-filter"]="blur("+e.blur+"px)"}))},t.prototype.useCanvasMode=function(){var e=this;this.imageType=this.options.imageType||"image/jpeg",function(e){var t=[],o=0,s=function(e){};function i(){++o==e.length&&s(t)}return 0===(e="object"!=typeof e?[e]:e).length&&s(t),e.map((function(e){var o=new Image;o.crossOrigin="*",o.src=e.dataset?e.dataset.src:e.getAttribute("data-src"),o.onload=i,o.onerror=i,t.push(o)})),{done:function(e){s=arguments[0]||s}}}(this.$els).done((function(t){t.map((function(t,o){e.$els[o].src=e.getDataURL(t)}))}))},t.prototype.blurify=function(e,t){var o=e.getContext("2d");o.globalAlpha=1/(2*+t);for(var s=-t;s<=t;s+=2)for(var i=-t;i<=t;i+=2)o.drawImage(e,i,s),i>=0&&s>=0&&o.drawImage(e,-(i-1),-(s-1));o.globalAlpha=1},t.prototype.getDataURL=function(e){var t=document.createElement("canvas"),o=t.getContext("2d");return t.width=e.width,t.height=e.height,o.drawImage(e,0,0),this.blurify(t,this.blur),t.toDataURL(this.imageType)},t})); 2 | //# sourceMappingURL=blurify.min.js.map 3 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { preload, cssSupport } from './common'; 2 | 3 | export default function blurify(options: { 4 | blur: number 5 | mode: string 6 | images: HTMLImageElement | HTMLImageElement[] 7 | } = { 8 | blur: 6, 9 | mode: 'auto', 10 | images: [], 11 | }) { 12 | if (!(this instanceof blurify)) return new (blurify as any)(options); 13 | 14 | if (typeof options === 'number') { 15 | options = { 16 | blur: options, 17 | images: arguments[1], 18 | mode: 'auto', 19 | }; 20 | } 21 | 22 | this.options = options; 23 | this.blur = options.blur || 6; 24 | this.mode = options.mode || 'css'; 25 | console.log(); 26 | 27 | this.$els = options.images.nodeType == 1 ? [options.images] : [].slice.call(options.images); 28 | 29 | if (this.mode == 'auto') { 30 | cssSupport('filter', 'blur(1px)') ? this.useCSSMode() : this.useCanvasMode(); 31 | } else if (this.mode == 'css') { 32 | this.blur = this.blur / 2; 33 | this.useCSSMode(); 34 | } else { 35 | this.useCanvasMode(); 36 | } 37 | } 38 | 39 | blurify.prototype.useCSSMode = function (): void { 40 | console.log(this.$els); 41 | 42 | this.$els.map((el: HTMLImageElement) => { 43 | console.log('el', el); 44 | 45 | el.src = el.dataset ? el.dataset.src : el.getAttribute('data-src'); 46 | el.style['filter'] = el.style['-webkit-filter'] = `blur(${this.blur}px)`; 47 | }); 48 | }; 49 | 50 | blurify.prototype.useCanvasMode = function (): void { 51 | this.imageType = this.options.imageType || `image/jpeg`; 52 | 53 | preload(this.$els).done((images: []) => { 54 | images.map((image, index) => { 55 | this.$els[index].src = this.getDataURL(image); 56 | }); 57 | }); 58 | }; 59 | 60 | blurify.prototype.blurify = function (canvas: HTMLCanvasElement, blur: number | string): void { 61 | const ctx = canvas.getContext('2d'); 62 | ctx.globalAlpha = 1 / (2 * +blur); 63 | for (let y = -blur; y <= blur; y += 2) { 64 | for (let x = -blur; x <= blur; x += 2) { 65 | ctx.drawImage(canvas, x, y); 66 | if (x >= 0 && y >= 0) ctx.drawImage(canvas, -(x - 1), -(y - 1)); 67 | } 68 | } 69 | ctx.globalAlpha = 1; 70 | }; 71 | 72 | blurify.prototype.getDataURL = function(image: HTMLImageElement) { 73 | const canvas = document.createElement('canvas'); 74 | const ctx = canvas.getContext('2d'); 75 | 76 | canvas.width = image.width; 77 | canvas.height = image.height; 78 | ctx.drawImage(image, 0, 0); 79 | 80 | this.blurify(canvas, this.blur); 81 | 82 | return canvas.toDataURL(this.imageType); 83 | }; 84 | -------------------------------------------------------------------------------- /dist/blurify.es.js: -------------------------------------------------------------------------------- 1 | function preload(images) { 2 | var imageNodes = []; 3 | var count = 0, doneAction = function (images) { }; 4 | images = (typeof images != 'object') ? [images] : images; 5 | images.length === 0 && doneAction(imageNodes); 6 | images.map(function (image) { 7 | var _image = new Image(); 8 | _image.crossOrigin = '*'; 9 | _image.src = image.dataset ? image.dataset.src : image.getAttribute('data-src'); 10 | _image.onload = imageLoad; 11 | _image.onerror = imageLoad; 12 | imageNodes.push(_image); 13 | }); 14 | function imageLoad() { 15 | count++; 16 | if (count == images.length) 17 | doneAction(imageNodes); 18 | } 19 | return { 20 | done: function (cb) { 21 | doneAction = arguments[0] || doneAction; 22 | }, 23 | }; 24 | } 25 | function cssSupport(key, value) { 26 | var element = document.createElement('div'); 27 | switch (arguments.length) { 28 | case 1: 29 | return key in element.style ? true : false; 30 | case 2: 31 | element.style[key] = value; 32 | return element.style[key] ? true : false; 33 | default: 34 | return false; 35 | } 36 | } 37 | 38 | function blurify(options) { 39 | if (options === void 0) { options = { 40 | blur: 6, 41 | mode: 'auto', 42 | images: [], 43 | }; } 44 | if (!(this instanceof blurify)) 45 | return new blurify(options); 46 | if (typeof options === 'number') { 47 | options = { 48 | blur: options, 49 | images: arguments[1], 50 | mode: 'auto', 51 | }; 52 | } 53 | this.options = options; 54 | this.blur = options.blur || 6; 55 | this.mode = options.mode || 'css'; 56 | console.log(); 57 | // @ts-ignore 58 | this.$els = options.images.nodeType == 1 ? [options.images] : [].slice.call(options.images); 59 | if (this.mode == 'auto') { 60 | cssSupport('filter', 'blur(1px)') ? this.useCSSMode() : this.useCanvasMode(); 61 | } 62 | else if (this.mode == 'css') { 63 | this.blur = this.blur / 2; 64 | this.useCSSMode(); 65 | } 66 | else { 67 | this.useCanvasMode(); 68 | } 69 | } 70 | blurify.prototype.useCSSMode = function () { 71 | var _this = this; 72 | console.log(this.$els); 73 | this.$els.map(function (el) { 74 | console.log('el', el); 75 | el.src = el.dataset ? el.dataset.src : el.getAttribute('data-src'); 76 | el.style['filter'] = el.style['-webkit-filter'] = "blur(" + _this.blur + "px)"; 77 | }); 78 | }; 79 | blurify.prototype.useCanvasMode = function () { 80 | var _this = this; 81 | this.imageType = this.options.imageType || "image/jpeg"; 82 | preload(this.$els).done(function (images) { 83 | images.map(function (image, index) { 84 | _this.$els[index].src = _this.getDataURL(image); 85 | }); 86 | }); 87 | }; 88 | blurify.prototype.blurify = function (canvas, blur) { 89 | var ctx = canvas.getContext('2d'); 90 | ctx.globalAlpha = 1 / (2 * +blur); 91 | for (var y = -blur; y <= blur; y += 2) { 92 | for (var x = -blur; x <= blur; x += 2) { 93 | ctx.drawImage(canvas, x, y); 94 | if (x >= 0 && y >= 0) 95 | ctx.drawImage(canvas, -(x - 1), -(y - 1)); 96 | } 97 | } 98 | ctx.globalAlpha = 1; 99 | }; 100 | blurify.prototype.getDataURL = function (image) { 101 | var canvas = document.createElement('canvas'); 102 | var ctx = canvas.getContext('2d'); 103 | canvas.width = image.width; 104 | canvas.height = image.height; 105 | ctx.drawImage(image, 0, 0); 106 | this.blurify(canvas, this.blur); 107 | return canvas.toDataURL(this.imageType); 108 | }; 109 | 110 | export default blurify; 111 | //# sourceMappingURL=blurify.es.js.map 112 | -------------------------------------------------------------------------------- /dist/blurify.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 3 | typeof define === 'function' && define.amd ? define(factory) : 4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.blurify = factory()); 5 | }(this, (function () { 'use strict'; 6 | 7 | function preload(images) { 8 | var imageNodes = []; 9 | var count = 0, doneAction = function (images) { }; 10 | images = (typeof images != 'object') ? [images] : images; 11 | images.length === 0 && doneAction(imageNodes); 12 | images.map(function (image) { 13 | var _image = new Image(); 14 | _image.crossOrigin = '*'; 15 | _image.src = image.dataset ? image.dataset.src : image.getAttribute('data-src'); 16 | _image.onload = imageLoad; 17 | _image.onerror = imageLoad; 18 | imageNodes.push(_image); 19 | }); 20 | function imageLoad() { 21 | count++; 22 | if (count == images.length) 23 | doneAction(imageNodes); 24 | } 25 | return { 26 | done: function (cb) { 27 | doneAction = arguments[0] || doneAction; 28 | }, 29 | }; 30 | } 31 | function cssSupport(key, value) { 32 | var element = document.createElement('div'); 33 | switch (arguments.length) { 34 | case 1: 35 | return key in element.style ? true : false; 36 | case 2: 37 | element.style[key] = value; 38 | return element.style[key] ? true : false; 39 | default: 40 | return false; 41 | } 42 | } 43 | 44 | function blurify(options) { 45 | if (options === void 0) { options = { 46 | blur: 6, 47 | mode: 'auto', 48 | images: [], 49 | }; } 50 | if (!(this instanceof blurify)) 51 | return new blurify(options); 52 | if (typeof options === 'number') { 53 | options = { 54 | blur: options, 55 | images: arguments[1], 56 | mode: 'auto', 57 | }; 58 | } 59 | this.options = options; 60 | this.blur = options.blur || 6; 61 | this.mode = options.mode || 'css'; 62 | console.log(); 63 | // @ts-ignore 64 | this.$els = options.images.nodeType == 1 ? [options.images] : [].slice.call(options.images); 65 | if (this.mode == 'auto') { 66 | cssSupport('filter', 'blur(1px)') ? this.useCSSMode() : this.useCanvasMode(); 67 | } 68 | else if (this.mode == 'css') { 69 | this.blur = this.blur / 2; 70 | this.useCSSMode(); 71 | } 72 | else { 73 | this.useCanvasMode(); 74 | } 75 | } 76 | blurify.prototype.useCSSMode = function () { 77 | var _this = this; 78 | console.log(this.$els); 79 | this.$els.map(function (el) { 80 | console.log('el', el); 81 | el.src = el.dataset ? el.dataset.src : el.getAttribute('data-src'); 82 | el.style['filter'] = el.style['-webkit-filter'] = "blur(" + _this.blur + "px)"; 83 | }); 84 | }; 85 | blurify.prototype.useCanvasMode = function () { 86 | var _this = this; 87 | this.imageType = this.options.imageType || "image/jpeg"; 88 | preload(this.$els).done(function (images) { 89 | images.map(function (image, index) { 90 | _this.$els[index].src = _this.getDataURL(image); 91 | }); 92 | }); 93 | }; 94 | blurify.prototype.blurify = function (canvas, blur) { 95 | var ctx = canvas.getContext('2d'); 96 | ctx.globalAlpha = 1 / (2 * +blur); 97 | for (var y = -blur; y <= blur; y += 2) { 98 | for (var x = -blur; x <= blur; x += 2) { 99 | ctx.drawImage(canvas, x, y); 100 | if (x >= 0 && y >= 0) 101 | ctx.drawImage(canvas, -(x - 1), -(y - 1)); 102 | } 103 | } 104 | ctx.globalAlpha = 1; 105 | }; 106 | blurify.prototype.getDataURL = function (image) { 107 | var canvas = document.createElement('canvas'); 108 | var ctx = canvas.getContext('2d'); 109 | canvas.width = image.width; 110 | canvas.height = image.height; 111 | ctx.drawImage(image, 0, 0); 112 | this.blurify(canvas, this.blur); 113 | return canvas.toDataURL(this.imageType); 114 | }; 115 | 116 | return blurify; 117 | 118 | }))); 119 | //# sourceMappingURL=blurify.js.map 120 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@babel/code-frame@^7.10.4": 6 | version "7.10.4" 7 | resolved "https://registry.npm.taobao.org/@babel/code-frame/download/@babel/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" 8 | integrity sha1-Fo2ho26Q2miujUnA8bSMfGJJITo= 9 | dependencies: 10 | "@babel/highlight" "^7.10.4" 11 | 12 | "@babel/helper-validator-identifier@^7.10.4": 13 | version "7.10.4" 14 | resolved "https://registry.npm.taobao.org/@babel/helper-validator-identifier/download/@babel/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" 15 | integrity sha1-p4x6clHgH2FlEtMbEK3PUq2l4NI= 16 | 17 | "@babel/highlight@^7.10.4": 18 | version "7.10.4" 19 | resolved "https://registry.npm.taobao.org/@babel/highlight/download/@babel/highlight-7.10.4.tgz?cache=0&sync_timestamp=1593521087106&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhighlight%2Fdownload%2F%40babel%2Fhighlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" 20 | integrity sha1-fRvf1ldTU4+r5sOFls23bZrGAUM= 21 | dependencies: 22 | "@babel/helper-validator-identifier" "^7.10.4" 23 | chalk "^2.0.0" 24 | js-tokens "^4.0.0" 25 | 26 | "@rollup/plugin-commonjs@^14.0.0": 27 | version "14.0.0" 28 | resolved "https://registry.npm.taobao.org/@rollup/plugin-commonjs/download/@rollup/plugin-commonjs-14.0.0.tgz?cache=0&sync_timestamp=1597326192868&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40rollup%2Fplugin-commonjs%2Fdownload%2F%40rollup%2Fplugin-commonjs-14.0.0.tgz#4285f9ec2db686a31129e5a2b415c94aa1f836f0" 29 | integrity sha1-QoX57C22hqMRKeWitBXJSqH4NvA= 30 | dependencies: 31 | "@rollup/pluginutils" "^3.0.8" 32 | commondir "^1.0.1" 33 | estree-walker "^1.0.1" 34 | glob "^7.1.2" 35 | is-reference "^1.1.2" 36 | magic-string "^0.25.2" 37 | resolve "^1.11.0" 38 | 39 | "@rollup/plugin-node-resolve@^8.4.0": 40 | version "8.4.0" 41 | resolved "https://registry.npm.taobao.org/@rollup/plugin-node-resolve/download/@rollup/plugin-node-resolve-8.4.0.tgz?cache=0&sync_timestamp=1597328884850&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40rollup%2Fplugin-node-resolve%2Fdownload%2F%40rollup%2Fplugin-node-resolve-8.4.0.tgz#261d79a680e9dc3d86761c14462f24126ba83575" 42 | integrity sha1-Jh15poDp3D2GdhwURi8kEmuoNXU= 43 | dependencies: 44 | "@rollup/pluginutils" "^3.1.0" 45 | "@types/resolve" "1.17.1" 46 | builtin-modules "^3.1.0" 47 | deep-freeze "^0.0.1" 48 | deepmerge "^4.2.2" 49 | is-module "^1.0.0" 50 | resolve "^1.17.0" 51 | 52 | "@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0": 53 | version "3.1.0" 54 | resolved "https://registry.npm.taobao.org/@rollup/pluginutils/download/@rollup/pluginutils-3.1.0.tgz?cache=0&sync_timestamp=1597328386643&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40rollup%2Fpluginutils%2Fdownload%2F%40rollup%2Fpluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" 55 | integrity sha1-cGtFJO5tyLEDs8mVUz5a1oDAK5s= 56 | dependencies: 57 | "@types/estree" "0.0.39" 58 | estree-walker "^1.0.1" 59 | picomatch "^2.2.2" 60 | 61 | "@types/estree@*": 62 | version "0.0.45" 63 | resolved "https://registry.npm.taobao.org/@types/estree/download/@types/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884" 64 | integrity sha1-6Th1cpmOXs2sIhlQ2rPow7Fq+IQ= 65 | 66 | "@types/estree@0.0.39": 67 | version "0.0.39" 68 | resolved "https://registry.npm.taobao.org/@types/estree/download/@types/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" 69 | integrity sha1-4Xfmme4bjCLSMXTKqnQiZEOJUJ8= 70 | 71 | "@types/node@*": 72 | version "14.6.0" 73 | resolved "https://registry.npm.taobao.org/@types/node/download/@types/node-14.6.0.tgz?cache=0&sync_timestamp=1597673176468&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499" 74 | integrity sha1-fUQRv1FXM5M318/4ZNn/RfF3tJk= 75 | 76 | "@types/resolve@1.17.1": 77 | version "1.17.1" 78 | resolved "https://registry.npm.taobao.org/@types/resolve/download/@types/resolve-1.17.1.tgz?cache=0&sync_timestamp=1596840738717&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fresolve%2Fdownload%2F%40types%2Fresolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" 79 | integrity sha1-Ov1q2JZ8d+Q3bFmKgt3Vj0bsRdY= 80 | dependencies: 81 | "@types/node" "*" 82 | 83 | ansi-styles@^3.2.1: 84 | version "3.2.1" 85 | resolved "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" 86 | integrity sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0= 87 | dependencies: 88 | color-convert "^1.9.0" 89 | 90 | balanced-match@^1.0.0: 91 | version "1.0.0" 92 | resolved "https://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" 93 | integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= 94 | 95 | brace-expansion@^1.1.7: 96 | version "1.1.11" 97 | resolved "https://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" 98 | integrity sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0= 99 | dependencies: 100 | balanced-match "^1.0.0" 101 | concat-map "0.0.1" 102 | 103 | browser-stdout@1.3.1: 104 | version "1.3.1" 105 | resolved "https://registry.npm.taobao.org/browser-stdout/download/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" 106 | integrity sha1-uqVZ7hTO1zRSIputcyZGfGH6vWA= 107 | 108 | buffer-from@^1.0.0: 109 | version "1.1.1" 110 | resolved "https://registry.npm.taobao.org/buffer-from/download/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" 111 | integrity sha1-MnE7wCj3XAL9txDXx7zsHyxgcO8= 112 | 113 | builtin-modules@^3.1.0: 114 | version "3.1.0" 115 | resolved "https://registry.npm.taobao.org/builtin-modules/download/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484" 116 | integrity sha1-qtl8FRMet2tltQ7yCOdYTNdqdIQ= 117 | 118 | chalk@^2.0.0: 119 | version "2.4.2" 120 | resolved "https://registry.npm.taobao.org/chalk/download/chalk-2.4.2.tgz?cache=0&sync_timestamp=1591687076871&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fchalk%2Fdownload%2Fchalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" 121 | integrity sha1-zUJUFnelQzPPVBpJEIwUMrRMlCQ= 122 | dependencies: 123 | ansi-styles "^3.2.1" 124 | escape-string-regexp "^1.0.5" 125 | supports-color "^5.3.0" 126 | 127 | color-convert@^1.9.0: 128 | version "1.9.3" 129 | resolved "https://registry.npm.taobao.org/color-convert/download/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" 130 | integrity sha1-u3GFBpDh8TZWfeYp0tVHHe2kweg= 131 | dependencies: 132 | color-name "1.1.3" 133 | 134 | color-name@1.1.3: 135 | version "1.1.3" 136 | resolved "https://registry.npm.taobao.org/color-name/download/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" 137 | integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= 138 | 139 | commander@2.15.1: 140 | version "2.15.1" 141 | resolved "https://registry.npm.taobao.org/commander/download/commander-2.15.1.tgz?cache=0&sync_timestamp=1595168214577&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" 142 | integrity sha1-30boZ9D8Kuxmo0ZitAapzK//Ww8= 143 | 144 | commander@^2.20.0: 145 | version "2.20.3" 146 | resolved "https://registry.npm.taobao.org/commander/download/commander-2.20.3.tgz?cache=0&sync_timestamp=1595168214577&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" 147 | integrity sha1-/UhehMA+tIgcIHIrpIA16FMa6zM= 148 | 149 | commondir@^1.0.1: 150 | version "1.0.1" 151 | resolved "https://registry.npm.taobao.org/commondir/download/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" 152 | integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= 153 | 154 | concat-map@0.0.1: 155 | version "0.0.1" 156 | resolved "https://registry.npm.taobao.org/concat-map/download/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" 157 | integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= 158 | 159 | debug@3.1.0: 160 | version "3.1.0" 161 | resolved "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" 162 | integrity sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE= 163 | dependencies: 164 | ms "2.0.0" 165 | 166 | deep-freeze@^0.0.1: 167 | version "0.0.1" 168 | resolved "https://registry.npm.taobao.org/deep-freeze/download/deep-freeze-0.0.1.tgz#3a0b0005de18672819dfd38cd31f91179c893e84" 169 | integrity sha1-OgsABd4YZygZ39OM0x+RF5yJPoQ= 170 | 171 | deepmerge@^4.2.2: 172 | version "4.2.2" 173 | resolved "https://registry.npm.taobao.org/deepmerge/download/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" 174 | integrity sha1-RNLqNnm49NT/ujPwPYZfwee/SVU= 175 | 176 | diff@3.5.0: 177 | version "3.5.0" 178 | resolved "https://registry.npm.taobao.org/diff/download/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" 179 | integrity sha1-gAwN0eCov7yVg1wgKtIg/jF+WhI= 180 | 181 | escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: 182 | version "1.0.5" 183 | resolved "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" 184 | integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= 185 | 186 | estree-walker@^1.0.1: 187 | version "1.0.1" 188 | resolved "https://registry.npm.taobao.org/estree-walker/download/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" 189 | integrity sha1-MbxdYSyWtwQQa0d+bdXYqhOMtwA= 190 | 191 | expect.js@^0.3.1: 192 | version "0.3.1" 193 | resolved "https://registry.npm.taobao.org/expect.js/download/expect.js-0.3.1.tgz#b0a59a0d2eff5437544ebf0ceaa6015841d09b5b" 194 | integrity sha1-sKWaDS7/VDdUTr8M6qYBWEHQm1s= 195 | 196 | find-cache-dir@^3.3.1: 197 | version "3.3.1" 198 | resolved "https://registry.npm.taobao.org/find-cache-dir/download/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880" 199 | integrity sha1-ibM/rUpGcNqpT4Vff74x1thP6IA= 200 | dependencies: 201 | commondir "^1.0.1" 202 | make-dir "^3.0.2" 203 | pkg-dir "^4.1.0" 204 | 205 | find-up@^4.0.0: 206 | version "4.1.0" 207 | resolved "https://registry.npm.taobao.org/find-up/download/find-up-4.1.0.tgz?cache=0&sync_timestamp=1597169795121&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffind-up%2Fdownload%2Ffind-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" 208 | integrity sha1-l6/n1s3AvFkoWEt8jXsW6KmqXRk= 209 | dependencies: 210 | locate-path "^5.0.0" 211 | path-exists "^4.0.0" 212 | 213 | fs-extra@8.1.0: 214 | version "8.1.0" 215 | resolved "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" 216 | integrity sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA= 217 | dependencies: 218 | graceful-fs "^4.2.0" 219 | jsonfile "^4.0.0" 220 | universalify "^0.1.0" 221 | 222 | fs.realpath@^1.0.0: 223 | version "1.0.0" 224 | resolved "https://registry.npm.taobao.org/fs.realpath/download/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" 225 | integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= 226 | 227 | fsevents@~2.1.2: 228 | version "2.1.3" 229 | resolved "https://registry.npm.taobao.org/fsevents/download/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" 230 | integrity sha1-+3OHA66NL5/pAMM4Nt3r7ouX8j4= 231 | 232 | glob@7.1.2: 233 | version "7.1.2" 234 | resolved "https://registry.npm.taobao.org/glob/download/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" 235 | integrity sha1-wZyd+aAocC1nhhI4SmVSQExjbRU= 236 | dependencies: 237 | fs.realpath "^1.0.0" 238 | inflight "^1.0.4" 239 | inherits "2" 240 | minimatch "^3.0.4" 241 | once "^1.3.0" 242 | path-is-absolute "^1.0.0" 243 | 244 | glob@^7.1.2: 245 | version "7.1.6" 246 | resolved "https://registry.npm.taobao.org/glob/download/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" 247 | integrity sha1-FB8zuBp8JJLhJVlDB0gMRmeSeKY= 248 | dependencies: 249 | fs.realpath "^1.0.0" 250 | inflight "^1.0.4" 251 | inherits "2" 252 | minimatch "^3.0.4" 253 | once "^1.3.0" 254 | path-is-absolute "^1.0.0" 255 | 256 | graceful-fs@^4.1.6, graceful-fs@^4.2.0: 257 | version "4.2.4" 258 | resolved "https://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" 259 | integrity sha1-Ila94U02MpWMRl68ltxGfKB6Kfs= 260 | 261 | growl@1.10.5: 262 | version "1.10.5" 263 | resolved "https://registry.npm.taobao.org/growl/download/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" 264 | integrity sha1-8nNdwig2dPpnR4sQGBBZNVw2nl4= 265 | 266 | has-flag@^3.0.0: 267 | version "3.0.0" 268 | resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" 269 | integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= 270 | 271 | has-flag@^4.0.0: 272 | version "4.0.0" 273 | resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" 274 | integrity sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s= 275 | 276 | he@1.1.1: 277 | version "1.1.1" 278 | resolved "https://registry.npm.taobao.org/he/download/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" 279 | integrity sha1-k0EP0hsAlzUVH4howvJx80J+I/0= 280 | 281 | inflight@^1.0.4: 282 | version "1.0.6" 283 | resolved "https://registry.npm.taobao.org/inflight/download/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" 284 | integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= 285 | dependencies: 286 | once "^1.3.0" 287 | wrappy "1" 288 | 289 | inherits@2: 290 | version "2.0.4" 291 | resolved "https://registry.npm.taobao.org/inherits/download/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" 292 | integrity sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w= 293 | 294 | is-module@^1.0.0: 295 | version "1.0.0" 296 | resolved "https://registry.npm.taobao.org/is-module/download/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" 297 | integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= 298 | 299 | is-reference@^1.1.2: 300 | version "1.2.1" 301 | resolved "https://registry.npm.taobao.org/is-reference/download/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" 302 | integrity sha1-iy2sCzcfS8mU/eq6nrVC0DAC0Lc= 303 | dependencies: 304 | "@types/estree" "*" 305 | 306 | jest-worker@^26.2.1: 307 | version "26.3.0" 308 | resolved "https://registry.npm.taobao.org/jest-worker/download/jest-worker-26.3.0.tgz?cache=0&sync_timestamp=1597059193924&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjest-worker%2Fdownload%2Fjest-worker-26.3.0.tgz#7c8a97e4f4364b4f05ed8bca8ca0c24de091871f" 309 | integrity sha1-fIqX5PQ2S08F7YvKjKDCTeCRhx8= 310 | dependencies: 311 | "@types/node" "*" 312 | merge-stream "^2.0.0" 313 | supports-color "^7.0.0" 314 | 315 | js-tokens@^4.0.0: 316 | version "4.0.0" 317 | resolved "https://registry.npm.taobao.org/js-tokens/download/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" 318 | integrity sha1-GSA/tZmR35jjoocFDUZHzerzJJk= 319 | 320 | jsonfile@^4.0.0: 321 | version "4.0.0" 322 | resolved "https://registry.npm.taobao.org/jsonfile/download/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" 323 | integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= 324 | optionalDependencies: 325 | graceful-fs "^4.1.6" 326 | 327 | locate-path@^5.0.0: 328 | version "5.0.0" 329 | resolved "https://registry.npm.taobao.org/locate-path/download/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" 330 | integrity sha1-Gvujlq/WdqbUJQTQpno6frn2KqA= 331 | dependencies: 332 | p-locate "^4.1.0" 333 | 334 | magic-string@^0.25.2: 335 | version "0.25.7" 336 | resolved "https://registry.npm.taobao.org/magic-string/download/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" 337 | integrity sha1-P0l9b9NMZpxnmNy4IfLvMfVEUFE= 338 | dependencies: 339 | sourcemap-codec "^1.4.4" 340 | 341 | make-dir@^3.0.2: 342 | version "3.1.0" 343 | resolved "https://registry.npm.taobao.org/make-dir/download/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" 344 | integrity sha1-QV6WcEazp/HRhSd9hKpYIDcmoT8= 345 | dependencies: 346 | semver "^6.0.0" 347 | 348 | merge-stream@^2.0.0: 349 | version "2.0.0" 350 | resolved "https://registry.npm.taobao.org/merge-stream/download/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" 351 | integrity sha1-UoI2KaFN0AyXcPtq1H3GMQ8sH2A= 352 | 353 | minimatch@3.0.4, minimatch@^3.0.4: 354 | version "3.0.4" 355 | resolved "https://registry.npm.taobao.org/minimatch/download/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" 356 | integrity sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM= 357 | dependencies: 358 | brace-expansion "^1.1.7" 359 | 360 | minimist@0.0.8: 361 | version "0.0.8" 362 | resolved "https://registry.npm.taobao.org/minimist/download/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" 363 | integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= 364 | 365 | mkdirp@0.5.1: 366 | version "0.5.1" 367 | resolved "https://registry.npm.taobao.org/mkdirp/download/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" 368 | integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= 369 | dependencies: 370 | minimist "0.0.8" 371 | 372 | mocha@^5.2.0: 373 | version "5.2.0" 374 | resolved "https://registry.npm.taobao.org/mocha/download/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6" 375 | integrity sha1-bYrlCPWRZ/lA8rWzxKYSrlDJCuY= 376 | dependencies: 377 | browser-stdout "1.3.1" 378 | commander "2.15.1" 379 | debug "3.1.0" 380 | diff "3.5.0" 381 | escape-string-regexp "1.0.5" 382 | glob "7.1.2" 383 | growl "1.10.5" 384 | he "1.1.1" 385 | minimatch "3.0.4" 386 | mkdirp "0.5.1" 387 | supports-color "5.4.0" 388 | 389 | ms@2.0.0: 390 | version "2.0.0" 391 | resolved "https://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" 392 | integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= 393 | 394 | once@^1.3.0: 395 | version "1.4.0" 396 | resolved "https://registry.npm.taobao.org/once/download/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" 397 | integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= 398 | dependencies: 399 | wrappy "1" 400 | 401 | p-limit@^2.2.0: 402 | version "2.3.0" 403 | resolved "https://registry.npm.taobao.org/p-limit/download/p-limit-2.3.0.tgz?cache=0&sync_timestamp=1594559711554&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fp-limit%2Fdownload%2Fp-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" 404 | integrity sha1-PdM8ZHohT9//2DWTPrCG2g3CHbE= 405 | dependencies: 406 | p-try "^2.0.0" 407 | 408 | p-locate@^4.1.0: 409 | version "4.1.0" 410 | resolved "https://registry.npm.taobao.org/p-locate/download/p-locate-4.1.0.tgz?cache=0&sync_timestamp=1597081369770&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fp-locate%2Fdownload%2Fp-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" 411 | integrity sha1-o0KLtwiLOmApL2aRkni3wpetTwc= 412 | dependencies: 413 | p-limit "^2.2.0" 414 | 415 | p-try@^2.0.0: 416 | version "2.2.0" 417 | resolved "https://registry.npm.taobao.org/p-try/download/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" 418 | integrity sha1-yyhoVA4xPWHeWPr741zpAE1VQOY= 419 | 420 | path-exists@^4.0.0: 421 | version "4.0.0" 422 | resolved "https://registry.npm.taobao.org/path-exists/download/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" 423 | integrity sha1-UTvb4tO5XXdi6METfvoZXGxhtbM= 424 | 425 | path-is-absolute@^1.0.0: 426 | version "1.0.1" 427 | resolved "https://registry.npm.taobao.org/path-is-absolute/download/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" 428 | integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= 429 | 430 | path-parse@^1.0.6: 431 | version "1.0.6" 432 | resolved "https://registry.npm.taobao.org/path-parse/download/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" 433 | integrity sha1-1i27VnlAXXLEc37FhgDp3c8G0kw= 434 | 435 | picomatch@^2.2.2: 436 | version "2.2.2" 437 | resolved "https://registry.npm.taobao.org/picomatch/download/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" 438 | integrity sha1-IfMz6ba46v8CRo9RRupAbTRfTa0= 439 | 440 | pkg-dir@^4.1.0: 441 | version "4.2.0" 442 | resolved "https://registry.npm.taobao.org/pkg-dir/download/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" 443 | integrity sha1-8JkTPfft5CLoHR2ESCcO6z5CYfM= 444 | dependencies: 445 | find-up "^4.0.0" 446 | 447 | randombytes@^2.1.0: 448 | version "2.1.0" 449 | resolved "https://registry.npm.taobao.org/randombytes/download/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" 450 | integrity sha1-32+ENy8CcNxlzfYpE0mrekc9Tyo= 451 | dependencies: 452 | safe-buffer "^5.1.0" 453 | 454 | resolve@1.17.0, resolve@^1.11.0, resolve@^1.17.0: 455 | version "1.17.0" 456 | resolved "https://registry.npm.taobao.org/resolve/download/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" 457 | integrity sha1-sllBtUloIxzC0bt2p5y38sC/hEQ= 458 | dependencies: 459 | path-parse "^1.0.6" 460 | 461 | rollup-plugin-terser@^7.0.0: 462 | version "7.0.0" 463 | resolved "https://registry.npm.taobao.org/rollup-plugin-terser/download/rollup-plugin-terser-7.0.0.tgz#26b38ada4f0b351cd7cd872ca04c0f8532d4864f" 464 | integrity sha1-JrOK2k8LNRzXzYcsoEwPhTLUhk8= 465 | dependencies: 466 | "@babel/code-frame" "^7.10.4" 467 | jest-worker "^26.2.1" 468 | serialize-javascript "^4.0.0" 469 | terser "^5.0.0" 470 | 471 | rollup-plugin-typescript2@^0.27.1: 472 | version "0.27.2" 473 | resolved "https://registry.npm.taobao.org/rollup-plugin-typescript2/download/rollup-plugin-typescript2-0.27.2.tgz#871a7f5d2a774f9cef50d25da868eec72acc2ed8" 474 | integrity sha1-hxp/XSp3T5zvUNJdqGjuxyrMLtg= 475 | dependencies: 476 | "@rollup/pluginutils" "^3.1.0" 477 | find-cache-dir "^3.3.1" 478 | fs-extra "8.1.0" 479 | resolve "1.17.0" 480 | tslib "2.0.1" 481 | 482 | rollup@^2.26.4: 483 | version "2.26.4" 484 | resolved "https://registry.npm.taobao.org/rollup/download/rollup-2.26.4.tgz?cache=0&sync_timestamp=1597843790185&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Frollup%2Fdownload%2Frollup-2.26.4.tgz#a8350fd6bd56fce9873a7db2bd9547d40de3992b" 485 | integrity sha1-qDUP1r1W/OmHOn2yvZVH1A3jmSs= 486 | optionalDependencies: 487 | fsevents "~2.1.2" 488 | 489 | safe-buffer@^5.1.0: 490 | version "5.2.1" 491 | resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" 492 | integrity sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY= 493 | 494 | semver@^6.0.0: 495 | version "6.3.0" 496 | resolved "https://registry.npm.taobao.org/semver/download/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" 497 | integrity sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0= 498 | 499 | serialize-javascript@^4.0.0: 500 | version "4.0.0" 501 | resolved "https://registry.npm.taobao.org/serialize-javascript/download/serialize-javascript-4.0.0.tgz?cache=0&sync_timestamp=1591623621018&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fserialize-javascript%2Fdownload%2Fserialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa" 502 | integrity sha1-tSXhI4SJpez8Qq+sw/6Z5mb0sao= 503 | dependencies: 504 | randombytes "^2.1.0" 505 | 506 | source-map-support@~0.5.12: 507 | version "0.5.19" 508 | resolved "https://registry.npm.taobao.org/source-map-support/download/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" 509 | integrity sha1-qYti+G3K9PZzmWSMCFKRq56P7WE= 510 | dependencies: 511 | buffer-from "^1.0.0" 512 | source-map "^0.6.0" 513 | 514 | source-map@^0.6.0, source-map@~0.6.1: 515 | version "0.6.1" 516 | resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" 517 | integrity sha1-dHIq8y6WFOnCh6jQu95IteLxomM= 518 | 519 | sourcemap-codec@^1.4.4: 520 | version "1.4.8" 521 | resolved "https://registry.npm.taobao.org/sourcemap-codec/download/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" 522 | integrity sha1-6oBL2UhXQC5pktBaOO8a41qatMQ= 523 | 524 | supports-color@5.4.0: 525 | version "5.4.0" 526 | resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" 527 | integrity sha1-HGszdALCE3YF7+GfEP7DkPb6q1Q= 528 | dependencies: 529 | has-flag "^3.0.0" 530 | 531 | supports-color@^5.3.0: 532 | version "5.5.0" 533 | resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" 534 | integrity sha1-4uaaRKyHcveKHsCzW2id9lMO/I8= 535 | dependencies: 536 | has-flag "^3.0.0" 537 | 538 | supports-color@^7.0.0: 539 | version "7.1.0" 540 | resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1" 541 | integrity sha1-aOMlkd9z4lrRxLSRCKLsUHliv9E= 542 | dependencies: 543 | has-flag "^4.0.0" 544 | 545 | terser@^5.0.0: 546 | version "5.2.0" 547 | resolved "https://registry.npm.taobao.org/terser/download/terser-5.2.0.tgz?cache=0&sync_timestamp=1597763310814&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fterser%2Fdownload%2Fterser-5.2.0.tgz#e547d0b20926b321d3e524bf9e5bc1b10ba2f360" 548 | integrity sha1-5UfQsgkmsyHT5SS/nlvBsQui82A= 549 | dependencies: 550 | commander "^2.20.0" 551 | source-map "~0.6.1" 552 | source-map-support "~0.5.12" 553 | 554 | tslib@2.0.1, tslib@^2.0.0: 555 | version "2.0.1" 556 | resolved "https://registry.npm.taobao.org/tslib/download/tslib-2.0.1.tgz?cache=0&sync_timestamp=1596752024863&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" 557 | integrity sha1-QQ6w0RPltjVkkO7HSWA3JbAhtD4= 558 | 559 | typescript@^3.9.3: 560 | version "3.9.7" 561 | resolved "https://registry.npm.taobao.org/typescript/download/typescript-3.9.7.tgz?cache=0&sync_timestamp=1597819730396&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" 562 | integrity sha1-mNYApevcOPQMsndSLxLcgA6eJfo= 563 | 564 | universalify@^0.1.0: 565 | version "0.1.2" 566 | resolved "https://registry.npm.taobao.org/universalify/download/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" 567 | integrity sha1-tkb2m+OULavOzJ1mOcgNwQXvqmY= 568 | 569 | wrappy@1: 570 | version "1.0.2" 571 | resolved "https://registry.npm.taobao.org/wrappy/download/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" 572 | integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= 573 | --------------------------------------------------------------------------------