@theia/application-manager 1.34.2 → 1.34.3

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.
Files changed (35) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +25 -25
  3. package/lib/application-package-manager.d.ts +39 -39
  4. package/lib/application-package-manager.js +188 -188
  5. package/lib/application-process.d.ts +19 -19
  6. package/lib/application-process.js +72 -72
  7. package/lib/expose-loader.d.ts +8 -8
  8. package/lib/expose-loader.js +69 -69
  9. package/lib/generator/abstract-generator.d.ts +19 -19
  10. package/lib/generator/abstract-generator.js +68 -68
  11. package/lib/generator/backend-generator.d.ts +6 -6
  12. package/lib/generator/backend-generator.js +101 -101
  13. package/lib/generator/frontend-generator.d.ts +13 -13
  14. package/lib/generator/frontend-generator.js +261 -261
  15. package/lib/generator/index.d.ts +3 -3
  16. package/lib/generator/index.js +30 -30
  17. package/lib/generator/webpack-generator.d.ts +10 -10
  18. package/lib/generator/webpack-generator.js +298 -298
  19. package/lib/index.d.ts +3 -3
  20. package/lib/index.js +30 -30
  21. package/lib/package.spec.js +25 -25
  22. package/lib/rebuild.d.ts +24 -24
  23. package/lib/rebuild.js +306 -306
  24. package/package.json +5 -5
  25. package/src/application-package-manager.ts +228 -228
  26. package/src/application-process.ts +80 -80
  27. package/src/expose-loader.ts +80 -80
  28. package/src/generator/abstract-generator.ts +82 -82
  29. package/src/generator/backend-generator.ts +103 -103
  30. package/src/generator/frontend-generator.ts +271 -271
  31. package/src/generator/index.ts +19 -19
  32. package/src/generator/webpack-generator.ts +304 -304
  33. package/src/index.ts +19 -19
  34. package/src/package.spec.ts +28 -28
  35. package/src/rebuild.ts +342 -342
