@shotstack/shotstack-canvas 1.2.7 → 1.2.9
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/package.json +3 -1
- package/scripts/postinstall.js +58 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shotstack/shotstack-canvas",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
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",
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist/**",
|
|
22
|
+
"scripts/postinstall.js",
|
|
22
23
|
"README.md",
|
|
23
24
|
"LICENSE"
|
|
24
25
|
],
|
|
25
26
|
"scripts": {
|
|
26
27
|
"dev": "tsup --watch",
|
|
27
28
|
"build": "tsup",
|
|
29
|
+
"postinstall": "node scripts/postinstall.js",
|
|
28
30
|
"vendor:harfbuzz": "node scripts/vendor-harfbuzz.js",
|
|
29
31
|
"example:node": "node examples/node-example.mjs",
|
|
30
32
|
"example:video": "node examples/node-video.mjs",
|
|
@@ -0,0 +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
|
+
}
|