@softpak/components 20.11.0 → 20.12.0-beta.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.
@@ -1,38 +1,28 @@
1
- import * as i2 from '@angular/router';
2
1
  import { Router } from '@angular/router';
3
2
  import * as i0 from '@angular/core';
4
3
  import { inject, ChangeDetectionStrategy, Component, Injectable } from '@angular/core';
5
4
  import { SpxStorage, SpxStorageKeyEnum } from '@softpak/components/spx-storage';
6
- import { createAction, props, union, createFeature, createReducer, on, Store } from '@ngrx/store';
7
- import { SpxButtonComponent } from '@softpak/components/spx-button';
8
- import { SpxAppChannelTypeEnum } from '@softpak/components/spx-app-configuration';
9
5
  import { Capacitor } from '@capacitor/core';
10
- import { TranslatePipe } from '@ngx-translate/core';
6
+ import { NavController } from '@ionic/angular';
7
+ import { SpxButtonComponent } from '@softpak/components/spx-button';
11
8
  import { SpxCapitalizePipe } from '@softpak/components/spx-capitalize';
9
+ import { createActionGroup, props, createFeature, createReducer, on, Store } from '@ngrx/store';
10
+ import { TranslatePipe } from '@ngx-translate/core';
11
+ import { map } from 'rxjs';
12
+ import { SpxAppChannelTypeEnum } from '@softpak/components/spx-app-configuration';
12
13
  import { spxTextChange } from '@softpak/components/spx-translate';
13
- import { NavController } from '@ionic/angular';
14
14
  import { toSignal } from '@angular/core/rxjs-interop';
15
- import { map } from 'rxjs';
16
- import * as i1 from '@ngrx/effects';
17
- import { createEffect, ofType } from '@ngrx/effects';
18
- import { switchMap } from 'rxjs/operators';
19
- import { setConfig } from '@capacitor/live-updates';
20
- import { spxUpdateUrl } from '@softpak/components/spx-update';
15
+ import { Actions, createEffect, ofType } from '@ngrx/effects';
21
16
  import { spxToasterActions, SpxToasterAutoCloseSpeedEnum } from '@softpak/components/spx-toaster';
22
- import { captureMessage } from '@sentry/angular';
23
- import { App } from '@capacitor/app';
24
-
25
- const choose = createAction('[SPX / Channel] Select', props());
26
- const initialize = createAction('[SPX / Channel] Initialize', props());
27
- const all = union({
28
- choose,
29
- initialize,
30
- });
17
+ import { spxUpdateUrl } from '@softpak/components/spx-update';
18
+ import { switchMap } from 'rxjs/operators';
31
19
 
