@office-open/pptx 0.6.1 → 0.6.3

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.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { i as __toCommonJS, n as __exportAll, r as __reExport, t as __esmMin } from "./chunk-090QGkrx.mjs";
2
- import { AppProperties, BaseXmlComponent, BuilderElement, Formatter, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PrettifyType, Relationships, StringContainer, XmlComponent, addSmartArtRelationships, buildCorePropertiesXml, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPixels as convertEmuToPixels$1, convertEmuToPoints, convertInchesToEmu, convertOutput, convertPixelsToEmu, convertPixelsToEmu as convertPixelsToEmu$1, convertPointsToEmu, convertPrettifyType, escapeRegex, formatId, getReferencedMedia, hasPlaceholders, hashedId, parseArchive, parseCorePropsElement, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, uniqueId, uniqueNumericIdCreator, uniqueUuid } from "@office-open/core";
2
+ import { AppProperties, BaseXmlComponent, BuilderElement, EmptyElement, Formatter, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PrettifyType, Relationships, XmlComponent, ZIP_STORED_LEVEL, addSmartArtRelationships, buildCorePropertiesXml, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPixels as convertEmuToPixels$1, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPixelsToEmu as convertPixelsToEmu$1, convertPointsToEmu, createPacker, escapeRegex, formatId, getReferencedMedia, hasPlaceholders, hashedId, parseArchive, parseCorePropsElement, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, stringContainerObj, uniqueId, uniqueNumericIdCreator, uniqueUuid } from "@office-open/core";
3
3
  import { BevelPresetType, CompoundLine, LineCap, LineJoin, PathShadeType, PenAlignment, PresetDash, PresetGeometry, PresetMaterialType, Stretch, TileFlipMode, buildFill, createBevel, createBlip, createBottomBevel, createColorElement, createColorTransforms, createEffectList, createEffectList as createEffectList$1, createGradientFill, createGradientStop, createGroupTransform2D, createOutline, createOutline as createOutline$1, createScene3D, createScene3D as createScene3D$1, createShape3D, createShape3D as createShape3D$1, createTransform2D, extractBlipFillMedia } from "@office-open/core/drawingml";
4
4
  import { ChartCollection, ChartSpace } from "@office-open/core/chart";
5
5
  import { DEFAULT_DRAWING_XML, SmartArtCollection, createDataModel, getColorXml, getLayoutXml, getStyleXml } from "@office-open/core/smartart";
6
6
  import { attr, attrBool, attrNum, children, findChild, findDeep, textOf, xml } from "@office-open/xml";
7
- import { Zip, ZipDeflate, ZipPassThrough, zipSync } from "fflate";
7
+ import { toUint8Array } from "undio";
8
8
  export * from "@office-open/core/values";
9
9
  //#region src/file/drawingml/effects.ts
10
10
  /** Convert PPTX simple color to core SolidFillOptions. */
@@ -18,7 +18,7 @@ function toColor(color, alpha) {
18
18
  alpha: (alpha ?? 40) * 1e3
19
19
  };
20
20
  }