@@ -1,73 +1,73 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 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 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ApplicationProcess = void 0;
19
- const path = require("path");
20
- const fs = require("fs-extra");
21
- const cp = require("child_process");
22
- class ApplicationProcess {
23
- constructor(pck, binProjectPath) {
24
- this.pck = pck;
25
- this.binProjectPath = binProjectPath;
26
- this.defaultOptions = {
27
- cwd: this.pck.projectPath,
28
- env: process.env
29
- };
30
- }
31
- spawn(command, args, options) {
32
- return cp.spawn(command, args || [], Object.assign({}, this.defaultOptions, options));
33
- }
34
- fork(modulePath, args, options) {
35
- return cp.fork(modulePath, args, Object.assign({}, this.defaultOptions, options));
36
- }
37
- canRun(command) {
38
- return fs.existsSync(this.resolveBin(command));
39
- }
40
- run(command, args, options) {
41
- const commandProcess = this.spawnBin(command, args, options);
42
- return this.promisify(command, commandProcess);
43
- }
44
- spawnBin(command, args, options) {
45
- const binPath = this.resolveBin(command);
46
- return this.spawn(binPath, args, options);
47
- }
48
- resolveBin(command) {
49
- const commandPath = path.resolve(this.binProjectPath, 'node_modules', '.bin', command);
50
- return process.platform === 'win32' ? commandPath + '.cmd' : commandPath;
51
- }
52
- promisify(command, p) {
53
- return new Promise((resolve, reject) => {
54
- p.stdout.on('data', data => this.pck.log(data.toString()));
55
- p.stderr.on('data', data => this.pck.error(data.toString()));
56
- p.on('error', reject);
57
- p.on('close', (code, signal) => {
58
- if (signal) {
59
- reject(new Error(`${command} exited with an unexpected signal: ${signal}.`));
60
- return;
61
- }
62
- if (code === 0) {
63
- resolve();
64
- }
65
- else {
66
- reject(new Error(`${command} exited with an unexpected code: ${code}.`));
67
- }
68
- });
69
- });
70
- }
71
- }
72
- exports.ApplicationProcess = ApplicationProcess;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 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 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ApplicationProcess = void 0;
19
+ const path = require("path");
20
+ const fs = require("fs-extra");
21
+ const cp = require("child_process");
22
+ class ApplicationProcess {
23
+ constructor(pck, binProjectPath) {
24
+ this.pck = pck;
25
+ this.binProjectPath = binProjectPath;
26
+ this.defaultOptions = {
27
+ cwd: this.pck.projectPath,
28
+ env: process.env
29
+ };
30
+ }
31
+ spawn(command, args, options) {
32
+ return cp.spawn(command, args || [], Object.assign({}, this.defaultOptions, options));
33
+ }
34
+ fork(modulePath, args, options) {
35
+ return cp.fork(modulePath, args, Object.assign({}, this.defaultOptions, options));
36
+ }
37
+ canRun(command) {
38
+ return fs.existsSync(this.resolveBin(command));
39
+ }
40
+ run(command, args, options) {
41
+ const commandProcess = this.spawnBin(command, args, options);
42
+ return this.promisify(command, commandProcess);
43
+ }
44
+ spawnBin(command, args, options) {
45
+ const binPath = this.resolveBin(command);
46
+ return this.spawn(binPath, args, options);
47
+ }
48
+ resolveBin(command) {
49
+ const commandPath = path.resolve(this.binProjectPath, 'node_modules', '.bin', command);
50
+ return process.platform === 'win32' ? commandPath + '.cmd' : commandPath;
51
+ }
52
+ promisify(command, p) {
53
+ return new Promise((resolve, reject) => {
54
+ p.stdout.on('data', data => this.pck.log(data.toString()));
55
+ p.stderr.on('data', data => this.pck.error(data.toString()));
56
+ p.on('error', reject);
57
+ p.on('close', (code, signal) => {
58
+ if (signal) {
59
+ reject(new Error(`${command} exited with an unexpected signal: ${signal}.`));
60
+ return;
61
+ }
62
+ if (code === 0) {
63
+ resolve();
64
+ }
65
+ else {
66
+ reject(new Error(`${command} exited with an unexpected code: ${code}.`));
67
+ }
68
+ });
69
+ });
70
+ }
71
+ }
72
+ exports.ApplicationProcess = ApplicationProcess;
73
73
  //# sourceMappingURL=application-process.js.map
@@ -1,9 +1,9 @@
1
- import type { RawSourceMap } from 'source-map';
2
- declare const _default: (this: any, source: string, sourceMap?: RawSourceMap | undefined) => string | undefined;
3
- /**
4
- * Expose bundled modules on window.theia.moduleName namespace, e.g.
5
- * window['theia']['@theia/core/lib/common/uri'].
6
- * Such syntax can be used by external code, for instance, for testing.
7
- */
8
- export = _default;
1
+ import type { RawSourceMap } from 'source-map';
2
+ declare const _default: (this: any, source: string, sourceMap?: RawSourceMap | undefined) => string | undefined;
3
+ /**
4
+ * Expose bundled modules on window.theia.moduleName namespace, e.g.
5
+ * window['theia']['@theia/core/lib/common/uri'].
6
+ * Such syntax can be used by external code, for instance, for testing.
7
+ */
8
+ export = _default;
9
9
  //# sourceMappingURL=expose-loader.d.ts.map
