@hydranium/protocol 1.0.0-next.360 → 1.0.0-next.362
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/worker-handshake.d.ts +5 -1
- package/lib/client/worker-handshake.d.ts.map +1 -1
- package/lib/client/worker-handshake.js.map +1 -1
- package/lib/errors.d.ts +41 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +77 -3
- package/lib/errors.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 +2 -1
- package/lib/messages/index.js.map +1 -1
- package/lib/profile-session.d.ts +12 -10
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js +10 -10
- package/lib/profile-session.js.map +1 -1
- package/package.json +1 -1
- package/src/client/worker-handshake.ts +5 -1
- package/src/errors.ts +96 -2
- package/src/messages/index.ts +8 -1
- package/src/profile-session.ts +18 -13
|
@@ -81,7 +81,11 @@ export declare const WORKER_BOOTSTRAP_PHASE = "bootstrap";
|
|
|
81
81
|
export interface WorkerErrorMessage {
|
|
82
82
|
/** The page raises this type too, on its own error event, when the `Worker` fires `error`. */
|
|
83
83
|
readonly type: typeof WORKER_ERROR_MESSAGE_TYPE;
|
|
84
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* What the worker was doing, {@link WORKER_BOOTSTRAP_PHASE} for a failed
|
|
86
|
+
* bootstrap. The page's own report of a `Worker` `error` event carries
|
|
87
|
+
* `WORKER_ERROR_EVENT_PHASE`.
|
|
88
|
+
*/
|
|
85
89
|
readonly phase: string;
|
|
86
90
|
/** The failure described for a log. Never branch on it. */
|
|
87
91
|
readonly message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-handshake.d.ts","sourceRoot":"","sources":["../../src/client/worker-handshake.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;GAmBG;AAEH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.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export declare const HYDRANIUM_ERROR_CODES: {
|
|
|
46
46
|
readonly documentNotOpen: 42005;
|
|
47
47
|
readonly duplicateClientId: 42006;
|
|
48
48
|
readonly reservedClientId: 42007;
|
|
49
|
+
readonly saveFailed: 42008;
|
|
49
50
|
};
|
|
50
51
|
/**
|
|
51
52
|
* JSON-RPC error code for {@link ConflictError}.
|
|
@@ -121,6 +122,8 @@ export declare const DOCUMENT_NOT_OPEN_ERROR_CODE: 42005;
|
|
|
121
122
|
export declare const DUPLICATE_CLIENT_ID_ERROR_CODE: 42006;
|
|
122
123
|
/** JSON-RPC code for {@link ReservedClientIdError}. */
|
|
123
124
|
export declare const RESERVED_CLIENT_ID_ERROR_CODE: 42007;
|
|
125
|
+
/** JSON-RPC code for {@link SaveFailedError}. */
|
|
126
|
+
export declare const SAVE_FAILED_ERROR_CODE: 42008;
|
|
124
127
|
/**
|
|
125
128
|
* The catalogue declaration behind {@link SessionClosedError}'s default
|
|
126
129
|
* sentence. It names no client id: the sentence can reach an end user, and the
|
|
@@ -205,6 +208,30 @@ export declare class ReservedClientIdError extends ResponseError<{
|
|
|
205
208
|
constructor(clientId: string);
|
|
206
209
|
get clientId(): string;
|
|
207
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* The catalogue declaration behind {@link SaveFailedError}'s message. Its
|
|
213
|
+
* `failures` names each document with the writer's own reason, which stays as
|
|
214
|
+
* written.
|
|
215
|
+
*/
|
|
216
|
+
export declare const SAVE_FAILED: import("./messages/primitives").MessageDefinition<"Could not save {failures}.">;
|
|
217
|
+
/** One document a save could not write, and why. */
|
|
218
|
+
export interface SaveFailure {
|
|
219
|
+
readonly uri: string;
|
|
220
|
+
readonly reason: string;
|
|
221
|
+
}
|
|
222
|
+
/** Structured payload carried in {@link SaveFailedError.data}. */
|
|
223
|
+
export interface SaveFailedErrorData extends HydraniumMessageData {
|
|
224
|
+
readonly failures: readonly SaveFailure[];
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Thrown by a save that could not write one or more of its documents. A save
|
|
228
|
+
* of several documents writes the others, so the files on disk can be a mix
|
|
229
|
+
* until a later save succeeds.
|
|
230
|
+
*/
|
|
231
|
+
export declare class SaveFailedError extends ResponseError<SaveFailedErrorData> {
|
|
232
|
+
constructor(failures: readonly SaveFailure[]);
|
|
233
|
+
get failures(): readonly SaveFailure[];
|
|
234
|
+
}
|
|
208
235
|
/**
|
|
209
236
|
* Whether `error` is a `ResponseError` from any copy of `vscode-jsonrpc`. An
|
|
210
237
|
* install holds several copies, and `instanceof` recognises only its own. An
|
|
@@ -219,6 +246,13 @@ export declare function isResponseError(error: unknown): error is ResponseError<
|
|
|
219
246
|
* none of the class getters.
|
|
220
247
|
*/
|
|
221
248
|
export declare function reviveProtocolError(error: unknown): unknown;
|
|
249
|
+
/**
|
|
250
|
+
* The error the JSON text `json` describes, as `JSON.stringify(error.toJson())`
|
|
251
|
+
* writes it, revived to its typed class as {@link reviveProtocolError} does, or
|
|
252
|
+
* `undefined` when `json` is not a JSON-RPC error envelope. For a transport
|
|
253
|
+
* that carries the error as text, such as a GLSP `RejectAction`'s `detail`.
|
|
254
|
+
*/
|
|
255
|
+
export declare function reviveProtocolErrorJson(json: string): ResponseError<unknown> | undefined;
|
|
222
256
|
/**
|
|
223
257
|
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
224
258
|
* when it arrives as a plain `ResponseError`, through a path that does not
|
|
@@ -231,6 +265,13 @@ export declare function isDocumentNotOpenError(error: unknown): error is Documen
|
|
|
231
265
|
export declare function isDuplicateClientIdError(error: unknown): error is DuplicateClientIdError;
|
|
232
266
|
/** Whether `error` is a {@link ReservedClientIdError}; see {@link isSessionClosedError}. */
|
|
233
267
|
export declare function isReservedClientIdError(error: unknown): error is ReservedClientIdError;
|
|
268
|
+
/**
|
|
269
|
+
* Whether `error` is a {@link SaveFailedError} that holds its `failures`: one
|
|
270
|
+
* thrown, or one {@link reviveProtocolError revived}. Unlike the other guards,
|
|
271
|
+
* a bare `ResponseError` with its code is not one, since it has no `failures`
|
|
272
|
+
* to read. Revive it first.
|
|
273
|
+
*/
|
|
274
|
+
export declare function isSaveFailedError(error: unknown): error is SaveFailedError;
|
|
234
275
|
/**
|
|
235
276
|
* Type guard for {@link ConflictError}. Detection ladder:
|
|
236
277
|
*
|
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;AAC9F,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAcnG;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,0IAGrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,0IAGnC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB;aAC/B,QAAQ,EAAE,KAAK;aACf,eAAe,EAAE,KAAK;aACtB,sBAAsB,EAAE,KAAK;aAC7B,aAAa,EAAE,KAAK;aACpB,eAAe,EAAE,KAAK;aACtB,iBAAiB,EAAE,KAAK;aACxB,gBAAgB,EAAE,KAAK;
|
|
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;AAC9F,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAcnG;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,0I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O,GAAG,KAAK,IAAI,qBAAqB,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAI1E;AAWD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAYtE"}
|
package/lib/errors.js
CHANGED
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.ReservedClientIdError = exports.DuplicateClientIdError = exports.DUPLICATE_CLIENT_ID = exports.DocumentNotOpenError = exports.DOCUMENT_NOT_OPEN = exports.SessionClosedError = exports.SESSION_CLOSED = exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.SESSION_CLOSED_ERROR_CODE = exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES = exports.STALE_BASE_VERSION_SAVE = exports.STALE_BASE_VERSION_UPDATE = void 0;
|
|
11
|
+
exports.SaveFailedError = exports.SAVE_FAILED = exports.ReservedClientIdError = exports.DuplicateClientIdError = exports.DUPLICATE_CLIENT_ID = exports.DocumentNotOpenError = exports.DOCUMENT_NOT_OPEN = exports.SessionClosedError = exports.SESSION_CLOSED = exports.SAVE_FAILED_ERROR_CODE = exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.SESSION_CLOSED_ERROR_CODE = exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES = exports.STALE_BASE_VERSION_SAVE = exports.STALE_BASE_VERSION_UPDATE = void 0;
|
|
12
12
|
exports.isResponseError = isResponseError;
|
|
13
13
|
exports.reviveProtocolError = reviveProtocolError;
|
|
14
|
+
exports.reviveProtocolErrorJson = reviveProtocolErrorJson;
|
|
14
15
|
exports.isSessionClosedError = isSessionClosedError;
|
|
15
16
|
exports.isDocumentNotOpenError = isDocumentNotOpenError;
|
|
16
17
|
exports.isDuplicateClientIdError = isDuplicateClientIdError;
|
|
17
18
|
exports.isReservedClientIdError = isReservedClientIdError;
|
|
19
|
+
exports.isSaveFailedError = isSaveFailedError;
|
|
18
20
|
exports.isConflictError = isConflictError;
|
|
19
21
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
20
22
|
const primitives_1 = require("./messages/primitives");
|
|
@@ -66,7 +68,8 @@ exports.HYDRANIUM_ERROR_CODES = {
|
|
|
66
68
|
sessionClosed: 42004,
|
|
67
69
|
documentNotOpen: 42005,
|
|
68
70
|
duplicateClientId: 42006,
|
|
69
|
-
reservedClientId: 42007
|
|
71
|
+
reservedClientId: 42007,
|
|
72
|
+
saveFailed: 42008
|
|
70
73
|
};
|
|
71
74
|
/**
|
|
72
75
|
* JSON-RPC error code for {@link ConflictError}.
|
|
@@ -155,6 +158,8 @@ exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.documentNot
|
|
|
155
158
|
exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.duplicateClientId;
|
|
156
159
|
/** JSON-RPC code for {@link ReservedClientIdError}. */
|
|
157
160
|
exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.reservedClientId;
|
|
161
|
+
/** JSON-RPC code for {@link SaveFailedError}. */
|
|
162
|
+
exports.SAVE_FAILED_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.saveFailed;
|
|
158
163
|
/**
|
|
159
164
|
* The catalogue declaration behind {@link SessionClosedError}'s default
|
|
160
165
|
* sentence. It names no client id: the sentence can reach an end user, and the
|
|
@@ -259,6 +264,32 @@ class ReservedClientIdError extends vscode_jsonrpc_1.ResponseError {
|
|
|
259
264
|
}
|
|
260
265
|
}
|
|
261
266
|
exports.ReservedClientIdError = ReservedClientIdError;
|
|
267
|
+
/**
|
|
268
|
+
* The catalogue declaration behind {@link SaveFailedError}'s message. Its
|
|
269
|
+
* `failures` names each document with the writer's own reason, which stays as
|
|
270
|
+
* written.
|
|
271
|
+
*/
|
|
272
|
+
exports.SAVE_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/save-failed', 'Could not save {failures}.');
|
|
273
|
+
/**
|
|
274
|
+
* Thrown by a save that could not write one or more of its documents. A save
|
|
275
|
+
* of several documents writes the others, so the files on disk can be a mix
|
|
276
|
+
* until a later save succeeds.
|
|
277
|
+
*/
|
|
278
|
+
class SaveFailedError extends vscode_jsonrpc_1.ResponseError {
|
|
279
|
+
constructor(failures) {
|
|
280
|
+
const named = failures.map(failure => `${failure.uri} (${failure.reason})`).join(', ');
|
|
281
|
+
super(exports.SAVE_FAILED_ERROR_CODE, exports.SAVE_FAILED.format({ failures: named }), {
|
|
282
|
+
failures,
|
|
283
|
+
...(0, primitives_1.messageData)(exports.SAVE_FAILED, { failures: named })
|
|
284
|
+
});
|
|
285
|
+
this.name = 'SaveFailedError';
|
|
286
|
+
Object.setPrototypeOf(this, SaveFailedError.prototype);
|
|
287
|
+
}
|
|
288
|
+
get failures() {
|
|
289
|
+
return this.data.failures;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
exports.SaveFailedError = SaveFailedError;
|
|
262
293
|
/** One entry per typed error class, keyed by its code; a class without one reaches a caller as a plain `ResponseError`. */
|
|
263
294
|
const PROTOCOL_ERROR_REVIVERS = new Map([
|
|
264
295
|
[
|
|
@@ -273,8 +304,18 @@ const PROTOCOL_ERROR_REVIVERS = new Map([
|
|
|
273
304
|
({ uri, clientId }) => (typeof uri === 'string' && typeof clientId === 'string' ? new DocumentNotOpenError(uri, clientId) : undefined)
|
|
274
305
|
],
|
|
275
306
|
[exports.DUPLICATE_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new DuplicateClientIdError(clientId) : undefined)],
|
|
276
|
-
[exports.RESERVED_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new ReservedClientIdError(clientId) : undefined)]
|
|
307
|
+
[exports.RESERVED_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new ReservedClientIdError(clientId) : undefined)],
|
|
308
|
+
[exports.SAVE_FAILED_ERROR_CODE, ({ failures }) => (isSaveFailureList(failures) ? new SaveFailedError(failures) : undefined)]
|
|
277
309
|
]);
|
|
310
|
+
function isSaveFailureList(value) {
|
|
311
|
+
return (Array.isArray(value) &&
|
|
312
|
+
value.every((failure) => typeof failure === 'object' &&
|
|
313
|
+
failure !== null &&
|
|
314
|
+
'uri' in failure &&
|
|
315
|
+
typeof failure.uri === 'string' &&
|
|
316
|
+
'reason' in failure &&
|
|
317
|
+
typeof failure.reason === 'string'));
|
|
318
|
+
}
|
|
278
319
|
/**
|
|
279
320
|
* Whether `error` is a `ResponseError` from any copy of `vscode-jsonrpc`. An
|
|
280
321
|
* install holds several copies, and `instanceof` recognises only its own. An
|
|
@@ -300,6 +341,30 @@ function reviveProtocolError(error) {
|
|
|
300
341
|
}
|
|
301
342
|
return Object.assign(revived, { message: error.message, data: error.data, stack: error.stack });
|
|
302
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* The error the JSON text `json` describes, as `JSON.stringify(error.toJson())`
|
|
346
|
+
* writes it, revived to its typed class as {@link reviveProtocolError} does, or
|
|
347
|
+
* `undefined` when `json` is not a JSON-RPC error envelope. For a transport
|
|
348
|
+
* that carries the error as text, such as a GLSP `RejectAction`'s `detail`.
|
|
349
|
+
*/
|
|
350
|
+
function reviveProtocolErrorJson(json) {
|
|
351
|
+
let envelope;
|
|
352
|
+
try {
|
|
353
|
+
envelope = JSON.parse(json);
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
return undefined;
|
|
357
|
+
}
|
|
358
|
+
if (typeof envelope !== 'object' || envelope === null || !('code' in envelope) || !('message' in envelope)) {
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
const { code, message } = envelope;
|
|
362
|
+
if (typeof code !== 'number' || !Number.isInteger(code) || typeof message !== 'string') {
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
const revived = reviveProtocolError(new vscode_jsonrpc_1.ResponseError(code, message, 'data' in envelope ? envelope.data : undefined));
|
|
366
|
+
return isResponseError(revived) ? revived : undefined;
|
|
367
|
+
}
|
|
303
368
|
/**
|
|
304
369
|
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
305
370
|
* when it arrives as a plain `ResponseError`, through a path that does not
|
|
@@ -320,6 +385,15 @@ function isDuplicateClientIdError(error) {
|
|
|
320
385
|
function isReservedClientIdError(error) {
|
|
321
386
|
return hasErrorIdentity(error, 'ReservedClientIdError', exports.RESERVED_CLIENT_ID_ERROR_CODE);
|
|
322
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* Whether `error` is a {@link SaveFailedError} that holds its `failures`: one
|
|
390
|
+
* thrown, or one {@link reviveProtocolError revived}. Unlike the other guards,
|
|
391
|
+
* a bare `ResponseError` with its code is not one, since it has no `failures`
|
|
392
|
+
* to read. Revive it first.
|
|
393
|
+
*/
|
|
394
|
+
function isSaveFailedError(error) {
|
|
395
|
+
return (hasErrorIdentity(error, 'SaveFailedError', exports.SAVE_FAILED_ERROR_CODE) && isSaveFailureList(error.failures));
|
|
396
|
+
}
|
|
323
397
|
function hasErrorIdentity(error, name, code) {
|
|
324
398
|
return error instanceof Error && (error.name === name || error.code === code);
|
|
325
399
|
}
|
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","sour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QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACrG,CAAC"}
|
package/lib/messages/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* The English is a fallback, not a contract; the code is the contract.
|
|
23
23
|
*/
|
|
24
24
|
export * from './primitives';
|
|
25
|
-
export { DOCUMENT_NOT_OPEN, DUPLICATE_CLIENT_ID, SESSION_CLOSED, STALE_BASE_VERSION_SAVE, STALE_BASE_VERSION_UPDATE } from '../errors';
|
|
25
|
+
export { DOCUMENT_NOT_OPEN, DUPLICATE_CLIENT_ID, SAVE_FAILED, SESSION_CLOSED, STALE_BASE_VERSION_SAVE, STALE_BASE_VERSION_UPDATE } from '../errors';
|
|
26
26
|
export { DATA_CONNECTION_SESSION_RESTORE_FAILED, DATA_CONNECTION_WATCH_RESTORE_FAILED } from '../client/data-connection';
|
|
27
27
|
export { DATA_SERVER_CONNECT_FAILED, DATA_SERVER_NOT_READY } from '../client/rpc-connection';
|
|
28
28
|
export { DATA_SESSION_ANSWER_WITHOUT_MODEL, DATA_SESSION_RESTORE_FAILED, DATA_SESSION_UNSAVED_LOST } from '../client/data-session';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;GAcG;AAEH,cAAc,cAAc,CAAC;AAE7B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;GAcG;AAEH,cAAc,cAAc,CAAC;AAE7B,OAAO,EACJ,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sCAAsC,EAAE,oCAAoC,EAAE,MAAM,2BAA2B,CAAC;AACzH,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,iCAAiC,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnI,OAAO,EACJ,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC9B,MAAM,yBAAyB,CAAC"}
|
package/lib/messages/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
22
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.RELAY_TRANSPORT_WRITE_FAILED = exports.RELAY_TRANSPORT_READ_FAILED = exports.RELAY_TRANSPORT_OPEN_FAILED = exports.RELAY_REPLAY_FAILED = exports.DATA_SESSION_UNSAVED_LOST = exports.DATA_SESSION_RESTORE_FAILED = exports.DATA_SESSION_ANSWER_WITHOUT_MODEL = exports.DATA_SERVER_NOT_READY = exports.DATA_SERVER_CONNECT_FAILED = exports.DATA_CONNECTION_WATCH_RESTORE_FAILED = exports.DATA_CONNECTION_SESSION_RESTORE_FAILED = exports.STALE_BASE_VERSION_UPDATE = exports.STALE_BASE_VERSION_SAVE = exports.SESSION_CLOSED = exports.DUPLICATE_CLIENT_ID = exports.DOCUMENT_NOT_OPEN = void 0;
|
|
25
|
+
exports.RELAY_TRANSPORT_WRITE_FAILED = exports.RELAY_TRANSPORT_READ_FAILED = exports.RELAY_TRANSPORT_OPEN_FAILED = exports.RELAY_REPLAY_FAILED = exports.DATA_SESSION_UNSAVED_LOST = exports.DATA_SESSION_RESTORE_FAILED = exports.DATA_SESSION_ANSWER_WITHOUT_MODEL = exports.DATA_SERVER_NOT_READY = exports.DATA_SERVER_CONNECT_FAILED = exports.DATA_CONNECTION_WATCH_RESTORE_FAILED = exports.DATA_CONNECTION_SESSION_RESTORE_FAILED = exports.STALE_BASE_VERSION_UPDATE = exports.STALE_BASE_VERSION_SAVE = exports.SESSION_CLOSED = exports.SAVE_FAILED = exports.DUPLICATE_CLIENT_ID = exports.DOCUMENT_NOT_OPEN = void 0;
|
|
26
26
|
/**
|
|
27
27
|
* The message-externalization mechanism, plus every user-facing message
|
|
28
28
|
* `@hydranium/protocol` itself raises.
|
|
@@ -42,6 +42,7 @@ __exportStar(require("./primitives"), exports);
|
|
|
42
42
|
var errors_1 = require("../errors");
|
|
43
43
|
Object.defineProperty(exports, "DOCUMENT_NOT_OPEN", { enumerable: true, get: function () { return errors_1.DOCUMENT_NOT_OPEN; } });
|
|
44
44
|
Object.defineProperty(exports, "DUPLICATE_CLIENT_ID", { enumerable: true, get: function () { return errors_1.DUPLICATE_CLIENT_ID; } });
|
|
45
|
+
Object.defineProperty(exports, "SAVE_FAILED", { enumerable: true, get: function () { return errors_1.SAVE_FAILED; } });
|
|
45
46
|
Object.defineProperty(exports, "SESSION_CLOSED", { enumerable: true, get: function () { return errors_1.SESSION_CLOSED; } });
|
|
46
47
|
Object.defineProperty(exports, "STALE_BASE_VERSION_SAVE", { enumerable: true, get: function () { return errors_1.STALE_BASE_VERSION_SAVE; } });
|
|
47
48
|
Object.defineProperty(exports, "STALE_BASE_VERSION_UPDATE", { enumerable: true, get: function () { return errors_1.STALE_BASE_VERSION_UPDATE; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;;AAElF;;;;;;;;;;;;;;GAcG;AAEH,+CAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;;AAElF;;;;;;;;;;;;;;GAcG;AAEH,+CAA6B;AAE7B,oCAOmB;AANhB,2GAAA,iBAAiB,OAAA;AACjB,6GAAA,mBAAmB,OAAA;AACnB,qGAAA,WAAW,OAAA;AACX,wGAAA,cAAc,OAAA;AACd,iHAAA,uBAAuB,OAAA;AACvB,mHAAA,yBAAyB,OAAA;AAE5B,6DAAyH;AAAhH,yIAAA,sCAAsC,OAAA;AAAE,uIAAA,oCAAoC,OAAA;AACrF,2DAA6F;AAApF,4HAAA,0BAA0B,OAAA;AAAE,uHAAA,qBAAqB,OAAA;AAC1D,uDAAmI;AAA1H,iIAAA,iCAAiC,OAAA;AAAE,2HAAA,2BAA2B,OAAA;AAAE,yHAAA,yBAAyB,OAAA;AAClG,yDAKiC;AAJ9B,oHAAA,mBAAmB,OAAA;AACnB,4HAAA,2BAA2B,OAAA;AAC3B,4HAAA,2BAA2B,OAAA;AAC3B,6HAAA,4BAA4B,OAAA"}
|
package/lib/profile-session.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ export interface ProfileRecord {
|
|
|
16
16
|
count: number;
|
|
17
17
|
/** Summed self-time across those runs (wall-clock minus nested scopes). */
|
|
18
18
|
selfMs: number;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Self-time as a percentage of the session's total wall-clock. Overlapping
|
|
21
|
+
* scopes each count their own wall time, so the percentages can add up to
|
|
22
|
+
* more than 100.
|
|
23
|
+
*/
|
|
20
24
|
selfPct: number;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
@@ -49,8 +53,9 @@ export interface ProfileSession {
|
|
|
49
53
|
/**
|
|
50
54
|
* Emit the aggregate through the bound {@link Logger}: one line per id,
|
|
51
55
|
* sorted by self-time descending, plus an "unaccounted" remainder (the
|
|
52
|
-
* session wall-clock not attributed to any top-level scope).
|
|
53
|
-
*
|
|
56
|
+
* session wall-clock not attributed to any top-level scope). The remainder
|
|
57
|
+
* is left out when overlapping scopes account for more than the wall-clock.
|
|
58
|
+
* No-op when `logLevel` is suppressed by the global threshold (incl. `'off'`).
|
|
54
59
|
*/
|
|
55
60
|
report(logLevel?: LogThreshold): void;
|
|
56
61
|
/** The same aggregate as structured records, for tests / programmatic use. */
|
|
@@ -79,11 +84,7 @@ export declare class DefaultProfileSession implements ProfileSession {
|
|
|
79
84
|
protected readonly identifier: string;
|
|
80
85
|
/** Single monotonic timeline for the whole session; per-scope readings are deltas off it. */
|
|
81
86
|
protected readonly sessionStopwatch: Stopwatch;
|
|
82
|
-
/**
|
|
83
|
-
* The scopes in flight, innermost last. They must end innermost first:
|
|
84
|
-
* {@link closeFrame} pops the top frame whichever scope ends, so
|
|
85
|
-
* overlapping async scopes misattribute their time.
|
|
86
|
-
*/
|
|
87
|
+
/** The scopes in flight, in the order they started. */
|
|
87
88
|
protected readonly stack: ProfileScopeFrame[];
|
|
88
89
|
/** Self-time in milliseconds per id, one sample per closed scope, which {@link records} sums. */
|
|
89
90
|
protected readonly entries: Map<string, number[]>;
|
|
@@ -91,8 +92,9 @@ export declare class DefaultProfileSession implements ProfileSession {
|
|
|
91
92
|
scope<T>(id: string, fn: () => Promise<T>): Promise<T>;
|
|
92
93
|
scope<T>(id: string, fn: () => T): T;
|
|
93
94
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
95
|
+
* Remove `frame`, charge its full duration to the frame below it, and record
|
|
96
|
+
* its self-time. Overlapping scopes can together outlast the one below
|
|
97
|
+
* them, whose self-time is then zero rather than negative.
|
|
96
98
|
*/
|
|
97
99
|
protected closeFrame(frame: ProfileScopeFrame): void;
|
|
98
100
|
records(): readonly ProfileRecord[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-session.d.ts","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAU,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D,iFAAiF;AACjF,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iF;IACjF,OAAO,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,cAAc;IAStD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAEjC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM;IAVxC,6FAA6F;IAC7F,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,CAAC;IAC/C,uDAAuD;IACvD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,EAAE,CAAM;IACnD,iGAAiG;IACjG,SAAS,CAAC,QAAQ,CAAC,OAAO,wBAA+B;IAEzD,YACsB,MAAM,EAAE,MAAM,EACjC,KAAK,EAAE,KAAK,EACO,UAAU,EAAE,MAAM,EAGvC;IAED,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IA2BrC;;;;OAIG;IACH,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAiBnD;IAED,OAAO,IAAI,SAAS,aAAa,EAAE,CAQlC;IAED,MAAM,CAAC,QAAQ,GAAE,YAAsB,GAAG,IAAI,CAgB7C;CACH"}
|
package/lib/profile-session.js
CHANGED
|
@@ -20,11 +20,7 @@ class DefaultProfileSession {
|
|
|
20
20
|
identifier;
|
|
21
21
|
/** Single monotonic timeline for the whole session; per-scope readings are deltas off it. */
|
|
22
22
|
sessionStopwatch;
|
|
23
|
-
/**
|
|
24
|
-
* The scopes in flight, innermost last. They must end innermost first:
|
|
25
|
-
* {@link closeFrame} pops the top frame whichever scope ends, so
|
|
26
|
-
* overlapping async scopes misattribute their time.
|
|
27
|
-
*/
|
|
23
|
+
/** The scopes in flight, in the order they started. */
|
|
28
24
|
stack = [];
|
|
29
25
|
/** Self-time in milliseconds per id, one sample per closed scope, which {@link records} sums. */
|
|
30
26
|
entries = new Map();
|
|
@@ -57,17 +53,21 @@ class DefaultProfileSession {
|
|
|
57
53
|
return result;
|
|
58
54
|
}
|
|
59
55
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
56
|
+
* Remove `frame`, charge its full duration to the frame below it, and record
|
|
57
|
+
* its self-time. Overlapping scopes can together outlast the one below
|
|
58
|
+
* them, whose self-time is then zero rather than negative.
|
|
62
59
|
*/
|
|
63
60
|
closeFrame(frame) {
|
|
64
|
-
this.stack.
|
|
61
|
+
const index = this.stack.lastIndexOf(frame);
|
|
62
|
+
if (index >= 0) {
|
|
63
|
+
this.stack.splice(index, 1);
|
|
64
|
+
}
|
|
65
65
|
const duration = this.sessionStopwatch.elapsedMs - frame.start;
|
|
66
|
-
const parent = this.stack[
|
|
66
|
+
const parent = index > 0 ? this.stack[index - 1] : undefined;
|
|
67
67
|
if (parent) {
|
|
68
68
|
parent.childMs += duration;
|
|
69
69
|
}
|
|
70
|
-
const selfMs = duration - frame.childMs;
|
|
70
|
+
const selfMs = Math.max(0, duration - frame.childMs);
|
|
71
71
|
const samples = this.entries.get(frame.id);
|
|
72
72
|
if (samples) {
|
|
73
73
|
samples.push(selfMs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-session.js","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,qCAA6D;
|
|
1
|
+
{"version":3,"file":"profile-session.js","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,qCAA6D;AAyE7D;;;;GAIG;AACH;IASyB,MAAM;IAEN,UAAU;IAVhC,6FAA6F;IAC1E,gBAAgB,CAAY;IAC/C,uDAAuD;IACpC,KAAK,GAAwB,EAAE,CAAC;IACnD,iGAAiG;IA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CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,mBAAmB,GAAG,KAAK,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;IACJ,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -102,7 +102,11 @@ export const WORKER_BOOTSTRAP_PHASE = 'bootstrap';
|
|
|
102
102
|
export interface WorkerErrorMessage {
|
|
103
103
|
/** The page raises this type too, on its own error event, when the `Worker` fires `error`. */
|
|
104
104
|
readonly type: typeof WORKER_ERROR_MESSAGE_TYPE;
|
|
105
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* What the worker was doing, {@link WORKER_BOOTSTRAP_PHASE} for a failed
|
|
107
|
+
* bootstrap. The page's own report of a `Worker` `error` event carries
|
|
108
|
+
* `WORKER_ERROR_EVENT_PHASE`.
|
|
109
|
+
*/
|
|
106
110
|
readonly phase: string;
|
|
107
111
|
/** The failure described for a log. Never branch on it. */
|
|
108
112
|
readonly message: string;
|
package/src/errors.ts
CHANGED
|
@@ -67,7 +67,8 @@ export const HYDRANIUM_ERROR_CODES = {
|
|
|
67
67
|
sessionClosed: 42004,
|
|
68
68
|
documentNotOpen: 42005,
|
|
69
69
|
duplicateClientId: 42006,
|
|
70
|
-
reservedClientId: 42007
|
|
70
|
+
reservedClientId: 42007,
|
|
71
|
+
saveFailed: 42008
|
|
71
72
|
} as const;
|
|
72
73
|
|
|
73
74
|
/**
|
|
@@ -179,6 +180,8 @@ export const DOCUMENT_NOT_OPEN_ERROR_CODE = HYDRANIUM_ERROR_CODES.documentNotOpe
|
|
|
179
180
|
export const DUPLICATE_CLIENT_ID_ERROR_CODE = HYDRANIUM_ERROR_CODES.duplicateClientId;
|
|
180
181
|
/** JSON-RPC code for {@link ReservedClientIdError}. */
|
|
181
182
|
export const RESERVED_CLIENT_ID_ERROR_CODE = HYDRANIUM_ERROR_CODES.reservedClientId;
|
|
183
|
+
/** JSON-RPC code for {@link SaveFailedError}. */
|
|
184
|
+
export const SAVE_FAILED_ERROR_CODE = HYDRANIUM_ERROR_CODES.saveFailed;
|
|
182
185
|
|
|
183
186
|
/**
|
|
184
187
|
* The catalogue declaration behind {@link SessionClosedError}'s default
|
|
@@ -314,6 +317,45 @@ export class ReservedClientIdError extends ResponseError<{ readonly clientId: st
|
|
|
314
317
|
}
|
|
315
318
|
}
|
|
316
319
|
|
|
320
|
+
/**
|
|
321
|
+
* The catalogue declaration behind {@link SaveFailedError}'s message. Its
|
|
322
|
+
* `failures` names each document with the writer's own reason, which stays as
|
|
323
|
+
* written.
|
|
324
|
+
*/
|
|
325
|
+
export const SAVE_FAILED = defineMessage('hydranium/protocol/save-failed', 'Could not save {failures}.');
|
|
326
|
+
|
|
327
|
+
/** One document a save could not write, and why. */
|
|
328
|
+
export interface SaveFailure {
|
|
329
|
+
readonly uri: string;
|
|
330
|
+
readonly reason: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Structured payload carried in {@link SaveFailedError.data}. */
|
|
334
|
+
export interface SaveFailedErrorData extends HydraniumMessageData {
|
|
335
|
+
readonly failures: readonly SaveFailure[];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Thrown by a save that could not write one or more of its documents. A save
|
|
340
|
+
* of several documents writes the others, so the files on disk can be a mix
|
|
341
|
+
* until a later save succeeds.
|
|
342
|
+
*/
|
|
343
|
+
export class SaveFailedError extends ResponseError<SaveFailedErrorData> {
|
|
344
|
+
constructor(failures: readonly SaveFailure[]) {
|
|
345
|
+
const named = failures.map(failure => `${failure.uri} (${failure.reason})`).join(', ');
|
|
346
|
+
super(SAVE_FAILED_ERROR_CODE, SAVE_FAILED.format({ failures: named }), {
|
|
347
|
+
failures,
|
|
348
|
+
...messageData(SAVE_FAILED, { failures: named })
|
|
349
|
+
});
|
|
350
|
+
this.name = 'SaveFailedError';
|
|
351
|
+
Object.setPrototypeOf(this, SaveFailedError.prototype);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
get failures(): readonly SaveFailure[] {
|
|
355
|
+
return this.data!.failures;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
317
359
|
/**
|
|
318
360
|
* Rebuilds one typed error from the `data` that crossed the wire, or
|
|
319
361
|
* `undefined` when `data` lacks the fields the class reads.
|
|
@@ -335,9 +377,25 @@ const PROTOCOL_ERROR_REVIVERS: ReadonlyMap<number, ProtocolErrorReviver> = new M
|
|
|
335
377
|
({ uri, clientId }) => (typeof uri === 'string' && typeof clientId === 'string' ? new DocumentNotOpenError(uri, clientId) : undefined)
|
|
336
378
|
],
|
|
337
379
|
[DUPLICATE_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new DuplicateClientIdError(clientId) : undefined)],
|
|
338
|
-
[RESERVED_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new ReservedClientIdError(clientId) : undefined)]
|
|
380
|
+
[RESERVED_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new ReservedClientIdError(clientId) : undefined)],
|
|
381
|
+
[SAVE_FAILED_ERROR_CODE, ({ failures }) => (isSaveFailureList(failures) ? new SaveFailedError(failures) : undefined)]
|
|
339
382
|
]);
|
|
340
383
|
|
|
384
|
+
function isSaveFailureList(value: unknown): value is SaveFailure[] {
|
|
385
|
+
return (
|
|
386
|
+
Array.isArray(value) &&
|
|
387
|
+
value.every(
|
|
388
|
+
(failure: unknown) =>
|
|
389
|
+
typeof failure === 'object' &&
|
|
390
|
+
failure !== null &&
|
|
391
|
+
'uri' in failure &&
|
|
392
|
+
typeof failure.uri === 'string' &&
|
|
393
|
+
'reason' in failure &&
|
|
394
|
+
typeof failure.reason === 'string'
|
|
395
|
+
)
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
341
399
|
/**
|
|
342
400
|
* Whether `error` is a `ResponseError` from any copy of `vscode-jsonrpc`. An
|
|
343
401
|
* install holds several copies, and `instanceof` recognises only its own. An
|
|
@@ -367,6 +425,30 @@ export function reviveProtocolError(error: unknown): unknown {
|
|
|
367
425
|
return Object.assign(revived, { message: error.message, data: error.data, stack: error.stack });
|
|
368
426
|
}
|
|
369
427
|
|
|
428
|
+
/**
|
|
429
|
+
* The error the JSON text `json` describes, as `JSON.stringify(error.toJson())`
|
|
430
|
+
* writes it, revived to its typed class as {@link reviveProtocolError} does, or
|
|
431
|
+
* `undefined` when `json` is not a JSON-RPC error envelope. For a transport
|
|
432
|
+
* that carries the error as text, such as a GLSP `RejectAction`'s `detail`.
|
|
433
|
+
*/
|
|
434
|
+
export function reviveProtocolErrorJson(json: string): ResponseError<unknown> | undefined {
|
|
435
|
+
let envelope: unknown;
|
|
436
|
+
try {
|
|
437
|
+
envelope = JSON.parse(json);
|
|
438
|
+
} catch {
|
|
439
|
+
return undefined;
|
|
440
|
+
}
|
|
441
|
+
if (typeof envelope !== 'object' || envelope === null || !('code' in envelope) || !('message' in envelope)) {
|
|
442
|
+
return undefined;
|
|
443
|
+
}
|
|
444
|
+
const { code, message } = envelope;
|
|
445
|
+
if (typeof code !== 'number' || !Number.isInteger(code) || typeof message !== 'string') {
|
|
446
|
+
return undefined;
|
|
447
|
+
}
|
|
448
|
+
const revived = reviveProtocolError(new ResponseError(code, message, 'data' in envelope ? envelope.data : undefined));
|
|
449
|
+
return isResponseError(revived) ? revived : undefined;
|
|
450
|
+
}
|
|
451
|
+
|
|
370
452
|
/**
|
|
371
453
|
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
372
454
|
* when it arrives as a plain `ResponseError`, through a path that does not
|
|
@@ -391,6 +473,18 @@ export function isReservedClientIdError(error: unknown): error is ReservedClient
|
|
|
391
473
|
return hasErrorIdentity(error, 'ReservedClientIdError', RESERVED_CLIENT_ID_ERROR_CODE);
|
|
392
474
|
}
|
|
393
475
|
|
|
476
|
+
/**
|
|
477
|
+
* Whether `error` is a {@link SaveFailedError} that holds its `failures`: one
|
|
478
|
+
* thrown, or one {@link reviveProtocolError revived}. Unlike the other guards,
|
|
479
|
+
* a bare `ResponseError` with its code is not one, since it has no `failures`
|
|
480
|
+
* to read. Revive it first.
|
|
481
|
+
*/
|
|
482
|
+
export function isSaveFailedError(error: unknown): error is SaveFailedError {
|
|
483
|
+
return (
|
|
484
|
+
hasErrorIdentity(error, 'SaveFailedError', SAVE_FAILED_ERROR_CODE) && isSaveFailureList((error as Partial<SaveFailedError>).failures)
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
394
488
|
function hasErrorIdentity(error: unknown, name: string, code: number): boolean {
|
|
395
489
|
return error instanceof Error && (error.name === name || (error as Partial<ResponseError<unknown>>).code === code);
|
|
396
490
|
}
|
package/src/messages/index.ts
CHANGED
|
@@ -25,7 +25,14 @@
|
|
|
25
25
|
|
|
26
26
|
export * from './primitives';
|
|
27
27
|
|
|
28
|
-
export {
|
|
28
|
+
export {
|
|
29
|
+
DOCUMENT_NOT_OPEN,
|
|
30
|
+
DUPLICATE_CLIENT_ID,
|
|
31
|
+
SAVE_FAILED,
|
|
32
|
+
SESSION_CLOSED,
|
|
33
|
+
STALE_BASE_VERSION_SAVE,
|
|
34
|
+
STALE_BASE_VERSION_UPDATE
|
|
35
|
+
} from '../errors';
|
|
29
36
|
export { DATA_CONNECTION_SESSION_RESTORE_FAILED, DATA_CONNECTION_WATCH_RESTORE_FAILED } from '../client/data-connection';
|
|
30
37
|
export { DATA_SERVER_CONNECT_FAILED, DATA_SERVER_NOT_READY } from '../client/rpc-connection';
|
|
31
38
|
export { DATA_SESSION_ANSWER_WITHOUT_MODEL, DATA_SESSION_RESTORE_FAILED, DATA_SESSION_UNSAVED_LOST } from '../client/data-session';
|
package/src/profile-session.ts
CHANGED
|
@@ -18,7 +18,11 @@ export interface ProfileRecord {
|
|
|
18
18
|
count: number;
|
|
19
19
|
/** Summed self-time across those runs (wall-clock minus nested scopes). */
|
|
20
20
|
selfMs: number;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Self-time as a percentage of the session's total wall-clock. Overlapping
|
|
23
|
+
* scopes each count their own wall time, so the percentages can add up to
|
|
24
|
+
* more than 100.
|
|
25
|
+
*/
|
|
22
26
|
selfPct: number;
|
|
23
27
|
}
|
|
24
28
|
|
|
@@ -53,8 +57,9 @@ export interface ProfileSession {
|
|
|
53
57
|
/**
|
|
54
58
|
* Emit the aggregate through the bound {@link Logger}: one line per id,
|
|
55
59
|
* sorted by self-time descending, plus an "unaccounted" remainder (the
|
|
56
|
-
* session wall-clock not attributed to any top-level scope).
|
|
57
|
-
*
|
|
60
|
+
* session wall-clock not attributed to any top-level scope). The remainder
|
|
61
|
+
* is left out when overlapping scopes account for more than the wall-clock.
|
|
62
|
+
* No-op when `logLevel` is suppressed by the global threshold (incl. `'off'`).
|
|
58
63
|
*/
|
|
59
64
|
report(logLevel?: LogThreshold): void;
|
|
60
65
|
|
|
@@ -84,11 +89,7 @@ export interface ProfileScopeFrame {
|
|
|
84
89
|
export class DefaultProfileSession implements ProfileSession {
|
|
85
90
|
/** Single monotonic timeline for the whole session; per-scope readings are deltas off it. */
|
|
86
91
|
protected readonly sessionStopwatch: Stopwatch;
|
|
87
|
-
/**
|
|
88
|
-
* The scopes in flight, innermost last. They must end innermost first:
|
|
89
|
-
* {@link closeFrame} pops the top frame whichever scope ends, so
|
|
90
|
-
* overlapping async scopes misattribute their time.
|
|
91
|
-
*/
|
|
92
|
+
/** The scopes in flight, in the order they started. */
|
|
92
93
|
protected readonly stack: ProfileScopeFrame[] = [];
|
|
93
94
|
/** Self-time in milliseconds per id, one sample per closed scope, which {@link records} sums. */
|
|
94
95
|
protected readonly entries = new Map<string, number[]>();
|
|
@@ -130,17 +131,21 @@ export class DefaultProfileSession implements ProfileSession {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
134
|
+
* Remove `frame`, charge its full duration to the frame below it, and record
|
|
135
|
+
* its self-time. Overlapping scopes can together outlast the one below
|
|
136
|
+
* them, whose self-time is then zero rather than negative.
|
|
135
137
|
*/
|
|
136
138
|
protected closeFrame(frame: ProfileScopeFrame): void {
|
|
137
|
-
this.stack.
|
|
139
|
+
const index = this.stack.lastIndexOf(frame);
|
|
140
|
+
if (index >= 0) {
|
|
141
|
+
this.stack.splice(index, 1);
|
|
142
|
+
}
|
|
138
143
|
const duration = this.sessionStopwatch.elapsedMs - frame.start;
|
|
139
|
-
const parent = this.stack[
|
|
144
|
+
const parent = index > 0 ? this.stack[index - 1] : undefined;
|
|
140
145
|
if (parent) {
|
|
141
146
|
parent.childMs += duration;
|
|
142
147
|
}
|
|
143
|
-
const selfMs = duration - frame.childMs;
|
|
148
|
+
const selfMs = Math.max(0, duration - frame.childMs);
|
|
144
149
|
const samples = this.entries.get(frame.id);
|
|
145
150
|
if (samples) {
|
|
146
151
|
samples.push(selfMs);
|