@signageos/front-applet 5.0.0-beta.7 → 5.0.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/CHANGELOG.md +78 -1
- package/dist/bundle.js +2 -2
- package/dist/bundle.js.map +1 -1
- package/docs/js-api/js-api-introduction.md +16 -12
- package/docs/js-api/js-applet-basics.md +162 -1
- package/docs/js-api/js-browser.md +35 -7
- package/docs/js-api/js-command.md +61 -21
- package/docs/js-api/js-display.md +48 -0
- package/docs/js-api/js-file-system.md +106 -7
- package/docs/js-api/js-hardware-serial.md +2 -2
- package/docs/js-api/js-input.md +27 -2
- package/docs/js-api/js-offline-cache-media-files.md +19 -7
- package/docs/js-api/js-video-stream.md +66 -24
- package/docs/management-api/10-js-management-application.md +18 -1
- package/docs/management-api/11-js-management-network.md +122 -3
- package/docs/management-api/13-js-management-wifi.md +4 -0
- package/docs/management-api/2-js-management-firmware.md +21 -0
- package/docs/management-api/5-js-management-screen.md +8 -4
- package/docs/management-api/6-js-management-time.md +17 -1
- package/es6/FrontApplet/Browser/Browser.d.ts +16 -6
- package/es6/FrontApplet/Browser/Browser.js +39 -12
- package/es6/FrontApplet/Browser/Browser.js.map +1 -1
- package/es6/FrontApplet/Browser/IOpenLinkOptions.d.ts +8 -0
- package/es6/FrontApplet/Browser/IOpenLinkOptions.js +4 -0
- package/es6/FrontApplet/Browser/IOpenLinkOptions.js.map +1 -1
- package/es6/FrontApplet/Browser/events.d.ts +15 -0
- package/es6/FrontApplet/Browser/events.js +14 -0
- package/es6/FrontApplet/Browser/events.js.map +1 -0
- package/es6/FrontApplet/Browser/messages.d.ts +5 -0
- package/es6/FrontApplet/Browser/messages.js +3 -0
- package/es6/FrontApplet/Browser/messages.js.map +1 -0
- package/es6/FrontApplet/Debug/Debug.d.ts +22 -0
- package/es6/FrontApplet/Debug/Debug.js +35 -0
- package/es6/FrontApplet/Debug/Debug.js.map +1 -0
- package/es6/FrontApplet/Exchange/Exchange.d.ts +7 -0
- package/es6/FrontApplet/Exchange/Exchange.js +28 -0
- package/es6/FrontApplet/Exchange/Exchange.js.map +1 -0
- package/es6/FrontApplet/FileSystem/FileSystem.d.ts +1 -0
- package/es6/FrontApplet/FileSystem/FileSystem.js +10 -0
- package/es6/FrontApplet/FileSystem/FileSystem.js.map +1 -1
- package/es6/FrontApplet/FrontApplet.d.ts +4 -2
- package/es6/FrontApplet/FrontApplet.js +20 -7
- package/es6/FrontApplet/FrontApplet.js.map +1 -1
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.d.ts +30 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js +92 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js.map +1 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/IBarcodeScannerDataMessage.d.ts +5 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/IBarcodeScannerDataMessage.js +3 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/IBarcodeScannerDataMessage.js.map +1 -0
- package/es6/FrontApplet/Hardware/Hardware.d.ts +4 -1
- package/es6/FrontApplet/Hardware/Hardware.js +3 -0
- package/es6/FrontApplet/Hardware/Hardware.js.map +1 -1
- package/es6/FrontApplet/Management/Firmware.d.ts +2 -0
- package/es6/FrontApplet/Management/Firmware.js +8 -0
- package/es6/FrontApplet/Management/Firmware.js.map +1 -1
- package/es6/FrontApplet/Management/FirmwareType.d.ts +4 -0
- package/es6/FrontApplet/Management/FirmwareType.js +8 -0
- package/es6/FrontApplet/Management/FirmwareType.js.map +1 -0
- package/es6/FrontApplet/Management/INetworkInfo.d.ts +26 -2
- package/es6/FrontApplet/Management/INetworkInfo.js +7 -1
- package/es6/FrontApplet/Management/INetworkInfo.js.map +1 -1
- package/es6/FrontApplet/Management/Network.d.ts +18 -2
- package/es6/FrontApplet/Management/Network.js +51 -9
- package/es6/FrontApplet/Management/Network.js.map +1 -1
- package/es6/FrontApplet/Management/Time.d.ts +18 -0
- package/es6/FrontApplet/Management/Time.js +16 -4
- package/es6/FrontApplet/Management/Time.js.map +1 -1
- package/es6/FrontApplet/Management/Wifi.d.ts +13 -1
- package/es6/FrontApplet/Management/Wifi.js +12 -1
- package/es6/FrontApplet/Management/Wifi.js.map +1 -1
- package/es6/FrontApplet/Management/helpers/SecurityHelper.js +1 -1
- package/es6/FrontApplet/Stream/Stream.d.ts +1 -0
- package/es6/FrontApplet/Stream/Stream.js +7 -0
- package/es6/FrontApplet/Stream/Stream.js.map +1 -1
- package/es6/FrontApplet/Validate/Validate.js +1 -1
- package/es6/FrontApplet/Validate/Validate.js.map +1 -1
- package/es6/Monitoring/Montoring.js +1 -1
- package/es6/Monitoring/Montoring.js.map +1 -1
- package/package.json +6 -33
- package/docs/js-api/js-timing.md +0 -54
|
@@ -19,14 +19,20 @@ Network management API allows you to manually set network interfaces or set back
|
|
|
19
19
|
::: table-responsive
|
|
20
20
|
| Method | Description | Supported since |
|
|
21
21
|
| ------ | -------- | :-------------: |
|
|
22
|
-
| `getActiveInfo()` | Information about network interfaces, IP addesses and MAC addresses | 4.0 |
|
|
22
|
+
| `getActiveInfo()` | Information about network interfaces, IP addesses and MAC addresses (**DEPRECATED**) | 4.0 |
|
|
23
|
+
| `listInterfaces()` | Information about network interfaces | 4.9 |
|
|
23
24
|
| `setManual()` | Allows you to set network settings manually | 4.0 |
|
|
24
25
|
| `setDHCP()` | Allows you to set network settings automatically from DHCP | 4.0 |
|
|
26
|
+
| `disableInterface()` | Disables a network interface | 4.13 |
|
|
25
27
|
:::
|
|
26
28
|
|
|
27
29
|
## getActiveInfo()
|
|
28
30
|
Method `getActiveInfo()` will display information about connected network.
|
|
29
31
|
|
|
32
|
+
::: alert alert--warning
|
|
33
|
+
This method is deprecated. Use `listInterfaces()` instead.
|
|
34
|
+
:::
|
|
35
|
+
|
|
30
36
|
### Javascript example
|
|
31
37
|
```javascript
|
|
32
38
|
await sos.management.network.getActiveInfo();
|
|
@@ -64,10 +70,75 @@ await sos.management.network.getActiveInfo();
|
|
|
64
70
|
</div>
|
|
65
71
|
</div>
|
|
66
72
|
|
|
73
|
+
## listInterfaces()
|
|
74
|
+
Returns list of all network interfaces, and their information like MAC address, IP address, etc.
|
|
75
|
+
|
|
76
|
+
### Javascript example
|
|
77
|
+
```javascript
|
|
78
|
+
const interfaces = await sos.management.network.listInterfaces();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Example of response
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
[
|
|
85
|
+
{
|
|
86
|
+
"type": "ethernet",
|
|
87
|
+
"name": "eth0",
|
|
88
|
+
"macAddress": "b8:27:eb:25:8f:63",
|
|
89
|
+
"localAddress": "192.168.1.137",
|
|
90
|
+
"gateway": "192.168.1.1",
|
|
91
|
+
"netmask": "255.255.255.0",
|
|
92
|
+
"dns": [
|
|
93
|
+
"192.168.1.1",
|
|
94
|
+
"1.1.1.1"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "wifi",
|
|
99
|
+
"name": "wlan0",
|
|
100
|
+
"macAddress": "b8:27:eb:25:8f:63",
|
|
101
|
+
"disabled": true,
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
<div class="row d-flex align-content-stretch force-padding-20">
|
|
107
|
+
<div class="col-12 d-flex">
|
|
108
|
+
<a class="wide-box wide-box--white d-flex align-content-stretch widebox-kb-color" target="_blank" href="https://github.com/signageos/applet-examples/blob/master/examples/management-js-api/network/">
|
|
109
|
+
<div>
|
|
110
|
+
<div class="wide-box__image d-flex align-items-center">
|
|
111
|
+
<i class="fab fa-github svg-black"></i>
|
|
112
|
+
</div>
|
|
113
|
+
<div>
|
|
114
|
+
<h3 class="wide-box__title wide-box__title__small pl-85">Getting network interfaces from device</h3>
|
|
115
|
+
<div class="wide-box__description">Working example on our Github</div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</a>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
67
122
|
## setManual()
|
|
68
|
-
|
|
123
|
+
Manually configures a network interface.
|
|
124
|
+
If the interface is disabled, it will be enabled.
|
|
125
|
+
|
|
126
|
+
::: alert alert--warning
|
|
127
|
+
Wi-Fi interface can be configured with this method but it has to be first enabled via the [Wi-Fi API](/api/js/management/11-js-management-network).
|
|
128
|
+
:::
|
|
69
129
|
|
|
70
130
|
### Object properties
|
|
131
|
+
|
|
132
|
+
#### New way
|
|
133
|
+
| Name | Type | Required | Description |
|
|
134
|
+
| ---- | ---- | :------: | ------ |
|
|
135
|
+
| `interfaceName` | String | <div class="red">Yes</div> | Network interface name, can be retrieved from `listInterfaces()` |
|
|
136
|
+
| `options.localAddress` | String | <div class="red">Yes</div> | Network local address |
|
|
137
|
+
| `options.gateway` | String | <div class="red">Yes</div> | Network gateway |
|
|
138
|
+
| `options.netmask` | String | <div class="red">Yes</div> | Network netmask |
|
|
139
|
+
| `options.dns` | Array | <div class="red">Yes</div> | Array of additionally DNSs |
|
|
140
|
+
|
|
141
|
+
#### Old way (deprecated)
|
|
71
142
|
| Name | Type | Required | Description |
|
|
72
143
|
| ---- | ---- | :------: | ------ |
|
|
73
144
|
| `interface` | String | <div class="red">Yes</div> | Network type interface, can be only `ethernet` or `wifi` |
|
|
@@ -78,6 +149,15 @@ Method `setManual()` will set the current network.
|
|
|
78
149
|
|
|
79
150
|
### Javascript example
|
|
80
151
|
```javascript
|
|
152
|
+
// new way
|
|
153
|
+
await sos.management.network.setManual('eth0', {
|
|
154
|
+
localAddress: '192.168.1.133',
|
|
155
|
+
gateway: '192.168.1.1',
|
|
156
|
+
netmask: '255.255.255.0',
|
|
157
|
+
dns: ['8.8.8.8', '192.168.1.1'],
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// old way (deprecated)
|
|
81
161
|
await sos.management.network.setManual({
|
|
82
162
|
interface: 'ethernet',
|
|
83
163
|
localAddress: '192.168.1.133',
|
|
@@ -88,14 +168,53 @@ await sos.management.network.setManual({
|
|
|
88
168
|
```
|
|
89
169
|
|
|
90
170
|
## setDHCP()
|
|
91
|
-
|
|
171
|
+
Configures a network interface to use DHCP to get an IP address asigned from the network.
|
|
172
|
+
If the interface is disabled, it will be enabled.
|
|
173
|
+
|
|
174
|
+
::: alert alert--warning
|
|
175
|
+
Wi-Fi interface can be configured with this method but it has to be first enabled via the [Wi-Fi API](/api/js/management/11-js-management-network).
|
|
176
|
+
:::
|
|
92
177
|
|
|
93
178
|
### Object properties
|
|
179
|
+
|
|
180
|
+
#### New way
|
|
181
|
+
| Name | Type | Required | Description |
|
|
182
|
+
| ---- | ---- | :------: | ------ |
|
|
183
|
+
| `interfaceName` | String | <div class="red">Yes</div> | Network interface name, can be retrieved from `listInterfaces()` |
|
|
184
|
+
|
|
185
|
+
#### Old way (deprecated)
|
|
94
186
|
| Name | Type | Required | Description |
|
|
95
187
|
| ---- | ---- | :------: | ------ |
|
|
96
188
|
| `networkInterface` | String | <div class="red">Yes</div> | Network type interface, can be only `ethernet` or `wifi` |
|
|
97
189
|
|
|
98
190
|
### Javascript example
|
|
99
191
|
```javascript
|
|
192
|
+
// new way
|
|
193
|
+
await sos.management.network.setDHCP('eth0');
|
|
194
|
+
|
|
195
|
+
// old way (deprecated)
|
|
100
196
|
await sos.management.network.setDHCP('ethernet');
|
|
101
197
|
```
|
|
198
|
+
|
|
199
|
+
## disableInterface()
|
|
200
|
+
Disables a network interface
|
|
201
|
+
|
|
202
|
+
::: table-responsive
|
|
203
|
+
| Param | Type | Required | Description |
|
|
204
|
+
| --------------- | ------ | :------------------------: | ---------------------------------------------------- |
|
|
205
|
+
| `interfaceName` | String | <div class="red">Yes</div> | Name of the network interface, that will be disabled |
|
|
206
|
+
:::
|
|
207
|
+
|
|
208
|
+
### Javascript example
|
|
209
|
+
```javascript
|
|
210
|
+
await sos.management.wifi.disableInterface("eth0");
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
::: alert alert--info
|
|
214
|
+
A disabled network interface can be re-enabled simply by calling either `setDHCP()` or `setManual()`.
|
|
215
|
+
:::
|
|
216
|
+
|
|
217
|
+
::: alert alert--warning
|
|
218
|
+
Don't use this method to disable Wi-Fi.
|
|
219
|
+
Use [Wi-Fi API](/api/js/management/11-js-management-network) to enable/disable Wi-Fi.
|
|
220
|
+
:::
|
|
@@ -191,6 +191,7 @@ It is only allowed to call this method in the **CLIENT** state.
|
|
|
191
191
|
| ------------------- | ------ | :---------: | ---------------------------------- |
|
|
192
192
|
| `ssid` | String | <div class="red">Yes</div> | Name of the network you want to connect to. |
|
|
193
193
|
| `password` | String | <div class="yellow">No</div> | Network's password. |
|
|
194
|
+
| `options` | Object | <div class="yellow">No</div> | Additional options. |
|
|
194
195
|
:::
|
|
195
196
|
|
|
196
197
|
### Javascript example
|
|
@@ -200,6 +201,9 @@ await sos.management.wifi.connect('network1');
|
|
|
200
201
|
|
|
201
202
|
// or network with password
|
|
202
203
|
await sos.management.wifi.connect('network2', 'password123');
|
|
204
|
+
|
|
205
|
+
// connect to a hidden network
|
|
206
|
+
await sos.management.wifi.connect('network3', 'password123', { hidden: true });
|
|
203
207
|
```
|
|
204
208
|
|
|
205
209
|
## disconnect()
|
|
@@ -65,8 +65,29 @@ await sos.management.firmware.upgrade(
|
|
|
65
65
|
## getVersion()
|
|
66
66
|
Method `getVersion()` will specify what current version of firmware is installed on a device.
|
|
67
67
|
|
|
68
|
+
### Javascript example
|
|
68
69
|
```javascript
|
|
69
70
|
sos.management.firmware.getVersion().then((version) => {
|
|
70
71
|
console.log(version); // Returns String e.g. T-HKMLAKUC-2020.5
|
|
71
72
|
});
|
|
72
73
|
```
|
|
74
|
+
|
|
75
|
+
## getType()
|
|
76
|
+
Returns a string identifier that, when combined with firmware version, can be used to identify a correct firmware image to install on the current device.
|
|
77
|
+
|
|
78
|
+
::: table-responsive
|
|
79
|
+
| Type | Description |
|
|
80
|
+
| ------------- | -------------------------------------- |
|
|
81
|
+
| `rpi` | any Raspberry Pi 3 or Compute Module 3 |
|
|
82
|
+
| `rpi4` | any Raspberry Pi 4 or Compute Module 4 |
|
|
83
|
+
| `benq-` | any Benq display |
|
|
84
|
+
| `philips-` | any Philips display |
|
|
85
|
+
| `sharp-` | any Sharp display |
|
|
86
|
+
| `elo-` | any Elo display |
|
|
87
|
+
:::
|
|
88
|
+
|
|
89
|
+
### Javascript example
|
|
90
|
+
```javascript
|
|
91
|
+
const type = await sos.management.firmware.getType();
|
|
92
|
+
console.log(type); // e.g. rpi4
|
|
93
|
+
```
|
|
@@ -29,7 +29,7 @@ reboot any device once a day.
|
|
|
29
29
|
| `setBrightness()` | Set screen brightness | 3.0.0 |
|
|
30
30
|
| `getBrightness()` | Get current brightness value | 3.0.0 |
|
|
31
31
|
| `powerOn()` | Turn `ON` the display (only the display) | 3.0.0 |
|
|
32
|
-
| `powerOff()` | Turn `OFF` the display (only the display) | 3.0.0 |
|
|
32
|
+
| `powerOff()` | Turn `OFF` the display (only the display, except Android devices where it turns off the webview as well) | 3.0.0 |
|
|
33
33
|
| `isPoweredOn()` | Check the display status | 3.0.0 |
|
|
34
34
|
| `takeAndUploadScreenshot()` | Takes screenshot from the device and upload it to server | 3.0.0 |
|
|
35
35
|
:::
|
|
@@ -41,7 +41,7 @@ Method `resize()` helps you manipulate with several aspects of your displays scr
|
|
|
41
41
|
::: table-responsive
|
|
42
42
|
| Param |Type | Required | Description |
|
|
43
43
|
| -------------- | -------------------| :----------: | -------------------- |
|
|
44
|
-
| `baseUrl` | String | <div class="red">Yes</div> |
|
|
44
|
+
| `baseUrl` | String | <div class="red">Yes</div> | SSSP & Tizen devices requires to install a orientation-specific Core App if you want to switch orientation to portrait or landscape. |
|
|
45
45
|
|^^|^^|^^| `https://cdn.your-cms.com/tizen/1.0.4` |
|
|
46
46
|
| `orientation` | Orientation | <div class="red">Yes</div> | Screen orientation |
|
|
47
47
|
|^^|^^|^^| `PORTRAIT`, `LANDSCAPE`, `PORTRAIT_FLIPED`, `LANDSCAPE_FLIPPED`, `AUTO` |
|
|
@@ -53,17 +53,21 @@ Method `resize()` helps you manipulate with several aspects of your displays scr
|
|
|
53
53
|
|^^|^^|^^| `LANDSCAPE`, `PORTRAIT` |
|
|
54
54
|
:::
|
|
55
55
|
|
|
56
|
+
::: alert alert--info
|
|
57
|
+
For Tizen, you have to provide `baseUrl` which points to your server where you uploaded previously built Core App for Tizen with your buiult-in Applet. [Read more how to upload your Core Apps here.](https://docs.signageos.io/knowledge-base/open-standalone-signageos-provisioning#tizen-specific-installation-url).
|
|
58
|
+
:::
|
|
59
|
+
|
|
56
60
|
### Javascript example
|
|
57
61
|
```javascript
|
|
58
62
|
// for Tizen
|
|
59
63
|
await sos.management.screen.resize(
|
|
60
64
|
"https://cdn.your-cms.com/tizen/1.0.4",
|
|
61
65
|
"PORTRAIT",
|
|
62
|
-
"
|
|
66
|
+
"FULL_READY",
|
|
63
67
|
"1.0.4"
|
|
64
68
|
);
|
|
65
69
|
|
|
66
|
-
//for other supported device
|
|
70
|
+
//for all other supported device
|
|
67
71
|
await sos.management.screen.resize(
|
|
68
72
|
"",
|
|
69
73
|
"PORTRAIT",
|
|
@@ -117,17 +117,33 @@ Calling `setManual()` will disable NTP server settings.
|
|
|
117
117
|
::: table-responsive
|
|
118
118
|
| Param |Type | Required | Description |
|
|
119
119
|
| -------------- | ---------- | :---------: | ------------------- |
|
|
120
|
-
| `currentDate` | Date
|
|
120
|
+
| `currentDate` | Date \| object | <div class="red">Yes</div> | Datetime to set |
|
|
121
121
|
| `timezone` | String | <div class="red">Yes</div> | Timezone to set. Accepted values are timezone names from [timezone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). |
|
|
122
122
|
:::
|
|
123
123
|
|
|
124
124
|
### Javascript example
|
|
125
125
|
```javascript
|
|
126
|
+
const datetimeObj = {
|
|
127
|
+
year: 2021,
|
|
128
|
+
month: 12,
|
|
129
|
+
day: 15,
|
|
130
|
+
hour: 9,
|
|
131
|
+
minute: 30,
|
|
132
|
+
seconds: 0,
|
|
133
|
+
};
|
|
134
|
+
const timezone = "Europe/Amsterdam";
|
|
135
|
+
await sos.management.time.setManual(datetimeObj, timezone);
|
|
136
|
+
|
|
137
|
+
// Using Date is deprecated. Use the example above.
|
|
126
138
|
const currentDate = new Date();
|
|
127
139
|
const timezone = "Europe/Amsterdam";
|
|
128
140
|
await sos.management.time.setManual(currentDate, timezone);
|
|
129
141
|
```
|
|
130
142
|
|
|
143
|
+
::: alert alert--warning
|
|
144
|
+
Calling this method with currentDate as Date is deprecated.
|
|
145
|
+
You should call it with datetime object instead. See example code.
|
|
146
|
+
:::
|
|
131
147
|
|
|
132
148
|
::: alert alert--warning
|
|
133
149
|
Setting time and timezone has side effects:
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import IPostMessage from '../IPostMessage';
|
|
2
1
|
import { IDeprecatedOpenLinkOptions } from './IOpenLinkOptions';
|
|
3
2
|
import IOpenLinkOptions from './IOpenLinkOptions';
|
|
3
|
+
import { CloseEvent } from './events';
|
|
4
|
+
import { IBrowserMessage } from './messages';
|
|
5
|
+
import Exchange from '../Exchange/Exchange';
|
|
4
6
|
export default class Browser {
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
constructor(messagePrefix: string, postMessage: IPostMessage<void>);
|
|
7
|
+
private readonly exchange;
|
|
8
|
+
private readonly events;
|
|
9
|
+
constructor(exchange: Exchange<void>);
|
|
9
10
|
open(uri: string, options?: IOpenLinkOptions): Promise<void>;
|
|
10
11
|
close(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Find out when the browser is closed.
|
|
14
|
+
* This can happen by an API call, by a user request or after a timeout.
|
|
15
|
+
*
|
|
16
|
+
* This doesn't fire between `open` calls or on subsequent `close` calls.
|
|
17
|
+
*
|
|
18
|
+
* @returns A callback which removes the listener.
|
|
19
|
+
*/
|
|
20
|
+
onClose(listener: (event: CloseEvent) => void): () => void;
|
|
21
|
+
handleMessageData(data: IBrowserMessage): void;
|
|
11
22
|
/** @deprecated use sos.browser.open() instead */
|
|
12
23
|
openLink(uri: string, options?: IDeprecatedOpenLinkOptions): Promise<void>;
|
|
13
|
-
private getMessage;
|
|
14
24
|
}
|
|
@@ -11,38 +11,65 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const IOpenLinkOptions_1 = require("./IOpenLinkOptions");
|
|
13
13
|
const Validate_1 = require("../Validate/Validate");
|
|
14
|
+
const events_1 = require("./events");
|
|
15
|
+
const events_2 = require("events");
|
|
14
16
|
class Browser {
|
|
15
|
-
constructor(
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
17
|
+
constructor(exchange) {
|
|
18
|
+
this.exchange = exchange;
|
|
19
|
+
this.events = new events_2.EventEmitter();
|
|
18
20
|
}
|
|
19
21
|
open(uri, options = {}) {
|
|
22
|
+
var _a;
|
|
20
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
24
|
Validate_1.default({ uri }).required().uri();
|
|
22
25
|
Validate_1.default({ options }).required().object(IOpenLinkOptions_1.VIOpenLinkOptions);
|
|
23
|
-
|
|
26
|
+
const headlessMode = (_a = options.headlessMode) !== null && _a !== void 0 ? _a : true;
|
|
27
|
+
yield this.exchange.postMessage(Object.assign(Object.assign({ uri }, options), { headlessMode, type: 'open' }));
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
close() {
|
|
27
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
yield this.postMessage({
|
|
29
|
-
type:
|
|
32
|
+
yield this.exchange.postMessage({
|
|
33
|
+
type: 'close',
|
|
30
34
|
});
|
|
31
35
|
});
|
|
32
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Find out when the browser is closed.
|
|
39
|
+
* This can happen by an API call, by a user request or after a timeout.
|
|
40
|
+
*
|
|
41
|
+
* This doesn't fire between `open` calls or on subsequent `close` calls.
|
|
42
|
+
*
|
|
43
|
+
* @returns A callback which removes the listener.
|
|
44
|
+
*/
|
|
45
|
+
onClose(listener) {
|
|
46
|
+
Validate_1.default({ listener }).required().function();
|
|
47
|
+
this.events.addListener(events_1.EventType.CLOSE, listener);
|
|
48
|
+
return () => {
|
|
49
|
+
this.events.removeListener(events_1.EventType.CLOSE, listener);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
handleMessageData(data) {
|
|
53
|
+
switch (data.type) {
|
|
54
|
+
case this.exchange.messageNameToType('closed'):
|
|
55
|
+
const event = {
|
|
56
|
+
type: events_1.EventType.CLOSE,
|
|
57
|
+
reason: data.reason,
|
|
58
|
+
};
|
|
59
|
+
this.events.emit(events_1.EventType.CLOSE, event);
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
}
|
|
63
|
+
}
|
|
33
64
|
/** @deprecated use sos.browser.open() instead */
|
|
34
65
|
openLink(uri, options = {}) {
|
|
35
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
console.warn('sos.browser.openLink() is deprecated and will be removed in the future versions. Use sos.browser.open() instead.');
|
|
36
68
|
Validate_1.default({ uri }).required().uri();
|
|
37
69
|
Validate_1.default({ options }).required().object();
|
|
38
|
-
|
|
39
|
-
yield this.postMessage(Object.assign({ type: this.getMessage('open_link'), uri }, options));
|
|
70
|
+
yield this.exchange.postMessage(Object.assign(Object.assign({ uri }, options), { headlessMode: false, type: 'open_link' }));
|
|
40
71
|
});
|
|
41
72
|
}
|
|
42
|
-
getMessage(name) {
|
|
43
|
-
return this.messagePrefix + '.' + Browser.MESSAGE_PREFIX + '.' + name;
|
|
44
|
-
}
|
|
45
73
|
}
|
|
46
74
|
exports.default = Browser;
|
|
47
|
-
Browser.MESSAGE_PREFIX = 'browser';
|
|
48
75
|
//# sourceMappingURL=Browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Browser.js","sourceRoot":"","sources":["../../../src/FrontApplet/Browser/Browser.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Browser.js","sourceRoot":"","sources":["../../../src/FrontApplet/Browser/Browser.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,yDAAmF;AAEnF,mDAA4C;AAC5C,qCAA8D;AAC9D,mCAAsC;AAItC,MAAqB,OAAO;IAI3B,YACkB,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;QAHzB,WAAM,GAAiB,IAAI,qBAAY,EAAE,CAAC;IAK3D,CAAC;IAEY,IAAI,CAAC,GAAW,EAAE,UAA4B,EAAE;;;YAC5D,kBAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC;YACnC,kBAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,oCAAiB,CAAC,CAAC;YAE3D,MAAM,YAAY,SAAG,OAAO,CAAC,YAAY,mCAAI,IAAI,CAAC;YAClD,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,+BAC9B,GAAG,IACA,OAAO,KACV,YAAY,EACZ,IAAI,EAAE,MAAM,IACX,CAAC;;KACH;IAEY,KAAK;;YACjB,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAC/B,IAAI,EAAE,OAAO;aACb,CAAC,CAAC;QACJ,CAAC;KAAA;IAED;;;;;;;OAOG;IACI,OAAO,CAAC,QAAqC;QACnD,kBAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;QAE7C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACnD,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,kBAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC,CAAC;IACH,CAAC;IAEM,iBAAiB,CAAC,IAAqB;QAC7C,QAAQ,IAAI,CAAC,IAAI,EAAE;YAClB,KAAK,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC;gBAC7C,MAAM,KAAK,GAAe;oBACzB,IAAI,EAAE,kBAAS,CAAC,KAAK;oBACrB,MAAM,EAAE,IAAI,CAAC,MAAqB;iBAClC,CAAC;gBACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBACzC,MAAM;YACP,QAAQ;SACR;IACF,CAAC;IAED,iDAAiD;IACpC,QAAQ,CACpB,GAAW,EACX,UAAsC,EAAE;;YAExC,OAAO,CAAC,IAAI,CAAC,kHAAkH,CAAC,CAAC;YAEjI,kBAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC;YACnC,kBAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC;YAE1C,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,+BAC9B,GAAG,IACA,OAAO,KACV,YAAY,EAAE,KAAK,EACnB,IAAI,EAAE,WAAW,IAChB,CAAC;QACJ,CAAC;KAAA;CACD;AA3ED,0BA2EC"}
|
|
@@ -93,6 +93,7 @@ interface IOpenLinkOptions {
|
|
|
93
93
|
aclDomains?: string[];
|
|
94
94
|
aclMode?: 'blacklist' | 'whitelist';
|
|
95
95
|
readOnlyAddressBar?: boolean;
|
|
96
|
+
idleTimeout?: number;
|
|
96
97
|
coordinates?: {
|
|
97
98
|
x: number;
|
|
98
99
|
y: number;
|
|
@@ -100,6 +101,9 @@ interface IOpenLinkOptions {
|
|
|
100
101
|
height: number;
|
|
101
102
|
};
|
|
102
103
|
theme?: ITheme;
|
|
104
|
+
headlessMode?: boolean;
|
|
105
|
+
clearData?: boolean;
|
|
106
|
+
canUserClose?: boolean;
|
|
103
107
|
}
|
|
104
108
|
export default IOpenLinkOptions;
|
|
105
109
|
export declare const VIOpenLinkOptions: {
|
|
@@ -110,6 +114,7 @@ export declare const VIOpenLinkOptions: {
|
|
|
110
114
|
'?string': string[];
|
|
111
115
|
};
|
|
112
116
|
readOnlyAddressBar: string;
|
|
117
|
+
idleTimeout: string;
|
|
113
118
|
coordinates: {
|
|
114
119
|
'?object': {
|
|
115
120
|
x: string;
|
|
@@ -171,4 +176,7 @@ export declare const VIOpenLinkOptions: {
|
|
|
171
176
|
};
|
|
172
177
|
};
|
|
173
178
|
};
|
|
179
|
+
headlessMode: string;
|
|
180
|
+
clearData: string;
|
|
181
|
+
canUserClose: string;
|
|
174
182
|
};
|
|
@@ -43,6 +43,7 @@ exports.VIOpenLinkOptions = {
|
|
|
43
43
|
aclDomains: { '?array': 'string' },
|
|
44
44
|
aclMode: { '?string': ['blacklist', 'whitelist'] },
|
|
45
45
|
readOnlyAddressBar: '?boolean',
|
|
46
|
+
idleTimeout: '?number',
|
|
46
47
|
coordinates: { '?object': {
|
|
47
48
|
x: 'number',
|
|
48
49
|
y: 'number',
|
|
@@ -51,5 +52,8 @@ exports.VIOpenLinkOptions = {
|
|
|
51
52
|
}
|
|
52
53
|
},
|
|
53
54
|
theme: { '?object': exports.VITheme },
|
|
55
|
+
headlessMode: '?boolean',
|
|
56
|
+
clearData: '?boolean',
|
|
57
|
+
canUserClose: '?boolean',
|
|
54
58
|
};
|
|
55
59
|
//# sourceMappingURL=IOpenLinkOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IOpenLinkOptions.js","sourceRoot":"","sources":["../../../src/FrontApplet/Browser/IOpenLinkOptions.ts"],"names":[],"mappings":";;AAmCa,QAAA,OAAO,GAAG;IACtB,IAAI,EAAE,EAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAC;IACpC,KAAK,EAAE,EAAC,SAAS,EAAE;YACjB,UAAU,EAAE,SAAS;SACrB;KACD;IACD,MAAM,EAAE,EAAC,SAAS,EAAE;YAClB,OAAO,EAAE,SAAS;YAClB,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,SAAS;SAClB;KACD;IACD,OAAO,EAAE,EAAC,SAAS,EAAE;YACnB,WAAW,EAAE,EAAC,SAAS,EAAE;oBACvB,MAAM,EAAE,EAAC,SAAS,EAAE;4BAClB,UAAU,EAAE,SAAS;4BACrB,IAAI,EAAE,SAAS;yBACf;qBACD;iBACD;aACD;YACD,WAAW,EAAE,EAAC,SAAS,EAAE;oBACvB,MAAM,EAAE,EAAC,SAAS,EAAE;4BAClB,UAAU,EAAE,SAAS;4BACrB,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,SAAS;yBACf;qBACD;oBACD,IAAI,EAAE,EAAC,SAAS,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAC;oBAC7D,IAAI,EAAE,SAAS;iBACf;aACD;YACD,QAAQ,EAAE,EAAC,SAAS,EAAE;oBACpB,KAAK,EAAE,SAAS;iBAChB;aACD;SACD;KACD;CACD,CAAC;
|
|
1
|
+
{"version":3,"file":"IOpenLinkOptions.js","sourceRoot":"","sources":["../../../src/FrontApplet/Browser/IOpenLinkOptions.ts"],"names":[],"mappings":";;AAmCa,QAAA,OAAO,GAAG;IACtB,IAAI,EAAE,EAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAC;IACpC,KAAK,EAAE,EAAC,SAAS,EAAE;YACjB,UAAU,EAAE,SAAS;SACrB;KACD;IACD,MAAM,EAAE,EAAC,SAAS,EAAE;YAClB,OAAO,EAAE,SAAS;YAClB,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,SAAS;SAClB;KACD;IACD,OAAO,EAAE,EAAC,SAAS,EAAE;YACnB,WAAW,EAAE,EAAC,SAAS,EAAE;oBACvB,MAAM,EAAE,EAAC,SAAS,EAAE;4BAClB,UAAU,EAAE,SAAS;4BACrB,IAAI,EAAE,SAAS;yBACf;qBACD;iBACD;aACD;YACD,WAAW,EAAE,EAAC,SAAS,EAAE;oBACvB,MAAM,EAAE,EAAC,SAAS,EAAE;4BAClB,UAAU,EAAE,SAAS;4BACrB,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,SAAS;yBACf;qBACD;oBACD,IAAI,EAAE,EAAC,SAAS,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAC;oBAC7D,IAAI,EAAE,SAAS;iBACf;aACD;YACD,QAAQ,EAAE,EAAC,SAAS,EAAE;oBACpB,KAAK,EAAE,SAAS;iBAChB;aACD;SACD;KACD;CACD,CAAC;AA8BW,QAAA,iBAAiB,GAAG;IAChC,UAAU,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAC;IAChC,OAAO,EAAE,EAAC,SAAS,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,EAAC;IAChD,kBAAkB,EAAE,UAAU;IAC9B,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,EAAC,SAAS,EAAE;YACvB,CAAC,EAAE,QAAQ;YACX,CAAC,EAAE,QAAQ;YACX,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,QAAQ;SAChB;KACD;IACD,KAAK,EAAE,EAAC,SAAS,EAAE,eAAO,EAAC;IAC3B,YAAY,EAAE,UAAU;IACxB,SAAS,EAAE,UAAU;IACrB,YAAY,EAAE,UAAU;CACxB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum EventType {
|
|
2
|
+
CLOSE = "close"
|
|
3
|
+
}
|
|
4
|
+
export declare const VIEventType: string[];
|
|
5
|
+
export declare type Event<TType extends EventType = EventType> = {
|
|
6
|
+
type: TType;
|
|
7
|
+
};
|
|
8
|
+
export interface CloseEvent extends Event<EventType.CLOSE> {
|
|
9
|
+
reason: CloseReason;
|
|
10
|
+
}
|
|
11
|
+
export declare enum CloseReason {
|
|
12
|
+
API = "API",
|
|
13
|
+
USER = "USER",
|
|
14
|
+
TIMEOUT = "TIMEOUT"
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var EventType;
|
|
4
|
+
(function (EventType) {
|
|
5
|
+
EventType["CLOSE"] = "close";
|
|
6
|
+
})(EventType = exports.EventType || (exports.EventType = {}));
|
|
7
|
+
exports.VIEventType = ['close'];
|
|
8
|
+
var CloseReason;
|
|
9
|
+
(function (CloseReason) {
|
|
10
|
+
CloseReason["API"] = "API";
|
|
11
|
+
CloseReason["USER"] = "USER";
|
|
12
|
+
CloseReason["TIMEOUT"] = "TIMEOUT";
|
|
13
|
+
})(CloseReason = exports.CloseReason || (exports.CloseReason = {}));
|
|
14
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/FrontApplet/Browser/events.ts"],"names":[],"mappings":";;AACA,IAAY,SAEX;AAFD,WAAY,SAAS;IACpB,4BAAe,CAAA;AAChB,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB;AAEY,QAAA,WAAW,GAAG,CAAC,OAAO,CAAC,CAAC;AAUrC,IAAY,WAIX;AAJD,WAAY,WAAW;IACtB,0BAAW,CAAA;IACX,4BAAa,CAAA;IACb,kCAAmB,CAAA;AACpB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/FrontApplet/Browser/messages.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import IMessage from "../IMessage";
|
|
4
|
+
interface IDebugSetWeinreMessage extends IMessage {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
url: string;
|
|
7
|
+
id: string;
|
|
8
|
+
}
|
|
9
|
+
export interface WeinreData {
|
|
10
|
+
__weinreLoaded?: boolean;
|
|
11
|
+
WeinreServerURL?: string;
|
|
12
|
+
WeinreServerId?: string;
|
|
13
|
+
}
|
|
14
|
+
export default class Debug extends EventEmitter {
|
|
15
|
+
readonly window: Window & WeinreData;
|
|
16
|
+
private messagePrefix;
|
|
17
|
+
static MESSAGE_PREFIX: string;
|
|
18
|
+
constructor(window: Window & WeinreData, messagePrefix: string);
|
|
19
|
+
handleMessageData(data: IDebugSetWeinreMessage): void;
|
|
20
|
+
private getMessage;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const events_1 = require("events");
|
|
4
|
+
class Debug extends events_1.EventEmitter {
|
|
5
|
+
constructor(window, messagePrefix) {
|
|
6
|
+
super();
|
|
7
|
+
this.window = window;
|
|
8
|
+
this.messagePrefix = messagePrefix;
|
|
9
|
+
}
|
|
10
|
+
handleMessageData(data) {
|
|
11
|
+
switch (data.type) {
|
|
12
|
+
case this.getMessage("configure"):
|
|
13
|
+
if (data.enabled) {
|
|
14
|
+
this.window.WeinreServerURL = data.url;
|
|
15
|
+
this.window.WeinreServerId = data.id;
|
|
16
|
+
if (!this.window.__weinreLoaded) {
|
|
17
|
+
require("weinre/web/target/target-script");
|
|
18
|
+
this.window.__weinreLoaded = true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.window.WeinreServerURL = undefined;
|
|
23
|
+
this.window.WeinreServerId = undefined;
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
getMessage(name) {
|
|
30
|
+
return this.messagePrefix + "." + Debug.MESSAGE_PREFIX + "." + name;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = Debug;
|
|
34
|
+
Debug.MESSAGE_PREFIX = "debug";
|
|
35
|
+
//# sourceMappingURL=Debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Debug.js","sourceRoot":"","sources":["../../../src/FrontApplet/Debug/Debug.ts"],"names":[],"mappings":";;AAAA,mCAAsC;AAetC,MAAqB,KAAM,SAAQ,qBAAY;IAG9C,YACiB,MAA2B,EACnC,aAAqB;QAE7B,KAAK,EAAE,CAAC;QAHQ,WAAM,GAAN,MAAM,CAAqB;QACnC,kBAAa,GAAb,aAAa,CAAQ;IAG9B,CAAC;IAEM,iBAAiB,CAAC,IAA4B;QACpD,QAAQ,IAAI,CAAC,IAAI,EAAE;YAClB,KAAK,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;gBAChC,IAAI,IAAI,CAAC,OAAO,EAAE;oBACjB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC;oBACvC,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC;oBACrC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;wBAChC,OAAO,CAAC,iCAAiC,CAAC,CAAC;wBAC3C,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;qBAClC;iBACD;qBAAM;oBACN,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,SAAS,CAAC;oBACxC,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,SAAS,CAAC;iBACvC;gBACD,MAAM;YACP,QAAQ;SACR;IACF,CAAC;IAEO,UAAU,CAAC,IAAY;QAC9B,OAAO,IAAI,CAAC,aAAa,GAAG,GAAG,GAAG,KAAK,CAAC,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC;IACrE,CAAC;;AA/BF,wBAgCC;AA/Bc,oBAAc,GAAW,OAAO,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import IPostMessage from "../../FrontApplet/IPostMessage";
|
|
2
|
+
export default interface Exchange<TResponse> {
|
|
3
|
+
postMessage: IPostMessage<TResponse>;
|
|
4
|
+
messageNameToType(name: string): string;
|
|
5
|
+
createNamespaced<TNamespacedResponse>(namespace: string): Exchange<TNamespacedResponse>;
|
|
6
|
+
}
|
|
7
|
+
export declare function createExchange<TResponse>(messagePrefix: string, postMessage: IPostMessage<any>): Exchange<TResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
function createExchange(messagePrefix, postMessage) {
|
|
13
|
+
const messageNameToType = (name) => {
|
|
14
|
+
return [messagePrefix, name].join('.');
|
|
15
|
+
};
|
|
16
|
+
const typedPostMessage = (message) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const type = messageNameToType(message.type);
|
|
18
|
+
message = Object.assign(Object.assign({}, message), { type });
|
|
19
|
+
return postMessage(message);
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
messageNameToType,
|
|
23
|
+
postMessage: typedPostMessage,
|
|
24
|
+
createNamespaced: (namespace) => createExchange(messageNameToType(namespace), postMessage)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.createExchange = createExchange;
|
|
28
|
+
//# sourceMappingURL=Exchange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Exchange.js","sourceRoot":"","sources":["../../../src/FrontApplet/Exchange/Exchange.ts"],"names":[],"mappings":";;;;;;;;;;;AASA,SAAgB,cAAc,CAC7B,aAAqB,EACrB,WAA8B;IAE9B,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;QAC1C,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC,CAAC;IACF,MAAM,gBAAgB,GAAG,CAAO,OAAiB,EAAsB,EAAE;QACxE,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,mCACH,OAAO,KACV,IAAI,GACJ,CAAC;QACF,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC,CAAA,CAAC;IACF,OAAO;QACN,iBAAiB;QACjB,WAAW,EAAE,gBAAgB;QAC7B,gBAAgB,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC;KAClG,CAAC;AACH,CAAC;AApBD,wCAoBC"}
|
|
@@ -15,6 +15,7 @@ export default class FileSystem {
|
|
|
15
15
|
exists(filePath: IFilePath): Promise<boolean>;
|
|
16
16
|
getFile(filePath: IFilePath): Promise<IFile | null>;
|
|
17
17
|
writeFile(filePath: IFilePath, contents: string): Promise<void>;
|
|
18
|
+
appendFile(filePath: IFilePath, contents: string): Promise<void>;
|
|
18
19
|
readFile(filePath: IFilePath): Promise<string>;
|
|
19
20
|
copyFile(sourceFilePath: IFilePath, destinationFilePath: IFilePath, options?: ICopyFileOptions): Promise<void>;
|
|
20
21
|
moveFile(sourceFilePath: IFilePath, destinationFilePath: IFilePath, options?: IMoveFileOptions): Promise<void>;
|