@grida/canvas-wasm 0.0.2 → 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
@@ -105,8 +105,7 @@ declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory
105
105
  declare class ApplicationFactory {
106
106
  private readonly module;
107
107
  constructor(module: createGridaCanvas.GridaCanvasWasmBindings);
108
- createCanvasSurface(htmlcanvasid: string): Grida2D;
109
- createSurface(width: number, height: number): Grida2D;
108
+ createWebGLCanvasSurface(canvas: HTMLCanvasElement): Grida2D;
110
109
  }
111
110
  declare class Grida2D {
112
111
  private ptr;
package/dist/index.d.ts CHANGED
@@ -105,8 +105,7 @@ declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory
105
105
  declare class ApplicationFactory {
106
106
  private readonly module;
107
107
  constructor(module: createGridaCanvas.GridaCanvasWasmBindings);
108
- createCanvasSurface(htmlcanvasid: string): Grida2D;
109
- createSurface(width: number, height: number): Grida2D;
108
+ createWebGLCanvasSurface(canvas: HTMLCanvasElement): Grida2D;
110
109
  }
111
110
  declare class Grida2D {
112
111
  private ptr;
package/dist/index.js CHANGED
@@ -7394,11 +7394,7 @@ var ApplicationFactory = class {
7394
7394
  constructor(module2) {
7395
7395
  this.module = module2;
7396
7396
  }
7397
- createCanvasSurface(htmlcanvasid) {
7398
- const canvas = document.getElementById(htmlcanvasid);
7399
- if (!(canvas instanceof HTMLCanvasElement)) {
7400
- throw new Error(`Element with id ${htmlcanvasid} is not a <canvas>`);
7401
- }
7397
+ createWebGLCanvasSurface(canvas) {
7402
7398
  const context = canvas.getContext("webgl2", {
7403
7399
  antialias: true,
7404
7400
  depth: true,
@@ -7415,10 +7411,6 @@ var ApplicationFactory = class {
7415
7411
  const ptr = this.module._init(canvas.width, canvas.height);
7416
7412
  return new Grida2D(this.module, ptr);
7417
7413
  }
7418
- createSurface(width, height) {
7419
- const ptr = this.module._init(width, height);
7420
- return new Grida2D(this.module, ptr);
7421
- }
7422
7414
  };
7423
7415
  var ApplicationCommandID = {
7424
7416
  ZoomIn: 1,
package/dist/index.mjs CHANGED
@@ -7390,11 +7390,7 @@ var ApplicationFactory = class {
7390
7390
  constructor(module) {
7391
7391
  this.module = module;
7392
7392
  }
7393
- createCanvasSurface(htmlcanvasid) {
7394
- const canvas = document.getElementById(htmlcanvasid);
7395
- if (!(canvas instanceof HTMLCanvasElement)) {
7396
- throw new Error(`Element with id ${htmlcanvasid} is not a <canvas>`);
7397
- }
7393
+ createWebGLCanvasSurface(canvas) {
7398
7394
  const context = canvas.getContext("webgl2", {
7399
7395
  antialias: true,
7400
7396
  depth: true,
@@ -7411,10 +7407,6 @@ var ApplicationFactory = class {
7411
7407
  const ptr = this.module._init(canvas.width, canvas.height);
7412
7408
  return new Grida2D(this.module, ptr);
7413
7409
  }
7414
- createSurface(width, height) {
7415
- const ptr = this.module._init(width, height);
7416
- return new Grida2D(this.module, ptr);
7417
- }
7418
7410
  };
7419
7411
  var ApplicationCommandID = {
7420
7412
  ZoomIn: 1,
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.2",
4
+ "version": "0.0.3",
5
5
  "keywords": [
6
6
  "grida",
7
7
  "canvas",