@audiotool/nexus 0.0.9 → 0.0.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.
- package/dist/api.js +2 -2
- package/dist/{audiotool-api-o8DnCQiu.js → audiotool-api-D9u-oGp3.js} +191 -184
- package/dist/document/backend/create-wasm-document-state.d.ts +11 -0
- package/dist/document/backend/document-service/connection/index.d.ts +37 -0
- package/dist/document/backend/document-service/connection/ping-notifier.d.ts +20 -0
- package/dist/document/backend/document-service/connection/transaction-receiver.d.ts +26 -0
- package/dist/document/backend/document-service/connection/transaction-receiver.test.d.ts +1 -0
- package/dist/document/backend/document-service/connection/transaction-sender.d.ts +17 -0
- package/dist/document/backend/document-service/connection/transaction-sender.test.d.ts +1 -0
- package/dist/document/backend/document-service/gateway.d.ts +19 -33
- package/dist/document/backend/gateway.d.ts +7 -0
- package/dist/document/backend/validator.d.ts +2 -0
- package/dist/document/document.d.ts +9 -1
- package/dist/document/event-manager.d.ts +5 -0
- package/dist/document/mock/mock-document-state.d.ts +1 -0
- package/dist/document.js +1 -1
- package/dist/{get-schema-location-details-D2lXBgbu.js → get-schema-location-details-CI3Fi5PK.js} +1 -1
- package/dist/{observable-notifier-value-pw47I_2-.js → hash-map-CMrPM1s6.js} +87 -88
- package/dist/index.js +1062 -1000
- package/dist/lang-K-8hAzE4.js +40 -0
- package/dist/login-status.d.ts +1 -2
- package/dist/synced-document.d.ts +19 -1
- package/dist/utils/combine-notifiers.d.ts +1 -1
- package/dist/utils/grpc/retrying-client.d.ts +2 -0
- package/dist/utils/lang.d.ts +17 -8
- package/dist/utils.js +3 -3
- package/package.json +1 -1
- package/dist/document/backend/document-service/wrapper/buffered-sender.d.ts +0 -29
- package/dist/document/backend/document-service/wrapper/create-ping-loop.d.ts +0 -8
- package/dist/document/backend/document-service/wrapper/create-receive-next-transaction-fn.d.ts +0 -15
- package/dist/document/backend/document-service/wrapper/wrapper.d.ts +0 -41
- package/dist/document/init-collab-gateway.d.ts +0 -6
- package/dist/lang-BqPY1uAS.js +0 -22
- /package/dist/{document/backend/document-service/wrapper/buffered-sender.test.d.ts → audiotool-client.test.d.ts} +0 -0
- /package/dist/document/backend/document-service/{wrapper/wrapper.test.d.ts → connection/ping-notifier.test.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Wt = Object.defineProperty;
|
|
2
|
+
var jt = (i) => {
|
|
3
3
|
throw TypeError(i);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var s = (i, e, t) => (
|
|
8
|
-
import { aS as entityMessageToTypeKey, aT as mustUnpackEntity, aU as packEntity, aV as getEntityTypeKeyFromProtoName, aW as unpackEntity, aX as Preset, aY as anyEntityToTypeKey, aZ as createRetryingPromiseClient, a_ as createAuthorizedKeepaliveTransport, aR as createAudiotoolAPI, a$ as extractUuid, n as neverThrowingFetch } from "./audiotool-api-
|
|
9
|
-
import { Message, proto3,
|
|
5
|
+
var Gt = (i, e, t) => e in i ? Wt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
6
|
+
var a = (i, e, t) => Gt(i, typeof e != "symbol" ? e + "" : e, t), At = (i, e, t) => e.has(i) || jt("Cannot " + t);
|
|
7
|
+
var s = (i, e, t) => (At(i, e, "read from private field"), t ? t.call(i) : e.get(i)), h = (i, e, t) => e.has(i) ? jt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), g = (i, e, t, n) => (At(i, e, "write to private field"), n ? n.call(i, t) : e.set(i, t), t), y = (i, e, t) => (At(i, e, "access private method"), t);
|
|
8
|
+
import { aS as entityMessageToTypeKey, aT as mustUnpackEntity, aU as packEntity, aV as getEntityTypeKeyFromProtoName, aW as unpackEntity, aX as Preset, aY as anyEntityToTypeKey, aZ as createRetryingPromiseClient, a_ as createAuthorizedKeepaliveTransport, aR as createAudiotoolAPI, a$ as extractUuid, n as neverThrowingFetch } from "./audiotool-api-D9u-oGp3.js";
|
|
9
|
+
import { Message, proto3, protoInt64, Any, ScalarType, MethodKind } from "@bufbuild/protobuf";
|
|
10
10
|
import { P as Pointer, E as Empty, e as entityMessageTypes } from "./types-Cztu157p.js";
|
|
11
|
-
import { t as throw_, a as assert, b as asyncInterval, s as sleep } from "./lang-
|
|
12
|
-
import {
|
|
11
|
+
import { t as throw_, a as assert, b as asyncInterval, s as sleep } from "./lang-K-8hAzE4.js";
|
|
12
|
+
import { V as ValueNotifier, N as Notifier, h as hashSymbol, H as HashMap, A as AsyncLock } from "./hash-map-CMrPM1s6.js";
|
|
13
|
+
import { ConnectError, Code } from "@connectrpc/connect";
|
|
13
14
|
import { v5 } from "uuid";
|
|
14
|
-
import { s as schemaLocationToSchemaPath, a as schemaPathToSchemaLocation, g as getSchemaLocationDetails, _ as _getSchemaLocatorDetails } from "./get-schema-location-details-
|
|
15
|
+
import { s as schemaLocationToSchemaPath, a as schemaPathToSchemaLocation, g as getSchemaLocationDetails, _ as _getSchemaLocatorDetails } from "./get-schema-location-details-CI3Fi5PK.js";
|
|
15
16
|
import toposort from "toposort";
|
|
16
|
-
|
|
17
|
-
const F = class F extends Message {
|
|
17
|
+
const L = class L extends Message {
|
|
18
18
|
constructor(t) {
|
|
19
19
|
super();
|
|
20
20
|
/**
|
|
@@ -22,7 +22,7 @@ const F = class F extends Message {
|
|
|
22
22
|
*
|
|
23
23
|
* @generated from field: string project_name = 1;
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
a(this, "projectName", "");
|
|
26
26
|
/**
|
|
27
27
|
* The client_id is used to identify the client.
|
|
28
28
|
*
|
|
@@ -30,23 +30,23 @@ const F = class F extends Message {
|
|
|
30
30
|
*
|
|
31
31
|
* @generated from field: string client_id = 2;
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
a(this, "clientId", "");
|
|
34
34
|
proto3.util.initPartial(t, this);
|
|
35
35
|
}
|
|
36
36
|
static fromBinary(t, n) {
|
|
37
|
-
return new
|
|
37
|
+
return new L().fromBinary(t, n);
|
|
38
38
|
}
|
|
39
39
|
static fromJson(t, n) {
|
|
40
|
-
return new
|
|
40
|
+
return new L().fromJson(t, n);
|
|
41
41
|
}
|
|
42
42
|
static fromJsonString(t, n) {
|
|
43
|
-
return new
|
|
43
|
+
return new L().fromJsonString(t, n);
|
|
44
44
|
}
|
|
45
45
|
static equals(t, n) {
|
|
46
|
-
return proto3.util.equals(
|
|
46
|
+
return proto3.util.equals(L, t, n);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
a(L, "runtime", proto3), a(L, "typeName", "audiotool.document.v1.AttachMetadataRequest"), a(L, "fields", proto3.util.newFieldList(() => [
|
|
50
50
|
{
|
|
51
51
|
no: 1,
|
|
52
52
|
name: "project_name",
|
|
@@ -62,8 +62,8 @@ r(F, "runtime", proto3), r(F, "typeName", "audiotool.document.v1.AttachMetadataR
|
|
|
62
62
|
/* ScalarType.STRING */
|
|
63
63
|
}
|
|
64
64
|
]));
|
|
65
|
-
let AttachMetadataRequest =
|
|
66
|
-
const
|
|
65
|
+
let AttachMetadataRequest = L;
|
|
66
|
+
const U = class U extends Message {
|
|
67
67
|
constructor(t) {
|
|
68
68
|
super();
|
|
69
69
|
/**
|
|
@@ -71,36 +71,36 @@ const J = class J extends Message {
|
|
|
71
71
|
*
|
|
72
72
|
* @generated from field: string source_name = 1;
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
a(this, "sourceName", "");
|
|
75
75
|
/**
|
|
76
76
|
* The client_id is used to identify the client. A user can have multiple clients as he could
|
|
77
77
|
* have multiple devices or multiple tabs open.
|
|
78
78
|
*
|
|
79
79
|
* @generated from field: string client_id = 2;
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
a(this, "clientId", "");
|
|
82
82
|
/**
|
|
83
83
|
* The coordinates of the client can be blank.
|
|
84
84
|
*
|
|
85
85
|
* @generated from field: audiotool.document.v1.ClientCoordinates client_coordinates = 3;
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
a(this, "clientCoordinates");
|
|
88
88
|
proto3.util.initPartial(t, this);
|
|
89
89
|
}
|
|
90
90
|
static fromBinary(t, n) {
|
|
91
|
-
return new
|
|
91
|
+
return new U().fromBinary(t, n);
|
|
92
92
|
}
|
|
93
93
|
static fromJson(t, n) {
|
|
94
|
-
return new
|
|
94
|
+
return new U().fromJson(t, n);
|
|
95
95
|
}
|
|
96
96
|
static fromJsonString(t, n) {
|
|
97
|
-
return new
|
|
97
|
+
return new U().fromJsonString(t, n);
|
|
98
98
|
}
|
|
99
99
|
static equals(t, n) {
|
|
100
|
-
return proto3.util.equals(
|
|
100
|
+
return proto3.util.equals(U, t, n);
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
|
|
103
|
+
a(U, "runtime", proto3), a(U, "typeName", "audiotool.document.v1.AttachMetadataResponse"), a(U, "fields", proto3.util.newFieldList(() => [
|
|
104
104
|
{
|
|
105
105
|
no: 1,
|
|
106
106
|
name: "source_name",
|
|
@@ -117,8 +117,8 @@ r(J, "runtime", proto3), r(J, "typeName", "audiotool.document.v1.AttachMetadataR
|
|
|
117
117
|
},
|
|
118
118
|
{ no: 3, name: "client_coordinates", kind: "message", T: ClientCoordinates }
|
|
119
119
|
]));
|
|
120
|
-
let AttachMetadataResponse =
|
|
121
|
-
const
|
|
120
|
+
let AttachMetadataResponse = U;
|
|
121
|
+
const B = class B extends Message {
|
|
122
122
|
constructor(t) {
|
|
123
123
|
super();
|
|
124
124
|
/**
|
|
@@ -126,7 +126,7 @@ const C = class C extends Message {
|
|
|
126
126
|
*
|
|
127
127
|
* @generated from field: string project_name = 1;
|
|
128
128
|
*/
|
|
129
|
-
|
|
129
|
+
a(this, "projectName", "");
|
|
130
130
|
/**
|
|
131
131
|
* The client_id is used to identify the client.
|
|
132
132
|
*
|
|
@@ -134,29 +134,29 @@ const C = class C extends Message {
|
|
|
134
134
|
*
|
|
135
135
|
* @generated from field: string client_id = 2;
|
|
136
136
|
*/
|
|
137
|
-
|
|
137
|
+
a(this, "clientId", "");
|
|
138
138
|
/**
|
|
139
139
|
* The coordinates of the client can be blank.
|
|
140
140
|
*
|
|
141
141
|
* @generated from field: audiotool.document.v1.ClientCoordinates client_coordinates = 3;
|
|
142
142
|
*/
|
|
143
|
-
|
|
143
|
+
a(this, "clientCoordinates");
|
|
144
144
|
proto3.util.initPartial(t, this);
|
|
145
145
|
}
|
|
146
146
|
static fromBinary(t, n) {
|
|
147
|
-
return new
|
|
147
|
+
return new B().fromBinary(t, n);
|
|
148
148
|
}
|
|
149
149
|
static fromJson(t, n) {
|
|
150
|
-
return new
|
|
150
|
+
return new B().fromJson(t, n);
|
|
151
151
|
}
|
|
152
152
|
static fromJsonString(t, n) {
|
|
153
|
-
return new
|
|
153
|
+
return new B().fromJsonString(t, n);
|
|
154
154
|
}
|
|
155
155
|
static equals(t, n) {
|
|
156
|
-
return proto3.util.equals(
|
|
156
|
+
return proto3.util.equals(B, t, n);
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
|
-
|
|
159
|
+
a(B, "runtime", proto3), a(B, "typeName", "audiotool.document.v1.PutMetadataRequest"), a(B, "fields", proto3.util.newFieldList(() => [
|
|
160
160
|
{
|
|
161
161
|
no: 1,
|
|
162
162
|
name: "project_name",
|
|
@@ -173,27 +173,27 @@ r(C, "runtime", proto3), r(C, "typeName", "audiotool.document.v1.PutMetadataRequ
|
|
|
173
173
|
},
|
|
174
174
|
{ no: 3, name: "client_coordinates", kind: "message", T: ClientCoordinates }
|
|
175
175
|
]));
|
|
176
|
-
let PutMetadataRequest =
|
|
177
|
-
const
|
|
176
|
+
let PutMetadataRequest = B;
|
|
177
|
+
const C = class C extends Message {
|
|
178
178
|
constructor(e) {
|
|
179
179
|
super(), proto3.util.initPartial(e, this);
|
|
180
180
|
}
|
|
181
181
|
static fromBinary(e, t) {
|
|
182
|
-
return new
|
|
182
|
+
return new C().fromBinary(e, t);
|
|
183
183
|
}
|
|
184
184
|
static fromJson(e, t) {
|
|
185
|
-
return new
|
|
185
|
+
return new C().fromJson(e, t);
|
|
186
186
|
}
|
|
187
187
|
static fromJsonString(e, t) {
|
|
188
|
-
return new
|
|
188
|
+
return new C().fromJsonString(e, t);
|
|
189
189
|
}
|
|
190
190
|
static equals(e, t) {
|
|
191
|
-
return proto3.util.equals(
|
|
191
|
+
return proto3.util.equals(C, e, t);
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
|
-
|
|
195
|
-
let PutMetadataResponse =
|
|
196
|
-
const
|
|
194
|
+
a(C, "runtime", proto3), a(C, "typeName", "audiotool.document.v1.PutMetadataResponse"), a(C, "fields", proto3.util.newFieldList(() => []));
|
|
195
|
+
let PutMetadataResponse = C;
|
|
196
|
+
const A = class A extends Message {
|
|
197
197
|
constructor(t) {
|
|
198
198
|
super();
|
|
199
199
|
/**
|
|
@@ -201,13 +201,13 @@ const U = class U extends Message {
|
|
|
201
201
|
*
|
|
202
202
|
* @generated from field: double x = 1;
|
|
203
203
|
*/
|
|
204
|
-
|
|
204
|
+
a(this, "x", 0);
|
|
205
205
|
/**
|
|
206
206
|
* The y coordinate of the cursor.
|
|
207
207
|
*
|
|
208
208
|
* @generated from field: double y = 2;
|
|
209
209
|
*/
|
|
210
|
-
|
|
210
|
+
a(this, "y", 0);
|
|
211
211
|
/**
|
|
212
212
|
* The context is a client specific information like:
|
|
213
213
|
* - timeline
|
|
@@ -223,47 +223,47 @@ const U = class U extends Message {
|
|
|
223
223
|
*
|
|
224
224
|
* @generated from field: string context = 3;
|
|
225
225
|
*/
|
|
226
|
-
|
|
226
|
+
a(this, "context", "");
|
|
227
227
|
/**
|
|
228
228
|
* The height of the context - optional.
|
|
229
229
|
*
|
|
230
230
|
* @generated from field: double context_height = 4;
|
|
231
231
|
*/
|
|
232
|
-
|
|
232
|
+
a(this, "contextHeight", 0);
|
|
233
233
|
/**
|
|
234
234
|
* The width of the context - optional.
|
|
235
235
|
*
|
|
236
236
|
* @generated from field: double context_width = 5;
|
|
237
237
|
*/
|
|
238
|
-
|
|
238
|
+
a(this, "contextWidth", 0);
|
|
239
239
|
/**
|
|
240
240
|
* The x display value of the context - optional.
|
|
241
241
|
*
|
|
242
242
|
* @generated from field: double context_x = 6;
|
|
243
243
|
*/
|
|
244
|
-
|
|
244
|
+
a(this, "contextX", 0);
|
|
245
245
|
/**
|
|
246
246
|
* The y display value of the context - optional.
|
|
247
247
|
*
|
|
248
248
|
* @generated from field: double context_y = 7;
|
|
249
249
|
*/
|
|
250
|
-
|
|
250
|
+
a(this, "contextY", 0);
|
|
251
251
|
proto3.util.initPartial(t, this);
|
|
252
252
|
}
|
|
253
253
|
static fromBinary(t, n) {
|
|
254
|
-
return new
|
|
254
|
+
return new A().fromBinary(t, n);
|
|
255
255
|
}
|
|
256
256
|
static fromJson(t, n) {
|
|
257
|
-
return new
|
|
257
|
+
return new A().fromJson(t, n);
|
|
258
258
|
}
|
|
259
259
|
static fromJsonString(t, n) {
|
|
260
|
-
return new
|
|
260
|
+
return new A().fromJsonString(t, n);
|
|
261
261
|
}
|
|
262
262
|
static equals(t, n) {
|
|
263
|
-
return proto3.util.equals(
|
|
263
|
+
return proto3.util.equals(A, t, n);
|
|
264
264
|
}
|
|
265
265
|
};
|
|
266
|
-
|
|
266
|
+
a(A, "runtime", proto3), a(A, "typeName", "audiotool.document.v1.ClientCoordinates"), a(A, "fields", proto3.util.newFieldList(() => [
|
|
267
267
|
{
|
|
268
268
|
no: 1,
|
|
269
269
|
name: "x",
|
|
@@ -314,8 +314,8 @@ r(U, "runtime", proto3), r(U, "typeName", "audiotool.document.v1.ClientCoordinat
|
|
|
314
314
|
/* ScalarType.DOUBLE */
|
|
315
315
|
}
|
|
316
316
|
]));
|
|
317
|
-
let ClientCoordinates =
|
|
318
|
-
const
|
|
317
|
+
let ClientCoordinates = A;
|
|
318
|
+
const D = class D extends Message {
|
|
319
319
|
constructor(t) {
|
|
320
320
|
super();
|
|
321
321
|
/**
|
|
@@ -323,29 +323,29 @@ const B = class B extends Message {
|
|
|
323
323
|
*
|
|
324
324
|
* @generated from field: string project_name = 1;
|
|
325
325
|
*/
|
|
326
|
-
|
|
326
|
+
a(this, "projectName", "");
|
|
327
327
|
/**
|
|
328
328
|
* The filter is used to filter the entities.
|
|
329
329
|
*
|
|
330
330
|
* @generated from field: string filter = 2;
|
|
331
331
|
*/
|
|
332
|
-
|
|
332
|
+
a(this, "filter", "");
|
|
333
333
|
proto3.util.initPartial(t, this);
|
|
334
334
|
}
|
|
335
335
|
static fromBinary(t, n) {
|
|
336
|
-
return new
|
|
336
|
+
return new D().fromBinary(t, n);
|
|
337
337
|
}
|
|
338
338
|
static fromJson(t, n) {
|
|
339
|
-
return new
|
|
339
|
+
return new D().fromJson(t, n);
|
|
340
340
|
}
|
|
341
341
|
static fromJsonString(t, n) {
|
|
342
|
-
return new
|
|
342
|
+
return new D().fromJsonString(t, n);
|
|
343
343
|
}
|
|
344
344
|
static equals(t, n) {
|
|
345
|
-
return proto3.util.equals(
|
|
345
|
+
return proto3.util.equals(D, t, n);
|
|
346
346
|
}
|
|
347
347
|
};
|
|
348
|
-
|
|
348
|
+
a(D, "runtime", proto3), a(D, "typeName", "audiotool.document.v1.GetEntitiesRequest"), a(D, "fields", proto3.util.newFieldList(() => [
|
|
349
349
|
{
|
|
350
350
|
no: 1,
|
|
351
351
|
name: "project_name",
|
|
@@ -361,8 +361,8 @@ r(B, "runtime", proto3), r(B, "typeName", "audiotool.document.v1.GetEntitiesRequ
|
|
|
361
361
|
/* ScalarType.STRING */
|
|
362
362
|
}
|
|
363
363
|
]));
|
|
364
|
-
let GetEntitiesRequest =
|
|
365
|
-
const
|
|
364
|
+
let GetEntitiesRequest = D;
|
|
365
|
+
const q = class q extends Message {
|
|
366
366
|
constructor(t) {
|
|
367
367
|
super();
|
|
368
368
|
/**
|
|
@@ -371,27 +371,27 @@ const A = class A extends Message {
|
|
|
371
371
|
*
|
|
372
372
|
* @generated from field: repeated google.protobuf.Any entities = 1;
|
|
373
373
|
*/
|
|
374
|
-
|
|
374
|
+
a(this, "entities", []);
|
|
375
375
|
proto3.util.initPartial(t, this);
|
|
376
376
|
}
|
|
377
377
|
static fromBinary(t, n) {
|
|
378
|
-
return new
|
|
378
|
+
return new q().fromBinary(t, n);
|
|
379
379
|
}
|
|
380
380
|
static fromJson(t, n) {
|
|
381
|
-
return new
|
|
381
|
+
return new q().fromJson(t, n);
|
|
382
382
|
}
|
|
383
383
|
static fromJsonString(t, n) {
|
|
384
|
-
return new
|
|
384
|
+
return new q().fromJsonString(t, n);
|
|
385
385
|
}
|
|
386
386
|
static equals(t, n) {
|
|
387
|
-
return proto3.util.equals(
|
|
387
|
+
return proto3.util.equals(q, t, n);
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
|
-
|
|
390
|
+
a(q, "runtime", proto3), a(q, "typeName", "audiotool.document.v1.GetEntitiesResponse"), a(q, "fields", proto3.util.newFieldList(() => [
|
|
391
391
|
{ no: 1, name: "entities", kind: "message", T: Any, repeated: !0 }
|
|
392
392
|
]));
|
|
393
|
-
let GetEntitiesResponse =
|
|
394
|
-
const
|
|
393
|
+
let GetEntitiesResponse = q;
|
|
394
|
+
const O = class O extends Message {
|
|
395
395
|
constructor(t) {
|
|
396
396
|
super();
|
|
397
397
|
/**
|
|
@@ -399,7 +399,7 @@ const D = class D extends Message {
|
|
|
399
399
|
*
|
|
400
400
|
* @generated from field: string project_name = 1;
|
|
401
401
|
*/
|
|
402
|
-
|
|
402
|
+
a(this, "projectName", "");
|
|
403
403
|
/**
|
|
404
404
|
* The commit_index which the client has last seen.
|
|
405
405
|
*
|
|
@@ -416,23 +416,23 @@ const D = class D extends Message {
|
|
|
416
416
|
*
|
|
417
417
|
* @generated from field: uint32 commit_index = 2;
|
|
418
418
|
*/
|
|
419
|
-
|
|
419
|
+
a(this, "commitIndex", 0);
|
|
420
420
|
proto3.util.initPartial(t, this);
|
|
421
421
|
}
|
|
422
422
|
static fromBinary(t, n) {
|
|
423
|
-
return new
|
|
423
|
+
return new O().fromBinary(t, n);
|
|
424
424
|
}
|
|
425
425
|
static fromJson(t, n) {
|
|
426
|
-
return new
|
|
426
|
+
return new O().fromJson(t, n);
|
|
427
427
|
}
|
|
428
428
|
static fromJsonString(t, n) {
|
|
429
|
-
return new
|
|
429
|
+
return new O().fromJsonString(t, n);
|
|
430
430
|
}
|
|
431
431
|
static equals(t, n) {
|
|
432
|
-
return proto3.util.equals(
|
|
432
|
+
return proto3.util.equals(O, t, n);
|
|
433
433
|
}
|
|
434
434
|
};
|
|
435
|
-
|
|
435
|
+
a(O, "runtime", proto3), a(O, "typeName", "audiotool.document.v1.AttachRequest"), a(O, "fields", proto3.util.newFieldList(() => [
|
|
436
436
|
{
|
|
437
437
|
no: 1,
|
|
438
438
|
name: "project_name",
|
|
@@ -448,8 +448,8 @@ r(D, "runtime", proto3), r(D, "typeName", "audiotool.document.v1.AttachRequest")
|
|
|
448
448
|
/* ScalarType.UINT32 */
|
|
449
449
|
}
|
|
450
450
|
]));
|
|
451
|
-
let AttachRequest =
|
|
452
|
-
const
|
|
451
|
+
let AttachRequest = O;
|
|
452
|
+
const R = class R extends Message {
|
|
453
453
|
constructor(t) {
|
|
454
454
|
super();
|
|
455
455
|
/**
|
|
@@ -457,28 +457,28 @@ const O = class O extends Message {
|
|
|
457
457
|
*
|
|
458
458
|
* @generated from oneof audiotool.document.v1.AttachResponse.message
|
|
459
459
|
*/
|
|
460
|
-
|
|
460
|
+
a(this, "message", { case: void 0 });
|
|
461
461
|
proto3.util.initPartial(t, this);
|
|
462
462
|
}
|
|
463
463
|
static fromBinary(t, n) {
|
|
464
|
-
return new
|
|
464
|
+
return new R().fromBinary(t, n);
|
|
465
465
|
}
|
|
466
466
|
static fromJson(t, n) {
|
|
467
|
-
return new
|
|
467
|
+
return new R().fromJson(t, n);
|
|
468
468
|
}
|
|
469
469
|
static fromJsonString(t, n) {
|
|
470
|
-
return new
|
|
470
|
+
return new R().fromJsonString(t, n);
|
|
471
471
|
}
|
|
472
472
|
static equals(t, n) {
|
|
473
|
-
return proto3.util.equals(
|
|
473
|
+
return proto3.util.equals(R, t, n);
|
|
474
474
|
}
|
|
475
475
|
};
|
|
476
|
-
|
|
476
|
+
a(R, "runtime", proto3), a(R, "typeName", "audiotool.document.v1.AttachResponse"), a(R, "fields", proto3.util.newFieldList(() => [
|
|
477
477
|
{ no: 1, name: "transaction", kind: "message", T: Transaction, oneof: "message" },
|
|
478
478
|
{ no: 2, name: "noop", kind: "message", T: Noop, oneof: "message" }
|
|
479
479
|
]));
|
|
480
|
-
let AttachResponse =
|
|
481
|
-
const
|
|
480
|
+
let AttachResponse = R;
|
|
481
|
+
const j = class j extends Message {
|
|
482
482
|
constructor(t) {
|
|
483
483
|
super();
|
|
484
484
|
/**
|
|
@@ -486,23 +486,23 @@ const q = class q extends Message {
|
|
|
486
486
|
*
|
|
487
487
|
* @generated from field: uint32 server_commit_index = 1;
|
|
488
488
|
*/
|
|
489
|
-
|
|
489
|
+
a(this, "serverCommitIndex", 0);
|
|
490
490
|
proto3.util.initPartial(t, this);
|
|
491
491
|
}
|
|
492
492
|
static fromBinary(t, n) {
|
|
493
|
-
return new
|
|
493
|
+
return new j().fromBinary(t, n);
|
|
494
494
|
}
|
|
495
495
|
static fromJson(t, n) {
|
|
496
|
-
return new
|
|
496
|
+
return new j().fromJson(t, n);
|
|
497
497
|
}
|
|
498
498
|
static fromJsonString(t, n) {
|
|
499
|
-
return new
|
|
499
|
+
return new j().fromJsonString(t, n);
|
|
500
500
|
}
|
|
501
501
|
static equals(t, n) {
|
|
502
|
-
return proto3.util.equals(
|
|
502
|
+
return proto3.util.equals(j, t, n);
|
|
503
503
|
}
|
|
504
504
|
};
|
|
505
|
-
|
|
505
|
+
a(j, "runtime", proto3), a(j, "typeName", "audiotool.document.v1.Noop"), a(j, "fields", proto3.util.newFieldList(() => [
|
|
506
506
|
{
|
|
507
507
|
no: 1,
|
|
508
508
|
name: "server_commit_index",
|
|
@@ -511,8 +511,8 @@ r(q, "runtime", proto3), r(q, "typeName", "audiotool.document.v1.Noop"), r(q, "f
|
|
|
511
511
|
/* ScalarType.UINT32 */
|
|
512
512
|
}
|
|
513
513
|
]));
|
|
514
|
-
let Noop =
|
|
515
|
-
const
|
|
514
|
+
let Noop = j;
|
|
515
|
+
const $ = class $ extends Message {
|
|
516
516
|
constructor(t) {
|
|
517
517
|
super();
|
|
518
518
|
/**
|
|
@@ -521,28 +521,28 @@ const j = class j extends Message {
|
|
|
521
521
|
*
|
|
522
522
|
* @generated from oneof audiotool.document.v1.ModifyRequest.message
|
|
523
523
|
*/
|
|
524
|
-
|
|
524
|
+
a(this, "message", { case: void 0 });
|
|
525
525
|
proto3.util.initPartial(t, this);
|
|
526
526
|
}
|
|
527
527
|
static fromBinary(t, n) {
|
|
528
|
-
return new
|
|
528
|
+
return new $().fromBinary(t, n);
|
|
529
529
|
}
|
|
530
530
|
static fromJson(t, n) {
|
|
531
|
-
return new
|
|
531
|
+
return new $().fromJson(t, n);
|
|
532
532
|
}
|
|
533
533
|
static fromJsonString(t, n) {
|
|
534
|
-
return new
|
|
534
|
+
return new $().fromJsonString(t, n);
|
|
535
535
|
}
|
|
536
536
|
static equals(t, n) {
|
|
537
|
-
return proto3.util.equals(
|
|
537
|
+
return proto3.util.equals($, t, n);
|
|
538
538
|
}
|
|
539
539
|
};
|
|
540
|
-
|
|
540
|
+
a($, "runtime", proto3), a($, "typeName", "audiotool.document.v1.ModifyRequest"), a($, "fields", proto3.util.newFieldList(() => [
|
|
541
541
|
{ no: 1, name: "project_name", kind: "scalar", T: 9, oneof: "message" },
|
|
542
542
|
{ no: 2, name: "transaction", kind: "message", T: Transaction, oneof: "message" }
|
|
543
543
|
]));
|
|
544
|
-
let ModifyRequest =
|
|
545
|
-
const
|
|
544
|
+
let ModifyRequest = $;
|
|
545
|
+
const V = class V extends Message {
|
|
546
546
|
constructor(t) {
|
|
547
547
|
super();
|
|
548
548
|
/**
|
|
@@ -551,23 +551,23 @@ const R = class R extends Message {
|
|
|
551
551
|
*
|
|
552
552
|
* @generated from field: string error = 1;
|
|
553
553
|
*/
|
|
554
|
-
|
|
554
|
+
a(this, "error", "");
|
|
555
555
|
proto3.util.initPartial(t, this);
|
|
556
556
|
}
|
|
557
557
|
static fromBinary(t, n) {
|
|
558
|
-
return new
|
|
558
|
+
return new V().fromBinary(t, n);
|
|
559
559
|
}
|
|
560
560
|
static fromJson(t, n) {
|
|
561
|
-
return new
|
|
561
|
+
return new V().fromJson(t, n);
|
|
562
562
|
}
|
|
563
563
|
static fromJsonString(t, n) {
|
|
564
|
-
return new
|
|
564
|
+
return new V().fromJsonString(t, n);
|
|
565
565
|
}
|
|
566
566
|
static equals(t, n) {
|
|
567
|
-
return proto3.util.equals(
|
|
567
|
+
return proto3.util.equals(V, t, n);
|
|
568
568
|
}
|
|
569
569
|
};
|
|
570
|
-
|
|
570
|
+
a(V, "runtime", proto3), a(V, "typeName", "audiotool.document.v1.ModifyResponse"), a(V, "fields", proto3.util.newFieldList(() => [
|
|
571
571
|
{
|
|
572
572
|
no: 1,
|
|
573
573
|
name: "error",
|
|
@@ -576,8 +576,8 @@ r(R, "runtime", proto3), r(R, "typeName", "audiotool.document.v1.ModifyResponse"
|
|
|
576
576
|
/* ScalarType.STRING */
|
|
577
577
|
}
|
|
578
578
|
]));
|
|
579
|
-
let ModifyResponse =
|
|
580
|
-
const
|
|
579
|
+
let ModifyResponse = V;
|
|
580
|
+
const W = class W extends Message {
|
|
581
581
|
constructor(t) {
|
|
582
582
|
super();
|
|
583
583
|
/**
|
|
@@ -585,29 +585,29 @@ const $ = class $ extends Message {
|
|
|
585
585
|
*
|
|
586
586
|
* @generated from field: string project_name = 1;
|
|
587
587
|
*/
|
|
588
|
-
|
|
588
|
+
a(this, "projectName", "");
|
|
589
589
|
/**
|
|
590
590
|
* The transactions to apply to the document, in order.
|
|
591
591
|
*
|
|
592
592
|
* @generated from field: repeated audiotool.document.v1.Transaction transactions = 2;
|
|
593
593
|
*/
|
|
594
|
-
|
|
594
|
+
a(this, "transactions", []);
|
|
595
595
|
proto3.util.initPartial(t, this);
|
|
596
596
|
}
|
|
597
597
|
static fromBinary(t, n) {
|
|
598
|
-
return new
|
|
598
|
+
return new W().fromBinary(t, n);
|
|
599
599
|
}
|
|
600
600
|
static fromJson(t, n) {
|
|
601
|
-
return new
|
|
601
|
+
return new W().fromJson(t, n);
|
|
602
602
|
}
|
|
603
603
|
static fromJsonString(t, n) {
|
|
604
|
-
return new
|
|
604
|
+
return new W().fromJsonString(t, n);
|
|
605
605
|
}
|
|
606
606
|
static equals(t, n) {
|
|
607
|
-
return proto3.util.equals(
|
|
607
|
+
return proto3.util.equals(W, t, n);
|
|
608
608
|
}
|
|
609
609
|
};
|
|
610
|
-
|
|
610
|
+
a(W, "runtime", proto3), a(W, "typeName", "audiotool.document.v1.ApplyTransactionsRequest"), a(W, "fields", proto3.util.newFieldList(() => [
|
|
611
611
|
{
|
|
612
612
|
no: 1,
|
|
613
613
|
name: "project_name",
|
|
@@ -617,8 +617,8 @@ r($, "runtime", proto3), r($, "typeName", "audiotool.document.v1.ApplyTransactio
|
|
|
617
617
|
},
|
|
618
618
|
{ no: 2, name: "transactions", kind: "message", T: Transaction, repeated: !0 }
|
|
619
619
|
]));
|
|
620
|
-
let ApplyTransactionsRequest =
|
|
621
|
-
const
|
|
620
|
+
let ApplyTransactionsRequest = W;
|
|
621
|
+
const G = class G extends Message {
|
|
622
622
|
constructor(t) {
|
|
623
623
|
super();
|
|
624
624
|
/**
|
|
@@ -626,31 +626,31 @@ const V = class V extends Message {
|
|
|
626
626
|
*
|
|
627
627
|
* @generated from field: map<string, string> errors = 1;
|
|
628
628
|
*/
|
|
629
|
-
|
|
629
|
+
a(this, "errors", {});
|
|
630
630
|
proto3.util.initPartial(t, this);
|
|
631
631
|
}
|
|
632
632
|
static fromBinary(t, n) {
|
|
633
|
-
return new
|
|
633
|
+
return new G().fromBinary(t, n);
|
|
634
634
|
}
|
|
635
635
|
static fromJson(t, n) {
|
|
636
|
-
return new
|
|
636
|
+
return new G().fromJson(t, n);
|
|
637
637
|
}
|
|
638
638
|
static fromJsonString(t, n) {
|
|
639
|
-
return new
|
|
639
|
+
return new G().fromJsonString(t, n);
|
|
640
640
|
}
|
|
641
641
|
static equals(t, n) {
|
|
642
|
-
return proto3.util.equals(
|
|
642
|
+
return proto3.util.equals(G, t, n);
|
|
643
643
|
}
|
|
644
644
|
};
|
|
645
|
-
|
|
645
|
+
a(G, "runtime", proto3), a(G, "typeName", "audiotool.document.v1.ApplyTransactionsResponse"), a(G, "fields", proto3.util.newFieldList(() => [
|
|
646
646
|
{ no: 1, name: "errors", kind: "map", K: 9, V: {
|
|
647
647
|
kind: "scalar",
|
|
648
648
|
T: 9
|
|
649
649
|
/* ScalarType.STRING */
|
|
650
650
|
} }
|
|
651
651
|
]));
|
|
652
|
-
let ApplyTransactionsResponse =
|
|
653
|
-
const
|
|
652
|
+
let ApplyTransactionsResponse = G;
|
|
653
|
+
const z = class z extends Message {
|
|
654
654
|
constructor(t) {
|
|
655
655
|
super();
|
|
656
656
|
/**
|
|
@@ -659,36 +659,36 @@ const W = class W extends Message {
|
|
|
659
659
|
*
|
|
660
660
|
* @generated from field: string id = 1;
|
|
661
661
|
*/
|
|
662
|
-
|
|
662
|
+
a(this, "id", "");
|
|
663
663
|
/**
|
|
664
664
|
* An incremental number that is increased with each accepted transaction provided by the
|
|
665
665
|
* document-service.
|
|
666
666
|
*
|
|
667
667
|
* @generated from field: uint32 commit_index = 2;
|
|
668
668
|
*/
|
|
669
|
-
|
|
669
|
+
a(this, "commitIndex", 0);
|
|
670
670
|
/**
|
|
671
671
|
* A list of modifications to the document. The order of the modifications is important.
|
|
672
672
|
*
|
|
673
673
|
* @generated from field: repeated audiotool.document.v1.Modification modifications = 3;
|
|
674
674
|
*/
|
|
675
|
-
|
|
675
|
+
a(this, "modifications", []);
|
|
676
676
|
proto3.util.initPartial(t, this);
|
|
677
677
|
}
|
|
678
678
|
static fromBinary(t, n) {
|
|
679
|
-
return new
|
|
679
|
+
return new z().fromBinary(t, n);
|
|
680
680
|
}
|
|
681
681
|
static fromJson(t, n) {
|
|
682
|
-
return new
|
|
682
|
+
return new z().fromJson(t, n);
|
|
683
683
|
}
|
|
684
684
|
static fromJsonString(t, n) {
|
|
685
|
-
return new
|
|
685
|
+
return new z().fromJsonString(t, n);
|
|
686
686
|
}
|
|
687
687
|
static equals(t, n) {
|
|
688
|
-
return proto3.util.equals(
|
|
688
|
+
return proto3.util.equals(z, t, n);
|
|
689
689
|
}
|
|
690
690
|
};
|
|
691
|
-
|
|
691
|
+
a(z, "runtime", proto3), a(z, "typeName", "audiotool.document.v1.Transaction"), a(z, "fields", proto3.util.newFieldList(() => [
|
|
692
692
|
{
|
|
693
693
|
no: 1,
|
|
694
694
|
name: "id",
|
|
@@ -705,8 +705,8 @@ r(W, "runtime", proto3), r(W, "typeName", "audiotool.document.v1.Transaction"),
|
|
|
705
705
|
},
|
|
706
706
|
{ no: 3, name: "modifications", kind: "message", T: Modification, repeated: !0 }
|
|
707
707
|
]));
|
|
708
|
-
let Transaction =
|
|
709
|
-
const
|
|
708
|
+
let Transaction = z;
|
|
709
|
+
const K = class K extends Message {
|
|
710
710
|
constructor(t) {
|
|
711
711
|
super();
|
|
712
712
|
/**
|
|
@@ -714,29 +714,29 @@ const G = class G extends Message {
|
|
|
714
714
|
*
|
|
715
715
|
* @generated from oneof audiotool.document.v1.Modification.modification
|
|
716
716
|
*/
|
|
717
|
-
|
|
717
|
+
a(this, "modification", { case: void 0 });
|
|
718
718
|
proto3.util.initPartial(t, this);
|
|
719
719
|
}
|
|
720
720
|
static fromBinary(t, n) {
|
|
721
|
-
return new
|
|
721
|
+
return new K().fromBinary(t, n);
|
|
722
722
|
}
|
|
723
723
|
static fromJson(t, n) {
|
|
724
|
-
return new
|
|
724
|
+
return new K().fromJson(t, n);
|
|
725
725
|
}
|
|
726
726
|
static fromJsonString(t, n) {
|
|
727
|
-
return new
|
|
727
|
+
return new K().fromJsonString(t, n);
|
|
728
728
|
}
|
|
729
729
|
static equals(t, n) {
|
|
730
|
-
return proto3.util.equals(
|
|
730
|
+
return proto3.util.equals(K, t, n);
|
|
731
731
|
}
|
|
732
732
|
};
|
|
733
|
-
|
|
733
|
+
a(K, "runtime", proto3), a(K, "typeName", "audiotool.document.v1.Modification"), a(K, "fields", proto3.util.newFieldList(() => [
|
|
734
734
|
{ no: 2, name: "create", kind: "message", T: Create, oneof: "modification" },
|
|
735
735
|
{ no: 3, name: "delete", kind: "message", T: Delete, oneof: "modification" },
|
|
736
736
|
{ no: 4, name: "update", kind: "message", T: Update, oneof: "modification" }
|
|
737
737
|
]));
|
|
738
|
-
let Modification =
|
|
739
|
-
const
|
|
738
|
+
let Modification = K;
|
|
739
|
+
const H = class H extends Message {
|
|
740
740
|
constructor(t) {
|
|
741
741
|
super();
|
|
742
742
|
/**
|
|
@@ -744,27 +744,27 @@ const z = class z extends Message {
|
|
|
744
744
|
*
|
|
745
745
|
* @generated from field: google.protobuf.Any entity = 1;
|
|
746
746
|
*/
|
|
747
|
-
|
|
747
|
+
a(this, "entity");
|
|
748
748
|
proto3.util.initPartial(t, this);
|
|
749
749
|
}
|
|
750
750
|
static fromBinary(t, n) {
|
|
751
|
-
return new
|
|
751
|
+
return new H().fromBinary(t, n);
|
|
752
752
|
}
|
|
753
753
|
static fromJson(t, n) {
|
|
754
|
-
return new
|
|
754
|
+
return new H().fromJson(t, n);
|
|
755
755
|
}
|
|
756
756
|
static fromJsonString(t, n) {
|
|
757
|
-
return new
|
|
757
|
+
return new H().fromJsonString(t, n);
|
|
758
758
|
}
|
|
759
759
|
static equals(t, n) {
|
|
760
|
-
return proto3.util.equals(
|
|
760
|
+
return proto3.util.equals(H, t, n);
|
|
761
761
|
}
|
|
762
762
|
};
|
|
763
|
-
|
|
763
|
+
a(H, "runtime", proto3), a(H, "typeName", "audiotool.document.v1.Create"), a(H, "fields", proto3.util.newFieldList(() => [
|
|
764
764
|
{ no: 1, name: "entity", kind: "message", T: Any }
|
|
765
765
|
]));
|
|
766
|
-
let Create =
|
|
767
|
-
const
|
|
766
|
+
let Create = H;
|
|
767
|
+
const Q = class Q extends Message {
|
|
768
768
|
constructor(t) {
|
|
769
769
|
super();
|
|
770
770
|
/**
|
|
@@ -772,29 +772,29 @@ const K = class K extends Message {
|
|
|
772
772
|
*
|
|
773
773
|
* @generated from field: audiotool.document.v1.Pointer field = 1;
|
|
774
774
|
*/
|
|
775
|
-
|
|
775
|
+
a(this, "field");
|
|
776
776
|
/**
|
|
777
777
|
* The poossible values for an update
|
|
778
778
|
*
|
|
779
779
|
* @generated from oneof audiotool.document.v1.Update.value
|
|
780
780
|
*/
|
|
781
|
-
|
|
781
|
+
a(this, "value", { case: void 0 });
|
|
782
782
|
proto3.util.initPartial(t, this);
|
|
783
783
|
}
|
|
784
784
|
static fromBinary(t, n) {
|
|
785
|
-
return new
|
|
785
|
+
return new Q().fromBinary(t, n);
|
|
786
786
|
}
|
|
787
787
|
static fromJson(t, n) {
|
|
788
|
-
return new
|
|
788
|
+
return new Q().fromJson(t, n);
|
|
789
789
|
}
|
|
790
790
|
static fromJsonString(t, n) {
|
|
791
|
-
return new
|
|
791
|
+
return new Q().fromJsonString(t, n);
|
|
792
792
|
}
|
|
793
793
|
static equals(t, n) {
|
|
794
|
-
return proto3.util.equals(
|
|
794
|
+
return proto3.util.equals(Q, t, n);
|
|
795
795
|
}
|
|
796
796
|
};
|
|
797
|
-
|
|
797
|
+
a(Q, "runtime", proto3), a(Q, "typeName", "audiotool.document.v1.Update"), a(Q, "fields", proto3.util.newFieldList(() => [
|
|
798
798
|
{ no: 1, name: "field", kind: "message", T: Pointer },
|
|
799
799
|
{ no: 2, name: "double", kind: "scalar", T: 1, oneof: "value" },
|
|
800
800
|
{ no: 3, name: "float", kind: "scalar", T: 2, oneof: "value" },
|
|
@@ -813,8 +813,8 @@ r(K, "runtime", proto3), r(K, "typeName", "audiotool.document.v1.Update"), r(K,
|
|
|
813
813
|
{ no: 16, name: "bytes", kind: "scalar", T: 12, oneof: "value" },
|
|
814
814
|
{ no: 17, name: "pointer", kind: "message", T: Pointer, oneof: "value" }
|
|
815
815
|
]));
|
|
816
|
-
let Update =
|
|
817
|
-
const
|
|
816
|
+
let Update = Q;
|
|
817
|
+
const X = class X extends Message {
|
|
818
818
|
constructor(t) {
|
|
819
819
|
super();
|
|
820
820
|
/**
|
|
@@ -822,23 +822,23 @@ const H = class H extends Message {
|
|
|
822
822
|
*
|
|
823
823
|
* @generated from field: string entity_id = 1;
|
|
824
824
|
*/
|
|
825
|
-
|
|
825
|
+
a(this, "entityId", "");
|
|
826
826
|
proto3.util.initPartial(t, this);
|
|
827
827
|
}
|
|
828
828
|
static fromBinary(t, n) {
|
|
829
|
-
return new
|
|
829
|
+
return new X().fromBinary(t, n);
|
|
830
830
|
}
|
|
831
831
|
static fromJson(t, n) {
|
|
832
|
-
return new
|
|
832
|
+
return new X().fromJson(t, n);
|
|
833
833
|
}
|
|
834
834
|
static fromJsonString(t, n) {
|
|
835
|
-
return new
|
|
835
|
+
return new X().fromJsonString(t, n);
|
|
836
836
|
}
|
|
837
837
|
static equals(t, n) {
|
|
838
|
-
return proto3.util.equals(
|
|
838
|
+
return proto3.util.equals(X, t, n);
|
|
839
839
|
}
|
|
840
840
|
};
|
|
841
|
-
|
|
841
|
+
a(X, "runtime", proto3), a(X, "typeName", "audiotool.document.v1.Delete"), a(X, "fields", proto3.util.newFieldList(() => [
|
|
842
842
|
{
|
|
843
843
|
no: 1,
|
|
844
844
|
name: "entity_id",
|
|
@@ -847,27 +847,27 @@ r(H, "runtime", proto3), r(H, "typeName", "audiotool.document.v1.Delete"), r(H,
|
|
|
847
847
|
/* ScalarType.STRING */
|
|
848
848
|
}
|
|
849
849
|
]));
|
|
850
|
-
let Delete =
|
|
851
|
-
const
|
|
850
|
+
let Delete = X;
|
|
851
|
+
const Y = class Y extends Message {
|
|
852
852
|
constructor(e) {
|
|
853
853
|
super(), proto3.util.initPartial(e, this);
|
|
854
854
|
}
|
|
855
855
|
static fromBinary(e, t) {
|
|
856
|
-
return new
|
|
856
|
+
return new Y().fromBinary(e, t);
|
|
857
857
|
}
|
|
858
858
|
static fromJson(e, t) {
|
|
859
|
-
return new
|
|
859
|
+
return new Y().fromJson(e, t);
|
|
860
860
|
}
|
|
861
861
|
static fromJsonString(e, t) {
|
|
862
|
-
return new
|
|
862
|
+
return new Y().fromJsonString(e, t);
|
|
863
863
|
}
|
|
864
864
|
static equals(e, t) {
|
|
865
|
-
return proto3.util.equals(
|
|
865
|
+
return proto3.util.equals(Y, e, t);
|
|
866
866
|
}
|
|
867
867
|
};
|
|
868
|
-
|
|
869
|
-
let GetWasmRequest =
|
|
870
|
-
const
|
|
868
|
+
a(Y, "runtime", proto3), a(Y, "typeName", "audiotool.document.v1.GetWasmRequest"), a(Y, "fields", proto3.util.newFieldList(() => []));
|
|
869
|
+
let GetWasmRequest = Y;
|
|
870
|
+
const Z = class Z extends Message {
|
|
871
871
|
constructor(t) {
|
|
872
872
|
super();
|
|
873
873
|
/**
|
|
@@ -875,23 +875,23 @@ const X = class X extends Message {
|
|
|
875
875
|
*
|
|
876
876
|
* @generated from field: bytes data = 1;
|
|
877
877
|
*/
|
|
878
|
-
|
|
878
|
+
a(this, "data", new Uint8Array(0));
|
|
879
879
|
proto3.util.initPartial(t, this);
|
|
880
880
|
}
|
|
881
881
|
static fromBinary(t, n) {
|
|
882
|
-
return new
|
|
882
|
+
return new Z().fromBinary(t, n);
|
|
883
883
|
}
|
|
884
884
|
static fromJson(t, n) {
|
|
885
|
-
return new
|
|
885
|
+
return new Z().fromJson(t, n);
|
|
886
886
|
}
|
|
887
887
|
static fromJsonString(t, n) {
|
|
888
|
-
return new
|
|
888
|
+
return new Z().fromJsonString(t, n);
|
|
889
889
|
}
|
|
890
890
|
static equals(t, n) {
|
|
891
|
-
return proto3.util.equals(
|
|
891
|
+
return proto3.util.equals(Z, t, n);
|
|
892
892
|
}
|
|
893
893
|
};
|
|
894
|
-
|
|
894
|
+
a(Z, "runtime", proto3), a(Z, "typeName", "audiotool.document.v1.GetWasmResponse"), a(Z, "fields", proto3.util.newFieldList(() => [
|
|
895
895
|
{
|
|
896
896
|
no: 1,
|
|
897
897
|
name: "data",
|
|
@@ -900,27 +900,27 @@ r(X, "runtime", proto3), r(X, "typeName", "audiotool.document.v1.GetWasmResponse
|
|
|
900
900
|
/* ScalarType.BYTES */
|
|
901
901
|
}
|
|
902
902
|
]));
|
|
903
|
-
let GetWasmResponse =
|
|
904
|
-
const
|
|
903
|
+
let GetWasmResponse = Z;
|
|
904
|
+
const _ = class _ extends Message {
|
|
905
905
|
constructor(e) {
|
|
906
906
|
super(), proto3.util.initPartial(e, this);
|
|
907
907
|
}
|
|
908
908
|
static fromBinary(e, t) {
|
|
909
|
-
return new
|
|
909
|
+
return new _().fromBinary(e, t);
|
|
910
910
|
}
|
|
911
911
|
static fromJson(e, t) {
|
|
912
|
-
return new
|
|
912
|
+
return new _().fromJson(e, t);
|
|
913
913
|
}
|
|
914
914
|
static fromJsonString(e, t) {
|
|
915
|
-
return new
|
|
915
|
+
return new _().fromJsonString(e, t);
|
|
916
916
|
}
|
|
917
917
|
static equals(e, t) {
|
|
918
|
-
return proto3.util.equals(
|
|
918
|
+
return proto3.util.equals(_, e, t);
|
|
919
919
|
}
|
|
920
920
|
};
|
|
921
|
-
|
|
922
|
-
let GetWasmExecRequest =
|
|
923
|
-
const
|
|
921
|
+
a(_, "runtime", proto3), a(_, "typeName", "audiotool.document.v1.GetWasmExecRequest"), a(_, "fields", proto3.util.newFieldList(() => []));
|
|
922
|
+
let GetWasmExecRequest = _;
|
|
923
|
+
const tt = class tt extends Message {
|
|
924
924
|
constructor(t) {
|
|
925
925
|
super();
|
|
926
926
|
/**
|
|
@@ -928,23 +928,23 @@ const Z = class Z extends Message {
|
|
|
928
928
|
*
|
|
929
929
|
* @generated from field: string data = 1;
|
|
930
930
|
*/
|
|
931
|
-
|
|
931
|
+
a(this, "data", "");
|
|
932
932
|
proto3.util.initPartial(t, this);
|
|
933
933
|
}
|
|
934
934
|
static fromBinary(t, n) {
|
|
935
|
-
return new
|
|
935
|
+
return new tt().fromBinary(t, n);
|
|
936
936
|
}
|
|
937
937
|
static fromJson(t, n) {
|
|
938
|
-
return new
|
|
938
|
+
return new tt().fromJson(t, n);
|
|
939
939
|
}
|
|
940
940
|
static fromJsonString(t, n) {
|
|
941
|
-
return new
|
|
941
|
+
return new tt().fromJsonString(t, n);
|
|
942
942
|
}
|
|
943
943
|
static equals(t, n) {
|
|
944
|
-
return proto3.util.equals(
|
|
944
|
+
return proto3.util.equals(tt, t, n);
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
|
-
|
|
947
|
+
a(tt, "runtime", proto3), a(tt, "typeName", "audiotool.document.v1.GetWasmExecResponse"), a(tt, "fields", proto3.util.newFieldList(() => [
|
|
948
948
|
{
|
|
949
949
|
no: 1,
|
|
950
950
|
name: "data",
|
|
@@ -953,8 +953,8 @@ r(Z, "runtime", proto3), r(Z, "typeName", "audiotool.document.v1.GetWasmExecResp
|
|
|
953
953
|
/* ScalarType.STRING */
|
|
954
954
|
}
|
|
955
955
|
]));
|
|
956
|
-
let GetWasmExecResponse =
|
|
957
|
-
const
|
|
956
|
+
let GetWasmExecResponse = tt;
|
|
957
|
+
const et = class et extends Message {
|
|
958
958
|
constructor(t) {
|
|
959
959
|
super();
|
|
960
960
|
/**
|
|
@@ -962,36 +962,36 @@ const _ = class _ extends Message {
|
|
|
962
962
|
*
|
|
963
963
|
* @generated from field: string project_name = 1;
|
|
964
964
|
*/
|
|
965
|
-
|
|
965
|
+
a(this, "projectName", "");
|
|
966
966
|
/**
|
|
967
967
|
* The client id is used to identify the client.
|
|
968
968
|
*
|
|
969
969
|
* @generated from field: string client_id = 2;
|
|
970
970
|
*/
|
|
971
|
-
|
|
971
|
+
a(this, "clientId", "");
|
|
972
972
|
/**
|
|
973
973
|
* The last ping duration in ms measured by the client.
|
|
974
974
|
* if left empty, the server will not count the ping.
|
|
975
975
|
*
|
|
976
976
|
* @generated from field: uint32 last_ping_ms = 3;
|
|
977
977
|
*/
|
|
978
|
-
|
|
978
|
+
a(this, "lastPingMs", 0);
|
|
979
979
|
proto3.util.initPartial(t, this);
|
|
980
980
|
}
|
|
981
981
|
static fromBinary(t, n) {
|
|
982
|
-
return new
|
|
982
|
+
return new et().fromBinary(t, n);
|
|
983
983
|
}
|
|
984
984
|
static fromJson(t, n) {
|
|
985
|
-
return new
|
|
985
|
+
return new et().fromJson(t, n);
|
|
986
986
|
}
|
|
987
987
|
static fromJsonString(t, n) {
|
|
988
|
-
return new
|
|
988
|
+
return new et().fromJsonString(t, n);
|
|
989
989
|
}
|
|
990
990
|
static equals(t, n) {
|
|
991
|
-
return proto3.util.equals(
|
|
991
|
+
return proto3.util.equals(et, t, n);
|
|
992
992
|
}
|
|
993
993
|
};
|
|
994
|
-
|
|
994
|
+
a(et, "runtime", proto3), a(et, "typeName", "audiotool.document.v1.PingRequest"), a(et, "fields", proto3.util.newFieldList(() => [
|
|
995
995
|
{
|
|
996
996
|
no: 1,
|
|
997
997
|
name: "project_name",
|
|
@@ -1014,27 +1014,27 @@ r(_, "runtime", proto3), r(_, "typeName", "audiotool.document.v1.PingRequest"),
|
|
|
1014
1014
|
/* ScalarType.UINT32 */
|
|
1015
1015
|
}
|
|
1016
1016
|
]));
|
|
1017
|
-
let PingRequest =
|
|
1018
|
-
const
|
|
1017
|
+
let PingRequest = et;
|
|
1018
|
+
const nt = class nt extends Message {
|
|
1019
1019
|
constructor(e) {
|
|
1020
1020
|
super(), proto3.util.initPartial(e, this);
|
|
1021
1021
|
}
|
|
1022
1022
|
static fromBinary(e, t) {
|
|
1023
|
-
return new
|
|
1023
|
+
return new nt().fromBinary(e, t);
|
|
1024
1024
|
}
|
|
1025
1025
|
static fromJson(e, t) {
|
|
1026
|
-
return new
|
|
1026
|
+
return new nt().fromJson(e, t);
|
|
1027
1027
|
}
|
|
1028
1028
|
static fromJsonString(e, t) {
|
|
1029
|
-
return new
|
|
1029
|
+
return new nt().fromJsonString(e, t);
|
|
1030
1030
|
}
|
|
1031
1031
|
static equals(e, t) {
|
|
1032
|
-
return proto3.util.equals(
|
|
1032
|
+
return proto3.util.equals(nt, e, t);
|
|
1033
1033
|
}
|
|
1034
1034
|
};
|
|
1035
|
-
|
|
1036
|
-
let PingResponse =
|
|
1037
|
-
const
|
|
1035
|
+
a(nt, "runtime", proto3), a(nt, "typeName", "audiotool.document.v1.PingResponse"), a(nt, "fields", proto3.util.newFieldList(() => []));
|
|
1036
|
+
let PingResponse = nt;
|
|
1037
|
+
const it = class it extends Message {
|
|
1038
1038
|
constructor(t) {
|
|
1039
1039
|
super();
|
|
1040
1040
|
/**
|
|
@@ -1042,23 +1042,23 @@ const et = class et extends Message {
|
|
|
1042
1042
|
*
|
|
1043
1043
|
* @generated from field: string project_name = 1;
|
|
1044
1044
|
*/
|
|
1045
|
-
|
|
1045
|
+
a(this, "projectName", "");
|
|
1046
1046
|
proto3.util.initPartial(t, this);
|
|
1047
1047
|
}
|
|
1048
1048
|
static fromBinary(t, n) {
|
|
1049
|
-
return new
|
|
1049
|
+
return new it().fromBinary(t, n);
|
|
1050
1050
|
}
|
|
1051
1051
|
static fromJson(t, n) {
|
|
1052
|
-
return new
|
|
1052
|
+
return new it().fromJson(t, n);
|
|
1053
1053
|
}
|
|
1054
1054
|
static fromJsonString(t, n) {
|
|
1055
|
-
return new
|
|
1055
|
+
return new it().fromJsonString(t, n);
|
|
1056
1056
|
}
|
|
1057
1057
|
static equals(t, n) {
|
|
1058
|
-
return proto3.util.equals(
|
|
1058
|
+
return proto3.util.equals(it, t, n);
|
|
1059
1059
|
}
|
|
1060
1060
|
};
|
|
1061
|
-
|
|
1061
|
+
a(it, "runtime", proto3), a(it, "typeName", "audiotool.document.v1.GetClientStatsRequest"), a(it, "fields", proto3.util.newFieldList(() => [
|
|
1062
1062
|
{
|
|
1063
1063
|
no: 1,
|
|
1064
1064
|
name: "project_name",
|
|
@@ -1067,8 +1067,8 @@ r(et, "runtime", proto3), r(et, "typeName", "audiotool.document.v1.GetClientStat
|
|
|
1067
1067
|
/* ScalarType.STRING */
|
|
1068
1068
|
}
|
|
1069
1069
|
]));
|
|
1070
|
-
let GetClientStatsRequest =
|
|
1071
|
-
const
|
|
1070
|
+
let GetClientStatsRequest = it;
|
|
1071
|
+
const ot = class ot extends Message {
|
|
1072
1072
|
constructor(t) {
|
|
1073
1073
|
super();
|
|
1074
1074
|
/**
|
|
@@ -1076,27 +1076,27 @@ const nt = class nt extends Message {
|
|
|
1076
1076
|
*
|
|
1077
1077
|
* @generated from field: repeated audiotool.document.v1.ClientInfo client_info = 1;
|
|
1078
1078
|
*/
|
|
1079
|
-
|
|
1079
|
+
a(this, "clientInfo", []);
|
|
1080
1080
|
proto3.util.initPartial(t, this);
|
|
1081
1081
|
}
|
|
1082
1082
|
static fromBinary(t, n) {
|
|
1083
|
-
return new
|
|
1083
|
+
return new ot().fromBinary(t, n);
|
|
1084
1084
|
}
|
|
1085
1085
|
static fromJson(t, n) {
|
|
1086
|
-
return new
|
|
1086
|
+
return new ot().fromJson(t, n);
|
|
1087
1087
|
}
|
|
1088
1088
|
static fromJsonString(t, n) {
|
|
1089
|
-
return new
|
|
1089
|
+
return new ot().fromJsonString(t, n);
|
|
1090
1090
|
}
|
|
1091
1091
|
static equals(t, n) {
|
|
1092
|
-
return proto3.util.equals(
|
|
1092
|
+
return proto3.util.equals(ot, t, n);
|
|
1093
1093
|
}
|
|
1094
1094
|
};
|
|
1095
|
-
|
|
1095
|
+
a(ot, "runtime", proto3), a(ot, "typeName", "audiotool.document.v1.GetClientStatsResponse"), a(ot, "fields", proto3.util.newFieldList(() => [
|
|
1096
1096
|
{ no: 1, name: "client_info", kind: "message", T: ClientInfo, repeated: !0 }
|
|
1097
1097
|
]));
|
|
1098
|
-
let GetClientStatsResponse =
|
|
1099
|
-
const
|
|
1098
|
+
let GetClientStatsResponse = ot;
|
|
1099
|
+
const rt = class rt extends Message {
|
|
1100
1100
|
constructor(t) {
|
|
1101
1101
|
super();
|
|
1102
1102
|
/**
|
|
@@ -1104,42 +1104,42 @@ const it = class it extends Message {
|
|
|
1104
1104
|
*
|
|
1105
1105
|
* @generated from field: string id = 1;
|
|
1106
1106
|
*/
|
|
1107
|
-
|
|
1107
|
+
a(this, "id", "");
|
|
1108
1108
|
/**
|
|
1109
1109
|
* the client's ping
|
|
1110
1110
|
*
|
|
1111
1111
|
* @generated from field: uint32 ping_ms = 2;
|
|
1112
1112
|
*/
|
|
1113
|
-
|
|
1113
|
+
a(this, "pingMs", 0);
|
|
1114
1114
|
/**
|
|
1115
1115
|
* set if client is offline
|
|
1116
1116
|
*
|
|
1117
1117
|
* @generated from field: bool offline = 3;
|
|
1118
1118
|
*/
|
|
1119
|
-
|
|
1119
|
+
a(this, "offline", !1);
|
|
1120
1120
|
/**
|
|
1121
1121
|
* The source name of the client. This can be a user name in the form of 'users/{id}' but is not
|
|
1122
1122
|
* guaranteed to be a user.
|
|
1123
1123
|
*
|
|
1124
1124
|
* @generated from field: string source_name = 4;
|
|
1125
1125
|
*/
|
|
1126
|
-
|
|
1126
|
+
a(this, "sourceName", "");
|
|
1127
1127
|
proto3.util.initPartial(t, this);
|
|
1128
1128
|
}
|
|
1129
1129
|
static fromBinary(t, n) {
|
|
1130
|
-
return new
|
|
1130
|
+
return new rt().fromBinary(t, n);
|
|
1131
1131
|
}
|
|
1132
1132
|
static fromJson(t, n) {
|
|
1133
|
-
return new
|
|
1133
|
+
return new rt().fromJson(t, n);
|
|
1134
1134
|
}
|
|
1135
1135
|
static fromJsonString(t, n) {
|
|
1136
|
-
return new
|
|
1136
|
+
return new rt().fromJsonString(t, n);
|
|
1137
1137
|
}
|
|
1138
1138
|
static equals(t, n) {
|
|
1139
|
-
return proto3.util.equals(
|
|
1139
|
+
return proto3.util.equals(rt, t, n);
|
|
1140
1140
|
}
|
|
1141
1141
|
};
|
|
1142
|
-
|
|
1142
|
+
a(rt, "runtime", proto3), a(rt, "typeName", "audiotool.document.v1.ClientInfo"), a(rt, "fields", proto3.util.newFieldList(() => [
|
|
1143
1143
|
{
|
|
1144
1144
|
no: 1,
|
|
1145
1145
|
name: "id",
|
|
@@ -1169,27 +1169,27 @@ r(it, "runtime", proto3), r(it, "typeName", "audiotool.document.v1.ClientInfo"),
|
|
|
1169
1169
|
/* ScalarType.STRING */
|
|
1170
1170
|
}
|
|
1171
1171
|
]));
|
|
1172
|
-
let ClientInfo =
|
|
1173
|
-
const
|
|
1172
|
+
let ClientInfo = rt;
|
|
1173
|
+
const at = class at extends Message {
|
|
1174
1174
|
constructor(e) {
|
|
1175
1175
|
super(), proto3.util.initPartial(e, this);
|
|
1176
1176
|
}
|
|
1177
1177
|
static fromBinary(e, t) {
|
|
1178
|
-
return new
|
|
1178
|
+
return new at().fromBinary(e, t);
|
|
1179
1179
|
}
|
|
1180
1180
|
static fromJson(e, t) {
|
|
1181
|
-
return new
|
|
1181
|
+
return new at().fromJson(e, t);
|
|
1182
1182
|
}
|
|
1183
1183
|
static fromJsonString(e, t) {
|
|
1184
|
-
return new
|
|
1184
|
+
return new at().fromJsonString(e, t);
|
|
1185
1185
|
}
|
|
1186
1186
|
static equals(e, t) {
|
|
1187
|
-
return proto3.util.equals(
|
|
1187
|
+
return proto3.util.equals(at, e, t);
|
|
1188
1188
|
}
|
|
1189
1189
|
};
|
|
1190
|
-
|
|
1191
|
-
let GetVersionRequest =
|
|
1192
|
-
const
|
|
1190
|
+
a(at, "runtime", proto3), a(at, "typeName", "audiotool.document.v1.GetVersionRequest"), a(at, "fields", proto3.util.newFieldList(() => []));
|
|
1191
|
+
let GetVersionRequest = at;
|
|
1192
|
+
const st = class st extends Message {
|
|
1193
1193
|
constructor(t) {
|
|
1194
1194
|
super();
|
|
1195
1195
|
/**
|
|
@@ -1197,23 +1197,23 @@ const rt = class rt extends Message {
|
|
|
1197
1197
|
*
|
|
1198
1198
|
* @generated from field: string version = 1;
|
|
1199
1199
|
*/
|
|
1200
|
-
|
|
1200
|
+
a(this, "version", "");
|
|
1201
1201
|
proto3.util.initPartial(t, this);
|
|
1202
1202
|
}
|
|
1203
1203
|
static fromBinary(t, n) {
|
|
1204
|
-
return new
|
|
1204
|
+
return new st().fromBinary(t, n);
|
|
1205
1205
|
}
|
|
1206
1206
|
static fromJson(t, n) {
|
|
1207
|
-
return new
|
|
1207
|
+
return new st().fromJson(t, n);
|
|
1208
1208
|
}
|
|
1209
1209
|
static fromJsonString(t, n) {
|
|
1210
|
-
return new
|
|
1210
|
+
return new st().fromJsonString(t, n);
|
|
1211
1211
|
}
|
|
1212
1212
|
static equals(t, n) {
|
|
1213
|
-
return proto3.util.equals(
|
|
1213
|
+
return proto3.util.equals(st, t, n);
|
|
1214
1214
|
}
|
|
1215
1215
|
};
|
|
1216
|
-
|
|
1216
|
+
a(st, "runtime", proto3), a(st, "typeName", "audiotool.document.v1.GetVersionResponse"), a(st, "fields", proto3.util.newFieldList(() => [
|
|
1217
1217
|
{
|
|
1218
1218
|
no: 1,
|
|
1219
1219
|
name: "version",
|
|
@@ -1222,27 +1222,27 @@ r(rt, "runtime", proto3), r(rt, "typeName", "audiotool.document.v1.GetVersionRes
|
|
|
1222
1222
|
/* ScalarType.STRING */
|
|
1223
1223
|
}
|
|
1224
1224
|
]));
|
|
1225
|
-
let GetVersionResponse =
|
|
1226
|
-
const
|
|
1225
|
+
let GetVersionResponse = st;
|
|
1226
|
+
const ct = class ct extends Message {
|
|
1227
1227
|
constructor(e) {
|
|
1228
1228
|
super(), proto3.util.initPartial(e, this);
|
|
1229
1229
|
}
|
|
1230
1230
|
static fromBinary(e, t) {
|
|
1231
|
-
return new
|
|
1231
|
+
return new ct().fromBinary(e, t);
|
|
1232
1232
|
}
|
|
1233
1233
|
static fromJson(e, t) {
|
|
1234
|
-
return new
|
|
1234
|
+
return new ct().fromJson(e, t);
|
|
1235
1235
|
}
|
|
1236
1236
|
static fromJsonString(e, t) {
|
|
1237
|
-
return new
|
|
1237
|
+
return new ct().fromJsonString(e, t);
|
|
1238
1238
|
}
|
|
1239
1239
|
static equals(e, t) {
|
|
1240
|
-
return proto3.util.equals(
|
|
1240
|
+
return proto3.util.equals(ct, e, t);
|
|
1241
1241
|
}
|
|
1242
1242
|
};
|
|
1243
|
-
|
|
1244
|
-
let GetTimeRequest =
|
|
1245
|
-
const
|
|
1243
|
+
a(ct, "runtime", proto3), a(ct, "typeName", "audiotool.document.v1.GetTimeRequest"), a(ct, "fields", proto3.util.newFieldList(() => []));
|
|
1244
|
+
let GetTimeRequest = ct;
|
|
1245
|
+
const dt = class dt extends Message {
|
|
1246
1246
|
constructor(t) {
|
|
1247
1247
|
super();
|
|
1248
1248
|
/**
|
|
@@ -1250,23 +1250,23 @@ const st = class st extends Message {
|
|
|
1250
1250
|
*
|
|
1251
1251
|
* @generated from field: int64 time = 1;
|
|
1252
1252
|
*/
|
|
1253
|
-
|
|
1253
|
+
a(this, "time", protoInt64.zero);
|
|
1254
1254
|
proto3.util.initPartial(t, this);
|
|
1255
1255
|
}
|
|
1256
1256
|
static fromBinary(t, n) {
|
|
1257
|
-
return new
|
|
1257
|
+
return new dt().fromBinary(t, n);
|
|
1258
1258
|
}
|
|
1259
1259
|
static fromJson(t, n) {
|
|
1260
|
-
return new
|
|
1260
|
+
return new dt().fromJson(t, n);
|
|
1261
1261
|
}
|
|
1262
1262
|
static fromJsonString(t, n) {
|
|
1263
|
-
return new
|
|
1263
|
+
return new dt().fromJsonString(t, n);
|
|
1264
1264
|
}
|
|
1265
1265
|
static equals(t, n) {
|
|
1266
|
-
return proto3.util.equals(
|
|
1266
|
+
return proto3.util.equals(dt, t, n);
|
|
1267
1267
|
}
|
|
1268
1268
|
};
|
|
1269
|
-
|
|
1269
|
+
a(dt, "runtime", proto3), a(dt, "typeName", "audiotool.document.v1.GetTimeResponse"), a(dt, "fields", proto3.util.newFieldList(() => [
|
|
1270
1270
|
{
|
|
1271
1271
|
no: 1,
|
|
1272
1272
|
name: "time",
|
|
@@ -1275,7 +1275,7 @@ r(st, "runtime", proto3), r(st, "typeName", "audiotool.document.v1.GetTimeRespon
|
|
|
1275
1275
|
/* ScalarType.INT64 */
|
|
1276
1276
|
}
|
|
1277
1277
|
]));
|
|
1278
|
-
let GetTimeResponse =
|
|
1278
|
+
let GetTimeResponse = dt;
|
|
1279
1279
|
const wasmUrl = "/document_validator.wasm", wasmJsUrl = "/wasm_exec.js", runningInNode = typeof process < "u";
|
|
1280
1280
|
let wasmDocumentStateBuilderCache;
|
|
1281
1281
|
const getWasmDocumentState = async () => {
|
|
@@ -1285,16 +1285,16 @@ const getWasmDocumentState = async () => {
|
|
|
1285
1285
|
wasmDocumentStateBuilderCache = i;
|
|
1286
1286
|
const t = executeWrapperJs(), n = loadWasm();
|
|
1287
1287
|
await t;
|
|
1288
|
-
const o = globalThis.Go ?? throw_("wasm wrapper initialization failed: Go not defined"),
|
|
1288
|
+
const o = globalThis.Go ?? throw_("wasm wrapper initialization failed: Go not defined"), r = new o();
|
|
1289
1289
|
try {
|
|
1290
1290
|
await n;
|
|
1291
|
-
const
|
|
1291
|
+
const d = await WebAssembly.instantiate(
|
|
1292
1292
|
await n,
|
|
1293
|
-
|
|
1293
|
+
r.importObject
|
|
1294
1294
|
);
|
|
1295
|
-
|
|
1296
|
-
} catch (
|
|
1297
|
-
throw new Error("Failed to instantiate validator WASM", { cause:
|
|
1295
|
+
r.run(d);
|
|
1296
|
+
} catch (d) {
|
|
1297
|
+
throw new Error("Failed to instantiate validator WASM", { cause: d });
|
|
1298
1298
|
}
|
|
1299
1299
|
delete globalThis.Go;
|
|
1300
1300
|
const c = (
|
|
@@ -1302,13 +1302,21 @@ const getWasmDocumentState = async () => {
|
|
|
1302
1302
|
globalThis.createDocumentState ?? throw_("wasm initialization failed: createDocumentState not defined")
|
|
1303
1303
|
);
|
|
1304
1304
|
return delete globalThis.createDocumentState, e(() => {
|
|
1305
|
-
const
|
|
1305
|
+
const d = c();
|
|
1306
|
+
let u = !1;
|
|
1306
1307
|
return {
|
|
1307
|
-
applyTransaction(
|
|
1308
|
-
|
|
1308
|
+
applyTransaction(f) {
|
|
1309
|
+
assert(
|
|
1310
|
+
!u,
|
|
1311
|
+
"tried applying a transaction after document state was terminated"
|
|
1312
|
+
);
|
|
1313
|
+
const m = d.applyTransaction(f.toBinary());
|
|
1309
1314
|
return m instanceof Object && "error" in m ? m.error : new Transaction({
|
|
1310
|
-
modifications: m.rollbacks.map((
|
|
1315
|
+
modifications: m.rollbacks.map((p) => Modification.fromBinary(p))
|
|
1311
1316
|
});
|
|
1317
|
+
},
|
|
1318
|
+
terminate() {
|
|
1319
|
+
u = !0, d.delete();
|
|
1312
1320
|
}
|
|
1313
1321
|
};
|
|
1314
1322
|
}), (await i)();
|
|
@@ -1343,6 +1351,321 @@ const getWasmDocumentState = async () => {
|
|
|
1343
1351
|
e.dirname(t.fileURLToPath(import.meta.url)),
|
|
1344
1352
|
`.${wasmUrl}`
|
|
1345
1353
|
), WebAssembly.compile(new Uint8Array(i.readFileSync(n)));
|
|
1354
|
+
};
|
|
1355
|
+
var I, b;
|
|
1356
|
+
class NexusStateConsolidator {
|
|
1357
|
+
constructor(e) {
|
|
1358
|
+
/**
|
|
1359
|
+
* A copy of the document state, to validate that pending transactions can still be applied,
|
|
1360
|
+
* and drop them if not.
|
|
1361
|
+
*/
|
|
1362
|
+
h(this, I);
|
|
1363
|
+
/**
|
|
1364
|
+
* Transactions not yet confirmed or rejected by the remote.
|
|
1365
|
+
*
|
|
1366
|
+
* This is list contains `[forward, backward]` transactions, where `forward` are always the last transactions
|
|
1367
|
+
* applied to {@link #state}, while backwards contains their respective reverse, so the state
|
|
1368
|
+
* before all transactions in {@link #pending} can be restored.
|
|
1369
|
+
*/
|
|
1370
|
+
h(this, b, []);
|
|
1371
|
+
g(this, I, e);
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Consolidate the local and remote transaction history.
|
|
1375
|
+
*
|
|
1376
|
+
* @param newReceived Newly received transaction from the remote
|
|
1377
|
+
* @param newReceivedRejected Newly received transaction rejections from the remote. **must be a subset of previously created transactions**
|
|
1378
|
+
* @param newCreated Newly created transactions on the local document
|
|
1379
|
+
* @returns Transactions needed to sync local & remote, plus transactions created but not yet received
|
|
1380
|
+
*/
|
|
1381
|
+
consolidate(e, t, n) {
|
|
1382
|
+
n.forEach((l) => {
|
|
1383
|
+
const d = s(this, I).applyTransaction(l);
|
|
1384
|
+
if (!(d instanceof Transaction))
|
|
1385
|
+
throw new Error(`Error applying reverse transaction: ${d}`);
|
|
1386
|
+
s(this, b).push([l, d]);
|
|
1387
|
+
});
|
|
1388
|
+
let o = e[0], r = s(this, b)[0];
|
|
1389
|
+
for (; o !== void 0 && r !== void 0 && o.id === r[0].id; )
|
|
1390
|
+
e.shift(), s(this, b).shift(), o = e[0], r = s(this, b)[0];
|
|
1391
|
+
if (e.length === 0) {
|
|
1392
|
+
if (t.size === 0)
|
|
1393
|
+
return [];
|
|
1394
|
+
const l = s(this, b).findIndex(
|
|
1395
|
+
([m]) => t.has(m.id)
|
|
1396
|
+
);
|
|
1397
|
+
if (l === -1)
|
|
1398
|
+
throw new Error(
|
|
1399
|
+
"Invariant violation: expected to find rejected transaction in #pending, but didn't. This is a bug."
|
|
1400
|
+
);
|
|
1401
|
+
const d = s(this, b).splice(l), u = d.map(([, m]) => {
|
|
1402
|
+
if (!(s(this, I).applyTransaction(m) instanceof Transaction))
|
|
1403
|
+
throw new Error("error applying reversal of transaction");
|
|
1404
|
+
return m;
|
|
1405
|
+
}).reverse(), f = d.filter(([m]) => !t.has(m.id)).map(([m]) => {
|
|
1406
|
+
const p = s(this, I).applyTransaction(m);
|
|
1407
|
+
if (p instanceof Transaction)
|
|
1408
|
+
return [m, p];
|
|
1409
|
+
}).filter((m) => m !== void 0);
|
|
1410
|
+
return s(this, b).push(...f), [...u, ...f.map(([m]) => m)];
|
|
1411
|
+
}
|
|
1412
|
+
const c = s(this, b).map((l) => l[1].clone()).reverse();
|
|
1413
|
+
return c.forEach((l) => {
|
|
1414
|
+
const d = s(this, I).applyTransaction(l);
|
|
1415
|
+
if (!(d instanceof Transaction))
|
|
1416
|
+
throw new Error(`Error applying reverse transaction: ${d}`);
|
|
1417
|
+
}), e.forEach((l) => {
|
|
1418
|
+
const d = s(this, I).applyTransaction(l);
|
|
1419
|
+
if (!(d instanceof Transaction))
|
|
1420
|
+
throw new Error(`Error applying incoming transaction: ${d}`);
|
|
1421
|
+
}), g(this, b, s(this, b).filter(([l]) => {
|
|
1422
|
+
const d = t.has(l.id), u = e.some(
|
|
1423
|
+
(f) => f.id === l.id
|
|
1424
|
+
);
|
|
1425
|
+
return !d && !u;
|
|
1426
|
+
}).map(([l]) => {
|
|
1427
|
+
const d = s(this, I).applyTransaction(l);
|
|
1428
|
+
return d instanceof Transaction ? [l, d] : void 0;
|
|
1429
|
+
}).filter((l) => l !== void 0)), [
|
|
1430
|
+
...c,
|
|
1431
|
+
...e,
|
|
1432
|
+
...s(this, b).map(([l]) => l)
|
|
1433
|
+
];
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
I = new WeakMap(), b = new WeakMap();
|
|
1437
|
+
const combinedValueNotifiersWithAnd = (...i) => {
|
|
1438
|
+
const e = new ValueNotifier(!0), t = () => e.setValue(i.every((n) => n.getValue()));
|
|
1439
|
+
return i.forEach((n) => n.subscribe(() => t())), t(), e;
|
|
1440
|
+
}, createPingNotifier = (i, e, t) => {
|
|
1441
|
+
const n = new Notifier(), o = new ValueNotifier(0), r = new ValueNotifier(!0);
|
|
1442
|
+
n.subscribe((l) => {
|
|
1443
|
+
r.setValue(l);
|
|
1444
|
+
});
|
|
1445
|
+
const c = asyncInterval(
|
|
1446
|
+
async (l) => {
|
|
1447
|
+
const d = Date.now(), u = await i.ping(
|
|
1448
|
+
{
|
|
1449
|
+
clientId: (t == null ? void 0 : t.clientId) ?? "undefined",
|
|
1450
|
+
projectName: e,
|
|
1451
|
+
// required by backend
|
|
1452
|
+
lastPingMs: Math.floor(o.getValue())
|
|
1453
|
+
},
|
|
1454
|
+
{
|
|
1455
|
+
onRetry: () => n.notify(!1),
|
|
1456
|
+
signal: l
|
|
1457
|
+
}
|
|
1458
|
+
);
|
|
1459
|
+
if (!l.aborted) {
|
|
1460
|
+
if (u instanceof Error)
|
|
1461
|
+
throw u;
|
|
1462
|
+
n.notify(!0), o.setValue(Date.now() - d);
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
1e3,
|
|
1466
|
+
{ immediateTrigger: !0 }
|
|
1467
|
+
);
|
|
1468
|
+
return {
|
|
1469
|
+
pingCallResults: n,
|
|
1470
|
+
connectionOk: r,
|
|
1471
|
+
pingMs: o,
|
|
1472
|
+
terminate: () => {
|
|
1473
|
+
n.terminate(), c.terminate(), r.terminate(), o.terminate();
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
}, createTransactionReceiver = (i, e, t) => {
|
|
1477
|
+
const n = new ValueNotifier(!0);
|
|
1478
|
+
let o = 0;
|
|
1479
|
+
const r = new AbortController();
|
|
1480
|
+
let c = new AbortController(), l = !1;
|
|
1481
|
+
const d = () => (c.abort(), c = new AbortController(), i.attach(
|
|
1482
|
+
{ projectName: e, commitIndex: o },
|
|
1483
|
+
{
|
|
1484
|
+
signal: AbortSignal.any([
|
|
1485
|
+
c.signal,
|
|
1486
|
+
r.signal
|
|
1487
|
+
])
|
|
1488
|
+
}
|
|
1489
|
+
)[Symbol.asyncIterator]());
|
|
1490
|
+
let u = d();
|
|
1491
|
+
const f = 1e3;
|
|
1492
|
+
return {
|
|
1493
|
+
nextTransactionIterator: async function* () {
|
|
1494
|
+
for (; ; )
|
|
1495
|
+
try {
|
|
1496
|
+
const { value: p, done: w } = await u.next();
|
|
1497
|
+
if (w ?? !1)
|
|
1498
|
+
throw new Error("document service attach stream closed");
|
|
1499
|
+
switch (n.setValue(!0), p.message.case) {
|
|
1500
|
+
case "noop": {
|
|
1501
|
+
if (!l) {
|
|
1502
|
+
l = !0, yield new Transaction({ id: crypto.randomUUID() });
|
|
1503
|
+
continue;
|
|
1504
|
+
}
|
|
1505
|
+
continue;
|
|
1506
|
+
}
|
|
1507
|
+
case "transaction": {
|
|
1508
|
+
o = p.message.value.commitIndex, l = !0, yield p.message.value;
|
|
1509
|
+
continue;
|
|
1510
|
+
}
|
|
1511
|
+
default:
|
|
1512
|
+
throw new Error(
|
|
1513
|
+
`received attach response with unknown message case: ${p.message.case}`
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1516
|
+
} catch (p) {
|
|
1517
|
+
if (r.signal.aborted)
|
|
1518
|
+
return;
|
|
1519
|
+
if (!(p instanceof ConnectError))
|
|
1520
|
+
throw p;
|
|
1521
|
+
switch (p.code) {
|
|
1522
|
+
case Code.Canceled:
|
|
1523
|
+
// thrown if abort controller is aborted
|
|
1524
|
+
case Code.Aborted:
|
|
1525
|
+
case Code.Unavailable:
|
|
1526
|
+
case Code.Unknown: {
|
|
1527
|
+
if (n.setValue(!1), await sleep(
|
|
1528
|
+
f + Math.random() * f * 0.1,
|
|
1529
|
+
// pass in master abort controller for early termination
|
|
1530
|
+
r.signal
|
|
1531
|
+
), r.signal.aborted)
|
|
1532
|
+
return;
|
|
1533
|
+
u = d();
|
|
1534
|
+
continue;
|
|
1535
|
+
}
|
|
1536
|
+
// else throw
|
|
1537
|
+
default:
|
|
1538
|
+
throw p.code === Code.OutOfRange ? new Error(
|
|
1539
|
+
"local document state too far in the past, must reload tab"
|
|
1540
|
+
) : p;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}(),
|
|
1544
|
+
terminate: () => r.abort(),
|
|
1545
|
+
reconnect: () => c.abort(),
|
|
1546
|
+
connectionOk: n
|
|
1547
|
+
};
|
|
1548
|
+
}, createTransactionSender = (i, e) => {
|
|
1549
|
+
const t = new ValueNotifier(!0), n = [], o = promiseBarrier();
|
|
1550
|
+
let r;
|
|
1551
|
+
return (async () => {
|
|
1552
|
+
for (; ; ) {
|
|
1553
|
+
const l = n.splice(0);
|
|
1554
|
+
if (l.length === 0) {
|
|
1555
|
+
if (r !== void 0) {
|
|
1556
|
+
r.resolve();
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
await o.wait;
|
|
1560
|
+
continue;
|
|
1561
|
+
}
|
|
1562
|
+
const d = await i.applyTransactions(
|
|
1563
|
+
{
|
|
1564
|
+
projectName: e,
|
|
1565
|
+
transactions: l.map(([u]) => u)
|
|
1566
|
+
},
|
|
1567
|
+
{
|
|
1568
|
+
callIsOk: t
|
|
1569
|
+
}
|
|
1570
|
+
// no signal passed: we want to send everything
|
|
1571
|
+
);
|
|
1572
|
+
if (d instanceof Error)
|
|
1573
|
+
throw new Error("error sending transaction", { cause: d });
|
|
1574
|
+
l.forEach(([u, f]) => {
|
|
1575
|
+
f(d.errors[u.id] ?? void 0);
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
})(), {
|
|
1579
|
+
sendNextTransaction: async (l) => {
|
|
1580
|
+
if (r !== void 0)
|
|
1581
|
+
throw new Error("tried sending transaction after termination");
|
|
1582
|
+
const { promise: d, resolve: u } = Promise.withResolvers();
|
|
1583
|
+
return n.push([l, u]), o.signal(), d;
|
|
1584
|
+
},
|
|
1585
|
+
terminate: async () => {
|
|
1586
|
+
if (r !== void 0) {
|
|
1587
|
+
await r.promise;
|
|
1588
|
+
return;
|
|
1589
|
+
}
|
|
1590
|
+
r = Promise.withResolvers(), o.signal(), t.terminate(), await r.promise, n.length > 0 && console.error(
|
|
1591
|
+
"invariant violation: nextBatch not empty after termination; have:",
|
|
1592
|
+
n.length,
|
|
1593
|
+
"transactions left"
|
|
1594
|
+
);
|
|
1595
|
+
},
|
|
1596
|
+
connectionOk: t
|
|
1597
|
+
};
|
|
1598
|
+
}, promiseBarrier = () => {
|
|
1599
|
+
let { promise: i, resolve: e } = Promise.withResolvers();
|
|
1600
|
+
return {
|
|
1601
|
+
get wait() {
|
|
1602
|
+
return i;
|
|
1603
|
+
},
|
|
1604
|
+
signal: () => {
|
|
1605
|
+
e(), { promise: i, resolve: e } = Promise.withResolvers();
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
}, createDocumentServiceConnection = (i, e, t) => {
|
|
1609
|
+
const n = createPingNotifier(i, e, {}), o = createTransactionReceiver(
|
|
1610
|
+
i,
|
|
1611
|
+
e
|
|
1612
|
+
), r = createTransactionSender(
|
|
1613
|
+
i,
|
|
1614
|
+
e
|
|
1615
|
+
), c = combinedValueNotifiersWithAnd(
|
|
1616
|
+
n.connectionOk,
|
|
1617
|
+
o.connectionOk,
|
|
1618
|
+
r.connectionOk
|
|
1619
|
+
);
|
|
1620
|
+
return n.pingCallResults.subscribe((l) => {
|
|
1621
|
+
l || o.reconnect();
|
|
1622
|
+
}), {
|
|
1623
|
+
receiveNextTransaction: o.nextTransactionIterator,
|
|
1624
|
+
sendNextTransaction: r.sendNextTransaction,
|
|
1625
|
+
pingMs: n.pingMs,
|
|
1626
|
+
connectionOk: c,
|
|
1627
|
+
terminate: async () => {
|
|
1628
|
+
n.terminate(), o.terminate(), await r.terminate(), c.terminate();
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
}, createCollabGateway = (i, e, t, n) => {
|
|
1632
|
+
const o = new ValueNotifier(!1), r = createDocumentServiceConnection(
|
|
1633
|
+
i,
|
|
1634
|
+
t
|
|
1635
|
+
), c = new NexusStateConsolidator(e), l = [], d = [], u = /* @__PURE__ */ new Set();
|
|
1636
|
+
(async () => {
|
|
1637
|
+
for await (const p of r.receiveNextTransaction)
|
|
1638
|
+
l.push(p);
|
|
1639
|
+
})(), r.connectionOk.subscribe((p) => {
|
|
1640
|
+
o.setValue(!p);
|
|
1641
|
+
});
|
|
1642
|
+
let m = !1;
|
|
1643
|
+
return {
|
|
1644
|
+
blocked: o,
|
|
1645
|
+
send: (p) => {
|
|
1646
|
+
if (m)
|
|
1647
|
+
throw new Error(
|
|
1648
|
+
"tried sending a transaction after gateway was terminated"
|
|
1649
|
+
);
|
|
1650
|
+
p = p.clone(), p.id = crypto.randomUUID(), d.push(p), r.sendNextTransaction(p).then((w) => {
|
|
1651
|
+
w !== void 0 && u.add(p.id);
|
|
1652
|
+
});
|
|
1653
|
+
},
|
|
1654
|
+
synchronize: () => {
|
|
1655
|
+
if (m)
|
|
1656
|
+
return [];
|
|
1657
|
+
l.length > 0;
|
|
1658
|
+
const p = c.consolidate(
|
|
1659
|
+
l,
|
|
1660
|
+
u,
|
|
1661
|
+
d
|
|
1662
|
+
);
|
|
1663
|
+
return l.length = 0, u.clear(), d.length = 0, p;
|
|
1664
|
+
},
|
|
1665
|
+
terminate: async () => {
|
|
1666
|
+
m = !0, await r.terminate(), l.length = 0, u.clear(), d.length = 0, o.terminate(), e.terminate();
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1346
1669
|
}, createWasmNexusValidator = async () => {
|
|
1347
1670
|
const i = await getWasmDocumentState();
|
|
1348
1671
|
return {
|
|
@@ -1352,16 +1675,19 @@ const getWasmDocumentState = async () => {
|
|
|
1352
1675
|
);
|
|
1353
1676
|
if (!(t instanceof Transaction))
|
|
1354
1677
|
return t;
|
|
1678
|
+
},
|
|
1679
|
+
terminate: () => {
|
|
1680
|
+
i.terminate();
|
|
1355
1681
|
}
|
|
1356
1682
|
};
|
|
1357
1683
|
};
|
|
1358
|
-
var
|
|
1359
|
-
const
|
|
1684
|
+
var St;
|
|
1685
|
+
const ht = class ht {
|
|
1360
1686
|
constructor(e = void 0, t = void 0, n = []) {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1687
|
+
a(this, "entityId");
|
|
1688
|
+
a(this, "fieldIndex");
|
|
1689
|
+
a(this, "entityType");
|
|
1690
|
+
h(this, St);
|
|
1365
1691
|
if (this.entityId = e ?? "", this.fieldIndex = n, this.entityType = t, e !== void 0 && e !== "" && t === void 0)
|
|
1366
1692
|
throw new Error("entity type is required if id is set");
|
|
1367
1693
|
}
|
|
@@ -1377,14 +1703,14 @@ const pt = class pt {
|
|
|
1377
1703
|
}
|
|
1378
1704
|
/** @internal Returns a copy of this object with an appended field number. */
|
|
1379
1705
|
withAppendedFieldNumber(e) {
|
|
1380
|
-
return new
|
|
1706
|
+
return new ht(this.entityId, this.entityType, [
|
|
1381
1707
|
...this.fieldIndex,
|
|
1382
1708
|
e
|
|
1383
1709
|
]);
|
|
1384
1710
|
}
|
|
1385
1711
|
/** @internal */
|
|
1386
1712
|
withFieldIndex(e) {
|
|
1387
|
-
return new
|
|
1713
|
+
return new ht(this.entityId, this.entityType, [...e]);
|
|
1388
1714
|
}
|
|
1389
1715
|
/** @internal */
|
|
1390
1716
|
toPointerMessage() {
|
|
@@ -1394,7 +1720,7 @@ const pt = class pt {
|
|
|
1394
1720
|
});
|
|
1395
1721
|
}
|
|
1396
1722
|
get [hashSymbol]() {
|
|
1397
|
-
return s(this,
|
|
1723
|
+
return s(this, St) === void 0 && g(this, St, hashNexusLocation(this.entityId, this.fieldIndex)), s(this, St);
|
|
1398
1724
|
}
|
|
1399
1725
|
/** Returns a human readable string representation */
|
|
1400
1726
|
toString() {
|
|
@@ -1405,27 +1731,27 @@ const pt = class pt {
|
|
|
1405
1731
|
}
|
|
1406
1732
|
/** @internal clones the location, updating only the id */
|
|
1407
1733
|
withId(e) {
|
|
1408
|
-
return new
|
|
1734
|
+
return new ht(e, this.entityType, this.fieldIndex.slice());
|
|
1409
1735
|
}
|
|
1410
1736
|
/** @internal */
|
|
1411
1737
|
static fromPointerMessage(e, t) {
|
|
1412
1738
|
if (t.entityId === void 0 || t.entityId === "")
|
|
1413
|
-
return new
|
|
1739
|
+
return new ht();
|
|
1414
1740
|
const n = e(t.entityId);
|
|
1415
1741
|
if (n === void 0)
|
|
1416
1742
|
throw new Error(
|
|
1417
1743
|
`entity type for ${t.entityId} is undefined for a set pointer: ${t.toJsonString()}`
|
|
1418
1744
|
);
|
|
1419
|
-
return new
|
|
1745
|
+
return new ht(t.entityId, n, t.fieldIndex.slice());
|
|
1420
1746
|
}
|
|
1421
1747
|
/** @internal */
|
|
1422
1748
|
static fromSchemaPath(e, t) {
|
|
1423
1749
|
const { entityType: n, fieldIndex: o } = schemaPathToSchemaLocation(t);
|
|
1424
|
-
return new
|
|
1750
|
+
return new ht(e, n, o);
|
|
1425
1751
|
}
|
|
1426
1752
|
};
|
|
1427
|
-
|
|
1428
|
-
let NexusLocation =
|
|
1753
|
+
St = new WeakMap();
|
|
1754
|
+
let NexusLocation = ht;
|
|
1429
1755
|
const hashNexusLocation = (i, e) => v5(
|
|
1430
1756
|
`${i}/${e.join(",")}`,
|
|
1431
1757
|
"4f4aaf81-65f2-4239-b1df-e34a0729f6b8"
|
|
@@ -1471,49 +1797,49 @@ const hashNexusLocation = (i, e) => v5(
|
|
|
1471
1797
|
class ArrayField {
|
|
1472
1798
|
/** @internal */
|
|
1473
1799
|
constructor(e, t) {
|
|
1474
|
-
|
|
1800
|
+
a(this, "location");
|
|
1475
1801
|
/** The array of fields contained in this array field. */
|
|
1476
|
-
|
|
1802
|
+
a(this, "array");
|
|
1477
1803
|
this.location = e, this.array = t;
|
|
1478
1804
|
}
|
|
1479
1805
|
}
|
|
1480
|
-
var
|
|
1806
|
+
var Et;
|
|
1481
1807
|
class PrimitiveField {
|
|
1482
1808
|
/** @internal */
|
|
1483
1809
|
constructor(e, t, n, o) {
|
|
1484
1810
|
/** The location of this field within the Nexus document. */
|
|
1485
|
-
|
|
1811
|
+
a(this, "location");
|
|
1486
1812
|
/** The value of the field; private with a getter to prevent accidenal overwrites. */
|
|
1487
|
-
|
|
1813
|
+
h(this, Et);
|
|
1488
1814
|
/** Whether the field is mutable. Updating immutable fields results in a transaction error.
|
|
1489
1815
|
*
|
|
1490
1816
|
* If the type fo the field is known at compile time, updating the field using the {@link TransactionBuilder}
|
|
1491
1817
|
* or listing to updates of the field using the {@link NexusEventManager} will result in type errors.
|
|
1492
1818
|
*/
|
|
1493
|
-
|
|
1819
|
+
a(this, "mutable");
|
|
1494
1820
|
/** @internal The type of the field in the protobuf message. Used internally. */
|
|
1495
|
-
|
|
1496
|
-
this.location = e,
|
|
1821
|
+
a(this, "_protoType");
|
|
1822
|
+
this.location = e, g(this, Et, t), this._protoType = n, this.mutable = o;
|
|
1497
1823
|
}
|
|
1498
1824
|
/** Get the value of the field. To set, use transactions in the document. */
|
|
1499
1825
|
get value() {
|
|
1500
|
-
return s(this,
|
|
1826
|
+
return s(this, Et);
|
|
1501
1827
|
}
|
|
1502
1828
|
/**
|
|
1503
1829
|
* @internal
|
|
1504
1830
|
*
|
|
1505
1831
|
* Set the value of this field. Used by {@link NexusDocument}, don't use directly! */
|
|
1506
1832
|
_setValue(e) {
|
|
1507
|
-
|
|
1833
|
+
g(this, Et, protoPrecision[this._protoType](e));
|
|
1508
1834
|
}
|
|
1509
1835
|
}
|
|
1510
|
-
|
|
1836
|
+
Et = new WeakMap();
|
|
1511
1837
|
class NexusObject {
|
|
1512
1838
|
/** @internal */
|
|
1513
1839
|
constructor(e, t) {
|
|
1514
1840
|
/** the fields in this object */
|
|
1515
|
-
|
|
1516
|
-
|
|
1841
|
+
a(this, "fields");
|
|
1842
|
+
a(this, "location");
|
|
1517
1843
|
this.location = t, this.fields = e;
|
|
1518
1844
|
}
|
|
1519
1845
|
/** @internal Returns the field with the given field number. Throws if it can't find it. */
|
|
@@ -1530,9 +1856,9 @@ class NexusEntity extends NexusObject {
|
|
|
1530
1856
|
constructor(t, n) {
|
|
1531
1857
|
super(n, t);
|
|
1532
1858
|
/** The id of this entity. */
|
|
1533
|
-
|
|
1859
|
+
a(this, "id");
|
|
1534
1860
|
/** The entity type key of this entity. */
|
|
1535
|
-
|
|
1861
|
+
a(this, "entityType");
|
|
1536
1862
|
this.id = t.entityId, this.entityType = t.entityType;
|
|
1537
1863
|
}
|
|
1538
1864
|
/**
|
|
@@ -1544,49 +1870,49 @@ class NexusEntity extends NexusObject {
|
|
|
1544
1870
|
if (t.length === 0)
|
|
1545
1871
|
throw "tried resolving empty field path";
|
|
1546
1872
|
const [n, ...o] = t;
|
|
1547
|
-
let
|
|
1873
|
+
let r = this._getField(n);
|
|
1548
1874
|
for (const c of o) {
|
|
1549
|
-
if (
|
|
1550
|
-
|
|
1875
|
+
if (r instanceof NexusObject) {
|
|
1876
|
+
r = r._getField(c);
|
|
1551
1877
|
continue;
|
|
1552
1878
|
}
|
|
1553
|
-
if (
|
|
1554
|
-
|
|
1879
|
+
if (r instanceof ArrayField) {
|
|
1880
|
+
r = r.array[c];
|
|
1555
1881
|
continue;
|
|
1556
1882
|
}
|
|
1557
|
-
throw `tried resolving field number ${c} on non-object field ${
|
|
1883
|
+
throw `tried resolving field number ${c} on non-object field ${r}`;
|
|
1558
1884
|
}
|
|
1559
|
-
return
|
|
1885
|
+
return r;
|
|
1560
1886
|
}
|
|
1561
1887
|
}
|
|
1562
1888
|
const createNexusFields = (i, e, t, n) => {
|
|
1563
1889
|
const o = {};
|
|
1564
|
-
return t.getType().fields.list().forEach((
|
|
1565
|
-
if (
|
|
1890
|
+
return t.getType().fields.list().forEach((r) => {
|
|
1891
|
+
if (r.name === "id" && r.no === 1)
|
|
1566
1892
|
return;
|
|
1567
|
-
const c = n.withAppendedFieldNumber(
|
|
1568
|
-
let
|
|
1569
|
-
if (!
|
|
1570
|
-
|
|
1893
|
+
const c = n.withAppendedFieldNumber(r.no), l = t[r.localName];
|
|
1894
|
+
let d;
|
|
1895
|
+
if (!r.repeated)
|
|
1896
|
+
d = createField(
|
|
1571
1897
|
i,
|
|
1572
1898
|
e,
|
|
1573
1899
|
c,
|
|
1574
|
-
|
|
1575
|
-
|
|
1900
|
+
l,
|
|
1901
|
+
r
|
|
1576
1902
|
);
|
|
1577
1903
|
else {
|
|
1578
|
-
const u =
|
|
1579
|
-
(
|
|
1904
|
+
const u = l.map(
|
|
1905
|
+
(f, m) => createField(
|
|
1580
1906
|
i,
|
|
1581
1907
|
e,
|
|
1582
|
-
c.withAppendedFieldNumber(
|
|
1583
|
-
|
|
1584
|
-
|
|
1908
|
+
c.withAppendedFieldNumber(m),
|
|
1909
|
+
f,
|
|
1910
|
+
r
|
|
1585
1911
|
)
|
|
1586
1912
|
);
|
|
1587
|
-
|
|
1913
|
+
d = new ArrayField(c, u);
|
|
1588
1914
|
}
|
|
1589
|
-
o[
|
|
1915
|
+
o[r.localName] = d;
|
|
1590
1916
|
}), o;
|
|
1591
1917
|
}, createField = (i, e, t, n, o) => {
|
|
1592
1918
|
switch (o.kind) {
|
|
@@ -1601,13 +1927,13 @@ const createNexusFields = (i, e, t, n) => {
|
|
|
1601
1927
|
if (o.T === Empty)
|
|
1602
1928
|
return new NexusObject({}, t);
|
|
1603
1929
|
assert(n !== void 0, `undefined value for field ${t}`);
|
|
1604
|
-
const
|
|
1930
|
+
const r = createNexusFields(
|
|
1605
1931
|
i,
|
|
1606
1932
|
e,
|
|
1607
1933
|
n,
|
|
1608
1934
|
t
|
|
1609
1935
|
);
|
|
1610
|
-
return new NexusObject(
|
|
1936
|
+
return new NexusObject(r, t);
|
|
1611
1937
|
}
|
|
1612
1938
|
case "scalar":
|
|
1613
1939
|
return new PrimitiveField(
|
|
@@ -1709,8 +2035,8 @@ const createNexusFields = (i, e, t, n) => {
|
|
|
1709
2035
|
o._setValue(t);
|
|
1710
2036
|
return;
|
|
1711
2037
|
}
|
|
1712
|
-
const
|
|
1713
|
-
|
|
2038
|
+
const r = o.value;
|
|
2039
|
+
r.isEmpty() || n == null || n.onStopPointingTo(o.location, r), o._setValue(t);
|
|
1714
2040
|
const c = t;
|
|
1715
2041
|
c.isEmpty() || n == null || n.onStartPointingTo(o.location, c);
|
|
1716
2042
|
}, nexusDocumentState = (i) => {
|
|
@@ -1726,51 +2052,51 @@ const createNexusFields = (i, e, t, n) => {
|
|
|
1726
2052
|
onUpdate: () => {
|
|
1727
2053
|
},
|
|
1728
2054
|
...(i == null ? void 0 : i.callbacks) ?? {}
|
|
1729
|
-
}, o = /* @__PURE__ */ new Map(),
|
|
1730
|
-
var
|
|
1731
|
-
return ((
|
|
2055
|
+
}, o = /* @__PURE__ */ new Map(), r = (u) => {
|
|
2056
|
+
var f;
|
|
2057
|
+
return ((f = e.get(u)) == null ? void 0 : f.entityType) ?? o.get(u);
|
|
1732
2058
|
}, c = (u) => {
|
|
1733
|
-
const
|
|
1734
|
-
|
|
2059
|
+
const f = createEntity(
|
|
2060
|
+
r,
|
|
1735
2061
|
mustUnpackEntity(
|
|
1736
2062
|
u.entity ?? throw_("received empty create modification")
|
|
1737
2063
|
)
|
|
1738
2064
|
);
|
|
1739
|
-
e.set(
|
|
1740
|
-
addSourceTarget(t,
|
|
1741
|
-
}), n.onCreate(
|
|
1742
|
-
}, d = (u) => {
|
|
1743
|
-
const m = u.entityId, f = e.get(m) ?? throw_("can't find deleted entity");
|
|
1744
|
-
e.delete(m), visitPointers$1(f, (y, v) => {
|
|
1745
|
-
removeSourceTarget(t, y, v), n.onStopPointingTo(y, v);
|
|
1746
|
-
}), n.onDelete(f);
|
|
2065
|
+
e.set(f.id, f), visitPointers$1(f, (m, p) => {
|
|
2066
|
+
addSourceTarget(t, m, p), n.onStartPointingTo(m, p);
|
|
2067
|
+
}), n.onCreate(f);
|
|
1747
2068
|
}, l = (u) => {
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
2069
|
+
const f = u.entityId, m = e.get(f) ?? throw_("can't find deleted entity");
|
|
2070
|
+
e.delete(f), visitPointers$1(m, (p, w) => {
|
|
2071
|
+
removeSourceTarget(t, p, w), n.onStopPointingTo(p, w);
|
|
2072
|
+
}), n.onDelete(m);
|
|
2073
|
+
}, d = (u) => {
|
|
2074
|
+
const f = u.field ?? throw_("received update without pointer"), m = NexusLocation.fromPointerMessage(r, f), p = e.get(m.entityId) ?? throw_("can't find updated entity"), w = extractPbUpdateValue(u.value, r);
|
|
2075
|
+
applyUpdate(p, m, w, {
|
|
2076
|
+
onStopPointingTo: (x, E) => {
|
|
2077
|
+
removeSourceTarget(t, x, E) || throw_(), n.onStopPointingTo(x, E);
|
|
1752
2078
|
},
|
|
1753
|
-
onStartPointingTo: (
|
|
1754
|
-
addSourceTarget(t,
|
|
2079
|
+
onStartPointingTo: (x, E) => {
|
|
2080
|
+
addSourceTarget(t, x, E), n.onStartPointingTo(x, E);
|
|
1755
2081
|
}
|
|
1756
|
-
}), n.onUpdate(
|
|
2082
|
+
}), n.onUpdate(m, w);
|
|
1757
2083
|
};
|
|
1758
2084
|
return {
|
|
1759
2085
|
entities: e,
|
|
1760
2086
|
references: t,
|
|
1761
2087
|
applyModification(u) {
|
|
1762
|
-
const
|
|
1763
|
-
switch (
|
|
2088
|
+
const f = u.modification;
|
|
2089
|
+
switch (f.case) {
|
|
1764
2090
|
case "create": {
|
|
1765
|
-
c(
|
|
2091
|
+
c(f.value);
|
|
1766
2092
|
break;
|
|
1767
2093
|
}
|
|
1768
2094
|
case "delete": {
|
|
1769
|
-
|
|
2095
|
+
l(f.value);
|
|
1770
2096
|
break;
|
|
1771
2097
|
}
|
|
1772
2098
|
case "update": {
|
|
1773
|
-
|
|
2099
|
+
d(f.value);
|
|
1774
2100
|
break;
|
|
1775
2101
|
}
|
|
1776
2102
|
}
|
|
@@ -1778,11 +2104,11 @@ const createNexusFields = (i, e, t, n) => {
|
|
|
1778
2104
|
getStats() {
|
|
1779
2105
|
return {
|
|
1780
2106
|
entities: e.size,
|
|
1781
|
-
references: t.values().reduce((u,
|
|
2107
|
+
references: t.values().reduce((u, f) => u + f.length, 0)
|
|
1782
2108
|
};
|
|
1783
2109
|
},
|
|
1784
|
-
_addEntityTypeForId(u,
|
|
1785
|
-
o.set(u,
|
|
2110
|
+
_addEntityTypeForId(u, f) {
|
|
2111
|
+
o.set(u, f);
|
|
1786
2112
|
}
|
|
1787
2113
|
};
|
|
1788
2114
|
}, TerminableBuilder = {
|
|
@@ -1793,17 +2119,17 @@ const createNexusFields = (i, e, t, n) => {
|
|
|
1793
2119
|
}
|
|
1794
2120
|
})
|
|
1795
2121
|
};
|
|
1796
|
-
var
|
|
1797
|
-
const
|
|
2122
|
+
var N, lt, k, F, J, Jt;
|
|
2123
|
+
const bt = class bt {
|
|
1798
2124
|
constructor(e = nexusDocumentState()) {
|
|
1799
|
-
|
|
1800
|
-
|
|
2125
|
+
h(this, N, new HashMap());
|
|
2126
|
+
h(this, lt, /* @__PURE__ */ new Map());
|
|
1801
2127
|
/** contains either: entity id, *, or entity type */
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
2128
|
+
h(this, k, /* @__PURE__ */ new Map());
|
|
2129
|
+
h(this, F, new HashMap());
|
|
2130
|
+
h(this, J, new HashMap());
|
|
2131
|
+
h(this, Jt);
|
|
2132
|
+
g(this, Jt, e), bt.debugWindowInstance ?? (bt.debugWindowInstance = this);
|
|
1807
2133
|
}
|
|
1808
2134
|
/**
|
|
1809
2135
|
* Subscribe to the event that an entity of a specific type is created.
|
|
@@ -1812,24 +2138,24 @@ const Et = class Et {
|
|
|
1812
2138
|
* during entity creation will still be called on removal of the entity.
|
|
1813
2139
|
*/
|
|
1814
2140
|
onCreate(e, t) {
|
|
1815
|
-
const n = (
|
|
2141
|
+
const n = (r) => {
|
|
1816
2142
|
const c = t(
|
|
1817
|
-
|
|
2143
|
+
r
|
|
1818
2144
|
);
|
|
1819
|
-
c !== void 0 && this.onRemove(
|
|
2145
|
+
c !== void 0 && this.onRemove(r, c);
|
|
1820
2146
|
};
|
|
1821
|
-
return getOrDefault(s(this,
|
|
2147
|
+
return getOrDefault(s(this, lt), e).add(n), TerminableBuilder.terminableFrom(
|
|
1822
2148
|
() => {
|
|
1823
|
-
var
|
|
1824
|
-
return (
|
|
2149
|
+
var r;
|
|
2150
|
+
return (r = s(this, lt).get(e)) == null ? void 0 : r.delete(n);
|
|
1825
2151
|
}
|
|
1826
2152
|
);
|
|
1827
2153
|
}
|
|
1828
2154
|
/** @internal */
|
|
1829
2155
|
_dispatchCreate(e) {
|
|
1830
2156
|
[
|
|
1831
|
-
...s(this,
|
|
1832
|
-
...s(this,
|
|
2157
|
+
...s(this, lt).get("*") ?? [],
|
|
2158
|
+
...s(this, lt).get(e.entityType) ?? []
|
|
1833
2159
|
].forEach((t) => t(e));
|
|
1834
2160
|
}
|
|
1835
2161
|
/**
|
|
@@ -1839,17 +2165,17 @@ const Et = class Et {
|
|
|
1839
2165
|
*/
|
|
1840
2166
|
onUpdate(e, t, n = !0) {
|
|
1841
2167
|
const o = t;
|
|
1842
|
-
return getOrDefault(s(this,
|
|
2168
|
+
return getOrDefault(s(this, N), e.location).add(o), n && t(e.value), TerminableBuilder.terminableFrom(
|
|
1843
2169
|
() => {
|
|
1844
2170
|
var c;
|
|
1845
|
-
return (c = s(this,
|
|
2171
|
+
return (c = s(this, N).get(e.location)) == null ? void 0 : c.delete(o);
|
|
1846
2172
|
}
|
|
1847
2173
|
);
|
|
1848
2174
|
}
|
|
1849
2175
|
/** @internal */
|
|
1850
2176
|
_dispatchUpdate(e, t) {
|
|
1851
2177
|
var n;
|
|
1852
|
-
(n = s(this,
|
|
2178
|
+
(n = s(this, N).get(e)) == null || n.forEach((o) => o(t));
|
|
1853
2179
|
}
|
|
1854
2180
|
/**
|
|
1855
2181
|
* Subscribe to an event where an entity is removed.
|
|
@@ -1870,8 +2196,8 @@ const Et = class Et {
|
|
|
1870
2196
|
typeof e == "string" ? e : e.id
|
|
1871
2197
|
).add(n), TerminableBuilder.terminableFrom(
|
|
1872
2198
|
() => {
|
|
1873
|
-
var
|
|
1874
|
-
return (
|
|
2199
|
+
var r;
|
|
2200
|
+
return (r = s(this, k).get(typeof e == "string" ? e : e.id)) == null ? void 0 : r.delete(n);
|
|
1875
2201
|
}
|
|
1876
2202
|
);
|
|
1877
2203
|
}
|
|
@@ -1881,7 +2207,7 @@ const Et = class Et {
|
|
|
1881
2207
|
...s(this, k).get("*") ?? [],
|
|
1882
2208
|
...s(this, k).get(e.id) ?? [],
|
|
1883
2209
|
...s(this, k).get(e.entityType) ?? []
|
|
1884
|
-
].forEach((t) => t(e)), s(this, k).delete(e.id), [...s(this,
|
|
2210
|
+
].forEach((t) => t(e)), s(this, k).delete(e.id), [...s(this, F).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, F).delete(t)), [...s(this, J).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, J).delete(t)), [...s(this, N).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, N).delete(t));
|
|
1885
2211
|
}
|
|
1886
2212
|
/** Subscribe to the event that some pointer in the document starts pointing to a given location.
|
|
1887
2213
|
*
|
|
@@ -1902,18 +2228,18 @@ const Et = class Et {
|
|
|
1902
2228
|
* @returns A terminable that when terminated will stop dispatching new onPointingTo events.
|
|
1903
2229
|
*/
|
|
1904
2230
|
onPointingTo(e, t, n = !0) {
|
|
1905
|
-
var
|
|
1906
|
-
return getOrDefault(s(this,
|
|
2231
|
+
var r;
|
|
2232
|
+
return getOrDefault(s(this, F), e).add(t), n && ((r = s(this, Jt).references.get(e)) == null || r.forEach((c) => t(c))), TerminableBuilder.terminableFrom(
|
|
1907
2233
|
() => {
|
|
1908
2234
|
var c;
|
|
1909
|
-
return (c = s(this,
|
|
2235
|
+
return (c = s(this, F).get(e)) == null ? void 0 : c.delete(t);
|
|
1910
2236
|
}
|
|
1911
2237
|
);
|
|
1912
2238
|
}
|
|
1913
2239
|
/** @internal */
|
|
1914
2240
|
_dispatchPointingTo(e, t) {
|
|
1915
2241
|
var n;
|
|
1916
|
-
(n = s(this,
|
|
2242
|
+
(n = s(this, F).get(e)) == null || n.forEach((o) => o(t));
|
|
1917
2243
|
}
|
|
1918
2244
|
/** Subscribe to the event that some pointer in the document stops pointing to a given location.
|
|
1919
2245
|
*
|
|
@@ -1930,17 +2256,24 @@ const Et = class Et {
|
|
|
1930
2256
|
* @returns A terminable that when terminated will stop dispatching new onStopPointingTo events.
|
|
1931
2257
|
*/
|
|
1932
2258
|
onStopPointingTo(e, t) {
|
|
1933
|
-
return getOrDefault(s(this,
|
|
2259
|
+
return getOrDefault(s(this, J), e).add(t), TerminableBuilder.terminableFrom(
|
|
1934
2260
|
() => {
|
|
1935
2261
|
var o;
|
|
1936
|
-
return (o = s(this,
|
|
2262
|
+
return (o = s(this, J).get(e)) == null ? void 0 : o.delete(t);
|
|
1937
2263
|
}
|
|
1938
2264
|
);
|
|
1939
2265
|
}
|
|
1940
2266
|
/** @internal */
|
|
1941
2267
|
_dispatchStopPointingTo(e, t) {
|
|
1942
2268
|
var n;
|
|
1943
|
-
(n = s(this,
|
|
2269
|
+
(n = s(this, J).get(e)) == null || n.forEach((o) => o(t));
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* @internal
|
|
2273
|
+
*
|
|
2274
|
+
* Removes all event listeners.*/
|
|
2275
|
+
_clear() {
|
|
2276
|
+
s(this, lt).clear(), s(this, N).clear(), s(this, k).clear(), s(this, F).clear(), s(this, J).clear();
|
|
1944
2277
|
}
|
|
1945
2278
|
/**
|
|
1946
2279
|
* @internal
|
|
@@ -1948,68 +2281,78 @@ const Et = class Et {
|
|
|
1948
2281
|
* on large documents. Don't call too often. */
|
|
1949
2282
|
getStats() {
|
|
1950
2283
|
return {
|
|
1951
|
-
numCreateListeners: sizeOf(s(this,
|
|
1952
|
-
numUpdateListeners: sizeOf(s(this,
|
|
2284
|
+
numCreateListeners: sizeOf(s(this, lt)),
|
|
2285
|
+
numUpdateListeners: sizeOf(s(this, N)),
|
|
1953
2286
|
numRemoveListeners: sizeOf(s(this, k)),
|
|
1954
|
-
numPointingToListeners: sizeOf(s(this,
|
|
1955
|
-
numStopPointingToListeners: sizeOf(s(this,
|
|
2287
|
+
numPointingToListeners: sizeOf(s(this, F)),
|
|
2288
|
+
numStopPointingToListeners: sizeOf(s(this, J))
|
|
1956
2289
|
};
|
|
1957
2290
|
}
|
|
1958
2291
|
};
|
|
1959
|
-
|
|
2292
|
+
N = new WeakMap(), lt = new WeakMap(), k = new WeakMap(), F = new WeakMap(), J = new WeakMap(), Jt = new WeakMap(), /**
|
|
1960
2293
|
* @internal
|
|
1961
2294
|
* For debugging purposes, the first instance of the nexus event manager ever created. */
|
|
1962
|
-
|
|
1963
|
-
let NexusEventManager =
|
|
1964
|
-
const sizeOf = (i) => i.values().reduce((e, t) => e + t.size, 0), getOrDefault = (i, e) => i.get(e) ?? i.set(e, /* @__PURE__ */ new Set()).get(e) ?? throw_(), mockNexusGateway = () =>
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2295
|
+
a(bt, "debugWindowInstance");
|
|
2296
|
+
let NexusEventManager = bt;
|
|
2297
|
+
const sizeOf = (i) => i.values().reduce((e, t) => e + t.size, 0), getOrDefault = (i, e) => i.get(e) ?? i.set(e, /* @__PURE__ */ new Set()).get(e) ?? throw_(), mockNexusGateway = () => {
|
|
2298
|
+
let i = !1, e = !1;
|
|
2299
|
+
return {
|
|
2300
|
+
synchronize: () => e ? [] : (e = !0, [new Transaction()]),
|
|
2301
|
+
send: () => {
|
|
2302
|
+
if (i)
|
|
2303
|
+
throw new Error("Gateway terminated");
|
|
2304
|
+
},
|
|
2305
|
+
blocked: new ValueNotifier(!1),
|
|
2306
|
+
terminate: async () => {
|
|
2307
|
+
i = !0;
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
}, mockNexusValidator = () => ({
|
|
1970
2311
|
validate: () => {
|
|
2312
|
+
},
|
|
2313
|
+
terminate: () => {
|
|
1971
2314
|
}
|
|
1972
2315
|
});
|
|
1973
|
-
var
|
|
1974
|
-
const
|
|
2316
|
+
var Pt, vt, kt, Mt, pt, Ft, $t;
|
|
2317
|
+
const qt = class qt {
|
|
1975
2318
|
constructor({
|
|
1976
2319
|
getFields: e,
|
|
1977
2320
|
getRefs: t,
|
|
1978
2321
|
filterFields: n,
|
|
1979
2322
|
documentLock: o
|
|
1980
2323
|
}) {
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2324
|
+
h(this, pt);
|
|
2325
|
+
h(this, Pt);
|
|
2326
|
+
h(this, vt);
|
|
2327
|
+
h(this, kt);
|
|
2328
|
+
h(this, Mt);
|
|
2329
|
+
g(this, Pt, e), g(this, vt, t), g(this, kt, n), g(this, Mt, o);
|
|
1987
2330
|
}
|
|
1988
2331
|
/** Only keep fields that are marked with target type appearing in `targetTypes`. */
|
|
1989
2332
|
ofTargetTypes(...e) {
|
|
1990
|
-
return
|
|
2333
|
+
return y(this, pt, Ft).call(this, (t) => getSchemaLocationDetails(t.location).targetTypes.some(
|
|
1991
2334
|
(n) => e.includes(n)
|
|
1992
2335
|
));
|
|
1993
2336
|
}
|
|
1994
2337
|
/** Only keep fields that aren't pointed to by any other field in the nexus document. */
|
|
1995
2338
|
notPointedTo() {
|
|
1996
|
-
return
|
|
1997
|
-
const t = s(this,
|
|
2339
|
+
return y(this, pt, Ft).call(this, (e) => {
|
|
2340
|
+
const t = s(this, vt).call(this).get(e.location);
|
|
1998
2341
|
return t === void 0 || t.length === 0;
|
|
1999
2342
|
});
|
|
2000
2343
|
}
|
|
2001
2344
|
pointedToBy(e) {
|
|
2002
|
-
return
|
|
2003
|
-
const n = s(this,
|
|
2345
|
+
return y(this, pt, Ft).call(this, (t) => {
|
|
2346
|
+
const n = s(this, vt).call(this).get(t.location);
|
|
2004
2347
|
return n !== void 0 && n.some((o) => o.equals(e));
|
|
2005
2348
|
});
|
|
2006
2349
|
}
|
|
2007
2350
|
primitiveFields() {
|
|
2008
|
-
return
|
|
2351
|
+
return y(this, pt, Ft).call(this, (e) => e instanceof PrimitiveField);
|
|
2009
2352
|
}
|
|
2010
2353
|
/** Returns all primitive fields selected using this query */
|
|
2011
2354
|
get() {
|
|
2012
|
-
return s(this,
|
|
2355
|
+
return s(this, Pt).call(this).filter((e) => s(this, kt).call(this, e));
|
|
2013
2356
|
}
|
|
2014
2357
|
/** Returns the first primitive field of the result, or undefined if the query is empty.
|
|
2015
2358
|
*/
|
|
@@ -2020,32 +2363,32 @@ const zt = class zt {
|
|
|
2020
2363
|
* part of a ComparableMap that maps entity ids to fields for that entity.
|
|
2021
2364
|
*/
|
|
2022
2365
|
getByEntity() {
|
|
2023
|
-
|
|
2366
|
+
y(this, pt, $t).call(this);
|
|
2024
2367
|
const e = /* @__PURE__ */ new Map();
|
|
2025
2368
|
return this.get().forEach((t) => {
|
|
2026
2369
|
e.has(t.location.entityId) || e.set(t.location.entityId, []), (e.get(t.location.entityId) ?? throw_()).push(t);
|
|
2027
2370
|
}), e;
|
|
2028
2371
|
}
|
|
2029
2372
|
};
|
|
2030
|
-
|
|
2031
|
-
return new
|
|
2032
|
-
getFields: s(this,
|
|
2033
|
-
getRefs: s(this,
|
|
2034
|
-
filterFields: (t) => s(this,
|
|
2035
|
-
documentLock: s(this,
|
|
2373
|
+
Pt = new WeakMap(), vt = new WeakMap(), kt = new WeakMap(), Mt = new WeakMap(), pt = new WeakSet(), Ft = function(e) {
|
|
2374
|
+
return new qt({
|
|
2375
|
+
getFields: s(this, Pt),
|
|
2376
|
+
getRefs: s(this, vt),
|
|
2377
|
+
filterFields: (t) => s(this, kt).call(this, t) && e(t),
|
|
2378
|
+
documentLock: s(this, Mt)
|
|
2036
2379
|
});
|
|
2037
|
-
},
|
|
2380
|
+
}, $t = function() {
|
|
2038
2381
|
var e;
|
|
2039
|
-
if (!(((e = s(this,
|
|
2382
|
+
if (!(((e = s(this, Mt)) == null ? void 0 : e.locked) ?? !0))
|
|
2040
2383
|
throw new Error("Document is not locked");
|
|
2041
2384
|
};
|
|
2042
|
-
let FieldQuery =
|
|
2043
|
-
var
|
|
2044
|
-
const
|
|
2385
|
+
let FieldQuery = qt;
|
|
2386
|
+
var T, ut, Tt, v, P, wt;
|
|
2387
|
+
const Ot = class Ot {
|
|
2045
2388
|
/** Don't construct this class, it is constructed by NexusDocument. */
|
|
2046
2389
|
constructor(e) {
|
|
2047
|
-
|
|
2048
|
-
|
|
2390
|
+
h(this, v);
|
|
2391
|
+
h(this, T);
|
|
2049
2392
|
/** This function filters & transforms entities. When modifying a query,
|
|
2050
2393
|
* (e.g. with `ofTypes`, we basically "append" another function
|
|
2051
2394
|
* to this one that filters and casts the entities.
|
|
@@ -2053,14 +2396,14 @@ const Kt = class Kt {
|
|
|
2053
2396
|
* When calling `run`, we get all entities and filter them using this function
|
|
2054
2397
|
* before returning all existing entities.
|
|
2055
2398
|
*/
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2399
|
+
h(this, ut);
|
|
2400
|
+
h(this, Tt);
|
|
2401
|
+
g(this, T, (e == null ? void 0 : e.documentState) ?? nexusDocumentState()), g(this, ut, (e == null ? void 0 : e.filterEntities) ?? ((t) => t)), g(this, Tt, e == null ? void 0 : e.documentLock);
|
|
2059
2402
|
}
|
|
2060
2403
|
/** Returns all entities selected by this query, in undefined order.
|
|
2061
2404
|
*/
|
|
2062
2405
|
get() {
|
|
2063
|
-
return
|
|
2406
|
+
return y(this, v, wt).call(this), [...s(this, ut).call(this, s(this, T).entities).values()];
|
|
2064
2407
|
}
|
|
2065
2408
|
/** Returns the first entity returned by `get()`, if any.
|
|
2066
2409
|
*
|
|
@@ -2069,11 +2412,11 @@ const Kt = class Kt {
|
|
|
2069
2412
|
* if it's known that the query will return at most one entity.
|
|
2070
2413
|
*/
|
|
2071
2414
|
getOne() {
|
|
2072
|
-
return
|
|
2415
|
+
return y(this, v, wt).call(this), this.get()[0];
|
|
2073
2416
|
}
|
|
2074
2417
|
/** Of all selected entities, return the one with id `id`, if it exists. */
|
|
2075
2418
|
getEntity(e) {
|
|
2076
|
-
return
|
|
2419
|
+
return y(this, v, wt).call(this), s(this, ut).call(this, s(this, T).entities).get(e);
|
|
2077
2420
|
}
|
|
2078
2421
|
/**
|
|
2079
2422
|
* Of all selected entities, return the one with id `id`. Throw if it doesn't
|
|
@@ -2087,7 +2430,7 @@ const Kt = class Kt {
|
|
|
2087
2430
|
* of the provided types.
|
|
2088
2431
|
*/
|
|
2089
2432
|
getEntityAs(e, ...t) {
|
|
2090
|
-
|
|
2433
|
+
y(this, v, wt).call(this), assert(t.length > 0, "must provide at least one type");
|
|
2091
2434
|
const n = this.getEntity(e);
|
|
2092
2435
|
if (n !== void 0 && t.includes(n.entityType))
|
|
2093
2436
|
return n;
|
|
@@ -2097,7 +2440,7 @@ const Kt = class Kt {
|
|
|
2097
2440
|
* provided types. Throw if it doesn't exist.
|
|
2098
2441
|
*/
|
|
2099
2442
|
mustGetEntityAs(e, ...t) {
|
|
2100
|
-
|
|
2443
|
+
y(this, v, wt).call(this), assert(t.length > 0, "must provide at least one type");
|
|
2101
2444
|
const n = this.mustGetEntity(e);
|
|
2102
2445
|
return t.includes(n.entityType) ? n : throw_(
|
|
2103
2446
|
`entity with uuid ${e} is not of any of the provided types ${t}`
|
|
@@ -2105,7 +2448,7 @@ const Kt = class Kt {
|
|
|
2105
2448
|
}
|
|
2106
2449
|
/** Only keep entities whose id appears in `ids`. */
|
|
2107
2450
|
withIds(...e) {
|
|
2108
|
-
return
|
|
2451
|
+
return y(this, v, P).call(this, (t) => filterByUuids(t, e));
|
|
2109
2452
|
}
|
|
2110
2453
|
/** Return the `FieldQuery<NexusField>` that starts with all fields of all
|
|
2111
2454
|
* currently selected entities.
|
|
@@ -2113,39 +2456,39 @@ const Kt = class Kt {
|
|
|
2113
2456
|
fields() {
|
|
2114
2457
|
return new FieldQuery({
|
|
2115
2458
|
getFields: () => [
|
|
2116
|
-
...s(this, ut).call(this, s(this,
|
|
2459
|
+
...s(this, ut).call(this, s(this, T).entities).values()
|
|
2117
2460
|
].flatMap((e) => toFields(e)),
|
|
2118
|
-
getRefs: () => s(this,
|
|
2461
|
+
getRefs: () => s(this, T).references,
|
|
2119
2462
|
filterFields: () => !0,
|
|
2120
|
-
documentLock: s(this,
|
|
2463
|
+
documentLock: s(this, Tt)
|
|
2121
2464
|
});
|
|
2122
2465
|
}
|
|
2123
2466
|
/** Only keep entities whose messages are marked with a target type appearing
|
|
2124
2467
|
* in `targetTypes`. Target types of fields of entities are ignored.
|
|
2125
2468
|
*/
|
|
2126
2469
|
ofTargetTypes(...e) {
|
|
2127
|
-
return
|
|
2470
|
+
return y(this, v, P).call(this, (t) => {
|
|
2128
2471
|
const n = /* @__PURE__ */ new Map();
|
|
2129
|
-
return t.forEach((o,
|
|
2472
|
+
return t.forEach((o, r) => {
|
|
2130
2473
|
getSchemaLocationDetails(o.location).targetTypes.some(
|
|
2131
2474
|
(c) => e.includes(c)
|
|
2132
|
-
) && n.set(
|
|
2475
|
+
) && n.set(r, o);
|
|
2133
2476
|
}), n;
|
|
2134
2477
|
});
|
|
2135
2478
|
}
|
|
2136
2479
|
/** Check if a specific entity is contained in the current query. */
|
|
2137
2480
|
has(e) {
|
|
2138
|
-
|
|
2481
|
+
y(this, v, wt).call(this);
|
|
2139
2482
|
const t = typeof e == "string" ? e : e.id;
|
|
2140
|
-
return s(this, ut).call(this, s(this,
|
|
2483
|
+
return s(this, ut).call(this, s(this, T).entities).has(t);
|
|
2141
2484
|
}
|
|
2142
2485
|
/** Only keep entities whose type string appears in `types`. */
|
|
2143
2486
|
ofTypes(...e) {
|
|
2144
|
-
return
|
|
2487
|
+
return y(this, v, P).call(this, (t) => filterByType(t, e));
|
|
2145
2488
|
}
|
|
2146
2489
|
/** Omit entities whose type string appears in `types`. */
|
|
2147
2490
|
notOfTypes(...e) {
|
|
2148
|
-
return
|
|
2491
|
+
return y(this, v, P).call(this, (t) => omitByType(t, e));
|
|
2149
2492
|
}
|
|
2150
2493
|
/** Only keep entities that have some fields that point to:
|
|
2151
2494
|
* * `entityOfType`: some field of entities of a set of types
|
|
@@ -2161,21 +2504,21 @@ const Kt = class Kt {
|
|
|
2161
2504
|
*/
|
|
2162
2505
|
get pointingTo() {
|
|
2163
2506
|
return {
|
|
2164
|
-
entityOfType: (...e) =>
|
|
2507
|
+
entityOfType: (...e) => y(this, v, P).call(this, (t) => filterByUuids(
|
|
2165
2508
|
t,
|
|
2166
2509
|
getUuidsPointingToTypes(
|
|
2167
|
-
s(this,
|
|
2168
|
-
s(this,
|
|
2510
|
+
s(this, T).references,
|
|
2511
|
+
s(this, T).entities,
|
|
2169
2512
|
...e
|
|
2170
2513
|
)
|
|
2171
2514
|
)),
|
|
2172
|
-
locations: (...e) =>
|
|
2515
|
+
locations: (...e) => y(this, v, P).call(this, (t) => filterByUuids(
|
|
2173
2516
|
t,
|
|
2174
|
-
getUuidsPointingToLocations(s(this,
|
|
2517
|
+
getUuidsPointingToLocations(s(this, T).references, e)
|
|
2175
2518
|
)),
|
|
2176
|
-
entities: (...e) =>
|
|
2519
|
+
entities: (...e) => y(this, v, P).call(this, (t) => filterByUuids(
|
|
2177
2520
|
t,
|
|
2178
|
-
getUuidsPointingToEntities(s(this,
|
|
2521
|
+
getUuidsPointingToEntities(s(this, T).references, e)
|
|
2179
2522
|
))
|
|
2180
2523
|
};
|
|
2181
2524
|
}
|
|
@@ -2193,41 +2536,41 @@ const Kt = class Kt {
|
|
|
2193
2536
|
*/
|
|
2194
2537
|
get pointedToBy() {
|
|
2195
2538
|
return {
|
|
2196
|
-
entityOfType: (...e) =>
|
|
2539
|
+
entityOfType: (...e) => y(this, v, P).call(this, (t) => filterByUuids(
|
|
2197
2540
|
t,
|
|
2198
2541
|
getUuidsPointedToByTypes(
|
|
2199
|
-
s(this,
|
|
2200
|
-
s(this,
|
|
2542
|
+
s(this, T).references,
|
|
2543
|
+
s(this, T).entities,
|
|
2201
2544
|
...e
|
|
2202
2545
|
)
|
|
2203
2546
|
)),
|
|
2204
|
-
locations: (...e) =>
|
|
2547
|
+
locations: (...e) => y(this, v, P).call(this, (t) => filterByUuids(
|
|
2205
2548
|
t,
|
|
2206
|
-
getUuidsPointedToByLocations(s(this,
|
|
2549
|
+
getUuidsPointedToByLocations(s(this, T).references, e)
|
|
2207
2550
|
)),
|
|
2208
|
-
entities: (...e) =>
|
|
2551
|
+
entities: (...e) => y(this, v, P).call(this, (t) => filterByUuids(
|
|
2209
2552
|
t,
|
|
2210
|
-
getUuidsPointedToByEntities(s(this,
|
|
2553
|
+
getUuidsPointedToByEntities(s(this, T).references, e)
|
|
2211
2554
|
))
|
|
2212
2555
|
};
|
|
2213
2556
|
}
|
|
2214
2557
|
};
|
|
2215
|
-
|
|
2558
|
+
T = new WeakMap(), ut = new WeakMap(), Tt = new WeakMap(), v = new WeakSet(), /** Return a copy of this class, with a new function "appended" to the
|
|
2216
2559
|
* filter pipeline. The filter can change the type of the entity, or
|
|
2217
2560
|
* remove entities from the query.
|
|
2218
2561
|
*/
|
|
2219
|
-
|
|
2220
|
-
return new
|
|
2221
|
-
documentState: s(this,
|
|
2562
|
+
P = function(e) {
|
|
2563
|
+
return new Ot({
|
|
2564
|
+
documentState: s(this, T),
|
|
2222
2565
|
filterEntities: (t) => e(s(this, ut).call(this, t)),
|
|
2223
|
-
documentLock: s(this,
|
|
2566
|
+
documentLock: s(this, Tt)
|
|
2224
2567
|
});
|
|
2225
|
-
},
|
|
2568
|
+
}, wt = function() {
|
|
2226
2569
|
var e;
|
|
2227
|
-
if (!(((e = s(this,
|
|
2570
|
+
if (!(((e = s(this, Tt)) == null ? void 0 : e.locked) ?? !0))
|
|
2228
2571
|
throw new Error("EntityQuery method called without locking the document");
|
|
2229
2572
|
};
|
|
2230
|
-
let EntityQuery =
|
|
2573
|
+
let EntityQuery = Ot;
|
|
2231
2574
|
const filterByType = (i, e) => {
|
|
2232
2575
|
const t = /* @__PURE__ */ new Map();
|
|
2233
2576
|
return [...i.values()].filter((n) => e.includes(n.entityType)).forEach((n) => t.set(n.id, n)), t;
|
|
@@ -2243,17 +2586,17 @@ const filterByType = (i, e) => {
|
|
|
2243
2586
|
var n;
|
|
2244
2587
|
return ((n = i.get(t)) == null ? void 0 : n.map((o) => o.entityId)) ?? [];
|
|
2245
2588
|
}), getUuidsPointingToEntities = (i, e) => [...i.entries()].filter(([t, n]) => e.some((o) => t.entityId === o)).flatMap(([t, n]) => n.map((o) => o.entityId)), getUuidsPointedToByLocations = (i, e) => [...i.entries()].filter(
|
|
2246
|
-
([t, n]) => e.some((o) => n.some((
|
|
2589
|
+
([t, n]) => e.some((o) => n.some((r) => o.equals(r)))
|
|
2247
2590
|
).map(([t, n]) => t.entityId), getUuidsPointingToTypes = (i, e, ...t) => [...i.entries()].filter(([n, o]) => {
|
|
2248
|
-
const
|
|
2249
|
-
return
|
|
2250
|
-
}).flatMap(([n, o]) => o.map((
|
|
2251
|
-
([n, o]) => o.some((
|
|
2252
|
-
const c = e.get(
|
|
2591
|
+
const r = e.get(n.entityId);
|
|
2592
|
+
return r !== void 0 && t.includes(r.entityType);
|
|
2593
|
+
}).flatMap(([n, o]) => o.map((r) => r.entityId)), getUuidsPointedToByTypes = (i, e, ...t) => [...i.entries()].filter(
|
|
2594
|
+
([n, o]) => o.some((r) => {
|
|
2595
|
+
const c = e.get(r.entityId);
|
|
2253
2596
|
return c !== void 0 && t.includes(c.entityType);
|
|
2254
2597
|
})
|
|
2255
2598
|
).map(([n, o]) => n.entityId), getUuidsPointedToByEntities = (i, e) => [...i.entries()].filter(
|
|
2256
|
-
([t, n]) => e.some((o) => n.some((
|
|
2599
|
+
([t, n]) => e.some((o) => n.some((r) => r.entityId === o))
|
|
2257
2600
|
).map(([t, n]) => t.entityId), toFields = (i) => {
|
|
2258
2601
|
const e = (t) => {
|
|
2259
2602
|
if (t instanceof PrimitiveField)
|
|
@@ -2356,15 +2699,15 @@ const filterByType = (i, e) => {
|
|
|
2356
2699
|
);
|
|
2357
2700
|
return;
|
|
2358
2701
|
}
|
|
2359
|
-
const
|
|
2702
|
+
const r = t[n.localName], c = o[n.localName];
|
|
2360
2703
|
assert(
|
|
2361
|
-
Array.isArray(
|
|
2704
|
+
Array.isArray(r),
|
|
2362
2705
|
`tried overriding repeated field ${n.localName} of message ${e.getType().typeName} with non-array field`
|
|
2363
2706
|
), assert(
|
|
2364
|
-
|
|
2707
|
+
r.length === c.length,
|
|
2365
2708
|
`tried overriding repeated field ${n.localName} with array of different length`
|
|
2366
|
-
),
|
|
2367
|
-
c[
|
|
2709
|
+
), r.forEach((l, d) => {
|
|
2710
|
+
c[d] = toFieldValue(i, n, c[d], l);
|
|
2368
2711
|
});
|
|
2369
2712
|
});
|
|
2370
2713
|
}, toFieldValue = (i, e, t, n) => {
|
|
@@ -2406,8 +2749,8 @@ const filterByType = (i, e) => {
|
|
|
2406
2749
|
return n.map((o) => t(o));
|
|
2407
2750
|
if (typeof n == "object" && n != null) {
|
|
2408
2751
|
const o = {};
|
|
2409
|
-
return Object.entries(n).forEach(([
|
|
2410
|
-
o[
|
|
2752
|
+
return Object.entries(n).forEach(([r, c]) => {
|
|
2753
|
+
o[r] = t(c);
|
|
2411
2754
|
}), o;
|
|
2412
2755
|
}
|
|
2413
2756
|
return n;
|
|
@@ -2415,31 +2758,31 @@ const filterByType = (i, e) => {
|
|
|
2415
2758
|
return t(i);
|
|
2416
2759
|
}, buildModificationsForCloneLinkedEntities = (...i) => {
|
|
2417
2760
|
const e = i.map(
|
|
2418
|
-
(
|
|
2761
|
+
(d) => d instanceof NexusEntity ? { entity: d } : d
|
|
2419
2762
|
), t = /* @__PURE__ */ new Map();
|
|
2420
2763
|
e.forEach(
|
|
2421
|
-
(
|
|
2764
|
+
(d) => t.set(d.entity.id, crypto.randomUUID())
|
|
2422
2765
|
);
|
|
2423
2766
|
const n = /* @__PURE__ */ new Map();
|
|
2424
|
-
e.forEach((
|
|
2425
|
-
const o = /* @__PURE__ */ new Map(),
|
|
2426
|
-
[...n.values()].forEach(({ entity:
|
|
2427
|
-
const
|
|
2428
|
-
|
|
2429
|
-
const
|
|
2430
|
-
const
|
|
2431
|
-
return
|
|
2432
|
-
...
|
|
2433
|
-
])) :
|
|
2767
|
+
e.forEach((d) => n.set(d.entity.id, d));
|
|
2768
|
+
const o = /* @__PURE__ */ new Map(), r = [];
|
|
2769
|
+
[...n.values()].forEach(({ entity: d, overwrites: u }) => {
|
|
2770
|
+
const f = entityToConstructorType(d), m = createDefaultEntityMessage(d.entityType);
|
|
2771
|
+
m.id = t.get(d.id) ?? throw_();
|
|
2772
|
+
const p = mapConstructorLocations(f, (w) => {
|
|
2773
|
+
const x = t.get(w.entityId);
|
|
2774
|
+
return x !== void 0 ? (r.push([m.id, x]), new NexusLocation(x, w.entityType, [
|
|
2775
|
+
...w.fieldIndex
|
|
2776
|
+
])) : w;
|
|
2434
2777
|
});
|
|
2435
|
-
updateEntityMessageWithConstructor(
|
|
2778
|
+
updateEntityMessageWithConstructor(m, p), u !== void 0 && updateEntityMessageWithConstructor(m, u), o.set(m.id, [d.entityType, m]);
|
|
2436
2779
|
});
|
|
2437
|
-
const c = toposort(
|
|
2438
|
-
(
|
|
2780
|
+
const c = toposort(r).reverse(), l = [...o.keys()].filter(
|
|
2781
|
+
(d) => !c.includes(d)
|
|
2439
2782
|
);
|
|
2440
2783
|
return {
|
|
2441
|
-
modifications: [...c, ...
|
|
2442
|
-
const [, u] = o.get(
|
|
2784
|
+
modifications: [...c, ...l].map((d) => {
|
|
2785
|
+
const [, u] = o.get(d) ?? throw_();
|
|
2443
2786
|
return buildCreateModification(u);
|
|
2444
2787
|
}),
|
|
2445
2788
|
uuidMap: t
|
|
@@ -2467,13 +2810,13 @@ const filterByType = (i, e) => {
|
|
|
2467
2810
|
};
|
|
2468
2811
|
}, buildModificationForRemove = (i) => buildDeleteModification(i), buildModificationForRemoveWithDependencies = (i, e) => {
|
|
2469
2812
|
const t = /* @__PURE__ */ new Set(), n = [];
|
|
2470
|
-
t.add(i), t.forEach((
|
|
2471
|
-
e.pointingTo.entities(
|
|
2472
|
-
n.push([c.id,
|
|
2813
|
+
t.add(i), t.forEach((r) => {
|
|
2814
|
+
e.pointingTo.entities(r).get().forEach((c) => {
|
|
2815
|
+
n.push([c.id, r]), t.add(c.id);
|
|
2473
2816
|
});
|
|
2474
2817
|
});
|
|
2475
2818
|
let o;
|
|
2476
|
-
return n.length > 0 ? o = toposort(n) : o = [i], o.map((
|
|
2819
|
+
return n.length > 0 ? o = toposort(n) : o = [i], o.map((r) => buildModificationForRemove(r));
|
|
2477
2820
|
}, buildPresetUpdateModifications = (i, e) => buildModificationForObject(i, e), buildModificationForField = (i, e) => {
|
|
2478
2821
|
if (i instanceof PrimitiveField)
|
|
2479
2822
|
return buildUpdateForPrimitiveField(i, e);
|
|
@@ -2492,17 +2835,17 @@ const filterByType = (i, e) => {
|
|
|
2492
2835
|
), i.value.equalsPointer(e) ? [] : [buildModificationForFieldUpdate(i, e)]) : i.value === e ? [] : [buildModificationForFieldUpdate(i, e)]), updatePresetPointers = (i, e) => {
|
|
2493
2836
|
const t = /* @__PURE__ */ new Map(), n = unpackEntity(i.target) ?? throw_();
|
|
2494
2837
|
t.set(n.id, e), t.set("", "");
|
|
2495
|
-
const o = i.relatives.map((
|
|
2496
|
-
return o.forEach((
|
|
2497
|
-
if (t.has(
|
|
2838
|
+
const o = i.relatives.map((r) => unpackEntity(r) ?? throw_());
|
|
2839
|
+
return o.forEach((r) => {
|
|
2840
|
+
if (t.has(r.id))
|
|
2498
2841
|
throw new Error("duplicate entity id");
|
|
2499
|
-
t.set(
|
|
2500
|
-
}), [n, ...o].forEach((
|
|
2501
|
-
|
|
2502
|
-
t.has(c.entityId) || console.error("entity",
|
|
2842
|
+
t.set(r.id, crypto.randomUUID());
|
|
2843
|
+
}), [n, ...o].forEach((r) => {
|
|
2844
|
+
r ?? (r = throw_("can't happen")), r.id = t.get(r.id) ?? throw_(), visitPointers(r, (c) => {
|
|
2845
|
+
t.has(c.entityId) || console.error("entity", r.constructor.name, "pointer", c), c.entityId = t.get(c.entityId) ?? throw_("preset contains pointer to unknown entity");
|
|
2503
2846
|
});
|
|
2504
2847
|
}), new Preset({
|
|
2505
|
-
relatives: o.map((
|
|
2848
|
+
relatives: o.map((r) => packEntity(r)),
|
|
2506
2849
|
target: packEntity(n)
|
|
2507
2850
|
});
|
|
2508
2851
|
}, visitPointers = (i, e) => {
|
|
@@ -2544,13 +2887,13 @@ const filterByType = (i, e) => {
|
|
|
2544
2887
|
entitiesToRemovePointingToMain: PRESET_TARGET_RELATIVE_TYPES[e] ?? throw_("preset with unexpected main entity type")
|
|
2545
2888
|
};
|
|
2546
2889
|
}, toposortEntities = (i) => {
|
|
2547
|
-
const e = new Map(i.map((
|
|
2548
|
-
i.forEach((
|
|
2549
|
-
visitPointers(
|
|
2550
|
-
e.has(c.entityId) && t.push([
|
|
2890
|
+
const e = new Map(i.map((r) => [r.id, r])), t = [];
|
|
2891
|
+
i.forEach((r) => {
|
|
2892
|
+
visitPointers(r, (c) => {
|
|
2893
|
+
e.has(c.entityId) && t.push([r.id, c.entityId]);
|
|
2551
2894
|
});
|
|
2552
2895
|
});
|
|
2553
|
-
const n = toposort(t).reverse().map((
|
|
2896
|
+
const n = toposort(t).reverse().map((r) => e.get(r) ?? throw_()), o = i.filter((r) => !n.includes(r));
|
|
2554
2897
|
return [...n, ...o];
|
|
2555
2898
|
}, PRESET_TARGET_RELATIVE_TYPES = {
|
|
2556
2899
|
// synthesizers
|
|
@@ -2656,12 +2999,12 @@ const filterByType = (i, e) => {
|
|
|
2656
2999
|
// select entities that point from/tom target entity
|
|
2657
3000
|
...o.pointingTo.entities(i.id).get(),
|
|
2658
3001
|
...o.pointedToBy.entities(i.id).get()
|
|
2659
|
-
].map((
|
|
3002
|
+
].map((r) => [
|
|
2660
3003
|
// select entities that point from/to any relatives entity
|
|
2661
|
-
...o.pointingTo.entities(
|
|
2662
|
-
...o.pointedToBy.entities(
|
|
2663
|
-
|
|
2664
|
-
]).flat().map((
|
|
3004
|
+
...o.pointingTo.entities(r.id).get(),
|
|
3005
|
+
...o.pointedToBy.entities(r.id).get(),
|
|
3006
|
+
r
|
|
3007
|
+
]).flat().map((r) => entityToPbMessage(r, !1));
|
|
2665
3008
|
}
|
|
2666
3009
|
return updateUuids([t, ...n]), new Preset({
|
|
2667
3010
|
relatives: n.map((o) => packEntity(o)),
|
|
@@ -2673,8 +3016,8 @@ const filterByType = (i, e) => {
|
|
|
2673
3016
|
const t = (n) => (e.set(n, e.get(n) ?? crypto.randomUUID()), e.get(n) ?? throw_());
|
|
2674
3017
|
i.forEach((n) => {
|
|
2675
3018
|
const o = t(n.id);
|
|
2676
|
-
n.id = o, visitPointers(n, (
|
|
2677
|
-
|
|
3019
|
+
n.id = o, visitPointers(n, (r) => {
|
|
3020
|
+
r.entityId = t(r.entityId);
|
|
2678
3021
|
});
|
|
2679
3022
|
});
|
|
2680
3023
|
}, transactionBuilder = (i) => {
|
|
@@ -2683,22 +3026,22 @@ const filterByType = (i, e) => {
|
|
|
2683
3026
|
create: (t, n) => {
|
|
2684
3027
|
if (e)
|
|
2685
3028
|
throw new CallAfterSendError("create");
|
|
2686
|
-
const { modification: o, entityId:
|
|
2687
|
-
return i.applyModification(o, !0), i.query.mustGetEntity(
|
|
3029
|
+
const { modification: o, entityId: r } = buildModificationForNewEntity(t, n);
|
|
3030
|
+
return i.applyModification(o, !0), i.query.mustGetEntity(r);
|
|
2688
3031
|
},
|
|
2689
3032
|
clone: (t, n) => {
|
|
2690
3033
|
if (e)
|
|
2691
3034
|
throw new CallAfterSendError("clone");
|
|
2692
|
-
const { modification: o, entityId:
|
|
2693
|
-
return i.applyModification(o, !0), i.query.mustGetEntity(
|
|
3035
|
+
const { modification: o, entityId: r } = buildModificationForEntityClone(t, n);
|
|
3036
|
+
return i.applyModification(o, !0), i.query.mustGetEntity(r);
|
|
2694
3037
|
},
|
|
2695
3038
|
cloneLinked: (...t) => {
|
|
2696
3039
|
if (e)
|
|
2697
3040
|
throw new CallAfterSendError("cloneLinked");
|
|
2698
3041
|
const { modifications: n, uuidMap: o } = buildModificationsForCloneLinkedEntities(...t);
|
|
2699
|
-
return n.forEach((
|
|
2700
|
-
const c =
|
|
2701
|
-
return i.query.mustGetEntity(
|
|
3042
|
+
return n.forEach((r) => i.applyModification(r, !0)), t.map((r) => {
|
|
3043
|
+
const c = r instanceof NexusEntity ? r.id : r.entity.id, l = o.get(c) ?? throw_();
|
|
3044
|
+
return i.query.mustGetEntity(l);
|
|
2702
3045
|
});
|
|
2703
3046
|
},
|
|
2704
3047
|
update: (t, n) => {
|
|
@@ -2725,7 +3068,7 @@ const filterByType = (i, e) => {
|
|
|
2725
3068
|
if (e)
|
|
2726
3069
|
throw new CallAfterSendError("removeWithDependencies");
|
|
2727
3070
|
const n = t instanceof NexusEntity ? t.id : t;
|
|
2728
|
-
buildModificationForRemoveWithDependencies(n, i.query).forEach((
|
|
3071
|
+
buildModificationForRemoveWithDependencies(n, i.query).forEach((r) => i.applyModification(r, !0));
|
|
2729
3072
|
},
|
|
2730
3073
|
applyPresetTo: (t, n) => {
|
|
2731
3074
|
if (e)
|
|
@@ -2770,10 +3113,10 @@ class CallAfterSendError extends Error {
|
|
|
2770
3113
|
);
|
|
2771
3114
|
}
|
|
2772
3115
|
}
|
|
2773
|
-
var mt,
|
|
3116
|
+
var mt, S, M, ft, yt, Lt, It, Ut, Nt, Bt, Ct, Dt;
|
|
2774
3117
|
class NexusDocument {
|
|
2775
3118
|
constructor(e) {
|
|
2776
|
-
|
|
3119
|
+
h(this, Ct);
|
|
2777
3120
|
/** Public field to query the entities in the document.
|
|
2778
3121
|
*
|
|
2779
3122
|
* ## Careful
|
|
@@ -2807,41 +3150,50 @@ class NexusDocument {
|
|
|
2807
3150
|
* })
|
|
2808
3151
|
* ```
|
|
2809
3152
|
*/
|
|
2810
|
-
|
|
3153
|
+
a(this, "queryEntitiesWithoutLock");
|
|
2811
3154
|
/** Manages subscriptions to nexus events, such as entity update & creation */
|
|
2812
|
-
|
|
3155
|
+
a(this, "events");
|
|
2813
3156
|
/**
|
|
2814
3157
|
* This is a notifier that notifies of all modifications applied on the nexus
|
|
2815
3158
|
* document, locally created or incoming from the backend.
|
|
2816
3159
|
*
|
|
2817
3160
|
* If the transaction is incoming `local` is `false`.
|
|
2818
3161
|
*/
|
|
2819
|
-
|
|
3162
|
+
a(this, "onModification", new Notifier());
|
|
2820
3163
|
/** Keeps track of all entities currently in the document. */
|
|
2821
|
-
|
|
3164
|
+
h(this, mt);
|
|
2822
3165
|
/**
|
|
2823
3166
|
* Lock that protects transactions. Only one transaction can be created at a time.
|
|
2824
3167
|
*/
|
|
2825
|
-
|
|
3168
|
+
h(this, S, new AsyncLock());
|
|
2826
3169
|
/** The connection to the backend */
|
|
2827
|
-
|
|
3170
|
+
h(this, M);
|
|
2828
3171
|
/** Validates any and all modifications */
|
|
2829
|
-
|
|
3172
|
+
h(this, ft);
|
|
2830
3173
|
/**
|
|
2831
3174
|
* This flag is set to true if {@link takeTransactions} is called. Before that, no transactions
|
|
2832
3175
|
* from the backend are processed, and no transactions are allowed to be created from the frontend.
|
|
2833
3176
|
*
|
|
2834
3177
|
* This is to make sure that all `onCreate` callbacks are attached before any entity is created.
|
|
2835
3178
|
*/
|
|
2836
|
-
|
|
3179
|
+
h(this, yt, !1);
|
|
3180
|
+
/**
|
|
3181
|
+
* This flag is set to true during {@link stop} to exit early if {@link stop} is called twice.
|
|
3182
|
+
*/
|
|
3183
|
+
h(this, Lt, !1);
|
|
3184
|
+
/**
|
|
3185
|
+
* This flag is set to true after {@link stop} is called and causes all further calls to {@link createTransaction} and {@link modify} to throw an error.
|
|
3186
|
+
*/
|
|
3187
|
+
h(this, It, !1);
|
|
2837
3188
|
/**
|
|
2838
3189
|
* The number of modifications applied to the document for incoming transactions before control
|
|
2839
3190
|
* is yield to the scheduler.
|
|
2840
3191
|
*/
|
|
2841
|
-
|
|
3192
|
+
h(this, Ut);
|
|
2842
3193
|
/** The delay between two gateway.synchronize() calls to sync with backend. */
|
|
2843
|
-
|
|
2844
|
-
h(this,
|
|
3194
|
+
h(this, Nt);
|
|
3195
|
+
h(this, Bt);
|
|
3196
|
+
g(this, Nt, (e == null ? void 0 : e.synchronizeEveryMs) ?? 16), g(this, Ut, (e == null ? void 0 : e.incomingModificationsBatchSize) ?? 20), g(this, mt, nexusDocumentState({
|
|
2845
3197
|
callbacks: {
|
|
2846
3198
|
onStartPointingTo: (t, n) => {
|
|
2847
3199
|
this.events._dispatchPointingTo(n, t);
|
|
@@ -2872,7 +3224,7 @@ class NexusDocument {
|
|
|
2872
3224
|
* This is to make sure that all `onCreate` callbacks are attached before any entity is created.
|
|
2873
3225
|
*/
|
|
2874
3226
|
get transactionsAllowed() {
|
|
2875
|
-
return s(this,
|
|
3227
|
+
return s(this, yt);
|
|
2876
3228
|
}
|
|
2877
3229
|
/**
|
|
2878
3230
|
* Wait to acquire the document lock, then returns a {@link TransactionBuilder} that can be used to modify the nexus document
|
|
@@ -2887,27 +3239,27 @@ class NexusDocument {
|
|
|
2887
3239
|
* @returns: {@link TransactionBuilder}
|
|
2888
3240
|
*/
|
|
2889
3241
|
async createTransaction(e, t = !0) {
|
|
2890
|
-
assert(s(this,
|
|
2891
|
-
const n = t ? await s(this,
|
|
3242
|
+
assert(s(this, yt), "Transactions not allowed yet"), assert(s(this, M) !== void 0, "Gateway not initialized"), assert(s(this, ft) !== void 0, "Validator not initialized"), assert(!s(this, It), "Document stopped");
|
|
3243
|
+
const n = t ? await s(this, S).acquire() : void 0, o = [], r = new EntityQuery({
|
|
2892
3244
|
documentState: s(this, mt),
|
|
2893
|
-
documentLock: s(this,
|
|
3245
|
+
documentLock: s(this, S)
|
|
2894
3246
|
}), c = (e == null ? void 0 : e.actionId) ?? Symbol();
|
|
2895
3247
|
return transactionBuilder({
|
|
2896
|
-
applyModification: (
|
|
2897
|
-
const u =
|
|
3248
|
+
applyModification: (l, d) => {
|
|
3249
|
+
const u = y(this, Ct, Dt).call(this, l, {
|
|
2898
3250
|
local: !0,
|
|
2899
|
-
throwIfInvalid:
|
|
3251
|
+
throwIfInvalid: d,
|
|
2900
3252
|
actionId: c
|
|
2901
3253
|
});
|
|
2902
3254
|
if (u !== void 0)
|
|
2903
3255
|
return u;
|
|
2904
|
-
o.push(
|
|
3256
|
+
o.push(l);
|
|
2905
3257
|
},
|
|
2906
3258
|
finish: () => {
|
|
2907
|
-
var
|
|
2908
|
-
return o.length === 0 ? (n == null || n.release(), []) : ((
|
|
3259
|
+
var l;
|
|
3260
|
+
return o.length === 0 ? (n == null || n.release(), []) : ((l = s(this, M)) == null || l.send(new Transaction({ modifications: o })), n == null || n.release(), o);
|
|
2909
3261
|
},
|
|
2910
|
-
query:
|
|
3262
|
+
query: r
|
|
2911
3263
|
});
|
|
2912
3264
|
}
|
|
2913
3265
|
/**
|
|
@@ -2940,397 +3292,108 @@ class NexusDocument {
|
|
|
2940
3292
|
* It should be called exactly once when all `onCreate` callbacks are registered.
|
|
2941
3293
|
*/
|
|
2942
3294
|
async takeTransactions(e) {
|
|
2943
|
-
if (s(this,
|
|
3295
|
+
if (s(this, yt))
|
|
2944
3296
|
throw new Error("called `takeTransactions()` twice");
|
|
2945
|
-
|
|
3297
|
+
g(this, ft, (e == null ? void 0 : e.validator) ?? mockNexusValidator()), g(this, M, (e == null ? void 0 : e.gateway) ?? mockNexusGateway());
|
|
2946
3298
|
let t;
|
|
2947
|
-
s(this, M).blocked.subscribe(async (
|
|
2948
|
-
|
|
3299
|
+
s(this, M).blocked.subscribe(async (u) => {
|
|
3300
|
+
u ? t === void 0 && (t = await s(this, S).acquire()) : (t == null || t.release(), t = void 0);
|
|
2949
3301
|
});
|
|
2950
|
-
const n = await s(this,
|
|
2951
|
-
|
|
3302
|
+
const n = await s(this, S).acquire();
|
|
3303
|
+
g(this, yt, !0);
|
|
2952
3304
|
const {
|
|
2953
3305
|
promise: o,
|
|
2954
|
-
resolve:
|
|
3306
|
+
resolve: r
|
|
2955
3307
|
} = Promise.withResolvers(), c = asyncInterval(async () => {
|
|
2956
|
-
const
|
|
2957
|
-
if (
|
|
3308
|
+
const u = (s(this, M) ?? throw_()).synchronize();
|
|
3309
|
+
if (u.length === 0)
|
|
2958
3310
|
return;
|
|
2959
|
-
const
|
|
2960
|
-
await this.
|
|
3311
|
+
const f = u.flatMap((m) => m.modifications).length;
|
|
3312
|
+
await this._applyIncomingTransactions(u, {
|
|
2961
3313
|
_takeTransactionLock: !1
|
|
2962
|
-
}), c.terminate(),
|
|
2963
|
-
}, s(this,
|
|
3314
|
+
}), c.terminate(), r(f > 0);
|
|
3315
|
+
}, s(this, Nt)), l = await o;
|
|
2964
3316
|
if ((e == null ? void 0 : e.templateTransaction) !== void 0)
|
|
2965
|
-
if (
|
|
3317
|
+
if (l)
|
|
2966
3318
|
console.error(
|
|
2967
3319
|
"Could not apply template transaction to document: Project state from backend is not empty."
|
|
2968
3320
|
);
|
|
2969
3321
|
else {
|
|
2970
|
-
const
|
|
2971
|
-
|
|
3322
|
+
const u = await e.templateTransaction, f = await this.createTransaction(void 0, !1);
|
|
3323
|
+
u.modifications.forEach((m) => f._addModification(m)), f.send();
|
|
2972
3324
|
}
|
|
2973
|
-
n.release()
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
3325
|
+
n.release();
|
|
3326
|
+
const d = asyncInterval(async (u) => {
|
|
3327
|
+
if (u.aborted)
|
|
3328
|
+
return;
|
|
3329
|
+
const f = await s(this, S).acquire(), m = (s(this, M) ?? throw_()).synchronize();
|
|
3330
|
+
await this._applyIncomingTransactions(m, { _takeTransactionLock: !1 }), f.release();
|
|
3331
|
+
}, s(this, Nt));
|
|
3332
|
+
g(this, Bt, () => d.terminate());
|
|
2977
3333
|
}
|
|
2978
3334
|
/** Apply a transaction that doesn't originate from this document. Yields to the browser
|
|
2979
3335
|
* scheduler every few modifications applied to make sure we don't block the main thread
|
|
2980
3336
|
* for too long for big transactions. Throws if the transaction lock isn't taken.
|
|
2981
3337
|
*
|
|
2982
3338
|
*/
|
|
2983
|
-
async
|
|
2984
|
-
assert(s(this, M) !== void 0, "Gateway not initialized"), assert(s(this,
|
|
2985
|
-
const n = (t == null ? void 0 : t._takeTransactionLock) ?? !0 ? await s(this,
|
|
2986
|
-
s(this,
|
|
3339
|
+
async _applyIncomingTransactions(e, t) {
|
|
3340
|
+
assert(s(this, M) !== void 0, "Gateway not initialized"), assert(s(this, ft) !== void 0, "Validator not initialized"), assert(!s(this, It), "Document stopped");
|
|
3341
|
+
const n = (t == null ? void 0 : t._takeTransactionLock) ?? !0 ? await s(this, S).acquire() : assert(
|
|
3342
|
+
s(this, S).locked,
|
|
2987
3343
|
"if takeTransactionLock is false, the lock must be held."
|
|
2988
3344
|
);
|
|
2989
3345
|
for (const o of e)
|
|
2990
|
-
for (const [
|
|
2991
|
-
|
|
3346
|
+
for (const [r, c] of o.modifications.entries())
|
|
3347
|
+
y(this, Ct, Dt).call(this, c, {
|
|
2992
3348
|
local: !1,
|
|
2993
3349
|
throwIfInvalid: !0
|
|
2994
|
-
}),
|
|
3350
|
+
}), r % s(this, Ut) === 0 && await sleep(0);
|
|
2995
3351
|
n == null || n.release();
|
|
2996
3352
|
}
|
|
2997
3353
|
/** For debugging purposes */
|
|
2998
3354
|
getStats() {
|
|
2999
3355
|
return s(this, mt).getStats();
|
|
3000
3356
|
}
|
|
3357
|
+
/** Stop the document from syncing. This will have the following effect:
|
|
3358
|
+
* First, all pending `modify` and `createTransaction` calls will finish.
|
|
3359
|
+
* The modifications they create will be synced with the backend, and the document is locked down.
|
|
3360
|
+
*
|
|
3361
|
+
* After this, calling `modify` or `createTransaction` will throw an error. The only property that
|
|
3362
|
+
* can still be accessed is `queryEntities`. The document can be thrown away safely after this.
|
|
3363
|
+
*/
|
|
3364
|
+
async terminate() {
|
|
3365
|
+
var e, t, n;
|
|
3366
|
+
if (!s(this, yt))
|
|
3367
|
+
throw new Error("Can't stop a document that hasn't started yet.");
|
|
3368
|
+
s(this, Lt) || (g(this, Lt, !0), await s(this, S).acquire(), (e = s(this, Bt)) == null || e.call(this), s(this, S).acquire = () => throw_(
|
|
3369
|
+
"invariant violated: cannot get transaction lock after document stopped"
|
|
3370
|
+
), g(this, It, !0), await ((t = s(this, M)) == null ? void 0 : t.terminate()), (n = s(this, ft)) == null || n.terminate(), this.events._clear());
|
|
3371
|
+
}
|
|
3001
3372
|
}
|
|
3002
|
-
mt = new WeakMap(),
|
|
3373
|
+
mt = new WeakMap(), S = new WeakMap(), M = new WeakMap(), ft = new WeakMap(), yt = new WeakMap(), Lt = new WeakMap(), It = new WeakMap(), Ut = new WeakMap(), Nt = new WeakMap(), Bt = new WeakMap(), Ct = new WeakSet(), /**
|
|
3003
3374
|
* Apply a modification to the document after validating it, and dispatch events to
|
|
3004
3375
|
* {@link onModification} listeners. Throws if the modification is invalid, unless `throwIfInvalid` is false;
|
|
3005
3376
|
* in that case, the function returns `string` on error and doesn't change the document state. If application
|
|
3006
3377
|
* succeeds, always returns undefined.
|
|
3007
3378
|
*/
|
|
3008
|
-
|
|
3379
|
+
Dt = function(e, {
|
|
3009
3380
|
local: t = !0,
|
|
3010
3381
|
throwIfInvalid: n = !0,
|
|
3011
3382
|
actionId: o
|
|
3012
3383
|
}) {
|
|
3013
|
-
assert(s(this,
|
|
3014
|
-
s(this,
|
|
3384
|
+
assert(s(this, ft) !== void 0, "Validator not initialized"), assert(
|
|
3385
|
+
s(this, S).locked,
|
|
3015
3386
|
"tried applying modification without lock"
|
|
3016
3387
|
);
|
|
3017
|
-
const
|
|
3018
|
-
if (
|
|
3388
|
+
const r = s(this, ft).validate(e);
|
|
3389
|
+
if (r !== void 0) {
|
|
3019
3390
|
if (n)
|
|
3020
|
-
throw new Error(`modification failed validation: ${
|
|
3021
|
-
return
|
|
3391
|
+
throw new Error(`modification failed validation: ${r}`);
|
|
3392
|
+
return r;
|
|
3022
3393
|
}
|
|
3023
3394
|
s(this, mt).applyModification(e), this.onModification.notify({ modification: e, local: t, actionId: o });
|
|
3024
3395
|
};
|
|
3025
|
-
|
|
3026
|
-
class NexusStateConsolidator {
|
|
3027
|
-
constructor(e) {
|
|
3028
|
-
/**
|
|
3029
|
-
* A copy of the document state, to validate that pending transactions can still be applied,
|
|
3030
|
-
* and drop them if not.
|
|
3031
|
-
*/
|
|
3032
|
-
p(this, I);
|
|
3033
|
-
/**
|
|
3034
|
-
* Transactions not yet confirmed or rejected by the remote.
|
|
3035
|
-
*
|
|
3036
|
-
* This is list contains `[forward, backward]` transactions, where `forward` are always the last transactions
|
|
3037
|
-
* applied to {@link #state}, while backwards contains their respective reverse, so the state
|
|
3038
|
-
* before all transactions in {@link #pending} can be restored.
|
|
3039
|
-
*/
|
|
3040
|
-
p(this, S, []);
|
|
3041
|
-
h(this, I, e);
|
|
3042
|
-
}
|
|
3043
|
-
/**
|
|
3044
|
-
* Consolidate the local and remote transaction history.
|
|
3045
|
-
*
|
|
3046
|
-
* @param newReceived Newly received transaction from the remote
|
|
3047
|
-
* @param newReceivedRejected Newly received transaction rejections from the remote. **must be a subset of previously created transactions**
|
|
3048
|
-
* @param newCreated Newly created transactions on the local document
|
|
3049
|
-
* @returns Transactions needed to sync local & remote, plus transactions created but not yet received
|
|
3050
|
-
*/
|
|
3051
|
-
consolidate(e, t, n) {
|
|
3052
|
-
n.forEach((d) => {
|
|
3053
|
-
const l = s(this, I).applyTransaction(d);
|
|
3054
|
-
if (!(l instanceof Transaction))
|
|
3055
|
-
throw new Error(`Error applying reverse transaction: ${l}`);
|
|
3056
|
-
s(this, S).push([d, l]);
|
|
3057
|
-
});
|
|
3058
|
-
let o = e[0], a = s(this, S)[0];
|
|
3059
|
-
for (; o !== void 0 && a !== void 0 && o.id === a[0].id; )
|
|
3060
|
-
e.shift(), s(this, S).shift(), o = e[0], a = s(this, S)[0];
|
|
3061
|
-
if (e.length === 0) {
|
|
3062
|
-
if (t.size === 0)
|
|
3063
|
-
return [];
|
|
3064
|
-
const d = s(this, S).findIndex(
|
|
3065
|
-
([f]) => t.has(f.id)
|
|
3066
|
-
);
|
|
3067
|
-
if (d === -1)
|
|
3068
|
-
throw new Error(
|
|
3069
|
-
"Invariant violation: expected to find rejected transaction in #pending, but didn't. This is a bug."
|
|
3070
|
-
);
|
|
3071
|
-
const l = s(this, S).splice(d), u = l.map(([, f]) => {
|
|
3072
|
-
if (!(s(this, I).applyTransaction(f) instanceof Transaction))
|
|
3073
|
-
throw new Error("error applying reversal of transaction");
|
|
3074
|
-
return f;
|
|
3075
|
-
}).reverse(), m = l.filter(([f]) => !t.has(f.id)).map(([f]) => {
|
|
3076
|
-
const y = s(this, I).applyTransaction(f);
|
|
3077
|
-
if (y instanceof Transaction)
|
|
3078
|
-
return [f, y];
|
|
3079
|
-
}).filter((f) => f !== void 0);
|
|
3080
|
-
return s(this, S).push(...m), [...u, ...m.map(([f]) => f)];
|
|
3081
|
-
}
|
|
3082
|
-
const c = s(this, S).map((d) => d[1].clone()).reverse();
|
|
3083
|
-
return c.forEach((d) => {
|
|
3084
|
-
const l = s(this, I).applyTransaction(d);
|
|
3085
|
-
if (!(l instanceof Transaction))
|
|
3086
|
-
throw new Error(`Error applying reverse transaction: ${l}`);
|
|
3087
|
-
}), e.forEach((d) => {
|
|
3088
|
-
const l = s(this, I).applyTransaction(d);
|
|
3089
|
-
if (!(l instanceof Transaction))
|
|
3090
|
-
throw new Error(`Error applying incoming transaction: ${l}`);
|
|
3091
|
-
}), h(this, S, s(this, S).filter(([d]) => {
|
|
3092
|
-
const l = t.has(d.id), u = e.some(
|
|
3093
|
-
(m) => m.id === d.id
|
|
3094
|
-
);
|
|
3095
|
-
return !l && !u;
|
|
3096
|
-
}).map(([d]) => {
|
|
3097
|
-
const l = s(this, I).applyTransaction(d);
|
|
3098
|
-
return l instanceof Transaction ? [d, l] : void 0;
|
|
3099
|
-
}).filter((d) => d !== void 0)), [
|
|
3100
|
-
...c,
|
|
3101
|
-
...e,
|
|
3102
|
-
...s(this, S).map(([d]) => d)
|
|
3103
|
-
];
|
|
3104
|
-
}
|
|
3105
|
-
}
|
|
3106
|
-
I = new WeakMap(), S = new WeakMap();
|
|
3107
|
-
var qt, jt, Rt, $t, Jt, Vt, bt, Ct, Lt;
|
|
3108
|
-
const wt = class wt {
|
|
3109
|
-
constructor({
|
|
3110
|
-
documentService: e,
|
|
3111
|
-
state: t,
|
|
3112
|
-
logOutgoingTransactions: n,
|
|
3113
|
-
logIncomingTransactions: o,
|
|
3114
|
-
logConsolidatedTransactions: a,
|
|
3115
|
-
logRejectedTransactions: c
|
|
3116
|
-
}) {
|
|
3117
|
-
p(this, qt);
|
|
3118
|
-
p(this, jt);
|
|
3119
|
-
p(this, Rt, !1);
|
|
3120
|
-
// = false due to ts complaining
|
|
3121
|
-
p(this, $t);
|
|
3122
|
-
// the connection to the backend, to send & receive transactions
|
|
3123
|
-
p(this, Jt);
|
|
3124
|
-
r(this, "blocked");
|
|
3125
|
-
p(this, Vt);
|
|
3126
|
-
p(this, bt, []);
|
|
3127
|
-
p(this, Ct, []);
|
|
3128
|
-
p(this, Lt, /* @__PURE__ */ new Set());
|
|
3129
|
-
h(this, Jt, e), h(this, Vt, new NexusStateConsolidator(t)), h(this, $t, a ?? !1), h(this, Rt, o ?? !1), h(this, jt, n ?? !1), h(this, qt, c ?? !1), (async () => {
|
|
3130
|
-
for (; ; ) {
|
|
3131
|
-
const l = await e.receiveNextTransaction();
|
|
3132
|
-
s(this, bt).push(l), wt.stats.numReceivedCtr++, s(this, Rt) && console.debug("CollabGateway: received transaction", l);
|
|
3133
|
-
}
|
|
3134
|
-
})();
|
|
3135
|
-
const d = new ValueNotifier(!1);
|
|
3136
|
-
s(this, Jt).connectionOk.subscribe((l) => {
|
|
3137
|
-
d.setValue(!l);
|
|
3138
|
-
}), this.blocked = d;
|
|
3139
|
-
}
|
|
3140
|
-
/** Send a transaction to the document service. */
|
|
3141
|
-
send(e) {
|
|
3142
|
-
e.id = crypto.randomUUID(), s(this, Ct).push(e.clone()), wt.stats.numQueuedCtr++, s(this, jt) && console.debug("CollabGateway: sending local transaction", e), s(this, Jt).sendNextTransaction(e).then((t) => {
|
|
3143
|
-
wt.stats.numConfirmedCtr++, t !== void 0 && (s(this, Lt).add(e.id), s(this, qt) && console.debug(
|
|
3144
|
-
"CollabGateway: received rejected transaction",
|
|
3145
|
-
e,
|
|
3146
|
-
t
|
|
3147
|
-
), wt.stats.numRejectedCtr++);
|
|
3148
|
-
});
|
|
3149
|
-
}
|
|
3150
|
-
/** Receive new transactions from the backend, already consolidated with the local change history.*/
|
|
3151
|
-
synchronize() {
|
|
3152
|
-
const e = s(this, bt).length > 0, t = s(this, Vt).consolidate(
|
|
3153
|
-
s(this, bt),
|
|
3154
|
-
s(this, Lt),
|
|
3155
|
-
s(this, Ct)
|
|
3156
|
-
);
|
|
3157
|
-
return s(this, bt).length = 0, s(this, Lt).clear(), s(this, Ct).length = 0, s(this, $t) && e && console.debug("CollabGateway: consolidated transactions", t), t;
|
|
3158
|
-
}
|
|
3159
|
-
};
|
|
3160
|
-
qt = new WeakMap(), jt = new WeakMap(), Rt = new WeakMap(), $t = new WeakMap(), Jt = new WeakMap(), Vt = new WeakMap(), bt = new WeakMap(), Ct = new WeakMap(), Lt = new WeakMap(), /**
|
|
3161
|
-
* Some stats, useful for debugging.
|
|
3162
|
-
*/
|
|
3163
|
-
r(wt, "stats", {
|
|
3164
|
-
numReceivedCtr: 0,
|
|
3165
|
-
numConfirmedCtr: 0,
|
|
3166
|
-
numQueuedCtr: 0,
|
|
3167
|
-
numRejectedCtr: 0
|
|
3168
|
-
});
|
|
3169
|
-
let CollabGateway = wt;
|
|
3170
|
-
const combinedValueNotifiersWithAnd = (...i) => {
|
|
3171
|
-
const e = new ValueNotifier(!0), t = () => e.setValue(i.every((n) => n.getValue()));
|
|
3172
|
-
return i.forEach((n) => n.subscribe(() => t())), t(), e;
|
|
3173
|
-
};
|
|
3174
|
-
var Ut;
|
|
3175
|
-
class BufferedSender {
|
|
3176
|
-
constructor(e, t = 100) {
|
|
3177
|
-
/** Contains data to be sent out during the next batched send. The second element resolves the promise
|
|
3178
|
-
* created in `send` for that data.
|
|
3179
|
-
*/
|
|
3180
|
-
p(this, Ut, []);
|
|
3181
|
-
(async () => {
|
|
3182
|
-
for (; ; ) {
|
|
3183
|
-
const n = s(this, Ut).splice(0, s(this, Ut).length);
|
|
3184
|
-
if (n.length === 0) {
|
|
3185
|
-
await sleep(t);
|
|
3186
|
-
continue;
|
|
3187
|
-
}
|
|
3188
|
-
const o = await e(n.map(([a]) => a));
|
|
3189
|
-
n.forEach(([, a], c) => {
|
|
3190
|
-
a(o[c]);
|
|
3191
|
-
});
|
|
3192
|
-
}
|
|
3193
|
-
})();
|
|
3194
|
-
}
|
|
3195
|
-
async send(e) {
|
|
3196
|
-
return new Promise((t) => {
|
|
3197
|
-
s(this, Ut).push([e, t]);
|
|
3198
|
-
});
|
|
3199
|
-
}
|
|
3200
|
-
}
|
|
3201
|
-
Ut = new WeakMap();
|
|
3202
|
-
const createPingNotifier = (i, e, t, n) => {
|
|
3203
|
-
const o = new ValueNotifier(0);
|
|
3204
|
-
return (async () => {
|
|
3205
|
-
for (; ; ) {
|
|
3206
|
-
const c = Date.now();
|
|
3207
|
-
await i.ping(
|
|
3208
|
-
{
|
|
3209
|
-
clientId: "undefined",
|
|
3210
|
-
projectName: e,
|
|
3211
|
-
lastPingMs: Math.floor(o.getValue())
|
|
3212
|
-
},
|
|
3213
|
-
{
|
|
3214
|
-
callIsOk: n
|
|
3215
|
-
}
|
|
3216
|
-
);
|
|
3217
|
-
const d = Date.now() - c;
|
|
3218
|
-
await sleep(Math.max(0, t - d)), o.setValue(d / 2);
|
|
3219
|
-
}
|
|
3220
|
-
})(), o;
|
|
3221
|
-
}, createReceiveNextTransactionFn = (i, e, t, n, o) => {
|
|
3222
|
-
let a = 0;
|
|
3223
|
-
const c = () => i.attach({ projectName: e, commitIndex: a }, { signal: o() })[Symbol.asyncIterator]();
|
|
3224
|
-
let d = c(), l = !1;
|
|
3225
|
-
return async () => {
|
|
3226
|
-
for (; ; )
|
|
3227
|
-
try {
|
|
3228
|
-
const { value: u, done: m } = await d.next();
|
|
3229
|
-
if (m ?? !1)
|
|
3230
|
-
throw new Error("document service attach stream closed");
|
|
3231
|
-
switch (t.setValue(!0), u.message.case) {
|
|
3232
|
-
case "noop": {
|
|
3233
|
-
if (l)
|
|
3234
|
-
continue;
|
|
3235
|
-
return l = !0, new Transaction();
|
|
3236
|
-
}
|
|
3237
|
-
case "transaction": {
|
|
3238
|
-
const f = u.message.value;
|
|
3239
|
-
return a = f.commitIndex, l = !0, f;
|
|
3240
|
-
}
|
|
3241
|
-
default:
|
|
3242
|
-
throw new Error(
|
|
3243
|
-
`received attach response with unknown message case: ${u.message.case}`
|
|
3244
|
-
);
|
|
3245
|
-
}
|
|
3246
|
-
} catch (u) {
|
|
3247
|
-
if (!(u instanceof ConnectError))
|
|
3248
|
-
throw u;
|
|
3249
|
-
switch (u.code) {
|
|
3250
|
-
case Code.Canceled:
|
|
3251
|
-
// happens if abort controller throws
|
|
3252
|
-
case Code.Aborted:
|
|
3253
|
-
case Code.Unavailable:
|
|
3254
|
-
case Code.Unknown: {
|
|
3255
|
-
t.setValue(!1), console.debug("Connection lost:", u.message, " - retrying..."), await sleep(n + Math.random() * n * 0.1), d = c();
|
|
3256
|
-
continue;
|
|
3257
|
-
}
|
|
3258
|
-
case Code.OutOfRange:
|
|
3259
|
-
throw new Error(
|
|
3260
|
-
"local document state too far in the past, must reload tab"
|
|
3261
|
-
);
|
|
3262
|
-
default:
|
|
3263
|
-
throw u;
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
};
|
|
3267
|
-
}, createDocumentServiceWrapper = ({
|
|
3268
|
-
projectName: i,
|
|
3269
|
-
pingIntervalMs: e,
|
|
3270
|
-
backoffMs: t = 1e3,
|
|
3271
|
-
documentService: n
|
|
3272
|
-
}) => {
|
|
3273
|
-
let o = new AbortController();
|
|
3274
|
-
const a = new ValueNotifier(!0);
|
|
3275
|
-
a.subscribe((w) => {
|
|
3276
|
-
w ? o = new AbortController() : o.abort("ping called failed, connection assumed lost");
|
|
3277
|
-
});
|
|
3278
|
-
let c;
|
|
3279
|
-
c = createPingNotifier(
|
|
3280
|
-
n,
|
|
3281
|
-
i,
|
|
3282
|
-
e,
|
|
3283
|
-
a
|
|
3284
|
-
);
|
|
3285
|
-
const d = new ValueNotifier(!0), l = createReceiveNextTransactionFn(
|
|
3286
|
-
n,
|
|
3287
|
-
i,
|
|
3288
|
-
d,
|
|
3289
|
-
t,
|
|
3290
|
-
() => o.signal
|
|
3291
|
-
), u = new ValueNotifier(!0), m = new BufferedSender(
|
|
3292
|
-
async (w) => {
|
|
3293
|
-
const b = await n.applyTransactions(
|
|
3294
|
-
{
|
|
3295
|
-
projectName: i,
|
|
3296
|
-
transactions: w
|
|
3297
|
-
},
|
|
3298
|
-
{
|
|
3299
|
-
callIsOk: u
|
|
3300
|
-
}
|
|
3301
|
-
);
|
|
3302
|
-
if (b instanceof Error)
|
|
3303
|
-
throw new Error("error sending transaction", { cause: b });
|
|
3304
|
-
return w.map(
|
|
3305
|
-
(N) => b.errors[N.id] ?? void 0
|
|
3306
|
-
);
|
|
3307
|
-
}
|
|
3308
|
-
), f = async (w) => await m.send(w), y = combinedValueNotifiersWithAnd(
|
|
3309
|
-
a,
|
|
3310
|
-
d,
|
|
3311
|
-
u
|
|
3312
|
-
);
|
|
3313
|
-
return {
|
|
3314
|
-
ping: c,
|
|
3315
|
-
connectionOk: y,
|
|
3316
|
-
receiveNextTransaction: l,
|
|
3317
|
-
sendNextTransaction: f
|
|
3318
|
-
};
|
|
3319
|
-
}, initCollabGateway = async (i, e) => {
|
|
3320
|
-
const t = createDocumentServiceWrapper({
|
|
3321
|
-
projectName: i,
|
|
3322
|
-
documentService: e,
|
|
3323
|
-
pingIntervalMs: 1e3
|
|
3324
|
-
}), n = await getWasmDocumentState();
|
|
3325
|
-
return new CollabGateway({
|
|
3326
|
-
documentService: t,
|
|
3327
|
-
state: n,
|
|
3328
|
-
logOutgoingTransactions: !1,
|
|
3329
|
-
logIncomingTransactions: !1,
|
|
3330
|
-
logConsolidatedTransactions: !1,
|
|
3331
|
-
logRejectedTransactions: !1
|
|
3332
|
-
});
|
|
3333
|
-
}, DocumentService = {
|
|
3396
|
+
const DocumentService = {
|
|
3334
3397
|
typeName: "audiotool.document.v1.DocumentService",
|
|
3335
3398
|
methods: {
|
|
3336
3399
|
/**
|
|
@@ -3503,7 +3566,7 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3503
3566
|
});
|
|
3504
3567
|
if (o instanceof Error)
|
|
3505
3568
|
throw new Error("Couldn't open session", { cause: o });
|
|
3506
|
-
const
|
|
3569
|
+
const r = createRetryingPromiseClient(
|
|
3507
3570
|
DocumentService,
|
|
3508
3571
|
createAuthorizedKeepaliveTransport({
|
|
3509
3572
|
baseUrl: ((u = o.session) == null ? void 0 : u.documentServiceUrl) ?? throw_("backend returned no document service url"),
|
|
@@ -3512,11 +3575,12 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3512
3575
|
})
|
|
3513
3576
|
);
|
|
3514
3577
|
await n;
|
|
3515
|
-
const c =
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3578
|
+
const c = createCollabGateway(
|
|
3579
|
+
r,
|
|
3580
|
+
await getWasmDocumentState(),
|
|
3581
|
+
e
|
|
3582
|
+
), l = new NexusDocument(), d = new ValueNotifier(!1);
|
|
3583
|
+
return c.blocked.subscribe((f) => d.setValue(!f)), createSyncedDocument(l, d, await n, c);
|
|
3520
3584
|
}, createOfflineDocument = async (i) => {
|
|
3521
3585
|
const e = i ? await createWasmNexusValidator() : mockNexusValidator(), t = mockNexusGateway(), n = new NexusDocument(), o = new ValueNotifier(!0);
|
|
3522
3586
|
return createSyncedDocument(n, o, e, t);
|
|
@@ -3526,31 +3590,29 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3526
3590
|
modify: (o) => i.modify(o),
|
|
3527
3591
|
queryEntities: i.queryEntitiesWithoutLock,
|
|
3528
3592
|
events: i.events,
|
|
3529
|
-
start: async () => i.takeTransactions({ validator: t, gateway: n })
|
|
3593
|
+
start: async () => i.takeTransactions({ validator: t, gateway: n }),
|
|
3594
|
+
stop: async () => i.terminate()
|
|
3530
3595
|
}), createAudiotoolClient = async ({
|
|
3531
3596
|
authorization: i
|
|
3532
3597
|
}) => {
|
|
3533
3598
|
const e = async () => {
|
|
3534
3599
|
if (typeof i == "string")
|
|
3535
3600
|
return addBearerPrefix(i);
|
|
3536
|
-
const
|
|
3537
|
-
if (
|
|
3601
|
+
const n = await i.getToken();
|
|
3602
|
+
if (n instanceof Error)
|
|
3538
3603
|
throw new Error("Failed to get authentication token", {
|
|
3539
|
-
cause:
|
|
3604
|
+
cause: n
|
|
3540
3605
|
});
|
|
3541
|
-
return addBearerPrefix(
|
|
3606
|
+
return addBearerPrefix(n);
|
|
3542
3607
|
}, t = await createAudiotoolAPI(e);
|
|
3543
|
-
let n = !1;
|
|
3544
3608
|
return {
|
|
3545
3609
|
api: t,
|
|
3546
|
-
createSyncedDocument: async (
|
|
3547
|
-
if (n)
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
const a = extractProjectName(o.project), c = await createOnlineDocument(t, a, e);
|
|
3551
|
-
return console.debug("Nexus connected."), c;
|
|
3610
|
+
createSyncedDocument: async (n) => {
|
|
3611
|
+
if (n.mode === "online") {
|
|
3612
|
+
const o = extractProjectName(n.project);
|
|
3613
|
+
return await createOnlineDocument(t, o, e);
|
|
3552
3614
|
} else
|
|
3553
|
-
return await createOfflineDocument(
|
|
3615
|
+
return await createOfflineDocument(n.validated);
|
|
3554
3616
|
}
|
|
3555
3617
|
};
|
|
3556
3618
|
}, extractProjectName = (i) => {
|
|
@@ -3572,17 +3634,17 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3572
3634
|
codeVerifier: `oidc_${i}_oidc_code_verifier`,
|
|
3573
3635
|
userName: `oidc_${i}_oidc_user_name`,
|
|
3574
3636
|
state: `oidc_${i}_oidc_state`
|
|
3575
|
-
}, o = () => redirectUserToLogin(n, i, t, e),
|
|
3637
|
+
}, o = () => redirectUserToLogin(n, i, t, e), r = new URLSearchParams(window.location.search), c = r.get("error"), l = r.get("error_description");
|
|
3576
3638
|
if (c != null)
|
|
3577
3639
|
return cleanupUrl(), cleanUpLocalStorage(n), {
|
|
3578
3640
|
loggedIn: !1,
|
|
3579
|
-
error: toError(c,
|
|
3641
|
+
error: toError(c, l),
|
|
3580
3642
|
login: o
|
|
3581
3643
|
};
|
|
3582
|
-
const
|
|
3583
|
-
if (
|
|
3584
|
-
const
|
|
3585
|
-
if (
|
|
3644
|
+
const d = r.get("code");
|
|
3645
|
+
if (d != null) {
|
|
3646
|
+
const m = r.get("state"), p = localStorage.getItem(n.state);
|
|
3647
|
+
if (m == null || p == null || m !== p)
|
|
3586
3648
|
return {
|
|
3587
3649
|
loggedIn: !1,
|
|
3588
3650
|
error: toError(
|
|
@@ -3591,14 +3653,14 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3591
3653
|
),
|
|
3592
3654
|
login: o
|
|
3593
3655
|
};
|
|
3594
|
-
const
|
|
3595
|
-
if (
|
|
3656
|
+
const w = localStorage.getItem(n.codeVerifier);
|
|
3657
|
+
if (w == null)
|
|
3596
3658
|
return {
|
|
3597
3659
|
loggedIn: !1,
|
|
3598
3660
|
error: toError("Code verifier not found. Restart the auth flow."),
|
|
3599
3661
|
login: o
|
|
3600
3662
|
};
|
|
3601
|
-
const
|
|
3663
|
+
const x = await fetch(TOKEN_ENDPOINT, {
|
|
3602
3664
|
method: "POST",
|
|
3603
3665
|
headers: {
|
|
3604
3666
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -3606,70 +3668,70 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3606
3668
|
body: new URLSearchParams({
|
|
3607
3669
|
client_id: i,
|
|
3608
3670
|
grant_type: "authorization_code",
|
|
3609
|
-
code:
|
|
3671
|
+
code: d,
|
|
3610
3672
|
redirect_uri: e,
|
|
3611
|
-
code_verifier:
|
|
3673
|
+
code_verifier: w,
|
|
3612
3674
|
token_endpoint_auth_method: "none"
|
|
3613
3675
|
})
|
|
3614
3676
|
}), {
|
|
3615
|
-
access_token:
|
|
3616
|
-
refresh_token:
|
|
3617
|
-
expires_in:
|
|
3618
|
-
error:
|
|
3619
|
-
error_description:
|
|
3620
|
-
} = await
|
|
3621
|
-
if (
|
|
3677
|
+
access_token: E,
|
|
3678
|
+
refresh_token: gt,
|
|
3679
|
+
expires_in: xt,
|
|
3680
|
+
error: Rt,
|
|
3681
|
+
error_description: Vt
|
|
3682
|
+
} = await x.json();
|
|
3683
|
+
if (Rt)
|
|
3622
3684
|
return {
|
|
3623
3685
|
loggedIn: !1,
|
|
3624
|
-
error: toError(
|
|
3686
|
+
error: toError(Rt, Vt),
|
|
3625
3687
|
login: o
|
|
3626
3688
|
};
|
|
3627
|
-
localStorage.setItem(n.accessToken,
|
|
3689
|
+
localStorage.setItem(n.accessToken, E), localStorage.setItem(n.refreshToken, gt), localStorage.setItem(
|
|
3628
3690
|
n.expiresAt,
|
|
3629
|
-
(Date.now() +
|
|
3691
|
+
(Date.now() + xt * 1e3).toString()
|
|
3630
3692
|
), cleanupUrl(), localStorage.removeItem(n.codeVerifier);
|
|
3631
3693
|
}
|
|
3632
3694
|
localStorage.removeItem(n.state);
|
|
3633
3695
|
const u = await getOrFetchValidToken(n, i);
|
|
3634
|
-
let
|
|
3696
|
+
let f;
|
|
3635
3697
|
if (typeof u == "string") {
|
|
3636
|
-
const
|
|
3637
|
-
if (
|
|
3638
|
-
|
|
3639
|
-
const
|
|
3640
|
-
return
|
|
3698
|
+
const m = async () => {
|
|
3699
|
+
if (f == null) {
|
|
3700
|
+
f = (async () => await getOrFetchValidToken(n, i) ?? new Error("User not logged in."))();
|
|
3701
|
+
const w = await f;
|
|
3702
|
+
return f = void 0, w;
|
|
3641
3703
|
}
|
|
3642
|
-
return await
|
|
3704
|
+
return await f;
|
|
3643
3705
|
};
|
|
3644
|
-
let
|
|
3706
|
+
let p;
|
|
3645
3707
|
return {
|
|
3646
3708
|
loggedIn: !0,
|
|
3647
|
-
getToken:
|
|
3709
|
+
getToken: m,
|
|
3648
3710
|
getUserName: async () => {
|
|
3649
|
-
if (
|
|
3650
|
-
return await
|
|
3651
|
-
const { promise:
|
|
3652
|
-
|
|
3653
|
-
const
|
|
3654
|
-
if (
|
|
3655
|
-
return
|
|
3656
|
-
const
|
|
3711
|
+
if (p !== void 0)
|
|
3712
|
+
return await p;
|
|
3713
|
+
const { promise: w, resolve: x } = Promise.withResolvers();
|
|
3714
|
+
p = w;
|
|
3715
|
+
const E = await m();
|
|
3716
|
+
if (E instanceof Error)
|
|
3717
|
+
return x(E), await p;
|
|
3718
|
+
const gt = await neverThrowingFetch(
|
|
3657
3719
|
`${API_ENDPOINT}/audiotool.auth.v1.AuthService/GetWhoami`,
|
|
3658
3720
|
{
|
|
3659
3721
|
method: "POST",
|
|
3660
3722
|
headers: {
|
|
3661
|
-
Authorization: `Bearer ${
|
|
3723
|
+
Authorization: `Bearer ${E}`,
|
|
3662
3724
|
"Content-Type": "application/json"
|
|
3663
3725
|
},
|
|
3664
3726
|
body: JSON.stringify({})
|
|
3665
3727
|
}
|
|
3666
3728
|
);
|
|
3667
|
-
if (
|
|
3668
|
-
return
|
|
3669
|
-
if (!
|
|
3670
|
-
return
|
|
3671
|
-
const { whoami:
|
|
3672
|
-
return console.debug("whoami",
|
|
3729
|
+
if (gt instanceof Error)
|
|
3730
|
+
return x(gt), await p;
|
|
3731
|
+
if (!gt.ok)
|
|
3732
|
+
return x(new Error(`Failed to get user info: ${gt.statusText}`)), await p;
|
|
3733
|
+
const { whoami: xt } = await gt.json();
|
|
3734
|
+
return console.debug("whoami", xt), x((xt == null ? void 0 : xt.userName) ?? "Unknown User"), await p;
|
|
3673
3735
|
},
|
|
3674
3736
|
logout() {
|
|
3675
3737
|
cleanUpLocalStorage(n), cleanupUrl(), window.location.reload();
|
|
@@ -3693,18 +3755,18 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3693
3755
|
}, redirectUserToLogin = async (i, e, t, n) => {
|
|
3694
3756
|
const o = generateCodeVerifier();
|
|
3695
3757
|
localStorage.setItem(i.codeVerifier, o);
|
|
3696
|
-
const
|
|
3758
|
+
const r = await generateCodeChallenge(o), c = crypto.getRandomValues(new Uint8Array(16)).join("");
|
|
3697
3759
|
localStorage.setItem(i.state, c);
|
|
3698
|
-
const
|
|
3699
|
-
|
|
3760
|
+
const l = new URL(AUTHORIZATION_ENDPOINT);
|
|
3761
|
+
l.search = new URLSearchParams({
|
|
3700
3762
|
response_type: "code",
|
|
3701
3763
|
client_id: e,
|
|
3702
3764
|
scope: t,
|
|
3703
3765
|
code_challenge_method: "S256",
|
|
3704
|
-
code_challenge:
|
|
3766
|
+
code_challenge: r,
|
|
3705
3767
|
redirect_uri: n,
|
|
3706
3768
|
state: c
|
|
3707
|
-
}).toString(), window.location.href =
|
|
3769
|
+
}).toString(), window.location.href = l.toString();
|
|
3708
3770
|
}, toError = (i, e) => (e = e ? `: ${e}` : "", new Error(`${i}${e}`)), generateCodeVerifier = () => {
|
|
3709
3771
|
const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
3710
3772
|
return crypto.getRandomValues(new Uint8Array(64)).reduce(
|
|
@@ -3720,8 +3782,8 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3720
3782
|
return;
|
|
3721
3783
|
let n = !0;
|
|
3722
3784
|
{
|
|
3723
|
-
const
|
|
3724
|
-
n =
|
|
3785
|
+
const m = localStorage.getItem(i.expiresAt);
|
|
3786
|
+
n = m == null ? !0 : Date.now() >= parseInt(m) - 6e4;
|
|
3725
3787
|
}
|
|
3726
3788
|
if (!n)
|
|
3727
3789
|
return t;
|
|
@@ -3730,7 +3792,7 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3730
3792
|
cleanUpLocalStorage(i);
|
|
3731
3793
|
return;
|
|
3732
3794
|
}
|
|
3733
|
-
const
|
|
3795
|
+
const r = await neverThrowingFetch(TOKEN_ENDPOINT, {
|
|
3734
3796
|
method: "POST",
|
|
3735
3797
|
headers: {
|
|
3736
3798
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -3741,15 +3803,15 @@ const createPingNotifier = (i, e, t, n) => {
|
|
|
3741
3803
|
refresh_token: o
|
|
3742
3804
|
})
|
|
3743
3805
|
});
|
|
3744
|
-
if (
|
|
3745
|
-
return new Error(`Error during refresh token request: ${
|
|
3746
|
-
cause:
|
|
3806
|
+
if (r instanceof Error)
|
|
3807
|
+
return new Error(`Error during refresh token request: ${r.name}`, {
|
|
3808
|
+
cause: r.message
|
|
3747
3809
|
});
|
|
3748
|
-
const { error: c, error_description:
|
|
3749
|
-
return c ? toError(c,
|
|
3810
|
+
const { error: c, error_description: l, access_token: d, refresh_token: u, expires_in: f } = await r.json();
|
|
3811
|
+
return c ? toError(c, l) : (localStorage.setItem(i.accessToken, d), localStorage.setItem(i.refreshToken, u), localStorage.setItem(
|
|
3750
3812
|
i.expiresAt,
|
|
3751
|
-
(Date.now() +
|
|
3752
|
-
),
|
|
3813
|
+
(Date.now() + f * 1e3).toString()
|
|
3814
|
+
), d);
|
|
3753
3815
|
};
|
|
3754
3816
|
export {
|
|
3755
3817
|
createAudiotoolClient,
|