32
- var spxChannel_actions = /*#__PURE__*/Object.freeze({
33
- __proto__: null,
34
- choose: choose,
35
- initialize: initialize
20
+ const SpxChannelActions = createActionGroup({
21
+ source: 'SpxChannel',
22
+ events: {
23
+ Choose: props(),
24
+ Initialize: props(),
25
+ },
36
26
  });
37
27
 
38
28
  const initialState = {
@@ -68,7 +58,7 @@ const determineActiveChannel = (channels) => {
68
58
  };
69
59
  var spxChannelReducer$1 = createFeature({
70
60
  name: 'spxChannel',
71
- reducer: createReducer(initialState, on(choose, (state, { channel, channelType }) => {
61
+ reducer: createReducer(initialState, on(SpxChannelActions.choose, (state, { channel, channelType }) => {
72
62
  SpxStorage.setSetting(SpxStorageKeyEnum.brand, channel?.brand);
73
63
  SpxStorage.setSetting(SpxStorageKeyEnum.channelType, channelType);
74
64
  return {
@@ -76,7 +66,7 @@ var spxChannelReducer$1 = createFeature({
76
66
  previousChannel: state.channel,
77
67
  channel,
78
68
  };
79
- }), on(initialize, (state, { channels }) => {
69
+ }), on(SpxChannelActions.initialize, (state, { channels }) => {
80
70
  let channelType = null;
81
71
  if (SpxStorage.getSetting(SpxStorageKeyEnum.channelType)) {
82
72
  channelType = { name: SpxStorage.getSetting(SpxStorageKeyEnum.channelType) };
@@ -104,7 +94,7 @@ class SpxChannelIndicatorComponent {
104
94
  constructor() {
105
95
  this.navController = inject(NavController);
106
96
  this.store = inject(Store);
107
- this.channel = toSignal(this.store.select(spxChannelReducer$1.selectChannel));
97
+ this.channel = this.store.selectSignal(spxChannelReducer$1.selectChannel);
108
98
  this.channelType = toSignal(this.store.select(spxChannelReducer$1.selectChannelType).pipe(map(channelType => channelType?.name)));
109
99
  this.spxTextChange = spxTextChange;
110
100
  }
@@ -149,11 +139,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImpor
149
139
  }] });
150
140
 
151
141
  class Effects {
152
- constructor(actions$, router) {
153
- this.actions$ = actions$;
154
- this.router = router;
155
- this.store = inject(Store);
156
- this.onChoose$ = createEffect(() => this.actions$.pipe(ofType(choose), switchMap((action) => {
142
+ constructor() {
143
+ this.actions$ = inject(Actions);
144
+ this.router = inject(Router);
145
+ this.onChoose$ = createEffect(() => this.actions$.pipe(ofType(SpxChannelActions.choose), switchMap((action) => {
157
146
  if (Capacitor.getPlatform() === 'web') {
158
147
  const channelType = action.channel.channelTypes.find(channelType => channelType.name === action.channelType);
159
148
  if (channelType.webUrl && !window.location.href.includes('http://localhost') && window.location.href.replace(channelType.webUrl, '').replace(channelType.oldWebUrl, '').split('/').at(0) !== '') {
@@ -164,16 +153,7 @@ class Effects {
164
153
  }
165
154
  }
166
155
  else {
167
- App.getInfo().then((binaryInfo) => {
168
- const binaryVersionGroup = binaryInfo.version.substring(0, 3);
169
- setConfig({
170
- channel: `${action.channelType}-${binaryVersionGroup}.x`
171
- });
172
- this.router.navigate([spxUpdateUrl]);
173
- }).catch((err) => {
174
- captureMessage(`SPX Channel Error: ${JSON.stringify(err)}`);
175
- this.router.navigate([spxUpdateUrl]);
176
- });
156
+ this.router.navigate([spxUpdateUrl]);
177
157
  }
178
158
  return [spxToasterActions.createSuccess({
179
159
  autoClose: SpxToasterAutoCloseSpeedEnum.DEFAULT,
@@ -181,12 +161,12 @@ class Effects {
181
161
  })];
182
162
  })), { dispatch: true });
183
163
  }
184
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: Effects, deps: [{ token: i1.Actions }, { token: i2.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
164
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: Effects, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
185
165
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: Effects }); }
186
166
  }
187
167
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: Effects, decorators: [{
188
168
  type: Injectable
189
- }], ctorParameters: () => [{ type: i1.Actions }, { type: i2.Router }] });
169
+ }] });
190
170
 
191
171
  var spxChannel_effects = /*#__PURE__*/Object.freeze({
192
172
  __proto__: null,
@@ -197,5 +177,5 @@ var spxChannel_effects = /*#__PURE__*/Object.freeze({
197
177
  * Generated bundle index. Do not edit.
198
178
  */
199
179
 
200
- export { SpxChannelGuard, SpxChannelIndicatorComponent, spxChannel_actions as spxChannelActions, spxChannel_effects as spxChannelEffects, spxChannel_reducer as spxChannelReducer, spxChannelSelectionUrl };
180
+ export { SpxChannelActions, SpxChannelGuard, SpxChannelIndicatorComponent, spxChannel_effects as spxChannelEffects, spxChannel_reducer as spxChannelReducer, spxChannelSelectionUrl };
201
181
  //# sourceMappingURL=softpak-components-spx-channel-selection.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"softpak-components-spx-channel-selection.mjs","sources":["../../../../projects/softpak/components/spx-channel-selection/store/spx-channel.actions.ts","../../../../projects/softpak/components/spx-channel-selection/store/spx-channel.reducer.ts","../../../../projects/softpak/components/spx-channel-selection/src/spx-channel-indicator/spx-channel-indicator.component.ts","../../../../projects/softpak/components/spx-channel-selection/src/spx-channel-indicator/spx-channel-indicator.component.html","../../../../projects/softpak/components/spx-channel-selection/src/spx-channel-guard.ts","../../../../projects/softpak/components/spx-channel-selection/store/spx-channel.effects.ts","../../../../projects/softpak/components/spx-channel-selection/softpak-components-spx-channel-selection.ts"],"sourcesContent":["import { createAction, props, union } from '@ngrx/store';\nimport { SpxAppChannelI, SpxAppChannelTypeEnum } from '@softpak/components/spx-app-configuration';\n\nexport const choose = createAction('[SPX / Channel] Select', props<{\n channel: SpxAppChannelI;\n channelType: SpxAppChannelTypeEnum;\n}>());\nexport const initialize = createAction('[SPX / Channel] Initialize', props<{\n channels: SpxAppChannelI[];\n}>());\n\nconst all = union({\n choose,\n initialize,\n});\n\nexport type Actions = typeof all;\n","\nimport * as actions from './spx-channel.actions';\nimport { createFeature, createReducer, on } from '@ngrx/store';\nimport { SpxStorage, SpxStorageKeyEnum } from '@softpak/components/spx-storage';\nimport { SpxAppChannelI, SpxAppChannelTypeEnum, SpxChannelTypeI } from '@softpak/components/spx-app-configuration';\nimport { Capacitor } from '@capacitor/core';\n\nexport const initialState: StateI = {\n previousChannel: null,\n channel: null,\n channelType: null,\n channels: [],\n};\n\nexport interface StateI {\n previousChannel: SpxAppChannelI | null;\n channel: SpxAppChannelI | null;\n channels: SpxAppChannelI[];\n channelType: SpxChannelTypeI | null;\n}\n\nconst determineActiveChannel = (channels: SpxAppChannelI[]): SpxAppChannelI | null => {\n if (SpxStorage.getSetting(SpxStorageKeyEnum.brand) && SpxStorage.getSetting(SpxStorageKeyEnum.channelType)) {\n const channelResult = channels.find(channel => channel.brand === SpxStorage.getSetting(SpxStorageKeyEnum.brand) && channel.channelTypes.some((e: SpxChannelTypeI) => e.name === SpxStorage.getSetting(SpxStorageKeyEnum.channelType) as SpxAppChannelTypeEnum));\n if (channelResult) {\n return channelResult;\n } else {\n const defaultBrandResult = channels.find(channel => channel.default);\n if (defaultBrandResult) {\n return defaultBrandResult;\n } else {\n SpxStorage.clearSetting(SpxStorageKeyEnum.brand);\n return null;\n }\n }\n } else {\n const defaultBrandResult = channels.find(channel => channel.default);\n if (defaultBrandResult) {\n return defaultBrandResult;\n }\n return null;\n }\n}\n\nexport default createFeature({\n name: 'spxChannel',\n reducer: createReducer(\n initialState,\n on(actions.choose, (state, { channel, channelType }): StateI => {\n SpxStorage.setSetting<SpxStorageKeyEnum>(SpxStorageKeyEnum.brand, channel?.brand);\n SpxStorage.setSetting<SpxStorageKeyEnum>(SpxStorageKeyEnum.channelType, channelType);\n return {\n ...state,\n previousChannel: state.channel,\n channel,\n };\n }),\n on(actions.initialize, (state, { channels }): StateI => {\n\n let channelType: SpxChannelTypeI | null = null;\n\n if (SpxStorage.getSetting(SpxStorageKeyEnum.channelType)) {\n channelType = { name: SpxStorage.getSetting(SpxStorageKeyEnum.channelType) as SpxAppChannelTypeEnum };\n }\n else {\n channelType = { name: Capacitor.getPlatform() === 'web' ? SpxAppChannelTypeEnum.webLive : SpxAppChannelTypeEnum.production }; // Default to production if no type is set\n }\n\n return {\n ...state,\n channel: determineActiveChannel(channels),\n channels: channels.slice().sort((a, b) => a.brand.localeCompare(b.brand)),\n channelType: channelType,\n }\n }),\n ),\n});\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { Store } from '@ngrx/store';\nimport { SpxButtonComponent } from '@softpak/components/spx-button';\nimport spxChannelReducer from '../../store/spx-channel.reducer';\nimport { TranslatePipe } from '@ngx-translate/core';\nimport { SpxCapitalizePipe } from '@softpak/components/spx-capitalize';\nimport { spxTextChange } from '@softpak/components/spx-translate';\nimport { NavController } from '@ionic/angular';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { map } from 'rxjs';\nimport { Capacitor } from '@capacitor/core';\nexport const spxChannelSelectionUrl = 'wlc';\n\n@Component({\n selector: 'spx-channel-indicator',\n templateUrl: './spx-channel-indicator.component.html',\n imports: [\n SpxButtonComponent,\n SpxCapitalizePipe,\n TranslatePipe,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n standalone: true,\n})\nexport class SpxChannelIndicatorComponent {\n private readonly navController = inject(NavController);\n private readonly store = inject(Store);\n protected readonly channel = toSignal(this.store.select(spxChannelReducer.selectChannel));\n protected readonly channelType = toSignal(this.store.select(spxChannelReducer.selectChannelType).pipe(\n map(channelType => channelType?.name)\n ));\n protected readonly spxTextChange = spxTextChange;\n\n protected onChange() {\n this.navController.navigateRoot([spxChannelSelectionUrl]);\n }\n\n protected canShowChannelType() {\n return Capacitor.getPlatform() !== 'web';\n }\n}\n","<div class=\"bg-white p-3 rounded flex gap-3 items-center text-black\">\n <div class=\"grow\">\n <div class=\"text-lg font-bold\">{{ channel()?.brand }}</div>\n @if (canShowChannelType() && channelType() !== 'Production') {\n <div class=\"text-base text-gray-600\">{{ channelType() }}</div>\n }\n </div>\n <spx-button (click)=\"onChange()\" [spxType]=\"'button'\">{{ spxTextChange | translate | capitalize }}</spx-button>\n</div>","import { Router } from '@angular/router';\nimport { inject, Injectable } from '@angular/core';\nimport { SpxStorage, SpxStorageKeyEnum } from '@softpak/components/spx-storage';\nimport { spxChannelSelectionUrl } from './spx-channel-indicator/spx-channel-indicator.component';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SpxChannelGuard {\n\n private readonly router = inject(Router);\n\n canActivate(): boolean {\n if (\n !SpxStorage.getSetting<SpxStorageKeyEnum>(SpxStorageKeyEnum.brand) ||\n !SpxStorage.getSetting<SpxStorageKeyEnum>(SpxStorageKeyEnum.channelType)\n ) {\n this.router.navigate([spxChannelSelectionUrl]);\n return false;\n }\n return true;\n }\n}\n","import { Actions, createEffect, ofType } from '@ngrx/effects';\nimport { switchMap, withLatestFrom } from 'rxjs/operators';\nimport { inject, Injectable } from '@angular/core';\nimport * as actions from './spx-channel.actions';\nimport { setConfig } from '@capacitor/live-updates';\nimport { Capacitor } from '@capacitor/core';\nimport { Router } from '@angular/router';\nimport { spxUpdateUrl } from '@softpak/components/spx-update';\nimport { spxToasterActions, SpxToasterAutoCloseSpeedEnum } from '@softpak/components/spx-toaster';\nimport { captureMessage } from '@sentry/angular';\nimport { App } from '@capacitor/app';\nimport { Store } from '@ngrx/store';\n\n@Injectable()\nexport class Effects {\n store = inject(Store);\n\n onChoose$ =\n createEffect(() =>\n this.actions$.pipe(\n ofType(actions.choose),\n switchMap((action) => {\n if (Capacitor.getPlatform() === 'web') {\n const channelType = action.channel.channelTypes.find(channelType => channelType.name === action.channelType)!;\n if (channelType.webUrl && !window.location.href.includes('http://localhost') && window.location.href.replace(channelType.webUrl!,'').replace(channelType.oldWebUrl!,'').split('/').at(0) !== '') {\n window.location.href = channelType.webUrl!;\n } else {\n this.router.navigate(['tabs/hme']);\n }\n } else {\n App.getInfo().then((binaryInfo) => {\n const binaryVersionGroup = binaryInfo.version.substring(0, 3);\n setConfig({\n channel: `${action.channelType}-${binaryVersionGroup}.x`\n });\n this.router.navigate([spxUpdateUrl]);\n }).catch((err) => {\n captureMessage(`SPX Channel Error: ${JSON.stringify(err)}`);\n this.router.navigate([spxUpdateUrl]);\n });\n }\n\n return [spxToasterActions.createSuccess({\n autoClose: SpxToasterAutoCloseSpeedEnum.DEFAULT,\n messageText: action.channel?.brand,\n })];\n }),\n ), { dispatch: true });\n\n constructor(\n private readonly actions$: Actions,\n private readonly router: Router,\n ) { }\n}\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["actions.choose","actions.initialize","spxChannelReducer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,EAAE,KAAK,EAG9D,CAAC;AACE,MAAM,UAAU,GAAG,YAAY,CAAC,4BAA4B,EAAE,KAAK,EAEtE,CAAC;AAEL,MAAM,GAAG,GAAG,KAAK,CAAC;IACd,MAAM;IACN,UAAU;AACb,CAAA,CAAC;;;;;;;;ACPK,MAAM,YAAY,GAAW;AAClC,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,QAAQ,EAAE,EAAE;CACb;AASD,MAAM,sBAAsB,GAAG,CAAC,QAA0B,KAA2B;AACnF,IAAA,IAAI,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE;QAC1G,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,YAAY,C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AC/C,oBAAA,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK;AACrC,iBAAA,CAAC,CAAC;QACP,CAAC,CAAC,CACL,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAK1B;8GAtCK,OAAO,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,OAAA,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,MAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAAP,OAAO,EAAA,CAAA,CAAA;;2FAAP,OAAO,EAAA,UAAA,EAAA,CAAA;kBADnB;;;;;;;;ACbD;;AAEG;;;;"}
1
+ {"version":3,"file":"softpak-components-spx-channel-selection.mjs","sources":["../../../../projects/softpak/components/spx-channel-selection/store/spx-channel.actions.ts","../../../../projects/softpak/components/spx-channel-selection/store/spx-channel.reducer.ts","../../../../projects/softpak/components/spx-channel-selection/src/spx-channel-indicator/spx-channel-indicator.component.ts","../../../../projects/softpak/components/spx-channel-selection/src/spx-channel-indicator/spx-channel-indicator.component.html","../../../../projects/softpak/components/spx-channel-selection/src/spx-channel-guard.ts","../../../../projects/softpak/components/spx-channel-selection/store/spx-channel.effects.ts","../../../../projects/softpak/components/spx-channel-selection/softpak-components-spx-channel-selection.ts"],"sourcesContent":["import { SpxAppChannelI, SpxAppChannelTypeEnum } from '@softpak/components/spx-app-configuration';\nimport { createActionGroup, props } from '@ngrx/store';\n\nexport const SpxChannelActions = createActionGroup({\n source: 'SpxChannel',\n events: {\n Choose: props<{\n channel: SpxAppChannelI;\n channelType: SpxAppChannelTypeEnum;\n }>(),\n Initialize: props<{\n channels: SpxAppChannelI[];\n }>(),\n },\n});\n","import { SpxAppChannelI, SpxAppChannelTypeEnum, SpxChannelTypeI } from '@softpak/components/spx-app-configuration';\nimport { SpxStorage, SpxStorageKeyEnum } from '@softpak/components/spx-storage';\nimport { createFeature, createReducer, on } from '@ngrx/store';\n\nimport { Capacitor } from '@capacitor/core';\nimport { SpxChannelActions } from './spx-channel.actions';\n\nexport const initialState: StateI = {\n previousChannel: null,\n channel: null,\n channelType: null,\n channels: [],\n};\n\nexport interface StateI {\n previousChannel: SpxAppChannelI | null;\n channel: SpxAppChannelI | null;\n channels: SpxAppChannelI[];\n channelType: SpxChannelTypeI | null;\n}\n\nconst determineActiveChannel = (channels: SpxAppChannelI[]): SpxAppChannelI | null => {\n if (SpxStorage.getSetting(SpxStorageKeyEnum.brand) && SpxStorage.getSetting(SpxStorageKeyEnum.channelType)) {\n const channelResult = channels.find(channel => channel.brand === SpxStorage.getSetting(SpxStorageKeyEnum.brand) && channel.channelTypes.some((e: SpxChannelTypeI) => e.name === SpxStorage.getSetting(SpxStorageKeyEnum.channelType) as SpxAppChannelTypeEnum));\n if (channelResult) {\n return channelResult;\n } else {\n const defaultBrandResult = channels.find(channel => channel.default);\n if (defaultBrandResult) {\n return defaultBrandResult;\n } else {\n SpxStorage.clearSetting(SpxStorageKeyEnum.brand);\n return null;\n }\n }\n } else {\n const defaultBrandResult = channels.find(channel => channel.default);\n if (defaultBrandResult) {\n return defaultBrandResult;\n }\n return null;\n }\n}\n\nexport default createFeature({\n name: 'spxChannel',\n reducer: createReducer(\n initialState,\n on(SpxChannelActions.choose, (state, { channel, channelType }): StateI => {\n SpxStorage.setSetting<SpxStorageKeyEnum>(SpxStorageKeyEnum.brand, channel?.brand);\n SpxStorage.setSetting<SpxStorageKeyEnum>(SpxStorageKeyEnum.channelType, channelType);\n return {\n ...state,\n previousChannel: state.channel,\n channel,\n };\n }),\n on(SpxChannelActions.initialize, (state, { channels }): StateI => {\n\n let channelType: SpxChannelTypeI | null = null;\n\n if (SpxStorage.getSetting(SpxStorageKeyEnum.channelType)) {\n channelType = { name: SpxStorage.getSetting(SpxStorageKeyEnum.channelType) as SpxAppChannelTypeEnum };\n }\n else {\n channelType = { name: Capacitor.getPlatform() === 'web' ? SpxAppChannelTypeEnum.webLive : SpxAppChannelTypeEnum.production }; // Default to production if no type is set\n }\n\n return {\n ...state,\n channel: determineActiveChannel(channels),\n channels: channels.slice().sort((a, b) => a.brand.localeCompare(b.brand)),\n channelType: channelType,\n }\n }),\n ),\n});\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\n\nimport { Capacitor } from '@capacitor/core';\nimport { NavController } from '@ionic/angular';\nimport { SpxButtonComponent } from '@softpak/components/spx-button';\nimport { SpxCapitalizePipe } from '@softpak/components/spx-capitalize';\nimport { Store } from '@ngrx/store';\nimport { TranslatePipe } from '@ngx-translate/core';\nimport { map } from 'rxjs';\nimport spxChannelReducer from '../../store/spx-channel.reducer';\nimport { spxTextChange } from '@softpak/components/spx-translate';\nimport { toSignal } from '@angular/core/rxjs-interop';\n\nexport const spxChannelSelectionUrl = 'wlc';\n\n@Component({\n selector: 'spx-channel-indicator',\n templateUrl: './spx-channel-indicator.component.html',\n imports: [\n SpxButtonComponent,\n SpxCapitalizePipe,\n TranslatePipe,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n standalone: true,\n})\nexport class SpxChannelIndicatorComponent {\n private readonly navController = inject(NavController);\n private readonly store = inject(Store);\n protected readonly channel = this.store.selectSignal(spxChannelReducer.selectChannel);\n protected readonly channelType = toSignal(this.store.select(spxChannelReducer.selectChannelType).pipe(\n map(channelType => channelType?.name)\n ));\n protected readonly spxTextChange = spxTextChange;\n\n protected onChange() {\n this.navController.navigateRoot([spxChannelSelectionUrl]);\n }\n\n protected canShowChannelType() {\n return Capacitor.getPlatform() !== 'web';\n }\n}\n","<div class=\"bg-white p-3 rounded flex gap-3 items-center text-black\">\n <div class=\"grow\">\n <div class=\"text-lg font-bold\">{{ channel()?.brand }}</div>\n @if (canShowChannelType() && channelType() !== 'Production') {\n <div class=\"text-base text-gray-600\">{{ channelType() }}</div>\n }\n </div>\n <spx-button (click)=\"onChange()\" [spxType]=\"'button'\">{{ spxTextChange | translate | capitalize }}</spx-button>\n</div>","import { Router } from '@angular/router';\nimport { inject, Injectable } from '@angular/core';\nimport { SpxStorage, SpxStorageKeyEnum } from '@softpak/components/spx-storage';\nimport { spxChannelSelectionUrl } from './spx-channel-indicator/spx-channel-indicator.component';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SpxChannelGuard {\n\n private readonly router = inject(Router);\n\n canActivate(): boolean {\n if (\n !SpxStorage.getSetting<SpxStorageKeyEnum>(SpxStorageKeyEnum.brand) ||\n !SpxStorage.getSetting<SpxStorageKeyEnum>(SpxStorageKeyEnum.channelType)\n ) {\n this.router.navigate([spxChannelSelectionUrl]);\n return false;\n }\n return true;\n }\n}\n","import { Actions, createEffect, ofType } from '@ngrx/effects';\nimport { Injectable, inject } from '@angular/core';\nimport { SpxToasterAutoCloseSpeedEnum, spxToasterActions } from '@softpak/components/spx-toaster';\n\nimport { Capacitor } from '@capacitor/core';\nimport { Router } from '@angular/router';\nimport { SpxChannelActions } from './spx-channel.actions';\nimport { spxUpdateUrl } from '@softpak/components/spx-update';\nimport { switchMap } from 'rxjs/operators';\n\n@Injectable()\nexport class Effects {\n private readonly actions$ = inject(Actions);\n private readonly router = inject(Router);\n\n onChoose$ =\n createEffect(() =>\n this.actions$.pipe(\n ofType(SpxChannelActions.choose),\n switchMap((action) => {\n if (Capacitor.getPlatform() === 'web') {\n const channelType = action.channel.channelTypes.find(channelType => channelType.name === action.channelType)!;\n if (channelType.webUrl && !window.location.href.includes('http://localhost') && window.location.href.replace(channelType.webUrl!, '').replace(channelType.oldWebUrl!, '').split('/').at(0) !== '') {\n window.location.href = channelType.webUrl!;\n } else {\n this.router.navigate(['tabs/hme']);\n }\n } else {\n this.router.navigate([spxUpdateUrl]);\n }\n return [spxToasterActions.createSuccess({\n autoClose: SpxToasterAutoCloseSpeedEnum.DEFAULT,\n messageText: action.channel?.brand,\n })];\n }),\n ), { dispatch: true });\n}\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["spxChannelReducer"],"mappings":";;;;;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AAC,CAAC,YAAY,CAAC,CAAC;YACxC;AACA,YAAA,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC;oBACpC,SAAS,EAAE,4BAA4B,CAAC,OAAO;AAC/C,oBAAA,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK;AACrC,iBAAA,CAAC,CAAC;QACP,CAAC,CAAC,CACL,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACjC,IAAA;8GAzBY,OAAO,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAAP,OAAO,EAAA,CAAA,CAAA;;2FAAP,OAAO,EAAA,UAAA,EAAA,CAAA;kBADnB;;;;;;;;ACVD;;AAEG;;;;"}
@@ -8,6 +8,7 @@ var SpxStorageKeyEnum;
8
8
  SpxStorageKeyEnum["channelType"] = "channelType";
9
9
  SpxStorageKeyEnum["channelSettings"] = "companySettings";
10
10
  SpxStorageKeyEnum["liveUpdate"] = "liveUpdate";
11
+ SpxStorageKeyEnum["liveUpdateChannel"] = "liveUpdateChannel";
11
12
  SpxStorageKeyEnum["platform"] = "platform";
12
13
  SpxStorageKeyEnum["platformVersion"] = "platformVersion";
13
14
  SpxStorageKeyEnum["token"] = "token";
@@ -1 +1 @@
1
- {"version":3,"file":"softpak-components-spx-storage.mjs","sources":["../../../../projects/softpak/components/spx-storage/src/spx-storage-key.enum.ts","../../../../projects/softpak/components/spx-storage/src/spx-storage.class.ts","../../../../projects/softpak/components/spx-storage/softpak-components-spx-storage.ts"],"sourcesContent":["export enum SpxStorageKeyEnum {\n afterSignIn = 'afterSignIn',\n brand = 'brand',\n binaryVersionGroup = 'binaryVersionGroup',\n bundleVersion = 'bundleVersion',\n lastBinaryVersionGroup = 'lastBinaryVersionGroup',\n channelType = 'channelType',\n channelSettings = 'companySettings',\n liveUpdate = 'liveUpdate',\n platform = 'platform',\n platformVersion = 'platformVersion',\n token = 'token',\n updateInProgress = 'updateInProgress',\n randomDeviceId = 'randomDeviceId',\n release = 'release',\n patch = 'patch',\n username = 'username',\n};\n","import { SpxStorageKeyEnum } from './spx-storage-key.enum';\n\nexport class SpxStorage {\n private static get channelId() {\n return `${this.getSetting(SpxStorageKeyEnum.brand)?.toUpperCase()}_${this.getSetting(SpxStorageKeyEnum.channelType)?.toUpperCase()}`;\n }\n\n public static clearSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): void {\n localStorage.removeItem(key as string);\n }\n\n public static getSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): string | null {\n return localStorage.getItem(key as string);\n }\n\n public static setSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum, settingValue: string): void {\n localStorage.setItem(key as string, settingValue);\n }\n\n public static getChannelSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): string | undefined {\n let storageObj;\n const storageObjStr = localStorage.getItem(SpxStorageKeyEnum.channelSettings);\n\n if (storageObjStr) {\n storageObj = JSON.parse(storageObjStr);\n if (!storageObj[this.channelId]) {\n return undefined;\n }\n return storageObj[this.channelId][key];\n } else {\n return undefined;\n }\n }\n\n public static setChannelSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum, settingValue: any): void {\n const companySettings = this.getSetting(SpxStorageKeyEnum.channelSettings);\n let storageObj;\n\n if (companySettings) {\n storageObj = JSON.parse(companySettings);\n } else {\n storageObj = {};\n }\n\n if (!storageObj[this.channelId]) {\n storageObj[this.channelId] = {};\n }\n\n storageObj[this.channelId][key] = settingValue;\n this.setSetting(SpxStorageKeyEnum.channelSettings, JSON.stringify(storageObj));\n }\n}\n\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IAAY;AAAZ,CAAA,UAAY,iBAAiB,EAAA;AACzB,IAAA,iBAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA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ts","../../../../projects/softpak/components/spx-storage/src/spx-storage.class.ts","../../../../projects/softpak/components/spx-storage/softpak-components-spx-storage.ts"],"sourcesContent":["export enum SpxStorageKeyEnum {\n afterSignIn = 'afterSignIn',\n brand = 'brand',\n binaryVersionGroup = 'binaryVersionGroup',\n bundleVersion = 'bundleVersion',\n lastBinaryVersionGroup = 'lastBinaryVersionGroup',\n channelType = 'channelType',\n channelSettings = 'companySettings',\n liveUpdate = 'liveUpdate',\n liveUpdateChannel = 'liveUpdateChannel',\n platform = 'platform',\n platformVersion = 'platformVersion',\n token = 'token',\n updateInProgress = 'updateInProgress',\n randomDeviceId = 'randomDeviceId',\n release = 'release',\n patch = 'patch',\n username = 'username',\n};\n","import { SpxStorageKeyEnum } from './spx-storage-key.enum';\n\nexport class SpxStorage {\n private static get channelId() {\n return `${this.getSetting(SpxStorageKeyEnum.brand)?.toUpperCase()}_${this.getSetting(SpxStorageKeyEnum.channelType)?.toUpperCase()}`;\n }\n\n public static clearSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): void {\n localStorage.removeItem(key as string);\n }\n\n public static getSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): string | null {\n return localStorage.getItem(key as string);\n }\n\n public static setSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum, settingValue: string): void {\n localStorage.setItem(key as string, settingValue);\n }\n\n public static getChannelSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): string | undefined {\n let storageObj;\n const storageObjStr = localStorage.getItem(SpxStorageKeyEnum.channelSettings);\n\n if (storageObjStr) {\n storageObj = JSON.parse(storageObjStr);\n if (!storageObj[this.channelId]) {\n return undefined;\n }\n return storageObj[this.channelId][key];\n } else {\n return undefined;\n }\n }\n\n public static setChannelSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum, settingValue: any): void {\n const companySettings = this.getSetting(SpxStorageKeyEnum.channelSettings);\n let storageObj;\n\n if (companySettings) {\n storageObj = JSON.parse(companySettings);\n } else {\n storageObj = {};\n }\n\n if (!storageObj[this.channelId]) {\n storageObj[this.channelId] = {};\n }\n\n storageObj[this.channelId][key] = settingValue;\n this.setSetting(SpxStorageKeyEnum.channelSettings, JSON.stringify(storageObj));\n }\n}\n\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IAAY;AAAZ,CAAA,UAAY,iBAAiB,EAAA;AACzB,IAAA,iBAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,iBAAA,CAAA,oBAAA,CAAA,GAAA,oBAAyC;AACzC,IAAA,iBAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,iBAAA,CAAA,wBAAA,CAAA,GAAA,wBAAiD;AACjD,IAAA,iBAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,iBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC;AACnC,IAAA,iBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,iBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,iBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACrB,IAAA,iBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC;AACnC,IAAA,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,iBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,iBAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC;AACjC,IAAA,iBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,iBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACzB,CAAC,EAlBW,iBAAiB,KAAjB,iBAAiB,GAAA,EAAA,CAAA,CAAA;AAkB5B;;MChBY,UAAU,CAAA;AACX,IAAA,W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EA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;AAC7B,YAAA,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;QACnC;QAEA,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,YAAY;AAC9C,QAAA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAClF;AACH;;ACnDD;;AAEG;;;;"}
@@ -1,54 +1,39 @@
1
+ import * as i3 from '@ionic/angular/standalone';
2
+ import { IonContent, IonHeader, IonToolbar, IonTitle } from '@ionic/angular/standalone';
3
+ import { spxTextCheckingForUpdates, spxTextOneMomentPlease, spxTextUpdate, spxTextReadyToBeInstalled, spxTextPatchAvailable, spxTextUpdateAvailable, spxTextOpenAppStore } from '@softpak/components/spx-translate';
1
4
  import * as i0 from '@angular/core';
2
5
  import { Component, signal, HostBinding, ChangeDetectionStrategy, inject, Injectable } from '@angular/core';
6
+ import { SpxCapitalizePipe } from '@softpak/components/spx-capitalize';
3
7
  import { TranslatePipe } from '@ngx-translate/core';
4
- import * as i3 from '@ionic/angular/standalone';
5
- import { IonContent, IonHeader, IonToolbar, IonTitle } from '@ionic/angular/standalone';
8
+ import { unsubscribeSubscriptions, SpxSeverityEnum } from '@softpak/components/spx-helpers';
6
9
  import * as i1 from '@ngrx/store';
7
- import { createAction, props, union, createFeature, createReducer, on } from '@ngrx/store';
10
+ import { createActionGroup, props, emptyProps, createFeature, createReducer, on } from '@ngrx/store';
8
11
  import { DateTime } from 'luxon';
9
- import { unsubscribeSubscriptions, SpxSeverityEnum } from '@softpak/components/spx-helpers';
10
- import { SpxCapitalizePipe } from '@softpak/components/spx-capitalize';
11
- import { spxTextCheckingForUpdates, spxTextOneMomentPlease, spxTextUpdate, spxTextReadyToBeInstalled, spxTextPatchAvailable, spxTextUpdateAvailable, spxTextOpenAppStore } from '@softpak/components/spx-translate';
12
12
  import * as i2 from '@angular/router';
13
13
  import { SpxButtonComponent } from '@softpak/components/spx-button';
14
14
  import * as i2$1 from '@angular/platform-browser';
15
15
  import * as i1$1 from '@ngrx/effects';
16
16
  import { Actions, createEffect, ofType } from '@ngrx/effects';
17
+ import { LiveUpdate } from '@capawesome/capacitor-live-update';
17
18
  import { from, of } from 'rxjs';
18
19
  import { SpxStorage, SpxStorageKeyEnum } from '@softpak/components/spx-storage';
19
- import { getConfig, setConfig, sync, reload } from '@capacitor/live-updates';
20
20
  import { delay, mergeMap, tap, exhaustMap, map, catchError } from 'rxjs/operators';
21
21
  import { App } from '@capacitor/app';
22
22
  import { Capacitor } from '@capacitor/core';
23
23
  import { SpxAppChannelTypeEnum } from '@softpak/components/spx-app-configuration';
24
24
  import { captureMessage } from '@sentry/angular';
25
25
 
26
- const anUpdateIsReady = createAction('[SPX / Update Check] An update is ready', props());
27
- const clearError = createAction('[SPX / Update Check] Clear error', props());
28
- const checkFailed = createAction('[SPX / Update Check] Error happened', props());
29
- const initialize = createAction('[SPX / Update Check] Initialize', props());
30
- const noUpdateWasFound = createAction('[SPX / Update Check] No update was found', props());
31
- const notAvailableOnWeb = createAction('[SPX / Update Check] Not available on web', props());
32
- const runCheck = createAction('[SPX / Update Check] Run', props());
33
- const all$1 = union({
34
- anUpdateIsReady,
35
- clearError,
36
- checkFailed,
37
- initialize,
38
- noUpdateWasFound,
39
- notAvailableOnWeb,
40
- runCheck,
41
- });
42
-
43
- var spxUpdateCheck_actions = /*#__PURE__*/Object.freeze({
44
- __proto__: null,
45
- anUpdateIsReady: anUpdateIsReady,
46
- checkFailed: checkFailed,
47
- clearError: clearError,
48
- initialize: initialize,
49
- noUpdateWasFound: noUpdateWasFound,
50
- notAvailableOnWeb: notAvailableOnWeb,
51
- runCheck: runCheck
26
+ const SpxUpdateCheckActions = createActionGroup({
27
+ source: 'SpxUpdateCheck',
28
+ events: {
29
+ AnUpdateIsReady: emptyProps(),
30
+ ClearError: emptyProps(),
31
+ CheckFailed: props(),
32
+ Initialaize: emptyProps(),
33
+ NoUpdateWasFound: props(),
34
+ NotAvailableOnWeb: emptyProps(),
35
+ RunCheck: props(),
36
+ },
52
37
  });
53
38
 
54
39
  const initialState$1 = {
@@ -64,36 +49,36 @@ var spxUpdateCheck_initial = /*#__PURE__*/Object.freeze({
64
49
 
65
50
  var updCheck = createFeature({
66
51
  name: 'spxUpdateCheck',
67
- reducer: createReducer(initialState$1, on(anUpdateIsReady, (state) => {
52
+ reducer: createReducer(initialState$1, on(SpxUpdateCheckActions.anUpdateIsReady, (state) => {
68
53
  return {
69
54
  ...state,
70
55
  lastCheck: DateTime.now().toISO(),
71
56
  showError: false,
72
57
  };
73
- }), on(clearError, (state) => {
58
+ }), on(SpxUpdateCheckActions.clearError, (state) => {
74
59
  return {
75
60
  ...state,
76
61
  showError: false,
77
62
  };
78
- }), on(checkFailed, (state) => {
63
+ }), on(SpxUpdateCheckActions.checkFailed, (state) => {
79
64
  return {
80
65
  ...state,
81
66
  forceWaitForUpdate: false,
82
67
  showError: true,
83
68
  };
84
- }), on(noUpdateWasFound, (state) => {
69
+ }), on(SpxUpdateCheckActions.noUpdateWasFound, (state) => {
85
70
  return {
86
71
  ...state,
87
72
  forceWaitForUpdate: false,
88
73
  lastCheck: DateTime.now().toISO(),
89
74
  showError: false,
90
75
  };
91
- }), on(runCheck, (state, { forceWaitForUpdate }) => {
76
+ }), on(SpxUpdateCheckActions.runCheck, (state, { forceWaitForUpdate }) => {
92
77
  return {
93
78
  ...state,
94
79
  forceWaitForUpdate: forceWaitForUpdate ? true : state.forceWaitForUpdate
95
80
  };
96
- }), on(notAvailableOnWeb, (state) => {
81
+ }), on(SpxUpdateCheckActions.notAvailableOnWeb, (state) => {
97
82
  return {
98
83
  ...state,
99
84
  forceWaitForUpdate: false
@@ -108,7 +93,7 @@ var spxUpdateCheck_reducer = /*#__PURE__*/Object.freeze({
108
93
 
109
94
  class SpxUpdatePageComponent {
110
95
  ngOnInit() {
111
- this.appStore.dispatch(runCheck({ forceWaitForUpdate: true }));
96
+ this.appStore.dispatch(SpxUpdateCheckActions.runCheck({ forceWaitForUpdate: true }));
112
97
  this.subscriptions.updCheck = this.appStore.select(updCheck.selectForceWaitForUpdate).subscribe(forceWaitForUpdate => {
113
98
  if (forceWaitForUpdate === false) {
114
99
  if (this.activatedRoute.snapshot.data['url'] === undefined) {
@@ -144,26 +129,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImpor
144
129
  ], standalone: true, template: "<ion-header>\n <ion-toolbar>\n <ion-title>\n {{ spxTextCheckingForUpdates | translate | capitalize }}\n </ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"ion-padding\">\n {{ spxTextOneMomentPlease | translate | capitalize }}...\n</ion-content>\n" }]
145
130
  }], ctorParameters: () => [{ type: i1.Store }, { type: i2.ActivatedRoute }, { type: i3.NavController }] });
146
131
 
147
- const acceptUpdate = createAction('[SPX / Update Pending] Accept update', props());
148
- const hasBeenDownloaded = createAction('[SPX / Update Pending] Has been downloaded', props());
149
- const hasBeenInstalled = createAction('[SPX / Update Pending] Has been installed', props());
150
- const postpone = createAction('[SPX / Update Pending] Postpone', props());
151
- const postponeExpired = createAction('[SPX / Update Pending] Postpone expired', props());
152
- const all = union({
153
- acceptUpdate,
154
- hasBeenDownloaded,
155
- hasBeenInstalled,
156
- postpone,
157
- postponeExpired,
158
- });
159
-
160
- var spxUpdatePending_actions = /*#__PURE__*/Object.freeze({
161
- __proto__: null,
162
- acceptUpdate: acceptUpdate,
163
- hasBeenDownloaded: hasBeenDownloaded,
164
- hasBeenInstalled: hasBeenInstalled,
165
- postpone: postpone,
166
- postponeExpired: postponeExpired
132
+ const SpxUpdatePendingActions = createActionGroup({
133
+ source: 'SpxUpdatePending',
134
+ events: {
135
+ AcceptUpdate: emptyProps(),
136
+ HasBeenDownloaded: emptyProps(),
137
+ HasBeenInstalled: emptyProps(),
138
+ Postpone: emptyProps(),
139
+ PostponeExpired: emptyProps(),
140
+ },
167
141
  });
168
142
 
169
143
  const initialState = {
@@ -178,24 +152,24 @@ var spxUpdatePending_initial = /*#__PURE__*/Object.freeze({
178
152
 
179
153
  var updPending = createFeature({
180
154
  name: 'spxUpdatePending',
181
- reducer: createReducer(initialState, on(hasBeenDownloaded, (state) => {
155
+ reducer: createReducer(initialState, on(SpxUpdatePendingActions.hasBeenDownloaded, (state) => {
182
156
  return {
183
157
  ...state,
184
158
  showLiveUpdateReady: true,
185
159
  updateIsDownloadedAndPending: true,
186
160
  };
187
- }), on(hasBeenInstalled, (state) => {
161
+ }), on(SpxUpdatePendingActions.hasBeenInstalled, (state) => {
188
162
  return {
189
163
  ...state,
190
164
  showLiveUpdateReady: false,
191
165
  updateIsDownloadedAndPending: false,
192
166
  };
193
- }), on(postpone, (state) => {
167
+ }), on(SpxUpdatePendingActions.postpone, (state) => {
194
168
  return {
195
169
  ...state,
196
170
  showLiveUpdateReady: false,
197
171
  };
198
- }), on(postponeExpired, (state) => {
172
+ }), on(SpxUpdatePendingActions.postponeExpired, (state) => {
199
173
  return {
200
174
  ...state,
201
175
  showLiveUpdateReady: true,
@@ -238,7 +212,7 @@ class SpxUpdatePendingComponent {
238
212
  this.subscriptions = {};
239
213
  }
240
214
  onUpdate() {
241
- this.appStore.dispatch(acceptUpdate({}));
215
+ this.appStore.dispatch(SpxUpdatePendingActions.acceptUpdate());
242
216
  }
243
217
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: SpxUpdatePendingComponent, deps: [{ token: i1.Store }, { token: i2$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component }); }
244
218
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.3", type: SpxUpdatePendingComponent, isStandalone: true, selector: "spx-update-pending", host: { properties: { "style": "this.baseStyle" } }, ngImport: i0, template: "@if (showLiveUpdateReady()) {\n<div class=\"bg-zinc-700 text-black p-3 rounded flex gap-3 mx-auto max-w-lg items-center\">\n <div class=\"grow\">\n <p\n class=\"text-xl font-extrabold bg-clip-text text-transparent bg-[linear-gradient(to_right,theme(colors.green.300),theme(colors.green.100),theme(colors.sky.400),theme(colors.yellow.200),theme(colors.sky.400),theme(colors.green.100),theme(colors.green.300))] bg-[length:200%_auto] animate-gradient\">\n {{ spxTextPatchAvailable | translate | capitalize }}</p>\n <div class=\"text-sm text-zinc-300\">{{ spxTextReadyToBeInstalled | translate | capitalize }}</div>\n </div>\n <spx-button [spxSeverity]=\"severitySuccess\" (spxClick)=\"onUpdate()\">{{ spxTextUpdate | translate | capitalize\n }}</spx-button>\n</div>\n}", dependencies: [{ kind: "component", type: SpxButtonComponent, selector: "spx-button", inputs: ["spxDisabled", "spxClass", "spxClassObject", "spxForm", "spxFullHeight", "spxFullWidth", "spxSeverity", "spxSize", "spxTabIndex", "spxType", "spxName"], outputs: ["spxClick"] }, { kind: "pipe", type: SpxCapitalizePipe, name: "capitalize" }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
@@ -260,56 +234,47 @@ const spxUpdateUrl = '';
260
234
  let Effects$1 = class Effects {
261
235
  constructor() {
262
236
  this.actions$ = inject(Actions);
263
- this.afterInitialize$ = createEffect(() => this.actions$.pipe(ofType(initialize), delay(120000), mergeMap(() => [
264
- runCheck({}),
237
+ this.afterInitialize$ = createEffect(() => this.actions$.pipe(ofType(SpxUpdateCheckActions.initialaize), delay(300000), mergeMap(() => [
238
+ SpxUpdateCheckActions.runCheck({}),
265
239
  ])));
266
- this.onRun$ = createEffect(() => this.actions$.pipe(ofType(runCheck), tap(async () => {
240
+ this.onRun$ = createEffect(() => this.actions$.pipe(ofType(SpxUpdateCheckActions.runCheck), tap(async () => {
267
241
  if (Capacitor.getPlatform() !== 'web') {
268
242
  // Migrate from e.g. 1.2.x to 1.3.x
269
243
  const binaryInfo = await App.getInfo();
270
244
  const binaryVersionGroup = binaryInfo.version.substring(0, 3);
271
- const config = await getConfig();
272
- const channelVersionGroup = config.channel.split('-')[1].substring(0, 3); // e.g. "1.4"
273
- let channelType = config.channel.split('-')[0];
274
- SpxStorage.setSetting(SpxStorageKeyEnum.binaryVersionGroup, `${binaryVersionGroup}.x`);
275
- SpxStorage.setSetting(SpxStorageKeyEnum.lastBinaryVersionGroup, `${channelVersionGroup}.x`);
276
- // Temp fix
277
- if (channelType === 'null') {
278
- channelType = 'Production';
279
- }
280
- // End temp fix
281
- if (channelType === null || binaryVersionGroup != channelVersionGroup) {
282
- await setConfig({
283
- channel: `${channelType ? channelType : SpxAppChannelTypeEnum.production}-${binaryVersionGroup}.x`
284
- });
245
+ let channelType = SpxStorage.getSetting(SpxStorageKeyEnum.channelType);
246
+ if (SpxStorage.getSetting(SpxStorageKeyEnum.binaryVersionGroup)) {
247
+ SpxStorage.setSetting(SpxStorageKeyEnum.lastBinaryVersionGroup, SpxStorage.getSetting(SpxStorageKeyEnum.binaryVersionGroup));
285
248
  }
249
+ SpxStorage.setSetting(SpxStorageKeyEnum.binaryVersionGroup, `${binaryVersionGroup}.x`);
250
+ SpxStorage.setSetting(SpxStorageKeyEnum.liveUpdateChannel, `${channelType ? channelType : SpxAppChannelTypeEnum.production}-${binaryVersionGroup}.x`);
286
251
  // End migrate from e.g. 1.2.x to 1.3.x
287
252
  }
288
- }), exhaustMap((action) => from(sync()).pipe(map((syncResult) => {
289
- if (syncResult.activeApplicationPathChanged) {
290
- SpxStorage.setSetting(SpxStorageKeyEnum.liveUpdate, syncResult.snapshot?.buildId);
253
+ }), exhaustMap((action) => from(LiveUpdate.sync({ channel: SpxStorage.getSetting(SpxStorageKeyEnum.liveUpdateChannel) })).pipe(map((syncResult) => {
254
+ if (syncResult.nextBundleId) {
255
+ SpxStorage.setSetting(SpxStorageKeyEnum.liveUpdate, syncResult.nextBundleId);
291
256
  if (action.forceWaitForUpdate) {
292
- reload();
257
+ LiveUpdate.reload();
293
258
  }
294
- return anUpdateIsReady({});
259
+ return SpxUpdateCheckActions.anUpdateIsReady();
295
260
  }
296
261
  else {
297
- return noUpdateWasFound({ startUpdateAgainAfterTimeout: !action.forceWaitForUpdate });
262
+ return SpxUpdateCheckActions.noUpdateWasFound({ startUpdateAgainAfterTimeout: !action.forceWaitForUpdate });
298
263
  }
299
264
  }), catchError((err) => {
300
265
  if (err.message !== 'Not implemented for web only') {
301
266
  captureMessage("[UPD] Handled: " + err.message);
302
267
  }
303
- return err.message === 'Not implemented for web only' ? of(notAvailableOnWeb({})) : of(checkFailed({ startUpdateAgainAfterTimeout: false }));
268
+ return err.message === 'Not implemented for web only' ? of(SpxUpdateCheckActions.notAvailableOnWeb()) : of(SpxUpdateCheckActions.checkFailed({ startUpdateAgainAfterTimeout: false }));
304
269
  })))));
305
- this.whenAndUpdateIsReady$ = createEffect(() => this.actions$.pipe(ofType(anUpdateIsReady), mergeMap(() => [
306
- hasBeenDownloaded({}),
270
+ this.whenAndUpdateIsReady$ = createEffect(() => this.actions$.pipe(ofType(SpxUpdateCheckActions.anUpdateIsReady), mergeMap(() => [
271
+ SpxUpdatePendingActions.hasBeenDownloaded(),
307
272
  ])));
308
- this.whenCheckHasFailed$ = createEffect(() => this.actions$.pipe(ofType(checkFailed), delay(30000), mergeMap((action) => !action.startUpdateAgainAfterTimeout ? [] : [
309
- runCheck({}),
273
+ this.whenCheckHasFailed$ = createEffect(() => this.actions$.pipe(ofType(SpxUpdateCheckActions.checkFailed), delay(30000), mergeMap((action) => !action.startUpdateAgainAfterTimeout ? [] : [
274
+ SpxUpdateCheckActions.runCheck({}),
310
275
  ])));
311
- this.whenNoUpdateWasFound$ = createEffect(() => this.actions$.pipe(ofType(noUpdateWasFound), delay(120000), mergeMap((action) => !action.startUpdateAgainAfterTimeout ? [] : [
312
- runCheck({}),
276
+ this.whenNoUpdateWasFound$ = createEffect(() => this.actions$.pipe(ofType(SpxUpdateCheckActions.noUpdateWasFound), delay(120000), mergeMap((action) => !action.startUpdateAgainAfterTimeout ? [] : [
277
+ SpxUpdateCheckActions.runCheck({}),
313
278
  ])));
314
279
  }
315
280
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: Effects, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
@@ -331,8 +296,8 @@ var spxUpdateCheck_state = /*#__PURE__*/Object.freeze({
331
296
  class Effects {
332
297
  constructor(actions$) {
333
298
  this.actions$ = actions$;
334
- this.whenAccepted$ = createEffect(() => this.actions$.pipe(ofType(acceptUpdate), mergeMap(() => {
335
- reload();
299
+ this.whenAccepted$ = createEffect(() => this.actions$.pipe(ofType(SpxUpdatePendingActions.acceptUpdate), mergeMap(() => {
300
+ LiveUpdate.reload();
336
301
  return [];
337
302
  })));
338
303
  }
@@ -356,5 +321,5 @@ var spxUpdatePending_state = /*#__PURE__*/Object.freeze({
356
321
  * Generated bundle index. Do not edit.
357
322
  */
358
323
 
359
- export { SpxUpdatePageComponent, SpxUpdatePendingComponent, spxUpdateCheck_actions as spxUpdateCheckActions, spxUpdateCheck_effects as spxUpdateCheckEffects, spxUpdateCheck_initial as spxUpdateCheckInitial, spxUpdateCheck_reducer as spxUpdateCheckReducer, spxUpdateCheck_state as spxUpdateCheckState, spxUpdatePending_actions as spxUpdatePendingActions, spxUpdatePending_effects as spxUpdatePendingEffects, spxUpdatePending_initial as spxUpdatePendingInitial, spxUpdatePending_reducer as spxUpdatePendingReducer, spxUpdatePending_state as spxUpdatePendingState, spxUpdateUrl };
324
+ export { SpxUpdateCheckActions, SpxUpdatePageComponent, SpxUpdatePendingActions, SpxUpdatePendingComponent, spxUpdateCheck_effects as spxUpdateCheckEffects, spxUpdateCheck_initial as spxUpdateCheckInitial, spxUpdateCheck_reducer as spxUpdateCheckReducer, spxUpdateCheck_state as spxUpdateCheckState, spxUpdatePending_effects as spxUpdatePendingEffects, spxUpdatePending_initial as spxUpdatePendingInitial, spxUpdatePending_reducer as spxUpdatePendingReducer, spxUpdatePending_state as spxUpdatePendingState, spxUpdateUrl };
360
325
  //# sourceMappingURL=softpak-components-spx-update.mjs.map