@grida/canvas-wasm 0.0.6 → 0.0.8

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.
Binary file
package/dist/index.d.mts CHANGED
@@ -13,6 +13,7 @@ declare function createGridaCanvas(moduleArg?: {
13
13
 
14
14
  declare namespace createGridaCanvas {
15
15
  interface GridaCanvasWasmBindings {
16
+ // #region
16
17
  // ====================================================================================================
17
18
  // EMSCRIPTEN EXPOSED METHODS
18
19
  // ====================================================================================================
@@ -23,14 +24,26 @@ declare namespace createGridaCanvas {
23
24
  ): number;
24
25
  makeContextCurrent(handle: number): void;
25
26
  };
27
+
28
+ HEAP8: Int8Array;
29
+ HEAP16: Int16Array;
30
+ HEAP32: Int32Array;
26
31
  HEAPF32: Float32Array;
32
+ HEAPF64: Float64Array;
33
+ HEAPU8: Uint8Array;
34
+ HEAPU16: Uint16Array;
35
+ HEAPU32: Uint32Array;
36
+
37
+ UTF8ToString(ptr: number, maxBytesToRead?: number): string;
27
38
  stringToUTF8(str: string, outPtr: number, maxBytesToWrite: number): void;
28
39
  lengthBytesUTF8(str: string): number;
29
- UTF8ToString(ptr: number, maxBytesToRead?: number): string;
40
+
30
41
  ___wbindgen_malloc(a0: number, a1: number): number;
31
42
  ___wbindgen_free(a0: number, a1: number, a2: number): void;
32
43
  ___wbindgen_realloc(a0: number, a1: number, a2: number, a3: number): number;
33
44
 
45
+ // #endregion
46
+
34
47
  // core memory wrapper
35
48
  _allocate(len: number): number;
36
49
  _deallocate(ptr: number, len: number): void;
@@ -43,7 +56,7 @@ declare namespace createGridaCanvas {
43
56
  // ====================================================================================================
44
57
  // APPLICATION METHODS
45
58
  // ====================================================================================================
46
- _tick(state: GridaCanvasWebGlApplicationPtr): void;
59
+ _tick(state: GridaCanvasWebGlApplicationPtr, time: number): void;
47
60
  _resize_surface(
48
61
  state: GridaCanvasWebGlApplicationPtr,
49
62
  width: number,
@@ -97,6 +110,15 @@ declare namespace createGridaCanvas {
97
110
  ptr: number,
98
111
  len: number
99
112
  ): Ptr;
113
+
114
+ _export_node_as(
115
+ state: GridaCanvasWebGlApplicationPtr,
116
+ id_ptr: number,
117
+ id_len: number,
118
+ fmt_ptr: number,
119
+ fmt_len: number
120
+ ): Ptr;
121
+
100
122
  _command(
101
123
  state: GridaCanvasWebGlApplicationPtr,
102
124
  id: number,
@@ -154,6 +176,14 @@ type Rectangle = {
154
176
  width: number;
155
177
  height: number;
156
178
  };
179
+ type ExportConstraints = {
180
+ type: "SCALE" | "WIDTH" | "HEIGHT";
181
+ value: number;
182
+ };
183
+ type ExportAs = {
184
+ format: "PNG" | "JPEG" | "WEBP" | "BMP";
185
+ constraints: ExportConstraints;
186
+ };
157
187
  declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory>;
158
188
  declare class ApplicationFactory {
159
189
  private readonly module;
@@ -162,7 +192,7 @@ declare class ApplicationFactory {
162
192
  createWebGLCanvasSurfaceById(htmlcanvasid: string): Grida2D;
163
193
  }
164
194
  declare class Grida2D {
165
- private ptr;
195
+ private appptr;
166
196
  private module;
167
197
  constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
168
198
  _alloc_string(txt: string): [number, number];
@@ -183,8 +213,10 @@ declare class Grida2D {
183
213
  /**
184
214
  * Tick the application clock.
185
215
  * bind this to requestAnimationFrame loop or similar
216
+ * @param time - The time in milliseconds. use performance.now()
217
+ * @default - performance.now()
186
218
  */
187
- tick(): void;
219
+ tick(time?: number): void;
188
220
  /**
189
221
  * Resize the surface.
190
222
  * @param width - The width of the surface.
@@ -197,6 +229,9 @@ declare class Grida2D {
197
229
  getNodeIdsFromPoint(x: number, y: number): string[];
198
230
  getNodeIdsFromEnvelope(envelope: Rectangle): string[];
199
231
  getNodeAbsoluteBoundingBox(id: string): Rectangle | null;
232
+ exportNodeAs(id: string, format: ExportAs): {
233
+ data: Uint8Array;
234
+ };
200
235
  execCommand(command: "ZoomIn" | "ZoomOut"): void;
201
236
  execCommandPan(tx: number, ty: number): void;
202
237
  execCommandZoomDelta(tz: number): void;
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ declare function createGridaCanvas(moduleArg?: {
13
13
 
14
14
  declare namespace createGridaCanvas {
15
15
  interface GridaCanvasWasmBindings {
16
+ // #region
16
17
  // ====================================================================================================
17
18
  // EMSCRIPTEN EXPOSED METHODS
18
19
  // ====================================================================================================
@@ -23,14 +24,26 @@ declare namespace createGridaCanvas {
23
24
  ): number;
24
25
  makeContextCurrent(handle: number): void;
25
26
  };
27
+
28
+ HEAP8: Int8Array;
29
+ HEAP16: Int16Array;
30
+ HEAP32: Int32Array;
26
31
  HEAPF32: Float32Array;
32
+ HEAPF64: Float64Array;
33
+ HEAPU8: Uint8Array;
34
+ HEAPU16: Uint16Array;
35
+ HEAPU32: Uint32Array;
36
+
37
+ UTF8ToString(ptr: number, maxBytesToRead?: number): string;
27
38
  stringToUTF8(str: string, outPtr: number, maxBytesToWrite: number): void;
28
39
  lengthBytesUTF8(str: string): number;
29
- UTF8ToString(ptr: number, maxBytesToRead?: number): string;
40
+
30
41
  ___wbindgen_malloc(a0: number, a1: number): number;
31
42
  ___wbindgen_free(a0: number, a1: number, a2: number): void;
32
43
  ___wbindgen_realloc(a0: number, a1: number, a2: number, a3: number): number;
33
44
 
45
+ // #endregion
46
+
34
47
  // core memory wrapper
35
48
  _allocate(len: number): number;
36
49
  _deallocate(ptr: number, len: number): void;
@@ -43,7 +56,7 @@ declare namespace createGridaCanvas {
43
56
  // ====================================================================================================
44
57
  // APPLICATION METHODS
45
58
  // ====================================================================================================
46
- _tick(state: GridaCanvasWebGlApplicationPtr): void;
59
+ _tick(state: GridaCanvasWebGlApplicationPtr, time: number): void;
47
60
  _resize_surface(
48
61
  state: GridaCanvasWebGlApplicationPtr,
49
62
  width: number,
@@ -97,6 +110,15 @@ declare namespace createGridaCanvas {
97
110
  ptr: number,
98
111
  len: number
99
112
  ): Ptr;
113
+
114
+ _export_node_as(
115
+ state: GridaCanvasWebGlApplicationPtr,
116
+ id_ptr: number,
117
+ id_len: number,
118
+ fmt_ptr: number,
119
+ fmt_len: number
120
+ ): Ptr;
121
+
100
122
  _command(
101
123
  state: GridaCanvasWebGlApplicationPtr,
102
124
  id: number,
@@ -154,6 +176,14 @@ type Rectangle = {
154
176
  width: number;
155
177
  height: number;
156
178
  };
179
+ type ExportConstraints = {
180
+ type: "SCALE" | "WIDTH" | "HEIGHT";
181
+ value: number;
182
+ };
183
+ type ExportAs = {
184
+ format: "PNG" | "JPEG" | "WEBP" | "BMP";
185
+ constraints: ExportConstraints;
186
+ };
157
187
  declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory>;
158
188
  declare class ApplicationFactory {
159
189
  private readonly module;
@@ -162,7 +192,7 @@ declare class ApplicationFactory {
162
192
  createWebGLCanvasSurfaceById(htmlcanvasid: string): Grida2D;
163
193
  }
164
194
  declare class Grida2D {
165
- private ptr;
195
+ private appptr;
166
196
  private module;
167
197
  constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
168
198
  _alloc_string(txt: string): [number, number];
@@ -183,8 +213,10 @@ declare class Grida2D {
183
213
  /**
184
214
  * Tick the application clock.
185
215
  * bind this to requestAnimationFrame loop or similar
216
+ * @param time - The time in milliseconds. use performance.now()
217
+ * @default - performance.now()
186
218
  */
187
- tick(): void;
219
+ tick(time?: number): void;
188
220
  /**
189
221
  * Resize the surface.
190
222
  * @param width - The width of the surface.
@@ -197,6 +229,9 @@ declare class Grida2D {
197
229
  getNodeIdsFromPoint(x: number, y: number): string[];
198
230
  getNodeIdsFromEnvelope(envelope: Rectangle): string[];
199
231
  getNodeAbsoluteBoundingBox(id: string): Rectangle | null;
232
+ exportNodeAs(id: string, format: ExportAs): {
233
+ data: Uint8Array;
234
+ };
200
235
  execCommand(command: "ZoomIn" | "ZoomOut"): void;
201
236
  execCommandPan(tx: number, ty: number): void;
202
237
  execCommandZoomDelta(tz: number): void;