@grida/canvas-wasm 0.0.6 → 0.0.7
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/grida-canvas-wasm.js +1 -1
- package/dist/grida_canvas_wasm.wasm +0 -0
- package/dist/index.d.mts +30 -3
- package/dist/index.d.ts +30 -3
- package/dist/index.js +189 -153
- package/dist/index.mjs +189 -153
- package/package.json +1 -1
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -23,7 +23,12 @@ declare namespace createGridaCanvas {
|
|
|
23
23
|
): number;
|
|
24
24
|
makeContextCurrent(handle: number): void;
|
|
25
25
|
};
|
|
26
|
+
HEAP8: Int8Array;
|
|
27
|
+
HEAP16: Int16Array;
|
|
28
|
+
HEAP32: Int32Array;
|
|
26
29
|
HEAPF32: Float32Array;
|
|
30
|
+
HEAPF64: Float64Array;
|
|
31
|
+
HEAPU8: Uint8Array;
|
|
27
32
|
stringToUTF8(str: string, outPtr: number, maxBytesToWrite: number): void;
|
|
28
33
|
lengthBytesUTF8(str: string): number;
|
|
29
34
|
UTF8ToString(ptr: number, maxBytesToRead?: number): string;
|
|
@@ -43,7 +48,7 @@ declare namespace createGridaCanvas {
|
|
|
43
48
|
// ====================================================================================================
|
|
44
49
|
// APPLICATION METHODS
|
|
45
50
|
// ====================================================================================================
|
|
46
|
-
_tick(state: GridaCanvasWebGlApplicationPtr): void;
|
|
51
|
+
_tick(state: GridaCanvasWebGlApplicationPtr, time: number): void;
|
|
47
52
|
_resize_surface(
|
|
48
53
|
state: GridaCanvasWebGlApplicationPtr,
|
|
49
54
|
width: number,
|
|
@@ -97,6 +102,15 @@ declare namespace createGridaCanvas {
|
|
|
97
102
|
ptr: number,
|
|
98
103
|
len: number
|
|
99
104
|
): Ptr;
|
|
105
|
+
|
|
106
|
+
_export_node_as(
|
|
107
|
+
state: GridaCanvasWebGlApplicationPtr,
|
|
108
|
+
id_ptr: number,
|
|
109
|
+
id_len: number,
|
|
110
|
+
fmt_ptr: number,
|
|
111
|
+
fmt_len: number
|
|
112
|
+
): Ptr;
|
|
113
|
+
|
|
100
114
|
_command(
|
|
101
115
|
state: GridaCanvasWebGlApplicationPtr,
|
|
102
116
|
id: number,
|
|
@@ -154,6 +168,14 @@ type Rectangle = {
|
|
|
154
168
|
width: number;
|
|
155
169
|
height: number;
|
|
156
170
|
};
|
|
171
|
+
type ExportConstraints = {
|
|
172
|
+
type: "SCALE" | "WIDTH" | "HEIGHT";
|
|
173
|
+
value: number;
|
|
174
|
+
};
|
|
175
|
+
type ExportAs = {
|
|
176
|
+
format: "PNG" | "JPEG" | "WEBP" | "BMP";
|
|
177
|
+
constraints: ExportConstraints;
|
|
178
|
+
};
|
|
157
179
|
declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory>;
|
|
158
180
|
declare class ApplicationFactory {
|
|
159
181
|
private readonly module;
|
|
@@ -162,7 +184,7 @@ declare class ApplicationFactory {
|
|
|
162
184
|
createWebGLCanvasSurfaceById(htmlcanvasid: string): Grida2D;
|
|
163
185
|
}
|
|
164
186
|
declare class Grida2D {
|
|
165
|
-
private
|
|
187
|
+
private appptr;
|
|
166
188
|
private module;
|
|
167
189
|
constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
|
|
168
190
|
_alloc_string(txt: string): [number, number];
|
|
@@ -183,8 +205,10 @@ declare class Grida2D {
|
|
|
183
205
|
/**
|
|
184
206
|
* Tick the application clock.
|
|
185
207
|
* bind this to requestAnimationFrame loop or similar
|
|
208
|
+
* @param time - The time in milliseconds. use performance.now()
|
|
209
|
+
* @default - performance.now()
|
|
186
210
|
*/
|
|
187
|
-
tick(): void;
|
|
211
|
+
tick(time?: number): void;
|
|
188
212
|
/**
|
|
189
213
|
* Resize the surface.
|
|
190
214
|
* @param width - The width of the surface.
|
|
@@ -197,6 +221,9 @@ declare class Grida2D {
|
|
|
197
221
|
getNodeIdsFromPoint(x: number, y: number): string[];
|
|
198
222
|
getNodeIdsFromEnvelope(envelope: Rectangle): string[];
|
|
199
223
|
getNodeAbsoluteBoundingBox(id: string): Rectangle | null;
|
|
224
|
+
exportNodeAs(id: string, format: ExportAs): {
|
|
225
|
+
data: Uint8Array;
|
|
226
|
+
};
|
|
200
227
|
execCommand(command: "ZoomIn" | "ZoomOut"): void;
|
|
201
228
|
execCommandPan(tx: number, ty: number): void;
|
|
202
229
|
execCommandZoomDelta(tz: number): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,12 @@ declare namespace createGridaCanvas {
|
|
|
23
23
|
): number;
|
|
24
24
|
makeContextCurrent(handle: number): void;
|
|
25
25
|
};
|
|
26
|
+
HEAP8: Int8Array;
|
|
27
|
+
HEAP16: Int16Array;
|
|
28
|
+
HEAP32: Int32Array;
|
|
26
29
|
HEAPF32: Float32Array;
|
|
30
|
+
HEAPF64: Float64Array;
|
|
31
|
+
HEAPU8: Uint8Array;
|
|
27
32
|
stringToUTF8(str: string, outPtr: number, maxBytesToWrite: number): void;
|
|
28
33
|
lengthBytesUTF8(str: string): number;
|
|
29
34
|
UTF8ToString(ptr: number, maxBytesToRead?: number): string;
|
|
@@ -43,7 +48,7 @@ declare namespace createGridaCanvas {
|
|
|
43
48
|
// ====================================================================================================
|
|
44
49
|
// APPLICATION METHODS
|
|
45
50
|
// ====================================================================================================
|
|
46
|
-
_tick(state: GridaCanvasWebGlApplicationPtr): void;
|
|
51
|
+
_tick(state: GridaCanvasWebGlApplicationPtr, time: number): void;
|
|
47
52
|
_resize_surface(
|
|
48
53
|
state: GridaCanvasWebGlApplicationPtr,
|
|
49
54
|
width: number,
|
|
@@ -97,6 +102,15 @@ declare namespace createGridaCanvas {
|
|
|
97
102
|
ptr: number,
|
|
98
103
|
len: number
|
|
99
104
|
): Ptr;
|
|
105
|
+
|
|
106
|
+
_export_node_as(
|
|
107
|
+
state: GridaCanvasWebGlApplicationPtr,
|
|
108
|
+
id_ptr: number,
|
|
109
|
+
id_len: number,
|
|
110
|
+
fmt_ptr: number,
|
|
111
|
+
fmt_len: number
|
|
112
|
+
): Ptr;
|
|
113
|
+
|
|
100
114
|
_command(
|
|
101
115
|
state: GridaCanvasWebGlApplicationPtr,
|
|
102
116
|
id: number,
|
|
@@ -154,6 +168,14 @@ type Rectangle = {
|
|
|
154
168
|
width: number;
|
|
155
169
|
height: number;
|
|
156
170
|
};
|
|
171
|
+
type ExportConstraints = {
|
|
172
|
+
type: "SCALE" | "WIDTH" | "HEIGHT";
|
|
173
|
+
value: number;
|
|
174
|
+
};
|
|
175
|
+
type ExportAs = {
|
|
176
|
+
format: "PNG" | "JPEG" | "WEBP" | "BMP";
|
|
177
|
+
constraints: ExportConstraints;
|
|
178
|
+
};
|
|
157
179
|
declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory>;
|
|
158
180
|
declare class ApplicationFactory {
|
|
159
181
|
private readonly module;
|
|
@@ -162,7 +184,7 @@ declare class ApplicationFactory {
|
|
|
162
184
|
createWebGLCanvasSurfaceById(htmlcanvasid: string): Grida2D;
|
|
163
185
|
}
|
|
164
186
|
declare class Grida2D {
|
|
165
|
-
private
|
|
187
|
+
private appptr;
|
|
166
188
|
private module;
|
|
167
189
|
constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
|
|
168
190
|
_alloc_string(txt: string): [number, number];
|
|
@@ -183,8 +205,10 @@ declare class Grida2D {
|
|
|
183
205
|
/**
|
|
184
206
|
* Tick the application clock.
|
|
185
207
|
* bind this to requestAnimationFrame loop or similar
|
|
208
|
+
* @param time - The time in milliseconds. use performance.now()
|
|
209
|
+
* @default - performance.now()
|
|
186
210
|
*/
|
|
187
|
-
tick(): void;
|
|
211
|
+
tick(time?: number): void;
|
|
188
212
|
/**
|
|
189
213
|
* Resize the surface.
|
|
190
214
|
* @param width - The width of the surface.
|
|
@@ -197,6 +221,9 @@ declare class Grida2D {
|
|
|
197
221
|
getNodeIdsFromPoint(x: number, y: number): string[];
|
|
198
222
|
getNodeIdsFromEnvelope(envelope: Rectangle): string[];
|
|
199
223
|
getNodeAbsoluteBoundingBox(id: string): Rectangle | null;
|
|
224
|
+
exportNodeAs(id: string, format: ExportAs): {
|
|
225
|
+
data: Uint8Array;
|
|
226
|
+
};
|
|
200
227
|
execCommand(command: "ZoomIn" | "ZoomOut"): void;
|
|
201
228
|
execCommandPan(tx: number, ty: number): void;
|
|
202
229
|
execCommandZoomDelta(tz: number): void;
|