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