cps-bi-sdk 0.1.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/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/cps-bi-sdk.css +2 -0
- package/dist/index.cjs +512 -0
- package/dist/index.js +61745 -0
- package/dist/types/builder/DashboardBuilder.d.ts +7 -0
- package/dist/types/builder/DashboardBuilder.d.ts.map +1 -0
- package/dist/types/builder/components/BuilderHelpModal.d.ts +11 -0
- package/dist/types/builder/components/BuilderHelpModal.d.ts.map +1 -0
- package/dist/types/builder/components/BuilderTopBar.d.ts +7 -0
- package/dist/types/builder/components/BuilderTopBar.d.ts.map +1 -0
- package/dist/types/builder/components/BuilderWidgetCard.d.ts +24 -0
- package/dist/types/builder/components/BuilderWidgetCard.d.ts.map +1 -0
- package/dist/types/builder/components/BuilderWidgetCardContainer.d.ts +11 -0
- package/dist/types/builder/components/BuilderWidgetCardContainer.d.ts.map +1 -0
- package/dist/types/builder/components/BuilderWidgetRenderer.d.ts +19 -0
- package/dist/types/builder/components/BuilderWidgetRenderer.d.ts.map +1 -0
- package/dist/types/builder/components/BuilderWidgetRendererContainer.d.ts +11 -0
- package/dist/types/builder/components/BuilderWidgetRendererContainer.d.ts.map +1 -0
- package/dist/types/builder/components/CanvasSettingsModal.d.ts +15 -0
- package/dist/types/builder/components/CanvasSettingsModal.d.ts.map +1 -0
- package/dist/types/builder/components/CanvasStage.d.ts +9 -0
- package/dist/types/builder/components/CanvasStage.d.ts.map +1 -0
- package/dist/types/builder/components/CanvasStageGrid.d.ts +71 -0
- package/dist/types/builder/components/CanvasStageGrid.d.ts.map +1 -0
- package/dist/types/builder/components/CanvasStageNodeContext.d.ts +55 -0
- package/dist/types/builder/components/CanvasStageNodeContext.d.ts.map +1 -0
- package/dist/types/builder/components/CanvasStageSurface.d.ts +32 -0
- package/dist/types/builder/components/CanvasStageSurface.d.ts.map +1 -0
- package/dist/types/builder/components/ClearCanvasConfirmModal.d.ts +20 -0
- package/dist/types/builder/components/ClearCanvasConfirmModal.d.ts.map +1 -0
- package/dist/types/builder/components/UnauthorizedWidgetPlaceholder.d.ts +18 -0
- package/dist/types/builder/components/UnauthorizedWidgetPlaceholder.d.ts.map +1 -0
- package/dist/types/builder/components/WidgetCatalogPanel.d.ts +7 -0
- package/dist/types/builder/components/WidgetCatalogPanel.d.ts.map +1 -0
- package/dist/types/builder/components/WidgetConfigPanel.d.ts +7 -0
- package/dist/types/builder/components/WidgetConfigPanel.d.ts.map +1 -0
- package/dist/types/builder/hooks/controllerActions.d.ts +24 -0
- package/dist/types/builder/hooks/controllerActions.d.ts.map +1 -0
- package/dist/types/builder/hooks/useBeforeUnloadProtection.d.ts +9 -0
- package/dist/types/builder/hooks/useBeforeUnloadProtection.d.ts.map +1 -0
- package/dist/types/builder/hooks/useBuilderAuthorization.d.ts +22 -0
- package/dist/types/builder/hooks/useBuilderAuthorization.d.ts.map +1 -0
- package/dist/types/builder/hooks/useBuilderController.d.ts +10 -0
- package/dist/types/builder/hooks/useBuilderController.d.ts.map +1 -0
- package/dist/types/builder/hooks/useBuilderFullscreen.d.ts +22 -0
- package/dist/types/builder/hooks/useBuilderFullscreen.d.ts.map +1 -0
- package/dist/types/builder/hooks/useCanvasStageResizeAutoPan.d.ts +21 -0
- package/dist/types/builder/hooks/useCanvasStageResizeAutoPan.d.ts.map +1 -0
- package/dist/types/builder/hooks/useCanvasStageScreenInteraction.d.ts +27 -0
- package/dist/types/builder/hooks/useCanvasStageScreenInteraction.d.ts.map +1 -0
- package/dist/types/builder/hooks/useCanvasStageViewport.d.ts +46 -0
- package/dist/types/builder/hooks/useCanvasStageViewport.d.ts.map +1 -0
- package/dist/types/builder/hooks/useCanvasStageWidgetHandlers.d.ts +11 -0
- package/dist/types/builder/hooks/useCanvasStageWidgetHandlers.d.ts.map +1 -0
- package/dist/types/builder/types.d.ts +264 -0
- package/dist/types/builder/types.d.ts.map +1 -0
- package/dist/types/builder/utils/controllerSchema.d.ts +35 -0
- package/dist/types/builder/utils/controllerSchema.d.ts.map +1 -0
- package/dist/types/builder/utils/schemaTransfer.d.ts +8 -0
- package/dist/types/builder/utils/schemaTransfer.d.ts.map +1 -0
- package/dist/types/builtin-widgets/BuiltinChartConfigForm.d.ts +10 -0
- package/dist/types/builtin-widgets/BuiltinChartConfigForm.d.ts.map +1 -0
- package/dist/types/builtin-widgets/BuiltinChartWidget.d.ts +10 -0
- package/dist/types/builtin-widgets/BuiltinChartWidget.d.ts.map +1 -0
- package/dist/types/builtin-widgets/BuiltinCountdownConfigForm.d.ts +7 -0
- package/dist/types/builtin-widgets/BuiltinCountdownConfigForm.d.ts.map +1 -0
- package/dist/types/builtin-widgets/BuiltinCountdownWidget.d.ts +7 -0
- package/dist/types/builtin-widgets/BuiltinCountdownWidget.d.ts.map +1 -0
- package/dist/types/builtin-widgets/BuiltinTableConfigForm.d.ts +7 -0
- package/dist/types/builtin-widgets/BuiltinTableConfigForm.d.ts.map +1 -0
- package/dist/types/builtin-widgets/BuiltinTableWidget.d.ts +7 -0
- package/dist/types/builtin-widgets/BuiltinTableWidget.d.ts.map +1 -0
- package/dist/types/builtin-widgets/BuiltinTextConfigForm.d.ts +7 -0
- package/dist/types/builtin-widgets/BuiltinTextConfigForm.d.ts.map +1 -0
- package/dist/types/builtin-widgets/BuiltinTextWidget.d.ts +7 -0
- package/dist/types/builtin-widgets/BuiltinTextWidget.d.ts.map +1 -0
- package/dist/types/builtin-widgets/builtinWidgetsManifest.d.ts +8 -0
- package/dist/types/builtin-widgets/builtinWidgetsManifest.d.ts.map +1 -0
- package/dist/types/builtin-widgets/chart-config.d.ts +22 -0
- package/dist/types/builtin-widgets/chart-config.d.ts.map +1 -0
- package/dist/types/builtin-widgets/chart-theme.d.ts +24 -0
- package/dist/types/builtin-widgets/chart-theme.d.ts.map +1 -0
- package/dist/types/builtin-widgets/chartHelpers.d.ts +47 -0
- package/dist/types/builtin-widgets/chartHelpers.d.ts.map +1 -0
- package/dist/types/builtin-widgets/chartOptions.d.ts +11 -0
- package/dist/types/builtin-widgets/chartOptions.d.ts.map +1 -0
- package/dist/types/builtin-widgets/index.d.ts +6 -0
- package/dist/types/builtin-widgets/index.d.ts.map +1 -0
- package/dist/types/components/WidgetStateCard.d.ts +41 -0
- package/dist/types/components/WidgetStateCard.d.ts.map +1 -0
- package/dist/types/contracts/builder.d.ts +28 -0
- package/dist/types/contracts/builder.d.ts.map +1 -0
- package/dist/types/contracts/builtin-countdown.d.ts +20 -0
- package/dist/types/contracts/builtin-countdown.d.ts.map +1 -0
- package/dist/types/contracts/builtin-table.d.ts +35 -0
- package/dist/types/contracts/builtin-table.d.ts.map +1 -0
- package/dist/types/contracts/builtin-text.d.ts +22 -0
- package/dist/types/contracts/builtin-text.d.ts.map +1 -0
- package/dist/types/contracts/chart.d.ts +238 -0
- package/dist/types/contracts/chart.d.ts.map +1 -0
- package/dist/types/contracts/common.d.ts +19 -0
- package/dist/types/contracts/common.d.ts.map +1 -0
- package/dist/types/contracts/data-source.d.ts +59 -0
- package/dist/types/contracts/data-source.d.ts.map +1 -0
- package/dist/types/contracts/events.d.ts +27 -0
- package/dist/types/contracts/events.d.ts.map +1 -0
- package/dist/types/contracts/index.d.ts +16 -0
- package/dist/types/contracts/index.d.ts.map +1 -0
- package/dist/types/contracts/schema.d.ts +157 -0
- package/dist/types/contracts/schema.d.ts.map +1 -0
- package/dist/types/contracts/services.d.ts +22 -0
- package/dist/types/contracts/services.d.ts.map +1 -0
- package/dist/types/contracts/widget.d.ts +149 -0
- package/dist/types/contracts/widget.d.ts.map +1 -0
- package/dist/types/core/event-bus/createEventBus.d.ts +62 -0
- package/dist/types/core/event-bus/createEventBus.d.ts.map +1 -0
- package/dist/types/core/layout/screenCanvas.d.ts +48 -0
- package/dist/types/core/layout/screenCanvas.d.ts.map +1 -0
- package/dist/types/core/schema/componentStyleConfig.d.ts +43 -0
- package/dist/types/core/schema/componentStyleConfig.d.ts.map +1 -0
- package/dist/types/core/store/createDashboardStore.d.ts +13 -0
- package/dist/types/core/store/createDashboardStore.d.ts.map +1 -0
- package/dist/types/core/store/storeEquality.d.ts +31 -0
- package/dist/types/core/store/storeEquality.d.ts.map +1 -0
- package/dist/types/core/store/storeSelectors.d.ts +38 -0
- package/dist/types/core/store/storeSelectors.d.ts.map +1 -0
- package/dist/types/core/store/types.d.ts +78 -0
- package/dist/types/core/store/types.d.ts.map +1 -0
- package/dist/types/core/store/useDashboardStoreSelector.d.ts +22 -0
- package/dist/types/core/store/useDashboardStoreSelector.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/providers/DashboardAntdProvider.d.ts +21 -0
- package/dist/types/providers/DashboardAntdProvider.d.ts.map +1 -0
- package/dist/types/providers/DashboardConfigProvider.d.ts +14 -0
- package/dist/types/providers/DashboardConfigProvider.d.ts.map +1 -0
- package/dist/types/providers/types.d.ts +43 -0
- package/dist/types/providers/types.d.ts.map +1 -0
- package/dist/types/utils/assertNever.d.ts +9 -0
- package/dist/types/utils/assertNever.d.ts.map +1 -0
- package/dist/types/utils/stableSerialize.d.ts +9 -0
- package/dist/types/utils/stableSerialize.d.ts.map +1 -0
- package/dist/types/viewer/DashboardViewer.d.ts +10 -0
- package/dist/types/viewer/DashboardViewer.d.ts.map +1 -0
- package/dist/types/viewer/hooks/useWidgetDataResolver.d.ts +93 -0
- package/dist/types/viewer/hooks/useWidgetDataResolver.d.ts.map +1 -0
- package/dist/types/viewer/renderers/WidgetRenderer.d.ts +54 -0
- package/dist/types/viewer/renderers/WidgetRenderer.d.ts.map +1 -0
- package/dist/types/viewer/renderers/WidgetStateFallback.d.ts +47 -0
- package/dist/types/viewer/renderers/WidgetStateFallback.d.ts.map +1 -0
- package/dist/types/viewer/runtime/getWidgetDataBinding.d.ts +28 -0
- package/dist/types/viewer/runtime/getWidgetDataBinding.d.ts.map +1 -0
- package/dist/types/viewer/runtime/normalizeWidgetDataError.d.ts +6 -0
- package/dist/types/viewer/runtime/normalizeWidgetDataError.d.ts.map +1 -0
- package/dist/types/viewer/runtime/resolveWidgetDataByBinding.d.ts +9 -0
- package/dist/types/viewer/runtime/resolveWidgetDataByBinding.d.ts.map +1 -0
- package/dist/types/viewer/types.d.ts +63 -0
- package/dist/types/viewer/types.d.ts.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/core/store/types.ts
|
|
3
|
+
* @description Dashboard store 的公开类型与快照契约。
|
|
4
|
+
*/
|
|
5
|
+
import type { ComponentInstance, ComponentStyleConfig, DashboardSchema, DashboardSettings, LayoutRect, LinkageTargetConfig } from "../../contracts/schema";
|
|
6
|
+
export type DashboardComponent = ComponentInstance;
|
|
7
|
+
/** Schema 元信息切片,不包含 settings 与 components。 */
|
|
8
|
+
export type DashboardSchemaMeta = Omit<DashboardSchema, "settings" | "components">;
|
|
9
|
+
/** 按组件壳层订阅所需字段。 */
|
|
10
|
+
export interface DashboardComponentShellSnapshot {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: DashboardComponent["kind"];
|
|
13
|
+
widgetCode: string;
|
|
14
|
+
uniqueCode: string;
|
|
15
|
+
layout: LayoutRect;
|
|
16
|
+
baseConfig: DashboardComponent["baseConfig"];
|
|
17
|
+
styleConfig: ComponentStyleConfig;
|
|
18
|
+
linkageTarget: LinkageTargetConfig;
|
|
19
|
+
}
|
|
20
|
+
/** 组件运行态渲染所需字段。 */
|
|
21
|
+
export interface DashboardComponentRuntimeSnapshot {
|
|
22
|
+
id: string;
|
|
23
|
+
kind: DashboardComponent["kind"];
|
|
24
|
+
widgetCode: string;
|
|
25
|
+
uniqueCode: string;
|
|
26
|
+
customConfig: DashboardComponent["customConfig"];
|
|
27
|
+
}
|
|
28
|
+
/** 画布结构订阅切片。 */
|
|
29
|
+
export interface DashboardCanvasLayoutSnapshot {
|
|
30
|
+
settings: DashboardSettings | null;
|
|
31
|
+
componentIds: string[];
|
|
32
|
+
items: Array<{
|
|
33
|
+
id: string;
|
|
34
|
+
layout: LayoutRect;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
/** Store 对外快照结构。 */
|
|
38
|
+
export interface DashboardStoreSnapshot {
|
|
39
|
+
schema: DashboardSchema | null;
|
|
40
|
+
schemaMeta: DashboardSchemaMeta | null;
|
|
41
|
+
settings: DashboardSettings | null;
|
|
42
|
+
componentIds: string[];
|
|
43
|
+
componentsById: Record<string, DashboardComponent>;
|
|
44
|
+
}
|
|
45
|
+
/** DashboardStore 对外接口。 */
|
|
46
|
+
export interface DashboardStoreState extends DashboardStoreSnapshot {
|
|
47
|
+
/** 获取当前 schema。 */
|
|
48
|
+
getSchema: () => DashboardSchema | null;
|
|
49
|
+
/** 获取当前快照。 */
|
|
50
|
+
getSnapshot: () => DashboardStoreSnapshot;
|
|
51
|
+
/** 使用完整 schema 替换当前状态。 */
|
|
52
|
+
replaceSchema: (schema: DashboardSchema) => void;
|
|
53
|
+
/** 兼容旧调用方的 setSchema 别名。 */
|
|
54
|
+
setSchema: (schema: DashboardSchema) => void;
|
|
55
|
+
/** 按组件更新。 */
|
|
56
|
+
updateComponent: (componentId: string, updater: (component: DashboardComponent) => DashboardComponent) => void;
|
|
57
|
+
/** 批量更新多个组件。 */
|
|
58
|
+
updateComponents: (componentIds: string[], updater: (component: DashboardComponent) => DashboardComponent) => void;
|
|
59
|
+
/** 删除组件。 */
|
|
60
|
+
removeComponent: (componentId: string) => void;
|
|
61
|
+
/** 添加组件。 */
|
|
62
|
+
addComponent: (component: DashboardComponent) => void;
|
|
63
|
+
/** 更新画布设置。 */
|
|
64
|
+
updateSettings: (patch: Partial<DashboardSettings>) => void;
|
|
65
|
+
/** 重置 schema。 */
|
|
66
|
+
reset: (schema?: DashboardSchema | null) => void;
|
|
67
|
+
/** 订阅状态变化。 */
|
|
68
|
+
subscribe: (listener: (state: DashboardStoreSnapshot) => void) => () => void;
|
|
69
|
+
/** 选择单个组件。 */
|
|
70
|
+
selectComponentById: (componentId: string | null) => DashboardComponent | null;
|
|
71
|
+
/** 选择组件壳层切片。 */
|
|
72
|
+
selectComponentShellById: (componentId: string | null) => DashboardComponentShellSnapshot | null;
|
|
73
|
+
/** 选择组件运行态切片。 */
|
|
74
|
+
selectComponentRuntimeById: (componentId: string | null) => DashboardComponentRuntimeSnapshot | null;
|
|
75
|
+
/** 选择画布结构切片。 */
|
|
76
|
+
selectCanvasLayoutSnapshot: () => DashboardCanvasLayoutSnapshot;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/store/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/core/store/useDashboardStoreSelector.ts
|
|
3
|
+
* @description Dashboard store 切片订阅 Hook。
|
|
4
|
+
*/
|
|
5
|
+
import type { DashboardStoreSnapshot, DashboardStoreState } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* 订阅 Dashboard store 的指定切片,并在切片等价时复用上一次结果。
|
|
8
|
+
*/
|
|
9
|
+
export declare function useDashboardStoreSelector<T>(
|
|
10
|
+
/**
|
|
11
|
+
* Dashboard store 实例,需要提供 getSnapshot 和 subscribe 方法。
|
|
12
|
+
*/
|
|
13
|
+
store: Pick<DashboardStoreState, "getSnapshot" | "subscribe">,
|
|
14
|
+
/**
|
|
15
|
+
* 选择器函数,用于从 store 快照中提取指定切片。
|
|
16
|
+
*/
|
|
17
|
+
selector: (snapshot: DashboardStoreSnapshot) => T,
|
|
18
|
+
/**
|
|
19
|
+
* 判断两个切片是否等价的函数,默认使用 Object.is。
|
|
20
|
+
*/
|
|
21
|
+
isEqual?: (left: T, right: T) => boolean): T;
|
|
22
|
+
//# sourceMappingURL=useDashboardStoreSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDashboardStoreSelector.d.ts","sourceRoot":"","sources":["../../../../src/core/store/useDashboardStoreSelector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE1E;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,CAAC;AACzC;;GAEG;AACH,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,WAAW,CAAC;AAC7D;;GAEG;AACH,QAAQ,EAAE,CAAC,QAAQ,EAAE,sBAAsB,KAAK,CAAC;AACjD;;GAEG;AACH,OAAO,GAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAmB,GAClD,CAAC,CAoCH"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/index.ts
|
|
3
|
+
* @description SDK 对外统一导出入口,聚合稳定的组件、内置组件与公开类型。
|
|
4
|
+
*/
|
|
5
|
+
import './styles/tokens.css';
|
|
6
|
+
import './styles/index.css';
|
|
7
|
+
export * from "./contracts";
|
|
8
|
+
export { builtinWidgets } from "./builtin-widgets";
|
|
9
|
+
export { DashboardConfigProvider } from './providers/DashboardConfigProvider';
|
|
10
|
+
export { DashboardBuilder } from './builder/DashboardBuilder';
|
|
11
|
+
export { DashboardViewer } from './viewer/DashboardViewer';
|
|
12
|
+
export type { DashboardBuiltinThemeConfig, DashboardConfigProviderProps } from './providers/types';
|
|
13
|
+
export type { DashboardBuilderProps } from './builder/types';
|
|
14
|
+
export type { DashboardViewerDebugConfig, DashboardViewerProps, LinkageFeedbackPayload, RuntimeErrorPayload, } from './viewer/types';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,qBAAqB,CAAA;AAC5B,OAAO,oBAAoB,CAAA;AAE3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,YAAY,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAA;AAClG,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAC5D,YAAY,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/providers/DashboardAntdProvider.tsx
|
|
3
|
+
* @description SDK 内部 antd 桥接层,负责把实例级 prefix/theme 注入到 Builder/Viewer。
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
interface DashboardAntdProviderProps {
|
|
7
|
+
/**
|
|
8
|
+
* 子组件
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* 弹出层容器
|
|
13
|
+
*/
|
|
14
|
+
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 将 antd 的 locale、prefixCls 与主题配置桥接到当前 SDK 实例。
|
|
18
|
+
*/
|
|
19
|
+
export declare function DashboardAntdProvider({ children, getPopupContainer }: DashboardAntdProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=DashboardAntdProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardAntdProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/DashboardAntdProvider.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,UAAU,0BAA0B;IAClC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,WAAW,KAAK,WAAW,CAAA;CAC/D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,0BAA0B,2CAQhG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/providers/DashboardConfigProvider.tsx
|
|
3
|
+
* @description SDK 顶层配置提供者,负责注入实例级 widgets、services、prefix 与主题配置。
|
|
4
|
+
*/
|
|
5
|
+
import type { DashboardConfigContextValue, DashboardConfigProviderProps } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Dashboard 配置 Provider。
|
|
8
|
+
*
|
|
9
|
+
* 向下游注入 widgets/services/prefix/theme。
|
|
10
|
+
*/
|
|
11
|
+
export declare function DashboardConfigProvider({ children, widgets, services, prefixCls, themeConfig, builtinThemeConfig }: DashboardConfigProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
/** 获取当前 SDK 实例的配置上下文。 */
|
|
13
|
+
export declare function useDashboardConfig(): DashboardConfigContextValue;
|
|
14
|
+
//# sourceMappingURL=DashboardConfigProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardConfigProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/DashboardConfigProvider.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAyCxF;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,SAAS,EACT,WAAW,EACX,kBAAkB,EACnB,EAAE,4BAA4B,2CAsB9B;AAED,yBAAyB;AACzB,wBAAgB,kBAAkB,IAAI,2BAA2B,CAQhE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/providers/types.ts
|
|
3
|
+
* @description DashboardConfigProvider 组件类型定义。
|
|
4
|
+
*/
|
|
5
|
+
import type { ThemeConfig } from 'antd';
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
import type { BuiltinChartThemeConfig, DashboardServices, WidgetManifest } from '../contracts';
|
|
8
|
+
/** SDK 内置组件主题配置。 */
|
|
9
|
+
export interface DashboardBuiltinThemeConfig {
|
|
10
|
+
/** 内置图表主题默认值。 */
|
|
11
|
+
charts?: BuiltinChartThemeConfig;
|
|
12
|
+
}
|
|
13
|
+
/** SDK 根配置容器 Props。 */
|
|
14
|
+
export interface DashboardConfigProviderProps {
|
|
15
|
+
/** 子组件 */
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
/** 组件注册表 */
|
|
18
|
+
widgets: WidgetManifest[];
|
|
19
|
+
/** 宿主能力接口 */
|
|
20
|
+
services?: DashboardServices;
|
|
21
|
+
/** 样式前缀 */
|
|
22
|
+
prefixCls?: string;
|
|
23
|
+
/** 主题配置 */
|
|
24
|
+
themeConfig?: ThemeConfig;
|
|
25
|
+
/** 内置组件主题配置 */
|
|
26
|
+
builtinThemeConfig?: DashboardBuiltinThemeConfig;
|
|
27
|
+
}
|
|
28
|
+
/** Provider 向下游模块注入的配置快照。 */
|
|
29
|
+
export interface DashboardConfigContextValue {
|
|
30
|
+
/** 组件注册表 */
|
|
31
|
+
widgets: WidgetManifest[];
|
|
32
|
+
/** 组件索引(widgetCode -> manifest) */
|
|
33
|
+
widgetMap: Map<string, WidgetManifest>;
|
|
34
|
+
/** 宿主能力接口 */
|
|
35
|
+
services: DashboardServices;
|
|
36
|
+
/** SDK 样式前缀 */
|
|
37
|
+
prefixCls: string;
|
|
38
|
+
/** antd 主题配置 */
|
|
39
|
+
themeConfig?: ThemeConfig;
|
|
40
|
+
/** 内置组件主题配置 */
|
|
41
|
+
builtinThemeConfig?: DashboardBuiltinThemeConfig;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE9F,oBAAoB;AACpB,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB;IACjB,MAAM,CAAC,EAAE,uBAAuB,CAAA;CACjC;AAED,uBAAuB;AACvB,MAAM,WAAW,4BAA4B;IAC3C,UAAU;IACV,QAAQ,EAAE,SAAS,CAAA;IACnB,YAAY;IACZ,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,aAAa;IACb,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,WAAW;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW;IACX,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,eAAe;IACf,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;CACjD;AAED,6BAA6B;AAC7B,MAAM,WAAW,2BAA2B;IAC1C,YAAY;IACZ,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,mCAAmC;IACnC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACtC,aAAa;IACb,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,eAAe;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB;IAChB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,eAAe;IACf,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;CACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertNever.d.ts","sourceRoot":"","sources":["../../../src/utils/assertNever.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stableSerialize.d.ts","sourceRoot":"","sources":["../../../src/utils/stableSerialize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAiBtD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/viewer/DashboardViewer.tsx
|
|
3
|
+
* @description 运行态主容器,负责按 schema 渲染组件并触发数据注入与画布布局计算。
|
|
4
|
+
*/
|
|
5
|
+
import type { DashboardViewerProps } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* 按 schema 渲染运行态仪表盘,并负责布局、背景与联动事件桥接。
|
|
8
|
+
*/
|
|
9
|
+
export declare function DashboardViewer({ schema, onRuntimeError, onLinkageFeedback, debug, emptyRender, errorRender, scene }: DashboardViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=DashboardViewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardViewer.d.ts","sourceRoot":"","sources":["../../../src/viewer/DashboardViewer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAwFnD;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,WAAW,EACX,KAAgB,EACjB,EAAE,oBAAoB,2CA2TtB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/viewer/hooks/useWidgetDataResolver.ts
|
|
3
|
+
* @description Viewer 数据注入 Hook,封装 adapter registry 调用与 AbortController 生命周期。
|
|
4
|
+
*/
|
|
5
|
+
import type { DashboardDataScene, DashboardDataTriggerType } from "../../contracts";
|
|
6
|
+
import type { ComponentInstance } from "../../contracts/schema";
|
|
7
|
+
import type { InjectedWidgetProps } from "../../contracts/widget";
|
|
8
|
+
import type { RuntimeErrorPayload } from "../types";
|
|
9
|
+
/**
|
|
10
|
+
* Widget 数据解析 Hook 的入参。
|
|
11
|
+
*/
|
|
12
|
+
interface UseWidgetDataResolverOptions {
|
|
13
|
+
/**
|
|
14
|
+
* 仪表板代码。
|
|
15
|
+
*/
|
|
16
|
+
dashboardCode: string;
|
|
17
|
+
/**
|
|
18
|
+
* 组件实例。
|
|
19
|
+
*/
|
|
20
|
+
component: ComponentInstance;
|
|
21
|
+
/**
|
|
22
|
+
* 小组件代码。
|
|
23
|
+
*/
|
|
24
|
+
widgetCode: string;
|
|
25
|
+
/**
|
|
26
|
+
* 小组件唯一标识。
|
|
27
|
+
*/
|
|
28
|
+
uniqueCode: string;
|
|
29
|
+
/**
|
|
30
|
+
* 小组件自定义配置。
|
|
31
|
+
*/
|
|
32
|
+
customConfig: ComponentInstance["customConfig"];
|
|
33
|
+
/**
|
|
34
|
+
* 数据解析场景。
|
|
35
|
+
*/
|
|
36
|
+
scene: DashboardDataScene;
|
|
37
|
+
/**
|
|
38
|
+
* 是否启用运行时数据解析。
|
|
39
|
+
*/
|
|
40
|
+
enabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 运行时错误回调函数。
|
|
43
|
+
*/
|
|
44
|
+
onRuntimeError?: (error: RuntimeErrorPayload) => void;
|
|
45
|
+
/**
|
|
46
|
+
* 接收更新回调函数。
|
|
47
|
+
*/
|
|
48
|
+
onReceiveUpdate?: InjectedWidgetProps["onReceiveUpdate"];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Widget 数据解析 Hook 的返回状态。
|
|
52
|
+
*/
|
|
53
|
+
interface WidgetDataResolverState {
|
|
54
|
+
/**
|
|
55
|
+
* 当前 Widget 是否存在有效的数据执行计划。
|
|
56
|
+
*/
|
|
57
|
+
active: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* 是否正在加载数据。
|
|
60
|
+
*/
|
|
61
|
+
loading: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* 解析后的数据。
|
|
64
|
+
*/
|
|
65
|
+
data: unknown;
|
|
66
|
+
/**
|
|
67
|
+
* 错误信息。
|
|
68
|
+
*/
|
|
69
|
+
error: unknown;
|
|
70
|
+
/**
|
|
71
|
+
* 手动触发数据解析函数。
|
|
72
|
+
*/
|
|
73
|
+
resolve: (options?: {
|
|
74
|
+
/**
|
|
75
|
+
* 触发类型。
|
|
76
|
+
*/
|
|
77
|
+
type?: DashboardDataTriggerType;
|
|
78
|
+
/**
|
|
79
|
+
* 事件名称。
|
|
80
|
+
*/
|
|
81
|
+
eventName?: string;
|
|
82
|
+
/**
|
|
83
|
+
* 参数。
|
|
84
|
+
*/
|
|
85
|
+
params?: Record<string, unknown>;
|
|
86
|
+
}) => Promise<unknown>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 管理单个 Widget 的数据解析生命周期,并处理联动触发与请求中止。
|
|
90
|
+
*/
|
|
91
|
+
export declare function useWidgetDataResolver({ dashboardCode, component, widgetCode, uniqueCode, customConfig, scene, enabled, onRuntimeError, onReceiveUpdate }: UseWidgetDataResolverOptions): WidgetDataResolverState;
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=useWidgetDataResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWidgetDataResolver.d.ts","sourceRoot":"","sources":["../../../../src/viewer/hooks/useWidgetDataResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAGjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAInD;;GAEG;AACH,UAAU,4BAA4B;IACpC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAA;IAC5B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,YAAY,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;IAC/C;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAA;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;IACrD;;OAEG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAA;CACzD;AAED;;GAEG;AACH,UAAU,uBAAuB;IAC/B;;OAEG;IACH,MAAM,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;IACd;;OAEG;IACH,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE;QAClB;;WAEG;QACH,IAAI,CAAC,EAAE,wBAAwB,CAAA;QAC/B;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACjC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACvB;AAkBD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,aAAa,EACb,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EACL,OAAc,EACd,cAAc,EACd,eAAe,EAChB,EAAE,4BAA4B,GAAG,uBAAuB,CAoLxD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/viewer/renderers/WidgetRenderer.tsx
|
|
3
|
+
* @description 单 Widget 渲染器,按 manifest 渲染组件并处理 empty/error 降级。
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import type { DashboardDataScene } from "../../contracts";
|
|
7
|
+
import type { ComponentInstance } from "../../contracts/schema";
|
|
8
|
+
import type { InjectedWidgetProps } from "../../contracts/widget";
|
|
9
|
+
import type { RuntimeErrorPayload } from "../types";
|
|
10
|
+
/**
|
|
11
|
+
* 单个 Widget 渲染器的入参。
|
|
12
|
+
*/
|
|
13
|
+
export interface WidgetRendererProps {
|
|
14
|
+
/**
|
|
15
|
+
* 仪表板代码。
|
|
16
|
+
*/
|
|
17
|
+
dashboardCode: string;
|
|
18
|
+
/**
|
|
19
|
+
* 组件实例。
|
|
20
|
+
*/
|
|
21
|
+
component: ComponentInstance;
|
|
22
|
+
/**
|
|
23
|
+
* 数据解析场景。
|
|
24
|
+
*/
|
|
25
|
+
scene?: DashboardDataScene;
|
|
26
|
+
/**
|
|
27
|
+
* 运行时错误处理函数。
|
|
28
|
+
*/
|
|
29
|
+
onRuntimeError?: (error: RuntimeErrorPayload) => void;
|
|
30
|
+
/**
|
|
31
|
+
* 空数据渲染函数。
|
|
32
|
+
*/
|
|
33
|
+
emptyRender?: (ctx: {
|
|
34
|
+
widgetCode: string;
|
|
35
|
+
uniqueCode: string;
|
|
36
|
+
}) => ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* 错误渲染函数。
|
|
39
|
+
*/
|
|
40
|
+
errorRender?: (ctx: RuntimeErrorPayload) => ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* 通知更新函数。
|
|
43
|
+
*/
|
|
44
|
+
notifyUpdate?: InjectedWidgetProps["notifyUpdate"];
|
|
45
|
+
/**
|
|
46
|
+
* 接收更新函数。
|
|
47
|
+
*/
|
|
48
|
+
onReceiveUpdate?: InjectedWidgetProps["onReceiveUpdate"];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 根据组件 manifest、数据状态与错误边界渲染单个 Widget。
|
|
52
|
+
*/
|
|
53
|
+
export declare function WidgetRenderer({ dashboardCode, component, scene, onRuntimeError, emptyRender, errorRender, notifyUpdate, onReceiveUpdate }: WidgetRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
//# sourceMappingURL=WidgetRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WidgetRenderer.d.ts","sourceRoot":"","sources":["../../../../src/viewer/renderers/WidgetRenderer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAgC,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAqB,MAAM,wBAAwB,CAAA;AAIpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AA+GnD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAA;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;IACrD;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAA;IAC5E;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,SAAS,CAAA;IACrD;;OAEG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAA;IAClD;;OAEG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAA;CACzD;AAOD;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,aAAa,EACb,SAAS,EACT,KAAgB,EAChB,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAA+B,EAC/B,eAAqC,EACtC,EAAE,mBAAmB,2CAwIrB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/viewer/renderers/WidgetStateFallback.tsx
|
|
3
|
+
* @description Widget 运行态降级视图,统一处理 loading / empty / error。
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import type { RuntimeErrorPayload } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Widget 降级渲染组件的入参。
|
|
9
|
+
*/
|
|
10
|
+
export interface WidgetStateFallbackProps {
|
|
11
|
+
/**
|
|
12
|
+
* 当前组件的状态,可能为 loading / empty / error。
|
|
13
|
+
*/
|
|
14
|
+
state: "loading" | "empty" | "error";
|
|
15
|
+
/**
|
|
16
|
+
* 组件的代码标识。
|
|
17
|
+
*/
|
|
18
|
+
widgetCode: string;
|
|
19
|
+
/**
|
|
20
|
+
* 组件的唯一标识。
|
|
21
|
+
*/
|
|
22
|
+
uniqueCode: string;
|
|
23
|
+
/**
|
|
24
|
+
* 错误发生的阶段,可能为 widget-render / data-resolve。
|
|
25
|
+
*/
|
|
26
|
+
phase?: RuntimeErrorPayload["phase"];
|
|
27
|
+
/**
|
|
28
|
+
* 错误信息。
|
|
29
|
+
*/
|
|
30
|
+
error?: unknown;
|
|
31
|
+
/**
|
|
32
|
+
* 自定义空数据渲染函数。
|
|
33
|
+
*/
|
|
34
|
+
emptyRender?: (ctx: {
|
|
35
|
+
widgetCode: string;
|
|
36
|
+
uniqueCode: string;
|
|
37
|
+
}) => ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* 自定义错误渲染函数。
|
|
40
|
+
*/
|
|
41
|
+
errorRender?: (ctx: RuntimeErrorPayload) => ReactNode;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 统一渲染 Widget 的 loading / empty / error 降级态。
|
|
45
|
+
*/
|
|
46
|
+
export declare function WidgetStateFallback({ state, widgetCode, uniqueCode, phase, error, emptyRender, errorRender }: WidgetStateFallbackProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
//# sourceMappingURL=WidgetStateFallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WidgetStateFallback.d.ts","sourceRoot":"","sources":["../../../../src/viewer/renderers/WidgetStateFallback.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAA;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAA;IAC5E;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,SAAS,CAAA;CACtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,UAAU,EACV,UAAU,EACV,KAAK,EACL,KAAK,EACL,WAAW,EACX,WAAW,EACZ,EAAE,wBAAwB,2CA+C1B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/viewer/runtime/getWidgetDataBinding.ts
|
|
3
|
+
* @description 根据 widget manifest 与 adapter registry 推导运行时执行计划。
|
|
4
|
+
*/
|
|
5
|
+
import type { DashboardDataExecuteRequest, DashboardDataScene, DashboardDataSourceAdapter, DashboardDataTrigger, DashboardServices, WidgetManifest } from "../../contracts";
|
|
6
|
+
import type { ComponentInstance } from "../../contracts/schema";
|
|
7
|
+
export interface WidgetDataBindingParams {
|
|
8
|
+
dashboardCode: string;
|
|
9
|
+
component: ComponentInstance;
|
|
10
|
+
manifest?: WidgetManifest;
|
|
11
|
+
scene: DashboardDataScene;
|
|
12
|
+
trigger: DashboardDataTrigger;
|
|
13
|
+
services: DashboardServices;
|
|
14
|
+
signal: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
export type WidgetDataBindingPlan = {
|
|
17
|
+
kind: "inactive";
|
|
18
|
+
} | {
|
|
19
|
+
kind: "execute";
|
|
20
|
+
adapter: DashboardDataSourceAdapter;
|
|
21
|
+
adapterKey: string;
|
|
22
|
+
request: DashboardDataExecuteRequest;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "error";
|
|
25
|
+
error: Error;
|
|
26
|
+
};
|
|
27
|
+
export declare function getWidgetDataBinding({ dashboardCode, component, manifest, scene, trigger, services, signal }: WidgetDataBindingParams): WidgetDataBindingPlan;
|
|
28
|
+
//# sourceMappingURL=getWidgetDataBinding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWidgetDataBinding.d.ts","sourceRoot":"","sources":["../../../../src/viewer/runtime/getWidgetDataBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,2BAA2B,EAC3B,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EAEjB,cAAc,EACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAI/D,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,KAAK,EAAE,kBAAkB,CAAA;IACzB,OAAO,EAAE,oBAAoB,CAAA;IAC7B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,WAAW,CAAA;CACpB;AAED,MAAM,MAAM,qBAAqB,GAC7B;IACE,IAAI,EAAE,UAAU,CAAA;CACjB,GACD;IACE,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,0BAA0B,CAAA;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,2BAA2B,CAAA;CACrC,GACD;IACE,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAcL,wBAAgB,oBAAoB,CAAC,EACnC,aAAa,EACb,SAAS,EACT,QAAQ,EACR,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACP,EAAE,uBAAuB,GAAG,qBAAqB,CA4DjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeWidgetDataError.d.ts","sourceRoot":"","sources":["../../../../src/viewer/runtime/normalizeWidgetDataError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAOhF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/viewer/runtime/resolveWidgetDataByBinding.ts
|
|
3
|
+
* @description 执行 Widget 数据绑定计划。
|
|
4
|
+
*/
|
|
5
|
+
import type { WidgetDataBindingPlan } from "./getWidgetDataBinding";
|
|
6
|
+
export declare function resolveWidgetDataByBinding(plan: Extract<WidgetDataBindingPlan, {
|
|
7
|
+
kind: "execute";
|
|
8
|
+
}>): Promise<unknown>;
|
|
9
|
+
//# sourceMappingURL=resolveWidgetDataByBinding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveWidgetDataByBinding.d.ts","sourceRoot":"","sources":["../../../../src/viewer/runtime/resolveWidgetDataByBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAEnE,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,OAAO,CAAC,qBAAqB,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,oBAMzG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/viewer/types.ts
|
|
3
|
+
* @description DashboardViewer 组件类型定义与运行时错误类型。
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import type { DashboardDataScene } from "../contracts";
|
|
7
|
+
import type { DashboardSchema } from "../contracts/schema";
|
|
8
|
+
/** 运行时错误载荷。 */
|
|
9
|
+
export interface RuntimeErrorPayload {
|
|
10
|
+
/** 错误阶段 */
|
|
11
|
+
phase: "data-resolve" | "widget-render" | "event-dispatch";
|
|
12
|
+
/** 组件类型编码 */
|
|
13
|
+
widgetCode: string;
|
|
14
|
+
/** 组件唯一编码 */
|
|
15
|
+
uniqueCode: string;
|
|
16
|
+
/** 错误信息 */
|
|
17
|
+
error: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** 联动反馈载荷。 */
|
|
20
|
+
export interface LinkageFeedbackPayload {
|
|
21
|
+
/** 事件名称 */
|
|
22
|
+
eventName: string;
|
|
23
|
+
/** 源组件编码 */
|
|
24
|
+
sourceWidgetCode: string;
|
|
25
|
+
/** 源组件唯一编码 */
|
|
26
|
+
sourceUniqueCode: string;
|
|
27
|
+
/** 目标组件编码 */
|
|
28
|
+
targetWidgetCode: string;
|
|
29
|
+
/** 目标组件唯一编码 */
|
|
30
|
+
targetUniqueCode: string;
|
|
31
|
+
/** 时间戳 */
|
|
32
|
+
timestamp: number;
|
|
33
|
+
}
|
|
34
|
+
/** Viewer 调试配置。 */
|
|
35
|
+
export interface DashboardViewerDebugConfig {
|
|
36
|
+
/** 是否输出联动调试日志。 */
|
|
37
|
+
linkage?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* DashboardViewer 组件的入参。
|
|
41
|
+
*/
|
|
42
|
+
export interface DashboardViewerProps {
|
|
43
|
+
/** 要渲染的仪表盘 Schema。 */
|
|
44
|
+
schema: DashboardSchema;
|
|
45
|
+
/** 运行时错误回调。 */
|
|
46
|
+
onRuntimeError?: (error: RuntimeErrorPayload) => void;
|
|
47
|
+
/** 联动事件反馈回调。 */
|
|
48
|
+
onLinkageFeedback?: (payload: LinkageFeedbackPayload) => void;
|
|
49
|
+
/** 调试配置。 */
|
|
50
|
+
debug?: DashboardViewerDebugConfig;
|
|
51
|
+
/** 自定义空态渲染函数。 */
|
|
52
|
+
emptyRender?: (ctx: {
|
|
53
|
+
/** 组件类型编码。 */
|
|
54
|
+
widgetCode: string;
|
|
55
|
+
/** 组件唯一编码。 */
|
|
56
|
+
uniqueCode: string;
|
|
57
|
+
}) => ReactNode;
|
|
58
|
+
/** 自定义错误态渲染函数。 */
|
|
59
|
+
errorRender?: (ctx: RuntimeErrorPayload) => ReactNode;
|
|
60
|
+
/** Viewer 调用场景。 */
|
|
61
|
+
scene?: Extract<DashboardDataScene, "viewer" | "builder-preview">;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/viewer/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,eAAe;AACf,MAAM,WAAW,mBAAmB;IAClC,WAAW;IACX,KAAK,EAAE,cAAc,GAAG,eAAe,GAAG,gBAAgB,CAAA;IAC1D,aAAa;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW;IACX,KAAK,EAAE,OAAO,CAAA;CACf;AAED,cAAc;AACd,MAAM,WAAW,sBAAsB;IACrC,WAAW;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY;IACZ,gBAAgB,EAAE,MAAM,CAAA;IACxB,cAAc;IACd,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa;IACb,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU;IACV,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,mBAAmB;AACnB,MAAM,WAAW,0BAA0B;IACzC,kBAAkB;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,sBAAsB;IACtB,MAAM,EAAE,eAAe,CAAA;IACvB,eAAe;IACf,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;IACrD,gBAAgB;IAChB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAA;IAC7D,YAAY;IACZ,KAAK,CAAC,EAAE,0BAA0B,CAAA;IAClC,iBAAiB;IACjB,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE;QAClB,cAAc;QACd,UAAU,EAAE,MAAM,CAAA;QAClB,cAAc;QACd,UAAU,EAAE,MAAM,CAAA;KACnB,KAAK,SAAS,CAAA;IACf,kBAAkB;IAClB,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,SAAS,CAAA;IACrD,mBAAmB;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC,kBAAkB,EAAE,QAAQ,GAAG,iBAAiB,CAAC,CAAA;CAClE"}
|