@theia/mini-browser 1.45.1 → 1.46.0-next.72
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 +45 -45
- package/lib/browser/environment/mini-browser-environment-module.d.ts +3 -3
- package/lib/browser/environment/mini-browser-environment-module.js +24 -24
- package/lib/browser/environment/mini-browser-environment.d.ts +25 -25
- package/lib/browser/environment/mini-browser-environment.js +95 -95
- package/lib/browser/environment/mini-browser-environment.js.map +1 -1
- package/lib/browser/location-mapper-service.d.ts +58 -58
- package/lib/browser/location-mapper-service.js +140 -140
- package/lib/browser/mini-browser-content-style.d.ts +17 -17
- package/lib/browser/mini-browser-content-style.js +36 -36
- package/lib/browser/mini-browser-content.d.ts +177 -177
- package/lib/browser/mini-browser-content.js +554 -554
- package/lib/browser/mini-browser-frontend-module.d.ts +4 -4
- package/lib/browser/mini-browser-frontend-module.js +70 -70
- package/lib/browser/mini-browser-frontend-security-warnings.d.ts +11 -11
- package/lib/browser/mini-browser-frontend-security-warnings.js +73 -73
- package/lib/browser/mini-browser-open-handler.d.ts +76 -76
- package/lib/browser/mini-browser-open-handler.js +292 -292
- package/lib/browser/mini-browser.d.ts +25 -25
- package/lib/browser/mini-browser.js +118 -118
- package/lib/common/mini-browser-endpoint.d.ts +12 -12
- package/lib/common/mini-browser-endpoint.js +31 -31
- package/lib/common/mini-browser-service.d.ts +14 -14
- package/lib/common/mini-browser-service.js +20 -20
- package/lib/electron-browser/environment/electron-mini-browser-environment-module.d.ts +3 -3
- package/lib/electron-browser/environment/electron-mini-browser-environment-module.js +25 -25
- package/lib/electron-browser/environment/electron-mini-browser-environment.d.ts +9 -9
- package/lib/electron-browser/environment/electron-mini-browser-environment.js +60 -60
- package/lib/electron-main/mini-browser-electron-main-contribution.d.ts +12 -12
- package/lib/electron-main/mini-browser-electron-main-contribution.js +54 -54
- package/lib/node/mini-browser-backend-module.d.ts +3 -3
- package/lib/node/mini-browser-backend-module.js +41 -41
- package/lib/node/mini-browser-backend-security-warnings.d.ts +5 -5
- package/lib/node/mini-browser-backend-security-warnings.js +51 -51
- package/lib/node/mini-browser-endpoint.d.ts +97 -97
- package/lib/node/mini-browser-endpoint.js +268 -268
- package/lib/node/mini-browser-endpoint.js.map +1 -1
- package/lib/node/mini-browser-ws-validator.d.ts +12 -12
- package/lib/node/mini-browser-ws-validator.js +69 -69
- package/lib/package.spec.js +18 -18
- package/package.json +5 -6
- package/src/browser/environment/mini-browser-environment-module.ts +24 -24
- package/src/browser/environment/mini-browser-environment.ts +87 -87
- package/src/browser/location-mapper-service.ts +150 -150
- package/src/browser/mini-browser-content-style.ts +32 -32
- package/src/browser/mini-browser-content.ts +630 -630
- package/src/browser/mini-browser-frontend-module.ts +86 -86
- package/src/browser/mini-browser-frontend-security-warnings.ts +59 -59
- package/src/browser/mini-browser-open-handler.ts +312 -312
- package/src/browser/mini-browser.ts +110 -110
- package/src/browser/pdfobject.d.ts +99 -99
- package/src/browser/style/index.css +157 -157
- package/src/browser/style/mini-browser.svg +17 -17
- package/src/common/mini-browser-endpoint.ts +28 -28
- package/src/common/mini-browser-service.ts +29 -29
- package/src/electron-browser/environment/electron-mini-browser-environment-module.ts +25 -25
- package/src/electron-browser/environment/electron-mini-browser-environment.ts +53 -53
- package/src/electron-main/mini-browser-electron-main-contribution.ts +42 -42
- package/src/node/mini-browser-backend-module.ts +41 -41
- package/src/node/mini-browser-backend-security-warnings.ts +45 -45
- package/src/node/mini-browser-endpoint.ts +315 -315
- package/src/node/mini-browser-ws-validator.ts +56 -56
- package/src/package.spec.ts +21 -21
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 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 { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
18
|
-
import URI from '@theia/core/lib/common/uri';
|
|
19
|
-
import { Endpoint } from '@theia/core/lib/browser';
|
|
20
|
-
import { MaybePromise, Prioritizeable } from '@theia/core/lib/common/types';
|
|
21
|
-
import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
|
22
|
-
import { MiniBrowserEnvironment } from './environment/mini-browser-environment';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Contribution for the `LocationMapperService`.
|
|
26
|
-
*/
|
|
27
|
-
export const LocationMapper = Symbol('LocationMapper');
|
|
28
|
-
export interface LocationMapper {
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Should return with a positive number if the current contribution can handle the given location.
|
|
32
|
-
* The number indicates the priority of the location mapper. If it is not a positive number, it means, the
|
|
33
|
-
* contribution cannot handle the location.
|
|
34
|
-
*/
|
|
35
|
-
canHandle(location: string): MaybePromise<number>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Maps the given location.
|
|
39
|
-
*/
|
|
40
|
-
map(location: string): MaybePromise<string>;
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Location mapper service.
|
|
46
|
-
*/
|
|
47
|
-
@injectable()
|
|
48
|
-
export class LocationMapperService {
|
|
49
|
-
|
|
50
|
-
@inject(ContributionProvider)
|
|
51
|
-
@named(LocationMapper)
|
|
52
|
-
protected readonly contributions: ContributionProvider<LocationMapper>;
|
|
53
|
-
|
|
54
|
-
async map(location: string): Promise<string> {
|
|
55
|
-
const contributions = await this.prioritize(location);
|
|
56
|
-
if (contributions.length === 0) {
|
|
57
|
-
return this.defaultMapper()(location);
|
|
58
|
-
}
|
|
59
|
-
return contributions[0].map(location);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
protected defaultMapper(): (location: string) => MaybePromise<string> {
|
|
63
|
-
return location => `${new Endpoint().httpScheme}//${location}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
protected async prioritize(location: string): Promise<LocationMapper[]> {
|
|
67
|
-
const prioritized = await Prioritizeable.prioritizeAll(this.getContributions(), contribution => contribution.canHandle(location));
|
|
68
|
-
return prioritized.map(p => p.value);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
protected getContributions(): LocationMapper[] {
|
|
72
|
-
return this.contributions.getContributions();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* HTTP location mapper.
|
|
79
|
-
*/
|
|
80
|
-
@injectable()
|
|
81
|
-
export class HttpLocationMapper implements LocationMapper {
|
|
82
|
-
|
|
83
|
-
canHandle(location: string): MaybePromise<number> {
|
|
84
|
-
return location.startsWith('http://') ? 1 : 0;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
map(location: string): MaybePromise<string> {
|
|
88
|
-
return location;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* HTTPS location mapper.
|
|
95
|
-
*/
|
|
96
|
-
@injectable()
|
|
97
|
-
export class HttpsLocationMapper implements LocationMapper {
|
|
98
|
-
|
|
99
|
-
canHandle(location: string): MaybePromise<number> {
|
|
100
|
-
return location.startsWith('https://') ? 1 : 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
map(location: string): MaybePromise<string> {
|
|
104
|
-
return location;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Location mapper for locations without a scheme.
|
|
111
|
-
*/
|
|
112
|
-
@injectable()
|
|
113
|
-
export class LocationWithoutSchemeMapper implements LocationMapper {
|
|
114
|
-
|
|
115
|
-
canHandle(location: string): MaybePromise<number> {
|
|
116
|
-
return new URI(location).scheme === '' ? 1 : 0;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
map(location: string): MaybePromise<string> {
|
|
120
|
-
return `http://${location}`;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* `file` URI location mapper.
|
|
127
|
-
*/
|
|
128
|
-
@injectable()
|
|
129
|
-
export class FileLocationMapper implements LocationMapper {
|
|
130
|
-
|
|
131
|
-
@inject(MiniBrowserEnvironment)
|
|
132
|
-
protected miniBrowserEnvironment: MiniBrowserEnvironment;
|
|
133
|
-
|
|
134
|
-
canHandle(location: string): MaybePromise<number> {
|
|
135
|
-
return location.startsWith('file://') ? 1 : 0;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async map(location: string): Promise<string> {
|
|
139
|
-
const uri = new URI(location);
|
|
140
|
-
if (uri.scheme !== 'file') {
|
|
141
|
-
throw new Error(`Only URIs with 'file' scheme can be mapped to an URL. URI was: ${uri}.`);
|
|
142
|
-
}
|
|
143
|
-
let rawLocation = uri.path.toString();
|
|
144
|
-
if (rawLocation.charAt(0) === '/') {
|
|
145
|
-
rawLocation = rawLocation.substring(1);
|
|
146
|
-
}
|
|
147
|
-
return this.miniBrowserEnvironment.getRandomEndpoint().getRestUrl().resolve(rawLocation).toString();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 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 { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
18
|
+
import URI from '@theia/core/lib/common/uri';
|
|
19
|
+
import { Endpoint } from '@theia/core/lib/browser';
|
|
20
|
+
import { MaybePromise, Prioritizeable } from '@theia/core/lib/common/types';
|
|
21
|
+
import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
|
22
|
+
import { MiniBrowserEnvironment } from './environment/mini-browser-environment';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Contribution for the `LocationMapperService`.
|
|
26
|
+
*/
|
|
27
|
+
export const LocationMapper = Symbol('LocationMapper');
|
|
28
|
+
export interface LocationMapper {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Should return with a positive number if the current contribution can handle the given location.
|
|
32
|
+
* The number indicates the priority of the location mapper. If it is not a positive number, it means, the
|
|
33
|
+
* contribution cannot handle the location.
|
|
34
|
+
*/
|
|
35
|
+
canHandle(location: string): MaybePromise<number>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Maps the given location.
|
|
39
|
+
*/
|
|
40
|
+
map(location: string): MaybePromise<string>;
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Location mapper service.
|
|
46
|
+
*/
|
|
47
|
+
@injectable()
|
|
48
|
+
export class LocationMapperService {
|
|
49
|
+
|
|
50
|
+
@inject(ContributionProvider)
|
|
51
|
+
@named(LocationMapper)
|
|
52
|
+
protected readonly contributions: ContributionProvider<LocationMapper>;
|
|
53
|
+
|
|
54
|
+
async map(location: string): Promise<string> {
|
|
55
|
+
const contributions = await this.prioritize(location);
|
|
56
|
+
if (contributions.length === 0) {
|
|
57
|
+
return this.defaultMapper()(location);
|
|
58
|
+
}
|
|
59
|
+
return contributions[0].map(location);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected defaultMapper(): (location: string) => MaybePromise<string> {
|
|
63
|
+
return location => `${new Endpoint().httpScheme}//${location}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected async prioritize(location: string): Promise<LocationMapper[]> {
|
|
67
|
+
const prioritized = await Prioritizeable.prioritizeAll(this.getContributions(), contribution => contribution.canHandle(location));
|
|
68
|
+
return prioritized.map(p => p.value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected getContributions(): LocationMapper[] {
|
|
72
|
+
return this.contributions.getContributions();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* HTTP location mapper.
|
|
79
|
+
*/
|
|
80
|
+
@injectable()
|
|
81
|
+
export class HttpLocationMapper implements LocationMapper {
|
|
82
|
+
|
|
83
|
+
canHandle(location: string): MaybePromise<number> {
|
|
84
|
+
return location.startsWith('http://') ? 1 : 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
map(location: string): MaybePromise<string> {
|
|
88
|
+
return location;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* HTTPS location mapper.
|
|
95
|
+
*/
|
|
96
|
+
@injectable()
|
|
97
|
+
export class HttpsLocationMapper implements LocationMapper {
|
|
98
|
+
|
|
99
|
+
canHandle(location: string): MaybePromise<number> {
|
|
100
|
+
return location.startsWith('https://') ? 1 : 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
map(location: string): MaybePromise<string> {
|
|
104
|
+
return location;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Location mapper for locations without a scheme.
|
|
111
|
+
*/
|
|
112
|
+
@injectable()
|
|
113
|
+
export class LocationWithoutSchemeMapper implements LocationMapper {
|
|
114
|
+
|
|
115
|
+
canHandle(location: string): MaybePromise<number> {
|
|
116
|
+
return new URI(location).scheme === '' ? 1 : 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
map(location: string): MaybePromise<string> {
|
|
120
|
+
return `http://${location}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* `file` URI location mapper.
|
|
127
|
+
*/
|
|
128
|
+
@injectable()
|
|
129
|
+
export class FileLocationMapper implements LocationMapper {
|
|
130
|
+
|
|
131
|
+
@inject(MiniBrowserEnvironment)
|
|
132
|
+
protected miniBrowserEnvironment: MiniBrowserEnvironment;
|
|
133
|
+
|
|
134
|
+
canHandle(location: string): MaybePromise<number> {
|
|
135
|
+
return location.startsWith('file://') ? 1 : 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async map(location: string): Promise<string> {
|
|
139
|
+
const uri = new URI(location);
|
|
140
|
+
if (uri.scheme !== 'file') {
|
|
141
|
+
throw new Error(`Only URIs with 'file' scheme can be mapped to an URL. URI was: ${uri}.`);
|
|
142
|
+
}
|
|
143
|
+
let rawLocation = uri.path.toString();
|
|
144
|
+
if (rawLocation.charAt(0) === '/') {
|
|
145
|
+
rawLocation = rawLocation.substring(1);
|
|
146
|
+
}
|
|
147
|
+
return this.miniBrowserEnvironment.getRandomEndpoint().getRestUrl().resolve(rawLocation).toString();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 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
|
-
export namespace MiniBrowserContentStyle {
|
|
17
|
-
export const MINI_BROWSER = 'theia-mini-browser';
|
|
18
|
-
export const TOOLBAR = 'theia-mini-browser-toolbar';
|
|
19
|
-
export const TOOLBAR_READ_ONLY = 'theia-mini-browser-toolbar-read-only';
|
|
20
|
-
export const PRE_LOAD = 'theia-mini-browser-load-indicator';
|
|
21
|
-
export const FADE_OUT = 'theia-fade-out';
|
|
22
|
-
export const CONTENT_AREA = 'theia-mini-browser-content-area';
|
|
23
|
-
export const PDF_CONTAINER = 'theia-mini-browser-pdf-container';
|
|
24
|
-
export const PREVIOUS = 'theia-mini-browser-previous';
|
|
25
|
-
export const NEXT = 'theia-mini-browser-next';
|
|
26
|
-
export const REFRESH = 'theia-mini-browser-refresh';
|
|
27
|
-
export const OPEN = 'theia-mini-browser-open';
|
|
28
|
-
export const BUTTON = 'theia-mini-browser-button';
|
|
29
|
-
export const DISABLED = 'theia-mini-browser-button-disabled';
|
|
30
|
-
export const TRANSPARENT_OVERLAY = 'theia-transparent-overlay';
|
|
31
|
-
export const ERROR_BAR = 'theia-mini-browser-error-bar';
|
|
32
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 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
|
+
export namespace MiniBrowserContentStyle {
|
|
17
|
+
export const MINI_BROWSER = 'theia-mini-browser';
|
|
18
|
+
export const TOOLBAR = 'theia-mini-browser-toolbar';
|
|
19
|
+
export const TOOLBAR_READ_ONLY = 'theia-mini-browser-toolbar-read-only';
|
|
20
|
+
export const PRE_LOAD = 'theia-mini-browser-load-indicator';
|
|
21
|
+
export const FADE_OUT = 'theia-fade-out';
|
|
22
|
+
export const CONTENT_AREA = 'theia-mini-browser-content-area';
|
|
23
|
+
export const PDF_CONTAINER = 'theia-mini-browser-pdf-container';
|
|
24
|
+
export const PREVIOUS = 'theia-mini-browser-previous';
|
|
25
|
+
export const NEXT = 'theia-mini-browser-next';
|
|
26
|
+
export const REFRESH = 'theia-mini-browser-refresh';
|
|
27
|
+
export const OPEN = 'theia-mini-browser-open';
|
|
28
|
+
export const BUTTON = 'theia-mini-browser-button';
|
|
29
|
+
export const DISABLED = 'theia-mini-browser-button-disabled';
|
|
30
|
+
export const TRANSPARENT_OVERLAY = 'theia-transparent-overlay';
|
|
31
|
+
export const ERROR_BAR = 'theia-mini-browser-error-bar';
|
|
32
|
+
}
|