@wawjs/ngx-bos 22.0.2 → 22.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wawjs/ngx-bos",
3
- "version": "22.0.2",
3
+ "version": "22.0.3",
4
4
  "license": "MIT",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^22.0.0",
@@ -8,15 +8,15 @@
8
8
  "@angular/core": "^22.0.0",
9
9
  "@angular/forms": "^22.0.0",
10
10
  "@angular/router": "^22.0.0",
11
- "@wawjs/ngx-core": "^22.0.0",
12
- "@wawjs/ngx-crud": "^22.0.0",
13
- "@wawjs/ngx-ace": "^22.0.0",
14
- "@wawjs/ngx-fabric": "^22.0.0",
15
- "@wawjs/ngx-form": "^22.0.0",
16
- "@wawjs/ngx-http": "^22.0.0",
17
- "@wawjs/ngx-tinymce": "^22.0.0",
18
- "@wawjs/ngx-translate": "^22.0.0",
19
- "@wawjs/ngx-ui": "^22.0.0",
11
+ "@wawjs/ngx-core": "^22.0.3",
12
+ "@wawjs/ngx-crud": "^22.0.3",
13
+ "@wawjs/ngx-ace": "^22.0.3",
14
+ "@wawjs/ngx-fabric": "^22.0.3",
15
+ "@wawjs/ngx-form": "^22.0.3",
16
+ "@wawjs/ngx-http": "^22.0.3",
17
+ "@wawjs/ngx-tinymce": "^22.0.3",
18
+ "@wawjs/ngx-translate": "^22.0.3",
19
+ "@wawjs/ngx-ui": "^22.0.3",
20
20
  "libphonenumber-js": "^1.13.7"
21
21
  },
