@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,580 @@
|
|
|
1
|
+
import {
|
|
2
|
+
default as CallbackRegistryFactory
|
|
3
|
+
} from "callback-registry";
|
|
4
|
+
import { ClientAPI } from "@glue42/server-api/dist/client";
|
|
5
|
+
import { UAParser } from "ua-parser-js";
|
|
6
|
+
import { ClientOptions } from "@glue42/server-api/dist/client-api/options";
|
|
7
|
+
import { IOConnectBrowserPlatform } from "../../browser.platform";
|
|
8
|
+
import { Gateway } from "../connection/gateway";
|
|
9
|
+
import { PlatformController } from "../controllers/main";
|
|
10
|
+
import { Platform } from "../platform";
|
|
11
|
+
import { GlueController } from "../controllers/glue";
|
|
12
|
+
import { PortsBridge } from "../connection/portsBridge";
|
|
13
|
+
import { WindowsController } from "../libs/windows/controller";
|
|
14
|
+
import { SessionStorageController } from "../storage/session";
|
|
15
|
+
import { WindowsStateController } from "../controllers/state";
|
|
16
|
+
import { ApplicationsController } from "../libs/applications/controller";
|
|
17
|
+
import { LayoutsController } from "../libs/layouts/controller";
|
|
18
|
+
import { IdbLayoutsStore } from "../libs/layouts/idbStore";
|
|
19
|
+
import { WorkspacesController } from "../libs/workspaces/controller";
|
|
20
|
+
import { IntentsController } from "../libs/intents/controller";
|
|
21
|
+
import { ChannelsController } from "../libs/channels/controller";
|
|
22
|
+
import { FramesController } from "../libs/workspaces/frames";
|
|
23
|
+
import { WorkspaceHibernationWatcher } from "../libs/workspaces/hibernationWatcher";
|
|
24
|
+
import { SystemController } from "../controllers/system";
|
|
25
|
+
import { AppDirectory } from "../libs/applications/appStore/directory";
|
|
26
|
+
import { RemoteWatcher } from "../libs/applications/appStore/remoteWatcher";
|
|
27
|
+
import { ServiceWorkerController } from "../controllers/serviceWorker";
|
|
28
|
+
import { NotificationsController } from "../libs/notifications/controller";
|
|
29
|
+
import { ExtensionController } from "../libs/extension/controller";
|
|
30
|
+
import { AsyncSequelizer } from "./sequelizer";
|
|
31
|
+
import { PreferredConnectionController } from "../connection/preferred";
|
|
32
|
+
import { Glue42CoreDB } from "../common/types";
|
|
33
|
+
import { IDBPDatabase, openDB } from "idb";
|
|
34
|
+
import { dbName, dbVersion } from "../common/constants";
|
|
35
|
+
import { TransactionsController } from "../controllers/transactions";
|
|
36
|
+
import { InterceptionController } from "../controllers/interception";
|
|
37
|
+
import { PluginsController } from "../controllers/plugins";
|
|
38
|
+
import { DomainsController } from "../controllers/domains";
|
|
39
|
+
import { IntentsResolverHelper } from "../libs/intents/resolverHelper";
|
|
40
|
+
import { LicenseController } from "../controllers/license";
|
|
41
|
+
import { Builder } from "../libs/layouts/global/builder";
|
|
42
|
+
import { Restorer } from "../libs/layouts/global/restorer";
|
|
43
|
+
import { LayoutValidator } from "../libs/layouts/global/validator";
|
|
44
|
+
import { Resetter } from "../libs/layouts/global/resetter";
|
|
45
|
+
import { SearchController } from "../libs/search/controller";
|
|
46
|
+
import { ApplicationsRepository } from "../libs/search/repositories/applications";
|
|
47
|
+
import { LayoutsRepository } from "../libs/search/repositories/layouts";
|
|
48
|
+
import { WorkspacesRepository } from "../libs/search/repositories/workspaces";
|
|
49
|
+
import { LocalStoreController } from "../storage/local";
|
|
50
|
+
import { ThemesController } from "../libs/themes/controller";
|
|
51
|
+
import { ManagerController } from "../libs/manager/controller";
|
|
52
|
+
import { Identity } from "../libs/manager/identity";
|
|
53
|
+
import { Session } from "../libs/manager/session";
|
|
54
|
+
|
|
55
|
+
export class IoC {
|
|
56
|
+
private _gatewayInstance!: Gateway;
|
|
57
|
+
private _platformInstance!: Platform;
|
|
58
|
+
private _mainController!: PlatformController;
|
|
59
|
+
private _glueController!: GlueController;
|
|
60
|
+
private _portsBridge!: PortsBridge;
|
|
61
|
+
private _windowsController!: WindowsController;
|
|
62
|
+
private _applicationsController!: ApplicationsController;
|
|
63
|
+
private _appDirectory!: AppDirectory;
|
|
64
|
+
private _remoteWatcher!: RemoteWatcher;
|
|
65
|
+
private _layoutsController!: LayoutsController;
|
|
66
|
+
private _workspacesController!: WorkspacesController;
|
|
67
|
+
private _hibernationWatcher!: WorkspaceHibernationWatcher;
|
|
68
|
+
private _intentsController!: IntentsController;
|
|
69
|
+
private _intentsResolverController!: IntentsResolverHelper;
|
|
70
|
+
private _channelsController!: ChannelsController;
|
|
71
|
+
private _notificationsController!: NotificationsController;
|
|
72
|
+
private _extensionController!: ExtensionController;
|
|
73
|
+
private _sessionController!: SessionStorageController;
|
|
74
|
+
private _localStorageController!: LocalStoreController;
|
|
75
|
+
private _stateChecker!: WindowsStateController;
|
|
76
|
+
private _framesController!: FramesController;
|
|
77
|
+
private _systemController!: SystemController;
|
|
78
|
+
private _idbStore!: IdbLayoutsStore;
|
|
79
|
+
private _serviceWorkerController!: ServiceWorkerController;
|
|
80
|
+
private _preferredConnectionController!: PreferredConnectionController;
|
|
81
|
+
private _database!: IDBPDatabase<Glue42CoreDB> | undefined;
|
|
82
|
+
private _transactionsController!: TransactionsController;
|
|
83
|
+
private _interceptionController!: InterceptionController;
|
|
84
|
+
private _pluginsController!: PluginsController;
|
|
85
|
+
private _domainsController!: DomainsController;
|
|
86
|
+
private _licenseController!: LicenseController;
|
|
87
|
+
private _layoutsBuilder!: Builder;
|
|
88
|
+
private _layoutsRestorer!: Restorer;
|
|
89
|
+
private _layoutsValidator!: LayoutValidator;
|
|
90
|
+
private _layoutsResetter!: Resetter;
|
|
91
|
+
private _searchController!: SearchController;
|
|
92
|
+
private _appsSearchRepo!: ApplicationsRepository;
|
|
93
|
+
private _layoutsSearchRepo!: LayoutsRepository;
|
|
94
|
+
private _workspacesSearchRepo!: WorkspacesRepository;
|
|
95
|
+
private _themesController!: ThemesController;
|
|
96
|
+
private _managerController!: ManagerController;
|
|
97
|
+
private _managerIdentity!: Identity;
|
|
98
|
+
private _managerSession!: Session;
|
|
99
|
+
|
|
100
|
+
constructor(private readonly config?: IOConnectBrowserPlatform.Config) {}
|
|
101
|
+
|
|
102
|
+
public get gateway(): Gateway {
|
|
103
|
+
if (!this._gatewayInstance) {
|
|
104
|
+
this._gatewayInstance = new Gateway();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return this._gatewayInstance;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public get platform(): Platform {
|
|
111
|
+
if (!this._platformInstance) {
|
|
112
|
+
this._platformInstance = new Platform(this.controller, this.sessionController, this.config);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return this._platformInstance;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public get domainsController(): DomainsController {
|
|
119
|
+
if (!this._domainsController) {
|
|
120
|
+
this._domainsController = new DomainsController(
|
|
121
|
+
this.systemController,
|
|
122
|
+
this.windowsController,
|
|
123
|
+
this.applicationsController,
|
|
124
|
+
this.layoutsController,
|
|
125
|
+
this.workspacesController,
|
|
126
|
+
this.intentsController,
|
|
127
|
+
this.channelsController,
|
|
128
|
+
this.notificationsController,
|
|
129
|
+
this.extensionController,
|
|
130
|
+
this.searchController,
|
|
131
|
+
this.themesController,
|
|
132
|
+
this.managerController
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return this._domainsController;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
public get controller(): PlatformController {
|
|
141
|
+
if (!this._mainController) {
|
|
142
|
+
this._mainController = new PlatformController(
|
|
143
|
+
this.domainsController,
|
|
144
|
+
this.glueController,
|
|
145
|
+
this.portsBridge,
|
|
146
|
+
this.stateController,
|
|
147
|
+
this.serviceWorkerController,
|
|
148
|
+
this.preferredConnectionController,
|
|
149
|
+
this.interceptionController,
|
|
150
|
+
this.pluginsController,
|
|
151
|
+
this.sessionController,
|
|
152
|
+
this.licenseController,
|
|
153
|
+
this.localStorageController
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return this._mainController;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public get glueController(): GlueController {
|
|
161
|
+
if (!this._glueController) {
|
|
162
|
+
this._glueController = new GlueController(this.portsBridge, this.sessionController);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return this._glueController;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public get systemController(): SystemController {
|
|
169
|
+
if (!this._systemController) {
|
|
170
|
+
this._systemController = new SystemController(this.sessionController);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return this._systemController;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public get searchController(): SearchController {
|
|
177
|
+
if (!this._searchController) {
|
|
178
|
+
this._searchController = new SearchController(
|
|
179
|
+
this.glueController,
|
|
180
|
+
this.appsSearchRepo,
|
|
181
|
+
this.layoutsSearchRepo,
|
|
182
|
+
this.workspacesSearchRepo
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return this._searchController;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public get themesController(): ThemesController {
|
|
190
|
+
if (!this._themesController) {
|
|
191
|
+
this._themesController = new ThemesController(
|
|
192
|
+
this.glueController,
|
|
193
|
+
this.localStorageController
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return this._themesController;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public get sessionController(): SessionStorageController {
|
|
201
|
+
if (!this._sessionController) {
|
|
202
|
+
this._sessionController = new SessionStorageController();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return this._sessionController;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public get localStorageController(): LocalStoreController {
|
|
209
|
+
if (!this._localStorageController) {
|
|
210
|
+
this._localStorageController = new LocalStoreController();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return this._localStorageController;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public get stateController(): WindowsStateController {
|
|
217
|
+
if (!this._stateChecker) {
|
|
218
|
+
this._stateChecker = new WindowsStateController(this.sessionController);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return this._stateChecker;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public get windowsController(): WindowsController {
|
|
225
|
+
if (!this._windowsController) {
|
|
226
|
+
this._windowsController = new WindowsController(this.glueController, this.sessionController, this.stateController, this);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return this._windowsController;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public get applicationsController(): ApplicationsController {
|
|
233
|
+
if (!this._applicationsController) {
|
|
234
|
+
this._applicationsController = new ApplicationsController(
|
|
235
|
+
this.glueController,
|
|
236
|
+
this.sessionController,
|
|
237
|
+
this.stateController,
|
|
238
|
+
this.appDirectory,
|
|
239
|
+
this
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return this._applicationsController;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
public get appDirectory(): AppDirectory {
|
|
247
|
+
if (!this._appDirectory) {
|
|
248
|
+
this._appDirectory = new AppDirectory(
|
|
249
|
+
this.sessionController,
|
|
250
|
+
this.remoteWatcher
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return this._appDirectory;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public get remoteWatcher(): RemoteWatcher {
|
|
258
|
+
if (!this._remoteWatcher) {
|
|
259
|
+
this._remoteWatcher = new RemoteWatcher();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return this._remoteWatcher;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
public get licenseController(): LicenseController {
|
|
266
|
+
if (!this._licenseController) {
|
|
267
|
+
this._licenseController = new LicenseController();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return this._licenseController;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
public get layoutsController(): LayoutsController {
|
|
275
|
+
if (!this._layoutsController) {
|
|
276
|
+
this._layoutsController = new LayoutsController(
|
|
277
|
+
this.glueController,
|
|
278
|
+
this.idbStore,
|
|
279
|
+
this.sessionController,
|
|
280
|
+
this.localStorageController,
|
|
281
|
+
this.layoutsBuilder,
|
|
282
|
+
this.layoutsRestorer,
|
|
283
|
+
CallbackRegistryFactory()
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return this._layoutsController;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
public get workspacesController(): WorkspacesController {
|
|
291
|
+
if (!this._workspacesController) {
|
|
292
|
+
this._workspacesController = new WorkspacesController(
|
|
293
|
+
this.framesController,
|
|
294
|
+
this.glueController,
|
|
295
|
+
this.stateController,
|
|
296
|
+
this.hibernationWatcher,
|
|
297
|
+
this
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return this._workspacesController;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
public get hibernationWatcher(): WorkspaceHibernationWatcher {
|
|
305
|
+
if (!this._hibernationWatcher) {
|
|
306
|
+
this._hibernationWatcher = new WorkspaceHibernationWatcher(this.sessionController, this.createSequelizer());
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return this._hibernationWatcher;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
public get intentsController(): IntentsController {
|
|
313
|
+
if (!this._intentsController) {
|
|
314
|
+
this._intentsController = new IntentsController(
|
|
315
|
+
this.glueController,
|
|
316
|
+
this.intentsResolverHelper,
|
|
317
|
+
this.appDirectory,
|
|
318
|
+
this
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return this._intentsController;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
public get intentsResolverHelper(): IntentsResolverHelper {
|
|
326
|
+
if (!this._intentsResolverController) {
|
|
327
|
+
this._intentsResolverController = new IntentsResolverHelper(this.glueController, this.workspacesController, this.windowsController);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return this._intentsResolverController;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
public get channelsController(): ChannelsController {
|
|
334
|
+
if (!this._channelsController) {
|
|
335
|
+
this._channelsController = new ChannelsController(
|
|
336
|
+
this.glueController
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return this._channelsController;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
public get extensionController(): ExtensionController {
|
|
344
|
+
if (!this._extensionController) {
|
|
345
|
+
this._extensionController = new ExtensionController(this.sessionController);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return this._extensionController;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
public get layoutsBuilder(): Builder {
|
|
352
|
+
if (!this._layoutsBuilder) {
|
|
353
|
+
this._layoutsBuilder = new Builder(
|
|
354
|
+
this.glueController,
|
|
355
|
+
this.sessionController,
|
|
356
|
+
this.windowsController,
|
|
357
|
+
this.workspacesController
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return this._layoutsBuilder;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
public get layoutsRestorer(): Restorer {
|
|
365
|
+
if (!this._layoutsRestorer) {
|
|
366
|
+
this._layoutsRestorer = new Restorer(
|
|
367
|
+
this.glueController,
|
|
368
|
+
this.layoutsValidator,
|
|
369
|
+
this.layoutsResetter,
|
|
370
|
+
this.workspacesController
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return this._layoutsRestorer;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
public get layoutsValidator(): LayoutValidator {
|
|
378
|
+
if (!this._layoutsValidator) {
|
|
379
|
+
this._layoutsValidator = new LayoutValidator(
|
|
380
|
+
this.glueController,
|
|
381
|
+
this.workspacesController
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return this._layoutsValidator;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
public get layoutsResetter(): Resetter {
|
|
389
|
+
if (!this._layoutsResetter) {
|
|
390
|
+
this._layoutsResetter = new Resetter(
|
|
391
|
+
this.glueController,
|
|
392
|
+
this.workspacesController
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return this._layoutsResetter;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
public get notificationsController(): NotificationsController {
|
|
400
|
+
if (!this._notificationsController) {
|
|
401
|
+
this._notificationsController = new NotificationsController(
|
|
402
|
+
this.glueController,
|
|
403
|
+
this.serviceWorkerController,
|
|
404
|
+
this.sessionController
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return this._notificationsController;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
public get framesController(): FramesController {
|
|
412
|
+
if (!this._framesController) {
|
|
413
|
+
this._framesController = new FramesController(
|
|
414
|
+
this.sessionController,
|
|
415
|
+
this.glueController,
|
|
416
|
+
this
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return this._framesController;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
public get idbStore(): IdbLayoutsStore {
|
|
424
|
+
if (!this._idbStore) {
|
|
425
|
+
this._idbStore = new IdbLayoutsStore(this);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return this._idbStore;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
public get portsBridge(): PortsBridge {
|
|
432
|
+
if (!this._portsBridge) {
|
|
433
|
+
this._portsBridge = new PortsBridge(this.gateway, this.sessionController, this);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return this._portsBridge;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
public get serviceWorkerController(): ServiceWorkerController {
|
|
440
|
+
if (!this._serviceWorkerController) {
|
|
441
|
+
this._serviceWorkerController = new ServiceWorkerController(this);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return this._serviceWorkerController;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
public get transactionsController(): TransactionsController {
|
|
448
|
+
if (!this._transactionsController) {
|
|
449
|
+
this._transactionsController = new TransactionsController();
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return this._transactionsController;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
public get interceptionController(): InterceptionController {
|
|
456
|
+
if (!this._interceptionController) {
|
|
457
|
+
this._interceptionController = new InterceptionController();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return this._interceptionController;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
public get pluginsController(): PluginsController {
|
|
464
|
+
if (!this._pluginsController) {
|
|
465
|
+
this._pluginsController = new PluginsController(this.interceptionController, this.glueController);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return this._pluginsController;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
public get appsSearchRepo(): ApplicationsRepository {
|
|
472
|
+
if (!this._appsSearchRepo) {
|
|
473
|
+
this._appsSearchRepo = new ApplicationsRepository(this.glueController);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return this._appsSearchRepo;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
public get managerController(): ManagerController {
|
|
480
|
+
if (!this._managerController) {
|
|
481
|
+
this._managerController = new ManagerController(
|
|
482
|
+
this.layoutsController,
|
|
483
|
+
this.managerIdentity,
|
|
484
|
+
this.managerSession,
|
|
485
|
+
this.buildClient.bind(this)
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return this._managerController;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
public get managerIdentity(): Identity {
|
|
493
|
+
if (!this._managerIdentity) {
|
|
494
|
+
this._managerIdentity = new Identity(
|
|
495
|
+
new UAParser(),
|
|
496
|
+
this.glueController,
|
|
497
|
+
this.pluginsController,
|
|
498
|
+
this.config?.workspaces?.src
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return this._managerIdentity;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
public get managerSession(): Session {
|
|
506
|
+
if (!this._managerSession) {
|
|
507
|
+
this._managerSession = new Session(
|
|
508
|
+
this.glueController,
|
|
509
|
+
this.layoutsController
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return this._managerSession;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
public get layoutsSearchRepo(): LayoutsRepository {
|
|
517
|
+
if (!this._layoutsSearchRepo) {
|
|
518
|
+
this._layoutsSearchRepo = new LayoutsRepository(this.glueController);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return this._layoutsSearchRepo;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
public get workspacesSearchRepo(): WorkspacesRepository {
|
|
525
|
+
if (!this._workspacesSearchRepo) {
|
|
526
|
+
this._workspacesSearchRepo = new WorkspacesRepository(this.glueController);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return this._workspacesSearchRepo;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
public getDatabase(): Promise<IDBPDatabase<Glue42CoreDB>> {
|
|
533
|
+
if (this._database) {
|
|
534
|
+
return Promise.resolve(this._database);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return new Promise((resolve) => {
|
|
538
|
+
|
|
539
|
+
openDB<Glue42CoreDB>(dbName, dbVersion, { upgrade: this.setUpDb.bind(this) })
|
|
540
|
+
.then((database) => {
|
|
541
|
+
this._database = database;
|
|
542
|
+
resolve(this._database);
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
public get preferredConnectionController(): PreferredConnectionController {
|
|
548
|
+
if (!this._preferredConnectionController) {
|
|
549
|
+
this._preferredConnectionController = new PreferredConnectionController(this.glueController, this.portsBridge, this.createSequelizer());
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return this._preferredConnectionController;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
public createMessageChannel(): MessageChannel {
|
|
556
|
+
return new MessageChannel();
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
public createSequelizer(looseInterval?: number): AsyncSequelizer {
|
|
560
|
+
return new AsyncSequelizer(looseInterval);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
public buildClient(clientOptions: ClientOptions): ClientAPI {
|
|
564
|
+
return new ClientAPI(clientOptions);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
private setUpDb(database: IDBPDatabase<Glue42CoreDB>): void {
|
|
568
|
+
if (!database.objectStoreNames.contains("workspaceLayouts" as never)) {
|
|
569
|
+
database.createObjectStore("workspaceLayouts" as never);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (!database.objectStoreNames.contains("globalLayouts" as never)) {
|
|
573
|
+
database.createObjectStore("globalLayouts" as never);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if (!database.objectStoreNames.contains("serviceWorker" as never)) {
|
|
577
|
+
database.createObjectStore("serviceWorker" as never);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IOConnectCore } from "@interopio/core";
|
|
2
|
+
|
|
3
|
+
class PlatformLogger {
|
|
4
|
+
|
|
5
|
+
private _logger: IOConnectCore.Logger.API | undefined;
|
|
6
|
+
|
|
7
|
+
public setLogger(logger: IOConnectCore.Logger.API): void {
|
|
8
|
+
this._logger = logger;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public get(subSystem: string): IOConnectCore.Logger.API | undefined {
|
|
12
|
+
if (!this._logger) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return this._logger.subLogger(subSystem);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default new PlatformLogger();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
export const PromiseWrap = <T>(promise: () => Promise<T>, timeoutMilliseconds: number, timeoutMessage?: string): Promise<T> => {
|
|
4
|
+
return new Promise<T>((resolve, reject) => {
|
|
5
|
+
|
|
6
|
+
let promiseActive = true;
|
|
7
|
+
|
|
8
|
+
const timeout = setTimeout(() => {
|
|
9
|
+
if (!promiseActive) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
promiseActive = false;
|
|
13
|
+
const message = timeoutMessage || `Promise timeout hit: ${timeoutMilliseconds}`;
|
|
14
|
+
|
|
15
|
+
reject(message);
|
|
16
|
+
}, timeoutMilliseconds);
|
|
17
|
+
|
|
18
|
+
promise()
|
|
19
|
+
.then((result) => {
|
|
20
|
+
if (!promiseActive) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
promiseActive = false;
|
|
24
|
+
clearTimeout(timeout);
|
|
25
|
+
resolve(result);
|
|
26
|
+
})
|
|
27
|
+
.catch((error) => {
|
|
28
|
+
if (!promiseActive) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
promiseActive = false;
|
|
32
|
+
clearTimeout(timeout);
|
|
33
|
+
|
|
34
|
+
reject(error);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const PromisePlus = <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void, timeoutMilliseconds: number, timeoutMessage?: string): Promise<T> => {
|
|
40
|
+
|
|
41
|
+
return new Promise<T>((resolve, reject) => {
|
|
42
|
+
const timeout = setTimeout(() => {
|
|
43
|
+
|
|
44
|
+
const message = timeoutMessage || `Promise timeout hit: ${timeoutMilliseconds}`;
|
|
45
|
+
|
|
46
|
+
reject(message);
|
|
47
|
+
}, timeoutMilliseconds);
|
|
48
|
+
|
|
49
|
+
const providedPromise = new Promise<T>(executor);
|
|
50
|
+
|
|
51
|
+
providedPromise
|
|
52
|
+
.then((result) => {
|
|
53
|
+
clearTimeout(timeout);
|
|
54
|
+
resolve(result);
|
|
55
|
+
})
|
|
56
|
+
.catch((error) => {
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
reject(error);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
export class AsyncSequelizer {
|
|
3
|
+
|
|
4
|
+
private readonly queue: Array<{ action: () => Promise<any>; resolve: (args?: any) => void; reject: (err?: any) => void }> = [];
|
|
5
|
+
private isExecutingQueue = false;
|
|
6
|
+
|
|
7
|
+
constructor(private readonly minSequenceInterval: number = 0) { }
|
|
8
|
+
|
|
9
|
+
public enqueue<T>(action: () => Promise<T>): Promise<T> {
|
|
10
|
+
return new Promise<T>((resolve, reject) => {
|
|
11
|
+
this.queue.push({ action, resolve, reject });
|
|
12
|
+
this.executeQueue();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private async executeQueue(): Promise<void> {
|
|
17
|
+
if (this.isExecutingQueue) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
this.isExecutingQueue = true;
|
|
22
|
+
|
|
23
|
+
while (this.queue.length) {
|
|
24
|
+
const operation = this.queue.shift();
|
|
25
|
+
|
|
26
|
+
// this satisfies the strict typescript mode
|
|
27
|
+
if (!operation) {
|
|
28
|
+
this.isExecutingQueue = false;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const actionResult = await operation.action();
|
|
34
|
+
operation.resolve(actionResult);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
operation.reject(error);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await this.intervalBreak();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.isExecutingQueue = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private intervalBreak(): Promise<void> {
|
|
46
|
+
return new Promise((res) => setTimeout(res, this.minSequenceInterval));
|
|
47
|
+
}
|
|
48
|
+
}
|