@dxos/client-services 0.1.41-next.d517c89 → 0.1.41
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-LGMYP2WL.mjs → chunk-T73F4MV4.mjs} +232 -213
- package/dist/lib/browser/chunk-T73F4MV4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +271 -252
- 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 +259 -217
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/logging/index.d.ts +2 -0
- package/dist/types/src/packlets/logging/index.d.ts.map +1 -0
- package/dist/types/src/packlets/logging/logging-service.d.ts +13 -0
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -0
- package/dist/types/src/packlets/logging/logging.test.d.ts +2 -0
- package/dist/types/src/packlets/logging/logging.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +6 -5
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +9 -8
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/packlets/logging/index.ts +5 -0
- package/src/packlets/logging/logging-service.ts +78 -0
- package/src/packlets/logging/logging.test.ts +50 -0
- package/src/packlets/services/service-host.ts +9 -2
- package/src/packlets/spaces/data-space-manager.ts +7 -3
- package/src/packlets/tests/shared-worker.test.ts +9 -10
- package/src/packlets/vault/iframe-host-runtime.ts +13 -16
- package/src/packlets/vault/iframe-proxy-runtime.ts +28 -34
- package/dist/lib/browser/chunk-LGMYP2WL.mjs.map +0 -7
- package/dist/types/src/packlets/deprecated/index.d.ts +0 -2
- package/dist/types/src/packlets/deprecated/index.d.ts.map +0 -1
- package/dist/types/src/packlets/deprecated/tracing.d.ts +0 -12
- package/dist/types/src/packlets/deprecated/tracing.d.ts.map +0 -1
- package/src/packlets/deprecated/index.ts +0 -5
- package/src/packlets/deprecated/tracing.ts +0 -21
|
@@ -78,26 +78,13 @@ var import_random_access_storage2 = require("@dxos/random-access-storage");
|
|
|
78
78
|
|
|
79
79
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
80
80
|
var import_node_assert14 = __toESM(require("node:assert"));
|
|
81
|
-
var
|
|
81
|
+
var import_async21 = require("@dxos/async");
|
|
82
82
|
var import_client8 = require("@dxos/client");
|
|
83
83
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
84
|
-
var
|
|
84
|
+
var import_log19 = require("@dxos/log");
|
|
85
85
|
var import_protocols8 = require("@dxos/protocols");
|
|
86
86
|
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
87
87
|
|
|
88
|
-
// packages/sdk/client-services/src/packlets/deprecated/tracing.ts
|
|
89
|
-
var TracingServiceImpl = class {
|
|
90
|
-
constructor(_config) {
|
|
91
|
-
this._config = _config;
|
|
92
|
-
}
|
|
93
|
-
async setTracingOptions() {
|
|
94
|
-
throw new Error("Tracing not available.");
|
|
95
|
-
}
|
|
96
|
-
subscribeToRpcTrace() {
|
|
97
|
-
throw new Error("Tracing not available.");
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
88
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
102
89
|
var import_async = require("@dxos/async");
|
|
103
90
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
@@ -2105,14 +2092,73 @@ var SpaceInvitationProtocol = class {
|
|
|
2105
2092
|
}
|
|
2106
2093
|
};
|
|
2107
2094
|
|
|
2108
|
-
// packages/sdk/client-services/src/packlets/
|
|
2095
|
+
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
2096
|
+
var import_async10 = require("@dxos/async");
|
|
2109
2097
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
2098
|
+
var import_log8 = require("@dxos/log");
|
|
2099
|
+
var LoggingServiceImpl = class {
|
|
2100
|
+
constructor() {
|
|
2101
|
+
this._logs = new import_async10.Event();
|
|
2102
|
+
this._logProcessor = (_config, entry2) => {
|
|
2103
|
+
this._logs.emit(entry2);
|
|
2104
|
+
};
|
|
2105
|
+
}
|
|
2106
|
+
async open() {
|
|
2107
|
+
import_log8.log.runtimeConfig.processors.push(this._logProcessor);
|
|
2108
|
+
}
|
|
2109
|
+
async close() {
|
|
2110
|
+
const index = import_log8.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
2111
|
+
import_log8.log.runtimeConfig.processors.splice(index, 1);
|
|
2112
|
+
}
|
|
2113
|
+
queryLogs(request) {
|
|
2114
|
+
var _a;
|
|
2115
|
+
const filters = ((_a = request.filters) == null ? void 0 : _a.length) ? request.filters : void 0;
|
|
2116
|
+
return new import_codec_protobuf9.Stream(({ ctx, next }) => {
|
|
2117
|
+
const handler = (entry2) => {
|
|
2118
|
+
var _a2;
|
|
2119
|
+
if (((_a2 = entry2.meta) == null ? void 0 : _a2.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
if ((0, import_log8.shouldLog)(entry2, filters)) {
|
|
2123
|
+
next(jsonify(entry2));
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
ctx.onDispose(() => {
|
|
2127
|
+
this._logs.off(handler);
|
|
2128
|
+
});
|
|
2129
|
+
this._logs.on(handler);
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
};
|
|
2133
|
+
var jsonify = (value) => {
|
|
2134
|
+
if (typeof value === "function") {
|
|
2135
|
+
return null;
|
|
2136
|
+
} else if (typeof value === "object" && value !== null) {
|
|
2137
|
+
if (Array.isArray(value)) {
|
|
2138
|
+
return value.map(jsonify);
|
|
2139
|
+
} else {
|
|
2140
|
+
if (typeof value.toJSON === "function") {
|
|
2141
|
+
return value.toJSON();
|
|
2142
|
+
}
|
|
2143
|
+
const res = {};
|
|
2144
|
+
for (const key of Object.keys(value)) {
|
|
2145
|
+
res[key] = jsonify(value[key]);
|
|
2146
|
+
}
|
|
2147
|
+
return res;
|
|
2148
|
+
}
|
|
2149
|
+
} else {
|
|
2150
|
+
return value;
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2153
|
+
|
|
2154
|
+
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
2155
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2110
2156
|
var NetworkServiceImpl = class {
|
|
2111
2157
|
constructor(networkManager) {
|
|
2112
2158
|
this.networkManager = networkManager;
|
|
2113
2159
|
}
|
|
2114
2160
|
subscribeToNetworkStatus() {
|
|
2115
|
-
return new
|
|
2161
|
+
return new import_codec_protobuf10.Stream(({ next }) => {
|
|
2116
2162
|
const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
|
|
2117
2163
|
state
|
|
2118
2164
|
}));
|
|
@@ -2129,35 +2175,35 @@ var NetworkServiceImpl = class {
|
|
|
2129
2175
|
|
|
2130
2176
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2131
2177
|
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2132
|
-
var
|
|
2178
|
+
var import_async13 = require("@dxos/async");
|
|
2133
2179
|
var import_client3 = require("@dxos/client");
|
|
2134
2180
|
var import_context7 = require("@dxos/context");
|
|
2135
2181
|
var import_credentials11 = require("@dxos/credentials");
|
|
2136
2182
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2137
2183
|
var import_keys10 = require("@dxos/keys");
|
|
2138
|
-
var
|
|
2184
|
+
var import_log11 = require("@dxos/log");
|
|
2139
2185
|
var import_protocols6 = require("@dxos/protocols");
|
|
2140
2186
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2141
2187
|
var import_util5 = require("@dxos/util");
|
|
2142
2188
|
|
|
2143
2189
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2144
|
-
var
|
|
2190
|
+
var import_async12 = require("@dxos/async");
|
|
2145
2191
|
var import_client2 = require("@dxos/client");
|
|
2146
2192
|
var import_context6 = require("@dxos/context");
|
|
2147
2193
|
var import_debug3 = require("@dxos/debug");
|
|
2148
2194
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2149
2195
|
var import_errors3 = require("@dxos/errors");
|
|
2150
2196
|
var import_keys9 = require("@dxos/keys");
|
|
2151
|
-
var
|
|
2197
|
+
var import_log10 = require("@dxos/log");
|
|
2152
2198
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2153
2199
|
var import_util4 = require("@dxos/util");
|
|
2154
2200
|
|
|
2155
2201
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2156
2202
|
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2157
|
-
var
|
|
2203
|
+
var import_async11 = require("@dxos/async");
|
|
2158
2204
|
var import_context5 = require("@dxos/context");
|
|
2159
2205
|
var import_keys8 = require("@dxos/keys");
|
|
2160
|
-
var
|
|
2206
|
+
var import_log9 = require("@dxos/log");
|
|
2161
2207
|
var import_protocols5 = require("@dxos/protocols");
|
|
2162
2208
|
var import_teleport2 = require("@dxos/teleport");
|
|
2163
2209
|
var import_util3 = require("@dxos/util");
|
|
@@ -2167,7 +2213,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2167
2213
|
var NotarizationPlugin = class {
|
|
2168
2214
|
constructor() {
|
|
2169
2215
|
this._ctx = new import_context5.Context();
|
|
2170
|
-
this._extensionOpened = new
|
|
2216
|
+
this._extensionOpened = new import_async11.Event();
|
|
2171
2217
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2172
2218
|
this._processedCredentials = new import_util3.ComplexSet(import_keys8.PublicKey.hash);
|
|
2173
2219
|
this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys8.PublicKey.hash);
|
|
@@ -2181,7 +2227,7 @@ var NotarizationPlugin = class {
|
|
|
2181
2227
|
* Request credentials to be notarized.
|
|
2182
2228
|
*/
|
|
2183
2229
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2184
|
-
(0,
|
|
2230
|
+
(0, import_log9.log)("notarize", {
|
|
2185
2231
|
credentials
|
|
2186
2232
|
}, {
|
|
2187
2233
|
file: "notarization-plugin.ts",
|
|
@@ -2190,10 +2236,10 @@ var NotarizationPlugin = class {
|
|
|
2190
2236
|
callSite: (f, a) => f(...a)
|
|
2191
2237
|
});
|
|
2192
2238
|
(0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2193
|
-
const errors = new
|
|
2239
|
+
const errors = new import_async11.Trigger();
|
|
2194
2240
|
const ctx = this._ctx.derive({
|
|
2195
2241
|
onError: (err) => {
|
|
2196
|
-
|
|
2242
|
+
import_log9.log.warn("Notarization error", {
|
|
2197
2243
|
err
|
|
2198
2244
|
}, {
|
|
2199
2245
|
file: "notarization-plugin.ts",
|
|
@@ -2207,8 +2253,8 @@ var NotarizationPlugin = class {
|
|
|
2207
2253
|
});
|
|
2208
2254
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
2209
2255
|
if (timeout !== 0) {
|
|
2210
|
-
(0,
|
|
2211
|
-
|
|
2256
|
+
(0, import_async11.scheduleTask)(ctx, () => {
|
|
2257
|
+
import_log9.log.warn("Notarization timeout", {
|
|
2212
2258
|
timeout,
|
|
2213
2259
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2214
2260
|
}, {
|
|
@@ -2218,12 +2264,12 @@ var NotarizationPlugin = class {
|
|
|
2218
2264
|
callSite: (f, a) => f(...a)
|
|
2219
2265
|
});
|
|
2220
2266
|
void ctx.dispose();
|
|
2221
|
-
errors.throw(new
|
|
2267
|
+
errors.throw(new import_async11.TimeoutError(timeout, "Notarization timed out"));
|
|
2222
2268
|
}, timeout);
|
|
2223
2269
|
}
|
|
2224
2270
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2225
2271
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2226
|
-
const notarizeTask = new
|
|
2272
|
+
const notarizeTask = new import_async11.DeferredTask(ctx, async () => {
|
|
2227
2273
|
try {
|
|
2228
2274
|
if (this._extensions.size === 0) {
|
|
2229
2275
|
return;
|
|
@@ -2232,7 +2278,7 @@ var NotarizationPlugin = class {
|
|
|
2232
2278
|
...this._extensions
|
|
2233
2279
|
].find((peer2) => !peersTried.has(peer2));
|
|
2234
2280
|
if (!peer) {
|
|
2235
|
-
|
|
2281
|
+
import_log9.log.warn("Exhausted all peers to notarize with", {
|
|
2236
2282
|
retryIn: retryTimeout
|
|
2237
2283
|
}, {
|
|
2238
2284
|
file: "notarization-plugin.ts",
|
|
@@ -2241,11 +2287,11 @@ var NotarizationPlugin = class {
|
|
|
2241
2287
|
callSite: (f, a) => f(...a)
|
|
2242
2288
|
});
|
|
2243
2289
|
peersTried.clear();
|
|
2244
|
-
(0,
|
|
2290
|
+
(0, import_async11.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2245
2291
|
return;
|
|
2246
2292
|
}
|
|
2247
2293
|
peersTried.add(peer);
|
|
2248
|
-
(0,
|
|
2294
|
+
(0, import_log9.log)("try notarizing", {
|
|
2249
2295
|
peer: peer.localPeerId,
|
|
2250
2296
|
credentialId: credentials.map((credential) => credential.id)
|
|
2251
2297
|
}, {
|
|
@@ -2257,15 +2303,15 @@ var NotarizationPlugin = class {
|
|
|
2257
2303
|
await peer.rpc.NotarizationService.notarize({
|
|
2258
2304
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2259
2305
|
});
|
|
2260
|
-
(0,
|
|
2306
|
+
(0, import_log9.log)("success", {}, {
|
|
2261
2307
|
file: "notarization-plugin.ts",
|
|
2262
2308
|
line: 142,
|
|
2263
2309
|
scope: this,
|
|
2264
2310
|
callSite: (f, a) => f(...a)
|
|
2265
2311
|
});
|
|
2266
|
-
await (0,
|
|
2312
|
+
await (0, import_async11.sleep)(successDelay);
|
|
2267
2313
|
} catch (err) {
|
|
2268
|
-
|
|
2314
|
+
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2269
2315
|
file: "notarization-plugin.ts",
|
|
2270
2316
|
line: 145,
|
|
2271
2317
|
scope: this,
|
|
@@ -2282,7 +2328,7 @@ var NotarizationPlugin = class {
|
|
|
2282
2328
|
allNotarized,
|
|
2283
2329
|
errors.wait()
|
|
2284
2330
|
]);
|
|
2285
|
-
(0,
|
|
2331
|
+
(0, import_log9.log)("done", {}, {
|
|
2286
2332
|
file: "notarization-plugin.ts",
|
|
2287
2333
|
line: 155,
|
|
2288
2334
|
scope: this,
|
|
@@ -2312,7 +2358,7 @@ var NotarizationPlugin = class {
|
|
|
2312
2358
|
if (this._processedCredentials.has(id)) {
|
|
2313
2359
|
return;
|
|
2314
2360
|
}
|
|
2315
|
-
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new
|
|
2361
|
+
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async11.Trigger()).value.wait();
|
|
2316
2362
|
}
|
|
2317
2363
|
/**
|
|
2318
2364
|
* Requests from other peers to notarize credentials.
|
|
@@ -2333,7 +2379,7 @@ var NotarizationPlugin = class {
|
|
|
2333
2379
|
createExtension() {
|
|
2334
2380
|
const extension = new NotarizationTeleportExtension({
|
|
2335
2381
|
onOpen: async () => {
|
|
2336
|
-
(0,
|
|
2382
|
+
(0, import_log9.log)("extension opened", {
|
|
2337
2383
|
peer: extension.localPeerId
|
|
2338
2384
|
}, {
|
|
2339
2385
|
file: "notarization-plugin.ts",
|
|
@@ -2345,7 +2391,7 @@ var NotarizationPlugin = class {
|
|
|
2345
2391
|
this._extensionOpened.emit();
|
|
2346
2392
|
},
|
|
2347
2393
|
onClose: async () => {
|
|
2348
|
-
(0,
|
|
2394
|
+
(0, import_log9.log)("extension closed", {
|
|
2349
2395
|
peer: extension.localPeerId
|
|
2350
2396
|
}, {
|
|
2351
2397
|
file: "notarization-plugin.ts",
|
|
@@ -2407,7 +2453,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2407
2453
|
constructor(params) {
|
|
2408
2454
|
this._ctx = new import_context6.Context();
|
|
2409
2455
|
this._state = import_client2.SpaceState.CLOSED;
|
|
2410
|
-
this.stateUpdate = new
|
|
2456
|
+
this.stateUpdate = new import_async12.Event();
|
|
2411
2457
|
var _a;
|
|
2412
2458
|
this._inner = params.inner;
|
|
2413
2459
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
@@ -2482,12 +2528,12 @@ var DataSpace = class DataSpace2 {
|
|
|
2482
2528
|
* Initialize the data pipeline in a separate task.
|
|
2483
2529
|
*/
|
|
2484
2530
|
initializeDataPipelineAsync() {
|
|
2485
|
-
(0,
|
|
2531
|
+
(0, import_async12.scheduleTask)(this._ctx, async () => {
|
|
2486
2532
|
try {
|
|
2487
2533
|
await this.initializeDataPipeline();
|
|
2488
2534
|
} catch (err) {
|
|
2489
2535
|
if (err instanceof import_errors3.CancelledError) {
|
|
2490
|
-
(0,
|
|
2536
|
+
(0, import_log10.log)("Data pipeline initialization cancelled", err, {
|
|
2491
2537
|
file: "data-space.ts",
|
|
2492
2538
|
line: 178,
|
|
2493
2539
|
scope: this,
|
|
@@ -2495,7 +2541,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2495
2541
|
});
|
|
2496
2542
|
return;
|
|
2497
2543
|
}
|
|
2498
|
-
|
|
2544
|
+
import_log10.log.error("Error initializing data pipeline", err, {
|
|
2499
2545
|
file: "data-space.ts",
|
|
2500
2546
|
line: 182,
|
|
2501
2547
|
scope: this,
|
|
@@ -2515,7 +2561,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2515
2561
|
breakOnStall: false
|
|
2516
2562
|
});
|
|
2517
2563
|
await this._createWritableFeeds();
|
|
2518
|
-
(0,
|
|
2564
|
+
(0, import_log10.log)("Writable feeds created", {}, {
|
|
2519
2565
|
file: "data-space.ts",
|
|
2520
2566
|
line: 200,
|
|
2521
2567
|
scope: this,
|
|
@@ -2536,7 +2582,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2536
2582
|
return pipeline;
|
|
2537
2583
|
}
|
|
2538
2584
|
});
|
|
2539
|
-
(0,
|
|
2585
|
+
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", {}, {
|
|
2540
2586
|
file: "data-space.ts",
|
|
2541
2587
|
line: 220,
|
|
2542
2588
|
scope: this,
|
|
@@ -2546,7 +2592,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2546
2592
|
ctx: this._ctx,
|
|
2547
2593
|
breakOnStall: false
|
|
2548
2594
|
});
|
|
2549
|
-
(0,
|
|
2595
|
+
(0, import_log10.log)("data pipeline ready", {}, {
|
|
2550
2596
|
file: "data-space.ts",
|
|
2551
2597
|
line: 227,
|
|
2552
2598
|
scope: this,
|
|
@@ -2605,7 +2651,7 @@ __decorate([
|
|
|
2605
2651
|
(0, import_debug3.timed)(1e4)
|
|
2606
2652
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2607
2653
|
DataSpace = __decorate([
|
|
2608
|
-
(0,
|
|
2654
|
+
(0, import_async12.trackLeaks)("open", "close")
|
|
2609
2655
|
], DataSpace);
|
|
2610
2656
|
|
|
2611
2657
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
@@ -2630,7 +2676,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2630
2676
|
this._feedStore = _feedStore;
|
|
2631
2677
|
this._snapshotStore = _snapshotStore;
|
|
2632
2678
|
this._ctx = new import_context7.Context();
|
|
2633
|
-
this.updated = new
|
|
2679
|
+
this.updated = new import_async13.Event();
|
|
2634
2680
|
this._spaces = new import_util5.ComplexMap(import_keys10.PublicKey.hash);
|
|
2635
2681
|
this._isOpen = false;
|
|
2636
2682
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
@@ -2640,13 +2686,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2640
2686
|
return this._spaces;
|
|
2641
2687
|
}
|
|
2642
2688
|
async open() {
|
|
2643
|
-
(0,
|
|
2689
|
+
(0, import_log11.log)("open", {}, {
|
|
2644
2690
|
file: "data-space-manager.ts",
|
|
2645
2691
|
line: 83,
|
|
2646
2692
|
scope: this,
|
|
2647
2693
|
callSite: (f, a) => f(...a)
|
|
2648
2694
|
});
|
|
2649
|
-
|
|
2695
|
+
import_log11.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.begin({
|
|
2650
2696
|
id: this._instanceId,
|
|
2651
2697
|
parentId: this._traceParent
|
|
2652
2698
|
}), {
|
|
@@ -2656,7 +2702,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2656
2702
|
callSite: (f, a) => f(...a)
|
|
2657
2703
|
});
|
|
2658
2704
|
await this._metadataStore.load();
|
|
2659
|
-
(0,
|
|
2705
|
+
(0, import_log11.log)("metadata loaded", {
|
|
2660
2706
|
spaces: this._metadataStore.spaces.length
|
|
2661
2707
|
}, {
|
|
2662
2708
|
file: "data-space-manager.ts",
|
|
@@ -2665,24 +2711,36 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2665
2711
|
callSite: (f, a) => f(...a)
|
|
2666
2712
|
});
|
|
2667
2713
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2714
|
+
try {
|
|
2715
|
+
(0, import_log11.log)("load space", {
|
|
2716
|
+
spaceMetadata
|
|
2717
|
+
}, {
|
|
2718
|
+
file: "data-space-manager.ts",
|
|
2719
|
+
line: 90,
|
|
2720
|
+
scope: this,
|
|
2721
|
+
callSite: (f, a) => f(...a)
|
|
2722
|
+
});
|
|
2723
|
+
const space = await this._constructSpace(spaceMetadata);
|
|
2724
|
+
space.initializeDataPipelineAsync();
|
|
2725
|
+
} catch (err) {
|
|
2726
|
+
import_log11.log.error("Error loading space", {
|
|
2727
|
+
spaceMetadata,
|
|
2728
|
+
err
|
|
2729
|
+
}, {
|
|
2730
|
+
file: "data-space-manager.ts",
|
|
2731
|
+
line: 94,
|
|
2732
|
+
scope: this,
|
|
2733
|
+
callSite: (f, a) => f(...a)
|
|
2734
|
+
});
|
|
2735
|
+
}
|
|
2678
2736
|
}
|
|
2679
2737
|
this._isOpen = true;
|
|
2680
2738
|
this.updated.emit();
|
|
2681
2739
|
}
|
|
2682
2740
|
async close() {
|
|
2683
|
-
(0,
|
|
2741
|
+
(0, import_log11.log)("close", {}, {
|
|
2684
2742
|
file: "data-space-manager.ts",
|
|
2685
|
-
line:
|
|
2743
|
+
line: 104,
|
|
2686
2744
|
scope: this,
|
|
2687
2745
|
callSite: (f, a) => f(...a)
|
|
2688
2746
|
});
|
|
@@ -2691,11 +2749,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2691
2749
|
for (const space of this._spaces.values()) {
|
|
2692
2750
|
await space.close();
|
|
2693
2751
|
}
|
|
2694
|
-
|
|
2752
|
+
import_log11.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.end({
|
|
2695
2753
|
id: this._instanceId
|
|
2696
2754
|
}), {
|
|
2697
2755
|
file: "data-space-manager.ts",
|
|
2698
|
-
line:
|
|
2756
|
+
line: 110,
|
|
2699
2757
|
scope: this,
|
|
2700
2758
|
callSite: (f, a) => f(...a)
|
|
2701
2759
|
});
|
|
@@ -2714,11 +2772,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2714
2772
|
controlFeedKey,
|
|
2715
2773
|
dataFeedKey
|
|
2716
2774
|
};
|
|
2717
|
-
(0,
|
|
2775
|
+
(0, import_log11.log)("creating space...", {
|
|
2718
2776
|
spaceKey
|
|
2719
2777
|
}, {
|
|
2720
2778
|
file: "data-space-manager.ts",
|
|
2721
|
-
line:
|
|
2779
|
+
line: 129,
|
|
2722
2780
|
scope: this,
|
|
2723
2781
|
callSite: (f, a) => f(...a)
|
|
2724
2782
|
});
|
|
@@ -2734,11 +2792,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2734
2792
|
}
|
|
2735
2793
|
// TODO(burdon): Rename join space.
|
|
2736
2794
|
async acceptSpace(opts) {
|
|
2737
|
-
(0,
|
|
2795
|
+
(0, import_log11.log)("accept space", {
|
|
2738
2796
|
opts
|
|
2739
2797
|
}, {
|
|
2740
2798
|
file: "data-space-manager.ts",
|
|
2741
|
-
line:
|
|
2799
|
+
line: 148,
|
|
2742
2800
|
scope: this,
|
|
2743
2801
|
callSite: (f, a) => f(...a)
|
|
2744
2802
|
});
|
|
@@ -2768,11 +2826,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2768
2826
|
}));
|
|
2769
2827
|
}
|
|
2770
2828
|
async _constructSpace(metadata) {
|
|
2771
|
-
(0,
|
|
2829
|
+
(0, import_log11.log)("construct space", {
|
|
2772
2830
|
metadata
|
|
2773
2831
|
}, {
|
|
2774
2832
|
file: "data-space-manager.ts",
|
|
2775
|
-
line:
|
|
2833
|
+
line: 184,
|
|
2776
2834
|
scope: this,
|
|
2777
2835
|
callSite: (f, a) => f(...a)
|
|
2778
2836
|
});
|
|
@@ -2823,23 +2881,23 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2823
2881
|
snapshotId: metadata.snapshot,
|
|
2824
2882
|
callbacks: {
|
|
2825
2883
|
beforeReady: async () => {
|
|
2826
|
-
(0,
|
|
2884
|
+
(0, import_log11.log)("before space ready", {
|
|
2827
2885
|
space: space.key
|
|
2828
2886
|
}, {
|
|
2829
2887
|
file: "data-space-manager.ts",
|
|
2830
|
-
line:
|
|
2888
|
+
line: 233,
|
|
2831
2889
|
scope: this,
|
|
2832
2890
|
callSite: (f, a) => f(...a)
|
|
2833
2891
|
});
|
|
2834
2892
|
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseBackend.createDataServiceHost());
|
|
2835
2893
|
},
|
|
2836
2894
|
afterReady: async () => {
|
|
2837
|
-
(0,
|
|
2895
|
+
(0, import_log11.log)("after space ready", {
|
|
2838
2896
|
space: space.key,
|
|
2839
2897
|
open: this._isOpen
|
|
2840
2898
|
}, {
|
|
2841
2899
|
file: "data-space-manager.ts",
|
|
2842
|
-
line:
|
|
2900
|
+
line: 240,
|
|
2843
2901
|
scope: this,
|
|
2844
2902
|
callSite: (f, a) => f(...a)
|
|
2845
2903
|
});
|
|
@@ -2861,27 +2919,27 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2861
2919
|
}
|
|
2862
2920
|
};
|
|
2863
2921
|
__decorate2([
|
|
2864
|
-
|
|
2922
|
+
import_async13.synchronized
|
|
2865
2923
|
], DataSpaceManager.prototype, "open", null);
|
|
2866
2924
|
__decorate2([
|
|
2867
|
-
|
|
2925
|
+
import_async13.synchronized
|
|
2868
2926
|
], DataSpaceManager.prototype, "close", null);
|
|
2869
2927
|
__decorate2([
|
|
2870
|
-
|
|
2928
|
+
import_async13.synchronized
|
|
2871
2929
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2872
2930
|
__decorate2([
|
|
2873
|
-
|
|
2931
|
+
import_async13.synchronized
|
|
2874
2932
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2875
2933
|
DataSpaceManager = __decorate2([
|
|
2876
|
-
(0,
|
|
2934
|
+
(0, import_async13.trackLeaks)("open", "close")
|
|
2877
2935
|
], DataSpaceManager);
|
|
2878
2936
|
|
|
2879
2937
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2880
|
-
var
|
|
2881
|
-
var
|
|
2938
|
+
var import_async14 = require("@dxos/async");
|
|
2939
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
2882
2940
|
var import_debug4 = require("@dxos/debug");
|
|
2883
2941
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
2884
|
-
var
|
|
2942
|
+
var import_log12 = require("@dxos/log");
|
|
2885
2943
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2886
2944
|
var import_util6 = require("@dxos/util");
|
|
2887
2945
|
var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
|
|
@@ -2904,11 +2962,11 @@ var SpacesServiceImpl = class {
|
|
|
2904
2962
|
(0, import_debug4.todo)();
|
|
2905
2963
|
}
|
|
2906
2964
|
querySpaces() {
|
|
2907
|
-
return new
|
|
2965
|
+
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
2908
2966
|
const onUpdate = async () => {
|
|
2909
2967
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2910
2968
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._transformSpace(space));
|
|
2911
|
-
(0,
|
|
2969
|
+
(0, import_log12.log)("update", {
|
|
2912
2970
|
spaces
|
|
2913
2971
|
}, {
|
|
2914
2972
|
file: "spaces-service.ts",
|
|
@@ -2920,9 +2978,9 @@ var SpacesServiceImpl = class {
|
|
|
2920
2978
|
spaces
|
|
2921
2979
|
});
|
|
2922
2980
|
};
|
|
2923
|
-
(0,
|
|
2981
|
+
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
2924
2982
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2925
|
-
const subscriptions = new
|
|
2983
|
+
const subscriptions = new import_async14.EventSubscriptions();
|
|
2926
2984
|
ctx.onDispose(() => subscriptions.clear());
|
|
2927
2985
|
const subscribeSpaces = () => {
|
|
2928
2986
|
subscriptions.clear();
|
|
@@ -2956,8 +3014,8 @@ var SpacesServiceImpl = class {
|
|
|
2956
3014
|
await space.postMessage(getChannelId(channel), message);
|
|
2957
3015
|
}
|
|
2958
3016
|
subscribeMessages({ spaceKey, channel }) {
|
|
2959
|
-
return new
|
|
2960
|
-
(0,
|
|
3017
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3018
|
+
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
2961
3019
|
var _a;
|
|
2962
3020
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2963
3021
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
@@ -2969,7 +3027,7 @@ var SpacesServiceImpl = class {
|
|
|
2969
3027
|
});
|
|
2970
3028
|
}
|
|
2971
3029
|
queryCredentials({ spaceKey }) {
|
|
2972
|
-
return new
|
|
3030
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
2973
3031
|
var _a;
|
|
2974
3032
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
2975
3033
|
const processor = space.spaceState.registerProcessor({
|
|
@@ -2978,7 +3036,7 @@ var SpacesServiceImpl = class {
|
|
|
2978
3036
|
}
|
|
2979
3037
|
});
|
|
2980
3038
|
ctx.onDispose(() => processor.close());
|
|
2981
|
-
(0,
|
|
3039
|
+
(0, import_async14.scheduleTask)(ctx, () => processor.open());
|
|
2982
3040
|
});
|
|
2983
3041
|
}
|
|
2984
3042
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3072,7 +3130,7 @@ var toStorageType = (type) => {
|
|
|
3072
3130
|
};
|
|
3073
3131
|
|
|
3074
3132
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3075
|
-
var
|
|
3133
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
3076
3134
|
var SystemServiceImpl = class {
|
|
3077
3135
|
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3078
3136
|
this._config = config;
|
|
@@ -3089,7 +3147,7 @@ var SystemServiceImpl = class {
|
|
|
3089
3147
|
await this._onUpdateStatus(status);
|
|
3090
3148
|
}
|
|
3091
3149
|
queryStatus() {
|
|
3092
|
-
return new
|
|
3150
|
+
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
3093
3151
|
const update = () => {
|
|
3094
3152
|
next({
|
|
3095
3153
|
status: this._getCurrentStatus()
|
|
@@ -3110,14 +3168,14 @@ var SystemServiceImpl = class {
|
|
|
3110
3168
|
};
|
|
3111
3169
|
|
|
3112
3170
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3113
|
-
var
|
|
3114
|
-
var
|
|
3171
|
+
var import_async16 = require("@dxos/async");
|
|
3172
|
+
var import_log13 = require("@dxos/log");
|
|
3115
3173
|
var import_messaging = require("@dxos/messaging");
|
|
3116
3174
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3117
3175
|
var import_util7 = require("@dxos/util");
|
|
3118
3176
|
|
|
3119
3177
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
3120
|
-
var
|
|
3178
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
3121
3179
|
var import_debug5 = require("@dxos/debug");
|
|
3122
3180
|
var import_rpc = require("@dxos/rpc");
|
|
3123
3181
|
var ClientRpcServer = class {
|
|
@@ -3142,7 +3200,7 @@ var ClientRpcServer = class {
|
|
|
3142
3200
|
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
3143
3201
|
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
3144
3202
|
if (this._handleStream) {
|
|
3145
|
-
return
|
|
3203
|
+
return import_codec_protobuf13.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
|
|
3146
3204
|
} else {
|
|
3147
3205
|
return handler(methodName, params2);
|
|
3148
3206
|
}
|
|
@@ -3171,14 +3229,14 @@ var ClientRpcServer = class {
|
|
|
3171
3229
|
|
|
3172
3230
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
3173
3231
|
var import_node_assert11 = __toESM(require("node:assert"));
|
|
3174
|
-
var
|
|
3232
|
+
var import_async15 = require("@dxos/async");
|
|
3175
3233
|
var import_client4 = require("@dxos/client");
|
|
3176
3234
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
3177
3235
|
var import_rpc2 = require("@dxos/rpc");
|
|
3178
3236
|
var ShellRuntimeImpl = class {
|
|
3179
3237
|
constructor(_port) {
|
|
3180
3238
|
this._port = _port;
|
|
3181
|
-
this.layoutUpdate = new
|
|
3239
|
+
this.layoutUpdate = new import_async15.Event();
|
|
3182
3240
|
this._layout = import_iframe.ShellLayout.DEFAULT;
|
|
3183
3241
|
}
|
|
3184
3242
|
get layout() {
|
|
@@ -3241,33 +3299,10 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3241
3299
|
};
|
|
3242
3300
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
3243
3301
|
var IFrameHostRuntime = class {
|
|
3244
|
-
constructor({
|
|
3245
|
-
this.
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
urls: "stun:dev.kube.dxos.org:3478",
|
|
3249
|
-
username: "dxos",
|
|
3250
|
-
credential: "dxos"
|
|
3251
|
-
},
|
|
3252
|
-
{
|
|
3253
|
-
urls: "turn:dev.kube.dxos.org:3478",
|
|
3254
|
-
username: "dxos",
|
|
3255
|
-
credential: "dxos"
|
|
3256
|
-
},
|
|
3257
|
-
{
|
|
3258
|
-
urls: "stun:kube.dxos.org:3478",
|
|
3259
|
-
username: "dxos",
|
|
3260
|
-
credential: "dxos"
|
|
3261
|
-
},
|
|
3262
|
-
{
|
|
3263
|
-
urls: "turn:kube.dxos.org:3478",
|
|
3264
|
-
username: "dxos",
|
|
3265
|
-
credential: "dxos"
|
|
3266
|
-
}
|
|
3267
|
-
]
|
|
3268
|
-
});
|
|
3269
|
-
this._ready = new import_async15.Trigger();
|
|
3270
|
-
this._configProvider = configProvider;
|
|
3302
|
+
constructor({ config, origin, appPort, shellPort }) {
|
|
3303
|
+
this._ready = new import_async16.Trigger();
|
|
3304
|
+
this._configProvider = config;
|
|
3305
|
+
this.origin = origin;
|
|
3271
3306
|
this._appPort = appPort;
|
|
3272
3307
|
this._shellPort = shellPort;
|
|
3273
3308
|
if (this._shellPort) {
|
|
@@ -3282,14 +3317,17 @@ var IFrameHostRuntime = class {
|
|
|
3282
3317
|
}
|
|
3283
3318
|
async start() {
|
|
3284
3319
|
var _a;
|
|
3285
|
-
(0,
|
|
3320
|
+
(0, import_log13.log)("starting...", {}, {
|
|
3286
3321
|
file: "iframe-host-runtime.ts",
|
|
3287
|
-
line:
|
|
3322
|
+
line: 69,
|
|
3288
3323
|
scope: this,
|
|
3289
3324
|
callSite: (f, a) => f(...a)
|
|
3290
3325
|
});
|
|
3291
3326
|
try {
|
|
3292
3327
|
this._config = await (0, import_util7.getAsyncValue)(this._configProvider);
|
|
3328
|
+
this._transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
|
|
3329
|
+
iceServers: this._config.get("runtime.services.ice")
|
|
3330
|
+
});
|
|
3293
3331
|
const signals = this._config.get("runtime.services.signaling");
|
|
3294
3332
|
this._clientServices = new LocalClientServices({
|
|
3295
3333
|
lockKey: LOCK_KEY,
|
|
@@ -3331,17 +3369,17 @@ var IFrameHostRuntime = class {
|
|
|
3331
3369
|
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
3332
3370
|
]);
|
|
3333
3371
|
this._ready.wake(void 0);
|
|
3334
|
-
(0,
|
|
3372
|
+
(0, import_log13.log)("started", {}, {
|
|
3335
3373
|
file: "iframe-host-runtime.ts",
|
|
3336
|
-
line:
|
|
3374
|
+
line: 115,
|
|
3337
3375
|
scope: this,
|
|
3338
3376
|
callSite: (f, a) => f(...a)
|
|
3339
3377
|
});
|
|
3340
3378
|
} catch (err) {
|
|
3341
3379
|
this._ready.wake(err);
|
|
3342
|
-
|
|
3380
|
+
import_log13.log.catch(err, {}, {
|
|
3343
3381
|
file: "iframe-host-runtime.ts",
|
|
3344
|
-
line:
|
|
3382
|
+
line: 118,
|
|
3345
3383
|
scope: this,
|
|
3346
3384
|
callSite: (f, a) => f(...a)
|
|
3347
3385
|
});
|
|
@@ -3349,37 +3387,38 @@ var IFrameHostRuntime = class {
|
|
|
3349
3387
|
}
|
|
3350
3388
|
async stop() {
|
|
3351
3389
|
var _a;
|
|
3352
|
-
(0,
|
|
3390
|
+
(0, import_log13.log)("stopping...", {}, {
|
|
3353
3391
|
file: "iframe-host-runtime.ts",
|
|
3354
|
-
line:
|
|
3392
|
+
line: 123,
|
|
3355
3393
|
scope: this,
|
|
3356
3394
|
callSite: (f, a) => f(...a)
|
|
3357
3395
|
});
|
|
3358
3396
|
await this._clientRpc.close();
|
|
3359
3397
|
await this._clientServices.close();
|
|
3360
3398
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3361
|
-
(0,
|
|
3399
|
+
(0, import_log13.log)("stopped", {}, {
|
|
3362
3400
|
file: "iframe-host-runtime.ts",
|
|
3363
|
-
line:
|
|
3401
|
+
line: 127,
|
|
3364
3402
|
scope: this,
|
|
3365
3403
|
callSite: (f, a) => f(...a)
|
|
3366
3404
|
});
|
|
3367
3405
|
}
|
|
3368
3406
|
};
|
|
3369
3407
|
__decorate3([
|
|
3370
|
-
|
|
3408
|
+
import_log13.logInfo
|
|
3371
3409
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
3372
3410
|
|
|
3373
3411
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3374
3412
|
var import_client5 = require("@dxos/client");
|
|
3375
3413
|
var import_errors5 = require("@dxos/errors");
|
|
3376
|
-
var
|
|
3414
|
+
var import_log14 = require("@dxos/log");
|
|
3377
3415
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
3378
3416
|
var import_rpc3 = require("@dxos/rpc");
|
|
3417
|
+
var import_util8 = require("@dxos/util");
|
|
3379
3418
|
|
|
3380
3419
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3381
|
-
var
|
|
3382
|
-
var
|
|
3420
|
+
var import_async17 = require("@dxos/async");
|
|
3421
|
+
var import_log15 = require("@dxos/log");
|
|
3383
3422
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
3384
3423
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3385
3424
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3397,7 +3436,7 @@ var Message;
|
|
|
3397
3436
|
var VaultResourceLock = class {
|
|
3398
3437
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3399
3438
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3400
|
-
this._releaseTrigger = new
|
|
3439
|
+
this._releaseTrigger = new import_async17.Trigger();
|
|
3401
3440
|
this._lockKey = lockKey;
|
|
3402
3441
|
this._onAcquire = onAcquire;
|
|
3403
3442
|
this._onRelease = onRelease;
|
|
@@ -3411,28 +3450,28 @@ var VaultResourceLock = class {
|
|
|
3411
3450
|
message: Message.ACQUIRING
|
|
3412
3451
|
});
|
|
3413
3452
|
try {
|
|
3414
|
-
(0,
|
|
3453
|
+
(0, import_log15.log)("aquiring lock...", {}, {
|
|
3415
3454
|
file: "vault-resource-lock.ts",
|
|
3416
3455
|
line: 44,
|
|
3417
3456
|
scope: this,
|
|
3418
3457
|
callSite: (f, a) => f(...a)
|
|
3419
3458
|
});
|
|
3420
|
-
await (0,
|
|
3421
|
-
(0,
|
|
3459
|
+
await (0, import_async17.asyncTimeout)(this._requestLock(), 3e3);
|
|
3460
|
+
(0, import_log15.log)("acquired lock", {}, {
|
|
3422
3461
|
file: "vault-resource-lock.ts",
|
|
3423
3462
|
line: 46,
|
|
3424
3463
|
scope: this,
|
|
3425
3464
|
callSite: (f, a) => f(...a)
|
|
3426
3465
|
});
|
|
3427
3466
|
} catch (e) {
|
|
3428
|
-
(0,
|
|
3467
|
+
(0, import_log15.log)("stealing lock...", {}, {
|
|
3429
3468
|
file: "vault-resource-lock.ts",
|
|
3430
3469
|
line: 48,
|
|
3431
3470
|
scope: this,
|
|
3432
3471
|
callSite: (f, a) => f(...a)
|
|
3433
3472
|
});
|
|
3434
3473
|
await this._requestLock(true);
|
|
3435
|
-
(0,
|
|
3474
|
+
(0, import_log15.log)("stolen lock", {}, {
|
|
3436
3475
|
file: "vault-resource-lock.ts",
|
|
3437
3476
|
line: 50,
|
|
3438
3477
|
scope: this,
|
|
@@ -3449,7 +3488,7 @@ var VaultResourceLock = class {
|
|
|
3449
3488
|
}
|
|
3450
3489
|
}
|
|
3451
3490
|
async _requestLock(steal = false) {
|
|
3452
|
-
(0,
|
|
3491
|
+
(0, import_log15.log)("requesting lock...", {
|
|
3453
3492
|
steal
|
|
3454
3493
|
}, {
|
|
3455
3494
|
file: "vault-resource-lock.ts",
|
|
@@ -3457,23 +3496,23 @@ var VaultResourceLock = class {
|
|
|
3457
3496
|
scope: this,
|
|
3458
3497
|
callSite: (f, a) => f(...a)
|
|
3459
3498
|
});
|
|
3460
|
-
const acquired = new
|
|
3499
|
+
const acquired = new import_async17.Trigger();
|
|
3461
3500
|
void navigator.locks.request(this._lockKey, {
|
|
3462
3501
|
steal
|
|
3463
3502
|
}, async () => {
|
|
3464
3503
|
var _a, _b;
|
|
3465
3504
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3466
3505
|
acquired.wake();
|
|
3467
|
-
this._releaseTrigger = new
|
|
3506
|
+
this._releaseTrigger = new import_async17.Trigger();
|
|
3468
3507
|
await this._releaseTrigger.wait();
|
|
3469
|
-
(0,
|
|
3508
|
+
(0, import_log15.log)("releasing lock...", {}, {
|
|
3470
3509
|
file: "vault-resource-lock.ts",
|
|
3471
3510
|
line: 74,
|
|
3472
3511
|
scope: this,
|
|
3473
3512
|
callSite: (f, a) => f(...a)
|
|
3474
3513
|
});
|
|
3475
3514
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3476
|
-
(0,
|
|
3515
|
+
(0, import_log15.log)("released lock", {}, {
|
|
3477
3516
|
file: "vault-resource-lock.ts",
|
|
3478
3517
|
line: 76,
|
|
3479
3518
|
scope: this,
|
|
@@ -3484,7 +3523,7 @@ var VaultResourceLock = class {
|
|
|
3484
3523
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3485
3524
|
});
|
|
3486
3525
|
await acquired.wait();
|
|
3487
|
-
(0,
|
|
3526
|
+
(0, import_log15.log)("recieved lock", {
|
|
3488
3527
|
steal
|
|
3489
3528
|
}, {
|
|
3490
3529
|
file: "vault-resource-lock.ts",
|
|
@@ -3495,22 +3534,22 @@ var VaultResourceLock = class {
|
|
|
3495
3534
|
}
|
|
3496
3535
|
};
|
|
3497
3536
|
__decorate4([
|
|
3498
|
-
|
|
3537
|
+
import_log15.logInfo
|
|
3499
3538
|
], VaultResourceLock.prototype, "lockKey", null);
|
|
3500
3539
|
|
|
3501
3540
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3502
|
-
var
|
|
3503
|
-
var
|
|
3541
|
+
var import_async19 = require("@dxos/async");
|
|
3542
|
+
var import_log17 = require("@dxos/log");
|
|
3504
3543
|
var import_messaging2 = require("@dxos/messaging");
|
|
3505
3544
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3506
3545
|
|
|
3507
3546
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3508
3547
|
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3509
|
-
var
|
|
3548
|
+
var import_async18 = require("@dxos/async");
|
|
3510
3549
|
var import_client6 = require("@dxos/client");
|
|
3511
|
-
var
|
|
3550
|
+
var import_log16 = require("@dxos/log");
|
|
3512
3551
|
var import_rpc4 = require("@dxos/rpc");
|
|
3513
|
-
var
|
|
3552
|
+
var import_util9 = require("@dxos/util");
|
|
3514
3553
|
var __decorate5 = function(decorators, target, key, desc) {
|
|
3515
3554
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3516
3555
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3525,8 +3564,8 @@ var WorkerSession = class {
|
|
|
3525
3564
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal, options = {
|
|
3526
3565
|
heartbeatInterval: 1e3
|
|
3527
3566
|
} }) {
|
|
3528
|
-
this._startTrigger = new
|
|
3529
|
-
this.onClose = new
|
|
3567
|
+
this._startTrigger = new import_async18.Trigger();
|
|
3568
|
+
this.onClose = new import_util9.Callback();
|
|
3530
3569
|
(0, import_node_assert12.default)(options);
|
|
3531
3570
|
(0, import_node_assert12.default)(serviceHost);
|
|
3532
3571
|
this._options = options;
|
|
@@ -3575,7 +3614,7 @@ var WorkerSession = class {
|
|
|
3575
3614
|
try {
|
|
3576
3615
|
await this.close();
|
|
3577
3616
|
} catch (err) {
|
|
3578
|
-
|
|
3617
|
+
import_log16.log.catch(err, {}, {
|
|
3579
3618
|
file: "worker-session.ts",
|
|
3580
3619
|
line: 107,
|
|
3581
3620
|
scope: this,
|
|
@@ -3593,7 +3632,7 @@ var WorkerSession = class {
|
|
|
3593
3632
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3594
3633
|
}
|
|
3595
3634
|
async open() {
|
|
3596
|
-
|
|
3635
|
+
import_log16.log.info("opening..", {}, {
|
|
3597
3636
|
file: "worker-session.ts",
|
|
3598
3637
|
line: 121,
|
|
3599
3638
|
scope: this,
|
|
@@ -3611,7 +3650,7 @@ var WorkerSession = class {
|
|
|
3611
3650
|
try {
|
|
3612
3651
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
3613
3652
|
} catch (err1) {
|
|
3614
|
-
|
|
3653
|
+
import_log16.log.warn("Heartbeat failed", {
|
|
3615
3654
|
err: err1
|
|
3616
3655
|
}, {
|
|
3617
3656
|
file: "worker-session.ts",
|
|
@@ -3622,7 +3661,7 @@ var WorkerSession = class {
|
|
|
3622
3661
|
try {
|
|
3623
3662
|
await this.close();
|
|
3624
3663
|
} catch (err) {
|
|
3625
|
-
|
|
3664
|
+
import_log16.log.catch(err, {}, {
|
|
3626
3665
|
file: "worker-session.ts",
|
|
3627
3666
|
line: 137,
|
|
3628
3667
|
scope: this,
|
|
@@ -3633,7 +3672,7 @@ var WorkerSession = class {
|
|
|
3633
3672
|
}, this._options.heartbeatInterval);
|
|
3634
3673
|
}
|
|
3635
3674
|
async close() {
|
|
3636
|
-
|
|
3675
|
+
import_log16.log.info("closing..", {}, {
|
|
3637
3676
|
file: "worker-session.ts",
|
|
3638
3677
|
line: 144,
|
|
3639
3678
|
scope: this,
|
|
@@ -3642,7 +3681,7 @@ var WorkerSession = class {
|
|
|
3642
3681
|
try {
|
|
3643
3682
|
await this.onClose.callIfSet();
|
|
3644
3683
|
} catch (err) {
|
|
3645
|
-
|
|
3684
|
+
import_log16.log.catch(err, {}, {
|
|
3646
3685
|
file: "worker-session.ts",
|
|
3647
3686
|
line: 148,
|
|
3648
3687
|
scope: this,
|
|
@@ -3659,9 +3698,9 @@ var WorkerSession = class {
|
|
|
3659
3698
|
}
|
|
3660
3699
|
async _maybeOpenShell() {
|
|
3661
3700
|
try {
|
|
3662
|
-
await (0,
|
|
3701
|
+
await (0, import_async18.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
3663
3702
|
} catch (e) {
|
|
3664
|
-
|
|
3703
|
+
import_log16.log.info("No shell connected.", {}, {
|
|
3665
3704
|
file: "worker-session.ts",
|
|
3666
3705
|
line: 162,
|
|
3667
3706
|
scope: this,
|
|
@@ -3671,12 +3710,12 @@ var WorkerSession = class {
|
|
|
3671
3710
|
}
|
|
3672
3711
|
};
|
|
3673
3712
|
__decorate5([
|
|
3674
|
-
|
|
3713
|
+
import_log16.logInfo
|
|
3675
3714
|
], WorkerSession.prototype, "origin", void 0);
|
|
3676
3715
|
|
|
3677
3716
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3678
3717
|
var import_node_assert13 = __toESM(require("node:assert"));
|
|
3679
|
-
var
|
|
3718
|
+
var import_async20 = require("@dxos/async");
|
|
3680
3719
|
var import_client7 = require("@dxos/client");
|
|
3681
3720
|
var import_credentials12 = require("@dxos/credentials");
|
|
3682
3721
|
var import_debug6 = require("@dxos/debug");
|
|
@@ -3684,7 +3723,7 @@ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
|
3684
3723
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3685
3724
|
var import_keyring = require("@dxos/keyring");
|
|
3686
3725
|
var import_keys11 = require("@dxos/keys");
|
|
3687
|
-
var
|
|
3726
|
+
var import_log18 = require("@dxos/log");
|
|
3688
3727
|
var import_protocols7 = require("@dxos/protocols");
|
|
3689
3728
|
var ServiceContext = class {
|
|
3690
3729
|
// prettier-ignore
|
|
@@ -3692,7 +3731,7 @@ var ServiceContext = class {
|
|
|
3692
3731
|
this.storage = storage;
|
|
3693
3732
|
this.networkManager = networkManager;
|
|
3694
3733
|
this.modelFactory = modelFactory;
|
|
3695
|
-
this.initialized = new
|
|
3734
|
+
this.initialized = new import_async20.Trigger();
|
|
3696
3735
|
this.dataServiceSubscriptions = new import_echo_pipeline4.DataServiceSubscriptions();
|
|
3697
3736
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3698
3737
|
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
@@ -3724,7 +3763,7 @@ var ServiceContext = class {
|
|
|
3724
3763
|
}, this._acceptIdentity.bind(this)));
|
|
3725
3764
|
}
|
|
3726
3765
|
async open() {
|
|
3727
|
-
|
|
3766
|
+
import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.begin({
|
|
3728
3767
|
id: this._instanceId
|
|
3729
3768
|
}), {
|
|
3730
3769
|
file: "service-context.ts",
|
|
@@ -3732,7 +3771,7 @@ var ServiceContext = class {
|
|
|
3732
3771
|
scope: this,
|
|
3733
3772
|
callSite: (f, a) => f(...a)
|
|
3734
3773
|
});
|
|
3735
|
-
(0,
|
|
3774
|
+
(0, import_log18.log)("opening...", {}, {
|
|
3736
3775
|
file: "service-context.ts",
|
|
3737
3776
|
line: 117,
|
|
3738
3777
|
scope: this,
|
|
@@ -3744,7 +3783,7 @@ var ServiceContext = class {
|
|
|
3744
3783
|
if (this.identityManager.identity) {
|
|
3745
3784
|
await this._initialize();
|
|
3746
3785
|
}
|
|
3747
|
-
(0,
|
|
3786
|
+
(0, import_log18.log)("opened", {}, {
|
|
3748
3787
|
file: "service-context.ts",
|
|
3749
3788
|
line: 124,
|
|
3750
3789
|
scope: this,
|
|
@@ -3753,7 +3792,7 @@ var ServiceContext = class {
|
|
|
3753
3792
|
}
|
|
3754
3793
|
async close() {
|
|
3755
3794
|
var _a, _b;
|
|
3756
|
-
(0,
|
|
3795
|
+
(0, import_log18.log)("closing...", {}, {
|
|
3757
3796
|
file: "service-context.ts",
|
|
3758
3797
|
line: 128,
|
|
3759
3798
|
scope: this,
|
|
@@ -3766,13 +3805,13 @@ var ServiceContext = class {
|
|
|
3766
3805
|
await this.feedStore.close();
|
|
3767
3806
|
await this.networkManager.close();
|
|
3768
3807
|
this.dataServiceSubscriptions.clear();
|
|
3769
|
-
(0,
|
|
3808
|
+
(0, import_log18.log)("closed", {}, {
|
|
3770
3809
|
file: "service-context.ts",
|
|
3771
3810
|
line: 136,
|
|
3772
3811
|
scope: this,
|
|
3773
3812
|
callSite: (f, a) => f(...a)
|
|
3774
3813
|
});
|
|
3775
|
-
|
|
3814
|
+
import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.end({
|
|
3776
3815
|
id: this._instanceId
|
|
3777
3816
|
}), {
|
|
3778
3817
|
file: "service-context.ts",
|
|
@@ -3799,7 +3838,7 @@ var ServiceContext = class {
|
|
|
3799
3838
|
// Called when identity is created.
|
|
3800
3839
|
async _initialize() {
|
|
3801
3840
|
var _a;
|
|
3802
|
-
(0,
|
|
3841
|
+
(0, import_log18.log)("initializing spaces...", {}, {
|
|
3803
3842
|
file: "service-context.ts",
|
|
3804
3843
|
line: 163,
|
|
3805
3844
|
scope: this,
|
|
@@ -3837,7 +3876,7 @@ var ServiceContext = class {
|
|
|
3837
3876
|
return;
|
|
3838
3877
|
}
|
|
3839
3878
|
if (!this.dataSpaceManager) {
|
|
3840
|
-
(0,
|
|
3879
|
+
(0, import_log18.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3841
3880
|
details: assertion
|
|
3842
3881
|
}, {
|
|
3843
3882
|
file: "service-context.ts",
|
|
@@ -3848,7 +3887,7 @@ var ServiceContext = class {
|
|
|
3848
3887
|
return;
|
|
3849
3888
|
}
|
|
3850
3889
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3851
|
-
(0,
|
|
3890
|
+
(0, import_log18.log)("space already exists, ignoring space admission", {
|
|
3852
3891
|
details: assertion
|
|
3853
3892
|
}, {
|
|
3854
3893
|
file: "service-context.ts",
|
|
@@ -3859,7 +3898,7 @@ var ServiceContext = class {
|
|
|
3859
3898
|
return;
|
|
3860
3899
|
}
|
|
3861
3900
|
try {
|
|
3862
|
-
(0,
|
|
3901
|
+
(0, import_log18.log)("accepting space recorded in halo", {
|
|
3863
3902
|
details: assertion
|
|
3864
3903
|
}, {
|
|
3865
3904
|
file: "service-context.ts",
|
|
@@ -3872,7 +3911,7 @@ var ServiceContext = class {
|
|
|
3872
3911
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3873
3912
|
});
|
|
3874
3913
|
} catch (err) {
|
|
3875
|
-
|
|
3914
|
+
import_log18.log.catch(err, {}, {
|
|
3876
3915
|
file: "service-context.ts",
|
|
3877
3916
|
line: 220,
|
|
3878
3917
|
scope: this,
|
|
@@ -3920,7 +3959,7 @@ var ClientServicesHost = class {
|
|
|
3920
3959
|
// TODO(wittjosiah): Turn this on by default.
|
|
3921
3960
|
lockKey
|
|
3922
3961
|
} = {}) {
|
|
3923
|
-
this._statusUpdate = new
|
|
3962
|
+
this._statusUpdate = new import_async21.Event();
|
|
3924
3963
|
this._opening = false;
|
|
3925
3964
|
this._open = false;
|
|
3926
3965
|
this._instanceId = import_client8.PublicKey.random().toHex();
|
|
@@ -3955,6 +3994,7 @@ var ClientServicesHost = class {
|
|
|
3955
3994
|
await this.reset();
|
|
3956
3995
|
}
|
|
3957
3996
|
});
|
|
3997
|
+
this._loggingService = new LoggingServiceImpl();
|
|
3958
3998
|
this._serviceRegistry = new ServiceRegistry(import_client8.clientServiceBundle, {
|
|
3959
3999
|
SystemService: this._systemService
|
|
3960
4000
|
});
|
|
@@ -3995,11 +4035,11 @@ var ClientServicesHost = class {
|
|
|
3995
4035
|
if (this._open) {
|
|
3996
4036
|
return;
|
|
3997
4037
|
}
|
|
3998
|
-
|
|
4038
|
+
import_log19.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.begin({
|
|
3999
4039
|
id: this._instanceId
|
|
4000
4040
|
}), {
|
|
4001
4041
|
file: "service-host.ts",
|
|
4002
|
-
line:
|
|
4042
|
+
line: 169,
|
|
4003
4043
|
scope: this,
|
|
4004
4044
|
callSite: (f, a) => f(...a)
|
|
4005
4045
|
});
|
|
@@ -4007,15 +4047,16 @@ var ClientServicesHost = class {
|
|
|
4007
4047
|
(0, import_node_assert14.default)(this._storage, "storage not set");
|
|
4008
4048
|
(0, import_node_assert14.default)(this._networkManager, "network manager not set");
|
|
4009
4049
|
this._opening = true;
|
|
4010
|
-
(0,
|
|
4050
|
+
(0, import_log19.log)("opening...", {
|
|
4011
4051
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
4012
4052
|
}, {
|
|
4013
4053
|
file: "service-host.ts",
|
|
4014
|
-
line:
|
|
4054
|
+
line: 176,
|
|
4015
4055
|
scope: this,
|
|
4016
4056
|
callSite: (f, a) => f(...a)
|
|
4017
4057
|
});
|
|
4018
4058
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
4059
|
+
await this._loggingService.open();
|
|
4019
4060
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
|
|
4020
4061
|
this._serviceRegistry.setServices({
|
|
4021
4062
|
SystemService: this._systemService,
|
|
@@ -4028,8 +4069,8 @@ var ClientServicesHost = class {
|
|
|
4028
4069
|
}),
|
|
4029
4070
|
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4030
4071
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
|
|
4072
|
+
LoggingService: this._loggingService,
|
|
4031
4073
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4032
|
-
TracingService: new TracingServiceImpl(this._config),
|
|
4033
4074
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4034
4075
|
events: new DevtoolsHostEvents(),
|
|
4035
4076
|
config: this._config,
|
|
@@ -4041,11 +4082,11 @@ var ClientServicesHost = class {
|
|
|
4041
4082
|
this._open = true;
|
|
4042
4083
|
this._statusUpdate.emit();
|
|
4043
4084
|
const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
|
|
4044
|
-
(0,
|
|
4085
|
+
(0, import_log19.log)("opened", {
|
|
4045
4086
|
deviceKey
|
|
4046
4087
|
}, {
|
|
4047
4088
|
file: "service-host.ts",
|
|
4048
|
-
line:
|
|
4089
|
+
line: 226,
|
|
4049
4090
|
scope: this,
|
|
4050
4091
|
callSite: (f, a) => f(...a)
|
|
4051
4092
|
});
|
|
@@ -4056,50 +4097,51 @@ var ClientServicesHost = class {
|
|
|
4056
4097
|
return;
|
|
4057
4098
|
}
|
|
4058
4099
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
4059
|
-
(0,
|
|
4100
|
+
(0, import_log19.log)("closing...", {
|
|
4060
4101
|
deviceKey
|
|
4061
4102
|
}, {
|
|
4062
4103
|
file: "service-host.ts",
|
|
4063
|
-
line:
|
|
4104
|
+
line: 235,
|
|
4064
4105
|
scope: this,
|
|
4065
4106
|
callSite: (f, a) => f(...a)
|
|
4066
4107
|
});
|
|
4067
4108
|
this._serviceRegistry.setServices({
|
|
4068
4109
|
SystemService: this._systemService
|
|
4069
4110
|
});
|
|
4111
|
+
await this._loggingService.close();
|
|
4070
4112
|
await this._serviceContext.close();
|
|
4071
4113
|
this._open = false;
|
|
4072
4114
|
this._statusUpdate.emit();
|
|
4073
|
-
(0,
|
|
4115
|
+
(0, import_log19.log)("closed", {
|
|
4074
4116
|
deviceKey
|
|
4075
4117
|
}, {
|
|
4076
4118
|
file: "service-host.ts",
|
|
4077
|
-
line:
|
|
4119
|
+
line: 241,
|
|
4078
4120
|
scope: this,
|
|
4079
4121
|
callSite: (f, a) => f(...a)
|
|
4080
4122
|
});
|
|
4081
|
-
|
|
4123
|
+
import_log19.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.end({
|
|
4082
4124
|
id: this._instanceId
|
|
4083
4125
|
}), {
|
|
4084
4126
|
file: "service-host.ts",
|
|
4085
|
-
line:
|
|
4127
|
+
line: 243,
|
|
4086
4128
|
scope: this,
|
|
4087
4129
|
callSite: (f, a) => f(...a)
|
|
4088
4130
|
});
|
|
4089
4131
|
}
|
|
4090
4132
|
async reset() {
|
|
4091
4133
|
var _a;
|
|
4092
|
-
(0,
|
|
4134
|
+
(0, import_log19.log)("resetting...", {}, {
|
|
4093
4135
|
file: "service-host.ts",
|
|
4094
|
-
line:
|
|
4136
|
+
line: 247,
|
|
4095
4137
|
scope: this,
|
|
4096
4138
|
callSite: (f, a) => f(...a)
|
|
4097
4139
|
});
|
|
4098
4140
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
4099
4141
|
await this._storage.reset();
|
|
4100
|
-
(0,
|
|
4142
|
+
(0, import_log19.log)("reset", {}, {
|
|
4101
4143
|
file: "service-host.ts",
|
|
4102
|
-
line:
|
|
4144
|
+
line: 250,
|
|
4103
4145
|
scope: this,
|
|
4104
4146
|
callSite: (f, a) => f(...a)
|
|
4105
4147
|
});
|
|
@@ -4130,7 +4172,7 @@ var LocalClientServices = class {
|
|
|
4130
4172
|
|
|
4131
4173
|
// packages/sdk/client-services/src/packlets/services/utils.ts
|
|
4132
4174
|
var import_config2 = require("@dxos/config");
|
|
4133
|
-
var
|
|
4175
|
+
var import_log20 = require("@dxos/log");
|
|
4134
4176
|
var import_messaging3 = require("@dxos/messaging");
|
|
4135
4177
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
4136
4178
|
|
|
@@ -4248,7 +4290,7 @@ var createSigningContext = async (keyring) => {
|
|
|
4248
4290
|
|
|
4249
4291
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
4250
4292
|
var import_node_assert15 = __toESM(require("node:assert"));
|
|
4251
|
-
var
|
|
4293
|
+
var import_async22 = require("@dxos/async");
|
|
4252
4294
|
var import_client10 = require("@dxos/client");
|
|
4253
4295
|
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4254
4296
|
var sanitizeInvitation = (invitation) => {
|
|
@@ -4263,9 +4305,9 @@ var sanitizeInvitation = (invitation) => {
|
|
|
4263
4305
|
};
|
|
4264
4306
|
};
|
|
4265
4307
|
var performInvitation = ({ host, guest, options, hooks }) => {
|
|
4266
|
-
const hostComplete = new
|
|
4267
|
-
const guestComplete = new
|
|
4268
|
-
const authCode = new
|
|
4308
|
+
const hostComplete = new import_async22.Trigger();
|
|
4309
|
+
const guestComplete = new import_async22.Trigger();
|
|
4310
|
+
const authCode = new import_async22.Trigger();
|
|
4269
4311
|
const hostObservable = createInvitation(host, options);
|
|
4270
4312
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
4271
4313
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
@@ -4424,14 +4466,14 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4424
4466
|
|
|
4425
4467
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4426
4468
|
var import_node_assert16 = __toESM(require("node:assert"));
|
|
4427
|
-
var
|
|
4469
|
+
var import_async23 = require("@dxos/async");
|
|
4428
4470
|
var import_client11 = require("@dxos/client");
|
|
4429
4471
|
var import_config3 = require("@dxos/config");
|
|
4430
4472
|
var import_debug7 = require("@dxos/debug");
|
|
4431
4473
|
var import_document_model = require("@dxos/document-model");
|
|
4432
4474
|
var import_echo_db = require("@dxos/echo-db");
|
|
4433
4475
|
var import_keys12 = require("@dxos/keys");
|
|
4434
|
-
var
|
|
4476
|
+
var import_log21 = require("@dxos/log");
|
|
4435
4477
|
var import_messaging5 = require("@dxos/messaging");
|
|
4436
4478
|
var import_network_manager7 = require("@dxos/network-manager");
|
|
4437
4479
|
var import_rpc5 = require("@dxos/rpc");
|
|
@@ -4524,7 +4566,7 @@ var testSpace = async (create, check = create) => {
|
|
|
4524
4566
|
const result = create.mutate((0, import_echo_db.genesisMutation)(objectId, import_document_model.DocumentModel.meta.type));
|
|
4525
4567
|
await result.batch.getReceipt();
|
|
4526
4568
|
(0, import_node_assert16.default)(create._itemManager.entities.has(result.objectsUpdated[0].id));
|
|
4527
|
-
await (0,
|
|
4569
|
+
await (0, import_async23.asyncTimeout)(check.itemUpdate.waitForCondition(() => check._itemManager.entities.has(objectId)), 1e3);
|
|
4528
4570
|
return result;
|
|
4529
4571
|
};
|
|
4530
4572
|
var syncItems = async (db1, db2) => {
|
|
@@ -4535,12 +4577,12 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4535
4577
|
const rootSpace = spaceKey ? initialPeer.getSpace(spaceKey) : await initialPeer.createSpace();
|
|
4536
4578
|
(0, import_node_assert16.default)(rootSpace, "Space not found.");
|
|
4537
4579
|
await Promise.all(peers.map(async (peer) => {
|
|
4538
|
-
const hostDone = new
|
|
4539
|
-
const guestDone = new
|
|
4580
|
+
const hostDone = new import_async23.Trigger();
|
|
4581
|
+
const guestDone = new import_async23.Trigger();
|
|
4540
4582
|
const hostObservable = rootSpace.createInvitation({
|
|
4541
4583
|
authMethod: import_client11.Invitation.AuthMethod.NONE
|
|
4542
4584
|
});
|
|
4543
|
-
(0,
|
|
4585
|
+
(0, import_log21.log)("invitation created", {}, {
|
|
4544
4586
|
file: "test-builder.ts",
|
|
4545
4587
|
line: 156,
|
|
4546
4588
|
scope: void 0,
|
|
@@ -4550,7 +4592,7 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4550
4592
|
switch (hostInvitation.state) {
|
|
4551
4593
|
case import_client11.Invitation.State.CONNECTING: {
|
|
4552
4594
|
const guestObservable = peer.acceptInvitation(hostInvitation);
|
|
4553
|
-
(0,
|
|
4595
|
+
(0, import_log21.log)("invitation accepted", {}, {
|
|
4554
4596
|
file: "test-builder.ts",
|
|
4555
4597
|
line: 162,
|
|
4556
4598
|
scope: void 0,
|
|
@@ -4560,7 +4602,7 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4560
4602
|
switch (guestInvitation.state) {
|
|
4561
4603
|
case import_client11.Invitation.State.SUCCESS: {
|
|
4562
4604
|
guestDone.wake(guestInvitation);
|
|
4563
|
-
(0,
|
|
4605
|
+
(0, import_log21.log)("invitation guestDone", {}, {
|
|
4564
4606
|
file: "test-builder.ts",
|
|
4565
4607
|
line: 169,
|
|
4566
4608
|
scope: void 0,
|
|
@@ -4574,7 +4616,7 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4574
4616
|
}
|
|
4575
4617
|
case import_client11.Invitation.State.SUCCESS: {
|
|
4576
4618
|
hostDone.wake(hostInvitation);
|
|
4577
|
-
(0,
|
|
4619
|
+
(0, import_log21.log)("invitation hostDone", {}, {
|
|
4578
4620
|
file: "test-builder.ts",
|
|
4579
4621
|
line: 181,
|
|
4580
4622
|
scope: void 0,
|