infographic-for-react 0.2.0 → 0.3.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/README.md +87 -4
- package/README.zh-CN.md +114 -4
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +69 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,9 +27,92 @@ npm install infographic-for-react @antv/infographic
|
|
|
27
27
|
|
|
28
28
|
## Quick Start
|
|
29
29
|
|
|
30
|
-
###
|
|
30
|
+
### String DSL (Recommended for Static Templates)
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Use the native infographic string DSL syntax for a concise, template-based approach.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Infographic } from 'infographic-for-react';
|
|
36
|
+
|
|
37
|
+
function App() {
|
|
38
|
+
const dslString = `
|
|
39
|
+
infographic sales-dashboard
|
|
40
|
+
theme
|
|
41
|
+
palette #f00 #0f0 #00f
|
|
42
|
+
data
|
|
43
|
+
title Q1 Growth Highlights
|
|
44
|
+
items
|
|
45
|
+
- label MAU
|
|
46
|
+
value 12.3
|
|
47
|
+
- label Revenue
|
|
48
|
+
value 4.5
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Infographic
|
|
53
|
+
dsl={dslString}
|
|
54
|
+
width={600}
|
|
55
|
+
height={400}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
> **Note**: When using string DSL, the `overrides` and `beforeRender` props are ignored. Use object DSL if you need these features.
|
|
62
|
+
|
|
63
|
+
### Children DSL (Recommended for Most Use Cases)
|
|
64
|
+
|
|
65
|
+
For a more declarative and React-like syntax, pass DSL as the component's children. This is particularly useful for static templates and provides better readability with preserved formatting.
|
|
66
|
+
|
|
67
|
+
> **⚠️ Important**: When using children DSL, you **must** wrap DSL content in a template literal `{}` to preserve newlines and indentation. This prevents React from collapsing whitespace.
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { Infographic } from 'infographic-for-react';
|
|
71
|
+
|
|
72
|
+
function App() {
|
|
73
|
+
return (
|
|
74
|
+
<Infographic width={600} height={400}>
|
|
75
|
+
{`infographic list-row-simple-horizontal-arrow
|
|
76
|
+
data
|
|
77
|
+
items
|
|
78
|
+
- label Step 1
|
|
79
|
+
desc Start
|
|
80
|
+
- label Step 2
|
|
81
|
+
desc In Progress
|
|
82
|
+
- label Step 3
|
|
83
|
+
desc Complete
|
|
84
|
+
`}
|
|
85
|
+
</Infographic>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
// You can also use template literals for dynamic content with variable interpolation
|
|
92
|
+
function App() {
|
|
93
|
+
const title = 'My Dashboard';
|
|
94
|
+
const items = [
|
|
95
|
+
{ label: 'MAU', value: 12.3 },
|
|
96
|
+
{ label: 'Revenue', value: 4.5 },
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Infographic>
|
|
101
|
+
{`infographic sales-dashboard
|
|
102
|
+
data
|
|
103
|
+
title ${title}
|
|
104
|
+
items
|
|
105
|
+
${items.map((item) => ` - label ${item.label}\n value ${item.value}`).join('\n')}`}
|
|
106
|
+
</Infographic>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> **Note**: When using children DSL, the `overrides` and `beforeRender` props are ignored. Use object DSL if you need these features. The `dsl` prop is also ignored when children are provided (children take precedence).
|
|
112
|
+
|
|
113
|
+
### Basic Usage (Object DSL)
|
|
114
|
+
|
|
115
|
+
Use object DSL for full TypeScript type safety and access to advanced features like `overrides` and `beforeRender` hooks.
|
|
33
116
|
|
|
34
117
|
```tsx
|
|
35
118
|
import { Infographic } from 'infographic-for-react';
|
|
@@ -69,7 +152,7 @@ function App() {
|
|
|
69
152
|
|
|
70
153
|
### DSL Overrides
|
|
71
154
|
|
|
72
|
-
Use the `overrides` prop to selectively modify DSL values by path without recreating
|
|
155
|
+
Use the `overrides` prop to selectively modify DSL values by path without recreating entire DSL object. This is useful for dynamic updates or theming. **Only works with object DSL**.
|
|
73
156
|
|
|
74
157
|
```tsx
|
|
75
158
|
import { Infographic } from 'infographic-for-react';
|
|
@@ -152,7 +235,7 @@ function App() {
|
|
|
152
235
|
|
|
153
236
|
### Pre/Post Render Hooks
|
|
154
237
|
|
|
155
|
-
Use `beforeRender` to preprocess
|
|
238
|
+
Use `beforeRender` to preprocess DSL before rendering, and `afterRender` to perform actions after infographic is rendered (e.g., logging, analytics, custom post-processing). **Only works with object DSL**.
|
|
156
239
|
|
|
157
240
|
```tsx
|
|
158
241
|
import { Infographic } from 'infographic-for-react';
|
package/README.zh-CN.md
CHANGED
|
@@ -27,9 +27,92 @@ npm install infographic-for-react @antv/infographic
|
|
|
27
27
|
|
|
28
28
|
## 快速开始
|
|
29
29
|
|
|
30
|
-
###
|
|
30
|
+
### 字符串 DSL
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
使用原生信息图表的字符串 DSL 语法,这种方式更简洁,适合基于模板的配置。
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Infographic } from 'infographic-for-react';
|
|
36
|
+
|
|
37
|
+
function App() {
|
|
38
|
+
const dslString = `
|
|
39
|
+
infographic 销售仪表盘
|
|
40
|
+
theme
|
|
41
|
+
palette #f00 #0f0 #00f
|
|
42
|
+
data
|
|
43
|
+
title 第一季度增长亮点
|
|
44
|
+
items
|
|
45
|
+
- label 月活跃用户
|
|
46
|
+
value 12.3
|
|
47
|
+
- label 营收
|
|
48
|
+
value 4.5
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Infographic
|
|
53
|
+
dsl={dslString}
|
|
54
|
+
width={600}
|
|
55
|
+
height={400}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
> **注意**:使用字符串 DSL 时,`overrides` 和 `beforeRender` 属性会被忽略。如需使用这些功能,请使用对象 DSL。
|
|
62
|
+
|
|
63
|
+
### Children DSL(推荐大多数场景)
|
|
64
|
+
|
|
65
|
+
为了获得更符合 React 风格的语法,你可以将 DSL 作为组件的 children 传递。这种方式特别适合静态模板,并且能更好地保留格式和缩进。
|
|
66
|
+
|
|
67
|
+
> **⚠️ 重要提示**:使用 children DSL 时,**必须**使用模板字符串 `{}` 包裹 DSL 内容,以保留换行和缩进。这样可以防止 React 合并空白字符。
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { Infographic } from 'infographic-for-react';
|
|
71
|
+
|
|
72
|
+
function App() {
|
|
73
|
+
return (
|
|
74
|
+
<Infographic width={600} height={400}>
|
|
75
|
+
{`infographic list-row-simple-horizontal-arrow
|
|
76
|
+
data
|
|
77
|
+
items
|
|
78
|
+
- label 步骤 1
|
|
79
|
+
desc 开始
|
|
80
|
+
- label 步骤 2
|
|
81
|
+
desc 进行中
|
|
82
|
+
- label 步骤 3
|
|
83
|
+
desc 完成
|
|
84
|
+
`}
|
|
85
|
+
</Infographic>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
// 你也可以使用模板字符串来动态生成内容,支持变量插值
|
|
92
|
+
function App() {
|
|
93
|
+
const title = '我的仪表盘';
|
|
94
|
+
const items = [
|
|
95
|
+
{ label: '月活跃用户', value: 12.3 },
|
|
96
|
+
{ label: '营收', value: 4.5 },
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Infographic>
|
|
101
|
+
{`infographic 销售仪表盘
|
|
102
|
+
data
|
|
103
|
+
title ${title}
|
|
104
|
+
items
|
|
105
|
+
${items.map((item) => ` - label ${item.label}\n value ${item.value}`).join('\n')}`}
|
|
106
|
+
</Infographic>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> **注意**:使用 children DSL 时,`overrides` 和 `beforeRender` 属性会被忽略。如需使用这些功能,请使用对象 DSL。当提供 children 时,`dsl` 属性也会被忽略(children 优先级更高)。
|
|
112
|
+
|
|
113
|
+
### 基础用法(对象 DSL)
|
|
114
|
+
|
|
115
|
+
使用对象 DSL 获得完整的 TypeScript 类型支持和 `overrides`、`beforeRender` 钩子等高级功能。
|
|
33
116
|
|
|
34
117
|
```tsx
|
|
35
118
|
import { Infographic } from 'infographic-for-react';
|
|
@@ -69,7 +152,34 @@ function App() {
|
|
|
69
152
|
|
|
70
153
|
### DSL 覆盖
|
|
71
154
|
|
|
72
|
-
使用 `overrides` 属性可以通过路径选择性地修改 DSL 值,而无需重新创建整个 DSL
|
|
155
|
+
使用 `overrides` 属性可以通过路径选择性地修改 DSL 值,而无需重新创建整个 DSL 对象。这对于动态更新或主题切换非常有用。**仅适用于对象 DSL**。
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import { Infographic } from 'infographic-for-react';
|
|
159
|
+
|
|
160
|
+
function App() {
|
|
161
|
+
const overrides = [
|
|
162
|
+
{ path: 'data.items[0].value', value: 200 },
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<Infographic>
|
|
167
|
+
{`infographic 销售仪表盘
|
|
168
|
+
data
|
|
169
|
+
title ${title}
|
|
170
|
+
items
|
|
171
|
+
${items.map((item) => ` - label ${item.label}\n value ${item.value}`).join('\n')}`}
|
|
172
|
+
</Infographic>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
> **注意**:使用 children DSL 时,`overrides` 和 `beforeRender` 属性会被忽略。如需使用这些功能,请使用对象 DSL。当提供 children 时,`dsl` 属性也会被忽略(children 优先级更高)。
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
### DSL 覆盖
|
|
181
|
+
|
|
182
|
+
使用 `overrides` 属性可以通过路径选择性地修改 DSL 值,而无需重新创建整个 DSL 对象。这对于动态更新或主题切换非常有用。**仅适用于对象 DSL**。
|
|
73
183
|
|
|
74
184
|
```tsx
|
|
75
185
|
import { Infographic } from 'infographic-for-react';
|
|
@@ -152,7 +262,7 @@ function App() {
|
|
|
152
262
|
|
|
153
263
|
### 渲染前/后钩子
|
|
154
264
|
|
|
155
|
-
使用 `beforeRender` 在渲染前预处理 DSL,使用 `afterRender`
|
|
265
|
+
使用 `beforeRender` 在渲染前预处理 DSL,使用 `afterRender` 在信息图表渲染后执行操作(如日志记录、分析、自定义后处理)。**仅适用于对象 DSL**。
|
|
156
266
|
|
|
157
267
|
```tsx
|
|
158
268
|
import { Infographic } from 'infographic-for-react';
|
package/dist/index.d.mts
CHANGED
|
@@ -26,7 +26,7 @@ interface DSLObject extends Partial<InfographicOptions> {
|
|
|
26
26
|
palette?: Palette;
|
|
27
27
|
themeConfig?: ThemeConfig;
|
|
28
28
|
}
|
|
29
|
-
type DSLInput = DSLObject;
|
|
29
|
+
type DSLInput = string | DSLObject;
|
|
30
30
|
interface DSLOverride {
|
|
31
31
|
path: string;
|
|
32
32
|
value: unknown;
|
|
@@ -48,6 +48,7 @@ interface ComposeTemplateOptions {
|
|
|
48
48
|
overrides?: DSLOverride[];
|
|
49
49
|
}
|
|
50
50
|
interface InfographicProps {
|
|
51
|
+
children?: string;
|
|
51
52
|
dsl?: DSLInput;
|
|
52
53
|
overrides?: DSLOverride[];
|
|
53
54
|
theme?: string;
|
|
@@ -69,8 +70,8 @@ interface InfographicRef {
|
|
|
69
70
|
destroy: () => void;
|
|
70
71
|
}
|
|
71
72
|
interface RendererInstance {
|
|
72
|
-
render: (options?: Partial<InfographicOptions>) => void;
|
|
73
|
-
update: (options: Partial<InfographicOptions>) => void;
|
|
73
|
+
render: (options?: string | Partial<InfographicOptions>) => void;
|
|
74
|
+
update: (options: string | Partial<InfographicOptions>) => void;
|
|
74
75
|
toDataURL: (options?: ExportOptions) => Promise<string>;
|
|
75
76
|
getTypes: () => string | undefined;
|
|
76
77
|
destroy: () => void;
|
|
@@ -101,8 +102,8 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryS
|
|
|
101
102
|
declare function useInfographic(containerRef: React.RefObject<HTMLElement>, props: InfographicProps): InfographicRef;
|
|
102
103
|
|
|
103
104
|
declare function useRenderer(containerRef: React.RefObject<HTMLElement>): {
|
|
104
|
-
render: (options: Partial<InfographicOptions>) => Promise<void>;
|
|
105
|
-
update: (options: Partial<InfographicOptions>) => void;
|
|
105
|
+
render: (options: string | Partial<InfographicOptions>) => Promise<void>;
|
|
106
|
+
update: (options: string | Partial<InfographicOptions>) => void;
|
|
106
107
|
toDataURL: (options?: ExportOptions) => Promise<string>;
|
|
107
108
|
getTypes: () => string | undefined;
|
|
108
109
|
destroy: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ interface DSLObject extends Partial<InfographicOptions> {
|
|
|
26
26
|
palette?: Palette;
|
|
27
27
|
themeConfig?: ThemeConfig;
|
|
28
28
|
}
|
|
29
|
-
type DSLInput = DSLObject;
|
|
29
|
+
type DSLInput = string | DSLObject;
|
|
30
30
|
interface DSLOverride {
|
|
31
31
|
path: string;
|
|
32
32
|
value: unknown;
|
|
@@ -48,6 +48,7 @@ interface ComposeTemplateOptions {
|
|
|
48
48
|
overrides?: DSLOverride[];
|
|
49
49
|
}
|
|
50
50
|
interface InfographicProps {
|
|
51
|
+
children?: string;
|
|
51
52
|
dsl?: DSLInput;
|
|
52
53
|
overrides?: DSLOverride[];
|
|
53
54
|
theme?: string;
|
|
@@ -69,8 +70,8 @@ interface InfographicRef {
|
|
|
69
70
|
destroy: () => void;
|
|
70
71
|
}
|
|
71
72
|
interface RendererInstance {
|
|
72
|
-
render: (options?: Partial<InfographicOptions>) => void;
|
|
73
|
-
update: (options: Partial<InfographicOptions>) => void;
|
|
73
|
+
render: (options?: string | Partial<InfographicOptions>) => void;
|
|
74
|
+
update: (options: string | Partial<InfographicOptions>) => void;
|
|
74
75
|
toDataURL: (options?: ExportOptions) => Promise<string>;
|
|
75
76
|
getTypes: () => string | undefined;
|
|
76
77
|
destroy: () => void;
|
|
@@ -101,8 +102,8 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryS
|
|
|
101
102
|
declare function useInfographic(containerRef: React.RefObject<HTMLElement>, props: InfographicProps): InfographicRef;
|
|
102
103
|
|
|
103
104
|
declare function useRenderer(containerRef: React.RefObject<HTMLElement>): {
|
|
104
|
-
render: (options: Partial<InfographicOptions>) => Promise<void>;
|
|
105
|
-
update: (options: Partial<InfographicOptions>) => void;
|
|
105
|
+
render: (options: string | Partial<InfographicOptions>) => Promise<void>;
|
|
106
|
+
update: (options: string | Partial<InfographicOptions>) => void;
|
|
106
107
|
toDataURL: (options?: ExportOptions) => Promise<string>;
|
|
107
108
|
getTypes: () => string | undefined;
|
|
108
109
|
destroy: () => void;
|
package/dist/index.js
CHANGED
|
@@ -11,9 +11,14 @@ function useRenderer(containerRef) {
|
|
|
11
11
|
const pendingListenersRef = react.useRef(/* @__PURE__ */ new Map());
|
|
12
12
|
const attachedListenersRef = react.useRef(/* @__PURE__ */ new Map());
|
|
13
13
|
const createRenderer = react.useCallback(
|
|
14
|
-
async (options) => {
|
|
14
|
+
async (options, container) => {
|
|
15
15
|
const { Infographic: InfographicClass } = await import('@antv/infographic');
|
|
16
|
-
|
|
16
|
+
let renderer;
|
|
17
|
+
if (typeof options === "string") {
|
|
18
|
+
renderer = new InfographicClass(options);
|
|
19
|
+
} else {
|
|
20
|
+
renderer = new InfographicClass({ ...options, container });
|
|
21
|
+
}
|
|
17
22
|
renderer.on("rendered", () => {
|
|
18
23
|
rendererRef.current = renderer;
|
|
19
24
|
isInitializedRef.current = true;
|
|
@@ -27,7 +32,11 @@ function useRenderer(containerRef) {
|
|
|
27
32
|
renderer.on("error", (error) => {
|
|
28
33
|
console.error("[Infographic-for-React] Renderer error:", error);
|
|
29
34
|
});
|
|
30
|
-
|
|
35
|
+
if (typeof options === "string") {
|
|
36
|
+
renderer.render({ container });
|
|
37
|
+
} else {
|
|
38
|
+
renderer.render();
|
|
39
|
+
}
|
|
31
40
|
return renderer;
|
|
32
41
|
},
|
|
33
42
|
[]
|
|
@@ -38,11 +47,14 @@ function useRenderer(containerRef) {
|
|
|
38
47
|
if (!container) {
|
|
39
48
|
throw new Error("Container element not found");
|
|
40
49
|
}
|
|
41
|
-
const renderOptions = { ...options, container };
|
|
42
50
|
if (rendererRef.current) {
|
|
43
|
-
|
|
51
|
+
if (typeof options === "string") {
|
|
52
|
+
rendererRef.current.update(options);
|
|
53
|
+
} else {
|
|
54
|
+
rendererRef.current.update({ ...options, container });
|
|
55
|
+
}
|
|
44
56
|
} else {
|
|
45
|
-
await createRenderer(
|
|
57
|
+
await createRenderer(options, container);
|
|
46
58
|
}
|
|
47
59
|
},
|
|
48
60
|
[containerRef, createRenderer]
|
|
@@ -356,41 +368,52 @@ var RENDER_DEBOUNCE_DELAY = 100;
|
|
|
356
368
|
function useRenderController(containerRef, rendererRender, props, processDSL, onError) {
|
|
357
369
|
const propsRef = react.useRef(props);
|
|
358
370
|
const dslCacheRef = react.useRef(null);
|
|
371
|
+
const stringDslCacheRef = react.useRef(null);
|
|
359
372
|
propsRef.current = props;
|
|
360
373
|
const render = react.useCallback(async () => {
|
|
361
374
|
const { dsl, width, height, theme, editable, className } = propsRef.current;
|
|
362
375
|
if (!dsl) {
|
|
363
376
|
throw new Error("DSL prop is required");
|
|
364
377
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
renderOptions.theme = processedDSL.theme;
|
|
373
|
-
} else if (theme) {
|
|
374
|
-
renderOptions.theme = theme;
|
|
375
|
-
}
|
|
376
|
-
if (palette) {
|
|
377
|
-
const existingThemeConfig = processedDSL.themeConfig || {};
|
|
378
|
-
renderOptions.themeConfig = {
|
|
379
|
-
...existingThemeConfig,
|
|
380
|
-
palette
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
if (editable !== void 0) {
|
|
384
|
-
renderOptions.editable = editable;
|
|
378
|
+
if (containerRef.current && className) {
|
|
379
|
+
containerRef.current.className = className;
|
|
380
|
+
}
|
|
381
|
+
if (typeof dsl === "string") {
|
|
382
|
+
const trimmedDsl = dsl.trim();
|
|
383
|
+
if (!trimmedDsl) {
|
|
384
|
+
throw new Error("String DSL cannot be empty or contain only whitespace");
|
|
385
385
|
}
|
|
386
|
-
if (
|
|
387
|
-
|
|
388
|
-
|
|
386
|
+
if (stringDslCacheRef.current !== trimmedDsl) {
|
|
387
|
+
stringDslCacheRef.current = trimmedDsl;
|
|
388
|
+
rendererRender(trimmedDsl);
|
|
389
389
|
}
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
} else {
|
|
391
|
+
const processedDSL = await processDSL(dsl);
|
|
392
|
+
const dslString = JSON.stringify(processedDSL);
|
|
393
|
+
if (dslCacheRef.current !== dslString) {
|
|
394
|
+
dslCacheRef.current = dslString;
|
|
395
|
+
const { palette, ...restDSL } = processedDSL;
|
|
396
|
+
const renderOptions = {
|
|
397
|
+
...restDSL,
|
|
398
|
+
data: processedDSL.data,
|
|
399
|
+
width,
|
|
400
|
+
height,
|
|
401
|
+
editable
|
|
402
|
+
};
|
|
403
|
+
if (processedDSL.theme) {
|
|
404
|
+
renderOptions.theme = processedDSL.theme;
|
|
405
|
+
} else if (theme) {
|
|
406
|
+
renderOptions.theme = theme;
|
|
407
|
+
}
|
|
408
|
+
if (palette) {
|
|
409
|
+
const existingThemeConfig = processedDSL.themeConfig || {};
|
|
410
|
+
renderOptions.themeConfig = {
|
|
411
|
+
...existingThemeConfig,
|
|
412
|
+
palette
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
rendererRender(renderOptions);
|
|
392
416
|
}
|
|
393
|
-
rendererRender(renderOptions);
|
|
394
417
|
}
|
|
395
418
|
}, [containerRef, rendererRender, processDSL]);
|
|
396
419
|
const debouncedRender = react.useCallback(
|
|
@@ -408,6 +431,10 @@ function useRefMethods(update, { processDSL, theme }) {
|
|
|
408
431
|
themeRef.current = theme;
|
|
409
432
|
const refUpdate = react.useCallback(
|
|
410
433
|
async (options) => {
|
|
434
|
+
if (typeof options === "string") {
|
|
435
|
+
update(options);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
411
438
|
const processed = await processDSL(options);
|
|
412
439
|
const { palette, ...restProcessed } = processed;
|
|
413
440
|
const themeConfig = processed.themeConfig || {};
|
|
@@ -455,7 +482,7 @@ function useInfographic(containerRef, props) {
|
|
|
455
482
|
props.onError?.(infographicError);
|
|
456
483
|
}
|
|
457
484
|
);
|
|
458
|
-
const { refUpdate } = useRefMethods(update, { processDSL, theme: props.theme });
|
|
485
|
+
const { refUpdate } = useRefMethods((options) => update(options), { processDSL, theme: props.theme });
|
|
459
486
|
react.useEffect(() => {
|
|
460
487
|
on("rendered", handleRendered);
|
|
461
488
|
on("loaded", handleRendered);
|
|
@@ -541,11 +568,19 @@ var defaultError = {
|
|
|
541
568
|
message: "An error occurred while rendering the infographic."
|
|
542
569
|
};
|
|
543
570
|
function InfographicComponent(props, ref) {
|
|
571
|
+
const { children, dsl: dslProp, ...restProps } = props;
|
|
544
572
|
const containerRef = react.useRef(null);
|
|
545
573
|
const [error, setError] = react.useState(null);
|
|
546
574
|
const [errorKey, setErrorKey] = react.useState(0);
|
|
575
|
+
console.log("children--------------", children);
|
|
576
|
+
const childrenDsl = children ? String(children).trim() : void 0;
|
|
577
|
+
const finalDsl = childrenDsl || dslProp;
|
|
578
|
+
if (!finalDsl) {
|
|
579
|
+
throw new Error("Either children or dsl prop must be provided");
|
|
580
|
+
}
|
|
547
581
|
const infographicRef = useInfographic(containerRef, {
|
|
548
|
-
...
|
|
582
|
+
...restProps,
|
|
583
|
+
dsl: finalDsl,
|
|
549
584
|
onError: (err) => {
|
|
550
585
|
setError(err);
|
|
551
586
|
props.onError?.(err);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useRenderer.ts","../src/utils/path.ts","../src/utils/dsl/merge.ts","../src/utils/dsl/compose.ts","../src/utils/error.ts","../src/hooks/useDSLProcessor.ts","../src/hooks/useRenderCallback.ts","../src/constants/index.ts","../src/hooks/useRenderController.ts","../src/hooks/useRefMethods.ts","../src/hooks/useInfographic.ts","../src/components/styles.ts","../src/components/Infographic.tsx","../src/components/ErrorBoundary.tsx"],"names":["useRef","useCallback","listeners","useEffect","debounce","useState","useImperativeHandle","jsxs","Fragment","jsx","forwardRef","Component"],"mappings":";;;;;;;AAOO,SAAS,YAAY,YAAA,EAA4C;AACtE,EAAA,MAAM,WAAA,GAAcA,aAAgC,IAAI,CAAA;AACxD,EAAA,MAAM,gBAAA,GAAmBA,aAAO,KAAK,CAAA;AACrC,EAAA,MAAM,mBAAA,GAAsBA,YAAA,iBAAmD,IAAI,GAAA,EAAK,CAAA;AACxF,EAAA,MAAM,oBAAA,GAAuBA,YAAA,iBAAmD,IAAI,GAAA,EAAK,CAAA;AAEzF,EAAA,MAAM,cAAA,GAAiBC,iBAAA;AAAA,IACrB,OAAO,OAAA,KAAoE;AACzE,MAAA,MAAM,EAAE,WAAA,EAAa,gBAAA,EAAiB,GAAI,MAAM,OAAO,mBAAmB,CAAA;AAC1E,MAAA,MAAM,QAAA,GAAW,IAAI,gBAAA,CAAiB,OAAO,CAAA;AAE7C,MAAA,QAAA,CAAS,EAAA,CAAG,YAAY,MAAM;AAC5B,QAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AACtB,QAAA,gBAAA,CAAiB,OAAA,GAAU,IAAA;AAE3B,QAAA,mBAAA,CAAoB,OAAA,CAAQ,OAAA,CAAQ,CAAC,SAAA,EAAW,KAAA,KAAU;AACxD,UAAA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uBACEJ,eAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,4BAAA,EACV,QAAA,EAAA;AAAA,sBAAAE,cAAAA,CAAC,IAAA,EAAA,EAAG,KAAA,EAAO,wBAAA,EAA0B,QAAA,EAAA,sBAAA,EAAoB,CAAA;AAAA,sBACzDA,cAAAA,CAAC,GAAA,EAAA,EAAG,QAAA,EAAA,KAAA,CAAM,OAAA,EAAQ,CAAA;AAAA,MACjB,SAAA,oBACCF,eAAAA,CAAC,SAAA,EAAA,EAAQ,OAAO,EAAE,SAAA,EAAW,QAAO,EAClC,QAAA,EAAA;AAAA,wBAAAE,cAAAA,CAAC,aAAQ,QAAA,EAAA,aAAA,EAAW,CAAA;AAAA,wBACpBA,cAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,wBAAA,EAA2B,oBAAU,cAAA,EAAe;AAAA,OAAA,EAClE,CAAA;AAAA,sBAEFA,cAAAA,CAAC,QAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EAAS,SAAS,IAAA,CAAK,WAAA,EAAa,KAAA,EAAO,8BAAA,EAAgC,QAAA,EAAA,WAAA,EAExF;AAAA,KAAA,EACF,CAAA;AAAA,EAEJ;AACF","file":"index.js","sourcesContent":["import { useEffect, useRef, useCallback } from 'react';\nimport type {\n InfographicOptions,\n RendererInstance,\n ExportOptions,\n} from '../types';\n\nexport function useRenderer(containerRef: React.RefObject<HTMLElement>) {\n const rendererRef = useRef<RendererInstance | null>(null);\n const isInitializedRef = useRef(false);\n const pendingListenersRef = useRef<Map<string, Set<(...args: any[]) => void>>>(new Map());\n const attachedListenersRef = useRef<Map<string, Set<(...args: any[]) => void>>>(new Map());\n\n const createRenderer = useCallback(\n async (options: Partial<InfographicOptions>): Promise<RendererInstance> => {\n const { Infographic: InfographicClass } = await import('@antv/infographic');\n const renderer = new InfographicClass(options);\n\n renderer.on('rendered', () => {\n rendererRef.current = renderer;\n isInitializedRef.current = true;\n\n pendingListenersRef.current.forEach((listeners, event) => {\n listeners.forEach((listener) => {\n renderer.on(event, listener);\n });\n });\n pendingListenersRef.current.clear();\n });\n\n renderer.on('error', (error) => {\n console.error('[Infographic-for-React] Renderer error:', error);\n });\n\n renderer.render();\n\n return renderer;\n },\n [],\n );\n\n const render = useCallback(\n async (options: Partial<InfographicOptions>) => {\n const container = containerRef.current;\n if (!container) {\n throw new Error('Container element not found');\n }\n\n const renderOptions = { ...options, container };\n\n if (rendererRef.current) {\n rendererRef.current.update(renderOptions);\n } else {\n await createRenderer(renderOptions);\n }\n },\n [containerRef, createRenderer],\n );\n\n const update = useCallback((options: Partial<InfographicOptions>) => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized. Call render first.');\n }\n rendererRef.current.update(options);\n }, []);\n\n const toDataURL = useCallback(\n (options?: ExportOptions): Promise<string> => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized');\n }\n return rendererRef.current.toDataURL(options);\n },\n [],\n );\n\n const getTypes = useCallback(() => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized');\n }\n return rendererRef.current.getTypes();\n }, []);\n\n const destroy = useCallback(() => {\n if (rendererRef.current) {\n attachedListenersRef.current.forEach((listeners, event) => {\n listeners.forEach((listener) => {\n rendererRef.current?.off(event, listener);\n });\n });\n attachedListenersRef.current.clear();\n\n rendererRef.current.destroy();\n rendererRef.current = null;\n }\n isInitializedRef.current = false;\n }, []);\n\n const on = useCallback((event: string, listener: (...args: any[]) => void) => {\n if (!rendererRef.current) {\n const listeners = pendingListenersRef.current.get(event) || new Set();\n listeners.add(listener);\n pendingListenersRef.current.set(event, listeners);\n return;\n }\n const listeners = attachedListenersRef.current.get(event) || new Set();\n listeners.add(listener);\n attachedListenersRef.current.set(event, listeners);\n rendererRef.current.on(event, listener);\n }, []);\n\n const off = useCallback((event: string, listener: (...args: any[]) => void) => {\n if (!rendererRef.current) {\n const listeners = pendingListenersRef.current.get(event);\n if (listeners) {\n listeners.delete(listener);\n if (listeners.size === 0) {\n pendingListenersRef.current.delete(event);\n }\n }\n return;\n }\n rendererRef.current.off(event, listener);\n const listeners = attachedListenersRef.current.get(event);\n if (listeners) {\n listeners.delete(listener);\n if (listeners.size === 0) {\n attachedListenersRef.current.delete(event);\n }\n }\n }, []);\n\n useEffect(() => {\n return () => {\n destroy();\n };\n }, [destroy]);\n\n return {\n render,\n update,\n toDataURL,\n getTypes,\n destroy,\n on,\n off,\n isReady: isInitializedRef.current,\n };\n}\n","export interface PathSegment {\n type: 'key' | 'index';\n value: string | number;\n}\n\nfunction parsePath(path: string): PathSegment[] {\n const segments: PathSegment[] = [];\n const regex = /([^.[\\]]+)|\\[(\\d+)\\]/g;\n let match;\n\n while ((match = regex.exec(path)) !== null) {\n if (match[1] !== undefined) {\n segments.push({ type: 'key', value: match[1] });\n } else if (match[2] !== undefined) {\n segments.push({ type: 'index', value: parseInt(match[2], 10) });\n }\n }\n\n return segments;\n}\n\nexport function setByPath(obj: Record<string, unknown>, path: string, value: unknown): void {\n const segments = parsePath(path);\n\n if (segments.length === 0) {\n throw new Error(`Invalid path: ${path}`);\n }\n\n let current: unknown = obj;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n const isLast = i === segments.length - 1;\n\n if (typeof current !== 'object' || current === null) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n\n if (segment.type === 'key') {\n const currentObj = current as Record<string, unknown>;\n if (isLast) {\n currentObj[segment.value] = value;\n } else {\n const nextValue = currentObj[segment.value];\n if (nextValue !== undefined && (typeof nextValue !== 'object' || nextValue === null)) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n if (typeof nextValue !== 'object' || nextValue === null) {\n currentObj[segment.value] = {};\n }\n current = currentObj[segment.value];\n }\n } else {\n const currentArray = current as unknown[];\n if (!Array.isArray(currentArray)) {\n throw new Error(`Cannot access array index at path \"${path}\": parent is not an array`);\n }\n const index = segment.value as number;\n if (isLast) {\n currentArray[index] = value;\n } else {\n const nextValue = currentArray[index];\n if (nextValue !== undefined && (typeof nextValue !== 'object' || nextValue === null)) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n if (typeof nextValue !== 'object' || nextValue === null) {\n currentArray[index] = {};\n }\n current = currentArray[index];\n }\n }\n }\n}\n\nexport function getByPath(obj: Record<string, unknown>, path: string): unknown {\n const segments = parsePath(path);\n\n if (segments.length === 0) {\n return undefined;\n }\n\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (typeof current !== 'object' || current === null) {\n return undefined;\n }\n\n if (segment.type === 'key') {\n current = (current as Record<string, unknown>)[segment.value];\n } else {\n if (!Array.isArray(current)) {\n return undefined;\n }\n const index = segment.value as number;\n current = current[index];\n }\n }\n\n return current;\n}\n","import type { DSLOverride, DSLObject } from '../../types';\nimport { setByPath } from '../path';\n\nexport function applyOverrides(base: DSLObject, overrides: DSLOverride[]): DSLObject {\n if (overrides.length === 0) return base;\n\n const result = { ...base };\n\n for (const override of overrides) {\n setByPath(result as Record<string, unknown>, override.path, override.value);\n }\n\n return result;\n}\n\nexport function mergeDSL(dsl1: DSLObject, dsl2: DSLObject): DSLObject {\n const merged = deepMerge(dsl1 as unknown as Record<string, unknown>, dsl2 as unknown as Record<string, unknown>);\n return merged as unknown as DSLObject;\n}\n\nfunction deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...target };\n\n for (const key in source) {\n if (source[key] === undefined) {\n continue;\n }\n\n const value = source[key];\n\n if (value === null) {\n result[key] = null;\n continue;\n }\n\n const targetValue = result[key];\n\n if (typeof value === 'object' && !Array.isArray(value) && targetValue && typeof targetValue === 'object' && !Array.isArray(targetValue)) {\n result[key] = deepMerge(targetValue as Record<string, unknown>, value as Record<string, unknown>);\n } else {\n result[key] = value;\n }\n }\n\n return result;\n}\n","import type { ComposeTemplateOptions, DSLObject } from '../../types';\nimport { applyOverrides } from './merge';\n\ninterface DSLNode {\n type?: string;\n data?: unknown;\n props?: Record<string, unknown>;\n children?: DSLNode[];\n [key: string]: unknown;\n}\n\nfunction isContainerNode(node: unknown): node is DSLNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'children' in node &&\n Array.isArray((node as DSLNode).children)\n );\n}\n\nexport function composeTemplates(options: ComposeTemplateOptions): DSLObject {\n const { templates, overrides = [] } = options;\n\n if (templates.length === 0) {\n throw new Error('At least one template is required');\n }\n\n if (templates.length === 1) {\n const base = templates[0];\n if (overrides.length > 0) {\n return applyOverrides(base, overrides);\n }\n return base;\n }\n\n const root = templates[0] as DSLNode;\n\n if (!isContainerNode(root)) {\n throw new Error('Root template must be a container node with children');\n }\n\n let currentChildren = root.children || [];\n\n for (let i = 1; i < templates.length; i++) {\n const template = templates[i] as DSLNode;\n\n if (isContainerNode(template) && template.children) {\n currentChildren = [...currentChildren, ...template.children];\n } else {\n currentChildren.push(template);\n }\n }\n\n root.children = currentChildren;\n\n let composed = root as DSLObject;\n\n if (overrides.length > 0) {\n composed = applyOverrides(composed, overrides);\n }\n\n return composed;\n}\n","import type { InfographicError } from '../types';\n\nexport function createInfographicError(\n type: InfographicError['type'],\n message: string,\n dsl?: string,\n details?: Error | unknown,\n): InfographicError {\n return {\n type,\n message,\n dsl,\n details,\n };\n}\n\nexport function isInfographicError(error: unknown): error is InfographicError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'type' in error &&\n 'message' in error &&\n ['syntax', 'render', 'runtime'].includes((error as InfographicError).type)\n );\n}\n\nexport function formatErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n}\n","import { useCallback, useRef } from 'react';\nimport { applyOverrides } from '../utils/dsl';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type {\n InfographicError,\n DSLObject,\n PreRenderHook,\n DSLOverride,\n} from '../types';\n\ninterface DSLProcessorOptions {\n overrides?: DSLOverride[];\n beforeRender?: PreRenderHook;\n onError?: (error: InfographicError) => void;\n}\n\nexport function useDSLProcessor(options: DSLProcessorOptions) {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const processDSL = useCallback(\n async (input: DSLObject): Promise<DSLObject> => {\n let processed: DSLObject = input;\n const { overrides, beforeRender } = optionsRef.current;\n\n if (overrides && overrides.length > 0) {\n try {\n processed = applyOverrides(processed, overrides);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'syntax',\n `Failed to apply overrides: ${formatErrorMessage(error)}`,\n JSON.stringify(processed),\n error,\n );\n optionsRef.current.onError?.(infographicError);\n throw infographicError;\n }\n }\n\n if (beforeRender) {\n try {\n processed = await beforeRender(processed);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'runtime',\n `beforeRender hook failed: ${formatErrorMessage(error)}`,\n JSON.stringify(processed),\n error,\n );\n optionsRef.current.onError?.(infographicError);\n throw infographicError;\n }\n }\n\n return processed;\n },\n [],\n );\n\n return { processDSL };\n}\n","import { useCallback, useRef } from 'react';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type { InfographicError, InfographicRenderResult, PostRenderHook } from '../types';\n\ninterface RenderCallbackOptions {\n afterRender?: PostRenderHook;\n onRender?: (result: InfographicRenderResult) => void;\n onLoad?: (result: InfographicRenderResult) => void;\n onError?: (error: InfographicError) => void;\n}\n\nexport function useRenderCallback(options: RenderCallbackOptions) {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const handleRendered = useCallback(\n async (result: InfographicRenderResult) => {\n const { afterRender, onRender, onLoad } = optionsRef.current;\n\n if (afterRender) {\n try {\n await afterRender(result);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'runtime',\n `afterRender hook failed: ${formatErrorMessage(error)}`,\n undefined,\n error,\n );\n optionsRef.current.onError?.(infographicError);\n return;\n }\n }\n\n onRender?.(result);\n onLoad?.(result);\n },\n [],\n );\n\n return { handleRendered };\n}\n","export const RENDER_DEBOUNCE_DELAY = 100;\n","import { useCallback, useRef } from 'react';\nimport { debounce } from 'lodash-es';\nimport { RENDER_DEBOUNCE_DELAY } from '../constants';\nimport type {\n DSLInput,\n DSLObject,\n InfographicOptions,\n ThemeConfig,\n} from '../types';\n\ninterface RenderControllerProps {\n dsl?: DSLInput;\n width?: number | string;\n height?: number | string;\n theme?: string;\n editable?: boolean;\n className?: string;\n}\n\nexport function useRenderController(\n containerRef: React.RefObject<HTMLElement>,\n rendererRender: (options: Partial<InfographicOptions>) => void,\n props: RenderControllerProps,\n processDSL: (input: DSLObject) => Promise<DSLObject>,\n onError?: (error: unknown) => void,\n) {\n const propsRef = useRef(props);\n const dslCacheRef = useRef<string | null>(null);\n\n propsRef.current = props;\n\n const render = useCallback(async () => {\n const { dsl, width, height, theme, editable, className } = propsRef.current;\n\n if (!dsl) {\n throw new Error('DSL prop is required');\n }\n\n const processedDSL: DSLObject = await processDSL(dsl);\n\n const dslString = JSON.stringify(processedDSL);\n if (dslCacheRef.current !== dslString) {\n dslCacheRef.current = dslString;\n\n const { palette, ...restDSL } = processedDSL;\n\n const renderOptions: Partial<InfographicOptions> = { ...restDSL, data: processedDSL.data };\n\n if (processedDSL.theme) {\n renderOptions.theme = processedDSL.theme;\n } else if (theme) {\n renderOptions.theme = theme;\n }\n\n if (palette) {\n const existingThemeConfig = (processedDSL.themeConfig || {}) as ThemeConfig;\n renderOptions.themeConfig = {\n ...existingThemeConfig,\n palette,\n };\n }\n\n if (editable !== undefined) {\n renderOptions.editable = editable;\n }\n\n if (width || height) {\n renderOptions.width = width;\n renderOptions.height = height;\n }\n\n if (containerRef.current && className) {\n containerRef.current.className = className;\n }\n\n rendererRender(renderOptions);\n }\n }, [containerRef, rendererRender, processDSL]);\n\n const debouncedRender = useCallback(\n debounce(() => {\n render().catch((error) => {\n onError?.(error);\n });\n }, RENDER_DEBOUNCE_DELAY),\n [render, onError],\n );\n\n return { debouncedRender };\n}\n","import { useCallback, useRef } from 'react';\nimport type { DSLInput, DSLObject, InfographicOptions, Palette, ThemeConfig } from '../types';\n\ninterface RefMethodsProps {\n processDSL: (input: DSLObject) => Promise<DSLObject>;\n theme?: string;\n}\n\nexport function useRefMethods(\n update: (options: Partial<InfographicOptions>) => void,\n { processDSL, theme }: RefMethodsProps,\n) {\n const themeRef = useRef(theme);\n themeRef.current = theme;\n\n const refUpdate = useCallback(\n async (options: DSLInput) => {\n const processed: DSLObject = await processDSL(options);\n const { palette, ...restProcessed } = processed;\n const themeConfig = (processed.themeConfig || {}) as ThemeConfig;\n\n if (palette) {\n themeConfig.palette = palette as Palette;\n }\n\n const renderOptions: Partial<InfographicOptions> = {\n ...restProcessed,\n theme: processed.theme ?? themeRef.current,\n themeConfig,\n };\n\n update(renderOptions);\n },\n [update, processDSL],\n );\n\n return { refUpdate };\n}\n","import { useEffect } from 'react';\nimport { useRenderer } from './useRenderer';\nimport { useDSLProcessor } from './useDSLProcessor';\nimport { useRenderCallback } from './useRenderCallback';\nimport { useRenderController } from './useRenderController';\nimport { useRefMethods } from './useRefMethods';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type {\n InfographicProps,\n InfographicRef,\n InfographicError,\n} from '../types';\n\nexport function useInfographic(\n containerRef: React.RefObject<HTMLElement>,\n props: InfographicProps,\n) {\n const { render: rendererRender, update, toDataURL, getTypes, destroy, on, off } = useRenderer(containerRef);\n\n const { processDSL } = useDSLProcessor({\n overrides: props.overrides,\n beforeRender: props.beforeRender,\n onError: props.onError,\n });\n\n const { handleRendered } = useRenderCallback({\n afterRender: props.afterRender,\n onRender: props.onRender,\n onLoad: props.onLoad,\n onError: props.onError,\n });\n\n const { debouncedRender } = useRenderController(\n containerRef,\n rendererRender,\n props,\n processDSL,\n (error) => {\n const infographicError: InfographicError = createInfographicError(\n 'render',\n formatErrorMessage(error),\n undefined,\n error,\n );\n props.onError?.(infographicError);\n },\n );\n\n const { refUpdate } = useRefMethods(update, { processDSL, theme: props.theme });\n\n useEffect(() => {\n on('rendered', handleRendered);\n on('loaded', handleRendered);\n\n return () => {\n off('rendered', handleRendered);\n off('loaded', handleRendered);\n };\n }, [on, off, handleRendered]);\n\n useEffect(() => {\n debouncedRender();\n return debouncedRender.cancel;\n }, [debouncedRender]);\n\n const ref: InfographicRef = {\n toDataURL,\n getTypes,\n update: refUpdate,\n destroy,\n };\n\n return ref;\n}\n","export const errorOverlayStyles: React.CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'rgba(0, 0, 0, 0.05)',\n color: '#d32f2f',\n padding: '20px',\n zIndex: 1,\n textAlign: 'center',\n};\n\nexport const errorTitleStyles: React.CSSProperties = {\n fontSize: '1.2em',\n fontWeight: 'bold',\n marginBottom: '10px',\n};\n\nexport const errorMessageStyles: React.CSSProperties = {\n marginBottom: '15px',\n};\n\nexport const retryButtonStyles: React.CSSProperties = {\n padding: '8px 16px',\n backgroundColor: '#1976d2',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n fontSize: '14px',\n};\n\nexport const errorBoundaryContainerStyles: React.CSSProperties = {\n padding: '20px',\n backgroundColor: '#fee',\n border: '1px solid #fcc',\n borderRadius: '4px',\n color: '#c33',\n};\n\nexport const errorBoundaryTitleStyles: React.CSSProperties = {\n marginTop: 0,\n};\n\nexport const errorBoundaryStackStyles: React.CSSProperties = {\n marginTop: '10px',\n padding: '10px',\n backgroundColor: 'white',\n borderRadius: '4px',\n overflow: 'auto',\n};\n\nexport const errorBoundaryRetryButtonStyles: React.CSSProperties = {\n marginTop: '15px',\n padding: '8px 16px',\n backgroundColor: '#c33',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n};\n","import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';\nimport { useInfographic } from '../hooks';\nimport type { InfographicProps, InfographicRef, InfographicError } from '../types';\nimport {\n errorOverlayStyles,\n errorTitleStyles,\n errorMessageStyles,\n retryButtonStyles,\n} from './styles';\n\nconst defaultError: InfographicError = {\n type: 'render',\n message: 'An error occurred while rendering the infographic.',\n};\n\nfunction InfographicComponent(\n props: InfographicProps,\n ref: React.Ref<InfographicRef>,\n) {\n const containerRef = useRef<HTMLDivElement>(null);\n const [error, setError] = useState<InfographicError | null>(null);\n const [errorKey, setErrorKey] = useState(0);\n\n const infographicRef = useInfographic(containerRef, {\n ...props,\n onError: (err) => {\n setError(err);\n props.onError?.(err);\n },\n });\n\n useImperativeHandle(ref, () => infographicRef, [infographicRef]);\n\n const handleRetry = () => {\n setError(null);\n setErrorKey((prev) => prev + 1);\n };\n\n const containerStyle: React.CSSProperties = {\n width: props.width ?? '100%',\n height: props.height ?? 'auto',\n overflow: 'hidden',\n };\n\n return (\n <>\n <div\n key={`infographic-container-${errorKey}`}\n ref={containerRef}\n className={props.className}\n style={containerStyle}\n data-infographic-container\n />\n {error && (\n <div style={errorOverlayStyles}>\n <div style={errorTitleStyles}>Infographic Render Error</div>\n <div style={errorMessageStyles}>{error.message || defaultError.message}</div>\n <button type=\"button\" onClick={handleRetry} style={retryButtonStyles}>\n Retry\n </button>\n </div>\n )}\n </>\n );\n}\n\nexport const Infographic = forwardRef(InfographicComponent);\n","import { Component, ErrorInfo, ReactNode } from 'react';\nimport {\n errorBoundaryContainerStyles,\n errorBoundaryTitleStyles,\n errorBoundaryStackStyles,\n errorBoundaryRetryButtonStyles,\n} from './styles';\n\ninterface ErrorBoundaryProps {\n children: ReactNode;\n fallback?: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode);\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n error?: Error;\n errorInfo?: ErrorInfo;\n}\n\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n this.setState({ errorInfo });\n this.props.onError?.(error, errorInfo);\n }\n\n handleReset = () => {\n this.setState({ hasError: false, error: undefined, errorInfo: undefined });\n };\n\n render() {\n const { hasError, error, errorInfo } = this.state;\n const { children, fallback } = this.props;\n\n if (!hasError || !error) {\n return children;\n }\n\n if (fallback) {\n if (typeof fallback === 'function') {\n return fallback(error, errorInfo!);\n }\n return fallback;\n }\n\n return (\n <div style={errorBoundaryContainerStyles}>\n <h2 style={errorBoundaryTitleStyles}>Something went wrong</h2>\n <p>{error.message}</p>\n {errorInfo && (\n <details style={{ marginTop: '10px' }}>\n <summary>Stack trace</summary>\n <pre style={errorBoundaryStackStyles}>{errorInfo.componentStack}</pre>\n </details>\n )}\n <button type=\"button\" onClick={this.handleReset} style={errorBoundaryRetryButtonStyles}>\n Try again\n </button>\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useRenderer.ts","../src/utils/path.ts","../src/utils/dsl/merge.ts","../src/utils/dsl/compose.ts","../src/utils/error.ts","../src/hooks/useDSLProcessor.ts","../src/hooks/useRenderCallback.ts","../src/constants/index.ts","../src/hooks/useRenderController.ts","../src/hooks/useRefMethods.ts","../src/hooks/useInfographic.ts","../src/components/styles.ts","../src/components/Infographic.tsx","../src/components/ErrorBoundary.tsx"],"names":["useRef","useCallback","listeners","useEffect","debounce","useState","useImperativeHandle","jsxs","Fragment","jsx","forwardRef","Component"],"mappings":";;;;;;;AAOO,SAAS,YAAY,YAAA,EAA4C;AACtE,EAAA,MAAM,WAAA,GAAcA,aAAgC,IAAI,CAAA;AACxD,EAAA,MAAM,gBAAA,GAAmBA,aAAO,KAAK,CAAA;AACrC,EAAA,MAAM,mBAAA,GAAsBA,YAAA,iBAAmD,IAAI,GAAA,EAAK,CAAA;AACxF,EAAA,MAAM,oBAAA,GAAuBA,YAAA,iBAAmD,IAAI,GAAA,EAAK,CAAA;AAEzF,EAAA,MAAM,cAAA,GAAiBC,iBAAA;AAAA,IACrB,OAAO,SAA+C,S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KAAA;AAC5C,IAAA,MAAM,EAAE,QAAA,EAAU,QAAA,EAAS,GAAI,IAAA,CAAK,KAAA;AAEpC,IAAA,IAAI,CAAC,QAAA,IAAY,CAAC,KAAA,EAAO;AACvB,MAAA,OAAO,QAAA;AAAA,IACT;AAEA,IAAA,IAAI,QAAA,EAAU;AACZ,MAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,QAAA,OAAO,QAAA,CAAS,OAAO,SAAU,CAAA;AAAA,MACnC;AACA,MAAA,OAAO,QAAA;AAAA,IACT;AAEA,IAAA,uBACEJ,eAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,4BAAA,EACV,QAAA,EAAA;AAAA,sBAAAE,cAAAA,CAAC,IAAA,EAAA,EAAG,KAAA,EAAO,wBAAA,EAA0B,QAAA,EAAA,sBAAA,EAAoB,CAAA;AAAA,sBACzDA,cAAAA,CAAC,GAAA,EAAA,EAAG,QAAA,EAAA,KAAA,CAAM,OAAA,EAAQ,CAAA;AAAA,MACjB,SAAA,oBACCF,eAAAA,CAAC,SAAA,EAAA,EAAQ,OAAO,EAAE,SAAA,EAAW,QAAO,EAClC,QAAA,EAAA;AAAA,wBAAAE,cAAAA,CAAC,aAAQ,QAAA,EAAA,aAAA,EAAW,CAAA;AAAA,wBACpBA,cAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,wBAAA,EAA2B,oBAAU,cAAA,EAAe;AAAA,OAAA,EAClE,CAAA;AAAA,sBAEFA,cAAAA,CAAC,QAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EAAS,SAAS,IAAA,CAAK,WAAA,EAAa,KAAA,EAAO,8BAAA,EAAgC,QAAA,EAAA,WAAA,EAExF;AAAA,KAAA,EACF,CAAA;AAAA,EAEJ;AACF","file":"index.js","sourcesContent":["import { useEffect, useRef, useCallback } from 'react';\nimport type {\n InfographicOptions,\n RendererInstance,\n ExportOptions,\n} from '../types';\n\nexport function useRenderer(containerRef: React.RefObject<HTMLElement>) {\n const rendererRef = useRef<RendererInstance | null>(null);\n const isInitializedRef = useRef(false);\n const pendingListenersRef = useRef<Map<string, Set<(...args: any[]) => void>>>(new Map());\n const attachedListenersRef = useRef<Map<string, Set<(...args: any[]) => void>>>(new Map());\n\n const createRenderer = useCallback(\n async (options: string | Partial<InfographicOptions>, container: HTMLElement): Promise<RendererInstance> => {\n const { Infographic: InfographicClass } = await import('@antv/infographic');\n\n let renderer: RendererInstance;\n\n if (typeof options === 'string') {\n renderer = new InfographicClass(options);\n } else {\n renderer = new InfographicClass({ ...options, container });\n }\n\n renderer.on('rendered', () => {\n rendererRef.current = renderer;\n isInitializedRef.current = true;\n\n pendingListenersRef.current.forEach((listeners, event) => {\n listeners.forEach((listener) => {\n renderer.on(event, listener);\n });\n });\n pendingListenersRef.current.clear();\n });\n\n renderer.on('error', (error) => {\n console.error('[Infographic-for-React] Renderer error:', error);\n });\n\n if (typeof options === 'string') {\n renderer.render({ container });\n } else {\n renderer.render();\n }\n\n return renderer;\n },\n [],\n );\n\n const render = useCallback(\n async (options: string | Partial<InfographicOptions>) => {\n const container = containerRef.current;\n if (!container) {\n throw new Error('Container element not found');\n }\n\n if (rendererRef.current) {\n if (typeof options === 'string') {\n rendererRef.current.update(options);\n } else {\n rendererRef.current.update({ ...options, container });\n }\n } else {\n await createRenderer(options, container);\n }\n },\n [containerRef, createRenderer],\n );\n\n const update = useCallback((options: string | Partial<InfographicOptions>) => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized. Call render first.');\n }\n rendererRef.current.update(options);\n }, []);\n\n const toDataURL = useCallback(\n (options?: ExportOptions): Promise<string> => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized');\n }\n return rendererRef.current.toDataURL(options);\n },\n [],\n );\n\n const getTypes = useCallback(() => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized');\n }\n return rendererRef.current.getTypes();\n }, []);\n\n const destroy = useCallback(() => {\n if (rendererRef.current) {\n attachedListenersRef.current.forEach((listeners, event) => {\n listeners.forEach((listener) => {\n rendererRef.current?.off(event, listener);\n });\n });\n attachedListenersRef.current.clear();\n\n rendererRef.current.destroy();\n rendererRef.current = null;\n }\n isInitializedRef.current = false;\n }, []);\n\n const on = useCallback((event: string, listener: (...args: any[]) => void) => {\n if (!rendererRef.current) {\n const listeners = pendingListenersRef.current.get(event) || new Set();\n listeners.add(listener);\n pendingListenersRef.current.set(event, listeners);\n return;\n }\n const listeners = attachedListenersRef.current.get(event) || new Set();\n listeners.add(listener);\n attachedListenersRef.current.set(event, listeners);\n rendererRef.current.on(event, listener);\n }, []);\n\n const off = useCallback((event: string, listener: (...args: any[]) => void) => {\n if (!rendererRef.current) {\n const listeners = pendingListenersRef.current.get(event);\n if (listeners) {\n listeners.delete(listener);\n if (listeners.size === 0) {\n pendingListenersRef.current.delete(event);\n }\n }\n return;\n }\n rendererRef.current.off(event, listener);\n const listeners = attachedListenersRef.current.get(event);\n if (listeners) {\n listeners.delete(listener);\n if (listeners.size === 0) {\n attachedListenersRef.current.delete(event);\n }\n }\n }, []);\n\n useEffect(() => {\n return () => {\n destroy();\n };\n }, [destroy]);\n\n return {\n render,\n update,\n toDataURL,\n getTypes,\n destroy,\n on,\n off,\n isReady: isInitializedRef.current,\n };\n}\n","export interface PathSegment {\n type: 'key' | 'index';\n value: string | number;\n}\n\nfunction parsePath(path: string): PathSegment[] {\n const segments: PathSegment[] = [];\n const regex = /([^.[\\]]+)|\\[(\\d+)\\]/g;\n let match;\n\n while ((match = regex.exec(path)) !== null) {\n if (match[1] !== undefined) {\n segments.push({ type: 'key', value: match[1] });\n } else if (match[2] !== undefined) {\n segments.push({ type: 'index', value: parseInt(match[2], 10) });\n }\n }\n\n return segments;\n}\n\nexport function setByPath(obj: Record<string, unknown>, path: string, value: unknown): void {\n const segments = parsePath(path);\n\n if (segments.length === 0) {\n throw new Error(`Invalid path: ${path}`);\n }\n\n let current: unknown = obj;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n const isLast = i === segments.length - 1;\n\n if (typeof current !== 'object' || current === null) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n\n if (segment.type === 'key') {\n const currentObj = current as Record<string, unknown>;\n if (isLast) {\n currentObj[segment.value] = value;\n } else {\n const nextValue = currentObj[segment.value];\n if (nextValue !== undefined && (typeof nextValue !== 'object' || nextValue === null)) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n if (typeof nextValue !== 'object' || nextValue === null) {\n currentObj[segment.value] = {};\n }\n current = currentObj[segment.value];\n }\n } else {\n const currentArray = current as unknown[];\n if (!Array.isArray(currentArray)) {\n throw new Error(`Cannot access array index at path \"${path}\": parent is not an array`);\n }\n const index = segment.value as number;\n if (isLast) {\n currentArray[index] = value;\n } else {\n const nextValue = currentArray[index];\n if (nextValue !== undefined && (typeof nextValue !== 'object' || nextValue === null)) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n if (typeof nextValue !== 'object' || nextValue === null) {\n currentArray[index] = {};\n }\n current = currentArray[index];\n }\n }\n }\n}\n\nexport function getByPath(obj: Record<string, unknown>, path: string): unknown {\n const segments = parsePath(path);\n\n if (segments.length === 0) {\n return undefined;\n }\n\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (typeof current !== 'object' || current === null) {\n return undefined;\n }\n\n if (segment.type === 'key') {\n current = (current as Record<string, unknown>)[segment.value];\n } else {\n if (!Array.isArray(current)) {\n return undefined;\n }\n const index = segment.value as number;\n current = current[index];\n }\n }\n\n return current;\n}\n","import type { DSLOverride, DSLObject } from '../../types';\nimport { setByPath } from '../path';\n\nexport function applyOverrides(base: DSLObject, overrides: DSLOverride[]): DSLObject {\n if (overrides.length === 0) return base;\n\n const result = { ...base };\n\n for (const override of overrides) {\n setByPath(result as Record<string, unknown>, override.path, override.value);\n }\n\n return result;\n}\n\nexport function mergeDSL(dsl1: DSLObject, dsl2: DSLObject): DSLObject {\n const merged = deepMerge(dsl1 as unknown as Record<string, unknown>, dsl2 as unknown as Record<string, unknown>);\n return merged as unknown as DSLObject;\n}\n\nfunction deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...target };\n\n for (const key in source) {\n if (source[key] === undefined) {\n continue;\n }\n\n const value = source[key];\n\n if (value === null) {\n result[key] = null;\n continue;\n }\n\n const targetValue = result[key];\n\n if (typeof value === 'object' && !Array.isArray(value) && targetValue && typeof targetValue === 'object' && !Array.isArray(targetValue)) {\n result[key] = deepMerge(targetValue as Record<string, unknown>, value as Record<string, unknown>);\n } else {\n result[key] = value;\n }\n }\n\n return result;\n}\n","import type { ComposeTemplateOptions, DSLObject } from '../../types';\nimport { applyOverrides } from './merge';\n\ninterface DSLNode {\n type?: string;\n data?: unknown;\n props?: Record<string, unknown>;\n children?: DSLNode[];\n [key: string]: unknown;\n}\n\nfunction isContainerNode(node: unknown): node is DSLNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'children' in node &&\n Array.isArray((node as DSLNode).children)\n );\n}\n\nexport function composeTemplates(options: ComposeTemplateOptions): DSLObject {\n const { templates, overrides = [] } = options;\n\n if (templates.length === 0) {\n throw new Error('At least one template is required');\n }\n\n if (templates.length === 1) {\n const base = templates[0];\n if (overrides.length > 0) {\n return applyOverrides(base, overrides);\n }\n return base;\n }\n\n const root = templates[0] as DSLNode;\n\n if (!isContainerNode(root)) {\n throw new Error('Root template must be a container node with children');\n }\n\n let currentChildren = root.children || [];\n\n for (let i = 1; i < templates.length; i++) {\n const template = templates[i] as DSLNode;\n\n if (isContainerNode(template) && template.children) {\n currentChildren = [...currentChildren, ...template.children];\n } else {\n currentChildren.push(template);\n }\n }\n\n root.children = currentChildren;\n\n let composed = root as DSLObject;\n\n if (overrides.length > 0) {\n composed = applyOverrides(composed, overrides);\n }\n\n return composed;\n}\n","import type { InfographicError } from '../types';\n\nexport function createInfographicError(\n type: InfographicError['type'],\n message: string,\n dsl?: string,\n details?: Error | unknown,\n): InfographicError {\n return {\n type,\n message,\n dsl,\n details,\n };\n}\n\nexport function isInfographicError(error: unknown): error is InfographicError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'type' in error &&\n 'message' in error &&\n ['syntax', 'render', 'runtime'].includes((error as InfographicError).type)\n );\n}\n\nexport function formatErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n}\n","import { useCallback, useRef } from 'react';\nimport { applyOverrides } from '../utils/dsl';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type {\n InfographicError,\n DSLObject,\n PreRenderHook,\n DSLOverride,\n} from '../types';\n\ninterface DSLProcessorOptions {\n overrides?: DSLOverride[];\n beforeRender?: PreRenderHook;\n onError?: (error: InfographicError) => void;\n}\n\nexport function useDSLProcessor(options: DSLProcessorOptions) {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const processDSL = useCallback(\n async (input: DSLObject): Promise<DSLObject> => {\n let processed: DSLObject = input;\n const { overrides, beforeRender } = optionsRef.current;\n\n if (overrides && overrides.length > 0) {\n try {\n processed = applyOverrides(processed, overrides);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'syntax',\n `Failed to apply overrides: ${formatErrorMessage(error)}`,\n JSON.stringify(processed),\n error,\n );\n optionsRef.current.onError?.(infographicError);\n throw infographicError;\n }\n }\n\n if (beforeRender) {\n try {\n processed = await beforeRender(processed);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'runtime',\n `beforeRender hook failed: ${formatErrorMessage(error)}`,\n JSON.stringify(processed),\n error,\n );\n optionsRef.current.onError?.(infographicError);\n throw infographicError;\n }\n }\n\n return processed;\n },\n [],\n );\n\n return { processDSL };\n}\n","import { useCallback, useRef } from 'react';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type { InfographicError, InfographicRenderResult, PostRenderHook } from '../types';\n\ninterface RenderCallbackOptions {\n afterRender?: PostRenderHook;\n onRender?: (result: InfographicRenderResult) => void;\n onLoad?: (result: InfographicRenderResult) => void;\n onError?: (error: InfographicError) => void;\n}\n\nexport function useRenderCallback(options: RenderCallbackOptions) {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const handleRendered = useCallback(\n async (result: InfographicRenderResult) => {\n const { afterRender, onRender, onLoad } = optionsRef.current;\n\n if (afterRender) {\n try {\n await afterRender(result);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'runtime',\n `afterRender hook failed: ${formatErrorMessage(error)}`,\n undefined,\n error,\n );\n optionsRef.current.onError?.(infographicError);\n return;\n }\n }\n\n onRender?.(result);\n onLoad?.(result);\n },\n [],\n );\n\n return { handleRendered };\n}\n","export const RENDER_DEBOUNCE_DELAY = 100;\n","import { useCallback, useRef } from 'react';\nimport { debounce } from 'lodash-es';\nimport { RENDER_DEBOUNCE_DELAY } from '../constants';\nimport type {\n DSLInput,\n DSLObject,\n InfographicOptions,\n ThemeConfig,\n} from '../types';\n\ninterface RenderControllerProps {\n dsl?: DSLInput;\n width?: number | string;\n height?: number | string;\n theme?: string;\n editable?: boolean;\n className?: string;\n}\n\nexport function useRenderController(\n containerRef: React.RefObject<HTMLElement>,\n rendererRender: (options: string | Partial<InfographicOptions>) => void,\n props: RenderControllerProps,\n processDSL: (input: DSLObject) => Promise<DSLObject>,\n onError?: (error: unknown) => void,\n) {\n const propsRef = useRef(props);\n const dslCacheRef = useRef<string | null>(null);\n const stringDslCacheRef = useRef<string | null>(null);\n\n propsRef.current = props;\n\n const render = useCallback(async () => {\n const { dsl, width, height, theme, editable, className } = propsRef.current;\n\n if (!dsl) {\n throw new Error('DSL prop is required');\n }\n\n if (containerRef.current && className) {\n containerRef.current.className = className;\n }\n\n if (typeof dsl === 'string') {\n const trimmedDsl = dsl.trim();\n if (!trimmedDsl) {\n throw new Error('String DSL cannot be empty or contain only whitespace');\n }\n if (stringDslCacheRef.current !== trimmedDsl) {\n stringDslCacheRef.current = trimmedDsl;\n rendererRender(trimmedDsl);\n }\n } else {\n const processedDSL: DSLObject = await processDSL(dsl);\n\n const dslString = JSON.stringify(processedDSL);\n if (dslCacheRef.current !== dslString) {\n dslCacheRef.current = dslString;\n\n const { palette, ...restDSL } = processedDSL;\n\n const renderOptions: Partial<InfographicOptions> = {\n ...restDSL,\n data: processedDSL.data,\n width,\n height,\n editable,\n };\n\n if (processedDSL.theme) {\n renderOptions.theme = processedDSL.theme;\n } else if (theme) {\n renderOptions.theme = theme;\n }\n\n if (palette) {\n const existingThemeConfig = (processedDSL.themeConfig || {}) as ThemeConfig;\n renderOptions.themeConfig = {\n ...existingThemeConfig,\n palette,\n };\n }\n\n rendererRender(renderOptions);\n }\n }\n }, [containerRef, rendererRender, processDSL]);\n\n const debouncedRender = useCallback(\n debounce(() => {\n render().catch((error) => {\n onError?.(error);\n });\n }, RENDER_DEBOUNCE_DELAY),\n [render, onError],\n );\n\n return { debouncedRender };\n}\n","import { useCallback, useRef } from 'react';\nimport type { DSLInput, DSLObject, InfographicOptions, Palette, ThemeConfig } from '../types';\n\ninterface RefMethodsProps {\n processDSL: (input: DSLObject) => Promise<DSLObject>;\n theme?: string;\n}\n\nexport function useRefMethods(\n update: (options: string | Partial<InfographicOptions>) => void,\n { processDSL, theme }: RefMethodsProps,\n) {\n const themeRef = useRef(theme);\n themeRef.current = theme;\n\n const refUpdate = useCallback(\n async (options: DSLInput) => {\n if (typeof options === 'string') {\n update(options);\n return;\n }\n\n const processed: DSLObject = await processDSL(options);\n const { palette, ...restProcessed } = processed;\n const themeConfig = (processed.themeConfig || {}) as ThemeConfig;\n\n if (palette) {\n themeConfig.palette = palette as Palette;\n }\n\n const renderOptions: Partial<InfographicOptions> = {\n ...restProcessed,\n theme: processed.theme ?? themeRef.current,\n themeConfig,\n };\n\n update(renderOptions);\n },\n [update, processDSL],\n );\n\n return { refUpdate };\n}\n","import { useEffect } from 'react';\nimport { useRenderer } from './useRenderer';\nimport { useDSLProcessor } from './useDSLProcessor';\nimport { useRenderCallback } from './useRenderCallback';\nimport { useRenderController } from './useRenderController';\nimport { useRefMethods } from './useRefMethods';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type {\n InfographicProps,\n InfographicRef,\n InfographicError,\n} from '../types';\n\nexport function useInfographic(\n containerRef: React.RefObject<HTMLElement>,\n props: InfographicProps,\n) {\n const { render: rendererRender, update, toDataURL, getTypes, destroy, on, off } = useRenderer(containerRef);\n\n const { processDSL } = useDSLProcessor({\n overrides: props.overrides,\n beforeRender: props.beforeRender,\n onError: props.onError,\n });\n\n const { handleRendered } = useRenderCallback({\n afterRender: props.afterRender,\n onRender: props.onRender,\n onLoad: props.onLoad,\n onError: props.onError,\n });\n\n const { debouncedRender } = useRenderController(\n containerRef,\n rendererRender,\n props,\n processDSL,\n (error) => {\n const infographicError: InfographicError = createInfographicError(\n 'render',\n formatErrorMessage(error),\n undefined,\n error,\n );\n props.onError?.(infographicError);\n },\n );\n\n const { refUpdate } = useRefMethods((options) => update(options), { processDSL, theme: props.theme });\n\n useEffect(() => {\n on('rendered', handleRendered);\n on('loaded', handleRendered);\n\n return () => {\n off('rendered', handleRendered);\n off('loaded', handleRendered);\n };\n }, [on, off, handleRendered]);\n\n useEffect(() => {\n debouncedRender();\n return debouncedRender.cancel;\n }, [debouncedRender]);\n\n const ref: InfographicRef = {\n toDataURL,\n getTypes,\n update: refUpdate,\n destroy,\n };\n\n return ref;\n}\n","export const errorOverlayStyles: React.CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'rgba(0, 0, 0, 0.05)',\n color: '#d32f2f',\n padding: '20px',\n zIndex: 1,\n textAlign: 'center',\n};\n\nexport const errorTitleStyles: React.CSSProperties = {\n fontSize: '1.2em',\n fontWeight: 'bold',\n marginBottom: '10px',\n};\n\nexport const errorMessageStyles: React.CSSProperties = {\n marginBottom: '15px',\n};\n\nexport const retryButtonStyles: React.CSSProperties = {\n padding: '8px 16px',\n backgroundColor: '#1976d2',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n fontSize: '14px',\n};\n\nexport const errorBoundaryContainerStyles: React.CSSProperties = {\n padding: '20px',\n backgroundColor: '#fee',\n border: '1px solid #fcc',\n borderRadius: '4px',\n color: '#c33',\n};\n\nexport const errorBoundaryTitleStyles: React.CSSProperties = {\n marginTop: 0,\n};\n\nexport const errorBoundaryStackStyles: React.CSSProperties = {\n marginTop: '10px',\n padding: '10px',\n backgroundColor: 'white',\n borderRadius: '4px',\n overflow: 'auto',\n};\n\nexport const errorBoundaryRetryButtonStyles: React.CSSProperties = {\n marginTop: '15px',\n padding: '8px 16px',\n backgroundColor: '#c33',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n};\n","import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';\nimport { useInfographic } from '../hooks';\nimport type { InfographicProps, InfographicRef, InfographicError } from '../types';\nimport {\n errorOverlayStyles,\n errorTitleStyles,\n errorMessageStyles,\n retryButtonStyles,\n} from './styles';\n\nconst defaultError: InfographicError = {\n type: 'render',\n message: 'An error occurred while rendering the infographic.',\n};\n\nfunction InfographicComponent(\n props: InfographicProps,\n ref: React.Ref<InfographicRef>,\n) {\n const { children, dsl: dslProp, ...restProps } = props;\n const containerRef = useRef<HTMLDivElement>(null);\n const [error, setError] = useState<InfographicError | null>(null);\n const [errorKey, setErrorKey] = useState(0);\n console.log('children--------------', children)\n const childrenDsl = children ? String(children).trim() : undefined;\n const finalDsl = childrenDsl || dslProp;\n\n if (!finalDsl) {\n throw new Error('Either children or dsl prop must be provided');\n }\n\n const infographicRef = useInfographic(containerRef, {\n ...restProps,\n dsl: finalDsl,\n onError: (err) => {\n setError(err);\n props.onError?.(err);\n },\n });\n\n useImperativeHandle(ref, () => infographicRef, [infographicRef]);\n\n const handleRetry = () => {\n setError(null);\n setErrorKey((prev) => prev + 1);\n };\n\n const containerStyle: React.CSSProperties = {\n width: props.width ?? '100%',\n height: props.height ?? 'auto',\n overflow: 'hidden',\n };\n\n return (\n <>\n <div\n key={`infographic-container-${errorKey}`}\n ref={containerRef}\n className={props.className}\n style={containerStyle}\n data-infographic-container\n />\n {error && (\n <div style={errorOverlayStyles}>\n <div style={errorTitleStyles}>Infographic Render Error</div>\n <div style={errorMessageStyles}>{error.message || defaultError.message}</div>\n <button type=\"button\" onClick={handleRetry} style={retryButtonStyles}>\n Retry\n </button>\n </div>\n )}\n </>\n );\n}\n\nexport const Infographic = forwardRef(InfographicComponent);\n","import { Component, ErrorInfo, ReactNode } from 'react';\nimport {\n errorBoundaryContainerStyles,\n errorBoundaryTitleStyles,\n errorBoundaryStackStyles,\n errorBoundaryRetryButtonStyles,\n} from './styles';\n\ninterface ErrorBoundaryProps {\n children: ReactNode;\n fallback?: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode);\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n error?: Error;\n errorInfo?: ErrorInfo;\n}\n\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n this.setState({ errorInfo });\n this.props.onError?.(error, errorInfo);\n }\n\n handleReset = () => {\n this.setState({ hasError: false, error: undefined, errorInfo: undefined });\n };\n\n render() {\n const { hasError, error, errorInfo } = this.state;\n const { children, fallback } = this.props;\n\n if (!hasError || !error) {\n return children;\n }\n\n if (fallback) {\n if (typeof fallback === 'function') {\n return fallback(error, errorInfo!);\n }\n return fallback;\n }\n\n return (\n <div style={errorBoundaryContainerStyles}>\n <h2 style={errorBoundaryTitleStyles}>Something went wrong</h2>\n <p>{error.message}</p>\n {errorInfo && (\n <details style={{ marginTop: '10px' }}>\n <summary>Stack trace</summary>\n <pre style={errorBoundaryStackStyles}>{errorInfo.componentStack}</pre>\n </details>\n )}\n <button type=\"button\" onClick={this.handleReset} style={errorBoundaryRetryButtonStyles}>\n Try again\n </button>\n </div>\n );\n }\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -9,9 +9,14 @@ function useRenderer(containerRef) {
|
|
|
9
9
|
const pendingListenersRef = useRef(/* @__PURE__ */ new Map());
|
|
10
10
|
const attachedListenersRef = useRef(/* @__PURE__ */ new Map());
|
|
11
11
|
const createRenderer = useCallback(
|
|
12
|
-
async (options) => {
|
|
12
|
+
async (options, container) => {
|
|
13
13
|
const { Infographic: InfographicClass } = await import('@antv/infographic');
|
|
14
|
-
|
|
14
|
+
let renderer;
|
|
15
|
+
if (typeof options === "string") {
|
|
16
|
+
renderer = new InfographicClass(options);
|
|
17
|
+
} else {
|
|
18
|
+
renderer = new InfographicClass({ ...options, container });
|
|
19
|
+
}
|
|
15
20
|
renderer.on("rendered", () => {
|
|
16
21
|
rendererRef.current = renderer;
|
|
17
22
|
isInitializedRef.current = true;
|
|
@@ -25,7 +30,11 @@ function useRenderer(containerRef) {
|
|
|
25
30
|
renderer.on("error", (error) => {
|
|
26
31
|
console.error("[Infographic-for-React] Renderer error:", error);
|
|
27
32
|
});
|
|
28
|
-
|
|
33
|
+
if (typeof options === "string") {
|
|
34
|
+
renderer.render({ container });
|
|
35
|
+
} else {
|
|
36
|
+
renderer.render();
|
|
37
|
+
}
|
|
29
38
|
return renderer;
|
|
30
39
|
},
|
|
31
40
|
[]
|
|
@@ -36,11 +45,14 @@ function useRenderer(containerRef) {
|
|
|
36
45
|
if (!container) {
|
|
37
46
|
throw new Error("Container element not found");
|
|
38
47
|
}
|
|
39
|
-
const renderOptions = { ...options, container };
|
|
40
48
|
if (rendererRef.current) {
|
|
41
|
-
|
|
49
|
+
if (typeof options === "string") {
|
|
50
|
+
rendererRef.current.update(options);
|
|
51
|
+
} else {
|
|
52
|
+
rendererRef.current.update({ ...options, container });
|
|
53
|
+
}
|
|
42
54
|
} else {
|
|
43
|
-
await createRenderer(
|
|
55
|
+
await createRenderer(options, container);
|
|
44
56
|
}
|
|
45
57
|
},
|
|
46
58
|
[containerRef, createRenderer]
|
|
@@ -354,41 +366,52 @@ var RENDER_DEBOUNCE_DELAY = 100;
|
|
|
354
366
|
function useRenderController(containerRef, rendererRender, props, processDSL, onError) {
|
|
355
367
|
const propsRef = useRef(props);
|
|
356
368
|
const dslCacheRef = useRef(null);
|
|
369
|
+
const stringDslCacheRef = useRef(null);
|
|
357
370
|
propsRef.current = props;
|
|
358
371
|
const render = useCallback(async () => {
|
|
359
372
|
const { dsl, width, height, theme, editable, className } = propsRef.current;
|
|
360
373
|
if (!dsl) {
|
|
361
374
|
throw new Error("DSL prop is required");
|
|
362
375
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
renderOptions.theme = processedDSL.theme;
|
|
371
|
-
} else if (theme) {
|
|
372
|
-
renderOptions.theme = theme;
|
|
373
|
-
}
|
|
374
|
-
if (palette) {
|
|
375
|
-
const existingThemeConfig = processedDSL.themeConfig || {};
|
|
376
|
-
renderOptions.themeConfig = {
|
|
377
|
-
...existingThemeConfig,
|
|
378
|
-
palette
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
if (editable !== void 0) {
|
|
382
|
-
renderOptions.editable = editable;
|
|
376
|
+
if (containerRef.current && className) {
|
|
377
|
+
containerRef.current.className = className;
|
|
378
|
+
}
|
|
379
|
+
if (typeof dsl === "string") {
|
|
380
|
+
const trimmedDsl = dsl.trim();
|
|
381
|
+
if (!trimmedDsl) {
|
|
382
|
+
throw new Error("String DSL cannot be empty or contain only whitespace");
|
|
383
383
|
}
|
|
384
|
-
if (
|
|
385
|
-
|
|
386
|
-
|
|
384
|
+
if (stringDslCacheRef.current !== trimmedDsl) {
|
|
385
|
+
stringDslCacheRef.current = trimmedDsl;
|
|
386
|
+
rendererRender(trimmedDsl);
|
|
387
387
|
}
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
} else {
|
|
389
|
+
const processedDSL = await processDSL(dsl);
|
|
390
|
+
const dslString = JSON.stringify(processedDSL);
|
|
391
|
+
if (dslCacheRef.current !== dslString) {
|
|
392
|
+
dslCacheRef.current = dslString;
|
|
393
|
+
const { palette, ...restDSL } = processedDSL;
|
|
394
|
+
const renderOptions = {
|
|
395
|
+
...restDSL,
|
|
396
|
+
data: processedDSL.data,
|
|
397
|
+
width,
|
|
398
|
+
height,
|
|
399
|
+
editable
|
|
400
|
+
};
|
|
401
|
+
if (processedDSL.theme) {
|
|
402
|
+
renderOptions.theme = processedDSL.theme;
|
|
403
|
+
} else if (theme) {
|
|
404
|
+
renderOptions.theme = theme;
|
|
405
|
+
}
|
|
406
|
+
if (palette) {
|
|
407
|
+
const existingThemeConfig = processedDSL.themeConfig || {};
|
|
408
|
+
renderOptions.themeConfig = {
|
|
409
|
+
...existingThemeConfig,
|
|
410
|
+
palette
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
rendererRender(renderOptions);
|
|
390
414
|
}
|
|
391
|
-
rendererRender(renderOptions);
|
|
392
415
|
}
|
|
393
416
|
}, [containerRef, rendererRender, processDSL]);
|
|
394
417
|
const debouncedRender = useCallback(
|
|
@@ -406,6 +429,10 @@ function useRefMethods(update, { processDSL, theme }) {
|
|
|
406
429
|
themeRef.current = theme;
|
|
407
430
|
const refUpdate = useCallback(
|
|
408
431
|
async (options) => {
|
|
432
|
+
if (typeof options === "string") {
|
|
433
|
+
update(options);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
409
436
|
const processed = await processDSL(options);
|
|
410
437
|
const { palette, ...restProcessed } = processed;
|
|
411
438
|
const themeConfig = processed.themeConfig || {};
|
|
@@ -453,7 +480,7 @@ function useInfographic(containerRef, props) {
|
|
|
453
480
|
props.onError?.(infographicError);
|
|
454
481
|
}
|
|
455
482
|
);
|
|
456
|
-
const { refUpdate } = useRefMethods(update, { processDSL, theme: props.theme });
|
|
483
|
+
const { refUpdate } = useRefMethods((options) => update(options), { processDSL, theme: props.theme });
|
|
457
484
|
useEffect(() => {
|
|
458
485
|
on("rendered", handleRendered);
|
|
459
486
|
on("loaded", handleRendered);
|
|
@@ -539,11 +566,19 @@ var defaultError = {
|
|
|
539
566
|
message: "An error occurred while rendering the infographic."
|
|
540
567
|
};
|
|
541
568
|
function InfographicComponent(props, ref) {
|
|
569
|
+
const { children, dsl: dslProp, ...restProps } = props;
|
|
542
570
|
const containerRef = useRef(null);
|
|
543
571
|
const [error, setError] = useState(null);
|
|
544
572
|
const [errorKey, setErrorKey] = useState(0);
|
|
573
|
+
console.log("children--------------", children);
|
|
574
|
+
const childrenDsl = children ? String(children).trim() : void 0;
|
|
575
|
+
const finalDsl = childrenDsl || dslProp;
|
|
576
|
+
if (!finalDsl) {
|
|
577
|
+
throw new Error("Either children or dsl prop must be provided");
|
|
578
|
+
}
|
|
545
579
|
const infographicRef = useInfographic(containerRef, {
|
|
546
|
-
...
|
|
580
|
+
...restProps,
|
|
581
|
+
dsl: finalDsl,
|
|
547
582
|
onError: (err) => {
|
|
548
583
|
setError(err);
|
|
549
584
|
props.onError?.(err);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useRenderer.ts","../src/utils/path.ts","../src/utils/dsl/merge.ts","../src/utils/dsl/compose.ts","../src/utils/error.ts","../src/hooks/useDSLProcessor.ts","../src/hooks/useRenderCallback.ts","../src/constants/index.ts","../src/hooks/useRenderController.ts","../src/hooks/useRefMethods.ts","../src/hooks/useInfographic.ts","../src/components/styles.ts","../src/components/Infographic.tsx","../src/components/ErrorBoundary.tsx"],"names":["listeners","useRef","useCallback","useEffect","jsxs","jsx"],"mappings":";;;;;AAOO,SAAS,YAAY,YAAA,EAA4C;AACtE,EAAA,MAAM,WAAA,GAAc,OAAgC,IAAI,CAAA;AACxD,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K,WAAA,EAAa,KAAA,EAAO,8BAAA,EAAgC,QAAA,EAAA,WAAA,EAExF;AAAA,KAAA,EACF,CAAA;AAAA,EAEJ;AACF","file":"index.mjs","sourcesContent":["import { useEffect, useRef, useCallback } from 'react';\nimport type {\n InfographicOptions,\n RendererInstance,\n ExportOptions,\n} from '../types';\n\nexport function useRenderer(containerRef: React.RefObject<HTMLElement>) {\n const rendererRef = useRef<RendererInstance | null>(null);\n const isInitializedRef = useRef(false);\n const pendingListenersRef = useRef<Map<string, Set<(...args: any[]) => void>>>(new Map());\n const attachedListenersRef = useRef<Map<string, Set<(...args: any[]) => void>>>(new Map());\n\n const createRenderer = useCallback(\n async (options: Partial<InfographicOptions>): Promise<RendererInstance> => {\n const { Infographic: InfographicClass } = await import('@antv/infographic');\n const renderer = new InfographicClass(options);\n\n renderer.on('rendered', () => {\n rendererRef.current = renderer;\n isInitializedRef.current = true;\n\n pendingListenersRef.current.forEach((listeners, event) => {\n listeners.forEach((listener) => {\n renderer.on(event, listener);\n });\n });\n pendingListenersRef.current.clear();\n });\n\n renderer.on('error', (error) => {\n console.error('[Infographic-for-React] Renderer error:', error);\n });\n\n renderer.render();\n\n return renderer;\n },\n [],\n );\n\n const render = useCallback(\n async (options: Partial<InfographicOptions>) => {\n const container = containerRef.current;\n if (!container) {\n throw new Error('Container element not found');\n }\n\n const renderOptions = { ...options, container };\n\n if (rendererRef.current) {\n rendererRef.current.update(renderOptions);\n } else {\n await createRenderer(renderOptions);\n }\n },\n [containerRef, createRenderer],\n );\n\n const update = useCallback((options: Partial<InfographicOptions>) => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized. Call render first.');\n }\n rendererRef.current.update(options);\n }, []);\n\n const toDataURL = useCallback(\n (options?: ExportOptions): Promise<string> => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized');\n }\n return rendererRef.current.toDataURL(options);\n },\n [],\n );\n\n const getTypes = useCallback(() => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized');\n }\n return rendererRef.current.getTypes();\n }, []);\n\n const destroy = useCallback(() => {\n if (rendererRef.current) {\n attachedListenersRef.current.forEach((listeners, event) => {\n listeners.forEach((listener) => {\n rendererRef.current?.off(event, listener);\n });\n });\n attachedListenersRef.current.clear();\n\n rendererRef.current.destroy();\n rendererRef.current = null;\n }\n isInitializedRef.current = false;\n }, []);\n\n const on = useCallback((event: string, listener: (...args: any[]) => void) => {\n if (!rendererRef.current) {\n const listeners = pendingListenersRef.current.get(event) || new Set();\n listeners.add(listener);\n pendingListenersRef.current.set(event, listeners);\n return;\n }\n const listeners = attachedListenersRef.current.get(event) || new Set();\n listeners.add(listener);\n attachedListenersRef.current.set(event, listeners);\n rendererRef.current.on(event, listener);\n }, []);\n\n const off = useCallback((event: string, listener: (...args: any[]) => void) => {\n if (!rendererRef.current) {\n const listeners = pendingListenersRef.current.get(event);\n if (listeners) {\n listeners.delete(listener);\n if (listeners.size === 0) {\n pendingListenersRef.current.delete(event);\n }\n }\n return;\n }\n rendererRef.current.off(event, listener);\n const listeners = attachedListenersRef.current.get(event);\n if (listeners) {\n listeners.delete(listener);\n if (listeners.size === 0) {\n attachedListenersRef.current.delete(event);\n }\n }\n }, []);\n\n useEffect(() => {\n return () => {\n destroy();\n };\n }, [destroy]);\n\n return {\n render,\n update,\n toDataURL,\n getTypes,\n destroy,\n on,\n off,\n isReady: isInitializedRef.current,\n };\n}\n","export interface PathSegment {\n type: 'key' | 'index';\n value: string | number;\n}\n\nfunction parsePath(path: string): PathSegment[] {\n const segments: PathSegment[] = [];\n const regex = /([^.[\\]]+)|\\[(\\d+)\\]/g;\n let match;\n\n while ((match = regex.exec(path)) !== null) {\n if (match[1] !== undefined) {\n segments.push({ type: 'key', value: match[1] });\n } else if (match[2] !== undefined) {\n segments.push({ type: 'index', value: parseInt(match[2], 10) });\n }\n }\n\n return segments;\n}\n\nexport function setByPath(obj: Record<string, unknown>, path: string, value: unknown): void {\n const segments = parsePath(path);\n\n if (segments.length === 0) {\n throw new Error(`Invalid path: ${path}`);\n }\n\n let current: unknown = obj;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n const isLast = i === segments.length - 1;\n\n if (typeof current !== 'object' || current === null) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n\n if (segment.type === 'key') {\n const currentObj = current as Record<string, unknown>;\n if (isLast) {\n currentObj[segment.value] = value;\n } else {\n const nextValue = currentObj[segment.value];\n if (nextValue !== undefined && (typeof nextValue !== 'object' || nextValue === null)) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n if (typeof nextValue !== 'object' || nextValue === null) {\n currentObj[segment.value] = {};\n }\n current = currentObj[segment.value];\n }\n } else {\n const currentArray = current as unknown[];\n if (!Array.isArray(currentArray)) {\n throw new Error(`Cannot access array index at path \"${path}\": parent is not an array`);\n }\n const index = segment.value as number;\n if (isLast) {\n currentArray[index] = value;\n } else {\n const nextValue = currentArray[index];\n if (nextValue !== undefined && (typeof nextValue !== 'object' || nextValue === null)) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n if (typeof nextValue !== 'object' || nextValue === null) {\n currentArray[index] = {};\n }\n current = currentArray[index];\n }\n }\n }\n}\n\nexport function getByPath(obj: Record<string, unknown>, path: string): unknown {\n const segments = parsePath(path);\n\n if (segments.length === 0) {\n return undefined;\n }\n\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (typeof current !== 'object' || current === null) {\n return undefined;\n }\n\n if (segment.type === 'key') {\n current = (current as Record<string, unknown>)[segment.value];\n } else {\n if (!Array.isArray(current)) {\n return undefined;\n }\n const index = segment.value as number;\n current = current[index];\n }\n }\n\n return current;\n}\n","import type { DSLOverride, DSLObject } from '../../types';\nimport { setByPath } from '../path';\n\nexport function applyOverrides(base: DSLObject, overrides: DSLOverride[]): DSLObject {\n if (overrides.length === 0) return base;\n\n const result = { ...base };\n\n for (const override of overrides) {\n setByPath(result as Record<string, unknown>, override.path, override.value);\n }\n\n return result;\n}\n\nexport function mergeDSL(dsl1: DSLObject, dsl2: DSLObject): DSLObject {\n const merged = deepMerge(dsl1 as unknown as Record<string, unknown>, dsl2 as unknown as Record<string, unknown>);\n return merged as unknown as DSLObject;\n}\n\nfunction deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...target };\n\n for (const key in source) {\n if (source[key] === undefined) {\n continue;\n }\n\n const value = source[key];\n\n if (value === null) {\n result[key] = null;\n continue;\n }\n\n const targetValue = result[key];\n\n if (typeof value === 'object' && !Array.isArray(value) && targetValue && typeof targetValue === 'object' && !Array.isArray(targetValue)) {\n result[key] = deepMerge(targetValue as Record<string, unknown>, value as Record<string, unknown>);\n } else {\n result[key] = value;\n }\n }\n\n return result;\n}\n","import type { ComposeTemplateOptions, DSLObject } from '../../types';\nimport { applyOverrides } from './merge';\n\ninterface DSLNode {\n type?: string;\n data?: unknown;\n props?: Record<string, unknown>;\n children?: DSLNode[];\n [key: string]: unknown;\n}\n\nfunction isContainerNode(node: unknown): node is DSLNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'children' in node &&\n Array.isArray((node as DSLNode).children)\n );\n}\n\nexport function composeTemplates(options: ComposeTemplateOptions): DSLObject {\n const { templates, overrides = [] } = options;\n\n if (templates.length === 0) {\n throw new Error('At least one template is required');\n }\n\n if (templates.length === 1) {\n const base = templates[0];\n if (overrides.length > 0) {\n return applyOverrides(base, overrides);\n }\n return base;\n }\n\n const root = templates[0] as DSLNode;\n\n if (!isContainerNode(root)) {\n throw new Error('Root template must be a container node with children');\n }\n\n let currentChildren = root.children || [];\n\n for (let i = 1; i < templates.length; i++) {\n const template = templates[i] as DSLNode;\n\n if (isContainerNode(template) && template.children) {\n currentChildren = [...currentChildren, ...template.children];\n } else {\n currentChildren.push(template);\n }\n }\n\n root.children = currentChildren;\n\n let composed = root as DSLObject;\n\n if (overrides.length > 0) {\n composed = applyOverrides(composed, overrides);\n }\n\n return composed;\n}\n","import type { InfographicError } from '../types';\n\nexport function createInfographicError(\n type: InfographicError['type'],\n message: string,\n dsl?: string,\n details?: Error | unknown,\n): InfographicError {\n return {\n type,\n message,\n dsl,\n details,\n };\n}\n\nexport function isInfographicError(error: unknown): error is InfographicError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'type' in error &&\n 'message' in error &&\n ['syntax', 'render', 'runtime'].includes((error as InfographicError).type)\n );\n}\n\nexport function formatErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n}\n","import { useCallback, useRef } from 'react';\nimport { applyOverrides } from '../utils/dsl';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type {\n InfographicError,\n DSLObject,\n PreRenderHook,\n DSLOverride,\n} from '../types';\n\ninterface DSLProcessorOptions {\n overrides?: DSLOverride[];\n beforeRender?: PreRenderHook;\n onError?: (error: InfographicError) => void;\n}\n\nexport function useDSLProcessor(options: DSLProcessorOptions) {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const processDSL = useCallback(\n async (input: DSLObject): Promise<DSLObject> => {\n let processed: DSLObject = input;\n const { overrides, beforeRender } = optionsRef.current;\n\n if (overrides && overrides.length > 0) {\n try {\n processed = applyOverrides(processed, overrides);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'syntax',\n `Failed to apply overrides: ${formatErrorMessage(error)}`,\n JSON.stringify(processed),\n error,\n );\n optionsRef.current.onError?.(infographicError);\n throw infographicError;\n }\n }\n\n if (beforeRender) {\n try {\n processed = await beforeRender(processed);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'runtime',\n `beforeRender hook failed: ${formatErrorMessage(error)}`,\n JSON.stringify(processed),\n error,\n );\n optionsRef.current.onError?.(infographicError);\n throw infographicError;\n }\n }\n\n return processed;\n },\n [],\n );\n\n return { processDSL };\n}\n","import { useCallback, useRef } from 'react';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type { InfographicError, InfographicRenderResult, PostRenderHook } from '../types';\n\ninterface RenderCallbackOptions {\n afterRender?: PostRenderHook;\n onRender?: (result: InfographicRenderResult) => void;\n onLoad?: (result: InfographicRenderResult) => void;\n onError?: (error: InfographicError) => void;\n}\n\nexport function useRenderCallback(options: RenderCallbackOptions) {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const handleRendered = useCallback(\n async (result: InfographicRenderResult) => {\n const { afterRender, onRender, onLoad } = optionsRef.current;\n\n if (afterRender) {\n try {\n await afterRender(result);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'runtime',\n `afterRender hook failed: ${formatErrorMessage(error)}`,\n undefined,\n error,\n );\n optionsRef.current.onError?.(infographicError);\n return;\n }\n }\n\n onRender?.(result);\n onLoad?.(result);\n },\n [],\n );\n\n return { handleRendered };\n}\n","export const RENDER_DEBOUNCE_DELAY = 100;\n","import { useCallback, useRef } from 'react';\nimport { debounce } from 'lodash-es';\nimport { RENDER_DEBOUNCE_DELAY } from '../constants';\nimport type {\n DSLInput,\n DSLObject,\n InfographicOptions,\n ThemeConfig,\n} from '../types';\n\ninterface RenderControllerProps {\n dsl?: DSLInput;\n width?: number | string;\n height?: number | string;\n theme?: string;\n editable?: boolean;\n className?: string;\n}\n\nexport function useRenderController(\n containerRef: React.RefObject<HTMLElement>,\n rendererRender: (options: Partial<InfographicOptions>) => void,\n props: RenderControllerProps,\n processDSL: (input: DSLObject) => Promise<DSLObject>,\n onError?: (error: unknown) => void,\n) {\n const propsRef = useRef(props);\n const dslCacheRef = useRef<string | null>(null);\n\n propsRef.current = props;\n\n const render = useCallback(async () => {\n const { dsl, width, height, theme, editable, className } = propsRef.current;\n\n if (!dsl) {\n throw new Error('DSL prop is required');\n }\n\n const processedDSL: DSLObject = await processDSL(dsl);\n\n const dslString = JSON.stringify(processedDSL);\n if (dslCacheRef.current !== dslString) {\n dslCacheRef.current = dslString;\n\n const { palette, ...restDSL } = processedDSL;\n\n const renderOptions: Partial<InfographicOptions> = { ...restDSL, data: processedDSL.data };\n\n if (processedDSL.theme) {\n renderOptions.theme = processedDSL.theme;\n } else if (theme) {\n renderOptions.theme = theme;\n }\n\n if (palette) {\n const existingThemeConfig = (processedDSL.themeConfig || {}) as ThemeConfig;\n renderOptions.themeConfig = {\n ...existingThemeConfig,\n palette,\n };\n }\n\n if (editable !== undefined) {\n renderOptions.editable = editable;\n }\n\n if (width || height) {\n renderOptions.width = width;\n renderOptions.height = height;\n }\n\n if (containerRef.current && className) {\n containerRef.current.className = className;\n }\n\n rendererRender(renderOptions);\n }\n }, [containerRef, rendererRender, processDSL]);\n\n const debouncedRender = useCallback(\n debounce(() => {\n render().catch((error) => {\n onError?.(error);\n });\n }, RENDER_DEBOUNCE_DELAY),\n [render, onError],\n );\n\n return { debouncedRender };\n}\n","import { useCallback, useRef } from 'react';\nimport type { DSLInput, DSLObject, InfographicOptions, Palette, ThemeConfig } from '../types';\n\ninterface RefMethodsProps {\n processDSL: (input: DSLObject) => Promise<DSLObject>;\n theme?: string;\n}\n\nexport function useRefMethods(\n update: (options: Partial<InfographicOptions>) => void,\n { processDSL, theme }: RefMethodsProps,\n) {\n const themeRef = useRef(theme);\n themeRef.current = theme;\n\n const refUpdate = useCallback(\n async (options: DSLInput) => {\n const processed: DSLObject = await processDSL(options);\n const { palette, ...restProcessed } = processed;\n const themeConfig = (processed.themeConfig || {}) as ThemeConfig;\n\n if (palette) {\n themeConfig.palette = palette as Palette;\n }\n\n const renderOptions: Partial<InfographicOptions> = {\n ...restProcessed,\n theme: processed.theme ?? themeRef.current,\n themeConfig,\n };\n\n update(renderOptions);\n },\n [update, processDSL],\n );\n\n return { refUpdate };\n}\n","import { useEffect } from 'react';\nimport { useRenderer } from './useRenderer';\nimport { useDSLProcessor } from './useDSLProcessor';\nimport { useRenderCallback } from './useRenderCallback';\nimport { useRenderController } from './useRenderController';\nimport { useRefMethods } from './useRefMethods';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type {\n InfographicProps,\n InfographicRef,\n InfographicError,\n} from '../types';\n\nexport function useInfographic(\n containerRef: React.RefObject<HTMLElement>,\n props: InfographicProps,\n) {\n const { render: rendererRender, update, toDataURL, getTypes, destroy, on, off } = useRenderer(containerRef);\n\n const { processDSL } = useDSLProcessor({\n overrides: props.overrides,\n beforeRender: props.beforeRender,\n onError: props.onError,\n });\n\n const { handleRendered } = useRenderCallback({\n afterRender: props.afterRender,\n onRender: props.onRender,\n onLoad: props.onLoad,\n onError: props.onError,\n });\n\n const { debouncedRender } = useRenderController(\n containerRef,\n rendererRender,\n props,\n processDSL,\n (error) => {\n const infographicError: InfographicError = createInfographicError(\n 'render',\n formatErrorMessage(error),\n undefined,\n error,\n );\n props.onError?.(infographicError);\n },\n );\n\n const { refUpdate } = useRefMethods(update, { processDSL, theme: props.theme });\n\n useEffect(() => {\n on('rendered', handleRendered);\n on('loaded', handleRendered);\n\n return () => {\n off('rendered', handleRendered);\n off('loaded', handleRendered);\n };\n }, [on, off, handleRendered]);\n\n useEffect(() => {\n debouncedRender();\n return debouncedRender.cancel;\n }, [debouncedRender]);\n\n const ref: InfographicRef = {\n toDataURL,\n getTypes,\n update: refUpdate,\n destroy,\n };\n\n return ref;\n}\n","export const errorOverlayStyles: React.CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'rgba(0, 0, 0, 0.05)',\n color: '#d32f2f',\n padding: '20px',\n zIndex: 1,\n textAlign: 'center',\n};\n\nexport const errorTitleStyles: React.CSSProperties = {\n fontSize: '1.2em',\n fontWeight: 'bold',\n marginBottom: '10px',\n};\n\nexport const errorMessageStyles: React.CSSProperties = {\n marginBottom: '15px',\n};\n\nexport const retryButtonStyles: React.CSSProperties = {\n padding: '8px 16px',\n backgroundColor: '#1976d2',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n fontSize: '14px',\n};\n\nexport const errorBoundaryContainerStyles: React.CSSProperties = {\n padding: '20px',\n backgroundColor: '#fee',\n border: '1px solid #fcc',\n borderRadius: '4px',\n color: '#c33',\n};\n\nexport const errorBoundaryTitleStyles: React.CSSProperties = {\n marginTop: 0,\n};\n\nexport const errorBoundaryStackStyles: React.CSSProperties = {\n marginTop: '10px',\n padding: '10px',\n backgroundColor: 'white',\n borderRadius: '4px',\n overflow: 'auto',\n};\n\nexport const errorBoundaryRetryButtonStyles: React.CSSProperties = {\n marginTop: '15px',\n padding: '8px 16px',\n backgroundColor: '#c33',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n};\n","import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';\nimport { useInfographic } from '../hooks';\nimport type { InfographicProps, InfographicRef, InfographicError } from '../types';\nimport {\n errorOverlayStyles,\n errorTitleStyles,\n errorMessageStyles,\n retryButtonStyles,\n} from './styles';\n\nconst defaultError: InfographicError = {\n type: 'render',\n message: 'An error occurred while rendering the infographic.',\n};\n\nfunction InfographicComponent(\n props: InfographicProps,\n ref: React.Ref<InfographicRef>,\n) {\n const containerRef = useRef<HTMLDivElement>(null);\n const [error, setError] = useState<InfographicError | null>(null);\n const [errorKey, setErrorKey] = useState(0);\n\n const infographicRef = useInfographic(containerRef, {\n ...props,\n onError: (err) => {\n setError(err);\n props.onError?.(err);\n },\n });\n\n useImperativeHandle(ref, () => infographicRef, [infographicRef]);\n\n const handleRetry = () => {\n setError(null);\n setErrorKey((prev) => prev + 1);\n };\n\n const containerStyle: React.CSSProperties = {\n width: props.width ?? '100%',\n height: props.height ?? 'auto',\n overflow: 'hidden',\n };\n\n return (\n <>\n <div\n key={`infographic-container-${errorKey}`}\n ref={containerRef}\n className={props.className}\n style={containerStyle}\n data-infographic-container\n />\n {error && (\n <div style={errorOverlayStyles}>\n <div style={errorTitleStyles}>Infographic Render Error</div>\n <div style={errorMessageStyles}>{error.message || defaultError.message}</div>\n <button type=\"button\" onClick={handleRetry} style={retryButtonStyles}>\n Retry\n </button>\n </div>\n )}\n </>\n );\n}\n\nexport const Infographic = forwardRef(InfographicComponent);\n","import { Component, ErrorInfo, ReactNode } from 'react';\nimport {\n errorBoundaryContainerStyles,\n errorBoundaryTitleStyles,\n errorBoundaryStackStyles,\n errorBoundaryRetryButtonStyles,\n} from './styles';\n\ninterface ErrorBoundaryProps {\n children: ReactNode;\n fallback?: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode);\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n error?: Error;\n errorInfo?: ErrorInfo;\n}\n\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n this.setState({ errorInfo });\n this.props.onError?.(error, errorInfo);\n }\n\n handleReset = () => {\n this.setState({ hasError: false, error: undefined, errorInfo: undefined });\n };\n\n render() {\n const { hasError, error, errorInfo } = this.state;\n const { children, fallback } = this.props;\n\n if (!hasError || !error) {\n return children;\n }\n\n if (fallback) {\n if (typeof fallback === 'function') {\n return fallback(error, errorInfo!);\n }\n return fallback;\n }\n\n return (\n <div style={errorBoundaryContainerStyles}>\n <h2 style={errorBoundaryTitleStyles}>Something went wrong</h2>\n <p>{error.message}</p>\n {errorInfo && (\n <details style={{ marginTop: '10px' }}>\n <summary>Stack trace</summary>\n <pre style={errorBoundaryStackStyles}>{errorInfo.componentStack}</pre>\n </details>\n )}\n <button type=\"button\" onClick={this.handleReset} style={errorBoundaryRetryButtonStyles}>\n Try again\n </button>\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useRenderer.ts","../src/utils/path.ts","../src/utils/dsl/merge.ts","../src/utils/dsl/compose.ts","../src/utils/error.ts","../src/hooks/useDSLProcessor.ts","../src/hooks/useRenderCallback.ts","../src/constants/index.ts","../src/hooks/useRenderController.ts","../src/hooks/useRefMethods.ts","../src/hooks/useInfographic.ts","../src/components/styles.ts","../src/components/Infographic.tsx","../src/components/ErrorBoundary.tsx"],"names":["listeners","useRef","useCallback","useEffect","jsxs","jsx"],"mappings":";;;;;AAOO,SAAS,YAAY,YAAA,EAA4C;AACtE,EAAA,MAAM,WAAA,GAAc,OAAgC,IAAI,CAAA;AACxD,EAAA,MAAM,gBAAA,GAAmB,OAAO,KAAK,CAAA;AACrC,EAAA,MAAM,mBAAA,GAAsB,MAAA,iBAAmD,IAAI,GAAA,EAAK,CAAA;AACxF,EAAA,MAAM,oBAAA,GAAuB,MAAA,iBAAmD,IAAI,GAAA,EAAK,CAAA;AAEzF,EAAA,MAAM,cAAA,GAAiB,WAAA;AAAA,IACrB,OAAO,SAA+C,SAAA,KAAsD;AAC1G,MAAA,MAAM,EAAE,WAAA,EAAa,gBAAA,EAAiB,GAAI,MAAM,OAAO,mBAAmB,CAAA;AAE1E,MAAA,IAAI,QAAA;AAEJ,MAAA,IAAI,OAAO,YAAY,QAAA,EAAU;AAC/B,QAAA,QAAA,GAAW,IAAI,iBAAiB,OAAO,CAAA;AAAA,MACzC,CAAA,MAAO;AACL,QAAA,QAAA,GAAW,IAAI,gBAAA,CAAiB,EAAE,GAAG,OAAA,EAAS,WAAW,CAAA;AAAA,MAC3D;AAEA,MAAA,QAAA,CAAS,EAAA,CAAG,YAAY,MAAM;AAC5B,QAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AACtB,QAAA,gBAAA,CAAiB,OAAA,GAAU,IAAA;AAE3B,QAAA,mBAAA,CAAoB,OAAA,CAAQ,OAAA,CAAQ,CAAC,SAAA,EAAW,KAAA,KAAU;AACxD,UAAA,SAAA,CAAU,OAAA,CAAQ,CAAC,QAAA,KAAa;AAC9B,YAAA,QAAA,CAAS,EAAA,CAAG,OAAO,QAAQ,CAAA;AAAA,UAC7B,CAAC,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wBAAAC,GAAAA,CAAC,aAAQ,QAAA,EAAA,aAAA,EAAW,CAAA;AAAA,wBACpBA,GAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,wBAAA,EAA2B,oBAAU,cAAA,EAAe;AAAA,OAAA,EAClE,CAAA;AAAA,sBAEFA,GAAAA,CAAC,QAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EAAS,SAAS,IAAA,CAAK,WAAA,EAAa,KAAA,EAAO,8BAAA,EAAgC,QAAA,EAAA,WAAA,EAExF;AAAA,KAAA,EACF,CAAA;AAAA,EAEJ;AACF","file":"index.mjs","sourcesContent":["import { useEffect, useRef, useCallback } from 'react';\nimport type {\n InfographicOptions,\n RendererInstance,\n ExportOptions,\n} from '../types';\n\nexport function useRenderer(containerRef: React.RefObject<HTMLElement>) {\n const rendererRef = useRef<RendererInstance | null>(null);\n const isInitializedRef = useRef(false);\n const pendingListenersRef = useRef<Map<string, Set<(...args: any[]) => void>>>(new Map());\n const attachedListenersRef = useRef<Map<string, Set<(...args: any[]) => void>>>(new Map());\n\n const createRenderer = useCallback(\n async (options: string | Partial<InfographicOptions>, container: HTMLElement): Promise<RendererInstance> => {\n const { Infographic: InfographicClass } = await import('@antv/infographic');\n\n let renderer: RendererInstance;\n\n if (typeof options === 'string') {\n renderer = new InfographicClass(options);\n } else {\n renderer = new InfographicClass({ ...options, container });\n }\n\n renderer.on('rendered', () => {\n rendererRef.current = renderer;\n isInitializedRef.current = true;\n\n pendingListenersRef.current.forEach((listeners, event) => {\n listeners.forEach((listener) => {\n renderer.on(event, listener);\n });\n });\n pendingListenersRef.current.clear();\n });\n\n renderer.on('error', (error) => {\n console.error('[Infographic-for-React] Renderer error:', error);\n });\n\n if (typeof options === 'string') {\n renderer.render({ container });\n } else {\n renderer.render();\n }\n\n return renderer;\n },\n [],\n );\n\n const render = useCallback(\n async (options: string | Partial<InfographicOptions>) => {\n const container = containerRef.current;\n if (!container) {\n throw new Error('Container element not found');\n }\n\n if (rendererRef.current) {\n if (typeof options === 'string') {\n rendererRef.current.update(options);\n } else {\n rendererRef.current.update({ ...options, container });\n }\n } else {\n await createRenderer(options, container);\n }\n },\n [containerRef, createRenderer],\n );\n\n const update = useCallback((options: string | Partial<InfographicOptions>) => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized. Call render first.');\n }\n rendererRef.current.update(options);\n }, []);\n\n const toDataURL = useCallback(\n (options?: ExportOptions): Promise<string> => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized');\n }\n return rendererRef.current.toDataURL(options);\n },\n [],\n );\n\n const getTypes = useCallback(() => {\n if (!rendererRef.current) {\n throw new Error('Renderer not initialized');\n }\n return rendererRef.current.getTypes();\n }, []);\n\n const destroy = useCallback(() => {\n if (rendererRef.current) {\n attachedListenersRef.current.forEach((listeners, event) => {\n listeners.forEach((listener) => {\n rendererRef.current?.off(event, listener);\n });\n });\n attachedListenersRef.current.clear();\n\n rendererRef.current.destroy();\n rendererRef.current = null;\n }\n isInitializedRef.current = false;\n }, []);\n\n const on = useCallback((event: string, listener: (...args: any[]) => void) => {\n if (!rendererRef.current) {\n const listeners = pendingListenersRef.current.get(event) || new Set();\n listeners.add(listener);\n pendingListenersRef.current.set(event, listeners);\n return;\n }\n const listeners = attachedListenersRef.current.get(event) || new Set();\n listeners.add(listener);\n attachedListenersRef.current.set(event, listeners);\n rendererRef.current.on(event, listener);\n }, []);\n\n const off = useCallback((event: string, listener: (...args: any[]) => void) => {\n if (!rendererRef.current) {\n const listeners = pendingListenersRef.current.get(event);\n if (listeners) {\n listeners.delete(listener);\n if (listeners.size === 0) {\n pendingListenersRef.current.delete(event);\n }\n }\n return;\n }\n rendererRef.current.off(event, listener);\n const listeners = attachedListenersRef.current.get(event);\n if (listeners) {\n listeners.delete(listener);\n if (listeners.size === 0) {\n attachedListenersRef.current.delete(event);\n }\n }\n }, []);\n\n useEffect(() => {\n return () => {\n destroy();\n };\n }, [destroy]);\n\n return {\n render,\n update,\n toDataURL,\n getTypes,\n destroy,\n on,\n off,\n isReady: isInitializedRef.current,\n };\n}\n","export interface PathSegment {\n type: 'key' | 'index';\n value: string | number;\n}\n\nfunction parsePath(path: string): PathSegment[] {\n const segments: PathSegment[] = [];\n const regex = /([^.[\\]]+)|\\[(\\d+)\\]/g;\n let match;\n\n while ((match = regex.exec(path)) !== null) {\n if (match[1] !== undefined) {\n segments.push({ type: 'key', value: match[1] });\n } else if (match[2] !== undefined) {\n segments.push({ type: 'index', value: parseInt(match[2], 10) });\n }\n }\n\n return segments;\n}\n\nexport function setByPath(obj: Record<string, unknown>, path: string, value: unknown): void {\n const segments = parsePath(path);\n\n if (segments.length === 0) {\n throw new Error(`Invalid path: ${path}`);\n }\n\n let current: unknown = obj;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n const isLast = i === segments.length - 1;\n\n if (typeof current !== 'object' || current === null) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n\n if (segment.type === 'key') {\n const currentObj = current as Record<string, unknown>;\n if (isLast) {\n currentObj[segment.value] = value;\n } else {\n const nextValue = currentObj[segment.value];\n if (nextValue !== undefined && (typeof nextValue !== 'object' || nextValue === null)) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n if (typeof nextValue !== 'object' || nextValue === null) {\n currentObj[segment.value] = {};\n }\n current = currentObj[segment.value];\n }\n } else {\n const currentArray = current as unknown[];\n if (!Array.isArray(currentArray)) {\n throw new Error(`Cannot access array index at path \"${path}\": parent is not an array`);\n }\n const index = segment.value as number;\n if (isLast) {\n currentArray[index] = value;\n } else {\n const nextValue = currentArray[index];\n if (nextValue !== undefined && (typeof nextValue !== 'object' || nextValue === null)) {\n throw new Error(`Cannot set property at path \"${path}\": cannot navigate through non-object`);\n }\n if (typeof nextValue !== 'object' || nextValue === null) {\n currentArray[index] = {};\n }\n current = currentArray[index];\n }\n }\n }\n}\n\nexport function getByPath(obj: Record<string, unknown>, path: string): unknown {\n const segments = parsePath(path);\n\n if (segments.length === 0) {\n return undefined;\n }\n\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (typeof current !== 'object' || current === null) {\n return undefined;\n }\n\n if (segment.type === 'key') {\n current = (current as Record<string, unknown>)[segment.value];\n } else {\n if (!Array.isArray(current)) {\n return undefined;\n }\n const index = segment.value as number;\n current = current[index];\n }\n }\n\n return current;\n}\n","import type { DSLOverride, DSLObject } from '../../types';\nimport { setByPath } from '../path';\n\nexport function applyOverrides(base: DSLObject, overrides: DSLOverride[]): DSLObject {\n if (overrides.length === 0) return base;\n\n const result = { ...base };\n\n for (const override of overrides) {\n setByPath(result as Record<string, unknown>, override.path, override.value);\n }\n\n return result;\n}\n\nexport function mergeDSL(dsl1: DSLObject, dsl2: DSLObject): DSLObject {\n const merged = deepMerge(dsl1 as unknown as Record<string, unknown>, dsl2 as unknown as Record<string, unknown>);\n return merged as unknown as DSLObject;\n}\n\nfunction deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...target };\n\n for (const key in source) {\n if (source[key] === undefined) {\n continue;\n }\n\n const value = source[key];\n\n if (value === null) {\n result[key] = null;\n continue;\n }\n\n const targetValue = result[key];\n\n if (typeof value === 'object' && !Array.isArray(value) && targetValue && typeof targetValue === 'object' && !Array.isArray(targetValue)) {\n result[key] = deepMerge(targetValue as Record<string, unknown>, value as Record<string, unknown>);\n } else {\n result[key] = value;\n }\n }\n\n return result;\n}\n","import type { ComposeTemplateOptions, DSLObject } from '../../types';\nimport { applyOverrides } from './merge';\n\ninterface DSLNode {\n type?: string;\n data?: unknown;\n props?: Record<string, unknown>;\n children?: DSLNode[];\n [key: string]: unknown;\n}\n\nfunction isContainerNode(node: unknown): node is DSLNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'children' in node &&\n Array.isArray((node as DSLNode).children)\n );\n}\n\nexport function composeTemplates(options: ComposeTemplateOptions): DSLObject {\n const { templates, overrides = [] } = options;\n\n if (templates.length === 0) {\n throw new Error('At least one template is required');\n }\n\n if (templates.length === 1) {\n const base = templates[0];\n if (overrides.length > 0) {\n return applyOverrides(base, overrides);\n }\n return base;\n }\n\n const root = templates[0] as DSLNode;\n\n if (!isContainerNode(root)) {\n throw new Error('Root template must be a container node with children');\n }\n\n let currentChildren = root.children || [];\n\n for (let i = 1; i < templates.length; i++) {\n const template = templates[i] as DSLNode;\n\n if (isContainerNode(template) && template.children) {\n currentChildren = [...currentChildren, ...template.children];\n } else {\n currentChildren.push(template);\n }\n }\n\n root.children = currentChildren;\n\n let composed = root as DSLObject;\n\n if (overrides.length > 0) {\n composed = applyOverrides(composed, overrides);\n }\n\n return composed;\n}\n","import type { InfographicError } from '../types';\n\nexport function createInfographicError(\n type: InfographicError['type'],\n message: string,\n dsl?: string,\n details?: Error | unknown,\n): InfographicError {\n return {\n type,\n message,\n dsl,\n details,\n };\n}\n\nexport function isInfographicError(error: unknown): error is InfographicError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'type' in error &&\n 'message' in error &&\n ['syntax', 'render', 'runtime'].includes((error as InfographicError).type)\n );\n}\n\nexport function formatErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n}\n","import { useCallback, useRef } from 'react';\nimport { applyOverrides } from '../utils/dsl';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type {\n InfographicError,\n DSLObject,\n PreRenderHook,\n DSLOverride,\n} from '../types';\n\ninterface DSLProcessorOptions {\n overrides?: DSLOverride[];\n beforeRender?: PreRenderHook;\n onError?: (error: InfographicError) => void;\n}\n\nexport function useDSLProcessor(options: DSLProcessorOptions) {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const processDSL = useCallback(\n async (input: DSLObject): Promise<DSLObject> => {\n let processed: DSLObject = input;\n const { overrides, beforeRender } = optionsRef.current;\n\n if (overrides && overrides.length > 0) {\n try {\n processed = applyOverrides(processed, overrides);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'syntax',\n `Failed to apply overrides: ${formatErrorMessage(error)}`,\n JSON.stringify(processed),\n error,\n );\n optionsRef.current.onError?.(infographicError);\n throw infographicError;\n }\n }\n\n if (beforeRender) {\n try {\n processed = await beforeRender(processed);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'runtime',\n `beforeRender hook failed: ${formatErrorMessage(error)}`,\n JSON.stringify(processed),\n error,\n );\n optionsRef.current.onError?.(infographicError);\n throw infographicError;\n }\n }\n\n return processed;\n },\n [],\n );\n\n return { processDSL };\n}\n","import { useCallback, useRef } from 'react';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type { InfographicError, InfographicRenderResult, PostRenderHook } from '../types';\n\ninterface RenderCallbackOptions {\n afterRender?: PostRenderHook;\n onRender?: (result: InfographicRenderResult) => void;\n onLoad?: (result: InfographicRenderResult) => void;\n onError?: (error: InfographicError) => void;\n}\n\nexport function useRenderCallback(options: RenderCallbackOptions) {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const handleRendered = useCallback(\n async (result: InfographicRenderResult) => {\n const { afterRender, onRender, onLoad } = optionsRef.current;\n\n if (afterRender) {\n try {\n await afterRender(result);\n } catch (error) {\n const infographicError: InfographicError = createInfographicError(\n 'runtime',\n `afterRender hook failed: ${formatErrorMessage(error)}`,\n undefined,\n error,\n );\n optionsRef.current.onError?.(infographicError);\n return;\n }\n }\n\n onRender?.(result);\n onLoad?.(result);\n },\n [],\n );\n\n return { handleRendered };\n}\n","export const RENDER_DEBOUNCE_DELAY = 100;\n","import { useCallback, useRef } from 'react';\nimport { debounce } from 'lodash-es';\nimport { RENDER_DEBOUNCE_DELAY } from '../constants';\nimport type {\n DSLInput,\n DSLObject,\n InfographicOptions,\n ThemeConfig,\n} from '../types';\n\ninterface RenderControllerProps {\n dsl?: DSLInput;\n width?: number | string;\n height?: number | string;\n theme?: string;\n editable?: boolean;\n className?: string;\n}\n\nexport function useRenderController(\n containerRef: React.RefObject<HTMLElement>,\n rendererRender: (options: string | Partial<InfographicOptions>) => void,\n props: RenderControllerProps,\n processDSL: (input: DSLObject) => Promise<DSLObject>,\n onError?: (error: unknown) => void,\n) {\n const propsRef = useRef(props);\n const dslCacheRef = useRef<string | null>(null);\n const stringDslCacheRef = useRef<string | null>(null);\n\n propsRef.current = props;\n\n const render = useCallback(async () => {\n const { dsl, width, height, theme, editable, className } = propsRef.current;\n\n if (!dsl) {\n throw new Error('DSL prop is required');\n }\n\n if (containerRef.current && className) {\n containerRef.current.className = className;\n }\n\n if (typeof dsl === 'string') {\n const trimmedDsl = dsl.trim();\n if (!trimmedDsl) {\n throw new Error('String DSL cannot be empty or contain only whitespace');\n }\n if (stringDslCacheRef.current !== trimmedDsl) {\n stringDslCacheRef.current = trimmedDsl;\n rendererRender(trimmedDsl);\n }\n } else {\n const processedDSL: DSLObject = await processDSL(dsl);\n\n const dslString = JSON.stringify(processedDSL);\n if (dslCacheRef.current !== dslString) {\n dslCacheRef.current = dslString;\n\n const { palette, ...restDSL } = processedDSL;\n\n const renderOptions: Partial<InfographicOptions> = {\n ...restDSL,\n data: processedDSL.data,\n width,\n height,\n editable,\n };\n\n if (processedDSL.theme) {\n renderOptions.theme = processedDSL.theme;\n } else if (theme) {\n renderOptions.theme = theme;\n }\n\n if (palette) {\n const existingThemeConfig = (processedDSL.themeConfig || {}) as ThemeConfig;\n renderOptions.themeConfig = {\n ...existingThemeConfig,\n palette,\n };\n }\n\n rendererRender(renderOptions);\n }\n }\n }, [containerRef, rendererRender, processDSL]);\n\n const debouncedRender = useCallback(\n debounce(() => {\n render().catch((error) => {\n onError?.(error);\n });\n }, RENDER_DEBOUNCE_DELAY),\n [render, onError],\n );\n\n return { debouncedRender };\n}\n","import { useCallback, useRef } from 'react';\nimport type { DSLInput, DSLObject, InfographicOptions, Palette, ThemeConfig } from '../types';\n\ninterface RefMethodsProps {\n processDSL: (input: DSLObject) => Promise<DSLObject>;\n theme?: string;\n}\n\nexport function useRefMethods(\n update: (options: string | Partial<InfographicOptions>) => void,\n { processDSL, theme }: RefMethodsProps,\n) {\n const themeRef = useRef(theme);\n themeRef.current = theme;\n\n const refUpdate = useCallback(\n async (options: DSLInput) => {\n if (typeof options === 'string') {\n update(options);\n return;\n }\n\n const processed: DSLObject = await processDSL(options);\n const { palette, ...restProcessed } = processed;\n const themeConfig = (processed.themeConfig || {}) as ThemeConfig;\n\n if (palette) {\n themeConfig.palette = palette as Palette;\n }\n\n const renderOptions: Partial<InfographicOptions> = {\n ...restProcessed,\n theme: processed.theme ?? themeRef.current,\n themeConfig,\n };\n\n update(renderOptions);\n },\n [update, processDSL],\n );\n\n return { refUpdate };\n}\n","import { useEffect } from 'react';\nimport { useRenderer } from './useRenderer';\nimport { useDSLProcessor } from './useDSLProcessor';\nimport { useRenderCallback } from './useRenderCallback';\nimport { useRenderController } from './useRenderController';\nimport { useRefMethods } from './useRefMethods';\nimport { createInfographicError, formatErrorMessage } from '../utils/error';\nimport type {\n InfographicProps,\n InfographicRef,\n InfographicError,\n} from '../types';\n\nexport function useInfographic(\n containerRef: React.RefObject<HTMLElement>,\n props: InfographicProps,\n) {\n const { render: rendererRender, update, toDataURL, getTypes, destroy, on, off } = useRenderer(containerRef);\n\n const { processDSL } = useDSLProcessor({\n overrides: props.overrides,\n beforeRender: props.beforeRender,\n onError: props.onError,\n });\n\n const { handleRendered } = useRenderCallback({\n afterRender: props.afterRender,\n onRender: props.onRender,\n onLoad: props.onLoad,\n onError: props.onError,\n });\n\n const { debouncedRender } = useRenderController(\n containerRef,\n rendererRender,\n props,\n processDSL,\n (error) => {\n const infographicError: InfographicError = createInfographicError(\n 'render',\n formatErrorMessage(error),\n undefined,\n error,\n );\n props.onError?.(infographicError);\n },\n );\n\n const { refUpdate } = useRefMethods((options) => update(options), { processDSL, theme: props.theme });\n\n useEffect(() => {\n on('rendered', handleRendered);\n on('loaded', handleRendered);\n\n return () => {\n off('rendered', handleRendered);\n off('loaded', handleRendered);\n };\n }, [on, off, handleRendered]);\n\n useEffect(() => {\n debouncedRender();\n return debouncedRender.cancel;\n }, [debouncedRender]);\n\n const ref: InfographicRef = {\n toDataURL,\n getTypes,\n update: refUpdate,\n destroy,\n };\n\n return ref;\n}\n","export const errorOverlayStyles: React.CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'rgba(0, 0, 0, 0.05)',\n color: '#d32f2f',\n padding: '20px',\n zIndex: 1,\n textAlign: 'center',\n};\n\nexport const errorTitleStyles: React.CSSProperties = {\n fontSize: '1.2em',\n fontWeight: 'bold',\n marginBottom: '10px',\n};\n\nexport const errorMessageStyles: React.CSSProperties = {\n marginBottom: '15px',\n};\n\nexport const retryButtonStyles: React.CSSProperties = {\n padding: '8px 16px',\n backgroundColor: '#1976d2',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n fontSize: '14px',\n};\n\nexport const errorBoundaryContainerStyles: React.CSSProperties = {\n padding: '20px',\n backgroundColor: '#fee',\n border: '1px solid #fcc',\n borderRadius: '4px',\n color: '#c33',\n};\n\nexport const errorBoundaryTitleStyles: React.CSSProperties = {\n marginTop: 0,\n};\n\nexport const errorBoundaryStackStyles: React.CSSProperties = {\n marginTop: '10px',\n padding: '10px',\n backgroundColor: 'white',\n borderRadius: '4px',\n overflow: 'auto',\n};\n\nexport const errorBoundaryRetryButtonStyles: React.CSSProperties = {\n marginTop: '15px',\n padding: '8px 16px',\n backgroundColor: '#c33',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n};\n","import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';\nimport { useInfographic } from '../hooks';\nimport type { InfographicProps, InfographicRef, InfographicError } from '../types';\nimport {\n errorOverlayStyles,\n errorTitleStyles,\n errorMessageStyles,\n retryButtonStyles,\n} from './styles';\n\nconst defaultError: InfographicError = {\n type: 'render',\n message: 'An error occurred while rendering the infographic.',\n};\n\nfunction InfographicComponent(\n props: InfographicProps,\n ref: React.Ref<InfographicRef>,\n) {\n const { children, dsl: dslProp, ...restProps } = props;\n const containerRef = useRef<HTMLDivElement>(null);\n const [error, setError] = useState<InfographicError | null>(null);\n const [errorKey, setErrorKey] = useState(0);\n console.log('children--------------', children)\n const childrenDsl = children ? String(children).trim() : undefined;\n const finalDsl = childrenDsl || dslProp;\n\n if (!finalDsl) {\n throw new Error('Either children or dsl prop must be provided');\n }\n\n const infographicRef = useInfographic(containerRef, {\n ...restProps,\n dsl: finalDsl,\n onError: (err) => {\n setError(err);\n props.onError?.(err);\n },\n });\n\n useImperativeHandle(ref, () => infographicRef, [infographicRef]);\n\n const handleRetry = () => {\n setError(null);\n setErrorKey((prev) => prev + 1);\n };\n\n const containerStyle: React.CSSProperties = {\n width: props.width ?? '100%',\n height: props.height ?? 'auto',\n overflow: 'hidden',\n };\n\n return (\n <>\n <div\n key={`infographic-container-${errorKey}`}\n ref={containerRef}\n className={props.className}\n style={containerStyle}\n data-infographic-container\n />\n {error && (\n <div style={errorOverlayStyles}>\n <div style={errorTitleStyles}>Infographic Render Error</div>\n <div style={errorMessageStyles}>{error.message || defaultError.message}</div>\n <button type=\"button\" onClick={handleRetry} style={retryButtonStyles}>\n Retry\n </button>\n </div>\n )}\n </>\n );\n}\n\nexport const Infographic = forwardRef(InfographicComponent);\n","import { Component, ErrorInfo, ReactNode } from 'react';\nimport {\n errorBoundaryContainerStyles,\n errorBoundaryTitleStyles,\n errorBoundaryStackStyles,\n errorBoundaryRetryButtonStyles,\n} from './styles';\n\ninterface ErrorBoundaryProps {\n children: ReactNode;\n fallback?: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode);\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n error?: Error;\n errorInfo?: ErrorInfo;\n}\n\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n this.setState({ errorInfo });\n this.props.onError?.(error, errorInfo);\n }\n\n handleReset = () => {\n this.setState({ hasError: false, error: undefined, errorInfo: undefined });\n };\n\n render() {\n const { hasError, error, errorInfo } = this.state;\n const { children, fallback } = this.props;\n\n if (!hasError || !error) {\n return children;\n }\n\n if (fallback) {\n if (typeof fallback === 'function') {\n return fallback(error, errorInfo!);\n }\n return fallback;\n }\n\n return (\n <div style={errorBoundaryContainerStyles}>\n <h2 style={errorBoundaryTitleStyles}>Something went wrong</h2>\n <p>{error.message}</p>\n {errorInfo && (\n <details style={{ marginTop: '10px' }}>\n <summary>Stack trace</summary>\n <pre style={errorBoundaryStackStyles}>{errorInfo.componentStack}</pre>\n </details>\n )}\n <button type=\"button\" onClick={this.handleReset} style={errorBoundaryRetryButtonStyles}>\n Try again\n </button>\n </div>\n );\n }\n}\n"]}
|