├── .gitignore ├── LICENSE ├── README.md ├── bin ├── command.js ├── compress.js └── index.js ├── index.js ├── lib ├── express │ ├── favicon.ico │ ├── index.js │ ├── upload │ │ └── index.js │ └── views │ │ ├── index.html │ │ └── static │ │ ├── index.css │ │ ├── index.js │ │ ├── jquery │ │ └── jquery-3.1.1.js │ │ ├── jszip │ │ ├── .codeclimate.yml │ │ ├── .editorconfig │ │ ├── .gitignore │ │ ├── .jshintignore │ │ ├── .jshintrc │ │ ├── .npmignore │ │ ├── .travis.yml │ │ ├── CHANGES.md │ │ ├── Gruntfile.js │ │ ├── LICENSE.markdown │ │ ├── README.markdown │ │ ├── _config.yml │ │ ├── bower.json │ │ ├── component.json │ │ ├── dist │ │ │ ├── jszip.js │ │ │ └── jszip.min.js │ │ ├── docs │ │ │ ├── APPNOTE.TXT │ │ │ ├── ZIP spec.txt │ │ │ └── references.txt │ │ ├── documentation │ │ │ ├── _layouts │ │ │ │ └── default.html │ │ │ ├── api_jszip.md │ │ │ ├── api_jszip │ │ │ │ ├── constructor.md │ │ │ │ ├── external.md │ │ │ │ ├── file_data.md │ │ │ │ ├── file_name.md │ │ │ │ ├── file_regex.md │ │ │ │ ├── filter.md │ │ │ │ ├── folder_data.md │ │ │ │ ├── folder_regex.md │ │ │ │ ├── for_each.md │ │ │ │ ├── generate_async.md │ │ │ │ ├── generate_internal_stream.md │ │ │ │ ├── generate_node_stream.md │ │ │ │ ├── load_async.md │ │ │ │ ├── load_async_object.md │ │ │ │ ├── remove.md │ │ │ │ ├── support.md │ │ │ │ └── version.md │ │ │ ├── api_streamhelper.md │ │ │ ├── api_streamhelper │ │ │ │ ├── accumulate.md │ │ │ │ ├── on.md │ │ │ │ ├── pause.md │ │ │ │ └── resume.md │ │ │ ├── api_zipobject.md │ │ │ ├── api_zipobject │ │ │ │ ├── async.md │ │ │ │ ├── internal_stream.md │ │ │ │ └── node_stream.md │ │ │ ├── contributing.md │ │ │ ├── css │ │ │ │ ├── main.css │ │ │ │ └── pygments.css │ │ │ ├── examples.md │ │ │ ├── examples │ │ │ │ ├── download-zip-file.html │ │ │ │ ├── downloader.html │ │ │ │ ├── downloader.js │ │ │ │ ├── get-binary-files-ajax.html │ │ │ │ └── read-local-file-api.html │ │ │ ├── faq.md │ │ │ ├── howto │ │ │ │ ├── read_zip.md │ │ │ │ └── write_zip.md │ │ │ ├── limitations.md │ │ │ └── upgrade_guide.md │ │ ├── index.html │ │ ├── lib │ │ │ ├── base64.js │ │ │ ├── compressedObject.js │ │ │ ├── compressions.js │ │ │ ├── crc32.js │ │ │ ├── defaults.js │ │ │ ├── external.js │ │ │ ├── flate.js │ │ │ ├── generate │ │ │ │ ├── ZipFileWorker.js │ │ │ │ └── index.js │ │ │ ├── index.js │ │ │ ├── license_header.js │ │ │ ├── load.js │ │ │ ├── nodejs │ │ │ │ ├── NodejsStreamInputAdapter.js │ │ │ │ └── NodejsStreamOutputAdapter.js │ │ │ ├── nodejsUtils.js │ │ │ ├── object.js │ │ │ ├── readable-stream-browser.js │ │ │ ├── reader │ │ │ │ ├── ArrayReader.js │ │ │ │ ├── DataReader.js │ │ │ │ ├── NodeBufferReader.js │ │ │ │ ├── StringReader.js │ │ │ │ ├── Uint8ArrayReader.js │ │ │ │ └── readerFor.js │ │ │ ├── signature.js │ │ │ ├── stream │ │ │ │ ├── ConvertWorker.js │ │ │ │ ├── Crc32Probe.js │ │ │ │ ├── DataLengthProbe.js │ │ │ │ ├── DataWorker.js │ │ │ │ ├── GenericWorker.js │ │ │ │ └── StreamHelper.js │ │ │ ├── support.js │ │ │ ├── utf8.js │ │ │ ├── utils.js │ │ │ ├── zipEntries.js │ │ │ ├── zipEntry.js │ │ │ └── zipObject.js │ │ ├── package.json │ │ └── vendor │ │ │ └── FileSaver.js │ │ ├── layui │ │ ├── css │ │ │ ├── layui.css │ │ │ ├── layui.mobile.css │ │ │ └── modules │ │ │ │ ├── code.css │ │ │ │ ├── laydate │ │ │ │ ├── icon.png │ │ │ │ └── laydate.css │ │ │ │ └── layer │ │ │ │ └── default │ │ │ │ ├── icon-ext.png │ │ │ │ ├── icon.png │ │ │ │ ├── layer.css │ │ │ │ ├── loading-0.gif │ │ │ │ ├── loading-1.gif │ │ │ │ └── loading-2.gif │ │ ├── font │ │ │ ├── iconfont.eot │ │ │ ├── iconfont.svg │ │ │ ├── iconfont.ttf │ │ │ └── iconfont.woff │ │ ├── images │ │ │ └── face │ │ │ │ ├── 0.gif │ │ │ │ ├── 1.gif │ │ │ │ ├── 10.gif │ │ │ │ ├── 11.gif │ │ │ │ ├── 12.gif │ │ │ │ ├── 13.gif │ │ │ │ ├── 14.gif │ │ │ │ ├── 15.gif │ │ │ │ ├── 16.gif │ │ │ │ ├── 17.gif │ │ │ │ ├── 18.gif │ │ │ │ ├── 19.gif │ │ │ │ ├── 2.gif │ │ │ │ ├── 20.gif │ │ │ │ ├── 21.gif │ │ │ │ ├── 22.gif │ │ │ │ ├── 23.gif │ │ │ │ ├── 24.gif │ │ │ │ ├── 25.gif │ │ │ │ ├── 26.gif │ │ │ │ ├── 27.gif │ │ │ │ ├── 28.gif │ │ │ │ ├── 29.gif │ │ │ │ ├── 3.gif │ │ │ │ ├── 30.gif │ │ │ │ ├── 31.gif │ │ │ │ ├── 32.gif │ │ │ │ ├── 33.gif │ │ │ │ ├── 34.gif │ │ │ │ ├── 35.gif │ │ │ │ ├── 36.gif │ │ │ │ ├── 37.gif │ │ │ │ ├── 38.gif │ │ │ │ ├── 39.gif │ │ │ │ ├── 4.gif │ │ │ │ ├── 40.gif │ │ │ │ ├── 41.gif │ │ │ │ ├── 42.gif │ │ │ │ ├── 43.gif │ │ │ │ ├── 44.gif │ │ │ │ ├── 45.gif │ │ │ │ ├── 46.gif │ │ │ │ ├── 47.gif │ │ │ │ ├── 48.gif │ │ │ │ ├── 49.gif │ │ │ │ ├── 5.gif │ │ │ │ ├── 50.gif │ │ │ │ ├── 51.gif │ │ │ │ ├── 52.gif │ │ │ │ ├── 53.gif │ │ │ │ ├── 54.gif │ │ │ │ ├── 55.gif │ │ │ │ ├── 56.gif │ │ │ │ ├── 57.gif │ │ │ │ ├── 58.gif │ │ │ │ ├── 59.gif │ │ │ │ ├── 6.gif │ │ │ │ ├── 60.gif │ │ │ │ ├── 61.gif │ │ │ │ ├── 62.gif │ │ │ │ ├── 63.gif │ │ │ │ ├── 64.gif │ │ │ │ ├── 65.gif │ │ │ │ ├── 66.gif │ │ │ │ ├── 67.gif │ │ │ │ ├── 68.gif │ │ │ │ ├── 69.gif │ │ │ │ ├── 7.gif │ │ │ │ ├── 70.gif │ │ │ │ ├── 71.gif │ │ │ │ ├── 8.gif │ │ │ │ └── 9.gif │ │ ├── lay │ │ │ ├── all-mobile.js │ │ │ ├── all.js │ │ │ └── modules │ │ │ │ ├── code.js │ │ │ │ ├── element.js │ │ │ │ ├── flow.js │ │ │ │ ├── form.js │ │ │ │ ├── jquery.js │ │ │ │ ├── laydate.js │ │ │ │ ├── layedit.js │ │ │ │ ├── layer.js │ │ │ │ ├── laypage.js │ │ │ │ ├── laytpl.js │ │ │ │ ├── mobile.js │ │ │ │ ├── mobile │ │ │ │ ├── layer-mobile.js │ │ │ │ ├── layim-mobile-open.js │ │ │ │ ├── upload-mobile.js │ │ │ │ └── zepto.js │ │ │ │ ├── tree.js │ │ │ │ ├── upload.js │ │ │ │ └── util.js │ │ └── layui.js │ │ ├── vue │ │ ├── vue.js │ │ ├── vue.min.js │ │ └── vue.router.js │ │ └── webuploader │ │ ├── Uploader.swf │ │ └── webuploader.min.js ├── imagemin │ └── index.js ├── index.js ├── log │ └── index.js └── runServer.js ├── package.json └── readmeFile ├── 0.0.1_test.gif ├── 0.0.2_test.gif ├── 0.0.4_test.gif ├── 0.0.5.test.gif ├── 1.0.0-cli-test.png └── 2017-05-08-i1.png /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode 3 | test 4 | temp 5 | compass 6 | package-lock.json 7 | yarn.lock -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 zoeDylan 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # z_img 2 | 3 | 图片压缩工具【持续更新中】 4 | 5 | # 重要更新 6 | 7 | [2017-11-28](#2017-11-28) 8 | 9 | ### 命令行 10 | 11 | 1. `npm i -g zimg` 12 | 13 | 2. 定位文件夹,然后执行:`zimg` 14 | 15 | > `zimg` 压缩当前文件夹所有图片 16 | 17 | > `zimg *.png *.jpg` 压缩指定图片 18 | 19 | ### 作为压缩网站: 20 | 21 | 1. `npm i -g zimg` 22 | 23 | 2. `zimg -r`或者`zimg -r 3000` 24 | 25 | > 自动打开浏览器窗口 26 | 27 | ### 作为项目调用 28 | 29 | 1. `npm i zimg --save` 30 | 31 | 2. `const zimg = require('zimg');` 32 | 33 | 3. `zimg(输入文件(arr或者string),输出文件夹路径);` 34 | 35 | # 功能说明 36 | 37 | 1. `cli`命令 38 | 39 | ![操作测试](./readmeFile/1.0.0-cli-test.png) 40 |   41 | 2. 网页压缩图片 42 | 43 | ![操作测试](./readmeFile/0.0.5.test.gif) 44 | 45 | 46 | # 流程说明 47 | 48 | * 图片压缩说明: 49 | 50 | 1. 用户每次打开新的页面都会生成一个`session` 51 | 52 | 2. 用户上传第一张图片时,生成`session`对应的文件夹,文件夹位于 `lib/express/compass` 53 | 54 | 3. 同时生成2个文件夹`lib/express/compass/{{文件名}}`(存放源文件)和`lib/express/compass/{{文件名}}/compass`(存放压缩文件) 55 | 56 | 4. 压缩后会返回图片的`base64`字符串,并添加了`data:image/**;base64,`数据头:`lib/express/upload.js => (v.data = 'data:' + contentType + ';base64,' + v.data;)` 57 | 58 | 5. 数据返回用户后,`lib/express/static/index.js => _zip.add(res.name, res.data);`添加压缩文件 59 | 60 | *提示:由于jszip压缩的base64字符串不需要文件头,所以去掉文件头信息 `lib/express/static/index.js => data.replace(/data.+base64,/, '')`* 61 | 62 | # `lib/imagemin` 63 | 64 | 图片压缩核心 65 | 仅对[imagemin](https://www.npmjs.com/package/imagemin)包进行了再次包装。 66 | 67 | **依赖包** 68 | 69 | >> [imagemin](https://www.npmjs.com/package/imagemin) 70 | 71 | **使用方式** 72 | 73 | `cosnt imagemin = require('./lib/imagemin');` 74 | 75 | **API** 76 | 77 | 文件路径问题详情查看:[imagemin](https://www.npmjs.com/package/imagemin) 78 | 79 | ``` 80 | cosnt imagemin = require('./lib/imagemin'); 81 | 82 | //imagemin.compass(input,output); 83 | 84 | // input: 文件目录或者文件地址, './image/*.{jpg,png}' || './image/1.jpg' || ['./image/*.{jpg,png}','./image/1.jpg'] 85 | 86 | // output: 文件输出目录 './image/compass' 默认:'imagemin/temp' 87 | 88 | imagemin.compass('./image/*.{jpg,png}','./image/compass') 89 | .then(v =>{ 90 | if(v.status){ 91 | console.log(v.data); //[{ data: buffer数据, path:图片路径 }] 路径为output所填路径加图片名称 './image/compass/1.jpg' 92 | }else{ 93 | console.log(v.error); //错误消息 94 | } 95 | }); 96 | 97 | ``` 98 | 99 | # 日志(时间倒叙) 100 | 101 | 2019-03-31 102 | 103 | 1. 添加命令行队列处理,解决卡死问题 104 | 105 | 2. 优化命令处理逻辑 106 | 107 | 2018-04-11 108 | 109 | 1. 修改协议为`MIT` 110 | 111 | ### 2017-11-28 112 | 113 | 1. 取消定位到文件夹进行网页压缩功能 114 | 115 | 2. 增加命令行启动网页压缩功能 116 | 117 | 3. 增加外部项目调用压缩功能 118 | 119 | 2017-09-19 120 | 121 | 1. 添加`cli`命令处理 122 | 123 | 2017-09-15 124 | 125 | 1. 新增`GIF`压缩 126 | 127 | 2017-09-14 128 | 129 | 1. 清除多余包 130 | 131 | 2. 取消`co`库,改为`async await` 132 | 133 | 2017-09-07 134 | 135 | 1. 添加上传成功、失败提示 136 | 137 | 2. 优化上传失败展示文案 138 | 139 | 3. 修复图片上传报错问题 140 | 141 | #### 2017-05-08 142 | 143 | 1. 添加数据展示信息 144 | 145 | *![数据展示信息](./readmeFile/2017-05-08-i1.png)* 146 | 147 | 2. 优化用户文件夹创建时间,之前是在用户访问页面时创建文件夹,现在修改为用户上传第一张图片的时候创建,避免用户一直刷新。 148 | 149 | 3. 用户已打开页面,但是服务器重启过,导致用户`session`失效,bug修复。 150 | 151 | 4. 添加图片预览,添加图片后点击列表中的图片可以在独立标签打开页面预览图片。 152 | 153 | 5. 图片限制`30M`,并发修改为`1` -------------------------------------------------------------------------------- /bin/command.js: -------------------------------------------------------------------------------- 1 | const 2 | runCommand = (() => { 3 | function version() { 4 | console.log('\nversion', require('../package.json').version, '\n'); 5 | } 6 | 7 | function help() { 8 | 9 | console.log(` 10 | command: 11 | -c ---compress file 12 | default = '-c' , You don't need this parameter '-c' 13 | 'zimg': Compress the current folder img files 14 | 'zimg [img file]': Compress the img file 15 | 'zimg [file] [file]': Compress the two files 16 | 'zimg [file] [file] ...': Compress more specified files 17 | -v ---show version 18 | -h ---show help 19 | -r ---run server 20 | 'zimg -r': run server at port : 3000 21 | 'zimg -r [port]' run server at port : set port 22 | `); 23 | 24 | } 25 | 26 | function run(port) { 27 | require('../lib/runServer')(port); 28 | } 29 | return { 30 | 'v': version, 31 | 'h': help, 32 | 'r': run 33 | } 34 | 35 | })(); 36 | 37 | 38 | 39 | //如果是命令处理就运行命令 40 | function isCommand(arr) { 41 | let 42 | com = arr.toString().split('-'); 43 | com[0].length === 0 && com.shift(); 44 | com = com[0]; 45 | if (/^v/.test(com)) { 46 | runCommand.v(); 47 | } else if (/^h|^\?/.test(com)) { 48 | runCommand.h(); 49 | } else if (/^r/.test(com)) { 50 | runCommand.r(com.split(',')[1] || 3000); 51 | } else if (/^c/.test(com)) { 52 | return com.replace('c,', '').replace(/^c/, ''); 53 | } else { 54 | return com.split(','); 55 | } 56 | } 57 | 58 | 59 | 60 | module.exports = { 61 | isCommand: isCommand 62 | }; -------------------------------------------------------------------------------- /bin/compress.js: -------------------------------------------------------------------------------- 1 | const 2 | fs = require('fs'), 3 | glob = require('glob'), 4 | dir = process.cwd(), 5 | imagemin = require('../lib/imagemin'); 6 | 7 | 8 | const queueList = []; 9 | let maxQueueRun = 3; 10 | let nowQueueRun = 0; 11 | 12 | function runQueue(fn) { 13 | fn && queueList.push(fn); 14 | if (nowQueueRun < maxQueueRun && queueList.length > 0) { 15 | nowQueueRun += 1; 16 | queueList[0]().then(() => { 17 | nowQueueRun -= 1; 18 | runQueue(); 19 | }); 20 | queueList.shift(); 21 | runQueue(); 22 | } 23 | } 24 | 25 | 26 | 27 | module.exports = (files) => { 28 | files = files || glob.sync(dir + '/*.?(jpg|png|jpeg|gif)'); 29 | function cInfo() { 30 | let 31 | numRatio = (files.length - succNum - errNum) / files.length, 32 | txt = ` 33 | ┏┓ 34 | ┃ 35 | ┣ ${getChar('■', 20 - Math.floor(numRatio * 20))}${getChar('□', Math.floor(numRatio * 20))}(${(100 - numRatio * 100).toFixed(2)}%)' 36 | ┃ 37 | ┣ 完成:${succNum + errNum} 38 | ┃ 39 | ┣ 剩余:${files.length - (succNum + errNum)} 40 | ┃ 41 | ┣ 错误:${errNum} 42 | ┃ 43 | ┣ 共计:${files.length} 44 | ┃ 45 | ┣ 总大小:${(allSourceSize / 1024).toFixed(2)}KB 46 | ┃ 47 | ┣ 压缩后大小:${(allSize / 1024).toFixed(2)}KB 48 | ┃ 49 | ┣ 压缩率:${((allSourceSize - allSize) / allSourceSize * 100).toFixed(3)}% 50 | ┃ 51 | ┗┛`; 52 | console.clear(); 53 | console.log(txt); 54 | } 55 | 56 | function getChar(txt, num) { 57 | let val = ''; 58 | for (let i = 0; i < num; i++) { 59 | val += txt; 60 | } 61 | return val; 62 | } 63 | let 64 | //完成数量 65 | succNum = 0, 66 | //出错数量 67 | errNum = 0, 68 | //总大小 69 | allSourceSize = 0, 70 | //总处理后大小 71 | allSize = 0; 72 | 73 | files.forEach(path => { 74 | runQueue(() => { 75 | return imagemin.compass(path, dir + '/zimg') 76 | .then(d => { 77 | const 78 | source = fs.statSync(path); 79 | succNum++; 80 | allSourceSize += source.size; 81 | allSize += d.data[0].data.length; 82 | cInfo(); 83 | }) 84 | .catch(() => { 85 | errNum++; 86 | cInfo(); 87 | }).then(() => { 88 | return true; 89 | }) 90 | }); 91 | }); 92 | } -------------------------------------------------------------------------------- /bin/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | process.title = 'zimg' 4 | 5 | const 6 | com = require('./command'), 7 | cmp = require('./compress'); 8 | 9 | let argv = process.argv; 10 | 11 | //删除前两个用不到的变量 12 | argv.splice(0, 2); 13 | if (argv.length <= 0) { 14 | cmp(); 15 | } else { 16 | let files = com.isCommand(argv); 17 | if (files) { 18 | cmp(files); 19 | } else if (files === '') { 20 | cmp(); 21 | } 22 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib'); -------------------------------------------------------------------------------- /lib/express/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/favicon.ico -------------------------------------------------------------------------------- /lib/express/index.js: -------------------------------------------------------------------------------- 1 | const 2 | express = require('express'), 3 | app = express(), 4 | session = require('express-session'), 5 | md5 = require('md5'), 6 | fs = require('fs'); 7 | 8 | //compass文件夹检查 9 | if (!fs.existsSync(__dirname + '/compass')) { 10 | fs.mkdirSync(__dirname + '/compass'); 11 | } 12 | 13 | app.use(session({ 14 | resave: false, 15 | saveUninitialized: true, 16 | secret: 'z-img', 17 | cookie: { 18 | maxAge: 1000 * 60 * 60 * 2 19 | } 20 | })) 21 | 22 | app.use("/static", express.static(__dirname + "/views/static")); 23 | 24 | app.get('/', (req, res) => { 25 | //添加文件夹名称-每次打开页面生成一个新的文件夹 26 | req.session.dir = md5(new Date().getTime()); 27 | 28 | res.sendFile(__dirname + "/views/index.html"); 29 | }); 30 | 31 | app.all('/favicon.ico', function(req, res) { 32 | res.sendFile(__dirname + '/favicon.ico'); 33 | }); 34 | 35 | app.use('/upload', require('./upload')); 36 | 37 | module.exports = app; -------------------------------------------------------------------------------- /lib/express/upload/index.js: -------------------------------------------------------------------------------- 1 | const 2 | express = require('express'), 3 | app = express(), 4 | multiparty = require('multiparty'), 5 | imagemin = require('../../imagemin'), 6 | fs = require('fs'), 7 | path = require('path'), 8 | log = require('../../log'); 9 | 10 | /** 11 | * 文件上传 12 | * @return { 13 | * status: true|false 14 | * [false => error: string] 15 | * [true => data: Object] 16 | * message: string 17 | * } 18 | */ 19 | app.post('/', (req, res) => { 20 | if (req.session.dir) { 21 | 22 | let 23 | //当前用户文件夹 24 | fileDir = path.join(__dirname, '..', 'compass', req.session.dir), 25 | form = new multiparty.Form({ uploadDir: fileDir }); 26 | 27 | //创建文件夹 28 | if (!fs.existsSync(fileDir)) { 29 | fs.mkdirSync(fileDir); 30 | fs.mkdirSync(fileDir + '/compass'); 31 | } 32 | 33 | form.parse(req, (err, fields, files) => { 34 | if (err) { 35 | res.send({ 36 | status: false, 37 | error: err.toString(), 38 | message: '文件上传失败!' 39 | }); 40 | } else { 41 | //文件信息处理 42 | let 43 | //上传的文件 44 | inputFile = files.file[0], 45 | //上传文件的路径 46 | uploadedPath = inputFile.path, 47 | //压缩文件夹路径 48 | compassDir = fileDir + '/compass', 49 | //重命名文件 originalFilename为文件名称 50 | newPath = fileDir + '/' + inputFile.originalFilename, 51 | //文件头:image/*** 52 | contentType = inputFile.headers['content-type'], 53 | //重命名 54 | newFile = rename(uploadedPath, newPath); 55 | 56 | //判断重命名状态 57 | if (newFile.status) { 58 | //压缩 59 | compass(newPath, compassDir) 60 | .then(v => { 61 | v.name = inputFile.originalFilename; 62 | //添加文件头 63 | v.data = 'data:' + contentType + ';base64,' + v.data; 64 | res.send(v); 65 | }) 66 | .catch(e => { 67 | console.log(e); 68 | res.send({ 69 | status: false, 70 | error: e.toString(), 71 | message: '压缩接口断开' 72 | }); 73 | }); 74 | } else { 75 | res.send(newFile); 76 | } 77 | } 78 | }); 79 | } else { 80 | res.send({ 81 | status: false, 82 | error: 'server 500 error', 83 | message: '服务器主动取消,请刷新页面重试。' 84 | }); 85 | } 86 | }); 87 | 88 | 89 | /** 90 | * 压缩 91 | * @param {*string||array} input 文件路径 92 | * @param {*string} output 压缩后文件路径 93 | * @return { 94 | * status: true|false 95 | * (true => size: number)文件压缩后的大小 96 | * (true => data: 文件的base64字符串,未添加文件信息头) 97 | * (false => (imagemin.compass)) lib/imagemin包里面的返回 98 | * } 99 | */ 100 | async function compass(input, output) { 101 | return await imagemin.compass(input, output) 102 | .then(v => { 103 | if (v.status) { 104 | //这里面每次压缩都是一个文件 所以直接 v.data[0] 105 | let file = v.data[0]; 106 | 107 | return { 108 | status: true, 109 | size: file.data.length, 110 | data: file.data.toString('base64') 111 | } 112 | } else { 113 | return { 114 | status: false, 115 | message: '文件压缩出错,日志:' + log(v.error) 116 | }; 117 | } 118 | }) 119 | } 120 | 121 | /** 122 | * 文件重命名 123 | * @param {string} oldPath 旧目录 124 | * @param {string} newPath 新目录 125 | * 126 | * @return { 127 | * status: true|false, 128 | * [false => error: string] 129 | * [true => data: (newPath)] 130 | * message: string 131 | * } 132 | */ 133 | function rename(oldPath, newPath) { 134 | let file = fs.renameSync(oldPath, newPath); 135 | return file ? { 136 | status: false, 137 | error: file.toString(), 138 | message: '文件重命名失败' 139 | } : { 140 | status: true, 141 | data: newPath, 142 | message: '文件重命名成功' 143 | }; 144 | } 145 | 146 | 147 | 148 | module.exports = app; -------------------------------------------------------------------------------- /lib/express/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | z-img 17 | 18 | 19 | 20 | 21 | 22 |
23 |
24 | 点击加号或将图片拖入此处 25 |
26 | 27 |
28 |
29 |
30 |

