@grida/canvas-wasm 0.0.1 → 0.0.3

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/README.md CHANGED
@@ -12,23 +12,16 @@ pnpm install @grida/canvas-wasm
12
12
  import init from "@grida/canvas-wasm";
13
13
 
14
14
  const factory = await init({
15
- // locate the wasm binary file
15
+ // locate the wasm binary file (location may vary by version)
16
+ // e.g. this will resolve to https://unpkg.com/@grida/canvas-wasm@0.0.2/dist/grida_canvas_wasm.wasm
16
17
  locateFile: (path) =>
17
- `https://unpkg.com/@grida/canvas-wasm@<VERSION>/bin/${path}`,
18
+ `https://unpkg.com/@grida/canvas-wasm@<VERSION>/${path}`,
18
19
  });
19
20
 
20
21
  // your canvas element
21
- const canvas = document.querySelector("#canvas");
22
- const context = canvas.getContext("webgl2", {
23
- antialias: true,
24
- depth: true,
25
- stencil: true,
26
- alpha: true,
27
- });
28
-
29
- const scene = factory.createSurface(context, 100, 100);
22
+ const canvas = document.getElementById("canvas") as HTMLCanvasElement;
23
+ const scene = factory.createWebGLCanvasSurface(canvas);
30
24
 
31
25
  // ready to draw
