@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.
@@ -9136,17 +9136,12 @@ var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY, OPTIMIZATION_END
9136
9136
  return actual.startsWith(prefix);
9137
9137
  }
9138
9138
  return actual === pattern;
9139
- }, MIME_MAP, isSharpFactory = (value) => typeof value === "function", callSharp = (sharpRef, input) => {
9140
- if (!isSharpFactory(sharpRef)) {
9141
- throw new Error("Loaded sharp module is not callable.");
9142
- }
9143
- return sharpRef(input);
9144
- }, toBuffer = (input) => {
9139
+ }, MIME_MAP, isSharpFactory = (value) => typeof value === "function", toBuffer = (input) => {
9145
9140
  if (Buffer.isBuffer(input))
9146
9141
  return input;
9147
9142
  return Buffer.from(input);
9148
- }, buildOptimizedUrl = (src, width, quality, basePath = OPTIMIZATION_ENDPOINT) => `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${quality}`, formatToMime = (format) => MIME_MAP[format], generateBlurSvg = (base64Thumbnail) => {
9149
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 320"><filter id="b" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="${BLUR_DEVIATION}"/><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1"/></filter><image filter="url(#b)" x="0" y="0" width="100%" height="100%" href="${base64Thumbnail}"/></svg>`;
9143
+ }, isUnsupportedFormatError = (err) => typeof err === "object" && err !== null && ("code" in err) && err.code === "ERR_IMAGE_FORMAT_UNSUPPORTED", buildOptimizedUrl = (src, width, quality, basePath = OPTIMIZATION_ENDPOINT) => `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${quality}`, formatToMime = (format) => MIME_MAP[format], generateBlurSvg = (base64Thumbnail) => {
9144
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 320"><filter id="b" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="${BLUR_DEVIATION}"/><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 100 -1"/></filter><image filter="url(#b)" x="0" y="0" width="100%" height="100%" href="${base64Thumbnail}"/></svg>`;
9150
9145
  const encoded = encodeURIComponent(svg);
9151
9146
  return `url("data:image/svg+xml,${encoded}")`;
9152
9147
  }, generateSrcSet = (src, width, sizes, config, loader) => {
@@ -9206,11 +9201,24 @@ var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY, OPTIMIZATION_END
9206
9201
  return "webp";
9207
9202
  }
9208
9203
  return "jpeg";
