@openfin/web-utils 0.0.1-v36.79.19-preview.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.
- package/LICENSE.md +1 -0
- package/README.md +3 -0
- package/out/custom-elements/main.d.ts +1 -0
- package/out/custom-elements/main.js +1 -0
- package/out/custom-elements/of-view.d.ts +20 -0
- package/out/custom-elements/of-view.js +79 -0
- package/out/utils/main.d.ts +1 -0
- package/out/utils/main.js +1 -0
- package/out/utils/options-encoder.d.ts +2 -0
- package/out/utils/options-encoder.js +14 -0
- package/package.json +44 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
FOR INTERNAL USE BY OPENFIN ONLY
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './of-view';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './of-view';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare class _OfViewElement extends HTMLElement {
|
|
2
|
+
#private;
|
|
3
|
+
connectedCallback(): void;
|
|
4
|
+
get brokerUrl(): string | null;
|
|
5
|
+
set brokerUrl(val: string | null);
|
|
6
|
+
get name(): string | null;
|
|
7
|
+
set name(val: string | null);
|
|
8
|
+
get uuid(): string | null;
|
|
9
|
+
set uuid(val: string | null);
|
|
10
|
+
get src(): string | null;
|
|
11
|
+
set src(val: string | null);
|
|
12
|
+
get providerId(): string | null;
|
|
13
|
+
set providerId(val: string | null);
|
|
14
|
+
get contextGroup(): string | null;
|
|
15
|
+
set contextGroup(val: string | null);
|
|
16
|
+
static get observedAttributes(): string[];
|
|
17
|
+
}
|
|
18
|
+
export type OfViewElement = typeof _OfViewElement;
|
|
19
|
+
export declare const registerOfViewElement: () => void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { encodeOptions } from '../utils/options-encoder';
|
|
2
|
+
class _OfViewElement extends HTMLElement {
|
|
3
|
+
connectedCallback() {
|
|
4
|
+
if (!this.name || !this.uuid) {
|
|
5
|
+
throw new Error('<of-view> Name or uuid attribute missing');
|
|
6
|
+
}
|
|
7
|
+
if (!this.src) {
|
|
8
|
+
throw new Error(`<of-view> missing 'src' attribute.`);
|
|
9
|
+
}
|
|
10
|
+
if (!this.#iframe) {
|
|
11
|
+
this.#iframe = document.createElement('iframe');
|
|
12
|
+
this.#iframe.src = this.src;
|
|
13
|
+
this.#iframe.style.height = '100%';
|
|
14
|
+
this.#iframe.style.width = '100%';
|
|
15
|
+
this.#iframe.setAttribute('name', encodeOptions({
|
|
16
|
+
brokerUrl: this.brokerUrl,
|
|
17
|
+
name: this.name,
|
|
18
|
+
uuid: this.uuid,
|
|
19
|
+
providerId: this.providerId,
|
|
20
|
+
contextGroup: this.contextGroup
|
|
21
|
+
}, 'of-frame'));
|
|
22
|
+
this.#iframe.setAttribute('id', this.name);
|
|
23
|
+
this.appendChild(this.#iframe);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
#iframe;
|
|
27
|
+
get brokerUrl() {
|
|
28
|
+
return this.getAttribute('of-broker');
|
|
29
|
+
}
|
|
30
|
+
set brokerUrl(val) {
|
|
31
|
+
if (val) {
|
|
32
|
+
this.setAttribute('of-broker', val);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
get name() {
|
|
36
|
+
return this.getAttribute('of-name');
|
|
37
|
+
}
|
|
38
|
+
set name(val) {
|
|
39
|
+
if (val) {
|
|
40
|
+
this.setAttribute('of-name', val);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
get uuid() {
|
|
44
|
+
return this.getAttribute('of-uuid');
|
|
45
|
+
}
|
|
46
|
+
set uuid(val) {
|
|
47
|
+
if (val) {
|
|
48
|
+
this.setAttribute('of-uuid', val);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
get src() {
|
|
52
|
+
return this.getAttribute('src');
|
|
53
|
+
}
|
|
54
|
+
set src(val) {
|
|
55
|
+
if (val) {
|
|
56
|
+
this.setAttribute('src', val);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
get providerId() {
|
|
60
|
+
return this.getAttribute('of-provider-id');
|
|
61
|
+
}
|
|
62
|
+
set providerId(val) {
|
|
63
|
+
if (val) {
|
|
64
|
+
this.setAttribute('of-provider-id', val);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
get contextGroup() {
|
|
68
|
+
return this.getAttribute('of-context-group');
|
|
69
|
+
}
|
|
70
|
+
set contextGroup(val) {
|
|
71
|
+
if (val) {
|
|
72
|
+
this.setAttribute('of-context-group', val);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
static get observedAttributes() {
|
|
76
|
+
return ['name'];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export const registerOfViewElement = () => customElements.define('of-view', _OfViewElement);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './options-encoder';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './options-encoder';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const encodeOptions = (data, prefix) => {
|
|
2
|
+
return `${prefix}<${btoa(JSON.stringify(data))}>`;
|
|
3
|
+
};
|
|
4
|
+
export const decodeOptions = (data, prefix) => {
|
|
5
|
+
const meta = new RegExp(`^${prefix}\<(?<meta>.*)\>$`).exec(data)?.groups?.meta;
|
|
6
|
+
if (meta) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(atob(meta));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
throw new Error(`Failed to decode JSON from ${meta}.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openfin/web-utils",
|
|
3
|
+
"version": "0.0.1-v36.79.19-preview.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"private": false,
|
|
6
|
+
"files": [
|
|
7
|
+
"./out/*"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
"./custom-elements": {
|
|
11
|
+
"types": "./out/custom-elements/main.d.ts",
|
|
12
|
+
"default": "./out/custom-elements/main.js"
|
|
13
|
+
},
|
|
14
|
+
"./utils": {
|
|
15
|
+
"types": "./out/utils/main.d.ts",
|
|
16
|
+
"default": "./out/utils/main.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"prebuild": "rimraf out",
|
|
21
|
+
"predev": "rimraf out",
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"dev": "tsc --sourcemap --skipLibCheck",
|
|
24
|
+
"watch": "npm run dev -- --watch"
|
|
25
|
+
},
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"uuid": "8.3.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@openfin/core-ci-tools": "0.0.1",
|
|
33
|
+
"@rollup/plugin-commonjs": "25.0.2",
|
|
34
|
+
"@rollup/plugin-typescript": "11.1.1",
|
|
35
|
+
"@types/uuid": "^8.3.4",
|
|
36
|
+
"jsdom": "^22.1.0",
|
|
37
|
+
"rimraf": "5.0.1",
|
|
38
|
+
"rollup": "3.24.1",
|
|
39
|
+
"ts-loader": "9.5.0",
|
|
40
|
+
"typescript": "4.9.5",
|
|
41
|
+
"vitest": "0.32.2",
|
|
42
|
+
"webpack": "5.89.0"
|
|
43
|
+
}
|
|
44
|
+
}
|