@dxos/client-services 0.8.4-main.f9ba587 → 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-ERQJUBAW.mjs → chunk-HYGNOM23.mjs} +4279 -3342
- 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 +539 -98
- 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 +45 -26
- 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-TMEG7JOG.mjs → chunk-GFT7MAQE.mjs} +3764 -2695
- 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 +539 -98
- 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 +45 -26
- 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 +3 -2
- 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 +2 -3
- 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/identity-manager.d.ts +7 -7
- 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 +9 -12
- 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 +2 -2
- 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 +8 -5
- 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 +4 -4
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +5 -4
- 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 +5 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +7 -6
- 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 +14 -9
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +21 -8
- 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 +8 -2
- 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/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 +29 -17
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +30 -13
- 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 +18 -8
- 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 +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 +72 -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 +17 -5
- package/src/packlets/devices/devices-service.test.ts +3 -3
- package/src/packlets/devices/devices-service.ts +2 -2
- package/src/packlets/devtools/devtools.ts +29 -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 +2 -3
- 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 +2 -2
- package/src/packlets/identity/identity-manager.test.ts +8 -8
- package/src/packlets/identity/identity-manager.ts +23 -20
- package/src/packlets/identity/identity-recovery-manager.ts +22 -18
- package/src/packlets/identity/identity-service.test.ts +8 -28
- package/src/packlets/identity/identity-service.ts +13 -80
- package/src/packlets/identity/identity.test.ts +11 -11
- package/src/packlets/identity/identity.ts +17 -39
- package/src/packlets/invitations/device-invitation-protocol.test.ts +4 -4
- package/src/packlets/invitations/device-invitation-protocol.ts +8 -6
- package/src/packlets/invitations/edge-invitation-handler.ts +10 -6
- 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 +8 -5
- package/src/packlets/invitations/invitation-state.ts +0 -10
- package/src/packlets/invitations/invitations-handler.test.ts +301 -292
- package/src/packlets/invitations/invitations-handler.ts +72 -16
- package/src/packlets/invitations/invitations-manager.ts +43 -18
- package/src/packlets/invitations/invitations-service.ts +10 -10
- package/src/packlets/invitations/space-invitation-protocol.test.ts +26 -25
- package/src/packlets/invitations/space-invitation-protocol.ts +13 -17
- 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 +8 -3
- package/src/packlets/logging/logging.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +3 -3
- package/src/packlets/network/network-service.ts +12 -10
- package/src/packlets/services/client-rpc-server.ts +20 -17
- 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 +4 -3
- package/src/packlets/services/service-context.ts +145 -59
- package/src/packlets/services/service-host.test.ts +10 -9
- package/src/packlets/services/service-host.ts +85 -38
- package/src/packlets/services/service-registry.test.ts +1 -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 +44 -6
- package/src/packlets/space-export/space-archive.test.ts +461 -0
- 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.test.ts +79 -13
- package/src/packlets/spaces/data-space-manager.ts +131 -118
- package/src/packlets/spaces/data-space.ts +65 -39
- package/src/packlets/spaces/edge-feed-replicator.test.ts +4 -4
- package/src/packlets/spaces/edge-feed-replicator.ts +13 -11
- 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 +3 -3
- package/src/packlets/spaces/notarization-plugin.ts +13 -12
- package/src/packlets/spaces/spaces-service.test.ts +20 -12
- package/src/packlets/spaces/spaces-service.ts +138 -38
- 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 +11 -7
- package/src/packlets/testing/test-builder.ts +39 -13
- package/src/packlets/worker/worker-runtime.ts +180 -17
- package/src/packlets/worker/worker-session.ts +15 -21
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-ERQJUBAW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TMEG7JOG.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,64 +16,384 @@ 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
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import { invariant } from "@dxos/invariant";
|
|
61
|
-
import { log, logInfo } from "@dxos/log";
|
|
370
|
+
import { Trigger, asyncTimeout } from "@dxos/async";
|
|
371
|
+
import { PROXY_CONNECTION_TIMEOUT, iframeServiceBundle, workerServiceBundle } from "@dxos/client-protocol";
|
|
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 {
|
|
384
|
+
_clientRpc;
|
|
385
|
+
_shellClientRpc;
|
|
386
|
+
_iframeRpc;
|
|
387
|
+
_startTrigger = new Trigger();
|
|
388
|
+
_serviceHost;
|
|
389
|
+
onClose = new Callback();
|
|
390
|
+
origin;
|
|
391
|
+
lockKey;
|
|
392
|
+
bridgeService;
|
|
72
393
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
F: __dxlog_file,
|
|
77
|
-
L: 54,
|
|
394
|
+
invariant2(serviceHost, void 0, {
|
|
395
|
+
F: __dxlog_file2,
|
|
396
|
+
L: 50,
|
|
78
397
|
S: this,
|
|
79
398
|
A: [
|
|
80
399
|
"serviceHost",
|
|
@@ -83,23 +402,23 @@ var WorkerSession = class {
|
|
|
83
402
|
});
|
|
84
403
|
this._serviceHost = serviceHost;
|
|
85
404
|
const middleware = {
|
|
86
|
-
handleCall: async (method, params, handler) => {
|
|
405
|
+
handleCall: async (method, params, handler, options) => {
|
|
87
406
|
const error = await readySignal.wait({
|
|
88
407
|
timeout: PROXY_CONNECTION_TIMEOUT
|
|
89
408
|
});
|
|
90
409
|
if (error) {
|
|
91
410
|
throw error;
|
|
92
411
|
}
|
|
93
|
-
return handler(method, params);
|
|
412
|
+
return handler(method, params, options);
|
|
94
413
|
},
|
|
95
|
-
handleStream: async (method, params, handler) => {
|
|
414
|
+
handleStream: async (method, params, handler, options) => {
|
|
96
415
|
const error = await readySignal.wait({
|
|
97
416
|
timeout: PROXY_CONNECTION_TIMEOUT
|
|
98
417
|
});
|
|
99
418
|
if (error) {
|
|
100
419
|
throw error;
|
|
101
420
|
}
|
|
102
|
-
return handler(method, params);
|
|
421
|
+
return handler(method, params, options);
|
|
103
422
|
}
|
|
104
423
|
};
|
|
105
424
|
this._clientRpc = new ClientRpcServer({
|
|
@@ -120,8 +439,6 @@ var WorkerSession = class {
|
|
|
120
439
|
start: async (request) => {
|
|
121
440
|
this.origin = request.origin;
|
|
122
441
|
this.lockKey = request.lockKey;
|
|
123
|
-
this.observabilityGroup = request.observabilityGroup;
|
|
124
|
-
this.signalTelemetryEnabled = request.signalTelemetryEnabled;
|
|
125
442
|
this._startTrigger.wake();
|
|
126
443
|
},
|
|
127
444
|
stop: async () => {
|
|
@@ -129,9 +446,9 @@ var WorkerSession = class {
|
|
|
129
446
|
try {
|
|
130
447
|
await this.close();
|
|
131
448
|
} catch (err) {
|
|
132
|
-
|
|
133
|
-
F:
|
|
134
|
-
L:
|
|
449
|
+
log2.catch(err, void 0, {
|
|
450
|
+
F: __dxlog_file2,
|
|
451
|
+
L: 102,
|
|
135
452
|
S: this,
|
|
136
453
|
C: (f, a) => f(...a)
|
|
137
454
|
});
|
|
@@ -146,9 +463,9 @@ var WorkerSession = class {
|
|
|
146
463
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
147
464
|
}
|
|
148
465
|
async open() {
|
|
149
|
-
|
|
150
|
-
F:
|
|
151
|
-
L:
|
|
466
|
+
log2("opening...", void 0, {
|
|
467
|
+
F: __dxlog_file2,
|
|
468
|
+
L: 116,
|
|
152
469
|
S: this,
|
|
153
470
|
C: (f, a) => f(...a)
|
|
154
471
|
});
|
|
@@ -163,26 +480,26 @@ var WorkerSession = class {
|
|
|
163
480
|
if (this.lockKey) {
|
|
164
481
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
165
482
|
}
|
|
166
|
-
|
|
167
|
-
F:
|
|
168
|
-
L:
|
|
483
|
+
log2("opened", void 0, {
|
|
484
|
+
F: __dxlog_file2,
|
|
485
|
+
L: 127,
|
|
169
486
|
S: this,
|
|
170
487
|
C: (f, a) => f(...a)
|
|
171
488
|
});
|
|
172
489
|
}
|
|
173
490
|
async close() {
|
|
174
|
-
|
|
175
|
-
F:
|
|
176
|
-
L:
|
|
491
|
+
log2.debug("closing...", void 0, {
|
|
492
|
+
F: __dxlog_file2,
|
|
493
|
+
L: 131,
|
|
177
494
|
S: this,
|
|
178
495
|
C: (f, a) => f(...a)
|
|
179
496
|
});
|
|
180
497
|
try {
|
|
181
498
|
await this.onClose.callIfSet();
|
|
182
499
|
} catch (err) {
|
|
183
|
-
|
|
184
|
-
F:
|
|
185
|
-
L:
|
|
500
|
+
log2.catch(err, void 0, {
|
|
501
|
+
F: __dxlog_file2,
|
|
502
|
+
L: 135,
|
|
186
503
|
S: this,
|
|
187
504
|
C: (f, a) => f(...a)
|
|
188
505
|
});
|
|
@@ -191,9 +508,9 @@ var WorkerSession = class {
|
|
|
191
508
|
this._clientRpc.close(),
|
|
192
509
|
this._iframeRpc.close()
|
|
193
510
|
]);
|
|
194
|
-
|
|
195
|
-
F:
|
|
196
|
-
L:
|
|
511
|
+
log2.debug("closed", void 0, {
|
|
512
|
+
F: __dxlog_file2,
|
|
513
|
+
L: 139,
|
|
197
514
|
S: this,
|
|
198
515
|
C: (f, a) => f(...a)
|
|
199
516
|
});
|
|
@@ -202,9 +519,9 @@ var WorkerSession = class {
|
|
|
202
519
|
try {
|
|
203
520
|
this._shellClientRpc && await asyncTimeout(this._shellClientRpc.open(), 1e3);
|
|
204
521
|
} catch {
|
|
205
|
-
|
|
206
|
-
F:
|
|
207
|
-
L:
|
|
522
|
+
log2.info("No shell connected.", void 0, {
|
|
523
|
+
F: __dxlog_file2,
|
|
524
|
+
L: 146,
|
|
208
525
|
S: this,
|
|
209
526
|
C: (f, a) => f(...a)
|
|
210
527
|
});
|
|
@@ -215,46 +532,77 @@ var WorkerSession = class {
|
|
|
215
532
|
}).then(callback);
|
|
216
533
|
}
|
|
217
534
|
};
|
|
218
|
-
|
|
535
|
+
_ts_decorate2([
|
|
219
536
|
logInfo
|
|
220
537
|
], WorkerSession.prototype, "origin", void 0);
|
|
221
|
-
|
|
538
|
+
_ts_decorate2([
|
|
222
539
|
logInfo
|
|
223
540
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
224
541
|
|
|
225
542
|
// src/packlets/worker/worker-runtime.ts
|
|
226
|
-
var
|
|
543
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
|
|
227
544
|
var WorkerRuntime = class {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
545
|
+
_configProvider;
|
|
546
|
+
_acquireLock;
|
|
547
|
+
_releaseLock;
|
|
548
|
+
_onStop;
|
|
549
|
+
_transportFactory = new RtcTransportProxyFactory();
|
|
550
|
+
_ready = new Trigger2();
|
|
551
|
+
_sessions = /* @__PURE__ */ new Set();
|
|
552
|
+
_clientServices;
|
|
553
|
+
_channel;
|
|
554
|
+
_automaticallyConnectWebrtc;
|
|
555
|
+
_livenessLock = new WebLockWrapper(`@dxos/client-services/WorkerRuntime/${crypto.randomUUID()}`);
|
|
556
|
+
_broadcastChannel;
|
|
557
|
+
_sessionForNetworking;
|
|
558
|
+
_config;
|
|
559
|
+
_signalMetadataTags = {
|
|
560
|
+
runtime: "worker-runtime"
|
|
561
|
+
};
|
|
562
|
+
_signalTelemetryEnabled = false;
|
|
563
|
+
_runtime;
|
|
564
|
+
constructor({ channel = DEFAULT_WORKER_BROADCAST_CHANNEL, configProvider, acquireLock, releaseLock, onStop, automaticallyConnectWebrtc = true, sqliteLayer }) {
|
|
236
565
|
this._configProvider = configProvider;
|
|
237
566
|
this._acquireLock = acquireLock;
|
|
238
567
|
this._releaseLock = releaseLock;
|
|
239
568
|
this._onStop = onStop;
|
|
240
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));
|
|
241
579
|
this._clientServices = new ClientServicesHost({
|
|
242
580
|
callbacks: {
|
|
243
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
|
|
244
587
|
}
|
|
245
588
|
});
|
|
589
|
+
this._automaticallyConnectWebrtc = automaticallyConnectWebrtc;
|
|
246
590
|
}
|
|
247
591
|
get host() {
|
|
248
592
|
return this._clientServices;
|
|
249
593
|
}
|
|
594
|
+
get livenessLockKey() {
|
|
595
|
+
return this._livenessLock.key;
|
|
596
|
+
}
|
|
250
597
|
async start() {
|
|
251
|
-
|
|
252
|
-
F:
|
|
253
|
-
L:
|
|
598
|
+
log3("starting...", void 0, {
|
|
599
|
+
F: __dxlog_file3,
|
|
600
|
+
L: 131,
|
|
254
601
|
S: this,
|
|
255
602
|
C: (f, a) => f(...a)
|
|
256
603
|
});
|
|
257
604
|
try {
|
|
605
|
+
void this._livenessLock.acquire();
|
|
258
606
|
this._broadcastChannel = new BroadcastChannel(this._channel);
|
|
259
607
|
this._broadcastChannel.postMessage({
|
|
260
608
|
action: "stop"
|
|
@@ -266,6 +614,11 @@ var WorkerRuntime = class {
|
|
|
266
614
|
};
|
|
267
615
|
await this._acquireLock();
|
|
268
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
|
+
}
|
|
269
622
|
const signals = this._config.get("runtime.services.signaling");
|
|
270
623
|
this._clientServices.initialize({
|
|
271
624
|
config: this._config,
|
|
@@ -273,13 +626,13 @@ var WorkerRuntime = class {
|
|
|
273
626
|
transportFactory: this._transportFactory
|
|
274
627
|
});
|
|
275
628
|
await this._clientServices.open(new Context(void 0, {
|
|
276
|
-
F:
|
|
277
|
-
L:
|
|
629
|
+
F: __dxlog_file3,
|
|
630
|
+
L: 162
|
|
278
631
|
}));
|
|
279
632
|
this._ready.wake(void 0);
|
|
280
|
-
|
|
281
|
-
F:
|
|
282
|
-
L:
|
|
633
|
+
log3("started", void 0, {
|
|
634
|
+
F: __dxlog_file3,
|
|
635
|
+
L: 164,
|
|
283
636
|
S: this,
|
|
284
637
|
C: (f, a) => f(...a)
|
|
285
638
|
});
|
|
@@ -292,9 +645,9 @@ var WorkerRuntime = class {
|
|
|
292
645
|
});
|
|
293
646
|
} catch (err) {
|
|
294
647
|
this._ready.wake(err);
|
|
295
|
-
|
|
296
|
-
F:
|
|
297
|
-
L:
|
|
648
|
+
log3.error("starting", err, {
|
|
649
|
+
F: __dxlog_file3,
|
|
650
|
+
L: 174,
|
|
298
651
|
S: this,
|
|
299
652
|
C: (f, a) => f(...a)
|
|
300
653
|
});
|
|
@@ -304,13 +657,39 @@ var WorkerRuntime = class {
|
|
|
304
657
|
this._releaseLock();
|
|
305
658
|
this._broadcastChannel?.close();
|
|
306
659
|
this._broadcastChannel = void 0;
|
|
307
|
-
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();
|
|
308
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
|
+
}
|
|
309
688
|
}
|
|
310
689
|
/**
|
|
311
690
|
* Create a new session.
|
|
312
691
|
*/
|
|
313
|
-
async createSession({ appPort, systemPort, shellPort }) {
|
|
692
|
+
async createSession({ appPort, systemPort, shellPort, onClose }) {
|
|
314
693
|
const session = new WorkerSession({
|
|
315
694
|
serviceHost: this._clientServices,
|
|
316
695
|
appPort,
|
|
@@ -323,34 +702,48 @@ var WorkerRuntime = class {
|
|
|
323
702
|
if (this._sessions.size === 0) {
|
|
324
703
|
await this.stop();
|
|
325
704
|
} else {
|
|
326
|
-
this.
|
|
705
|
+
if (this._automaticallyConnectWebrtc) {
|
|
706
|
+
this._reconnectWebrtc();
|
|
707
|
+
}
|
|
327
708
|
}
|
|
709
|
+
await onClose?.();
|
|
328
710
|
});
|
|
329
711
|
await session.open();
|
|
330
|
-
|
|
331
|
-
F:
|
|
332
|
-
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,
|
|
333
715
|
S: this,
|
|
334
716
|
A: [
|
|
335
717
|
"!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin",
|
|
336
718
|
"`worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`"
|
|
337
719
|
]
|
|
338
720
|
});
|
|
339
|
-
if (session.observabilityGroup) {
|
|
340
|
-
this._signalMetadataTags.group = session.observabilityGroup;
|
|
341
|
-
}
|
|
342
|
-
this._signalTelemetryEnabled = session.signalTelemetryEnabled ?? false;
|
|
343
721
|
this._signalMetadataTags.origin = session.origin;
|
|
344
722
|
this._sessions.add(session);
|
|
345
|
-
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);
|
|
346
739
|
}
|
|
347
740
|
/**
|
|
348
741
|
* Selects one of the existing session for WebRTC networking.
|
|
349
742
|
*/
|
|
350
743
|
_reconnectWebrtc() {
|
|
351
|
-
|
|
352
|
-
F:
|
|
353
|
-
L:
|
|
744
|
+
log3("reconnecting webrtc...", void 0, {
|
|
745
|
+
F: __dxlog_file3,
|
|
746
|
+
L: 272,
|
|
354
747
|
S: this,
|
|
355
748
|
C: (f, a) => f(...a)
|
|
356
749
|
});
|
|
@@ -361,15 +754,58 @@ var WorkerRuntime = class {
|
|
|
361
754
|
}
|
|
362
755
|
if (!this._sessionForNetworking) {
|
|
363
756
|
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
|
-
}
|
|
757
|
+
this.connectWebrtcBridge(selected);
|
|
370
758
|
}
|
|
371
759
|
}
|
|
372
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
|
+
};
|
|
373
809
|
export {
|
|
374
810
|
ClientRpcServer,
|
|
375
811
|
ClientServicesHost,
|
|
@@ -388,33 +824,38 @@ export {
|
|
|
388
824
|
InvitationsHandler,
|
|
389
825
|
InvitationsManager,
|
|
390
826
|
InvitationsServiceImpl,
|
|
391
|
-
Lock,
|
|
392
827
|
ServiceContext,
|
|
393
828
|
ServiceRegistry,
|
|
829
|
+
SpaceArchiveWriter,
|
|
394
830
|
SpaceInvitationProtocol,
|
|
395
831
|
SpacesServiceImpl,
|
|
396
832
|
TrustedKeySetAuthVerifier,
|
|
397
833
|
WorkerRuntime,
|
|
398
834
|
WorkerSession,
|
|
835
|
+
buildDatabaseDirectoryFromObjects,
|
|
399
836
|
createAdmissionKeypair,
|
|
400
837
|
createAuthProvider,
|
|
401
|
-
createCollectDiagnosticsBroadcastHandler,
|
|
402
|
-
createCollectDiagnosticsBroadcastSender,
|
|
403
838
|
createDiagnostics,
|
|
404
839
|
createLevel,
|
|
405
840
|
createStorageObjects,
|
|
406
841
|
decodeProfileArchive,
|
|
842
|
+
detectSpaceArchiveFormat,
|
|
407
843
|
encodeProfileArchive,
|
|
408
844
|
exportProfileData,
|
|
845
|
+
extractSpaceArchive,
|
|
409
846
|
getNetworkPeers,
|
|
410
847
|
importProfileData,
|
|
411
|
-
|
|
848
|
+
objJsonToObjectStructure,
|
|
849
|
+
objectStructureToObjJson,
|
|
850
|
+
orderObjJsonFields,
|
|
851
|
+
readSerializedSpaceArchive,
|
|
412
852
|
subscribeToFeedBlocks,
|
|
413
853
|
subscribeToFeeds,
|
|
414
854
|
subscribeToNetworkStatus,
|
|
415
855
|
subscribeToNetworkTopics,
|
|
416
856
|
subscribeToSignal,
|
|
417
857
|
subscribeToSpaces,
|
|
418
|
-
subscribeToSwarmInfo
|
|
858
|
+
subscribeToSwarmInfo,
|
|
859
|
+
writeSerializedSpaceArchive
|
|
419
860
|
};
|
|
420
861
|
//# sourceMappingURL=index.mjs.map
|