@mmstack/primitives 20.7.0 → 20.7.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, isSignal, ElementRef, Injectable } from '@angular/core';
|
|
3
3
|
import { isPlatformServer } from '@angular/common';
|
|
4
4
|
import { SIGNAL } from '@angular/core/primitives/signals';
|
|
5
5
|
|
|
@@ -250,6 +250,7 @@ class MmActivity {
|
|
|
250
250
|
tpl = inject(TemplateRef);
|
|
251
251
|
vcr = inject(ViewContainerRef);
|
|
252
252
|
parent = inject(Injector);
|
|
253
|
+
onServer = isPlatformServer(inject(PLATFORM_ID, { optional: true }) ?? 'browser');
|
|
253
254
|
/** When false, keep the content mounted but hidden + CD-detached. */
|
|
254
255
|
visible = input.required(...(ngDevMode ? [{ debugName: "visible", alias: 'mmActivity' }] : [{ alias: 'mmActivity' }]));
|
|
255
256
|
/** Paused == not visible — handed to the kept subtree as PAUSED_CONTEXT. */
|
|
@@ -272,6 +273,8 @@ class MmActivity {
|
|
|
272
273
|
}),
|
|
273
274
|
});
|
|
274
275
|
}
|
|
276
|
+
if (this.onServer)
|
|
277
|
+
return;
|
|
275
278
|
for (const node of this.view.rootNodes) {
|
|
276
279
|
// covers HTML and SVG roots; text/comment roots can't be styled — their CD is still
|
|
277
280
|
// detached, but prefer an element root for true visual hiding
|
|
@@ -651,6 +654,7 @@ function registerResource(res, opt) {
|
|
|
651
654
|
function injectStartTransition() {
|
|
652
655
|
const scope = injectTransitionScope();
|
|
653
656
|
const injector = inject(Injector);
|
|
657
|
+
const onServer = isPlatformServer(inject(PLATFORM_ID, { optional: true }) ?? 'browser');
|
|
654
658
|
return (fn) => {
|
|
655
659
|
untracked(fn);
|
|
656
660
|
let sawPending = false;
|
|
@@ -665,6 +669,13 @@ function injectStartTransition() {
|
|
|
665
669
|
resolve();
|
|
666
670
|
}
|
|
667
671
|
}, ...(ngDevMode ? [{ debugName: "watcher", injector }] : [{ injector }]));
|
|
672
|
+
if (onServer) {
|
|
673
|
+
if (!untracked(scope.pending)) {
|
|
674
|
+
watcher.destroy();
|
|
675
|
+
resolve();
|
|
676
|
+
}
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
668
679
|
// no-async fallback: once the reactive system has processed the writes (afterNextRender),
|
|
669
680
|
// if nothing ever went in flight, the transition is already complete.
|
|
670
681
|
afterNextRender(() => {
|
|
@@ -805,6 +816,7 @@ function runInTransaction(txn, fn) {
|
|
|
805
816
|
function injectStartTransaction() {
|
|
806
817
|
const scope = injectTransitionScope();
|
|
807
818
|
const injector = inject(Injector);
|
|
819
|
+
const onServer = isPlatformServer(inject(PLATFORM_ID, { optional: true }) ?? 'browser');
|
|
808
820
|
return (fn) => {
|
|
809
821
|
const txn = createTransaction();
|
|
810
822
|
// Hold BEFORE the writes, so the display freezes at pre-transaction values.
|
|
@@ -846,11 +858,17 @@ function injectStartTransaction() {
|
|
|
846
858
|
if (sawPending && !p)
|
|
847
859
|
finish(false);
|
|
848
860
|
}, { injector });
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (!sawPending && !untracked(scope.pending))
|
|
861
|
+
if (onServer) {
|
|
862
|
+
if (!untracked(scope.pending))
|
|
852
863
|
finish(false);
|
|
853
|
-
}
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
// no-async fallback: if nothing ever went in flight, settle once the writes are processed.
|
|
867
|
+
afterNextRender(() => {
|
|
868
|
+
if (!sawPending && !untracked(scope.pending))
|
|
869
|
+
finish(false);
|
|
870
|
+
}, { injector });
|
|
871
|
+
}
|
|
854
872
|
return {
|
|
855
873
|
pending: scope.pending,
|
|
856
874
|
done,
|