@dxos/client-services 0.1.24 → 0.1.25-next.3c6b542

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.
Files changed (70) hide show
  1. package/dist/lib/browser/{chunk-R2FEBB66.mjs → chunk-WF53R6F7.mjs} +325 -95
  2. package/dist/lib/browser/chunk-WF53R6F7.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +11 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +3 -3
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/index.cjs +350 -111
  8. package/dist/lib/node/index.cjs.map +4 -4
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +228 -110
  11. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  12. package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
  13. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts +1 -1
  15. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  16. package/dist/types/src/packlets/identity/identity.d.ts +2 -2
  17. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +1 -1
  19. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-context.d.ts +1 -1
  21. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -1
  23. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  24. package/dist/types/src/packlets/spaces/data-space.d.ts +1 -1
  25. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  26. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  27. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  28. package/dist/types/src/packlets/testing/test-builder.d.ts +1 -1
  29. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  30. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +11 -4
  31. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  32. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +6 -1
  33. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  34. package/dist/types/src/packlets/vault/index.d.ts +2 -0
  35. package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
  36. package/dist/types/src/packlets/vault/services.d.ts +9 -1
  37. package/dist/types/src/packlets/vault/services.d.ts.map +1 -1
  38. package/dist/types/src/packlets/vault/shell-controller.d.ts +24 -0
  39. package/dist/types/src/packlets/vault/shell-controller.d.ts.map +1 -0
  40. package/dist/types/src/packlets/vault/shell-runtime.d.ts +45 -0
  41. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -0
  42. package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -1
  43. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  44. package/dist/types/src/packlets/vault/worker-session.d.ts +4 -1
  45. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  46. package/package.json +29 -28
  47. package/src/packlets/devtools/spaces.ts +1 -1
  48. package/src/packlets/identity/authenticator.ts +1 -1
  49. package/src/packlets/identity/identity-manager.test.ts +1 -1
  50. package/src/packlets/identity/identity-manager.ts +1 -1
  51. package/src/packlets/identity/identity.test.ts +1 -1
  52. package/src/packlets/identity/identity.ts +1 -1
  53. package/src/packlets/invitations/space-invitations-handler.test.ts +1 -1
  54. package/src/packlets/invitations/space-invitations-handler.ts +1 -1
  55. package/src/packlets/services/service-context.ts +2 -2
  56. package/src/packlets/services/service-host.ts +1 -1
  57. package/src/packlets/spaces/data-space-manager.test.ts +1 -1
  58. package/src/packlets/spaces/data-space-manager.ts +4 -4
  59. package/src/packlets/spaces/data-space.ts +3 -3
  60. package/src/packlets/spaces/spaces-service.ts +1 -1
  61. package/src/packlets/testing/test-builder.ts +3 -3
  62. package/src/packlets/vault/iframe-host-runtime.ts +26 -7
  63. package/src/packlets/vault/iframe-proxy-runtime.ts +16 -1
  64. package/src/packlets/vault/index.ts +2 -0
  65. package/src/packlets/vault/services.ts +17 -1
  66. package/src/packlets/vault/shell-controller.ts +78 -0
  67. package/src/packlets/vault/shell-runtime.ts +133 -0
  68. package/src/packlets/vault/worker-runtime.ts +3 -1
  69. package/src/packlets/vault/worker-session.ts +29 -19
  70. package/dist/lib/browser/chunk-R2FEBB66.mjs.map +0 -7
@@ -2184,7 +2184,7 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
2184
2184
  import { Trigger as Trigger5 } from "@dxos/async";
2185
2185
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2186
2186
  import { failUndefined as failUndefined2 } from "@dxos/debug";
2187
- import { valueEncoding, DataServiceSubscriptions, MetadataStore, SpaceManager, SnapshotStore } from "@dxos/echo-db";
2187
+ import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
2188
2188
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
2189
2189
  import { Keyring } from "@dxos/keyring";
2190
2190
  import { log as log11 } from "@dxos/log";
@@ -2194,7 +2194,7 @@ import assert12 from "@dxos/node-std/assert";
2194
2194
  import { Event as Event4, synchronized, trackLeaks as trackLeaks2 } from "@dxos/async";
2195
2195
  import { Context as Context7 } from "@dxos/context";
2196
2196
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
2197
- import { spaceGenesis, SnapshotManager } from "@dxos/echo-db";
2197
+ import { spaceGenesis, SnapshotManager } from "@dxos/echo-pipeline";
2198
2198
  import { PublicKey as PublicKey7 } from "@dxos/keys";
2199
2199
  import { log as log10 } from "@dxos/log";
2200
2200
  import { Presence } from "@dxos/teleport-extension-presence";
