@dxos/client-services 0.8.4-main.e8ec1fe → 0.8.4-main.ef1bc66f44
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/lib/browser/chunk-NQSC7HOE.mjs +22 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CZSLDMSL.mjs → chunk-NTZOEM4P.mjs} +1197 -1338
- package/dist/lib/browser/chunk-NTZOEM4P.mjs.map +7 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +441 -66
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/browser.mjs +126 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +66 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +24 -12
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-EUNILIU5.mjs → chunk-DQWA5ILA.mjs} +689 -699
- package/dist/lib/node-esm/chunk-DQWA5ILA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs +22 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +441 -66
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs +126 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +66 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +24 -12
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/packlets/devtools/devtools.d.ts +2 -2
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +2 -2
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +4 -4
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +2 -3
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -2
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/index.d.ts +1 -1
- package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +4 -0
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/feed-syncer.d.ts +41 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +13 -7
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +19 -5
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -5
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +2 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -6
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +6 -3
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +6 -5
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +31 -4
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-session.d.ts +2 -2
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +70 -48
- package/src/packlets/devtools/devtools.ts +2 -2
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.ts +2 -2
- package/src/packlets/identity/default-space-state-machine.ts +2 -2
- package/src/packlets/identity/identity-manager.ts +6 -6
- package/src/packlets/identity/identity-recovery-manager.ts +2 -2
- package/src/packlets/identity/identity.ts +2 -2
- package/src/packlets/invitations/device-invitation-protocol.ts +5 -5
- package/src/packlets/invitations/invitation-guest-extenstion.ts +6 -4
- package/src/packlets/invitations/invitation-host-extension.ts +6 -4
- package/src/packlets/invitations/invitation-protocol.ts +2 -3
- package/src/packlets/invitations/invitations-handler.ts +7 -7
- package/src/packlets/invitations/space-invitation-protocol.ts +7 -13
- package/src/packlets/locks/index.ts +1 -1
- package/src/packlets/logging/logging-service.ts +4 -0
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/feed-syncer.ts +227 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.ts +47 -21
- package/src/packlets/services/service-host.ts +56 -16
- package/src/packlets/space-export/space-archive-reader.ts +1 -1
- package/src/packlets/space-export/space-archive-writer.ts +3 -2
- package/src/packlets/spaces/data-space-manager.ts +43 -20
- package/src/packlets/spaces/data-space.ts +10 -6
- package/src/packlets/spaces/edge-feed-replicator.ts +2 -2
- package/src/packlets/spaces/epoch-migrations.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.ts +8 -8
- package/src/packlets/spaces/spaces-service.ts +10 -7
- package/src/packlets/storage/storage.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +7 -4
- package/src/packlets/testing/test-builder.ts +36 -10
- package/src/packlets/worker/worker-runtime.ts +149 -11
- package/src/packlets/worker/worker-session.ts +4 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-CZSLDMSL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EUNILIU5.mjs.map +0 -7
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Reactivity from '@effect/experimental/Reactivity';
|
|
6
|
+
import type * as SqlClient from '@effect/sql/SqlClient';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
9
|
+
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
10
|
+
|
|
5
11
|
import { Trigger } from '@dxos/async';
|
|
6
12
|
import { DEFAULT_WORKER_BROADCAST_CHANNEL } from '@dxos/client-protocol';
|
|
7
13
|
import { type Config } from '@dxos/config';
|
|
@@ -16,6 +22,10 @@ import {
|
|
|
16
22
|
} from '@dxos/messaging';
|
|
17
23
|
import { RtcTransportProxyFactory } from '@dxos/network-manager';
|
|
18
24
|
import { type RpcPort } from '@dxos/rpc';
|
|
25
|
+
import * as OpfsWorker from '@dxos/sql-sqlite/OpfsWorker';
|
|
26
|
+
import * as SqlExport from '@dxos/sql-sqlite/SqlExport';
|
|
27
|
+
import * as SqliteClient from '@dxos/sql-sqlite/SqliteClient';
|
|
28
|
+
import * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
19
29
|
import { type MaybePromise } from '@dxos/util';
|
|
20
30
|
|
|
21
31
|
import { ClientServicesHost } from '../services';
|
|
@@ -23,10 +33,11 @@ import { ClientServicesHost } from '../services';
|
|
|
23
33
|
import { WorkerSession } from './worker-session';
|
|
24
34
|
|
|
25
35
|
// NOTE: Keep as RpcPorts to avoid dependency on @dxos/rpc-tunnel so we don't depend on browser-specific apis.
|
|
26
|
-
export type
|
|
36
|
+
export type CreateSessionProps = {
|
|
27
37
|
appPort: RpcPort;
|
|
28
38
|
systemPort: RpcPort;
|
|
29
39
|
shellPort?: RpcPort;
|
|
40
|
+
onClose?: () => Promise<void>;
|
|
30
41
|
};
|
|
31
42
|
|
|
32
43
|
export type WorkerRuntimeOptions = {
|
|
@@ -35,10 +46,20 @@ export type WorkerRuntimeOptions = {
|
|
|
35
46
|
acquireLock: () => Promise<void>;
|
|
36
47
|
releaseLock: () => void;
|
|
37
48
|
onStop?: () => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
automaticallyConnectWebrtc?: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Optional SQLite layer for Effect. Defaults to LocalSqliteOpfsLayer.
|
|
56
|
+
* For testing in Node.js, use `sqliteLayerMemory` from `@dxos/sql-sqlite/platform`.
|
|
57
|
+
*/
|
|
58
|
+
sqliteLayer?: Layer.Layer<SqlClient.SqlClient | SqlExport.SqlExport, unknown>;
|
|
38
59
|
};
|
|
39
60
|
|
|
40
61
|
/**
|
|
41
|
-
* Runtime for the shared worker.
|
|
62
|
+
* Runtime for the shared and dedciated worker.
|
|
42
63
|
* Manages connections from proxies (in tabs).
|
|
43
64
|
* Tabs make requests to the `ClientServicesHost`, and provide a WebRTC gateway.
|
|
44
65
|
*/
|
|
@@ -52,11 +73,17 @@ export class WorkerRuntime {
|
|
|
52
73
|
private readonly _sessions = new Set<WorkerSession>();
|
|
53
74
|
private readonly _clientServices!: ClientServicesHost;
|
|
54
75
|
private readonly _channel: string;
|
|
76
|
+
private readonly _automaticallyConnectWebrtc: boolean;
|
|
77
|
+
private readonly _livenessLock = new WebLockWrapper(`@dxos/client-services/WorkerRuntime/${crypto.randomUUID()}`);
|
|
55
78
|
private _broadcastChannel?: BroadcastChannel;
|
|
56
79
|
private _sessionForNetworking?: WorkerSession; // TODO(burdon): Expose to client QueryStatusResponse.
|
|
57
80
|
private _config!: Config;
|
|
58
81
|
private _signalMetadataTags: any = { runtime: 'worker-runtime' };
|
|
59
82
|
private _signalTelemetryEnabled: boolean = false;
|
|
83
|
+
private _runtime!: ManagedRuntime.ManagedRuntime<
|
|
84
|
+
SqlTransaction.SqlTransaction | SqlClient.SqlClient | SqlExport.SqlExport,
|
|
85
|
+
never
|
|
86
|
+
>;
|
|
60
87
|
|
|
61
88
|
constructor({
|
|
62
89
|
channel = DEFAULT_WORKER_BROADCAST_CHANNEL,
|
|
@@ -64,26 +91,49 @@ export class WorkerRuntime {
|
|
|
64
91
|
acquireLock,
|
|
65
92
|
releaseLock,
|
|
66
93
|
onStop,
|
|
94
|
+
automaticallyConnectWebrtc = true,
|
|
95
|
+
sqliteLayer,
|
|
67
96
|
}: WorkerRuntimeOptions) {
|
|
68
97
|
this._configProvider = configProvider;
|
|
69
98
|
this._acquireLock = acquireLock;
|
|
70
99
|
this._releaseLock = releaseLock;
|
|
71
100
|
this._onStop = onStop;
|
|
72
101
|
this._channel = channel;
|
|
102
|
+
if (sqliteLayer) {
|
|
103
|
+
log.warn('Using testing SQLite layer');
|
|
104
|
+
}
|
|
105
|
+
this._runtime = ManagedRuntime.make(
|
|
106
|
+
SqlTransaction.layer
|
|
107
|
+
.pipe(Layer.provideMerge(sqliteLayer ?? LocalSqliteOpfsLayer), Layer.provideMerge(Reactivity.layer))
|
|
108
|
+
.pipe(Layer.orDie),
|
|
109
|
+
);
|
|
73
110
|
this._clientServices = new ClientServicesHost({
|
|
74
111
|
callbacks: {
|
|
75
112
|
onReset: async () => this.stop(),
|
|
76
113
|
},
|
|
114
|
+
runtime: this._runtime.runtimeEffect,
|
|
115
|
+
runtimeProps: {
|
|
116
|
+
// Auto-activate spaces that were previously active after leader changeover.
|
|
117
|
+
autoActivateSpaces: true,
|
|
118
|
+
},
|
|
77
119
|
});
|
|
120
|
+
this._automaticallyConnectWebrtc = automaticallyConnectWebrtc;
|
|
78
121
|
}
|
|
79
122
|
|
|
80
123
|
get host() {
|
|
81
124
|
return this._clientServices;
|
|
82
125
|
}
|
|
83
126
|
|
|
127
|
+
get livenessLockKey(): string {
|
|
128
|
+
return this._livenessLock.key;
|
|
129
|
+
}
|
|
130
|
+
|
|
84
131
|
async start(): Promise<void> {
|
|
85
132
|
log('starting...');
|
|
86
133
|
try {
|
|
134
|
+
void this._livenessLock.acquire();
|
|
135
|
+
|
|
136
|
+
// Steal the lock from the other worker.
|
|
87
137
|
this._broadcastChannel = new BroadcastChannel(this._channel);
|
|
88
138
|
this._broadcastChannel.postMessage({ action: 'stop' });
|
|
89
139
|
this._broadcastChannel.onmessage = async (event) => {
|
|
@@ -127,13 +177,15 @@ export class WorkerRuntime {
|
|
|
127
177
|
this._broadcastChannel?.close();
|
|
128
178
|
this._broadcastChannel = undefined;
|
|
129
179
|
await this._clientServices.close();
|
|
180
|
+
await this._runtime.dispose();
|
|
130
181
|
await this._onStop?.();
|
|
182
|
+
await this._livenessLock.release();
|
|
131
183
|
}
|
|
132
184
|
|
|
133
185
|
/**
|
|
134
186
|
* Create a new session.
|
|
135
187
|
*/
|
|
136
|
-
async createSession({ appPort, systemPort, shellPort }:
|
|
188
|
+
async createSession({ appPort, systemPort, shellPort, onClose }: CreateSessionProps): Promise<WorkerSession> {
|
|
137
189
|
const session = new WorkerSession({
|
|
138
190
|
serviceHost: this._clientServices,
|
|
139
191
|
appPort,
|
|
@@ -149,8 +201,11 @@ export class WorkerRuntime {
|
|
|
149
201
|
// Terminate the worker when all sessions are closed.
|
|
150
202
|
await this.stop();
|
|
151
203
|
} else {
|
|
152
|
-
this.
|
|
204
|
+
if (this._automaticallyConnectWebrtc) {
|
|
205
|
+
this._reconnectWebrtc();
|
|
206
|
+
}
|
|
153
207
|
}
|
|
208
|
+
await onClose?.();
|
|
154
209
|
});
|
|
155
210
|
|
|
156
211
|
await session.open();
|
|
@@ -166,7 +221,24 @@ export class WorkerRuntime {
|
|
|
166
221
|
this._signalMetadataTags.origin = session.origin;
|
|
167
222
|
this._sessions.add(session);
|
|
168
223
|
|
|
169
|
-
this.
|
|
224
|
+
if (this._automaticallyConnectWebrtc) {
|
|
225
|
+
this._reconnectWebrtc();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return session;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Connects the WebRTC bridge to the specified session.
|
|
233
|
+
* If no session is provided, disconnects the WebRTC bridge.
|
|
234
|
+
*
|
|
235
|
+
* Called automatically if `automaticallyConnectWebrtc` is true.
|
|
236
|
+
*
|
|
237
|
+
* @param session The session to connect the WebRTC bridge to.
|
|
238
|
+
*/
|
|
239
|
+
connectWebrtcBridge(session: WorkerSession | undefined): void {
|
|
240
|
+
this._sessionForNetworking = session;
|
|
241
|
+
this._transportFactory.setBridgeService(session?.bridgeService);
|
|
170
242
|
}
|
|
171
243
|
|
|
172
244
|
/**
|
|
@@ -184,12 +256,78 @@ export class WorkerRuntime {
|
|
|
184
256
|
// Select existing session.
|
|
185
257
|
if (!this._sessionForNetworking) {
|
|
186
258
|
const selected = Array.from(this._sessions).find((session) => session.bridgeService);
|
|
187
|
-
|
|
188
|
-
this._sessionForNetworking = selected;
|
|
189
|
-
this._transportFactory.setBridgeService(selected.bridgeService);
|
|
190
|
-
} else {
|
|
191
|
-
this._transportFactory.setBridgeService(undefined);
|
|
192
|
-
}
|
|
259
|
+
this.connectWebrtcBridge(selected);
|
|
193
260
|
}
|
|
194
261
|
}
|
|
195
262
|
}
|
|
263
|
+
|
|
264
|
+
const DB_NAME = 'DXOS';
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* SqlExport layer that wraps SqliteClient to provide export functionality.
|
|
268
|
+
*/
|
|
269
|
+
const SqlExportLayer: Layer.Layer<SqlExport.SqlExport, never, SqliteClient.SqliteClient> = Layer.effect(
|
|
270
|
+
SqlExport.SqlExport,
|
|
271
|
+
Effect.gen(function* () {
|
|
272
|
+
const sql = yield* SqliteClient.SqliteClient;
|
|
273
|
+
return {
|
|
274
|
+
export: sql.export,
|
|
275
|
+
} satisfies SqlExport.Service;
|
|
276
|
+
}),
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Local SQLite layer for the worker.
|
|
281
|
+
* Uses OPFS sync API as an FS backend.
|
|
282
|
+
* Does NOT spawn a new worker.
|
|
283
|
+
* NOTE: Only usable within a worker.
|
|
284
|
+
* TODO(mykola): This does not work right now. Fix.
|
|
285
|
+
*/
|
|
286
|
+
const LocalSqliteOpfsLayer = Layer.unwrapScoped(
|
|
287
|
+
Effect.gen(function* () {
|
|
288
|
+
const { port1: clientPort, port2: serverPort } = new MessageChannel();
|
|
289
|
+
clientPort.start();
|
|
290
|
+
serverPort.start();
|
|
291
|
+
yield* Effect.addFinalizer(() =>
|
|
292
|
+
Effect.sync(() => {
|
|
293
|
+
clientPort.close();
|
|
294
|
+
serverPort.close();
|
|
295
|
+
}),
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
yield* Effect.forkScoped(OpfsWorker.run({ port: serverPort, dbName: DB_NAME }));
|
|
299
|
+
return SqlExportLayer.pipe(Layer.provideMerge(SqliteClient.layer({ worker: Effect.succeed(clientPort) })));
|
|
300
|
+
}),
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
// TODO(wittjosiah): Factor out to a separate module.
|
|
304
|
+
class WebLockWrapper {
|
|
305
|
+
readonly #key: string;
|
|
306
|
+
#release?: () => void;
|
|
307
|
+
|
|
308
|
+
constructor(key: string) {
|
|
309
|
+
this.#key = key;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
get key(): string {
|
|
313
|
+
return this.#key;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
acquire(options: LockOptions = {}) {
|
|
317
|
+
return navigator.locks.request(this.#key, options, async () => {
|
|
318
|
+
await new Promise<void>((resolve) => {
|
|
319
|
+
this.#release = resolve;
|
|
320
|
+
}); // Blocks for the duration of the worker's lifetime.
|
|
321
|
+
this.#release = undefined;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
release() {
|
|
326
|
+
this.#release?.();
|
|
327
|
+
this.#release = undefined;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
[Symbol.dispose]() {
|
|
331
|
+
this.release();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -15,9 +15,9 @@ import { type BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
|
15
15
|
import { type ProtoRpcPeer, type RpcPort, createProtoRpcPeer } from '@dxos/rpc';
|
|
16
16
|
import { Callback, type MaybePromise } from '@dxos/util';
|
|
17
17
|
|
|
18
|
-
import { ClientRpcServer, type
|
|
18
|
+
import { ClientRpcServer, type ClientRpcServerProps, type ClientServicesHost } from '../services';
|
|
19
19
|
|
|
20
|
-
export type
|
|
20
|
+
export type WorkerSessionProps = {
|
|
21
21
|
serviceHost: ClientServicesHost;
|
|
22
22
|
systemPort: RpcPort;
|
|
23
23
|
appPort: RpcPort;
|
|
@@ -50,11 +50,11 @@ export class WorkerSession {
|
|
|
50
50
|
|
|
51
51
|
public bridgeService?: BridgeService;
|
|
52
52
|
|
|
53
|
-
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }:
|
|
53
|
+
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }: WorkerSessionProps) {
|
|
54
54
|
invariant(serviceHost);
|
|
55
55
|
this._serviceHost = serviceHost;
|
|
56
56
|
|
|
57
|
-
const middleware: Pick<
|
|
57
|
+
const middleware: Pick<ClientRpcServerProps, 'handleCall' | 'handleStream'> = {
|
|
58
58
|
handleCall: async (method, params, handler) => {
|
|
59
59
|
const error = await readySignal.wait({ timeout: PROXY_CONNECTION_TIMEOUT });
|
|
60
60
|
if (error) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DXOS_VERSION = "0.8.4-main.
|
|
1
|
+
export const DXOS_VERSION = "0.8.4-main.ef1bc66f44";
|