@grida/canvas-wasm 0.0.10 → 0.0.12

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
@@ -51,7 +51,11 @@ declare namespace createGridaCanvas {
51
51
  // ====================================================================================================
52
52
  // INITIALIZATION
53
53
  // ====================================================================================================
54
- _init(width: number, height: number): GridaCanvasWebGlApplicationPtr;
54
+ _init(
55
+ width: number,
56
+ height: number,
57
+ cfg_font_fallback: boolean
58
+ ): GridaCanvasWebGlApplicationPtr;
55
59
 
56
60
  // ====================================================================================================
57
61
  // APPLICATION METHODS
@@ -154,21 +158,20 @@ declare namespace createGridaCanvas {
154
158
 
155
159
  type GridaCanvasWebGlApplicationPtr = number;
156
160
 
157
- interface GridaCanvasInitOptions {
158
- /**
159
- * This callback will be invoked when the loader needs to fetch a file (e.g.
160
- * the blob of WASM code). The correct url prefix should be applied.
161
- * @param file - the name of the file that is about to be loaded.
162
- *
163
- * @example
164
- * ```ts
165
- * locateFile: (file) => `https://unpkg.com/@grida/canvas-wasm@$latest/bin/${file}`,
166
- * locateFile: (file) => `custom-binary-path/${file}`,
167
- * ```
168
- */
169
- locateFile(file: string): string;
161
+ interface GridaCanvasModuleInitOptions {
162
+ /**
163
+ * This callback will be invoked when the loader needs to fetch a file (e.g.
164
+ * the blob of WASM code). The correct url prefix should be applied.
165
+ * @param file - the name of the file that is about to be loaded.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * locateFile: (file) => `https://unpkg.com/@grida/canvas-wasm@$latest/bin/${file}`,
170
+ * locateFile: (file) => `custom-binary-path/${file}`,
171
+ * ```
172
+ */
173
+ locateFile(file: string, version: string): string;
170
174
  }
171
-
172
175
  type Transform2D = [[number, number, number], [number, number, number]];
173
176
  type Rectangle = {
174
177
  x: number;
@@ -191,11 +194,18 @@ type ExportAsImage = {
191
194
  format: "PNG" | "JPEG" | "WEBP" | "BMP";
192
195
  constraints: ExportConstraints;
193
196
  };
194
- declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory>;
197
+ declare function init(opts?: GridaCanvasModuleInitOptions): Promise<ApplicationFactory>;
198
+ interface CreateWebGLCanvasSurfaceOptions {
199
+ /**
200
+ * when true, built-in fonts will be used for text rendering, even if the font family and style does not match.
201
+ * @default true
202
+ */
203
+ fontFallback?: boolean;
204
+ }
195
205
  declare class ApplicationFactory {
196
206
  private readonly module;
197
207
  constructor(module: createGridaCanvas.GridaCanvasWasmBindings);
198
- createWebGLCanvasSurface(canvas: HTMLCanvasElement): Grida2D;
208
+ createWebGLCanvasSurface(canvas: HTMLCanvasElement, options?: CreateWebGLCanvasSurfaceOptions): Grida2D;
199
209
  createWebGLCanvasSurfaceById(htmlcanvasid: string): Grida2D;
200
210
  }
201
211
  declare class Grida2D {
@@ -273,4 +283,4 @@ declare class Grida2D {
273
283
  devtools_rendering_set_show_ruler(show: boolean): void;
274
284
  }
275
285
 
276
- export { Grida2D, init as default };
286
+ export { Grida2D, type GridaCanvasModuleInitOptions, init as default };
package/dist/index.d.ts CHANGED
@@ -51,7 +51,11 @@ declare namespace createGridaCanvas {
51
51
  // ====================================================================================================
52
52
  // INITIALIZATION
53
53
  // ====================================================================================================
54
- _init(width: number, height: number): GridaCanvasWebGlApplicationPtr;
54
+ _init(
55
+ width: number,
56
+ height: number,
57
+ cfg_font_fallback: boolean
58
+ ): GridaCanvasWebGlApplicationPtr;
55
59
 
56
60
  // ====================================================================================================
57
61
  // APPLICATION METHODS
@@ -154,21 +158,20 @@ declare namespace createGridaCanvas {
154
158
 
155
159
  type GridaCanvasWebGlApplicationPtr = number;
156
160
 
157
- interface GridaCanvasInitOptions {
158
- /**
159
- * This callback will be invoked when the loader needs to fetch a file (e.g.
160
- * the blob of WASM code). The correct url prefix should be applied.
161
- * @param file - the name of the file that is about to be loaded.
162
- *
163
- * @example
164
- * ```ts
165
- * locateFile: (file) => `https://unpkg.com/@grida/canvas-wasm@$latest/bin/${file}`,
166
- * locateFile: (file) => `custom-binary-path/${file}`,
167
- * ```
168
- */
169
- locateFile(file: string): string;
161
+ interface GridaCanvasModuleInitOptions {
162
+ /**
163
+ * This callback will be invoked when the loader needs to fetch a file (e.g.
164
+ * the blob of WASM code). The correct url prefix should be applied.
165
+ * @param file - the name of the file that is about to be loaded.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * locateFile: (file) => `https://unpkg.com/@grida/canvas-wasm@$latest/bin/${file}`,
170
+ * locateFile: (file) => `custom-binary-path/${file}`,
171
+ * ```
172
+ */
173
+ locateFile(file: string, version: string): string;
170
174
  }
171
-
172
175
  type Transform2D = [[number, number, number], [number, number, number]];
173
176
  type Rectangle = {
174
177
  x: number;
@@ -191,11 +194,18 @@ type ExportAsImage = {
191
194
  format: "PNG" | "JPEG" | "WEBP" | "BMP";
192
195
  constraints: ExportConstraints;
193
196
  };
194
- declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory>;
197
+ declare function init(opts?: GridaCanvasModuleInitOptions): Promise<ApplicationFactory>;
198
+ interface CreateWebGLCanvasSurfaceOptions {
199
+ /**
200
+ * when true, built-in fonts will be used for text rendering, even if the font family and style does not match.
201
+ * @default true
202
+ */
203
+ fontFallback?: boolean;
204
+ }
195
205
  declare class ApplicationFactory {
196
206
  private readonly module;
197
207
  constructor(module: createGridaCanvas.GridaCanvasWasmBindings);
198
- createWebGLCanvasSurface(canvas: HTMLCanvasElement): Grida2D;
208
+ createWebGLCanvasSurface(canvas: HTMLCanvasElement, options?: CreateWebGLCanvasSurfaceOptions): Grida2D;
199
209
  createWebGLCanvasSurfaceById(htmlcanvasid: string): Grida2D;
200
210
  }
201
211
  declare class Grida2D {
@@ -273,4 +283,4 @@ declare class Grida2D {
273
283
  devtools_rendering_set_show_ruler(show: boolean): void;
274
284
  }
275
285
 
276
- export { Grida2D, init as default };
286
+ export { Grida2D, type GridaCanvasModuleInitOptions, init as default };