@@ -2204,7 +2204,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
2204
2204
  import { trackLeaks } from "@dxos/async";
2205
2205
  import { Context as Context6 } from "@dxos/context";
2206
2206
  import { timed } from "@dxos/debug";
2207
- import { DataPipelineControllerImpl, createMappedFeedWriter } from "@dxos/echo-db";
2207
+ import { DataPipelineControllerImpl, createMappedFeedWriter } from "@dxos/echo-pipeline";
2208
2208
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2209
2209
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2210
2210
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
@@ -3013,18 +3013,133 @@ var toStorageType = (type) => {
3013
3013
  }
3014
3014
  };
3015
3015
 
3016
+ // packages/sdk/client-services/src/packlets/vault/services.ts
3017
+ import { schema as schema7 } from "@dxos/protocols";
3018
+ var iframeServiceBundle = {
3019
+ IframeService: schema7.getService("dxos.iframe.IframeService"),
3020
+ BridgeService: schema7.getService("dxos.mesh.bridge.BridgeService")
3021
+ };
3022
+ var workerServiceBundle = {
3023
+ WorkerService: schema7.getService("dxos.iframe.WorkerService")
3024
+ };
3025
+ var appServiceBundle = {
3026
+ AppService: schema7.getService("dxos.iframe.AppService")
3027
+ };
3028
+ var shellServiceBundle = {
3029
+ ShellService: schema7.getService("dxos.iframe.ShellService")
3030
+ };
3031
+
3032
+ // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
3033
+ import assert13 from "@dxos/node-std/assert";
3034
+ import { Event as Event5 } from "@dxos/async";
3035
+ import { ShellLayout } from "@dxos/protocols/proto/dxos/iframe";
3036
+ import { createProtoRpcPeer } from "@dxos/rpc";
3037
+ var ShellRuntimeImpl = class {
3038
+ constructor(_port) {
3039
+ this._port = _port;
3040
+ this.layoutUpdate = new Event5();
3041
+ this._layout = ShellLayout.DEFAULT;
3042
+ }
3043
+ get layout() {
3044
+ return this._layout;
3045
+ }
3046
+ get invitationCode() {
3047
+ return this._invitationCode;
3048
+ }
3049
+ get spaceKey() {
3050
+ return this._spaceKey;
3051
+ }
3052
+ setLayout(layout, options = {}) {
3053
+ this._layout = layout;
3054
+ this._invitationCode = options.invitationCode;
3055
+ this._spaceKey = options.spaceKey;
3056
+ this.layoutUpdate.emit({
3057
+ layout,
3058
+ ...options
3059
+ });
3060
+ }
3061
+ async setAppContext(context) {
3062
+ assert13(this._appRpc, "runtime not open");
3063
+ if (context.spaceKey) {
3064
+ this._spaceKey = context.spaceKey;
3065
+ }
3066
+ if (context.invitationCode) {
3067
+ this._invitationCode = context.invitationCode;
3068
+ }
3069
+ await this._appRpc.rpc.AppService.setContext({
3070
+ ...context,
3071
+ spaceKey: this._spaceKey,
3072
+ invitationCode: this._invitationCode
3073
+ });
3074
+ }
3075
+ async open() {
3076
+ this._appRpc = createProtoRpcPeer({
3077
+ requested: appServiceBundle,
3078
+ exposed: shellServiceBundle,
3079
+ handlers: {
3080
+ ShellService: {
3081
+ setLayout: async (request) => {
3082
+ this._layout = request.layout;
3083
+ this._invitationCode = request.invitationCode;
3084
+ this._spaceKey = request.spaceKey;
3085
+ this.layoutUpdate.emit(request);
3086
+ }
3087
+ }
3088
+ },
3089
+ port: this._port
3090
+ });
3091
+ await this._appRpc.open();
3092
+ }
3093
+ async close() {
3094
+ var _a;
3095
+ await ((_a = this._appRpc) == null ? void 0 : _a.close());
3096
+ this._appRpc = void 0;
3097
+ }
3098
+ };
3099
+ var MemoryShellRuntime = class {
3100
+ constructor({ layout, invitationCode, spaceKey } = {}) {
3101
+ this.layoutUpdate = new Event5();
3102
+ this.contextUpdate = new Event5();
3103
+ this._layout = layout != null ? layout : ShellLayout.DEFAULT;
3104
+ this._invitationCode = invitationCode;
3105
+ this._spaceKey = spaceKey;
3106
+ }
3107
+ get layout() {
3108
+ return this._layout;
3109
+ }
3110
+ get invitationCode() {
3111
+ return this._invitationCode;
3112
+ }
3113
+ get spaceKey() {
3114
+ return this._spaceKey;
3115
+ }
3116
+ setLayout(layout, options = {}) {
3117
+ this._layout = layout;
3118
+ this._invitationCode = options.invitationCode;
3119
+ this._spaceKey = options.spaceKey;
3120
+ this.layoutUpdate.emit({
3121
+ layout,
3122
+ ...options
3123
+ });
3124
+ }
3125
+ async setAppContext(context) {
3126
+ this.contextUpdate.emit(context);
3127
+ }
3128
+ };
3129
+
3016
3130
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3017
3131
  import { Trigger as Trigger9 } from "@dxos/async";