31 | 已添加【{{add}}】 32 | 上传中【{{upload}}】 33 | 完成【{{success}}】 34 | 失败【{{error}}】 35 | 处理结束【{{end}}】 36 |

37 |
38 |
39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 61 | 66 | 73 | 74 | 75 | 76 |
图片进度本地大小处理大小计算消息
57 |
58 | 59 |
60 |
{{item.name}}
62 |
63 |
64 |
65 |
67 | {{( item.size/ 1024 / 1024).toFixed(3) + 'M'}} 68 | {{( item.serverSize/ 1024 / 1024).toFixed(3) + 'M'}} 69 |
压缩:{{ (((item.size-item.serverSize)/item.size)*100).toFixed(1) + '%'}}
70 |
增加:{{ (((item.serverSize-item.size)/item.serverSize)*100).toFixed(1)+ '%'}}
71 |
无变化
72 |
{{item.message}}
77 |
78 | 79 |
80 | 83 |
84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /lib/express/views/static/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 60px 10px; 3 | padding-top: 120px; 4 | } 5 | 6 | #__uploader { 7 | position: fixed; 8 | width: 100%; 9 | left: 0; 10 | top: 0; 11 | padding: 10px 10px 20px; 12 | background: #fff; 13 | z-index: 1; 14 | } 15 | 16 | #__uploader fieldset { 17 | width: 97%; 18 | } 19 | #__uploader legend i{ 20 | font-size: 30px; 21 | line-height: 30px; 22 | vertical-align: middle; 23 | } 24 | 25 | #__uploader div { 26 | position: relative; 27 | } 28 | 29 | #__uploader div.pick { 30 | position: absolute; 31 | left: 0; 32 | top: 0; 33 | width: 100%; 34 | height: 100%; 35 | opacity: 0; 36 | } 37 | 38 | #__uploader div.pick div { 39 | height: 100%; 40 | } 41 | 42 | #__uploader p.msg { 43 | position: absolute; 44 | bottom: 10px; 45 | left: 10px; 46 | width: 95%; 47 | text-align: right; 48 | } 49 | 50 | #__imgList tbody img { 51 | width: 40px; 52 | height: auto; 53 | transition: all .3s; 54 | } 55 | 56 | #__imgList tbody .img { 57 | height: 40px; 58 | overflow: hidden; 59 | } 60 | 61 | #__imgList tbody tr.success td{ 62 | background-color: #dff0d8; 63 | } 64 | #__imgList tbody tr.danger td{ 65 | background-color: #f2dede; 66 | } 67 | 68 | #__btnGroup { 69 | position: fixed; 70 | z-index: 1; 71 | width: 100%; 72 | height: 40px; 73 | background: #2F4056; 74 | left: 0; 75 | bottom: 0; 76 | text-align: right; 77 | color: #fff; 78 | } -------------------------------------------------------------------------------- /lib/express/views/static/jszip/.codeclimate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | engines: 3 | duplication: 4 | enabled: true 5 | config: 6 | languages: 7 | - javascript 8 | eslint: 9 | enabled: true 10 | fixme: 11 | enabled: true 12 | ratings: 13 | paths: 14 | - "lib/*.js" 15 | exclude_paths: 16 | - "dist/*" 17 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 4 9 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | sauce_connect.log 4 | .c9revisions -------------------------------------------------------------------------------- /lib/express/views/static/jszip/.jshintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "nonew": true, 5 | "noarg": true, 6 | "forin": true, 7 | "futurehostile": true, 8 | "freeze": true, 9 | "undef": true, 10 | "strict": true, 11 | "sub": true, 12 | "esversion": 3, 13 | 14 | "globals": { 15 | "TextEncoder": false, 16 | "TextDecoder": false 17 | }, 18 | "browser": true, 19 | "node": true 20 | } 21 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/.npmignore: -------------------------------------------------------------------------------- 1 | _config.yml 2 | bower.json 3 | component.json 4 | docs 5 | documentation 6 | Gruntfile.js 7 | index.html 8 | test 9 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | matrix: 4 | include: 5 | - node_js: "stable" 6 | env: COMMAND=lint 7 | - node_js: "0.10" 8 | env: COMMAND=test-node 9 | - node_js: "0.12" 10 | env: COMMAND=test-node 11 | - node_js: "4.4" 12 | env: COMMAND=test-node 13 | - node_js: "stable" 14 | env: COMMAND=test-node 15 | - node_js: "stable" 16 | env: COMMAND=test-browser 17 | env: 18 | global: 19 | - secure: MhA8GHU42X3GWTUMaqdZVvarx4BMjhQCUGNi3kvuD/iCmKVb7gMwj4jbds7AcJdsCRsRk8bBGzZs/E7HidBJMPDa5DhgLKy9EV1s42JlHq8lVzbJeWIGgrtyJvhVUkGRy2OJjnDSgh3U6elkQmvDn74jreSQc6m/yGoPFF1nqq8= 20 | - secure: qREw6aUu2DnB+2reMuHgygSkumRiJvt7Z5Fz4uEVoraqbe65e4PGhtzypr9uIgCN43vxS2D5tAIeDbfid5VQrWFUQnrC9O5Z5qgVPsKN94zZ1tvYurXI4wRlAg58nNjkfGXWhLI3VUjjDTp5gYcMqgfe5hpEFYUPnUQkKGnaqAk= 21 | script: npm run $COMMAND 22 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/README.markdown: -------------------------------------------------------------------------------- 1 | JSZip [![Build Status](https://api.travis-ci.org/Stuk/jszip.svg?branch=master)](http://travis-ci.org/Stuk/jszip) [![Code Climate](https://codeclimate.com/github/Stuk/jszip/badges/gpa.svg)](https://codeclimate.com/github/Stuk/jszip) 2 | ===== 3 | 4 | [![Selenium Test Status](https://saucelabs.com/browser-matrix/jszip.svg)](https://saucelabs.com/u/jszip) 5 | 6 | A library for creating, reading and editing .zip files with Javascript, with a 7 | lovely and simple API. 8 | 9 | See https://stuk.github.io/jszip for all the documentation. 10 | 11 | ```javascript 12 | var zip = new JSZip(); 13 | 14 | zip.file("Hello.txt", "Hello World\n"); 15 | 16 | var img = zip.folder("images"); 17 | img.file("smile.gif", imgData, {base64: true}); 18 | 19 | zip.generateAsync({type:"blob"}).then(function(content) { 20 | // see FileSaver.js 21 | saveAs(content, "example.zip"); 22 | }); 23 | 24 | /* 25 | Results in a zip containing 26 | Hello.txt 27 | images/ 28 | smile.gif 29 | */ 30 | ``` 31 | License 32 | ------- 33 | 34 | JSZip is dual-licensed. You may use it under the MIT license *or* the GPLv3 35 | license. See [LICENSE.markdown](LICENSE.markdown). 36 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/_config.yml: -------------------------------------------------------------------------------- 1 | # will be overwritten by github, see https://help.github.com/articles/using-jekyll-with-pages 2 | lsi: false 3 | safe: true 4 | source: ./ 5 | incremental: false 6 | highlighter: rouge 7 | gist: 8 | noscript: false 9 | # /overwritten 10 | 11 | baseurl: /jszip 12 | 13 | layouts_dir: ./documentation/_layouts 14 | permalink: none 15 | exclude: ['bin', 'README.md', 'node_modules'] 16 | 17 | 18 | kramdown: 19 | input: GFM 20 | hard_wrap: false 21 | gems: 22 | - jekyll-coffeescript 23 | - jekyll-paginate 24 | 25 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jszip", 3 | "homepage": "http://stuartk.com/jszip", 4 | "authors": [ 5 | "Stuart Knightley " 6 | ], 7 | "description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip", 8 | "main": "dist/jszip.js", 9 | "keywords": [ 10 | "zip", 11 | "deflate", 12 | "inflate" 13 | ], 14 | "license": "MIT or GPLv3", 15 | "ignore": [ 16 | "**/.*", 17 | "node_modules", 18 | "bower_components", 19 | "test", 20 | "tests" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jszip", 3 | "repo": "Stuk/jszip", 4 | "description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip", 5 | "version": "3.1.3", 6 | "keywords": [ 7 | "zip", 8 | "deflate", 9 | "inflate" 10 | ], 11 | "main": "dist/jszip.js", 12 | "license": "MIT or GPLv3", 13 | "scripts": [ 14 | "dist/jszip.js" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/docs/ZIP spec.txt: -------------------------------------------------------------------------------- 1 | Here are the notes I made while working through the ZIP file specification. 2 | 3 | For each file: 4 | 5 | local file header signature 4 bytes (0x04034b50) 6 | version needed to extract 2 bytes 7 | general purpose bit flag 2 bytes 8 | compression method 2 bytes 9 | last mod file time 2 bytes 10 | last mod file date 2 bytes 11 | crc-32 4 bytes 12 | compressed size 4 bytes 13 | uncompressed size 4 bytes 14 | file name length 2 bytes 15 | extra field length 2 bytes 16 | 17 | |sig |v |g |c |t |d |crc |csz |usz |n |x | 18 | PK.. ## 00 00 ?? ?? xxxx ???? ???? ?? 00 19 | 20 | 21 | Central directory: 22 | 23 | central file header signature 4 bytes (0x02014b50) 24 | version made by 2 bytes 25 | version needed to extract 2 bytes * 26 | general purpose bit flag 2 bytes * 27 | compression method 2 bytes * 28 | last mod file time 2 bytes * 29 | last mod file date 2 bytes * 30 | crc-32 4 bytes * 31 | compressed size 4 bytes * 32 | uncompressed size 4 bytes * 33 | file name length 2 bytes * 34 | extra field length 2 bytes * 35 | file comment length 2 bytes 36 | disk number start 2 bytes 37 | internal file attributes 2 bytes 38 | external file attributes 4 bytes 39 | relative offset of local header 4 bytes 40 | 41 | file name (variable size) 42 | extra field (variable size) 43 | file comment (variable size) 44 | 45 | |sig |vm|vx|g |c |d |t |crc |csz |usz |n |x |cm|dn|ia|xa |roff| 46 | PK.. ## ## 00 00 ?? ?? xxxx ???? ???? ?? 00 00 00 00 xxxx ???? 47 | 48 | End of central directory: 49 | 50 | end of central dir signature 4 bytes (0x06054b50) 51 | number of this disk 2 bytes 52 | number of the disk with the 53 | start of the central directory 2 bytes 54 | total number of entries in the 55 | central directory on this disk 2 bytes 56 | total number of entries in 57 | the central directory 2 bytes 58 | size of the central directory 4 bytes 59 | offset of start of central 60 | directory with respect to 61 | the starting disk number 4 bytes 62 | .ZIP file comment length 2 bytes 63 | .ZIP file comment (variable size) 64 | 65 | |sig |n1|n2|e |ne|size|off |cm| 66 | PK.. 00 00 ?? ?? ???? ???? 00 67 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/docs/references.txt: -------------------------------------------------------------------------------- 1 | Zip format 2 | ---------- 3 | http://www.pkware.com/support/zip-application-note 4 | http://www.xxcopy.com/xxcopy06.htm 5 | 6 | Data URL 7 | -------- 8 | https://developer.mozilla.org/en/The_data_URL_scheme 9 | http://msdn.microsoft.com/en-us/library/cc848897(VS.85).aspx 10 | http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/ 11 | 12 | http://www.motobit.com/util/base64-decoder-encoder.asp 13 | 14 | Saving files 15 | ------------ 16 | http://msdn.microsoft.com/en-us/library/ms536676(VS.85).aspx 17 | http://msdn.microsoft.com/en-us/library/ms536419(VS.85).aspx 18 | http://msdn.microsoft.com/en-us/library/ms537418(VS.85).aspx 19 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "JSZip API" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | An instance of JSZip represents a set of files. You can add them, remove them, 8 | modify them. You can also import an existing zip file or generate one. 9 | 10 | ### Attributes 11 | 12 | attribute name | type | description 13 | ---------------------|-------------|------------- 14 | `files` | object | the [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html)s inside the zip with the name as key. See [file(name)]({{site.baseurl}}/documentation/api_jszip/file_name.html). 15 | `comment` | string | the comment of the zip file. 16 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/constructor.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "new JSZip() or JSZip()" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Create a new JSZip instance. 8 | 9 | __Arguments__ : None 10 | 11 | __Returns__ : A new JSZip. 12 | 13 | __Throws__ : Nothing. 14 | 15 | 16 | 17 | __Example__ 18 | 19 | ```js 20 | var zip = new JSZip(); 21 | // same as 22 | var zip = JSZip(); 23 | ``` 24 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/external.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "JSZip.external" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | JSZip uses objects that may not exist on every platform, in which case it uses 8 | a shim. 9 | Accessing or replacing these objects can sometimes be useful. JSZip.external 10 | contains the following properties : 11 | 12 | * `Promise` : the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) implementation used. 13 | 14 | The global object is prefered when available. 15 | 16 | __Example__ 17 | 18 | ```js 19 | // use bluebird instead 20 | JSZip.external.Promise = Bluebird; 21 | 22 | // use the native Promise object: 23 | JSZip.external.Promise = Promise; 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/file_data.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "file(name, data [,options])" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Add (or update) a file to the zip file. 8 | 9 | __Arguments__ 10 | 11 | name | type | description 12 | --------------------|---------|------------ 13 | name | string | the name of the file. You can specify folders in the name : the folder separator is a forward slash ("/"). 14 | data | String/ArrayBuffer/Uint8Array/Buffer/Blob/Promise/Nodejs stream | the content of the file. 15 | options | object | the options. 16 | 17 | Content of `options` : 18 | 19 | name | type | default | description 20 | ------------|---------|---------|------------ 21 | base64 | boolean | `false` | set to `true` if the data is base64 encoded. For example image data from a `` element. Plain text and HTML do not need this option. 22 | binary | boolean | `false` | set to `true` if the data should be treated as raw content, `false` if this is a text. If base64 is used, this defaults to `true`, if the data is not a string, this will be set to `true`. 23 | date | date | the current date | the last modification date. 24 | compression | string | null | If set, specifies compression method to use for this specific file. If not, the default file compression will be used, see [generateAsync(options)]({{site.baseurl}}/documentation/api_jszip/generate_async.html). 25 | compressionOptions | object | `null` | the options to use when compressing the file, see [generate(options)]({{site.baseurl}}/documentation/api_jszip/generate_async.html). 26 | comment | string | null | The comment for this file. 27 | optimizedBinaryString | boolean | `false` | Set to true if (and only if) the input is a "binary string" and has already been prepared with a 0xFF mask. 28 | createFolders | boolean | `true` | Set to true if folders in the file path should be automatically created, otherwise there will only be virtual folders that represent the path to the file. 29 | unixPermissions | 16 bits number | null | The UNIX permissions of the file, if any. 30 | dosPermissions | 6 bits number | null | The DOS permissions of the file, if any. 31 | dir | boolean | false | Set to true if this is a directory and content should be ignored. 32 | 33 | You shouldn't update the data given to this method : it is kept as it so any 34 | update will impact the stored data. 35 | 36 | 37 | __For the permissions__ : 38 | 39 | The field `unixPermissions` also accepts a string representing the octal value : 40 | "644", "755", etc. On nodejs you can use the `mode` attribute of 41 | [nodejs' fs.Stats](http://nodejs.org/api/fs.html#fs_class_fs_stats). 42 | 43 | See also [the platform option of generateAsync()]({{site.baseurl}}/documentation/api_jszip/generate_async.html). 44 | 45 | 46 | __About `dir`__ : 47 | 48 | If `dir` is true or if a permission says it's a folder, this entry be flagged 49 | as a folder and the content will be ignored. 50 | 51 | __About nodejs stream__: 52 | 53 | A stream can't be restarted: if it is used once, it can't be used again ( 54 | by [generateAsync()]({{site.baseurl}}/documentation/api_jszip/generate_async.html) 55 | or by [ZipObject methods]({{site.baseurl}}/documentation/api_zipobject.html)). 56 | In that case, the promise/stream (depending on the method called) will get 57 | an error. 58 | 59 | __Returns__ : The current JSZip object, for chaining. 60 | 61 | __Throws__ : Nothing. (an exception will be propagated if the data is not in 62 | a supported format). 63 | 64 | 70 | 71 | __Example__ 72 | 73 | ```js 74 | zip.file("Hello.txt", "Hello World\n"); 75 | 76 | // base64 77 | zip.file("smile.gif", "R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=", {base64: true}); 78 | // from an ajax call with xhr.responseType = 'arraybuffer' 79 | zip.file("smile.gif", arraybufferFromXhr); 80 | // or on nodejs 81 | zip.file("smile.gif", fs.readFileSync("smile.gif")); 82 | 83 | zip.file("Xmas.txt", "Ho ho ho !", {date : new Date("December 25, 2007 00:00:01")}); 84 | zip.file("folder/file.txt", "file in folder"); 85 | 86 | zip.file("animals.txt", "dog,platypus\n").file("people.txt", "james,sebastian\n"); 87 | 88 | // result : Hello.txt, smile.gif, Xmas.txt, animals.txt, people.txt, 89 | // folder/, folder/file.txt 90 | // In the above case, the "folder" folder will not have a 'D'irectory attribute or Method property. The 91 | // folder only exists as part of the path to "file.txt". 92 | 93 | zip.file("folder/file.txt", "file in folder", {createFolders: true}); 94 | // In this case, the "folder" folder WILL have a 'D'irectory attribute and a Method property of "store". 95 | // It will exist whether or not "file.txt" is present. 96 | 97 | zip.file("script.sh", "echo 'hello world'", { 98 | unixPermissions : "755" 99 | }); 100 | // when generated with platform:UNIX, the script.sh file will be executable 101 | ``` 102 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/file_name.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "file(name)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Get a file with the specified name. You can specify folders 8 | in the name : the folder separator is a forward slash ("/"). 9 | 10 | __Arguments__ 11 | 12 | name | type | description 13 | -----|--------|------------- 14 | name | string | the name of the file. 15 | 16 | __Returns__ : An instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html) representing 17 | the file if any, `null` otherwise. 18 | 19 | __Throws__ : Nothing. 20 | 21 | 22 | 23 | __Examples__ 24 | 25 | ```js 26 | var zip = new JSZip(); 27 | zip.file("file.txt", "content"); 28 | 29 | zip.file("file.txt").name // "file.txt" 30 | zip.file("file.txt").async("string") // a promise of "content" 31 | zip.file("file.txt").options.dir // false 32 | 33 | // utf8 example 34 | var zip = new JSZip(); 35 | zip.file("amount.txt", "€15"); 36 | zip.file("amount.txt").async("string") // a promise of "€15" 37 | zip.file("amount.txt").async("arraybuffer") // a promise of an ArrayBuffer containing €15 encoded as utf8 38 | zip.file("amount.txt").async("uint8array") // a promise of an Uint8Array containing €15 encoded as utf8 39 | 40 | // with folders 41 | zip.folder("sub").file("file.txt", "content"); 42 | zip.file("sub/file.txt"); // the file 43 | // or 44 | zip.folder("sub").file("file.txt") // the file 45 | ``` 46 | 47 | 48 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/file_regex.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "file(regex)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Search a file in the current folder and subfolders with a 8 | [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions). 9 | The regex is tested against the relative filename. 10 | 11 | __Arguments__ 12 | 13 | name | type | description 14 | ------|--------|------------ 15 | regex | RegExp | the regex to use. 16 | 17 | __Returns__ : An array of matching files (an empty array if none matched). Each 18 | maching file is an instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html). 19 | 20 | __Throws__ : Nothing. 21 | 22 | 26 | 27 | __Example__ 28 | 29 | ```js 30 | var zip = new JSZip(); 31 | zip.file("file1.txt", "content"); 32 | zip.file("file2.txt", "content"); 33 | 34 | zip.file(/file/); // array of size 2 35 | 36 | // example with a relative path : 37 | var folder = zip.folder("sub"); 38 | folder 39 | .file("file3.txt", "content") // relative path from folder : file3.txt 40 | .file("file4.txt", "content"); // relative path from folder : file4.txt 41 | 42 | folder.file(/file/); // array of size 2 43 | folder.file(/^file/); // array of size 2, the relative paths start with file 44 | 45 | // arrays contain objects in the form: 46 | // {name: "file2.txt", dir: false, async : function () {...}, ...} 47 | ``` 48 | 49 | 50 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/filter.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "filter(predicate)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Filter nested files/folders with the specified function. 8 | 9 | __Arguments__ 10 | 11 | name | type | description 12 | ----------|----------|------------ 13 | predicate | function | the predicate to use. 14 | 15 | The predicate has the following signature : `function (relativePath, file) {...}` : 16 | 17 | name | type | description 18 | -------------|-----------|------------ 19 | relativePath | string | the filename and its path, reliatively to the current folder. 20 | file | ZipObject | the file being tested. See [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html). 21 | 22 | The predicate must return true if the file should be included, false otherwise. 23 | 24 | 25 | __Returns__ : An array of matching ZipObject. 26 | 27 | __Throws__ : Nothing. 28 | 29 | 30 | 31 | __Example__ 32 | 33 | ```js 34 | var zip = new JSZip().folder("dir"); 35 | zip.file("readme.txt", "content"); 36 | zip.filter(function (relativePath, file){ 37 | // relativePath == "readme.txt" 38 | // file = {name:"dir/readme.txt",options:{...},async:function} 39 | return true/false; 40 | }); 41 | ``` 42 | 43 | 44 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/folder_data.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "folder(name)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Create a directory if it doesn't exist, return a new JSZip 8 | object with the new folder as root. 9 | 10 | See also [the `dir` option of file()]({{site.baseurl}}/documentation/api_jszip/file_data.html). 11 | 12 | __Arguments__ 13 | 14 | name | type | description 15 | -----|--------|------------ 16 | name | string | the name of the directory. 17 | 18 | __Returns__ : A new JSZip (for chaining), with the new folder as root. 19 | 20 | __Throws__ : Nothing. 21 | 22 | 23 | 24 | __Example__ 25 | 26 | ```js 27 | zip.folder("images"); 28 | zip.folder("css").file("style.css", "body {background: #FF0000}"); 29 | // or specify an absolute path (using forward slashes) 30 | zip.file("css/font.css", "body {font-family: sans-serif}") 31 | 32 | // result : images/, css/, css/style.css, css/font.css 33 | ``` 34 | 35 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/folder_regex.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "folder(regex)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Search a subdirectory in the current directory with a 8 | [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions). 9 | The regex is tested against the relative path. 10 | 11 | __Arguments__ 12 | 13 | name | type | description 14 | ------|--------|------------ 15 | regex | RegExp | the regex to use. 16 | 17 | __Returns__ : An array of matching folders (an empty array if none matched). 18 | Each maching folder is an instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html). 19 | 20 | __Throws__ : Nothing. 21 | 22 | 26 | 27 | __Example__ 28 | 29 | ```js 30 | var zip = new JSZip(); 31 | zip.folder("home/Pierre/videos"); 32 | zip.folder("home/Pierre/photos"); 33 | zip.folder("home/Jean/videos"); 34 | zip.folder("home/Jean/photos"); 35 | 36 | zip.folder(/videos/); // array of size 2 37 | 38 | zip.folder("home/Jean").folder(/^vid/); // array of 1 39 | ``` 40 | 41 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/for_each.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "forEach(callback)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Call a callback function for each entry at this folder level. 8 | 9 | __Arguments__ 10 | 11 | name | type | description 12 | ----------|----------|------------ 13 | callback | function | the callback to use. 14 | 15 | The callback has the following signature : `function (relativePath, file) {...}` : 16 | 17 | name | type | description 18 | -------------|-----------|------------ 19 | relativePath | string | the filename and its path, reliatively to the current folder. 20 | file | ZipObject | the current file. See [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html). 21 | 22 | 23 | __Returns__ : Nothing. 24 | 25 | __Throws__ : Nothing. 26 | 27 | 28 | 29 | __Example__ 30 | 31 | ```js 32 | var zip = new JSZip(); 33 | zip.file("package.json", "..."); 34 | zip.file("lib/index.js", "..."); 35 | zip.file("test/index.html", "..."); 36 | zip.file("test/asserts/file.js", "..."); 37 | zip.file("test/asserts/generate.js", "..."); 38 | 39 | zip.folder("test").forEach(function (relativePath, file){ 40 | console.log("iterating over", relativePath); 41 | }); 42 | 43 | // will display: 44 | // iterating over index.html 45 | // iterating over asserts/ 46 | // iterating over asserts/file.js 47 | // iterating over asserts/generate.js 48 | ``` 49 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/generate_internal_stream.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "generateInternalStream(options)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Generates the complete zip file with the internal stream 8 | implementation. 9 | 10 | __Arguments__ 11 | 12 | name | type | default | description 13 | --------------------|----------|---------|------------ 14 | options | object | | the options to generate the zip file, see [the options of `generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html) 15 | 16 | __Metadata__ : see [the metadata of `generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html). 17 | 18 | __Returns__ : a [StreamHelper]({{site.baseurl}}/documentation/api_streamhelper.html). 19 | 20 | __Throws__ : Nothing. 21 | 22 | __Example__ 23 | 24 | ```js 25 | zip.generateInternalStream({type:"blob"}).accumulate(function callback(err, content) { 26 | if (err) { 27 | // handle error 28 | } 29 | // see FileSaver.js 30 | saveAs(content, "hello.zip"); 31 | }, function updateCallback(metadata) { 32 | // print progression with metadata.percent and metadata.currentFile 33 | }); 34 | ``` 35 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/generate_node_stream.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "generateNodeStream(options[, onUpdate])" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Generates the complete zip file as a nodejs stream. 8 | 9 | __Arguments__ 10 | 11 | name | type | default | description 12 | --------------------|----------|---------|------------ 13 | options | object | | the options to generate the zip file, see [the options of `generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html) 14 | onUpdate | function | | The optional function called on each internal update with the metadata. 15 | 16 | The `type` parameter has here the default value of `nodebuffer`. 17 | Only `nodebuffer` is currently supported. 18 | 19 | __Metadata__ : see [the metadata of `generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html). 20 | 21 | __Returns__ : a [nodejs Streams3](https://github.com/nodejs/readable-stream). 22 | 23 | __Throws__ : Nothing. 24 | 25 | __Example__ 26 | 27 | ```js 28 | zip 29 | .generateNodeStream({streamFiles:true}) 30 | .pipe(fs.createWriteStream('out.zip')) 31 | .on('finish', function () { 32 | // JSZip generates a readable stream with a "end" event, 33 | // but is piped here in a writable stream which emits a "finish" event. 34 | console.log("out.zip written."); 35 | }); 36 | ``` 37 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/load_async.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "loadAsync(data [, options])" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Read an existing zip and merge the data in the current JSZip 8 | object at the current folder level. This technique has some limitations, see 9 | [here]({{site.baseurl}}/documentation/limitations.html). 10 | 11 | __Arguments__ 12 | 13 | name | type | description 14 | -------------------|--------|------------ 15 | data | String/Array of bytes/ArrayBuffer/Uint8Array/Buffer/Blob/Promise | the zip file 16 | options | object | the options to load the zip file 17 | 18 | Content of `options` : 19 | 20 | name | type | default | description 21 | ------------------------------|---------|---------|------------ 22 | options.base64 | boolean | false | set to `true` if the data is base64 encoded, `false` for binary. 23 | options.checkCRC32 | boolean | false | set to `true` if the read data should be checked against its CRC32. 24 | options.optimizedBinaryString | boolean | false | set to `true` if (and only if) the input is a string and has already been prepared with a 0xFF mask. 25 | options.createFolders | boolean | false | set to `true` to create folders in the file path automatically. Leaving it false will result in only virtual folders (i.e. folders that merely represent part of the file path) being created. 26 | options.decodeFileName | function | decode from UTF-8 | the function to decode the file name / comment. 27 | 28 | You shouldn't update the data given to this method : it is kept as it so any 29 | update will impact the stored data. 30 | 31 | Zip features supported by this method : 32 | 33 | * Compression (DEFLATE supported) 34 | * zip with data descriptor 35 | * ZIP64 36 | * UTF8 in file name, UTF8 in file content 37 | 38 | Zip features not (yet) supported : 39 | 40 | * password protected zip 41 | * multi-volume zip 42 | 43 | 44 | __About `decodeFileName`__ : 45 | 46 | A zip file has a flag to say if the filename and comment are encoded with UTF-8. 47 | If it's not set, JSZip has **no way** to know the encoding used. It usually 48 | is the default encoding of the operating system. 49 | 50 | The function takes the bytes array (Uint8Array or Array) and returns the 51 | decoded string. 52 | 53 | __Returns__ : A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with the updated zip object. 54 | The promise can fail if the loaded data is not valid zip data or if it 55 | uses features (multi volume, password protected, etc). 56 | 57 | 68 | 69 | __Example__ 70 | 71 | ```js 72 | var zip = new JSZip(); 73 | zip.loadAsync(zipDataFromXHR); 74 | ``` 75 | 76 | ```js 77 | require("fs").readFile("hello.zip", function (err, data) { 78 | if (err) throw err; 79 | var zip = new JSZip(); 80 | zip.loadAsync(data); 81 | } 82 | ``` 83 | 84 | Using sub folders : 85 | 86 | ```js 87 | var zip = new JSZip(); 88 | zip.folder("subfolder").loadAsync(data); 89 | // the content of data will be loaded in subfolder/ 90 | ``` 91 | 92 | Using a custom charset : 93 | 94 | ```js 95 | // using iconv-lite for example 96 | var iconv = require('iconv-lite'); 97 | 98 | zip.loadAsync(content, { 99 | decodeFileName: function (bytes) { 100 | return iconv.decode(bytes, 'your-encoding'); 101 | } 102 | }); 103 | ``` 104 | 105 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/load_async_object.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "JSZip.loadAsync(data [, options])" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | This is a shortcut for 8 | 9 | ```js 10 | var zip = new JSZip(); 11 | zip.loadAsync(data, options); 12 | ``` 13 | 14 | Please see the documentation of [loadAsync]({{site.baseurl}}/documentation/api_jszip/load_async.html). 15 | 16 | 17 | __Examples__ 18 | 19 | ```js 20 | dataAsPromise 21 | .then(JSZip.loadAsync) 22 | .then(function(zip) {...}) 23 | ``` 24 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/remove.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "remove(name)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Delete a file or folder (recursively). 8 | 9 | __Arguments__ 10 | 11 | name | type | description 12 | -----|--------|------------ 13 | name | string | the name of the file/folder to delete. 14 | 15 | __Returns__ : The current JSZip object. 16 | 17 | __Throws__ : Nothing. 18 | 19 | 23 | 24 | __Example__ 25 | 26 | ```js 27 | var zip = new JSZip(); 28 | zip.file("Hello.txt", "Hello World\n"); 29 | zip.file("temp.txt", "nothing").remove("temp.txt"); 30 | // result : Hello.txt 31 | 32 | zip.folder("css").file("style.css", "body {background: #FF0000}"); 33 | zip.remove("css"); 34 | //result : empty zip 35 | ``` 36 | 37 | 38 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/support.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "JSZip.support" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | If the browser supports them, JSZip can take advantage of some "new" features : 8 | ArrayBuffer, Blob, Uint8Array. To know if JSZip can use them, you can check the 9 | JSZip.support object. It contains the following boolean properties : 10 | 11 | * `arraybuffer` : true if JSZip can read and generate ArrayBuffer, false otherwise. 12 | * `uint8array` : true if JSZip can read and generate Uint8Array, false otherwise. 13 | * `blob` : true if JSZip can generate Blob, false otherwise. 14 | * `nodebuffer` : true if JSZip can read and generate nodejs Buffer, false otherwise. 15 | * `nodestream` : true if JSZip can read and generate nodejs stream, false otherwise. 16 | 17 | 18 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_jszip/version.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "JSZip.version" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | The version of JSZip as a string. 8 | 9 | __Example__ 10 | 11 | ```js 12 | JSZip.version == "3.1.0"; 13 | ``` 14 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_streamhelper.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "StreamHelper API" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | A `StreamHelper` can be viewed as a pausable stream with some helper methods. 8 | It is not a full featured stream like in nodejs (and can't directly used as one) 9 | but the exposed methods should be enough to write the glue code with other async 10 | libraries : `on('data', function)`, `on('end', function)` and `on('error', function)`. 11 | 12 | It starts paused, be sure to `resume()` it when ready. 13 | 14 | If you are looking for an asynchronous helper without writing glue code, take a 15 | look at `accumulate(function)`. 16 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_streamhelper/accumulate.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "accumulate([updateCallback])" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Read the whole stream and call a callback with the complete content. 8 | 9 | __Arguments__ 10 | 11 | name | type | description 12 | ----------------|----------|------------ 13 | updateCallback | function | the function called every time the stream updates. This function is optional. 14 | 15 | 16 | The update callback function takes 1 parameter : the metadata (see the [`on` method]({{site.baseurl}}/documentation/api_streamhelper/on.html)). 17 | 18 | __Returns__ : A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) 19 | of the full content. 20 | 21 | __Throws__ : Nothing. 22 | 23 | __Example__ 24 | 25 | ```js 26 | zip 27 | .generateInternalStream({type:"uint8array"}) 28 | .accumulate(function updateCallback(metadata) { 29 | // metadata contains for example currentFile and percent, see the generateInternalStream doc. 30 | }).then(function (data) { 31 | // data contains here the complete zip file as a uint8array (the type asked in generateInternalStream) 32 | }); 33 | ``` 34 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_streamhelper/on.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "on(event, callback)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Register a listener on an event. 8 | 9 | __Arguments__ 10 | 11 | name | type | description 12 | ----------|----------|------------ 13 | event | string | the name of the event. Only 3 events are supported : `data`, `end` and `error`. 14 | callback | function | the function called when the event occurs. See below for the arguments. 15 | 16 | 17 | A `data` callback takes 2 parameters : 18 | 19 | - the current chunk of data (in a format specified by the method which 20 | generated this StreamHelper) 21 | - the metadata (see each method to know what's inside) 22 | 23 | A `end` callback does not take any parameter. 24 | 25 | A `error` callback takes an `Error` as parameter. 26 | 27 | The callbacks are executed in with the current `StreamHelper` as `this`. 28 | 29 | __Returns__ : The current StreamHelper object, for chaining. 30 | 31 | __Throws__ : An exception if the event is unkown. 32 | 33 | __Example__ 34 | 35 | ```js 36 | zip 37 | .generateInternalStream({type:"uint8array"}) 38 | .on('data', function (data, metadata) { 39 | // data is a Uint8Array because that's the type asked in generateInternalStream 40 | // metadata contains for example currentFile and percent, see the generateInternalStream doc. 41 | }) 42 | .on('error', function (e) { 43 | // e is the error 44 | }) 45 | .on('end', function () { 46 | // no parameter 47 | }) 48 | .resume(); 49 | ``` 50 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_streamhelper/pause.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "pause()" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Pause the stream if the stream is running. Once paused, the 8 | stream stops sending `data` events. 9 | 10 | __Arguments__ : None. 11 | 12 | __Returns__ : The current StreamHelper object, for chaining. 13 | 14 | __Throws__ : Nothing. 15 | 16 | __Example__ 17 | 18 | ```js 19 | zip 20 | .generateInternalStream({type:"uint8array"}) 21 | .on('data', function(chunk) { 22 | 23 | // if we push the chunk to an other service which is overloaded, we can 24 | // pause the stream as backpressure. 25 | this.pause(); 26 | 27 | }).resume(); // start the stream the first time 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_streamhelper/resume.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "resume()" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Resume the stream if the stream is paused. Once resumed, the 8 | stream starts sending `data` events again. 9 | 10 | __Arguments__ : None. 11 | 12 | __Returns__ : The current StreamHelper object, for chaining. 13 | 14 | __Throws__ : Nothing. 15 | 16 | __Example__ 17 | 18 | ```js 19 | zip 20 | .generateInternalStream({type:"uint8array"}) 21 | .on('data', function() {...}) 22 | .resume(); 23 | ``` 24 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_zipobject.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ZipObject API" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | This represents an entry in the zip file. If the entry comes from an existing 8 | archive previously [loaded]({{site.baseurl}}/documentation/api_jszip/load_async.html), the content 9 | will be automatically decompressed/converted first. 10 | 11 | ### Attributes 12 | 13 | attribute name | type | description 14 | ----------------------------|-------------|------------- 15 | `name` | string | the absolute path of the file 16 | `dir` | boolean | true if this is a directory 17 | `date` | date | the last modification date 18 | `comment` | string | the comment for this file 19 | `unixPermissions` | 16 bits number | The UNIX permissions of the file, if any. 20 | `dosPermissions` | 6 bits number | The DOS permissions of the file, if any. 21 | `options` | object | the options of the file. The available options are : 22 | `options.compression` | compression | see [file(name, data [,options])]({{site.baseurl}}/documentation/api_jszip/file_data.html) 23 | 24 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_zipobject/async.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "async(type[, onUpdate])" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) of the content in the asked type. 8 | 9 | __Arguments__ 10 | 11 | name | type | description 12 | ---------|----------|------------ 13 | type | String | the type of the result : `string` (or `text`, its alias), `binarystring`, `base64`, `array`, `uint8array`, `arraybuffer`, `nodebuffer`. 14 | onUpdate | Function | an optional function called on each internal update with the metadata. 15 | 16 | __Metadata__ : the metadata are : 17 | 18 | name | type | description 19 | ------------|--------|------------ 20 | percent | number | the percent of completion (a double between 0 and 100) 21 | 22 | __Returns__ : A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) of the content. 23 | 24 | __Throws__ : Nothing. 25 | 26 | __Example__ 27 | 28 | ```js 29 | zip 30 | .file("my_text.txt") 31 | .async("string") 32 | .then(function success(content) { 33 | // use the content 34 | }, function error(e) { 35 | // handle the error 36 | }); 37 | ``` 38 | 39 | ```js 40 | zip 41 | .file("my_text.txt") 42 | .async("string", function (meta) { 43 | console.log("Generating the content, we are at " + meta.percent.toFixed(2) + " %"); 44 | }) 45 | .then(...); 46 | ``` 47 | 48 | 49 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_zipobject/internal_stream.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "internalStream(type)" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Return a [StreamHelper]({{site.baseurl}}/documentation/api_streamhelper.html) of the content in the asked type. 8 | 9 | __Arguments__ 10 | 11 | name | type | description 12 | ---------|----------|------------ 13 | type | String | the type of the result : `string`, `binarystring`, `uint8array`, `arraybuffer`, `nodebuffer`. 14 | 15 | 16 | __Returns__ : a [StreamHelper]({{site.baseurl}}/documentation/api_streamhelper.html) of the content in the asked type. 17 | 18 | __Throws__ : Nothing. 19 | 20 | __Example__ 21 | 22 | ```js 23 | zip 24 | .file("my_text.txt") 25 | .internalStream("string") 26 | .on("data", function (data) {...}) 27 | .on("error", function (e) {...}) 28 | .on("end", function () {...}); 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/api_zipobject/node_stream.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "nodeStream(type[, onUpdate])" 3 | layout: default 4 | section: api 5 | --- 6 | 7 | __Description__ : Return a [nodejs Streams3](https://github.com/nodejs/readable-stream) 8 | of the content in the asked type. 9 | 10 | __Arguments__ 11 | 12 | name | type | default | description 13 | ---------|----------|--------------|------------ 14 | type | String | `nodebuffer` | only `nodebuffer` is currently supported. 15 | onUpdate | Function | | an optional function called on each internal update with the metadata. 16 | 17 | __Metadata__ : see [the metadata of `async()`]({{site.baseurl}}/documentation/api_zipobject/async.html). 18 | 19 | __Returns__ : a [nodejs Streams3](https://github.com/nodejs/readable-stream). 20 | 21 | __Throws__ : Nothing. 22 | 23 | __Example__ 24 | 25 | ```js 26 | zip 27 | .file("my_text.txt") 28 | .nodeStream() 29 | .pipe(fs.createWriteStream('/tmp/my_text.txt')) 30 | .on('finish', function () { 31 | // JSZip generates a readable stream with a "end" event, 32 | // but is piped here in a writable stream which emits a "finish" event. 33 | console.log("text file written."); 34 | }); 35 | ``` 36 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/contributing.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contributing 3 | layout: default 4 | section: main 5 | --- 6 | 7 | 8 | ### Download the sources 9 | 10 | You should create a [Github](https://github.com/) account and 11 | [fork the repository](https://help.github.com/articles/fork-a-repo) (you will 12 | need one to create the pull request). 13 | 14 | If you just want the get the source code, you can use git and do 15 | `git clone https://github.com/Stuk/jszip.git` to get the sources. You can also 16 | download the latest sources [here](https://github.com/Stuk/jszip/archive/master.zip). 17 | 18 | ### Building the project 19 | 20 | #### Code 21 | 22 | The dependencies are handled by npm, the first step is to run 23 | `npm install` to get the dependencies. 24 | JSZip uses Grunt to handle the build, [see here to install its CLI](http://gruntjs.com/getting-started). 25 | 26 | Here are the interesting build commands : 27 | 28 | * `grunt` will generate the final js file in dist/ and the minified version. 29 | * `npm run test-node` will run the tests in nodejs. 30 | * `npm run test-browser` will the tests in some browsers using SauceLabs, see 31 | below. 32 | * `npm run test` will run the tests in nodejs and in the browser. 33 | * `npm run lint` will use jshint the check the source code. 34 | 35 | #### Documentation 36 | 37 | The documentation uses jekyll on gh-pages. To render the documentation, you 38 | need to [install jekyll](http://jekyllrb.com/docs/installation/) and then run 39 | `jekyll serve --baseurl ''`. 40 | 41 | ### Testing the project 42 | 43 | To test JSZip in nodejs, use `npm run test-node`. 44 | 45 | To test JSZip in a browser, you can open the file `test/index.html` in the 46 | browser you want to test. Don't forget to update the dist/ files with `grunt`. 47 | 48 | You can also test JSZip in a lot of browsers at once with 49 | [SauceLabs](https://saucelabs.com/). You will need a SauceLabs account and two 50 | variables into your environment. On linux, just use 51 | 52 | ```bash 53 | export SAUCE_USERNAME=your-saucelabs-username 54 | export SAUCE_ACCESS_KEY=your-saucelabs-access-key 55 | ``` 56 | 57 | before running the `npm run test-browser` command. 58 | 59 | ### Merging the changes 60 | 61 | If you have tested bug fixes or new features, you can open a 62 | [pull request](https://help.github.com/articles/using-pull-requests) on Github. 63 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/css/main.css: -------------------------------------------------------------------------------- 1 | ul.nav ul { 2 | list-style:none; 3 | margin: 0; 4 | padding: 0 0 0 25px; 5 | } 6 | 7 | #downloader_application form { 8 | margin-bottom: 10px; 9 | } 10 | 11 | #downloader_application ul { 12 | list-style-type: none; 13 | } 14 | 15 | .browser_support th { 16 | border-bottom-width: 3px !important; 17 | } 18 | 19 | .support_ie {border-bottom-color: #0275BA !important;} 20 | .support_ff {border-bottom-color: #DF7215 !important;} 21 | .support_sf {border-bottom-color: #43B3E9 !important;} 22 | .support_cr {border-bottom-color: #39B642 !important;} 23 | .support_op {border-bottom-color: #C42122 !important;} 24 | .support_nd {border-bottom-color: #8CC84B !important;} 25 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/css/pygments.css: -------------------------------------------------------------------------------- 1 | /* Generated with : 2 | * pygmentize -S default -f html > pygments.css 3 | */ 4 | .hll { background-color: #ffffcc } 5 | .c { color: #408080; font-style: italic } /* Comment */ 6 | .err { border: 1px solid #FF0000 } /* Error */ 7 | .k { color: #008000; font-weight: bold } /* Keyword */ 8 | .o { color: #666666 } /* Operator */ 9 | .cm { color: #408080; font-style: italic } /* Comment.Multiline */ 10 | .cp { color: #BC7A00 } /* Comment.Preproc */ 11 | .c1 { color: #408080; font-style: italic } /* Comment.Single */ 12 | .cs { color: #408080; font-style: italic } /* Comment.Special */ 13 | .gd { color: #A00000 } /* Generic.Deleted */ 14 | .ge { font-style: italic } /* Generic.Emph */ 15 | .gr { color: #FF0000 } /* Generic.Error */ 16 | .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 17 | .gi { color: #00A000 } /* Generic.Inserted */ 18 | .go { color: #888888 } /* Generic.Output */ 19 | .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ 20 | .gs { font-weight: bold } /* Generic.Strong */ 21 | .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 22 | .gt { color: #0044DD } /* Generic.Traceback */ 23 | .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ 24 | .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ 25 | .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ 26 | .kp { color: #008000 } /* Keyword.Pseudo */ 27 | .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ 28 | .kt { color: #B00040 } /* Keyword.Type */ 29 | .m { color: #666666 } /* Literal.Number */ 30 | .s { color: #BA2121 } /* Literal.String */ 31 | .na { color: #7D9029 } /* Name.Attribute */ 32 | .nb { color: #008000 } /* Name.Builtin */ 33 | .nc { color: #0000FF; font-weight: bold } /* Name.Class */ 34 | .no { color: #880000 } /* Name.Constant */ 35 | .nd { color: #AA22FF } /* Name.Decorator */ 36 | .ni { color: #999999; font-weight: bold } /* Name.Entity */ 37 | .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ 38 | .nf { color: #0000FF } /* Name.Function */ 39 | .nl { color: #A0A000 } /* Name.Label */ 40 | .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ 41 | .nt { color: #008000; font-weight: bold } /* Name.Tag */ 42 | .nv { color: #19177C } /* Name.Variable */ 43 | .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ 44 | .w { color: #bbbbbb } /* Text.Whitespace */ 45 | .mf { color: #666666 } /* Literal.Number.Float */ 46 | .mh { color: #666666 } /* Literal.Number.Hex */ 47 | .mi { color: #666666 } /* Literal.Number.Integer */ 48 | .mo { color: #666666 } /* Literal.Number.Oct */ 49 | .sb { color: #BA2121 } /* Literal.String.Backtick */ 50 | .sc { color: #BA2121 } /* Literal.String.Char */ 51 | .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ 52 | .s2 { color: #BA2121 } /* Literal.String.Double */ 53 | .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ 54 | .sh { color: #BA2121 } /* Literal.String.Heredoc */ 55 | .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ 56 | .sx { color: #008000 } /* Literal.String.Other */ 57 | .sr { color: #BB6688 } /* Literal.String.Regex */ 58 | .s1 { color: #BA2121 } /* Literal.String.Single */ 59 | .ss { color: #19177C } /* Literal.String.Symbol */ 60 | .bp { color: #008000 } /* Name.Builtin.Pseudo */ 61 | .vc { color: #19177C } /* Name.Variable.Class */ 62 | .vg { color: #19177C } /* Name.Variable.Global */ 63 | .vi { color: #19177C } /* Name.Variable.Instance */ 64 | .il { color: #666666 } /* Literal.Number.Integer.Long */ 65 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/examples.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "How to use JSZip" 3 | layout: default 4 | section: example 5 | --- 6 | 7 | An instance of JSZip represents a set of files. You can add them, remove them, 8 | modify them. You can also import an existing zip file or generate one. 9 | 10 | ### Getting the object 11 | 12 | #### In a browser 13 | 14 | For a browser, there are two interesting files : `dist/jszip.js` and 15 | `dist/jszip.min.js` (include just one). 16 | 17 | If you use an AMD loader (RequireJS for example) JSZip will register itself : 18 | you just have to put the js file at the right place, or configure the loader 19 | (see [here for RequireJS](http://requirejs.org/docs/api.html#config-paths)). 20 | 21 | Without any loader, JSZip will declare in the global scope a variable named `JSZip`. 22 | 23 | #### In nodejs 24 | 25 | In nodejs, you can `require` it : 26 | 27 | ```js 28 | var JSZip = require("jszip"); 29 | ``` 30 | 31 | ### Basic manipulations 32 | 33 | The first step is to create an instance of JSZip : 34 | 35 | ```js 36 | var zip = new JSZip(); 37 | ``` 38 | 39 | On this instance, we can add (and update) files and folders with 40 | `.file(name, content)` and `.folder(name)`. 41 | They return the current JSZip instance so you can chain the calls. 42 | 43 | ```js 44 | // create a file 45 | zip.file("hello.txt", "Hello[p my)6cxsw2q"); 46 | // oops, cat on keyboard. Fixing ! 47 | zip.file("hello.txt", "Hello World\n"); 48 | 49 | // create a file and a folder 50 | zip.file("nested/hello.txt", "Hello World\n"); 51 | // same as 52 | zip.folder("nested").file("hello.txt", "Hello World\n"); 53 | ``` 54 | 55 | With `.folder(name)`, the returned object has a different root : if you add files 56 | on this object, you will put them in the created subfolder. This is just a 57 | view, the added files will also be in the "root" object. 58 | 59 | ```js 60 | var photoZip = zip.folder("photos"); 61 | // this call will create photos/README 62 | photoZip.file("README", "a folder with photos"); 63 | ``` 64 | 65 | You can access the file content with `.file(name)` and 66 | [its getters]({{site.baseurl}}/documentation/api_zipobject.html) : 67 | 68 | ```js 69 | zip.file("hello.txt").async("string").then(function (data) { 70 | // data is "Hello World\n" 71 | }); 72 | 73 | if (JSZip.support.uint8array) { 74 | zip.file("hello.txt").async("uint8array").then(function (data) { 75 | // data is Uint8Array { 0=72, 1=101, 2=108, more...} 76 | }); 77 | } 78 | ``` 79 | 80 | You can also remove files or folders with `.remove(name)` : 81 | 82 | ```js 83 | zip.remove("photos/README"); 84 | zip.remove("photos"); 85 | // same as 86 | zip.remove("photos"); // by removing the folder, you also remove its content. 87 | ``` 88 | 89 | ### Generate a zip file 90 | 91 | With `.generateAsync(options)` or `.generateNodeStream(options)` you can generate 92 | a zip file (not a real file but its representation in memory). Check 93 | [this page]({{site.baseurl}}/documentation/howto/write_zip.html) for more 94 | informations on how to write / give the file to the user. 95 | 96 | ```js 97 | var promise = null; 98 | if (JSZip.support.uint8array) { 99 | promise = zip.generateAsync({type : "uint8array"}); 100 | } else { 101 | promise = zip.generateAsync({type : "string"}); 102 | } 103 | ``` 104 | 105 | ### Read a zip file 106 | 107 | With `.loadAsync(data)` you can load a zip file. Check 108 | [this page]({{site.baseurl}}/documentation/howto/read_zip.html) to see how to 109 | do properly (it's more tricky that it seems). 110 | 111 | ```js 112 | var new_zip = new JSZip(); 113 | // more files ! 114 | new_zip.loadAsync(content) 115 | .then(function(zip) { 116 | // you now have every files contained in the loaded zip 117 | new_zip.file("hello.txt").async("string"); // a promise of "Hello World\n" 118 | }); 119 | ``` 120 | 121 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/examples/download-zip-file.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Download the generated zip file" 3 | layout: default 4 | section: example 5 | --- 6 | 7 |

