@openfin/core-web 0.39.18 → 0.39.20
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +27 -23
- package/docs/platform-developer-guide.md +13 -5
- package/out/api-client.d.ts +10 -3
- package/out/api-client.js +1 -1
- package/out/docs/@openfin/core-web/README.md +2 -0
- package/out/docs/@openfin/core-web/type-aliases/ViewComponentConfig.md +9 -0
- package/out/docs/@openfin/core-web/type-aliases/WebLayoutComponent.md +1 -1
- package/out/docs/@openfin/core-web/type-aliases/WebLayoutManager.md +9 -0
- package/out/iframe-broker.js +1 -1
- package/out/main-16c13302.js +3 -0
- package/out/main-dd65fda5.js +1 -0
- package/out/shared-worker.js +1 -1
- package/package.json +4 -5
- package/out/main-c2033d08.js +0 -1
- package/out/main-f2314505.js +0 -1
package/README.md
CHANGED
@@ -1,45 +1,49 @@
|
|
1
1
|
# @openfin/core-web
|
2
2
|
|
3
|
-
`@openfin/core-web` enables
|
3
|
+
`@openfin/core-web` enables interoperability and layouts within a web browser. It is intended to be used by both content and platform developers to create integrated experiences which leverage OpenFin's existing interoperability APIs.
|
4
4
|
|
5
5
|
This package relies on the type definitions found in [@openfin/core](https://www.npmjs.com/package/@openfin/core) which is a required peer dependency.
|
6
6
|
|
7
|
+
## Built on OpenFin Web-Starter
|
8
|
+
|
9
|
+
To see more examples of `@openfin/core-web` see the [Built on OpenFin Web-Starter Repository](https://github.com/built-on-openfin/web-starter/).
|
10
|
+
|
7
11
|
## Developer Guides
|
8
12
|
|
9
13
|
(Please note, these links work in your IDE and not on npm.org, we will update this soon.)
|
10
14
|
|
11
|
-
-
|
12
|
-
-
|
15
|
+
- [Content Developer Guide](docs/web-application-developer-guide.md) - For developers who need access to the `fin` api to build web applications.
|
16
|
+
- [Platform Developer Guide](docs/platform-developer-guide.md) - For developers building platform-like web experiences who wish to enable and host a Web Interop setup.
|
13
17
|
|
14
18
|
## Supported APIs
|
15
19
|
|
16
20
|
`@openfin/core-web` currently supports the following APIs:
|
17
21
|
|
18
|
-
-
|
19
|
-
-
|
20
|
-
-
|
21
|
-
-
|
22
|
-
|
23
|
-
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
- `fin.me.identity` - The identity of the `fin` instance provided by the Web Broker.
|
23
|
+
- `fin.InterApplicationBus.Channel.connect` - Currently, the only supported channel strategy is `classic`.
|
24
|
+
- `fin.InterApplicationBus.Channel.create`
|
25
|
+
- `InteropBroker`
|
26
|
+
- `fin.Interop.init`
|
27
|
+
- `InteropClient`
|
28
|
+
- `fin.Interop.connectSync`
|
29
|
+
- `fin.me.interop`
|
30
|
+
- `InteropClient.getFDC3()` - (FDC3 support is currently limited to context sharing on User Channels)
|
31
|
+
- `Layout`
|
32
|
+
- `fin.Platform.Layout.init`
|
33
|
+
- `fin.Platform.Layout.create`
|
34
|
+
- `fin.Platform.Layout.destroy`
|
35
|
+
- `fin.Platform.Layout.getCurrentLayoutManagerSync`
|
32
36
|
|
33
37
|
## API Reference
|
34
38
|
|
35
39
|
(Please note, these links work in your IDE and not on npmjs.com, we will update this soon.)
|
36
40
|
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
+
- [index](out/docs/README.md)
|
42
|
+
- [@openfin/core-web](out/docs/@openfin/core-web/README.md)
|
43
|
+
- [@openfin/core-web/iframe-broker](out/docs/@openfin/core-web/iframe-broker/README.md)
|
44
|
+
- [@openfin/core-web/shared-worker](out/docs/@openfin/core-web/shared-worker/README.md)
|
41
45
|
|
42
46
|
## See Also
|
43
47
|
|
44
|
-
-
|
45
|
-
-
|
48
|
+
- [OpenFin Container Developer guide](https://developers.openfin.co/of-docs/docs/container-overview)
|
49
|
+
- [Fin API reference](https://developer.openfin.co/docs/javascript/stable)
|
@@ -115,6 +115,14 @@ const layoutSnapshot = {
|
|
115
115
|
|
116
116
|
The JSON structure of the underlying layout options is interchangeable, though not identical, between Desktop and Web. Web Layout Snapshots have an optional `web` property within the view `componentState` options which stores web specific properties. This `web` property is ignored on desktop.
|
117
117
|
|
118
|
+
### Layout Settings
|
119
|
+
|
120
|
+
Layouts in the web support the following [`LayoutOptions.settings`](https://cdn.openfin.co/docs/javascript/stable/interfaces/OpenFin.LayoutOptions.html#settings):
|
121
|
+
|
122
|
+
- `reorderEnabled` (Default value **true**): If true, users can re-arrange the layout by dragging items by their tabs to the desired location. Note, unlike in an OpenFin environment the dragging of items is limited to the current window.
|
123
|
+
- `hasHeaders` (Default value **true**): Turns tab headers on or off. If false, the layout will be displayed with splitters only.
|
124
|
+
- `preventSplitterResize` (Default value **false**): When true the splitters will not be draggable and the layout will not resize.
|
125
|
+
|
118
126
|
### Example: Retrieve a layoutSnapshot from both desktop and web environments
|
119
127
|
|
120
128
|
From within your OpenFin v34+ Desktop environment, retrieve the current layoutSnapshot:
|
@@ -219,11 +227,11 @@ Note that cross-tab support is experimental, browser-dependent and respects each
|
|
219
227
|
|
220
228
|
(Please note, these links work in your IDE and not on npmjs.com, we will update this soon.)
|
221
229
|
|
222
|
-
-
|
223
|
-
-
|
224
|
-
-
|
230
|
+
- [@openfin/core-web](../out/docs/@openfin/core-web/README.md)
|
231
|
+
- [@openfin/core-web/iframe-broker](../out/docs/@openfin/core-web/iframe-broker/README.md)
|
232
|
+
- [@openfin/core-web/shared-worker](../out/docs/@openfin/core-web/shared-worker/README.md)
|
225
233
|
|
226
234
|
## See Also
|
227
235
|
|
228
|
-
-
|
229
|
-
-
|
236
|
+
- [OpenFin Container Developer guide](https://developers.openfin.co/of-docs/docs/container-overview)
|
237
|
+
- [Fin API reference](https://developer.openfin.co/docs/javascript/stable)
|
package/out/api-client.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import OpenFin from '@openfin/core';
|
2
2
|
|
3
3
|
export declare type BaseConfig = {
|
4
4
|
/**
|
@@ -49,6 +49,8 @@ export declare const connect: (connectConfig: ConnectConfig) => Promise<OpenFin.
|
|
49
49
|
|
50
50
|
export declare type ConnectConfig = StandAloneConnectConfig | InheritModeConnectConfig;
|
51
51
|
|
52
|
+
declare type GL2Types = OpenFin.LayoutEntityTypes | 'component' | 'root' | 'ground';
|
53
|
+
|
52
54
|
export declare type InheritModeConnectConfig = BaseConfig & {
|
53
55
|
/**
|
54
56
|
* @defaultValue 'disabled'
|
@@ -91,6 +93,8 @@ export declare type StandAloneConnectConfig = BaseConfig & {
|
|
91
93
|
options: BaseConnectionOptions;
|
92
94
|
};
|
93
95
|
|
96
|
+
export declare type ViewComponentConfig = WebLayoutComponent['componentState'];
|
97
|
+
|
94
98
|
export declare type WebCreateLayoutOptions = Omit<OpenFin.CreateLayoutOptions, 'layout'> & {
|
95
99
|
layout: WebLayoutOptions;
|
96
100
|
};
|
@@ -100,7 +104,7 @@ declare type WebLayoutColumn = OpenFin.LayoutColumn & WebLayoutItemConfig;
|
|
100
104
|
/**
|
101
105
|
* Web-only component supplied to IframeViewComponent as it's config
|
102
106
|
*/
|
103
|
-
export declare type WebLayoutComponent = OpenFin.LayoutComponent & {
|
107
|
+
export declare type WebLayoutComponent = Omit<OpenFin.LayoutComponent, 'componentState'> & {
|
104
108
|
componentState?: OpenFin.LayoutComponent['componentState'] & {
|
105
109
|
web?: WebState;
|
106
110
|
};
|
@@ -112,10 +116,13 @@ export declare type WebLayoutInitOptions = Omit<OpenFin.InitLayoutOptions, 'layo
|
|
112
116
|
layoutManagerOverride?: OpenFin.LayoutManagerOverride<WebLayoutSnapshot>;
|
113
117
|
};
|
114
118
|
|
115
|
-
declare type WebLayoutItemConfig = Omit<OpenFin.LayoutItemConfig, 'content'> & {
|
119
|
+
declare type WebLayoutItemConfig = Omit<OpenFin.LayoutItemConfig, 'content' | 'type'> & {
|
116
120
|
content?: WebLayoutContent;
|
121
|
+
type: GL2Types;
|
117
122
|
};
|
118
123
|
|
124
|
+
export declare type WebLayoutManager = OpenFin.LayoutManager<WebLayoutSnapshot>;
|
125
|
+
|
119
126
|
export declare type WebLayoutOptions = Omit<OpenFin.LayoutOptions, 'content'> & {
|
120
127
|
content?: WebLayoutContent;
|
121
128
|
};
|
package/out/api-client.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var e=require("./main-
|
1
|
+
"use strict";var e=require("./main-dd65fda5.js");require("buffer/"),require("uuid"),require("events"),require("lodash/cloneDeep"),require("lodash/isEqual"),exports.connect=e.connect;
|
@@ -37,9 +37,11 @@ const fin = await connect({
|
|
37
37
|
- [ConnectConfig](type-aliases/ConnectConfig.md)
|
38
38
|
- [InheritModeConnectConfig](type-aliases/InheritModeConnectConfig.md)
|
39
39
|
- [StandAloneConnectConfig](type-aliases/StandAloneConnectConfig.md)
|
40
|
+
- [ViewComponentConfig](type-aliases/ViewComponentConfig.md)
|
40
41
|
- [WebCreateLayoutOptions](type-aliases/WebCreateLayoutOptions.md)
|
41
42
|
- [WebLayoutComponent](type-aliases/WebLayoutComponent.md)
|
42
43
|
- [WebLayoutInitOptions](type-aliases/WebLayoutInitOptions.md)
|
44
|
+
- [WebLayoutManager](type-aliases/WebLayoutManager.md)
|
43
45
|
- [WebLayoutOptions](type-aliases/WebLayoutOptions.md)
|
44
46
|
- [WebLayoutPlatformOptions](type-aliases/WebLayoutPlatformOptions.md)
|
45
47
|
- [WebLayoutSnapshot](type-aliases/WebLayoutSnapshot.md)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
**@openfin/core-web** • [API](../../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@openfin/core-web](../../../README.md) / [@openfin/core-web](../README.md) / ViewComponentConfig
|
6
|
+
|
7
|
+
# Type alias: ViewComponentConfig
|
8
|
+
|
9
|
+
> **ViewComponentConfig**: [`WebLayoutComponent`](WebLayoutComponent.md)\[`"componentState"`\]
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Type alias: WebLayoutComponent
|
8
8
|
|
9
|
-
> **WebLayoutComponent**: `OpenFin.LayoutComponent` & `object`
|
9
|
+
> **WebLayoutComponent**: `Omit`\<`OpenFin.LayoutComponent`, `"componentState"`\> & `object`
|
10
10
|
|
11
11
|
Web-only component supplied to IframeViewComponent as it's config
|
12
12
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
**@openfin/core-web** • [API](../../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@openfin/core-web](../../../README.md) / [@openfin/core-web](../README.md) / WebLayoutManager
|
6
|
+
|
7
|
+
# Type alias: WebLayoutManager
|
8
|
+
|
9
|
+
> **WebLayoutManager**: `OpenFin.LayoutManager`\<[`WebLayoutSnapshot`](WebLayoutSnapshot.md)\>
|
package/out/iframe-broker.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const e="web-broker-ports-ready",t="worker-initialize-connection",
|
1
|
+
"use strict";const e="web-broker-ports-ready",t="worker-initialize-connection",i="create-fallback-connection",r="request-fallback-connection",n=e=>`ack-${e}`,o=(...e)=>({log:(...t)=>console.debug(`[${(new Date).toISOString()}]`,...(e=>e.map((e=>`[${e}]`)))(e),...t),getLogger:(...t)=>o(...e,...t)}),s=e=>window.top===e,a=(e,t)=>{try{return e.origin===t.origin}catch(e){return!1}},c="openfin/web-shared-worker";class d{static get lockApi(){return navigator.locks}constructor(e){this.name=e,this.releaseCallback=null,d.pending.add(this),this.lockAcquiredPromise=new Promise(((e,t)=>{this.lockReleasedPromise=d.lockApi.request(this.name,(()=>(d.pending.delete(this),e(),new Promise((e=>{d.held.add(this),this.releaseCallback=e}))))).catch((e=>{throw t(e),e}))}))}async acquired(){await this.lockAcquiredPromise}async release(){if(!this.releaseCallback)throw new Error(`Lock ${this.name} not acquired.`);this.releaseCallback(),this.releaseCallback=null,await this.lockReleasedPromise,d.held.delete(this)}async onReleased(e){if(!this.lockReleasedPromise)throw new Error(`Lock ${this.name} not queued.`);return this.lockReleasedPromise.then(e)}autoRelease(){this.acquired().then((()=>this.release()))}static async releaseAll(){const e=Promise.all([...this.pending].map((async e=>{await e.acquired(),await e.release()})));await Promise.all([...this.held].map((async e=>{await e.release()}))),await e}}d.pending=new Set,d.held=new Set;class l{constructor(e=100,t=2){this.pingIntervalMs=e,this.allowedMissedPings=t,this.lockSelf=async e=>{const t=new d((e=>`__OPENFIN__${e.uuid}_${e.name}`)(e));return await t.acquired(),t}}async lockProxiedConnection(e,t){let i=0;t.addEventListener("message",(e=>{"pong"===e.data.topic&&i--}));const r=await this.lockSelf(e);let n=setInterval((()=>{i>=this.allowedMissedPings?(r.release(),clearInterval(n)):(i++,t.postMessage({topic:"ping"}))}),this.pingIntervalMs);t.start()}registerProxiedConnection(e){e.addEventListener("message",(t=>{"ping"===t.data.topic&&e.postMessage({topic:"pong"})})),e.start()}}class h{constructor(e,t,o){this.workerUrl=e,this.iframeWindow=t,this.forceWorker=o,this.identityDisconnectionController=new l,this.isSharedWorkerSupported=()=>!this.forceWorker&&!!window.SharedWorker,this.state="ready",this.establishWorkerConnectionViaWindow=async(e,t)=>{if(a(this.iframeWindow,e)){const o=new MessageChannel,s=new MessageChannel;return this.identityDisconnectionController.registerProxiedConnection(s.port1),new Promise(((a,c)=>{o.port1.addEventListener("message",(e=>{e.data.topic===n(i)&&(e.data.success?a(o.port1):c(e.data.reason))})),o.port1.start();const d={topic:r,payload:{identity:t}};e.postMessage(d,location.origin,[o.port2,s.port2])}))}throw new Error("Could not connect via top level browsing context as its origin does not much the web interop broker.")},this.listenForNestedConnections=e=>{"top-window"===this.state&&a(this.iframeWindow,this.iframeWindow.parent)&&this.iframeWindow.parent.addEventListener("message",(async t=>{const{data:n}=t;if(t.origin===location.origin&&n.topic===r){const[r,...o]=t.ports;if(o.length>0&&n.payload?.identity){const[e]=o;await this.identityDisconnectionController.lockProxiedConnection(n.payload.identity,e)}const s={topic:i};e.postMessage(s,[r])}}))},this.initialize=async e=>{if("ready"!==this.state)throw new Error("Worker connection already initialized");return(e=>{const t=i=>!(!(e=>{try{return!e.origin}catch(e){return!0}})(i)&&i.origin===e.origin)||!s(i)&&t(i.parent);return!s(e)&&t(e.parent)})(this.iframeWindow)&&a(this.iframeWindow,this.iframeWindow.top)?this.state="partitioned-frame":s(this.iframeWindow.parent)?this.state="top-window":this.state="frame",this.connect(e)}}async connect(e){if("ready"===this.state)throw new Error("Must call initialize before connect");switch(this.state){case"partitioned-frame":return this.establishWorkerConnectionViaWindow(this.iframeWindow.top,e);case"top-window":{let t;return t=this.isSharedWorkerSupported()?new SharedWorker(this.workerUrl,c).port:new Worker(this.workerUrl),await this.identityDisconnectionController.lockSelf(e),this.listenForNestedConnections(t),t}case"frame":{if(!this.isSharedWorkerSupported())try{return await this.establishWorkerConnectionViaWindow(this.iframeWindow.top,e)}catch(e){throw new Error(`SharedWorker is not supported and an unexpected error occured when trying to connect via fallback mechanism: ${e.message}`,{cause:e})}await this.identityDisconnectionController.lockSelf(e);const{port:t}=new SharedWorker(this.workerUrl,c);return t}default:throw this.state,new Error(`Invalid state: ${this.state}`)}}}const w=o("@openfin/core-web/iframe-broker"),p=()=>{const e=((e,t)=>{const i=new RegExp(`^${t}<(?<meta>.*)>$`).exec(e)?.groups?.meta;if(i)try{return JSON.parse(atob(i))}catch(e){throw new Error(`Failed to decode JSON from ${i}.`)}})(window.name,"of-broker");if(!e)throw new Error("Invalid or missing identity string in iframe context. Ensure that this iframe is being renderered via the @openfin/core-web library.");return e};function g(t){const i={topic:n(e),success:!1,reason:t?.reason??"Connection Rejected"};window.parent.postMessage(i,"*")}exports.init=async i=>{try{const{sharedWorkerUrl:r}=i;await("loading"===document.readyState?new Promise((e=>{const t=()=>{e(),window.removeEventListener("DOMContentLoaded",t)};window.addEventListener("DOMContentLoaded",t)})):Promise.resolve());const o=p(),s=new h(r,window,"same-site"!==i.experimental?.crossTab),a=await s.initialize(o);w.log(`Loading ${r} in ${s.state} mode...`);const c=await(async(i,r,o)=>{const s=new MessageChannel,a=new MessageChannel,c={topic:t,payload:{identity:o}};await new Promise(((e,i)=>{r.addEventListener("message",(r=>{r.data.topic===n(t)&&(r.data.success?e():i(new Error(r.data.reason)))})),r.start?.(),r.postMessage(c,[a.port2])}));const d={topic:n(e),success:!0,payload:{identity:o}};return i.postMessage(d,"*",[s.port2,a.port1]),s.port1})(window.parent,a,o);c.start(),a.start?.(),w.log(`Port transfer complete in ${s.state} mode. Connection established with identity ${JSON.stringify(o)}. SharedWorker support=${s.isSharedWorkerSupported()}`)}catch(e){const t=new Error(`An unexpected error occured during initialization. ${e.message}`);g({reason:t.message}),console.error(t)}},exports.rejectConnections=g;
|