@geexcode/geex-angular 0.0.38 → 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: Promise<{
108
+ init: (force?: boolean) => Promise<{
109
109
  [K in keyof GeexModules<TExtensionModules>]: any;
110
110
  }>;
111
111
  tenant: TenantModule;
@@ -120,10 +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
- * 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.
123
+ * @param force - If true, forces re-initialization. Defaults to false.
124
+ * When force is false, multiple calls will share the same initialization Promise.
125
125
  */
126
- init: Promise<any>;
126
+ init: (force?: boolean) => Promise<any>;
127
127
  } & TExtension;
128
128
  declare function createTenantModule(injector: Injector): TenantModule;
129
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: Promise<{
108
+ init: (force?: boolean) => Promise<{
109
109
  [K in keyof GeexModules<TExtensionModules>]: any;
110
110
  }>;
111
111
  tenant: TenantModule;
@@ -120,10 +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
- * 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.
123
+ * @param force - If true, forces re-initialization. Defaults to false.
124
+ * When force is false, multiple calls will share the same initialization Promise.
125
125
  */
126
- init: Promise<any>;
126
+ init: (force?: boolean) => Promise<any>;
127
127
  } & TExtension;
128
128
  declare function createTenantModule(injector: Injector): TenantModule;
129
129
  declare function createAuthModule(injector: Injector): AuthModule;
