@dxos/client-services 0.1.41-next.adfd7c6 → 0.1.42-next.6e229fb
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-6DELP6G3.mjs} +231 -213
- package/dist/lib/browser/chunk-6DELP6G3.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 +270 -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 +258 -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 +4 -4
- 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 +10 -15
- 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,9 @@ 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, appPort, shellPort }) {
|
|
3303
|
+
this._ready = new import_async16.Trigger();
|
|
3304
|
+
this._configProvider = config;
|
|
3271
3305
|
this._appPort = appPort;
|
|
3272
3306
|
this._shellPort = shellPort;
|
|
3273
3307
|
if (this._shellPort) {
|
|
@@ -3282,14 +3316,17 @@ var IFrameHostRuntime = class {
|
|
|
3282
3316
|
}
|
|
3283
3317
|
async start() {
|
|
3284
3318
|
var _a;
|
|
3285
|
-
(0,
|
|
3319
|
+
(0, import_log13.log)("starting...", {}, {
|
|
3286
3320
|
file: "iframe-host-runtime.ts",
|
|
3287
|
-
line:
|
|
3321
|
+
line: 67,
|
|
3288
3322
|
scope: this,
|
|
3289
3323
|
callSite: (f, a) => f(...a)
|
|
3290
3324
|
});
|
|
3291
3325
|
try {
|
|
3292
3326
|
this._config = await (0, import_util7.getAsyncValue)(this._configProvider);
|
|
3327
|
+
this._transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
|
|
3328
|
+
iceServers: this._config.get("runtime.services.ice")
|
|
3329
|
+
});
|
|
3293
3330
|
const signals = this._config.get("runtime.services.signaling");
|
|
3294
3331
|
this._clientServices = new LocalClientServices({
|
|
3295
3332
|
lockKey: LOCK_KEY,
|
|
@@ -3331,17 +3368,17 @@ var IFrameHostRuntime = class {
|
|
|
3331
3368
|
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
3332
3369
|
]);
|
|
3333
3370
|
this._ready.wake(void 0);
|
|
3334
|
-
(0,
|
|
3371
|
+
(0, import_log13.log)("started", {}, {
|
|
3335
3372
|
file: "iframe-host-runtime.ts",
|
|
3336
|
-
line:
|
|
3373
|
+
line: 113,
|
|
3337
3374
|
scope: this,
|
|
3338
3375
|
callSite: (f, a) => f(...a)
|
|
3339
3376
|
});
|
|
3340
3377
|
} catch (err) {
|
|
3341
3378
|
this._ready.wake(err);
|
|
3342
|
-
|
|
3379
|
+
import_log13.log.catch(err, {}, {
|
|
3343
3380
|
file: "iframe-host-runtime.ts",
|
|
3344
|
-
line:
|
|
3381
|
+
line: 116,
|
|
3345
3382
|
scope: this,
|
|
3346
3383
|
callSite: (f, a) => f(...a)
|
|
3347
3384
|
});
|
|
@@ -3349,37 +3386,38 @@ var IFrameHostRuntime = class {
|
|
|
3349
3386
|
}
|
|
3350
3387
|
async stop() {
|
|
3351
3388
|
var _a;
|
|
3352
|
-
(0,
|
|
3389
|
+
(0, import_log13.log)("stopping...", {}, {
|
|
3353
3390
|
file: "iframe-host-runtime.ts",
|
|
3354
|
-
line:
|
|
3391
|
+
line: 121,
|
|
3355
3392
|
scope: this,
|
|
3356
3393
|
callSite: (f, a) => f(...a)
|
|
3357
3394
|
});
|
|
3358
3395
|
await this._clientRpc.close();
|
|
3359
3396
|
await this._clientServices.close();
|
|
3360
3397
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3361
|
-
(0,
|
|
3398
|
+
(0, import_log13.log)("stopped", {}, {
|
|
3362
3399
|
file: "iframe-host-runtime.ts",
|
|
3363
|
-
line:
|
|
3400
|
+
line: 125,
|
|
3364
3401
|
scope: this,
|
|
3365
3402
|
callSite: (f, a) => f(...a)
|
|
3366
3403
|
});
|
|
3367
3404
|
}
|
|
3368
3405
|
};
|
|
3369
3406
|
__decorate3([
|
|
3370
|
-
|
|
3407
|
+
import_log13.logInfo
|
|
3371
3408
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
3372
3409
|
|
|
3373
3410
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3374
3411
|
var import_client5 = require("@dxos/client");
|
|
3375
3412
|
var import_errors5 = require("@dxos/errors");
|
|
3376
|
-
var
|
|
3413
|
+
var import_log14 = require("@dxos/log");
|
|
3377
3414
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
3378
3415
|
var import_rpc3 = require("@dxos/rpc");
|
|
3416
|
+
var import_util8 = require("@dxos/util");
|
|
3379
3417
|
|
|
3380
3418
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3381
|
-
var
|
|
3382
|
-
var
|
|
3419
|
+
var import_async17 = require("@dxos/async");
|
|
3420
|
+
var import_log15 = require("@dxos/log");
|
|
3383
3421
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
3384
3422
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3385
3423
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3397,7 +3435,7 @@ var Message;
|
|
|
3397
3435
|
var VaultResourceLock = class {
|
|
3398
3436
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3399
3437
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3400
|
-
this._releaseTrigger = new
|
|
3438
|
+
this._releaseTrigger = new import_async17.Trigger();
|
|
3401
3439
|
this._lockKey = lockKey;
|
|
3402
3440
|
this._onAcquire = onAcquire;
|
|
3403
3441
|
this._onRelease = onRelease;
|
|
@@ -3411,28 +3449,28 @@ var VaultResourceLock = class {
|
|
|
3411
3449
|
message: Message.ACQUIRING
|
|
3412
3450
|
});
|
|
3413
3451
|
try {
|
|
3414
|
-
(0,
|
|
3452
|
+
(0, import_log15.log)("aquiring lock...", {}, {
|
|
3415
3453
|
file: "vault-resource-lock.ts",
|
|
3416
3454
|
line: 44,
|
|
3417
3455
|
scope: this,
|
|
3418
3456
|
callSite: (f, a) => f(...a)
|
|
3419
3457
|
});
|
|
3420
|
-
await (0,
|
|
3421
|
-
(0,
|
|
3458
|
+
await (0, import_async17.asyncTimeout)(this._requestLock(), 3e3);
|
|
3459
|
+
(0, import_log15.log)("acquired lock", {}, {
|
|
3422
3460
|
file: "vault-resource-lock.ts",
|
|
3423
3461
|
line: 46,
|
|
3424
3462
|
scope: this,
|
|
3425
3463
|
callSite: (f, a) => f(...a)
|
|
3426
3464
|
});
|
|
3427
3465
|
} catch (e) {
|
|
3428
|
-
(0,
|
|
3466
|
+
(0, import_log15.log)("stealing lock...", {}, {
|
|
3429
3467
|
file: "vault-resource-lock.ts",
|
|
3430
3468
|
line: 48,
|
|
3431
3469
|
scope: this,
|
|
3432
3470
|
callSite: (f, a) => f(...a)
|
|
3433
3471
|
});
|
|
3434
3472
|
await this._requestLock(true);
|
|
3435
|
-
(0,
|
|
3473
|
+
(0, import_log15.log)("stolen lock", {}, {
|
|
3436
3474
|
file: "vault-resource-lock.ts",
|
|
3437
3475
|
line: 50,
|
|
3438
3476
|
scope: this,
|
|
@@ -3449,7 +3487,7 @@ var VaultResourceLock = class {
|
|
|
3449
3487
|
}
|
|
3450
3488
|
}
|
|
3451
3489
|
async _requestLock(steal = false) {
|
|
3452
|
-
(0,
|
|
3490
|
+
(0, import_log15.log)("requesting lock...", {
|
|
3453
3491
|
steal
|
|
3454
3492
|
}, {
|
|
3455
3493
|
file: "vault-resource-lock.ts",
|
|
@@ -3457,23 +3495,23 @@ var VaultResourceLock = class {
|
|
|
3457
3495
|
scope: this,
|
|
3458
3496
|
callSite: (f, a) => f(...a)
|
|
3459
3497
|
});
|
|
3460
|
-
const acquired = new
|
|
3498
|
+
const acquired = new import_async17.Trigger();
|
|
3461
3499
|
void navigator.locks.request(this._lockKey, {
|
|
3462
3500
|
steal
|
|
3463
3501
|
}, async () => {
|
|
3464
3502
|
var _a, _b;
|
|
3465
3503
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3466
3504
|
acquired.wake();
|
|
3467
|
-
this._releaseTrigger = new
|
|
3505
|
+
this._releaseTrigger = new import_async17.Trigger();
|
|
3468
3506
|
await this._releaseTrigger.wait();
|
|
3469
|
-
(0,
|
|
3507
|
+
(0, import_log15.log)("releasing lock...", {}, {
|
|
3470
3508
|
file: "vault-resource-lock.ts",
|
|
3471
3509
|
line: 74,
|
|
3472
3510
|
scope: this,
|
|
3473
3511
|
callSite: (f, a) => f(...a)
|
|
3474
3512
|
});
|
|
3475
3513
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3476
|
-
(0,
|
|
3514
|
+
(0, import_log15.log)("released lock", {}, {
|
|
3477
3515
|
file: "vault-resource-lock.ts",
|
|
3478
3516
|
line: 76,
|
|
3479
3517
|
scope: this,
|
|
@@ -3484,7 +3522,7 @@ var VaultResourceLock = class {
|
|
|
3484
3522
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3485
3523
|
});
|
|
3486
3524
|
await acquired.wait();
|
|
3487
|
-
(0,
|
|
3525
|
+
(0, import_log15.log)("recieved lock", {
|
|
3488
3526
|
steal
|
|
3489
3527
|
}, {
|
|
3490
3528
|
file: "vault-resource-lock.ts",
|
|
@@ -3495,22 +3533,22 @@ var VaultResourceLock = class {
|
|
|
3495
3533
|
}
|
|
3496
3534
|
};
|
|
3497
3535
|
__decorate4([
|
|
3498
|
-
|
|
3536
|
+
import_log15.logInfo
|
|
3499
3537
|
], VaultResourceLock.prototype, "lockKey", null);
|
|
3500
3538
|
|
|
3501
3539
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3502
|
-
var
|
|
3503
|
-
var
|
|
3540
|
+
var import_async19 = require("@dxos/async");
|
|
3541
|
+
var import_log17 = require("@dxos/log");
|
|
3504
3542
|
var import_messaging2 = require("@dxos/messaging");
|
|
3505
3543
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3506
3544
|
|
|
3507
3545
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3508
3546
|
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3509
|
-
var
|
|
3547
|
+
var import_async18 = require("@dxos/async");
|
|
3510
3548
|
var import_client6 = require("@dxos/client");
|
|
3511
|
-
var
|
|
3549
|
+
var import_log16 = require("@dxos/log");
|
|
3512
3550
|
var import_rpc4 = require("@dxos/rpc");
|
|
3513
|
-
var
|
|
3551
|
+
var import_util9 = require("@dxos/util");
|
|
3514
3552
|
var __decorate5 = function(decorators, target, key, desc) {
|
|
3515
3553
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3516
3554
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3525,8 +3563,8 @@ var WorkerSession = class {
|
|
|
3525
3563
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal, options = {
|
|
3526
3564
|
heartbeatInterval: 1e3
|
|
3527
3565
|
} }) {
|
|
3528
|
-
this._startTrigger = new
|
|
3529
|
-
this.onClose = new
|
|
3566
|
+
this._startTrigger = new import_async18.Trigger();
|
|
3567
|
+
this.onClose = new import_util9.Callback();
|
|
3530
3568
|
(0, import_node_assert12.default)(options);
|
|
3531
3569
|
(0, import_node_assert12.default)(serviceHost);
|
|
3532
3570
|
this._options = options;
|
|
@@ -3575,7 +3613,7 @@ var WorkerSession = class {
|
|
|
3575
3613
|
try {
|
|
3576
3614
|
await this.close();
|
|
3577
3615
|
} catch (err) {
|
|
3578
|
-
|
|
3616
|
+
import_log16.log.catch(err, {}, {
|
|
3579
3617
|
file: "worker-session.ts",
|
|
3580
3618
|
line: 107,
|
|
3581
3619
|
scope: this,
|
|
@@ -3593,7 +3631,7 @@ var WorkerSession = class {
|
|
|
3593
3631
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3594
3632
|
}
|
|
3595
3633
|
async open() {
|
|
3596
|
-
|
|
3634
|
+
import_log16.log.info("opening..", {}, {
|
|
3597
3635
|
file: "worker-session.ts",
|
|
3598
3636
|
line: 121,
|
|
3599
3637
|
scope: this,
|
|
@@ -3611,7 +3649,7 @@ var WorkerSession = class {
|
|
|
3611
3649
|
try {
|
|
3612
3650
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
3613
3651
|
} catch (err1) {
|
|
3614
|
-
|
|
3652
|
+
import_log16.log.warn("Heartbeat failed", {
|
|
3615
3653
|
err: err1
|
|
3616
3654
|
}, {
|
|
3617
3655
|
file: "worker-session.ts",
|
|
@@ -3622,7 +3660,7 @@ var WorkerSession = class {
|
|
|
3622
3660
|
try {
|
|
3623
3661
|
await this.close();
|
|
3624
3662
|
} catch (err) {
|
|
3625
|
-
|
|
3663
|
+
import_log16.log.catch(err, {}, {
|
|
3626
3664
|
file: "worker-session.ts",
|
|
3627
3665
|
line: 137,
|
|
3628
3666
|
scope: this,
|
|
@@ -3633,7 +3671,7 @@ var WorkerSession = class {
|
|
|
3633
3671
|
}, this._options.heartbeatInterval);
|
|
3634
3672
|
}
|
|
3635
3673
|
async close() {
|
|
3636
|
-
|
|
3674
|
+
import_log16.log.info("closing..", {}, {
|
|
3637
3675
|
file: "worker-session.ts",
|
|
3638
3676
|
line: 144,
|
|
3639
3677
|
scope: this,
|
|
@@ -3642,7 +3680,7 @@ var WorkerSession = class {
|
|
|
3642
3680
|
try {
|
|
3643
3681
|
await this.onClose.callIfSet();
|
|
3644
3682
|
} catch (err) {
|
|
3645
|
-
|
|
3683
|
+
import_log16.log.catch(err, {}, {
|
|
3646
3684
|
file: "worker-session.ts",
|
|
3647
3685
|
line: 148,
|
|
3648
3686
|
scope: this,
|
|
@@ -3659,9 +3697,9 @@ var WorkerSession = class {
|
|
|
3659
3697
|
}
|
|
3660
3698
|
async _maybeOpenShell() {
|
|
3661
3699
|
try {
|
|
3662
|
-
await (0,
|
|
3700
|
+
await (0, import_async18.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
3663
3701
|
} catch (e) {
|
|
3664
|
-
|
|
3702
|
+
import_log16.log.info("No shell connected.", {}, {
|
|
3665
3703
|
file: "worker-session.ts",
|
|
3666
3704
|
line: 162,
|
|
3667
3705
|
scope: this,
|
|
@@ -3671,12 +3709,12 @@ var WorkerSession = class {
|
|
|
3671
3709
|
}
|
|
3672
3710
|
};
|
|
3673
3711
|
__decorate5([
|
|
3674
|
-
|
|
3712
|
+
import_log16.logInfo
|
|
3675
3713
|
], WorkerSession.prototype, "origin", void 0);
|
|
3676
3714
|
|
|
3677
3715
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3678
3716
|
var import_node_assert13 = __toESM(require("node:assert"));
|
|
3679
|
-
var
|
|
3717
|
+
var import_async20 = require("@dxos/async");
|
|
3680
3718
|
var import_client7 = require("@dxos/client");
|
|
3681
3719
|
var import_credentials12 = require("@dxos/credentials");
|
|
3682
3720
|
var import_debug6 = require("@dxos/debug");
|
|
@@ -3684,7 +3722,7 @@ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
|
3684
3722
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3685
3723
|
var import_keyring = require("@dxos/keyring");
|
|
3686
3724
|
var import_keys11 = require("@dxos/keys");
|
|
3687
|
-
var
|
|
3725
|
+
var import_log18 = require("@dxos/log");
|
|
3688
3726
|
var import_protocols7 = require("@dxos/protocols");
|
|
3689
3727
|
var ServiceContext = class {
|
|
3690
3728
|
// prettier-ignore
|
|
@@ -3692,7 +3730,7 @@ var ServiceContext = class {
|
|
|
3692
3730
|
this.storage = storage;
|
|
3693
3731
|
this.networkManager = networkManager;
|
|
3694
3732
|
this.modelFactory = modelFactory;
|
|
3695
|
-
this.initialized = new
|
|
3733
|
+
this.initialized = new import_async20.Trigger();
|
|
3696
3734
|
this.dataServiceSubscriptions = new import_echo_pipeline4.DataServiceSubscriptions();
|
|
3697
3735
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3698
3736
|
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
@@ -3724,7 +3762,7 @@ var ServiceContext = class {
|
|
|
3724
3762
|
}, this._acceptIdentity.bind(this)));
|
|
3725
3763
|
}
|
|
3726
3764
|
async open() {
|
|
3727
|
-
|
|
3765
|
+
import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.begin({
|
|
3728
3766
|
id: this._instanceId
|
|
3729
3767
|
}), {
|
|
3730
3768
|
file: "service-context.ts",
|
|
@@ -3732,7 +3770,7 @@ var ServiceContext = class {
|
|
|
3732
3770
|
scope: this,
|
|
3733
3771
|
callSite: (f, a) => f(...a)
|
|
3734
3772
|
});
|
|
3735
|
-
(0,
|
|
3773
|
+
(0, import_log18.log)("opening...", {}, {
|
|
3736
3774
|
file: "service-context.ts",
|
|
3737
3775
|
line: 117,
|
|
3738
3776
|
scope: this,
|
|
@@ -3744,7 +3782,7 @@ var ServiceContext = class {
|
|
|
3744
3782
|
if (this.identityManager.identity) {
|
|
3745
3783
|
await this._initialize();
|
|
3746
3784
|
}
|
|
3747
|
-
(0,
|
|
3785
|
+
(0, import_log18.log)("opened", {}, {
|
|
3748
3786
|
file: "service-context.ts",
|
|
3749
3787
|
line: 124,
|
|
3750
3788
|
scope: this,
|
|
@@ -3753,7 +3791,7 @@ var ServiceContext = class {
|
|
|
3753
3791
|
}
|
|
3754
3792
|
async close() {
|
|
3755
3793
|
var _a, _b;
|
|
3756
|
-
(0,
|
|
3794
|
+
(0, import_log18.log)("closing...", {}, {
|
|
3757
3795
|
file: "service-context.ts",
|
|
3758
3796
|
line: 128,
|
|
3759
3797
|
scope: this,
|
|
@@ -3766,13 +3804,13 @@ var ServiceContext = class {
|
|
|
3766
3804
|
await this.feedStore.close();
|
|
3767
3805
|
await this.networkManager.close();
|
|
3768
3806
|
this.dataServiceSubscriptions.clear();
|
|
3769
|
-
(0,
|
|
3807
|
+
(0, import_log18.log)("closed", {}, {
|
|
3770
3808
|
file: "service-context.ts",
|
|
3771
3809
|
line: 136,
|
|
3772
3810
|
scope: this,
|
|
3773
3811
|
callSite: (f, a) => f(...a)
|
|
3774
3812
|
});
|
|
3775
|
-
|
|
3813
|
+
import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.end({
|
|
3776
3814
|
id: this._instanceId
|
|
3777
3815
|
}), {
|
|
3778
3816
|
file: "service-context.ts",
|
|
@@ -3799,7 +3837,7 @@ var ServiceContext = class {
|
|
|
3799
3837
|
// Called when identity is created.
|
|
3800
3838
|
async _initialize() {
|
|
3801
3839
|
var _a;
|
|
3802
|
-
(0,
|
|
3840
|
+
(0, import_log18.log)("initializing spaces...", {}, {
|
|
3803
3841
|
file: "service-context.ts",
|
|
3804
3842
|
line: 163,
|
|
3805
3843
|
scope: this,
|
|
@@ -3837,7 +3875,7 @@ var ServiceContext = class {
|
|
|
3837
3875
|
return;
|
|
3838
3876
|
}
|
|
3839
3877
|
if (!this.dataSpaceManager) {
|
|
3840
|
-
(0,
|
|
3878
|
+
(0, import_log18.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3841
3879
|
details: assertion
|
|
3842
3880
|
}, {
|
|
3843
3881
|
file: "service-context.ts",
|
|
@@ -3848,7 +3886,7 @@ var ServiceContext = class {
|
|
|
3848
3886
|
return;
|
|
3849
3887
|
}
|
|
3850
3888
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3851
|
-
(0,
|
|
3889
|
+
(0, import_log18.log)("space already exists, ignoring space admission", {
|
|
3852
3890
|
details: assertion
|
|
3853
3891
|
}, {
|
|
3854
3892
|
file: "service-context.ts",
|
|
@@ -3859,7 +3897,7 @@ var ServiceContext = class {
|
|
|
3859
3897
|
return;
|
|
3860
3898
|
}
|
|
3861
3899
|
try {
|
|
3862
|
-
(0,
|
|
3900
|
+
(0, import_log18.log)("accepting space recorded in halo", {
|
|
3863
3901
|
details: assertion
|
|
3864
3902
|
}, {
|
|
3865
3903
|
file: "service-context.ts",
|
|
@@ -3872,7 +3910,7 @@ var ServiceContext = class {
|
|
|
3872
3910
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3873
3911
|
});
|
|
3874
3912
|
} catch (err) {
|
|
3875
|
-
|
|
3913
|
+
import_log18.log.catch(err, {}, {
|
|
3876
3914
|
file: "service-context.ts",
|
|
3877
3915
|
line: 220,
|
|
3878
3916
|
scope: this,
|
|
@@ -3920,7 +3958,7 @@ var ClientServicesHost = class {
|
|
|
3920
3958
|
// TODO(wittjosiah): Turn this on by default.
|
|
3921
3959
|
lockKey
|
|
3922
3960
|
} = {}) {
|
|
3923
|
-
this._statusUpdate = new
|
|
3961
|
+
this._statusUpdate = new import_async21.Event();
|
|
3924
3962
|
this._opening = false;
|
|
3925
3963
|
this._open = false;
|
|
3926
3964
|
this._instanceId = import_client8.PublicKey.random().toHex();
|
|
@@ -3955,6 +3993,7 @@ var ClientServicesHost = class {
|
|
|
3955
3993
|
await this.reset();
|
|
3956
3994
|
}
|
|
3957
3995
|
});
|
|
3996
|
+
this._loggingService = new LoggingServiceImpl();
|
|
3958
3997
|
this._serviceRegistry = new ServiceRegistry(import_client8.clientServiceBundle, {
|
|
3959
3998
|
SystemService: this._systemService
|
|
3960
3999
|
});
|
|
@@ -3995,11 +4034,11 @@ var ClientServicesHost = class {
|
|
|
3995
4034
|
if (this._open) {
|
|
3996
4035
|
return;
|
|
3997
4036
|
}
|
|
3998
|
-
|
|
4037
|
+
import_log19.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.begin({
|
|
3999
4038
|
id: this._instanceId
|
|
4000
4039
|
}), {
|
|
4001
4040
|
file: "service-host.ts",
|
|
4002
|
-
line:
|
|
4041
|
+
line: 169,
|
|
4003
4042
|
scope: this,
|
|
4004
4043
|
callSite: (f, a) => f(...a)
|
|
4005
4044
|
});
|
|
@@ -4007,15 +4046,16 @@ var ClientServicesHost = class {
|
|
|
4007
4046
|
(0, import_node_assert14.default)(this._storage, "storage not set");
|
|
4008
4047
|
(0, import_node_assert14.default)(this._networkManager, "network manager not set");
|
|
4009
4048
|
this._opening = true;
|
|
4010
|
-
(0,
|
|
4049
|
+
(0, import_log19.log)("opening...", {
|
|
4011
4050
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
4012
4051
|
}, {
|
|
4013
4052
|
file: "service-host.ts",
|
|
4014
|
-
line:
|
|
4053
|
+
line: 176,
|
|
4015
4054
|
scope: this,
|
|
4016
4055
|
callSite: (f, a) => f(...a)
|
|
4017
4056
|
});
|
|
4018
4057
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
4058
|
+
await this._loggingService.open();
|
|
4019
4059
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
|
|
4020
4060
|
this._serviceRegistry.setServices({
|
|
4021
4061
|
SystemService: this._systemService,
|
|
@@ -4028,8 +4068,8 @@ var ClientServicesHost = class {
|
|
|
4028
4068
|
}),
|
|
4029
4069
|
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4030
4070
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
|
|
4071
|
+
LoggingService: this._loggingService,
|
|
4031
4072
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4032
|
-
TracingService: new TracingServiceImpl(this._config),
|
|
4033
4073
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4034
4074
|
events: new DevtoolsHostEvents(),
|
|
4035
4075
|
config: this._config,
|
|
@@ -4041,11 +4081,11 @@ var ClientServicesHost = class {
|
|
|
4041
4081
|
this._open = true;
|
|
4042
4082
|
this._statusUpdate.emit();
|
|
4043
4083
|
const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
|
|
4044
|
-
(0,
|
|
4084
|
+
(0, import_log19.log)("opened", {
|
|
4045
4085
|
deviceKey
|
|
4046
4086
|
}, {
|
|
4047
4087
|
file: "service-host.ts",
|
|
4048
|
-
line:
|
|
4088
|
+
line: 226,
|
|
4049
4089
|
scope: this,
|
|
4050
4090
|
callSite: (f, a) => f(...a)
|
|
4051
4091
|
});
|
|
@@ -4056,50 +4096,51 @@ var ClientServicesHost = class {
|
|
|
4056
4096
|
return;
|
|
4057
4097
|
}
|
|
4058
4098
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
4059
|
-
(0,
|
|
4099
|
+
(0, import_log19.log)("closing...", {
|
|
4060
4100
|
deviceKey
|
|
4061
4101
|
}, {
|
|
4062
4102
|
file: "service-host.ts",
|
|
4063
|
-
line:
|
|
4103
|
+
line: 235,
|
|
4064
4104
|
scope: this,
|
|
4065
4105
|
callSite: (f, a) => f(...a)
|
|
4066
4106
|
});
|
|
4067
4107
|
this._serviceRegistry.setServices({
|
|
4068
4108
|
SystemService: this._systemService
|
|
4069
4109
|
});
|
|
4110
|
+
await this._loggingService.close();
|
|
4070
4111
|
await this._serviceContext.close();
|
|
4071
4112
|
this._open = false;
|
|
4072
4113
|
this._statusUpdate.emit();
|
|
4073
|
-
(0,
|
|
4114
|
+
(0, import_log19.log)("closed", {
|
|
4074
4115
|
deviceKey
|
|
4075
4116
|
}, {
|
|
4076
4117
|
file: "service-host.ts",
|
|
4077
|
-
line:
|
|
4118
|
+
line: 241,
|
|
4078
4119
|
scope: this,
|
|
4079
4120
|
callSite: (f, a) => f(...a)
|
|
4080
4121
|
});
|
|
4081
|
-
|
|
4122
|
+
import_log19.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.end({
|
|
4082
4123
|
id: this._instanceId
|
|
4083
4124
|
}), {
|
|
4084
4125
|
file: "service-host.ts",
|
|
4085
|
-
line:
|
|
4126
|
+
line: 243,
|
|
4086
4127
|
scope: this,
|
|
4087
4128
|
callSite: (f, a) => f(...a)
|
|
4088
4129
|
});
|
|
4089
4130
|
}
|
|
4090
4131
|
async reset() {
|
|
4091
4132
|
var _a;
|
|
4092
|
-
(0,
|
|
4133
|
+
(0, import_log19.log)("resetting...", {}, {
|
|
4093
4134
|
file: "service-host.ts",
|
|
4094
|
-
line:
|
|
4135
|
+
line: 247,
|
|
4095
4136
|
scope: this,
|
|
4096
4137
|
callSite: (f, a) => f(...a)
|
|
4097
4138
|
});
|
|
4098
4139
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
4099
4140
|
await this._storage.reset();
|
|
4100
|
-
(0,
|
|
4141
|
+
(0, import_log19.log)("reset", {}, {
|
|
4101
4142
|
file: "service-host.ts",
|
|
4102
|
-
line:
|
|
4143
|
+
line: 250,
|
|
4103
4144
|
scope: this,
|
|
4104
4145
|
callSite: (f, a) => f(...a)
|
|
4105
4146
|
});
|
|
@@ -4130,7 +4171,7 @@ var LocalClientServices = class {
|
|
|
4130
4171
|
|
|
4131
4172
|
// packages/sdk/client-services/src/packlets/services/utils.ts
|
|
4132
4173
|
var import_config2 = require("@dxos/config");
|
|
4133
|
-
var
|
|
4174
|
+
var import_log20 = require("@dxos/log");
|
|
4134
4175
|
var import_messaging3 = require("@dxos/messaging");
|
|
4135
4176
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
4136
4177
|
|
|
@@ -4248,7 +4289,7 @@ var createSigningContext = async (keyring) => {
|
|
|
4248
4289
|
|
|
4249
4290
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
4250
4291
|
var import_node_assert15 = __toESM(require("node:assert"));
|
|
4251
|
-
var
|
|
4292
|
+
var import_async22 = require("@dxos/async");
|
|
4252
4293
|
var import_client10 = require("@dxos/client");
|
|
4253
4294
|
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4254
4295
|
var sanitizeInvitation = (invitation) => {
|
|
@@ -4263,9 +4304,9 @@ var sanitizeInvitation = (invitation) => {
|
|
|
4263
4304
|
};
|
|
4264
4305
|
};
|
|
4265
4306
|
var performInvitation = ({ host, guest, options, hooks }) => {
|
|
4266
|
-
const hostComplete = new
|
|
4267
|
-
const guestComplete = new
|
|
4268
|
-
const authCode = new
|
|
4307
|
+
const hostComplete = new import_async22.Trigger();
|
|
4308
|
+
const guestComplete = new import_async22.Trigger();
|
|
4309
|
+
const authCode = new import_async22.Trigger();
|
|
4269
4310
|
const hostObservable = createInvitation(host, options);
|
|
4270
4311
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
4271
4312
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
@@ -4424,14 +4465,14 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4424
4465
|
|
|
4425
4466
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4426
4467
|
var import_node_assert16 = __toESM(require("node:assert"));
|
|
4427
|
-
var
|
|
4468
|
+
var import_async23 = require("@dxos/async");
|
|
4428
4469
|
var import_client11 = require("@dxos/client");
|
|
4429
4470
|
var import_config3 = require("@dxos/config");
|
|
4430
4471
|
var import_debug7 = require("@dxos/debug");
|
|
4431
4472
|
var import_document_model = require("@dxos/document-model");
|
|
4432
4473
|
var import_echo_db = require("@dxos/echo-db");
|
|
4433
4474
|
var import_keys12 = require("@dxos/keys");
|
|
4434
|
-
var
|
|
4475
|
+
var import_log21 = require("@dxos/log");
|
|
4435
4476
|
var import_messaging5 = require("@dxos/messaging");
|
|
4436
4477
|
var import_network_manager7 = require("@dxos/network-manager");
|
|
4437
4478
|
var import_rpc5 = require("@dxos/rpc");
|
|
@@ -4524,7 +4565,7 @@ var testSpace = async (create, check = create) => {
|
|
|
4524
4565
|
const result = create.mutate((0, import_echo_db.genesisMutation)(objectId, import_document_model.DocumentModel.meta.type));
|
|
4525
4566
|
await result.batch.getReceipt();
|
|
4526
4567
|
(0, import_node_assert16.default)(create._itemManager.entities.has(result.objectsUpdated[0].id));
|
|
4527
|
-
await (0,
|
|
4568
|
+
await (0, import_async23.asyncTimeout)(check.itemUpdate.waitForCondition(() => check._itemManager.entities.has(objectId)), 1e3);
|
|
4528
4569
|
return result;
|
|
4529
4570
|
};
|
|
4530
4571
|
var syncItems = async (db1, db2) => {
|
|
@@ -4535,12 +4576,12 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4535
4576
|
const rootSpace = spaceKey ? initialPeer.getSpace(spaceKey) : await initialPeer.createSpace();
|
|
4536
4577
|
(0, import_node_assert16.default)(rootSpace, "Space not found.");
|
|
4537
4578
|
await Promise.all(peers.map(async (peer) => {
|
|
4538
|
-
const hostDone = new
|
|
4539
|
-
const guestDone = new
|
|
4579
|
+
const hostDone = new import_async23.Trigger();
|
|
4580
|
+
const guestDone = new import_async23.Trigger();
|
|
4540
4581
|
const hostObservable = rootSpace.createInvitation({
|
|
4541
4582
|
authMethod: import_client11.Invitation.AuthMethod.NONE
|
|
4542
4583
|
});
|
|
4543
|
-
(0,
|
|
4584
|
+
(0, import_log21.log)("invitation created", {}, {
|
|
4544
4585
|
file: "test-builder.ts",
|
|
4545
4586
|
line: 156,
|
|
4546
4587
|
scope: void 0,
|
|
@@ -4550,7 +4591,7 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4550
4591
|
switch (hostInvitation.state) {
|
|
4551
4592
|
case import_client11.Invitation.State.CONNECTING: {
|
|
4552
4593
|
const guestObservable = peer.acceptInvitation(hostInvitation);
|
|
4553
|
-
(0,
|
|
4594
|
+
(0, import_log21.log)("invitation accepted", {}, {
|
|
4554
4595
|
file: "test-builder.ts",
|
|
4555
4596
|
line: 162,
|
|
4556
4597
|
scope: void 0,
|
|
@@ -4560,7 +4601,7 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4560
4601
|
switch (guestInvitation.state) {
|
|
4561
4602
|
case import_client11.Invitation.State.SUCCESS: {
|
|
4562
4603
|
guestDone.wake(guestInvitation);
|
|
4563
|
-
(0,
|
|
4604
|
+
(0, import_log21.log)("invitation guestDone", {}, {
|
|
4564
4605
|
file: "test-builder.ts",
|
|
4565
4606
|
line: 169,
|
|
4566
4607
|
scope: void 0,
|
|
@@ -4574,7 +4615,7 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4574
4615
|
}
|
|
4575
4616
|
case import_client11.Invitation.State.SUCCESS: {
|
|
4576
4617
|
hostDone.wake(hostInvitation);
|
|
4577
|
-
(0,
|
|
4618
|
+
(0, import_log21.log)("invitation hostDone", {}, {
|
|
4578
4619
|
file: "test-builder.ts",
|
|
4579
4620
|
line: 181,
|
|
4580
4621
|
scope: void 0,
|