21
- /** Convert PPTX IShadowOptions to core OuterShadowEffectOptions. */
21
+ /** Convert PPTX ShadowOptions to core OuterShadowEffectOptions. */
22
22
  function toOuterShadow(opts) {
23
23
  return {
24
24
  blurRadius: opts.blur,
@@ -28,7 +28,7 @@ function toOuterShadow(opts) {
28
28
  color: toColor(opts.color, opts.alpha)
29
29
  };
30
30
  }
31
- /** Convert PPTX IShadowOptions to core InnerShadowEffectOptions. */
31
+ /** Convert PPTX ShadowOptions to core InnerShadowEffectOptions. */
32
32
  function toInnerShadow(opts) {
33
33
  return {
34
34
  blurRadius: opts.blur,
@@ -37,14 +37,14 @@ function toInnerShadow(opts) {
37
37
  color: toColor(opts.color, opts.alpha)
38
38
  };
39
39
  }
40
- /** Convert PPTX IGlowOptions to core GlowEffectOptions. */
40
+ /** Convert PPTX GlowOptions to core GlowEffectOptions. */
41
41
  function toGlow(opts) {
42
42
  return {
43
43
  radius: opts.radius ?? 152400,
44
44
  color: toColor(opts.color, opts.alpha)
45
45
  };
46
46
  }
47
- /** Convert PPTX IReflectionOptions to core ReflectionEffectOptions. */
47
+ /** Convert PPTX ReflectionOptions to core ReflectionEffectOptions. */
48
48
  function toReflection(opts) {
49
49
  const result = {};
50
50
  if (opts.blurRadius !== void 0) result.blurRadius = opts.blurRadius;
@@ -63,14 +63,14 @@ function toReflection(opts) {
63
63
  if (opts.rotateWithShape === false) result.rotWithShape = 0;
64
64
  return result;
65
65
  }
66
- /** Convert PPTX IBevelOptions to core BevelOptions. */
66
+ /** Convert PPTX PPTXBevelOptions to core BevelOptions. */
67
67
  function toBevel(opts) {
68
68
  return {
69
69
  ...opts.width !== void 0 && { w: opts.width * 12700 },
70
70
  ...opts.height !== void 0 && { h: opts.height * 12700 }
71
71
  };
72
72
  }
73
- /** Map PPTX IEffectsOptions to core EffectListOptions. */
73
+ /** Map PPTX EffectsOptions to core EffectListOptions. */
74
74
  function toEffectListOptions(opts) {
75
75
  if (!(opts.outerShadow || opts.innerShadow || opts.glow || opts.reflection || opts.softEdge)) return void 0;
76
76
  return {
@@ -81,7 +81,7 @@ function toEffectListOptions(opts) {
81
81
  softEdge: opts.softEdge ? opts.softEdge.radius ?? 50800 : void 0
82
82
  };
83
83
  }
84
- /** Map PPTX IEffectsOptions to core Scene3DOptions, or null if not needed. */
84
+ /** Map PPTX EffectsOptions to core Scene3DOptions, or null if not needed. */
85
85
  function buildScene3D(options) {
86
86
  if (!options.rotation3D && !options.lighting) return null;
87
87
  return createScene3D$1({
@@ -100,7 +100,7 @@ function buildScene3D(options) {
100
100
  }
101
101
  });
102
102
  }
103
- /** Map PPTX IEffectsOptions to core Shape3DOptions, or null if not needed. */
103
+ /** Map PPTX EffectsOptions to core Shape3DOptions, or null if not needed. */
104
104
  function buildShape3D(options) {
105
105
  if (!options.extrusionH && !options.bevelTop && !options.bevelBottom && !options.material) return null;
106
106
  return createShape3D$1({
@@ -110,7 +110,7 @@ function buildShape3D(options) {
110
110
  ...options.material ? { prstMaterial: options.material } : {}
111
111
  });
112
112
  }
113
- /** Create a:effectLst from PPTX simplified IEffectsOptions. */
113
+ /** Create a:effectLst from PPTX simplified EffectsOptions. */
114
114
  function createPptxEffectList(options) {
115
115
  const effectListOpts = toEffectListOptions(options);
116
116
  return effectListOpts ? createEffectList$1(effectListOpts) : null;
@@ -662,7 +662,6 @@ function buildParagraphProperties(options) {
662
662
  if (options.marginBottom !== void 0 || options.marginTop !== void 0) children.push({ "a:spcAft": [{ "a:spcPts": { _attr: { val: options.marginBottom ?? 0 } } }] });
663
663
  if (options.marginTop !== void 0) children.push({ "a:spcBef": [{ "a:spcPts": { _attr: { val: options.marginTop } } }] });
664
664
  if (options.bullet) children.push(...buildBulletChildren(options.bullet));
665
- else if (options.bulletNone !== false) children.push({ "a:buNone": {} });
666
665
  if (children.length === 0) return void 0;
667
666
  return { "a:pPr": children.length === 1 && "_attr" in children[0] ? children[0] : children };
668
667
  }
@@ -888,7 +887,7 @@ var TableCell = class extends BaseXmlComponent {
888
887
  super("a:tc");
889
888
  this.options = options;
890
889
  this.paragraphs = options.children?.map((c) => typeof c === "string" ? new Paragraph(c) : c instanceof BaseXmlComponent ? c : new Paragraph(c)) ?? (options.text !== void 0 ? [new Paragraph({
891
- properties: { bulletNone: false },
890
+ properties: {},
892
891
  children: [new TextRun({ text: options.text })]
893
892
  })] : void 0);
894
893
  }
@@ -1739,7 +1738,7 @@ init_xml_components();
1739
1738
  * a:cNvPicPr — Non-visual picture drawing properties.
1740
1739
  * Uses a: prefix (DrawingML type) but referenced via p:cNvPicPr in PML context.
1741
1740
  */
1742
- var NonVisualPictureProperties = class extends XmlComponent {
1741
+ var NonVisualPictureProperties = class extends EmptyElement {
1743
1742
  constructor() {
1744
1743
  super("a:cNvPicPr");
1745
1744
  }
@@ -1883,7 +1882,7 @@ init_xml_components();
1883
1882
  * p:cNvSpPr — Non-visual shape properties.
1884
1883
  * Uses p: prefix in PresentationML context.
1885
1884
  */
1886
- var NonVisualShapeProperties = class extends XmlComponent {
1885
+ var NonVisualShapeProperties = class extends EmptyElement {
1887
1886
  constructor() {
1888
1887
  super("p:cNvSpPr");
1889
1888
  }
@@ -3203,7 +3202,7 @@ function buildEntrOrExitEffects(options, spid, ids) {
3203
3202
  }),
3204
3203
  new BuilderElement({
3205
3204
  name: "p:attrNameLst",
3206
- children: [new StringContainer("p:attrName", "style.visibility")]
3205
+ children: [stringContainerObj("p:attrName", "style.visibility")]
3207
3206
  })
3208
3207
  ]
3209
3208
  }), new BuilderElement({
@@ -3466,7 +3465,7 @@ function buildEmphasisEffects(options, spid, ids) {
3466
3465
  tgtEl,
3467
3466
  new BuilderElement({
3468
3467
  name: "p:attrNameLst",
3469
- children: [new StringContainer("p:attrName", "style.opacity")]
3468
+ children: [stringContainerObj("p:attrName", "style.opacity")]
3470
3469
  })
3471
3470
  ]
3472
3471
  })]
@@ -3702,7 +3701,7 @@ function buildPropertyAnimation(options, spid, ids) {
3702
3701
  }), buildTargetElement(spid, options)];
3703
3702
  if (options.attributeName) cBhvrChildren.push(new BuilderElement({
3704
3703
  name: "p:attrNameLst",
3705
- children: [new StringContainer("p:attrName", options.attributeName)]
3704
+ children: [stringContainerObj("p:attrName", options.attributeName)]
3706
3705
  }));
3707
3706
  const animChildren = [new BuilderElement({
3708
3707
  name: "p:cBhvr",
@@ -4656,9 +4655,10 @@ init_xml_components();
4656
4655
  /**
4657
4656
  * a:t — Text content within a run.
4658
4657
  */
4659
- var Text = class extends StringContainer {
4658
+ var Text = class extends XmlComponent {
4660
4659
  constructor(value) {
4661
- super("a:t", value);
4660
+ super("a:t");
4661
+ this.root.push(value);
4662
4662
  }
4663
4663
  };
4664
4664
  //#endregion
@@ -4695,7 +4695,7 @@ var Field = class extends XmlComponent {
4695
4695
  }
4696
4696
  }
4697
4697
  }));
4698
- this.root.push(new StringContainer("a:t", displayText));
4698
+ this.root.push(stringContainerObj("a:t", displayText));
4699
4699
  }
4700
4700
  };
4701
4701
  /**
@@ -4829,7 +4829,7 @@ var HeaderFooter = class extends XmlComponent {
4829
4829
  name: "a:p",
4830
4830
  children: [new BuilderElement({
4831
4831
  name: "a:r",
4832
- children: [new StringContainer("a:t", options.footer)]
4832
+ children: [stringContainerObj("a:t", options.footer)]
4833
4833
  }), new BuilderElement({
4834
4834
  name: "a:endParaRPr",
4835
4835
  attributes: { lang: {
@@ -4849,3143 +4849,6 @@ init_fill();
4849
4849
  init_effects();
4850
4850
  init_background();
4851
4851
  //#endregion
4852
- //#region \0polyfill-node.global.js
4853
- var _polyfill_node_global_default = typeof _polyfill_node_global_default !== "undefined" ? _polyfill_node_global_default : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
4854
- //#endregion
4855
- //#region \0polyfill-node.buffer.js
4856
- var lookup = [];
4857
- var revLookup = [];
4858
- var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
4859
- var inited = false;
4860
- function init() {
4861
- inited = true;
4862
- var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4863
- for (var i = 0, len = code.length; i < len; ++i) {
4864
- lookup[i] = code[i];
4865
- revLookup[code.charCodeAt(i)] = i;
4866
- }
4867
- revLookup["-".charCodeAt(0)] = 62;
4868
- revLookup["_".charCodeAt(0)] = 63;
4869
- }
4870
- function toByteArray(b64) {
4871
- if (!inited) init();
4872
- var i, j, l, tmp, placeHolders, arr;
4873
- var len = b64.length;
4874
- if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
4875
- placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
4876
- arr = new Arr(len * 3 / 4 - placeHolders);
4877
- l = placeHolders > 0 ? len - 4 : len;
4878
- var L = 0;
4879
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
4880
- tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
4881
- arr[L++] = tmp >> 16 & 255;
4882
- arr[L++] = tmp >> 8 & 255;
4883
- arr[L++] = tmp & 255;
4884
- }
4885
- if (placeHolders === 2) {
4886
- tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
4887
- arr[L++] = tmp & 255;
4888
- } else if (placeHolders === 1) {
4889
- tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
4890
- arr[L++] = tmp >> 8 & 255;
4891
- arr[L++] = tmp & 255;
4892
- }
4893
- return arr;
4894
- }
4895
- function tripletToBase64(num) {
4896
- return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
4897
- }
4898
- function encodeChunk(uint8, start, end) {
4899
- var tmp;
4900
- var output = [];
4901
- for (var i = start; i < end; i += 3) {
4902
- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
4903
- output.push(tripletToBase64(tmp));
4904
- }
4905
- return output.join("");
4906
- }
4907
- function fromByteArray(uint8) {
4908
- if (!inited) init();
4909
- var tmp;
4910
- var len = uint8.length;
4911
- var extraBytes = len % 3;
4912
- var output = "";
4913
- var parts = [];
4914
- var maxChunkLength = 16383;
4915
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
4916
- if (extraBytes === 1) {
4917
- tmp = uint8[len - 1];
4918
- output += lookup[tmp >> 2];
4919
- output += lookup[tmp << 4 & 63];
4920
- output += "==";
4921
- } else if (extraBytes === 2) {
4922
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
4923
- output += lookup[tmp >> 10];
4924
- output += lookup[tmp >> 4 & 63];
4925
- output += lookup[tmp << 2 & 63];
4926
- output += "=";
4927
- }
4928
- parts.push(output);
4929
- return parts.join("");
4930
- }
4931
- function read(buffer, offset, isLE, mLen, nBytes) {
4932
- var e, m;
4933
- var eLen = nBytes * 8 - mLen - 1;
4934
- var eMax = (1 << eLen) - 1;
4935
- var eBias = eMax >> 1;
4936
- var nBits = -7;
4937
- var i = isLE ? nBytes - 1 : 0;
4938
- var d = isLE ? -1 : 1;
4939
- var s = buffer[offset + i];
4940
- i += d;
4941
- e = s & (1 << -nBits) - 1;
4942
- s >>= -nBits;
4943
- nBits += eLen;
4944
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
4945
- m = e & (1 << -nBits) - 1;
4946
- e >>= -nBits;
4947
- nBits += mLen;
4948
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
4949
- if (e === 0) e = 1 - eBias;
4950
- else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity;
4951
- else {
4952
- m = m + Math.pow(2, mLen);
4953
- e = e - eBias;
4954
- }
4955
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
4956
- }
4957
- function write(buffer, value, offset, isLE, mLen, nBytes) {
4958
- var e, m, c;
4959
- var eLen = nBytes * 8 - mLen - 1;
4960
- var eMax = (1 << eLen) - 1;
4961
- var eBias = eMax >> 1;
4962
- var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
4963
- var i = isLE ? 0 : nBytes - 1;
4964
- var d = isLE ? 1 : -1;
4965
- var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
4966
- value = Math.abs(value);
4967
- if (isNaN(value) || value === Infinity) {
4968
- m = isNaN(value) ? 1 : 0;
4969
- e = eMax;
4970
- } else {
4971
- e = Math.floor(Math.log(value) / Math.LN2);
4972
- if (value * (c = Math.pow(2, -e)) < 1) {
4973
- e--;
4974
- c *= 2;
4975
- }
4976
- if (e + eBias >= 1) value += rt / c;
4977
- else value += rt * Math.pow(2, 1 - eBias);
4978
- if (value * c >= 2) {
4979
- e++;
4980
- c /= 2;
4981
- }
4982
- if (e + eBias >= eMax) {
4983
- m = 0;
4984
- e = eMax;
4985
- } else if (e + eBias >= 1) {
4986
- m = (value * c - 1) * Math.pow(2, mLen);
4987
- e = e + eBias;
4988
- } else {
4989
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
4990
- e = 0;
4991
- }
4992
- }
4993
- for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8);
4994
- e = e << mLen | m;
4995
- eLen += mLen;
4996
- for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8);
4997
- buffer[offset + i - d] |= s * 128;
4998
- }
4999
- var toString = {}.toString;
5000
- var isArray$1 = Array.isArray || function(arr) {
5001
- return toString.call(arr) == "[object Array]";
5002
- };
5003
- /**
5004
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
5005
- * === true Use Uint8Array implementation (fastest)
5006
- * === false Use Object implementation (most compatible, even IE6)
5007
- *
5008
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
5009
- * Opera 11.6+, iOS 4.2+.
5010
- *
5011
- * Due to various browser bugs, sometimes the Object implementation will be used even
5012
- * when the browser supports typed arrays.
5013
- *
5014
- * Note:
5015
- *
5016
- * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
5017
- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
5018
- *
5019
- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
5020
- *
5021
- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
5022
- * incorrect length in some situations.
5023
-
5024
- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
5025
- * get the Object implementation, which is slower but behaves correctly.
5026
- */
5027
- Buffer.TYPED_ARRAY_SUPPORT = _polyfill_node_global_default.TYPED_ARRAY_SUPPORT !== void 0 ? _polyfill_node_global_default.TYPED_ARRAY_SUPPORT : true;
5028
- kMaxLength();
5029
- function kMaxLength() {
5030
- return Buffer.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
5031
- }
5032
- function createBuffer(that, length) {
5033
- if (kMaxLength() < length) throw new RangeError("Invalid typed array length");
5034
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5035
- that = new Uint8Array(length);
5036
- that.__proto__ = Buffer.prototype;
5037
- } else {
5038
- if (that === null) that = new Buffer(length);
5039
- that.length = length;
5040
- }
5041
- return that;
5042
- }
5043
- /**
5044
- * The Buffer constructor returns instances of `Uint8Array` that have their
5045
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
5046
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
5047
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
5048
- * returns a single octet.
5049
- *
5050
- * The `Uint8Array` prototype remains unmodified.
5051
- */
5052
- function Buffer(arg, encodingOrOffset, length) {
5053
- if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) return new Buffer(arg, encodingOrOffset, length);
5054
- if (typeof arg === "number") {
5055
- if (typeof encodingOrOffset === "string") throw new Error("If encoding is specified then the first argument must be a string");
5056
- return allocUnsafe(this, arg);
5057
- }
5058
- return from(this, arg, encodingOrOffset, length);
5059
- }
5060
- Buffer.poolSize = 8192;
5061
- Buffer._augment = function(arr) {
5062
- arr.__proto__ = Buffer.prototype;
5063
- return arr;
5064
- };
5065
- function from(that, value, encodingOrOffset, length) {
5066
- if (typeof value === "number") throw new TypeError("\"value\" argument must not be a number");
5067
- if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) return fromArrayBuffer(that, value, encodingOrOffset, length);
5068
- if (typeof value === "string") return fromString(that, value, encodingOrOffset);
5069
- return fromObject(that, value);
5070
- }
5071
- /**
5072
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
5073
- * if value is a number.
5074
- * Buffer.from(str[, encoding])
5075
- * Buffer.from(array)
5076
- * Buffer.from(buffer)
5077
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
5078
- **/
5079
- Buffer.from = function(value, encodingOrOffset, length) {
5080
- return from(null, value, encodingOrOffset, length);
5081
- };
5082
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5083
- Buffer.prototype.__proto__ = Uint8Array.prototype;
5084
- Buffer.__proto__ = Uint8Array;
5085
- if (typeof Symbol !== "undefined" && Symbol.species && Buffer[Symbol.species] === Buffer);
5086
- }
5087
- function assertSize(size) {
5088
- if (typeof size !== "number") throw new TypeError("\"size\" argument must be a number");
5089
- else if (size < 0) throw new RangeError("\"size\" argument must not be negative");
5090
- }
5091
- function alloc(that, size, fill, encoding) {
5092
- assertSize(size);
5093
- if (size <= 0) return createBuffer(that, size);
5094
- if (fill !== void 0) return typeof encoding === "string" ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
5095
- return createBuffer(that, size);
5096
- }
5097
- /**
5098
- * Creates a new filled Buffer instance.
5099
- * alloc(size[, fill[, encoding]])
5100
- **/
5101
- Buffer.alloc = function(size, fill, encoding) {
5102
- return alloc(null, size, fill, encoding);
5103
- };
5104
- function allocUnsafe(that, size) {
5105
- assertSize(size);
5106
- that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
5107
- if (!Buffer.TYPED_ARRAY_SUPPORT) for (var i = 0; i < size; ++i) that[i] = 0;
5108
- return that;
5109
- }
5110
- /**
5111
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
5112
- * */
5113
- Buffer.allocUnsafe = function(size) {
5114
- return allocUnsafe(null, size);
5115
- };
5116
- /**
5117
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
5118
- */
5119
- Buffer.allocUnsafeSlow = function(size) {
5120
- return allocUnsafe(null, size);
5121
- };
5122
- function fromString(that, string, encoding) {
5123
- if (typeof encoding !== "string" || encoding === "") encoding = "utf8";
5124
- if (!Buffer.isEncoding(encoding)) throw new TypeError("\"encoding\" must be a valid string encoding");
5125
- var length = byteLength(string, encoding) | 0;
5126
- that = createBuffer(that, length);
5127
- var actual = that.write(string, encoding);
5128
- if (actual !== length) that = that.slice(0, actual);
5129
- return that;
5130
- }
5131
- function fromArrayLike(that, array) {
5132
- var length = array.length < 0 ? 0 : checked(array.length) | 0;
5133
- that = createBuffer(that, length);
5134
- for (var i = 0; i < length; i += 1) that[i] = array[i] & 255;
5135
- return that;
5136
- }
5137
- function fromArrayBuffer(that, array, byteOffset, length) {
5138
- array.byteLength;
5139
- if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError("'offset' is out of bounds");
5140
- if (array.byteLength < byteOffset + (length || 0)) throw new RangeError("'length' is out of bounds");
5141
- if (byteOffset === void 0 && length === void 0) array = new Uint8Array(array);
5142
- else if (length === void 0) array = new Uint8Array(array, byteOffset);
5143
- else array = new Uint8Array(array, byteOffset, length);
5144
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5145
- that = array;
5146
- that.__proto__ = Buffer.prototype;
5147
- } else that = fromArrayLike(that, array);
5148
- return that;
5149
- }
5150
- function fromObject(that, obj) {
5151
- if (internalIsBuffer(obj)) {
5152
- var len = checked(obj.length) | 0;
5153
- that = createBuffer(that, len);
5154
- if (that.length === 0) return that;
5155
- obj.copy(that, 0, 0, len);
5156
- return that;
5157
- }
5158
- if (obj) {
5159
- if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
5160
- if (typeof obj.length !== "number" || isnan(obj.length)) return createBuffer(that, 0);
5161
- return fromArrayLike(that, obj);
5162
- }
5163
- if (obj.type === "Buffer" && isArray$1(obj.data)) return fromArrayLike(that, obj.data);
5164
- }
5165
- throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
5166
- }
5167
- function checked(length) {
5168
- if (length >= kMaxLength()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
5169
- return length | 0;
5170
- }
5171
- Buffer.isBuffer = isBuffer;
5172
- function internalIsBuffer(b) {
5173
- return !!(b != null && b._isBuffer);
5174
- }
5175
- Buffer.compare = function compare(a, b) {
5176
- if (!internalIsBuffer(a) || !internalIsBuffer(b)) throw new TypeError("Arguments must be Buffers");
5177
- if (a === b) return 0;
5178
- var x = a.length;
5179
- var y = b.length;
5180
- for (var i = 0, len = Math.min(x, y); i < len; ++i) if (a[i] !== b[i]) {
5181
- x = a[i];
5182
- y = b[i];
5183
- break;
5184
- }
5185
- if (x < y) return -1;
5186
- if (y < x) return 1;
5187
- return 0;
5188
- };
5189
- Buffer.isEncoding = function isEncoding(encoding) {
5190
- switch (String(encoding).toLowerCase()) {
5191
- case "hex":
5192
- case "utf8":
5193
- case "utf-8":
5194
- case "ascii":
5195
- case "latin1":
5196
- case "binary":
5197
- case "base64":
5198
- case "ucs2":
5199
- case "ucs-2":
5200
- case "utf16le":
5201
- case "utf-16le": return true;
5202
- default: return false;
5203
- }
5204
- };
5205
- Buffer.concat = function concat(list, length) {
5206
- if (!isArray$1(list)) throw new TypeError("\"list\" argument must be an Array of Buffers");
5207
- if (list.length === 0) return Buffer.alloc(0);
5208
- var i;
5209
- if (length === void 0) {
5210
- length = 0;
5211
- for (i = 0; i < list.length; ++i) length += list[i].length;
5212
- }
5213
- var buffer = Buffer.allocUnsafe(length);
5214
- var pos = 0;
5215
- for (i = 0; i < list.length; ++i) {
5216
- var buf = list[i];
5217
- if (!internalIsBuffer(buf)) throw new TypeError("\"list\" argument must be an Array of Buffers");
5218
- buf.copy(buffer, pos);
5219
- pos += buf.length;
5220
- }
5221
- return buffer;
5222
- };
5223
- function byteLength(string, encoding) {
5224
- if (internalIsBuffer(string)) return string.length;
5225
- if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) return string.byteLength;
5226
- if (typeof string !== "string") string = "" + string;
5227
- var len = string.length;
5228
- if (len === 0) return 0;
5229
- var loweredCase = false;
5230
- for (;;) switch (encoding) {
5231
- case "ascii":
5232
- case "latin1":
5233
- case "binary": return len;
5234
- case "utf8":
5235
- case "utf-8":
5236
- case void 0: return utf8ToBytes(string).length;
5237
- case "ucs2":
5238
- case "ucs-2":
5239
- case "utf16le":
5240
- case "utf-16le": return len * 2;
5241
- case "hex": return len >>> 1;
5242
- case "base64": return base64ToBytes(string).length;
5243
- default:
5244
- if (loweredCase) return utf8ToBytes(string).length;
5245
- encoding = ("" + encoding).toLowerCase();
5246
- loweredCase = true;
5247
- }
5248
- }
5249
- Buffer.byteLength = byteLength;
5250
- function slowToString(encoding, start, end) {
5251
- var loweredCase = false;
5252
- if (start === void 0 || start < 0) start = 0;
5253
- if (start > this.length) return "";
5254
- if (end === void 0 || end > this.length) end = this.length;
5255
- if (end <= 0) return "";
5256
- end >>>= 0;
5257
- start >>>= 0;
5258
- if (end <= start) return "";
5259
- if (!encoding) encoding = "utf8";
5260
- while (true) switch (encoding) {
5261
- case "hex": return hexSlice(this, start, end);
5262
- case "utf8":
5263
- case "utf-8": return utf8Slice(this, start, end);
5264
- case "ascii": return asciiSlice(this, start, end);
5265
- case "latin1":
5266
- case "binary": return latin1Slice(this, start, end);
5267
- case "base64": return base64Slice(this, start, end);
5268
- case "ucs2":
5269
- case "ucs-2":
5270
- case "utf16le":
5271
- case "utf-16le": return utf16leSlice(this, start, end);
5272
- default:
5273
- if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
5274
- encoding = (encoding + "").toLowerCase();
5275
- loweredCase = true;
5276
- }
5277
- }
5278
- Buffer.prototype._isBuffer = true;
5279
- function swap(b, n, m) {
5280
- var i = b[n];
5281
- b[n] = b[m];
5282
- b[m] = i;
5283
- }
5284
- Buffer.prototype.swap16 = function swap16() {
5285
- var len = this.length;
5286
- if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
5287
- for (var i = 0; i < len; i += 2) swap(this, i, i + 1);
5288
- return this;
5289
- };
5290
- Buffer.prototype.swap32 = function swap32() {
5291
- var len = this.length;
5292
- if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
5293
- for (var i = 0; i < len; i += 4) {
5294
- swap(this, i, i + 3);
5295
- swap(this, i + 1, i + 2);
5296
- }
5297
- return this;
5298
- };
5299
- Buffer.prototype.swap64 = function swap64() {
5300
- var len = this.length;
5301
- if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
5302
- for (var i = 0; i < len; i += 8) {
5303
- swap(this, i, i + 7);
5304
- swap(this, i + 1, i + 6);
5305
- swap(this, i + 2, i + 5);
5306
- swap(this, i + 3, i + 4);
5307
- }
5308
- return this;
5309
- };
5310
- Buffer.prototype.toString = function toString() {
5311
- var length = this.length | 0;
5312
- if (length === 0) return "";
5313
- if (arguments.length === 0) return utf8Slice(this, 0, length);
5314
- return slowToString.apply(this, arguments);
5315
- };
5316
- Buffer.prototype.equals = function equals(b) {
5317
- if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
5318
- if (this === b) return true;
5319
- return Buffer.compare(this, b) === 0;
5320
- };
5321
- Buffer.prototype.inspect = function inspect() {
5322
- var str = "";
5323
- var max = 50;
5324
- if (this.length > 0) {
5325
- str = this.toString("hex", 0, max).match(/.{2}/g).join(" ");
5326
- if (this.length > max) str += " ... ";
5327
- }
5328
- return "<Buffer " + str + ">";
5329
- };
5330
- Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
5331
- if (!internalIsBuffer(target)) throw new TypeError("Argument must be a Buffer");
5332
- if (start === void 0) start = 0;
5333
- if (end === void 0) end = target ? target.length : 0;
5334
- if (thisStart === void 0) thisStart = 0;
5335
- if (thisEnd === void 0) thisEnd = this.length;
5336
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError("out of range index");
5337
- if (thisStart >= thisEnd && start >= end) return 0;
5338
- if (thisStart >= thisEnd) return -1;
5339
- if (start >= end) return 1;
5340
- start >>>= 0;
5341
- end >>>= 0;
5342
- thisStart >>>= 0;
5343
- thisEnd >>>= 0;
5344
- if (this === target) return 0;
5345
- var x = thisEnd - thisStart;
5346
- var y = end - start;
5347
- var len = Math.min(x, y);
5348
- var thisCopy = this.slice(thisStart, thisEnd);
5349
- var targetCopy = target.slice(start, end);
5350
- for (var i = 0; i < len; ++i) if (thisCopy[i] !== targetCopy[i]) {
5351
- x = thisCopy[i];
5352
- y = targetCopy[i];
5353
- break;
5354
- }
5355
- if (x < y) return -1;
5356
- if (y < x) return 1;
5357
- return 0;
5358
- };
5359
- function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
5360
- if (buffer.length === 0) return -1;
5361
- if (typeof byteOffset === "string") {
5362
- encoding = byteOffset;
5363
- byteOffset = 0;
5364
- } else if (byteOffset > 2147483647) byteOffset = 2147483647;
5365
- else if (byteOffset < -2147483648) byteOffset = -2147483648;
5366
- byteOffset = +byteOffset;
5367
- if (isNaN(byteOffset)) byteOffset = dir ? 0 : buffer.length - 1;
5368
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
5369
- if (byteOffset >= buffer.length) if (dir) return -1;
5370
- else byteOffset = buffer.length - 1;
5371
- else if (byteOffset < 0) if (dir) byteOffset = 0;
5372
- else return -1;
5373
- if (typeof val === "string") val = Buffer.from(val, encoding);
5374
- if (internalIsBuffer(val)) {
5375
- if (val.length === 0) return -1;
5376
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
5377
- } else if (typeof val === "number") {
5378
- val = val & 255;
5379
- if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
5380
- else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
5381
- return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
5382
- }
5383
- throw new TypeError("val must be string, number or Buffer");
5384
- }
5385
- function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
5386
- var indexSize = 1;
5387
- var arrLength = arr.length;
5388
- var valLength = val.length;
5389
- if (encoding !== void 0) {
5390
- encoding = String(encoding).toLowerCase();
5391
- if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
5392
- if (arr.length < 2 || val.length < 2) return -1;
5393
- indexSize = 2;
5394
- arrLength /= 2;
5395
- valLength /= 2;
5396
- byteOffset /= 2;
5397
- }
5398
- }
5399
- function read(buf, i) {
5400
- if (indexSize === 1) return buf[i];
5401
- else return buf.readUInt16BE(i * indexSize);
5402
- }
5403
- var i;
5404
- if (dir) {
5405
- var foundIndex = -1;
5406
- for (i = byteOffset; i < arrLength; i++) if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
5407
- if (foundIndex === -1) foundIndex = i;
5408
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
5409
- } else {
5410
- if (foundIndex !== -1) i -= i - foundIndex;
5411
- foundIndex = -1;
5412
- }
5413
- } else {
5414
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
5415
- for (i = byteOffset; i >= 0; i--) {
5416
- var found = true;
5417
- for (var j = 0; j < valLength; j++) if (read(arr, i + j) !== read(val, j)) {
5418
- found = false;
5419
- break;
5420
- }
5421
- if (found) return i;
5422
- }
5423
- }
5424
- return -1;
5425
- }
5426
- Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
5427
- return this.indexOf(val, byteOffset, encoding) !== -1;
5428
- };
5429
- Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
5430
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
5431
- };
5432
- Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
5433
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
5434
- };
5435
- function hexWrite(buf, string, offset, length) {
5436
- offset = Number(offset) || 0;
5437
- var remaining = buf.length - offset;
5438
- if (!length) length = remaining;
5439
- else {
5440
- length = Number(length);
5441
- if (length > remaining) length = remaining;
5442
- }
5443
- var strLen = string.length;
5444
- if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
5445
- if (length > strLen / 2) length = strLen / 2;
5446
- for (var i = 0; i < length; ++i) {
5447
- var parsed = parseInt(string.substr(i * 2, 2), 16);
5448
- if (isNaN(parsed)) return i;
5449
- buf[offset + i] = parsed;
5450
- }
5451
- return i;
5452
- }
5453
- function utf8Write(buf, string, offset, length) {
5454
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
5455
- }
5456
- function asciiWrite(buf, string, offset, length) {
5457
- return blitBuffer(asciiToBytes(string), buf, offset, length);
5458
- }
5459
- function latin1Write(buf, string, offset, length) {
5460
- return asciiWrite(buf, string, offset, length);
5461
- }
5462
- function base64Write(buf, string, offset, length) {
5463
- return blitBuffer(base64ToBytes(string), buf, offset, length);
5464
- }
5465
- function ucs2Write(buf, string, offset, length) {
5466
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
5467
- }
5468
- Buffer.prototype.write = function write(string, offset, length, encoding) {
5469
- if (offset === void 0) {
5470
- encoding = "utf8";
5471
- length = this.length;
5472
- offset = 0;
5473
- } else if (length === void 0 && typeof offset === "string") {
5474
- encoding = offset;
5475
- length = this.length;
5476
- offset = 0;
5477
- } else if (isFinite(offset)) {
5478
- offset = offset | 0;
5479
- if (isFinite(length)) {
5480
- length = length | 0;
5481
- if (encoding === void 0) encoding = "utf8";
5482
- } else {
5483
- encoding = length;
5484
- length = void 0;
5485
- }
5486
- } else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
5487
- var remaining = this.length - offset;
5488
- if (length === void 0 || length > remaining) length = remaining;
5489
- if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw new RangeError("Attempt to write outside buffer bounds");
5490
- if (!encoding) encoding = "utf8";
5491
- var loweredCase = false;
5492
- for (;;) switch (encoding) {
5493
- case "hex": return hexWrite(this, string, offset, length);
5494
- case "utf8":
5495
- case "utf-8": return utf8Write(this, string, offset, length);
5496
- case "ascii": return asciiWrite(this, string, offset, length);
5497
- case "latin1":
5498
- case "binary": return latin1Write(this, string, offset, length);
5499
- case "base64": return base64Write(this, string, offset, length);
5500
- case "ucs2":
5501
- case "ucs-2":
5502
- case "utf16le":
5503
- case "utf-16le": return ucs2Write(this, string, offset, length);
5504
- default:
5505
- if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
5506
- encoding = ("" + encoding).toLowerCase();
5507
- loweredCase = true;
5508
- }
5509
- };
5510
- Buffer.prototype.toJSON = function toJSON() {
5511
- return {
5512
- type: "Buffer",
5513
- data: Array.prototype.slice.call(this._arr || this, 0)
5514
- };
5515
- };
5516
- function base64Slice(buf, start, end) {
5517
- if (start === 0 && end === buf.length) return fromByteArray(buf);
5518
- else return fromByteArray(buf.slice(start, end));
5519
- }
5520
- function utf8Slice(buf, start, end) {
5521
- end = Math.min(buf.length, end);
5522
- var res = [];
5523
- var i = start;
5524
- while (i < end) {
5525
- var firstByte = buf[i];
5526
- var codePoint = null;
5527
- var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
5528
- if (i + bytesPerSequence <= end) {
5529
- var secondByte, thirdByte, fourthByte, tempCodePoint;
5530
- switch (bytesPerSequence) {
5531
- case 1:
5532
- if (firstByte < 128) codePoint = firstByte;
5533
- break;
5534
- case 2:
5535
- secondByte = buf[i + 1];
5536
- if ((secondByte & 192) === 128) {
5537
- tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
5538
- if (tempCodePoint > 127) codePoint = tempCodePoint;
5539
- }
5540
- break;
5541
- case 3:
5542
- secondByte = buf[i + 1];
5543
- thirdByte = buf[i + 2];
5544
- if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
5545
- tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
5546
- if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) codePoint = tempCodePoint;
5547
- }
5548
- break;
5549
- case 4:
5550
- secondByte = buf[i + 1];
5551
- thirdByte = buf[i + 2];
5552
- fourthByte = buf[i + 3];
5553
- if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
5554
- tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
5555
- if (tempCodePoint > 65535 && tempCodePoint < 1114112) codePoint = tempCodePoint;
5556
- }
5557
- }
5558
- }
5559
- if (codePoint === null) {
5560
- codePoint = 65533;
5561
- bytesPerSequence = 1;
5562
- } else if (codePoint > 65535) {
5563
- codePoint -= 65536;
5564
- res.push(codePoint >>> 10 & 1023 | 55296);
5565
- codePoint = 56320 | codePoint & 1023;
5566
- }
5567
- res.push(codePoint);
5568
- i += bytesPerSequence;
5569
- }
5570
- return decodeCodePointsArray(res);
5571
- }
5572
- var MAX_ARGUMENTS_LENGTH = 4096;
5573
- function decodeCodePointsArray(codePoints) {
5574
- var len = codePoints.length;
5575
- if (len <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints);
5576
- var res = "";
5577
- var i = 0;
5578
- while (i < len) res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
5579
- return res;
5580
- }
5581
- function asciiSlice(buf, start, end) {
5582
- var ret = "";
5583
- end = Math.min(buf.length, end);
5584
- for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i] & 127);
5585
- return ret;
5586
- }
5587
- function latin1Slice(buf, start, end) {
5588
- var ret = "";
5589
- end = Math.min(buf.length, end);
5590
- for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i]);
5591
- return ret;
5592
- }
5593
- function hexSlice(buf, start, end) {
5594
- var len = buf.length;
5595
- if (!start || start < 0) start = 0;
5596
- if (!end || end < 0 || end > len) end = len;
5597
- var out = "";
5598
- for (var i = start; i < end; ++i) out += toHex(buf[i]);
5599
- return out;
5600
- }
5601
- function utf16leSlice(buf, start, end) {
5602
- var bytes = buf.slice(start, end);
5603
- var res = "";
5604
- for (var i = 0; i < bytes.length; i += 2) res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
5605
- return res;
5606
- }
5607
- Buffer.prototype.slice = function slice(start, end) {
5608
- var len = this.length;
5609
- start = ~~start;
5610
- end = end === void 0 ? len : ~~end;
5611
- if (start < 0) {
5612
- start += len;
5613
- if (start < 0) start = 0;
5614
- } else if (start > len) start = len;
5615
- if (end < 0) {
5616
- end += len;
5617
- if (end < 0) end = 0;
5618
- } else if (end > len) end = len;
5619
- if (end < start) end = start;
5620
- var newBuf;
5621
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5622
- newBuf = this.subarray(start, end);
5623
- newBuf.__proto__ = Buffer.prototype;
5624
- } else {
5625
- var sliceLen = end - start;
5626
- newBuf = new Buffer(sliceLen, void 0);
5627
- for (var i = 0; i < sliceLen; ++i) newBuf[i] = this[i + start];
5628
- }
5629
- return newBuf;
5630
- };
5631
- function checkOffset(offset, ext, length) {
5632
- if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
5633
- if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
5634
- }
5635
- Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
5636
- offset = offset | 0;
5637
- byteLength = byteLength | 0;
5638
- if (!noAssert) checkOffset(offset, byteLength, this.length);
5639
- var val = this[offset];
5640
- var mul = 1;
5641
- var i = 0;
5642
- while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
5643
- return val;
5644
- };
5645
- Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
5646
- offset = offset | 0;
5647
- byteLength = byteLength | 0;
5648
- if (!noAssert) checkOffset(offset, byteLength, this.length);
5649
- var val = this[offset + --byteLength];
5650
- var mul = 1;
5651
- while (byteLength > 0 && (mul *= 256)) val += this[offset + --byteLength] * mul;
5652
- return val;
5653
- };
5654
- Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
5655
- if (!noAssert) checkOffset(offset, 1, this.length);
5656
- return this[offset];
5657
- };
5658
- Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
5659
- if (!noAssert) checkOffset(offset, 2, this.length);
5660
- return this[offset] | this[offset + 1] << 8;
5661
- };
5662
- Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
5663
- if (!noAssert) checkOffset(offset, 2, this.length);
5664
- return this[offset] << 8 | this[offset + 1];
5665
- };
5666
- Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
5667
- if (!noAssert) checkOffset(offset, 4, this.length);
5668
- return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
5669
- };
5670
- Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
5671
- if (!noAssert) checkOffset(offset, 4, this.length);
5672
- return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
5673
- };
5674
- Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
5675
- offset = offset | 0;
5676
- byteLength = byteLength | 0;
5677
- if (!noAssert) checkOffset(offset, byteLength, this.length);
5678
- var val = this[offset];
5679
- var mul = 1;
5680
- var i = 0;
5681
- while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
5682
- mul *= 128;
5683
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
5684
- return val;
5685
- };
5686
- Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
5687
- offset = offset | 0;
5688
- byteLength = byteLength | 0;
5689
- if (!noAssert) checkOffset(offset, byteLength, this.length);
5690
- var i = byteLength;
5691
- var mul = 1;
5692
- var val = this[offset + --i];
5693
- while (i > 0 && (mul *= 256)) val += this[offset + --i] * mul;
5694
- mul *= 128;
5695
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
5696
- return val;
5697
- };
5698
- Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
5699
- if (!noAssert) checkOffset(offset, 1, this.length);
5700
- if (!(this[offset] & 128)) return this[offset];
5701
- return (255 - this[offset] + 1) * -1;
5702
- };
5703
- Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
5704
- if (!noAssert) checkOffset(offset, 2, this.length);
5705
- var val = this[offset] | this[offset + 1] << 8;
5706
- return val & 32768 ? val | 4294901760 : val;
5707
- };
5708
- Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
5709
- if (!noAssert) checkOffset(offset, 2, this.length);
5710
- var val = this[offset + 1] | this[offset] << 8;
5711
- return val & 32768 ? val | 4294901760 : val;
5712
- };
5713
- Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
5714
- if (!noAssert) checkOffset(offset, 4, this.length);
5715
- return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
5716
- };
5717
- Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
5718
- if (!noAssert) checkOffset(offset, 4, this.length);
5719
- return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
5720
- };
5721
- Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
5722
- if (!noAssert) checkOffset(offset, 4, this.length);
5723
- return read(this, offset, true, 23, 4);
5724
- };
5725
- Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
5726
- if (!noAssert) checkOffset(offset, 4, this.length);
5727
- return read(this, offset, false, 23, 4);
5728
- };
5729
- Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
5730
- if (!noAssert) checkOffset(offset, 8, this.length);
5731
- return read(this, offset, true, 52, 8);
5732
- };
5733
- Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
5734
- if (!noAssert) checkOffset(offset, 8, this.length);
5735
- return read(this, offset, false, 52, 8);
5736
- };
5737
- function checkInt(buf, value, offset, ext, max, min) {
5738
- if (!internalIsBuffer(buf)) throw new TypeError("\"buffer\" argument must be a Buffer instance");
5739
- if (value > max || value < min) throw new RangeError("\"value\" argument is out of bounds");
5740
- if (offset + ext > buf.length) throw new RangeError("Index out of range");
5741
- }
5742
- Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
5743
- value = +value;
5744
- offset = offset | 0;
5745
- byteLength = byteLength | 0;
5746
- if (!noAssert) {
5747
- var maxBytes = Math.pow(2, 8 * byteLength) - 1;
5748
- checkInt(this, value, offset, byteLength, maxBytes, 0);
5749
- }
5750
- var mul = 1;
5751
- var i = 0;
5752
- this[offset] = value & 255;
5753
- while (++i < byteLength && (mul *= 256)) this[offset + i] = value / mul & 255;
5754
- return offset + byteLength;
5755
- };
5756
- Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
5757
- value = +value;
5758
- offset = offset | 0;
5759
- byteLength = byteLength | 0;
5760
- if (!noAssert) {
5761
- var maxBytes = Math.pow(2, 8 * byteLength) - 1;
5762
- checkInt(this, value, offset, byteLength, maxBytes, 0);
5763
- }
5764
- var i = byteLength - 1;
5765
- var mul = 1;
5766
- this[offset + i] = value & 255;
5767
- while (--i >= 0 && (mul *= 256)) this[offset + i] = value / mul & 255;
5768
- return offset + byteLength;
5769
- };
5770
- Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
5771
- value = +value;
5772
- offset = offset | 0;
5773
- if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
5774
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
5775
- this[offset] = value & 255;
5776
- return offset + 1;
5777
- };
5778
- function objectWriteUInt16(buf, value, offset, littleEndian) {
5779
- if (value < 0) value = 65535 + value + 1;
5780
- 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;
5781
- }
5782
- Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
5783
- value = +value;
5784
- offset = offset | 0;
5785
- if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
5786
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5787
- this[offset] = value & 255;
5788
- this[offset + 1] = value >>> 8;
5789
- } else objectWriteUInt16(this, value, offset, true);
5790
- return offset + 2;
5791
- };
5792
- Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
5793
- value = +value;
5794
- offset = offset | 0;
5795
- if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
5796
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5797
- this[offset] = value >>> 8;
5798
- this[offset + 1] = value & 255;
5799
- } else objectWriteUInt16(this, value, offset, false);
5800
- return offset + 2;
5801
- };
5802
- function objectWriteUInt32(buf, value, offset, littleEndian) {
5803
- if (value < 0) value = 4294967295 + value + 1;
5804
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
5805
- }
5806
- Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
5807
- value = +value;
5808
- offset = offset | 0;
5809
- if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
5810
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5811
- this[offset + 3] = value >>> 24;
5812
- this[offset + 2] = value >>> 16;
5813
- this[offset + 1] = value >>> 8;
5814
- this[offset] = value & 255;
5815
- } else objectWriteUInt32(this, value, offset, true);
5816
- return offset + 4;
5817
- };
5818
- Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
5819
- value = +value;
5820
- offset = offset | 0;
5821
- if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
5822
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5823
- this[offset] = value >>> 24;
5824
- this[offset + 1] = value >>> 16;
5825
- this[offset + 2] = value >>> 8;
5826
- this[offset + 3] = value & 255;
5827
- } else objectWriteUInt32(this, value, offset, false);
5828
- return offset + 4;
5829
- };
5830
- Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
5831
- value = +value;
5832
- offset = offset | 0;
5833
- if (!noAssert) {
5834
- var limit = Math.pow(2, 8 * byteLength - 1);
5835
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
5836
- }
5837
- var i = 0;
5838
- var mul = 1;
5839
- var sub = 0;
5840
- this[offset] = value & 255;
5841
- while (++i < byteLength && (mul *= 256)) {
5842
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1;
5843
- this[offset + i] = (value / mul >> 0) - sub & 255;
5844
- }
5845
- return offset + byteLength;
5846
- };
5847
- Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
5848
- value = +value;
5849
- offset = offset | 0;
5850
- if (!noAssert) {
5851
- var limit = Math.pow(2, 8 * byteLength - 1);
5852
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
5853
- }
5854
- var i = byteLength - 1;
5855
- var mul = 1;
5856
- var sub = 0;
5857
- this[offset + i] = value & 255;
5858
- while (--i >= 0 && (mul *= 256)) {
5859
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1;
5860
- this[offset + i] = (value / mul >> 0) - sub & 255;
5861
- }
5862
- return offset + byteLength;
5863
- };
5864
- Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
5865
- value = +value;
5866
- offset = offset | 0;
5867
- if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
5868
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
5869
- if (value < 0) value = 255 + value + 1;
5870
- this[offset] = value & 255;
5871
- return offset + 1;
5872
- };
5873
- Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
5874
- value = +value;
5875
- offset = offset | 0;
5876
- if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
5877
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5878
- this[offset] = value & 255;
5879
- this[offset + 1] = value >>> 8;
5880
- } else objectWriteUInt16(this, value, offset, true);
5881
- return offset + 2;
5882
- };
5883
- Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
5884
- value = +value;
5885
- offset = offset | 0;
5886
- if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
5887
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5888
- this[offset] = value >>> 8;
5889
- this[offset + 1] = value & 255;
5890
- } else objectWriteUInt16(this, value, offset, false);
5891
- return offset + 2;
5892
- };
5893
- Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
5894
- value = +value;
5895
- offset = offset | 0;
5896
- if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
5897
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5898
- this[offset] = value & 255;
5899
- this[offset + 1] = value >>> 8;
5900
- this[offset + 2] = value >>> 16;
5901
- this[offset + 3] = value >>> 24;
5902
- } else objectWriteUInt32(this, value, offset, true);
5903
- return offset + 4;
5904
- };
5905
- Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
5906
- value = +value;
5907
- offset = offset | 0;
5908
- if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
5909
- if (value < 0) value = 4294967295 + value + 1;
5910
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5911
- this[offset] = value >>> 24;
5912
- this[offset + 1] = value >>> 16;
5913
- this[offset + 2] = value >>> 8;
5914
- this[offset + 3] = value & 255;
5915
- } else objectWriteUInt32(this, value, offset, false);
5916
- return offset + 4;
5917
- };
5918
- function checkIEEE754(buf, value, offset, ext, max, min) {
5919
- if (offset + ext > buf.length) throw new RangeError("Index out of range");
5920
- if (offset < 0) throw new RangeError("Index out of range");
5921
- }
5922
- function writeFloat(buf, value, offset, littleEndian, noAssert) {
5923
- if (!noAssert) checkIEEE754(buf, value, offset, 4);
5924
- write(buf, value, offset, littleEndian, 23, 4);
5925
- return offset + 4;
5926
- }
5927
- Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
5928
- return writeFloat(this, value, offset, true, noAssert);
5929
- };
5930
- Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
5931
- return writeFloat(this, value, offset, false, noAssert);
5932
- };
5933
- function writeDouble(buf, value, offset, littleEndian, noAssert) {
5934
- if (!noAssert) checkIEEE754(buf, value, offset, 8);
5935
- write(buf, value, offset, littleEndian, 52, 8);
5936
- return offset + 8;
5937
- }
5938
- Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
5939
- return writeDouble(this, value, offset, true, noAssert);
5940
- };
5941
- Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
5942
- return writeDouble(this, value, offset, false, noAssert);
5943
- };
5944
- Buffer.prototype.copy = function copy(target, targetStart, start, end) {
5945
- if (!start) start = 0;
5946
- if (!end && end !== 0) end = this.length;
5947
- if (targetStart >= target.length) targetStart = target.length;
5948
- if (!targetStart) targetStart = 0;
5949
- if (end > 0 && end < start) end = start;
5950
- if (end === start) return 0;
5951
- if (target.length === 0 || this.length === 0) return 0;
5952
- if (targetStart < 0) throw new RangeError("targetStart out of bounds");
5953
- if (start < 0 || start >= this.length) throw new RangeError("sourceStart out of bounds");
5954
- if (end < 0) throw new RangeError("sourceEnd out of bounds");
5955
- if (end > this.length) end = this.length;
5956
- if (target.length - targetStart < end - start) end = target.length - targetStart + start;
5957
- var len = end - start;
5958
- var i;
5959
- if (this === target && start < targetStart && targetStart < end) for (i = len - 1; i >= 0; --i) target[i + targetStart] = this[i + start];
5960
- else if (len < 1e3 || !Buffer.TYPED_ARRAY_SUPPORT) for (i = 0; i < len; ++i) target[i + targetStart] = this[i + start];
5961
- else Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
5962
- return len;
5963
- };
5964
- Buffer.prototype.fill = function fill(val, start, end, encoding) {
5965
- if (typeof val === "string") {
5966
- if (typeof start === "string") {
5967
- encoding = start;
5968
- start = 0;
5969
- end = this.length;
5970
- } else if (typeof end === "string") {
5971
- encoding = end;
5972
- end = this.length;
5973
- }
5974
- if (val.length === 1) {
5975
- var code = val.charCodeAt(0);
5976
- if (code < 256) val = code;
5977
- }
5978
- if (encoding !== void 0 && typeof encoding !== "string") throw new TypeError("encoding must be a string");
5979
- if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding);
5980
- } else if (typeof val === "number") val = val & 255;
5981
- if (start < 0 || this.length < start || this.length < end) throw new RangeError("Out of range index");
5982
- if (end <= start) return this;
5983
- start = start >>> 0;
5984
- end = end === void 0 ? this.length : end >>> 0;
5985
- if (!val) val = 0;
5986
- var i;
5987
- if (typeof val === "number") for (i = start; i < end; ++i) this[i] = val;
5988
- else {
5989
- var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString());
5990
- var len = bytes.length;
5991
- for (i = 0; i < end - start; ++i) this[i + start] = bytes[i % len];
5992
- }
5993
- return this;
5994
- };
5995
- var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
5996
- function base64clean(str) {
5997
- str = stringtrim(str).replace(INVALID_BASE64_RE, "");
5998
- if (str.length < 2) return "";
5999
- while (str.length % 4 !== 0) str = str + "=";
6000
- return str;
6001
- }
6002
- function stringtrim(str) {
6003
- if (str.trim) return str.trim();
6004
- return str.replace(/^\s+|\s+$/g, "");
6005
- }
6006
- function toHex(n) {
6007
- if (n < 16) return "0" + n.toString(16);
6008
- return n.toString(16);
6009
- }
6010
- function utf8ToBytes(string, units) {
6011
- units = units || Infinity;
6012
- var codePoint;
6013
- var length = string.length;
6014
- var leadSurrogate = null;
6015
- var bytes = [];
6016
- for (var i = 0; i < length; ++i) {
6017
- codePoint = string.charCodeAt(i);
6018
- if (codePoint > 55295 && codePoint < 57344) {
6019
- if (!leadSurrogate) {
6020
- if (codePoint > 56319) {
6021
- if ((units -= 3) > -1) bytes.push(239, 191, 189);
6022
- continue;
6023
- } else if (i + 1 === length) {
6024
- if ((units -= 3) > -1) bytes.push(239, 191, 189);
6025
- continue;
6026
- }
6027
- leadSurrogate = codePoint;
6028
- continue;
6029
- }
6030
- if (codePoint < 56320) {
6031
- if ((units -= 3) > -1) bytes.push(239, 191, 189);
6032
- leadSurrogate = codePoint;
6033
- continue;
6034
- }
6035
- codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
6036
- } else if (leadSurrogate) {
6037
- if ((units -= 3) > -1) bytes.push(239, 191, 189);
6038
- }
6039
- leadSurrogate = null;
6040
- if (codePoint < 128) {
6041
- if ((units -= 1) < 0) break;
6042
- bytes.push(codePoint);
6043
- } else if (codePoint < 2048) {
6044
- if ((units -= 2) < 0) break;
6045
- bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
6046
- } else if (codePoint < 65536) {
6047
- if ((units -= 3) < 0) break;
6048
- bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
6049
- } else if (codePoint < 1114112) {
6050
- if ((units -= 4) < 0) break;
6051
- bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
6052
- } else throw new Error("Invalid code point");
6053
- }
6054
- return bytes;
6055
- }
6056
- function asciiToBytes(str) {
6057
- var byteArray = [];
6058
- for (var i = 0; i < str.length; ++i) byteArray.push(str.charCodeAt(i) & 255);
6059
- return byteArray;
6060
- }
6061
- function utf16leToBytes(str, units) {
6062
- var c, hi, lo;
6063
- var byteArray = [];
6064
- for (var i = 0; i < str.length; ++i) {
6065
- if ((units -= 2) < 0) break;
6066
- c = str.charCodeAt(i);
6067
- hi = c >> 8;
6068
- lo = c % 256;
6069
- byteArray.push(lo);
6070
- byteArray.push(hi);
6071
- }
6072
- return byteArray;
6073
- }
6074
- function base64ToBytes(str) {
6075
- return toByteArray(base64clean(str));
6076
- }
6077
- function blitBuffer(src, dst, offset, length) {
6078
- for (var i = 0; i < length; ++i) {
6079
- if (i + offset >= dst.length || i >= src.length) break;
6080
- dst[i + offset] = src[i];
6081
- }
6082
- return i;
6083
- }
6084
- function isnan(val) {
6085
- return val !== val;
6086
- }
6087
- function isBuffer(obj) {
6088
- return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
6089
- }
6090
- function isFastBuffer(obj) {
6091
- return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
6092
- }
6093
- function isSlowBuffer(obj) {
6094
- return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
6095
- }
6096
- //#endregion
6097
- //#region \0polyfill-node.events.js
6098
- var domain;
6099
- function EventHandlers() {}
6100
- EventHandlers.prototype = Object.create(null);
6101
- function EventEmitter() {
6102
- EventEmitter.init.call(this);
6103
- }
6104
- EventEmitter.EventEmitter = EventEmitter;
6105
- EventEmitter.usingDomains = false;
6106
- EventEmitter.prototype.domain = void 0;
6107
- EventEmitter.prototype._events = void 0;
6108
- EventEmitter.prototype._maxListeners = void 0;
6109
- EventEmitter.defaultMaxListeners = 10;
6110
- EventEmitter.init = function() {
6111
- this.domain = null;
6112
- if (EventEmitter.usingDomains) {
6113
- if (domain.active && !(this instanceof domain.Domain)) this.domain = domain.active;
6114
- }
6115
- if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
6116
- this._events = new EventHandlers();
6117
- this._eventsCount = 0;
6118
- }
6119
- this._maxListeners = this._maxListeners || void 0;
6120
- };
6121
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
6122
- if (typeof n !== "number" || n < 0 || isNaN(n)) throw new TypeError("\"n\" argument must be a positive number");
6123
- this._maxListeners = n;
6124
- return this;
6125
- };
6126
- function $getMaxListeners(that) {
6127
- if (that._maxListeners === void 0) return EventEmitter.defaultMaxListeners;
6128
- return that._maxListeners;
6129
- }
6130
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
6131
- return $getMaxListeners(this);
6132
- };
6133
- function emitNone(handler, isFn, self) {
6134
- if (isFn) handler.call(self);
6135
- else {
6136
- var len = handler.length;
6137
- var listeners = arrayClone(handler, len);
6138
- for (var i = 0; i < len; ++i) listeners[i].call(self);
6139
- }
6140
- }
6141
- function emitOne(handler, isFn, self, arg1) {
6142
- if (isFn) handler.call(self, arg1);
6143
- else {
6144
- var len = handler.length;
6145
- var listeners = arrayClone(handler, len);
6146
- for (var i = 0; i < len; ++i) listeners[i].call(self, arg1);
6147
- }
6148
- }
6149
- function emitTwo(handler, isFn, self, arg1, arg2) {
6150
- if (isFn) handler.call(self, arg1, arg2);
6151
- else {
6152
- var len = handler.length;
6153
- var listeners = arrayClone(handler, len);
6154
- for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2);
6155
- }
6156
- }
6157
- function emitThree(handler, isFn, self, arg1, arg2, arg3) {
6158
- if (isFn) handler.call(self, arg1, arg2, arg3);
6159
- else {
6160
- var len = handler.length;
6161
- var listeners = arrayClone(handler, len);
6162
- for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2, arg3);
6163
- }
6164
- }
6165
- function emitMany(handler, isFn, self, args) {
6166
- if (isFn) handler.apply(self, args);
6167
- else {
6168
- var len = handler.length;
6169
- var listeners = arrayClone(handler, len);
6170
- for (var i = 0; i < len; ++i) listeners[i].apply(self, args);
6171
- }
6172
- }
6173
- EventEmitter.prototype.emit = function emit(type) {
6174
- var er, handler, len, args, i, events, domain;
6175
- var needDomainExit = false;
6176
- var doError = type === "error";
6177
- events = this._events;
6178
- if (events) doError = doError && events.error == null;
6179
- else if (!doError) return false;
6180
- domain = this.domain;
6181
- if (doError) {
6182
- er = arguments[1];
6183
- if (domain) {
6184
- if (!er) er = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event");
6185
- er.domainEmitter = this;
6186
- er.domain = domain;
6187
- er.domainThrown = false;
6188
- domain.emit("error", er);
6189
- } else if (er instanceof Error) throw er;
6190
- else {
6191
- var err = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event. (" + er + ")");
6192
- err.context = er;
6193
- throw err;
6194
- }
6195
- return false;
6196
- }
6197
- handler = events[type];
6198
- if (!handler) return false;
6199
- var isFn = typeof handler === "function";
6200
- len = arguments.length;
6201
- switch (len) {
6202
- case 1:
6203
- emitNone(handler, isFn, this);
6204
- break;
6205
- case 2:
6206
- emitOne(handler, isFn, this, arguments[1]);
6207
- break;
6208
- case 3:
6209
- emitTwo(handler, isFn, this, arguments[1], arguments[2]);
6210
- break;
6211
- case 4:
6212
- emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
6213
- break;
6214
- default:
6215
- args = new Array(len - 1);
6216
- for (i = 1; i < len; i++) args[i - 1] = arguments[i];
6217
- emitMany(handler, isFn, this, args);
6218
- }
6219
- if (needDomainExit) domain.exit();
6220
- return true;
6221
- };
6222
- function _addListener(target, type, listener, prepend) {
6223
- var m;
6224
- var events;
6225
- var existing;
6226
- if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
6227
- events = target._events;
6228
- if (!events) {
6229
- events = target._events = new EventHandlers();
6230
- target._eventsCount = 0;
6231
- } else {
6232
- if (events.newListener) {
6233
- target.emit("newListener", type, listener.listener ? listener.listener : listener);
6234
- events = target._events;
6235
- }
6236
- existing = events[type];
6237
- }
6238
- if (!existing) {
6239
- existing = events[type] = listener;
6240
- ++target._eventsCount;
6241
- } else {
6242
- if (typeof existing === "function") existing = events[type] = prepend ? [listener, existing] : [existing, listener];
6243
- else if (prepend) existing.unshift(listener);
6244
- else existing.push(listener);
6245
- if (!existing.warned) {
6246
- m = $getMaxListeners(target);
6247
- if (m && m > 0 && existing.length > m) {
6248
- existing.warned = true;
6249
- var w = /* @__PURE__ */ new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + type + " listeners added. Use emitter.setMaxListeners() to increase limit");
6250
- w.name = "MaxListenersExceededWarning";
6251
- w.emitter = target;
6252
- w.type = type;
6253
- w.count = existing.length;
6254
- emitWarning(w);
6255
- }
6256
- }
6257
- }
6258
- return target;
6259
- }
6260
- function emitWarning(e) {
6261
- typeof console.warn === "function" ? console.warn(e) : console.log(e);
6262
- }
6263
- EventEmitter.prototype.addListener = function addListener(type, listener) {
6264
- return _addListener(this, type, listener, false);
6265
- };
6266
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
6267
- EventEmitter.prototype.prependListener = function prependListener(type, listener) {
6268
- return _addListener(this, type, listener, true);
6269
- };
6270
- function _onceWrap(target, type, listener) {
6271
- var fired = false;
6272
- function g() {
6273
- target.removeListener(type, g);
6274
- if (!fired) {
6275
- fired = true;
6276
- listener.apply(target, arguments);
6277
- }
6278
- }
6279
- g.listener = listener;
6280
- return g;
6281
- }
6282
- EventEmitter.prototype.once = function once(type, listener) {
6283
- if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
6284
- this.on(type, _onceWrap(this, type, listener));
6285
- return this;
6286
- };
6287
- EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
6288
- if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
6289
- this.prependListener(type, _onceWrap(this, type, listener));
6290
- return this;
6291
- };
6292
- EventEmitter.prototype.removeListener = function removeListener(type, listener) {
6293
- var list, events, position, i, originalListener;
6294
- if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
6295
- events = this._events;
6296
- if (!events) return this;
6297
- list = events[type];
6298
- if (!list) return this;
6299
- if (list === listener || list.listener && list.listener === listener) if (--this._eventsCount === 0) this._events = new EventHandlers();
6300
- else {
6301
- delete events[type];
6302
- if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
6303
- }
6304
- else if (typeof list !== "function") {
6305
- position = -1;
6306
- for (i = list.length; i-- > 0;) if (list[i] === listener || list[i].listener && list[i].listener === listener) {
6307
- originalListener = list[i].listener;
6308
- position = i;
6309
- break;
6310
- }
6311
- if (position < 0) return this;
6312
- if (list.length === 1) {
6313
- list[0] = void 0;
6314
- if (--this._eventsCount === 0) {
6315
- this._events = new EventHandlers();
6316
- return this;
6317
- } else delete events[type];
6318
- } else spliceOne(list, position);
6319
- if (events.removeListener) this.emit("removeListener", type, originalListener || listener);
6320
- }
6321
- return this;
6322
- };
6323
- EventEmitter.prototype.off = function(type, listener) {
6324
- return this.removeListener(type, listener);
6325
- };
6326
- EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
6327
- var listeners, events = this._events;
6328
- if (!events) return this;
6329
- if (!events.removeListener) {
6330
- if (arguments.length === 0) {
6331
- this._events = new EventHandlers();
6332
- this._eventsCount = 0;
6333
- } else if (events[type]) if (--this._eventsCount === 0) this._events = new EventHandlers();
6334
- else delete events[type];
6335
- return this;
6336
- }
6337
- if (arguments.length === 0) {
6338
- var keys = Object.keys(events);
6339
- for (var i = 0, key; i < keys.length; ++i) {
6340
- key = keys[i];
6341
- if (key === "removeListener") continue;
6342
- this.removeAllListeners(key);
6343
- }
6344
- this.removeAllListeners("removeListener");
6345
- this._events = new EventHandlers();
6346
- this._eventsCount = 0;
6347
- return this;
6348
- }
6349
- listeners = events[type];
6350
- if (typeof listeners === "function") this.removeListener(type, listeners);
6351
- else if (listeners) do
6352
- this.removeListener(type, listeners[listeners.length - 1]);
6353
- while (listeners[0]);
6354
- return this;
6355
- };
6356
- EventEmitter.prototype.listeners = function listeners(type) {
6357
- var evlistener;
6358
- var ret;
6359
- var events = this._events;
6360
- if (!events) ret = [];
6361
- else {
6362
- evlistener = events[type];
6363
- if (!evlistener) ret = [];
6364
- else if (typeof evlistener === "function") ret = [evlistener.listener || evlistener];
6365
- else ret = unwrapListeners(evlistener);
6366
- }
6367
- return ret;
6368
- };
6369
- EventEmitter.listenerCount = function(emitter, type) {
6370
- if (typeof emitter.listenerCount === "function") return emitter.listenerCount(type);
6371
- else return listenerCount$1.call(emitter, type);
6372
- };
6373
- EventEmitter.prototype.listenerCount = listenerCount$1;
6374
- function listenerCount$1(type) {
6375
- var events = this._events;
6376
- if (events) {
6377
- var evlistener = events[type];
6378
- if (typeof evlistener === "function") return 1;
6379
- else if (evlistener) return evlistener.length;
6380
- }
6381
- return 0;
6382
- }
6383
- EventEmitter.prototype.eventNames = function eventNames() {
6384
- return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
6385
- };
6386
- function spliceOne(list, index) {
6387
- for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) list[i] = list[k];
6388
- list.pop();
6389
- }
6390
- function arrayClone(arr, i) {
6391
- var copy = new Array(i);
6392
- while (i--) copy[i] = arr[i];
6393
- return copy;
6394
- }
6395
- function unwrapListeners(arr) {
6396
- var ret = new Array(arr.length);
6397
- for (var i = 0; i < ret.length; ++i) ret[i] = arr[i].listener || arr[i];
6398
- return ret;
6399
- }
6400
- //#endregion
6401
- //#region \0polyfill-node.process.js
6402
- function defaultSetTimout() {
6403
- throw new Error("setTimeout has not been defined");
6404
- }
6405
- function defaultClearTimeout() {
6406
- throw new Error("clearTimeout has not been defined");
6407
- }
6408
- var cachedSetTimeout = defaultSetTimout;
6409
- var cachedClearTimeout = defaultClearTimeout;
6410
- if (typeof _polyfill_node_global_default.setTimeout === "function") cachedSetTimeout = setTimeout;
6411
- if (typeof _polyfill_node_global_default.clearTimeout === "function") cachedClearTimeout = clearTimeout;
6412
- function runTimeout(fun) {
6413
- if (cachedSetTimeout === setTimeout) return setTimeout(fun, 0);
6414
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
6415
- cachedSetTimeout = setTimeout;
6416
- return setTimeout(fun, 0);
6417
- }
6418
- try {
6419
- return cachedSetTimeout(fun, 0);
6420
- } catch (e) {
6421
- try {
6422
- return cachedSetTimeout.call(null, fun, 0);
6423
- } catch (e) {
6424
- return cachedSetTimeout.call(this, fun, 0);
6425
- }
6426
- }
6427
- }
6428
- function runClearTimeout(marker) {
6429
- if (cachedClearTimeout === clearTimeout) return clearTimeout(marker);
6430
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
6431
- cachedClearTimeout = clearTimeout;
6432
- return clearTimeout(marker);
6433
- }
6434
- try {
6435
- return cachedClearTimeout(marker);
6436
- } catch (e) {
6437
- try {
6438
- return cachedClearTimeout.call(null, marker);
6439
- } catch (e) {
6440
- return cachedClearTimeout.call(this, marker);
6441
- }
6442
- }
6443
- }
6444
- var queue = [];
6445
- var draining = false;
6446
- var currentQueue;
6447
- var queueIndex = -1;
6448
- function cleanUpNextTick() {
6449
- if (!draining || !currentQueue) return;
6450
- draining = false;
6451
- if (currentQueue.length) queue = currentQueue.concat(queue);
6452
- else queueIndex = -1;
6453
- if (queue.length) drainQueue();
6454
- }
6455
- function drainQueue() {
6456
- if (draining) return;
6457
- var timeout = runTimeout(cleanUpNextTick);
6458
- draining = true;
6459
- var len = queue.length;
6460
- while (len) {
6461
- currentQueue = queue;
6462
- queue = [];
6463
- while (++queueIndex < len) if (currentQueue) currentQueue[queueIndex].run();
6464
- queueIndex = -1;
6465
- len = queue.length;
6466
- }
6467
- currentQueue = null;
6468
- draining = false;
6469
- runClearTimeout(timeout);
6470
- }
6471
- function nextTick(fun) {
6472
- var args = new Array(arguments.length - 1);
6473
- if (arguments.length > 1) for (var i = 1; i < arguments.length; i++) args[i - 1] = arguments[i];
6474
- queue.push(new Item(fun, args));
6475
- if (queue.length === 1 && !draining) runTimeout(drainQueue);
6476
- }
6477
- function Item(fun, array) {
6478
- this.fun = fun;
6479
- this.array = array;
6480
- }
6481
- Item.prototype.run = function() {
6482
- this.fun.apply(null, this.array);
6483
- };
6484
- var title = "browser";
6485
- var platform = "browser";
6486
- var env = {};
6487
- var argv = [];
6488
- var versions = {};
6489
- var release = {};
6490
- var config = {};
6491
- function noop() {}
6492
- var on = noop;
6493
- var addListener = noop;
6494
- var once = noop;
6495
- var off = noop;
6496
- var removeListener = noop;
6497
- var removeAllListeners = noop;
6498
- var emit = noop;
6499
- function binding(name) {
6500
- throw new Error("process.binding is not supported");
6501
- }
6502
- function cwd() {
6503
- return "/";
6504
- }
6505
- function chdir(dir) {
6506
- throw new Error("process.chdir is not supported");
6507
- }
6508
- function umask() {
6509
- return 0;
6510
- }
6511
- var performance = _polyfill_node_global_default.performance || {};
6512
- var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
6513
- return (/* @__PURE__ */ new Date()).getTime();
6514
- };
6515
- function hrtime(previousTimestamp) {
6516
- var clocktime = performanceNow.call(performance) * .001;
6517
- var seconds = Math.floor(clocktime);
6518
- var nanoseconds = Math.floor(clocktime % 1 * 1e9);
6519
- if (previousTimestamp) {
6520
- seconds = seconds - previousTimestamp[0];
6521
- nanoseconds = nanoseconds - previousTimestamp[1];
6522
- if (nanoseconds < 0) {
6523
- seconds--;
6524
- nanoseconds += 1e9;
6525
- }
6526
- }
6527
- return [seconds, nanoseconds];
6528
- }
6529
- var startTime = /* @__PURE__ */ new Date();
6530
- function uptime() {
6531
- return (/* @__PURE__ */ new Date() - startTime) / 1e3;
6532
- }
6533
- var browser$1 = {
6534
- nextTick,
6535
- title,
6536
- browser: true,
6537
- env,
6538
- argv,
6539
- version: "",
6540
- versions,
6541
- on,
6542
- addListener,
6543
- once,
6544
- off,
6545
- removeListener,
6546
- removeAllListeners,
6547
- emit,
6548
- binding,
6549
- cwd,
6550
- chdir,
6551
- umask,
6552
- hrtime,
6553
- platform,
6554
- release,
6555
- config,
6556
- uptime
6557
- };
6558
- //#endregion
6559
- //#region \0polyfill-node._inherits.js
6560
- var inherits;
6561
- if (typeof Object.create === "function") inherits = function inherits(ctor, superCtor) {
6562
- ctor.super_ = superCtor;
6563
- ctor.prototype = Object.create(superCtor.prototype, { constructor: {
6564
- value: ctor,
6565
- enumerable: false,
6566
- writable: true,
6567
- configurable: true
6568
- } });
6569
- };
6570
- else inherits = function inherits(ctor, superCtor) {
6571
- ctor.super_ = superCtor;
6572
- var TempCtor = function() {};
6573
- TempCtor.prototype = superCtor.prototype;
6574
- ctor.prototype = new TempCtor();
6575
- ctor.prototype.constructor = ctor;
6576
- };
6577
- var _polyfill_node__inherits_default = inherits;
6578
- //#endregion
6579
- //#region \0polyfill-node.util.js
6580
- /**
6581
- * Inherit the prototype methods from one constructor into another.
6582
- *
6583
- * The Function.prototype.inherits from lang.js rewritten as a standalone
6584
- * function (not on Function.prototype). NOTE: If this file is to be loaded
6585
- * during bootstrapping this function needs to be rewritten using some native
6586
- * functions as prototype setup using normal JavaScript does not work as
6587
- * expected during bootstrapping (see mirror.js in r114903).
6588
- *
6589
- * @param {function} ctor Constructor function which needs to inherit the
6590
- * prototype.
6591
- * @param {function} superCtor Constructor function to inherit prototype from.
6592
- */
6593
- var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors(obj) {
6594
- var keys = Object.keys(obj);
6595
- var descriptors = {};
6596
- for (var i = 0; i < keys.length; i++) descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
6597
- return descriptors;
6598
- };
6599
- var formatRegExp = /%[sdj%]/g;
6600
- function format(f) {
6601
- if (!isString(f)) {
6602
- var objects = [];
6603
- for (var i = 0; i < arguments.length; i++) objects.push(inspect(arguments[i]));
6604
- return objects.join(" ");
6605
- }
6606
- var i = 1;
6607
- var args = arguments;
6608
- var len = args.length;
6609
- var str = String(f).replace(formatRegExp, function(x) {
6610
- if (x === "%%") return "%";
6611
- if (i >= len) return x;
6612
- switch (x) {
6613
- case "%s": return String(args[i++]);
6614
- case "%d": return Number(args[i++]);
6615
- case "%j": try {
6616
- return JSON.stringify(args[i++]);
6617
- } catch (_) {
6618
- return "[Circular]";
6619
- }
6620
- default: return x;
6621
- }
6622
- });
6623
- for (var x = args[i]; i < len; x = args[++i]) if (isNull(x) || !isObject(x)) str += " " + x;
6624
- else str += " " + inspect(x);
6625
- return str;
6626
- }
6627
- function deprecate(fn, msg) {
6628
- if (isUndefined(_polyfill_node_global_default.process)) return function() {
6629
- return deprecate(fn, msg).apply(this, arguments);
6630
- };
6631
- if (browser$1.noDeprecation === true) return fn;
6632
- var warned = false;
6633
- function deprecated() {
6634
- if (!warned) {
6635
- if (browser$1.throwDeprecation) throw new Error(msg);
6636
- else if (browser$1.traceDeprecation) console.trace(msg);
6637
- else console.error(msg);
6638
- warned = true;
6639
- }
6640
- return fn.apply(this, arguments);
6641
- }
6642
- return deprecated;
6643
- }
6644
- var debugs = {};
6645
- var debugEnviron;
6646
- function debuglog(set) {
6647
- if (isUndefined(debugEnviron)) debugEnviron = browser$1.env.NODE_DEBUG || "";
6648
- set = set.toUpperCase();
6649
- if (!debugs[set]) if (new RegExp("\\b" + set + "\\b", "i").test(debugEnviron)) {
6650
- var pid = 0;
6651
- debugs[set] = function() {
6652
- var msg = format.apply(null, arguments);
6653
- console.error("%s %d: %s", set, pid, msg);
6654
- };
6655
- } else debugs[set] = function() {};
6656
- return debugs[set];
6657
- }
6658
- /**
6659
- * Echos the value of a value. Trys to print the value out
6660
- * in the best way possible given the different types.
6661
- *
6662
- * @param {Object} obj The object to print out.
6663
- * @param {Object} opts Optional options object that alters the output.
6664
- */
6665
- function inspect(obj, opts) {
6666
- var ctx = {
6667
- seen: [],
6668
- stylize: stylizeNoColor
6669
- };
6670
- if (arguments.length >= 3) ctx.depth = arguments[2];
6671
- if (arguments.length >= 4) ctx.colors = arguments[3];
6672
- if (isBoolean(opts)) ctx.showHidden = opts;
6673
- else if (opts) _extend(ctx, opts);
6674
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
6675
- if (isUndefined(ctx.depth)) ctx.depth = 2;
6676
- if (isUndefined(ctx.colors)) ctx.colors = false;
6677
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
6678
- if (ctx.colors) ctx.stylize = stylizeWithColor;
6679
- return formatValue(ctx, obj, ctx.depth);
6680
- }
6681
- inspect.colors = {
6682
- "bold": [1, 22],
6683
- "italic": [3, 23],
6684
- "underline": [4, 24],
6685
- "inverse": [7, 27],
6686
- "white": [37, 39],
6687
- "grey": [90, 39],
6688
- "black": [30, 39],
6689
- "blue": [34, 39],
6690
- "cyan": [36, 39],
6691
- "green": [32, 39],
6692
- "magenta": [35, 39],
6693
- "red": [31, 39],
6694
- "yellow": [33, 39]
6695
- };
6696
- inspect.styles = {
6697
- "special": "cyan",
6698
- "number": "yellow",
6699
- "boolean": "yellow",
6700
- "undefined": "grey",
6701
- "null": "bold",
6702
- "string": "green",
6703
- "date": "magenta",
6704
- "regexp": "red"
6705
- };
6706
- function stylizeWithColor(str, styleType) {
6707
- var style = inspect.styles[styleType];
6708
- if (style) return "\x1B[" + inspect.colors[style][0] + "m" + str + "\x1B[" + inspect.colors[style][1] + "m";
6709
- else return str;
6710
- }
6711
- function stylizeNoColor(str, styleType) {
6712
- return str;
6713
- }
6714
- function arrayToHash(array) {
6715
- var hash = {};
6716
- array.forEach(function(val, idx) {
6717
- hash[val] = true;
6718
- });
6719
- return hash;
6720
- }
6721
- function formatValue(ctx, value, recurseTimes) {
6722
- if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value)) {
6723
- var ret = value.inspect(recurseTimes, ctx);
6724
- if (!isString(ret)) ret = formatValue(ctx, ret, recurseTimes);
6725
- return ret;
6726
- }
6727
- var primitive = formatPrimitive(ctx, value);
6728
- if (primitive) return primitive;
6729
- var keys = Object.keys(value);
6730
- var visibleKeys = arrayToHash(keys);
6731
- if (ctx.showHidden) keys = Object.getOwnPropertyNames(value);
6732
- if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) return formatError(value);
6733
- if (keys.length === 0) {
6734
- if (isFunction(value)) {
6735
- var name = value.name ? ": " + value.name : "";
6736
- return ctx.stylize("[Function" + name + "]", "special");
6737
- }
6738
- if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
6739
- if (isDate(value)) return ctx.stylize(Date.prototype.toString.call(value), "date");
6740
- if (isError(value)) return formatError(value);
6741
- }
6742
- var base = "", array = false, braces = ["{", "}"];
6743
- if (isArray(value)) {
6744
- array = true;
6745
- braces = ["[", "]"];
6746
- }
6747
- if (isFunction(value)) base = " [Function" + (value.name ? ": " + value.name : "") + "]";
6748
- if (isRegExp(value)) base = " " + RegExp.prototype.toString.call(value);
6749
- if (isDate(value)) base = " " + Date.prototype.toUTCString.call(value);
6750
- if (isError(value)) base = " " + formatError(value);
6751
- if (keys.length === 0 && (!array || value.length == 0)) return braces[0] + base + braces[1];
6752
- if (recurseTimes < 0) if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
6753
- else return ctx.stylize("[Object]", "special");
6754
- ctx.seen.push(value);
6755
- var output;
6756
- if (array) output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
6757
- else output = keys.map(function(key) {
6758
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
6759
- });
6760
- ctx.seen.pop();
6761
- return reduceToSingleString(output, base, braces);
6762
- }
6763
- function formatPrimitive(ctx, value) {
6764
- if (isUndefined(value)) return ctx.stylize("undefined", "undefined");
6765
- if (isString(value)) {
6766
- var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\"") + "'";
6767
- return ctx.stylize(simple, "string");
6768
- }
6769
- if (isNumber(value)) return ctx.stylize("" + value, "number");
6770
- if (isBoolean(value)) return ctx.stylize("" + value, "boolean");
6771
- if (isNull(value)) return ctx.stylize("null", "null");
6772
- }
6773
- function formatError(value) {
6774
- return "[" + Error.prototype.toString.call(value) + "]";
6775
- }
6776
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
6777
- var output = [];
6778
- 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));
6779
- else output.push("");
6780
- keys.forEach(function(key) {
6781
- if (!key.match(/^\d+$/)) output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
6782
- });
6783
- return output;
6784
- }
6785
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
6786
- var name, str, desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
6787
- if (desc.get) if (desc.set) str = ctx.stylize("[Getter/Setter]", "special");
6788
- else str = ctx.stylize("[Getter]", "special");
6789
- else if (desc.set) str = ctx.stylize("[Setter]", "special");
6790
- if (!hasOwnProperty(visibleKeys, key)) name = "[" + key + "]";
6791
- if (!str) if (ctx.seen.indexOf(desc.value) < 0) {
6792
- if (isNull(recurseTimes)) str = formatValue(ctx, desc.value, null);
6793
- else str = formatValue(ctx, desc.value, recurseTimes - 1);
6794
- if (str.indexOf("\n") > -1) if (array) str = str.split("\n").map(function(line) {
6795
- return " " + line;
6796
- }).join("\n").substr(2);
6797
- else str = "\n" + str.split("\n").map(function(line) {
6798
- return " " + line;
6799
- }).join("\n");
6800
- } else str = ctx.stylize("[Circular]", "special");
6801
- if (isUndefined(name)) {
6802
- if (array && key.match(/^\d+$/)) return str;
6803
- name = JSON.stringify("" + key);
6804
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
6805
- name = name.substr(1, name.length - 2);
6806
- name = ctx.stylize(name, "name");
6807
- } else {
6808
- name = name.replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
6809
- name = ctx.stylize(name, "string");
6810
- }
6811
- }
6812
- return name + ": " + str;
6813
- }
6814
- function reduceToSingleString(output, base, braces) {
6815
- var numLinesEst = 0;
6816
- if (output.reduce(function(prev, cur) {
6817
- numLinesEst++;
6818
- if (cur.indexOf("\n") >= 0) numLinesEst++;
6819
- return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1;
6820
- }, 0) > 60) return braces[0] + (base === "" ? "" : base + "\n ") + " " + output.join(",\n ") + " " + braces[1];
6821
- return braces[0] + base + " " + output.join(", ") + " " + braces[1];
6822
- }
6823
- function isArray(ar) {
6824
- return Array.isArray(ar);
6825
- }
6826
- function isBoolean(arg) {
6827
- return typeof arg === "boolean";
6828
- }
6829
- function isNull(arg) {
6830
- return arg === null;
6831
- }
6832
- function isNumber(arg) {
6833
- return typeof arg === "number";
6834
- }
6835
- function isString(arg) {
6836
- return typeof arg === "string";
6837
- }
6838
- function isUndefined(arg) {
6839
- return arg === void 0;
6840
- }
6841
- function isRegExp(re) {
6842
- return isObject(re) && objectToString(re) === "[object RegExp]";
6843
- }
6844
- function isObject(arg) {
6845
- return typeof arg === "object" && arg !== null;
6846
- }
6847
- function isDate(d) {
6848
- return isObject(d) && objectToString(d) === "[object Date]";
6849
- }
6850
- function isError(e) {
6851
- return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
6852
- }
6853
- function isFunction(arg) {
6854
- return typeof arg === "function";
6855
- }
6856
- function objectToString(o) {
6857
- return Object.prototype.toString.call(o);
6858
- }
6859
- function _extend(origin, add) {
6860
- if (!add || !isObject(add)) return origin;
6861
- var keys = Object.keys(add);
6862
- var i = keys.length;
6863
- while (i--) origin[keys[i]] = add[keys[i]];
6864
- return origin;
6865
- }
6866
- function hasOwnProperty(obj, prop) {
6867
- return Object.prototype.hasOwnProperty.call(obj, prop);
6868
- }
6869
- var kCustomPromisifiedSymbol = typeof Symbol !== "undefined" ? Symbol("util.promisify.custom") : void 0;
6870
- function promisify(original) {
6871
- if (typeof original !== "function") throw new TypeError("The \"original\" argument must be of type Function");
6872
- if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
6873
- var fn = original[kCustomPromisifiedSymbol];
6874
- if (typeof fn !== "function") throw new TypeError("The \"util.promisify.custom\" argument must be of type Function");
6875
- Object.defineProperty(fn, kCustomPromisifiedSymbol, {
6876
- value: fn,
6877
- enumerable: false,
6878
- writable: false,
6879
- configurable: true
6880
- });
6881
- return fn;
6882
- }
6883
- function fn() {
6884
- var promiseResolve, promiseReject;
6885
- var promise = new Promise(function(resolve, reject) {
6886
- promiseResolve = resolve;
6887
- promiseReject = reject;
6888
- });
6889
- var args = [];
6890
- for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);
6891
- args.push(function(err, value) {
6892
- if (err) promiseReject(err);
6893
- else promiseResolve(value);
6894
- });
6895
- try {
6896
- original.apply(this, args);
6897
- } catch (err) {
6898
- promiseReject(err);
6899
- }
6900
- return promise;
6901
- }
6902
- Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
6903
- if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
6904
- value: fn,
6905
- enumerable: false,
6906
- writable: false,
6907
- configurable: true
6908
- });
6909
- return Object.defineProperties(fn, getOwnPropertyDescriptors(original));
6910
- }
6911
- promisify.custom = kCustomPromisifiedSymbol;
6912
- //#endregion
6913
- //#region \0polyfill-node._buffer_list.js
6914
- var _polyfill_node__buffer_list_default = BufferList;
6915
- function BufferList() {
6916
- this.head = null;
6917
- this.tail = null;
6918
- this.length = 0;
6919
- }
6920
- BufferList.prototype.push = function(v) {
6921
- var entry = {
6922
- data: v,
6923
- next: null
6924
- };
6925
- if (this.length > 0) this.tail.next = entry;
6926
- else this.head = entry;
6927
- this.tail = entry;
6928
- ++this.length;
6929
- };
6930
- BufferList.prototype.unshift = function(v) {
6931
- var entry = {
6932
- data: v,
6933
- next: this.head
6934
- };
6935
- if (this.length === 0) this.tail = entry;
6936
- this.head = entry;
6937
- ++this.length;
6938
- };
6939
- BufferList.prototype.shift = function() {
6940
- if (this.length === 0) return;
6941
- var ret = this.head.data;
6942
- if (this.length === 1) this.head = this.tail = null;
6943
- else this.head = this.head.next;
6944
- --this.length;
6945
- return ret;
6946
- };
6947
- BufferList.prototype.clear = function() {
6948
- this.head = this.tail = null;
6949
- this.length = 0;
6950
- };
6951
- BufferList.prototype.join = function(s) {
6952
- if (this.length === 0) return "";
6953
- var p = this.head;
6954
- var ret = "" + p.data;
6955
- while (p = p.next) ret += s + p.data;
6956
- return ret;
6957
- };
6958
- BufferList.prototype.concat = function(n) {
6959
- if (this.length === 0) return Buffer.alloc(0);
6960
- if (this.length === 1) return this.head.data;
6961
- var ret = Buffer.allocUnsafe(n >>> 0);
6962
- var p = this.head;
6963
- var i = 0;
6964
- while (p) {
6965
- p.data.copy(ret, i);
6966
- i += p.data.length;
6967
- p = p.next;
6968
- }
6969
- return ret;
6970
- };
6971
- //#endregion
6972
- //#region \0polyfill-node.string_decoder.js
6973
- var isBufferEncoding = Buffer.isEncoding || function(encoding) {
6974
- switch (encoding && encoding.toLowerCase()) {
6975
- case "hex":
6976
- case "utf8":
6977
- case "utf-8":
6978
- case "ascii":
6979
- case "binary":
6980
- case "base64":
6981
- case "ucs2":
6982
- case "ucs-2":
6983
- case "utf16le":
6984
- case "utf-16le":
6985
- case "raw": return true;
6986
- default: return false;
6987
- }
6988
- };
6989
- function assertEncoding(encoding) {
6990
- if (encoding && !isBufferEncoding(encoding)) throw new Error("Unknown encoding: " + encoding);
6991
- }
6992
- function StringDecoder(encoding) {
6993
- this.encoding = (encoding || "utf8").toLowerCase().replace(/[-_]/, "");
6994
- assertEncoding(encoding);
6995
- switch (this.encoding) {
6996
- case "utf8":
6997
- this.surrogateSize = 3;
6998
- break;
6999
- case "ucs2":
7000
- case "utf16le":
7001
- this.surrogateSize = 2;
7002
- this.detectIncompleteChar = utf16DetectIncompleteChar;
7003
- break;
7004
- case "base64":
7005
- this.surrogateSize = 3;
7006
- this.detectIncompleteChar = base64DetectIncompleteChar;
7007
- break;
7008
- default:
7009
- this.write = passThroughWrite;
7010
- return;
7011
- }
7012
- this.charBuffer = new Buffer(6);
7013
- this.charReceived = 0;
7014
- this.charLength = 0;
7015
- }
7016
- StringDecoder.prototype.write = function(buffer) {
7017
- var charStr = "";
7018
- while (this.charLength) {
7019
- var available = buffer.length >= this.charLength - this.charReceived ? this.charLength - this.charReceived : buffer.length;
7020
- buffer.copy(this.charBuffer, this.charReceived, 0, available);
7021
- this.charReceived += available;
7022
- if (this.charReceived < this.charLength) return "";
7023
- buffer = buffer.slice(available, buffer.length);
7024
- charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
7025
- var charCode = charStr.charCodeAt(charStr.length - 1);
7026
- if (charCode >= 55296 && charCode <= 56319) {
7027
- this.charLength += this.surrogateSize;
7028
- charStr = "";
7029
- continue;
7030
- }
7031
- this.charReceived = this.charLength = 0;
7032
- if (buffer.length === 0) return charStr;
7033
- break;
7034
- }
7035
- this.detectIncompleteChar(buffer);
7036
- var end = buffer.length;
7037
- if (this.charLength) {
7038
- buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
7039
- end -= this.charReceived;
7040
- }
7041
- charStr += buffer.toString(this.encoding, 0, end);
7042
- var end = charStr.length - 1;
7043
- var charCode = charStr.charCodeAt(end);
7044
- if (charCode >= 55296 && charCode <= 56319) {
7045
- var size = this.surrogateSize;
7046
- this.charLength += size;
7047
- this.charReceived += size;
7048
- this.charBuffer.copy(this.charBuffer, size, 0, size);
7049
- buffer.copy(this.charBuffer, 0, 0, size);
7050
- return charStr.substring(0, end);
7051
- }
7052
- return charStr;
7053
- };
7054
- StringDecoder.prototype.detectIncompleteChar = function(buffer) {
7055
- var i = buffer.length >= 3 ? 3 : buffer.length;
7056
- for (; i > 0; i--) {
7057
- var c = buffer[buffer.length - i];
7058
- if (i == 1 && c >> 5 == 6) {
7059
- this.charLength = 2;
7060
- break;
7061
- }
7062
- if (i <= 2 && c >> 4 == 14) {
7063
- this.charLength = 3;
7064
- break;
7065
- }
7066
- if (i <= 3 && c >> 3 == 30) {
7067
- this.charLength = 4;
7068
- break;
7069
- }
7070
- }
7071
- this.charReceived = i;
7072
- };
7073
- StringDecoder.prototype.end = function(buffer) {
7074
- var res = "";
7075
- if (buffer && buffer.length) res = this.write(buffer);
7076
- if (this.charReceived) {
7077
- var cr = this.charReceived;
7078
- var buf = this.charBuffer;
7079
- var enc = this.encoding;
7080
- res += buf.slice(0, cr).toString(enc);
7081
- }
7082
- return res;
7083
- };
7084
- function passThroughWrite(buffer) {
7085
- return buffer.toString(this.encoding);
7086
- }
7087
- function utf16DetectIncompleteChar(buffer) {
7088
- this.charReceived = buffer.length % 2;
7089
- this.charLength = this.charReceived ? 2 : 0;
7090
- }
7091
- function base64DetectIncompleteChar(buffer) {
7092
- this.charReceived = buffer.length % 3;
7093
- this.charLength = this.charReceived ? 3 : 0;
7094
- }
7095
- //#endregion
7096
- //#region \0polyfill-node._stream_readable.js
7097
- Readable.ReadableState = ReadableState;
7098
- var debug = debuglog("stream");
7099
- _polyfill_node__inherits_default(Readable, EventEmitter);
7100
- function prependListener(emitter, event, fn) {
7101
- if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
7102
- else if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
7103
- else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);
7104
- else emitter._events[event] = [fn, emitter._events[event]];
7105
- }
7106
- function listenerCount(emitter, type) {
7107
- return emitter.listeners(type).length;
7108
- }
7109
- function ReadableState(options, stream) {
7110
- options = options || {};
7111
- this.objectMode = !!options.objectMode;
7112
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
7113
- var hwm = options.highWaterMark;
7114
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
7115
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
7116
- this.highWaterMark = ~~this.highWaterMark;
7117
- this.buffer = new _polyfill_node__buffer_list_default();
7118
- this.length = 0;
7119
- this.pipes = null;
7120
- this.pipesCount = 0;
7121
- this.flowing = null;
7122
- this.ended = false;
7123
- this.endEmitted = false;
7124
- this.reading = false;
7125
- this.sync = true;
7126
- this.needReadable = false;
7127
- this.emittedReadable = false;
7128
- this.readableListening = false;
7129
- this.resumeScheduled = false;
7130
- this.defaultEncoding = options.defaultEncoding || "utf8";
7131
- this.ranOut = false;
7132
- this.awaitDrain = 0;
7133
- this.readingMore = false;
7134
- this.decoder = null;
7135
- this.encoding = null;
7136
- if (options.encoding) {
7137
- this.decoder = new StringDecoder(options.encoding);
7138
- this.encoding = options.encoding;
7139
- }
7140
- }
7141
- function Readable(options) {
7142
- if (!(this instanceof Readable)) return new Readable(options);
7143
- this._readableState = new ReadableState(options, this);
7144
- this.readable = true;
7145
- if (options && typeof options.read === "function") this._read = options.read;
7146
- EventEmitter.call(this);
7147
- }
7148
- Readable.prototype.push = function(chunk, encoding) {
7149
- var state = this._readableState;
7150
- if (!state.objectMode && typeof chunk === "string") {
7151
- encoding = encoding || state.defaultEncoding;
7152
- if (encoding !== state.encoding) {
7153
- chunk = Buffer.from(chunk, encoding);
7154
- encoding = "";
7155
- }
7156
- }
7157
- return readableAddChunk(this, state, chunk, encoding, false);
7158
- };
7159
- Readable.prototype.unshift = function(chunk) {
7160
- var state = this._readableState;
7161
- return readableAddChunk(this, state, chunk, "", true);
7162
- };
7163
- Readable.prototype.isPaused = function() {
7164
- return this._readableState.flowing === false;
7165
- };
7166
- function readableAddChunk(stream, state, chunk, encoding, addToFront) {
7167
- var er = chunkInvalid(state, chunk);
7168
- if (er) stream.emit("error", er);
7169
- else if (chunk === null) {
7170
- state.reading = false;
7171
- onEofChunk(stream, state);
7172
- } else if (state.objectMode || chunk && chunk.length > 0) if (state.ended && !addToFront) {
7173
- var e = /* @__PURE__ */ new Error("stream.push() after EOF");
7174
- stream.emit("error", e);
7175
- } else if (state.endEmitted && addToFront) {
7176
- var _e = /* @__PURE__ */ new Error("stream.unshift() after end event");
7177
- stream.emit("error", _e);
7178
- } else {
7179
- var skipAdd;
7180
- if (state.decoder && !addToFront && !encoding) {
7181
- chunk = state.decoder.write(chunk);
7182
- skipAdd = !state.objectMode && chunk.length === 0;
7183
- }
7184
- if (!addToFront) state.reading = false;
7185
- if (!skipAdd) if (state.flowing && state.length === 0 && !state.sync) {
7186
- stream.emit("data", chunk);
7187
- stream.read(0);
7188
- } else {
7189
- state.length += state.objectMode ? 1 : chunk.length;
7190
- if (addToFront) state.buffer.unshift(chunk);
7191
- else state.buffer.push(chunk);
7192
- if (state.needReadable) emitReadable(stream);
7193
- }
7194
- maybeReadMore(stream, state);
7195
- }
7196
- else if (!addToFront) state.reading = false;
7197
- return needMoreData(state);
7198
- }
7199
- function needMoreData(state) {
7200
- return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
7201
- }
7202
- Readable.prototype.setEncoding = function(enc) {
7203
- this._readableState.decoder = new StringDecoder(enc);
7204
- this._readableState.encoding = enc;
7205
- return this;
7206
- };
7207
- var MAX_HWM = 8388608;
7208
- function computeNewHighWaterMark(n) {
7209
- if (n >= MAX_HWM) n = MAX_HWM;
7210
- else {
7211
- n--;
7212
- n |= n >>> 1;
7213
- n |= n >>> 2;
7214
- n |= n >>> 4;
7215
- n |= n >>> 8;
7216
- n |= n >>> 16;
7217
- n++;
7218
- }
7219
- return n;
7220
- }
7221
- function howMuchToRead(n, state) {
7222
- if (n <= 0 || state.length === 0 && state.ended) return 0;
7223
- if (state.objectMode) return 1;
7224
- if (n !== n) if (state.flowing && state.length) return state.buffer.head.data.length;
7225
- else return state.length;
7226
- if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
7227
- if (n <= state.length) return n;
7228
- if (!state.ended) {
7229
- state.needReadable = true;
7230
- return 0;
7231
- }
7232
- return state.length;
7233
- }
7234
- Readable.prototype.read = function(n) {
7235
- debug("read", n);
7236
- n = parseInt(n, 10);
7237
- var state = this._readableState;
7238
- var nOrig = n;
7239
- if (n !== 0) state.emittedReadable = false;
7240
- if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
7241
- debug("read: emitReadable", state.length, state.ended);
7242
- if (state.length === 0 && state.ended) endReadable(this);
7243
- else emitReadable(this);
7244
- return null;
7245
- }
7246
- n = howMuchToRead(n, state);
7247
- if (n === 0 && state.ended) {
7248
- if (state.length === 0) endReadable(this);
7249
- return null;
7250
- }
7251
- var doRead = state.needReadable;
7252
- debug("need readable", doRead);
7253
- if (state.length === 0 || state.length - n < state.highWaterMark) {
7254
- doRead = true;
7255
- debug("length less than watermark", doRead);
7256
- }
7257
- if (state.ended || state.reading) {
7258
- doRead = false;
7259
- debug("reading or ended", doRead);
7260
- } else if (doRead) {
7261
- debug("do read");
7262
- state.reading = true;
7263
- state.sync = true;
7264
- if (state.length === 0) state.needReadable = true;
7265
- this._read(state.highWaterMark);
7266
- state.sync = false;
7267
- if (!state.reading) n = howMuchToRead(nOrig, state);
7268
- }
7269
- var ret;
7270
- if (n > 0) ret = fromList(n, state);
7271
- else ret = null;
7272
- if (ret === null) {
7273
- state.needReadable = true;
7274
- n = 0;
7275
- } else state.length -= n;
7276
- if (state.length === 0) {
7277
- if (!state.ended) state.needReadable = true;
7278
- if (nOrig !== n && state.ended) endReadable(this);
7279
- }
7280
- if (ret !== null) this.emit("data", ret);
7281
- return ret;
7282
- };
7283
- function chunkInvalid(state, chunk) {
7284
- var er = null;
7285
- if (!Buffer.isBuffer(chunk) && typeof chunk !== "string" && chunk !== null && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
7286
- return er;
7287
- }
7288
- function onEofChunk(stream, state) {
7289
- if (state.ended) return;
7290
- if (state.decoder) {
7291
- var chunk = state.decoder.end();
7292
- if (chunk && chunk.length) {
7293
- state.buffer.push(chunk);
7294
- state.length += state.objectMode ? 1 : chunk.length;
7295
- }
7296
- }
7297
- state.ended = true;
7298
- emitReadable(stream);
7299
- }
7300
- function emitReadable(stream) {
7301
- var state = stream._readableState;
7302
- state.needReadable = false;
7303
- if (!state.emittedReadable) {
7304
- debug("emitReadable", state.flowing);
7305
- state.emittedReadable = true;
7306
- if (state.sync) nextTick(emitReadable_, stream);
7307
- else emitReadable_(stream);
7308
- }
7309
- }
7310
- function emitReadable_(stream) {
7311
- debug("emit readable");
7312
- stream.emit("readable");
7313
- flow(stream);
7314
- }
7315
- function maybeReadMore(stream, state) {
7316
- if (!state.readingMore) {
7317
- state.readingMore = true;
7318
- nextTick(maybeReadMore_, stream, state);
7319
- }
7320
- }
7321
- function maybeReadMore_(stream, state) {
7322
- var len = state.length;
7323
- while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
7324
- debug("maybeReadMore read 0");
7325
- stream.read(0);
7326
- if (len === state.length) break;
7327
- else len = state.length;
7328
- }
7329
- state.readingMore = false;
7330
- }
7331
- Readable.prototype._read = function(n) {
7332
- this.emit("error", /* @__PURE__ */ new Error("not implemented"));
7333
- };
7334
- Readable.prototype.pipe = function(dest, pipeOpts) {
7335
- var src = this;
7336
- var state = this._readableState;
7337
- switch (state.pipesCount) {
7338
- case 0:
7339
- state.pipes = dest;
7340
- break;
7341
- case 1:
7342
- state.pipes = [state.pipes, dest];
7343
- break;
7344
- default:
7345
- state.pipes.push(dest);
7346
- break;
7347
- }
7348
- state.pipesCount += 1;
7349
- debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
7350
- var endFn = !pipeOpts || pipeOpts.end !== false ? onend : cleanup;
7351
- if (state.endEmitted) nextTick(endFn);
7352
- else src.once("end", endFn);
7353
- dest.on("unpipe", onunpipe);
7354
- function onunpipe(readable) {
7355
- debug("onunpipe");
7356
- if (readable === src) cleanup();
7357
- }
7358
- function onend() {
7359
- debug("onend");
7360
- dest.end();
7361
- }
7362
- var ondrain = pipeOnDrain(src);
7363
- dest.on("drain", ondrain);
7364
- var cleanedUp = false;
7365
- function cleanup() {
7366
- debug("cleanup");
7367
- dest.removeListener("close", onclose);
7368
- dest.removeListener("finish", onfinish);
7369
- dest.removeListener("drain", ondrain);
7370
- dest.removeListener("error", onerror);
7371
- dest.removeListener("unpipe", onunpipe);
7372
- src.removeListener("end", onend);
7373
- src.removeListener("end", cleanup);
7374
- src.removeListener("data", ondata);
7375
- cleanedUp = true;
7376
- if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
7377
- }
7378
- var increasedAwaitDrain = false;
7379
- src.on("data", ondata);
7380
- function ondata(chunk) {
7381
- debug("ondata");
7382
- increasedAwaitDrain = false;
7383
- if (false === dest.write(chunk) && !increasedAwaitDrain) {
7384
- if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
7385
- debug("false write response, pause", src._readableState.awaitDrain);
7386
- src._readableState.awaitDrain++;
7387
- increasedAwaitDrain = true;
7388
- }
7389
- src.pause();
7390
- }
7391
- }
7392
- function onerror(er) {
7393
- debug("onerror", er);
7394
- unpipe();
7395
- dest.removeListener("error", onerror);
7396
- if (listenerCount(dest, "error") === 0) dest.emit("error", er);
7397
- }
7398
- prependListener(dest, "error", onerror);
7399
- function onclose() {
7400
- dest.removeListener("finish", onfinish);
7401
- unpipe();
7402
- }
7403
- dest.once("close", onclose);
7404
- function onfinish() {
7405
- debug("onfinish");
7406
- dest.removeListener("close", onclose);
7407
- unpipe();
7408
- }
7409
- dest.once("finish", onfinish);
7410
- function unpipe() {
7411
- debug("unpipe");
7412
- src.unpipe(dest);
7413
- }
7414
- dest.emit("pipe", src);
7415
- if (!state.flowing) {
7416
- debug("pipe resume");
7417
- src.resume();
7418
- }
7419
- return dest;
7420
- };
7421
- function pipeOnDrain(src) {
7422
- return function() {
7423
- var state = src._readableState;
7424
- debug("pipeOnDrain", state.awaitDrain);
7425
- if (state.awaitDrain) state.awaitDrain--;
7426
- if (state.awaitDrain === 0 && src.listeners("data").length) {
7427
- state.flowing = true;
7428
- flow(src);
7429
- }
7430
- };
7431
- }
7432
- Readable.prototype.unpipe = function(dest) {
7433
- var state = this._readableState;
7434
- if (state.pipesCount === 0) return this;
7435
- if (state.pipesCount === 1) {
7436
- if (dest && dest !== state.pipes) return this;
7437
- if (!dest) dest = state.pipes;
7438
- state.pipes = null;
7439
- state.pipesCount = 0;
7440
- state.flowing = false;
7441
- if (dest) dest.emit("unpipe", this);
7442
- return this;
7443
- }
7444
- if (!dest) {
7445
- var dests = state.pipes;
7446
- var len = state.pipesCount;
7447
- state.pipes = null;
7448
- state.pipesCount = 0;
7449
- state.flowing = false;
7450
- for (var _i = 0; _i < len; _i++) dests[_i].emit("unpipe", this);
7451
- return this;
7452
- }
7453
- var i = indexOf(state.pipes, dest);
7454
- if (i === -1) return this;
7455
- state.pipes.splice(i, 1);
7456
- state.pipesCount -= 1;
7457
- if (state.pipesCount === 1) state.pipes = state.pipes[0];
7458
- dest.emit("unpipe", this);
7459
- return this;
7460
- };
7461
- Readable.prototype.on = function(ev, fn) {
7462
- var res = EventEmitter.prototype.on.call(this, ev, fn);
7463
- if (ev === "data") {
7464
- if (this._readableState.flowing !== false) this.resume();
7465
- } else if (ev === "readable") {
7466
- var state = this._readableState;
7467
- if (!state.endEmitted && !state.readableListening) {
7468
- state.readableListening = state.needReadable = true;
7469
- state.emittedReadable = false;
7470
- if (!state.reading) nextTick(nReadingNextTick, this);
7471
- else if (state.length) emitReadable(this, state);
7472
- }
7473
- }
7474
- return res;
7475
- };
7476
- Readable.prototype.addListener = Readable.prototype.on;
7477
- function nReadingNextTick(self) {
7478
- debug("readable nexttick read 0");
7479
- self.read(0);
7480
- }
7481
- Readable.prototype.resume = function() {
7482
- var state = this._readableState;
7483
- if (!state.flowing) {
7484
- debug("resume");
7485
- state.flowing = true;
7486
- resume(this, state);
7487
- }
7488
- return this;
7489
- };
7490
- function resume(stream, state) {
7491
- if (!state.resumeScheduled) {
7492
- state.resumeScheduled = true;
7493
- nextTick(resume_, stream, state);
7494
- }
7495
- }
7496
- function resume_(stream, state) {
7497
- if (!state.reading) {
7498
- debug("resume read 0");
7499
- stream.read(0);
7500
- }
7501
- state.resumeScheduled = false;
7502
- state.awaitDrain = 0;
7503
- stream.emit("resume");
7504
- flow(stream);
7505
- if (state.flowing && !state.reading) stream.read(0);
7506
- }
7507
- Readable.prototype.pause = function() {
7508
- debug("call pause flowing=%j", this._readableState.flowing);
7509
- if (false !== this._readableState.flowing) {
7510
- debug("pause");
7511
- this._readableState.flowing = false;
7512
- this.emit("pause");
7513
- }
7514
- return this;
7515
- };
7516
- function flow(stream) {
7517
- var state = stream._readableState;
7518
- debug("flow", state.flowing);
7519
- while (state.flowing && stream.read() !== null);
7520
- }
7521
- Readable.prototype.wrap = function(stream) {
7522
- var state = this._readableState;
7523
- var paused = false;
7524
- var self = this;
7525
- stream.on("end", function() {
7526
- debug("wrapped end");
7527
- if (state.decoder && !state.ended) {
7528
- var chunk = state.decoder.end();
7529
- if (chunk && chunk.length) self.push(chunk);
7530
- }
7531
- self.push(null);
7532
- });
7533
- stream.on("data", function(chunk) {
7534
- debug("wrapped data");
7535
- if (state.decoder) chunk = state.decoder.write(chunk);
7536
- if (state.objectMode && (chunk === null || chunk === void 0)) return;
7537
- else if (!state.objectMode && (!chunk || !chunk.length)) return;
7538
- if (!self.push(chunk)) {
7539
- paused = true;
7540
- stream.pause();
7541
- }
7542
- });
7543
- for (var i in stream) if (this[i] === void 0 && typeof stream[i] === "function") this[i] = function(method) {
7544
- return function() {
7545
- return stream[method].apply(stream, arguments);
7546
- };
7547
- }(i);
7548
- forEach([
7549
- "error",
7550
- "close",
7551
- "destroy",
7552
- "pause",
7553
- "resume"
7554
- ], function(ev) {
7555
- stream.on(ev, self.emit.bind(self, ev));
7556
- });
7557
- self._read = function(n) {
7558
- debug("wrapped _read", n);
7559
- if (paused) {
7560
- paused = false;
7561
- stream.resume();
7562
- }
7563
- };
7564
- return self;
7565
- };
7566
- Readable._fromList = fromList;
7567
- function fromList(n, state) {
7568
- if (state.length === 0) return null;
7569
- var ret;
7570
- if (state.objectMode) ret = state.buffer.shift();
7571
- else if (!n || n >= state.length) {
7572
- if (state.decoder) ret = state.buffer.join("");
7573
- else if (state.buffer.length === 1) ret = state.buffer.head.data;
7574
- else ret = state.buffer.concat(state.length);
7575
- state.buffer.clear();
7576
- } else ret = fromListPartial(n, state.buffer, state.decoder);
7577
- return ret;
7578
- }
7579
- function fromListPartial(n, list, hasStrings) {
7580
- var ret;
7581
- if (n < list.head.data.length) {
7582
- ret = list.head.data.slice(0, n);
7583
- list.head.data = list.head.data.slice(n);
7584
- } else if (n === list.head.data.length) ret = list.shift();
7585
- else ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
7586
- return ret;
7587
- }
7588
- function copyFromBufferString(n, list) {
7589
- var p = list.head;
7590
- var c = 1;
7591
- var ret = p.data;
7592
- n -= ret.length;
7593
- while (p = p.next) {
7594
- var str = p.data;
7595
- var nb = n > str.length ? str.length : n;
7596
- if (nb === str.length) ret += str;
7597
- else ret += str.slice(0, n);
7598
- n -= nb;
7599
- if (n === 0) {
7600
- if (nb === str.length) {
7601
- ++c;
7602
- if (p.next) list.head = p.next;
7603
- else list.head = list.tail = null;
7604
- } else {
7605
- list.head = p;
7606
- p.data = str.slice(nb);
7607
- }
7608
- break;
7609
- }
7610
- ++c;
7611
- }
7612
- list.length -= c;
7613
- return ret;
7614
- }
7615
- function copyFromBuffer(n, list) {
7616
- var ret = Buffer.allocUnsafe(n);
7617
- var p = list.head;
7618
- var c = 1;
7619
- p.data.copy(ret);
7620
- n -= p.data.length;
7621
- while (p = p.next) {
7622
- var buf = p.data;
7623
- var nb = n > buf.length ? buf.length : n;
7624
- buf.copy(ret, ret.length - n, 0, nb);
7625
- n -= nb;
7626
- if (n === 0) {
7627
- if (nb === buf.length) {
7628
- ++c;
7629
- if (p.next) list.head = p.next;
7630
- else list.head = list.tail = null;
7631
- } else {
7632
- list.head = p;
7633
- p.data = buf.slice(nb);
7634
- }
7635
- break;
7636
- }
7637
- ++c;
7638
- }
7639
- list.length -= c;
7640
- return ret;
7641
- }
7642
- function endReadable(stream) {
7643
- var state = stream._readableState;
7644
- if (state.length > 0) throw new Error("\"endReadable()\" called on non-empty stream");
7645
- if (!state.endEmitted) {
7646
- state.ended = true;
7647
- nextTick(endReadableNT, state, stream);
7648
- }
7649
- }
7650
- function endReadableNT(state, stream) {
7651
- if (!state.endEmitted && state.length === 0) {
7652
- state.endEmitted = true;
7653
- stream.readable = false;
7654
- stream.emit("end");
7655
- }
7656
- }
7657
- function forEach(xs, f) {
7658
- for (var i = 0, l = xs.length; i < l; i++) f(xs[i], i);
7659
- }
7660
- function indexOf(xs, x) {
7661
- for (var i = 0, l = xs.length; i < l; i++) if (xs[i] === x) return i;
7662
- return -1;
7663
- }
7664
- //#endregion
7665
- //#region \0polyfill-node._stream_writable.js
7666
- Writable.WritableState = WritableState;
7667
- _polyfill_node__inherits_default(Writable, EventEmitter);
7668
- function nop() {}
7669
- function WriteReq(chunk, encoding, cb) {
7670
- this.chunk = chunk;
7671
- this.encoding = encoding;
7672
- this.callback = cb;
7673
- this.next = null;
7674
- }
7675
- function WritableState(options, stream) {
7676
- Object.defineProperty(this, "buffer", { get: deprecate(function() {
7677
- return this.getBuffer();
7678
- }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.") });
7679
- options = options || {};
7680
- this.objectMode = !!options.objectMode;
7681
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
7682
- var hwm = options.highWaterMark;
7683
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
7684
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
7685
- this.highWaterMark = ~~this.highWaterMark;
7686
- this.needDrain = false;
7687
- this.ending = false;
7688
- this.ended = false;
7689
- this.finished = false;
7690
- var noDecode = options.decodeStrings === false;
7691
- this.decodeStrings = !noDecode;
7692
- this.defaultEncoding = options.defaultEncoding || "utf8";
7693
- this.length = 0;
7694
- this.writing = false;
7695
- this.corked = 0;
7696
- this.sync = true;
7697
- this.bufferProcessing = false;
7698
- this.onwrite = function(er) {
7699
- onwrite(stream, er);
7700
- };
7701
- this.writecb = null;
7702
- this.writelen = 0;
7703
- this.bufferedRequest = null;
7704
- this.lastBufferedRequest = null;
7705
- this.pendingcb = 0;
7706
- this.prefinished = false;
7707
- this.errorEmitted = false;
7708
- this.bufferedRequestCount = 0;
7709
- this.corkedRequestsFree = new CorkedRequest(this);
7710
- }
7711
- WritableState.prototype.getBuffer = function writableStateGetBuffer() {
7712
- var current = this.bufferedRequest;
7713
- var out = [];
7714
- while (current) {
7715
- out.push(current);
7716
- current = current.next;
7717
- }
7718
- return out;
7719
- };
7720
- function Writable(options) {
7721
- if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
7722
- this._writableState = new WritableState(options, this);
7723
- this.writable = true;
7724
- if (options) {
7725
- if (typeof options.write === "function") this._write = options.write;
7726
- if (typeof options.writev === "function") this._writev = options.writev;
7727
- }
7728
- EventEmitter.call(this);
7729
- }
7730
- Writable.prototype.pipe = function() {
7731
- this.emit("error", /* @__PURE__ */ new Error("Cannot pipe, not readable"));
7732
- };
7733
- function writeAfterEnd(stream, cb) {
7734
- var er = /* @__PURE__ */ new Error("write after end");
7735
- stream.emit("error", er);
7736
- nextTick(cb, er);
7737
- }
7738
- function validChunk(stream, state, chunk, cb) {
7739
- var valid = true;
7740
- var er = false;
7741
- if (chunk === null) er = /* @__PURE__ */ new TypeError("May not write null values to stream");
7742
- else if (!Buffer.isBuffer(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
7743
- if (er) {
7744
- stream.emit("error", er);
7745
- nextTick(cb, er);
7746
- valid = false;
7747
- }
7748
- return valid;
7749
- }
7750
- Writable.prototype.write = function(chunk, encoding, cb) {
7751
- var state = this._writableState;
7752
- var ret = false;
7753
- if (typeof encoding === "function") {
7754
- cb = encoding;
7755
- encoding = null;
7756
- }
7757
- if (Buffer.isBuffer(chunk)) encoding = "buffer";
7758
- else if (!encoding) encoding = state.defaultEncoding;
7759
- if (typeof cb !== "function") cb = nop;
7760
- if (state.ended) writeAfterEnd(this, cb);
7761
- else if (validChunk(this, state, chunk, cb)) {
7762
- state.pendingcb++;
7763
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
7764
- }
7765
- return ret;
7766
- };
7767
- Writable.prototype.cork = function() {
7768
- var state = this._writableState;
7769
- state.corked++;
7770
- };
7771
- Writable.prototype.uncork = function() {
7772
- var state = this._writableState;
7773
- if (state.corked) {
7774
- state.corked--;
7775
- if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
7776
- }
7777
- };
7778
- Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
7779
- if (typeof encoding === "string") encoding = encoding.toLowerCase();
7780
- if (!([
7781
- "hex",
7782
- "utf8",
7783
- "utf-8",
7784
- "ascii",
7785
- "binary",
7786
- "base64",
7787
- "ucs2",
7788
- "ucs-2",
7789
- "utf16le",
7790
- "utf-16le",
7791
- "raw"
7792
- ].indexOf((encoding + "").toLowerCase()) > -1)) throw new TypeError("Unknown encoding: " + encoding);
7793
- this._writableState.defaultEncoding = encoding;
7794
- return this;
7795
- };
7796
- function decodeChunk(state, chunk, encoding) {
7797
- if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") chunk = Buffer.from(chunk, encoding);
7798
- return chunk;
7799
- }
7800
- function writeOrBuffer(stream, state, chunk, encoding, cb) {
7801
- chunk = decodeChunk(state, chunk, encoding);
7802
- if (Buffer.isBuffer(chunk)) encoding = "buffer";
7803
- var len = state.objectMode ? 1 : chunk.length;
7804
- state.length += len;
7805
- var ret = state.length < state.highWaterMark;
7806
- if (!ret) state.needDrain = true;
7807
- if (state.writing || state.corked) {
7808
- var last = state.lastBufferedRequest;
7809
- state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
7810
- if (last) last.next = state.lastBufferedRequest;
7811
- else state.bufferedRequest = state.lastBufferedRequest;
7812
- state.bufferedRequestCount += 1;
7813
- } else doWrite(stream, state, false, len, chunk, encoding, cb);
7814
- return ret;
7815
- }
7816
- function doWrite(stream, state, writev, len, chunk, encoding, cb) {
7817
- state.writelen = len;
7818
- state.writecb = cb;
7819
- state.writing = true;
7820
- state.sync = true;
7821
- if (writev) stream._writev(chunk, state.onwrite);
7822
- else stream._write(chunk, encoding, state.onwrite);
7823
- state.sync = false;
7824
- }
7825
- function onwriteError(stream, state, sync, er, cb) {
7826
- --state.pendingcb;
7827
- if (sync) nextTick(cb, er);
7828
- else cb(er);
7829
- stream._writableState.errorEmitted = true;
7830
- stream.emit("error", er);
7831
- }
7832
- function onwriteStateUpdate(state) {
7833
- state.writing = false;
7834
- state.writecb = null;
7835
- state.length -= state.writelen;
7836
- state.writelen = 0;
7837
- }
7838
- function onwrite(stream, er) {
7839
- var state = stream._writableState;
7840
- var sync = state.sync;
7841
- var cb = state.writecb;
7842
- onwriteStateUpdate(state);
7843
- if (er) onwriteError(stream, state, sync, er, cb);
7844
- else {
7845
- var finished = needFinish(state);
7846
- if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(stream, state);
7847
- if (sync) nextTick(afterWrite, stream, state, finished, cb);
7848
- else afterWrite(stream, state, finished, cb);
7849
- }
7850
- }
7851
- function afterWrite(stream, state, finished, cb) {
7852
- if (!finished) onwriteDrain(stream, state);
7853
- state.pendingcb--;
7854
- cb();
7855
- finishMaybe(stream, state);
7856
- }
7857
- function onwriteDrain(stream, state) {
7858
- if (state.length === 0 && state.needDrain) {
7859
- state.needDrain = false;
7860
- stream.emit("drain");
7861
- }
7862
- }
7863
- function clearBuffer(stream, state) {
7864
- state.bufferProcessing = true;
7865
- var entry = state.bufferedRequest;
7866
- if (stream._writev && entry && entry.next) {
7867
- var l = state.bufferedRequestCount;
7868
- var buffer = new Array(l);
7869
- var holder = state.corkedRequestsFree;
7870
- holder.entry = entry;
7871
- var count = 0;
7872
- while (entry) {
7873
- buffer[count] = entry;
7874
- entry = entry.next;
7875
- count += 1;
7876
- }
7877
- doWrite(stream, state, true, state.length, buffer, "", holder.finish);
7878
- state.pendingcb++;
7879
- state.lastBufferedRequest = null;
7880
- if (holder.next) {
7881
- state.corkedRequestsFree = holder.next;
7882
- holder.next = null;
7883
- } else state.corkedRequestsFree = new CorkedRequest(state);
7884
- } else {
7885
- while (entry) {
7886
- var chunk = entry.chunk;
7887
- var encoding = entry.encoding;
7888
- var cb = entry.callback;
7889
- doWrite(stream, state, false, state.objectMode ? 1 : chunk.length, chunk, encoding, cb);
7890
- entry = entry.next;
7891
- if (state.writing) break;
7892
- }
7893
- if (entry === null) state.lastBufferedRequest = null;
7894
- }
7895
- state.bufferedRequestCount = 0;
7896
- state.bufferedRequest = entry;
7897
- state.bufferProcessing = false;
7898
- }
7899
- Writable.prototype._write = function(chunk, encoding, cb) {
7900
- cb(/* @__PURE__ */ new Error("not implemented"));
7901
- };
7902
- Writable.prototype._writev = null;
7903
- Writable.prototype.end = function(chunk, encoding, cb) {
7904
- var state = this._writableState;
7905
- if (typeof chunk === "function") {
7906
- cb = chunk;
7907
- chunk = null;
7908
- encoding = null;
7909
- } else if (typeof encoding === "function") {
7910
- cb = encoding;
7911
- encoding = null;
7912
- }
7913
- if (chunk !== null && chunk !== void 0) this.write(chunk, encoding);
7914
- if (state.corked) {
7915
- state.corked = 1;
7916
- this.uncork();
7917
- }
7918
- if (!state.ending && !state.finished) endWritable(this, state, cb);
7919
- };
7920
- function needFinish(state) {
7921
- return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
7922
- }
7923
- function prefinish(stream, state) {
7924
- if (!state.prefinished) {
7925
- state.prefinished = true;
7926
- stream.emit("prefinish");
7927
- }
7928
- }
7929
- function finishMaybe(stream, state) {
7930
- var need = needFinish(state);
7931
- if (need) if (state.pendingcb === 0) {
7932
- prefinish(stream, state);
7933
- state.finished = true;
7934
- stream.emit("finish");
7935
- } else prefinish(stream, state);
7936
- return need;
7937
- }
7938
- function endWritable(stream, state, cb) {
7939
- state.ending = true;
7940
- finishMaybe(stream, state);
7941
- if (cb) if (state.finished) nextTick(cb);
7942
- else stream.once("finish", cb);
7943
- state.ended = true;
7944
- stream.writable = false;
7945
- }
7946
- function CorkedRequest(state) {
7947
- var _this = this;
7948
- this.next = null;
7949
- this.entry = null;
7950
- this.finish = function(err) {
7951
- var entry = _this.entry;
7952
- _this.entry = null;
7953
- while (entry) {
7954
- var cb = entry.callback;
7955
- state.pendingcb--;
7956
- cb(err);
7957
- entry = entry.next;
7958
- }
7959
- if (state.corkedRequestsFree) state.corkedRequestsFree.next = _this;
7960
- else state.corkedRequestsFree = _this;
7961
- };
7962
- }
7963
- //#endregion
7964
- //#region \0polyfill-node._stream_duplex.js
7965
- _polyfill_node__inherits_default(Duplex, Readable);
7966
- var keys = Object.keys(Writable.prototype);
7967
- for (var v = 0; v < keys.length; v++) {
7968
- var method = keys[v];
7969
- if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
7970
- }
7971
- function Duplex(options) {
7972
- if (!(this instanceof Duplex)) return new Duplex(options);
7973
- Readable.call(this, options);
7974
- Writable.call(this, options);
7975
- if (options && options.readable === false) this.readable = false;
7976
- if (options && options.writable === false) this.writable = false;
7977
- this.allowHalfOpen = true;
7978
- if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
7979
- this.once("end", onend);
7980
- }
7981
- function onend() {
7982
- if (this.allowHalfOpen || this._writableState.ended) return;
7983
- nextTick(onEndNT, this);
7984
- }
7985
- function onEndNT(self) {
7986
- self.end();
7987
- }
7988
- //#endregion
7989
4852
  //#region src/export/packer/hyperlink-placeholders.ts
7990
4853
  function replaceHyperlinkPlaceholders(xml, hyperlinks, offset) {
7991
4854
  let result = xml;
@@ -8215,56 +5078,56 @@ var Compiler = class {
8215
5078
  const files = {};
8216
5079
  for (const key of Object.keys(mapping)) {
8217
5080
  const entry = mapping[key];
8218
- files[entry.path] = [textToUint8Array(entry.data), { level: 0 }];
5081
+ files[entry.path] = textToUint8Array(entry.data);
8219
5082
  }
8220
5083
  for (const override of overrides) files[override.path] = override.data instanceof Uint8Array ? override.data : textToUint8Array(override.data);
8221
5084
  for (let i = 0; i < file.Charts.Array.length; i++) {
8222
5085
  const chartData = file.Charts.Array[i];
8223
- files[`ppt/charts/chart${i + 1}.xml`] = [textToUint8Array(xml(this.formatter.format(chartData.chartSpace, context), {
5086
+ files[`ppt/charts/chart${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(chartData.chartSpace, context), {
8224
5087
  declaration,
8225
5088
  indent
8226
- })), { level: 0 }];
8227
- files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = [textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5089
+ }));
5090
+ files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
8228
5091
  encoding: "UTF-8",
8229
5092
  standalone: "yes"
8230
- } })), { level: 0 }];
5093
+ } }));
8231
5094
  }
8232
5095
  for (let i = 0; i < file.SmartArts.Array.length; i++) {
8233
5096
  const smartArtData = file.SmartArts.Array[i];
8234
- files[`ppt/diagrams/data${i + 1}.xml`] = [textToUint8Array(xml(this.formatter.format(smartArtData.dataModel, context), {
5097
+ files[`ppt/diagrams/data${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(smartArtData.dataModel, context), {
8235
5098
  declaration,
8236
5099
  indent
8237
- })), { level: 0 }];
8238
- files[`ppt/diagrams/layout${i + 1}.xml`] = [textToUint8Array(getLayoutXml(smartArtData.layout)), { level: 0 }];
8239
- files[`ppt/diagrams/quickStyle${i + 1}.xml`] = [textToUint8Array(getStyleXml(smartArtData.style)), { level: 0 }];
8240
- files[`ppt/diagrams/colors${i + 1}.xml`] = [textToUint8Array(getColorXml(smartArtData.color)), { level: 0 }];
8241
- files[`ppt/diagrams/drawing${i + 1}.xml`] = [textToUint8Array(DEFAULT_DRAWING_XML), { level: 0 }];
5100
+ }));
5101
+ files[`ppt/diagrams/layout${i + 1}.xml`] = textToUint8Array(getLayoutXml(smartArtData.layout));
5102
+ files[`ppt/diagrams/quickStyle${i + 1}.xml`] = textToUint8Array(getStyleXml(smartArtData.style));
5103
+ files[`ppt/diagrams/colors${i + 1}.xml`] = textToUint8Array(getColorXml(smartArtData.color));
5104
+ files[`ppt/diagrams/drawing${i + 1}.xml`] = textToUint8Array(DEFAULT_DRAWING_XML);
8242
5105
  }
8243
5106
  for (let i = 0; i < file.NotesSlides.length; i++) {
8244
5107
  const notesSlide = file.NotesSlides[i];
8245
- files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = [textToUint8Array(xml(this.formatter.format(notesSlide, context), {
5108
+ files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(notesSlide, context), {
8246
5109
  declaration,
8247
5110
  indent
8248
- })), { level: 0 }];
8249
- files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = [textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5111
+ }));
5112
+ files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
8250
5113
  encoding: "UTF-8",
8251
5114
  standalone: "yes"
8252
- } })), { level: 0 }];
5115
+ } }));
8253
5116
  }