@@ -1,70 +1,70 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2020 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 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- const fs = require("fs-extra");
18
- const path = require("path");
19
- const application_package_1 = require("@theia/application-package/lib/application-package");
20
- const modulePackages = [];
21
- for (const extensionPackage of new application_package_1.ApplicationPackage({ projectPath: process.cwd() }).extensionPackages) {
22
- modulePackages.push({
23
- name: extensionPackage.name,
24
- dir: path.dirname(extensionPackage.raw.installed.packagePath)
25
- });
26
- }
27
- function exposeModule(modulePackage, resourcePath, source) {
28
- if (!modulePackage.name) {
29
- return source;
30
- }
31
- const { dir, name } = path.parse(resourcePath);
32
- let moduleName = path.join(modulePackage.name, dir.substring(modulePackage.dir.length));
33
- if (name !== 'index') {
34
- moduleName = path.join(moduleName, name);
35
- }
36
- if (path.sep !== '/') {
37
- moduleName = moduleName.split(path.sep).join('/');
38
- }
39
- return source + `\n;(globalThis['theia'] = globalThis['theia'] || {})['${moduleName}'] = this;\n`;
40
- }
41
- module.exports = function (source, sourceMap) {
42
- if (this.cacheable) {
43
- this.cacheable();
44
- }
45
- let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir + path.sep));
46
- if (modulePackage) {
47
- this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
48
- return;
49
- }
50
- const searchString = path.sep + 'node_modules';
51
- const index = this.resourcePath.lastIndexOf(searchString);
52
- if (index !== -1) {
53
- const nodeModulesPath = this.resourcePath.substring(0, index + searchString.length);
54
- let dir = this.resourcePath;
55
- while ((dir = path.dirname(dir)) !== nodeModulesPath) {
56
- try {
57
- const { name } = fs.readJSONSync(path.join(dir, 'package.json'));
58
- modulePackage = { name, dir };
59
- modulePackages.push(modulePackage);
60
- this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
61
- return;
62
- }
63
- catch (_a) {
64
- /** no-op */
65
- }
66
- }
67
- }
68
- this.callback(undefined, source, sourceMap);
69
- };
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2020 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 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ const fs = require("fs-extra");
18
+ const path = require("path");
19
+ const application_package_1 = require("@theia/application-package/lib/application-package");
20
+ const modulePackages = [];
21
+ for (const extensionPackage of new application_package_1.ApplicationPackage({ projectPath: process.cwd() }).extensionPackages) {
22
+ modulePackages.push({
23
+ name: extensionPackage.name,
24
+ dir: path.dirname(extensionPackage.raw.installed.packagePath)
25
+ });
26
+ }
27
+ function exposeModule(modulePackage, resourcePath, source) {
28
+ if (!modulePackage.name) {
29
+ return source;
30
+ }
31
+ const { dir, name } = path.parse(resourcePath);
32
+ let moduleName = path.join(modulePackage.name, dir.substring(modulePackage.dir.length));
33
+ if (name !== 'index') {
34
+ moduleName = path.join(moduleName, name);
35
+ }
36
+ if (path.sep !== '/') {
37
+ moduleName = moduleName.split(path.sep).join('/');
38
+ }
39
+ return source + `\n;(globalThis['theia'] = globalThis['theia'] || {})['${moduleName}'] = this;\n`;
40
+ }
41
+ module.exports = function (source, sourceMap) {
42
+ if (this.cacheable) {
43
+ this.cacheable();
44
+ }
45
+ let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir + path.sep));
46
+ if (modulePackage) {
47
+ this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
48
+ return;
49
+ }
50
+ const searchString = path.sep + 'node_modules';
51
+ const index = this.resourcePath.lastIndexOf(searchString);
52
+ if (index !== -1) {
53
+ const nodeModulesPath = this.resourcePath.substring(0, index + searchString.length);
54
+ let dir = this.resourcePath;
55
+ while ((dir = path.dirname(dir)) !== nodeModulesPath) {
56
+ try {
57
+ const { name } = fs.readJSONSync(path.join(dir, 'package.json'));
58
+ modulePackage = { name, dir };
59
+ modulePackages.push(modulePackage);
60
+ this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
61
+ return;
62
+ }
63
+ catch (_a) {
64
+ /** no-op */
65
+ }
66
+ }
67
+ }
68
+ this.callback(undefined, source, sourceMap);
69
+ };
70
70
  //# sourceMappingURL=expose-loader.js.map
