@mmstack/primitives 21.2.0 → 21.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,
|
|
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. */
|
|
@@ -268,6 +269,8 @@ class MmActivity {
|
|
|
268
269
|
}),
|
|
269
270
|
});
|
|
270
271
|
}
|
|
272
|
+
if (this.onServer)
|
|
273
|
+
return;
|
|
271
274
|
for (const node of this.view.rootNodes) {
|
|
272
275
|
// covers HTML and SVG roots; text/comment roots can't be styled — their CD is still
|
|
273
276
|
// detached, but prefer an element root for true visual hiding
|
|
@@ -639,6 +642,7 @@ function registerResource(res, opt) {
|
|
|
639
642
|
function injectStartTransition() {
|
|
640
643
|
const scope = injectTransitionScope();
|
|
641
644
|
const injector = inject(Injector);
|
|
645
|
+
const onServer = isPlatformServer(inject(PLATFORM_ID, { optional: true }) ?? 'browser');
|
|
642
646
|
return (fn) => {
|
|
643
647
|
untracked(fn);
|
|
644
648
|
let sawPending = false;
|
|
@@ -653,6 +657,13 @@ function injectStartTransition() {
|
|
|
653
657
|
resolve();
|
|
654
658
|
}
|
|
655
659
|
}, { ...(ngDevMode ? { debugName: "watcher" } : /* istanbul ignore next */ {}), injector });
|
|
660
|
+
if (onServer) {
|
|
661
|
+
if (!untracked(scope.pending)) {
|
|
662
|
+
watcher.destroy();
|
|
663
|
+
resolve();
|
|
664
|
+
}
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
656
667
|
// no-async fallback: once the reactive system has processed the writes (afterNextRender),
|
|
657
668
|
// if nothing ever went in flight, the transition is already complete.
|
|
658
669
|
afterNextRender(() => {
|
|
@@ -793,6 +804,7 @@ function runInTransaction(txn, fn) {
|
|
|
793
804
|
function injectStartTransaction() {
|
|
794
805
|
const scope = injectTransitionScope();
|
|
795
806
|
const injector = inject(Injector);
|
|
807
|
+
const onServer = isPlatformServer(inject(PLATFORM_ID, { optional: true }) ?? 'browser');
|
|
796
808
|
return (fn) => {
|
|
797
809
|
const txn = createTransaction();
|
|
798
810
|
// Hold BEFORE the writes, so the display freezes at pre-transaction values.
|
|
@@ -834,11 +846,17 @@ function injectStartTransaction() {
|
|
|
834
846
|
if (sawPending && !p)
|
|
835
847
|
finish(false);
|
|
836
848
|
}, { injector });
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
if (!sawPending && !untracked(scope.pending))
|
|
849
|
+
if (onServer) {
|
|
850
|
+
if (!untracked(scope.pending))
|
|
840
851
|
finish(false);
|
|
841
|
-
}
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
// no-async fallback: if nothing ever went in flight, settle once the writes are processed.
|
|
855
|
+
afterNextRender(() => {
|
|
856
|
+
if (!sawPending && !untracked(scope.pending))
|
|
857
|
+
finish(false);
|
|
858
|
+
}, { injector });
|
|
859
|
+
}
|
|
842
860
|
return {
|
|
843
861
|
pending: scope.pending,
|
|
844
862
|
done,
|