@canveletedotcom/sdk 2.0.1 → 2.0.2
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/resources/render.js +11 -2
- package/package.json +4 -1
package/dist/resources/render.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Render resource for creating and managing render jobs
|
|
3
3
|
*/
|
|
4
|
-
import { writeFileSync } from 'fs';
|
|
5
4
|
import { ValidationError } from '../errors';
|
|
5
|
+
// Helper to check if we're in a Node.js environment
|
|
6
|
+
const isNode = typeof process !== 'undefined' && process.versions?.node;
|
|
7
|
+
// Dynamic import for fs (only available in Node.js)
|
|
8
|
+
const writeFile = async (path, data) => {
|
|
9
|
+
if (!isNode) {
|
|
10
|
+
throw new Error('File writing is only available in Node.js environments');
|
|
11
|
+
}
|
|
12
|
+
const { writeFileSync } = await import('fs');
|
|
13
|
+
writeFileSync(path, data);
|
|
14
|
+
};
|
|
6
15
|
export class RenderResource {
|
|
7
16
|
constructor(client) {
|
|
8
17
|
this.client = client;
|
|
@@ -37,7 +46,7 @@ export class RenderResource {
|
|
|
37
46
|
binary: true,
|
|
38
47
|
});
|
|
39
48
|
if (options.outputFile) {
|
|
40
|
-
|
|
49
|
+
await writeFile(options.outputFile, Buffer.from(imageData));
|
|
41
50
|
}
|
|
42
51
|
return imageData;
|
|
43
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canveletedotcom/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Official TypeScript SDK for the Canvelete API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -53,5 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=18.0.0"
|
|
56
|
+
},
|
|
57
|
+
"browser": {
|
|
58
|
+
"fs": false
|
|
56
59
|
}
|
|
57
60
|
}
|