mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-02-19 19:51:34 +01:00
Start again
This commit is contained in:
32
vendors/jszip/.bower.json
vendored
Normal file
32
vendors/jszip/.bower.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "jszip",
|
||||
"homepage": "http://stuartk.com/jszip",
|
||||
"authors": [
|
||||
"Stuart Knightley <stuart@stuartk.com>"
|
||||
],
|
||||
"description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip",
|
||||
"main": "dist/jszip.js",
|
||||
"keywords": [
|
||||
"zip",
|
||||
"deflate",
|
||||
"inflate"
|
||||
],
|
||||
"license": "MIT or GPLv3",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"version": "2.6.0",
|
||||
"_release": "2.6.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v2.6.0",
|
||||
"commit": "8f190955e9328b768d7fc4f2770234fd53c407a7"
|
||||
},
|
||||
"_source": "git://github.com/Stuk/jszip.git",
|
||||
"_target": "v2.6.0",
|
||||
"_originalSource": "Stuk/jszip"
|
||||
}
|
||||
77
vendors/jszip/CHANGES.md
vendored
Normal file
77
vendors/jszip/CHANGES.md
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
---
|
||||
title: Changelog
|
||||
layout: default
|
||||
section: main
|
||||
---
|
||||
|
||||
### v2.6.0 2016-03-23
|
||||
- publish `dist/` files in the npm package (see [#225](https://github.com/Stuk/jszip/pull/225)).
|
||||
- update pako to v1.0.0 (see [#261](https://github.com/Stuk/jszip/pull/261)).
|
||||
- add support of Array in JSZip#load (see [#252](https://github.com/Stuk/jszip/pull/252)).
|
||||
- improve file name / comment encoding support (see [#211](https://github.com/Stuk/jszip/pull/211)).
|
||||
- handle prepended data (see [#266](https://github.com/Stuk/jszip/pull/266)).
|
||||
- improve platform coverage in tests (see [#233](https://github.com/Stuk/jszip/pull/233) and [#269](https://github.com/Stuk/jszip/pull/269)).
|
||||
|
||||
### v2.5.0 2015-03-10
|
||||
- add support for custom mime-types (see [#199](https://github.com/Stuk/jszip/issues/199)).
|
||||
- add an option to set the DEFLATE level (see [#201](https://github.com/Stuk/jszip/issues/201)).
|
||||
- improve the error message with corrupted zip (see [#202](https://github.com/Stuk/jszip/issues/202)).
|
||||
- add support for UNIX / DOS permissions (see [#200](https://github.com/Stuk/jszip/issues/200) and [#205](https://github.com/Stuk/jszip/issues/205)).
|
||||
|
||||
### v2.4.0 2014-07-24
|
||||
- update pako to 0.2.5 (see [#156](https://github.com/Stuk/jszip/issues/156)).
|
||||
- make JSZip work in a Firefox addon context (see [#151](https://github.com/Stuk/jszip/issues/151)).
|
||||
- add an option (`createFolders`) to control the subfolder generation (see [#154](https://github.com/Stuk/jszip/issues/154)).
|
||||
- allow `Buffer` polyfill in the browser (see [#139](https://github.com/Stuk/jszip/issues/139)).
|
||||
|
||||
### v2.3.0 2014-06-18
|
||||
- don't generate subfolders (see [#130](https://github.com/Stuk/jszip/issues/130)).
|
||||
- add comment support (see [#134](https://github.com/Stuk/jszip/issues/134)).
|
||||
- on `ZipObject#options`, the attributes `date` and `dir` have been deprecated and are now on `ZipObject` (see [the upgrade guide](http://stuk.github.io/jszip/documentation/upgrade_guide.html)).
|
||||
- on `ZipObject#options`, the attributes `base64` and `binary` have been deprecated (see [the upgrade guide](http://stuk.github.io/jszip/documentation/upgrade_guide.html)).
|
||||
- deprecate internal functions exposed in the public API (see [#123](https://github.com/Stuk/jszip/issues/123)).
|
||||
- improve UTF-8 support (see [#142](https://github.com/Stuk/jszip/issues/142)).
|
||||
|
||||
### v2.2.2, 2014-05-01
|
||||
- update pako to v0.2.1, fix an error when decompressing some files (see [#126](https://github.com/Stuk/jszip/issues/126)).
|
||||
|
||||
### v2.2.1, 2014-04-23
|
||||
- fix unreadable generated file on Windows 8 (see [#112](https://github.com/Stuk/jszip/issues/112)).
|
||||
- replace zlibjs with pako.
|
||||
|
||||
### v2.2.0, 2014-02-25
|
||||
- make the `new` operator optional before the `JSZip` constructor (see [#93](https://github.com/Stuk/jszip/pull/93)).
|
||||
- update zlibjs to v0.2.0.
|
||||
|
||||
### v2.1.1, 2014-02-13
|
||||
- use the npm package for zlib.js instead of the github url.
|
||||
|
||||
### v2.1.0, 2014-02-06
|
||||
- split the files and use Browserify to generate the final file (see [#74](https://github.com/Stuk/jszip/pull/74))
|
||||
- packaging change : instead of 4 files (jszip.js, jszip-load.js, jszip-inflate.js, jszip-deflate.js) we now have 2 files : dist/jszip.js and dist/jszip.min.js
|
||||
- add component/bower support
|
||||
- rename variable: 'byte' is a reserved word (see [#76](https://github.com/Stuk/jszip/pull/76))
|
||||
- add support for the unicode path extra field (see [#82](https://github.com/Stuk/jszip/pull/82))
|
||||
- ensure that the generated files have a header with the licenses (see [#80](https://github.com/Stuk/jszip/pull/80))
|
||||
|
||||
# v2.0.0, 2013-10-20
|
||||
|
||||
- `JSZipBase64` has been renamed to `JSZip.base64`.
|
||||
- The `data` attribute on the object returned by `zip.file(name)` has been removed. Use `asText()`, `asBinary()`, `asUint8Array()`, `asArrayBuffer()` or `asNodeBuffer()`.
|
||||
|
||||
- [Fix issue with Android browser](https://github.com/Stuk/jszip/pull/60)
|
||||
|
||||
- The compression/decompression methods now give their input type with the `compressInputType` and `uncompressInputType` attributes.
|
||||
- Lazily decompress data when needed and [improve performance in general](https://github.com/Stuk/jszip/pull/56)
|
||||
- [Add support for `Buffer` in Node.js](https://github.com/Stuk/jszip/pull/57).
|
||||
- Package for CommonJS/npm.
|
||||
|
||||
### v1.0.1, 2013-03-04
|
||||
|
||||
- Fixed an issue when generating a compressed zip file with empty files or folders, see #33.
|
||||
- With bad data (null or undefined), asText/asBinary/asUint8Array/asArrayBuffer methods now return an empty string, see #36.
|
||||
|
||||
# v1.0.0, 2013-02-14
|
||||
|
||||
- First release after a long period without version.
|
||||
|
||||
162
vendors/jszip/Gruntfile.js
vendored
Normal file
162
vendors/jszip/Gruntfile.js
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
/*jshint node: true */
|
||||
module.exports = function(grunt) {
|
||||
var browsers = [{
|
||||
browserName: "iphone",
|
||||
platform: "OS X 10.8",
|
||||
version: "6"
|
||||
}, {
|
||||
browserName: "iphone",
|
||||
platform: "OS X 10.10",
|
||||
version: "9.2"
|
||||
}, {
|
||||
browserName: "android",
|
||||
platform: "Linux",
|
||||
version: "4.0"
|
||||
}, {
|
||||
browserName: "android",
|
||||
platform: "Linux",
|
||||
version: "4.4"
|
||||
}, {
|
||||
browserName: "android",
|
||||
platform: "Linux",
|
||||
version: "5.1"
|
||||
}, {
|
||||
browserName: "firefox",
|
||||
platform: "Windows 10"
|
||||
}, {
|
||||
browserName: "chrome",
|
||||
platform: "Windows 10"
|
||||
}, {
|
||||
browserName: "internet explorer",
|
||||
platform: "XP",
|
||||
version: "7"
|
||||
}, {
|
||||
browserName: "internet explorer",
|
||||
platform: "Windows 7",
|
||||
version: "8"
|
||||
}, {
|
||||
browserName: "internet explorer",
|
||||
platform: "Windows 7",
|
||||
version: "9"
|
||||
}, {
|
||||
browserName: "internet explorer",
|
||||
platform: "Windows 8",
|
||||
version: "10"
|
||||
}, {
|
||||
browserName: "internet explorer",
|
||||
platform: "Windows 10",
|
||||
version: "11"
|
||||
}, {
|
||||
browserName: "microsoftedge",
|
||||
platform: "Windows 10",
|
||||
version: "13.10586"
|
||||
}, {
|
||||
browserName: "opera",
|
||||
platform: "Windows 2008",
|
||||
version: "12"
|
||||
}, {
|
||||
browserName: "safari",
|
||||
platform: "OS X 10.8",
|
||||
version: "6"
|
||||
}, {
|
||||
browserName: "safari",
|
||||
platform: "OS X 10.9",
|
||||
version: "7"
|
||||
}, {
|
||||
browserName: "safari",
|
||||
platform: "OS X 10.10",
|
||||
version: "8"
|
||||
}, {
|
||||
browserName: "safari",
|
||||
platform: "OS X 10.11",
|
||||
version: "9"
|
||||
}];
|
||||
|
||||
var tags = [];
|
||||
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST != "false") {
|
||||
tags.push("pr" + process.env.TRAVIS_PULL_REQUEST);
|
||||
} else if (process.env.TRAVIS_BRANCH) {
|
||||
tags.push(process.env.TRAVIS_BRANCH);
|
||||
}
|
||||
|
||||
grunt.initConfig({
|
||||
connect: {
|
||||
server: {
|
||||
options: {
|
||||
base: "",
|
||||
port: 9999
|
||||
}
|
||||
}
|
||||
},
|
||||
'saucelabs-qunit': {
|
||||
all: {
|
||||
options: {
|
||||
urls: ["http://127.0.0.1:9999/test/index.html"],
|
||||
tunnelTimeout: 5,
|
||||
build: process.env.TRAVIS_JOB_ID,
|
||||
concurrency: 3,
|
||||
browsers: browsers,
|
||||
testname: "qunit tests",
|
||||
tags: tags
|
||||
}
|
||||
}
|
||||
},
|
||||
jshint: {
|
||||
options: {
|
||||
jshintrc: "./.jshintrc"
|
||||
},
|
||||
all: ['./lib/*.js']
|
||||
},
|
||||
browserify: {
|
||||
all: {
|
||||
files: {
|
||||
'dist/jszip.js': ['lib/index.js']
|
||||
},
|
||||
options: {
|
||||
browserifyOptions: {
|
||||
standalone: 'JSZip',
|
||||
insertGlobalVars : {
|
||||
Buffer: function () {
|
||||
// instead of the full polyfill, we just use the raw value
|
||||
// (or undefined).
|
||||
return '(typeof Buffer !== "undefined" ? Buffer : undefined)';
|
||||
}
|
||||
}
|
||||
},
|
||||
postBundleCB: function(err, src, done) {
|
||||
// add the license
|
||||
var license = require('fs').readFileSync('lib/license_header.js');
|
||||
// remove the source mapping of zlib.js, see #75
|
||||
var srcWithoutSourceMapping = src.toString().replace(/\/\/@ sourceMappingURL=raw..flate.min.js.map/g, '');
|
||||
done(err, license + srcWithoutSourceMapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
options: {
|
||||
report: 'gzip',
|
||||
mangle: true,
|
||||
preserveComments: 'some'
|
||||
},
|
||||
all: {
|
||||
src: 'dist/jszip.js',
|
||||
dest: 'dist/jszip.min.js'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks("grunt-saucelabs");
|
||||
grunt.loadNpmTasks("grunt-contrib-connect");
|
||||
grunt.loadNpmTasks('grunt-browserify');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
|
||||
if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
|
||||
grunt.registerTask("test", ["connect", "saucelabs-qunit"]);
|
||||
} else {
|
||||
grunt.registerTask("test", []);
|
||||
}
|
||||
grunt.registerTask("build", ["browserify", "uglify"]);
|
||||
grunt.registerTask("default", ["jshint", "build"]);
|
||||
};
|
||||
651
vendors/jszip/LICENSE.markdown
vendored
Normal file
651
vendors/jszip/LICENSE.markdown
vendored
Normal file
@@ -0,0 +1,651 @@
|
||||
JSZip is dual licensed. You may use it under the MIT license *or* the GPLv3
|
||||
license.
|
||||
|
||||
The MIT License
|
||||
===============
|
||||
|
||||
Copyright (c) 2009-2014 Stuart Knightley, David Duponchel, Franz Buchinger, António Afonso
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
GPL version 3
|
||||
=============
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
35
vendors/jszip/README.markdown
vendored
Normal file
35
vendors/jszip/README.markdown
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
JSZip [](http://travis-ci.org/Stuk/jszip) [](https://codeclimate.com/github/Stuk/jszip)
|
||||
=====
|
||||
|
||||
[](https://saucelabs.com/u/jszip)
|
||||
|
||||
A library for creating, reading and editing .zip files with Javascript, with a
|
||||
lovely and simple API.
|
||||
|
||||
See http://stuartk.com/jszip for all the documentation.
|
||||
|
||||
```javascript
|
||||
var zip = new JSZip();
|
||||
|
||||
zip.file("Hello.txt", "Hello World\n");
|
||||
|
||||
var img = zip.folder("images");
|
||||
img.file("smile.gif", imgData, {base64: true});
|
||||
|
||||
var content = zip.generate({type:"blob"});
|
||||
|
||||
// see FileSaver.js
|
||||
saveAs(content, "example.zip");
|
||||
|
||||
/*
|
||||
Results in a zip containing
|
||||
Hello.txt
|
||||
images/
|
||||
smile.gif
|
||||
*/
|
||||
```
|
||||
License
|
||||
-------
|
||||
|
||||
JSZip is dual-licensed. You may use it under the MIT license *or* the GPLv3
|
||||
license. See [LICENSE.markdown](LICENSE.markdown).
|
||||
24
vendors/jszip/_config.yml
vendored
Normal file
24
vendors/jszip/_config.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# will be overwritten by github, see https://help.github.com/articles/using-jekyll-with-pages
|
||||
lsi: false
|
||||
safe: true
|
||||
source: ./
|
||||
incremental: false
|
||||
highlighter: rouge
|
||||
gist:
|
||||
noscript: false
|
||||
# /overwritten
|
||||
|
||||
baseurl: /jszip
|
||||
|
||||
layouts_dir: ./documentation/_layouts
|
||||
permalink: none
|
||||
exclude: ['bin', 'README.md', 'node_modules']
|
||||
|
||||
|
||||
kramdown:
|
||||
input: GFM
|
||||
hard_wrap: false
|
||||
gems:
|
||||
- jekyll-coffeescript
|
||||
- jekyll-paginate
|
||||
|
||||
22
vendors/jszip/bower.json
vendored
Normal file
22
vendors/jszip/bower.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "jszip",
|
||||
"homepage": "http://stuartk.com/jszip",
|
||||
"authors": [
|
||||
"Stuart Knightley <stuart@stuartk.com>"
|
||||
],
|
||||
"description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip",
|
||||
"main": "dist/jszip.js",
|
||||
"keywords": [
|
||||
"zip",
|
||||
"deflate",
|
||||
"inflate"
|
||||
],
|
||||
"license": "MIT or GPLv3",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
16
vendors/jszip/component.json
vendored
Normal file
16
vendors/jszip/component.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "jszip",
|
||||
"repo": "Stuk/jszip",
|
||||
"description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip",
|
||||
"version": "2.6.0",
|
||||
"keywords": [
|
||||
"zip",
|
||||
"deflate",
|
||||
"inflate"
|
||||
],
|
||||
"main": "dist/jszip.js",
|
||||
"license": "MIT or GPLv3",
|
||||
"scripts": [
|
||||
"dist/jszip.js"
|
||||
]
|
||||
}
|
||||
9344
vendors/jszip/dist/jszip.js
vendored
Normal file
9344
vendors/jszip/dist/jszip.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
14
vendors/jszip/dist/jszip.min.js
vendored
Normal file
14
vendors/jszip/dist/jszip.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3217
vendors/jszip/docs/APPNOTE.TXT
vendored
Normal file
3217
vendors/jszip/docs/APPNOTE.TXT
vendored
Normal file
File diff suppressed because it is too large
Load Diff
66
vendors/jszip/docs/ZIP spec.txt
vendored
Normal file
66
vendors/jszip/docs/ZIP spec.txt
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
Here are the notes I made while working through the ZIP file specification.
|
||||
|
||||
For each file:
|
||||
|
||||
local file header signature 4 bytes (0x04034b50)
|
||||
version needed to extract 2 bytes
|
||||
general purpose bit flag 2 bytes
|
||||
compression method 2 bytes
|
||||
last mod file time 2 bytes
|
||||
last mod file date 2 bytes
|
||||
crc-32 4 bytes
|
||||
compressed size 4 bytes
|
||||
uncompressed size 4 bytes
|
||||
file name length 2 bytes
|
||||
extra field length 2 bytes
|
||||
|
||||
|sig |v |g |c |t |d |crc |csz |usz |n |x |
|
||||
PK.. ## 00 00 ?? ?? xxxx ???? ???? ?? 00
|
||||
<file name><file data>
|
||||
|
||||
Central directory:
|
||||
|
||||
central file header signature 4 bytes (0x02014b50)
|
||||
version made by 2 bytes
|
||||
version needed to extract 2 bytes *
|
||||
general purpose bit flag 2 bytes *
|
||||
compression method 2 bytes *
|
||||
last mod file time 2 bytes *
|
||||
last mod file date 2 bytes *
|
||||
crc-32 4 bytes *
|
||||
compressed size 4 bytes *
|
||||
uncompressed size 4 bytes *
|
||||
file name length 2 bytes *
|
||||
extra field length 2 bytes *
|
||||
file comment length 2 bytes
|
||||
disk number start 2 bytes
|
||||
internal file attributes 2 bytes
|
||||
external file attributes 4 bytes
|
||||
relative offset of local header 4 bytes
|
||||
|
||||
file name (variable size)
|
||||
extra field (variable size)
|
||||
file comment (variable size)
|
||||
|
||||
|sig |vm|vx|g |c |d |t |crc |csz |usz |n |x |cm|dn|ia|xa |roff|
|
||||
PK.. ## ## 00 00 ?? ?? xxxx ???? ???? ?? 00 00 00 00 xxxx ????
|
||||
|
||||
End of central directory:
|
||||
|
||||
end of central dir signature 4 bytes (0x06054b50)
|
||||
number of this disk 2 bytes
|
||||
number of the disk with the
|
||||
start of the central directory 2 bytes
|
||||
total number of entries in the
|
||||
central directory on this disk 2 bytes
|
||||
total number of entries in
|
||||
the central directory 2 bytes
|
||||
size of the central directory 4 bytes
|
||||
offset of start of central
|
||||
directory with respect to
|
||||
the starting disk number 4 bytes
|
||||
.ZIP file comment length 2 bytes
|
||||
.ZIP file comment (variable size)
|
||||
|
||||
|sig |n1|n2|e |ne|size|off |cm|
|
||||
PK.. 00 00 ?? ?? ???? ???? 00
|
||||
18
vendors/jszip/docs/references.txt
vendored
Normal file
18
vendors/jszip/docs/references.txt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
Zip format
|
||||
----------
|
||||
http://www.pkware.com/support/zip-application-note
|
||||
http://www.xxcopy.com/xxcopy06.htm
|
||||
|
||||
Data URL
|
||||
--------
|
||||
https://developer.mozilla.org/en/The_data_URL_scheme
|
||||
http://msdn.microsoft.com/en-us/library/cc848897(VS.85).aspx
|
||||
http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/
|
||||
|
||||
http://www.motobit.com/util/base64-decoder-encoder.asp
|
||||
|
||||
Saving files
|
||||
------------
|
||||
http://msdn.microsoft.com/en-us/library/ms536676(VS.85).aspx
|
||||
http://msdn.microsoft.com/en-us/library/ms536419(VS.85).aspx
|
||||
http://msdn.microsoft.com/en-us/library/ms537418(VS.85).aspx
|
||||
158
vendors/jszip/documentation/_layouts/default.html
vendored
Normal file
158
vendors/jszip/documentation/_layouts/default.html
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="Create .zip files using Javascript. Provides a simple API to place any content generated by Javascript into a .zip file for your users." />
|
||||
<title>{{page.title}}</title>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<!-- <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> -->
|
||||
|
||||
<link rel="stylesheet" href="{{site.baseurl}}/documentation/css/pygments.css">
|
||||
<link rel="stylesheet" href="{{site.baseurl}}/documentation/css/main.css">
|
||||
|
||||
<script type="text/javascript" src="{{site.baseurl}}/dist/jszip.js"></script>
|
||||
|
||||
<script type="text/javascript" src="//stuk.github.io/jszip-utils/dist/jszip-utils.js"></script>
|
||||
<!--
|
||||
Mandatory in IE 6, 7, 8 and 9.
|
||||
-->
|
||||
<!--[if IE]>
|
||||
<script type="text/javascript" src="//stuk.github.io/jszip-utils/dist/jszip-utils-ie.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<!--
|
||||
Any version of jQuery will do (it's just to write some examples), this one
|
||||
happens to be available in our tests.
|
||||
-->
|
||||
<script type="text/javascript" src="{{site.baseurl}}/test/jquery-1.8.3.min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="{{site.baseurl}}/vendor/FileSaver.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="navbar navbar-default" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="{{site.baseurl}}/"><strong>JS</strong>Zip</a>
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li {% if page.section == "api" %}class="active"{% endif %}>
|
||||
<a href="{{site.baseurl}}/documentation/api_jszip.html">API</a>
|
||||
</li>
|
||||
<li {% if page.section == "example" %}class="active"{% endif %}>
|
||||
<a href="{{site.baseurl}}/documentation/examples.html">How to / examples</a>
|
||||
</li>
|
||||
<li {% if page.section == "limitations" %}class="active"{% endif %}>
|
||||
<a href="{{site.baseurl}}/documentation/limitations.html">Performances / limitations</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/Stuk/jszip">JSZip on Github</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% if page.section and page.fullpage != true %}
|
||||
<div class="row">
|
||||
<nav class="col-md-3">
|
||||
{% case page.section %}
|
||||
{% when "main" %}
|
||||
<h4>JSZip users :</h4>
|
||||
<ul class="nav">
|
||||
<li><a href="{{site.baseurl}}/">Installation</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/faq.html">FAQ</a></li>
|
||||
<li><a href="{{site.baseurl}}/CHANGES.html">Changelog</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/upgrade_guide.html">Upgrade guide</a></li>
|
||||
<li><a href="https://github.com/Stuk/jszip/issues">Bug tracker</a></li>
|
||||
</ul>
|
||||
<h4>JSZip developers :</h4>
|
||||
<ul class="nav">
|
||||
<li><a href="{{site.baseurl}}/documentation/contributing.html">How to contribute</a></li>
|
||||
<li><a href="https://github.com/Stuk/jszip/graphs/contributors">Contributors</a></li>
|
||||
</ul>
|
||||
{% when "api" %}
|
||||
<ul class="nav">
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip.html">JSZip</a>
|
||||
<ul>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/constructor.html">new JSZip() or JSZip()</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/constructor_load.html">new JSZip(data [,options])</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/file_name.html">JSZip#file(name)</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/file_regex.html">JSZip#file(regex)</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/file_data.html">JSZip#file(name, data [,options])</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/folder_data.html">JSZip#folder(name)</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/folder_regex.html">JSZip#folder(regex)</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/filter.html">JSZip#filter(predicate)</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/remove.html">JSZip#remove(name)</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/generate.html">JSZip#generate(options)</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/load.html">JSZip#load(data [, options])</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_jszip/support.html">JSZip.support</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="{{site.baseurl}}/documentation/api_zipobject.html">ZipObject</a></li>
|
||||
</ul>
|
||||
{% when "example" %}
|
||||
<h4>How to ...</h4>
|
||||
<ul class="nav">
|
||||
<li><a href="{{site.baseurl}}/documentation/examples.html">Use JSZip</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/howto/read_zip.html">Read a file</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/howto/write_zip.html">Write a file</a></li>
|
||||
</ul>
|
||||
<h4>Examples</h4>
|
||||
<ul class="nav">
|
||||
<li><a href="{{site.baseurl}}/documentation/examples/read-local-file-api.html">Read local file</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/examples/get-binary-files-ajax.html">Read remote file</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/examples/download-zip-file.html">Give the user its zip file</a></li>
|
||||
<li><a href="{{site.baseurl}}/documentation/examples/downloader.html">Mini app : downloader</a></li>
|
||||
</ul>
|
||||
{% endcase %}
|
||||
<!-- <ul class="nav"> -->
|
||||
<!-- <li><a href="{{site.baseurl}}/documentation/faq.html">FAQ</a></li> -->
|
||||
<!-- </ul> -->
|
||||
<!-- <li><a href="{{site.baseurl}}/">installation</a></li> -->
|
||||
</nav>
|
||||
{% endif %}
|
||||
<div class="{% if page.section and page.fullpage != true%}col-md-9{% else %}col-md-12{% endif %}">
|
||||
<h1>{{page.title}}</h1>
|
||||
<!-- ===================== -->
|
||||
<!-- === C O N T E N T === -->
|
||||
<!-- ===================== -->
|
||||
|
||||
{{content}}
|
||||
|
||||
<!-- ===================== -->
|
||||
<!-- == / C O N T E N T == -->
|
||||
<!-- ===================== -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// FIXME find how to do that cleanly
|
||||
(function(){
|
||||
var tables = document.getElementsByTagName("table");
|
||||
for(var i = 0; i < tables.length; i++) {
|
||||
tables[i].className += " table table-condensed table-striped table-bordered ";
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-52085706-1', 'stuk.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
15
vendors/jszip/documentation/api_jszip.md
vendored
Normal file
15
vendors/jszip/documentation/api_jszip.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "JSZip API"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
An instance of JSZip represents a set of files. You can add them, remove them,
|
||||
modify them. You can also import an existing zip file or generate one.
|
||||
|
||||
### Attributes
|
||||
|
||||
attribute name | type | description
|
||||
---------------------|-------------|-------------
|
||||
`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).
|
||||
`comment` | string | the comment of the zip file.
|
||||
23
vendors/jszip/documentation/api_jszip/constructor.md
vendored
Normal file
23
vendors/jszip/documentation/api_jszip/constructor.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
title: "new JSZip() or JSZip()"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Create a new JSZip instance.
|
||||
|
||||
__Arguments__ : None
|
||||
|
||||
__Returns__ : A new JSZip.
|
||||
|
||||
__Throws__ : Nothing.
|
||||
|
||||
<!-- __Complexity__ : Object creation in **O(1)**. -->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
// same as
|
||||
var zip = JSZip();
|
||||
```
|
||||
22
vendors/jszip/documentation/api_jszip/constructor_load.md
vendored
Normal file
22
vendors/jszip/documentation/api_jszip/constructor_load.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: "new JSZip(data [,options]) or JSZip(data [,options])"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
This is a shortcut for
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
zip.load(data, options);
|
||||
```
|
||||
|
||||
Please see the documentation of [load]({{site.baseurl}}/documentation/api_jszip/load.html).
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
var zip = new JSZip(data, options);
|
||||
// same as
|
||||
var zip = JSZip(data, options);
|
||||
```
|
||||
90
vendors/jszip/documentation/api_jszip/file_data.md
vendored
Normal file
90
vendors/jszip/documentation/api_jszip/file_data.md
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
---
|
||||
title: "file(name, data [,options])"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Add (or update) a file to the zip file.
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | description
|
||||
--------------------|---------|------------
|
||||
name | string | the name of the file. You can specify folders in the name : the folder separator is a forward slash ("/").
|
||||
data | String/ArrayBuffer/Uint8Array/Buffer | the content of the file.
|
||||
options | object | the options.
|
||||
|
||||
Content of `options` :
|
||||
|
||||
name | type | default | description
|
||||
------------|---------|---------|------------
|
||||
base64 | boolean | `false` | set to `true` if the data is base64 encoded. For example image data from a `<canvas>` element. Plain text and HTML do not need this option.
|
||||
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`.
|
||||
date | date | the current date | the last modification date.
|
||||
compression | string | null | If set, specifies compression method to use for this specific file. If not, the default file compression will be used, see [generate(options)]({{site.baseurl}}/documentation/api_jszip/generate.html).
|
||||
compressionOptions | object | `null` | the options to use when compressing the file, see [generate(options)]({{site.baseurl}}/documentation/api_jszip/generate.html).
|
||||
comment | string | null | The comment for this file.
|
||||
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.
|
||||
createFolders | boolean | `false` | 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.
|
||||
unixPermissions | 16 bits number | null | The UNIX permissions of the file, if any.
|
||||
dosPermissions | 6 bits number | null | The DOS permissions of the file, if any.
|
||||
dir | boolean | false | Set to true if this is a directory and content should be ignored.
|
||||
|
||||
You shouldn't update the data given to this method : it is kept as it so any
|
||||
update will impact the stored data.
|
||||
|
||||
__For the permissions__ :
|
||||
|
||||
The field `unixPermissions` also accepts a string representing the octal value :
|
||||
"644", "755", etc. On nodejs you can use the `mode` attribute of
|
||||
[nodejs' fs.Stats](http://nodejs.org/api/fs.html#fs_class_fs_stats).
|
||||
|
||||
See also [the platform option of generate()]({{site.baseurl}}/documentation/api_jszip/generate.html).
|
||||
|
||||
__About `dir`__ :
|
||||
|
||||
If `dir` is true or if a permission says it's a folder, this entry be flagged
|
||||
as a folder and the content will be ignored.
|
||||
|
||||
__Returns__ : The current JSZip object, for chaining.
|
||||
|
||||
__Throws__ : An exception if the data is not in a supported format.
|
||||
|
||||
<!--
|
||||
__Complexity__ : **O(1)** for anything but binary strings.
|
||||
For binary strings (`data` is a string and `binary` = true), if
|
||||
`optimizedBinaryString` is not set, the 0xFF mask will be applied giving a
|
||||
complexity in **O(n)** where n is the size of the added data.
|
||||
-->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
zip.file("Hello.txt", "Hello World\n");
|
||||
|
||||
// base64
|
||||
zip.file("smile.gif", "R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=", {base64: true});
|
||||
// from an ajax call with xhr.responseType = 'arraybuffer'
|
||||
zip.file("smile.gif", arraybufferFromXhr);
|
||||
// or on nodejs
|
||||
zip.file("smile.gif", fs.readFileSync("smile.gif"));
|
||||
|
||||
zip.file("Xmas.txt", "Ho ho ho !", {date : new Date("December 25, 2007 00:00:01")});
|
||||
zip.file("folder/file.txt", "file in folder");
|
||||
|
||||
zip.file("animals.txt", "dog,platypus\n").file("people.txt", "james,sebastian\n");
|
||||
|
||||
// result : Hello.txt, smile.gif, Xmas.txt, animals.txt, people.txt,
|
||||
// folder/, folder/file.txt
|
||||
// In the above case, the "folder" folder will not have a 'D'irectory attribute or Method property. The
|
||||
// folder only exists as part of the path to "file.txt".
|
||||
|
||||
zip.file("folder/file.txt", "file in folder", {createFolders: true});
|
||||
// In this case, the "folder" folder WILL have a 'D'irectory attribute and a Method property of "store".
|
||||
// It will exist whether or not "file.txt" is present.
|
||||
|
||||
zip.file("script.sh", "echo 'hello world'", {
|
||||
unixPermissions : "755"
|
||||
});
|
||||
// when generated with platform:UNIX, the script.sh file will be executable
|
||||
```
|
||||
46
vendors/jszip/documentation/api_jszip/file_name.md
vendored
Normal file
46
vendors/jszip/documentation/api_jszip/file_name.md
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
title: "file(name)"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Get a file with the specified name. You can specify folders
|
||||
in the name : the folder separator is a forward slash ("/").
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | description
|
||||
-----|--------|-------------
|
||||
name | string | the name of the file.
|
||||
|
||||
__Returns__ : An instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html) representing
|
||||
the file if any, `null` otherwise.
|
||||
|
||||
__Throws__ : Nothing.
|
||||
|
||||
<!-- __Complexity__ : This is a simple lookup in **O(1)**. -->
|
||||
|
||||
__Examples__
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
zip.file("file.txt", "content");
|
||||
|
||||
zip.file("file.txt").name // "file.txt"
|
||||
zip.file("file.txt").asText() // "content"
|
||||
zip.file("file.txt").options.dir // false
|
||||
|
||||
// utf8 example
|
||||
var zip = new JSZip(zipFromAjaxWithUTF8);
|
||||
zip.file("amount.txt").asText() // "€15"
|
||||
zip.file("amount.txt").asArrayBuffer() // an ArrayBuffer containing €15 encoded as utf8
|
||||
zip.file("amount.txt").asUint8Array() // an Uint8Array containing €15 encoded as utf8
|
||||
|
||||
// with folders
|
||||
zip.folder("sub").file("file.txt", "content");
|
||||
zip.file("sub/file.txt"); // the file
|
||||
// or
|
||||
zip.folder("sub").file("file.txt") // the file
|
||||
```
|
||||
|
||||
|
||||
49
vendors/jszip/documentation/api_jszip/file_regex.md
vendored
Normal file
49
vendors/jszip/documentation/api_jszip/file_regex.md
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
title: "file(regex)"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Search a file in the current folder and subfolders with a
|
||||
[regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).
|
||||
The regex is tested against the relative filename.
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | description
|
||||
------|--------|------------
|
||||
regex | RegExp | the regex to use.
|
||||
|
||||
__Returns__ : An array of matching files (an empty array if none matched). Each
|
||||
maching file is an instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html).
|
||||
|
||||
__Throws__ : Nothing.
|
||||
|
||||
<!--
|
||||
__Complexity__ : **O(k)** where k is the number of entries in the current JSZip
|
||||
instance.
|
||||
-->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
zip.file("file1.txt", "content");
|
||||
zip.file("file2.txt", "content");
|
||||
|
||||
zip.file(/file/); // array of size 2
|
||||
|
||||
// example with a relative path :
|
||||
var folder = zip.folder("sub");
|
||||
folder
|
||||
.file("file3.txt", "content") // relative path from folder : file3.txt
|
||||
.file("file4.txt", "content"); // relative path from folder : file4.txt
|
||||
|
||||
folder.file(/file/); // array of size 2
|
||||
folder.file(/^file/); // array of size 2, the relative paths start with file
|
||||
|
||||
// arrays contain objects in the form:
|
||||
// {name: "file2.txt", dir: false, asText : function () {...}, ...}
|
||||
```
|
||||
|
||||
|
||||
43
vendors/jszip/documentation/api_jszip/filter.md
vendored
Normal file
43
vendors/jszip/documentation/api_jszip/filter.md
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: "filter(predicate)"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Filter nested files/folders with the specified function.
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | description
|
||||
----------|----------|------------
|
||||
predicate | function | the predicate to use.
|
||||
|
||||
The predicate has the following signature : `function (relativePath, file) {...}` :
|
||||
|
||||
name | type | description
|
||||
-------------|-----------|------------
|
||||
relativePath | string | the filename and its path, reliatively to the current folder.
|
||||
file | ZipObject | the file being tested. See [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html).
|
||||
|
||||
The predicate must return true if the file should be included, false otherwise.
|
||||
|
||||
|
||||
__Returns__ : An array of matching ZipObject.
|
||||
|
||||
__Throws__ : Nothing.
|
||||
|
||||
<!-- __Complexity__ : **O(k)** where k is the number of entries. -->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
var zip = new JSZip().folder("dir");
|
||||
zip.file("readme.txt", "content");
|
||||
zip.filter(function (relativePath, file){
|
||||
// relativePath == "readme.txt"
|
||||
// file = {name:"dir/readme.txt",options:{...},asText:function}
|
||||
return true/false;
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
34
vendors/jszip/documentation/api_jszip/folder_data.md
vendored
Normal file
34
vendors/jszip/documentation/api_jszip/folder_data.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: "folder(name)"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Create a directory if it doesn't exist, return a new JSZip
|
||||
object with the new folder as root.
|
||||
|
||||
See also [the `dir` option of file()]({{site.baseurl}}/documentation/api_jszip/file_data.html).
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | description
|
||||
-----|--------|------------
|
||||
name | string | the name of the directory.
|
||||
|
||||
__Returns__ : A new JSZip (for chaining), with the new folder as root.
|
||||
|
||||
__Throws__ : Nothing.
|
||||
|
||||
<!-- __Complexity__ : **O(1)** -->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
zip.folder("images");
|
||||
zip.folder("css").file("style.css", "body {background: #FF0000}");
|
||||
// or specify an absolute path (using forward slashes)
|
||||
zip.file("css/font.css", "body {font-family: sans-serif}")
|
||||
|
||||
// result : images/, css/, css/style.css, css/font.css
|
||||
```
|
||||
|
||||
40
vendors/jszip/documentation/api_jszip/folder_regex.md
vendored
Normal file
40
vendors/jszip/documentation/api_jszip/folder_regex.md
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: "folder(regex)"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Search a subdirectory in the current directory with a
|
||||
[regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).
|
||||
The regex is tested against the relative path.
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | description
|
||||
------|--------|------------
|
||||
regex | RegExp | the regex to use.
|
||||
|
||||
__Returns__ : An array of matching folders (an empty array if none matched).
|
||||
Each maching folder is an instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html).
|
||||
|
||||
__Throws__ : Nothing.
|
||||
|
||||
<!--
|
||||
__Complexity__ : **O(k)** where k is the number of entries in the current JSZip
|
||||
instance.
|
||||
-->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
zip.folder("home/Pierre/videos");
|
||||
zip.folder("home/Pierre/photos");
|
||||
zip.folder("home/Jean/videos");
|
||||
zip.folder("home/Jean/photos");
|
||||
|
||||
zip.folder(/videos/); // array of size 2
|
||||
|
||||
zip.folder("home/Jean").folder(/^vid/); // array of 1
|
||||
```
|
||||
|
||||
161
vendors/jszip/documentation/api_jszip/generate.md
vendored
Normal file
161
vendors/jszip/documentation/api_jszip/generate.md
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
---
|
||||
title: "generate(options)"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Generates the complete zip file.
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | default | description
|
||||
--------------------|---------|---------|------------
|
||||
options | object | | the options to generate the zip file :
|
||||
options.base64 | boolean | false | **deprecated**, use `type` instead. If `type` is not used, set to `false` to get the result as a raw byte string, `true` to encode it as base64.
|
||||
options.compression | string | `STORE` (no compression) | the default file compression method to use. Available methods are `STORE` and `DEFLATE`. You can also provide your own compression method.
|
||||
options.compressionOptions | object | `null` | the options to use when compressing the file, see below.
|
||||
options.type | string | `base64` | The type of zip to return, see below for the other types.
|
||||
options.comment | string | | The comment to use for the zip file.
|
||||
options.mimeType | string | `application/zip` | mime-type for the generated file. Useful when you need to generate a file with a different extension, ie: ".ods".
|
||||
options.platform | string | `DOS` | The platform to use when generating the zip file.
|
||||
options.encodeFileName | function | encode with UTF-8 | the function to encode the file name / comment.
|
||||
|
||||
Possible values for `type` :
|
||||
|
||||
* `base64` (default) : the result will be a string, the binary in a base64 form.
|
||||
* `string` : the result will be a string in "binary" form, using 1 byte per char (2 bytes).
|
||||
* `uint8array` : the result will be a Uint8Array containing the zip. This requires a compatible browser.
|
||||
* `arraybuffer` : the result will be a ArrayBuffer containing the zip. This requires a compatible browser.
|
||||
* `blob` : the result will be a Blob containing the zip. This requires a compatible browser.
|
||||
* `nodebuffer` : the result will be a nodejs Buffer containing the zip. This requires nodejs.
|
||||
|
||||
Note : when using type = "uint8array", "arraybuffer" or "blob", be sure to
|
||||
check if the browser supports it (you can use [`JSZip.support`]({{site.baseurl}}/documentation/api_jszip/support.html)).
|
||||
|
||||
The `compressionOptions` parameter depends on the compression type. With
|
||||
`STORE` (no compression), this parameter is ignored. With `DEFLATE`, you can
|
||||
give the compression level with `compressionOptions : {level:6}` (or any level
|
||||
between 1 (best speed) and 9 (best compression)).
|
||||
|
||||
Note : if the entry is *already* compressed (coming from a compressed zip file),
|
||||
calling `generate()` with a different compression level won't update the entry.
|
||||
The reason is simple : JSZip doesn't know how compressed the content was and
|
||||
how to match the compression level with the implementation we use.
|
||||
|
||||
Note for the `comment` option : the zip format has no flag or field to give the
|
||||
encoding of this field and JSZip will use UTF-8. With non ASCII characters you
|
||||
might get encoding issues if the file archiver doesn't use UTF-8 to decode the
|
||||
comment.
|
||||
|
||||
If not set, JSZip will use the field `comment` on its `options`.
|
||||
|
||||
Possible values for `platform` : `DOS` and `UNIX`. It also accepts nodejs
|
||||
`process.platform` values.
|
||||
When using `DOS`, the attribute `dosPermissions` of each file is used.
|
||||
When using `UNIX`, the attribute `unixPermissions` of each file is used.
|
||||
|
||||
If you set the platform value on nodejs, be sure to use `process.platform`.
|
||||
`fs.stats` returns a non executable mode for folders on windows, if you
|
||||
force the platform to `UNIX` the generated zip file will have a strange
|
||||
behavior on UNIX platforms.
|
||||
|
||||
__About `encodeFileName`__ :
|
||||
|
||||
By default, JSZip uses UTF-8 to encode the file names / comments. You can use
|
||||
this method to force an other encoding. Note : the encoding used is not stored
|
||||
in a zip file, not using UTF-8 may lead to encoding issues.
|
||||
The function takes a string and returns a bytes array (Uint8Array or Array).
|
||||
|
||||
__Returns__ : The generated zip file.
|
||||
|
||||
__Throws__ : An exception if the asked `type` is not available in the browser,
|
||||
see [JSZip.support]({{site.baseurl}}/documentation/api_jszip/support.html).
|
||||
|
||||
<!-- __Complexity__ : TODO : worst case, with/out compression, etc -->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
var content = zip.generate({type:"blob"});
|
||||
// see FileSaver.js
|
||||
saveAs(content, "hello.zip");
|
||||
```
|
||||
|
||||
```js
|
||||
var content = zip.generate({type:"base64"});
|
||||
location.href="data:application/zip;base64,"+content;
|
||||
```
|
||||
|
||||
```js
|
||||
var content = zip.generate({type:"nodebuffer"});
|
||||
require("fs").writeFile("hello.zip", content, function(err){/*...*/});
|
||||
```
|
||||
|
||||
```js
|
||||
// on nodejs
|
||||
zip.file(pathname, content, {
|
||||
date: stat.mtime,
|
||||
unixPermissions: stat.mode
|
||||
});
|
||||
|
||||
// ...
|
||||
|
||||
zip.generate({
|
||||
type: 'nodebuffer',
|
||||
platform: process.platform
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
//This example will Generate a Open Document Spreasheet, with the correct mime type
|
||||
var zip = new JSZip();
|
||||
zip.file("mimetype", "application/vnd.oasis.opendocument.spreadsheet");
|
||||
var conf2 = zip.folder("Configurations2");
|
||||
conf2.folder("acceleator");
|
||||
conf2.folder("images");
|
||||
conf2.folder("popupmenu");
|
||||
conf2.folder("statusbar");
|
||||
conf2.folder("floater");
|
||||
conf2.folder("menubar");
|
||||
conf2.folder("progressbar");
|
||||
conf2.folder("toolbar");
|
||||
|
||||
var manifest = "<..."; //xml containing manifest.xml
|
||||
var styles = "<..."; //xml containing styles.xml
|
||||
var settings = "<..."; //xml containing settings.xml
|
||||
var meta = "<..."; //xml containing meta.xml
|
||||
var content = "<..."; //xml containing content.xml
|
||||
|
||||
var metaInf = zip.folder("META-INF");
|
||||
metaInf.file("manifest.xml", manifest);
|
||||
zip.file("styles.xml", styles);
|
||||
zip.file("settings.xml", settings);
|
||||
zip.file("meta.xml", meta);
|
||||
zip.file("content.xml", content);
|
||||
|
||||
//Generate the file
|
||||
var odsFile = zip.generate({type: "blob", mimeType: "application/ods", compression: "DEFLATE"});
|
||||
|
||||
var url = window.URL.createObjectURL(odsFile);
|
||||
var link = document.getElementById("link"); //I suppose you'll have a link with this id :)
|
||||
link.download = "testjs.ods";
|
||||
link.href = url;
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
Using a custom charset :
|
||||
|
||||
```js
|
||||
// using iconv-lite for example
|
||||
var iconv = require('iconv-lite');
|
||||
|
||||
zip.generate({
|
||||
type: 'uint8array',
|
||||
encodeFileName: function (string) {
|
||||
return iconv.encode(string, 'your-encoding');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
105
vendors/jszip/documentation/api_jszip/load.md
vendored
Normal file
105
vendors/jszip/documentation/api_jszip/load.md
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: "load(data [, options])"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Read an existing zip and merge the data in the current JSZip
|
||||
object at the current folder level. This technique has some limitations, see
|
||||
[here]({{site.baseurl}}/documentation/limitations.html).
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | description
|
||||
-------------------|--------|------------
|
||||
data | String/Array of bytes/ArrayBuffer/Uint8Array/Buffer | the zip file
|
||||
options | object | the options to load the zip file
|
||||
|
||||
Content of `options` :
|
||||
|
||||
name | type | default | description
|
||||
------------------------------|---------|---------|------------
|
||||
options.base64 | boolean | false | set to `true` if the data is base64 encoded, `false` for binary.
|
||||
options.checkCRC32 | boolean | false | set to `true` if the read data should be checked against its CRC32.
|
||||
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.
|
||||
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.
|
||||
options.decodeFileName | function | decode from UTF-8 | the function to decode the file name / comment.
|
||||
|
||||
You shouldn't update the data given to this method : it is kept as it so any
|
||||
update will impact the stored data.
|
||||
|
||||
Zip features supported by this method :
|
||||
|
||||
* Compression (<code>DEFLATE</code> supported)
|
||||
* zip with data descriptor
|
||||
* ZIP64
|
||||
* UTF8 in file name, UTF8 in file content
|
||||
|
||||
Zip features not (yet) supported :
|
||||
|
||||
* password protected zip
|
||||
* multi-volume zip
|
||||
|
||||
|
||||
__About `decodeFileName`__ :
|
||||
|
||||
A zip file has a flag to say if the filename and comment are encoded with UTF-8.
|
||||
If it's not set, JSZip has **no way** to know the encoding used. It usually
|
||||
is the default encoding of the operating system.
|
||||
|
||||
The function takes the bytes array (Uint8Array or Array) and returns the
|
||||
decoded string.
|
||||
|
||||
__Returns__ : The current JSZip object.
|
||||
|
||||
__Throws__ : An exception if the loaded data is not valid zip data or if it
|
||||
uses features (multi volume, password protected, etc).
|
||||
|
||||
<!--
|
||||
__Complexity__ : for k the number of entries in the zip file and n the length
|
||||
of the data :
|
||||
|
||||
The default use case is **O(k)**.
|
||||
If the data is in base64, we must first decode it : **O(k + n)**.
|
||||
If the data is a string not in base64 and optimizedBinaryString is false, we
|
||||
must apply the 0xFF mask : **O(k + n)**.
|
||||
If checkCRC32 is true, it **adds** to the above complexity **O(n)** and the
|
||||
complexity of the decompression algorithm.
|
||||
-->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
zip.load(zipDataFromXHR);
|
||||
```
|
||||
|
||||
```js
|
||||
require("fs").readFile("hello.zip", function (err, data) {
|
||||
if (err) throw err;
|
||||
var zip = new JSZip();
|
||||
zip.load(data);
|
||||
}
|
||||
```
|
||||
|
||||
Using sub folders :
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
zip.folder("subfolder").load(data);
|
||||
// the content of data will be loaded in subfolder/
|
||||
```
|
||||
|
||||
Using a custom charset :
|
||||
|
||||
```js
|
||||
// using iconv-lite for example
|
||||
var iconv = require('iconv-lite');
|
||||
|
||||
zip.load(content, {
|
||||
decodeFileName: function (bytes) {
|
||||
return iconv.decode(bytes, 'your-encoding');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
37
vendors/jszip/documentation/api_jszip/remove.md
vendored
Normal file
37
vendors/jszip/documentation/api_jszip/remove.md
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: "remove(name)"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
__Description__ : Delete a file or folder (recursively).
|
||||
|
||||
__Arguments__
|
||||
|
||||
name | type | description
|
||||
-----|--------|------------
|
||||
name | string | the name of the file/folder to delete.
|
||||
|
||||
__Returns__ : The current JSZip object.
|
||||
|
||||
__Throws__ : Nothing.
|
||||
|
||||
<!--
|
||||
__Complexity__ : **O(k)** where k is the number of entry to delete (may be > 1
|
||||
when removing a folder).
|
||||
-->
|
||||
|
||||
__Example__
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
zip.file("Hello.txt", "Hello World\n");
|
||||
zip.file("temp.txt", "nothing").remove("temp.txt");
|
||||
// result : Hello.txt
|
||||
|
||||
zip.folder("css").file("style.css", "body {background: #FF0000}");
|
||||
zip.remove("css");
|
||||
//result : empty zip
|
||||
```
|
||||
|
||||
|
||||
16
vendors/jszip/documentation/api_jszip/support.md
vendored
Normal file
16
vendors/jszip/documentation/api_jszip/support.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: "JSZip.support"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
If the browser supports them, JSZip can take advantage of some "new" features :
|
||||
ArrayBuffer, Blob, Uint8Array. To know if JSZip can use them, you can check the
|
||||
JSZip.support object. It contains the following boolean properties :
|
||||
|
||||
* `arraybuffer` : true if JSZip can read and generate ArrayBuffer, false otherwise.
|
||||
* `uint8array` : true if JSZip can read and generate Uint8Array, false otherwise.
|
||||
* `blob` : true if JSZip can generate Blob, false otherwise.
|
||||
* `nodebuffer` : true if JSZip can read and generate nodejs Buffer, false otherwise.
|
||||
|
||||
|
||||
37
vendors/jszip/documentation/api_zipobject.md
vendored
Normal file
37
vendors/jszip/documentation/api_zipobject.md
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: "ZipObject API"
|
||||
layout: default
|
||||
section: api
|
||||
---
|
||||
|
||||
This represents an entry in the zip file. If the entry comes from an existing
|
||||
archive previously [loaded]({{site.baseurl}}/documentation/api_jszip/load.html), the content
|
||||
will be automatically decompressed/converted first.
|
||||
|
||||
### Attributes
|
||||
|
||||
attribute name | type | description
|
||||
----------------------------|-------------|-------------
|
||||
`name` | string | the absolute path of the file
|
||||
`dir` | boolean | true if this is a directory
|
||||
`date` | date | the last modification date
|
||||
`comment` | string | the comment for this file
|
||||
`unixPermissions` | 16 bits number | The UNIX permissions of the file, if any.
|
||||
`dosPermissions` | 6 bits number | The DOS permissions of the file, if any.
|
||||
`options` | object | the options of the file. The available options are :
|
||||
`options.base64` | boolean | **Deprecated**, see [file(name, data [,options])]({{site.baseurl}}/documentation/api_jszip/file_data.html)
|
||||
`options.binary` | boolean | **Deprecated**, see [file(name, data [,options])]({{site.baseurl}}/documentation/api_jszip/file_data.html)
|
||||
`options.dir` | boolean | **Deprecated**, use `dir`. True if this is a directory
|
||||
`options.date` | date | **Deprecated**, use `date`. See [file(name, data [,options])]({{site.baseurl}}/documentation/api_jszip/file_data.html)
|
||||
`options.compression` | compression | see [file(name, data [,options])]({{site.baseurl}}/documentation/api_jszip/file_data.html)
|
||||
|
||||
|
||||
### Getters
|
||||
|
||||
method | return type | description
|
||||
------------------|---------------|-------------
|
||||
`asText()` | string | the content as an unicode string.
|
||||
`asBinary()` | string | the content as binary string.
|
||||
`asArrayBuffer()` | ArrayBuffer | need a [compatible browser]({{site.baseurl}}/documentation/api_jszip/support.html).
|
||||
`asUint8Array()` | Uint8Array | need a [compatible browser]({{site.baseurl}}/documentation/api_jszip/support.html).
|
||||
`asNodeBuffer()` | nodejs Buffer | need [nodejs]({{site.baseurl}}/documentation/api_jszip/support.html).
|
||||
62
vendors/jszip/documentation/contributing.md
vendored
Normal file
62
vendors/jszip/documentation/contributing.md
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
---
|
||||
title: Contributing
|
||||
layout: default
|
||||
section: main
|
||||
---
|
||||
|
||||
|
||||
### Download the sources
|
||||
|
||||
You should create a [Github](https://github.com/) account and
|
||||
[fork the repository](https://help.github.com/articles/fork-a-repo) (you will
|
||||
need one to create the pull request).
|
||||
|
||||
If you just want the get the source code, you can use git and do
|
||||
`git clone https://github.com/Stuk/jszip.git` to get the sources. You can also
|
||||
download the latest sources [here](https://github.com/Stuk/jszip/archive/master.zip).
|
||||
|
||||
### Building the project
|
||||
|
||||
#### Code
|
||||
|
||||
The dependencies are handled by npm, the first step is to run
|
||||
`npm install` to get the dependencies.
|
||||
JSZip uses Grunt to handle the build, [see here to install its CLI](http://gruntjs.com/getting-started).
|
||||
|
||||
Here are the interesting build commands :
|
||||
|
||||
* `grunt` will generate the final js file in dist/ and the minified version.
|
||||
* `npm run test-node` will run the tests in nodejs.
|
||||
* `npm run test-browser` will the tests in some browsers using SauceLabs, see
|
||||
below.
|
||||
* `npm run test` will run the tests in nodejs and in the browser.
|
||||
* `npm run lint` will use jshint the check the source code.
|
||||
|
||||
#### Documentation
|
||||
|
||||
The documentation uses jekyll on gh-pages. To render the documentation, you
|
||||
need to [install jekyll](http://jekyllrb.com/docs/installation/) and then run
|
||||
`jekyll serve --baseurl ''`.
|
||||
|
||||
### Testing the project
|
||||
|
||||
To test JSZip in nodejs, use `npm run test-node`.
|
||||
|
||||
To test JSZip in a browser, you can open the file `test/index.html` in the
|
||||
browser you want to test. Don't forget to update the dist/ files with `grunt`.
|
||||
|
||||
You can also test JSZip in a lot of browsers at once with
|
||||
[SauceLabs](https://saucelabs.com/). You will need a SauceLabs account and two
|
||||
variables into your environment. On linux, just use
|
||||
|
||||
```bash
|
||||
export SAUCE_USERNAME=your-saucelabs-username
|
||||
export SAUCE_ACCESS_KEY=your-saucelabs-access-key
|
||||
```
|
||||
|
||||
before running the `npm run test-browser` command.
|
||||
|
||||
### Merging the changes
|
||||
|
||||
If you have tested bug fixes or new features, you can open a
|
||||
[pull request](https://help.github.com/articles/using-pull-requests) on Github.
|
||||
24
vendors/jszip/documentation/css/main.css
vendored
Normal file
24
vendors/jszip/documentation/css/main.css
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
ul.nav ul {
|
||||
list-style:none;
|
||||
margin: 0;
|
||||
padding: 0 0 0 25px;
|
||||
}
|
||||
|
||||
#downloader_application form {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#downloader_application ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.browser_support th {
|
||||
border-bottom-width: 3px !important;
|
||||
}
|
||||
|
||||
.support_ie {border-bottom-color: #0275BA !important;}
|
||||
.support_ff {border-bottom-color: #DF7215 !important;}
|
||||
.support_sf {border-bottom-color: #43B3E9 !important;}
|
||||
.support_cr {border-bottom-color: #39B642 !important;}
|
||||
.support_op {border-bottom-color: #C42122 !important;}
|
||||
.support_nd {border-bottom-color: #8CC84B !important;}
|
||||
64
vendors/jszip/documentation/css/pygments.css
vendored
Normal file
64
vendors/jszip/documentation/css/pygments.css
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/* Generated with :
|
||||
* pygmentize -S default -f html > pygments.css
|
||||
*/
|
||||
.hll { background-color: #ffffcc }
|
||||
.c { color: #408080; font-style: italic } /* Comment */
|
||||
.err { border: 1px solid #FF0000 } /* Error */
|
||||
.k { color: #008000; font-weight: bold } /* Keyword */
|
||||
.o { color: #666666 } /* Operator */
|
||||
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
||||
.cp { color: #BC7A00 } /* Comment.Preproc */
|
||||
.c1 { color: #408080; font-style: italic } /* Comment.Single */
|
||||
.cs { color: #408080; font-style: italic } /* Comment.Special */
|
||||
.gd { color: #A00000 } /* Generic.Deleted */
|
||||
.ge { font-style: italic } /* Generic.Emph */
|
||||
.gr { color: #FF0000 } /* Generic.Error */
|
||||
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||
.gi { color: #00A000 } /* Generic.Inserted */
|
||||
.go { color: #888888 } /* Generic.Output */
|
||||
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
||||
.gs { font-weight: bold } /* Generic.Strong */
|
||||
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||
.gt { color: #0044DD } /* Generic.Traceback */
|
||||
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
|
||||
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
|
||||
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
|
||||
.kp { color: #008000 } /* Keyword.Pseudo */
|
||||
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
|
||||
.kt { color: #B00040 } /* Keyword.Type */
|
||||
.m { color: #666666 } /* Literal.Number */
|
||||
.s { color: #BA2121 } /* Literal.String */
|
||||
.na { color: #7D9029 } /* Name.Attribute */
|
||||
.nb { color: #008000 } /* Name.Builtin */
|
||||
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
||||
.no { color: #880000 } /* Name.Constant */
|
||||
.nd { color: #AA22FF } /* Name.Decorator */
|
||||
.ni { color: #999999; font-weight: bold } /* Name.Entity */
|
||||
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
||||
.nf { color: #0000FF } /* Name.Function */
|
||||
.nl { color: #A0A000 } /* Name.Label */
|
||||
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
||||
.nt { color: #008000; font-weight: bold } /* Name.Tag */
|
||||
.nv { color: #19177C } /* Name.Variable */
|
||||
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
||||
.w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.mf { color: #666666 } /* Literal.Number.Float */
|
||||
.mh { color: #666666 } /* Literal.Number.Hex */
|
||||
.mi { color: #666666 } /* Literal.Number.Integer */
|
||||
.mo { color: #666666 } /* Literal.Number.Oct */
|
||||
.sb { color: #BA2121 } /* Literal.String.Backtick */
|
||||
.sc { color: #BA2121 } /* Literal.String.Char */
|
||||
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
||||
.s2 { color: #BA2121 } /* Literal.String.Double */
|
||||
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
||||
.sh { color: #BA2121 } /* Literal.String.Heredoc */
|
||||
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
||||
.sx { color: #008000 } /* Literal.String.Other */
|
||||
.sr { color: #BB6688 } /* Literal.String.Regex */
|
||||
.s1 { color: #BA2121 } /* Literal.String.Single */
|
||||
.ss { color: #19177C } /* Literal.String.Symbol */
|
||||
.bp { color: #008000 } /* Name.Builtin.Pseudo */
|
||||
.vc { color: #19177C } /* Name.Variable.Class */
|
||||
.vg { color: #19177C } /* Name.Variable.Global */
|
||||
.vi { color: #19177C } /* Name.Variable.Instance */
|
||||
.il { color: #666666 } /* Literal.Number.Integer.Long */
|
||||
115
vendors/jszip/documentation/examples.md
vendored
Normal file
115
vendors/jszip/documentation/examples.md
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
---
|
||||
title: "How to use JSZip"
|
||||
layout: default
|
||||
section: example
|
||||
---
|
||||
|
||||
An instance of JSZip represents a set of files. You can add them, remove them,
|
||||
modify them. You can also import an existing zip file or generate one.
|
||||
|
||||
### Getting the object
|
||||
|
||||
#### In a browser
|
||||
|
||||
For a browser, there are two interesting files : `dist/jszip.js` and
|
||||
`dist/jszip.min.js` (include just one).
|
||||
|
||||
If you use an AMD loader (RequireJS for example) JSZip will register itself :
|
||||
you just have to put the js file at the right place, or configure the loader
|
||||
(see [here for RequireJS](http://requirejs.org/docs/api.html#config-paths)).
|
||||
|
||||
Without any loader, JSZip will declare in the global scope a variable named `JSZip`.
|
||||
|
||||
#### In nodejs
|
||||
|
||||
In nodejs, you can `require` it :
|
||||
|
||||
```js
|
||||
var JSZip = require("jszip");
|
||||
```
|
||||
|
||||
### Basic manipulations
|
||||
|
||||
The first step is to create an instance of JSZip :
|
||||
|
||||
```js
|
||||
var zip = new JSZip();
|
||||
```
|
||||
|
||||
On this instance, we can add (and update) files and folders with
|
||||
`.file(name, content)` and `.folder(name)`.
|
||||
They return the current JSZip instance so you can chain the calls.
|
||||
|
||||
```js
|
||||
// create a file
|
||||
zip.file("hello.txt", "Hello[p my)6cxsw2q");
|
||||
// oops, cat on keyboard. Fixing !
|
||||
zip.file("hello.txt", "Hello World\n");
|
||||
|
||||
// create a file and a folder
|
||||
zip.file("nested/hello.txt", "Hello World\n");
|
||||
// same as
|
||||
zip.folder("nested").file("hello.txt", "Hello World\n");
|
||||
```
|
||||
|
||||
With `.folder(name)`, the returned object has a different root : if you add files
|
||||
on this object, you will put them in the created subfolder. This is just a
|
||||
view, the added files will also be in the "root" object.
|
||||
|
||||
```js
|
||||
var photoZip = zip.folder("photos");
|
||||
// this call will create photos/README
|
||||
photoZip.file("README", "a folder with photos");
|
||||
```
|
||||
|
||||
You can access the file content with `.file(name)` and
|
||||
[its getters]({{site.baseurl}}/documentation/api_zipobject.html) :
|
||||
|
||||
```js
|
||||
zip.file("hello.txt").asText(); // "Hello World\n"
|
||||
|
||||
if (JSZip.support.uint8array) {
|
||||
zip.file("hello.txt").asUint8Array(); // Uint8Array { 0=72, 1=101, 2=108, more...}
|
||||
}
|
||||
```
|
||||
|
||||
You can also remove files or folders with `.remove(name)` :
|
||||
|
||||
```js
|
||||
zip.remove("photos/README");
|
||||
zip.remove("photos");
|
||||
// same as
|
||||
zip.remove("photos"); // by removing the folder, you also remove its content.
|
||||
```
|
||||
|
||||
### Generate a zip file
|
||||
|
||||
With `.generate(options)` you can generate a zip file (not a real file but its
|
||||
representation in memory). Check
|
||||
[this page]({{site.baseurl}}/documentation/howto/write_zip.html) for more
|
||||
informations on how to write / give the file to the user.
|
||||
|
||||
```js
|
||||
var content = null;
|
||||
if (JSZip.support.uint8array) {
|
||||
content = zip.generate({type : "uint8array"});
|
||||
} else {
|
||||
content = zip.generate({type : "string"});
|
||||
}
|
||||
```
|
||||
|
||||
### Read a zip file
|
||||
|
||||
With `.load(data)` you can load a zip file. Check
|
||||
[this page]({{site.baseurl}}/documentation/howto/read_zip.html) to see how to
|
||||
do properly (it's more tricky that it seems).
|
||||
|
||||
```js
|
||||
var new_zip = new JSZip();
|
||||
// more files !
|
||||
new_zip.load(content);
|
||||
|
||||
// you now have every files contained in the loaded zip
|
||||
new_zip.file("hello.txt").asText(); // "Hello World\n"
|
||||
```
|
||||
|
||||
59
vendors/jszip/documentation/examples/download-zip-file.html
vendored
Normal file
59
vendors/jszip/documentation/examples/download-zip-file.html
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: "Download the generated zip file"
|
||||
layout: default
|
||||
section: example
|
||||
---
|
||||
|
||||
<p>Tip : check the source of the page !</p>
|
||||
<h2>The FileSaver API</h2>
|
||||
<div>
|
||||
Works on firefox, chrome , opera >= 15 and IE >= 10 (but NOT in compatibility view).<br/>
|
||||
<button id="blob" class="btn btn-primary">click to download</button>
|
||||
</div>
|
||||
<h2>The data URL</h2>
|
||||
<div>
|
||||
Does not work in IE, has restrictions on the length.<br/>
|
||||
<button id="data_uri" class="btn btn-primary">click to download</button>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var zip = new JSZip();
|
||||
zip.file("Hello.txt", "Hello world\n");
|
||||
|
||||
function bindEvent(el, eventName, eventHandler) {
|
||||
if (el.addEventListener){
|
||||
// standard way
|
||||
el.addEventListener(eventName, eventHandler, false);
|
||||
} else if (el.attachEvent){
|
||||
// old IE
|
||||
el.attachEvent('on'+eventName, eventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
// Blob
|
||||
var blobLink = document.getElementById('blob');
|
||||
if (JSZip.support.blob) {
|
||||
function downloadWithBlob() {
|
||||
try {
|
||||
var blob = zip.generate({type:"blob"});
|
||||
// see FileSaver.js
|
||||
saveAs(blob, "hello.zip");
|
||||
} catch(e) {
|
||||
blobLink.innerHTML += " " + e;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bindEvent(blobLink, 'click', downloadWithBlob);
|
||||
} else {
|
||||
blobLink.innerHTML += " (not supported on this browser)";
|
||||
}
|
||||
|
||||
// data URI
|
||||
function downloadWithDataURI() {
|
||||
window.location = "data:application/zip;base64," + zip.generate({type:"base64"});
|
||||
}
|
||||
var dataUriLink = document.getElementById('data_uri');
|
||||
bindEvent(dataUriLink, 'click', downloadWithDataURI);
|
||||
|
||||
})();
|
||||
</script>
|
||||
58
vendors/jszip/documentation/examples/downloader.html
vendored
Normal file
58
vendors/jszip/documentation/examples/downloader.html
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
---
|
||||
title: "Mini app : Downloader"
|
||||
layout: default
|
||||
section: example
|
||||
---
|
||||
|
||||
<p>Tip : check the source of the page !</p>
|
||||
|
||||
<p>
|
||||
This mini application let you choose the files you want in a list, download
|
||||
them, zip them and give the result to the user.
|
||||
</p>
|
||||
<p>
|
||||
This demo requires a recent browser, see <a href="{{site.baseurl}}/documentation/howto/write_zip.html">
|
||||
the howto</a>.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<div id="downloader_application">
|
||||
<h3>Please select your files</h3>
|
||||
<form action="#" id="download_form">
|
||||
<ul>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" data-url="{{site.baseurl}}/test/ref/complex_files/Franz Kafka - The Metamorphosis.epub" checked />
|
||||
Franz Kafka - The Metamorphosis.epub
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" data-url="{{site.baseurl}}/documentation/css/pygments.css" checked />
|
||||
pygments.css
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" data-url="{{site.baseurl}}/dist/jszip.js" />
|
||||
jszip.js
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" data-url="{{site.baseurl}}/test/ref/all.zip" />
|
||||
all.zip
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<button type="submit" class="btn btn-primary">pack them !</button>
|
||||
</form>
|
||||
|
||||
<p class="hide" id="result"></p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="{{site.baseurl}}/documentation/examples/downloader.js"></script>
|
||||
89
vendors/jszip/documentation/examples/downloader.js
vendored
Normal file
89
vendors/jszip/documentation/examples/downloader.js
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
jQuery(function ($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Reset the message.
|
||||
*/
|
||||
function resetMessage () {
|
||||
$("#result")
|
||||
.removeClass()
|
||||
.text("");
|
||||
}
|
||||
/**
|
||||
* show a successful message.
|
||||
* @param {String} text the text to show.
|
||||
*/
|
||||
function showMessage(text) {
|
||||
resetMessage();
|
||||
$("#result")
|
||||
.addClass("alert alert-success")
|
||||
.text(text);
|
||||
}
|
||||
/**
|
||||
* show an error message.
|
||||
* @param {String} text the text to show.
|
||||
*/
|
||||
function showError(text) {
|
||||
resetMessage();
|
||||
$("#result")
|
||||
.addClass("alert alert-danger")
|
||||
.text(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the content, add it to the JSZip object
|
||||
* and use a jQuery deferred to hold the result.
|
||||
* @param {String} url the url of the content to fetch.
|
||||
* @param {String} filename the filename to use in the JSZip object.
|
||||
* @param {JSZip} zip the JSZip instance.
|
||||
* @return {jQuery.Deferred} the deferred containing the data.
|
||||
*/
|
||||
function deferredAddZip(url, filename, zip) {
|
||||
var deferred = $.Deferred();
|
||||
JSZipUtils.getBinaryContent(url, function (err, data) {
|
||||
if(err) {
|
||||
deferred.reject(err);
|
||||
} else {
|
||||
zip.file(filename, data, {binary:true});
|
||||
deferred.resolve(data);
|
||||
}
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
|
||||
if(!JSZip.support.blob) {
|
||||
showError("This demo works only with a recent browser !");
|
||||
return;
|
||||
}
|
||||
|
||||
var $form = $("#download_form").on("submit", function () {
|
||||
|
||||
resetMessage();
|
||||
|
||||
var zip = new JSZip();
|
||||
var deferreds = [];
|
||||
|
||||
// find every checked item
|
||||
$(this).find(":checked").each(function () {
|
||||
var $this = $(this);
|
||||
var url = $this.data("url");
|
||||
var filename = url.replace(/.*\//g, "");
|
||||
deferreds.push(deferredAddZip(url, filename, zip));
|
||||
});
|
||||
|
||||
// when everything has been downloaded, we can trigger the dl
|
||||
$.when.apply($, deferreds).done(function () {
|
||||
var blob = zip.generate({type:"blob"});
|
||||
|
||||
// see FileSaver.js
|
||||
saveAs(blob, "example.zip");
|
||||
|
||||
showMessage("done !");
|
||||
}).fail(function (err) {
|
||||
showError(err);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
// vim: set shiftwidth=4 softtabstop=4:
|
||||
43
vendors/jszip/documentation/examples/get-binary-files-ajax.html
vendored
Normal file
43
vendors/jszip/documentation/examples/get-binary-files-ajax.html
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: "Get a file with an ajax call"
|
||||
layout: default
|
||||
section: example
|
||||
---
|
||||
|
||||
<p>Tip : check the source of the page !</p>
|
||||
|
||||
<h3>With JSZipUtils</h3>
|
||||
<div id="jszip_utils"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
|
||||
function showError(elt, err) {
|
||||
elt.innerHTML = "<p class='alert alert-danger'>" + err + "</p>";
|
||||
}
|
||||
|
||||
function showContent(elt, type, content) {
|
||||
elt.innerHTML = "<p class='alert alert-success'>loaded ! (as a " + type + ")<br/>" +
|
||||
"Content = " + content + "</p>";
|
||||
}
|
||||
|
||||
//=========================
|
||||
// JSZipUtils
|
||||
//=========================
|
||||
JSZipUtils.getBinaryContent('{{site.baseurl}}/test/ref/text.zip', function(err, data) {
|
||||
var elt = document.getElementById('jszip_utils');
|
||||
if(err) {
|
||||
showError(elt, err);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var zip = new JSZip(data);
|
||||
showContent(elt, "" + data, zip.file("Hello.txt").asText());
|
||||
} catch(e) {
|
||||
showError(elt, e);
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
87
vendors/jszip/documentation/examples/read-local-file-api.html
vendored
Normal file
87
vendors/jszip/documentation/examples/read-local-file-api.html
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
title: "Reading a local file with the File API"
|
||||
layout: default
|
||||
section: example
|
||||
---
|
||||
|
||||
<h3>Choose the local(s) zip file(s)</h3>
|
||||
<p class="note">Note : your browser will process the zip file, don't choose a file too big !</p>
|
||||
<input type="file" id="file" name="file" multiple /><br />
|
||||
|
||||
<div id="error_block" class="alert alert-danger hidden">
|
||||
You will need a recent browser to use this demo :(
|
||||
</div>
|
||||
|
||||
<div id="result_block" class="hidden">
|
||||
<h3>Content :</h3>
|
||||
<div id="result"></div>
|
||||
</div>
|
||||
<script type="text/javascript" src="{{site.baseurl}}/test/jquery-1.8.3.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
if (!window.FileReader || !window.ArrayBuffer) {
|
||||
$("#error_block").removeClass("hidden").addClass("show");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var $result = $("#result");
|
||||
$("#file").on("change", function(evt) {
|
||||
// remove content
|
||||
$result.html("");
|
||||
// be sure to show the results
|
||||
$("#result_block").removeClass("hidden").addClass("show");
|
||||
|
||||
// see http://www.html5rocks.com/en/tutorials/file/dndfiles/
|
||||
|
||||
var files = evt.target.files;
|
||||
for (var i = 0, f; f = files[i]; i++) {
|
||||
|
||||
var reader = new FileReader();
|
||||
|
||||
// Closure to capture the file information.
|
||||
reader.onload = (function(theFile) {
|
||||
return function(e) {
|
||||
var $title = $("<h4>", {
|
||||
text : theFile.name
|
||||
});
|
||||
$result.append($title);
|
||||
var $fileContent = $("<ul>");
|
||||
try {
|
||||
|
||||
var dateBefore = new Date();
|
||||
// read the content of the file with JSZip
|
||||
var zip = new JSZip(e.target.result);
|
||||
var dateAfter = new Date();
|
||||
|
||||
$title.append($("<span>", {
|
||||
text:" (parsed in " + (dateAfter - dateBefore) + "ms)"
|
||||
}));
|
||||
|
||||
// that, or a good ol' for(var entryName in zip.files)
|
||||
$.each(zip.files, function (index, zipEntry) {
|
||||
$fileContent.append($("<li>", {
|
||||
text : zipEntry.name
|
||||
}));
|
||||
// the content is here : zipEntry.asText()
|
||||
});
|
||||
// end of the magic !
|
||||
|
||||
} catch(e) {
|
||||
$fileContent = $("<div>", {
|
||||
"class" : "alert alert-danger",
|
||||
text : "Error reading " + theFile.name + " : " + e.message
|
||||
});
|
||||
}
|
||||
$result.append($fileContent);
|
||||
}
|
||||
})(f);
|
||||
|
||||
// read the file !
|
||||
// readAsArrayBuffer and readAsBinaryString both produce valid content for JSZip.
|
||||
reader.readAsArrayBuffer(f);
|
||||
// reader.readAsBinaryString(f);
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
19
vendors/jszip/documentation/faq.md
vendored
Normal file
19
vendors/jszip/documentation/faq.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
title: "Frequently Asked Questions"
|
||||
layout: default
|
||||
section: main
|
||||
---
|
||||
|
||||
### "Corrupted zip or bug : unexpected signature"
|
||||
|
||||
If you are sure that the zip file is correct, that error often comes from a
|
||||
corrupted content. An ajax request, if not prepared correctly, will try to
|
||||
decode the binary content as a text and corrupt it. See
|
||||
[this page]({{site.baseurl}}/documentation/howto/read_zip.html).
|
||||
|
||||
### My browser crashes / becomes unresponsive / never finish the execution
|
||||
|
||||
That happens if you try to handle to much data. If possible, try again with a
|
||||
small (some KB) zip file to see if your code is correct. See
|
||||
[this page]({{site.baseurl}}/documentation/limitations.html) for more
|
||||
informations.
|
||||
152
vendors/jszip/documentation/howto/read_zip.md
vendored
Normal file
152
vendors/jszip/documentation/howto/read_zip.md
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
---
|
||||
title: "How to read a file"
|
||||
layout: default
|
||||
section: example
|
||||
---
|
||||
|
||||
This page explains how to read an existing zip file or add a existing file into
|
||||
the zip file.
|
||||
|
||||
|
||||
### In the browser
|
||||
|
||||
#### AJAX request
|
||||
|
||||
Getting binary data with an ajax request is hard (mainly because of IE <= 9).
|
||||
The easy way is to use [JSZipUtils.getBinaryContent](https://github.com/stuk/jszip-utils).
|
||||
With JSZipUtils.getBinaryContent, you can do the following (see the
|
||||
documentation for more examples) :
|
||||
|
||||
```js
|
||||
JSZipUtils.getBinaryContent('path/to/content.zip', function(err, data) {
|
||||
if(err) {
|
||||
throw err; // or handle err
|
||||
}
|
||||
|
||||
var zip = new JSZip(data);
|
||||
});
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
If you need to adapt an existing solution to what getBinaryContent does, here
|
||||
are the details. When doing a XHR request (level 1, without setting the
|
||||
`responseType`) the browser will try to interpret the response as a string and
|
||||
decode it from its charset. To avoid this on Firefox/Chrome/Opera, you need to
|
||||
set mime type : `xhr.overrideMimeType("text/plain; charset=x-user-defined");`.
|
||||
On IE <= 9, this is harder. The overrideMimeType trick doesn't work so we need
|
||||
to use [vbscript](http://stackoverflow.com/questions/1095102/how-do-i-load-binary-image-data-using-javascript-and-xmlhttprequest)
|
||||
and non standard attributes.
|
||||
On IE > 9, overrideMimeType doesn't work but xhr2 does.
|
||||
|
||||
With [xhr 2](http://caniuse.com/xhr2), you can just set the responseType
|
||||
attribute : `xhr.responseType = "arraybuffer";`. With this, the browser will
|
||||
return an ArrayBuffer.
|
||||
|
||||
#### Local files
|
||||
|
||||
If the browser supports the [FileReader API](http://caniuse.com/filereader),
|
||||
you can use it to read a zip file. JSZip can read ArrayBuffer, so you can use
|
||||
`FileReader.readAsArrayBuffer(Blob)`, see this [example]({{site.baseurl}}/documentation/examples/read-local-file-api.html).
|
||||
|
||||
### In nodejs
|
||||
|
||||
JSZip can read Buffers so you can do the following :
|
||||
|
||||
#### Local file
|
||||
|
||||
```js
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs");
|
||||
var JSZip = require("jszip");
|
||||
|
||||
// read a zip file
|
||||
fs.readFile("test.zip", function(err, data) {
|
||||
if (err) throw err;
|
||||
var zip = new JSZip(data);
|
||||
});
|
||||
|
||||
// read a file and add it to a zip
|
||||
fs.readFile("picture.png", function(err, data) {
|
||||
if (err) throw err;
|
||||
var zip = new JSZip();
|
||||
zip.file("picture.png", data);
|
||||
});
|
||||
```
|
||||
|
||||
#### Remote file
|
||||
|
||||
There are a lot of nodejs libraries doing http requests, from the built-in
|
||||
[http](http://nodejs.org/docs/latest/api/http.html) to the
|
||||
[npm packages](https://www.npmjs.org/browse/keyword/http). Here are two
|
||||
examples, one with the default http API, the other with
|
||||
[request](https://github.com/mikeal/request) (but you're free to use your
|
||||
favorite library !). If possible, download the file as a Buffer (you will get
|
||||
better performances). If it's not possible, you can fallback to a binary string
|
||||
(the option is likely to be `encoding : "binary"`).
|
||||
|
||||
##### With http :
|
||||
|
||||
```js
|
||||
"use strict";
|
||||
|
||||
var http = require("http");
|
||||
var url = require("url");
|
||||
var JSZip = require("jszip");
|
||||
|
||||
var req = http.get(url.parse("http://localhost/.../file.zip"), function (res) {
|
||||
if (res.statusCode !== 200) {
|
||||
console.log(res.statusCode);
|
||||
// handle error
|
||||
return;
|
||||
}
|
||||
var data = [], dataLen = 0;
|
||||
|
||||
// don't set the encoding, it will break everything !
|
||||
// or, if you must, set it to null. In that case the chunk will be a string.
|
||||
|
||||
res.on("data", function (chunk) {
|
||||
data.push(chunk);
|
||||
dataLen += chunk.length;
|
||||
});
|
||||
|
||||
res.on("end", function () {
|
||||
var buf = new Buffer(dataLen);
|
||||
for (var i=0,len=data.length,pos=0; i<len; i++) {
|
||||
data[i].copy(buf, pos);
|
||||
pos += data[i].length;
|
||||
}
|
||||
|
||||
// here we go !
|
||||
var zip = new JSZip(buf);
|
||||
console.log(zip.file("content.txt").asText());
|
||||
});
|
||||
});
|
||||
|
||||
req.on("error", function(err){
|
||||
// handle error
|
||||
});
|
||||
```
|
||||
|
||||
##### With request :
|
||||
|
||||
```js
|
||||
"use strict";
|
||||
|
||||
var request = require('request');
|
||||
var JSZip = require("jszip");
|
||||
|
||||
request({
|
||||
method : "GET",
|
||||
url : "http://localhost/.../file.zip",
|
||||
encoding: null // <- this one is important !
|
||||
}, function (error, response, body) {
|
||||
if(error || response.statusCode !== 200) {
|
||||
// handle error
|
||||
return;
|
||||
}
|
||||
var zip = new JSZip(body);
|
||||
console.log(zip.file("content.txt").asText());
|
||||
});
|
||||
```
|
||||
106
vendors/jszip/documentation/howto/write_zip.md
vendored
Normal file
106
vendors/jszip/documentation/howto/write_zip.md
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
---
|
||||
title: "How to write a file / give it to the user"
|
||||
layout: default
|
||||
section: example
|
||||
---
|
||||
|
||||
### In the browser
|
||||
|
||||
With only javascript, this part won't work in old browsers, including IE < 10.
|
||||
For those browsers, you can use a flash polyfill, see below.
|
||||
|
||||
You can also see this
|
||||
[example]({{site.baseurl}}/documentation/examples/download-zip-file.html).
|
||||
|
||||
#### Blob URL / FileSaver
|
||||
|
||||
With recent browsers, the easiest way is to use `saveAs` or a polyfill, see
|
||||
[FileSaver.js](https://github.com/eligrey/FileSaver.js) :
|
||||
|
||||
```js
|
||||
var blob = zip.generate({type:"blob"});
|
||||
saveAs(blob, "hello.zip");
|
||||
```
|
||||
|
||||
Under the hood, the polyfill uses the native `saveAs` from the
|
||||
[FileSaver](http://www.w3.org/TR/file-writer-api/#the-filesaver-interface) API
|
||||
(on Chrome and IE10+) or use a [Blob URL](http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download)
|
||||
(on Firefox).
|
||||
|
||||
|
||||
#### Data URI
|
||||
|
||||
For older browsers that support [data URI](http://caniuse.com/datauri), you can also
|
||||
do the following :
|
||||
|
||||
```js
|
||||
location.href="data:application/zip;base64," + zip.generate({type:"base64"});
|
||||
```
|
||||
|
||||
The biggest issue here is that the filenames are very awkward, Firefox
|
||||
generates filenames such as `a5sZQRsx.zip.part` (see bugs
|
||||
[367231](https://bugzilla.mozilla.org/show_bug.cgi?id=367231) and
|
||||
[532230](https://bugzilla.mozilla.org/show_bug.cgi?id=532230), and Safari
|
||||
isn't much better with just `Unknown`.
|
||||
|
||||
Browser support and resulting filename :
|
||||
|
||||
Opera | Firefox | Safari | Chrome | Internet Explorer
|
||||
-------|---------|--------|--------|------------------
|
||||
"default.zip" | random alphanumeric with ".part" extension | "Unknown" (no extension) | "download.zip" on OSX and Linux, just "download" on Windows | No
|
||||
|
||||
#### Downloadify
|
||||
|
||||
[Downloadify](https://github.com/dcneiner/downloadify) uses a small Flash SWF
|
||||
to download files to a user's computer with a filename that you can choose.
|
||||
Doug Neiner has added the `dataType` option to allow you to pass a zip for
|
||||
downloading. Follow the [Downloadify demo](http://pixelgraphics.us/downloadify/test.html)
|
||||
with the following changes:
|
||||
|
||||
```js
|
||||
zip = new JSZip();
|
||||
zip.file("Hello.", "hello.txt");
|
||||
Downloadify.create('downloadify',{
|
||||
...
|
||||
data: function(){
|
||||
return zip.generate({type:"base64"});
|
||||
},
|
||||
...
|
||||
dataType: 'base64'
|
||||
});
|
||||
```
|
||||
|
||||
<!--
|
||||
TODO : send data as GET / POST ?
|
||||
-->
|
||||
|
||||
#### Deprecated google gears
|
||||
|
||||
[Franz Buchinger](http://www.picurl.org/blog/author/franz/) has written a
|
||||
brilliant tutorial on [using JSZip with Google Gears](http://www.picurl.org/blog/2009/11/22/creating-zip-archives-with-gears)
|
||||
([part 2](http://www.picurl.org/blog/2009/11/29/gearszipper-part2-adding-support-for-real-files-and-canvas-elements/)).
|
||||
If you want to let your Gears users download several files at once I really
|
||||
recommend having a look at some of his [examples](http://picurl.org/gears/zipper/).
|
||||
|
||||
|
||||
|
||||
### In nodejs
|
||||
|
||||
JSZip can generate Buffers so you can do the following :
|
||||
|
||||
```js
|
||||
var fs = require("fs");
|
||||
var JSZip = require("jszip");
|
||||
|
||||
var zip = new JSZip();
|
||||
// zip.file("file", content);
|
||||
// ... and other manipulations
|
||||
|
||||
var buffer = zip.generate({type:"nodebuffer"});
|
||||
|
||||
fs.writeFile("test.zip", buffer, function(err) {
|
||||
if (err) throw err;
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
88
vendors/jszip/documentation/limitations.md
vendored
Normal file
88
vendors/jszip/documentation/limitations.md
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
---
|
||||
title: "Limitations of JSZip"
|
||||
layout: default
|
||||
section: limitations
|
||||
fullpage: true
|
||||
---
|
||||
|
||||
### Not supported features
|
||||
|
||||
All the features of zip files are not supported. Classic zip files will work
|
||||
but encrypted zip, multi-volume, etc are not supported and the load() method
|
||||
will throw an `Error`.
|
||||
|
||||
|
||||
### ZIP64 and 32bit integers
|
||||
|
||||
ZIP64 files can be loaded, but only if the zip file is not "too big". ZIP64 uses 64bits integers
|
||||
but Javascript represents all numbers as
|
||||
[64-bit double precision IEEE 754 floating point numbers](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf)
|
||||
(see section 8.5). So, we have 53bits for integers and
|
||||
[bitwise operations treat everything as 32bits](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators).
|
||||
So if all the 64bits integers can fit into 32 bits integers, everything will be
|
||||
fine. If it's not the case, you will have other problems anyway (see next
|
||||
limitation).
|
||||
|
||||
### Performance issues
|
||||
|
||||
An other limitation comes from the browser (and the machine running the
|
||||
browser). A compressed zip file of 10MB is "easily" opened by firefox / chrome
|
||||
/ opera / IE10+ but will crash older IE. Also keep in mind that strings in
|
||||
javascript are encoded in UTF-16 : a 10MB ascii text file will take 20MB of
|
||||
memory.
|
||||
|
||||
If you're having performance issues, please consider the following :
|
||||
|
||||
* Don't use IE <= 9. Everything is better with typed arrays.
|
||||
* Use typed arrays (Uint8Array, ArrayBuffer, etc) if possible :
|
||||
* If you generate a zip file, you should use `type:"uint8array"`
|
||||
(or blob, arraybuffer, nodebuffer).
|
||||
* If you load the file from an ajax call, ask your XHR an ArrayBuffer.
|
||||
Loading a string is asking for troubles.
|
||||
* Don't use compression (see below).
|
||||
* If you want to get the content of an ASCII file as a string, consider using
|
||||
`asBinary()` instead of `asText()`. The transformation
|
||||
"binary string" -> "unicode string" is a consuming process.
|
||||
|
||||
Note about compression :
|
||||
When reading a file, JSZip will store the content without decompressing it.
|
||||
When generating a compressed file, JSZip will reuse if possible compressed
|
||||
content :
|
||||
|
||||
* If you read a zip file compressed with DEFLATE and call `generate` with the
|
||||
DEFLATE compression, JSZip won't call the compression algorithms (same with
|
||||
STORE everywhere.)
|
||||
* If you read a zip file compressed with DEFLATE and call `generate` with the
|
||||
STORE compression, JSZip will have to decompress everything.
|
||||
|
||||
On IE <=9, typed arrays are not supported and the compression algorithm
|
||||
will fallback on arrays. In that case, JSZip needs to convert the binary string
|
||||
into an array, DEFLATE it and convert the result into a binary string.
|
||||
You don't want that to happen.
|
||||
|
||||
### The output zip will differ from the input zip
|
||||
|
||||
Reading and generating a zip file won't give you back the same file.
|
||||
Some data are discarded (file metadata) and other are added (subfolders).
|
||||
|
||||
### Encodings support
|
||||
|
||||
JSZip only supports UTF-8 natively. A zip file doesn't contain the name of the
|
||||
encoding used, you need to know it before doing anything.
|
||||
|
||||
#### File name
|
||||
|
||||
If the name of a file inside the zip is encoded with UTF-8 then JSZip can
|
||||
detect it (Language encoding flag, Unicode Path Extra Field). If not, JSZip
|
||||
can't detect the encoding used and will generate [Mojibake](https://en.wikipedia.org/wiki/Mojibake).
|
||||
You can use the [encodeFileName]({{site.baseurl}}/documentation/api_jszip/generate.html)
|
||||
option and the [decodeFileName]({{site.baseurl}}/documentation/api_jszip/load.html)
|
||||
option to encode/decode using a custom encoding.
|
||||
|
||||
#### File content
|
||||
|
||||
The `asText()` method uses UTF-8 to decode the content. If you have a text in
|
||||
a different encoding, you can get the bytes array with `asUint8Array()` and
|
||||
decode it with a lib (iconv, iconv-lite, etc) on your side.
|
||||
To save a text using a non-UTF-8 encoding, do the same : encode it into a
|
||||
Uint8Array before adding it to JSZip.
|
||||
57
vendors/jszip/documentation/upgrade_guide.md
vendored
Normal file
57
vendors/jszip/documentation/upgrade_guide.md
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
title: Upgrade Guide
|
||||
layout: default
|
||||
section: main
|
||||
---
|
||||
|
||||
### From 2.2.2 to 2.3.0
|
||||
|
||||
* On `ZipObject#options`, the attributes `date` and `dir` have been
|
||||
deprecated and are now on `ZipObject`.
|
||||
* On `ZipObject#options`, the attributes `base64` and `binary` have been
|
||||
deprecated.
|
||||
* `JSZip.base64`, `JSZip.prototype.crc32`, `JSZip.prototype.utf8decode`,
|
||||
`JSZip.prototype.utf8encode` and `JSZip.utils` have been deprecated.
|
||||
|
||||
```js
|
||||
// deprecated
|
||||
zip.file("test.txt").options.date
|
||||
zip.file("test.txt").options.dir
|
||||
// new API
|
||||
zip.file("test.txt").date
|
||||
zip.file("test.txt").dir
|
||||
```
|
||||
|
||||
|
||||
### From 2.0.0 to 2.1.0
|
||||
|
||||
* The packaging changed : instead of loading jszip.js, jszip-load.js,
|
||||
jszip-inflate.js, jszip-deflate.js, just include dist/jszip.js or
|
||||
dist/jszip.min.js.
|
||||
For AMD loader users : JSZip now registers itself. You just have to put the
|
||||
file at the right place or configure your loader.
|
||||
|
||||
|
||||
### From 1.x to 2.x
|
||||
|
||||
* `JSZipBase64` has been renamed to `JSZip.base64`.
|
||||
* The `data` attribute doesn't exist anymore :
|
||||
use the getters `asText()`, `asBinary()`, etc
|
||||
* The compression/decompression methods now give their input type with the
|
||||
`compressInputType` and `uncompressInputType` attributes.
|
||||
|
||||
Example for the data attribute :
|
||||
|
||||
```js
|
||||
// before
|
||||
zip.file("test.txt").data;
|
||||
zip.files["test.txt"].data;
|
||||
zip.file("image.png").data;
|
||||
zip.files["image.png"].data;
|
||||
|
||||
// after
|
||||
zip.file("test.txt").asText();
|
||||
zip.files["test.txt"].asText();
|
||||
zip.file("image.png").asBinary();
|
||||
zip.files["image.png"].asBinary();
|
||||
```
|
||||
169
vendors/jszip/index.html
vendored
Normal file
169
vendors/jszip/index.html
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
---
|
||||
title: JSZip
|
||||
layout: default
|
||||
section: main
|
||||
---
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
|
||||
JSZip is a javascript library for creating, reading and editing .zip files, with a
|
||||
lovely and simple API.
|
||||
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<p>
|
||||
<strong>Current version</strong> : v2.6.0
|
||||
</p>
|
||||
<p>
|
||||
<strong>License</strong> : JSZip is dual-licensed. You may use it under the
|
||||
MIT license <em>or</em> the GPLv3 license. See
|
||||
<a href="https://github.com/Stuk/jszip/blob/master/LICENSE.markdown">LICENSE.markdown</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<script type="text/javascript">
|
||||
imgData = "R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=";
|
||||
|
||||
jQuery(function($) {
|
||||
if(!JSZip.support.blob) {
|
||||
$("#demo-not-supported").removeClass("hidden");
|
||||
$("#demo").hide();
|
||||
return;
|
||||
}
|
||||
$("#demo").click(function () {
|
||||
try {
|
||||
eval($("#demo-code").val());
|
||||
$("#status")
|
||||
.removeClass()
|
||||
.addClass("text-success")
|
||||
.text("Done!");
|
||||
}
|
||||
catch (e) {
|
||||
$("#status")
|
||||
.removeClass()
|
||||
.addClass("text-danger")
|
||||
.text(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<textarea class="form-control" id="demo-code" rows="7" spellcheck="false">
|
||||
var zip = new JSZip();
|
||||
zip.file("Hello.txt", "Hello World\n");
|
||||
var img = zip.folder("images");
|
||||
img.file("smile.gif", imgData, {base64: true});
|
||||
var content = zip.generate({type:"blob"});
|
||||
// see FileSaver.js
|
||||
saveAs(content, "example.zip");</textarea>
|
||||
<button id="demo" class="btn btn-primary">Run!</button>
|
||||
<span id="status"></span>
|
||||
<div id="demo-not-supported" class="alert alert-danger hidden">
|
||||
This browser doesn't support blobs, this demo won't work :(
|
||||
See <a href="{{site.baseurl}}/documentation/howto/write_zip.html" class="alert-link">here for more info</a>.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
|
||||
<h3>Installation</h3>
|
||||
|
||||
<p>
|
||||
<strong>With npm</strong> : <code>npm install jszip</code>
|
||||
</p>
|
||||
<p>
|
||||
<strong>With bower</strong> : <code>bower install Stuk/jszip</code>
|
||||
</p>
|
||||
<p>
|
||||
<strong>With component</strong> : <code>component install Stuk/jszip</code>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Manually</strong> : <a href="http://github.com/Stuk/jszip/zipball/master">download JSZip</a>
|
||||
and include the file <code>dist/jszip.js</code> or <code>dist/jszip.min.js</code>
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
Installed ? Great ! You can now check our
|
||||
<a href="{{site.baseurl}}/documentation/examples.html">guides and examples !</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Support</h3>
|
||||
|
||||
<table class="browser_support">
|
||||
<tr>
|
||||
<th class="support_op">Opera</th>
|
||||
<th class="support_ff">Firefox</th>
|
||||
<th class="support_sf">Safari</th>
|
||||
<th class="support_cr">Chrome</th>
|
||||
<th class="support_ie">Internet Explorer</th>
|
||||
<th class="support_nd">Node.js</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with 3.0 / 3.6 / latest version</td>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with IE 6 / 7 / 8 / 9 / 10</td>
|
||||
<td>Tested with node.js 0.8 and 0.10</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Getting help</h3>
|
||||
|
||||
<p>
|
||||
Having trouble ? We'd like to help !
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
Try the <a href="{{site.baseurl}}/documentation/faq.html">FAQ</a>, it has
|
||||
answers to common questions.
|
||||
</li>
|
||||
<li>
|
||||
If you're looking for informations about a specific method, try the
|
||||
<a href="{{site.baseurl}}/documentation/api_jszip.html">documentation</a>.
|
||||
</li>
|
||||
<li>
|
||||
Check the
|
||||
<a href="{{site.baseurl}}/documentation/examples.html">examples</a>.
|
||||
</li>
|
||||
<li>
|
||||
Report bugs in our
|
||||
<a href="https://github.com/Stuk/jszip/issues">Bug tracker</a>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Test status</h3>
|
||||
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Travis build :</dt>
|
||||
<dd>
|
||||
<a href="http://travis-ci.org/Stuk/jszip">
|
||||
<img src="https://api.travis-ci.org/Stuk/jszip.svg?branch=master" alt="" />
|
||||
</a>
|
||||
</dd>
|
||||
<dt>Saucelabs build :</dt>
|
||||
<dd>
|
||||
<a href="https://saucelabs.com/u/jszip">
|
||||
<img src="https://saucelabs.com/browser-matrix/jszip.svg" alt="" />
|
||||
</a>
|
||||
</dd>
|
||||
<dt>Live tests :</dt>
|
||||
<dd>
|
||||
<a href="{{site.baseurl}}/test/">See for yourself !</a>
|
||||
</dd>
|
||||
</dl>
|
||||
51
vendors/jszip/lib/arrayReader.js
vendored
Normal file
51
vendors/jszip/lib/arrayReader.js
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
var DataReader = require('./dataReader');
|
||||
|
||||
function ArrayReader(data) {
|
||||
if (data) {
|
||||
this.data = data;
|
||||
this.length = this.data.length;
|
||||
this.index = 0;
|
||||
this.zero = 0;
|
||||
|
||||
for(var i = 0; i < this.data.length; i++) {
|
||||
data[i] = data[i] & 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayReader.prototype = new DataReader();
|
||||
/**
|
||||
* @see DataReader.byteAt
|
||||
*/
|
||||
ArrayReader.prototype.byteAt = function(i) {
|
||||
return this.data[this.zero + i];
|
||||
};
|
||||
/**
|
||||
* @see DataReader.lastIndexOfSignature
|
||||
*/
|
||||
ArrayReader.prototype.lastIndexOfSignature = function(sig) {
|
||||
var sig0 = sig.charCodeAt(0),
|
||||
sig1 = sig.charCodeAt(1),
|
||||
sig2 = sig.charCodeAt(2),
|
||||
sig3 = sig.charCodeAt(3);
|
||||
for (var i = this.length - 4; i >= 0; --i) {
|
||||
if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {
|
||||
return i - this.zero;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
/**
|
||||
* @see DataReader.readData
|
||||
*/
|
||||
ArrayReader.prototype.readData = function(size) {
|
||||
this.checkOffset(size);
|
||||
if(size === 0) {
|
||||
return [];
|
||||
}
|
||||
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
||||
this.index += size;
|
||||
return result;
|
||||
};
|
||||
module.exports = ArrayReader;
|
||||
70
vendors/jszip/lib/base64.js
vendored
Normal file
70
vendors/jszip/lib/base64.js
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
// private property
|
||||
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
|
||||
// public method for encoding
|
||||
exports.encode = function(input, utf8) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
while (i < input.length) {
|
||||
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
|
||||
if (isNaN(chr2)) {
|
||||
enc3 = enc4 = 64;
|
||||
}
|
||||
else if (isNaN(chr3)) {
|
||||
enc4 = 64;
|
||||
}
|
||||
|
||||
output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
// public method for decoding
|
||||
exports.decode = function(input, utf8) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3;
|
||||
var enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
|
||||
while (i < input.length) {
|
||||
|
||||
enc1 = _keyStr.indexOf(input.charAt(i++));
|
||||
enc2 = _keyStr.indexOf(input.charAt(i++));
|
||||
enc3 = _keyStr.indexOf(input.charAt(i++));
|
||||
enc4 = _keyStr.indexOf(input.charAt(i++));
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 != 64) {
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
};
|
||||
28
vendors/jszip/lib/compressedObject.js
vendored
Normal file
28
vendors/jszip/lib/compressedObject.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
function CompressedObject() {
|
||||
this.compressedSize = 0;
|
||||
this.uncompressedSize = 0;
|
||||
this.crc32 = 0;
|
||||
this.compressionMethod = null;
|
||||
this.compressedContent = null;
|
||||
}
|
||||
|
||||
CompressedObject.prototype = {
|
||||
/**
|
||||
* Return the decompressed content in an unspecified format.
|
||||
* The format will depend on the decompressor.
|
||||
* @return {Object} the decompressed content.
|
||||
*/
|
||||
getContent: function() {
|
||||
return null; // see implementation
|
||||
},
|
||||
/**
|
||||
* Return the compressed content in an unspecified format.
|
||||
* The format will depend on the compressed conten source.
|
||||
* @return {Object} the compressed content.
|
||||
*/
|
||||
getCompressedContent: function() {
|
||||
return null; // see implementation
|
||||
}
|
||||
};
|
||||
module.exports = CompressedObject;
|
||||
13
vendors/jszip/lib/compressions.js
vendored
Normal file
13
vendors/jszip/lib/compressions.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
exports.STORE = {
|
||||
magic: "\x00\x00",
|
||||
compress: function(content, compressionOptions) {
|
||||
return content; // no compression
|
||||
},
|
||||
uncompress: function(content) {
|
||||
return content; // no compression
|
||||
},
|
||||
compressInputType: null,
|
||||
uncompressInputType: null
|
||||
};
|
||||
exports.DEFLATE = require('./flate');
|
||||
102
vendors/jszip/lib/crc32.js
vendored
Normal file
102
vendors/jszip/lib/crc32.js
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
var table = [
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
|
||||
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
||||
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
|
||||
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
||||
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
|
||||
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
|
||||
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
|
||||
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
|
||||
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
||||
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
|
||||
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
||||
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
||||
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
|
||||
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
|
||||
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
||||
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
|
||||
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
||||
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
|
||||
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
|
||||
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
|
||||
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
|
||||
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
||||
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
|
||||
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
||||
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
||||
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
|
||||
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
|
||||
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
];
|
||||
|
||||
/**
|
||||
*
|
||||
* Javascript crc32
|
||||
* http://www.webtoolkit.info/
|
||||
*
|
||||
*/
|
||||
module.exports = function crc32(input, crc) {
|
||||
if (typeof input === "undefined" || !input.length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var isArray = utils.getTypeOf(input) !== "string";
|
||||
|
||||
if (typeof(crc) == "undefined") {
|
||||
crc = 0;
|
||||
}
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var b = 0;
|
||||
|
||||
crc = crc ^ (-1);
|
||||
for (var i = 0, iTop = input.length; i < iTop; i++) {
|
||||
b = isArray ? input[i] : input.charCodeAt(i);
|
||||
y = (crc ^ b) & 0xFF;
|
||||
x = table[y];
|
||||
crc = (crc >>> 8) ^ x;
|
||||
}
|
||||
|
||||
return crc ^ (-1);
|
||||
};
|
||||
// vim: set shiftwidth=4 softtabstop=4:
|
||||
108
vendors/jszip/lib/dataReader.js
vendored
Normal file
108
vendors/jszip/lib/dataReader.js
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
'use strict';
|
||||
var utils = require('./utils');
|
||||
|
||||
function DataReader(data) {
|
||||
this.data = null; // type : see implementation
|
||||
this.length = 0;
|
||||
this.index = 0;
|
||||
this.zero = 0;
|
||||
}
|
||||
DataReader.prototype = {
|
||||
/**
|
||||
* Check that the offset will not go too far.
|
||||
* @param {string} offset the additional offset to check.
|
||||
* @throws {Error} an Error if the offset is out of bounds.
|
||||
*/
|
||||
checkOffset: function(offset) {
|
||||
this.checkIndex(this.index + offset);
|
||||
},
|
||||
/**
|
||||
* Check that the specifed index will not be too far.
|
||||
* @param {string} newIndex the index to check.
|
||||
* @throws {Error} an Error if the index is out of bounds.
|
||||
*/
|
||||
checkIndex: function(newIndex) {
|
||||
if (this.length < this.zero + newIndex || newIndex < 0) {
|
||||
throw new Error("End of data reached (data length = " + this.length + ", asked index = " + (newIndex) + "). Corrupted zip ?");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Change the index.
|
||||
* @param {number} newIndex The new index.
|
||||
* @throws {Error} if the new index is out of the data.
|
||||
*/
|
||||
setIndex: function(newIndex) {
|
||||
this.checkIndex(newIndex);
|
||||
this.index = newIndex;
|
||||
},
|
||||
/**
|
||||
* Skip the next n bytes.
|
||||
* @param {number} n the number of bytes to skip.
|
||||
* @throws {Error} if the new index is out of the data.
|
||||
*/
|
||||
skip: function(n) {
|
||||
this.setIndex(this.index + n);
|
||||
},
|
||||
/**
|
||||
* Get the byte at the specified index.
|
||||
* @param {number} i the index to use.
|
||||
* @return {number} a byte.
|
||||
*/
|
||||
byteAt: function(i) {
|
||||
// see implementations
|
||||
},
|
||||
/**
|
||||
* Get the next number with a given byte size.
|
||||
* @param {number} size the number of bytes to read.
|
||||
* @return {number} the corresponding number.
|
||||
*/
|
||||
readInt: function(size) {
|
||||
var result = 0,
|
||||
i;
|
||||
this.checkOffset(size);
|
||||
for (i = this.index + size - 1; i >= this.index; i--) {
|
||||
result = (result << 8) + this.byteAt(i);
|
||||
}
|
||||
this.index += size;
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* Get the next string with a given byte size.
|
||||
* @param {number} size the number of bytes to read.
|
||||
* @return {string} the corresponding string.
|
||||
*/
|
||||
readString: function(size) {
|
||||
return utils.transformTo("string", this.readData(size));
|
||||
},
|
||||
/**
|
||||
* Get raw data without conversion, <size> bytes.
|
||||
* @param {number} size the number of bytes to read.
|
||||
* @return {Object} the raw data, implementation specific.
|
||||
*/
|
||||
readData: function(size) {
|
||||
// see implementations
|
||||
},
|
||||
/**
|
||||
* Find the last occurence of a zip signature (4 bytes).
|
||||
* @param {string} sig the signature to find.
|
||||
* @return {number} the index of the last occurence, -1 if not found.
|
||||
*/
|
||||
lastIndexOfSignature: function(sig) {
|
||||
// see implementations
|
||||
},
|
||||
/**
|
||||
* Get the next date.
|
||||
* @return {Date} the date.
|
||||
*/
|
||||
readDate: function() {
|
||||
var dostime = this.readInt(4);
|
||||
return new Date(
|
||||
((dostime >> 25) & 0x7f) + 1980, // year
|
||||
((dostime >> 21) & 0x0f) - 1, // month
|
||||
(dostime >> 16) & 0x1f, // day
|
||||
(dostime >> 11) & 0x1f, // hour
|
||||
(dostime >> 5) & 0x3f, // minute
|
||||
(dostime & 0x1f) << 1); // second
|
||||
}
|
||||
};
|
||||
module.exports = DataReader;
|
||||
11
vendors/jszip/lib/defaults.js
vendored
Normal file
11
vendors/jszip/lib/defaults.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
exports.base64 = false;
|
||||
exports.binary = false;
|
||||
exports.dir = false;
|
||||
exports.createFolders = false;
|
||||
exports.date = null;
|
||||
exports.compression = null;
|
||||
exports.compressionOptions = null;
|
||||
exports.comment = null;
|
||||
exports.unixPermissions = null;
|
||||
exports.dosPermissions = null;
|
||||
105
vendors/jszip/lib/deprecatedPublicUtils.js
vendored
Normal file
105
vendors/jszip/lib/deprecatedPublicUtils.js
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
'use strict';
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.string2binary = function(str) {
|
||||
return utils.string2binary(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.string2Uint8Array = function(str) {
|
||||
return utils.transformTo("uint8array", str);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.uint8Array2String = function(array) {
|
||||
return utils.transformTo("string", array);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.string2Blob = function(str) {
|
||||
var buffer = utils.transformTo("arraybuffer", str);
|
||||
return utils.arrayBuffer2Blob(buffer);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.arrayBuffer2Blob = function(buffer) {
|
||||
return utils.arrayBuffer2Blob(buffer);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.transformTo = function(outputType, input) {
|
||||
return utils.transformTo(outputType, input);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.getTypeOf = function(input) {
|
||||
return utils.getTypeOf(input);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.checkSupport = function(type) {
|
||||
return utils.checkSupport(type);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This value will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.MAX_VALUE_16BITS = utils.MAX_VALUE_16BITS;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This value will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.MAX_VALUE_32BITS = utils.MAX_VALUE_32BITS;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.pretty = function(str) {
|
||||
return utils.pretty(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.findCompression = function(compressionMethod) {
|
||||
return utils.findCompression(compressionMethod);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.isRegExp = function (object) {
|
||||
return utils.isRegExp(object);
|
||||
};
|
||||
|
||||
16
vendors/jszip/lib/flate.js
vendored
Normal file
16
vendors/jszip/lib/flate.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
var USE_TYPEDARRAY = (typeof Uint8Array !== 'undefined') && (typeof Uint16Array !== 'undefined') && (typeof Uint32Array !== 'undefined');
|
||||
|
||||
var pako = require("pako");
|
||||
exports.uncompressInputType = USE_TYPEDARRAY ? "uint8array" : "array";
|
||||
exports.compressInputType = USE_TYPEDARRAY ? "uint8array" : "array";
|
||||
|
||||
exports.magic = "\x08\x00";
|
||||
exports.compress = function(input, compressionOptions) {
|
||||
return pako.deflateRaw(input, {
|
||||
level : compressionOptions.level || -1 // default compression
|
||||
});
|
||||
};
|
||||
exports.uncompress = function(input) {
|
||||
return pako.inflateRaw(input);
|
||||
};
|
||||
79
vendors/jszip/lib/index.js
vendored
Normal file
79
vendors/jszip/lib/index.js
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
|
||||
var base64 = require('./base64');
|
||||
|
||||
/**
|
||||
Usage:
|
||||
zip = new JSZip();
|
||||
zip.file("hello.txt", "Hello, World!").file("tempfile", "nothing");
|
||||
zip.folder("images").file("smile.gif", base64Data, {base64: true});
|
||||
zip.file("Xmas.txt", "Ho ho ho !", {date : new Date("December 25, 2007 00:00:01")});
|
||||
zip.remove("tempfile");
|
||||
|
||||
base64zip = zip.generate();
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
* Representation a of zip file in js
|
||||
* @constructor
|
||||
* @param {String=|ArrayBuffer=|Uint8Array=} data the data to load, if any (optional).
|
||||
* @param {Object=} options the options for creating this objects (optional).
|
||||
*/
|
||||
function JSZip(data, options) {
|
||||
// if this constructor is used without `new`, it adds `new` before itself:
|
||||
if(!(this instanceof JSZip)) return new JSZip(data, options);
|
||||
|
||||
// object containing the files :
|
||||
// {
|
||||
// "folder/" : {...},
|
||||
// "folder/data.txt" : {...}
|
||||
// }
|
||||
this.files = {};
|
||||
|
||||
this.comment = null;
|
||||
|
||||
// Where we are in the hierarchy
|
||||
this.root = "";
|
||||
if (data) {
|
||||
this.load(data, options);
|
||||
}
|
||||
this.clone = function() {
|
||||
var newObj = new JSZip();
|
||||
for (var i in this) {
|
||||
if (typeof this[i] !== "function") {
|
||||
newObj[i] = this[i];
|
||||
}
|
||||
}
|
||||
return newObj;
|
||||
};
|
||||
}
|
||||
JSZip.prototype = require('./object');
|
||||
JSZip.prototype.load = require('./load');
|
||||
JSZip.support = require('./support');
|
||||
JSZip.defaults = require('./defaults');
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This namespace will be removed in a future version without replacement.
|
||||
*/
|
||||
JSZip.utils = require('./deprecatedPublicUtils');
|
||||
|
||||
JSZip.base64 = {
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
encode : function(input) {
|
||||
return base64.encode(input);
|
||||
},
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
decode : function(input) {
|
||||
return base64.decode(input);
|
||||
}
|
||||
};
|
||||
JSZip.compressions = require('./compressions');
|
||||
module.exports = JSZip;
|
||||
11
vendors/jszip/lib/license_header.js
vendored
Normal file
11
vendors/jszip/lib/license_header.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
|
||||
JSZip - A Javascript class for generating and reading zip files
|
||||
<http://stuartk.com/jszip>
|
||||
|
||||
(c) 2009-2014 Stuart Knightley <stuart [at] stuartk.com>
|
||||
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
|
||||
|
||||
JSZip uses the library pako released under the MIT license :
|
||||
https://github.com/nodeca/pako/blob/master/LICENSE
|
||||
*/
|
||||
39
vendors/jszip/lib/load.js
vendored
Normal file
39
vendors/jszip/lib/load.js
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
var base64 = require('./base64');
|
||||
var utf8 = require('./utf8');
|
||||
var utils = require('./utils');
|
||||
var ZipEntries = require('./zipEntries');
|
||||
module.exports = function(data, options) {
|
||||
var files, zipEntries, i, input;
|
||||
options = utils.extend(options || {}, {
|
||||
base64: false,
|
||||
checkCRC32: false,
|
||||
optimizedBinaryString : false,
|
||||
createFolders: false,
|
||||
decodeFileName: utf8.utf8decode
|
||||
});
|
||||
if (options.base64) {
|
||||
data = base64.decode(data);
|
||||
}
|
||||
|
||||
zipEntries = new ZipEntries(data, options);
|
||||
files = zipEntries.files;
|
||||
for (i = 0; i < files.length; i++) {
|
||||
input = files[i];
|
||||
this.file(input.fileNameStr, input.decompressed, {
|
||||
binary: true,
|
||||
optimizedBinaryString: true,
|
||||
date: input.date,
|
||||
dir: input.dir,
|
||||
comment : input.fileCommentStr.length ? input.fileCommentStr : null,
|
||||
unixPermissions : input.unixPermissions,
|
||||
dosPermissions : input.dosPermissions,
|
||||
createFolders: options.createFolders
|
||||
});
|
||||
}
|
||||
if (zipEntries.zipComment.length) {
|
||||
this.comment = zipEntries.zipComment;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
7
vendors/jszip/lib/nodeBuffer.js
vendored
Normal file
7
vendors/jszip/lib/nodeBuffer.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
module.exports = function(data, encoding){
|
||||
return new Buffer(data, encoding);
|
||||
};
|
||||
module.exports.test = function(b){
|
||||
return Buffer.isBuffer(b);
|
||||
};
|
||||
21
vendors/jszip/lib/nodeBufferReader.js
vendored
Normal file
21
vendors/jszip/lib/nodeBufferReader.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
var Uint8ArrayReader = require('./uint8ArrayReader');
|
||||
|
||||
function NodeBufferReader(data) {
|
||||
this.data = data;
|
||||
this.length = this.data.length;
|
||||
this.index = 0;
|
||||
this.zero = 0;
|
||||
}
|
||||
NodeBufferReader.prototype = new Uint8ArrayReader();
|
||||
|
||||
/**
|
||||
* @see DataReader.readData
|
||||
*/
|
||||
NodeBufferReader.prototype.readData = function(size) {
|
||||
this.checkOffset(size);
|
||||
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
||||
this.index += size;
|
||||
return result;
|
||||
};
|
||||
module.exports = NodeBufferReader;
|
||||
870
vendors/jszip/lib/object.js
vendored
Normal file
870
vendors/jszip/lib/object.js
vendored
Normal file
@@ -0,0 +1,870 @@
|
||||
'use strict';
|
||||
var support = require('./support');
|
||||
var utils = require('./utils');
|
||||
var crc32 = require('./crc32');
|
||||
var signature = require('./signature');
|
||||
var defaults = require('./defaults');
|
||||
var base64 = require('./base64');
|
||||
var compressions = require('./compressions');
|
||||
var CompressedObject = require('./compressedObject');
|
||||
var nodeBuffer = require('./nodeBuffer');
|
||||
var utf8 = require('./utf8');
|
||||
var StringWriter = require('./stringWriter');
|
||||
var Uint8ArrayWriter = require('./uint8ArrayWriter');
|
||||
|
||||
/**
|
||||
* Returns the raw data of a ZipObject, decompress the content if necessary.
|
||||
* @param {ZipObject} file the file to use.
|
||||
* @return {String|ArrayBuffer|Uint8Array|Buffer} the data.
|
||||
*/
|
||||
var getRawData = function(file) {
|
||||
if (file._data instanceof CompressedObject) {
|
||||
file._data = file._data.getContent();
|
||||
file.options.binary = true;
|
||||
file.options.base64 = false;
|
||||
|
||||
if (utils.getTypeOf(file._data) === "uint8array") {
|
||||
var copy = file._data;
|
||||
// when reading an arraybuffer, the CompressedObject mechanism will keep it and subarray() a Uint8Array.
|
||||
// if we request a file in the same format, we might get the same Uint8Array or its ArrayBuffer (the original zip file).
|
||||
file._data = new Uint8Array(copy.length);
|
||||
// with an empty Uint8Array, Opera fails with a "Offset larger than array size"
|
||||
if (copy.length !== 0) {
|
||||
file._data.set(copy, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return file._data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the data of a ZipObject in a binary form. If the content is an unicode string, encode it.
|
||||
* @param {ZipObject} file the file to use.
|
||||
* @return {String|ArrayBuffer|Uint8Array|Buffer} the data.
|
||||
*/
|
||||
var getBinaryData = function(file) {
|
||||
var result = getRawData(file),
|
||||
type = utils.getTypeOf(result);
|
||||
if (type === "string") {
|
||||
if (!file.options.binary) {
|
||||
// unicode text !
|
||||
// unicode string => binary string is a painful process, check if we can avoid it.
|
||||
if (support.nodebuffer) {
|
||||
return nodeBuffer(result, "utf-8");
|
||||
}
|
||||
}
|
||||
return file.asBinary();
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform this._data into a string.
|
||||
* @param {function} filter a function String -> String, applied if not null on the result.
|
||||
* @return {String} the string representing this._data.
|
||||
*/
|
||||
var dataToString = function(asUTF8) {
|
||||
var result = getRawData(this);
|
||||
if (result === null || typeof result === "undefined") {
|
||||
return "";
|
||||
}
|
||||
// if the data is a base64 string, we decode it before checking the encoding !
|
||||
if (this.options.base64) {
|
||||
result = base64.decode(result);
|
||||
}
|
||||
if (asUTF8 && this.options.binary) {
|
||||
// JSZip.prototype.utf8decode supports arrays as input
|
||||
// skip to array => string step, utf8decode will do it.
|
||||
result = out.utf8decode(result);
|
||||
}
|
||||
else {
|
||||
// no utf8 transformation, do the array => string step.
|
||||
result = utils.transformTo("string", result);
|
||||
}
|
||||
|
||||
if (!asUTF8 && !this.options.binary) {
|
||||
result = utils.transformTo("string", out.utf8encode(result));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* A simple object representing a file in the zip file.
|
||||
* @constructor
|
||||
* @param {string} name the name of the file
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data
|
||||
* @param {Object} options the options of the file
|
||||
*/
|
||||
var ZipObject = function(name, data, options) {
|
||||
this.name = name;
|
||||
this.dir = options.dir;
|
||||
this.date = options.date;
|
||||
this.comment = options.comment;
|
||||
this.unixPermissions = options.unixPermissions;
|
||||
this.dosPermissions = options.dosPermissions;
|
||||
|
||||
this._data = data;
|
||||
this.options = options;
|
||||
|
||||
/*
|
||||
* This object contains initial values for dir and date.
|
||||
* With them, we can check if the user changed the deprecated metadata in
|
||||
* `ZipObject#options` or not.
|
||||
*/
|
||||
this._initialMetadata = {
|
||||
dir : options.dir,
|
||||
date : options.date
|
||||
};
|
||||
};
|
||||
|
||||
ZipObject.prototype = {
|
||||
/**
|
||||
* Return the content as UTF8 string.
|
||||
* @return {string} the UTF8 string.
|
||||
*/
|
||||
asText: function() {
|
||||
return dataToString.call(this, true);
|
||||
},
|
||||
/**
|
||||
* Returns the binary content.
|
||||
* @return {string} the content as binary.
|
||||
*/
|
||||
asBinary: function() {
|
||||
return dataToString.call(this, false);
|
||||
},
|
||||
/**
|
||||
* Returns the content as a nodejs Buffer.
|
||||
* @return {Buffer} the content as a Buffer.
|
||||
*/
|
||||
asNodeBuffer: function() {
|
||||
var result = getBinaryData(this);
|
||||
return utils.transformTo("nodebuffer", result);
|
||||
},
|
||||
/**
|
||||
* Returns the content as an Uint8Array.
|
||||
* @return {Uint8Array} the content as an Uint8Array.
|
||||
*/
|
||||
asUint8Array: function() {
|
||||
var result = getBinaryData(this);
|
||||
return utils.transformTo("uint8array", result);
|
||||
},
|
||||
/**
|
||||
* Returns the content as an ArrayBuffer.
|
||||
* @return {ArrayBuffer} the content as an ArrayBufer.
|
||||
*/
|
||||
asArrayBuffer: function() {
|
||||
return this.asUint8Array().buffer;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform an integer into a string in hexadecimal.
|
||||
* @private
|
||||
* @param {number} dec the number to convert.
|
||||
* @param {number} bytes the number of bytes to generate.
|
||||
* @returns {string} the result.
|
||||
*/
|
||||
var decToHex = function(dec, bytes) {
|
||||
var hex = "",
|
||||
i;
|
||||
for (i = 0; i < bytes; i++) {
|
||||
hex += String.fromCharCode(dec & 0xff);
|
||||
dec = dec >>> 8;
|
||||
}
|
||||
return hex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Transforms the (incomplete) options from the user into the complete
|
||||
* set of options to create a file.
|
||||
* @private
|
||||
* @param {Object} o the options from the user.
|
||||
* @return {Object} the complete set of options.
|
||||
*/
|
||||
var prepareFileAttrs = function(o) {
|
||||
o = o || {};
|
||||
if (o.base64 === true && (o.binary === null || o.binary === undefined)) {
|
||||
o.binary = true;
|
||||
}
|
||||
o = utils.extend(o, defaults);
|
||||
o.date = o.date || new Date();
|
||||
if (o.compression !== null) o.compression = o.compression.toUpperCase();
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a file in the current folder.
|
||||
* @private
|
||||
* @param {string} name the name of the file
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file
|
||||
* @param {Object} o the options of the file
|
||||
* @return {Object} the new file.
|
||||
*/
|
||||
var fileAdd = function(name, data, o) {
|
||||
// be sure sub folders exist
|
||||
var dataType = utils.getTypeOf(data),
|
||||
parent;
|
||||
|
||||
o = prepareFileAttrs(o);
|
||||
|
||||
if (typeof o.unixPermissions === "string") {
|
||||
o.unixPermissions = parseInt(o.unixPermissions, 8);
|
||||
}
|
||||
|
||||
// UNX_IFDIR 0040000 see zipinfo.c
|
||||
if (o.unixPermissions && (o.unixPermissions & 0x4000)) {
|
||||
o.dir = true;
|
||||
}
|
||||
// Bit 4 Directory
|
||||
if (o.dosPermissions && (o.dosPermissions & 0x0010)) {
|
||||
o.dir = true;
|
||||
}
|
||||
|
||||
if (o.dir) {
|
||||
name = forceTrailingSlash(name);
|
||||
}
|
||||
|
||||
if (o.createFolders && (parent = parentFolder(name))) {
|
||||
folderAdd.call(this, parent, true);
|
||||
}
|
||||
|
||||
if (o.dir || data === null || typeof data === "undefined") {
|
||||
o.base64 = false;
|
||||
o.binary = false;
|
||||
data = null;
|
||||
dataType = null;
|
||||
}
|
||||
else if (dataType === "string") {
|
||||
if (o.binary && !o.base64) {
|
||||
// optimizedBinaryString == true means that the file has already been filtered with a 0xFF mask
|
||||
if (o.optimizedBinaryString !== true) {
|
||||
// this is a string, not in a base64 format.
|
||||
// Be sure that this is a correct "binary string"
|
||||
data = utils.string2binary(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // arraybuffer, uint8array, ...
|
||||
o.base64 = false;
|
||||
o.binary = true;
|
||||
|
||||
if (!dataType && !(data instanceof CompressedObject)) {
|
||||
throw new Error("The data of '" + name + "' is in an unsupported format !");
|
||||
}
|
||||
|
||||
// special case : it's way easier to work with Uint8Array than with ArrayBuffer
|
||||
if (dataType === "arraybuffer") {
|
||||
data = utils.transformTo("uint8array", data);
|
||||
}
|
||||
}
|
||||
|
||||
var object = new ZipObject(name, data, o);
|
||||
this.files[name] = object;
|
||||
return object;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find the parent folder of the path.
|
||||
* @private
|
||||
* @param {string} path the path to use
|
||||
* @return {string} the parent folder, or ""
|
||||
*/
|
||||
var parentFolder = function (path) {
|
||||
if (path.slice(-1) == '/') {
|
||||
path = path.substring(0, path.length - 1);
|
||||
}
|
||||
var lastSlash = path.lastIndexOf('/');
|
||||
return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the path with a slash at the end.
|
||||
* @private
|
||||
* @param {String} path the path to check.
|
||||
* @return {String} the path with a trailing slash.
|
||||
*/
|
||||
var forceTrailingSlash = function(path) {
|
||||
// Check the name ends with a /
|
||||
if (path.slice(-1) != "/") {
|
||||
path += "/"; // IE doesn't like substr(-1)
|
||||
}
|
||||
return path;
|
||||
};
|
||||
/**
|
||||
* Add a (sub) folder in the current folder.
|
||||
* @private
|
||||
* @param {string} name the folder's name
|
||||
* @param {boolean=} [createFolders] If true, automatically create sub
|
||||
* folders. Defaults to false.
|
||||
* @return {Object} the new folder.
|
||||
*/
|
||||
var folderAdd = function(name, createFolders) {
|
||||
createFolders = (typeof createFolders !== 'undefined') ? createFolders : false;
|
||||
|
||||
name = forceTrailingSlash(name);
|
||||
|
||||
// Does this folder already exist?
|
||||
if (!this.files[name]) {
|
||||
fileAdd.call(this, name, null, {
|
||||
dir: true,
|
||||
createFolders: createFolders
|
||||
});
|
||||
}
|
||||
return this.files[name];
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a JSZip.CompressedObject for a given zipOject.
|
||||
* @param {ZipObject} file the object to read.
|
||||
* @param {JSZip.compression} compression the compression to use.
|
||||
* @param {Object} compressionOptions the options to use when compressing.
|
||||
* @return {JSZip.CompressedObject} the compressed result.
|
||||
*/
|
||||
var generateCompressedObjectFrom = function(file, compression, compressionOptions) {
|
||||
var result = new CompressedObject(),
|
||||
content;
|
||||
|
||||
// the data has not been decompressed, we might reuse things !
|
||||
if (file._data instanceof CompressedObject) {
|
||||
result.uncompressedSize = file._data.uncompressedSize;
|
||||
result.crc32 = file._data.crc32;
|
||||
|
||||
if (result.uncompressedSize === 0 || file.dir) {
|
||||
compression = compressions['STORE'];
|
||||
result.compressedContent = "";
|
||||
result.crc32 = 0;
|
||||
}
|
||||
else if (file._data.compressionMethod === compression.magic) {
|
||||
result.compressedContent = file._data.getCompressedContent();
|
||||
}
|
||||
else {
|
||||
content = file._data.getContent();
|
||||
// need to decompress / recompress
|
||||
result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content), compressionOptions);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// have uncompressed data
|
||||
content = getBinaryData(file);
|
||||
if (!content || content.length === 0 || file.dir) {
|
||||
compression = compressions['STORE'];
|
||||
content = "";
|
||||
}
|
||||
result.uncompressedSize = content.length;
|
||||
result.crc32 = crc32(content);
|
||||
result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content), compressionOptions);
|
||||
}
|
||||
|
||||
result.compressedSize = result.compressedContent.length;
|
||||
result.compressionMethod = compression.magic;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate the UNIX part of the external file attributes.
|
||||
* @param {Object} unixPermissions the unix permissions or null.
|
||||
* @param {Boolean} isDir true if the entry is a directory, false otherwise.
|
||||
* @return {Number} a 32 bit integer.
|
||||
*
|
||||
* adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :
|
||||
*
|
||||
* TTTTsstrwxrwxrwx0000000000ADVSHR
|
||||
* ^^^^____________________________ file type, see zipinfo.c (UNX_*)
|
||||
* ^^^_________________________ setuid, setgid, sticky
|
||||
* ^^^^^^^^^________________ permissions
|
||||
* ^^^^^^^^^^______ not used ?
|
||||
* ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only
|
||||
*/
|
||||
var generateUnixExternalFileAttr = function (unixPermissions, isDir) {
|
||||
|
||||
var result = unixPermissions;
|
||||
if (!unixPermissions) {
|
||||
// I can't use octal values in strict mode, hence the hexa.
|
||||
// 040775 => 0x41fd
|
||||
// 0100664 => 0x81b4
|
||||
result = isDir ? 0x41fd : 0x81b4;
|
||||
}
|
||||
|
||||
return (result & 0xFFFF) << 16;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate the DOS part of the external file attributes.
|
||||
* @param {Object} dosPermissions the dos permissions or null.
|
||||
* @param {Boolean} isDir true if the entry is a directory, false otherwise.
|
||||
* @return {Number} a 32 bit integer.
|
||||
*
|
||||
* Bit 0 Read-Only
|
||||
* Bit 1 Hidden
|
||||
* Bit 2 System
|
||||
* Bit 3 Volume Label
|
||||
* Bit 4 Directory
|
||||
* Bit 5 Archive
|
||||
*/
|
||||
var generateDosExternalFileAttr = function (dosPermissions, isDir) {
|
||||
|
||||
// the dir flag is already set for compatibility
|
||||
|
||||
return (dosPermissions || 0) & 0x3F;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate the various parts used in the construction of the final zip file.
|
||||
* @param {string} name the file name.
|
||||
* @param {ZipObject} file the file content.
|
||||
* @param {JSZip.CompressedObject} compressedObject the compressed object.
|
||||
* @param {number} offset the current offset from the start of the zip file.
|
||||
* @param {String} platform let's pretend we are this platform (change platform dependents fields)
|
||||
* @param {Function} encodeFileName the function to encode the file name / comment.
|
||||
* @return {object} the zip parts.
|
||||
*/
|
||||
var generateZipParts = function(name, file, compressedObject, offset, platform, encodeFileName) {
|
||||
var data = compressedObject.compressedContent,
|
||||
useCustomEncoding = encodeFileName !== utf8.utf8encode,
|
||||
encodedFileName = utils.transformTo("string", encodeFileName(file.name)),
|
||||
utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)),
|
||||
comment = file.comment || "",
|
||||
encodedComment = utils.transformTo("string", encodeFileName(comment)),
|
||||
utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)),
|
||||
useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,
|
||||
useUTF8ForComment = utfEncodedComment.length !== comment.length,
|
||||
o = file.options,
|
||||
dosTime,
|
||||
dosDate,
|
||||
extraFields = "",
|
||||
unicodePathExtraField = "",
|
||||
unicodeCommentExtraField = "",
|
||||
dir, date;
|
||||
|
||||
|
||||
// handle the deprecated options.dir
|
||||
if (file._initialMetadata.dir !== file.dir) {
|
||||
dir = file.dir;
|
||||
} else {
|
||||
dir = o.dir;
|
||||
}
|
||||
|
||||
// handle the deprecated options.date
|
||||
if(file._initialMetadata.date !== file.date) {
|
||||
date = file.date;
|
||||
} else {
|
||||
date = o.date;
|
||||
}
|
||||
|
||||
var extFileAttr = 0;
|
||||
var versionMadeBy = 0;
|
||||
if (dir) {
|
||||
// dos or unix, we set the dos dir flag
|
||||
extFileAttr |= 0x00010;
|
||||
}
|
||||
if(platform === "UNIX") {
|
||||
versionMadeBy = 0x031E; // UNIX, version 3.0
|
||||
extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);
|
||||
} else { // DOS or other, fallback to DOS
|
||||
versionMadeBy = 0x0014; // DOS, version 2.0
|
||||
extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);
|
||||
}
|
||||
|
||||
// date
|
||||
// @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
|
||||
// @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
|
||||
// @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
|
||||
|
||||
dosTime = date.getHours();
|
||||
dosTime = dosTime << 6;
|
||||
dosTime = dosTime | date.getMinutes();
|
||||
dosTime = dosTime << 5;
|
||||
dosTime = dosTime | date.getSeconds() / 2;
|
||||
|
||||
dosDate = date.getFullYear() - 1980;
|
||||
dosDate = dosDate << 4;
|
||||
dosDate = dosDate | (date.getMonth() + 1);
|
||||
dosDate = dosDate << 5;
|
||||
dosDate = dosDate | date.getDate();
|
||||
|
||||
if (useUTF8ForFileName) {
|
||||
// set the unicode path extra field. unzip needs at least one extra
|
||||
// field to correctly handle unicode path, so using the path is as good
|
||||
// as any other information. This could improve the situation with
|
||||
// other archive managers too.
|
||||
// This field is usually used without the utf8 flag, with a non
|
||||
// unicode path in the header (winrar, winzip). This helps (a bit)
|
||||
// with the messy Windows' default compressed folders feature but
|
||||
// breaks on p7zip which doesn't seek the unicode path extra field.
|
||||
// So for now, UTF-8 everywhere !
|
||||
unicodePathExtraField =
|
||||
// Version
|
||||
decToHex(1, 1) +
|
||||
// NameCRC32
|
||||
decToHex(crc32(encodedFileName), 4) +
|
||||
// UnicodeName
|
||||
utfEncodedFileName;
|
||||
|
||||
extraFields +=
|
||||
// Info-ZIP Unicode Path Extra Field
|
||||
"\x75\x70" +
|
||||
// size
|
||||
decToHex(unicodePathExtraField.length, 2) +
|
||||
// content
|
||||
unicodePathExtraField;
|
||||
}
|
||||
|
||||
if(useUTF8ForComment) {
|
||||
|
||||
unicodeCommentExtraField =
|
||||
// Version
|
||||
decToHex(1, 1) +
|
||||
// CommentCRC32
|
||||
decToHex(this.crc32(encodedComment), 4) +
|
||||
// UnicodeName
|
||||
utfEncodedComment;
|
||||
|
||||
extraFields +=
|
||||
// Info-ZIP Unicode Path Extra Field
|
||||
"\x75\x63" +
|
||||
// size
|
||||
decToHex(unicodeCommentExtraField.length, 2) +
|
||||
// content
|
||||
unicodeCommentExtraField;
|
||||
}
|
||||
|
||||
var header = "";
|
||||
|
||||
// version needed to extract
|
||||
header += "\x0A\x00";
|
||||
// general purpose bit flag
|
||||
// set bit 11 if utf8
|
||||
header += !useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment) ? "\x00\x08" : "\x00\x00";
|
||||
// compression method
|
||||
header += compressedObject.compressionMethod;
|
||||
// last mod file time
|
||||
header += decToHex(dosTime, 2);
|
||||
// last mod file date
|
||||
header += decToHex(dosDate, 2);
|
||||
// crc-32
|
||||
header += decToHex(compressedObject.crc32, 4);
|
||||
// compressed size
|
||||
header += decToHex(compressedObject.compressedSize, 4);
|
||||
// uncompressed size
|
||||
header += decToHex(compressedObject.uncompressedSize, 4);
|
||||
// file name length
|
||||
header += decToHex(encodedFileName.length, 2);
|
||||
// extra field length
|
||||
header += decToHex(extraFields.length, 2);
|
||||
|
||||
|
||||
var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;
|
||||
|
||||
var dirRecord = signature.CENTRAL_FILE_HEADER +
|
||||
// version made by (00: DOS)
|
||||
decToHex(versionMadeBy, 2) +
|
||||
// file header (common to file and central directory)
|
||||
header +
|
||||
// file comment length
|
||||
decToHex(encodedComment.length, 2) +
|
||||
// disk number start
|
||||
"\x00\x00" +
|
||||
// internal file attributes TODO
|
||||
"\x00\x00" +
|
||||
// external file attributes
|
||||
decToHex(extFileAttr, 4) +
|
||||
// relative offset of local header
|
||||
decToHex(offset, 4) +
|
||||
// file name
|
||||
encodedFileName +
|
||||
// extra field
|
||||
extraFields +
|
||||
// file comment
|
||||
encodedComment;
|
||||
|
||||
return {
|
||||
fileRecord: fileRecord,
|
||||
dirRecord: dirRecord,
|
||||
compressedObject: compressedObject
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// return the actual prototype of JSZip
|
||||
var out = {
|
||||
/**
|
||||
* Read an existing zip and merge the data in the current JSZip object.
|
||||
* The implementation is in jszip-load.js, don't forget to include it.
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} stream The stream to load
|
||||
* @param {Object} options Options for loading the stream.
|
||||
* options.base64 : is the stream in base64 ? default : false
|
||||
* @return {JSZip} the current JSZip object
|
||||
*/
|
||||
load: function(stream, options) {
|
||||
throw new Error("Load method is not defined. Is the file jszip-load.js included ?");
|
||||
},
|
||||
|
||||
/**
|
||||
* Filter nested files/folders with the specified function.
|
||||
* @param {Function} search the predicate to use :
|
||||
* function (relativePath, file) {...}
|
||||
* It takes 2 arguments : the relative path and the file.
|
||||
* @return {Array} An array of matching elements.
|
||||
*/
|
||||
filter: function(search) {
|
||||
var result = [],
|
||||
filename, relativePath, file, fileClone;
|
||||
for (filename in this.files) {
|
||||
if (!this.files.hasOwnProperty(filename)) {
|
||||
continue;
|
||||
}
|
||||
file = this.files[filename];
|
||||
// return a new object, don't let the user mess with our internal objects :)
|
||||
fileClone = new ZipObject(file.name, file._data, utils.extend(file.options));
|
||||
relativePath = filename.slice(this.root.length, filename.length);
|
||||
if (filename.slice(0, this.root.length) === this.root && // the file is in the current root
|
||||
search(relativePath, fileClone)) { // and the file matches the function
|
||||
result.push(fileClone);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a file to the zip file, or search a file.
|
||||
* @param {string|RegExp} name The name of the file to add (if data is defined),
|
||||
* the name of the file to find (if no data) or a regex to match files.
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded
|
||||
* @param {Object} o File options
|
||||
* @return {JSZip|Object|Array} this JSZip object (when adding a file),
|
||||
* a file (when searching by string) or an array of files (when searching by regex).
|
||||
*/
|
||||
file: function(name, data, o) {
|
||||
if (arguments.length === 1) {
|
||||
if (utils.isRegExp(name)) {
|
||||
var regexp = name;
|
||||
return this.filter(function(relativePath, file) {
|
||||
return !file.dir && regexp.test(relativePath);
|
||||
});
|
||||
}
|
||||
else { // text
|
||||
return this.filter(function(relativePath, file) {
|
||||
return !file.dir && relativePath === name;
|
||||
})[0] || null;
|
||||
}
|
||||
}
|
||||
else { // more than one argument : we have data !
|
||||
name = this.root + name;
|
||||
fileAdd.call(this, name, data, o);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a directory to the zip file, or search.
|
||||
* @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.
|
||||
* @return {JSZip} an object with the new directory as the root, or an array containing matching folders.
|
||||
*/
|
||||
folder: function(arg) {
|
||||
if (!arg) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (utils.isRegExp(arg)) {
|
||||
return this.filter(function(relativePath, file) {
|
||||
return file.dir && arg.test(relativePath);
|
||||
});
|
||||
}
|
||||
|
||||
// else, name is a new folder
|
||||
var name = this.root + arg;
|
||||
var newFolder = folderAdd.call(this, name);
|
||||
|
||||
// Allow chaining by returning a new object with this folder as the root
|
||||
var ret = this.clone();
|
||||
ret.root = newFolder.name;
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete a file, or a directory and all sub-files, from the zip
|
||||
* @param {string} name the name of the file to delete
|
||||
* @return {JSZip} this JSZip object
|
||||
*/
|
||||
remove: function(name) {
|
||||
name = this.root + name;
|
||||
var file = this.files[name];
|
||||
if (!file) {
|
||||
// Look for any folders
|
||||
if (name.slice(-1) != "/") {
|
||||
name += "/";
|
||||
}
|
||||
file = this.files[name];
|
||||
}
|
||||
|
||||
if (file && !file.dir) {
|
||||
// file
|
||||
delete this.files[name];
|
||||
} else {
|
||||
// maybe a folder, delete recursively
|
||||
var kids = this.filter(function(relativePath, file) {
|
||||
return file.name.slice(0, name.length) === name;
|
||||
});
|
||||
for (var i = 0; i < kids.length; i++) {
|
||||
delete this.files[kids[i].name];
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate the complete zip file
|
||||
* @param {Object} options the options to generate the zip file :
|
||||
* - base64, (deprecated, use type instead) true to generate base64.
|
||||
* - compression, "STORE" by default.
|
||||
* - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
|
||||
* @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file
|
||||
*/
|
||||
generate: function(options) {
|
||||
options = utils.extend(options || {}, {
|
||||
base64: true,
|
||||
compression: "STORE",
|
||||
compressionOptions : null,
|
||||
type: "base64",
|
||||
platform: "DOS",
|
||||
comment: null,
|
||||
mimeType: 'application/zip',
|
||||
encodeFileName: utf8.utf8encode
|
||||
});
|
||||
|
||||
utils.checkSupport(options.type);
|
||||
|
||||
// accept nodejs `process.platform`
|
||||
if(
|
||||
options.platform === 'darwin' ||
|
||||
options.platform === 'freebsd' ||
|
||||
options.platform === 'linux' ||
|
||||
options.platform === 'sunos'
|
||||
) {
|
||||
options.platform = "UNIX";
|
||||
}
|
||||
if (options.platform === 'win32') {
|
||||
options.platform = "DOS";
|
||||
}
|
||||
|
||||
var zipData = [],
|
||||
localDirLength = 0,
|
||||
centralDirLength = 0,
|
||||
writer, i,
|
||||
encodedComment = utils.transformTo("string", options.encodeFileName(options.comment || this.comment || ""));
|
||||
|
||||
// first, generate all the zip parts.
|
||||
for (var name in this.files) {
|
||||
if (!this.files.hasOwnProperty(name)) {
|
||||
continue;
|
||||
}
|
||||
var file = this.files[name];
|
||||
|
||||
var compressionName = file.options.compression || options.compression.toUpperCase();
|
||||
var compression = compressions[compressionName];
|
||||
if (!compression) {
|
||||
throw new Error(compressionName + " is not a valid compression method !");
|
||||
}
|
||||
var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};
|
||||
|
||||
var compressedObject = generateCompressedObjectFrom.call(this, file, compression, compressionOptions);
|
||||
|
||||
var zipPart = generateZipParts.call(this, name, file, compressedObject, localDirLength, options.platform, options.encodeFileName);
|
||||
localDirLength += zipPart.fileRecord.length + compressedObject.compressedSize;
|
||||
centralDirLength += zipPart.dirRecord.length;
|
||||
zipData.push(zipPart);
|
||||
}
|
||||
|
||||
var dirEnd = "";
|
||||
|
||||
// end of central dir signature
|
||||
dirEnd = signature.CENTRAL_DIRECTORY_END +
|
||||
// number of this disk
|
||||
"\x00\x00" +
|
||||
// number of the disk with the start of the central directory
|
||||
"\x00\x00" +
|
||||
// total number of entries in the central directory on this disk
|
||||
decToHex(zipData.length, 2) +
|
||||
// total number of entries in the central directory
|
||||
decToHex(zipData.length, 2) +
|
||||
// size of the central directory 4 bytes
|
||||
decToHex(centralDirLength, 4) +
|
||||
// offset of start of central directory with respect to the starting disk number
|
||||
decToHex(localDirLength, 4) +
|
||||
// .ZIP file comment length
|
||||
decToHex(encodedComment.length, 2) +
|
||||
// .ZIP file comment
|
||||
encodedComment;
|
||||
|
||||
|
||||
// we have all the parts (and the total length)
|
||||
// time to create a writer !
|
||||
var typeName = options.type.toLowerCase();
|
||||
if(typeName==="uint8array"||typeName==="arraybuffer"||typeName==="blob"||typeName==="nodebuffer") {
|
||||
writer = new Uint8ArrayWriter(localDirLength + centralDirLength + dirEnd.length);
|
||||
}else{
|
||||
writer = new StringWriter(localDirLength + centralDirLength + dirEnd.length);
|
||||
}
|
||||
|
||||
for (i = 0; i < zipData.length; i++) {
|
||||
writer.append(zipData[i].fileRecord);
|
||||
writer.append(zipData[i].compressedObject.compressedContent);
|
||||
}
|
||||
for (i = 0; i < zipData.length; i++) {
|
||||
writer.append(zipData[i].dirRecord);
|
||||
}
|
||||
|
||||
writer.append(dirEnd);
|
||||
|
||||
var zip = writer.finalize();
|
||||
|
||||
|
||||
|
||||
switch(options.type.toLowerCase()) {
|
||||
// case "zip is an Uint8Array"
|
||||
case "uint8array" :
|
||||
case "arraybuffer" :
|
||||
case "nodebuffer" :
|
||||
return utils.transformTo(options.type.toLowerCase(), zip);
|
||||
case "blob" :
|
||||
return utils.arrayBuffer2Blob(utils.transformTo("arraybuffer", zip), options.mimeType);
|
||||
// case "zip is a string"
|
||||
case "base64" :
|
||||
return (options.base64) ? base64.encode(zip) : zip;
|
||||
default : // case "string" :
|
||||
return zip;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
crc32: function (input, crc) {
|
||||
return crc32(input, crc);
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
utf8encode: function (string) {
|
||||
return utils.transformTo("string", utf8.utf8encode(string));
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
utf8decode: function (input) {
|
||||
return utf8.utf8decode(input);
|
||||
}
|
||||
};
|
||||
module.exports = out;
|
||||
7
vendors/jszip/lib/signature.js
vendored
Normal file
7
vendors/jszip/lib/signature.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
exports.LOCAL_FILE_HEADER = "PK\x03\x04";
|
||||
exports.CENTRAL_FILE_HEADER = "PK\x01\x02";
|
||||
exports.CENTRAL_DIRECTORY_END = "PK\x05\x06";
|
||||
exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07";
|
||||
exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06";
|
||||
exports.DATA_DESCRIPTOR = "PK\x07\x08";
|
||||
37
vendors/jszip/lib/stringReader.js
vendored
Normal file
37
vendors/jszip/lib/stringReader.js
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
var DataReader = require('./dataReader');
|
||||
var utils = require('./utils');
|
||||
|
||||
function StringReader(data, optimizedBinaryString) {
|
||||
this.data = data;
|
||||
if (!optimizedBinaryString) {
|
||||
this.data = utils.string2binary(this.data);
|
||||
}
|
||||
this.length = this.data.length;
|
||||
this.index = 0;
|
||||
this.zero = 0;
|
||||
}
|
||||
StringReader.prototype = new DataReader();
|
||||
/**
|
||||
* @see DataReader.byteAt
|
||||
*/
|
||||
StringReader.prototype.byteAt = function(i) {
|
||||
return this.data.charCodeAt(this.zero + i);
|
||||
};
|
||||
/**
|
||||
* @see DataReader.lastIndexOfSignature
|
||||
*/
|
||||
StringReader.prototype.lastIndexOfSignature = function(sig) {
|
||||
return this.data.lastIndexOf(sig) - this.zero;
|
||||
};
|
||||
/**
|
||||
* @see DataReader.readData
|
||||
*/
|
||||
StringReader.prototype.readData = function(size) {
|
||||
this.checkOffset(size);
|
||||
// this will work because the constructor applied the "& 0xff" mask.
|
||||
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
||||
this.index += size;
|
||||
return result;
|
||||
};
|
||||
module.exports = StringReader;
|
||||
30
vendors/jszip/lib/stringWriter.js
vendored
Normal file
30
vendors/jszip/lib/stringWriter.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* An object to write any content to a string.
|
||||
* @constructor
|
||||
*/
|
||||
var StringWriter = function() {
|
||||
this.data = [];
|
||||
};
|
||||
StringWriter.prototype = {
|
||||
/**
|
||||
* Append any content to the current string.
|
||||
* @param {Object} input the content to add.
|
||||
*/
|
||||
append: function(input) {
|
||||
input = utils.transformTo("string", input);
|
||||
this.data.push(input);
|
||||
},
|
||||
/**
|
||||
* Finalize the construction an return the result.
|
||||
* @return {string} the generated string.
|
||||
*/
|
||||
finalize: function() {
|
||||
return this.data.join("");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = StringWriter;
|
||||
34
vendors/jszip/lib/support.js
vendored
Normal file
34
vendors/jszip/lib/support.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
exports.base64 = true;
|
||||
exports.array = true;
|
||||
exports.string = true;
|
||||
exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
|
||||
// contains true if JSZip can read/generate nodejs Buffer, false otherwise.
|
||||
// Browserify will provide a Buffer implementation for browsers, which is
|
||||
// an augmented Uint8Array (i.e., can be used as either Buffer or U8).
|
||||
exports.nodebuffer = typeof Buffer !== "undefined";
|
||||
// contains true if JSZip can read/generate Uint8Array, false otherwise.
|
||||
exports.uint8array = typeof Uint8Array !== "undefined";
|
||||
|
||||
if (typeof ArrayBuffer === "undefined") {
|
||||
exports.blob = false;
|
||||
}
|
||||
else {
|
||||
var buffer = new ArrayBuffer(0);
|
||||
try {
|
||||
exports.blob = new Blob([buffer], {
|
||||
type: "application/zip"
|
||||
}).size === 0;
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
||||
var builder = new Builder();
|
||||
builder.append(buffer);
|
||||
exports.blob = builder.getBlob('application/zip').size === 0;
|
||||
}
|
||||
catch (e) {
|
||||
exports.blob = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
vendors/jszip/lib/uint8ArrayReader.js
vendored
Normal file
26
vendors/jszip/lib/uint8ArrayReader.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
var ArrayReader = require('./arrayReader');
|
||||
|
||||
function Uint8ArrayReader(data) {
|
||||
if (data) {
|
||||
this.data = data;
|
||||
this.length = this.data.length;
|
||||
this.index = 0;
|
||||
this.zero = 0;
|
||||
}
|
||||
}
|
||||
Uint8ArrayReader.prototype = new ArrayReader();
|
||||
/**
|
||||
* @see DataReader.readData
|
||||
*/
|
||||
Uint8ArrayReader.prototype.readData = function(size) {
|
||||
this.checkOffset(size);
|
||||
if(size === 0) {
|
||||
// in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].
|
||||
return new Uint8Array(0);
|
||||
}
|
||||
var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);
|
||||
this.index += size;
|
||||
return result;
|
||||
};
|
||||
module.exports = Uint8ArrayReader;
|
||||
36
vendors/jszip/lib/uint8ArrayWriter.js
vendored
Normal file
36
vendors/jszip/lib/uint8ArrayWriter.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* An object to write any content to an Uint8Array.
|
||||
* @constructor
|
||||
* @param {number} length The length of the array.
|
||||
*/
|
||||
var Uint8ArrayWriter = function(length) {
|
||||
this.data = new Uint8Array(length);
|
||||
this.index = 0;
|
||||
};
|
||||
Uint8ArrayWriter.prototype = {
|
||||
/**
|
||||
* Append any content to the current array.
|
||||
* @param {Object} input the content to add.
|
||||
*/
|
||||
append: function(input) {
|
||||
if (input.length !== 0) {
|
||||
// with an empty Uint8Array, Opera fails with a "Offset larger than array size"
|
||||
input = utils.transformTo("uint8array", input);
|
||||
this.data.set(input, this.index);
|
||||
this.index += input.length;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Finalize the construction an return the result.
|
||||
* @return {Uint8Array} the generated array.
|
||||
*/
|
||||
finalize: function() {
|
||||
return this.data;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Uint8ArrayWriter;
|
||||
207
vendors/jszip/lib/utf8.js
vendored
Normal file
207
vendors/jszip/lib/utf8.js
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
var support = require('./support');
|
||||
var nodeBuffer = require('./nodeBuffer');
|
||||
|
||||
/**
|
||||
* The following functions come from pako, from pako/lib/utils/strings
|
||||
* released under the MIT license, see pako https://github.com/nodeca/pako/
|
||||
*/
|
||||
|
||||
// Table with utf8 lengths (calculated by first byte of sequence)
|
||||
// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
|
||||
// because max possible codepoint is 0x10ffff
|
||||
var _utf8len = new Array(256);
|
||||
for (var i=0; i<256; i++) {
|
||||
_utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);
|
||||
}
|
||||
_utf8len[254]=_utf8len[254]=1; // Invalid sequence start
|
||||
|
||||
// convert string to array (typed, when possible)
|
||||
var string2buf = function (str) {
|
||||
var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
|
||||
|
||||
// count binary size
|
||||
for (m_pos = 0; m_pos < str_len; m_pos++) {
|
||||
c = str.charCodeAt(m_pos);
|
||||
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {
|
||||
c2 = str.charCodeAt(m_pos+1);
|
||||
if ((c2 & 0xfc00) === 0xdc00) {
|
||||
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
|
||||
m_pos++;
|
||||
}
|
||||
}
|
||||
buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
|
||||
}
|
||||
|
||||
// allocate buffer
|
||||
if (support.uint8array) {
|
||||
buf = new Uint8Array(buf_len);
|
||||
} else {
|
||||
buf = new Array(buf_len);
|
||||
}
|
||||
|
||||
// convert
|
||||
for (i=0, m_pos = 0; i < buf_len; m_pos++) {
|
||||
c = str.charCodeAt(m_pos);
|
||||
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {
|
||||
c2 = str.charCodeAt(m_pos+1);
|
||||
if ((c2 & 0xfc00) === 0xdc00) {
|
||||
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
|
||||
m_pos++;
|
||||
}
|
||||
}
|
||||
if (c < 0x80) {
|
||||
/* one byte */
|
||||
buf[i++] = c;
|
||||
} else if (c < 0x800) {
|
||||
/* two bytes */
|
||||
buf[i++] = 0xC0 | (c >>> 6);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
} else if (c < 0x10000) {
|
||||
/* three bytes */
|
||||
buf[i++] = 0xE0 | (c >>> 12);
|
||||
buf[i++] = 0x80 | (c >>> 6 & 0x3f);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
} else {
|
||||
/* four bytes */
|
||||
buf[i++] = 0xf0 | (c >>> 18);
|
||||
buf[i++] = 0x80 | (c >>> 12 & 0x3f);
|
||||
buf[i++] = 0x80 | (c >>> 6 & 0x3f);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
};
|
||||
|
||||
// Calculate max possible position in utf8 buffer,
|
||||
// that will not break sequence. If that's not possible
|
||||
// - (very small limits) return max size as is.
|
||||
//
|
||||
// buf[] - utf8 bytes array
|
||||
// max - length limit (mandatory);
|
||||
var utf8border = function(buf, max) {
|
||||
var pos;
|
||||
|
||||
max = max || buf.length;
|
||||
if (max > buf.length) { max = buf.length; }
|
||||
|
||||
// go back from last position, until start of sequence found
|
||||
pos = max-1;
|
||||
while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
|
||||
|
||||
// Fuckup - very small and broken sequence,
|
||||
// return max, because we should return something anyway.
|
||||
if (pos < 0) { return max; }
|
||||
|
||||
// If we came to start of buffer - that means vuffer is too small,
|
||||
// return max too.
|
||||
if (pos === 0) { return max; }
|
||||
|
||||
return (pos + _utf8len[buf[pos]] > max) ? pos : max;
|
||||
};
|
||||
|
||||
// convert array to string
|
||||
var buf2string = function (buf) {
|
||||
var str, i, out, c, c_len;
|
||||
var len = buf.length;
|
||||
|
||||
// Reserve max possible length (2 words per char)
|
||||
// NB: by unknown reasons, Array is significantly faster for
|
||||
// String.fromCharCode.apply than Uint16Array.
|
||||
var utf16buf = new Array(len*2);
|
||||
|
||||
for (out=0, i=0; i<len;) {
|
||||
c = buf[i++];
|
||||
// quick process ascii
|
||||
if (c < 0x80) { utf16buf[out++] = c; continue; }
|
||||
|
||||
c_len = _utf8len[c];
|
||||
// skip 5 & 6 byte codes
|
||||
if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; }
|
||||
|
||||
// apply mask on first byte
|
||||
c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
|
||||
// join the rest
|
||||
while (c_len > 1 && i < len) {
|
||||
c = (c << 6) | (buf[i++] & 0x3f);
|
||||
c_len--;
|
||||
}
|
||||
|
||||
// terminated by end of string?
|
||||
if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }
|
||||
|
||||
if (c < 0x10000) {
|
||||
utf16buf[out++] = c;
|
||||
} else {
|
||||
c -= 0x10000;
|
||||
utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);
|
||||
utf16buf[out++] = 0xdc00 | (c & 0x3ff);
|
||||
}
|
||||
}
|
||||
|
||||
// shrinkBuf(utf16buf, out)
|
||||
if (utf16buf.length !== out) {
|
||||
if(utf16buf.subarray) {
|
||||
utf16buf = utf16buf.subarray(0, out);
|
||||
} else {
|
||||
utf16buf.length = out;
|
||||
}
|
||||
}
|
||||
|
||||
// return String.fromCharCode.apply(null, utf16buf);
|
||||
return utils.applyFromCharCode(utf16buf);
|
||||
};
|
||||
|
||||
|
||||
// That's all for the pako functions.
|
||||
|
||||
|
||||
/**
|
||||
* Transform a javascript string into an array (typed if possible) of bytes,
|
||||
* UTF-8 encoded.
|
||||
* @param {String} str the string to encode
|
||||
* @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.
|
||||
*/
|
||||
exports.utf8encode = function utf8encode(str) {
|
||||
if (support.nodebuffer) {
|
||||
return nodeBuffer(str, "utf-8");
|
||||
}
|
||||
|
||||
return string2buf(str);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Transform a bytes array (or a representation) representing an UTF-8 encoded
|
||||
* string into a javascript string.
|
||||
* @param {Array|Uint8Array|Buffer} buf the data de decode
|
||||
* @return {String} the decoded string.
|
||||
*/
|
||||
exports.utf8decode = function utf8decode(buf) {
|
||||
if (support.nodebuffer) {
|
||||
return utils.transformTo("nodebuffer", buf).toString("utf-8");
|
||||
}
|
||||
|
||||
buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf);
|
||||
|
||||
// return buf2string(buf);
|
||||
// Chrome prefers to work with "small" chunks of data
|
||||
// for the method buf2string.
|
||||
// Firefox and Chrome has their own shortcut, IE doesn't seem to really care.
|
||||
var result = [], k = 0, len = buf.length, chunk = 65536;
|
||||
while (k < len) {
|
||||
var nextBoundary = utf8border(buf, Math.min(k + chunk, len));
|
||||
if (support.uint8array) {
|
||||
result.push(buf2string(buf.subarray(k, nextBoundary)));
|
||||
} else {
|
||||
result.push(buf2string(buf.slice(k, nextBoundary)));
|
||||
}
|
||||
k = nextBoundary;
|
||||
}
|
||||
return result.join("");
|
||||
|
||||
};
|
||||
// vim: set shiftwidth=4 softtabstop=4:
|
||||
344
vendors/jszip/lib/utils.js
vendored
Normal file
344
vendors/jszip/lib/utils.js
vendored
Normal file
@@ -0,0 +1,344 @@
|
||||
'use strict';
|
||||
var support = require('./support');
|
||||
var compressions = require('./compressions');
|
||||
var nodeBuffer = require('./nodeBuffer');
|
||||
/**
|
||||
* Convert a string to a "binary string" : a string containing only char codes between 0 and 255.
|
||||
* @param {string} str the string to transform.
|
||||
* @return {String} the binary string.
|
||||
*/
|
||||
exports.string2binary = function(str) {
|
||||
var result = "";
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
result += String.fromCharCode(str.charCodeAt(i) & 0xff);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.arrayBuffer2Blob = function(buffer, mimeType) {
|
||||
exports.checkSupport("blob");
|
||||
mimeType = mimeType || 'application/zip';
|
||||
|
||||
try {
|
||||
// Blob constructor
|
||||
return new Blob([buffer], {
|
||||
type: mimeType
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
try {
|
||||
// deprecated, browser only, old way
|
||||
var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
||||
var builder = new Builder();
|
||||
builder.append(buffer);
|
||||
return builder.getBlob(mimeType);
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
// well, fuck ?!
|
||||
throw new Error("Bug : can't construct the Blob.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
/**
|
||||
* The identity function.
|
||||
* @param {Object} input the input.
|
||||
* @return {Object} the same input.
|
||||
*/
|
||||
function identity(input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in an array with a string.
|
||||
* @param {String} str the string to use.
|
||||
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).
|
||||
* @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.
|
||||
*/
|
||||
function stringToArrayLike(str, array) {
|
||||
for (var i = 0; i < str.length; ++i) {
|
||||
array[i] = str.charCodeAt(i) & 0xFF;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform an array-like object to a string.
|
||||
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
|
||||
* @return {String} the result.
|
||||
*/
|
||||
function arrayLikeToString(array) {
|
||||
// Performances notes :
|
||||
// --------------------
|
||||
// String.fromCharCode.apply(null, array) is the fastest, see
|
||||
// see http://jsperf.com/converting-a-uint8array-to-a-string/2
|
||||
// but the stack is limited (and we can get huge arrays !).
|
||||
//
|
||||
// result += String.fromCharCode(array[i]); generate too many strings !
|
||||
//
|
||||
// This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
|
||||
var chunk = 65536;
|
||||
var result = [],
|
||||
len = array.length,
|
||||
type = exports.getTypeOf(array),
|
||||
k = 0,
|
||||
canUseApply = true;
|
||||
try {
|
||||
switch(type) {
|
||||
case "uint8array":
|
||||
String.fromCharCode.apply(null, new Uint8Array(0));
|
||||
break;
|
||||
case "nodebuffer":
|
||||
String.fromCharCode.apply(null, nodeBuffer(0));
|
||||
break;
|
||||
}
|
||||
} catch(e) {
|
||||
canUseApply = false;
|
||||
}
|
||||
|
||||
// no apply : slow and painful algorithm
|
||||
// default browser on android 4.*
|
||||
if (!canUseApply) {
|
||||
var resultStr = "";
|
||||
for(var i = 0; i < array.length;i++) {
|
||||
resultStr += String.fromCharCode(array[i]);
|
||||
}
|
||||
return resultStr;
|
||||
}
|
||||
while (k < len && chunk > 1) {
|
||||
try {
|
||||
if (type === "array" || type === "nodebuffer") {
|
||||
result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
|
||||
}
|
||||
else {
|
||||
result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
|
||||
}
|
||||
k += chunk;
|
||||
}
|
||||
catch (e) {
|
||||
chunk = Math.floor(chunk / 2);
|
||||
}
|
||||
}
|
||||
return result.join("");
|
||||
}
|
||||
|
||||
exports.applyFromCharCode = arrayLikeToString;
|
||||
|
||||
|
||||
/**
|
||||
* Copy the data from an array-like to an other array-like.
|
||||
* @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.
|
||||
* @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.
|
||||
* @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.
|
||||
*/
|
||||
function arrayLikeToArrayLike(arrayFrom, arrayTo) {
|
||||
for (var i = 0; i < arrayFrom.length; i++) {
|
||||
arrayTo[i] = arrayFrom[i];
|
||||
}
|
||||
return arrayTo;
|
||||
}
|
||||
|
||||
// a matrix containing functions to transform everything into everything.
|
||||
var transform = {};
|
||||
|
||||
// string to ?
|
||||
transform["string"] = {
|
||||
"string": identity,
|
||||
"array": function(input) {
|
||||
return stringToArrayLike(input, new Array(input.length));
|
||||
},
|
||||
"arraybuffer": function(input) {
|
||||
return transform["string"]["uint8array"](input).buffer;
|
||||
},
|
||||
"uint8array": function(input) {
|
||||
return stringToArrayLike(input, new Uint8Array(input.length));
|
||||
},
|
||||
"nodebuffer": function(input) {
|
||||
return stringToArrayLike(input, nodeBuffer(input.length));
|
||||
}
|
||||
};
|
||||
|
||||
// array to ?
|
||||
transform["array"] = {
|
||||
"string": arrayLikeToString,
|
||||
"array": identity,
|
||||
"arraybuffer": function(input) {
|
||||
return (new Uint8Array(input)).buffer;
|
||||
},
|
||||
"uint8array": function(input) {
|
||||
return new Uint8Array(input);
|
||||
},
|
||||
"nodebuffer": function(input) {
|
||||
return nodeBuffer(input);
|
||||
}
|
||||
};
|
||||
|
||||
// arraybuffer to ?
|
||||
transform["arraybuffer"] = {
|
||||
"string": function(input) {
|
||||
return arrayLikeToString(new Uint8Array(input));
|
||||
},
|
||||
"array": function(input) {
|
||||
return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
|
||||
},
|
||||
"arraybuffer": identity,
|
||||
"uint8array": function(input) {
|
||||
return new Uint8Array(input);
|
||||
},
|
||||
"nodebuffer": function(input) {
|
||||
return nodeBuffer(new Uint8Array(input));
|
||||
}
|
||||
};
|
||||
|
||||
// uint8array to ?
|
||||
transform["uint8array"] = {
|
||||
"string": arrayLikeToString,
|
||||
"array": function(input) {
|
||||
return arrayLikeToArrayLike(input, new Array(input.length));
|
||||
},
|
||||
"arraybuffer": function(input) {
|
||||
return input.buffer;
|
||||
},
|
||||
"uint8array": identity,
|
||||
"nodebuffer": function(input) {
|
||||
return nodeBuffer(input);
|
||||
}
|
||||
};
|
||||
|
||||
// nodebuffer to ?
|
||||
transform["nodebuffer"] = {
|
||||
"string": arrayLikeToString,
|
||||
"array": function(input) {
|
||||
return arrayLikeToArrayLike(input, new Array(input.length));
|
||||
},
|
||||
"arraybuffer": function(input) {
|
||||
return transform["nodebuffer"]["uint8array"](input).buffer;
|
||||
},
|
||||
"uint8array": function(input) {
|
||||
return arrayLikeToArrayLike(input, new Uint8Array(input.length));
|
||||
},
|
||||
"nodebuffer": identity
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform an input into any type.
|
||||
* The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.
|
||||
* If no output type is specified, the unmodified input will be returned.
|
||||
* @param {String} outputType the output type.
|
||||
* @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.
|
||||
* @throws {Error} an Error if the browser doesn't support the requested output type.
|
||||
*/
|
||||
exports.transformTo = function(outputType, input) {
|
||||
if (!input) {
|
||||
// undefined, null, etc
|
||||
// an empty string won't harm.
|
||||
input = "";
|
||||
}
|
||||
if (!outputType) {
|
||||
return input;
|
||||
}
|
||||
exports.checkSupport(outputType);
|
||||
var inputType = exports.getTypeOf(input);
|
||||
var result = transform[inputType][outputType](input);
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the type of the input.
|
||||
* The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.
|
||||
* @param {Object} input the input to identify.
|
||||
* @return {String} the (lowercase) type of the input.
|
||||
*/
|
||||
exports.getTypeOf = function(input) {
|
||||
if (typeof input === "string") {
|
||||
return "string";
|
||||
}
|
||||
if (Object.prototype.toString.call(input) === "[object Array]") {
|
||||
return "array";
|
||||
}
|
||||
if (support.nodebuffer && nodeBuffer.test(input)) {
|
||||
return "nodebuffer";
|
||||
}
|
||||
if (support.uint8array && input instanceof Uint8Array) {
|
||||
return "uint8array";
|
||||
}
|
||||
if (support.arraybuffer && input instanceof ArrayBuffer) {
|
||||
return "arraybuffer";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Throw an exception if the type is not supported.
|
||||
* @param {String} type the type to check.
|
||||
* @throws {Error} an Error if the browser doesn't support the requested type.
|
||||
*/
|
||||
exports.checkSupport = function(type) {
|
||||
var supported = support[type.toLowerCase()];
|
||||
if (!supported) {
|
||||
throw new Error(type + " is not supported by this browser");
|
||||
}
|
||||
};
|
||||
exports.MAX_VALUE_16BITS = 65535;
|
||||
exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1
|
||||
|
||||
/**
|
||||
* Prettify a string read as binary.
|
||||
* @param {string} str the string to prettify.
|
||||
* @return {string} a pretty string.
|
||||
*/
|
||||
exports.pretty = function(str) {
|
||||
var res = '',
|
||||
code, i;
|
||||
for (i = 0; i < (str || "").length; i++) {
|
||||
code = str.charCodeAt(i);
|
||||
res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find a compression registered in JSZip.
|
||||
* @param {string} compressionMethod the method magic to find.
|
||||
* @return {Object|null} the JSZip compression object, null if none found.
|
||||
*/
|
||||
exports.findCompression = function(compressionMethod) {
|
||||
for (var method in compressions) {
|
||||
if (!compressions.hasOwnProperty(method)) {
|
||||
continue;
|
||||
}
|
||||
if (compressions[method].magic === compressionMethod) {
|
||||
return compressions[method];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
/**
|
||||
* Cross-window, cross-Node-context regular expression detection
|
||||
* @param {Object} object Anything
|
||||
* @return {Boolean} true if the object is a regular expression,
|
||||
* false otherwise
|
||||
*/
|
||||
exports.isRegExp = function (object) {
|
||||
return Object.prototype.toString.call(object) === "[object RegExp]";
|
||||
};
|
||||
|
||||
/**
|
||||
* Merge the objects passed as parameters into a new one.
|
||||
* @private
|
||||
* @param {...Object} var_args All objects to merge.
|
||||
* @return {Object} a new object with the data of the others.
|
||||
*/
|
||||
exports.extend = function() {
|
||||
var result = {}, i, attr;
|
||||
for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers
|
||||
for (attr in arguments[i]) {
|
||||
if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") {
|
||||
result[attr] = arguments[i][attr];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
280
vendors/jszip/lib/zipEntries.js
vendored
Normal file
280
vendors/jszip/lib/zipEntries.js
vendored
Normal file
@@ -0,0 +1,280 @@
|
||||
'use strict';
|
||||
var StringReader = require('./stringReader');
|
||||
var NodeBufferReader = require('./nodeBufferReader');
|
||||
var Uint8ArrayReader = require('./uint8ArrayReader');
|
||||
var ArrayReader = require('./arrayReader');
|
||||
var utils = require('./utils');
|
||||
var sig = require('./signature');
|
||||
var ZipEntry = require('./zipEntry');
|
||||
var support = require('./support');
|
||||
var jszipProto = require('./object');
|
||||
// class ZipEntries {{{
|
||||
/**
|
||||
* All the entries in the zip file.
|
||||
* @constructor
|
||||
* @param {String|ArrayBuffer|Uint8Array} data the binary stream to load.
|
||||
* @param {Object} loadOptions Options for loading the stream.
|
||||
*/
|
||||
function ZipEntries(data, loadOptions) {
|
||||
this.files = [];
|
||||
this.loadOptions = loadOptions;
|
||||
if (data) {
|
||||
this.load(data);
|
||||
}
|
||||
}
|
||||
ZipEntries.prototype = {
|
||||
/**
|
||||
* Check that the reader is on the speficied signature.
|
||||
* @param {string} expectedSignature the expected signature.
|
||||
* @throws {Error} if it is an other signature.
|
||||
*/
|
||||
checkSignature: function(expectedSignature) {
|
||||
var signature = this.reader.readString(4);
|
||||
if (signature !== expectedSignature) {
|
||||
throw new Error("Corrupted zip or bug : unexpected signature " + "(" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Check if the given signature is at the given index.
|
||||
* @param {number} askedIndex the index to check.
|
||||
* @param {string} expectedSignature the signature to expect.
|
||||
* @return {boolean} true if the signature is here, false otherwise.
|
||||
*/
|
||||
isSignature: function(askedIndex, expectedSignature) {
|
||||
var currentIndex = this.reader.index;
|
||||
this.reader.setIndex(askedIndex);
|
||||
var signature = this.reader.readString(4);
|
||||
var result = signature === expectedSignature;
|
||||
this.reader.setIndex(currentIndex);
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* Read the end of the central directory.
|
||||
*/
|
||||
readBlockEndOfCentral: function() {
|
||||
this.diskNumber = this.reader.readInt(2);
|
||||
this.diskWithCentralDirStart = this.reader.readInt(2);
|
||||
this.centralDirRecordsOnThisDisk = this.reader.readInt(2);
|
||||
this.centralDirRecords = this.reader.readInt(2);
|
||||
this.centralDirSize = this.reader.readInt(4);
|
||||
this.centralDirOffset = this.reader.readInt(4);
|
||||
|
||||
this.zipCommentLength = this.reader.readInt(2);
|
||||
// warning : the encoding depends of the system locale
|
||||
// On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.
|
||||
// On a windows machine, this field is encoded with the localized windows code page.
|
||||
var zipComment = this.reader.readData(this.zipCommentLength);
|
||||
var decodeParamType = support.uint8array ? "uint8array" : "array";
|
||||
// To get consistent behavior with the generation part, we will assume that
|
||||
// this is utf8 encoded unless specified otherwise.
|
||||
var decodeContent = utils.transformTo(decodeParamType, zipComment);
|
||||
this.zipComment = this.loadOptions.decodeFileName(decodeContent);
|
||||
},
|
||||
/**
|
||||
* Read the end of the Zip 64 central directory.
|
||||
* Not merged with the method readEndOfCentral :
|
||||
* The end of central can coexist with its Zip64 brother,
|
||||
* I don't want to read the wrong number of bytes !
|
||||
*/
|
||||
readBlockZip64EndOfCentral: function() {
|
||||
this.zip64EndOfCentralSize = this.reader.readInt(8);
|
||||
this.versionMadeBy = this.reader.readString(2);
|
||||
this.versionNeeded = this.reader.readInt(2);
|
||||
this.diskNumber = this.reader.readInt(4);
|
||||
this.diskWithCentralDirStart = this.reader.readInt(4);
|
||||
this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
|
||||
this.centralDirRecords = this.reader.readInt(8);
|
||||
this.centralDirSize = this.reader.readInt(8);
|
||||
this.centralDirOffset = this.reader.readInt(8);
|
||||
|
||||
this.zip64ExtensibleData = {};
|
||||
var extraDataSize = this.zip64EndOfCentralSize - 44,
|
||||
index = 0,
|
||||
extraFieldId,
|
||||
extraFieldLength,
|
||||
extraFieldValue;
|
||||
while (index < extraDataSize) {
|
||||
extraFieldId = this.reader.readInt(2);
|
||||
extraFieldLength = this.reader.readInt(4);
|
||||
extraFieldValue = this.reader.readString(extraFieldLength);
|
||||
this.zip64ExtensibleData[extraFieldId] = {
|
||||
id: extraFieldId,
|
||||
length: extraFieldLength,
|
||||
value: extraFieldValue
|
||||
};
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the end of the Zip 64 central directory locator.
|
||||
*/
|
||||
readBlockZip64EndOfCentralLocator: function() {
|
||||
this.diskWithZip64CentralDirStart = this.reader.readInt(4);
|
||||
this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);
|
||||
this.disksCount = this.reader.readInt(4);
|
||||
if (this.disksCount > 1) {
|
||||
throw new Error("Multi-volumes zip are not supported");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the local files, based on the offset read in the central part.
|
||||
*/
|
||||
readLocalFiles: function() {
|
||||
var i, file;
|
||||
for (i = 0; i < this.files.length; i++) {
|
||||
file = this.files[i];
|
||||
this.reader.setIndex(file.localHeaderOffset);
|
||||
this.checkSignature(sig.LOCAL_FILE_HEADER);
|
||||
file.readLocalPart(this.reader);
|
||||
file.handleUTF8();
|
||||
file.processAttributes();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the central directory.
|
||||
*/
|
||||
readCentralDir: function() {
|
||||
var file;
|
||||
|
||||
this.reader.setIndex(this.centralDirOffset);
|
||||
while (this.reader.readString(4) === sig.CENTRAL_FILE_HEADER) {
|
||||
file = new ZipEntry({
|
||||
zip64: this.zip64
|
||||
}, this.loadOptions);
|
||||
file.readCentralPart(this.reader);
|
||||
this.files.push(file);
|
||||
}
|
||||
|
||||
if (this.centralDirRecords !== this.files.length) {
|
||||
if (this.centralDirRecords !== 0 && this.files.length === 0) {
|
||||
// We expected some records but couldn't find ANY.
|
||||
// This is really suspicious, as if something went wrong.
|
||||
throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
|
||||
} else {
|
||||
// We found some records but not all.
|
||||
// Something is wrong but we got something for the user: no error here.
|
||||
// console.warn("expected", this.centralDirRecords, "records in central dir, got", this.files.length);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the end of central directory.
|
||||
*/
|
||||
readEndOfCentral: function() {
|
||||
var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
|
||||
if (offset < 0) {
|
||||
// Check if the content is a truncated zip or complete garbage.
|
||||
// A "LOCAL_FILE_HEADER" is not required at the beginning (auto
|
||||
// extractible zip for example) but it can give a good hint.
|
||||
// If an ajax request was used without responseType, we will also
|
||||
// get unreadable data.
|
||||
var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);
|
||||
|
||||
if (isGarbage) {
|
||||
throw new Error("Can't find end of central directory : is this a zip file ? " +
|
||||
"If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html");
|
||||
} else {
|
||||
throw new Error("Corrupted zip : can't find end of central directory");
|
||||
}
|
||||
}
|
||||
this.reader.setIndex(offset);
|
||||
var endOfCentralDirOffset = offset;
|
||||
this.checkSignature(sig.CENTRAL_DIRECTORY_END);
|
||||
this.readBlockEndOfCentral();
|
||||
|
||||
|
||||
/* extract from the zip spec :
|
||||
4) If one of the fields in the end of central directory
|
||||
record is too small to hold required data, the field
|
||||
should be set to -1 (0xFFFF or 0xFFFFFFFF) and the
|
||||
ZIP64 format record should be created.
|
||||
5) The end of central directory record and the
|
||||
Zip64 end of central directory locator record must
|
||||
reside on the same disk when splitting or spanning
|
||||
an archive.
|
||||
*/
|
||||
if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {
|
||||
this.zip64 = true;
|
||||
|
||||
/*
|
||||
Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from
|
||||
the zip file can fit into a 32bits integer. This cannot be solved : Javascript represents
|
||||
all numbers as 64-bit double precision IEEE 754 floating point numbers.
|
||||
So, we have 53bits for integers and bitwise operations treat everything as 32bits.
|
||||
see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators
|
||||
and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5
|
||||
*/
|
||||
|
||||
// should look for a zip64 EOCD locator
|
||||
offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
|
||||
if (offset < 0) {
|
||||
throw new Error("Corrupted zip : can't find the ZIP64 end of central directory locator");
|
||||
}
|
||||
this.reader.setIndex(offset);
|
||||
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
|
||||
this.readBlockZip64EndOfCentralLocator();
|
||||
|
||||
// now the zip64 EOCD record
|
||||
if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {
|
||||
// console.warn("ZIP64 end of central directory not where expected.");
|
||||
this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
|
||||
if (this.relativeOffsetEndOfZip64CentralDir < 0) {
|
||||
throw new Error("Corrupted zip : can't find the ZIP64 end of central directory");
|
||||
}
|
||||
}
|
||||
this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);
|
||||
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
|
||||
this.readBlockZip64EndOfCentral();
|
||||
}
|
||||
|
||||
var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;
|
||||
if (this.zip64) {
|
||||
expectedEndOfCentralDirOffset += 20; // end of central dir 64 locator
|
||||
expectedEndOfCentralDirOffset += 12 /* should not include the leading 12 bytes */ + this.zip64EndOfCentralSize;
|
||||
}
|
||||
|
||||
var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;
|
||||
|
||||
if (extraBytes > 0) {
|
||||
// console.warn(extraBytes, "extra bytes at beginning or within zipfile");
|
||||
if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {
|
||||
// The offsets seem wrong, but we have something at the specified offset.
|
||||
// So… we keep it.
|
||||
} else {
|
||||
// the offset is wrong, update the "zero" of the reader
|
||||
// this happens if data has been prepended (crx files for example)
|
||||
this.reader.zero = extraBytes;
|
||||
}
|
||||
} else if (extraBytes < 0) {
|
||||
throw new Error("Corrupted zip: missing " + Math.abs(extraBytes) + " bytes.");
|
||||
}
|
||||
},
|
||||
prepareReader: function(data) {
|
||||
var type = utils.getTypeOf(data);
|
||||
utils.checkSupport(type);
|
||||
if (type === "string" && !support.uint8array) {
|
||||
this.reader = new StringReader(data, this.loadOptions.optimizedBinaryString);
|
||||
}
|
||||
else if (type === "nodebuffer") {
|
||||
this.reader = new NodeBufferReader(data);
|
||||
}
|
||||
else if (support.uint8array) {
|
||||
this.reader = new Uint8ArrayReader(utils.transformTo("uint8array", data));
|
||||
} else if (support.array) {
|
||||
this.reader = new ArrayReader(utils.transformTo("array", data));
|
||||
} else {
|
||||
throw new Error("Unexpected error: unsupported type '" + type + "'");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read a zip file and create ZipEntries.
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.
|
||||
*/
|
||||
load: function(data) {
|
||||
this.prepareReader(data);
|
||||
this.readEndOfCentral();
|
||||
this.readCentralDir();
|
||||
this.readLocalFiles();
|
||||
}
|
||||
};
|
||||
// }}} end of ZipEntries
|
||||
module.exports = ZipEntries;
|
||||
319
vendors/jszip/lib/zipEntry.js
vendored
Normal file
319
vendors/jszip/lib/zipEntry.js
vendored
Normal file
@@ -0,0 +1,319 @@
|
||||
'use strict';
|
||||
var StringReader = require('./stringReader');
|
||||
var utils = require('./utils');
|
||||
var CompressedObject = require('./compressedObject');
|
||||
var jszipProto = require('./object');
|
||||
var support = require('./support');
|
||||
|
||||
var MADE_BY_DOS = 0x00;
|
||||
var MADE_BY_UNIX = 0x03;
|
||||
|
||||
// class ZipEntry {{{
|
||||
/**
|
||||
* An entry in the zip file.
|
||||
* @constructor
|
||||
* @param {Object} options Options of the current file.
|
||||
* @param {Object} loadOptions Options for loading the stream.
|
||||
*/
|
||||
function ZipEntry(options, loadOptions) {
|
||||
this.options = options;
|
||||
this.loadOptions = loadOptions;
|
||||
}
|
||||
ZipEntry.prototype = {
|
||||
/**
|
||||
* say if the file is encrypted.
|
||||
* @return {boolean} true if the file is encrypted, false otherwise.
|
||||
*/
|
||||
isEncrypted: function() {
|
||||
// bit 1 is set
|
||||
return (this.bitFlag & 0x0001) === 0x0001;
|
||||
},
|
||||
/**
|
||||
* say if the file has utf-8 filename/comment.
|
||||
* @return {boolean} true if the filename/comment is in utf-8, false otherwise.
|
||||
*/
|
||||
useUTF8: function() {
|
||||
// bit 11 is set
|
||||
return (this.bitFlag & 0x0800) === 0x0800;
|
||||
},
|
||||
/**
|
||||
* Prepare the function used to generate the compressed content from this ZipFile.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
* @param {number} from the offset from where we should read the data.
|
||||
* @param {number} length the length of the data to read.
|
||||
* @return {Function} the callback to get the compressed content (the type depends of the DataReader class).
|
||||
*/
|
||||
prepareCompressedContent: function(reader, from, length) {
|
||||
return function() {
|
||||
var previousIndex = reader.index;
|
||||
reader.setIndex(from);
|
||||
var compressedFileData = reader.readData(length);
|
||||
reader.setIndex(previousIndex);
|
||||
|
||||
return compressedFileData;
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Prepare the function used to generate the uncompressed content from this ZipFile.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
* @param {number} from the offset from where we should read the data.
|
||||
* @param {number} length the length of the data to read.
|
||||
* @param {JSZip.compression} compression the compression used on this file.
|
||||
* @param {number} uncompressedSize the uncompressed size to expect.
|
||||
* @return {Function} the callback to get the uncompressed content (the type depends of the DataReader class).
|
||||
*/
|
||||
prepareContent: function(reader, from, length, compression, uncompressedSize) {
|
||||
return function() {
|
||||
|
||||
var compressedFileData = utils.transformTo(compression.uncompressInputType, this.getCompressedContent());
|
||||
var uncompressedFileData = compression.uncompress(compressedFileData);
|
||||
|
||||
if (uncompressedFileData.length !== uncompressedSize) {
|
||||
throw new Error("Bug : uncompressed data size mismatch");
|
||||
}
|
||||
|
||||
return uncompressedFileData;
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Read the local part of a zip file and add the info in this object.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
*/
|
||||
readLocalPart: function(reader) {
|
||||
var compression, localExtraFieldsLength;
|
||||
|
||||
// we already know everything from the central dir !
|
||||
// If the central dir data are false, we are doomed.
|
||||
// On the bright side, the local part is scary : zip64, data descriptors, both, etc.
|
||||
// The less data we get here, the more reliable this should be.
|
||||
// Let's skip the whole header and dash to the data !
|
||||
reader.skip(22);
|
||||
// in some zip created on windows, the filename stored in the central dir contains \ instead of /.
|
||||
// Strangely, the filename here is OK.
|
||||
// I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes
|
||||
// or APPNOTE#4.4.17.1, "All slashes MUST be forward slashes '/'") but there are a lot of bad zip generators...
|
||||
// Search "unzip mismatching "local" filename continuing with "central" filename version" on
|
||||
// the internet.
|
||||
//
|
||||
// I think I see the logic here : the central directory is used to display
|
||||
// content and the local directory is used to extract the files. Mixing / and \
|
||||
// may be used to display \ to windows users and use / when extracting the files.
|
||||
// Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394
|
||||
this.fileNameLength = reader.readInt(2);
|
||||
localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir
|
||||
this.fileName = reader.readData(this.fileNameLength);
|
||||
reader.skip(localExtraFieldsLength);
|
||||
|
||||
if (this.compressedSize == -1 || this.uncompressedSize == -1) {
|
||||
throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory " + "(compressedSize == -1 || uncompressedSize == -1)");
|
||||
}
|
||||
|
||||
compression = utils.findCompression(this.compressionMethod);
|
||||
if (compression === null) { // no compression found
|
||||
throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + utils.transformTo("string", this.fileName) + ")");
|
||||
}
|
||||
this.decompressed = new CompressedObject();
|
||||
this.decompressed.compressedSize = this.compressedSize;
|
||||
this.decompressed.uncompressedSize = this.uncompressedSize;
|
||||
this.decompressed.crc32 = this.crc32;
|
||||
this.decompressed.compressionMethod = this.compressionMethod;
|
||||
this.decompressed.getCompressedContent = this.prepareCompressedContent(reader, reader.index, this.compressedSize, compression);
|
||||
this.decompressed.getContent = this.prepareContent(reader, reader.index, this.compressedSize, compression, this.uncompressedSize);
|
||||
|
||||
// we need to compute the crc32...
|
||||
if (this.loadOptions.checkCRC32) {
|
||||
this.decompressed = utils.transformTo("string", this.decompressed.getContent());
|
||||
if (jszipProto.crc32(this.decompressed) !== this.crc32) {
|
||||
throw new Error("Corrupted zip : CRC32 mismatch");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Read the central part of a zip file and add the info in this object.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
*/
|
||||
readCentralPart: function(reader) {
|
||||
this.versionMadeBy = reader.readInt(2);
|
||||
this.versionNeeded = reader.readInt(2);
|
||||
this.bitFlag = reader.readInt(2);
|
||||
this.compressionMethod = reader.readString(2);
|
||||
this.date = reader.readDate();
|
||||
this.crc32 = reader.readInt(4);
|
||||
this.compressedSize = reader.readInt(4);
|
||||
this.uncompressedSize = reader.readInt(4);
|
||||
this.fileNameLength = reader.readInt(2);
|
||||
this.extraFieldsLength = reader.readInt(2);
|
||||
this.fileCommentLength = reader.readInt(2);
|
||||
this.diskNumberStart = reader.readInt(2);
|
||||
this.internalFileAttributes = reader.readInt(2);
|
||||
this.externalFileAttributes = reader.readInt(4);
|
||||
this.localHeaderOffset = reader.readInt(4);
|
||||
|
||||
if (this.isEncrypted()) {
|
||||
throw new Error("Encrypted zip are not supported");
|
||||
}
|
||||
|
||||
this.fileName = reader.readData(this.fileNameLength);
|
||||
this.readExtraFields(reader);
|
||||
this.parseZIP64ExtraField(reader);
|
||||
this.fileComment = reader.readData(this.fileCommentLength);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the external file attributes and get the unix/dos permissions.
|
||||
*/
|
||||
processAttributes: function () {
|
||||
this.unixPermissions = null;
|
||||
this.dosPermissions = null;
|
||||
var madeBy = this.versionMadeBy >> 8;
|
||||
|
||||
// Check if we have the DOS directory flag set.
|
||||
// We look for it in the DOS and UNIX permissions
|
||||
// but some unknown platform could set it as a compatibility flag.
|
||||
this.dir = this.externalFileAttributes & 0x0010 ? true : false;
|
||||
|
||||
if(madeBy === MADE_BY_DOS) {
|
||||
// first 6 bits (0 to 5)
|
||||
this.dosPermissions = this.externalFileAttributes & 0x3F;
|
||||
}
|
||||
|
||||
if(madeBy === MADE_BY_UNIX) {
|
||||
this.unixPermissions = (this.externalFileAttributes >> 16) & 0xFFFF;
|
||||
// the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);
|
||||
}
|
||||
|
||||
// fail safe : if the name ends with a / it probably means a folder
|
||||
if (!this.dir && this.fileNameStr.slice(-1) === '/') {
|
||||
this.dir = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the ZIP64 extra field and merge the info in the current ZipEntry.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
*/
|
||||
parseZIP64ExtraField: function(reader) {
|
||||
|
||||
if (!this.extraFields[0x0001]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// should be something, preparing the extra reader
|
||||
var extraReader = new StringReader(this.extraFields[0x0001].value);
|
||||
|
||||
// I really hope that these 64bits integer can fit in 32 bits integer, because js
|
||||
// won't let us have more.
|
||||
if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
|
||||
this.uncompressedSize = extraReader.readInt(8);
|
||||
}
|
||||
if (this.compressedSize === utils.MAX_VALUE_32BITS) {
|
||||
this.compressedSize = extraReader.readInt(8);
|
||||
}
|
||||
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
|
||||
this.localHeaderOffset = extraReader.readInt(8);
|
||||
}
|
||||
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
|
||||
this.diskNumberStart = extraReader.readInt(4);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the central part of a zip file and add the info in this object.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
*/
|
||||
readExtraFields: function(reader) {
|
||||
var start = reader.index,
|
||||
extraFieldId,
|
||||
extraFieldLength,
|
||||
extraFieldValue;
|
||||
|
||||
this.extraFields = this.extraFields || {};
|
||||
|
||||
while (reader.index < start + this.extraFieldsLength) {
|
||||
extraFieldId = reader.readInt(2);
|
||||
extraFieldLength = reader.readInt(2);
|
||||
extraFieldValue = reader.readString(extraFieldLength);
|
||||
|
||||
this.extraFields[extraFieldId] = {
|
||||
id: extraFieldId,
|
||||
length: extraFieldLength,
|
||||
value: extraFieldValue
|
||||
};
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Apply an UTF8 transformation if needed.
|
||||
*/
|
||||
handleUTF8: function() {
|
||||
var decodeParamType = support.uint8array ? "uint8array" : "array";
|
||||
if (this.useUTF8()) {
|
||||
this.fileNameStr = jszipProto.utf8decode(this.fileName);
|
||||
this.fileCommentStr = jszipProto.utf8decode(this.fileComment);
|
||||
} else {
|
||||
var upath = this.findExtraFieldUnicodePath();
|
||||
if (upath !== null) {
|
||||
this.fileNameStr = upath;
|
||||
} else {
|
||||
var fileNameByteArray = utils.transformTo(decodeParamType, this.fileName);
|
||||
this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);
|
||||
}
|
||||
|
||||
var ucomment = this.findExtraFieldUnicodeComment();
|
||||
if (ucomment !== null) {
|
||||
this.fileCommentStr = ucomment;
|
||||
} else {
|
||||
var commentByteArray = utils.transformTo(decodeParamType, this.fileComment);
|
||||
this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the unicode path declared in the extra field, if any.
|
||||
* @return {String} the unicode path, null otherwise.
|
||||
*/
|
||||
findExtraFieldUnicodePath: function() {
|
||||
var upathField = this.extraFields[0x7075];
|
||||
if (upathField) {
|
||||
var extraReader = new StringReader(upathField.value);
|
||||
|
||||
// wrong version
|
||||
if (extraReader.readInt(1) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// the crc of the filename changed, this field is out of date.
|
||||
if (jszipProto.crc32(this.fileName) !== extraReader.readInt(4)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jszipProto.utf8decode(extraReader.readString(upathField.length - 5));
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the unicode comment declared in the extra field, if any.
|
||||
* @return {String} the unicode comment, null otherwise.
|
||||
*/
|
||||
findExtraFieldUnicodeComment: function() {
|
||||
var ucommentField = this.extraFields[0x6375];
|
||||
if (ucommentField) {
|
||||
var extraReader = new StringReader(ucommentField.value);
|
||||
|
||||
// wrong version
|
||||
if (extraReader.readInt(1) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// the crc of the comment changed, this field is out of date.
|
||||
if (jszipProto.crc32(this.fileComment) !== extraReader.readInt(4)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jszipProto.utf8decode(extraReader.readString(ucommentField.length - 5));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
module.exports = ZipEntry;
|
||||
53
vendors/jszip/package.json
vendored
Normal file
53
vendors/jszip/package.json
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "jszip",
|
||||
"version": "2.6.0",
|
||||
"author": "Stuart Knightley <stuart@stuartk.com>",
|
||||
"description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip",
|
||||
"scripts": {
|
||||
"test": "npm run test-node && npm run test-browser",
|
||||
"test-node": "cd test && qunit -c node.js -t test.js",
|
||||
"test-browser": "grunt build && grunt test",
|
||||
"lint": "grunt jshint"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Franz Buchinger"
|
||||
},
|
||||
{
|
||||
"name": "António Afonso"
|
||||
},
|
||||
{
|
||||
"name": "David Duponchel"
|
||||
},
|
||||
{
|
||||
"name": "yiminghe"
|
||||
}
|
||||
],
|
||||
"main": "./lib/index",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Stuk/jszip.git"
|
||||
},
|
||||
"keywords": [
|
||||
"zip",
|
||||
"deflate",
|
||||
"inflate"
|
||||
],
|
||||
"devDependencies": {
|
||||
"qunit": "^0.7.6",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-cli": "~0.1.9",
|
||||
"grunt-saucelabs": "~8.6.1",
|
||||
"grunt-contrib-connect": "~0.11.2",
|
||||
"jshint": "~2.8.0",
|
||||
"browserify": "~11.2.0",
|
||||
"grunt-browserify": "~4.0.1",
|
||||
"grunt-contrib-jshint": "~0.11.3",
|
||||
"grunt-contrib-uglify": "~0.9.2",
|
||||
"jszip-utils": "~0.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"pako": "~1.0.0"
|
||||
},
|
||||
"license": "(MIT OR GPL-3.0)"
|
||||
}
|
||||
247
vendors/jszip/vendor/FileSaver.js
vendored
Normal file
247
vendors/jszip/vendor/FileSaver.js
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
/*! FileSaver.js
|
||||
* A saveAs() FileSaver implementation.
|
||||
* 2014-01-24
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* License: X11/MIT
|
||||
* See LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self */
|
||||
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||
|
||||
var saveAs = saveAs
|
||||
// IE 10+ (native saveAs)
|
||||
|| (typeof navigator !== "undefined" &&
|
||||
navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
|
||||
// Everyone else
|
||||
|| (function(view) {
|
||||
"use strict";
|
||||
// IE <10 is explicitly unsupported
|
||||
if (typeof navigator !== "undefined" &&
|
||||
/MSIE [1-9]\./.test(navigator.userAgent)) {
|
||||
return;
|
||||
}
|
||||
var
|
||||
doc = view.document
|
||||
// only get URL when necessary in case BlobBuilder.js hasn't overridden it yet
|
||||
, get_URL = function() {
|
||||
return view.URL || view.webkitURL || view;
|
||||
}
|
||||
, URL = view.URL || view.webkitURL || view
|
||||
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
|
||||
, can_use_save_link = !view.externalHost && "download" in save_link
|
||||
, click = function(node) {
|
||||
var event = doc.createEvent("MouseEvents");
|
||||
event.initMouseEvent(
|
||||
"click", true, false, view, 0, 0, 0, 0, 0
|
||||
, false, false, false, false, 0, null
|
||||
);
|
||||
node.dispatchEvent(event);
|
||||
}
|
||||
, webkit_req_fs = view.webkitRequestFileSystem
|
||||
, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
|
||||
, throw_outside = function(ex) {
|
||||
(view.setImmediate || view.setTimeout)(function() {
|
||||
throw ex;
|
||||
}, 0);
|
||||
}
|
||||
, force_saveable_type = "application/octet-stream"
|
||||
, fs_min_size = 0
|
||||
, deletion_queue = []
|
||||
, process_deletion_queue = function() {
|
||||
var i = deletion_queue.length;
|
||||
while (i--) {
|
||||
var file = deletion_queue[i];
|
||||
if (typeof file === "string") { // file is an object URL
|
||||
URL.revokeObjectURL(file);
|
||||
} else { // file is a File
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
deletion_queue.length = 0; // clear queue
|
||||
}
|
||||
, dispatch = function(filesaver, event_types, event) {
|
||||
event_types = [].concat(event_types);
|
||||
var i = event_types.length;
|
||||
while (i--) {
|
||||
var listener = filesaver["on" + event_types[i]];
|
||||
if (typeof listener === "function") {
|
||||
try {
|
||||
listener.call(filesaver, event || filesaver);
|
||||
} catch (ex) {
|
||||
throw_outside(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
, FileSaver = function(blob, name) {
|
||||
// First try a.download, then web filesystem, then object URLs
|
||||
var
|
||||
filesaver = this
|
||||
, type = blob.type
|
||||
, blob_changed = false
|
||||
, object_url
|
||||
, target_view
|
||||
, get_object_url = function() {
|
||||
var object_url = get_URL().createObjectURL(blob);
|
||||
deletion_queue.push(object_url);
|
||||
return object_url;
|
||||
}
|
||||
, dispatch_all = function() {
|
||||
dispatch(filesaver, "writestart progress write writeend".split(" "));
|
||||
}
|
||||
// on any filesys errors revert to saving with object URLs
|
||||
, fs_error = function() {
|
||||
// don't create more object URLs than needed
|
||||
if (blob_changed || !object_url) {
|
||||
object_url = get_object_url(blob);
|
||||
}
|
||||
if (target_view) {
|
||||
target_view.location.href = object_url;
|
||||
} else {
|
||||
window.open(object_url, "_blank");
|
||||
}
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
}
|
||||
, abortable = function(func) {
|
||||
return function() {
|
||||
if (filesaver.readyState !== filesaver.DONE) {
|
||||
return func.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
, create_if_not_found = {create: true, exclusive: false}
|
||||
, slice
|
||||
;
|
||||
filesaver.readyState = filesaver.INIT;
|
||||
if (!name) {
|
||||
name = "download";
|
||||
}
|
||||
if (can_use_save_link) {
|
||||
object_url = get_object_url(blob);
|
||||
// FF for Android has a nasty garbage collection mechanism
|
||||
// that turns all objects that are not pure javascript into 'deadObject'
|
||||
// this means `doc` and `save_link` are unusable and need to be recreated
|
||||
// `view` is usable though:
|
||||
doc = view.document;
|
||||
save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a");
|
||||
save_link.href = object_url;
|
||||
save_link.download = name;
|
||||
var event = doc.createEvent("MouseEvents");
|
||||
event.initMouseEvent(
|
||||
"click", true, false, view, 0, 0, 0, 0, 0
|
||||
, false, false, false, false, 0, null
|
||||
);
|
||||
save_link.dispatchEvent(event);
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
return;
|
||||
}
|
||||
// Object and web filesystem URLs have a problem saving in Google Chrome when
|
||||
// viewed in a tab, so I force save with application/octet-stream
|
||||
// http://code.google.com/p/chromium/issues/detail?id=91158
|
||||
if (view.chrome && type && type !== force_saveable_type) {
|
||||
slice = blob.slice || blob.webkitSlice;
|
||||
blob = slice.call(blob, 0, blob.size, force_saveable_type);
|
||||
blob_changed = true;
|
||||
}
|
||||
// Since I can't be sure that the guessed media type will trigger a download
|
||||
// in WebKit, I append .download to the filename.
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=65440
|
||||
if (webkit_req_fs && name !== "download") {
|
||||
name += ".download";
|
||||
}
|
||||
if (type === force_saveable_type || webkit_req_fs) {
|
||||
target_view = view;
|
||||
}
|
||||
if (!req_fs) {
|
||||
fs_error();
|
||||
return;
|
||||
}
|
||||
fs_min_size += blob.size;
|
||||
req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
|
||||
fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
|
||||
var save = function() {
|
||||
dir.getFile(name, create_if_not_found, abortable(function(file) {
|
||||
file.createWriter(abortable(function(writer) {
|
||||
writer.onwriteend = function(event) {
|
||||
target_view.location.href = file.toURL();
|
||||
deletion_queue.push(file);
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch(filesaver, "writeend", event);
|
||||
};
|
||||
writer.onerror = function() {
|
||||
var error = writer.error;
|
||||
if (error.code !== error.ABORT_ERR) {
|
||||
fs_error();
|
||||
}
|
||||
};
|
||||
"writestart progress write abort".split(" ").forEach(function(event) {
|
||||
writer["on" + event] = filesaver["on" + event];
|
||||
});
|
||||
writer.write(blob);
|
||||
filesaver.abort = function() {
|
||||
writer.abort();
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
};
|
||||
filesaver.readyState = filesaver.WRITING;
|
||||
}), fs_error);
|
||||
}), fs_error);
|
||||
};
|
||||
dir.getFile(name, {create: false}, abortable(function(file) {
|
||||
// delete file if it already exists
|
||||
file.remove();
|
||||
save();
|
||||
}), abortable(function(ex) {
|
||||
if (ex.code === ex.NOT_FOUND_ERR) {
|
||||
save();
|
||||
} else {
|
||||
fs_error();
|
||||
}
|
||||
}));
|
||||
}), fs_error);
|
||||
}), fs_error);
|
||||
}
|
||||
, FS_proto = FileSaver.prototype
|
||||
, saveAs = function(blob, name) {
|
||||
return new FileSaver(blob, name);
|
||||
}
|
||||
;
|
||||
FS_proto.abort = function() {
|
||||
var filesaver = this;
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch(filesaver, "abort");
|
||||
};
|
||||
FS_proto.readyState = FS_proto.INIT = 0;
|
||||
FS_proto.WRITING = 1;
|
||||
FS_proto.DONE = 2;
|
||||
|
||||
FS_proto.error =
|
||||
FS_proto.onwritestart =
|
||||
FS_proto.onprogress =
|
||||
FS_proto.onwrite =
|
||||
FS_proto.onabort =
|
||||
FS_proto.onerror =
|
||||
FS_proto.onwriteend =
|
||||
null;
|
||||
|
||||
view.addEventListener("unload", process_deletion_queue, false);
|
||||
saveAs.unload = function() {
|
||||
process_deletion_queue();
|
||||
view.removeEventListener("unload", process_deletion_queue, false);
|
||||
};
|
||||
return saveAs;
|
||||
}(
|
||||
typeof self !== "undefined" && self
|
||||
|| typeof window !== "undefined" && window
|
||||
|| this.content
|
||||
));
|
||||
// `self` is undefined in Firefox for Android content script context
|
||||
// while `this` is nsIContentFrameMessageManager
|
||||
// with an attribute `content` that corresponds to the window
|
||||
|
||||
if (typeof module !== "undefined") module.exports = saveAs;
|
||||
Reference in New Issue
Block a user