Files
Stirling-PDF/src/main/resources/static/pdfjs/pdf.sandbox.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

797 lines
642 KiB
JavaScript
Raw Normal View History

2023-10-22 20:16:59 +03:00
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright 2023 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* JavaScript code in this page
*/
(function webpackUniversalModuleDefinition(root, factory) {
if (typeof exports === 'object' && typeof module === 'object')
module.exports = root.pdfjsSandbox = factory();
else if (typeof define === 'function' && define.amd)
define("pdfjs-dist/build/pdf.sandbox", [], () => {
return (root.pdfjsSandbox = factory());
});
else if (typeof exports === 'object')
exports["pdfjs-dist/build/pdf.sandbox"] = root.pdfjsSandbox = factory();
else
root["pdfjs-dist/build/pdf.sandbox"] = root.pdfjsSandbox = factory();
})(globalThis, () => {
return /******/ (() => { // webpackBootstrap
/******/
"use strict";
/******/
var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((__unused_webpack_module, exports) => {
Object.defineProperty(exports, "__esModule", ({value: true}));
exports["default"] = void 0;
var Module = (() => {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
return function (Module) {
Module = Module || {};
var c;
c || (c = typeof Module !== 'undefined' ? Module : {});
var h, n;
c.ready = new Promise(function (a, b) {
h = a;
n = b;
});
var r = Object.assign({}, c), t = "";
"undefined" != typeof document && document.currentScript && (t = document.currentScript.src);
_scriptDir && (t = _scriptDir);
0 !== t.indexOf("blob:") ? t = t.substr(0, t.replace(/[?#].*/, "").lastIndexOf("/") + 1) : t = "";
var aa = c.print || console.log.bind(console), u = c.printErr || console.warn.bind(console);
Object.assign(c, r);
r = null;
var v;
c.wasmBinary && (v = c.wasmBinary);
var noExitRuntime = c.noExitRuntime || !0;
"object" != typeof WebAssembly && w("no native wasm support detected");
var x, y = !1;
function z(a, b, d, e) {
var f = {
string: function (l) {
var p = 0;
if (null !== l && void 0 !== l && 0 !== l) {
var S = (l.length << 2) + 1;
p = A(S);
B(l, C, p, S);
}
return p;
}, array: function (l) {
var p = A(l.length);
D.set(l, p);
return p;
}
};
a = c["_" + a];
var g = [], k = 0;
if (e) for (var m = 0; m < e.length; m++) {
var q = f[d[m]];
q ? (0 === k && (k = E()), g[m] = q(e[m])) : g[m] = e[m];
}
d = a.apply(null, g);
return d = function (l) {
0 !== k && F(k);
return "string" === b ? G(l) : "boolean" === b ? !!l : l;
}(d);
}
var H = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0;
function I(a, b) {
for (var d = b + NaN, e = b; a[e] && !(e >= d);) ++e;
if (16 < e - b && a.buffer && H) return H.decode(a.subarray(b, e));
for (d = ""; b < e;) {
var f = a[b++];
if (f & 128) {
var g = a[b++] & 63;
if (192 == (f & 224)) d += String.fromCharCode((f & 31) << 6 | g); else {
var k = a[b++] & 63;
f = 224 == (f & 240) ? (f & 15) << 12 | g << 6 | k : (f & 7) << 18 | g << 12 | k << 6 | a[b++] & 63;
65536 > f ? d += String.fromCharCode(f) : (f -= 65536, d += String.fromCharCode(55296 | f >> 10, 56320 | f & 1023));
}
} else d += String.fromCharCode(f);
}
return d;
}
function G(a) {
return a ? I(C, a) : "";
}
function B(a, b, d, e) {
if (0 < e) {
e = d + e - 1;
for (var f = 0; f < a.length; ++f) {
var g = a.charCodeAt(f);
if (55296 <= g && 57343 >= g) {
var k = a.charCodeAt(++f);
g = 65536 + ((g & 1023) << 10) | k & 1023;
}
if (127 >= g) {
if (d >= e) break;
b[d++] = g;
} else {
if (2047 >= g) {
if (d + 1 >= e) break;
b[d++] = 192 | g >> 6;
} else {
if (65535 >= g) {
if (d + 2 >= e) break;
b[d++] = 224 | g >> 12;
} else {
if (d + 3 >= e) break;
b[d++] = 240 | g >> 18;
b[d++] = 128 | g >> 12 & 63;
}
b[d++] = 128 | g >> 6 & 63;
}
b[d++] = 128 | g & 63;
}
}
b[d] = 0;
}
}
function J(a) {
for (var b = 0, d = 0; d < a.length; ++d) {
var e = a.charCodeAt(d);
55296 <= e && 57343 >= e && (e = 65536 + ((e & 1023) << 10) | a.charCodeAt(++d) & 1023);
127 >= e ? ++b : b = 2047 >= e ? b + 2 : 65535 >= e ? b + 3 : b + 4;
}
return b;
}
function K(a) {
var b = J(a) + 1, d = L(b);
d && B(a, D, d, b);
return d;
}
var M, D, C, N;
function ba() {
var a = x.buffer;
M = a;
c.HEAP8 = D = new Int8Array(a);
c.HEAP16 = new Int16Array(a);
c.HEAP32 = N = new Int32Array(a);
c.HEAPU8 = C = new Uint8Array(a);
c.HEAPU16 = new Uint16Array(a);
c.HEAPU32 = new Uint32Array(a);
c.HEAPF32 = new Float32Array(a);
c.HEAPF64 = new Float64Array(a);
}
var O, ca = [], da = [], ea = [];
function fa() {
var a = c.preRun.shift();
ca.unshift(a);
}
var P = 0, Q = null, R = null;
function w(a) {
if (c.onAbort) c.onAbort(a);
a = "Aborted(" + a + ")";
u(a);
y = !0;
a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
n(a);
throw a;
}
function T(a) {
return a.startsWith("data:application/octet-stream;base64,");
}
var U;
U = "data:application/octet-stream;base64,AGFzbQEAAAAByQZtYAR/fn9/AX5gA39/fwF/YAJ/fwF/YAJ/fwBgAX8Bf2AFf35/f38BfmADf39/AGABfwBgAXwBfGACf34BfmAEf39/fwF/YAJ/fgBgAn9/AX5gAn9+AX9gA39/fgF/YAN/fn8BfmABfgF/YAN/fn8AYAZ/fn9/f38BfmADf35/AX9gBX9/f39/AX9gBn9+fn9/fwF+YAN/fn4BfmAEf39/fwBgBH9/fn8Bf2ADf39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4G/Qb8BvsG+gb5BvgG9wb2BvUG9AbzBvIG8QbwBu8G7gbtBuwG6wbpBugG5wbmBuUG5AbjBuIG4QbgBt8G3gbdBtwG2wbSCNEI1gjaBsoIjQbbCLIE2QjUCK8E2gKZBcwIxQjDCNkG0wjLCMQI3AjaCNgIpgKzA80IzgjXCNgG1wbWBtUG1AbTBtIG0QbQBs8GzgbNBswGywbKBskGyAbHBsYGxQbEBsMGwgbLBMEGygTABr8GvQa8BrsGuga5BrgGtwa2BrQGsQagBp8GnQacBq4GsAasBqoGqAamBqQGogatBq8GqwapBqcGpQajBqEGxwSbBpoGmQaYBpcGlgaVBpQGkwaSBoUExwTQCIgGzwiVBJUEyAjHCMIIwQi/CArDuBLSCDUBAX8CQCABQiCIp0F1SQ0AIAGnIgIgAigCACICQQFrNgIAIAJBAUoNACAAKAIQIAEQhgULCxMAIABCgICAgHCDQoCAgIDgAFELTQECfyAAKAJAIgJBgAJqIQMgAigCnAIgACgCBEcEQCADQcABEBAgAyAAKAIEEB4gA
if (!T(U)) {
var ha = U;
U = c.locateFile ? c.locateFile(ha, t) : t + ha;
}
function ia() {
var a = U;
try {
if (a == U && v) return new Uint8Array(v);
if (T(a)) try {
var b = ja(a.slice(37)), d = new Uint8Array(b.length);
for (a = 0; a < b.length; ++a) d[a] = b.charCodeAt(a);
var e = d;
} catch (g) {
throw Error("Converting base64 string to bytes failed.");
} else e = void 0;
var f = e;
if (f) return f;
throw "both async and sync fetching of the wasm failed";
} catch (g) {
w(g);
}
}
function ka() {
return v || "function" != typeof fetch ? Promise.resolve().then(function () {
return ia();
}) : fetch(U, {credentials: "same-origin"}).then(function (a) {
if (!a.ok) throw "failed to load wasm binary file at '" + U + "'";
return a.arrayBuffer();
}).catch(function () {
return ia();
});
}
function V(a) {
for (; 0 < a.length;) {
var b = a.shift();
if ("function" == typeof b) b(c); else {
var d = b.C;
"number" == typeof d ? void 0 === b.A ? O.get(d)() : O.get(d)(b.A) : d(void 0 === b.A ? null : b.A);
}
}
}
function la(a, b, d) {
function e(q) {
return (q = q.toTimeString().match(/\(([A-Za-z ]+)\)$/)) ? q[1] : "GMT";
}
var f = new Date().getFullYear(), g = new Date(f, 0, 1), k = new Date(f, 6, 1);
f = g.getTimezoneOffset();
var m = k.getTimezoneOffset();
N[a >> 2] = 60 * Math.max(f, m);
N[b >> 2] = Number(f != m);
a = e(g);
b = e(k);
a = K(a);
b = K(b);
m < f ? (N[d >> 2] = a, N[d + 4 >> 2] = b) : (N[d >> 2] = b, N[d + 4 >> 2] = a);
}
function W(a, b, d) {
W.B || (W.B = !0, la(a, b, d));
}
function X(a) {
var b = J(a) + 1, d = L(b);
B(a, C, d, b);
return d;
}
function ma() {
}
var na = [null, [], []];
ma = (a, b, d) => {
a = G(a);
b = null !== b ? JSON.parse(G(b)) : [];
try {
const e = c.externalCall(a, b);
return e ? X(e) : null;
} catch (e) {
return c.HEAPU8[d] = 1, X(e.message);
}
};
var ja = "function" == typeof atob ? atob : function (a) {
var b = "", d = 0;
a = a.replace(/[^A-Za-z0-9\+\/=]/g, "");
do {
var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));
var f = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));
var g = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));
var k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));
e = e << 2 | f >> 4;
f = (f & 15) << 4 | g >> 2;
var m = (g & 3) << 6 | k;
b += String.fromCharCode(e);
64 !== g && (b += String.fromCharCode(f));
64 !== k && (b += String.fromCharCode(m));
} while (d < a.length);
return b;
}, oa = {
a: function (a, b, d, e) {
w("Assertion failed: " + G(a) + ", at: " + [b ? G(b) : "unknown filename", d, e ? G(e) : "unknown function"]);
}, d: function () {
return Date.now();
}, e: function (a, b) {
a = new Date(1E3 * N[a >> 2]);
N[b >> 2] = a.getSeconds();
N[b + 4 >> 2] = a.getMinutes();
N[b + 8 >> 2] = a.getHours();
N[b + 12 >> 2] = a.getDate();
N[b + 16 >> 2] = a.getMonth();
N[b + 20 >> 2] = a.getFullYear() - 1900;
N[b + 24 >> 2] = a.getDay();
var d = new Date(a.getFullYear(), 0, 1);
N[b + 28 >> 2] = (a.getTime() - d.getTime()) / 864E5 | 0;
N[b + 36 >> 2] = -(60 * a.getTimezoneOffset());
var e = new Date(a.getFullYear(), 6, 1).getTimezoneOffset();
d = d.getTimezoneOffset();
N[b + 32 >> 2] = (e != d && a.getTimezoneOffset() == Math.min(d, e)) | 0;
}, f: W, b: function () {
w("");
}, h: ma, g: function (a, b) {
a = G(a);
let d;
try {
d = window.JSON.parse(a);
} catch (e) {
d = a;
}
0 !== b ? window.alert(a) : window.console.log("DUMP", d);
}, j: function (a) {
var b = C.length;
a >>>= 0;
if (2147483648 < a) return !1;
for (var d = 1; 4 >= d; d *= 2) {
var e = b * (1 + .2 / d);
e = Math.min(e, a + 100663296);
var f = Math;
e = Math.max(a, e);
f = f.min.call(f, 2147483648, e + (65536 - e % 65536) % 65536);
a:{
try {
x.grow(f - M.byteLength + 65535 >>> 16);
ba();
var g = 1;
break a;
} catch (k) {
}
g = void 0;
}
if (g) return !0;
}
return !1;
}, c: function (a, b, d, e) {
for (var f = 0, g = 0; g < d; g++) {
var k = N[b >> 2], m = N[b + 4 >> 2];
b += 8;
for (var q = 0; q < m; q++) {
var l = C[k + q], p = na[a];
0 === l || 10 === l ? ((1 === a ? aa : u)(I(p, 0)), p.length = 0) : p.push(l);
}
f += m;
}
N[e >> 2] = f;
return 0;
}, k: function (a) {
a = G(a);
window.console.log(a);
}, i: function (a) {
a = G(a);
return Date.parse(a);
}, l: function (a, b, d, e) {
a = G(a);
b = G(b);
d = G(d);
d = `Quickjs -- ${a}: ${b}\n${d}`;
0 !== e ? window.alert(d) : window.console.error(d);
}
};
(function () {
function a(f) {
c.asm = f.exports;
x = c.asm.m;
ba();
O = c.asm.v;
da.unshift(c.asm.n);
P--;
c.monitorRunDependencies && c.monitorRunDependencies(P);
0 == P && (null !== Q && (clearInterval(Q), Q = null), R && (f = R, R = null, f()));
}
function b(f) {
a(f.instance);
}
function d(f) {
return ka().then(function (g) {
return WebAssembly.instantiate(g, e);
}).then(function (g) {
return g;
}).then(f, function (g) {
u("failed to asynchronously prepare wasm: " + g);
w(g);
});
}
var e = {a: oa};
P++;
c.monitorRunDependencies && c.monitorRunDependencies(P);
if (c.instantiateWasm) try {
return c.instantiateWasm(e, a);
} catch (f) {
return u("Module.instantiateWasm callback failed with error: " + f), !1;
}
(function () {
return v || "function" != typeof WebAssembly.instantiateStreaming || T(U) || "function" != typeof fetch ? d(b) : fetch(U, {credentials: "same-origin"}).then(function (f) {
return WebAssembly.instantiateStreaming(f, e).then(b, function (g) {
u("wasm streaming compile failed: " + g);
u("falling back to ArrayBuffer instantiation");
return d(b);
});
});
})().catch(n);
return {};
})();
c.___wasm_call_ctors = function () {
return (c.___wasm_call_ctors = c.asm.n).apply(null, arguments);
};
c._evalInSandbox = function () {
return (c._evalInSandbox = c.asm.o).apply(null, arguments);
};
c._nukeSandbox = function () {
return (c._nukeSandbox = c.asm.p).apply(null, arguments);
};
c._init = function () {
return (c._init = c.asm.q).apply(null, arguments);
};
c._commFun = function () {
return (c._commFun = c.asm.r).apply(null, arguments);
};
c._dumpMemoryUse = function () {
return (c._dumpMemoryUse = c.asm.s).apply(null, arguments);
};
var L = c._malloc = function () {
return (L = c._malloc = c.asm.t).apply(null, arguments);
};
c._free = function () {
return (c._free = c.asm.u).apply(null, arguments);
};
var E = c.stackSave = function () {
return (E = c.stackSave = c.asm.w).apply(null, arguments);
}, F = c.stackRestore = function () {
return (F = c.stackRestore = c.asm.x).apply(null, arguments);
}, A = c.stackAlloc = function () {
return (A = c.stackAlloc = c.asm.y).apply(null, arguments);
};
c.ccall = z;
c.cwrap = function (a, b, d, e) {
d = d || [];
var f = d.every(function (g) {
return "number" === g;
});
return "string" !== b && f && !e ? c["_" + a] : function () {
return z(a, b, d, arguments, e);
};
};
c.stringToNewUTF8 = X;
var Y;
R = function pa() {
Y || Z();
Y || (R = pa);
};
function Z() {
function a() {
if (!Y && (Y = !0, c.calledRun = !0, !y)) {
V(da);
h(c);
if (c.onRuntimeInitialized) c.onRuntimeInitialized();
if (c.postRun) for ("function" == typeof c.postRun && (c.postRun = [c.postRun]); c.postRun.length;) {
var b = c.postRun.shift();
ea.unshift(b);
}
V(ea);
}
}
if (!(0 < P)) {
if (c.preRun) for ("function" == typeof c.preRun && (c.preRun = [c.preRun]); c.preRun.length;) fa();
V(ca);
0 < P || (c.setStatus ? (c.setStatus("Running..."), setTimeout(function () {
setTimeout(function () {
c.setStatus("");
}, 1);
a();
}, 1)) : a());
}
}
c.run = Z;
if (c.preInit) for ("function" == typeof c.preInit && (c.preInit = [c.preInit]); 0 < c.preInit.length;) c.preInit.pop()();
Z();
return Module.ready;
};
})();
var _default = Module;
exports["default"] = _default;
/***/
}),
/* 2 */
/***/ ((__unused_webpack_module, exports) => {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.SandboxSupportBase = void 0;
class SandboxSupportBase {
constructor(win) {
this.win = win;
this.timeoutIds = new Map();
this.commFun = null;
}
destroy() {
this.commFun = null;
for (const id of this.timeoutIds.values()) {
this.win.clearTimeout(id);
}
this.timeoutIds = null;
}
exportValueToSandbox(val) {
throw new Error("Not implemented");
}
importValueFromSandbox(val) {
throw new Error("Not implemented");
}
createErrorForSandbox(errorMessage) {
throw new Error("Not implemented");
}
callSandboxFunction(name, args) {
try {
args = this.exportValueToSandbox(args);
this.commFun(name, args);
} catch (e) {
this.win.console.error(e);
}
}
createSandboxExternals() {
const externals = {
setTimeout: (callbackId, nMilliseconds) => {
if (typeof callbackId !== "number" || typeof nMilliseconds !== "number") {
return;
}
if (callbackId === 0) {
this.win.clearTimeout(this.timeoutIds.get(callbackId));
}
const id = this.win.setTimeout(() => {
this.timeoutIds.delete(callbackId);
this.callSandboxFunction("timeoutCb", {
callbackId,
interval: false
});
}, nMilliseconds);
this.timeoutIds.set(callbackId, id);
},
clearTimeout: callbackId => {
this.win.clearTimeout(this.timeoutIds.get(callbackId));
this.timeoutIds.delete(callbackId);
},
setInterval: (callbackId, nMilliseconds) => {
if (typeof callbackId !== "number" || typeof nMilliseconds !== "number") {
return;
}
const id = this.win.setInterval(() => {
this.callSandboxFunction("timeoutCb", {
callbackId,
interval: true
});
}, nMilliseconds);
this.timeoutIds.set(callbackId, id);
},
clearInterval: callbackId => {
this.win.clearInterval(this.timeoutIds.get(callbackId));
this.timeoutIds.delete(callbackId);
},
alert: cMsg => {
if (typeof cMsg !== "string") {
return;
}
this.win.alert(cMsg);
},
confirm: cMsg => {
if (typeof cMsg !== "string") {
return false;
}
return this.win.confirm(cMsg);
},
prompt: (cQuestion, cDefault) => {
if (typeof cQuestion !== "string" || typeof cDefault !== "string") {
return null;
}
return this.win.prompt(cQuestion, cDefault);
},
parseURL: cUrl => {
const url = new this.win.URL(cUrl);
const props = ["hash", "host", "hostname", "href", "origin", "password", "pathname", "port", "protocol", "search", "searchParams", "username"];
return Object.fromEntries(props.map(name => [name, url[name].toString()]));
},
send: data => {
if (!data) {
return;
}
const event = new this.win.CustomEvent("updatefromsandbox", {
detail: this.importValueFromSandbox(data)
});
this.win.dispatchEvent(event);
}
};
Object.setPrototypeOf(externals, null);
return (name, args) => {
try {
const result = externals[name](...args);
return this.exportValueToSandbox(result);
} catch (error) {
throw this.createErrorForSandbox(error?.toString() ?? "");
}
};
}
}
exports.SandboxSupportBase = SandboxSupportBase;
/***/
})
/******/]);
/************************************************************************/
/******/ // The module cache
/******/
var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/
function __w_pdfjs_require__(moduleId) {
/******/ // Check if module is in cache
/******/
var cachedModule = __webpack_module_cache__[moduleId];
/******/
if (cachedModule !== undefined) {
/******/
return cachedModule.exports;
/******/
}
/******/ // Create a new module (and put it into the cache)
/******/
var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/
};
/******/
/******/ // Execute the module function
/******/
__webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__);
/******/
/******/ // Return the exports of the module
/******/
return module.exports;
/******/
}
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.QuickJSSandbox = QuickJSSandbox;
var _quickjsEval = _interopRequireDefault(__w_pdfjs_require__(1));
var _pdfSandboxExternal = __w_pdfjs_require__(2);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
const pdfjsVersion = '3.11.174';
const pdfjsBuild = 'ce8716743';
class SandboxSupport extends _pdfSandboxExternal.SandboxSupportBase {
exportValueToSandbox(val) {
return JSON.stringify(val);
}
importValueFromSandbox(val) {
return val;
}
createErrorForSandbox(errorMessage) {
return new Error(errorMessage);
}
}
class Sandbox {
constructor(win, module) {
this.support = new SandboxSupport(win, this);
module.externalCall = this.support.createSandboxExternals();
this._module = module;
this._alertOnError = 0;
}
create(data) {
const code = ['(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === \'object\' && typeof module === \'object\')\n\t\tmodule.exports = root.pdfjsScripting = factory();\n\telse if(typeof define === \'function\' && define.amd)\n\t\tdefine("pdfjs-dist/build/pdf.scripting", [], () => { return (root.pdfjsScripting = factory()); });\n\telse if(typeof exports === \'object\')\n\t\texports["pdfjs-dist/build/pdf.scripting"] = root.pdfjsScripting = factory();\n\telse\n\t\troot["pdfjs-dist/build/pdf.scripting"] = root.pdfjsScripting = factory();\n})(globalThis, () => {\nreturn /******/ (() => { // webpackBootstrap\n/******/ \t"use strict";\n/******/ \tvar __webpack_modules__ = ([\n/* 0 */,\n/* 1 */\n/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {\n\n\n\nObject.defineProperty(exports, "__esModule", ({\n value: true\n}));\nexports.initSandbox = initSandbox;\nvar _constants = __w_pdfjs_require__(2);\nvar _field = __w_pdfjs_require__(3);\nvar _aform = __w_pdfjs_require__(8);\nvar _app = __w_pdfjs_require__(9);\nvar _color = __w_pdfjs_require__(5);\nvar _console = __w_pdfjs_require__(14);\nvar _doc = __w_pdfjs_require__(15);\nvar _proxy = __w_pdfjs_require__(17);\nvar _app_utils = __w_pdfjs_require__(10);\nvar _util = __w_pdfjs_require__(18);\nfunction initSandbox(params) {\n delete globalThis.pdfjsScripting;\n const externalCall = globalThis.callExternalFunction;\n delete globalThis.callExternalFunction;\n const globalEval = code => globalThis.eval(code);\n const send = data => externalCall("send", [data]);\n const proxyHandler = new _proxy.ProxyHandler();\n const {\n data\n } = params;\n const doc = new _doc.Doc({\n send,\n globalEval,\n ...data.docInfo\n });\n const _document = {\n obj: doc,\n wrapped: new Proxy(doc, proxyHandler)\n };\n const app = new _app.App({\n send,\n globalEval,\n externalCall,\n _document,\n calculationOrder: data.calculationOrder,\n proxyHandler,\n ...data.appInfo\n });\n const util = new _util.Util({\n externalCall\n });\n const appObjects = app._objects;\n if (data.objects) {\n const annotations = [];\n for (const [name, objs] of Object.entries(data.objects)) {\n annotations.length = 0;\n let container = null;\n for (const obj of objs) {\n if (obj.type !== "") {\n annotations.push(obj);\n } else {\n container = obj;\n }\n }\n let obj = container;\n if (annotations.length > 0) {\n obj = annotations[0];\n obj.send = send;\n }\n obj.globalEval = globalEval;\n obj.doc = _document;\n obj.fieldPath = name;\n obj.appObjects = appObjects;\n let field;\n switch (obj.type) {\n case "radiobutton":\n {\n const otherButtons = annotations.slice(1);\n field = new _field.RadioButtonField(otherButtons, obj);\n break;\n }\n case "checkbox":\n {\n const otherButtons = annotations.slice(1);\n field = new _field.CheckboxField(otherButtons, obj);\n break;\n }\n case "text":\n if (annotations.length <= 1) {\n field = new _field.Field(obj);\n break;\n }\n obj.siblings = annotations.map(x => x.id).slice(1);\n field = new _field.Field(obj);\n break;\n default:\n field = new _field.Field(obj);\n }\n const wrapped = new Proxy(field, proxyHandler);\n const _object = {\n obj: field,\n wrapped\n };\n doc._addField(name, _object);\n for (const object of objs) {\n appObjects[object.id] = _object;\n }\n if (container) {\n appObjects[container.id] = _object;\n }\n }\n }\n const color = new _color.Color();\n globalThis.event = null;\n globalThis.global = Object.create(null);\n globalThis.app = new Proxy(app, proxyHandler);\n globalThis.color = new Proxy(color, proxyHandler);\n globalThis.console = new Proxy
code.push("delete dump;");
let success = false;
let buf = 0;
try {
const sandboxData = JSON.stringify(data);
code.push(`pdfjsScripting.initSandbox({ data: ${sandboxData} })`);
buf = this._module.stringToNewUTF8(code.join("\n"));
success = !!this._module.ccall("init", "number", ["number", "number"], [buf, this._alertOnError]);
} catch (error) {
console.error(error);
} finally {
if (buf) {
this._module.ccall("free", "number", ["number"], [buf]);
}
}
if (success) {
this.support.commFun = this._module.cwrap("commFun", null, ["string", "string"]);
} else {
this.nukeSandbox();
throw new Error("Cannot start sandbox");
}
}
dispatchEvent(event) {
this.support?.callSandboxFunction("dispatchEvent", event);
}
dumpMemoryUse() {
this._module?.ccall("dumpMemoryUse", null, []);
}
nukeSandbox() {
if (this._module !== null) {
this.support.destroy();
this.support = null;
this._module.ccall("nukeSandbox", null, []);
this._module = null;
}
}
evalForTesting(code, key) {
throw new Error("Not implemented: evalForTesting");
}
}
function QuickJSSandbox() {
return (0, _quickjsEval.default)().then(module => {
return new Sandbox(window, module);
});
}
})();
/******/
return __webpack_exports__;
/******/
})()
;
});
//# sourceMappingURL=pdf.sandbox.js.map