@iyulab/declart 0.15.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.
Files changed (4) hide show
  1. package/index.d.ts +46 -0
  2. package/index.js +63 -0
  3. package/index.mjs +12 -0
  4. package/package.json +32 -0
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,63 @@
1
+ 'use strict';
2
+
3
+ const wasm = require('./wasm/declart_wasm');
4
+
5
+ /**
6
+ * Renders a TOML or JSON diagram declaration to SVG.
7
+ * @param {string} input - TOML or JSON declaration string (auto-detected)
8
+ * @param {string} [theme='default'] - Theme name: 'default', 'monochrome', 'accessible', 'warm'
9
+ * @param {number} [width] - Optional canvas width in pixels
10
+ * @returns {string} SVG string
11
+ */
12
+ function render(input, theme = 'default', width) {
13
+ return wasm.render(input, theme, width ?? null);
14
+ }
15
+
16
+ /**
17
+ * Renders a JSON diagram declaration to SVG.
18
+ * @param {string} input - JSON declaration string
19
+ * @param {string} [theme='default'] - Theme name
20
+ * @param {number} [width] - Optional canvas width in pixels
21
+ * @returns {string} SVG string
22
+ */
23
+ function renderJson(input, theme = 'default', width) {
24
+ return wasm.render_json(input, theme, width ?? null);
25
+ }
26
+
27
+ /**
28
+ * Renders a TOML or JSON diagram declaration with a custom theme TOML.
29
+ * @param {string} input - TOML or JSON declaration string
30
+ * @param {string} themeToml - TOML theme definition string
31
+ * @param {number} [width] - Optional canvas width in pixels
32
+ * @returns {string} SVG string
33
+ */
34
+ function renderWithThemeToml(input, themeToml, width) {
35
+ return wasm.render_with_theme_toml(input, themeToml, width ?? null);
36
+ }
37
+
38
+ /**
39
+ * Validates a TOML or JSON diagram declaration without rendering.
40
+ * @param {string} input - TOML or JSON declaration string
41
+ * @throws {Error} If the declaration is invalid
42
+ */
43
+ function validate(input) {
44
+ return wasm.validate(input);
45
+ }
46
+
47
+ /**
48
+ * Returns the list of supported theme names.
49
+ * @returns {string[]}
50
+ */
51
+ function themes() {
52
+ return wasm.themes().split(',');
53
+ }
54
+
55
+ /**
56
+ * Returns the list of supported diagram kind names.
57
+ * @returns {string[]}
58
+ */
59
+ function kinds() {
60
+ return wasm.kinds().split(',');
61
+ }
62
+
63
+ module.exports = { render, renderJson, renderWithThemeToml, validate, themes, kinds };
package/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ // ESM entry point — wraps the CJS module with named exports
2
+ import { createRequire } from 'module';
3
+
4
+ const require = createRequire(import.meta.url);
5
+ const declart = require('./index.js');
6
+
7
+ export const render = declart.render;
8
+ export const renderJson = declart.renderJson;
9
+ export const renderWithThemeToml = declart.renderWithThemeToml;
10
+ export const validate = declart.validate;
11
+ export const themes = declart.themes;
12
+ export const kinds = declart.kinds;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@iyulab/declart",
3
+ "version": "0.15.0",
4
+ "description": "Declarative diagram engine — declare what to show, the engine renders SVG",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/iyulab/declart"
9
+ },
10
+ "main": "index.js",
11
+ "types": "index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./index.mjs",
15
+ "require": "./index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "index.mjs",
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 nodejs --out-dir ../../packages/declart-node/wasm"
28
+ },
29
+ "engines": {
30
+ "node": ">=16"
31
+ }
32
+ }