@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 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): Promise<{
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 even if already initialized. Defaults to false.
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): Promise<{
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 even if already initialized. Defaults to false.
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: async (force = false) => {
153
- if (_initialized && !force) {
154
- return;
153
+ init: (force = false) => {
154
+ if (force) {
155
+ _initPromise = null;
156
+ _initialized = false;
155
157
  }
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);
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: async (force = false) => {
195
- if (_initialized && !force) {
196
- return;
202
+ init: (force = false) => {
203
+ if (force) {
204
+ _initPromise = null;
205
+ _initialized = false;
197
206
  }
198
- try {
199
- const userData = await module2.loadUserData();
200
- _user.set(userData ?? null);
201
- _initialized = true;
202
- } catch (err) {
203
- console.error(err);
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
- async init(force = false) {
242
- if (_initialized && !force) {
243
- return;
256
+ init: (force = false) => {
257
+ if (force) {
258
+ _initPromise = null;
259
+ _initialized = false;
244
260
  }
245
- try {
246
- await geex.tenant.init();
247
- await geex.auth.init();
248
- await new Promise((resolve, reject) => {
249
- 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)));
250
- orgs$.subscribe({
251
- next: (orgs) => {
252
- (0, import_core.runInInjectionContext)(injector, () => {
253
- _orgsSignal.set(orgs);
254
- const userData = geex.auth.user();
255
- let allOwned = [];
256
- if (orgs?.length && userData) {
257
- if (userData.id === "000000000000000000000001") {
258
- allOwned = (0, import_util.deepCopy)(orgs);
259
- } else {
260
- const ownedCodes = userData.orgs.map((x) => x.code);
261
- allOwned = orgs.filter((o) => ownedCodes.some((code) => o.code.startsWith(code)));
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
- error: (err) => {
269
- console.error(err);
270
- reject(err);
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
- async init(force = false) {
286
- if (_initialized && !force) {
287
- return;
307
+ init: (force = false) => {
308
+ if (force) {
309
+ _initPromise = null;
310
+ _initialized = false;
288
311
  }
289
- try {
290
- await geex.auth.init();
291
- if (injector.get(import_angular_oauth2_oidc.OAuthService).hasValidAccessToken()) {
292
- const subClient = injector.get(import_apollo_angular.Apollo).use("subscription");
293
- subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe((0, import_rxjs.map)((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
294
- module2.onPublicNotify(notify);
295
- });
296
- }
297
- _initialized = true;
298
- } catch (err) {
299
- console.error(err);
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
- async init(force = false) {
314
- if (_initialized && !force) {
315
- return;
342
+ init: (force = false) => {
343
+ if (force) {
344
+ _initPromise = null;
345
+ _initialized = false;
316
346
  }
317
- const res = await (0, import_rxjs.firstValueFrom)(
318
- injector.get(import_apollo_angular.Apollo).query({ query: GQL_INIT_SETTINGS })
319
- );
320
- const settings = res.data.initSettings;
321
- _settingsSignal.set(settings);
322
- _initialized = true;
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
- async init(force = false) {
339
- if (_initialized && !force) {
340
- return;
378
+ init: (force = false) => {
379
+ if (force) {
380
+ _initPromise = null;
381
+ _initialized = false;
341
382
  }
342
- _initialized = true;
343
- return;
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
- modules.init ?? (modules.init = async (force = false) => {
358
- const entries = Object.entries(modules).filter(([key]) => key !== "init");
359
- return Object.fromEntries(await Promise.all(
360
- entries.map(async ([key, mod]) => {
361
- const maybeInit = mod.init;
362
- try {
363
- return [key, await maybeInit(force)];
364
- } catch (err) {
365
- console.error(err);
366
- return [key, null];
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: async (force = false) => {
107
- if (_initialized && !force) {
108
- return;
107
+ init: (force = false) => {
108
+ if (force) {
109
+ _initPromise = null;
110
+ _initialized = false;
109
111
  }
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);
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: async (force = false) => {
149
- if (_initialized && !force) {
150
- return;
156
+ init: (force = false) => {
157
+ if (force) {
158
+ _initPromise = null;
159
+ _initialized = false;
151
160
  }
152
- try {
153
- const userData = await module.loadUserData();
154
- _user.set(userData ?? null);
155
- _initialized = true;
156
- } catch (err) {
157
- console.error(err);
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
- async init(force = false) {
196
- if (_initialized && !force) {
197
- return;
210
+ init: (force = false) => {
211
+ if (force) {
212
+ _initPromise = null;
213
+ _initialized = false;
198
214
  }
199
- try {
200
- await geex.tenant.init();
201
- await geex.auth.init();
202
- await new Promise((resolve, reject) => {
203
- const orgs$ = injector.get(Apollo).watchQuery({ query: GQL_ORGS_CACHE }).valueChanges.pipe(map((res) => deepCopy(res.data.orgs.items)));
204
- orgs$.subscribe({
205
- next: (orgs) => {
206
- runInInjectionContext(injector, () => {
207
- _orgsSignal.set(orgs);
208
- const userData = geex.auth.user();
209
- let allOwned = [];
210
- if (orgs?.length && userData) {
211
- if (userData.id === "000000000000000000000001") {
212
- allOwned = deepCopy(orgs);
213
- } else {
214
- const ownedCodes = userData.orgs.map((x) => x.code);
215
- allOwned = orgs.filter((o) => ownedCodes.some((code) => o.code.startsWith(code)));
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
- error: (err) => {
223
- console.error(err);
224
- reject(err);
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
- async init(force = false) {
240
- if (_initialized && !force) {
241
- return;
261
+ init: (force = false) => {
262
+ if (force) {
263
+ _initPromise = null;
264
+ _initialized = false;
242
265
  }
243
- try {
244
- await geex.auth.init();
245
- if (injector.get(OAuthService).hasValidAccessToken()) {
246
- const subClient = injector.get(Apollo).use("subscription");
247
- subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe(map((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
248
- module.onPublicNotify(notify);
249
- });
250
- }
251
- _initialized = true;
252
- } catch (err) {
253
- console.error(err);
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
- async init(force = false) {
268
- if (_initialized && !force) {
269
- return;
296
+ init: (force = false) => {
297
+ if (force) {
298
+ _initPromise = null;
299
+ _initialized = false;
270
300
  }
271
- const res = await firstValueFrom(
272
- injector.get(Apollo).query({ query: GQL_INIT_SETTINGS })
273
- );
274
- const settings = res.data.initSettings;
275
- _settingsSignal.set(settings);
276
- _initialized = true;
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
- async init(force = false) {
293
- if (_initialized && !force) {
294
- return;
332
+ init: (force = false) => {
333
+ if (force) {
334
+ _initPromise = null;
335
+ _initialized = false;
295
336
  }
296
- _initialized = true;
297
- return;
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
- modules.init ?? (modules.init = async (force = false) => {
312
- const entries = Object.entries(modules).filter(([key]) => key !== "init");
313
- return Object.fromEntries(await Promise.all(
314
- entries.map(async ([key, mod]) => {
315
- const maybeInit = mod.init;
316
- try {
317
- return [key, await maybeInit(force)];
318
- } catch (err) {
319
- console.error(err);
320
- return [key, null];
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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geexcode/geex-angular",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "description": "Angular adapter for Geex core.",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.cjs",