@office-open/docx 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -8
- package/dist/index.d.mts +13 -40
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +49 -1482
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __reExport, t as __exportAll } from "./_chunks/chunk-DmsbSTSH.mjs";
|
|
2
|
-
import { AppProperties, BaseXmlComponent, BuilderElement, BuilderElement as BuilderElement$1, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, NextAttributeComponent, NumberValueElement, OnOffElement, RawPassthrough, Relationships, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, XmlAttributeComponent, XmlAttributeComponent as XmlAttributeComponent$1, XmlComponent, chartAttr, convertInchesToTwip, convertMillimetersToTwip, convertPixelsToEmu, convertToXmlComponent, getImageType, hasPlaceholders, hashedId, hpsMeasureObj, isRaw, numberValObj, onOffObj, parseCoreProperties, parseRels, readAllXmlParts, readXmlFromZip, stringEnumValObj, stringValObj, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueNumericIdCreator as uniqueNumericIdCreator$1, uniqueUuid, unzipToMap, wrapEl } from "@office-open/core";
|
|
2
|
+
import { AppProperties, BaseXmlComponent, BuilderElement, BuilderElement as BuilderElement$1, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, NextAttributeComponent, NumberValueElement, OnOffElement, PrettifyType, RawPassthrough, Relationships, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, XmlAttributeComponent, XmlAttributeComponent as XmlAttributeComponent$1, XmlComponent, addSmartArtRelationships, chartAttr, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPrettifyType, convertToXmlComponent, getImageType, getReferencedMedia, hasPlaceholders, hashedId, hpsMeasureObj, isRaw, numberValObj, onOffObj, parseCoreProperties, parseRels, readAllXmlParts, readXmlFromZip, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, stringEnumValObj, stringValObj, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueNumericIdCreator as uniqueNumericIdCreator$1, uniqueUuid, unzipToMap, wrapEl } from "@office-open/core";
|
|
3
3
|
import { textToUint8Array, toUint8Array } from "undio";
|
|
4
4
|
import { PresetGeometry, buildFill, createBlipFill, createCustomGeometry, createEffectDag, createEffectList, createOutline, createScene3D, createShape3D, extractBlipFillMedia } from "@office-open/core/drawingml";
|
|
5
5
|
import { ChartCollection, ChartTitle, createChartType } from "@office-open/core/chart";
|
|
@@ -21159,1281 +21159,6 @@ var file_exports = /* @__PURE__ */ __exportAll({
|
|
|
21159
21159
|
});
|
|
21160
21160
|
__reExport(file_exports, smartart_exports);
|
|
21161
21161
|
//#endregion
|
|
21162
|
-
//#region \0polyfill-node.global.js
|
|
21163
|
-
var _polyfill_node_global_default = typeof _polyfill_node_global_default !== "undefined" ? _polyfill_node_global_default : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
21164
|
-
//#endregion
|
|
21165
|
-
//#region \0polyfill-node.buffer.js
|
|
21166
|
-
var lookup = [];
|
|
21167
|
-
var revLookup = [];
|
|
21168
|
-
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
21169
|
-
var inited = false;
|
|
21170
|
-
function init() {
|
|
21171
|
-
inited = true;
|
|
21172
|
-
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
21173
|
-
for (var i = 0, len = code.length; i < len; ++i) {
|
|
21174
|
-
lookup[i] = code[i];
|
|
21175
|
-
revLookup[code.charCodeAt(i)] = i;
|
|
21176
|
-
}
|
|
21177
|
-
revLookup["-".charCodeAt(0)] = 62;
|
|
21178
|
-
revLookup["_".charCodeAt(0)] = 63;
|
|
21179
|
-
}
|
|
21180
|
-
function toByteArray(b64) {
|
|
21181
|
-
if (!inited) init();
|
|
21182
|
-
var i, j, l, tmp, placeHolders, arr;
|
|
21183
|
-
var len = b64.length;
|
|
21184
|
-
if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
|
|
21185
|
-
placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
|
|
21186
|
-
arr = new Arr(len * 3 / 4 - placeHolders);
|
|
21187
|
-
l = placeHolders > 0 ? len - 4 : len;
|
|
21188
|
-
var L = 0;
|
|
21189
|
-
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
|
21190
|
-
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
|
|
21191
|
-
arr[L++] = tmp >> 16 & 255;
|
|
21192
|
-
arr[L++] = tmp >> 8 & 255;
|
|
21193
|
-
arr[L++] = tmp & 255;
|
|
21194
|
-
}
|
|
21195
|
-
if (placeHolders === 2) {
|
|
21196
|
-
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
|
|
21197
|
-
arr[L++] = tmp & 255;
|
|
21198
|
-
} else if (placeHolders === 1) {
|
|
21199
|
-
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
|
|
21200
|
-
arr[L++] = tmp >> 8 & 255;
|
|
21201
|
-
arr[L++] = tmp & 255;
|
|
21202
|
-
}
|
|
21203
|
-
return arr;
|
|
21204
|
-
}
|
|
21205
|
-
function tripletToBase64(num) {
|
|
21206
|
-
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
21207
|
-
}
|
|
21208
|
-
function encodeChunk(uint8, start, end) {
|
|
21209
|
-
var tmp;
|
|
21210
|
-
var output = [];
|
|
21211
|
-
for (var i = start; i < end; i += 3) {
|
|
21212
|
-
tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
|
|
21213
|
-
output.push(tripletToBase64(tmp));
|
|
21214
|
-
}
|
|
21215
|
-
return output.join("");
|
|
21216
|
-
}
|
|
21217
|
-
function fromByteArray(uint8) {
|
|
21218
|
-
if (!inited) init();
|
|
21219
|
-
var tmp;
|
|
21220
|
-
var len = uint8.length;
|
|
21221
|
-
var extraBytes = len % 3;
|
|
21222
|
-
var output = "";
|
|
21223
|
-
var parts = [];
|
|
21224
|
-
var maxChunkLength = 16383;
|
|
21225
|
-
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
|
|
21226
|
-
if (extraBytes === 1) {
|
|
21227
|
-
tmp = uint8[len - 1];
|
|
21228
|
-
output += lookup[tmp >> 2];
|
|
21229
|
-
output += lookup[tmp << 4 & 63];
|
|
21230
|
-
output += "==";
|
|
21231
|
-
} else if (extraBytes === 2) {
|
|
21232
|
-
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
21233
|
-
output += lookup[tmp >> 10];
|
|
21234
|
-
output += lookup[tmp >> 4 & 63];
|
|
21235
|
-
output += lookup[tmp << 2 & 63];
|
|
21236
|
-
output += "=";
|
|
21237
|
-
}
|
|
21238
|
-
parts.push(output);
|
|
21239
|
-
return parts.join("");
|
|
21240
|
-
}
|
|
21241
|
-
function read(buffer, offset, isLE, mLen, nBytes) {
|
|
21242
|
-
var e, m;
|
|
21243
|
-
var eLen = nBytes * 8 - mLen - 1;
|
|
21244
|
-
var eMax = (1 << eLen) - 1;
|
|
21245
|
-
var eBias = eMax >> 1;
|
|
21246
|
-
var nBits = -7;
|
|
21247
|
-
var i = isLE ? nBytes - 1 : 0;
|
|
21248
|
-
var d = isLE ? -1 : 1;
|
|
21249
|
-
var s = buffer[offset + i];
|
|
21250
|
-
i += d;
|
|
21251
|
-
e = s & (1 << -nBits) - 1;
|
|
21252
|
-
s >>= -nBits;
|
|
21253
|
-
nBits += eLen;
|
|
21254
|
-
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
|
|
21255
|
-
m = e & (1 << -nBits) - 1;
|
|
21256
|
-
e >>= -nBits;
|
|
21257
|
-
nBits += mLen;
|
|
21258
|
-
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
|
|
21259
|
-
if (e === 0) e = 1 - eBias;
|
|
21260
|
-
else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
21261
|
-
else {
|
|
21262
|
-
m = m + Math.pow(2, mLen);
|
|
21263
|
-
e = e - eBias;
|
|
21264
|
-
}
|
|
21265
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
21266
|
-
}
|
|
21267
|
-
function write(buffer, value, offset, isLE, mLen, nBytes) {
|
|
21268
|
-
var e, m, c;
|
|
21269
|
-
var eLen = nBytes * 8 - mLen - 1;
|
|
21270
|
-
var eMax = (1 << eLen) - 1;
|
|
21271
|
-
var eBias = eMax >> 1;
|
|
21272
|
-
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
21273
|
-
var i = isLE ? 0 : nBytes - 1;
|
|
21274
|
-
var d = isLE ? 1 : -1;
|
|
21275
|
-
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
21276
|
-
value = Math.abs(value);
|
|
21277
|
-
if (isNaN(value) || value === Infinity) {
|
|
21278
|
-
m = isNaN(value) ? 1 : 0;
|
|
21279
|
-
e = eMax;
|
|
21280
|
-
} else {
|
|
21281
|
-
e = Math.floor(Math.log(value) / Math.LN2);
|
|
21282
|
-
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
21283
|
-
e--;
|
|
21284
|
-
c *= 2;
|
|
21285
|
-
}
|
|
21286
|
-
if (e + eBias >= 1) value += rt / c;
|
|
21287
|
-
else value += rt * Math.pow(2, 1 - eBias);
|
|
21288
|
-
if (value * c >= 2) {
|
|
21289
|
-
e++;
|
|
21290
|
-
c /= 2;
|
|
21291
|
-
}
|
|
21292
|
-
if (e + eBias >= eMax) {
|
|
21293
|
-
m = 0;
|
|
21294
|
-
e = eMax;
|
|
21295
|
-
} else if (e + eBias >= 1) {
|
|
21296
|
-
m = (value * c - 1) * Math.pow(2, mLen);
|
|
21297
|
-
e = e + eBias;
|
|
21298
|
-
} else {
|
|
21299
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
21300
|
-
e = 0;
|
|
21301
|
-
}
|
|
21302
|
-
}
|
|
21303
|
-
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8);
|
|
21304
|
-
e = e << mLen | m;
|
|
21305
|
-
eLen += mLen;
|
|
21306
|
-
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8);
|
|
21307
|
-
buffer[offset + i - d] |= s * 128;
|
|
21308
|
-
}
|
|
21309
|
-
var toString = {}.toString;
|
|
21310
|
-
var isArray = Array.isArray || function(arr) {
|
|
21311
|
-
return toString.call(arr) == "[object Array]";
|
|
21312
|
-
};
|
|
21313
|
-
/**
|
|
21314
|
-
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
21315
|
-
* === true Use Uint8Array implementation (fastest)
|
|
21316
|
-
* === false Use Object implementation (most compatible, even IE6)
|
|
21317
|
-
*
|
|
21318
|
-
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
21319
|
-
* Opera 11.6+, iOS 4.2+.
|
|
21320
|
-
*
|
|
21321
|
-
* Due to various browser bugs, sometimes the Object implementation will be used even
|
|
21322
|
-
* when the browser supports typed arrays.
|
|
21323
|
-
*
|
|
21324
|
-
* Note:
|
|
21325
|
-
*
|
|
21326
|
-
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
|
21327
|
-
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
|
21328
|
-
*
|
|
21329
|
-
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
|
21330
|
-
*
|
|
21331
|
-
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
|
21332
|
-
* incorrect length in some situations.
|
|
21333
|
-
|
|
21334
|
-
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
|
21335
|
-
* get the Object implementation, which is slower but behaves correctly.
|
|
21336
|
-
*/
|
|
21337
|
-
Buffer.TYPED_ARRAY_SUPPORT = _polyfill_node_global_default.TYPED_ARRAY_SUPPORT !== void 0 ? _polyfill_node_global_default.TYPED_ARRAY_SUPPORT : true;
|
|
21338
|
-
kMaxLength();
|
|
21339
|
-
function kMaxLength() {
|
|
21340
|
-
return Buffer.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
|
|
21341
|
-
}
|
|
21342
|
-
function createBuffer(that, length) {
|
|
21343
|
-
if (kMaxLength() < length) throw new RangeError("Invalid typed array length");
|
|
21344
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
21345
|
-
that = new Uint8Array(length);
|
|
21346
|
-
that.__proto__ = Buffer.prototype;
|
|
21347
|
-
} else {
|
|
21348
|
-
if (that === null) that = new Buffer(length);
|
|
21349
|
-
that.length = length;
|
|
21350
|
-
}
|
|
21351
|
-
return that;
|
|
21352
|
-
}
|
|
21353
|
-
/**
|
|
21354
|
-
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
21355
|
-
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
21356
|
-
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
21357
|
-
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
21358
|
-
* returns a single octet.
|
|
21359
|
-
*
|
|
21360
|
-
* The `Uint8Array` prototype remains unmodified.
|
|
21361
|
-
*/
|
|
21362
|
-
function Buffer(arg, encodingOrOffset, length) {
|
|
21363
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) return new Buffer(arg, encodingOrOffset, length);
|
|
21364
|
-
if (typeof arg === "number") {
|
|
21365
|
-
if (typeof encodingOrOffset === "string") throw new Error("If encoding is specified then the first argument must be a string");
|
|
21366
|
-
return allocUnsafe(this, arg);
|
|
21367
|
-
}
|
|
21368
|
-
return from(this, arg, encodingOrOffset, length);
|
|
21369
|
-
}
|
|
21370
|
-
Buffer.poolSize = 8192;
|
|
21371
|
-
Buffer._augment = function(arr) {
|
|
21372
|
-
arr.__proto__ = Buffer.prototype;
|
|
21373
|
-
return arr;
|
|
21374
|
-
};
|
|
21375
|
-
function from(that, value, encodingOrOffset, length) {
|
|
21376
|
-
if (typeof value === "number") throw new TypeError("\"value\" argument must not be a number");
|
|
21377
|
-
if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) return fromArrayBuffer(that, value, encodingOrOffset, length);
|
|
21378
|
-
if (typeof value === "string") return fromString(that, value, encodingOrOffset);
|
|
21379
|
-
return fromObject(that, value);
|
|
21380
|
-
}
|
|
21381
|
-
/**
|
|
21382
|
-
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
21383
|
-
* if value is a number.
|
|
21384
|
-
* Buffer.from(str[, encoding])
|
|
21385
|
-
* Buffer.from(array)
|
|
21386
|
-
* Buffer.from(buffer)
|
|
21387
|
-
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
21388
|
-
**/
|
|
21389
|
-
Buffer.from = function(value, encodingOrOffset, length) {
|
|
21390
|
-
return from(null, value, encodingOrOffset, length);
|
|
21391
|
-
};
|
|
21392
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
21393
|
-
Buffer.prototype.__proto__ = Uint8Array.prototype;
|
|
21394
|
-
Buffer.__proto__ = Uint8Array;
|
|
21395
|
-
if (typeof Symbol !== "undefined" && Symbol.species && Buffer[Symbol.species] === Buffer);
|
|
21396
|
-
}
|
|
21397
|
-
function assertSize(size) {
|
|
21398
|
-
if (typeof size !== "number") throw new TypeError("\"size\" argument must be a number");
|
|
21399
|
-
else if (size < 0) throw new RangeError("\"size\" argument must not be negative");
|
|
21400
|
-
}
|
|
21401
|
-
function alloc(that, size, fill, encoding) {
|
|
21402
|
-
assertSize(size);
|
|
21403
|
-
if (size <= 0) return createBuffer(that, size);
|
|
21404
|
-
if (fill !== void 0) return typeof encoding === "string" ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
|
|
21405
|
-
return createBuffer(that, size);
|
|
21406
|
-
}
|
|
21407
|
-
/**
|
|
21408
|
-
* Creates a new filled Buffer instance.
|
|
21409
|
-
* alloc(size[, fill[, encoding]])
|
|
21410
|
-
**/
|
|
21411
|
-
Buffer.alloc = function(size, fill, encoding) {
|
|
21412
|
-
return alloc(null, size, fill, encoding);
|
|
21413
|
-
};
|
|
21414
|
-
function allocUnsafe(that, size) {
|
|
21415
|
-
assertSize(size);
|
|
21416
|
-
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
|
|
21417
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT) for (var i = 0; i < size; ++i) that[i] = 0;
|
|
21418
|
-
return that;
|
|
21419
|
-
}
|
|
21420
|
-
/**
|
|
21421
|
-
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
21422
|
-
* */
|
|
21423
|
-
Buffer.allocUnsafe = function(size) {
|
|
21424
|
-
return allocUnsafe(null, size);
|
|
21425
|
-
};
|
|
21426
|
-
/**
|
|
21427
|
-
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
21428
|
-
*/
|
|
21429
|
-
Buffer.allocUnsafeSlow = function(size) {
|
|
21430
|
-
return allocUnsafe(null, size);
|
|
21431
|
-
};
|
|
21432
|
-
function fromString(that, string, encoding) {
|
|
21433
|
-
if (typeof encoding !== "string" || encoding === "") encoding = "utf8";
|
|
21434
|
-
if (!Buffer.isEncoding(encoding)) throw new TypeError("\"encoding\" must be a valid string encoding");
|
|
21435
|
-
var length = byteLength(string, encoding) | 0;
|
|
21436
|
-
that = createBuffer(that, length);
|
|
21437
|
-
var actual = that.write(string, encoding);
|
|
21438
|
-
if (actual !== length) that = that.slice(0, actual);
|
|
21439
|
-
return that;
|
|
21440
|
-
}
|
|
21441
|
-
function fromArrayLike(that, array) {
|
|
21442
|
-
var length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
21443
|
-
that = createBuffer(that, length);
|
|
21444
|
-
for (var i = 0; i < length; i += 1) that[i] = array[i] & 255;
|
|
21445
|
-
return that;
|
|
21446
|
-
}
|
|
21447
|
-
function fromArrayBuffer(that, array, byteOffset, length) {
|
|
21448
|
-
array.byteLength;
|
|
21449
|
-
if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError("'offset' is out of bounds");
|
|
21450
|
-
if (array.byteLength < byteOffset + (length || 0)) throw new RangeError("'length' is out of bounds");
|
|
21451
|
-
if (byteOffset === void 0 && length === void 0) array = new Uint8Array(array);
|
|
21452
|
-
else if (length === void 0) array = new Uint8Array(array, byteOffset);
|
|
21453
|
-
else array = new Uint8Array(array, byteOffset, length);
|
|
21454
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
21455
|
-
that = array;
|
|
21456
|
-
that.__proto__ = Buffer.prototype;
|
|
21457
|
-
} else that = fromArrayLike(that, array);
|
|
21458
|
-
return that;
|
|
21459
|
-
}
|
|
21460
|
-
function fromObject(that, obj) {
|
|
21461
|
-
if (internalIsBuffer(obj)) {
|
|
21462
|
-
var len = checked(obj.length) | 0;
|
|
21463
|
-
that = createBuffer(that, len);
|
|
21464
|
-
if (that.length === 0) return that;
|
|
21465
|
-
obj.copy(that, 0, 0, len);
|
|
21466
|
-
return that;
|
|
21467
|
-
}
|
|
21468
|
-
if (obj) {
|
|
21469
|
-
if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
|
|
21470
|
-
if (typeof obj.length !== "number" || isnan(obj.length)) return createBuffer(that, 0);
|
|
21471
|
-
return fromArrayLike(that, obj);
|
|
21472
|
-
}
|
|
21473
|
-
if (obj.type === "Buffer" && isArray(obj.data)) return fromArrayLike(that, obj.data);
|
|
21474
|
-
}
|
|
21475
|
-
throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
|
|
21476
|
-
}
|
|
21477
|
-
function checked(length) {
|
|
21478
|
-
if (length >= kMaxLength()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
|
|
21479
|
-
return length | 0;
|
|
21480
|
-
}
|
|
21481
|
-
Buffer.isBuffer = isBuffer;
|
|
21482
|
-
function internalIsBuffer(b) {
|
|
21483
|
-
return !!(b != null && b._isBuffer);
|
|
21484
|
-
}
|
|
21485
|
-
Buffer.compare = function compare(a, b) {
|
|
21486
|
-
if (!internalIsBuffer(a) || !internalIsBuffer(b)) throw new TypeError("Arguments must be Buffers");
|
|
21487
|
-
if (a === b) return 0;
|
|
21488
|
-
var x = a.length;
|
|
21489
|
-
var y = b.length;
|
|
21490
|
-
for (var i = 0, len = Math.min(x, y); i < len; ++i) if (a[i] !== b[i]) {
|
|
21491
|
-
x = a[i];
|
|
21492
|
-
y = b[i];
|
|
21493
|
-
break;
|
|
21494
|
-
}
|
|
21495
|
-
if (x < y) return -1;
|
|
21496
|
-
if (y < x) return 1;
|
|
21497
|
-
return 0;
|
|
21498
|
-
};
|
|
21499
|
-
Buffer.isEncoding = function isEncoding(encoding) {
|
|
21500
|
-
switch (String(encoding).toLowerCase()) {
|
|
21501
|
-
case "hex":
|
|
21502
|
-
case "utf8":
|
|
21503
|
-
case "utf-8":
|
|
21504
|
-
case "ascii":
|
|
21505
|
-
case "latin1":
|
|
21506
|
-
case "binary":
|
|
21507
|
-
case "base64":
|
|
21508
|
-
case "ucs2":
|
|
21509
|
-
case "ucs-2":
|
|
21510
|
-
case "utf16le":
|
|
21511
|
-
case "utf-16le": return true;
|
|
21512
|
-
default: return false;
|
|
21513
|
-
}
|
|
21514
|
-
};
|
|
21515
|
-
Buffer.concat = function concat(list, length) {
|
|
21516
|
-
if (!isArray(list)) throw new TypeError("\"list\" argument must be an Array of Buffers");
|
|
21517
|
-
if (list.length === 0) return Buffer.alloc(0);
|
|
21518
|
-
var i;
|
|
21519
|
-
if (length === void 0) {
|
|
21520
|
-
length = 0;
|
|
21521
|
-
for (i = 0; i < list.length; ++i) length += list[i].length;
|
|
21522
|
-
}
|
|
21523
|
-
var buffer = Buffer.allocUnsafe(length);
|
|
21524
|
-
var pos = 0;
|
|
21525
|
-
for (i = 0; i < list.length; ++i) {
|
|
21526
|
-
var buf = list[i];
|
|
21527
|
-
if (!internalIsBuffer(buf)) throw new TypeError("\"list\" argument must be an Array of Buffers");
|
|
21528
|
-
buf.copy(buffer, pos);
|
|
21529
|
-
pos += buf.length;
|
|
21530
|
-
}
|
|
21531
|
-
return buffer;
|
|
21532
|
-
};
|
|
21533
|
-
function byteLength(string, encoding) {
|
|
21534
|
-
if (internalIsBuffer(string)) return string.length;
|
|
21535
|
-
if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) return string.byteLength;
|
|
21536
|
-
if (typeof string !== "string") string = "" + string;
|
|
21537
|
-
var len = string.length;
|
|
21538
|
-
if (len === 0) return 0;
|
|
21539
|
-
var loweredCase = false;
|
|
21540
|
-
for (;;) switch (encoding) {
|
|
21541
|
-
case "ascii":
|
|
21542
|
-
case "latin1":
|
|
21543
|
-
case "binary": return len;
|
|
21544
|
-
case "utf8":
|
|
21545
|
-
case "utf-8":
|
|
21546
|
-
case void 0: return utf8ToBytes(string).length;
|
|
21547
|
-
case "ucs2":
|
|
21548
|
-
case "ucs-2":
|
|
21549
|
-
case "utf16le":
|
|
21550
|
-
case "utf-16le": return len * 2;
|
|
21551
|
-
case "hex": return len >>> 1;
|
|
21552
|
-
case "base64": return base64ToBytes(string).length;
|
|
21553
|
-
default:
|
|
21554
|
-
if (loweredCase) return utf8ToBytes(string).length;
|
|
21555
|
-
encoding = ("" + encoding).toLowerCase();
|
|
21556
|
-
loweredCase = true;
|
|
21557
|
-
}
|
|
21558
|
-
}
|
|
21559
|
-
Buffer.byteLength = byteLength;
|
|
21560
|
-
function slowToString(encoding, start, end) {
|
|
21561
|
-
var loweredCase = false;
|
|
21562
|
-
if (start === void 0 || start < 0) start = 0;
|
|
21563
|
-
if (start > this.length) return "";
|
|
21564
|
-
if (end === void 0 || end > this.length) end = this.length;
|
|
21565
|
-
if (end <= 0) return "";
|
|
21566
|
-
end >>>= 0;
|
|
21567
|
-
start >>>= 0;
|
|
21568
|
-
if (end <= start) return "";
|
|
21569
|
-
if (!encoding) encoding = "utf8";
|
|
21570
|
-
while (true) switch (encoding) {
|
|
21571
|
-
case "hex": return hexSlice(this, start, end);
|
|
21572
|
-
case "utf8":
|
|
21573
|
-
case "utf-8": return utf8Slice(this, start, end);
|
|
21574
|
-
case "ascii": return asciiSlice(this, start, end);
|
|
21575
|
-
case "latin1":
|
|
21576
|
-
case "binary": return latin1Slice(this, start, end);
|
|
21577
|
-
case "base64": return base64Slice(this, start, end);
|
|
21578
|
-
case "ucs2":
|
|
21579
|
-
case "ucs-2":
|
|
21580
|
-
case "utf16le":
|
|
21581
|
-
case "utf-16le": return utf16leSlice(this, start, end);
|
|
21582
|
-
default:
|
|
21583
|
-
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
21584
|
-
encoding = (encoding + "").toLowerCase();
|
|
21585
|
-
loweredCase = true;
|
|
21586
|
-
}
|
|
21587
|
-
}
|
|
21588
|
-
Buffer.prototype._isBuffer = true;
|
|
21589
|
-
function swap(b, n, m) {
|
|
21590
|
-
var i = b[n];
|
|
21591
|
-
b[n] = b[m];
|
|
21592
|
-
b[m] = i;
|
|
21593
|
-
}
|
|
21594
|
-
Buffer.prototype.swap16 = function swap16() {
|
|
21595
|
-
var len = this.length;
|
|
21596
|
-
if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
21597
|
-
for (var i = 0; i < len; i += 2) swap(this, i, i + 1);
|
|
21598
|
-
return this;
|
|
21599
|
-
};
|
|
21600
|
-
Buffer.prototype.swap32 = function swap32() {
|
|
21601
|
-
var len = this.length;
|
|
21602
|
-
if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
21603
|
-
for (var i = 0; i < len; i += 4) {
|
|
21604
|
-
swap(this, i, i + 3);
|
|
21605
|
-
swap(this, i + 1, i + 2);
|
|
21606
|
-
}
|
|
21607
|
-
return this;
|
|
21608
|
-
};
|
|
21609
|
-
Buffer.prototype.swap64 = function swap64() {
|
|
21610
|
-
var len = this.length;
|
|
21611
|
-
if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
21612
|
-
for (var i = 0; i < len; i += 8) {
|
|
21613
|
-
swap(this, i, i + 7);
|
|
21614
|
-
swap(this, i + 1, i + 6);
|
|
21615
|
-
swap(this, i + 2, i + 5);
|
|
21616
|
-
swap(this, i + 3, i + 4);
|
|
21617
|
-
}
|
|
21618
|
-
return this;
|
|
21619
|
-
};
|
|
21620
|
-
Buffer.prototype.toString = function toString() {
|
|
21621
|
-
var length = this.length | 0;
|
|
21622
|
-
if (length === 0) return "";
|
|
21623
|
-
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
21624
|
-
return slowToString.apply(this, arguments);
|
|
21625
|
-
};
|
|
21626
|
-
Buffer.prototype.equals = function equals(b) {
|
|
21627
|
-
if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
21628
|
-
if (this === b) return true;
|
|
21629
|
-
return Buffer.compare(this, b) === 0;
|
|
21630
|
-
};
|
|
21631
|
-
Buffer.prototype.inspect = function inspect() {
|
|
21632
|
-
var str = "";
|
|
21633
|
-
var max = 50;
|
|
21634
|
-
if (this.length > 0) {
|
|
21635
|
-
str = this.toString("hex", 0, max).match(/.{2}/g).join(" ");
|
|
21636
|
-
if (this.length > max) str += " ... ";
|
|
21637
|
-
}
|
|
21638
|
-
return "<Buffer " + str + ">";
|
|
21639
|
-
};
|
|
21640
|
-
Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
21641
|
-
if (!internalIsBuffer(target)) throw new TypeError("Argument must be a Buffer");
|
|
21642
|
-
if (start === void 0) start = 0;
|
|
21643
|
-
if (end === void 0) end = target ? target.length : 0;
|
|
21644
|
-
if (thisStart === void 0) thisStart = 0;
|
|
21645
|
-
if (thisEnd === void 0) thisEnd = this.length;
|
|
21646
|
-
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError("out of range index");
|
|
21647
|
-
if (thisStart >= thisEnd && start >= end) return 0;
|
|
21648
|
-
if (thisStart >= thisEnd) return -1;
|
|
21649
|
-
if (start >= end) return 1;
|
|
21650
|
-
start >>>= 0;
|
|
21651
|
-
end >>>= 0;
|
|
21652
|
-
thisStart >>>= 0;
|
|
21653
|
-
thisEnd >>>= 0;
|
|
21654
|
-
if (this === target) return 0;
|
|
21655
|
-
var x = thisEnd - thisStart;
|
|
21656
|
-
var y = end - start;
|
|
21657
|
-
var len = Math.min(x, y);
|
|
21658
|
-
var thisCopy = this.slice(thisStart, thisEnd);
|
|
21659
|
-
var targetCopy = target.slice(start, end);
|
|
21660
|
-
for (var i = 0; i < len; ++i) if (thisCopy[i] !== targetCopy[i]) {
|
|
21661
|
-
x = thisCopy[i];
|
|
21662
|
-
y = targetCopy[i];
|
|
21663
|
-
break;
|
|
21664
|
-
}
|
|
21665
|
-
if (x < y) return -1;
|
|
21666
|
-
if (y < x) return 1;
|
|
21667
|
-
return 0;
|
|
21668
|
-
};
|
|
21669
|
-
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
21670
|
-
if (buffer.length === 0) return -1;
|
|
21671
|
-
if (typeof byteOffset === "string") {
|
|
21672
|
-
encoding = byteOffset;
|
|
21673
|
-
byteOffset = 0;
|
|
21674
|
-
} else if (byteOffset > 2147483647) byteOffset = 2147483647;
|
|
21675
|
-
else if (byteOffset < -2147483648) byteOffset = -2147483648;
|
|
21676
|
-
byteOffset = +byteOffset;
|
|
21677
|
-
if (isNaN(byteOffset)) byteOffset = dir ? 0 : buffer.length - 1;
|
|
21678
|
-
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
21679
|
-
if (byteOffset >= buffer.length) if (dir) return -1;
|
|
21680
|
-
else byteOffset = buffer.length - 1;
|
|
21681
|
-
else if (byteOffset < 0) if (dir) byteOffset = 0;
|
|
21682
|
-
else return -1;
|
|
21683
|
-
if (typeof val === "string") val = Buffer.from(val, encoding);
|
|
21684
|
-
if (internalIsBuffer(val)) {
|
|
21685
|
-
if (val.length === 0) return -1;
|
|
21686
|
-
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
21687
|
-
} else if (typeof val === "number") {
|
|
21688
|
-
val = val & 255;
|
|
21689
|
-
if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
21690
|
-
else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
21691
|
-
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
21692
|
-
}
|
|
21693
|
-
throw new TypeError("val must be string, number or Buffer");
|
|
21694
|
-
}
|
|
21695
|
-
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
21696
|
-
var indexSize = 1;
|
|
21697
|
-
var arrLength = arr.length;
|
|
21698
|
-
var valLength = val.length;
|
|
21699
|
-
if (encoding !== void 0) {
|
|
21700
|
-
encoding = String(encoding).toLowerCase();
|
|
21701
|
-
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
21702
|
-
if (arr.length < 2 || val.length < 2) return -1;
|
|
21703
|
-
indexSize = 2;
|
|
21704
|
-
arrLength /= 2;
|
|
21705
|
-
valLength /= 2;
|
|
21706
|
-
byteOffset /= 2;
|
|
21707
|
-
}
|
|
21708
|
-
}
|
|
21709
|
-
function read(buf, i) {
|
|
21710
|
-
if (indexSize === 1) return buf[i];
|
|
21711
|
-
else return buf.readUInt16BE(i * indexSize);
|
|
21712
|
-
}
|
|
21713
|
-
var i;
|
|
21714
|
-
if (dir) {
|
|
21715
|
-
var foundIndex = -1;
|
|
21716
|
-
for (i = byteOffset; i < arrLength; i++) if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
21717
|
-
if (foundIndex === -1) foundIndex = i;
|
|
21718
|
-
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
|
21719
|
-
} else {
|
|
21720
|
-
if (foundIndex !== -1) i -= i - foundIndex;
|
|
21721
|
-
foundIndex = -1;
|
|
21722
|
-
}
|
|
21723
|
-
} else {
|
|
21724
|
-
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
21725
|
-
for (i = byteOffset; i >= 0; i--) {
|
|
21726
|
-
var found = true;
|
|
21727
|
-
for (var j = 0; j < valLength; j++) if (read(arr, i + j) !== read(val, j)) {
|
|
21728
|
-
found = false;
|
|
21729
|
-
break;
|
|
21730
|
-
}
|
|
21731
|
-
if (found) return i;
|
|
21732
|
-
}
|
|
21733
|
-
}
|
|
21734
|
-
return -1;
|
|
21735
|
-
}
|
|
21736
|
-
Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
21737
|
-
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
21738
|
-
};
|
|
21739
|
-
Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
21740
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
21741
|
-
};
|
|
21742
|
-
Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
21743
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
21744
|
-
};
|
|
21745
|
-
function hexWrite(buf, string, offset, length) {
|
|
21746
|
-
offset = Number(offset) || 0;
|
|
21747
|
-
var remaining = buf.length - offset;
|
|
21748
|
-
if (!length) length = remaining;
|
|
21749
|
-
else {
|
|
21750
|
-
length = Number(length);
|
|
21751
|
-
if (length > remaining) length = remaining;
|
|
21752
|
-
}
|
|
21753
|
-
var strLen = string.length;
|
|
21754
|
-
if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
|
|
21755
|
-
if (length > strLen / 2) length = strLen / 2;
|
|
21756
|
-
for (var i = 0; i < length; ++i) {
|
|
21757
|
-
var parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
21758
|
-
if (isNaN(parsed)) return i;
|
|
21759
|
-
buf[offset + i] = parsed;
|
|
21760
|
-
}
|
|
21761
|
-
return i;
|
|
21762
|
-
}
|
|
21763
|
-
function utf8Write(buf, string, offset, length) {
|
|
21764
|
-
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
21765
|
-
}
|
|
21766
|
-
function asciiWrite(buf, string, offset, length) {
|
|
21767
|
-
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
21768
|
-
}
|
|
21769
|
-
function latin1Write(buf, string, offset, length) {
|
|
21770
|
-
return asciiWrite(buf, string, offset, length);
|
|
21771
|
-
}
|
|
21772
|
-
function base64Write(buf, string, offset, length) {
|
|
21773
|
-
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
21774
|
-
}
|
|
21775
|
-
function ucs2Write(buf, string, offset, length) {
|
|
21776
|
-
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
21777
|
-
}
|
|
21778
|
-
Buffer.prototype.write = function write(string, offset, length, encoding) {
|
|
21779
|
-
if (offset === void 0) {
|
|
21780
|
-
encoding = "utf8";
|
|
21781
|
-
length = this.length;
|
|
21782
|
-
offset = 0;
|
|
21783
|
-
} else if (length === void 0 && typeof offset === "string") {
|
|
21784
|
-
encoding = offset;
|
|
21785
|
-
length = this.length;
|
|
21786
|
-
offset = 0;
|
|
21787
|
-
} else if (isFinite(offset)) {
|
|
21788
|
-
offset = offset | 0;
|
|
21789
|
-
if (isFinite(length)) {
|
|
21790
|
-
length = length | 0;
|
|
21791
|
-
if (encoding === void 0) encoding = "utf8";
|
|
21792
|
-
} else {
|
|
21793
|
-
encoding = length;
|
|
21794
|
-
length = void 0;
|
|
21795
|
-
}
|
|
21796
|
-
} else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
|
|
21797
|
-
var remaining = this.length - offset;
|
|
21798
|
-
if (length === void 0 || length > remaining) length = remaining;
|
|
21799
|
-
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw new RangeError("Attempt to write outside buffer bounds");
|
|
21800
|
-
if (!encoding) encoding = "utf8";
|
|
21801
|
-
var loweredCase = false;
|
|
21802
|
-
for (;;) switch (encoding) {
|
|
21803
|
-
case "hex": return hexWrite(this, string, offset, length);
|
|
21804
|
-
case "utf8":
|
|
21805
|
-
case "utf-8": return utf8Write(this, string, offset, length);
|
|
21806
|
-
case "ascii": return asciiWrite(this, string, offset, length);
|
|
21807
|
-
case "latin1":
|
|
21808
|
-
case "binary": return latin1Write(this, string, offset, length);
|
|
21809
|
-
case "base64": return base64Write(this, string, offset, length);
|
|
21810
|
-
case "ucs2":
|
|
21811
|
-
case "ucs-2":
|
|
21812
|
-
case "utf16le":
|
|
21813
|
-
case "utf-16le": return ucs2Write(this, string, offset, length);
|
|
21814
|
-
default:
|
|
21815
|
-
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
21816
|
-
encoding = ("" + encoding).toLowerCase();
|
|
21817
|
-
loweredCase = true;
|
|
21818
|
-
}
|
|
21819
|
-
};
|
|
21820
|
-
Buffer.prototype.toJSON = function toJSON() {
|
|
21821
|
-
return {
|
|
21822
|
-
type: "Buffer",
|
|
21823
|
-
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
21824
|
-
};
|
|
21825
|
-
};
|
|
21826
|
-
function base64Slice(buf, start, end) {
|
|
21827
|
-
if (start === 0 && end === buf.length) return fromByteArray(buf);
|
|
21828
|
-
else return fromByteArray(buf.slice(start, end));
|
|
21829
|
-
}
|
|
21830
|
-
function utf8Slice(buf, start, end) {
|
|
21831
|
-
end = Math.min(buf.length, end);
|
|
21832
|
-
var res = [];
|
|
21833
|
-
var i = start;
|
|
21834
|
-
while (i < end) {
|
|
21835
|
-
var firstByte = buf[i];
|
|
21836
|
-
var codePoint = null;
|
|
21837
|
-
var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
21838
|
-
if (i + bytesPerSequence <= end) {
|
|
21839
|
-
var secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
21840
|
-
switch (bytesPerSequence) {
|
|
21841
|
-
case 1:
|
|
21842
|
-
if (firstByte < 128) codePoint = firstByte;
|
|
21843
|
-
break;
|
|
21844
|
-
case 2:
|
|
21845
|
-
secondByte = buf[i + 1];
|
|
21846
|
-
if ((secondByte & 192) === 128) {
|
|
21847
|
-
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
21848
|
-
if (tempCodePoint > 127) codePoint = tempCodePoint;
|
|
21849
|
-
}
|
|
21850
|
-
break;
|
|
21851
|
-
case 3:
|
|
21852
|
-
secondByte = buf[i + 1];
|
|
21853
|
-
thirdByte = buf[i + 2];
|
|
21854
|
-
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
21855
|
-
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
21856
|
-
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) codePoint = tempCodePoint;
|
|
21857
|
-
}
|
|
21858
|
-
break;
|
|
21859
|
-
case 4:
|
|
21860
|
-
secondByte = buf[i + 1];
|
|
21861
|
-
thirdByte = buf[i + 2];
|
|
21862
|
-
fourthByte = buf[i + 3];
|
|
21863
|
-
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
21864
|
-
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
21865
|
-
if (tempCodePoint > 65535 && tempCodePoint < 1114112) codePoint = tempCodePoint;
|
|
21866
|
-
}
|
|
21867
|
-
}
|
|
21868
|
-
}
|
|
21869
|
-
if (codePoint === null) {
|
|
21870
|
-
codePoint = 65533;
|
|
21871
|
-
bytesPerSequence = 1;
|
|
21872
|
-
} else if (codePoint > 65535) {
|
|
21873
|
-
codePoint -= 65536;
|
|
21874
|
-
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
21875
|
-
codePoint = 56320 | codePoint & 1023;
|
|
21876
|
-
}
|
|
21877
|
-
res.push(codePoint);
|
|
21878
|
-
i += bytesPerSequence;
|
|
21879
|
-
}
|
|
21880
|
-
return decodeCodePointsArray(res);
|
|
21881
|
-
}
|
|
21882
|
-
var MAX_ARGUMENTS_LENGTH = 4096;
|
|
21883
|
-
function decodeCodePointsArray(codePoints) {
|
|
21884
|
-
var len = codePoints.length;
|
|
21885
|
-
if (len <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints);
|
|
21886
|
-
var res = "";
|
|
21887
|
-
var i = 0;
|
|
21888
|
-
while (i < len) res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
|
|
21889
|
-
return res;
|
|
21890
|
-
}
|
|
21891
|
-
function asciiSlice(buf, start, end) {
|
|
21892
|
-
var ret = "";
|
|
21893
|
-
end = Math.min(buf.length, end);
|
|
21894
|
-
for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i] & 127);
|
|
21895
|
-
return ret;
|
|
21896
|
-
}
|
|
21897
|
-
function latin1Slice(buf, start, end) {
|
|
21898
|
-
var ret = "";
|
|
21899
|
-
end = Math.min(buf.length, end);
|
|
21900
|
-
for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i]);
|
|
21901
|
-
return ret;
|
|
21902
|
-
}
|
|
21903
|
-
function hexSlice(buf, start, end) {
|
|
21904
|
-
var len = buf.length;
|
|
21905
|
-
if (!start || start < 0) start = 0;
|
|
21906
|
-
if (!end || end < 0 || end > len) end = len;
|
|
21907
|
-
var out = "";
|
|
21908
|
-
for (var i = start; i < end; ++i) out += toHex(buf[i]);
|
|
21909
|
-
return out;
|
|
21910
|
-
}
|
|
21911
|
-
function utf16leSlice(buf, start, end) {
|
|
21912
|
-
var bytes = buf.slice(start, end);
|
|
21913
|
-
var res = "";
|
|
21914
|
-
for (var i = 0; i < bytes.length; i += 2) res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
21915
|
-
return res;
|
|
21916
|
-
}
|
|
21917
|
-
Buffer.prototype.slice = function slice(start, end) {
|
|
21918
|
-
var len = this.length;
|
|
21919
|
-
start = ~~start;
|
|
21920
|
-
end = end === void 0 ? len : ~~end;
|
|
21921
|
-
if (start < 0) {
|
|
21922
|
-
start += len;
|
|
21923
|
-
if (start < 0) start = 0;
|
|
21924
|
-
} else if (start > len) start = len;
|
|
21925
|
-
if (end < 0) {
|
|
21926
|
-
end += len;
|
|
21927
|
-
if (end < 0) end = 0;
|
|
21928
|
-
} else if (end > len) end = len;
|
|
21929
|
-
if (end < start) end = start;
|
|
21930
|
-
var newBuf;
|
|
21931
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
21932
|
-
newBuf = this.subarray(start, end);
|
|
21933
|
-
newBuf.__proto__ = Buffer.prototype;
|
|
21934
|
-
} else {
|
|
21935
|
-
var sliceLen = end - start;
|
|
21936
|
-
newBuf = new Buffer(sliceLen, void 0);
|
|
21937
|
-
for (var i = 0; i < sliceLen; ++i) newBuf[i] = this[i + start];
|
|
21938
|
-
}
|
|
21939
|
-
return newBuf;
|
|
21940
|
-
};
|
|
21941
|
-
function checkOffset(offset, ext, length) {
|
|
21942
|
-
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
21943
|
-
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
|
21944
|
-
}
|
|
21945
|
-
Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
|
|
21946
|
-
offset = offset | 0;
|
|
21947
|
-
byteLength = byteLength | 0;
|
|
21948
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
21949
|
-
var val = this[offset];
|
|
21950
|
-
var mul = 1;
|
|
21951
|
-
var i = 0;
|
|
21952
|
-
while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
|
|
21953
|
-
return val;
|
|
21954
|
-
};
|
|
21955
|
-
Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
|
|
21956
|
-
offset = offset | 0;
|
|
21957
|
-
byteLength = byteLength | 0;
|
|
21958
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
21959
|
-
var val = this[offset + --byteLength];
|
|
21960
|
-
var mul = 1;
|
|
21961
|
-
while (byteLength > 0 && (mul *= 256)) val += this[offset + --byteLength] * mul;
|
|
21962
|
-
return val;
|
|
21963
|
-
};
|
|
21964
|
-
Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
21965
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
21966
|
-
return this[offset];
|
|
21967
|
-
};
|
|
21968
|
-
Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
21969
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
21970
|
-
return this[offset] | this[offset + 1] << 8;
|
|
21971
|
-
};
|
|
21972
|
-
Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
21973
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
21974
|
-
return this[offset] << 8 | this[offset + 1];
|
|
21975
|
-
};
|
|
21976
|
-
Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
21977
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
21978
|
-
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
21979
|
-
};
|
|
21980
|
-
Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
21981
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
21982
|
-
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
21983
|
-
};
|
|
21984
|
-
Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
|
|
21985
|
-
offset = offset | 0;
|
|
21986
|
-
byteLength = byteLength | 0;
|
|
21987
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
21988
|
-
var val = this[offset];
|
|
21989
|
-
var mul = 1;
|
|
21990
|
-
var i = 0;
|
|
21991
|
-
while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
|
|
21992
|
-
mul *= 128;
|
|
21993
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
21994
|
-
return val;
|
|
21995
|
-
};
|
|
21996
|
-
Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
|
|
21997
|
-
offset = offset | 0;
|
|
21998
|
-
byteLength = byteLength | 0;
|
|
21999
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
22000
|
-
var i = byteLength;
|
|
22001
|
-
var mul = 1;
|
|
22002
|
-
var val = this[offset + --i];
|
|
22003
|
-
while (i > 0 && (mul *= 256)) val += this[offset + --i] * mul;
|
|
22004
|
-
mul *= 128;
|
|
22005
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
22006
|
-
return val;
|
|
22007
|
-
};
|
|
22008
|
-
Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
22009
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
22010
|
-
if (!(this[offset] & 128)) return this[offset];
|
|
22011
|
-
return (255 - this[offset] + 1) * -1;
|
|
22012
|
-
};
|
|
22013
|
-
Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
22014
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
22015
|
-
var val = this[offset] | this[offset + 1] << 8;
|
|
22016
|
-
return val & 32768 ? val | 4294901760 : val;
|
|
22017
|
-
};
|
|
22018
|
-
Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
22019
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
22020
|
-
var val = this[offset + 1] | this[offset] << 8;
|
|
22021
|
-
return val & 32768 ? val | 4294901760 : val;
|
|
22022
|
-
};
|
|
22023
|
-
Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
22024
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
22025
|
-
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
22026
|
-
};
|
|
22027
|
-
Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
22028
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
22029
|
-
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
22030
|
-
};
|
|
22031
|
-
Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
22032
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
22033
|
-
return read(this, offset, true, 23, 4);
|
|
22034
|
-
};
|
|
22035
|
-
Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
22036
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
22037
|
-
return read(this, offset, false, 23, 4);
|
|
22038
|
-
};
|
|
22039
|
-
Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
22040
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
22041
|
-
return read(this, offset, true, 52, 8);
|
|
22042
|
-
};
|
|
22043
|
-
Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
22044
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
22045
|
-
return read(this, offset, false, 52, 8);
|
|
22046
|
-
};
|
|
22047
|
-
function checkInt(buf, value, offset, ext, max, min) {
|
|
22048
|
-
if (!internalIsBuffer(buf)) throw new TypeError("\"buffer\" argument must be a Buffer instance");
|
|
22049
|
-
if (value > max || value < min) throw new RangeError("\"value\" argument is out of bounds");
|
|
22050
|
-
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
22051
|
-
}
|
|
22052
|
-
Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
|
|
22053
|
-
value = +value;
|
|
22054
|
-
offset = offset | 0;
|
|
22055
|
-
byteLength = byteLength | 0;
|
|
22056
|
-
if (!noAssert) {
|
|
22057
|
-
var maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
22058
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
22059
|
-
}
|
|
22060
|
-
var mul = 1;
|
|
22061
|
-
var i = 0;
|
|
22062
|
-
this[offset] = value & 255;
|
|
22063
|
-
while (++i < byteLength && (mul *= 256)) this[offset + i] = value / mul & 255;
|
|
22064
|
-
return offset + byteLength;
|
|
22065
|
-
};
|
|
22066
|
-
Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
|
|
22067
|
-
value = +value;
|
|
22068
|
-
offset = offset | 0;
|
|
22069
|
-
byteLength = byteLength | 0;
|
|
22070
|
-
if (!noAssert) {
|
|
22071
|
-
var maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
22072
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
22073
|
-
}
|
|
22074
|
-
var i = byteLength - 1;
|
|
22075
|
-
var mul = 1;
|
|
22076
|
-
this[offset + i] = value & 255;
|
|
22077
|
-
while (--i >= 0 && (mul *= 256)) this[offset + i] = value / mul & 255;
|
|
22078
|
-
return offset + byteLength;
|
|
22079
|
-
};
|
|
22080
|
-
Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
22081
|
-
value = +value;
|
|
22082
|
-
offset = offset | 0;
|
|
22083
|
-
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
22084
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
|
|
22085
|
-
this[offset] = value & 255;
|
|
22086
|
-
return offset + 1;
|
|
22087
|
-
};
|
|
22088
|
-
function objectWriteUInt16(buf, value, offset, littleEndian) {
|
|
22089
|
-
if (value < 0) value = 65535 + value + 1;
|
|
22090
|
-
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;
|
|
22091
|
-
}
|
|
22092
|
-
Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
22093
|
-
value = +value;
|
|
22094
|
-
offset = offset | 0;
|
|
22095
|
-
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
22096
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
22097
|
-
this[offset] = value & 255;
|
|
22098
|
-
this[offset + 1] = value >>> 8;
|
|
22099
|
-
} else objectWriteUInt16(this, value, offset, true);
|
|
22100
|
-
return offset + 2;
|
|
22101
|
-
};
|
|
22102
|
-
Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
22103
|
-
value = +value;
|
|
22104
|
-
offset = offset | 0;
|
|
22105
|
-
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
22106
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
22107
|
-
this[offset] = value >>> 8;
|
|
22108
|
-
this[offset + 1] = value & 255;
|
|
22109
|
-
} else objectWriteUInt16(this, value, offset, false);
|
|
22110
|
-
return offset + 2;
|
|
22111
|
-
};
|
|
22112
|
-
function objectWriteUInt32(buf, value, offset, littleEndian) {
|
|
22113
|
-
if (value < 0) value = 4294967295 + value + 1;
|
|
22114
|
-
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
|
|
22115
|
-
}
|
|
22116
|
-
Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
22117
|
-
value = +value;
|
|
22118
|
-
offset = offset | 0;
|
|
22119
|
-
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
22120
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
22121
|
-
this[offset + 3] = value >>> 24;
|
|
22122
|
-
this[offset + 2] = value >>> 16;
|
|
22123
|
-
this[offset + 1] = value >>> 8;
|
|
22124
|
-
this[offset] = value & 255;
|
|
22125
|
-
} else objectWriteUInt32(this, value, offset, true);
|
|
22126
|
-
return offset + 4;
|
|
22127
|
-
};
|
|
22128
|
-
Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
22129
|
-
value = +value;
|
|
22130
|
-
offset = offset | 0;
|
|
22131
|
-
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
22132
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
22133
|
-
this[offset] = value >>> 24;
|
|
22134
|
-
this[offset + 1] = value >>> 16;
|
|
22135
|
-
this[offset + 2] = value >>> 8;
|
|
22136
|
-
this[offset + 3] = value & 255;
|
|
22137
|
-
} else objectWriteUInt32(this, value, offset, false);
|
|
22138
|
-
return offset + 4;
|
|
22139
|
-
};
|
|
22140
|
-
Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
|
|
22141
|
-
value = +value;
|
|
22142
|
-
offset = offset | 0;
|
|
22143
|
-
if (!noAssert) {
|
|
22144
|
-
var limit = Math.pow(2, 8 * byteLength - 1);
|
|
22145
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
22146
|
-
}
|
|
22147
|
-
var i = 0;
|
|
22148
|
-
var mul = 1;
|
|
22149
|
-
var sub = 0;
|
|
22150
|
-
this[offset] = value & 255;
|
|
22151
|
-
while (++i < byteLength && (mul *= 256)) {
|
|
22152
|
-
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1;
|
|
22153
|
-
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
22154
|
-
}
|
|
22155
|
-
return offset + byteLength;
|
|
22156
|
-
};
|
|
22157
|
-
Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
|
|
22158
|
-
value = +value;
|
|
22159
|
-
offset = offset | 0;
|
|
22160
|
-
if (!noAssert) {
|
|
22161
|
-
var limit = Math.pow(2, 8 * byteLength - 1);
|
|
22162
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
22163
|
-
}
|
|
22164
|
-
var i = byteLength - 1;
|
|
22165
|
-
var mul = 1;
|
|
22166
|
-
var sub = 0;
|
|
22167
|
-
this[offset + i] = value & 255;
|
|
22168
|
-
while (--i >= 0 && (mul *= 256)) {
|
|
22169
|
-
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1;
|
|
22170
|
-
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
22171
|
-
}
|
|
22172
|
-
return offset + byteLength;
|
|
22173
|
-
};
|
|
22174
|
-
Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
22175
|
-
value = +value;
|
|
22176
|
-
offset = offset | 0;
|
|
22177
|
-
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
22178
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
|
|
22179
|
-
if (value < 0) value = 255 + value + 1;
|
|
22180
|
-
this[offset] = value & 255;
|
|
22181
|
-
return offset + 1;
|
|
22182
|
-
};
|
|
22183
|
-
Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
22184
|
-
value = +value;
|
|
22185
|
-
offset = offset | 0;
|
|
22186
|
-
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
22187
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
22188
|
-
this[offset] = value & 255;
|
|
22189
|
-
this[offset + 1] = value >>> 8;
|
|
22190
|
-
} else objectWriteUInt16(this, value, offset, true);
|
|
22191
|
-
return offset + 2;
|
|
22192
|
-
};
|
|
22193
|
-
Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
22194
|
-
value = +value;
|
|
22195
|
-
offset = offset | 0;
|
|
22196
|
-
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
22197
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
22198
|
-
this[offset] = value >>> 8;
|
|
22199
|
-
this[offset + 1] = value & 255;
|
|
22200
|
-
} else objectWriteUInt16(this, value, offset, false);
|
|
22201
|
-
return offset + 2;
|
|
22202
|
-
};
|
|
22203
|
-
Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
22204
|
-
value = +value;
|
|
22205
|
-
offset = offset | 0;
|
|
22206
|
-
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
22207
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
22208
|
-
this[offset] = value & 255;
|
|
22209
|
-
this[offset + 1] = value >>> 8;
|
|
22210
|
-
this[offset + 2] = value >>> 16;
|
|
22211
|
-
this[offset + 3] = value >>> 24;
|
|
22212
|
-
} else objectWriteUInt32(this, value, offset, true);
|
|
22213
|
-
return offset + 4;
|
|
22214
|
-
};
|
|
22215
|
-
Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
22216
|
-
value = +value;
|
|
22217
|
-
offset = offset | 0;
|
|
22218
|
-
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
22219
|
-
if (value < 0) value = 4294967295 + value + 1;
|
|
22220
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
22221
|
-
this[offset] = value >>> 24;
|
|
22222
|
-
this[offset + 1] = value >>> 16;
|
|
22223
|
-
this[offset + 2] = value >>> 8;
|
|
22224
|
-
this[offset + 3] = value & 255;
|
|
22225
|
-
} else objectWriteUInt32(this, value, offset, false);
|
|
22226
|
-
return offset + 4;
|
|
22227
|
-
};
|
|
22228
|
-
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
22229
|
-
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
22230
|
-
if (offset < 0) throw new RangeError("Index out of range");
|
|
22231
|
-
}
|
|
22232
|
-
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
22233
|
-
if (!noAssert) checkIEEE754(buf, value, offset, 4);
|
|
22234
|
-
write(buf, value, offset, littleEndian, 23, 4);
|
|
22235
|
-
return offset + 4;
|
|
22236
|
-
}
|
|
22237
|
-
Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
22238
|
-
return writeFloat(this, value, offset, true, noAssert);
|
|
22239
|
-
};
|
|
22240
|
-
Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
22241
|
-
return writeFloat(this, value, offset, false, noAssert);
|
|
22242
|
-
};
|
|
22243
|
-
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
22244
|
-
if (!noAssert) checkIEEE754(buf, value, offset, 8);
|
|
22245
|
-
write(buf, value, offset, littleEndian, 52, 8);
|
|
22246
|
-
return offset + 8;
|
|
22247
|
-
}
|
|
22248
|
-
Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
22249
|
-
return writeDouble(this, value, offset, true, noAssert);
|
|
22250
|
-
};
|
|
22251
|
-
Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
22252
|
-
return writeDouble(this, value, offset, false, noAssert);
|
|
22253
|
-
};
|
|
22254
|
-
Buffer.prototype.copy = function copy(target, targetStart, start, end) {
|
|
22255
|
-
if (!start) start = 0;
|
|
22256
|
-
if (!end && end !== 0) end = this.length;
|
|
22257
|
-
if (targetStart >= target.length) targetStart = target.length;
|
|
22258
|
-
if (!targetStart) targetStart = 0;
|
|
22259
|
-
if (end > 0 && end < start) end = start;
|
|
22260
|
-
if (end === start) return 0;
|
|
22261
|
-
if (target.length === 0 || this.length === 0) return 0;
|
|
22262
|
-
if (targetStart < 0) throw new RangeError("targetStart out of bounds");
|
|
22263
|
-
if (start < 0 || start >= this.length) throw new RangeError("sourceStart out of bounds");
|
|
22264
|
-
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
22265
|
-
if (end > this.length) end = this.length;
|
|
22266
|
-
if (target.length - targetStart < end - start) end = target.length - targetStart + start;
|
|
22267
|
-
var len = end - start;
|
|
22268
|
-
var i;
|
|
22269
|
-
if (this === target && start < targetStart && targetStart < end) for (i = len - 1; i >= 0; --i) target[i + targetStart] = this[i + start];
|
|
22270
|
-
else if (len < 1e3 || !Buffer.TYPED_ARRAY_SUPPORT) for (i = 0; i < len; ++i) target[i + targetStart] = this[i + start];
|
|
22271
|
-
else Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
|
|
22272
|
-
return len;
|
|
22273
|
-
};
|
|
22274
|
-
Buffer.prototype.fill = function fill(val, start, end, encoding) {
|
|
22275
|
-
if (typeof val === "string") {
|
|
22276
|
-
if (typeof start === "string") {
|
|
22277
|
-
encoding = start;
|
|
22278
|
-
start = 0;
|
|
22279
|
-
end = this.length;
|
|
22280
|
-
} else if (typeof end === "string") {
|
|
22281
|
-
encoding = end;
|
|
22282
|
-
end = this.length;
|
|
22283
|
-
}
|
|
22284
|
-
if (val.length === 1) {
|
|
22285
|
-
var code = val.charCodeAt(0);
|
|
22286
|
-
if (code < 256) val = code;
|
|
22287
|
-
}
|
|
22288
|
-
if (encoding !== void 0 && typeof encoding !== "string") throw new TypeError("encoding must be a string");
|
|
22289
|
-
if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding);
|
|
22290
|
-
} else if (typeof val === "number") val = val & 255;
|
|
22291
|
-
if (start < 0 || this.length < start || this.length < end) throw new RangeError("Out of range index");
|
|
22292
|
-
if (end <= start) return this;
|
|
22293
|
-
start = start >>> 0;
|
|
22294
|
-
end = end === void 0 ? this.length : end >>> 0;
|
|
22295
|
-
if (!val) val = 0;
|
|
22296
|
-
var i;
|
|
22297
|
-
if (typeof val === "number") for (i = start; i < end; ++i) this[i] = val;
|
|
22298
|
-
else {
|
|
22299
|
-
var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString());
|
|
22300
|
-
var len = bytes.length;
|
|
22301
|
-
for (i = 0; i < end - start; ++i) this[i + start] = bytes[i % len];
|
|
22302
|
-
}
|
|
22303
|
-
return this;
|
|
22304
|
-
};
|
|
22305
|
-
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
|
|
22306
|
-
function base64clean(str) {
|
|
22307
|
-
str = stringtrim(str).replace(INVALID_BASE64_RE, "");
|
|
22308
|
-
if (str.length < 2) return "";
|
|
22309
|
-
while (str.length % 4 !== 0) str = str + "=";
|
|
22310
|
-
return str;
|
|
22311
|
-
}
|
|
22312
|
-
function stringtrim(str) {
|
|
22313
|
-
if (str.trim) return str.trim();
|
|
22314
|
-
return str.replace(/^\s+|\s+$/g, "");
|
|
22315
|
-
}
|
|
22316
|
-
function toHex(n) {
|
|
22317
|
-
if (n < 16) return "0" + n.toString(16);
|
|
22318
|
-
return n.toString(16);
|
|
22319
|
-
}
|
|
22320
|
-
function utf8ToBytes(string, units) {
|
|
22321
|
-
units = units || Infinity;
|
|
22322
|
-
var codePoint;
|
|
22323
|
-
var length = string.length;
|
|
22324
|
-
var leadSurrogate = null;
|
|
22325
|
-
var bytes = [];
|
|
22326
|
-
for (var i = 0; i < length; ++i) {
|
|
22327
|
-
codePoint = string.charCodeAt(i);
|
|
22328
|
-
if (codePoint > 55295 && codePoint < 57344) {
|
|
22329
|
-
if (!leadSurrogate) {
|
|
22330
|
-
if (codePoint > 56319) {
|
|
22331
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
22332
|
-
continue;
|
|
22333
|
-
} else if (i + 1 === length) {
|
|
22334
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
22335
|
-
continue;
|
|
22336
|
-
}
|
|
22337
|
-
leadSurrogate = codePoint;
|
|
22338
|
-
continue;
|
|
22339
|
-
}
|
|
22340
|
-
if (codePoint < 56320) {
|
|
22341
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
22342
|
-
leadSurrogate = codePoint;
|
|
22343
|
-
continue;
|
|
22344
|
-
}
|
|
22345
|
-
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
22346
|
-
} else if (leadSurrogate) {
|
|
22347
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
22348
|
-
}
|
|
22349
|
-
leadSurrogate = null;
|
|
22350
|
-
if (codePoint < 128) {
|
|
22351
|
-
if ((units -= 1) < 0) break;
|
|
22352
|
-
bytes.push(codePoint);
|
|
22353
|
-
} else if (codePoint < 2048) {
|
|
22354
|
-
if ((units -= 2) < 0) break;
|
|
22355
|
-
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
|
|
22356
|
-
} else if (codePoint < 65536) {
|
|
22357
|
-
if ((units -= 3) < 0) break;
|
|
22358
|
-
bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
|
|
22359
|
-
} else if (codePoint < 1114112) {
|
|
22360
|
-
if ((units -= 4) < 0) break;
|
|
22361
|
-
bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
|
|
22362
|
-
} else throw new Error("Invalid code point");
|
|
22363
|
-
}
|
|
22364
|
-
return bytes;
|
|
22365
|
-
}
|
|
22366
|
-
function asciiToBytes(str) {
|
|
22367
|
-
var byteArray = [];
|
|
22368
|
-
for (var i = 0; i < str.length; ++i) byteArray.push(str.charCodeAt(i) & 255);
|
|
22369
|
-
return byteArray;
|
|
22370
|
-
}
|
|
22371
|
-
function utf16leToBytes(str, units) {
|
|
22372
|
-
var c, hi, lo;
|
|
22373
|
-
var byteArray = [];
|
|
22374
|
-
for (var i = 0; i < str.length; ++i) {
|
|
22375
|
-
if ((units -= 2) < 0) break;
|
|
22376
|
-
c = str.charCodeAt(i);
|
|
22377
|
-
hi = c >> 8;
|
|
22378
|
-
lo = c % 256;
|
|
22379
|
-
byteArray.push(lo);
|
|
22380
|
-
byteArray.push(hi);
|
|
22381
|
-
}
|
|
22382
|
-
return byteArray;
|
|
22383
|
-
}
|
|
22384
|
-
function base64ToBytes(str) {
|
|
22385
|
-
return toByteArray(base64clean(str));
|
|
22386
|
-
}
|
|
22387
|
-
function blitBuffer(src, dst, offset, length) {
|
|
22388
|
-
for (var i = 0; i < length; ++i) {
|
|
22389
|
-
if (i + offset >= dst.length || i >= src.length) break;
|
|
22390
|
-
dst[i + offset] = src[i];
|
|
22391
|
-
}
|
|
22392
|
-
return i;
|
|
22393
|
-
}
|
|
22394
|
-
function isnan(val) {
|
|
22395
|
-
return val !== val;
|
|
22396
|
-
}
|
|
22397
|
-
function isBuffer(obj) {
|
|
22398
|
-
return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
|
|
22399
|
-
}
|
|
22400
|
-
function isFastBuffer(obj) {
|
|
22401
|
-
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
22402
|
-
}
|
|
22403
|
-
function isSlowBuffer(obj) {
|
|
22404
|
-
return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
|
|
22405
|
-
}
|
|
22406
|
-
//#endregion
|
|
22407
|
-
//#region src/util/output-type.ts
|
|
22408
|
-
/**
|
|
22409
|
-
* Output type definitions for document generation.
|
|
22410
|
-
*
|
|
22411
|
-
* This module defines the various output formats supported when generating
|
|
22412
|
-
* .docx files. These types correspond to fflate's output formats.
|
|
22413
|
-
*
|
|
22414
|
-
* @module
|
|
22415
|
-
*/
|
|
22416
|
-
/**
|
|
22417
|
-
* Converts a Uint8Array to the specified output type.
|
|
22418
|
-
*
|
|
22419
|
-
* This is used by both the Packer and patchDocument to convert fflate's
|
|
22420
|
-
* raw Uint8Array output into the user's requested format.
|
|
22421
|
-
*/
|
|
22422
|
-
const convertOutput = (data, type) => {
|
|
22423
|
-
switch (type) {
|
|
22424
|
-
case "nodebuffer": return Buffer.from(data);
|
|
22425
|
-
case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
|
22426
|
-
case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
22427
|
-
case "uint8array": return data;
|
|
22428
|
-
case "base64": return btoa(strFromU8(data, true));
|
|
22429
|
-
case "string":
|
|
22430
|
-
case "text":
|
|
22431
|
-
case "binarystring": return strFromU8(data, true);
|
|
22432
|
-
case "array": return [...data];
|
|
22433
|
-
default: return data;
|
|
22434
|
-
}
|
|
22435
|
-
};
|
|
22436
|
-
//#endregion
|
|
22437
21162
|
//#region src/file/fonts/obfuscate-ttf-to-odttf.ts
|
|
22438
21163
|
/**
|
|
22439
21164
|
* Font obfuscation module for embedding fonts in WordprocessingML documents.
|
|
@@ -22486,125 +21211,12 @@ const obfuscate = (buf, fontKey) => {
|
|
|
22486
21211
|
return out;
|
|
22487
21212
|
};
|
|
22488
21213
|
//#endregion
|
|
22489
|
-
//#region src/export/packer/
|
|
22490
|
-
|
|
22491
|
-
|
|
22492
|
-
|
|
22493
|
-
|
|
22494
|
-
|
|
22495
|
-
*/
|
|
22496
|
-
var ChartReplacer = class {
|
|
22497
|
-
/**
|
|
22498
|
-
* Replaces chart placeholder tokens with relationship IDs.
|
|
22499
|
-
*
|
|
22500
|
-
* @param xmlData - The XML string containing chart placeholders
|
|
22501
|
-
* @param charts - The chart collection
|
|
22502
|
-
* @param offset - Starting offset for relationship IDs
|
|
22503
|
-
* @returns XML string with placeholders replaced by relationship IDs
|
|
22504
|
-
*/
|
|
22505
|
-
replace(xmlData, charts, offset) {
|
|
22506
|
-
let currentXmlData = xmlData;
|
|
22507
|
-
charts.Array.forEach((chartData, i) => {
|
|
22508
|
-
currentXmlData = currentXmlData.replace(new RegExp(`\\{chart:${chartData.key}\\}`, "g"), (offset + i).toString());
|
|
22509
|
-
});
|
|
22510
|
-
return currentXmlData;
|
|
22511
|
-
}
|
|
22512
|
-
};
|
|
22513
|
-
//#endregion
|
|
22514
|
-
//#region src/export/packer/image-replacer.ts
|
|
22515
|
-
var ImageReplacer = class {
|
|
22516
|
-
replace(xmlData, mediaData, offset) {
|
|
22517
|
-
let currentXmlData = xmlData;
|
|
22518
|
-
mediaData.forEach((image, i) => {
|
|
22519
|
-
currentXmlData = currentXmlData.replace(new RegExp(`{${image.fileName}}`, "g"), `rId${offset + i}`);
|
|
22520
|
-
});
|
|
22521
|
-
return currentXmlData;
|
|
22522
|
-
}
|
|
22523
|
-
getMediaData(xmlData, media) {
|
|
22524
|
-
return media.Array.filter((image) => xmlData.search(`{${image.fileName}}`) > 0);
|
|
22525
|
-
}
|
|
22526
|
-
};
|
|
22527
|
-
//#endregion
|
|
22528
|
-
//#region src/export/packer/numbering-replacer.ts
|
|
22529
|
-
/**
|
|
22530
|
-
* Replaces numbering instance placeholders with actual numbering IDs in XML content.
|
|
22531
|
-
*
|
|
22532
|
-
* Numbering instances (for bullets and numbered lists) use placeholder tokens during
|
|
22533
|
-
* compilation. This class replaces those placeholders with the final numbering IDs
|
|
22534
|
-
* that reference the numbering definitions in numbering.xml.
|
|
22535
|
-
*
|
|
22536
|
-
* @example
|
|
22537
|
-
* ```typescript
|
|
22538
|
-
* const replacer = new NumberingReplacer();
|
|
22539
|
-
* const updatedXml = replacer.replace(xmlString, concreteNumberings);
|
|
22540
|
-
* ```
|
|
22541
|
-
*/
|
|
22542
|
-
var NumberingReplacer = class {
|
|
22543
|
-
/**
|
|
22544
|
-
* Replaces numbering placeholder tokens with actual numbering IDs.
|
|
22545
|
-
*
|
|
22546
|
-
* Placeholder format: {reference-instance} where reference identifies the
|
|
22547
|
-
* numbering definition and instance is the specific usage.
|
|
22548
|
-
*
|
|
22549
|
-
* @param xmlData - The XML string containing numbering placeholders
|
|
22550
|
-
* @param concreteNumberings - Array of concrete numbering instances to replace
|
|
22551
|
-
* @returns XML string with placeholders replaced by numbering IDs
|
|
22552
|
-
*/
|
|
22553
|
-
replace(xmlData, concreteNumberings) {
|
|
22554
|
-
let currentXmlData = xmlData;
|
|
22555
|
-
for (const concreteNumbering of concreteNumberings) currentXmlData = currentXmlData.replace(new RegExp(`{${concreteNumbering.reference}-${concreteNumbering.instance}}`, "g"), concreteNumbering.numId.toString());
|
|
22556
|
-
return currentXmlData;
|
|
22557
|
-
}
|
|
22558
|
-
};
|
|
22559
|
-
//#endregion
|
|
22560
|
-
//#region src/export/packer/smartart-replacer.ts
|
|
22561
|
-
/**
|
|
22562
|
-
* Replaces SmartArt placeholder tokens with relationship IDs in XML content.
|
|
22563
|
-
*
|
|
22564
|
-
* SmartArt uses multiple placeholders:
|
|
22565
|
-
* - `{smartart:N}` — data model relationship (internal)
|
|
22566
|
-
* - `{smartart-lo:N}` — layout relationship (internal)
|
|
22567
|
-
* - `{smartart-qs:N}` — quick style relationship (internal)
|
|
22568
|
-
* - `{smartart-cs:N}` — color style relationship (internal)
|
|
22569
|
-
*/
|
|
22570
|
-
var SmartArtReplacer = class {
|
|
22571
|
-
/**
|
|
22572
|
-
* Replaces SmartArt placeholder tokens with relationship IDs.
|
|
22573
|
-
*/
|
|
22574
|
-
replace(xmlData, smartArts, dataOffset) {
|
|
22575
|
-
let currentXmlData = xmlData;
|
|
22576
|
-
smartArts.Array.forEach((smartArtData, i) => {
|
|
22577
|
-
const key = smartArtData.key;
|
|
22578
|
-
currentXmlData = currentXmlData.replace(new RegExp(`\\{smartart:${key}\\}`, "g"), (dataOffset + i).toString());
|
|
22579
|
-
const loOffset = dataOffset + smartArts.Array.length;
|
|
22580
|
-
const qsOffset = loOffset + smartArts.Array.length;
|
|
22581
|
-
const csOffset = qsOffset + smartArts.Array.length;
|
|
22582
|
-
currentXmlData = currentXmlData.replace(new RegExp(`\\{smartart-lo:${key}\\}`, "g"), (loOffset + i).toString());
|
|
22583
|
-
currentXmlData = currentXmlData.replace(new RegExp(`\\{smartart-qs:${key}\\}`, "g"), (qsOffset + i).toString());
|
|
22584
|
-
currentXmlData = currentXmlData.replace(new RegExp(`\\{smartart-cs:${key}\\}`, "g"), (csOffset + i).toString());
|
|
22585
|
-
});
|
|
22586
|
-
return currentXmlData;
|
|
22587
|
-
}
|
|
22588
|
-
/**
|
|
22589
|
-
* Adds SmartArt relationships to the document relationships.
|
|
22590
|
-
*
|
|
22591
|
-
* All relationships are internal (pointing to package-local files).
|
|
22592
|
-
*/
|
|
22593
|
-
addRelationships(smartArts, addRelationship, baseOffset, chartCount) {
|
|
22594
|
-
const dataOffset = baseOffset + chartCount;
|
|
22595
|
-
const smartArtCount = smartArts.Array.length;
|
|
22596
|
-
const loOffset = dataOffset + smartArtCount;
|
|
22597
|
-
const qsOffset = loOffset + smartArtCount;
|
|
22598
|
-
const csOffset = qsOffset + smartArtCount;
|
|
22599
|
-
smartArts.Array.forEach((_smartArtData, i) => {
|
|
22600
|
-
addRelationship(dataOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData", `diagrams/data${i + 1}.xml`);
|
|
22601
|
-
addRelationship(loOffset + i, "http://schemas.microsoft.com/office/2007/relationships/diagramLayout", `diagrams/layout${i + 1}.xml`);
|
|
22602
|
-
addRelationship(qsOffset + i, "http://schemas.microsoft.com/office/2007/relationships/diagramStyle", `diagrams/quickStyle${i + 1}.xml`);
|
|
22603
|
-
addRelationship(csOffset + i, "http://schemas.microsoft.com/office/2007/relationships/diagramColors", `diagrams/colors${i + 1}.xml`);
|
|
22604
|
-
addRelationship(csOffset + smartArtCount + i, "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing", `diagrams/drawing${i + 1}.xml`);
|
|
22605
|
-
});
|
|
22606
|
-
}
|
|
22607
|
-
};
|
|
21214
|
+
//#region src/export/packer/numbering-placeholders.ts
|
|
21215
|
+
function replaceNumberingPlaceholders(xml, concreteNumberings) {
|
|
21216
|
+
let result = xml;
|
|
21217
|
+
for (const { reference, instance, numId } of concreteNumberings) result = result.replace(new RegExp(`{${reference}-${instance}}`, "g"), numId.toString());
|
|
21218
|
+
return result;
|
|
21219
|
+
}
|
|
22608
21220
|
//#endregion
|
|
22609
21221
|
//#region src/export/packer/next-compiler.ts
|
|
22610
21222
|
/**
|
|
@@ -22622,21 +21234,8 @@ var SmartArtReplacer = class {
|
|
|
22622
21234
|
*/
|
|
22623
21235
|
var Compiler = class {
|
|
22624
21236
|
formatter;
|
|
22625
|
-
imageReplacer;
|
|
22626
|
-
numberingReplacer;
|
|
22627
|
-
chartReplacer;
|
|
22628
|
-
smartArtReplacer;
|
|
22629
|
-
/**
|
|
22630
|
-
* Creates a new Compiler instance.
|
|
22631
|
-
*
|
|
22632
|
-
* Initializes the formatter and replacer utilities used during compilation.
|
|
22633
|
-
*/
|
|
22634
21237
|
constructor() {
|
|
22635
21238
|
this.formatter = new Formatter();
|
|
22636
|
-
this.imageReplacer = new ImageReplacer();
|
|
22637
|
-
this.numberingReplacer = new NumberingReplacer();
|
|
22638
|
-
this.chartReplacer = new ChartReplacer();
|
|
22639
|
-
this.smartArtReplacer = new SmartArtReplacer();
|
|
22640
21239
|
}
|
|
22641
21240
|
/**
|
|
22642
21241
|
* Compiles a File object into a flat file map suitable for fflate zipSync.
|
|
@@ -22662,12 +21261,12 @@ var Compiler = class {
|
|
|
22662
21261
|
const footerFormattedViews = /* @__PURE__ */ new Map();
|
|
22663
21262
|
const xmlifiedFileMapping = this.xmlifyFile(file, headerFormattedViews, footerFormattedViews, prettifyXml);
|
|
22664
21263
|
const map = new Map(Object.entries(xmlifiedFileMapping));
|
|
22665
|
-
for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = typeof subFile.data === "string" ? textToUint8Array(subFile.data) : subFile.data;
|
|
21264
|
+
for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = [typeof subFile.data === "string" ? textToUint8Array(subFile.data) : subFile.data, { level: 0 }];
|
|
22666
21265
|
else {
|
|
22667
21266
|
const fileObj = obj;
|
|
22668
|
-
files[fileObj.path] = typeof fileObj.data === "string" ? textToUint8Array(fileObj.data) : fileObj.data;
|
|
21267
|
+
files[fileObj.path] = [typeof fileObj.data === "string" ? textToUint8Array(fileObj.data) : fileObj.data, { level: 0 }];
|
|
22669
21268
|
}
|
|
22670
|
-
for (const subFile of overrides) files[subFile.path] = typeof subFile.data === "string" ? textToUint8Array(subFile.data) : subFile.data;
|
|
21269
|
+
for (const subFile of overrides) files[subFile.path] = [typeof subFile.data === "string" ? textToUint8Array(subFile.data) : subFile.data, { level: 0 }];
|
|
22671
21270
|
for (const mediaData of file.Media.Array) {
|
|
22672
21271
|
files[`word/media/${mediaData.fileName}`] = [toUint8Array(mediaData.data), { level: 0 }];
|
|
22673
21272
|
if (mediaData.type === "svg") files[`word/media/${mediaData.fallback.fileName}`] = [toUint8Array(mediaData.fallback.data), { level: 0 }];
|
|
@@ -22721,9 +21320,9 @@ var Compiler = class {
|
|
|
22721
21320
|
},
|
|
22722
21321
|
indent: prettify
|
|
22723
21322
|
});
|
|
22724
|
-
const documentMediaDatas = hasPlaceholders(documentXmlData) ?
|
|
22725
|
-
const commentMediaDatas = hasPlaceholders(commentXmlData) ?
|
|
22726
|
-
const footnoteMediaDatas = hasPlaceholders(footnoteXmlData) ?
|
|
21323
|
+
const documentMediaDatas = hasPlaceholders(documentXmlData) ? getReferencedMedia(documentXmlData, file.Media.Array) : [];
|
|
21324
|
+
const commentMediaDatas = hasPlaceholders(commentXmlData) ? getReferencedMedia(commentXmlData, file.Media.Array) : [];
|
|
21325
|
+
const footnoteMediaDatas = hasPlaceholders(footnoteXmlData) ? getReferencedMedia(footnoteXmlData, file.Media.Array) : [];
|
|
22727
21326
|
return {
|
|
22728
21327
|
AppProperties: {
|
|
22729
21328
|
data: xml(this.formatter.format(file.AppProperties, {
|
|
@@ -22731,20 +21330,14 @@ var Compiler = class {
|
|
|
22731
21330
|
file,
|
|
22732
21331
|
stack: [],
|
|
22733
21332
|
viewWrapper: file.Document
|
|
22734
|
-
}), {
|
|
22735
|
-
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
},
|
|
22739
|
-
indent: prettify
|
|
22740
|
-
}),
|
|
21333
|
+
}), { declaration: {
|
|
21334
|
+
encoding: "UTF-8",
|
|
21335
|
+
standalone: "yes"
|
|
21336
|
+
} }),
|
|
22741
21337
|
path: "docProps/app.xml"
|
|
22742
21338
|
},
|
|
22743
21339
|
Comments: {
|
|
22744
|
-
data: (()
|
|
22745
|
-
const xmlData = commentMediaDatas.length > 0 ? this.imageReplacer.replace(commentXmlData, commentMediaDatas, commentRelationshipCount) : commentXmlData;
|
|
22746
|
-
return this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering);
|
|
22747
|
-
})(),
|
|
21340
|
+
data: replaceNumberingPlaceholders(commentMediaDatas.length > 0 ? replaceImagePlaceholders(commentXmlData, commentMediaDatas, commentRelationshipCount, "plain") : commentXmlData, file.Numbering.ConcreteNumbering),
|
|
22748
21341
|
path: "word/comments.xml"
|
|
22749
21342
|
},
|
|
22750
21343
|
CommentsRelationships: {
|
|
@@ -22808,13 +21401,13 @@ var Compiler = class {
|
|
|
22808
21401
|
},
|
|
22809
21402
|
Document: {
|
|
22810
21403
|
data: (() => {
|
|
22811
|
-
let xmlData = documentMediaDatas.length > 0 ?
|
|
21404
|
+
let xmlData = documentMediaDatas.length > 0 ? replaceImagePlaceholders(documentXmlData, documentMediaDatas, documentRelationshipCount, "plain") : documentXmlData;
|
|
22812
21405
|
if (hasPlaceholders(xmlData)) {
|
|
22813
|
-
xmlData =
|
|
21406
|
+
xmlData = replaceChartPlaceholders(xmlData, file.Charts.Array.map((c) => c.key), documentRelationshipCount, "plain");
|
|
22814
21407
|
const smartArtDataOffset = documentRelationshipCount + documentMediaDatas.length + file.Charts.Array.length;
|
|
22815
|
-
xmlData =
|
|
21408
|
+
xmlData = replaceSmartArtPlaceholders(xmlData, file.SmartArts.Array.map((s) => s.key), smartArtDataOffset, "plain");
|
|
22816
21409
|
}
|
|
22817
|
-
return
|
|
21410
|
+
return replaceNumberingPlaceholders(xmlData, file.Numbering.ConcreteNumbering);
|
|
22818
21411
|
})(),
|
|
22819
21412
|
path: "word/document.xml"
|
|
22820
21413
|
},
|
|
@@ -22882,10 +21475,7 @@ var Compiler = class {
|
|
|
22882
21475
|
path: "word/_rels/fontTable.xml.rels"
|
|
22883
21476
|
},
|
|
22884
21477
|
FootNotes: {
|
|
22885
|
-
data: (()
|
|
22886
|
-
const xmlData = footnoteMediaDatas.length > 0 ? this.imageReplacer.replace(footnoteXmlData, footnoteMediaDatas, footnoteRelationshipCount) : footnoteXmlData;
|
|
22887
|
-
return this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering);
|
|
22888
|
-
})(),
|
|
21478
|
+
data: replaceNumberingPlaceholders(footnoteMediaDatas.length > 0 ? replaceImagePlaceholders(footnoteXmlData, footnoteMediaDatas, footnoteRelationshipCount, "plain") : footnoteXmlData, file.Numbering.ConcreteNumbering),
|
|
22889
21479
|
path: "word/footnotes.xml"
|
|
22890
21480
|
},
|
|
22891
21481
|
FootNotesRelationships: {
|
|
@@ -22916,7 +21506,7 @@ var Compiler = class {
|
|
|
22916
21506
|
indent: prettify
|
|
22917
21507
|
});
|
|
22918
21508
|
footerFormattedViews.set(index, xmlData);
|
|
22919
|
-
|
|
21509
|
+
getReferencedMedia(xmlData, file.Media.Array).forEach((mediaData, i) => {
|
|
22920
21510
|
footerWrapper.Relationships.addRelationship(i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${mediaData.fileName}`);
|
|
22921
21511
|
});
|
|
22922
21512
|
return {
|
|
@@ -22934,10 +21524,9 @@ var Compiler = class {
|
|
|
22934
21524
|
}),
|
|
22935
21525
|
Footers: file.Footers.map((_footerWrapper, index) => {
|
|
22936
21526
|
const tempXmlData = footerFormattedViews.get(index);
|
|
22937
|
-
const mediaDatas = hasPlaceholders(tempXmlData) ?
|
|
22938
|
-
const xmlData = mediaDatas.length > 0 ? this.imageReplacer.replace(tempXmlData, mediaDatas, 0) : tempXmlData;
|
|
21527
|
+
const mediaDatas = hasPlaceholders(tempXmlData) ? getReferencedMedia(tempXmlData, file.Media.Array) : [];
|
|
22939
21528
|
return {
|
|
22940
|
-
data:
|
|
21529
|
+
data: replaceNumberingPlaceholders(mediaDatas.length > 0 ? replaceImagePlaceholders(tempXmlData, mediaDatas, 0, "plain") : tempXmlData, file.Numbering.ConcreteNumbering),
|
|
22941
21530
|
path: `word/footer${index + 1}.xml`
|
|
22942
21531
|
};
|
|
22943
21532
|
}),
|
|
@@ -22952,7 +21541,7 @@ var Compiler = class {
|
|
|
22952
21541
|
indent: prettify
|
|
22953
21542
|
});
|
|
22954
21543
|
headerFormattedViews.set(index, xmlData);
|
|
22955
|
-
|
|
21544
|
+
getReferencedMedia(xmlData, file.Media.Array).forEach((mediaData, i) => {
|
|
22956
21545
|
headerWrapper.Relationships.addRelationship(i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${mediaData.fileName}`);
|
|
22957
21546
|
});
|
|
22958
21547
|
return {
|
|
@@ -22970,10 +21559,9 @@ var Compiler = class {
|
|
|
22970
21559
|
}),
|
|
22971
21560
|
Headers: file.Headers.map((_headerWrapper, index) => {
|
|
22972
21561
|
const tempXmlData = headerFormattedViews.get(index);
|
|
22973
|
-
const mediaDatas = hasPlaceholders(tempXmlData) ?
|
|
22974
|
-
const xmlData = mediaDatas.length > 0 ? this.imageReplacer.replace(tempXmlData, mediaDatas, 0) : tempXmlData;
|
|
21562
|
+
const mediaDatas = hasPlaceholders(tempXmlData) ? getReferencedMedia(tempXmlData, file.Media.Array) : [];
|
|
22975
21563
|
return {
|
|
22976
|
-
data:
|
|
21564
|
+
data: replaceNumberingPlaceholders(mediaDatas.length > 0 ? replaceImagePlaceholders(tempXmlData, mediaDatas, 0, "plain") : tempXmlData, file.Numbering.ConcreteNumbering),
|
|
22977
21565
|
path: `word/header${index + 1}.xml`
|
|
22978
21566
|
};
|
|
22979
21567
|
}),
|
|
@@ -23016,9 +21604,12 @@ var Compiler = class {
|
|
|
23016
21604
|
file.Charts.Array.forEach((_chartData, i) => {
|
|
23017
21605
|
file.Document.Relationships.addRelationship(chartOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", `charts/chart${i + 1}.xml`);
|
|
23018
21606
|
});
|
|
23019
|
-
|
|
23020
|
-
file.Document.Relationships.addRelationship(id, type, target
|
|
23021
|
-
}, documentRelationshipCount
|
|
21607
|
+
addSmartArtRelationships(file.SmartArts.Array.map((s) => s.key), (id, type, target) => {
|
|
21608
|
+
file.Document.Relationships.addRelationship(id, type, target);
|
|
21609
|
+
}, documentRelationshipCount + documentMediaDatas.length + file.Charts.Array.length, 0, {
|
|
21610
|
+
pathPrefix: "",
|
|
21611
|
+
styleRelType: "http://schemas.microsoft.com/office/2007/relationships/diagramStyle"
|
|
21612
|
+
});
|
|
23022
21613
|
file.Document.Relationships.addRelationship(file.Document.Relationships.RelationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", "fontTable.xml");
|
|
23023
21614
|
return xml(this.formatter.format(file.Document.Relationships, {
|
|
23024
21615
|
fileData: file,
|
|
@@ -23048,21 +21639,18 @@ var Compiler = class {
|
|
|
23048
21639
|
path: "word/settings.xml"
|
|
23049
21640
|
},
|
|
23050
21641
|
Styles: {
|
|
23051
|
-
data: ((
|
|
23052
|
-
|
|
23053
|
-
|
|
23054
|
-
|
|
23055
|
-
|
|
23056
|
-
|
|
23057
|
-
|
|
23058
|
-
|
|
23059
|
-
|
|
23060
|
-
|
|
23061
|
-
|
|
23062
|
-
|
|
23063
|
-
});
|
|
23064
|
-
return this.numberingReplacer.replace(xmlStyles, file.Numbering.ConcreteNumbering);
|
|
23065
|
-
})(),
|
|
21642
|
+
data: replaceNumberingPlaceholders(xml(this.formatter.format(file.Styles, {
|
|
21643
|
+
fileData: file,
|
|
21644
|
+
file,
|
|
21645
|
+
stack: [],
|
|
21646
|
+
viewWrapper: file.Document
|
|
21647
|
+
}), {
|
|
21648
|
+
declaration: {
|
|
21649
|
+
encoding: "UTF-8",
|
|
21650
|
+
standalone: "yes"
|
|
21651
|
+
},
|
|
21652
|
+
indent: prettify
|
|
21653
|
+
}), file.Numbering.ConcreteNumbering),
|
|
23066
21654
|
path: "word/styles.xml"
|
|
23067
21655
|
},
|
|
23068
21656
|
...file.Bibliography ? { Bibliography: {
|
|
@@ -23151,26 +21739,6 @@ var Compiler = class {
|
|
|
23151
21739
|
//#endregion
|
|
23152
21740
|
//#region src/export/packer/packer.ts
|
|
23153
21741
|
/**
|
|
23154
|
-
* Packer module for exporting documents to various output formats.
|
|
23155
|
-
*
|
|
23156
|
-
* @module
|
|
23157
|
-
*/
|
|
23158
|
-
/**
|
|
23159
|
-
* Prettify options for formatting XML output.
|
|
23160
|
-
*
|
|
23161
|
-
* Controls the indentation style used when formatting the generated XML.
|
|
23162
|
-
* Prettified output is more human-readable but results in larger file sizes.
|
|
23163
|
-
*
|
|
23164
|
-
* @publicApi
|
|
23165
|
-
*/
|
|
23166
|
-
const PrettifyType = {
|
|
23167
|
-
NONE: "",
|
|
23168
|
-
WITH_2_BLANKS: " ",
|
|
23169
|
-
WITH_4_BLANKS: " ",
|
|
23170
|
-
WITH_TAB: " "
|
|
23171
|
-
};
|
|
23172
|
-
const convertPrettifyType = (prettify) => prettify === true ? PrettifyType.WITH_2_BLANKS : prettify === false ? void 0 : prettify;
|
|
23173
|
-
/**
|
|
23174
21742
|
* Exports documents to various output formats.
|
|
23175
21743
|
*
|
|
23176
21744
|
* The Packer class provides static methods to convert a File object into different
|
|
@@ -23892,7 +22460,6 @@ const PatchType = {
|
|
|
23892
22460
|
DOCUMENT: "file",
|
|
23893
22461
|
PARAGRAPH: "paragraph"
|
|
23894
22462
|
};
|
|
23895
|
-
const imageReplacer = new ImageReplacer();
|
|
23896
22463
|
const UTF16LE = new Uint8Array([255, 254]);
|
|
23897
22464
|
const UTF16BE = new Uint8Array([254, 255]);
|
|
23898
22465
|
const compareByteArrays = (a, b) => {
|
|
@@ -24017,7 +22584,7 @@ const patchDocument = async ({ outputType, data, patches, keepOriginalStyles, pl
|
|
|
24017
22584
|
if (!recursive || !didFindOccurrence) break;
|
|
24018
22585
|
}
|
|
24019
22586
|
}
|
|
24020
|
-
const mediaDatas =
|
|
22587
|
+
const mediaDatas = getReferencedMedia(JSON.stringify(json), context.file.Media.Array);
|
|
24021
22588
|
if (mediaDatas.length > 0) {
|
|
24022
22589
|
hasMedia = true;
|
|
24023
22590
|
imageRelationshipAdditions.push({
|
|
@@ -24033,7 +22600,7 @@ const patchDocument = async ({ outputType, data, patches, keepOriginalStyles, pl
|
|
|
24033
22600
|
const relationshipsJson = map.get(relationshipKey) ?? createRelationshipFile();
|
|
24034
22601
|
map.set(relationshipKey, relationshipsJson);
|
|
24035
22602
|
const index = getNextRelationshipIndex(relationshipsJson);
|
|
24036
|
-
const newJson =
|
|
22603
|
+
const newJson = replaceImagePlaceholders(JSON.stringify(map.get(key)), mediaDatas, index, "plain");
|
|
24037
22604
|
map.set(key, JSON.parse(newJson));
|
|
24038
22605
|
for (let i = 0; i < mediaDatas.length; i++) {
|
|
24039
22606
|
const { fileName } = mediaDatas[i];
|