@dxos/client-services 0.5.8 → 0.5.9-main.079a532

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/lib/browser/{chunk-JECXTGZA.mjs → chunk-QZ5LNV55.mjs} +1781 -1480
  2. package/dist/lib/browser/chunk-QZ5LNV55.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +55 -365
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +14 -14
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-OR7LRWDY.cjs → chunk-V7UMWFUS.cjs} +2055 -1761
  9. package/dist/lib/node/chunk-V7UMWFUS.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +92 -397
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +19 -19
  14. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  15. package/dist/types/src/index.d.ts +3 -3
  16. package/dist/types/src/index.d.ts.map +1 -1
  17. package/dist/types/src/packlets/devtools/network.d.ts +4 -4
  18. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  19. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +19 -0
  20. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -0
  21. package/dist/types/src/packlets/identity/identity-service.d.ts +14 -7
  22. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  23. package/dist/types/src/packlets/identity/identity.d.ts +4 -1
  24. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  25. package/dist/types/src/packlets/network/network-service.d.ts +2 -2
  26. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  27. package/dist/types/src/packlets/services/service-context.d.ts +4 -5
  28. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  29. package/dist/types/src/packlets/services/service-host.d.ts +1 -1
  30. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  31. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +4 -1
  32. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  33. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -3
  34. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  35. package/dist/types/src/packlets/spaces/data-space.d.ts +11 -9
  36. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  37. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +23 -0
  38. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -0
  39. package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
  40. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  41. package/dist/types/src/packlets/testing/test-builder.d.ts +11 -9
  42. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  43. package/dist/types/src/packlets/worker/index.d.ts +3 -0
  44. package/dist/types/src/packlets/worker/index.d.ts.map +1 -0
  45. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -0
  46. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -0
  47. package/dist/types/src/version.d.ts +1 -1
  48. package/dist/types/src/version.d.ts.map +1 -1
  49. package/package.json +36 -36
  50. package/src/index.ts +3 -3
  51. package/src/packlets/devtools/network.ts +4 -4
  52. package/src/packlets/identity/default-space-state-machine.ts +44 -0
  53. package/src/packlets/identity/identity-manager.test.ts +2 -2
  54. package/src/packlets/identity/identity-service.test.ts +35 -5
  55. package/src/packlets/identity/identity-service.ts +55 -8
  56. package/src/packlets/identity/identity.test.ts +8 -4
  57. package/src/packlets/identity/identity.ts +25 -2
  58. package/src/packlets/invitations/invitations-handler.ts +2 -2
  59. package/src/packlets/network/network-service.ts +2 -2
  60. package/src/packlets/services/service-context.ts +4 -7
  61. package/src/packlets/services/service-host.ts +16 -44
  62. package/src/packlets/spaces/automerge-space-state.ts +11 -2
  63. package/src/packlets/spaces/data-space-manager.test.ts +46 -1
  64. package/src/packlets/spaces/data-space-manager.ts +81 -31
  65. package/src/packlets/spaces/data-space.ts +89 -132
  66. package/src/packlets/spaces/epoch-migrations.ts +135 -0
  67. package/src/packlets/spaces/spaces-service.ts +5 -2
  68. package/src/packlets/testing/test-builder.ts +16 -14
  69. package/src/packlets/worker/index.ts +6 -0
  70. package/src/version.ts +1 -5
  71. package/dist/lib/browser/chunk-JECXTGZA.mjs.map +0 -7
  72. package/dist/lib/node/chunk-OR7LRWDY.cjs.map +0 -7
  73. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +0 -37
  74. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +0 -1
  75. package/dist/types/src/packlets/vault/index.d.ts +0 -6
  76. package/dist/types/src/packlets/vault/index.d.ts.map +0 -1
  77. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +0 -36
  78. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +0 -1
  79. package/dist/types/src/packlets/vault/shell-runtime.d.ts +0 -33
  80. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +0 -1
  81. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +0 -1
  82. package/dist/types/src/packlets/vault/worker-session.d.ts.map +0 -1
  83. package/src/packlets/vault/iframe-host-runtime.ts +0 -130
  84. package/src/packlets/vault/index.ts +0 -9
  85. package/src/packlets/vault/shared-worker-connection.ts +0 -115
  86. package/src/packlets/vault/shell-runtime.ts +0 -111
  87. /package/dist/types/src/packlets/{vault → worker}/worker-runtime.d.ts +0 -0
  88. /package/dist/types/src/packlets/{vault → worker}/worker-session.d.ts +0 -0
  89. /package/src/packlets/{vault → worker}/worker-runtime.ts +0 -0
  90. /package/src/packlets/{vault → worker}/worker-session.ts +0 -0
