@shotstack/shotstack-canvas 1.4.6 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-HYGMWVDX.js +19 -0
- package/dist/entry.node.cjs +36 -15
- package/dist/entry.node.js +36 -15
- package/dist/entry.web.js +39 -18
- package/dist/hb-KXF2MJ2J.js +550 -0
- package/dist/hbjs-ZTRARROF.js +499 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
+
}) : x)(function(x) {
|
|
7
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
+
});
|
|
10
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
__require,
|
|
17
|
+
__commonJS,
|
|
18
|
+
__publicField
|
|
19
|
+
};
|
package/dist/entry.node.cjs
CHANGED
|
@@ -293,6 +293,23 @@ function setupWasmInterceptors(wasmBinary) {
|
|
|
293
293
|
}
|
|
294
294
|
return originalFetch.apply(this, [input, init]);
|
|
295
295
|
};
|
|
296
|
+
const originalInstantiate = WebAssembly.instantiate;
|
|
297
|
+
WebAssembly.instantiate = async function(bufferSourceOrModule, importObject) {
|
|
298
|
+
console.log(
|
|
299
|
+
`\u{1F504} WebAssembly.instantiate called, type: ${bufferSourceOrModule instanceof WebAssembly.Module ? "Module" : "BufferSource"}`
|
|
300
|
+
);
|
|
301
|
+
if (bufferSourceOrModule instanceof WebAssembly.Module) {
|
|
302
|
+
return originalInstantiate.call(WebAssembly, bufferSourceOrModule, importObject);
|
|
303
|
+
}
|
|
304
|
+
console.log(`\u{1F504} Intercepted WebAssembly.instantiate, using pre-loaded WASM binary`);
|
|
305
|
+
const module2 = await WebAssembly.compile(wasmBinary);
|
|
306
|
+
const instance = await originalInstantiate.call(
|
|
307
|
+
WebAssembly,
|
|
308
|
+
module2,
|
|
309
|
+
importObject
|
|
310
|
+
);
|
|
311
|
+
return { module: module2, instance };
|
|
312
|
+
};
|
|
296
313
|
const originalInstantiateStreaming = WebAssembly.instantiateStreaming;
|
|
297
314
|
if (originalInstantiateStreaming) {
|
|
298
315
|
WebAssembly.instantiateStreaming = async function(source, importObject) {
|
|
@@ -330,21 +347,25 @@ async function initHB(wasmBaseURL) {
|
|
|
330
347
|
console.log(`\u2705 WASM binary loaded successfully (${wasmBinary.byteLength} bytes)`);
|
|
331
348
|
if (!isNode()) {
|
|
332
349
|
setupWasmInterceptors(wasmBinary);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
}
|
|
350
|
+
window.Module = {
|
|
351
|
+
wasmBinary,
|
|
352
|
+
locateFile: (path) => {
|
|
353
|
+
console.log(`\u{1F50D} locateFile called for: ${path}`);
|
|
354
|
+
return path;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
console.log(`\u{1F30D} Set global Module.wasmBinary (${wasmBinary.byteLength} bytes)`);
|
|
358
|
+
}
|
|
359
|
+
console.log("\u{1F504} Importing harfbuzzjs/hb.js (factory)");
|
|
360
|
+
const hbModule = await import("harfbuzzjs/hb.js");
|
|
361
|
+
const hbFactory = hbModule.default || hbModule;
|
|
362
|
+
console.log("\u{1F504} Calling hb factory with wasmBinary");
|
|
363
|
+
const hbInstance = await hbFactory({ wasmBinary });
|
|
364
|
+
console.log("\u{1F504} Importing harfbuzzjs/hbjs.js (wrapper)");
|
|
365
|
+
const hbjsModule = await import("harfbuzzjs/hbjs.js");
|
|
366
|
+
const hbjsWrapper = hbjsModule.default || hbjsModule;
|
|
367
|
+
console.log("\u{1F504} Wrapping hb instance");
|
|
368
|
+
const hb = hbjsWrapper(hbInstance);
|
|
348
369
|
if (!hb || typeof hb.createBuffer !== "function" || typeof hb.createFont !== "function") {
|
|
349
370
|
throw new Error("Failed to initialize HarfBuzz: unexpected export shape from 'harfbuzzjs'.");
|
|
350
371
|
}
|
package/dist/entry.node.js
CHANGED
|
@@ -254,6 +254,23 @@ function setupWasmInterceptors(wasmBinary) {
|
|
|
254
254
|
}
|
|
255
255
|
return originalFetch.apply(this, [input, init]);
|
|
256
256
|
};
|
|
257
|
+
const originalInstantiate = WebAssembly.instantiate;
|
|
258
|
+
WebAssembly.instantiate = async function(bufferSourceOrModule, importObject) {
|
|
259
|
+
console.log(
|
|
260
|
+
`\u{1F504} WebAssembly.instantiate called, type: ${bufferSourceOrModule instanceof WebAssembly.Module ? "Module" : "BufferSource"}`
|
|
261
|
+
);
|
|
262
|
+
if (bufferSourceOrModule instanceof WebAssembly.Module) {
|
|
263
|
+
return originalInstantiate.call(WebAssembly, bufferSourceOrModule, importObject);
|
|
264
|
+
}
|
|
265
|
+
console.log(`\u{1F504} Intercepted WebAssembly.instantiate, using pre-loaded WASM binary`);
|
|
266
|
+
const module = await WebAssembly.compile(wasmBinary);
|
|
267
|
+
const instance = await originalInstantiate.call(
|
|
268
|
+
WebAssembly,
|
|
269
|
+
module,
|
|
270
|
+
importObject
|
|
271
|
+
);
|
|
272
|
+
return { module, instance };
|
|
273
|
+
};
|
|
257
274
|
const originalInstantiateStreaming = WebAssembly.instantiateStreaming;
|
|
258
275
|
if (originalInstantiateStreaming) {
|
|
259
276
|
WebAssembly.instantiateStreaming = async function(source, importObject) {
|
|
@@ -291,21 +308,25 @@ async function initHB(wasmBaseURL) {
|
|
|
291
308
|
console.log(`\u2705 WASM binary loaded successfully (${wasmBinary.byteLength} bytes)`);
|
|
292
309
|
if (!isNode()) {
|
|
293
310
|
setupWasmInterceptors(wasmBinary);
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
}
|
|
311
|
+
window.Module = {
|
|
312
|
+
wasmBinary,
|
|
313
|
+
locateFile: (path) => {
|
|
314
|
+
console.log(`\u{1F50D} locateFile called for: ${path}`);
|
|
315
|
+
return path;
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
console.log(`\u{1F30D} Set global Module.wasmBinary (${wasmBinary.byteLength} bytes)`);
|
|
319
|
+
}
|
|
320
|
+
console.log("\u{1F504} Importing harfbuzzjs/hb.js (factory)");
|
|
321
|
+
const hbModule = await import("harfbuzzjs/hb.js");
|
|
322
|
+
const hbFactory = hbModule.default || hbModule;
|
|
323
|
+
console.log("\u{1F504} Calling hb factory with wasmBinary");
|
|
324
|
+
const hbInstance = await hbFactory({ wasmBinary });
|
|
325
|
+
console.log("\u{1F504} Importing harfbuzzjs/hbjs.js (wrapper)");
|
|
326
|
+
const hbjsModule = await import("harfbuzzjs/hbjs.js");
|
|
327
|
+
const hbjsWrapper = hbjsModule.default || hbjsModule;
|
|
328
|
+
console.log("\u{1F504} Wrapping hb instance");
|
|
329
|
+
const hb = hbjsWrapper(hbInstance);
|
|
309
330
|
if (!hb || typeof hb.createBuffer !== "function" || typeof hb.createFont !== "function") {
|
|
310
331
|
throw new Error("Failed to initialize HarfBuzz: unexpected export shape from 'harfbuzzjs'.");
|
|
311
332
|
}
|
package/dist/entry.web.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
__publicField
|
|
3
|
+
} from "./chunk-HYGMWVDX.js";
|
|
4
4
|
|
|
5
5
|
// src/schema/asset-schema.ts
|
|
6
6
|
import Joi from "joi";
|
|
@@ -258,6 +258,23 @@ function setupWasmInterceptors(wasmBinary) {
|
|
|
258
258
|
}
|
|
259
259
|
return originalFetch.apply(this, [input, init]);
|
|
260
260
|
};
|
|
261
|
+
const originalInstantiate = WebAssembly.instantiate;
|
|
262
|
+
WebAssembly.instantiate = async function(bufferSourceOrModule, importObject) {
|
|
263
|
+
console.log(
|
|
264
|
+
`\u{1F504} WebAssembly.instantiate called, type: ${bufferSourceOrModule instanceof WebAssembly.Module ? "Module" : "BufferSource"}`
|
|
265
|
+
);
|
|
266
|
+
if (bufferSourceOrModule instanceof WebAssembly.Module) {
|
|
267
|
+
return originalInstantiate.call(WebAssembly, bufferSourceOrModule, importObject);
|
|
268
|
+
}
|
|
269
|
+
console.log(`\u{1F504} Intercepted WebAssembly.instantiate, using pre-loaded WASM binary`);
|
|
270
|
+
const module = await WebAssembly.compile(wasmBinary);
|
|
271
|
+
const instance = await originalInstantiate.call(
|
|
272
|
+
WebAssembly,
|
|
273
|
+
module,
|
|
274
|
+
importObject
|
|
275
|
+
);
|
|
276
|
+
return { module, instance };
|
|
277
|
+
};
|
|
261
278
|
const originalInstantiateStreaming = WebAssembly.instantiateStreaming;
|
|
262
279
|
if (originalInstantiateStreaming) {
|
|
263
280
|
WebAssembly.instantiateStreaming = async function(source, importObject) {
|
|
@@ -295,21 +312,25 @@ async function initHB(wasmBaseURL) {
|
|
|
295
312
|
console.log(`\u2705 WASM binary loaded successfully (${wasmBinary.byteLength} bytes)`);
|
|
296
313
|
if (!isNode()) {
|
|
297
314
|
setupWasmInterceptors(wasmBinary);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
}
|
|
315
|
+
window.Module = {
|
|
316
|
+
wasmBinary,
|
|
317
|
+
locateFile: (path) => {
|
|
318
|
+
console.log(`\u{1F50D} locateFile called for: ${path}`);
|
|
319
|
+
return path;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
console.log(`\u{1F30D} Set global Module.wasmBinary (${wasmBinary.byteLength} bytes)`);
|
|
323
|
+
}
|
|
324
|
+
console.log("\u{1F504} Importing harfbuzzjs/hb.js (factory)");
|
|
325
|
+
const hbModule = await import("./hb-KXF2MJ2J.js");
|
|
326
|
+
const hbFactory = hbModule.default || hbModule;
|
|
327
|
+
console.log("\u{1F504} Calling hb factory with wasmBinary");
|
|
328
|
+
const hbInstance = await hbFactory({ wasmBinary });
|
|
329
|
+
console.log("\u{1F504} Importing harfbuzzjs/hbjs.js (wrapper)");
|
|
330
|
+
const hbjsModule = await import("./hbjs-ZTRARROF.js");
|
|
331
|
+
const hbjsWrapper = hbjsModule.default || hbjsModule;
|
|
332
|
+
console.log("\u{1F504} Wrapping hb instance");
|
|
333
|
+
const hb = hbjsWrapper(hbInstance);
|
|
313
334
|
if (!hb || typeof hb.createBuffer !== "function" || typeof hb.createFont !== "function") {
|
|
314
335
|
throw new Error("Failed to initialize HarfBuzz: unexpected export shape from 'harfbuzzjs'.");
|
|
315
336
|
}
|
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__publicField,
|
|
4
|
+
__require
|
|
5
|
+
} from "./chunk-HYGMWVDX.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/harfbuzzjs/hb.js
|
|
8
|
+
var require_hb = __commonJS({
|
|
9
|
+
"node_modules/harfbuzzjs/hb.js"(exports, module) {
|
|
10
|
+
var createHarfBuzz = (() => {
|
|
11
|
+
var _scriptName = typeof document != "undefined" ? document.currentScript?.src : void 0;
|
|
12
|
+
return async function(moduleArg = {}) {
|
|
13
|
+
var moduleRtn;
|
|
14
|
+
var Module = moduleArg;
|
|
15
|
+
var ENVIRONMENT_IS_WEB = typeof window == "object";
|
|
16
|
+
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != "undefined";
|
|
17
|
+
var ENVIRONMENT_IS_NODE = typeof process == "object" && process.versions?.node && process.type != "renderer";
|
|
18
|
+
var arguments_ = [];
|
|
19
|
+
var thisProgram = "./this.program";
|
|
20
|
+
var quit_ = (status, toThrow) => {
|
|
21
|
+
throw toThrow;
|
|
22
|
+
};
|
|
23
|
+
if (typeof __filename != "undefined") {
|
|
24
|
+
_scriptName = __filename;
|
|
25
|
+
} else if (ENVIRONMENT_IS_WORKER) {
|
|
26
|
+
_scriptName = self.location.href;
|
|
27
|
+
}
|
|
28
|
+
var scriptDirectory = "";
|
|
29
|
+
function locateFile(path) {
|
|
30
|
+
if (Module["locateFile"]) {
|
|
31
|
+
return Module["locateFile"](path, scriptDirectory);
|
|
32
|
+
}
|
|
33
|
+
return scriptDirectory + path;
|
|
34
|
+
}
|
|
35
|
+
var readAsync, readBinary;
|
|
36
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
37
|
+
var fs = __require("fs");
|
|
38
|
+
scriptDirectory = __dirname + "/";
|
|
39
|
+
readBinary = (filename) => {
|
|
40
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
41
|
+
var ret = fs.readFileSync(filename);
|
|
42
|
+
return ret;
|
|
43
|
+
};
|
|
44
|
+
readAsync = async (filename, binary = true) => {
|
|
45
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
46
|
+
var ret = fs.readFileSync(filename, binary ? void 0 : "utf8");
|
|
47
|
+
return ret;
|
|
48
|
+
};
|
|
49
|
+
if (process.argv.length > 1) {
|
|
50
|
+
thisProgram = process.argv[1].replace(/\\/g, "/");
|
|
51
|
+
}
|
|
52
|
+
arguments_ = process.argv.slice(2);
|
|
53
|
+
quit_ = (status, toThrow) => {
|
|
54
|
+
process.exitCode = status;
|
|
55
|
+
throw toThrow;
|
|
56
|
+
};
|
|
57
|
+
} else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
58
|
+
try {
|
|
59
|
+
scriptDirectory = new URL(".", _scriptName).href;
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
{
|
|
63
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
64
|
+
readBinary = (url) => {
|
|
65
|
+
var xhr = new XMLHttpRequest();
|
|
66
|
+
xhr.open("GET", url, false);
|
|
67
|
+
xhr.responseType = "arraybuffer";
|
|
68
|
+
xhr.send(null);
|
|
69
|
+
return new Uint8Array(xhr.response);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
readAsync = async (url) => {
|
|
73
|
+
if (isFileURI(url)) {
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
var xhr = new XMLHttpRequest();
|
|
76
|
+
xhr.open("GET", url, true);
|
|
77
|
+
xhr.responseType = "arraybuffer";
|
|
78
|
+
xhr.onload = () => {
|
|
79
|
+
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
80
|
+
resolve(xhr.response);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
reject(xhr.status);
|
|
84
|
+
};
|
|
85
|
+
xhr.onerror = reject;
|
|
86
|
+
xhr.send(null);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
var response = await fetch(url, { credentials: "same-origin" });
|
|
90
|
+
if (response.ok) {
|
|
91
|
+
return response.arrayBuffer();
|
|
92
|
+
}
|
|
93
|
+
throw new Error(response.status + " : " + response.url);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
}
|
|
98
|
+
var out = console.log.bind(console);
|
|
99
|
+
var err = console.error.bind(console);
|
|
100
|
+
var wasmBinary;
|
|
101
|
+
var ABORT = false;
|
|
102
|
+
var EXITSTATUS;
|
|
103
|
+
var isFileURI = (filename) => filename.startsWith("file://");
|
|
104
|
+
var readyPromiseResolve, readyPromiseReject;
|
|
105
|
+
var wasmMemory;
|
|
106
|
+
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
|
|
107
|
+
var HEAP64, HEAPU64;
|
|
108
|
+
var runtimeInitialized = false;
|
|
109
|
+
function updateMemoryViews() {
|
|
110
|
+
var b = wasmMemory.buffer;
|
|
111
|
+
Module["HEAP8"] = HEAP8 = new Int8Array(b);
|
|
112
|
+
HEAP16 = new Int16Array(b);
|
|
113
|
+
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
|
|
114
|
+
HEAPU16 = new Uint16Array(b);
|
|
115
|
+
Module["HEAP32"] = HEAP32 = new Int32Array(b);
|
|
116
|
+
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
|
|
117
|
+
Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
|
|
118
|
+
HEAPF64 = new Float64Array(b);
|
|
119
|
+
HEAP64 = new BigInt64Array(b);
|
|
120
|
+
HEAPU64 = new BigUint64Array(b);
|
|
121
|
+
}
|
|
122
|
+
function preRun() {
|
|
123
|
+
if (Module["preRun"]) {
|
|
124
|
+
if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
|
|
125
|
+
while (Module["preRun"].length) {
|
|
126
|
+
addOnPreRun(Module["preRun"].shift());
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
callRuntimeCallbacks(onPreRuns);
|
|
130
|
+
}
|
|
131
|
+
function initRuntime() {
|
|
132
|
+
runtimeInitialized = true;
|
|
133
|
+
wasmExports["__wasm_call_ctors"]();
|
|
134
|
+
}
|
|
135
|
+
function postRun() {
|
|
136
|
+
if (Module["postRun"]) {
|
|
137
|
+
if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
|
|
138
|
+
while (Module["postRun"].length) {
|
|
139
|
+
addOnPostRun(Module["postRun"].shift());
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
callRuntimeCallbacks(onPostRuns);
|
|
143
|
+
}
|
|
144
|
+
var runDependencies = 0;
|
|
145
|
+
var dependenciesFulfilled = null;
|
|
146
|
+
function addRunDependency(id) {
|
|
147
|
+
runDependencies++;
|
|
148
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
149
|
+
}
|
|
150
|
+
function removeRunDependency(id) {
|
|
151
|
+
runDependencies--;
|
|
152
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
153
|
+
if (runDependencies == 0) {
|
|
154
|
+
if (dependenciesFulfilled) {
|
|
155
|
+
var callback = dependenciesFulfilled;
|
|
156
|
+
dependenciesFulfilled = null;
|
|
157
|
+
callback();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function abort(what) {
|
|
162
|
+
Module["onAbort"]?.(what);
|
|
163
|
+
what = "Aborted(" + what + ")";
|
|
164
|
+
err(what);
|
|
165
|
+
ABORT = true;
|
|
166
|
+
what += ". Build with -sASSERTIONS for more info.";
|
|
167
|
+
var e = new WebAssembly.RuntimeError(what);
|
|
168
|
+
readyPromiseReject?.(e);
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
var wasmBinaryFile;
|
|
172
|
+
function findWasmBinary() {
|
|
173
|
+
return locateFile("hb.wasm");
|
|
174
|
+
}
|
|
175
|
+
function getBinarySync(file) {
|
|
176
|
+
if (file == wasmBinaryFile && wasmBinary) {
|
|
177
|
+
return new Uint8Array(wasmBinary);
|
|
178
|
+
}
|
|
179
|
+
if (readBinary) {
|
|
180
|
+
return readBinary(file);
|
|
181
|
+
}
|
|
182
|
+
throw "both async and sync fetching of the wasm failed";
|
|
183
|
+
}
|
|
184
|
+
async function getWasmBinary(binaryFile) {
|
|
185
|
+
if (!wasmBinary) {
|
|
186
|
+
try {
|
|
187
|
+
var response = await readAsync(binaryFile);
|
|
188
|
+
return new Uint8Array(response);
|
|
189
|
+
} catch {
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return getBinarySync(binaryFile);
|
|
193
|
+
}
|
|
194
|
+
async function instantiateArrayBuffer(binaryFile, imports) {
|
|
195
|
+
try {
|
|
196
|
+
var binary = await getWasmBinary(binaryFile);
|
|
197
|
+
var instance = await WebAssembly.instantiate(binary, imports);
|
|
198
|
+
return instance;
|
|
199
|
+
} catch (reason) {
|
|
200
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
201
|
+
abort(reason);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async function instantiateAsync(binary, binaryFile, imports) {
|
|
205
|
+
if (!binary && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE) {
|
|
206
|
+
try {
|
|
207
|
+
var response = fetch(binaryFile, { credentials: "same-origin" });
|
|
208
|
+
var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
|
|
209
|
+
return instantiationResult;
|
|
210
|
+
} catch (reason) {
|
|
211
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
212
|
+
err("falling back to ArrayBuffer instantiation");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return instantiateArrayBuffer(binaryFile, imports);
|
|
216
|
+
}
|
|
217
|
+
function getWasmImports() {
|
|
218
|
+
return { env: wasmImports, wasi_snapshot_preview1: wasmImports };
|
|
219
|
+
}
|
|
220
|
+
async function createWasm() {
|
|
221
|
+
function receiveInstance(instance, module2) {
|
|
222
|
+
wasmExports = instance.exports;
|
|
223
|
+
Module["wasmExports"] = wasmExports;
|
|
224
|
+
wasmMemory = wasmExports["memory"];
|
|
225
|
+
Module["wasmMemory"] = wasmMemory;
|
|
226
|
+
updateMemoryViews();
|
|
227
|
+
wasmTable = wasmExports["__indirect_function_table"];
|
|
228
|
+
assignWasmExports(wasmExports);
|
|
229
|
+
removeRunDependency("wasm-instantiate");
|
|
230
|
+
return wasmExports;
|
|
231
|
+
}
|
|
232
|
+
addRunDependency("wasm-instantiate");
|
|
233
|
+
function receiveInstantiationResult(result2) {
|
|
234
|
+
return receiveInstance(result2["instance"]);
|
|
235
|
+
}
|
|
236
|
+
var info = getWasmImports();
|
|
237
|
+
if (Module["instantiateWasm"]) {
|
|
238
|
+
return new Promise((resolve, reject) => {
|
|
239
|
+
Module["instantiateWasm"](info, (mod, inst) => {
|
|
240
|
+
resolve(receiveInstance(mod, inst));
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
wasmBinaryFile ?? (wasmBinaryFile = findWasmBinary());
|
|
245
|
+
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
|
|
246
|
+
var exports2 = receiveInstantiationResult(result);
|
|
247
|
+
return exports2;
|
|
248
|
+
}
|
|
249
|
+
class ExitStatus {
|
|
250
|
+
constructor(status) {
|
|
251
|
+
__publicField(this, "name", "ExitStatus");
|
|
252
|
+
this.message = `Program terminated with exit(${status})`;
|
|
253
|
+
this.status = status;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
var callRuntimeCallbacks = (callbacks) => {
|
|
257
|
+
while (callbacks.length > 0) {
|
|
258
|
+
callbacks.shift()(Module);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var onPostRuns = [];
|
|
262
|
+
var addOnPostRun = (cb) => onPostRuns.push(cb);
|
|
263
|
+
var onPreRuns = [];
|
|
264
|
+
var addOnPreRun = (cb) => onPreRuns.push(cb);
|
|
265
|
+
var noExitRuntime = true;
|
|
266
|
+
var __abort_js = () => abort("");
|
|
267
|
+
var runtimeKeepaliveCounter = 0;
|
|
268
|
+
var __emscripten_runtime_keepalive_clear = () => {
|
|
269
|
+
noExitRuntime = false;
|
|
270
|
+
runtimeKeepaliveCounter = 0;
|
|
271
|
+
};
|
|
272
|
+
var timers = {};
|
|
273
|
+
var handleException = (e) => {
|
|
274
|
+
if (e instanceof ExitStatus || e == "unwind") {
|
|
275
|
+
return EXITSTATUS;
|
|
276
|
+
}
|
|
277
|
+
quit_(1, e);
|
|
278
|
+
};
|
|
279
|
+
var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
|
|
280
|
+
var _proc_exit = (code) => {
|
|
281
|
+
EXITSTATUS = code;
|
|
282
|
+
if (!keepRuntimeAlive()) {
|
|
283
|
+
Module["onExit"]?.(code);
|
|
284
|
+
ABORT = true;
|
|
285
|
+
}
|
|
286
|
+
quit_(code, new ExitStatus(code));
|
|
287
|
+
};
|
|
288
|
+
var exitJS = (status, implicit) => {
|
|
289
|
+
EXITSTATUS = status;
|
|
290
|
+
_proc_exit(status);
|
|
291
|
+
};
|
|
292
|
+
var _exit = exitJS;
|
|
293
|
+
var maybeExit = () => {
|
|
294
|
+
if (!keepRuntimeAlive()) {
|
|
295
|
+
try {
|
|
296
|
+
_exit(EXITSTATUS);
|
|
297
|
+
} catch (e) {
|
|
298
|
+
handleException(e);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
var callUserCallback = (func) => {
|
|
303
|
+
if (ABORT) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
func();
|
|
308
|
+
maybeExit();
|
|
309
|
+
} catch (e) {
|
|
310
|
+
handleException(e);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
var _emscripten_get_now = () => performance.now();
|
|
314
|
+
var __setitimer_js = (which, timeout_ms) => {
|
|
315
|
+
if (timers[which]) {
|
|
316
|
+
clearTimeout(timers[which].id);
|
|
317
|
+
delete timers[which];
|
|
318
|
+
}
|
|
319
|
+
if (!timeout_ms) return 0;
|
|
320
|
+
var id = setTimeout(() => {
|
|
321
|
+
delete timers[which];
|
|
322
|
+
callUserCallback(() => __emscripten_timeout(which, _emscripten_get_now()));
|
|
323
|
+
}, timeout_ms);
|
|
324
|
+
timers[which] = { id, timeout_ms };
|
|
325
|
+
return 0;
|
|
326
|
+
};
|
|
327
|
+
var getHeapMax = () => 2147483648;
|
|
328
|
+
var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
|
|
329
|
+
var growMemory = (size) => {
|
|
330
|
+
var oldHeapSize = wasmMemory.buffer.byteLength;
|
|
331
|
+
var pages = (size - oldHeapSize + 65535) / 65536 | 0;
|
|
332
|
+
try {
|
|
333
|
+
wasmMemory.grow(pages);
|
|
334
|
+
updateMemoryViews();
|
|
335
|
+
return 1;
|
|
336
|
+
} catch (e) {
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
var _emscripten_resize_heap = (requestedSize) => {
|
|
340
|
+
var oldSize = HEAPU8.length;
|
|
341
|
+
requestedSize >>>= 0;
|
|
342
|
+
var maxHeapSize = getHeapMax();
|
|
343
|
+
if (requestedSize > maxHeapSize) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
|
|
347
|
+
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
|
|
348
|
+
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
349
|
+
var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
350
|
+
var replacement = growMemory(newSize);
|
|
351
|
+
if (replacement) {
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return false;
|
|
356
|
+
};
|
|
357
|
+
var uleb128EncodeWithLen = (arr) => {
|
|
358
|
+
const n = arr.length;
|
|
359
|
+
return [n % 128 | 128, n >> 7, ...arr];
|
|
360
|
+
};
|
|
361
|
+
var wasmTypeCodes = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 };
|
|
362
|
+
var generateTypePack = (types) => uleb128EncodeWithLen(Array.from(types, (type) => {
|
|
363
|
+
var code = wasmTypeCodes[type];
|
|
364
|
+
return code;
|
|
365
|
+
}));
|
|
366
|
+
var convertJsFunctionToWasm = (func, sig) => {
|
|
367
|
+
var bytes = Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0, 1, ...uleb128EncodeWithLen([1, 96, ...generateTypePack(sig.slice(1)), ...generateTypePack(sig[0] === "v" ? "" : sig[0])]), 2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
|
|
368
|
+
var module2 = new WebAssembly.Module(bytes);
|
|
369
|
+
var instance = new WebAssembly.Instance(module2, { e: { f: func } });
|
|
370
|
+
var wrappedFunc = instance.exports["f"];
|
|
371
|
+
return wrappedFunc;
|
|
372
|
+
};
|
|
373
|
+
var wasmTable;
|
|
374
|
+
var getWasmTableEntry = (funcPtr) => wasmTable.get(funcPtr);
|
|
375
|
+
var updateTableMap = (offset, count) => {
|
|
376
|
+
if (functionsInTableMap) {
|
|
377
|
+
for (var i = offset; i < offset + count; i++) {
|
|
378
|
+
var item = getWasmTableEntry(i);
|
|
379
|
+
if (item) {
|
|
380
|
+
functionsInTableMap.set(item, i);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
var functionsInTableMap;
|
|
386
|
+
var getFunctionAddress = (func) => {
|
|
387
|
+
if (!functionsInTableMap) {
|
|
388
|
+
functionsInTableMap = /* @__PURE__ */ new WeakMap();
|
|
389
|
+
updateTableMap(0, wasmTable.length);
|
|
390
|
+
}
|
|
391
|
+
return functionsInTableMap.get(func) || 0;
|
|
392
|
+
};
|
|
393
|
+
var freeTableIndexes = [];
|
|
394
|
+
var getEmptyTableSlot = () => {
|
|
395
|
+
if (freeTableIndexes.length) {
|
|
396
|
+
return freeTableIndexes.pop();
|
|
397
|
+
}
|
|
398
|
+
return wasmTable["grow"](1);
|
|
399
|
+
};
|
|
400
|
+
var setWasmTableEntry = (idx, func) => wasmTable.set(idx, func);
|
|
401
|
+
var addFunction = (func, sig) => {
|
|
402
|
+
var rtn = getFunctionAddress(func);
|
|
403
|
+
if (rtn) {
|
|
404
|
+
return rtn;
|
|
405
|
+
}
|
|
406
|
+
var ret = getEmptyTableSlot();
|
|
407
|
+
try {
|
|
408
|
+
setWasmTableEntry(ret, func);
|
|
409
|
+
} catch (err2) {
|
|
410
|
+
if (!(err2 instanceof TypeError)) {
|
|
411
|
+
throw err2;
|
|
412
|
+
}
|
|
413
|
+
var wrapped = convertJsFunctionToWasm(func, sig);
|
|
414
|
+
setWasmTableEntry(ret, wrapped);
|
|
415
|
+
}
|
|
416
|
+
functionsInTableMap.set(func, ret);
|
|
417
|
+
return ret;
|
|
418
|
+
};
|
|
419
|
+
var removeFunction = (index) => {
|
|
420
|
+
functionsInTableMap.delete(getWasmTableEntry(index));
|
|
421
|
+
setWasmTableEntry(index, null);
|
|
422
|
+
freeTableIndexes.push(index);
|
|
423
|
+
};
|
|
424
|
+
{
|
|
425
|
+
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
|
|
426
|
+
if (Module["print"]) out = Module["print"];
|
|
427
|
+
if (Module["printErr"]) err = Module["printErr"];
|
|
428
|
+
if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
|
|
429
|
+
if (Module["arguments"]) arguments_ = Module["arguments"];
|
|
430
|
+
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
|
|
431
|
+
}
|
|
432
|
+
Module["wasmMemory"] = wasmMemory;
|
|
433
|
+
Module["wasmExports"] = wasmExports;
|
|
434
|
+
Module["addFunction"] = addFunction;
|
|
435
|
+
Module["removeFunction"] = removeFunction;
|
|
436
|
+
var _hb_blob_create, _hb_blob_destroy, _hb_blob_get_length, _hb_blob_get_data, _hb_buffer_serialize_glyphs, _hb_buffer_create, _hb_buffer_destroy, _hb_buffer_get_content_type, _hb_buffer_set_direction, _hb_buffer_set_script, _hb_buffer_set_language, _hb_buffer_set_flags, _hb_buffer_set_cluster_level, _hb_buffer_get_length, _hb_buffer_get_glyph_infos, _hb_buffer_get_glyph_positions, _hb_glyph_info_get_glyph_flags, _hb_buffer_guess_segment_properties, _hb_buffer_add_utf8, _hb_buffer_add_utf16, _hb_buffer_set_message_func, _hb_language_from_string, _hb_script_from_string, _hb_version, _hb_version_string, _hb_feature_from_string, _malloc, _free, _hb_draw_funcs_set_move_to_func, _hb_draw_funcs_set_line_to_func, _hb_draw_funcs_set_quadratic_to_func, _hb_draw_funcs_set_cubic_to_func, _hb_draw_funcs_set_close_path_func, _hb_draw_funcs_create, _hb_draw_funcs_destroy, _hb_face_create, _hb_face_destroy, _hb_face_reference_table, _hb_face_get_upem, _hb_face_collect_unicodes, _hb_font_draw_glyph, _hb_font_glyph_to_string, _hb_font_create, _hb_font_set_variations, _hb_font_destroy, _hb_font_set_scale, _hb_set_create, _hb_set_destroy, _hb_ot_var_get_axis_infos, _hb_set_get_population, _hb_set_next_many, _hb_shape, __emscripten_timeout;
|
|
437
|
+
function assignWasmExports(wasmExports2) {
|
|
438
|
+
Module["_hb_blob_create"] = _hb_blob_create = wasmExports2["hb_blob_create"];
|
|
439
|
+
Module["_hb_blob_destroy"] = _hb_blob_destroy = wasmExports2["hb_blob_destroy"];
|
|
440
|
+
Module["_hb_blob_get_length"] = _hb_blob_get_length = wasmExports2["hb_blob_get_length"];
|
|
441
|
+
Module["_hb_blob_get_data"] = _hb_blob_get_data = wasmExports2["hb_blob_get_data"];
|
|
442
|
+
Module["_hb_buffer_serialize_glyphs"] = _hb_buffer_serialize_glyphs = wasmExports2["hb_buffer_serialize_glyphs"];
|
|
443
|
+
Module["_hb_buffer_create"] = _hb_buffer_create = wasmExports2["hb_buffer_create"];
|
|
444
|
+
Module["_hb_buffer_destroy"] = _hb_buffer_destroy = wasmExports2["hb_buffer_destroy"];
|
|
445
|
+
Module["_hb_buffer_get_content_type"] = _hb_buffer_get_content_type = wasmExports2["hb_buffer_get_content_type"];
|
|
446
|
+
Module["_hb_buffer_set_direction"] = _hb_buffer_set_direction = wasmExports2["hb_buffer_set_direction"];
|
|
447
|
+
Module["_hb_buffer_set_script"] = _hb_buffer_set_script = wasmExports2["hb_buffer_set_script"];
|
|
448
|
+
Module["_hb_buffer_set_language"] = _hb_buffer_set_language = wasmExports2["hb_buffer_set_language"];
|
|
449
|
+
Module["_hb_buffer_set_flags"] = _hb_buffer_set_flags = wasmExports2["hb_buffer_set_flags"];
|
|
450
|
+
Module["_hb_buffer_set_cluster_level"] = _hb_buffer_set_cluster_level = wasmExports2["hb_buffer_set_cluster_level"];
|
|
451
|
+
Module["_hb_buffer_get_length"] = _hb_buffer_get_length = wasmExports2["hb_buffer_get_length"];
|
|
452
|
+
Module["_hb_buffer_get_glyph_infos"] = _hb_buffer_get_glyph_infos = wasmExports2["hb_buffer_get_glyph_infos"];
|
|
453
|
+
Module["_hb_buffer_get_glyph_positions"] = _hb_buffer_get_glyph_positions = wasmExports2["hb_buffer_get_glyph_positions"];
|
|
454
|
+
Module["_hb_glyph_info_get_glyph_flags"] = _hb_glyph_info_get_glyph_flags = wasmExports2["hb_glyph_info_get_glyph_flags"];
|
|
455
|
+
Module["_hb_buffer_guess_segment_properties"] = _hb_buffer_guess_segment_properties = wasmExports2["hb_buffer_guess_segment_properties"];
|
|
456
|
+
Module["_hb_buffer_add_utf8"] = _hb_buffer_add_utf8 = wasmExports2["hb_buffer_add_utf8"];
|
|
457
|
+
Module["_hb_buffer_add_utf16"] = _hb_buffer_add_utf16 = wasmExports2["hb_buffer_add_utf16"];
|
|
458
|
+
Module["_hb_buffer_set_message_func"] = _hb_buffer_set_message_func = wasmExports2["hb_buffer_set_message_func"];
|
|
459
|
+
Module["_hb_language_from_string"] = _hb_language_from_string = wasmExports2["hb_language_from_string"];
|
|
460
|
+
Module["_hb_script_from_string"] = _hb_script_from_string = wasmExports2["hb_script_from_string"];
|
|
461
|
+
Module["_hb_version"] = _hb_version = wasmExports2["hb_version"];
|
|
462
|
+
Module["_hb_version_string"] = _hb_version_string = wasmExports2["hb_version_string"];
|
|
463
|
+
Module["_hb_feature_from_string"] = _hb_feature_from_string = wasmExports2["hb_feature_from_string"];
|
|
464
|
+
Module["_malloc"] = _malloc = wasmExports2["malloc"];
|
|
465
|
+
Module["_free"] = _free = wasmExports2["free"];
|
|
466
|
+
Module["_hb_draw_funcs_set_move_to_func"] = _hb_draw_funcs_set_move_to_func = wasmExports2["hb_draw_funcs_set_move_to_func"];
|
|
467
|
+
Module["_hb_draw_funcs_set_line_to_func"] = _hb_draw_funcs_set_line_to_func = wasmExports2["hb_draw_funcs_set_line_to_func"];
|
|
468
|
+
Module["_hb_draw_funcs_set_quadratic_to_func"] = _hb_draw_funcs_set_quadratic_to_func = wasmExports2["hb_draw_funcs_set_quadratic_to_func"];
|
|
469
|
+
Module["_hb_draw_funcs_set_cubic_to_func"] = _hb_draw_funcs_set_cubic_to_func = wasmExports2["hb_draw_funcs_set_cubic_to_func"];
|
|
470
|
+
Module["_hb_draw_funcs_set_close_path_func"] = _hb_draw_funcs_set_close_path_func = wasmExports2["hb_draw_funcs_set_close_path_func"];
|
|
471
|
+
Module["_hb_draw_funcs_create"] = _hb_draw_funcs_create = wasmExports2["hb_draw_funcs_create"];
|
|
472
|
+
Module["_hb_draw_funcs_destroy"] = _hb_draw_funcs_destroy = wasmExports2["hb_draw_funcs_destroy"];
|
|
473
|
+
Module["_hb_face_create"] = _hb_face_create = wasmExports2["hb_face_create"];
|
|
474
|
+
Module["_hb_face_destroy"] = _hb_face_destroy = wasmExports2["hb_face_destroy"];
|
|
475
|
+
Module["_hb_face_reference_table"] = _hb_face_reference_table = wasmExports2["hb_face_reference_table"];
|
|
476
|
+
Module["_hb_face_get_upem"] = _hb_face_get_upem = wasmExports2["hb_face_get_upem"];
|
|
477
|
+
Module["_hb_face_collect_unicodes"] = _hb_face_collect_unicodes = wasmExports2["hb_face_collect_unicodes"];
|
|
478
|
+
Module["_hb_font_draw_glyph"] = _hb_font_draw_glyph = wasmExports2["hb_font_draw_glyph"];
|
|
479
|
+
Module["_hb_font_glyph_to_string"] = _hb_font_glyph_to_string = wasmExports2["hb_font_glyph_to_string"];
|
|
480
|
+
Module["_hb_font_create"] = _hb_font_create = wasmExports2["hb_font_create"];
|
|
481
|
+
Module["_hb_font_set_variations"] = _hb_font_set_variations = wasmExports2["hb_font_set_variations"];
|
|
482
|
+
Module["_hb_font_destroy"] = _hb_font_destroy = wasmExports2["hb_font_destroy"];
|
|
483
|
+
Module["_hb_font_set_scale"] = _hb_font_set_scale = wasmExports2["hb_font_set_scale"];
|
|
484
|
+
Module["_hb_set_create"] = _hb_set_create = wasmExports2["hb_set_create"];
|
|
485
|
+
Module["_hb_set_destroy"] = _hb_set_destroy = wasmExports2["hb_set_destroy"];
|
|
486
|
+
Module["_hb_ot_var_get_axis_infos"] = _hb_ot_var_get_axis_infos = wasmExports2["hb_ot_var_get_axis_infos"];
|
|
487
|
+
Module["_hb_set_get_population"] = _hb_set_get_population = wasmExports2["hb_set_get_population"];
|
|
488
|
+
Module["_hb_set_next_many"] = _hb_set_next_many = wasmExports2["hb_set_next_many"];
|
|
489
|
+
Module["_hb_shape"] = _hb_shape = wasmExports2["hb_shape"];
|
|
490
|
+
__emscripten_timeout = wasmExports2["_emscripten_timeout"];
|
|
491
|
+
}
|
|
492
|
+
var wasmImports = { _abort_js: __abort_js, _emscripten_runtime_keepalive_clear: __emscripten_runtime_keepalive_clear, _setitimer_js: __setitimer_js, emscripten_resize_heap: _emscripten_resize_heap, proc_exit: _proc_exit };
|
|
493
|
+
var wasmExports = await createWasm();
|
|
494
|
+
function run() {
|
|
495
|
+
if (runDependencies > 0) {
|
|
496
|
+
dependenciesFulfilled = run;
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
preRun();
|
|
500
|
+
if (runDependencies > 0) {
|
|
501
|
+
dependenciesFulfilled = run;
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
function doRun() {
|
|
505
|
+
Module["calledRun"] = true;
|
|
506
|
+
if (ABORT) return;
|
|
507
|
+
initRuntime();
|
|
508
|
+
readyPromiseResolve?.(Module);
|
|
509
|
+
Module["onRuntimeInitialized"]?.();
|
|
510
|
+
postRun();
|
|
511
|
+
}
|
|
512
|
+
if (Module["setStatus"]) {
|
|
513
|
+
Module["setStatus"]("Running...");
|
|
514
|
+
setTimeout(() => {
|
|
515
|
+
setTimeout(() => Module["setStatus"](""), 1);
|
|
516
|
+
doRun();
|
|
517
|
+
}, 1);
|
|
518
|
+
} else {
|
|
519
|
+
doRun();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function preInit() {
|
|
523
|
+
if (Module["preInit"]) {
|
|
524
|
+
if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
|
|
525
|
+
while (Module["preInit"].length > 0) {
|
|
526
|
+
Module["preInit"].shift()();
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
preInit();
|
|
531
|
+
run();
|
|
532
|
+
if (runtimeInitialized) {
|
|
533
|
+
moduleRtn = Module;
|
|
534
|
+
} else {
|
|
535
|
+
moduleRtn = new Promise((resolve, reject) => {
|
|
536
|
+
readyPromiseResolve = resolve;
|
|
537
|
+
readyPromiseReject = reject;
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
;
|
|
541
|
+
return moduleRtn;
|
|
542
|
+
};
|
|
543
|
+
})();
|
|
544
|
+
if (typeof exports === "object" && typeof module === "object") {
|
|
545
|
+
module.exports = createHarfBuzz;
|
|
546
|
+
module.exports.default = createHarfBuzz;
|
|
547
|
+
} else if (typeof define === "function" && define["amd"]) define([], () => createHarfBuzz);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
export default require_hb();
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS
|
|
3
|
+
} from "./chunk-HYGMWVDX.js";
|
|
4
|
+
|
|
5
|
+
// node_modules/harfbuzzjs/hbjs.js
|
|
6
|
+
var require_hbjs = __commonJS({
|
|
7
|
+
"node_modules/harfbuzzjs/hbjs.js"(exports, module) {
|
|
8
|
+
function hbjs(Module) {
|
|
9
|
+
"use strict";
|
|
10
|
+
var exports2 = Module.wasmExports;
|
|
11
|
+
var utf8Decoder = new TextDecoder("utf8");
|
|
12
|
+
let addFunction = Module.addFunction;
|
|
13
|
+
let removeFunction = Module.removeFunction;
|
|
14
|
+
var freeFuncPtr = addFunction(function(ptr) {
|
|
15
|
+
exports2.free(ptr);
|
|
16
|
+
}, "vi");
|
|
17
|
+
var HB_MEMORY_MODE_WRITABLE = 2;
|
|
18
|
+
var HB_SET_VALUE_INVALID = -1;
|
|
19
|
+
var HB_BUFFER_CONTENT_TYPE_GLYPHS = 2;
|
|
20
|
+
var DONT_STOP = 0;
|
|
21
|
+
var GSUB_PHASE = 1;
|
|
22
|
+
var GPOS_PHASE = 2;
|
|
23
|
+
function hb_tag(s) {
|
|
24
|
+
return (s.charCodeAt(0) & 255) << 24 | (s.charCodeAt(1) & 255) << 16 | (s.charCodeAt(2) & 255) << 8 | (s.charCodeAt(3) & 255) << 0;
|
|
25
|
+
}
|
|
26
|
+
var HB_BUFFER_SERIALIZE_FORMAT_JSON = hb_tag("JSON");
|
|
27
|
+
var HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 4;
|
|
28
|
+
function _hb_untag(tag) {
|
|
29
|
+
return [
|
|
30
|
+
String.fromCharCode(tag >> 24 & 255),
|
|
31
|
+
String.fromCharCode(tag >> 16 & 255),
|
|
32
|
+
String.fromCharCode(tag >> 8 & 255),
|
|
33
|
+
String.fromCharCode(tag >> 0 & 255)
|
|
34
|
+
].join("");
|
|
35
|
+
}
|
|
36
|
+
function _buffer_flag(s) {
|
|
37
|
+
if (s == "BOT") {
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
if (s == "EOT") {
|
|
41
|
+
return 2;
|
|
42
|
+
}
|
|
43
|
+
if (s == "PRESERVE_DEFAULT_IGNORABLES") {
|
|
44
|
+
return 4;
|
|
45
|
+
}
|
|
46
|
+
if (s == "REMOVE_DEFAULT_IGNORABLES") {
|
|
47
|
+
return 8;
|
|
48
|
+
}
|
|
49
|
+
if (s == "DO_NOT_INSERT_DOTTED_CIRCLE") {
|
|
50
|
+
return 16;
|
|
51
|
+
}
|
|
52
|
+
if (s == "PRODUCE_UNSAFE_TO_CONCAT") {
|
|
53
|
+
return 64;
|
|
54
|
+
}
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
function createBlob(blob) {
|
|
58
|
+
var blobPtr = exports2.malloc(blob.byteLength);
|
|
59
|
+
Module.HEAPU8.set(new Uint8Array(blob), blobPtr);
|
|
60
|
+
var ptr = exports2.hb_blob_create(blobPtr, blob.byteLength, HB_MEMORY_MODE_WRITABLE, blobPtr, freeFuncPtr);
|
|
61
|
+
return {
|
|
62
|
+
ptr,
|
|
63
|
+
/**
|
|
64
|
+
* Free the object.
|
|
65
|
+
*/
|
|
66
|
+
destroy: function() {
|
|
67
|
+
exports2.hb_blob_destroy(ptr);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function typedArrayFromSet(setPtr) {
|
|
72
|
+
const setCount = exports2.hb_set_get_population(setPtr);
|
|
73
|
+
const arrayPtr = exports2.malloc(setCount << 2);
|
|
74
|
+
const arrayOffset = arrayPtr >> 2;
|
|
75
|
+
const array = Module.HEAPU32.subarray(arrayOffset, arrayOffset + setCount);
|
|
76
|
+
Module.HEAPU32.set(array, arrayOffset);
|
|
77
|
+
exports2.hb_set_next_many(setPtr, HB_SET_VALUE_INVALID, arrayPtr, setCount);
|
|
78
|
+
return array;
|
|
79
|
+
}
|
|
80
|
+
function createFace(blob, index) {
|
|
81
|
+
var ptr = exports2.hb_face_create(blob.ptr, index);
|
|
82
|
+
const upem = exports2.hb_face_get_upem(ptr);
|
|
83
|
+
return {
|
|
84
|
+
ptr,
|
|
85
|
+
upem,
|
|
86
|
+
/**
|
|
87
|
+
* Return the binary contents of an OpenType table.
|
|
88
|
+
* @param {string} table Table name
|
|
89
|
+
*/
|
|
90
|
+
reference_table: function(table) {
|
|
91
|
+
var blob2 = exports2.hb_face_reference_table(ptr, hb_tag(table));
|
|
92
|
+
var length = exports2.hb_blob_get_length(blob2);
|
|
93
|
+
if (!length) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
var blobptr = exports2.hb_blob_get_data(blob2, null);
|
|
97
|
+
var table_string = Module.HEAPU8.subarray(blobptr, blobptr + length);
|
|
98
|
+
return table_string;
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Return variation axis infos
|
|
102
|
+
*/
|
|
103
|
+
getAxisInfos: function() {
|
|
104
|
+
var axis = exports2.malloc(64 * 32);
|
|
105
|
+
var c = exports2.malloc(4);
|
|
106
|
+
Module.HEAPU32[c / 4] = 64;
|
|
107
|
+
exports2.hb_ot_var_get_axis_infos(ptr, 0, c, axis);
|
|
108
|
+
var result = {};
|
|
109
|
+
Array.from({ length: Module.HEAPU32[c / 4] }).forEach(function(_, i) {
|
|
110
|
+
result[_hb_untag(Module.HEAPU32[axis / 4 + i * 8 + 1])] = {
|
|
111
|
+
min: Module.HEAPF32[axis / 4 + i * 8 + 4],
|
|
112
|
+
default: Module.HEAPF32[axis / 4 + i * 8 + 5],
|
|
113
|
+
max: Module.HEAPF32[axis / 4 + i * 8 + 6]
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
exports2.free(c);
|
|
117
|
+
exports2.free(axis);
|
|
118
|
+
return result;
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Return unicodes the face supports
|
|
122
|
+
*/
|
|
123
|
+
collectUnicodes: function() {
|
|
124
|
+
var unicodeSetPtr = exports2.hb_set_create();
|
|
125
|
+
exports2.hb_face_collect_unicodes(ptr, unicodeSetPtr);
|
|
126
|
+
var result = typedArrayFromSet(unicodeSetPtr);
|
|
127
|
+
exports2.hb_set_destroy(unicodeSetPtr);
|
|
128
|
+
return result;
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* Free the object.
|
|
132
|
+
*/
|
|
133
|
+
destroy: function() {
|
|
134
|
+
exports2.hb_face_destroy(ptr);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var pathBuffer = "";
|
|
139
|
+
var nameBufferSize = 256;
|
|
140
|
+
var nameBuffer = exports2.malloc(nameBufferSize);
|
|
141
|
+
function createFont(face) {
|
|
142
|
+
var ptr = exports2.hb_font_create(face.ptr);
|
|
143
|
+
var drawFuncsPtr = null;
|
|
144
|
+
var moveToPtr = null;
|
|
145
|
+
var lineToPtr = null;
|
|
146
|
+
var cubicToPtr = null;
|
|
147
|
+
var quadToPtr = null;
|
|
148
|
+
var closePathPtr = null;
|
|
149
|
+
function glyphToPath(glyphId) {
|
|
150
|
+
if (!drawFuncsPtr) {
|
|
151
|
+
var moveTo = function(dfuncs, draw_data, draw_state, to_x, to_y, user_data) {
|
|
152
|
+
pathBuffer += `M${to_x},${to_y}`;
|
|
153
|
+
};
|
|
154
|
+
var lineTo = function(dfuncs, draw_data, draw_state, to_x, to_y, user_data) {
|
|
155
|
+
pathBuffer += `L${to_x},${to_y}`;
|
|
156
|
+
};
|
|
157
|
+
var cubicTo = function(dfuncs, draw_data, draw_state, c1_x, c1_y, c2_x, c2_y, to_x, to_y, user_data) {
|
|
158
|
+
pathBuffer += `C${c1_x},${c1_y} ${c2_x},${c2_y} ${to_x},${to_y}`;
|
|
159
|
+
};
|
|
160
|
+
var quadTo = function(dfuncs, draw_data, draw_state, c_x, c_y, to_x, to_y, user_data) {
|
|
161
|
+
pathBuffer += `Q${c_x},${c_y} ${to_x},${to_y}`;
|
|
162
|
+
};
|
|
163
|
+
var closePath = function(dfuncs, draw_data, draw_state, user_data) {
|
|
164
|
+
pathBuffer += "Z";
|
|
165
|
+
};
|
|
166
|
+
moveToPtr = addFunction(moveTo, "viiiffi");
|
|
167
|
+
lineToPtr = addFunction(lineTo, "viiiffi");
|
|
168
|
+
cubicToPtr = addFunction(cubicTo, "viiiffffffi");
|
|
169
|
+
quadToPtr = addFunction(quadTo, "viiiffffi");
|
|
170
|
+
closePathPtr = addFunction(closePath, "viiii");
|
|
171
|
+
drawFuncsPtr = exports2.hb_draw_funcs_create();
|
|
172
|
+
exports2.hb_draw_funcs_set_move_to_func(drawFuncsPtr, moveToPtr, 0, 0);
|
|
173
|
+
exports2.hb_draw_funcs_set_line_to_func(drawFuncsPtr, lineToPtr, 0, 0);
|
|
174
|
+
exports2.hb_draw_funcs_set_cubic_to_func(drawFuncsPtr, cubicToPtr, 0, 0);
|
|
175
|
+
exports2.hb_draw_funcs_set_quadratic_to_func(drawFuncsPtr, quadToPtr, 0, 0);
|
|
176
|
+
exports2.hb_draw_funcs_set_close_path_func(drawFuncsPtr, closePathPtr, 0, 0);
|
|
177
|
+
}
|
|
178
|
+
pathBuffer = "";
|
|
179
|
+
exports2.hb_font_draw_glyph(ptr, glyphId, drawFuncsPtr, 0);
|
|
180
|
+
return pathBuffer;
|
|
181
|
+
}
|
|
182
|
+
function glyphName(glyphId) {
|
|
183
|
+
exports2.hb_font_glyph_to_string(
|
|
184
|
+
ptr,
|
|
185
|
+
glyphId,
|
|
186
|
+
nameBuffer,
|
|
187
|
+
nameBufferSize
|
|
188
|
+
);
|
|
189
|
+
var array = Module.HEAPU8.subarray(nameBuffer, nameBuffer + nameBufferSize);
|
|
190
|
+
return utf8Decoder.decode(array.slice(0, array.indexOf(0)));
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
ptr,
|
|
194
|
+
glyphName,
|
|
195
|
+
glyphToPath,
|
|
196
|
+
/**
|
|
197
|
+
* Return a glyph as a JSON path string
|
|
198
|
+
* based on format described on https://svgwg.org/specs/paths/#InterfaceSVGPathSegment
|
|
199
|
+
* @param {number} glyphId ID of the requested glyph in the font.
|
|
200
|
+
**/
|
|
201
|
+
glyphToJson: function(glyphId) {
|
|
202
|
+
var path = glyphToPath(glyphId);
|
|
203
|
+
return path.replace(/([MLQCZ])/g, "|$1 ").split("|").filter(function(x) {
|
|
204
|
+
return x.length;
|
|
205
|
+
}).map(function(x) {
|
|
206
|
+
var row = x.split(/[ ,]/g);
|
|
207
|
+
return { type: row[0], values: row.slice(1).filter(function(x2) {
|
|
208
|
+
return x2.length;
|
|
209
|
+
}).map(function(x2) {
|
|
210
|
+
return +x2;
|
|
211
|
+
}) };
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
/**
|
|
215
|
+
* Set the font's scale factor, affecting the position values returned from
|
|
216
|
+
* shaping.
|
|
217
|
+
* @param {number} xScale Units to scale in the X dimension.
|
|
218
|
+
* @param {number} yScale Units to scale in the Y dimension.
|
|
219
|
+
**/
|
|
220
|
+
setScale: function(xScale, yScale) {
|
|
221
|
+
exports2.hb_font_set_scale(ptr, xScale, yScale);
|
|
222
|
+
},
|
|
223
|
+
/**
|
|
224
|
+
* Set the font's variations.
|
|
225
|
+
* @param {object} variations Dictionary of variations to set
|
|
226
|
+
**/
|
|
227
|
+
setVariations: function(variations) {
|
|
228
|
+
var entries = Object.entries(variations);
|
|
229
|
+
var vars = exports2.malloc(8 * entries.length);
|
|
230
|
+
entries.forEach(function(entry, i) {
|
|
231
|
+
Module.HEAPU32[vars / 4 + i * 2 + 0] = hb_tag(entry[0]);
|
|
232
|
+
Module.HEAPF32[vars / 4 + i * 2 + 1] = entry[1];
|
|
233
|
+
});
|
|
234
|
+
exports2.hb_font_set_variations(ptr, vars, entries.length);
|
|
235
|
+
exports2.free(vars);
|
|
236
|
+
},
|
|
237
|
+
/**
|
|
238
|
+
* Free the object.
|
|
239
|
+
*/
|
|
240
|
+
destroy: function() {
|
|
241
|
+
exports2.hb_font_destroy(ptr);
|
|
242
|
+
if (drawFuncsPtr) {
|
|
243
|
+
exports2.hb_draw_funcs_destroy(drawFuncsPtr);
|
|
244
|
+
drawFuncsPtr = null;
|
|
245
|
+
removeFunction(moveToPtr);
|
|
246
|
+
removeFunction(lineToPtr);
|
|
247
|
+
removeFunction(cubicToPtr);
|
|
248
|
+
removeFunction(quadToPtr);
|
|
249
|
+
removeFunction(closePathPtr);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function createAsciiString(text) {
|
|
255
|
+
var ptr = exports2.malloc(text.length + 1);
|
|
256
|
+
for (let i = 0; i < text.length; ++i) {
|
|
257
|
+
const char = text.charCodeAt(i);
|
|
258
|
+
if (char > 127) throw new Error("Expected ASCII text");
|
|
259
|
+
Module.HEAPU8[ptr + i] = char;
|
|
260
|
+
}
|
|
261
|
+
Module.HEAPU8[ptr + text.length] = 0;
|
|
262
|
+
return {
|
|
263
|
+
ptr,
|
|
264
|
+
length: text.length,
|
|
265
|
+
free: function() {
|
|
266
|
+
exports2.free(ptr);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function createJsString(text) {
|
|
271
|
+
const ptr = exports2.malloc(text.length * 2);
|
|
272
|
+
const words = new Uint16Array(Module.wasmMemory.buffer, ptr, text.length);
|
|
273
|
+
for (let i = 0; i < words.length; ++i) words[i] = text.charCodeAt(i);
|
|
274
|
+
return {
|
|
275
|
+
ptr,
|
|
276
|
+
length: words.length,
|
|
277
|
+
free: function() {
|
|
278
|
+
exports2.free(ptr);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function createBuffer() {
|
|
283
|
+
var ptr = exports2.hb_buffer_create();
|
|
284
|
+
return {
|
|
285
|
+
ptr,
|
|
286
|
+
/**
|
|
287
|
+
* Add text to the buffer.
|
|
288
|
+
* @param {string} text Text to be added to the buffer.
|
|
289
|
+
**/
|
|
290
|
+
addText: function(text) {
|
|
291
|
+
const str = createJsString(text);
|
|
292
|
+
exports2.hb_buffer_add_utf16(ptr, str.ptr, str.length, 0, str.length);
|
|
293
|
+
str.free();
|
|
294
|
+
},
|
|
295
|
+
/**
|
|
296
|
+
* Set buffer script, language and direction.
|
|
297
|
+
*
|
|
298
|
+
* This needs to be done before shaping.
|
|
299
|
+
**/
|
|
300
|
+
guessSegmentProperties: function() {
|
|
301
|
+
return exports2.hb_buffer_guess_segment_properties(ptr);
|
|
302
|
+
},
|
|
303
|
+
/**
|
|
304
|
+
* Set buffer direction explicitly.
|
|
305
|
+
* @param {string} direction: One of "ltr", "rtl", "ttb" or "btt"
|
|
306
|
+
*/
|
|
307
|
+
setDirection: function(dir) {
|
|
308
|
+
exports2.hb_buffer_set_direction(ptr, {
|
|
309
|
+
ltr: 4,
|
|
310
|
+
rtl: 5,
|
|
311
|
+
ttb: 6,
|
|
312
|
+
btt: 7
|
|
313
|
+
}[dir] || 0);
|
|
314
|
+
},
|
|
315
|
+
/**
|
|
316
|
+
* Set buffer flags explicitly.
|
|
317
|
+
* @param {string[]} flags: A list of strings which may be either:
|
|
318
|
+
* "BOT"
|
|
319
|
+
* "EOT"
|
|
320
|
+
* "PRESERVE_DEFAULT_IGNORABLES"
|
|
321
|
+
* "REMOVE_DEFAULT_IGNORABLES"
|
|
322
|
+
* "DO_NOT_INSERT_DOTTED_CIRCLE"
|
|
323
|
+
* "PRODUCE_UNSAFE_TO_CONCAT"
|
|
324
|
+
*/
|
|
325
|
+
setFlags: function(flags) {
|
|
326
|
+
var flagValue = 0;
|
|
327
|
+
flags.forEach(function(s) {
|
|
328
|
+
flagValue |= _buffer_flag(s);
|
|
329
|
+
});
|
|
330
|
+
exports2.hb_buffer_set_flags(ptr, flagValue);
|
|
331
|
+
},
|
|
332
|
+
/**
|
|
333
|
+
* Set buffer language explicitly.
|
|
334
|
+
* @param {string} language: The buffer language
|
|
335
|
+
*/
|
|
336
|
+
setLanguage: function(language) {
|
|
337
|
+
var str = createAsciiString(language);
|
|
338
|
+
exports2.hb_buffer_set_language(ptr, exports2.hb_language_from_string(str.ptr, -1));
|
|
339
|
+
str.free();
|
|
340
|
+
},
|
|
341
|
+
/**
|
|
342
|
+
* Set buffer script explicitly.
|
|
343
|
+
* @param {string} script: The buffer script
|
|
344
|
+
*/
|
|
345
|
+
setScript: function(script) {
|
|
346
|
+
var str = createAsciiString(script);
|
|
347
|
+
exports2.hb_buffer_set_script(ptr, exports2.hb_script_from_string(str.ptr, -1));
|
|
348
|
+
str.free();
|
|
349
|
+
},
|
|
350
|
+
/**
|
|
351
|
+
* Set the Harfbuzz clustering level.
|
|
352
|
+
*
|
|
353
|
+
* Affects the cluster values returned from shaping.
|
|
354
|
+
* @param {number} level: Clustering level. See the Harfbuzz manual chapter
|
|
355
|
+
* on Clusters.
|
|
356
|
+
**/
|
|
357
|
+
setClusterLevel: function(level) {
|
|
358
|
+
exports2.hb_buffer_set_cluster_level(ptr, level);
|
|
359
|
+
},
|
|
360
|
+
/**
|
|
361
|
+
* Return the buffer contents as a JSON object.
|
|
362
|
+
*
|
|
363
|
+
* After shaping, this function will return an array of glyph information
|
|
364
|
+
* objects. Each object will have the following attributes:
|
|
365
|
+
*
|
|
366
|
+
* - g: The glyph ID
|
|
367
|
+
* - cl: The cluster ID
|
|
368
|
+
* - ax: Advance width (width to advance after this glyph is painted)
|
|
369
|
+
* - ay: Advance height (height to advance after this glyph is painted)
|
|
370
|
+
* - dx: X displacement (adjustment in X dimension when painting this glyph)
|
|
371
|
+
* - dy: Y displacement (adjustment in Y dimension when painting this glyph)
|
|
372
|
+
* - flags: Glyph flags like `HB_GLYPH_FLAG_UNSAFE_TO_BREAK` (0x1)
|
|
373
|
+
**/
|
|
374
|
+
json: function() {
|
|
375
|
+
var length = exports2.hb_buffer_get_length(ptr);
|
|
376
|
+
var result = [];
|
|
377
|
+
var infosPtr = exports2.hb_buffer_get_glyph_infos(ptr, 0);
|
|
378
|
+
var infosPtr32 = infosPtr / 4;
|
|
379
|
+
var positionsPtr32 = exports2.hb_buffer_get_glyph_positions(ptr, 0) / 4;
|
|
380
|
+
var infos = Module.HEAPU32.subarray(infosPtr32, infosPtr32 + 5 * length);
|
|
381
|
+
var positions = Module.HEAP32.subarray(positionsPtr32, positionsPtr32 + 5 * length);
|
|
382
|
+
for (var i = 0; i < length; ++i) {
|
|
383
|
+
result.push({
|
|
384
|
+
g: infos[i * 5 + 0],
|
|
385
|
+
cl: infos[i * 5 + 2],
|
|
386
|
+
ax: positions[i * 5 + 0],
|
|
387
|
+
ay: positions[i * 5 + 1],
|
|
388
|
+
dx: positions[i * 5 + 2],
|
|
389
|
+
dy: positions[i * 5 + 3],
|
|
390
|
+
flags: exports2.hb_glyph_info_get_glyph_flags(infosPtr + i * 20)
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return result;
|
|
394
|
+
},
|
|
395
|
+
/**
|
|
396
|
+
* Free the object.
|
|
397
|
+
*/
|
|
398
|
+
destroy: function() {
|
|
399
|
+
exports2.hb_buffer_destroy(ptr);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function shape(font, buffer, features) {
|
|
404
|
+
var featuresPtr = 0;
|
|
405
|
+
var featuresLen = 0;
|
|
406
|
+
if (features) {
|
|
407
|
+
features = features.split(",");
|
|
408
|
+
featuresPtr = exports2.malloc(16 * features.length);
|
|
409
|
+
features.forEach(function(feature, i) {
|
|
410
|
+
var str = createAsciiString(feature);
|
|
411
|
+
if (exports2.hb_feature_from_string(str.ptr, -1, featuresPtr + featuresLen * 16))
|
|
412
|
+
featuresLen++;
|
|
413
|
+
str.free();
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
exports2.hb_shape(font.ptr, buffer.ptr, featuresPtr, featuresLen);
|
|
417
|
+
if (featuresPtr)
|
|
418
|
+
exports2.free(featuresPtr);
|
|
419
|
+
}
|
|
420
|
+
function shapeWithTrace(font, buffer, features, stop_at, stop_phase) {
|
|
421
|
+
var trace = [];
|
|
422
|
+
var currentPhase = DONT_STOP;
|
|
423
|
+
var stopping = false;
|
|
424
|
+
var failure = false;
|
|
425
|
+
var traceBufLen = 1024 * 1024;
|
|
426
|
+
var traceBufPtr = exports2.malloc(traceBufLen);
|
|
427
|
+
var traceFunc = function(bufferPtr, fontPtr, messagePtr, user_data) {
|
|
428
|
+
var message = utf8Decoder.decode(Module.HEAPU8.subarray(messagePtr, Module.HEAPU8.indexOf(0, messagePtr)));
|
|
429
|
+
if (message.startsWith("start table GSUB"))
|
|
430
|
+
currentPhase = GSUB_PHASE;
|
|
431
|
+
else if (message.startsWith("start table GPOS"))
|
|
432
|
+
currentPhase = GPOS_PHASE;
|
|
433
|
+
if (currentPhase != stop_phase)
|
|
434
|
+
stopping = false;
|
|
435
|
+
if (failure)
|
|
436
|
+
return 1;
|
|
437
|
+
if (stop_phase != DONT_STOP && currentPhase == stop_phase && message.startsWith("end lookup " + stop_at))
|
|
438
|
+
stopping = true;
|
|
439
|
+
if (stopping)
|
|
440
|
+
return 0;
|
|
441
|
+
exports2.hb_buffer_serialize_glyphs(
|
|
442
|
+
bufferPtr,
|
|
443
|
+
0,
|
|
444
|
+
exports2.hb_buffer_get_length(bufferPtr),
|
|
445
|
+
traceBufPtr,
|
|
446
|
+
traceBufLen,
|
|
447
|
+
0,
|
|
448
|
+
fontPtr,
|
|
449
|
+
HB_BUFFER_SERIALIZE_FORMAT_JSON,
|
|
450
|
+
HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES
|
|
451
|
+
);
|
|
452
|
+
trace.push({
|
|
453
|
+
m: message,
|
|
454
|
+
t: JSON.parse(utf8Decoder.decode(Module.HEAPU8.subarray(traceBufPtr, Module.HEAPU8.indexOf(0, traceBufPtr)))),
|
|
455
|
+
glyphs: exports2.hb_buffer_get_content_type(bufferPtr) == HB_BUFFER_CONTENT_TYPE_GLYPHS
|
|
456
|
+
});
|
|
457
|
+
return 1;
|
|
458
|
+
};
|
|
459
|
+
var traceFuncPtr = addFunction(traceFunc, "iiiii");
|
|
460
|
+
exports2.hb_buffer_set_message_func(buffer.ptr, traceFuncPtr, 0, 0);
|
|
461
|
+
shape(font, buffer, features, 0);
|
|
462
|
+
exports2.free(traceBufPtr);
|
|
463
|
+
removeFunction(traceFuncPtr);
|
|
464
|
+
return trace;
|
|
465
|
+
}
|
|
466
|
+
function version() {
|
|
467
|
+
var versionPtr = exports2.malloc(12);
|
|
468
|
+
exports2.hb_version(versionPtr, versionPtr + 4, versionPtr + 8);
|
|
469
|
+
var version2 = {
|
|
470
|
+
major: Module.HEAPU32[versionPtr / 4],
|
|
471
|
+
minor: Module.HEAPU32[(versionPtr + 4) / 4],
|
|
472
|
+
micro: Module.HEAPU32[(versionPtr + 8) / 4]
|
|
473
|
+
};
|
|
474
|
+
exports2.free(versionPtr);
|
|
475
|
+
return version2;
|
|
476
|
+
}
|
|
477
|
+
function version_string() {
|
|
478
|
+
var versionPtr = exports2.hb_version_string();
|
|
479
|
+
var version2 = utf8Decoder.decode(Module.HEAPU8.subarray(versionPtr, Module.HEAPU8.indexOf(0, versionPtr)));
|
|
480
|
+
return version2;
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
createBlob,
|
|
484
|
+
createFace,
|
|
485
|
+
createFont,
|
|
486
|
+
createBuffer,
|
|
487
|
+
shape,
|
|
488
|
+
shapeWithTrace,
|
|
489
|
+
version,
|
|
490
|
+
version_string
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
try {
|
|
494
|
+
module.exports = hbjs;
|
|
495
|
+
} catch (e) {
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
export default require_hbjs();
|
package/package.json
CHANGED