@validationcloud/fractal-ui 1.79.0 → 1.80.1

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/bin/fractal-ui ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import('../dist/cli.js');
@@ -0,0 +1,8 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const renderChartCommand: Command<[], {
3
+ input?: string | undefined;
4
+ output: string;
5
+ width: string;
6
+ height: string;
7
+ dpr: string;
8
+ }, {}>;
@@ -0,0 +1,59 @@
1
+ import { Command as o } from "@commander-js/extra-typings";
2
+ import { writeFile as a, rename as n, rm as p } from "node:fs/promises";
3
+ import { join as s, dirname as c } from "node:path";
4
+ import { isPlainObject as d } from "../lib/is-plain-object.js";
5
+ import { renderMavrikChartToImage as h } from "../lib/render-mavrik-chart-to-image.js";
6
+ import { resolveJson as u } from "../lib/resolve-json.js";
7
+ async function m() {
8
+ const t = [];
9
+ for await (const r of process.stdin)
10
+ t.push(Buffer.from(r));
11
+ return Buffer.concat(t).toString("utf8");
12
+ }
13
+ async function f(t) {
14
+ if (t !== void 0)
15
+ return u(t);
16
+ if (process.stdin.isTTY)
17
+ throw new Error(
18
+ `No input provided. Use -i <json> or pipe JSON to stdin.
19
+ Example: echo '{"xAxis":...}' | fractal-ui render-chart -o out.png`
20
+ );
21
+ const r = await m(), e = JSON.parse(r);
22
+ if (!d(e))
23
+ throw new TypeError("stdin must contain a JSON object");
24
+ return e;
25
+ }
26
+ async function l(t, r) {
27
+ if (t === "-") {
28
+ process.stdout.write(r);
29
+ return;
30
+ }
31
+ const e = s(c(t), `.fractal-ui-${String(process.pid)}-${String(Date.now())}.tmp`);
32
+ await a(e, r);
33
+ try {
34
+ await n(e, t);
35
+ } catch (i) {
36
+ throw await p(e, { force: !0 }), i;
37
+ }
38
+ }
39
+ const v = new o("render-chart").description("Render an ECharts JSON option to a PNG image using the Mavrik theme").option("-i, --input <json>", "ECharts option as JSON string or path to JSON file (reads stdin if omitted)").requiredOption("-o, --output <path>", 'Path to output PNG file, or "-" for stdout').option("-W, --width <pixels>", "Chart width in pixels", "800").option("-H, --height <pixels>", "Chart height in pixels", "600").option("-d, --dpr <ratio>", "Device pixel ratio", "2").addHelpText(
40
+ "after",
41
+ `
42
+ Examples:
43
+ # Render a chart from a JSON file
44
+ npx -y @validationcloud/fractal-ui render-chart -i chart.json -o chart.png
45
+
46
+ # Pipe JSON from another tool
47
+ curl -s https://api.example.com/chart | npx -y @validationcloud/fractal-ui render-chart -o chart.png`
48
+ ).action(async (t) => {
49
+ const r = await f(t.input), e = h({
50
+ option: r,
51
+ width: Number.parseInt(t.width, 10),
52
+ height: Number.parseInt(t.height, 10),
53
+ devicePixelRatio: Number.parseInt(t.dpr, 10)
54
+ });
55
+ await l(t.output, e);
56
+ });
57
+ export {
58
+ v as renderChartCommand
59
+ };
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,6 @@
1
+ import { renderChartCommand as e } from "./cli/render-chart-command.js";
2
+ import { Command as a } from "@commander-js/extra-typings";
3
+ import { createRequire as n } from "node:module";
4
+ const i = n(import.meta.url), r = i("../package.json"), o = new a().name(r.name).version(r.version).description(r.description).showHelpAfterError("(add --help for additional information)").showSuggestionAfterError();
5
+ o.addCommand(e);
6
+ await o.parseAsync();
@@ -0,0 +1 @@
1
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,6 @@
1
+ function t(r) {
2
+ return typeof r == "object" && r !== null && !Array.isArray(r);
3
+ }
4
+ export {
5
+ t as isPlainObject
6
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Attempts to parse a JSON string that may be escaped.
3
+ *
4
+ * Handles three patterns:
5
+ * 1. Regular JSON: `{"name": "John"}` → parsed object
6
+ * 2. Quoted JSON string: `"{\"name\": \"John\"}"` → parsed object
7
+ * 3. Backslash-escaped: `{\"name\": \"John\"}` → parsed object
8
+ */
9
+ export declare function parseJsonWithUnescape(content: string): unknown;
@@ -0,0 +1,18 @@
1
+ function a(e) {
2
+ try {
3
+ const r = JSON.parse(e);
4
+ if (typeof r == "string")
5
+ try {
6
+ return JSON.parse(r);
7
+ } catch {
8
+ return r;
9
+ }
10
+ return r;
11
+ } catch {
12
+ }
13
+ const t = e.replaceAll(String.raw`\"`, '"').replaceAll("\\\\", "\\");
14
+ return JSON.parse(t);
15
+ }
16
+ export {
17
+ a as parseJsonWithUnescape
18
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Resolves input as either inline JSON object or file path to JSON object.
3
+ *
4
+ * Resolution order:
5
+ * 1. Parse input with {@link parseJsonWithUnescape}
6
+ * 2. If result is a plain object → return it (inline JSON)
7
+ * 3. If result is an array → throw (not supported)
8
+ * 4. If result is a string → treat as file path, read & parse as strict JSON
9
+ * 5. If initial parse fails → treat input as file path
10
+ *
11
+ * @throws If input is an array, file doesn't exist, or file doesn't contain an object
12
+ */
13
+ export declare function resolveJson(input: string): Promise<Record<string, unknown>>;
@@ -0,0 +1,33 @@
1
+ import { readFile as c } from "node:fs/promises";
2
+ import { isPlainObject as a } from "./is-plain-object.js";
3
+ import { parseJsonWithUnescape as i } from "./parse-json-with-unescape.js";
4
+ async function n(e) {
5
+ let r;
6
+ try {
7
+ r = await c(e, "utf8");
8
+ } catch (o) {
9
+ throw o.code === "ENOENT" ? new Error(`File not found: ${e}`) : o;
10
+ }
11
+ const t = JSON.parse(r);
12
+ if (!a(t))
13
+ throw new Error(`File must contain a JSON object: ${e}`);
14
+ return t;
15
+ }
16
+ async function y(e) {
17
+ let r;
18
+ try {
19
+ r = i(e);
20
+ } catch {
21
+ return n(e);
22
+ }
23
+ if (a(r))
24
+ return r;
25
+ if (Array.isArray(r))
26
+ throw new TypeError("JSON arrays are not supported, expected an object");
27
+ if (typeof r == "string")
28
+ return n(r);
29
+ throw new TypeError(`Expected JSON object or file path, got ${typeof r}: ${String(r)}`);
30
+ }
31
+ export {
32
+ y as resolveJson
33
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@validationcloud/fractal-ui",
3
+ "description": "Validation Cloud's shared React component library with design tokens, Tailwind CSS utilities, and CLI tools",
3
4
  "private": false,
4
- "version": "1.79.0",
5
+ "version": "1.80.1",
5
6
  "module": "./dist/index.js",
6
7
  "type": "module",
8
+ "bin": {
9
+ "fractal-ui": "bin/fractal-ui"
10
+ },
7
11
  "files": [
12
+ "bin",
8
13
  "dist",
9
14
  "dist/fonts"
10
15
  ],
@@ -58,6 +63,8 @@
58
63
  "node": ">=22.14.0"
59
64
  },
60
65
  "dependencies": {
66
+ "@commander-js/extra-typings": "^14.0.0",
67
+ "commander": "^14.0.3",
61
68
  "radix-ui": "^1.4.3",
62
69
  "react": "^19.2.3",
63
70
  "react-dom": "^19.2.3",
@@ -65,6 +72,10 @@
65
72
  "tailwind-merge": "^3.4.0",
66
73
  "zod": "^4.3.5"
67
74
  },
75
+ "optionalDependencies": {
76
+ "echarts": "^6.0.0",
77
+ "skia-canvas": "^3.0.8"
78
+ },
68
79
  "devDependencies": {
69
80
  "@eslint/compat": "^2.0.1",
70
81
  "@eslint/js": "^9.39.2",
@@ -103,7 +114,6 @@
103
114
  "rollup-preserve-directives": "^1.1.3",
104
115
  "semantic-release": "^25.0.2",
105
116
  "shapefile": "^0.6.6",
106
- "skia-canvas": "^3.0.8",
107
117
  "storybook": "^10.1.11",
108
118
  "tailwindcss": "^4.1.18",
109
119
  "topojson-client": "^3.1.0",