@geexcode/geex-angular 0.0.36 → 0.0.38
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 +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +133 -104
- package/dist/index.mjs +133 -104
- 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
|
|
108
|
+
init: Promise<{
|
|
109
109
|
[K in keyof GeexModules<TExtensionModules>]: any;
|
|
110
110
|
}>;
|
|
111
111
|
tenant: TenantModule;
|
|
@@ -120,9 +120,10 @@ 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
|
-
*
|
|
123
|
+
* The init property is a Promise that resolves when the module is initialized.
|
|
124
|
+
* Multiple awaits on the same init will share the same initialization process.
|
|
124
125
|
*/
|
|
125
|
-
init:
|
|
126
|
+
init: Promise<any>;
|
|
126
127
|
} & TExtension;
|
|
127
128
|
declare function createTenantModule(injector: Injector): TenantModule;
|
|
128
129
|
declare function createAuthModule(injector: Injector): AuthModule;
|
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
|
|
108
|
+
init: Promise<{
|
|
109
109
|
[K in keyof GeexModules<TExtensionModules>]: any;
|
|
110
110
|
}>;
|
|
111
111
|
tenant: TenantModule;
|
|
@@ -120,9 +120,10 @@ 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
|
-
*
|
|
123
|
+
* The init property is a Promise that resolves when the module is initialized.
|
|
124
|
+
* Multiple awaits on the same init will share the same initialization process.
|
|
124
125
|
*/
|
|
125
|
-
init:
|
|
126
|
+
init: Promise<any>;
|
|
126
127
|
} & TExtension;
|
|
127
128
|
declare function createTenantModule(injector: Injector): TenantModule;
|
|
128
129
|
declare function createAuthModule(injector: Injector): AuthModule;
|
package/dist/index.js
CHANGED
|
@@ -148,21 +148,24 @@ 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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
get init() {
|
|
154
|
+
if (!_initPromise) {
|
|
155
|
+
_initPromise = (async () => {
|
|
156
|
+
try {
|
|
157
|
+
const tenantCode = injector.get(import_util.CookieService).get("__tenant");
|
|
158
|
+
if (tenantCode) {
|
|
159
|
+
const tenantData = await module2.loadTenantData(tenantCode);
|
|
160
|
+
_current.set(tenantData ?? null);
|
|
161
|
+
}
|
|
162
|
+
_initialized = true;
|
|
163
|
+
} catch (err) {
|
|
164
|
+
console.error(err);
|
|
165
|
+
}
|
|
166
|
+
})();
|
|
165
167
|
}
|
|
168
|
+
return _initPromise;
|
|
166
169
|
},
|
|
167
170
|
current: guardedSignal(_current, () => _initialized),
|
|
168
171
|
async loadTenantData(code) {
|
|
@@ -190,18 +193,21 @@ function createTenantModule(injector) {
|
|
|
190
193
|
function createAuthModule(injector) {
|
|
191
194
|
const _user = (0, import_core.signal)(null);
|
|
192
195
|
let _initialized = false;
|
|
196
|
+
let _initPromise = null;
|
|
193
197
|
const module2 = {
|
|
194
|
-
init
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
get init() {
|
|
199
|
+
if (!_initPromise) {
|
|
200
|
+
_initPromise = (async () => {
|
|
201
|
+
try {
|
|
202
|
+
const userData = await module2.loadUserData();
|
|
203
|
+
_user.set(userData ?? null);
|
|
204
|
+
_initialized = true;
|
|
205
|
+
} catch (err) {
|
|
206
|
+
console.error(err);
|
|
207
|
+
}
|
|
208
|
+
})();
|
|
204
209
|
}
|
|
210
|
+
return _initPromise;
|
|
205
211
|
},
|
|
206
212
|
user: guardedSignal(_user, () => _initialized),
|
|
207
213
|
async loadUserData() {
|
|
@@ -235,71 +241,75 @@ function createIdentityModule(injector) {
|
|
|
235
241
|
const _orgsSignal = (0, import_core.signal)([]);
|
|
236
242
|
const _userOwnedOrgsSignal = (0, import_core.signal)([]);
|
|
237
243
|
let _initialized = false;
|
|
244
|
+
let _initPromise = null;
|
|
238
245
|
const module2 = {
|
|
239
246
|
orgs: guardedSignal(_orgsSignal, () => _initialized),
|
|
240
247
|
userOwnedOrgs: guardedSignal(_userOwnedOrgsSignal, () => _initialized),
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
248
|
+
get init() {
|
|
249
|
+
if (!_initPromise) {
|
|
250
|
+
_initPromise = (async () => {
|
|
251
|
+
try {
|
|
252
|
+
await geex.tenant.init;
|
|
253
|
+
await geex.auth.init;
|
|
254
|
+
await new Promise((resolve, reject) => {
|
|
255
|
+
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)));
|
|
256
|
+
orgs$.subscribe({
|
|
257
|
+
next: (orgs) => {
|
|
258
|
+
(0, import_core.runInInjectionContext)(injector, () => {
|
|
259
|
+
_orgsSignal.set(orgs);
|
|
260
|
+
const userData = geex.auth.user();
|
|
261
|
+
let allOwned = [];
|
|
262
|
+
if (orgs?.length && userData) {
|
|
263
|
+
if (userData.id === "000000000000000000000001") {
|
|
264
|
+
allOwned = (0, import_util.deepCopy)(orgs);
|
|
265
|
+
} else {
|
|
266
|
+
const ownedCodes = userData.orgs.map((x) => x.code);
|
|
267
|
+
allOwned = orgs.filter((o) => ownedCodes.some((code) => o.code.startsWith(code)));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
_userOwnedOrgsSignal.set(allOwned);
|
|
271
|
+
resolve();
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
error: (err) => {
|
|
275
|
+
console.error(err);
|
|
276
|
+
reject(err);
|
|
267
277
|
}
|
|
268
278
|
});
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
});
|
|
276
|
-
_initialized = true;
|
|
277
|
-
} catch (error) {
|
|
278
|
-
console.error(error);
|
|
279
|
+
});
|
|
280
|
+
_initialized = true;
|
|
281
|
+
} catch (error) {
|
|
282
|
+
console.error(error);
|
|
283
|
+
}
|
|
284
|
+
})();
|
|
279
285
|
}
|
|
286
|
+
return _initPromise;
|
|
280
287
|
}
|
|
281
288
|
};
|
|
282
289
|
return module2;
|
|
283
290
|
}
|
|
284
291
|
function createMessagingModule(injector) {
|
|
285
292
|
let _initialized = false;
|
|
293
|
+
let _initPromise = null;
|
|
286
294
|
const module2 = {
|
|
287
|
-
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
295
|
+
get init() {
|
|
296
|
+
if (!_initPromise) {
|
|
297
|
+
_initPromise = (async () => {
|
|
298
|
+
try {
|
|
299
|
+
await geex.auth.init;
|
|
300
|
+
if (injector.get(import_angular_oauth2_oidc.OAuthService).hasValidAccessToken()) {
|
|
301
|
+
const subClient = injector.get(import_apollo_angular.Apollo).use("subscription");
|
|
302
|
+
subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe((0, import_rxjs.map)((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
|
|
303
|
+
module2.onPublicNotify(notify);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
_initialized = true;
|
|
307
|
+
} catch (err) {
|
|
308
|
+
console.error(err);
|
|
309
|
+
}
|
|
310
|
+
})();
|
|
302
311
|
}
|
|
312
|
+
return _initPromise;
|
|
303
313
|
},
|
|
304
314
|
onPublicNotify(notify) {
|
|
305
315
|
console.log("Public notify", notify);
|
|
@@ -310,18 +320,25 @@ function createMessagingModule(injector) {
|
|
|
310
320
|
function createSettingsModule(injector) {
|
|
311
321
|
const _settingsSignal = (0, import_core.signal)([]);
|
|
312
322
|
let _initialized = false;
|
|
323
|
+
let _initPromise = null;
|
|
313
324
|
const module2 = {
|
|
314
325
|
settings: guardedSignal(_settingsSignal, () => _initialized),
|
|
315
|
-
|
|
316
|
-
if (
|
|
317
|
-
|
|
326
|
+
get init() {
|
|
327
|
+
if (!_initPromise) {
|
|
328
|
+
_initPromise = (async () => {
|
|
329
|
+
try {
|
|
330
|
+
const res = await (0, import_rxjs.firstValueFrom)(
|
|
331
|
+
injector.get(import_apollo_angular.Apollo).query({ query: GQL_INIT_SETTINGS })
|
|
332
|
+
);
|
|
333
|
+
const settings = res.data.initSettings;
|
|
334
|
+
_settingsSignal.set(settings);
|
|
335
|
+
_initialized = true;
|
|
336
|
+
} catch (err) {
|
|
337
|
+
console.error(err);
|
|
338
|
+
}
|
|
339
|
+
})();
|
|
318
340
|
}
|
|
319
|
-
|
|
320
|
-
injector.get(import_apollo_angular.Apollo).query({ query: GQL_INIT_SETTINGS })
|
|
321
|
-
);
|
|
322
|
-
const settings = res.data.initSettings;
|
|
323
|
-
_settingsSignal.set(settings);
|
|
324
|
-
_initialized = true;
|
|
341
|
+
return _initPromise;
|
|
325
342
|
}
|
|
326
343
|
};
|
|
327
344
|
return module2;
|
|
@@ -333,16 +350,18 @@ function createUiModule(injector) {
|
|
|
333
350
|
(0, import_operators.switchMap)(async () => window.innerHeight / window.innerWidth >= 1.5)
|
|
334
351
|
));
|
|
335
352
|
let _initialized = false;
|
|
353
|
+
let _initPromise = null;
|
|
336
354
|
const module2 = {
|
|
337
355
|
fullScreen: guardedSignal(_fullScreenSignal, () => _initialized),
|
|
338
356
|
isMobile: guardedSignal(_isMobile, () => _initialized),
|
|
339
357
|
activeRoutedComponent: void 0,
|
|
340
|
-
|
|
341
|
-
if (
|
|
342
|
-
|
|
358
|
+
get init() {
|
|
359
|
+
if (!_initPromise) {
|
|
360
|
+
_initPromise = (async () => {
|
|
361
|
+
_initialized = true;
|
|
362
|
+
})();
|
|
343
363
|
}
|
|
344
|
-
|
|
345
|
-
return;
|
|
364
|
+
return _initPromise;
|
|
346
365
|
}
|
|
347
366
|
};
|
|
348
367
|
return module2;
|
|
@@ -352,24 +371,34 @@ function createUiModule(injector) {
|
|
|
352
371
|
var geex;
|
|
353
372
|
var Geex = new import_core2.InjectionToken("Geex");
|
|
354
373
|
function configGeex(injector, overrides = {}) {
|
|
355
|
-
const modules = {
|
|
356
|
-
...overrides
|
|
357
|
-
};
|
|
358
374
|
(0, import_core2.runInInjectionContext)(injector, () => {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
375
|
+
const modules = {
|
|
376
|
+
...overrides
|
|
377
|
+
};
|
|
378
|
+
let _initPromise = null;
|
|
379
|
+
if (!modules.init) {
|
|
380
|
+
Object.defineProperty(modules, "init", {
|
|
381
|
+
get() {
|
|
382
|
+
if (!_initPromise) {
|
|
383
|
+
_initPromise = (async () => {
|
|
384
|
+
const entries = Object.entries(modules).filter(([key]) => key !== "init");
|
|
385
|
+
return Object.fromEntries(await Promise.all(
|
|
386
|
+
entries.map(async ([key, mod]) => {
|
|
387
|
+
const maybeInit = mod.init;
|
|
388
|
+
try {
|
|
389
|
+
return [key, await maybeInit];
|
|
390
|
+
} catch (err) {
|
|
391
|
+
console.error(err);
|
|
392
|
+
return [key, null];
|
|
393
|
+
}
|
|
394
|
+
})
|
|
395
|
+
));
|
|
396
|
+
})();
|
|
369
397
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
398
|
+
return _initPromise;
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}
|
|
373
402
|
modules.tenant ?? (modules.tenant = createTenantModule(injector));
|
|
374
403
|
modules.auth ?? (modules.auth = createAuthModule(injector));
|
|
375
404
|
modules.identity ?? (modules.identity = createIdentityModule(injector));
|
package/dist/index.mjs
CHANGED
|
@@ -102,21 +102,24 @@ 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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
get init() {
|
|
108
|
+
if (!_initPromise) {
|
|
109
|
+
_initPromise = (async () => {
|
|
110
|
+
try {
|
|
111
|
+
const tenantCode = injector.get(CookieService).get("__tenant");
|
|
112
|
+
if (tenantCode) {
|
|
113
|
+
const tenantData = await module.loadTenantData(tenantCode);
|
|
114
|
+
_current.set(tenantData ?? null);
|
|
115
|
+
}
|
|
116
|
+
_initialized = true;
|
|
117
|
+
} catch (err) {
|
|
118
|
+
console.error(err);
|
|
119
|
+
}
|
|
120
|
+
})();
|
|
119
121
|
}
|
|
122
|
+
return _initPromise;
|
|
120
123
|
},
|
|
121
124
|
current: guardedSignal(_current, () => _initialized),
|
|
122
125
|
async loadTenantData(code) {
|
|
@@ -144,18 +147,21 @@ function createTenantModule(injector) {
|
|
|
144
147
|
function createAuthModule(injector) {
|
|
145
148
|
const _user = signal(null);
|
|
146
149
|
let _initialized = false;
|
|
150
|
+
let _initPromise = null;
|
|
147
151
|
const module = {
|
|
148
|
-
init
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
get init() {
|
|
153
|
+
if (!_initPromise) {
|
|
154
|
+
_initPromise = (async () => {
|
|
155
|
+
try {
|
|
156
|
+
const userData = await module.loadUserData();
|
|
157
|
+
_user.set(userData ?? null);
|
|
158
|
+
_initialized = true;
|
|
159
|
+
} catch (err) {
|
|
160
|
+
console.error(err);
|
|
161
|
+
}
|
|
162
|
+
})();
|
|
158
163
|
}
|
|
164
|
+
return _initPromise;
|
|
159
165
|
},
|
|
160
166
|
user: guardedSignal(_user, () => _initialized),
|
|
161
167
|
async loadUserData() {
|
|
@@ -189,71 +195,75 @@ function createIdentityModule(injector) {
|
|
|
189
195
|
const _orgsSignal = signal([]);
|
|
190
196
|
const _userOwnedOrgsSignal = signal([]);
|
|
191
197
|
let _initialized = false;
|
|
198
|
+
let _initPromise = null;
|
|
192
199
|
const module = {
|
|
193
200
|
orgs: guardedSignal(_orgsSignal, () => _initialized),
|
|
194
201
|
userOwnedOrgs: guardedSignal(_userOwnedOrgsSignal, () => _initialized),
|
|
195
|
-
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
202
|
+
get init() {
|
|
203
|
+
if (!_initPromise) {
|
|
204
|
+
_initPromise = (async () => {
|
|
205
|
+
try {
|
|
206
|
+
await geex.tenant.init;
|
|
207
|
+
await geex.auth.init;
|
|
208
|
+
await new Promise((resolve, reject) => {
|
|
209
|
+
const orgs$ = injector.get(Apollo).watchQuery({ query: GQL_ORGS_CACHE }).valueChanges.pipe(map((res) => deepCopy(res.data.orgs.items)));
|
|
210
|
+
orgs$.subscribe({
|
|
211
|
+
next: (orgs) => {
|
|
212
|
+
runInInjectionContext(injector, () => {
|
|
213
|
+
_orgsSignal.set(orgs);
|
|
214
|
+
const userData = geex.auth.user();
|
|
215
|
+
let allOwned = [];
|
|
216
|
+
if (orgs?.length && userData) {
|
|
217
|
+
if (userData.id === "000000000000000000000001") {
|
|
218
|
+
allOwned = deepCopy(orgs);
|
|
219
|
+
} else {
|
|
220
|
+
const ownedCodes = userData.orgs.map((x) => x.code);
|
|
221
|
+
allOwned = orgs.filter((o) => ownedCodes.some((code) => o.code.startsWith(code)));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
_userOwnedOrgsSignal.set(allOwned);
|
|
225
|
+
resolve();
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
error: (err) => {
|
|
229
|
+
console.error(err);
|
|
230
|
+
reject(err);
|
|
221
231
|
}
|
|
222
232
|
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
});
|
|
230
|
-
_initialized = true;
|
|
231
|
-
} catch (error) {
|
|
232
|
-
console.error(error);
|
|
233
|
+
});
|
|
234
|
+
_initialized = true;
|
|
235
|
+
} catch (error) {
|
|
236
|
+
console.error(error);
|
|
237
|
+
}
|
|
238
|
+
})();
|
|
233
239
|
}
|
|
240
|
+
return _initPromise;
|
|
234
241
|
}
|
|
235
242
|
};
|
|
236
243
|
return module;
|
|
237
244
|
}
|
|
238
245
|
function createMessagingModule(injector) {
|
|
239
246
|
let _initialized = false;
|
|
247
|
+
let _initPromise = null;
|
|
240
248
|
const module = {
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
249
|
+
get init() {
|
|
250
|
+
if (!_initPromise) {
|
|
251
|
+
_initPromise = (async () => {
|
|
252
|
+
try {
|
|
253
|
+
await geex.auth.init;
|
|
254
|
+
if (injector.get(OAuthService).hasValidAccessToken()) {
|
|
255
|
+
const subClient = injector.get(Apollo).use("subscription");
|
|
256
|
+
subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe(map((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
|
|
257
|
+
module.onPublicNotify(notify);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
_initialized = true;
|
|
261
|
+
} catch (err) {
|
|
262
|
+
console.error(err);
|
|
263
|
+
}
|
|
264
|
+
})();
|
|
256
265
|
}
|
|
266
|
+
return _initPromise;
|
|
257
267
|
},
|
|
258
268
|
onPublicNotify(notify) {
|
|
259
269
|
console.log("Public notify", notify);
|
|
@@ -264,18 +274,25 @@ function createMessagingModule(injector) {
|
|
|
264
274
|
function createSettingsModule(injector) {
|
|
265
275
|
const _settingsSignal = signal([]);
|
|
266
276
|
let _initialized = false;
|
|
277
|
+
let _initPromise = null;
|
|
267
278
|
const module = {
|
|
268
279
|
settings: guardedSignal(_settingsSignal, () => _initialized),
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
|
|
280
|
+
get init() {
|
|
281
|
+
if (!_initPromise) {
|
|
282
|
+
_initPromise = (async () => {
|
|
283
|
+
try {
|
|
284
|
+
const res = await firstValueFrom(
|
|
285
|
+
injector.get(Apollo).query({ query: GQL_INIT_SETTINGS })
|
|
286
|
+
);
|
|
287
|
+
const settings = res.data.initSettings;
|
|
288
|
+
_settingsSignal.set(settings);
|
|
289
|
+
_initialized = true;
|
|
290
|
+
} catch (err) {
|
|
291
|
+
console.error(err);
|
|
292
|
+
}
|
|
293
|
+
})();
|
|
272
294
|
}
|
|
273
|
-
|
|
274
|
-
injector.get(Apollo).query({ query: GQL_INIT_SETTINGS })
|
|
275
|
-
);
|
|
276
|
-
const settings = res.data.initSettings;
|
|
277
|
-
_settingsSignal.set(settings);
|
|
278
|
-
_initialized = true;
|
|
295
|
+
return _initPromise;
|
|
279
296
|
}
|
|
280
297
|
};
|
|
281
298
|
return module;
|
|
@@ -287,16 +304,18 @@ function createUiModule(injector) {
|
|
|
287
304
|
switchMap(async () => window.innerHeight / window.innerWidth >= 1.5)
|
|
288
305
|
));
|
|
289
306
|
let _initialized = false;
|
|
307
|
+
let _initPromise = null;
|
|
290
308
|
const module = {
|
|
291
309
|
fullScreen: guardedSignal(_fullScreenSignal, () => _initialized),
|
|
292
310
|
isMobile: guardedSignal(_isMobile, () => _initialized),
|
|
293
311
|
activeRoutedComponent: void 0,
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
|
|
312
|
+
get init() {
|
|
313
|
+
if (!_initPromise) {
|
|
314
|
+
_initPromise = (async () => {
|
|
315
|
+
_initialized = true;
|
|
316
|
+
})();
|
|
297
317
|
}
|
|
298
|
-
|
|
299
|
-
return;
|
|
318
|
+
return _initPromise;
|
|
300
319
|
}
|
|
301
320
|
};
|
|
302
321
|
return module;
|
|
@@ -306,24 +325,34 @@ function createUiModule(injector) {
|
|
|
306
325
|
var geex;
|
|
307
326
|
var Geex = new InjectionToken("Geex");
|
|
308
327
|
function configGeex(injector, overrides = {}) {
|
|
309
|
-
const modules = {
|
|
310
|
-
...overrides
|
|
311
|
-
};
|
|
312
328
|
runInInjectionContext2(injector, () => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
329
|
+
const modules = {
|
|
330
|
+
...overrides
|
|
331
|
+
};
|
|
332
|
+
let _initPromise = null;
|
|
333
|
+
if (!modules.init) {
|
|
334
|
+
Object.defineProperty(modules, "init", {
|
|
335
|
+
get() {
|
|
336
|
+
if (!_initPromise) {
|
|
337
|
+
_initPromise = (async () => {
|
|
338
|
+
const entries = Object.entries(modules).filter(([key]) => key !== "init");
|
|
339
|
+
return Object.fromEntries(await Promise.all(
|
|
340
|
+
entries.map(async ([key, mod]) => {
|
|
341
|
+
const maybeInit = mod.init;
|
|
342
|
+
try {
|
|
343
|
+
return [key, await maybeInit];
|
|
344
|
+
} catch (err) {
|
|
345
|
+
console.error(err);
|
|
346
|
+
return [key, null];
|
|
347
|
+
}
|
|
348
|
+
})
|
|
349
|
+
));
|
|
350
|
+
})();
|
|
323
351
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
352
|
+
return _initPromise;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
327
356
|
modules.tenant ?? (modules.tenant = createTenantModule(injector));
|
|
328
357
|
modules.auth ?? (modules.auth = createAuthModule(injector));
|
|
329
358
|
modules.identity ?? (modules.identity = createIdentityModule(injector));
|