package/dist/index.js CHANGED
@@ -150,7 +150,11 @@ function createTenantModule(injector) {
150
150
  let _initialized = false;
151
151
  let _initPromise = null;
152
152
  const module2 = {
153
- get init() {
153
+ init: (force = false) => {
154
+ if (force) {
155
+ _initPromise = null;
156
+ _initialized = false;
157
+ }
154
158
  if (!_initPromise) {
155
159
  _initPromise = (async () => {
156
160
  try {
@@ -195,7 +199,11 @@ function createAuthModule(injector) {
195
199
  let _initialized = false;
196
200
  let _initPromise = null;
197
201
  const module2 = {
198
- get init() {
202
+ init: (force = false) => {
203
+ if (force) {
204
+ _initPromise = null;
205
+ _initialized = false;
206
+ }
199
207
  if (!_initPromise) {
200
208
  _initPromise = (async () => {
201
209
  try {
@@ -245,12 +253,16 @@ function createIdentityModule(injector) {
245
253
  const module2 = {
246
254
  orgs: guardedSignal(_orgsSignal, () => _initialized),
247
255
  userOwnedOrgs: guardedSignal(_userOwnedOrgsSignal, () => _initialized),
248
- get init() {
256
+ init: (force = false) => {
257
+ if (force) {
258
+ _initPromise = null;
259
+ _initialized = false;
260
+ }
249
261
  if (!_initPromise) {
250
262
  _initPromise = (async () => {
251
263
  try {
252
- await geex.tenant.init;
253
- await geex.auth.init;
264
+ await geex.tenant.init();
265
+ await geex.auth.init();
254
266
  await new Promise((resolve, reject) => {
255
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)));
256
268
  orgs$.subscribe({
@@ -292,11 +304,15 @@ function createMessagingModule(injector) {
292
304
  let _initialized = false;
293
305
  let _initPromise = null;
294
306
  const module2 = {
295
- get init() {
307
+ init: (force = false) => {
308
+ if (force) {
309
+ _initPromise = null;
310
+ _initialized = false;
311
+ }
296
312
  if (!_initPromise) {
297
313
  _initPromise = (async () => {
298
314
  try {
299
- await geex.auth.init;
315
+ await geex.auth.init();
300
316
  if (injector.get(import_angular_oauth2_oidc.OAuthService).hasValidAccessToken()) {
301
317
  const subClient = injector.get(import_apollo_angular.Apollo).use("subscription");
302
318
  subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe((0, import_rxjs.map)((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
@@ -323,7 +339,11 @@ function createSettingsModule(injector) {
323
339
  let _initPromise = null;
324
340
  const module2 = {
325
341
  settings: guardedSignal(_settingsSignal, () => _initialized),
326
- get init() {
342
+ init: (force = false) => {
343
+ if (force) {
344
+ _initPromise = null;
345
+ _initialized = false;
346
+ }
327
347
  if (!_initPromise) {
328
348
  _initPromise = (async () => {
329
349
  try {
@@ -355,7 +375,11 @@ function createUiModule(injector) {
355
375
  fullScreen: guardedSignal(_fullScreenSignal, () => _initialized),
356
376
  isMobile: guardedSignal(_isMobile, () => _initialized),
357
377
  activeRoutedComponent: void 0,
358
- get init() {
378
+ init: (force = false) => {
379
+ if (force) {
380
+ _initPromise = null;
381
+ _initialized = false;
382
+ }
359
383
  if (!_initPromise) {
360
384
  _initPromise = (async () => {
361
385
  _initialized = true;
@@ -376,29 +400,28 @@ function configGeex(injector, overrides = {}) {
376
400
  ...overrides
377
401
  };
378
402
  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
- })();
397
- }
398
- return _initPromise;
399
- }
400
- });
401
- }
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;
424
+ });
402
425
  modules.tenant ?? (modules.tenant = createTenantModule(injector));
403
426
  modules.auth ?? (modules.auth = createAuthModule(injector));
404
427
  modules.identity ?? (modules.identity = createIdentityModule(injector));
package/dist/index.mjs CHANGED
@@ -104,7 +104,11 @@ function createTenantModule(injector) {
104
104
  let _initialized = false;
105
105
  let _initPromise = null;
106
106
  const module = {
107
- get init() {
107
+ init: (force = false) => {
108
+ if (force) {
109
+ _initPromise = null;
110
+ _initialized = false;
111
+ }
108
112
  if (!_initPromise) {
109
113
  _initPromise = (async () => {
110
114
  try {
@@ -149,7 +153,11 @@ function createAuthModule(injector) {
149
153
  let _initialized = false;
150
154
  let _initPromise = null;
151
155
  const module = {
152
- get init() {
156
+ init: (force = false) => {
157
+ if (force) {
158
+ _initPromise = null;
159
+ _initialized = false;
160
+ }
153
161
  if (!_initPromise) {
154
162
  _initPromise = (async () => {
155
163
  try {
@@ -199,12 +207,16 @@ function createIdentityModule(injector) {
199
207
  const module = {
200
208
  orgs: guardedSignal(_orgsSignal, () => _initialized),
201
209
  userOwnedOrgs: guardedSignal(_userOwnedOrgsSignal, () => _initialized),
202
- get init() {
210
+ init: (force = false) => {
211
+ if (force) {
212
+ _initPromise = null;
213
+ _initialized = false;
214
+ }
203
215
  if (!_initPromise) {
204
216
  _initPromise = (async () => {
205
217
  try {
206
- await geex.tenant.init;
207
- await geex.auth.init;
218
+ await geex.tenant.init();
219
+ await geex.auth.init();
208
220
  await new Promise((resolve, reject) => {
209
221
  const orgs$ = injector.get(Apollo).watchQuery({ query: GQL_ORGS_CACHE }).valueChanges.pipe(map((res) => deepCopy(res.data.orgs.items)));
210
222
  orgs$.subscribe({
@@ -246,11 +258,15 @@ function createMessagingModule(injector) {
246
258
  let _initialized = false;
247
259
  let _initPromise = null;
248
260
  const module = {
249
- get init() {
261
+ init: (force = false) => {
262
+ if (force) {
263
+ _initPromise = null;
264
+ _initialized = false;
265
+ }
250
266
  if (!_initPromise) {
251
267
  _initPromise = (async () => {
252
268
  try {
253
- await geex.auth.init;
269
+ await geex.auth.init();
254
270
  if (injector.get(OAuthService).hasValidAccessToken()) {
255
271
  const subClient = injector.get(Apollo).use("subscription");
256
272
  subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe(map((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
@@ -277,7 +293,11 @@ function createSettingsModule(injector) {
277
293
  let _initPromise = null;
278
294
  const module = {
279
295
  settings: guardedSignal(_settingsSignal, () => _initialized),
280
- get init() {
296
+ init: (force = false) => {
297
+ if (force) {
298
+ _initPromise = null;
299
+ _initialized = false;
300
+ }
281
301
  if (!_initPromise) {
282
302
  _initPromise = (async () => {
283
303
  try {
@@ -309,7 +329,11 @@ function createUiModule(injector) {
309
329
  fullScreen: guardedSignal(_fullScreenSignal, () => _initialized),
310
330
  isMobile: guardedSignal(_isMobile, () => _initialized),
311
331
  activeRoutedComponent: void 0,
312
- get init() {
332
+ init: (force = false) => {
333
+ if (force) {
334
+ _initPromise = null;
335
+ _initialized = false;
336
+ }
313
337
  if (!_initPromise) {
314
338
  _initPromise = (async () => {
315
339
  _initialized = true;
@@ -330,29 +354,28 @@ function configGeex(injector, overrides = {}) {
330
354
  ...overrides
331
355
  };
332
356
  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
- })();
351
- }
352
- return _initPromise;
353
- }
354
- });
355
- }
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;
378
+ });
356
379
  modules.tenant ?? (modules.tenant = createTenantModule(injector));
357
380
  modules.auth ?? (modules.auth = createAuthModule(injector));
358
381
  modules.identity ?? (modules.identity = createIdentityModule(injector));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geexcode/geex-angular",
3
- "version": "0.0.38",
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",