docx-plus 0.0.2 → 0.0.4
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/dist/index.cjs +3630 -461
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +7 -5
- package/dist/index.iife.js +3633 -463
- package/dist/index.mjs +3622 -452
- package/dist/index.umd.js +3633 -464
- package/package.json +15 -15
package/dist/index.umd.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("xml-js"), require("hash.js"), require("nanoid/non-secure"), require("
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("xml-js"), require("hash.js"), require("nanoid/non-secure"), require("undio"), require("fflate"), require("xml")) : typeof define === "function" && define.amd ? define([
|
|
3
3
|
"exports",
|
|
4
4
|
"xml-js",
|
|
5
5
|
"hash.js",
|
|
6
6
|
"nanoid/non-secure",
|
|
7
|
-
"stream",
|
|
8
|
-
"fflate",
|
|
9
7
|
"undio",
|
|
8
|
+
"fflate",
|
|
10
9
|
"xml"
|
|
11
|
-
], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.
|
|
12
|
-
})(this, function(exports, xml_js, hash_js, nanoid_non_secure,
|
|
10
|
+
], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.docx = {}, global.xml_js, global.hash_js, global.nanoid_non_secure, global.undio, global.fflate, global.xml));
|
|
11
|
+
})(this, function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate, xml) {
|
|
13
12
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
14
13
|
//#region \0rolldown/runtime.js
|
|
15
14
|
var __create = Object.create;
|
|
@@ -33,9 +32,9 @@
|
|
|
33
32
|
enumerable: true
|
|
34
33
|
}) : target, mod));
|
|
35
34
|
//#endregion
|
|
36
|
-
hash_js = __toESM(hash_js);
|
|
37
|
-
xml = __toESM(xml);
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
35
|
+
hash_js = __toESM(hash_js, 1);
|
|
36
|
+
xml = __toESM(xml, 1);
|
|
37
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
|
|
39
38
|
function _typeof(o) {
|
|
40
39
|
"@babel/helpers - typeof";
|
|
41
40
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -45,7 +44,7 @@
|
|
|
45
44
|
}, _typeof(o);
|
|
46
45
|
}
|
|
47
46
|
//#endregion
|
|
48
|
-
//#region \0@oxc-project+runtime@0.
|
|
47
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
|
|
49
48
|
function toPrimitive(t, r) {
|
|
50
49
|
if ("object" != _typeof(t) || !t) return t;
|
|
51
50
|
var e = t[Symbol.toPrimitive];
|
|
@@ -57,13 +56,13 @@
|
|
|
57
56
|
return ("string" === r ? String : Number)(t);
|
|
58
57
|
}
|
|
59
58
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
59
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
|
|
61
60
|
function toPropertyKey(t) {
|
|
62
61
|
var i = toPrimitive(t, "string");
|
|
63
62
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
64
63
|
}
|
|
65
64
|
//#endregion
|
|
66
|
-
//#region \0@oxc-project+runtime@0.
|
|
65
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
|
|
67
66
|
function _defineProperty(e, r, t) {
|
|
68
67
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
69
68
|
value: t,
|
|
@@ -248,29 +247,6 @@
|
|
|
248
247
|
}
|
|
249
248
|
};
|
|
250
249
|
//#endregion
|
|
251
|
-
//#region \0@oxc-project+runtime@0.123.0/helpers/objectSpread2.js
|
|
252
|
-
function ownKeys(e, r) {
|
|
253
|
-
var t = Object.keys(e);
|
|
254
|
-
if (Object.getOwnPropertySymbols) {
|
|
255
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
256
|
-
r && (o = o.filter(function(r) {
|
|
257
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
258
|
-
})), t.push.apply(t, o);
|
|
259
|
-
}
|
|
260
|
-
return t;
|
|
261
|
-
}
|
|
262
|
-
function _objectSpread2(e) {
|
|
263
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
264
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
265
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
266
|
-
_defineProperty(e, r, t[r]);
|
|
267
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
268
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
return e;
|
|
272
|
-
}
|
|
273
|
-
//#endregion
|
|
274
250
|
//#region src/file/xml-components/default-attributes.ts
|
|
275
251
|
/**
|
|
276
252
|
* XML attribute components for the docx library.
|
|
@@ -364,7 +340,10 @@
|
|
|
364
340
|
* @returns Object with _attr key containing the attributes
|
|
365
341
|
*/
|
|
366
342
|
prepForXml(_) {
|
|
367
|
-
return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) =>
|
|
343
|
+
return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) => ({
|
|
344
|
+
...acc,
|
|
345
|
+
[key]: value
|
|
346
|
+
}), {}) };
|
|
368
347
|
}
|
|
369
348
|
};
|
|
370
349
|
//#endregion
|
|
@@ -4738,13 +4717,16 @@
|
|
|
4738
4717
|
* @returns An XML component representing the click hyperlink
|
|
4739
4718
|
*/
|
|
4740
4719
|
const createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
|
|
4741
|
-
attributes:
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4720
|
+
attributes: {
|
|
4721
|
+
...hasXmlNs ? { xmlns: {
|
|
4722
|
+
key: "xmlns:a",
|
|
4723
|
+
value: "http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
4724
|
+
} } : {},
|
|
4725
|
+
id: {
|
|
4726
|
+
key: "r:id",
|
|
4727
|
+
value: `rId${linkId}`
|
|
4728
|
+
}
|
|
4729
|
+
},
|
|
4748
4730
|
name: "a:hlinkClick"
|
|
4749
4731
|
});
|
|
4750
4732
|
//#endregion
|
|
@@ -4992,21 +4974,23 @@
|
|
|
4992
4974
|
super("a:graphicData");
|
|
4993
4975
|
if (mediaData.type === "wps") {
|
|
4994
4976
|
this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" }));
|
|
4995
|
-
const wps = createWpsShape(
|
|
4977
|
+
const wps = createWpsShape({
|
|
4978
|
+
...mediaData.data,
|
|
4996
4979
|
outline,
|
|
4997
4980
|
solidFill,
|
|
4998
4981
|
transformation: transform
|
|
4999
|
-
})
|
|
4982
|
+
});
|
|
5000
4983
|
this.root.push(wps);
|
|
5001
4984
|
} else if (mediaData.type === "wpg") {
|
|
5002
4985
|
this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" }));
|
|
5003
4986
|
const wpg = createWpgGroup({
|
|
5004
4987
|
children: mediaData.children.map((child) => {
|
|
5005
|
-
if (child.type === "wps") return createWpsShape(
|
|
4988
|
+
if (child.type === "wps") return createWpsShape({
|
|
4989
|
+
...child.data,
|
|
5006
4990
|
outline: child.outline,
|
|
5007
4991
|
solidFill: child.solidFill,
|
|
5008
4992
|
transformation: child.transformation
|
|
5009
|
-
})
|
|
4993
|
+
});
|
|
5010
4994
|
else return new Pic({
|
|
5011
4995
|
mediaData: child,
|
|
5012
4996
|
outline: child.outline,
|
|
@@ -5635,14 +5619,15 @@
|
|
|
5635
5619
|
var Anchor = class extends XmlComponent {
|
|
5636
5620
|
constructor({ mediaData, transform, drawingOptions }) {
|
|
5637
5621
|
super("wp:anchor");
|
|
5638
|
-
const floating =
|
|
5622
|
+
const floating = {
|
|
5639
5623
|
allowOverlap: true,
|
|
5640
5624
|
behindDocument: false,
|
|
5641
5625
|
horizontalPosition: {},
|
|
5642
5626
|
layoutInCell: true,
|
|
5643
5627
|
lockAnchor: false,
|
|
5644
|
-
verticalPosition: {}
|
|
5645
|
-
|
|
5628
|
+
verticalPosition: {},
|
|
5629
|
+
...drawingOptions.floating
|
|
5630
|
+
};
|
|
5646
5631
|
this.root.push(new AnchorAttributes({
|
|
5647
5632
|
distT: floating.margins ? floating.margins.top || 0 : 0,
|
|
5648
5633
|
distB: floating.margins ? floating.margins.bottom || 0 : 0,
|
|
@@ -5782,29 +5767,20 @@
|
|
|
5782
5767
|
};
|
|
5783
5768
|
//#endregion
|
|
5784
5769
|
//#region src/file/paragraph/run/image-run.ts
|
|
5785
|
-
const
|
|
5786
|
-
|
|
5787
|
-
const base64IndexWithOffset = base64Index === -1 ? 0 : base64Index + 8;
|
|
5788
|
-
const binaryString = atob(dataURI.substring(base64IndexWithOffset));
|
|
5789
|
-
const bytes = new Uint8Array(binaryString.length);
|
|
5790
|
-
for (let i = 0; i < binaryString.length; i++) bytes[i] = binaryString.charCodeAt(i);
|
|
5791
|
-
return bytes;
|
|
5792
|
-
};
|
|
5793
|
-
const standardizeData = (data) => typeof data === "string" ? convertDataURIToBinary(data) : data;
|
|
5794
|
-
const createImageData = (options, key) => ({
|
|
5795
|
-
data: standardizeData(options.data),
|
|
5770
|
+
const createImageData = (data, transformation, key) => ({
|
|
5771
|
+
data,
|
|
5796
5772
|
fileName: key,
|
|
5797
5773
|
transformation: {
|
|
5798
5774
|
emus: {
|
|
5799
|
-
x: Math.round(
|
|
5800
|
-
y: Math.round(
|
|
5775
|
+
x: Math.round(transformation.width * 9525),
|
|
5776
|
+
y: Math.round(transformation.height * 9525)
|
|
5801
5777
|
},
|
|
5802
|
-
flip:
|
|
5778
|
+
flip: transformation.flip,
|
|
5803
5779
|
pixels: {
|
|
5804
|
-
x: Math.round(
|
|
5805
|
-
y: Math.round(
|
|
5780
|
+
x: Math.round(transformation.width),
|
|
5781
|
+
y: Math.round(transformation.height)
|
|
5806
5782
|
},
|
|
5807
|
-
rotation:
|
|
5783
|
+
rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
|
|
5808
5784
|
}
|
|
5809
5785
|
});
|
|
5810
5786
|
/**
|
|
@@ -5833,8 +5809,22 @@
|
|
|
5833
5809
|
constructor(options) {
|
|
5834
5810
|
super({});
|
|
5835
5811
|
_defineProperty(this, "imageData", void 0);
|
|
5836
|
-
const
|
|
5837
|
-
|
|
5812
|
+
const rawData = (0, undio.toUint8Array)(options.data);
|
|
5813
|
+
const key = `${hashedId(rawData)}.${options.type}`;
|
|
5814
|
+
if (options.type === "svg") {
|
|
5815
|
+
const fallbackData = (0, undio.toUint8Array)(options.fallback.data);
|
|
5816
|
+
this.imageData = {
|
|
5817
|
+
type: options.type,
|
|
5818
|
+
...createImageData(rawData, options.transformation, key),
|
|
5819
|
+
fallback: {
|
|
5820
|
+
type: options.fallback.type,
|
|
5821
|
+
...createImageData(fallbackData, options.transformation, `${hashedId(fallbackData)}.${options.fallback.type}`)
|
|
5822
|
+
}
|
|
5823
|
+
};
|
|
5824
|
+
} else this.imageData = {
|
|
5825
|
+
type: options.type,
|
|
5826
|
+
...createImageData(rawData, options.transformation, key)
|
|
5827
|
+
};
|
|
5838
5828
|
const drawing = new Drawing(this.imageData, {
|
|
5839
5829
|
docProperties: options.altText,
|
|
5840
5830
|
floating: options.floating,
|
|
@@ -5883,7 +5873,7 @@
|
|
|
5883
5873
|
super({});
|
|
5884
5874
|
_defineProperty(this, "wpsShapeData", void 0);
|
|
5885
5875
|
this.wpsShapeData = {
|
|
5886
|
-
data:
|
|
5876
|
+
data: { ...options },
|
|
5887
5877
|
transformation: createTransformation(options.transformation),
|
|
5888
5878
|
type: options.type
|
|
5889
5879
|
};
|
|
@@ -7910,13 +7900,16 @@
|
|
|
7910
7900
|
* Creates a font relationship element for embedding fonts.
|
|
7911
7901
|
*/
|
|
7912
7902
|
const createFontRelationship = ({ id, fontKey, subsetted }, name) => new BuilderElement({
|
|
7913
|
-
attributes:
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7903
|
+
attributes: {
|
|
7904
|
+
id: {
|
|
7905
|
+
key: "r:id",
|
|
7906
|
+
value: id
|
|
7907
|
+
},
|
|
7908
|
+
...fontKey ? { fontKey: {
|
|
7909
|
+
key: "w:fontKey",
|
|
7910
|
+
value: `{${fontKey}}`
|
|
7911
|
+
} } : {}
|
|
7912
|
+
},
|
|
7920
7913
|
children: subsetted ? [new OnOffElement("w:subsetted", subsetted)] : [],
|
|
7921
7914
|
name
|
|
7922
7915
|
});
|
|
@@ -8154,7 +8147,10 @@
|
|
|
8154
8147
|
_defineProperty(this, "fontTable", void 0);
|
|
8155
8148
|
_defineProperty(this, "relationships", void 0);
|
|
8156
8149
|
_defineProperty(this, "fontOptionsWithKey", []);
|
|
8157
|
-
this.fontOptionsWithKey = options.map((o) =>
|
|
8150
|
+
this.fontOptionsWithKey = options.map((o) => ({
|
|
8151
|
+
...o,
|
|
8152
|
+
fontKey: uniqueUuid()
|
|
8153
|
+
}));
|
|
8158
8154
|
this.fontTable = createFontTable(this.fontOptionsWithKey);
|
|
8159
8155
|
this.relationships = new Relationships();
|
|
8160
8156
|
for (let i = 0; i < options.length; i++) this.relationships.addRelationship(i + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font", `fonts/${options[i].name}.odttf`);
|
|
@@ -8572,7 +8568,10 @@
|
|
|
8572
8568
|
date: options.date,
|
|
8573
8569
|
id: options.id
|
|
8574
8570
|
}));
|
|
8575
|
-
this.root.push(new ParagraphProperties(
|
|
8571
|
+
this.root.push(new ParagraphProperties({
|
|
8572
|
+
...options,
|
|
8573
|
+
includeIfEmpty: true
|
|
8574
|
+
}));
|
|
8576
8575
|
}
|
|
8577
8576
|
};
|
|
8578
8577
|
//#endregion
|
|
@@ -10787,7 +10786,10 @@
|
|
|
10787
10786
|
*
|
|
10788
10787
|
* @publicApi
|
|
10789
10788
|
*/
|
|
10790
|
-
const VerticalAlignSection =
|
|
10789
|
+
const VerticalAlignSection = {
|
|
10790
|
+
...VerticalAlignTable,
|
|
10791
|
+
BOTH: "both"
|
|
10792
|
+
};
|
|
10791
10793
|
/**
|
|
10792
10794
|
* @deprecated Use {@link VerticalAlignTable} for table cells or
|
|
10793
10795
|
* {@link VerticalAlignSection} for section properties. This alias remains for
|
|
@@ -11304,7 +11306,10 @@
|
|
|
11304
11306
|
date: options.date,
|
|
11305
11307
|
id: options.id
|
|
11306
11308
|
}));
|
|
11307
|
-
this.root.push(new TableCellProperties(
|
|
11309
|
+
this.root.push(new TableCellProperties({
|
|
11310
|
+
...options,
|
|
11311
|
+
includeIfEmpty: true
|
|
11312
|
+
}));
|
|
11308
11313
|
}
|
|
11309
11314
|
};
|
|
11310
11315
|
//#endregion
|
|
@@ -11848,7 +11853,10 @@
|
|
|
11848
11853
|
date: options.date,
|
|
11849
11854
|
id: options.id
|
|
11850
11855
|
}));
|
|
11851
|
-
this.root.push(new TableProperties(
|
|
11856
|
+
this.root.push(new TableProperties({
|
|
11857
|
+
...options,
|
|
11858
|
+
includeIfEmpty: true
|
|
11859
|
+
}));
|
|
11852
11860
|
}
|
|
11853
11861
|
};
|
|
11854
11862
|
//#endregion
|
|
@@ -12093,7 +12101,10 @@
|
|
|
12093
12101
|
date: options.date,
|
|
12094
12102
|
id: options.id
|
|
12095
12103
|
}));
|
|
12096
|
-
this.root.push(new TableRowProperties(
|
|
12104
|
+
this.root.push(new TableRowProperties({
|
|
12105
|
+
...options,
|
|
12106
|
+
includeIfEmpty: true
|
|
12107
|
+
}));
|
|
12097
12108
|
}
|
|
12098
12109
|
};
|
|
12099
12110
|
//#endregion
|
|
@@ -12492,8 +12503,14 @@
|
|
|
12492
12503
|
*/
|
|
12493
12504
|
var DocumentAttributes = class extends XmlAttributeComponent {
|
|
12494
12505
|
constructor(ns, Ignorable) {
|
|
12495
|
-
super(
|
|
12496
|
-
|
|
12506
|
+
super({
|
|
12507
|
+
Ignorable,
|
|
12508
|
+
...Object.fromEntries(ns.map((n) => [n, DocumentAttributeNamespaces[n]]))
|
|
12509
|
+
});
|
|
12510
|
+
_defineProperty(this, "xmlKeys", {
|
|
12511
|
+
Ignorable: "mc:Ignorable",
|
|
12512
|
+
...Object.fromEntries(Object.keys(DocumentAttributeNamespaces).map((key) => [key, `xmlns:${key}`]))
|
|
12513
|
+
});
|
|
12497
12514
|
}
|
|
12498
12515
|
};
|
|
12499
12516
|
//#endregion
|
|
@@ -16173,7 +16190,10 @@
|
|
|
16173
16190
|
if (((_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.hyphenationZone) !== void 0) this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone));
|
|
16174
16191
|
if (((_options$hyphenation3 = options.hyphenation) === null || _options$hyphenation3 === void 0 ? void 0 : _options$hyphenation3.consecutiveHyphenLimit) !== void 0) this.root.push(new NumberValueElement("w:consecutiveHyphenLimit", options.hyphenation.consecutiveHyphenLimit));
|
|
16175
16192
|
if (((_options$hyphenation4 = options.hyphenation) === null || _options$hyphenation4 === void 0 ? void 0 : _options$hyphenation4.doNotHyphenateCaps) !== void 0) this.root.push(new OnOffElement("w:doNotHyphenateCaps", options.hyphenation.doNotHyphenateCaps));
|
|
16176
|
-
this.root.push(new Compatibility(
|
|
16193
|
+
this.root.push(new Compatibility({
|
|
16194
|
+
...options.compatibility,
|
|
16195
|
+
version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15
|
|
16196
|
+
}));
|
|
16177
16197
|
}
|
|
16178
16198
|
};
|
|
16179
16199
|
//#endregion
|
|
@@ -16442,10 +16462,11 @@
|
|
|
16442
16462
|
super({
|
|
16443
16463
|
styleId: options.id,
|
|
16444
16464
|
type: "character"
|
|
16445
|
-
},
|
|
16465
|
+
}, {
|
|
16446
16466
|
uiPriority: 99,
|
|
16447
|
-
unhideWhenUsed: true
|
|
16448
|
-
|
|
16467
|
+
unhideWhenUsed: true,
|
|
16468
|
+
...options
|
|
16469
|
+
});
|
|
16449
16470
|
_defineProperty(this, "runProperties", void 0);
|
|
16450
16471
|
this.runProperties = new RunProperties(options.run);
|
|
16451
16472
|
this.root.push(this.runProperties);
|
|
@@ -16481,11 +16502,12 @@
|
|
|
16481
16502
|
*/
|
|
16482
16503
|
var HeadingStyle = class extends StyleForParagraph {
|
|
16483
16504
|
constructor(options) {
|
|
16484
|
-
super(
|
|
16505
|
+
super({
|
|
16485
16506
|
basedOn: "Normal",
|
|
16486
16507
|
next: "Normal",
|
|
16487
|
-
quickFormat: true
|
|
16488
|
-
|
|
16508
|
+
quickFormat: true,
|
|
16509
|
+
...options
|
|
16510
|
+
});
|
|
16489
16511
|
}
|
|
16490
16512
|
};
|
|
16491
16513
|
/**
|
|
@@ -16502,10 +16524,11 @@
|
|
|
16502
16524
|
*/
|
|
16503
16525
|
var TitleStyle = class extends HeadingStyle {
|
|
16504
16526
|
constructor(options) {
|
|
16505
|
-
super(
|
|
16527
|
+
super({
|
|
16506
16528
|
id: "Title",
|
|
16507
|
-
name: "Title"
|
|
16508
|
-
|
|
16529
|
+
name: "Title",
|
|
16530
|
+
...options
|
|
16531
|
+
});
|
|
16509
16532
|
}
|
|
16510
16533
|
};
|
|
16511
16534
|
/**
|
|
@@ -16522,10 +16545,11 @@
|
|
|
16522
16545
|
*/
|
|
16523
16546
|
var Heading1Style = class extends HeadingStyle {
|
|
16524
16547
|
constructor(options) {
|
|
16525
|
-
super(
|
|
16548
|
+
super({
|
|
16526
16549
|
id: "Heading1",
|
|
16527
|
-
name: "Heading 1"
|
|
16528
|
-
|
|
16550
|
+
name: "Heading 1",
|
|
16551
|
+
...options
|
|
16552
|
+
});
|
|
16529
16553
|
}
|
|
16530
16554
|
};
|
|
16531
16555
|
/**
|
|
@@ -16535,10 +16559,11 @@
|
|
|
16535
16559
|
*/
|
|
16536
16560
|
var Heading2Style = class extends HeadingStyle {
|
|
16537
16561
|
constructor(options) {
|
|
16538
|
-
super(
|
|
16562
|
+
super({
|
|
16539
16563
|
id: "Heading2",
|
|
16540
|
-
name: "Heading 2"
|
|
16541
|
-
|
|
16564
|
+
name: "Heading 2",
|
|
16565
|
+
...options
|
|
16566
|
+
});
|
|
16542
16567
|
}
|
|
16543
16568
|
};
|
|
16544
16569
|
/**
|
|
@@ -16548,10 +16573,11 @@
|
|
|
16548
16573
|
*/
|
|
16549
16574
|
var Heading3Style = class extends HeadingStyle {
|
|
16550
16575
|
constructor(options) {
|
|
16551
|
-
super(
|
|
16576
|
+
super({
|
|
16552
16577
|
id: "Heading3",
|
|
16553
|
-
name: "Heading 3"
|
|
16554
|
-
|
|
16578
|
+
name: "Heading 3",
|
|
16579
|
+
...options
|
|
16580
|
+
});
|
|
16555
16581
|
}
|
|
16556
16582
|
};
|
|
16557
16583
|
/**
|
|
@@ -16561,10 +16587,11 @@
|
|
|
16561
16587
|
*/
|
|
16562
16588
|
var Heading4Style = class extends HeadingStyle {
|
|
16563
16589
|
constructor(options) {
|
|
16564
|
-
super(
|
|
16590
|
+
super({
|
|
16565
16591
|
id: "Heading4",
|
|
16566
|
-
name: "Heading 4"
|
|
16567
|
-
|
|
16592
|
+
name: "Heading 4",
|
|
16593
|
+
...options
|
|
16594
|
+
});
|
|
16568
16595
|
}
|
|
16569
16596
|
};
|
|
16570
16597
|
/**
|
|
@@ -16574,10 +16601,11 @@
|
|
|
16574
16601
|
*/
|
|
16575
16602
|
var Heading5Style = class extends HeadingStyle {
|
|
16576
16603
|
constructor(options) {
|
|
16577
|
-
super(
|
|
16604
|
+
super({
|
|
16578
16605
|
id: "Heading5",
|
|
16579
|
-
name: "Heading 5"
|
|
16580
|
-
|
|
16606
|
+
name: "Heading 5",
|
|
16607
|
+
...options
|
|
16608
|
+
});
|
|
16581
16609
|
}
|
|
16582
16610
|
};
|
|
16583
16611
|
/**
|
|
@@ -16587,10 +16615,11 @@
|
|
|
16587
16615
|
*/
|
|
16588
16616
|
var Heading6Style = class extends HeadingStyle {
|
|
16589
16617
|
constructor(options) {
|
|
16590
|
-
super(
|
|
16618
|
+
super({
|
|
16591
16619
|
id: "Heading6",
|
|
16592
|
-
name: "Heading 6"
|
|
16593
|
-
|
|
16620
|
+
name: "Heading 6",
|
|
16621
|
+
...options
|
|
16622
|
+
});
|
|
16594
16623
|
}
|
|
16595
16624
|
};
|
|
16596
16625
|
/**
|
|
@@ -16600,10 +16629,11 @@
|
|
|
16600
16629
|
*/
|
|
16601
16630
|
var StrongStyle = class extends HeadingStyle {
|
|
16602
16631
|
constructor(options) {
|
|
16603
|
-
super(
|
|
16632
|
+
super({
|
|
16604
16633
|
id: "Strong",
|
|
16605
|
-
name: "Strong"
|
|
16606
|
-
|
|
16634
|
+
name: "Strong",
|
|
16635
|
+
...options
|
|
16636
|
+
});
|
|
16607
16637
|
}
|
|
16608
16638
|
};
|
|
16609
16639
|
/**
|
|
@@ -16613,12 +16643,13 @@
|
|
|
16613
16643
|
*/
|
|
16614
16644
|
var ListParagraph = class extends StyleForParagraph {
|
|
16615
16645
|
constructor(options) {
|
|
16616
|
-
super(
|
|
16646
|
+
super({
|
|
16617
16647
|
basedOn: "Normal",
|
|
16618
16648
|
id: "ListParagraph",
|
|
16619
16649
|
name: "List Paragraph",
|
|
16620
|
-
quickFormat: true
|
|
16621
|
-
|
|
16650
|
+
quickFormat: true,
|
|
16651
|
+
...options
|
|
16652
|
+
});
|
|
16622
16653
|
}
|
|
16623
16654
|
};
|
|
16624
16655
|
/**
|
|
@@ -16628,7 +16659,7 @@
|
|
|
16628
16659
|
*/
|
|
16629
16660
|
var FootnoteText = class extends StyleForParagraph {
|
|
16630
16661
|
constructor(options) {
|
|
16631
|
-
super(
|
|
16662
|
+
super({
|
|
16632
16663
|
basedOn: "Normal",
|
|
16633
16664
|
id: "FootnoteText",
|
|
16634
16665
|
link: "FootnoteTextChar",
|
|
@@ -16641,8 +16672,9 @@
|
|
|
16641
16672
|
run: { size: 20 },
|
|
16642
16673
|
semiHidden: true,
|
|
16643
16674
|
uiPriority: 99,
|
|
16644
|
-
unhideWhenUsed: true
|
|
16645
|
-
|
|
16675
|
+
unhideWhenUsed: true,
|
|
16676
|
+
...options
|
|
16677
|
+
});
|
|
16646
16678
|
}
|
|
16647
16679
|
};
|
|
16648
16680
|
/**
|
|
@@ -16652,13 +16684,14 @@
|
|
|
16652
16684
|
*/
|
|
16653
16685
|
var FootnoteReferenceStyle = class extends StyleForCharacter {
|
|
16654
16686
|
constructor(options) {
|
|
16655
|
-
super(
|
|
16687
|
+
super({
|
|
16656
16688
|
basedOn: "DefaultParagraphFont",
|
|
16657
16689
|
id: "FootnoteReference",
|
|
16658
16690
|
name: "footnote reference",
|
|
16659
16691
|
run: { superScript: true },
|
|
16660
|
-
semiHidden: true
|
|
16661
|
-
|
|
16692
|
+
semiHidden: true,
|
|
16693
|
+
...options
|
|
16694
|
+
});
|
|
16662
16695
|
}
|
|
16663
16696
|
};
|
|
16664
16697
|
/**
|
|
@@ -16668,14 +16701,15 @@
|
|
|
16668
16701
|
*/
|
|
16669
16702
|
var FootnoteTextChar = class extends StyleForCharacter {
|
|
16670
16703
|
constructor(options) {
|
|
16671
|
-
super(
|
|
16704
|
+
super({
|
|
16672
16705
|
basedOn: "DefaultParagraphFont",
|
|
16673
16706
|
id: "FootnoteTextChar",
|
|
16674
16707
|
link: "FootnoteText",
|
|
16675
16708
|
name: "Footnote Text Char",
|
|
16676
16709
|
run: { size: 20 },
|
|
16677
|
-
semiHidden: true
|
|
16678
|
-
|
|
16710
|
+
semiHidden: true,
|
|
16711
|
+
...options
|
|
16712
|
+
});
|
|
16679
16713
|
}
|
|
16680
16714
|
};
|
|
16681
16715
|
/**
|
|
@@ -16685,7 +16719,7 @@
|
|
|
16685
16719
|
*/
|
|
16686
16720
|
var EndnoteText = class extends StyleForParagraph {
|
|
16687
16721
|
constructor(options) {
|
|
16688
|
-
super(
|
|
16722
|
+
super({
|
|
16689
16723
|
basedOn: "Normal",
|
|
16690
16724
|
id: "EndnoteText",
|
|
16691
16725
|
link: "EndnoteTextChar",
|
|
@@ -16698,8 +16732,9 @@
|
|
|
16698
16732
|
run: { size: 20 },
|
|
16699
16733
|
semiHidden: true,
|
|
16700
16734
|
uiPriority: 99,
|
|
16701
|
-
unhideWhenUsed: true
|
|
16702
|
-
|
|
16735
|
+
unhideWhenUsed: true,
|
|
16736
|
+
...options
|
|
16737
|
+
});
|
|
16703
16738
|
}
|
|
16704
16739
|
};
|
|
16705
16740
|
/**
|
|
@@ -16709,13 +16744,14 @@
|
|
|
16709
16744
|
*/
|
|
16710
16745
|
var EndnoteReferenceStyle = class extends StyleForCharacter {
|
|
16711
16746
|
constructor(options) {
|
|
16712
|
-
super(
|
|
16747
|
+
super({
|
|
16713
16748
|
basedOn: "DefaultParagraphFont",
|
|
16714
16749
|
id: "EndnoteReference",
|
|
16715
16750
|
name: "endnote reference",
|
|
16716
16751
|
run: { superScript: true },
|
|
16717
|
-
semiHidden: true
|
|
16718
|
-
|
|
16752
|
+
semiHidden: true,
|
|
16753
|
+
...options
|
|
16754
|
+
});
|
|
16719
16755
|
}
|
|
16720
16756
|
};
|
|
16721
16757
|
/**
|
|
@@ -16725,14 +16761,15 @@
|
|
|
16725
16761
|
*/
|
|
16726
16762
|
var EndnoteTextChar = class extends StyleForCharacter {
|
|
16727
16763
|
constructor(options) {
|
|
16728
|
-
super(
|
|
16764
|
+
super({
|
|
16729
16765
|
basedOn: "DefaultParagraphFont",
|
|
16730
16766
|
id: "EndnoteTextChar",
|
|
16731
16767
|
link: "EndnoteText",
|
|
16732
16768
|
name: "Endnote Text Char",
|
|
16733
16769
|
run: { size: 20 },
|
|
16734
|
-
semiHidden: true
|
|
16735
|
-
|
|
16770
|
+
semiHidden: true,
|
|
16771
|
+
...options
|
|
16772
|
+
});
|
|
16736
16773
|
}
|
|
16737
16774
|
};
|
|
16738
16775
|
/**
|
|
@@ -16742,15 +16779,16 @@
|
|
|
16742
16779
|
*/
|
|
16743
16780
|
var HyperlinkStyle = class extends StyleForCharacter {
|
|
16744
16781
|
constructor(options) {
|
|
16745
|
-
super(
|
|
16782
|
+
super({
|
|
16746
16783
|
basedOn: "DefaultParagraphFont",
|
|
16747
16784
|
id: "Hyperlink",
|
|
16748
16785
|
name: "Hyperlink",
|
|
16749
16786
|
run: {
|
|
16750
16787
|
color: "0563C1",
|
|
16751
16788
|
underline: { type: UnderlineType.SINGLE }
|
|
16752
|
-
}
|
|
16753
|
-
|
|
16789
|
+
},
|
|
16790
|
+
...options
|
|
16791
|
+
});
|
|
16754
16792
|
}
|
|
16755
16793
|
};
|
|
16756
16794
|
//#endregion
|
|
@@ -17020,26 +17058,50 @@
|
|
|
17020
17058
|
return {
|
|
17021
17059
|
importedStyles: [
|
|
17022
17060
|
new DocumentDefaults((_options$document = options.document) !== null && _options$document !== void 0 ? _options$document : {}),
|
|
17023
|
-
new TitleStyle(
|
|
17024
|
-
|
|
17025
|
-
|
|
17026
|
-
|
|
17027
|
-
|
|
17028
|
-
|
|
17029
|
-
|
|
17030
|
-
|
|
17031
|
-
|
|
17032
|
-
|
|
17033
|
-
|
|
17034
|
-
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17039
|
-
|
|
17040
|
-
|
|
17041
|
-
new
|
|
17042
|
-
|
|
17061
|
+
new TitleStyle({
|
|
17062
|
+
run: { size: 56 },
|
|
17063
|
+
...options.title
|
|
17064
|
+
}),
|
|
17065
|
+
new Heading1Style({
|
|
17066
|
+
run: {
|
|
17067
|
+
color: "2E74B5",
|
|
17068
|
+
size: 32
|
|
17069
|
+
},
|
|
17070
|
+
...options.heading1
|
|
17071
|
+
}),
|
|
17072
|
+
new Heading2Style({
|
|
17073
|
+
run: {
|
|
17074
|
+
color: "2E74B5",
|
|
17075
|
+
size: 26
|
|
17076
|
+
},
|
|
17077
|
+
...options.heading2
|
|
17078
|
+
}),
|
|
17079
|
+
new Heading3Style({
|
|
17080
|
+
run: {
|
|
17081
|
+
color: "1F4D78",
|
|
17082
|
+
size: 24
|
|
17083
|
+
},
|
|
17084
|
+
...options.heading3
|
|
17085
|
+
}),
|
|
17086
|
+
new Heading4Style({
|
|
17087
|
+
run: {
|
|
17088
|
+
color: "2E74B5",
|
|
17089
|
+
italics: true
|
|
17090
|
+
},
|
|
17091
|
+
...options.heading4
|
|
17092
|
+
}),
|
|
17093
|
+
new Heading5Style({
|
|
17094
|
+
run: { color: "2E74B5" },
|
|
17095
|
+
...options.heading5
|
|
17096
|
+
}),
|
|
17097
|
+
new Heading6Style({
|
|
17098
|
+
run: { color: "1F4D78" },
|
|
17099
|
+
...options.heading6
|
|
17100
|
+
}),
|
|
17101
|
+
new StrongStyle({
|
|
17102
|
+
run: { bold: true },
|
|
17103
|
+
...options.strong
|
|
17104
|
+
}),
|
|
17043
17105
|
new ListParagraph(options.listParagraph || {}),
|
|
17044
17106
|
new HyperlinkStyle(options.hyperlink || {}),
|
|
17045
17107
|
new FootnoteReferenceStyle(options.footnoteReference || {}),
|
|
@@ -17157,11 +17219,12 @@
|
|
|
17157
17219
|
_defineProperty(this, "styles", void 0);
|
|
17158
17220
|
_defineProperty(this, "comments", void 0);
|
|
17159
17221
|
_defineProperty(this, "fontWrapper", void 0);
|
|
17160
|
-
this.coreProperties = new CoreProperties(
|
|
17222
|
+
this.coreProperties = new CoreProperties({
|
|
17223
|
+
...options,
|
|
17161
17224
|
creator: (_options$creator = options.creator) !== null && _options$creator !== void 0 ? _options$creator : "Un-named",
|
|
17162
17225
|
lastModifiedBy: (_options$lastModified = options.lastModifiedBy) !== null && _options$lastModified !== void 0 ? _options$lastModified : "Un-named",
|
|
17163
17226
|
revision: (_options$revision = options.revision) !== null && _options$revision !== void 0 ? _options$revision : 1
|
|
17164
|
-
})
|
|
17227
|
+
});
|
|
17165
17228
|
this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] });
|
|
17166
17229
|
this.comments = new Comments((_options$comments = options.comments) !== null && _options$comments !== void 0 ? _options$comments : { children: [] });
|
|
17167
17230
|
this.fileRelationships = new Relationships();
|
|
@@ -17190,8 +17253,14 @@
|
|
|
17190
17253
|
var _options$styles;
|
|
17191
17254
|
const defaultStyles = new DefaultStylesFactory().newInstance((_options$styles = options.styles) === null || _options$styles === void 0 ? void 0 : _options$styles.default);
|
|
17192
17255
|
const externalStyles = new ExternalStylesFactory().newInstance(options.externalStyles);
|
|
17193
|
-
this.styles = new Styles(
|
|
17194
|
-
|
|
17256
|
+
this.styles = new Styles({
|
|
17257
|
+
...externalStyles,
|
|
17258
|
+
importedStyles: [...defaultStyles.importedStyles, ...externalStyles.importedStyles]
|
|
17259
|
+
});
|
|
17260
|
+
} else if (options.styles) this.styles = new Styles({
|
|
17261
|
+
...new DefaultStylesFactory().newInstance(options.styles.default),
|
|
17262
|
+
...options.styles
|
|
17263
|
+
});
|
|
17195
17264
|
else this.styles = new Styles(new DefaultStylesFactory().newInstance());
|
|
17196
17265
|
this.addDefaultRelationships();
|
|
17197
17266
|
for (const section of options.sections) this.addSection(section);
|
|
@@ -17200,7 +17269,8 @@
|
|
|
17200
17269
|
this.fontWrapper = new FontWrapper((_options$fonts = options.fonts) !== null && _options$fonts !== void 0 ? _options$fonts : []);
|
|
17201
17270
|
}
|
|
17202
17271
|
addSection({ headers = {}, footers = {}, children, properties }) {
|
|
17203
|
-
this.documentWrapper.View.Body.addSection(
|
|
17272
|
+
this.documentWrapper.View.Body.addSection({
|
|
17273
|
+
...properties,
|
|
17204
17274
|
footerWrapperGroup: {
|
|
17205
17275
|
default: footers.default ? this.createFooter(footers.default) : void 0,
|
|
17206
17276
|
even: footers.even ? this.createFooter(footers.even) : void 0,
|
|
@@ -17211,7 +17281,7 @@
|
|
|
17211
17281
|
even: headers.even ? this.createHeader(headers.even) : void 0,
|
|
17212
17282
|
first: headers.first ? this.createHeader(headers.first) : void 0
|
|
17213
17283
|
}
|
|
17214
|
-
})
|
|
17284
|
+
});
|
|
17215
17285
|
for (const child of children) this.documentWrapper.View.add(child);
|
|
17216
17286
|
}
|
|
17217
17287
|
createHeader(header) {
|
|
@@ -17468,28 +17538,6 @@
|
|
|
17468
17538
|
}
|
|
17469
17539
|
};
|
|
17470
17540
|
//#endregion
|
|
17471
|
-
//#region \0@oxc-project+runtime@0.123.0/helpers/objectWithoutPropertiesLoose.js
|
|
17472
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
17473
|
-
if (null == r) return {};
|
|
17474
|
-
var t = {};
|
|
17475
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
17476
|
-
if (e.includes(n)) continue;
|
|
17477
|
-
t[n] = r[n];
|
|
17478
|
-
}
|
|
17479
|
-
return t;
|
|
17480
|
-
}
|
|
17481
|
-
//#endregion
|
|
17482
|
-
//#region \0@oxc-project+runtime@0.123.0/helpers/objectWithoutProperties.js
|
|
17483
|
-
function _objectWithoutProperties(e, t) {
|
|
17484
|
-
if (null == e) return {};
|
|
17485
|
-
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
17486
|
-
if (Object.getOwnPropertySymbols) {
|
|
17487
|
-
var s = Object.getOwnPropertySymbols(e);
|
|
17488
|
-
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
17489
|
-
}
|
|
17490
|
-
return i;
|
|
17491
|
-
}
|
|
17492
|
-
//#endregion
|
|
17493
17541
|
//#region src/file/table-of-contents/table-of-contents.ts
|
|
17494
17542
|
/**
|
|
17495
17543
|
* Table of Contents module for WordprocessingML documents.
|
|
@@ -17501,11 +17549,6 @@
|
|
|
17501
17549
|
*
|
|
17502
17550
|
* @module
|
|
17503
17551
|
*/
|
|
17504
|
-
const _excluded$1 = [
|
|
17505
|
-
"contentChildren",
|
|
17506
|
-
"cachedEntries",
|
|
17507
|
-
"beginDirty"
|
|
17508
|
-
];
|
|
17509
17552
|
/**
|
|
17510
17553
|
* Represents a Table of Contents in a WordprocessingML document.
|
|
17511
17554
|
*
|
|
@@ -17536,8 +17579,7 @@
|
|
|
17536
17579
|
* ```
|
|
17537
17580
|
*/
|
|
17538
17581
|
var TableOfContents = class extends FileChild {
|
|
17539
|
-
constructor(alias = "Table of Contents",
|
|
17540
|
-
let { contentChildren = [], cachedEntries = [], beginDirty = true } = _ref, properties = _objectWithoutProperties(_ref, _excluded$1);
|
|
17582
|
+
constructor(alias = "Table of Contents", { contentChildren = [], cachedEntries = [], beginDirty = true, ...properties } = {}) {
|
|
17541
17583
|
super("w:sdt");
|
|
17542
17584
|
this.root.push(new StructuredDocumentTagProperties(alias));
|
|
17543
17585
|
const content = new StructuredDocumentTagContent();
|
|
@@ -18233,7 +18275,6 @@
|
|
|
18233
18275
|
*
|
|
18234
18276
|
* @module
|
|
18235
18277
|
*/
|
|
18236
|
-
const _excluded = ["style", "children"];
|
|
18237
18278
|
/**
|
|
18238
18279
|
* Represents a textbox in a WordprocessingML document.
|
|
18239
18280
|
*
|
|
@@ -18283,8 +18324,7 @@
|
|
|
18283
18324
|
* ```
|
|
18284
18325
|
*/
|
|
18285
18326
|
var Textbox = class extends FileChild {
|
|
18286
|
-
constructor(
|
|
18287
|
-
let { style, children } = _ref, rest = _objectWithoutProperties(_ref, _excluded);
|
|
18327
|
+
constructor({ style, children, ...rest }) {
|
|
18288
18328
|
super("w:p");
|
|
18289
18329
|
this.root.push(new ParagraphProperties(rest));
|
|
18290
18330
|
this.root.push(createPictElement({ shape: createShape({
|
|
@@ -18295,116 +18335,3260 @@
|
|
|
18295
18335
|
}
|
|
18296
18336
|
};
|
|
18297
18337
|
//#endregion
|
|
18298
|
-
//#region
|
|
18299
|
-
|
|
18300
|
-
|
|
18301
|
-
|
|
18302
|
-
|
|
18303
|
-
|
|
18304
|
-
|
|
18305
|
-
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18338
|
+
//#region \0polyfill-node.events.js
|
|
18339
|
+
var domain;
|
|
18340
|
+
function EventHandlers() {}
|
|
18341
|
+
EventHandlers.prototype = Object.create(null);
|
|
18342
|
+
function EventEmitter() {
|
|
18343
|
+
EventEmitter.init.call(this);
|
|
18344
|
+
}
|
|
18345
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
18346
|
+
EventEmitter.usingDomains = false;
|
|
18347
|
+
EventEmitter.prototype.domain = void 0;
|
|
18348
|
+
EventEmitter.prototype._events = void 0;
|
|
18349
|
+
EventEmitter.prototype._maxListeners = void 0;
|
|
18350
|
+
EventEmitter.defaultMaxListeners = 10;
|
|
18351
|
+
EventEmitter.init = function() {
|
|
18352
|
+
this.domain = null;
|
|
18353
|
+
if (EventEmitter.usingDomains) {
|
|
18354
|
+
if (domain.active && !(this instanceof domain.Domain)) this.domain = domain.active;
|
|
18355
|
+
}
|
|
18356
|
+
if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
|
|
18357
|
+
this._events = new EventHandlers();
|
|
18358
|
+
this._eventsCount = 0;
|
|
18359
|
+
}
|
|
18360
|
+
this._maxListeners = this._maxListeners || void 0;
|
|
18361
|
+
};
|
|
18362
|
+
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
18363
|
+
if (typeof n !== "number" || n < 0 || isNaN(n)) throw new TypeError("\"n\" argument must be a positive number");
|
|
18364
|
+
this._maxListeners = n;
|
|
18365
|
+
return this;
|
|
18366
|
+
};
|
|
18367
|
+
function $getMaxListeners(that) {
|
|
18368
|
+
if (that._maxListeners === void 0) return EventEmitter.defaultMaxListeners;
|
|
18369
|
+
return that._maxListeners;
|
|
18370
|
+
}
|
|
18371
|
+
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
|
18372
|
+
return $getMaxListeners(this);
|
|
18373
|
+
};
|
|
18374
|
+
function emitNone(handler, isFn, self) {
|
|
18375
|
+
if (isFn) handler.call(self);
|
|
18376
|
+
else {
|
|
18377
|
+
var len = handler.length;
|
|
18378
|
+
var listeners = arrayClone(handler, len);
|
|
18379
|
+
for (var i = 0; i < len; ++i) listeners[i].call(self);
|
|
18380
|
+
}
|
|
18381
|
+
}
|
|
18382
|
+
function emitOne(handler, isFn, self, arg1) {
|
|
18383
|
+
if (isFn) handler.call(self, arg1);
|
|
18384
|
+
else {
|
|
18385
|
+
var len = handler.length;
|
|
18386
|
+
var listeners = arrayClone(handler, len);
|
|
18387
|
+
for (var i = 0; i < len; ++i) listeners[i].call(self, arg1);
|
|
18388
|
+
}
|
|
18389
|
+
}
|
|
18390
|
+
function emitTwo(handler, isFn, self, arg1, arg2) {
|
|
18391
|
+
if (isFn) handler.call(self, arg1, arg2);
|
|
18392
|
+
else {
|
|
18393
|
+
var len = handler.length;
|
|
18394
|
+
var listeners = arrayClone(handler, len);
|
|
18395
|
+
for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2);
|
|
18396
|
+
}
|
|
18397
|
+
}
|
|
18398
|
+
function emitThree(handler, isFn, self, arg1, arg2, arg3) {
|
|
18399
|
+
if (isFn) handler.call(self, arg1, arg2, arg3);
|
|
18400
|
+
else {
|
|
18401
|
+
var len = handler.length;
|
|
18402
|
+
var listeners = arrayClone(handler, len);
|
|
18403
|
+
for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2, arg3);
|
|
18404
|
+
}
|
|
18405
|
+
}
|
|
18406
|
+
function emitMany(handler, isFn, self, args) {
|
|
18407
|
+
if (isFn) handler.apply(self, args);
|
|
18408
|
+
else {
|
|
18409
|
+
var len = handler.length;
|
|
18410
|
+
var listeners = arrayClone(handler, len);
|
|
18411
|
+
for (var i = 0; i < len; ++i) listeners[i].apply(self, args);
|
|
18412
|
+
}
|
|
18413
|
+
}
|
|
18414
|
+
EventEmitter.prototype.emit = function emit(type) {
|
|
18415
|
+
var er, handler, len, args, i, events, domain;
|
|
18416
|
+
var needDomainExit = false;
|
|
18417
|
+
var doError = type === "error";
|
|
18418
|
+
events = this._events;
|
|
18419
|
+
if (events) doError = doError && events.error == null;
|
|
18420
|
+
else if (!doError) return false;
|
|
18421
|
+
domain = this.domain;
|
|
18422
|
+
if (doError) {
|
|
18423
|
+
er = arguments[1];
|
|
18424
|
+
if (domain) {
|
|
18425
|
+
if (!er) er = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event");
|
|
18426
|
+
er.domainEmitter = this;
|
|
18427
|
+
er.domain = domain;
|
|
18428
|
+
er.domainThrown = false;
|
|
18429
|
+
domain.emit("error", er);
|
|
18430
|
+
} else if (er instanceof Error) throw er;
|
|
18431
|
+
else {
|
|
18432
|
+
var err = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event. (" + er + ")");
|
|
18433
|
+
err.context = er;
|
|
18434
|
+
throw err;
|
|
18435
|
+
}
|
|
18436
|
+
return false;
|
|
18437
|
+
}
|
|
18438
|
+
handler = events[type];
|
|
18439
|
+
if (!handler) return false;
|
|
18440
|
+
var isFn = typeof handler === "function";
|
|
18441
|
+
len = arguments.length;
|
|
18442
|
+
switch (len) {
|
|
18443
|
+
case 1:
|
|
18444
|
+
emitNone(handler, isFn, this);
|
|
18445
|
+
break;
|
|
18446
|
+
case 2:
|
|
18447
|
+
emitOne(handler, isFn, this, arguments[1]);
|
|
18448
|
+
break;
|
|
18449
|
+
case 3:
|
|
18450
|
+
emitTwo(handler, isFn, this, arguments[1], arguments[2]);
|
|
18451
|
+
break;
|
|
18452
|
+
case 4:
|
|
18453
|
+
emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
|
|
18454
|
+
break;
|
|
18455
|
+
default:
|
|
18456
|
+
args = new Array(len - 1);
|
|
18457
|
+
for (i = 1; i < len; i++) args[i - 1] = arguments[i];
|
|
18458
|
+
emitMany(handler, isFn, this, args);
|
|
18459
|
+
}
|
|
18460
|
+
if (needDomainExit) domain.exit();
|
|
18461
|
+
return true;
|
|
18462
|
+
};
|
|
18463
|
+
function _addListener(target, type, listener, prepend) {
|
|
18464
|
+
var m;
|
|
18465
|
+
var events;
|
|
18466
|
+
var existing;
|
|
18467
|
+
if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
|
|
18468
|
+
events = target._events;
|
|
18469
|
+
if (!events) {
|
|
18470
|
+
events = target._events = new EventHandlers();
|
|
18471
|
+
target._eventsCount = 0;
|
|
18472
|
+
} else {
|
|
18473
|
+
if (events.newListener) {
|
|
18474
|
+
target.emit("newListener", type, listener.listener ? listener.listener : listener);
|
|
18475
|
+
events = target._events;
|
|
18476
|
+
}
|
|
18477
|
+
existing = events[type];
|
|
18478
|
+
}
|
|
18479
|
+
if (!existing) {
|
|
18480
|
+
existing = events[type] = listener;
|
|
18481
|
+
++target._eventsCount;
|
|
18482
|
+
} else {
|
|
18483
|
+
if (typeof existing === "function") existing = events[type] = prepend ? [listener, existing] : [existing, listener];
|
|
18484
|
+
else if (prepend) existing.unshift(listener);
|
|
18485
|
+
else existing.push(listener);
|
|
18486
|
+
if (!existing.warned) {
|
|
18487
|
+
m = $getMaxListeners(target);
|
|
18488
|
+
if (m && m > 0 && existing.length > m) {
|
|
18489
|
+
existing.warned = true;
|
|
18490
|
+
var w = /* @__PURE__ */ new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + type + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
18491
|
+
w.name = "MaxListenersExceededWarning";
|
|
18492
|
+
w.emitter = target;
|
|
18493
|
+
w.type = type;
|
|
18494
|
+
w.count = existing.length;
|
|
18495
|
+
emitWarning(w);
|
|
18496
|
+
}
|
|
18497
|
+
}
|
|
18498
|
+
}
|
|
18499
|
+
return target;
|
|
18500
|
+
}
|
|
18501
|
+
function emitWarning(e) {
|
|
18502
|
+
typeof console.warn === "function" ? console.warn(e) : console.log(e);
|
|
18503
|
+
}
|
|
18504
|
+
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
|
18505
|
+
return _addListener(this, type, listener, false);
|
|
18506
|
+
};
|
|
18507
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
18508
|
+
EventEmitter.prototype.prependListener = function prependListener(type, listener) {
|
|
18509
|
+
return _addListener(this, type, listener, true);
|
|
18510
|
+
};
|
|
18511
|
+
function _onceWrap(target, type, listener) {
|
|
18512
|
+
var fired = false;
|
|
18513
|
+
function g() {
|
|
18514
|
+
target.removeListener(type, g);
|
|
18515
|
+
if (!fired) {
|
|
18516
|
+
fired = true;
|
|
18517
|
+
listener.apply(target, arguments);
|
|
18518
|
+
}
|
|
18519
|
+
}
|
|
18520
|
+
g.listener = listener;
|
|
18521
|
+
return g;
|
|
18522
|
+
}
|
|
18523
|
+
EventEmitter.prototype.once = function once(type, listener) {
|
|
18524
|
+
if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
|
|
18525
|
+
this.on(type, _onceWrap(this, type, listener));
|
|
18526
|
+
return this;
|
|
18527
|
+
};
|
|
18528
|
+
EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
|
|
18529
|
+
if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
|
|
18530
|
+
this.prependListener(type, _onceWrap(this, type, listener));
|
|
18531
|
+
return this;
|
|
18532
|
+
};
|
|
18533
|
+
EventEmitter.prototype.removeListener = function removeListener(type, listener) {
|
|
18534
|
+
var list, events, position, i, originalListener;
|
|
18535
|
+
if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
|
|
18536
|
+
events = this._events;
|
|
18537
|
+
if (!events) return this;
|
|
18538
|
+
list = events[type];
|
|
18539
|
+
if (!list) return this;
|
|
18540
|
+
if (list === listener || list.listener && list.listener === listener) if (--this._eventsCount === 0) this._events = new EventHandlers();
|
|
18541
|
+
else {
|
|
18542
|
+
delete events[type];
|
|
18543
|
+
if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
|
|
18544
|
+
}
|
|
18545
|
+
else if (typeof list !== "function") {
|
|
18546
|
+
position = -1;
|
|
18547
|
+
for (i = list.length; i-- > 0;) if (list[i] === listener || list[i].listener && list[i].listener === listener) {
|
|
18548
|
+
originalListener = list[i].listener;
|
|
18549
|
+
position = i;
|
|
18550
|
+
break;
|
|
18551
|
+
}
|
|
18552
|
+
if (position < 0) return this;
|
|
18553
|
+
if (list.length === 1) {
|
|
18554
|
+
list[0] = void 0;
|
|
18555
|
+
if (--this._eventsCount === 0) {
|
|
18556
|
+
this._events = new EventHandlers();
|
|
18557
|
+
return this;
|
|
18558
|
+
} else delete events[type];
|
|
18559
|
+
} else spliceOne(list, position);
|
|
18560
|
+
if (events.removeListener) this.emit("removeListener", type, originalListener || listener);
|
|
18561
|
+
}
|
|
18562
|
+
return this;
|
|
18563
|
+
};
|
|
18564
|
+
EventEmitter.prototype.off = function(type, listener) {
|
|
18565
|
+
return this.removeListener(type, listener);
|
|
18566
|
+
};
|
|
18567
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
|
|
18568
|
+
var listeners, events = this._events;
|
|
18569
|
+
if (!events) return this;
|
|
18570
|
+
if (!events.removeListener) {
|
|
18571
|
+
if (arguments.length === 0) {
|
|
18572
|
+
this._events = new EventHandlers();
|
|
18573
|
+
this._eventsCount = 0;
|
|
18574
|
+
} else if (events[type]) if (--this._eventsCount === 0) this._events = new EventHandlers();
|
|
18575
|
+
else delete events[type];
|
|
18576
|
+
return this;
|
|
18577
|
+
}
|
|
18578
|
+
if (arguments.length === 0) {
|
|
18579
|
+
var keys = Object.keys(events);
|
|
18580
|
+
for (var i = 0, key; i < keys.length; ++i) {
|
|
18581
|
+
key = keys[i];
|
|
18582
|
+
if (key === "removeListener") continue;
|
|
18583
|
+
this.removeAllListeners(key);
|
|
18584
|
+
}
|
|
18585
|
+
this.removeAllListeners("removeListener");
|
|
18586
|
+
this._events = new EventHandlers();
|
|
18587
|
+
this._eventsCount = 0;
|
|
18588
|
+
return this;
|
|
18317
18589
|
}
|
|
18590
|
+
listeners = events[type];
|
|
18591
|
+
if (typeof listeners === "function") this.removeListener(type, listeners);
|
|
18592
|
+
else if (listeners) do
|
|
18593
|
+
this.removeListener(type, listeners[listeners.length - 1]);
|
|
18594
|
+
while (listeners[0]);
|
|
18595
|
+
return this;
|
|
18596
|
+
};
|
|
18597
|
+
EventEmitter.prototype.listeners = function listeners(type) {
|
|
18598
|
+
var evlistener;
|
|
18599
|
+
var ret;
|
|
18600
|
+
var events = this._events;
|
|
18601
|
+
if (!events) ret = [];
|
|
18602
|
+
else {
|
|
18603
|
+
evlistener = events[type];
|
|
18604
|
+
if (!evlistener) ret = [];
|
|
18605
|
+
else if (typeof evlistener === "function") ret = [evlistener.listener || evlistener];
|
|
18606
|
+
else ret = unwrapListeners(evlistener);
|
|
18607
|
+
}
|
|
18608
|
+
return ret;
|
|
18609
|
+
};
|
|
18610
|
+
EventEmitter.listenerCount = function(emitter, type) {
|
|
18611
|
+
if (typeof emitter.listenerCount === "function") return emitter.listenerCount(type);
|
|
18612
|
+
else return listenerCount$1.call(emitter, type);
|
|
18613
|
+
};
|
|
18614
|
+
EventEmitter.prototype.listenerCount = listenerCount$1;
|
|
18615
|
+
function listenerCount$1(type) {
|
|
18616
|
+
var events = this._events;
|
|
18617
|
+
if (events) {
|
|
18618
|
+
var evlistener = events[type];
|
|
18619
|
+
if (typeof evlistener === "function") return 1;
|
|
18620
|
+
else if (evlistener) return evlistener.length;
|
|
18621
|
+
}
|
|
18622
|
+
return 0;
|
|
18623
|
+
}
|
|
18624
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
18625
|
+
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
|
18318
18626
|
};
|
|
18627
|
+
function spliceOne(list, index) {
|
|
18628
|
+
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) list[i] = list[k];
|
|
18629
|
+
list.pop();
|
|
18630
|
+
}
|
|
18631
|
+
function arrayClone(arr, i) {
|
|
18632
|
+
var copy = new Array(i);
|
|
18633
|
+
while (i--) copy[i] = arr[i];
|
|
18634
|
+
return copy;
|
|
18635
|
+
}
|
|
18636
|
+
function unwrapListeners(arr) {
|
|
18637
|
+
var ret = new Array(arr.length);
|
|
18638
|
+
for (var i = 0; i < ret.length; ++i) ret[i] = arr[i].listener || arr[i];
|
|
18639
|
+
return ret;
|
|
18640
|
+
}
|
|
18319
18641
|
//#endregion
|
|
18320
|
-
//#region
|
|
18642
|
+
//#region \0polyfill-node.global.js
|
|
18643
|
+
var _polyfill_node_global_default = typeof _polyfill_node_global_default !== "undefined" ? _polyfill_node_global_default : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
18644
|
+
//#endregion
|
|
18645
|
+
//#region \0polyfill-node.buffer.js
|
|
18646
|
+
var lookup = [];
|
|
18647
|
+
var revLookup = [];
|
|
18648
|
+
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
18649
|
+
var inited = false;
|
|
18650
|
+
function init() {
|
|
18651
|
+
inited = true;
|
|
18652
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
18653
|
+
for (var i = 0, len = code.length; i < len; ++i) {
|
|
18654
|
+
lookup[i] = code[i];
|
|
18655
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
18656
|
+
}
|
|
18657
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
18658
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
18659
|
+
}
|
|
18660
|
+
function toByteArray(b64) {
|
|
18661
|
+
if (!inited) init();
|
|
18662
|
+
var i, j, l, tmp, placeHolders, arr;
|
|
18663
|
+
var len = b64.length;
|
|
18664
|
+
if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
|
|
18665
|
+
placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
|
|
18666
|
+
arr = new Arr(len * 3 / 4 - placeHolders);
|
|
18667
|
+
l = placeHolders > 0 ? len - 4 : len;
|
|
18668
|
+
var L = 0;
|
|
18669
|
+
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
|
18670
|
+
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
|
|
18671
|
+
arr[L++] = tmp >> 16 & 255;
|
|
18672
|
+
arr[L++] = tmp >> 8 & 255;
|
|
18673
|
+
arr[L++] = tmp & 255;
|
|
18674
|
+
}
|
|
18675
|
+
if (placeHolders === 2) {
|
|
18676
|
+
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
|
|
18677
|
+
arr[L++] = tmp & 255;
|
|
18678
|
+
} else if (placeHolders === 1) {
|
|
18679
|
+
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
|
|
18680
|
+
arr[L++] = tmp >> 8 & 255;
|
|
18681
|
+
arr[L++] = tmp & 255;
|
|
18682
|
+
}
|
|
18683
|
+
return arr;
|
|
18684
|
+
}
|
|
18685
|
+
function tripletToBase64(num) {
|
|
18686
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
18687
|
+
}
|
|
18688
|
+
function encodeChunk(uint8, start, end) {
|
|
18689
|
+
var tmp;
|
|
18690
|
+
var output = [];
|
|
18691
|
+
for (var i = start; i < end; i += 3) {
|
|
18692
|
+
tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
|
|
18693
|
+
output.push(tripletToBase64(tmp));
|
|
18694
|
+
}
|
|
18695
|
+
return output.join("");
|
|
18696
|
+
}
|
|
18697
|
+
function fromByteArray(uint8) {
|
|
18698
|
+
if (!inited) init();
|
|
18699
|
+
var tmp;
|
|
18700
|
+
var len = uint8.length;
|
|
18701
|
+
var extraBytes = len % 3;
|
|
18702
|
+
var output = "";
|
|
18703
|
+
var parts = [];
|
|
18704
|
+
var maxChunkLength = 16383;
|
|
18705
|
+
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
|
|
18706
|
+
if (extraBytes === 1) {
|
|
18707
|
+
tmp = uint8[len - 1];
|
|
18708
|
+
output += lookup[tmp >> 2];
|
|
18709
|
+
output += lookup[tmp << 4 & 63];
|
|
18710
|
+
output += "==";
|
|
18711
|
+
} else if (extraBytes === 2) {
|
|
18712
|
+
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
18713
|
+
output += lookup[tmp >> 10];
|
|
18714
|
+
output += lookup[tmp >> 4 & 63];
|
|
18715
|
+
output += lookup[tmp << 2 & 63];
|
|
18716
|
+
output += "=";
|
|
18717
|
+
}
|
|
18718
|
+
parts.push(output);
|
|
18719
|
+
return parts.join("");
|
|
18720
|
+
}
|
|
18721
|
+
function read(buffer, offset, isLE, mLen, nBytes) {
|
|
18722
|
+
var e, m;
|
|
18723
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
18724
|
+
var eMax = (1 << eLen) - 1;
|
|
18725
|
+
var eBias = eMax >> 1;
|
|
18726
|
+
var nBits = -7;
|
|
18727
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
18728
|
+
var d = isLE ? -1 : 1;
|
|
18729
|
+
var s = buffer[offset + i];
|
|
18730
|
+
i += d;
|
|
18731
|
+
e = s & (1 << -nBits) - 1;
|
|
18732
|
+
s >>= -nBits;
|
|
18733
|
+
nBits += eLen;
|
|
18734
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
|
|
18735
|
+
m = e & (1 << -nBits) - 1;
|
|
18736
|
+
e >>= -nBits;
|
|
18737
|
+
nBits += mLen;
|
|
18738
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
|
|
18739
|
+
if (e === 0) e = 1 - eBias;
|
|
18740
|
+
else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
18741
|
+
else {
|
|
18742
|
+
m = m + Math.pow(2, mLen);
|
|
18743
|
+
e = e - eBias;
|
|
18744
|
+
}
|
|
18745
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
18746
|
+
}
|
|
18747
|
+
function write(buffer, value, offset, isLE, mLen, nBytes) {
|
|
18748
|
+
var e, m, c;
|
|
18749
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
18750
|
+
var eMax = (1 << eLen) - 1;
|
|
18751
|
+
var eBias = eMax >> 1;
|
|
18752
|
+
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
18753
|
+
var i = isLE ? 0 : nBytes - 1;
|
|
18754
|
+
var d = isLE ? 1 : -1;
|
|
18755
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
18756
|
+
value = Math.abs(value);
|
|
18757
|
+
if (isNaN(value) || value === Infinity) {
|
|
18758
|
+
m = isNaN(value) ? 1 : 0;
|
|
18759
|
+
e = eMax;
|
|
18760
|
+
} else {
|
|
18761
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
18762
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
18763
|
+
e--;
|
|
18764
|
+
c *= 2;
|
|
18765
|
+
}
|
|
18766
|
+
if (e + eBias >= 1) value += rt / c;
|
|
18767
|
+
else value += rt * Math.pow(2, 1 - eBias);
|
|
18768
|
+
if (value * c >= 2) {
|
|
18769
|
+
e++;
|
|
18770
|
+
c /= 2;
|
|
18771
|
+
}
|
|
18772
|
+
if (e + eBias >= eMax) {
|
|
18773
|
+
m = 0;
|
|
18774
|
+
e = eMax;
|
|
18775
|
+
} else if (e + eBias >= 1) {
|
|
18776
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
18777
|
+
e = e + eBias;
|
|
18778
|
+
} else {
|
|
18779
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
18780
|
+
e = 0;
|
|
18781
|
+
}
|
|
18782
|
+
}
|
|
18783
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8);
|
|
18784
|
+
e = e << mLen | m;
|
|
18785
|
+
eLen += mLen;
|
|
18786
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8);
|
|
18787
|
+
buffer[offset + i - d] |= s * 128;
|
|
18788
|
+
}
|
|
18789
|
+
var toString = {}.toString;
|
|
18790
|
+
var isArray$1 = Array.isArray || function(arr) {
|
|
18791
|
+
return toString.call(arr) == "[object Array]";
|
|
18792
|
+
};
|
|
18321
18793
|
/**
|
|
18322
|
-
*
|
|
18323
|
-
*
|
|
18324
|
-
*
|
|
18325
|
-
* fonts in DOCX documents. Obfuscation is required by the OOXML specification
|
|
18326
|
-
* to prevent simple extraction of embedded font files.
|
|
18794
|
+
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
18795
|
+
* === true Use Uint8Array implementation (fastest)
|
|
18796
|
+
* === false Use Object implementation (most compatible, even IE6)
|
|
18327
18797
|
*
|
|
18328
|
-
*
|
|
18798
|
+
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
18799
|
+
* Opera 11.6+, iOS 4.2+.
|
|
18329
18800
|
*
|
|
18330
|
-
*
|
|
18331
|
-
|
|
18332
|
-
/** Start offset for obfuscation in the font file */
|
|
18333
|
-
const obfuscatedStartOffset = 0;
|
|
18334
|
-
/** End offset for obfuscation (first 32 bytes are obfuscated) */
|
|
18335
|
-
const obfuscatedEndOffset = 32;
|
|
18336
|
-
/** Expected GUID size (32 hex characters without dashes) */
|
|
18337
|
-
const guidSize = 32;
|
|
18338
|
-
/**
|
|
18339
|
-
* Obfuscates a TrueType font file for embedding in OOXML documents.
|
|
18801
|
+
* Due to various browser bugs, sometimes the Object implementation will be used even
|
|
18802
|
+
* when the browser supports typed arrays.
|
|
18340
18803
|
*
|
|
18341
|
-
*
|
|
18342
|
-
* with a reversed byte sequence derived from the font's GUID key.
|
|
18343
|
-
* This prevents simple extraction while maintaining font functionality.
|
|
18804
|
+
* Note:
|
|
18344
18805
|
*
|
|
18345
|
-
*
|
|
18346
|
-
*
|
|
18347
|
-
* @returns The obfuscated font data
|
|
18348
|
-
* @throws Error if the fontKey is not a valid 32-character GUID
|
|
18806
|
+
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
|
18807
|
+
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
|
18349
18808
|
*
|
|
18350
|
-
*
|
|
18351
|
-
* ```typescript
|
|
18352
|
-
* const fontData = readFileSync("font.ttf");
|
|
18353
|
-
* const fontKey = "00000000-0000-0000-0000-000000000000";
|
|
18354
|
-
* const obfuscatedData = obfuscate(fontData, fontKey);
|
|
18355
|
-
* ```
|
|
18809
|
+
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
|
18356
18810
|
*
|
|
18357
|
-
*
|
|
18811
|
+
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
|
18812
|
+
* incorrect length in some situations.
|
|
18813
|
+
|
|
18814
|
+
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
|
18815
|
+
* get the Object implementation, which is slower but behaves correctly.
|
|
18358
18816
|
*/
|
|
18359
|
-
|
|
18360
|
-
|
|
18361
|
-
|
|
18362
|
-
|
|
18363
|
-
|
|
18364
|
-
|
|
18365
|
-
|
|
18366
|
-
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
|
|
18372
|
-
|
|
18817
|
+
Buffer$1.TYPED_ARRAY_SUPPORT = _polyfill_node_global_default.TYPED_ARRAY_SUPPORT !== void 0 ? _polyfill_node_global_default.TYPED_ARRAY_SUPPORT : true;
|
|
18818
|
+
kMaxLength();
|
|
18819
|
+
function kMaxLength() {
|
|
18820
|
+
return Buffer$1.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
|
|
18821
|
+
}
|
|
18822
|
+
function createBuffer(that, length) {
|
|
18823
|
+
if (kMaxLength() < length) throw new RangeError("Invalid typed array length");
|
|
18824
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
18825
|
+
that = new Uint8Array(length);
|
|
18826
|
+
that.__proto__ = Buffer$1.prototype;
|
|
18827
|
+
} else {
|
|
18828
|
+
if (that === null) that = new Buffer$1(length);
|
|
18829
|
+
that.length = length;
|
|
18830
|
+
}
|
|
18831
|
+
return that;
|
|
18832
|
+
}
|
|
18373
18833
|
/**
|
|
18374
|
-
*
|
|
18375
|
-
*
|
|
18376
|
-
*
|
|
18377
|
-
*
|
|
18378
|
-
*
|
|
18834
|
+
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
18835
|
+
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
18836
|
+
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
18837
|
+
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
18838
|
+
* returns a single octet.
|
|
18379
18839
|
*
|
|
18380
|
-
*
|
|
18381
|
-
* ```typescript
|
|
18382
|
-
* const formatter = new Formatter();
|
|
18383
|
-
* const paragraph = new Paragraph("Hello World");
|
|
18384
|
-
* const xmlObject = formatter.format(paragraph, context);
|
|
18385
|
-
* ```
|
|
18840
|
+
* The `Uint8Array` prototype remains unmodified.
|
|
18386
18841
|
*/
|
|
18387
|
-
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
|
|
18392
|
-
* @param context - The context containing file state and relationships
|
|
18393
|
-
* @returns A serializable XML object structure
|
|
18394
|
-
* @throws Error if the component cannot be formatted correctly
|
|
18395
|
-
*/
|
|
18396
|
-
format(input, context = { stack: [] }) {
|
|
18397
|
-
const output = input.prepForXml(context);
|
|
18398
|
-
if (output) return output;
|
|
18399
|
-
else throw new Error("XMLComponent did not format correctly");
|
|
18842
|
+
function Buffer$1(arg, encodingOrOffset, length) {
|
|
18843
|
+
if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) return new Buffer$1(arg, encodingOrOffset, length);
|
|
18844
|
+
if (typeof arg === "number") {
|
|
18845
|
+
if (typeof encodingOrOffset === "string") throw new Error("If encoding is specified then the first argument must be a string");
|
|
18846
|
+
return allocUnsafe(this, arg);
|
|
18400
18847
|
}
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
|
|
18848
|
+
return from(this, arg, encodingOrOffset, length);
|
|
18849
|
+
}
|
|
18850
|
+
Buffer$1.poolSize = 8192;
|
|
18851
|
+
Buffer$1._augment = function(arr) {
|
|
18852
|
+
arr.__proto__ = Buffer$1.prototype;
|
|
18853
|
+
return arr;
|
|
18854
|
+
};
|
|
18855
|
+
function from(that, value, encodingOrOffset, length) {
|
|
18856
|
+
if (typeof value === "number") throw new TypeError("\"value\" argument must not be a number");
|
|
18857
|
+
if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) return fromArrayBuffer(that, value, encodingOrOffset, length);
|
|
18858
|
+
if (typeof value === "string") return fromString(that, value, encodingOrOffset);
|
|
18859
|
+
return fromObject(that, value);
|
|
18860
|
+
}
|
|
18404
18861
|
/**
|
|
18405
|
-
*
|
|
18406
|
-
*
|
|
18407
|
-
*
|
|
18862
|
+
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
18863
|
+
* if value is a number.
|
|
18864
|
+
* Buffer.from(str[, encoding])
|
|
18865
|
+
* Buffer.from(array)
|
|
18866
|
+
* Buffer.from(buffer)
|
|
18867
|
+
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
18868
|
+
**/
|
|
18869
|
+
Buffer$1.from = function(value, encodingOrOffset, length) {
|
|
18870
|
+
return from(null, value, encodingOrOffset, length);
|
|
18871
|
+
};
|
|
18872
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
18873
|
+
Buffer$1.prototype.__proto__ = Uint8Array.prototype;
|
|
18874
|
+
Buffer$1.__proto__ = Uint8Array;
|
|
18875
|
+
if (typeof Symbol !== "undefined" && Symbol.species && Buffer$1[Symbol.species] === Buffer$1);
|
|
18876
|
+
}
|
|
18877
|
+
function assertSize(size) {
|
|
18878
|
+
if (typeof size !== "number") throw new TypeError("\"size\" argument must be a number");
|
|
18879
|
+
else if (size < 0) throw new RangeError("\"size\" argument must not be negative");
|
|
18880
|
+
}
|
|
18881
|
+
function alloc(that, size, fill, encoding) {
|
|
18882
|
+
assertSize(size);
|
|
18883
|
+
if (size <= 0) return createBuffer(that, size);
|
|
18884
|
+
if (fill !== void 0) return typeof encoding === "string" ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
|
|
18885
|
+
return createBuffer(that, size);
|
|
18886
|
+
}
|
|
18887
|
+
/**
|
|
18888
|
+
* Creates a new filled Buffer instance.
|
|
18889
|
+
* alloc(size[, fill[, encoding]])
|
|
18890
|
+
**/
|
|
18891
|
+
Buffer$1.alloc = function(size, fill, encoding) {
|
|
18892
|
+
return alloc(null, size, fill, encoding);
|
|
18893
|
+
};
|
|
18894
|
+
function allocUnsafe(that, size) {
|
|
18895
|
+
assertSize(size);
|
|
18896
|
+
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
|
|
18897
|
+
if (!Buffer$1.TYPED_ARRAY_SUPPORT) for (var i = 0; i < size; ++i) that[i] = 0;
|
|
18898
|
+
return that;
|
|
18899
|
+
}
|
|
18900
|
+
/**
|
|
18901
|
+
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
18902
|
+
* */
|
|
18903
|
+
Buffer$1.allocUnsafe = function(size) {
|
|
18904
|
+
return allocUnsafe(null, size);
|
|
18905
|
+
};
|
|
18906
|
+
/**
|
|
18907
|
+
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
18908
|
+
*/
|
|
18909
|
+
Buffer$1.allocUnsafeSlow = function(size) {
|
|
18910
|
+
return allocUnsafe(null, size);
|
|
18911
|
+
};
|
|
18912
|
+
function fromString(that, string, encoding) {
|
|
18913
|
+
if (typeof encoding !== "string" || encoding === "") encoding = "utf8";
|
|
18914
|
+
if (!Buffer$1.isEncoding(encoding)) throw new TypeError("\"encoding\" must be a valid string encoding");
|
|
18915
|
+
var length = byteLength(string, encoding) | 0;
|
|
18916
|
+
that = createBuffer(that, length);
|
|
18917
|
+
var actual = that.write(string, encoding);
|
|
18918
|
+
if (actual !== length) that = that.slice(0, actual);
|
|
18919
|
+
return that;
|
|
18920
|
+
}
|
|
18921
|
+
function fromArrayLike(that, array) {
|
|
18922
|
+
var length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
18923
|
+
that = createBuffer(that, length);
|
|
18924
|
+
for (var i = 0; i < length; i += 1) that[i] = array[i] & 255;
|
|
18925
|
+
return that;
|
|
18926
|
+
}
|
|
18927
|
+
function fromArrayBuffer(that, array, byteOffset, length) {
|
|
18928
|
+
array.byteLength;
|
|
18929
|
+
if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError("'offset' is out of bounds");
|
|
18930
|
+
if (array.byteLength < byteOffset + (length || 0)) throw new RangeError("'length' is out of bounds");
|
|
18931
|
+
if (byteOffset === void 0 && length === void 0) array = new Uint8Array(array);
|
|
18932
|
+
else if (length === void 0) array = new Uint8Array(array, byteOffset);
|
|
18933
|
+
else array = new Uint8Array(array, byteOffset, length);
|
|
18934
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
18935
|
+
that = array;
|
|
18936
|
+
that.__proto__ = Buffer$1.prototype;
|
|
18937
|
+
} else that = fromArrayLike(that, array);
|
|
18938
|
+
return that;
|
|
18939
|
+
}
|
|
18940
|
+
function fromObject(that, obj) {
|
|
18941
|
+
if (internalIsBuffer(obj)) {
|
|
18942
|
+
var len = checked(obj.length) | 0;
|
|
18943
|
+
that = createBuffer(that, len);
|
|
18944
|
+
if (that.length === 0) return that;
|
|
18945
|
+
obj.copy(that, 0, 0, len);
|
|
18946
|
+
return that;
|
|
18947
|
+
}
|
|
18948
|
+
if (obj) {
|
|
18949
|
+
if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
|
|
18950
|
+
if (typeof obj.length !== "number" || isnan(obj.length)) return createBuffer(that, 0);
|
|
18951
|
+
return fromArrayLike(that, obj);
|
|
18952
|
+
}
|
|
18953
|
+
if (obj.type === "Buffer" && isArray$1(obj.data)) return fromArrayLike(that, obj.data);
|
|
18954
|
+
}
|
|
18955
|
+
throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
|
|
18956
|
+
}
|
|
18957
|
+
function checked(length) {
|
|
18958
|
+
if (length >= kMaxLength()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
|
|
18959
|
+
return length | 0;
|
|
18960
|
+
}
|
|
18961
|
+
Buffer$1.isBuffer = isBuffer;
|
|
18962
|
+
function internalIsBuffer(b) {
|
|
18963
|
+
return !!(b != null && b._isBuffer);
|
|
18964
|
+
}
|
|
18965
|
+
Buffer$1.compare = function compare(a, b) {
|
|
18966
|
+
if (!internalIsBuffer(a) || !internalIsBuffer(b)) throw new TypeError("Arguments must be Buffers");
|
|
18967
|
+
if (a === b) return 0;
|
|
18968
|
+
var x = a.length;
|
|
18969
|
+
var y = b.length;
|
|
18970
|
+
for (var i = 0, len = Math.min(x, y); i < len; ++i) if (a[i] !== b[i]) {
|
|
18971
|
+
x = a[i];
|
|
18972
|
+
y = b[i];
|
|
18973
|
+
break;
|
|
18974
|
+
}
|
|
18975
|
+
if (x < y) return -1;
|
|
18976
|
+
if (y < x) return 1;
|
|
18977
|
+
return 0;
|
|
18978
|
+
};
|
|
18979
|
+
Buffer$1.isEncoding = function isEncoding(encoding) {
|
|
18980
|
+
switch (String(encoding).toLowerCase()) {
|
|
18981
|
+
case "hex":
|
|
18982
|
+
case "utf8":
|
|
18983
|
+
case "utf-8":
|
|
18984
|
+
case "ascii":
|
|
18985
|
+
case "latin1":
|
|
18986
|
+
case "binary":
|
|
18987
|
+
case "base64":
|
|
18988
|
+
case "ucs2":
|
|
18989
|
+
case "ucs-2":
|
|
18990
|
+
case "utf16le":
|
|
18991
|
+
case "utf-16le": return true;
|
|
18992
|
+
default: return false;
|
|
18993
|
+
}
|
|
18994
|
+
};
|
|
18995
|
+
Buffer$1.concat = function concat(list, length) {
|
|
18996
|
+
if (!isArray$1(list)) throw new TypeError("\"list\" argument must be an Array of Buffers");
|
|
18997
|
+
if (list.length === 0) return Buffer$1.alloc(0);
|
|
18998
|
+
var i;
|
|
18999
|
+
if (length === void 0) {
|
|
19000
|
+
length = 0;
|
|
19001
|
+
for (i = 0; i < list.length; ++i) length += list[i].length;
|
|
19002
|
+
}
|
|
19003
|
+
var buffer = Buffer$1.allocUnsafe(length);
|
|
19004
|
+
var pos = 0;
|
|
19005
|
+
for (i = 0; i < list.length; ++i) {
|
|
19006
|
+
var buf = list[i];
|
|
19007
|
+
if (!internalIsBuffer(buf)) throw new TypeError("\"list\" argument must be an Array of Buffers");
|
|
19008
|
+
buf.copy(buffer, pos);
|
|
19009
|
+
pos += buf.length;
|
|
19010
|
+
}
|
|
19011
|
+
return buffer;
|
|
19012
|
+
};
|
|
19013
|
+
function byteLength(string, encoding) {
|
|
19014
|
+
if (internalIsBuffer(string)) return string.length;
|
|
19015
|
+
if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) return string.byteLength;
|
|
19016
|
+
if (typeof string !== "string") string = "" + string;
|
|
19017
|
+
var len = string.length;
|
|
19018
|
+
if (len === 0) return 0;
|
|
19019
|
+
var loweredCase = false;
|
|
19020
|
+
for (;;) switch (encoding) {
|
|
19021
|
+
case "ascii":
|
|
19022
|
+
case "latin1":
|
|
19023
|
+
case "binary": return len;
|
|
19024
|
+
case "utf8":
|
|
19025
|
+
case "utf-8":
|
|
19026
|
+
case void 0: return utf8ToBytes(string).length;
|
|
19027
|
+
case "ucs2":
|
|
19028
|
+
case "ucs-2":
|
|
19029
|
+
case "utf16le":
|
|
19030
|
+
case "utf-16le": return len * 2;
|
|
19031
|
+
case "hex": return len >>> 1;
|
|
19032
|
+
case "base64": return base64ToBytes(string).length;
|
|
19033
|
+
default:
|
|
19034
|
+
if (loweredCase) return utf8ToBytes(string).length;
|
|
19035
|
+
encoding = ("" + encoding).toLowerCase();
|
|
19036
|
+
loweredCase = true;
|
|
19037
|
+
}
|
|
19038
|
+
}
|
|
19039
|
+
Buffer$1.byteLength = byteLength;
|
|
19040
|
+
function slowToString(encoding, start, end) {
|
|
19041
|
+
var loweredCase = false;
|
|
19042
|
+
if (start === void 0 || start < 0) start = 0;
|
|
19043
|
+
if (start > this.length) return "";
|
|
19044
|
+
if (end === void 0 || end > this.length) end = this.length;
|
|
19045
|
+
if (end <= 0) return "";
|
|
19046
|
+
end >>>= 0;
|
|
19047
|
+
start >>>= 0;
|
|
19048
|
+
if (end <= start) return "";
|
|
19049
|
+
if (!encoding) encoding = "utf8";
|
|
19050
|
+
while (true) switch (encoding) {
|
|
19051
|
+
case "hex": return hexSlice(this, start, end);
|
|
19052
|
+
case "utf8":
|
|
19053
|
+
case "utf-8": return utf8Slice(this, start, end);
|
|
19054
|
+
case "ascii": return asciiSlice(this, start, end);
|
|
19055
|
+
case "latin1":
|
|
19056
|
+
case "binary": return latin1Slice(this, start, end);
|
|
19057
|
+
case "base64": return base64Slice(this, start, end);
|
|
19058
|
+
case "ucs2":
|
|
19059
|
+
case "ucs-2":
|
|
19060
|
+
case "utf16le":
|
|
19061
|
+
case "utf-16le": return utf16leSlice(this, start, end);
|
|
19062
|
+
default:
|
|
19063
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
19064
|
+
encoding = (encoding + "").toLowerCase();
|
|
19065
|
+
loweredCase = true;
|
|
19066
|
+
}
|
|
19067
|
+
}
|
|
19068
|
+
Buffer$1.prototype._isBuffer = true;
|
|
19069
|
+
function swap(b, n, m) {
|
|
19070
|
+
var i = b[n];
|
|
19071
|
+
b[n] = b[m];
|
|
19072
|
+
b[m] = i;
|
|
19073
|
+
}
|
|
19074
|
+
Buffer$1.prototype.swap16 = function swap16() {
|
|
19075
|
+
var len = this.length;
|
|
19076
|
+
if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
19077
|
+
for (var i = 0; i < len; i += 2) swap(this, i, i + 1);
|
|
19078
|
+
return this;
|
|
19079
|
+
};
|
|
19080
|
+
Buffer$1.prototype.swap32 = function swap32() {
|
|
19081
|
+
var len = this.length;
|
|
19082
|
+
if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
19083
|
+
for (var i = 0; i < len; i += 4) {
|
|
19084
|
+
swap(this, i, i + 3);
|
|
19085
|
+
swap(this, i + 1, i + 2);
|
|
19086
|
+
}
|
|
19087
|
+
return this;
|
|
19088
|
+
};
|
|
19089
|
+
Buffer$1.prototype.swap64 = function swap64() {
|
|
19090
|
+
var len = this.length;
|
|
19091
|
+
if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
19092
|
+
for (var i = 0; i < len; i += 8) {
|
|
19093
|
+
swap(this, i, i + 7);
|
|
19094
|
+
swap(this, i + 1, i + 6);
|
|
19095
|
+
swap(this, i + 2, i + 5);
|
|
19096
|
+
swap(this, i + 3, i + 4);
|
|
19097
|
+
}
|
|
19098
|
+
return this;
|
|
19099
|
+
};
|
|
19100
|
+
Buffer$1.prototype.toString = function toString() {
|
|
19101
|
+
var length = this.length | 0;
|
|
19102
|
+
if (length === 0) return "";
|
|
19103
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
19104
|
+
return slowToString.apply(this, arguments);
|
|
19105
|
+
};
|
|
19106
|
+
Buffer$1.prototype.equals = function equals(b) {
|
|
19107
|
+
if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
19108
|
+
if (this === b) return true;
|
|
19109
|
+
return Buffer$1.compare(this, b) === 0;
|
|
19110
|
+
};
|
|
19111
|
+
Buffer$1.prototype.inspect = function inspect() {
|
|
19112
|
+
var str = "";
|
|
19113
|
+
var max = 50;
|
|
19114
|
+
if (this.length > 0) {
|
|
19115
|
+
str = this.toString("hex", 0, max).match(/.{2}/g).join(" ");
|
|
19116
|
+
if (this.length > max) str += " ... ";
|
|
19117
|
+
}
|
|
19118
|
+
return "<Buffer " + str + ">";
|
|
19119
|
+
};
|
|
19120
|
+
Buffer$1.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
19121
|
+
if (!internalIsBuffer(target)) throw new TypeError("Argument must be a Buffer");
|
|
19122
|
+
if (start === void 0) start = 0;
|
|
19123
|
+
if (end === void 0) end = target ? target.length : 0;
|
|
19124
|
+
if (thisStart === void 0) thisStart = 0;
|
|
19125
|
+
if (thisEnd === void 0) thisEnd = this.length;
|
|
19126
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError("out of range index");
|
|
19127
|
+
if (thisStart >= thisEnd && start >= end) return 0;
|
|
19128
|
+
if (thisStart >= thisEnd) return -1;
|
|
19129
|
+
if (start >= end) return 1;
|
|
19130
|
+
start >>>= 0;
|
|
19131
|
+
end >>>= 0;
|
|
19132
|
+
thisStart >>>= 0;
|
|
19133
|
+
thisEnd >>>= 0;
|
|
19134
|
+
if (this === target) return 0;
|
|
19135
|
+
var x = thisEnd - thisStart;
|
|
19136
|
+
var y = end - start;
|
|
19137
|
+
var len = Math.min(x, y);
|
|
19138
|
+
var thisCopy = this.slice(thisStart, thisEnd);
|
|
19139
|
+
var targetCopy = target.slice(start, end);
|
|
19140
|
+
for (var i = 0; i < len; ++i) if (thisCopy[i] !== targetCopy[i]) {
|
|
19141
|
+
x = thisCopy[i];
|
|
19142
|
+
y = targetCopy[i];
|
|
19143
|
+
break;
|
|
19144
|
+
}
|
|
19145
|
+
if (x < y) return -1;
|
|
19146
|
+
if (y < x) return 1;
|
|
19147
|
+
return 0;
|
|
19148
|
+
};
|
|
19149
|
+
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
19150
|
+
if (buffer.length === 0) return -1;
|
|
19151
|
+
if (typeof byteOffset === "string") {
|
|
19152
|
+
encoding = byteOffset;
|
|
19153
|
+
byteOffset = 0;
|
|
19154
|
+
} else if (byteOffset > 2147483647) byteOffset = 2147483647;
|
|
19155
|
+
else if (byteOffset < -2147483648) byteOffset = -2147483648;
|
|
19156
|
+
byteOffset = +byteOffset;
|
|
19157
|
+
if (isNaN(byteOffset)) byteOffset = dir ? 0 : buffer.length - 1;
|
|
19158
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
19159
|
+
if (byteOffset >= buffer.length) if (dir) return -1;
|
|
19160
|
+
else byteOffset = buffer.length - 1;
|
|
19161
|
+
else if (byteOffset < 0) if (dir) byteOffset = 0;
|
|
19162
|
+
else return -1;
|
|
19163
|
+
if (typeof val === "string") val = Buffer$1.from(val, encoding);
|
|
19164
|
+
if (internalIsBuffer(val)) {
|
|
19165
|
+
if (val.length === 0) return -1;
|
|
19166
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
19167
|
+
} else if (typeof val === "number") {
|
|
19168
|
+
val = val & 255;
|
|
19169
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
19170
|
+
else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
19171
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
19172
|
+
}
|
|
19173
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
19174
|
+
}
|
|
19175
|
+
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
19176
|
+
var indexSize = 1;
|
|
19177
|
+
var arrLength = arr.length;
|
|
19178
|
+
var valLength = val.length;
|
|
19179
|
+
if (encoding !== void 0) {
|
|
19180
|
+
encoding = String(encoding).toLowerCase();
|
|
19181
|
+
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
19182
|
+
if (arr.length < 2 || val.length < 2) return -1;
|
|
19183
|
+
indexSize = 2;
|
|
19184
|
+
arrLength /= 2;
|
|
19185
|
+
valLength /= 2;
|
|
19186
|
+
byteOffset /= 2;
|
|
19187
|
+
}
|
|
19188
|
+
}
|
|
19189
|
+
function read(buf, i) {
|
|
19190
|
+
if (indexSize === 1) return buf[i];
|
|
19191
|
+
else return buf.readUInt16BE(i * indexSize);
|
|
19192
|
+
}
|
|
19193
|
+
var i;
|
|
19194
|
+
if (dir) {
|
|
19195
|
+
var foundIndex = -1;
|
|
19196
|
+
for (i = byteOffset; i < arrLength; i++) if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
19197
|
+
if (foundIndex === -1) foundIndex = i;
|
|
19198
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
|
19199
|
+
} else {
|
|
19200
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
19201
|
+
foundIndex = -1;
|
|
19202
|
+
}
|
|
19203
|
+
} else {
|
|
19204
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
19205
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
19206
|
+
var found = true;
|
|
19207
|
+
for (var j = 0; j < valLength; j++) if (read(arr, i + j) !== read(val, j)) {
|
|
19208
|
+
found = false;
|
|
19209
|
+
break;
|
|
19210
|
+
}
|
|
19211
|
+
if (found) return i;
|
|
19212
|
+
}
|
|
19213
|
+
}
|
|
19214
|
+
return -1;
|
|
19215
|
+
}
|
|
19216
|
+
Buffer$1.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
19217
|
+
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
19218
|
+
};
|
|
19219
|
+
Buffer$1.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
19220
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
19221
|
+
};
|
|
19222
|
+
Buffer$1.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
19223
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
19224
|
+
};
|
|
19225
|
+
function hexWrite(buf, string, offset, length) {
|
|
19226
|
+
offset = Number(offset) || 0;
|
|
19227
|
+
var remaining = buf.length - offset;
|
|
19228
|
+
if (!length) length = remaining;
|
|
19229
|
+
else {
|
|
19230
|
+
length = Number(length);
|
|
19231
|
+
if (length > remaining) length = remaining;
|
|
19232
|
+
}
|
|
19233
|
+
var strLen = string.length;
|
|
19234
|
+
if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
|
|
19235
|
+
if (length > strLen / 2) length = strLen / 2;
|
|
19236
|
+
for (var i = 0; i < length; ++i) {
|
|
19237
|
+
var parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
19238
|
+
if (isNaN(parsed)) return i;
|
|
19239
|
+
buf[offset + i] = parsed;
|
|
19240
|
+
}
|
|
19241
|
+
return i;
|
|
19242
|
+
}
|
|
19243
|
+
function utf8Write(buf, string, offset, length) {
|
|
19244
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
19245
|
+
}
|
|
19246
|
+
function asciiWrite(buf, string, offset, length) {
|
|
19247
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
19248
|
+
}
|
|
19249
|
+
function latin1Write(buf, string, offset, length) {
|
|
19250
|
+
return asciiWrite(buf, string, offset, length);
|
|
19251
|
+
}
|
|
19252
|
+
function base64Write(buf, string, offset, length) {
|
|
19253
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
19254
|
+
}
|
|
19255
|
+
function ucs2Write(buf, string, offset, length) {
|
|
19256
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
19257
|
+
}
|
|
19258
|
+
Buffer$1.prototype.write = function write(string, offset, length, encoding) {
|
|
19259
|
+
if (offset === void 0) {
|
|
19260
|
+
encoding = "utf8";
|
|
19261
|
+
length = this.length;
|
|
19262
|
+
offset = 0;
|
|
19263
|
+
} else if (length === void 0 && typeof offset === "string") {
|
|
19264
|
+
encoding = offset;
|
|
19265
|
+
length = this.length;
|
|
19266
|
+
offset = 0;
|
|
19267
|
+
} else if (isFinite(offset)) {
|
|
19268
|
+
offset = offset | 0;
|
|
19269
|
+
if (isFinite(length)) {
|
|
19270
|
+
length = length | 0;
|
|
19271
|
+
if (encoding === void 0) encoding = "utf8";
|
|
19272
|
+
} else {
|
|
19273
|
+
encoding = length;
|
|
19274
|
+
length = void 0;
|
|
19275
|
+
}
|
|
19276
|
+
} else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
|
|
19277
|
+
var remaining = this.length - offset;
|
|
19278
|
+
if (length === void 0 || length > remaining) length = remaining;
|
|
19279
|
+
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw new RangeError("Attempt to write outside buffer bounds");
|
|
19280
|
+
if (!encoding) encoding = "utf8";
|
|
19281
|
+
var loweredCase = false;
|
|
19282
|
+
for (;;) switch (encoding) {
|
|
19283
|
+
case "hex": return hexWrite(this, string, offset, length);
|
|
19284
|
+
case "utf8":
|
|
19285
|
+
case "utf-8": return utf8Write(this, string, offset, length);
|
|
19286
|
+
case "ascii": return asciiWrite(this, string, offset, length);
|
|
19287
|
+
case "latin1":
|
|
19288
|
+
case "binary": return latin1Write(this, string, offset, length);
|
|
19289
|
+
case "base64": return base64Write(this, string, offset, length);
|
|
19290
|
+
case "ucs2":
|
|
19291
|
+
case "ucs-2":
|
|
19292
|
+
case "utf16le":
|
|
19293
|
+
case "utf-16le": return ucs2Write(this, string, offset, length);
|
|
19294
|
+
default:
|
|
19295
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
19296
|
+
encoding = ("" + encoding).toLowerCase();
|
|
19297
|
+
loweredCase = true;
|
|
19298
|
+
}
|
|
19299
|
+
};
|
|
19300
|
+
Buffer$1.prototype.toJSON = function toJSON() {
|
|
19301
|
+
return {
|
|
19302
|
+
type: "Buffer",
|
|
19303
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
19304
|
+
};
|
|
19305
|
+
};
|
|
19306
|
+
function base64Slice(buf, start, end) {
|
|
19307
|
+
if (start === 0 && end === buf.length) return fromByteArray(buf);
|
|
19308
|
+
else return fromByteArray(buf.slice(start, end));
|
|
19309
|
+
}
|
|
19310
|
+
function utf8Slice(buf, start, end) {
|
|
19311
|
+
end = Math.min(buf.length, end);
|
|
19312
|
+
var res = [];
|
|
19313
|
+
var i = start;
|
|
19314
|
+
while (i < end) {
|
|
19315
|
+
var firstByte = buf[i];
|
|
19316
|
+
var codePoint = null;
|
|
19317
|
+
var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
19318
|
+
if (i + bytesPerSequence <= end) {
|
|
19319
|
+
var secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
19320
|
+
switch (bytesPerSequence) {
|
|
19321
|
+
case 1:
|
|
19322
|
+
if (firstByte < 128) codePoint = firstByte;
|
|
19323
|
+
break;
|
|
19324
|
+
case 2:
|
|
19325
|
+
secondByte = buf[i + 1];
|
|
19326
|
+
if ((secondByte & 192) === 128) {
|
|
19327
|
+
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
19328
|
+
if (tempCodePoint > 127) codePoint = tempCodePoint;
|
|
19329
|
+
}
|
|
19330
|
+
break;
|
|
19331
|
+
case 3:
|
|
19332
|
+
secondByte = buf[i + 1];
|
|
19333
|
+
thirdByte = buf[i + 2];
|
|
19334
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
19335
|
+
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
19336
|
+
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) codePoint = tempCodePoint;
|
|
19337
|
+
}
|
|
19338
|
+
break;
|
|
19339
|
+
case 4:
|
|
19340
|
+
secondByte = buf[i + 1];
|
|
19341
|
+
thirdByte = buf[i + 2];
|
|
19342
|
+
fourthByte = buf[i + 3];
|
|
19343
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
19344
|
+
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
19345
|
+
if (tempCodePoint > 65535 && tempCodePoint < 1114112) codePoint = tempCodePoint;
|
|
19346
|
+
}
|
|
19347
|
+
}
|
|
19348
|
+
}
|
|
19349
|
+
if (codePoint === null) {
|
|
19350
|
+
codePoint = 65533;
|
|
19351
|
+
bytesPerSequence = 1;
|
|
19352
|
+
} else if (codePoint > 65535) {
|
|
19353
|
+
codePoint -= 65536;
|
|
19354
|
+
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
19355
|
+
codePoint = 56320 | codePoint & 1023;
|
|
19356
|
+
}
|
|
19357
|
+
res.push(codePoint);
|
|
19358
|
+
i += bytesPerSequence;
|
|
19359
|
+
}
|
|
19360
|
+
return decodeCodePointsArray(res);
|
|
19361
|
+
}
|
|
19362
|
+
var MAX_ARGUMENTS_LENGTH = 4096;
|
|
19363
|
+
function decodeCodePointsArray(codePoints) {
|
|
19364
|
+
var len = codePoints.length;
|
|
19365
|
+
if (len <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints);
|
|
19366
|
+
var res = "";
|
|
19367
|
+
var i = 0;
|
|
19368
|
+
while (i < len) res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
|
|
19369
|
+
return res;
|
|
19370
|
+
}
|
|
19371
|
+
function asciiSlice(buf, start, end) {
|
|
19372
|
+
var ret = "";
|
|
19373
|
+
end = Math.min(buf.length, end);
|
|
19374
|
+
for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i] & 127);
|
|
19375
|
+
return ret;
|
|
19376
|
+
}
|
|
19377
|
+
function latin1Slice(buf, start, end) {
|
|
19378
|
+
var ret = "";
|
|
19379
|
+
end = Math.min(buf.length, end);
|
|
19380
|
+
for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i]);
|
|
19381
|
+
return ret;
|
|
19382
|
+
}
|
|
19383
|
+
function hexSlice(buf, start, end) {
|
|
19384
|
+
var len = buf.length;
|
|
19385
|
+
if (!start || start < 0) start = 0;
|
|
19386
|
+
if (!end || end < 0 || end > len) end = len;
|
|
19387
|
+
var out = "";
|
|
19388
|
+
for (var i = start; i < end; ++i) out += toHex(buf[i]);
|
|
19389
|
+
return out;
|
|
19390
|
+
}
|
|
19391
|
+
function utf16leSlice(buf, start, end) {
|
|
19392
|
+
var bytes = buf.slice(start, end);
|
|
19393
|
+
var res = "";
|
|
19394
|
+
for (var i = 0; i < bytes.length; i += 2) res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
19395
|
+
return res;
|
|
19396
|
+
}
|
|
19397
|
+
Buffer$1.prototype.slice = function slice(start, end) {
|
|
19398
|
+
var len = this.length;
|
|
19399
|
+
start = ~~start;
|
|
19400
|
+
end = end === void 0 ? len : ~~end;
|
|
19401
|
+
if (start < 0) {
|
|
19402
|
+
start += len;
|
|
19403
|
+
if (start < 0) start = 0;
|
|
19404
|
+
} else if (start > len) start = len;
|
|
19405
|
+
if (end < 0) {
|
|
19406
|
+
end += len;
|
|
19407
|
+
if (end < 0) end = 0;
|
|
19408
|
+
} else if (end > len) end = len;
|
|
19409
|
+
if (end < start) end = start;
|
|
19410
|
+
var newBuf;
|
|
19411
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19412
|
+
newBuf = this.subarray(start, end);
|
|
19413
|
+
newBuf.__proto__ = Buffer$1.prototype;
|
|
19414
|
+
} else {
|
|
19415
|
+
var sliceLen = end - start;
|
|
19416
|
+
newBuf = new Buffer$1(sliceLen, void 0);
|
|
19417
|
+
for (var i = 0; i < sliceLen; ++i) newBuf[i] = this[i + start];
|
|
19418
|
+
}
|
|
19419
|
+
return newBuf;
|
|
19420
|
+
};
|
|
19421
|
+
function checkOffset(offset, ext, length) {
|
|
19422
|
+
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
19423
|
+
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
|
19424
|
+
}
|
|
19425
|
+
Buffer$1.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
|
|
19426
|
+
offset = offset | 0;
|
|
19427
|
+
byteLength = byteLength | 0;
|
|
19428
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
19429
|
+
var val = this[offset];
|
|
19430
|
+
var mul = 1;
|
|
19431
|
+
var i = 0;
|
|
19432
|
+
while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
|
|
19433
|
+
return val;
|
|
19434
|
+
};
|
|
19435
|
+
Buffer$1.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
|
|
19436
|
+
offset = offset | 0;
|
|
19437
|
+
byteLength = byteLength | 0;
|
|
19438
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
19439
|
+
var val = this[offset + --byteLength];
|
|
19440
|
+
var mul = 1;
|
|
19441
|
+
while (byteLength > 0 && (mul *= 256)) val += this[offset + --byteLength] * mul;
|
|
19442
|
+
return val;
|
|
19443
|
+
};
|
|
19444
|
+
Buffer$1.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
19445
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
19446
|
+
return this[offset];
|
|
19447
|
+
};
|
|
19448
|
+
Buffer$1.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
19449
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
19450
|
+
return this[offset] | this[offset + 1] << 8;
|
|
19451
|
+
};
|
|
19452
|
+
Buffer$1.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
19453
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
19454
|
+
return this[offset] << 8 | this[offset + 1];
|
|
19455
|
+
};
|
|
19456
|
+
Buffer$1.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
19457
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
19458
|
+
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
19459
|
+
};
|
|
19460
|
+
Buffer$1.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
19461
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
19462
|
+
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
19463
|
+
};
|
|
19464
|
+
Buffer$1.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
|
|
19465
|
+
offset = offset | 0;
|
|
19466
|
+
byteLength = byteLength | 0;
|
|
19467
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
19468
|
+
var val = this[offset];
|
|
19469
|
+
var mul = 1;
|
|
19470
|
+
var i = 0;
|
|
19471
|
+
while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
|
|
19472
|
+
mul *= 128;
|
|
19473
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
19474
|
+
return val;
|
|
19475
|
+
};
|
|
19476
|
+
Buffer$1.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
|
|
19477
|
+
offset = offset | 0;
|
|
19478
|
+
byteLength = byteLength | 0;
|
|
19479
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
19480
|
+
var i = byteLength;
|
|
19481
|
+
var mul = 1;
|
|
19482
|
+
var val = this[offset + --i];
|
|
19483
|
+
while (i > 0 && (mul *= 256)) val += this[offset + --i] * mul;
|
|
19484
|
+
mul *= 128;
|
|
19485
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
19486
|
+
return val;
|
|
19487
|
+
};
|
|
19488
|
+
Buffer$1.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
19489
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
19490
|
+
if (!(this[offset] & 128)) return this[offset];
|
|
19491
|
+
return (255 - this[offset] + 1) * -1;
|
|
19492
|
+
};
|
|
19493
|
+
Buffer$1.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
19494
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
19495
|
+
var val = this[offset] | this[offset + 1] << 8;
|
|
19496
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
19497
|
+
};
|
|
19498
|
+
Buffer$1.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
19499
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
19500
|
+
var val = this[offset + 1] | this[offset] << 8;
|
|
19501
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
19502
|
+
};
|
|
19503
|
+
Buffer$1.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
19504
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
19505
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
19506
|
+
};
|
|
19507
|
+
Buffer$1.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
19508
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
19509
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
19510
|
+
};
|
|
19511
|
+
Buffer$1.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
19512
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
19513
|
+
return read(this, offset, true, 23, 4);
|
|
19514
|
+
};
|
|
19515
|
+
Buffer$1.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
19516
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
19517
|
+
return read(this, offset, false, 23, 4);
|
|
19518
|
+
};
|
|
19519
|
+
Buffer$1.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
19520
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
19521
|
+
return read(this, offset, true, 52, 8);
|
|
19522
|
+
};
|
|
19523
|
+
Buffer$1.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
19524
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
19525
|
+
return read(this, offset, false, 52, 8);
|
|
19526
|
+
};
|
|
19527
|
+
function checkInt(buf, value, offset, ext, max, min) {
|
|
19528
|
+
if (!internalIsBuffer(buf)) throw new TypeError("\"buffer\" argument must be a Buffer instance");
|
|
19529
|
+
if (value > max || value < min) throw new RangeError("\"value\" argument is out of bounds");
|
|
19530
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
19531
|
+
}
|
|
19532
|
+
Buffer$1.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
|
|
19533
|
+
value = +value;
|
|
19534
|
+
offset = offset | 0;
|
|
19535
|
+
byteLength = byteLength | 0;
|
|
19536
|
+
if (!noAssert) {
|
|
19537
|
+
var maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
19538
|
+
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
19539
|
+
}
|
|
19540
|
+
var mul = 1;
|
|
19541
|
+
var i = 0;
|
|
19542
|
+
this[offset] = value & 255;
|
|
19543
|
+
while (++i < byteLength && (mul *= 256)) this[offset + i] = value / mul & 255;
|
|
19544
|
+
return offset + byteLength;
|
|
19545
|
+
};
|
|
19546
|
+
Buffer$1.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
|
|
19547
|
+
value = +value;
|
|
19548
|
+
offset = offset | 0;
|
|
19549
|
+
byteLength = byteLength | 0;
|
|
19550
|
+
if (!noAssert) {
|
|
19551
|
+
var maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
19552
|
+
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
19553
|
+
}
|
|
19554
|
+
var i = byteLength - 1;
|
|
19555
|
+
var mul = 1;
|
|
19556
|
+
this[offset + i] = value & 255;
|
|
19557
|
+
while (--i >= 0 && (mul *= 256)) this[offset + i] = value / mul & 255;
|
|
19558
|
+
return offset + byteLength;
|
|
19559
|
+
};
|
|
19560
|
+
Buffer$1.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
19561
|
+
value = +value;
|
|
19562
|
+
offset = offset | 0;
|
|
19563
|
+
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
19564
|
+
if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
|
|
19565
|
+
this[offset] = value & 255;
|
|
19566
|
+
return offset + 1;
|
|
19567
|
+
};
|
|
19568
|
+
function objectWriteUInt16(buf, value, offset, littleEndian) {
|
|
19569
|
+
if (value < 0) value = 65535 + value + 1;
|
|
19570
|
+
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) buf[offset + i] = (value & 255 << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
|
|
19571
|
+
}
|
|
19572
|
+
Buffer$1.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
19573
|
+
value = +value;
|
|
19574
|
+
offset = offset | 0;
|
|
19575
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
19576
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19577
|
+
this[offset] = value & 255;
|
|
19578
|
+
this[offset + 1] = value >>> 8;
|
|
19579
|
+
} else objectWriteUInt16(this, value, offset, true);
|
|
19580
|
+
return offset + 2;
|
|
19581
|
+
};
|
|
19582
|
+
Buffer$1.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
19583
|
+
value = +value;
|
|
19584
|
+
offset = offset | 0;
|
|
19585
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
19586
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19587
|
+
this[offset] = value >>> 8;
|
|
19588
|
+
this[offset + 1] = value & 255;
|
|
19589
|
+
} else objectWriteUInt16(this, value, offset, false);
|
|
19590
|
+
return offset + 2;
|
|
19591
|
+
};
|
|
19592
|
+
function objectWriteUInt32(buf, value, offset, littleEndian) {
|
|
19593
|
+
if (value < 0) value = 4294967295 + value + 1;
|
|
19594
|
+
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
|
|
19595
|
+
}
|
|
19596
|
+
Buffer$1.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
19597
|
+
value = +value;
|
|
19598
|
+
offset = offset | 0;
|
|
19599
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
19600
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19601
|
+
this[offset + 3] = value >>> 24;
|
|
19602
|
+
this[offset + 2] = value >>> 16;
|
|
19603
|
+
this[offset + 1] = value >>> 8;
|
|
19604
|
+
this[offset] = value & 255;
|
|
19605
|
+
} else objectWriteUInt32(this, value, offset, true);
|
|
19606
|
+
return offset + 4;
|
|
19607
|
+
};
|
|
19608
|
+
Buffer$1.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
19609
|
+
value = +value;
|
|
19610
|
+
offset = offset | 0;
|
|
19611
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
19612
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19613
|
+
this[offset] = value >>> 24;
|
|
19614
|
+
this[offset + 1] = value >>> 16;
|
|
19615
|
+
this[offset + 2] = value >>> 8;
|
|
19616
|
+
this[offset + 3] = value & 255;
|
|
19617
|
+
} else objectWriteUInt32(this, value, offset, false);
|
|
19618
|
+
return offset + 4;
|
|
19619
|
+
};
|
|
19620
|
+
Buffer$1.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
|
|
19621
|
+
value = +value;
|
|
19622
|
+
offset = offset | 0;
|
|
19623
|
+
if (!noAssert) {
|
|
19624
|
+
var limit = Math.pow(2, 8 * byteLength - 1);
|
|
19625
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
19626
|
+
}
|
|
19627
|
+
var i = 0;
|
|
19628
|
+
var mul = 1;
|
|
19629
|
+
var sub = 0;
|
|
19630
|
+
this[offset] = value & 255;
|
|
19631
|
+
while (++i < byteLength && (mul *= 256)) {
|
|
19632
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1;
|
|
19633
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
19634
|
+
}
|
|
19635
|
+
return offset + byteLength;
|
|
19636
|
+
};
|
|
19637
|
+
Buffer$1.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
|
|
19638
|
+
value = +value;
|
|
19639
|
+
offset = offset | 0;
|
|
19640
|
+
if (!noAssert) {
|
|
19641
|
+
var limit = Math.pow(2, 8 * byteLength - 1);
|
|
19642
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
19643
|
+
}
|
|
19644
|
+
var i = byteLength - 1;
|
|
19645
|
+
var mul = 1;
|
|
19646
|
+
var sub = 0;
|
|
19647
|
+
this[offset + i] = value & 255;
|
|
19648
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
19649
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1;
|
|
19650
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
19651
|
+
}
|
|
19652
|
+
return offset + byteLength;
|
|
19653
|
+
};
|
|
19654
|
+
Buffer$1.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
19655
|
+
value = +value;
|
|
19656
|
+
offset = offset | 0;
|
|
19657
|
+
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
19658
|
+
if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
|
|
19659
|
+
if (value < 0) value = 255 + value + 1;
|
|
19660
|
+
this[offset] = value & 255;
|
|
19661
|
+
return offset + 1;
|
|
19662
|
+
};
|
|
19663
|
+
Buffer$1.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
19664
|
+
value = +value;
|
|
19665
|
+
offset = offset | 0;
|
|
19666
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
19667
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19668
|
+
this[offset] = value & 255;
|
|
19669
|
+
this[offset + 1] = value >>> 8;
|
|
19670
|
+
} else objectWriteUInt16(this, value, offset, true);
|
|
19671
|
+
return offset + 2;
|
|
19672
|
+
};
|
|
19673
|
+
Buffer$1.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
19674
|
+
value = +value;
|
|
19675
|
+
offset = offset | 0;
|
|
19676
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
19677
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19678
|
+
this[offset] = value >>> 8;
|
|
19679
|
+
this[offset + 1] = value & 255;
|
|
19680
|
+
} else objectWriteUInt16(this, value, offset, false);
|
|
19681
|
+
return offset + 2;
|
|
19682
|
+
};
|
|
19683
|
+
Buffer$1.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
19684
|
+
value = +value;
|
|
19685
|
+
offset = offset | 0;
|
|
19686
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
19687
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19688
|
+
this[offset] = value & 255;
|
|
19689
|
+
this[offset + 1] = value >>> 8;
|
|
19690
|
+
this[offset + 2] = value >>> 16;
|
|
19691
|
+
this[offset + 3] = value >>> 24;
|
|
19692
|
+
} else objectWriteUInt32(this, value, offset, true);
|
|
19693
|
+
return offset + 4;
|
|
19694
|
+
};
|
|
19695
|
+
Buffer$1.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
19696
|
+
value = +value;
|
|
19697
|
+
offset = offset | 0;
|
|
19698
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
19699
|
+
if (value < 0) value = 4294967295 + value + 1;
|
|
19700
|
+
if (Buffer$1.TYPED_ARRAY_SUPPORT) {
|
|
19701
|
+
this[offset] = value >>> 24;
|
|
19702
|
+
this[offset + 1] = value >>> 16;
|
|
19703
|
+
this[offset + 2] = value >>> 8;
|
|
19704
|
+
this[offset + 3] = value & 255;
|
|
19705
|
+
} else objectWriteUInt32(this, value, offset, false);
|
|
19706
|
+
return offset + 4;
|
|
19707
|
+
};
|
|
19708
|
+
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
19709
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
19710
|
+
if (offset < 0) throw new RangeError("Index out of range");
|
|
19711
|
+
}
|
|
19712
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
19713
|
+
if (!noAssert) checkIEEE754(buf, value, offset, 4);
|
|
19714
|
+
write(buf, value, offset, littleEndian, 23, 4);
|
|
19715
|
+
return offset + 4;
|
|
19716
|
+
}
|
|
19717
|
+
Buffer$1.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
19718
|
+
return writeFloat(this, value, offset, true, noAssert);
|
|
19719
|
+
};
|
|
19720
|
+
Buffer$1.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
19721
|
+
return writeFloat(this, value, offset, false, noAssert);
|
|
19722
|
+
};
|
|
19723
|
+
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
19724
|
+
if (!noAssert) checkIEEE754(buf, value, offset, 8);
|
|
19725
|
+
write(buf, value, offset, littleEndian, 52, 8);
|
|
19726
|
+
return offset + 8;
|
|
19727
|
+
}
|
|
19728
|
+
Buffer$1.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
19729
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
19730
|
+
};
|
|
19731
|
+
Buffer$1.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
19732
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
19733
|
+
};
|
|
19734
|
+
Buffer$1.prototype.copy = function copy(target, targetStart, start, end) {
|
|
19735
|
+
if (!start) start = 0;
|
|
19736
|
+
if (!end && end !== 0) end = this.length;
|
|
19737
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
19738
|
+
if (!targetStart) targetStart = 0;
|
|
19739
|
+
if (end > 0 && end < start) end = start;
|
|
19740
|
+
if (end === start) return 0;
|
|
19741
|
+
if (target.length === 0 || this.length === 0) return 0;
|
|
19742
|
+
if (targetStart < 0) throw new RangeError("targetStart out of bounds");
|
|
19743
|
+
if (start < 0 || start >= this.length) throw new RangeError("sourceStart out of bounds");
|
|
19744
|
+
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
19745
|
+
if (end > this.length) end = this.length;
|
|
19746
|
+
if (target.length - targetStart < end - start) end = target.length - targetStart + start;
|
|
19747
|
+
var len = end - start;
|
|
19748
|
+
var i;
|
|
19749
|
+
if (this === target && start < targetStart && targetStart < end) for (i = len - 1; i >= 0; --i) target[i + targetStart] = this[i + start];
|
|
19750
|
+
else if (len < 1e3 || !Buffer$1.TYPED_ARRAY_SUPPORT) for (i = 0; i < len; ++i) target[i + targetStart] = this[i + start];
|
|
19751
|
+
else Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
|
|
19752
|
+
return len;
|
|
19753
|
+
};
|
|
19754
|
+
Buffer$1.prototype.fill = function fill(val, start, end, encoding) {
|
|
19755
|
+
if (typeof val === "string") {
|
|
19756
|
+
if (typeof start === "string") {
|
|
19757
|
+
encoding = start;
|
|
19758
|
+
start = 0;
|
|
19759
|
+
end = this.length;
|
|
19760
|
+
} else if (typeof end === "string") {
|
|
19761
|
+
encoding = end;
|
|
19762
|
+
end = this.length;
|
|
19763
|
+
}
|
|
19764
|
+
if (val.length === 1) {
|
|
19765
|
+
var code = val.charCodeAt(0);
|
|
19766
|
+
if (code < 256) val = code;
|
|
19767
|
+
}
|
|
19768
|
+
if (encoding !== void 0 && typeof encoding !== "string") throw new TypeError("encoding must be a string");
|
|
19769
|
+
if (typeof encoding === "string" && !Buffer$1.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding);
|
|
19770
|
+
} else if (typeof val === "number") val = val & 255;
|
|
19771
|
+
if (start < 0 || this.length < start || this.length < end) throw new RangeError("Out of range index");
|
|
19772
|
+
if (end <= start) return this;
|
|
19773
|
+
start = start >>> 0;
|
|
19774
|
+
end = end === void 0 ? this.length : end >>> 0;
|
|
19775
|
+
if (!val) val = 0;
|
|
19776
|
+
var i;
|
|
19777
|
+
if (typeof val === "number") for (i = start; i < end; ++i) this[i] = val;
|
|
19778
|
+
else {
|
|
19779
|
+
var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer$1(val, encoding).toString());
|
|
19780
|
+
var len = bytes.length;
|
|
19781
|
+
for (i = 0; i < end - start; ++i) this[i + start] = bytes[i % len];
|
|
19782
|
+
}
|
|
19783
|
+
return this;
|
|
19784
|
+
};
|
|
19785
|
+
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
|
|
19786
|
+
function base64clean(str) {
|
|
19787
|
+
str = stringtrim(str).replace(INVALID_BASE64_RE, "");
|
|
19788
|
+
if (str.length < 2) return "";
|
|
19789
|
+
while (str.length % 4 !== 0) str = str + "=";
|
|
19790
|
+
return str;
|
|
19791
|
+
}
|
|
19792
|
+
function stringtrim(str) {
|
|
19793
|
+
if (str.trim) return str.trim();
|
|
19794
|
+
return str.replace(/^\s+|\s+$/g, "");
|
|
19795
|
+
}
|
|
19796
|
+
function toHex(n) {
|
|
19797
|
+
if (n < 16) return "0" + n.toString(16);
|
|
19798
|
+
return n.toString(16);
|
|
19799
|
+
}
|
|
19800
|
+
function utf8ToBytes(string, units) {
|
|
19801
|
+
units = units || Infinity;
|
|
19802
|
+
var codePoint;
|
|
19803
|
+
var length = string.length;
|
|
19804
|
+
var leadSurrogate = null;
|
|
19805
|
+
var bytes = [];
|
|
19806
|
+
for (var i = 0; i < length; ++i) {
|
|
19807
|
+
codePoint = string.charCodeAt(i);
|
|
19808
|
+
if (codePoint > 55295 && codePoint < 57344) {
|
|
19809
|
+
if (!leadSurrogate) {
|
|
19810
|
+
if (codePoint > 56319) {
|
|
19811
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
19812
|
+
continue;
|
|
19813
|
+
} else if (i + 1 === length) {
|
|
19814
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
19815
|
+
continue;
|
|
19816
|
+
}
|
|
19817
|
+
leadSurrogate = codePoint;
|
|
19818
|
+
continue;
|
|
19819
|
+
}
|
|
19820
|
+
if (codePoint < 56320) {
|
|
19821
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
19822
|
+
leadSurrogate = codePoint;
|
|
19823
|
+
continue;
|
|
19824
|
+
}
|
|
19825
|
+
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
19826
|
+
} else if (leadSurrogate) {
|
|
19827
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
19828
|
+
}
|
|
19829
|
+
leadSurrogate = null;
|
|
19830
|
+
if (codePoint < 128) {
|
|
19831
|
+
if ((units -= 1) < 0) break;
|
|
19832
|
+
bytes.push(codePoint);
|
|
19833
|
+
} else if (codePoint < 2048) {
|
|
19834
|
+
if ((units -= 2) < 0) break;
|
|
19835
|
+
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
|
|
19836
|
+
} else if (codePoint < 65536) {
|
|
19837
|
+
if ((units -= 3) < 0) break;
|
|
19838
|
+
bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
|
|
19839
|
+
} else if (codePoint < 1114112) {
|
|
19840
|
+
if ((units -= 4) < 0) break;
|
|
19841
|
+
bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
|
|
19842
|
+
} else throw new Error("Invalid code point");
|
|
19843
|
+
}
|
|
19844
|
+
return bytes;
|
|
19845
|
+
}
|
|
19846
|
+
function asciiToBytes(str) {
|
|
19847
|
+
var byteArray = [];
|
|
19848
|
+
for (var i = 0; i < str.length; ++i) byteArray.push(str.charCodeAt(i) & 255);
|
|
19849
|
+
return byteArray;
|
|
19850
|
+
}
|
|
19851
|
+
function utf16leToBytes(str, units) {
|
|
19852
|
+
var c, hi, lo;
|
|
19853
|
+
var byteArray = [];
|
|
19854
|
+
for (var i = 0; i < str.length; ++i) {
|
|
19855
|
+
if ((units -= 2) < 0) break;
|
|
19856
|
+
c = str.charCodeAt(i);
|
|
19857
|
+
hi = c >> 8;
|
|
19858
|
+
lo = c % 256;
|
|
19859
|
+
byteArray.push(lo);
|
|
19860
|
+
byteArray.push(hi);
|
|
19861
|
+
}
|
|
19862
|
+
return byteArray;
|
|
19863
|
+
}
|
|
19864
|
+
function base64ToBytes(str) {
|
|
19865
|
+
return toByteArray(base64clean(str));
|
|
19866
|
+
}
|
|
19867
|
+
function blitBuffer(src, dst, offset, length) {
|
|
19868
|
+
for (var i = 0; i < length; ++i) {
|
|
19869
|
+
if (i + offset >= dst.length || i >= src.length) break;
|
|
19870
|
+
dst[i + offset] = src[i];
|
|
19871
|
+
}
|
|
19872
|
+
return i;
|
|
19873
|
+
}
|
|
19874
|
+
function isnan(val) {
|
|
19875
|
+
return val !== val;
|
|
19876
|
+
}
|
|
19877
|
+
function isBuffer(obj) {
|
|
19878
|
+
return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
|
|
19879
|
+
}
|
|
19880
|
+
function isFastBuffer(obj) {
|
|
19881
|
+
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
19882
|
+
}
|
|
19883
|
+
function isSlowBuffer(obj) {
|
|
19884
|
+
return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
|
|
19885
|
+
}
|
|
19886
|
+
//#endregion
|
|
19887
|
+
//#region \0polyfill-node.process.js
|
|
19888
|
+
function defaultSetTimout() {
|
|
19889
|
+
throw new Error("setTimeout has not been defined");
|
|
19890
|
+
}
|
|
19891
|
+
function defaultClearTimeout() {
|
|
19892
|
+
throw new Error("clearTimeout has not been defined");
|
|
19893
|
+
}
|
|
19894
|
+
var cachedSetTimeout = defaultSetTimout;
|
|
19895
|
+
var cachedClearTimeout = defaultClearTimeout;
|
|
19896
|
+
if (typeof _polyfill_node_global_default.setTimeout === "function") cachedSetTimeout = setTimeout;
|
|
19897
|
+
if (typeof _polyfill_node_global_default.clearTimeout === "function") cachedClearTimeout = clearTimeout;
|
|
19898
|
+
function runTimeout(fun) {
|
|
19899
|
+
if (cachedSetTimeout === setTimeout) return setTimeout(fun, 0);
|
|
19900
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
19901
|
+
cachedSetTimeout = setTimeout;
|
|
19902
|
+
return setTimeout(fun, 0);
|
|
19903
|
+
}
|
|
19904
|
+
try {
|
|
19905
|
+
return cachedSetTimeout(fun, 0);
|
|
19906
|
+
} catch (e) {
|
|
19907
|
+
try {
|
|
19908
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
19909
|
+
} catch (e) {
|
|
19910
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
19911
|
+
}
|
|
19912
|
+
}
|
|
19913
|
+
}
|
|
19914
|
+
function runClearTimeout(marker) {
|
|
19915
|
+
if (cachedClearTimeout === clearTimeout) return clearTimeout(marker);
|
|
19916
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
19917
|
+
cachedClearTimeout = clearTimeout;
|
|
19918
|
+
return clearTimeout(marker);
|
|
19919
|
+
}
|
|
19920
|
+
try {
|
|
19921
|
+
return cachedClearTimeout(marker);
|
|
19922
|
+
} catch (e) {
|
|
19923
|
+
try {
|
|
19924
|
+
return cachedClearTimeout.call(null, marker);
|
|
19925
|
+
} catch (e) {
|
|
19926
|
+
return cachedClearTimeout.call(this, marker);
|
|
19927
|
+
}
|
|
19928
|
+
}
|
|
19929
|
+
}
|
|
19930
|
+
var queue = [];
|
|
19931
|
+
var draining = false;
|
|
19932
|
+
var currentQueue;
|
|
19933
|
+
var queueIndex = -1;
|
|
19934
|
+
function cleanUpNextTick() {
|
|
19935
|
+
if (!draining || !currentQueue) return;
|
|
19936
|
+
draining = false;
|
|
19937
|
+
if (currentQueue.length) queue = currentQueue.concat(queue);
|
|
19938
|
+
else queueIndex = -1;
|
|
19939
|
+
if (queue.length) drainQueue();
|
|
19940
|
+
}
|
|
19941
|
+
function drainQueue() {
|
|
19942
|
+
if (draining) return;
|
|
19943
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
19944
|
+
draining = true;
|
|
19945
|
+
var len = queue.length;
|
|
19946
|
+
while (len) {
|
|
19947
|
+
currentQueue = queue;
|
|
19948
|
+
queue = [];
|
|
19949
|
+
while (++queueIndex < len) if (currentQueue) currentQueue[queueIndex].run();
|
|
19950
|
+
queueIndex = -1;
|
|
19951
|
+
len = queue.length;
|
|
19952
|
+
}
|
|
19953
|
+
currentQueue = null;
|
|
19954
|
+
draining = false;
|
|
19955
|
+
runClearTimeout(timeout);
|
|
19956
|
+
}
|
|
19957
|
+
function nextTick(fun) {
|
|
19958
|
+
var args = new Array(arguments.length - 1);
|
|
19959
|
+
if (arguments.length > 1) for (var i = 1; i < arguments.length; i++) args[i - 1] = arguments[i];
|
|
19960
|
+
queue.push(new Item(fun, args));
|
|
19961
|
+
if (queue.length === 1 && !draining) runTimeout(drainQueue);
|
|
19962
|
+
}
|
|
19963
|
+
function Item(fun, array) {
|
|
19964
|
+
this.fun = fun;
|
|
19965
|
+
this.array = array;
|
|
19966
|
+
}
|
|
19967
|
+
Item.prototype.run = function() {
|
|
19968
|
+
this.fun.apply(null, this.array);
|
|
19969
|
+
};
|
|
19970
|
+
var title = "browser";
|
|
19971
|
+
var platform = "browser";
|
|
19972
|
+
var env = {};
|
|
19973
|
+
var argv = [];
|
|
19974
|
+
var versions = {};
|
|
19975
|
+
var release = {};
|
|
19976
|
+
var config = {};
|
|
19977
|
+
function noop() {}
|
|
19978
|
+
var on = noop;
|
|
19979
|
+
var addListener = noop;
|
|
19980
|
+
var once = noop;
|
|
19981
|
+
var off = noop;
|
|
19982
|
+
var removeListener = noop;
|
|
19983
|
+
var removeAllListeners = noop;
|
|
19984
|
+
var emit = noop;
|
|
19985
|
+
function binding(name) {
|
|
19986
|
+
throw new Error("process.binding is not supported");
|
|
19987
|
+
}
|
|
19988
|
+
function cwd() {
|
|
19989
|
+
return "/";
|
|
19990
|
+
}
|
|
19991
|
+
function chdir(dir) {
|
|
19992
|
+
throw new Error("process.chdir is not supported");
|
|
19993
|
+
}
|
|
19994
|
+
function umask() {
|
|
19995
|
+
return 0;
|
|
19996
|
+
}
|
|
19997
|
+
var performance = _polyfill_node_global_default.performance || {};
|
|
19998
|
+
var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
|
|
19999
|
+
return (/* @__PURE__ */ new Date()).getTime();
|
|
20000
|
+
};
|
|
20001
|
+
function hrtime(previousTimestamp) {
|
|
20002
|
+
var clocktime = performanceNow.call(performance) * .001;
|
|
20003
|
+
var seconds = Math.floor(clocktime);
|
|
20004
|
+
var nanoseconds = Math.floor(clocktime % 1 * 1e9);
|
|
20005
|
+
if (previousTimestamp) {
|
|
20006
|
+
seconds = seconds - previousTimestamp[0];
|
|
20007
|
+
nanoseconds = nanoseconds - previousTimestamp[1];
|
|
20008
|
+
if (nanoseconds < 0) {
|
|
20009
|
+
seconds--;
|
|
20010
|
+
nanoseconds += 1e9;
|
|
20011
|
+
}
|
|
20012
|
+
}
|
|
20013
|
+
return [seconds, nanoseconds];
|
|
20014
|
+
}
|
|
20015
|
+
var startTime = /* @__PURE__ */ new Date();
|
|
20016
|
+
function uptime() {
|
|
20017
|
+
return (/* @__PURE__ */ new Date() - startTime) / 1e3;
|
|
20018
|
+
}
|
|
20019
|
+
var browser$1 = {
|
|
20020
|
+
nextTick,
|
|
20021
|
+
title,
|
|
20022
|
+
browser: true,
|
|
20023
|
+
env,
|
|
20024
|
+
argv,
|
|
20025
|
+
version: "",
|
|
20026
|
+
versions,
|
|
20027
|
+
on,
|
|
20028
|
+
addListener,
|
|
20029
|
+
once,
|
|
20030
|
+
off,
|
|
20031
|
+
removeListener,
|
|
20032
|
+
removeAllListeners,
|
|
20033
|
+
emit,
|
|
20034
|
+
binding,
|
|
20035
|
+
cwd,
|
|
20036
|
+
chdir,
|
|
20037
|
+
umask,
|
|
20038
|
+
hrtime,
|
|
20039
|
+
platform,
|
|
20040
|
+
release,
|
|
20041
|
+
config,
|
|
20042
|
+
uptime
|
|
20043
|
+
};
|
|
20044
|
+
//#endregion
|
|
20045
|
+
//#region \0polyfill-node._inherits.js
|
|
20046
|
+
var inherits;
|
|
20047
|
+
if (typeof Object.create === "function") inherits = function inherits(ctor, superCtor) {
|
|
20048
|
+
ctor.super_ = superCtor;
|
|
20049
|
+
ctor.prototype = Object.create(superCtor.prototype, { constructor: {
|
|
20050
|
+
value: ctor,
|
|
20051
|
+
enumerable: false,
|
|
20052
|
+
writable: true,
|
|
20053
|
+
configurable: true
|
|
20054
|
+
} });
|
|
20055
|
+
};
|
|
20056
|
+
else inherits = function inherits(ctor, superCtor) {
|
|
20057
|
+
ctor.super_ = superCtor;
|
|
20058
|
+
var TempCtor = function() {};
|
|
20059
|
+
TempCtor.prototype = superCtor.prototype;
|
|
20060
|
+
ctor.prototype = new TempCtor();
|
|
20061
|
+
ctor.prototype.constructor = ctor;
|
|
20062
|
+
};
|
|
20063
|
+
var _polyfill_node__inherits_default = inherits;
|
|
20064
|
+
//#endregion
|
|
20065
|
+
//#region \0polyfill-node.util.js
|
|
20066
|
+
/**
|
|
20067
|
+
* Inherit the prototype methods from one constructor into another.
|
|
20068
|
+
*
|
|
20069
|
+
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
|
20070
|
+
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
|
20071
|
+
* during bootstrapping this function needs to be rewritten using some native
|
|
20072
|
+
* functions as prototype setup using normal JavaScript does not work as
|
|
20073
|
+
* expected during bootstrapping (see mirror.js in r114903).
|
|
20074
|
+
*
|
|
20075
|
+
* @param {function} ctor Constructor function which needs to inherit the
|
|
20076
|
+
* prototype.
|
|
20077
|
+
* @param {function} superCtor Constructor function to inherit prototype from.
|
|
20078
|
+
*/
|
|
20079
|
+
var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors(obj) {
|
|
20080
|
+
var keys = Object.keys(obj);
|
|
20081
|
+
var descriptors = {};
|
|
20082
|
+
for (var i = 0; i < keys.length; i++) descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
|
|
20083
|
+
return descriptors;
|
|
20084
|
+
};
|
|
20085
|
+
var formatRegExp = /%[sdj%]/g;
|
|
20086
|
+
function format(f) {
|
|
20087
|
+
if (!isString(f)) {
|
|
20088
|
+
var objects = [];
|
|
20089
|
+
for (var i = 0; i < arguments.length; i++) objects.push(inspect(arguments[i]));
|
|
20090
|
+
return objects.join(" ");
|
|
20091
|
+
}
|
|
20092
|
+
var i = 1;
|
|
20093
|
+
var args = arguments;
|
|
20094
|
+
var len = args.length;
|
|
20095
|
+
var str = String(f).replace(formatRegExp, function(x) {
|
|
20096
|
+
if (x === "%%") return "%";
|
|
20097
|
+
if (i >= len) return x;
|
|
20098
|
+
switch (x) {
|
|
20099
|
+
case "%s": return String(args[i++]);
|
|
20100
|
+
case "%d": return Number(args[i++]);
|
|
20101
|
+
case "%j": try {
|
|
20102
|
+
return JSON.stringify(args[i++]);
|
|
20103
|
+
} catch (_) {
|
|
20104
|
+
return "[Circular]";
|
|
20105
|
+
}
|
|
20106
|
+
default: return x;
|
|
20107
|
+
}
|
|
20108
|
+
});
|
|
20109
|
+
for (var x = args[i]; i < len; x = args[++i]) if (isNull(x) || !isObject(x)) str += " " + x;
|
|
20110
|
+
else str += " " + inspect(x);
|
|
20111
|
+
return str;
|
|
20112
|
+
}
|
|
20113
|
+
function deprecate(fn, msg) {
|
|
20114
|
+
if (isUndefined(_polyfill_node_global_default.process)) return function() {
|
|
20115
|
+
return deprecate(fn, msg).apply(this, arguments);
|
|
20116
|
+
};
|
|
20117
|
+
if (browser$1.noDeprecation === true) return fn;
|
|
20118
|
+
var warned = false;
|
|
20119
|
+
function deprecated() {
|
|
20120
|
+
if (!warned) {
|
|
20121
|
+
if (browser$1.throwDeprecation) throw new Error(msg);
|
|
20122
|
+
else if (browser$1.traceDeprecation) console.trace(msg);
|
|
20123
|
+
else console.error(msg);
|
|
20124
|
+
warned = true;
|
|
20125
|
+
}
|
|
20126
|
+
return fn.apply(this, arguments);
|
|
20127
|
+
}
|
|
20128
|
+
return deprecated;
|
|
20129
|
+
}
|
|
20130
|
+
var debugs = {};
|
|
20131
|
+
var debugEnviron;
|
|
20132
|
+
function debuglog(set) {
|
|
20133
|
+
if (isUndefined(debugEnviron)) debugEnviron = browser$1.env.NODE_DEBUG || "";
|
|
20134
|
+
set = set.toUpperCase();
|
|
20135
|
+
if (!debugs[set]) if (new RegExp("\\b" + set + "\\b", "i").test(debugEnviron)) {
|
|
20136
|
+
var pid = 0;
|
|
20137
|
+
debugs[set] = function() {
|
|
20138
|
+
var msg = format.apply(null, arguments);
|
|
20139
|
+
console.error("%s %d: %s", set, pid, msg);
|
|
20140
|
+
};
|
|
20141
|
+
} else debugs[set] = function() {};
|
|
20142
|
+
return debugs[set];
|
|
20143
|
+
}
|
|
20144
|
+
/**
|
|
20145
|
+
* Echos the value of a value. Trys to print the value out
|
|
20146
|
+
* in the best way possible given the different types.
|
|
20147
|
+
*
|
|
20148
|
+
* @param {Object} obj The object to print out.
|
|
20149
|
+
* @param {Object} opts Optional options object that alters the output.
|
|
20150
|
+
*/
|
|
20151
|
+
function inspect(obj, opts) {
|
|
20152
|
+
var ctx = {
|
|
20153
|
+
seen: [],
|
|
20154
|
+
stylize: stylizeNoColor
|
|
20155
|
+
};
|
|
20156
|
+
if (arguments.length >= 3) ctx.depth = arguments[2];
|
|
20157
|
+
if (arguments.length >= 4) ctx.colors = arguments[3];
|
|
20158
|
+
if (isBoolean(opts)) ctx.showHidden = opts;
|
|
20159
|
+
else if (opts) _extend(ctx, opts);
|
|
20160
|
+
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
|
20161
|
+
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
|
20162
|
+
if (isUndefined(ctx.colors)) ctx.colors = false;
|
|
20163
|
+
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
|
20164
|
+
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
|
20165
|
+
return formatValue(ctx, obj, ctx.depth);
|
|
20166
|
+
}
|
|
20167
|
+
inspect.colors = {
|
|
20168
|
+
"bold": [1, 22],
|
|
20169
|
+
"italic": [3, 23],
|
|
20170
|
+
"underline": [4, 24],
|
|
20171
|
+
"inverse": [7, 27],
|
|
20172
|
+
"white": [37, 39],
|
|
20173
|
+
"grey": [90, 39],
|
|
20174
|
+
"black": [30, 39],
|
|
20175
|
+
"blue": [34, 39],
|
|
20176
|
+
"cyan": [36, 39],
|
|
20177
|
+
"green": [32, 39],
|
|
20178
|
+
"magenta": [35, 39],
|
|
20179
|
+
"red": [31, 39],
|
|
20180
|
+
"yellow": [33, 39]
|
|
20181
|
+
};
|
|
20182
|
+
inspect.styles = {
|
|
20183
|
+
"special": "cyan",
|
|
20184
|
+
"number": "yellow",
|
|
20185
|
+
"boolean": "yellow",
|
|
20186
|
+
"undefined": "grey",
|
|
20187
|
+
"null": "bold",
|
|
20188
|
+
"string": "green",
|
|
20189
|
+
"date": "magenta",
|
|
20190
|
+
"regexp": "red"
|
|
20191
|
+
};
|
|
20192
|
+
function stylizeWithColor(str, styleType) {
|
|
20193
|
+
var style = inspect.styles[styleType];
|
|
20194
|
+
if (style) return "\x1B[" + inspect.colors[style][0] + "m" + str + "\x1B[" + inspect.colors[style][1] + "m";
|
|
20195
|
+
else return str;
|
|
20196
|
+
}
|
|
20197
|
+
function stylizeNoColor(str, styleType) {
|
|
20198
|
+
return str;
|
|
20199
|
+
}
|
|
20200
|
+
function arrayToHash(array) {
|
|
20201
|
+
var hash = {};
|
|
20202
|
+
array.forEach(function(val, idx) {
|
|
20203
|
+
hash[val] = true;
|
|
20204
|
+
});
|
|
20205
|
+
return hash;
|
|
20206
|
+
}
|
|
20207
|
+
function formatValue(ctx, value, recurseTimes) {
|
|
20208
|
+
if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value)) {
|
|
20209
|
+
var ret = value.inspect(recurseTimes, ctx);
|
|
20210
|
+
if (!isString(ret)) ret = formatValue(ctx, ret, recurseTimes);
|
|
20211
|
+
return ret;
|
|
20212
|
+
}
|
|
20213
|
+
var primitive = formatPrimitive(ctx, value);
|
|
20214
|
+
if (primitive) return primitive;
|
|
20215
|
+
var keys = Object.keys(value);
|
|
20216
|
+
var visibleKeys = arrayToHash(keys);
|
|
20217
|
+
if (ctx.showHidden) keys = Object.getOwnPropertyNames(value);
|
|
20218
|
+
if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) return formatError(value);
|
|
20219
|
+
if (keys.length === 0) {
|
|
20220
|
+
if (isFunction(value)) {
|
|
20221
|
+
var name = value.name ? ": " + value.name : "";
|
|
20222
|
+
return ctx.stylize("[Function" + name + "]", "special");
|
|
20223
|
+
}
|
|
20224
|
+
if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
|
|
20225
|
+
if (isDate(value)) return ctx.stylize(Date.prototype.toString.call(value), "date");
|
|
20226
|
+
if (isError(value)) return formatError(value);
|
|
20227
|
+
}
|
|
20228
|
+
var base = "", array = false, braces = ["{", "}"];
|
|
20229
|
+
if (isArray(value)) {
|
|
20230
|
+
array = true;
|
|
20231
|
+
braces = ["[", "]"];
|
|
20232
|
+
}
|
|
20233
|
+
if (isFunction(value)) base = " [Function" + (value.name ? ": " + value.name : "") + "]";
|
|
20234
|
+
if (isRegExp(value)) base = " " + RegExp.prototype.toString.call(value);
|
|
20235
|
+
if (isDate(value)) base = " " + Date.prototype.toUTCString.call(value);
|
|
20236
|
+
if (isError(value)) base = " " + formatError(value);
|
|
20237
|
+
if (keys.length === 0 && (!array || value.length == 0)) return braces[0] + base + braces[1];
|
|
20238
|
+
if (recurseTimes < 0) if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
|
|
20239
|
+
else return ctx.stylize("[Object]", "special");
|
|
20240
|
+
ctx.seen.push(value);
|
|
20241
|
+
var output;
|
|
20242
|
+
if (array) output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
20243
|
+
else output = keys.map(function(key) {
|
|
20244
|
+
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
20245
|
+
});
|
|
20246
|
+
ctx.seen.pop();
|
|
20247
|
+
return reduceToSingleString(output, base, braces);
|
|
20248
|
+
}
|
|
20249
|
+
function formatPrimitive(ctx, value) {
|
|
20250
|
+
if (isUndefined(value)) return ctx.stylize("undefined", "undefined");
|
|
20251
|
+
if (isString(value)) {
|
|
20252
|
+
var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\"") + "'";
|
|
20253
|
+
return ctx.stylize(simple, "string");
|
|
20254
|
+
}
|
|
20255
|
+
if (isNumber(value)) return ctx.stylize("" + value, "number");
|
|
20256
|
+
if (isBoolean(value)) return ctx.stylize("" + value, "boolean");
|
|
20257
|
+
if (isNull(value)) return ctx.stylize("null", "null");
|
|
20258
|
+
}
|
|
20259
|
+
function formatError(value) {
|
|
20260
|
+
return "[" + Error.prototype.toString.call(value) + "]";
|
|
20261
|
+
}
|
|
20262
|
+
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
20263
|
+
var output = [];
|
|
20264
|
+
for (var i = 0, l = value.length; i < l; ++i) if (hasOwnProperty(value, String(i))) output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
|
|
20265
|
+
else output.push("");
|
|
20266
|
+
keys.forEach(function(key) {
|
|
20267
|
+
if (!key.match(/^\d+$/)) output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
|
|
20268
|
+
});
|
|
20269
|
+
return output;
|
|
20270
|
+
}
|
|
20271
|
+
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
20272
|
+
var name, str, desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
|
20273
|
+
if (desc.get) if (desc.set) str = ctx.stylize("[Getter/Setter]", "special");
|
|
20274
|
+
else str = ctx.stylize("[Getter]", "special");
|
|
20275
|
+
else if (desc.set) str = ctx.stylize("[Setter]", "special");
|
|
20276
|
+
if (!hasOwnProperty(visibleKeys, key)) name = "[" + key + "]";
|
|
20277
|
+
if (!str) if (ctx.seen.indexOf(desc.value) < 0) {
|
|
20278
|
+
if (isNull(recurseTimes)) str = formatValue(ctx, desc.value, null);
|
|
20279
|
+
else str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
20280
|
+
if (str.indexOf("\n") > -1) if (array) str = str.split("\n").map(function(line) {
|
|
20281
|
+
return " " + line;
|
|
20282
|
+
}).join("\n").substr(2);
|
|
20283
|
+
else str = "\n" + str.split("\n").map(function(line) {
|
|
20284
|
+
return " " + line;
|
|
20285
|
+
}).join("\n");
|
|
20286
|
+
} else str = ctx.stylize("[Circular]", "special");
|
|
20287
|
+
if (isUndefined(name)) {
|
|
20288
|
+
if (array && key.match(/^\d+$/)) return str;
|
|
20289
|
+
name = JSON.stringify("" + key);
|
|
20290
|
+
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
20291
|
+
name = name.substr(1, name.length - 2);
|
|
20292
|
+
name = ctx.stylize(name, "name");
|
|
20293
|
+
} else {
|
|
20294
|
+
name = name.replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
|
|
20295
|
+
name = ctx.stylize(name, "string");
|
|
20296
|
+
}
|
|
20297
|
+
}
|
|
20298
|
+
return name + ": " + str;
|
|
20299
|
+
}
|
|
20300
|
+
function reduceToSingleString(output, base, braces) {
|
|
20301
|
+
var numLinesEst = 0;
|
|
20302
|
+
if (output.reduce(function(prev, cur) {
|
|
20303
|
+
numLinesEst++;
|
|
20304
|
+
if (cur.indexOf("\n") >= 0) numLinesEst++;
|
|
20305
|
+
return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1;
|
|
20306
|
+
}, 0) > 60) return braces[0] + (base === "" ? "" : base + "\n ") + " " + output.join(",\n ") + " " + braces[1];
|
|
20307
|
+
return braces[0] + base + " " + output.join(", ") + " " + braces[1];
|
|
20308
|
+
}
|
|
20309
|
+
function isArray(ar) {
|
|
20310
|
+
return Array.isArray(ar);
|
|
20311
|
+
}
|
|
20312
|
+
function isBoolean(arg) {
|
|
20313
|
+
return typeof arg === "boolean";
|
|
20314
|
+
}
|
|
20315
|
+
function isNull(arg) {
|
|
20316
|
+
return arg === null;
|
|
20317
|
+
}
|
|
20318
|
+
function isNumber(arg) {
|
|
20319
|
+
return typeof arg === "number";
|
|
20320
|
+
}
|
|
20321
|
+
function isString(arg) {
|
|
20322
|
+
return typeof arg === "string";
|
|
20323
|
+
}
|
|
20324
|
+
function isUndefined(arg) {
|
|
20325
|
+
return arg === void 0;
|
|
20326
|
+
}
|
|
20327
|
+
function isRegExp(re) {
|
|
20328
|
+
return isObject(re) && objectToString(re) === "[object RegExp]";
|
|
20329
|
+
}
|
|
20330
|
+
function isObject(arg) {
|
|
20331
|
+
return typeof arg === "object" && arg !== null;
|
|
20332
|
+
}
|
|
20333
|
+
function isDate(d) {
|
|
20334
|
+
return isObject(d) && objectToString(d) === "[object Date]";
|
|
20335
|
+
}
|
|
20336
|
+
function isError(e) {
|
|
20337
|
+
return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
|
|
20338
|
+
}
|
|
20339
|
+
function isFunction(arg) {
|
|
20340
|
+
return typeof arg === "function";
|
|
20341
|
+
}
|
|
20342
|
+
function objectToString(o) {
|
|
20343
|
+
return Object.prototype.toString.call(o);
|
|
20344
|
+
}
|
|
20345
|
+
function _extend(origin, add) {
|
|
20346
|
+
if (!add || !isObject(add)) return origin;
|
|
20347
|
+
var keys = Object.keys(add);
|
|
20348
|
+
var i = keys.length;
|
|
20349
|
+
while (i--) origin[keys[i]] = add[keys[i]];
|
|
20350
|
+
return origin;
|
|
20351
|
+
}
|
|
20352
|
+
function hasOwnProperty(obj, prop) {
|
|
20353
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
20354
|
+
}
|
|
20355
|
+
var kCustomPromisifiedSymbol = typeof Symbol !== "undefined" ? Symbol("util.promisify.custom") : void 0;
|
|
20356
|
+
function promisify(original) {
|
|
20357
|
+
if (typeof original !== "function") throw new TypeError("The \"original\" argument must be of type Function");
|
|
20358
|
+
if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
|
|
20359
|
+
var fn = original[kCustomPromisifiedSymbol];
|
|
20360
|
+
if (typeof fn !== "function") throw new TypeError("The \"util.promisify.custom\" argument must be of type Function");
|
|
20361
|
+
Object.defineProperty(fn, kCustomPromisifiedSymbol, {
|
|
20362
|
+
value: fn,
|
|
20363
|
+
enumerable: false,
|
|
20364
|
+
writable: false,
|
|
20365
|
+
configurable: true
|
|
20366
|
+
});
|
|
20367
|
+
return fn;
|
|
20368
|
+
}
|
|
20369
|
+
function fn() {
|
|
20370
|
+
var promiseResolve, promiseReject;
|
|
20371
|
+
var promise = new Promise(function(resolve, reject) {
|
|
20372
|
+
promiseResolve = resolve;
|
|
20373
|
+
promiseReject = reject;
|
|
20374
|
+
});
|
|
20375
|
+
var args = [];
|
|
20376
|
+
for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);
|
|
20377
|
+
args.push(function(err, value) {
|
|
20378
|
+
if (err) promiseReject(err);
|
|
20379
|
+
else promiseResolve(value);
|
|
20380
|
+
});
|
|
20381
|
+
try {
|
|
20382
|
+
original.apply(this, args);
|
|
20383
|
+
} catch (err) {
|
|
20384
|
+
promiseReject(err);
|
|
20385
|
+
}
|
|
20386
|
+
return promise;
|
|
20387
|
+
}
|
|
20388
|
+
Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
|
|
20389
|
+
if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
|
|
20390
|
+
value: fn,
|
|
20391
|
+
enumerable: false,
|
|
20392
|
+
writable: false,
|
|
20393
|
+
configurable: true
|
|
20394
|
+
});
|
|
20395
|
+
return Object.defineProperties(fn, getOwnPropertyDescriptors(original));
|
|
20396
|
+
}
|
|
20397
|
+
promisify.custom = kCustomPromisifiedSymbol;
|
|
20398
|
+
//#endregion
|
|
20399
|
+
//#region \0polyfill-node._buffer_list.js
|
|
20400
|
+
var _polyfill_node__buffer_list_default = BufferList;
|
|
20401
|
+
function BufferList() {
|
|
20402
|
+
this.head = null;
|
|
20403
|
+
this.tail = null;
|
|
20404
|
+
this.length = 0;
|
|
20405
|
+
}
|
|
20406
|
+
BufferList.prototype.push = function(v) {
|
|
20407
|
+
var entry = {
|
|
20408
|
+
data: v,
|
|
20409
|
+
next: null
|
|
20410
|
+
};
|
|
20411
|
+
if (this.length > 0) this.tail.next = entry;
|
|
20412
|
+
else this.head = entry;
|
|
20413
|
+
this.tail = entry;
|
|
20414
|
+
++this.length;
|
|
20415
|
+
};
|
|
20416
|
+
BufferList.prototype.unshift = function(v) {
|
|
20417
|
+
var entry = {
|
|
20418
|
+
data: v,
|
|
20419
|
+
next: this.head
|
|
20420
|
+
};
|
|
20421
|
+
if (this.length === 0) this.tail = entry;
|
|
20422
|
+
this.head = entry;
|
|
20423
|
+
++this.length;
|
|
20424
|
+
};
|
|
20425
|
+
BufferList.prototype.shift = function() {
|
|
20426
|
+
if (this.length === 0) return;
|
|
20427
|
+
var ret = this.head.data;
|
|
20428
|
+
if (this.length === 1) this.head = this.tail = null;
|
|
20429
|
+
else this.head = this.head.next;
|
|
20430
|
+
--this.length;
|
|
20431
|
+
return ret;
|
|
20432
|
+
};
|
|
20433
|
+
BufferList.prototype.clear = function() {
|
|
20434
|
+
this.head = this.tail = null;
|
|
20435
|
+
this.length = 0;
|
|
20436
|
+
};
|
|
20437
|
+
BufferList.prototype.join = function(s) {
|
|
20438
|
+
if (this.length === 0) return "";
|
|
20439
|
+
var p = this.head;
|
|
20440
|
+
var ret = "" + p.data;
|
|
20441
|
+
while (p = p.next) ret += s + p.data;
|
|
20442
|
+
return ret;
|
|
20443
|
+
};
|
|
20444
|
+
BufferList.prototype.concat = function(n) {
|
|
20445
|
+
if (this.length === 0) return Buffer$1.alloc(0);
|
|
20446
|
+
if (this.length === 1) return this.head.data;
|
|
20447
|
+
var ret = Buffer$1.allocUnsafe(n >>> 0);
|
|
20448
|
+
var p = this.head;
|
|
20449
|
+
var i = 0;
|
|
20450
|
+
while (p) {
|
|
20451
|
+
p.data.copy(ret, i);
|
|
20452
|
+
i += p.data.length;
|
|
20453
|
+
p = p.next;
|
|
20454
|
+
}
|
|
20455
|
+
return ret;
|
|
20456
|
+
};
|
|
20457
|
+
//#endregion
|
|
20458
|
+
//#region \0polyfill-node.string_decoder.js
|
|
20459
|
+
var isBufferEncoding = Buffer$1.isEncoding || function(encoding) {
|
|
20460
|
+
switch (encoding && encoding.toLowerCase()) {
|
|
20461
|
+
case "hex":
|
|
20462
|
+
case "utf8":
|
|
20463
|
+
case "utf-8":
|
|
20464
|
+
case "ascii":
|
|
20465
|
+
case "binary":
|
|
20466
|
+
case "base64":
|
|
20467
|
+
case "ucs2":
|
|
20468
|
+
case "ucs-2":
|
|
20469
|
+
case "utf16le":
|
|
20470
|
+
case "utf-16le":
|
|
20471
|
+
case "raw": return true;
|
|
20472
|
+
default: return false;
|
|
20473
|
+
}
|
|
20474
|
+
};
|
|
20475
|
+
function assertEncoding(encoding) {
|
|
20476
|
+
if (encoding && !isBufferEncoding(encoding)) throw new Error("Unknown encoding: " + encoding);
|
|
20477
|
+
}
|
|
20478
|
+
function StringDecoder(encoding) {
|
|
20479
|
+
this.encoding = (encoding || "utf8").toLowerCase().replace(/[-_]/, "");
|
|
20480
|
+
assertEncoding(encoding);
|
|
20481
|
+
switch (this.encoding) {
|
|
20482
|
+
case "utf8":
|
|
20483
|
+
this.surrogateSize = 3;
|
|
20484
|
+
break;
|
|
20485
|
+
case "ucs2":
|
|
20486
|
+
case "utf16le":
|
|
20487
|
+
this.surrogateSize = 2;
|
|
20488
|
+
this.detectIncompleteChar = utf16DetectIncompleteChar;
|
|
20489
|
+
break;
|
|
20490
|
+
case "base64":
|
|
20491
|
+
this.surrogateSize = 3;
|
|
20492
|
+
this.detectIncompleteChar = base64DetectIncompleteChar;
|
|
20493
|
+
break;
|
|
20494
|
+
default:
|
|
20495
|
+
this.write = passThroughWrite;
|
|
20496
|
+
return;
|
|
20497
|
+
}
|
|
20498
|
+
this.charBuffer = new Buffer$1(6);
|
|
20499
|
+
this.charReceived = 0;
|
|
20500
|
+
this.charLength = 0;
|
|
20501
|
+
}
|
|
20502
|
+
StringDecoder.prototype.write = function(buffer) {
|
|
20503
|
+
var charStr = "";
|
|
20504
|
+
while (this.charLength) {
|
|
20505
|
+
var available = buffer.length >= this.charLength - this.charReceived ? this.charLength - this.charReceived : buffer.length;
|
|
20506
|
+
buffer.copy(this.charBuffer, this.charReceived, 0, available);
|
|
20507
|
+
this.charReceived += available;
|
|
20508
|
+
if (this.charReceived < this.charLength) return "";
|
|
20509
|
+
buffer = buffer.slice(available, buffer.length);
|
|
20510
|
+
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
|
20511
|
+
var charCode = charStr.charCodeAt(charStr.length - 1);
|
|
20512
|
+
if (charCode >= 55296 && charCode <= 56319) {
|
|
20513
|
+
this.charLength += this.surrogateSize;
|
|
20514
|
+
charStr = "";
|
|
20515
|
+
continue;
|
|
20516
|
+
}
|
|
20517
|
+
this.charReceived = this.charLength = 0;
|
|
20518
|
+
if (buffer.length === 0) return charStr;
|
|
20519
|
+
break;
|
|
20520
|
+
}
|
|
20521
|
+
this.detectIncompleteChar(buffer);
|
|
20522
|
+
var end = buffer.length;
|
|
20523
|
+
if (this.charLength) {
|
|
20524
|
+
buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
|
|
20525
|
+
end -= this.charReceived;
|
|
20526
|
+
}
|
|
20527
|
+
charStr += buffer.toString(this.encoding, 0, end);
|
|
20528
|
+
var end = charStr.length - 1;
|
|
20529
|
+
var charCode = charStr.charCodeAt(end);
|
|
20530
|
+
if (charCode >= 55296 && charCode <= 56319) {
|
|
20531
|
+
var size = this.surrogateSize;
|
|
20532
|
+
this.charLength += size;
|
|
20533
|
+
this.charReceived += size;
|
|
20534
|
+
this.charBuffer.copy(this.charBuffer, size, 0, size);
|
|
20535
|
+
buffer.copy(this.charBuffer, 0, 0, size);
|
|
20536
|
+
return charStr.substring(0, end);
|
|
20537
|
+
}
|
|
20538
|
+
return charStr;
|
|
20539
|
+
};
|
|
20540
|
+
StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
|
20541
|
+
var i = buffer.length >= 3 ? 3 : buffer.length;
|
|
20542
|
+
for (; i > 0; i--) {
|
|
20543
|
+
var c = buffer[buffer.length - i];
|
|
20544
|
+
if (i == 1 && c >> 5 == 6) {
|
|
20545
|
+
this.charLength = 2;
|
|
20546
|
+
break;
|
|
20547
|
+
}
|
|
20548
|
+
if (i <= 2 && c >> 4 == 14) {
|
|
20549
|
+
this.charLength = 3;
|
|
20550
|
+
break;
|
|
20551
|
+
}
|
|
20552
|
+
if (i <= 3 && c >> 3 == 30) {
|
|
20553
|
+
this.charLength = 4;
|
|
20554
|
+
break;
|
|
20555
|
+
}
|
|
20556
|
+
}
|
|
20557
|
+
this.charReceived = i;
|
|
20558
|
+
};
|
|
20559
|
+
StringDecoder.prototype.end = function(buffer) {
|
|
20560
|
+
var res = "";
|
|
20561
|
+
if (buffer && buffer.length) res = this.write(buffer);
|
|
20562
|
+
if (this.charReceived) {
|
|
20563
|
+
var cr = this.charReceived;
|
|
20564
|
+
var buf = this.charBuffer;
|
|
20565
|
+
var enc = this.encoding;
|
|
20566
|
+
res += buf.slice(0, cr).toString(enc);
|
|
20567
|
+
}
|
|
20568
|
+
return res;
|
|
20569
|
+
};
|
|
20570
|
+
function passThroughWrite(buffer) {
|
|
20571
|
+
return buffer.toString(this.encoding);
|
|
20572
|
+
}
|
|
20573
|
+
function utf16DetectIncompleteChar(buffer) {
|
|
20574
|
+
this.charReceived = buffer.length % 2;
|
|
20575
|
+
this.charLength = this.charReceived ? 2 : 0;
|
|
20576
|
+
}
|
|
20577
|
+
function base64DetectIncompleteChar(buffer) {
|
|
20578
|
+
this.charReceived = buffer.length % 3;
|
|
20579
|
+
this.charLength = this.charReceived ? 3 : 0;
|
|
20580
|
+
}
|
|
20581
|
+
//#endregion
|
|
20582
|
+
//#region \0polyfill-node._stream_readable.js
|
|
20583
|
+
Readable.ReadableState = ReadableState;
|
|
20584
|
+
var debug = debuglog("stream");
|
|
20585
|
+
_polyfill_node__inherits_default(Readable, EventEmitter);
|
|
20586
|
+
function prependListener(emitter, event, fn) {
|
|
20587
|
+
if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
|
|
20588
|
+
else if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
|
|
20589
|
+
else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);
|
|
20590
|
+
else emitter._events[event] = [fn, emitter._events[event]];
|
|
20591
|
+
}
|
|
20592
|
+
function listenerCount(emitter, type) {
|
|
20593
|
+
return emitter.listeners(type).length;
|
|
20594
|
+
}
|
|
20595
|
+
function ReadableState(options, stream) {
|
|
20596
|
+
options = options || {};
|
|
20597
|
+
this.objectMode = !!options.objectMode;
|
|
20598
|
+
if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
20599
|
+
var hwm = options.highWaterMark;
|
|
20600
|
+
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
20601
|
+
this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
|
|
20602
|
+
this.highWaterMark = ~~this.highWaterMark;
|
|
20603
|
+
this.buffer = new _polyfill_node__buffer_list_default();
|
|
20604
|
+
this.length = 0;
|
|
20605
|
+
this.pipes = null;
|
|
20606
|
+
this.pipesCount = 0;
|
|
20607
|
+
this.flowing = null;
|
|
20608
|
+
this.ended = false;
|
|
20609
|
+
this.endEmitted = false;
|
|
20610
|
+
this.reading = false;
|
|
20611
|
+
this.sync = true;
|
|
20612
|
+
this.needReadable = false;
|
|
20613
|
+
this.emittedReadable = false;
|
|
20614
|
+
this.readableListening = false;
|
|
20615
|
+
this.resumeScheduled = false;
|
|
20616
|
+
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
20617
|
+
this.ranOut = false;
|
|
20618
|
+
this.awaitDrain = 0;
|
|
20619
|
+
this.readingMore = false;
|
|
20620
|
+
this.decoder = null;
|
|
20621
|
+
this.encoding = null;
|
|
20622
|
+
if (options.encoding) {
|
|
20623
|
+
this.decoder = new StringDecoder(options.encoding);
|
|
20624
|
+
this.encoding = options.encoding;
|
|
20625
|
+
}
|
|
20626
|
+
}
|
|
20627
|
+
function Readable(options) {
|
|
20628
|
+
if (!(this instanceof Readable)) return new Readable(options);
|
|
20629
|
+
this._readableState = new ReadableState(options, this);
|
|
20630
|
+
this.readable = true;
|
|
20631
|
+
if (options && typeof options.read === "function") this._read = options.read;
|
|
20632
|
+
EventEmitter.call(this);
|
|
20633
|
+
}
|
|
20634
|
+
Readable.prototype.push = function(chunk, encoding) {
|
|
20635
|
+
var state = this._readableState;
|
|
20636
|
+
if (!state.objectMode && typeof chunk === "string") {
|
|
20637
|
+
encoding = encoding || state.defaultEncoding;
|
|
20638
|
+
if (encoding !== state.encoding) {
|
|
20639
|
+
chunk = Buffer$1.from(chunk, encoding);
|
|
20640
|
+
encoding = "";
|
|
20641
|
+
}
|
|
20642
|
+
}
|
|
20643
|
+
return readableAddChunk(this, state, chunk, encoding, false);
|
|
20644
|
+
};
|
|
20645
|
+
Readable.prototype.unshift = function(chunk) {
|
|
20646
|
+
var state = this._readableState;
|
|
20647
|
+
return readableAddChunk(this, state, chunk, "", true);
|
|
20648
|
+
};
|
|
20649
|
+
Readable.prototype.isPaused = function() {
|
|
20650
|
+
return this._readableState.flowing === false;
|
|
20651
|
+
};
|
|
20652
|
+
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
|
20653
|
+
var er = chunkInvalid(state, chunk);
|
|
20654
|
+
if (er) stream.emit("error", er);
|
|
20655
|
+
else if (chunk === null) {
|
|
20656
|
+
state.reading = false;
|
|
20657
|
+
onEofChunk(stream, state);
|
|
20658
|
+
} else if (state.objectMode || chunk && chunk.length > 0) if (state.ended && !addToFront) {
|
|
20659
|
+
var e = /* @__PURE__ */ new Error("stream.push() after EOF");
|
|
20660
|
+
stream.emit("error", e);
|
|
20661
|
+
} else if (state.endEmitted && addToFront) {
|
|
20662
|
+
var _e = /* @__PURE__ */ new Error("stream.unshift() after end event");
|
|
20663
|
+
stream.emit("error", _e);
|
|
20664
|
+
} else {
|
|
20665
|
+
var skipAdd;
|
|
20666
|
+
if (state.decoder && !addToFront && !encoding) {
|
|
20667
|
+
chunk = state.decoder.write(chunk);
|
|
20668
|
+
skipAdd = !state.objectMode && chunk.length === 0;
|
|
20669
|
+
}
|
|
20670
|
+
if (!addToFront) state.reading = false;
|
|
20671
|
+
if (!skipAdd) if (state.flowing && state.length === 0 && !state.sync) {
|
|
20672
|
+
stream.emit("data", chunk);
|
|
20673
|
+
stream.read(0);
|
|
20674
|
+
} else {
|
|
20675
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
20676
|
+
if (addToFront) state.buffer.unshift(chunk);
|
|
20677
|
+
else state.buffer.push(chunk);
|
|
20678
|
+
if (state.needReadable) emitReadable(stream);
|
|
20679
|
+
}
|
|
20680
|
+
maybeReadMore(stream, state);
|
|
20681
|
+
}
|
|
20682
|
+
else if (!addToFront) state.reading = false;
|
|
20683
|
+
return needMoreData(state);
|
|
20684
|
+
}
|
|
20685
|
+
function needMoreData(state) {
|
|
20686
|
+
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
|
20687
|
+
}
|
|
20688
|
+
Readable.prototype.setEncoding = function(enc) {
|
|
20689
|
+
this._readableState.decoder = new StringDecoder(enc);
|
|
20690
|
+
this._readableState.encoding = enc;
|
|
20691
|
+
return this;
|
|
20692
|
+
};
|
|
20693
|
+
var MAX_HWM = 8388608;
|
|
20694
|
+
function computeNewHighWaterMark(n) {
|
|
20695
|
+
if (n >= MAX_HWM) n = MAX_HWM;
|
|
20696
|
+
else {
|
|
20697
|
+
n--;
|
|
20698
|
+
n |= n >>> 1;
|
|
20699
|
+
n |= n >>> 2;
|
|
20700
|
+
n |= n >>> 4;
|
|
20701
|
+
n |= n >>> 8;
|
|
20702
|
+
n |= n >>> 16;
|
|
20703
|
+
n++;
|
|
20704
|
+
}
|
|
20705
|
+
return n;
|
|
20706
|
+
}
|
|
20707
|
+
function howMuchToRead(n, state) {
|
|
20708
|
+
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
20709
|
+
if (state.objectMode) return 1;
|
|
20710
|
+
if (n !== n) if (state.flowing && state.length) return state.buffer.head.data.length;
|
|
20711
|
+
else return state.length;
|
|
20712
|
+
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
20713
|
+
if (n <= state.length) return n;
|
|
20714
|
+
if (!state.ended) {
|
|
20715
|
+
state.needReadable = true;
|
|
20716
|
+
return 0;
|
|
20717
|
+
}
|
|
20718
|
+
return state.length;
|
|
20719
|
+
}
|
|
20720
|
+
Readable.prototype.read = function(n) {
|
|
20721
|
+
debug("read", n);
|
|
20722
|
+
n = parseInt(n, 10);
|
|
20723
|
+
var state = this._readableState;
|
|
20724
|
+
var nOrig = n;
|
|
20725
|
+
if (n !== 0) state.emittedReadable = false;
|
|
20726
|
+
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
|
20727
|
+
debug("read: emitReadable", state.length, state.ended);
|
|
20728
|
+
if (state.length === 0 && state.ended) endReadable(this);
|
|
20729
|
+
else emitReadable(this);
|
|
20730
|
+
return null;
|
|
20731
|
+
}
|
|
20732
|
+
n = howMuchToRead(n, state);
|
|
20733
|
+
if (n === 0 && state.ended) {
|
|
20734
|
+
if (state.length === 0) endReadable(this);
|
|
20735
|
+
return null;
|
|
20736
|
+
}
|
|
20737
|
+
var doRead = state.needReadable;
|
|
20738
|
+
debug("need readable", doRead);
|
|
20739
|
+
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
20740
|
+
doRead = true;
|
|
20741
|
+
debug("length less than watermark", doRead);
|
|
20742
|
+
}
|
|
20743
|
+
if (state.ended || state.reading) {
|
|
20744
|
+
doRead = false;
|
|
20745
|
+
debug("reading or ended", doRead);
|
|
20746
|
+
} else if (doRead) {
|
|
20747
|
+
debug("do read");
|
|
20748
|
+
state.reading = true;
|
|
20749
|
+
state.sync = true;
|
|
20750
|
+
if (state.length === 0) state.needReadable = true;
|
|
20751
|
+
this._read(state.highWaterMark);
|
|
20752
|
+
state.sync = false;
|
|
20753
|
+
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
20754
|
+
}
|
|
20755
|
+
var ret;
|
|
20756
|
+
if (n > 0) ret = fromList(n, state);
|
|
20757
|
+
else ret = null;
|
|
20758
|
+
if (ret === null) {
|
|
20759
|
+
state.needReadable = true;
|
|
20760
|
+
n = 0;
|
|
20761
|
+
} else state.length -= n;
|
|
20762
|
+
if (state.length === 0) {
|
|
20763
|
+
if (!state.ended) state.needReadable = true;
|
|
20764
|
+
if (nOrig !== n && state.ended) endReadable(this);
|
|
20765
|
+
}
|
|
20766
|
+
if (ret !== null) this.emit("data", ret);
|
|
20767
|
+
return ret;
|
|
20768
|
+
};
|
|
20769
|
+
function chunkInvalid(state, chunk) {
|
|
20770
|
+
var er = null;
|
|
20771
|
+
if (!Buffer$1.isBuffer(chunk) && typeof chunk !== "string" && chunk !== null && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
|
|
20772
|
+
return er;
|
|
20773
|
+
}
|
|
20774
|
+
function onEofChunk(stream, state) {
|
|
20775
|
+
if (state.ended) return;
|
|
20776
|
+
if (state.decoder) {
|
|
20777
|
+
var chunk = state.decoder.end();
|
|
20778
|
+
if (chunk && chunk.length) {
|
|
20779
|
+
state.buffer.push(chunk);
|
|
20780
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
20781
|
+
}
|
|
20782
|
+
}
|
|
20783
|
+
state.ended = true;
|
|
20784
|
+
emitReadable(stream);
|
|
20785
|
+
}
|
|
20786
|
+
function emitReadable(stream) {
|
|
20787
|
+
var state = stream._readableState;
|
|
20788
|
+
state.needReadable = false;
|
|
20789
|
+
if (!state.emittedReadable) {
|
|
20790
|
+
debug("emitReadable", state.flowing);
|
|
20791
|
+
state.emittedReadable = true;
|
|
20792
|
+
if (state.sync) nextTick(emitReadable_, stream);
|
|
20793
|
+
else emitReadable_(stream);
|
|
20794
|
+
}
|
|
20795
|
+
}
|
|
20796
|
+
function emitReadable_(stream) {
|
|
20797
|
+
debug("emit readable");
|
|
20798
|
+
stream.emit("readable");
|
|
20799
|
+
flow(stream);
|
|
20800
|
+
}
|
|
20801
|
+
function maybeReadMore(stream, state) {
|
|
20802
|
+
if (!state.readingMore) {
|
|
20803
|
+
state.readingMore = true;
|
|
20804
|
+
nextTick(maybeReadMore_, stream, state);
|
|
20805
|
+
}
|
|
20806
|
+
}
|
|
20807
|
+
function maybeReadMore_(stream, state) {
|
|
20808
|
+
var len = state.length;
|
|
20809
|
+
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
|
20810
|
+
debug("maybeReadMore read 0");
|
|
20811
|
+
stream.read(0);
|
|
20812
|
+
if (len === state.length) break;
|
|
20813
|
+
else len = state.length;
|
|
20814
|
+
}
|
|
20815
|
+
state.readingMore = false;
|
|
20816
|
+
}
|
|
20817
|
+
Readable.prototype._read = function(n) {
|
|
20818
|
+
this.emit("error", /* @__PURE__ */ new Error("not implemented"));
|
|
20819
|
+
};
|
|
20820
|
+
Readable.prototype.pipe = function(dest, pipeOpts) {
|
|
20821
|
+
var src = this;
|
|
20822
|
+
var state = this._readableState;
|
|
20823
|
+
switch (state.pipesCount) {
|
|
20824
|
+
case 0:
|
|
20825
|
+
state.pipes = dest;
|
|
20826
|
+
break;
|
|
20827
|
+
case 1:
|
|
20828
|
+
state.pipes = [state.pipes, dest];
|
|
20829
|
+
break;
|
|
20830
|
+
default:
|
|
20831
|
+
state.pipes.push(dest);
|
|
20832
|
+
break;
|
|
20833
|
+
}
|
|
20834
|
+
state.pipesCount += 1;
|
|
20835
|
+
debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
|
|
20836
|
+
var endFn = !pipeOpts || pipeOpts.end !== false ? onend : cleanup;
|
|
20837
|
+
if (state.endEmitted) nextTick(endFn);
|
|
20838
|
+
else src.once("end", endFn);
|
|
20839
|
+
dest.on("unpipe", onunpipe);
|
|
20840
|
+
function onunpipe(readable) {
|
|
20841
|
+
debug("onunpipe");
|
|
20842
|
+
if (readable === src) cleanup();
|
|
20843
|
+
}
|
|
20844
|
+
function onend() {
|
|
20845
|
+
debug("onend");
|
|
20846
|
+
dest.end();
|
|
20847
|
+
}
|
|
20848
|
+
var ondrain = pipeOnDrain(src);
|
|
20849
|
+
dest.on("drain", ondrain);
|
|
20850
|
+
var cleanedUp = false;
|
|
20851
|
+
function cleanup() {
|
|
20852
|
+
debug("cleanup");
|
|
20853
|
+
dest.removeListener("close", onclose);
|
|
20854
|
+
dest.removeListener("finish", onfinish);
|
|
20855
|
+
dest.removeListener("drain", ondrain);
|
|
20856
|
+
dest.removeListener("error", onerror);
|
|
20857
|
+
dest.removeListener("unpipe", onunpipe);
|
|
20858
|
+
src.removeListener("end", onend);
|
|
20859
|
+
src.removeListener("end", cleanup);
|
|
20860
|
+
src.removeListener("data", ondata);
|
|
20861
|
+
cleanedUp = true;
|
|
20862
|
+
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
20863
|
+
}
|
|
20864
|
+
var increasedAwaitDrain = false;
|
|
20865
|
+
src.on("data", ondata);
|
|
20866
|
+
function ondata(chunk) {
|
|
20867
|
+
debug("ondata");
|
|
20868
|
+
increasedAwaitDrain = false;
|
|
20869
|
+
if (false === dest.write(chunk) && !increasedAwaitDrain) {
|
|
20870
|
+
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
20871
|
+
debug("false write response, pause", src._readableState.awaitDrain);
|
|
20872
|
+
src._readableState.awaitDrain++;
|
|
20873
|
+
increasedAwaitDrain = true;
|
|
20874
|
+
}
|
|
20875
|
+
src.pause();
|
|
20876
|
+
}
|
|
20877
|
+
}
|
|
20878
|
+
function onerror(er) {
|
|
20879
|
+
debug("onerror", er);
|
|
20880
|
+
unpipe();
|
|
20881
|
+
dest.removeListener("error", onerror);
|
|
20882
|
+
if (listenerCount(dest, "error") === 0) dest.emit("error", er);
|
|
20883
|
+
}
|
|
20884
|
+
prependListener(dest, "error", onerror);
|
|
20885
|
+
function onclose() {
|
|
20886
|
+
dest.removeListener("finish", onfinish);
|
|
20887
|
+
unpipe();
|
|
20888
|
+
}
|
|
20889
|
+
dest.once("close", onclose);
|
|
20890
|
+
function onfinish() {
|
|
20891
|
+
debug("onfinish");
|
|
20892
|
+
dest.removeListener("close", onclose);
|
|
20893
|
+
unpipe();
|
|
20894
|
+
}
|
|
20895
|
+
dest.once("finish", onfinish);
|
|
20896
|
+
function unpipe() {
|
|
20897
|
+
debug("unpipe");
|
|
20898
|
+
src.unpipe(dest);
|
|
20899
|
+
}
|
|
20900
|
+
dest.emit("pipe", src);
|
|
20901
|
+
if (!state.flowing) {
|
|
20902
|
+
debug("pipe resume");
|
|
20903
|
+
src.resume();
|
|
20904
|
+
}
|
|
20905
|
+
return dest;
|
|
20906
|
+
};
|
|
20907
|
+
function pipeOnDrain(src) {
|
|
20908
|
+
return function() {
|
|
20909
|
+
var state = src._readableState;
|
|
20910
|
+
debug("pipeOnDrain", state.awaitDrain);
|
|
20911
|
+
if (state.awaitDrain) state.awaitDrain--;
|
|
20912
|
+
if (state.awaitDrain === 0 && src.listeners("data").length) {
|
|
20913
|
+
state.flowing = true;
|
|
20914
|
+
flow(src);
|
|
20915
|
+
}
|
|
20916
|
+
};
|
|
20917
|
+
}
|
|
20918
|
+
Readable.prototype.unpipe = function(dest) {
|
|
20919
|
+
var state = this._readableState;
|
|
20920
|
+
if (state.pipesCount === 0) return this;
|
|
20921
|
+
if (state.pipesCount === 1) {
|
|
20922
|
+
if (dest && dest !== state.pipes) return this;
|
|
20923
|
+
if (!dest) dest = state.pipes;
|
|
20924
|
+
state.pipes = null;
|
|
20925
|
+
state.pipesCount = 0;
|
|
20926
|
+
state.flowing = false;
|
|
20927
|
+
if (dest) dest.emit("unpipe", this);
|
|
20928
|
+
return this;
|
|
20929
|
+
}
|
|
20930
|
+
if (!dest) {
|
|
20931
|
+
var dests = state.pipes;
|
|
20932
|
+
var len = state.pipesCount;
|
|
20933
|
+
state.pipes = null;
|
|
20934
|
+
state.pipesCount = 0;
|
|
20935
|
+
state.flowing = false;
|
|
20936
|
+
for (var _i = 0; _i < len; _i++) dests[_i].emit("unpipe", this);
|
|
20937
|
+
return this;
|
|
20938
|
+
}
|
|
20939
|
+
var i = indexOf(state.pipes, dest);
|
|
20940
|
+
if (i === -1) return this;
|
|
20941
|
+
state.pipes.splice(i, 1);
|
|
20942
|
+
state.pipesCount -= 1;
|
|
20943
|
+
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
20944
|
+
dest.emit("unpipe", this);
|
|
20945
|
+
return this;
|
|
20946
|
+
};
|
|
20947
|
+
Readable.prototype.on = function(ev, fn) {
|
|
20948
|
+
var res = EventEmitter.prototype.on.call(this, ev, fn);
|
|
20949
|
+
if (ev === "data") {
|
|
20950
|
+
if (this._readableState.flowing !== false) this.resume();
|
|
20951
|
+
} else if (ev === "readable") {
|
|
20952
|
+
var state = this._readableState;
|
|
20953
|
+
if (!state.endEmitted && !state.readableListening) {
|
|
20954
|
+
state.readableListening = state.needReadable = true;
|
|
20955
|
+
state.emittedReadable = false;
|
|
20956
|
+
if (!state.reading) nextTick(nReadingNextTick, this);
|
|
20957
|
+
else if (state.length) emitReadable(this, state);
|
|
20958
|
+
}
|
|
20959
|
+
}
|
|
20960
|
+
return res;
|
|
20961
|
+
};
|
|
20962
|
+
Readable.prototype.addListener = Readable.prototype.on;
|
|
20963
|
+
function nReadingNextTick(self) {
|
|
20964
|
+
debug("readable nexttick read 0");
|
|
20965
|
+
self.read(0);
|
|
20966
|
+
}
|
|
20967
|
+
Readable.prototype.resume = function() {
|
|
20968
|
+
var state = this._readableState;
|
|
20969
|
+
if (!state.flowing) {
|
|
20970
|
+
debug("resume");
|
|
20971
|
+
state.flowing = true;
|
|
20972
|
+
resume(this, state);
|
|
20973
|
+
}
|
|
20974
|
+
return this;
|
|
20975
|
+
};
|
|
20976
|
+
function resume(stream, state) {
|
|
20977
|
+
if (!state.resumeScheduled) {
|
|
20978
|
+
state.resumeScheduled = true;
|
|
20979
|
+
nextTick(resume_, stream, state);
|
|
20980
|
+
}
|
|
20981
|
+
}
|
|
20982
|
+
function resume_(stream, state) {
|
|
20983
|
+
if (!state.reading) {
|
|
20984
|
+
debug("resume read 0");
|
|
20985
|
+
stream.read(0);
|
|
20986
|
+
}
|
|
20987
|
+
state.resumeScheduled = false;
|
|
20988
|
+
state.awaitDrain = 0;
|
|
20989
|
+
stream.emit("resume");
|
|
20990
|
+
flow(stream);
|
|
20991
|
+
if (state.flowing && !state.reading) stream.read(0);
|
|
20992
|
+
}
|
|
20993
|
+
Readable.prototype.pause = function() {
|
|
20994
|
+
debug("call pause flowing=%j", this._readableState.flowing);
|
|
20995
|
+
if (false !== this._readableState.flowing) {
|
|
20996
|
+
debug("pause");
|
|
20997
|
+
this._readableState.flowing = false;
|
|
20998
|
+
this.emit("pause");
|
|
20999
|
+
}
|
|
21000
|
+
return this;
|
|
21001
|
+
};
|
|
21002
|
+
function flow(stream) {
|
|
21003
|
+
var state = stream._readableState;
|
|
21004
|
+
debug("flow", state.flowing);
|
|
21005
|
+
while (state.flowing && stream.read() !== null);
|
|
21006
|
+
}
|
|
21007
|
+
Readable.prototype.wrap = function(stream) {
|
|
21008
|
+
var state = this._readableState;
|
|
21009
|
+
var paused = false;
|
|
21010
|
+
var self = this;
|
|
21011
|
+
stream.on("end", function() {
|
|
21012
|
+
debug("wrapped end");
|
|
21013
|
+
if (state.decoder && !state.ended) {
|
|
21014
|
+
var chunk = state.decoder.end();
|
|
21015
|
+
if (chunk && chunk.length) self.push(chunk);
|
|
21016
|
+
}
|
|
21017
|
+
self.push(null);
|
|
21018
|
+
});
|
|
21019
|
+
stream.on("data", function(chunk) {
|
|
21020
|
+
debug("wrapped data");
|
|
21021
|
+
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
21022
|
+
if (state.objectMode && (chunk === null || chunk === void 0)) return;
|
|
21023
|
+
else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
21024
|
+
if (!self.push(chunk)) {
|
|
21025
|
+
paused = true;
|
|
21026
|
+
stream.pause();
|
|
21027
|
+
}
|
|
21028
|
+
});
|
|
21029
|
+
for (var i in stream) if (this[i] === void 0 && typeof stream[i] === "function") this[i] = function(method) {
|
|
21030
|
+
return function() {
|
|
21031
|
+
return stream[method].apply(stream, arguments);
|
|
21032
|
+
};
|
|
21033
|
+
}(i);
|
|
21034
|
+
forEach([
|
|
21035
|
+
"error",
|
|
21036
|
+
"close",
|
|
21037
|
+
"destroy",
|
|
21038
|
+
"pause",
|
|
21039
|
+
"resume"
|
|
21040
|
+
], function(ev) {
|
|
21041
|
+
stream.on(ev, self.emit.bind(self, ev));
|
|
21042
|
+
});
|
|
21043
|
+
self._read = function(n) {
|
|
21044
|
+
debug("wrapped _read", n);
|
|
21045
|
+
if (paused) {
|
|
21046
|
+
paused = false;
|
|
21047
|
+
stream.resume();
|
|
21048
|
+
}
|
|
21049
|
+
};
|
|
21050
|
+
return self;
|
|
21051
|
+
};
|
|
21052
|
+
Readable._fromList = fromList;
|
|
21053
|
+
function fromList(n, state) {
|
|
21054
|
+
if (state.length === 0) return null;
|
|
21055
|
+
var ret;
|
|
21056
|
+
if (state.objectMode) ret = state.buffer.shift();
|
|
21057
|
+
else if (!n || n >= state.length) {
|
|
21058
|
+
if (state.decoder) ret = state.buffer.join("");
|
|
21059
|
+
else if (state.buffer.length === 1) ret = state.buffer.head.data;
|
|
21060
|
+
else ret = state.buffer.concat(state.length);
|
|
21061
|
+
state.buffer.clear();
|
|
21062
|
+
} else ret = fromListPartial(n, state.buffer, state.decoder);
|
|
21063
|
+
return ret;
|
|
21064
|
+
}
|
|
21065
|
+
function fromListPartial(n, list, hasStrings) {
|
|
21066
|
+
var ret;
|
|
21067
|
+
if (n < list.head.data.length) {
|
|
21068
|
+
ret = list.head.data.slice(0, n);
|
|
21069
|
+
list.head.data = list.head.data.slice(n);
|
|
21070
|
+
} else if (n === list.head.data.length) ret = list.shift();
|
|
21071
|
+
else ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
|
21072
|
+
return ret;
|
|
21073
|
+
}
|
|
21074
|
+
function copyFromBufferString(n, list) {
|
|
21075
|
+
var p = list.head;
|
|
21076
|
+
var c = 1;
|
|
21077
|
+
var ret = p.data;
|
|
21078
|
+
n -= ret.length;
|
|
21079
|
+
while (p = p.next) {
|
|
21080
|
+
var str = p.data;
|
|
21081
|
+
var nb = n > str.length ? str.length : n;
|
|
21082
|
+
if (nb === str.length) ret += str;
|
|
21083
|
+
else ret += str.slice(0, n);
|
|
21084
|
+
n -= nb;
|
|
21085
|
+
if (n === 0) {
|
|
21086
|
+
if (nb === str.length) {
|
|
21087
|
+
++c;
|
|
21088
|
+
if (p.next) list.head = p.next;
|
|
21089
|
+
else list.head = list.tail = null;
|
|
21090
|
+
} else {
|
|
21091
|
+
list.head = p;
|
|
21092
|
+
p.data = str.slice(nb);
|
|
21093
|
+
}
|
|
21094
|
+
break;
|
|
21095
|
+
}
|
|
21096
|
+
++c;
|
|
21097
|
+
}
|
|
21098
|
+
list.length -= c;
|
|
21099
|
+
return ret;
|
|
21100
|
+
}
|
|
21101
|
+
function copyFromBuffer(n, list) {
|
|
21102
|
+
var ret = Buffer$1.allocUnsafe(n);
|
|
21103
|
+
var p = list.head;
|
|
21104
|
+
var c = 1;
|
|
21105
|
+
p.data.copy(ret);
|
|
21106
|
+
n -= p.data.length;
|
|
21107
|
+
while (p = p.next) {
|
|
21108
|
+
var buf = p.data;
|
|
21109
|
+
var nb = n > buf.length ? buf.length : n;
|
|
21110
|
+
buf.copy(ret, ret.length - n, 0, nb);
|
|
21111
|
+
n -= nb;
|
|
21112
|
+
if (n === 0) {
|
|
21113
|
+
if (nb === buf.length) {
|
|
21114
|
+
++c;
|
|
21115
|
+
if (p.next) list.head = p.next;
|
|
21116
|
+
else list.head = list.tail = null;
|
|
21117
|
+
} else {
|
|
21118
|
+
list.head = p;
|
|
21119
|
+
p.data = buf.slice(nb);
|
|
21120
|
+
}
|
|
21121
|
+
break;
|
|
21122
|
+
}
|
|
21123
|
+
++c;
|
|
21124
|
+
}
|
|
21125
|
+
list.length -= c;
|
|
21126
|
+
return ret;
|
|
21127
|
+
}
|
|
21128
|
+
function endReadable(stream) {
|
|
21129
|
+
var state = stream._readableState;
|
|
21130
|
+
if (state.length > 0) throw new Error("\"endReadable()\" called on non-empty stream");
|
|
21131
|
+
if (!state.endEmitted) {
|
|
21132
|
+
state.ended = true;
|
|
21133
|
+
nextTick(endReadableNT, state, stream);
|
|
21134
|
+
}
|
|
21135
|
+
}
|
|
21136
|
+
function endReadableNT(state, stream) {
|
|
21137
|
+
if (!state.endEmitted && state.length === 0) {
|
|
21138
|
+
state.endEmitted = true;
|
|
21139
|
+
stream.readable = false;
|
|
21140
|
+
stream.emit("end");
|
|
21141
|
+
}
|
|
21142
|
+
}
|
|
21143
|
+
function forEach(xs, f) {
|
|
21144
|
+
for (var i = 0, l = xs.length; i < l; i++) f(xs[i], i);
|
|
21145
|
+
}
|
|
21146
|
+
function indexOf(xs, x) {
|
|
21147
|
+
for (var i = 0, l = xs.length; i < l; i++) if (xs[i] === x) return i;
|
|
21148
|
+
return -1;
|
|
21149
|
+
}
|
|
21150
|
+
//#endregion
|
|
21151
|
+
//#region \0polyfill-node._stream_writable.js
|
|
21152
|
+
Writable.WritableState = WritableState;
|
|
21153
|
+
_polyfill_node__inherits_default(Writable, EventEmitter);
|
|
21154
|
+
function nop() {}
|
|
21155
|
+
function WriteReq(chunk, encoding, cb) {
|
|
21156
|
+
this.chunk = chunk;
|
|
21157
|
+
this.encoding = encoding;
|
|
21158
|
+
this.callback = cb;
|
|
21159
|
+
this.next = null;
|
|
21160
|
+
}
|
|
21161
|
+
function WritableState(options, stream) {
|
|
21162
|
+
Object.defineProperty(this, "buffer", { get: deprecate(function() {
|
|
21163
|
+
return this.getBuffer();
|
|
21164
|
+
}, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.") });
|
|
21165
|
+
options = options || {};
|
|
21166
|
+
this.objectMode = !!options.objectMode;
|
|
21167
|
+
if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
21168
|
+
var hwm = options.highWaterMark;
|
|
21169
|
+
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
21170
|
+
this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
|
|
21171
|
+
this.highWaterMark = ~~this.highWaterMark;
|
|
21172
|
+
this.needDrain = false;
|
|
21173
|
+
this.ending = false;
|
|
21174
|
+
this.ended = false;
|
|
21175
|
+
this.finished = false;
|
|
21176
|
+
this.decodeStrings = !(options.decodeStrings === false);
|
|
21177
|
+
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
21178
|
+
this.length = 0;
|
|
21179
|
+
this.writing = false;
|
|
21180
|
+
this.corked = 0;
|
|
21181
|
+
this.sync = true;
|
|
21182
|
+
this.bufferProcessing = false;
|
|
21183
|
+
this.onwrite = function(er) {
|
|
21184
|
+
onwrite(stream, er);
|
|
21185
|
+
};
|
|
21186
|
+
this.writecb = null;
|
|
21187
|
+
this.writelen = 0;
|
|
21188
|
+
this.bufferedRequest = null;
|
|
21189
|
+
this.lastBufferedRequest = null;
|
|
21190
|
+
this.pendingcb = 0;
|
|
21191
|
+
this.prefinished = false;
|
|
21192
|
+
this.errorEmitted = false;
|
|
21193
|
+
this.bufferedRequestCount = 0;
|
|
21194
|
+
this.corkedRequestsFree = new CorkedRequest(this);
|
|
21195
|
+
}
|
|
21196
|
+
WritableState.prototype.getBuffer = function writableStateGetBuffer() {
|
|
21197
|
+
var current = this.bufferedRequest;
|
|
21198
|
+
var out = [];
|
|
21199
|
+
while (current) {
|
|
21200
|
+
out.push(current);
|
|
21201
|
+
current = current.next;
|
|
21202
|
+
}
|
|
21203
|
+
return out;
|
|
21204
|
+
};
|
|
21205
|
+
function Writable(options) {
|
|
21206
|
+
if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
|
|
21207
|
+
this._writableState = new WritableState(options, this);
|
|
21208
|
+
this.writable = true;
|
|
21209
|
+
if (options) {
|
|
21210
|
+
if (typeof options.write === "function") this._write = options.write;
|
|
21211
|
+
if (typeof options.writev === "function") this._writev = options.writev;
|
|
21212
|
+
}
|
|
21213
|
+
EventEmitter.call(this);
|
|
21214
|
+
}
|
|
21215
|
+
Writable.prototype.pipe = function() {
|
|
21216
|
+
this.emit("error", /* @__PURE__ */ new Error("Cannot pipe, not readable"));
|
|
21217
|
+
};
|
|
21218
|
+
function writeAfterEnd(stream, cb) {
|
|
21219
|
+
var er = /* @__PURE__ */ new Error("write after end");
|
|
21220
|
+
stream.emit("error", er);
|
|
21221
|
+
nextTick(cb, er);
|
|
21222
|
+
}
|
|
21223
|
+
function validChunk(stream, state, chunk, cb) {
|
|
21224
|
+
var valid = true;
|
|
21225
|
+
var er = false;
|
|
21226
|
+
if (chunk === null) er = /* @__PURE__ */ new TypeError("May not write null values to stream");
|
|
21227
|
+
else if (!Buffer$1.isBuffer(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
|
|
21228
|
+
if (er) {
|
|
21229
|
+
stream.emit("error", er);
|
|
21230
|
+
nextTick(cb, er);
|
|
21231
|
+
valid = false;
|
|
21232
|
+
}
|
|
21233
|
+
return valid;
|
|
21234
|
+
}
|
|
21235
|
+
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
21236
|
+
var state = this._writableState;
|
|
21237
|
+
var ret = false;
|
|
21238
|
+
if (typeof encoding === "function") {
|
|
21239
|
+
cb = encoding;
|
|
21240
|
+
encoding = null;
|
|
21241
|
+
}
|
|
21242
|
+
if (Buffer$1.isBuffer(chunk)) encoding = "buffer";
|
|
21243
|
+
else if (!encoding) encoding = state.defaultEncoding;
|
|
21244
|
+
if (typeof cb !== "function") cb = nop;
|
|
21245
|
+
if (state.ended) writeAfterEnd(this, cb);
|
|
21246
|
+
else if (validChunk(this, state, chunk, cb)) {
|
|
21247
|
+
state.pendingcb++;
|
|
21248
|
+
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
|
21249
|
+
}
|
|
21250
|
+
return ret;
|
|
21251
|
+
};
|
|
21252
|
+
Writable.prototype.cork = function() {
|
|
21253
|
+
var state = this._writableState;
|
|
21254
|
+
state.corked++;
|
|
21255
|
+
};
|
|
21256
|
+
Writable.prototype.uncork = function() {
|
|
21257
|
+
var state = this._writableState;
|
|
21258
|
+
if (state.corked) {
|
|
21259
|
+
state.corked--;
|
|
21260
|
+
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
21261
|
+
}
|
|
21262
|
+
};
|
|
21263
|
+
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
21264
|
+
if (typeof encoding === "string") encoding = encoding.toLowerCase();
|
|
21265
|
+
if (!([
|
|
21266
|
+
"hex",
|
|
21267
|
+
"utf8",
|
|
21268
|
+
"utf-8",
|
|
21269
|
+
"ascii",
|
|
21270
|
+
"binary",
|
|
21271
|
+
"base64",
|
|
21272
|
+
"ucs2",
|
|
21273
|
+
"ucs-2",
|
|
21274
|
+
"utf16le",
|
|
21275
|
+
"utf-16le",
|
|
21276
|
+
"raw"
|
|
21277
|
+
].indexOf((encoding + "").toLowerCase()) > -1)) throw new TypeError("Unknown encoding: " + encoding);
|
|
21278
|
+
this._writableState.defaultEncoding = encoding;
|
|
21279
|
+
return this;
|
|
21280
|
+
};
|
|
21281
|
+
function decodeChunk(state, chunk, encoding) {
|
|
21282
|
+
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") chunk = Buffer$1.from(chunk, encoding);
|
|
21283
|
+
return chunk;
|
|
21284
|
+
}
|
|
21285
|
+
function writeOrBuffer(stream, state, chunk, encoding, cb) {
|
|
21286
|
+
chunk = decodeChunk(state, chunk, encoding);
|
|
21287
|
+
if (Buffer$1.isBuffer(chunk)) encoding = "buffer";
|
|
21288
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
21289
|
+
state.length += len;
|
|
21290
|
+
var ret = state.length < state.highWaterMark;
|
|
21291
|
+
if (!ret) state.needDrain = true;
|
|
21292
|
+
if (state.writing || state.corked) {
|
|
21293
|
+
var last = state.lastBufferedRequest;
|
|
21294
|
+
state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
|
|
21295
|
+
if (last) last.next = state.lastBufferedRequest;
|
|
21296
|
+
else state.bufferedRequest = state.lastBufferedRequest;
|
|
21297
|
+
state.bufferedRequestCount += 1;
|
|
21298
|
+
} else doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
21299
|
+
return ret;
|
|
21300
|
+
}
|
|
21301
|
+
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
21302
|
+
state.writelen = len;
|
|
21303
|
+
state.writecb = cb;
|
|
21304
|
+
state.writing = true;
|
|
21305
|
+
state.sync = true;
|
|
21306
|
+
if (writev) stream._writev(chunk, state.onwrite);
|
|
21307
|
+
else stream._write(chunk, encoding, state.onwrite);
|
|
21308
|
+
state.sync = false;
|
|
21309
|
+
}
|
|
21310
|
+
function onwriteError(stream, state, sync, er, cb) {
|
|
21311
|
+
--state.pendingcb;
|
|
21312
|
+
if (sync) nextTick(cb, er);
|
|
21313
|
+
else cb(er);
|
|
21314
|
+
stream._writableState.errorEmitted = true;
|
|
21315
|
+
stream.emit("error", er);
|
|
21316
|
+
}
|
|
21317
|
+
function onwriteStateUpdate(state) {
|
|
21318
|
+
state.writing = false;
|
|
21319
|
+
state.writecb = null;
|
|
21320
|
+
state.length -= state.writelen;
|
|
21321
|
+
state.writelen = 0;
|
|
21322
|
+
}
|
|
21323
|
+
function onwrite(stream, er) {
|
|
21324
|
+
var state = stream._writableState;
|
|
21325
|
+
var sync = state.sync;
|
|
21326
|
+
var cb = state.writecb;
|
|
21327
|
+
onwriteStateUpdate(state);
|
|
21328
|
+
if (er) onwriteError(stream, state, sync, er, cb);
|
|
21329
|
+
else {
|
|
21330
|
+
var finished = needFinish(state);
|
|
21331
|
+
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(stream, state);
|
|
21332
|
+
if (sync) nextTick(afterWrite, stream, state, finished, cb);
|
|
21333
|
+
else afterWrite(stream, state, finished, cb);
|
|
21334
|
+
}
|
|
21335
|
+
}
|
|
21336
|
+
function afterWrite(stream, state, finished, cb) {
|
|
21337
|
+
if (!finished) onwriteDrain(stream, state);
|
|
21338
|
+
state.pendingcb--;
|
|
21339
|
+
cb();
|
|
21340
|
+
finishMaybe(stream, state);
|
|
21341
|
+
}
|
|
21342
|
+
function onwriteDrain(stream, state) {
|
|
21343
|
+
if (state.length === 0 && state.needDrain) {
|
|
21344
|
+
state.needDrain = false;
|
|
21345
|
+
stream.emit("drain");
|
|
21346
|
+
}
|
|
21347
|
+
}
|
|
21348
|
+
function clearBuffer(stream, state) {
|
|
21349
|
+
state.bufferProcessing = true;
|
|
21350
|
+
var entry = state.bufferedRequest;
|
|
21351
|
+
if (stream._writev && entry && entry.next) {
|
|
21352
|
+
var l = state.bufferedRequestCount;
|
|
21353
|
+
var buffer = new Array(l);
|
|
21354
|
+
var holder = state.corkedRequestsFree;
|
|
21355
|
+
holder.entry = entry;
|
|
21356
|
+
var count = 0;
|
|
21357
|
+
while (entry) {
|
|
21358
|
+
buffer[count] = entry;
|
|
21359
|
+
entry = entry.next;
|
|
21360
|
+
count += 1;
|
|
21361
|
+
}
|
|
21362
|
+
doWrite(stream, state, true, state.length, buffer, "", holder.finish);
|
|
21363
|
+
state.pendingcb++;
|
|
21364
|
+
state.lastBufferedRequest = null;
|
|
21365
|
+
if (holder.next) {
|
|
21366
|
+
state.corkedRequestsFree = holder.next;
|
|
21367
|
+
holder.next = null;
|
|
21368
|
+
} else state.corkedRequestsFree = new CorkedRequest(state);
|
|
21369
|
+
} else {
|
|
21370
|
+
while (entry) {
|
|
21371
|
+
var chunk = entry.chunk;
|
|
21372
|
+
var encoding = entry.encoding;
|
|
21373
|
+
var cb = entry.callback;
|
|
21374
|
+
doWrite(stream, state, false, state.objectMode ? 1 : chunk.length, chunk, encoding, cb);
|
|
21375
|
+
entry = entry.next;
|
|
21376
|
+
if (state.writing) break;
|
|
21377
|
+
}
|
|
21378
|
+
if (entry === null) state.lastBufferedRequest = null;
|
|
21379
|
+
}
|
|
21380
|
+
state.bufferedRequestCount = 0;
|
|
21381
|
+
state.bufferedRequest = entry;
|
|
21382
|
+
state.bufferProcessing = false;
|
|
21383
|
+
}
|
|
21384
|
+
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
21385
|
+
cb(/* @__PURE__ */ new Error("not implemented"));
|
|
21386
|
+
};
|
|
21387
|
+
Writable.prototype._writev = null;
|
|
21388
|
+
Writable.prototype.end = function(chunk, encoding, cb) {
|
|
21389
|
+
var state = this._writableState;
|
|
21390
|
+
if (typeof chunk === "function") {
|
|
21391
|
+
cb = chunk;
|
|
21392
|
+
chunk = null;
|
|
21393
|
+
encoding = null;
|
|
21394
|
+
} else if (typeof encoding === "function") {
|
|
21395
|
+
cb = encoding;
|
|
21396
|
+
encoding = null;
|
|
21397
|
+
}
|
|
21398
|
+
if (chunk !== null && chunk !== void 0) this.write(chunk, encoding);
|
|
21399
|
+
if (state.corked) {
|
|
21400
|
+
state.corked = 1;
|
|
21401
|
+
this.uncork();
|
|
21402
|
+
}
|
|
21403
|
+
if (!state.ending && !state.finished) endWritable(this, state, cb);
|
|
21404
|
+
};
|
|
21405
|
+
function needFinish(state) {
|
|
21406
|
+
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
21407
|
+
}
|
|
21408
|
+
function prefinish(stream, state) {
|
|
21409
|
+
if (!state.prefinished) {
|
|
21410
|
+
state.prefinished = true;
|
|
21411
|
+
stream.emit("prefinish");
|
|
21412
|
+
}
|
|
21413
|
+
}
|
|
21414
|
+
function finishMaybe(stream, state) {
|
|
21415
|
+
var need = needFinish(state);
|
|
21416
|
+
if (need) if (state.pendingcb === 0) {
|
|
21417
|
+
prefinish(stream, state);
|
|
21418
|
+
state.finished = true;
|
|
21419
|
+
stream.emit("finish");
|
|
21420
|
+
} else prefinish(stream, state);
|
|
21421
|
+
return need;
|
|
21422
|
+
}
|
|
21423
|
+
function endWritable(stream, state, cb) {
|
|
21424
|
+
state.ending = true;
|
|
21425
|
+
finishMaybe(stream, state);
|
|
21426
|
+
if (cb) if (state.finished) nextTick(cb);
|
|
21427
|
+
else stream.once("finish", cb);
|
|
21428
|
+
state.ended = true;
|
|
21429
|
+
stream.writable = false;
|
|
21430
|
+
}
|
|
21431
|
+
function CorkedRequest(state) {
|
|
21432
|
+
var _this = this;
|
|
21433
|
+
this.next = null;
|
|
21434
|
+
this.entry = null;
|
|
21435
|
+
this.finish = function(err) {
|
|
21436
|
+
var entry = _this.entry;
|
|
21437
|
+
_this.entry = null;
|
|
21438
|
+
while (entry) {
|
|
21439
|
+
var cb = entry.callback;
|
|
21440
|
+
state.pendingcb--;
|
|
21441
|
+
cb(err);
|
|
21442
|
+
entry = entry.next;
|
|
21443
|
+
}
|
|
21444
|
+
if (state.corkedRequestsFree) state.corkedRequestsFree.next = _this;
|
|
21445
|
+
else state.corkedRequestsFree = _this;
|
|
21446
|
+
};
|
|
21447
|
+
}
|
|
21448
|
+
//#endregion
|
|
21449
|
+
//#region \0polyfill-node._stream_duplex.js
|
|
21450
|
+
_polyfill_node__inherits_default(Duplex, Readable);
|
|
21451
|
+
var keys = Object.keys(Writable.prototype);
|
|
21452
|
+
for (var v = 0; v < keys.length; v++) {
|
|
21453
|
+
var method = keys[v];
|
|
21454
|
+
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
21455
|
+
}
|
|
21456
|
+
function Duplex(options) {
|
|
21457
|
+
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
21458
|
+
Readable.call(this, options);
|
|
21459
|
+
Writable.call(this, options);
|
|
21460
|
+
if (options && options.readable === false) this.readable = false;
|
|
21461
|
+
if (options && options.writable === false) this.writable = false;
|
|
21462
|
+
this.allowHalfOpen = true;
|
|
21463
|
+
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
|
21464
|
+
this.once("end", onend);
|
|
21465
|
+
}
|
|
21466
|
+
function onend() {
|
|
21467
|
+
if (this.allowHalfOpen || this._writableState.ended) return;
|
|
21468
|
+
nextTick(onEndNT, this);
|
|
21469
|
+
}
|
|
21470
|
+
function onEndNT(self) {
|
|
21471
|
+
self.end();
|
|
21472
|
+
}
|
|
21473
|
+
//#endregion
|
|
21474
|
+
//#region src/util/output-type.ts
|
|
21475
|
+
/**
|
|
21476
|
+
* Output type definitions for document generation.
|
|
21477
|
+
*
|
|
21478
|
+
* This module defines the various output formats supported when generating
|
|
21479
|
+
* .docx files. These types correspond to fflate's output formats.
|
|
21480
|
+
*
|
|
21481
|
+
* @module
|
|
21482
|
+
*/
|
|
21483
|
+
/**
|
|
21484
|
+
* Converts a Uint8Array to the specified output type.
|
|
21485
|
+
*
|
|
21486
|
+
* This is used by both the Packer and patchDocument to convert fflate's
|
|
21487
|
+
* raw Uint8Array output into the user's requested format.
|
|
21488
|
+
*/
|
|
21489
|
+
const convertOutput = (data, type) => {
|
|
21490
|
+
switch (type) {
|
|
21491
|
+
case "nodebuffer": return Buffer$1.from(data);
|
|
21492
|
+
case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
|
21493
|
+
case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
21494
|
+
case "uint8array": return data;
|
|
21495
|
+
case "base64": return btoa((0, fflate.strFromU8)(data, true));
|
|
21496
|
+
case "string":
|
|
21497
|
+
case "text":
|
|
21498
|
+
case "binarystring": return (0, fflate.strFromU8)(data, true);
|
|
21499
|
+
case "array": return [...data];
|
|
21500
|
+
default: return data;
|
|
21501
|
+
}
|
|
21502
|
+
};
|
|
21503
|
+
//#endregion
|
|
21504
|
+
//#region src/file/fonts/obfuscate-ttf-to-odttf.ts
|
|
21505
|
+
/**
|
|
21506
|
+
* Font obfuscation module for embedding fonts in WordprocessingML documents.
|
|
21507
|
+
*
|
|
21508
|
+
* This module implements the OOXML font obfuscation algorithm used to embed
|
|
21509
|
+
* fonts in DOCX documents. Obfuscation is required by the OOXML specification
|
|
21510
|
+
* to prevent simple extraction of embedded font files.
|
|
21511
|
+
*
|
|
21512
|
+
* Reference: ECMA-376 Part 2, Section 11.1 (Font Embedding)
|
|
21513
|
+
*
|
|
21514
|
+
* @module
|
|
21515
|
+
*/
|
|
21516
|
+
/** Start offset for obfuscation in the font file */
|
|
21517
|
+
const obfuscatedStartOffset = 0;
|
|
21518
|
+
/** End offset for obfuscation (first 32 bytes are obfuscated) */
|
|
21519
|
+
const obfuscatedEndOffset = 32;
|
|
21520
|
+
/** Expected GUID size (32 hex characters without dashes) */
|
|
21521
|
+
const guidSize = 32;
|
|
21522
|
+
/**
|
|
21523
|
+
* Obfuscates a TrueType font file for embedding in OOXML documents.
|
|
21524
|
+
*
|
|
21525
|
+
* The obfuscation algorithm XORs the first 32 bytes of the font file
|
|
21526
|
+
* with a reversed byte sequence derived from the font's GUID key.
|
|
21527
|
+
* This prevents simple extraction while maintaining font functionality.
|
|
21528
|
+
*
|
|
21529
|
+
* @param buf - The original font file as a byte array
|
|
21530
|
+
* @param fontKey - The GUID key for the font (with or without dashes)
|
|
21531
|
+
* @returns The obfuscated font data
|
|
21532
|
+
* @throws Error if the fontKey is not a valid 32-character GUID
|
|
21533
|
+
*
|
|
21534
|
+
* @example
|
|
21535
|
+
* ```typescript
|
|
21536
|
+
* const fontData = readFileSync("font.ttf");
|
|
21537
|
+
* const fontKey = "00000000-0000-0000-0000-000000000000";
|
|
21538
|
+
* const obfuscatedData = obfuscate(fontData, fontKey);
|
|
21539
|
+
* ```
|
|
21540
|
+
*
|
|
21541
|
+
* @internal
|
|
21542
|
+
*/
|
|
21543
|
+
const obfuscate = (buf, fontKey) => {
|
|
21544
|
+
const guid = fontKey.replace(/-/g, "");
|
|
21545
|
+
if (guid.length !== guidSize) throw new Error(`Error: Cannot extract GUID from font filename: ${fontKey}`);
|
|
21546
|
+
const hexNumbers = guid.replace(/(..)/g, "$1 ").trim().split(" ").map((hexString) => parseInt(hexString, 16));
|
|
21547
|
+
hexNumbers.reverse();
|
|
21548
|
+
const obfuscatedBytes = buf.slice(obfuscatedStartOffset, obfuscatedEndOffset).map((byte, i) => byte ^ hexNumbers[i % hexNumbers.length]);
|
|
21549
|
+
const out = new Uint8Array(obfuscatedStartOffset + obfuscatedBytes.length + Math.max(0, buf.length - obfuscatedEndOffset));
|
|
21550
|
+
out.set(buf.slice(0, obfuscatedStartOffset));
|
|
21551
|
+
out.set(obfuscatedBytes, obfuscatedStartOffset);
|
|
21552
|
+
out.set(buf.slice(obfuscatedEndOffset), obfuscatedStartOffset + obfuscatedBytes.length);
|
|
21553
|
+
return out;
|
|
21554
|
+
};
|
|
21555
|
+
//#endregion
|
|
21556
|
+
//#region src/export/formatter.ts
|
|
21557
|
+
/**
|
|
21558
|
+
* Converts XML components into serializable objects ready for XML generation.
|
|
21559
|
+
*
|
|
21560
|
+
* The Formatter is responsible for preparing XML components for serialization by calling
|
|
21561
|
+
* their prepForXml method with the appropriate context. This is a critical step in the
|
|
21562
|
+
* export pipeline that transforms the declarative API objects into XML-compatible structures.
|
|
21563
|
+
*
|
|
21564
|
+
* @example
|
|
21565
|
+
* ```typescript
|
|
21566
|
+
* const formatter = new Formatter();
|
|
21567
|
+
* const paragraph = new Paragraph("Hello World");
|
|
21568
|
+
* const xmlObject = formatter.format(paragraph, context);
|
|
21569
|
+
* ```
|
|
21570
|
+
*/
|
|
21571
|
+
var Formatter = class {
|
|
21572
|
+
/**
|
|
21573
|
+
* Formats an XML component into a serializable object.
|
|
21574
|
+
*
|
|
21575
|
+
* @param input - The XML component to format
|
|
21576
|
+
* @param context - The context containing file state and relationships
|
|
21577
|
+
* @returns A serializable XML object structure
|
|
21578
|
+
* @throws Error if the component cannot be formatted correctly
|
|
21579
|
+
*/
|
|
21580
|
+
format(input, context = { stack: [] }) {
|
|
21581
|
+
const output = input.prepForXml(context);
|
|
21582
|
+
if (output) return output;
|
|
21583
|
+
else throw new Error("XMLComponent did not format correctly");
|
|
21584
|
+
}
|
|
21585
|
+
};
|
|
21586
|
+
//#endregion
|
|
21587
|
+
//#region src/export/packer/image-replacer.ts
|
|
21588
|
+
/**
|
|
21589
|
+
* Replaces image placeholders with relationship IDs in XML content.
|
|
21590
|
+
*
|
|
21591
|
+
* During document compilation, images are referenced using placeholder tokens
|
|
18408
21592
|
* like {image1.png}. This class replaces those placeholders with the actual
|
|
18409
21593
|
* relationship IDs used in the OOXML structure.
|
|
18410
21594
|
*
|
|
@@ -18886,32 +22070,6 @@
|
|
|
18886
22070
|
}
|
|
18887
22071
|
};
|
|
18888
22072
|
//#endregion
|
|
18889
|
-
//#region \0@oxc-project+runtime@0.123.0/helpers/asyncToGenerator.js
|
|
18890
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
18891
|
-
try {
|
|
18892
|
-
var i = n[a](c), u = i.value;
|
|
18893
|
-
} catch (n) {
|
|
18894
|
-
e(n);
|
|
18895
|
-
return;
|
|
18896
|
-
}
|
|
18897
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
18898
|
-
}
|
|
18899
|
-
function _asyncToGenerator(n) {
|
|
18900
|
-
return function() {
|
|
18901
|
-
var t = this, e = arguments;
|
|
18902
|
-
return new Promise(function(r, o) {
|
|
18903
|
-
var a = n.apply(t, e);
|
|
18904
|
-
function _next(n) {
|
|
18905
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
18906
|
-
}
|
|
18907
|
-
function _throw(n) {
|
|
18908
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
18909
|
-
}
|
|
18910
|
-
_next(void 0);
|
|
18911
|
-
});
|
|
18912
|
-
};
|
|
18913
|
-
}
|
|
18914
|
-
//#endregion
|
|
18915
22073
|
//#region src/export/packer/packer.ts
|
|
18916
22074
|
/**
|
|
18917
22075
|
* Packer module for exporting documents to various output formats.
|
|
@@ -18964,11 +22122,8 @@
|
|
|
18964
22122
|
* @param overrides - Optional array of file overrides for custom XML content
|
|
18965
22123
|
* @returns A promise resolving to the exported document in the specified format
|
|
18966
22124
|
*/
|
|
18967
|
-
static pack(
|
|
18968
|
-
|
|
18969
|
-
return _asyncToGenerator(function* (file, type, prettify, overrides = []) {
|
|
18970
|
-
return convertOutput((0, fflate.zipSync)(_this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
|
|
18971
|
-
}).apply(this, arguments);
|
|
22125
|
+
static async pack(file, type, prettify, overrides = []) {
|
|
22126
|
+
return convertOutput((0, fflate.zipSync)(this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
|
|
18972
22127
|
}
|
|
18973
22128
|
/**
|
|
18974
22129
|
* Exports a document to a string representation.
|
|
@@ -19044,16 +22199,20 @@
|
|
|
19044
22199
|
* ```
|
|
19045
22200
|
*/
|
|
19046
22201
|
static toStream(file, prettify, overrides = []) {
|
|
19047
|
-
|
|
22202
|
+
/* v8 ignore start */
|
|
22203
|
+
const stream = new Readable({ read() {} });
|
|
22204
|
+
/* v8 ignore stop */
|
|
19048
22205
|
try {
|
|
19049
22206
|
const files = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
|
|
19050
22207
|
const zip = new fflate.Zip((err, chunk, final) => {
|
|
22208
|
+
/* v8 ignore start */
|
|
19051
22209
|
if (err) {
|
|
19052
|
-
stream
|
|
22210
|
+
stream.destroy(err);
|
|
19053
22211
|
return;
|
|
19054
22212
|
}
|
|
19055
|
-
|
|
19056
|
-
if (
|
|
22213
|
+
/* v8 ignore stop */
|
|
22214
|
+
if (!stream.destroyed) stream.push(chunk);
|
|
22215
|
+
if (final) stream.push(null);
|
|
19057
22216
|
});
|
|
19058
22217
|
for (const [name, data] of Object.entries(files)) {
|
|
19059
22218
|
var _level;
|
|
@@ -19065,9 +22224,9 @@
|
|
|
19065
22224
|
}
|
|
19066
22225
|
zip.end();
|
|
19067
22226
|
} catch (err) {
|
|
19068
|
-
stream
|
|
22227
|
+
stream.destroy(err instanceof Error ? err : new Error(String(err)));
|
|
19069
22228
|
}
|
|
19070
|
-
return stream
|
|
22229
|
+
return stream;
|
|
19071
22230
|
}
|
|
19072
22231
|
};
|
|
19073
22232
|
_defineProperty(Packer, "compiler", new Compiler());
|
|
@@ -19136,7 +22295,10 @@
|
|
|
19136
22295
|
* // Adds xml:space="preserve" to maintain whitespace
|
|
19137
22296
|
* ```
|
|
19138
22297
|
*/
|
|
19139
|
-
const patchSpaceAttribute = (element) =>
|
|
22298
|
+
const patchSpaceAttribute = (element) => ({
|
|
22299
|
+
...element,
|
|
22300
|
+
attributes: { "xml:space": "preserve" }
|
|
22301
|
+
});
|
|
19140
22302
|
/**
|
|
19141
22303
|
* Retrieves first-level child elements by parent element name.
|
|
19142
22304
|
*
|
|
@@ -19328,14 +22490,24 @@
|
|
|
19328
22490
|
if (e.type === "element" && e.name === "w:t") {
|
|
19329
22491
|
var _ref, _e$elements;
|
|
19330
22492
|
const splitText = ((_ref = (_e$elements = e.elements) === null || _e$elements === void 0 || (_e$elements = _e$elements[0]) === null || _e$elements === void 0 ? void 0 : _e$elements.text) !== null && _ref !== void 0 ? _ref : "").split(token);
|
|
19331
|
-
const newElements = splitText.map((t) =>
|
|
22493
|
+
const newElements = splitText.map((t) => ({
|
|
22494
|
+
...e,
|
|
22495
|
+
...patchSpaceAttribute(e),
|
|
22496
|
+
elements: createTextElementContents(t)
|
|
22497
|
+
}));
|
|
19332
22498
|
if (splitText.length > 1) splitIndex = i;
|
|
19333
22499
|
return newElements;
|
|
19334
22500
|
} else return e;
|
|
19335
22501
|
}).flat()) !== null && _runElement$elements$ !== void 0 ? _runElement$elements$ : [];
|
|
19336
22502
|
return {
|
|
19337
|
-
left:
|
|
19338
|
-
|
|
22503
|
+
left: {
|
|
22504
|
+
...JSON.parse(JSON.stringify(runElement)),
|
|
22505
|
+
elements: splitElements.slice(0, splitIndex + 1)
|
|
22506
|
+
},
|
|
22507
|
+
right: {
|
|
22508
|
+
...JSON.parse(JSON.stringify(runElement)),
|
|
22509
|
+
elements: splitElements.slice(splitIndex + 1)
|
|
22510
|
+
}
|
|
19339
22511
|
};
|
|
19340
22512
|
};
|
|
19341
22513
|
//#endregion
|
|
@@ -19595,9 +22767,15 @@
|
|
|
19595
22767
|
const runElementNonTextualElements = runElementToBeReplaced.elements.filter((e) => e.type === "element" && e.name === "w:rPr");
|
|
19596
22768
|
newRunElements = textJson.map((e) => {
|
|
19597
22769
|
var _e$elements;
|
|
19598
|
-
return
|
|
22770
|
+
return {
|
|
22771
|
+
...e,
|
|
22772
|
+
elements: [...runElementNonTextualElements, ...(_e$elements = e.elements) !== null && _e$elements !== void 0 ? _e$elements : []]
|
|
22773
|
+
};
|
|
19599
22774
|
});
|
|
19600
|
-
patchedRightElement =
|
|
22775
|
+
patchedRightElement = {
|
|
22776
|
+
...right,
|
|
22777
|
+
elements: [...runElementNonTextualElements, ...right.elements]
|
|
22778
|
+
};
|
|
19601
22779
|
}
|
|
19602
22780
|
paragraphElement.elements.splice(index, 1, left, ...newRunElements, patchedRightElement);
|
|
19603
22781
|
break;
|
|
@@ -19683,69 +22861,70 @@
|
|
|
19683
22861
|
*
|
|
19684
22862
|
* @publicApi
|
|
19685
22863
|
*/
|
|
19686
|
-
const patchDocument =
|
|
19687
|
-
|
|
19688
|
-
|
|
19689
|
-
|
|
19690
|
-
|
|
19691
|
-
|
|
19692
|
-
|
|
19693
|
-
|
|
19694
|
-
|
|
19695
|
-
|
|
19696
|
-
|
|
19697
|
-
|
|
19698
|
-
|
|
19699
|
-
|
|
19700
|
-
|
|
19701
|
-
|
|
19702
|
-
|
|
19703
|
-
|
|
19704
|
-
|
|
19705
|
-
|
|
19706
|
-
|
|
19707
|
-
|
|
19708
|
-
|
|
19709
|
-
|
|
19710
|
-
|
|
19711
|
-
|
|
19712
|
-
|
|
19713
|
-
|
|
19714
|
-
|
|
19715
|
-
|
|
19716
|
-
|
|
19717
|
-
|
|
19718
|
-
|
|
19719
|
-
|
|
19720
|
-
|
|
19721
|
-
document.attributes["mc:Ignorable"] = `${document.attributes["mc:Ignorable"] || ""} w15`.trim();
|
|
19722
|
-
}
|
|
22864
|
+
const patchDocument = async ({ outputType, data, patches, keepOriginalStyles, placeholderDelimiters = {
|
|
22865
|
+
end: "}}",
|
|
22866
|
+
start: "{{"
|
|
22867
|
+
}, recursive = true }) => {
|
|
22868
|
+
const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
|
|
22869
|
+
const contexts = /* @__PURE__ */ new Map();
|
|
22870
|
+
const file = { Media: new Media() };
|
|
22871
|
+
const map = /* @__PURE__ */ new Map();
|
|
22872
|
+
const imageRelationshipAdditions = [];
|
|
22873
|
+
const hyperlinkRelationshipAdditions = [];
|
|
22874
|
+
let hasMedia = false;
|
|
22875
|
+
const binaryContentMap = /* @__PURE__ */ new Map();
|
|
22876
|
+
for (const [key, value] of Object.entries(zipContent)) {
|
|
22877
|
+
const startBytes = value.slice(0, 2);
|
|
22878
|
+
if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
|
|
22879
|
+
binaryContentMap.set(key, value);
|
|
22880
|
+
continue;
|
|
22881
|
+
}
|
|
22882
|
+
if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
|
|
22883
|
+
binaryContentMap.set(key, value);
|
|
22884
|
+
continue;
|
|
22885
|
+
}
|
|
22886
|
+
const json = toJson((0, fflate.strFromU8)(value));
|
|
22887
|
+
if (key === "word/document.xml") {
|
|
22888
|
+
var _json$elements;
|
|
22889
|
+
const document = (_json$elements = json.elements) === null || _json$elements === void 0 ? void 0 : _json$elements.find((i) => i.name === "w:document");
|
|
22890
|
+
if (document && document.attributes) {
|
|
22891
|
+
for (const ns of [
|
|
22892
|
+
"mc",
|
|
22893
|
+
"wp",
|
|
22894
|
+
"r",
|
|
22895
|
+
"w15",
|
|
22896
|
+
"m"
|
|
22897
|
+
]) document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];
|
|
22898
|
+
document.attributes["mc:Ignorable"] = `${document.attributes["mc:Ignorable"] || ""} w15`.trim();
|
|
19723
22899
|
}
|
|
19724
|
-
|
|
19725
|
-
|
|
19726
|
-
|
|
19727
|
-
|
|
19728
|
-
|
|
19729
|
-
|
|
19730
|
-
|
|
19731
|
-
|
|
19732
|
-
|
|
19733
|
-
|
|
19734
|
-
|
|
19735
|
-
|
|
19736
|
-
}
|
|
19737
|
-
}
|
|
19738
|
-
|
|
19739
|
-
|
|
19740
|
-
|
|
19741
|
-
|
|
19742
|
-
|
|
19743
|
-
|
|
19744
|
-
|
|
19745
|
-
|
|
19746
|
-
|
|
19747
|
-
|
|
19748
|
-
|
|
22900
|
+
}
|
|
22901
|
+
if (key.startsWith("word/") && !key.endsWith(".xml.rels")) {
|
|
22902
|
+
const context = {
|
|
22903
|
+
file,
|
|
22904
|
+
stack: [],
|
|
22905
|
+
viewWrapper: { Relationships: { addRelationship: (linkId, _, target, __) => {
|
|
22906
|
+
hyperlinkRelationshipAdditions.push({
|
|
22907
|
+
hyperlink: {
|
|
22908
|
+
id: linkId,
|
|
22909
|
+
link: target
|
|
22910
|
+
},
|
|
22911
|
+
key
|
|
22912
|
+
});
|
|
22913
|
+
} } }
|
|
22914
|
+
};
|
|
22915
|
+
contexts.set(key, context);
|
|
22916
|
+
if (!(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.start.trim()) || !(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.end.trim())) throw new Error("Both start and end delimiters must be non-empty strings.");
|
|
22917
|
+
const { start, end } = placeholderDelimiters;
|
|
22918
|
+
for (const [patchKey, patchValue] of Object.entries(patches)) {
|
|
22919
|
+
const patchText = `${start}${patchKey}${end}`;
|
|
22920
|
+
while (true) {
|
|
22921
|
+
const { didFindOccurrence } = replacer({
|
|
22922
|
+
context,
|
|
22923
|
+
json,
|
|
22924
|
+
keepOriginalStyles,
|
|
22925
|
+
patch: {
|
|
22926
|
+
...patchValue,
|
|
22927
|
+
children: patchValue.children.map((element) => {
|
|
19749
22928
|
if (element instanceof ExternalHyperlink) {
|
|
19750
22929
|
const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId());
|
|
19751
22930
|
hyperlinkRelationshipAdditions.push({
|
|
@@ -19757,63 +22936,60 @@
|
|
|
19757
22936
|
});
|
|
19758
22937
|
return concreteHyperlink;
|
|
19759
22938
|
} else return element;
|
|
19760
|
-
})
|
|
19761
|
-
|
|
19762
|
-
|
|
19763
|
-
if (!recursive || !didFindOccurrence) break;
|
|
19764
|
-
}
|
|
19765
|
-
}
|
|
19766
|
-
const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json), context.file.Media);
|
|
19767
|
-
if (mediaDatas.length > 0) {
|
|
19768
|
-
hasMedia = true;
|
|
19769
|
-
imageRelationshipAdditions.push({
|
|
19770
|
-
key,
|
|
19771
|
-
mediaDatas
|
|
22939
|
+
})
|
|
22940
|
+
},
|
|
22941
|
+
patchText
|
|
19772
22942
|
});
|
|
22943
|
+
if (!recursive || !didFindOccurrence) break;
|
|
19773
22944
|
}
|
|
19774
22945
|
}
|
|
19775
|
-
|
|
19776
|
-
|
|
19777
|
-
|
|
19778
|
-
|
|
19779
|
-
|
|
19780
|
-
|
|
19781
|
-
|
|
19782
|
-
const index = getNextRelationshipIndex(relationshipsJson);
|
|
19783
|
-
const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
|
|
19784
|
-
map.set(key, JSON.parse(newJson));
|
|
19785
|
-
for (let i = 0; i < mediaDatas.length; i++) {
|
|
19786
|
-
const { fileName } = mediaDatas[i];
|
|
19787
|
-
appendRelationship(relationshipsJson, index + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${fileName}`);
|
|
22946
|
+
const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json), context.file.Media);
|
|
22947
|
+
if (mediaDatas.length > 0) {
|
|
22948
|
+
hasMedia = true;
|
|
22949
|
+
imageRelationshipAdditions.push({
|
|
22950
|
+
key,
|
|
22951
|
+
mediaDatas
|
|
22952
|
+
});
|
|
19788
22953
|
}
|
|
19789
22954
|
}
|
|
19790
|
-
|
|
19791
|
-
|
|
19792
|
-
|
|
19793
|
-
|
|
19794
|
-
|
|
19795
|
-
|
|
22955
|
+
map.set(key, json);
|
|
22956
|
+
}
|
|
22957
|
+
for (const { key, mediaDatas } of imageRelationshipAdditions) {
|
|
22958
|
+
var _map$get;
|
|
22959
|
+
const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
|
|
22960
|
+
const relationshipsJson = (_map$get = map.get(relationshipKey)) !== null && _map$get !== void 0 ? _map$get : createRelationshipFile();
|
|
22961
|
+
map.set(relationshipKey, relationshipsJson);
|
|
22962
|
+
const index = getNextRelationshipIndex(relationshipsJson);
|
|
22963
|
+
const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
|
|
22964
|
+
map.set(key, JSON.parse(newJson));
|
|
22965
|
+
for (let i = 0; i < mediaDatas.length; i++) {
|
|
22966
|
+
const { fileName } = mediaDatas[i];
|
|
22967
|
+
appendRelationship(relationshipsJson, index + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${fileName}`);
|
|
19796
22968
|
}
|
|
19797
|
-
|
|
19798
|
-
|
|
19799
|
-
|
|
19800
|
-
|
|
19801
|
-
|
|
19802
|
-
|
|
19803
|
-
|
|
19804
|
-
|
|
19805
|
-
|
|
19806
|
-
|
|
19807
|
-
|
|
19808
|
-
|
|
19809
|
-
|
|
19810
|
-
|
|
19811
|
-
|
|
19812
|
-
|
|
19813
|
-
|
|
19814
|
-
|
|
19815
|
-
};
|
|
19816
|
-
|
|
22969
|
+
}
|
|
22970
|
+
for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {
|
|
22971
|
+
var _map$get2;
|
|
22972
|
+
const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
|
|
22973
|
+
const relationshipsJson = (_map$get2 = map.get(relationshipKey)) !== null && _map$get2 !== void 0 ? _map$get2 : createRelationshipFile();
|
|
22974
|
+
map.set(relationshipKey, relationshipsJson);
|
|
22975
|
+
appendRelationship(relationshipsJson, hyperlink.id, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hyperlink.link, TargetModeType.EXTERNAL);
|
|
22976
|
+
}
|
|
22977
|
+
if (hasMedia) {
|
|
22978
|
+
const contentTypesJson = map.get("[Content_Types].xml");
|
|
22979
|
+
if (!contentTypesJson) throw new Error("Could not find content types file");
|
|
22980
|
+
appendContentType(contentTypesJson, "image/png", "png");
|
|
22981
|
+
appendContentType(contentTypesJson, "image/jpeg", "jpeg");
|
|
22982
|
+
appendContentType(contentTypesJson, "image/jpeg", "jpg");
|
|
22983
|
+
appendContentType(contentTypesJson, "image/bmp", "bmp");
|
|
22984
|
+
appendContentType(contentTypesJson, "image/gif", "gif");
|
|
22985
|
+
appendContentType(contentTypesJson, "image/svg+xml", "svg");
|
|
22986
|
+
}
|
|
22987
|
+
const files = {};
|
|
22988
|
+
for (const [key, value] of map) files[key] = (0, undio.textToUint8Array)(toXml(value));
|
|
22989
|
+
for (const [key, value] of binaryContentMap) files[key] = value;
|
|
22990
|
+
for (const { data: mediaData, fileName } of file.Media.Array) files[`word/media/${fileName}`] = mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);
|
|
22991
|
+
return convertOutput((0, fflate.zipSync)(files, { level: 6 }), outputType);
|
|
22992
|
+
};
|
|
19817
22993
|
const toXml = (jsonObj) => {
|
|
19818
22994
|
return (0, xml_js.js2xml)(jsonObj, { attributeValueFn: (str) => String(str).replace(/&(?!amp;|lt;|gt;|quot;|apos;)/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'") });
|
|
19819
22995
|
};
|
|
@@ -19862,20 +23038,15 @@
|
|
|
19862
23038
|
* });
|
|
19863
23039
|
* ```
|
|
19864
23040
|
*/
|
|
19865
|
-
const patchDetector =
|
|
19866
|
-
|
|
19867
|
-
|
|
19868
|
-
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
|
|
19872
|
-
|
|
19873
|
-
|
|
19874
|
-
});
|
|
19875
|
-
return function patchDetector(_x) {
|
|
19876
|
-
return _ref.apply(this, arguments);
|
|
19877
|
-
};
|
|
19878
|
-
}();
|
|
23041
|
+
const patchDetector = async ({ data }) => {
|
|
23042
|
+
const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
|
|
23043
|
+
const patches = /* @__PURE__ */ new Set();
|
|
23044
|
+
for (const [key, value] of Object.entries(zipContent)) {
|
|
23045
|
+
if (!key.endsWith(".xml") && !key.endsWith(".rels")) continue;
|
|
23046
|
+
if (key.startsWith("word/") && !key.endsWith(".xml.rels")) traverse(toJson((0, fflate.strFromU8)(value))).forEach((p) => findPatchKeys(p.text).forEach((patch) => patches.add(patch)));
|
|
23047
|
+
}
|
|
23048
|
+
return [...patches];
|
|
23049
|
+
};
|
|
19879
23050
|
/**
|
|
19880
23051
|
* Extracts placeholder keys from text using regex pattern.
|
|
19881
23052
|
*
|
|
@@ -19884,8 +23055,7 @@
|
|
|
19884
23055
|
*/
|
|
19885
23056
|
const findPatchKeys = (text) => {
|
|
19886
23057
|
var _text$match;
|
|
19887
|
-
|
|
19888
|
-
return (_text$match = text.match(pattern)) !== null && _text$match !== void 0 ? _text$match : [];
|
|
23058
|
+
return (_text$match = text.match(/(?<=\{\{).+?(?=\}\})/gs)) !== null && _text$match !== void 0 ? _text$match : [];
|
|
19889
23059
|
};
|
|
19890
23060
|
//#endregion
|
|
19891
23061
|
exports.AbstractNumbering = AbstractNumbering;
|
|
@@ -20184,7 +23354,6 @@
|
|
|
20184
23354
|
exports.shortHexNumber = shortHexNumber;
|
|
20185
23355
|
exports.signedHpsMeasureValue = signedHpsMeasureValue;
|
|
20186
23356
|
exports.signedTwipsMeasureValue = signedTwipsMeasureValue;
|
|
20187
|
-
exports.standardizeData = standardizeData;
|
|
20188
23357
|
exports.twipsMeasureValue = twipsMeasureValue;
|
|
20189
23358
|
exports.uCharHexNumber = uCharHexNumber;
|
|
20190
23359
|
exports.uniqueId = uniqueId;
|