@theia/application-manager 1.75.0-next.8 → 1.75.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.
Files changed (35) hide show
  1. package/lib/application-package-manager.d.ts +1 -0
  2. package/lib/application-package-manager.d.ts.map +1 -1
  3. package/lib/application-package-manager.js +14 -9
  4. package/lib/application-package-manager.js.map +1 -1
  5. package/lib/browser-only/prepare-browser-only-plugins.d.ts +12 -0
  6. package/lib/browser-only/prepare-browser-only-plugins.d.ts.map +1 -0
  7. package/lib/browser-only/prepare-browser-only-plugins.js +313 -0
  8. package/lib/browser-only/prepare-browser-only-plugins.js.map +1 -0
  9. package/lib/browser-only/prepare-browser-only-plugins.spec.d.ts +2 -0
  10. package/lib/browser-only/prepare-browser-only-plugins.spec.d.ts.map +1 -0
  11. package/lib/browser-only/prepare-browser-only-plugins.spec.js +136 -0
  12. package/lib/browser-only/prepare-browser-only-plugins.spec.js.map +1 -0
  13. package/lib/browser-only/write-browser-only-extensions-list.d.ts +7 -0
  14. package/lib/browser-only/write-browser-only-extensions-list.d.ts.map +1 -0
  15. package/lib/browser-only/write-browser-only-extensions-list.js +28 -0
  16. package/lib/browser-only/write-browser-only-extensions-list.js.map +1 -0
  17. package/lib/generator/bundler-generator.d.ts +7 -8
  18. package/lib/generator/bundler-generator.d.ts.map +1 -1
  19. package/lib/generator/bundler-generator.js +32 -563
  20. package/lib/generator/bundler-generator.js.map +1 -1
  21. package/lib/generator/frontend-generator.d.ts.map +1 -1
  22. package/lib/generator/frontend-generator.js +1 -3
  23. package/lib/generator/frontend-generator.js.map +1 -1
  24. package/package.json +11 -33
  25. package/src/application-package-manager.ts +16 -8
  26. package/src/browser-only/prepare-browser-only-plugins.spec.ts +169 -0
  27. package/src/browser-only/prepare-browser-only-plugins.ts +376 -0
  28. package/src/browser-only/write-browser-only-extensions-list.ts +27 -0
  29. package/src/generator/bundler-generator.ts +36 -568
  30. package/src/generator/frontend-generator.ts +1 -3
  31. package/lib/expose-loader.d.ts +0 -9
  32. package/lib/expose-loader.d.ts.map +0 -1
  33. package/lib/expose-loader.js +0 -73
  34. package/lib/expose-loader.js.map +0 -1
  35. package/src/expose-loader.ts +0 -83