3018
- import { log as log16, logInfo as logInfo2 } from "@dxos/log";
3132
+ import { log as log17, logInfo as logInfo2 } from "@dxos/log";
3019
3133
  import { MemorySignalManager as MemorySignalManager2, MemorySignalManagerContext as MemorySignalManagerContext2, WebsocketSignalManager as WebsocketSignalManager2 } from "@dxos/messaging";
3020
3134
  import { createWebRTCTransportFactory, NetworkManager as NetworkManager2 } from "@dxos/network-manager";
3021
- import { createProtoRpcPeer as createProtoRpcPeer4 } from "@dxos/rpc";
3135
+ import { createProtoRpcPeer as createProtoRpcPeer6 } from "@dxos/rpc";
3136
+ import { getAsyncValue } from "@dxos/util";
3022
3137
 
3023
3138
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3024
3139
  import { raise as raise2 } from "@dxos/debug";
3025
3140
  import { DocumentModel } from "@dxos/document-model";
3026
- import { DataServiceImpl } from "@dxos/echo-db";
3027
- import { log as log15 } from "@dxos/log";
3141
+ import { DataServiceImpl } from "@dxos/echo-pipeline";
3142
+ import { log as log16 } from "@dxos/log";
3028
3143
  import { ModelFactory } from "@dxos/model-factory";
3029
3144
  import { Status } from "@dxos/protocols/proto/dxos/client";
3030
3145
  import { TextModel } from "@dxos/text-model";
