Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../assets/pdf/build
File: pdf.worker.js
return buffer.join("");
[6000] Fix | Delete
}
[6001] Fix | Delete
function validateFontName(fontFamily, mustWarn = false) {
[6002] Fix | Delete
const m = /^("|').*("|')$/.exec(fontFamily);
[6003] Fix | Delete
if (m && m[1] === m[2]) {
[6004] Fix | Delete
const re = new RegExp(`[^\\\\]${m[1]}`);
[6005] Fix | Delete
if (re.test(fontFamily.slice(1, -1))) {
[6006] Fix | Delete
if (mustWarn) {
[6007] Fix | Delete
warn(`FontFamily contains unescaped ${m[1]}: ${fontFamily}.`);
[6008] Fix | Delete
}
[6009] Fix | Delete
return false;
[6010] Fix | Delete
}
[6011] Fix | Delete
} else {
[6012] Fix | Delete
for (const ident of fontFamily.split(/[ \t]+/)) {
[6013] Fix | Delete
if (/^(\d|(-(\d|-)))/.test(ident) || !/^[\w-\\]+$/.test(ident)) {
[6014] Fix | Delete
if (mustWarn) {
[6015] Fix | Delete
warn(`FontFamily contains invalid <custom-ident>: ${fontFamily}.`);
[6016] Fix | Delete
}
[6017] Fix | Delete
return false;
[6018] Fix | Delete
}
[6019] Fix | Delete
}
[6020] Fix | Delete
}
[6021] Fix | Delete
return true;
[6022] Fix | Delete
}
[6023] Fix | Delete
function validateCSSFont(cssFontInfo) {
[6024] Fix | Delete
const DEFAULT_CSS_FONT_OBLIQUE = "14";
[6025] Fix | Delete
const DEFAULT_CSS_FONT_WEIGHT = "400";
[6026] Fix | Delete
const CSS_FONT_WEIGHT_VALUES = new Set(["100", "200", "300", "400", "500", "600", "700", "800", "900", "1000", "normal", "bold", "bolder", "lighter"]);
[6027] Fix | Delete
const {
[6028] Fix | Delete
fontFamily,
[6029] Fix | Delete
fontWeight,
[6030] Fix | Delete
italicAngle
[6031] Fix | Delete
} = cssFontInfo;
[6032] Fix | Delete
if (!validateFontName(fontFamily, true)) {
[6033] Fix | Delete
return false;
[6034] Fix | Delete
}
[6035] Fix | Delete
const weight = fontWeight ? fontWeight.toString() : "";
[6036] Fix | Delete
cssFontInfo.fontWeight = CSS_FONT_WEIGHT_VALUES.has(weight) ? weight : DEFAULT_CSS_FONT_WEIGHT;
[6037] Fix | Delete
const angle = parseFloat(italicAngle);
[6038] Fix | Delete
cssFontInfo.italicAngle = isNaN(angle) || angle < -90 || angle > 90 ? DEFAULT_CSS_FONT_OBLIQUE : italicAngle.toString();
[6039] Fix | Delete
return true;
[6040] Fix | Delete
}
[6041] Fix | Delete
function recoverJsURL(str) {
[6042] Fix | Delete
const URL_OPEN_METHODS = ["app.launchURL", "window.open", "xfa.host.gotoURL"];
[6043] Fix | Delete
const regex = new RegExp("^\\s*(" + URL_OPEN_METHODS.join("|").replaceAll(".", "\\.") + ")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))", "i");
[6044] Fix | Delete
const jsUrl = regex.exec(str);
[6045] Fix | Delete
if (jsUrl?.[2]) {
[6046] Fix | Delete
const url = jsUrl[2];
[6047] Fix | Delete
let newWindow = false;
[6048] Fix | Delete
if (jsUrl[3] === "true" && jsUrl[1] === "app.launchURL") {
[6049] Fix | Delete
newWindow = true;
[6050] Fix | Delete
}
[6051] Fix | Delete
return {
[6052] Fix | Delete
url,
[6053] Fix | Delete
newWindow
[6054] Fix | Delete
};
[6055] Fix | Delete
}
[6056] Fix | Delete
return null;
[6057] Fix | Delete
}
[6058] Fix | Delete
function numberToString(value) {
[6059] Fix | Delete
if (Number.isInteger(value)) {
[6060] Fix | Delete
return value.toString();
[6061] Fix | Delete
}
[6062] Fix | Delete
const roundedValue = Math.round(value * 100);
[6063] Fix | Delete
if (roundedValue % 100 === 0) {
[6064] Fix | Delete
return (roundedValue / 100).toString();
[6065] Fix | Delete
}
[6066] Fix | Delete
if (roundedValue % 10 === 0) {
[6067] Fix | Delete
return value.toFixed(1);
[6068] Fix | Delete
}
[6069] Fix | Delete
return value.toFixed(2);
[6070] Fix | Delete
}
[6071] Fix | Delete
function getNewAnnotationsMap(annotationStorage) {
[6072] Fix | Delete
if (!annotationStorage) {
[6073] Fix | Delete
return null;
[6074] Fix | Delete
}
[6075] Fix | Delete
const newAnnotationsByPage = new Map();
[6076] Fix | Delete
for (const [key, value] of annotationStorage) {
[6077] Fix | Delete
if (!key.startsWith(AnnotationEditorPrefix)) {
[6078] Fix | Delete
continue;
[6079] Fix | Delete
}
[6080] Fix | Delete
let annotations = newAnnotationsByPage.get(value.pageIndex);
[6081] Fix | Delete
if (!annotations) {
[6082] Fix | Delete
annotations = [];
[6083] Fix | Delete
newAnnotationsByPage.set(value.pageIndex, annotations);
[6084] Fix | Delete
}
[6085] Fix | Delete
annotations.push(value);
[6086] Fix | Delete
}
[6087] Fix | Delete
return newAnnotationsByPage.size > 0 ? newAnnotationsByPage : null;
[6088] Fix | Delete
}
[6089] Fix | Delete
function isAscii(str) {
[6090] Fix | Delete
return /^[\x00-\x7F]*$/.test(str);
[6091] Fix | Delete
}
[6092] Fix | Delete
function stringToUTF16HexString(str) {
[6093] Fix | Delete
const buf = [];
[6094] Fix | Delete
for (let i = 0, ii = str.length; i < ii; i++) {
[6095] Fix | Delete
const char = str.charCodeAt(i);
[6096] Fix | Delete
buf.push((char >> 8 & 0xff).toString(16).padStart(2, "0"), (char & 0xff).toString(16).padStart(2, "0"));
[6097] Fix | Delete
}
[6098] Fix | Delete
return buf.join("");
[6099] Fix | Delete
}
[6100] Fix | Delete
function stringToUTF16String(str, bigEndian = false) {
[6101] Fix | Delete
const buf = [];
[6102] Fix | Delete
if (bigEndian) {
[6103] Fix | Delete
buf.push("\xFE\xFF");
[6104] Fix | Delete
}
[6105] Fix | Delete
for (let i = 0, ii = str.length; i < ii; i++) {
[6106] Fix | Delete
const char = str.charCodeAt(i);
[6107] Fix | Delete
buf.push(String.fromCharCode(char >> 8 & 0xff), String.fromCharCode(char & 0xff));
[6108] Fix | Delete
}
[6109] Fix | Delete
return buf.join("");
[6110] Fix | Delete
}
[6111] Fix | Delete
function getRotationMatrix(rotation, width, height) {
[6112] Fix | Delete
switch (rotation) {
[6113] Fix | Delete
case 90:
[6114] Fix | Delete
return [0, 1, -1, 0, width, 0];
[6115] Fix | Delete
case 180:
[6116] Fix | Delete
return [-1, 0, 0, -1, width, height];
[6117] Fix | Delete
case 270:
[6118] Fix | Delete
return [0, -1, 1, 0, 0, height];
[6119] Fix | Delete
default:
[6120] Fix | Delete
throw new Error("Invalid rotation");
[6121] Fix | Delete
}
[6122] Fix | Delete
}
[6123] Fix | Delete
function getSizeInBytes(x) {
[6124] Fix | Delete
return Math.ceil(Math.ceil(Math.log2(1 + x)) / 8);
[6125] Fix | Delete
}
[6126] Fix | Delete
[6127] Fix | Delete
;// CONCATENATED MODULE: ./src/core/stream.js
[6128] Fix | Delete
[6129] Fix | Delete
[6130] Fix | Delete
[6131] Fix | Delete
[6132] Fix | Delete
[6133] Fix | Delete
[6134] Fix | Delete
[6135] Fix | Delete
[6136] Fix | Delete
class Stream extends BaseStream {
[6137] Fix | Delete
constructor(arrayBuffer, start, length, dict) {
[6138] Fix | Delete
super();
[6139] Fix | Delete
this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
[6140] Fix | Delete
this.start = start || 0;
[6141] Fix | Delete
this.pos = this.start;
[6142] Fix | Delete
this.end = start + length || this.bytes.length;
[6143] Fix | Delete
this.dict = dict;
[6144] Fix | Delete
}
[6145] Fix | Delete
get length() {
[6146] Fix | Delete
return this.end - this.start;
[6147] Fix | Delete
}
[6148] Fix | Delete
get isEmpty() {
[6149] Fix | Delete
return this.length === 0;
[6150] Fix | Delete
}
[6151] Fix | Delete
getByte() {
[6152] Fix | Delete
if (this.pos >= this.end) {
[6153] Fix | Delete
return -1;
[6154] Fix | Delete
}
[6155] Fix | Delete
return this.bytes[this.pos++];
[6156] Fix | Delete
}
[6157] Fix | Delete
getBytes(length) {
[6158] Fix | Delete
const bytes = this.bytes;
[6159] Fix | Delete
const pos = this.pos;
[6160] Fix | Delete
const strEnd = this.end;
[6161] Fix | Delete
if (!length) {
[6162] Fix | Delete
return bytes.subarray(pos, strEnd);
[6163] Fix | Delete
}
[6164] Fix | Delete
let end = pos + length;
[6165] Fix | Delete
if (end > strEnd) {
[6166] Fix | Delete
end = strEnd;
[6167] Fix | Delete
}
[6168] Fix | Delete
this.pos = end;
[6169] Fix | Delete
return bytes.subarray(pos, end);
[6170] Fix | Delete
}
[6171] Fix | Delete
getByteRange(begin, end) {
[6172] Fix | Delete
if (begin < 0) {
[6173] Fix | Delete
begin = 0;
[6174] Fix | Delete
}
[6175] Fix | Delete
if (end > this.end) {
[6176] Fix | Delete
end = this.end;
[6177] Fix | Delete
}
[6178] Fix | Delete
return this.bytes.subarray(begin, end);
[6179] Fix | Delete
}
[6180] Fix | Delete
reset() {
[6181] Fix | Delete
this.pos = this.start;
[6182] Fix | Delete
}
[6183] Fix | Delete
moveStart() {
[6184] Fix | Delete
this.start = this.pos;
[6185] Fix | Delete
}
[6186] Fix | Delete
makeSubStream(start, length, dict = null) {
[6187] Fix | Delete
return new Stream(this.bytes.buffer, start, length, dict);
[6188] Fix | Delete
}
[6189] Fix | Delete
}
[6190] Fix | Delete
class StringStream extends Stream {
[6191] Fix | Delete
constructor(str) {
[6192] Fix | Delete
super(stringToBytes(str));
[6193] Fix | Delete
}
[6194] Fix | Delete
}
[6195] Fix | Delete
class NullStream extends Stream {
[6196] Fix | Delete
constructor() {
[6197] Fix | Delete
super(new Uint8Array(0));
[6198] Fix | Delete
}
[6199] Fix | Delete
}
[6200] Fix | Delete
[6201] Fix | Delete
;// CONCATENATED MODULE: ./src/core/chunked_stream.js
[6202] Fix | Delete
[6203] Fix | Delete
[6204] Fix | Delete
[6205] Fix | Delete
[6206] Fix | Delete
[6207] Fix | Delete
[6208] Fix | Delete
[6209] Fix | Delete
[6210] Fix | Delete
[6211] Fix | Delete
[6212] Fix | Delete
[6213] Fix | Delete
[6214] Fix | Delete
[6215] Fix | Delete
[6216] Fix | Delete
[6217] Fix | Delete
[6218] Fix | Delete
[6219] Fix | Delete
[6220] Fix | Delete
class ChunkedStream extends Stream {
[6221] Fix | Delete
constructor(length, chunkSize, manager) {
[6222] Fix | Delete
super(new Uint8Array(length), 0, length, null);
[6223] Fix | Delete
this.chunkSize = chunkSize;
[6224] Fix | Delete
this._loadedChunks = new Set();
[6225] Fix | Delete
this.numChunks = Math.ceil(length / chunkSize);
[6226] Fix | Delete
this.manager = manager;
[6227] Fix | Delete
this.progressiveDataLength = 0;
[6228] Fix | Delete
this.lastSuccessfulEnsureByteChunk = -1;
[6229] Fix | Delete
}
[6230] Fix | Delete
getMissingChunks() {
[6231] Fix | Delete
const chunks = [];
[6232] Fix | Delete
for (let chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
[6233] Fix | Delete
if (!this._loadedChunks.has(chunk)) {
[6234] Fix | Delete
chunks.push(chunk);
[6235] Fix | Delete
}
[6236] Fix | Delete
}
[6237] Fix | Delete
return chunks;
[6238] Fix | Delete
}
[6239] Fix | Delete
get numChunksLoaded() {
[6240] Fix | Delete
return this._loadedChunks.size;
[6241] Fix | Delete
}
[6242] Fix | Delete
get isDataLoaded() {
[6243] Fix | Delete
return this.numChunksLoaded === this.numChunks;
[6244] Fix | Delete
}
[6245] Fix | Delete
onReceiveData(begin, chunk) {
[6246] Fix | Delete
const chunkSize = this.chunkSize;
[6247] Fix | Delete
if (begin % chunkSize !== 0) {
[6248] Fix | Delete
throw new Error(`Bad begin offset: ${begin}`);
[6249] Fix | Delete
}
[6250] Fix | Delete
const end = begin + chunk.byteLength;
[6251] Fix | Delete
if (end % chunkSize !== 0 && end !== this.bytes.length) {
[6252] Fix | Delete
throw new Error(`Bad end offset: ${end}`);
[6253] Fix | Delete
}
[6254] Fix | Delete
this.bytes.set(new Uint8Array(chunk), begin);
[6255] Fix | Delete
const beginChunk = Math.floor(begin / chunkSize);
[6256] Fix | Delete
const endChunk = Math.floor((end - 1) / chunkSize) + 1;
[6257] Fix | Delete
for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
[6258] Fix | Delete
this._loadedChunks.add(curChunk);
[6259] Fix | Delete
}
[6260] Fix | Delete
}
[6261] Fix | Delete
onReceiveProgressiveData(data) {
[6262] Fix | Delete
let position = this.progressiveDataLength;
[6263] Fix | Delete
const beginChunk = Math.floor(position / this.chunkSize);
[6264] Fix | Delete
this.bytes.set(new Uint8Array(data), position);
[6265] Fix | Delete
position += data.byteLength;
[6266] Fix | Delete
this.progressiveDataLength = position;
[6267] Fix | Delete
const endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
[6268] Fix | Delete
for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
[6269] Fix | Delete
this._loadedChunks.add(curChunk);
[6270] Fix | Delete
}
[6271] Fix | Delete
}
[6272] Fix | Delete
ensureByte(pos) {
[6273] Fix | Delete
if (pos < this.progressiveDataLength) {
[6274] Fix | Delete
return;
[6275] Fix | Delete
}
[6276] Fix | Delete
const chunk = Math.floor(pos / this.chunkSize);
[6277] Fix | Delete
if (chunk > this.numChunks) {
[6278] Fix | Delete
return;
[6279] Fix | Delete
}
[6280] Fix | Delete
if (chunk === this.lastSuccessfulEnsureByteChunk) {
[6281] Fix | Delete
return;
[6282] Fix | Delete
}
[6283] Fix | Delete
if (!this._loadedChunks.has(chunk)) {
[6284] Fix | Delete
throw new MissingDataException(pos, pos + 1);
[6285] Fix | Delete
}
[6286] Fix | Delete
this.lastSuccessfulEnsureByteChunk = chunk;
[6287] Fix | Delete
}
[6288] Fix | Delete
ensureRange(begin, end) {
[6289] Fix | Delete
if (begin >= end) {
[6290] Fix | Delete
return;
[6291] Fix | Delete
}
[6292] Fix | Delete
if (end <= this.progressiveDataLength) {
[6293] Fix | Delete
return;
[6294] Fix | Delete
}
[6295] Fix | Delete
const beginChunk = Math.floor(begin / this.chunkSize);
[6296] Fix | Delete
if (beginChunk > this.numChunks) {
[6297] Fix | Delete
return;
[6298] Fix | Delete
}
[6299] Fix | Delete
const endChunk = Math.min(Math.floor((end - 1) / this.chunkSize) + 1, this.numChunks);
[6300] Fix | Delete
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
[6301] Fix | Delete
if (!this._loadedChunks.has(chunk)) {
[6302] Fix | Delete
throw new MissingDataException(begin, end);
[6303] Fix | Delete
}
[6304] Fix | Delete
}
[6305] Fix | Delete
}
[6306] Fix | Delete
nextEmptyChunk(beginChunk) {
[6307] Fix | Delete
const numChunks = this.numChunks;
[6308] Fix | Delete
for (let i = 0; i < numChunks; ++i) {
[6309] Fix | Delete
const chunk = (beginChunk + i) % numChunks;
[6310] Fix | Delete
if (!this._loadedChunks.has(chunk)) {
[6311] Fix | Delete
return chunk;
[6312] Fix | Delete
}
[6313] Fix | Delete
}
[6314] Fix | Delete
return null;
[6315] Fix | Delete
}
[6316] Fix | Delete
hasChunk(chunk) {
[6317] Fix | Delete
return this._loadedChunks.has(chunk);
[6318] Fix | Delete
}
[6319] Fix | Delete
getByte() {
[6320] Fix | Delete
const pos = this.pos;
[6321] Fix | Delete
if (pos >= this.end) {
[6322] Fix | Delete
return -1;
[6323] Fix | Delete
}
[6324] Fix | Delete
if (pos >= this.progressiveDataLength) {
[6325] Fix | Delete
this.ensureByte(pos);
[6326] Fix | Delete
}
[6327] Fix | Delete
return this.bytes[this.pos++];
[6328] Fix | Delete
}
[6329] Fix | Delete
getBytes(length) {
[6330] Fix | Delete
const bytes = this.bytes;
[6331] Fix | Delete
const pos = this.pos;
[6332] Fix | Delete
const strEnd = this.end;
[6333] Fix | Delete
if (!length) {
[6334] Fix | Delete
if (strEnd > this.progressiveDataLength) {
[6335] Fix | Delete
this.ensureRange(pos, strEnd);
[6336] Fix | Delete
}
[6337] Fix | Delete
return bytes.subarray(pos, strEnd);
[6338] Fix | Delete
}
[6339] Fix | Delete
let end = pos + length;
[6340] Fix | Delete
if (end > strEnd) {
[6341] Fix | Delete
end = strEnd;
[6342] Fix | Delete
}
[6343] Fix | Delete
if (end > this.progressiveDataLength) {
[6344] Fix | Delete
this.ensureRange(pos, end);
[6345] Fix | Delete
}
[6346] Fix | Delete
this.pos = end;
[6347] Fix | Delete
return bytes.subarray(pos, end);
[6348] Fix | Delete
}
[6349] Fix | Delete
getByteRange(begin, end) {
[6350] Fix | Delete
if (begin < 0) {
[6351] Fix | Delete
begin = 0;
[6352] Fix | Delete
}
[6353] Fix | Delete
if (end > this.end) {
[6354] Fix | Delete
end = this.end;
[6355] Fix | Delete
}
[6356] Fix | Delete
if (end > this.progressiveDataLength) {
[6357] Fix | Delete
this.ensureRange(begin, end);
[6358] Fix | Delete
}
[6359] Fix | Delete
return this.bytes.subarray(begin, end);
[6360] Fix | Delete
}
[6361] Fix | Delete
makeSubStream(start, length, dict = null) {
[6362] Fix | Delete
if (length) {
[6363] Fix | Delete
if (start + length > this.progressiveDataLength) {
[6364] Fix | Delete
this.ensureRange(start, start + length);
[6365] Fix | Delete
}
[6366] Fix | Delete
} else if (start >= this.progressiveDataLength) {
[6367] Fix | Delete
this.ensureByte(start);
[6368] Fix | Delete
}
[6369] Fix | Delete
function ChunkedStreamSubstream() {}
[6370] Fix | Delete
ChunkedStreamSubstream.prototype = Object.create(this);
[6371] Fix | Delete
ChunkedStreamSubstream.prototype.getMissingChunks = function () {
[6372] Fix | Delete
const chunkSize = this.chunkSize;
[6373] Fix | Delete
const beginChunk = Math.floor(this.start / chunkSize);
[6374] Fix | Delete
const endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
[6375] Fix | Delete
const missingChunks = [];
[6376] Fix | Delete
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
[6377] Fix | Delete
if (!this._loadedChunks.has(chunk)) {
[6378] Fix | Delete
missingChunks.push(chunk);
[6379] Fix | Delete
}
[6380] Fix | Delete
}
[6381] Fix | Delete
return missingChunks;
[6382] Fix | Delete
};
[6383] Fix | Delete
Object.defineProperty(ChunkedStreamSubstream.prototype, "isDataLoaded", {
[6384] Fix | Delete
get() {
[6385] Fix | Delete
if (this.numChunksLoaded === this.numChunks) {
[6386] Fix | Delete
return true;
[6387] Fix | Delete
}
[6388] Fix | Delete
return this.getMissingChunks().length === 0;
[6389] Fix | Delete
},
[6390] Fix | Delete
configurable: true
[6391] Fix | Delete
});
[6392] Fix | Delete
const subStream = new ChunkedStreamSubstream();
[6393] Fix | Delete
subStream.pos = subStream.start = start;
[6394] Fix | Delete
subStream.end = start + length || this.end;
[6395] Fix | Delete
subStream.dict = dict;
[6396] Fix | Delete
return subStream;
[6397] Fix | Delete
}
[6398] Fix | Delete
getBaseStreams() {
[6399] Fix | Delete
return [this];
[6400] Fix | Delete
}
[6401] Fix | Delete
}
[6402] Fix | Delete
class ChunkedStreamManager {
[6403] Fix | Delete
constructor(pdfNetworkStream, args) {
[6404] Fix | Delete
this.length = args.length;
[6405] Fix | Delete
this.chunkSize = args.rangeChunkSize;
[6406] Fix | Delete
this.stream = new ChunkedStream(this.length, this.chunkSize, this);
[6407] Fix | Delete
this.pdfNetworkStream = pdfNetworkStream;
[6408] Fix | Delete
this.disableAutoFetch = args.disableAutoFetch;
[6409] Fix | Delete
this.msgHandler = args.msgHandler;
[6410] Fix | Delete
this.currRequestId = 0;
[6411] Fix | Delete
this._chunksNeededByRequest = new Map();
[6412] Fix | Delete
this._requestsByChunk = new Map();
[6413] Fix | Delete
this._promisesByRequest = new Map();
[6414] Fix | Delete
this.progressiveDataLength = 0;
[6415] Fix | Delete
this.aborted = false;
[6416] Fix | Delete
this._loadedStreamCapability = Promise.withResolvers();
[6417] Fix | Delete
}
[6418] Fix | Delete
sendRequest(begin, end) {
[6419] Fix | Delete
const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
[6420] Fix | Delete
if (!rangeReader.isStreamingSupported) {
[6421] Fix | Delete
rangeReader.onProgress = this.onProgress.bind(this);
[6422] Fix | Delete
}
[6423] Fix | Delete
let chunks = [],
[6424] Fix | Delete
loaded = 0;
[6425] Fix | Delete
return new Promise((resolve, reject) => {
[6426] Fix | Delete
const readChunk = ({
[6427] Fix | Delete
value,
[6428] Fix | Delete
done
[6429] Fix | Delete
}) => {
[6430] Fix | Delete
try {
[6431] Fix | Delete
if (done) {
[6432] Fix | Delete
const chunkData = arrayBuffersToBytes(chunks);
[6433] Fix | Delete
chunks = null;
[6434] Fix | Delete
resolve(chunkData);
[6435] Fix | Delete
return;
[6436] Fix | Delete
}
[6437] Fix | Delete
loaded += value.byteLength;
[6438] Fix | Delete
if (rangeReader.isStreamingSupported) {
[6439] Fix | Delete
this.onProgress({
[6440] Fix | Delete
loaded
[6441] Fix | Delete
});
[6442] Fix | Delete
}
[6443] Fix | Delete
chunks.push(value);
[6444] Fix | Delete
rangeReader.read().then(readChunk, reject);
[6445] Fix | Delete
} catch (e) {
[6446] Fix | Delete
reject(e);
[6447] Fix | Delete
}
[6448] Fix | Delete
};
[6449] Fix | Delete
rangeReader.read().then(readChunk, reject);
[6450] Fix | Delete
}).then(data => {
[6451] Fix | Delete
if (this.aborted) {
[6452] Fix | Delete
return;
[6453] Fix | Delete
}
[6454] Fix | Delete
this.onReceiveData({
[6455] Fix | Delete
chunk: data,
[6456] Fix | Delete
begin
[6457] Fix | Delete
});
[6458] Fix | Delete
});
[6459] Fix | Delete
}
[6460] Fix | Delete
requestAllChunks(noFetch = false) {
[6461] Fix | Delete
if (!noFetch) {
[6462] Fix | Delete
const missingChunks = this.stream.getMissingChunks();
[6463] Fix | Delete
this._requestChunks(missingChunks);
[6464] Fix | Delete
}
[6465] Fix | Delete
return this._loadedStreamCapability.promise;
[6466] Fix | Delete
}
[6467] Fix | Delete
_requestChunks(chunks) {
[6468] Fix | Delete
const requestId = this.currRequestId++;
[6469] Fix | Delete
const chunksNeeded = new Set();
[6470] Fix | Delete
this._chunksNeededByRequest.set(requestId, chunksNeeded);
[6471] Fix | Delete
for (const chunk of chunks) {
[6472] Fix | Delete
if (!this.stream.hasChunk(chunk)) {
[6473] Fix | Delete
chunksNeeded.add(chunk);
[6474] Fix | Delete
}
[6475] Fix | Delete
}
[6476] Fix | Delete
if (chunksNeeded.size === 0) {
[6477] Fix | Delete
return Promise.resolve();
[6478] Fix | Delete
}
[6479] Fix | Delete
const capability = Promise.withResolvers();
[6480] Fix | Delete
this._promisesByRequest.set(requestId, capability);
[6481] Fix | Delete
const chunksToRequest = [];
[6482] Fix | Delete
for (const chunk of chunksNeeded) {
[6483] Fix | Delete
let requestIds = this._requestsByChunk.get(chunk);
[6484] Fix | Delete
if (!requestIds) {
[6485] Fix | Delete
requestIds = [];
[6486] Fix | Delete
this._requestsByChunk.set(chunk, requestIds);
[6487] Fix | Delete
chunksToRequest.push(chunk);
[6488] Fix | Delete
}
[6489] Fix | Delete
requestIds.push(requestId);
[6490] Fix | Delete
}
[6491] Fix | Delete
if (chunksToRequest.length > 0) {
[6492] Fix | Delete
const groupedChunksToRequest = this.groupChunks(chunksToRequest);
[6493] Fix | Delete
for (const groupedChunk of groupedChunksToRequest) {
[6494] Fix | Delete
const begin = groupedChunk.beginChunk * this.chunkSize;
[6495] Fix | Delete
const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
[6496] Fix | Delete
this.sendRequest(begin, end).catch(capability.reject);
[6497] Fix | Delete
}
[6498] Fix | Delete
}
[6499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function