@absolutejs/absolute 0.19.0-beta.961 → 0.19.0-beta.963

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,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-e5Ukal/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-sz98NP/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-e5Ukal/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-sz98NP/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -48,7 +48,7 @@ var warnMissingStreamingSlotCollector = (primitiveName) => {
48
48
  getWarningController()?.maybeWarn(primitiveName);
49
49
  };
50
50
 
51
- // .angular-partial-tmp-e5Ukal/src/core/streamingSlotRegistry.ts
51
+ // .angular-partial-tmp-sz98NP/src/core/streamingSlotRegistry.ts
52
52
  var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
53
53
  var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
54
54
  var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
@@ -1,4 +1,4 @@
1
- import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, NgZone, inject, signal } from '@angular/core';
1
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, inject, signal } from '@angular/core';
2
2
  import { DomSanitizer } from '@angular/platform-browser';
3
3
  import { isStreamingSlotCollectionActive, registerStreamingSlot, warnMissingStreamingSlotCollector } from './core/streamingSlotRegistrar.js';
4
4
  import * as i0 from "@angular/core";
@@ -14,12 +14,9 @@ export class StreamSlotComponent {
14
14
  constructor() {
15
15
  this.cdr = inject(ChangeDetectorRef);
16
16
  this.sanitizer = inject(DomSanitizer);
17
- this.zone = inject(NgZone);
18
17
  this.slotConsumer = (payload) => {
19
- this.zone.run(() => {
20
- this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(resolvePayloadHtml(payload)));
21
- this.cdr.markForCheck();
22
- });
18
+ this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(resolvePayloadHtml(payload)));
19
+ this.cdr.markForCheck();
23
20
  return true;
24
21
  };
25
22
  this.fallbackHtml = '';
@@ -14866,8 +14866,116 @@ var handleAngularPageRequest = async (input) => {
14866
14866
  };
14867
14867
  // src/angular/page.ts
14868
14868
  var defineAngularPage = (definition) => definition;
14869
+ // src/angular/composables/useResource.ts
14870
+ import { DestroyRef, inject, signal } from "@angular/core";
14871
+ var useResource = (fetcher, options = {}) => {
14872
+ const destroyRef = inject(DestroyRef);
14873
+ const data = signal(null);
14874
+ const error = signal(null);
14875
+ const loading = signal(false);
14876
+ let controller = null;
14877
+ let destroyed = false;
14878
+ const cancel = () => {
14879
+ if (controller) {
14880
+ controller.abort();
14881
+ controller = null;
14882
+ }
14883
+ };
14884
+ const refresh = async () => {
14885
+ if (destroyed)
14886
+ return;
14887
+ cancel();
14888
+ const next = new AbortController;
14889
+ controller = next;
14890
+ loading.set(true);
14891
+ error.set(null);
14892
+ try {
14893
+ const result = await fetcher(next.signal);
14894
+ if (next.signal.aborted)
14895
+ return;
14896
+ data.set(result);
14897
+ } catch (cause) {
14898
+ if (next.signal.aborted)
14899
+ return;
14900
+ error.set(cause);
14901
+ } finally {
14902
+ if (controller === next) {
14903
+ controller = null;
14904
+ }
14905
+ if (!next.signal.aborted) {
14906
+ loading.set(false);
14907
+ }
14908
+ }
14909
+ };
14910
+ const mutate = (next) => {
14911
+ if (destroyed)
14912
+ return;
14913
+ cancel();
14914
+ error.set(null);
14915
+ loading.set(false);
14916
+ const resolved = typeof next === "function" ? next(data()) : next;
14917
+ data.set(resolved);
14918
+ };
14919
+ destroyRef.onDestroy(() => {
14920
+ destroyed = true;
14921
+ cancel();
14922
+ });
14923
+ if (options.immediate !== false) {
14924
+ refresh();
14925
+ }
14926
+ return { cancel, data, error, loading, mutate, refresh };
14927
+ };
14928
+ // src/angular/composables/useSubscription.ts
14929
+ import { DestroyRef as DestroyRef2, inject as inject2 } from "@angular/core";
14930
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
14931
+ function useSubscription(observable, observerOrNext) {
14932
+ const destroyRef = inject2(DestroyRef2);
14933
+ return observable.pipe(takeUntilDestroyed(destroyRef)).subscribe(typeof observerOrNext === "function" ? { next: observerOrNext } : observerOrNext);
14934
+ }
14935
+ // src/angular/composables/useTimers.ts
14936
+ import { DestroyRef as DestroyRef3, inject as inject3 } from "@angular/core";
14937
+ var useTimers = () => {
14938
+ const destroyRef = inject3(DestroyRef3);
14939
+ const timeouts = new Set;
14940
+ const intervals = new Set;
14941
+ const clearAll = () => {
14942
+ timeouts.forEach((timer) => clearTimeout(timer));
14943
+ intervals.forEach((timer) => clearInterval(timer));
14944
+ timeouts.clear();
14945
+ intervals.clear();
14946
+ };
14947
+ destroyRef.onDestroy(clearAll);
14948
+ return {
14949
+ clearAll,
14950
+ clearInterval(timer) {
14951
+ if (!timer)
14952
+ return;
14953
+ clearInterval(timer);
14954
+ intervals.delete(timer);
14955
+ },
14956
+ clearTimeout(timer) {
14957
+ if (!timer)
14958
+ return;
14959
+ clearTimeout(timer);
14960
+ timeouts.delete(timer);
14961
+ },
14962
+ setInterval(callback, delayMs) {
14963
+ const timer = setInterval(callback, delayMs);
14964
+ intervals.add(timer);
14965
+ return timer;
14966
+ },
14967
+ setTimeout(callback, delayMs) {
14968
+ const timer = setTimeout(() => {
14969
+ timeouts.delete(timer);
14970
+ callback();
14971
+ }, delayMs);
14972
+ timeouts.add(timer);
14973
+ return timer;
14974
+ }
14975
+ };
14976
+ };
14869
14977
  // src/angular/preserveAcrossHmr.ts