9209
- }, AVIF_QUALITY_OFFSET = 20, AVIF_EFFORT = 3, optimizeImage = async (buffer, width, quality, format) => {
9210
- const sharp = await tryLoadSharp();
9211
- if (!sharp)
9212
- return toBuffer(buffer);
9213
- const pipeline = callSharp(sharp, toBuffer(buffer)).rotate().resize(width, undefined, { withoutEnlargement: true });
9204
+ }, AVIF_QUALITY_OFFSET = 20, AVIF_EFFORT = 3, PNG_COMPRESSION_LEVEL = 9, optimizeWithBunImage = async (buffer, width, quality, format) => {
9205
+ const pipeline = new Bun.Image(buffer).resize(width, undefined, {
9206
+ withoutEnlargement: true
9207
+ });
9208
+ switch (format) {
9209
+ case "avif":
9210
+ return pipeline.avif({
9211
+ quality: Math.max(1, quality - AVIF_QUALITY_OFFSET)
9212
+ }).toBuffer();
9213
+ case "jpeg":
9214
+ return pipeline.jpeg({ quality }).toBuffer();
9215
+ case "png":
9216
+ return pipeline.png({ compressionLevel: PNG_COMPRESSION_LEVEL }).toBuffer();
9217
+ case "webp":
9218
+ return pipeline.webp({ quality }).toBuffer();
9219
+ }
9220
+ }, optimizeWithSharp = async (sharpRef, buffer, width, quality, format) => {
9221
+ const pipeline = sharpRef(buffer).rotate().resize(width, undefined, { withoutEnlargement: true });
9214
9222
  switch (format) {
9215
9223
  case "avif":
9216
9224
  return pipeline.avif({
@@ -9223,8 +9231,19 @@ var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY, OPTIMIZATION_END
9223
9231
  return pipeline.png({ quality }).toBuffer();
9224
9232
  case "webp":
9225
9233
  return pipeline.webp({ quality }).toBuffer();
9226
- default:
9227
- return toBuffer(buffer);
9234
+ }
9235
+ }, optimizeImage = async (buffer, width, quality, format) => {
9236
+ const input = toBuffer(buffer);
9237
+ try {
9238
+ return await optimizeWithBunImage(input, width, quality, format);
9239
+ } catch (err) {
9240
+ if (format === "avif" && isUnsupportedFormatError(err)) {
9241
+ const sharp = await tryLoadSharp();
9242
+ if (sharp && isSharpFactory(sharp)) {
9243
+ return optimizeWithSharp(sharp, input, width, quality, format);
9244
+ }
9245
+ }
9246
+ throw err;
9228
9247
  }
9229
9248
  }, readFromCache = (cacheDir, cacheKey) => {
9230
9249
  const metaPath = join(cacheDir, `${cacheKey}.meta`);
@@ -9251,7 +9270,7 @@ var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY, OPTIMIZATION_END
9251
9270
  if (sharpWarned)
9252
9271
  return null;
9253
9272
  sharpWarned = true;
9254
- console.warn("[image] sharp not installed \u2014 serving unoptimized images. Install with: bun add sharp");
9273
+ console.warn('[image] AVIF requested but sharp not installed and Bun.Image cannot encode AVIF on this platform. Install sharp (`bun add sharp`) to enable AVIF, or remove "avif" from your image formats config. See docs/SHARP_REMOVAL.md for context.');
9255
9274
  return null;
9256
9275
  }
9257
9276
  }, writeToCache = (cacheDir, cacheKey, buffer, meta) => {
@@ -9374,8 +9393,116 @@ var provideDeterministicEnv = (options = {}) => {
9374
9393
  };
9375
9394
  // src/angular/page.ts
9376
9395
  var defineAngularPage = (definition) => definition;
9396
+ // src/angular/composables/useResource.ts
9397
+ import { DestroyRef, inject, signal } from "@angular/core";
9398
+ var useResource = (fetcher, options = {}) => {
9399
+ const destroyRef = inject(DestroyRef);
9400
+ const data = signal(null);
9401
+ const error = signal(null);
9402
+ const loading = signal(false);
9403
+ let controller = null;
9404
+ let destroyed = false;
9405
+ const cancel = () => {
9406
+ if (controller) {
9407
+ controller.abort();
9408
+ controller = null;
9409
+ }
9410
+ };
9411
+ const refresh = async () => {
9412
+ if (destroyed)
9413
+ return;
9414
+ cancel();
9415
+ const next = new AbortController;
9416
+ controller = next;
9417
+ loading.set(true);
9418
+ error.set(null);
9419
+ try {
9420
+ const result = await fetcher(next.signal);
9421
+ if (next.signal.aborted)
9422
+ return;
9423
+ data.set(result);
9424
+ } catch (cause) {
9425
+ if (next.signal.aborted)
9426
+ return;
9427
+ error.set(cause);
9428
+ } finally {
9429
+ if (controller === next) {
9430
+ controller = null;
9431
+ }
9432
+ if (!next.signal.aborted) {
9433
+ loading.set(false);
9434
+ }
9435
+ }
9436
+ };
9437
+ const mutate = (next) => {
9438
+ if (destroyed)
9439
+ return;
9440
+ cancel();
9441
+ error.set(null);
9442
+ loading.set(false);
9443
+ const resolved = typeof next === "function" ? next(data()) : next;
9444
+ data.set(resolved);
9445
+ };
9446
+ destroyRef.onDestroy(() => {
9447
+ destroyed = true;
9448
+ cancel();
9449
+ });
9450
+ if (options.immediate !== false) {
9451
+ refresh();
9452
+ }
9453
+ return { cancel, data, error, loading, mutate, refresh };
9454
+ };
9455
+ // src/angular/composables/useSubscription.ts
9456
+ import { DestroyRef as DestroyRef2, inject as inject2 } from "@angular/core";
9457
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
9458
+ function useSubscription(observable, observerOrNext) {
9459
+ const destroyRef = inject2(DestroyRef2);
9460
+ return observable.pipe(takeUntilDestroyed(destroyRef)).subscribe(typeof observerOrNext === "function" ? { next: observerOrNext } : observerOrNext);
9461
+ }
9462
+ // src/angular/composables/useTimers.ts
9463
+ import { DestroyRef as DestroyRef3, inject as inject3 } from "@angular/core";
9464
+ var useTimers = () => {
9465
+ const destroyRef = inject3(DestroyRef3);
9466
+ const timeouts = new Set;
9467
+ const intervals = new Set;
9468
+ const clearAll = () => {
9469
+ timeouts.forEach((timer) => clearTimeout(timer));
9470
+ intervals.forEach((timer) => clearInterval(timer));
9471
+ timeouts.clear();
9472
+ intervals.clear();
9473
+ };
9474
+ destroyRef.onDestroy(clearAll);
9475
+ return {
9476
+ clearAll,
9477
+ clearInterval(timer) {
9478
+ if (!timer)
9479
+ return;
9480
+ clearInterval(timer);
9481
+ intervals.delete(timer);
9482
+ },
9483
+ clearTimeout(timer) {
9484
+ if (!timer)
9485
+ return;
9486
+ clearTimeout(timer);
9487
+ timeouts.delete(timer);
9488
+ },
9489
+ setInterval(callback, delayMs) {
9490
+ const timer = setInterval(callback, delayMs);
9491
+ intervals.add(timer);
9492
+ return timer;
9493
+ },
9494
+ setTimeout(callback, delayMs) {
9495
+ const timer = setTimeout(() => {
9496
+ timeouts.delete(timer);
9497
+ callback();
9498
+ }, delayMs);
9499
+ timeouts.add(timer);
9500
+ return timer;
9501
+ }
9502
+ };
9503
+ };
9377
9504
  // src/angular/preserveAcrossHmr.ts
9378
- import { ChangeDetectorRef, inject } from "@angular/core";
9505
+ import { ChangeDetectorRef, inject as inject4 } from "@angular/core";
9379
9506
 
9380
9507
  // src/angular/hmrPreserveCore.ts
9381
9508
  var isHmrPreserveDev = () => {
@@ -9446,7 +9573,7 @@ var preserveAcrossHmr = (instance, key) => {
9446
9573
  if (!restored)
9447
9574
  return;
9448
9575
  try {
9449
- const cdr = inject(ChangeDetectorRef, { optional: true });
9576
+ const cdr = inject4(ChangeDetectorRef, { optional: true });
9450
9577
  if (cdr)
9451
9578
  queueMicrotask(() => cdr.markForCheck());
9452
9579
  } catch {}
@@ -9604,9 +9731,9 @@ Island = __legacyDecorateClassTS([
9604
9731
  })
9605
9732
  ], Island);
9606
9733
  // src/angular/pendingTask.ts
9607
- import { inject as inject2, PendingTasks } from "@angular/core";
9734
+ import { inject as inject5, PendingTasks } from "@angular/core";
9608
9735
  var withPendingTask = async (work) => {
9609
- const removeTask = inject2(PendingTasks).add();
9736
+ const removeTask = inject5(PendingTasks).add();
9610
9737
  try {
9611
9738
  return await work();
9612
9739
  } finally {
@@ -9761,8 +9888,8 @@ import {
9761
9888
  Component as Component2,
9762
9889
  ContentChild,
9763
9890
  Input as Input2,
9764
- inject as inject4,
9765
- signal
9891
+ inject as inject7,
9892
+ signal as signal2
9766
9893
  } from "@angular/core";
9767
9894
  import { NgTemplateOutlet } from "@angular/common";
9768
9895
 
@@ -9775,9 +9902,9 @@ var isAngularDeferSlotPayload = (value) => {
9775
9902
  };
9776
9903
 
9777
9904
  // src/angular/components/defer-slot-templates.directive.ts
9778
- import { Directive, TemplateRef, inject as inject3 } from "@angular/core";
9905
+ import { Directive, TemplateRef, inject as inject6 } from "@angular/core";
9779
9906
  class DeferErrorTemplateDirective {
9780
- templateRef = inject3(TemplateRef);
9907
+ templateRef = inject6(TemplateRef);
9781
9908
  }
9782
9909
  DeferErrorTemplateDirective = __legacyDecorateClassTS([
9783
9910
  Directive({
@@ -9787,7 +9914,7 @@ DeferErrorTemplateDirective = __legacyDecorateClassTS([
9787
9914
  ], DeferErrorTemplateDirective);
9788
9915
 
9789
9916
  class DeferFallbackTemplateDirective {
9790
- templateRef = inject3(TemplateRef);
9917
+ templateRef = inject6(TemplateRef);
9791
9918
  }
9792
9919
  DeferFallbackTemplateDirective = __legacyDecorateClassTS([
9793
9920
  Directive({
@@ -9797,7 +9924,7 @@ DeferFallbackTemplateDirective = __legacyDecorateClassTS([
9797
9924
  ], DeferFallbackTemplateDirective);
9798
9925
 
9799
9926
  class DeferResolvedTemplateDirective {
9800
- templateRef = inject3(TemplateRef);
9927
+ templateRef = inject6(TemplateRef);
9801
9928
  }
9802
9929
  DeferResolvedTemplateDirective = __legacyDecorateClassTS([
9803
9930
  Directive({
@@ -9811,11 +9938,11 @@ class DeferSlotComponent {
9811
9938
  constructor() {
9812
9939
  this.id = "";
9813
9940
  }
9814
- cdr = inject4(ChangeDetectorRef2);
9815
- runtimeReady = signal(false);
9941
+ cdr = inject7(ChangeDetectorRef2);
9942
+ runtimeReady = signal2(false);
9816
9943
  serverSlotRegistered = false;
9817
- slotData = signal({});
9818
- state = signal("fallback");
9944
+ slotData = signal2({});
9945
+ state = signal2("fallback");
9819
9946
  activeTemplate = () => {
9820
9947
  if (this.state() === "resolved") {
9821
9948
  return this.resolvedTemplate?.templateRef ?? null;
@@ -9947,7 +10074,7 @@ DeferSlotComponent = __legacyDecorateClassTS([
9947
10074
  ], DeferSlotComponent);
9948
10075
  // src/angular/components/image.component.ts
9949
10076
  init_imageProcessing();
9950
- import { Component as Component3, computed, input, signal as signal2 } from "@angular/core";
10077
+ import { Component as Component3, computed, input, signal as signal3 } from "@angular/core";
9951
10078
  import { NgStyle } from "@angular/common";
9952
10079
  var resolveBlurBg = (placeholderValue, blurDataUrl) => {
9953
10080
  if (typeof placeholderValue === "string" && placeholderValue !== "blur" && placeholderValue.startsWith("data:")) {
@@ -9980,7 +10107,7 @@ class ImageComponent {
9980
10107
  style = input();
9981
10108
  unoptimized = input(false);
9982
10109
  width = input();
9983
- blurRemoved = signal2(false);
10110
+ blurRemoved = signal3(false);
9984
10111
  resolvedSrc = computed(() => {
9985
10112
  const override = this.overrideSrc();
9986
10113
  if (override)
@@ -10094,9 +10221,8 @@ import {
10094
10221
  ChangeDetectorRef as ChangeDetectorRef3,
10095
10222
  Component as Component4,
10096
10223
  Input as Input3,
10097
- NgZone,
10098
- inject as inject5,
10099
- signal as signal3
10224
+ inject as inject8,
10225
+ signal as signal4
10100
10226
  } from "@angular/core";
10101
10227
  import { DomSanitizer } from "@angular/platform-browser";
10102
10228
  var isObjectRecord3 = (value) => Boolean(value) && typeof value === "object";
@@ -10112,17 +10238,14 @@ class StreamSlotComponent {
10112
10238
  constructor() {
10113
10239
  this.fallbackHtml = "";
10114
10240
  }
10115
- cdr = inject5(ChangeDetectorRef3);
10116
- sanitizer = inject5(DomSanitizer);
10117
- zone = inject5(NgZone);
10241
+ cdr = inject8(ChangeDetectorRef3);
10242
+ sanitizer = inject8(DomSanitizer);
10118
10243
  slotConsumer = (payload) => {
10119
- this.zone.run(() => {
10120
- this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(resolvePayloadHtml(payload)));
10121
- this.cdr.markForCheck();
10122
- });
10244
+ this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(resolvePayloadHtml(payload)));
10245
+ this.cdr.markForCheck();
10123
10246
  return true;
10124
10247
  };
10125
- currentHtml = signal3("");
10248
+ currentHtml = signal4("");
10126
10249
  ngOnInit() {
10127
10250
  if (isStreamingSlotCollectionActive()) {
10128
10251
  this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(this.fallbackHtml));
@@ -10206,6 +10329,9 @@ var renderIsland = async () => {
10206
10329
  };
10207
10330
  export {
10208
10331
  withPendingTask,
10332
+ useTimers,
10333
+ useSubscription,
10334
+ useResource,
10209
10335
  renderIsland,
10210
10336
  provideDeterministicEnv,
10211
10337
  preserveAcrossHmr,
@@ -10227,5 +10353,5 @@ export {
10227
10353
  ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
10228
10354
  };
10229
10355
 
10230
- //# debugId=9D6243A1FB854B4064756E2164756E21
10356
+ //# debugId=566EE1BB76DC6E4A64756E2164756E21
10231
10357
  //# sourceMappingURL=browser.js.map