@shotstack/shotstack-canvas 1.3.2 → 1.3.4

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.
@@ -182,6 +182,7 @@ function bufferToArrayBuffer(buffer) {
182
182
  var DEFAULT_WASM_URL = "https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm";
183
183
  async function fetchWasmFromUrl(url) {
184
184
  try {
185
+ console.log(`\u{1F310} Fetching WASM from URL: ${url}`);
185
186
  const response = await fetch(url);
186
187
  if (response.ok) {
187
188
  const arrayBuffer = await response.arrayBuffer();
@@ -189,15 +190,19 @@ async function fetchWasmFromUrl(url) {
189
190
  if (bytes.length >= 4 && bytes[0] === 0 && bytes[1] === 97 && bytes[2] === 115 && bytes[3] === 109) {
190
191
  console.log(`\u2705 Fetched WASM from URL (${bytes.length} bytes)`);
191
192
  return arrayBuffer;
193
+ } else {
194
+ console.error(`\u274C Invalid WASM magic number from URL: ${url}`);
192
195
  }
196
+ } else {
197
+ console.error(`\u274C Failed to fetch WASM from URL: ${url}, status: ${response.status}`);
193
198
  }
194
199
  return void 0;
195
200
  } catch (err) {
196
- console.warn(`Failed to fetch WASM from ${url}:`, err);
201
+ console.error(`\u274C Error fetching WASM from ${url}:`, err);
197
202
  return void 0;
198
203
  }
199
204
  }
200
- async function loadWasmNode(wasmBaseURL) {
205
+ async function loadWasmNode() {
201
206
  try {
202
207
  const { readFile: readFile2 } = await import("fs/promises");
203
208
  const { fileURLToPath } = await import("url");
@@ -213,23 +218,20 @@ async function loadWasmNode(wasmBaseURL) {
213
218
  } catch {
214
219
  }
215
220
  const candidates = [
216
- // First try the harfbuzzjs package location (resolved via require)
221
+ // First try the harfbuzzjs package location
217
222
  ...harfbuzzWasmPath ? [harfbuzzWasmPath] : [],
218
- // Lambda environment paths
219
- "/var/task/node_modules/harfbuzzjs/hb.wasm",
220
- "/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm",
221
- // Relative paths from current directory
223
+ // Then try relative paths from current directory
222
224
  path.join(currentDir, "../../dist/hb.wasm"),
223
225
  path.join(currentDir, "../dist/hb.wasm"),
224
226
  path.join(currentDir, "../../assets/wasm/hb.wasm"),
225
227
  path.join(currentDir, "../assets/wasm/hb.wasm"),
226
228
  path.join(currentDir, "./hb.wasm"),
227
229
  path.join(currentDir, "../hb.wasm"),
228
- // node_modules relative paths
230
+ // Also try node_modules paths relative to current dir
229
231
  path.join(currentDir, "../../node_modules/harfbuzzjs/hb.wasm"),
230
- path.join(currentDir, "../../../node_modules/harfbuzzjs/hb.wasm"),
231
- path.join(currentDir, "../../../../node_modules/harfbuzzjs/hb.wasm")
232
+ path.join(currentDir, "../../../node_modules/harfbuzzjs/hb.wasm")
232
233
  ];
234
+ console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
233
235
  for (const candidate of candidates) {
234
236
  try {
235
237
  const buffer = await readFile2(candidate);
@@ -239,10 +241,10 @@ async function loadWasmNode(wasmBaseURL) {
239
241
  continue;
240
242
  }
241
243
  }
242
- console.log("Local WASM not found, fetching from URL...");
243
- const urlToFetch = wasmBaseURL || DEFAULT_WASM_URL;
244
- return await fetchWasmFromUrl(urlToFetch);
245
- } catch {
244
+ console.log("\u{1F4C2} Local WASM not found, fetching from URL...");
245
+ return await fetchWasmFromUrl(DEFAULT_WASM_URL);
246
+ } catch (err) {
247
+ console.error("Error in loadWasmNode:", err);
246
248
  return void 0;
247
249
  }
248
250
  }
@@ -313,7 +315,7 @@ async function initHB(wasmBaseURL) {
313
315
  try {
314
316
  let wasmBinary;
315
317
  if (isNode()) {
316
- wasmBinary = await loadWasmNode(wasmBaseURL);
318
+ wasmBinary = await loadWasmNode();
317
319
  } else {
318
320
  wasmBinary = await loadWasmWeb(wasmBaseURL);
319
321
  }
@@ -143,6 +143,7 @@ function bufferToArrayBuffer(buffer) {
143
143
  var DEFAULT_WASM_URL = "https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm";
144
144
  async function fetchWasmFromUrl(url) {
145
145
  try {
146
+ console.log(`\u{1F310} Fetching WASM from URL: ${url}`);
146
147
  const response = await fetch(url);
147
148
  if (response.ok) {
148
149
  const arrayBuffer = await response.arrayBuffer();
@@ -150,15 +151,19 @@ async function fetchWasmFromUrl(url) {
150
151
  if (bytes.length >= 4 && bytes[0] === 0 && bytes[1] === 97 && bytes[2] === 115 && bytes[3] === 109) {
151
152
  console.log(`\u2705 Fetched WASM from URL (${bytes.length} bytes)`);
152
153
  return arrayBuffer;
154
+ } else {
155
+ console.error(`\u274C Invalid WASM magic number from URL: ${url}`);
153
156
  }
157
+ } else {
158
+ console.error(`\u274C Failed to fetch WASM from URL: ${url}, status: ${response.status}`);
154
159
  }
155
160
  return void 0;
156
161
  } catch (err) {
157
- console.warn(`Failed to fetch WASM from ${url}:`, err);
162
+ console.error(`\u274C Error fetching WASM from ${url}:`, err);
158
163
  return void 0;
159
164
  }
160
165
  }
161
- async function loadWasmNode(wasmBaseURL) {
166
+ async function loadWasmNode() {
162
167
  try {
163
168
  const { readFile: readFile2 } = await import("fs/promises");
164
169
  const { fileURLToPath } = await import("url");
@@ -174,23 +179,20 @@ async function loadWasmNode(wasmBaseURL) {
174
179
  } catch {
175
180
  }
176
181
  const candidates = [
177
- // First try the harfbuzzjs package location (resolved via require)
182
+ // First try the harfbuzzjs package location
178
183
  ...harfbuzzWasmPath ? [harfbuzzWasmPath] : [],
179
- // Lambda environment paths
180
- "/var/task/node_modules/harfbuzzjs/hb.wasm",
181
- "/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm",
182
- // Relative paths from current directory
184
+ // Then try relative paths from current directory
183
185
  path.join(currentDir, "../../dist/hb.wasm"),
184
186
  path.join(currentDir, "../dist/hb.wasm"),
185
187
  path.join(currentDir, "../../assets/wasm/hb.wasm"),
186
188
  path.join(currentDir, "../assets/wasm/hb.wasm"),
187
189
  path.join(currentDir, "./hb.wasm"),
188
190
  path.join(currentDir, "../hb.wasm"),
189
- // node_modules relative paths
191
+ // Also try node_modules paths relative to current dir
190
192
  path.join(currentDir, "../../node_modules/harfbuzzjs/hb.wasm"),
191
- path.join(currentDir, "../../../node_modules/harfbuzzjs/hb.wasm"),
192
- path.join(currentDir, "../../../../node_modules/harfbuzzjs/hb.wasm")
193
+ path.join(currentDir, "../../../node_modules/harfbuzzjs/hb.wasm")
193
194
  ];
195
+ console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
194
196
  for (const candidate of candidates) {
195
197
  try {
196
198
  const buffer = await readFile2(candidate);
@@ -200,10 +202,10 @@ async function loadWasmNode(wasmBaseURL) {
200
202
  continue;
201
203
  }
202
204
  }
203
- console.log("Local WASM not found, fetching from URL...");
204
- const urlToFetch = wasmBaseURL || DEFAULT_WASM_URL;
205
- return await fetchWasmFromUrl(urlToFetch);
206
- } catch {
205
+ console.log("\u{1F4C2} Local WASM not found, fetching from URL...");
206
+ return await fetchWasmFromUrl(DEFAULT_WASM_URL);
207
+ } catch (err) {
208
+ console.error("Error in loadWasmNode:", err);
207
209
  return void 0;
208
210
  }
209
211
  }
@@ -274,7 +276,7 @@ async function initHB(wasmBaseURL) {
274
276
  try {
275
277
  let wasmBinary;
276
278
  if (isNode()) {
277
- wasmBinary = await loadWasmNode(wasmBaseURL);
279
+ wasmBinary = await loadWasmNode();
278
280
  } else {
279
281
  wasmBinary = await loadWasmWeb(wasmBaseURL);
280
282
  }
package/dist/entry.web.js CHANGED
@@ -147,6 +147,7 @@ function bufferToArrayBuffer(buffer) {
147
147
  var DEFAULT_WASM_URL = "https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm";
148
148
  async function fetchWasmFromUrl(url) {
149
149
  try {
150
+ console.log(`\u{1F310} Fetching WASM from URL: ${url}`);
150
151
  const response = await fetch(url);
151
152
  if (response.ok) {
152
153
  const arrayBuffer = await response.arrayBuffer();
@@ -154,15 +155,19 @@ async function fetchWasmFromUrl(url) {
154
155
  if (bytes.length >= 4 && bytes[0] === 0 && bytes[1] === 97 && bytes[2] === 115 && bytes[3] === 109) {
155
156
  console.log(`\u2705 Fetched WASM from URL (${bytes.length} bytes)`);
156
157
  return arrayBuffer;
158
+ } else {
159
+ console.error(`\u274C Invalid WASM magic number from URL: ${url}`);
157
160
  }
161
+ } else {
162
+ console.error(`\u274C Failed to fetch WASM from URL: ${url}, status: ${response.status}`);
158
163
  }
159
164
  return void 0;
160
165
  } catch (err) {
161
- console.warn(`Failed to fetch WASM from ${url}:`, err);
166
+ console.error(`\u274C Error fetching WASM from ${url}:`, err);
162
167
  return void 0;
163
168
  }
164
169
  }
165
- async function loadWasmNode(wasmBaseURL) {
170
+ async function loadWasmNode() {
166
171
  try {
167
172
  const { readFile } = await import("fs/promises");
168
173
  const { fileURLToPath } = await import("url");
@@ -178,23 +183,20 @@ async function loadWasmNode(wasmBaseURL) {
178
183
  } catch {
179
184
  }
180
185
  const candidates = [
181
- // First try the harfbuzzjs package location (resolved via require)
186
+ // First try the harfbuzzjs package location
182
187
  ...harfbuzzWasmPath ? [harfbuzzWasmPath] : [],
183
- // Lambda environment paths
184
- "/var/task/node_modules/harfbuzzjs/hb.wasm",
185
- "/var/task/node_modules/@shotstack/shotstack-canvas/assets/wasm/hb.wasm",
186
- // Relative paths from current directory
188
+ // Then try relative paths from current directory
187
189
  path.join(currentDir, "../../dist/hb.wasm"),
188
190
  path.join(currentDir, "../dist/hb.wasm"),
189
191
  path.join(currentDir, "../../assets/wasm/hb.wasm"),
190
192
  path.join(currentDir, "../assets/wasm/hb.wasm"),
191
193
  path.join(currentDir, "./hb.wasm"),
192
194
  path.join(currentDir, "../hb.wasm"),
193
- // node_modules relative paths
195
+ // Also try node_modules paths relative to current dir
194
196
  path.join(currentDir, "../../node_modules/harfbuzzjs/hb.wasm"),
195
- path.join(currentDir, "../../../node_modules/harfbuzzjs/hb.wasm"),
196
- path.join(currentDir, "../../../../node_modules/harfbuzzjs/hb.wasm")
197
+ path.join(currentDir, "../../../node_modules/harfbuzzjs/hb.wasm")
197
198
  ];
199
+ console.log(`\u{1F50D} Searching for WASM in ${candidates.length} local paths...`);
198
200
  for (const candidate of candidates) {
199
201
  try {
200
202
  const buffer = await readFile(candidate);
@@ -204,10 +206,10 @@ async function loadWasmNode(wasmBaseURL) {
204
206
  continue;
205
207
  }
206
208
  }
207
- console.log("Local WASM not found, fetching from URL...");
208
- const urlToFetch = wasmBaseURL || DEFAULT_WASM_URL;
209
- return await fetchWasmFromUrl(urlToFetch);
210
- } catch {
209
+ console.log("\u{1F4C2} Local WASM not found, fetching from URL...");
210
+ return await fetchWasmFromUrl(DEFAULT_WASM_URL);
211
+ } catch (err) {
212
+ console.error("Error in loadWasmNode:", err);
211
213
  return void 0;
212
214
  }
213
215
  }
@@ -278,7 +280,7 @@ async function initHB(wasmBaseURL) {
278
280
  try {
279
281
  let wasmBinary;
280
282
  if (isNode()) {
281
- wasmBinary = await loadWasmNode(wasmBaseURL);
283
+ wasmBinary = await loadWasmNode();
282
284
  } else {
283
285
  wasmBinary = await loadWasmWeb(wasmBaseURL);
284
286
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotstack/shotstack-canvas",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
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",