Skip to content

Commit ee02067

Browse files
committed
Update build and changes for 3.10.0
1 parent 8893668 commit ee02067

File tree

4 files changed

+204
-18
lines changed

4 files changed

+204
-18
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ layout: default
44
section: main
55
---
66

7+
### v3.10.0 2022-05-20
8+
9+
- Change setimmediate dependency to more efficient one. Fixes https://github.com/Stuk/jszip/issues/617 (see [#829](https://github.com/Stuk/jszip/pull/829)
10+
- Update types of `currentFile` metadata to include `null` (see [#826](https://github.com/Stuk/jszip/pull/826)
11+
712
### v3.9.1 2022-04-06
813

914
- Fix recursive definition of `InputFileFormat` introduced in 3.9.0.

dist/jszip.js

Lines changed: 194 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*!
22
3-
JSZip v3.9.1 - A JavaScript class for generating and reading zip files
3+
JSZip v3.10.0 - A JavaScript class for generating and reading zip files
44
<http://stuartk.com/jszip>
55
66
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
7-
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
7+
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
88
99
JSZip uses the library pako released under the MIT license :
10-
https://github.com/nodeca/pako/blob/master/LICENSE
10+
https://github.com/nodeca/pako/blob/main/LICENSE
1111
*/
1212

1313
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSZip = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
@@ -1059,7 +1059,7 @@ JSZip.defaults = require('./defaults');
10591059

10601060
// TODO find a better way to handle this version,
10611061
// a require('package.json').version doesn't work with webpack, see #327
1062-
JSZip.version = "3.9.1";
1062+
JSZip.version = "3.10.0";
10631063

10641064
JSZip.loadAsync = function (content, options) {
10651065
return new JSZip().loadAsync(content, options);
@@ -3045,8 +3045,8 @@ exports.Utf8EncodeWorker = Utf8EncodeWorker;
30453045
var support = require('./support');
30463046
var base64 = require('./base64');
30473047
var nodejsUtils = require('./nodejsUtils');
3048-
var setImmediate = require('set-immediate-shim');
30493048
var external = require("./external");
3049+
require('setimmediate');
30503050

30513051

30523052
/**
@@ -3542,7 +3542,7 @@ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinarySt
35423542
});
35433543
};
35443544

3545-
},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,"set-immediate-shim":54}],33:[function(require,module,exports){
3545+
},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,"setimmediate":54}],33:[function(require,module,exports){
35463546
'use strict';
35473547
var readerFor = require('./reader/readerFor');
35483548
var utils = require('./utils');
@@ -11390,13 +11390,194 @@ function ZStream() {
1139011390
module.exports = ZStream;
1139111391

1139211392
},{}],54:[function(require,module,exports){
11393-
'use strict';
11394-
module.exports = typeof setImmediate === 'function' ? setImmediate :
11395-
function setImmediate() {
11396-
var args = [].slice.apply(arguments);
11397-
args.splice(1, 0, 0);
11398-
setTimeout.apply(null, args);
11399-
};
11393+
(function (global){
11394+
(function (global, undefined) {
11395+
"use strict";
11396+
11397+
if (global.setImmediate) {
11398+
return;
11399+
}
11400+
11401+
var nextHandle = 1; // Spec says greater than zero
11402+
var tasksByHandle = {};
11403+
var currentlyRunningATask = false;
11404+
var doc = global.document;
11405+
var registerImmediate;
11406+
11407+
function setImmediate(callback) {
11408+
// Callback can either be a function or a string
11409+
if (typeof callback !== "function") {
11410+
callback = new Function("" + callback);
11411+
}
11412+
// Copy function arguments
11413+
var args = new Array(arguments.length - 1);
11414+
for (var i = 0; i < args.length; i++) {
11415+
args[i] = arguments[i + 1];
11416+
}
11417+
// Store and register the task
11418+
var task = { callback: callback, args: args };
11419+
tasksByHandle[nextHandle] = task;
11420+
registerImmediate(nextHandle);
11421+
return nextHandle++;
11422+
}
11423+
11424+
function clearImmediate(handle) {
11425+
delete tasksByHandle[handle];
11426+
}
11427+
11428+
function run(task) {
11429+
var callback = task.callback;
11430+
var args = task.args;
11431+
switch (args.length) {
11432+
case 0:
11433+
callback();
11434+
break;
11435+
case 1:
11436+
callback(args[0]);
11437+
break;
11438+
case 2:
11439+
callback(args[0], args[1]);
11440+
break;
11441+
case 3:
11442+
callback(args[0], args[1], args[2]);
11443+
break;
11444+
default:
11445+
callback.apply(undefined, args);
11446+
break;
11447+
}
11448+
}
1140011449

11450+
function runIfPresent(handle) {
11451+
// From the spec: "Wait until any invocations of this algorithm started before this one have completed."
11452+
// So if we're currently running a task, we'll need to delay this invocation.
11453+
if (currentlyRunningATask) {
11454+
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
11455+
// "too much recursion" error.
11456+
setTimeout(runIfPresent, 0, handle);
11457+
} else {
11458+
var task = tasksByHandle[handle];
11459+
if (task) {
11460+
currentlyRunningATask = true;
11461+
try {
11462+
run(task);
11463+
} finally {
11464+
clearImmediate(handle);
11465+
currentlyRunningATask = false;
11466+
}
11467+
}
11468+
}
11469+
}
11470+
11471+
function installNextTickImplementation() {
11472+
registerImmediate = function(handle) {
11473+
process.nextTick(function () { runIfPresent(handle); });
11474+
};
11475+
}
11476+
11477+
function canUsePostMessage() {
11478+
// The test against `importScripts` prevents this implementation from being installed inside a web worker,
11479+
// where `global.postMessage` means something completely different and can't be used for this purpose.
11480+
if (global.postMessage && !global.importScripts) {
11481+
var postMessageIsAsynchronous = true;
11482+
var oldOnMessage = global.onmessage;
11483+
global.onmessage = function() {
11484+
postMessageIsAsynchronous = false;
11485+
};
11486+
global.postMessage("", "*");
11487+
global.onmessage = oldOnMessage;
11488+
return postMessageIsAsynchronous;
11489+
}
11490+
}
11491+
11492+
function installPostMessageImplementation() {
11493+
// Installs an event handler on `global` for the `message` event: see
11494+
// * https://developer.mozilla.org/en/DOM/window.postMessage
11495+
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
11496+
11497+
var messagePrefix = "setImmediate$" + Math.random() + "$";
11498+
var onGlobalMessage = function(event) {
11499+
if (event.source === global &&
11500+
typeof event.data === "string" &&
11501+
event.data.indexOf(messagePrefix) === 0) {
11502+
runIfPresent(+event.data.slice(messagePrefix.length));
11503+
}
11504+
};
11505+
11506+
if (global.addEventListener) {
11507+
global.addEventListener("message", onGlobalMessage, false);
11508+
} else {
11509+
global.attachEvent("onmessage", onGlobalMessage);
11510+
}
11511+
11512+
registerImmediate = function(handle) {
11513+
global.postMessage(messagePrefix + handle, "*");
11514+
};
11515+
}
11516+
11517+
function installMessageChannelImplementation() {
11518+
var channel = new MessageChannel();
11519+
channel.port1.onmessage = function(event) {
11520+
var handle = event.data;
11521+
runIfPresent(handle);
11522+
};
11523+
11524+
registerImmediate = function(handle) {
11525+
channel.port2.postMessage(handle);
11526+
};
11527+
}
11528+
11529+
function installReadyStateChangeImplementation() {
11530+
var html = doc.documentElement;
11531+
registerImmediate = function(handle) {
11532+
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
11533+
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
11534+
var script = doc.createElement("script");
11535+
script.onreadystatechange = function () {
11536+
runIfPresent(handle);
11537+
script.onreadystatechange = null;
11538+
html.removeChild(script);
11539+
script = null;
11540+
};
11541+
html.appendChild(script);
11542+
};
11543+
}
11544+
11545+
function installSetTimeoutImplementation() {
11546+
registerImmediate = function(handle) {
11547+
setTimeout(runIfPresent, 0, handle);
11548+
};
11549+
}
11550+
11551+
// If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
11552+
var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
11553+
attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
11554+
11555+
// Don't get fooled by e.g. browserify environments.
11556+
if ({}.toString.call(global.process) === "[object process]") {
11557+
// For Node.js before 0.9
11558+
installNextTickImplementation();
11559+
11560+
} else if (canUsePostMessage()) {
11561+
// For non-IE10 modern browsers
11562+
installPostMessageImplementation();
11563+
11564+
} else if (global.MessageChannel) {
11565+
// For web workers, where supported
11566+
installMessageChannelImplementation();
11567+
11568+
} else if (doc && "onreadystatechange" in doc.createElement("script")) {
11569+
// For IE 6–8
11570+
installReadyStateChangeImplementation();
11571+
11572+
} else {
11573+
// For older browsers
11574+
installSetTimeoutImplementation();
11575+
}
11576+
11577+
attachTo.setImmediate = setImmediate;
11578+
attachTo.clearImmediate = clearImmediate;
11579+
}(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
11580+
11581+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1140111582
},{}]},{},[10])(10)
1140211583
});

dist/jszip.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ JSZip.defaults = require('./defaults');
4545

4646
// TODO find a better way to handle this version,
4747
// a require('package.json').version doesn't work with webpack, see #327
48-
JSZip.version = "3.9.1";
48+
JSZip.version = "3.10.0";
4949

5050
JSZip.loadAsync = function (content, options) {
5151
return new JSZip().loadAsync(content, options);

0 commit comments

Comments
 (0)