@dxos/client-services 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/{chunk-6C7MTZLC.mjs → chunk-HPR4MJ4W.mjs} +2916 -3802
- package/dist/lib/browser/chunk-HPR4MJ4W.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/chunk-XJRPB3GA.mjs +22 -0
- package/dist/lib/browser/chunk-XJRPB3GA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +576 -139
- 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 +88 -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 +86 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +48 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +59 -55
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs +22 -0
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs.map +7 -0
- 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-YOHACH7G.mjs → chunk-JW6QHPRJ.mjs} +2859 -3614
- package/dist/lib/node-esm/chunk-JW6QHPRJ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +576 -139
- 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 +88 -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 +86 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +48 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +59 -55
- 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/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +7 -3
- 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/keys.d.ts +2 -2
- package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/spaces.d.ts.map +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.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +2 -3
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +3 -3
- 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 +10 -10
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +14 -9
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +7 -11
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +10 -13
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +7 -6
- 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/invitation-topology.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 +5 -5
- 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 +6 -5
- 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/browser.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/locks/node.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 +75 -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/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +22 -19
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +20 -13
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
- package/dist/types/src/packlets/services/sqlite-storage.d.ts +27 -0
- package/dist/types/src/packlets/services/sqlite-storage.d.ts.map +1 -0
- package/dist/types/src/packlets/services/util.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/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +49 -22
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +38 -13
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +4 -3
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -9
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +10 -7
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/profile-archive-sqlite.d.ts +24 -0
- package/dist/types/src/packlets/storage/profile-archive-sqlite.d.ts.map +1 -0
- package/dist/types/src/packlets/storage/profile-archive-sqlite.test.d.ts +2 -0
- package/dist/types/src/packlets/storage/profile-archive-sqlite.test.d.ts.map +1 -0
- 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/storage/util.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/credential-utils.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 +20 -22
- 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/testing/setup.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 +71 -57
- package/src/index.ts +1 -0
- package/src/packlets/agents/edge-agent-manager.ts +10 -7
- package/src/packlets/agents/edge-agent-service.ts +15 -3
- package/src/packlets/devices/devices-service.test.ts +0 -1
- package/src/packlets/devices/devices-service.ts +1 -1
- package/src/packlets/devtools/devtools.ts +28 -7
- package/src/packlets/devtools/feeds.ts +1 -1
- package/src/packlets/devtools/keys.ts +2 -2
- package/src/packlets/devtools/spaces.ts +1 -1
- package/src/packlets/diagnostics/diagnostics.ts +1 -2
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.ts +3 -3
- package/src/packlets/identity/contacts-service.ts +1 -2
- package/src/packlets/identity/identity-manager.test.ts +6 -6
- package/src/packlets/identity/identity-manager.ts +29 -28
- package/src/packlets/identity/identity-recovery-manager.ts +31 -22
- package/src/packlets/identity/identity-service.test.ts +6 -27
- package/src/packlets/identity/identity-service.ts +17 -83
- package/src/packlets/identity/identity.test.ts +7 -7
- package/src/packlets/identity/identity.ts +12 -35
- package/src/packlets/invitations/device-invitation-protocol.ts +10 -9
- 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 +13 -14
- package/src/packlets/invitations/invitation-protocol.ts +7 -4
- package/src/packlets/invitations/invitation-state.ts +1 -15
- package/src/packlets/invitations/invitations-handler.test.ts +4 -5
- package/src/packlets/invitations/invitations-handler.ts +74 -22
- package/src/packlets/invitations/invitations-manager.ts +42 -17
- 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 +13 -18
- 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 +376 -0
- package/src/packlets/services/feed-syncer.ts +536 -0
- package/src/packlets/services/index.ts +1 -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 +218 -80
- package/src/packlets/services/service-host.test.ts +8 -10
- package/src/packlets/services/service-host.ts +104 -65
- package/src/packlets/services/service-registry.test.ts +0 -1
- package/src/packlets/services/sqlite-storage.ts +390 -0
- 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 +129 -0
- package/src/packlets/space-export/serialized-space-writer.ts +260 -0
- package/src/packlets/space-export/space-archive-reader.ts +65 -4
- package/src/packlets/space-export/space-archive-writer.ts +43 -5
- package/src/packlets/space-export/space-archive.test.ts +482 -0
- package/src/packlets/spaces/data-space-manager.test.ts +169 -14
- package/src/packlets/spaces/data-space-manager.ts +209 -128
- package/src/packlets/spaces/data-space.ts +89 -43
- package/src/packlets/spaces/edge-feed-replicator.test.ts +3 -3
- package/src/packlets/spaces/edge-feed-replicator.ts +12 -10
- package/src/packlets/spaces/epoch-migrations.ts +7 -6
- package/src/packlets/spaces/genesis.ts +9 -4
- 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 +131 -25
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/profile-archive-sqlite.test.ts +79 -0
- package/src/packlets/storage/profile-archive-sqlite.ts +100 -0
- package/src/packlets/storage/profile-archive.ts +3 -0
- package/src/packlets/storage/storage.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +10 -6
- package/src/packlets/testing/test-builder.ts +59 -40
- package/src/packlets/worker/worker-runtime.ts +173 -17
- package/src/packlets/worker/worker-session.ts +12 -18
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-6C7MTZLC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YOHACH7G.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
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as SqlClient from '@effect/sql/SqlClient';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
5
8
|
import { Event, synchronized } from '@dxos/async';
|
|
6
9
|
import { type ClientServices, clientServiceBundle } from '@dxos/client-protocol';
|
|
7
|
-
import { type Config } from '@dxos/config';
|
|
10
|
+
import { type Config, resolveTelemetryTag } from '@dxos/config';
|
|
8
11
|
import { Context } from '@dxos/context';
|
|
9
12
|
import { EdgeClient, type EdgeConnection, EdgeHttpClient, createStubEdgeIdentity } from '@dxos/edge-client';
|
|
13
|
+
import { RuntimeProvider } from '@dxos/effect';
|
|
10
14
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import { PublicKey } from '@dxos/keys';
|
|
12
|
-
import { type LevelDB } from '@dxos/kv-store';
|
|
13
15
|
import { log } from '@dxos/log';
|
|
14
16
|
import { EdgeSignalManager, type SignalManager, WebsocketSignalManager } from '@dxos/messaging';
|
|
15
17
|
import {
|
|
@@ -18,10 +20,10 @@ import {
|
|
|
18
20
|
createIceProvider,
|
|
19
21
|
createRtcTransportFactory,
|
|
20
22
|
} from '@dxos/network-manager';
|
|
21
|
-
import { trace } from '@dxos/protocols';
|
|
22
23
|
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
23
|
-
import
|
|
24
|
-
import
|
|
24
|
+
import * as SqlExport from '@dxos/sql-sqlite/SqlExport';
|
|
25
|
+
import type * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
26
|
+
import { trace as Trace } from '@dxos/tracing';
|
|
25
27
|
import { WebsocketRpcClient } from '@dxos/websocket-rpc';
|
|
26
28
|
|
|
27
29
|
import { EdgeAgentServiceImpl } from '../agents';
|
|
@@ -39,13 +41,11 @@ import { Lock, type ResourceLock } from '../locks';
|
|
|
39
41
|
import { LoggingServiceImpl } from '../logging';
|
|
40
42
|
import { NetworkServiceImpl } from '../network';
|
|
41
43
|
import { SpacesServiceImpl } from '../spaces';
|
|
42
|
-
import { createLevel, createStorageObjects } from '../storage';
|
|
43
44
|
import { SystemServiceImpl } from '../system';
|
|
44
|
-
|
|
45
|
-
import { ServiceContext, type ServiceContextRuntimeParams } from './service-context';
|
|
45
|
+
import { ServiceContext, type ServiceContextRuntimeProps } from './service-context';
|
|
46
46
|
import { ServiceRegistry } from './service-registry';
|
|
47
47
|
|
|
48
|
-
export type
|
|
48
|
+
export type ClientServicesHostProps = {
|
|
49
49
|
/**
|
|
50
50
|
* Can be omitted if `initialize` is later called.
|
|
51
51
|
*/
|
|
@@ -53,11 +53,10 @@ export type ClientServicesHostParams = {
|
|
|
53
53
|
transportFactory?: TransportFactory;
|
|
54
54
|
signalManager?: SignalManager;
|
|
55
55
|
connectionLog?: boolean;
|
|
56
|
-
storage?: Storage;
|
|
57
|
-
level?: LevelDB;
|
|
58
56
|
lockKey?: string;
|
|
59
57
|
callbacks?: ClientServicesHostCallbacks;
|
|
60
|
-
|
|
58
|
+
runtime: RuntimeProvider.RuntimeProvider<SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction>;
|
|
59
|
+
runtimeProps?: ServiceContextRuntimeProps;
|
|
61
60
|
};
|
|
62
61
|
|
|
63
62
|
export type ClientServicesHostCallbacks = {
|
|
@@ -80,22 +79,21 @@ export class ClientServicesHost {
|
|
|
80
79
|
private readonly _serviceRegistry: ServiceRegistry<ClientServices>;
|
|
81
80
|
private readonly _systemService: SystemServiceImpl;
|
|
82
81
|
private readonly _loggingService: LoggingServiceImpl;
|
|
83
|
-
private readonly _tracingService = TRACE_PROCESSOR.createTraceSender();
|
|
84
|
-
|
|
85
82
|
private readonly _statusUpdate = new Event<void>();
|
|
86
83
|
|
|
87
84
|
private _config?: Config;
|
|
88
85
|
private _signalManager?: SignalManager;
|
|
89
86
|
private _networkManager?: SwarmNetworkManager;
|
|
90
|
-
private _storage?: Storage;
|
|
91
|
-
private _level?: LevelDB;
|
|
92
87
|
private _callbacks?: ClientServicesHostCallbacks;
|
|
93
88
|
private _devtoolsProxy?: WebsocketRpcClient<{}, ClientServices>;
|
|
94
89
|
private _edgeConnection?: EdgeConnection = undefined;
|
|
95
90
|
private _edgeHttpClient?: EdgeHttpClient = undefined;
|
|
96
91
|
|
|
97
92
|
private _serviceContext!: ServiceContext;
|
|
98
|
-
private readonly
|
|
93
|
+
private readonly _runtime: RuntimeProvider.RuntimeProvider<
|
|
94
|
+
SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction
|
|
95
|
+
>;
|
|
96
|
+
private readonly _runtimeProps: ServiceContextRuntimeProps;
|
|
99
97
|
private diagnosticsBroadcastHandler: CollectDiagnosticsBroadcastHandler;
|
|
100
98
|
|
|
101
99
|
@Trace.info()
|
|
@@ -111,25 +109,15 @@ export class ClientServicesHost {
|
|
|
111
109
|
config,
|
|
112
110
|
transportFactory,
|
|
113
111
|
signalManager,
|
|
114
|
-
storage,
|
|
115
|
-
level,
|
|
116
112
|
// TODO(wittjosiah): Turn this on by default.
|
|
117
113
|
lockKey,
|
|
118
114
|
callbacks,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this._level = level;
|
|
115
|
+
runtime,
|
|
116
|
+
runtimeProps,
|
|
117
|
+
}: ClientServicesHostProps) {
|
|
123
118
|
this._callbacks = callbacks;
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
if (this._runtimeParams.disableP2pReplication === undefined) {
|
|
127
|
-
this._runtimeParams.disableP2pReplication = config?.get('runtime.client.disableP2pReplication', false);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (this._runtimeParams.enableVectorIndexing === undefined) {
|
|
131
|
-
this._runtimeParams.enableVectorIndexing = config?.get('runtime.client.enableVectorIndexing', false);
|
|
132
|
-
}
|
|
119
|
+
this._runtime = runtime;
|
|
120
|
+
this._runtimeProps = runtimeProps ?? {};
|
|
133
121
|
|
|
134
122
|
if (config) {
|
|
135
123
|
this.initialize({ config, transportFactory, signalManager });
|
|
@@ -143,7 +131,7 @@ export class ClientServicesHost {
|
|
|
143
131
|
void this.open(new Context());
|
|
144
132
|
}
|
|
145
133
|
},
|
|
146
|
-
onRelease: () => this.close(),
|
|
134
|
+
onRelease: () => this.close(Context.default()),
|
|
147
135
|
});
|
|
148
136
|
}
|
|
149
137
|
|
|
@@ -172,7 +160,6 @@ export class ClientServicesHost {
|
|
|
172
160
|
|
|
173
161
|
this._serviceRegistry = new ServiceRegistry<ClientServices>(clientServiceBundle, {
|
|
174
162
|
SystemService: this._systemService,
|
|
175
|
-
TracingService: this._tracingService,
|
|
176
163
|
});
|
|
177
164
|
}
|
|
178
165
|
|
|
@@ -200,6 +187,30 @@ export class ClientServicesHost {
|
|
|
200
187
|
return this._serviceRegistry.services;
|
|
201
188
|
}
|
|
202
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Debugging util.
|
|
192
|
+
*/
|
|
193
|
+
async exportSqliteDatabase(): Promise<Uint8Array> {
|
|
194
|
+
return await RuntimeProvider.runPromise(this._runtime)(
|
|
195
|
+
Effect.gen(function* () {
|
|
196
|
+
const sql = yield* SqlExport.SqlExport;
|
|
197
|
+
return yield* sql.export;
|
|
198
|
+
}),
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Debugging util.
|
|
204
|
+
*/
|
|
205
|
+
async runSqliteQuery(query: string, params?: unknown[]): Promise<readonly Record<string, unknown>[]> {
|
|
206
|
+
return await RuntimeProvider.runPromise(this._runtime)(
|
|
207
|
+
Effect.gen(function* () {
|
|
208
|
+
const sql = yield* SqlClient.SqlClient;
|
|
209
|
+
return yield* sql`${sql.unsafe(query, params)}`;
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
203
214
|
/**
|
|
204
215
|
* Initialize the service host with the config.
|
|
205
216
|
* Config can also be provided in the constructor.
|
|
@@ -210,21 +221,27 @@ export class ClientServicesHost {
|
|
|
210
221
|
log('initializing...');
|
|
211
222
|
|
|
212
223
|
if (config) {
|
|
224
|
+
if (this._runtimeProps.disableP2pReplication === undefined) {
|
|
225
|
+
this._runtimeProps.disableP2pReplication = config?.get('runtime.client.disableP2pReplication', false);
|
|
226
|
+
}
|
|
227
|
+
if (this._runtimeProps.enableVectorIndexing === undefined) {
|
|
228
|
+
this._runtimeProps.enableVectorIndexing = config?.get('runtime.client.enableVectorIndexing', false);
|
|
229
|
+
}
|
|
230
|
+
|
|
213
231
|
invariant(!this._config, 'config already set');
|
|
214
232
|
this._config = config;
|
|
215
|
-
if (!this._storage) {
|
|
216
|
-
this._storage = createStorageObjects(config.get('runtime.client.storage', {})!).storage;
|
|
217
|
-
}
|
|
218
233
|
}
|
|
219
234
|
|
|
235
|
+
// TODO(wittjosiah): This is quite noisy during tests. Make configurable? Remove?
|
|
220
236
|
if (!options.signalManager) {
|
|
221
|
-
log.warn('running signaling without telemetry metadata.');
|
|
237
|
+
// log.warn('running signaling without telemetry metadata.');
|
|
222
238
|
}
|
|
223
239
|
|
|
224
240
|
const endpoint = config?.get('runtime.services.edge.url');
|
|
225
241
|
if (endpoint) {
|
|
226
|
-
|
|
227
|
-
this.
|
|
242
|
+
const clientTag = resolveTelemetryTag(config);
|
|
243
|
+
this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), { socketEndpoint: endpoint, clientTag });
|
|
244
|
+
this._edgeHttpClient = new EdgeHttpClient(endpoint, { clientTag });
|
|
228
245
|
}
|
|
229
246
|
|
|
230
247
|
const {
|
|
@@ -263,11 +280,9 @@ export class ClientServicesHost {
|
|
|
263
280
|
return;
|
|
264
281
|
}
|
|
265
282
|
|
|
266
|
-
|
|
267
|
-
log.trace('dxos.client-services.host.open', trace.begin({ id: traceId }));
|
|
283
|
+
log('opening service host');
|
|
268
284
|
|
|
269
285
|
invariant(this._config, 'config not set');
|
|
270
|
-
invariant(this._storage, 'storage not set');
|
|
271
286
|
invariant(this._signalManager, 'signal manager not set');
|
|
272
287
|
invariant(this._networkManager, 'network manager not set');
|
|
273
288
|
|
|
@@ -276,21 +291,15 @@ export class ClientServicesHost {
|
|
|
276
291
|
|
|
277
292
|
await this._resourceLock?.acquire();
|
|
278
293
|
|
|
279
|
-
if (!this._level) {
|
|
280
|
-
this._level = await createLevel(this._config.get('runtime.client.storage', {})!);
|
|
281
|
-
}
|
|
282
|
-
await this._level.open();
|
|
283
|
-
|
|
284
294
|
await this._loggingService.open();
|
|
285
295
|
|
|
286
296
|
this._serviceContext = new ServiceContext(
|
|
287
|
-
this._storage,
|
|
288
|
-
this._level,
|
|
289
297
|
this._networkManager,
|
|
290
298
|
this._signalManager,
|
|
291
299
|
this._edgeConnection,
|
|
292
300
|
this._edgeHttpClient,
|
|
293
|
-
this.
|
|
301
|
+
this._runtime,
|
|
302
|
+
this._runtimeProps,
|
|
294
303
|
this._config.get('runtime.client.edgeFeatures'),
|
|
295
304
|
);
|
|
296
305
|
|
|
@@ -308,8 +317,7 @@ export class ClientServicesHost {
|
|
|
308
317
|
this._serviceContext.identityManager,
|
|
309
318
|
this._serviceContext.recoveryManager,
|
|
310
319
|
this._serviceContext.keyring,
|
|
311
|
-
() => this.
|
|
312
|
-
(params) => this._createIdentity(params),
|
|
320
|
+
(params, ctx) => this._createIdentity(params, ctx),
|
|
313
321
|
(profile) => this._serviceContext.broadcastProfileUpdate(profile),
|
|
314
322
|
);
|
|
315
323
|
|
|
@@ -329,11 +337,13 @@ export class ClientServicesHost {
|
|
|
329
337
|
SpacesService: new SpacesServiceImpl(
|
|
330
338
|
this._serviceContext.identityManager,
|
|
331
339
|
this._serviceContext.spaceManager,
|
|
340
|
+
this._serviceContext.echoHost,
|
|
332
341
|
dataSpaceManagerProvider,
|
|
333
342
|
),
|
|
334
343
|
|
|
335
344
|
DataService: this._serviceContext.echoHost.dataService,
|
|
336
345
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
346
|
+
QueueService: this._serviceContext.echoHost.queuesService,
|
|
337
347
|
|
|
338
348
|
NetworkService: new NetworkServiceImpl(
|
|
339
349
|
this._serviceContext.networkManager,
|
|
@@ -342,20 +352,26 @@ export class ClientServicesHost {
|
|
|
342
352
|
),
|
|
343
353
|
|
|
344
354
|
LoggingService: this._loggingService,
|
|
345
|
-
TracingService: this._tracingService,
|
|
346
355
|
|
|
347
356
|
// TODO(burdon): Move to new protobuf definitions.
|
|
348
357
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
349
358
|
events: new DevtoolsHostEvents(),
|
|
350
359
|
config: this._config,
|
|
351
360
|
context: this._serviceContext,
|
|
361
|
+
exportSqliteDatabase: () => this.exportSqliteDatabase(),
|
|
362
|
+
runSqliteQuery: (query, params) => this.runSqliteQuery(query, params),
|
|
352
363
|
}),
|
|
353
364
|
|
|
354
365
|
EdgeAgentService: new EdgeAgentServiceImpl(agentManagerProvider, this._edgeConnection),
|
|
355
366
|
});
|
|
356
367
|
|
|
368
|
+
log('service-host: opening service context...');
|
|
357
369
|
await this._serviceContext.open(ctx);
|
|
370
|
+
log('service-host: service context opened');
|
|
371
|
+
|
|
372
|
+
log('service-host: opening identity service...');
|
|
358
373
|
await identityService.open();
|
|
374
|
+
log('service-host: identity service opened');
|
|
359
375
|
|
|
360
376
|
const devtoolsProxy = this._config?.get('runtime.client.devtoolsProxy');
|
|
361
377
|
if (devtoolsProxy) {
|
|
@@ -374,12 +390,11 @@ export class ClientServicesHost {
|
|
|
374
390
|
this._statusUpdate.emit();
|
|
375
391
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
376
392
|
log('opened', { deviceKey });
|
|
377
|
-
log.trace('dxos.client-services.host.open', trace.end({ id: traceId }));
|
|
378
393
|
}
|
|
379
394
|
|
|
380
395
|
@synchronized
|
|
381
396
|
@Trace.span()
|
|
382
|
-
async close(): Promise<void> {
|
|
397
|
+
async close(ctx: Context): Promise<void> {
|
|
383
398
|
if (!this._open) {
|
|
384
399
|
return;
|
|
385
400
|
}
|
|
@@ -391,30 +406,54 @@ export class ClientServicesHost {
|
|
|
391
406
|
this._serviceRegistry.setServices({ SystemService: this._systemService });
|
|
392
407
|
await this._loggingService.close();
|
|
393
408
|
await this._serviceContext.close();
|
|
394
|
-
await this._level?.close();
|
|
395
409
|
this._open = false;
|
|
396
410
|
this._statusUpdate.emit();
|
|
397
411
|
log('closed', { deviceKey });
|
|
398
412
|
}
|
|
399
413
|
|
|
400
414
|
async reset(): Promise<void> {
|
|
401
|
-
const traceId = PublicKey.random().toHex();
|
|
402
|
-
log.trace('dxos.sdk.client-services-host.reset', trace.begin({ id: traceId }));
|
|
403
|
-
|
|
404
415
|
log.info('resetting...');
|
|
405
416
|
// Emit this status update immediately so app returns to fallback.
|
|
406
417
|
// This state is never cleared because the app reloads.
|
|
407
418
|
this._resetting = true;
|
|
408
419
|
this._statusUpdate.emit();
|
|
409
420
|
await this._serviceContext?.close();
|
|
410
|
-
|
|
421
|
+
// Wipe all SQLite tables so next open starts fresh.
|
|
422
|
+
await RuntimeProvider.runPromise(this._runtime)(
|
|
423
|
+
Effect.gen(function* () {
|
|
424
|
+
const sql = yield* SqlClient.SqlClient;
|
|
425
|
+
// Echo metadata + large space data.
|
|
426
|
+
yield* sql`DELETE FROM space_metadata`;
|
|
427
|
+
yield* sql`DELETE FROM space_large`;
|
|
428
|
+
// Blob store.
|
|
429
|
+
yield* sql`DELETE FROM blobs_meta`;
|
|
430
|
+
yield* sql`DELETE FROM blobs_data`;
|
|
431
|
+
// Keyring.
|
|
432
|
+
yield* sql`DELETE FROM keyring`;
|
|
433
|
+
// Automerge chunks + heads.
|
|
434
|
+
yield* sql`DELETE FROM automerge_chunks`;
|
|
435
|
+
yield* sql`DELETE FROM automerge_heads`;
|
|
436
|
+
// Hypercore feed files.
|
|
437
|
+
yield* sql`DELETE FROM hypercore_files`;
|
|
438
|
+
// Feed store (queue feeds, blocks, etc.).
|
|
439
|
+
yield* sql`DELETE FROM feeds`;
|
|
440
|
+
yield* sql`DELETE FROM blocks`;
|
|
441
|
+
yield* sql`DELETE FROM subscriptions`;
|
|
442
|
+
yield* sql`DELETE FROM cursor_tokens`;
|
|
443
|
+
yield* sql`DELETE FROM sync_state`;
|
|
444
|
+
// Index tables.
|
|
445
|
+
yield* sql`DELETE FROM indexCursor`;
|
|
446
|
+
yield* sql`DELETE FROM objectMeta`;
|
|
447
|
+
yield* sql`DELETE FROM reverseRef`;
|
|
448
|
+
yield* sql`DELETE FROM ftsIndex`;
|
|
449
|
+
}),
|
|
450
|
+
);
|
|
411
451
|
log.info('reset');
|
|
412
|
-
log.trace('dxos.sdk.client-services-host.reset', trace.end({ id: traceId }));
|
|
413
452
|
await this._callbacks?.onReset?.();
|
|
414
453
|
}
|
|
415
454
|
|
|
416
|
-
private async _createIdentity(params: CreateIdentityOptions) {
|
|
417
|
-
const identity = await this._serviceContext.createIdentity(params);
|
|
455
|
+
private async _createIdentity(params: CreateIdentityOptions, ctx?: Context) {
|
|
456
|
+
const identity = await this._serviceContext.createIdentity(params, ctx);
|
|
418
457
|
await this._serviceContext.initialized.wait();
|
|
419
458
|
return identity;
|
|
420
459
|
}
|
|
@@ -15,7 +15,6 @@ import { createLinkedPorts, createProtoRpcPeer, createServiceBundle } from '@dxo
|
|
|
15
15
|
|
|
16
16
|
import { SystemServiceImpl } from '../system';
|
|
17
17
|
import { createServiceContext } from '../testing';
|
|
18
|
-
|
|
19
18
|
import { ServiceRegistry } from './service-registry';
|
|
20
19
|
|
|
21
20
|
// TODO(burdon): Create TestService (that doesn't require peers).
|