-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
index.node.ts
49 lines (41 loc) · 1.27 KB
/
index.node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// First we set the env variable
import { setEnv } from './src/env';
import { getEnv, getNodeCanvas } from './src/env/node';
setEnv(getEnv());
// After the env is set we can export everything and expose specific node functionality
import type { JpegConfig, PngConfig } from 'canvas';
import {
Canvas as CanvasBase,
StaticCanvas as StaticCanvasBase,
} from './fabric';
import { FabricObject } from './src/shapes/Object/Object';
FabricObject.ownDefaults.objectCaching = false;
export * from './fabric';
export class StaticCanvas extends StaticCanvasBase {
getNodeCanvas() {
return getNodeCanvas(this.getElement());
}
createPNGStream(opts?: PngConfig) {
return this.getNodeCanvas().createPNGStream(opts);
}
createJPEGStream(opts?: JpegConfig) {
return this.getNodeCanvas().createJPEGStream(opts);
}
}
/**
* **NOTICE**:
* {@link Canvas} is designed for interactivity.
* Therefore, using it in node has no benefit.
* Use {@link StaticCanvas} instead.
*/
export class Canvas extends CanvasBase {
getNodeCanvas() {
return getNodeCanvas(this.getElement());
}
createPNGStream(opts?: PngConfig) {
return this.getNodeCanvas().createPNGStream(opts);
}
createJPEGStream(opts?: JpegConfig) {
return this.getNodeCanvas().createJPEGStream(opts);
}
}