@theia/application-package 1.48.0 → 1.48.1

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.
@@ -1,74 +1,74 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2018 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.environment = void 0;
19
- const isElectron = require('is-electron');
20
- /**
21
- * The electron specific environment.
22
- */
23
- class ElectronEnv {
24
- constructor() {
25
- /**
26
- * Environment variable that can be accessed on the `process` to check if running in electron or not.
27
- */
28
- this.THEIA_ELECTRON_VERSION = 'THEIA_ELECTRON_VERSION';
29
- }
30
- /**
31
- * `true` if running in electron. Otherwise, `false`.
32
- *
33
- * Can be called from both the `main` and the render process. Also works for forked cluster workers.
34
- */
35
- is() {
36
- return isElectron();
37
- }
38
- /**
39
- * `true` if running in Electron in development mode. Otherwise, `false`.
40
- *
41
- * Cannot be used from the browser. From the browser, it is always `false`.
42
- */
43
- isDevMode() {
44
- return this.is()
45
- && typeof process !== 'undefined'
46
- // `defaultApp` does not exist on the Node.js API, but on electron (`electron.d.ts`).
47
- && (process.defaultApp || /node_modules[/\\]electron[/\\]/.test(process.execPath)); // eslint-disable-line @typescript-eslint/no-explicit-any
48
- }
49
- /**
50
- * Creates and return with a new environment object which always contains the `ELECTRON_RUN_AS_NODE: 1` property pair.
51
- * This should be used to `spawn` and `fork` a new Node.js process from the Node.js shipped with Electron. Otherwise, a new Electron
52
- * process will be spawned which [has side-effects](https://github.com/eclipse-theia/theia/issues/5385).
53
- *
54
- * If called from the backend and the `env` argument is not defined, it falls back to `process.env` such as Node.js behaves
55
- * with the [`SpawnOptions`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
56
- * If `env` is defined, it will be shallow-copied.
57
- *
58
- * Calling this function from the frontend does not make any sense, hence throw an error.
59
- */
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- runAsNodeEnv(env) {
62
- if (typeof process === 'undefined') {
63
- throw new Error("'process' cannot be undefined.");
64
- }
65
- return {
66
- ...(env === undefined ? process.env : env),
67
- ELECTRON_RUN_AS_NODE: 1
68
- };
69
- }
70
- }
71
- const electron = new ElectronEnv();
72
- const environment = { electron };
73
- exports.environment = environment;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2018 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.environment = void 0;
19
+ const isElectron = require('is-electron');
20
+ /**
21
+ * The electron specific environment.
22
+ */
23
+ class ElectronEnv {
24
+ constructor() {
25
+ /**
26
+ * Environment variable that can be accessed on the `process` to check if running in electron or not.
27
+ */
28
+ this.THEIA_ELECTRON_VERSION = 'THEIA_ELECTRON_VERSION';
29
+ }
30
+ /**
31
+ * `true` if running in electron. Otherwise, `false`.
32
+ *
33
+ * Can be called from both the `main` and the render process. Also works for forked cluster workers.
34
+ */
35
+ is() {
36
+ return isElectron();
37
+ }
38
+ /**
39
+ * `true` if running in Electron in development mode. Otherwise, `false`.
40
+ *
41
+ * Cannot be used from the browser. From the browser, it is always `false`.
42
+ */
43
+ isDevMode() {
44
+ return this.is()
45
+ && typeof process !== 'undefined'
46
+ // `defaultApp` does not exist on the Node.js API, but on electron (`electron.d.ts`).
47
+ && (process.defaultApp || /node_modules[/\\]electron[/\\]/.test(process.execPath)); // eslint-disable-line @typescript-eslint/no-explicit-any
48
+ }
49
+ /**
50
+ * Creates and return with a new environment object which always contains the `ELECTRON_RUN_AS_NODE: 1` property pair.
51
+ * This should be used to `spawn` and `fork` a new Node.js process from the Node.js shipped with Electron. Otherwise, a new Electron
52
+ * process will be spawned which [has side-effects](https://github.com/eclipse-theia/theia/issues/5385).
53
+ *
54
+ * If called from the backend and the `env` argument is not defined, it falls back to `process.env` such as Node.js behaves
55
+ * with the [`SpawnOptions`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
56
+ * If `env` is defined, it will be shallow-copied.
57
+ *
58
+ * Calling this function from the frontend does not make any sense, hence throw an error.
59
+ */
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ runAsNodeEnv(env) {
62
+ if (typeof process === 'undefined') {
63
+ throw new Error("'process' cannot be undefined.");
64
+ }
65
+ return {
66
+ ...(env === undefined ? process.env : env),
67
+ ELECTRON_RUN_AS_NODE: 1
68
+ };
69
+ }
70
+ }
71
+ const electron = new ElectronEnv();
72
+ const environment = { electron };
73
+ exports.environment = environment;
74
74
  //# sourceMappingURL=environment.js.map