32
- scene.createRectangleNode();
33
- scene.redraw();
26
+ scene.loadDummyScene();
34
27
  ```
package/dist/index.d.mts CHANGED
@@ -1,3 +1,91 @@
1
+ declare function createGridaCanvas(moduleArg?: {
2
+ locateFile?: (path: string, scriptDirectory: string) => string;
3
+ }): Promise<createGridaCanvas.GridaCanvasWasmBindings>;
4
+
5
+ declare namespace createGridaCanvas {
6
+ interface GridaCanvasWasmBindings {
7
+ // ====================================================================================================
8
+ // EMSCRIPTEN EXPOSED METHODS
9
+ // ====================================================================================================
10
+ GL: {
11
+ registerContext(
12
+ context: WebGLRenderingContext,
13
+ options: { majorVersion: number }
14
+ ): number;
15
+ makeContextCurrent(handle: number): void;
16
+ };
17
+ stringToUTF8(str: string, outPtr: number, maxBytesToWrite: number): void;
18
+ lengthBytesUTF8(str: string): number;
19
+ ___wbindgen_malloc(a0: number, a1: number): number;
20
+ ___wbindgen_free(a0: number, a1: number, a2: number): void;
21
+ ___wbindgen_realloc(a0: number, a1: number, a2: number, a3: number): number;
22
+
23
+ // core memory wrapper
24
+ _allocate(len: number): number;
25
+ _deallocate(ptr: number, len: number): void;
26
+
27
+ // ====================================================================================================
28
+ // INITIALIZATION
29
+ // ====================================================================================================
30
+ _init(width: number, height: number): GridaCanvasWebGlApplicationPtr;
31
+
32
+ // ====================================================================================================
33
+ // APPLICATION METHODS
34
+ // ====================================================================================================
35
+ _tick(state: GridaCanvasWebGlApplicationPtr): void;
36
+ _resize_surface(
37
+ state: GridaCanvasWebGlApplicationPtr,
38
+ width: number,
39
+ height: number
40
+ ): void;
41
+ _redraw(state: GridaCanvasWebGlApplicationPtr): void;
42
+ _load_scene_json(
43
+ state: GridaCanvasWebGlApplicationPtr,
44
+ ptr: number,
45
+ len: number
46
+ ): void;
47
+ _load_dummy_scene(state: GridaCanvasWebGlApplicationPtr): void;
48
+ _load_benchmark_scene(
49
+ state: GridaCanvasWebGlApplicationPtr,
50
+ cols: number,
51
+ rows: number
52
+ ): void;
53
+ _pointer_move(
54
+ state: GridaCanvasWebGlApplicationPtr,
55
+ x: number,
56
+ y: number
57
+ ): void;
58
+ _command(
59
+ state: GridaCanvasWebGlApplicationPtr,
60
+ id: number,
61
+ a: number,
62
+ b: number
63
+ ): void;
64
+ _devtools_rendering_set_show_tiles(
65
+ state: GridaCanvasWebGlApplicationPtr,
66
+ show: boolean
67
+ ): void;
68
+ _devtools_rendering_set_show_fps_meter(
69
+ state: GridaCanvasWebGlApplicationPtr,
70
+ show: boolean
71
+ ): void;
72
+ _devtools_rendering_set_show_stats(
73
+ state: GridaCanvasWebGlApplicationPtr,
74
+ show: boolean
75
+ ): void;
76
+ _devtools_rendering_set_show_hit_testing(
77
+ state: GridaCanvasWebGlApplicationPtr,
78
+ show: boolean
79
+ ): void;
80
+ _devtools_rendering_set_show_ruler(
81
+ state: GridaCanvasWebGlApplicationPtr,
82
+ show: boolean
83
+ ): void;
84
+ }
85
+ }
86
+
87
+ type GridaCanvasWebGlApplicationPtr = number;
88
+
1
89
  interface GridaCanvasInitOptions {
2
90
  /**
3
91
  * This callback will be invoked when the loader needs to fetch a file (e.g.
@@ -16,17 +104,69 @@ interface GridaCanvasInitOptions {
16
104
  declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory>;
17
105
  declare class ApplicationFactory {
18
106
  private readonly module;
19
- constructor(module: GridaCanvasWasmBindings);
20
- createSurface(width: number, height: number): Grida2D;
107
+ constructor(module: createGridaCanvas.GridaCanvasWasmBindings);
108
+ createWebGLCanvasSurface(canvas: HTMLCanvasElement): Grida2D;
21
109
  }
22
110
  declare class Grida2D {
23
111
  private ptr;
24
112
  private module;
25
- constructor(module: GridaCanvasWasmBindings, ptr: GridaCanvasWebGlApplicationPtr);
113
+ constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
114
+ _alloc_string(txt: string): [number, number];
115
+ _free_string(ptr: number, len: number): void;
116
+ /**
117
+ * Load a scene from a JSON string.
118
+ * @param data - The JSON string to load.
119
+ */
120
+ loadScene(data: string): void;
121
+ /**
122
+ * @deprecated - test use only
123
+ */
124
+ loadDummyScene(): void;
125
+ /**
126
+ * @deprecated - test use only
127
+ */
128
+ loadBenchmarkScene(cols: number, rows: number): void;
129
+ /**
130
+ * Tick the application clock.
131
+ * bind this to requestAnimationFrame loop or similar
132
+ */
26
133
  tick(): void;
134
+ /**
135
+ * Resize the surface.
136
+ * @param width - The width of the surface.
137
+ * @param height - The height of the surface.
138
+ */
27
139
  resize(width: number, height: number): void;
28
140
  redraw(): void;
29
141
  execCommand(command: "ZoomIn" | "ZoomOut"): void;
142
+ execCommandPan(tx: number, ty: number): void;
143
+ execCommandZoomDelta(tz: number): void;
144
+ pointermove(x: number, y: number): void;
145
+ /**
146
+ * Set the visibility of the tiles.
147
+ * @param show - The visibility of the tiles.
148
+ */
149
+ devtools_rendering_set_show_tiles(show: boolean): void;
150
+ /**
151
+ * Set the visibility of the FPS meter.
152
+ * @param show - The visibility of the FPS meter.
153
+ */
154
+ devtools_rendering_set_show_fps_meter(show: boolean): void;
155
+ /**
156
+ * Set the visibility of the stats.
157
+ * @param show - The visibility of the stats.
158
+ */
159
+ devtools_rendering_set_show_stats(show: boolean): void;
160
+ /**
161
+ * Set the visibility of the hit testing.
162
+ * @param show - The visibility of the hit testing.
163
+ */
164
+ devtools_rendering_set_show_hit_testing(show: boolean): void;
165
+ /**
166
+ * Set the visibility of the ruler.
167
+ * @param show - The visibility of the ruler.
168
+ */
169
+ devtools_rendering_set_show_ruler(show: boolean): void;
30
170
  }
31
171
 
32
172
  export { init as default };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,91 @@
1
+ declare function createGridaCanvas(moduleArg?: {
2
+ locateFile?: (path: string, scriptDirectory: string) => string;
3
+ }): Promise<createGridaCanvas.GridaCanvasWasmBindings>;
4
+
5
+ declare namespace createGridaCanvas {
6
+ interface GridaCanvasWasmBindings {
7
+ // ====================================================================================================
8
+ // EMSCRIPTEN EXPOSED METHODS
9
+ // ====================================================================================================
10
+ GL: {
11
+ registerContext(
12
+ context: WebGLRenderingContext,
13
+ options: { majorVersion: number }
14
+ ): number;
15
+ makeContextCurrent(handle: number): void;
16
+ };
17
+ stringToUTF8(str: string, outPtr: number, maxBytesToWrite: number): void;
18
+ lengthBytesUTF8(str: string): number;
19
+ ___wbindgen_malloc(a0: number, a1: number): number;
20
+ ___wbindgen_free(a0: number, a1: number, a2: number): void;
21
+ ___wbindgen_realloc(a0: number, a1: number, a2: number, a3: number): number;
22
+
23
+ // core memory wrapper
24
+ _allocate(len: number): number;
25
+ _deallocate(ptr: number, len: number): void;
26
+
27
+ // ====================================================================================================
28
+ // INITIALIZATION
29
+ // ====================================================================================================
30
+ _init(width: number, height: number): GridaCanvasWebGlApplicationPtr;
31
+
32
+ // ====================================================================================================
33
+ // APPLICATION METHODS
34
+ // ====================================================================================================
35
+ _tick(state: GridaCanvasWebGlApplicationPtr): void;
36
+ _resize_surface(
37
+ state: GridaCanvasWebGlApplicationPtr,
38
+ width: number,
39
+ height: number
40
+ ): void;
41
+ _redraw(state: GridaCanvasWebGlApplicationPtr): void;
42
+ _load_scene_json(
43
+ state: GridaCanvasWebGlApplicationPtr,
44
+ ptr: number,
45
+ len: number
46
+ ): void;
47
+ _load_dummy_scene(state: GridaCanvasWebGlApplicationPtr): void;
48
+ _load_benchmark_scene(
49
+ state: GridaCanvasWebGlApplicationPtr,
50
+ cols: number,
51
+ rows: number
52
+ ): void;
53
+ _pointer_move(
54
+ state: GridaCanvasWebGlApplicationPtr,
55
+ x: number,
56
+ y: number
57
+ ): void;
58
+ _command(
59
+ state: GridaCanvasWebGlApplicationPtr,
60
+ id: number,
61
+ a: number,
62
+ b: number
63
+ ): void;
64
+ _devtools_rendering_set_show_tiles(
65
+ state: GridaCanvasWebGlApplicationPtr,
66
+ show: boolean
67
+ ): void;
68
+ _devtools_rendering_set_show_fps_meter(
69
+ state: GridaCanvasWebGlApplicationPtr,
70
+ show: boolean
71
+ ): void;
72
+ _devtools_rendering_set_show_stats(
73
+ state: GridaCanvasWebGlApplicationPtr,
74
+ show: boolean
75
+ ): void;
76
+ _devtools_rendering_set_show_hit_testing(
77
+ state: GridaCanvasWebGlApplicationPtr,
78
+ show: boolean
79
+ ): void;
80
+ _devtools_rendering_set_show_ruler(
81
+ state: GridaCanvasWebGlApplicationPtr,
82
+ show: boolean
83
+ ): void;
84
+ }
85
+ }
86
+
87
+ type GridaCanvasWebGlApplicationPtr = number;
88
+
1
89
  interface GridaCanvasInitOptions {
2
90
  /**
3
91
  * This callback will be invoked when the loader needs to fetch a file (e.g.
@@ -16,17 +104,69 @@ interface GridaCanvasInitOptions {
16
104
  declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory>;
17
105
  declare class ApplicationFactory {
18
106
  private readonly module;
19
- constructor(module: GridaCanvasWasmBindings);
20
- createSurface(width: number, height: number): Grida2D;
107
+ constructor(module: createGridaCanvas.GridaCanvasWasmBindings);
108
+ createWebGLCanvasSurface(canvas: HTMLCanvasElement): Grida2D;
21
109
  }
22
110
  declare class Grida2D {
23
111
  private ptr;
24
112
  private module;
25
- constructor(module: GridaCanvasWasmBindings, ptr: GridaCanvasWebGlApplicationPtr);
113
+ constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
114
+ _alloc_string(txt: string): [number, number];
115
+ _free_string(ptr: number, len: number): void;
116
+ /**
117
+ * Load a scene from a JSON string.
118
+ * @param data - The JSON string to load.
119
+ */
120
+ loadScene(data: string): void;
121
+ /**
122
+ * @deprecated - test use only
123
+ */
124
+ loadDummyScene(): void;
125
+ /**
126
+ * @deprecated - test use only
127
+ */
128
+ loadBenchmarkScene(cols: number, rows: number): void;
129
+ /**
130
+ * Tick the application clock.
131
+ * bind this to requestAnimationFrame loop or similar
132
+ */
26
133
  tick(): void;
134
+ /**
135
+ * Resize the surface.
136
+ * @param width - The width of the surface.
137
+ * @param height - The height of the surface.
138
+ */
27
139
  resize(width: number, height: number): void;
28
140
  redraw(): void;
29
141
  execCommand(command: "ZoomIn" | "ZoomOut"): void;
142
+ execCommandPan(tx: number, ty: number): void;
143
+ execCommandZoomDelta(tz: number): void;
144
+ pointermove(x: number, y: number): void;
145
+ /**
146
+ * Set the visibility of the tiles.
147
+ * @param show - The visibility of the tiles.
148
+ */
149
+ devtools_rendering_set_show_tiles(show: boolean): void;
150
+ /**
151
+ * Set the visibility of the FPS meter.
152
+ * @param show - The visibility of the FPS meter.
153
+ */
154
+ devtools_rendering_set_show_fps_meter(show: boolean): void;
155
+ /**
156
+ * Set the visibility of the stats.
157
+ * @param show - The visibility of the stats.
158
+ */
159
+ devtools_rendering_set_show_stats(show: boolean): void;
160
+ /**
161
+ * Set the visibility of the hit testing.
162
+ * @param show - The visibility of the hit testing.
163
+ */
164
+ devtools_rendering_set_show_hit_testing(show: boolean): void;
165
+ /**
166
+ * Set the visibility of the ruler.
167
+ * @param show - The visibility of the ruler.
168
+ */
169
+ devtools_rendering_set_show_ruler(show: boolean): void;
30
170
  }
31
171
 
32
172
  export { init as default };
package/dist/index.js CHANGED
@@ -7384,20 +7384,35 @@ __export(index_exports, {
7384
7384
  module.exports = __toCommonJS(index_exports);
7385
7385
  var import_grida_canvas_wasm = __toESM(require_grida_canvas_wasm());
7386
7386
  async function init(opts) {
7387
- const bindings = await createGridaCanvas({ locateFile: opts == null ? void 0 : opts.locateFile });
7388
- return new ApplicationFactory(bindings);
7387
+ const bindings = await (0, import_grida_canvas_wasm.default)({ locateFile: opts == null ? void 0 : opts.locateFile });
7388
+ return new ApplicationFactory(
7389
+ bindings
7390
+ );
7389
7391
  }
7390
7392
  var ApplicationFactory = class {
7391
7393
  module;
7392
7394
  constructor(module2) {
7393
7395
  this.module = module2;
7394
7396
  }
7395
- createSurface(width, height) {
7396
- const ptr = this.module._init(width, height);
7397
+ createWebGLCanvasSurface(canvas) {
7398
+ const context = canvas.getContext("webgl2", {
7399
+ antialias: true,
7400
+ depth: true,
7401
+ stencil: true,
7402
+ alpha: true
7403
+ });
7404
+ if (!context) {
7405
+ throw new Error("Failed to get WebGL2 context");
7406
+ }
7407
+ const handle = this.module.GL.registerContext(context, {
7408
+ majorVersion: 2
7409
+ });
7410
+ this.module.GL.makeContextCurrent(handle);
7411
+ const ptr = this.module._init(canvas.width, canvas.height);
7397
7412
  return new Grida2D(this.module, ptr);
7398
7413
  }
7399
7414
  };
7400
- var ApplicationCommandKey = {
7415
+ var ApplicationCommandID = {
7401
7416
  ZoomIn: 1,
7402
7417
  ZoomOut: 2,
7403
7418
  ZoomDelta: 3,
@@ -7410,9 +7425,48 @@ var Grida2D = class {
7410
7425
  this.module = module2;
7411
7426
  this.ptr = ptr;
7412
7427
  }
7428
+ _alloc_string(txt) {
7429
+ const len = this.module.lengthBytesUTF8(txt) + 1;
7430
+ const ptr = this.module._allocate(len);
7431
+ this.module.stringToUTF8(txt, ptr, len);
7432
+ return [ptr, len];
7433
+ }
7434
+ _free_string(ptr, len) {
7435
+ this.module._deallocate(ptr, len);
7436
+ }
7437
+ /**
7438
+ * Load a scene from a JSON string.
7439
+ * @param data - The JSON string to load.
7440
+ */
7441
+ loadScene(data) {
7442
+ const [ptr, len] = this._alloc_string(data);
7443
+ this.module._load_scene_json(this.ptr, ptr, len - 1);
7444
+ this._free_string(ptr, len);
7445
+ }
7446
+ /**
7447
+ * @deprecated - test use only
7448
+ */
7449
+ loadDummyScene() {
7450
+ this.module._load_dummy_scene(this.ptr);
7451
+ }
7452
+ /**
7453
+ * @deprecated - test use only
7454
+ */
7455
+ loadBenchmarkScene(cols, rows) {
7456
+ this.module._load_benchmark_scene(this.ptr, cols, rows);
7457
+ }
7458
+ /**
7459
+ * Tick the application clock.
7460
+ * bind this to requestAnimationFrame loop or similar
7461
+ */
7413
7462
  tick() {
7414
7463
  this.module._tick(this.ptr);
7415
7464
  }
7465
+ /**
7466
+ * Resize the surface.
7467
+ * @param width - The width of the surface.
7468
+ * @param height - The height of the surface.
7469
+ */
7416
7470
  resize(width, height) {
7417
7471
  this.module._resize_surface(this.ptr, width, height);
7418
7472
  }
@@ -7420,6 +7474,53 @@ var Grida2D = class {
7420
7474
  this.module._redraw(this.ptr);
7421
7475
  }
7422
7476
  execCommand(command) {
7423
- this.module._command(this.ptr, ApplicationCommandKey[command], 0, 0);
7477
+ this.module._command(this.ptr, ApplicationCommandID[command], 0, 0);
7478
+ }
7479
+ execCommandPan(tx, ty) {
7480
+ this.module._command(this.ptr, ApplicationCommandID.Pan, tx, ty);
7481
+ }
7482
+ execCommandZoomDelta(tz) {
7483
+ this.module._command(this.ptr, ApplicationCommandID.ZoomDelta, tz, 0);
7484
+ }
7485
+ pointermove(x, y) {
7486
+ this.module._pointer_move(this.ptr, x, y);
7487
+ }
7488
+ // ====================================================================================================
7489
+ // DEVTOOLS
7490
+ // ====================================================================================================
7491
+ /**
7492
+ * Set the visibility of the tiles.
7493
+ * @param show - The visibility of the tiles.
7494
+ */
7495
+ devtools_rendering_set_show_tiles(show) {
7496
+ this.module._devtools_rendering_set_show_tiles(this.ptr, show);
7497
+ }
7498
+ /**
7499
+ * Set the visibility of the FPS meter.
7500
+ * @param show - The visibility of the FPS meter.
7501
+ */
7502
+ devtools_rendering_set_show_fps_meter(show) {
7503
+ this.module._devtools_rendering_set_show_fps_meter(this.ptr, show);
7504
+ }
7505
+ /**
7506
+ * Set the visibility of the stats.
7507
+ * @param show - The visibility of the stats.
7508
+ */
7509
+ devtools_rendering_set_show_stats(show) {
7510
+ this.module._devtools_rendering_set_show_stats(this.ptr, show);
7511
+ }
7512
+ /**
7513
+ * Set the visibility of the hit testing.
7514
+ * @param show - The visibility of the hit testing.
7515
+ */
7516
+ devtools_rendering_set_show_hit_testing(show) {
7517
+ this.module._devtools_rendering_set_show_hit_testing(this.ptr, show);
7518
+ }
7519
+ /**
7520
+ * Set the visibility of the ruler.
7521
+ * @param show - The visibility of the ruler.
7522
+ */
7523
+ devtools_rendering_set_show_ruler(show) {
7524
+ this.module._devtools_rendering_set_show_ruler(this.ptr, show);
7424
7525
  }
7425
7526
  };
package/dist/index.mjs CHANGED
@@ -7380,20 +7380,35 @@ var require_grida_canvas_wasm = __commonJS({
7380
7380
  // lib/index.ts
7381
7381
  var import_grida_canvas_wasm = __toESM(require_grida_canvas_wasm());
7382
7382
  async function init(opts) {
7383
- const bindings = await createGridaCanvas({ locateFile: opts == null ? void 0 : opts.locateFile });
7384
- return new ApplicationFactory(bindings);
7383
+ const bindings = await (0, import_grida_canvas_wasm.default)({ locateFile: opts == null ? void 0 : opts.locateFile });
7384
+ return new ApplicationFactory(
7385
+ bindings
7386
+ );
7385
7387
  }
7386
7388
  var ApplicationFactory = class {
7387
7389
  module;
7388
7390
  constructor(module) {
7389
7391
  this.module = module;
7390
7392
  }
7391
- createSurface(width, height) {
7392
- const ptr = this.module._init(width, height);
7393
+ createWebGLCanvasSurface(canvas) {
7394
+ const context = canvas.getContext("webgl2", {
7395
+ antialias: true,
7396
+ depth: true,
7397
+ stencil: true,
7398
+ alpha: true
7399
+ });
7400
+ if (!context) {
7401
+ throw new Error("Failed to get WebGL2 context");
7402
+ }
7403
+ const handle = this.module.GL.registerContext(context, {
7404
+ majorVersion: 2
7405
+ });
7406
+ this.module.GL.makeContextCurrent(handle);
7407
+ const ptr = this.module._init(canvas.width, canvas.height);
7393
7408
  return new Grida2D(this.module, ptr);
7394
7409
  }
7395
7410
  };
7396
- var ApplicationCommandKey = {
7411
+ var ApplicationCommandID = {
7397
7412
  ZoomIn: 1,
7398
7413
  ZoomOut: 2,
7399
7414
  ZoomDelta: 3,
@@ -7406,9 +7421,48 @@ var Grida2D = class {
7406
7421
  this.module = module;
7407
7422
  this.ptr = ptr;
7408
7423
  }
7424
+ _alloc_string(txt) {
7425
+ const len = this.module.lengthBytesUTF8(txt) + 1;
7426
+ const ptr = this.module._allocate(len);
7427
+ this.module.stringToUTF8(txt, ptr, len);
7428
+ return [ptr, len];
7429
+ }
7430
+ _free_string(ptr, len) {
7431
+ this.module._deallocate(ptr, len);
7432
+ }
7433
+ /**
7434
+ * Load a scene from a JSON string.
7435
+ * @param data - The JSON string to load.
7436
+ */
7437
+ loadScene(data) {
7438
+ const [ptr, len] = this._alloc_string(data);
7439
+ this.module._load_scene_json(this.ptr, ptr, len - 1);
7440
+ this._free_string(ptr, len);
7441
+ }
7442
+ /**
7443
+ * @deprecated - test use only
7444
+ */
7445
+ loadDummyScene() {
7446
+ this.module._load_dummy_scene(this.ptr);
7447
+ }
7448
+ /**
7449
+ * @deprecated - test use only
7450
+ */
7451
+ loadBenchmarkScene(cols, rows) {
7452
+ this.module._load_benchmark_scene(this.ptr, cols, rows);
7453
+ }
7454
+ /**
7455
+ * Tick the application clock.
7456
+ * bind this to requestAnimationFrame loop or similar
7457
+ */
7409
7458
  tick() {
7410
7459
  this.module._tick(this.ptr);
7411
7460
  }
7461
+ /**
7462
+ * Resize the surface.
7463
+ * @param width - The width of the surface.
7464
+ * @param height - The height of the surface.
7465
+ */
7412
7466
  resize(width, height) {
7413
7467
  this.module._resize_surface(this.ptr, width, height);
7414
7468
  }
@@ -7416,7 +7470,54 @@ var Grida2D = class {
7416
7470
  this.module._redraw(this.ptr);
7417
7471
  }
7418
7472
  execCommand(command) {
7419
- this.module._command(this.ptr, ApplicationCommandKey[command], 0, 0);
7473
+ this.module._command(this.ptr, ApplicationCommandID[command], 0, 0);
7474
+ }
7475
+ execCommandPan(tx, ty) {
7476
+ this.module._command(this.ptr, ApplicationCommandID.Pan, tx, ty);
7477
+ }
7478
+ execCommandZoomDelta(tz) {
7479
+ this.module._command(this.ptr, ApplicationCommandID.ZoomDelta, tz, 0);
7480
+ }
7481
+ pointermove(x, y) {
7482
+ this.module._pointer_move(this.ptr, x, y);
7483
+ }
7484
+ // ====================================================================================================
7485
+ // DEVTOOLS
7486
+ // ====================================================================================================
7487
+ /**
7488
+ * Set the visibility of the tiles.
7489
+ * @param show - The visibility of the tiles.
7490
+ */
7491
+ devtools_rendering_set_show_tiles(show) {
7492
+ this.module._devtools_rendering_set_show_tiles(this.ptr, show);
7493
+ }
7494
+ /**
7495
+ * Set the visibility of the FPS meter.
7496
+ * @param show - The visibility of the FPS meter.
7497
+ */
7498
+ devtools_rendering_set_show_fps_meter(show) {
7499
+ this.module._devtools_rendering_set_show_fps_meter(this.ptr, show);
7500
+ }
7501
+ /**
7502
+ * Set the visibility of the stats.
7503
+ * @param show - The visibility of the stats.
7504
+ */
7505
+ devtools_rendering_set_show_stats(show) {
7506
+ this.module._devtools_rendering_set_show_stats(this.ptr, show);
7507
+ }
7508
+ /**
7509
+ * Set the visibility of the hit testing.
7510
+ * @param show - The visibility of the hit testing.
7511
+ */
7512
+ devtools_rendering_set_show_hit_testing(show) {
7513
+ this.module._devtools_rendering_set_show_hit_testing(this.ptr, show);
7514
+ }
7515
+ /**
7516
+ * Set the visibility of the ruler.
7517
+ * @param show - The visibility of the ruler.
7518
+ */
7519
+ devtools_rendering_set_show_ruler(show) {
7520
+ this.module._devtools_rendering_set_show_ruler(this.ptr, show);
7420
7521
  }
7421
7522
  };
7422
7523
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@grida/canvas-wasm",
3
3
  "description": "WASM bindings for Grida Canvas",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "keywords": [
6
6
  "grida",
7
7
  "canvas",