@opendaw/studio-core 0.0.128 → 0.0.130
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/capture/CaptureAudio.js +1 -1
- package/dist/processors.js +10 -10
- package/dist/processors.js.map +3 -3
- package/dist/ysync/YSync.d.ts +1 -0
- package/dist/ysync/YSync.d.ts.map +1 -1
- package/dist/ysync/YSync.js +29 -3
- package/package.json +5 -5
package/dist/ysync/YSync.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type Construct<T> = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare class YSync<T> implements Terminable {
|
|
10
10
|
#private;
|
|
11
|
+
/** @internal */
|
|
11
12
|
static isEmpty(doc: Y.Doc): boolean;
|
|
12
13
|
static populateRoom<T>({ boxGraph, boxes }: Construct<T>): Promise<YSync<T>>;
|
|
13
14
|
static joinRoom<T>({ boxGraph, boxes }: Construct<T>): Promise<YSync<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YSync.d.ts","sourceRoot":"","sources":["../../src/ysync/YSync.ts"],"names":[],"mappings":"AAAA,OAAO,EASH,QAAQ,EAER,UAAU,EAGb,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAa,QAAQ,EAA2D,MAAM,kBAAkB,CAAA;AAE/G,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACvB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtB,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;CAC/B,CAAA;AAED,qBAAa,KAAK,CAAC,CAAC,CAAE,YAAW,UAAU;;IACvC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,OAAO;WAItB,YAAY,CAAC,CAAC,EA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,IAAI,IAAI;CA4LpB"}
|
package/dist/ysync/YSync.js
CHANGED
|
@@ -2,6 +2,7 @@ import { asDefined, asInstanceOf, assert, EmptyExec, isUndefined, Option, panic,
|
|
|
2
2
|
import { YMapper } from "./YMapper";
|
|
3
3
|
import * as Y from "yjs";
|
|
4
4
|
export class YSync {
|
|
5
|
+
/** @internal */
|
|
5
6
|
static isEmpty(doc) {
|
|
6
7
|
return doc.getMap("boxes").size === 0;
|
|
7
8
|
}
|
|
@@ -33,31 +34,44 @@ export class YSync {
|
|
|
33
34
|
boxGraph.endTransaction();
|
|
34
35
|
return sync;
|
|
35
36
|
}
|
|
37
|
+
static #computePathPrefix(boxes) {
|
|
38
|
+
const prefix = [];
|
|
39
|
+
let item = boxes._item;
|
|
40
|
+
while (item !== null) {
|
|
41
|
+
prefix.unshift(item.parentSub);
|
|
42
|
+
const parent = item.parent;
|
|
43
|
+
item = parent._item;
|
|
44
|
+
}
|
|
45
|
+
return prefix;
|
|
46
|
+
}
|
|
36
47
|
#terminator = new Terminator();
|
|
37
48
|
#boxGraph;
|
|
38
49
|
#conflict;
|
|
39
50
|
#boxes;
|
|
40
51
|
#updates;
|
|
52
|
+
#pathPrefix;
|
|
41
53
|
#ignoreUpdates = false;
|
|
42
54
|
constructor({ boxGraph, boxes, conflict }) {
|
|
43
55
|
this.#boxGraph = boxGraph;
|
|
44
56
|
this.#conflict = Option.wrap(conflict);
|
|
45
57
|
this.#boxes = boxes;
|
|
46
58
|
this.#updates = [];
|
|
59
|
+
this.#pathPrefix = YSync.#computePathPrefix(boxes);
|
|
47
60
|
this.#terminator.ownAll(this.#setupYjs(), this.#setupOpenDAW());
|
|
48
61
|
}
|
|
49
62
|
terminate() { this.#terminator.terminate(); }
|
|
50
63
|
#setupYjs() {
|
|
51
64
|
const eventHandler = (events, { origin, local }) => {
|
|
52
65
|
const originLabel = typeof origin === "string" ? origin : "WebsocketProvider";
|
|
53
|
-
|
|
66
|
+
const isOwnOrigin = typeof origin === "string" && origin.startsWith("[openDAW]");
|
|
54
67
|
const isHistoryReplay = typeof origin === "string" && origin.startsWith("[history]");
|
|
55
|
-
|
|
68
|
+
console.debug(`got ${events.length} ${local ? "local" : "external"} updates from '${originLabel}', isHistoryReplay: ${isHistoryReplay}`);
|
|
69
|
+
if (isOwnOrigin || (local && !isHistoryReplay)) {
|
|
56
70
|
return;
|
|
57
71
|
}
|
|
58
72
|
this.#boxGraph.beginTransaction();
|
|
59
73
|
for (const event of events) {
|
|
60
|
-
const path = event.path;
|
|
74
|
+
const path = this.#normalizePath(event.path);
|
|
61
75
|
const keys = event.changes.keys;
|
|
62
76
|
for (const [key, change] of keys.entries()) {
|
|
63
77
|
if (change.action === "add") {
|
|
@@ -110,6 +124,18 @@ export class YSync {
|
|
|
110
124
|
YMapper.applyFromBoxMap(optBox.unwrap(), fields);
|
|
111
125
|
}
|
|
112
126
|
}
|
|
127
|
+
#normalizePath(path) {
|
|
128
|
+
const prefix = this.#pathPrefix;
|
|
129
|
+
if (prefix.length === 0 || path.length < prefix.length) {
|
|
130
|
+
return path;
|
|
131
|
+
}
|
|
132
|
+
for (let i = 0; i < prefix.length; i++) {
|
|
133
|
+
if (path[i] !== prefix[i]) {
|
|
134
|
+
return path;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return path.slice(prefix.length);
|
|
138
|
+
}
|
|
113
139
|
#updateValue(path, key) {
|
|
114
140
|
console.debug(`#updateValue`, path, key);
|
|
115
141
|
const vertexOption = this.#boxGraph.findVertex(YMapper.pathToAddress(path, key));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendaw/studio-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.130",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@opendaw/lib-runtime": "^0.0.75",
|
|
42
42
|
"@opendaw/lib-std": "^0.0.74",
|
|
43
43
|
"@opendaw/nam-wasm": "^1.0.3",
|
|
44
|
-
"@opendaw/studio-adapters": "^0.0.
|
|
44
|
+
"@opendaw/studio-adapters": "^0.0.102",
|
|
45
45
|
"@opendaw/studio-boxes": "^0.0.85",
|
|
46
46
|
"@opendaw/studio-enums": "^0.0.70",
|
|
47
47
|
"dropbox": "^10.34.0",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"@ffmpeg/ffmpeg": "^0.12.15",
|
|
58
58
|
"@ffmpeg/util": "^0.12.2",
|
|
59
59
|
"@opendaw/eslint-config": "^0.0.27",
|
|
60
|
-
"@opendaw/studio-core-processors": "^0.0.
|
|
61
|
-
"@opendaw/studio-core-workers": "^0.0.
|
|
60
|
+
"@opendaw/studio-core-processors": "^0.0.106",
|
|
61
|
+
"@opendaw/studio-core-workers": "^0.0.97",
|
|
62
62
|
"@opendaw/studio-forge-boxes": "^0.0.85",
|
|
63
63
|
"@opendaw/typescript-config": "^0.0.29"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "8e46cba2c2aba3ebb2ff49c764d039e0f9b8b820"
|
|
66
66
|
}
|