@@ -1,16 +1,16 @@
1
- import { NodePackage, PublishedNodePackage } from './npm-registry';
2
- import { ExtensionPackage, ExtensionPackageOptions } from './extension-package';
3
- export declare class ExtensionPackageCollector {
4
- protected readonly extensionPackageFactory: (raw: PublishedNodePackage, options?: ExtensionPackageOptions) => ExtensionPackage;
5
- protected readonly resolveModule: (modulePath: string) => string;
6
- protected readonly sorted: ExtensionPackage[];
7
- protected readonly visited: Map<string, boolean>;
8
- constructor(extensionPackageFactory: (raw: PublishedNodePackage, options?: ExtensionPackageOptions) => ExtensionPackage, resolveModule: (modulePath: string) => string);
9
- protected root: NodePackage;
10
- collect(pck: NodePackage): ReadonlyArray<ExtensionPackage>;
11
- protected collectPackages(pck: NodePackage): void;
12
- protected parent: ExtensionPackage | undefined;
13
- protected collectPackagesWithParent(pck: NodePackage, parent: ExtensionPackage): void;
14
- protected collectPackage(name: string, versionRange: string): void;
15
- }
1
+ import { NodePackage, PublishedNodePackage } from './npm-registry';
2
+ import { ExtensionPackage, ExtensionPackageOptions } from './extension-package';
3
+ export declare class ExtensionPackageCollector {
4
+ protected readonly extensionPackageFactory: (raw: PublishedNodePackage, options?: ExtensionPackageOptions) => ExtensionPackage;
5
+ protected readonly resolveModule: (modulePath: string) => string;
6
+ protected readonly sorted: ExtensionPackage[];
7
+ protected readonly visited: Map<string, boolean>;
8
+ constructor(extensionPackageFactory: (raw: PublishedNodePackage, options?: ExtensionPackageOptions) => ExtensionPackage, resolveModule: (modulePath: string) => string);
9
+ protected root: NodePackage;
10
+ collect(pck: NodePackage): ReadonlyArray<ExtensionPackage>;
11
+ protected collectPackages(pck: NodePackage): void;
12
+ protected parent: ExtensionPackage | undefined;
13
+ protected collectPackagesWithParent(pck: NodePackage, parent: ExtensionPackage): void;
14
+ protected collectPackage(name: string, versionRange: string): void;
15
+ }
16
16
  //# sourceMappingURL=extension-package-collector.d.ts.map
