@openfin/node-adapter 33.76.36

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 ADDED
@@ -0,0 +1,4 @@
1
+ Learn more about OpenFin licensing at the links listed below or email us at support@openfin.co with questions.
2
+
3
+ - [Developer agreement](https://openfin.co/developer-agreement/)
4
+
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # OpenFin Node.js adapter
2
+
3
+ Allows the use of the OpenFin API from node.js. Please note the launch and connect methods are specific to a node environment.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js 16 or greater
8
+
9
+ # Usage
10
+
11
+ ## Connect
12
+
13
+ `connect` can be used to establish a connection to an OpenFin runtime from node.
14
+
15
+ A uuid must be provided to identify the connection. Multiple connections will require distinct uuids.
16
+
17
+ A runtime version or manifest url must also be specified.
18
+
19
+ Note - `connect` will instantiate a runtime instance if one does not exist for the given configuration. If the runtime is already running, connect will simply establish a new connection.
20
+
21
+ ### Connecting via Runtime Version
22
+
23
+ ```javascript
24
+ import { connect } from '@openfin/node-adapter';
25
+
26
+ (async () => {
27
+ const fin = await connect({
28
+ uuid: 'my-uuid-123',
29
+ runtime: {
30
+ version: 'stable'
31
+ }
32
+ });
33
+ await fin.Platform.startFromManifest('http://www.your-domain-goes-here.com/manifest.json');
34
+ })();
35
+ ```
36
+
37
+ ### Connecting via Manifest Url
38
+
39
+ ```javascript
40
+ import { connect } from '@openfin/node-adapter';
41
+
42
+ (async () => {
43
+ const fin = await connect({
44
+ uuid: 'connection-id',
45
+ manifestUrl: 'http://www.your-domain-goes-here.com/manifest'
46
+ });
47
+ })();
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Launch
53
+
54
+ Unlike `connect`, `launch` starts an OpenFin application if not running and returns a port number instead of a `fin` object.
55
+
56
+ This can be provided to connect to create a `fin` object for the runtime that has been created on the specific port.
57
+
58
+ `launch` can be called multiple times for a given application, however launches for an application that is already running will result in a [run-requested](https://developer.openfin.co/jsdocs/stable/tutorial-application.addEventListener.html#run-requested) event being triggered instead of a relaunch. If the application is an OpenFin platform, this will result in the layout windows reloading.
59
+
60
+ ### Launching and Connecting via Port
61
+
62
+ ```javascript
63
+ import { launch, connect } from '@openfin/node-adapter';
64
+
65
+ (async () => {
66
+ const port = await launch({
67
+ manifestUrl: 'http://www.your-domain-goes-here.com/manifest'
68
+ });
69
+
70
+ const fin = await connect({
71
+ address: `ws://localhost:${port}`,
72
+ uuid: 'external-app-via-launch'
73
+ });
74
+
75
+ console.log(await fin.System.getRuntimeInfo());
76
+ })();
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Types
82
+
83
+ `@openfin/node-adapter` comes bundled with its own types types.
84
+
85
+ If you wish to explicitly reference OpenFin types, the `OpenFin` namespace export may be used as follows:
86
+
87
+ ### Type Usage Example
88
+
89
+ ```typescript
90
+ import OpenFin, { connect } from '@openfin/node-adapter';
91
+
92
+ (async () => {
93
+ const fin: OpenFin.Fin<'external connection'> = await connect({
94
+ uuid: 'connection-id'
95
+ });
96
+ const platform: OpenFin.Platform = await fin.Platform.startFromManifest(
97
+ 'http://www.your-domain-goes-here.com/manifest'
98
+ );
99
+ })();
100
+ ```
101
+
102
+ ---
103
+
104
+ # Migrating from openfin-adapter to @openfin/node-adapter
105
+
106
+ For users of the `connect` and `launch` functions in `openfin-adapter`, no changes are necessary, other than updating the dependency name.
107
+
108
+ If using the exported types from `openfin-adapter`, an `OpenFin` export has been created that encapsualates them.
109
+
110
+ ### Before
111
+
112
+ ```typescript
113
+ import { launch, connect, Application, Fin } from 'openfin-adapter';
114
+
115
+ (async () => {
116
+ const fin: Fin = await connect({
117
+ uuid: 'external-connection-1',
118
+ runtime: { version: 'stable' }
119
+ });
120
+ const app: Application = await fin.Application.start({...});
121
+ })()
122
+ ```
123
+
124
+ ### After
125
+
126
+ ```typescript
127
+ import OpenFin, { launch, connect } from '@openfin/node-adapter';
128
+ (async () => {
129
+ const fin: OpenFin.Fin<'external connection'> = await connect({
130
+ uuid: 'external-connection-1',
131
+ runtime: { version: 'stable' }
132
+ });
133
+ const app: OpenFin.Application = await fin.Application.start({...});
134
+ })()
135
+
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Further Reading
141
+
142
+ - [Developer guide](https://developers.openfin.co/of-docs/docs/container-overview)
143
+ - [API reference](https://developer.openfin.co/docs/javascript/stable)
144
+
145
+ ## License
146
+
147
+ Copyright 2020-2023 OpenFin
148
+
149
+ The code in this package is distributed under the Apache License, Version 2.0.
150
+
151
+ However, if you run this code, it may call on the OpenFin RVM or OpenFin Runtime, which are covered by OpenFin's Developer, Community, and Enterprise licenses. You can learn more about OpenFin licensing at the links listed below or email us at support@openfin.co with questions.
152
+
153
+ - [Developer agreement](https://openfin.co/developer-agreement/)