@dxos/client-services 0.1.51 → 0.1.52-main.1744ed2
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/node/index.cjs +78 -84
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +64 -70
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/locks/node.d.ts +2 -2
- package/dist/types/src/packlets/locks/node.d.ts.map +1 -1
- package/package.json +32 -33
- package/src/packlets/locks/node.ts +8 -13
package/dist/lib/node/index.cjs
CHANGED
|
@@ -2141,8 +2141,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2141
2141
|
};
|
|
2142
2142
|
|
|
2143
2143
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2144
|
-
var
|
|
2145
|
-
var
|
|
2144
|
+
var import_node_assert13 = __toESM(require("node:assert"));
|
|
2145
|
+
var import_async17 = require("@dxos/async");
|
|
2146
2146
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
2147
2147
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
2148
2148
|
var import_keys11 = require("@dxos/keys");
|
|
@@ -2200,8 +2200,8 @@ var DevicesServiceImpl = class {
|
|
|
2200
2200
|
};
|
|
2201
2201
|
|
|
2202
2202
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
2203
|
-
var
|
|
2204
|
-
var
|
|
2203
|
+
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2204
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
2205
2205
|
var import_log8 = require("@dxos/log");
|
|
2206
2206
|
var __decorate = function(decorators, target, key, desc) {
|
|
2207
2207
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2215,7 +2215,6 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2215
2215
|
};
|
|
2216
2216
|
var Lock = class {
|
|
2217
2217
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
2218
|
-
this._releaseTrigger = new import_async11.Trigger();
|
|
2219
2218
|
this._lockPath = lockPath;
|
|
2220
2219
|
this._onAcquire = onAcquire;
|
|
2221
2220
|
this._onRelease = onRelease;
|
|
@@ -2227,45 +2226,40 @@ var Lock = class {
|
|
|
2227
2226
|
var _a;
|
|
2228
2227
|
(0, import_log8.log)("acquiring lock...", {}, {
|
|
2229
2228
|
file: "node.ts",
|
|
2230
|
-
line:
|
|
2229
|
+
line: 32,
|
|
2231
2230
|
scope: this,
|
|
2232
2231
|
callSite: (f, a) => f(...a)
|
|
2233
2232
|
});
|
|
2234
|
-
|
|
2235
|
-
throw new Error(`Lock already acquired: ${this._lockPath}`);
|
|
2236
|
-
}
|
|
2237
|
-
import_lockfile.default.lockSync(this._lockPath);
|
|
2233
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
2238
2234
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
2239
2235
|
(0, import_log8.log)("acquired lock", {}, {
|
|
2240
2236
|
file: "node.ts",
|
|
2241
|
-
line:
|
|
2237
|
+
line: 37,
|
|
2242
2238
|
scope: this,
|
|
2243
2239
|
callSite: (f, a) => f(...a)
|
|
2244
2240
|
});
|
|
2245
2241
|
}
|
|
2246
2242
|
async release() {
|
|
2247
2243
|
var _a;
|
|
2248
|
-
if (!import_lockfile.default.checkSync(this._lockPath)) {
|
|
2249
|
-
throw new Error(`Lock already acquired: ${this._lockPath}`);
|
|
2250
|
-
}
|
|
2251
2244
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
2252
|
-
|
|
2245
|
+
(0, import_node_assert9.default)(this._fileHandle, "Lock is not acquired");
|
|
2246
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
2253
2247
|
}
|
|
2254
2248
|
};
|
|
2255
2249
|
__decorate([
|
|
2256
2250
|
import_log8.logInfo
|
|
2257
2251
|
], Lock.prototype, "lockKey", null);
|
|
2258
|
-
var isLocked = (lockPath) =>
|
|
2252
|
+
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
2259
2253
|
|
|
2260
2254
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
2261
|
-
var
|
|
2255
|
+
var import_async11 = require("@dxos/async");
|
|
2262
2256
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2263
2257
|
var import_log9 = require("@dxos/log");
|
|
2264
2258
|
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2265
2259
|
var import_util3 = require("@dxos/util");
|
|
2266
2260
|
var LoggingServiceImpl = class {
|
|
2267
2261
|
constructor() {
|
|
2268
|
-
this._logs = new
|
|
2262
|
+
this._logs = new import_async11.Event();
|
|
2269
2263
|
this._logProcessor = (_config, entry2) => {
|
|
2270
2264
|
this._logs.emit(entry2);
|
|
2271
2265
|
};
|
|
@@ -2366,8 +2360,8 @@ var NetworkServiceImpl = class {
|
|
|
2366
2360
|
};
|
|
2367
2361
|
|
|
2368
2362
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2369
|
-
var
|
|
2370
|
-
var
|
|
2363
|
+
var import_node_assert11 = __toESM(require("node:assert"));
|
|
2364
|
+
var import_async14 = require("@dxos/async");
|
|
2371
2365
|
var import_context7 = require("@dxos/context");
|
|
2372
2366
|
var import_credentials12 = require("@dxos/credentials");
|
|
2373
2367
|
var import_keys9 = require("@dxos/keys");
|
|
@@ -2378,7 +2372,7 @@ var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip"
|
|
|
2378
2372
|
var import_util6 = require("@dxos/util");
|
|
2379
2373
|
|
|
2380
2374
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2381
|
-
var
|
|
2375
|
+
var import_async13 = require("@dxos/async");
|
|
2382
2376
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2383
2377
|
var import_context6 = require("@dxos/context");
|
|
2384
2378
|
var import_debug3 = require("@dxos/debug");
|
|
@@ -2392,8 +2386,8 @@ var import_timeframe = require("@dxos/timeframe");
|
|
|
2392
2386
|
var import_util5 = require("@dxos/util");
|
|
2393
2387
|
|
|
2394
2388
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2395
|
-
var
|
|
2396
|
-
var
|
|
2389
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2390
|
+
var import_async12 = require("@dxos/async");
|
|
2397
2391
|
var import_context5 = require("@dxos/context");
|
|
2398
2392
|
var import_keys7 = require("@dxos/keys");
|
|
2399
2393
|
var import_log10 = require("@dxos/log");
|
|
@@ -2407,7 +2401,7 @@ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
|
2407
2401
|
var NotarizationPlugin = class {
|
|
2408
2402
|
constructor() {
|
|
2409
2403
|
this._ctx = new import_context5.Context();
|
|
2410
|
-
this._extensionOpened = new
|
|
2404
|
+
this._extensionOpened = new import_async12.Event();
|
|
2411
2405
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2412
2406
|
this._processedCredentials = new import_util4.ComplexSet(import_keys7.PublicKey.hash);
|
|
2413
2407
|
this._processCredentialsTriggers = new import_util4.ComplexMap(import_keys7.PublicKey.hash);
|
|
@@ -2429,8 +2423,8 @@ var NotarizationPlugin = class {
|
|
|
2429
2423
|
scope: this,
|
|
2430
2424
|
callSite: (f, a) => f(...a)
|
|
2431
2425
|
});
|
|
2432
|
-
(0,
|
|
2433
|
-
const errors = new
|
|
2426
|
+
(0, import_node_assert10.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2427
|
+
const errors = new import_async12.Trigger();
|
|
2434
2428
|
const ctx = this._ctx.derive({
|
|
2435
2429
|
onError: (err) => {
|
|
2436
2430
|
import_log10.log.warn("Notarization error", {
|
|
@@ -2447,7 +2441,7 @@ var NotarizationPlugin = class {
|
|
|
2447
2441
|
});
|
|
2448
2442
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
2449
2443
|
if (timeout !== 0) {
|
|
2450
|
-
(0,
|
|
2444
|
+
(0, import_async12.scheduleTask)(ctx, () => {
|
|
2451
2445
|
import_log10.log.warn("Notarization timeout", {
|
|
2452
2446
|
timeout,
|
|
2453
2447
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2458,12 +2452,12 @@ var NotarizationPlugin = class {
|
|
|
2458
2452
|
callSite: (f, a) => f(...a)
|
|
2459
2453
|
});
|
|
2460
2454
|
void ctx.dispose();
|
|
2461
|
-
errors.throw(new
|
|
2455
|
+
errors.throw(new import_async12.TimeoutError(timeout, "Notarization timed out"));
|
|
2462
2456
|
}, timeout);
|
|
2463
2457
|
}
|
|
2464
2458
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2465
2459
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2466
|
-
const notarizeTask = new
|
|
2460
|
+
const notarizeTask = new import_async12.DeferredTask(ctx, async () => {
|
|
2467
2461
|
try {
|
|
2468
2462
|
if (this._extensions.size === 0) {
|
|
2469
2463
|
return;
|
|
@@ -2481,7 +2475,7 @@ var NotarizationPlugin = class {
|
|
|
2481
2475
|
callSite: (f, a) => f(...a)
|
|
2482
2476
|
});
|
|
2483
2477
|
peersTried.clear();
|
|
2484
|
-
(0,
|
|
2478
|
+
(0, import_async12.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2485
2479
|
return;
|
|
2486
2480
|
}
|
|
2487
2481
|
peersTried.add(peer);
|
|
@@ -2503,7 +2497,7 @@ var NotarizationPlugin = class {
|
|
|
2503
2497
|
scope: this,
|
|
2504
2498
|
callSite: (f, a) => f(...a)
|
|
2505
2499
|
});
|
|
2506
|
-
await (0,
|
|
2500
|
+
await (0, import_async12.sleep)(successDelay);
|
|
2507
2501
|
} catch (err) {
|
|
2508
2502
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2509
2503
|
import_log10.log.warn("error notarizing (recoverable)", err, {
|
|
@@ -2547,14 +2541,14 @@ var NotarizationPlugin = class {
|
|
|
2547
2541
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2548
2542
|
}
|
|
2549
2543
|
setWriter(writer) {
|
|
2550
|
-
(0,
|
|
2544
|
+
(0, import_node_assert10.default)(!this._writer, "Writer already set.");
|
|
2551
2545
|
this._writer = writer;
|
|
2552
2546
|
}
|
|
2553
2547
|
async _waitUntilProcessed(id) {
|
|
2554
2548
|
if (this._processedCredentials.has(id)) {
|
|
2555
2549
|
return;
|
|
2556
2550
|
}
|
|
2557
|
-
await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new
|
|
2551
|
+
await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new import_async12.Trigger()).value.wait();
|
|
2558
2552
|
}
|
|
2559
2553
|
/**
|
|
2560
2554
|
* Requests from other peers to notarize credentials.
|
|
@@ -2565,7 +2559,7 @@ var NotarizationPlugin = class {
|
|
|
2565
2559
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2566
2560
|
}
|
|
2567
2561
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2568
|
-
(0,
|
|
2562
|
+
(0, import_node_assert10.default)(credential.id, "Credential must have an id");
|
|
2569
2563
|
if (this._processedCredentials.has(credential.id)) {
|
|
2570
2564
|
continue;
|
|
2571
2565
|
}
|
|
@@ -2652,7 +2646,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2652
2646
|
* Error for _state === SpaceState.ERROR.
|
|
2653
2647
|
*/
|
|
2654
2648
|
this.error = void 0;
|
|
2655
|
-
this.stateUpdate = new
|
|
2649
|
+
this.stateUpdate = new import_async13.Event();
|
|
2656
2650
|
this.metrics = {};
|
|
2657
2651
|
var _a;
|
|
2658
2652
|
this._inner = params.inner;
|
|
@@ -2723,7 +2717,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2723
2717
|
* Initialize the data pipeline in a separate task.
|
|
2724
2718
|
*/
|
|
2725
2719
|
initializeDataPipelineAsync() {
|
|
2726
|
-
(0,
|
|
2720
|
+
(0, import_async13.scheduleTask)(this._ctx, async () => {
|
|
2727
2721
|
try {
|
|
2728
2722
|
this.metrics.pipelineInitBegin = new Date();
|
|
2729
2723
|
await this.initializeDataPipeline();
|
|
@@ -2876,7 +2870,7 @@ __decorate2([
|
|
|
2876
2870
|
(0, import_debug3.timed)(1e4)
|
|
2877
2871
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2878
2872
|
DataSpace = __decorate2([
|
|
2879
|
-
(0,
|
|
2873
|
+
(0, import_async13.trackLeaks)("open", "close")
|
|
2880
2874
|
], DataSpace);
|
|
2881
2875
|
|
|
2882
2876
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
@@ -2969,7 +2963,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2969
2963
|
this._signingContext = _signingContext;
|
|
2970
2964
|
this._feedStore = _feedStore;
|
|
2971
2965
|
this._ctx = new import_context7.Context();
|
|
2972
|
-
this.updated = new
|
|
2966
|
+
this.updated = new import_async14.Event();
|
|
2973
2967
|
this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
2974
2968
|
this._isOpen = false;
|
|
2975
2969
|
this._instanceId = import_keys9.PublicKey.random().toHex();
|
|
@@ -3054,7 +3048,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3054
3048
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3055
3049
|
*/
|
|
3056
3050
|
async createSpace() {
|
|
3057
|
-
(0,
|
|
3051
|
+
(0, import_node_assert11.default)(this._isOpen, "Not open.");
|
|
3058
3052
|
const spaceKey = await this._keyring.createKey();
|
|
3059
3053
|
const controlFeedKey = await this._keyring.createKey();
|
|
3060
3054
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -3076,7 +3070,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3076
3070
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
3077
3071
|
await this._metadataStore.addSpace(metadata);
|
|
3078
3072
|
const memberCredential = credentials[1];
|
|
3079
|
-
(0,
|
|
3073
|
+
(0, import_node_assert11.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
3080
3074
|
await this._signingContext.recordCredential(memberCredential);
|
|
3081
3075
|
await space.initializeDataPipeline();
|
|
3082
3076
|
this.updated.emit();
|
|
@@ -3092,8 +3086,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3092
3086
|
scope: this,
|
|
3093
3087
|
callSite: (f, a) => f(...a)
|
|
3094
3088
|
});
|
|
3095
|
-
(0,
|
|
3096
|
-
(0,
|
|
3089
|
+
(0, import_node_assert11.default)(this._isOpen, "Not open.");
|
|
3090
|
+
(0, import_node_assert11.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
3097
3091
|
const metadata = {
|
|
3098
3092
|
key: opts.spaceKey,
|
|
3099
3093
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -3216,23 +3210,23 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3216
3210
|
}
|
|
3217
3211
|
};
|
|
3218
3212
|
__decorate3([
|
|
3219
|
-
|
|
3213
|
+
import_async14.synchronized
|
|
3220
3214
|
], DataSpaceManager.prototype, "open", null);
|
|
3221
3215
|
__decorate3([
|
|
3222
|
-
|
|
3216
|
+
import_async14.synchronized
|
|
3223
3217
|
], DataSpaceManager.prototype, "close", null);
|
|
3224
3218
|
__decorate3([
|
|
3225
|
-
|
|
3219
|
+
import_async14.synchronized
|
|
3226
3220
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3227
3221
|
__decorate3([
|
|
3228
|
-
|
|
3222
|
+
import_async14.synchronized
|
|
3229
3223
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3230
3224
|
DataSpaceManager = __decorate3([
|
|
3231
|
-
(0,
|
|
3225
|
+
(0, import_async14.trackLeaks)("open", "close")
|
|
3232
3226
|
], DataSpaceManager);
|
|
3233
3227
|
|
|
3234
3228
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3235
|
-
var
|
|
3229
|
+
var import_async15 = require("@dxos/async");
|
|
3236
3230
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
3237
3231
|
var import_debug5 = require("@dxos/debug");
|
|
3238
3232
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
@@ -3276,9 +3270,9 @@ var SpacesServiceImpl = class {
|
|
|
3276
3270
|
spaces
|
|
3277
3271
|
});
|
|
3278
3272
|
};
|
|
3279
|
-
(0,
|
|
3273
|
+
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
3280
3274
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3281
|
-
const subscriptions = new
|
|
3275
|
+
const subscriptions = new import_async15.EventSubscriptions();
|
|
3282
3276
|
ctx.onDispose(() => subscriptions.clear());
|
|
3283
3277
|
const subscribeSpaces = () => {
|
|
3284
3278
|
subscriptions.clear();
|
|
@@ -3314,7 +3308,7 @@ var SpacesServiceImpl = class {
|
|
|
3314
3308
|
}
|
|
3315
3309
|
subscribeMessages({ spaceKey, channel }) {
|
|
3316
3310
|
return new import_codec_protobuf12.Stream(({ ctx, next }) => {
|
|
3317
|
-
(0,
|
|
3311
|
+
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
3318
3312
|
var _a;
|
|
3319
3313
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3320
3314
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
@@ -3335,7 +3329,7 @@ var SpacesServiceImpl = class {
|
|
|
3335
3329
|
}
|
|
3336
3330
|
});
|
|
3337
3331
|
ctx.onDispose(() => processor.close());
|
|
3338
|
-
(0,
|
|
3332
|
+
(0, import_async15.scheduleTask)(ctx, () => processor.open());
|
|
3339
3333
|
});
|
|
3340
3334
|
}
|
|
3341
3335
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3482,8 +3476,8 @@ var SystemServiceImpl = class {
|
|
|
3482
3476
|
};
|
|
3483
3477
|
|
|
3484
3478
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3485
|
-
var
|
|
3486
|
-
var
|
|
3479
|
+
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3480
|
+
var import_async16 = require("@dxos/async");
|
|
3487
3481
|
var import_credentials13 = require("@dxos/credentials");
|
|
3488
3482
|
var import_debug6 = require("@dxos/debug");
|
|
3489
3483
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
@@ -3501,7 +3495,7 @@ var ServiceContext = class {
|
|
|
3501
3495
|
this.networkManager = networkManager;
|
|
3502
3496
|
this.signalManager = signalManager;
|
|
3503
3497
|
this.modelFactory = modelFactory;
|
|
3504
|
-
this.initialized = new
|
|
3498
|
+
this.initialized = new import_async16.Trigger();
|
|
3505
3499
|
this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
|
|
3506
3500
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3507
3501
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
@@ -3601,7 +3595,7 @@ var ServiceContext = class {
|
|
|
3601
3595
|
}
|
|
3602
3596
|
getInvitationHandler(invitation) {
|
|
3603
3597
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3604
|
-
(0,
|
|
3598
|
+
(0, import_node_assert12.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3605
3599
|
return factory(invitation);
|
|
3606
3600
|
}
|
|
3607
3601
|
async _acceptIdentity(params) {
|
|
@@ -3641,7 +3635,7 @@ var ServiceContext = class {
|
|
|
3641
3635
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3642
3636
|
await this.dataSpaceManager.open();
|
|
3643
3637
|
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
3644
|
-
(0,
|
|
3638
|
+
(0, import_node_assert12.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3645
3639
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3646
3640
|
});
|
|
3647
3641
|
this.initialized.wake();
|
|
@@ -3740,7 +3734,7 @@ var ClientServicesHost = class {
|
|
|
3740
3734
|
// TODO(wittjosiah): Turn this on by default.
|
|
3741
3735
|
lockKey
|
|
3742
3736
|
} = {}) {
|
|
3743
|
-
this._statusUpdate = new
|
|
3737
|
+
this._statusUpdate = new import_async17.Event();
|
|
3744
3738
|
this._opening = false;
|
|
3745
3739
|
this._open = false;
|
|
3746
3740
|
this._storage = storage;
|
|
@@ -3803,9 +3797,9 @@ var ClientServicesHost = class {
|
|
|
3803
3797
|
*/
|
|
3804
3798
|
initialize({ config, ...options }) {
|
|
3805
3799
|
var _a, _b, _c;
|
|
3806
|
-
(0,
|
|
3800
|
+
(0, import_node_assert13.default)(!this._open, "service host is open");
|
|
3807
3801
|
if (config) {
|
|
3808
|
-
(0,
|
|
3802
|
+
(0, import_node_assert13.default)(!this._config, "config already set");
|
|
3809
3803
|
this._config = config;
|
|
3810
3804
|
if (!this._storage) {
|
|
3811
3805
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3815,7 +3809,7 @@ var ClientServicesHost = class {
|
|
|
3815
3809
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3816
3810
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3817
3811
|
this._signalManager = signalManager;
|
|
3818
|
-
(0,
|
|
3812
|
+
(0, import_node_assert13.default)(!this._networkManager, "network manager already set");
|
|
3819
3813
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3820
3814
|
log: connectionLog,
|
|
3821
3815
|
transportFactory,
|
|
@@ -3836,10 +3830,10 @@ var ClientServicesHost = class {
|
|
|
3836
3830
|
scope: this,
|
|
3837
3831
|
callSite: (f, a) => f(...a)
|
|
3838
3832
|
});
|
|
3839
|
-
(0,
|
|
3840
|
-
(0,
|
|
3841
|
-
(0,
|
|
3842
|
-
(0,
|
|
3833
|
+
(0, import_node_assert13.default)(this._config, "config not set");
|
|
3834
|
+
(0, import_node_assert13.default)(this._storage, "storage not set");
|
|
3835
|
+
(0, import_node_assert13.default)(this._signalManager, "signal manager not set");
|
|
3836
|
+
(0, import_node_assert13.default)(this._networkManager, "network manager not set");
|
|
3843
3837
|
this._opening = true;
|
|
3844
3838
|
(0, import_log15.log)("opening...", {
|
|
3845
3839
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
@@ -3982,7 +3976,7 @@ var LocalClientServices = class {
|
|
|
3982
3976
|
};
|
|
3983
3977
|
|
|
3984
3978
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3985
|
-
var
|
|
3979
|
+
var import_async19 = require("@dxos/async");
|
|
3986
3980
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
3987
3981
|
var import_log16 = require("@dxos/log");
|
|
3988
3982
|
var import_messaging2 = require("@dxos/messaging");
|
|
@@ -4043,15 +4037,15 @@ var ClientRpcServer = class {
|
|
|
4043
4037
|
};
|
|
4044
4038
|
|
|
4045
4039
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
4046
|
-
var
|
|
4047
|
-
var
|
|
4040
|
+
var import_node_assert14 = __toESM(require("node:assert"));
|
|
4041
|
+
var import_async18 = require("@dxos/async");
|
|
4048
4042
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4049
4043
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
4050
4044
|
var import_rpc2 = require("@dxos/rpc");
|
|
4051
4045
|
var ShellRuntimeImpl = class {
|
|
4052
4046
|
constructor(_port) {
|
|
4053
4047
|
this._port = _port;
|
|
4054
|
-
this.layoutUpdate = new
|
|
4048
|
+
this.layoutUpdate = new import_async18.Event();
|
|
4055
4049
|
this._layout = import_iframe.ShellLayout.DEFAULT;
|
|
4056
4050
|
}
|
|
4057
4051
|
get layout() {
|
|
@@ -4073,7 +4067,7 @@ var ShellRuntimeImpl = class {
|
|
|
4073
4067
|
});
|
|
4074
4068
|
}
|
|
4075
4069
|
async setAppContext(context) {
|
|
4076
|
-
(0,
|
|
4070
|
+
(0, import_node_assert14.default)(this._appRpc, "runtime not open");
|
|
4077
4071
|
await this._appRpc.rpc.AppService.setContext(context);
|
|
4078
4072
|
}
|
|
4079
4073
|
async open() {
|
|
@@ -4102,8 +4096,8 @@ var ShellRuntimeImpl = class {
|
|
|
4102
4096
|
};
|
|
4103
4097
|
var MemoryShellRuntime = class {
|
|
4104
4098
|
constructor({ layout, invitationCode, spaceKey } = {}) {
|
|
4105
|
-
this.layoutUpdate = new
|
|
4106
|
-
this.contextUpdate = new
|
|
4099
|
+
this.layoutUpdate = new import_async18.Event();
|
|
4100
|
+
this.contextUpdate = new import_async18.Event();
|
|
4107
4101
|
this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
|
|
4108
4102
|
this._invitationCode = invitationCode;
|
|
4109
4103
|
this._spaceKey = spaceKey;
|
|
@@ -4145,7 +4139,7 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
4145
4139
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
4146
4140
|
var IFrameHostRuntime = class {
|
|
4147
4141
|
constructor({ config, origin, appPort, shellPort }) {
|
|
4148
|
-
this._ready = new
|
|
4142
|
+
this._ready = new import_async19.Trigger();
|
|
4149
4143
|
this._configProvider = config;
|
|
4150
4144
|
this.origin = origin;
|
|
4151
4145
|
this._appPort = appPort;
|
|
@@ -4251,7 +4245,7 @@ __decorate4([
|
|
|
4251
4245
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
4252
4246
|
|
|
4253
4247
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
4254
|
-
var
|
|
4248
|
+
var import_async20 = require("@dxos/async");
|
|
4255
4249
|
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
4256
4250
|
var import_errors5 = require("@dxos/errors");
|
|
4257
4251
|
var import_log17 = require("@dxos/log");
|
|
@@ -4261,7 +4255,7 @@ var import_util10 = require("@dxos/util");
|
|
|
4261
4255
|
var IFrameProxyRuntime = class {
|
|
4262
4256
|
constructor({ config, systemPort, shellPort }) {
|
|
4263
4257
|
this._id = String(Math.floor(Math.random() * 1e6));
|
|
4264
|
-
this._release = new
|
|
4258
|
+
this._release = new import_async20.Trigger();
|
|
4265
4259
|
this._configProvider = config;
|
|
4266
4260
|
this._systemPort = systemPort;
|
|
4267
4261
|
this._shellPort = shellPort;
|
|
@@ -4290,8 +4284,8 @@ var IFrameProxyRuntime = class {
|
|
|
4290
4284
|
let lockKey;
|
|
4291
4285
|
if (typeof navigator !== "undefined") {
|
|
4292
4286
|
lockKey = this._lockKey(origin);
|
|
4293
|
-
this._release = new
|
|
4294
|
-
const ready = new
|
|
4287
|
+
this._release = new import_async20.Trigger();
|
|
4288
|
+
const ready = new import_async20.Trigger();
|
|
4295
4289
|
void navigator.locks.request(lockKey, async () => {
|
|
4296
4290
|
ready.wake();
|
|
4297
4291
|
await this._release.wait();
|
|
@@ -4328,14 +4322,14 @@ var IFrameProxyRuntime = class {
|
|
|
4328
4322
|
};
|
|
4329
4323
|
|
|
4330
4324
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
4331
|
-
var
|
|
4325
|
+
var import_async22 = require("@dxos/async");
|
|
4332
4326
|
var import_log19 = require("@dxos/log");
|
|
4333
4327
|
var import_messaging3 = require("@dxos/messaging");
|
|
4334
4328
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
4335
4329
|
|
|
4336
4330
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
4337
|
-
var
|
|
4338
|
-
var
|
|
4331
|
+
var import_node_assert15 = __toESM(require("node:assert"));
|
|
4332
|
+
var import_async21 = require("@dxos/async");
|
|
4339
4333
|
var import_client_protocol9 = require("@dxos/client-protocol");
|
|
4340
4334
|
var import_log18 = require("@dxos/log");
|
|
4341
4335
|
var import_rpc4 = require("@dxos/rpc");
|
|
@@ -4352,9 +4346,9 @@ var __decorate5 = function(decorators, target, key, desc) {
|
|
|
4352
4346
|
};
|
|
4353
4347
|
var WorkerSession = class {
|
|
4354
4348
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
4355
|
-
this._startTrigger = new
|
|
4349
|
+
this._startTrigger = new import_async21.Trigger();
|
|
4356
4350
|
this.onClose = new import_util11.Callback();
|
|
4357
|
-
(0,
|
|
4351
|
+
(0, import_node_assert15.default)(serviceHost);
|
|
4358
4352
|
this._serviceHost = serviceHost;
|
|
4359
4353
|
const middleware = {
|
|
4360
4354
|
handleCall: async (method, params, handler) => {
|
|
@@ -4460,7 +4454,7 @@ var WorkerSession = class {
|
|
|
4460
4454
|
}
|
|
4461
4455
|
async _maybeOpenShell() {
|
|
4462
4456
|
try {
|
|
4463
|
-
await (0,
|
|
4457
|
+
await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
4464
4458
|
} catch (e) {
|
|
4465
4459
|
import_log18.log.info("No shell connected.", {}, {
|
|
4466
4460
|
file: "worker-session.ts",
|
|
@@ -4488,7 +4482,7 @@ var WorkerRuntime = class {
|
|
|
4488
4482
|
constructor(_configProvider) {
|
|
4489
4483
|
this._configProvider = _configProvider;
|
|
4490
4484
|
this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
|
|
4491
|
-
this._ready = new
|
|
4485
|
+
this._ready = new import_async22.Trigger();
|
|
4492
4486
|
this.sessions = /* @__PURE__ */ new Set();
|
|
4493
4487
|
this._clientServices = new ClientServicesHost();
|
|
4494
4488
|
}
|