@@ -1,77 +1,77 @@
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-only WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ExtensionPackageCollector = void 0;
19
- const json_file_1 = require("./json-file");
20
- const extension_package_1 = require("./extension-package");
21
- class ExtensionPackageCollector {
22
- constructor(extensionPackageFactory, resolveModule) {
23
- this.extensionPackageFactory = extensionPackageFactory;
24
- this.resolveModule = resolveModule;
25
- this.sorted = [];
26
- this.visited = new Map();
27
- }
28
- collect(pck) {
29
- this.root = pck;
30
- this.collectPackages(pck);
31
- return this.sorted;
32
- }
33
- collectPackages(pck) {
34
- var _a, _b;
35
- for (const [dependency, versionRange] of [
36
- ...Object.entries((_a = pck.dependencies) !== null && _a !== void 0 ? _a : {}),
37
- ...Object.entries((_b = pck.peerDependencies) !== null && _b !== void 0 ? _b : {})
38
- ]) {
39
- this.collectPackage(dependency, versionRange);
40
- }
41
- }
42
- collectPackagesWithParent(pck, parent) {
43
- const current = this.parent;
44
- this.parent = parent;
45
- this.collectPackages(pck);
46
- this.parent = current;
47
- }
48
- collectPackage(name, versionRange) {
49
- if (this.visited.has(name)) {
50
- return;
51
- }
52
- this.visited.set(name, true);
53
- let packagePath;
54
- try {
55
- packagePath = this.resolveModule(name);
56
- }
57
- catch {
58
- console.debug(`Failed to resolve module: ${name}`);
59
- }
60
- if (!packagePath) {
61
- return;
62
- }
63
- const pck = (0, json_file_1.readJsonFile)(packagePath);
64
- if (extension_package_1.RawExtensionPackage.is(pck)) {
65
- const parent = this.parent;
66
- const version = pck.version;
67
- const transitive = !(name in this.root.dependencies);
68
- pck.installed = { packagePath, version, parent, transitive };
69
- pck.version = versionRange;
70
- const extensionPackage = this.extensionPackageFactory(pck, { alias: name });
71
- this.collectPackagesWithParent(pck, extensionPackage);
72
- this.sorted.push(extensionPackage);
73
- }
74
- }
75
- }
76
- exports.ExtensionPackageCollector = ExtensionPackageCollector;
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-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ExtensionPackageCollector = void 0;
19
+ const json_file_1 = require("./json-file");
20
+ const extension_package_1 = require("./extension-package");
21
+ class ExtensionPackageCollector {
22
+ constructor(extensionPackageFactory, resolveModule) {
23
+ this.extensionPackageFactory = extensionPackageFactory;
24
+ this.resolveModule = resolveModule;
25
+ this.sorted = [];
26
+ this.visited = new Map();
27
+ }
28
+ collect(pck) {
29
+ this.root = pck;
30
+ this.collectPackages(pck);
31
+ return this.sorted;
32
+ }
33
+ collectPackages(pck) {
34
+ var _a, _b;
35
+ for (const [dependency, versionRange] of [
36
+ ...Object.entries((_a = pck.dependencies) !== null && _a !== void 0 ? _a : {}),
37
+ ...Object.entries((_b = pck.peerDependencies) !== null && _b !== void 0 ? _b : {})
38
+ ]) {
39
+ this.collectPackage(dependency, versionRange);
40
+ }
41
+ }
42
+ collectPackagesWithParent(pck, parent) {
43
+ const current = this.parent;
44
+ this.parent = parent;
45
+ this.collectPackages(pck);
46
+ this.parent = current;
47
+ }
48
+ collectPackage(name, versionRange) {
49
+ if (this.visited.has(name)) {
50
+ return;
51
+ }
52
+ this.visited.set(name, true);
53
+ let packagePath;
54
+ try {
55
+ packagePath = this.resolveModule(name);
56
+ }
57
+ catch {
58
+ console.debug(`Failed to resolve module: ${name}`);
59
+ }
60
+ if (!packagePath) {
61
+ return;
62
+ }
63
+ const pck = (0, json_file_1.readJsonFile)(packagePath);
64
+ if (extension_package_1.RawExtensionPackage.is(pck)) {
65
+ const parent = this.parent;
66
+ const version = pck.version;
67
+ const transitive = !(name in this.root.dependencies);
68
+ pck.installed = { packagePath, version, parent, transitive };
69
+ pck.version = versionRange;
70
+ const extensionPackage = this.extensionPackageFactory(pck, { alias: name });
71
+ this.collectPackagesWithParent(pck, extensionPackage);
72
+ this.sorted.push(extensionPackage);
73
+ }
74
+ }
75
+ }
76
+ exports.ExtensionPackageCollector = ExtensionPackageCollector;
77
77
  //# sourceMappingURL=extension-package-collector.js.map
