@opendaw/lib-box 0.0.53 → 0.0.56

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/dist/editing.d.ts CHANGED
@@ -8,6 +8,8 @@ export declare class BoxEditing implements Editing {
8
8
  #private;
9
9
  constructor(graph: BoxGraph);
10
10
  get graph(): BoxGraph;
11
+ markSaved(): void;
12
+ hasUnsavedChanges(): boolean;
11
13
  isEmpty(): boolean;
12
14
  clear(): void;
13
15
  undo(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"editing.d.ts","sourceRoot":"","sources":["../src/editing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAA;AAChC,OAAO,EAAiB,OAAO,EAAO,KAAK,EAAE,MAAM,EAAY,YAAY,EAAC,MAAM,kBAAkB,CAAA;AAqBpG,MAAM,WAAW,mBAAmB;IAChC,OAAO,IAAI,IAAI,CAAA;IACf,MAAM,IAAI,IAAI,CAAA;CACjB;AAED,qBAAa,UAAW,YAAW,OAAO;;gBAU1B,KAAK,EAAE,QAAQ;IAI3B,IAAI,KAAK,IAAI,QAAQ,CAAqB;IAE1C,OAAO,IAAI,OAAO;IAElB,KAAK,IAAI,IAAI;IAOb,IAAI,IAAI,OAAO;IAUf,IAAI,IAAI,OAAO;IAcf,UAAU,IAAI,OAAO;IAErB,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,GAAE,OAAc,GAAG,MAAM,CAAC,CAAC,CAAC;IAW5E,iBAAiB,IAAI,mBAAmB;IAuCxC,IAAI,IAAI,IAAI;IAOZ,YAAY,IAAI,IAAI;IAMpB,OAAO,IAAI,IAAI;CAGlB"}
1
+ {"version":3,"file":"editing.d.ts","sourceRoot":"","sources":["../src/editing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAA;AAChC,OAAO,EAAiB,OAAO,EAAO,KAAK,EAAE,MAAM,EAAY,YAAY,EAAC,MAAM,kBAAkB,CAAA;AAqBpG,MAAM,WAAW,mBAAmB;IAChC,OAAO,IAAI,IAAI,CAAA;IACf,MAAM,IAAI,IAAI,CAAA;CACjB;AAED,qBAAa,UAAW,YAAW,OAAO;;gBAU1B,KAAK,EAAE,QAAQ;IAI3B,IAAI,KAAK,IAAI,QAAQ,CAAqB;IAE1C,SAAS,IAAI,IAAI;IAKjB,iBAAiB,IAAI,OAAO;IAM5B,OAAO,IAAI,OAAO;IAElB,KAAK,IAAI,IAAI;IAQb,IAAI,IAAI,OAAO;IAUf,IAAI,IAAI,OAAO;IAcf,UAAU,IAAI,OAAO;IAErB,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,GAAE,OAAc,GAAG,MAAM,CAAC,CAAC,CAAC;IAW5E,iBAAiB,IAAI,mBAAmB;IAuCxC,IAAI,IAAI,IAAI;IAYZ,YAAY,IAAI,IAAI;IAMpB,OAAO,IAAI,IAAI;CAGlB"}
package/dist/editing.js CHANGED
@@ -20,16 +20,33 @@ export class BoxEditing {
20
20
  #modifying = false;
21
21
  #disabled = false;
22
22
  #historyIndex = 0;
23
+ #savedHistoryIndex = 0; // -1 = saved state was spliced away, >= 0 = valid saved position
23
24
  constructor(graph) {
24
25
  this.#graph = graph;
25
26
  }
26
27
  get graph() { return this.#graph; }
28
+ markSaved() {
29
+ if (this.#pending.length > 0) {
30
+ this.mark();
31
+ }
32
+ this.#savedHistoryIndex = this.#historyIndex;
33
+ }
34
+ hasUnsavedChanges() {
35
+ if (this.#pending.length > 0) {
36
+ return true;
37
+ }
38
+ if (this.#savedHistoryIndex === -1) {
39
+ return true;
40
+ }
41
+ return this.#historyIndex !== this.#savedHistoryIndex;
42
+ }
27
43
  isEmpty() { return this.#marked.length === 0 && this.#pending.length === 0; }
28
44
  clear() {
29
45
  assert(!this.#modifying, "Already modifying");
30
46
  Arrays.clear(this.#pending);
31
47
  Arrays.clear(this.#marked);
32
48
  this.#historyIndex = 0;
49
+ this.#savedHistoryIndex = 0;
33
50
  }
34
51
  undo() {
35
52
  if (this.#disabled) {
@@ -120,6 +137,9 @@ export class BoxEditing {
120
137
  return;
121
138
  }
122
139
  if (this.#marked.length - this.#historyIndex > 0) {
140
+ if (this.#savedHistoryIndex > this.#historyIndex) {
141
+ this.#savedHistoryIndex = -1;
142
+ }
123
143
  this.#marked.splice(this.#historyIndex);
124
144
  }
125
145
  this.#marked.push(this.#pending.splice(0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendaw/lib-box",
3
- "version": "0.0.53",
3
+ "version": "0.0.56",
4
4
  "sideEffects": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,12 +23,12 @@
23
23
  "test": "vitest run"
24
24
  },
25
25
  "dependencies": {
26
- "@opendaw/lib-runtime": "^0.0.53",
27
- "@opendaw/lib-std": "^0.0.53"
26
+ "@opendaw/lib-runtime": "^0.0.55",
27
+ "@opendaw/lib-std": "^0.0.55"
28
28
  },
29
29
  "devDependencies": {
30
- "@opendaw/eslint-config": "^0.0.20",
31
- "@opendaw/typescript-config": "^0.0.20"
30
+ "@opendaw/eslint-config": "^0.0.22",
31
+ "@opendaw/typescript-config": "^0.0.22"
32
32
  },
33
- "gitHead": "046a92e919f8489330255eaaf1703357c7b15098"
33
+ "gitHead": "99f8c7e3c6aadfea5e9fef05027b6817ab5bdf31"
34
34
  }