@theia/dev-container 1.48.0
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 +43 -0
- package/lib/dev-container-server/dev-container-server.d.ts +2 -0
- package/lib/dev-container-server/dev-container-server.d.ts.map +1 -0
- package/lib/dev-container-server/dev-container-server.js +48 -0
- package/lib/dev-container-server/dev-container-server.js.map +1 -0
- package/lib/electron-browser/container-connection-contribution.d.ts +22 -0
- package/lib/electron-browser/container-connection-contribution.d.ts.map +1 -0
- package/lib/electron-browser/container-connection-contribution.js +106 -0
- package/lib/electron-browser/container-connection-contribution.js.map +1 -0
- package/lib/electron-browser/container-output-provider.d.ts +8 -0
- package/lib/electron-browser/container-output-provider.d.ts.map +1 -0
- package/lib/electron-browser/container-output-provider.js +41 -0
- package/lib/electron-browser/container-output-provider.js.map +1 -0
- package/lib/electron-browser/dev-container-frontend-module.d.ts +4 -0
- package/lib/electron-browser/dev-container-frontend-module.d.ts.map +1 -0
- package/lib/electron-browser/dev-container-frontend-module.js +33 -0
- package/lib/electron-browser/dev-container-frontend-module.js.map +1 -0
- package/lib/electron-common/container-output-provider.d.ts +4 -0
- package/lib/electron-common/container-output-provider.d.ts.map +1 -0
- package/lib/electron-common/container-output-provider.js +18 -0
- package/lib/electron-common/container-output-provider.js.map +1 -0
- package/lib/electron-common/remote-container-connection-provider.d.ts +27 -0
- package/lib/electron-common/remote-container-connection-provider.d.ts.map +1 -0
- package/lib/electron-common/remote-container-connection-provider.js +21 -0
- package/lib/electron-common/remote-container-connection-provider.js.map +1 -0
- package/lib/electron-node/dev-container-backend-module.d.ts +5 -0
- package/lib/electron-node/dev-container-backend-module.d.ts.map +1 -0
- package/lib/electron-node/dev-container-backend-module.js +44 -0
- package/lib/electron-node/dev-container-backend-module.js.map +1 -0
- package/lib/electron-node/dev-container-file-service.d.ts +10 -0
- package/lib/electron-node/dev-container-file-service.d.ts.map +1 -0
- package/lib/electron-node/dev-container-file-service.js +73 -0
- package/lib/electron-node/dev-container-file-service.js.map +1 -0
- package/lib/electron-node/devcontainer-contributions/main-container-creation-contributions.d.ts +29 -0
- package/lib/electron-node/devcontainer-contributions/main-container-creation-contributions.d.ts.map +1 -0
- package/lib/electron-node/devcontainer-contributions/main-container-creation-contributions.js +133 -0
- package/lib/electron-node/devcontainer-contributions/main-container-creation-contributions.js.map +1 -0
- package/lib/electron-node/devcontainer-file.d.ts +323 -0
- package/lib/electron-node/devcontainer-file.d.ts.map +1 -0
- package/lib/electron-node/devcontainer-file.js +18 -0
- package/lib/electron-node/devcontainer-file.js.map +1 -0
- package/lib/electron-node/docker-container-service.d.ts +23 -0
- package/lib/electron-node/docker-container-service.d.ts.map +1 -0
- package/lib/electron-node/docker-container-service.js +114 -0
- package/lib/electron-node/docker-container-service.js.map +1 -0
- package/lib/electron-node/remote-container-connection-provider.d.ts +74 -0
- package/lib/electron-node/remote-container-connection-provider.d.ts.map +1 -0
- package/lib/electron-node/remote-container-connection-provider.js +241 -0
- package/lib/electron-node/remote-container-connection-provider.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +26 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +55 -0
- package/src/dev-container-server/dev-container-server.ts +53 -0
- package/src/electron-browser/container-connection-contribution.ts +103 -0
- package/src/electron-browser/container-output-provider.ts +36 -0
- package/src/electron-browser/dev-container-frontend-module.ts +33 -0
- package/src/electron-common/container-output-provider.ts +19 -0
- package/src/electron-common/remote-container-connection-provider.ts +49 -0
- package/src/electron-node/dev-container-backend-module.ts +47 -0
- package/src/electron-node/dev-container-file-service.ts +72 -0
- package/src/electron-node/devcontainer-contributions/main-container-creation-contributions.ts +140 -0
- package/src/electron-node/devcontainer-file.ts +380 -0
- package/src/electron-node/docker-container-service.ts +124 -0
- package/src/electron-node/remote-container-connection-provider.ts +294 -0
- package/src/package.spec.ts +28 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 Typefox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DockerContainerService = exports.ContainerCreationContribution = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const core_1 = require("@theia/core");
|
|
21
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
+
const common_1 = require("@theia/workspace/lib/common");
|
|
23
|
+
const fs = require("@theia/core/shared/fs-extra");
|
|
24
|
+
const dev_container_file_service_1 = require("./dev-container-file-service");
|
|
25
|
+
exports.ContainerCreationContribution = Symbol('ContainerCreationContributions');
|
|
26
|
+
let DockerContainerService = class DockerContainerService {
|
|
27
|
+
async getOrCreateContainer(docker, devcontainerFile, lastContainerInfo, outputProvider) {
|
|
28
|
+
let container;
|
|
29
|
+
const workspace = new core_1.URI(await this.workspaceServer.getMostRecentlyUsedWorkspace());
|
|
30
|
+
if (lastContainerInfo && fs.statSync(devcontainerFile).mtimeMs < lastContainerInfo.lastUsed) {
|
|
31
|
+
try {
|
|
32
|
+
container = docker.getContainer(lastContainerInfo.id);
|
|
33
|
+
if ((await container.inspect()).State.Running) {
|
|
34
|
+
await container.restart();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
await container.start();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
container = undefined;
|
|
42
|
+
console.warn('DevContainer: could not find last used container');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!container) {
|
|
46
|
+
container = await this.buildContainer(docker, devcontainerFile, workspace, outputProvider);
|
|
47
|
+
}
|
|
48
|
+
return container;
|
|
49
|
+
}
|
|
50
|
+
async buildContainer(docker, devcontainerFile, workspace, outputProvider) {
|
|
51
|
+
const devcontainerConfig = await this.devContainerFileService.getConfiguration(devcontainerFile);
|
|
52
|
+
if (!devcontainerConfig) {
|
|
53
|
+
// TODO add ability for user to create new config
|
|
54
|
+
throw new Error('No devcontainer.json');
|
|
55
|
+
}
|
|
56
|
+
const containerCreateOptions = {
|
|
57
|
+
Tty: true,
|
|
58
|
+
ExposedPorts: {},
|
|
59
|
+
HostConfig: {
|
|
60
|
+
PortBindings: {},
|
|
61
|
+
Mounts: [{
|
|
62
|
+
Source: workspace.path.toString(),
|
|
63
|
+
Target: `/workspaces/${workspace.path.name}`,
|
|
64
|
+
Type: 'bind'
|
|
65
|
+
}],
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
for (const containerCreateContrib of this.containerCreationContributions.getContributions()) {
|
|
69
|
+
await containerCreateContrib.handleContainerCreation(containerCreateOptions, devcontainerConfig, docker, outputProvider);
|
|
70
|
+
}
|
|
71
|
+
// TODO add more config
|
|
72
|
+
const container = await docker.createContainer(containerCreateOptions);
|
|
73
|
+
await container.start();
|
|
74
|
+
return container;
|
|
75
|
+
}
|
|
76
|
+
getPortBindings(forwardPorts) {
|
|
77
|
+
var _a;
|
|
78
|
+
const res = { exposedPorts: {}, portBindings: {} };
|
|
79
|
+
for (const port of forwardPorts) {
|
|
80
|
+
let portKey;
|
|
81
|
+
let hostPort;
|
|
82
|
+
if (typeof port === 'string') {
|
|
83
|
+
const parts = port.split(':');
|
|
84
|
+
portKey = isNaN(+parts[0]) ? parts[0] : `${parts[0]}/tcp`;
|
|
85
|
+
hostPort = (_a = parts[1]) !== null && _a !== void 0 ? _a : parts[0];
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
portKey = `${port}/tcp`;
|
|
89
|
+
hostPort = port.toString();
|
|
90
|
+
}
|
|
91
|
+
res.exposedPorts[portKey] = {};
|
|
92
|
+
res.portBindings[portKey] = [{ HostPort: hostPort }];
|
|
93
|
+
}
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
(0, tslib_1.__decorate)([
|
|
98
|
+
(0, inversify_1.inject)(common_1.WorkspaceServer),
|
|
99
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
100
|
+
], DockerContainerService.prototype, "workspaceServer", void 0);
|
|
101
|
+
(0, tslib_1.__decorate)([
|
|
102
|
+
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
103
|
+
(0, inversify_1.named)(exports.ContainerCreationContribution),
|
|
104
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
105
|
+
], DockerContainerService.prototype, "containerCreationContributions", void 0);
|
|
106
|
+
(0, tslib_1.__decorate)([
|
|
107
|
+
(0, inversify_1.inject)(dev_container_file_service_1.DevContainerFileService),
|
|
108
|
+
(0, tslib_1.__metadata)("design:type", dev_container_file_service_1.DevContainerFileService)
|
|
109
|
+
], DockerContainerService.prototype, "devContainerFileService", void 0);
|
|
110
|
+
DockerContainerService = (0, tslib_1.__decorate)([
|
|
111
|
+
(0, inversify_1.injectable)()
|
|
112
|
+
], DockerContainerService);
|
|
113
|
+
exports.DockerContainerService = DockerContainerService;
|
|
114
|
+
//# sourceMappingURL=docker-container-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker-container-service.js","sourceRoot":"","sources":["../../src/electron-node/docker-container-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;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AAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC9B,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;gBAC1D,QAAQ,GAAG,MAAA,KAAK,CAAC,CAAC,CAAC,mCAAI,KAAK,CAAC,CAAC,CAAC,CAAC;aACnC;iBAAM;gBACH,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC;gBACxB,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;aAC9B;YACD,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YAC/B,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;SACxD;QAED,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AApFG;IADC,IAAA,kBAAM,EAAC,wBAAe,CAAC;;+DAC4B;AAGpD;IADC,IAAA,kBAAM,EAAC,2BAAoB,CAAC;IAAE,IAAA,iBAAK,EAAC,qCAA6B,CAAC;;8EACoC;AAGvG;IADC,IAAA,kBAAM,EAAC,oDAAuB,CAAC;2CACY,oDAAuB;uEAAC;AAT3D,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CAuFlC;AAvFY,wDAAsB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ContainerConnectionOptions, ContainerConnectionResult, DevContainerFile, RemoteContainerConnectionProvider } from '../electron-common/remote-container-connection-provider';
|
|
3
|
+
import { RemoteConnection, RemoteExecOptions, RemoteExecResult, RemoteExecTester } from '@theia/remote/lib/electron-node/remote-types';
|
|
4
|
+
import { RemoteSetupResult, RemoteSetupService } from '@theia/remote/lib/electron-node/setup/remote-setup-service';
|
|
5
|
+
import { RemoteConnectionService } from '@theia/remote/lib/electron-node/remote-connection-service';
|
|
6
|
+
import { RemoteProxyServerProvider } from '@theia/remote/lib/electron-node/remote-proxy-server-provider';
|
|
7
|
+
import { Emitter, Event, MessageService, RpcServer } from '@theia/core';
|
|
8
|
+
import { Socket } from 'net';
|
|
9
|
+
import * as Docker from 'dockerode';
|
|
10
|
+
import { DockerContainerService } from './docker-container-service';
|
|
11
|
+
import { WriteStream } from 'tty';
|
|
12
|
+
import { DevContainerFileService } from './dev-container-file-service';
|
|
13
|
+
import { ContainerOutputProvider } from '../electron-common/container-output-provider';
|
|
14
|
+
export declare class DevContainerConnectionProvider implements RemoteContainerConnectionProvider, RpcServer<ContainerOutputProvider> {
|
|
15
|
+
protected readonly remoteConnectionService: RemoteConnectionService;
|
|
16
|
+
protected readonly remoteSetup: RemoteSetupService;
|
|
17
|
+
protected readonly messageService: MessageService;
|
|
18
|
+
protected readonly serverProvider: RemoteProxyServerProvider;
|
|
19
|
+
protected readonly containerService: DockerContainerService;
|
|
20
|
+
protected readonly devContainerFileService: DevContainerFileService;
|
|
21
|
+
protected outputProvider: ContainerOutputProvider | undefined;
|
|
22
|
+
setClient(client: ContainerOutputProvider): void;
|
|
23
|
+
connectToContainer(options: ContainerConnectionOptions): Promise<ContainerConnectionResult>;
|
|
24
|
+
getDevContainerFiles(): Promise<DevContainerFile[]>;
|
|
25
|
+
createContainerConnection(container: Docker.Container, docker: Docker): Promise<RemoteDockerContainerConnection>;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
28
|
+
export interface RemoteContainerConnectionOptions {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
type: string;
|
|
32
|
+
docker: Docker;
|
|
33
|
+
container: Docker.Container;
|
|
34
|
+
}
|
|
35
|
+
interface ContainerTerminalSession {
|
|
36
|
+
execution: Docker.Exec;
|
|
37
|
+
stdout: WriteStream;
|
|
38
|
+
stderr: WriteStream;
|
|
39
|
+
executeCommand(cmd: string, args?: string[]): Promise<{
|
|
40
|
+
stdout: string;
|
|
41
|
+
stderr: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
interface ContainerTerminalSession {
|
|
45
|
+
execution: Docker.Exec;
|
|
46
|
+
stdout: WriteStream;
|
|
47
|
+
stderr: WriteStream;
|
|
48
|
+
executeCommand(cmd: string, args?: string[]): Promise<{
|
|
49
|
+
stdout: string;
|
|
50
|
+
stderr: string;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
export declare class RemoteDockerContainerConnection implements RemoteConnection {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
type: string;
|
|
57
|
+
localPort: number;
|
|
58
|
+
remotePort: number;
|
|
59
|
+
docker: Docker;
|
|
60
|
+
container: Docker.Container;
|
|
61
|
+
containerInfo: Docker.ContainerInspectInfo | undefined;
|
|
62
|
+
remoteSetupResult: RemoteSetupResult;
|
|
63
|
+
protected activeTerminalSession: ContainerTerminalSession | undefined;
|
|
64
|
+
protected readonly onDidDisconnectEmitter: Emitter<void>;
|
|
65
|
+
onDidDisconnect: Event<void>;
|
|
66
|
+
constructor(options: RemoteContainerConnectionOptions);
|
|
67
|
+
forwardOut(socket: Socket, port?: number): Promise<void>;
|
|
68
|
+
exec(cmd: string, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
|
|
69
|
+
execPartial(cmd: string, tester: RemoteExecTester, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
|
|
70
|
+
copy(localPath: string | Buffer | NodeJS.ReadableStream, remotePath: string): Promise<void>;
|
|
71
|
+
dispose(): void;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=remote-container-connection-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-container-connection-provider.d.ts","sourceRoot":"","sources":["../../src/electron-node/remote-container-connection-provider.ts"],"names":[],"mappings":";AAiBA,OAAO,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,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IAEnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;IAE5B,aAAa,EAAE,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAEvD,iBAAiB,EAAE,iBAAiB,CAAC;IAErC,SAAS,CAAC,qBAAqB,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAEtE,SAAS,CAAC,QAAQ,CAAC,sBAAsB,gBAAuB;IAChE,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,CAAqC;gBAErD,OAAO,EAAE,gCAAgC;IAU/C,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBxD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyB1F,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwC3H,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBjG,OAAO,IAAI,IAAI;CAIlB"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 Typefox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.RemoteDockerContainerConnection = exports.DevContainerConnectionProvider = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const remote_setup_service_1 = require("@theia/remote/lib/electron-node/setup/remote-setup-service");
|
|
21
|
+
const remote_connection_service_1 = require("@theia/remote/lib/electron-node/remote-connection-service");
|
|
22
|
+
const remote_proxy_server_provider_1 = require("@theia/remote/lib/electron-node/remote-proxy-server-provider");
|
|
23
|
+
const core_1 = require("@theia/core");
|
|
24
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
25
|
+
const Docker = require("dockerode");
|
|
26
|
+
const docker_container_service_1 = require("./docker-container-service");
|
|
27
|
+
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
28
|
+
const stream_1 = require("stream");
|
|
29
|
+
const child_process_1 = require("child_process");
|
|
30
|
+
const dev_container_file_service_1 = require("./dev-container-file-service");
|
|
31
|
+
let DevContainerConnectionProvider = class DevContainerConnectionProvider {
|
|
32
|
+
setClient(client) {
|
|
33
|
+
this.outputProvider = client;
|
|
34
|
+
}
|
|
35
|
+
async connectToContainer(options) {
|
|
36
|
+
const dockerConnection = new Docker();
|
|
37
|
+
const version = await dockerConnection.version().catch(() => undefined);
|
|
38
|
+
if (!version) {
|
|
39
|
+
this.messageService.error('Docker Daemon is not running');
|
|
40
|
+
throw new Error('Docker is not running');
|
|
41
|
+
}
|
|
42
|
+
// create container
|
|
43
|
+
const progress = await this.messageService.showProgress({
|
|
44
|
+
text: 'Creating container',
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
const container = await this.containerService.getOrCreateContainer(dockerConnection, options.devcontainerFile, options.lastContainerInfo, this.outputProvider);
|
|
48
|
+
// create actual connection
|
|
49
|
+
const report = message => progress.report({ message });
|
|
50
|
+
report('Connecting to remote system...');
|
|
51
|
+
const remote = await this.createContainerConnection(container, dockerConnection);
|
|
52
|
+
const result = await this.remoteSetup.setup({
|
|
53
|
+
connection: remote,
|
|
54
|
+
report,
|
|
55
|
+
nodeDownloadTemplate: options.nodeDownloadTemplate
|
|
56
|
+
});
|
|
57
|
+
remote.remoteSetupResult = result;
|
|
58
|
+
const registration = this.remoteConnectionService.register(remote);
|
|
59
|
+
const server = await this.serverProvider.getProxyServer(socket => {
|
|
60
|
+
remote.forwardOut(socket);
|
|
61
|
+
});
|
|
62
|
+
remote.onDidDisconnect(() => {
|
|
63
|
+
server.close();
|
|
64
|
+
registration.dispose();
|
|
65
|
+
});
|
|
66
|
+
const localPort = server.address().port;
|
|
67
|
+
remote.localPort = localPort;
|
|
68
|
+
return {
|
|
69
|
+
containerId: container.id,
|
|
70
|
+
workspacePath: (await container.inspect()).Mounts[0].Destination,
|
|
71
|
+
port: localPort.toString(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
this.messageService.error(e.message);
|
|
76
|
+
console.error(e);
|
|
77
|
+
throw e;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
progress.cancel();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
getDevContainerFiles() {
|
|
84
|
+
return this.devContainerFileService.getAvailableFiles();
|
|
85
|
+
}
|
|
86
|
+
async createContainerConnection(container, docker) {
|
|
87
|
+
return Promise.resolve(new RemoteDockerContainerConnection({
|
|
88
|
+
id: (0, core_1.generateUuid)(),
|
|
89
|
+
name: 'dev-container',
|
|
90
|
+
type: 'container',
|
|
91
|
+
docker,
|
|
92
|
+
container,
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
dispose() {
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
(0, tslib_1.__decorate)([
|
|
99
|
+
(0, inversify_1.inject)(remote_connection_service_1.RemoteConnectionService),
|
|
100
|
+
(0, tslib_1.__metadata)("design:type", remote_connection_service_1.RemoteConnectionService)
|
|
101
|
+
], DevContainerConnectionProvider.prototype, "remoteConnectionService", void 0);
|
|
102
|
+
(0, tslib_1.__decorate)([
|
|
103
|
+
(0, inversify_1.inject)(remote_setup_service_1.RemoteSetupService),
|
|
104
|
+
(0, tslib_1.__metadata)("design:type", remote_setup_service_1.RemoteSetupService)
|
|
105
|
+
], DevContainerConnectionProvider.prototype, "remoteSetup", void 0);
|
|
106
|
+
(0, tslib_1.__decorate)([
|
|
107
|
+
(0, inversify_1.inject)(core_1.MessageService),
|
|
108
|
+
(0, tslib_1.__metadata)("design:type", core_1.MessageService)
|
|
109
|
+
], DevContainerConnectionProvider.prototype, "messageService", void 0);
|
|
110
|
+
(0, tslib_1.__decorate)([
|
|
111
|
+
(0, inversify_1.inject)(remote_proxy_server_provider_1.RemoteProxyServerProvider),
|
|
112
|
+
(0, tslib_1.__metadata)("design:type", remote_proxy_server_provider_1.RemoteProxyServerProvider)
|
|
113
|
+
], DevContainerConnectionProvider.prototype, "serverProvider", void 0);
|
|
114
|
+
(0, tslib_1.__decorate)([
|
|
115
|
+
(0, inversify_1.inject)(docker_container_service_1.DockerContainerService),
|
|
116
|
+
(0, tslib_1.__metadata)("design:type", docker_container_service_1.DockerContainerService)
|
|
117
|
+
], DevContainerConnectionProvider.prototype, "containerService", void 0);
|
|
118
|
+
(0, tslib_1.__decorate)([
|
|
119
|
+
(0, inversify_1.inject)(dev_container_file_service_1.DevContainerFileService),
|
|
120
|
+
(0, tslib_1.__metadata)("design:type", dev_container_file_service_1.DevContainerFileService)
|
|
121
|
+
], DevContainerConnectionProvider.prototype, "devContainerFileService", void 0);
|
|
122
|
+
DevContainerConnectionProvider = (0, tslib_1.__decorate)([
|
|
123
|
+
(0, inversify_1.injectable)()
|
|
124
|
+
], DevContainerConnectionProvider);
|
|
125
|
+
exports.DevContainerConnectionProvider = DevContainerConnectionProvider;
|
|
126
|
+
class RemoteDockerContainerConnection {
|
|
127
|
+
constructor(options) {
|
|
128
|
+
this.onDidDisconnectEmitter = new core_1.Emitter();
|
|
129
|
+
this.onDidDisconnect = this.onDidDisconnectEmitter.event;
|
|
130
|
+
this.id = options.id;
|
|
131
|
+
this.type = options.type;
|
|
132
|
+
this.name = options.name;
|
|
133
|
+
this.onDidDisconnect(() => this.dispose());
|
|
134
|
+
this.docker = options.docker;
|
|
135
|
+
this.container = options.container;
|
|
136
|
+
}
|
|
137
|
+
async forwardOut(socket, port) {
|
|
138
|
+
const node = `${this.remoteSetupResult.nodeDirectory}/bin/node`;
|
|
139
|
+
const devContainerServer = `${this.remoteSetupResult.applicationDirectory}/backend/dev-container-server.js`;
|
|
140
|
+
try {
|
|
141
|
+
const ttySession = await this.container.exec({
|
|
142
|
+
Cmd: ['sh', '-c', `${node} ${devContainerServer} -target-port=${port !== null && port !== void 0 ? port : this.remotePort}`],
|
|
143
|
+
AttachStdin: true, AttachStdout: true, AttachStderr: true
|
|
144
|
+
});
|
|
145
|
+
const stream = await ttySession.start({ hijack: true, stdin: true });
|
|
146
|
+
socket.pipe(stream);
|
|
147
|
+
ttySession.modem.demuxStream(stream, socket, socket);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
console.error(e);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async exec(cmd, args, options) {
|
|
154
|
+
var _a;
|
|
155
|
+
// return (await this.getOrCreateTerminalSession()).executeCommand(cmd, args);
|
|
156
|
+
const deferred = new promise_util_1.Deferred();
|
|
157
|
+
try {
|
|
158
|
+
// TODO add windows container support
|
|
159
|
+
const execution = await this.container.exec({ Cmd: ['sh', '-c', `${cmd} ${(_a = args === null || args === void 0 ? void 0 : args.join(' ')) !== null && _a !== void 0 ? _a : ''}`], AttachStdout: true, AttachStderr: true });
|
|
160
|
+
let stdoutBuffer = '';
|
|
161
|
+
let stderrBuffer = '';
|
|
162
|
+
const stream = await (execution === null || execution === void 0 ? void 0 : execution.start({}));
|
|
163
|
+
const stdout = new stream_1.PassThrough();
|
|
164
|
+
stdout.on('data', (chunk) => {
|
|
165
|
+
stdoutBuffer += chunk.toString();
|
|
166
|
+
});
|
|
167
|
+
const stderr = new stream_1.PassThrough();
|
|
168
|
+
stderr.on('data', (chunk) => {
|
|
169
|
+
stderrBuffer += chunk.toString();
|
|
170
|
+
});
|
|
171
|
+
execution.modem.demuxStream(stream, stdout, stderr);
|
|
172
|
+
stream === null || stream === void 0 ? void 0 : stream.addListener('close', () => deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer }));
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
deferred.reject(e);
|
|
176
|
+
}
|
|
177
|
+
return deferred.promise;
|
|
178
|
+
}
|
|
179
|
+
async execPartial(cmd, tester, args, options) {
|
|
180
|
+
var _a;
|
|
181
|
+
const deferred = new promise_util_1.Deferred();
|
|
182
|
+
try {
|
|
183
|
+
// TODO add windows container support
|
|
184
|
+
const execution = await this.container.exec({ Cmd: ['sh', '-c', `${cmd} ${(_a = args === null || args === void 0 ? void 0 : args.join(' ')) !== null && _a !== void 0 ? _a : ''}`], AttachStdout: true, AttachStderr: true });
|
|
185
|
+
let stdoutBuffer = '';
|
|
186
|
+
let stderrBuffer = '';
|
|
187
|
+
const stream = await (execution === null || execution === void 0 ? void 0 : execution.start({}));
|
|
188
|
+
stream.on('close', () => {
|
|
189
|
+
if (deferred.state === 'unresolved') {
|
|
190
|
+
deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
const stdout = new stream_1.PassThrough();
|
|
194
|
+
stdout.on('data', (data) => {
|
|
195
|
+
if (deferred.state === 'unresolved') {
|
|
196
|
+
stdoutBuffer += data.toString();
|
|
197
|
+
if (tester(stdoutBuffer, stderrBuffer)) {
|
|
198
|
+
deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
const stderr = new stream_1.PassThrough();
|
|
203
|
+
stderr.on('data', (data) => {
|
|
204
|
+
if (deferred.state === 'unresolved') {
|
|
205
|
+
stderrBuffer += data.toString();
|
|
206
|
+
if (tester(stdoutBuffer, stderrBuffer)) {
|
|
207
|
+
deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
execution.modem.demuxStream(stream, stdout, stderr);
|
|
212
|
+
}
|
|
213
|
+
catch (e) {
|
|
214
|
+
deferred.reject(e);
|
|
215
|
+
}
|
|
216
|
+
return deferred.promise;
|
|
217
|
+
}
|
|
218
|
+
async copy(localPath, remotePath) {
|
|
219
|
+
var _a;
|
|
220
|
+
const deferred = new promise_util_1.Deferred();
|
|
221
|
+
const process = (0, child_process_1.exec)(`docker cp -qa ${localPath.toString()} ${this.container.id}:${remotePath}`);
|
|
222
|
+
let stderr = '';
|
|
223
|
+
(_a = process.stderr) === null || _a === void 0 ? void 0 : _a.on('data', data => {
|
|
224
|
+
stderr += data.toString();
|
|
225
|
+
});
|
|
226
|
+
process.on('close', code => {
|
|
227
|
+
if (code === 0) {
|
|
228
|
+
deferred.resolve();
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
deferred.reject(stderr);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return deferred.promise;
|
|
235
|
+
}
|
|
236
|
+
dispose() {
|
|
237
|
+
this.container.stop();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.RemoteDockerContainerConnection = RemoteDockerContainerConnection;
|
|
241
|
+
//# sourceMappingURL=remote-container-connection-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-container-connection-provider.js","sourceRoot":"","sources":["../../src/electron-node/remote-container-connection-provider.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAQhF,qGAAmH;AACnH,yGAAoG;AACpG,+GAAyG;AACzG,sCAAsF;AAEtF,4DAAkE;AAClE,oCAAoC;AACpC,yEAAoE;AACpE,sEAA+D;AAE/D,mCAAqC;AACrC,iDAAqC;AACrC,6EAAuE;AAIvE,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAsBvC,SAAS,CAAC,MAA+B;QACrC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,OAAmC;QACxD,MAAM,gBAAgB,GAAG,IAAI,MAAM,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAExE,IAAI,CAAC,OAAO,EAAE;YACV,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAC1D,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;SAC5C;QAED,mBAAmB;QACnB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;YACpD,IAAI,EAAE,oBAAoB;SAC7B,CAAC,CAAC;QACH,IAAI;YACA,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,OAAO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,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;YACvB,IAAI,IAAI,KAAK,CAAC,EAAE;gBACZ,QAAQ,CAAC,OAAO,EAAE,CAAC;aACtB;iBAAM;gBACH,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;aAC3B;QACL,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED,OAAO;QACH,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;CAEJ;AAvID,0EAuIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=package.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
/* note: this bogus test file is required so that
|
|
17
|
+
we are able to run mocha unit tests on this
|
|
18
|
+
package, without having any actual unit tests in it.
|
|
19
|
+
This way a coverage report will be generated,
|
|
20
|
+
showing 0% coverage, instead of no report.
|
|
21
|
+
This file can be removed once we have real unit
|
|
22
|
+
tests in place. */
|
|
23
|
+
describe('dev-container package', () => {
|
|
24
|
+
it('support code coverage statistics', () => true);
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=package.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAEhF;;;;;;qBAMqB;AAErB,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IAEnC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theia/dev-container",
|
|
3
|
+
"version": "1.48.0",
|
|
4
|
+
"description": "Theia - Editor Preview Extension",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@theia/core": "1.48.0",
|
|
7
|
+
"@theia/output": "1.48.0",
|
|
8
|
+
"@theia/remote": "1.48.0",
|
|
9
|
+
"@theia/workspace": "1.48.0",
|
|
10
|
+
"dockerode": "^4.0.2",
|
|
11
|
+
"jsonc-parser": "^2.2.0",
|
|
12
|
+
"uuid": "^8.0.0"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"theiaExtensions": [
|
|
18
|
+
{
|
|
19
|
+
"frontendElectron": "lib/electron-browser/dev-container-frontend-module",
|
|
20
|
+
"backendElectron": "lib/electron-node/dev-container-backend-module"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"theia-extension"
|
|
25
|
+
],
|
|
26
|
+
"license": "EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/eclipse-theia/theia.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/eclipse-theia/theia/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/eclipse-theia/theia",
|
|
35
|
+
"files": [
|
|
36
|
+
"lib",
|
|
37
|
+
"src"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "theiaext build",
|
|
41
|
+
"clean": "theiaext clean",
|
|
42
|
+
"compile": "theiaext compile",
|
|
43
|
+
"lint": "theiaext lint",
|
|
44
|
+
"test": "theiaext test",
|
|
45
|
+
"watch": "theiaext watch"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@theia/ext-scripts": "1.48.0",
|
|
49
|
+
"@types/dockerode": "^3.3.23"
|
|
50
|
+
},
|
|
51
|
+
"nyc": {
|
|
52
|
+
"extends": "../../configs/nyc.json"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "ffae6a0739f7924a7cacafeb5ceb1140d93fe010"
|
|
55
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 Typefox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { createConnection } from 'net';
|
|
18
|
+
import { stdin, argv, stdout } from 'process';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* this node.js Program is supposed to be executed by an docker exec session inside a docker container.
|
|
22
|
+
* It uses a tty session to listen on stdin and send on stdout all communication with the theia backend running inside the container.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
let backendPort: number | undefined = undefined;
|
|
26
|
+
argv.slice(2).forEach(arg => {
|
|
27
|
+
if (arg.startsWith('-target-port')) {
|
|
28
|
+
backendPort = parseInt(arg.split('=')[1]);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!backendPort) {
|
|
33
|
+
throw new Error('please start with -target-port={port number}');
|
|
34
|
+
}
|
|
35
|
+
if (stdin.isTTY) {
|
|
36
|
+
stdin.setRawMode(true);
|
|
37
|
+
}
|
|
38
|
+
const connection = createConnection(backendPort, '0.0.0.0');
|
|
39
|
+
|
|
40
|
+
connection.pipe(stdout);
|
|
41
|
+
stdin.pipe(connection);
|
|
42
|
+
|
|
43
|
+
connection.on('error', error => {
|
|
44
|
+
console.error('connection error', error);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
connection.on('close', () => {
|
|
48
|
+
console.log('connection closed');
|
|
49
|
+
process.exit(0);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// keep the process running
|
|
53
|
+
setInterval(() => { }, 1 << 30);
|