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