@@ -1,66 +1,66 @@
1
- import { NpmRegistry, PublishedNodePackage, NodePackage } from './npm-registry';
2
- export interface Extension {
3
- frontendPreload?: string;
4
- frontendOnlyPreload?: string;
5
- frontend?: string;
6
- frontendOnly?: string;
7
- frontendElectron?: string;
8
- secondaryWindow?: string;
9
- backend?: string;
10
- backendElectron?: string;
11
- electronMain?: string;
12
- preload?: string;
13
- }
14
- export interface ExtensionPackageOptions {
15
- /**
16
- * Alias to use in place of the original package's name.
17
- */
18
- alias?: string;
19
- }
20
- export declare class ExtensionPackage {
21
- readonly raw: PublishedNodePackage & Partial<RawExtensionPackage>;
22
- protected readonly registry: NpmRegistry;
23
- protected _name: string;
24
- constructor(raw: PublishedNodePackage & Partial<RawExtensionPackage>, registry: NpmRegistry, options?: ExtensionPackageOptions);
25
- /**
26
- * The name of the extension's package as defined in "dependencies" (might be aliased)
27
- */
28
- get name(): string;
29
- get version(): string;
30
- get description(): string;
31
- get theiaExtensions(): Extension[];
32
- get installed(): boolean;
33
- get dependent(): string | undefined;
34
- get transitive(): boolean;
35
- get parent(): ExtensionPackage | undefined;
36
- protected view(): Promise<RawExtensionPackage.ViewState>;
37
- protected readme?: string;
38
- getReadme(): Promise<string>;
39
- protected resolveReadme(): Promise<string>;
40
- getAuthor(): string;
41
- }
42
- export interface RawExtensionPackage extends PublishedNodePackage {
43
- installed?: RawExtensionPackage.InstalledState;
44
- view?: RawExtensionPackage.ViewState;
45
- theiaExtensions: Extension[];
46
- }
47
- export declare namespace RawExtensionPackage {
48
- interface InstalledState {
49
- version: string;
50
- packagePath: string;
51
- transitive: boolean;
52
- parent?: ExtensionPackage;
53
- }
54
- class ViewState {
55
- protected readonly registry: NpmRegistry;
56
- readme?: string;
57
- tags?: {
58
- [tag: string]: string;
59
- };
60
- constructor(registry: NpmRegistry);
61
- get latestVersion(): string | undefined;
62
- }
63
- function is(pck: NodePackage | undefined): pck is RawExtensionPackage;
64
- function view(registry: NpmRegistry, name: string, version?: string): Promise<RawExtensionPackage | undefined>;
65
- }
1
+ import { NpmRegistry, PublishedNodePackage, NodePackage } from './npm-registry';
2
+ export interface Extension {
3
+ frontendPreload?: string;
4
+ frontendOnlyPreload?: string;
5
+ frontend?: string;
6
+ frontendOnly?: string;
7
+ frontendElectron?: string;
8
+ secondaryWindow?: string;
9
+ backend?: string;
10
+ backendElectron?: string;
11
+ electronMain?: string;
12
+ preload?: string;
13
+ }
14
+ export interface ExtensionPackageOptions {
15
+ /**
16
+ * Alias to use in place of the original package's name.
17
+ */
18
+ alias?: string;
19
+ }
20
+ export declare class ExtensionPackage {
21
+ readonly raw: PublishedNodePackage & Partial<RawExtensionPackage>;
22
+ protected readonly registry: NpmRegistry;
23
+ protected _name: string;
24
+ constructor(raw: PublishedNodePackage & Partial<RawExtensionPackage>, registry: NpmRegistry, options?: ExtensionPackageOptions);
25
+ /**
26
+ * The name of the extension's package as defined in "dependencies" (might be aliased)
27
+ */
28
+ get name(): string;
29
+ get version(): string;
30
+ get description(): string;
31
+ get theiaExtensions(): Extension[];
32
+ get installed(): boolean;
33
+ get dependent(): string | undefined;
34
+ get transitive(): boolean;
35
+ get parent(): ExtensionPackage | undefined;
36
+ protected view(): Promise<RawExtensionPackage.ViewState>;
37
+ protected readme?: string;
38
+ getReadme(): Promise<string>;
39
+ protected resolveReadme(): Promise<string>;
40
+ getAuthor(): string;
41
+ }
42
+ export interface RawExtensionPackage extends PublishedNodePackage {
43
+ installed?: RawExtensionPackage.InstalledState;
44
+ view?: RawExtensionPackage.ViewState;
45
+ theiaExtensions: Extension[];
46
+ }
47
+ export declare namespace RawExtensionPackage {
48
+ interface InstalledState {
49
+ version: string;
50
+ packagePath: string;
51
+ transitive: boolean;
52
+ parent?: ExtensionPackage;
53
+ }
54
+ class ViewState {
55
+ protected readonly registry: NpmRegistry;
56
+ readme?: string;
57
+ tags?: {
58
+ [tag: string]: string;
59
+ };
60
+ constructor(registry: NpmRegistry);
61
+ get latestVersion(): string | undefined;
62
+ }
63
+ function is(pck: NodePackage | undefined): pck is RawExtensionPackage;
64
+ function view(registry: NpmRegistry, name: string, version?: string): Promise<RawExtensionPackage | undefined>;
65
+ }
66
66
  //# sourceMappingURL=extension-package.d.ts.map