@iyulab/declart 0.15.0 → 0.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyulab/declart",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Declarative diagram engine — declare what to show, the engine renders SVG",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,52 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Returns a comma-separated list of supported diagram kind names.
6
+ */
7
+ export function kinds(): string;
8
+
9
+ /**
10
+ * Renders a TOML or JSON diagram declaration to SVG.
11
+ *
12
+ * - `input`: TOML or JSON declaration string (auto-detected by leading `{`)
13
+ * - `theme`: `"default"`, `"monochrome"`, `"accessible"`, or `"warm"` (unknown values fall back to `"default"`)
14
+ * - `width`: optional canvas width in pixels (height scales proportionally)
15
+ *
16
+ * Returns the SVG string on success, or a `JsError` with a descriptive message on failure.
17
+ */
18
+ export function render(input: string, theme: string, width?: number | null): string;
19
+
20
+ /**
21
+ * Renders a JSON diagram declaration to SVG with a named theme.
22
+ *
23
+ * - `input`: JSON declaration string
24
+ * - `theme`: `"default"`, `"monochrome"`, `"accessible"`, or `"warm"`
25
+ * - `width`: optional canvas width in pixels
26
+ *
27
+ * Returns the SVG string on success, or a `JsError` on failure.
28
+ */
29
+ export function render_json(input: string, theme: string, width?: number | null): string;
30
+
31
+ /**
32
+ * Renders a TOML or JSON diagram declaration with a custom theme defined as a TOML string.
33
+ *
34
+ * - `input`: TOML or JSON declaration string (auto-detected)
35
+ * - `theme_toml`: TOML theme string (see [`Theme::from_toml`])
36
+ * - `width`: optional canvas width in pixels
37
+ *
38
+ * Returns the SVG string on success, or a `JsError` on parse/validation failure.
39
+ */
40
+ export function render_with_theme_toml(input: string, theme_toml: string, width?: number | null): string;
41
+
42
+ /**
43
+ * Returns a comma-separated list of supported theme names.
44
+ */
45
+ export function themes(): string;
46
+
47
+ /**
48
+ * Validates a TOML or JSON diagram declaration without rendering.
49
+ *
50
+ * Returns `Ok(())` if valid, or a `JsError` with the parse/validation error message.
51
+ */
52
+ export function validate(input: string): void;
@@ -0,0 +1,273 @@
1
+ /* @ts-self-types="./declart_wasm.d.ts" */
2
+
3
+ /**
4
+ * Returns a comma-separated list of supported diagram kind names.
5
+ * @returns {string}
6
+ */
7
+ function kinds() {
8
+ let deferred1_0;
9
+ let deferred1_1;
10
+ try {
11
+ const ret = wasm.kinds();
12
+ deferred1_0 = ret[0];
13
+ deferred1_1 = ret[1];
14
+ return getStringFromWasm0(ret[0], ret[1]);
15
+ } finally {
16
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
17
+ }
18
+ }
19
+ exports.kinds = kinds;
20
+
21
+ /**
22
+ * Renders a TOML or JSON diagram declaration to SVG.
23
+ *
24
+ * - `input`: TOML or JSON declaration string (auto-detected by leading `{`)
25
+ * - `theme`: `"default"`, `"monochrome"`, `"accessible"`, or `"warm"` (unknown values fall back to `"default"`)
26
+ * - `width`: optional canvas width in pixels (height scales proportionally)
27
+ *
28
+ * Returns the SVG string on success, or a `JsError` with a descriptive message on failure.
29
+ * @param {string} input
30
+ * @param {string} theme
31
+ * @param {number | null} [width]
32
+ * @returns {string}
33
+ */
34
+ function render(input, theme, width) {
35
+ let deferred4_0;
36
+ let deferred4_1;
37
+ try {
38
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
39
+ const len0 = WASM_VECTOR_LEN;
40
+ const ptr1 = passStringToWasm0(theme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ const len1 = WASM_VECTOR_LEN;
42
+ const ret = wasm.render(ptr0, len0, ptr1, len1, isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0);
43
+ var ptr3 = ret[0];
44
+ var len3 = ret[1];
45
+ if (ret[3]) {
46
+ ptr3 = 0; len3 = 0;
47
+ throw takeFromExternrefTable0(ret[2]);
48
+ }
49
+ deferred4_0 = ptr3;
50
+ deferred4_1 = len3;
51
+ return getStringFromWasm0(ptr3, len3);
52
+ } finally {
53
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
54
+ }
55
+ }
56
+ exports.render = render;
57
+
58
+ /**
59
+ * Renders a JSON diagram declaration to SVG with a named theme.
60
+ *
61
+ * - `input`: JSON declaration string
62
+ * - `theme`: `"default"`, `"monochrome"`, `"accessible"`, or `"warm"`
63
+ * - `width`: optional canvas width in pixels
64
+ *
65
+ * Returns the SVG string on success, or a `JsError` on failure.
66
+ * @param {string} input
67
+ * @param {string} theme
68
+ * @param {number | null} [width]
69
+ * @returns {string}
70
+ */
71
+ function render_json(input, theme, width) {
72
+ let deferred4_0;
73
+ let deferred4_1;
74
+ try {
75
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
76
+ const len0 = WASM_VECTOR_LEN;
77
+ const ptr1 = passStringToWasm0(theme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
78
+ const len1 = WASM_VECTOR_LEN;
79
+ const ret = wasm.render_json(ptr0, len0, ptr1, len1, isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0);
80
+ var ptr3 = ret[0];
81
+ var len3 = ret[1];
82
+ if (ret[3]) {
83
+ ptr3 = 0; len3 = 0;
84
+ throw takeFromExternrefTable0(ret[2]);
85
+ }
86
+ deferred4_0 = ptr3;
87
+ deferred4_1 = len3;
88
+ return getStringFromWasm0(ptr3, len3);
89
+ } finally {
90
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
91
+ }
92
+ }
93
+ exports.render_json = render_json;
94
+
95
+ /**
96
+ * Renders a TOML or JSON diagram declaration with a custom theme defined as a TOML string.
97
+ *
98
+ * - `input`: TOML or JSON declaration string (auto-detected)
99
+ * - `theme_toml`: TOML theme string (see [`Theme::from_toml`])
100
+ * - `width`: optional canvas width in pixels
101
+ *
102
+ * Returns the SVG string on success, or a `JsError` on parse/validation failure.
103
+ * @param {string} input
104
+ * @param {string} theme_toml
105
+ * @param {number | null} [width]
106
+ * @returns {string}
107
+ */
108
+ function render_with_theme_toml(input, theme_toml, width) {
109
+ let deferred4_0;
110
+ let deferred4_1;
111
+ try {
112
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
+ const len0 = WASM_VECTOR_LEN;
114
+ const ptr1 = passStringToWasm0(theme_toml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
115
+ 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);
117
+ var ptr3 = ret[0];
118
+ var len3 = ret[1];
119
+ if (ret[3]) {
120
+ ptr3 = 0; len3 = 0;
121
+ throw takeFromExternrefTable0(ret[2]);
122
+ }
123
+ deferred4_0 = ptr3;
124
+ deferred4_1 = len3;
125
+ return getStringFromWasm0(ptr3, len3);
126
+ } finally {
127
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
128
+ }
129
+ }
130
+ exports.render_with_theme_toml = render_with_theme_toml;
131
+
132
+ /**
133
+ * Returns a comma-separated list of supported theme names.
134
+ * @returns {string}
135
+ */
136
+ function themes() {
137
+ let deferred1_0;
138
+ let deferred1_1;
139
+ try {
140
+ const ret = wasm.themes();
141
+ deferred1_0 = ret[0];
142
+ deferred1_1 = ret[1];
143
+ return getStringFromWasm0(ret[0], ret[1]);
144
+ } finally {
145
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
146
+ }
147
+ }
148
+ exports.themes = themes;
149
+
150
+ /**
151
+ * Validates a TOML or JSON diagram declaration without rendering.
152
+ *
153
+ * Returns `Ok(())` if valid, or a `JsError` with the parse/validation error message.
154
+ * @param {string} input
155
+ */
156
+ function validate(input) {
157
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
158
+ const len0 = WASM_VECTOR_LEN;
159
+ const ret = wasm.validate(ptr0, len0);
160
+ if (ret[1]) {
161
+ throw takeFromExternrefTable0(ret[0]);
162
+ }
163
+ }
164
+ exports.validate = validate;
165
+ function __wbg_get_imports() {
166
+ const import0 = {
167
+ __proto__: null,
168
+ __wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
169
+ const ret = Error(getStringFromWasm0(arg0, arg1));
170
+ return ret;
171
+ },
172
+ __wbindgen_init_externref_table: function() {
173
+ const table = wasm.__wbindgen_externrefs;
174
+ const offset = table.grow(4);
175
+ table.set(0, undefined);
176
+ table.set(offset + 0, undefined);
177
+ table.set(offset + 1, null);
178
+ table.set(offset + 2, true);
179
+ table.set(offset + 3, false);
180
+ },
181
+ };
182
+ return {
183
+ __proto__: null,
184
+ "./declart_wasm_bg.js": import0,
185
+ };
186
+ }
187
+
188
+ function getStringFromWasm0(ptr, len) {
189
+ return decodeText(ptr >>> 0, len);
190
+ }
191
+
192
+ let cachedUint8ArrayMemory0 = null;
193
+ function getUint8ArrayMemory0() {
194
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
195
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
196
+ }
197
+ return cachedUint8ArrayMemory0;
198
+ }
199
+
200
+ function isLikeNone(x) {
201
+ return x === undefined || x === null;
202
+ }
203
+
204
+ function passStringToWasm0(arg, malloc, realloc) {
205
+ if (realloc === undefined) {
206
+ const buf = cachedTextEncoder.encode(arg);
207
+ const ptr = malloc(buf.length, 1) >>> 0;
208
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
209
+ WASM_VECTOR_LEN = buf.length;
210
+ return ptr;
211
+ }
212
+
213
+ let len = arg.length;
214
+ let ptr = malloc(len, 1) >>> 0;
215
+
216
+ const mem = getUint8ArrayMemory0();
217
+
218
+ let offset = 0;
219
+
220
+ for (; offset < len; offset++) {
221
+ const code = arg.charCodeAt(offset);
222
+ if (code > 0x7F) break;
223
+ mem[ptr + offset] = code;
224
+ }
225
+ if (offset !== len) {
226
+ if (offset !== 0) {
227
+ arg = arg.slice(offset);
228
+ }
229
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
230
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
231
+ const ret = cachedTextEncoder.encodeInto(arg, view);
232
+
233
+ offset += ret.written;
234
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
235
+ }
236
+
237
+ WASM_VECTOR_LEN = offset;
238
+ return ptr;
239
+ }
240
+
241
+ function takeFromExternrefTable0(idx) {
242
+ const value = wasm.__wbindgen_externrefs.get(idx);
243
+ wasm.__externref_table_dealloc(idx);
244
+ return value;
245
+ }
246
+
247
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
248
+ cachedTextDecoder.decode();
249
+ function decodeText(ptr, len) {
250
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
251
+ }
252
+
253
+ const cachedTextEncoder = new TextEncoder();
254
+
255
+ if (!('encodeInto' in cachedTextEncoder)) {
256
+ cachedTextEncoder.encodeInto = function (arg, view) {
257
+ const buf = cachedTextEncoder.encode(arg);
258
+ view.set(buf);
259
+ return {
260
+ read: arg.length,
261
+ written: buf.length
262
+ };
263
+ };
264
+ }
265
+
266
+ let WASM_VECTOR_LEN = 0;
267
+
268
+ const wasmPath = `${__dirname}/declart_wasm_bg.wasm`;
269
+ const wasmBytes = require('fs').readFileSync(wasmPath);
270
+ const wasmModule = new WebAssembly.Module(wasmBytes);
271
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
272
+ let wasm = wasmInstance.exports;
273
+ wasm.__wbindgen_start();
Binary file