@paydock/client-sdk 1.140.1 → 1.141.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/bundles/index.cjs +2164 -97
- package/bundles/index.cjs.d.ts +24 -9
- package/bundles/index.mjs +2164 -97
- package/bundles/index.mjs.d.ts +24 -9
- package/bundles/types/checkout-button/checkout-button.d.ts.map +1 -1
- package/bundles/types/checkout-button/zipmoney/zipmoney-checkout-button.d.ts +24 -10
- package/bundles/types/checkout-button/zipmoney/zipmoney-checkout-button.d.ts.map +1 -1
- package/bundles/types/checkout-button/zipmoney/zipmoney-contextual.runner.d.ts.map +1 -1
- package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts +1 -0
- package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts +1 -0
- package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts +1 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
- package/bundles/widget.umd.js +2164 -97
- package/bundles/widget.umd.js.d.ts +24 -9
- package/bundles/widget.umd.js.min.d.ts +24 -9
- package/bundles/widget.umd.min.js +1 -1
- package/docs/api-checkout-button.md +22 -0
- package/package.json +13 -3
package/bundles/widget.umd.js
CHANGED
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
}
|
|
322
322
|
function _superPropGet(t, o, e, r) {
|
|
323
323
|
var p = _get(_getPrototypeOf(t.prototype ), o, e);
|
|
324
|
-
return "function" == typeof p ? function (t) {
|
|
324
|
+
return 2 & r && "function" == typeof p ? function (t) {
|
|
325
325
|
return p.apply(e, t);
|
|
326
326
|
} : p;
|
|
327
327
|
}
|
|
@@ -1198,7 +1198,7 @@
|
|
|
1198
1198
|
version: 'x-sdk-version',
|
|
1199
1199
|
type: 'x-sdk-type'
|
|
1200
1200
|
});
|
|
1201
|
-
SDK._version = 'v1.
|
|
1201
|
+
SDK._version = 'v1.141.0-beta';
|
|
1202
1202
|
|
|
1203
1203
|
function isFunction(value) {
|
|
1204
1204
|
return typeof value === 'function';
|
|
@@ -6585,7 +6585,7 @@
|
|
|
6585
6585
|
}, {
|
|
6586
6586
|
key: "setEnv",
|
|
6587
6587
|
value: function setEnv(env, alias) {
|
|
6588
|
-
_superPropGet(PopupRunner, "setEnv", this)([env, alias]);
|
|
6588
|
+
_superPropGet(PopupRunner, "setEnv", this, 3)([env, alias]);
|
|
6589
6589
|
this.dispatcher.setEnv(env, alias);
|
|
6590
6590
|
this.popup.setEnv(env);
|
|
6591
6591
|
}
|
|
@@ -6644,7 +6644,7 @@
|
|
|
6644
6644
|
return _createClass(ZipmoneyRunner, [{
|
|
6645
6645
|
key: "setEnv",
|
|
6646
6646
|
value: function setEnv(env, alias) {
|
|
6647
|
-
_superPropGet(ZipmoneyRunner, "setEnv", this)([env, alias]);
|
|
6647
|
+
_superPropGet(ZipmoneyRunner, "setEnv", this, 3)([env, alias]);
|
|
6648
6648
|
this.apiEnv.setEnv(env, alias);
|
|
6649
6649
|
}
|
|
6650
6650
|
}]);
|
|
@@ -6673,6 +6673,9 @@
|
|
|
6673
6673
|
return _createClass(ZipmoneyContextualRunner, [{
|
|
6674
6674
|
key: "run",
|
|
6675
6675
|
value: function run() {
|
|
6676
|
+
if (this.isRunning()) {
|
|
6677
|
+
return;
|
|
6678
|
+
}
|
|
6676
6679
|
this.runs = true;
|
|
6677
6680
|
this.background.initLoader();
|
|
6678
6681
|
this.checkoutTab = window.open(this.getLoadingUrl(), '_blank');
|
|
@@ -6709,7 +6712,7 @@
|
|
|
6709
6712
|
}, {
|
|
6710
6713
|
key: "stop",
|
|
6711
6714
|
value: function stop() {
|
|
6712
|
-
_superPropGet(ZipmoneyContextualRunner, "stop", this)([]);
|
|
6715
|
+
_superPropGet(ZipmoneyContextualRunner, "stop", this, 3)([]);
|
|
6713
6716
|
this.runs = false;
|
|
6714
6717
|
var element = document.querySelector('.zipmoney-overlay');
|
|
6715
6718
|
if (element) {
|
|
@@ -6938,7 +6941,7 @@
|
|
|
6938
6941
|
}, {
|
|
6939
6942
|
key: "setEnv",
|
|
6940
6943
|
value: function setEnv(env, alias) {
|
|
6941
|
-
_superPropGet(ZipmoneyRedirectRunner, "setEnv", this)([env, alias]);
|
|
6944
|
+
_superPropGet(ZipmoneyRedirectRunner, "setEnv", this, 3)([env, alias]);
|
|
6942
6945
|
this.storageDispatcher.setEnv(env, alias);
|
|
6943
6946
|
}
|
|
6944
6947
|
}]);
|
|
@@ -6998,7 +7001,7 @@
|
|
|
6998
7001
|
}, {
|
|
6999
7002
|
key: "onCheckout",
|
|
7000
7003
|
value: function onCheckout(event, cb) {
|
|
7001
|
-
_superPropGet(AfterpayRunner, "onCheckout", this)([event, function (checkout, data) {
|
|
7004
|
+
_superPropGet(AfterpayRunner, "onCheckout", this, 3)([event, function (checkout, data) {
|
|
7002
7005
|
if (!(data === null || data === void 0 ? void 0 : data.status)) return cb(checkout);
|
|
7003
7006
|
var status = data.status,
|
|
7004
7007
|
newData = __rest(data, ["status"]);
|
|
@@ -7243,29 +7246,67 @@
|
|
|
7243
7246
|
value: function initCheckout(container) {
|
|
7244
7247
|
var _this = this;
|
|
7245
7248
|
container.on('click', function (event) {
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7249
|
+
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
|
|
7250
|
+
var _this2 = this;
|
|
7251
|
+
var results, externalCheckout;
|
|
7252
|
+
return _regenerator().w(function (_context) {
|
|
7253
|
+
while (1) switch (_context.n) {
|
|
7254
|
+
case 0:
|
|
7255
|
+
if (!isContextualRunner(this.runner)) {
|
|
7256
|
+
_context.n = 2;
|
|
7257
|
+
break;
|
|
7258
|
+
}
|
|
7259
|
+
if (!this.runner.isRunning()) {
|
|
7260
|
+
_context.n = 1;
|
|
7261
|
+
break;
|
|
7262
|
+
}
|
|
7263
|
+
return _context.a(2);
|
|
7264
|
+
case 1:
|
|
7265
|
+
this.runner.run();
|
|
7266
|
+
case 2:
|
|
7267
|
+
if (!(isRedirectRunner(this.runner) && !this.runner.getRedirectUrl())) {
|
|
7268
|
+
_context.n = 3;
|
|
7269
|
+
break;
|
|
7270
|
+
}
|
|
7271
|
+
throw Error("".concat(CHECKOUT_BTN_LOG_PREFIX, " The merchant redirect URL should is required in the '").concat(this.mode, "' mode."));
|
|
7272
|
+
case 3:
|
|
7273
|
+
_context.n = 4;
|
|
7274
|
+
return this.eventEmitter.emitWithResult(CHECKOUT_BUTTON_EVENT.CLICK);
|
|
7275
|
+
case 4:
|
|
7276
|
+
results = _context.v;
|
|
7277
|
+
if (!results.some(function (result) {
|
|
7278
|
+
return result === false;
|
|
7279
|
+
})) {
|
|
7280
|
+
_context.n = 5;
|
|
7281
|
+
break;
|
|
7282
|
+
}
|
|
7283
|
+
if (isContextualRunner(this.runner) && this.runner.isRunning()) {
|
|
7284
|
+
this.close();
|
|
7285
|
+
}
|
|
7286
|
+
return _context.a(2);
|
|
7287
|
+
case 5:
|
|
7288
|
+
externalCheckout = new Builder$1(this.gatewayId, this.runner.getSuccessRedirectUri(), this.runner.getErrorRedirectUri());
|
|
7289
|
+
externalCheckout.setMeta(this.meta);
|
|
7290
|
+
externalCheckout.setEnv(this.env);
|
|
7291
|
+
externalCheckout.send(this.accessToken, function (checkout) {
|
|
7292
|
+
var buttonEvent = isContextualRunner(_this2.runner) ? CHECKOUT_BUTTON_EVENT.POPUP_REDIRECT : CHECKOUT_BUTTON_EVENT.REDIRECT;
|
|
7293
|
+
_this2.eventEmitter.emit(buttonEvent);
|
|
7294
|
+
_this2.runner.next(checkout, _this2.buildAdditionalParams());
|
|
7295
|
+
}, function (error, code) {
|
|
7296
|
+
console.error("".concat(CHECKOUT_BTN_LOG_PREFIX, " ").concat(error));
|
|
7297
|
+
_this2.eventEmitter.emit(CHECKOUT_BUTTON_EVENT.ERROR, {
|
|
7298
|
+
error: error,
|
|
7299
|
+
code: code
|
|
7300
|
+
});
|
|
7301
|
+
_this2.runner.error(error, code, function (close) {
|
|
7302
|
+
if (close) _this2.close();
|
|
7303
|
+
});
|
|
7304
|
+
});
|
|
7305
|
+
case 6:
|
|
7306
|
+
return _context.a(2);
|
|
7307
|
+
}
|
|
7308
|
+
}, _callee, this);
|
|
7309
|
+
}));
|
|
7269
7310
|
});
|
|
7270
7311
|
}
|
|
7271
7312
|
/**
|
|
@@ -7503,7 +7544,7 @@
|
|
|
7503
7544
|
}, {
|
|
7504
7545
|
key: "buildAdditionalParams",
|
|
7505
7546
|
value: function buildAdditionalParams() {
|
|
7506
|
-
var params = _superPropGet(AfterpayCheckoutButton, "buildAdditionalParams", this)([]);
|
|
7547
|
+
var params = _superPropGet(AfterpayCheckoutButton, "buildAdditionalParams", this, 3)([]);
|
|
7507
7548
|
if (this.showETP) {
|
|
7508
7549
|
params.show_etp = true;
|
|
7509
7550
|
}
|
|
@@ -7864,7 +7905,7 @@
|
|
|
7864
7905
|
}, {
|
|
7865
7906
|
key: "setEnv",
|
|
7866
7907
|
value: function setEnv(env) {
|
|
7867
|
-
_superPropGet(AfterPayWalletService, "setEnv", this)([env]);
|
|
7908
|
+
_superPropGet(AfterPayWalletService, "setEnv", this, 3)([env]);
|
|
7868
7909
|
if (this.isRedirectMode) {
|
|
7869
7910
|
this.storageDispatcher.setEnv(env);
|
|
7870
7911
|
}
|
|
@@ -8053,7 +8094,7 @@
|
|
|
8053
8094
|
}]);
|
|
8054
8095
|
}(WalletService);
|
|
8055
8096
|
|
|
8056
|
-
/*! @license DOMPurify 3.3.
|
|
8097
|
+
/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */
|
|
8057
8098
|
|
|
8058
8099
|
var purify_cjs;
|
|
8059
8100
|
var hasRequiredPurify_cjs;
|
|
@@ -8358,7 +8399,7 @@
|
|
|
8358
8399
|
function createDOMPurify() {
|
|
8359
8400
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
8360
8401
|
const DOMPurify = root => createDOMPurify(root);
|
|
8361
|
-
DOMPurify.version = '3.3.
|
|
8402
|
+
DOMPurify.version = '3.3.3';
|
|
8362
8403
|
DOMPurify.removed = [];
|
|
8363
8404
|
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
8364
8405
|
// Not running in a browser, provide a factory function
|
|
@@ -8653,7 +8694,7 @@
|
|
|
8653
8694
|
/* Parse profile info */
|
|
8654
8695
|
if (USE_PROFILES) {
|
|
8655
8696
|
ALLOWED_TAGS = addToSet({}, text);
|
|
8656
|
-
ALLOWED_ATTR =
|
|
8697
|
+
ALLOWED_ATTR = create(null);
|
|
8657
8698
|
if (USE_PROFILES.html === true) {
|
|
8658
8699
|
addToSet(ALLOWED_TAGS, html$1);
|
|
8659
8700
|
addToSet(ALLOWED_ATTR, html);
|
|
@@ -8674,6 +8715,13 @@
|
|
|
8674
8715
|
addToSet(ALLOWED_ATTR, xml);
|
|
8675
8716
|
}
|
|
8676
8717
|
}
|
|
8718
|
+
/* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */
|
|
8719
|
+
if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) {
|
|
8720
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
8721
|
+
}
|
|
8722
|
+
if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) {
|
|
8723
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
8724
|
+
}
|
|
8677
8725
|
/* Merge configuration parameters */
|
|
8678
8726
|
if (cfg.ADD_TAGS) {
|
|
8679
8727
|
if (typeof cfg.ADD_TAGS === 'function') {
|
|
@@ -8704,6 +8752,12 @@
|
|
|
8704
8752
|
}
|
|
8705
8753
|
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
8706
8754
|
}
|
|
8755
|
+
if (cfg.ADD_FORBID_CONTENTS) {
|
|
8756
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
8757
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
8758
|
+
}
|
|
8759
|
+
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
|
|
8760
|
+
}
|
|
8707
8761
|
/* Add #text in case KEEP_CONTENT is set to true */
|
|
8708
8762
|
if (KEEP_CONTENT) {
|
|
8709
8763
|
ALLOWED_TAGS['#text'] = true;
|
|
@@ -9065,6 +9119,10 @@
|
|
|
9065
9119
|
*/
|
|
9066
9120
|
// eslint-disable-next-line complexity
|
|
9067
9121
|
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
9122
|
+
/* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
|
|
9123
|
+
if (FORBID_ATTR[lcName]) {
|
|
9124
|
+
return false;
|
|
9125
|
+
}
|
|
9068
9126
|
/* Make sure attribute cannot clobber */
|
|
9069
9127
|
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
9070
9128
|
return false;
|
|
@@ -9157,7 +9215,7 @@
|
|
|
9157
9215
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
9158
9216
|
}
|
|
9159
9217
|
/* Work around a security issue with comments inside attributes */
|
|
9160
|
-
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) {
|
|
9218
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
9161
9219
|
_removeAttribute(name, currentNode);
|
|
9162
9220
|
continue;
|
|
9163
9221
|
}
|
|
@@ -9638,14 +9696,14 @@
|
|
|
9638
9696
|
key: "initControl",
|
|
9639
9697
|
value: function initControl() {
|
|
9640
9698
|
if (!this.imageStyle) this.createImageStyles();
|
|
9641
|
-
_superPropGet(WalletBackground, "initControl", this)([]);
|
|
9699
|
+
_superPropGet(WalletBackground, "initControl", this, 3)([]);
|
|
9642
9700
|
}
|
|
9643
9701
|
}, {
|
|
9644
9702
|
key: "clear",
|
|
9645
9703
|
value: function clear() {
|
|
9646
9704
|
if (this.imageStyle) this.imageStyle.parentNode.removeChild(this.imageStyle);
|
|
9647
9705
|
this.imageStyle = null;
|
|
9648
|
-
_superPropGet(WalletBackground, "clear", this)([]);
|
|
9706
|
+
_superPropGet(WalletBackground, "clear", this, 3)([]);
|
|
9649
9707
|
}
|
|
9650
9708
|
}, {
|
|
9651
9709
|
key: "createTemplate",
|
|
@@ -9767,7 +9825,7 @@
|
|
|
9767
9825
|
key: "setEnv",
|
|
9768
9826
|
value: function setEnv(env) {
|
|
9769
9827
|
this.link.setEnv(env);
|
|
9770
|
-
return _superPropGet(FlypayV2WalletService, "setEnv", this)([env]);
|
|
9828
|
+
return _superPropGet(FlypayV2WalletService, "setEnv", this, 3)([env]);
|
|
9771
9829
|
}
|
|
9772
9830
|
}, {
|
|
9773
9831
|
key: "enable",
|
|
@@ -10477,8 +10535,11 @@
|
|
|
10477
10535
|
formattedCapabilities = _this4.formatCapabilities(_this4.meta.apple_pay_capabilities);
|
|
10478
10536
|
}
|
|
10479
10537
|
ApplePaySession.applePayCapabilities(_this4.getMerchantId()).then(function (capabilities) {
|
|
10480
|
-
|
|
10481
|
-
|
|
10538
|
+
if (_this4.isUnsuportedBrowser(capabilities)) {
|
|
10539
|
+
return resolve(ApplePaySession.canMakePayments());
|
|
10540
|
+
}
|
|
10541
|
+
var allowedCapability = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
|
|
10542
|
+
return resolve(allowedCapability);
|
|
10482
10543
|
})["catch"](function (_err) {
|
|
10483
10544
|
return resolve(false);
|
|
10484
10545
|
});
|
|
@@ -10601,6 +10662,11 @@
|
|
|
10601
10662
|
value: function createButtonStyle() {
|
|
10602
10663
|
return "\n apple-pay-button {\n display: inline-block;\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 40px;\n --apple-pay-button-border-radius: 5px;\n --apple-pay-button-padding: 5px 0px;\n }\n ";
|
|
10603
10664
|
}
|
|
10665
|
+
}, {
|
|
10666
|
+
key: "isUnsuportedBrowser",
|
|
10667
|
+
value: function isUnsuportedBrowser(capabilities) {
|
|
10668
|
+
return (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
|
|
10669
|
+
}
|
|
10604
10670
|
}]);
|
|
10605
10671
|
}(WalletService);
|
|
10606
10672
|
|
|
@@ -14516,7 +14582,7 @@
|
|
|
14516
14582
|
key: "setFormElement",
|
|
14517
14583
|
value: function setFormElement(element) {
|
|
14518
14584
|
this.configs[0].setFormFields([element.field]);
|
|
14519
|
-
_superPropGet(HtmlWidget, "setFormElement", this)([_extends(_extends({}, element), {
|
|
14585
|
+
_superPropGet(HtmlWidget, "setFormElement", this, 3)([_extends(_extends({}, element), {
|
|
14520
14586
|
field: element.field.replace('*', '')
|
|
14521
14587
|
})]);
|
|
14522
14588
|
}
|
|
@@ -16414,19 +16480,19 @@
|
|
|
16414
16480
|
return _this;
|
|
16415
16481
|
}
|
|
16416
16482
|
/**
|
|
16417
|
-
|
|
16418
|
-
|
|
16419
|
-
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
|
|
16423
|
-
|
|
16424
|
-
|
|
16483
|
+
* Method for setting suspended redirect uri. Redirect after referred checkout
|
|
16484
|
+
*
|
|
16485
|
+
* The URI is used for a redirect after the checkout is complete.
|
|
16486
|
+
* This can be provided, even if using in-context checkout (sdk). By default, the standard styled page will be used.
|
|
16487
|
+
* If using in-context (sdk) we will not automatically redirect to this URI.
|
|
16488
|
+
*
|
|
16489
|
+
* @param {uri} string - uri for suspended redirect (by default)
|
|
16490
|
+
*/
|
|
16425
16491
|
_inherits(ZipmoneyCheckoutButton, _CheckoutButton);
|
|
16426
16492
|
return _createClass(ZipmoneyCheckoutButton, [{
|
|
16427
16493
|
key: "setSuspendedRedirectUri",
|
|
16428
16494
|
value: function setSuspendedRedirectUri(uri) {
|
|
16429
|
-
_superPropGet(ZipmoneyCheckoutButton, "setSuspendedRedirectUri", this)([uri]);
|
|
16495
|
+
_superPropGet(ZipmoneyCheckoutButton, "setSuspendedRedirectUri", this, 3)([uri]);
|
|
16430
16496
|
}
|
|
16431
16497
|
/**
|
|
16432
16498
|
* Method for setting the merchant redirect URL.
|
|
@@ -16443,21 +16509,39 @@
|
|
|
16443
16509
|
key: "setRedirectUrl",
|
|
16444
16510
|
value: function setRedirectUrl(url) {
|
|
16445
16511
|
if (isContextualRunner(this.runner)) {
|
|
16446
|
-
_superPropGet(ZipmoneyCheckoutButton, "chooseRunner", this)([GATEWAY_TYPE.ZIPMONEY, CHECKOUT_MODE.REDIRECT]);
|
|
16447
|
-
_superPropGet(ZipmoneyCheckoutButton, "setEnv", this)([this.env, this.alias]);
|
|
16512
|
+
_superPropGet(ZipmoneyCheckoutButton, "chooseRunner", this, 3)([GATEWAY_TYPE.ZIPMONEY, CHECKOUT_MODE.REDIRECT]);
|
|
16513
|
+
_superPropGet(ZipmoneyCheckoutButton, "setEnv", this, 3)([this.env, this.alias]);
|
|
16448
16514
|
}
|
|
16449
|
-
_superPropGet(ZipmoneyCheckoutButton, "setRedirectUrl", this)([url]);
|
|
16515
|
+
_superPropGet(ZipmoneyCheckoutButton, "setRedirectUrl", this, 3)([url]);
|
|
16450
16516
|
}
|
|
16451
16517
|
}, {
|
|
16452
16518
|
key: "buildAdditionalParams",
|
|
16453
16519
|
value: function buildAdditionalParams() {
|
|
16454
|
-
var defaultParams = _superPropGet(ZipmoneyCheckoutButton, "buildAdditionalParams", this)([]);
|
|
16520
|
+
var defaultParams = _superPropGet(ZipmoneyCheckoutButton, "buildAdditionalParams", this, 3)([]);
|
|
16455
16521
|
var params = _extends(_extends({}, defaultParams), {
|
|
16456
16522
|
public_key: this.publicKey,
|
|
16457
16523
|
gateway_id: this.gatewayId
|
|
16458
16524
|
});
|
|
16459
16525
|
return params;
|
|
16460
16526
|
}
|
|
16527
|
+
/**
|
|
16528
|
+
* Subscribe to the click event with an async handler.
|
|
16529
|
+
* The checkout flow will wait for the async handler to complete before proceeding.
|
|
16530
|
+
* If the handler resolves to `false`, the checkout flow will be cancelled.
|
|
16531
|
+
*
|
|
16532
|
+
* @param handler - Async function to be called when the button is clicked
|
|
16533
|
+
*
|
|
16534
|
+
* @example
|
|
16535
|
+
* button.onClick(async () => {
|
|
16536
|
+
* const isValid = await fetchDataFromServer();
|
|
16537
|
+
* return isValid; // return false to stop checkout
|
|
16538
|
+
* });
|
|
16539
|
+
*/
|
|
16540
|
+
}, {
|
|
16541
|
+
key: "onClick",
|
|
16542
|
+
value: function onClick(handler) {
|
|
16543
|
+
this.eventEmitter.subscribe(CHECKOUT_BUTTON_EVENT.CLICK, handler);
|
|
16544
|
+
}
|
|
16461
16545
|
}]);
|
|
16462
16546
|
}(CheckoutButton);
|
|
16463
16547
|
|
|
@@ -17353,7 +17437,7 @@
|
|
|
17353
17437
|
}, {
|
|
17354
17438
|
key: "destroy",
|
|
17355
17439
|
value: function destroy() {
|
|
17356
|
-
_superPropGet(InstructionCardFormShow, "destroy", this)([]);
|
|
17440
|
+
_superPropGet(InstructionCardFormShow, "destroy", this, 3)([]);
|
|
17357
17441
|
clearTimeout(this.timeoutId);
|
|
17358
17442
|
}
|
|
17359
17443
|
}, {
|
|
@@ -17852,7 +17936,7 @@
|
|
|
17852
17936
|
}, {
|
|
17853
17937
|
key: "destroy",
|
|
17854
17938
|
value: function destroy() {
|
|
17855
|
-
_superPropGet(InstructionPaymentMethodShow, "destroy", this)([]);
|
|
17939
|
+
_superPropGet(InstructionPaymentMethodShow, "destroy", this, 3)([]);
|
|
17856
17940
|
clearTimeout(this.timeoutId);
|
|
17857
17941
|
}
|
|
17858
17942
|
}, {
|
|
@@ -20016,8 +20100,11 @@
|
|
|
20016
20100
|
formattedCapabilities = _this6.formatCapabilities(_this6.meta.apple_pay_capabilities);
|
|
20017
20101
|
}
|
|
20018
20102
|
ApplePaySession.applePayCapabilities(_this6.getMerchantId()).then(function (capabilities) {
|
|
20019
|
-
|
|
20020
|
-
|
|
20103
|
+
if (_this6.isUnsuportedBrowser(capabilities)) {
|
|
20104
|
+
return resolve(ApplePaySession.canMakePayments());
|
|
20105
|
+
}
|
|
20106
|
+
var allowedCapability = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
|
|
20107
|
+
return resolve(allowedCapability);
|
|
20021
20108
|
})["catch"](function () {
|
|
20022
20109
|
resolve(false);
|
|
20023
20110
|
});
|
|
@@ -20278,6 +20365,11 @@
|
|
|
20278
20365
|
applePayLaterAvailability: this.meta.apple_pay_later_availability
|
|
20279
20366
|
});
|
|
20280
20367
|
}
|
|
20368
|
+
}, {
|
|
20369
|
+
key: "isUnsuportedBrowser",
|
|
20370
|
+
value: function isUnsuportedBrowser(capabilities) {
|
|
20371
|
+
return (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
|
|
20372
|
+
}
|
|
20281
20373
|
}]);
|
|
20282
20374
|
}(OpenWalletService);
|
|
20283
20375
|
|
|
@@ -23695,8 +23787,11 @@
|
|
|
23695
23787
|
formattedCapabilities = _this6.formatCapabilities(_this6.meta.apple_pay_capabilities);
|
|
23696
23788
|
}
|
|
23697
23789
|
ApplePaySession.applePayCapabilities(config.credentials[WALLET_TYPE.APPLE].merchant).then(function (capabilities) {
|
|
23698
|
-
|
|
23699
|
-
|
|
23790
|
+
if (_this6.isUnsuportedBrowser(capabilities)) {
|
|
23791
|
+
return resolve(ApplePaySession.canMakePayments());
|
|
23792
|
+
}
|
|
23793
|
+
var allowedCapability = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
|
|
23794
|
+
return resolve(allowedCapability);
|
|
23700
23795
|
})["catch"](function (_err) {
|
|
23701
23796
|
return resolve(false);
|
|
23702
23797
|
});
|
|
@@ -23867,6 +23962,11 @@
|
|
|
23867
23962
|
var code = codeMap[error.code] || 'unknown';
|
|
23868
23963
|
return new ApplePayError(code, contactField, error.message);
|
|
23869
23964
|
}
|
|
23965
|
+
}, {
|
|
23966
|
+
key: "isUnsuportedBrowser",
|
|
23967
|
+
value: function isUnsuportedBrowser(capabilities) {
|
|
23968
|
+
return (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
|
|
23969
|
+
}
|
|
23870
23970
|
}]);
|
|
23871
23971
|
}(BaseWalletButton);
|
|
23872
23972
|
|
|
@@ -27418,8 +27518,8 @@
|
|
|
27418
27518
|
// * 0's are not included unless the value is a 'relative zero'
|
|
27419
27519
|
//
|
|
27420
27520
|
|
|
27421
|
-
var START
|
|
27422
|
-
var END
|
|
27521
|
+
var START = 'Start';
|
|
27522
|
+
var END = 'End';
|
|
27423
27523
|
var UNLOAD_EVENT = 'unloadEvent';
|
|
27424
27524
|
var REDIRECT = 'redirect';
|
|
27425
27525
|
var DOMAIN_LOOKUP = 'domainLookup';
|
|
@@ -27445,26 +27545,26 @@
|
|
|
27445
27545
|
if (!pt) return;
|
|
27446
27546
|
v.of = offset;
|
|
27447
27547
|
handleValue(v.of, v, 'n', true);
|
|
27448
|
-
handleValue(pt[UNLOAD_EVENT + START
|
|
27449
|
-
handleValue(pt[REDIRECT + START
|
|
27450
|
-
handleValue(pt[UNLOAD_EVENT + END
|
|
27451
|
-
handleValue(pt[REDIRECT + END
|
|
27452
|
-
handleValue(pt['fetch' + START
|
|
27453
|
-
handleValue(pt[DOMAIN_LOOKUP + START
|
|
27454
|
-
handleValue(pt[DOMAIN_LOOKUP + END
|
|
27455
|
-
handleValue(pt['c' + ONNECT + START
|
|
27456
|
-
handleValue(pt['secureC' + ONNECT + 'ion' + START
|
|
27457
|
-
handleValue(pt['c' + ONNECT + END
|
|
27458
|
-
handleValue(pt[REQUEST + START
|
|
27459
|
-
handleValue(pt[RESPONSE + START
|
|
27460
|
-
handleValue(pt[RESPONSE + END
|
|
27548
|
+
handleValue(pt[UNLOAD_EVENT + START], v, 'u', isL1Api);
|
|
27549
|
+
handleValue(pt[REDIRECT + START], v, 'r', isL1Api);
|
|
27550
|
+
handleValue(pt[UNLOAD_EVENT + END], v, 'ue', isL1Api);
|
|
27551
|
+
handleValue(pt[REDIRECT + END], v, 're', isL1Api);
|
|
27552
|
+
handleValue(pt['fetch' + START], v, 'f', isL1Api);
|
|
27553
|
+
handleValue(pt[DOMAIN_LOOKUP + START], v, 'dn', isL1Api);
|
|
27554
|
+
handleValue(pt[DOMAIN_LOOKUP + END], v, 'dne', isL1Api);
|
|
27555
|
+
handleValue(pt['c' + ONNECT + START], v, 'c', isL1Api);
|
|
27556
|
+
handleValue(pt['secureC' + ONNECT + 'ion' + START], v, 's', isL1Api);
|
|
27557
|
+
handleValue(pt['c' + ONNECT + END], v, 'ce', isL1Api);
|
|
27558
|
+
handleValue(pt[REQUEST + START], v, 'rq', isL1Api);
|
|
27559
|
+
handleValue(pt[RESPONSE + START], v, 'rp', isL1Api);
|
|
27560
|
+
handleValue(pt[RESPONSE + END], v, 'rpe', isL1Api);
|
|
27461
27561
|
handleValue(pt.domLoading, v, 'dl', isL1Api);
|
|
27462
27562
|
handleValue(pt.domInteractive, v, 'di', isL1Api);
|
|
27463
|
-
handleValue(pt[DOM_CONTENT_LOAD_EVENT + START
|
|
27464
|
-
handleValue(pt[DOM_CONTENT_LOAD_EVENT + END
|
|
27563
|
+
handleValue(pt[DOM_CONTENT_LOAD_EVENT + START], v, 'ds', isL1Api);
|
|
27564
|
+
handleValue(pt[DOM_CONTENT_LOAD_EVENT + END], v, 'de', isL1Api);
|
|
27465
27565
|
handleValue(pt.domComplete, v, 'dc', isL1Api);
|
|
27466
|
-
handleValue(pt[LOAD_EVENT + START
|
|
27467
|
-
handleValue(pt[LOAD_EVENT + END
|
|
27566
|
+
handleValue(pt[LOAD_EVENT + START], v, 'l', isL1Api);
|
|
27567
|
+
handleValue(pt[LOAD_EVENT + END], v, 'le', isL1Api);
|
|
27468
27568
|
return v;
|
|
27469
27569
|
}
|
|
27470
27570
|
|
|
@@ -29718,21 +29818,11 @@
|
|
|
29718
29818
|
const FETCH_BODY$1 = 'fetch-body-';
|
|
29719
29819
|
const JSONP_END$1 = 'jsonp-end';
|
|
29720
29820
|
const originalSetTimeout$1 = originals.ST;
|
|
29721
|
-
const START = '-start';
|
|
29722
|
-
const END = '-end';
|
|
29723
|
-
const BODY = '-body';
|
|
29724
|
-
const CB_END = 'cb' + END;
|
|
29725
|
-
const JS_TIME = 'jsTime';
|
|
29726
|
-
const FETCH = 'fetch';
|
|
29727
29821
|
|
|
29728
29822
|
var CONSTANTS = /*#__PURE__*/Object.freeze({
|
|
29729
29823
|
__proto__: null,
|
|
29730
|
-
BODY: BODY,
|
|
29731
|
-
CB_END: CB_END,
|
|
29732
29824
|
CB_START: CB_START$1,
|
|
29733
|
-
END: END,
|
|
29734
29825
|
FEATURE_NAME: FEATURE_NAME$2,
|
|
29735
|
-
FETCH: FETCH,
|
|
29736
29826
|
FETCH_BODY: FETCH_BODY$1,
|
|
29737
29827
|
FETCH_DONE: FETCH_DONE$1,
|
|
29738
29828
|
FETCH_START: FETCH_START$1,
|
|
@@ -29743,11 +29833,9 @@
|
|
|
29743
29833
|
INTERACTION_EVENTS: INTERACTION_EVENTS$1,
|
|
29744
29834
|
JSONP_END: JSONP_END$1,
|
|
29745
29835
|
JSONP_NODE: JSONP_NODE$1,
|
|
29746
|
-
JS_TIME: JS_TIME,
|
|
29747
29836
|
MAX_TIMER_BUDGET: MAX_TIMER_BUDGET$1,
|
|
29748
29837
|
REMAINING: REMAINING$1,
|
|
29749
29838
|
SPA_NODE: SPA_NODE$1,
|
|
29750
|
-
START: START,
|
|
29751
29839
|
originalSetTimeout: originalSetTimeout$1
|
|
29752
29840
|
});
|
|
29753
29841
|
|
|
@@ -41666,6 +41754,25 @@
|
|
|
41666
41754
|
// However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
|
|
41667
41755
|
// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
|
|
41668
41756
|
// is better for memory in most engines (I *think*).
|
|
41757
|
+
var ch2 = {};
|
|
41758
|
+
var wk = (function (c, id, msg, transfer, cb) {
|
|
41759
|
+
var w = new Worker(ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([
|
|
41760
|
+
c + ';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'
|
|
41761
|
+
], { type: 'text/javascript' }))));
|
|
41762
|
+
w.onmessage = function (e) {
|
|
41763
|
+
var d = e.data, ed = d.$e$;
|
|
41764
|
+
if (ed) {
|
|
41765
|
+
var err = new Error(ed[0]);
|
|
41766
|
+
err['code'] = ed[1];
|
|
41767
|
+
err.stack = ed[2];
|
|
41768
|
+
cb(err, null);
|
|
41769
|
+
}
|
|
41770
|
+
else
|
|
41771
|
+
cb(null, d);
|
|
41772
|
+
};
|
|
41773
|
+
w.postMessage(msg, transfer);
|
|
41774
|
+
return w;
|
|
41775
|
+
});
|
|
41669
41776
|
|
|
41670
41777
|
// aliases for shorter compressed code (most minifers don't do this)
|
|
41671
41778
|
var u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;
|
|
@@ -41694,7 +41801,7 @@
|
|
|
41694
41801
|
var _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];
|
|
41695
41802
|
// we can ignore the fact that the other numbers are wrong; they never happen anyway
|
|
41696
41803
|
fl[28] = 258, revfl[258] = 28;
|
|
41697
|
-
var _b = freb(fdeb, 0), revfd = _b[1];
|
|
41804
|
+
var _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];
|
|
41698
41805
|
// map of value to reverse (assuming 16 bits)
|
|
41699
41806
|
var rev = new u16(32768);
|
|
41700
41807
|
for (var i = 0; i < 32768; ++i) {
|
|
@@ -41771,14 +41878,35 @@
|
|
|
41771
41878
|
for (var i = 0; i < 32; ++i)
|
|
41772
41879
|
fdt[i] = 5;
|
|
41773
41880
|
// fixed length map
|
|
41774
|
-
var flm = /*#__PURE__*/ hMap(flt, 9, 0);
|
|
41881
|
+
var flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);
|
|
41775
41882
|
// fixed distance map
|
|
41776
|
-
var fdm = /*#__PURE__*/ hMap(fdt, 5, 0);
|
|
41883
|
+
var fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
|
|
41884
|
+
// find max of array
|
|
41885
|
+
var max = function (a) {
|
|
41886
|
+
var m = a[0];
|
|
41887
|
+
for (var i = 1; i < a.length; ++i) {
|
|
41888
|
+
if (a[i] > m)
|
|
41889
|
+
m = a[i];
|
|
41890
|
+
}
|
|
41891
|
+
return m;
|
|
41892
|
+
};
|
|
41893
|
+
// read d, starting at bit p and mask with m
|
|
41894
|
+
var bits = function (d, p, m) {
|
|
41895
|
+
var o = (p / 8) | 0;
|
|
41896
|
+
return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;
|
|
41897
|
+
};
|
|
41898
|
+
// read d, starting at bit p continuing for at least 16 bits
|
|
41899
|
+
var bits16 = function (d, p) {
|
|
41900
|
+
var o = (p / 8) | 0;
|
|
41901
|
+
return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));
|
|
41902
|
+
};
|
|
41777
41903
|
// get end of byte
|
|
41778
41904
|
var shft = function (p) { return ((p + 7) / 8) | 0; };
|
|
41779
41905
|
// typed array slice - allows garbage collector to free original reference,
|
|
41780
41906
|
// while being more compatible than .slice
|
|
41781
41907
|
var slc = function (v, s, e) {
|
|
41908
|
+
if (s == null || s < 0)
|
|
41909
|
+
s = 0;
|
|
41782
41910
|
if (e == null || e > v.length)
|
|
41783
41911
|
e = v.length;
|
|
41784
41912
|
// can't use .constructor in case user-supplied
|
|
@@ -41786,6 +41914,232 @@
|
|
|
41786
41914
|
n.set(v.subarray(s, e));
|
|
41787
41915
|
return n;
|
|
41788
41916
|
};
|
|
41917
|
+
/**
|
|
41918
|
+
* Codes for errors generated within this library
|
|
41919
|
+
*/
|
|
41920
|
+
var FlateErrorCode = {
|
|
41921
|
+
UnexpectedEOF: 0,
|
|
41922
|
+
InvalidBlockType: 1,
|
|
41923
|
+
InvalidLengthLiteral: 2,
|
|
41924
|
+
InvalidDistance: 3,
|
|
41925
|
+
StreamFinished: 4,
|
|
41926
|
+
NoStreamHandler: 5,
|
|
41927
|
+
InvalidHeader: 6,
|
|
41928
|
+
NoCallback: 7,
|
|
41929
|
+
InvalidUTF8: 8,
|
|
41930
|
+
ExtraFieldTooLong: 9,
|
|
41931
|
+
InvalidDate: 10,
|
|
41932
|
+
FilenameTooLong: 11,
|
|
41933
|
+
StreamFinishing: 12,
|
|
41934
|
+
InvalidZipData: 13,
|
|
41935
|
+
UnknownCompressionMethod: 14
|
|
41936
|
+
};
|
|
41937
|
+
// error codes
|
|
41938
|
+
var ec = [
|
|
41939
|
+
'unexpected EOF',
|
|
41940
|
+
'invalid block type',
|
|
41941
|
+
'invalid length/literal',
|
|
41942
|
+
'invalid distance',
|
|
41943
|
+
'stream finished',
|
|
41944
|
+
'no stream handler',
|
|
41945
|
+
,
|
|
41946
|
+
'no callback',
|
|
41947
|
+
'invalid UTF-8 data',
|
|
41948
|
+
'extra field too long',
|
|
41949
|
+
'date not in range 1980-2099',
|
|
41950
|
+
'filename too long',
|
|
41951
|
+
'stream finishing',
|
|
41952
|
+
'invalid zip data'
|
|
41953
|
+
// determined by unknown compression method
|
|
41954
|
+
];
|
|
41955
|
+
var err = function (ind, msg, nt) {
|
|
41956
|
+
var e = new Error(msg || ec[ind]);
|
|
41957
|
+
e.code = ind;
|
|
41958
|
+
if (Error.captureStackTrace)
|
|
41959
|
+
Error.captureStackTrace(e, err);
|
|
41960
|
+
if (!nt)
|
|
41961
|
+
throw e;
|
|
41962
|
+
return e;
|
|
41963
|
+
};
|
|
41964
|
+
// expands raw DEFLATE data
|
|
41965
|
+
var inflt = function (dat, buf, st) {
|
|
41966
|
+
// source length
|
|
41967
|
+
var sl = dat.length;
|
|
41968
|
+
if (!sl || (st && st.f && !st.l))
|
|
41969
|
+
return buf || new u8(0);
|
|
41970
|
+
// have to estimate size
|
|
41971
|
+
var noBuf = !buf || st;
|
|
41972
|
+
// no state
|
|
41973
|
+
var noSt = !st || st.i;
|
|
41974
|
+
if (!st)
|
|
41975
|
+
st = {};
|
|
41976
|
+
// Assumes roughly 33% compression ratio average
|
|
41977
|
+
if (!buf)
|
|
41978
|
+
buf = new u8(sl * 3);
|
|
41979
|
+
// ensure buffer can fit at least l elements
|
|
41980
|
+
var cbuf = function (l) {
|
|
41981
|
+
var bl = buf.length;
|
|
41982
|
+
// need to increase size to fit
|
|
41983
|
+
if (l > bl) {
|
|
41984
|
+
// Double or set to necessary, whichever is greater
|
|
41985
|
+
var nbuf = new u8(Math.max(bl * 2, l));
|
|
41986
|
+
nbuf.set(buf);
|
|
41987
|
+
buf = nbuf;
|
|
41988
|
+
}
|
|
41989
|
+
};
|
|
41990
|
+
// last chunk bitpos bytes
|
|
41991
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
41992
|
+
// total bits
|
|
41993
|
+
var tbts = sl * 8;
|
|
41994
|
+
do {
|
|
41995
|
+
if (!lm) {
|
|
41996
|
+
// BFINAL - this is only 1 when last chunk is next
|
|
41997
|
+
final = bits(dat, pos, 1);
|
|
41998
|
+
// type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
|
|
41999
|
+
var type = bits(dat, pos + 1, 3);
|
|
42000
|
+
pos += 3;
|
|
42001
|
+
if (!type) {
|
|
42002
|
+
// go to end of byte boundary
|
|
42003
|
+
var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;
|
|
42004
|
+
if (t > sl) {
|
|
42005
|
+
if (noSt)
|
|
42006
|
+
err(0);
|
|
42007
|
+
break;
|
|
42008
|
+
}
|
|
42009
|
+
// ensure size
|
|
42010
|
+
if (noBuf)
|
|
42011
|
+
cbuf(bt + l);
|
|
42012
|
+
// Copy over uncompressed data
|
|
42013
|
+
buf.set(dat.subarray(s, t), bt);
|
|
42014
|
+
// Get new bitpos, update byte count
|
|
42015
|
+
st.b = bt += l, st.p = pos = t * 8, st.f = final;
|
|
42016
|
+
continue;
|
|
42017
|
+
}
|
|
42018
|
+
else if (type == 1)
|
|
42019
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
42020
|
+
else if (type == 2) {
|
|
42021
|
+
// literal lengths
|
|
42022
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
42023
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
42024
|
+
pos += 14;
|
|
42025
|
+
// length+distance tree
|
|
42026
|
+
var ldt = new u8(tl);
|
|
42027
|
+
// code length tree
|
|
42028
|
+
var clt = new u8(19);
|
|
42029
|
+
for (var i = 0; i < hcLen; ++i) {
|
|
42030
|
+
// use index map to get real code
|
|
42031
|
+
clt[clim[i]] = bits(dat, pos + i * 3, 7);
|
|
42032
|
+
}
|
|
42033
|
+
pos += hcLen * 3;
|
|
42034
|
+
// code lengths bits
|
|
42035
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
42036
|
+
// code lengths map
|
|
42037
|
+
var clm = hMap(clt, clb, 1);
|
|
42038
|
+
for (var i = 0; i < tl;) {
|
|
42039
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
42040
|
+
// bits read
|
|
42041
|
+
pos += r & 15;
|
|
42042
|
+
// symbol
|
|
42043
|
+
var s = r >>> 4;
|
|
42044
|
+
// code length to copy
|
|
42045
|
+
if (s < 16) {
|
|
42046
|
+
ldt[i++] = s;
|
|
42047
|
+
}
|
|
42048
|
+
else {
|
|
42049
|
+
// copy count
|
|
42050
|
+
var c = 0, n = 0;
|
|
42051
|
+
if (s == 16)
|
|
42052
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
|
|
42053
|
+
else if (s == 17)
|
|
42054
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
42055
|
+
else if (s == 18)
|
|
42056
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
42057
|
+
while (n--)
|
|
42058
|
+
ldt[i++] = c;
|
|
42059
|
+
}
|
|
42060
|
+
}
|
|
42061
|
+
// length tree distance tree
|
|
42062
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
42063
|
+
// max length bits
|
|
42064
|
+
lbt = max(lt);
|
|
42065
|
+
// max dist bits
|
|
42066
|
+
dbt = max(dt);
|
|
42067
|
+
lm = hMap(lt, lbt, 1);
|
|
42068
|
+
dm = hMap(dt, dbt, 1);
|
|
42069
|
+
}
|
|
42070
|
+
else
|
|
42071
|
+
err(1);
|
|
42072
|
+
if (pos > tbts) {
|
|
42073
|
+
if (noSt)
|
|
42074
|
+
err(0);
|
|
42075
|
+
break;
|
|
42076
|
+
}
|
|
42077
|
+
}
|
|
42078
|
+
// Make sure the buffer can hold this + the largest possible addition
|
|
42079
|
+
// Maximum chunk size (practically, theoretically infinite) is 2^17;
|
|
42080
|
+
if (noBuf)
|
|
42081
|
+
cbuf(bt + 131072);
|
|
42082
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
42083
|
+
var lpos = pos;
|
|
42084
|
+
for (;; lpos = pos) {
|
|
42085
|
+
// bits read, code
|
|
42086
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;
|
|
42087
|
+
pos += c & 15;
|
|
42088
|
+
if (pos > tbts) {
|
|
42089
|
+
if (noSt)
|
|
42090
|
+
err(0);
|
|
42091
|
+
break;
|
|
42092
|
+
}
|
|
42093
|
+
if (!c)
|
|
42094
|
+
err(2);
|
|
42095
|
+
if (sym < 256)
|
|
42096
|
+
buf[bt++] = sym;
|
|
42097
|
+
else if (sym == 256) {
|
|
42098
|
+
lpos = pos, lm = null;
|
|
42099
|
+
break;
|
|
42100
|
+
}
|
|
42101
|
+
else {
|
|
42102
|
+
var add = sym - 254;
|
|
42103
|
+
// no extra bits needed if less
|
|
42104
|
+
if (sym > 264) {
|
|
42105
|
+
// index
|
|
42106
|
+
var i = sym - 257, b = fleb[i];
|
|
42107
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i];
|
|
42108
|
+
pos += b;
|
|
42109
|
+
}
|
|
42110
|
+
// dist
|
|
42111
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;
|
|
42112
|
+
if (!d)
|
|
42113
|
+
err(3);
|
|
42114
|
+
pos += d & 15;
|
|
42115
|
+
var dt = fd[dsym];
|
|
42116
|
+
if (dsym > 3) {
|
|
42117
|
+
var b = fdeb[dsym];
|
|
42118
|
+
dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;
|
|
42119
|
+
}
|
|
42120
|
+
if (pos > tbts) {
|
|
42121
|
+
if (noSt)
|
|
42122
|
+
err(0);
|
|
42123
|
+
break;
|
|
42124
|
+
}
|
|
42125
|
+
if (noBuf)
|
|
42126
|
+
cbuf(bt + 131072);
|
|
42127
|
+
var end = bt + add;
|
|
42128
|
+
for (; bt < end; bt += 4) {
|
|
42129
|
+
buf[bt] = buf[bt - dt];
|
|
42130
|
+
buf[bt + 1] = buf[bt + 1 - dt];
|
|
42131
|
+
buf[bt + 2] = buf[bt + 2 - dt];
|
|
42132
|
+
buf[bt + 3] = buf[bt + 3 - dt];
|
|
42133
|
+
}
|
|
42134
|
+
bt = end;
|
|
42135
|
+
}
|
|
42136
|
+
}
|
|
42137
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
42138
|
+
if (lm)
|
|
42139
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
42140
|
+
} while (!final);
|
|
42141
|
+
return bt == buf.length ? buf : slc(buf, 0, bt);
|
|
42142
|
+
};
|
|
41789
42143
|
// starting at p, write the minimum number of bits that can hold v to d
|
|
41790
42144
|
var wbits = function (d, p, v) {
|
|
41791
42145
|
v <<= p & 7;
|
|
@@ -42123,6 +42477,9 @@
|
|
|
42123
42477
|
}
|
|
42124
42478
|
}
|
|
42125
42479
|
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
42480
|
+
// this is the easiest way to avoid needing to maintain state
|
|
42481
|
+
if (!lst && pos & 7)
|
|
42482
|
+
pos = wfblk(w, pos + 1, et);
|
|
42126
42483
|
}
|
|
42127
42484
|
return slc(o, 0, pre + shft(pos) + post);
|
|
42128
42485
|
};
|
|
@@ -42151,10 +42508,156 @@
|
|
|
42151
42508
|
d: function () { return ~c; }
|
|
42152
42509
|
};
|
|
42153
42510
|
};
|
|
42511
|
+
// Alder32
|
|
42512
|
+
var adler = function () {
|
|
42513
|
+
var a = 1, b = 0;
|
|
42514
|
+
return {
|
|
42515
|
+
p: function (d) {
|
|
42516
|
+
// closures have awful performance
|
|
42517
|
+
var n = a, m = b;
|
|
42518
|
+
var l = d.length | 0;
|
|
42519
|
+
for (var i = 0; i != l;) {
|
|
42520
|
+
var e = Math.min(i + 2655, l);
|
|
42521
|
+
for (; i < e; ++i)
|
|
42522
|
+
m += n += d[i];
|
|
42523
|
+
n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
|
|
42524
|
+
}
|
|
42525
|
+
a = n, b = m;
|
|
42526
|
+
},
|
|
42527
|
+
d: function () {
|
|
42528
|
+
a %= 65521, b %= 65521;
|
|
42529
|
+
return (a & 255) << 24 | (a >>> 8) << 16 | (b & 255) << 8 | (b >>> 8);
|
|
42530
|
+
}
|
|
42531
|
+
};
|
|
42532
|
+
};
|
|
42154
42533
|
// deflate with opts
|
|
42155
42534
|
var dopt = function (dat, opt, pre, post, st) {
|
|
42156
|
-
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post,
|
|
42535
|
+
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, !st);
|
|
42536
|
+
};
|
|
42537
|
+
// Walmart object spread
|
|
42538
|
+
var mrg = function (a, b) {
|
|
42539
|
+
var o = {};
|
|
42540
|
+
for (var k in a)
|
|
42541
|
+
o[k] = a[k];
|
|
42542
|
+
for (var k in b)
|
|
42543
|
+
o[k] = b[k];
|
|
42544
|
+
return o;
|
|
42545
|
+
};
|
|
42546
|
+
// worker clone
|
|
42547
|
+
// This is possibly the craziest part of the entire codebase, despite how simple it may seem.
|
|
42548
|
+
// The only parameter to this function is a closure that returns an array of variables outside of the function scope.
|
|
42549
|
+
// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.
|
|
42550
|
+
// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).
|
|
42551
|
+
// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.
|
|
42552
|
+
// This took me three weeks to figure out how to do.
|
|
42553
|
+
var wcln = function (fn, fnStr, td) {
|
|
42554
|
+
var dt = fn();
|
|
42555
|
+
var st = fn.toString();
|
|
42556
|
+
var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/\s+/g, '').split(',');
|
|
42557
|
+
for (var i = 0; i < dt.length; ++i) {
|
|
42558
|
+
var v = dt[i], k = ks[i];
|
|
42559
|
+
if (typeof v == 'function') {
|
|
42560
|
+
fnStr += ';' + k + '=';
|
|
42561
|
+
var st_1 = v.toString();
|
|
42562
|
+
if (v.prototype) {
|
|
42563
|
+
// for global objects
|
|
42564
|
+
if (st_1.indexOf('[native code]') != -1) {
|
|
42565
|
+
var spInd = st_1.indexOf(' ', 8) + 1;
|
|
42566
|
+
fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));
|
|
42567
|
+
}
|
|
42568
|
+
else {
|
|
42569
|
+
fnStr += st_1;
|
|
42570
|
+
for (var t in v.prototype)
|
|
42571
|
+
fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();
|
|
42572
|
+
}
|
|
42573
|
+
}
|
|
42574
|
+
else
|
|
42575
|
+
fnStr += st_1;
|
|
42576
|
+
}
|
|
42577
|
+
else
|
|
42578
|
+
td[k] = v;
|
|
42579
|
+
}
|
|
42580
|
+
return [fnStr, td];
|
|
42581
|
+
};
|
|
42582
|
+
var ch = [];
|
|
42583
|
+
// clone bufs
|
|
42584
|
+
var cbfs = function (v) {
|
|
42585
|
+
var tl = [];
|
|
42586
|
+
for (var k in v) {
|
|
42587
|
+
if (v[k].buffer) {
|
|
42588
|
+
tl.push((v[k] = new v[k].constructor(v[k])).buffer);
|
|
42589
|
+
}
|
|
42590
|
+
}
|
|
42591
|
+
return tl;
|
|
42592
|
+
};
|
|
42593
|
+
// use a worker to execute code
|
|
42594
|
+
var wrkr = function (fns, init, id, cb) {
|
|
42595
|
+
var _a;
|
|
42596
|
+
if (!ch[id]) {
|
|
42597
|
+
var fnStr = '', td_1 = {}, m = fns.length - 1;
|
|
42598
|
+
for (var i = 0; i < m; ++i)
|
|
42599
|
+
_a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];
|
|
42600
|
+
ch[id] = wcln(fns[m], fnStr, td_1);
|
|
42601
|
+
}
|
|
42602
|
+
var td = mrg({}, ch[id][1]);
|
|
42603
|
+
return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);
|
|
42604
|
+
};
|
|
42605
|
+
// base async inflate fn
|
|
42606
|
+
var bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, ec, hMap, max, bits, bits16, shft, slc, err, inflt, inflateSync, pbf, gu8]; };
|
|
42607
|
+
var bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };
|
|
42608
|
+
// gzip extra
|
|
42609
|
+
var gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };
|
|
42610
|
+
// gunzip extra
|
|
42611
|
+
var guze = function () { return [gzs, gzl]; };
|
|
42612
|
+
// zlib extra
|
|
42613
|
+
var zle = function () { return [zlh, wbytes, adler]; };
|
|
42614
|
+
// unzlib extra
|
|
42615
|
+
var zule = function () { return [zlv]; };
|
|
42616
|
+
// post buf
|
|
42617
|
+
var pbf = function (msg) { return postMessage(msg, [msg.buffer]); };
|
|
42618
|
+
// get u8
|
|
42619
|
+
var gu8 = function (o) { return o && o.size && new u8(o.size); };
|
|
42620
|
+
// async helper
|
|
42621
|
+
var cbify = function (dat, opts, fns, init, id, cb) {
|
|
42622
|
+
var w = wrkr(fns, init, id, function (err, dat) {
|
|
42623
|
+
w.terminate();
|
|
42624
|
+
cb(err, dat);
|
|
42625
|
+
});
|
|
42626
|
+
w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []);
|
|
42627
|
+
return function () { w.terminate(); };
|
|
42157
42628
|
};
|
|
42629
|
+
// auto stream
|
|
42630
|
+
var astrm = function (strm) {
|
|
42631
|
+
strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };
|
|
42632
|
+
return function (ev) { return strm.push(ev.data[0], ev.data[1]); };
|
|
42633
|
+
};
|
|
42634
|
+
// async stream attach
|
|
42635
|
+
var astrmify = function (fns, strm, opts, init, id) {
|
|
42636
|
+
var t;
|
|
42637
|
+
var w = wrkr(fns, init, id, function (err, dat) {
|
|
42638
|
+
if (err)
|
|
42639
|
+
w.terminate(), strm.ondata.call(strm, err);
|
|
42640
|
+
else {
|
|
42641
|
+
if (dat[1])
|
|
42642
|
+
w.terminate();
|
|
42643
|
+
strm.ondata.call(strm, err, dat[0], dat[1]);
|
|
42644
|
+
}
|
|
42645
|
+
});
|
|
42646
|
+
w.postMessage(opts);
|
|
42647
|
+
strm.push = function (d, f) {
|
|
42648
|
+
if (!strm.ondata)
|
|
42649
|
+
err(5);
|
|
42650
|
+
if (t)
|
|
42651
|
+
strm.ondata(err(4, 0, 1), null, !!f);
|
|
42652
|
+
w.postMessage([d, t = f], [d.buffer]);
|
|
42653
|
+
};
|
|
42654
|
+
strm.terminate = function () { w.terminate(); };
|
|
42655
|
+
};
|
|
42656
|
+
// read 2 bytes
|
|
42657
|
+
var b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };
|
|
42658
|
+
// read 4 bytes
|
|
42659
|
+
var b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };
|
|
42660
|
+
var b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };
|
|
42158
42661
|
// write bytes
|
|
42159
42662
|
var wbytes = function (d, b, v) {
|
|
42160
42663
|
for (; v; ++b)
|
|
@@ -42172,8 +42675,242 @@
|
|
|
42172
42675
|
c[i + 10] = fn.charCodeAt(i);
|
|
42173
42676
|
}
|
|
42174
42677
|
};
|
|
42678
|
+
// gzip footer: -8 to -4 = CRC, -4 to -0 is length
|
|
42679
|
+
// gzip start
|
|
42680
|
+
var gzs = function (d) {
|
|
42681
|
+
if (d[0] != 31 || d[1] != 139 || d[2] != 8)
|
|
42682
|
+
err(6, 'invalid gzip data');
|
|
42683
|
+
var flg = d[3];
|
|
42684
|
+
var st = 10;
|
|
42685
|
+
if (flg & 4)
|
|
42686
|
+
st += d[10] | (d[11] << 8) + 2;
|
|
42687
|
+
for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])
|
|
42688
|
+
;
|
|
42689
|
+
return st + (flg & 2);
|
|
42690
|
+
};
|
|
42691
|
+
// gzip length
|
|
42692
|
+
var gzl = function (d) {
|
|
42693
|
+
var l = d.length;
|
|
42694
|
+
return ((d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) | (d[l - 1] << 24)) >>> 0;
|
|
42695
|
+
};
|
|
42175
42696
|
// gzip header length
|
|
42176
42697
|
var gzhl = function (o) { return 10 + ((o.filename && (o.filename.length + 1)) || 0); };
|
|
42698
|
+
// zlib header
|
|
42699
|
+
var zlh = function (c, o) {
|
|
42700
|
+
var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
|
|
42701
|
+
c[0] = 120, c[1] = (fl << 6) | (fl ? (32 - 2 * fl) : 1);
|
|
42702
|
+
};
|
|
42703
|
+
// zlib valid
|
|
42704
|
+
var zlv = function (d) {
|
|
42705
|
+
if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))
|
|
42706
|
+
err(6, 'invalid zlib data');
|
|
42707
|
+
if (d[1] & 32)
|
|
42708
|
+
err(6, 'invalid zlib data: preset dictionaries not supported');
|
|
42709
|
+
};
|
|
42710
|
+
function AsyncCmpStrm(opts, cb) {
|
|
42711
|
+
if (!cb && typeof opts == 'function')
|
|
42712
|
+
cb = opts, opts = {};
|
|
42713
|
+
this.ondata = cb;
|
|
42714
|
+
return opts;
|
|
42715
|
+
}
|
|
42716
|
+
// zlib footer: -4 to -0 is Adler32
|
|
42717
|
+
/**
|
|
42718
|
+
* Streaming DEFLATE compression
|
|
42719
|
+
*/
|
|
42720
|
+
var Deflate = /*#__PURE__*/ (function () {
|
|
42721
|
+
function Deflate(opts, cb) {
|
|
42722
|
+
if (!cb && typeof opts == 'function')
|
|
42723
|
+
cb = opts, opts = {};
|
|
42724
|
+
this.ondata = cb;
|
|
42725
|
+
this.o = opts || {};
|
|
42726
|
+
}
|
|
42727
|
+
Deflate.prototype.p = function (c, f) {
|
|
42728
|
+
this.ondata(dopt(c, this.o, 0, 0, !f), f);
|
|
42729
|
+
};
|
|
42730
|
+
/**
|
|
42731
|
+
* Pushes a chunk to be deflated
|
|
42732
|
+
* @param chunk The chunk to push
|
|
42733
|
+
* @param final Whether this is the last chunk
|
|
42734
|
+
*/
|
|
42735
|
+
Deflate.prototype.push = function (chunk, final) {
|
|
42736
|
+
if (!this.ondata)
|
|
42737
|
+
err(5);
|
|
42738
|
+
if (this.d)
|
|
42739
|
+
err(4);
|
|
42740
|
+
this.d = final;
|
|
42741
|
+
this.p(chunk, final || false);
|
|
42742
|
+
};
|
|
42743
|
+
return Deflate;
|
|
42744
|
+
}());
|
|
42745
|
+
/**
|
|
42746
|
+
* Asynchronous streaming DEFLATE compression
|
|
42747
|
+
*/
|
|
42748
|
+
var AsyncDeflate = /*#__PURE__*/ (function () {
|
|
42749
|
+
function AsyncDeflate(opts, cb) {
|
|
42750
|
+
astrmify([
|
|
42751
|
+
bDflt,
|
|
42752
|
+
function () { return [astrm, Deflate]; }
|
|
42753
|
+
], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
|
|
42754
|
+
var strm = new Deflate(ev.data);
|
|
42755
|
+
onmessage = astrm(strm);
|
|
42756
|
+
}, 6);
|
|
42757
|
+
}
|
|
42758
|
+
return AsyncDeflate;
|
|
42759
|
+
}());
|
|
42760
|
+
function deflate(data, opts, cb) {
|
|
42761
|
+
if (!cb)
|
|
42762
|
+
cb = opts, opts = {};
|
|
42763
|
+
if (typeof cb != 'function')
|
|
42764
|
+
err(7);
|
|
42765
|
+
return cbify(data, opts, [
|
|
42766
|
+
bDflt,
|
|
42767
|
+
], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);
|
|
42768
|
+
}
|
|
42769
|
+
/**
|
|
42770
|
+
* Compresses data with DEFLATE without any wrapper
|
|
42771
|
+
* @param data The data to compress
|
|
42772
|
+
* @param opts The compression options
|
|
42773
|
+
* @returns The deflated version of the data
|
|
42774
|
+
*/
|
|
42775
|
+
function deflateSync(data, opts) {
|
|
42776
|
+
return dopt(data, opts || {}, 0, 0);
|
|
42777
|
+
}
|
|
42778
|
+
/**
|
|
42779
|
+
* Streaming DEFLATE decompression
|
|
42780
|
+
*/
|
|
42781
|
+
var Inflate = /*#__PURE__*/ (function () {
|
|
42782
|
+
/**
|
|
42783
|
+
* Creates an inflation stream
|
|
42784
|
+
* @param cb The callback to call whenever data is inflated
|
|
42785
|
+
*/
|
|
42786
|
+
function Inflate(cb) {
|
|
42787
|
+
this.s = {};
|
|
42788
|
+
this.p = new u8(0);
|
|
42789
|
+
this.ondata = cb;
|
|
42790
|
+
}
|
|
42791
|
+
Inflate.prototype.e = function (c) {
|
|
42792
|
+
if (!this.ondata)
|
|
42793
|
+
err(5);
|
|
42794
|
+
if (this.d)
|
|
42795
|
+
err(4);
|
|
42796
|
+
var l = this.p.length;
|
|
42797
|
+
var n = new u8(l + c.length);
|
|
42798
|
+
n.set(this.p), n.set(c, l), this.p = n;
|
|
42799
|
+
};
|
|
42800
|
+
Inflate.prototype.c = function (final) {
|
|
42801
|
+
this.d = this.s.i = final || false;
|
|
42802
|
+
var bts = this.s.b;
|
|
42803
|
+
var dt = inflt(this.p, this.o, this.s);
|
|
42804
|
+
this.ondata(slc(dt, bts, this.s.b), this.d);
|
|
42805
|
+
this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
|
|
42806
|
+
this.p = slc(this.p, (this.s.p / 8) | 0), this.s.p &= 7;
|
|
42807
|
+
};
|
|
42808
|
+
/**
|
|
42809
|
+
* Pushes a chunk to be inflated
|
|
42810
|
+
* @param chunk The chunk to push
|
|
42811
|
+
* @param final Whether this is the final chunk
|
|
42812
|
+
*/
|
|
42813
|
+
Inflate.prototype.push = function (chunk, final) {
|
|
42814
|
+
this.e(chunk), this.c(final);
|
|
42815
|
+
};
|
|
42816
|
+
return Inflate;
|
|
42817
|
+
}());
|
|
42818
|
+
/**
|
|
42819
|
+
* Asynchronous streaming DEFLATE decompression
|
|
42820
|
+
*/
|
|
42821
|
+
var AsyncInflate = /*#__PURE__*/ (function () {
|
|
42822
|
+
/**
|
|
42823
|
+
* Creates an asynchronous inflation stream
|
|
42824
|
+
* @param cb The callback to call whenever data is deflated
|
|
42825
|
+
*/
|
|
42826
|
+
function AsyncInflate(cb) {
|
|
42827
|
+
this.ondata = cb;
|
|
42828
|
+
astrmify([
|
|
42829
|
+
bInflt,
|
|
42830
|
+
function () { return [astrm, Inflate]; }
|
|
42831
|
+
], this, 0, function () {
|
|
42832
|
+
var strm = new Inflate();
|
|
42833
|
+
onmessage = astrm(strm);
|
|
42834
|
+
}, 7);
|
|
42835
|
+
}
|
|
42836
|
+
return AsyncInflate;
|
|
42837
|
+
}());
|
|
42838
|
+
function inflate(data, opts, cb) {
|
|
42839
|
+
if (!cb)
|
|
42840
|
+
cb = opts, opts = {};
|
|
42841
|
+
if (typeof cb != 'function')
|
|
42842
|
+
err(7);
|
|
42843
|
+
return cbify(data, opts, [
|
|
42844
|
+
bInflt
|
|
42845
|
+
], function (ev) { return pbf(inflateSync(ev.data[0], gu8(ev.data[1]))); }, 1, cb);
|
|
42846
|
+
}
|
|
42847
|
+
/**
|
|
42848
|
+
* Expands DEFLATE data with no wrapper
|
|
42849
|
+
* @param data The data to decompress
|
|
42850
|
+
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
|
|
42851
|
+
* @returns The decompressed version of the data
|
|
42852
|
+
*/
|
|
42853
|
+
function inflateSync(data, out) {
|
|
42854
|
+
return inflt(data, out);
|
|
42855
|
+
}
|
|
42856
|
+
// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.
|
|
42857
|
+
/**
|
|
42858
|
+
* Streaming GZIP compression
|
|
42859
|
+
*/
|
|
42860
|
+
var Gzip = /*#__PURE__*/ (function () {
|
|
42861
|
+
function Gzip(opts, cb) {
|
|
42862
|
+
this.c = crc();
|
|
42863
|
+
this.l = 0;
|
|
42864
|
+
this.v = 1;
|
|
42865
|
+
Deflate.call(this, opts, cb);
|
|
42866
|
+
}
|
|
42867
|
+
/**
|
|
42868
|
+
* Pushes a chunk to be GZIPped
|
|
42869
|
+
* @param chunk The chunk to push
|
|
42870
|
+
* @param final Whether this is the last chunk
|
|
42871
|
+
*/
|
|
42872
|
+
Gzip.prototype.push = function (chunk, final) {
|
|
42873
|
+
Deflate.prototype.push.call(this, chunk, final);
|
|
42874
|
+
};
|
|
42875
|
+
Gzip.prototype.p = function (c, f) {
|
|
42876
|
+
this.c.p(c);
|
|
42877
|
+
this.l += c.length;
|
|
42878
|
+
var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);
|
|
42879
|
+
if (this.v)
|
|
42880
|
+
gzh(raw, this.o), this.v = 0;
|
|
42881
|
+
if (f)
|
|
42882
|
+
wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);
|
|
42883
|
+
this.ondata(raw, f);
|
|
42884
|
+
};
|
|
42885
|
+
return Gzip;
|
|
42886
|
+
}());
|
|
42887
|
+
/**
|
|
42888
|
+
* Asynchronous streaming GZIP compression
|
|
42889
|
+
*/
|
|
42890
|
+
var AsyncGzip = /*#__PURE__*/ (function () {
|
|
42891
|
+
function AsyncGzip(opts, cb) {
|
|
42892
|
+
astrmify([
|
|
42893
|
+
bDflt,
|
|
42894
|
+
gze,
|
|
42895
|
+
function () { return [astrm, Deflate, Gzip]; }
|
|
42896
|
+
], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
|
|
42897
|
+
var strm = new Gzip(ev.data);
|
|
42898
|
+
onmessage = astrm(strm);
|
|
42899
|
+
}, 8);
|
|
42900
|
+
}
|
|
42901
|
+
return AsyncGzip;
|
|
42902
|
+
}());
|
|
42903
|
+
function gzip(data, opts, cb) {
|
|
42904
|
+
if (!cb)
|
|
42905
|
+
cb = opts, opts = {};
|
|
42906
|
+
if (typeof cb != 'function')
|
|
42907
|
+
err(7);
|
|
42908
|
+
return cbify(data, opts, [
|
|
42909
|
+
bDflt,
|
|
42910
|
+
gze,
|
|
42911
|
+
function () { return [gzipSync]; }
|
|
42912
|
+
], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);
|
|
42913
|
+
}
|
|
42177
42914
|
/**
|
|
42178
42915
|
* Compresses data with GZIP
|
|
42179
42916
|
* @param data The data to compress
|
|
@@ -42188,6 +42925,336 @@
|
|
|
42188
42925
|
var d = dopt(data, opts, gzhl(opts), 8), s = d.length;
|
|
42189
42926
|
return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;
|
|
42190
42927
|
}
|
|
42928
|
+
/**
|
|
42929
|
+
* Streaming GZIP decompression
|
|
42930
|
+
*/
|
|
42931
|
+
var Gunzip = /*#__PURE__*/ (function () {
|
|
42932
|
+
/**
|
|
42933
|
+
* Creates a GUNZIP stream
|
|
42934
|
+
* @param cb The callback to call whenever data is inflated
|
|
42935
|
+
*/
|
|
42936
|
+
function Gunzip(cb) {
|
|
42937
|
+
this.v = 1;
|
|
42938
|
+
Inflate.call(this, cb);
|
|
42939
|
+
}
|
|
42940
|
+
/**
|
|
42941
|
+
* Pushes a chunk to be GUNZIPped
|
|
42942
|
+
* @param chunk The chunk to push
|
|
42943
|
+
* @param final Whether this is the last chunk
|
|
42944
|
+
*/
|
|
42945
|
+
Gunzip.prototype.push = function (chunk, final) {
|
|
42946
|
+
Inflate.prototype.e.call(this, chunk);
|
|
42947
|
+
if (this.v) {
|
|
42948
|
+
var s = this.p.length > 3 ? gzs(this.p) : 4;
|
|
42949
|
+
if (s >= this.p.length && !final)
|
|
42950
|
+
return;
|
|
42951
|
+
this.p = this.p.subarray(s), this.v = 0;
|
|
42952
|
+
}
|
|
42953
|
+
if (final) {
|
|
42954
|
+
if (this.p.length < 8)
|
|
42955
|
+
err(6, 'invalid gzip data');
|
|
42956
|
+
this.p = this.p.subarray(0, -8);
|
|
42957
|
+
}
|
|
42958
|
+
// necessary to prevent TS from using the closure value
|
|
42959
|
+
// This allows for workerization to function correctly
|
|
42960
|
+
Inflate.prototype.c.call(this, final);
|
|
42961
|
+
};
|
|
42962
|
+
return Gunzip;
|
|
42963
|
+
}());
|
|
42964
|
+
/**
|
|
42965
|
+
* Asynchronous streaming GZIP decompression
|
|
42966
|
+
*/
|
|
42967
|
+
var AsyncGunzip = /*#__PURE__*/ (function () {
|
|
42968
|
+
/**
|
|
42969
|
+
* Creates an asynchronous GUNZIP stream
|
|
42970
|
+
* @param cb The callback to call whenever data is deflated
|
|
42971
|
+
*/
|
|
42972
|
+
function AsyncGunzip(cb) {
|
|
42973
|
+
this.ondata = cb;
|
|
42974
|
+
astrmify([
|
|
42975
|
+
bInflt,
|
|
42976
|
+
guze,
|
|
42977
|
+
function () { return [astrm, Inflate, Gunzip]; }
|
|
42978
|
+
], this, 0, function () {
|
|
42979
|
+
var strm = new Gunzip();
|
|
42980
|
+
onmessage = astrm(strm);
|
|
42981
|
+
}, 9);
|
|
42982
|
+
}
|
|
42983
|
+
return AsyncGunzip;
|
|
42984
|
+
}());
|
|
42985
|
+
function gunzip(data, opts, cb) {
|
|
42986
|
+
if (!cb)
|
|
42987
|
+
cb = opts, opts = {};
|
|
42988
|
+
if (typeof cb != 'function')
|
|
42989
|
+
err(7);
|
|
42990
|
+
return cbify(data, opts, [
|
|
42991
|
+
bInflt,
|
|
42992
|
+
guze,
|
|
42993
|
+
function () { return [gunzipSync]; }
|
|
42994
|
+
], function (ev) { return pbf(gunzipSync(ev.data[0])); }, 3, cb);
|
|
42995
|
+
}
|
|
42996
|
+
/**
|
|
42997
|
+
* Expands GZIP data
|
|
42998
|
+
* @param data The data to decompress
|
|
42999
|
+
* @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
|
|
43000
|
+
* @returns The decompressed version of the data
|
|
43001
|
+
*/
|
|
43002
|
+
function gunzipSync(data, out) {
|
|
43003
|
+
return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));
|
|
43004
|
+
}
|
|
43005
|
+
/**
|
|
43006
|
+
* Streaming Zlib compression
|
|
43007
|
+
*/
|
|
43008
|
+
var Zlib = /*#__PURE__*/ (function () {
|
|
43009
|
+
function Zlib(opts, cb) {
|
|
43010
|
+
this.c = adler();
|
|
43011
|
+
this.v = 1;
|
|
43012
|
+
Deflate.call(this, opts, cb);
|
|
43013
|
+
}
|
|
43014
|
+
/**
|
|
43015
|
+
* Pushes a chunk to be zlibbed
|
|
43016
|
+
* @param chunk The chunk to push
|
|
43017
|
+
* @param final Whether this is the last chunk
|
|
43018
|
+
*/
|
|
43019
|
+
Zlib.prototype.push = function (chunk, final) {
|
|
43020
|
+
Deflate.prototype.push.call(this, chunk, final);
|
|
43021
|
+
};
|
|
43022
|
+
Zlib.prototype.p = function (c, f) {
|
|
43023
|
+
this.c.p(c);
|
|
43024
|
+
var raw = dopt(c, this.o, this.v && 2, f && 4, !f);
|
|
43025
|
+
if (this.v)
|
|
43026
|
+
zlh(raw, this.o), this.v = 0;
|
|
43027
|
+
if (f)
|
|
43028
|
+
wbytes(raw, raw.length - 4, this.c.d());
|
|
43029
|
+
this.ondata(raw, f);
|
|
43030
|
+
};
|
|
43031
|
+
return Zlib;
|
|
43032
|
+
}());
|
|
43033
|
+
/**
|
|
43034
|
+
* Asynchronous streaming Zlib compression
|
|
43035
|
+
*/
|
|
43036
|
+
var AsyncZlib = /*#__PURE__*/ (function () {
|
|
43037
|
+
function AsyncZlib(opts, cb) {
|
|
43038
|
+
astrmify([
|
|
43039
|
+
bDflt,
|
|
43040
|
+
zle,
|
|
43041
|
+
function () { return [astrm, Deflate, Zlib]; }
|
|
43042
|
+
], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
|
|
43043
|
+
var strm = new Zlib(ev.data);
|
|
43044
|
+
onmessage = astrm(strm);
|
|
43045
|
+
}, 10);
|
|
43046
|
+
}
|
|
43047
|
+
return AsyncZlib;
|
|
43048
|
+
}());
|
|
43049
|
+
function zlib(data, opts, cb) {
|
|
43050
|
+
if (!cb)
|
|
43051
|
+
cb = opts, opts = {};
|
|
43052
|
+
if (typeof cb != 'function')
|
|
43053
|
+
err(7);
|
|
43054
|
+
return cbify(data, opts, [
|
|
43055
|
+
bDflt,
|
|
43056
|
+
zle,
|
|
43057
|
+
function () { return [zlibSync]; }
|
|
43058
|
+
], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);
|
|
43059
|
+
}
|
|
43060
|
+
/**
|
|
43061
|
+
* Compress data with Zlib
|
|
43062
|
+
* @param data The data to compress
|
|
43063
|
+
* @param opts The compression options
|
|
43064
|
+
* @returns The zlib-compressed version of the data
|
|
43065
|
+
*/
|
|
43066
|
+
function zlibSync(data, opts) {
|
|
43067
|
+
if (!opts)
|
|
43068
|
+
opts = {};
|
|
43069
|
+
var a = adler();
|
|
43070
|
+
a.p(data);
|
|
43071
|
+
var d = dopt(data, opts, 2, 4);
|
|
43072
|
+
return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
|
|
43073
|
+
}
|
|
43074
|
+
/**
|
|
43075
|
+
* Streaming Zlib decompression
|
|
43076
|
+
*/
|
|
43077
|
+
var Unzlib = /*#__PURE__*/ (function () {
|
|
43078
|
+
/**
|
|
43079
|
+
* Creates a Zlib decompression stream
|
|
43080
|
+
* @param cb The callback to call whenever data is inflated
|
|
43081
|
+
*/
|
|
43082
|
+
function Unzlib(cb) {
|
|
43083
|
+
this.v = 1;
|
|
43084
|
+
Inflate.call(this, cb);
|
|
43085
|
+
}
|
|
43086
|
+
/**
|
|
43087
|
+
* Pushes a chunk to be unzlibbed
|
|
43088
|
+
* @param chunk The chunk to push
|
|
43089
|
+
* @param final Whether this is the last chunk
|
|
43090
|
+
*/
|
|
43091
|
+
Unzlib.prototype.push = function (chunk, final) {
|
|
43092
|
+
Inflate.prototype.e.call(this, chunk);
|
|
43093
|
+
if (this.v) {
|
|
43094
|
+
if (this.p.length < 2 && !final)
|
|
43095
|
+
return;
|
|
43096
|
+
this.p = this.p.subarray(2), this.v = 0;
|
|
43097
|
+
}
|
|
43098
|
+
if (final) {
|
|
43099
|
+
if (this.p.length < 4)
|
|
43100
|
+
err(6, 'invalid zlib data');
|
|
43101
|
+
this.p = this.p.subarray(0, -4);
|
|
43102
|
+
}
|
|
43103
|
+
// necessary to prevent TS from using the closure value
|
|
43104
|
+
// This allows for workerization to function correctly
|
|
43105
|
+
Inflate.prototype.c.call(this, final);
|
|
43106
|
+
};
|
|
43107
|
+
return Unzlib;
|
|
43108
|
+
}());
|
|
43109
|
+
/**
|
|
43110
|
+
* Asynchronous streaming Zlib decompression
|
|
43111
|
+
*/
|
|
43112
|
+
var AsyncUnzlib = /*#__PURE__*/ (function () {
|
|
43113
|
+
/**
|
|
43114
|
+
* Creates an asynchronous Zlib decompression stream
|
|
43115
|
+
* @param cb The callback to call whenever data is deflated
|
|
43116
|
+
*/
|
|
43117
|
+
function AsyncUnzlib(cb) {
|
|
43118
|
+
this.ondata = cb;
|
|
43119
|
+
astrmify([
|
|
43120
|
+
bInflt,
|
|
43121
|
+
zule,
|
|
43122
|
+
function () { return [astrm, Inflate, Unzlib]; }
|
|
43123
|
+
], this, 0, function () {
|
|
43124
|
+
var strm = new Unzlib();
|
|
43125
|
+
onmessage = astrm(strm);
|
|
43126
|
+
}, 11);
|
|
43127
|
+
}
|
|
43128
|
+
return AsyncUnzlib;
|
|
43129
|
+
}());
|
|
43130
|
+
function unzlib(data, opts, cb) {
|
|
43131
|
+
if (!cb)
|
|
43132
|
+
cb = opts, opts = {};
|
|
43133
|
+
if (typeof cb != 'function')
|
|
43134
|
+
err(7);
|
|
43135
|
+
return cbify(data, opts, [
|
|
43136
|
+
bInflt,
|
|
43137
|
+
zule,
|
|
43138
|
+
function () { return [unzlibSync]; }
|
|
43139
|
+
], function (ev) { return pbf(unzlibSync(ev.data[0], gu8(ev.data[1]))); }, 5, cb);
|
|
43140
|
+
}
|
|
43141
|
+
/**
|
|
43142
|
+
* Expands Zlib data
|
|
43143
|
+
* @param data The data to decompress
|
|
43144
|
+
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
|
|
43145
|
+
* @returns The decompressed version of the data
|
|
43146
|
+
*/
|
|
43147
|
+
function unzlibSync(data, out) {
|
|
43148
|
+
return inflt((zlv(data), data.subarray(2, -4)), out);
|
|
43149
|
+
}
|
|
43150
|
+
/**
|
|
43151
|
+
* Streaming GZIP, Zlib, or raw DEFLATE decompression
|
|
43152
|
+
*/
|
|
43153
|
+
var Decompress = /*#__PURE__*/ (function () {
|
|
43154
|
+
/**
|
|
43155
|
+
* Creates a decompression stream
|
|
43156
|
+
* @param cb The callback to call whenever data is decompressed
|
|
43157
|
+
*/
|
|
43158
|
+
function Decompress(cb) {
|
|
43159
|
+
this.G = Gunzip;
|
|
43160
|
+
this.I = Inflate;
|
|
43161
|
+
this.Z = Unzlib;
|
|
43162
|
+
this.ondata = cb;
|
|
43163
|
+
}
|
|
43164
|
+
/**
|
|
43165
|
+
* Pushes a chunk to be decompressed
|
|
43166
|
+
* @param chunk The chunk to push
|
|
43167
|
+
* @param final Whether this is the last chunk
|
|
43168
|
+
*/
|
|
43169
|
+
Decompress.prototype.push = function (chunk, final) {
|
|
43170
|
+
if (!this.ondata)
|
|
43171
|
+
err(5);
|
|
43172
|
+
if (!this.s) {
|
|
43173
|
+
if (this.p && this.p.length) {
|
|
43174
|
+
var n = new u8(this.p.length + chunk.length);
|
|
43175
|
+
n.set(this.p), n.set(chunk, this.p.length);
|
|
43176
|
+
}
|
|
43177
|
+
else
|
|
43178
|
+
this.p = chunk;
|
|
43179
|
+
if (this.p.length > 2) {
|
|
43180
|
+
var _this_1 = this;
|
|
43181
|
+
var cb = function () { _this_1.ondata.apply(_this_1, arguments); };
|
|
43182
|
+
this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)
|
|
43183
|
+
? new this.G(cb)
|
|
43184
|
+
: ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))
|
|
43185
|
+
? new this.I(cb)
|
|
43186
|
+
: new this.Z(cb);
|
|
43187
|
+
this.s.push(this.p, final);
|
|
43188
|
+
this.p = null;
|
|
43189
|
+
}
|
|
43190
|
+
}
|
|
43191
|
+
else
|
|
43192
|
+
this.s.push(chunk, final);
|
|
43193
|
+
};
|
|
43194
|
+
return Decompress;
|
|
43195
|
+
}());
|
|
43196
|
+
/**
|
|
43197
|
+
* Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression
|
|
43198
|
+
*/
|
|
43199
|
+
var AsyncDecompress = /*#__PURE__*/ (function () {
|
|
43200
|
+
/**
|
|
43201
|
+
* Creates an asynchronous decompression stream
|
|
43202
|
+
* @param cb The callback to call whenever data is decompressed
|
|
43203
|
+
*/
|
|
43204
|
+
function AsyncDecompress(cb) {
|
|
43205
|
+
this.G = AsyncGunzip;
|
|
43206
|
+
this.I = AsyncInflate;
|
|
43207
|
+
this.Z = AsyncUnzlib;
|
|
43208
|
+
this.ondata = cb;
|
|
43209
|
+
}
|
|
43210
|
+
/**
|
|
43211
|
+
* Pushes a chunk to be decompressed
|
|
43212
|
+
* @param chunk The chunk to push
|
|
43213
|
+
* @param final Whether this is the last chunk
|
|
43214
|
+
*/
|
|
43215
|
+
AsyncDecompress.prototype.push = function (chunk, final) {
|
|
43216
|
+
Decompress.prototype.push.call(this, chunk, final);
|
|
43217
|
+
};
|
|
43218
|
+
return AsyncDecompress;
|
|
43219
|
+
}());
|
|
43220
|
+
function decompress(data, opts, cb) {
|
|
43221
|
+
if (!cb)
|
|
43222
|
+
cb = opts, opts = {};
|
|
43223
|
+
if (typeof cb != 'function')
|
|
43224
|
+
err(7);
|
|
43225
|
+
return (data[0] == 31 && data[1] == 139 && data[2] == 8)
|
|
43226
|
+
? gunzip(data, opts, cb)
|
|
43227
|
+
: ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))
|
|
43228
|
+
? inflate(data, opts, cb)
|
|
43229
|
+
: unzlib(data, opts, cb);
|
|
43230
|
+
}
|
|
43231
|
+
/**
|
|
43232
|
+
* Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
|
|
43233
|
+
* @param data The data to decompress
|
|
43234
|
+
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
|
|
43235
|
+
* @returns The decompressed version of the data
|
|
43236
|
+
*/
|
|
43237
|
+
function decompressSync(data, out) {
|
|
43238
|
+
return (data[0] == 31 && data[1] == 139 && data[2] == 8)
|
|
43239
|
+
? gunzipSync(data, out)
|
|
43240
|
+
: ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))
|
|
43241
|
+
? inflateSync(data, out)
|
|
43242
|
+
: unzlibSync(data, out);
|
|
43243
|
+
}
|
|
43244
|
+
// flatten a directory structure
|
|
43245
|
+
var fltn = function (d, p, t, o) {
|
|
43246
|
+
for (var k in d) {
|
|
43247
|
+
var val = d[k], n = p + k, op = o;
|
|
43248
|
+
if (Array.isArray(val))
|
|
43249
|
+
op = mrg(o, val[1]), val = val[0];
|
|
43250
|
+
if (val instanceof u8)
|
|
43251
|
+
t[n] = [val, op];
|
|
43252
|
+
else {
|
|
43253
|
+
t[n += '/'] = [new u8(0), op];
|
|
43254
|
+
fltn(val, n, t, o);
|
|
43255
|
+
}
|
|
43256
|
+
}
|
|
43257
|
+
};
|
|
42191
43258
|
// text encoder
|
|
42192
43259
|
var te = typeof TextEncoder != 'undefined' && /*#__PURE__*/ new TextEncoder();
|
|
42193
43260
|
// text decoder
|
|
@@ -42199,6 +43266,100 @@
|
|
|
42199
43266
|
tds = 1;
|
|
42200
43267
|
}
|
|
42201
43268
|
catch (e) { }
|
|
43269
|
+
// decode UTF8
|
|
43270
|
+
var dutf8 = function (d) {
|
|
43271
|
+
for (var r = '', i = 0;;) {
|
|
43272
|
+
var c = d[i++];
|
|
43273
|
+
var eb = (c > 127) + (c > 223) + (c > 239);
|
|
43274
|
+
if (i + eb > d.length)
|
|
43275
|
+
return [r, slc(d, i - 1)];
|
|
43276
|
+
if (!eb)
|
|
43277
|
+
r += String.fromCharCode(c);
|
|
43278
|
+
else if (eb == 3) {
|
|
43279
|
+
c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,
|
|
43280
|
+
r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));
|
|
43281
|
+
}
|
|
43282
|
+
else if (eb & 1)
|
|
43283
|
+
r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));
|
|
43284
|
+
else
|
|
43285
|
+
r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));
|
|
43286
|
+
}
|
|
43287
|
+
};
|
|
43288
|
+
/**
|
|
43289
|
+
* Streaming UTF-8 decoding
|
|
43290
|
+
*/
|
|
43291
|
+
var DecodeUTF8 = /*#__PURE__*/ (function () {
|
|
43292
|
+
/**
|
|
43293
|
+
* Creates a UTF-8 decoding stream
|
|
43294
|
+
* @param cb The callback to call whenever data is decoded
|
|
43295
|
+
*/
|
|
43296
|
+
function DecodeUTF8(cb) {
|
|
43297
|
+
this.ondata = cb;
|
|
43298
|
+
if (tds)
|
|
43299
|
+
this.t = new TextDecoder();
|
|
43300
|
+
else
|
|
43301
|
+
this.p = et;
|
|
43302
|
+
}
|
|
43303
|
+
/**
|
|
43304
|
+
* Pushes a chunk to be decoded from UTF-8 binary
|
|
43305
|
+
* @param chunk The chunk to push
|
|
43306
|
+
* @param final Whether this is the last chunk
|
|
43307
|
+
*/
|
|
43308
|
+
DecodeUTF8.prototype.push = function (chunk, final) {
|
|
43309
|
+
if (!this.ondata)
|
|
43310
|
+
err(5);
|
|
43311
|
+
final = !!final;
|
|
43312
|
+
if (this.t) {
|
|
43313
|
+
this.ondata(this.t.decode(chunk, { stream: true }), final);
|
|
43314
|
+
if (final) {
|
|
43315
|
+
if (this.t.decode().length)
|
|
43316
|
+
err(8);
|
|
43317
|
+
this.t = null;
|
|
43318
|
+
}
|
|
43319
|
+
return;
|
|
43320
|
+
}
|
|
43321
|
+
if (!this.p)
|
|
43322
|
+
err(4);
|
|
43323
|
+
var dat = new u8(this.p.length + chunk.length);
|
|
43324
|
+
dat.set(this.p);
|
|
43325
|
+
dat.set(chunk, this.p.length);
|
|
43326
|
+
var _a = dutf8(dat), ch = _a[0], np = _a[1];
|
|
43327
|
+
if (final) {
|
|
43328
|
+
if (np.length)
|
|
43329
|
+
err(8);
|
|
43330
|
+
this.p = null;
|
|
43331
|
+
}
|
|
43332
|
+
else
|
|
43333
|
+
this.p = np;
|
|
43334
|
+
this.ondata(ch, final);
|
|
43335
|
+
};
|
|
43336
|
+
return DecodeUTF8;
|
|
43337
|
+
}());
|
|
43338
|
+
/**
|
|
43339
|
+
* Streaming UTF-8 encoding
|
|
43340
|
+
*/
|
|
43341
|
+
var EncodeUTF8 = /*#__PURE__*/ (function () {
|
|
43342
|
+
/**
|
|
43343
|
+
* Creates a UTF-8 decoding stream
|
|
43344
|
+
* @param cb The callback to call whenever data is encoded
|
|
43345
|
+
*/
|
|
43346
|
+
function EncodeUTF8(cb) {
|
|
43347
|
+
this.ondata = cb;
|
|
43348
|
+
}
|
|
43349
|
+
/**
|
|
43350
|
+
* Pushes a chunk to be encoded to UTF-8
|
|
43351
|
+
* @param chunk The string data to push
|
|
43352
|
+
* @param final Whether this is the last chunk
|
|
43353
|
+
*/
|
|
43354
|
+
EncodeUTF8.prototype.push = function (chunk, final) {
|
|
43355
|
+
if (!this.ondata)
|
|
43356
|
+
err(5);
|
|
43357
|
+
if (this.d)
|
|
43358
|
+
err(4);
|
|
43359
|
+
this.ondata(strToU8(chunk), this.d = final || false);
|
|
43360
|
+
};
|
|
43361
|
+
return EncodeUTF8;
|
|
43362
|
+
}());
|
|
42202
43363
|
/**
|
|
42203
43364
|
* Converts a string into a Uint8Array for use with compression/decompression methods
|
|
42204
43365
|
* @param str The string to encode
|
|
@@ -42238,12 +43399,918 @@
|
|
|
42238
43399
|
}
|
|
42239
43400
|
return slc(ar, 0, ai);
|
|
42240
43401
|
}
|
|
43402
|
+
/**
|
|
43403
|
+
* Converts a Uint8Array to a string
|
|
43404
|
+
* @param dat The data to decode to string
|
|
43405
|
+
* @param latin1 Whether or not to interpret the data as Latin-1. This should
|
|
43406
|
+
* not need to be true unless encoding to binary string.
|
|
43407
|
+
* @returns The original UTF-8/Latin-1 string
|
|
43408
|
+
*/
|
|
43409
|
+
function strFromU8(dat, latin1) {
|
|
43410
|
+
if (latin1) {
|
|
43411
|
+
var r = '';
|
|
43412
|
+
for (var i = 0; i < dat.length; i += 16384)
|
|
43413
|
+
r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
|
|
43414
|
+
return r;
|
|
43415
|
+
}
|
|
43416
|
+
else if (td)
|
|
43417
|
+
return td.decode(dat);
|
|
43418
|
+
else {
|
|
43419
|
+
var _a = dutf8(dat), out = _a[0], ext = _a[1];
|
|
43420
|
+
if (ext.length)
|
|
43421
|
+
err(8);
|
|
43422
|
+
return out;
|
|
43423
|
+
}
|
|
43424
|
+
}
|
|
43425
|
+
// deflate bit flag
|
|
43426
|
+
var dbf = function (l) { return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0; };
|
|
43427
|
+
// skip local zip header
|
|
43428
|
+
var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };
|
|
43429
|
+
// read zip header
|
|
43430
|
+
var zh = function (d, b, z) {
|
|
43431
|
+
var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
|
|
43432
|
+
var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];
|
|
43433
|
+
return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];
|
|
43434
|
+
};
|
|
43435
|
+
// read zip64 extra field
|
|
43436
|
+
var z64e = function (d, b) {
|
|
43437
|
+
for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))
|
|
43438
|
+
;
|
|
43439
|
+
return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
|
|
43440
|
+
};
|
|
43441
|
+
// extra field length
|
|
43442
|
+
var exfl = function (ex) {
|
|
43443
|
+
var le = 0;
|
|
43444
|
+
if (ex) {
|
|
43445
|
+
for (var k in ex) {
|
|
43446
|
+
var l = ex[k].length;
|
|
43447
|
+
if (l > 65535)
|
|
43448
|
+
err(9);
|
|
43449
|
+
le += l + 4;
|
|
43450
|
+
}
|
|
43451
|
+
}
|
|
43452
|
+
return le;
|
|
43453
|
+
};
|
|
43454
|
+
// write zip header
|
|
43455
|
+
var wzh = function (d, b, f, fn, u, c, ce, co) {
|
|
43456
|
+
var fl = fn.length, ex = f.extra, col = co && co.length;
|
|
43457
|
+
var exl = exfl(ex);
|
|
43458
|
+
wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;
|
|
43459
|
+
if (ce != null)
|
|
43460
|
+
d[b++] = 20, d[b++] = f.os;
|
|
43461
|
+
d[b] = 20, b += 2; // spec compliance? what's that?
|
|
43462
|
+
d[b++] = (f.flag << 1) | (c < 0 && 8), d[b++] = u && 8;
|
|
43463
|
+
d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
|
|
43464
|
+
var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
|
|
43465
|
+
if (y < 0 || y > 119)
|
|
43466
|
+
err(10);
|
|
43467
|
+
wbytes(d, b, (y << 25) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >>> 1)), b += 4;
|
|
43468
|
+
if (c != -1) {
|
|
43469
|
+
wbytes(d, b, f.crc);
|
|
43470
|
+
wbytes(d, b + 4, c < 0 ? -c - 2 : c);
|
|
43471
|
+
wbytes(d, b + 8, f.size);
|
|
43472
|
+
}
|
|
43473
|
+
wbytes(d, b + 12, fl);
|
|
43474
|
+
wbytes(d, b + 14, exl), b += 16;
|
|
43475
|
+
if (ce != null) {
|
|
43476
|
+
wbytes(d, b, col);
|
|
43477
|
+
wbytes(d, b + 6, f.attrs);
|
|
43478
|
+
wbytes(d, b + 10, ce), b += 14;
|
|
43479
|
+
}
|
|
43480
|
+
d.set(fn, b);
|
|
43481
|
+
b += fl;
|
|
43482
|
+
if (exl) {
|
|
43483
|
+
for (var k in ex) {
|
|
43484
|
+
var exf = ex[k], l = exf.length;
|
|
43485
|
+
wbytes(d, b, +k);
|
|
43486
|
+
wbytes(d, b + 2, l);
|
|
43487
|
+
d.set(exf, b + 4), b += 4 + l;
|
|
43488
|
+
}
|
|
43489
|
+
}
|
|
43490
|
+
if (col)
|
|
43491
|
+
d.set(co, b), b += col;
|
|
43492
|
+
return b;
|
|
43493
|
+
};
|
|
43494
|
+
// write zip footer (end of central directory)
|
|
43495
|
+
var wzf = function (o, b, c, d, e) {
|
|
43496
|
+
wbytes(o, b, 0x6054B50); // skip disk
|
|
43497
|
+
wbytes(o, b + 8, c);
|
|
43498
|
+
wbytes(o, b + 10, c);
|
|
43499
|
+
wbytes(o, b + 12, d);
|
|
43500
|
+
wbytes(o, b + 16, e);
|
|
43501
|
+
};
|
|
43502
|
+
/**
|
|
43503
|
+
* A pass-through stream to keep data uncompressed in a ZIP archive.
|
|
43504
|
+
*/
|
|
43505
|
+
var ZipPassThrough = /*#__PURE__*/ (function () {
|
|
43506
|
+
/**
|
|
43507
|
+
* Creates a pass-through stream that can be added to ZIP archives
|
|
43508
|
+
* @param filename The filename to associate with this data stream
|
|
43509
|
+
*/
|
|
43510
|
+
function ZipPassThrough(filename) {
|
|
43511
|
+
this.filename = filename;
|
|
43512
|
+
this.c = crc();
|
|
43513
|
+
this.size = 0;
|
|
43514
|
+
this.compression = 0;
|
|
43515
|
+
}
|
|
43516
|
+
/**
|
|
43517
|
+
* Processes a chunk and pushes to the output stream. You can override this
|
|
43518
|
+
* method in a subclass for custom behavior, but by default this passes
|
|
43519
|
+
* the data through. You must call this.ondata(err, chunk, final) at some
|
|
43520
|
+
* point in this method.
|
|
43521
|
+
* @param chunk The chunk to process
|
|
43522
|
+
* @param final Whether this is the last chunk
|
|
43523
|
+
*/
|
|
43524
|
+
ZipPassThrough.prototype.process = function (chunk, final) {
|
|
43525
|
+
this.ondata(null, chunk, final);
|
|
43526
|
+
};
|
|
43527
|
+
/**
|
|
43528
|
+
* Pushes a chunk to be added. If you are subclassing this with a custom
|
|
43529
|
+
* compression algorithm, note that you must push data from the source
|
|
43530
|
+
* file only, pre-compression.
|
|
43531
|
+
* @param chunk The chunk to push
|
|
43532
|
+
* @param final Whether this is the last chunk
|
|
43533
|
+
*/
|
|
43534
|
+
ZipPassThrough.prototype.push = function (chunk, final) {
|
|
43535
|
+
if (!this.ondata)
|
|
43536
|
+
err(5);
|
|
43537
|
+
this.c.p(chunk);
|
|
43538
|
+
this.size += chunk.length;
|
|
43539
|
+
if (final)
|
|
43540
|
+
this.crc = this.c.d();
|
|
43541
|
+
this.process(chunk, final || false);
|
|
43542
|
+
};
|
|
43543
|
+
return ZipPassThrough;
|
|
43544
|
+
}());
|
|
43545
|
+
// I don't extend because TypeScript extension adds 1kB of runtime bloat
|
|
43546
|
+
/**
|
|
43547
|
+
* Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate
|
|
43548
|
+
* for better performance
|
|
43549
|
+
*/
|
|
43550
|
+
var ZipDeflate = /*#__PURE__*/ (function () {
|
|
43551
|
+
/**
|
|
43552
|
+
* Creates a DEFLATE stream that can be added to ZIP archives
|
|
43553
|
+
* @param filename The filename to associate with this data stream
|
|
43554
|
+
* @param opts The compression options
|
|
43555
|
+
*/
|
|
43556
|
+
function ZipDeflate(filename, opts) {
|
|
43557
|
+
var _this_1 = this;
|
|
43558
|
+
if (!opts)
|
|
43559
|
+
opts = {};
|
|
43560
|
+
ZipPassThrough.call(this, filename);
|
|
43561
|
+
this.d = new Deflate(opts, function (dat, final) {
|
|
43562
|
+
_this_1.ondata(null, dat, final);
|
|
43563
|
+
});
|
|
43564
|
+
this.compression = 8;
|
|
43565
|
+
this.flag = dbf(opts.level);
|
|
43566
|
+
}
|
|
43567
|
+
ZipDeflate.prototype.process = function (chunk, final) {
|
|
43568
|
+
try {
|
|
43569
|
+
this.d.push(chunk, final);
|
|
43570
|
+
}
|
|
43571
|
+
catch (e) {
|
|
43572
|
+
this.ondata(e, null, final);
|
|
43573
|
+
}
|
|
43574
|
+
};
|
|
43575
|
+
/**
|
|
43576
|
+
* Pushes a chunk to be deflated
|
|
43577
|
+
* @param chunk The chunk to push
|
|
43578
|
+
* @param final Whether this is the last chunk
|
|
43579
|
+
*/
|
|
43580
|
+
ZipDeflate.prototype.push = function (chunk, final) {
|
|
43581
|
+
ZipPassThrough.prototype.push.call(this, chunk, final);
|
|
43582
|
+
};
|
|
43583
|
+
return ZipDeflate;
|
|
43584
|
+
}());
|
|
43585
|
+
/**
|
|
43586
|
+
* Asynchronous streaming DEFLATE compression for ZIP archives
|
|
43587
|
+
*/
|
|
43588
|
+
var AsyncZipDeflate = /*#__PURE__*/ (function () {
|
|
43589
|
+
/**
|
|
43590
|
+
* Creates a DEFLATE stream that can be added to ZIP archives
|
|
43591
|
+
* @param filename The filename to associate with this data stream
|
|
43592
|
+
* @param opts The compression options
|
|
43593
|
+
*/
|
|
43594
|
+
function AsyncZipDeflate(filename, opts) {
|
|
43595
|
+
var _this_1 = this;
|
|
43596
|
+
if (!opts)
|
|
43597
|
+
opts = {};
|
|
43598
|
+
ZipPassThrough.call(this, filename);
|
|
43599
|
+
this.d = new AsyncDeflate(opts, function (err, dat, final) {
|
|
43600
|
+
_this_1.ondata(err, dat, final);
|
|
43601
|
+
});
|
|
43602
|
+
this.compression = 8;
|
|
43603
|
+
this.flag = dbf(opts.level);
|
|
43604
|
+
this.terminate = this.d.terminate;
|
|
43605
|
+
}
|
|
43606
|
+
AsyncZipDeflate.prototype.process = function (chunk, final) {
|
|
43607
|
+
this.d.push(chunk, final);
|
|
43608
|
+
};
|
|
43609
|
+
/**
|
|
43610
|
+
* Pushes a chunk to be deflated
|
|
43611
|
+
* @param chunk The chunk to push
|
|
43612
|
+
* @param final Whether this is the last chunk
|
|
43613
|
+
*/
|
|
43614
|
+
AsyncZipDeflate.prototype.push = function (chunk, final) {
|
|
43615
|
+
ZipPassThrough.prototype.push.call(this, chunk, final);
|
|
43616
|
+
};
|
|
43617
|
+
return AsyncZipDeflate;
|
|
43618
|
+
}());
|
|
43619
|
+
// TODO: Better tree shaking
|
|
43620
|
+
/**
|
|
43621
|
+
* A zippable archive to which files can incrementally be added
|
|
43622
|
+
*/
|
|
43623
|
+
var Zip = /*#__PURE__*/ (function () {
|
|
43624
|
+
/**
|
|
43625
|
+
* Creates an empty ZIP archive to which files can be added
|
|
43626
|
+
* @param cb The callback to call whenever data for the generated ZIP archive
|
|
43627
|
+
* is available
|
|
43628
|
+
*/
|
|
43629
|
+
function Zip(cb) {
|
|
43630
|
+
this.ondata = cb;
|
|
43631
|
+
this.u = [];
|
|
43632
|
+
this.d = 1;
|
|
43633
|
+
}
|
|
43634
|
+
/**
|
|
43635
|
+
* Adds a file to the ZIP archive
|
|
43636
|
+
* @param file The file stream to add
|
|
43637
|
+
*/
|
|
43638
|
+
Zip.prototype.add = function (file) {
|
|
43639
|
+
var _this_1 = this;
|
|
43640
|
+
if (!this.ondata)
|
|
43641
|
+
err(5);
|
|
43642
|
+
// finishing or finished
|
|
43643
|
+
if (this.d & 2)
|
|
43644
|
+
this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, false);
|
|
43645
|
+
else {
|
|
43646
|
+
var f = strToU8(file.filename), fl_1 = f.length;
|
|
43647
|
+
var com = file.comment, o = com && strToU8(com);
|
|
43648
|
+
var u = fl_1 != file.filename.length || (o && (com.length != o.length));
|
|
43649
|
+
var hl_1 = fl_1 + exfl(file.extra) + 30;
|
|
43650
|
+
if (fl_1 > 65535)
|
|
43651
|
+
this.ondata(err(11, 0, 1), null, false);
|
|
43652
|
+
var header = new u8(hl_1);
|
|
43653
|
+
wzh(header, 0, file, f, u, -1);
|
|
43654
|
+
var chks_1 = [header];
|
|
43655
|
+
var pAll_1 = function () {
|
|
43656
|
+
for (var _i = 0, chks_2 = chks_1; _i < chks_2.length; _i++) {
|
|
43657
|
+
var chk = chks_2[_i];
|
|
43658
|
+
_this_1.ondata(null, chk, false);
|
|
43659
|
+
}
|
|
43660
|
+
chks_1 = [];
|
|
43661
|
+
};
|
|
43662
|
+
var tr_1 = this.d;
|
|
43663
|
+
this.d = 0;
|
|
43664
|
+
var ind_1 = this.u.length;
|
|
43665
|
+
var uf_1 = mrg(file, {
|
|
43666
|
+
f: f,
|
|
43667
|
+
u: u,
|
|
43668
|
+
o: o,
|
|
43669
|
+
t: function () {
|
|
43670
|
+
if (file.terminate)
|
|
43671
|
+
file.terminate();
|
|
43672
|
+
},
|
|
43673
|
+
r: function () {
|
|
43674
|
+
pAll_1();
|
|
43675
|
+
if (tr_1) {
|
|
43676
|
+
var nxt = _this_1.u[ind_1 + 1];
|
|
43677
|
+
if (nxt)
|
|
43678
|
+
nxt.r();
|
|
43679
|
+
else
|
|
43680
|
+
_this_1.d = 1;
|
|
43681
|
+
}
|
|
43682
|
+
tr_1 = 1;
|
|
43683
|
+
}
|
|
43684
|
+
});
|
|
43685
|
+
var cl_1 = 0;
|
|
43686
|
+
file.ondata = function (err, dat, final) {
|
|
43687
|
+
if (err) {
|
|
43688
|
+
_this_1.ondata(err, dat, final);
|
|
43689
|
+
_this_1.terminate();
|
|
43690
|
+
}
|
|
43691
|
+
else {
|
|
43692
|
+
cl_1 += dat.length;
|
|
43693
|
+
chks_1.push(dat);
|
|
43694
|
+
if (final) {
|
|
43695
|
+
var dd = new u8(16);
|
|
43696
|
+
wbytes(dd, 0, 0x8074B50);
|
|
43697
|
+
wbytes(dd, 4, file.crc);
|
|
43698
|
+
wbytes(dd, 8, cl_1);
|
|
43699
|
+
wbytes(dd, 12, file.size);
|
|
43700
|
+
chks_1.push(dd);
|
|
43701
|
+
uf_1.c = cl_1, uf_1.b = hl_1 + cl_1 + 16, uf_1.crc = file.crc, uf_1.size = file.size;
|
|
43702
|
+
if (tr_1)
|
|
43703
|
+
uf_1.r();
|
|
43704
|
+
tr_1 = 1;
|
|
43705
|
+
}
|
|
43706
|
+
else if (tr_1)
|
|
43707
|
+
pAll_1();
|
|
43708
|
+
}
|
|
43709
|
+
};
|
|
43710
|
+
this.u.push(uf_1);
|
|
43711
|
+
}
|
|
43712
|
+
};
|
|
43713
|
+
/**
|
|
43714
|
+
* Ends the process of adding files and prepares to emit the final chunks.
|
|
43715
|
+
* This *must* be called after adding all desired files for the resulting
|
|
43716
|
+
* ZIP file to work properly.
|
|
43717
|
+
*/
|
|
43718
|
+
Zip.prototype.end = function () {
|
|
43719
|
+
var _this_1 = this;
|
|
43720
|
+
if (this.d & 2) {
|
|
43721
|
+
this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, true);
|
|
43722
|
+
return;
|
|
43723
|
+
}
|
|
43724
|
+
if (this.d)
|
|
43725
|
+
this.e();
|
|
43726
|
+
else
|
|
43727
|
+
this.u.push({
|
|
43728
|
+
r: function () {
|
|
43729
|
+
if (!(_this_1.d & 1))
|
|
43730
|
+
return;
|
|
43731
|
+
_this_1.u.splice(-1, 1);
|
|
43732
|
+
_this_1.e();
|
|
43733
|
+
},
|
|
43734
|
+
t: function () { }
|
|
43735
|
+
});
|
|
43736
|
+
this.d = 3;
|
|
43737
|
+
};
|
|
43738
|
+
Zip.prototype.e = function () {
|
|
43739
|
+
var bt = 0, l = 0, tl = 0;
|
|
43740
|
+
for (var _i = 0, _a = this.u; _i < _a.length; _i++) {
|
|
43741
|
+
var f = _a[_i];
|
|
43742
|
+
tl += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0);
|
|
43743
|
+
}
|
|
43744
|
+
var out = new u8(tl + 22);
|
|
43745
|
+
for (var _b = 0, _c = this.u; _b < _c.length; _b++) {
|
|
43746
|
+
var f = _c[_b];
|
|
43747
|
+
wzh(out, bt, f, f.f, f.u, -f.c - 2, l, f.o);
|
|
43748
|
+
bt += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0), l += f.b;
|
|
43749
|
+
}
|
|
43750
|
+
wzf(out, bt, this.u.length, tl, l);
|
|
43751
|
+
this.ondata(null, out, true);
|
|
43752
|
+
this.d = 2;
|
|
43753
|
+
};
|
|
43754
|
+
/**
|
|
43755
|
+
* A method to terminate any internal workers used by the stream. Subsequent
|
|
43756
|
+
* calls to add() will fail.
|
|
43757
|
+
*/
|
|
43758
|
+
Zip.prototype.terminate = function () {
|
|
43759
|
+
for (var _i = 0, _a = this.u; _i < _a.length; _i++) {
|
|
43760
|
+
var f = _a[_i];
|
|
43761
|
+
f.t();
|
|
43762
|
+
}
|
|
43763
|
+
this.d = 2;
|
|
43764
|
+
};
|
|
43765
|
+
return Zip;
|
|
43766
|
+
}());
|
|
43767
|
+
function zip(data, opts, cb) {
|
|
43768
|
+
if (!cb)
|
|
43769
|
+
cb = opts, opts = {};
|
|
43770
|
+
if (typeof cb != 'function')
|
|
43771
|
+
err(7);
|
|
43772
|
+
var r = {};
|
|
43773
|
+
fltn(data, '', r, opts);
|
|
43774
|
+
var k = Object.keys(r);
|
|
43775
|
+
var lft = k.length, o = 0, tot = 0;
|
|
43776
|
+
var slft = lft, files = new Array(lft);
|
|
43777
|
+
var term = [];
|
|
43778
|
+
var tAll = function () {
|
|
43779
|
+
for (var i = 0; i < term.length; ++i)
|
|
43780
|
+
term[i]();
|
|
43781
|
+
};
|
|
43782
|
+
var cbd = function (a, b) {
|
|
43783
|
+
mt(function () { cb(a, b); });
|
|
43784
|
+
};
|
|
43785
|
+
mt(function () { cbd = cb; });
|
|
43786
|
+
var cbf = function () {
|
|
43787
|
+
var out = new u8(tot + 22), oe = o, cdl = tot - o;
|
|
43788
|
+
tot = 0;
|
|
43789
|
+
for (var i = 0; i < slft; ++i) {
|
|
43790
|
+
var f = files[i];
|
|
43791
|
+
try {
|
|
43792
|
+
var l = f.c.length;
|
|
43793
|
+
wzh(out, tot, f, f.f, f.u, l);
|
|
43794
|
+
var badd = 30 + f.f.length + exfl(f.extra);
|
|
43795
|
+
var loc = tot + badd;
|
|
43796
|
+
out.set(f.c, loc);
|
|
43797
|
+
wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l;
|
|
43798
|
+
}
|
|
43799
|
+
catch (e) {
|
|
43800
|
+
return cbd(e, null);
|
|
43801
|
+
}
|
|
43802
|
+
}
|
|
43803
|
+
wzf(out, o, files.length, cdl, oe);
|
|
43804
|
+
cbd(null, out);
|
|
43805
|
+
};
|
|
43806
|
+
if (!lft)
|
|
43807
|
+
cbf();
|
|
43808
|
+
var _loop_1 = function (i) {
|
|
43809
|
+
var fn = k[i];
|
|
43810
|
+
var _a = r[fn], file = _a[0], p = _a[1];
|
|
43811
|
+
var c = crc(), size = file.length;
|
|
43812
|
+
c.p(file);
|
|
43813
|
+
var f = strToU8(fn), s = f.length;
|
|
43814
|
+
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
|
|
43815
|
+
var exl = exfl(p.extra);
|
|
43816
|
+
var compression = p.level == 0 ? 0 : 8;
|
|
43817
|
+
var cbl = function (e, d) {
|
|
43818
|
+
if (e) {
|
|
43819
|
+
tAll();
|
|
43820
|
+
cbd(e, null);
|
|
43821
|
+
}
|
|
43822
|
+
else {
|
|
43823
|
+
var l = d.length;
|
|
43824
|
+
files[i] = mrg(p, {
|
|
43825
|
+
size: size,
|
|
43826
|
+
crc: c.d(),
|
|
43827
|
+
c: d,
|
|
43828
|
+
f: f,
|
|
43829
|
+
m: m,
|
|
43830
|
+
u: s != fn.length || (m && (com.length != ms)),
|
|
43831
|
+
compression: compression
|
|
43832
|
+
});
|
|
43833
|
+
o += 30 + s + exl + l;
|
|
43834
|
+
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
|
|
43835
|
+
if (!--lft)
|
|
43836
|
+
cbf();
|
|
43837
|
+
}
|
|
43838
|
+
};
|
|
43839
|
+
if (s > 65535)
|
|
43840
|
+
cbl(err(11, 0, 1), null);
|
|
43841
|
+
if (!compression)
|
|
43842
|
+
cbl(null, file);
|
|
43843
|
+
else if (size < 160000) {
|
|
43844
|
+
try {
|
|
43845
|
+
cbl(null, deflateSync(file, p));
|
|
43846
|
+
}
|
|
43847
|
+
catch (e) {
|
|
43848
|
+
cbl(e, null);
|
|
43849
|
+
}
|
|
43850
|
+
}
|
|
43851
|
+
else
|
|
43852
|
+
term.push(deflate(file, p, cbl));
|
|
43853
|
+
};
|
|
43854
|
+
// Cannot use lft because it can decrease
|
|
43855
|
+
for (var i = 0; i < slft; ++i) {
|
|
43856
|
+
_loop_1(i);
|
|
43857
|
+
}
|
|
43858
|
+
return tAll;
|
|
43859
|
+
}
|
|
43860
|
+
/**
|
|
43861
|
+
* Synchronously creates a ZIP file. Prefer using `zip` for better performance
|
|
43862
|
+
* with more than one file.
|
|
43863
|
+
* @param data The directory structure for the ZIP archive
|
|
43864
|
+
* @param opts The main options, merged with per-file options
|
|
43865
|
+
* @returns The generated ZIP archive
|
|
43866
|
+
*/
|
|
43867
|
+
function zipSync(data, opts) {
|
|
43868
|
+
if (!opts)
|
|
43869
|
+
opts = {};
|
|
43870
|
+
var r = {};
|
|
43871
|
+
var files = [];
|
|
43872
|
+
fltn(data, '', r, opts);
|
|
43873
|
+
var o = 0;
|
|
43874
|
+
var tot = 0;
|
|
43875
|
+
for (var fn in r) {
|
|
43876
|
+
var _a = r[fn], file = _a[0], p = _a[1];
|
|
43877
|
+
var compression = p.level == 0 ? 0 : 8;
|
|
43878
|
+
var f = strToU8(fn), s = f.length;
|
|
43879
|
+
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
|
|
43880
|
+
var exl = exfl(p.extra);
|
|
43881
|
+
if (s > 65535)
|
|
43882
|
+
err(11);
|
|
43883
|
+
var d = compression ? deflateSync(file, p) : file, l = d.length;
|
|
43884
|
+
var c = crc();
|
|
43885
|
+
c.p(file);
|
|
43886
|
+
files.push(mrg(p, {
|
|
43887
|
+
size: file.length,
|
|
43888
|
+
crc: c.d(),
|
|
43889
|
+
c: d,
|
|
43890
|
+
f: f,
|
|
43891
|
+
m: m,
|
|
43892
|
+
u: s != fn.length || (m && (com.length != ms)),
|
|
43893
|
+
o: o,
|
|
43894
|
+
compression: compression
|
|
43895
|
+
}));
|
|
43896
|
+
o += 30 + s + exl + l;
|
|
43897
|
+
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
|
|
43898
|
+
}
|
|
43899
|
+
var out = new u8(tot + 22), oe = o, cdl = tot - o;
|
|
43900
|
+
for (var i = 0; i < files.length; ++i) {
|
|
43901
|
+
var f = files[i];
|
|
43902
|
+
wzh(out, f.o, f, f.f, f.u, f.c.length);
|
|
43903
|
+
var badd = 30 + f.f.length + exfl(f.extra);
|
|
43904
|
+
out.set(f.c, f.o + badd);
|
|
43905
|
+
wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
|
|
43906
|
+
}
|
|
43907
|
+
wzf(out, o, files.length, cdl, oe);
|
|
43908
|
+
return out;
|
|
43909
|
+
}
|
|
43910
|
+
/**
|
|
43911
|
+
* Streaming pass-through decompression for ZIP archives
|
|
43912
|
+
*/
|
|
43913
|
+
var UnzipPassThrough = /*#__PURE__*/ (function () {
|
|
43914
|
+
function UnzipPassThrough() {
|
|
43915
|
+
}
|
|
43916
|
+
UnzipPassThrough.prototype.push = function (data, final) {
|
|
43917
|
+
this.ondata(null, data, final);
|
|
43918
|
+
};
|
|
43919
|
+
UnzipPassThrough.compression = 0;
|
|
43920
|
+
return UnzipPassThrough;
|
|
43921
|
+
}());
|
|
43922
|
+
/**
|
|
43923
|
+
* Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for
|
|
43924
|
+
* better performance.
|
|
43925
|
+
*/
|
|
43926
|
+
var UnzipInflate = /*#__PURE__*/ (function () {
|
|
43927
|
+
/**
|
|
43928
|
+
* Creates a DEFLATE decompression that can be used in ZIP archives
|
|
43929
|
+
*/
|
|
43930
|
+
function UnzipInflate() {
|
|
43931
|
+
var _this_1 = this;
|
|
43932
|
+
this.i = new Inflate(function (dat, final) {
|
|
43933
|
+
_this_1.ondata(null, dat, final);
|
|
43934
|
+
});
|
|
43935
|
+
}
|
|
43936
|
+
UnzipInflate.prototype.push = function (data, final) {
|
|
43937
|
+
try {
|
|
43938
|
+
this.i.push(data, final);
|
|
43939
|
+
}
|
|
43940
|
+
catch (e) {
|
|
43941
|
+
this.ondata(e, null, final);
|
|
43942
|
+
}
|
|
43943
|
+
};
|
|
43944
|
+
UnzipInflate.compression = 8;
|
|
43945
|
+
return UnzipInflate;
|
|
43946
|
+
}());
|
|
43947
|
+
/**
|
|
43948
|
+
* Asynchronous streaming DEFLATE decompression for ZIP archives
|
|
43949
|
+
*/
|
|
43950
|
+
var AsyncUnzipInflate = /*#__PURE__*/ (function () {
|
|
43951
|
+
/**
|
|
43952
|
+
* Creates a DEFLATE decompression that can be used in ZIP archives
|
|
43953
|
+
*/
|
|
43954
|
+
function AsyncUnzipInflate(_, sz) {
|
|
43955
|
+
var _this_1 = this;
|
|
43956
|
+
if (sz < 320000) {
|
|
43957
|
+
this.i = new Inflate(function (dat, final) {
|
|
43958
|
+
_this_1.ondata(null, dat, final);
|
|
43959
|
+
});
|
|
43960
|
+
}
|
|
43961
|
+
else {
|
|
43962
|
+
this.i = new AsyncInflate(function (err, dat, final) {
|
|
43963
|
+
_this_1.ondata(err, dat, final);
|
|
43964
|
+
});
|
|
43965
|
+
this.terminate = this.i.terminate;
|
|
43966
|
+
}
|
|
43967
|
+
}
|
|
43968
|
+
AsyncUnzipInflate.prototype.push = function (data, final) {
|
|
43969
|
+
if (this.i.terminate)
|
|
43970
|
+
data = slc(data, 0);
|
|
43971
|
+
this.i.push(data, final);
|
|
43972
|
+
};
|
|
43973
|
+
AsyncUnzipInflate.compression = 8;
|
|
43974
|
+
return AsyncUnzipInflate;
|
|
43975
|
+
}());
|
|
43976
|
+
/**
|
|
43977
|
+
* A ZIP archive decompression stream that emits files as they are discovered
|
|
43978
|
+
*/
|
|
43979
|
+
var Unzip = /*#__PURE__*/ (function () {
|
|
43980
|
+
/**
|
|
43981
|
+
* Creates a ZIP decompression stream
|
|
43982
|
+
* @param cb The callback to call whenever a file in the ZIP archive is found
|
|
43983
|
+
*/
|
|
43984
|
+
function Unzip(cb) {
|
|
43985
|
+
this.onfile = cb;
|
|
43986
|
+
this.k = [];
|
|
43987
|
+
this.o = {
|
|
43988
|
+
0: UnzipPassThrough
|
|
43989
|
+
};
|
|
43990
|
+
this.p = et;
|
|
43991
|
+
}
|
|
43992
|
+
/**
|
|
43993
|
+
* Pushes a chunk to be unzipped
|
|
43994
|
+
* @param chunk The chunk to push
|
|
43995
|
+
* @param final Whether this is the last chunk
|
|
43996
|
+
*/
|
|
43997
|
+
Unzip.prototype.push = function (chunk, final) {
|
|
43998
|
+
var _this_1 = this;
|
|
43999
|
+
if (!this.onfile)
|
|
44000
|
+
err(5);
|
|
44001
|
+
if (!this.p)
|
|
44002
|
+
err(4);
|
|
44003
|
+
if (this.c > 0) {
|
|
44004
|
+
var len = Math.min(this.c, chunk.length);
|
|
44005
|
+
var toAdd = chunk.subarray(0, len);
|
|
44006
|
+
this.c -= len;
|
|
44007
|
+
if (this.d)
|
|
44008
|
+
this.d.push(toAdd, !this.c);
|
|
44009
|
+
else
|
|
44010
|
+
this.k[0].push(toAdd);
|
|
44011
|
+
chunk = chunk.subarray(len);
|
|
44012
|
+
if (chunk.length)
|
|
44013
|
+
return this.push(chunk, final);
|
|
44014
|
+
}
|
|
44015
|
+
else {
|
|
44016
|
+
var f = 0, i = 0, is = void 0, buf = void 0;
|
|
44017
|
+
if (!this.p.length)
|
|
44018
|
+
buf = chunk;
|
|
44019
|
+
else if (!chunk.length)
|
|
44020
|
+
buf = this.p;
|
|
44021
|
+
else {
|
|
44022
|
+
buf = new u8(this.p.length + chunk.length);
|
|
44023
|
+
buf.set(this.p), buf.set(chunk, this.p.length);
|
|
44024
|
+
}
|
|
44025
|
+
var l = buf.length, oc = this.c, add = oc && this.d;
|
|
44026
|
+
var _loop_2 = function () {
|
|
44027
|
+
var _a;
|
|
44028
|
+
var sig = b4(buf, i);
|
|
44029
|
+
if (sig == 0x4034B50) {
|
|
44030
|
+
f = 1, is = i;
|
|
44031
|
+
this_1.d = null;
|
|
44032
|
+
this_1.c = 0;
|
|
44033
|
+
var bf = b2(buf, i + 6), cmp_1 = b2(buf, i + 8), u = bf & 2048, dd = bf & 8, fnl = b2(buf, i + 26), es = b2(buf, i + 28);
|
|
44034
|
+
if (l > i + 30 + fnl + es) {
|
|
44035
|
+
var chks_3 = [];
|
|
44036
|
+
this_1.k.unshift(chks_3);
|
|
44037
|
+
f = 2;
|
|
44038
|
+
var sc_1 = b4(buf, i + 18), su_1 = b4(buf, i + 22);
|
|
44039
|
+
var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);
|
|
44040
|
+
if (sc_1 == 4294967295) {
|
|
44041
|
+
_a = dd ? [-2] : z64e(buf, i), sc_1 = _a[0], su_1 = _a[1];
|
|
44042
|
+
}
|
|
44043
|
+
else if (dd)
|
|
44044
|
+
sc_1 = -1;
|
|
44045
|
+
i += es;
|
|
44046
|
+
this_1.c = sc_1;
|
|
44047
|
+
var d_1;
|
|
44048
|
+
var file_1 = {
|
|
44049
|
+
name: fn_1,
|
|
44050
|
+
compression: cmp_1,
|
|
44051
|
+
start: function () {
|
|
44052
|
+
if (!file_1.ondata)
|
|
44053
|
+
err(5);
|
|
44054
|
+
if (!sc_1)
|
|
44055
|
+
file_1.ondata(null, et, true);
|
|
44056
|
+
else {
|
|
44057
|
+
var ctr = _this_1.o[cmp_1];
|
|
44058
|
+
if (!ctr)
|
|
44059
|
+
file_1.ondata(err(14, 'unknown compression type ' + cmp_1, 1), null, false);
|
|
44060
|
+
d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);
|
|
44061
|
+
d_1.ondata = function (err, dat, final) { file_1.ondata(err, dat, final); };
|
|
44062
|
+
for (var _i = 0, chks_4 = chks_3; _i < chks_4.length; _i++) {
|
|
44063
|
+
var dat = chks_4[_i];
|
|
44064
|
+
d_1.push(dat, false);
|
|
44065
|
+
}
|
|
44066
|
+
if (_this_1.k[0] == chks_3 && _this_1.c)
|
|
44067
|
+
_this_1.d = d_1;
|
|
44068
|
+
else
|
|
44069
|
+
d_1.push(et, true);
|
|
44070
|
+
}
|
|
44071
|
+
},
|
|
44072
|
+
terminate: function () {
|
|
44073
|
+
if (d_1 && d_1.terminate)
|
|
44074
|
+
d_1.terminate();
|
|
44075
|
+
}
|
|
44076
|
+
};
|
|
44077
|
+
if (sc_1 >= 0)
|
|
44078
|
+
file_1.size = sc_1, file_1.originalSize = su_1;
|
|
44079
|
+
this_1.onfile(file_1);
|
|
44080
|
+
}
|
|
44081
|
+
return "break";
|
|
44082
|
+
}
|
|
44083
|
+
else if (oc) {
|
|
44084
|
+
if (sig == 0x8074B50) {
|
|
44085
|
+
is = i += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;
|
|
44086
|
+
return "break";
|
|
44087
|
+
}
|
|
44088
|
+
else if (sig == 0x2014B50) {
|
|
44089
|
+
is = i -= 4, f = 3, this_1.c = 0;
|
|
44090
|
+
return "break";
|
|
44091
|
+
}
|
|
44092
|
+
}
|
|
44093
|
+
};
|
|
44094
|
+
var this_1 = this;
|
|
44095
|
+
for (; i < l - 4; ++i) {
|
|
44096
|
+
var state_1 = _loop_2();
|
|
44097
|
+
if (state_1 === "break")
|
|
44098
|
+
break;
|
|
44099
|
+
}
|
|
44100
|
+
this.p = et;
|
|
44101
|
+
if (oc < 0) {
|
|
44102
|
+
var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 0x8074B50 && 4)) : buf.subarray(0, i);
|
|
44103
|
+
if (add)
|
|
44104
|
+
add.push(dat, !!f);
|
|
44105
|
+
else
|
|
44106
|
+
this.k[+(f == 2)].push(dat);
|
|
44107
|
+
}
|
|
44108
|
+
if (f & 2)
|
|
44109
|
+
return this.push(buf.subarray(i), final);
|
|
44110
|
+
this.p = buf.subarray(i);
|
|
44111
|
+
}
|
|
44112
|
+
if (final) {
|
|
44113
|
+
if (this.c)
|
|
44114
|
+
err(13);
|
|
44115
|
+
this.p = null;
|
|
44116
|
+
}
|
|
44117
|
+
};
|
|
44118
|
+
/**
|
|
44119
|
+
* Registers a decoder with the stream, allowing for files compressed with
|
|
44120
|
+
* the compression type provided to be expanded correctly
|
|
44121
|
+
* @param decoder The decoder constructor
|
|
44122
|
+
*/
|
|
44123
|
+
Unzip.prototype.register = function (decoder) {
|
|
44124
|
+
this.o[decoder.compression] = decoder;
|
|
44125
|
+
};
|
|
44126
|
+
return Unzip;
|
|
44127
|
+
}());
|
|
44128
|
+
var mt = typeof queueMicrotask == 'function' ? queueMicrotask : typeof setTimeout == 'function' ? setTimeout : function (fn) { fn(); };
|
|
44129
|
+
function unzip(data, opts, cb) {
|
|
44130
|
+
if (!cb)
|
|
44131
|
+
cb = opts, opts = {};
|
|
44132
|
+
if (typeof cb != 'function')
|
|
44133
|
+
err(7);
|
|
44134
|
+
var term = [];
|
|
44135
|
+
var tAll = function () {
|
|
44136
|
+
for (var i = 0; i < term.length; ++i)
|
|
44137
|
+
term[i]();
|
|
44138
|
+
};
|
|
44139
|
+
var files = {};
|
|
44140
|
+
var cbd = function (a, b) {
|
|
44141
|
+
mt(function () { cb(a, b); });
|
|
44142
|
+
};
|
|
44143
|
+
mt(function () { cbd = cb; });
|
|
44144
|
+
var e = data.length - 22;
|
|
44145
|
+
for (; b4(data, e) != 0x6054B50; --e) {
|
|
44146
|
+
if (!e || data.length - e > 65558) {
|
|
44147
|
+
cbd(err(13, 0, 1), null);
|
|
44148
|
+
return tAll;
|
|
44149
|
+
}
|
|
44150
|
+
}
|
|
44151
|
+
var lft = b2(data, e + 8);
|
|
44152
|
+
if (lft) {
|
|
44153
|
+
var c = lft;
|
|
44154
|
+
var o = b4(data, e + 16);
|
|
44155
|
+
var z = o == 4294967295 || c == 65535;
|
|
44156
|
+
if (z) {
|
|
44157
|
+
var ze = b4(data, e - 12);
|
|
44158
|
+
z = b4(data, ze) == 0x6064B50;
|
|
44159
|
+
if (z) {
|
|
44160
|
+
c = lft = b4(data, ze + 32);
|
|
44161
|
+
o = b4(data, ze + 48);
|
|
44162
|
+
}
|
|
44163
|
+
}
|
|
44164
|
+
var fltr = opts && opts.filter;
|
|
44165
|
+
var _loop_3 = function (i) {
|
|
44166
|
+
var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
|
|
44167
|
+
o = no;
|
|
44168
|
+
var cbl = function (e, d) {
|
|
44169
|
+
if (e) {
|
|
44170
|
+
tAll();
|
|
44171
|
+
cbd(e, null);
|
|
44172
|
+
}
|
|
44173
|
+
else {
|
|
44174
|
+
if (d)
|
|
44175
|
+
files[fn] = d;
|
|
44176
|
+
if (!--lft)
|
|
44177
|
+
cbd(null, files);
|
|
44178
|
+
}
|
|
44179
|
+
};
|
|
44180
|
+
if (!fltr || fltr({
|
|
44181
|
+
name: fn,
|
|
44182
|
+
size: sc,
|
|
44183
|
+
originalSize: su,
|
|
44184
|
+
compression: c_1
|
|
44185
|
+
})) {
|
|
44186
|
+
if (!c_1)
|
|
44187
|
+
cbl(null, slc(data, b, b + sc));
|
|
44188
|
+
else if (c_1 == 8) {
|
|
44189
|
+
var infl = data.subarray(b, b + sc);
|
|
44190
|
+
if (sc < 320000) {
|
|
44191
|
+
try {
|
|
44192
|
+
cbl(null, inflateSync(infl, new u8(su)));
|
|
44193
|
+
}
|
|
44194
|
+
catch (e) {
|
|
44195
|
+
cbl(e, null);
|
|
44196
|
+
}
|
|
44197
|
+
}
|
|
44198
|
+
else
|
|
44199
|
+
term.push(inflate(infl, { size: su }, cbl));
|
|
44200
|
+
}
|
|
44201
|
+
else
|
|
44202
|
+
cbl(err(14, 'unknown compression type ' + c_1, 1), null);
|
|
44203
|
+
}
|
|
44204
|
+
else
|
|
44205
|
+
cbl(null, null);
|
|
44206
|
+
};
|
|
44207
|
+
for (var i = 0; i < c; ++i) {
|
|
44208
|
+
_loop_3(i);
|
|
44209
|
+
}
|
|
44210
|
+
}
|
|
44211
|
+
else
|
|
44212
|
+
cbd(null, {});
|
|
44213
|
+
return tAll;
|
|
44214
|
+
}
|
|
44215
|
+
/**
|
|
44216
|
+
* Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
|
|
44217
|
+
* performance with more than one file.
|
|
44218
|
+
* @param data The raw compressed ZIP file
|
|
44219
|
+
* @param opts The ZIP extraction options
|
|
44220
|
+
* @returns The decompressed files
|
|
44221
|
+
*/
|
|
44222
|
+
function unzipSync(data, opts) {
|
|
44223
|
+
var files = {};
|
|
44224
|
+
var e = data.length - 22;
|
|
44225
|
+
for (; b4(data, e) != 0x6054B50; --e) {
|
|
44226
|
+
if (!e || data.length - e > 65558)
|
|
44227
|
+
err(13);
|
|
44228
|
+
}
|
|
44229
|
+
var c = b2(data, e + 8);
|
|
44230
|
+
if (!c)
|
|
44231
|
+
return {};
|
|
44232
|
+
var o = b4(data, e + 16);
|
|
44233
|
+
var z = o == 4294967295 || c == 65535;
|
|
44234
|
+
if (z) {
|
|
44235
|
+
var ze = b4(data, e - 12);
|
|
44236
|
+
z = b4(data, ze) == 0x6064B50;
|
|
44237
|
+
if (z) {
|
|
44238
|
+
c = b4(data, ze + 32);
|
|
44239
|
+
o = b4(data, ze + 48);
|
|
44240
|
+
}
|
|
44241
|
+
}
|
|
44242
|
+
var fltr = opts && opts.filter;
|
|
44243
|
+
for (var i = 0; i < c; ++i) {
|
|
44244
|
+
var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
|
|
44245
|
+
o = no;
|
|
44246
|
+
if (!fltr || fltr({
|
|
44247
|
+
name: fn,
|
|
44248
|
+
size: sc,
|
|
44249
|
+
originalSize: su,
|
|
44250
|
+
compression: c_2
|
|
44251
|
+
})) {
|
|
44252
|
+
if (!c_2)
|
|
44253
|
+
files[fn] = slc(data, b, b + sc);
|
|
44254
|
+
else if (c_2 == 8)
|
|
44255
|
+
files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));
|
|
44256
|
+
else
|
|
44257
|
+
err(14, 'unknown compression type ' + c_2);
|
|
44258
|
+
}
|
|
44259
|
+
}
|
|
44260
|
+
return files;
|
|
44261
|
+
}
|
|
42241
44262
|
|
|
42242
44263
|
var browser = /*#__PURE__*/Object.freeze({
|
|
42243
44264
|
__proto__: null,
|
|
44265
|
+
AsyncCompress: AsyncGzip,
|
|
44266
|
+
AsyncDecompress: AsyncDecompress,
|
|
44267
|
+
AsyncDeflate: AsyncDeflate,
|
|
44268
|
+
AsyncGunzip: AsyncGunzip,
|
|
44269
|
+
AsyncGzip: AsyncGzip,
|
|
44270
|
+
AsyncInflate: AsyncInflate,
|
|
44271
|
+
AsyncUnzipInflate: AsyncUnzipInflate,
|
|
44272
|
+
AsyncUnzlib: AsyncUnzlib,
|
|
44273
|
+
AsyncZipDeflate: AsyncZipDeflate,
|
|
44274
|
+
AsyncZlib: AsyncZlib,
|
|
44275
|
+
Compress: Gzip,
|
|
44276
|
+
DecodeUTF8: DecodeUTF8,
|
|
44277
|
+
Decompress: Decompress,
|
|
44278
|
+
Deflate: Deflate,
|
|
44279
|
+
EncodeUTF8: EncodeUTF8,
|
|
44280
|
+
FlateErrorCode: FlateErrorCode,
|
|
44281
|
+
Gunzip: Gunzip,
|
|
44282
|
+
Gzip: Gzip,
|
|
44283
|
+
Inflate: Inflate,
|
|
44284
|
+
Unzip: Unzip,
|
|
44285
|
+
UnzipInflate: UnzipInflate,
|
|
44286
|
+
UnzipPassThrough: UnzipPassThrough,
|
|
44287
|
+
Unzlib: Unzlib,
|
|
44288
|
+
Zip: Zip,
|
|
44289
|
+
ZipDeflate: ZipDeflate,
|
|
44290
|
+
ZipPassThrough: ZipPassThrough,
|
|
44291
|
+
Zlib: Zlib,
|
|
44292
|
+
compress: gzip,
|
|
42244
44293
|
compressSync: gzipSync,
|
|
44294
|
+
decompress: decompress,
|
|
44295
|
+
decompressSync: decompressSync,
|
|
44296
|
+
deflate: deflate,
|
|
44297
|
+
deflateSync: deflateSync,
|
|
44298
|
+
gunzip: gunzip,
|
|
44299
|
+
gunzipSync: gunzipSync,
|
|
44300
|
+
gzip: gzip,
|
|
42245
44301
|
gzipSync: gzipSync,
|
|
42246
|
-
|
|
44302
|
+
inflate: inflate,
|
|
44303
|
+
inflateSync: inflateSync,
|
|
44304
|
+
strFromU8: strFromU8,
|
|
44305
|
+
strToU8: strToU8,
|
|
44306
|
+
unzip: unzip,
|
|
44307
|
+
unzipSync: unzipSync,
|
|
44308
|
+
unzlib: unzlib,
|
|
44309
|
+
unzlibSync: unzlibSync,
|
|
44310
|
+
zip: zip,
|
|
44311
|
+
zipSync: zipSync,
|
|
44312
|
+
zlib: zlib,
|
|
44313
|
+
zlibSync: zlibSync
|
|
42247
44314
|
});
|
|
42248
44315
|
|
|
42249
44316
|
exports.AfterpayCheckoutButton = AfterpayCheckoutButton;
|