@finos/legend-application 15.0.66 → 15.0.68
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/lib/application/LegendApplication.d.ts +3 -0
- package/lib/application/LegendApplication.d.ts.map +1 -1
- package/lib/application/LegendApplication.js +11 -0
- package/lib/application/LegendApplication.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/util/DownloadHelperServiceWorker.d.ts +19 -0
- package/lib/util/DownloadHelperServiceWorker.d.ts.map +1 -0
- package/lib/util/DownloadHelperServiceWorker.js +132 -0
- package/lib/util/DownloadHelperServiceWorker.js.map +1 -0
- package/package.json +3 -3
- package/src/application/LegendApplication.ts +15 -0
- package/src/index.ts +1 -0
- package/src/util/DownloadHelperServiceWorker.ts +181 -0
- package/tsconfig.json +1 -0
|
@@ -46,6 +46,8 @@ export declare abstract class LegendApplication {
|
|
|
46
46
|
protected baseAddress: string;
|
|
47
47
|
protected pluginRegister?: ((pluginManager: LegendApplicationPluginManager<LegendApplicationPlugin>, config: LegendApplicationConfig) => void) | undefined;
|
|
48
48
|
protected _isConfigured: boolean;
|
|
49
|
+
protected downloadHelperServiceWorkerPath: string | undefined;
|
|
50
|
+
protected downloadHelper: boolean;
|
|
49
51
|
protected constructor(pluginManager: LegendApplicationPluginManager<LegendApplicationPlugin>);
|
|
50
52
|
setup(options: {
|
|
51
53
|
/** Base URL of the application. e.g. /studio/, /query/ */
|
|
@@ -60,6 +62,7 @@ export declare abstract class LegendApplication {
|
|
|
60
62
|
protected withBasePlugins(plugins: AbstractPlugin[]): LegendApplication;
|
|
61
63
|
withPresets(presets: AbstractPreset[]): LegendApplication;
|
|
62
64
|
withPlugins(plugins: AbstractPlugin[]): LegendApplication;
|
|
65
|
+
withDownloadHelper(path?: string | undefined): LegendApplication;
|
|
63
66
|
fetchApplicationConfiguration(baseUrl: string): Promise<[LegendApplicationConfig, ExtensionsConfigurationData]>;
|
|
64
67
|
loadDocumentationRegistryData(config: LegendApplicationConfig): Promise<void>;
|
|
65
68
|
protected abstract configureApplication(input: LegendApplicationConfigurationInput<LegendApplicationConfigurationData>): Promise<LegendApplicationConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendApplication.d.ts","sourceRoot":"","sources":["../../src/application/LegendApplication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,QAAQ,EAKR,KAAK,2BAA2B,EAEjC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAC1F,OAAO,EAEL,KAAK,sBAAsB,EAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"LegendApplication.d.ts","sourceRoot":"","sources":["../../src/application/LegendApplication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,QAAQ,EAKR,KAAK,2BAA2B,EAEjC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAC1F,OAAO,EAEL,KAAK,sBAAsB,EAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAA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uB,GAC9B,OAAO,CAAC,IAAI,CAAC;IAmEhB,SAAS,CAAC,QAAQ,CAAC,oBAAoB,CACrC,KAAK,EAAE,mCAAmC,CAAC,kCAAkC,CAAC,GAC7E,OAAO,CAAC,uBAAuB,CAAC;IAEnC,SAAS,CAAC,QAAQ,CAAC,eAAe,CAChC,gBAAgB,EAAE,gBAAgB,CAChC,uBAAuB,EACvB,8BAA8B,CAAC,uBAAuB,CAAC,CACxD,GACA,OAAO,CAAC,IAAI,CAAC;IAEV,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAuD7B;AAED,eAAO,MAAM,mCAAmC,4BAA4B,CAAC;AAG7E,eAAO,MAAM,yBAAyB,QAAO,OAY5C,CAAC"}
|
|
@@ -17,6 +17,7 @@ import { assertErrorThrown, LogEvent, guaranteeNonEmptyString, assertNonNullable
|
|
|
17
17
|
import { APPLICATION_EVENT } from '../__lib__/LegendApplicationEvent.js';
|
|
18
18
|
import { collectKeyedDocumentationEntriesFromConfig, } from '../stores/DocumentationService.js';
|
|
19
19
|
import { ApplicationStore } from '../stores/ApplicationStore.js';
|
|
20
|
+
import { registerDownloadHelperServiceWorker } from '../util/DownloadHelperServiceWorker.js';
|
|
20
21
|
export class LegendApplicationLogger {
|
|
21
22
|
}
|
|
22
23
|
export class LegendApplicationWebConsole extends LegendApplicationLogger {
|
|
@@ -46,6 +47,8 @@ export class LegendApplication {
|
|
|
46
47
|
baseAddress;
|
|
47
48
|
pluginRegister;
|
|
48
49
|
_isConfigured = false;
|
|
50
|
+
downloadHelperServiceWorkerPath;
|
|
51
|
+
downloadHelper = false;
|
|
49
52
|
constructor(pluginManager) {
|
|
50
53
|
this.pluginManager = pluginManager;
|
|
51
54
|
this.logger = new LegendApplicationWebConsole();
|
|
@@ -72,6 +75,11 @@ export class LegendApplication {
|
|
|
72
75
|
this.pluginManager.usePlugins([...this.basePlugins, ...plugins]);
|
|
73
76
|
return this;
|
|
74
77
|
}
|
|
78
|
+
withDownloadHelper(path) {
|
|
79
|
+
this.downloadHelper = true;
|
|
80
|
+
this.downloadHelperServiceWorkerPath = path;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
75
83
|
async fetchApplicationConfiguration(baseUrl) {
|
|
76
84
|
const client = new NetworkClient();
|
|
77
85
|
// app config
|
|
@@ -171,6 +179,9 @@ export class LegendApplication {
|
|
|
171
179
|
// load application
|
|
172
180
|
await this.loadApplication(applicationStore);
|
|
173
181
|
this.logger.info(LogEvent.create(APPLICATION_EVENT.APPLICATION_LOAD__SUCCESS), 'Legend application loaded');
|
|
182
|
+
if (this.downloadHelper) {
|
|
183
|
+
registerDownloadHelperServiceWorker(this.downloadHelperServiceWorkerPath);
|
|
184
|
+
}
|
|
174
185
|
}
|
|
175
186
|
catch (error) {
|
|
176
187
|
assertErrorThrown(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendApplication.js","sourceRoot":"","sources":["../../src/application/LegendApplication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAGL,iBAAiB,EACjB,QAAQ,EACR,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EAGb,sCAAsC,GACvC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EACL,0CAA0C,GAI3C,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"LegendApplication.js","sourceRoot":"","sources":["../../src/application/LegendApplication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAGL,iBAAiB,EACjB,QAAQ,EACR,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EAGb,sCAAsC,GACvC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EACL,0CAA0C,G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A2C,CAAC,CAAC;IAC1E,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/lib/index.css
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from './components/useCommands.js';
|
|
|
29
29
|
export { forceDispatchKeyboardEvent, BackdropContainer, } from './components/ApplicationComponentFrameworkProvider.js';
|
|
30
30
|
export * from './stores/ApplicationStore.js';
|
|
31
31
|
export { NAVIGATION_ZONE_SEPARATOR, NavigationService, type NavigationAddress, type NavigationLocation, type NavigationZone, } from './stores/navigation/NavigationService.js';
|
|
32
|
+
export { downloadStream } from './util/DownloadHelperServiceWorker.js';
|
|
32
33
|
export * from './stores/storage/ApplicationStorage.js';
|
|
33
34
|
export * from './stores/storage/StorageService.js';
|
|
34
35
|
export * from './stores/SettingService.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,+BAA+B,CAAC;AAE9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC;AACzD,cAAc,iDAAiD,CAAC;AAEhE,cAAc,qCAAqC,CAAC;AACpD,cAAc,yCAAyC,CAAC;AACxD,cAAc,uCAAuC,CAAC;AACtD,cAAc,6CAA6C,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,0CAA0C,CAAC;AAE1F,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,iDAAiD,CAAC;AAChE,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,uDAAuD,CAAC;AAE/D,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,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AAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iDAAiD,CAAC;AAChE,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export * from './components/useCommands.js';
|
|
|
29
29
|
export { forceDispatchKeyboardEvent, BackdropContainer, } from './components/ApplicationComponentFrameworkProvider.js';
|
|
30
30
|
export * from './stores/ApplicationStore.js';
|
|
31
31
|
export { NAVIGATION_ZONE_SEPARATOR, NavigationService, } from './stores/navigation/NavigationService.js';
|
|
32
|
+
export { downloadStream } from './util/DownloadHelperServiceWorker.js';
|
|
32
33
|
export * from './stores/storage/ApplicationStorage.js';
|
|
33
34
|
export * from './stores/storage/StorageService.js';
|
|
34
35
|
export * from './stores/SettingService.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,+BAA+B,CAAC;AAE9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC;AACzD,cAAc,iDAAiD,CAAC;AAEhE,cAAc,qCAAqC,CAAC;AACpD,cAAc,yCAAyC,CAAC;AACxD,cAAc,uCAAuC,CAAC;AACtD,cAAc,6CAA6C,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,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O,EACL,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,uDAAuD,CAAC;AAE/D,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAIlB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iDAAiD,CAAC;AAChE,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/lib/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { type ContentType } from '@finos/legend-shared';
|
|
17
|
+
export declare function downloadStream(response: Response, filename: string, contentType: ContentType): Promise<void>;
|
|
18
|
+
export declare function registerDownloadHelperServiceWorker(workerPath?: string | undefined): void;
|
|
19
|
+
//# sourceMappingURL=DownloadHelperServiceWorker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadHelperServiceWorker.d.ts","sourceRoot":"","sources":["../../src/util/DownloadHelperServiceWorker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,sBAAsB,CAAC;AAqG9B,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED,wBAAgB,mCAAmC,CACjD,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,GAC9B,IAAI,CAsBN"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { downloadFileUsingDataURI, guaranteeNonNullable, } from '@finos/legend-shared';
|
|
17
|
+
var DOWNLOAD_EVENTS;
|
|
18
|
+
(function (DOWNLOAD_EVENTS) {
|
|
19
|
+
DOWNLOAD_EVENTS["TAG_REQUEST"] = "download-request";
|
|
20
|
+
DOWNLOAD_EVENTS["TAG_RESPONSE"] = "download-response";
|
|
21
|
+
DOWNLOAD_EVENTS["STREAM_CLOSED"] = "#stream-closed";
|
|
22
|
+
DOWNLOAD_EVENTS["STREAM_ABORTED"] = "#stream-aborted";
|
|
23
|
+
})(DOWNLOAD_EVENTS || (DOWNLOAD_EVENTS = {}));
|
|
24
|
+
function createWritableStreamFromMessageChannel(channel) {
|
|
25
|
+
return new WritableStream({
|
|
26
|
+
write(chunk) {
|
|
27
|
+
channel.port1.postMessage(chunk);
|
|
28
|
+
},
|
|
29
|
+
close() {
|
|
30
|
+
channel.port1.postMessage(DOWNLOAD_EVENTS.STREAM_CLOSED);
|
|
31
|
+
},
|
|
32
|
+
abort() {
|
|
33
|
+
channel.port1.postMessage(DOWNLOAD_EVENTS.STREAM_ABORTED);
|
|
34
|
+
closeMessagePort(channel.port1);
|
|
35
|
+
closeMessagePort(channel.port2);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function closeMessagePort(port) {
|
|
40
|
+
port.onmessage = null;
|
|
41
|
+
port.close();
|
|
42
|
+
}
|
|
43
|
+
async function getServiceWorker() {
|
|
44
|
+
if (!('serviceWorker' in navigator)) {
|
|
45
|
+
return Promise.reject(new Error('Service worker is not available. Service Worker requires HTTPS protocol'));
|
|
46
|
+
}
|
|
47
|
+
return navigator.serviceWorker
|
|
48
|
+
.getRegistration()
|
|
49
|
+
.then((workerRegistration) => {
|
|
50
|
+
if (workerRegistration === undefined) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const pending = workerRegistration.installing ?? workerRegistration.waiting;
|
|
54
|
+
return (workerRegistration.active ??
|
|
55
|
+
new Promise((resolve) => {
|
|
56
|
+
// if not activated, add listener to waiting or installing registration
|
|
57
|
+
const listener = () => {
|
|
58
|
+
if (pending?.state === 'activated') {
|
|
59
|
+
pending.removeEventListener('statechange', listener);
|
|
60
|
+
resolve(workerRegistration.active ?? undefined);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
pending?.addEventListener('statechange', listener);
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function createDownloadRequest(filename) {
|
|
68
|
+
const PREFIX = 6;
|
|
69
|
+
const prefix = String(Math.random()).slice(-PREFIX);
|
|
70
|
+
const url = new URL(`${prefix}/${filename}`, window.location.href).toString();
|
|
71
|
+
return { tag: DOWNLOAD_EVENTS.TAG_REQUEST, filename, url };
|
|
72
|
+
}
|
|
73
|
+
function handleServiceWorkerDownloadResponse(event) {
|
|
74
|
+
const data = event.data;
|
|
75
|
+
if (data?.tag === DOWNLOAD_EVENTS.TAG_RESPONSE && data.downloadUrl.length) {
|
|
76
|
+
openInIframe(data.downloadUrl);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function openInIframe(src) {
|
|
80
|
+
const iframe = document.createElement('iframe');
|
|
81
|
+
iframe.hidden = true;
|
|
82
|
+
iframe.src = src;
|
|
83
|
+
document.body.appendChild(iframe);
|
|
84
|
+
return iframe;
|
|
85
|
+
}
|
|
86
|
+
export async function downloadStream(response, filename, contentType) {
|
|
87
|
+
const responseBody = guaranteeNonNullable(response.body);
|
|
88
|
+
// creates communication channel with service worker with response handler
|
|
89
|
+
const channel = new MessageChannel();
|
|
90
|
+
channel.port1.onmessage = handleServiceWorkerDownloadResponse;
|
|
91
|
+
// grabs service worker and handles it download along with response channel port
|
|
92
|
+
const serviceWorker = await getServiceWorker();
|
|
93
|
+
if (!serviceWorker) {
|
|
94
|
+
// TODO: remove once service worker workflow is tested
|
|
95
|
+
const text = await response.text();
|
|
96
|
+
// eslint-disable-next-line no-console
|
|
97
|
+
console.debug('service worker not found. Using in memory file download');
|
|
98
|
+
downloadFileUsingDataURI(filename, text, contentType);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// eslint-disable-next-line no-console
|
|
102
|
+
console.debug('Service worker found. Continuing download');
|
|
103
|
+
const downloadRequest = createDownloadRequest(filename);
|
|
104
|
+
serviceWorker.postMessage(downloadRequest, [channel.port2]);
|
|
105
|
+
// creates new data stream over communication channel and pipes given stream in it
|
|
106
|
+
responseBody
|
|
107
|
+
.pipeTo(createWritableStreamFromMessageChannel(channel))
|
|
108
|
+
.then(() => {
|
|
109
|
+
// TODO: trace success
|
|
110
|
+
})
|
|
111
|
+
.catch(() => {
|
|
112
|
+
// TODO: fail
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export function registerDownloadHelperServiceWorker(workerPath) {
|
|
116
|
+
if ('serviceWorker' in navigator) {
|
|
117
|
+
const path = workerPath ?? '/ServiceWorker.js';
|
|
118
|
+
navigator.serviceWorker
|
|
119
|
+
.register(path)
|
|
120
|
+
.then((reg) => {
|
|
121
|
+
// TODO: add trace
|
|
122
|
+
// eslint-disable-next-line no-console
|
|
123
|
+
console.debug(`register service worker success with path: ${path}`, reg);
|
|
124
|
+
})
|
|
125
|
+
.catch((error) => {
|
|
126
|
+
// TODO: add trace
|
|
127
|
+
// eslint-disable-next-line no-console
|
|
128
|
+
console.debug(`register service worker error with path: ${path}`, error);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=DownloadHelperServiceWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadHelperServiceWorker.js","sourceRoot":"","sources":["../../src/util/DownloadHelperServiceWorker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAE9B,IAAK,eAKJ;AALD,WAAK,eAAe;IAClB,mDAAgC,CAAA;IAChC,qDAAkC,CAAA;IAClC,mDAAgC,CAAA;IAChC,qDAAkC,CAAA;AACpC,CAAC,EALI,eAAe,KAAf,eAAe,QAKnB;AAED,SAAS,sCAAsC,CAC7C,OAAuB;IAEvB,OAAO,IAAI,cAAc,CAAC;QACxB,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;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,kBAAkB;YAClB,sCAAsC;YACtC,OAAO,CAAC,KAAK,CACX,4CAA4C,IAAI,EAAE,EAClD,KAAK,CACN,CAAC;QACJ,CAAC,CAAC,CAAC;KACN;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finos/legend-application",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.68",
|
|
4
4
|
"description": "Legend application core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"legend",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"test:watch": "jest --watch"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@finos/legend-art": "7.1.
|
|
48
|
+
"@finos/legend-art": "7.1.20",
|
|
49
49
|
"@finos/legend-shared": "10.0.32",
|
|
50
50
|
"@types/react": "18.2.31",
|
|
51
51
|
"@types/react-dom": "18.2.14",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"xterm-addon-webgl": "0.16.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@finos/legend-dev-utils": "2.1.
|
|
71
|
+
"@finos/legend-dev-utils": "2.1.3",
|
|
72
72
|
"@jest/globals": "29.7.0",
|
|
73
73
|
"cross-env": "7.0.3",
|
|
74
74
|
"eslint": "8.52.0",
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
} from '../stores/DocumentationService.js';
|
|
42
42
|
import type { LegendApplicationPlugin } from '../stores/LegendApplicationPlugin.js';
|
|
43
43
|
import { ApplicationStore } from '../stores/ApplicationStore.js';
|
|
44
|
+
import { registerDownloadHelperServiceWorker } from '../util/DownloadHelperServiceWorker.js';
|
|
44
45
|
|
|
45
46
|
export abstract class LegendApplicationLogger {
|
|
46
47
|
abstract debug(event: LogEvent, ...data: unknown[]): void;
|
|
@@ -109,6 +110,9 @@ export abstract class LegendApplication {
|
|
|
109
110
|
| undefined;
|
|
110
111
|
protected _isConfigured = false;
|
|
111
112
|
|
|
113
|
+
protected downloadHelperServiceWorkerPath: string | undefined;
|
|
114
|
+
protected downloadHelper = false;
|
|
115
|
+
|
|
112
116
|
protected constructor(
|
|
113
117
|
pluginManager: LegendApplicationPluginManager<LegendApplicationPlugin>,
|
|
114
118
|
) {
|
|
@@ -157,6 +161,12 @@ export abstract class LegendApplication {
|
|
|
157
161
|
return this;
|
|
158
162
|
}
|
|
159
163
|
|
|
164
|
+
withDownloadHelper(path?: string | undefined): LegendApplication {
|
|
165
|
+
this.downloadHelper = true;
|
|
166
|
+
this.downloadHelperServiceWorkerPath = path;
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
|
|
160
170
|
async fetchApplicationConfiguration(
|
|
161
171
|
baseUrl: string,
|
|
162
172
|
): Promise<[LegendApplicationConfig, ExtensionsConfigurationData]> {
|
|
@@ -326,6 +336,11 @@ export abstract class LegendApplication {
|
|
|
326
336
|
LogEvent.create(APPLICATION_EVENT.APPLICATION_LOAD__SUCCESS),
|
|
327
337
|
'Legend application loaded',
|
|
328
338
|
);
|
|
339
|
+
if (this.downloadHelper) {
|
|
340
|
+
registerDownloadHelperServiceWorker(
|
|
341
|
+
this.downloadHelperServiceWorkerPath,
|
|
342
|
+
);
|
|
343
|
+
}
|
|
329
344
|
} catch (error) {
|
|
330
345
|
assertErrorThrown(error);
|
|
331
346
|
this.logger.error(
|
package/src/index.ts
CHANGED
|
@@ -43,6 +43,7 @@ export {
|
|
|
43
43
|
type NavigationLocation,
|
|
44
44
|
type NavigationZone,
|
|
45
45
|
} from './stores/navigation/NavigationService.js';
|
|
46
|
+
export { downloadStream } from './util/DownloadHelperServiceWorker.js';
|
|
46
47
|
export * from './stores/storage/ApplicationStorage.js';
|
|
47
48
|
export * from './stores/storage/StorageService.js';
|
|
48
49
|
export * from './stores/SettingService.js';
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
type ContentType,
|
|
19
|
+
downloadFileUsingDataURI,
|
|
20
|
+
guaranteeNonNullable,
|
|
21
|
+
} from '@finos/legend-shared';
|
|
22
|
+
|
|
23
|
+
enum DOWNLOAD_EVENTS {
|
|
24
|
+
TAG_REQUEST = 'download-request',
|
|
25
|
+
TAG_RESPONSE = 'download-response',
|
|
26
|
+
STREAM_CLOSED = '#stream-closed',
|
|
27
|
+
STREAM_ABORTED = '#stream-aborted',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function createWritableStreamFromMessageChannel(
|
|
31
|
+
channel: MessageChannel,
|
|
32
|
+
): WritableStream {
|
|
33
|
+
return new WritableStream({
|
|
34
|
+
write(chunk) {
|
|
35
|
+
channel.port1.postMessage(chunk);
|
|
36
|
+
},
|
|
37
|
+
close() {
|
|
38
|
+
channel.port1.postMessage(DOWNLOAD_EVENTS.STREAM_CLOSED);
|
|
39
|
+
},
|
|
40
|
+
abort() {
|
|
41
|
+
channel.port1.postMessage(DOWNLOAD_EVENTS.STREAM_ABORTED);
|
|
42
|
+
closeMessagePort(channel.port1);
|
|
43
|
+
closeMessagePort(channel.port2);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function closeMessagePort(port: MessagePort): void {
|
|
49
|
+
port.onmessage = null;
|
|
50
|
+
port.close();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface LegendApplicationDownloadRequest {
|
|
54
|
+
tag: string;
|
|
55
|
+
filename: string;
|
|
56
|
+
url: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface LegendApplicationTagResponse {
|
|
60
|
+
tag: string;
|
|
61
|
+
downloadUrl: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function getServiceWorker(): Promise<ServiceWorker | undefined> {
|
|
65
|
+
if (!('serviceWorker' in navigator)) {
|
|
66
|
+
return Promise.reject(
|
|
67
|
+
new Error(
|
|
68
|
+
'Service worker is not available. Service Worker requires HTTPS protocol',
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return navigator.serviceWorker
|
|
73
|
+
.getRegistration()
|
|
74
|
+
.then((workerRegistration) => {
|
|
75
|
+
if (workerRegistration === undefined) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const pending =
|
|
79
|
+
workerRegistration.installing ?? workerRegistration.waiting;
|
|
80
|
+
return (
|
|
81
|
+
workerRegistration.active ??
|
|
82
|
+
new Promise((resolve) => {
|
|
83
|
+
// if not activated, add listener to waiting or installing registration
|
|
84
|
+
const listener = (): void => {
|
|
85
|
+
if (pending?.state === 'activated') {
|
|
86
|
+
pending.removeEventListener('statechange', listener);
|
|
87
|
+
resolve(workerRegistration.active ?? undefined);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
pending?.addEventListener('statechange', listener);
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function createDownloadRequest(
|
|
97
|
+
filename: string,
|
|
98
|
+
): LegendApplicationDownloadRequest {
|
|
99
|
+
const PREFIX = 6;
|
|
100
|
+
const prefix = String(Math.random()).slice(-PREFIX);
|
|
101
|
+
const url = new URL(`${prefix}/${filename}`, window.location.href).toString();
|
|
102
|
+
return { tag: DOWNLOAD_EVENTS.TAG_REQUEST, filename, url };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function handleServiceWorkerDownloadResponse(
|
|
106
|
+
event: MessageEvent<LegendApplicationTagResponse | undefined>,
|
|
107
|
+
): void {
|
|
108
|
+
const data = event.data;
|
|
109
|
+
if (data?.tag === DOWNLOAD_EVENTS.TAG_RESPONSE && data.downloadUrl.length) {
|
|
110
|
+
openInIframe(data.downloadUrl);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function openInIframe(src: string): HTMLIFrameElement {
|
|
115
|
+
const iframe = document.createElement('iframe');
|
|
116
|
+
iframe.hidden = true;
|
|
117
|
+
iframe.src = src;
|
|
118
|
+
document.body.appendChild(iframe);
|
|
119
|
+
return iframe;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export async function downloadStream(
|
|
123
|
+
response: Response,
|
|
124
|
+
filename: string,
|
|
125
|
+
contentType: ContentType,
|
|
126
|
+
): Promise<void> {
|
|
127
|
+
const responseBody = guaranteeNonNullable(response.body);
|
|
128
|
+
// creates communication channel with service worker with response handler
|
|
129
|
+
const channel = new MessageChannel();
|
|
130
|
+
channel.port1.onmessage = handleServiceWorkerDownloadResponse;
|
|
131
|
+
|
|
132
|
+
// grabs service worker and handles it download along with response channel port
|
|
133
|
+
const serviceWorker = await getServiceWorker();
|
|
134
|
+
if (!serviceWorker) {
|
|
135
|
+
// TODO: remove once service worker workflow is tested
|
|
136
|
+
const text = await response.text();
|
|
137
|
+
// eslint-disable-next-line no-console
|
|
138
|
+
console.debug('service worker not found. Using in memory file download');
|
|
139
|
+
downloadFileUsingDataURI(filename, text, contentType);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// eslint-disable-next-line no-console
|
|
143
|
+
console.debug('Service worker found. Continuing download');
|
|
144
|
+
const downloadRequest = createDownloadRequest(filename);
|
|
145
|
+
serviceWorker.postMessage(downloadRequest, [channel.port2]);
|
|
146
|
+
// creates new data stream over communication channel and pipes given stream in it
|
|
147
|
+
responseBody
|
|
148
|
+
.pipeTo(createWritableStreamFromMessageChannel(channel))
|
|
149
|
+
.then(() => {
|
|
150
|
+
// TODO: trace success
|
|
151
|
+
})
|
|
152
|
+
.catch(() => {
|
|
153
|
+
// TODO: fail
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function registerDownloadHelperServiceWorker(
|
|
158
|
+
workerPath?: string | undefined,
|
|
159
|
+
): void {
|
|
160
|
+
if ('serviceWorker' in navigator) {
|
|
161
|
+
const path = workerPath ?? '/ServiceWorker.js';
|
|
162
|
+
navigator.serviceWorker
|
|
163
|
+
.register(path)
|
|
164
|
+
.then((reg) => {
|
|
165
|
+
// TODO: add trace
|
|
166
|
+
// eslint-disable-next-line no-console
|
|
167
|
+
console.debug(
|
|
168
|
+
`register service worker success with path: ${path}`,
|
|
169
|
+
reg,
|
|
170
|
+
);
|
|
171
|
+
})
|
|
172
|
+
.catch((error) => {
|
|
173
|
+
// TODO: add trace
|
|
174
|
+
// eslint-disable-next-line no-console
|
|
175
|
+
console.debug(
|
|
176
|
+
`register service worker error with path: ${path}`,
|
|
177
|
+
error,
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"./src/stores/storage/StorageService.ts",
|
|
76
76
|
"./src/stores/terminal/Terminal.ts",
|
|
77
77
|
"./src/stores/terminal/XTerm.ts",
|
|
78
|
+
"./src/util/DownloadHelperServiceWorker.ts",
|
|
78
79
|
"./src/components/ActionAlert.tsx",
|
|
79
80
|
"./src/components/ApplicationComponentFrameworkProvider.tsx",
|
|
80
81
|
"./src/components/ApplicationFrameworkProvider.tsx",
|