@shotstack/shotstack-canvas 1.4.3 → 1.4.5
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/entry.node.cjs +21 -4
- package/dist/entry.node.js +21 -4
- package/dist/entry.web.js +21 -4
- package/package.json +1 -1
package/dist/entry.node.cjs
CHANGED
|
@@ -178,6 +178,10 @@ function bufferToArrayBuffer(buffer) {
|
|
|
178
178
|
}
|
|
179
179
|
return arrayBuffer;
|
|
180
180
|
}
|
|
181
|
+
function getPkgName() {
|
|
182
|
+
const codes = [104, 97, 114, 102, 98, 117, 122, 122, 106, 115];
|
|
183
|
+
return codes.map((c) => String.fromCharCode(c)).join("");
|
|
184
|
+
}
|
|
181
185
|
var DEFAULT_WASM_URL = "https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm";
|
|
182
186
|
async function fetchWasmFromUrl(url) {
|
|
183
187
|
try {
|
|
@@ -206,10 +210,11 @@ async function loadWasmNode() {
|
|
|
206
210
|
const { readFile: readFile2 } = await import("fs/promises");
|
|
207
211
|
const path = await import("path");
|
|
208
212
|
const candidates = [];
|
|
213
|
+
const pkgName = getPkgName();
|
|
209
214
|
try {
|
|
210
215
|
const { createRequire } = await import("module");
|
|
211
216
|
const requireFn = createRequire(import_meta.url || `file://${process.cwd()}/`);
|
|
212
|
-
const harfbuzzPkgPath = requireFn.resolve("
|
|
217
|
+
const harfbuzzPkgPath = requireFn.resolve(pkgName + "/package.json");
|
|
213
218
|
const harfbuzzDir = path.dirname(harfbuzzPkgPath);
|
|
214
219
|
candidates.push(path.join(harfbuzzDir, "hb.wasm"));
|
|
215
220
|
} catch {
|
|
@@ -228,11 +233,11 @@ async function loadWasmNode() {
|
|
|
228
233
|
candidates.push(
|
|
229
234
|
path.join(currentDir, "dist/hb.wasm"),
|
|
230
235
|
path.join(currentDir, "assets/wasm/hb.wasm"),
|
|
231
|
-
path.join(currentDir, "node_modules
|
|
236
|
+
path.join(currentDir, "node_modules", pkgName, "hb.wasm"),
|
|
232
237
|
path.join(currentDir, "node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm")
|
|
233
238
|
);
|
|
234
239
|
candidates.push(
|
|
235
|
-
"/var/task/node_modules/
|
|
240
|
+
"/var/task/node_modules/" + pkgName + "/hb.wasm",
|
|
236
241
|
"/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm"
|
|
237
242
|
);
|
|
238
243
|
console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
|
|
@@ -315,6 +320,18 @@ function setupWasmInterceptors(wasmBinary) {
|
|
|
315
320
|
};
|
|
316
321
|
}
|
|
317
322
|
}
|
|
323
|
+
async function importHarfBuzzJS() {
|
|
324
|
+
try {
|
|
325
|
+
const moduleName = getPkgName();
|
|
326
|
+
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
327
|
+
return await dynamicImport(moduleName);
|
|
328
|
+
} catch (err) {
|
|
329
|
+
console.error("Failed to import harfbuzzjs:", err);
|
|
330
|
+
throw new Error(
|
|
331
|
+
`Cannot import harfbuzzjs. This library requires harfbuzzjs to be installed. Error: ${err instanceof Error ? err.message : String(err)}`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
318
335
|
async function initHB(wasmBaseURL) {
|
|
319
336
|
if (hbSingleton) return hbSingleton;
|
|
320
337
|
try {
|
|
@@ -331,7 +348,7 @@ async function initHB(wasmBaseURL) {
|
|
|
331
348
|
if (!isNode()) {
|
|
332
349
|
setupWasmInterceptors(wasmBinary);
|
|
333
350
|
}
|
|
334
|
-
const mod = await
|
|
351
|
+
const mod = await importHarfBuzzJS();
|
|
335
352
|
let hb;
|
|
336
353
|
const candidate = mod.default || mod;
|
|
337
354
|
if (typeof candidate === "function") {
|
package/dist/entry.node.js
CHANGED
|
@@ -139,6 +139,10 @@ function bufferToArrayBuffer(buffer) {
|
|
|
139
139
|
}
|
|
140
140
|
return arrayBuffer;
|
|
141
141
|
}
|
|
142
|
+
function getPkgName() {
|
|
143
|
+
const codes = [104, 97, 114, 102, 98, 117, 122, 122, 106, 115];
|
|
144
|
+
return codes.map((c) => String.fromCharCode(c)).join("");
|
|
145
|
+
}
|
|
142
146
|
var DEFAULT_WASM_URL = "https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm";
|
|
143
147
|
async function fetchWasmFromUrl(url) {
|
|
144
148
|
try {
|
|
@@ -167,10 +171,11 @@ async function loadWasmNode() {
|
|
|
167
171
|
const { readFile: readFile2 } = await import("fs/promises");
|
|
168
172
|
const path = await import("path");
|
|
169
173
|
const candidates = [];
|
|
174
|
+
const pkgName = getPkgName();
|
|
170
175
|
try {
|
|
171
176
|
const { createRequire } = await import("module");
|
|
172
177
|
const requireFn = createRequire(import.meta.url || `file://${process.cwd()}/`);
|
|
173
|
-
const harfbuzzPkgPath = requireFn.resolve("
|
|
178
|
+
const harfbuzzPkgPath = requireFn.resolve(pkgName + "/package.json");
|
|
174
179
|
const harfbuzzDir = path.dirname(harfbuzzPkgPath);
|
|
175
180
|
candidates.push(path.join(harfbuzzDir, "hb.wasm"));
|
|
176
181
|
} catch {
|
|
@@ -189,11 +194,11 @@ async function loadWasmNode() {
|
|
|
189
194
|
candidates.push(
|
|
190
195
|
path.join(currentDir, "dist/hb.wasm"),
|
|
191
196
|
path.join(currentDir, "assets/wasm/hb.wasm"),
|
|
192
|
-
path.join(currentDir, "node_modules
|
|
197
|
+
path.join(currentDir, "node_modules", pkgName, "hb.wasm"),
|
|
193
198
|
path.join(currentDir, "node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm")
|
|
194
199
|
);
|
|
195
200
|
candidates.push(
|
|
196
|
-
"/var/task/node_modules/
|
|
201
|
+
"/var/task/node_modules/" + pkgName + "/hb.wasm",
|
|
197
202
|
"/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm"
|
|
198
203
|
);
|
|
199
204
|
console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
|
|
@@ -276,6 +281,18 @@ function setupWasmInterceptors(wasmBinary) {
|
|
|
276
281
|
};
|
|
277
282
|
}
|
|
278
283
|
}
|
|
284
|
+
async function importHarfBuzzJS() {
|
|
285
|
+
try {
|
|
286
|
+
const moduleName = getPkgName();
|
|
287
|
+
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
288
|
+
return await dynamicImport(moduleName);
|
|
289
|
+
} catch (err) {
|
|
290
|
+
console.error("Failed to import harfbuzzjs:", err);
|
|
291
|
+
throw new Error(
|
|
292
|
+
`Cannot import harfbuzzjs. This library requires harfbuzzjs to be installed. Error: ${err instanceof Error ? err.message : String(err)}`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
279
296
|
async function initHB(wasmBaseURL) {
|
|
280
297
|
if (hbSingleton) return hbSingleton;
|
|
281
298
|
try {
|
|
@@ -292,7 +309,7 @@ async function initHB(wasmBaseURL) {
|
|
|
292
309
|
if (!isNode()) {
|
|
293
310
|
setupWasmInterceptors(wasmBinary);
|
|
294
311
|
}
|
|
295
|
-
const mod = await
|
|
312
|
+
const mod = await importHarfBuzzJS();
|
|
296
313
|
let hb;
|
|
297
314
|
const candidate = mod.default || mod;
|
|
298
315
|
if (typeof candidate === "function") {
|
package/dist/entry.web.js
CHANGED
|
@@ -143,6 +143,10 @@ function bufferToArrayBuffer(buffer) {
|
|
|
143
143
|
}
|
|
144
144
|
return arrayBuffer;
|
|
145
145
|
}
|
|
146
|
+
function getPkgName() {
|
|
147
|
+
const codes = [104, 97, 114, 102, 98, 117, 122, 122, 106, 115];
|
|
148
|
+
return codes.map((c) => String.fromCharCode(c)).join("");
|
|
149
|
+
}
|
|
146
150
|
var DEFAULT_WASM_URL = "https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm";
|
|
147
151
|
async function fetchWasmFromUrl(url) {
|
|
148
152
|
try {
|
|
@@ -171,10 +175,11 @@ async function loadWasmNode() {
|
|
|
171
175
|
const { readFile } = await import("fs/promises");
|
|
172
176
|
const path = await import("path");
|
|
173
177
|
const candidates = [];
|
|
178
|
+
const pkgName = getPkgName();
|
|
174
179
|
try {
|
|
175
180
|
const { createRequire } = await import("module");
|
|
176
181
|
const requireFn = createRequire(import.meta.url || `file://${process.cwd()}/`);
|
|
177
|
-
const harfbuzzPkgPath = requireFn.resolve("
|
|
182
|
+
const harfbuzzPkgPath = requireFn.resolve(pkgName + "/package.json");
|
|
178
183
|
const harfbuzzDir = path.dirname(harfbuzzPkgPath);
|
|
179
184
|
candidates.push(path.join(harfbuzzDir, "hb.wasm"));
|
|
180
185
|
} catch {
|
|
@@ -193,11 +198,11 @@ async function loadWasmNode() {
|
|
|
193
198
|
candidates.push(
|
|
194
199
|
path.join(currentDir, "dist/hb.wasm"),
|
|
195
200
|
path.join(currentDir, "assets/wasm/hb.wasm"),
|
|
196
|
-
path.join(currentDir, "node_modules
|
|
201
|
+
path.join(currentDir, "node_modules", pkgName, "hb.wasm"),
|
|
197
202
|
path.join(currentDir, "node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm")
|
|
198
203
|
);
|
|
199
204
|
candidates.push(
|
|
200
|
-
"/var/task/node_modules/
|
|
205
|
+
"/var/task/node_modules/" + pkgName + "/hb.wasm",
|
|
201
206
|
"/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm"
|
|
202
207
|
);
|
|
203
208
|
console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
|
|
@@ -280,6 +285,18 @@ function setupWasmInterceptors(wasmBinary) {
|
|
|
280
285
|
};
|
|
281
286
|
}
|
|
282
287
|
}
|
|
288
|
+
async function importHarfBuzzJS() {
|
|
289
|
+
try {
|
|
290
|
+
const moduleName = getPkgName();
|
|
291
|
+
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
292
|
+
return await dynamicImport(moduleName);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
console.error("Failed to import harfbuzzjs:", err);
|
|
295
|
+
throw new Error(
|
|
296
|
+
`Cannot import harfbuzzjs. This library requires harfbuzzjs to be installed. Error: ${err instanceof Error ? err.message : String(err)}`
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
283
300
|
async function initHB(wasmBaseURL) {
|
|
284
301
|
if (hbSingleton) return hbSingleton;
|
|
285
302
|
try {
|
|
@@ -296,7 +313,7 @@ async function initHB(wasmBaseURL) {
|
|
|
296
313
|
if (!isNode()) {
|
|
297
314
|
setupWasmInterceptors(wasmBinary);
|
|
298
315
|
}
|
|
299
|
-
const mod = await
|
|
316
|
+
const mod = await importHarfBuzzJS();
|
|
300
317
|
let hb;
|
|
301
318
|
const candidate = mod.default || mod;
|
|
302
319
|
if (typeof candidate === "function") {
|
package/package.json
CHANGED