@hydranium/protocol 1.0.0-next.37 → 1.0.0-next.39
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/lib/client/data-events.d.ts +9 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +14 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/data/data-protocol-methods.d.ts +2 -2
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +6 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +21 -1
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +70 -3
- package/lib/data/events.d.ts.map +1 -1
- package/lib/errors.d.ts +15 -6
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +20 -10
- package/lib/errors.js.map +1 -1
- package/lib/model-server.d.ts +2 -2
- package/lib/model-server.d.ts.map +1 -1
- package/lib/testing/data-doubles.d.ts +6 -2
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +12 -2
- package/lib/testing/data-doubles.js.map +1 -1
- package/package.json +1 -1
- package/src/client/data-events.ts +24 -1
- package/src/data/data-protocol-methods.ts +6 -3
- package/src/data/data-server-protocol.ts +29 -1
- package/src/data/events.ts +74 -3
- package/src/errors.ts +22 -12
- package/src/model-server.ts +2 -2
- package/src/testing/data-doubles.ts +25 -3
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { Emitter, type Event } from 'vscode-jsonrpc';
|
|
10
|
-
import type { DataClientProtocol, ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from '../data';
|
|
10
|
+
import type { DataClientProtocol, ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from '../data';
|
|
11
11
|
import type { Project } from '../project';
|
|
12
12
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
13
13
|
import type { TransferElement } from '../transfer-element';
|
|
@@ -34,15 +34,23 @@ import type { TransferElement } from '../transfer-element';
|
|
|
34
34
|
export declare class DataEvents<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> implements DataClientProtocol<TTransfer, TDiagnostic, TProject> {
|
|
35
35
|
protected readonly documentUpdatedEmitter: Emitter<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
|
|
36
36
|
protected readonly documentSavedEmitter: Emitter<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
|
|
37
|
+
protected readonly documentDeletedEmitter: Emitter<TransferDocumentDeletedEvent>;
|
|
38
|
+
protected readonly documentsBuiltEmitter: Emitter<TransferDocumentsBuiltEvent>;
|
|
37
39
|
protected readonly projectsChangedEmitter: Emitter<ProjectsChangedEvent<TProject>>;
|
|
38
40
|
/** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
|
|
39
41
|
readonly onDidUpdateDocument: Event<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
|
|
40
42
|
/** A watched document was persisted to disk. */
|
|
41
43
|
readonly onDidSaveDocument: Event<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
|
|
44
|
+
/** A document's backing file was removed, watched or not. Any watch survives. */
|
|
45
|
+
readonly onDidDeleteDocument: Event<TransferDocumentDeletedEvent>;
|
|
46
|
+
/** Documents built that nobody watches — re-read anything derived from them. */
|
|
47
|
+
readonly onDidBuildDocuments: Event<TransferDocumentsBuiltEvent>;
|
|
42
48
|
/** The project set changed. */
|
|
43
49
|
readonly onDidChangeProjects: Event<ProjectsChangedEvent<TProject>>;
|
|
44
50
|
onDocumentUpdated(event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>): void;
|
|
45
51
|
onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
|
|
52
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
|
|
53
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
|
|
46
54
|
onProjectsChanged(event: ProjectsChangedEvent<TProject>): void;
|
|
47
55
|
dispose(): void;
|
|
48
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-events.d.ts","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"data-events.d.ts","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EACT,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,UAAU,CACpB,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,QAAQ,SAAS,OAAO,GAAG,OAAO,CACnC,YAAW,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC;IAC9D,SAAS,CAAC,QAAQ,CAAC,sBAAsB,gEAAuE;IAChH,SAAS,CAAC,QAAQ,CAAC,oBAAoB,8DAAqE;IAC5G,SAAS,CAAC,QAAQ,CAAC,sBAAsB,wCAA+C;IACxF,SAAS,CAAC,QAAQ,CAAC,qBAAqB,uCAA8C;IACtF,SAAS,CAAC,QAAQ,CAAC,sBAAsB,0CAAiD;IAE1F,4FAA4F;IAC5F,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAqC;IAC9H,gDAAgD;IAChD,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAmC;IACxH,iFAAiF;IACjF,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAqC;IACtG,gFAAgF;IAChF,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAoC;IACpG,+BAA+B;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAqC;IAIxG,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;IAIpF,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;IAIhF,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,GAAG,IAAI;IAI5D,gBAAgB,CAAC,KAAK,EAAE,2BAA2B,GAAG,IAAI;IAI1D,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,IAAI;IAI9D,OAAO,IAAI,IAAI;CAOjB"}
|
|
@@ -33,11 +33,17 @@ const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
|
33
33
|
class DataEvents {
|
|
34
34
|
documentUpdatedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
35
35
|
documentSavedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
36
|
+
documentDeletedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
37
|
+
documentsBuiltEmitter = new vscode_jsonrpc_1.Emitter();
|
|
36
38
|
projectsChangedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
37
39
|
/** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
|
|
38
40
|
onDidUpdateDocument = this.documentUpdatedEmitter.event;
|
|
39
41
|
/** A watched document was persisted to disk. */
|
|
40
42
|
onDidSaveDocument = this.documentSavedEmitter.event;
|
|
43
|
+
/** A document's backing file was removed, watched or not. Any watch survives. */
|
|
44
|
+
onDidDeleteDocument = this.documentDeletedEmitter.event;
|
|
45
|
+
/** Documents built that nobody watches — re-read anything derived from them. */
|
|
46
|
+
onDidBuildDocuments = this.documentsBuiltEmitter.event;
|
|
41
47
|
/** The project set changed. */
|
|
42
48
|
onDidChangeProjects = this.projectsChangedEmitter.event;
|
|
43
49
|
// --- DataClientProtocol (wire names) ---
|
|
@@ -47,12 +53,20 @@ class DataEvents {
|
|
|
47
53
|
onDocumentSaved(event) {
|
|
48
54
|
this.documentSavedEmitter.fire(event);
|
|
49
55
|
}
|
|
56
|
+
onDocumentDeleted(event) {
|
|
57
|
+
this.documentDeletedEmitter.fire(event);
|
|
58
|
+
}
|
|
59
|
+
onDocumentsBuilt(event) {
|
|
60
|
+
this.documentsBuiltEmitter.fire(event);
|
|
61
|
+
}
|
|
50
62
|
onProjectsChanged(event) {
|
|
51
63
|
this.projectsChangedEmitter.fire(event);
|
|
52
64
|
}
|
|
53
65
|
dispose() {
|
|
54
66
|
this.documentUpdatedEmitter.dispose();
|
|
55
67
|
this.documentSavedEmitter.dispose();
|
|
68
|
+
this.documentDeletedEmitter.dispose();
|
|
69
|
+
this.documentsBuiltEmitter.dispose();
|
|
56
70
|
this.projectsChangedEmitter.dispose();
|
|
57
71
|
}
|
|
58
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-events.js","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mDAAqD;
|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,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACJ,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACH;AAnDD,gCAmDC"}
|
|
@@ -25,7 +25,7 @@ export declare const DATA_SERVER_PROTOCOL_METHODS: readonly ["openModelDocument"
|
|
|
25
25
|
*/
|
|
26
26
|
export declare const REFERENCE_SERVER_PROTOCOL_METHODS: readonly ["findReferenceCandidates", "resolveReference", "findNextName"];
|
|
27
27
|
/** Notification-method names on {@link DocumentClientProtocol}. */
|
|
28
|
-
export declare const DOCUMENT_CLIENT_PROTOCOL_METHODS: readonly ["onDocumentUpdated", "onDocumentSaved"];
|
|
28
|
+
export declare const DOCUMENT_CLIENT_PROTOCOL_METHODS: readonly ["onDocumentUpdated", "onDocumentSaved", "onDocumentDeleted", "onDocumentsBuilt"];
|
|
29
29
|
/** Notification-method names on {@link ProjectClientProtocol}. */
|
|
30
30
|
export declare const PROJECT_CLIENT_PROTOCOL_METHODS: readonly ["onProjectsChanged"];
|
|
31
31
|
/**
|
|
@@ -35,5 +35,5 @@ export declare const PROJECT_CLIENT_PROTOCOL_METHODS: readonly ["onProjectsChang
|
|
|
35
35
|
* data head's connection routes `<methodNamespace>onDocumentUpdated` etc. to
|
|
36
36
|
* the bound client target.
|
|
37
37
|
*/
|
|
38
|
-
export declare const DATA_CLIENT_PROTOCOL_METHODS: readonly ["onDocumentUpdated", "onDocumentSaved", "onProjectsChanged"];
|
|
38
|
+
export declare const DATA_CLIENT_PROTOCOL_METHODS: readonly ["onDocumentUpdated", "onDocumentSaved", "onDocumentDeleted", "onDocumentsBuilt", "onProjectsChanged"];
|
|
39
39
|
//# sourceMappingURL=data-protocol-methods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-protocol-methods.d.ts","sourceRoot":"","sources":["../../src/data/data-protocol-methods.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAalF,8DAA8D;AAC9D,eAAO,MAAM,gCAAgC,oLAS6C,CAAC;AAE3F,6DAA6D;AAC7D,eAAO,MAAM,+BAA+B,8CAE3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,uNAG6C,CAAC;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,0EAI6C,CAAC;AAE5F,mEAAmE;AACnE,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"data-protocol-methods.d.ts","sourceRoot":"","sources":["../../src/data/data-protocol-methods.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAalF,8DAA8D;AAC9D,eAAO,MAAM,gCAAgC,oLAS6C,CAAC;AAE3F,6DAA6D;AAC7D,eAAO,MAAM,+BAA+B,8CAE3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,uNAG6C,CAAC;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,0EAI6C,CAAC;AAE5F,mEAAmE;AACnE,eAAO,MAAM,gCAAgC,4FAK6C,CAAC;AAE3F,kEAAkE;AAClE,eAAO,MAAM,+BAA+B,gCAA+F,CAAC;AAE5I;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,iHAG6C,CAAC"}
|
|
@@ -44,7 +44,12 @@ exports.REFERENCE_SERVER_PROTOCOL_METHODS = [
|
|
|
44
44
|
'findNextName'
|
|
45
45
|
];
|
|
46
46
|
/** Notification-method names on {@link DocumentClientProtocol}. */
|
|
47
|
-
exports.DOCUMENT_CLIENT_PROTOCOL_METHODS = [
|
|
47
|
+
exports.DOCUMENT_CLIENT_PROTOCOL_METHODS = [
|
|
48
|
+
'onDocumentUpdated',
|
|
49
|
+
'onDocumentSaved',
|
|
50
|
+
'onDocumentDeleted',
|
|
51
|
+
'onDocumentsBuilt'
|
|
52
|
+
];
|
|
48
53
|
/** Notification-method names on {@link ProjectClientProtocol}. */
|
|
49
54
|
exports.PROJECT_CLIENT_PROTOCOL_METHODS = ['onProjectsChanged'];
|
|
50
55
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-protocol-methods.js","sourceRoot":"","sources":["../../src/data/data-protocol-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAalF,8DAA8D;AACjD,QAAA,gCAAgC,GAAG;IAC7C,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;IACtB,cAAc;CACyE,CAAC;AAE3F,6DAA6D;AAChD,QAAA,+BAA+B,GAAG,CAAC,aAAa,EAAE,kBAAkB,CAEhF,CAAC;AAEF;;;;;GAKG;AACU,QAAA,4BAA4B,GAAG;IACzC,GAAG,wCAAgC;IACnC,GAAG,uCAA+B;CACiD,CAAC;AAEvF;;;;;GAKG;AACU,QAAA,iCAAiC,GAAG;IAC9C,yBAAyB;IACzB,kBAAkB;IAClB,cAAc;CAC0E,CAAC;AAE5F,mEAAmE;AACtD,QAAA,gCAAgC,GAAG,
|
|
1
|
+
{"version":3,"file":"data-protocol-methods.js","sourceRoot":"","sources":["../../src/data/data-protocol-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAalF,8DAA8D;AACjD,QAAA,gCAAgC,GAAG;IAC7C,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;IACtB,cAAc;CACyE,CAAC;AAE3F,6DAA6D;AAChD,QAAA,+BAA+B,GAAG,CAAC,aAAa,EAAE,kBAAkB,CAEhF,CAAC;AAEF;;;;;GAKG;AACU,QAAA,4BAA4B,GAAG;IACzC,GAAG,wCAAgC;IACnC,GAAG,uCAA+B;CACiD,CAAC;AAEvF;;;;;GAKG;AACU,QAAA,iCAAiC,GAAG;IAC9C,yBAAyB;IACzB,kBAAkB;IAClB,cAAc;CAC0E,CAAC;AAE5F,mEAAmE;AACtD,QAAA,gCAAgC,GAAG;IAC7C,mBAAmB;IACnB,iBAAiB;IACjB,mBAAmB;IACnB,kBAAkB;CACqE,CAAC;AAE3F,kEAAkE;AACrD,QAAA,+BAA+B,GAAG,CAAC,mBAAmB,CAAwE,CAAC;AAE5I;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG;IACzC,GAAG,wCAAgC;IACnC,GAAG,uCAA+B;CACiD,CAAC"}
|
|
@@ -12,7 +12,7 @@ import type { Project } from '../project';
|
|
|
12
12
|
import type { TransferDocument } from '../transfer-document';
|
|
13
13
|
import type { CloseModelArgs, FindNextNameArgs, OpenModelArgs, ReferenceContext, ReferenceRequest } from '../model-server';
|
|
14
14
|
import type { ReferenceCandidate, ReferenceTarget } from '../model-service/reference-candidate';
|
|
15
|
-
import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from './events';
|
|
15
|
+
import type { ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from './events';
|
|
16
16
|
import type { GetModelDocumentArgs, GetProjectForUriArgs, TransferSaveDocumentArgs, WatchModelDocumentArgs, TransferUpdateDocumentArgs } from './requests';
|
|
17
17
|
/**
|
|
18
18
|
* Document-scoped slice of the data-server wire contract: the per-document
|
|
@@ -235,6 +235,26 @@ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiag
|
|
|
235
235
|
* codepath, not a subscription codepath).
|
|
236
236
|
*/
|
|
237
237
|
onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
|
|
238
|
+
/**
|
|
239
|
+
* Delivered when a document's backing file was removed. Separate from
|
|
240
|
+
* {@link onDocumentUpdated} for the same reason as {@link onDocumentSaved},
|
|
241
|
+
* and more strongly: there is no built state to deliver, and the build-phase
|
|
242
|
+
* path cannot report a deletion at all.
|
|
243
|
+
*
|
|
244
|
+
* Ungated, because on a browser host — where the workspace lives behind the
|
|
245
|
+
* head — no other source can observe a file disappearing. Recipients that
|
|
246
|
+
* only care about their own documents filter by URI.
|
|
247
|
+
*/
|
|
248
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
|
|
249
|
+
/**
|
|
250
|
+
* Delivered once per build, naming the documents that reached the
|
|
251
|
+
* subscription phase and that
|
|
252
|
+
* nobody on this connection watches — chiefly the ones rebuilt as a cascade
|
|
253
|
+
* from a dependency's change, which no filesystem watcher can see because
|
|
254
|
+
* their own files did not change. The complement of
|
|
255
|
+
* {@link onDocumentUpdated}; carries URIs and no documents.
|
|
256
|
+
*/
|
|
257
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
|
|
238
258
|
}
|
|
239
259
|
/**
|
|
240
260
|
* Project-scoped slice of the client surface — the project-registry change
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-server-protocol.d.ts","sourceRoot":"","sources":["../../src/data/data-server-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC3H,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe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/events.d.ts
CHANGED
|
@@ -28,10 +28,14 @@ import type { TransferDocument } from '../transfer-document';
|
|
|
28
28
|
* from both `onDocumentUpdated` and `onDocumentSaved`. The framework's own
|
|
29
29
|
* `dispatchPhaseEvent` does NOT emit `'saved'` — saves take the dedicated
|
|
30
30
|
* `DataClientProtocol.onDocumentSaved` channel.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* Deletion is deliberately NOT a member. An update event carries a built
|
|
33
|
+
* document, which a deleted one has none of, and the phase-driven path that
|
|
34
|
+
* produces these events never runs for a deleted URI — the builder drops the
|
|
35
|
+
* document before deriving the rebuild set. It travels as
|
|
36
|
+
* {@link TransferDocumentDeletedEvent} on its own channel instead.
|
|
33
37
|
*/
|
|
34
|
-
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved'
|
|
38
|
+
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved';
|
|
35
39
|
/**
|
|
36
40
|
* Delivered on the data-server when a document's content (or existence)
|
|
37
41
|
* changed. Subscribers receive this via `DocumentServerProtocol.watchModelDocument`.
|
|
@@ -72,6 +76,69 @@ export interface TransferDocumentSavedEvent<TTransfer extends TransferElement, T
|
|
|
72
76
|
}
|
|
73
77
|
/** Callback shape for `DataClientProtocol.onDocumentSaved`. */
|
|
74
78
|
export type TransferDocumentSavedListener<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Delivered on the data-server when a document's backing file was removed.
|
|
81
|
+
* Carries no document, and cannot: the state a
|
|
82
|
+
* {@link TransferDocumentUpdatedEvent} would have to carry no longer exists by
|
|
83
|
+
* the time anyone can be told. That is also why deletion is not a `reason` on
|
|
84
|
+
* the update stream — `DocumentBuilder.update` drops the document before
|
|
85
|
+
* deriving the rebuild set, so the phase-driven path that produces update
|
|
86
|
+
* events never runs for it.
|
|
87
|
+
*
|
|
88
|
+
* **Delivered for EVERY document, not only watched ones**, unlike
|
|
89
|
+
* `onDocumentUpdated` and `onDocumentSaved`. The test that decides which
|
|
90
|
+
* channels are gated is whether any OTHER source can observe the fact on the
|
|
91
|
+
* least capable host: a browser-hosted client's workspace lives behind the
|
|
92
|
+
* head, so nothing there can see a file disappear, and gating the notification
|
|
93
|
+
* would leave it blind. (A Theia frontend's filesystem watcher would cover it,
|
|
94
|
+
* which is why this is a host argument and not a structure-versus-content one.)
|
|
95
|
+
* A watcher is told about its own document's deletion here too, the update
|
|
96
|
+
* channel being silent for deletions by construction. Filter on {@link uri} if
|
|
97
|
+
* the receiver only cares about documents it opened.
|
|
98
|
+
*
|
|
99
|
+
* A watch survives the deletion, so a file that comes back resumes delivering
|
|
100
|
+
* `onDocumentUpdated` to the same subscribers with no re-subscription. A
|
|
101
|
+
* client that responds by closing its editor releases the watch through
|
|
102
|
+
* `closeModelDocument` as usual.
|
|
103
|
+
*/
|
|
104
|
+
export interface TransferDocumentDeletedEvent {
|
|
105
|
+
/** Canonical URI of the removed document, keyed as the subscription is. */
|
|
106
|
+
readonly uri: string;
|
|
107
|
+
}
|
|
108
|
+
/** Callback shape for `DataClientProtocol.onDocumentDeleted`. */
|
|
109
|
+
export type TransferDocumentDeletedListener = (event: TransferDocumentDeletedEvent) => void;
|
|
110
|
+
/**
|
|
111
|
+
* Delivered on the data-server once per build, naming the documents that reached
|
|
112
|
+
* the configured subscription phase (`DataServerOptions.subscriptionPhase`,
|
|
113
|
+
* `Validated` by default) and that NO client on the connection is watching. Not
|
|
114
|
+
* the integrity-settled landmark, which is a different point and a different
|
|
115
|
+
* word in this framework.
|
|
116
|
+
*
|
|
117
|
+
* The complement of {@link TransferDocumentUpdatedEvent}, which is gated per
|
|
118
|
+
* URI: together the two cover every document a build touched. This one exists
|
|
119
|
+
* for the case no source outside the server can observe — a document rebuilt
|
|
120
|
+
* because something it DEPENDS ON changed. Its own file never changed, so a
|
|
121
|
+
* filesystem watcher cannot see it, and it has no subscriber, so the update
|
|
122
|
+
* channel does not report it. A consumer showing data derived from such a
|
|
123
|
+
* document (a tree label, a decorator) would otherwise hold a stale value with
|
|
124
|
+
* nothing to invalidate it.
|
|
125
|
+
*
|
|
126
|
+
* Carries URIs and no documents: a recipient re-reads what it displays, through
|
|
127
|
+
* `getModelDocument` or its own request. That keeps the bandwidth property the
|
|
128
|
+
* per-URI subscription exists for, without gating the message.
|
|
129
|
+
*
|
|
130
|
+
* Not sent when the set is empty, which is the normal case while editing — the
|
|
131
|
+
* document being edited is watched by its own editor and therefore excluded.
|
|
132
|
+
* Workspace initialisation sends nothing either: it does not build to the
|
|
133
|
+
* subscription phase. The largest message a workspace can produce is therefore
|
|
134
|
+
* a whole-workspace rebuild at that phase, which is one message of URIs.
|
|
135
|
+
*/
|
|
136
|
+
export interface TransferDocumentsBuiltEvent {
|
|
137
|
+
/** Canonical URIs, keyed as subscriptions are. Never empty. */
|
|
138
|
+
readonly uris: readonly string[];
|
|
139
|
+
}
|
|
140
|
+
/** Callback shape for `DataClientProtocol.onDocumentsBuilt`. */
|
|
141
|
+
export type TransferDocumentsBuiltListener = (event: TransferDocumentsBuiltEvent) => void;
|
|
75
142
|
/**
|
|
76
143
|
* Why a project-change event fired. `added` — the project was newly
|
|
77
144
|
* registered (descriptor discovered); `updated` — the project's
|
package/lib/data/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/data/events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D
|
|
1
|
+
{"version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0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,4BAA4B;IAC1C,2EAA2E;IAC3E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACvB;AAED,iEAAiE;AACjE,MAAM,MAAM,+BAA+B,GAAG,CAAC,KAAK,EAAE,4BAA4B,KAAK,IAAI,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,2BAA2B;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,gEAAgE;AAChE,MAAM,MAAM,8BAA8B,GAAG,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;AAE1F;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,oBAAoB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IACrE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;CACvC;AAED,iEAAiE;AACjE,MAAM,MAAM,uBAAuB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC"}
|
package/lib/errors.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { type HydraniumMessageData } from './messages/primitives';
|
|
|
16
16
|
* That tier only ever works untranslated, which is why it is the last resort
|
|
17
17
|
* behind the numeric code rather than the primary check.
|
|
18
18
|
*/
|
|
19
|
-
export declare const STALE_BASED_UPDATE: import("./messages/primitives").MessageDefinition<"Stale-based update for {uri}: expected v{
|
|
19
|
+
export declare const STALE_BASED_UPDATE: import("./messages/primitives").MessageDefinition<"Stale-based update for {uri}: expected v{expectedVersion}, server is at v{actualVersion}">;
|
|
20
20
|
/**
|
|
21
21
|
* Application-specific JSON-RPC error code for {@link ConflictError}.
|
|
22
22
|
* Outside the reserved range (-32768 .. -32000) per JSON-RPC 2.0.
|
|
@@ -34,9 +34,9 @@ export declare const CONFLICT_ERROR_CODE = 1001;
|
|
|
34
34
|
export interface ConflictErrorData extends HydraniumMessageData {
|
|
35
35
|
readonly uri: string;
|
|
36
36
|
/** The based-on version the caller authored against. */
|
|
37
|
-
readonly
|
|
37
|
+
readonly expectedVersion: number;
|
|
38
38
|
/** The server's current text-document version at the time of the throw. */
|
|
39
|
-
readonly
|
|
39
|
+
readonly actualVersion: number;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Thrown by `ModelService.update` / `ModelService.save` when the caller-
|
|
@@ -70,10 +70,19 @@ export interface ConflictErrorData extends HydraniumMessageData {
|
|
|
70
70
|
* No auto-retry or auto-merge ships by default.
|
|
71
71
|
*/
|
|
72
72
|
export declare class ConflictError extends ResponseError<ConflictErrorData> {
|
|
73
|
-
constructor(uri: string,
|
|
73
|
+
constructor(uri: string, expectedVersion: number, actualVersion: number);
|
|
74
74
|
get uri(): string;
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
/**
|
|
76
|
+
* The based-on version the caller authored against.
|
|
77
|
+
*
|
|
78
|
+
* Must not be renamed to `expected`, nor its sibling to `actual`: a test
|
|
79
|
+
* reporter reads an error carrying both as an assertion failure, and
|
|
80
|
+
* vitest's formatter then ASSIGNS to them, which throws on an accessor and
|
|
81
|
+
* replaces the real failure with a `TypeError`.
|
|
82
|
+
*/
|
|
83
|
+
get expectedVersion(): number;
|
|
84
|
+
/** The server's version at the time of the throw. Not `actual` — see {@link expectedVersion}. */
|
|
85
|
+
get actualVersion(): number;
|
|
77
86
|
}
|
|
78
87
|
/**
|
|
79
88
|
* Type guard for {@link ConflictError}. Detection ladder:
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAiB,KAAK,oBAAoB,EAAe,MAAM,uBAAuB,CAAC;AAE9F;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAiB,KAAK,oBAAoB,EAAe,MAAM,uBAAuB,CAAC;AAE9F;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,+IAG9B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC5D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,2EAA2E;IAC3E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAc,SAAQ,aAAa,CAAC,iBAAiB,CAAC;gBACpD,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;IAgBvE,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;;;;;;OAOG;IACH,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,iGAAiG;IACjG,IAAI,aAAa,IAAI,MAAM,CAE1B;CACH;AAOD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAYtE"}
|
package/lib/errors.js
CHANGED
|
@@ -20,7 +20,7 @@ const primitives_1 = require("./messages/primitives");
|
|
|
20
20
|
* That tier only ever works untranslated, which is why it is the last resort
|
|
21
21
|
* behind the numeric code rather than the primary check.
|
|
22
22
|
*/
|
|
23
|
-
exports.STALE_BASED_UPDATE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-based-update', 'Stale-based update for {uri}: expected v{
|
|
23
|
+
exports.STALE_BASED_UPDATE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-based-update', 'Stale-based update for {uri}: expected v{expectedVersion}, server is at v{actualVersion}');
|
|
24
24
|
/**
|
|
25
25
|
* Application-specific JSON-RPC error code for {@link ConflictError}.
|
|
26
26
|
* Outside the reserved range (-32768 .. -32000) per JSON-RPC 2.0.
|
|
@@ -63,28 +63,38 @@ exports.CONFLICT_ERROR_CODE = 1001;
|
|
|
63
63
|
* No auto-retry or auto-merge ships by default.
|
|
64
64
|
*/
|
|
65
65
|
class ConflictError extends vscode_jsonrpc_1.ResponseError {
|
|
66
|
-
constructor(uri,
|
|
67
|
-
const params = { uri,
|
|
66
|
+
constructor(uri, expectedVersion, actualVersion) {
|
|
67
|
+
const params = { uri, expectedVersion, actualVersion };
|
|
68
68
|
// The identity rides alongside the typed payload rather than replacing
|
|
69
|
-
// it:
|
|
70
|
-
//
|
|
69
|
+
// it: `isConflictError`'s name check is surface an adopter may bind, so
|
|
70
|
+
// adding the identity widens the payload rather than reshaping it.
|
|
71
71
|
super(exports.CONFLICT_ERROR_CODE, exports.STALE_BASED_UPDATE.format(params), { ...params, ...(0, primitives_1.messageData)(exports.STALE_BASED_UPDATE, params) });
|
|
72
72
|
this.name = 'ConflictError';
|
|
73
73
|
// ResponseError's constructor calls `Object.setPrototypeOf(this,
|
|
74
74
|
// ResponseError.prototype)` to keep its own prototype chain intact across
|
|
75
75
|
// transpilation targets; that resets us to ResponseError, hiding the
|
|
76
76
|
// ConflictError-specific getters. Restore the prototype here so
|
|
77
|
-
// `err.uri` / `.
|
|
77
|
+
// `err.uri` / `.expectedVersion` / `.actualVersion` resolve through this
|
|
78
|
+
// class.
|
|
78
79
|
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
79
80
|
}
|
|
80
81
|
get uri() {
|
|
81
82
|
return this.data.uri;
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
|
+
* The based-on version the caller authored against.
|
|
86
|
+
*
|
|
87
|
+
* Must not be renamed to `expected`, nor its sibling to `actual`: a test
|
|
88
|
+
* reporter reads an error carrying both as an assertion failure, and
|
|
89
|
+
* vitest's formatter then ASSIGNS to them, which throws on an accessor and
|
|
90
|
+
* replaces the real failure with a `TypeError`.
|
|
91
|
+
*/
|
|
92
|
+
get expectedVersion() {
|
|
93
|
+
return this.data.expectedVersion;
|
|
85
94
|
}
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
/** The server's version at the time of the throw. Not `actual` — see {@link expectedVersion}. */
|
|
96
|
+
get actualVersion() {
|
|
97
|
+
return this.data.actualVersion;
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
exports.ConflictError = ConflictError;
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAmIlF,0CAYC;AA7ID,mDAA+C;AAC/C,sDAA8F;AAE9F;;;;;;;GAOG;AACU,QAAA,kBAAkB,GAAG,IAAA,0BAAa,EAC5C,uCAAuC,EACvC,0FAA0F,CAC5F,CAAC;AAEF;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAcxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAa,aAAc,SAA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AChC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACrG,CAAC"}
|
package/lib/model-server.d.ts
CHANGED
|
@@ -46,8 +46,8 @@ export interface CloseModelArgs extends TransferClientArgs {
|
|
|
46
46
|
export interface TransferUpdatedEvent<TDocument> {
|
|
47
47
|
document: TDocument;
|
|
48
48
|
sourceClientId: string;
|
|
49
|
-
/** See `
|
|
50
|
-
reason: 'changed' | '
|
|
49
|
+
/** See `TransferDocumentUpdateReason` in `./data/events` for the canonical reason set + semantics. */
|
|
50
|
+
reason: 'changed' | 'rebuilt' | 'saved';
|
|
51
51
|
}
|
|
52
52
|
export interface TransferSavedEvent<TDocument> {
|
|
53
53
|
/** The document as persisted — the state that reached disk, not the state at request time. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-server.d.ts","sourceRoot":"","sources":["../src/model-server.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAW9E,6CAA6C;AAC7C,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACtD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yDAAyD;AAEzD,MAAM,WAAW,cAAe,SAAQ,kBAAkB;CAAG;AAM7D,MAAM,WAAW,oBAAoB,CAAC,SAAS;IAC5C,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,
|
|
1
|
+
{"version":3,"file":"model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5B;AA8BD,yBAAiB,gBAAgB,CAAC;IAC/B,oEAAoE;IACpE,SAAgB,OAAO,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAE1E;CACH;AAED,yBAAiB,gBAAgB,CAAC;IAC/B,6EAA6E;IAC7E,SAAgB,OAAO,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAI1E;IAED;;;;;;OAMG;IACH,SAAgB,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,kBAAkB,GAAG,gBAAgB,CAE/F;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtD,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC9B;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;CAClB"}
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
import { type MessageConnection } from 'vscode-jsonrpc';
|
|
33
33
|
import type { DataPort } from '../client/data-port';
|
|
34
34
|
import type { DataClientProtocol } from '../data/data-server-protocol';
|
|
35
|
-
import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from '../data/events';
|
|
35
|
+
import type { ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from '../data/events';
|
|
36
36
|
import type { ResolvedMessage } from '../messages/primitives';
|
|
37
37
|
import type { Project } from '../project';
|
|
38
38
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
@@ -103,13 +103,17 @@ export interface CapturingDataClient<TTransfer extends TransferElement, TDiagnos
|
|
|
103
103
|
readonly updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[];
|
|
104
104
|
/** Every `onDocumentSaved` event, in arrival order. */
|
|
105
105
|
readonly saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[];
|
|
106
|
+
/** Every `onDocumentDeleted` event, in arrival order. */
|
|
107
|
+
readonly deletions: TransferDocumentDeletedEvent[];
|
|
108
|
+
/** Every `onDocumentsBuilt` event, in arrival order. */
|
|
109
|
+
readonly builds: TransferDocumentsBuiltEvent[];
|
|
106
110
|
/** Every `onProjectsChanged` event, in arrival order. */
|
|
107
111
|
readonly projectsChanges: ProjectsChangedEvent<TProject>[];
|
|
108
112
|
}
|
|
109
113
|
/**
|
|
110
114
|
* A {@link DataClientProtocol} that records every notification it receives.
|
|
111
115
|
*
|
|
112
|
-
* Recording
|
|
116
|
+
* Recording EVERY channel even when a suite reads one is deliberate: an
|
|
113
117
|
* event delivered on the wrong channel is a real defect of the data head, and a
|
|
114
118
|
* double that drops the other two turns it into silence on the one being
|
|
115
119
|
* watched.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-doubles.d.ts","sourceRoot":"","sources":["../../src/testing/data-doubles.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"data-doubles.d.ts","sourceRoot":"","sources":["../../src/testing/data-doubles.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD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,CAAC,MAAM,EAAE,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACtE,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC;IACzE,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC;IACrE,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,4BAA4B,EAAE,CAAC;IACnD,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,2BAA2B,EAAE,CAAC;IAC/C,yDAAyD;IACzD,QAAQ,CAAC,eAAe,EAAE,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;CAC7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACpC,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,QAAQ,SAAS,OAAO,GAAG,OAAO,EACnC,SAAS,GAAE,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAM,GAAG,mBAAmB,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAkCtI"}
|
|
@@ -69,7 +69,7 @@ function makeFakeDataPort(options) {
|
|
|
69
69
|
/**
|
|
70
70
|
* A {@link DataClientProtocol} that records every notification it receives.
|
|
71
71
|
*
|
|
72
|
-
* Recording
|
|
72
|
+
* Recording EVERY channel even when a suite reads one is deliberate: an
|
|
73
73
|
* event delivered on the wrong channel is a real defect of the data head, and a
|
|
74
74
|
* double that drops the other two turns it into silence on the one being
|
|
75
75
|
* watched.
|
|
@@ -82,6 +82,8 @@ function makeFakeDataPort(options) {
|
|
|
82
82
|
function makeCapturingDataClient(overrides = {}) {
|
|
83
83
|
const updates = [];
|
|
84
84
|
const saves = [];
|
|
85
|
+
const deletions = [];
|
|
86
|
+
const builds = [];
|
|
85
87
|
const projectsChanges = [];
|
|
86
88
|
const client = {
|
|
87
89
|
onDocumentUpdated: overrides.onDocumentUpdated ??
|
|
@@ -92,11 +94,19 @@ function makeCapturingDataClient(overrides = {}) {
|
|
|
92
94
|
(event => {
|
|
93
95
|
saves.push(event);
|
|
94
96
|
}),
|
|
97
|
+
onDocumentDeleted: overrides.onDocumentDeleted ??
|
|
98
|
+
(event => {
|
|
99
|
+
deletions.push(event);
|
|
100
|
+
}),
|
|
101
|
+
onDocumentsBuilt: overrides.onDocumentsBuilt ??
|
|
102
|
+
(event => {
|
|
103
|
+
builds.push(event);
|
|
104
|
+
}),
|
|
95
105
|
onProjectsChanged: overrides.onProjectsChanged ??
|
|
96
106
|
(event => {
|
|
97
107
|
projectsChanges.push(event);
|
|
98
108
|
})
|
|
99
109
|
};
|
|
100
|
-
return { client, updates, saves, projectsChanges };
|
|
110
|
+
return { client, updates, saves, deletions, builds, projectsChanges };
|
|
101
111
|
}
|
|
102
112
|
//# sourceMappingURL=data-doubles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-doubles.js","sourceRoot":"","sources":["../../src/testing/data-doubles.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;
|
|
1
|
+
{"version":3,"file":"data-doubles.js","sourceRoot":"","sources":["../../src/testing/data-doubles.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;AAiGlF,4CAwBC;AAmCD,0DAsCC;AAhMD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,mDAAiE;AAgEjE;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,OAA4B;IAC1D,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAAmD,EAAE,CAAC;IACpE,MAAM,cAAc,GAAG,IAAI,wBAAO,EAAQ,CAAC;IAC3C,OAAO;QACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,gBAAgB;QAC9C,WAAW;QACX,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AAC,EAAE;gBACN,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC,CAAC;QACL,iBAAiB,EACd,SAAS,CAAC,iBAAiB;YAC3B,CAAC,KAAK,CAAC,EAAE;gBACN,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC,CAAC;KACP,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AACzE,CAAC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,14 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import { Emitter, type Event } from 'vscode-jsonrpc';
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
DataClientProtocol,
|
|
13
|
+
ProjectsChangedEvent,
|
|
14
|
+
TransferDocumentDeletedEvent,
|
|
15
|
+
TransferDocumentSavedEvent,
|
|
16
|
+
TransferDocumentsBuiltEvent,
|
|
17
|
+
TransferDocumentUpdatedEvent
|
|
18
|
+
} from '../data';
|
|
12
19
|
import type { Project } from '../project';
|
|
13
20
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
14
21
|
import type { TransferElement } from '../transfer-element';
|
|
@@ -40,12 +47,18 @@ export class DataEvents<
|
|
|
40
47
|
> implements DataClientProtocol<TTransfer, TDiagnostic, TProject> {
|
|
41
48
|
protected readonly documentUpdatedEmitter = new Emitter<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>();
|
|
42
49
|
protected readonly documentSavedEmitter = new Emitter<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>();
|
|
50
|
+
protected readonly documentDeletedEmitter = new Emitter<TransferDocumentDeletedEvent>();
|
|
51
|
+
protected readonly documentsBuiltEmitter = new Emitter<TransferDocumentsBuiltEvent>();
|
|
43
52
|
protected readonly projectsChangedEmitter = new Emitter<ProjectsChangedEvent<TProject>>();
|
|
44
53
|
|
|
45
54
|
/** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
|
|
46
55
|
readonly onDidUpdateDocument: Event<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>> = this.documentUpdatedEmitter.event;
|
|
47
56
|
/** A watched document was persisted to disk. */
|
|
48
57
|
readonly onDidSaveDocument: Event<TransferDocumentSavedEvent<TTransfer, TDiagnostic>> = this.documentSavedEmitter.event;
|
|
58
|
+
/** A document's backing file was removed, watched or not. Any watch survives. */
|
|
59
|
+
readonly onDidDeleteDocument: Event<TransferDocumentDeletedEvent> = this.documentDeletedEmitter.event;
|
|
60
|
+
/** Documents built that nobody watches — re-read anything derived from them. */
|
|
61
|
+
readonly onDidBuildDocuments: Event<TransferDocumentsBuiltEvent> = this.documentsBuiltEmitter.event;
|
|
49
62
|
/** The project set changed. */
|
|
50
63
|
readonly onDidChangeProjects: Event<ProjectsChangedEvent<TProject>> = this.projectsChangedEmitter.event;
|
|
51
64
|
|
|
@@ -59,6 +72,14 @@ export class DataEvents<
|
|
|
59
72
|
this.documentSavedEmitter.fire(event);
|
|
60
73
|
}
|
|
61
74
|
|
|
75
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void {
|
|
76
|
+
this.documentDeletedEmitter.fire(event);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void {
|
|
80
|
+
this.documentsBuiltEmitter.fire(event);
|
|
81
|
+
}
|
|
82
|
+
|
|
62
83
|
onProjectsChanged(event: ProjectsChangedEvent<TProject>): void {
|
|
63
84
|
this.projectsChangedEmitter.fire(event);
|
|
64
85
|
}
|
|
@@ -66,6 +87,8 @@ export class DataEvents<
|
|
|
66
87
|
dispose(): void {
|
|
67
88
|
this.documentUpdatedEmitter.dispose();
|
|
68
89
|
this.documentSavedEmitter.dispose();
|
|
90
|
+
this.documentDeletedEmitter.dispose();
|
|
91
|
+
this.documentsBuiltEmitter.dispose();
|
|
69
92
|
this.projectsChangedEmitter.dispose();
|
|
70
93
|
}
|
|
71
94
|
}
|
|
@@ -59,9 +59,12 @@ export const REFERENCE_SERVER_PROTOCOL_METHODS = [
|
|
|
59
59
|
] as const satisfies ReadonlyArray<keyof ReferenceServerProtocol<TransferElement> & string>;
|
|
60
60
|
|
|
61
61
|
/** Notification-method names on {@link DocumentClientProtocol}. */
|
|
62
|
-
export const DOCUMENT_CLIENT_PROTOCOL_METHODS = [
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
export const DOCUMENT_CLIENT_PROTOCOL_METHODS = [
|
|
63
|
+
'onDocumentUpdated',
|
|
64
|
+
'onDocumentSaved',
|
|
65
|
+
'onDocumentDeleted',
|
|
66
|
+
'onDocumentsBuilt'
|
|
67
|
+
] as const satisfies ReadonlyArray<keyof DocumentClientProtocol<TransferElement> & string>;
|
|
65
68
|
|
|
66
69
|
/** Notification-method names on {@link ProjectClientProtocol}. */
|
|
67
70
|
export const PROJECT_CLIENT_PROTOCOL_METHODS = ['onProjectsChanged'] as const satisfies ReadonlyArray<keyof ProjectClientProtocol & string>;
|
|
@@ -13,7 +13,13 @@ import type { Project } from '../project';
|
|
|
13
13
|
import type { TransferDocument } from '../transfer-document';
|
|
14
14
|
import type { CloseModelArgs, FindNextNameArgs, OpenModelArgs, ReferenceContext, ReferenceRequest } from '../model-server';
|
|
15
15
|
import type { ReferenceCandidate, ReferenceTarget } from '../model-service/reference-candidate';
|
|
16
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
ProjectsChangedEvent,
|
|
18
|
+
TransferDocumentDeletedEvent,
|
|
19
|
+
TransferDocumentSavedEvent,
|
|
20
|
+
TransferDocumentsBuiltEvent,
|
|
21
|
+
TransferDocumentUpdatedEvent
|
|
22
|
+
} from './events';
|
|
17
23
|
import type {
|
|
18
24
|
GetModelDocumentArgs,
|
|
19
25
|
GetProjectForUriArgs,
|
|
@@ -262,6 +268,28 @@ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiag
|
|
|
262
268
|
* codepath, not a subscription codepath).
|
|
263
269
|
*/
|
|
264
270
|
onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Delivered when a document's backing file was removed. Separate from
|
|
274
|
+
* {@link onDocumentUpdated} for the same reason as {@link onDocumentSaved},
|
|
275
|
+
* and more strongly: there is no built state to deliver, and the build-phase
|
|
276
|
+
* path cannot report a deletion at all.
|
|
277
|
+
*
|
|
278
|
+
* Ungated, because on a browser host — where the workspace lives behind the
|
|
279
|
+
* head — no other source can observe a file disappearing. Recipients that
|
|
280
|
+
* only care about their own documents filter by URI.
|
|
281
|
+
*/
|
|
282
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Delivered once per build, naming the documents that reached the
|
|
286
|
+
* subscription phase and that
|
|
287
|
+
* nobody on this connection watches — chiefly the ones rebuilt as a cascade
|
|
288
|
+
* from a dependency's change, which no filesystem watcher can see because
|
|
289
|
+
* their own files did not change. The complement of
|
|
290
|
+
* {@link onDocumentUpdated}; carries URIs and no documents.
|
|
291
|
+
*/
|
|
292
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
|
|
265
293
|
}
|
|
266
294
|
|
|
267
295
|
/**
|
package/src/data/events.ts
CHANGED
|
@@ -30,10 +30,14 @@ import type { TransferDocument } from '../transfer-document';
|
|
|
30
30
|
* from both `onDocumentUpdated` and `onDocumentSaved`. The framework's own
|
|
31
31
|
* `dispatchPhaseEvent` does NOT emit `'saved'` — saves take the dedicated
|
|
32
32
|
* `DataClientProtocol.onDocumentSaved` channel.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
*
|
|
34
|
+
* Deletion is deliberately NOT a member. An update event carries a built
|
|
35
|
+
* document, which a deleted one has none of, and the phase-driven path that
|
|
36
|
+
* produces these events never runs for a deleted URI — the builder drops the
|
|
37
|
+
* document before deriving the rebuild set. It travels as
|
|
38
|
+
* {@link TransferDocumentDeletedEvent} on its own channel instead.
|
|
35
39
|
*/
|
|
36
|
-
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved'
|
|
40
|
+
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved';
|
|
37
41
|
|
|
38
42
|
/**
|
|
39
43
|
* Delivered on the data-server when a document's content (or existence)
|
|
@@ -91,6 +95,73 @@ export type TransferDocumentSavedListener<
|
|
|
91
95
|
TDiagnostic extends TransferDiagnostic = TransferDiagnostic
|
|
92
96
|
> = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
|
|
93
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Delivered on the data-server when a document's backing file was removed.
|
|
100
|
+
* Carries no document, and cannot: the state a
|
|
101
|
+
* {@link TransferDocumentUpdatedEvent} would have to carry no longer exists by
|
|
102
|
+
* the time anyone can be told. That is also why deletion is not a `reason` on
|
|
103
|
+
* the update stream — `DocumentBuilder.update` drops the document before
|
|
104
|
+
* deriving the rebuild set, so the phase-driven path that produces update
|
|
105
|
+
* events never runs for it.
|
|
106
|
+
*
|
|
107
|
+
* **Delivered for EVERY document, not only watched ones**, unlike
|
|
108
|
+
* `onDocumentUpdated` and `onDocumentSaved`. The test that decides which
|
|
109
|
+
* channels are gated is whether any OTHER source can observe the fact on the
|
|
110
|
+
* least capable host: a browser-hosted client's workspace lives behind the
|
|
111
|
+
* head, so nothing there can see a file disappear, and gating the notification
|
|
112
|
+
* would leave it blind. (A Theia frontend's filesystem watcher would cover it,
|
|
113
|
+
* which is why this is a host argument and not a structure-versus-content one.)
|
|
114
|
+
* A watcher is told about its own document's deletion here too, the update
|
|
115
|
+
* channel being silent for deletions by construction. Filter on {@link uri} if
|
|
116
|
+
* the receiver only cares about documents it opened.
|
|
117
|
+
*
|
|
118
|
+
* A watch survives the deletion, so a file that comes back resumes delivering
|
|
119
|
+
* `onDocumentUpdated` to the same subscribers with no re-subscription. A
|
|
120
|
+
* client that responds by closing its editor releases the watch through
|
|
121
|
+
* `closeModelDocument` as usual.
|
|
122
|
+
*/
|
|
123
|
+
export interface TransferDocumentDeletedEvent {
|
|
124
|
+
/** Canonical URI of the removed document, keyed as the subscription is. */
|
|
125
|
+
readonly uri: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Callback shape for `DataClientProtocol.onDocumentDeleted`. */
|
|
129
|
+
export type TransferDocumentDeletedListener = (event: TransferDocumentDeletedEvent) => void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Delivered on the data-server once per build, naming the documents that reached
|
|
133
|
+
* the configured subscription phase (`DataServerOptions.subscriptionPhase`,
|
|
134
|
+
* `Validated` by default) and that NO client on the connection is watching. Not
|
|
135
|
+
* the integrity-settled landmark, which is a different point and a different
|
|
136
|
+
* word in this framework.
|
|
137
|
+
*
|
|
138
|
+
* The complement of {@link TransferDocumentUpdatedEvent}, which is gated per
|
|
139
|
+
* URI: together the two cover every document a build touched. This one exists
|
|
140
|
+
* for the case no source outside the server can observe — a document rebuilt
|
|
141
|
+
* because something it DEPENDS ON changed. Its own file never changed, so a
|
|
142
|
+
* filesystem watcher cannot see it, and it has no subscriber, so the update
|
|
143
|
+
* channel does not report it. A consumer showing data derived from such a
|
|
144
|
+
* document (a tree label, a decorator) would otherwise hold a stale value with
|
|
145
|
+
* nothing to invalidate it.
|
|
146
|
+
*
|
|
147
|
+
* Carries URIs and no documents: a recipient re-reads what it displays, through
|
|
148
|
+
* `getModelDocument` or its own request. That keeps the bandwidth property the
|
|
149
|
+
* per-URI subscription exists for, without gating the message.
|
|
150
|
+
*
|
|
151
|
+
* Not sent when the set is empty, which is the normal case while editing — the
|
|
152
|
+
* document being edited is watched by its own editor and therefore excluded.
|
|
153
|
+
* Workspace initialisation sends nothing either: it does not build to the
|
|
154
|
+
* subscription phase. The largest message a workspace can produce is therefore
|
|
155
|
+
* a whole-workspace rebuild at that phase, which is one message of URIs.
|
|
156
|
+
*/
|
|
157
|
+
export interface TransferDocumentsBuiltEvent {
|
|
158
|
+
/** Canonical URIs, keyed as subscriptions are. Never empty. */
|
|
159
|
+
readonly uris: readonly string[];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Callback shape for `DataClientProtocol.onDocumentsBuilt`. */
|
|
163
|
+
export type TransferDocumentsBuiltListener = (event: TransferDocumentsBuiltEvent) => void;
|
|
164
|
+
|
|
94
165
|
/**
|
|
95
166
|
* Why a project-change event fired. `added` — the project was newly
|
|
96
167
|
* registered (descriptor discovered); `updated` — the project's
|
package/src/errors.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { defineMessage, type HydraniumMessageData, messageData } from './message
|
|
|
20
20
|
*/
|
|
21
21
|
export const STALE_BASED_UPDATE = defineMessage(
|
|
22
22
|
'hydranium/protocol/stale-based-update',
|
|
23
|
-
'Stale-based update for {uri}: expected v{
|
|
23
|
+
'Stale-based update for {uri}: expected v{expectedVersion}, server is at v{actualVersion}'
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -41,9 +41,9 @@ export const CONFLICT_ERROR_CODE = 1001;
|
|
|
41
41
|
export interface ConflictErrorData extends HydraniumMessageData {
|
|
42
42
|
readonly uri: string;
|
|
43
43
|
/** The based-on version the caller authored against. */
|
|
44
|
-
readonly
|
|
44
|
+
readonly expectedVersion: number;
|
|
45
45
|
/** The server's current text-document version at the time of the throw. */
|
|
46
|
-
readonly
|
|
46
|
+
readonly actualVersion: number;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -78,18 +78,19 @@ export interface ConflictErrorData extends HydraniumMessageData {
|
|
|
78
78
|
* No auto-retry or auto-merge ships by default.
|
|
79
79
|
*/
|
|
80
80
|
export class ConflictError extends ResponseError<ConflictErrorData> {
|
|
81
|
-
constructor(uri: string,
|
|
82
|
-
const params = { uri,
|
|
81
|
+
constructor(uri: string, expectedVersion: number, actualVersion: number) {
|
|
82
|
+
const params = { uri, expectedVersion, actualVersion };
|
|
83
83
|
// The identity rides alongside the typed payload rather than replacing
|
|
84
|
-
// it:
|
|
85
|
-
//
|
|
84
|
+
// it: `isConflictError`'s name check is surface an adopter may bind, so
|
|
85
|
+
// adding the identity widens the payload rather than reshaping it.
|
|
86
86
|
super(CONFLICT_ERROR_CODE, STALE_BASED_UPDATE.format(params), { ...params, ...messageData(STALE_BASED_UPDATE, params) });
|
|
87
87
|
this.name = 'ConflictError';
|
|
88
88
|
// ResponseError's constructor calls `Object.setPrototypeOf(this,
|
|
89
89
|
// ResponseError.prototype)` to keep its own prototype chain intact across
|
|
90
90
|
// transpilation targets; that resets us to ResponseError, hiding the
|
|
91
91
|
// ConflictError-specific getters. Restore the prototype here so
|
|
92
|
-
// `err.uri` / `.
|
|
92
|
+
// `err.uri` / `.expectedVersion` / `.actualVersion` resolve through this
|
|
93
|
+
// class.
|
|
93
94
|
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -97,12 +98,21 @@ export class ConflictError extends ResponseError<ConflictErrorData> {
|
|
|
97
98
|
return this.data!.uri;
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
/**
|
|
102
|
+
* The based-on version the caller authored against.
|
|
103
|
+
*
|
|
104
|
+
* Must not be renamed to `expected`, nor its sibling to `actual`: a test
|
|
105
|
+
* reporter reads an error carrying both as an assertion failure, and
|
|
106
|
+
* vitest's formatter then ASSIGNS to them, which throws on an accessor and
|
|
107
|
+
* replaces the real failure with a `TypeError`.
|
|
108
|
+
*/
|
|
109
|
+
get expectedVersion(): number {
|
|
110
|
+
return this.data!.expectedVersion;
|
|
102
111
|
}
|
|
103
112
|
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
/** The server's version at the time of the throw. Not `actual` — see {@link expectedVersion}. */
|
|
114
|
+
get actualVersion(): number {
|
|
115
|
+
return this.data!.actualVersion;
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
118
|
|
package/src/model-server.ts
CHANGED
|
@@ -64,8 +64,8 @@ export interface CloseModelArgs extends TransferClientArgs {}
|
|
|
64
64
|
export interface TransferUpdatedEvent<TDocument> {
|
|
65
65
|
document: TDocument;
|
|
66
66
|
sourceClientId: string;
|
|
67
|
-
/** See `
|
|
68
|
-
reason: 'changed' | '
|
|
67
|
+
/** See `TransferDocumentUpdateReason` in `./data/events` for the canonical reason set + semantics. */
|
|
68
|
+
reason: 'changed' | 'rebuilt' | 'saved';
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export interface TransferSavedEvent<TDocument> {
|
|
@@ -34,7 +34,13 @@
|
|
|
34
34
|
import { Emitter, type MessageConnection } from 'vscode-jsonrpc';
|
|
35
35
|
import type { DataPort } from '../client/data-port';
|
|
36
36
|
import type { DataClientProtocol } from '../data/data-server-protocol';
|
|
37
|
-
import type {
|
|
37
|
+
import type {
|
|
38
|
+
ProjectsChangedEvent,
|
|
39
|
+
TransferDocumentDeletedEvent,
|
|
40
|
+
TransferDocumentSavedEvent,
|
|
41
|
+
TransferDocumentsBuiltEvent,
|
|
42
|
+
TransferDocumentUpdatedEvent
|
|
43
|
+
} from '../data/events';
|
|
38
44
|
import type { ResolvedMessage } from '../messages/primitives';
|
|
39
45
|
import type { Project } from '../project';
|
|
40
46
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
@@ -134,6 +140,10 @@ export interface CapturingDataClient<
|
|
|
134
140
|
readonly updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[];
|
|
135
141
|
/** Every `onDocumentSaved` event, in arrival order. */
|
|
136
142
|
readonly saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[];
|
|
143
|
+
/** Every `onDocumentDeleted` event, in arrival order. */
|
|
144
|
+
readonly deletions: TransferDocumentDeletedEvent[];
|
|
145
|
+
/** Every `onDocumentsBuilt` event, in arrival order. */
|
|
146
|
+
readonly builds: TransferDocumentsBuiltEvent[];
|
|
137
147
|
/** Every `onProjectsChanged` event, in arrival order. */
|
|
138
148
|
readonly projectsChanges: ProjectsChangedEvent<TProject>[];
|
|
139
149
|
}
|
|
@@ -141,7 +151,7 @@ export interface CapturingDataClient<
|
|
|
141
151
|
/**
|
|
142
152
|
* A {@link DataClientProtocol} that records every notification it receives.
|
|
143
153
|
*
|
|
144
|
-
* Recording
|
|
154
|
+
* Recording EVERY channel even when a suite reads one is deliberate: an
|
|
145
155
|
* event delivered on the wrong channel is a real defect of the data head, and a
|
|
146
156
|
* double that drops the other two turns it into silence on the one being
|
|
147
157
|
* watched.
|
|
@@ -158,6 +168,8 @@ export function makeCapturingDataClient<
|
|
|
158
168
|
>(overrides: Partial<DataClientProtocol<TTransfer, TDiagnostic, TProject>> = {}): CapturingDataClient<TTransfer, TDiagnostic, TProject> {
|
|
159
169
|
const updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[] = [];
|
|
160
170
|
const saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[] = [];
|
|
171
|
+
const deletions: TransferDocumentDeletedEvent[] = [];
|
|
172
|
+
const builds: TransferDocumentsBuiltEvent[] = [];
|
|
161
173
|
const projectsChanges: ProjectsChangedEvent<TProject>[] = [];
|
|
162
174
|
const client: DataClientProtocol<TTransfer, TDiagnostic, TProject> = {
|
|
163
175
|
onDocumentUpdated:
|
|
@@ -170,11 +182,21 @@ export function makeCapturingDataClient<
|
|
|
170
182
|
(event => {
|
|
171
183
|
saves.push(event);
|
|
172
184
|
}),
|
|
185
|
+
onDocumentDeleted:
|
|
186
|
+
overrides.onDocumentDeleted ??
|
|
187
|
+
(event => {
|
|
188
|
+
deletions.push(event);
|
|
189
|
+
}),
|
|
190
|
+
onDocumentsBuilt:
|
|
191
|
+
overrides.onDocumentsBuilt ??
|
|
192
|
+
(event => {
|
|
193
|
+
builds.push(event);
|
|
194
|
+
}),
|
|
173
195
|
onProjectsChanged:
|
|
174
196
|
overrides.onProjectsChanged ??
|
|
175
197
|
(event => {
|
|
176
198
|
projectsChanges.push(event);
|
|
177
199
|
})
|
|
178
200
|
};
|
|
179
|
-
return { client, updates, saves, projectsChanges };
|
|
201
|
+
return { client, updates, saves, deletions, builds, projectsChanges };
|
|
180
202
|
}
|