@opendaw/lib-box 0.0.61 → 0.0.63
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.map +1 -1
- package/dist/editing.js +43 -32
- package/dist/graph.d.ts +1 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +46 -0
- package/package.json +5 -5
package/dist/editing.d.ts.map
CHANGED
|
@@ -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,
|
|
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,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAA;AAqB1F,MAAM,WAAW,mBAAmB;IAChC,OAAO,IAAI,IAAI,CAAA;IACf,MAAM,IAAI,IAAI,CAAA;CACjB;AAED,qBAAa,UAAW,YAAW,OAAO;;gBAW1B,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;IAyB5E,iBAAiB,IAAI,mBAAmB;IAkCxC,IAAI,IAAI,IAAI;IAYZ,YAAY,IAAI,IAAI;IAMpB,OAAO,IAAI,IAAI;CAGlB"}
|
package/dist/editing.js
CHANGED
|
@@ -18,6 +18,7 @@ export class BoxEditing {
|
|
|
18
18
|
#pending = [];
|
|
19
19
|
#marked = [];
|
|
20
20
|
#modifying = false;
|
|
21
|
+
#inProcess = false;
|
|
21
22
|
#disabled = false;
|
|
22
23
|
#historyIndex = 0;
|
|
23
24
|
#savedHistoryIndex = 0; // -1 = saved state was spliced away, >= 0 = valid saved position
|
|
@@ -82,56 +83,66 @@ export class BoxEditing {
|
|
|
82
83
|
// See ParameterWrapper. Not the nicest solution. Probably coming back to this sooner or later.
|
|
83
84
|
mustModify() { return !this.#graph.inTransaction(); }
|
|
84
85
|
modify(modifier, mark = true) {
|
|
86
|
+
assert(!this.#inProcess, "Cannot call modify while a modification process is running");
|
|
85
87
|
if (this.#modifying) {
|
|
86
|
-
//
|
|
88
|
+
// Nested modify call - just execute without separate recording
|
|
87
89
|
return Option.wrap(modifier());
|
|
88
90
|
}
|
|
89
91
|
if (mark && this.#pending.length > 0) {
|
|
90
92
|
this.mark();
|
|
91
93
|
}
|
|
92
|
-
|
|
94
|
+
this.#modifying = true;
|
|
95
|
+
const updates = [];
|
|
96
|
+
const subscription = this.#graph.subscribeToAllUpdates({
|
|
97
|
+
onUpdate: (update) => updates.push(update)
|
|
98
|
+
});
|
|
99
|
+
this.#graph.beginTransaction();
|
|
100
|
+
const result = modifier();
|
|
101
|
+
this.#graph.endTransaction();
|
|
102
|
+
subscription.terminate();
|
|
103
|
+
if (updates.length > 0) {
|
|
104
|
+
this.#pending.push(new Modification(updates));
|
|
105
|
+
}
|
|
106
|
+
this.#modifying = false;
|
|
107
|
+
this.#graph.edges().validateRequirements();
|
|
93
108
|
if (mark) {
|
|
94
109
|
this.mark();
|
|
95
110
|
}
|
|
96
|
-
return result;
|
|
111
|
+
return Option.wrap(result);
|
|
97
112
|
}
|
|
98
113
|
beginModification() {
|
|
99
|
-
|
|
100
|
-
if (!alreadyIntransaction) {
|
|
101
|
-
this.#graph.beginTransaction();
|
|
102
|
-
}
|
|
114
|
+
assert(!this.#modifying && !this.#inProcess, "Cannot begin modification while another is in progress");
|
|
103
115
|
this.#modifying = true;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
116
|
+
this.#inProcess = true;
|
|
117
|
+
const updates = [];
|
|
118
|
+
const subscription = this.#graph.subscribeToAllUpdates({
|
|
119
|
+
onUpdate: (update) => updates.push(update)
|
|
120
|
+
});
|
|
121
|
+
this.#graph.beginTransaction();
|
|
122
|
+
return {
|
|
123
|
+
approve: () => {
|
|
107
124
|
this.#graph.endTransaction();
|
|
125
|
+
subscription.terminate();
|
|
126
|
+
if (updates.length > 0) {
|
|
127
|
+
this.#pending.push(new Modification(updates));
|
|
128
|
+
}
|
|
129
|
+
this.#modifying = false;
|
|
130
|
+
this.#inProcess = false;
|
|
108
131
|
this.#graph.edges().validateRequirements();
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
approve: complete,
|
|
132
|
+
this.mark();
|
|
133
|
+
},
|
|
113
134
|
revert: () => {
|
|
114
|
-
this.
|
|
115
|
-
|
|
135
|
+
this.#graph.endTransaction();
|
|
136
|
+
subscription.terminate();
|
|
137
|
+
this.#modifying = false;
|
|
138
|
+
this.#inProcess = false;
|
|
139
|
+
this.#graph.edges().validateRequirements();
|
|
140
|
+
if (updates.length > 0) {
|
|
141
|
+
new Modification(updates).inverse(this.#graph);
|
|
142
|
+
}
|
|
116
143
|
}
|
|
117
144
|
};
|
|
118
145
|
}
|
|
119
|
-
#modify(modifier) {
|
|
120
|
-
assert(!this.#modifying, "Already modifying");
|
|
121
|
-
this.#modifying = true;
|
|
122
|
-
const updates = [];
|
|
123
|
-
const subscription = this.#graph.subscribeToAllUpdates({ onUpdate: (update) => { updates.push(update); } });
|
|
124
|
-
this.#graph.beginTransaction();
|
|
125
|
-
const result = modifier();
|
|
126
|
-
this.#graph.endTransaction();
|
|
127
|
-
if (updates.length > 0) {
|
|
128
|
-
this.#pending.push(new Modification(updates));
|
|
129
|
-
}
|
|
130
|
-
subscription.terminate();
|
|
131
|
-
this.#modifying = false;
|
|
132
|
-
this.#graph.edges().validateRequirements();
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
146
|
mark() {
|
|
136
147
|
if (this.#pending.length === 0) {
|
|
137
148
|
return;
|
package/dist/graph.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare class BoxGraph<BoxMap = any> {
|
|
|
41
41
|
checksum(): Int8Array;
|
|
42
42
|
onPrimitiveValueUpdate<V extends PrimitiveValues>(field: PrimitiveField<V, any>, oldValue: V, newValue: V): void;
|
|
43
43
|
onPointerAddressUpdated(pointerField: PointerField, oldValue: Option<Address>, newValue: Option<Address>): void;
|
|
44
|
+
findOrphans(rootBox: Box): ReadonlyArray<Box>;
|
|
44
45
|
dependenciesOf(box: Box, options?: {
|
|
45
46
|
excludeBox?: Predicate<Box>;
|
|
46
47
|
alwaysFollowMandatory?: boolean;
|
package/dist/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,IAAI,EACJ,GAAG,EAEH,SAAS,EAET,MAAM,EACN,QAAQ,EAER,SAAS,EAET,SAAS,EAET,YAAY,EACZ,IAAI,EACP,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,cAAc,EAAE,eAAe,EAAC,MAAM,aAAa,CAAA;AAE3D,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings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AAE,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;IA8B/G,WAAW,CAAC,OAAO,EAAE,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC;IA6C7C,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE;QAC9B,UAAU,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;QAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAC7B,GAAG,YAAY;IAmCrB,cAAc,IAAI;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE;IAwBhC,UAAU,IAAI,IAAI;IAYlB,iBAAiB,IAAI,IAAI;IAUzB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IAS5D,aAAa,IAAI,eAAe;IAYhC,eAAe,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI;IA2BnD,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC;CAWhC"}
|
package/dist/graph.js
CHANGED
|
@@ -155,6 +155,50 @@ export class BoxGraph {
|
|
|
155
155
|
this.#dispatchers.dispatch(update);
|
|
156
156
|
this.#updateListeners.proxy.onUpdate(update);
|
|
157
157
|
}
|
|
158
|
+
findOrphans(rootBox) {
|
|
159
|
+
const connectedBoxes = this.#collectAllConnectedBoxes(rootBox);
|
|
160
|
+
return this.boxes().filter(box => !connectedBoxes.has(box));
|
|
161
|
+
}
|
|
162
|
+
#collectAllConnectedBoxes(rootBox) {
|
|
163
|
+
const visited = new Set();
|
|
164
|
+
const queue = [rootBox];
|
|
165
|
+
while (queue.length > 0) {
|
|
166
|
+
const box = queue.pop();
|
|
167
|
+
if (visited.has(box)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
visited.add(box);
|
|
171
|
+
this.#collectPointersFromBox(box).forEach(pointer => {
|
|
172
|
+
pointer.targetAddress.ifSome(address => {
|
|
173
|
+
this.findBox(address.uuid).ifSome(targetBox => {
|
|
174
|
+
if (!visited.has(targetBox)) {
|
|
175
|
+
queue.push(targetBox);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
for (const pointer of box.incomingEdges()) {
|
|
181
|
+
if (!visited.has(pointer.box)) {
|
|
182
|
+
queue.push(pointer.box);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return visited;
|
|
187
|
+
}
|
|
188
|
+
#collectPointersFromBox(box) {
|
|
189
|
+
const pointers = [];
|
|
190
|
+
const collectFromFields = (fields) => {
|
|
191
|
+
for (const field of fields) {
|
|
192
|
+
field.accept({
|
|
193
|
+
visitPointerField: (p) => pointers.push(p),
|
|
194
|
+
visitObjectField: (o) => collectFromFields(o.fields()),
|
|
195
|
+
visitArrayField: (a) => collectFromFields(a.fields())
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
collectFromFields(box.fields());
|
|
200
|
+
return pointers;
|
|
201
|
+
}
|
|
158
202
|
dependenciesOf(box, options = {}) {
|
|
159
203
|
const excludeBox = isDefined(options.excludeBox) ? options.excludeBox : Predicates.alwaysFalse;
|
|
160
204
|
const alwaysFollowMandatory = isDefined(options.alwaysFollowMandatory) ? options.alwaysFollowMandatory : false;
|
|
@@ -173,6 +217,8 @@ export class BoxGraph {
|
|
|
173
217
|
pointers.add(source);
|
|
174
218
|
if (targetVertex.pointerRules.mandatory &&
|
|
175
219
|
(alwaysFollowMandatory || targetVertex.pointerHub.incoming()
|
|
220
|
+
// Only check pointers to this specific address, not to other fields in the box
|
|
221
|
+
.filter(p => p.targetAddress.mapOr(address => address.equals(targetAddress), false))
|
|
176
222
|
.every(pointer => pointers.has(pointer)))) {
|
|
177
223
|
return trace(targetVertex.box);
|
|
178
224
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendaw/lib-box",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.63",
|
|
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.
|
|
27
|
-
"@opendaw/lib-std": "^0.0.
|
|
26
|
+
"@opendaw/lib-runtime": "^0.0.62",
|
|
27
|
+
"@opendaw/lib-std": "^0.0.62"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@opendaw/eslint-config": "^0.0.27",
|
|
31
|
-
"@opendaw/typescript-config": "^0.0.
|
|
31
|
+
"@opendaw/typescript-config": "^0.0.28"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "100e759378d7150e6eb7165232d8c4a1fbb77bbc"
|
|
34
34
|
}
|