@hydranium/client-theia 1.0.0-next.50 → 1.0.0-next.52
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/browser/connection-diagnostics-contribution.d.ts +69 -0
- package/lib/browser/connection-diagnostics-contribution.d.ts.map +1 -0
- package/lib/browser/connection-diagnostics-contribution.js +153 -0
- package/lib/browser/connection-diagnostics-contribution.js.map +1 -0
- package/lib/browser/index.d.ts +2 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +2 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/session-aware-connection-source.d.ts +94 -0
- package/lib/browser/session-aware-connection-source.d.ts.map +1 -0
- package/lib/browser/session-aware-connection-source.js +163 -0
- package/lib/browser/session-aware-connection-source.js.map +1 -0
- package/lib/common/connection-resilience-options.d.ts +24 -0
- package/lib/common/connection-resilience-options.d.ts.map +1 -0
- package/lib/common/connection-resilience-options.js +11 -0
- package/lib/common/connection-resilience-options.js.map +1 -0
- package/lib/common/framed-socket-write-buffer.d.ts +121 -0
- package/lib/common/framed-socket-write-buffer.d.ts.map +1 -0
- package/lib/common/framed-socket-write-buffer.js +176 -0
- package/lib/common/framed-socket-write-buffer.js.map +1 -0
- package/lib/common/index.d.ts +11 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +30 -0
- package/lib/common/index.js.map +1 -0
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/session-bound-frontend-connection-service.d.ts +73 -0
- package/lib/node/session-bound-frontend-connection-service.d.ts.map +1 -0
- package/lib/node/session-bound-frontend-connection-service.js +124 -0
- package/lib/node/session-bound-frontend-connection-service.js.map +1 -0
- package/package.json +12 -3
- package/src/browser/connection-diagnostics-contribution.ts +142 -0
- package/src/browser/index.ts +2 -0
- package/src/browser/session-aware-connection-source.ts +175 -0
- package/src/common/connection-resilience-options.ts +24 -0
- package/src/common/framed-socket-write-buffer.ts +212 -0
- package/src/common/index.ts +14 -0
- package/src/node/index.ts +1 -0
- package/src/node/session-bound-frontend-connection-service.ts +151 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import { MessageService } from '@theia/core';
|
|
10
|
+
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
|
|
11
|
+
import { ConnectionStatus, ConnectionStatusService } from '@theia/core/lib/browser/connection-status-service';
|
|
12
|
+
import { WebSocketConnectionSource } from '@theia/core/lib/browser/messaging/ws-connection-source';
|
|
13
|
+
import { type interfaces } from '@theia/core/shared/inversify';
|
|
14
|
+
import { type ConnectionBufferOverflow } from '../common/framed-socket-write-buffer';
|
|
15
|
+
import { ChannelLogger } from './channel-logger';
|
|
16
|
+
/**
|
|
17
|
+
* Records the browser side of the websocket lifecycle into the adopter's Output
|
|
18
|
+
* channel, and tells the user the one thing they cannot recover from on their
|
|
19
|
+
* own.
|
|
20
|
+
*
|
|
21
|
+
* Theia reports an outage only as an "Offline" status-bar item, which cannot
|
|
22
|
+
* distinguish a plain network drop from the server having stopped answering on a
|
|
23
|
+
* socket that is still up. The latter is what a connection defect looks like
|
|
24
|
+
* from here, so the two are logged differently — that distinction is what says
|
|
25
|
+
* whether reopening an editor helps or only a reload does.
|
|
26
|
+
*
|
|
27
|
+
* Purely observational apart from the overflow message: nothing here changes how
|
|
28
|
+
* the connection behaves.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ConnectionDiagnosticsContribution implements FrontendApplicationContribution {
|
|
31
|
+
protected readonly connectionSource: WebSocketConnectionSource;
|
|
32
|
+
protected readonly connectionStatus: ConnectionStatusService;
|
|
33
|
+
protected readonly logger: ChannelLogger;
|
|
34
|
+
protected readonly messageService: MessageService;
|
|
35
|
+
/** Main channels created so far; more than one means the server did not recognise this frontend. */
|
|
36
|
+
protected channelCount: number;
|
|
37
|
+
protected socketClosedAt?: number;
|
|
38
|
+
protected offlineAt?: number;
|
|
39
|
+
initialize(): void;
|
|
40
|
+
protected handleSocketOpen(): void;
|
|
41
|
+
protected handleSocketClose(): void;
|
|
42
|
+
/**
|
|
43
|
+
* A second channel means the reconnect was refused and the session discarded.
|
|
44
|
+
* Only reachable with `reloadOnReconnect` off — with it on, Theia reloads the
|
|
45
|
+
* page instead of opening another channel.
|
|
46
|
+
*/
|
|
47
|
+
protected handleChannelOpen(): void;
|
|
48
|
+
protected handleStatusChange(status: ConnectionStatus): void;
|
|
49
|
+
/**
|
|
50
|
+
* The outage outlasted what the buffer can hold, so changes made from here on
|
|
51
|
+
* are being thrown away rather than queued. Reconnecting resumes sending but
|
|
52
|
+
* cannot bring those back, which leaves the editor disagreeing with the
|
|
53
|
+
* server — and without a message the user would see nothing but an editor
|
|
54
|
+
* that has quietly stopped saving, so say it plainly.
|
|
55
|
+
*/
|
|
56
|
+
protected handleBufferOverflow(overflow: ConnectionBufferOverflow): void;
|
|
57
|
+
protected socketId(): string;
|
|
58
|
+
protected statusName(status: ConnectionStatus): string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Bind {@link ConnectionDiagnosticsContribution} as a `FrontendApplicationContribution`.
|
|
62
|
+
*
|
|
63
|
+
* Needs a {@link ChannelLogger} binding, so call it from a module that has also
|
|
64
|
+
* called `bindChannelLogger`. Unlike `bindConnectionResilience` this belongs in a
|
|
65
|
+
* normal frontend module: it only observes, so it has no reason to run during
|
|
66
|
+
* preload, and `MessageService` is not available that early.
|
|
67
|
+
*/
|
|
68
|
+
export declare function bindConnectionDiagnostics(bind: interfaces.Bind): void;
|
|
69
|
+
//# sourceMappingURL=connection-diagnostics-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-diagnostics-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/connection-diagnostics-contribution.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,cAAc,EAAO,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2DAA2D,CAAC;AAC5G,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,wDAAwD,CAAC;AACnG,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD;;;;;;;;;;;;;GAaG;AACH,qBACa,iCAAkC,YAAW,+BAA+B;IACnD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAC;IACjE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;IACvE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAE1E,oGAAoG;IACpG,SAAS,CAAC,YAAY,SAAK;IAC3B,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE7B,UAAU,IAAI,IAAI;IAalB,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAMlC,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAKnC;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAYnC,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAmB5D;;;;;;OAMG;IACH,SAAS,CAAC,oBAAoB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI;IAUxE,SAAS,CAAC,QAAQ,IAAI,MAAM;IAI5B,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM;CAGxD;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,GAAG,IAAI,CAGrE"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the MIT License which is available in the project root.
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
};
|
|
16
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.ConnectionDiagnosticsContribution = void 0;
|
|
21
|
+
exports.bindConnectionDiagnostics = bindConnectionDiagnostics;
|
|
22
|
+
const core_1 = require("@theia/core");
|
|
23
|
+
const frontend_application_contribution_1 = require("@theia/core/lib/browser/frontend-application-contribution");
|
|
24
|
+
const connection_status_service_1 = require("@theia/core/lib/browser/connection-status-service");
|
|
25
|
+
const ws_connection_source_1 = require("@theia/core/lib/browser/messaging/ws-connection-source");
|
|
26
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
27
|
+
const channel_logger_1 = require("./channel-logger");
|
|
28
|
+
const session_aware_connection_source_1 = require("./session-aware-connection-source");
|
|
29
|
+
/**
|
|
30
|
+
* Records the browser side of the websocket lifecycle into the adopter's Output
|
|
31
|
+
* channel, and tells the user the one thing they cannot recover from on their
|
|
32
|
+
* own.
|
|
33
|
+
*
|
|
34
|
+
* Theia reports an outage only as an "Offline" status-bar item, which cannot
|
|
35
|
+
* distinguish a plain network drop from the server having stopped answering on a
|
|
36
|
+
* socket that is still up. The latter is what a connection defect looks like
|
|
37
|
+
* from here, so the two are logged differently — that distinction is what says
|
|
38
|
+
* whether reopening an editor helps or only a reload does.
|
|
39
|
+
*
|
|
40
|
+
* Purely observational apart from the overflow message: nothing here changes how
|
|
41
|
+
* the connection behaves.
|
|
42
|
+
*/
|
|
43
|
+
let ConnectionDiagnosticsContribution = class ConnectionDiagnosticsContribution {
|
|
44
|
+
connectionSource;
|
|
45
|
+
connectionStatus;
|
|
46
|
+
logger;
|
|
47
|
+
messageService;
|
|
48
|
+
/** Main channels created so far; more than one means the server did not recognise this frontend. */
|
|
49
|
+
channelCount = 0;
|
|
50
|
+
socketClosedAt;
|
|
51
|
+
offlineAt;
|
|
52
|
+
initialize() {
|
|
53
|
+
this.connectionSource.onSocketDidOpen(() => this.handleSocketOpen());
|
|
54
|
+
this.connectionSource.onSocketDidClose(() => this.handleSocketClose());
|
|
55
|
+
this.connectionSource.onConnectionDidOpen(() => this.handleChannelOpen());
|
|
56
|
+
this.connectionStatus.onStatusChange(status => this.handleStatusChange(status));
|
|
57
|
+
if (this.connectionSource instanceof session_aware_connection_source_1.SessionAwareConnectionSource) {
|
|
58
|
+
this.connectionSource.onBufferOverflow(overflow => this.handleBufferOverflow(overflow));
|
|
59
|
+
}
|
|
60
|
+
// The socket is opened by the preloader, before this contribution exists, so the first
|
|
61
|
+
// `onSocketDidOpen` has already fired; state the current situation instead.
|
|
62
|
+
this.logger.info(`diagnostics active; socket ${this.socketId()}, backend ${this.statusName(this.connectionStatus.currentStatus)}`);
|
|
63
|
+
}
|
|
64
|
+
handleSocketOpen() {
|
|
65
|
+
const downFor = this.socketClosedAt === undefined ? '' : ` after ${Date.now() - this.socketClosedAt} ms down`;
|
|
66
|
+
this.socketClosedAt = undefined;
|
|
67
|
+
this.logger.info(`websocket connected: socket ${this.socketId()}${downFor}`);
|
|
68
|
+
}
|
|
69
|
+
handleSocketClose() {
|
|
70
|
+
this.socketClosedAt = Date.now();
|
|
71
|
+
this.logger.info(`websocket disconnected: socket ${this.socketId()}; outgoing messages are buffered until it returns`);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A second channel means the reconnect was refused and the session discarded.
|
|
75
|
+
* Only reachable with `reloadOnReconnect` off — with it on, Theia reloads the
|
|
76
|
+
* page instead of opening another channel.
|
|
77
|
+
*/
|
|
78
|
+
handleChannelOpen() {
|
|
79
|
+
this.channelCount++;
|
|
80
|
+
if (this.channelCount === 1) {
|
|
81
|
+
this.logger.info(`initial channel opened on socket ${this.socketId()}`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.logger.warn(`new channel #${this.channelCount} on socket ${this.socketId()}: the backend did not recognise this frontend, ` +
|
|
85
|
+
'so its session was discarded and every pending request rejected');
|
|
86
|
+
}
|
|
87
|
+
handleStatusChange(status) {
|
|
88
|
+
if (status === connection_status_service_1.ConnectionStatus.ONLINE) {
|
|
89
|
+
const offlineFor = this.offlineAt === undefined ? '' : ` after ${Date.now() - this.offlineAt} ms`;
|
|
90
|
+
this.offlineAt = undefined;
|
|
91
|
+
this.logger.info(`backend reachable again${offlineFor}`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.offlineAt = Date.now();
|
|
95
|
+
const socket = this.connectionSource.socket;
|
|
96
|
+
if (socket?.connected) {
|
|
97
|
+
this.logger.warn(`backend stopped answering while socket ${socket.id} is still connected: nothing this session sends will ` +
|
|
98
|
+
'arrive, and socket.io will not reconnect on its own. Reload the page to recover.');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.logger.info(`backend unreachable; websocket is disconnected (socket ${this.socketId()})`);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The outage outlasted what the buffer can hold, so changes made from here on
|
|
105
|
+
* are being thrown away rather than queued. Reconnecting resumes sending but
|
|
106
|
+
* cannot bring those back, which leaves the editor disagreeing with the
|
|
107
|
+
* server — and without a message the user would see nothing but an editor
|
|
108
|
+
* that has quietly stopped saving, so say it plainly.
|
|
109
|
+
*/
|
|
110
|
+
handleBufferOverflow(overflow) {
|
|
111
|
+
this.logger.error(`buffer full at ${overflow.maxBytes} bytes holding ${overflow.messages} message(s)`);
|
|
112
|
+
this.messageService.error(core_1.nls.localize('hydranium/connection/offlineLimitReached', 'Disconnected for too long: recent changes were not sent. Reload the page before continuing.'));
|
|
113
|
+
}
|
|
114
|
+
socketId() {
|
|
115
|
+
return this.connectionSource.socket?.id ?? ws_connection_source_1.WebSocketConnectionSource.NO_CONNECTION;
|
|
116
|
+
}
|
|
117
|
+
statusName(status) {
|
|
118
|
+
return status === connection_status_service_1.ConnectionStatus.ONLINE ? 'online' : 'offline';
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
exports.ConnectionDiagnosticsContribution = ConnectionDiagnosticsContribution;
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, inversify_1.inject)(ws_connection_source_1.WebSocketConnectionSource),
|
|
124
|
+
__metadata("design:type", ws_connection_source_1.WebSocketConnectionSource)
|
|
125
|
+
], ConnectionDiagnosticsContribution.prototype, "connectionSource", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
(0, inversify_1.inject)(connection_status_service_1.ConnectionStatusService),
|
|
128
|
+
__metadata("design:type", Object)
|
|
129
|
+
], ConnectionDiagnosticsContribution.prototype, "connectionStatus", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
(0, inversify_1.inject)(channel_logger_1.ChannelLogger),
|
|
132
|
+
__metadata("design:type", channel_logger_1.ChannelLogger)
|
|
133
|
+
], ConnectionDiagnosticsContribution.prototype, "logger", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, inversify_1.inject)(core_1.MessageService),
|
|
136
|
+
__metadata("design:type", core_1.MessageService)
|
|
137
|
+
], ConnectionDiagnosticsContribution.prototype, "messageService", void 0);
|
|
138
|
+
exports.ConnectionDiagnosticsContribution = ConnectionDiagnosticsContribution = __decorate([
|
|
139
|
+
(0, inversify_1.injectable)()
|
|
140
|
+
], ConnectionDiagnosticsContribution);
|
|
141
|
+
/**
|
|
142
|
+
* Bind {@link ConnectionDiagnosticsContribution} as a `FrontendApplicationContribution`.
|
|
143
|
+
*
|
|
144
|
+
* Needs a {@link ChannelLogger} binding, so call it from a module that has also
|
|
145
|
+
* called `bindChannelLogger`. Unlike `bindConnectionResilience` this belongs in a
|
|
146
|
+
* normal frontend module: it only observes, so it has no reason to run during
|
|
147
|
+
* preload, and `MessageService` is not available that early.
|
|
148
|
+
*/
|
|
149
|
+
function bindConnectionDiagnostics(bind) {
|
|
150
|
+
bind(ConnectionDiagnosticsContribution).toSelf().inSingletonScope();
|
|
151
|
+
bind(frontend_application_contribution_1.FrontendApplicationContribution).toService(ConnectionDiagnosticsContribution);
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=connection-diagnostics-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-diagnostics-contribution.js","sourceRoot":"","sources":["../../src/browser/connection-diagnostics-contribution.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;AAmIlF,8DAGC;AApID,sCAAkD;AAClD,iHAA4G;AAC5G,iGAA8G;AAC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C;AAED;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CAAC,IAAqB;IAC5D,IAAI,CAAC,iCAAiC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACpE,IAAI,CAAC,mEAA+B,CAAC,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC;AACtF,CAAC"}
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -10,4 +10,6 @@ export * from './channel-logger';
|
|
|
10
10
|
export * from './log-level-preference';
|
|
11
11
|
export * from './browser-capture';
|
|
12
12
|
export * from './memory-diagnostics-contribution';
|
|
13
|
+
export * from './session-aware-connection-source';
|
|
14
|
+
export * from './connection-diagnostics-contribution';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC"}
|
package/lib/browser/index.js
CHANGED
|
@@ -27,4 +27,6 @@ __exportStar(require("./channel-logger"), exports);
|
|
|
27
27
|
__exportStar(require("./log-level-preference"), exports);
|
|
28
28
|
__exportStar(require("./browser-capture"), exports);
|
|
29
29
|
__exportStar(require("./memory-diagnostics-contribution"), exports);
|
|
30
|
+
__exportStar(require("./session-aware-connection-source"), exports);
|
|
31
|
+
__exportStar(require("./connection-diagnostics-contribution"), exports);
|
|
30
32
|
//# sourceMappingURL=index.js.map
|
package/lib/browser/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,gFAAgF;AAChF,mDAAiC;AACjC,yDAAuC;AACvC,oDAAkC;AAClC,oEAAkD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,gFAAgF;AAChF,mDAAiC;AACjC,yDAAuC;AACvC,oDAAkC;AAClC,oEAAkD;AAClD,oEAAkD;AAClD,wEAAsD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import { WebSocketConnectionSource } from '@theia/core/lib/browser/messaging/ws-connection-source';
|
|
10
|
+
import { type Event } from '@theia/core/lib/common/event';
|
|
11
|
+
import { type AbstractChannel } from '@theia/core/lib/common/message-rpc/channel';
|
|
12
|
+
import { type interfaces } from '@theia/core/shared/inversify';
|
|
13
|
+
import { type ConnectionResilienceOptions } from '../common/connection-resilience-options';
|
|
14
|
+
import { type ConnectionBufferOverflow, FramedSocketWriteBuffer } from '../common/framed-socket-write-buffer';
|
|
15
|
+
/**
|
|
16
|
+
* Sends a message only once the server has confirmed the session, and only
|
|
17
|
+
* behind anything already queued.
|
|
18
|
+
*
|
|
19
|
+
* Theia sends straight away when `socket.connected` is true and buffers
|
|
20
|
+
* otherwise. The gap is that reconnecting sets that flag immediately, while the
|
|
21
|
+
* session is only confirmed a round trip later. A message produced in that
|
|
22
|
+
* window either jumps ahead of older messages still waiting in the buffer, or,
|
|
23
|
+
* if nothing was waiting, goes out on a socket whose channel the server has not
|
|
24
|
+
* attached yet and is discarded by a peer with no listener for it.
|
|
25
|
+
*
|
|
26
|
+
* Losing one or reordering them is equally unrecoverable for anything that
|
|
27
|
+
* applies messages by position. Theia's plugin host keeps a line-indexed copy of
|
|
28
|
+
* every open document, so a single late or missing edit leaves that copy wrong
|
|
29
|
+
* for good, and the next edit past its end fails.
|
|
30
|
+
*
|
|
31
|
+
* The server side needs no equivalent: it adopts its socket and flushes in one
|
|
32
|
+
* synchronous step, so it has no window of this kind.
|
|
33
|
+
*/
|
|
34
|
+
export declare class SessionAwareConnectionSource extends WebSocketConnectionSource {
|
|
35
|
+
/**
|
|
36
|
+
* Whether the server has confirmed, on the socket in use right now, that it
|
|
37
|
+
* still holds this frontend's session. A connected socket is not enough:
|
|
38
|
+
* until the handshake is answered the server has not attached its channel to
|
|
39
|
+
* this socket, and a message sent meanwhile reaches a peer with no listener
|
|
40
|
+
* for it and is discarded without a trace.
|
|
41
|
+
*/
|
|
42
|
+
protected sessionResumed: boolean;
|
|
43
|
+
protected sessionListenersAttached: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Every connect starts a socket the server has not confirmed yet, including
|
|
46
|
+
* the reconnects socket.io performs on its own. Resetting here rather than on
|
|
47
|
+
* disconnect also covers a connect that follows no clean disconnect event.
|
|
48
|
+
*/
|
|
49
|
+
protected handleSocketConnected(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Watches the connection handshake for its outcome.
|
|
52
|
+
*
|
|
53
|
+
* Attached once, to the socket socket.io reuses across reconnects, and before
|
|
54
|
+
* the base class adds its own per-negotiation listeners — so this has already
|
|
55
|
+
* recorded the outcome by the time the base class reacts to it by flushing.
|
|
56
|
+
*/
|
|
57
|
+
protected trackSessionState(): void;
|
|
58
|
+
/** Whether a message may go out now, as opposed to waiting in the buffer. */
|
|
59
|
+
protected get canSend(): boolean;
|
|
60
|
+
protected createChannel(): AbstractChannel;
|
|
61
|
+
/** Fires when the buffer runs out of room, so an adopter can say so rather than just stopping. */
|
|
62
|
+
get onBufferOverflow(): Event<ConnectionBufferOverflow>;
|
|
63
|
+
/**
|
|
64
|
+
* The write buffer Theia injected into the base class.
|
|
65
|
+
*
|
|
66
|
+
* Reached through a structural view rather than as `this.writeBuffer`,
|
|
67
|
+
* because that member is `private` in Theia 1.70 and only became `protected`
|
|
68
|
+
* in 1.71 — and this package compiles against the whole range. The view
|
|
69
|
+
* asserts nothing the versions disagree about: the field is there in both,
|
|
70
|
+
* holding whatever `SocketWriteBuffer` is bound, and the check below is what
|
|
71
|
+
* establishes it is ours.
|
|
72
|
+
*/
|
|
73
|
+
protected get framedBuffer(): FramedSocketWriteBuffer;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Replaces the frontend pieces that decide how outgoing messages survive a
|
|
77
|
+
* reconnect. Every one of them rebinds something Theia's
|
|
78
|
+
* `messagingFrontendModule` already bound, so this belongs in a module loaded
|
|
79
|
+
* into the same container.
|
|
80
|
+
*
|
|
81
|
+
* It must be a `frontendPreload` module rather than a normal frontend module:
|
|
82
|
+
* Theia's preloader resolves `WebSocketConnectionSource` (and with it the write
|
|
83
|
+
* buffer) while loading i18n and OS settings, which happens before any frontend
|
|
84
|
+
* module is loaded. A rebind there would come too late — the instances would
|
|
85
|
+
* already exist. All `frontendPreload` modules, by contrast, are loaded before
|
|
86
|
+
* the preloader constructs anything.
|
|
87
|
+
*
|
|
88
|
+
* Does nothing but warn on a Theia too old to expose the buffer binding, so the
|
|
89
|
+
* package keeps one supported range rather than splitting its floor for this
|
|
90
|
+
* feature. Returns whether the hardening was installed, for an adopter that
|
|
91
|
+
* wants to branch on it.
|
|
92
|
+
*/
|
|
93
|
+
export declare function bindConnectionResilience(isBound: interfaces.IsBound, rebind: interfaces.Rebind, options?: ConnectionResilienceOptions): boolean;
|
|
94
|
+
//# sourceMappingURL=session-aware-connection-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-aware-connection-source.d.ts","sourceRoot":"","sources":["../../src/browser/session-aware-connection-source.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,yBAAyB,EAAE,MAAM,wDAAwD,CAAC;AAEnG,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,4CAA4C,CAAC;AAGrG,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE3E,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EACJ,KAAK,wBAAwB,EAE7B,uBAAuB,EAGzB,MAAM,sCAAsC,CAAC;AAE9C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBACa,4BAA6B,SAAQ,yBAAyB;IACxE;;;;;;OAMG;IACH,SAAS,CAAC,cAAc,UAAS;IACjC,SAAS,CAAC,wBAAwB,UAAS;IAE3C;;;;OAIG;cACgB,qBAAqB,IAAI,IAAI;IAMhD;;;;;;OAMG;IACH,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAanC,6EAA6E;IAC7E,SAAS,KAAK,OAAO,IAAI,OAAO,CAE/B;cAEkB,aAAa,IAAI,eAAe;IA0BnD,kGAAkG;IAClG,IAAI,gBAAgB,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAEtD;IAED;;;;;;;;;OASG;IACH,SAAS,KAAK,YAAY,IAAI,uBAAuB,CAMpD;CACH;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACrC,OAAO,EAAE,UAAU,CAAC,OAAO,EAC3B,MAAM,EAAE,UAAU,CAAC,MAAM,EACzB,OAAO,GAAE,2BAAgC,GACzC,OAAO,CAST"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the MIT License which is available in the project root.
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SessionAwareConnectionSource = void 0;
|
|
18
|
+
exports.bindConnectionResilience = bindConnectionResilience;
|
|
19
|
+
const ws_connection_source_1 = require("@theia/core/lib/browser/messaging/ws-connection-source");
|
|
20
|
+
const disposable_1 = require("@theia/core/lib/common/disposable");
|
|
21
|
+
const channel_1 = require("@theia/core/lib/common/message-rpc/channel");
|
|
22
|
+
const uint8_array_message_buffer_1 = require("@theia/core/lib/common/message-rpc/uint8-array-message-buffer");
|
|
23
|
+
const connection_management_1 = require("@theia/core/lib/common/messaging/connection-management");
|
|
24
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
25
|
+
const socket_write_buffer_1 = require("@theia/core/lib/common/messaging/socket-write-buffer");
|
|
26
|
+
const framed_socket_write_buffer_1 = require("../common/framed-socket-write-buffer");
|
|
27
|
+
/**
|
|
28
|
+
* Sends a message only once the server has confirmed the session, and only
|
|
29
|
+
* behind anything already queued.
|
|
30
|
+
*
|
|
31
|
+
* Theia sends straight away when `socket.connected` is true and buffers
|
|
32
|
+
* otherwise. The gap is that reconnecting sets that flag immediately, while the
|
|
33
|
+
* session is only confirmed a round trip later. A message produced in that
|
|
34
|
+
* window either jumps ahead of older messages still waiting in the buffer, or,
|
|
35
|
+
* if nothing was waiting, goes out on a socket whose channel the server has not
|
|
36
|
+
* attached yet and is discarded by a peer with no listener for it.
|
|
37
|
+
*
|
|
38
|
+
* Losing one or reordering them is equally unrecoverable for anything that
|
|
39
|
+
* applies messages by position. Theia's plugin host keeps a line-indexed copy of
|
|
40
|
+
* every open document, so a single late or missing edit leaves that copy wrong
|
|
41
|
+
* for good, and the next edit past its end fails.
|
|
42
|
+
*
|
|
43
|
+
* The server side needs no equivalent: it adopts its socket and flushes in one
|
|
44
|
+
* synchronous step, so it has no window of this kind.
|
|
45
|
+
*/
|
|
46
|
+
let SessionAwareConnectionSource = class SessionAwareConnectionSource extends ws_connection_source_1.WebSocketConnectionSource {
|
|
47
|
+
/**
|
|
48
|
+
* Whether the server has confirmed, on the socket in use right now, that it
|
|
49
|
+
* still holds this frontend's session. A connected socket is not enough:
|
|
50
|
+
* until the handshake is answered the server has not attached its channel to
|
|
51
|
+
* this socket, and a message sent meanwhile reaches a peer with no listener
|
|
52
|
+
* for it and is discarded without a trace.
|
|
53
|
+
*/
|
|
54
|
+
sessionResumed = false;
|
|
55
|
+
sessionListenersAttached = false;
|
|
56
|
+
/**
|
|
57
|
+
* Every connect starts a socket the server has not confirmed yet, including
|
|
58
|
+
* the reconnects socket.io performs on its own. Resetting here rather than on
|
|
59
|
+
* disconnect also covers a connect that follows no clean disconnect event.
|
|
60
|
+
*/
|
|
61
|
+
handleSocketConnected() {
|
|
62
|
+
this.trackSessionState();
|
|
63
|
+
this.sessionResumed = false;
|
|
64
|
+
super.handleSocketConnected();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Watches the connection handshake for its outcome.
|
|
68
|
+
*
|
|
69
|
+
* Attached once, to the socket socket.io reuses across reconnects, and before
|
|
70
|
+
* the base class adds its own per-negotiation listeners — so this has already
|
|
71
|
+
* recorded the outcome by the time the base class reacts to it by flushing.
|
|
72
|
+
*/
|
|
73
|
+
trackSessionState() {
|
|
74
|
+
if (this.sessionListenersAttached) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.sessionListenersAttached = true;
|
|
78
|
+
this.socket.on(connection_management_1.ConnectionManagementMessages.INITIAL_CONNECT, () => {
|
|
79
|
+
this.sessionResumed = true;
|
|
80
|
+
});
|
|
81
|
+
this.socket.on(connection_management_1.ConnectionManagementMessages.RECONNECT, (hasConnection) => {
|
|
82
|
+
this.sessionResumed = hasConnection;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** Whether a message may go out now, as opposed to waiting in the buffer. */
|
|
86
|
+
get canSend() {
|
|
87
|
+
return this.socket.connected && this.sessionResumed;
|
|
88
|
+
}
|
|
89
|
+
createChannel() {
|
|
90
|
+
const toDispose = new disposable_1.DisposableCollection();
|
|
91
|
+
const messageHandler = (data) => {
|
|
92
|
+
this.onIncomingMessageActivityEmitter.fire();
|
|
93
|
+
if (this.currentChannel) {
|
|
94
|
+
// socket.io hands binary over as ArrayBuffer in the browser.
|
|
95
|
+
const buffer = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
|
|
96
|
+
this.currentChannel.onMessageEmitter.fire(() => new uint8_array_message_buffer_1.Uint8ArrayReadBuffer(buffer));
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
this.socket.on('message', messageHandler);
|
|
100
|
+
toDispose.push(disposable_1.Disposable.create(() => this.socket.off('message', messageHandler)));
|
|
101
|
+
return new channel_1.ForwardingChannel('any', () => toDispose.dispose(), () => {
|
|
102
|
+
const result = new uint8_array_message_buffer_1.Uint8ArrayWriteBuffer();
|
|
103
|
+
// Says only whether the session can carry a message; the buffer decides whether it may
|
|
104
|
+
// go ahead of anything already waiting.
|
|
105
|
+
result.onCommit(buffer => this.framedBuffer.sendOrQueue(this.canSend ? this.socket : undefined, buffer));
|
|
106
|
+
return result;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/** Fires when the buffer runs out of room, so an adopter can say so rather than just stopping. */
|
|
110
|
+
get onBufferOverflow() {
|
|
111
|
+
return this.framedBuffer.onOverflow;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The write buffer Theia injected into the base class.
|
|
115
|
+
*
|
|
116
|
+
* Reached through a structural view rather than as `this.writeBuffer`,
|
|
117
|
+
* because that member is `private` in Theia 1.70 and only became `protected`
|
|
118
|
+
* in 1.71 — and this package compiles against the whole range. The view
|
|
119
|
+
* asserts nothing the versions disagree about: the field is there in both,
|
|
120
|
+
* holding whatever `SocketWriteBuffer` is bound, and the check below is what
|
|
121
|
+
* establishes it is ours.
|
|
122
|
+
*/
|
|
123
|
+
get framedBuffer() {
|
|
124
|
+
const buffer = this.writeBuffer;
|
|
125
|
+
if (!(buffer instanceof framed_socket_write_buffer_1.FramedSocketWriteBuffer)) {
|
|
126
|
+
throw new Error('SessionAwareConnectionSource requires FramedSocketWriteBuffer to be bound');
|
|
127
|
+
}
|
|
128
|
+
return buffer;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
exports.SessionAwareConnectionSource = SessionAwareConnectionSource;
|
|
132
|
+
exports.SessionAwareConnectionSource = SessionAwareConnectionSource = __decorate([
|
|
133
|
+
(0, inversify_1.injectable)()
|
|
134
|
+
], SessionAwareConnectionSource);
|
|
135
|
+
/**
|
|
136
|
+
* Replaces the frontend pieces that decide how outgoing messages survive a
|
|
137
|
+
* reconnect. Every one of them rebinds something Theia's
|
|
138
|
+
* `messagingFrontendModule` already bound, so this belongs in a module loaded
|
|
139
|
+
* into the same container.
|
|
140
|
+
*
|
|
141
|
+
* It must be a `frontendPreload` module rather than a normal frontend module:
|
|
142
|
+
* Theia's preloader resolves `WebSocketConnectionSource` (and with it the write
|
|
143
|
+
* buffer) while loading i18n and OS settings, which happens before any frontend
|
|
144
|
+
* module is loaded. A rebind there would come too late — the instances would
|
|
145
|
+
* already exist. All `frontendPreload` modules, by contrast, are loaded before
|
|
146
|
+
* the preloader constructs anything.
|
|
147
|
+
*
|
|
148
|
+
* Does nothing but warn on a Theia too old to expose the buffer binding, so the
|
|
149
|
+
* package keeps one supported range rather than splitting its floor for this
|
|
150
|
+
* feature. Returns whether the hardening was installed, for an adopter that
|
|
151
|
+
* wants to branch on it.
|
|
152
|
+
*/
|
|
153
|
+
function bindConnectionResilience(isBound, rebind, options = {}) {
|
|
154
|
+
if (!(0, framed_socket_write_buffer_1.supportsConnectionResilience)(isBound)) {
|
|
155
|
+
(0, framed_socket_write_buffer_1.warnConnectionResilienceUnavailable)('frontend');
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
// Scopes are kept as Theia declares them: one buffer per connection source, one shared socket owner.
|
|
159
|
+
rebind(socket_write_buffer_1.SocketWriteBuffer).toDynamicValue(() => (0, framed_socket_write_buffer_1.createFramedSocketWriteBuffer)(options.bufferBytes));
|
|
160
|
+
rebind(ws_connection_source_1.WebSocketConnectionSource).to(SessionAwareConnectionSource).inSingletonScope();
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=session-aware-connection-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-aware-connection-source.js","sourceRoot":"","sources":["../../src/browser/session-aware-connection-source.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;AA0JlF,4DAaC;AArKD,iGAAmG;AACnG,kEAAqF;AAErF,wEAAqG;AACrG,8GAA4H;AAC5H,kGAAsG;AACtG,4DAA2E;AAC3E,8FAAyF;AAEzF,qFAM8C;AAE9C;;;;;;;;;;;;;;;;;;GAkBG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,gDAAyB;IACxE;;;;;;OAMG;IACO,cAAc,GAAG,KAAK,CAAC;IACvB,wBAAwB,GAAG,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AC,IAAA,yDAA4B,EAAC,OAAO,CAAC,EAAE,CAAC;QAC1C,IAAA,gEAAmC,EAAC,UAAU,CAAC,CAAC;QAChD,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,qGAAqG;IACrG,MAAM,CAAC,uCAAiB,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,IAAA,0DAA6B,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACnG,MAAM,CAAC,gDAAyB,CAAC,CAAC,EAAE,CAAC,4BAA4B,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACtF,OAAO,IAAI,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
/**
|
|
10
|
+
* Options for the `bindConnectionResilience` helper each tier exports.
|
|
11
|
+
*
|
|
12
|
+
* Lives in `common` rather than beside either helper so the server entry can
|
|
13
|
+
* name the type without importing the browser module, and the other way round.
|
|
14
|
+
*/
|
|
15
|
+
export interface ConnectionResilienceOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Size of the buffer holding messages while the socket is down, in bytes.
|
|
18
|
+
* Defaults to Theia's own limit. It decides how long an outage can last
|
|
19
|
+
* before changes start being rejected, so a deployment on a poor network
|
|
20
|
+
* trades memory for tolerance here.
|
|
21
|
+
*/
|
|
22
|
+
readonly bufferBytes?: number;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=connection-resilience-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-resilience-options.d.ts","sourceRoot":"","sources":["../../src/common/connection-resilience-options.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAChC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the MIT License which is available in the project root.
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
//# sourceMappingURL=connection-resilience-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-resilience-options.js","sourceRoot":"","sources":["../../src/common/connection-resilience-options.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF"}
|