@dxos/client-services 0.8.4-main.72ec0f3 → 0.8.4-main.74a063c4e0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-HJH6BNTN.mjs → chunk-3LSLNVKQ.mjs} +2102 -1870
- package/dist/lib/browser/chunk-3LSLNVKQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs +22 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs.map +7 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +451 -67
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/browser.mjs +126 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +66 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +36 -17
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ONQM6RQH.mjs → chunk-5S7PIHLS.mjs} +1942 -1579
- package/dist/lib/node-esm/chunk-5S7PIHLS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs +22 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +451 -67
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs +126 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +66 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +36 -17
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +3 -2
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +2 -2
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +6 -6
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +7 -6
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +1 -6
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +8 -11
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +4 -4
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +2 -3
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +3 -3
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -2
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/index.d.ts +1 -1
- package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +4 -0
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/feed-syncer.d.ts +59 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts +2 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +13 -8
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +20 -6
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +9 -1
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +6 -0
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts +2 -0
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +27 -15
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +24 -8
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +2 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -6
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +6 -3
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +6 -5
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +31 -4
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-session.d.ts +2 -2
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +70 -48
- package/src/index.ts +1 -0
- package/src/packlets/agents/edge-agent-manager.ts +8 -5
- package/src/packlets/agents/edge-agent-service.ts +2 -1
- package/src/packlets/devices/devices-service.test.ts +0 -1
- package/src/packlets/devtools/devtools.ts +2 -3
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.ts +2 -2
- package/src/packlets/identity/contacts-service.ts +0 -1
- package/src/packlets/identity/identity-manager.test.ts +5 -5
- package/src/packlets/identity/identity-manager.ts +21 -18
- package/src/packlets/identity/identity-recovery-manager.ts +22 -18
- package/src/packlets/identity/identity-service.test.ts +6 -27
- package/src/packlets/identity/identity-service.ts +5 -76
- package/src/packlets/identity/identity.test.ts +2 -2
- package/src/packlets/identity/identity.ts +9 -32
- package/src/packlets/invitations/device-invitation-protocol.ts +5 -6
- package/src/packlets/invitations/edge-invitation-handler.ts +4 -3
- package/src/packlets/invitations/invitation-guest-extenstion.ts +6 -4
- package/src/packlets/invitations/invitation-host-extension.ts +6 -4
- package/src/packlets/invitations/invitation-protocol.ts +2 -3
- package/src/packlets/invitations/invitations-handler.test.ts +4 -5
- package/src/packlets/invitations/invitations-handler.ts +10 -10
- package/src/packlets/invitations/invitations-manager.ts +37 -14
- package/src/packlets/invitations/invitations-service.ts +4 -4
- package/src/packlets/invitations/space-invitation-protocol.test.ts +17 -16
- package/src/packlets/invitations/space-invitation-protocol.ts +10 -15
- package/src/packlets/locks/index.ts +1 -1
- package/src/packlets/logging/logging-service.ts +4 -0
- package/src/packlets/network/network-service.test.ts +0 -1
- package/src/packlets/network/network-service.ts +5 -4
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/feed-syncer.test.ts +340 -0
- package/src/packlets/services/feed-syncer.ts +337 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.test.ts +3 -2
- package/src/packlets/services/service-context.ts +129 -44
- package/src/packlets/services/service-host.test.ts +8 -8
- package/src/packlets/services/service-host.ts +63 -22
- package/src/packlets/services/service-registry.test.ts +0 -1
- package/src/packlets/space-export/space-archive-reader.ts +64 -3
- package/src/packlets/space-export/space-archive-writer.ts +39 -2
- package/src/packlets/space-export/space-archive.test.ts +287 -0
- package/src/packlets/spaces/data-space-manager.test.ts +79 -13
- package/src/packlets/spaces/data-space-manager.ts +97 -107
- package/src/packlets/spaces/data-space.ts +52 -29
- package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
- package/src/packlets/spaces/edge-feed-replicator.ts +10 -9
- package/src/packlets/spaces/epoch-migrations.ts +5 -5
- package/src/packlets/spaces/genesis.ts +6 -1
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.ts +10 -9
- package/src/packlets/spaces/spaces-service.test.ts +9 -7
- package/src/packlets/spaces/spaces-service.ts +40 -16
- package/src/packlets/storage/storage.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +10 -6
- package/src/packlets/testing/test-builder.ts +36 -10
- package/src/packlets/worker/worker-runtime.ts +150 -13
- package/src/packlets/worker/worker-session.ts +8 -8
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-HJH6BNTN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ONQM6RQH.mjs.map +0 -7
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +0 -19
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +0 -1
- package/src/packlets/identity/default-space-state-machine.ts +0 -44
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
import {
|
|
3
|
-
ClientRpcServer,
|
|
4
3
|
ClientServicesHost,
|
|
5
4
|
DataSpace,
|
|
6
5
|
DataSpaceManager,
|
|
@@ -17,25 +16,21 @@ import {
|
|
|
17
16
|
InvitationsHandler,
|
|
18
17
|
InvitationsManager,
|
|
19
18
|
InvitationsServiceImpl,
|
|
20
|
-
Lock,
|
|
21
19
|
ServiceContext,
|
|
22
20
|
ServiceRegistry,
|
|
21
|
+
SpaceArchiveWriter,
|
|
23
22
|
SpaceInvitationProtocol,
|
|
24
23
|
SpacesServiceImpl,
|
|
25
24
|
TrustedKeySetAuthVerifier,
|
|
26
25
|
createAdmissionKeypair,
|
|
27
26
|
createAuthProvider,
|
|
28
|
-
createCollectDiagnosticsBroadcastHandler,
|
|
29
|
-
createCollectDiagnosticsBroadcastSender,
|
|
30
27
|
createDiagnostics,
|
|
31
28
|
createLevel,
|
|
32
29
|
createStorageObjects,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exportProfileData,
|
|
30
|
+
diagnostics_exports,
|
|
31
|
+
extractSpaceArchive,
|
|
36
32
|
getNetworkPeers,
|
|
37
|
-
|
|
38
|
-
isLocked,
|
|
33
|
+
locks_exports,
|
|
39
34
|
subscribeToFeedBlocks,
|
|
40
35
|
subscribeToFeeds,
|
|
41
36
|
subscribeToNetworkStatus,
|
|
@@ -43,31 +38,334 @@ import {
|
|
|
43
38
|
subscribeToSignal,
|
|
44
39
|
subscribeToSpaces,
|
|
45
40
|
subscribeToSwarmInfo
|
|
46
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-3LSLNVKQ.mjs";
|
|
42
|
+
import "./chunk-NQSC7HOE.mjs";
|
|
43
|
+
import {
|
|
44
|
+
__export,
|
|
45
|
+
__reExport
|
|
46
|
+
} from "./chunk-QCWEHHJW.mjs";
|
|
47
|
+
|
|
48
|
+
// src/index.ts
|
|
49
|
+
var index_exports = {};
|
|
50
|
+
__export(index_exports, {
|
|
51
|
+
ClientRpcServer: () => ClientRpcServer,
|
|
52
|
+
ClientServicesHost: () => ClientServicesHost,
|
|
53
|
+
DataSpace: () => DataSpace,
|
|
54
|
+
DataSpaceManager: () => DataSpaceManager,
|
|
55
|
+
DeviceInvitationProtocol: () => DeviceInvitationProtocol,
|
|
56
|
+
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
57
|
+
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
58
|
+
DiagnosticsCollector: () => DiagnosticsCollector,
|
|
59
|
+
EdgeAgentManager: () => EdgeAgentManager,
|
|
60
|
+
EdgeAgentServiceImpl: () => EdgeAgentServiceImpl,
|
|
61
|
+
EdgeFeedReplicator: () => EdgeFeedReplicator,
|
|
62
|
+
Identity: () => Identity,
|
|
63
|
+
IdentityManager: () => IdentityManager,
|
|
64
|
+
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
65
|
+
InvitationsHandler: () => InvitationsHandler,
|
|
66
|
+
InvitationsManager: () => InvitationsManager,
|
|
67
|
+
InvitationsServiceImpl: () => InvitationsServiceImpl,
|
|
68
|
+
ServiceContext: () => ServiceContext,
|
|
69
|
+
ServiceRegistry: () => ServiceRegistry,
|
|
70
|
+
SpaceArchiveWriter: () => SpaceArchiveWriter,
|
|
71
|
+
SpaceInvitationProtocol: () => SpaceInvitationProtocol,
|
|
72
|
+
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
73
|
+
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
74
|
+
WorkerRuntime: () => WorkerRuntime,
|
|
75
|
+
WorkerSession: () => WorkerSession,
|
|
76
|
+
createAdmissionKeypair: () => createAdmissionKeypair,
|
|
77
|
+
createAuthProvider: () => createAuthProvider,
|
|
78
|
+
createDiagnostics: () => createDiagnostics,
|
|
79
|
+
createLevel: () => createLevel,
|
|
80
|
+
createStorageObjects: () => createStorageObjects,
|
|
81
|
+
decodeProfileArchive: () => decodeProfileArchive,
|
|
82
|
+
encodeProfileArchive: () => encodeProfileArchive,
|
|
83
|
+
exportProfileData: () => exportProfileData,
|
|
84
|
+
extractSpaceArchive: () => extractSpaceArchive,
|
|
85
|
+
getNetworkPeers: () => getNetworkPeers,
|
|
86
|
+
importProfileData: () => importProfileData,
|
|
87
|
+
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
88
|
+
subscribeToFeeds: () => subscribeToFeeds,
|
|
89
|
+
subscribeToNetworkStatus: () => subscribeToNetworkStatus,
|
|
90
|
+
subscribeToNetworkTopics: () => subscribeToNetworkTopics,
|
|
91
|
+
subscribeToSignal: () => subscribeToSignal,
|
|
92
|
+
subscribeToSpaces: () => subscribeToSpaces,
|
|
93
|
+
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
94
|
+
});
|
|
95
|
+
__reExport(index_exports, diagnostics_exports);
|
|
96
|
+
__reExport(index_exports, locks_exports);
|
|
97
|
+
|
|
98
|
+
// src/packlets/services/client-rpc-server.ts
|
|
99
|
+
import { Stream } from "@dxos/codec-protobuf";
|
|
100
|
+
import { raise } from "@dxos/debug";
|
|
101
|
+
import { RpcPeer, parseMethodName } from "@dxos/rpc";
|
|
102
|
+
import { MapCounter, trace } from "@dxos/tracing";
|
|
103
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
104
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
105
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
106
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
107
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
108
|
+
}
|
|
109
|
+
var ClientRpcServer = class {
|
|
110
|
+
_serviceRegistry;
|
|
111
|
+
_rpcPeer;
|
|
112
|
+
_handlerCache = /* @__PURE__ */ new Map();
|
|
113
|
+
_handleCall;
|
|
114
|
+
_handleStream;
|
|
115
|
+
_callMetrics = new MapCounter();
|
|
116
|
+
get _services() {
|
|
117
|
+
return Object.keys(this._serviceRegistry.services);
|
|
118
|
+
}
|
|
119
|
+
constructor(params) {
|
|
120
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
121
|
+
this._handleCall = handleCall;
|
|
122
|
+
this._handleStream = handleStream;
|
|
123
|
+
this._serviceRegistry = serviceRegistry;
|
|
124
|
+
this._rpcPeer = new RpcPeer({
|
|
125
|
+
...rpcOptions,
|
|
126
|
+
callHandler: (method, params2) => {
|
|
127
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
128
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
129
|
+
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
130
|
+
if (this._handleCall) {
|
|
131
|
+
return this._handleCall(methodName, params2, handler);
|
|
132
|
+
} else {
|
|
133
|
+
return handler(methodName, params2);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
streamHandler: (method, params2) => {
|
|
137
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
138
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
139
|
+
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
140
|
+
if (this._handleStream) {
|
|
141
|
+
return Stream.map(Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
|
|
142
|
+
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
143
|
+
return data;
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
return handler(methodName, params2);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async open() {
|
|
152
|
+
await this._rpcPeer.open();
|
|
153
|
+
}
|
|
154
|
+
async close() {
|
|
155
|
+
await this._rpcPeer.close();
|
|
156
|
+
}
|
|
157
|
+
_getServiceHandler(serviceName) {
|
|
158
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
159
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
|
|
160
|
+
const service = this._serviceRegistry.services[key];
|
|
161
|
+
if (!service) {
|
|
162
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
163
|
+
}
|
|
164
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
165
|
+
}
|
|
166
|
+
return this._handlerCache.get(serviceName);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
_ts_decorate([
|
|
170
|
+
trace.metricsCounter()
|
|
171
|
+
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
172
|
+
_ts_decorate([
|
|
173
|
+
trace.info()
|
|
174
|
+
], ClientRpcServer.prototype, "_services", null);
|
|
175
|
+
ClientRpcServer = _ts_decorate([
|
|
176
|
+
trace.resource()
|
|
177
|
+
], ClientRpcServer);
|
|
178
|
+
|
|
179
|
+
// src/packlets/storage/profile-archive.ts
|
|
180
|
+
import { cbor } from "@automerge/automerge-repo";
|
|
181
|
+
import { invariant } from "@dxos/invariant";
|
|
182
|
+
import { log } from "@dxos/log";
|
|
183
|
+
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
184
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
185
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
186
|
+
var encodeProfileArchive = (profile) => cbor.encode(profile);
|
|
187
|
+
var decodeProfileArchive = (data) => cbor.decode(data);
|
|
188
|
+
var exportProfileData = async ({ storage, level }) => {
|
|
189
|
+
const archive = {
|
|
190
|
+
storage: [],
|
|
191
|
+
meta: {
|
|
192
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
{
|
|
196
|
+
const directory = await storage.createDirectory();
|
|
197
|
+
const files = await directory.list();
|
|
198
|
+
log.info("begin exporting files", {
|
|
199
|
+
count: files.length
|
|
200
|
+
}, {
|
|
201
|
+
F: __dxlog_file,
|
|
202
|
+
L: 31,
|
|
203
|
+
S: void 0,
|
|
204
|
+
C: (f, a) => f(...a)
|
|
205
|
+
});
|
|
206
|
+
for (const filename of files) {
|
|
207
|
+
const file = await directory.getOrCreateFile(filename);
|
|
208
|
+
const { size } = await file.stat();
|
|
209
|
+
const data = await file.read(0, size);
|
|
210
|
+
archive.storage.push({
|
|
211
|
+
type: ProfileArchiveEntryType.FILE,
|
|
212
|
+
key: filename,
|
|
213
|
+
value: data
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
log.info("done exporting files", {
|
|
217
|
+
count: files.length
|
|
218
|
+
}, {
|
|
219
|
+
F: __dxlog_file,
|
|
220
|
+
L: 42,
|
|
221
|
+
S: void 0,
|
|
222
|
+
C: (f, a) => f(...a)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
{
|
|
226
|
+
log.info("begin exporting kv pairs", void 0, {
|
|
227
|
+
F: __dxlog_file,
|
|
228
|
+
L: 46,
|
|
229
|
+
S: void 0,
|
|
230
|
+
C: (f, a) => f(...a)
|
|
231
|
+
});
|
|
232
|
+
const iter = await level.iterator({
|
|
233
|
+
keyEncoding: "binary",
|
|
234
|
+
valueEncoding: "binary"
|
|
235
|
+
});
|
|
236
|
+
let count = 0;
|
|
237
|
+
for await (const [key, value] of iter) {
|
|
238
|
+
archive.storage.push({
|
|
239
|
+
type: ProfileArchiveEntryType.KEY_VALUE,
|
|
240
|
+
key,
|
|
241
|
+
value
|
|
242
|
+
});
|
|
243
|
+
count++;
|
|
244
|
+
}
|
|
245
|
+
log.info("done exporting kv pairs", {
|
|
246
|
+
count
|
|
247
|
+
}, {
|
|
248
|
+
F: __dxlog_file,
|
|
249
|
+
L: 57,
|
|
250
|
+
S: void 0,
|
|
251
|
+
C: (f, a) => f(...a)
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return archive;
|
|
255
|
+
};
|
|
256
|
+
var importProfileData = async ({ storage, level }, archive) => {
|
|
257
|
+
let batch = level.batch();
|
|
258
|
+
let count = 0;
|
|
259
|
+
for (const entry of archive.storage) {
|
|
260
|
+
switch (entry.type) {
|
|
261
|
+
case ProfileArchiveEntryType.FILE: {
|
|
262
|
+
const directory = await storage.createDirectory();
|
|
263
|
+
invariant(typeof entry.key === "string", "Invalid key type", {
|
|
264
|
+
F: __dxlog_file,
|
|
265
|
+
L: 80,
|
|
266
|
+
S: void 0,
|
|
267
|
+
A: [
|
|
268
|
+
"typeof entry.key === 'string'",
|
|
269
|
+
"'Invalid key type'"
|
|
270
|
+
]
|
|
271
|
+
});
|
|
272
|
+
const file = await directory.getOrCreateFile(entry.key);
|
|
273
|
+
invariant(entry.value instanceof Uint8Array, "Invalid value type", {
|
|
274
|
+
F: __dxlog_file,
|
|
275
|
+
L: 82,
|
|
276
|
+
S: void 0,
|
|
277
|
+
A: [
|
|
278
|
+
"entry.value instanceof Uint8Array",
|
|
279
|
+
"'Invalid value type'"
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
await file.write(0, arrayToBuffer(entry.value));
|
|
283
|
+
await file.close();
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
case ProfileArchiveEntryType.KEY_VALUE: {
|
|
287
|
+
invariant(entry.key instanceof Uint8Array, "Invalid key type", {
|
|
288
|
+
F: __dxlog_file,
|
|
289
|
+
L: 88,
|
|
290
|
+
S: void 0,
|
|
291
|
+
A: [
|
|
292
|
+
"entry.key instanceof Uint8Array",
|
|
293
|
+
"'Invalid key type'"
|
|
294
|
+
]
|
|
295
|
+
});
|
|
296
|
+
invariant(entry.value instanceof Uint8Array, "Invalid value type", {
|
|
297
|
+
F: __dxlog_file,
|
|
298
|
+
L: 89,
|
|
299
|
+
S: void 0,
|
|
300
|
+
A: [
|
|
301
|
+
"entry.value instanceof Uint8Array",
|
|
302
|
+
"'Invalid value type'"
|
|
303
|
+
]
|
|
304
|
+
});
|
|
305
|
+
batch.put(entry.key, entry.value, {
|
|
306
|
+
keyEncoding: "binary",
|
|
307
|
+
valueEncoding: "binary"
|
|
308
|
+
});
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
default:
|
|
312
|
+
throw new Error(`Invalid entry type: ${entry.type}`);
|
|
313
|
+
}
|
|
314
|
+
if (++count % 1e3 === 0) {
|
|
315
|
+
await batch.write();
|
|
316
|
+
batch = level.batch();
|
|
317
|
+
log.info("importing", {
|
|
318
|
+
count,
|
|
319
|
+
total: archive.storage.length,
|
|
320
|
+
progress: `${(count / archive.storage.length * 100).toFixed()}%`
|
|
321
|
+
}, {
|
|
322
|
+
F: __dxlog_file,
|
|
323
|
+
L: 102,
|
|
324
|
+
S: void 0,
|
|
325
|
+
C: (f, a) => f(...a)
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
log.info("committing changes..", void 0, {
|
|
330
|
+
F: __dxlog_file,
|
|
331
|
+
L: 110,
|
|
332
|
+
S: void 0,
|
|
333
|
+
C: (f, a) => f(...a)
|
|
334
|
+
});
|
|
335
|
+
await batch.write();
|
|
336
|
+
};
|
|
47
337
|
|
|
48
338
|
// src/packlets/worker/worker-runtime.ts
|
|
339
|
+
import * as Reactivity from "@effect/experimental/Reactivity";
|
|
340
|
+
import * as Effect from "effect/Effect";
|
|
341
|
+
import * as Layer from "effect/Layer";
|
|
342
|
+
import * as ManagedRuntime from "effect/ManagedRuntime";
|
|
49
343
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
50
344
|
import { DEFAULT_WORKER_BROADCAST_CHANNEL } from "@dxos/client-protocol";
|
|
51
345
|
import { Context } from "@dxos/context";
|
|
52
|
-
import { invariant as
|
|
53
|
-
import { log as
|
|
346
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
347
|
+
import { log as log3 } from "@dxos/log";
|
|
54
348
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager, setIdentityTags } from "@dxos/messaging";
|
|
55
349
|
import { RtcTransportProxyFactory } from "@dxos/network-manager";
|
|
350
|
+
import * as OpfsWorker from "@dxos/sql-sqlite/OpfsWorker";
|
|
351
|
+
import * as SqlExport from "@dxos/sql-sqlite/SqlExport";
|
|
352
|
+
import * as SqliteClient from "@dxos/sql-sqlite/SqliteClient";
|
|
353
|
+
import * as SqlTransaction from "@dxos/sql-sqlite/SqlTransaction";
|
|
56
354
|
|
|
57
355
|
// src/packlets/worker/worker-session.ts
|
|
58
356
|
import { Trigger, asyncTimeout } from "@dxos/async";
|
|
59
357
|
import { PROXY_CONNECTION_TIMEOUT, iframeServiceBundle, workerServiceBundle } from "@dxos/client-protocol";
|
|
60
|
-
import { invariant } from "@dxos/invariant";
|
|
61
|
-
import { log, logInfo } from "@dxos/log";
|
|
358
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
359
|
+
import { log as log2, logInfo } from "@dxos/log";
|
|
62
360
|
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
63
361
|
import { Callback } from "@dxos/util";
|
|
64
|
-
function
|
|
362
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
65
363
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
66
364
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
67
365
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
68
366
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
69
367
|
}
|
|
70
|
-
var
|
|
368
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
|
|
71
369
|
var WorkerSession = class {
|
|
72
370
|
_clientRpc;
|
|
73
371
|
_shellClientRpc;
|
|
@@ -82,8 +380,8 @@ var WorkerSession = class {
|
|
|
82
380
|
lockKey;
|
|
83
381
|
bridgeService;
|
|
84
382
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
85
|
-
|
|
86
|
-
F:
|
|
383
|
+
invariant2(serviceHost, void 0, {
|
|
384
|
+
F: __dxlog_file2,
|
|
87
385
|
L: 54,
|
|
88
386
|
S: this,
|
|
89
387
|
A: [
|
|
@@ -139,8 +437,8 @@ var WorkerSession = class {
|
|
|
139
437
|
try {
|
|
140
438
|
await this.close();
|
|
141
439
|
} catch (err) {
|
|
142
|
-
|
|
143
|
-
F:
|
|
440
|
+
log2.catch(err, void 0, {
|
|
441
|
+
F: __dxlog_file2,
|
|
144
442
|
L: 108,
|
|
145
443
|
S: this,
|
|
146
444
|
C: (f, a) => f(...a)
|
|
@@ -156,8 +454,8 @@ var WorkerSession = class {
|
|
|
156
454
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
157
455
|
}
|
|
158
456
|
async open() {
|
|
159
|
-
|
|
160
|
-
F:
|
|
457
|
+
log2("opening...", void 0, {
|
|
458
|
+
F: __dxlog_file2,
|
|
161
459
|
L: 122,
|
|
162
460
|
S: this,
|
|
163
461
|
C: (f, a) => f(...a)
|
|
@@ -173,16 +471,16 @@ var WorkerSession = class {
|
|
|
173
471
|
if (this.lockKey) {
|
|
174
472
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
175
473
|
}
|
|
176
|
-
|
|
177
|
-
F:
|
|
474
|
+
log2("opened", void 0, {
|
|
475
|
+
F: __dxlog_file2,
|
|
178
476
|
L: 133,
|
|
179
477
|
S: this,
|
|
180
478
|
C: (f, a) => f(...a)
|
|
181
479
|
});
|
|
182
480
|
}
|
|
183
481
|
async close() {
|
|
184
|
-
|
|
185
|
-
F:
|
|
482
|
+
log2.debug("closing...", void 0, {
|
|
483
|
+
F: __dxlog_file2,
|
|
186
484
|
L: 137,
|
|
187
485
|
S: this,
|
|
188
486
|
C: (f, a) => f(...a)
|
|
@@ -190,8 +488,8 @@ var WorkerSession = class {
|
|
|
190
488
|
try {
|
|
191
489
|
await this.onClose.callIfSet();
|
|
192
490
|
} catch (err) {
|
|
193
|
-
|
|
194
|
-
F:
|
|
491
|
+
log2.catch(err, void 0, {
|
|
492
|
+
F: __dxlog_file2,
|
|
195
493
|
L: 141,
|
|
196
494
|
S: this,
|
|
197
495
|
C: (f, a) => f(...a)
|
|
@@ -201,8 +499,8 @@ var WorkerSession = class {
|
|
|
201
499
|
this._clientRpc.close(),
|
|
202
500
|
this._iframeRpc.close()
|
|
203
501
|
]);
|
|
204
|
-
|
|
205
|
-
F:
|
|
502
|
+
log2.debug("closed", void 0, {
|
|
503
|
+
F: __dxlog_file2,
|
|
206
504
|
L: 145,
|
|
207
505
|
S: this,
|
|
208
506
|
C: (f, a) => f(...a)
|
|
@@ -212,8 +510,8 @@ var WorkerSession = class {
|
|
|
212
510
|
try {
|
|
213
511
|
this._shellClientRpc && await asyncTimeout(this._shellClientRpc.open(), 1e3);
|
|
214
512
|
} catch {
|
|
215
|
-
|
|
216
|
-
F:
|
|
513
|
+
log2.info("No shell connected.", void 0, {
|
|
514
|
+
F: __dxlog_file2,
|
|
217
515
|
L: 152,
|
|
218
516
|
S: this,
|
|
219
517
|
C: (f, a) => f(...a)
|
|
@@ -225,15 +523,15 @@ var WorkerSession = class {
|
|
|
225
523
|
}).then(callback);
|
|
226
524
|
}
|
|
227
525
|
};
|
|
228
|
-
|
|
526
|
+
_ts_decorate2([
|
|
229
527
|
logInfo
|
|
230
528
|
], WorkerSession.prototype, "origin", void 0);
|
|
231
|
-
|
|
529
|
+
_ts_decorate2([
|
|
232
530
|
logInfo
|
|
233
531
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
234
532
|
|
|
235
533
|
// src/packlets/worker/worker-runtime.ts
|
|
236
|
-
var
|
|
534
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
|
|
237
535
|
var WorkerRuntime = class {
|
|
238
536
|
_configProvider;
|
|
239
537
|
_acquireLock;
|
|
@@ -244,6 +542,8 @@ var WorkerRuntime = class {
|
|
|
244
542
|
_sessions = /* @__PURE__ */ new Set();
|
|
245
543
|
_clientServices;
|
|
246
544
|
_channel;
|
|
545
|
+
_automaticallyConnectWebrtc;
|
|
546
|
+
_livenessLock = new WebLockWrapper(`@dxos/client-services/WorkerRuntime/${crypto.randomUUID()}`);
|
|
247
547
|
_broadcastChannel;
|
|
248
548
|
_sessionForNetworking;
|
|
249
549
|
_config;
|
|
@@ -251,29 +551,49 @@ var WorkerRuntime = class {
|
|
|
251
551
|
runtime: "worker-runtime"
|
|
252
552
|
};
|
|
253
553
|
_signalTelemetryEnabled = false;
|
|
254
|
-
|
|
554
|
+
_runtime;
|
|
555
|
+
constructor({ channel = DEFAULT_WORKER_BROADCAST_CHANNEL, configProvider, acquireLock, releaseLock, onStop, automaticallyConnectWebrtc = true, sqliteLayer }) {
|
|
255
556
|
this._configProvider = configProvider;
|
|
256
557
|
this._acquireLock = acquireLock;
|
|
257
558
|
this._releaseLock = releaseLock;
|
|
258
559
|
this._onStop = onStop;
|
|
259
560
|
this._channel = channel;
|
|
561
|
+
if (sqliteLayer) {
|
|
562
|
+
log3.warn("Using testing SQLite layer", void 0, {
|
|
563
|
+
F: __dxlog_file3,
|
|
564
|
+
L: 102,
|
|
565
|
+
S: this,
|
|
566
|
+
C: (f, a) => f(...a)
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
this._runtime = ManagedRuntime.make(SqlTransaction.layer.pipe(Layer.provideMerge(sqliteLayer ?? LocalSqliteOpfsLayer), Layer.provideMerge(Reactivity.layer)).pipe(Layer.orDie));
|
|
260
570
|
this._clientServices = new ClientServicesHost({
|
|
261
571
|
callbacks: {
|
|
262
572
|
onReset: async () => this.stop()
|
|
573
|
+
},
|
|
574
|
+
runtime: this._runtime.runtimeEffect,
|
|
575
|
+
runtimeProps: {
|
|
576
|
+
// Auto-activate spaces that were previously active after leader changeover.
|
|
577
|
+
autoActivateSpaces: true
|
|
263
578
|
}
|
|
264
579
|
});
|
|
580
|
+
this._automaticallyConnectWebrtc = automaticallyConnectWebrtc;
|
|
265
581
|
}
|
|
266
582
|
get host() {
|
|
267
583
|
return this._clientServices;
|
|
268
584
|
}
|
|
585
|
+
get livenessLockKey() {
|
|
586
|
+
return this._livenessLock.key;
|
|
587
|
+
}
|
|
269
588
|
async start() {
|
|
270
|
-
|
|
271
|
-
F:
|
|
272
|
-
L:
|
|
589
|
+
log3("starting...", void 0, {
|
|
590
|
+
F: __dxlog_file3,
|
|
591
|
+
L: 131,
|
|
273
592
|
S: this,
|
|
274
593
|
C: (f, a) => f(...a)
|
|
275
594
|
});
|
|
276
595
|
try {
|
|
596
|
+
void this._livenessLock.acquire();
|
|
277
597
|
this._broadcastChannel = new BroadcastChannel(this._channel);
|
|
278
598
|
this._broadcastChannel.postMessage({
|
|
279
599
|
action: "stop"
|
|
@@ -292,13 +612,13 @@ var WorkerRuntime = class {
|
|
|
292
612
|
transportFactory: this._transportFactory
|
|
293
613
|
});
|
|
294
614
|
await this._clientServices.open(new Context(void 0, {
|
|
295
|
-
F:
|
|
296
|
-
L:
|
|
615
|
+
F: __dxlog_file3,
|
|
616
|
+
L: 157
|
|
297
617
|
}));
|
|
298
618
|
this._ready.wake(void 0);
|
|
299
|
-
|
|
300
|
-
F:
|
|
301
|
-
L:
|
|
619
|
+
log3("started", void 0, {
|
|
620
|
+
F: __dxlog_file3,
|
|
621
|
+
L: 159,
|
|
302
622
|
S: this,
|
|
303
623
|
C: (f, a) => f(...a)
|
|
304
624
|
});
|
|
@@ -311,9 +631,9 @@ var WorkerRuntime = class {
|
|
|
311
631
|
});
|
|
312
632
|
} catch (err) {
|
|
313
633
|
this._ready.wake(err);
|
|
314
|
-
|
|
315
|
-
F:
|
|
316
|
-
L:
|
|
634
|
+
log3.error("starting", err, {
|
|
635
|
+
F: __dxlog_file3,
|
|
636
|
+
L: 169,
|
|
317
637
|
S: this,
|
|
318
638
|
C: (f, a) => f(...a)
|
|
319
639
|
});
|
|
@@ -323,13 +643,18 @@ var WorkerRuntime = class {
|
|
|
323
643
|
this._releaseLock();
|
|
324
644
|
this._broadcastChannel?.close();
|
|
325
645
|
this._broadcastChannel = void 0;
|
|
326
|
-
await this._clientServices.close(
|
|
646
|
+
await this._clientServices.close(Context.default(void 0, {
|
|
647
|
+
F: __dxlog_file3,
|
|
648
|
+
L: 178
|
|
649
|
+
}));
|
|
650
|
+
await this._runtime.dispose();
|
|
327
651
|
await this._onStop?.();
|
|
652
|
+
await this._livenessLock.release();
|
|
328
653
|
}
|
|
329
654
|
/**
|
|
330
655
|
* Create a new session.
|
|
331
656
|
*/
|
|
332
|
-
async createSession({ appPort, systemPort, shellPort }) {
|
|
657
|
+
async createSession({ appPort, systemPort, shellPort, onClose }) {
|
|
333
658
|
const session = new WorkerSession({
|
|
334
659
|
serviceHost: this._clientServices,
|
|
335
660
|
appPort,
|
|
@@ -342,13 +667,16 @@ var WorkerRuntime = class {
|
|
|
342
667
|
if (this._sessions.size === 0) {
|
|
343
668
|
await this.stop();
|
|
344
669
|
} else {
|
|
345
|
-
this.
|
|
670
|
+
if (this._automaticallyConnectWebrtc) {
|
|
671
|
+
this._reconnectWebrtc();
|
|
672
|
+
}
|
|
346
673
|
}
|
|
674
|
+
await onClose?.();
|
|
347
675
|
});
|
|
348
676
|
await session.open();
|
|
349
|
-
|
|
350
|
-
F:
|
|
351
|
-
L:
|
|
677
|
+
invariant3(!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin, `worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`, {
|
|
678
|
+
F: __dxlog_file3,
|
|
679
|
+
L: 212,
|
|
352
680
|
S: this,
|
|
353
681
|
A: [
|
|
354
682
|
"!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin",
|
|
@@ -361,15 +689,30 @@ var WorkerRuntime = class {
|
|
|
361
689
|
this._signalTelemetryEnabled = session.signalTelemetryEnabled ?? false;
|
|
362
690
|
this._signalMetadataTags.origin = session.origin;
|
|
363
691
|
this._sessions.add(session);
|
|
364
|
-
this.
|
|
692
|
+
if (this._automaticallyConnectWebrtc) {
|
|
693
|
+
this._reconnectWebrtc();
|
|
694
|
+
}
|
|
695
|
+
return session;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Connects the WebRTC bridge to the specified session.
|
|
699
|
+
* If no session is provided, disconnects the WebRTC bridge.
|
|
700
|
+
*
|
|
701
|
+
* Called automatically if `automaticallyConnectWebrtc` is true.
|
|
702
|
+
*
|
|
703
|
+
* @param session The session to connect the WebRTC bridge to.
|
|
704
|
+
*/
|
|
705
|
+
connectWebrtcBridge(session) {
|
|
706
|
+
this._sessionForNetworking = session;
|
|
707
|
+
this._transportFactory.setBridgeService(session?.bridgeService);
|
|
365
708
|
}
|
|
366
709
|
/**
|
|
367
710
|
* Selects one of the existing session for WebRTC networking.
|
|
368
711
|
*/
|
|
369
712
|
_reconnectWebrtc() {
|
|
370
|
-
|
|
371
|
-
F:
|
|
372
|
-
L:
|
|
713
|
+
log3("reconnecting webrtc...", void 0, {
|
|
714
|
+
F: __dxlog_file3,
|
|
715
|
+
L: 247,
|
|
373
716
|
S: this,
|
|
374
717
|
C: (f, a) => f(...a)
|
|
375
718
|
});
|
|
@@ -380,15 +723,58 @@ var WorkerRuntime = class {
|
|
|
380
723
|
}
|
|
381
724
|
if (!this._sessionForNetworking) {
|
|
382
725
|
const selected = Array.from(this._sessions).find((session) => session.bridgeService);
|
|
383
|
-
|
|
384
|
-
this._sessionForNetworking = selected;
|
|
385
|
-
this._transportFactory.setBridgeService(selected.bridgeService);
|
|
386
|
-
} else {
|
|
387
|
-
this._transportFactory.setBridgeService(void 0);
|
|
388
|
-
}
|
|
726
|
+
this.connectWebrtcBridge(selected);
|
|
389
727
|
}
|
|
390
728
|
}
|
|
391
729
|
};
|
|
730
|
+
var DB_NAME = "DXOS";
|
|
731
|
+
var SqlExportLayer = Layer.effect(SqlExport.SqlExport, Effect.gen(function* () {
|
|
732
|
+
const sql = yield* SqliteClient.SqliteClient;
|
|
733
|
+
return {
|
|
734
|
+
export: sql.export
|
|
735
|
+
};
|
|
736
|
+
}));
|
|
737
|
+
var LocalSqliteOpfsLayer = Layer.unwrapScoped(Effect.gen(function* () {
|
|
738
|
+
const { port1: clientPort, port2: serverPort } = new MessageChannel();
|
|
739
|
+
clientPort.start();
|
|
740
|
+
serverPort.start();
|
|
741
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
742
|
+
clientPort.close();
|
|
743
|
+
serverPort.close();
|
|
744
|
+
}));
|
|
745
|
+
yield* Effect.forkScoped(OpfsWorker.run({
|
|
746
|
+
port: serverPort,
|
|
747
|
+
dbName: DB_NAME
|
|
748
|
+
}));
|
|
749
|
+
return SqlExportLayer.pipe(Layer.provideMerge(SqliteClient.layer({
|
|
750
|
+
worker: Effect.succeed(clientPort)
|
|
751
|
+
})));
|
|
752
|
+
}));
|
|
753
|
+
var WebLockWrapper = class {
|
|
754
|
+
#key;
|
|
755
|
+
#release;
|
|
756
|
+
constructor(key) {
|
|
757
|
+
this.#key = key;
|
|
758
|
+
}
|
|
759
|
+
get key() {
|
|
760
|
+
return this.#key;
|
|
761
|
+
}
|
|
762
|
+
acquire(options = {}) {
|
|
763
|
+
return navigator.locks.request(this.#key, options, async () => {
|
|
764
|
+
await new Promise((resolve) => {
|
|
765
|
+
this.#release = resolve;
|
|
766
|
+
});
|
|
767
|
+
this.#release = void 0;
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
release() {
|
|
771
|
+
this.#release?.();
|
|
772
|
+
this.#release = void 0;
|
|
773
|
+
}
|
|
774
|
+
[Symbol.dispose]() {
|
|
775
|
+
this.release();
|
|
776
|
+
}
|
|
777
|
+
};
|
|
392
778
|
export {
|
|
393
779
|
ClientRpcServer,
|
|
394
780
|
ClientServicesHost,
|
|
@@ -407,9 +793,9 @@ export {
|
|
|
407
793
|
InvitationsHandler,
|
|
408
794
|
InvitationsManager,
|
|
409
795
|
InvitationsServiceImpl,
|
|
410
|
-
Lock,
|
|
411
796
|
ServiceContext,
|
|
412
797
|
ServiceRegistry,
|
|
798
|
+
SpaceArchiveWriter,
|
|
413
799
|
SpaceInvitationProtocol,
|
|
414
800
|
SpacesServiceImpl,
|
|
415
801
|
TrustedKeySetAuthVerifier,
|
|
@@ -417,17 +803,15 @@ export {
|
|
|
417
803
|
WorkerSession,
|
|
418
804
|
createAdmissionKeypair,
|
|
419
805
|
createAuthProvider,
|
|
420
|
-
createCollectDiagnosticsBroadcastHandler,
|
|
421
|
-
createCollectDiagnosticsBroadcastSender,
|
|
422
806
|
createDiagnostics,
|
|
423
807
|
createLevel,
|
|
424
808
|
createStorageObjects,
|
|
425
809
|
decodeProfileArchive,
|
|
426
810
|
encodeProfileArchive,
|
|
427
811
|
exportProfileData,
|
|
812
|
+
extractSpaceArchive,
|
|
428
813
|
getNetworkPeers,
|
|
429
814
|
importProfileData,
|
|
430
|
-
isLocked,
|
|
431
815
|
subscribeToFeedBlocks,
|
|
432
816
|
subscribeToFeeds,
|
|
433
817
|
subscribeToNetworkStatus,
|