@@ -3097,7 +3212,7 @@ var NetworkServiceImpl = class {
3097
3212
  import { scheduleTask as scheduleTask4 } from "@dxos/async";
3098
3213
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
3099
3214
  import { raise } from "@dxos/debug";
3100
- import { SpaceNotFoundError } from "@dxos/echo-db";
3215
+ import { SpaceNotFoundError } from "@dxos/echo-pipeline";
3101
3216
  var SpacesServiceImpl = class {
3102
3217
  constructor(_spaceManager) {
3103
3218
  this._spaceManager = _spaceManager;
@@ -3139,26 +3254,15 @@ var SpacesServiceImpl = class {
3139
3254
 
3140
3255
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3141
3256
  import { WebRTCTransportService } from "@dxos/network-manager";
3142
- import { createProtoRpcPeer } from "@dxos/rpc";
3143
-
3144
- // packages/sdk/client-services/src/packlets/vault/services.ts
3145
- import { schema as schema7 } from "@dxos/protocols";
3146
- var iframeServiceBundle = {
3147
- IframeService: schema7.getService("dxos.iframe.IframeService"),
3148
- BridgeService: schema7.getService("dxos.mesh.bridge.BridgeService")
3149
- };
3150
- var workerServiceBundle = {
3151
- WorkerService: schema7.getService("dxos.iframe.WorkerService")
3152
- };
3153
-
3154
- // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3257
+ import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
3155
3258
  var IFrameProxyRuntime = class {
3156
- constructor({ systemPort, workerAppPort, windowAppPort }) {
3259
+ constructor({ systemPort, workerAppPort, windowAppPort, shellPort }) {
3157
3260
  this._transportService = new WebRTCTransportService();
3158
3261
  this._systemPort = systemPort;
3159
3262
  this._windowAppPort = windowAppPort;
3160
3263
  this._workerAppPort = workerAppPort;
3161
- this._systemRpc = createProtoRpcPeer({
3264
+ this._shellPort = shellPort;
3265
+ this._systemRpc = createProtoRpcPeer2({
3162
3266
  requested: workerServiceBundle,
3163
3267
  exposed: iframeServiceBundle,
3164
3268
  handlers: {
@@ -3173,22 +3277,109 @@ var IFrameProxyRuntime = class {
3173
3277
  });
3174
3278
  this._workerAppPort.subscribe((msg) => this._windowAppPort.send(msg));
3175
3279
  this._windowAppPort.subscribe((msg) => this._workerAppPort.send(msg));
3280
+ if (this._shellPort) {
3281
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3282
+ }
3283
+ }
3284
+ get shell() {
3285
+ return this._shellRuntime;
3176
3286
  }
3177
3287
  async open(origin) {
3288
+ var _a;
3178
3289
  await this._systemRpc.open();
3179
3290
  await this._systemRpc.rpc.WorkerService.start({
3180
3291
  origin
3181
3292
  });
3293
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
3182
3294
  }
3183
3295
  async close() {
3296
+ var _a;
3297
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
3184
3298
  await this._systemRpc.rpc.WorkerService.stop();
3185
3299
  await this._systemRpc.close();
3186
3300
  }
3187
3301
  };
3188
3302
 
3303
+ // packages/sdk/client-services/src/packlets/vault/shell-controller.ts
3304
+ import { Event as Event6 } from "@dxos/async";
3305
+ import { log as log12 } from "@dxos/log";
3306
+ import { ShellDisplay } from "@dxos/protocols/proto/dxos/iframe";
3307
+ import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
3308
+ var ShellController = class {
3309
+ constructor(_port) {
3310
+ this._port = _port;
3311
+ this.contextUpdate = new Event6();
3312
+ this._display = ShellDisplay.NONE;
3313
+ }
3314
+ get display() {
3315
+ return this._display;
3316
+ }
3317
+ get spaceKey() {
3318
+ return this._spaceKey;
3319
+ }
3320
+ setSpace(key) {
3321
+ this._spaceKey = key;
3322
+ this._emitUpdate();
3323
+ }
3324
+ async setLayout(layout, options = {}) {
3325
+ var _a;
3326
+ log12("set layout", {
3327
+ layout,
3328
+ ...options
3329
+ }, {
3330
+ file: "shell-controller.ts",
3331
+ line: 39,
3332
+ scope: this,
3333
+ callSite: (f, a) => f(...a)
3334
+ });
3335
+ this._display = ShellDisplay.FULLSCREEN;
3336
+ this._emitUpdate();
3337
+ await ((_a = this._shellRpc) == null ? void 0 : _a.rpc.ShellService.setLayout({
3338
+ layout,
3339
+ ...options
3340
+ }));
3341
+ }
3342
+ async open() {
3343
+ this._shellRpc = createProtoRpcPeer3({
3344
+ requested: shellServiceBundle,
3345
+ exposed: appServiceBundle,
3346
+ handlers: {
3347
+ AppService: {
3348
+ setContext: async (request) => {
3349
+ log12("set context", request, {
3350
+ file: "shell-controller.ts",
3351
+ line: 52,
3352
+ scope: this,
3353
+ callSite: (f, a) => f(...a)
3354
+ });
3355
+ this._display = request.display;
3356
+ this._spaceKey = request.spaceKey;
3357
+ this._invitationCode = request.invitationCode;
3358
+ this.contextUpdate.emit(request);
3359
+ }
3360
+ }
3361
+ },
3362
+ port: this._port
3363
+ });
3364
+ await this._shellRpc.open();
3365
+ }
3366
+ async close() {
3367
+ var _a;
3368
+ await ((_a = this._shellRpc) == null ? void 0 : _a.close());
3369
+ this._shellRpc = void 0;
3370
+ }
3371
+ _emitUpdate() {
3372
+ this.contextUpdate.emit({
3373
+ display: this._display,
3374
+ spaceKey: this._spaceKey,
3375
+ invitationCode: this._invitationCode
3376
+ });
3377
+ }
3378
+ };
3379
+
3189
3380
  // packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
3190
3381
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3191
- import { log as log12 } from "@dxos/log";
3382
+ import { log as log13 } from "@dxos/log";
3192
3383
  var Message;
3193
3384
  (function(Message2) {
3194
3385
  Message2["ACQUIRING"] = "acquiring";
@@ -3221,7 +3412,7 @@ var VaultResourceLock = class {
3221
3412
  }
3222
3413
  }
3223
3414
  async _requestLock(steal = false) {
3224
- log12("requesting lock...", {
3415
+ log13("requesting lock...", {
3225
3416
  steal
3226
3417
  }, {
3227
3418
  file: "vault-resource-lock.ts",
@@ -3238,14 +3429,14 @@ var VaultResourceLock = class {
3238
3429
  acquired.wake();
3239
3430
  this._releaseTrigger = new Trigger6();
3240
3431
  await this._releaseTrigger.wait();
3241
- log12("releasing lock...", {}, {
3432
+ log13("releasing lock...", {}, {
3242
3433
  file: "vault-resource-lock.ts",
3243
3434
  line: 65,
3244
3435
  scope: this,
3245
3436
  callSite: (f, a) => f(...a)
3246
3437
  });
3247
3438
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3248
- log12("released lock", {}, {
3439
+ log13("released lock", {}, {
3249
3440
  file: "vault-resource-lock.ts",
3250
3441
  line: 67,
3251
3442
  scope: this,
@@ -3256,7 +3447,7 @@ var VaultResourceLock = class {
3256
3447
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3257
3448
  });
3258
3449
  await acquired.wait();
3259
- log12("recieved lock", {
3450
+ log13("recieved lock", {
3260
3451
  steal
3261
3452
  }, {
3262
3453
  file: "vault-resource-lock.ts",
@@ -3269,15 +3460,15 @@ var VaultResourceLock = class {
3269
3460
 
3270
3461
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
3271
3462
  import { Trigger as Trigger8 } from "@dxos/async";
3272
- import { log as log14 } from "@dxos/log";
3463
+ import { log as log15 } from "@dxos/log";
3273
3464
  import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from "@dxos/messaging";
3274
3465
  import { NetworkManager, WebRTCTransportProxyFactory } from "@dxos/network-manager";
3275
3466
 
3276
3467
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
3277
- import assert13 from "@dxos/node-std/assert";
3278
- import { Trigger as Trigger7 } from "@dxos/async";
3279
- import { log as log13, logInfo } from "@dxos/log";
3280
- import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
3468
+ import assert14 from "@dxos/node-std/assert";
3469
+ import { asyncTimeout as asyncTimeout2, Trigger as Trigger7 } from "@dxos/async";
3470
+ import { log as log14, logInfo } from "@dxos/log";
3471
+ import { createProtoRpcPeer as createProtoRpcPeer4 } from "@dxos/rpc";
3281
3472
  import { Callback } from "@dxos/util";
3282
3473
  var __decorate3 = function(decorators, target, key, desc) {
3283
3474
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3290,33 +3481,39 @@ var __decorate3 = function(decorators, target, key, desc) {
3290
3481
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3291
3482
  };
3292
3483
  var WorkerSession = class {
3293
- constructor({ getService, systemPort, appPort, options = {
3484
+ constructor({ getService, systemPort, appPort, shellPort, options = {
3294
3485
  heartbeatInterval: 1e3
3295
3486
  } }) {
3296
3487
  this._startTrigger = new Trigger7();
3297
3488
  this.onClose = new Callback();
3298
- assert13(options);
3299
- assert13(getService);
3489
+ assert14(options);
3490
+ assert14(getService);
3300
3491
  this._options = options;
3301
3492
  this._getService = getService;
3302
- this._clientRpc = createProtoRpcPeer2({
3493
+ const handlers = {
3494
+ DataService: async () => await this._getService((services) => services.DataService),
3495
+ DevicesService: async () => await this._getService((services) => services.DevicesService),
3496
+ DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
3497
+ HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
3498
+ NetworkService: async () => await this._getService((services) => services.NetworkService),
3499
+ ProfileService: async () => await this._getService((services) => services.ProfileService),
3500
+ SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
3501
+ SpaceService: async () => await this._getService((services) => services.SpaceService),
3502
+ SpacesService: async () => await this._getService((services) => services.SpacesService),
3503
+ SystemService: async () => await this._getService((services) => services.SystemService),
3504
+ TracingService: async () => await this._getService((services) => services.TracingService)
3505
+ };
3506
+ this._clientRpc = createProtoRpcPeer4({
3303
3507
  exposed: clientServiceBundle,
3304
- handlers: {
3305
- DataService: async () => await this._getService((services) => services.DataService),
3306
- DevicesService: async () => await this._getService((services) => services.DevicesService),
3307
- DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
3308
- HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
3309
- NetworkService: async () => await this._getService((services) => services.NetworkService),
3310
- ProfileService: async () => await this._getService((services) => services.ProfileService),
3311
- SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
3312
- SpaceService: async () => await this._getService((services) => services.SpaceService),
3313
- SpacesService: async () => await this._getService((services) => services.SpacesService),
3314
- SystemService: async () => await this._getService((services) => services.SystemService),
3315
- TracingService: async () => await this._getService((services) => services.TracingService)
3316
- },
3508
+ handlers,
3317
3509
  port: appPort
3318
3510
  });
3319
- this._iframeRpc = createProtoRpcPeer2({
3511
+ this._shellClientRpc = createProtoRpcPeer4({
3512
+ exposed: clientServiceBundle,
3513
+ handlers,
3514
+ port: shellPort
3515
+ });
3516
+ this._iframeRpc = createProtoRpcPeer4({
3320
3517
  requested: iframeServiceBundle,
3321
3518
  exposed: workerServiceBundle,
3322
3519
  handlers: {
@@ -3330,9 +3527,9 @@ var WorkerSession = class {
3330
3527
  try {
3331
3528
  await this.close();
3332
3529
  } catch (err) {
3333
- log13.catch(err, {}, {
3530
+ log14.catch(err, {}, {
3334
3531
  file: "worker-session.ts",
3335
- line: 90,
3532
+ line: 92,
3336
3533
  scope: this,
3337
3534
  callSite: (f, a) => f(...a)
3338
3535
  });
@@ -3348,15 +3545,16 @@ var WorkerSession = class {
3348
3545
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
3349
3546
  }
3350
3547
  async open() {
3351
- log13.info("opening..", {}, {
3548
+ log14.info("opening..", {}, {
3352
3549
  file: "worker-session.ts",
3353
- line: 104,
3550
+ line: 106,
3354
3551
  scope: this,
3355
3552
  callSite: (f, a) => f(...a)
3356
3553
  });
3357
3554
  await Promise.all([
3358
3555
  this._clientRpc.open(),
3359
- this._iframeRpc.open()
3556
+ this._iframeRpc.open(),
3557
+ this._maybeOpenShell()
3360
3558
  ]);
3361
3559
  await this._startTrigger.wait({
3362
3560
  timeout: 3e3
@@ -3365,20 +3563,20 @@ var WorkerSession = class {
3365
3563
  try {
3366
3564
  await this._iframeRpc.rpc.IframeService.heartbeat();
3367
3565
  } catch (err1) {
3368
- log13.warn("Heartbeat failed", {
3566
+ log14.warn("Heartbeat failed", {
3369
3567
  err: err1
3370
3568
  }, {
3371
3569
  file: "worker-session.ts",
3372
- line: 116,
3570
+ line: 118,
3373
3571
  scope: this,
3374
3572
  callSite: (f, a) => f(...a)
3375
3573
  });
3376
3574
  try {
3377
3575
  await this.close();
3378
3576
  } catch (err) {
3379
- log13.catch(err, {}, {
3577
+ log14.catch(err, {}, {
3380
3578
  file: "worker-session.ts",
3381
- line: 120,
3579
+ line: 122,
3382
3580
  scope: this,
3383
3581
  callSite: (f, a) => f(...a)
3384
3582
  });
@@ -3387,18 +3585,18 @@ var WorkerSession = class {
3387
3585
  }, this._options.heartbeatInterval);
3388
3586
  }
3389
3587
  async close() {
3390
- log13.info("closing..", {}, {
3588
+ log14.info("closing..", {}, {
3391
3589
  file: "worker-session.ts",
3392
- line: 127,
3590
+ line: 129,
3393
3591
  scope: this,
3394
3592
  callSite: (f, a) => f(...a)
3395
3593
  });
3396
3594
  try {
3397
3595
  await this.onClose.callIfSet();
3398
3596
  } catch (err) {
3399
- log13.catch(err, {}, {
3597
+ log14.catch(err, {}, {
3400
3598
  file: "worker-session.ts",
3401
- line: 131,
3599
+ line: 133,
3402
3600
  scope: this,
3403
3601
  callSite: (f, a) => f(...a)
3404
3602
  });
@@ -3411,6 +3609,18 @@ var WorkerSession = class {
3411
3609
  this._iframeRpc.close()
3412
3610
  ]);
3413
3611
  }
3612
+ async _maybeOpenShell() {
3613
+ try {
3614
+ await asyncTimeout2(this._shellClientRpc.open(), 1e3);
3615
+ } catch (e) {
3616
+ log14.info("No shell connected.", {}, {
3617
+ file: "worker-session.ts",
3618
+ line: 147,
3619
+ scope: this,
3620
+ callSite: (f, a) => f(...a)
3621
+ });
3622
+ }
3623
+ }
3414
3624
  };
3415
3625
  __decorate3([
3416
3626
  logInfo
@@ -3426,9 +3636,9 @@ var WorkerRuntime = class {
3426
3636
  this.sessions = /* @__PURE__ */ new Set();
3427
3637
  }
3428
3638
  async start() {
3429
- log14("starting...", {}, {
3639
+ log15("starting...", {}, {
3430
3640
  file: "worker-runtime.ts",
3431
- line: 41,
3641
+ line: 42,
3432
3642
  scope: this,
3433
3643
  callSite: (f, a) => f(...a)
3434
3644
  });
@@ -3447,17 +3657,17 @@ var WorkerRuntime = class {
3447
3657
  });
3448
3658
  await this._clientServices.open();
3449
3659
  this._ready.wake(void 0);
3450
- log14("started", {}, {
3660
+ log15("started", {}, {
3451
3661
  file: "worker-runtime.ts",
3452
- line: 58,
3662
+ line: 59,
3453
3663
  scope: this,
3454
3664
  callSite: (f, a) => f(...a)
3455
3665
  });
3456
3666
  } catch (err) {
3457
3667
  this._ready.wake(err);
3458
- log14.catch(err, {}, {
3668
+ log15.catch(err, {}, {
3459
3669
  file: "worker-runtime.ts",
3460
- line: 61,
3670
+ line: 62,
3461
3671
  scope: this,
3462
3672
  callSite: (f, a) => f(...a)
3463
3673
  });
@@ -3469,7 +3679,7 @@ var WorkerRuntime = class {
3469
3679
  /**
3470
3680
  * Create a new session.
3471
3681
  */
3472
- async createSession({ appPort, systemPort }) {
3682
+ async createSession({ appPort, systemPort, shellPort }) {
3473
3683
  const session = new WorkerSession({
3474
3684
  getService: async (find) => {
3475
3685
  const error = await this._ready.wait();
@@ -3484,6 +3694,7 @@ var WorkerRuntime = class {
3484
3694
  },
3485
3695
  appPort,
3486
3696
  systemPort,
3697
+ shellPort,
3487
3698
  readySignal: this._ready
3488
3699
  });
3489
3700
  session.onClose.set(async () => {
@@ -3595,7 +3806,7 @@ var ClientServicesHost = class {
3595
3806
  if (this._open) {
3596
3807
  return;
3597
3808
  }
3598
- log15("opening...", {}, {
3809
+ log16("opening...", {}, {
3599
3810
  file: "service-host.ts",
3600
3811
  line: 125,
3601
3812
  scope: this,
@@ -3631,7 +3842,7 @@ var ClientServicesHost = class {
3631
3842
  await this._serviceContext.open();
3632
3843
  this._open = true;
3633
3844
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
3634
- log15("opened", {
3845
+ log16("opened", {
3635
3846
  deviceKey
3636
3847
  }, {
3637
3848
  file: "service-host.ts",
@@ -3646,7 +3857,7 @@ var ClientServicesHost = class {
3646
3857
  return;
3647
3858
  }
3648
3859
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
3649
- log15("closing...", {
3860
+ log16("closing...", {
3650
3861
  deviceKey
3651
3862
  }, {
3652
3863
  file: "service-host.ts",
@@ -3659,7 +3870,7 @@ var ClientServicesHost = class {
3659
3870
  });
3660
3871
  await this._serviceContext.close();
3661
3872
  this._open = false;
3662
- log15("closed", {
3873
+ log16("closed", {
3663
3874
  deviceKey
3664
3875
  }, {
3665
3876
  file: "service-host.ts",
@@ -3671,14 +3882,14 @@ var ClientServicesHost = class {
3671
3882
  };
3672
3883
 
3673
3884
  // packages/sdk/client-services/src/packlets/services/service-proxy.ts
3674
- import { asyncTimeout as asyncTimeout2 } from "@dxos/async";
3885
+ import { asyncTimeout as asyncTimeout3 } from "@dxos/async";
3675
3886
  import { RemoteServiceConnectionTimeout } from "@dxos/errors";
3676
- import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
3887
+ import { createProtoRpcPeer as createProtoRpcPeer5 } from "@dxos/rpc";
3677
3888
  var ClientServicesProxy = class {
3678
3889
  // prettier-ignore
3679
3890
  constructor(port, _timeout = 3e4) {
3680
3891
  this._timeout = _timeout;
3681
- this._proxy = createProtoRpcPeer3({
3892
+ this._proxy = createProtoRpcPeer5({
3682
3893
  requested: clientServiceBundle,
3683
3894
  exposed: {},
3684
3895
  handlers: {},
@@ -3695,7 +3906,7 @@ var ClientServicesProxy = class {
3695
3906
  return this._proxy.rpc;
3696
3907
  }
3697
3908
  async open() {
3698
- await asyncTimeout2(this._proxy.open(), this._timeout, new RemoteServiceConnectionTimeout());
3909
+ await asyncTimeout3(this._proxy.open(), this._timeout, new RemoteServiceConnectionTimeout());
3699
3910
  }
3700
3911
  async close() {
3701
3912
  await this._proxy.close();
@@ -3715,11 +3926,12 @@ var __decorate4 = function(decorators, target, key, desc) {
3715
3926
  };
3716
3927
  var LOCK_KEY = "DXOS_RESOURCE_LOCK";
3717
3928
  var IFrameHostRuntime = class {
3718
- constructor({ configProvider, appPort }) {
3929
+ constructor({ configProvider, appPort, shellPort }) {
3719
3930
  this._transportFactory = createWebRTCTransportFactory();
3720
3931
  this._ready = new Trigger9();
3721
3932
  this._configProvider = configProvider;
3722
3933
  this._appPort = appPort;
3934
+ this._shellPort = shellPort;
3723
3935
  this._getService = async (find) => {
3724
3936
  const error = await this._ready.wait();
3725
3937
  if (error) {
@@ -3731,16 +3943,26 @@ var IFrameHostRuntime = class {
3731
3943
  }
3732
3944
  return service;
3733
3945
  };
3946
+ if (this._shellPort) {
3947
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3948
+ }
3949
+ }
3950
+ get services() {
3951
+ return this._clientServices;
3952
+ }
3953
+ get shell() {
3954
+ return this._shellRuntime;
3734
3955
  }
3735
3956
  async start() {
3736
- log16("starting...", {}, {
3957
+ var _a;
3958
+ log17("starting...", {}, {
3737
3959
  file: "iframe-host-runtime.ts",
3738
- line: 63,
3960
+ line: 81,
3739
3961
  scope: this,
3740
3962
  callSite: (f, a) => f(...a)
3741
3963
  });
3742
3964
  try {
3743
- this._config = await this._configProvider();
3965
+ this._config = await getAsyncValue(this._configProvider);
3744
3966
  const signalServer = this._config.get("runtime.services.signal.server");
3745
3967
  this._clientServices = new ClientServicesHost({
3746
3968
  lockKey: LOCK_KEY,
@@ -3753,7 +3975,7 @@ var IFrameHostRuntime = class {
3753
3975
  transportFactory: this._transportFactory
3754
3976
  })
3755
3977
  });
3756
- this._clientRpc = createProtoRpcPeer4({
3978
+ this._clientRpc = createProtoRpcPeer6({
3757
3979
  exposed: clientServiceBundle,
3758
3980
  handlers: {
3759
3981
  DataService: async () => await this._getService((services) => services.DataService),
@@ -3772,37 +3994,40 @@ var IFrameHostRuntime = class {
3772
3994
  });
3773
3995
  await Promise.all([
3774
3996
  this._clientServices.open(),
3775
- this._clientRpc.open()
3997
+ this._clientRpc.open(),
3998
+ (_a = this._shellRuntime) == null ? void 0 : _a.open()
3776
3999
  ]);
3777
4000
  this._ready.wake(void 0);
3778
- log16("started", {}, {
4001
+ log17("started", {}, {
3779
4002
  file: "iframe-host-runtime.ts",
3780
- line: 99,
4003
+ line: 117,
3781
4004
  scope: this,
3782
4005
  callSite: (f, a) => f(...a)
3783
4006
  });
3784
4007
  } catch (err) {
3785
4008
  this._ready.wake(err);
3786
- log16.catch(err, {}, {
4009
+ log17.catch(err, {}, {
3787
4010
  file: "iframe-host-runtime.ts",
3788
- line: 102,
4011
+ line: 120,
3789
4012
  scope: this,
3790
4013
  callSite: (f, a) => f(...a)
3791
4014
  });
3792
4015
  }
3793
4016
  }
3794
4017
  async stop() {
3795
- log16("stopping...", {}, {
4018
+ var _a;
4019
+ log17("stopping...", {}, {
3796
4020
  file: "iframe-host-runtime.ts",
3797
- line: 107,
4021
+ line: 125,
3798
4022
  scope: this,
3799
4023
  callSite: (f, a) => f(...a)
3800
4024
  });
3801
4025
  await this._clientRpc.close();
3802
4026
  await this._clientServices.close();
3803
- log16("stopped", {}, {
4027
+ await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
4028
+ log17("stopped", {}, {
3804
4029
  file: "iframe-host-runtime.ts",
3805
- line: 110,
4030
+ line: 129,
3806
4031
  scope: this,
3807
4032
  callSite: (f, a) => f(...a)
3808
4033
  });
@@ -3850,10 +4075,15 @@ export {
3850
4075
  ServiceContext,
3851
4076
  clientServiceBundle,
3852
4077
  createStorageObjects,
3853
- IFrameHostRuntime,
3854
4078
  iframeServiceBundle,
3855
4079
  workerServiceBundle,
4080
+ appServiceBundle,
4081
+ shellServiceBundle,
4082
+ ShellRuntimeImpl,
4083
+ MemoryShellRuntime,
4084
+ IFrameHostRuntime,
3856
4085
  IFrameProxyRuntime,
4086
+ ShellController,
3857
4087
  VaultResourceLock,
3858
4088
  WorkerSession,
3859
4089
  WorkerRuntime,
@@ -3862,4 +4092,4 @@ export {
3862
4092
  ClientServicesHost,
3863
4093
  ClientServicesProxy
3864
4094
  };
3865
- //# sourceMappingURL=chunk-R2FEBB66.mjs.map
4095
+ //# sourceMappingURL=chunk-WF53R6F7.mjs.map