@iyulab/declart 0.21.0 → 0.22.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/index.d.ts +25 -4
- package/index.js +21 -7
- package/index.mjs +1 -0
- package/package.json +1 -1
- package/wasm/declart_wasm.d.ts +12 -3
- package/wasm/declart_wasm.js +40 -6
- package/wasm/declart_wasm_bg.wasm +0 -0
package/index.d.ts
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
|
+
/** Options for the render functions. */
|
|
2
|
+
export interface RenderOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Leave the backdrop unpainted so the page shows through. Colors are unchanged —
|
|
5
|
+
* on a dark page use the `dark` theme so text stays legible.
|
|
6
|
+
*/
|
|
7
|
+
transparent?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
/**
|
|
2
11
|
* Renders a TOML or JSON diagram declaration to SVG.
|
|
3
12
|
* @param input - TOML or JSON declaration string (format auto-detected)
|
|
4
|
-
* @param theme - Theme name: 'default', 'monochrome', 'accessible', 'warm' (defaults to 'default')
|
|
13
|
+
* @param theme - Theme name: 'default', 'monochrome', 'accessible', 'warm', 'dark' (defaults to 'default')
|
|
5
14
|
* @param width - Optional canvas width in pixels (height scales proportionally)
|
|
15
|
+
* @param options - `transparent: true` leaves the backdrop unpainted
|
|
6
16
|
* @returns SVG string
|
|
7
17
|
* @throws If the declaration is invalid
|
|
8
18
|
*/
|
|
9
|
-
export function render(input: string, theme?: string, width?: number): string;
|
|
19
|
+
export function render(input: string, theme?: string, width?: number, options?: RenderOptions): string;
|
|
10
20
|
|
|
11
21
|
/**
|
|
12
22
|
* Renders a JSON diagram declaration to SVG.
|
|
13
23
|
* @param input - JSON declaration string
|
|
14
24
|
* @param theme - Theme name (defaults to 'default')
|
|
15
25
|
* @param width - Optional canvas width in pixels
|
|
26
|
+
* @param options - `transparent: true` leaves the backdrop unpainted
|
|
16
27
|
* @returns SVG string
|
|
17
28
|
* @throws If the JSON declaration is invalid
|
|
18
29
|
*/
|
|
19
|
-
export function renderJson(input: string, theme?: string, width?: number): string;
|
|
30
|
+
export function renderJson(input: string, theme?: string, width?: number, options?: RenderOptions): string;
|
|
20
31
|
|
|
21
32
|
/**
|
|
22
33
|
* Renders a TOML or JSON diagram declaration with a custom theme TOML.
|
|
23
34
|
* @param input - TOML or JSON declaration string
|
|
24
35
|
* @param themeToml - TOML theme definition string
|
|
25
36
|
* @param width - Optional canvas width in pixels
|
|
37
|
+
* @param options - `transparent: true` leaves the backdrop unpainted
|
|
26
38
|
* @returns SVG string
|
|
27
39
|
* @throws If the declaration or theme is invalid
|
|
28
40
|
*/
|
|
29
|
-
export function renderWithThemeToml(input: string, themeToml: string, width?: number): string;
|
|
41
|
+
export function renderWithThemeToml(input: string, themeToml: string, width?: number, options?: RenderOptions): string;
|
|
30
42
|
|
|
31
43
|
/**
|
|
32
44
|
* Validates a TOML or JSON diagram declaration without rendering.
|
|
@@ -35,6 +47,15 @@ export function renderWithThemeToml(input: string, themeToml: string, width?: nu
|
|
|
35
47
|
*/
|
|
36
48
|
export function validate(input: string): void;
|
|
37
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Returns a one-paragraph text equivalent of a TOML or JSON declaration — the text the
|
|
52
|
+
* rendered SVG carries as its `<desc>`. Use it as `alt` when the SVG is shown through `<img>`.
|
|
53
|
+
* @param input - TOML or JSON declaration string
|
|
54
|
+
* @returns Text equivalent, e.g. `"Process: Upload → Parse → Index."`
|
|
55
|
+
* @throws If the declaration is invalid
|
|
56
|
+
*/
|
|
57
|
+
export function describe(input: string): string;
|
|
58
|
+
|
|
38
59
|
/**
|
|
39
60
|
* Returns the list of supported theme names.
|
|
40
61
|
*/
|
package/index.js
CHANGED
|
@@ -7,10 +7,11 @@ const wasm = require('./wasm/declart_wasm');
|
|
|
7
7
|
* @param {string} input - TOML or JSON declaration string (auto-detected)
|
|
8
8
|
* @param {string} [theme='default'] - Theme name: 'default', 'monochrome', 'accessible', 'warm'
|
|
9
9
|
* @param {number} [width] - Optional canvas width in pixels
|
|
10
|
+
* @param {{ transparent?: boolean }} [options] - `transparent: true` leaves the backdrop unpainted
|
|
10
11
|
* @returns {string} SVG string
|
|
11
12
|
*/
|
|
12
|
-
function render(input, theme = 'default', width) {
|
|
13
|
-
return wasm.render(input, theme, width ?? null);
|
|
13
|
+
function render(input, theme = 'default', width, options) {
|
|
14
|
+
return wasm.render(input, theme, width ?? null, options?.transparent ?? null);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -18,10 +19,11 @@ function render(input, theme = 'default', width) {
|
|
|
18
19
|
* @param {string} input - JSON declaration string
|
|
19
20
|
* @param {string} [theme='default'] - Theme name
|
|
20
21
|
* @param {number} [width] - Optional canvas width in pixels
|
|
22
|
+
* @param {{ transparent?: boolean }} [options] - `transparent: true` leaves the backdrop unpainted
|
|
21
23
|
* @returns {string} SVG string
|
|
22
24
|
*/
|
|
23
|
-
function renderJson(input, theme = 'default', width) {
|
|
24
|
-
return wasm.render_json(input, theme, width ?? null);
|
|
25
|
+
function renderJson(input, theme = 'default', width, options) {
|
|
26
|
+
return wasm.render_json(input, theme, width ?? null, options?.transparent ?? null);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -29,10 +31,11 @@ function renderJson(input, theme = 'default', width) {
|
|
|
29
31
|
* @param {string} input - TOML or JSON declaration string
|
|
30
32
|
* @param {string} themeToml - TOML theme definition string
|
|
31
33
|
* @param {number} [width] - Optional canvas width in pixels
|
|
34
|
+
* @param {{ transparent?: boolean }} [options] - `transparent: true` leaves the backdrop unpainted
|
|
32
35
|
* @returns {string} SVG string
|
|
33
36
|
*/
|
|
34
|
-
function renderWithThemeToml(input, themeToml, width) {
|
|
35
|
-
return wasm.render_with_theme_toml(input, themeToml, width ?? null);
|
|
37
|
+
function renderWithThemeToml(input, themeToml, width, options) {
|
|
38
|
+
return wasm.render_with_theme_toml(input, themeToml, width ?? null, options?.transparent ?? null);
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
@@ -44,6 +47,17 @@ function validate(input) {
|
|
|
44
47
|
return wasm.validate(input);
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Returns a one-paragraph text equivalent of a TOML or JSON declaration — the text the
|
|
52
|
+
* rendered SVG carries as its `<desc>`. Use it as `alt` when the SVG is shown through `<img>`.
|
|
53
|
+
* @param {string} input - TOML or JSON declaration string
|
|
54
|
+
* @returns {string} Text equivalent
|
|
55
|
+
* @throws {Error} If the declaration is invalid
|
|
56
|
+
*/
|
|
57
|
+
function describe(input) {
|
|
58
|
+
return wasm.describe(input);
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
/**
|
|
48
62
|
* Returns the list of supported theme names.
|
|
49
63
|
* @returns {string[]}
|
|
@@ -60,4 +74,4 @@ function kinds() {
|
|
|
60
74
|
return wasm.kinds().split(',');
|
|
61
75
|
}
|
|
62
76
|
|
|
63
|
-
module.exports = { render, renderJson, renderWithThemeToml, validate, themes, kinds };
|
|
77
|
+
module.exports = { render, renderJson, renderWithThemeToml, validate, describe, themes, kinds };
|
package/index.mjs
CHANGED
|
@@ -8,5 +8,6 @@ export const render = declart.render;
|
|
|
8
8
|
export const renderJson = declart.renderJson;
|
|
9
9
|
export const renderWithThemeToml = declart.renderWithThemeToml;
|
|
10
10
|
export const validate = declart.validate;
|
|
11
|
+
export const describe = declart.describe;
|
|
11
12
|
export const themes = declart.themes;
|
|
12
13
|
export const kinds = declart.kinds;
|
package/package.json
CHANGED
package/wasm/declart_wasm.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Returns a one-paragraph text equivalent of a TOML or JSON declaration — the same text the
|
|
6
|
+
* rendered SVG carries as `<desc>`. Use it as `alt` when the SVG is shown through `<img>`.
|
|
7
|
+
*
|
|
8
|
+
* Returns a `JsError` with the parse/validation error message when the declaration is invalid.
|
|
9
|
+
*/
|
|
10
|
+
export function describe(input: string): string;
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* Returns a comma-separated list of supported diagram kind names.
|
|
6
14
|
*/
|
|
@@ -12,10 +20,11 @@ export function kinds(): string;
|
|
|
12
20
|
* - `input`: TOML or JSON declaration string (auto-detected by leading `{`)
|
|
13
21
|
* - `theme`: `"default"`, `"monochrome"`, `"accessible"`, or `"warm"` (unknown values fall back to `"default"`)
|
|
14
22
|
* - `width`: optional canvas width in pixels (height scales proportionally)
|
|
23
|
+
* - `transparent`: `Some(true)` leaves the backdrop unpainted so the page shows through
|
|
15
24
|
*
|
|
16
25
|
* Returns the SVG string on success, or a `JsError` with a descriptive message on failure.
|
|
17
26
|
*/
|
|
18
|
-
export function render(input: string, theme: string, width?: number | null): string;
|
|
27
|
+
export function render(input: string, theme: string, width?: number | null, transparent?: boolean | null): string;
|
|
19
28
|
|
|
20
29
|
/**
|
|
21
30
|
* Renders a JSON diagram declaration to SVG with a named theme.
|
|
@@ -26,7 +35,7 @@ export function render(input: string, theme: string, width?: number | null): str
|
|
|
26
35
|
*
|
|
27
36
|
* Returns the SVG string on success, or a `JsError` on failure.
|
|
28
37
|
*/
|
|
29
|
-
export function render_json(input: string, theme: string, width?: number | null): string;
|
|
38
|
+
export function render_json(input: string, theme: string, width?: number | null, transparent?: boolean | null): string;
|
|
30
39
|
|
|
31
40
|
/**
|
|
32
41
|
* Renders a TOML or JSON diagram declaration with a custom theme defined as a TOML string.
|
|
@@ -37,7 +46,7 @@ export function render_json(input: string, theme: string, width?: number | null)
|
|
|
37
46
|
*
|
|
38
47
|
* Returns the SVG string on success, or a `JsError` on parse/validation failure.
|
|
39
48
|
*/
|
|
40
|
-
export function render_with_theme_toml(input: string, theme_toml: string, width?: number | null): string;
|
|
49
|
+
export function render_with_theme_toml(input: string, theme_toml: string, width?: number | null, transparent?: boolean | null): string;
|
|
41
50
|
|
|
42
51
|
/**
|
|
43
52
|
* Returns a comma-separated list of supported theme names.
|
package/wasm/declart_wasm.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
/* @ts-self-types="./declart_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Returns a one-paragraph text equivalent of a TOML or JSON declaration — the same text the
|
|
5
|
+
* rendered SVG carries as `<desc>`. Use it as `alt` when the SVG is shown through `<img>`.
|
|
6
|
+
*
|
|
7
|
+
* Returns a `JsError` with the parse/validation error message when the declaration is invalid.
|
|
8
|
+
* @param {string} input
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
function describe(input) {
|
|
12
|
+
let deferred3_0;
|
|
13
|
+
let deferred3_1;
|
|
14
|
+
try {
|
|
15
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
16
|
+
const len0 = WASM_VECTOR_LEN;
|
|
17
|
+
const ret = wasm.describe(ptr0, len0);
|
|
18
|
+
var ptr2 = ret[0];
|
|
19
|
+
var len2 = ret[1];
|
|
20
|
+
if (ret[3]) {
|
|
21
|
+
ptr2 = 0; len2 = 0;
|
|
22
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
23
|
+
}
|
|
24
|
+
deferred3_0 = ptr2;
|
|
25
|
+
deferred3_1 = len2;
|
|
26
|
+
return getStringFromWasm0(ptr2, len2);
|
|
27
|
+
} finally {
|
|
28
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.describe = describe;
|
|
32
|
+
|
|
3
33
|
/**
|
|
4
34
|
* Returns a comma-separated list of supported diagram kind names.
|
|
5
35
|
* @returns {string}
|
|
@@ -24,14 +54,16 @@ exports.kinds = kinds;
|
|
|
24
54
|
* - `input`: TOML or JSON declaration string (auto-detected by leading `{`)
|
|
25
55
|
* - `theme`: `"default"`, `"monochrome"`, `"accessible"`, or `"warm"` (unknown values fall back to `"default"`)
|
|
26
56
|
* - `width`: optional canvas width in pixels (height scales proportionally)
|
|
57
|
+
* - `transparent`: `Some(true)` leaves the backdrop unpainted so the page shows through
|
|
27
58
|
*
|
|
28
59
|
* Returns the SVG string on success, or a `JsError` with a descriptive message on failure.
|
|
29
60
|
* @param {string} input
|
|
30
61
|
* @param {string} theme
|
|
31
62
|
* @param {number | null} [width]
|
|
63
|
+
* @param {boolean | null} [transparent]
|
|
32
64
|
* @returns {string}
|
|
33
65
|
*/
|
|
34
|
-
function render(input, theme, width) {
|
|
66
|
+
function render(input, theme, width, transparent) {
|
|
35
67
|
let deferred4_0;
|
|
36
68
|
let deferred4_1;
|
|
37
69
|
try {
|
|
@@ -39,7 +71,7 @@ function render(input, theme, width) {
|
|
|
39
71
|
const len0 = WASM_VECTOR_LEN;
|
|
40
72
|
const ptr1 = passStringToWasm0(theme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
41
73
|
const len1 = WASM_VECTOR_LEN;
|
|
42
|
-
const ret = wasm.render(ptr0, len0, ptr1, len1, isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0);
|
|
74
|
+
const ret = wasm.render(ptr0, len0, ptr1, len1, isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0, isLikeNone(transparent) ? 0xFFFFFF : transparent ? 1 : 0);
|
|
43
75
|
var ptr3 = ret[0];
|
|
44
76
|
var len3 = ret[1];
|
|
45
77
|
if (ret[3]) {
|
|
@@ -66,9 +98,10 @@ exports.render = render;
|
|
|
66
98
|
* @param {string} input
|
|
67
99
|
* @param {string} theme
|
|
68
100
|
* @param {number | null} [width]
|
|
101
|
+
* @param {boolean | null} [transparent]
|
|
69
102
|
* @returns {string}
|
|
70
103
|
*/
|
|
71
|
-
function render_json(input, theme, width) {
|
|
104
|
+
function render_json(input, theme, width, transparent) {
|
|
72
105
|
let deferred4_0;
|
|
73
106
|
let deferred4_1;
|
|
74
107
|
try {
|
|
@@ -76,7 +109,7 @@ function render_json(input, theme, width) {
|
|
|
76
109
|
const len0 = WASM_VECTOR_LEN;
|
|
77
110
|
const ptr1 = passStringToWasm0(theme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
78
111
|
const len1 = WASM_VECTOR_LEN;
|
|
79
|
-
const ret = wasm.render_json(ptr0, len0, ptr1, len1, isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0);
|
|
112
|
+
const ret = wasm.render_json(ptr0, len0, ptr1, len1, isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0, isLikeNone(transparent) ? 0xFFFFFF : transparent ? 1 : 0);
|
|
80
113
|
var ptr3 = ret[0];
|
|
81
114
|
var len3 = ret[1];
|
|
82
115
|
if (ret[3]) {
|
|
@@ -103,9 +136,10 @@ exports.render_json = render_json;
|
|
|
103
136
|
* @param {string} input
|
|
104
137
|
* @param {string} theme_toml
|
|
105
138
|
* @param {number | null} [width]
|
|
139
|
+
* @param {boolean | null} [transparent]
|
|
106
140
|
* @returns {string}
|
|
107
141
|
*/
|
|
108
|
-
function render_with_theme_toml(input, theme_toml, width) {
|
|
142
|
+
function render_with_theme_toml(input, theme_toml, width, transparent) {
|
|
109
143
|
let deferred4_0;
|
|
110
144
|
let deferred4_1;
|
|
111
145
|
try {
|
|
@@ -113,7 +147,7 @@ function render_with_theme_toml(input, theme_toml, width) {
|
|
|
113
147
|
const len0 = WASM_VECTOR_LEN;
|
|
114
148
|
const ptr1 = passStringToWasm0(theme_toml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
115
149
|
const len1 = WASM_VECTOR_LEN;
|
|
116
|
-
const ret = wasm.render_with_theme_toml(ptr0, len0, ptr1, len1, isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0);
|
|
150
|
+
const ret = wasm.render_with_theme_toml(ptr0, len0, ptr1, len1, isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0, isLikeNone(transparent) ? 0xFFFFFF : transparent ? 1 : 0);
|
|
117
151
|
var ptr3 = ret[0];
|
|
118
152
|
var len3 = ret[1];
|
|
119
153
|
if (ret[3]) {
|
|
Binary file
|