@@ -18,173 +18,60 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
- ClientRpcServer: () => import_chunk_OR7LRWDY.ClientRpcServer,
22
- ClientServicesHost: () => import_chunk_OR7LRWDY.ClientServicesHost,
23
- ClientServicesProviderResource: () => import_chunk_OR7LRWDY.ClientServicesProviderResource,
24
- DataSpace: () => import_chunk_OR7LRWDY.DataSpace,
25
- DataSpaceManager: () => import_chunk_OR7LRWDY.DataSpaceManager,
26
- DeviceInvitationProtocol: () => import_chunk_OR7LRWDY.DeviceInvitationProtocol,
27
- DevtoolsHostEvents: () => import_chunk_OR7LRWDY.DevtoolsHostEvents,
28
- DevtoolsServiceImpl: () => import_chunk_OR7LRWDY.DevtoolsServiceImpl,
29
- DiagnosticsCollector: () => import_chunk_OR7LRWDY.DiagnosticsCollector,
30
- IFrameHostRuntime: () => IFrameHostRuntime,
31
- Identity: () => import_chunk_OR7LRWDY.Identity,
32
- IdentityManager: () => import_chunk_OR7LRWDY.IdentityManager,
33
- IdentityServiceImpl: () => import_chunk_OR7LRWDY.IdentityServiceImpl,
34
- InvitationsHandler: () => import_chunk_OR7LRWDY.InvitationsHandler,
35
- InvitationsManager: () => import_chunk_OR7LRWDY.InvitationsManager,
36
- InvitationsServiceImpl: () => import_chunk_OR7LRWDY.InvitationsServiceImpl,
37
- Lock: () => import_chunk_OR7LRWDY.Lock,
38
- ServiceContext: () => import_chunk_OR7LRWDY.ServiceContext,
39
- ServiceRegistry: () => import_chunk_OR7LRWDY.ServiceRegistry,
40
- SharedWorkerConnection: () => SharedWorkerConnection,
41
- ShellRuntimeImpl: () => ShellRuntimeImpl,
42
- SpaceInvitationProtocol: () => import_chunk_OR7LRWDY.SpaceInvitationProtocol,
43
- SpacesServiceImpl: () => import_chunk_OR7LRWDY.SpacesServiceImpl,
44
- TrustedKeySetAuthVerifier: () => import_chunk_OR7LRWDY.TrustedKeySetAuthVerifier,
21
+ ClientRpcServer: () => import_chunk_V7UMWFUS.ClientRpcServer,
22
+ ClientServicesHost: () => import_chunk_V7UMWFUS.ClientServicesHost,
23
+ ClientServicesProviderResource: () => import_chunk_V7UMWFUS.ClientServicesProviderResource,
24
+ DataSpace: () => import_chunk_V7UMWFUS.DataSpace,
25
+ DataSpaceManager: () => import_chunk_V7UMWFUS.DataSpaceManager,
26
+ DeviceInvitationProtocol: () => import_chunk_V7UMWFUS.DeviceInvitationProtocol,
27
+ DevtoolsHostEvents: () => import_chunk_V7UMWFUS.DevtoolsHostEvents,
28
+ DevtoolsServiceImpl: () => import_chunk_V7UMWFUS.DevtoolsServiceImpl,
29
+ DiagnosticsCollector: () => import_chunk_V7UMWFUS.DiagnosticsCollector,
30
+ Identity: () => import_chunk_V7UMWFUS.Identity,
31
+ IdentityManager: () => import_chunk_V7UMWFUS.IdentityManager,
32
+ IdentityServiceImpl: () => import_chunk_V7UMWFUS.IdentityServiceImpl,
33
+ InvitationsHandler: () => import_chunk_V7UMWFUS.InvitationsHandler,
34
+ InvitationsManager: () => import_chunk_V7UMWFUS.InvitationsManager,
35
+ InvitationsServiceImpl: () => import_chunk_V7UMWFUS.InvitationsServiceImpl,
36
+ Lock: () => import_chunk_V7UMWFUS.Lock,
37
+ ServiceContext: () => import_chunk_V7UMWFUS.ServiceContext,
38
+ ServiceRegistry: () => import_chunk_V7UMWFUS.ServiceRegistry,
39
+ SpaceInvitationProtocol: () => import_chunk_V7UMWFUS.SpaceInvitationProtocol,
40
+ SpacesServiceImpl: () => import_chunk_V7UMWFUS.SpacesServiceImpl,
41
+ TrustedKeySetAuthVerifier: () => import_chunk_V7UMWFUS.TrustedKeySetAuthVerifier,
45
42
  WorkerRuntime: () => WorkerRuntime,
46
43
  WorkerSession: () => WorkerSession,
