@dxos/client-services 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5
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-WBMHLEAB.mjs → chunk-HYGNOM23.mjs} +2843 -2114
- package/dist/lib/browser/chunk-HYGNOM23.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 +512 -90
- 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 +37 -19
- 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-IPVFX6KI.mjs → chunk-GFT7MAQE.mjs} +2571 -1711
- package/dist/lib/node-esm/chunk-GFT7MAQE.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 +512 -90
- 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 +37 -19
- 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 +2 -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/diagnostics.d.ts +1 -2
- 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.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 +6 -10
- 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 +6 -5
- 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/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 +7 -4
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-state.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/invitations-service.d.ts +3 -3
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +4 -3
- 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 +5 -4
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +5 -5
- 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 -7
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/archive-format.d.ts +9 -0
- package/dist/types/src/packlets/space-export/archive-format.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/index.d.ts +4 -1
- package/dist/types/src/packlets/space-export/index.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts +23 -0
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts +36 -0
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts.map +1 -0
- 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 +7 -1
- 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 +28 -16
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +26 -9
- 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 +17 -7
- 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 +41 -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 -4
- 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 +10 -7
- package/src/packlets/agents/edge-agent-service.ts +15 -3
- package/src/packlets/devices/devices-service.test.ts +0 -1
- package/src/packlets/devices/devices-service.ts +1 -1
- package/src/packlets/devtools/devtools.ts +2 -3
- package/src/packlets/diagnostics/diagnostics.ts +1 -2
- 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 +13 -81
- package/src/packlets/identity/identity.test.ts +6 -6
- package/src/packlets/identity/identity.ts +11 -34
- package/src/packlets/invitations/device-invitation-protocol.ts +8 -7
- package/src/packlets/invitations/edge-invitation-handler.ts +9 -5
- 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 +7 -4
- package/src/packlets/invitations/invitation-state.ts +0 -10
- package/src/packlets/invitations/invitations-handler.test.ts +4 -5
- package/src/packlets/invitations/invitations-handler.ts +69 -13
- package/src/packlets/invitations/invitations-manager.ts +40 -15
- package/src/packlets/invitations/invitations-service.ts +9 -9
- package/src/packlets/invitations/space-invitation-protocol.test.ts +17 -16
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -16
- package/src/packlets/locks/index.ts +1 -1
- package/src/packlets/logging/logging-service.ts +5 -1
- package/src/packlets/network/network-service.test.ts +0 -1
- package/src/packlets/network/network-service.ts +10 -8
- package/src/packlets/services/client-rpc-server.ts +19 -16
- 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 +141 -55
- package/src/packlets/services/service-host.test.ts +8 -8
- package/src/packlets/services/service-host.ts +77 -32
- package/src/packlets/services/service-registry.test.ts +0 -1
- package/src/packlets/space-export/archive-format.ts +42 -0
- package/src/packlets/space-export/index.ts +4 -1
- package/src/packlets/space-export/serialized-space-reader.ts +111 -0
- package/src/packlets/space-export/serialized-space-writer.ts +246 -0
- package/src/packlets/space-export/space-archive-reader.ts +65 -4
- package/src/packlets/space-export/space-archive-writer.ts +43 -5
- package/src/packlets/space-export/space-archive.test.ts +461 -0
- package/src/packlets/spaces/data-space-manager.test.ts +79 -13
- package/src/packlets/spaces/data-space-manager.ts +122 -110
- package/src/packlets/spaces/data-space.ts +58 -33
- package/src/packlets/spaces/edge-feed-replicator.test.ts +2 -2
- package/src/packlets/spaces/edge-feed-replicator.ts +12 -10
- 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 +18 -11
- package/src/packlets/spaces/spaces-service.ts +124 -25
- 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 +179 -17
- package/src/packlets/worker/worker-session.ts +12 -18
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-WBMHLEAB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IPVFX6KI.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,57 +16,370 @@ 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,
|
|
25
|
+
buildDatabaseDirectoryFromObjects,
|
|
26
26
|
createAdmissionKeypair,
|
|
27
27
|
createAuthProvider,
|
|
28
|
-
createCollectDiagnosticsBroadcastHandler,
|
|
29
|
-
createCollectDiagnosticsBroadcastSender,
|
|
30
28
|
createDiagnostics,
|
|
31
29
|
createLevel,
|
|
32
30
|
createStorageObjects,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
detectSpaceArchiveFormat,
|
|
32
|
+
diagnostics_exports,
|
|
33
|
+
extractSpaceArchive,
|
|
36
34
|
getNetworkPeers,
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
locks_exports,
|
|
36
|
+
objJsonToObjectStructure,
|
|
37
|
+
objectStructureToObjJson,
|
|
38
|
+
orderObjJsonFields,
|
|
39
|
+
readSerializedSpaceArchive,
|
|
39
40
|
subscribeToFeedBlocks,
|
|
40
41
|
subscribeToFeeds,
|
|
41
42
|
subscribeToNetworkStatus,
|
|
42
43
|
subscribeToNetworkTopics,
|
|
43
44
|
subscribeToSignal,
|
|
44
45
|
subscribeToSpaces,
|
|
45
|
-
subscribeToSwarmInfo
|
|
46
|
-
|
|
46
|
+
subscribeToSwarmInfo,
|
|
47
|
+
writeSerializedSpaceArchive
|
|
48
|
+
} from "./chunk-HYGNOM23.mjs";
|
|
49
|
+
import "./chunk-NQSC7HOE.mjs";
|
|
50
|
+
import {
|
|
51
|
+
__export,
|
|
52
|
+
__reExport
|
|
53
|
+
} from "./chunk-QCWEHHJW.mjs";
|
|
54
|
+
|
|
55
|
+
// src/index.ts
|
|
56
|
+
var index_exports = {};
|
|
57
|
+
__export(index_exports, {
|
|
58
|
+
ClientRpcServer: () => ClientRpcServer,
|
|
59
|
+
ClientServicesHost: () => ClientServicesHost,
|
|
60
|
+
DataSpace: () => DataSpace,
|
|
61
|
+
DataSpaceManager: () => DataSpaceManager,
|
|
62
|
+
DeviceInvitationProtocol: () => DeviceInvitationProtocol,
|
|
63
|
+
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
64
|
+
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
65
|
+
DiagnosticsCollector: () => DiagnosticsCollector,
|
|
66
|
+
EdgeAgentManager: () => EdgeAgentManager,
|
|
67
|
+
EdgeAgentServiceImpl: () => EdgeAgentServiceImpl,
|
|
68
|
+
EdgeFeedReplicator: () => EdgeFeedReplicator,
|
|
69
|
+
Identity: () => Identity,
|
|
70
|
+
IdentityManager: () => IdentityManager,
|
|
71
|
+
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
72
|
+
InvitationsHandler: () => InvitationsHandler,
|
|
73
|
+
InvitationsManager: () => InvitationsManager,
|
|
74
|
+
InvitationsServiceImpl: () => InvitationsServiceImpl,
|
|
75
|
+
ServiceContext: () => ServiceContext,
|
|
76
|
+
ServiceRegistry: () => ServiceRegistry,
|
|
77
|
+
SpaceArchiveWriter: () => SpaceArchiveWriter,
|
|
78
|
+
SpaceInvitationProtocol: () => SpaceInvitationProtocol,
|
|
79
|
+
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
80
|
+
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
81
|
+
WorkerRuntime: () => WorkerRuntime,
|
|
82
|
+
WorkerSession: () => WorkerSession,
|
|
83
|
+
buildDatabaseDirectoryFromObjects: () => buildDatabaseDirectoryFromObjects,
|
|
84
|
+
createAdmissionKeypair: () => createAdmissionKeypair,
|
|
85
|
+
createAuthProvider: () => createAuthProvider,
|
|
86
|
+
createDiagnostics: () => createDiagnostics,
|
|
87
|
+
createLevel: () => createLevel,
|
|
88
|
+
createStorageObjects: () => createStorageObjects,
|
|
89
|
+
decodeProfileArchive: () => decodeProfileArchive,
|
|
90
|
+
detectSpaceArchiveFormat: () => detectSpaceArchiveFormat,
|
|
91
|
+
encodeProfileArchive: () => encodeProfileArchive,
|
|
92
|
+
exportProfileData: () => exportProfileData,
|
|
93
|
+
extractSpaceArchive: () => extractSpaceArchive,
|
|
94
|
+
getNetworkPeers: () => getNetworkPeers,
|
|
95
|
+
importProfileData: () => importProfileData,
|
|
96
|
+
objJsonToObjectStructure: () => objJsonToObjectStructure,
|
|
97
|
+
objectStructureToObjJson: () => objectStructureToObjJson,
|
|
98
|
+
orderObjJsonFields: () => orderObjJsonFields,
|
|
99
|
+
readSerializedSpaceArchive: () => readSerializedSpaceArchive,
|
|
100
|
+
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
101
|
+
subscribeToFeeds: () => subscribeToFeeds,
|
|
102
|
+
subscribeToNetworkStatus: () => subscribeToNetworkStatus,
|
|
103
|
+
subscribeToNetworkTopics: () => subscribeToNetworkTopics,
|
|
104
|
+
subscribeToSignal: () => subscribeToSignal,
|
|
105
|
+
subscribeToSpaces: () => subscribeToSpaces,
|
|
106
|
+
subscribeToSwarmInfo: () => subscribeToSwarmInfo,
|
|
107
|
+
writeSerializedSpaceArchive: () => writeSerializedSpaceArchive
|
|
108
|
+
});
|
|
109
|
+
__reExport(index_exports, diagnostics_exports);
|
|
110
|
+
__reExport(index_exports, locks_exports);
|
|
111
|
+
|
|
112
|
+
// src/packlets/services/client-rpc-server.ts
|
|
113
|
+
import { Stream } from "@dxos/codec-protobuf";
|
|
114
|
+
import { raise } from "@dxos/debug";
|
|
115
|
+
import { RpcPeer, parseMethodName } from "@dxos/rpc";
|
|
116
|
+
import { MapCounter, trace } from "@dxos/tracing";
|
|
117
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
118
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
119
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
120
|
+
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;
|
|
121
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
122
|
+
}
|
|
123
|
+
var ClientRpcServer = class {
|
|
124
|
+
_serviceRegistry;
|
|
125
|
+
_rpcPeer;
|
|
126
|
+
_handlerCache = /* @__PURE__ */ new Map();
|
|
127
|
+
_handleCall;
|
|
128
|
+
_handleStream;
|
|
129
|
+
_callMetrics = new MapCounter();
|
|
130
|
+
get _services() {
|
|
131
|
+
return Object.keys(this._serviceRegistry.services);
|
|
132
|
+
}
|
|
133
|
+
constructor(params) {
|
|
134
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
135
|
+
this._handleCall = handleCall;
|
|
136
|
+
this._handleStream = handleStream;
|
|
137
|
+
this._serviceRegistry = serviceRegistry;
|
|
138
|
+
this._rpcPeer = new RpcPeer({
|
|
139
|
+
...rpcOptions,
|
|
140
|
+
callHandler: (method, params2, options) => {
|
|
141
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
142
|
+
const handler = (method2, params3, handlerOptions) => this._getServiceHandler(serviceName).call(method2, params3, handlerOptions);
|
|
143
|
+
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
144
|
+
if (this._handleCall) {
|
|
145
|
+
return this._handleCall(methodName, params2, handler, options);
|
|
146
|
+
} else {
|
|
147
|
+
return handler(methodName, params2, options);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
streamHandler: (method, params2, options) => {
|
|
151
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
152
|
+
const handler = (method2, params3, handlerOptions) => this._getServiceHandler(serviceName).callStream(method2, params3, handlerOptions);
|
|
153
|
+
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
154
|
+
if (this._handleStream) {
|
|
155
|
+
return Stream.map(Stream.unwrapPromise(this._handleStream(methodName, params2, handler, options)), (data) => {
|
|
156
|
+
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
157
|
+
return data;
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
return handler(methodName, params2, options);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async open() {
|
|
166
|
+
await this._rpcPeer.open();
|
|
167
|
+
}
|
|
168
|
+
async close() {
|
|
169
|
+
await this._rpcPeer.close();
|
|
170
|
+
}
|
|
171
|
+
_getServiceHandler(serviceName) {
|
|
172
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
173
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
|
|
174
|
+
const service = this._serviceRegistry.services[key];
|
|
175
|
+
if (!service) {
|
|
176
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
177
|
+
}
|
|
178
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
179
|
+
}
|
|
180
|
+
return this._handlerCache.get(serviceName);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
_ts_decorate([
|
|
184
|
+
trace.metricsCounter()
|
|
185
|
+
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
186
|
+
_ts_decorate([
|
|
187
|
+
trace.info()
|
|
188
|
+
], ClientRpcServer.prototype, "_services", null);
|
|
189
|
+
ClientRpcServer = _ts_decorate([
|
|
190
|
+
trace.resource()
|
|
191
|
+
], ClientRpcServer);
|
|
192
|
+
|
|
193
|
+
// src/packlets/storage/profile-archive.ts
|
|
194
|
+
import { cbor } from "@automerge/automerge-repo";
|
|
195
|
+
import { invariant } from "@dxos/invariant";
|
|
196
|
+
import { log } from "@dxos/log";
|
|
197
|
+
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
198
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
199
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
200
|
+
var encodeProfileArchive = (profile) => cbor.encode(profile);
|
|
201
|
+
var decodeProfileArchive = (data) => cbor.decode(data);
|
|
202
|
+
var exportProfileData = async ({ storage, level }) => {
|
|
203
|
+
const archive = {
|
|
204
|
+
storage: [],
|
|
205
|
+
meta: {
|
|
206
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
{
|
|
210
|
+
const directory = await storage.createDirectory();
|
|
211
|
+
const files = await directory.list();
|
|
212
|
+
log.info("begin exporting files", {
|
|
213
|
+
count: files.length
|
|
214
|
+
}, {
|
|
215
|
+
F: __dxlog_file,
|
|
216
|
+
L: 31,
|
|
217
|
+
S: void 0,
|
|
218
|
+
C: (f, a) => f(...a)
|
|
219
|
+
});
|
|
220
|
+
for (const filename of files) {
|
|
221
|
+
const file = await directory.getOrCreateFile(filename);
|
|
222
|
+
const { size } = await file.stat();
|
|
223
|
+
const data = await file.read(0, size);
|
|
224
|
+
archive.storage.push({
|
|
225
|
+
type: ProfileArchiveEntryType.FILE,
|
|
226
|
+
key: filename,
|
|
227
|
+
value: data
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
log.info("done exporting files", {
|
|
231
|
+
count: files.length
|
|
232
|
+
}, {
|
|
233
|
+
F: __dxlog_file,
|
|
234
|
+
L: 42,
|
|
235
|
+
S: void 0,
|
|
236
|
+
C: (f, a) => f(...a)
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
{
|
|
240
|
+
log.info("begin exporting kv pairs", void 0, {
|
|
241
|
+
F: __dxlog_file,
|
|
242
|
+
L: 46,
|
|
243
|
+
S: void 0,
|
|
244
|
+
C: (f, a) => f(...a)
|
|
245
|
+
});
|
|
246
|
+
const iter = await level.iterator({
|
|
247
|
+
keyEncoding: "binary",
|
|
248
|
+
valueEncoding: "binary"
|
|
249
|
+
});
|
|
250
|
+
let count = 0;
|
|
251
|
+
for await (const [key, value] of iter) {
|
|
252
|
+
archive.storage.push({
|
|
253
|
+
type: ProfileArchiveEntryType.KEY_VALUE,
|
|
254
|
+
key,
|
|
255
|
+
value
|
|
256
|
+
});
|
|
257
|
+
count++;
|
|
258
|
+
}
|
|
259
|
+
log.info("done exporting kv pairs", {
|
|
260
|
+
count
|
|
261
|
+
}, {
|
|
262
|
+
F: __dxlog_file,
|
|
263
|
+
L: 57,
|
|
264
|
+
S: void 0,
|
|
265
|
+
C: (f, a) => f(...a)
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return archive;
|
|
269
|
+
};
|
|
270
|
+
var importProfileData = async ({ storage, level }, archive) => {
|
|
271
|
+
let batch = level.batch();
|
|
272
|
+
let count = 0;
|
|
273
|
+
for (const entry of archive.storage) {
|
|
274
|
+
switch (entry.type) {
|
|
275
|
+
case ProfileArchiveEntryType.FILE: {
|
|
276
|
+
const directory = await storage.createDirectory();
|
|
277
|
+
invariant(typeof entry.key === "string", "Invalid key type", {
|
|
278
|
+
F: __dxlog_file,
|
|
279
|
+
L: 80,
|
|
280
|
+
S: void 0,
|
|
281
|
+
A: [
|
|
282
|
+
"typeof entry.key === 'string'",
|
|
283
|
+
"'Invalid key type'"
|
|
284
|
+
]
|
|
285
|
+
});
|
|
286
|
+
const file = await directory.getOrCreateFile(entry.key);
|
|
287
|
+
invariant(entry.value instanceof Uint8Array, "Invalid value type", {
|
|
288
|
+
F: __dxlog_file,
|
|
289
|
+
L: 82,
|
|
290
|
+
S: void 0,
|
|
291
|
+
A: [
|
|
292
|
+
"entry.value instanceof Uint8Array",
|
|
293
|
+
"'Invalid value type'"
|
|
294
|
+
]
|
|
295
|
+
});
|
|
296
|
+
await file.write(0, arrayToBuffer(entry.value));
|
|
297
|
+
await file.close();
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case ProfileArchiveEntryType.KEY_VALUE: {
|
|
301
|
+
invariant(entry.key instanceof Uint8Array, "Invalid key type", {
|
|
302
|
+
F: __dxlog_file,
|
|
303
|
+
L: 88,
|
|
304
|
+
S: void 0,
|
|
305
|
+
A: [
|
|
306
|
+
"entry.key instanceof Uint8Array",
|
|
307
|
+
"'Invalid key type'"
|
|
308
|
+
]
|
|
309
|
+
});
|
|
310
|
+
invariant(entry.value instanceof Uint8Array, "Invalid value type", {
|
|
311
|
+
F: __dxlog_file,
|
|
312
|
+
L: 89,
|
|
313
|
+
S: void 0,
|
|
314
|
+
A: [
|
|
315
|
+
"entry.value instanceof Uint8Array",
|
|
316
|
+
"'Invalid value type'"
|
|
317
|
+
]
|
|
318
|
+
});
|
|
319
|
+
batch.put(entry.key, entry.value, {
|
|
320
|
+
keyEncoding: "binary",
|
|
321
|
+
valueEncoding: "binary"
|
|
322
|
+
});
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
default:
|
|
326
|
+
throw new Error(`Invalid entry type: ${entry.type}`);
|
|
327
|
+
}
|
|
328
|
+
if (++count % 1e3 === 0) {
|
|
329
|
+
await batch.write();
|
|
330
|
+
batch = level.batch();
|
|
331
|
+
log.info("importing", {
|
|
332
|
+
count,
|
|
333
|
+
total: archive.storage.length,
|
|
334
|
+
progress: `${(count / archive.storage.length * 100).toFixed()}%`
|
|
335
|
+
}, {
|
|
336
|
+
F: __dxlog_file,
|
|
337
|
+
L: 102,
|
|
338
|
+
S: void 0,
|
|
339
|
+
C: (f, a) => f(...a)
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
log.info("committing changes..", void 0, {
|
|
344
|
+
F: __dxlog_file,
|
|
345
|
+
L: 110,
|
|
346
|
+
S: void 0,
|
|
347
|
+
C: (f, a) => f(...a)
|
|
348
|
+
});
|
|
349
|
+
await batch.write();
|
|
350
|
+
};
|
|
47
351
|
|
|
48
352
|
// src/packlets/worker/worker-runtime.ts
|
|
353
|
+
import * as Reactivity from "@effect/experimental/Reactivity";
|
|
354
|
+
import * as Effect from "effect/Effect";
|
|
355
|
+
import * as Layer from "effect/Layer";
|
|
356
|
+
import * as ManagedRuntime from "effect/ManagedRuntime";
|
|
49
357
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
50
358
|
import { DEFAULT_WORKER_BROADCAST_CHANNEL } from "@dxos/client-protocol";
|
|
51
359
|
import { Context } from "@dxos/context";
|
|
52
|
-
import { invariant as
|
|
53
|
-
import { log as
|
|
360
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
361
|
+
import { log as log3 } from "@dxos/log";
|
|
54
362
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager, setIdentityTags } from "@dxos/messaging";
|
|
55
363
|
import { RtcTransportProxyFactory } from "@dxos/network-manager";
|
|
364
|
+
import * as OpfsWorker from "@dxos/sql-sqlite/OpfsWorker";
|
|
365
|
+
import * as SqlExport from "@dxos/sql-sqlite/SqlExport";
|
|
366
|
+
import * as SqliteClient from "@dxos/sql-sqlite/SqliteClient";
|
|
367
|
+
import * as SqlTransaction from "@dxos/sql-sqlite/SqlTransaction";
|
|
56
368
|
|
|
57
369
|
// src/packlets/worker/worker-session.ts
|
|
58
370
|
import { Trigger, asyncTimeout } from "@dxos/async";
|
|
59
371
|
import { PROXY_CONNECTION_TIMEOUT, iframeServiceBundle, workerServiceBundle } from "@dxos/client-protocol";
|
|
60
|
-
import { invariant } from "@dxos/invariant";
|
|
61
|
-
import { log, logInfo } from "@dxos/log";
|
|
372
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
373
|
+
import { log as log2, logInfo } from "@dxos/log";
|
|
62
374
|
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
63
375
|
import { Callback } from "@dxos/util";
|
|
64
|
-
function
|
|
376
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
65
377
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
66
378
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
67
379
|
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
380
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
69
381
|
}
|
|
70
|
-
var
|
|
382
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
|
|
71
383
|
var WorkerSession = class {
|
|
72
384
|
_clientRpc;
|
|
73
385
|
_shellClientRpc;
|
|
@@ -76,15 +388,12 @@ var WorkerSession = class {
|
|
|
76
388
|
_serviceHost;
|
|
77
389
|
onClose = new Callback();
|
|
78
390
|
origin;
|
|
79
|
-
// TODO(nf): factor out?
|
|
80
|
-
observabilityGroup;
|
|
81
|
-
signalTelemetryEnabled;
|
|
82
391
|
lockKey;
|
|
83
392
|
bridgeService;
|
|
84
393
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
85
|
-
|
|
86
|
-
F:
|
|
87
|
-
L:
|
|
394
|
+
invariant2(serviceHost, void 0, {
|
|
395
|
+
F: __dxlog_file2,
|
|
396
|
+
L: 50,
|
|
88
397
|
S: this,
|
|
89
398
|
A: [
|
|
90
399
|
"serviceHost",
|
|
@@ -93,23 +402,23 @@ var WorkerSession = class {
|
|
|
93
402
|
});
|
|
94
403
|
this._serviceHost = serviceHost;
|
|
95
404
|
const middleware = {
|
|
96
|
-
handleCall: async (method, params, handler) => {
|
|
405
|
+
handleCall: async (method, params, handler, options) => {
|
|
97
406
|
const error = await readySignal.wait({
|
|
98
407
|
timeout: PROXY_CONNECTION_TIMEOUT
|
|
99
408
|
});
|
|
100
409
|
if (error) {
|
|
101
410
|
throw error;
|
|
102
411
|
}
|
|
103
|
-
return handler(method, params);
|
|
412
|
+
return handler(method, params, options);
|
|
104
413
|
},
|
|
105
|
-
handleStream: async (method, params, handler) => {
|
|
414
|
+
handleStream: async (method, params, handler, options) => {
|
|
106
415
|
const error = await readySignal.wait({
|
|
107
416
|
timeout: PROXY_CONNECTION_TIMEOUT
|
|
108
417
|
});
|
|
109
418
|
if (error) {
|
|
110
419
|
throw error;
|
|
111
420
|
}
|
|
112
|
-
return handler(method, params);
|
|
421
|
+
return handler(method, params, options);
|
|
113
422
|
}
|
|
114
423
|
};
|
|
115
424
|
this._clientRpc = new ClientRpcServer({
|
|
@@ -130,8 +439,6 @@ var WorkerSession = class {
|
|
|
130
439
|
start: async (request) => {
|
|
131
440
|
this.origin = request.origin;
|
|
132
441
|
this.lockKey = request.lockKey;
|
|
133
|
-
this.observabilityGroup = request.observabilityGroup;
|
|
134
|
-
this.signalTelemetryEnabled = request.signalTelemetryEnabled;
|
|
135
442
|
this._startTrigger.wake();
|
|
136
443
|
},
|
|
137
444
|
stop: async () => {
|
|
@@ -139,9 +446,9 @@ var WorkerSession = class {
|
|
|
139
446
|
try {
|
|
140
447
|
await this.close();
|
|
141
448
|
} catch (err) {
|
|
142
|
-
|
|
143
|
-
F:
|
|
144
|
-
L:
|
|
449
|
+
log2.catch(err, void 0, {
|
|
450
|
+
F: __dxlog_file2,
|
|
451
|
+
L: 102,
|
|
145
452
|
S: this,
|
|
146
453
|
C: (f, a) => f(...a)
|
|
147
454
|
});
|
|
@@ -156,9 +463,9 @@ var WorkerSession = class {
|
|
|
156
463
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
157
464
|
}
|
|
158
465
|
async open() {
|
|
159
|
-
|
|
160
|
-
F:
|
|
161
|
-
L:
|
|
466
|
+
log2("opening...", void 0, {
|
|
467
|
+
F: __dxlog_file2,
|
|
468
|
+
L: 116,
|
|
162
469
|
S: this,
|
|
163
470
|
C: (f, a) => f(...a)
|
|
164
471
|
});
|
|
@@ -173,26 +480,26 @@ var WorkerSession = class {
|
|
|
173
480
|
if (this.lockKey) {
|
|
174
481
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
175
482
|
}
|
|
176
|
-
|
|
177
|
-
F:
|
|
178
|
-
L:
|
|
483
|
+
log2("opened", void 0, {
|
|
484
|
+
F: __dxlog_file2,
|
|
485
|
+
L: 127,
|
|
179
486
|
S: this,
|
|
180
487
|
C: (f, a) => f(...a)
|
|
181
488
|
});
|
|
182
489
|
}
|
|
183
490
|
async close() {
|
|
184
|
-
|
|
185
|
-
F:
|
|
186
|
-
L:
|
|
491
|
+
log2.debug("closing...", void 0, {
|
|
492
|
+
F: __dxlog_file2,
|
|
493
|
+
L: 131,
|
|
187
494
|
S: this,
|
|
188
495
|
C: (f, a) => f(...a)
|
|
189
496
|
});
|
|
190
497
|
try {
|
|
191
498
|
await this.onClose.callIfSet();
|
|
192
499
|
} catch (err) {
|
|
193
|
-
|
|
194
|
-
F:
|
|
195
|
-
L:
|
|
500
|
+
log2.catch(err, void 0, {
|
|
501
|
+
F: __dxlog_file2,
|
|
502
|
+
L: 135,
|
|
196
503
|
S: this,
|
|
197
504
|
C: (f, a) => f(...a)
|
|
198
505
|
});
|
|
@@ -201,9 +508,9 @@ var WorkerSession = class {
|
|
|
201
508
|
this._clientRpc.close(),
|
|
202
509
|
this._iframeRpc.close()
|
|
203
510
|
]);
|
|
204
|
-
|
|
205
|
-
F:
|
|
206
|
-
L:
|
|
511
|
+
log2.debug("closed", void 0, {
|
|
512
|
+
F: __dxlog_file2,
|
|
513
|
+
L: 139,
|
|
207
514
|
S: this,
|
|
208
515
|
C: (f, a) => f(...a)
|
|
209
516
|
});
|
|
@@ -212,9 +519,9 @@ var WorkerSession = class {
|
|
|
212
519
|
try {
|
|
213
520
|
this._shellClientRpc && await asyncTimeout(this._shellClientRpc.open(), 1e3);
|
|
214
521
|
} catch {
|
|
215
|
-
|
|
216
|
-
F:
|
|
217
|
-
L:
|
|
522
|
+
log2.info("No shell connected.", void 0, {
|
|
523
|
+
F: __dxlog_file2,
|
|
524
|
+
L: 146,
|
|
218
525
|
S: this,
|
|
219
526
|
C: (f, a) => f(...a)
|
|
220
527
|
});
|
|
@@ -225,15 +532,15 @@ var WorkerSession = class {
|
|
|
225
532
|
}).then(callback);
|
|
226
533
|
}
|
|
227
534
|
};
|
|
228
|
-
|
|
535
|
+
_ts_decorate2([
|
|
229
536
|
logInfo
|
|
230
537
|
], WorkerSession.prototype, "origin", void 0);
|
|
231
|
-
|
|
538
|
+
_ts_decorate2([
|
|
232
539
|
logInfo
|
|
233
540
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
234
541
|
|
|
235
542
|
// src/packlets/worker/worker-runtime.ts
|
|
236
|
-
var
|
|
543
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
|
|
237
544
|
var WorkerRuntime = class {
|
|
238
545
|
_configProvider;
|
|
239
546
|
_acquireLock;
|
|
@@ -244,6 +551,8 @@ var WorkerRuntime = class {
|
|
|
244
551
|
_sessions = /* @__PURE__ */ new Set();
|
|
245
552
|
_clientServices;
|
|
246
553
|
_channel;
|
|
554
|
+
_automaticallyConnectWebrtc;
|
|
555
|
+
_livenessLock = new WebLockWrapper(`@dxos/client-services/WorkerRuntime/${crypto.randomUUID()}`);
|
|
247
556
|
_broadcastChannel;
|
|
248
557
|
_sessionForNetworking;
|
|
249
558
|
_config;
|
|
@@ -251,29 +560,49 @@ var WorkerRuntime = class {
|
|
|
251
560
|
runtime: "worker-runtime"
|
|
252
561
|
};
|
|
253
562
|
_signalTelemetryEnabled = false;
|
|
254
|
-
|
|
563
|
+
_runtime;
|
|
564
|
+
constructor({ channel = DEFAULT_WORKER_BROADCAST_CHANNEL, configProvider, acquireLock, releaseLock, onStop, automaticallyConnectWebrtc = true, sqliteLayer }) {
|
|
255
565
|
this._configProvider = configProvider;
|
|
256
566
|
this._acquireLock = acquireLock;
|
|
257
567
|
this._releaseLock = releaseLock;
|
|
258
568
|
this._onStop = onStop;
|
|
259
569
|
this._channel = channel;
|
|
570
|
+
if (sqliteLayer) {
|
|
571
|
+
log3.warn("Using testing SQLite layer", void 0, {
|
|
572
|
+
F: __dxlog_file3,
|
|
573
|
+
L: 102,
|
|
574
|
+
S: this,
|
|
575
|
+
C: (f, a) => f(...a)
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
this._runtime = ManagedRuntime.make(SqlTransaction.layer.pipe(Layer.provideMerge(sqliteLayer ?? LocalSqliteOpfsLayer), Layer.provideMerge(Reactivity.layer)).pipe(Layer.orDie));
|
|
260
579
|
this._clientServices = new ClientServicesHost({
|
|
261
580
|
callbacks: {
|
|
262
581
|
onReset: async () => this.stop()
|
|
582
|
+
},
|
|
583
|
+
runtime: this._runtime.runtimeEffect,
|
|
584
|
+
runtimeProps: {
|
|
585
|
+
// Auto-activate spaces that were previously active after leader changeover.
|
|
586
|
+
autoActivateSpaces: true
|
|
263
587
|
}
|
|
264
588
|
});
|
|
589
|
+
this._automaticallyConnectWebrtc = automaticallyConnectWebrtc;
|
|
265
590
|
}
|
|
266
591
|
get host() {
|
|
267
592
|
return this._clientServices;
|
|
268
593
|
}
|
|
594
|
+
get livenessLockKey() {
|
|
595
|
+
return this._livenessLock.key;
|
|
596
|
+
}
|
|
269
597
|
async start() {
|
|
270
|
-
|
|
271
|
-
F:
|
|
272
|
-
L:
|
|
598
|
+
log3("starting...", void 0, {
|
|
599
|
+
F: __dxlog_file3,
|
|
600
|
+
L: 131,
|
|
273
601
|
S: this,
|
|
274
602
|
C: (f, a) => f(...a)
|
|
275
603
|
});
|
|
276
604
|
try {
|
|
605
|
+
void this._livenessLock.acquire();
|
|
277
606
|
this._broadcastChannel = new BroadcastChannel(this._channel);
|
|
278
607
|
this._broadcastChannel.postMessage({
|
|
279
608
|
action: "stop"
|
|
@@ -285,6 +614,11 @@ var WorkerRuntime = class {
|
|
|
285
614
|
};
|
|
286
615
|
await this._acquireLock();
|
|
287
616
|
this._config = await this._configProvider();
|
|
617
|
+
this._signalTelemetryEnabled = this._config.get("runtime.client.signalTelemetryEnabled") ?? false;
|
|
618
|
+
const observabilityGroup = this._config.get("runtime.client.observabilityGroup");
|
|
619
|
+
if (observabilityGroup) {
|
|
620
|
+
this._signalMetadataTags.group = observabilityGroup;
|
|
621
|
+
}
|
|
288
622
|
const signals = this._config.get("runtime.services.signaling");
|
|
289
623
|
this._clientServices.initialize({
|
|
290
624
|
config: this._config,
|
|
@@ -292,13 +626,13 @@ var WorkerRuntime = class {
|
|
|
292
626
|
transportFactory: this._transportFactory
|
|
293
627
|
});
|
|
294
628
|
await this._clientServices.open(new Context(void 0, {
|
|
295
|
-
F:
|
|
296
|
-
L:
|
|
629
|
+
F: __dxlog_file3,
|
|
630
|
+
L: 162
|
|
297
631
|
}));
|
|
298
632
|
this._ready.wake(void 0);
|
|
299
|
-
|
|
300
|
-
F:
|
|
301
|
-
L:
|
|
633
|
+
log3("started", void 0, {
|
|
634
|
+
F: __dxlog_file3,
|
|
635
|
+
L: 164,
|
|
302
636
|
S: this,
|
|
303
637
|
C: (f, a) => f(...a)
|
|
304
638
|
});
|
|
@@ -311,9 +645,9 @@ var WorkerRuntime = class {
|
|
|
311
645
|
});
|
|
312
646
|
} catch (err) {
|
|
313
647
|
this._ready.wake(err);
|
|
314
|
-
|
|
315
|
-
F:
|
|
316
|
-
L:
|
|
648
|
+
log3.error("starting", err, {
|
|
649
|
+
F: __dxlog_file3,
|
|
650
|
+
L: 174,
|
|
317
651
|
S: this,
|
|
318
652
|
C: (f, a) => f(...a)
|
|
319
653
|
});
|
|
@@ -323,13 +657,39 @@ var WorkerRuntime = class {
|
|
|
323
657
|
this._releaseLock();
|
|
324
658
|
this._broadcastChannel?.close();
|
|
325
659
|
this._broadcastChannel = void 0;
|
|
326
|
-
await this._clientServices.close(
|
|
660
|
+
await this._clientServices.close(Context.default(void 0, {
|
|
661
|
+
F: __dxlog_file3,
|
|
662
|
+
L: 183
|
|
663
|
+
}));
|
|
664
|
+
await this._runtime.dispose();
|
|
327
665
|
await this._onStop?.();
|
|
666
|
+
await this._livenessLock.release();
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Update signaling telemetry tags from a client-supplied config overlay.
|
|
670
|
+
*
|
|
671
|
+
* The worker services outlive individual client connections, so the first client seeds the
|
|
672
|
+
* worker's core config (storage, signaling, edge features). For fields that can legitimately
|
|
673
|
+
* differ per tab — `observabilityGroup` and `signalTelemetryEnabled` — this method lets later
|
|
674
|
+
* connections refresh the signal metadata the worker attaches to its signaling requests
|
|
675
|
+
* (last-writer-wins, matching the pre-DX-930 per-session RPC behaviour).
|
|
676
|
+
*/
|
|
677
|
+
updateSignalMetadata(config) {
|
|
678
|
+
const observabilityGroup = config.get("runtime.client.observabilityGroup");
|
|
679
|
+
if (observabilityGroup) {
|
|
680
|
+
this._signalMetadataTags.group = observabilityGroup;
|
|
681
|
+
} else {
|
|
682
|
+
delete this._signalMetadataTags.group;
|
|
683
|
+
}
|
|
684
|
+
const signalTelemetryEnabled = config.get("runtime.client.signalTelemetryEnabled");
|
|
685
|
+
if (signalTelemetryEnabled !== void 0) {
|
|
686
|
+
this._signalTelemetryEnabled = signalTelemetryEnabled;
|
|
687
|
+
}
|
|
328
688
|
}
|
|
329
689
|
/**
|
|
330
690
|
* Create a new session.
|
|
331
691
|
*/
|
|
332
|
-
async createSession({ appPort, systemPort, shellPort }) {
|
|
692
|
+
async createSession({ appPort, systemPort, shellPort, onClose }) {
|
|
333
693
|
const session = new WorkerSession({
|
|
334
694
|
serviceHost: this._clientServices,
|
|
335
695
|
appPort,
|
|
@@ -342,34 +702,48 @@ var WorkerRuntime = class {
|
|
|
342
702
|
if (this._sessions.size === 0) {
|
|
343
703
|
await this.stop();
|
|
344
704
|
} else {
|
|
345
|
-
this.
|
|
705
|
+
if (this._automaticallyConnectWebrtc) {
|
|
706
|
+
this._reconnectWebrtc();
|
|
707
|
+
}
|
|
346
708
|
}
|
|
709
|
+
await onClose?.();
|
|
347
710
|
});
|
|
348
711
|
await session.open();
|
|
349
|
-
|
|
350
|
-
F:
|
|
351
|
-
L:
|
|
712
|
+
invariant3(!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin, `worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`, {
|
|
713
|
+
F: __dxlog_file3,
|
|
714
|
+
L: 241,
|
|
352
715
|
S: this,
|
|
353
716
|
A: [
|
|
354
717
|
"!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin",
|
|
355
718
|
"`worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`"
|
|
356
719
|
]
|
|
357
720
|
});
|
|
358
|
-
if (session.observabilityGroup) {
|
|
359
|
-
this._signalMetadataTags.group = session.observabilityGroup;
|
|
360
|
-
}
|
|
361
|
-
this._signalTelemetryEnabled = session.signalTelemetryEnabled ?? false;
|
|
362
721
|
this._signalMetadataTags.origin = session.origin;
|
|
363
722
|
this._sessions.add(session);
|
|
364
|
-
this.
|
|
723
|
+
if (this._automaticallyConnectWebrtc) {
|
|
724
|
+
this._reconnectWebrtc();
|
|
725
|
+
}
|
|
726
|
+
return session;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Connects the WebRTC bridge to the specified session.
|
|
730
|
+
* If no session is provided, disconnects the WebRTC bridge.
|
|
731
|
+
*
|
|
732
|
+
* Called automatically if `automaticallyConnectWebrtc` is true.
|
|
733
|
+
*
|
|
734
|
+
* @param session The session to connect the WebRTC bridge to.
|
|
735
|
+
*/
|
|
736
|
+
connectWebrtcBridge(session) {
|
|
737
|
+
this._sessionForNetworking = session;
|
|
738
|
+
this._transportFactory.setBridgeService(session?.bridgeService);
|
|
365
739
|
}
|
|
366
740
|
/**
|
|
367
741
|
* Selects one of the existing session for WebRTC networking.
|
|
368
742
|
*/
|
|
369
743
|
_reconnectWebrtc() {
|
|
370
|
-
|
|
371
|
-
F:
|
|
372
|
-
L:
|
|
744
|
+
log3("reconnecting webrtc...", void 0, {
|
|
745
|
+
F: __dxlog_file3,
|
|
746
|
+
L: 272,
|
|
373
747
|
S: this,
|
|
374
748
|
C: (f, a) => f(...a)
|
|
375
749
|
});
|
|
@@ -380,15 +754,58 @@ var WorkerRuntime = class {
|
|
|
380
754
|
}
|
|
381
755
|
if (!this._sessionForNetworking) {
|
|
382
756
|
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
|
-
}
|
|
757
|
+
this.connectWebrtcBridge(selected);
|
|
389
758
|
}
|
|
390
759
|
}
|
|
391
760
|
};
|
|
761
|
+
var DB_NAME = "DXOS";
|
|
762
|
+
var SqlExportLayer = Layer.effect(SqlExport.SqlExport, Effect.gen(function* () {
|
|
763
|
+
const sql = yield* SqliteClient.SqliteClient;
|
|
764
|
+
return {
|
|
765
|
+
export: sql.export
|
|
766
|
+
};
|
|
767
|
+
}));
|
|
768
|
+
var LocalSqliteOpfsLayer = Layer.unwrapScoped(Effect.gen(function* () {
|
|
769
|
+
const { port1: clientPort, port2: serverPort } = new MessageChannel();
|
|
770
|
+
clientPort.start();
|
|
771
|
+
serverPort.start();
|
|
772
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
773
|
+
clientPort.close();
|
|
774
|
+
serverPort.close();
|
|
775
|
+
}));
|
|
776
|
+
yield* Effect.forkScoped(OpfsWorker.run({
|
|
777
|
+
port: serverPort,
|
|
778
|
+
dbName: DB_NAME
|
|
779
|
+
}));
|
|
780
|
+
return SqlExportLayer.pipe(Layer.provideMerge(SqliteClient.layer({
|
|
781
|
+
worker: Effect.succeed(clientPort)
|
|
782
|
+
})));
|
|
783
|
+
}));
|
|
784
|
+
var WebLockWrapper = class {
|
|
785
|
+
#key;
|
|
786
|
+
#release;
|
|
787
|
+
constructor(key) {
|
|
788
|
+
this.#key = key;
|
|
789
|
+
}
|
|
790
|
+
get key() {
|
|
791
|
+
return this.#key;
|
|
792
|
+
}
|
|
793
|
+
acquire(options = {}) {
|
|
794
|
+
return navigator.locks.request(this.#key, options, async () => {
|
|
795
|
+
await new Promise((resolve) => {
|
|
796
|
+
this.#release = resolve;
|
|
797
|
+
});
|
|
798
|
+
this.#release = void 0;
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
release() {
|
|
802
|
+
this.#release?.();
|
|
803
|
+
this.#release = void 0;
|
|
804
|
+
}
|
|
805
|
+
[Symbol.dispose]() {
|
|
806
|
+
this.release();
|
|
807
|
+
}
|
|
808
|
+
};
|
|
392
809
|
export {
|
|
393
810
|
ClientRpcServer,
|
|
394
811
|
ClientServicesHost,
|
|
@@ -407,33 +824,38 @@ export {
|
|
|
407
824
|
InvitationsHandler,
|
|
408
825
|
InvitationsManager,
|
|
409
826
|
InvitationsServiceImpl,
|
|
410
|
-
Lock,
|
|
411
827
|
ServiceContext,
|
|
412
828
|
ServiceRegistry,
|
|
829
|
+
SpaceArchiveWriter,
|
|
413
830
|
SpaceInvitationProtocol,
|
|
414
831
|
SpacesServiceImpl,
|
|
415
832
|
TrustedKeySetAuthVerifier,
|
|
416
833
|
WorkerRuntime,
|
|
417
834
|
WorkerSession,
|
|
835
|
+
buildDatabaseDirectoryFromObjects,
|
|
418
836
|
createAdmissionKeypair,
|
|
419
837
|
createAuthProvider,
|
|
420
|
-
createCollectDiagnosticsBroadcastHandler,
|
|
421
|
-
createCollectDiagnosticsBroadcastSender,
|
|
422
838
|
createDiagnostics,
|
|
423
839
|
createLevel,
|
|
424
840
|
createStorageObjects,
|
|
425
841
|
decodeProfileArchive,
|
|
842
|
+
detectSpaceArchiveFormat,
|
|
426
843
|
encodeProfileArchive,
|
|
427
844
|
exportProfileData,
|
|
845
|
+
extractSpaceArchive,
|
|
428
846
|
getNetworkPeers,
|
|
429
847
|
importProfileData,
|
|
430
|
-
|
|
848
|
+
objJsonToObjectStructure,
|
|
849
|
+
objectStructureToObjJson,
|
|
850
|
+
orderObjJsonFields,
|
|
851
|
+
readSerializedSpaceArchive,
|
|
431
852
|
subscribeToFeedBlocks,
|
|
432
853
|
subscribeToFeeds,
|
|
433
854
|
subscribeToNetworkStatus,
|
|
434
855
|
subscribeToNetworkTopics,
|
|
435
856
|
subscribeToSignal,
|
|
436
857
|
subscribeToSpaces,
|
|
437
|
-
subscribeToSwarmInfo
|
|
858
|
+
subscribeToSwarmInfo,
|
|
859
|
+
writeSerializedSpaceArchive
|
|
438
860
|
};
|
|
439
861
|
//# sourceMappingURL=index.mjs.map
|