@@ -1,20 +1,20 @@
1
- import { ApplicationPackage } from '@theia/application-package';
2
- export interface GeneratorOptions {
3
- mode?: 'development' | 'production';
4
- splitFrontend?: boolean;
5
- }
6
- export declare abstract class AbstractGenerator {
7
- protected readonly pck: ApplicationPackage;
8
- protected options: GeneratorOptions;
9
- constructor(pck: ApplicationPackage, options?: GeneratorOptions);
10
- protected compileFrontendModuleImports(modules: Map<string, string>): string;
11
- protected compileBackendModuleImports(modules: Map<string, string>): string;
12
- protected compileElectronMainModuleImports(modules?: Map<string, string>): string;
13
- protected compileModuleImports(modules: Map<string, string>, fn: 'import' | 'require'): string;
14
- protected ifBrowser(value: string, defaultValue?: string): string;
15
- protected ifElectron(value: string, defaultValue?: string): string;
16
- protected write(path: string, content: string): Promise<void>;
17
- protected ifMonaco(value: () => string, defaultValue?: () => string): string;
18
- protected prettyStringify(object: object): string;
19
- }
1
+ import { ApplicationPackage } from '@theia/application-package';
2
+ export interface GeneratorOptions {
3
+ mode?: 'development' | 'production';
4
+ splitFrontend?: boolean;
5
+ }
6
+ export declare abstract class AbstractGenerator {
7
+ protected readonly pck: ApplicationPackage;
8
+ protected options: GeneratorOptions;
9
+ constructor(pck: ApplicationPackage, options?: GeneratorOptions);
10
+ protected compileFrontendModuleImports(modules: Map<string, string>): string;
11
+ protected compileBackendModuleImports(modules: Map<string, string>): string;
12
+ protected compileElectronMainModuleImports(modules?: Map<string, string>): string;
13
+ protected compileModuleImports(modules: Map<string, string>, fn: 'import' | 'require'): string;
14
+ protected ifBrowser(value: string, defaultValue?: string): string;
15
+ protected ifElectron(value: string, defaultValue?: string): string;
16
+ protected write(path: string, content: string): Promise<void>;
17
+ protected ifMonaco(value: () => string, defaultValue?: () => string): string;
18
+ protected prettyStringify(object: object): string;
19
+ }
20
20
  //# sourceMappingURL=abstract-generator.d.ts.map