47
- createAdmissionKeypair: () => import_chunk_OR7LRWDY.createAdmissionKeypair,
48
- createAuthProvider: () => import_chunk_OR7LRWDY.createAuthProvider,
49
- createCollectDiagnosticsBroadcastHandler: () => import_chunk_OR7LRWDY.createCollectDiagnosticsBroadcastHandler,
50
- createCollectDiagnosticsBroadcastSender: () => import_chunk_OR7LRWDY.createCollectDiagnosticsBroadcastSender,
51
- createDiagnostics: () => import_chunk_OR7LRWDY.createDiagnostics,
52
- createLevel: () => import_chunk_OR7LRWDY.createLevel,
53
- createStorageObjects: () => import_chunk_OR7LRWDY.createStorageObjects,
54
- findPropertiesObject: () => import_chunk_OR7LRWDY.findPropertiesObject,
55
- getNetworkPeers: () => import_chunk_OR7LRWDY.getNetworkPeers,
56
- isLocked: () => import_chunk_OR7LRWDY.isLocked,
57
- subscribeToFeedBlocks: () => import_chunk_OR7LRWDY.subscribeToFeedBlocks,
58
- subscribeToFeeds: () => import_chunk_OR7LRWDY.subscribeToFeeds,
59
- subscribeToNetworkStatus: () => import_chunk_OR7LRWDY.subscribeToNetworkStatus,
60
- subscribeToNetworkTopics: () => import_chunk_OR7LRWDY.subscribeToNetworkTopics,
61
- subscribeToSignal: () => import_chunk_OR7LRWDY.subscribeToSignal,
62
- subscribeToSpaces: () => import_chunk_OR7LRWDY.subscribeToSpaces,
63
- subscribeToSwarmInfo: () => import_chunk_OR7LRWDY.subscribeToSwarmInfo
44
+ createAdmissionKeypair: () => import_chunk_V7UMWFUS.createAdmissionKeypair,
45
+ createAuthProvider: () => import_chunk_V7UMWFUS.createAuthProvider,
46
+ createCollectDiagnosticsBroadcastHandler: () => import_chunk_V7UMWFUS.createCollectDiagnosticsBroadcastHandler,
47
+ createCollectDiagnosticsBroadcastSender: () => import_chunk_V7UMWFUS.createCollectDiagnosticsBroadcastSender,
48
+ createDiagnostics: () => import_chunk_V7UMWFUS.createDiagnostics,
49
+ createLevel: () => import_chunk_V7UMWFUS.createLevel,
50
+ createStorageObjects: () => import_chunk_V7UMWFUS.createStorageObjects,
51
+ getNetworkPeers: () => import_chunk_V7UMWFUS.getNetworkPeers,
52
+ isLocked: () => import_chunk_V7UMWFUS.isLocked,
53
+ subscribeToFeedBlocks: () => import_chunk_V7UMWFUS.subscribeToFeedBlocks,
54
+ subscribeToFeeds: () => import_chunk_V7UMWFUS.subscribeToFeeds,
55
+ subscribeToNetworkStatus: () => import_chunk_V7UMWFUS.subscribeToNetworkStatus,
56
+ subscribeToNetworkTopics: () => import_chunk_V7UMWFUS.subscribeToNetworkTopics,
57
+ subscribeToSignal: () => import_chunk_V7UMWFUS.subscribeToSignal,
58
+ subscribeToSpaces: () => import_chunk_V7UMWFUS.subscribeToSpaces,
59
+ subscribeToSwarmInfo: () => import_chunk_V7UMWFUS.subscribeToSwarmInfo
64
60
  });
65
61
  module.exports = __toCommonJS(node_exports);
66
- var import_chunk_OR7LRWDY = require("./chunk-OR7LRWDY.cjs");
62
+ var import_chunk_V7UMWFUS = require("./chunk-V7UMWFUS.cjs");
67
63
  var import_async = require("@dxos/async");
68
- var import_client_protocol = require("@dxos/client-protocol");
69
64
  var import_context = require("@dxos/context");
65
+ var import_invariant = require("@dxos/invariant");
70
66
  var import_log = require("@dxos/log");
71
67
  var import_messaging = require("@dxos/messaging");
72
68
  var import_network_manager = require("@dxos/network-manager");
73
- var import_util = require("@dxos/util");
74
69
  var import_async2 = require("@dxos/async");
75
- var import_client_protocol2 = require("@dxos/client-protocol");
76
- var import_invariant = require("@dxos/invariant");
77
- var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
78
- var import_rpc = require("@dxos/rpc");
79
- var import_async3 = require("@dxos/async");
80
- var import_client_protocol3 = require("@dxos/client-protocol");
81
- var import_log2 = require("@dxos/log");
82
- var import_network_manager2 = require("@dxos/network-manager");
83
- var import_protocols = require("@dxos/protocols");
84
- var import_rpc2 = require("@dxos/rpc");
85
- var import_util2 = require("@dxos/util");
86
- var import_async4 = require("@dxos/async");
87
- var import_context2 = require("@dxos/context");
70
+ var import_client_protocol = require("@dxos/client-protocol");
88
71
  var import_invariant2 = require("@dxos/invariant");
