@interopio/browser-platform 3.0.1
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/browser.platform.d.ts +455 -0
- package/changelog.md +69 -0
- package/dist/browser.platform.es.js +46074 -0
- package/dist/browser.platform.es.js.map +1 -0
- package/dist/browser.platform.umd.js +46082 -0
- package/dist/browser.platform.umd.js.map +1 -0
- package/license.md +21 -0
- package/package.json +78 -0
- package/readme.md +9 -0
- package/rollup.config.js +45 -0
- package/src/common/constants.ts +46 -0
- package/src/common/defaultConfig.ts +56 -0
- package/src/common/gateway.d.ts +32 -0
- package/src/common/types.ts +222 -0
- package/src/connection/gateway.ts +132 -0
- package/src/connection/no-gateway.ts +1 -0
- package/src/connection/portsBridge.ts +441 -0
- package/src/connection/preferred.ts +247 -0
- package/src/controllers/domains.ts +156 -0
- package/src/controllers/glue.ts +604 -0
- package/src/controllers/interception.ts +53 -0
- package/src/controllers/license.ts +50 -0
- package/src/controllers/main.ts +256 -0
- package/src/controllers/plugins.ts +121 -0
- package/src/controllers/serviceWorker.ts +193 -0
- package/src/controllers/state.ts +84 -0
- package/src/controllers/system.ts +99 -0
- package/src/controllers/transactions.ts +80 -0
- package/src/factory.ts +40 -0
- package/src/fallbacks/browser.ts +47 -0
- package/src/fallbacks/dekstop.ts +21 -0
- package/src/index.ts +18 -0
- package/src/libs/applications/appStore/directory.ts +235 -0
- package/src/libs/applications/appStore/remoteWatcher.ts +112 -0
- package/src/libs/applications/controller.ts +469 -0
- package/src/libs/applications/decoders.ts +98 -0
- package/src/libs/applications/defaults.ts +6 -0
- package/src/libs/applications/types.ts +98 -0
- package/src/libs/channels/controller.ts +109 -0
- package/src/libs/channels/decoders.ts +19 -0
- package/src/libs/extension/controller.ts +120 -0
- package/src/libs/extension/decoders.ts +18 -0
- package/src/libs/extension/types.ts +11 -0
- package/src/libs/intents/constants.ts +9 -0
- package/src/libs/intents/controller.ts +500 -0
- package/src/libs/intents/decoders.ts +96 -0
- package/src/libs/intents/resolverHelper.ts +264 -0
- package/src/libs/intents/types.ts +119 -0
- package/src/libs/layouts/constants.ts +3 -0
- package/src/libs/layouts/controller.ts +476 -0
- package/src/libs/layouts/decoders.ts +132 -0
- package/src/libs/layouts/global/builder.ts +400 -0
- package/src/libs/layouts/global/resetter.ts +116 -0
- package/src/libs/layouts/global/restorer.ts +217 -0
- package/src/libs/layouts/global/validator.ts +169 -0
- package/src/libs/layouts/idbStore.ts +63 -0
- package/src/libs/layouts/types.ts +133 -0
- package/src/libs/manager/controller.ts +175 -0
- package/src/libs/manager/decoders.ts +6 -0
- package/src/libs/manager/defaults.ts +5 -0
- package/src/libs/manager/identity.ts +92 -0
- package/src/libs/manager/session.ts +195 -0
- package/src/libs/manager/types.ts +51 -0
- package/src/libs/notifications/controller.ts +447 -0
- package/src/libs/notifications/decoders.ts +166 -0
- package/src/libs/notifications/types.ts +49 -0
- package/src/libs/notifications/utils.ts +7 -0
- package/src/libs/search/controller.ts +232 -0
- package/src/libs/search/decoders.ts +6 -0
- package/src/libs/search/repositories/applications.ts +62 -0
- package/src/libs/search/repositories/layouts.ts +48 -0
- package/src/libs/search/repositories/workspaces.ts +47 -0
- package/src/libs/search/types.ts +9 -0
- package/src/libs/themes/constants.ts +9 -0
- package/src/libs/themes/controller.ts +153 -0
- package/src/libs/themes/decoders.ts +28 -0
- package/src/libs/themes/types.ts +28 -0
- package/src/libs/windows/controller.ts +498 -0
- package/src/libs/windows/decoders.ts +64 -0
- package/src/libs/windows/types.ts +59 -0
- package/src/libs/workspaces/controller.ts +922 -0
- package/src/libs/workspaces/decoders.ts +868 -0
- package/src/libs/workspaces/defaultConfig.ts +11 -0
- package/src/libs/workspaces/frames.ts +239 -0
- package/src/libs/workspaces/hibernationWatcher.ts +231 -0
- package/src/libs/workspaces/types.ts +506 -0
- package/src/platform.ts +156 -0
- package/src/shared/decoders.ts +479 -0
- package/src/shared/fetchTimeout.ts +25 -0
- package/src/shared/ioc.ts +580 -0
- package/src/shared/logger.ts +19 -0
- package/src/shared/promisePlus.ts +62 -0
- package/src/shared/sequelizer.ts +48 -0
- package/src/shared/utils.ts +86 -0
- package/src/storage/local.ts +111 -0
- package/src/storage/session.ts +436 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { IOConnectBrowser } from "@interopio/browser";
|
|
3
|
+
import { IOConnectWorkspaces } from "@interopio/workspaces-api";
|
|
4
|
+
import { anyJson, array, boolean, constant, Decoder, fail, lazy, number, object, oneOf, optional, string } from "decoder-validate";
|
|
5
|
+
import { IOConnectBrowserPlatform } from "../../browser.platform";
|
|
6
|
+
import { FocusEventData, LibDomains, OperationCheckConfig, OperationCheckResult, SystemOperationTypes } from "../common/types";
|
|
7
|
+
|
|
8
|
+
export const nonNegativeNumberDecoder: Decoder<number> = number().where((num) => num >= 0, "Expected a non-negative number");
|
|
9
|
+
export const nonEmptyStringDecoder: Decoder<string> = string().where((s) => s.length > 0, "Expected a non-empty string");
|
|
10
|
+
export const anyDecoder: Decoder<unknown> = anyJson();
|
|
11
|
+
|
|
12
|
+
export const windowBoundsDecoder: Decoder<IOConnectBrowser.Windows.Bounds> = object({
|
|
13
|
+
top: number(),
|
|
14
|
+
left: number(),
|
|
15
|
+
width: nonNegativeNumberDecoder,
|
|
16
|
+
height: nonNegativeNumberDecoder
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const windowRelativeDirectionDecoder: Decoder<IOConnectBrowser.Windows.RelativeDirection> = oneOf<"top" | "left" | "right" | "bottom">(
|
|
20
|
+
constant("top"),
|
|
21
|
+
constant("left"),
|
|
22
|
+
constant("right"),
|
|
23
|
+
constant("bottom")
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const logLevelDecoder: Decoder<IOConnectBrowserPlatform.Gateway.LogLevel> = oneOf<"trace" | "debug" | "info" | "warn" | "error">(
|
|
27
|
+
constant("trace"),
|
|
28
|
+
constant("debug"),
|
|
29
|
+
constant("info"),
|
|
30
|
+
constant("warn"),
|
|
31
|
+
constant("error")
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const channelMetaDecoder: Decoder<IOConnectBrowserPlatform.Channels.ChannelMeta> = anyJson().where(
|
|
35
|
+
(meta: IOConnectBrowserPlatform.Channels.ChannelMeta) => typeof meta["color"] === "string" && meta["color"].length > 0,
|
|
36
|
+
"Expected color to be a non-empty string"
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export const layoutTypeDecoder: Decoder<IOConnectBrowser.Layouts.LayoutType> = oneOf<"Global" | "Activity" | "ApplicationDefault" | "Swimlane" | "Workspace">(
|
|
40
|
+
constant("Global"),
|
|
41
|
+
constant("Activity"),
|
|
42
|
+
constant("ApplicationDefault"),
|
|
43
|
+
constant("Swimlane"),
|
|
44
|
+
constant("Workspace")
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const componentTypeDecoder: Decoder<IOConnectBrowser.Layouts.ComponentType> = oneOf<"application" | "activity">(
|
|
48
|
+
constant("application"),
|
|
49
|
+
constant("activity")
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const functionCheck = (input: any, propDescription: string): Decoder<any> => {
|
|
53
|
+
const providedType = typeof input;
|
|
54
|
+
|
|
55
|
+
return providedType === "function" ?
|
|
56
|
+
anyJson() :
|
|
57
|
+
fail(`The provided argument as ${propDescription} should be of type function, provided: ${typeof providedType}`);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const operationCheckConfigDecoder: Decoder<OperationCheckConfig> = object({
|
|
61
|
+
operation: nonEmptyStringDecoder
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const operationCheckResultDecoder: Decoder<OperationCheckResult> = object({
|
|
65
|
+
isSupported: boolean()
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const layoutSummaryDecoder: Decoder<IOConnectBrowser.Layouts.LayoutSummary> = object({
|
|
69
|
+
name: nonEmptyStringDecoder,
|
|
70
|
+
type: layoutTypeDecoder,
|
|
71
|
+
context: optional(anyJson()),
|
|
72
|
+
metadata: optional(anyJson())
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const windowComponentStateDecoder: Decoder<IOConnectBrowser.Layouts.WindowComponentState> = object({
|
|
76
|
+
context: optional(anyJson()),
|
|
77
|
+
bounds: windowBoundsDecoder,
|
|
78
|
+
createArgs: object({
|
|
79
|
+
name: optional(nonEmptyStringDecoder),
|
|
80
|
+
url: optional(nonEmptyStringDecoder),
|
|
81
|
+
context: optional(anyJson())
|
|
82
|
+
}),
|
|
83
|
+
windowState: optional(nonEmptyStringDecoder),
|
|
84
|
+
restoreState: optional(nonEmptyStringDecoder),
|
|
85
|
+
instanceId: nonEmptyStringDecoder,
|
|
86
|
+
isCollapsed: optional(boolean()),
|
|
87
|
+
isSticky: optional(boolean()),
|
|
88
|
+
restoreSettings: object({
|
|
89
|
+
groupId: optional(nonEmptyStringDecoder),
|
|
90
|
+
groupZOrder: optional(number())
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export const windowLayoutComponentDecoder: Decoder<IOConnectBrowser.Layouts.WindowComponent> = object({
|
|
95
|
+
type: constant("window"),
|
|
96
|
+
componentType: optional(componentTypeDecoder),
|
|
97
|
+
application: nonEmptyStringDecoder,
|
|
98
|
+
state: windowComponentStateDecoder
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const libDomainDecoder: Decoder<LibDomains> = oneOf<"system" | "windows" | "appManager" | "layouts" | "workspaces" | "intents" | "notifications" | "extension" | "channels" | "search" | "themes" | "manager">(
|
|
102
|
+
constant("system"),
|
|
103
|
+
constant("windows"),
|
|
104
|
+
constant("appManager"),
|
|
105
|
+
constant("layouts"),
|
|
106
|
+
constant("workspaces"),
|
|
107
|
+
constant("intents"),
|
|
108
|
+
constant("notifications"),
|
|
109
|
+
constant("extension"),
|
|
110
|
+
constant("channels"),
|
|
111
|
+
constant("search"),
|
|
112
|
+
constant("themes"),
|
|
113
|
+
constant("manager")
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
export const systemOperationTypesDecoder: Decoder<SystemOperationTypes> = oneOf<"getEnvironment" | "getBase" | "operationCheck">(
|
|
117
|
+
constant("getEnvironment"),
|
|
118
|
+
constant("getBase"),
|
|
119
|
+
constant("operationCheck")
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
export const windowLayoutItemDecoder: Decoder<IOConnectWorkspaces.WindowLayoutItem> = object({
|
|
123
|
+
type: constant("window"),
|
|
124
|
+
config: object({
|
|
125
|
+
appName: nonEmptyStringDecoder,
|
|
126
|
+
windowId: optional(nonEmptyStringDecoder),
|
|
127
|
+
context: optional(anyJson()),
|
|
128
|
+
url: optional(nonEmptyStringDecoder),
|
|
129
|
+
title: optional(string()),
|
|
130
|
+
showCloseButton: optional(boolean()),
|
|
131
|
+
allowExtract: optional(boolean()),
|
|
132
|
+
allowReorder: optional(boolean()),
|
|
133
|
+
isMaximized: optional(boolean())
|
|
134
|
+
})
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export const groupLayoutItemDecoder: Decoder<IOConnectWorkspaces.GroupLayoutItem> = object({
|
|
138
|
+
type: constant("group"),
|
|
139
|
+
config: anyJson(),
|
|
140
|
+
children: array(oneOf<IOConnectWorkspaces.WindowLayoutItem>(
|
|
141
|
+
windowLayoutItemDecoder
|
|
142
|
+
))
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export const columnLayoutItemDecoder: Decoder<IOConnectWorkspaces.ColumnLayoutItem> = object({
|
|
146
|
+
type: constant("column"),
|
|
147
|
+
config: anyJson(),
|
|
148
|
+
children: array(oneOf<IOConnectWorkspaces.RowLayoutItem | IOConnectWorkspaces.ColumnLayoutItem | IOConnectWorkspaces.GroupLayoutItem | IOConnectWorkspaces.WindowLayoutItem>(
|
|
149
|
+
groupLayoutItemDecoder,
|
|
150
|
+
windowLayoutItemDecoder,
|
|
151
|
+
lazy(() => columnLayoutItemDecoder),
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
153
|
+
lazy(() => rowLayoutItemDecoder)
|
|
154
|
+
))
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
export const rowLayoutItemDecoder: Decoder<IOConnectWorkspaces.RowLayoutItem> = object({
|
|
158
|
+
type: constant("row"),
|
|
159
|
+
config: anyJson(),
|
|
160
|
+
children: array(oneOf<IOConnectWorkspaces.RowLayoutItem | IOConnectWorkspaces.ColumnLayoutItem | IOConnectWorkspaces.GroupLayoutItem | IOConnectWorkspaces.WindowLayoutItem>(
|
|
161
|
+
columnLayoutItemDecoder,
|
|
162
|
+
groupLayoutItemDecoder,
|
|
163
|
+
windowLayoutItemDecoder,
|
|
164
|
+
lazy(() => rowLayoutItemDecoder)
|
|
165
|
+
))
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
export const workspaceLayoutComponentStateDecoder: Decoder<IOConnectWorkspaces.WorkspaceLayoutComponentState> = object({
|
|
169
|
+
config: anyJson(),
|
|
170
|
+
context: anyJson(),
|
|
171
|
+
children: array(oneOf<IOConnectWorkspaces.RowLayoutItem | IOConnectWorkspaces.ColumnLayoutItem | IOConnectWorkspaces.GroupLayoutItem | IOConnectWorkspaces.WindowLayoutItem>(
|
|
172
|
+
rowLayoutItemDecoder,
|
|
173
|
+
columnLayoutItemDecoder,
|
|
174
|
+
groupLayoutItemDecoder,
|
|
175
|
+
windowLayoutItemDecoder
|
|
176
|
+
))
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
export const workspaceLayoutComponentDecoder: Decoder<IOConnectWorkspaces.WorkspaceComponent> = object({
|
|
180
|
+
type: constant("Workspace"),
|
|
181
|
+
application: optional(string()),
|
|
182
|
+
state: workspaceLayoutComponentStateDecoder
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
export const workspaceFrameComponentStateDecoder: Decoder<IOConnectBrowser.Layouts.WorkspaceFrameComponentState> = object({
|
|
186
|
+
bounds: windowBoundsDecoder,
|
|
187
|
+
instanceId: nonEmptyStringDecoder,
|
|
188
|
+
selectedWorkspace: nonNegativeNumberDecoder,
|
|
189
|
+
workspaces: array(workspaceLayoutComponentStateDecoder),
|
|
190
|
+
windowState: optional(nonEmptyStringDecoder),
|
|
191
|
+
restoreState: optional(nonEmptyStringDecoder),
|
|
192
|
+
context: optional(anyJson())
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
export const workspaceFrameComponentDecoder: Decoder<IOConnectBrowser.Layouts.WorkspaceFrameComponent> = object({
|
|
196
|
+
type: constant<"workspaceFrame">("workspaceFrame"),
|
|
197
|
+
application: nonEmptyStringDecoder,
|
|
198
|
+
componentType: optional(componentTypeDecoder),
|
|
199
|
+
state: workspaceFrameComponentStateDecoder
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
export const glueLayoutDecoder: Decoder<IOConnectBrowser.Layouts.Layout> = object({
|
|
203
|
+
name: nonEmptyStringDecoder,
|
|
204
|
+
type: layoutTypeDecoder,
|
|
205
|
+
components: array(oneOf<IOConnectBrowser.Layouts.WindowComponent | IOConnectBrowser.Layouts.WorkspaceFrameComponent | IOConnectWorkspaces.WorkspaceComponent>(
|
|
206
|
+
windowLayoutComponentDecoder,
|
|
207
|
+
workspaceLayoutComponentDecoder,
|
|
208
|
+
workspaceFrameComponentDecoder
|
|
209
|
+
)),
|
|
210
|
+
context: optional(anyJson()),
|
|
211
|
+
metadata: optional(anyJson()),
|
|
212
|
+
version: optional(number())
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
export const applicationDetailsDecoder: Decoder<IOConnectBrowser.AppManager.DefinitionDetails> = object({
|
|
216
|
+
url: nonEmptyStringDecoder,
|
|
217
|
+
top: optional(number()),
|
|
218
|
+
left: optional(number()),
|
|
219
|
+
width: optional(nonNegativeNumberDecoder),
|
|
220
|
+
height: optional(nonNegativeNumberDecoder)
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
export const intentDefinitionDecoder: Decoder<IOConnectBrowser.AppManager.Intent> = object({
|
|
224
|
+
name: nonEmptyStringDecoder,
|
|
225
|
+
displayName: optional(string()),
|
|
226
|
+
contexts: optional(array(string())),
|
|
227
|
+
customConfig: optional(object()),
|
|
228
|
+
resultType: optional(nonEmptyStringDecoder)
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export const glueCoreAppDefinitionDecoder: Decoder<IOConnectBrowser.AppManager.Definition> = object({
|
|
232
|
+
name: nonEmptyStringDecoder,
|
|
233
|
+
type: nonEmptyStringDecoder.where((s) => s === "window", "Expected a value of window"),
|
|
234
|
+
title: optional(nonEmptyStringDecoder),
|
|
235
|
+
version: optional(nonEmptyStringDecoder),
|
|
236
|
+
customProperties: optional(anyJson()),
|
|
237
|
+
icon: optional(string()),
|
|
238
|
+
caption: optional(string()),
|
|
239
|
+
details: applicationDetailsDecoder,
|
|
240
|
+
intents: optional(array(intentDefinitionDecoder)),
|
|
241
|
+
hidden: optional(boolean())
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// todo: remove this dirty fix once the remote app services are updated
|
|
245
|
+
export const fdc3AppDefinitionDecoder: Decoder<IOConnectBrowserPlatform.Applications.FDC3Definition> = object({
|
|
246
|
+
name: nonEmptyStringDecoder,
|
|
247
|
+
title: optional(nonEmptyStringDecoder),
|
|
248
|
+
version: optional(nonEmptyStringDecoder),
|
|
249
|
+
appId: optional(nonEmptyStringDecoder),
|
|
250
|
+
manifest: nonEmptyStringDecoder,
|
|
251
|
+
manifestType: nonEmptyStringDecoder,
|
|
252
|
+
tooltip: optional(nonEmptyStringDecoder),
|
|
253
|
+
description: optional(nonEmptyStringDecoder),
|
|
254
|
+
contactEmail: optional(nonEmptyStringDecoder),
|
|
255
|
+
supportEmail: optional(nonEmptyStringDecoder),
|
|
256
|
+
publisher: optional(nonEmptyStringDecoder),
|
|
257
|
+
images: optional(array(object({ url: optional(nonEmptyStringDecoder) }))),
|
|
258
|
+
icons: optional(array(object({ icon: optional(nonEmptyStringDecoder) }))),
|
|
259
|
+
customConfig: anyJson(),
|
|
260
|
+
intents: optional(array(intentDefinitionDecoder))
|
|
261
|
+
}) as Decoder<IOConnectBrowserPlatform.Applications.FDC3Definition>;
|
|
262
|
+
|
|
263
|
+
export const remoteStoreDecoder: Decoder<IOConnectBrowserPlatform.RemoteStore> = object({
|
|
264
|
+
url: nonEmptyStringDecoder,
|
|
265
|
+
pollingInterval: optional(nonNegativeNumberDecoder),
|
|
266
|
+
requestTimeout: optional(nonNegativeNumberDecoder),
|
|
267
|
+
customHeaders: optional(anyJson())
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
export const supplierDecoder: Decoder<IOConnectBrowserPlatform.Supplier<any>> = object({
|
|
271
|
+
fetch: anyJson().andThen((result) => functionCheck(result, "supplier fetch")),
|
|
272
|
+
timeout: optional(nonNegativeNumberDecoder),
|
|
273
|
+
pollingInterval: optional(nonNegativeNumberDecoder),
|
|
274
|
+
save: optional(anyJson().andThen((result) => functionCheck(result, "supplier save"))),
|
|
275
|
+
delete: optional(anyJson().andThen((result) => functionCheck(result, "supplier delete")))
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
export const channelDefinitionDecoder: Decoder<IOConnectBrowserPlatform.Channels.ChannelDefinition> = object({
|
|
279
|
+
name: nonEmptyStringDecoder,
|
|
280
|
+
meta: channelMetaDecoder,
|
|
281
|
+
data: optional(anyJson())
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
export const pluginDefinitionDecoder: Decoder<IOConnectBrowserPlatform.Plugins.PluginDefinition> = object({
|
|
285
|
+
name: nonEmptyStringDecoder,
|
|
286
|
+
start: anyJson(),
|
|
287
|
+
stop: optional(anyJson()),
|
|
288
|
+
version: optional(nonEmptyStringDecoder),
|
|
289
|
+
config: optional(anyJson()),
|
|
290
|
+
critical: optional(boolean())
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
export const allApplicationDefinitionsDecoder: Decoder<IOConnectBrowser.AppManager.Definition | IOConnectBrowserPlatform.Applications.FDC3Definition> = oneOf<IOConnectBrowser.AppManager.Definition | IOConnectBrowserPlatform.Applications.FDC3Definition>(
|
|
294
|
+
glueCoreAppDefinitionDecoder,
|
|
295
|
+
fdc3AppDefinitionDecoder
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
export const appsCollectionDecoder: Decoder<Array<IOConnectBrowser.AppManager.Definition | IOConnectBrowserPlatform.Applications.FDC3Definition>> = array(allApplicationDefinitionsDecoder);
|
|
299
|
+
|
|
300
|
+
export const applicationsConfigDecoder: Decoder<IOConnectBrowserPlatform.Applications.Config> = object({
|
|
301
|
+
local: optional(array(allApplicationDefinitionsDecoder)),
|
|
302
|
+
remote: optional(remoteStoreDecoder)
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
export const layoutsConfigDecoder: Decoder<IOConnectBrowserPlatform.Layouts.Config> = object({
|
|
306
|
+
mode: optional(oneOf<"idb" | "session">(
|
|
307
|
+
constant("idb"),
|
|
308
|
+
constant("session")
|
|
309
|
+
)),
|
|
310
|
+
local: optional(array(glueLayoutDecoder))
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
export const channelsConfigDecoder: Decoder<IOConnectBrowserPlatform.Channels.Config> = object({
|
|
314
|
+
definitions: array(channelDefinitionDecoder)
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
export const pluginsConfigDecoder: Decoder<IOConnectBrowserPlatform.Plugins.Config> = object({
|
|
318
|
+
definitions: array(pluginDefinitionDecoder)
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
export const gatewayConfigDecoder: Decoder<IOConnectBrowserPlatform.Gateway.Config> = object({
|
|
322
|
+
logging: optional(object({
|
|
323
|
+
level: optional(logLevelDecoder),
|
|
324
|
+
appender: optional(anyJson().andThen((result) => functionCheck(result, "gateway log appender")))
|
|
325
|
+
})),
|
|
326
|
+
clients: optional(object({
|
|
327
|
+
buffer_size: optional(number())
|
|
328
|
+
}))
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// todo: proper implement when the config has been finalized
|
|
332
|
+
export const glueConfigDecoder: Decoder<IOConnectBrowser.Config> = anyJson();
|
|
333
|
+
|
|
334
|
+
export const maximumActiveWorkspacesDecoder: Decoder<IOConnectBrowserPlatform.Workspaces.MaximumActiveWorkspacesRule> = object({
|
|
335
|
+
threshold: number().where((num) => num > 1, "Expected a number larger than 1")
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
export const idleWorkspacesDecoder: Decoder<IOConnectBrowserPlatform.Workspaces.IdleWorkspacesRule> = object({
|
|
339
|
+
idleMSThreshold: number().where((num) => num > 100, "Expected a number larger than 100")
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
export const hibernationConfigDecoder: Decoder<IOConnectBrowserPlatform.Workspaces.HibernationConfig> = object({
|
|
343
|
+
maximumActiveWorkspaces: optional(maximumActiveWorkspacesDecoder),
|
|
344
|
+
idleWorkspaces: optional(idleWorkspacesDecoder)
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
export const loadingConfigDecoder: Decoder<IOConnectBrowserPlatform.Workspaces.LoadingConfig> = object({
|
|
348
|
+
delayed: optional(object({
|
|
349
|
+
batch: optional(number()),
|
|
350
|
+
initialOffsetInterval: optional(number()),
|
|
351
|
+
interval: optional(number())
|
|
352
|
+
})),
|
|
353
|
+
defaultStrategy: optional(oneOf(constant("direct"), constant("delayed"), constant("lazy"))),
|
|
354
|
+
showDelayedIndicator: optional(boolean())
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
export const workspacesConfigDecoder: Decoder<IOConnectBrowserPlatform.Workspaces.Config> = object({
|
|
358
|
+
src: nonEmptyStringDecoder,
|
|
359
|
+
hibernation: optional(hibernationConfigDecoder),
|
|
360
|
+
loadingStrategy: optional(loadingConfigDecoder),
|
|
361
|
+
isFrame: optional(boolean()),
|
|
362
|
+
initAsEmpty: optional(boolean()),
|
|
363
|
+
frameCache: optional(boolean())
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
export const preferredConnectionSettingsDecoder: Decoder<IOConnectBrowserPlatform.Connection.PreferredConnectionSettings> = object({
|
|
367
|
+
url: nonEmptyStringDecoder,
|
|
368
|
+
auth: optional(object({
|
|
369
|
+
username: optional(nonEmptyStringDecoder),
|
|
370
|
+
password: optional(nonEmptyStringDecoder),
|
|
371
|
+
sessionId: optional(nonEmptyStringDecoder),
|
|
372
|
+
provider: optional(nonEmptyStringDecoder),
|
|
373
|
+
providerContext: optional(anyJson()),
|
|
374
|
+
token: optional(nonEmptyStringDecoder),
|
|
375
|
+
gatewayToken: optional(nonEmptyStringDecoder),
|
|
376
|
+
flowName: optional(constant<"sspi">("sspi")),
|
|
377
|
+
flowCallback: optional(anyJson().andThen((result) => functionCheck(result, "flowCallback function")))
|
|
378
|
+
})),
|
|
379
|
+
forceIncompleteSwitch: optional(boolean()),
|
|
380
|
+
discoveryIntervalMS: optional(nonNegativeNumberDecoder)
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
export const connectionConfigDecoder: Decoder<IOConnectBrowserPlatform.Connection.Config> = object({
|
|
384
|
+
preferred: optional(preferredConnectionSettingsDecoder),
|
|
385
|
+
enableManualSwitching: optional(boolean()),
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
export const windowsConfigDecoder: Decoder<IOConnectBrowserPlatform.Windows.Config> = object({
|
|
389
|
+
windowResponseTimeoutMs: optional(nonNegativeNumberDecoder),
|
|
390
|
+
defaultWindowOpenBounds: optional(windowBoundsDecoder)
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
export const serviceWorkerConfigDecoder: Decoder<IOConnectBrowserPlatform.ServiceWorker.Config> = object({
|
|
394
|
+
url: optional(nonEmptyStringDecoder),
|
|
395
|
+
registrationPromise: optional(anyJson())
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
export const notificationsConfigDecoder: Decoder<IOConnectBrowserPlatform.Notifications.Config> = object({
|
|
399
|
+
enable: optional(boolean()),
|
|
400
|
+
enableToasts: optional(boolean()),
|
|
401
|
+
clearNotificationOnClick: optional(boolean())
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
export const themesConfigDecoder: Decoder<IOConnectBrowserPlatform.Themes.Config> = object({
|
|
405
|
+
defaultTheme: optional(oneOf< "os" | "light" | "dark">(
|
|
406
|
+
constant("os"),
|
|
407
|
+
constant("light"),
|
|
408
|
+
constant("dark")
|
|
409
|
+
))
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
export const userConfigDecoder: Decoder<IOConnectBrowserPlatform.User.Config> = object({
|
|
413
|
+
username: nonEmptyStringDecoder
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
export const managerAuthConfig: Decoder<IOConnectBrowserPlatform.Manager.AuthConfig> = object({
|
|
417
|
+
basic: optional(object({
|
|
418
|
+
username: nonEmptyStringDecoder,
|
|
419
|
+
password: nonEmptyStringDecoder
|
|
420
|
+
})),
|
|
421
|
+
username: optional(nonEmptyStringDecoder),
|
|
422
|
+
token: optional(object({
|
|
423
|
+
bearer: optional(nonEmptyStringDecoder)
|
|
424
|
+
})),
|
|
425
|
+
includeCredentials: optional(boolean())
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
export const managerConfigDecoder: Decoder<IOConnectBrowserPlatform.Manager.Config> = object({
|
|
429
|
+
url: nonEmptyStringDecoder,
|
|
430
|
+
auth: managerAuthConfig,
|
|
431
|
+
critical: optional(boolean()),
|
|
432
|
+
headers: optional(anyJson()),
|
|
433
|
+
fetchIntervalMS: optional(nonNegativeNumberDecoder),
|
|
434
|
+
tokenRefreshIntervalMS: optional(nonNegativeNumberDecoder)
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
export const platformConfigDecoder: Decoder<IOConnectBrowserPlatform.Config> = object({
|
|
438
|
+
licenseKey: nonEmptyStringDecoder,
|
|
439
|
+
windows: optional(windowsConfigDecoder),
|
|
440
|
+
applications: optional(applicationsConfigDecoder),
|
|
441
|
+
notifications: optional(notificationsConfigDecoder),
|
|
442
|
+
layouts: optional(layoutsConfigDecoder),
|
|
443
|
+
channels: optional(channelsConfigDecoder),
|
|
444
|
+
plugins: optional(pluginsConfigDecoder),
|
|
445
|
+
serviceWorker: optional(serviceWorkerConfigDecoder),
|
|
446
|
+
gateway: optional(gatewayConfigDecoder),
|
|
447
|
+
connection: optional(connectionConfigDecoder),
|
|
448
|
+
browser: optional(glueConfigDecoder),
|
|
449
|
+
workspaces: optional(workspacesConfigDecoder),
|
|
450
|
+
environment: optional(anyJson()),
|
|
451
|
+
themes: optional(themesConfigDecoder),
|
|
452
|
+
manager: optional(managerConfigDecoder),
|
|
453
|
+
browserFactory: optional(anyJson().andThen((result) => functionCheck(result, "glueFactory")))
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
export const windowOpenSettingsDecoder: Decoder<IOConnectBrowser.Windows.Settings> = object({
|
|
457
|
+
top: optional(number()),
|
|
458
|
+
left: optional(number()),
|
|
459
|
+
width: optional(nonNegativeNumberDecoder),
|
|
460
|
+
height: optional(nonNegativeNumberDecoder),
|
|
461
|
+
context: optional(anyJson()),
|
|
462
|
+
relativeTo: optional(nonEmptyStringDecoder),
|
|
463
|
+
relativeDirection: optional(windowRelativeDirectionDecoder),
|
|
464
|
+
windowId: optional(nonEmptyStringDecoder),
|
|
465
|
+
layoutComponentId: optional(nonEmptyStringDecoder)
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
export const interceptorRegistrationRequestDecoder: Decoder<IOConnectBrowserPlatform.Plugins.InterceptorRegistrationRequest> = object({
|
|
469
|
+
callInterceptor: anyJson().andThen((result) => functionCheck(result, "callInterceptor")),
|
|
470
|
+
interceptions: array(object({
|
|
471
|
+
domain: libDomainDecoder,
|
|
472
|
+
operation: nonEmptyStringDecoder
|
|
473
|
+
}))
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
export const focusEventDataDecoder: Decoder<FocusEventData> = object({
|
|
477
|
+
windowId: nonEmptyStringDecoder,
|
|
478
|
+
hasFocus: boolean()
|
|
479
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defaultFetchTimeoutMs } from "../common/defaultConfig";
|
|
2
|
+
|
|
3
|
+
export const fetchTimeout = (request: string | Request, timeoutMilliseconds = defaultFetchTimeoutMs): Promise<Response> => {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
let timeoutHit = false;
|
|
6
|
+
const timeout = setTimeout(() => {
|
|
7
|
+
timeoutHit = true;
|
|
8
|
+
reject(new Error(`Fetch request for: ${JSON.stringify(request)} timed out at: ${timeoutMilliseconds} milliseconds`));
|
|
9
|
+
}, timeoutMilliseconds);
|
|
10
|
+
|
|
11
|
+
fetch(request)
|
|
12
|
+
.then((response) => {
|
|
13
|
+
if (!timeoutHit) {
|
|
14
|
+
clearTimeout(timeout);
|
|
15
|
+
resolve(response);
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
.catch((err) => {
|
|
19
|
+
if (!timeoutHit) {
|
|
20
|
+
clearTimeout(timeout);
|
|
21
|
+
reject(err);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
};
|