@@ -1,69 +1,69 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 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 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.AbstractGenerator = void 0;
19
- const os = require("os");
20
- const fs = require("fs-extra");
21
- class AbstractGenerator {
22
- constructor(pck, options = {}) {
23
- this.pck = pck;
24
- this.options = options;
25
- }
26
- compileFrontendModuleImports(modules) {
27
- var _a;
28
- const splitFrontend = (_a = this.options.splitFrontend) !== null && _a !== void 0 ? _a : this.options.mode !== 'production';
29
- return this.compileModuleImports(modules, splitFrontend ? 'import' : 'require');
30
- }
31
- compileBackendModuleImports(modules) {
32
- return this.compileModuleImports(modules, 'require');
33
- }
34
- compileElectronMainModuleImports(modules) {
35
- return modules && this.compileModuleImports(modules, 'require') || '';
36
- }
37
- compileModuleImports(modules, fn) {
38
- if (modules.size === 0) {
39
- return '';
40
- }
41
- const lines = Array.from(modules.keys()).map(moduleName => {
42
- const invocation = `${fn}('${modules.get(moduleName)}')`;
43
- if (fn === 'require') {
44
- return `Promise.resolve(${invocation})`;
45
- }
46
- return invocation;
47
- }).map(statement => ` .then(function () { return ${statement}.then(load) })`);
48
- return os.EOL + lines.join(os.EOL);
49
- }
50
- ifBrowser(value, defaultValue = '') {
51
- return this.pck.ifBrowser(value, defaultValue);
52
- }
53
- ifElectron(value, defaultValue = '') {
54
- return this.pck.ifElectron(value, defaultValue);
55
- }
56
- async write(path, content) {
57
- await fs.ensureFile(path);
58
- await fs.writeFile(path, content);
59
- }
60
- ifMonaco(value, defaultValue = () => '') {
61
- return (this.pck.extensionPackages.some(e => e.name === '@theia/monaco' || e.name === '@theia/monaco-editor-core') ? value : defaultValue)();
62
- }
63
- prettyStringify(object) {
64
- // eslint-disable-next-line no-null/no-null
65
- return JSON.stringify(object, null, 4);
66
- }
67
- }
68
- exports.AbstractGenerator = AbstractGenerator;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 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 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.AbstractGenerator = void 0;
19
+ const os = require("os");
20
+ const fs = require("fs-extra");
21
+ class AbstractGenerator {
22
+ constructor(pck, options = {}) {
23
+ this.pck = pck;
24
+ this.options = options;
25
+ }
26
+ compileFrontendModuleImports(modules) {
27
+ var _a;
28
+ const splitFrontend = (_a = this.options.splitFrontend) !== null && _a !== void 0 ? _a : this.options.mode !== 'production';
29
+ return this.compileModuleImports(modules, splitFrontend ? 'import' : 'require');
30
+ }
31
+ compileBackendModuleImports(modules) {
32
+ return this.compileModuleImports(modules, 'require');
33
+ }
34
+ compileElectronMainModuleImports(modules) {
35
+ return modules && this.compileModuleImports(modules, 'require') || '';
36
+ }
37
+ compileModuleImports(modules, fn) {
38
+ if (modules.size === 0) {
39
+ return '';
40
+ }
41
+ const lines = Array.from(modules.keys()).map(moduleName => {
42
+ const invocation = `${fn}('${modules.get(moduleName)}')`;
43
+ if (fn === 'require') {
44
+ return `Promise.resolve(${invocation})`;
45
+ }
46
+ return invocation;
47
+ }).map(statement => ` .then(function () { return ${statement}.then(load) })`);
48
+ return os.EOL + lines.join(os.EOL);
49
+ }
50
+ ifBrowser(value, defaultValue = '') {
51
+ return this.pck.ifBrowser(value, defaultValue);
52
+ }
53
+ ifElectron(value, defaultValue = '') {
54
+ return this.pck.ifElectron(value, defaultValue);
55
+ }
56
+ async write(path, content) {
57
+ await fs.ensureFile(path);
58
+ await fs.writeFile(path, content);
59
+ }
60
+ ifMonaco(value, defaultValue = () => '') {
61
+ return (this.pck.extensionPackages.some(e => e.name === '@theia/monaco' || e.name === '@theia/monaco-editor-core') ? value : defaultValue)();
62
+ }
63
+ prettyStringify(object) {
64
+ // eslint-disable-next-line no-null/no-null
65
+ return JSON.stringify(object, null, 4);
66
+ }
67
+ }
68
+ exports.AbstractGenerator = AbstractGenerator;
69
69
  //# sourceMappingURL=abstract-generator.js.map
@@ -1,7 +1,7 @@
1
- import { AbstractGenerator } from './abstract-generator';
2
- export declare class BackendGenerator extends AbstractGenerator {
3
- generate(): Promise<void>;
4
- protected compileServer(backendModules: Map<string, string>): string;
5
- protected compileMain(backendModules: Map<string, string>): string;
6
- }
1
+ import { AbstractGenerator } from './abstract-generator';
2
+ export declare class BackendGenerator extends AbstractGenerator {
3
+ generate(): Promise<void>;
4
+ protected compileServer(backendModules: Map<string, string>): string;
5
+ protected compileMain(backendModules: Map<string, string>): string;
6
+ }
7
7
  //# sourceMappingURL=backend-generator.d.ts.map