89
- var import_log3 = require("@dxos/log");
90
- var import_messaging2 = require("@dxos/messaging");
91
- var import_network_manager3 = require("@dxos/network-manager");
92
- var import_async5 = require("@dxos/async");
93
- var import_client_protocol4 = require("@dxos/client-protocol");
94
- var import_invariant3 = require("@dxos/invariant");
95
- var import_log4 = require("@dxos/log");
96
- var import_rpc3 = require("@dxos/rpc");
97
- var import_util3 = require("@dxos/util");
98
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shell-runtime.ts";
99
- var ShellRuntimeImpl = class {
100
- constructor(_port) {
101
- this._port = _port;
102
- this.layoutUpdate = new import_async2.Event();
103
- this.invitationUrlUpdate = new import_async2.Event();
104
- this._layout = import_iframe.ShellLayout.DEFAULT;
105
- this._invitationUrl = typeof window !== "undefined" ? window.location.origin : void 0;
106
- this._deviceInvitationParam = "deviceInvitationCode";
107
- this._spaceInvitationParam = "spaceInvitationCode";
108
- }
109
- get layout() {
110
- return this._layout;
111
- }
112
- get invitationCode() {
113
- return this._invitationCode;
114
- }
115
- get spaceKey() {
116
- return this._spaceKey;
117
- }
118
- get invitationUrl() {
119
- return this._invitationUrl;
120
- }
121
- get deviceInvitationParam() {
122
- return this._deviceInvitationParam;
123
- }
124
- get spaceInvitationParam() {
125
- return this._spaceInvitationParam;
126
- }
127
- setLayout({ layout, invitationCode, spaceKey }) {
128
- this._layout = layout;
129
- this._invitationCode = invitationCode;
130
- this._spaceKey = spaceKey;
131
- this.layoutUpdate.emit({
132
- layout,
133
- invitationCode,
134
- spaceKey
135
- });
136
- }
137
- setInvitationUrl({ invitationUrl, deviceInvitationParam, spaceInvitationParam }) {
138
- this._invitationUrl = invitationUrl;
139
- this._deviceInvitationParam = deviceInvitationParam;
140
- this._spaceInvitationParam = spaceInvitationParam;
141
- this.invitationUrlUpdate.emit({
142
- invitationUrl,
143
- deviceInvitationParam,
144
- spaceInvitationParam
145
- });
146
- }
147
- async setAppContext(context) {
148
- (0, import_invariant.invariant)(this._appRpc, "runtime not open", {
149
- F: __dxlog_file,
150
- L: 76,
151
- S: this,
152
- A: [
153
- "this._appRpc",
154
- "'runtime not open'"
155
- ]
156
- });
157
- await this._appRpc.rpc.AppService.setContext(context);
158
- }
159
- async open() {
160
- this._appRpc = (0, import_rpc.createProtoRpcPeer)({
161
- requested: import_client_protocol2.appServiceBundle,
162
- exposed: import_client_protocol2.shellServiceBundle,
163
- handlers: {
164
- ShellService: {
165
- setLayout: async (request) => {
166
- this._layout = request.layout;
167
- this._invitationCode = request.invitationCode;
168
- this._spaceKey = request.spaceKey;
169
- this.layoutUpdate.emit(request);
170
- },
171
- setInvitationUrl: async (request) => {
172
- this._invitationUrl = request.invitationUrl;
173
- this._deviceInvitationParam = request.deviceInvitationParam;
174
- this._spaceInvitationParam = request.spaceInvitationParam;
175
- this.invitationUrlUpdate.emit(request);
176
- }
177
- }
178
- },
179
- port: this._port
180
- });
181
- await this._appRpc.open();
182
- }
183
- async close() {
184
- await this._appRpc?.close();
185
- this._appRpc = void 0;
186
- }
187
- };
72
+ var import_log2 = require("@dxos/log");
73
+ var import_rpc = require("@dxos/rpc");
74
+ var import_util = require("@dxos/util");
188
75
  function _ts_decorate(decorators, target, key, desc) {
189
76
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
190
77
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -195,201 +82,13 @@ function _ts_decorate(decorators, target, key, desc) {
195
82
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
196
83
  return c > 3 && r && Object.defineProperty(target, key, r), r;
197
84
  }
198
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
199
- var LOCK_KEY = "DXOS_RESOURCE_LOCK";
200
- var IFrameHostRuntime = class {
201
- constructor({ config, origin, appPort, shellPort }) {
202
- this._ready = new import_async.Trigger();
203
- this._configProvider = config;
204
- this.origin = origin;
205
- this._appPort = appPort;
206
- this._shellPort = shellPort;
207
- if (this._shellPort) {
208
- this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
209
- }
210
- }
211
- get services() {
212
- return this._clientServices;
213
- }
214
- get shell() {
215
- return this._shellRuntime;
216
- }
217
- async start() {
218
- (0, import_log.log)("starting...", void 0, {
219
- F: __dxlog_file2,
220
- L: 73,
221
- S: this,
222
- C: (f, a) => f(...a)
223
- });
224
- try {
225
- this._config = await (0, import_util.getAsyncValue)(this._configProvider);
226
- this._transportFactory = (0, import_network_manager.createSimplePeerTransportFactory)({
227
- iceServers: this._config.get("runtime.services.ice")
228
- });
229
- const signals = this._config.get("runtime.services.signaling");
230
- this._clientServices = new import_chunk_OR7LRWDY.ClientServicesHost({
231
- lockKey: LOCK_KEY,
232
- config: this._config,
233
- signalManager: signals ? new import_messaging.WebsocketSignalManager(signals) : new import_messaging.MemorySignalManager(new import_messaging.MemorySignalManagerContext()),
234
- transportFactory: this._transportFactory
235
- });
236
- const middleware = {
237
- handleCall: async (method, params, handler) => {
238
- const error = await this._ready.wait({
239
- timeout: import_client_protocol.PROXY_CONNECTION_TIMEOUT
240
- });
241
- if (error) {
242
- throw error;
243
- }
244
- return handler(method, params);
245
- },
246
- handleStream: async (method, params, handler) => {
247
- const error = await this._ready.wait({
248
- timeout: import_client_protocol.PROXY_CONNECTION_TIMEOUT
249
- });
250
- if (error) {
251
- throw error;
252
- }
253
- return handler(method, params);
254
- }
255
- };
256
- this._clientRpc = new import_chunk_OR7LRWDY.ClientRpcServer({
257
- serviceRegistry: this._clientServices.serviceRegistry,
258
- port: this._appPort,
259
- ...middleware
260
- });
261
- await Promise.all([
262
- this._clientServices.open(new import_context.Context()),
263
- this._clientRpc.open(),
264
- this._shellRuntime?.open()
265
- ]);
266
- this._ready.wake(void 0);
267
- (0, import_log.log)("started", void 0, {
268
- F: __dxlog_file2,
269
- L: 116,
270
- S: this,
271
- C: (f, a) => f(...a)
272
- });
273
- } catch (err) {
274
- this._ready.wake(err);
275
- import_log.log.catch(err, void 0, {
276
- F: __dxlog_file2,
277
- L: 119,
278
- S: this,
279
- C: (f, a) => f(...a)
280
- });
281
- }
282
- }
283
- async stop() {
284
- (0, import_log.log)("stopping...", void 0, {
285
- F: __dxlog_file2,
286
- L: 124,
287
- S: this,
288
- C: (f, a) => f(...a)
289
- });
290
- await this._clientRpc.close();
291
- await this._clientServices.close();
292
- await this._shellRuntime?.close();
293
- (0, import_log.log)("stopped", void 0, {
294
- F: __dxlog_file2,
295
- L: 128,
296
- S: this,
297
- C: (f, a) => f(...a)
298
- });
299
- }
300
- };
301
- _ts_decorate([
302
- import_log.logInfo
303
- ], IFrameHostRuntime.prototype, "origin", void 0);
304
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shared-worker-connection.ts";
305
- var SharedWorkerConnection = class {
306
- constructor({ config, systemPort, shellPort }) {
307
- this._id = String(Math.floor(Math.random() * 1e6));
308
- this._release = new import_async3.Trigger();
309
- this._configProvider = config;
310
- this._systemPort = systemPort;
311
- this._shellPort = shellPort;
312
- if (this._shellPort) {
313
- this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
314
- }
315
- }
316
- get shell() {
317
- return this._shellRuntime;
318
- }
319
- async open(params) {
320
- this._config = await (0, import_util2.getAsyncValue)(this._configProvider);
321
- this._transportService = new import_network_manager2.SimplePeerTransportService({
322
- iceServers: this._config.get("runtime.services.ice")
323
- });
324
- this._systemRpc = (0, import_rpc2.createProtoRpcPeer)({
325
- requested: import_client_protocol3.workerServiceBundle,
326
- exposed: import_client_protocol3.iframeServiceBundle,
327
- handlers: {
328
- BridgeService: this._transportService
329
- },
330
- port: this._systemPort,
331
- // TODO(wittjosiah): Make longer and factor out to constant.
332
- // TODO(wittjosiah): If this is too long then it breaks the reset flows in Composer.
333
- timeout: 200
334
- });
335
- let lockKey;
336
- if (typeof navigator !== "undefined") {
337
- lockKey = this._lockKey(params.origin);
338
- this._release = new import_async3.Trigger();
339
- const ready = new import_async3.Trigger();
340
- void navigator.locks.request(lockKey, async () => {
341
- ready.wake();
342
- await this._release.wait();
343
- });
344
- await ready.wait();
345
- }
346
- try {
347
- await this._systemRpc.open();
348
- await this._systemRpc.rpc.WorkerService.start({
349
- lockKey,
350
- ...params
351
- });
352
- } catch (err) {
353
- import_log2.log.catch(err, void 0, {
354
- F: __dxlog_file3,
355
- L: 95,
356
- S: this,
357
- C: (f, a) => f(...a)
358
- });
359
- throw new import_protocols.RemoteServiceConnectionError("Failed to connect to worker");
360
- }
361
- await this._shellRuntime?.open();
362
- }
363
- async close() {
364
- this._release.wake();
365
- await this._shellRuntime?.close();
366
- try {
367
- await this._systemRpc.rpc.WorkerService.stop();
368
- } catch {
369
- }
370
- await this._systemRpc.close();
371
- }
372
- _lockKey(origin) {
373
- return `${origin}-${this._id}`;
374
- }
375
- };
376
- function _ts_decorate2(decorators, target, key, desc) {
377
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
378
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
379
- r = Reflect.decorate(decorators, target, key, desc);
380
- else
381
- for (var i = decorators.length - 1; i >= 0; i--)
382
- if (d = decorators[i])
383
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
384
- return c > 3 && r && Object.defineProperty(target, key, r), r;
385
- }
386
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
85
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
387
86
  var WorkerSession = class {
388
87
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
389
- this._startTrigger = new import_async5.Trigger();
390
- this.onClose = new import_util3.Callback();
391
- (0, import_invariant3.invariant)(serviceHost, void 0, {
392
- F: __dxlog_file4,
88
+ this._startTrigger = new import_async2.Trigger();
89
+ this.onClose = new import_util.Callback();
90
+ (0, import_invariant2.invariant)(serviceHost, void 0, {
91
+ F: __dxlog_file,
393
92
  L: 54,
394
93
  S: this,
395
94
  A: [
@@ -401,7 +100,7 @@ var WorkerSession = class {
401
100
  const middleware = {
402
101
  handleCall: async (method, params, handler) => {
403
102
  const error = await readySignal.wait({
404
- timeout: import_client_protocol4.PROXY_CONNECTION_TIMEOUT
103
+ timeout: import_client_protocol.PROXY_CONNECTION_TIMEOUT
405
104
  });
406
105
  if (error) {
407
106
  throw error;
@@ -410,7 +109,7 @@ var WorkerSession = class {
410
109
  },
411
110
  handleStream: async (method, params, handler) => {
412
111
  const error = await readySignal.wait({
413
- timeout: import_client_protocol4.PROXY_CONNECTION_TIMEOUT
112
+ timeout: import_client_protocol.PROXY_CONNECTION_TIMEOUT
414
113
  });
415
114
  if (error) {
416
115
  throw error;
@@ -418,19 +117,19 @@ var WorkerSession = class {
418
117
  return handler(method, params);
419
118
  }
420
119
  };
421
- this._clientRpc = new import_chunk_OR7LRWDY.ClientRpcServer({
120
+ this._clientRpc = new import_chunk_V7UMWFUS.ClientRpcServer({
422
121
  serviceRegistry: this._serviceHost.serviceRegistry,
423
122
  port: appPort,
424
123
  ...middleware
425
124
  });
426
- this._shellClientRpc = shellPort ? new import_chunk_OR7LRWDY.ClientRpcServer({
125
+ this._shellClientRpc = shellPort ? new import_chunk_V7UMWFUS.ClientRpcServer({
427
126
  serviceRegistry: this._serviceHost.serviceRegistry,
428
127
  port: shellPort,
429
128
  ...middleware
430
129
  }) : void 0;
431
- this._iframeRpc = (0, import_rpc3.createProtoRpcPeer)({
432
- requested: import_client_protocol4.iframeServiceBundle,
433
- exposed: import_client_protocol4.workerServiceBundle,
130
+ this._iframeRpc = (0, import_rpc.createProtoRpcPeer)({
131
+ requested: import_client_protocol.iframeServiceBundle,
132
+ exposed: import_client_protocol.workerServiceBundle,
434
133
  handlers: {
435
134
  WorkerService: {
436
135
  start: async (request) => {
@@ -445,8 +144,8 @@ var WorkerSession = class {
445
144
  try {
446
145
  await this.close();
447
146
  } catch (err) {
448
- import_log4.log.catch(err, void 0, {
449
- F: __dxlog_file4,
147
+ import_log2.log.catch(err, void 0, {
148
+ F: __dxlog_file,
450
149
  L: 108,
451
150
  S: this,
452
151
  C: (f, a) => f(...a)
@@ -462,8 +161,8 @@ var WorkerSession = class {
462
161
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
463
162
  }
464
163
  async open() {
465
- import_log4.log.info("opening...", void 0, {
466
- F: __dxlog_file4,
164
+ import_log2.log.info("opening...", void 0, {
165
+ F: __dxlog_file,
467
166
  L: 122,
468
167
  S: this,
469
168
  C: (f, a) => f(...a)
@@ -474,21 +173,21 @@ var WorkerSession = class {
474
173
  this._maybeOpenShell()
475
174
  ]);
476
175
  await this._startTrigger.wait({
477
- timeout: import_client_protocol4.PROXY_CONNECTION_TIMEOUT
176
+ timeout: import_client_protocol.PROXY_CONNECTION_TIMEOUT
478
177
  });
479
178
  if (this.lockKey) {
480
179
  void this._afterLockReleases(this.lockKey, () => this.close());
481
180
  }
482
- import_log4.log.info("opened", void 0, {
483
- F: __dxlog_file4,
181
+ import_log2.log.info("opened", void 0, {
182
+ F: __dxlog_file,
484
183
  L: 133,
485
184
  S: this,
486
185
  C: (f, a) => f(...a)
487
186
  });
488
187
  }
489
188
  async close() {
490
- import_log4.log.info("closing...", void 0, {
491
- F: __dxlog_file4,
189
+ import_log2.log.info("closing...", void 0, {
190
+ F: __dxlog_file,
492
191
  L: 137,
493
192
  S: this,
494
193
  C: (f, a) => f(...a)
@@ -496,8 +195,8 @@ var WorkerSession = class {
496
195
  try {
497
196
  await this.onClose.callIfSet();
498
197
  } catch (err) {
499
- import_log4.log.catch(err, void 0, {
500
- F: __dxlog_file4,
198
+ import_log2.log.catch(err, void 0, {
199
+ F: __dxlog_file,
501
200
  L: 141,
502
201
  S: this,
503
202
  C: (f, a) => f(...a)
@@ -507,8 +206,8 @@ var WorkerSession = class {
507
206
  this._clientRpc.close(),
508
207
  this._iframeRpc.close()
509
208
  ]);
510
- import_log4.log.info("closed", void 0, {
511
- F: __dxlog_file4,
209
+ import_log2.log.info("closed", void 0, {
210
+ F: __dxlog_file,
512
211
  L: 145,
513
212
  S: this,
514
213
  C: (f, a) => f(...a)
@@ -516,10 +215,10 @@ var WorkerSession = class {
516
215
  }
517
216
  async _maybeOpenShell() {
518
217
  try {
519
- this._shellClientRpc && await (0, import_async5.asyncTimeout)(this._shellClientRpc.open(), 1e3);
218
+ this._shellClientRpc && await (0, import_async2.asyncTimeout)(this._shellClientRpc.open(), 1e3);
520
219
  } catch {
521
- import_log4.log.info("No shell connected.", void 0, {
522
- F: __dxlog_file4,
220
+ import_log2.log.info("No shell connected.", void 0, {
221
+ F: __dxlog_file,
523
222
  L: 152,
524
223
  S: this,
525
224
  C: (f, a) => f(...a)
@@ -531,18 +230,18 @@ var WorkerSession = class {
531
230
  }).then(callback);
532
231
  }
533
232
  };
534
- _ts_decorate2([
535
- import_log4.logInfo
233
+ _ts_decorate([
234
+ import_log2.logInfo
536
235
  ], WorkerSession.prototype, "origin", void 0);
537
- _ts_decorate2([
538
- import_log4.logInfo
236
+ _ts_decorate([
237
+ import_log2.logInfo
539
238
  ], WorkerSession.prototype, "lockKey", void 0);
540
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
239
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
541
240
  var WorkerRuntime = class {
542
241
  constructor(_configProvider, { acquireLock, releaseLock, onReset }) {
543
242
  this._configProvider = _configProvider;
544
- this._transportFactory = new import_network_manager3.SimplePeerTransportProxyFactory();
545
- this._ready = new import_async4.Trigger();
243
+ this._transportFactory = new import_network_manager.SimplePeerTransportProxyFactory();
244
+ this._ready = new import_async.Trigger();
546
245
  this._sessions = /* @__PURE__ */ new Set();
547
246
  this._signalMetadataTags = {
548
247
  runtime: "worker-runtime"
@@ -550,7 +249,7 @@ var WorkerRuntime = class {
550
249
  this._signalTelemetryEnabled = false;
551
250
  this._acquireLock = acquireLock;
552
251
  this._releaseLock = releaseLock;
553
- this._clientServices = new import_chunk_OR7LRWDY.ClientServicesHost({
252
+ this._clientServices = new import_chunk_V7UMWFUS.ClientServicesHost({
554
253
  callbacks: {
555
254
  onReset: async () => onReset()
556
255
  }
@@ -560,8 +259,8 @@ var WorkerRuntime = class {
560
259
  return this._clientServices;
561
260
  }
562
261
  async start() {
563
- (0, import_log3.log)("starting...", void 0, {
564
- F: __dxlog_file5,
262
+ (0, import_log.log)("starting...", void 0, {
263
+ F: __dxlog_file2,
565
264
  L: 71,
566
265
  S: this,
567
266
  C: (f, a) => f(...a)
@@ -572,18 +271,18 @@ var WorkerRuntime = class {
572
271
  const signals = this._config.get("runtime.services.signaling");
573
272
  this._clientServices.initialize({
574
273
  config: this._config,
575
- signalManager: signals ? new import_messaging2.WebsocketSignalManager(signals, () => this._signalTelemetryEnabled ? this._signalMetadataTags : {}) : new import_messaging2.MemorySignalManager(new import_messaging2.MemorySignalManagerContext()),
274
+ signalManager: signals ? new import_messaging.WebsocketSignalManager(signals, () => this._signalTelemetryEnabled ? this._signalMetadataTags : {}) : new import_messaging.MemorySignalManager(new import_messaging.MemorySignalManagerContext()),
576
275
  transportFactory: this._transportFactory
577
276
  });
578
- await this._clientServices.open(new import_context2.Context());
277
+ await this._clientServices.open(new import_context.Context());
579
278
  this._ready.wake(void 0);
580
- (0, import_log3.log)("started", void 0, {
581
- F: __dxlog_file5,
279
+ (0, import_log.log)("started", void 0, {
280
+ F: __dxlog_file2,
582
281
  L: 86,
583
282
  S: this,
584
283
  C: (f, a) => f(...a)
585
284
  });
586
- (0, import_messaging2.setIdentityTags)({
285
+ (0, import_messaging.setIdentityTags)({
587
286
  identityService: this._clientServices.services.IdentityService,
588
287
  devicesService: this._clientServices.services.DevicesService,
589
288
  setTag: (k, v) => {
@@ -592,8 +291,8 @@ var WorkerRuntime = class {
592
291
  });
593
292
  } catch (err) {
594
293
  this._ready.wake(err);
595
- import_log3.log.error("starting", err, {
596
- F: __dxlog_file5,
294
+ import_log.log.error("starting", err, {
295
+ F: __dxlog_file2,
597
296
  L: 96,
598
297
  S: this,
599
298
  C: (f, a) => f(...a)
@@ -626,8 +325,8 @@ var WorkerRuntime = class {
626
325
  }
627
326
  });
628
327
  await session.open();
629
- (0, import_invariant2.invariant)(!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin, `worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`, {
630
- F: __dxlog_file5,
328
+ (0, import_invariant.invariant)(!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin, `worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`, {
329
+ F: __dxlog_file2,
631
330
  L: 133,
632
331
  S: this,
633
332
  A: [
@@ -647,8 +346,8 @@ var WorkerRuntime = class {
647
346
  * Selects one of the existing session for WebRTC networking.
648
347
  */
649
348
  _reconnectWebrtc() {
650
- (0, import_log3.log)("reconnecting webrtc...", void 0, {
651
- F: __dxlog_file5,
349
+ (0, import_log.log)("reconnecting webrtc...", void 0, {
350
+ F: __dxlog_file2,
652
351
  L: 151,
653
352
  S: this,
654
353
  C: (f, a) => f(...a)
@@ -680,7 +379,6 @@ var WorkerRuntime = class {
680
379
  DevtoolsHostEvents,
681
380
  DevtoolsServiceImpl,
682
381
  DiagnosticsCollector,
683
- IFrameHostRuntime,
684
382
  Identity,
685
383
  IdentityManager,
686
384
  IdentityServiceImpl,
@@ -690,8 +388,6 @@ var WorkerRuntime = class {
690
388
  Lock,
691
389
  ServiceContext,
692
390
  ServiceRegistry,
693
- SharedWorkerConnection,
694
- ShellRuntimeImpl,
695
391
  SpaceInvitationProtocol,
696
392
  SpacesServiceImpl,
697
393
  TrustedKeySetAuthVerifier,
@@ -704,7 +400,6 @@ var WorkerRuntime = class {
704
400
  createDiagnostics,
705
401
  createLevel,
706
402
  createStorageObjects,
707
- findPropertiesObject,
708
403
  getNetworkPeers,
709
404
  isLocked,
710
405
  subscribeToFeedBlocks,