@magic-xpa/angular 4.1300.0-dev4130.325 → 4.1300.0-dev4130.327

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.
@@ -8,7 +8,7 @@ import { FormGroup, FormControl, Validators, NG_VALIDATORS, NG_VALUE_ACCESSOR, C
8
8
  import * as i1$1 from 'ng-dynamic-component';
9
9
  import { DynamicModule } from 'ng-dynamic-component';
10
10
  import { InteractiveCommandType, HtmlProperties, OverlayType, Styles, GuiConstants, CommandType, PIC, GuiEnvironment, Events, Modifiers } from '@magic-xpa/gui';
11
- import { MagicBridge, getGuiEventObj, CookieService, Environment, LastFocusedManager } from '@magic-xpa/engine';
11
+ import { MagicBridge, getGuiEventObj, CookieService, Environment, LastFocusedManager, SubscriberClient } from '@magic-xpa/engine';
12
12
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
13
13
  import { MagicProperties, Logger, StrUtil, StorageAttribute, PICInterface, MsgInterface, BindingLevel, StorageAttributeType, MgControlType } from '@magic-xpa/utils';
14
14
  import { Subject, EMPTY, fromEvent, Observable } from 'rxjs';
@@ -6243,6 +6243,8 @@ class MagicShellComponent {
6243
6243
  }
6244
6244
  /**
6245
6245
  * Before-unload event listener
6246
+ * The context is not terminated here, as 'beforeunload' is also fired when the page is about to enter
6247
+ * the back-forward cache, from where it may be restored. It is terminated in 'pagehide' instead.
6246
6248
  * @param event
6247
6249
  */
6248
6250
  onBeforeUnload(event) {
@@ -6251,22 +6253,41 @@ class MagicShellComponent {
6251
6253
  event.returnValue = 'Are you sure?';
6252
6254
  return 'Are you sure?';
6253
6255
  }
6254
- else {
6255
- // terminate the magic server context using fetch API with keep-alive
6256
- this.engineMagicService.TerminateContextUsingFetchAPI();
6257
- this.magicEngineTerminated = true;
6258
- }
6259
6256
  }
6260
6257
  /**
6261
6258
  * Page-hide event listener, used in place of 'unload'.
6262
6259
  * Chrome blocks 'unload' by permissions policy ("unload is not allowed in this document"),
6263
6260
  * so an unload handler is never even registered. 'pagehide' is fired at an earlier step of
6264
6261
  * the same unloading sequence, so it covers every case 'unload' did.
6262
+ * 'pagehide' is also fired when the page enters the back-forward cache (event.persisted is true).
6263
+ * The page may be restored from that cache, so the context is not terminated in that case.
6265
6264
  */
6266
- onPageHide() {
6267
- // Chrome provides an opportunity to terminate the context after user approves the browser unload alert
6265
+ onPageHide(event) {
6266
+ if (event.persisted) {
6267
+ return;
6268
+ }
6269
+ // terminate the magic server context using fetch API with keep-alive.
6270
+ // If the browser unload alert was shown, this is reached only after the user approves it.
6268
6271
  if (!this.magicEngineTerminated) {
6269
6272
  this.engineMagicService.TerminateContextUsingFetchAPI();
6273
+ this.magicEngineTerminated = true;
6274
+ }
6275
+ }
6276
+ /**
6277
+ * Page-hide event listener for the pubsub subscriber socket.
6278
+ * Fired on page unload and also when the page enters the back-forward cache.
6279
+ * Close the socket explicitly, so the pubsub middleware drops its subscriptions immediately.
6280
+ */
6281
+ onPageHideSubscriber() {
6282
+ SubscriberClient.DisconnectInstance();
6283
+ }
6284
+ /**
6285
+ * Page-show event listener for the pubsub subscriber socket.
6286
+ * When the page is restored from the back-forward cache (event.persisted), reconnect the socket.
6287
+ */
6288
+ onPageShow(event) {
6289
+ if (event.persisted) {
6290
+ SubscriberClient.ConnectInstance();
6270
6291
  }
6271
6292
  }
6272
6293
  ngAfterViewInit() {
@@ -6390,7 +6411,7 @@ class MagicShellComponent {
6390
6411
  } if (rf & 2) {
6391
6412
  i0.ɵɵqueryAdvance();
6392
6413
  } }, hostBindings: function MagicShellComponent_HostBindings(rf, ctx) { if (rf & 1) {
6393
- i0.ɵɵlistener("beforeunload", function MagicShellComponent_beforeunload_HostBindingHandler($event) { return ctx.onBeforeUnload($event); }, i0.ɵɵresolveWindow)("pagehide", function MagicShellComponent_pagehide_HostBindingHandler() { return ctx.onPageHide(); }, i0.ɵɵresolveWindow);
6414
+ i0.ɵɵlistener("beforeunload", function MagicShellComponent_beforeunload_HostBindingHandler($event) { return ctx.onBeforeUnload($event); }, i0.ɵɵresolveWindow)("pagehide", function MagicShellComponent_pagehide_HostBindingHandler() { return ctx.onPageHideSubscriber(); }, i0.ɵɵresolveWindow)("pageshow", function MagicShellComponent_pageshow_HostBindingHandler($event) { return ctx.onPageShow($event); }, i0.ɵɵresolveWindow);
6394
6415
  } }, inputs: { SpinnerTemplate: [1, "SpinnerTemplate"] }, standalone: false, features: [i0.ɵɵProvidersFeature([
6395
6416
  // ExitMagicService
6396
6417
  ])], decls: 8, vars: 2, consts: [["magicRoot", ""], ["overlayWindowsContainer", ""], ["defaultSpinner", ""], [3, "ndcDynamicComponent", "ndcDynamicInputs"], ["magicViewContainerRef", ""], [1, "spinner-background"], [3, "ngTemplateOutlet"], [1, "mgSpinnerClass"]], template: function MagicShellComponent_Template(rf, ctx) { if (rf & 1) {
@@ -6438,10 +6459,16 @@ class MagicShellComponent {
6438
6459
  type: HostListener,
6439
6460
  args: ['window:beforeunload', ['$event']]
6440
6461
  }], onPageHide: [{
6462
+ type: HostListener,
6463
+ args: ['window:pagehide', ['$event']]
6464
+ }], onPageHideSubscriber: [{
6441
6465
  type: HostListener,
6442
6466
  args: ['window:pagehide']
6467
+ }], onPageShow: [{
6468
+ type: HostListener,
6469
+ args: ['window:pageshow', ['$event']]
6443
6470
  }] }); })();
6444
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MagicShellComponent, { className: "MagicShellComponent", filePath: "src/ui/magic-root.component.ts", lineNumber: 90 }); })();
6471
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MagicShellComponent, { className: "MagicShellComponent", filePath: "src/ui/magic-root.component.ts", lineNumber: 91 }); })();
6445
6472
 
6446
6473
  /**
6447
6474
  * @ignore