@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,299 +1,299 @@
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.WebpackGenerator = void 0;
19
- const paths = require("path");
20
- const fs = require("fs-extra");
21
- const abstract_generator_1 = require("./abstract-generator");
22
- class WebpackGenerator extends abstract_generator_1.AbstractGenerator {
23
- async generate() {
24
- await this.write(this.genConfigPath, this.compileWebpackConfig());
25
- if (await this.shouldGenerateUserWebpackConfig()) {
26
- await this.write(this.configPath, this.compileUserWebpackConfig());
27
- }
28
- }
29
- async shouldGenerateUserWebpackConfig() {
30
- if (!(await fs.pathExists(this.configPath))) {
31
- return true;
32
- }
33
- const content = await fs.readFile(this.configPath, 'utf8');
34
- return content.indexOf('gen-webpack') === -1;
35
- }
36
- get configPath() {
37
- return this.pck.path('webpack.config.js');
38
- }
39
- get genConfigPath() {
40
- return this.pck.path('gen-webpack.config.js');
41
- }
42
- resolve(moduleName, path) {
43
- return this.pck.resolveModulePath(moduleName, path).split(paths.sep).join('/');
44
- }
45
- compileWebpackConfig() {
46
- return `/**
47
- * Don't touch this file. It will be regenerated by theia build.
48
- * To customize webpack configuration change ${this.configPath}
49
- */
50
- // @ts-check
51
- const path = require('path');
52
- const webpack = require('webpack');
53
- const yargs = require('yargs');
54
- const CopyWebpackPlugin = require('copy-webpack-plugin');
55
- const CompressionPlugin = require('compression-webpack-plugin')
56
- const MiniCssExtractPlugin = require('mini-css-extract-plugin')
57
-
58
- const outputPath = path.resolve(__dirname, 'lib');
59
- const { mode, staticCompression } = yargs.option('mode', {
60
- description: "Mode to use",
61
- choices: ["development", "production"],
62
- default: "production"
63
- }).option('static-compression', {
64
- description: 'Controls whether to enable compression of static artifacts.',
65
- type: 'boolean',
66
- default: true
67
- }).argv;
68
- const development = mode === 'development';
69
-
70
- const plugins = [
71
- new CopyWebpackPlugin({
72
- patterns: [{
73
- // copy secondary window html file to lib folder
74
- from: path.resolve(__dirname, 'src-gen/frontend/secondary-window.html')
75
- }]
76
- }),
77
- new webpack.ProvidePlugin({
78
- // the Buffer class doesn't exist in the browser but some dependencies rely on it
79
- Buffer: ['buffer', 'Buffer']
80
- })
81
- ];
82
- // it should go after copy-plugin in order to compress monaco as well
83
- if (staticCompression) {
84
- plugins.push(new CompressionPlugin({}));
85
- }
86
-
87
- module.exports = [{
88
- mode,
89
- plugins,
90
- devtool: 'source-map',
91
- entry: {
92
- bundle: path.resolve(__dirname, 'src-gen/frontend/index.js'),
93
- ${this.ifMonaco(() => "'editor.worker': '@theia/monaco-editor-core/esm/vs/editor/editor.worker.js'")}
94
- },
95
- output: {
96
- filename: '[name].js',
97
- path: outputPath,
98
- devtoolModuleFilenameTemplate: 'webpack:///[resource-path]?[loaders]',
99
- globalObject: 'self'
100
- },
101
- target: '${this.ifBrowser('web', 'electron-renderer')}',
102
- cache: staticCompression,
103
- module: {
104
- rules: [
105
- {
106
- // Removes the host check in PhosphorJS to enable moving widgets to secondary windows.
107
- test: /widget\\.js$/,
108
- loader: 'string-replace-loader',
109
- include: /node_modules[\\\\/]@phosphor[\\\\/]widgets[\\\\/]lib/,
110
- options: {
111
- multiple: [
112
- {
113
- search: /document\\.body\\.contains\\(widget.node\\)/gm,
114
- replace: 'widget.node.ownerDocument.body.contains(widget.node)'
115
- },
116
- {
117
- search: /\\!document\\.body\\.contains\\(host\\)/gm,
118
- replace: ' !host.ownerDocument.body.contains(host)'
119
- }
120
- ]
121
- }
122
- },
123
- {
124
- test: /\\.css$/,
125
- exclude: /materialcolors\\.css$|\\.useable\\.css$/,
126
- use: ['style-loader', 'css-loader']
127
- },
128
- {
129
- test: /materialcolors\\.css$|\\.useable\\.css$/,
130
- use: [
131
- {
132
- loader: 'style-loader',
133
- options: {
134
- esModule: false,
135
- injectType: 'lazySingletonStyleTag',
136
- attributes: {
137
- id: 'theia-theme'
138
- }
139
- }
140
- },
141
- 'css-loader'
142
- ]
143
- },
144
- {
145
- test: /\\.(ttf|eot|svg)(\\?v=\\d+\\.\\d+\\.\\d+)?$/,
146
- type: 'asset',
147
- parser: {
148
- dataUrlCondition: {
149
- maxSize: 10000,
150
- }
151
- },
152
- generator: {
153
- dataUrl: {
154
- mimetype: 'image/svg+xml'
155
- }
156
- }
157
- },
158
- {
159
- test: /\\.(jpg|png|gif)$/,
160
- type: 'asset/resource',
161
- generator: {
162
- filename: '[hash].[ext]'
163
- }
164
- },
165
- {
166
- // see https://github.com/eclipse-theia/theia/issues/556
167
- test: /source-map-support/,
168
- loader: 'ignore-loader'
169
- },
170
- {
171
- test: /\\.js$/,
172
- enforce: 'pre',
173
- loader: 'source-map-loader',
174
- exclude: /jsonc-parser|fast-plist|onigasm/
175
- },
176
- {
177
- test: /\\.woff(2)?(\\?v=[0-9]\\.[0-9]\\.[0-9])?$/,
178
- type: 'asset',
179
- parser: {
180
- dataUrlCondition: {
181
- maxSize: 10000,
182
- }
183
- },
184
- generator: {
185
- dataUrl: {
186
- mimetype: 'image/svg+xml'
187
- }
188
- }
189
- },
190
- {
191
- test: /node_modules[\\\\|\/](vscode-languageserver-types|vscode-uri|jsonc-parser|vscode-languageserver-protocol)/,
192
- loader: 'umd-compat-loader'
193
- },
194
- {
195
- test: /\\.wasm$/,
196
- type: 'asset/resource'
197
- },
198
- {
199
- test: /\\.plist$/,
200
- type: 'asset/resource'
201
- }
202
- ]
203
- },
204
- resolve: {
205
- fallback: {
206
- 'child_process': false,
207
- 'crypto': false,
208
- 'net': false,
209
- 'path': require.resolve('path-browserify'),
210
- 'process': false,
211
- 'os': false,
212
- 'timers': false
213
- },
214
- extensions: ['.js']
215
- },
216
- stats: {
217
- warnings: true,
218
- children: true
219
- },
220
- ignoreWarnings: [
221
- // Some packages do not have source maps, that's ok
222
- /Failed to parse source map/,
223
- {
224
- // Monaco uses 'require' in a non-standard way
225
- module: /@theia\\/monaco-editor-core/,
226
- message: /require function is used in a way in which dependencies cannot be statically extracted/
227
- }
228
- ]
229
- },
230
- {
231
- mode,
232
- plugins: [
233
- new MiniCssExtractPlugin({
234
- // Options similar to the same options in webpackOptions.output
235
- // both options are optional
236
- filename: "[name].css",
237
- chunkFilename: "[id].css",
238
- }),
239
- ],
240
- devtool: 'source-map',
241
- entry: {
242
- "secondary-window": path.resolve(__dirname, 'src-gen/frontend/secondary-index.js'),
243
- },
244
- output: {
245
- filename: '[name].js',
246
- path: outputPath,
247
- devtoolModuleFilenameTemplate: 'webpack:///[resource-path]?[loaders]',
248
- globalObject: 'self'
249
- },
250
- target: 'electron-renderer',
251
- cache: staticCompression,
252
- module: {
253
- rules: [
254
- {
255
- test: /\.css$/i,
256
- use: [MiniCssExtractPlugin.loader, "css-loader"]
257
- }
258
- ]
259
- },
260
- resolve: {
261
- fallback: {
262
- 'child_process': false,
263
- 'crypto': false,
264
- 'net': false,
265
- 'path': require.resolve('path-browserify'),
266
- 'process': false,
267
- 'os': false,
268
- 'timers': false
269
- },
270
- extensions: ['.js']
271
- },
272
- stats: {
273
- warnings: true,
274
- children: true
275
- }
276
- }];`;
277
- }
278
- compileUserWebpackConfig() {
279
- return `/**
280
- * This file can be edited to customize webpack configuration.
281
- * To reset delete this file and rerun theia build again.
282
- */
283
- // @ts-check
284
- const config = require('./${paths.basename(this.genConfigPath)}');
285
-
286
- /**
287
- * Expose bundled modules on window.theia.moduleName namespace, e.g.
288
- * window['theia']['@theia/core/lib/common/uri'].
289
- * Such syntax can be used by external code, for instance, for testing.
290
- config.module.rules.push({
291
- test: /\\.js$/,
292
- loader: require.resolve('@theia/application-manager/lib/expose-loader')
293
- }); */
294
-
295
- module.exports = config;`;
296
- }
297
- }
298
- exports.WebpackGenerator = WebpackGenerator;
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.WebpackGenerator = void 0;
19
+ const paths = require("path");
20
+ const fs = require("fs-extra");
21
+ const abstract_generator_1 = require("./abstract-generator");
22
+ class WebpackGenerator extends abstract_generator_1.AbstractGenerator {
23
+ async generate() {
24
+ await this.write(this.genConfigPath, this.compileWebpackConfig());
25
+ if (await this.shouldGenerateUserWebpackConfig()) {
26
+ await this.write(this.configPath, this.compileUserWebpackConfig());
27
+ }
28
+ }
29
+ async shouldGenerateUserWebpackConfig() {
30
+ if (!(await fs.pathExists(this.configPath))) {
31
+ return true;
32
+ }
33
+ const content = await fs.readFile(this.configPath, 'utf8');
34
+ return content.indexOf('gen-webpack') === -1;
35
+ }
36
+ get configPath() {
37
+ return this.pck.path('webpack.config.js');
38
+ }
39
+ get genConfigPath() {
40
+ return this.pck.path('gen-webpack.config.js');
41
+ }
42
+ resolve(moduleName, path) {
43
+ return this.pck.resolveModulePath(moduleName, path).split(paths.sep).join('/');
44
+ }
45
+ compileWebpackConfig() {
46
+ return `/**
47
+ * Don't touch this file. It will be regenerated by theia build.
48
+ * To customize webpack configuration change ${this.configPath}
49
+ */
50
+ // @ts-check
51
+ const path = require('path');
52
+ const webpack = require('webpack');
53
+ const yargs = require('yargs');
54
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
55
+ const CompressionPlugin = require('compression-webpack-plugin')
56
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
57
+
58
+ const outputPath = path.resolve(__dirname, 'lib');
59
+ const { mode, staticCompression } = yargs.option('mode', {
60
+ description: "Mode to use",
61
+ choices: ["development", "production"],
62
+ default: "production"
63
+ }).option('static-compression', {
64
+ description: 'Controls whether to enable compression of static artifacts.',
65
+ type: 'boolean',
66
+ default: true
67
+ }).argv;
68
+ const development = mode === 'development';
69
+
70
+ const plugins = [
71
+ new CopyWebpackPlugin({
72
+ patterns: [{
73
+ // copy secondary window html file to lib folder
74
+ from: path.resolve(__dirname, 'src-gen/frontend/secondary-window.html')
75
+ }]
76
+ }),
77
+ new webpack.ProvidePlugin({
78
+ // the Buffer class doesn't exist in the browser but some dependencies rely on it
79
+ Buffer: ['buffer', 'Buffer']
80
+ })
81
+ ];
82
+ // it should go after copy-plugin in order to compress monaco as well
83
+ if (staticCompression) {
84
+ plugins.push(new CompressionPlugin({}));
85
+ }
86
+
87
+ module.exports = [{
88
+ mode,
89
+ plugins,
90
+ devtool: 'source-map',
91
+ entry: {
92
+ bundle: path.resolve(__dirname, 'src-gen/frontend/index.js'),
93
+ ${this.ifMonaco(() => "'editor.worker': '@theia/monaco-editor-core/esm/vs/editor/editor.worker.js'")}
94
+ },
95
+ output: {
96
+ filename: '[name].js',
97
+ path: outputPath,
98
+ devtoolModuleFilenameTemplate: 'webpack:///[resource-path]?[loaders]',
99
+ globalObject: 'self'
100
+ },
101
+ target: '${this.ifBrowser('web', 'electron-renderer')}',
102
+ cache: staticCompression,
103
+ module: {
104
+ rules: [
105
+ {
106
+ // Removes the host check in PhosphorJS to enable moving widgets to secondary windows.
107
+ test: /widget\\.js$/,
108
+ loader: 'string-replace-loader',
109
+ include: /node_modules[\\\\/]@phosphor[\\\\/]widgets[\\\\/]lib/,
110
+ options: {
111
+ multiple: [
112
+ {
113
+ search: /document\\.body\\.contains\\(widget.node\\)/gm,
114
+ replace: 'widget.node.ownerDocument.body.contains(widget.node)'
115
+ },
116
+ {
117
+ search: /\\!document\\.body\\.contains\\(host\\)/gm,
118
+ replace: ' !host.ownerDocument.body.contains(host)'
119
+ }
120
+ ]
121
+ }
122
+ },
123
+ {
124
+ test: /\\.css$/,
125
+ exclude: /materialcolors\\.css$|\\.useable\\.css$/,
126
+ use: ['style-loader', 'css-loader']
127
+ },
128
+ {
129
+ test: /materialcolors\\.css$|\\.useable\\.css$/,
130
+ use: [
131
+ {
132
+ loader: 'style-loader',
133
+ options: {
134
+ esModule: false,
135
+ injectType: 'lazySingletonStyleTag',
136
+ attributes: {
137
+ id: 'theia-theme'
138
+ }
139
+ }
140
+ },
141
+ 'css-loader'
142
+ ]
143
+ },
144
+ {
145
+ test: /\\.(ttf|eot|svg)(\\?v=\\d+\\.\\d+\\.\\d+)?$/,
146
+ type: 'asset',
147
+ parser: {
148
+ dataUrlCondition: {
149
+ maxSize: 10000,
150
+ }
151
+ },
152
+ generator: {
153
+ dataUrl: {
154
+ mimetype: 'image/svg+xml'
155
+ }
156
+ }
157
+ },
158
+ {
159
+ test: /\\.(jpg|png|gif)$/,
160
+ type: 'asset/resource',
161
+ generator: {
162
+ filename: '[hash].[ext]'
163
+ }
164
+ },
165
+ {
166
+ // see https://github.com/eclipse-theia/theia/issues/556
167
+ test: /source-map-support/,
168
+ loader: 'ignore-loader'
169
+ },
170
+ {
171
+ test: /\\.js$/,
172
+ enforce: 'pre',
173
+ loader: 'source-map-loader',
174
+ exclude: /jsonc-parser|fast-plist|onigasm/
175
+ },
176
+ {
177
+ test: /\\.woff(2)?(\\?v=[0-9]\\.[0-9]\\.[0-9])?$/,
178
+ type: 'asset',
179
+ parser: {
180
+ dataUrlCondition: {
181
+ maxSize: 10000,
182
+ }
183
+ },
184
+ generator: {
185
+ dataUrl: {
186
+ mimetype: 'image/svg+xml'
187
+ }
188
+ }
189
+ },
190
+ {
191
+ test: /node_modules[\\\\|\/](vscode-languageserver-types|vscode-uri|jsonc-parser|vscode-languageserver-protocol)/,
192
+ loader: 'umd-compat-loader'
193
+ },
194
+ {
195
+ test: /\\.wasm$/,
196
+ type: 'asset/resource'
197
+ },
198
+ {
199
+ test: /\\.plist$/,
200
+ type: 'asset/resource'
201
+ }
202
+ ]
203
+ },
204
+ resolve: {
205
+ fallback: {
206
+ 'child_process': false,
207
+ 'crypto': false,
208
+ 'net': false,
209
+ 'path': require.resolve('path-browserify'),
210
+ 'process': false,
211
+ 'os': false,
212
+ 'timers': false
213
+ },
214
+ extensions: ['.js']
215
+ },
216
+ stats: {
217
+ warnings: true,
218
+ children: true
219
+ },
220
+ ignoreWarnings: [
221
+ // Some packages do not have source maps, that's ok
222
+ /Failed to parse source map/,
223
+ {
224
+ // Monaco uses 'require' in a non-standard way
225
+ module: /@theia\\/monaco-editor-core/,
226
+ message: /require function is used in a way in which dependencies cannot be statically extracted/
227
+ }
228
+ ]
229
+ },
230
+ {
231
+ mode,
232
+ plugins: [
233
+ new MiniCssExtractPlugin({
234
+ // Options similar to the same options in webpackOptions.output
235
+ // both options are optional
236
+ filename: "[name].css",
237
+ chunkFilename: "[id].css",
238
+ }),
239
+ ],
240
+ devtool: 'source-map',
241
+ entry: {
242
+ "secondary-window": path.resolve(__dirname, 'src-gen/frontend/secondary-index.js'),
243
+ },
244
+ output: {
245
+ filename: '[name].js',
246
+ path: outputPath,
247
+ devtoolModuleFilenameTemplate: 'webpack:///[resource-path]?[loaders]',
248
+ globalObject: 'self'
249
+ },
250
+ target: 'electron-renderer',
251
+ cache: staticCompression,
252
+ module: {
253
+ rules: [
254
+ {
255
+ test: /\.css$/i,
256
+ use: [MiniCssExtractPlugin.loader, "css-loader"]
257
+ }
258
+ ]
259
+ },
260
+ resolve: {
261
+ fallback: {
262
+ 'child_process': false,
263
+ 'crypto': false,
264
+ 'net': false,
265
+ 'path': require.resolve('path-browserify'),
266
+ 'process': false,
267
+ 'os': false,
268
+ 'timers': false
269
+ },
270
+ extensions: ['.js']
271
+ },
272
+ stats: {
273
+ warnings: true,
274
+ children: true
275
+ }
276
+ }];`;
277
+ }
278
+ compileUserWebpackConfig() {
279
+ return `/**
280
+ * This file can be edited to customize webpack configuration.
281
+ * To reset delete this file and rerun theia build again.
282
+ */
283
+ // @ts-check
284
+ const config = require('./${paths.basename(this.genConfigPath)}');
285
+
286
+ /**
287
+ * Expose bundled modules on window.theia.moduleName namespace, e.g.
288
+ * window['theia']['@theia/core/lib/common/uri'].
289
+ * Such syntax can be used by external code, for instance, for testing.
290
+ config.module.rules.push({
291
+ test: /\\.js$/,
292
+ loader: require.resolve('@theia/application-manager/lib/expose-loader')
293
+ }); */
294
+
295
+ module.exports = config;`;
296
+ }
297
+ }
298
+ exports.WebpackGenerator = WebpackGenerator;
299
299
  //# sourceMappingURL=webpack-generator.js.map
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './rebuild';
2
- export * from './application-package-manager';
3
- export * from './application-process';
1
+ export * from './rebuild';
2
+ export * from './application-package-manager';
3
+ export * from './application-process';
4
4
  //# sourceMappingURL=index.d.ts.map