@shotstack/shotstack-canvas 1.4.5 → 1.4.6

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.
@@ -178,10 +178,6 @@ 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
- }
185
181
  var DEFAULT_WASM_URL = "https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm";
186
182
  async function fetchWasmFromUrl(url) {
187
183
  try {
@@ -210,11 +206,10 @@ async function loadWasmNode() {
210
206
  const { readFile: readFile2 } = await import("fs/promises");
211
207
  const path = await import("path");
212
208
  const candidates = [];
213
- const pkgName = getPkgName();
214
209
  try {
215
210
  const { createRequire } = await import("module");
216
211
  const requireFn = createRequire(import_meta.url || `file://${process.cwd()}/`);
217
- const harfbuzzPkgPath = requireFn.resolve(pkgName + "/package.json");
212
+ const harfbuzzPkgPath = requireFn.resolve("harfbuzzjs/package.json");
218
213
  const harfbuzzDir = path.dirname(harfbuzzPkgPath);
219
214
  candidates.push(path.join(harfbuzzDir, "hb.wasm"));
220
215
  } catch {
@@ -233,11 +228,11 @@ async function loadWasmNode() {
233
228
  candidates.push(
234
229
  path.join(currentDir, "dist/hb.wasm"),
235
230
  path.join(currentDir, "assets/wasm/hb.wasm"),
236
- path.join(currentDir, "node_modules", pkgName, "hb.wasm"),
231
+ path.join(currentDir, "node_modules/harfbuzzjs/hb.wasm"),
237
232
  path.join(currentDir, "node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm")
238
233
  );
239
234
  candidates.push(
240
- "/var/task/node_modules/" + pkgName + "/hb.wasm",
235
+ "/var/task/node_modules/harfbuzzjs/hb.wasm",
241
236
  "/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm"
242
237
  );
243
238
  console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
@@ -320,18 +315,6 @@ function setupWasmInterceptors(wasmBinary) {
320
315
  };
321
316
  }
322
317
  }
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
- }
335
318
  async function initHB(wasmBaseURL) {
336
319
  if (hbSingleton) return hbSingleton;
337
320
  try {
@@ -348,7 +331,7 @@ async function initHB(wasmBaseURL) {
348
331
  if (!isNode()) {
349
332
  setupWasmInterceptors(wasmBinary);
350
333
  }
351
- const mod = await importHarfBuzzJS();
334
+ const mod = await import("harfbuzzjs");
352
335
  let hb;
353
336
  const candidate = mod.default || mod;
354
337
  if (typeof candidate === "function") {
@@ -139,10 +139,6 @@ 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
- }
146
142
  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
143
  async function fetchWasmFromUrl(url) {
148
144
  try {
@@ -171,11 +167,10 @@ async function loadWasmNode() {
171
167
  const { readFile: readFile2 } = await import("fs/promises");
172
168
  const path = await import("path");
173
169
  const candidates = [];
174
- const pkgName = getPkgName();
175
170
  try {
176
171
  const { createRequire } = await import("module");
177
172
  const requireFn = createRequire(import.meta.url || `file://${process.cwd()}/`);
178
- const harfbuzzPkgPath = requireFn.resolve(pkgName + "/package.json");
173
+ const harfbuzzPkgPath = requireFn.resolve("harfbuzzjs/package.json");
179
174
  const harfbuzzDir = path.dirname(harfbuzzPkgPath);
180
175
  candidates.push(path.join(harfbuzzDir, "hb.wasm"));
181
176
  } catch {
@@ -194,11 +189,11 @@ async function loadWasmNode() {
194
189
  candidates.push(
195
190
  path.join(currentDir, "dist/hb.wasm"),
196
191
  path.join(currentDir, "assets/wasm/hb.wasm"),
197
- path.join(currentDir, "node_modules", pkgName, "hb.wasm"),
192
+ path.join(currentDir, "node_modules/harfbuzzjs/hb.wasm"),
198
193
  path.join(currentDir, "node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm")
199
194
  );
200
195
  candidates.push(
201
- "/var/task/node_modules/" + pkgName + "/hb.wasm",
196
+ "/var/task/node_modules/harfbuzzjs/hb.wasm",
202
197
  "/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm"
203
198
  );
204
199
  console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
@@ -281,18 +276,6 @@ function setupWasmInterceptors(wasmBinary) {
281
276
  };
282
277
  }
283
278
  }
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
- }
296
279
  async function initHB(wasmBaseURL) {
297
280
  if (hbSingleton) return hbSingleton;
298
281
  try {
@@ -309,7 +292,7 @@ async function initHB(wasmBaseURL) {
309
292
  if (!isNode()) {
310
293
  setupWasmInterceptors(wasmBinary);
311
294
  }
312
- const mod = await importHarfBuzzJS();
295
+ const mod = await import("harfbuzzjs");
313
296
  let hb;
314
297
  const candidate = mod.default || mod;
315
298
  if (typeof candidate === "function") {
package/dist/entry.web.js CHANGED
@@ -143,10 +143,6 @@ 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
- }
150
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";
151
147
  async function fetchWasmFromUrl(url) {
152
148
  try {
@@ -175,11 +171,10 @@ async function loadWasmNode() {
175
171
  const { readFile } = await import("fs/promises");
176
172
  const path = await import("path");
177
173
  const candidates = [];
178
- const pkgName = getPkgName();
179
174
  try {
180
175
  const { createRequire } = await import("module");
181
176
  const requireFn = createRequire(import.meta.url || `file://${process.cwd()}/`);
182
- const harfbuzzPkgPath = requireFn.resolve(pkgName + "/package.json");
177
+ const harfbuzzPkgPath = requireFn.resolve("harfbuzzjs/package.json");
183
178
  const harfbuzzDir = path.dirname(harfbuzzPkgPath);
184
179
  candidates.push(path.join(harfbuzzDir, "hb.wasm"));
185
180
  } catch {
@@ -198,11 +193,11 @@ async function loadWasmNode() {
198
193
  candidates.push(
199
194
  path.join(currentDir, "dist/hb.wasm"),
200
195
  path.join(currentDir, "assets/wasm/hb.wasm"),
201
- path.join(currentDir, "node_modules", pkgName, "hb.wasm"),
196
+ path.join(currentDir, "node_modules/harfbuzzjs/hb.wasm"),
202
197
  path.join(currentDir, "node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm")
203
198
  );
204
199
  candidates.push(
205
- "/var/task/node_modules/" + pkgName + "/hb.wasm",
200
+ "/var/task/node_modules/harfbuzzjs/hb.wasm",
206
201
  "/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm"
207
202
  );
208
203
  console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
@@ -285,18 +280,6 @@ function setupWasmInterceptors(wasmBinary) {
285
280
  };
286
281
  }
287
282
  }
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
- }
300
283
  async function initHB(wasmBaseURL) {
301
284
  if (hbSingleton) return hbSingleton;
302
285
  try {
@@ -313,7 +296,7 @@ async function initHB(wasmBaseURL) {
313
296
  if (!isNode()) {
314
297
  setupWasmInterceptors(wasmBinary);
315
298
  }
316
- const mod = await importHarfBuzzJS();
299
+ const mod = await import("harfbuzzjs");
317
300
  let hb;
318
301
  const candidate = mod.default || mod;
319
302
  if (typeof candidate === "function") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotstack/shotstack-canvas",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "Text layout & animation engine (HarfBuzz) for Node & Web - fully self-contained.",
5
5
  "type": "module",
6
6
  "main": "./dist/entry.node.cjs",