@visactor/vbi 0.4.13 → 0.4.14

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.
@@ -1,3 +1,4 @@
1
1
  export { VBIBuilder } from './vbi-builder';
2
2
  export { VBI } from './vbi';
3
3
  export { MeasuresBuilder, DimensionsBuilder, ChartTypeBuilder, HavingFiltersBuilder } from './sub-builders';
4
+ export { UndoManager } from './undo-manager';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @description 撤销/重做管理器,提供基于 YJS 的撤销和重做功能,支持栈管理和历史清除操作
3
+ */
4
+ export declare class UndoManager {
5
+ private manager;
6
+ /**
7
+ * @description 构造函数
8
+ * @param scope - YJS 文档或类型作用域,用于定义撤销/重做的追踪范围
9
+ */
10
+ constructor(scope: any);
11
+ /**
12
+ * @description 撤销上一次修改
13
+ * @returns 是否成功撤销
14
+ */
15
+ undo(): boolean;
16
+ /**
17
+ * @description 重做被撤销的修改
18
+ * @returns 是否成功重做
19
+ */
20
+ redo(): boolean;
21
+ /**
22
+ * @description 检查是否有可撤销的操作
23
+ * @returns 是否可以撤销
24
+ */
25
+ canUndo(): boolean;
26
+ /**
27
+ * @description 检查是否有可重做的操作
28
+ * @returns 是否可以重做
29
+ */
30
+ canRedo(): boolean;
31
+ /**
32
+ * @description 清除历史记录
33
+ * @param clearUndoStack - 是否清除撤销栈,默认 true
34
+ * @param clearRedoStack - 是否清除重做栈,默认 true
35
+ */
36
+ clear(clearUndoStack?: boolean, clearRedoStack?: boolean): void;
37
+ }
@@ -6,11 +6,12 @@ import { MeasuresBuilder } from './sub-builders/measures';
6
6
  import { HavingFiltersBuilder } from './sub-builders/havingFilters';
7
7
  import { WhereFiltersBuilder } from './sub-builders';
8
8
  import { ChartTypeBuilder } from './sub-builders';
9
+ import { UndoManager } from './undo-manager';
9
10
  import { VBIDSL, VBIBuilderInterface } from '../types';
10
11
  export declare class VBIBuilder implements VBIBuilderInterface {
11
12
  doc: Y.Doc;
12
13
  dsl: Y.Map<any>;
13
- undoManager: Y.UndoManager;
14
+ undoManager: UndoManager;
14
15
  chartType: ChartTypeBuilder;
15
16
  measures: MeasuresBuilder;
16
17
  dimensions: DimensionsBuilder;
package/dist/index.cjs CHANGED
@@ -607,6 +607,27 @@ class WhereFiltersBuilder {
607
607
  return void 0 !== yMap.get('field');
608
608
  }
609
609
  }
610
+ class UndoManager {
611
+ manager;
612
+ constructor(scope){
613
+ this.manager = new external_yjs_namespaceObject.UndoManager(scope);
614
+ }
615
+ undo() {
616
+ return null !== this.manager.undo();
617
+ }
618
+ redo() {
619
+ return null !== this.manager.redo();
620
+ }
621
+ canUndo() {
622
+ return this.manager.canUndo();
623
+ }
624
+ canRedo() {
625
+ return this.manager.canRedo();
626
+ }
627
+ clear(clearUndoStack, clearRedoStack) {
628
+ this.manager.clear(clearUndoStack, clearRedoStack);
629
+ }
630
+ }
610
631
  const external_remeda_namespaceObject = require("remeda");
611
632
  const buildSelect = (queryDSL, context)=>{
612
633
  const { vbiDSL } = context;
@@ -776,7 +797,7 @@ class VBIBuilder {
776
797
  constructor(doc){
777
798
  this.doc = doc;
778
799
  this.dsl = doc.getMap('dsl');
779
- this.undoManager = new external_yjs_namespaceObject.UndoManager(this.dsl);
800
+ this.undoManager = new UndoManager(this.dsl);
780
801
  this.chartType = new ChartTypeBuilder(doc, this.dsl);
781
802
  this.measures = new MeasuresBuilder(doc, this.dsl);
782
803
  this.dimensions = new DimensionsBuilder(doc, this.dsl);
package/dist/index.js CHANGED
@@ -569,6 +569,27 @@ class WhereFiltersBuilder {
569
569
  return void 0 !== yMap.get('field');
570
570
  }
571
571
  }
572
+ class undo_manager_UndoManager {
573
+ manager;
574
+ constructor(scope){
575
+ this.manager = new UndoManager(scope);
576
+ }
577
+ undo() {
578
+ return null !== this.manager.undo();
579
+ }
580
+ redo() {
581
+ return null !== this.manager.redo();
582
+ }
583
+ canUndo() {
584
+ return this.manager.canUndo();
585
+ }
586
+ canRedo() {
587
+ return this.manager.canRedo();
588
+ }
589
+ clear(clearUndoStack, clearRedoStack) {
590
+ this.manager.clear(clearUndoStack, clearRedoStack);
591
+ }
592
+ }
572
593
  const buildSelect = (queryDSL, context)=>{
573
594
  const { vbiDSL } = context;
574
595
  const measures = vbiDSL.measures;
@@ -737,7 +758,7 @@ class VBIBuilder {
737
758
  constructor(doc){
738
759
  this.doc = doc;
739
760
  this.dsl = doc.getMap('dsl');
740
- this.undoManager = new UndoManager(this.dsl);
761
+ this.undoManager = new undo_manager_UndoManager(this.dsl);
741
762
  this.chartType = new ChartTypeBuilder(doc, this.dsl);
742
763
  this.measures = new MeasuresBuilder(doc, this.dsl);
743
764
  this.dimensions = new DimensionsBuilder(doc, this.dsl);
@@ -2,7 +2,8 @@ import type { VQueryDSL } from '@visactor/vquery';
2
2
  import type { VBIDSL } from '../dsl';
3
3
  import type { VSeedDSL } from '@visactor/vseed';
4
4
  import type { MeasuresBuilder, DimensionsBuilder, ChartTypeBuilder, HavingFiltersBuilder, WhereFiltersBuilder } from '../../builder/sub-builders';
5
- import type { Map, Doc, UndoManager } from 'yjs';
5
+ import type { Map, Doc } from 'yjs';
6
+ import type { UndoManager } from '../../builder/undo-manager';
6
7
  export interface VBIBuilderInterface {
7
8
  doc: Doc;
8
9
  dsl: Map<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vbi",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "license": "MIT",
5
5
  "homepage": "https://visactor.github.io/VBI",
6
6
  "bugs": "https://github.com/VisActor/VBI/issues",
@@ -33,11 +33,11 @@
33
33
  "uuid": "13.0.0",
34
34
  "yjs": "13.6.28",
35
35
  "zod": "4.0.17",
36
- "@visactor/vseed": "0.4.13"
36
+ "@visactor/vseed": "0.4.14"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@visactor/vquery": "0.4.13",
40
- "@visactor/vseed": "0.4.13"
39
+ "@visactor/vquery": "0.4.14",
40
+ "@visactor/vseed": "0.4.14"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@eslint/js": "9.39.0",
@@ -51,7 +51,7 @@
51
51
  "ts-morph": "26.0.0",
52
52
  "typescript": "5.9.3",
53
53
  "typescript-eslint": "8.48.0",
54
- "@visactor/vquery": "0.4.13"
54
+ "@visactor/vquery": "0.4.14"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "rslib build",