@hydranium/data-server 1.0.0-next.31 → 1.0.0-next.315
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/README.md +57 -73
- package/lib/browser/index.d.ts +10 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +15 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/start-data-server-in-worker.d.ts +23 -0
- package/lib/browser/start-data-server-in-worker.d.ts.map +1 -0
- package/lib/browser/start-data-server-in-worker.js +29 -0
- package/lib/browser/start-data-server-in-worker.js.map +1 -0
- package/lib/data-server.d.ts +444 -290
- package/lib/data-server.d.ts.map +1 -1
- package/lib/data-server.js +752 -506
- package/lib/data-server.js.map +1 -1
- package/lib/messages/index.d.ts +1 -1
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +1 -1
- package/lib/messages/index.js.map +1 -1
- package/lib/node/node-diagnostics-provider.d.ts.map +1 -1
- package/lib/node/node-diagnostics-provider.js +2 -1
- package/lib/node/node-diagnostics-provider.js.map +1 -1
- package/lib/testing/data-server-harness.d.ts +31 -14
- package/lib/testing/data-server-harness.d.ts.map +1 -1
- package/lib/testing/data-server-harness.js +8 -3
- package/lib/testing/data-server-harness.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js.map +1 -1
- package/package.json +35 -43
- package/src/browser/index.ts +15 -0
- package/src/browser/start-data-server-in-worker.ts +35 -0
- package/src/data-server.ts +908 -545
- package/src/messages/index.ts +8 -1
- package/src/node/node-diagnostics-provider.ts +2 -8
- package/src/testing/data-server-harness.ts +55 -26
- package/src/testing/index.ts +5 -2
package/src/messages/index.ts
CHANGED
|
@@ -16,4 +16,11 @@
|
|
|
16
16
|
* code is the contract, and renaming one is a breaking change.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export {
|
|
20
|
+
NO_ACTIVE_PROFILE,
|
|
21
|
+
NO_ACTIVE_PROFILE_CODE,
|
|
22
|
+
noActiveProfileError,
|
|
23
|
+
REFERENCE_SETTLE_TIMEOUT,
|
|
24
|
+
REFERENCE_SETTLE_TIMEOUT_CODE,
|
|
25
|
+
referenceSettleTimeoutError
|
|
26
|
+
} from '../data-server.js';
|
|
@@ -8,14 +8,8 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import type { ServerSharedServices } from '@hydranium/core';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
formatProfileReport,
|
|
14
|
-
formatServerState,
|
|
15
|
-
ProfileCapture,
|
|
16
|
-
recordServerSummaryEntry,
|
|
17
|
-
writeHeapSnapshotToDir
|
|
18
|
-
} from '@hydranium/core/node';
|
|
11
|
+
import { formatProfileReport, formatServerState, ProfileCapture, recordServerSummaryEntry } from '@hydranium/core/node';
|
|
12
|
+
import { formatPodMemory, writeHeapSnapshotToDir } from '@hydranium/protocol/node';
|
|
19
13
|
import type { DumpServerStateArgs, StartProfilingArgs, StopProfilingArgs, WriteServerHeapSnapshotArgs } from '@hydranium/protocol';
|
|
20
14
|
import type { DataServerDiagnosticsProvider, DataServerProfileCapture } from '../diagnostics-provider.js';
|
|
21
15
|
|
|
@@ -14,10 +14,13 @@ import {
|
|
|
14
14
|
type DataClientProtocol,
|
|
15
15
|
type DataServerProtocol,
|
|
16
16
|
type ProjectsChangedEvent,
|
|
17
|
+
type TransferDocumentDeletedEvent,
|
|
18
|
+
type TransferDocumentDirtyChangedEvent,
|
|
17
19
|
type TransferDocumentSavedEvent,
|
|
20
|
+
type TransferDocumentsBuiltEvent,
|
|
18
21
|
type TransferDocumentUpdatedEvent
|
|
19
22
|
} from '@hydranium/protocol/data';
|
|
20
|
-
import { type Harness, makeCapturingDataClient } from '@hydranium/protocol/testing';
|
|
23
|
+
import { type AdditionalClientMethod, type Harness, makeCapturingDataClient } from '@hydranium/protocol/testing';
|
|
21
24
|
import { makeDuplexConnectionPair, type DuplexConnectionPair } from '@hydranium/protocol/testing/node';
|
|
22
25
|
import type { MessageConnection } from 'vscode-jsonrpc/node';
|
|
23
26
|
|
|
@@ -29,16 +32,17 @@ import type { MessageConnection } from 'vscode-jsonrpc/node';
|
|
|
29
32
|
* (the "server side" of the duplex pair). The factory is invoked once,
|
|
30
33
|
* synchronously, after the pair is wired.
|
|
31
34
|
*
|
|
32
|
-
* `client` lets tests override individual handlers on the captured
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
35
|
+
* `client` lets tests override individual handlers on the captured client.
|
|
36
|
+
* Unspecified handlers default to pushing incoming events into the
|
|
37
|
+
* {@link DataServerHarness} bundle's `events` / `saves` / `projectsChanges`
|
|
38
|
+
* arrays — the typical assertion target.
|
|
36
39
|
*/
|
|
37
40
|
export interface MakeDataServerHarnessOptions<
|
|
38
41
|
TServer,
|
|
39
42
|
TTransfer extends TransferElement,
|
|
40
43
|
TDiagnostic extends TransferDiagnostic = TransferDiagnostic,
|
|
41
|
-
TProject extends Project = Project
|
|
44
|
+
TProject extends Project = Project,
|
|
45
|
+
TClient extends DataClientProtocol<TTransfer, TDiagnostic, TProject> = DataClientProtocol<TTransfer, TDiagnostic, TProject>
|
|
42
46
|
> {
|
|
43
47
|
/**
|
|
44
48
|
* Construct the `DataServer` (or subclass) under test against
|
|
@@ -47,12 +51,19 @@ export interface MakeDataServerHarnessOptions<
|
|
|
47
51
|
*/
|
|
48
52
|
server: (channel: MessageConnection) => TServer;
|
|
49
53
|
/**
|
|
50
|
-
* Override per-method handlers on the captured
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
+
* Override per-method handlers on the captured client. An additional
|
|
55
|
+
* method's override needs the method in `additionalClientMethods`, or the
|
|
56
|
+
* harness throws. Each overridden handler REPLACES the default (which
|
|
57
|
+
* pushes into the bundle's capture arrays); test code wanting to BOTH
|
|
58
|
+
* capture AND react should push to the array manually inside the override.
|
|
54
59
|
*/
|
|
55
|
-
client?: Partial<
|
|
60
|
+
client?: Partial<TClient>;
|
|
61
|
+
/**
|
|
62
|
+
* Notification methods `TClient` adds to {@link DataClientProtocol}. Each is
|
|
63
|
+
* bound and captured into `additionalNotifications`; one left out reaches no
|
|
64
|
+
* handler.
|
|
65
|
+
*/
|
|
66
|
+
additionalClientMethods?: readonly AdditionalClientMethod<TClient>[];
|
|
56
67
|
/**
|
|
57
68
|
* Wire namespace the proxy addresses the server under. Defaults to
|
|
58
69
|
* {@link DATA_SERVER_WIRE_PREFIX}. Override when the `DataServer`
|
|
@@ -78,7 +89,8 @@ export interface DataServerHarness<
|
|
|
78
89
|
TServer,
|
|
79
90
|
TTransfer extends TransferElement,
|
|
80
91
|
TDiagnostic extends TransferDiagnostic = TransferDiagnostic,
|
|
81
|
-
TProject extends Project = Project
|
|
92
|
+
TProject extends Project = Project,
|
|
93
|
+
TClient extends DataClientProtocol<TTransfer, TDiagnostic, TProject> = DataClientProtocol<TTransfer, TDiagnostic, TProject>
|
|
82
94
|
> extends Harness {
|
|
83
95
|
readonly server: TServer;
|
|
84
96
|
readonly proxy: DataServerProtocol<TTransfer, TDiagnostic, TProject>;
|
|
@@ -87,8 +99,18 @@ export interface DataServerHarness<
|
|
|
87
99
|
readonly events: ReadonlyArray<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
|
|
88
100
|
/** Captured `onDocumentSaved` events. */
|
|
89
101
|
readonly saves: ReadonlyArray<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
|
|
102
|
+
/** Captured `onDocumentDirtyChanged` events. */
|
|
103
|
+
readonly dirtyChanges: ReadonlyArray<TransferDocumentDirtyChangedEvent>;
|
|
104
|
+
/** Captured `onDocumentDeleted` events. */
|
|
105
|
+
readonly deletions: ReadonlyArray<TransferDocumentDeletedEvent>;
|
|
106
|
+
/** Captured `onDocumentsBuilt` events, one per build that had unwatched documents. */
|
|
107
|
+
readonly builds: ReadonlyArray<TransferDocumentsBuiltEvent>;
|
|
90
108
|
/** Captured `onProjectsChanged` events. */
|
|
91
109
|
readonly projectsChanges: ReadonlyArray<ProjectsChangedEvent<TProject>>;
|
|
110
|
+
/** Captured events of each `additionalClientMethods` entry, keyed by method. */
|
|
111
|
+
readonly additionalNotifications: {
|
|
112
|
+
readonly [K in AdditionalClientMethod<TClient>]: TClient[K] extends (event: infer TEvent) => void ? ReadonlyArray<TEvent> : never;
|
|
113
|
+
};
|
|
92
114
|
/** Dispose the underlying duplex pair. Idempotent. */
|
|
93
115
|
dispose(): void;
|
|
94
116
|
}
|
|
@@ -107,15 +129,17 @@ export function makeDataServerHarness<
|
|
|
107
129
|
TServer,
|
|
108
130
|
TTransfer extends TransferElement,
|
|
109
131
|
TDiagnostic extends TransferDiagnostic = TransferDiagnostic,
|
|
110
|
-
TProject extends Project = Project
|
|
132
|
+
TProject extends Project = Project,
|
|
133
|
+
TClient extends DataClientProtocol<TTransfer, TDiagnostic, TProject> = DataClientProtocol<TTransfer, TDiagnostic, TProject>
|
|
111
134
|
>(
|
|
112
|
-
options: MakeDataServerHarnessOptions<TServer, TTransfer, TDiagnostic, TProject>
|
|
113
|
-
): DataServerHarness<TServer, TTransfer, TDiagnostic, TProject> {
|
|
135
|
+
options: MakeDataServerHarnessOptions<TServer, TTransfer, TDiagnostic, TProject, TClient>
|
|
136
|
+
): DataServerHarness<TServer, TTransfer, TDiagnostic, TProject, TClient> {
|
|
114
137
|
const pair = makeDuplexConnectionPair();
|
|
115
138
|
const server = options.server(pair.left);
|
|
139
|
+
const additionalClientMethods = options.additionalClientMethods ?? [];
|
|
116
140
|
|
|
117
141
|
// The capture half is the shared client double, not a local copy: the same
|
|
118
|
-
// recording semantics (
|
|
142
|
+
// recording semantics (every channel, an override replacing rather than
|
|
119
143
|
// supplementing) then hold for a client-side suite that stands the double up
|
|
120
144
|
// without a server, so an assertion learnt against one reads the same in the
|
|
121
145
|
// other.
|
|
@@ -123,17 +147,18 @@ export function makeDataServerHarness<
|
|
|
123
147
|
client: localClient,
|
|
124
148
|
updates: events,
|
|
125
149
|
saves,
|
|
126
|
-
|
|
127
|
-
|
|
150
|
+
dirtyChanges,
|
|
151
|
+
deletions,
|
|
152
|
+
builds,
|
|
153
|
+
projectsChanges,
|
|
154
|
+
additionalNotifications
|
|
155
|
+
} = makeCapturingDataClient<TTransfer, TDiagnostic, TProject, TClient>(options.client, additionalClientMethods);
|
|
128
156
|
|
|
129
|
-
const proxy = createRpcProxy<DataServerProtocol<TTransfer, TDiagnostic, TProject>,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
localMethods: DATA_CLIENT_PROTOCOL_METHODS
|
|
135
|
-
}
|
|
136
|
-
);
|
|
157
|
+
const proxy = createRpcProxy<DataServerProtocol<TTransfer, TDiagnostic, TProject>, TClient>(pair.right, {
|
|
158
|
+
methodNamespace: options.methodNamespace ?? DATA_SERVER_WIRE_PREFIX,
|
|
159
|
+
localTarget: localClient,
|
|
160
|
+
localMethods: [...DATA_CLIENT_PROTOCOL_METHODS, ...additionalClientMethods]
|
|
161
|
+
});
|
|
137
162
|
|
|
138
163
|
return {
|
|
139
164
|
server,
|
|
@@ -141,7 +166,11 @@ export function makeDataServerHarness<
|
|
|
141
166
|
pair,
|
|
142
167
|
events,
|
|
143
168
|
saves,
|
|
169
|
+
dirtyChanges,
|
|
170
|
+
deletions,
|
|
171
|
+
builds,
|
|
144
172
|
projectsChanges,
|
|
173
|
+
additionalNotifications,
|
|
145
174
|
dispose: () => pair.dispose()
|
|
146
175
|
};
|
|
147
176
|
}
|
package/src/testing/index.ts
CHANGED
|
@@ -12,8 +12,11 @@
|
|
|
12
12
|
// real wire. The duplex `MessageConnection` pair lives in
|
|
13
13
|
// `@hydranium/protocol/testing`, which owns the transport; only its TYPE is
|
|
14
14
|
// re-exported here, because `DataServerHarness.pair` names it in a public
|
|
15
|
-
// signature
|
|
16
|
-
//
|
|
15
|
+
// signature; `AdditionalClientMethod` is re-exported for the same reason, as
|
|
16
|
+
// the harness options name it. A test that wires its own server rather than
|
|
17
|
+
// using the harness calls `makeDuplexConnectionPair` from
|
|
18
|
+
// `@hydranium/protocol/testing` directly.
|
|
17
19
|
|
|
20
|
+
export type { AdditionalClientMethod } from '@hydranium/protocol/testing';
|
|
18
21
|
export type { DuplexConnectionPair } from '@hydranium/protocol/testing/node';
|
|
19
22
|
export * from './data-server-harness.js';
|