@dxos/client-services 0.8.4-main.406dc2a → 0.8.4-main.422d1c7879
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-TF7KXCT7.mjs → chunk-J7VTDH4K.mjs} +3459 -3082
- package/dist/lib/browser/chunk-J7VTDH4K.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 +584 -187
- 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 +70 -80
- 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-XJAHJBOC.mjs → chunk-2WCRQW4E.mjs} +3111 -2603
- package/dist/lib/node-esm/chunk-2WCRQW4E.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 +584 -187
- 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 +70 -80
- 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 -55
- package/src/index.ts +1 -0
- package/src/packlets/agents/edge-agent-manager.ts +8 -5
- package/src/packlets/agents/edge-agent-service.ts +4 -2
- package/src/packlets/devices/devices-service.test.ts +0 -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 +2 -2
- 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 +20 -16
- 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 +137 -51
- package/src/packlets/services/service-host.test.ts +8 -8
- package/src/packlets/services/service-host.ts +69 -31
- 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 +253 -0
- package/src/packlets/space-export/space-archive-reader.ts +64 -3
- package/src/packlets/space-export/space-archive-writer.ts +41 -3
- 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 +114 -109
- package/src/packlets/spaces/data-space.ts +58 -33
- package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
- package/src/packlets/spaces/edge-feed-replicator.ts +11 -9
- package/src/packlets/spaces/epoch-migrations.ts +5 -5
- package/src/packlets/spaces/genesis.ts +6 -1
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.ts +10 -9
- package/src/packlets/spaces/spaces-service.test.ts +18 -11
- package/src/packlets/spaces/spaces-service.ts +123 -24
- 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-TF7KXCT7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJAHJBOC.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,155 +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-J7VTDH4K.mjs";
|
|
49
|
+
import "./chunk-NQSC7HOE.mjs";
|
|
50
|
+
import {
|
|
51
|
+
__export,
|
|
52
|
+
__reExport
|
|
53
|
+
} from "./chunk-QCWEHHJW.mjs";
|
|
47
54
|
|
|
48
|
-
// src/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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);
|
|
56
111
|
|
|
57
|
-
// src/packlets/
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
63
|
-
import { Callback } from "@dxos/util";
|
|
64
|
-
function _define_property(obj, key, value) {
|
|
65
|
-
if (key in obj) {
|
|
66
|
-
Object.defineProperty(obj, key, {
|
|
67
|
-
value,
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
obj[key] = value;
|
|
74
|
-
}
|
|
75
|
-
return obj;
|
|
76
|
-
}
|
|
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";
|
|
77
117
|
function _ts_decorate(decorators, target, key, desc) {
|
|
78
118
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
79
119
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
80
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;
|
|
81
121
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
82
122
|
}
|
|
83
|
-
var
|
|
84
|
-
|
|
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
|
+
}
|
|
85
165
|
async open() {
|
|
86
|
-
|
|
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
|
+
}, {
|
|
87
215
|
F: __dxlog_file,
|
|
88
|
-
L:
|
|
89
|
-
S:
|
|
216
|
+
L: 31,
|
|
217
|
+
S: void 0,
|
|
90
218
|
C: (f, a) => f(...a)
|
|
91
219
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
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
|
+
});
|
|
102
229
|
}
|
|
103
|
-
log.info("
|
|
230
|
+
log.info("done exporting files", {
|
|
231
|
+
count: files.length
|
|
232
|
+
}, {
|
|
104
233
|
F: __dxlog_file,
|
|
105
|
-
L:
|
|
106
|
-
S:
|
|
234
|
+
L: 42,
|
|
235
|
+
S: void 0,
|
|
107
236
|
C: (f, a) => f(...a)
|
|
108
237
|
});
|
|
109
238
|
}
|
|
110
|
-
|
|
111
|
-
log.info("
|
|
239
|
+
{
|
|
240
|
+
log.info("begin exporting kv pairs", void 0, {
|
|
112
241
|
F: __dxlog_file,
|
|
113
|
-
L:
|
|
114
|
-
S:
|
|
242
|
+
L: 46,
|
|
243
|
+
S: void 0,
|
|
115
244
|
C: (f, a) => f(...a)
|
|
116
245
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
|
125
256
|
});
|
|
257
|
+
count++;
|
|
126
258
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
]);
|
|
131
|
-
log.info("closed", void 0, {
|
|
259
|
+
log.info("done exporting kv pairs", {
|
|
260
|
+
count
|
|
261
|
+
}, {
|
|
132
262
|
F: __dxlog_file,
|
|
133
|
-
L:
|
|
134
|
-
S:
|
|
263
|
+
L: 57,
|
|
264
|
+
S: void 0,
|
|
135
265
|
C: (f, a) => f(...a)
|
|
136
266
|
});
|
|
137
267
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
+
}, {
|
|
143
336
|
F: __dxlog_file,
|
|
144
|
-
L:
|
|
145
|
-
S:
|
|
337
|
+
L: 102,
|
|
338
|
+
S: void 0,
|
|
146
339
|
C: (f, a) => f(...a)
|
|
147
340
|
});
|
|
148
341
|
}
|
|
149
342
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
+
};
|
|
351
|
+
|
|
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";
|
|
357
|
+
import { Trigger as Trigger2 } from "@dxos/async";
|
|
358
|
+
import { DEFAULT_WORKER_BROADCAST_CHANNEL } from "@dxos/client-protocol";
|
|
359
|
+
import { Context } from "@dxos/context";
|
|
360
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
361
|
+
import { log as log3 } from "@dxos/log";
|
|
362
|
+
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager, setIdentityTags } from "@dxos/messaging";
|
|
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";
|
|
368
|
+
|
|
369
|
+
// src/packlets/worker/worker-session.ts
|
|
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";
|
|
374
|
+
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
375
|
+
import { Callback } from "@dxos/util";
|
|
376
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
377
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
378
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
380
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
381
|
+
}
|
|
382
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
|
|
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;
|
|
154
393
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
_define_property(this, "_startTrigger", new Trigger());
|
|
159
|
-
_define_property(this, "_serviceHost", void 0);
|
|
160
|
-
_define_property(this, "onClose", new Callback());
|
|
161
|
-
_define_property(this, "origin", void 0);
|
|
162
|
-
_define_property(this, "observabilityGroup", void 0);
|
|
163
|
-
_define_property(this, "signalTelemetryEnabled", void 0);
|
|
164
|
-
_define_property(this, "lockKey", void 0);
|
|
165
|
-
_define_property(this, "bridgeService", void 0);
|
|
166
|
-
invariant(serviceHost, void 0, {
|
|
167
|
-
F: __dxlog_file,
|
|
168
|
-
L: 54,
|
|
394
|
+
invariant2(serviceHost, void 0, {
|
|
395
|
+
F: __dxlog_file2,
|
|
396
|
+
L: 50,
|
|
169
397
|
S: this,
|
|
170
398
|
A: [
|
|
171
399
|
"serviceHost",
|
|
@@ -174,23 +402,23 @@ var WorkerSession = class {
|
|
|
174
402
|
});
|
|
175
403
|
this._serviceHost = serviceHost;
|
|
176
404
|
const middleware = {
|
|
177
|
-
handleCall: async (method, params, handler) => {
|
|
405
|
+
handleCall: async (method, params, handler, options) => {
|
|
178
406
|
const error = await readySignal.wait({
|
|
179
407
|
timeout: PROXY_CONNECTION_TIMEOUT
|
|
180
408
|
});
|
|
181
409
|
if (error) {
|
|
182
410
|
throw error;
|
|
183
411
|
}
|
|
184
|
-
return handler(method, params);
|
|
412
|
+
return handler(method, params, options);
|
|
185
413
|
},
|
|
186
|
-
handleStream: async (method, params, handler) => {
|
|
414
|
+
handleStream: async (method, params, handler, options) => {
|
|
187
415
|
const error = await readySignal.wait({
|
|
188
416
|
timeout: PROXY_CONNECTION_TIMEOUT
|
|
189
417
|
});
|
|
190
418
|
if (error) {
|
|
191
419
|
throw error;
|
|
192
420
|
}
|
|
193
|
-
return handler(method, params);
|
|
421
|
+
return handler(method, params, options);
|
|
194
422
|
}
|
|
195
423
|
};
|
|
196
424
|
this._clientRpc = new ClientRpcServer({
|
|
@@ -211,8 +439,6 @@ var WorkerSession = class {
|
|
|
211
439
|
start: async (request) => {
|
|
212
440
|
this.origin = request.origin;
|
|
213
441
|
this.lockKey = request.lockKey;
|
|
214
|
-
this.observabilityGroup = request.observabilityGroup;
|
|
215
|
-
this.signalTelemetryEnabled = request.signalTelemetryEnabled;
|
|
216
442
|
this._startTrigger.wake();
|
|
217
443
|
},
|
|
218
444
|
stop: async () => {
|
|
@@ -220,9 +446,9 @@ var WorkerSession = class {
|
|
|
220
446
|
try {
|
|
221
447
|
await this.close();
|
|
222
448
|
} catch (err) {
|
|
223
|
-
|
|
224
|
-
F:
|
|
225
|
-
L:
|
|
449
|
+
log2.catch(err, void 0, {
|
|
450
|
+
F: __dxlog_file2,
|
|
451
|
+
L: 102,
|
|
226
452
|
S: this,
|
|
227
453
|
C: (f, a) => f(...a)
|
|
228
454
|
});
|
|
@@ -236,41 +462,147 @@ var WorkerSession = class {
|
|
|
236
462
|
});
|
|
237
463
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
238
464
|
}
|
|
465
|
+
async open() {
|
|
466
|
+
log2("opening...", void 0, {
|
|
467
|
+
F: __dxlog_file2,
|
|
468
|
+
L: 116,
|
|
469
|
+
S: this,
|
|
470
|
+
C: (f, a) => f(...a)
|
|
471
|
+
});
|
|
472
|
+
await Promise.all([
|
|
473
|
+
this._clientRpc.open(),
|
|
474
|
+
this._iframeRpc.open(),
|
|
475
|
+
this._maybeOpenShell()
|
|
476
|
+
]);
|
|
477
|
+
await this._startTrigger.wait({
|
|
478
|
+
timeout: PROXY_CONNECTION_TIMEOUT
|
|
479
|
+
});
|
|
480
|
+
if (this.lockKey) {
|
|
481
|
+
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
482
|
+
}
|
|
483
|
+
log2("opened", void 0, {
|
|
484
|
+
F: __dxlog_file2,
|
|
485
|
+
L: 127,
|
|
486
|
+
S: this,
|
|
487
|
+
C: (f, a) => f(...a)
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
async close() {
|
|
491
|
+
log2.debug("closing...", void 0, {
|
|
492
|
+
F: __dxlog_file2,
|
|
493
|
+
L: 131,
|
|
494
|
+
S: this,
|
|
495
|
+
C: (f, a) => f(...a)
|
|
496
|
+
});
|
|
497
|
+
try {
|
|
498
|
+
await this.onClose.callIfSet();
|
|
499
|
+
} catch (err) {
|
|
500
|
+
log2.catch(err, void 0, {
|
|
501
|
+
F: __dxlog_file2,
|
|
502
|
+
L: 135,
|
|
503
|
+
S: this,
|
|
504
|
+
C: (f, a) => f(...a)
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
await Promise.all([
|
|
508
|
+
this._clientRpc.close(),
|
|
509
|
+
this._iframeRpc.close()
|
|
510
|
+
]);
|
|
511
|
+
log2.debug("closed", void 0, {
|
|
512
|
+
F: __dxlog_file2,
|
|
513
|
+
L: 139,
|
|
514
|
+
S: this,
|
|
515
|
+
C: (f, a) => f(...a)
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
async _maybeOpenShell() {
|
|
519
|
+
try {
|
|
520
|
+
this._shellClientRpc && await asyncTimeout(this._shellClientRpc.open(), 1e3);
|
|
521
|
+
} catch {
|
|
522
|
+
log2.info("No shell connected.", void 0, {
|
|
523
|
+
F: __dxlog_file2,
|
|
524
|
+
L: 146,
|
|
525
|
+
S: this,
|
|
526
|
+
C: (f, a) => f(...a)
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
_afterLockReleases(lockKey, callback) {
|
|
531
|
+
return navigator.locks.request(lockKey, () => {
|
|
532
|
+
}).then(callback);
|
|
533
|
+
}
|
|
239
534
|
};
|
|
240
|
-
|
|
535
|
+
_ts_decorate2([
|
|
241
536
|
logInfo
|
|
242
537
|
], WorkerSession.prototype, "origin", void 0);
|
|
243
|
-
|
|
538
|
+
_ts_decorate2([
|
|
244
539
|
logInfo
|
|
245
540
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
246
541
|
|
|
247
542
|
// src/packlets/worker/worker-runtime.ts
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
543
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
|
|
544
|
+
var WorkerRuntime = class {
|
|
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 }) {
|
|
565
|
+
this._configProvider = configProvider;
|
|
566
|
+
this._acquireLock = acquireLock;
|
|
567
|
+
this._releaseLock = releaseLock;
|
|
568
|
+
this._onStop = onStop;
|
|
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));
|
|
579
|
+
this._clientServices = new ClientServicesHost({
|
|
580
|
+
callbacks: {
|
|
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
|
|
587
|
+
}
|
|
255
588
|
});
|
|
256
|
-
|
|
257
|
-
obj[key] = value;
|
|
589
|
+
this._automaticallyConnectWebrtc = automaticallyConnectWebrtc;
|
|
258
590
|
}
|
|
259
|
-
return obj;
|
|
260
|
-
}
|
|
261
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
|
|
262
|
-
var WorkerRuntime = class {
|
|
263
591
|
get host() {
|
|
264
592
|
return this._clientServices;
|
|
265
593
|
}
|
|
594
|
+
get livenessLockKey() {
|
|
595
|
+
return this._livenessLock.key;
|
|
596
|
+
}
|
|
266
597
|
async start() {
|
|
267
|
-
|
|
268
|
-
F:
|
|
269
|
-
L:
|
|
598
|
+
log3("starting...", void 0, {
|
|
599
|
+
F: __dxlog_file3,
|
|
600
|
+
L: 131,
|
|
270
601
|
S: this,
|
|
271
602
|
C: (f, a) => f(...a)
|
|
272
603
|
});
|
|
273
604
|
try {
|
|
605
|
+
void this._livenessLock.acquire();
|
|
274
606
|
this._broadcastChannel = new BroadcastChannel(this._channel);
|
|
275
607
|
this._broadcastChannel.postMessage({
|
|
276
608
|
action: "stop"
|
|
@@ -282,6 +614,11 @@ var WorkerRuntime = class {
|
|
|
282
614
|
};
|
|
283
615
|
await this._acquireLock();
|
|
284
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
|
+
}
|
|
285
622
|
const signals = this._config.get("runtime.services.signaling");
|
|
286
623
|
this._clientServices.initialize({
|
|
287
624
|
config: this._config,
|
|
@@ -289,13 +626,13 @@ var WorkerRuntime = class {
|
|
|
289
626
|
transportFactory: this._transportFactory
|
|
290
627
|
});
|
|
291
628
|
await this._clientServices.open(new Context(void 0, {
|
|
292
|
-
F:
|
|
293
|
-
L:
|
|
629
|
+
F: __dxlog_file3,
|
|
630
|
+
L: 162
|
|
294
631
|
}));
|
|
295
632
|
this._ready.wake(void 0);
|
|
296
|
-
|
|
297
|
-
F:
|
|
298
|
-
L:
|
|
633
|
+
log3("started", void 0, {
|
|
634
|
+
F: __dxlog_file3,
|
|
635
|
+
L: 164,
|
|
299
636
|
S: this,
|
|
300
637
|
C: (f, a) => f(...a)
|
|
301
638
|
});
|
|
@@ -308,9 +645,9 @@ var WorkerRuntime = class {
|
|
|
308
645
|
});
|
|
309
646
|
} catch (err) {
|
|
310
647
|
this._ready.wake(err);
|
|
311
|
-
|
|
312
|
-
F:
|
|
313
|
-
L:
|
|
648
|
+
log3.error("starting", err, {
|
|
649
|
+
F: __dxlog_file3,
|
|
650
|
+
L: 174,
|
|
314
651
|
S: this,
|
|
315
652
|
C: (f, a) => f(...a)
|
|
316
653
|
});
|
|
@@ -320,13 +657,39 @@ var WorkerRuntime = class {
|
|
|
320
657
|
this._releaseLock();
|
|
321
658
|
this._broadcastChannel?.close();
|
|
322
659
|
this._broadcastChannel = void 0;
|
|
323
|
-
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();
|
|
324
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
|
+
}
|
|
325
688
|
}
|
|
326
689
|
/**
|
|
327
690
|
* Create a new session.
|
|
328
691
|
*/
|
|
329
|
-
async createSession({ appPort, systemPort, shellPort }) {
|
|
692
|
+
async createSession({ appPort, systemPort, shellPort, onClose }) {
|
|
330
693
|
const session = new WorkerSession({
|
|
331
694
|
serviceHost: this._clientServices,
|
|
332
695
|
appPort,
|
|
@@ -339,34 +702,48 @@ var WorkerRuntime = class {
|
|
|
339
702
|
if (this._sessions.size === 0) {
|
|
340
703
|
await this.stop();
|
|
341
704
|
} else {
|
|
342
|
-
this.
|
|
705
|
+
if (this._automaticallyConnectWebrtc) {
|
|
706
|
+
this._reconnectWebrtc();
|
|
707
|
+
}
|
|
343
708
|
}
|
|
709
|
+
await onClose?.();
|
|
344
710
|
});
|
|
345
711
|
await session.open();
|
|
346
|
-
|
|
347
|
-
F:
|
|
348
|
-
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,
|
|
349
715
|
S: this,
|
|
350
716
|
A: [
|
|
351
717
|
"!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin",
|
|
352
718
|
"`worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`"
|
|
353
719
|
]
|
|
354
720
|
});
|
|
355
|
-
if (session.observabilityGroup) {
|
|
356
|
-
this._signalMetadataTags.group = session.observabilityGroup;
|
|
357
|
-
}
|
|
358
|
-
this._signalTelemetryEnabled = session.signalTelemetryEnabled ?? false;
|
|
359
721
|
this._signalMetadataTags.origin = session.origin;
|
|
360
722
|
this._sessions.add(session);
|
|
361
|
-
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);
|
|
362
739
|
}
|
|
363
740
|
/**
|
|
364
741
|
* Selects one of the existing session for WebRTC networking.
|
|
365
742
|
*/
|
|
366
743
|
_reconnectWebrtc() {
|
|
367
|
-
|
|
368
|
-
F:
|
|
369
|
-
L:
|
|
744
|
+
log3("reconnecting webrtc...", void 0, {
|
|
745
|
+
F: __dxlog_file3,
|
|
746
|
+
L: 272,
|
|
370
747
|
S: this,
|
|
371
748
|
C: (f, a) => f(...a)
|
|
372
749
|
});
|
|
@@ -377,42 +754,57 @@ var WorkerRuntime = class {
|
|
|
377
754
|
}
|
|
378
755
|
if (!this._sessionForNetworking) {
|
|
379
756
|
const selected = Array.from(this._sessions).find((session) => session.bridgeService);
|
|
380
|
-
|
|
381
|
-
this._sessionForNetworking = selected;
|
|
382
|
-
this._transportFactory.setBridgeService(selected.bridgeService);
|
|
383
|
-
} else {
|
|
384
|
-
this._transportFactory.setBridgeService(void 0);
|
|
385
|
-
}
|
|
757
|
+
this.connectWebrtcBridge(selected);
|
|
386
758
|
}
|
|
387
759
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
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;
|
|
414
799
|
});
|
|
415
800
|
}
|
|
801
|
+
release() {
|
|
802
|
+
this.#release?.();
|
|
803
|
+
this.#release = void 0;
|
|
804
|
+
}
|
|
805
|
+
[Symbol.dispose]() {
|
|
806
|
+
this.release();
|
|
807
|
+
}
|
|
416
808
|
};
|
|
417
809
|
export {
|
|
418
810
|
ClientRpcServer,
|
|
@@ -432,33 +824,38 @@ export {
|
|
|
432
824
|
InvitationsHandler,
|
|
433
825
|
InvitationsManager,
|
|
434
826
|
InvitationsServiceImpl,
|
|
435
|
-
Lock,
|
|
436
827
|
ServiceContext,
|
|
437
828
|
ServiceRegistry,
|
|
829
|
+
SpaceArchiveWriter,
|
|
438
830
|
SpaceInvitationProtocol,
|
|
439
831
|
SpacesServiceImpl,
|
|
440
832
|
TrustedKeySetAuthVerifier,
|
|
441
833
|
WorkerRuntime,
|
|
442
834
|
WorkerSession,
|
|
835
|
+
buildDatabaseDirectoryFromObjects,
|
|
443
836
|
createAdmissionKeypair,
|
|
444
837
|
createAuthProvider,
|
|
445
|
-
createCollectDiagnosticsBroadcastHandler,
|
|
446
|
-
createCollectDiagnosticsBroadcastSender,
|
|
447
838
|
createDiagnostics,
|
|
448
839
|
createLevel,
|
|
449
840
|
createStorageObjects,
|
|
450
841
|
decodeProfileArchive,
|
|
842
|
+
detectSpaceArchiveFormat,
|
|
451
843
|
encodeProfileArchive,
|
|
452
844
|
exportProfileData,
|
|
845
|
+
extractSpaceArchive,
|
|
453
846
|
getNetworkPeers,
|
|
454
847
|
importProfileData,
|
|
455
|
-
|
|
848
|
+
objJsonToObjectStructure,
|
|
849
|
+
objectStructureToObjJson,
|
|
850
|
+
orderObjJsonFields,
|
|
851
|
+
readSerializedSpaceArchive,
|
|
456
852
|
subscribeToFeedBlocks,
|
|
457
853
|
subscribeToFeeds,
|
|
458
854
|
subscribeToNetworkStatus,
|
|
459
855
|
subscribeToNetworkTopics,
|
|
460
856
|
subscribeToSignal,
|
|
461
857
|
subscribeToSpaces,
|
|
462
|
-
subscribeToSwarmInfo
|
|
858
|
+
subscribeToSwarmInfo,
|
|
859
|
+
writeSerializedSpaceArchive
|
|
463
860
|
};
|
|
464
861
|
//# sourceMappingURL=index.mjs.map
|