@mmstack/primitives 22.2.0 → 22.2.1

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,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { isDevMode, inject, Injector, untracked, effect, DestroyRef, linkedSignal, InjectionToken, TemplateRef, ViewContainerRef, input, computed, Directive, signal, PLATFORM_ID, runInInjectionContext, afterNextRender, Component, isWritableSignal as isWritableSignal$2, isSignal, ElementRef, Injectable } from '@angular/core';
2
+ import { isDevMode, inject, Injector, untracked, effect, DestroyRef, linkedSignal, InjectionToken, TemplateRef, ViewContainerRef, PLATFORM_ID, input, computed, Directive, signal, runInInjectionContext, afterNextRender, Component, isWritableSignal as isWritableSignal$2, isSignal, ElementRef, Injectable } from '@angular/core';
3
3
  import { isPlatformServer } from '@angular/common';
4
4
  import { SIGNAL } from '@angular/core/primitives/signals';
5
5
 
@@ -246,6 +246,7 @@ class MmActivity {
246
246
  tpl = inject(TemplateRef);
247
247
  vcr = inject(ViewContainerRef);
248
248
  parent = inject(Injector);
249
+ onServer = isPlatformServer(inject(PLATFORM_ID, { optional: true }) ?? 'browser');
249
250
  /** When false, keep the content mounted but hidden + CD-detached. */
250
251
  visible = input.required({ ...(ngDevMode ? { debugName: "visible" } : /* istanbul ignore next */ {}), alias: 'mmActivity' });
251
252
  /** Paused == not visible — handed to the kept subtree as PAUSED_CONTEXT. */
@@ -269,6 +270,8 @@ class MmActivity {
269
270
  }),
270
271
  });
271
272
  }
273
+ if (this.onServer)
274
+ return;
272
275
  for (const node of this.view.rootNodes) {
273
276
  // covers HTML and SVG roots; text/comment roots can't be styled — their CD is still
274
277
  // detached, but prefer an element root for true visual hiding
@@ -644,6 +647,7 @@ function registerResource(res, opt) {
644
647
  function injectStartTransition() {
645
648
  const scope = injectTransitionScope();
646
649
  const injector = inject(Injector);
650
+ const onServer = isPlatformServer(inject(PLATFORM_ID, { optional: true }) ?? 'browser');
647
651
  return (fn) => {
648
652
  untracked(fn);
649
653
  let sawPending = false;
@@ -658,6 +662,13 @@ function injectStartTransition() {
658
662
  resolve();
659
663
  }
660
664
  }, { ...(ngDevMode ? { debugName: "watcher" } : /* istanbul ignore next */ {}), injector });
665
+ if (onServer) {
666
+ if (!untracked(scope.pending)) {
667
+ watcher.destroy();
668
+ resolve();
669
+ }
670
+ return;
671
+ }
661
672
  // no-async fallback: once the reactive system has processed the writes (afterNextRender),
662
673
  // if nothing ever went in flight, the transition is already complete.
663
674
  afterNextRender(() => {
@@ -800,6 +811,7 @@ function runInTransaction(txn, fn) {
800
811
  function injectStartTransaction() {
801
812
  const scope = injectTransitionScope();
802
813
  const injector = inject(Injector);
814
+ const onServer = isPlatformServer(inject(PLATFORM_ID, { optional: true }) ?? 'browser');
803
815
  return (fn) => {
804
816
  const txn = createTransaction();
805
817
  // Hold BEFORE the writes, so the display freezes at pre-transaction values.
@@ -841,11 +853,17 @@ function injectStartTransaction() {
841
853
  if (sawPending && !p)
842
854
  finish(false);
843
855
  }, { injector });
844
- // no-async fallback: if nothing ever went in flight, settle once the writes are processed.
845
- afterNextRender(() => {
846
- if (!sawPending && !untracked(scope.pending))
856
+ if (onServer) {
857
+ if (!untracked(scope.pending))
847
858
  finish(false);
848
- }, { injector });
859
+ }
860
+ else {
861
+ // no-async fallback: if nothing ever went in flight, settle once the writes are processed.
862
+ afterNextRender(() => {
863
+ if (!sawPending && !untracked(scope.pending))
864
+ finish(false);
865
+ }, { injector });
866
+ }
849
867
  return {
850
868
  pending: scope.pending,
851
869
  done,