@dxos/client-services 0.5.8 → 0.5.9-main.079a532
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-JECXTGZA.mjs → chunk-QZ5LNV55.mjs} +1781 -1480
- package/dist/lib/browser/chunk-QZ5LNV55.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +55 -365
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +14 -14
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-OR7LRWDY.cjs → chunk-V7UMWFUS.cjs} +2055 -1761
- package/dist/lib/node/chunk-V7UMWFUS.cjs.map +7 -0
- package/dist/lib/node/index.cjs +92 -397
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +19 -19
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +4 -4
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +19 -0
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-service.d.ts +14 -7
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +4 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +2 -2
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +4 -5
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +4 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +11 -9
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +23 -0
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +11 -9
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/index.d.ts +3 -0
- package/dist/types/src/packlets/worker/index.d.ts.map +1 -0
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -0
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -0
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +36 -36
- package/src/index.ts +3 -3
- package/src/packlets/devtools/network.ts +4 -4
- package/src/packlets/identity/default-space-state-machine.ts +44 -0
- package/src/packlets/identity/identity-manager.test.ts +2 -2
- package/src/packlets/identity/identity-service.test.ts +35 -5
- package/src/packlets/identity/identity-service.ts +55 -8
- package/src/packlets/identity/identity.test.ts +8 -4
- package/src/packlets/identity/identity.ts +25 -2
- package/src/packlets/invitations/invitations-handler.ts +2 -2
- package/src/packlets/network/network-service.ts +2 -2
- package/src/packlets/services/service-context.ts +4 -7
- package/src/packlets/services/service-host.ts +16 -44
- package/src/packlets/spaces/automerge-space-state.ts +11 -2
- package/src/packlets/spaces/data-space-manager.test.ts +46 -1
- package/src/packlets/spaces/data-space-manager.ts +81 -31
- package/src/packlets/spaces/data-space.ts +89 -132
- package/src/packlets/spaces/epoch-migrations.ts +135 -0
- package/src/packlets/spaces/spaces-service.ts +5 -2
- package/src/packlets/testing/test-builder.ts +16 -14
- package/src/packlets/worker/index.ts +6 -0
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-JECXTGZA.mjs.map +0 -7
- package/dist/lib/node/chunk-OR7LRWDY.cjs.map +0 -7
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +0 -37
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/index.d.ts +0 -6
- package/dist/types/src/packlets/vault/index.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +0 -36
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +0 -33
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +0 -1
- package/src/packlets/vault/iframe-host-runtime.ts +0 -130
- package/src/packlets/vault/index.ts +0 -9
- package/src/packlets/vault/shared-worker-connection.ts +0 -115
- package/src/packlets/vault/shell-runtime.ts +0 -111
- /package/dist/types/src/packlets/{vault → worker}/worker-runtime.d.ts +0 -0
- /package/dist/types/src/packlets/{vault → worker}/worker-session.d.ts +0 -0
- /package/src/packlets/{vault → worker}/worker-runtime.ts +0 -0
- /package/src/packlets/{vault → worker}/worker-session.ts +0 -0
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
createDiagnostics,
|
|
29
29
|
createLevel,
|
|
30
30
|
createStorageObjects,
|
|
31
|
-
findPropertiesObject,
|
|
32
31
|
getNetworkPeers,
|
|
33
32
|
isLocked,
|
|
34
33
|
subscribeToFeedBlocks,
|
|
@@ -38,329 +37,24 @@ import {
|
|
|
38
37
|
subscribeToSignal,
|
|
39
38
|
subscribeToSpaces,
|
|
40
39
|
subscribeToSwarmInfo
|
|
41
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-QZ5LNV55.mjs";
|
|
42
41
|
|
|
43
|
-
// packages/sdk/client-services/src/packlets/
|
|
44
|
-
import { Trigger } from "@dxos/async";
|
|
45
|
-
import { PROXY_CONNECTION_TIMEOUT } from "@dxos/client-protocol";
|
|
46
|
-
import { Context } from "@dxos/context";
|
|
47
|
-
import { log, logInfo } from "@dxos/log";
|
|
48
|
-
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from "@dxos/messaging";
|
|
49
|
-
import { createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
50
|
-
import { getAsyncValue } from "@dxos/util";
|
|
51
|
-
|
|
52
|
-
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
53
|
-
import { Event } from "@dxos/async";
|
|
54
|
-
import { appServiceBundle, shellServiceBundle } from "@dxos/client-protocol";
|
|
55
|
-
import { invariant } from "@dxos/invariant";
|
|
56
|
-
import { ShellLayout } from "@dxos/protocols/proto/dxos/iframe";
|
|
57
|
-
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
58
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shell-runtime.ts";
|
|
59
|
-
var ShellRuntimeImpl = class {
|
|
60
|
-
constructor(_port) {
|
|
61
|
-
this._port = _port;
|
|
62
|
-
this.layoutUpdate = new Event();
|
|
63
|
-
this.invitationUrlUpdate = new Event();
|
|
64
|
-
this._layout = ShellLayout.DEFAULT;
|
|
65
|
-
this._invitationUrl = typeof window !== "undefined" ? window.location.origin : void 0;
|
|
66
|
-
this._deviceInvitationParam = "deviceInvitationCode";
|
|
67
|
-
this._spaceInvitationParam = "spaceInvitationCode";
|
|
68
|
-
}
|
|
69
|
-
get layout() {
|
|
70
|
-
return this._layout;
|
|
71
|
-
}
|
|
72
|
-
get invitationCode() {
|
|
73
|
-
return this._invitationCode;
|
|
74
|
-
}
|
|
75
|
-
get spaceKey() {
|
|
76
|
-
return this._spaceKey;
|
|
77
|
-
}
|
|
78
|
-
get invitationUrl() {
|
|
79
|
-
return this._invitationUrl;
|
|
80
|
-
}
|
|
81
|
-
get deviceInvitationParam() {
|
|
82
|
-
return this._deviceInvitationParam;
|
|
83
|
-
}
|
|
84
|
-
get spaceInvitationParam() {
|
|
85
|
-
return this._spaceInvitationParam;
|
|
86
|
-
}
|
|
87
|
-
setLayout({ layout, invitationCode, spaceKey }) {
|
|
88
|
-
this._layout = layout;
|
|
89
|
-
this._invitationCode = invitationCode;
|
|
90
|
-
this._spaceKey = spaceKey;
|
|
91
|
-
this.layoutUpdate.emit({
|
|
92
|
-
layout,
|
|
93
|
-
invitationCode,
|
|
94
|
-
spaceKey
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
setInvitationUrl({ invitationUrl, deviceInvitationParam, spaceInvitationParam }) {
|
|
98
|
-
this._invitationUrl = invitationUrl;
|
|
99
|
-
this._deviceInvitationParam = deviceInvitationParam;
|
|
100
|
-
this._spaceInvitationParam = spaceInvitationParam;
|
|
101
|
-
this.invitationUrlUpdate.emit({
|
|
102
|
-
invitationUrl,
|
|
103
|
-
deviceInvitationParam,
|
|
104
|
-
spaceInvitationParam
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
async setAppContext(context) {
|
|
108
|
-
invariant(this._appRpc, "runtime not open", {
|
|
109
|
-
F: __dxlog_file,
|
|
110
|
-
L: 76,
|
|
111
|
-
S: this,
|
|
112
|
-
A: [
|
|
113
|
-
"this._appRpc",
|
|
114
|
-
"'runtime not open'"
|
|
115
|
-
]
|
|
116
|
-
});
|
|
117
|
-
await this._appRpc.rpc.AppService.setContext(context);
|
|
118
|
-
}
|
|
119
|
-
async open() {
|
|
120
|
-
this._appRpc = createProtoRpcPeer({
|
|
121
|
-
requested: appServiceBundle,
|
|
122
|
-
exposed: shellServiceBundle,
|
|
123
|
-
handlers: {
|
|
124
|
-
ShellService: {
|
|
125
|
-
setLayout: async (request) => {
|
|
126
|
-
this._layout = request.layout;
|
|
127
|
-
this._invitationCode = request.invitationCode;
|
|
128
|
-
this._spaceKey = request.spaceKey;
|
|
129
|
-
this.layoutUpdate.emit(request);
|
|
130
|
-
},
|
|
131
|
-
setInvitationUrl: async (request) => {
|
|
132
|
-
this._invitationUrl = request.invitationUrl;
|
|
133
|
-
this._deviceInvitationParam = request.deviceInvitationParam;
|
|
134
|
-
this._spaceInvitationParam = request.spaceInvitationParam;
|
|
135
|
-
this.invitationUrlUpdate.emit(request);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
port: this._port
|
|
140
|
-
});
|
|
141
|
-
await this._appRpc.open();
|
|
142
|
-
}
|
|
143
|
-
async close() {
|
|
144
|
-
await this._appRpc?.close();
|
|
145
|
-
this._appRpc = void 0;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
150
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
151
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
152
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
153
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
154
|
-
else
|
|
155
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
156
|
-
if (d = decorators[i])
|
|
157
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
158
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
159
|
-
}
|
|
160
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
|
|
161
|
-
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
162
|
-
var IFrameHostRuntime = class {
|
|
163
|
-
constructor({ config, origin, appPort, shellPort }) {
|
|
164
|
-
this._ready = new Trigger();
|
|
165
|
-
this._configProvider = config;
|
|
166
|
-
this.origin = origin;
|
|
167
|
-
this._appPort = appPort;
|
|
168
|
-
this._shellPort = shellPort;
|
|
169
|
-
if (this._shellPort) {
|
|
170
|
-
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
get services() {
|
|
174
|
-
return this._clientServices;
|
|
175
|
-
}
|
|
176
|
-
get shell() {
|
|
177
|
-
return this._shellRuntime;
|
|
178
|
-
}
|
|
179
|
-
async start() {
|
|
180
|
-
log("starting...", void 0, {
|
|
181
|
-
F: __dxlog_file2,
|
|
182
|
-
L: 73,
|
|
183
|
-
S: this,
|
|
184
|
-
C: (f, a) => f(...a)
|
|
185
|
-
});
|
|
186
|
-
try {
|
|
187
|
-
this._config = await getAsyncValue(this._configProvider);
|
|
188
|
-
this._transportFactory = createSimplePeerTransportFactory({
|
|
189
|
-
iceServers: this._config.get("runtime.services.ice")
|
|
190
|
-
});
|
|
191
|
-
const signals = this._config.get("runtime.services.signaling");
|
|
192
|
-
this._clientServices = new ClientServicesHost({
|
|
193
|
-
lockKey: LOCK_KEY,
|
|
194
|
-
config: this._config,
|
|
195
|
-
signalManager: signals ? new WebsocketSignalManager(signals) : new MemorySignalManager(new MemorySignalManagerContext()),
|
|
196
|
-
transportFactory: this._transportFactory
|
|
197
|
-
});
|
|
198
|
-
const middleware = {
|
|
199
|
-
handleCall: async (method, params, handler) => {
|
|
200
|
-
const error = await this._ready.wait({
|
|
201
|
-
timeout: PROXY_CONNECTION_TIMEOUT
|
|
202
|
-
});
|
|
203
|
-
if (error) {
|
|
204
|
-
throw error;
|
|
205
|
-
}
|
|
206
|
-
return handler(method, params);
|
|
207
|
-
},
|
|
208
|
-
handleStream: async (method, params, handler) => {
|
|
209
|
-
const error = await this._ready.wait({
|
|
210
|
-
timeout: PROXY_CONNECTION_TIMEOUT
|
|
211
|
-
});
|
|
212
|
-
if (error) {
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
return handler(method, params);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
this._clientRpc = new ClientRpcServer({
|
|
219
|
-
serviceRegistry: this._clientServices.serviceRegistry,
|
|
220
|
-
port: this._appPort,
|
|
221
|
-
...middleware
|
|
222
|
-
});
|
|
223
|
-
await Promise.all([
|
|
224
|
-
this._clientServices.open(new Context()),
|
|
225
|
-
this._clientRpc.open(),
|
|
226
|
-
this._shellRuntime?.open()
|
|
227
|
-
]);
|
|
228
|
-
this._ready.wake(void 0);
|
|
229
|
-
log("started", void 0, {
|
|
230
|
-
F: __dxlog_file2,
|
|
231
|
-
L: 116,
|
|
232
|
-
S: this,
|
|
233
|
-
C: (f, a) => f(...a)
|
|
234
|
-
});
|
|
235
|
-
} catch (err) {
|
|
236
|
-
this._ready.wake(err);
|
|
237
|
-
log.catch(err, void 0, {
|
|
238
|
-
F: __dxlog_file2,
|
|
239
|
-
L: 119,
|
|
240
|
-
S: this,
|
|
241
|
-
C: (f, a) => f(...a)
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
async stop() {
|
|
246
|
-
log("stopping...", void 0, {
|
|
247
|
-
F: __dxlog_file2,
|
|
248
|
-
L: 124,
|
|
249
|
-
S: this,
|
|
250
|
-
C: (f, a) => f(...a)
|
|
251
|
-
});
|
|
252
|
-
await this._clientRpc.close();
|
|
253
|
-
await this._clientServices.close();
|
|
254
|
-
await this._shellRuntime?.close();
|
|
255
|
-
log("stopped", void 0, {
|
|
256
|
-
F: __dxlog_file2,
|
|
257
|
-
L: 128,
|
|
258
|
-
S: this,
|
|
259
|
-
C: (f, a) => f(...a)
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
_ts_decorate([
|
|
264
|
-
logInfo
|
|
265
|
-
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
266
|
-
|
|
267
|
-
// packages/sdk/client-services/src/packlets/vault/shared-worker-connection.ts
|
|
42
|
+
// packages/sdk/client-services/src/packlets/worker/worker-runtime.ts
|
|
268
43
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
269
|
-
import {
|
|
44
|
+
import { Context } from "@dxos/context";
|
|
45
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
270
46
|
import { log as log2 } from "@dxos/log";
|
|
271
|
-
import {
|
|
272
|
-
import { RemoteServiceConnectionError } from "@dxos/protocols";
|
|
273
|
-
import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
|
|
274
|
-
import { getAsyncValue as getAsyncValue2 } from "@dxos/util";
|
|
275
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shared-worker-connection.ts";
|
|
276
|
-
var SharedWorkerConnection = class {
|
|
277
|
-
constructor({ config, systemPort, shellPort }) {
|
|
278
|
-
this._id = String(Math.floor(Math.random() * 1e6));
|
|
279
|
-
this._release = new Trigger2();
|
|
280
|
-
this._configProvider = config;
|
|
281
|
-
this._systemPort = systemPort;
|
|
282
|
-
this._shellPort = shellPort;
|
|
283
|
-
if (this._shellPort) {
|
|
284
|
-
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
get shell() {
|
|
288
|
-
return this._shellRuntime;
|
|
289
|
-
}
|
|
290
|
-
async open(params) {
|
|
291
|
-
this._config = await getAsyncValue2(this._configProvider);
|
|
292
|
-
this._transportService = new SimplePeerTransportService({
|
|
293
|
-
iceServers: this._config.get("runtime.services.ice")
|
|
294
|
-
});
|
|
295
|
-
this._systemRpc = createProtoRpcPeer2({
|
|
296
|
-
requested: workerServiceBundle,
|
|
297
|
-
exposed: iframeServiceBundle,
|
|
298
|
-
handlers: {
|
|
299
|
-
BridgeService: this._transportService
|
|
300
|
-
},
|
|
301
|
-
port: this._systemPort,
|
|
302
|
-
// TODO(wittjosiah): Make longer and factor out to constant.
|
|
303
|
-
// TODO(wittjosiah): If this is too long then it breaks the reset flows in Composer.
|
|
304
|
-
timeout: 200
|
|
305
|
-
});
|
|
306
|
-
let lockKey;
|
|
307
|
-
if (typeof navigator !== "undefined") {
|
|
308
|
-
lockKey = this._lockKey(params.origin);
|
|
309
|
-
this._release = new Trigger2();
|
|
310
|
-
const ready = new Trigger2();
|
|
311
|
-
void navigator.locks.request(lockKey, async () => {
|
|
312
|
-
ready.wake();
|
|
313
|
-
await this._release.wait();
|
|
314
|
-
});
|
|
315
|
-
await ready.wait();
|
|
316
|
-
}
|
|
317
|
-
try {
|
|
318
|
-
await this._systemRpc.open();
|
|
319
|
-
await this._systemRpc.rpc.WorkerService.start({
|
|
320
|
-
lockKey,
|
|
321
|
-
...params
|
|
322
|
-
});
|
|
323
|
-
} catch (err) {
|
|
324
|
-
log2.catch(err, void 0, {
|
|
325
|
-
F: __dxlog_file3,
|
|
326
|
-
L: 95,
|
|
327
|
-
S: this,
|
|
328
|
-
C: (f, a) => f(...a)
|
|
329
|
-
});
|
|
330
|
-
throw new RemoteServiceConnectionError("Failed to connect to worker");
|
|
331
|
-
}
|
|
332
|
-
await this._shellRuntime?.open();
|
|
333
|
-
}
|
|
334
|
-
async close() {
|
|
335
|
-
this._release.wake();
|
|
336
|
-
await this._shellRuntime?.close();
|
|
337
|
-
try {
|
|
338
|
-
await this._systemRpc.rpc.WorkerService.stop();
|
|
339
|
-
} catch {
|
|
340
|
-
}
|
|
341
|
-
await this._systemRpc.close();
|
|
342
|
-
}
|
|
343
|
-
_lockKey(origin) {
|
|
344
|
-
return `${origin}-${this._id}`;
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
349
|
-
import { Trigger as Trigger4 } from "@dxos/async";
|
|
350
|
-
import { Context as Context2 } from "@dxos/context";
|
|
351
|
-
import { invariant as invariant3 } from "@dxos/invariant";
|
|
352
|
-
import { log as log4 } from "@dxos/log";
|
|
353
|
-
import { MemorySignalManager as MemorySignalManager2, MemorySignalManagerContext as MemorySignalManagerContext2, WebsocketSignalManager as WebsocketSignalManager2, setIdentityTags } from "@dxos/messaging";
|
|
47
|
+
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager, setIdentityTags } from "@dxos/messaging";
|
|
354
48
|
import { SimplePeerTransportProxyFactory } from "@dxos/network-manager";
|
|
355
49
|
|
|
356
|
-
// packages/sdk/client-services/src/packlets/
|
|
357
|
-
import { asyncTimeout, Trigger
|
|
358
|
-
import { iframeServiceBundle
|
|
359
|
-
import { invariant
|
|
360
|
-
import { log
|
|
361
|
-
import { createProtoRpcPeer
|
|
50
|
+
// packages/sdk/client-services/src/packlets/worker/worker-session.ts
|
|
51
|
+
import { asyncTimeout, Trigger } from "@dxos/async";
|
|
52
|
+
import { iframeServiceBundle, PROXY_CONNECTION_TIMEOUT, workerServiceBundle } from "@dxos/client-protocol";
|
|
53
|
+
import { invariant } from "@dxos/invariant";
|
|
54
|
+
import { log, logInfo } from "@dxos/log";
|
|
55
|
+
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
362
56
|
import { Callback } from "@dxos/util";
|
|
363
|
-
function
|
|
57
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
364
58
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
365
59
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
366
60
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -370,13 +64,13 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
370
64
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
371
65
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
372
66
|
}
|
|
373
|
-
var
|
|
67
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
|
|
374
68
|
var WorkerSession = class {
|
|
375
69
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
376
|
-
this._startTrigger = new
|
|
70
|
+
this._startTrigger = new Trigger();
|
|
377
71
|
this.onClose = new Callback();
|
|
378
|
-
|
|
379
|
-
F:
|
|
72
|
+
invariant(serviceHost, void 0, {
|
|
73
|
+
F: __dxlog_file,
|
|
380
74
|
L: 54,
|
|
381
75
|
S: this,
|
|
382
76
|
A: [
|
|
@@ -388,7 +82,7 @@ var WorkerSession = class {
|
|
|
388
82
|
const middleware = {
|
|
389
83
|
handleCall: async (method, params, handler) => {
|
|
390
84
|
const error = await readySignal.wait({
|
|
391
|
-
timeout:
|
|
85
|
+
timeout: PROXY_CONNECTION_TIMEOUT
|
|
392
86
|
});
|
|
393
87
|
if (error) {
|
|
394
88
|
throw error;
|
|
@@ -397,7 +91,7 @@ var WorkerSession = class {
|
|
|
397
91
|
},
|
|
398
92
|
handleStream: async (method, params, handler) => {
|
|
399
93
|
const error = await readySignal.wait({
|
|
400
|
-
timeout:
|
|
94
|
+
timeout: PROXY_CONNECTION_TIMEOUT
|
|
401
95
|
});
|
|
402
96
|
if (error) {
|
|
403
97
|
throw error;
|
|
@@ -415,9 +109,9 @@ var WorkerSession = class {
|
|
|
415
109
|
port: shellPort,
|
|
416
110
|
...middleware
|
|
417
111
|
}) : void 0;
|
|
418
|
-
this._iframeRpc =
|
|
419
|
-
requested:
|
|
420
|
-
exposed:
|
|
112
|
+
this._iframeRpc = createProtoRpcPeer({
|
|
113
|
+
requested: iframeServiceBundle,
|
|
114
|
+
exposed: workerServiceBundle,
|
|
421
115
|
handlers: {
|
|
422
116
|
WorkerService: {
|
|
423
117
|
start: async (request) => {
|
|
@@ -432,8 +126,8 @@ var WorkerSession = class {
|
|
|
432
126
|
try {
|
|
433
127
|
await this.close();
|
|
434
128
|
} catch (err) {
|
|
435
|
-
|
|
436
|
-
F:
|
|
129
|
+
log.catch(err, void 0, {
|
|
130
|
+
F: __dxlog_file,
|
|
437
131
|
L: 108,
|
|
438
132
|
S: this,
|
|
439
133
|
C: (f, a) => f(...a)
|
|
@@ -449,8 +143,8 @@ var WorkerSession = class {
|
|
|
449
143
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
450
144
|
}
|
|
451
145
|
async open() {
|
|
452
|
-
|
|
453
|
-
F:
|
|
146
|
+
log.info("opening...", void 0, {
|
|
147
|
+
F: __dxlog_file,
|
|
454
148
|
L: 122,
|
|
455
149
|
S: this,
|
|
456
150
|
C: (f, a) => f(...a)
|
|
@@ -461,21 +155,21 @@ var WorkerSession = class {
|
|
|
461
155
|
this._maybeOpenShell()
|
|
462
156
|
]);
|
|
463
157
|
await this._startTrigger.wait({
|
|
464
|
-
timeout:
|
|
158
|
+
timeout: PROXY_CONNECTION_TIMEOUT
|
|
465
159
|
});
|
|
466
160
|
if (this.lockKey) {
|
|
467
161
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
468
162
|
}
|
|
469
|
-
|
|
470
|
-
F:
|
|
163
|
+
log.info("opened", void 0, {
|
|
164
|
+
F: __dxlog_file,
|
|
471
165
|
L: 133,
|
|
472
166
|
S: this,
|
|
473
167
|
C: (f, a) => f(...a)
|
|
474
168
|
});
|
|
475
169
|
}
|
|
476
170
|
async close() {
|
|
477
|
-
|
|
478
|
-
F:
|
|
171
|
+
log.info("closing...", void 0, {
|
|
172
|
+
F: __dxlog_file,
|
|
479
173
|
L: 137,
|
|
480
174
|
S: this,
|
|
481
175
|
C: (f, a) => f(...a)
|
|
@@ -483,8 +177,8 @@ var WorkerSession = class {
|
|
|
483
177
|
try {
|
|
484
178
|
await this.onClose.callIfSet();
|
|
485
179
|
} catch (err) {
|
|
486
|
-
|
|
487
|
-
F:
|
|
180
|
+
log.catch(err, void 0, {
|
|
181
|
+
F: __dxlog_file,
|
|
488
182
|
L: 141,
|
|
489
183
|
S: this,
|
|
490
184
|
C: (f, a) => f(...a)
|
|
@@ -494,8 +188,8 @@ var WorkerSession = class {
|
|
|
494
188
|
this._clientRpc.close(),
|
|
495
189
|
this._iframeRpc.close()
|
|
496
190
|
]);
|
|
497
|
-
|
|
498
|
-
F:
|
|
191
|
+
log.info("closed", void 0, {
|
|
192
|
+
F: __dxlog_file,
|
|
499
193
|
L: 145,
|
|
500
194
|
S: this,
|
|
501
195
|
C: (f, a) => f(...a)
|
|
@@ -505,8 +199,8 @@ var WorkerSession = class {
|
|
|
505
199
|
try {
|
|
506
200
|
this._shellClientRpc && await asyncTimeout(this._shellClientRpc.open(), 1e3);
|
|
507
201
|
} catch {
|
|
508
|
-
|
|
509
|
-
F:
|
|
202
|
+
log.info("No shell connected.", void 0, {
|
|
203
|
+
F: __dxlog_file,
|
|
510
204
|
L: 152,
|
|
511
205
|
S: this,
|
|
512
206
|
C: (f, a) => f(...a)
|
|
@@ -518,20 +212,20 @@ var WorkerSession = class {
|
|
|
518
212
|
}).then(callback);
|
|
519
213
|
}
|
|
520
214
|
};
|
|
521
|
-
|
|
522
|
-
|
|
215
|
+
_ts_decorate([
|
|
216
|
+
logInfo
|
|
523
217
|
], WorkerSession.prototype, "origin", void 0);
|
|
524
|
-
|
|
525
|
-
|
|
218
|
+
_ts_decorate([
|
|
219
|
+
logInfo
|
|
526
220
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
527
221
|
|
|
528
|
-
// packages/sdk/client-services/src/packlets/
|
|
529
|
-
var
|
|
222
|
+
// packages/sdk/client-services/src/packlets/worker/worker-runtime.ts
|
|
223
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
|
|
530
224
|
var WorkerRuntime = class {
|
|
531
225
|
constructor(_configProvider, { acquireLock, releaseLock, onReset }) {
|
|
532
226
|
this._configProvider = _configProvider;
|
|
533
227
|
this._transportFactory = new SimplePeerTransportProxyFactory();
|
|
534
|
-
this._ready = new
|
|
228
|
+
this._ready = new Trigger2();
|
|
535
229
|
this._sessions = /* @__PURE__ */ new Set();
|
|
536
230
|
this._signalMetadataTags = {
|
|
537
231
|
runtime: "worker-runtime"
|
|
@@ -549,8 +243,8 @@ var WorkerRuntime = class {
|
|
|
549
243
|
return this._clientServices;
|
|
550
244
|
}
|
|
551
245
|
async start() {
|
|
552
|
-
|
|
553
|
-
F:
|
|
246
|
+
log2("starting...", void 0, {
|
|
247
|
+
F: __dxlog_file2,
|
|
554
248
|
L: 71,
|
|
555
249
|
S: this,
|
|
556
250
|
C: (f, a) => f(...a)
|
|
@@ -561,13 +255,13 @@ var WorkerRuntime = class {
|
|
|
561
255
|
const signals = this._config.get("runtime.services.signaling");
|
|
562
256
|
this._clientServices.initialize({
|
|
563
257
|
config: this._config,
|
|
564
|
-
signalManager: signals ? new
|
|
258
|
+
signalManager: signals ? new WebsocketSignalManager(signals, () => this._signalTelemetryEnabled ? this._signalMetadataTags : {}) : new MemorySignalManager(new MemorySignalManagerContext()),
|
|
565
259
|
transportFactory: this._transportFactory
|
|
566
260
|
});
|
|
567
|
-
await this._clientServices.open(new
|
|
261
|
+
await this._clientServices.open(new Context());
|
|
568
262
|
this._ready.wake(void 0);
|
|
569
|
-
|
|
570
|
-
F:
|
|
263
|
+
log2("started", void 0, {
|
|
264
|
+
F: __dxlog_file2,
|
|
571
265
|
L: 86,
|
|
572
266
|
S: this,
|
|
573
267
|
C: (f, a) => f(...a)
|
|
@@ -581,8 +275,8 @@ var WorkerRuntime = class {
|
|
|
581
275
|
});
|
|
582
276
|
} catch (err) {
|
|
583
277
|
this._ready.wake(err);
|
|
584
|
-
|
|
585
|
-
F:
|
|
278
|
+
log2.error("starting", err, {
|
|
279
|
+
F: __dxlog_file2,
|
|
586
280
|
L: 96,
|
|
587
281
|
S: this,
|
|
588
282
|
C: (f, a) => f(...a)
|
|
@@ -615,8 +309,8 @@ var WorkerRuntime = class {
|
|
|
615
309
|
}
|
|
616
310
|
});
|
|
617
311
|
await session.open();
|
|
618
|
-
|
|
619
|
-
F:
|
|
312
|
+
invariant2(!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin, `worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`, {
|
|
313
|
+
F: __dxlog_file2,
|
|
620
314
|
L: 133,
|
|
621
315
|
S: this,
|
|
622
316
|
A: [
|
|
@@ -636,8 +330,8 @@ var WorkerRuntime = class {
|
|
|
636
330
|
* Selects one of the existing session for WebRTC networking.
|
|
637
331
|
*/
|
|
638
332
|
_reconnectWebrtc() {
|
|
639
|
-
|
|
640
|
-
F:
|
|
333
|
+
log2("reconnecting webrtc...", void 0, {
|
|
334
|
+
F: __dxlog_file2,
|
|
641
335
|
L: 151,
|
|
642
336
|
S: this,
|
|
643
337
|
C: (f, a) => f(...a)
|
|
@@ -668,7 +362,6 @@ export {
|
|
|
668
362
|
DevtoolsHostEvents,
|
|
669
363
|
DevtoolsServiceImpl,
|
|
670
364
|
DiagnosticsCollector,
|
|
671
|
-
IFrameHostRuntime,
|
|
672
365
|
Identity,
|
|
673
366
|
IdentityManager,
|
|
674
367
|
IdentityServiceImpl,
|
|
@@ -678,8 +371,6 @@ export {
|
|
|
678
371
|
Lock,
|
|
679
372
|
ServiceContext,
|
|
680
373
|
ServiceRegistry,
|
|
681
|
-
SharedWorkerConnection,
|
|
682
|
-
ShellRuntimeImpl,
|
|
683
374
|
SpaceInvitationProtocol,
|
|
684
375
|
SpacesServiceImpl,
|
|
685
376
|
TrustedKeySetAuthVerifier,
|
|
@@ -692,7 +383,6 @@ export {
|
|
|
692
383
|
createDiagnostics,
|
|
693
384
|
createLevel,
|
|
694
385
|
createStorageObjects,
|
|
695
|
-
findPropertiesObject,
|
|
696
386
|
getNetworkPeers,
|
|
697
387
|
isLocked,
|
|
698
388
|
subscribeToFeedBlocks,
|