@hydranium/client-theia 1.0.0-next.15 → 1.0.0-next.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -6
- package/lib/browser/channel-logger.d.ts +4 -3
- package/lib/browser/channel-logger.d.ts.map +1 -1
- package/lib/browser/channel-logger.js +9 -4
- package/lib/browser/channel-logger.js.map +1 -1
- 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/editor-disk-sync.d.ts +133 -0
- package/lib/browser/editor-disk-sync.d.ts.map +1 -0
- package/lib/browser/editor-disk-sync.js +232 -0
- package/lib/browser/editor-disk-sync.js.map +1 -0
- package/lib/browser/hydranium-file-service.d.ts +44 -0
- package/lib/browser/hydranium-file-service.d.ts.map +1 -0
- package/lib/browser/hydranium-file-service.js +61 -0
- package/lib/browser/hydranium-file-service.js.map +1 -0
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +4 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/log-level-preference.d.ts.map +1 -1
- package/lib/browser/log-level-preference.js +11 -0
- package/lib/browser/log-level-preference.js.map +1 -1
- package/lib/browser/memory-diagnostics-contribution.d.ts +40 -4
- package/lib/browser/memory-diagnostics-contribution.d.ts.map +1 -1
- package/lib/browser/memory-diagnostics-contribution.js +161 -31
- package/lib/browser/memory-diagnostics-contribution.js.map +1 -1
- package/lib/browser/session-aware-connection-source.d.ts +98 -0
- package/lib/browser/session-aware-connection-source.d.ts.map +1 -0
- package/lib/browser/session-aware-connection-source.js +167 -0
- package/lib/browser/session-aware-connection-source.js.map +1 -0
- package/lib/common/clock.d.ts +19 -0
- package/lib/common/clock.d.ts.map +1 -0
- package/lib/common/clock.js +13 -0
- package/lib/common/clock.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 +190 -0
- package/lib/common/framed-socket-write-buffer.js.map +1 -0
- package/lib/common/index.d.ts +12 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +31 -0
- package/lib/common/index.js.map +1 -0
- package/lib/node/abstract-socket-forwarding-connection-handler.d.ts +8 -7
- package/lib/node/abstract-socket-forwarding-connection-handler.d.ts.map +1 -1
- package/lib/node/abstract-socket-forwarding-connection-handler.js +28 -7
- package/lib/node/abstract-socket-forwarding-connection-handler.js.map +1 -1
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +2 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/session-bound-frontend-connection-service.d.ts +77 -0
- package/lib/node/session-bound-frontend-connection-service.d.ts.map +1 -0
- package/lib/node/session-bound-frontend-connection-service.js +128 -0
- package/lib/node/session-bound-frontend-connection-service.js.map +1 -0
- package/lib/node/socket-channel-forwarder.d.ts +54 -0
- package/lib/node/socket-channel-forwarder.d.ts.map +1 -0
- package/lib/node/socket-channel-forwarder.js +93 -0
- package/lib/node/socket-channel-forwarder.js.map +1 -0
- package/package.json +20 -5
- package/src/browser/channel-logger.ts +9 -4
- package/src/browser/connection-diagnostics-contribution.ts +142 -0
- package/src/browser/editor-disk-sync.ts +236 -0
- package/src/browser/hydranium-file-service.ts +56 -0
- package/src/browser/index.ts +4 -0
- package/src/browser/log-level-preference.ts +11 -0
- package/src/browser/memory-diagnostics-contribution.ts +268 -45
- package/src/browser/session-aware-connection-source.ts +179 -0
- package/src/common/clock.ts +20 -0
- package/src/common/connection-resilience-options.ts +24 -0
- package/src/common/framed-socket-write-buffer.ts +227 -0
- package/src/common/index.ts +15 -0
- package/src/node/abstract-socket-forwarding-connection-handler.ts +19 -9
- package/src/node/index.ts +2 -0
- package/src/node/session-bound-frontend-connection-service.ts +155 -0
- package/src/node/socket-channel-forwarder.ts +99 -0
package/README.md
CHANGED
|
@@ -32,6 +32,21 @@ hydranium server; a non-Theia host does not need it.
|
|
|
32
32
|
(Backend) — register only when the optional `HostMemoryDiagnosticsService` is
|
|
33
33
|
bound. You bind `MemoryDiagnosticsService` to your own connected data-server
|
|
34
34
|
frontend; the framework cannot, because that class is yours.
|
|
35
|
+
- **`EditorDiskSync`** — keeps a dirty editor's save from applying edits its
|
|
36
|
+
file already holds, as the file does once the server saves a document the
|
|
37
|
+
editor shows unsaved. Before each save of the editor it drops the edits the
|
|
38
|
+
file holds, so the save writes only the rest, a save participant's included;
|
|
39
|
+
on each watched change of the file to the editor's text it marks the editor
|
|
40
|
+
clean. Theia otherwise keeps the editor dirty, and its next save applies the
|
|
41
|
+
editor's edits to a file that already holds them. You bind it as a
|
|
42
|
+
`FrontendApplicationContribution`.
|
|
43
|
+
- **`HydraniumFileService`** — Theia's `FileService`, refusing an editor's
|
|
44
|
+
incremental save once the file's mtime has moved past the one the editor
|
|
45
|
+
read, so the editor writes its whole text instead. Theia's own check passes a
|
|
46
|
+
file of unchanged size, and the save then applies the editor's edits to a
|
|
47
|
+
file that may already hold them; `write` keeps Theia's check. The safety net
|
|
48
|
+
behind `EditorDiskSync`, for a save the sync cannot catch. You bind it with
|
|
49
|
+
`rebind(FileService).to(HydraniumFileService).inSingletonScope()`.
|
|
35
50
|
- **`captureBrowserRuntime` / `formatBrowserRuntime`** — the renderer's own memory
|
|
36
51
|
reading as a `BrowserRuntimeReport`, preferring the standardized
|
|
37
52
|
`performance.measureUserAgentSpecificMemory()` and falling back to Chromium's
|
|
@@ -43,6 +58,14 @@ hydranium server; a non-Theia host does not need it.
|
|
|
43
58
|
forwarder bridges the two; port discovery, connect orchestration, and the
|
|
44
59
|
buffer-and-replay fix for frontend writes that arrive before the forwarder is
|
|
45
60
|
wired all live here.
|
|
61
|
+
- **`SocketChannelForwarder`** (Node side) — the byte forwarder both heads plug
|
|
62
|
+
into that hook. When the frontend channel closes, it finishes the writes it
|
|
63
|
+
still has queued before it ends the socket, so a message sent just before a
|
|
64
|
+
page goes away still reaches the server.
|
|
65
|
+
- **`Clock`** (either side) — the protocol's `Clock` as an injection token.
|
|
66
|
+
The frontend and backend classes above that time or bound something inject
|
|
67
|
+
it as optional and use a `SystemClock` when the container binds none, so a
|
|
68
|
+
container can supply another clock.
|
|
46
69
|
- **`./testing`** — `makeStubOutputChannelManager` and `makeStubInversifyContext`,
|
|
47
70
|
the doubles that let the pieces above be unit-tested without a Theia
|
|
48
71
|
application.
|
|
@@ -60,8 +83,11 @@ declared peer dependencies are:
|
|
|
60
83
|
| --------------------- | ------------- |
|
|
61
84
|
| `@hydranium/protocol` | `^1.0.0-next` |
|
|
62
85
|
| `@theia/core` | `^1.70.0` |
|
|
86
|
+
| `@theia/editor` | `^1.70.0` |
|
|
87
|
+
| `@theia/filesystem` | `^1.70.0` |
|
|
63
88
|
| `@theia/output` | `^1.70.0` |
|
|
64
89
|
| `inversify` | `^6.0.0` |
|
|
90
|
+
| `vscode-jsonrpc` | `9.0.1` |
|
|
65
91
|
|
|
66
92
|
`@theia/output` is easy to miss: the memory-diagnostics commands and the channel
|
|
67
93
|
logger both write to an Output channel, so a host that does not already depend on
|
|
@@ -86,12 +112,13 @@ from here:
|
|
|
86
112
|
|
|
87
113
|
## Entry points
|
|
88
114
|
|
|
89
|
-
| Subpath | Holds
|
|
90
|
-
| ----------- |
|
|
91
|
-
| `.` | Nothing. Deliberately empty, so an environment-specific import cannot reach the wrong bundle through a barrel.
|
|
92
|
-
| `./browser` | `ChannelLogger`, `ChannelTracer`, `LogLevelPreferenceContribution`, `MemoryDiagnosticsContribution`, the `bind*` helpers, `captureBrowserRuntime`
|
|
93
|
-
| `./
|
|
94
|
-
| `./
|
|
115
|
+
| Subpath | Holds | Environment |
|
|
116
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
|
|
117
|
+
| `.` | Nothing. Deliberately empty, so an environment-specific import cannot reach the wrong bundle through a barrel. | browser-neutral (gated) |
|
|
118
|
+
| `./browser` | `ChannelLogger`, `ChannelTracer`, `LogLevelPreferenceContribution`, `MemoryDiagnosticsContribution`, `EditorDiskSync`, `HydraniumFileService`, the `bind*` helpers, `captureBrowserRuntime` | browser / Theia frontend (gated) |
|
|
119
|
+
| `./common` | `Clock`, the framed socket write buffer and the connection-resilience options | browser-neutral (gated) |
|
|
120
|
+
| `./node` | `AbstractSocketForwardingConnectionHandler` and its options, `SocketChannelForwarder` — imports `node:net` | Node / Theia backend |
|
|
121
|
+
| `./testing` | `makeStubOutputChannelManager`, `makeStubInversifyContext` | browser-neutral (gated) |
|
|
95
122
|
|
|
96
123
|
Every subpath also has a `./lib/<name>` twin, so a consumer on
|
|
97
124
|
`moduleResolution: "Node"` can reach it. "Gated" means the entry is enforced
|
|
@@ -61,9 +61,10 @@ export declare class ChannelLogger extends AbstractLogger {
|
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Inversify token for the browser `Tracer` — a {@link DefaultTracer} over
|
|
64
|
-
* the {@link ChannelLogger} (emit sink) +
|
|
65
|
-
*
|
|
66
|
-
*
|
|
64
|
+
* the {@link ChannelLogger} (emit sink) + the container's {@link Clock}, or a
|
|
65
|
+
* `SystemClock` when it binds none, + a browser heap reader. The browser head
|
|
66
|
+
* has no Langium `services.Tracer` slot, so this is how frontend services that
|
|
67
|
+
* time obtain a tracer: `@inject(ChannelTracer)`.
|
|
67
68
|
* Bound by {@link bindChannelLogger}.
|
|
68
69
|
*/
|
|
69
70
|
export declare const ChannelTracer: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-logger.d.ts","sourceRoot":"","sources":["../../src/browser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AE,MAAM,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI;IAOhG;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAQ3C;AAOD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,eAA0B,CAAC;AAErD;gDACgD;AAChD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,CAOpF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAc5F"}
|
|
@@ -26,6 +26,7 @@ exports.bindChannelLogger = bindChannelLogger;
|
|
|
26
26
|
const protocol_1 = require("@hydranium/protocol");
|
|
27
27
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
28
28
|
const output_channel_1 = require("@theia/output/lib/browser/output-channel");
|
|
29
|
+
const clock_1 = require("../common/clock");
|
|
29
30
|
/** Inversify token for the {@link ChannelLoggerOptions} constant (merged with the
|
|
30
31
|
* interface name — the standard Theia "type + token under one identifier" idiom). */
|
|
31
32
|
exports.ChannelLoggerOptions = Symbol('ChannelLoggerOptions');
|
|
@@ -89,9 +90,10 @@ exports.ChannelLogger = ChannelLogger = __decorate([
|
|
|
89
90
|
const ChannelLoggerBase = Symbol('ChannelLoggerBase');
|
|
90
91
|
/**
|
|
91
92
|
* Inversify token for the browser `Tracer` — a {@link DefaultTracer} over
|
|
92
|
-
* the {@link ChannelLogger} (emit sink) +
|
|
93
|
-
*
|
|
94
|
-
*
|
|
93
|
+
* the {@link ChannelLogger} (emit sink) + the container's {@link Clock}, or a
|
|
94
|
+
* `SystemClock` when it binds none, + a browser heap reader. The browser head
|
|
95
|
+
* has no Langium `services.Tracer` slot, so this is how frontend services that
|
|
96
|
+
* time obtain a tracer: `@inject(ChannelTracer)`.
|
|
95
97
|
* Bound by {@link bindChannelLogger}.
|
|
96
98
|
*/
|
|
97
99
|
exports.ChannelTracer = Symbol('ChannelTracer');
|
|
@@ -127,7 +129,10 @@ function bindChannelLogger(bind, options) {
|
|
|
127
129
|
return parentName ? base.for(parentName) : base;
|
|
128
130
|
});
|
|
129
131
|
bind(exports.ChannelTracer)
|
|
130
|
-
.toDynamicValue(ctx =>
|
|
132
|
+
.toDynamicValue(ctx => {
|
|
133
|
+
const clock = ctx.container.isBound(clock_1.Clock) ? ctx.container.get(clock_1.Clock) : new protocol_1.SystemClock();
|
|
134
|
+
return new protocol_1.DefaultTracer(ctx.container.get(ChannelLoggerBase), clock, readBrowserMemory);
|
|
135
|
+
})
|
|
131
136
|
.inSingletonScope();
|
|
132
137
|
}
|
|
133
138
|
/** Browser heap reader for {@link ChannelTracer}, backed by Chromium's non-standard `performance.memory`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-logger.js","sourceRoot":"","sources":["../../src/browser/channel-logger.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"channel-logger.js","sourceRoot":"","sources":["../../src/browser/channel-logger.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;AAoGlF,oDAOC;AAeD,8CAcC;AAtID,kDAAmH;AACnH,4DAA8F;AAC9F,6EAAoG;AACpG,2CAAwC;AAkBxC;sFACsF;AACzE,QAAA,oBAAoB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,yBAAc;IAIM;IACA;IAJ1C,QAAQ,CAAiB;IAEnC,YACoD,cAAoC,EACpC,OAA6B,EACjE,YAAgC,OAAO,CAAC,SAAS;QAE9D,KAAK,CAAC,SAAS,CAAC,CAAC;QAJgC,mBAAc,GAAd,cAAc,CAAsB;QACpC,YAAO,GAAP,OAAO,CA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AAC,CAAC,IAAI,sBAAW,EAAE,CAAC;QACjG,OAAO,IAAI,wBAAa,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;IAC3G,CAAC,CAAC;SACD,gBAAgB,EAAE,CAAC;AAC1B,CAAC;AAMD,6GAA6G;AAC7G,MAAM,iBAAiB,GAAiB,GAAG,EAAE;IAC1C,MAAM,GAAG,GAAI,WAA8C,CAAC,MAAM,CAAC;IACnE,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,cAAc,EAAE,UAAU,EAAE,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,CAAC,CAAC;AAEF,SAAS,YAAY,CAAC,GAAY;IAC/B,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,GAAG,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACN,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;AACJ,CAAC"}
|
|
@@ -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;AAC9G,iGAAmG;AACnG,4DAAmF;AAEnF,qDAAiD;AACjD,uFAAiF;AAEjF;;;;;;;;;;;;;GAaG;AAEI,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IACW,gBAAgB,CAA4B;IAC9C,gBAAgB,CAA0B;IACpD,MAAM,CAAgB;IACrB,cAAc,CAAiB;IAE1E,oGAAoG;IAC1F,YAAY,GAAG,CAAC,CAAC;IACjB,cAAc,CAAU;IACxB,SAAS,CAAU;IAE7B,UAAU;QACP,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,i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EAC1C,6FAA6F,CAC/F,CACH,CAAC;IACL,CAAC;IAES,QAAQ;QACf,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,IAAI,gDAAyB,CAAC,aAAa,CAAC;IACtF,CAAC;IAES,UAAU,CAAC,MAAwB;QAC1C,OAAO,MAAM,KAAK,4CAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACpE,CAAC;CACH,CAAA;AA/FY,8EAAiC;AACW;IAArD,IAAA,kBAAM,EAAC,gDAAyB,CAAC;8BAAsC,gDAAyB;2EAAC;AAC9C;IAAnD,IAAA,kBAAM,EAAC,mDAAuB,CAAC;;2EAA8D;AACpD;IAAzC,IAAA,kBAAM,EAAC,8BAAa,CAAC;8BAA4B,8BAAa;iEAAC;AACrB;IAA1C,IAAA,kBAAM,EAAC,qBAAc,CAAC;8BAAoC,qBAAc;yEAAC;4CAJhE,iCAAiC;IAD7C,IAAA,sBAAU,GAAE;GACA,iCAAiC,CA+F7C;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"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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 type { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
10
|
+
import { ILogger } from '@theia/core/lib/common/logger';
|
|
11
|
+
import URI from '@theia/core/lib/common/uri';
|
|
12
|
+
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
13
|
+
import type { EditorWidget } from '@theia/editor/lib/browser/editor-widget';
|
|
14
|
+
import type { FileResourceVersion } from '@theia/filesystem/lib/browser/file-resource';
|
|
15
|
+
import { FileService, type TextFileContent } from '@theia/filesystem/lib/browser/file-service';
|
|
16
|
+
import { Clock } from '../common/clock';
|
|
17
|
+
/**
|
|
18
|
+
* The members of Theia's Monaco editor model {@link EditorDiskSync} reads and
|
|
19
|
+
* resets. `contentChanges`, `resourceVersion` and `run` are `protected` there,
|
|
20
|
+
* so {@link isResyncableEditorDocument} checks for them at runtime: a Theia
|
|
21
|
+
* that renames them yields a document it refuses, and the sync then leaves it
|
|
22
|
+
* alone.
|
|
23
|
+
*/
|
|
24
|
+
export interface ResyncableEditorDocument {
|
|
25
|
+
readonly uri: string;
|
|
26
|
+
readonly dirty: boolean;
|
|
27
|
+
getText(): string;
|
|
28
|
+
revert(options: {
|
|
29
|
+
soft: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
/** The edits the next save applies to the file, in place of the whole text. */
|
|
32
|
+
readonly contentChanges: unknown[];
|
|
33
|
+
/** The file version the next save expects to find on disk. */
|
|
34
|
+
resourceVersion: FileResourceVersion | undefined;
|
|
35
|
+
/** Queue `operation` behind the model's saves and syncs in progress. */
|
|
36
|
+
run(operation: () => Promise<void>): Promise<void>;
|
|
37
|
+
/** Awaited by each save before it takes the pending edits. */
|
|
38
|
+
onModelWillSaveModel(listener: () => Promise<void>): {
|
|
39
|
+
dispose(): void;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Whether `document` carries the members of {@link ResyncableEditorDocument}. */
|
|
43
|
+
export declare function isResyncableEditorDocument(document: object): document is ResyncableEditorDocument;
|
|
44
|
+
/**
|
|
45
|
+
* Keeps a dirty editor's save from applying edits its file already holds, as
|
|
46
|
+
* the file does once the server saves a document the editor shows unsaved.
|
|
47
|
+
*
|
|
48
|
+
* Theia keeps such an editor dirty, and its next save corrupts the file: the
|
|
49
|
+
* save applies the editor's pending edits to the file rather than writing the
|
|
50
|
+
* whole text, and the file already holds them, so each is applied twice.
|
|
51
|
+
* Theia's check that the file has not changed since the editor read it passes
|
|
52
|
+
* whenever the new file has the old one's size, so no conflict is reported. A
|
|
53
|
+
* revert alone keeps the pending edits.
|
|
54
|
+
*
|
|
55
|
+
* Before each save of the editor it reads the file. When the file holds the
|
|
56
|
+
* text the buffer held as the save began, it drops the edits pending then and
|
|
57
|
+
* has the save expect the file's version, so the save writes only the edits
|
|
58
|
+
* made after that point, a save participant's included, onto the file as it
|
|
59
|
+
* is. The save is not cancelled: it completes and is reported as saved. Save
|
|
60
|
+
* All relies on this check, since it saves a diagram and then an editor on the
|
|
61
|
+
* same file at once, before the file watcher has reported the diagram's write.
|
|
62
|
+
* The buffer is taken when the save calls its will-save listeners. Theia runs
|
|
63
|
+
* its save participants one after another, each behind an await, and its
|
|
64
|
+
* first one awaits before it edits, so none has changed the buffer by then. A
|
|
65
|
+
* participant ordered ahead of it that edits before its first await makes the
|
|
66
|
+
* file and the taken text differ, and the save applies every edit again.
|
|
67
|
+
*
|
|
68
|
+
* On each change the file watcher reports, it marks the editor clean when the
|
|
69
|
+
* file holds exactly its buffer. The file is compared with the buffer after
|
|
70
|
+
* it has been read, and the editor is marked in the same step, so a keystroke
|
|
71
|
+
* made while the file was read leaves the editor dirty. This sync waits behind
|
|
72
|
+
* a save in flight: that save drops the edits it sent from the pending ones
|
|
73
|
+
* when it finishes, and a sync before then would have it drop the edits typed
|
|
74
|
+
* meanwhile.
|
|
75
|
+
*
|
|
76
|
+
* An editor whose file holds neither text is left to Theia's own save,
|
|
77
|
+
* same-size gap included, and so is one whose file cannot be read within
|
|
78
|
+
* {@link readTimeoutMs}, or whose check throws.
|
|
79
|
+
*
|
|
80
|
+
* The adopter binds it as a `FrontendApplicationContribution`.
|
|
81
|
+
*/
|
|
82
|
+
export declare class EditorDiskSync implements FrontendApplicationContribution {
|
|
83
|
+
protected readonly fileService: FileService;
|
|
84
|
+
protected readonly editorManager: EditorManager;
|
|
85
|
+
protected readonly logger: ILogger;
|
|
86
|
+
/** Times {@link readTimeoutMs}: the container's {@link Clock}, or a `SystemClock`. */
|
|
87
|
+
protected readonly clock: Clock;
|
|
88
|
+
/** Whether an editor's document has failed {@link isResyncableEditorDocument}; warned of once. */
|
|
89
|
+
protected warnedUnsyncable: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* How long a check waits for the file. The editor's save, and every later
|
|
92
|
+
* save and sync of that editor, waits for the check.
|
|
93
|
+
*/
|
|
94
|
+
protected readTimeoutMs: number;
|
|
95
|
+
onStart(): void;
|
|
96
|
+
/** Check `widget`'s document before each of its saves, for as long as the widget lives. */
|
|
97
|
+
protected guardSaves(widget: EditorWidget): void;
|
|
98
|
+
/** Check each dirty document an editor shows on `uri`, behind that document's save in flight. */
|
|
99
|
+
protected checkFile(uri: URI): void;
|
|
100
|
+
/** Read the file of `document` if it is dirty, and sync it if the file holds its buffer. */
|
|
101
|
+
protected syncIfOnDisk(document: ResyncableEditorDocument): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Before a save of `document`, drop the edits pending now if its file holds
|
|
104
|
+
* the buffer as it is now, and take the file's version. The buffer and the
|
|
105
|
+
* count are taken before the first await, while the save is still calling
|
|
106
|
+
* its will-save listeners; an edit made after that stays pending, and the
|
|
107
|
+
* save writes it onto the file.
|
|
108
|
+
*/
|
|
109
|
+
protected dropChangesOnDisk(document: ResyncableEditorDocument): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* The file of `document`, or `undefined` when it is gone, cannot be read, or
|
|
112
|
+
* is not read within {@link readTimeoutMs}.
|
|
113
|
+
*/
|
|
114
|
+
protected readFile(document: ResyncableEditorDocument): Promise<TextFileContent | undefined>;
|
|
115
|
+
/**
|
|
116
|
+
* Run `check`, and log its failure rather than pass it on. A will-save
|
|
117
|
+
* listener that rejects makes Theia drop the save without writing, and a
|
|
118
|
+
* sync that rejects goes unhandled.
|
|
119
|
+
*/
|
|
120
|
+
protected isolate(check: () => Promise<void>): Promise<void>;
|
|
121
|
+
/** The dirty documents open in an editor on `uri`, each once however many editors show it. */
|
|
122
|
+
protected dirtyDocuments(uri: URI): ResyncableEditorDocument[];
|
|
123
|
+
/** `document` if it carries the members the sync resets; otherwise `undefined`, warned of once. */
|
|
124
|
+
protected resyncable(document: object): ResyncableEditorDocument | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Take `version` as the file `document` was last saved to, with nothing
|
|
127
|
+
* pending, and mark it clean. Synchronous throughout: a soft revert only
|
|
128
|
+
* marks the document clean, and reads nothing. The revert also cancels a
|
|
129
|
+
* save queued behind the sync, which would have written the same text.
|
|
130
|
+
*/
|
|
131
|
+
protected syncFromDisk(document: ResyncableEditorDocument, version: FileResourceVersion): void;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=editor-disk-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-disk-sync.d.ts","sourceRoot":"","sources":["../../src/browser/editor-disk-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACtC,QAAQ,CAAC,GAAG,EAAE,MA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