Implement breaking changes for JSZip v3. #253

Merged
merged 19 commits into from Mar 22, 2016

Projects

None yet

1 participant

@dduponchel
Collaborator

This pull request implements most of the changes discussed in #224:

  • remove the defensive copy of zip.filter
  • remove deprecated API
  • type in generateAsync is now mandatory
  • change the createFolders default value from false to true
  • remove JSZip.compressions
  • add base64 support in async()
  • add a forEach method, use it in generate (to restrict content using JSZip.root)

It also add the related changes:

  • split the test/test.js file into test/asserts/*.js files
  • improve nodejs support
  • use UTC instead of the local timezone for dates

Regarding the nodejs support, I restricted the type to nodebuffer:
An object stream streaming blob/arraybuffer/uint8array/string is strange and
I don't know if it would be useful. I prefer disabling this feature and
wait for a real use case over this feature, finding out that that wasn't
a good idea and deprecate an awkward method.

This pull request is quite big, sorry. Each commit should be self-sufficient
and it may be easier to read them individually.

dduponchel added some commits Jan 10, 2015
@dduponchel dduponchel [breaking change] zip.filter : remove the defensive copy
The filter method (reused by the file/folder method) created defensive
copies of every single item for each call. The idea was to prevent
people from updating the options or the data outside our API, but :

* that pointless because zip.files contains everything
* people already bypass that (see #20)
* this have a performance hit with many entries
* this behavior was never documented
c7df4d0
@dduponchel dduponchel [breaking change] Remove deprecated API
This removes :

- options.base64 in generate()
- options.{base64,binary,dir,date} on ZipObject
- JSZip.utils
- JSZip#{crc32,utf8encode,utf8decode}

Lone survivor : JSZip.base64, because I don't know yet how to decode it
in the tests.
1ebf4c2
@dduponchel dduponchel [breaking change] Change the createFolders default value.
Change the createFolders default value from false to true. People are
used to file managers creating folders, the false value is (only ?)
needed when we don't generate a regular zip file (xlsx file for
example).
4950449
@dduponchel dduponchel [breaking change] Mandatory type in generate().
Calling `generate()` won't work anymore, the developer needs to specify an
output type.

"base64" was a nice default when the main way to provide a zip to a user
was to do:

    window.location = "data:application/zip;base64," + zip.generate({type:"base64"});

We now have better alternatives (saveAs, blob url, etc) that aren't
limited by the number of characters you can put in an url.
972bef0
@dduponchel dduponchel Rework unit tests.
This commit does several things on the unit tests:

- upgrade QUnit 1.11 -> 1.20
- use qunit-cli instead of qunit (this let us use a recent version of QUnit)
- split the test/test.js file: we now have separated files in the
  test/asserts/ folder
- add the test files in the jshint list
- fix the indentation (3 spaces -> 4 spaces)
4a30823
@dduponchel dduponchel Avoid concurrent workers on the same node stream.
If the ZipObject contains a nodejs stream or a worker, we will only be
able to read it once. This commit let the StreamHelper to "lock" a
worker chain to prevent further use.
135be38
@dduponchel dduponchel Add support.nodestream.
It will be easier to predict if the nodejs stream methods will fail.
Also update the error message to be less confusing server side ("not
supported by this platform" instead of "not supported by this browser").
fcbc5c4
@dduponchel dduponchel Node stream methods: use buffers by default.
While technically you can have a stream with an objectMode == true and
stream ArrayBuffers or unicode strings, asking for a type here is
overkill and error prone. Buffers are the best default value.
9d9c34e
@dduponchel dduponchel Node streams: only support nodebuffer for now.
An object stream streaming blob/arraybuffer/uint8array/string is strange and
I don't know if it would be useful.

I prefer disabling this feature and wait for a real use case over
enabling this feature, finding out that that wasn't a good idea and
deprecate an awkward method.
32c500a
@dduponchel dduponchel Add more unit tests.
We were lacking nodejs stream unit tests.
311b4da
@dduponchel dduponchel referenced this pull request Feb 10, 2016
Closed

Async support #121

@dduponchel
Collaborator

The build fails in the generation of the dist/ files with node 0.10 (triggered by the gzip reporter of grunt-contrib-uglify). I'll look into the travis configuration to start the job test-browser only once (no need to build the dist/ files in every node version).
If that's not easy to do, removing the uglify reporter also fix the issue.

@dduponchel
Collaborator

The build pass now.

dduponchel added some commits Jan 10, 2016
@dduponchel dduponchel Upgrade dependencies.
On grunt-contrib-uglify, the `preserveComments: 'some'` option has some
issues. We can remove all comments but re-add the banner.
459afb0
@dduponchel dduponchel [breaking change] Remove JSZip.compressions.
This object now requires internal objects to work, exposing it is not
useful anymore.
79e6fe7
@dduponchel dduponchel Dates: use UTC instead of the local timezone.
To get reproducible zip files, we need to use UTC instead of the local
timezone. That means my pc (Europe/Paris) and the test server (UTC)
should generate the same zip file.
9c7e009
@dduponchel dduponchel [breaking change] Remove JSZip.base64.
The API was awkward (the `decode` function returned a binary string) and
base64 input/output provided by other methods should be enough.
7540792
@dduponchel dduponchel Add base64 support in async().
It already worked, but now it is documented and tested.

Before that, people used `JSZip.base64` to encode binary contents.
2d55525
@dduponchel dduponchel Add a forEach method, use it in generate.
The new forEach method is aware of the root folder level: it will only
show entries that start with `zip.root`.

When used in generate methods, it means the generated zip file will be
restricted to the current subfolder, fix #203.
d4da68f
@dduponchel dduponchel Use the createFolders default value with folder().
This is the compagnion of 4950449, "[breaking change] Change the
createFolders default value". The previous commit didn't use the
default value for folders, this is now the case.
31c16c9
@dduponchel dduponchel Foreach: add a missing test file.
I forgot a file in 5fcfa93, here it is.
ca7ee67
@dduponchel dduponchel Remove the gzip reporter.
It uses a dependency which requires node >=0.12. On node 0.10 (used in the
travis builds) this reporter break the buid with a

    Object #<Object> has no method 'gzipSync'

This reporter needs the `--verbose` flag on grunt to display its
result, this commit won't change anything to the default output.
431a1ce
@dduponchel dduponchel merged commit 77fa193 into Stuk:jszip_v3 Mar 22, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dduponchel dduponchel deleted the dduponchel:breaking_changes branch Mar 22, 2016
@dduponchel dduponchel referenced this pull request Apr 12, 2016
Merged

Release 3.0.0 #278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment