@finos/legend-lego 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/download-helper/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqGH,wBAAsB,cAAc,CAClC,YAAY,EAAE,cAAc,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED,wBAAgB,mCAAmC,IAAI,IAAI,CAa1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/download-helper/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqGH,wBAAsB,cAAc,CAClC,YAAY,EAAE,cAAc,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED,wBAAgB,mCAAmC,IAAI,IAAI,CAe1D"}
@@ -106,14 +106,16 @@ export async function downloadStream(responseBody, filename) {
106
106
  export function registerDownloadHelperServiceWorker() {
107
107
  if ('serviceWorker' in navigator) {
108
108
  navigator.serviceWorker
109
- .register(new URL('./DownloadHelper.service-worker.js', import.meta.url))
109
+ .register('ServiceWorker.js')
110
110
  .then((reg) => {
111
111
  // TODO: add trace
112
- // console.debug('register service worker success', reg);
112
+ // eslint-disable-next-line no-console
113
+ console.debug('register service worker success', reg);
113
114
  })
114
115
  .catch((error) => {
115
116
  // TODO: add trace
116
- // console.debug('register service worker error', error);
117
+ // eslint-disable-next-line no-console
118
+ console.debug('register service worker error', error);
117
119
  });
118
120
  }
119
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/download-helper/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,IAAK,eAKJ;AALD,WAAK,eAAe;IAClB,mDAAgC,CAAA;IAChC,qDAAkC,CAAA;IAClC,mDAAgC,CAAA;IAChC,qDAAkC,CAAA;AACpC,CAAC,EALI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AED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,YAA4B,EAC5B,QAAgB;IAEhB,0EAA0E;IAC1E,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,mCAAmC,CAAC;IAE9D,gFAAgF;IAChF,MAAM,aAAa,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAC/C,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO;KACR;IACD,MAAM,eAAe,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxD,aAAa,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAE5D,kFAAkF;IAClF,YAAY;SACT,MAAM,CAAC,sCAAsC,CAAC,OAAO,CAAC,CAAC;SACvD,IAAI,CAAC,GAAG,EAAE;QACT,sBAAsB;IACxB,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,EAAE;QACV,aAAa;IACf,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,mCAAmC;IACjD,IAAI,eAAe,IAAI,SAAS,EAAE;QAChC,SAAS,CAAC,aAAa;aACpB,QAAQ,CAAC,kBAAkB,CAAC;aAC5B,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,kBAAkB;YAClB,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAC;QACxD,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,kBAAkB;YAClB,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;KACN;AACH,CAAC"}
package/lib/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /** @license @finos/legend-lego v1.2.0
1
+ /** @license @finos/legend-lego v1.2.2
2
2
  * Copyright (c) 2020-present, Goldman Sachs
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finos/legend-lego",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Legend shared advanced application components and building blocks",
5
5
  "keywords": [
6
6
  "legend",
@@ -65,10 +65,10 @@
65
65
  "@ag-grid-enterprise/server-side-row-model": "30.2.0",
66
66
  "@ag-grid-enterprise/side-bar": "30.2.0",
67
67
  "@ag-grid-enterprise/status-bar": "30.2.0",
68
- "@finos/legend-application": "15.0.64",
69
- "@finos/legend-art": "7.1.17",
70
- "@finos/legend-graph": "31.7.0",
71
- "@finos/legend-shared": "10.0.31",
68
+ "@finos/legend-application": "15.0.66",
69
+ "@finos/legend-art": "7.1.19",
70
+ "@finos/legend-graph": "31.7.2",
71
+ "@finos/legend-shared": "10.0.32",
72
72
  "@types/css-font-loading-module": "0.0.10",
73
73
  "@types/react": "18.2.31",
74
74
  "@types/react-dom": "18.2.14",
@@ -80,7 +80,7 @@
80
80
  "react-dom": "18.2.0"
81
81
  },
82
82
  "devDependencies": {
83
- "@finos/legend-dev-utils": "2.1.0",
83
+ "@finos/legend-dev-utils": "2.1.2",
84
84
  "@jest/globals": "29.7.0",
85
85
  "cross-env": "7.0.3",
86
86
  "eslint": "8.52.0",
@@ -143,14 +143,16 @@ export async function downloadStream(
143
143
  export function registerDownloadHelperServiceWorker(): void {
144
144
  if ('serviceWorker' in navigator) {
145
145
  navigator.serviceWorker
146
- .register(new URL('./DownloadHelper.service-worker.js', import.meta.url))
146
+ .register('ServiceWorker.js')
147
147
  .then((reg) => {
148
148
  // TODO: add trace
149
- // console.debug('register service worker success', reg);
149
+ // eslint-disable-next-line no-console
150
+ console.debug('register service worker success', reg);
150
151
  })
151
152
  .catch((error) => {
152
153
  // TODO: add trace
153
- // console.debug('register service worker error', error);
154
+ // eslint-disable-next-line no-console
155
+ console.debug('register service worker error', error);
154
156
  });
155
157
  }
156
158
  }
package/tsconfig.json CHANGED
@@ -39,7 +39,6 @@
39
39
  "./src/code-editor/__test-utils__/MockedMonacoEditor.ts",
40
40
  "./src/code-editor/themes/MonacoEditorThemeUtils.ts",
41
41
  "./src/data-grid/index.ts",
42
- "./src/download-helper/DownloadHelper.service-worker.ts",
43
42
  "./src/download-helper/index.ts",
44
43
  "./src/download-helper/__test-utils__/MockedDownloadHelper.ts",
45
44
  "./src/graph-editor/index.ts",
@@ -1,17 +0,0 @@
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
- export declare function handleDownloadMessage(event: ExtendableMessageEvent): void;
17
- //# sourceMappingURL=DownloadHelper.service-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DownloadHelper.service-worker.d.ts","sourceRoot":"","sources":["../../src/download-helper/DownloadHelper.service-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAsCH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAezE"}
@@ -1,96 +0,0 @@
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
- const TAG_REQUEST = 'download-request';
17
- const TAG_RESPONSE = 'download-response';
18
- const STREAM_CLOSED = '#stream-closed';
19
- const STREAM_ABORTED = '#stream-aborted';
20
- // will interact from `createWritableStreamFromMessageChannel`
21
- function createReadableStreamFromMessagePort(port) {
22
- return new ReadableStream({
23
- start(controller) {
24
- port.onmessage = ({ data }) => {
25
- if (data === STREAM_CLOSED) {
26
- return controller.close();
27
- }
28
- if (data === STREAM_ABORTED) {
29
- controller.error('aborted');
30
- return undefined;
31
- }
32
- controller.enqueue(data);
33
- return undefined;
34
- };
35
- },
36
- });
37
- }
38
- const entries = new Map();
39
- export function handleDownloadMessage(event) {
40
- const data = event.data;
41
- if (event.data && event.data.tag === TAG_REQUEST) {
42
- const port = event.ports[0];
43
- if (port === undefined) {
44
- throw new Error('Port 1 expected to handle download request');
45
- }
46
- const entry = [
47
- createReadableStreamFromMessagePort(port),
48
- data,
49
- port,
50
- ];
51
- entries.set(data.url, entry);
52
- port.postMessage({ tag: TAG_RESPONSE, downloadUrl: data.url });
53
- }
54
- }
55
- function handleDownloadFetch(event) {
56
- const url = event.request.url;
57
- const entry = entries.get(url);
58
- if (entry) {
59
- entries.delete(url);
60
- const [stream, data] = entry;
61
- const { filename } = data;
62
- const headers = new Headers({
63
- 'Content-Type': 'application/octet-stream; charset=utf-8',
64
- 'Content-Disposition': `attachment; filename*=UTF-8''${filename}`,
65
- 'Content-Security-Policy': "default-src 'none'",
66
- });
67
- // TODO: add trace
68
- // console.log('responding to ffetch', stream);
69
- event.respondWith(new Response(stream, { headers }));
70
- }
71
- }
72
- function handleInstall(event) {
73
- // TODO: add trace
74
- // console.log('service worker install', event);
75
- event.waitUntil(self.skipWaiting());
76
- }
77
- function handleActivate(event) {
78
- // TODO: add trace
79
- // console.log('service worker activate', event);
80
- event.waitUntil(self.clients.claim());
81
- }
82
- function handleMessage(event) {
83
- // TODO: add trace
84
- // console.log('service worker message', event);
85
- handleDownloadMessage(event);
86
- }
87
- function handleFetch(event) {
88
- // TODO: add trace
89
- // console.log('service worker fetch', event);
90
- handleDownloadFetch(event);
91
- }
92
- self.addEventListener('install', handleInstall);
93
- self.addEventListener('activate', handleActivate);
94
- self.addEventListener('message', handleMessage);
95
- self.addEventListener('fetch', handleFetch);
96
- //# sourceMappingURL=DownloadHelper.service-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DownloadHelper.service-worker.js","sourceRoot":"","sources":["../../src/download-helper/DownloadHelper.service-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,GAAG,kBAAkB,CAAC;AACvC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC,8DAA8D;AAC9D,SAAS,mCAAmC,CAC1C,IAAiB;IAEjB,OAAO,IAAI,cAAc,CAAC;QACxB,KAAK,CAAC,UAAU;YACd,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC5B,IAAI,IAAI,KAAK,aAAa,EAAE;oBAC1B,OAAO,UAAU,CAAC,KAAK,EAAE,CAAC;iBAC3B;gBACD,IAAI,IAAI,KAAK,cAAc,EAAE;oBAC3B,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;oBAC5B,OAAO,SAAS,CAAC;iBAClB;gBACD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACzB,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAQD,MAAM,OAAO,GACX,IAAI,GAAG,EAAE,CAAC;AAEZ,MAAM,UAAU,qBAAqB,CAAC,KAA6B;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAuB,CAAC;IAC3C,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,KAA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C,CAAC;AACtC,CAAC;AAED,SAAS,cAAc,CAAC,KAAsB;IAC5C,kBAAkB;IAClB,iDAAiD;IACjD,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,aAAa,CAAC,KAA6B;IAClD,kBAAkB;IAClB,gDAAgD;IAChD,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,WAAW,CAAC,KAAiB;IACpC,kBAAkB;IAClB,8CAA8C;IAC9C,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAChD,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAClD,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAChD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC"}
@@ -1,120 +0,0 @@
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
- const TAG_REQUEST = 'download-request';
18
- const TAG_RESPONSE = 'download-response';
19
-
20
- const STREAM_CLOSED = '#stream-closed';
21
- const STREAM_ABORTED = '#stream-aborted';
22
-
23
- // will interact from `createWritableStreamFromMessageChannel`
24
- function createReadableStreamFromMessagePort(
25
- port: MessagePort,
26
- ): ReadableStream {
27
- return new ReadableStream({
28
- start(controller) {
29
- port.onmessage = ({ data }) => {
30
- if (data === STREAM_CLOSED) {
31
- return controller.close();
32
- }
33
- if (data === STREAM_ABORTED) {
34
- controller.error('aborted');
35
- return undefined;
36
- }
37
- controller.enqueue(data);
38
- return undefined;
39
- };
40
- },
41
- });
42
- }
43
-
44
- interface DownloadRequest {
45
- tag: string;
46
- filename: string;
47
- url: string;
48
- }
49
-
50
- const entries: Map<string, [ReadableStream, DownloadRequest, MessagePort]> =
51
- new Map();
52
-
53
- export function handleDownloadMessage(event: ExtendableMessageEvent): void {
54
- const data = event.data as DownloadRequest;
55
- if (event.data && event.data.tag === TAG_REQUEST) {
56
- const port = event.ports[0];
57
- if (port === undefined) {
58
- throw new Error('Port 1 expected to handle download request');
59
- }
60
- const entry: [ReadableStream, DownloadRequest, MessagePort] = [
61
- createReadableStreamFromMessagePort(port),
62
- data,
63
- port,
64
- ];
65
- entries.set(data.url, entry);
66
- port.postMessage({ tag: TAG_RESPONSE, downloadUrl: data.url });
67
- }
68
- }
69
-
70
- function handleDownloadFetch(event: FetchEvent): void {
71
- const url = event.request.url;
72
- const entry = entries.get(url);
73
-
74
- if (entry) {
75
- entries.delete(url);
76
- const [stream, data] = entry;
77
- const { filename } = data;
78
- const headers = new Headers({
79
- 'Content-Type': 'application/octet-stream; charset=utf-8',
80
- 'Content-Disposition': `attachment; filename*=UTF-8''${filename}`,
81
- 'Content-Security-Policy': "default-src 'none'",
82
- });
83
- // TODO: add trace
84
- // console.log('responding to ffetch', stream);
85
- event.respondWith(new Response(stream, { headers }));
86
- }
87
- }
88
-
89
- // ------------------ Service Worker Lifecycle ------------------
90
-
91
- declare const self: ServiceWorkerGlobalScope;
92
-
93
- function handleInstall(event: ExtendableEvent): void {
94
- // TODO: add trace
95
- // console.log('service worker install', event);
96
- event.waitUntil(self.skipWaiting());
97
- }
98
-
99
- function handleActivate(event: ExtendableEvent): void {
100
- // TODO: add trace
101
- // console.log('service worker activate', event);
102
- event.waitUntil(self.clients.claim());
103
- }
104
-
105
- function handleMessage(event: ExtendableMessageEvent): void {
106
- // TODO: add trace
107
- // console.log('service worker message', event);
108
- handleDownloadMessage(event);
109
- }
110
-
111
- function handleFetch(event: FetchEvent): void {
112
- // TODO: add trace
113
- // console.log('service worker fetch', event);
114
- handleDownloadFetch(event);
115
- }
116
-
117
- self.addEventListener('install', handleInstall);
118
- self.addEventListener('activate', handleActivate);
119
- self.addEventListener('message', handleMessage);
120
- self.addEventListener('fetch', handleFetch);