Tip : check the source of the page !

8 |

The FileSaver API

9 |
10 | Works on firefox, chrome , opera >= 15 and IE >= 10 (but NOT in compatibility view).
11 | 12 |
13 |

The data URL

14 |
15 | Does not work in IE, has restrictions on the length.
16 | 17 |
18 | 62 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/examples/downloader.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Mini app : Downloader" 3 | layout: default 4 | section: example 5 | --- 6 | 7 |

Tip : check the source of the page !

8 | 9 |

10 | This mini application let you choose the files you want in a list, download 11 | them, zip them and give the result to the user. 12 |

13 |

14 | This demo requires a recent browser, see 15 | the howto. 16 |

17 | 18 | 19 | 20 |
21 |

Please select your files

22 |
23 |
    24 |
  • 25 | 29 |
  • 30 |
  • 31 | 35 |
  • 36 |
  • 37 | 41 |
  • 42 |
  • 43 | 47 |
  • 48 |
49 | 50 | 51 |
52 | 53 |
54 |
55 |
56 |
57 | 58 |

59 | 60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/examples/downloader.js: -------------------------------------------------------------------------------- 1 | jQuery(function ($) { 2 | "use strict"; 3 | 4 | var Promise = window.Promise; 5 | if (!Promise) { 6 | Promise = JSZip.external.Promise; 7 | } 8 | 9 | /** 10 | * Reset the message. 11 | */ 12 | function resetMessage () { 13 | $("#result") 14 | .removeClass() 15 | .text(""); 16 | } 17 | /** 18 | * show a successful message. 19 | * @param {String} text the text to show. 20 | */ 21 | function showMessage(text) { 22 | resetMessage(); 23 | $("#result") 24 | .addClass("alert alert-success") 25 | .text(text); 26 | } 27 | /** 28 | * show an error message. 29 | * @param {String} text the text to show. 30 | */ 31 | function showError(text) { 32 | resetMessage(); 33 | $("#result") 34 | .addClass("alert alert-danger") 35 | .text(text); 36 | } 37 | /** 38 | * Update the progress bar. 39 | * @param {Integer} percent the current percent 40 | */ 41 | function updatePercent(percent) { 42 | $("#progress_bar").removeClass("hide") 43 | .find(".progress-bar") 44 | .attr("aria-valuenow", percent) 45 | .css({ 46 | width : percent + "%" 47 | }); 48 | } 49 | 50 | /** 51 | * Fetch the content and return the associated promise. 52 | * @param {String} url the url of the content to fetch. 53 | * @return {Promise} the promise containing the data. 54 | */ 55 | function urlToPromise(url) { 56 | return new Promise(function(resolve, reject) { 57 | JSZipUtils.getBinaryContent(url, function (err, data) { 58 | if(err) { 59 | reject(err); 60 | } else { 61 | resolve(data); 62 | } 63 | }); 64 | }); 65 | } 66 | 67 | if(!JSZip.support.blob) { 68 | showError("This demo works only with a recent browser !"); 69 | return; 70 | } 71 | 72 | var $form = $("#download_form").on("submit", function () { 73 | 74 | resetMessage(); 75 | 76 | var zip = new JSZip(); 77 | 78 | // find every checked item 79 | $(this).find(":checked").each(function () { 80 | var $this = $(this); 81 | var url = $this.data("url"); 82 | var filename = url.replace(/.*\//g, ""); 83 | zip.file(filename, urlToPromise(url), {binary:true}); 84 | }); 85 | 86 | // when everything has been downloaded, we can trigger the dl 87 | zip.generateAsync({type:"blob"}, function updateCallback(metadata) { 88 | var msg = "progression : " + metadata.percent.toFixed(2) + " %"; 89 | if(metadata.currentFile) { 90 | msg += ", current file = " + metadata.currentFile; 91 | } 92 | showMessage(msg); 93 | updatePercent(metadata.percent|0); 94 | }) 95 | .then(function callback(blob) { 96 | 97 | // see FileSaver.js 98 | saveAs(blob, "example.zip"); 99 | 100 | showMessage("done !"); 101 | }, function (e) { 102 | showError(e); 103 | }); 104 | 105 | return false; 106 | }); 107 | }); 108 | 109 | // vim: set shiftwidth=4 softtabstop=4: 110 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/examples/get-binary-files-ajax.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Get a file with an ajax call" 3 | layout: default 4 | section: example 5 | --- 6 | 7 |

Tip : check the source of the page !

8 | 9 |

With JSZipUtils

10 |
11 | 12 |

With the Fetch API

13 |
14 | 15 | 82 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/examples/read-local-file-api.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Reading a local file with the File API" 3 | layout: default 4 | section: example 5 | --- 6 | 7 |

Choose the local(s) zip file(s)

8 |

Note : your browser will process the zip file, don't choose a file too big !

9 |
10 | 11 | 14 | 15 | 19 | 20 | 73 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/faq.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Frequently Asked Questions" 3 | layout: default 4 | section: main 5 | --- 6 | 7 | ### "Corrupted zip or bug : unexpected signature" 8 | 9 | If you are sure that the zip file is correct, that error often comes from a 10 | corrupted content. An ajax request, if not prepared correctly, will try to 11 | decode the binary content as a text and corrupt it. See 12 | [this page]({{site.baseurl}}/documentation/howto/read_zip.html). 13 | 14 | ### My browser crashes / becomes unresponsive / never finish the execution 15 | 16 | That happens if you try to handle to much data with the synchronous API. If 17 | possible, try the asynchronous API, see 18 | [this page]({{site.baseurl}}/documentation/limitations.html) for more informations. 19 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/howto/write_zip.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "How to write a file / give it to the user" 3 | layout: default 4 | section: example 5 | --- 6 | 7 | ### In the browser 8 | 9 | With only javascript, this part won't work in old browsers, including IE < 10. 10 | For those browsers, you can use a flash polyfill, see below. 11 | 12 | You can also see this 13 | [example]({{site.baseurl}}/documentation/examples/download-zip-file.html). 14 | 15 | #### Blob URL / FileSaver 16 | 17 | With recent browsers, the easiest way is to use `saveAs` or a polyfill, see 18 | [FileSaver.js](https://github.com/eligrey/FileSaver.js) : 19 | 20 | ```js 21 | zip.generateAsync({type:"blob"}) 22 | .then(function (blob) { 23 | saveAs(blob, "hello.zip"); 24 | }); 25 | ``` 26 | 27 | Under the hood, the polyfill uses the native `saveAs` from the 28 | [FileSaver](http://www.w3.org/TR/file-writer-api/#the-filesaver-interface) API 29 | (on Chrome and IE10+) or use a [Blob URL](http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download) 30 | (on Firefox). 31 | 32 | 33 | #### Data URI 34 | 35 | For older browsers that support [data URI](http://caniuse.com/datauri), you can also 36 | do the following : 37 | 38 | ```js 39 | zip.generateAsync({type:"base64"}).then(function (base64) { 40 | location.href="data:application/zip;base64," + base64; 41 | }); 42 | ``` 43 | 44 | The biggest issue here is that the filenames are very awkward, Firefox 45 | generates filenames such as `a5sZQRsx.zip.part` (see bugs 46 | [367231](https://bugzilla.mozilla.org/show_bug.cgi?id=367231) and 47 | [532230](https://bugzilla.mozilla.org/show_bug.cgi?id=532230), and Safari 48 | isn't much better with just `Unknown`. 49 | 50 | Browser support and resulting filename : 51 | 52 | Opera | Firefox | Safari | Chrome | Internet Explorer 53 | -------|---------|--------|--------|------------------ 54 | "default.zip" | random alphanumeric with ".part" extension | "Unknown" (no extension) | "download.zip" on OSX and Linux, just "download" on Windows | No 55 | 56 | #### Downloadify 57 | 58 | [Downloadify](https://github.com/dcneiner/downloadify) uses a small Flash SWF 59 | to download files to a user's computer with a filename that you can choose. 60 | Doug Neiner has added the `dataType` option to allow you to pass a zip for 61 | downloading. Follow the [Downloadify demo](http://pixelgraphics.us/downloadify/test.html) 62 | with the following changes: 63 | 64 | ```js 65 | zip = new JSZip(); 66 | zip.file("Hello.", "hello.txt"); 67 | 68 | zip.generateAsync({type:"base64"}).then(function (base64) { 69 | Downloadify.create('downloadify',{ 70 | ... 71 | data: function(){ 72 | return base64; 73 | }, 74 | ... 75 | dataType: 'base64' 76 | }); 77 | }); 78 | ``` 79 | 80 | 83 | 84 | #### Deprecated google gears 85 | 86 | [Franz Buchinger](http://www.picurl.org/blog/author/franz/) has written a 87 | brilliant tutorial on [using JSZip with Google Gears](http://www.picurl.org/blog/2009/11/22/creating-zip-archives-with-gears) 88 | ([part 2](http://www.picurl.org/blog/2009/11/29/gearszipper-part2-adding-support-for-real-files-and-canvas-elements/)). 89 | If you want to let your Gears users download several files at once I really 90 | recommend having a look at some of his [examples](http://picurl.org/gears/zipper/). 91 | 92 | 93 | 94 | ### In nodejs 95 | 96 | JSZip can generate Buffers so you can do the following : 97 | 98 | ```js 99 | var fs = require("fs"); 100 | var JSZip = require("jszip"); 101 | 102 | var zip = new JSZip(); 103 | // zip.file("file", content); 104 | // ... and other manipulations 105 | 106 | zip 107 | .generateNodeStream({type:'nodebuffer',streamFiles:true}) 108 | .pipe(fs.createWriteStream('out.zip')) 109 | .on('finish', function () { 110 | // JSZip generates a readable stream with a "end" event, 111 | // but is piped here in a writable stream which emits a "finish" event. 112 | console.log("out.zip written."); 113 | }); 114 | ``` 115 | 116 | 117 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/limitations.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Limitations of JSZip" 3 | layout: default 4 | section: limitations 5 | fullpage: true 6 | --- 7 | 8 | ### Not supported features 9 | 10 | All the features of zip files are not supported. Classic zip files will work 11 | but encrypted zip, multi-volume, etc are not supported and the loadAsync() 12 | method will return a failed promise. 13 | 14 | 15 | ### ZIP64 and 32bit integers 16 | 17 | ZIP64 files can be loaded, but only if the zip file is not "too big". ZIP64 uses 64bits integers 18 | but Javascript represents all numbers as 19 | [64-bit double precision IEEE 754 floating point numbers](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf) 20 | (see section 8.5). So, we have 53bits for integers and 21 | [bitwise operations treat everything as 32bits](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators). 22 | So if all the 64bits integers can fit into 32 bits integers, everything will be 23 | fine. If it's not the case, you will have other problems anyway (see next 24 | limitation). 25 | 26 | ### Performance issues 27 | 28 | An other limitation comes from the browser (and the machine running the 29 | browser). A compressed zip file of 10MB is easily opened by firefox / chrome 30 | / opera / IE10+ but will crash older IE. Also keep in mind that strings in 31 | javascript are encoded in UTF-16 : a 10MB ascii text file will take 20MB of 32 | memory. 33 | 34 | The 35 | [`async` method]({{site.baseurl}}/documentation/api_zipobject/async.html) and the 36 | [`generateAsync` method]({{site.baseurl}}/documentation/api_jszip/generate_async.html) 37 | hold the full result in memory but doesn't freeze the browser. If the result 38 | is too big, and if you can't use the 39 | [`nodeStream` method]({{site.baseurl}}/documentation/api_zipobject/node_stream.html) or the 40 | [`generateNodeStream` method]({{site.baseurl}}/documentation/api_jszip/generate_node_stream.html) 41 | you need to use the underlying 42 | [`StreamHelper`]({{site.baseurl}}/documentation/api_streamhelper.html) to 43 | handle the result chunk by chunk and `pause()`/`resume()` to handle the 44 | backpressure. 45 | 46 | If you're having performance issues, please consider the following : 47 | 48 | * Don't use IE <= 9. Everything is better with typed arrays. 49 | * Use typed arrays (Uint8Array, ArrayBuffer, etc) if possible : 50 | * If you generate a zip file, you should use `type:"uint8array"` 51 | (or blob, arraybuffer, nodebuffer). 52 | * If you load the file from an ajax call, ask your XHR an ArrayBuffer. 53 | Loading a string is asking for troubles. 54 | 55 | Note about compression : 56 | When reading a file, JSZip will store the content without decompressing it. 57 | When generating a compressed file, JSZip will reuse if possible the compressed 58 | content : 59 | 60 | * If you read a zip file compressed with DEFLATE and call `generate` with the 61 | DEFLATE compression, JSZip won't call the compression algorithms (same with 62 | STORE everywhere.) 63 | * If you read a zip file compressed with DEFLATE and call `generate` with the 64 | STORE compression, JSZip will have to decompress everything. 65 | 66 | On IE <=9, typed arrays are not supported and the compression algorithm 67 | will fallback on arrays. In that case, JSZip needs to convert the binary string 68 | into an array, DEFLATE it and convert the result into a binary string. 69 | You don't want that to happen. 70 | 71 | ### The output zip will differ from the input zip 72 | 73 | Reading and generating a zip file won't give you back the same file. 74 | Some data are discarded (file metadata) and other are added (subfolders). 75 | 76 | ### Encodings support 77 | 78 | JSZip only supports UTF-8 natively. A zip file doesn't contain the name of the 79 | encoding used, you need to know it before doing anything. 80 | 81 | #### File name 82 | 83 | If the name of a file inside the zip is encoded with UTF-8 then JSZip can 84 | detect it (Language encoding flag, Unicode Path Extra Field). If not, JSZip 85 | can't detect the encoding used and will generate [Mojibake](https://en.wikipedia.org/wiki/Mojibake). 86 | You can use the [encodeFileName]({{site.baseurl}}/documentation/api_jszip/generate.html) 87 | option and the [decodeFileName]({{site.baseurl}}/documentation/api_jszip/load.html) 88 | option to encode/decode using a custom encoding. 89 | 90 | #### File content 91 | 92 | The `async("string")` method uses UTF-8 to decode the content. If you have a text in 93 | a different encoding, you can get the bytes array with `async("uint8array")` and 94 | decode it with a lib (iconv, iconv-lite, etc) on your side. 95 | To save a text using a non-UTF-8 encoding, do the same : encode it into a 96 | Uint8Array before adding it to JSZip. 97 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/documentation/upgrade_guide.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Upgrade Guide 3 | layout: default 4 | section: main 5 | --- 6 | 7 | ### From 2.x to 3.0.0 8 | 9 | * Deprecated objects/methods has been removed: 10 | * `options.base64` in `generate()` (the base64 type is still valid) 11 | * `options.base64`, `options.binary`, `options.dir`, `options.date` 12 | on `ZipObject` (see the [2.3 upgrade section](#from-222-to-230)) 13 | * `JSZip.utils` 14 | * `JSZip.prototype.crc32`, `JSZip.prototype.utf8encode`, `JSZip.prototype.utf8decode` 15 | * `JSZip.base64` (you can get the content of a file directly as a base64 string) 16 | * `JSZip.compressions` has been removed. 17 | * On `ZipObject`, the synchronous getters has been replaced by `async()` and 18 | `nodeStream()`. 19 | * The `generate()` method has been replaced by `generateAsync()` and 20 | `generateNodeStream()`. 21 | * The `type` option in `generate()` is now mandatory. 22 | * The "text" type has been replaced by the "string" type, a binary string is 23 | named "binarystring". 24 | * The `load()` method and the constructor with data (`new JSZip(data)`) have 25 | been replaced by `loadAsync()`. 26 | * When adding a file, the option `createFolders` now defaults to `true`. If 27 | you don't want to create sub folders, set it to false. 28 | * `zip.generateAsync()` and `zip.generateNodeStream()` now depend on the 29 | current folder level. 30 | 31 | ```js 32 | // 2.x 33 | zip.file("test.txt").asText(); 34 | // 3.x 35 | zip.file("test.txt").async("string") 36 | .then(function (content) { 37 | // use content 38 | }); 39 | 40 | 41 | // 2.x 42 | zip.generate(); 43 | // 3.x 44 | zip.generateAsync({type:"uint8array"}) 45 | .then(function (content) { 46 | // use content 47 | }); 48 | 49 | // 2.x 50 | new JSZip(data); 51 | zip.load(data); 52 | // zip.file(...) 53 | // 3.x 54 | JSZip.loadAsync(data).then(zip) {...}; 55 | zip.loadAsync(data).then(zip) {...}; 56 | // here, zip won't have (yet) the updated content 57 | 58 | // 2.x 59 | var data = zip.file("img.jpg").asBinary(); 60 | var dataURI = "data:image/jpeg;base64," + JSZip.base64.encode(data); 61 | // 3.x 62 | zip.file("img.jpg").async("base64") 63 | .then(function (data64) { 64 | var dataURI = "data:image/jpeg;base64," + data64; 65 | }); 66 | ``` 67 | 68 | `async` and `loadAsync` use (a polyfill of) promises, you can find 69 | the documentation [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) 70 | and a tutorial [here](http://www.html5rocks.com/en/tutorials/es6/promises/). 71 | 72 | It is worth noting that: 73 | 74 | ```js 75 | /* 76 | * JSZip accepts these promise as input 77 | */ 78 | 79 | // replace a content with JSZip v2 80 | var content = zip.file("my_file").asText(); 81 | content = content.replace(/apples/, 'oranges'); 82 | zip.file("my_file", content); 83 | 84 | // replace a content with JSZip v3 85 | var contentPromise = zip.file("my_file").async("text").then(function (content) { 86 | return content.replace(/apples/, 'oranges'); 87 | }); 88 | zip.file("my_file", contentPromise); 89 | 90 | 91 | /* 92 | * Promises are chainable 93 | */ 94 | 95 | // read, update, generate a zip file with JSZip v2 96 | var zip = new JSZip(content); 97 | zip.file("new_file", "new_content"); 98 | var blob = zip.generate({type: "blob"}); 99 | saveAs(blob, "result.zip"); 100 | 101 | // read, update, generate a zip file with JSZip v3 102 | JSZip.loadAsync(content) 103 | .then(function (zip) { 104 | zip.file("new_file", "new_content"); 105 | // if you return the zip object, it will be available in the next "then" 106 | return zip; 107 | .then(function (zip) { 108 | // if you return a promise of a blob, promises will "merge": the current 109 | // promise will wait for the other and the next "then" will get the 110 | // blob 111 | return zip.generateAsync({type: "blob"}); 112 | .then(function (blob) { 113 | saveAs(blob, "result.zip"); 114 | }); 115 | ``` 116 | 117 | ### From 2.2.2 to 2.3.0 118 | 119 | * On `ZipObject#options`, the attributes `date` and `dir` have been 120 | deprecated and are now on `ZipObject`. 121 | * On `ZipObject#options`, the attributes `base64` and `binary` have been 122 | deprecated. 123 | * `JSZip.base64`, `JSZip.prototype.crc32`, `JSZip.prototype.utf8decode`, 124 | `JSZip.prototype.utf8encode` and `JSZip.utils` have been deprecated. 125 | 126 | ```js 127 | // deprecated 128 | zip.file("test.txt").options.date 129 | zip.file("test.txt").options.dir 130 | // new API 131 | zip.file("test.txt").date 132 | zip.file("test.txt").dir 133 | ``` 134 | 135 | 136 | ### From 2.0.0 to 2.1.0 137 | 138 | * The packaging changed : instead of loading jszip.js, jszip-load.js, 139 | jszip-inflate.js, jszip-deflate.js, just include dist/jszip.js or 140 | dist/jszip.min.js. 141 | For AMD loader users : JSZip now registers itself. You just have to put the 142 | file at the right place or configure your loader. 143 | 144 | 145 | ### From 1.x to 2.x 146 | 147 | * `JSZipBase64` has been renamed to `JSZip.base64`. 148 | * The `data` attribute doesn't exist anymore : 149 | use the getters `asText()`, `asBinary()`, etc 150 | * The compression/decompression methods now give their input type with the 151 | `compressInputType` and `uncompressInputType` attributes. 152 | 153 | Example for the data attribute : 154 | 155 | ```js 156 | // before 157 | zip.file("test.txt").data; 158 | zip.files["test.txt"].data; 159 | zip.file("image.png").data; 160 | zip.files["image.png"].data; 161 | 162 | // after 163 | zip.file("test.txt").asText(); 164 | zip.files["test.txt"].asText(); 165 | zip.file("image.png").asBinary(); 166 | zip.files["image.png"].asBinary(); 167 | ``` 168 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: JSZip 3 | layout: default 4 | section: main 5 | --- 6 | 7 |
8 |
9 | 10 | JSZip is a javascript library for creating, reading and editing .zip files, with a 11 | lovely and simple API. 12 | 13 |
14 |
15 |

16 | Current version : v3.1.3 17 |

18 |

19 | License : JSZip is dual-licensed. You may use it under the 20 | MIT license or the GPLv3 license. See 21 | LICENSE.markdown. 22 |

23 |
24 | 25 |
26 |
27 | 28 |

Example

29 | 30 | 57 | 67 | 68 | 69 | 73 |
74 |
75 | 76 |

Installation

77 | 78 |

79 | With npm : npm install jszip 80 |

81 |

82 | With bower : bower install Stuk/jszip 83 |

84 |

85 | With component : component install Stuk/jszip 86 |

87 |

88 | Manually : download JSZip 89 | and include the file dist/jszip.js or dist/jszip.min.js 90 |

91 |
92 |

93 | Installed ? Great ! You can now check our 94 | guides and examples ! 95 |

96 |
97 |
98 | 99 |

Support

100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 |
OperaFirefoxSafariChromeInternet ExplorerNode.js
YesYesYesYesYesYes
Tested with the latest versionTested with 3.0 / 3.6 / latest versionTested with the latest versionTested with the latest versionTested with IE 6 / 7 / 8 / 9 / 10Tested with node.js 0.10 / latest version
127 | 128 |

Getting help

129 | 130 |

131 | Having trouble ? We'd like to help ! 132 |

133 |
    134 |
  • 135 | Try the FAQ, it has 136 | answers to common questions. 137 |
  • 138 |
  • 139 | If you're looking for informations about a specific method, try the 140 | documentation. 141 |
  • 142 |
  • 143 | Check the 144 | examples. 145 |
  • 146 |
  • 147 | Report bugs in our 148 | Bug tracker. 149 |
  • 150 |
151 | 152 |

Test status

153 | 154 |
155 |
Travis build :
156 |
157 | 158 | 159 | 160 |
161 |
Saucelabs build :
162 |
163 | 164 | 165 | 166 |
167 |
Live tests :
168 |
169 | See for yourself ! 170 |
171 |
172 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/base64.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var utils = require('./utils'); 3 | var support = require('./support'); 4 | // private property 5 | var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 6 | 7 | 8 | // public method for encoding 9 | exports.encode = function(input) { 10 | var output = []; 11 | var chr1, chr2, chr3, enc1, enc2, enc3, enc4; 12 | var i = 0, len = input.length, remainingBytes = len; 13 | 14 | var isArray = utils.getTypeOf(input) !== "string"; 15 | while (i < input.length) { 16 | remainingBytes = len - i; 17 | 18 | if (!isArray) { 19 | chr1 = input.charCodeAt(i++); 20 | chr2 = i < len ? input.charCodeAt(i++) : 0; 21 | chr3 = i < len ? input.charCodeAt(i++) : 0; 22 | } else { 23 | chr1 = input[i++]; 24 | chr2 = i < len ? input[i++] : 0; 25 | chr3 = i < len ? input[i++] : 0; 26 | } 27 | 28 | enc1 = chr1 >> 2; 29 | enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 30 | enc3 = remainingBytes > 1 ? (((chr2 & 15) << 2) | (chr3 >> 6)) : 64; 31 | enc4 = remainingBytes > 2 ? (chr3 & 63) : 64; 32 | 33 | output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4)); 34 | 35 | } 36 | 37 | return output.join(""); 38 | }; 39 | 40 | // public method for decoding 41 | exports.decode = function(input) { 42 | var chr1, chr2, chr3; 43 | var enc1, enc2, enc3, enc4; 44 | var i = 0, resultIndex = 0; 45 | 46 | var dataUrlPrefix = "data:"; 47 | 48 | if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) { 49 | // This is a common error: people give a data url 50 | // (data:image/png;base64,iVBOR...) with a {base64: true} and 51 | // wonders why things don't work. 52 | // We can detect that the string input looks like a data url but we 53 | // *can't* be sure it is one: removing everything up to the comma would 54 | // be too dangerous. 55 | throw new Error("Invalid base64 input, it looks like a data url."); 56 | } 57 | 58 | input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 59 | 60 | var totalLength = input.length * 3 / 4; 61 | if(input.charAt(input.length - 1) === _keyStr.charAt(64)) { 62 | totalLength--; 63 | } 64 | if(input.charAt(input.length - 2) === _keyStr.charAt(64)) { 65 | totalLength--; 66 | } 67 | if (totalLength % 1 !== 0) { 68 | // totalLength is not an integer, the length does not match a valid 69 | // base64 content. That can happen if: 70 | // - the input is not a base64 content 71 | // - the input is *almost* a base64 content, with a extra chars at the 72 | // beginning or at the end 73 | // - the input uses a base64 variant (base64url for example) 74 | throw new Error("Invalid base64 input, bad content length."); 75 | } 76 | var output; 77 | if (support.uint8array) { 78 | output = new Uint8Array(totalLength|0); 79 | } else { 80 | output = new Array(totalLength|0); 81 | } 82 | 83 | while (i < input.length) { 84 | 85 | enc1 = _keyStr.indexOf(input.charAt(i++)); 86 | enc2 = _keyStr.indexOf(input.charAt(i++)); 87 | enc3 = _keyStr.indexOf(input.charAt(i++)); 88 | enc4 = _keyStr.indexOf(input.charAt(i++)); 89 | 90 | chr1 = (enc1 << 2) | (enc2 >> 4); 91 | chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 92 | chr3 = ((enc3 & 3) << 6) | enc4; 93 | 94 | output[resultIndex++] = chr1; 95 | 96 | if (enc3 !== 64) { 97 | output[resultIndex++] = chr2; 98 | } 99 | if (enc4 !== 64) { 100 | output[resultIndex++] = chr3; 101 | } 102 | 103 | } 104 | 105 | return output; 106 | }; 107 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/compressedObject.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var external = require("./external"); 4 | var DataWorker = require('./stream/DataWorker'); 5 | var DataLengthProbe = require('./stream/DataLengthProbe'); 6 | var Crc32Probe = require('./stream/Crc32Probe'); 7 | var DataLengthProbe = require('./stream/DataLengthProbe'); 8 | 9 | /** 10 | * Represent a compressed object, with everything needed to decompress it. 11 | * @constructor 12 | * @param {number} compressedSize the size of the data compressed. 13 | * @param {number} uncompressedSize the size of the data after decompression. 14 | * @param {number} crc32 the crc32 of the decompressed file. 15 | * @param {object} compression the type of compression, see lib/compressions.js. 16 | * @param {String|ArrayBuffer|Uint8Array|Buffer} data the compressed data. 17 | */ 18 | function CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) { 19 | this.compressedSize = compressedSize; 20 | this.uncompressedSize = uncompressedSize; 21 | this.crc32 = crc32; 22 | this.compression = compression; 23 | this.compressedContent = data; 24 | } 25 | 26 | CompressedObject.prototype = { 27 | /** 28 | * Create a worker to get the uncompressed content. 29 | * @return {GenericWorker} the worker. 30 | */ 31 | getContentWorker : function () { 32 | var worker = new DataWorker(external.Promise.resolve(this.compressedContent)) 33 | .pipe(this.compression.uncompressWorker()) 34 | .pipe(new DataLengthProbe("data_length")); 35 | 36 | var that = this; 37 | worker.on("end", function () { 38 | if(this.streamInfo['data_length'] !== that.uncompressedSize) { 39 | throw new Error("Bug : uncompressed data size mismatch"); 40 | } 41 | }); 42 | return worker; 43 | }, 44 | /** 45 | * Create a worker to get the compressed content. 46 | * @return {GenericWorker} the worker. 47 | */ 48 | getCompressedWorker : function () { 49 | return new DataWorker(external.Promise.resolve(this.compressedContent)) 50 | .withStreamInfo("compressedSize", this.compressedSize) 51 | .withStreamInfo("uncompressedSize", this.uncompressedSize) 52 | .withStreamInfo("crc32", this.crc32) 53 | .withStreamInfo("compression", this.compression) 54 | ; 55 | } 56 | }; 57 | 58 | /** 59 | * Chain the given worker with other workers to compress the content with the 60 | * given compresion. 61 | * @param {GenericWorker} uncompressedWorker the worker to pipe. 62 | * @param {Object} compression the compression object. 63 | * @param {Object} compressionOptions the options to use when compressing. 64 | * @return {GenericWorker} the new worker compressing the content. 65 | */ 66 | CompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions) { 67 | return uncompressedWorker 68 | .pipe(new Crc32Probe()) 69 | .pipe(new DataLengthProbe("uncompressedSize")) 70 | .pipe(compression.compressWorker(compressionOptions)) 71 | .pipe(new DataLengthProbe("compressedSize")) 72 | .withStreamInfo("compression", compression); 73 | }; 74 | 75 | module.exports = CompressedObject; 76 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/compressions.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var GenericWorker = require("./stream/GenericWorker"); 4 | 5 | exports.STORE = { 6 | magic: "\x00\x00", 7 | compressWorker : function (compressionOptions) { 8 | return new GenericWorker("STORE compression"); 9 | }, 10 | uncompressWorker : function () { 11 | return new GenericWorker("STORE decompression"); 12 | } 13 | }; 14 | exports.DEFLATE = require('./flate'); 15 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/crc32.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./utils'); 4 | 5 | /** 6 | * The following functions come from pako, from pako/lib/zlib/crc32.js 7 | * released under the MIT license, see pako https://github.com/nodeca/pako/ 8 | */ 9 | 10 | // Use ordinary array, since untyped makes no boost here 11 | function makeTable() { 12 | var c, table = []; 13 | 14 | for(var n =0; n < 256; n++){ 15 | c = n; 16 | for(var k =0; k < 8; k++){ 17 | c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); 18 | } 19 | table[n] = c; 20 | } 21 | 22 | return table; 23 | } 24 | 25 | // Create table on load. Just 255 signed longs. Not a problem. 26 | var crcTable = makeTable(); 27 | 28 | 29 | function crc32(crc, buf, len, pos) { 30 | var t = crcTable, end = pos + len; 31 | 32 | crc = crc ^ (-1); 33 | 34 | for (var i = pos; i < end; i++ ) { 35 | crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; 36 | } 37 | 38 | return (crc ^ (-1)); // >>> 0; 39 | } 40 | 41 | // That's all for the pako functions. 42 | 43 | /** 44 | * Compute the crc32 of a string. 45 | * This is almost the same as the function crc32, but for strings. Using the 46 | * same function for the two use cases leads to horrible performances. 47 | * @param {Number} crc the starting value of the crc. 48 | * @param {String} str the string to use. 49 | * @param {Number} len the length of the string. 50 | * @param {Number} pos the starting position for the crc32 computation. 51 | * @return {Number} the computed crc32. 52 | */ 53 | function crc32str(crc, str, len, pos) { 54 | var t = crcTable, end = pos + len; 55 | 56 | crc = crc ^ (-1); 57 | 58 | for (var i = pos; i < end; i++ ) { 59 | crc = (crc >>> 8) ^ t[(crc ^ str.charCodeAt(i)) & 0xFF]; 60 | } 61 | 62 | return (crc ^ (-1)); // >>> 0; 63 | } 64 | 65 | module.exports = function crc32wrapper(input, crc) { 66 | if (typeof input === "undefined" || !input.length) { 67 | return 0; 68 | } 69 | 70 | var isArray = utils.getTypeOf(input) !== "string"; 71 | 72 | if(isArray) { 73 | return crc32(crc|0, input, input.length, 0); 74 | } else { 75 | return crc32str(crc|0, input, input.length, 0); 76 | } 77 | }; 78 | // vim: set shiftwidth=4 softtabstop=4: 79 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/defaults.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | exports.base64 = false; 3 | exports.binary = false; 4 | exports.dir = false; 5 | exports.createFolders = true; 6 | exports.date = null; 7 | exports.compression = null; 8 | exports.compressionOptions = null; 9 | exports.comment = null; 10 | exports.unixPermissions = null; 11 | exports.dosPermissions = null; 12 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/external.js: -------------------------------------------------------------------------------- 1 | /* global Promise */ 2 | 'use strict'; 3 | 4 | // load the global object first: 5 | // - it should be better integrated in the system (unhandledRejection in node) 6 | // - the environment may have a custom Promise implementation (see zone.js) 7 | var ES6Promise = null; 8 | if (typeof Promise !== "undefined") { 9 | ES6Promise = Promise; 10 | } else { 11 | ES6Promise = require("lie"); 12 | } 13 | 14 | /** 15 | * Let the user use/change some implementations. 16 | */ 17 | module.exports = { 18 | Promise: ES6Promise 19 | }; 20 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/flate.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var USE_TYPEDARRAY = (typeof Uint8Array !== 'undefined') && (typeof Uint16Array !== 'undefined') && (typeof Uint32Array !== 'undefined'); 3 | 4 | var pako = require("pako"); 5 | var utils = require("./utils"); 6 | var GenericWorker = require("./stream/GenericWorker"); 7 | 8 | var ARRAY_TYPE = USE_TYPEDARRAY ? "uint8array" : "array"; 9 | 10 | exports.magic = "\x08\x00"; 11 | 12 | /** 13 | * Create a worker that uses pako to inflate/deflate. 14 | * @constructor 15 | * @param {String} action the name of the pako function to call : either "Deflate" or "Inflate". 16 | * @param {Object} options the options to use when (de)compressing. 17 | */ 18 | function FlateWorker(action, options) { 19 | GenericWorker.call(this, "FlateWorker/" + action); 20 | 21 | this._pako = new pako[action]({ 22 | raw:true, 23 | level : options.level || -1 // default compression 24 | }); 25 | // the `meta` object from the last chunk received 26 | // this allow this worker to pass around metadata 27 | this.meta = {}; 28 | 29 | var self = this; 30 | this._pako.onData = function(data) { 31 | self.push({ 32 | data : data, 33 | meta : self.meta 34 | }); 35 | }; 36 | } 37 | 38 | utils.inherits(FlateWorker, GenericWorker); 39 | 40 | /** 41 | * @see GenericWorker.processChunk 42 | */ 43 | FlateWorker.prototype.processChunk = function (chunk) { 44 | this.meta = chunk.meta; 45 | this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false); 46 | }; 47 | 48 | /** 49 | * @see GenericWorker.flush 50 | */ 51 | FlateWorker.prototype.flush = function () { 52 | GenericWorker.prototype.flush.call(this); 53 | this._pako.push([], true); 54 | }; 55 | /** 56 | * @see GenericWorker.cleanUp 57 | */ 58 | FlateWorker.prototype.cleanUp = function () { 59 | GenericWorker.prototype.cleanUp.call(this); 60 | this._pako = null; 61 | }; 62 | 63 | exports.compressWorker = function (compressionOptions) { 64 | return new FlateWorker("Deflate", compressionOptions); 65 | }; 66 | exports.uncompressWorker = function () { 67 | return new FlateWorker("Inflate", {}); 68 | }; 69 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/generate/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var compressions = require('../compressions'); 4 | var ZipFileWorker = require('./ZipFileWorker'); 5 | 6 | /** 7 | * Find the compression to use. 8 | * @param {String} fileCompression the compression defined at the file level, if any. 9 | * @param {String} zipCompression the compression defined at the load() level. 10 | * @return {Object} the compression object to use. 11 | */ 12 | var getCompression = function (fileCompression, zipCompression) { 13 | 14 | var compressionName = fileCompression || zipCompression; 15 | var compression = compressions[compressionName]; 16 | if (!compression) { 17 | throw new Error(compressionName + " is not a valid compression method !"); 18 | } 19 | return compression; 20 | }; 21 | 22 | /** 23 | * Create a worker to generate a zip file. 24 | * @param {JSZip} zip the JSZip instance at the right root level. 25 | * @param {Object} options to generate the zip file. 26 | * @param {String} comment the comment to use. 27 | */ 28 | exports.generateWorker = function (zip, options, comment) { 29 | 30 | var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName); 31 | var entriesCount = 0; 32 | try { 33 | 34 | zip.forEach(function (relativePath, file) { 35 | entriesCount++; 36 | var compression = getCompression(file.options.compression, options.compression); 37 | var compressionOptions = file.options.compressionOptions || options.compressionOptions || {}; 38 | var dir = file.dir, date = file.date; 39 | 40 | file._compressWorker(compression, compressionOptions) 41 | .withStreamInfo("file", { 42 | name : relativePath, 43 | dir : dir, 44 | date : date, 45 | comment : file.comment || "", 46 | unixPermissions : file.unixPermissions, 47 | dosPermissions : file.dosPermissions 48 | }) 49 | .pipe(zipFileWorker); 50 | }); 51 | zipFileWorker.entriesCount = entriesCount; 52 | } catch (e) { 53 | zipFileWorker.error(e); 54 | } 55 | 56 | return zipFileWorker; 57 | }; 58 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Representation a of zip file in js 5 | * @constructor 6 | */ 7 | function JSZip() { 8 | // if this constructor is used without `new`, it adds `new` before itself: 9 | if(!(this instanceof JSZip)) { 10 | return new JSZip(); 11 | } 12 | 13 | if(arguments.length) { 14 | throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide."); 15 | } 16 | 17 | // object containing the files : 18 | // { 19 | // "folder/" : {...}, 20 | // "folder/data.txt" : {...} 21 | // } 22 | this.files = {}; 23 | 24 | this.comment = null; 25 | 26 | // Where we are in the hierarchy 27 | this.root = ""; 28 | this.clone = function() { 29 | var newObj = new JSZip(); 30 | for (var i in this) { 31 | if (typeof this[i] !== "function") { 32 | newObj[i] = this[i]; 33 | } 34 | } 35 | return newObj; 36 | }; 37 | } 38 | JSZip.prototype = require('./object'); 39 | JSZip.prototype.loadAsync = require('./load'); 40 | JSZip.support = require('./support'); 41 | JSZip.defaults = require('./defaults'); 42 | 43 | // TODO find a better way to handle this version, 44 | // a require('package.json').version doesn't work with webpack, see #327 45 | JSZip.version = "3.1.3"; 46 | 47 | JSZip.loadAsync = function (content, options) { 48 | return new JSZip().loadAsync(content, options); 49 | }; 50 | 51 | JSZip.external = require("./external"); 52 | module.exports = JSZip; 53 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/license_header.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZip v__VERSION__ - A Javascript class for generating and reading zip files 4 | 5 | 6 | (c) 2009-2016 Stuart Knightley 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. 8 | 9 | JSZip uses the library pako released under the MIT license : 10 | https://github.com/nodeca/pako/blob/master/LICENSE 11 | */ 12 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/load.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var utils = require('./utils'); 3 | var external = require("./external"); 4 | var utf8 = require('./utf8'); 5 | var utils = require('./utils'); 6 | var ZipEntries = require('./zipEntries'); 7 | var Crc32Probe = require('./stream/Crc32Probe'); 8 | var nodejsUtils = require("./nodejsUtils"); 9 | 10 | /** 11 | * Check the CRC32 of an entry. 12 | * @param {ZipEntry} zipEntry the zip entry to check. 13 | * @return {Promise} the result. 14 | */ 15 | function checkEntryCRC32(zipEntry) { 16 | return new external.Promise(function (resolve, reject) { 17 | var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe()); 18 | worker.on("error", function (e) { 19 | reject(e); 20 | }) 21 | .on("end", function () { 22 | if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) { 23 | reject(new Error("Corrupted zip : CRC32 mismatch")); 24 | } else { 25 | resolve(); 26 | } 27 | }) 28 | .resume(); 29 | }); 30 | } 31 | 32 | module.exports = function(data, options) { 33 | var zip = this; 34 | options = utils.extend(options || {}, { 35 | base64: false, 36 | checkCRC32: false, 37 | optimizedBinaryString: false, 38 | createFolders: false, 39 | decodeFileName: utf8.utf8decode 40 | }); 41 | 42 | if (nodejsUtils.isNode && nodejsUtils.isStream(data)) { 43 | return external.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")); 44 | } 45 | 46 | return utils.prepareContent("the loaded zip file", data, true, options.optimizedBinaryString, options.base64) 47 | .then(function(data) { 48 | var zipEntries = new ZipEntries(options); 49 | zipEntries.load(data); 50 | return zipEntries; 51 | }).then(function checkCRC32(zipEntries) { 52 | var promises = [external.Promise.resolve(zipEntries)]; 53 | var files = zipEntries.files; 54 | if (options.checkCRC32) { 55 | for (var i = 0; i < files.length; i++) { 56 | promises.push(checkEntryCRC32(files[i])); 57 | } 58 | } 59 | return external.Promise.all(promises); 60 | }).then(function addFiles(results) { 61 | var zipEntries = results.shift(); 62 | var files = zipEntries.files; 63 | for (var i = 0; i < files.length; i++) { 64 | var input = files[i]; 65 | zip.file(input.fileNameStr, input.decompressed, { 66 | binary: true, 67 | optimizedBinaryString: true, 68 | date: input.date, 69 | dir: input.dir, 70 | comment : input.fileCommentStr.length ? input.fileCommentStr : null, 71 | unixPermissions : input.unixPermissions, 72 | dosPermissions : input.dosPermissions, 73 | createFolders: options.createFolders 74 | }); 75 | } 76 | if (zipEntries.zipComment.length) { 77 | zip.comment = zipEntries.zipComment; 78 | } 79 | 80 | return zip; 81 | }); 82 | }; 83 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/nodejs/NodejsStreamInputAdapter.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var utils = require('../utils'); 4 | var GenericWorker = require('../stream/GenericWorker'); 5 | 6 | /** 7 | * A worker that use a nodejs stream as source. 8 | * @constructor 9 | * @param {String} filename the name of the file entry for this stream. 10 | * @param {Readable} stream the nodejs stream. 11 | */ 12 | function NodejsStreamInputAdapter(filename, stream) { 13 | GenericWorker.call(this, "Nodejs stream input adapter for " + filename); 14 | this._upstreamEnded = false; 15 | this._bindStream(stream); 16 | } 17 | 18 | utils.inherits(NodejsStreamInputAdapter, GenericWorker); 19 | 20 | /** 21 | * Prepare the stream and bind the callbacks on it. 22 | * Do this ASAP on node 0.10 ! A lazy binding doesn't always work. 23 | * @param {Stream} stream the nodejs stream to use. 24 | */ 25 | NodejsStreamInputAdapter.prototype._bindStream = function (stream) { 26 | var self = this; 27 | this._stream = stream; 28 | stream.pause(); 29 | stream 30 | .on("data", function (chunk) { 31 | self.push({ 32 | data: chunk, 33 | meta : { 34 | percent : 0 35 | } 36 | }); 37 | }) 38 | .on("error", function (e) { 39 | if(self.isPaused) { 40 | this.generatedError = e; 41 | } else { 42 | self.error(e); 43 | } 44 | }) 45 | .on("end", function () { 46 | if(self.isPaused) { 47 | self._upstreamEnded = true; 48 | } else { 49 | self.end(); 50 | } 51 | }); 52 | }; 53 | NodejsStreamInputAdapter.prototype.pause = function () { 54 | if(!GenericWorker.prototype.pause.call(this)) { 55 | return false; 56 | } 57 | this._stream.pause(); 58 | return true; 59 | }; 60 | NodejsStreamInputAdapter.prototype.resume = function () { 61 | if(!GenericWorker.prototype.resume.call(this)) { 62 | return false; 63 | } 64 | 65 | if(this._upstreamEnded) { 66 | this.end(); 67 | } else { 68 | this._stream.resume(); 69 | } 70 | 71 | return true; 72 | }; 73 | 74 | module.exports = NodejsStreamInputAdapter; 75 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/nodejs/NodejsStreamOutputAdapter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Readable = require('readable-stream').Readable; 4 | 5 | var utils = require('../utils'); 6 | utils.inherits(NodejsStreamOutputAdapter, Readable); 7 | 8 | /** 9 | * A nodejs stream using a worker as source. 10 | * @see the SourceWrapper in http://nodejs.org/api/stream.html 11 | * @constructor 12 | * @param {StreamHelper} helper the helper wrapping the worker 13 | * @param {Object} options the nodejs stream options 14 | * @param {Function} updateCb the update callback. 15 | */ 16 | function NodejsStreamOutputAdapter(helper, options, updateCb) { 17 | Readable.call(this, options); 18 | this._helper = helper; 19 | 20 | var self = this; 21 | helper.on("data", function (data, meta) { 22 | if (!self.push(data)) { 23 | self._helper.pause(); 24 | } 25 | if(updateCb) { 26 | updateCb(meta); 27 | } 28 | }) 29 | .on("error", function(e) { 30 | self.emit('error', e); 31 | }) 32 | .on("end", function () { 33 | self.push(null); 34 | }); 35 | } 36 | 37 | 38 | NodejsStreamOutputAdapter.prototype._read = function() { 39 | this._helper.resume(); 40 | }; 41 | 42 | module.exports = NodejsStreamOutputAdapter; 43 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/nodejsUtils.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | /** 5 | * True if this is running in Nodejs, will be undefined in a browser. 6 | * In a browser, browserify won't include this file and the whole module 7 | * will be resolved an empty object. 8 | */ 9 | isNode : typeof Buffer !== "undefined", 10 | /** 11 | * Create a new nodejs Buffer. 12 | * @param {Object} data the data to pass to the constructor. 13 | * @param {String} encoding the encoding to use. 14 | * @return {Buffer} a new Buffer. 15 | */ 16 | newBuffer : function(data, encoding){ 17 | return new Buffer(data, encoding); 18 | }, 19 | /** 20 | * Find out if an object is a Buffer. 21 | * @param {Object} b the object to test. 22 | * @return {Boolean} true if the object is a Buffer, false otherwise. 23 | */ 24 | isBuffer : function(b){ 25 | return Buffer.isBuffer(b); 26 | }, 27 | 28 | isStream : function (obj) { 29 | return obj && 30 | typeof obj.on === "function" && 31 | typeof obj.pause === "function" && 32 | typeof obj.resume === "function"; 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/readable-stream-browser.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is used by module bundlers (browserify/webpack/etc) when 3 | * including a stream implementation. We use "readable-stream" to get a 4 | * consistent behavior between nodejs versions but bundlers often have a shim 5 | * for "stream". Using this shim greatly improve the compatibility and greatly 6 | * reduce the final size of the bundle (only one stream implementation, not 7 | * two). 8 | */ 9 | module.exports = require("stream"); 10 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/reader/ArrayReader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var DataReader = require('./DataReader'); 3 | var utils = require('../utils'); 4 | 5 | function ArrayReader(data) { 6 | DataReader.call(this, data); 7 | for(var i = 0; i < this.data.length; i++) { 8 | data[i] = data[i] & 0xFF; 9 | } 10 | } 11 | utils.inherits(ArrayReader, DataReader); 12 | /** 13 | * @see DataReader.byteAt 14 | */ 15 | ArrayReader.prototype.byteAt = function(i) { 16 | return this.data[this.zero + i]; 17 | }; 18 | /** 19 | * @see DataReader.lastIndexOfSignature 20 | */ 21 | ArrayReader.prototype.lastIndexOfSignature = function(sig) { 22 | var sig0 = sig.charCodeAt(0), 23 | sig1 = sig.charCodeAt(1), 24 | sig2 = sig.charCodeAt(2), 25 | sig3 = sig.charCodeAt(3); 26 | for (var i = this.length - 4; i >= 0; --i) { 27 | if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) { 28 | return i - this.zero; 29 | } 30 | } 31 | 32 | return -1; 33 | }; 34 | /** 35 | * @see DataReader.readAndCheckSignature 36 | */ 37 | ArrayReader.prototype.readAndCheckSignature = function (sig) { 38 | var sig0 = sig.charCodeAt(0), 39 | sig1 = sig.charCodeAt(1), 40 | sig2 = sig.charCodeAt(2), 41 | sig3 = sig.charCodeAt(3), 42 | data = this.readData(4); 43 | return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3]; 44 | }; 45 | /** 46 | * @see DataReader.readData 47 | */ 48 | ArrayReader.prototype.readData = function(size) { 49 | this.checkOffset(size); 50 | if(size === 0) { 51 | return []; 52 | } 53 | var result = this.data.slice(this.zero + this.index, this.zero + this.index + size); 54 | this.index += size; 55 | return result; 56 | }; 57 | module.exports = ArrayReader; 58 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/reader/DataReader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var utils = require('../utils'); 3 | 4 | function DataReader(data) { 5 | this.data = data; // type : see implementation 6 | this.length = data.length; 7 | this.index = 0; 8 | this.zero = 0; 9 | } 10 | DataReader.prototype = { 11 | /** 12 | * Check that the offset will not go too far. 13 | * @param {string} offset the additional offset to check. 14 | * @throws {Error} an Error if the offset is out of bounds. 15 | */ 16 | checkOffset: function(offset) { 17 | this.checkIndex(this.index + offset); 18 | }, 19 | /** 20 | * Check that the specifed index will not be too far. 21 | * @param {string} newIndex the index to check. 22 | * @throws {Error} an Error if the index is out of bounds. 23 | */ 24 | checkIndex: function(newIndex) { 25 | if (this.length < this.zero + newIndex || newIndex < 0) { 26 | throw new Error("End of data reached (data length = " + this.length + ", asked index = " + (newIndex) + "). Corrupted zip ?"); 27 | } 28 | }, 29 | /** 30 | * Change the index. 31 | * @param {number} newIndex The new index. 32 | * @throws {Error} if the new index is out of the data. 33 | */ 34 | setIndex: function(newIndex) { 35 | this.checkIndex(newIndex); 36 | this.index = newIndex; 37 | }, 38 | /** 39 | * Skip the next n bytes. 40 | * @param {number} n the number of bytes to skip. 41 | * @throws {Error} if the new index is out of the data. 42 | */ 43 | skip: function(n) { 44 | this.setIndex(this.index + n); 45 | }, 46 | /** 47 | * Get the byte at the specified index. 48 | * @param {number} i the index to use. 49 | * @return {number} a byte. 50 | */ 51 | byteAt: function(i) { 52 | // see implementations 53 | }, 54 | /** 55 | * Get the next number with a given byte size. 56 | * @param {number} size the number of bytes to read. 57 | * @return {number} the corresponding number. 58 | */ 59 | readInt: function(size) { 60 | var result = 0, 61 | i; 62 | this.checkOffset(size); 63 | for (i = this.index + size - 1; i >= this.index; i--) { 64 | result = (result << 8) + this.byteAt(i); 65 | } 66 | this.index += size; 67 | return result; 68 | }, 69 | /** 70 | * Get the next string with a given byte size. 71 | * @param {number} size the number of bytes to read. 72 | * @return {string} the corresponding string. 73 | */ 74 | readString: function(size) { 75 | return utils.transformTo("string", this.readData(size)); 76 | }, 77 | /** 78 | * Get raw data without conversion, bytes. 79 | * @param {number} size the number of bytes to read. 80 | * @return {Object} the raw data, implementation specific. 81 | */ 82 | readData: function(size) { 83 | // see implementations 84 | }, 85 | /** 86 | * Find the last occurence of a zip signature (4 bytes). 87 | * @param {string} sig the signature to find. 88 | * @return {number} the index of the last occurence, -1 if not found. 89 | */ 90 | lastIndexOfSignature: function(sig) { 91 | // see implementations 92 | }, 93 | /** 94 | * Read the signature (4 bytes) at the current position and compare it with sig. 95 | * @param {string} sig the expected signature 96 | * @return {boolean} true if the signature matches, false otherwise. 97 | */ 98 | readAndCheckSignature: function(sig) { 99 | // see implementations 100 | }, 101 | /** 102 | * Get the next date. 103 | * @return {Date} the date. 104 | */ 105 | readDate: function() { 106 | var dostime = this.readInt(4); 107 | return new Date(Date.UTC( 108 | ((dostime >> 25) & 0x7f) + 1980, // year 109 | ((dostime >> 21) & 0x0f) - 1, // month 110 | (dostime >> 16) & 0x1f, // day 111 | (dostime >> 11) & 0x1f, // hour 112 | (dostime >> 5) & 0x3f, // minute 113 | (dostime & 0x1f) << 1)); // second 114 | } 115 | }; 116 | module.exports = DataReader; 117 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/reader/NodeBufferReader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var Uint8ArrayReader = require('./Uint8ArrayReader'); 3 | var utils = require('../utils'); 4 | 5 | function NodeBufferReader(data) { 6 | Uint8ArrayReader.call(this, data); 7 | } 8 | utils.inherits(NodeBufferReader, Uint8ArrayReader); 9 | 10 | /** 11 | * @see DataReader.readData 12 | */ 13 | NodeBufferReader.prototype.readData = function(size) { 14 | this.checkOffset(size); 15 | var result = this.data.slice(this.zero + this.index, this.zero + this.index + size); 16 | this.index += size; 17 | return result; 18 | }; 19 | module.exports = NodeBufferReader; 20 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/reader/StringReader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var DataReader = require('./DataReader'); 3 | var utils = require('../utils'); 4 | 5 | function StringReader(data) { 6 | DataReader.call(this, data); 7 | } 8 | utils.inherits(StringReader, DataReader); 9 | /** 10 | * @see DataReader.byteAt 11 | */ 12 | StringReader.prototype.byteAt = function(i) { 13 | return this.data.charCodeAt(this.zero + i); 14 | }; 15 | /** 16 | * @see DataReader.lastIndexOfSignature 17 | */ 18 | StringReader.prototype.lastIndexOfSignature = function(sig) { 19 | return this.data.lastIndexOf(sig) - this.zero; 20 | }; 21 | /** 22 | * @see DataReader.readAndCheckSignature 23 | */ 24 | StringReader.prototype.readAndCheckSignature = function (sig) { 25 | var data = this.readData(4); 26 | return sig === data; 27 | }; 28 | /** 29 | * @see DataReader.readData 30 | */ 31 | StringReader.prototype.readData = function(size) { 32 | this.checkOffset(size); 33 | // this will work because the constructor applied the "& 0xff" mask. 34 | var result = this.data.slice(this.zero + this.index, this.zero + this.index + size); 35 | this.index += size; 36 | return result; 37 | }; 38 | module.exports = StringReader; 39 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/reader/Uint8ArrayReader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var ArrayReader = require('./ArrayReader'); 3 | var utils = require('../utils'); 4 | 5 | function Uint8ArrayReader(data) { 6 | ArrayReader.call(this, data); 7 | } 8 | utils.inherits(Uint8ArrayReader, ArrayReader); 9 | /** 10 | * @see DataReader.readData 11 | */ 12 | Uint8ArrayReader.prototype.readData = function(size) { 13 | this.checkOffset(size); 14 | if(size === 0) { 15 | // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of []. 16 | return new Uint8Array(0); 17 | } 18 | var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size); 19 | this.index += size; 20 | return result; 21 | }; 22 | module.exports = Uint8ArrayReader; 23 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/reader/readerFor.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../utils'); 4 | var support = require('../support'); 5 | var ArrayReader = require('./ArrayReader'); 6 | var StringReader = require('./StringReader'); 7 | var NodeBufferReader = require('./NodeBufferReader'); 8 | var Uint8ArrayReader = require('./Uint8ArrayReader'); 9 | 10 | /** 11 | * Create a reader adapted to the data. 12 | * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read. 13 | * @return {DataReader} the data reader. 14 | */ 15 | module.exports = function (data) { 16 | var type = utils.getTypeOf(data); 17 | utils.checkSupport(type); 18 | if (type === "string" && !support.uint8array) { 19 | return new StringReader(data); 20 | } 21 | if (type === "nodebuffer") { 22 | return new NodeBufferReader(data); 23 | } 24 | if (support.uint8array) { 25 | return new Uint8ArrayReader(utils.transformTo("uint8array", data)); 26 | } 27 | return new ArrayReader(utils.transformTo("array", data)); 28 | }; 29 | 30 | // vim: set shiftwidth=4 softtabstop=4: 31 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/signature.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | exports.LOCAL_FILE_HEADER = "PK\x03\x04"; 3 | exports.CENTRAL_FILE_HEADER = "PK\x01\x02"; 4 | exports.CENTRAL_DIRECTORY_END = "PK\x05\x06"; 5 | exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07"; 6 | exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06"; 7 | exports.DATA_DESCRIPTOR = "PK\x07\x08"; 8 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/stream/ConvertWorker.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var GenericWorker = require('./GenericWorker'); 4 | var utils = require('../utils'); 5 | 6 | /** 7 | * A worker which convert chunks to a specified type. 8 | * @constructor 9 | * @param {String} destType the destination type. 10 | */ 11 | function ConvertWorker(destType) { 12 | GenericWorker.call(this, "ConvertWorker to " + destType); 13 | this.destType = destType; 14 | } 15 | utils.inherits(ConvertWorker, GenericWorker); 16 | 17 | /** 18 | * @see GenericWorker.processChunk 19 | */ 20 | ConvertWorker.prototype.processChunk = function (chunk) { 21 | this.push({ 22 | data : utils.transformTo(this.destType, chunk.data), 23 | meta : chunk.meta 24 | }); 25 | }; 26 | module.exports = ConvertWorker; 27 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/stream/Crc32Probe.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var GenericWorker = require('./GenericWorker'); 4 | var crc32 = require('../crc32'); 5 | var utils = require('../utils'); 6 | 7 | /** 8 | * A worker which calculate the crc32 of the data flowing through. 9 | * @constructor 10 | */ 11 | function Crc32Probe() { 12 | GenericWorker.call(this, "Crc32Probe"); 13 | this.withStreamInfo("crc32", 0); 14 | } 15 | utils.inherits(Crc32Probe, GenericWorker); 16 | 17 | /** 18 | * @see GenericWorker.processChunk 19 | */ 20 | Crc32Probe.prototype.processChunk = function (chunk) { 21 | this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0); 22 | this.push(chunk); 23 | }; 24 | module.exports = Crc32Probe; 25 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/stream/DataLengthProbe.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../utils'); 4 | var GenericWorker = require('./GenericWorker'); 5 | 6 | /** 7 | * A worker which calculate the total length of the data flowing through. 8 | * @constructor 9 | * @param {String} propName the name used to expose the length 10 | */ 11 | function DataLengthProbe(propName) { 12 | GenericWorker.call(this, "DataLengthProbe for " + propName); 13 | this.propName = propName; 14 | this.withStreamInfo(propName, 0); 15 | } 16 | utils.inherits(DataLengthProbe, GenericWorker); 17 | 18 | /** 19 | * @see GenericWorker.processChunk 20 | */ 21 | DataLengthProbe.prototype.processChunk = function (chunk) { 22 | if(chunk) { 23 | var length = this.streamInfo[this.propName] || 0; 24 | this.streamInfo[this.propName] = length + chunk.data.length; 25 | } 26 | GenericWorker.prototype.processChunk.call(this, chunk); 27 | }; 28 | module.exports = DataLengthProbe; 29 | 30 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/stream/DataWorker.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../utils'); 4 | var GenericWorker = require('./GenericWorker'); 5 | 6 | // the size of the generated chunks 7 | // TODO expose this as a public variable 8 | var DEFAULT_BLOCK_SIZE = 16 * 1024; 9 | 10 | /** 11 | * A worker that reads a content and emits chunks. 12 | * @constructor 13 | * @param {Promise} dataP the promise of the data to split 14 | */ 15 | function DataWorker(dataP) { 16 | GenericWorker.call(this, "DataWorker"); 17 | var self = this; 18 | this.dataIsReady = false; 19 | this.index = 0; 20 | this.max = 0; 21 | this.data = null; 22 | this.type = ""; 23 | 24 | this._tickScheduled = false; 25 | 26 | dataP.then(function (data) { 27 | self.dataIsReady = true; 28 | self.data = data; 29 | self.max = data && data.length || 0; 30 | self.type = utils.getTypeOf(data); 31 | if(!self.isPaused) { 32 | self._tickAndRepeat(); 33 | } 34 | }, function (e) { 35 | self.error(e); 36 | }); 37 | } 38 | 39 | utils.inherits(DataWorker, GenericWorker); 40 | 41 | /** 42 | * @see GenericWorker.cleanUp 43 | */ 44 | DataWorker.prototype.cleanUp = function () { 45 | GenericWorker.prototype.cleanUp.call(this); 46 | this.data = null; 47 | }; 48 | 49 | /** 50 | * @see GenericWorker.resume 51 | */ 52 | DataWorker.prototype.resume = function () { 53 | if(!GenericWorker.prototype.resume.call(this)) { 54 | return false; 55 | } 56 | 57 | if (!this._tickScheduled && this.dataIsReady) { 58 | this._tickScheduled = true; 59 | utils.delay(this._tickAndRepeat, [], this); 60 | } 61 | return true; 62 | }; 63 | 64 | /** 65 | * Trigger a tick a schedule an other call to this function. 66 | */ 67 | DataWorker.prototype._tickAndRepeat = function() { 68 | this._tickScheduled = false; 69 | if(this.isPaused || this.isFinished) { 70 | return; 71 | } 72 | this._tick(); 73 | if(!this.isFinished) { 74 | utils.delay(this._tickAndRepeat, [], this); 75 | this._tickScheduled = true; 76 | } 77 | }; 78 | 79 | /** 80 | * Read and push a chunk. 81 | */ 82 | DataWorker.prototype._tick = function() { 83 | 84 | if(this.isPaused || this.isFinished) { 85 | return false; 86 | } 87 | 88 | var size = DEFAULT_BLOCK_SIZE; 89 | var data = null, nextIndex = Math.min(this.max, this.index + size); 90 | if (this.index >= this.max) { 91 | // EOF 92 | return this.end(); 93 | } else { 94 | switch(this.type) { 95 | case "string": 96 | data = this.data.substring(this.index, nextIndex); 97 | break; 98 | case "uint8array": 99 | data = this.data.subarray(this.index, nextIndex); 100 | break; 101 | case "array": 102 | case "nodebuffer": 103 | data = this.data.slice(this.index, nextIndex); 104 | break; 105 | } 106 | this.index = nextIndex; 107 | return this.push({ 108 | data : data, 109 | meta : { 110 | percent : this.max ? this.index / this.max * 100 : 0 111 | } 112 | }); 113 | } 114 | }; 115 | 116 | module.exports = DataWorker; 117 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/support.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.base64 = true; 4 | exports.array = true; 5 | exports.string = true; 6 | exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined"; 7 | exports.nodebuffer = typeof Buffer !== "undefined"; 8 | // contains true if JSZip can read/generate Uint8Array, false otherwise. 9 | exports.uint8array = typeof Uint8Array !== "undefined"; 10 | 11 | if (typeof ArrayBuffer === "undefined") { 12 | exports.blob = false; 13 | } 14 | else { 15 | var buffer = new ArrayBuffer(0); 16 | try { 17 | exports.blob = new Blob([buffer], { 18 | type: "application/zip" 19 | }).size === 0; 20 | } 21 | catch (e) { 22 | try { 23 | var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder; 24 | var builder = new Builder(); 25 | builder.append(buffer); 26 | exports.blob = builder.getBlob('application/zip').size === 0; 27 | } 28 | catch (e) { 29 | exports.blob = false; 30 | } 31 | } 32 | } 33 | 34 | try { 35 | exports.nodestream = !!require('readable-stream').Readable; 36 | } catch(e) { 37 | exports.nodestream = false; 38 | } 39 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/lib/zipObject.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var StreamHelper = require('./stream/StreamHelper'); 4 | var DataWorker = require('./stream/DataWorker'); 5 | var utf8 = require('./utf8'); 6 | var CompressedObject = require('./compressedObject'); 7 | var GenericWorker = require('./stream/GenericWorker'); 8 | 9 | /** 10 | * A simple object representing a file in the zip file. 11 | * @constructor 12 | * @param {string} name the name of the file 13 | * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data 14 | * @param {Object} options the options of the file 15 | */ 16 | var ZipObject = function(name, data, options) { 17 | this.name = name; 18 | this.dir = options.dir; 19 | this.date = options.date; 20 | this.comment = options.comment; 21 | this.unixPermissions = options.unixPermissions; 22 | this.dosPermissions = options.dosPermissions; 23 | 24 | this._data = data; 25 | this._dataBinary = options.binary; 26 | // keep only the compression 27 | this.options = { 28 | compression : options.compression, 29 | compressionOptions : options.compressionOptions 30 | }; 31 | }; 32 | 33 | ZipObject.prototype = { 34 | /** 35 | * Create an internal stream for the content of this object. 36 | * @param {String} type the type of each chunk. 37 | * @return StreamHelper the stream. 38 | */ 39 | internalStream: function (type) { 40 | var outputType = type.toLowerCase(); 41 | var askUnicodeString = outputType === "string" || outputType === "text"; 42 | if (outputType === "binarystring" || outputType === "text") { 43 | outputType = "string"; 44 | } 45 | var result = this._decompressWorker(); 46 | 47 | var isUnicodeString = !this._dataBinary; 48 | 49 | if (isUnicodeString && !askUnicodeString) { 50 | result = result.pipe(new utf8.Utf8EncodeWorker()); 51 | } 52 | if (!isUnicodeString && askUnicodeString) { 53 | result = result.pipe(new utf8.Utf8DecodeWorker()); 54 | } 55 | 56 | return new StreamHelper(result, outputType, ""); 57 | }, 58 | 59 | /** 60 | * Prepare the content in the asked type. 61 | * @param {String} type the type of the result. 62 | * @param {Function} onUpdate a function to call on each internal update. 63 | * @return Promise the promise of the result. 64 | */ 65 | async: function (type, onUpdate) { 66 | return this.internalStream(type).accumulate(onUpdate); 67 | }, 68 | 69 | /** 70 | * Prepare the content as a nodejs stream. 71 | * @param {String} type the type of each chunk. 72 | * @param {Function} onUpdate a function to call on each internal update. 73 | * @return Stream the stream. 74 | */ 75 | nodeStream: function (type, onUpdate) { 76 | return this.internalStream(type || "nodebuffer").toNodejsStream(onUpdate); 77 | }, 78 | 79 | /** 80 | * Return a worker for the compressed content. 81 | * @private 82 | * @param {Object} compression the compression object to use. 83 | * @param {Object} compressionOptions the options to use when compressing. 84 | * @return Worker the worker. 85 | */ 86 | _compressWorker: function (compression, compressionOptions) { 87 | if ( 88 | this._data instanceof CompressedObject && 89 | this._data.compression.magic === compression.magic 90 | ) { 91 | return this._data.getCompressedWorker(); 92 | } else { 93 | var result = this._decompressWorker(); 94 | if(!this._dataBinary) { 95 | result = result.pipe(new utf8.Utf8EncodeWorker()); 96 | } 97 | return CompressedObject.createWorkerFrom(result, compression, compressionOptions); 98 | } 99 | }, 100 | /** 101 | * Return a worker for the decompressed content. 102 | * @private 103 | * @return Worker the worker. 104 | */ 105 | _decompressWorker : function () { 106 | if (this._data instanceof CompressedObject) { 107 | return this._data.getContentWorker(); 108 | } else if (this._data instanceof GenericWorker) { 109 | return this._data; 110 | } else { 111 | return new DataWorker(this._data); 112 | } 113 | } 114 | }; 115 | 116 | var removedMethods = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"]; 117 | var removedFn = function () { 118 | throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); 119 | }; 120 | 121 | for(var i = 0; i < removedMethods.length; i++) { 122 | ZipObject.prototype[removedMethods[i]] = removedFn; 123 | } 124 | module.exports = ZipObject; 125 | -------------------------------------------------------------------------------- /lib/express/views/static/jszip/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jszip", 3 | "version": "3.1.3", 4 | "author": "Stuart Knightley ", 5 | "description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip", 6 | "scripts": { 7 | "test": "npm run test-node && npm run test-browser", 8 | "test-node": "qunit-cli -c test/helpers/test-utils.js test/helpers/node-test-utils.js test/asserts/*.js", 9 | "test-browser": "grunt build && grunt test", 10 | "lint": "grunt jshint" 11 | }, 12 | "contributors": [ 13 | { 14 | "name": "Franz Buchinger" 15 | }, 16 | { 17 | "name": "António Afonso" 18 | }, 19 | { 20 | "name": "David Duponchel" 21 | }, 22 | { 23 | "name": "yiminghe" 24 | } 25 | ], 26 | "main": "./lib/index", 27 | "browser": { 28 | "readable-stream": "./lib/readable-stream-browser.js" 29 | }, 30 | "repository": { 31 | "type": "git", 32 | "url": "https://github.com/Stuk/jszip.git" 33 | }, 34 | "keywords": [ 35 | "zip", 36 | "deflate", 37 | "inflate" 38 | ], 39 | "devDependencies": { 40 | "grunt": "~0.4.1", 41 | "grunt-cli": "~1.1.0", 42 | "grunt-saucelabs": "~8.6.2", 43 | "grunt-contrib-connect": "1.0.0", 44 | "jshint": "~2.9.1", 45 | "browserify": "~13.0.0", 46 | "grunt-browserify": "~5.0.0", 47 | "grunt-contrib-jshint": "~1.0.0", 48 | "grunt-contrib-qunit": "~1.2.0", 49 | "grunt-contrib-uglify": "~1.0.0", 50 | "jszip-utils": "~0.0.2", 51 | "package-json-versionify": "~1.0.2", 52 | "qunit-cli": "~0.2.0", 53 | "qunitjs": "~1.23.0", 54 | "tmp": "0.0.28" 55 | }, 56 | "dependencies": { 57 | "core-js": "~2.3.0", 58 | "es6-promise": "~3.0.2", 59 | "lie": "~3.1.0", 60 | "pako": "~1.0.2", 61 | "readable-stream": "~2.0.6" 62 | }, 63 | "license": "(MIT OR GPL-3.0)" 64 | } 65 | -------------------------------------------------------------------------------- /lib/express/views/static/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name: layui.code 4 | @Author: 贤心 5 | @Site: http://www.layui.com 6 | 7 | */ 8 | 9 | /* 加载就绪标志 */ 10 | html #layuicss-skincodecss{display:none; position: absolute; width:1989px;} 11 | 12 | /* 默认风格 */ 13 | .layui-code-view{display: block; position: relative; margin: 10px 0; padding: 0; border: 1px solid #ddd; border-left-width: 6px; background-color: #F2F2F2; color: #333; font-family: Courier New; font-size: 12px;} 14 | .layui-code-h3{position: relative; padding: 0 10px; height: 30px; line-height: 30px; border-bottom: 1px solid #ddd; font-size: 12px;} 15 | .layui-code-h3 a{position: absolute; right: 10px; top: 0; color: #999;} 16 | .layui-code-view .layui-code-ol{position: relative; overflow: auto;} 17 | .layui-code-view .layui-code-ol li{position: relative; margin-left: 45px; line-height: 20px; padding: 0 5px; border-left: 1px solid #ddd; list-style-type: decimal-leading-zero; *list-style-type: decimal; background-color: #fff;} 18 | .layui-code-view pre{margin: 0;} 19 | 20 | /* notepadd++风格 */ 21 | .layui-code-notepad{border: 1px solid #0C0C0C; border-left-color: #3F3F3F; background-color: #0C0C0C; color: #C2BE9E} 22 | .layui-code-notepad .layui-code-h3{border-bottom: none;} 23 | .layui-code-notepad .layui-code-ol li{background-color: #3F3F3F; border-left: none;} -------------------------------------------------------------------------------- /lib/express/views/static/layui/css/modules/laydate/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/css/modules/laydate/icon.png -------------------------------------------------------------------------------- /lib/express/views/static/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /lib/express/views/static/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /lib/express/views/static/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/font/iconfont.eot -------------------------------------------------------------------------------- /lib/express/views/static/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /lib/express/views/static/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/font/iconfont.woff -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/0.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/1.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/10.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/11.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/12.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/13.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/14.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/15.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/16.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/17.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/18.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/19.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/2.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/20.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/21.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/22.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/23.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/24.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/25.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/26.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/27.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/28.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/29.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/3.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/30.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/31.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/32.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/33.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/34.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/35.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/36.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/37.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/38.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/39.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/4.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/40.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/41.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/42.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/43.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/44.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/45.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/46.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/47.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/48.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/49.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/5.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/50.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/51.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/52.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/53.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/54.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/55.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/56.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/57.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/58.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/59.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/6.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/60.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/61.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/62.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/63.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/64.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/65.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/66.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/67.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/68.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/69.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/7.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/70.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/71.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/8.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/layui/images/face/9.gif -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/all-mobile.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:用于打包移动完整版 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | exports('layui.mobile', layui.v); 11 | }); 12 | -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/all.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:用于打包PC完整版,即包含layui.js和所有模块的完整合并(该文件不会存在于构建后的目录) 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | var cache = layui.cache; 11 | layui.config({ 12 | dir: cache.dir.replace(/lay\/dest\/$/, '') 13 | }); 14 | exports('layui.all', layui.v); 15 | }); 16 | -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.code 代码修饰器 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.jquery; 13 | var about = 'http://www.layui.com/doc/modules/code.html'; //关于信息 14 | 15 | exports('code', function(options){ 16 | var elems = []; 17 | options = options || {}; 18 | options.elem = $(options.elem||'.layui-code'); 19 | options.about = 'about' in options ? options.about : true; 20 | 21 | options.elem.each(function(){ 22 | elems.push(this); 23 | }); 24 | 25 | layui.each(elems.reverse(), function(index, item){ 26 | var othis = $(item), html = othis.html(); 27 | 28 | //转义HTML标签 29 | if(othis.attr('lay-encode') || options.encode){ 30 | html = html.replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') 31 | .replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"') 32 | } 33 | 34 | othis.html('
  1. ' + html.replace(/[\r\t\n]+/g, '
  2. ') + '
') 35 | 36 | if(!othis.find('>.layui-code-h3')[0]){ 37 | othis.prepend('

'+ (othis.attr('lay-title')||options.title||'code') + (options.about ? 'layui.code' : '') + '

'); 38 | } 39 | 40 | var ol = othis.find('>.layui-code-ol'); 41 | othis.addClass('layui-box layui-code-view'); 42 | 43 | //识别皮肤 44 | if(othis.attr('lay-skin') || options.skin){ 45 | othis.addClass('layui-code-' +(othis.attr('lay-skin') || options.skin)); 46 | } 47 | 48 | //按行数适配左边距 49 | if((ol.find('li').length/100|0) > 0){ 50 | ol.css('margin-left', (ol.find('li').length/100|0) + 'px'); 51 | } 52 | 53 | //设置最大高度 54 | if(othis.attr('lay-height') || options.height){ 55 | ol.css('max-height', othis.attr('lay-height') || options.height); 56 | } 57 | 58 | }); 59 | 60 | }); 61 | }).addcss('modules/code.css', 'skincodecss'); -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.flow 流加载 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | 10 | layui.define('jquery', function(exports){ 11 | "use strict"; 12 | 13 | var $ = layui.jquery, Flow = function(options){} 14 | ,ELEM_MORE = 'layui-flow-more' 15 | ,ELEM_LOAD = ''; 16 | 17 | //主方法 18 | Flow.prototype.load = function(options){ 19 | var that = this, page = 0, lock, isOver, lazyimg, timer; 20 | options = options || {}; 21 | 22 | var elem = $(options.elem); if(!elem[0]) return; 23 | var scrollElem = $(options.scrollElem || document); //滚动条所在元素 24 | var mb = options.mb || 50; //与底部的临界距离 25 | var isAuto = 'isAuto' in options ? options.isAuto : true; //是否自动滚动加载 26 | var end = options.end || '没有更多了'; //“末页”显示文案 27 | 28 | //滚动条所在元素是否为document 29 | var notDocment = options.scrollElem && options.scrollElem !== document; 30 | 31 | //加载更多 32 | var ELEM_TEXT = '加载更多' 33 | ,more = $(''); 34 | 35 | if(!elem.find('.layui-flow-more')[0]){ 36 | elem.append(more); 37 | } 38 | 39 | //加载下一个元素 40 | var next = function(html, over){ 41 | html = $(html); 42 | more.before(html); 43 | over = over == 0 ? true : null; 44 | over ? more.html(end) : more.find('a').html(ELEM_TEXT); 45 | isOver = over; 46 | lock = null; 47 | lazyimg && lazyimg(); 48 | }; 49 | 50 | //触发请求 51 | var done = function(){ 52 | lock = true; 53 | more.find('a').html(ELEM_LOAD); 54 | typeof options.done === 'function' && options.done(++page, next); 55 | }; 56 | 57 | done(); 58 | 59 | //不自动滚动加载 60 | more.find('a').on('click', function(){ 61 | var othis = $(this); 62 | if(isOver) return; 63 | lock || done(); 64 | }); 65 | 66 | //如果允许图片懒加载 67 | if(options.isLazyimg){ 68 | var lazyimg = that.lazyimg({ 69 | elem: options.elem + ' img' 70 | ,scrollElem: options.scrollElem 71 | }); 72 | } 73 | 74 | if(!isAuto) return that; 75 | 76 | scrollElem.on('scroll', function(){ 77 | var othis = $(this), top = othis.scrollTop(); 78 | 79 | if(timer) clearTimeout(timer); 80 | if(isOver) return; 81 | 82 | timer = setTimeout(function(){ 83 | //计算滚动所在容器的可视高度 84 | var height = notDocment ? othis.height() : $(window).height(); 85 | 86 | //计算滚动所在容器的实际高度 87 | var scrollHeight = notDocment 88 | ? othis.prop('scrollHeight') 89 | : document.documentElement.scrollHeight; 90 | 91 | //临界点 92 | if(scrollHeight - top - height <= mb){ 93 | lock || done(); 94 | } 95 | }, 100); 96 | }); 97 | return that; 98 | }; 99 | 100 | //图片懒加载 101 | Flow.prototype.lazyimg = function(options){ 102 | var that = this, index = 0, haveScroll; 103 | options = options || {}; 104 | 105 | var scrollElem = $(options.scrollElem || document); //滚动条所在元素 106 | var elem = options.elem || 'img'; 107 | 108 | //滚动条所在元素是否为document 109 | var notDocment = options.scrollElem && options.scrollElem !== document; 110 | 111 | //显示图片 112 | var show = function(item, height){ 113 | var start = scrollElem.scrollTop(), end = start + height; 114 | var elemTop = notDocment ? function(){ 115 | return item.offset().top - scrollElem.offset().top + start; 116 | }() : item.offset().top; 117 | 118 | /* 始终只加载在当前屏范围内的图片 */ 119 | if(elemTop >= start && elemTop <= end){ 120 | if(!item.attr('src')){ 121 | var src = item.attr('lay-src'); 122 | layui.img(src, function(){ 123 | var next = that.lazyimg.elem.eq(index); 124 | item.attr('src', src).removeAttr('lay-src'); 125 | 126 | /* 当前图片加载就绪后,检测下一个图片是否在当前屏 */ 127 | next[0] && render(next); 128 | index++; 129 | }); 130 | } 131 | } 132 | }, render = function(othis, scroll){ 133 | 134 | //计算滚动所在容器的可视高度 135 | var height = notDocment ? (scroll||scrollElem).height() : $(window).height(); 136 | var start = scrollElem.scrollTop(), end = start + height; 137 | 138 | that.lazyimg.elem = $(elem); 139 | 140 | if(othis){ 141 | show(othis, height); 142 | } else { 143 | //计算未加载过的图片 144 | for(var i = 0; i < that.lazyimg.elem.length; i++){ 145 | var item = that.lazyimg.elem.eq(i), elemTop = notDocment ? function(){ 146 | return item.offset().top - scrollElem.offset().top + start; 147 | }() : item.offset().top; 148 | 149 | show(item, height); 150 | index = i; 151 | 152 | //如果图片的top坐标,超出了当前屏,则终止后续图片的遍历 153 | if(elemTop > end) break; 154 | } 155 | } 156 | }; 157 | 158 | render(); 159 | 160 | if(!haveScroll){ 161 | var timer; 162 | scrollElem.on('scroll', function(){ 163 | var othis = $(this); 164 | if(timer) clearTimeout(timer) 165 | timer = setTimeout(function(){ 166 | render(null, othis); 167 | }, 50); 168 | }); 169 | haveScroll = true; 170 | } 171 | return render; 172 | }; 173 | 174 | //暴露接口 175 | exports('flow', new Flow()); 176 | }); 177 | -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name : layui.laytpl 模板引擎 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | 11 | "use strict"; 12 | 13 | var config = { 14 | open: '{{', 15 | close: '}}' 16 | }; 17 | 18 | var tool = { 19 | exp: function(str){ 20 | return new RegExp(str, 'g'); 21 | }, 22 | //匹配满足规则内容 23 | query: function(type, _, __){ 24 | var types = [ 25 | '#([\\s\\S])+?', //js语句 26 | '([^{#}])*?' //普通字段 27 | ][type || 0]; 28 | return exp((_||'') + config.open + types + config.close + (__||'')); 29 | }, 30 | escape: function(html){ 31 | return String(html||'').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') 32 | .replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); 33 | }, 34 | error: function(e, tplog){ 35 | var error = 'Laytpl Error:'; 36 | typeof console === 'object' && console.error(error + e + '\n'+ (tplog || '')); 37 | return error + e; 38 | } 39 | }; 40 | 41 | var exp = tool.exp, Tpl = function(tpl){ 42 | this.tpl = tpl; 43 | }; 44 | 45 | Tpl.pt = Tpl.prototype; 46 | 47 | window.errors = 0; 48 | 49 | //编译模版 50 | Tpl.pt.parse = function(tpl, data){ 51 | var that = this, tplog = tpl; 52 | var jss = exp('^'+config.open+'#', ''), jsse = exp(config.close+'$', ''); 53 | 54 | tpl = tpl.replace(/\s+|\r|\t|\n/g, ' ').replace(exp(config.open+'#'), config.open+'# ') 55 | 56 | .replace(exp(config.close+'}'), '} '+config.close).replace(/\\/g, '\\\\') 57 | 58 | .replace(/(?="|')/g, '\\').replace(tool.query(), function(str){ 59 | str = str.replace(jss, '').replace(jsse, ''); 60 | return '";' + str.replace(/\\/g, '') + ';view+="'; 61 | }) 62 | 63 | .replace(tool.query(1), function(str){ 64 | var start = '"+('; 65 | if(str.replace(/\s/g, '') === config.open+config.close){ 66 | return ''; 67 | } 68 | str = str.replace(exp(config.open+'|'+config.close), ''); 69 | if(/^=/.test(str)){ 70 | str = str.replace(/^=/, ''); 71 | start = '"+_escape_('; 72 | } 73 | return start + str.replace(/\\/g, '') + ')+"'; 74 | }); 75 | 76 | tpl = '"use strict";var view = "' + tpl + '";return view;'; 77 | 78 | try{ 79 | that.cache = tpl = new Function('d, _escape_', tpl); 80 | return tpl(data, tool.escape); 81 | } catch(e){ 82 | delete that.cache; 83 | return tool.error(e, tplog); 84 | } 85 | }; 86 | 87 | Tpl.pt.render = function(data, callback){ 88 | var that = this, tpl; 89 | if(!data) return tool.error('no data'); 90 | tpl = that.cache ? that.cache(data, tool.escape) : that.parse(that.tpl, data); 91 | if(!callback) return tpl; 92 | callback(tpl); 93 | }; 94 | 95 | var laytpl = function(tpl){ 96 | if(typeof tpl !== 'string') return tool.error('Template not found'); 97 | return new Tpl(tpl); 98 | }; 99 | 100 | laytpl.config = function(options){ 101 | options = options || {}; 102 | for(var i in options){ 103 | config[i] = options[i]; 104 | } 105 | }; 106 | 107 | laytpl.v = '1.2.0'; 108 | 109 | exports('laytpl', laytpl); 110 | 111 | }); -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/modules/mobile.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui 移动模块入口 | 构建后则为移动模块集合 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | 10 | if(!layui['layui.mobile']){ 11 | layui.config({ 12 | base: layui.cache.dir + 'lay/modules/mobile/' 13 | }).extend({ 14 | 'layer-mobile': 'layer-mobile' 15 | ,'zepto': 'zepto' 16 | ,'upload-mobile': 'upload-mobile' 17 | ,'layim-mobile': 'layim-mobile' 18 | }); 19 | } 20 | 21 | layui.define([ 22 | 'layer-mobile' 23 | ,'zepto' 24 | ,'layim-mobile' 25 | ], function(exports){ 26 | exports('mobile', { 27 | layer: layui['layer-mobile'] //弹层 28 | ,layim: layui['layim-mobile'] //WebIM 29 | }); 30 | }); -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/modules/mobile/layim-mobile-open.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layim mobile 开源包 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | exports('layim-mobile', layui.v); 11 | }); -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/modules/mobile/upload-mobile.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @Title: layui.upload 单文件上传 - 全浏览器兼容版 4 | @Author: 贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(['layer-mobile', 'zepto'] , function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.zepto; 13 | var layer = layui['layer-mobile']; 14 | var device = layui.device(); 15 | 16 | var elemDragEnter = 'layui-upload-enter'; 17 | var elemIframe = 'layui-upload-iframe'; 18 | 19 | var msgConf = { 20 | icon: 2 21 | ,shift: 6 22 | }, fileType = { 23 | file: '文件' 24 | ,video: '视频' 25 | ,audio: '音频' 26 | }; 27 | 28 | layer.msg = function(content){ 29 | return layer.open({ 30 | content: content || '' 31 | ,skin: 'msg' 32 | ,time: 2 //2秒后自动关闭 33 | }); 34 | }; 35 | 36 | var Upload = function(options){ 37 | this.options = options; 38 | }; 39 | 40 | //初始化渲染 41 | Upload.prototype.init = function(){ 42 | var that = this, options = that.options; 43 | var body = $('body'), elem = $(options.elem || '.layui-upload-file'); 44 | var iframe = $(''); 45 | 46 | //插入iframe 47 | $('#'+elemIframe)[0] || body.append(iframe); 48 | 49 | return elem.each(function(index, item){ 50 | item = $(item); 51 | var form = '
'; 52 | 53 | var type = item.attr('lay-type') || options.type; //获取文件类型 54 | 55 | //包裹ui元素 56 | if(!options.unwrap){ 57 | form = '
' + form + ''+ ( 58 | item.attr('lay-title') || options.title|| ('上传'+ (fileType[type]||'图片') ) 59 | ) +'
'; 60 | } 61 | 62 | form = $(form); 63 | 64 | //拖拽支持 65 | if(!options.unwrap){ 66 | form.on('dragover', function(e){ 67 | e.preventDefault(); 68 | $(this).addClass(elemDragEnter); 69 | }).on('dragleave', function(){ 70 | $(this).removeClass(elemDragEnter); 71 | }).on('drop', function(){ 72 | $(this).removeClass(elemDragEnter); 73 | }); 74 | } 75 | 76 | //如果已经实例化,则移除包裹元素 77 | if(item.parent('form').attr('target') === elemIframe){ 78 | if(options.unwrap){ 79 | item.unwrap(); 80 | } else { 81 | item.parent().next().remove(); 82 | item.unwrap().unwrap(); 83 | } 84 | }; 85 | 86 | //包裹元素 87 | item.wrap(form); 88 | 89 | //触发上传 90 | item.off('change').on('change', function(){ 91 | that.action(this, type); 92 | }); 93 | }); 94 | }; 95 | 96 | //提交上传 97 | Upload.prototype.action = function(input, type){ 98 | var that = this, options = that.options, val = input.value; 99 | var item = $(input), ext = item.attr('lay-ext') || options.ext || ''; //获取支持上传的文件扩展名; 100 | 101 | if(!val){ 102 | return; 103 | }; 104 | 105 | //校验文件 106 | switch(type){ 107 | case 'file': //一般文件 108 | if(ext && !RegExp('\\w\\.('+ ext +')$', 'i').test(escape(val))){ 109 | layer.msg('不支持该文件格式', msgConf); 110 | return input.value = ''; 111 | } 112 | break; 113 | case 'video': //视频文件 114 | if(!RegExp('\\w\\.('+ (ext||'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(val))){ 115 | layer.msg('不支持该视频格式', msgConf); 116 | return input.value = ''; 117 | } 118 | break; 119 | case 'audio': //音频文件 120 | if(!RegExp('\\w\\.('+ (ext||'mp3|wav|mid') +')$', 'i').test(escape(val))){ 121 | layer.msg('不支持该音频格式', msgConf); 122 | return input.value = ''; 123 | } 124 | break; 125 | default: //图片文件 126 | if(!RegExp('\\w\\.('+ (ext||'jpg|png|gif|bmp|jpeg') +')$', 'i').test(escape(val))){ 127 | layer.msg('不支持该图片格式', msgConf); 128 | return input.value = ''; 129 | } 130 | break; 131 | } 132 | 133 | options.before && options.before(input); 134 | item.parent().submit(); 135 | 136 | var iframe = $('#'+elemIframe), timer = setInterval(function() { 137 | var res; 138 | try { 139 | res = iframe.contents().find('body').text(); 140 | } catch(e) { 141 | layer.msg('上传接口存在跨域', msgConf); 142 | clearInterval(timer); 143 | } 144 | if(res){ 145 | clearInterval(timer); 146 | iframe.contents().find('body').html(''); 147 | try { 148 | res = JSON.parse(res); 149 | } catch(e){ 150 | res = {}; 151 | return layer.msg('请对上传接口返回JSON字符', msgConf); 152 | } 153 | typeof options.success === 'function' && options.success(res, input); 154 | } 155 | }, 30); 156 | 157 | input.value = ''; 158 | }; 159 | 160 | //暴露接口 161 | exports('upload-mobile', function(options){ 162 | var upload = new Upload(options = options || {}); 163 | upload.init(); 164 | }); 165 | }); 166 | 167 | -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/modules/upload.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @Title: layui.upload 单文件上传 - 全浏览器兼容版 4 | @Author: 贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('layer' , function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.jquery; 13 | var layer = layui.layer; 14 | var device = layui.device(); 15 | 16 | var elemDragEnter = 'layui-upload-enter'; 17 | var elemIframe = 'layui-upload-iframe'; 18 | 19 | var msgConf = { 20 | icon: 2 21 | ,shift: 6 22 | }, fileType = { 23 | file: '文件' 24 | ,video: '视频' 25 | ,audio: '音频' 26 | }; 27 | 28 | var Upload = function(options){ 29 | this.options = options; 30 | }; 31 | 32 | //初始化渲染 33 | Upload.prototype.init = function(){ 34 | var that = this, options = that.options; 35 | var body = $('body'), elem = $(options.elem || '.layui-upload-file'); 36 | var iframe = $(''); 37 | 38 | //插入iframe 39 | $('#'+elemIframe)[0] || body.append(iframe); 40 | 41 | return elem.each(function(index, item){ 42 | item = $(item); 43 | var form = '
'; 44 | 45 | var type = item.attr('lay-type') || options.type; //获取文件类型 46 | 47 | //包裹ui元素 48 | if(!options.unwrap){ 49 | form = '
' + form + ''+ ( 50 | item.attr('lay-title') || options.title|| ('上传'+ (fileType[type]||'图片') ) 51 | ) +'
'; 52 | } 53 | 54 | form = $(form); 55 | 56 | //拖拽支持 57 | if(!options.unwrap){ 58 | form.on('dragover', function(e){ 59 | e.preventDefault(); 60 | $(this).addClass(elemDragEnter); 61 | }).on('dragleave', function(){ 62 | $(this).removeClass(elemDragEnter); 63 | }).on('drop', function(){ 64 | $(this).removeClass(elemDragEnter); 65 | }); 66 | } 67 | 68 | //如果已经实例化,则移除包裹元素 69 | if(item.parent('form').attr('target') === elemIframe){ 70 | if(options.unwrap){ 71 | item.unwrap(); 72 | } else { 73 | item.parent().next().remove(); 74 | item.unwrap().unwrap(); 75 | } 76 | }; 77 | 78 | //包裹元素 79 | item.wrap(form); 80 | 81 | //触发上传 82 | item.off('change').on('change', function(){ 83 | that.action(this, type); 84 | }); 85 | }); 86 | }; 87 | 88 | //提交上传 89 | Upload.prototype.action = function(input, type){ 90 | var that = this, options = that.options, val = input.value; 91 | var item = $(input), ext = item.attr('lay-ext') || options.ext || ''; //获取支持上传的文件扩展名; 92 | 93 | if(!val){ 94 | return; 95 | }; 96 | 97 | //校验文件 98 | switch(type){ 99 | case 'file': //一般文件 100 | if(ext && !RegExp('\\w\\.('+ ext +')$', 'i').test(escape(val))){ 101 | layer.msg('不支持该文件格式', msgConf); 102 | return input.value = ''; 103 | } 104 | break; 105 | case 'video': //视频文件 106 | if(!RegExp('\\w\\.('+ (ext||'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(val))){ 107 | layer.msg('不支持该视频格式', msgConf); 108 | return input.value = ''; 109 | } 110 | break; 111 | case 'audio': //音频文件 112 | if(!RegExp('\\w\\.('+ (ext||'mp3|wav|mid') +')$', 'i').test(escape(val))){ 113 | layer.msg('不支持该音频格式', msgConf); 114 | return input.value = ''; 115 | } 116 | break; 117 | default: //图片文件 118 | if(!RegExp('\\w\\.('+ (ext||'jpg|png|gif|bmp|jpeg') +')$', 'i').test(escape(val))){ 119 | layer.msg('不支持该图片格式', msgConf); 120 | return input.value = ''; 121 | } 122 | break; 123 | } 124 | 125 | options.before && options.before(input); 126 | item.parent().submit(); 127 | 128 | var iframe = $('#'+elemIframe), timer = setInterval(function() { 129 | var res; 130 | try { 131 | res = iframe.contents().find('body').text(); 132 | } catch(e) { 133 | layer.msg('上传接口存在跨域', msgConf); 134 | clearInterval(timer); 135 | } 136 | if(res){ 137 | clearInterval(timer); 138 | iframe.contents().find('body').html(''); 139 | try { 140 | res = JSON.parse(res); 141 | } catch(e){ 142 | res = {}; 143 | return layer.msg('请对上传接口返回JSON字符', msgConf); 144 | } 145 | typeof options.success === 'function' && options.success(res, input); 146 | } 147 | }, 30); 148 | 149 | input.value = ''; 150 | }; 151 | 152 | //暴露接口 153 | exports('upload', function(options){ 154 | var upload = new Upload(options = options || {}); 155 | upload.init(); 156 | }); 157 | }); 158 | 159 | -------------------------------------------------------------------------------- /lib/express/views/static/layui/lay/modules/util.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.util 工具集 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.jquery 13 | 14 | ,util = { 15 | //固定块 16 | fixbar: function(options){ 17 | options = options || {}; 18 | options.bgcolor = options.bgcolor ? ('background-color:' + options.bgcolor) : ''; 19 | 20 | var TOP_BAR = 'layui-fixbar-top', timer, is, icon = [ 21 | options.bar1 === true ? '' : options.bar1 //bar1 - 信息图标 22 | ,options.bar2 === true ? '' : options.bar2 //bar2 - 问号图标 23 | ,'' //置顶 24 | ] 25 | 26 | ,dom = $(['
    ' 27 | ,options.bar1 ? '
  • '+ icon[0] +'
  • ' : '' 28 | ,options.bar2 ? '
  • '+ icon[1] +'
  • ' : '' 29 | ,'
  • '+ icon[2] +'
  • ' 30 | ,'
'].join('')) 31 | 32 | ,topbar = dom.find('.'+TOP_BAR) 33 | 34 | ,scroll = function(){ 35 | var stop = $(document).scrollTop(); 36 | if(stop >= (options.showHeight || 200)){ 37 | is || (topbar.show(), is = 1); 38 | } else { 39 | is && (topbar.hide(), is = 0); 40 | } 41 | }; 42 | 43 | if($('.layui-fixbar')[0]) return; 44 | typeof options.css === 'object' && (dom.css(options.css)); 45 | $('body').append(dom), scroll(); 46 | 47 | //bar点击事件 48 | dom.find('li').on('click', function(){ 49 | var othis = $(this), type = othis.attr('lay-type'); 50 | if(type === 'top'){ 51 | $('html,body').animate({ 52 | scrollTop : 0 53 | }, 200);; 54 | } 55 | options.click && options.click.call(this, type); 56 | }); 57 | 58 | //Top显示控制 59 | $(document).on('scroll', function(){ 60 | if(timer) clearTimeout(timer); 61 | timer = setTimeout(function(){ 62 | scroll(); 63 | }, 100); 64 | }); 65 | } 66 | }; 67 | 68 | exports('util', util); 69 | }); -------------------------------------------------------------------------------- /lib/express/views/static/webuploader/Uploader.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/lib/express/views/static/webuploader/Uploader.swf -------------------------------------------------------------------------------- /lib/imagemin/index.js: -------------------------------------------------------------------------------- 1 | const 2 | imagemin = require('imagemin'), 3 | imageminMozjpeg = require('imagemin-mozjpeg'), 4 | imageminPngquant = require('imagemin-pngquant'), 5 | imageminGifsicle = require('imagemin-gifsicle'), 6 | fs = require('fs'); 7 | 8 | /** 9 | * 文件压缩 10 | * @param {string||array} input 文件路径 11 | * @param {string} output 文件输出路径:默认 imagemin/temp 12 | * @return { 13 | * status: true|false 14 | * [true => (imageminCompass return true)] 15 | * [false => error: string] 16 | * } 17 | */ 18 | async function compass(input, output) { 19 | return await imageminCompass(input, output); 20 | } 21 | 22 | /** 23 | * imagemin压缩 24 | * @param {string|Array} input 源目录 25 | * @param {string} output 输出目录 26 | * @return { 27 | * status: true|false, 28 | * [true => data: array] 29 | * [false => error: string] 30 | * } 31 | */ 32 | async function imageminCompass(input, output = 'temp') { 33 | input = (typeof input == 'string') ? [input] : input; 34 | return await imagemin(input, output, { 35 | use: [ 36 | imageminMozjpeg(), 37 | imageminPngquant(), 38 | imageminGifsicle({ 39 | optimizationLevel:3 40 | }) 41 | ] 42 | }) 43 | .then(file => { 44 | return { 45 | status: true, 46 | data: file 47 | }; 48 | }) 49 | .catch(e => { 50 | console.log(e); 51 | return { 52 | status: false, 53 | error: e.toString() 54 | } 55 | }); 56 | } 57 | 58 | module.exports = { 59 | compass: compass 60 | }; -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./imagemin').compass; -------------------------------------------------------------------------------- /lib/log/index.js: -------------------------------------------------------------------------------- 1 | const 2 | fs = require('fs'), 3 | dir = __dirname + '/files/'; 4 | 5 | module.exports = (msg = '') => { 6 | let name = new Date().getTime(); 7 | fs.writeFileSync(dir + name, msg, 'utf-8'); 8 | return name; 9 | } -------------------------------------------------------------------------------- /lib/runServer.js: -------------------------------------------------------------------------------- 1 | module.exports = (port = 3000) => { 2 | const 3 | http = require('http'), 4 | open = require('open'), 5 | express = require('./express'); 6 | 7 | 8 | http.createServer(express).listen(port, () => { 9 | console.log('server is run:' + port); 10 | open('http://localhost:' + port); 11 | }); 12 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zimg", 3 | "version": "1.201904.1", 4 | "description": "图片压缩操作工具", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/zoeDylan/z_img.git" 9 | }, 10 | "author": "zoeDylan", 11 | "license": "MIT", 12 | "bin": { 13 | "zimg": "./bin/index.js" 14 | }, 15 | "keywords": [ 16 | "zoeDylan", 17 | "image", 18 | "compass", 19 | "imagemin", 20 | "png", 21 | "jpg", 22 | "img", 23 | "pngquant", 24 | "mozjpeg" 25 | ], 26 | "bugs": { 27 | "url": "https://github.com/zoeDylan/z_img/issues" 28 | }, 29 | "homepage": "https://github.com/zoeDylan/z_img#readme", 30 | "dependencies": { 31 | "express": "4.15.2", 32 | "express-session": "1.15.2", 33 | "glob": "^7.1.2", 34 | "imagemin": "5.2.2", 35 | "imagemin-gifsicle": "^5.2.0", 36 | "imagemin-mozjpeg": "6.0.0", 37 | "imagemin-pngquant": "5.0.0", 38 | "md5": "2.2.1", 39 | "multiparty": "4.1.3", 40 | "open": "0.0.5" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /readmeFile/0.0.1_test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/readmeFile/0.0.1_test.gif -------------------------------------------------------------------------------- /readmeFile/0.0.2_test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/readmeFile/0.0.2_test.gif -------------------------------------------------------------------------------- /readmeFile/0.0.4_test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/readmeFile/0.0.4_test.gif -------------------------------------------------------------------------------- /readmeFile/0.0.5.test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/readmeFile/0.0.5.test.gif -------------------------------------------------------------------------------- /readmeFile/1.0.0-cli-test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/readmeFile/1.0.0-cli-test.png -------------------------------------------------------------------------------- /readmeFile/2017-05-08-i1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ulidev9527/z_img/849441fe6486b551591d1e3d14e0dde9115455be/readmeFile/2017-05-08-i1.png --------------------------------------------------------------------------------