@iyulab/declart-web 0.18.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 ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Renders a TOML or JSON diagram declaration to SVG.
3
+ * @param input - TOML or JSON declaration string (format auto-detected)
4
+ * @param theme - Theme name: 'default', 'monochrome', 'accessible', 'warm' (defaults to 'default')
5
+ * @param width - Optional canvas width in pixels (height scales proportionally)
6
+ * @returns SVG string
7
+ * @throws If the declaration is invalid
8
+ */
9
+ export function render(input: string, theme?: string, width?: number): string;
10
+
11
+ /**
12
+ * Renders a JSON diagram declaration to SVG.
13
+ * @param input - JSON declaration string
14
+ * @param theme - Theme name (defaults to 'default')
15
+ * @param width - Optional canvas width in pixels
16
+ * @returns SVG string
17
+ * @throws If the JSON declaration is invalid
18
+ */
19
+ export function renderJson(input: string, theme?: string, width?: number): string;
20
+
21
+ /**
22
+ * Renders a TOML or JSON diagram declaration with a custom theme TOML.
23
+ * @param input - TOML or JSON declaration string
24
+ * @param themeToml - TOML theme definition string
25
+ * @param width - Optional canvas width in pixels
26
+ * @returns SVG string
27
+ * @throws If the declaration or theme is invalid
28
+ */
29
+ export function renderWithThemeToml(input: string, themeToml: string, width?: number): string;
30
+
31
+ /**
32
+ * Validates a TOML or JSON diagram declaration without rendering.
33
+ * @param input - TOML or JSON declaration string
34
+ * @throws If the declaration is invalid
35
+ */
36
+ export function validate(input: string): void;
37
+
38
+ /**
39
+ * Returns the list of supported theme names.
40
+ */
41
+ export function themes(): string[];
42
+
43
+ /**
44
+ * Returns the list of supported diagram kind names.
45
+ */
46
+ export function kinds(): string[];
package/index.js ADDED
@@ -0,0 +1,30 @@
1
+ import {
2
+ render as wasmRender,
3
+ render_json,
4
+ render_with_theme_toml,
5
+ validate,
6
+ themes as wasmThemes,
7
+ kinds as wasmKinds,
8
+ } from './wasm/declart_wasm.js';
9
+
10
+ export { validate };
11
+
12
+ export function render(input, theme = 'default', width) {
13
+ return wasmRender(input, theme, width ?? undefined);
14
+ }
15
+
16
+ export function renderJson(input, theme = 'default', width) {
17
+ return render_json(input, theme, width ?? undefined);
18
+ }
19
+
20
+ export function renderWithThemeToml(input, themeToml, width) {
21
+ return render_with_theme_toml(input, themeToml, width ?? undefined);
22
+ }
23
+
24
+ export function themes() {
25
+ return wasmThemes().split(',');
26
+ }
27
+
28
+ export function kinds() {
29
+ return wasmKinds().split(',');
30
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@iyulab/declart-web",
3
+ "version": "0.18.0",
4
+ "description": "Declarative diagram engine for browsers and bundlers (Vite, webpack, Rollup) — declare what to show, the engine renders SVG",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/iyulab/declart"
10
+ },
11
+ "main": "index.js",
12
+ "types": "index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./index.d.ts",
16
+ "import": "./index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts",
22
+ "wasm/declart_wasm.js",
23
+ "wasm/declart_wasm.d.ts",
24
+ "wasm/declart_wasm_bg.wasm"
25
+ ],
26
+ "scripts": {
27
+ "build": "wasm-pack build ../../crates/declart-wasm --target bundler --out-dir ../../packages/declart-web/wasm"
28
+ },
29
+ "engines": {
30
+ "node": ">=18"
31
+ },
32
+ "keywords": ["diagram", "svg", "wasm", "browser", "vite", "declart"]
33
+ }
@@ -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,9 @@
1
+ /* @ts-self-types="./declart_wasm.d.ts" */
2
+ import * as wasm from "./declart_wasm_bg.wasm";
3
+ import { __wbg_set_wasm } from "./declart_wasm_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ kinds, render, render_json, render_with_theme_toml, themes, validate
9
+ } from "./declart_wasm_bg.js";
Binary file