@dxos/client-services 0.8.4-main.fffef41 → 0.9.0
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-I2RGLVJF.mjs → chunk-37BKOM5O.mjs} +2870 -3767
- package/dist/lib/browser/chunk-37BKOM5O.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 +58 -53
- 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-QTUURCR4.mjs → chunk-2ONS4DLO.mjs} +2810 -3576
- package/dist/lib/node-esm/chunk-2ONS4DLO.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/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 +58 -53
- 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 +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 +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 +3 -3
- 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 +19 -15
- 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 +215 -78
- package/src/packlets/services/service-host.test.ts +8 -10
- package/src/packlets/services/service-host.ts +102 -70
- 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 +64 -3
- package/src/packlets/space-export/space-archive-writer.ts +41 -4
- 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 +192 -127
- package/src/packlets/spaces/data-space.ts +89 -43
- package/src/packlets/spaces/edge-feed-replicator.test.ts +2 -2
- package/src/packlets/spaces/edge-feed-replicator.ts +11 -9
- 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 +130 -24
- 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 +5 -1
- package/dist/lib/browser/chunk-I2RGLVJF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QTUURCR4.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,11 +221,15 @@ 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
|
|
|
220
235
|
// TODO(wittjosiah): This is quite noisy during tests. Make configurable? Remove?
|
|
@@ -224,8 +239,9 @@ export class ClientServicesHost {
|
|
|
224
239
|
|
|
225
240
|
const endpoint = config?.get('runtime.services.edge.url');
|
|
226
241
|
if (endpoint) {
|
|
227
|
-
|
|
228
|
-
this.
|
|
242
|
+
const clientTag = resolveTelemetryTag(config);
|
|
243
|
+
this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), { socketEndpoint: endpoint, clientTag });
|
|
244
|
+
this._edgeHttpClient = new EdgeHttpClient(endpoint, { clientTag });
|
|
229
245
|
}
|
|
230
246
|
|
|
231
247
|
const {
|
|
@@ -264,11 +280,9 @@ export class ClientServicesHost {
|
|
|
264
280
|
return;
|
|
265
281
|
}
|
|
266
282
|
|
|
267
|
-
|
|
268
|
-
log.trace('dxos.client-services.host.open', trace.begin({ id: traceId }));
|
|
283
|
+
log('opening service host');
|
|
269
284
|
|
|
270
285
|
invariant(this._config, 'config not set');
|
|
271
|
-
invariant(this._storage, 'storage not set');
|
|
272
286
|
invariant(this._signalManager, 'signal manager not set');
|
|
273
287
|
invariant(this._networkManager, 'network manager not set');
|
|
274
288
|
|
|
@@ -277,21 +291,15 @@ export class ClientServicesHost {
|
|
|
277
291
|
|
|
278
292
|
await this._resourceLock?.acquire();
|
|
279
293
|
|
|
280
|
-
if (!this._level) {
|
|
281
|
-
this._level = await createLevel(this._config.get('runtime.client.storage', {})!);
|
|
282
|
-
}
|
|
283
|
-
await this._level.open();
|
|
284
|
-
|
|
285
294
|
await this._loggingService.open();
|
|
286
295
|
|
|
287
296
|
this._serviceContext = new ServiceContext(
|
|
288
|
-
this._storage,
|
|
289
|
-
this._level,
|
|
290
297
|
this._networkManager,
|
|
291
298
|
this._signalManager,
|
|
292
299
|
this._edgeConnection,
|
|
293
300
|
this._edgeHttpClient,
|
|
294
|
-
this.
|
|
301
|
+
this._runtime,
|
|
302
|
+
this._runtimeProps,
|
|
295
303
|
this._config.get('runtime.client.edgeFeatures'),
|
|
296
304
|
);
|
|
297
305
|
|
|
@@ -309,8 +317,7 @@ export class ClientServicesHost {
|
|
|
309
317
|
this._serviceContext.identityManager,
|
|
310
318
|
this._serviceContext.recoveryManager,
|
|
311
319
|
this._serviceContext.keyring,
|
|
312
|
-
() => this.
|
|
313
|
-
(params) => this._createIdentity(params),
|
|
320
|
+
(params, ctx) => this._createIdentity(params, ctx),
|
|
314
321
|
(profile) => this._serviceContext.broadcastProfileUpdate(profile),
|
|
315
322
|
);
|
|
316
323
|
|
|
@@ -330,11 +337,13 @@ export class ClientServicesHost {
|
|
|
330
337
|
SpacesService: new SpacesServiceImpl(
|
|
331
338
|
this._serviceContext.identityManager,
|
|
332
339
|
this._serviceContext.spaceManager,
|
|
340
|
+
this._serviceContext.echoHost,
|
|
333
341
|
dataSpaceManagerProvider,
|
|
334
342
|
),
|
|
335
343
|
|
|
336
344
|
DataService: this._serviceContext.echoHost.dataService,
|
|
337
345
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
346
|
+
QueueService: this._serviceContext.echoHost.queuesService,
|
|
338
347
|
|
|
339
348
|
NetworkService: new NetworkServiceImpl(
|
|
340
349
|
this._serviceContext.networkManager,
|
|
@@ -343,20 +352,26 @@ export class ClientServicesHost {
|
|
|
343
352
|
),
|
|
344
353
|
|
|
345
354
|
LoggingService: this._loggingService,
|
|
346
|
-
TracingService: this._tracingService,
|
|
347
355
|
|
|
348
356
|
// TODO(burdon): Move to new protobuf definitions.
|
|
349
357
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
350
358
|
events: new DevtoolsHostEvents(),
|
|
351
359
|
config: this._config,
|
|
352
360
|
context: this._serviceContext,
|
|
361
|
+
exportSqliteDatabase: () => this.exportSqliteDatabase(),
|
|
362
|
+
runSqliteQuery: (query, params) => this.runSqliteQuery(query, params),
|
|
353
363
|
}),
|
|
354
364
|
|
|
355
365
|
EdgeAgentService: new EdgeAgentServiceImpl(agentManagerProvider, this._edgeConnection),
|
|
356
366
|
});
|
|
357
367
|
|
|
368
|
+
log('service-host: opening service context...');
|
|
358
369
|
await this._serviceContext.open(ctx);
|
|
370
|
+
log('service-host: service context opened');
|
|
371
|
+
|
|
372
|
+
log('service-host: opening identity service...');
|
|
359
373
|
await identityService.open();
|
|
374
|
+
log('service-host: identity service opened');
|
|
360
375
|
|
|
361
376
|
const devtoolsProxy = this._config?.get('runtime.client.devtoolsProxy');
|
|
362
377
|
if (devtoolsProxy) {
|
|
@@ -375,12 +390,11 @@ export class ClientServicesHost {
|
|
|
375
390
|
this._statusUpdate.emit();
|
|
376
391
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
377
392
|
log('opened', { deviceKey });
|
|
378
|
-
log.trace('dxos.client-services.host.open', trace.end({ id: traceId }));
|
|
379
393
|
}
|
|
380
394
|
|
|
381
395
|
@synchronized
|
|
382
396
|
@Trace.span()
|
|
383
|
-
async close(): Promise<void> {
|
|
397
|
+
async close(ctx: Context): Promise<void> {
|
|
384
398
|
if (!this._open) {
|
|
385
399
|
return;
|
|
386
400
|
}
|
|
@@ -392,36 +406,54 @@ export class ClientServicesHost {
|
|
|
392
406
|
this._serviceRegistry.setServices({ SystemService: this._systemService });
|
|
393
407
|
await this._loggingService.close();
|
|
394
408
|
await this._serviceContext.close();
|
|
395
|
-
await this._level?.close();
|
|
396
409
|
this._open = false;
|
|
397
410
|
this._statusUpdate.emit();
|
|
398
411
|
log('closed', { deviceKey });
|
|
399
412
|
}
|
|
400
413
|
|
|
401
414
|
async reset(): Promise<void> {
|
|
402
|
-
const traceId = PublicKey.random().toHex();
|
|
403
|
-
log.trace('dxos.sdk.client-services-host.reset', trace.begin({ id: traceId }));
|
|
404
|
-
|
|
405
415
|
log.info('resetting...');
|
|
406
416
|
// Emit this status update immediately so app returns to fallback.
|
|
407
417
|
// This state is never cleared because the app reloads.
|
|
408
418
|
this._resetting = true;
|
|
409
419
|
this._statusUpdate.emit();
|
|
410
420
|
await this._serviceContext?.close();
|
|
411
|
-
//
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
+
);
|
|
418
451
|
log.info('reset');
|
|
419
|
-
log.trace('dxos.sdk.client-services-host.reset', trace.end({ id: traceId }));
|
|
420
452
|
await this._callbacks?.onReset?.();
|
|
421
453
|
}
|
|
422
454
|
|
|
423
|
-
private async _createIdentity(params: CreateIdentityOptions) {
|
|
424
|
-
const identity = await this._serviceContext.createIdentity(params);
|
|
455
|
+
private async _createIdentity(params: CreateIdentityOptions, ctx?: Context) {
|
|
456
|
+
const identity = await this._serviceContext.createIdentity(params, ctx);
|
|
425
457
|
await this._serviceContext.initialized.wait();
|
|
426
458
|
return identity;
|
|
427
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).
|