22
22
  "dependencies": {
@@ -1,4 +1,5 @@
1
- import { inject } from '@angular/core';
1
+ import { inject, PLATFORM_ID } from '@angular/core';
2
+ import { isPlatformBrowser } from '@angular/common';
2
3
  import { CanActivateFn, Router } from '@angular/router';
3
4
  import { NGX_BOS_CONFIG } from '../../../ngx-bos.config';
4
5
 
@@ -6,6 +7,11 @@ export const adminsGuard: CanActivateFn = () => {
6
7
  const router = inject(Router);
7
8
  const config = inject(NGX_BOS_CONFIG);
8
9
 
10
+ if (!isPlatformBrowser(inject(PLATFORM_ID))) {
11
+ // See authenticatedGuard — no real session at build/prerender time, defer to the client.
12
+ return true;
13
+ }
14
+
9
15
  const stored = localStorage.getItem('waw_user');
10
16
 
11
17
  if (!stored) {
@@ -1,4 +1,5 @@
1
- import { inject } from '@angular/core';
1
+ import { inject, PLATFORM_ID } from '@angular/core';
2
+ import { isPlatformBrowser } from '@angular/common';
2
3
  import { CanActivateFn, Router } from '@angular/router';
3
4
  import { NGX_BOS_CONFIG } from '../../../ngx-bos.config';
4
5
 
@@ -6,6 +7,13 @@ export const authenticatedGuard: CanActivateFn = () => {
6
7
  const router = inject(Router);
7
8
  const config = inject(NGX_BOS_CONFIG);
8
9
 
10
+ if (!isPlatformBrowser(inject(PLATFORM_ID))) {
11
+ // No real session exists at build/prerender time — render the shell and let the client
12
+ // re-check against the real localStorage after hydration, instead of baking a redirect
13
+ // stub into the static file (which would bounce an already-authenticated user on reload).
14
+ return true;
15
+ }
16
+
9
17
  if (localStorage.getItem('waw_user')) {
10
18
  return true;
11
19
  }
@@ -1,4 +1,5 @@
1
- import { inject } from '@angular/core';
1
+ import { inject, PLATFORM_ID } from '@angular/core';
2
+ import { isPlatformBrowser } from '@angular/common';
2
3
  import { CanActivateFn, Router } from '@angular/router';
3
4
  import { NGX_BOS_CONFIG } from '../../../ngx-bos.config';
4
5
 
@@ -6,7 +7,7 @@ export const guestGuard: CanActivateFn = () => {
6
7
  const router = inject(Router);
7
8
  const config = inject(NGX_BOS_CONFIG);
8
9
 
9
- if (localStorage.getItem('waw_user')) {
10
+ if (isPlatformBrowser(inject(PLATFORM_ID)) && localStorage.getItem('waw_user')) {
10
11
  return router.parseUrl(config.profilePath);
11
12
  }
12
13
 
@@ -1,4 +1,5 @@
1
- import { Service, computed, inject, signal } from '@angular/core';
1
+ import { Service, computed, inject, PLATFORM_ID, signal } from '@angular/core';
2
+ import { isPlatformBrowser } from '@angular/common';
2
3
  import { Router } from '@angular/router';
3
4
  import { AlertService } from '@wawjs/ngx-ui';
4
5
  import { CrudService } from '@wawjs/ngx-crud';
@@ -18,6 +19,8 @@ export class UserService extends CrudService<User> {
18
19
 
19
20
  private readonly _bosConfig = inject(NGX_BOS_CONFIG);
20
21
 
22
+ private readonly _isBrowserPlatform = isPlatformBrowser(inject(PLATFORM_ID));
23
+
21
24
  readonly url = this._bosConfig.url;
22
25
 
23
26
  roles = this._bosConfig.roles.concat(['admin']);
@@ -26,9 +29,11 @@ export class UserService extends CrudService<User> {
26
29
 
27
30
  readonly users = this.documents;
28
31
 
32
+ private readonly _storedUser = this._isBrowserPlatform ? localStorage.getItem('waw_user') : null;
33
+
29
34
  user = signal<User>(
30
- localStorage.getItem('waw_user')
31
- ? JSON.parse(localStorage.getItem('waw_user') as string)
35
+ this._storedUser
36
+ ? JSON.parse(this._storedUser)
32
37
  : this.prepareDocument()(),
33
38
  );
34
39
 
@@ -81,7 +86,7 @@ export class UserService extends CrudService<User> {
81
86
  },
82
87
  });
83
88
 
84
- if (localStorage.getItem('waw_user')) {
89
+ if (this._isBrowserPlatform && localStorage.getItem('waw_user')) {
85
90
  this.fetch({}, { name: 'me' }).subscribe((user: User) => {
86
91
  if (user) {
87
92
  if (
@@ -6,10 +6,10 @@ import { Component, input } from '@angular/core';
6
6
  styleUrl: './spider.component.scss',
7
7
  host: {
8
8
  class: 'spider',
9
- '[style.--spider-w]': 'width',
10
- '[style.--spider-h]': 'height',
11
- '[style.--spider-start]': 'start',
12
- '[style.--spider-end]': 'end',
9
+ '[style.--spider-w]': 'width()',
10
+ '[style.--spider-h]': 'height()',
11
+ '[style.--spider-start]': 'start()',
12
+ '[style.--spider-end]': 'end()',
13
13
  },
14
14
  })
15
15
  export class SpiderComponent {
@@ -27,7 +27,7 @@ export const DEFAULT_NGX_BOS_CONFIG: Required<NgxBosConfig> = {
27
27
  userForm: [],
28
28
  signPath: '/sign',
29
29
  profilePath: '/profile',
30
- defaultUserThumb: 'assets/default.png',
30
+ defaultUserThumb: 'default.png',
31
31
  };
32
32
 
33
33
  export const NGX_BOS_CONFIG = new InjectionToken<Required<NgxBosConfig>>(
@@ -197,10 +197,12 @@ declare class UserService extends CrudService<User> {
197
197
  private readonly _router;
198
198
  private readonly _emitterService;
199
199
  private readonly _bosConfig;
200
+ private readonly _isBrowserPlatform;
200
201
  readonly url: string;
201
202
  roles: string[];
202
203
  employees: string[];
203
204
  readonly users: _angular_core.Signal<User[]>;
205
+ private readonly _storedUser;
204
206
  user: _angular_core.WritableSignal<User>;
205
207
  thumb: _angular_core.Signal<string>;
206
208
  role(role: string): boolean;