@huanban/rulego-editor-core 1.3.8 → 1.3.10

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.
@@ -278,6 +278,8 @@ export declare class HuanbanRulegoEditor {
278
278
  private toolbarIcons;
279
279
  private aiAssistantOpen;
280
280
  private aiAssistantUnread;
281
+ private savedSnapshotJson;
282
+ private isLoadingDataIntoCanvas;
281
283
  /** 组件数据 @internal */
282
284
  components: ComponentDefinition[];
283
285
  /** 左侧分组展开状态 @internal */
@@ -411,6 +413,19 @@ export declare class HuanbanRulegoEditor {
411
413
  /** 关闭弹窗 */
412
414
  /** @internal 子模块(editor-dialogs)使用 */
413
415
  _closeModal(): void;
416
+ /** 标记画布存在未保存修改。供事件桥接和属性抽屉复用。 */
417
+ /** @internal */
418
+ _markDirty(reason?: string): void;
419
+ /** 保存或加载完成后记录前端 diff 的基线快照。 */
420
+ /** @internal */
421
+ _markSavedSnapshot(data?: RuleChainData | null): void;
422
+ /** 在 LogicFlow 完成渲染后用画布导出结果作为 clean 基线。 */
423
+ /** @internal */
424
+ _markSavedSnapshotFromCanvas(): void;
425
+ /** 刷新保存按钮和 diff 按钮的未保存状态。 */
426
+ private _updateDirtySaveUi;
427
+ /** 打开前端规则链 JSON 变更 diff 弹窗。 */
428
+ showUnsavedDiffDialog(): void;
414
429
  /**
415
430
  * 显示规则链选择器弹窗 — 支持搜索和分页
416
431
  * 实现已提取到 editor-dialogs.ts
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Shared guard for editable right-side drawers.
3
+ *
4
+ * The guard intentionally tracks only real form controls. Debug filters, search
5
+ * boxes, transient picker inputs, and tab state are excluded so browsing a
6
+ * drawer does not trigger an unsaved-change prompt.
7
+ */
8
+ export type DrawerCloseDecision = 'save' | 'discard' | 'cancel';
9
+ export interface DrawerGuardI18nContext {
10
+ t(key: string, params?: Record<string, string>): string;
11
+ }
12
+ export interface DrawerSnapshotOptions {
13
+ selector?: string;
14
+ extra?: unknown;
15
+ beforeCapture?: () => void;
16
+ }
17
+ export declare function captureDrawerFormSnapshot(root: ParentNode, options?: DrawerSnapshotOptions): string;
18
+ export declare function isDrawerFormDirty(root: ParentNode, initialSnapshot: string, options?: DrawerSnapshotOptions): boolean;
19
+ export declare function confirmDrawerUnsavedClose(ctx: DrawerGuardI18nContext): Promise<DrawerCloseDecision>;
20
+ //# sourceMappingURL=drawer-unsaved-guard.d.ts.map
@@ -27,6 +27,8 @@ export interface PropertyDrawerContext {
27
27
  _escapeHtml(str: string): string;
28
28
  /** 关闭 Drawer */
29
29
  _closeDrawer(): void;
30
+ /** 标记画布存在未保存修改 */
31
+ _markDirty?(reason?: string): void;
30
32
  /** 当前正在添加的节点 (可变状态, 供取消时删除) */
31
33
  _currentAddNode: any;
32
34
  /** 当前正在添加的边 (可变状态, 供取消时删除) */
@@ -0,0 +1,45 @@
1
+ import type { Delta } from 'jsondiffpatch';
2
+ export type JsonDiffKind = 'added' | 'removed' | 'changed';
3
+ export type UnifiedJsonDiffLineKind = 'meta' | 'hunk' | 'context' | 'added' | 'removed';
4
+ export interface JsonDiffEntry {
5
+ path: string;
6
+ kind: JsonDiffKind;
7
+ before: unknown;
8
+ after: unknown;
9
+ }
10
+ export interface UnifiedJsonDiffLine {
11
+ kind: UnifiedJsonDiffLineKind;
12
+ oldLine?: number;
13
+ newLine?: number;
14
+ marker: string;
15
+ text: string;
16
+ }
17
+ export interface JsonDiffResult {
18
+ beforeJson: string;
19
+ afterJson: string;
20
+ delta: Delta;
21
+ deltaJson: string;
22
+ entries: JsonDiffEntry[];
23
+ unifiedDiff: UnifiedJsonDiffLine[];
24
+ hasChanges: boolean;
25
+ truncated: boolean;
26
+ }
27
+ export interface RuleChainJsonValidationResult {
28
+ valid: boolean;
29
+ errors: string[];
30
+ jsonString?: string;
31
+ }
32
+ export declare const MAX_FRONTEND_DIFF_ENTRIES = 800;
33
+ export declare const MAX_UNIFIED_DIFF_LINES = 1600;
34
+ export declare function normalizeSnapshotValue(value: unknown, seen?: WeakSet<object>): unknown;
35
+ export declare function stableSnapshotString(value: unknown): string;
36
+ export declare function parseSnapshotJson(json: string): unknown;
37
+ export declare function collectFrontendJsonDiff(before: unknown, after: unknown, path?: string, entries?: JsonDiffEntry[]): JsonDiffEntry[];
38
+ export declare function formatDiffPreviewValue(value: unknown): string;
39
+ export declare function createUnifiedJsonDiff(beforeJson: string, afterJson: string): {
40
+ lines: UnifiedJsonDiffLine[];
41
+ truncated: boolean;
42
+ };
43
+ export declare function createJsonDiffResult(beforeRaw: unknown, afterRaw: unknown): JsonDiffResult;
44
+ export declare function validateRuleChainJsonIntegrity(data: unknown): RuleChainJsonValidationResult;
45
+ //# sourceMappingURL=json-diff.d.ts.map
@@ -0,0 +1,19 @@
1
+ export type RunHistoryRecord = Record<string, any>;
2
+ export type RunHistoryStatusKind = 'success' | 'failed' | 'unknown';
3
+ export interface RunHistoryStatusView {
4
+ kind: RunHistoryStatusKind;
5
+ label: string;
6
+ }
7
+ export declare function getRunHistoryId(item: RunHistoryRecord): string;
8
+ export declare function formatRunHistoryTime(item: RunHistoryRecord, locale?: string): string;
9
+ export declare function getRunHistoryMsgType(item: RunHistoryRecord): string;
10
+ export declare function getRunHistoryStatusView(item: RunHistoryRecord, labels?: {
11
+ success?: string;
12
+ failed?: string;
13
+ unknown?: string;
14
+ }): RunHistoryStatusView;
15
+ export declare function formatRunHistoryDuration(item: RunHistoryRecord): string;
16
+ export declare function getRunHistoryLogDuration(log: RunHistoryRecord): string;
17
+ export declare function formatRunHistoryMessageForDetail(msg: any): string;
18
+ export declare function formatRunHistoryRecordJson(item: RunHistoryRecord, maxChars?: 20000): string;
19
+ //# sourceMappingURL=run-history-format.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huanban/rulego-editor-core",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "RuleGo 规则链编辑器核心库 - 框架无关的 Headless 编辑器引擎 + API 抽象层 (WorkflowFetcher)",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
@@ -53,10 +53,11 @@
53
53
  "@codemirror/state": "^6.6.0",
54
54
  "@codemirror/theme-one-dark": "^6.1.3",
55
55
  "@codemirror/view": "^6.40.0",
56
+ "@lezer/javascript": "^1.5.4",
56
57
  "@logicflow/core": "2.1.11",
57
58
  "@logicflow/extension": "2.1.11",
58
- "@lezer/javascript": "^1.5.4",
59
- "codemirror": "^6.0.2"
59
+ "codemirror": "^6.0.2",
60
+ "jsondiffpatch": "^0.7.6"
60
61
  },
61
62
  "devDependencies": {
62
63
  "typescript": "^5.4.0",