14870
- import { ChangeDetectorRef, inject } from "@angular/core";
14978
+ import { ChangeDetectorRef, inject as inject4 } from "@angular/core";
14871
14979
 
14872
14980
  // src/angular/hmrPreserveCore.ts
14873
14981
  var isHmrPreserveDev = () => {
@@ -14938,15 +15046,15 @@ var preserveAcrossHmr = (instance, key) => {
14938
15046
  if (!restored)
14939
15047
  return;
14940
15048
  try {
14941
- const cdr = inject(ChangeDetectorRef, { optional: true });
15049
+ const cdr = inject4(ChangeDetectorRef, { optional: true });
14942
15050
  if (cdr)
14943
15051
  queueMicrotask(() => cdr.markForCheck());
14944
15052
  } catch {}
14945
15053
  };
14946
15054
  // src/angular/pendingTask.ts
14947
- import { inject as inject2, PendingTasks } from "@angular/core";
15055
+ import { inject as inject5, PendingTasks } from "@angular/core";
14948
15056
  var withPendingTask = async (work) => {
14949
- const removeTask = inject2(PendingTasks).add();
15057
+ const removeTask = inject5(PendingTasks).add();
14950
15058
  try {
14951
15059
  return await work();
14952
15060
  } finally {
@@ -15146,9 +15254,8 @@ import {
15146
15254
  ChangeDetectorRef as ChangeDetectorRef2,
15147
15255
  Component as Component2,
15148
15256
  Input as Input2,
15149
- NgZone,
15150
- inject as inject3,
15151
- signal
15257
+ inject as inject6,
15258
+ signal as signal2
15152
15259
  } from "@angular/core";
15153
15260
  import { DomSanitizer } from "@angular/platform-browser";
15154
15261
  var isObjectRecord5 = (value) => Boolean(value) && typeof value === "object";
@@ -15164,17 +15271,14 @@ class StreamSlotComponent {
15164
15271
  constructor() {
15165
15272
  this.fallbackHtml = "";
15166
15273
  }
15167
- cdr = inject3(ChangeDetectorRef2);
15168
- sanitizer = inject3(DomSanitizer);
15169
- zone = inject3(NgZone);
15274
+ cdr = inject6(ChangeDetectorRef2);
15275
+ sanitizer = inject6(DomSanitizer);
15170
15276
  slotConsumer = (payload) => {
15171
- this.zone.run(() => {
15172
- this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(resolvePayloadHtml(payload)));
15173
- this.cdr.markForCheck();
15174
- });
15277
+ this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(resolvePayloadHtml(payload)));
15278
+ this.cdr.markForCheck();
15175
15279
  return true;
15176
15280
  };
15177
- currentHtml = signal("");
15281
+ currentHtml = signal2("");
15178
15282
  ngOnInit() {
15179
15283
  if (isStreamingSlotCollectionActive()) {
15180
15284
  this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(this.fallbackHtml));
@@ -15253,6 +15357,9 @@ StreamSlotComponent = __legacyDecorateClassTS([
15253
15357
  ], StreamSlotComponent);
15254
15358
  export {
15255
15359
  withPendingTask,
15360
+ useTimers,
15361
+ useSubscription,
15362
+ useResource,
15256
15363
  renderIsland,
15257
15364
  provideDeterministicEnv,
15258
15365
  preserveAcrossHmr,
@@ -15271,5 +15378,5 @@ export {
15271
15378
  ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
15272
15379
  };
15273
15380
 
15274
- //# debugId=C34B09637A6FD85164756E2164756E21
15381
+ //# debugId=D2DC5A8B92142CFA64756E2164756E21
15275
15382
  //# sourceMappingURL=index.js.map