@shotstack/shotstack-canvas 1.8.4 → 1.8.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/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # @shotstack/shotstack-canvas
2
-
3
- One package → identical text shaping/wrapping/animation on Web & Node.
4
- - HarfBuzz WASM for shaping and glyph outlines (via `harfbuzzjs`).
5
- - Device-independent draw-ops.
6
- - Painters: Canvas2D (web) and node-canvas (node).
7
- - Deterministic time-driven animations.
8
-
9
- ## Install
10
-
11
- ```bash
12
- pnpm add @shotstack/shotstack-canvas
13
- # or npm i / yarn add
1
+ # @shotstack/shotstack-canvas
2
+
3
+ One package → identical text shaping/wrapping/animation on Web & Node.
4
+ - HarfBuzz WASM for shaping and glyph outlines (via `harfbuzzjs`).
5
+ - Device-independent draw-ops.
6
+ - Painters: Canvas2D (web) and node-canvas (node).
7
+ - Deterministic time-driven animations.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @shotstack/shotstack-canvas
13
+ # or npm i / yarn add
@@ -327,7 +327,7 @@ function setupWasmInterceptors(wasmBinary) {
327
327
  const originalFetch = window.fetch;
328
328
  window.fetch = function(input, init) {
329
329
  const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
330
- if (url.includes("hb.wasm") || url.endsWith(".wasm") && !url.includes("source.wasm")) {
330
+ if (url.includes("hb.wasm")) {
331
331
  return Promise.resolve(
332
332
  new Response(wasmBinary.slice(0), {
333
333
  status: 200,
@@ -360,7 +360,7 @@ function setupWasmInterceptors(wasmBinary) {
360
360
  try {
361
361
  const response = await source;
362
362
  const url = response.url || "";
363
- if (url.includes("hb.wasm") || url.endsWith(".wasm") && !url.includes("source.wasm")) {
363
+ if (url.includes("hb.wasm")) {
364
364
  const module2 = await WebAssembly.compile(wasmBinary);
365
365
  const instance = await WebAssembly.instantiate(module2, importObject);
366
366
  return { module: module2, instance };
@@ -283,7 +283,7 @@ function setupWasmInterceptors(wasmBinary) {
283
283
  const originalFetch = window.fetch;
284
284
  window.fetch = function(input, init) {
285
285
  const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
286
- if (url.includes("hb.wasm") || url.endsWith(".wasm") && !url.includes("source.wasm")) {
286
+ if (url.includes("hb.wasm")) {
287
287
  return Promise.resolve(
288
288
  new Response(wasmBinary.slice(0), {
289
289
  status: 200,
@@ -316,7 +316,7 @@ function setupWasmInterceptors(wasmBinary) {
316
316
  try {
317
317
  const response = await source;
318
318
  const url = response.url || "";
319
- if (url.includes("hb.wasm") || url.endsWith(".wasm") && !url.includes("source.wasm")) {
319
+ if (url.includes("hb.wasm")) {
320
320
  const module = await WebAssembly.compile(wasmBinary);
321
321
  const instance = await WebAssembly.instantiate(module, importObject);
322
322
  return { module, instance };
package/dist/entry.web.js CHANGED
@@ -287,7 +287,7 @@ function setupWasmInterceptors(wasmBinary) {
287
287
  const originalFetch = window.fetch;
288
288
  window.fetch = function(input, init) {
289
289
  const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
290
- if (url.includes("hb.wasm") || url.endsWith(".wasm") && !url.includes("source.wasm")) {
290
+ if (url.includes("hb.wasm")) {
291
291
  return Promise.resolve(
292
292
  new Response(wasmBinary.slice(0), {
293
293
  status: 200,
@@ -320,7 +320,7 @@ function setupWasmInterceptors(wasmBinary) {
320
320
  try {
321
321
  const response = await source;
322
322
  const url = response.url || "";
323
- if (url.includes("hb.wasm") || url.endsWith(".wasm") && !url.includes("source.wasm")) {
323
+ if (url.includes("hb.wasm")) {
324
324
  const module = await WebAssembly.compile(wasmBinary);
325
325
  const instance = await WebAssembly.instantiate(module, importObject);
326
326
  return { module, instance };
@@ -355,10 +355,10 @@ async function initHB(wasmBaseURL) {
355
355
  }
356
356
  };
357
357
  }
358
- const hbModule = await import("./hb-ODWKSLMB.js");
358
+ const hbModule = await import("./hb-KXF2MJ2J.js");
359
359
  const hbFactory = hbModule.default || hbModule;
360
360
  const hbInstance = await hbFactory({ wasmBinary });
361
- const hbjsModule = await import("./hbjs-HHU2TAW7.js");
361
+ const hbjsModule = await import("./hbjs-ZTRARROF.js");
362
362
  const hbjsWrapper = hbjsModule.default || hbjsModule;
363
363
  const hb = hbjsWrapper(hbInstance);
364
364
  if (!hb || typeof hb.createBuffer !== "function" || typeof hb.createFont !== "function") {
@@ -4,9 +4,9 @@ import {
4
4
  __require
5
5
  } from "./chunk-HYGMWVDX.js";
6
6
 
7
- // node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.js
7
+ // node_modules/harfbuzzjs/hb.js
8
8
  var require_hb = __commonJS({
9
- "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.js"(exports, module) {
9
+ "node_modules/harfbuzzjs/hb.js"(exports, module) {
10
10
  var createHarfBuzz = (() => {
11
11
  var _scriptName = typeof document != "undefined" ? document.currentScript?.src : void 0;
12
12
  return async function(moduleArg = {}) {
@@ -2,9 +2,9 @@ import {
2
2
  __commonJS
3
3
  } from "./chunk-HYGMWVDX.js";
4
4
 
5
- // node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hbjs.js
5
+ // node_modules/harfbuzzjs/hbjs.js
6
6
  var require_hbjs = __commonJS({
7
- "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hbjs.js"(exports, module) {
7
+ "node_modules/harfbuzzjs/hbjs.js"(exports, module) {
8
8
  function hbjs(Module) {
9
9
  "use strict";
10
10
  var exports2 = Module.wasmExports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotstack/shotstack-canvas",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
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",
@@ -1,58 +1,58 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Postinstall script to verify native canvas bindings are available
5
- * This helps catch issues early and provides helpful guidance
6
- */
7
-
8
- import { platform as _platform, arch as _arch } from 'os';
9
- import { dirname } from 'path';
10
- import { readdirSync } from 'fs';
11
- import { createRequire } from 'module';
12
-
13
- const require = createRequire(import.meta.url);
14
-
15
- const platform = _platform();
16
- const arch = _arch();
17
-
18
- // Map platform/arch to package names
19
- const platformMap = {
20
- 'darwin-arm64': '@napi-rs/canvas-darwin-arm64',
21
- 'darwin-x64': '@napi-rs/canvas-darwin-x64',
22
- 'linux-arm64': '@napi-rs/canvas-linux-arm64-gnu',
23
- 'linux-x64': '@napi-rs/canvas-linux-x64-gnu',
24
- 'win32-x64': '@napi-rs/canvas-win32-x64-msvc',
25
- 'linux-arm': '@napi-rs/canvas-linux-arm-gnueabihf',
26
- 'android-arm64': '@napi-rs/canvas-android-arm64',
27
- };
28
-
29
- const platformKey = `${platform}-${arch}`;
30
- const requiredPackage = platformMap[platformKey];
31
-
32
- if (!requiredPackage) {
33
- console.warn(`\n⚠️ Warning: Unsupported platform ${platformKey} for @napi-rs/canvas`);
34
- console.warn(' Canvas rendering may not work on this platform.\n');
35
- process.exit(0);
36
- }
37
-
38
- // Check if the native binding package is installed
39
- try {
40
- const packagePath = require.resolve(`${requiredPackage}/package.json`);
41
- const packageDir = dirname(packagePath);
42
-
43
- // Verify the .node file exists
44
- const nodeFiles = readdirSync(packageDir).filter(f => f.endsWith('.node'));
45
-
46
- if (nodeFiles.length > 0) {
47
- console.log(`✅ @shotstack/shotstack-canvas: Native canvas binding found for ${platformKey}`);
48
- } else {
49
- throw new Error('No .node file found');
50
- }
51
- } catch (error) {
52
- console.warn(`\n⚠️ Warning: Native canvas binding not found for ${platformKey}`);
53
- console.warn(` Expected package: ${requiredPackage}`);
54
- console.warn('\n If you see "Cannot find native binding" errors, try:');
55
- console.warn(' 1. Delete node_modules and package-lock.json');
56
- console.warn(' 2. Run: npm install');
57
- console.warn(` 3. Or manually install: npm install ${requiredPackage}\n`);
58
- }
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall script to verify native canvas bindings are available
5
+ * This helps catch issues early and provides helpful guidance
6
+ */
7
+
8
+ import { platform as _platform, arch as _arch } from 'os';
9
+ import { dirname } from 'path';
10
+ import { readdirSync } from 'fs';
11
+ import { createRequire } from 'module';
12
+
13
+ const require = createRequire(import.meta.url);
14
+
15
+ const platform = _platform();
16
+ const arch = _arch();
17
+
18
+ // Map platform/arch to package names
19
+ const platformMap = {
20
+ 'darwin-arm64': '@napi-rs/canvas-darwin-arm64',
21
+ 'darwin-x64': '@napi-rs/canvas-darwin-x64',
22
+ 'linux-arm64': '@napi-rs/canvas-linux-arm64-gnu',
23
+ 'linux-x64': '@napi-rs/canvas-linux-x64-gnu',
24
+ 'win32-x64': '@napi-rs/canvas-win32-x64-msvc',
25
+ 'linux-arm': '@napi-rs/canvas-linux-arm-gnueabihf',
26
+ 'android-arm64': '@napi-rs/canvas-android-arm64',
27
+ };
28
+
29
+ const platformKey = `${platform}-${arch}`;
30
+ const requiredPackage = platformMap[platformKey];
31
+
32
+ if (!requiredPackage) {
33
+ console.warn(`\n⚠️ Warning: Unsupported platform ${platformKey} for @napi-rs/canvas`);
34
+ console.warn(' Canvas rendering may not work on this platform.\n');
35
+ process.exit(0);
36
+ }
37
+
38
+ // Check if the native binding package is installed
39
+ try {
40
+ const packagePath = require.resolve(`${requiredPackage}/package.json`);
41
+ const packageDir = dirname(packagePath);
42
+
43
+ // Verify the .node file exists
44
+ const nodeFiles = readdirSync(packageDir).filter(f => f.endsWith('.node'));
45
+
46
+ if (nodeFiles.length > 0) {
47
+ console.log(`✅ @shotstack/shotstack-canvas: Native canvas binding found for ${platformKey}`);
48
+ } else {
49
+ throw new Error('No .node file found');
50
+ }
51
+ } catch (error) {
52
+ console.warn(`\n⚠️ Warning: Native canvas binding not found for ${platformKey}`);
53
+ console.warn(` Expected package: ${requiredPackage}`);
54
+ console.warn('\n If you see "Cannot find native binding" errors, try:');
55
+ console.warn(' 1. Delete node_modules and package-lock.json');
56
+ console.warn(' 2. Run: npm install');
57
+ console.warn(` 3. Or manually install: npm install ${requiredPackage}\n`);
58
+ }