@grida/canvas-wasm 0.0.82-canary.1 → 0.0.84-canary.0
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 +225 -5
- package/dist/index.d.ts +225 -5
- package/dist/index.js +470 -143
- package/dist/index.mjs +470 -143
- package/package.json +1 -1
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -193,6 +193,192 @@ declare namespace fonts {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
declare namespace svgtypes {
|
|
197
|
+
// ====================================================================================================
|
|
198
|
+
// #region: Core Type Definitions
|
|
199
|
+
// ====================================================================================================
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* rust/serde Option<T> equivalant
|
|
203
|
+
*/
|
|
204
|
+
type TOption<T> = T | null;
|
|
205
|
+
type RGBA8888 = [r: number, g: number, b: number, a: number];
|
|
206
|
+
type Transform2D = [[number, number, number], [number, number, number]];
|
|
207
|
+
type StrokeCap = "butt" | "round" | "square";
|
|
208
|
+
type StrokeJoin = "miter" | "round" | "bevel";
|
|
209
|
+
type FillRule = "nonzero" | "evenodd";
|
|
210
|
+
type BlendMode =
|
|
211
|
+
| "normal"
|
|
212
|
+
| "multiply"
|
|
213
|
+
| "screen"
|
|
214
|
+
| "overlay"
|
|
215
|
+
| "darken"
|
|
216
|
+
| "lighten"
|
|
217
|
+
| "color-dodge"
|
|
218
|
+
| "color-burn"
|
|
219
|
+
| "hard-light"
|
|
220
|
+
| "soft-light"
|
|
221
|
+
| "difference"
|
|
222
|
+
| "exclusion"
|
|
223
|
+
| "hue"
|
|
224
|
+
| "saturation"
|
|
225
|
+
| "color"
|
|
226
|
+
| "luminosity";
|
|
227
|
+
|
|
228
|
+
export enum SVGTextAnchor {
|
|
229
|
+
start = "start",
|
|
230
|
+
middle = "middle",
|
|
231
|
+
end = "end",
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export enum SVGSpreadMethod {
|
|
235
|
+
pad = "pad",
|
|
236
|
+
reflect = "reflect",
|
|
237
|
+
repeat = "repeat",
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface SVGSolidPaint {
|
|
241
|
+
kind: "solid";
|
|
242
|
+
color: RGBA8888;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface SVGGradientStop {
|
|
246
|
+
color: RGBA8888;
|
|
247
|
+
offset: number;
|
|
248
|
+
// opacity: number;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface SVGLinearGradientPaint {
|
|
252
|
+
kind: "linear-gradient";
|
|
253
|
+
id: string;
|
|
254
|
+
x1: number;
|
|
255
|
+
y1: number;
|
|
256
|
+
x2: number;
|
|
257
|
+
y2: number;
|
|
258
|
+
transform: Transform2D;
|
|
259
|
+
stops: Array<SVGGradientStop>;
|
|
260
|
+
spread_method: SVGSpreadMethod;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface SVGRadialGradientPaint {
|
|
264
|
+
kind: "radial-gradient";
|
|
265
|
+
id: string;
|
|
266
|
+
cx: number;
|
|
267
|
+
cy: number;
|
|
268
|
+
r: number;
|
|
269
|
+
fx: number;
|
|
270
|
+
fy: number;
|
|
271
|
+
transform: Transform2D;
|
|
272
|
+
stops: Array<SVGGradientStop>;
|
|
273
|
+
spread_method: SVGSpreadMethod;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export type SVGPaint =
|
|
277
|
+
| SVGSolidPaint
|
|
278
|
+
| SVGLinearGradientPaint
|
|
279
|
+
| SVGRadialGradientPaint;
|
|
280
|
+
|
|
281
|
+
export interface SVGFillAttributes {
|
|
282
|
+
paint: SVGPaint;
|
|
283
|
+
fill_opacity: number;
|
|
284
|
+
fill_rule: FillRule;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface SVGStrokeAttributes {
|
|
288
|
+
paint: SVGPaint;
|
|
289
|
+
stroke_width: TOption<number>;
|
|
290
|
+
stroke_linecap: StrokeCap;
|
|
291
|
+
stroke_linejoin: StrokeJoin;
|
|
292
|
+
stroke_miterlimit: number;
|
|
293
|
+
stroke_dasharray: TOption<Array<number>>;
|
|
294
|
+
stroke_opacity: number;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export namespace ir {
|
|
298
|
+
export interface IRSVGInitialContainerNode {
|
|
299
|
+
width: number;
|
|
300
|
+
height: number;
|
|
301
|
+
children: Array<IRSVGChildNode>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export type IRSVGChildNode =
|
|
305
|
+
| IRSVGGroupNode
|
|
306
|
+
| IRSVGPathNode
|
|
307
|
+
| IRSVGTextNode
|
|
308
|
+
| IRSVGImageNode;
|
|
309
|
+
|
|
310
|
+
export interface IRSVGGroupNode {
|
|
311
|
+
kind: "group";
|
|
312
|
+
transform: Transform2D;
|
|
313
|
+
opacity: number;
|
|
314
|
+
blend_mode: BlendMode;
|
|
315
|
+
children: Array<IRSVGChildNode>;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface IRSVGPathNode {
|
|
319
|
+
kind: "path";
|
|
320
|
+
transform: Transform2D;
|
|
321
|
+
fill: TOption<SVGFillAttributes>;
|
|
322
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
323
|
+
d: string;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface IRSVGTextNode {
|
|
327
|
+
kind: "text";
|
|
328
|
+
transform: Transform2D;
|
|
329
|
+
text_content: string;
|
|
330
|
+
fill: TOption<SVGFillAttributes>;
|
|
331
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
332
|
+
spans: Array<IRSVGTextSpanNode>;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface IRSVGTextSpanNode {
|
|
336
|
+
transform: Transform2D;
|
|
337
|
+
text: string;
|
|
338
|
+
fill: TOption<SVGFillAttributes>;
|
|
339
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
340
|
+
font_size: TOption<number>;
|
|
341
|
+
anchor: SVGTextAnchor;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface IRSVGImageNode {
|
|
345
|
+
kind: "image";
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
declare namespace svg {
|
|
351
|
+
export type SVGOptimizeResponse = CAPIMethodResult<{
|
|
352
|
+
/** Optimized SVG string with CSS styles resolved and inlined */
|
|
353
|
+
svg_optimized: string;
|
|
354
|
+
}>;
|
|
355
|
+
|
|
356
|
+
export type SVGPackResponse = CAPIMethodResult<{
|
|
357
|
+
svg: svgtypes.ir.IRSVGInitialContainerNode;
|
|
358
|
+
}>;
|
|
359
|
+
|
|
360
|
+
// ====================================================================================================
|
|
361
|
+
// #region: WASM Function Declarations
|
|
362
|
+
// ====================================================================================================
|
|
363
|
+
|
|
364
|
+
export interface SVGModule {
|
|
365
|
+
// ====================================================================================================
|
|
366
|
+
// #region: High-Level SVG APIs
|
|
367
|
+
// ====================================================================================================
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Optimizes and resolves an SVG, producing a flat, self-contained SVG output.
|
|
371
|
+
* Resolves CSS styles from `<style>` tags and inlines them as element attributes.
|
|
372
|
+
*
|
|
373
|
+
* @param svg - Pointer to input SVG string (null-terminated C string)
|
|
374
|
+
* @returns Pointer to JSON string containing {@link svgtypes.SvgOptimizeResponse}
|
|
375
|
+
*/
|
|
376
|
+
_grida_svg_optimize(svg: CPtr): CPtr;
|
|
377
|
+
|
|
378
|
+
_grida_svg_pack(sgv: CPtr): CPtr;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
196
382
|
///
|
|
197
383
|
/// @grida/canvas-wasm grida-canvas-wasm.js typescript definitions
|
|
198
384
|
/// this is NOT generated by emscripten. update manually.
|
|
@@ -211,7 +397,8 @@ declare namespace createGridaCanvas$1 {
|
|
|
211
397
|
interface GridaCanvasWasmBindings
|
|
212
398
|
extends emscripten.emscripten_EXPORTED_RUNTIME_METHODS,
|
|
213
399
|
canvas.CanvasModule,
|
|
214
|
-
fonts.FontsModule
|
|
400
|
+
fonts.FontsModule,
|
|
401
|
+
svg.SVGModule {}
|
|
215
402
|
}
|
|
216
403
|
|
|
217
404
|
declare class FontsAPI {
|
|
@@ -266,6 +453,38 @@ declare class FontsAPI {
|
|
|
266
453
|
parseFont(fontData: ArrayBuffer | Uint8Array, faceId: string, userFontStyleItalic?: boolean): Promise<fonts.types.FaceRecord>;
|
|
267
454
|
}
|
|
268
455
|
|
|
456
|
+
declare class SVGAPI {
|
|
457
|
+
private module;
|
|
458
|
+
constructor(module: any);
|
|
459
|
+
/**
|
|
460
|
+
* Allocates memory for a string and returns pointer and length.
|
|
461
|
+
* @param txt - String to allocate
|
|
462
|
+
* @returns [pointer, length] tuple
|
|
463
|
+
*/
|
|
464
|
+
private _alloc_string;
|
|
465
|
+
/**
|
|
466
|
+
* Frees memory allocated for a string.
|
|
467
|
+
* @param ptr - Pointer to free
|
|
468
|
+
* @param len - Length of allocated memory
|
|
469
|
+
*/
|
|
470
|
+
private _free_string;
|
|
471
|
+
/**
|
|
472
|
+
* Converts a WASM-allocated string to JavaScript string and frees the WASM memory.
|
|
473
|
+
* @param ptr - Pointer to WASM string
|
|
474
|
+
* @returns JavaScript string
|
|
475
|
+
*/
|
|
476
|
+
private _string_from_wasm;
|
|
477
|
+
/**
|
|
478
|
+
* Optimizes and resolves an SVG with JavaScript-friendly interface.
|
|
479
|
+
* Resolves CSS styles from `<style>` tags and inlines them as element attributes.
|
|
480
|
+
*
|
|
481
|
+
* @param svg - Input SVG string
|
|
482
|
+
* @returns Promise resolving to SvgOptimizeResponse
|
|
483
|
+
*/
|
|
484
|
+
optimize(svg: string): svg.SVGOptimizeResponse;
|
|
485
|
+
pack(svg: string): svg.SVGPackResponse;
|
|
486
|
+
}
|
|
487
|
+
|
|
269
488
|
interface CreateImageResourceResult {
|
|
270
489
|
hash: string;
|
|
271
490
|
url: string;
|
|
@@ -283,6 +502,7 @@ declare class Scene {
|
|
|
283
502
|
private appptr;
|
|
284
503
|
private module;
|
|
285
504
|
readonly fontskit: FontsAPI;
|
|
505
|
+
readonly svgkit: SVGAPI;
|
|
286
506
|
constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
|
|
287
507
|
/**
|
|
288
508
|
* Allocates memory for a string and returns pointer and length.
|
|
@@ -348,8 +568,8 @@ declare class Scene {
|
|
|
348
568
|
setMainCameraTransform(transform: types.Transform2D): void;
|
|
349
569
|
getNodeIdFromPoint(x: number, y: number): string | null;
|
|
350
570
|
getNodeIdsFromPoint(x: number, y: number): string[];
|
|
351
|
-
getNodeIdsFromEnvelope(envelope: types.
|
|
352
|
-
getNodeAbsoluteBoundingBox(id: string): types.
|
|
571
|
+
getNodeIdsFromEnvelope(envelope: types.Rect): string[];
|
|
572
|
+
getNodeAbsoluteBoundingBox(id: string): types.Rect | null;
|
|
353
573
|
/**
|
|
354
574
|
* Convert a node into a vector network representation.
|
|
355
575
|
* Supports primitive shapes and text nodes.
|
|
@@ -429,7 +649,7 @@ declare namespace types {
|
|
|
429
649
|
number
|
|
430
650
|
]
|
|
431
651
|
];
|
|
432
|
-
type
|
|
652
|
+
type Rect = {
|
|
433
653
|
x: number;
|
|
434
654
|
y: number;
|
|
435
655
|
width: number;
|
|
@@ -480,4 +700,4 @@ declare class ApplicationFactory {
|
|
|
480
700
|
createWebGLCanvasSurfaceById(htmlcanvasid: string): Scene;
|
|
481
701
|
}
|
|
482
702
|
|
|
483
|
-
export { ApplicationFactory, type GridaCanvasModuleInitOptions, Scene, init as default, types, version };
|
|
703
|
+
export { ApplicationFactory, type GridaCanvasModuleInitOptions, Scene, init as default, svgtypes, types, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -193,6 +193,192 @@ declare namespace fonts {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
declare namespace svgtypes {
|
|
197
|
+
// ====================================================================================================
|
|
198
|
+
// #region: Core Type Definitions
|
|
199
|
+
// ====================================================================================================
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* rust/serde Option<T> equivalant
|
|
203
|
+
*/
|
|
204
|
+
type TOption<T> = T | null;
|
|
205
|
+
type RGBA8888 = [r: number, g: number, b: number, a: number];
|
|
206
|
+
type Transform2D = [[number, number, number], [number, number, number]];
|
|
207
|
+
type StrokeCap = "butt" | "round" | "square";
|
|
208
|
+
type StrokeJoin = "miter" | "round" | "bevel";
|
|
209
|
+
type FillRule = "nonzero" | "evenodd";
|
|
210
|
+
type BlendMode =
|
|
211
|
+
| "normal"
|
|
212
|
+
| "multiply"
|
|
213
|
+
| "screen"
|
|
214
|
+
| "overlay"
|
|
215
|
+
| "darken"
|
|
216
|
+
| "lighten"
|
|
217
|
+
| "color-dodge"
|
|
218
|
+
| "color-burn"
|
|
219
|
+
| "hard-light"
|
|
220
|
+
| "soft-light"
|
|
221
|
+
| "difference"
|
|
222
|
+
| "exclusion"
|
|
223
|
+
| "hue"
|
|
224
|
+
| "saturation"
|
|
225
|
+
| "color"
|
|
226
|
+
| "luminosity";
|
|
227
|
+
|
|
228
|
+
export enum SVGTextAnchor {
|
|
229
|
+
start = "start",
|
|
230
|
+
middle = "middle",
|
|
231
|
+
end = "end",
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export enum SVGSpreadMethod {
|
|
235
|
+
pad = "pad",
|
|
236
|
+
reflect = "reflect",
|
|
237
|
+
repeat = "repeat",
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface SVGSolidPaint {
|
|
241
|
+
kind: "solid";
|
|
242
|
+
color: RGBA8888;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface SVGGradientStop {
|
|
246
|
+
color: RGBA8888;
|
|
247
|
+
offset: number;
|
|
248
|
+
// opacity: number;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface SVGLinearGradientPaint {
|
|
252
|
+
kind: "linear-gradient";
|
|
253
|
+
id: string;
|
|
254
|
+
x1: number;
|
|
255
|
+
y1: number;
|
|
256
|
+
x2: number;
|
|
257
|
+
y2: number;
|
|
258
|
+
transform: Transform2D;
|
|
259
|
+
stops: Array<SVGGradientStop>;
|
|
260
|
+
spread_method: SVGSpreadMethod;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface SVGRadialGradientPaint {
|
|
264
|
+
kind: "radial-gradient";
|
|
265
|
+
id: string;
|
|
266
|
+
cx: number;
|
|
267
|
+
cy: number;
|
|
268
|
+
r: number;
|
|
269
|
+
fx: number;
|
|
270
|
+
fy: number;
|
|
271
|
+
transform: Transform2D;
|
|
272
|
+
stops: Array<SVGGradientStop>;
|
|
273
|
+
spread_method: SVGSpreadMethod;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export type SVGPaint =
|
|
277
|
+
| SVGSolidPaint
|
|
278
|
+
| SVGLinearGradientPaint
|
|
279
|
+
| SVGRadialGradientPaint;
|
|
280
|
+
|
|
281
|
+
export interface SVGFillAttributes {
|
|
282
|
+
paint: SVGPaint;
|
|
283
|
+
fill_opacity: number;
|
|
284
|
+
fill_rule: FillRule;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface SVGStrokeAttributes {
|
|
288
|
+
paint: SVGPaint;
|
|
289
|
+
stroke_width: TOption<number>;
|
|
290
|
+
stroke_linecap: StrokeCap;
|
|
291
|
+
stroke_linejoin: StrokeJoin;
|
|
292
|
+
stroke_miterlimit: number;
|
|
293
|
+
stroke_dasharray: TOption<Array<number>>;
|
|
294
|
+
stroke_opacity: number;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export namespace ir {
|
|
298
|
+
export interface IRSVGInitialContainerNode {
|
|
299
|
+
width: number;
|
|
300
|
+
height: number;
|
|
301
|
+
children: Array<IRSVGChildNode>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export type IRSVGChildNode =
|
|
305
|
+
| IRSVGGroupNode
|
|
306
|
+
| IRSVGPathNode
|
|
307
|
+
| IRSVGTextNode
|
|
308
|
+
| IRSVGImageNode;
|
|
309
|
+
|
|
310
|
+
export interface IRSVGGroupNode {
|
|
311
|
+
kind: "group";
|
|
312
|
+
transform: Transform2D;
|
|
313
|
+
opacity: number;
|
|
314
|
+
blend_mode: BlendMode;
|
|
315
|
+
children: Array<IRSVGChildNode>;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface IRSVGPathNode {
|
|
319
|
+
kind: "path";
|
|
320
|
+
transform: Transform2D;
|
|
321
|
+
fill: TOption<SVGFillAttributes>;
|
|
322
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
323
|
+
d: string;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface IRSVGTextNode {
|
|
327
|
+
kind: "text";
|
|
328
|
+
transform: Transform2D;
|
|
329
|
+
text_content: string;
|
|
330
|
+
fill: TOption<SVGFillAttributes>;
|
|
331
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
332
|
+
spans: Array<IRSVGTextSpanNode>;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface IRSVGTextSpanNode {
|
|
336
|
+
transform: Transform2D;
|
|
337
|
+
text: string;
|
|
338
|
+
fill: TOption<SVGFillAttributes>;
|
|
339
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
340
|
+
font_size: TOption<number>;
|
|
341
|
+
anchor: SVGTextAnchor;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface IRSVGImageNode {
|
|
345
|
+
kind: "image";
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
declare namespace svg {
|
|
351
|
+
export type SVGOptimizeResponse = CAPIMethodResult<{
|
|
352
|
+
/** Optimized SVG string with CSS styles resolved and inlined */
|
|
353
|
+
svg_optimized: string;
|
|
354
|
+
}>;
|
|
355
|
+
|
|
356
|
+
export type SVGPackResponse = CAPIMethodResult<{
|
|
357
|
+
svg: svgtypes.ir.IRSVGInitialContainerNode;
|
|
358
|
+
}>;
|
|
359
|
+
|
|
360
|
+
// ====================================================================================================
|
|
361
|
+
// #region: WASM Function Declarations
|
|
362
|
+
// ====================================================================================================
|
|
363
|
+
|
|
364
|
+
export interface SVGModule {
|
|
365
|
+
// ====================================================================================================
|
|
366
|
+
// #region: High-Level SVG APIs
|
|
367
|
+
// ====================================================================================================
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Optimizes and resolves an SVG, producing a flat, self-contained SVG output.
|
|
371
|
+
* Resolves CSS styles from `<style>` tags and inlines them as element attributes.
|
|
372
|
+
*
|
|
373
|
+
* @param svg - Pointer to input SVG string (null-terminated C string)
|
|
374
|
+
* @returns Pointer to JSON string containing {@link svgtypes.SvgOptimizeResponse}
|
|
375
|
+
*/
|
|
376
|
+
_grida_svg_optimize(svg: CPtr): CPtr;
|
|
377
|
+
|
|
378
|
+
_grida_svg_pack(sgv: CPtr): CPtr;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
196
382
|
///
|
|
197
383
|
/// @grida/canvas-wasm grida-canvas-wasm.js typescript definitions
|
|
198
384
|
/// this is NOT generated by emscripten. update manually.
|
|
@@ -211,7 +397,8 @@ declare namespace createGridaCanvas$1 {
|
|
|
211
397
|
interface GridaCanvasWasmBindings
|
|
212
398
|
extends emscripten.emscripten_EXPORTED_RUNTIME_METHODS,
|
|
213
399
|
canvas.CanvasModule,
|
|
214
|
-
fonts.FontsModule
|
|
400
|
+
fonts.FontsModule,
|
|
401
|
+
svg.SVGModule {}
|
|
215
402
|
}
|
|
216
403
|
|
|
217
404
|
declare class FontsAPI {
|
|
@@ -266,6 +453,38 @@ declare class FontsAPI {
|
|
|
266
453
|
parseFont(fontData: ArrayBuffer | Uint8Array, faceId: string, userFontStyleItalic?: boolean): Promise<fonts.types.FaceRecord>;
|
|
267
454
|
}
|
|
268
455
|
|
|
456
|
+
declare class SVGAPI {
|
|
457
|
+
private module;
|
|
458
|
+
constructor(module: any);
|
|
459
|
+
/**
|
|
460
|
+
* Allocates memory for a string and returns pointer and length.
|
|
461
|
+
* @param txt - String to allocate
|
|
462
|
+
* @returns [pointer, length] tuple
|
|
463
|
+
*/
|
|
464
|
+
private _alloc_string;
|
|
465
|
+
/**
|
|
466
|
+
* Frees memory allocated for a string.
|
|
467
|
+
* @param ptr - Pointer to free
|
|
468
|
+
* @param len - Length of allocated memory
|
|
469
|
+
*/
|
|
470
|
+
private _free_string;
|
|
471
|
+
/**
|
|
472
|
+
* Converts a WASM-allocated string to JavaScript string and frees the WASM memory.
|
|
473
|
+
* @param ptr - Pointer to WASM string
|
|
474
|
+
* @returns JavaScript string
|
|
475
|
+
*/
|
|
476
|
+
private _string_from_wasm;
|
|
477
|
+
/**
|
|
478
|
+
* Optimizes and resolves an SVG with JavaScript-friendly interface.
|
|
479
|
+
* Resolves CSS styles from `<style>` tags and inlines them as element attributes.
|
|
480
|
+
*
|
|
481
|
+
* @param svg - Input SVG string
|
|
482
|
+
* @returns Promise resolving to SvgOptimizeResponse
|
|
483
|
+
*/
|
|
484
|
+
optimize(svg: string): svg.SVGOptimizeResponse;
|
|
485
|
+
pack(svg: string): svg.SVGPackResponse;
|
|
486
|
+
}
|
|
487
|
+
|
|
269
488
|
interface CreateImageResourceResult {
|
|
270
489
|
hash: string;
|
|
271
490
|
url: string;
|
|
@@ -283,6 +502,7 @@ declare class Scene {
|
|
|
283
502
|
private appptr;
|
|
284
503
|
private module;
|
|
285
504
|
readonly fontskit: FontsAPI;
|
|
505
|
+
readonly svgkit: SVGAPI;
|
|
286
506
|
constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
|
|
287
507
|
/**
|
|
288
508
|
* Allocates memory for a string and returns pointer and length.
|
|
@@ -348,8 +568,8 @@ declare class Scene {
|
|
|
348
568
|
setMainCameraTransform(transform: types.Transform2D): void;
|
|
349
569
|
getNodeIdFromPoint(x: number, y: number): string | null;
|
|
350
570
|
getNodeIdsFromPoint(x: number, y: number): string[];
|
|
351
|
-
getNodeIdsFromEnvelope(envelope: types.
|
|
352
|
-
getNodeAbsoluteBoundingBox(id: string): types.
|
|
571
|
+
getNodeIdsFromEnvelope(envelope: types.Rect): string[];
|
|
572
|
+
getNodeAbsoluteBoundingBox(id: string): types.Rect | null;
|
|
353
573
|
/**
|
|
354
574
|
* Convert a node into a vector network representation.
|
|
355
575
|
* Supports primitive shapes and text nodes.
|
|
@@ -429,7 +649,7 @@ declare namespace types {
|
|
|
429
649
|
number
|
|
430
650
|
]
|
|
431
651
|
];
|
|
432
|
-
type
|
|
652
|
+
type Rect = {
|
|
433
653
|
x: number;
|
|
434
654
|
y: number;
|
|
435
655
|
width: number;
|
|
@@ -480,4 +700,4 @@ declare class ApplicationFactory {
|
|
|
480
700
|
createWebGLCanvasSurfaceById(htmlcanvasid: string): Scene;
|
|
481
701
|
}
|
|
482
702
|
|
|
483
|
-
export { ApplicationFactory, type GridaCanvasModuleInitOptions, Scene, init as default, types, version };
|
|
703
|
+
export { ApplicationFactory, type GridaCanvasModuleInitOptions, Scene, init as default, svgtypes, types, version };
|