@@ -1,9 +0,0 @@
1
- import type { RawSourceMap } from 'source-map';
2
- /**
3
- * Expose bundled modules on window.theia.moduleName namespace, e.g.
4
- * window['theia']['@theia/core/lib/common/uri'].
5
- * Such syntax can be used by external code, for instance, for testing.
6
- */
7
- declare const _default: (this: any, source: string, sourceMap?: RawSourceMap) => string | undefined;
8
- export = _default;
9
- //# sourceMappingURL=expose-loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expose-loader.d.ts","sourceRoot":"","sources":["../src/expose-loader.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA6B/C;;;;GAIG;yBAGgB,MAAM,GAAG,EAAE,QAAQ,MAAM,EAAE,YAAY,YAAY,KAAG,MAAM,GAAG,SAAS;AAA3F,kBA2BE"}
@@ -1,73 +0,0 @@
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-only 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
- // Use `module.exports` with a fallback to `this` for compatibility with ESM modules.
40
- // Webpack wraps ESM modules in arrow functions where `this` is `undefined`,
41
- // but `module.exports` is available and points to the webpack exports object.
42
- return source + `\n;(globalThis['theia'] = globalThis['theia'] || {})['${moduleName}'] = (typeof module === 'object' && module.exports) || this;\n`;
43
- }
44
- module.exports = function (source, sourceMap) {
45
- if (this.cacheable) {
46
- this.cacheable();
47
- }
48
- let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir + path.sep));
49
- if (modulePackage) {
50
- this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
51
- return;
52
- }
53
- const searchString = path.sep + 'node_modules';
54
- const index = this.resourcePath.lastIndexOf(searchString);
55
- if (index !== -1) {
56
- const nodeModulesPath = this.resourcePath.substring(0, index + searchString.length);
57
- let dir = this.resourcePath;
58
- while ((dir = path.dirname(dir)) !== nodeModulesPath) {
59
- try {
60
- const { name } = fs.readJSONSync(path.join(dir, 'package.json'));
61
- modulePackage = { name, dir };
62
- modulePackages.push(modulePackage);
63
- this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
64
- return;
65
- }
66
- catch {
67
- /** no-op */
68
- }
69
- }
70
- }
71
- this.callback(undefined, source, sourceMap);
72
- };
73
- //# sourceMappingURL=expose-loader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expose-loader.js","sourceRoot":"","sources":["../src/expose-loader.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;A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IAAI,EAAE,GAAG,EAAE,CAAC;gBAC9B,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBACnC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;gBAC5F,OAAO;YACX,CAAC;YAAC,MAAM,CAAC;gBACL,YAAY;YAChB,CAAC;QACL,CAAC;IACL,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC,CAAC"}
@@ -1,83 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 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 * as fs from 'fs-extra';
18
- import * as path from 'path';
19
- // eslint-disable-next-line import/no-extraneous-dependencies
20
- import type { RawSourceMap } from 'source-map';
21
- import { ApplicationPackage } from '@theia/application-package/lib/application-package';
22
-
23
- const modulePackages: { dir: string, name?: string }[] = [];
24
- for (const extensionPackage of new ApplicationPackage({ projectPath: process.cwd() }).extensionPackages) {
25
- modulePackages.push({
26
- name: extensionPackage.name,
27
- dir: path.dirname(extensionPackage.raw.installed!.packagePath)
28
- });
29
- }
30
-
31
- function exposeModule(modulePackage: { dir: string, name?: string }, resourcePath: string, source: string): string {
32
- if (!modulePackage.name) {
33
- return source;
34
- }
35
- const { dir, name } = path.parse(resourcePath);
36
- let moduleName = path.join(modulePackage.name, dir.substring(modulePackage.dir.length));
37
- if (name !== 'index') {
38
- moduleName = path.join(moduleName, name);
39
- }
40
- if (path.sep !== '/') {
41
- moduleName = moduleName.split(path.sep).join('/');
42
- }
43
- // Use `module.exports` with a fallback to `this` for compatibility with ESM modules.
44
- // Webpack wraps ESM modules in arrow functions where `this` is `undefined`,
45
- // but `module.exports` is available and points to the webpack exports object.
46
- return source + `\n;(globalThis['theia'] = globalThis['theia'] || {})['${moduleName}'] = (typeof module === 'object' && module.exports) || this;\n`;
47
- }
48
-
49
- /**
50
- * Expose bundled modules on window.theia.moduleName namespace, e.g.
51
- * window['theia']['@theia/core/lib/common/uri'].
52
- * Such syntax can be used by external code, for instance, for testing.
53
- */
54
- // TODO: webpack@5.36.2 is missing a `LoaderContext` interface so we'll use any in the meantime
55
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- export = function (this: any, source: string, sourceMap?: RawSourceMap): string | undefined {
57
- if (this.cacheable) {
58
- this.cacheable();
59
- }
60
- let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir + path.sep));
61
- if (modulePackage) {
62
- this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
63
- return;
64
- }
65
- const searchString = path.sep + 'node_modules';
66
- const index = this.resourcePath.lastIndexOf(searchString);
67
- if (index !== -1) {
68
- const nodeModulesPath = this.resourcePath.substring(0, index + searchString.length);
69
- let dir = this.resourcePath;
70
- while ((dir = path.dirname(dir)) !== nodeModulesPath) {
71
- try {
72
- const { name } = fs.readJSONSync(path.join(dir, 'package.json'));
73
- modulePackage = { name, dir };
74
- modulePackages.push(modulePackage);
75
- this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
76
- return;
77
- } catch {
78
- /** no-op */
79
- }
80
- }
81
- }
82
- this.callback(undefined, source, sourceMap);
83
- };