8254
- if (file.CommentAuthorList) files["ppt/commentAuthors.xml"] = [textToUint8Array(xml(this.formatter.format(file.CommentAuthorList, context), {
5117
+ if (file.CommentAuthorList) files["ppt/commentAuthors.xml"] = textToUint8Array(xml(this.formatter.format(file.CommentAuthorList, context), {
8255
5118
  declaration,
8256
5119
  indent
8257
- })), { level: 0 }];
5120
+ }));
8258
5121
  const commentLists = file.SlideCommentLists;
8259
- for (let i = 0; i < commentLists.length; i++) if (commentLists[i]) files[`ppt/comments/comment${i + 1}.xml`] = [textToUint8Array(xml(this.formatter.format(commentLists[i], context), {
5122
+ for (let i = 0; i < commentLists.length; i++) if (commentLists[i]) files[`ppt/comments/comment${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(commentLists[i], context), {
8260
5123
  declaration,
8261
5124
  indent
8262
- })), { level: 0 }];
5125
+ }));
8263
5126
  for (const image of file.Media.Array) {
8264
- files[`ppt/media/${image.fileName}`] = [image.data, { level: 0 }];
5127
+ files[`ppt/media/${image.fileName}`] = [image.data, { level: ZIP_STORED_LEVEL }];
8265
5128
  if (image.type === "svg" && "fallback" in image) {
8266
5129
  const fallback = image.fallback;
8267
- files[`ppt/media/${fallback.fileName}`] = [fallback.data, { level: 0 }];
5130
+ files[`ppt/media/${fallback.fileName}`] = [fallback.data, { level: ZIP_STORED_LEVEL }];
8268
5131
  }
8269
5132
  }
8270
5133
  return files;
@@ -8276,52 +5139,11 @@ function textToUint8Array(data) {
8276
5139
  }
8277
5140
  //#endregion
8278
5141
  //#region src/export/packer/packer.ts
8279
- var Packer = class Packer {
8280
- static async pack(file, type, prettify, overrides = []) {
8281
- return convertOutput(zipSync(this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type, OoxmlMimeType.PPTX);
8282
- }
8283
- static async toString(file, prettify, overrides = []) {
8284
- return Packer.pack(file, "string", prettify, overrides);
8285
- }
8286
- static toArrayBuffer(file, prettify, overrides = []) {
8287
- return Packer.pack(file, "arraybuffer", prettify, overrides);
8288
- }
8289
- static toBuffer(file, prettify, overrides = []) {
8290
- return Packer.pack(file, "nodebuffer", prettify, overrides);
8291
- }
8292
- static toBlob(file, prettify, overrides = []) {
8293
- return Packer.pack(file, "blob", prettify, overrides);
8294
- }
8295
- static toBase64String(file, prettify, overrides = []) {
8296
- return Packer.pack(file, "base64", prettify, overrides);
8297
- }
8298
- static toStream(file, prettify, overrides = []) {
8299
- const stream = new Readable({ read() {} });
8300
- try {
8301
- const files = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
8302
- const zip = new Zip((err, chunk, final) => {
8303
- if (err) {
8304
- stream.destroy(err);
8305
- return;
8306
- }
8307
- if (!stream.destroyed) stream.push(Buffer.from(chunk));
8308
- if (final) stream.push(null);
8309
- });
8310
- for (const [name, data] of Object.entries(files)) {
8311
- const raw = Array.isArray(data) ? data[0] : data;
8312
- const level = Array.isArray(data) ? data[1].level ?? 6 : 6;
8313
- const entry = level === 0 ? new ZipPassThrough(name) : new ZipDeflate(name, { level });
8314
- zip.add(entry);
8315
- entry.push(raw, true);
8316
- }
8317
- zip.end();
8318
- } catch (err) {
8319
- stream.destroy(err instanceof Error ? err : new Error(String(err)));
8320
- }
8321
- return stream;
8322
- }
8323
- static compiler = new Compiler();
8324
- };
5142
+ const compiler = new Compiler();
5143
+ const Packer = createPacker({
5144
+ compile: (file, prettify, overrides) => compiler.compile(file, prettify, overrides),
5145
+ mimeType: OoxmlMimeType.PPTX
5146
+ });
8325
5147
  //#endregion
8326
5148
  //#region src/util/types.ts
8327
5149
  /** Convert percentage to thousandths of a percent (used in some OOXML attributes) */
@@ -8370,16 +5192,284 @@ var ParseContext = class {
8370
5192
  }
8371
5193
  };
8372
5194
  //#endregion
5195
+ //#region src/parse/animation.ts
5196
+ /**
5197
+ * Animation parser for PPTX documents.
5198
+ *
5199
+ * Parses p:timing elements and maps animations to their target shapes.
5200
+ *
5201
+ * @module
5202
+ */
5203
+ const ENTR_PRESET_TO_TYPE = /* @__PURE__ */ new Map();
5204
+ const EXIT_PRESET_TO_TYPE = /* @__PURE__ */ new Map();
5205
+ const EMPH_PRESET_TO_ID = /* @__PURE__ */ new Map();
5206
+ const PATH_PRESET_TO_TYPE = /* @__PURE__ */ new Map();
5207
+ const ENTR_IDS = {
5208
+ appear: 1,
5209
+ fade: 10,
5210
+ fly: 2,
5211
+ wipe: 22,
5212
+ dissolve: 34,
5213
+ split: 21,
5214
+ blinds: 25,
5215
+ checker: 26,
5216
+ randomBars: 24,
5217
+ wheel: 27,
5218
+ zoom: 10,
5219
+ cover: 28,
5220
+ push: 19,
5221
+ strips: 23
5222
+ };
5223
+ const EXIT_IDS = {
5224
+ appear: 53,
5225
+ fade: 59,
5226
+ fly: 51,
5227
+ wipe: 72,
5228
+ dissolve: 84,
5229
+ split: 71,
5230
+ blinds: 75,
5231
+ checker: 76,
5232
+ randomBars: 74,
5233
+ wheel: 77,
5234
+ zoom: 60,
5235
+ cover: 78,
5236
+ push: 69,
5237
+ strips: 73
5238
+ };
5239
+ const EMPH_IDS = {
5240
+ growShrink: 53,
5241
+ spin: 54,
5242
+ growWithTurn: 56,
5243
+ colorChange: 29,
5244
+ transparency: 57,
5245
+ boldFlash: 50,
5246
+ wave: 55,
5247
+ pulse: 58
5248
+ };
5249
+ const PATH_IDS = {
5250
+ customPath: 200,
5251
+ arc: 201,
5252
+ bounce: 202,
5253
+ circle: 203,
5254
+ curve: 204,
5255
+ figureEight: 205,
5256
+ line: 206,
5257
+ loop: 207
5258
+ };
5259
+ for (const [k, v] of Object.entries(ENTR_IDS)) ENTR_PRESET_TO_TYPE.set(v, k);
5260
+ for (const [k, v] of Object.entries(EXIT_IDS)) EXIT_PRESET_TO_TYPE.set(v, k);
5261
+ for (const [k, v] of Object.entries(EMPH_IDS)) EMPH_PRESET_TO_ID.set(v, k);
5262
+ for (const [k, v] of Object.entries(PATH_IDS)) PATH_PRESET_TO_TYPE.set(v, k);
5263
+ const SUBTYPE_TO_DIRECTION = /* @__PURE__ */ new Map();
5264
+ for (const [k, v] of Object.entries({
5265
+ left: 4,
5266
+ right: 8,
5267
+ up: 2,
5268
+ down: 1,
5269
+ horizontal: 16,
5270
+ vertical: 32
5271
+ })) SUBTYPE_TO_DIRECTION.set(v, k);
5272
+ /**
5273
+ * Parse p:timing element and return a map of shape ID → AnimationOptions.
5274
+ */
5275
+ function parseTiming(el) {
5276
+ const result = /* @__PURE__ */ new Map();
5277
+ const tnLst = findChild(el, "p:tnLst");
5278
+ if (!tnLst) return result;
5279
+ const mainPar = findChild(tnLst, "p:par");
5280
+ if (!mainPar) return result;
5281
+ const mainCTn = findChild(mainPar, "p:cTn");
5282
+ if (!mainCTn) return result;
5283
+ const childTnLst = findChild(mainCTn, "p:childTnLst");
5284
+ if (!childTnLst) return result;
5285
+ const seq = findChild(childTnLst, "p:seq");
5286
+ if (!seq) return result;
5287
+ const seqCTn = findChild(seq, "p:cTn");
5288
+ const seqChildTnLst = seqCTn ? findChild(seqCTn, "p:childTnLst") : void 0;
5289
+ if (!seqChildTnLst) return result;
5290
+ for (const parEl of seqChildTnLst.elements ?? []) {
5291
+ if (parEl.name !== "p:par") continue;
5292
+ const parCTn = findChild(parEl, "p:cTn");
5293
+ if (!parCTn) continue;
5294
+ const parChildTnLst = findChild(parCTn, "p:childTnLst");
5295
+ if (!parChildTnLst) continue;
5296
+ for (const effectEl of parChildTnLst.elements ?? []) {
5297
+ const anim = parseAnimationEffect(effectEl);
5298
+ if (!anim) continue;
5299
+ const shapeId = extractTargetShapeId(effectEl);
5300
+ if (shapeId !== void 0) result.set(shapeId, anim);
5301
+ }
5302
+ }
5303
+ return result;
5304
+ }
5305
+ function parseAnimationEffect(el) {
5306
+ const opts = {};
5307
+ const cTn = findChild(el, "p:cTn") ?? el;
5308
+ const nodeType = attr(cTn, "nodeType");
5309
+ if (nodeType === "clickEffect") opts.trigger = "onClick";
5310
+ else if (nodeType === "withEffect") opts.trigger = "withPrevious";
5311
+ else if (nodeType === "afterEffect") opts.trigger = "afterPrevious";
5312
+ const presetClass = attr(cTn, "presetClass");
5313
+ if (presetClass) opts.class = presetClass;
5314
+ const presetID = attrNum(cTn, "presetID");
5315
+ const dur = attr(cTn, "dur");
5316
+ if (dur) {
5317
+ const ms = parseDuration(dur);
5318
+ if (ms !== void 0) opts.duration = ms;
5319
+ }
5320
+ const stCondLst = findChild(cTn, "p:stCondLst");
5321
+ if (stCondLst) {
5322
+ const cond = findChild(stCondLst, "p:cond");
5323
+ if (cond) {
5324
+ const delay = attr(cond, "delay");
5325
+ if (delay) {
5326
+ const ms = parseDuration(delay);
5327
+ if (ms !== void 0) opts.delay = ms;
5328
+ }
5329
+ }
5330
+ }
5331
+ const presetSubtype = attrNum(cTn, "presetSubtype");
5332
+ if (presetSubtype !== void 0) {
5333
+ const dir = SUBTYPE_TO_DIRECTION.get(presetSubtype);
5334
+ if (dir) opts.direction = dir;
5335
+ }
5336
+ if (presetID !== void 0) {
5337
+ const cls = presetClass ?? "entr";
5338
+ if (cls === "entr") {
5339
+ const type = ENTR_PRESET_TO_TYPE.get(presetID);
5340
+ if (type) opts.type = type;
5341
+ } else if (cls === "exit") {
5342
+ const type = EXIT_PRESET_TO_TYPE.get(presetID);
5343
+ if (type) opts.type = type;
5344
+ } else if (cls === "emph") {
5345
+ const emphType = EMPH_PRESET_TO_ID.get(presetID);
5346
+ if (emphType) {
5347
+ opts.emphasisType = emphType;
5348
+ opts.type = "appear";
5349
+ }
5350
+ } else if (cls === "mediacall") {
5351
+ opts.mediaType = "play";
5352
+ opts.type = "appear";
5353
+ }
5354
+ }
5355
+ const childTnLst = findChild(cTn, "p:childTnLst");
5356
+ if (childTnLst) for (const sub of childTnLst.elements ?? []) switch (sub.name) {
5357
+ case "p:animEffect": {
5358
+ const subCTn = findChild(sub, "p:cTn");
5359
+ if (subCTn) {
5360
+ const subDur = attr(subCTn, "dur");
5361
+ if (subDur) {
5362
+ const ms = parseDuration(subDur);
5363
+ if (ms !== void 0) opts.duration = ms;
5364
+ }
5365
+ }
5366
+ break;
5367
+ }
5368
+ case "p:anim": {
5369
+ const subCTn = findChild(sub, "p:cTn");
5370
+ if (subCTn) {
5371
+ const attrName = findChild(subCTn, "p:attrNameLst");
5372
+ if (attrName) {
5373
+ const name = findChild(attrName, "p:attrName");
5374
+ if (name) {
5375
+ const text = name.elements?.[0]?.text;
5376
+ if (text) opts.attributeName = text;
5377
+ }
5378
+ }
5379
+ }
5380
+ const from = findChild(sub, "p:cb");
5381
+ if (from) {
5382
+ const val = findChild(from, "p:val");
5383
+ if (val) {
5384
+ const v = attr(val, "val");
5385
+ if (v) opts.from = v;
5386
+ }
5387
+ }
5388
+ const toEl = findChild(sub, "p:tavLst");
5389
+ if (toEl) {
5390
+ const tav = findChild(toEl, "p:tav");
5391
+ if (tav) {
5392
+ const toVal = findChild(tav, "p:val");
5393
+ if (toVal) {
5394
+ const v = attr(toVal, "val");
5395
+ if (v) opts.to = v;
5396
+ }
5397
+ }
5398
+ }
5399
+ break;
5400
+ }
5401
+ case "p:animMotion": {
5402
+ opts.pathType = "customPath";
5403
+ const path = attr(sub, "path");
5404
+ if (path) opts.path = path;
5405
+ break;
5406
+ }
5407
+ case "p:animScale":
5408
+ opts.emphasisType = "growShrink";
5409
+ break;
5410
+ case "p:animRot":
5411
+ opts.emphasisType = "spin";
5412
+ break;
5413
+ case "p:animClr":
5414
+ opts.emphasisType = "colorChange";
5415
+ break;
5416
+ case "p:cmd":
5417
+ if (attr(sub, "type") === "call") opts.mediaType = "play";
5418
+ break;
5419
+ }
5420
+ return Object.keys(opts).length > 0 ? opts : void 0;
5421
+ }
5422
+ function extractTargetShapeId(el) {
5423
+ const cBhvr = findDeep$1(el, "p:cBhvr")[0];
5424
+ if (!cBhvr) return void 0;
5425
+ const tgtEl = findChild(cBhvr, "p:tgtEl");
5426
+ if (!tgtEl) return void 0;
5427
+ const spTgt = findChild(tgtEl, "p:spTgt");
5428
+ if (!spTgt) return void 0;
5429
+ return attrNum(spTgt, "spid");
5430
+ }
5431
+ function findDeep$1(parent, name) {
5432
+ const results = [];
5433
+ function walk(el) {
5434
+ if (el.name === name) {
5435
+ results.push(el);
5436
+ return;
5437
+ }
5438
+ for (const child of el.elements ?? []) walk(child);
5439
+ }
5440
+ for (const child of parent.elements ?? []) walk(child);
5441
+ return results;
5442
+ }
5443
+ /**
5444
+ * Parse OOXML duration string to milliseconds.
5445
+ * Format: "PT#H#M#S" or "###ms" or just a number string
5446
+ */
5447
+ function parseDuration(val) {
5448
+ if (val.startsWith("PT")) {
5449
+ let ms = 0;
5450
+ const sMatch = val.match(/(\d+\.?\d*)S/);
5451
+ if (sMatch) ms += Math.round(parseFloat(sMatch[1]) * 1e3);
5452
+ const mMatch = val.match(/(\d+\.?\d*)M/);
5453
+ if (mMatch) ms += Math.round(parseFloat(mMatch[1]) * 6e4);
5454
+ const hMatch = val.match(/(\d+\.?\d*)H/);
5455
+ if (hMatch) ms += Math.round(parseFloat(hMatch[1]) * 36e5);
5456
+ return ms;
5457
+ }
5458
+ if (val === "indefinite") return void 0;
5459
+ const num = parseInt(val, 10);
5460
+ return isNaN(num) ? void 0 : num;
5461
+ }
5462
+ //#endregion
8373
5463
  //#region src/parse/slide.ts
8374
5464
  /**
8375
5465
  * Slide parser for PPTX documents.
8376
5466
  *
8377
- * Parses p:sld elements into ISlideOptions.
5467
+ * Parses p:sld elements into SlideOptions.
8378
5468
  *
8379
5469
  * @module
8380
5470
  */
8381
5471
  /**
8382
- * Parse a p:sld element into ISlideOptions.
5472
+ * Parse a p:sld element into SlideOptions.
8383
5473
  */
8384
5474
  function parseSlide(el, ctx) {
8385
5475
  const opts = {};
@@ -8396,9 +5486,31 @@ function parseSlide(el, ctx) {
8396
5486
  }
8397
5487
  if (slideChildren.length > 0) opts.children = slideChildren;
8398
5488
  }
5489
+ const hf = findChild(cSld, "p:hf");
5490
+ if (hf) {
5491
+ const hfOpts = {};
5492
+ if (findChild(hf, "p:sldNum")) hfOpts.slideNumber = true;
5493
+ if (findChild(hf, "p:dt")) hfOpts.dateTime = true;
5494
+ if (findChild(hf, "p:ftr")) hfOpts.footer = true;
5495
+ if (findChild(hf, "p:hdr")) hfOpts.header = true;
5496
+ if (Object.keys(hfOpts).length > 0) opts.headerFooter = hfOpts;
5497
+ }
8399
5498
  }
8400
5499
  const transition = findChild(el, "p:transition");
8401
5500
  if (transition) opts.transition = parseTransition(transition);
5501
+ const timing = findChild(el, "p:timing");
5502
+ if (timing) {
5503
+ const animMap = parseTiming(timing);
5504
+ if (animMap.size > 0 && opts.children) {
5505
+ const children = opts.children;
5506
+ for (let i = 0; i < children.length; i++) {
5507
+ const child = children[i];
5508
+ const inner = child[Object.keys(child)[0]] ?? {};
5509
+ const shapeId = inner.id;
5510
+ if (shapeId !== void 0 && animMap.has(shapeId)) inner.animation = animMap.get(shapeId);
5511
+ }
5512
+ }
5513
+ }
8402
5514
  for (const [, path] of ctx.slideRels) {
8403
5515
  if (!path.includes("notesSlides")) continue;
8404
5516
  const notesEl = ctx.pptx.doc.get(path);
@@ -8411,8 +5523,18 @@ function parseSlide(el, ctx) {
8411
5523
  }
8412
5524
  function parseSlideChild(el, ctx) {
8413
5525
  switch (el.name) {
8414
- case "p:sp": return { shape: parseShape(el, ctx) };
8415
- case "p:pic": return { picture: parsePicture(el, ctx) };
5526
+ case "p:sp": {
5527
+ const spPr = findChild(el, "p:spPr");
5528
+ const prstGeom = spPr ? findChild(spPr, "a:prstGeom") : void 0;
5529
+ if ((prstGeom ? attr(prstGeom, "prst") : void 0) === "line") return { line: parseLineShape(el) };
5530
+ return { shape: parseShape(el, ctx) };
5531
+ }
5532
+ case "p:pic": {
5533
+ const mediaType = detectMediaType(el);
5534
+ if (mediaType === "video") return { video: parseMediaFrame(el, ctx, "video") };
5535
+ if (mediaType === "audio") return { audio: parseMediaFrame(el, ctx, "audio") };
5536
+ return { picture: parsePicture(el, ctx) };
5537
+ }
8416
5538
  case "p:graphicFrame": return parseGraphicFrame(el, ctx);
8417
5539
  case "p:cxnSp": return { connector: parseConnector(el) };
8418
5540
  case "p:grpSp": return { group: parseGroup(el, ctx) };
@@ -8531,6 +5653,48 @@ function parseShape(el, _ctx) {
8531
5653
  if (txBody) parseTextBody(txBody, opts);
8532
5654
  return opts;
8533
5655
  }
5656
+ function parseLineShape(el) {
5657
+ const opts = {};
5658
+ const nvSpPr = findChild(el, "p:nvSpPr");
5659
+ if (nvSpPr) {
5660
+ const cNvPr = findChild(nvSpPr, "p:cNvPr");
5661
+ if (cNvPr) {
5662
+ const id = attrNum(cNvPr, "id");
5663
+ if (id !== void 0) opts.id = id;
5664
+ const name = attr(cNvPr, "name");
5665
+ if (name) opts.name = name;
5666
+ }
5667
+ }
5668
+ const spPr = findChild(el, "p:spPr");
5669
+ if (spPr) {
5670
+ const xfrm = findChild(spPr, "a:xfrm");
5671
+ if (xfrm) {
5672
+ const off = findChild(xfrm, "a:off");
5673
+ const ext = findChild(xfrm, "a:ext");
5674
+ const flipH = attrBool(xfrm, "flipH");
5675
+ const flipV = attrBool(xfrm, "flipV");
5676
+ if (off && ext) {
5677
+ const offX = attrNum(off, "x") ?? 0;
5678
+ const offY = attrNum(off, "y") ?? 0;
5679
+ const cx = attrNum(ext, "cx") ?? 0;
5680
+ const cy = attrNum(ext, "cy") ?? 0;
5681
+ const x1 = flipH ? offX + cx : offX;
5682
+ const y1 = flipV ? offY + cy : offY;
5683
+ const x2 = flipH ? offX : offX + cx;
5684
+ const y2 = flipV ? offY : offY + cy;
5685
+ opts.x1 = convertEmuToPixels$1(x1);
5686
+ opts.y1 = convertEmuToPixels$1(y1);
5687
+ opts.x2 = convertEmuToPixels$1(x2);
5688
+ opts.y2 = convertEmuToPixels$1(y2);
5689
+ }
5690
+ }
5691
+ const fill = parseFillFromElement(spPr);
5692
+ if (fill) opts.fill = fill;
5693
+ const outline = parseOutlineFromElement(spPr);
5694
+ if (outline) opts.outline = outline;
5695
+ }
5696
+ return opts;
5697
+ }
8534
5698
  function parsePicture(el, ctx) {
8535
5699
  const opts = {};
8536
5700
  const spPr = findChild(el, "p:spPr");
@@ -8783,6 +5947,24 @@ function parseTableFrame(el, tbl) {
8783
5947
  if (attrBool(tblPr, "firstCol")) opts.firstCol = true;
8784
5948
  if (attrBool(tblPr, "lastCol")) opts.lastCol = true;
8785
5949
  if (attrBool(tblPr, "bandCol")) opts.bandCol = true;
5950
+ const borders = {};
5951
+ for (const [elName, key] of [
5952
+ ["a:lnL", "left"],
5953
+ ["a:lnR", "right"],
5954
+ ["a:lnT", "top"],
5955
+ ["a:lnB", "bottom"]
5956
+ ]) {
5957
+ const borderEl = findChild(tblPr, elName);
5958
+ if (borderEl) {
5959
+ const borderOpts = {};
5960
+ const w = attrNum(borderEl, "w");
5961
+ if (w !== void 0) borderOpts.width = w;
5962
+ const fill = parseFillFromElement(borderEl);
5963
+ if (typeof fill === "string") borderOpts.color = fill;
5964
+ if (Object.keys(borderOpts).length > 0) borders[key] = borderOpts;
5965
+ }
5966
+ }
5967
+ if (Object.keys(borders).length > 0) opts.borders = borders;
8786
5968
  }
8787
5969
  const tblGrid = findChild(tbl, "a:tblGrid");
8788
5970
  if (tblGrid) {
@@ -9206,6 +6388,34 @@ function parseFillFromElement(parent) {
9206
6388
  };
9207
6389
  }
9208
6390
  if (findChild(parent, "a:noFill")) return { type: "none" };
6391
+ const pattFill = findChild(parent, "a:pattFill");
6392
+ if (pattFill) {
6393
+ const result = {
6394
+ type: "pattern",
6395
+ pattern: attr(pattFill, "prst") ?? ""
6396
+ };
6397
+ const fgClr = findChild(pattFill, "a:fgClr");
6398
+ if (fgClr) {
6399
+ const srgbClr = findChild(fgClr, "a:srgbClr");
6400
+ if (srgbClr) {
6401
+ const val = attr(srgbClr, "val");
6402
+ if (val) result.foregroundColor = val;
6403
+ }
6404
+ }
6405
+ const bgClr = findChild(pattFill, "a:bgClr");
6406
+ if (bgClr) {
6407
+ const srgbClr = findChild(bgClr, "a:srgbClr");
6408
+ if (srgbClr) {
6409
+ const val = attr(srgbClr, "val");
6410
+ if (val) result.backgroundColor = val;
6411
+ }
6412
+ }
6413
+ return result;
6414
+ }
6415
+ const blipFill = findChild(parent, "a:blipFill");
6416
+ if (blipFill) {
6417
+ if (findChild(blipFill, "a:blip")) return { type: "blip" };
6418
+ }
9209
6419
  const gradFill = findChild(parent, "a:gradFill");
9210
6420
  if (gradFill) {
9211
6421
  const stops = [];
@@ -9247,6 +6457,11 @@ function parseOutlineFromElement(parent) {
9247
6457
  if (val) opts.color = val;
9248
6458
  }
9249
6459
  }
6460
+ const prstDash = findChild(ln, "a:prstDash");
6461
+ if (prstDash) {
6462
+ const val = attr(prstDash, "val");
6463
+ if (val) opts.dashStyle = val;
6464
+ }
9250
6465
  return Object.keys(opts).length > 0 ? opts : void 0;
9251
6466
  }
9252
6467
  function parseEffectsFromElement(parent) {
@@ -9388,6 +6603,96 @@ function imageTypeFromPath(path) {
9388
6603
  default: return "png";
9389
6604
  }
9390
6605
  }
6606
+ const VIDEO_EXT_URI = "{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}";
6607
+ const AUDIO_EXT_URI = "{CF1602FD-DB20-4165-A070-5F299619DA56}";
6608
+ /**
6609
+ * Check if a p:pic element is actually a video or audio frame
6610
+ * by looking for media extension URIs in nvPr > extLst.
6611
+ */
6612
+ function detectMediaType(el) {
6613
+ const nvPicPr = findChild(el, "p:nvPicPr");
6614
+ if (!nvPicPr) return void 0;
6615
+ const nvPr = findChild(nvPicPr, "p:nvPr");
6616
+ if (!nvPr) return void 0;
6617
+ const extLst = findChild(nvPr, "p:extLst");
6618
+ if (!extLst) return void 0;
6619
+ for (const ext of extLst.elements ?? []) {
6620
+ if (ext.name !== "p:ext") continue;
6621
+ const uri = attr(ext, "uri");
6622
+ if (uri === VIDEO_EXT_URI) return "video";
6623
+ if (uri === AUDIO_EXT_URI) return "audio";
6624
+ }
6625
+ }
6626
+ function parseMediaFrame(el, ctx, mediaKind) {
6627
+ const opts = {};
6628
+ const spPr = findChild(el, "p:spPr");
6629
+ if (spPr) parseTransformFromSpPr(spPr, opts);
6630
+ const nvPicPr = findChild(el, "p:nvPicPr");
6631
+ if (nvPicPr) {
6632
+ const cNvPr = findChild(nvPicPr, "p:cNvPr");
6633
+ if (cNvPr) {
6634
+ const name = attr(cNvPr, "name");
6635
+ if (name) opts.name = name;
6636
+ }
6637
+ }
6638
+ const blip = findDeep(el, "a:blip")[0];
6639
+ if (blip) {
6640
+ const rEmbed = attr(blip, "r:embed");
6641
+ if (rEmbed) {
6642
+ const mediaPath = ctx.slideRels.get(rEmbed);
6643
+ if (mediaPath) {
6644
+ const data = ctx.pptx.doc.getRaw(mediaPath);
6645
+ if (data) {
6646
+ opts.data = data;
6647
+ opts.type = mediaTypeFromPath(mediaPath, mediaKind);
6648
+ }
6649
+ }
6650
+ }
6651
+ }
6652
+ if (mediaKind === "video") {
6653
+ const blipFill = findChild(el, "p:blipFill");
6654
+ if (blipFill) {
6655
+ const posterBlip = findChild(blipFill, "a:blip");
6656
+ if (posterBlip) {
6657
+ const rEmbed = attr(posterBlip, "r:embed");
6658
+ if (rEmbed) {
6659
+ const posterPath = ctx.slideRels.get(rEmbed);
6660
+ if (posterPath) {
6661
+ const posterData = ctx.pptx.doc.getRaw(posterPath);
6662
+ if (posterData) {
6663
+ opts.poster = posterData;
6664
+ opts.posterType = imageTypeFromPath(posterPath);
6665
+ }
6666
+ }
6667
+ }
6668
+ }
6669
+ }
6670
+ }
6671
+ return opts;
6672
+ }
6673
+ function mediaTypeFromPath(path, kind) {
6674
+ const ext = path.split(".").pop()?.toLowerCase() ?? "";
6675
+ if (kind === "video") switch (ext) {
6676
+ case "mp4": return "mp4";
6677
+ case "mov":
6678
+ case "qt": return "mov";
6679
+ case "wmv": return "wmv";
6680
+ case "avi": return "avi";
6681
+ default: return "mp4";
6682
+ }
6683
+ else switch (ext) {
6684
+ case "mp3": return "mp3";
6685
+ case "wav": return "wav";
6686
+ case "wma": return "wma";
6687
+ case "aac": return "aac";
6688
+ default: return "mp3";
6689
+ }
6690
+ }
6691
+ /**
6692
+ * Parse a:blipFill from a shape's spPr.
6693
+ * Used when a shape has an image fill (not a picture element).
6694
+ * Returns { type: "blip", data } if found.
6695
+ */
9391
6696
  //#endregion
9392
6697
  //#region src/parse/slide-layout.ts
9393
6698
  const NAME_TO_TYPE = {
@@ -9540,7 +6845,7 @@ function parseSlideRels(doc, slidePaths, refs) {
9540
6845
  }
9541
6846
  }
9542
6847
  function parsePptx(data) {
9543
- const doc = parseArchive(data);
6848
+ const doc = parseArchive(toUint8Array(data));
9544
6849
  const presentation = doc.get("ppt/presentation.xml");
9545
6850
  const relsXml = doc.get("ppt/_rels/presentation.xml.rels");
9546
6851
  const slides = [];
@@ -9629,7 +6934,7 @@ function resolveRelTargets(doc, paths, predicate) {
9629
6934
  return map;
9630
6935
  }
9631
6936
  /**
9632
- * Parse a .pptx file and convert it into IPresentationOptions.
6937
+ * Parse a .pptx file and convert it into PresentationOptions.
9633
6938
  *
9634
6939
  * This is the main public API for parsing PPTX files.
9635
6940
  * The returned options can be passed directly to `new Presentation(parsed)`
@@ -9714,12 +7019,27 @@ function parsePresentation(data) {
9714
7019
  masterDefs.push(masterDef);
9715
7020
  }
9716
7021
  if (masterCount > 1) opts.masters = masterDefs;
7022
+ const commentAuthors = /* @__PURE__ */ new Map();
7023
+ if (pptx.partRefs.commentAuthors) {
7024
+ const authorsEl = pptx.doc.get(pptx.partRefs.commentAuthors);
7025
+ if (authorsEl) for (const child of authorsEl.elements ?? []) {
7026
+ if (child.name !== "p:cmAuthor") continue;
7027
+ const id = attrNum(child, "id");
7028
+ const name = attr(child, "name");
7029
+ const initials = attr(child, "initials");
7030
+ if (id !== void 0) commentAuthors.set(id, {
7031
+ name: name ?? "",
7032
+ initials: initials ?? ""
7033
+ });
7034
+ }
7035
+ }
9717
7036
  const result = [];
9718
7037
  for (let si = 0; si < pptx.slides.length; si++) {
9719
7038
  const slidePath = pptx.slides[si];
9720
7039
  const slideEl = pptx.doc.get(slidePath);
9721
7040
  if (!slideEl) continue;
9722
- const slideOpts = parseSlide(slideEl, new ParseContext(pptx, parseSlideRelMap(pptx.doc, slidePath)));
7041
+ const slideRels = parseSlideRelMap(pptx.doc, slidePath);
7042
+ const slideOpts = parseSlide(slideEl, new ParseContext(pptx, slideRels));
9723
7043
  const layoutPath = slideLayoutPaths.get(slidePath);
9724
7044
  if (layoutPath) {
9725
7045
  const layoutEl = pptx.doc.get(layoutPath);
@@ -9730,11 +7050,57 @@ function parsePresentation(data) {
9730
7050
  if (masterIdx >= 0 && masterDefs[masterIdx]) slideOpts.master = masterDefs[masterIdx].name;
9731
7051
  }
9732
7052
  }
7053
+ for (const [, relPath] of slideRels) {
7054
+ if (!relPath.includes("/comments/")) continue;
7055
+ const commentsEl = pptx.doc.get(relPath);
7056
+ if (!commentsEl) continue;
7057
+ const comments = [];
7058
+ for (const cm of commentsEl.elements ?? []) {
7059
+ if (cm.name !== "p:cm") continue;
7060
+ const authorId = attrNum(cm, "authorId");
7061
+ const dt = attr(cm, "dt");
7062
+ const idx = attrNum(cm, "idx");
7063
+ const author = authorId !== void 0 ? commentAuthors.get(authorId) : void 0;
7064
+ const pos = findChild(cm, "p:pos");
7065
+ const x = pos ? attrNum(pos, "x") : void 0;
7066
+ const y = pos ? attrNum(pos, "y") : void 0;
7067
+ const txBody = findChild(cm, "p:txBody");
7068
+ const text = txBody ? extractCommentText(txBody) : "";
7069
+ const commentEntry = {};
7070
+ if (authorId !== void 0) commentEntry.authorId = authorId;
7071
+ if (author) commentEntry.author = author.name;
7072
+ if (idx !== void 0) commentEntry.idx = idx;
7073
+ if (dt) commentEntry.date = dt;
7074
+ if (x !== void 0) commentEntry.x = x;
7075
+ if (y !== void 0) commentEntry.y = y;
7076
+ if (text) commentEntry.text = text;
7077
+ comments.push(commentEntry);
7078
+ }
7079
+ if (comments.length > 0) slideOpts.comments = comments;
7080
+ break;
7081
+ }
9733
7082
  result.push(slideOpts);
9734
7083
  }
9735
7084
  opts.slides = result;
9736
7085
  return opts;
9737
7086
  }
7087
+ /**
7088
+ * Extract plain text from a p:txBody in a comment element.
7089
+ */
7090
+ function extractCommentText(txBody) {
7091
+ const parts = [];
7092
+ for (const p of txBody.elements ?? []) {
7093
+ if (p.name !== "a:p") continue;
7094
+ for (const r of p.elements ?? []) {
7095
+ if (r.name !== "a:r") continue;
7096
+ for (const t of r.elements ?? []) if (t.name === "a:t") {
7097
+ const text = textOf(t);
7098
+ if (text) parts.push(text);
7099
+ }
7100
+ }
7101
+ }
7102
+ return parts.join("");
7103
+ }
9738
7104
  __reExport(/* @__PURE__ */ __exportAll({
9739
7105
  AppProperties: () => AppProperties,
9740
7106
  AudioFrame: () => AudioFrame,