@geexcode/geex-angular 0.0.37 → 0.0.39
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/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +152 -98
- package/dist/index.mjs +152 -98
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -105,7 +105,7 @@ interface UiModule extends GeexModule {
|
|
|
105
105
|
declare const ExtensionModule: Record<string, any> & {};
|
|
106
106
|
type ExtensionModule = typeof ExtensionModule;
|
|
107
107
|
type GeexModules<TExtensionModules extends ExtensionModule = ExtensionModule> = {
|
|
108
|
-
init(force?: boolean)
|
|
108
|
+
init: (force?: boolean) => Promise<{
|
|
109
109
|
[K in keyof GeexModules<TExtensionModules>]: any;
|
|
110
110
|
}>;
|
|
111
111
|
tenant: TenantModule;
|
|
@@ -120,7 +120,8 @@ type GeexModule<TExtension = ExtensionModule> = {
|
|
|
120
120
|
* A module combines both reactive state (signals) and business logic methods.
|
|
121
121
|
* Concrete modules can extend this interface to expose their own signals & methods.
|
|
122
122
|
* This empty base exists mainly for typing convenience and future extension.
|
|
123
|
-
* @param force - If true, forces re-initialization
|
|
123
|
+
* @param force - If true, forces re-initialization. Defaults to false.
|
|
124
|
+
* When force is false, multiple calls will share the same initialization Promise.
|
|
124
125
|
*/
|
|
125
126
|
init: (force?: boolean) => Promise<any>;
|
|
126
127
|
} & TExtension;
|
package/dist/index.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ interface UiModule extends GeexModule {
|
|
|
105
105
|
declare const ExtensionModule: Record<string, any> & {};
|
|
106
106
|
type ExtensionModule = typeof ExtensionModule;
|
|
107
107
|
type GeexModules<TExtensionModules extends ExtensionModule = ExtensionModule> = {
|
|
108
|
-
init(force?: boolean)
|
|
108
|
+
init: (force?: boolean) => Promise<{
|
|
109
109
|
[K in keyof GeexModules<TExtensionModules>]: any;
|
|
110
110
|
}>;
|
|
111
111
|
tenant: TenantModule;
|
|
@@ -120,7 +120,8 @@ type GeexModule<TExtension = ExtensionModule> = {
|
|
|
120
120
|
* A module combines both reactive state (signals) and business logic methods.
|
|
121
121
|
* Concrete modules can extend this interface to expose their own signals & methods.
|
|
122
122
|
* This empty base exists mainly for typing convenience and future extension.
|
|
123
|
-
* @param force - If true, forces re-initialization
|
|
123
|
+
* @param force - If true, forces re-initialization. Defaults to false.
|
|
124
|
+
* When force is false, multiple calls will share the same initialization Promise.
|
|
124
125
|
*/
|
|
125
126
|
init: (force?: boolean) => Promise<any>;
|
|
126
127
|
} & TExtension;
|
package/dist/index.js
CHANGED
|
@@ -148,21 +148,28 @@ function guardedSignal(innerSignal, isInitialized) {
|
|
|
148
148
|
function createTenantModule(injector) {
|
|
149
149
|
const _current = (0, import_core.signal)(null);
|
|
150
150
|
let _initialized = false;
|
|
151
|
+
let _initPromise = null;
|
|
151
152
|
const module2 = {
|
|
152
|
-
init:
|
|
153
|
-
if (
|
|
154
|
-
|
|
153
|
+
init: (force = false) => {
|
|
154
|
+
if (force) {
|
|
155
|
+
_initPromise = null;
|
|
156
|
+
_initialized = false;
|
|
155
157
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
if (!_initPromise) {
|
|
159
|
+
_initPromise = (async () => {
|
|
160
|
+
try {
|
|
161
|
+
const tenantCode = injector.get(import_util.CookieService).get("__tenant");
|
|
162
|
+
if (tenantCode) {
|
|
163
|
+
const tenantData = await module2.loadTenantData(tenantCode);
|
|
164
|
+
_current.set(tenantData ?? null);
|
|
165
|
+
}
|
|
166
|
+
_initialized = true;
|
|
167
|
+
} catch (err) {
|
|
168
|
+
console.error(err);
|
|
169
|
+
}
|
|
170
|
+
})();
|
|
165
171
|
}
|
|
172
|
+
return _initPromise;
|
|
166
173
|
},
|
|
167
174
|
current: guardedSignal(_current, () => _initialized),
|
|
168
175
|
async loadTenantData(code) {
|
|
@@ -190,18 +197,25 @@ function createTenantModule(injector) {
|
|
|
190
197
|
function createAuthModule(injector) {
|
|
191
198
|
const _user = (0, import_core.signal)(null);
|
|
192
199
|
let _initialized = false;
|
|
200
|
+
let _initPromise = null;
|
|
193
201
|
const module2 = {
|
|
194
|
-
init:
|
|
195
|
-
if (
|
|
196
|
-
|
|
202
|
+
init: (force = false) => {
|
|
203
|
+
if (force) {
|
|
204
|
+
_initPromise = null;
|
|
205
|
+
_initialized = false;
|
|
197
206
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
207
|
+
if (!_initPromise) {
|
|
208
|
+
_initPromise = (async () => {
|
|
209
|
+
try {
|
|
210
|
+
const userData = await module2.loadUserData();
|
|
211
|
+
_user.set(userData ?? null);
|
|
212
|
+
_initialized = true;
|
|
213
|
+
} catch (err) {
|
|
214
|
+
console.error(err);
|
|
215
|
+
}
|
|
216
|
+
})();
|
|
204
217
|
}
|
|
218
|
+
return _initPromise;
|
|
205
219
|
},
|
|
206
220
|
user: guardedSignal(_user, () => _initialized),
|
|
207
221
|
async loadUserData() {
|
|
@@ -235,69 +249,83 @@ function createIdentityModule(injector) {
|
|
|
235
249
|
const _orgsSignal = (0, import_core.signal)([]);
|
|
236
250
|
const _userOwnedOrgsSignal = (0, import_core.signal)([]);
|
|
237
251
|
let _initialized = false;
|
|
252
|
+
let _initPromise = null;
|
|
238
253
|
const module2 = {
|
|
239
254
|
orgs: guardedSignal(_orgsSignal, () => _initialized),
|
|
240
255
|
userOwnedOrgs: guardedSignal(_userOwnedOrgsSignal, () => _initialized),
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
|
|
256
|
+
init: (force = false) => {
|
|
257
|
+
if (force) {
|
|
258
|
+
_initPromise = null;
|
|
259
|
+
_initialized = false;
|
|
244
260
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
if (!_initPromise) {
|
|
262
|
+
_initPromise = (async () => {
|
|
263
|
+
try {
|
|
264
|
+
await geex.tenant.init();
|
|
265
|
+
await geex.auth.init();
|
|
266
|
+
await new Promise((resolve, reject) => {
|
|
267
|
+
const orgs$ = injector.get(import_apollo_angular.Apollo).watchQuery({ query: GQL_ORGS_CACHE }).valueChanges.pipe((0, import_rxjs.map)((res) => (0, import_util.deepCopy)(res.data.orgs.items)));
|
|
268
|
+
orgs$.subscribe({
|
|
269
|
+
next: (orgs) => {
|
|
270
|
+
(0, import_core.runInInjectionContext)(injector, () => {
|
|
271
|
+
_orgsSignal.set(orgs);
|
|
272
|
+
const userData = geex.auth.user();
|
|
273
|
+
let allOwned = [];
|
|
274
|
+
if (orgs?.length && userData) {
|
|
275
|
+
if (userData.id === "000000000000000000000001") {
|
|
276
|
+
allOwned = (0, import_util.deepCopy)(orgs);
|
|
277
|
+
} else {
|
|
278
|
+
const ownedCodes = userData.orgs.map((x) => x.code);
|
|
279
|
+
allOwned = orgs.filter((o) => ownedCodes.some((code) => o.code.startsWith(code)));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
_userOwnedOrgsSignal.set(allOwned);
|
|
283
|
+
resolve();
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
error: (err) => {
|
|
287
|
+
console.error(err);
|
|
288
|
+
reject(err);
|
|
263
289
|
}
|
|
264
|
-
_userOwnedOrgsSignal.set(allOwned);
|
|
265
|
-
resolve();
|
|
266
290
|
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
});
|
|
274
|
-
_initialized = true;
|
|
275
|
-
} catch (error) {
|
|
276
|
-
console.error(error);
|
|
291
|
+
});
|
|
292
|
+
_initialized = true;
|
|
293
|
+
} catch (error) {
|
|
294
|
+
console.error(error);
|
|
295
|
+
}
|
|
296
|
+
})();
|
|
277
297
|
}
|
|
298
|
+
return _initPromise;
|
|
278
299
|
}
|
|
279
300
|
};
|
|
280
301
|
return module2;
|
|
281
302
|
}
|
|
282
303
|
function createMessagingModule(injector) {
|
|
283
304
|
let _initialized = false;
|
|
305
|
+
let _initPromise = null;
|
|
284
306
|
const module2 = {
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
|
|
307
|
+
init: (force = false) => {
|
|
308
|
+
if (force) {
|
|
309
|
+
_initPromise = null;
|
|
310
|
+
_initialized = false;
|
|
288
311
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
312
|
+
if (!_initPromise) {
|
|
313
|
+
_initPromise = (async () => {
|
|
314
|
+
try {
|
|
315
|
+
await geex.auth.init();
|
|
316
|
+
if (injector.get(import_angular_oauth2_oidc.OAuthService).hasValidAccessToken()) {
|
|
317
|
+
const subClient = injector.get(import_apollo_angular.Apollo).use("subscription");
|
|
318
|
+
subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe((0, import_rxjs.map)((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
|
|
319
|
+
module2.onPublicNotify(notify);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
_initialized = true;
|
|
323
|
+
} catch (err) {
|
|
324
|
+
console.error(err);
|
|
325
|
+
}
|
|
326
|
+
})();
|
|
300
327
|
}
|
|
328
|
+
return _initPromise;
|
|
301
329
|
},
|
|
302
330
|
onPublicNotify(notify) {
|
|
303
331
|
console.log("Public notify", notify);
|
|
@@ -308,18 +336,29 @@ function createMessagingModule(injector) {
|
|
|
308
336
|
function createSettingsModule(injector) {
|
|
309
337
|
const _settingsSignal = (0, import_core.signal)([]);
|
|
310
338
|
let _initialized = false;
|
|
339
|
+
let _initPromise = null;
|
|
311
340
|
const module2 = {
|
|
312
341
|
settings: guardedSignal(_settingsSignal, () => _initialized),
|
|
313
|
-
|
|
314
|
-
if (
|
|
315
|
-
|
|
342
|
+
init: (force = false) => {
|
|
343
|
+
if (force) {
|
|
344
|
+
_initPromise = null;
|
|
345
|
+
_initialized = false;
|
|
316
346
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
347
|
+
if (!_initPromise) {
|
|
348
|
+
_initPromise = (async () => {
|
|
349
|
+
try {
|
|
350
|
+
const res = await (0, import_rxjs.firstValueFrom)(
|
|
351
|
+
injector.get(import_apollo_angular.Apollo).query({ query: GQL_INIT_SETTINGS })
|
|
352
|
+
);
|
|
353
|
+
const settings = res.data.initSettings;
|
|
354
|
+
_settingsSignal.set(settings);
|
|
355
|
+
_initialized = true;
|
|
356
|
+
} catch (err) {
|
|
357
|
+
console.error(err);
|
|
358
|
+
}
|
|
359
|
+
})();
|
|
360
|
+
}
|
|
361
|
+
return _initPromise;
|
|
323
362
|
}
|
|
324
363
|
};
|
|
325
364
|
return module2;
|
|
@@ -331,16 +370,22 @@ function createUiModule(injector) {
|
|
|
331
370
|
(0, import_operators.switchMap)(async () => window.innerHeight / window.innerWidth >= 1.5)
|
|
332
371
|
));
|
|
333
372
|
let _initialized = false;
|
|
373
|
+
let _initPromise = null;
|
|
334
374
|
const module2 = {
|
|
335
375
|
fullScreen: guardedSignal(_fullScreenSignal, () => _initialized),
|
|
336
376
|
isMobile: guardedSignal(_isMobile, () => _initialized),
|
|
337
377
|
activeRoutedComponent: void 0,
|
|
338
|
-
|
|
339
|
-
if (
|
|
340
|
-
|
|
378
|
+
init: (force = false) => {
|
|
379
|
+
if (force) {
|
|
380
|
+
_initPromise = null;
|
|
381
|
+
_initialized = false;
|
|
341
382
|
}
|
|
342
|
-
|
|
343
|
-
|
|
383
|
+
if (!_initPromise) {
|
|
384
|
+
_initPromise = (async () => {
|
|
385
|
+
_initialized = true;
|
|
386
|
+
})();
|
|
387
|
+
}
|
|
388
|
+
return _initPromise;
|
|
344
389
|
}
|
|
345
390
|
};
|
|
346
391
|
return module2;
|
|
@@ -350,23 +395,32 @@ function createUiModule(injector) {
|
|
|
350
395
|
var geex;
|
|
351
396
|
var Geex = new import_core2.InjectionToken("Geex");
|
|
352
397
|
function configGeex(injector, overrides = {}) {
|
|
353
|
-
const modules = {
|
|
354
|
-
...overrides
|
|
355
|
-
};
|
|
356
398
|
(0, import_core2.runInInjectionContext)(injector, () => {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
399
|
+
const modules = {
|
|
400
|
+
...overrides
|
|
401
|
+
};
|
|
402
|
+
let _initPromise = null;
|
|
403
|
+
modules.init ?? (modules.init = (force = false) => {
|
|
404
|
+
if (force) {
|
|
405
|
+
_initPromise = null;
|
|
406
|
+
}
|
|
407
|
+
if (!_initPromise) {
|
|
408
|
+
_initPromise = (async () => {
|
|
409
|
+
const entries = Object.entries(modules).filter(([key]) => key !== "init");
|
|
410
|
+
return Object.fromEntries(await Promise.all(
|
|
411
|
+
entries.map(async ([key, mod]) => {
|
|
412
|
+
const maybeInit = mod.init;
|
|
413
|
+
try {
|
|
414
|
+
return [key, await maybeInit(force)];
|
|
415
|
+
} catch (err) {
|
|
416
|
+
console.error(err);
|
|
417
|
+
return [key, null];
|
|
418
|
+
}
|
|
419
|
+
})
|
|
420
|
+
));
|
|
421
|
+
})();
|
|
422
|
+
}
|
|
423
|
+
return _initPromise;
|
|
370
424
|
});
|
|
371
425
|
modules.tenant ?? (modules.tenant = createTenantModule(injector));
|
|
372
426
|
modules.auth ?? (modules.auth = createAuthModule(injector));
|
package/dist/index.mjs
CHANGED
|
@@ -102,21 +102,28 @@ function guardedSignal(innerSignal, isInitialized) {
|
|
|
102
102
|
function createTenantModule(injector) {
|
|
103
103
|
const _current = signal(null);
|
|
104
104
|
let _initialized = false;
|
|
105
|
+
let _initPromise = null;
|
|
105
106
|
const module = {
|
|
106
|
-
init:
|
|
107
|
-
if (
|
|
108
|
-
|
|
107
|
+
init: (force = false) => {
|
|
108
|
+
if (force) {
|
|
109
|
+
_initPromise = null;
|
|
110
|
+
_initialized = false;
|
|
109
111
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
if (!_initPromise) {
|
|
113
|
+
_initPromise = (async () => {
|
|
114
|
+
try {
|
|
115
|
+
const tenantCode = injector.get(CookieService).get("__tenant");
|
|
116
|
+
if (tenantCode) {
|
|
117
|
+
const tenantData = await module.loadTenantData(tenantCode);
|
|
118
|
+
_current.set(tenantData ?? null);
|
|
119
|
+
}
|
|
120
|
+
_initialized = true;
|
|
121
|
+
} catch (err) {
|
|
122
|
+
console.error(err);
|
|
123
|
+
}
|
|
124
|
+
})();
|
|
119
125
|
}
|
|
126
|
+
return _initPromise;
|
|
120
127
|
},
|
|
121
128
|
current: guardedSignal(_current, () => _initialized),
|
|
122
129
|
async loadTenantData(code) {
|
|
@@ -144,18 +151,25 @@ function createTenantModule(injector) {
|
|
|
144
151
|
function createAuthModule(injector) {
|
|
145
152
|
const _user = signal(null);
|
|
146
153
|
let _initialized = false;
|
|
154
|
+
let _initPromise = null;
|
|
147
155
|
const module = {
|
|
148
|
-
init:
|
|
149
|
-
if (
|
|
150
|
-
|
|
156
|
+
init: (force = false) => {
|
|
157
|
+
if (force) {
|
|
158
|
+
_initPromise = null;
|
|
159
|
+
_initialized = false;
|
|
151
160
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
161
|
+
if (!_initPromise) {
|
|
162
|
+
_initPromise = (async () => {
|
|
163
|
+
try {
|
|
164
|
+
const userData = await module.loadUserData();
|
|
165
|
+
_user.set(userData ?? null);
|
|
166
|
+
_initialized = true;
|
|
167
|
+
} catch (err) {
|
|
168
|
+
console.error(err);
|
|
169
|
+
}
|
|
170
|
+
})();
|
|
158
171
|
}
|
|
172
|
+
return _initPromise;
|
|
159
173
|
},
|
|
160
174
|
user: guardedSignal(_user, () => _initialized),
|
|
161
175
|
async loadUserData() {
|
|
@@ -189,69 +203,83 @@ function createIdentityModule(injector) {
|
|
|
189
203
|
const _orgsSignal = signal([]);
|
|
190
204
|
const _userOwnedOrgsSignal = signal([]);
|
|
191
205
|
let _initialized = false;
|
|
206
|
+
let _initPromise = null;
|
|
192
207
|
const module = {
|
|
193
208
|
orgs: guardedSignal(_orgsSignal, () => _initialized),
|
|
194
209
|
userOwnedOrgs: guardedSignal(_userOwnedOrgsSignal, () => _initialized),
|
|
195
|
-
|
|
196
|
-
if (
|
|
197
|
-
|
|
210
|
+
init: (force = false) => {
|
|
211
|
+
if (force) {
|
|
212
|
+
_initPromise = null;
|
|
213
|
+
_initialized = false;
|
|
198
214
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
if (!_initPromise) {
|
|
216
|
+
_initPromise = (async () => {
|
|
217
|
+
try {
|
|
218
|
+
await geex.tenant.init();
|
|
219
|
+
await geex.auth.init();
|
|
220
|
+
await new Promise((resolve, reject) => {
|
|
221
|
+
const orgs$ = injector.get(Apollo).watchQuery({ query: GQL_ORGS_CACHE }).valueChanges.pipe(map((res) => deepCopy(res.data.orgs.items)));
|
|
222
|
+
orgs$.subscribe({
|
|
223
|
+
next: (orgs) => {
|
|
224
|
+
runInInjectionContext(injector, () => {
|
|
225
|
+
_orgsSignal.set(orgs);
|
|
226
|
+
const userData = geex.auth.user();
|
|
227
|
+
let allOwned = [];
|
|
228
|
+
if (orgs?.length && userData) {
|
|
229
|
+
if (userData.id === "000000000000000000000001") {
|
|
230
|
+
allOwned = deepCopy(orgs);
|
|
231
|
+
} else {
|
|
232
|
+
const ownedCodes = userData.orgs.map((x) => x.code);
|
|
233
|
+
allOwned = orgs.filter((o) => ownedCodes.some((code) => o.code.startsWith(code)));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
_userOwnedOrgsSignal.set(allOwned);
|
|
237
|
+
resolve();
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
error: (err) => {
|
|
241
|
+
console.error(err);
|
|
242
|
+
reject(err);
|
|
217
243
|
}
|
|
218
|
-
_userOwnedOrgsSignal.set(allOwned);
|
|
219
|
-
resolve();
|
|
220
244
|
});
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
});
|
|
228
|
-
_initialized = true;
|
|
229
|
-
} catch (error) {
|
|
230
|
-
console.error(error);
|
|
245
|
+
});
|
|
246
|
+
_initialized = true;
|
|
247
|
+
} catch (error) {
|
|
248
|
+
console.error(error);
|
|
249
|
+
}
|
|
250
|
+
})();
|
|
231
251
|
}
|
|
252
|
+
return _initPromise;
|
|
232
253
|
}
|
|
233
254
|
};
|
|
234
255
|
return module;
|
|
235
256
|
}
|
|
236
257
|
function createMessagingModule(injector) {
|
|
237
258
|
let _initialized = false;
|
|
259
|
+
let _initPromise = null;
|
|
238
260
|
const module = {
|
|
239
|
-
|
|
240
|
-
if (
|
|
241
|
-
|
|
261
|
+
init: (force = false) => {
|
|
262
|
+
if (force) {
|
|
263
|
+
_initPromise = null;
|
|
264
|
+
_initialized = false;
|
|
242
265
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
266
|
+
if (!_initPromise) {
|
|
267
|
+
_initPromise = (async () => {
|
|
268
|
+
try {
|
|
269
|
+
await geex.auth.init();
|
|
270
|
+
if (injector.get(OAuthService).hasValidAccessToken()) {
|
|
271
|
+
const subClient = injector.get(Apollo).use("subscription");
|
|
272
|
+
subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe(map((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
|
|
273
|
+
module.onPublicNotify(notify);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
_initialized = true;
|
|
277
|
+
} catch (err) {
|
|
278
|
+
console.error(err);
|
|
279
|
+
}
|
|
280
|
+
})();
|
|
254
281
|
}
|
|
282
|
+
return _initPromise;
|
|
255
283
|
},
|
|
256
284
|
onPublicNotify(notify) {
|
|
257
285
|
console.log("Public notify", notify);
|
|
@@ -262,18 +290,29 @@ function createMessagingModule(injector) {
|
|
|
262
290
|
function createSettingsModule(injector) {
|
|
263
291
|
const _settingsSignal = signal([]);
|
|
264
292
|
let _initialized = false;
|
|
293
|
+
let _initPromise = null;
|
|
265
294
|
const module = {
|
|
266
295
|
settings: guardedSignal(_settingsSignal, () => _initialized),
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
|
|
296
|
+
init: (force = false) => {
|
|
297
|
+
if (force) {
|
|
298
|
+
_initPromise = null;
|
|
299
|
+
_initialized = false;
|
|
270
300
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
301
|
+
if (!_initPromise) {
|
|
302
|
+
_initPromise = (async () => {
|
|
303
|
+
try {
|
|
304
|
+
const res = await firstValueFrom(
|
|
305
|
+
injector.get(Apollo).query({ query: GQL_INIT_SETTINGS })
|
|
306
|
+
);
|
|
307
|
+
const settings = res.data.initSettings;
|
|
308
|
+
_settingsSignal.set(settings);
|
|
309
|
+
_initialized = true;
|
|
310
|
+
} catch (err) {
|
|
311
|
+
console.error(err);
|
|
312
|
+
}
|
|
313
|
+
})();
|
|
314
|
+
}
|
|
315
|
+
return _initPromise;
|
|
277
316
|
}
|
|
278
317
|
};
|
|
279
318
|
return module;
|
|
@@ -285,16 +324,22 @@ function createUiModule(injector) {
|
|
|
285
324
|
switchMap(async () => window.innerHeight / window.innerWidth >= 1.5)
|
|
286
325
|
));
|
|
287
326
|
let _initialized = false;
|
|
327
|
+
let _initPromise = null;
|
|
288
328
|
const module = {
|
|
289
329
|
fullScreen: guardedSignal(_fullScreenSignal, () => _initialized),
|
|
290
330
|
isMobile: guardedSignal(_isMobile, () => _initialized),
|
|
291
331
|
activeRoutedComponent: void 0,
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
|
|
332
|
+
init: (force = false) => {
|
|
333
|
+
if (force) {
|
|
334
|
+
_initPromise = null;
|
|
335
|
+
_initialized = false;
|
|
295
336
|
}
|
|
296
|
-
|
|
297
|
-
|
|
337
|
+
if (!_initPromise) {
|
|
338
|
+
_initPromise = (async () => {
|
|
339
|
+
_initialized = true;
|
|
340
|
+
})();
|
|
341
|
+
}
|
|
342
|
+
return _initPromise;
|
|
298
343
|
}
|
|
299
344
|
};
|
|
300
345
|
return module;
|
|
@@ -304,23 +349,32 @@ function createUiModule(injector) {
|
|
|
304
349
|
var geex;
|
|
305
350
|
var Geex = new InjectionToken("Geex");
|
|
306
351
|
function configGeex(injector, overrides = {}) {
|
|
307
|
-
const modules = {
|
|
308
|
-
...overrides
|
|
309
|
-
};
|
|
310
352
|
runInInjectionContext2(injector, () => {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
353
|
+
const modules = {
|
|
354
|
+
...overrides
|
|
355
|
+
};
|
|
356
|
+
let _initPromise = null;
|
|
357
|
+
modules.init ?? (modules.init = (force = false) => {
|
|
358
|
+
if (force) {
|
|
359
|
+
_initPromise = null;
|
|
360
|
+
}
|
|
361
|
+
if (!_initPromise) {
|
|
362
|
+
_initPromise = (async () => {
|
|
363
|
+
const entries = Object.entries(modules).filter(([key]) => key !== "init");
|
|
364
|
+
return Object.fromEntries(await Promise.all(
|
|
365
|
+
entries.map(async ([key, mod]) => {
|
|
366
|
+
const maybeInit = mod.init;
|
|
367
|
+
try {
|
|
368
|
+
return [key, await maybeInit(force)];
|
|
369
|
+
} catch (err) {
|
|
370
|
+
console.error(err);
|
|
371
|
+
return [key, null];
|
|
372
|
+
}
|
|
373
|
+
})
|
|
374
|
+
));
|
|
375
|
+
})();
|
|
376
|
+
}
|
|
377
|
+
return _initPromise;
|
|
324
378
|
});
|
|
325
379
|
modules.tenant ?? (modules.tenant = createTenantModule(injector));
|
|
326
380
|
modules.auth ?? (modules.auth = createAuthModule(injector));
|