@grida/canvas-wasm 0.0.83-canary.0 → 0.0.85-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 +284 -5
- package/dist/index.d.ts +284 -5
- package/dist/index.js +522 -143
- package/dist/index.mjs +522 -143
- package/package.json +1 -1
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -193,6 +193,218 @@ declare namespace fonts {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
declare namespace markdown {
|
|
197
|
+
export type MarkdownToHtmlResponse = CAPIMethodResult<{
|
|
198
|
+
/** Converted HTML string */
|
|
199
|
+
html: string;
|
|
200
|
+
}>;
|
|
201
|
+
|
|
202
|
+
// ====================================================================================================
|
|
203
|
+
// #region: WASM Function Declarations
|
|
204
|
+
// ====================================================================================================
|
|
205
|
+
|
|
206
|
+
export interface MarkdownModule {
|
|
207
|
+
// ====================================================================================================
|
|
208
|
+
// #region: High-Level Markdown APIs
|
|
209
|
+
// ====================================================================================================
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Converts markdown text to HTML.
|
|
213
|
+
* Parses markdown content and converts it to HTML using the pulldown-cmark library.
|
|
214
|
+
*
|
|
215
|
+
* @param markdown - Pointer to input markdown string (null-terminated C string)
|
|
216
|
+
* @returns Pointer to JSON string containing {@link MarkdownToHtmlResponse}
|
|
217
|
+
*/
|
|
218
|
+
_grida_markdown_to_html(markdown: CPtr): CPtr;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
declare namespace svgtypes {
|
|
223
|
+
// ====================================================================================================
|
|
224
|
+
// #region: Core Type Definitions
|
|
225
|
+
// ====================================================================================================
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* rust/serde Option<T> equivalant
|
|
229
|
+
*/
|
|
230
|
+
type TOption<T> = T | null;
|
|
231
|
+
type RGBA8888 = [r: number, g: number, b: number, a: number];
|
|
232
|
+
type Transform2D = [[number, number, number], [number, number, number]];
|
|
233
|
+
type StrokeCap = "butt" | "round" | "square";
|
|
234
|
+
type StrokeJoin = "miter" | "round" | "bevel";
|
|
235
|
+
type FillRule = "nonzero" | "evenodd";
|
|
236
|
+
type BlendMode =
|
|
237
|
+
| "normal"
|
|
238
|
+
| "multiply"
|
|
239
|
+
| "screen"
|
|
240
|
+
| "overlay"
|
|
241
|
+
| "darken"
|
|
242
|
+
| "lighten"
|
|
243
|
+
| "color-dodge"
|
|
244
|
+
| "color-burn"
|
|
245
|
+
| "hard-light"
|
|
246
|
+
| "soft-light"
|
|
247
|
+
| "difference"
|
|
248
|
+
| "exclusion"
|
|
249
|
+
| "hue"
|
|
250
|
+
| "saturation"
|
|
251
|
+
| "color"
|
|
252
|
+
| "luminosity";
|
|
253
|
+
|
|
254
|
+
export enum SVGTextAnchor {
|
|
255
|
+
start = "start",
|
|
256
|
+
middle = "middle",
|
|
257
|
+
end = "end",
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export enum SVGSpreadMethod {
|
|
261
|
+
pad = "pad",
|
|
262
|
+
reflect = "reflect",
|
|
263
|
+
repeat = "repeat",
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface SVGSolidPaint {
|
|
267
|
+
kind: "solid";
|
|
268
|
+
color: RGBA8888;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface SVGGradientStop {
|
|
272
|
+
color: RGBA8888;
|
|
273
|
+
offset: number;
|
|
274
|
+
// opacity: number;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface SVGLinearGradientPaint {
|
|
278
|
+
kind: "linear-gradient";
|
|
279
|
+
id: string;
|
|
280
|
+
x1: number;
|
|
281
|
+
y1: number;
|
|
282
|
+
x2: number;
|
|
283
|
+
y2: number;
|
|
284
|
+
transform: Transform2D;
|
|
285
|
+
stops: Array<SVGGradientStop>;
|
|
286
|
+
spread_method: SVGSpreadMethod;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface SVGRadialGradientPaint {
|
|
290
|
+
kind: "radial-gradient";
|
|
291
|
+
id: string;
|
|
292
|
+
cx: number;
|
|
293
|
+
cy: number;
|
|
294
|
+
r: number;
|
|
295
|
+
fx: number;
|
|
296
|
+
fy: number;
|
|
297
|
+
transform: Transform2D;
|
|
298
|
+
stops: Array<SVGGradientStop>;
|
|
299
|
+
spread_method: SVGSpreadMethod;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export type SVGPaint =
|
|
303
|
+
| SVGSolidPaint
|
|
304
|
+
| SVGLinearGradientPaint
|
|
305
|
+
| SVGRadialGradientPaint;
|
|
306
|
+
|
|
307
|
+
export interface SVGFillAttributes {
|
|
308
|
+
paint: SVGPaint;
|
|
309
|
+
fill_opacity: number;
|
|
310
|
+
fill_rule: FillRule;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface SVGStrokeAttributes {
|
|
314
|
+
paint: SVGPaint;
|
|
315
|
+
stroke_width: TOption<number>;
|
|
316
|
+
stroke_linecap: StrokeCap;
|
|
317
|
+
stroke_linejoin: StrokeJoin;
|
|
318
|
+
stroke_miterlimit: number;
|
|
319
|
+
stroke_dasharray: TOption<Array<number>>;
|
|
320
|
+
stroke_opacity: number;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export namespace ir {
|
|
324
|
+
export interface IRSVGInitialContainerNode {
|
|
325
|
+
width: number;
|
|
326
|
+
height: number;
|
|
327
|
+
children: Array<IRSVGChildNode>;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export type IRSVGChildNode =
|
|
331
|
+
| IRSVGGroupNode
|
|
332
|
+
| IRSVGPathNode
|
|
333
|
+
| IRSVGTextNode
|
|
334
|
+
| IRSVGImageNode;
|
|
335
|
+
|
|
336
|
+
export interface IRSVGGroupNode {
|
|
337
|
+
kind: "group";
|
|
338
|
+
transform: Transform2D;
|
|
339
|
+
opacity: number;
|
|
340
|
+
blend_mode: BlendMode;
|
|
341
|
+
children: Array<IRSVGChildNode>;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface IRSVGPathNode {
|
|
345
|
+
kind: "path";
|
|
346
|
+
transform: Transform2D;
|
|
347
|
+
fill: TOption<SVGFillAttributes>;
|
|
348
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
349
|
+
d: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface IRSVGTextNode {
|
|
353
|
+
kind: "text";
|
|
354
|
+
transform: Transform2D;
|
|
355
|
+
text_content: string;
|
|
356
|
+
fill: TOption<SVGFillAttributes>;
|
|
357
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
358
|
+
spans: Array<IRSVGTextSpanNode>;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface IRSVGTextSpanNode {
|
|
362
|
+
transform: Transform2D;
|
|
363
|
+
text: string;
|
|
364
|
+
fill: TOption<SVGFillAttributes>;
|
|
365
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
366
|
+
font_size: TOption<number>;
|
|
367
|
+
anchor: SVGTextAnchor;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export interface IRSVGImageNode {
|
|
371
|
+
kind: "image";
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
declare namespace svg {
|
|
377
|
+
export type SVGOptimizeResponse = CAPIMethodResult<{
|
|
378
|
+
/** Optimized SVG string with CSS styles resolved and inlined */
|
|
379
|
+
svg_optimized: string;
|
|
380
|
+
}>;
|
|
381
|
+
|
|
382
|
+
export type SVGPackResponse = CAPIMethodResult<{
|
|
383
|
+
svg: svgtypes.ir.IRSVGInitialContainerNode;
|
|
384
|
+
}>;
|
|
385
|
+
|
|
386
|
+
// ====================================================================================================
|
|
387
|
+
// #region: WASM Function Declarations
|
|
388
|
+
// ====================================================================================================
|
|
389
|
+
|
|
390
|
+
export interface SVGModule {
|
|
391
|
+
// ====================================================================================================
|
|
392
|
+
// #region: High-Level SVG APIs
|
|
393
|
+
// ====================================================================================================
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Optimizes and resolves an SVG, producing a flat, self-contained SVG output.
|
|
397
|
+
* Resolves CSS styles from `<style>` tags and inlines them as element attributes.
|
|
398
|
+
*
|
|
399
|
+
* @param svg - Pointer to input SVG string (null-terminated C string)
|
|
400
|
+
* @returns Pointer to JSON string containing {@link svgtypes.SvgOptimizeResponse}
|
|
401
|
+
*/
|
|
402
|
+
_grida_svg_optimize(svg: CPtr): CPtr;
|
|
403
|
+
|
|
404
|
+
_grida_svg_pack(sgv: CPtr): CPtr;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
196
408
|
///
|
|
197
409
|
/// @grida/canvas-wasm grida-canvas-wasm.js typescript definitions
|
|
198
410
|
/// this is NOT generated by emscripten. update manually.
|
|
@@ -211,7 +423,9 @@ declare namespace createGridaCanvas$1 {
|
|
|
211
423
|
interface GridaCanvasWasmBindings
|
|
212
424
|
extends emscripten.emscripten_EXPORTED_RUNTIME_METHODS,
|
|
213
425
|
canvas.CanvasModule,
|
|
214
|
-
fonts.FontsModule
|
|
426
|
+
fonts.FontsModule,
|
|
427
|
+
markdown.MarkdownModule,
|
|
428
|
+
svg.SVGModule {}
|
|
215
429
|
}
|
|
216
430
|
|
|
217
431
|
declare class FontsAPI {
|
|
@@ -266,6 +480,69 @@ declare class FontsAPI {
|
|
|
266
480
|
parseFont(fontData: ArrayBuffer | Uint8Array, faceId: string, userFontStyleItalic?: boolean): Promise<fonts.types.FaceRecord>;
|
|
267
481
|
}
|
|
268
482
|
|
|
483
|
+
declare class MarkdownAPI {
|
|
484
|
+
private module;
|
|
485
|
+
constructor(module: any);
|
|
486
|
+
/**
|
|
487
|
+
* Allocates memory for a string and returns pointer and length.
|
|
488
|
+
* @param txt - String to allocate
|
|
489
|
+
* @returns [pointer, length] tuple
|
|
490
|
+
*/
|
|
491
|
+
private _alloc_string;
|
|
492
|
+
/**
|
|
493
|
+
* Frees memory allocated for a string.
|
|
494
|
+
* @param ptr - Pointer to free
|
|
495
|
+
* @param len - Length of allocated memory
|
|
496
|
+
*/
|
|
497
|
+
private _free_string;
|
|
498
|
+
/**
|
|
499
|
+
* Converts a WASM-allocated string to JavaScript string and frees the WASM memory.
|
|
500
|
+
* @param ptr - Pointer to WASM string
|
|
501
|
+
* @returns JavaScript string
|
|
502
|
+
*/
|
|
503
|
+
private _string_from_wasm;
|
|
504
|
+
/**
|
|
505
|
+
* Converts markdown text to HTML with JavaScript-friendly interface.
|
|
506
|
+
* Parses markdown content and converts it to HTML using the pulldown-cmark library.
|
|
507
|
+
*
|
|
508
|
+
* @param markdown - Input markdown string
|
|
509
|
+
* @returns MarkdownToHtmlResponse containing the converted HTML or error information
|
|
510
|
+
*/
|
|
511
|
+
toHtml(markdown: string): markdown.MarkdownToHtmlResponse;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
declare class SVGAPI {
|
|
515
|
+
private module;
|
|
516
|
+
constructor(module: any);
|
|
517
|
+
/**
|
|
518
|
+
* Allocates memory for a string and returns pointer and length.
|
|
519
|
+
* @param txt - String to allocate
|
|
520
|
+
* @returns [pointer, length] tuple
|
|
521
|
+
*/
|
|
522
|
+
private _alloc_string;
|
|
523
|
+
/**
|
|
524
|
+
* Frees memory allocated for a string.
|
|
525
|
+
* @param ptr - Pointer to free
|
|
526
|
+
* @param len - Length of allocated memory
|
|
527
|
+
*/
|
|
528
|
+
private _free_string;
|
|
529
|
+
/**
|
|
530
|
+
* Converts a WASM-allocated string to JavaScript string and frees the WASM memory.
|
|
531
|
+
* @param ptr - Pointer to WASM string
|
|
532
|
+
* @returns JavaScript string
|
|
533
|
+
*/
|
|
534
|
+
private _string_from_wasm;
|
|
535
|
+
/**
|
|
536
|
+
* Optimizes and resolves an SVG with JavaScript-friendly interface.
|
|
537
|
+
* Resolves CSS styles from `<style>` tags and inlines them as element attributes.
|
|
538
|
+
*
|
|
539
|
+
* @param svg - Input SVG string
|
|
540
|
+
* @returns Promise resolving to SvgOptimizeResponse
|
|
541
|
+
*/
|
|
542
|
+
optimize(svg: string): svg.SVGOptimizeResponse;
|
|
543
|
+
pack(svg: string): svg.SVGPackResponse;
|
|
544
|
+
}
|
|
545
|
+
|
|
269
546
|
interface CreateImageResourceResult {
|
|
270
547
|
hash: string;
|
|
271
548
|
url: string;
|
|
@@ -283,6 +560,8 @@ declare class Scene {
|
|
|
283
560
|
private appptr;
|
|
284
561
|
private module;
|
|
285
562
|
readonly fontskit: FontsAPI;
|
|
563
|
+
readonly markdownkit: MarkdownAPI;
|
|
564
|
+
readonly svgkit: SVGAPI;
|
|
286
565
|
constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
|
|
287
566
|
/**
|
|
288
567
|
* Allocates memory for a string and returns pointer and length.
|
|
@@ -348,8 +627,8 @@ declare class Scene {
|
|
|
348
627
|
setMainCameraTransform(transform: types.Transform2D): void;
|
|
349
628
|
getNodeIdFromPoint(x: number, y: number): string | null;
|
|
350
629
|
getNodeIdsFromPoint(x: number, y: number): string[];
|
|
351
|
-
getNodeIdsFromEnvelope(envelope: types.
|
|
352
|
-
getNodeAbsoluteBoundingBox(id: string): types.
|
|
630
|
+
getNodeIdsFromEnvelope(envelope: types.Rect): string[];
|
|
631
|
+
getNodeAbsoluteBoundingBox(id: string): types.Rect | null;
|
|
353
632
|
/**
|
|
354
633
|
* Convert a node into a vector network representation.
|
|
355
634
|
* Supports primitive shapes and text nodes.
|
|
@@ -429,7 +708,7 @@ declare namespace types {
|
|
|
429
708
|
number
|
|
430
709
|
]
|
|
431
710
|
];
|
|
432
|
-
type
|
|
711
|
+
type Rect = {
|
|
433
712
|
x: number;
|
|
434
713
|
y: number;
|
|
435
714
|
width: number;
|
|
@@ -480,4 +759,4 @@ declare class ApplicationFactory {
|
|
|
480
759
|
createWebGLCanvasSurfaceById(htmlcanvasid: string): Scene;
|
|
481
760
|
}
|
|
482
761
|
|
|
483
|
-
export { ApplicationFactory, type GridaCanvasModuleInitOptions, Scene, init as default, types, version };
|
|
762
|
+
export { ApplicationFactory, type GridaCanvasModuleInitOptions, Scene, init as default, svgtypes, types, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -193,6 +193,218 @@ declare namespace fonts {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
declare namespace markdown {
|
|
197
|
+
export type MarkdownToHtmlResponse = CAPIMethodResult<{
|
|
198
|
+
/** Converted HTML string */
|
|
199
|
+
html: string;
|
|
200
|
+
}>;
|
|
201
|
+
|
|
202
|
+
// ====================================================================================================
|
|
203
|
+
// #region: WASM Function Declarations
|
|
204
|
+
// ====================================================================================================
|
|
205
|
+
|
|
206
|
+
export interface MarkdownModule {
|
|
207
|
+
// ====================================================================================================
|
|
208
|
+
// #region: High-Level Markdown APIs
|
|
209
|
+
// ====================================================================================================
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Converts markdown text to HTML.
|
|
213
|
+
* Parses markdown content and converts it to HTML using the pulldown-cmark library.
|
|
214
|
+
*
|
|
215
|
+
* @param markdown - Pointer to input markdown string (null-terminated C string)
|
|
216
|
+
* @returns Pointer to JSON string containing {@link MarkdownToHtmlResponse}
|
|
217
|
+
*/
|
|
218
|
+
_grida_markdown_to_html(markdown: CPtr): CPtr;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
declare namespace svgtypes {
|
|
223
|
+
// ====================================================================================================
|
|
224
|
+
// #region: Core Type Definitions
|
|
225
|
+
// ====================================================================================================
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* rust/serde Option<T> equivalant
|
|
229
|
+
*/
|
|
230
|
+
type TOption<T> = T | null;
|
|
231
|
+
type RGBA8888 = [r: number, g: number, b: number, a: number];
|
|
232
|
+
type Transform2D = [[number, number, number], [number, number, number]];
|
|
233
|
+
type StrokeCap = "butt" | "round" | "square";
|
|
234
|
+
type StrokeJoin = "miter" | "round" | "bevel";
|
|
235
|
+
type FillRule = "nonzero" | "evenodd";
|
|
236
|
+
type BlendMode =
|
|
237
|
+
| "normal"
|
|
238
|
+
| "multiply"
|
|
239
|
+
| "screen"
|
|
240
|
+
| "overlay"
|
|
241
|
+
| "darken"
|
|
242
|
+
| "lighten"
|
|
243
|
+
| "color-dodge"
|
|
244
|
+
| "color-burn"
|
|
245
|
+
| "hard-light"
|
|
246
|
+
| "soft-light"
|
|
247
|
+
| "difference"
|
|
248
|
+
| "exclusion"
|
|
249
|
+
| "hue"
|
|
250
|
+
| "saturation"
|
|
251
|
+
| "color"
|
|
252
|
+
| "luminosity";
|
|
253
|
+
|
|
254
|
+
export enum SVGTextAnchor {
|
|
255
|
+
start = "start",
|
|
256
|
+
middle = "middle",
|
|
257
|
+
end = "end",
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export enum SVGSpreadMethod {
|
|
261
|
+
pad = "pad",
|
|
262
|
+
reflect = "reflect",
|
|
263
|
+
repeat = "repeat",
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface SVGSolidPaint {
|
|
267
|
+
kind: "solid";
|
|
268
|
+
color: RGBA8888;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface SVGGradientStop {
|
|
272
|
+
color: RGBA8888;
|
|
273
|
+
offset: number;
|
|
274
|
+
// opacity: number;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface SVGLinearGradientPaint {
|
|
278
|
+
kind: "linear-gradient";
|
|
279
|
+
id: string;
|
|
280
|
+
x1: number;
|
|
281
|
+
y1: number;
|
|
282
|
+
x2: number;
|
|
283
|
+
y2: number;
|
|
284
|
+
transform: Transform2D;
|
|
285
|
+
stops: Array<SVGGradientStop>;
|
|
286
|
+
spread_method: SVGSpreadMethod;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface SVGRadialGradientPaint {
|
|
290
|
+
kind: "radial-gradient";
|
|
291
|
+
id: string;
|
|
292
|
+
cx: number;
|
|
293
|
+
cy: number;
|
|
294
|
+
r: number;
|
|
295
|
+
fx: number;
|
|
296
|
+
fy: number;
|
|
297
|
+
transform: Transform2D;
|
|
298
|
+
stops: Array<SVGGradientStop>;
|
|
299
|
+
spread_method: SVGSpreadMethod;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export type SVGPaint =
|
|
303
|
+
| SVGSolidPaint
|
|
304
|
+
| SVGLinearGradientPaint
|
|
305
|
+
| SVGRadialGradientPaint;
|
|
306
|
+
|
|
307
|
+
export interface SVGFillAttributes {
|
|
308
|
+
paint: SVGPaint;
|
|
309
|
+
fill_opacity: number;
|
|
310
|
+
fill_rule: FillRule;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface SVGStrokeAttributes {
|
|
314
|
+
paint: SVGPaint;
|
|
315
|
+
stroke_width: TOption<number>;
|
|
316
|
+
stroke_linecap: StrokeCap;
|
|
317
|
+
stroke_linejoin: StrokeJoin;
|
|
318
|
+
stroke_miterlimit: number;
|
|
319
|
+
stroke_dasharray: TOption<Array<number>>;
|
|
320
|
+
stroke_opacity: number;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export namespace ir {
|
|
324
|
+
export interface IRSVGInitialContainerNode {
|
|
325
|
+
width: number;
|
|
326
|
+
height: number;
|
|
327
|
+
children: Array<IRSVGChildNode>;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export type IRSVGChildNode =
|
|
331
|
+
| IRSVGGroupNode
|
|
332
|
+
| IRSVGPathNode
|
|
333
|
+
| IRSVGTextNode
|
|
334
|
+
| IRSVGImageNode;
|
|
335
|
+
|
|
336
|
+
export interface IRSVGGroupNode {
|
|
337
|
+
kind: "group";
|
|
338
|
+
transform: Transform2D;
|
|
339
|
+
opacity: number;
|
|
340
|
+
blend_mode: BlendMode;
|
|
341
|
+
children: Array<IRSVGChildNode>;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface IRSVGPathNode {
|
|
345
|
+
kind: "path";
|
|
346
|
+
transform: Transform2D;
|
|
347
|
+
fill: TOption<SVGFillAttributes>;
|
|
348
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
349
|
+
d: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface IRSVGTextNode {
|
|
353
|
+
kind: "text";
|
|
354
|
+
transform: Transform2D;
|
|
355
|
+
text_content: string;
|
|
356
|
+
fill: TOption<SVGFillAttributes>;
|
|
357
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
358
|
+
spans: Array<IRSVGTextSpanNode>;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface IRSVGTextSpanNode {
|
|
362
|
+
transform: Transform2D;
|
|
363
|
+
text: string;
|
|
364
|
+
fill: TOption<SVGFillAttributes>;
|
|
365
|
+
stroke: TOption<SVGStrokeAttributes>;
|
|
366
|
+
font_size: TOption<number>;
|
|
367
|
+
anchor: SVGTextAnchor;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export interface IRSVGImageNode {
|
|
371
|
+
kind: "image";
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
declare namespace svg {
|
|
377
|
+
export type SVGOptimizeResponse = CAPIMethodResult<{
|
|
378
|
+
/** Optimized SVG string with CSS styles resolved and inlined */
|
|
379
|
+
svg_optimized: string;
|
|
380
|
+
}>;
|
|
381
|
+
|
|
382
|
+
export type SVGPackResponse = CAPIMethodResult<{
|
|
383
|
+
svg: svgtypes.ir.IRSVGInitialContainerNode;
|
|
384
|
+
}>;
|
|
385
|
+
|
|
386
|
+
// ====================================================================================================
|
|
387
|
+
// #region: WASM Function Declarations
|
|
388
|
+
// ====================================================================================================
|
|
389
|
+
|
|
390
|
+
export interface SVGModule {
|
|
391
|
+
// ====================================================================================================
|
|
392
|
+
// #region: High-Level SVG APIs
|
|
393
|
+
// ====================================================================================================
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Optimizes and resolves an SVG, producing a flat, self-contained SVG output.
|
|
397
|
+
* Resolves CSS styles from `<style>` tags and inlines them as element attributes.
|
|
398
|
+
*
|
|
399
|
+
* @param svg - Pointer to input SVG string (null-terminated C string)
|
|
400
|
+
* @returns Pointer to JSON string containing {@link svgtypes.SvgOptimizeResponse}
|
|
401
|
+
*/
|
|
402
|
+
_grida_svg_optimize(svg: CPtr): CPtr;
|
|
403
|
+
|
|
404
|
+
_grida_svg_pack(sgv: CPtr): CPtr;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
196
408
|
///
|
|
197
409
|
/// @grida/canvas-wasm grida-canvas-wasm.js typescript definitions
|
|
198
410
|
/// this is NOT generated by emscripten. update manually.
|
|
@@ -211,7 +423,9 @@ declare namespace createGridaCanvas$1 {
|
|
|
211
423
|
interface GridaCanvasWasmBindings
|
|
212
424
|
extends emscripten.emscripten_EXPORTED_RUNTIME_METHODS,
|
|
213
425
|
canvas.CanvasModule,
|
|
214
|
-
fonts.FontsModule
|
|
426
|
+
fonts.FontsModule,
|
|
427
|
+
markdown.MarkdownModule,
|
|
428
|
+
svg.SVGModule {}
|
|
215
429
|
}
|
|
216
430
|
|
|
217
431
|
declare class FontsAPI {
|
|
@@ -266,6 +480,69 @@ declare class FontsAPI {
|
|
|
266
480
|
parseFont(fontData: ArrayBuffer | Uint8Array, faceId: string, userFontStyleItalic?: boolean): Promise<fonts.types.FaceRecord>;
|
|
267
481
|
}
|
|
268
482
|
|
|
483
|
+
declare class MarkdownAPI {
|
|
484
|
+
private module;
|
|
485
|
+
constructor(module: any);
|
|
486
|
+
/**
|
|
487
|
+
* Allocates memory for a string and returns pointer and length.
|
|
488
|
+
* @param txt - String to allocate
|
|
489
|
+
* @returns [pointer, length] tuple
|
|
490
|
+
*/
|
|
491
|
+
private _alloc_string;
|
|
492
|
+
/**
|
|
493
|
+
* Frees memory allocated for a string.
|
|
494
|
+
* @param ptr - Pointer to free
|
|
495
|
+
* @param len - Length of allocated memory
|
|
496
|
+
*/
|
|
497
|
+
private _free_string;
|
|
498
|
+
/**
|
|
499
|
+
* Converts a WASM-allocated string to JavaScript string and frees the WASM memory.
|
|
500
|
+
* @param ptr - Pointer to WASM string
|
|
501
|
+
* @returns JavaScript string
|
|
502
|
+
*/
|
|
503
|
+
private _string_from_wasm;
|
|
504
|
+
/**
|
|
505
|
+
* Converts markdown text to HTML with JavaScript-friendly interface.
|
|
506
|
+
* Parses markdown content and converts it to HTML using the pulldown-cmark library.
|
|
507
|
+
*
|
|
508
|
+
* @param markdown - Input markdown string
|
|
509
|
+
* @returns MarkdownToHtmlResponse containing the converted HTML or error information
|
|
510
|
+
*/
|
|
511
|
+
toHtml(markdown: string): markdown.MarkdownToHtmlResponse;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
declare class SVGAPI {
|
|
515
|
+
private module;
|
|
516
|
+
constructor(module: any);
|
|
517
|
+
/**
|
|
518
|
+
* Allocates memory for a string and returns pointer and length.
|
|
519
|
+
* @param txt - String to allocate
|
|
520
|
+
* @returns [pointer, length] tuple
|
|
521
|
+
*/
|
|
522
|
+
private _alloc_string;
|
|
523
|
+
/**
|
|
524
|
+
* Frees memory allocated for a string.
|
|
525
|
+
* @param ptr - Pointer to free
|
|
526
|
+
* @param len - Length of allocated memory
|
|
527
|
+
*/
|
|
528
|
+
private _free_string;
|
|
529
|
+
/**
|
|
530
|
+
* Converts a WASM-allocated string to JavaScript string and frees the WASM memory.
|
|
531
|
+
* @param ptr - Pointer to WASM string
|
|
532
|
+
* @returns JavaScript string
|
|
533
|
+
*/
|
|
534
|
+
private _string_from_wasm;
|
|
535
|
+
/**
|
|
536
|
+
* Optimizes and resolves an SVG with JavaScript-friendly interface.
|
|
537
|
+
* Resolves CSS styles from `<style>` tags and inlines them as element attributes.
|
|
538
|
+
*
|
|
539
|
+
* @param svg - Input SVG string
|
|
540
|
+
* @returns Promise resolving to SvgOptimizeResponse
|
|
541
|
+
*/
|
|
542
|
+
optimize(svg: string): svg.SVGOptimizeResponse;
|
|
543
|
+
pack(svg: string): svg.SVGPackResponse;
|
|
544
|
+
}
|
|
545
|
+
|
|
269
546
|
interface CreateImageResourceResult {
|
|
270
547
|
hash: string;
|
|
271
548
|
url: string;
|
|
@@ -283,6 +560,8 @@ declare class Scene {
|
|
|
283
560
|
private appptr;
|
|
284
561
|
private module;
|
|
285
562
|
readonly fontskit: FontsAPI;
|
|
563
|
+
readonly markdownkit: MarkdownAPI;
|
|
564
|
+
readonly svgkit: SVGAPI;
|
|
286
565
|
constructor(module: createGridaCanvas.GridaCanvasWasmBindings, ptr: number);
|
|
287
566
|
/**
|
|
288
567
|
* Allocates memory for a string and returns pointer and length.
|
|
@@ -348,8 +627,8 @@ declare class Scene {
|
|
|
348
627
|
setMainCameraTransform(transform: types.Transform2D): void;
|
|
349
628
|
getNodeIdFromPoint(x: number, y: number): string | null;
|
|
350
629
|
getNodeIdsFromPoint(x: number, y: number): string[];
|
|
351
|
-
getNodeIdsFromEnvelope(envelope: types.
|
|
352
|
-
getNodeAbsoluteBoundingBox(id: string): types.
|
|
630
|
+
getNodeIdsFromEnvelope(envelope: types.Rect): string[];
|
|
631
|
+
getNodeAbsoluteBoundingBox(id: string): types.Rect | null;
|
|
353
632
|
/**
|
|
354
633
|
* Convert a node into a vector network representation.
|
|
355
634
|
* Supports primitive shapes and text nodes.
|
|
@@ -429,7 +708,7 @@ declare namespace types {
|
|
|
429
708
|
number
|
|
430
709
|
]
|
|
431
710
|
];
|
|
432
|
-
type
|
|
711
|
+
type Rect = {
|
|
433
712
|
x: number;
|
|
434
713
|
y: number;
|
|
435
714
|
width: number;
|
|
@@ -480,4 +759,4 @@ declare class ApplicationFactory {
|
|
|
480
759
|
createWebGLCanvasSurfaceById(htmlcanvasid: string): Scene;
|
|
481
760
|
}
|
|
482
761
|
|
|
483
|
-
export { ApplicationFactory, type GridaCanvasModuleInitOptions, Scene, init as default, types, version };
|
|
762
|
+
export { ApplicationFactory, type GridaCanvasModuleInitOptions, Scene, init as default, svgtypes, types, version };
|