@qwik.dev/core 2.0.0-beta.37 → 2.0.0-beta.39

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.
Files changed (37) hide show
  1. package/dist/backpatch/package.json +1 -1
  2. package/dist/build/package.json +1 -1
  3. package/dist/cli.mjs +14 -5
  4. package/dist/core-internal.d.ts +397 -323
  5. package/dist/core.min.mjs +9 -8
  6. package/dist/core.mjs +1886 -1161
  7. package/dist/core.mjs.map +1 -1
  8. package/dist/core.prod.mjs +4646 -4048
  9. package/dist/loader/index.mjs +2 -2
  10. package/dist/loader/package.json +1 -1
  11. package/dist/optimizer.d.ts +5 -3
  12. package/dist/optimizer.mjs +1676 -1722
  13. package/dist/preloader.mjs +1 -1
  14. package/dist/qwikloader.debug.js +1 -1
  15. package/dist/qwikloader.js +1 -1
  16. package/dist/server.d.ts +7 -0
  17. package/dist/server.mjs +75 -34
  18. package/dist/server.prod.mjs +392 -345
  19. package/dist/starters/adapters/bun/src/entry.bun.ts +35 -0
  20. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +20 -0
  21. package/dist/starters/adapters/deno/src/entry.deno.ts +41 -0
  22. package/dist/starters/adapters/express/src/entry.express.tsx +20 -0
  23. package/dist/starters/adapters/fastify/package.json +2 -2
  24. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +20 -0
  25. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +10 -1
  26. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +20 -0
  27. package/dist/starters/features/csr/package.json +1 -1
  28. package/dist/starters/features/drizzle/package.json +1 -1
  29. package/dist/starters/features/vitest/package.json +1 -1
  30. package/dist/testing/index.d.ts +40 -31
  31. package/dist/testing/index.mjs +1568 -942
  32. package/dist/testing/package.json +1 -1
  33. package/dist/worker/package.json +1 -1
  34. package/dist/worker/worker.shared.js +1 -1
  35. package/handlers.mjs +3 -0
  36. package/package.json +7 -7
  37. package/public.d.ts +3 -0
@@ -108,7 +108,7 @@ declare type AllEventsMap = Omit<AllEventMapRaw, keyof EventCorrectionMap> & Eve
108
108
 
109
109
  declare type _AllowPlainQrl<Q> = QRLEventHandlerMulti<any, any> extends Q ? Q extends QRLEventHandlerMulti<infer EV, infer EL> ? Q | (EL extends Element ? EventHandler<EV, EL> : never) : Q : Q extends QRL<infer U> ? Q | U : NonNullable<Q> extends never ? Q : QRL<Q> | Q;
110
110
 
111
- declare type AllSignalFlags = SignalFlags | WrappedSignalFlags | SerializationSignalFlags | AsyncSignalFlags;
111
+ declare type AllSignalFlags = ComputedSignalFlags | SerializationSignalFlags | AsyncSignalFlags;
112
112
 
113
113
  /**
114
114
  * TS defines these with the React syntax which is not compatible with Qwik. E.g. `ariaAtomic`
@@ -366,56 +366,17 @@ declare interface AriaAttributes {
366
366
  /** @public */
367
367
  declare type AriaRole = 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'cell' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'navigation' | 'none' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem' | (string & {});
368
368
 
369
- declare type AsyncCtx<T = unknown> = {
370
- track: Tracker;
371
- /**
372
- * Register a cleanup callback to be called when the async computation is aborted or completed.
373
- * The next invocation will await the previous cleanup. If you do not want this, do not return a
374
- * Promise.
375
- */
376
- cleanup: (callback: () => void | Promise<void>) => void;
377
- /**
378
- * A lazily created AbortSignal, for interrupting the async computation when needed, e.g. when the
379
- * component is unmounted or the computation is invalidated. Pass it to `fetch` or other APIs that
380
- * support it to ensure that unnecessary work is not performed.
381
- */
382
- readonly abortSignal: AbortSignal;
383
- /** The result of the previous computation, if any */
384
- readonly previous: T | undefined;
385
- /** Extra info passed to `invalidate(info)` for this computation, if any. */
386
- readonly info?: unknown;
387
- };
388
-
389
369
  /**
390
- * Note, we don't pass the generic type to AsyncCtx because it causes TypeScript to not infer the
370
+ * Note, we don't pass the generic type to ComputeCtx because it causes TypeScript to not infer the
391
371
  * type of the resource correctly. The type is only used for the `previous` property, which is not
392
372
  * commonly used, and can be easily cast if needed.
393
373
  *
374
+ * @deprecated Use `useComputed$` with an async function instead.
394
375
  * @public
395
376
  */
396
- export declare type AsyncFn<T> = (ctx: AsyncCtx) => ValueOrPromise<T>;
397
-
398
- /** Retains job metadata and also serves as the argument for the compute function */
399
- declare class AsyncJob<T> implements AsyncCtx<T> {
400
- readonly $signal$: _AsyncSignalImpl<T>;
401
- /** First holds the compute promise and then the cleanup promise */
402
- $promise$: Promise<void> | null | void;
403
- $cleanupRequested$: boolean;
404
- $canWrite$: boolean;
405
- $track$: AsyncCtx<T>['track'] | undefined;
406
- $cleanups$: Parameters<AsyncCtx<T>['cleanup']>[0][] | undefined;
407
- $abortController$: AbortController | undefined;
408
- info: unknown;
409
- $infoVersion$: number | undefined;
410
- constructor($signal$: _AsyncSignalImpl<T>, info: unknown, $infoVersion$: number | undefined);
411
- get track(): AsyncCtx<T>['track'];
412
- get abortSignal(): AbortSignal;
413
- /** Backward compatible cache method for resource */
414
- cache(): void;
415
- get previous(): T | undefined;
416
- cleanup(callback: () => void): void;
417
- }
377
+ export declare type AsyncFn<T> = (ctx: ComputeCtx) => ValueOrPromise<T>;
418
378
 
379
+ /** @deprecated Use `ComputeQRL` instead. */
419
380
  declare type AsyncQRL<T> = _QRLInternal<AsyncFn<T>>;
420
381
 
421
382
  /**
@@ -440,70 +401,18 @@ declare type AsyncQRL<T> = _QRLInternal<AsyncFn<T>>;
440
401
  * If the async function threw an error, reading the `.value` will throw that same error. Read from
441
402
  * `.error` to check if there was an error.
442
403
  *
404
+ * @deprecated Use `ComputedSignal` instead, it has async support now.
443
405
  * @public
444
406
  */
445
- export declare interface AsyncSignal<T = unknown> extends ComputedSignal<T> {
446
- /**
447
- * Whether the signal is currently loading. This will trigger lazy loading of the signal, so you
448
- * can use it like this:
449
- *
450
- * ```tsx
451
- * signal.loading ? <Loading /> : signal.error ? <Error /> : <Component
452
- * value={signal.value} />
453
- * ```
454
- */
455
- loading: boolean;
456
- /**
457
- * Lets you read the loading state without subscribing to `.loading` updates. It also triggers
458
- * lazy loading of the signal.
459
- *
460
- * Setting it will trigger listeners for `.loading`.
461
- */
462
- untrackedLoading: boolean;
463
- /**
464
- * The error that occurred while computing the signal, if any. This will be cleared when the
465
- * signal is successfully computed. It does not trigger lazy loading of the signal.
466
- */
467
- error: Error | undefined;
468
- /**
469
- * Lets you read the error state without subscribing to `.error` updates. It does not trigger lazy
470
- * loading of the signal.
471
- *
472
- * Setting it will trigger listeners for `.error`.
473
- */
474
- untrackedError: Error | undefined;
475
- /**
476
- * Expiration time in ms. Writable and immediately effective.
477
- *
478
- * When set, the signal is invalidated after this many ms. Whether it auto-recomputes depends on
479
- * the `poll` property. `0` means no expiration.
480
- */
481
- expires: number;
482
- /**
483
- * Whether to automatically re-run the function when the value expires. Writable and immediately
484
- * effective. Only relevant when `expires` is set.
485
- *
486
- * Defaults to `true`.
487
- */
488
- poll: boolean;
489
- /** @deprecated Use `expires` and `poll` instead. Will be removed before v2 */
490
- interval: number;
491
- /** A promise that resolves when the value is computed or rejected. */
492
- promise(): Promise<void>;
493
- /** Abort the current computation and run cleanups if needed. */
494
- abort(reason?: any): void;
495
- /**
496
- * Use this to force recalculation. If you pass `info`, it will be provided to the calculation
497
- * function.
498
- */
499
- invalidate(info?: unknown): void;
500
- }
407
+ export declare type AsyncSignal<T = unknown> = ComputedSignal<T>;
501
408
 
502
409
  declare const enum AsyncSignalFlags {
503
410
  EAGER_CLEANUP = 32,
504
411
  CLIENT_ONLY = 64,
505
- CLEAR_ON_INVALIDATE = 128,
506
- NO_POLL = 256
412
+ /** The compute fn is async: the async engine (jobs, loading, error) is active */
413
+ ASYNC_MODE = 512,
414
+ /** Invoke the compute fn AsyncSignal-style: pass the ComputeCtx argument, no auto-tracking */
415
+ CTX_ARG = 1024
507
416
  }
508
417
 
509
418
  /**
@@ -513,157 +422,21 @@ declare const enum AsyncSignalFlags {
513
422
  *
514
423
  * # ================================
515
424
  *
425
+ * The async engine (jobs, loading, error) lives in ComputedSignalImpl; this subclass configures it
426
+ * from options and switches the compute invocation to CTX_ARG mode: the compute fn receives the
427
+ * ComputeCtx argument and tracks only via its explicit `track()` (no auto-tracking).
428
+ *
516
429
  * @internal
517
430
  */
518
- export declare class _AsyncSignalImpl<T> extends ComputedSignalImpl<T, AsyncQRL<T>> implements BackRef, AsyncSignal<T> {
519
- $untrackedLoading$: boolean;
520
- $untrackedError$: Error | undefined;
521
- $current$: AsyncJob<T> | null;
522
- $jobs$: AsyncJob<T>[] | undefined;
523
- $concurrency$: number | undefined;
524
- $expires$: number | undefined;
525
- $timeoutMs$: number | undefined;
526
- $loadingEffects$: undefined | Set<EffectSubscription>;
527
- $errorEffects$: undefined | Set<EffectSubscription>;
528
- $pollTimeoutId$: ReturnType<typeof setTimeout> | undefined;
529
- $computationTimeoutId$: ReturnType<typeof setTimeout> | undefined;
530
- $info$: unknown | undefined;
531
- $infoVersion$: number | undefined;
532
- [_EFFECT_BACK_REF]: Map<_EffectProperty | string, EffectSubscription> | undefined;
533
- constructor(container: _Container | null, fn: AsyncQRL<T>, flags?: SignalFlags | SerializationSignalFlags, options?: AsyncSignalOptions<T>);
534
- get untrackedValue(): T;
535
- set untrackedValue(value: T);
536
- /**
537
- * Read the value, subscribing if in a tracking context. Triggers computation if needed.
538
- *
539
- * Setting the value will mark the signal as not loading and clear any error, and prevent any
540
- * pending computations from writing their results.
541
- *
542
- * If you want to set the value without affecting loading or error state, set `untrackedValue`
543
- * instead and make sure to trigger effects manually if needed.
544
- *
545
- * If you want to abort pending computations when setting, you have to call `abort()` manually.
546
- */
547
- get value(): T;
548
- set value(value: T);
549
- /**
550
- * Loading is true if the signal is still waiting for the promise to resolve, false if the promise
551
- * has resolved or rejected.
552
- *
553
- * Accessing .loading will trigger computation if needed, since it's often used like
554
- * `signal.loading ? <Loading /> : signal.value`.
555
- */
556
- get loading(): boolean;
557
- set untrackedLoading(value: boolean);
558
- get untrackedLoading(): boolean;
559
- /** The error that occurred when the signal was resolved. */
560
- get error(): Error | undefined;
561
- set untrackedError(value: Error | undefined);
562
- get untrackedError(): Error | undefined;
563
- get expires(): number;
564
- set expires(value: number);
565
- get poll(): boolean;
566
- set poll(value: boolean);
567
- /** @deprecated Use `expires` and `poll` instead. */
568
- get interval(): number;
569
- set interval(value: number);
570
- /** Invalidates the signal, causing it to re-compute its value. */
571
- invalidate(info?: unknown): Promise<void>;
572
- $setInvalid$(allowRecalc: boolean, mustClear: boolean | number): void;
573
- /** Abort the current computation and run cleanups if needed. */
574
- abort(reason?: any): void;
575
- /** Schedule eager cleanup on next macro task if no subscribers remain. */
576
- $scheduleEagerCleanup$(): void;
577
- /** Returns a promise resolves when the signal finished computing. */
578
- promise(): Promise<void>;
579
- /** Run the computation if needed */
580
- $computeIfNeeded$(): void;
581
- $runComputation$(running: AsyncJob<T>): Promise<void>;
582
- /**
583
- * Sets the error from the given job. We only accept errors from the current job and we ignore
584
- * AbortErrors.
585
- */
586
- $setError$(job: AsyncJob<T>, error: Error): void;
587
- /** Called after SSR/unmount */
588
- $destroy$(): Promise<void>;
589
- private $clearNextPoll$;
590
- private $scheduleNextPoll$;
591
- private $hasSubscribers$;
592
- $requestCleanups$(job: AsyncJob<T>, reason?: any): void;
593
- /** Clean up and trigger signal compute once complete */
594
- $runCleanups$(job: AsyncJob<T>): Promise<void> | undefined;
431
+ export declare class _AsyncSignalImpl<T> extends ComputedSignalImpl<T, AsyncQRL<T>> implements AsyncSignal<T> {
432
+ constructor(container: _Container | null, fn: AsyncQRL<T>, flags?: number, options?: AsyncSignalOptions<T>);
595
433
  }
596
434
 
597
- /** @public */
598
- export declare interface AsyncSignalOptions<T> extends ComputedOptions {
599
- /** Like useSignal's `initial`; prevents the throw on first read when uninitialized */
600
- initial?: T | (() => T);
601
- /**
602
- * Maximum number of concurrent computations. Use `0` for unlimited.
603
- *
604
- * Defaults to `1`.
605
- */
606
- concurrency?: number;
607
- /**
608
- * When subscribers drop to 0, run cleanup in the next tick, instead of waiting for the function
609
- * inputs to change.
610
- *
611
- * Defaults to `false`, meaning cleanup happens only when inputs change.
612
- */
613
- eagerCleanup?: boolean;
614
- /**
615
- * Time in milliseconds after which the value expires.
616
- *
617
- * When the value expires and subscribers exist, the signal is invalidated. If `poll` is `true`
618
- * (default), the function is re-run automatically. If `poll` is `false`, the value is marked
619
- * stale and recomputation happens when reading `.value` or `.loading`.
620
- *
621
- * `0` (default) means no expiration.
622
- */
623
- expires?: number;
624
- /**
625
- * Whether to automatically re-run the function when the value expires. Only relevant when
626
- * `expires` is set.
627
- *
628
- * Defaults to `true`.
629
- */
630
- poll?: boolean;
631
- /** @deprecated Use `expires` and `poll` instead. Will be removed before v2 */
632
- interval?: number;
633
- /**
634
- * When true, the async computation is postponed to the browser. On SSR, the signal remains
635
- * INVALID and does not execute the function. On the client, it will compute on first read.
636
- *
637
- * Defaults to `false`.
638
- */
639
- clientOnly?: boolean;
640
- /**
641
- * When true (default), the previous value is kept while the signal re-computes after
642
- * invalidation, so reads return stale data instead of throwing a promise. Reactivity will then
643
- * update the readers when the new value is ready.
644
- *
645
- * When false, invalidation clears the value so reads throw the computation promise (like the
646
- * initial load), which is useful for navigations where showing old data would be confusing.
647
- *
648
- * Note that polling invalidations (`expires` with `poll: true`) are not affected by this option
649
- * and will keep the old value while the new value is loading, to avoid flashing loaders.
650
- *
651
- * This option only affects manual invalidations via `invalidate()`, and non-polling expirations
652
- * (`poll: false`, or there are no subscribers).
653
- *
654
- * Defaults to `true`.
655
- */
656
- allowStale?: boolean;
657
- /**
658
- * Maximum time in milliseconds to wait for the async computation to complete. If exceeded, the
659
- * computation is aborted and an error is thrown.
660
- *
661
- * If `0`, no timeout is applied.
662
- *
663
- * Defaults to `0`.
664
- */
665
- timeout?: number;
666
- }
435
+ /**
436
+ * @deprecated Use `ComputedOptions` instead.
437
+ * @public
438
+ */
439
+ export declare type AsyncSignalOptions<T> = ComputedOptions<T>;
667
440
 
668
441
  /**
669
442
  * Replace given element's props with custom types and return all props specific to the element. Use
@@ -709,7 +482,7 @@ export declare let _captures: Readonly<unknown[]> | null;
709
482
  *
710
483
  * @internal
711
484
  */
712
- export declare function _chk(this: string | undefined, _: any, element: HTMLInputElement): void;
485
+ export declare function _chk(this: string | undefined, _: any, element: HTMLInputElement): void | Promise<void>;
713
486
 
714
487
  declare const enum ChoreBits {
715
488
  NONE = 0,
@@ -838,17 +611,81 @@ declare type ComponentChildren<PROPS> = PROPS extends {
838
611
  /** @internal */
839
612
  export declare const componentQrl: <PROPS extends Record<any, any>>(componentQrl: QRL<OnRenderFn<PROPS>>) => Component<PROPS>;
840
613
 
841
- /** @public */
842
- export declare type ComputedFn<T> = () => T;
614
+ declare type ComputeCtx<T = unknown> = {
615
+ /**
616
+ * Track reactive reads so the computation re-runs when they change. Computed functions track
617
+ * synchronous reads automatically, but after the first `await` the tracking context is lost, so
618
+ * later reads must go through `track()`.
619
+ */
620
+ readonly track: Tracker;
621
+ /**
622
+ * Register a cleanup callback to be called when the async computation is aborted or completed.
623
+ * The next invocation will await the previous cleanup. If you do not want this, do not return a
624
+ * Promise.
625
+ */
626
+ cleanup: (callback: () => void | Promise<void>) => void;
627
+ /**
628
+ * A lazily created AbortSignal, for interrupting the async computation when needed, e.g. when the
629
+ * component is unmounted or the computation is invalidated. Pass it to `fetch` or other APIs that
630
+ * support it to ensure that unnecessary work is not performed.
631
+ */
632
+ readonly abortSignal: AbortSignal;
633
+ /** The result of the previous computation, if any */
634
+ readonly previous: T | undefined;
635
+ /** Extra info passed to `invalidate(info)` for this computation, if any. */
636
+ readonly info?: unknown;
637
+ };
638
+
639
+ /**
640
+ * The compute function. The context provides `track()`, `previous` (the last computed value),
641
+ * `info` (the argument of the `invalidate(info)` call that triggered this computation), `cleanup()`
642
+ * and `abortSignal`. Synchronous reactive state reads are tracked automatically, use `untrack()` to
643
+ * read signals without tracking. Return a `Promise` (or use an `async` function) for async values.
644
+ * After the first `await`, reads are no longer tracked automatically and must use `track()`.
645
+ *
646
+ * @public
647
+ */
648
+ export declare type ComputedFn<T> = (ctx: ComputeCtx) => ValueOrPromise<T>;
843
649
 
844
650
  /** @public */
845
- export declare interface ComputedOptions {
651
+ export declare interface ComputedOptions<T = unknown> {
846
652
  serializationStrategy?: SerializationStrategy;
847
653
  container?: _Container;
654
+ /** Like useSignal's `initial`; prevents the throw on first read when uninitialized */
655
+ initial?: Awaited<T> | (() => Awaited<T>);
656
+ /**
657
+ * Maximum number of concurrent computations. Use `0` for unlimited.
658
+ *
659
+ * Defaults to `1`.
660
+ */
661
+ concurrency?: number;
662
+ /**
663
+ * When subscribers drop to 0, run cleanup in the next tick, instead of waiting for the function
664
+ * inputs to change.
665
+ *
666
+ * Defaults to `false`, meaning cleanup happens only when inputs change.
667
+ */
668
+ eagerCleanup?: boolean;
669
+ /**
670
+ * When true, the async computation is postponed to the browser. On SSR, the signal remains
671
+ * INVALID and does not execute the function. On the client, it will compute on first read.
672
+ *
673
+ * Defaults to `false`.
674
+ */
675
+ clientOnly?: boolean;
676
+ /**
677
+ * Maximum time in milliseconds to wait for the async computation to complete. If exceeded, the
678
+ * computation is aborted and an error is thrown.
679
+ *
680
+ * If `0`, no timeout is applied.
681
+ *
682
+ * Defaults to `0`.
683
+ */
684
+ timeout?: number;
848
685
  }
849
686
 
850
687
  /** @public */
851
- export declare type ComputedReturnType<T> = T extends Promise<any> ? never : ComputedSignal<T>;
688
+ export declare type ComputedReturnType<T> = ComputedSignal<Awaited<T>>;
852
689
 
853
690
  /**
854
691
  * A computed signal is a signal which is calculated from other signals. When the signals change,
@@ -862,28 +699,174 @@ export declare interface ComputedSignal<T> extends Signal<T> {
862
699
  force(): void;
863
700
  /** Use this to force recalculation. */
864
701
  invalidate(): void;
702
+ /**
703
+ * Clear the value and recompute. Unlike `invalidate()`, readers see the loading state (reads
704
+ * throw the computation promise) instead of the stale value while the new value computes.
705
+ */
706
+ clear(): void;
707
+ /**
708
+ * Whether the signal is currently loading. This will trigger lazy computation of the signal, so
709
+ * you can use it like this:
710
+ *
711
+ * ```tsx
712
+ * signal.pending ? <Loading /> : signal.error ? <Error /> : <Component
713
+ * value={signal.value} />
714
+ * ```
715
+ */
716
+ pending: boolean;
717
+ /**
718
+ * Lets you read the pending state without subscribing to `.pending` updates. It also triggers
719
+ * lazy computation of the signal.
720
+ *
721
+ * Setting it will trigger listeners for `.pending`.
722
+ */
723
+ untrackedPending: boolean;
724
+ /** @deprecated Use `pending` instead */
725
+ loading: boolean;
726
+ /** @deprecated Use `untrackedPending` instead */
727
+ untrackedLoading: boolean;
728
+ /**
729
+ * The error that occurred while computing the signal, if any, including synchronous throws. This
730
+ * will be cleared when the signal is successfully computed. It also triggers lazy computation of
731
+ * the signal. While the error is set, reading `.value` throws it.
732
+ */
733
+ error: Error | undefined;
734
+ /**
735
+ * Lets you read the error state without subscribing to `.error` updates. It also triggers lazy
736
+ * computation of the signal.
737
+ *
738
+ * Setting it will trigger listeners for `.error`.
739
+ */
740
+ untrackedError: Error | undefined;
741
+ /** A promise that resolves when the value is computed or rejected. */
742
+ promise(): Promise<void>;
743
+ /** Abort the current computation and run cleanups if needed. */
744
+ abort(reason?: any): void;
745
+ /**
746
+ * Use this to force recalculation. If you pass `info`, it will be provided to the calculation
747
+ * function.
748
+ */
749
+ invalidate(info?: unknown): void;
750
+ }
751
+
752
+ declare const enum ComputedSignalFlags {
753
+ INVALID = 1,
754
+ RUN_EFFECTS = 2,
755
+ PRESERVE_ON_SEQ_CLEANUP = 4
865
756
  }
866
757
 
867
758
  /**
868
759
  * A signal which is computed from other signals.
869
760
  *
870
- * The value is available synchronously, but the computation is done lazily.
761
+ * Sync compute functions resolve synchronously and every read they perform is auto-tracked. When
762
+ * the compute function turns out to be async (it returned a promise), the signal lazily switches on
763
+ * the async engine — jobs, `loading`, `error` — giving it the same API as an AsyncSignal.
764
+ * Auto-tracking only covers reads before the first await point (the invoke context is lost after
765
+ * it); later reads must use the ComputeCtx `track()`.
871
766
  */
872
767
  declare class ComputedSignalImpl<T, S extends _QRLInternal = ComputeQRL<T>> extends SignalImpl<T> implements BackRef {
873
768
  /**
874
769
  * The compute function is stored here.
875
770
  *
876
- * The computed functions must be executed synchronously (because of this we need to eagerly
877
- * resolve the QRL during the mark dirty phase so that any call to it will be synchronous). )
771
+ * Sync computed functions must be executed synchronously (because of this we need to eagerly
772
+ * resolve the QRL during the mark dirty phase so that any call to it will be synchronous).
878
773
  */
879
774
  $computeQrl$: S;
880
- $flags$: SignalFlags | SerializationSignalFlags;
775
+ $flags$: number;
881
776
  [_EFFECT_BACK_REF]: Map<_EffectProperty | string, EffectSubscription> | undefined;
882
- constructor(container: _Container | null, fn: S, flags?: SignalFlags | SerializationSignalFlags);
883
- invalidate(): void;
777
+ $untrackedPending$: boolean | undefined;
778
+ $untrackedError$: Error | undefined;
779
+ $current$: Job<T> | null | undefined;
780
+ $jobs$: Job<T>[] | undefined;
781
+ $concurrency$: number | undefined;
782
+ $timeoutMs$: number | undefined;
783
+ $loadingEffects$: undefined | Set<EffectSubscription>;
784
+ $errorEffects$: undefined | Set<EffectSubscription>;
785
+ $computationTimeoutId$: ReturnType<typeof setTimeout> | undefined;
786
+ $info$: unknown | undefined;
787
+ $infoVersion$: number | undefined;
788
+ constructor(container: _Container | null, fn: S, flags?: number, options?: ComputedOptions<T>);
789
+ /** Clear the value so readers see the loading state, then recompute. */
790
+ clear(): void;
791
+ invalidate(info?: unknown): void;
792
+ /**
793
+ * Read the value, subscribing if in a tracking context. Triggers computation if needed.
794
+ *
795
+ * Setting the value will mark the signal as not loading and clear any error, and prevent any
796
+ * pending computations from writing their results.
797
+ *
798
+ * If you want to set the value without affecting loading or error state, set `untrackedValue`
799
+ * instead and make sure to trigger effects manually if needed.
800
+ *
801
+ * If you want to abort pending computations when setting, you have to call `abort()` manually.
802
+ */
803
+ get value(): T;
804
+ set value(value: T);
884
805
  get untrackedValue(): T;
885
806
  set untrackedValue(value: T);
807
+ /**
808
+ * Loading is true if the signal is still waiting for the promise to resolve, false if the promise
809
+ * has resolved or rejected (or the compute function is synchronous).
810
+ *
811
+ * Accessing `.pending` will trigger computation if needed, since it's often used like
812
+ *
813
+ * ```ts
814
+ * signal.pending ? <Loading /> : signal.value
815
+ * ```
816
+ */
817
+ get pending(): boolean;
818
+ set untrackedPending(value: boolean);
819
+ get untrackedPending(): boolean;
820
+ /** @deprecated Use `pending` instead */
821
+ get loading(): boolean;
822
+ /** @deprecated Use `untrackedPending` instead */
823
+ get untrackedLoading(): boolean;
824
+ set untrackedLoading(value: boolean);
825
+ /**
826
+ * The error the compute function threw or rejected with.
827
+ *
828
+ * Accessing .error will trigger computation if needed, since it's often used like
829
+ *
830
+ * ```ts
831
+ * signal.error ? <Failed /> : signal.value
832
+ * ```
833
+ */
834
+ get error(): Error | undefined;
835
+ set untrackedError(value: Error | undefined);
836
+ get untrackedError(): Error | undefined;
837
+ $setInvalid$(allowRecalc: boolean): void;
838
+ /** Abort the current computation and run cleanups if needed. */
839
+ abort(reason?: any): void;
840
+ /** Schedule eager cleanup on next macro task if no subscribers remain. */
841
+ $scheduleEagerCleanup$(): void;
842
+ /** Returns a promise resolves when the signal finished computing. */
843
+ promise(): Promise<void>;
844
+ /** Run the computation if needed */
886
845
  $computeIfNeeded$(): void;
846
+ /**
847
+ * Invoke the compute fn with the ComputeCtx argument. CTX_ARG signals (useAsync$, useResource$)
848
+ * only track via its explicit track(). Computeds auto-track every synchronous read instead; after
849
+ * the first await they must use the explicit track() too.
850
+ */
851
+ $invokeComputeFn$(fn: Function, job: Job<T>): T | Promise<T>;
852
+ /** Start an async computation (the async engine; assumes the INVALID flag is set) */
853
+ $computeAsync$(): void;
854
+ $runComputation$(running: Job<T>): Promise<void>;
855
+ /** Await the computation and publish its result, error, and loading transitions. */
856
+ $settleComputation$(running: Job<T>, compute: () => ValueOrPromise<T>): Promise<void>;
857
+ /**
858
+ * Sets the error from the given job. We only accept errors from the current job and we ignore
859
+ * AbortErrors.
860
+ */
861
+ $setError$(job: Job<T>, error: Error): void;
862
+ /** Called after SSR/unmount */
863
+ $destroy$(): Promise<void>;
864
+ private $hasSubscribers$;
865
+ $requestCleanups$(job: Job<T>, reason?: any): void;
866
+ /** Run a job's cleanup callbacks, returning a promise when any of them are async. */
867
+ $runCleanupCallbacks$(job: Job<T>): Promise<void> | undefined;
868
+ /** Clean up and trigger signal compute once complete */
869
+ $runCleanups$(job: Job<T>): Promise<void> | undefined;
887
870
  }
888
871
 
889
872
  declare type ComputeQRL<T> = _QRLInternal<ComputedFn<T>>;
@@ -945,6 +928,13 @@ export declare interface _Container {
945
928
  } | null, symbolToChunkResolver: SymbolToChunkResolver, writer?: StreamWriter): SerializationContext;
946
929
  }
947
930
 
931
+ declare const enum ContainerDataProcessState {
932
+ NotStarted = 0,
933
+ ProcessingVNode = 1,
934
+ ProcessingState = 2,
935
+ ProcessingStateDone = 3
936
+ }
937
+
948
938
  /** @internal */
949
939
  export declare interface _ContainerElement extends HTMLElement {
950
940
  qContainer?: ClientContainer;
@@ -962,6 +952,7 @@ export declare interface _ContainerElement extends HTMLElement {
962
952
  qVNodeRefs?: Map<number, Element | _ElementVNode>;
963
953
  /** String from `<script type="qwik/vnode">` tag. */
964
954
  qVnodeData?: string;
955
+ qDestroy?: () => void;
965
956
  /** Segment-local strings from `<script type="qwik/vnode" q:r="...">` tags. */
966
957
  qSegmentVnodeData?: Map<string, string>;
967
958
  }
@@ -1096,9 +1087,10 @@ export declare interface CorrectedToggleEvent extends Event {
1096
1087
  * Create a signal holding a `.value` which is calculated from the given async function (QRL). The
1097
1088
  * standalone version of `useAsync$`.
1098
1089
  *
1090
+ * @deprecated Use `createComputed$` instead, it has async support now.
1099
1091
  * @public
1100
1092
  */
1101
- export declare const createAsync$: <T>(qrl: (arg: AsyncCtx<T>) => Promise<T>, options?: AsyncSignalOptions<T>) => AsyncSignal<T>;
1093
+ export declare const createAsync$: <T>(qrl: (arg: ComputeCtx<T>) => Promise<T>, options?: AsyncSignalOptions<T>) => AsyncSignal<T>;
1102
1094
 
1103
1095
  /** @internal */
1104
1096
  export declare const createAsyncQrl: <T>(qrl: QRL<AsyncFn<T>>, options?: AsyncSignalOptions<T>) => _AsyncSignalImpl<T>;
@@ -1109,16 +1101,17 @@ export declare const createAsyncQrl: <T>(qrl: QRL<AsyncFn<T>>, options?: AsyncSi
1109
1101
  * recalculated.
1110
1102
  *
1111
1103
  * The QRL must be a function which returns the value of the signal. The function must not have side
1112
- * effects, and it must be synchronous.
1113
- *
1114
- * If you need the function to be async, use `createAsync$` instead (don't forget to use `track()`).
1104
+ * effects. Every synchronous signal or store read is tracked automatically; reads after the first
1105
+ * `await` must use the `track()` provided on the context argument. When the function is async, the
1106
+ * returned signal exposes the async API (`.pending`, `.error`, `.promise()`), and reading an
1107
+ * unresolved `.value` throws the computation promise.
1115
1108
  *
1116
1109
  * @public
1117
1110
  */
1118
- export declare const createComputed$: <T>(qrl: () => T, options?: ComputedOptions) => ComputedReturnType<T>;
1111
+ export declare const createComputed$: <T>(qrl: (ctx: ComputeCtx) => ValueOrPromise<T>, options?: ComputedOptions<T>) => ComputedReturnType<T>;
1119
1112
 
1120
1113
  /** @internal */
1121
- export declare const createComputedQrl: <T>(qrl: QRL<() => T>, options?: ComputedOptions) => ComputedSignalImpl<T>;
1114
+ export declare const createComputedQrl: <T>(qrl: QRL<ComputedFn<T>>, options?: ComputedOptions<T>) => ComputedSignalImpl<T>;
1122
1115
 
1123
1116
  /**
1124
1117
  * Create a context ID to be used in your application. The name should be written with no spaces.
@@ -1188,7 +1181,7 @@ export declare function _createDeserializeContainer(stateData: unknown[]): Deser
1188
1181
  *
1189
1182
  * @internal
1190
1183
  */
1191
- export declare const _createQRL: <TYPE>(chunk: string | null, symbol: string, symbolRef?: null | ValueOrPromise<TYPE>, symbolFn?: null | (() => Promise<Record<string, TYPE>>), captures?: Readonly<unknown[]> | string | null, container?: _Container) => _QRLInternal<TYPE>;
1184
+ export declare const _createQRL: <TYPE>(chunk: string | null, symbol: string, symbolRef?: null | ValueOrPromise<TYPE>, symbolFn?: null | (() => Promise<Record<string, TYPE>>), captures?: QrlCaptures, container?: _Container) => _QRLInternal<TYPE>;
1192
1185
 
1193
1186
  /**
1194
1187
  * Create a signal that holds a custom serializable value. See {@link useSerializer$} for more
@@ -1239,26 +1232,21 @@ declare class DeleteOperation {
1239
1232
  constructor(target: Element | Text);
1240
1233
  }
1241
1234
 
1242
- declare interface DescriptorBase<T = unknown, B = unknown> extends BackRef {
1243
- $flags$: number;
1244
- $index$: number;
1245
- $el$: _HostElement;
1246
- $qrl$: _QRLInternal<T>;
1247
- $state$: B | undefined;
1248
- $destroy$: (() => void) | null;
1249
- }
1250
-
1251
1235
  /**
1252
- * Deserialize data from string to an array of objects.
1236
+ * Deserialize data from string.
1253
1237
  *
1254
1238
  * @param rawStateData - Data to deserialize
1255
1239
  * @internal
1256
1240
  */
1257
- export declare function _deserialize<T>(rawStateData: string): T;
1241
+ export declare function _deserialize<T>(rawStateData: string): Promise<T>;
1258
1242
 
1259
1243
  declare interface DeserializeContainer {
1260
1244
  $getObjectById$: (id: number | string) => unknown;
1261
1245
  $getForwardRef$: (id: number) => number | string | undefined;
1246
+ $pendingStoreTargets$?: Map<object, {
1247
+ t: number;
1248
+ v: unknown;
1249
+ }>;
1262
1250
  element: HTMLElement | null;
1263
1251
  getSyncFn: (id: number) => (...args: unknown[]) => unknown;
1264
1252
  $state$?: unknown[];
@@ -1295,15 +1283,17 @@ declare class DomContainer extends _SharedContainer implements ClientContainer {
1295
1283
  $instanceHash$: string;
1296
1284
  $forwardRefs$: Array<number | string> | null;
1297
1285
  vNodeLocate: (id: string | Element) => _VNode;
1286
+ $containerDataProcessState$: ContainerDataProcessState;
1287
+ $containerStateReadyCallbacks$: Array<() => void> | undefined;
1288
+ $containerStateDataState$: unknown;
1298
1289
  private $rawStateData$;
1299
1290
  private $stateData$;
1300
1291
  private $rootForwardRefs$;
1301
1292
  private $styleIds$;
1302
1293
  constructor(element: _ContainerElement);
1294
+ $processContainerData$(): Generator<void, void, void>;
1303
1295
  /** Tear down this container so stale references fail gracefully. */
1304
1296
  $destroy$(): void;
1305
- private $processRootStateScript$;
1306
- private $stateScriptSelector$;
1307
1297
  /**
1308
1298
  * The first time we render we need to hoist the styles. (Meaning we need to move all styles from
1309
1299
  * component inline to <head>)
@@ -1587,7 +1577,7 @@ export declare const _hasStoreEffects: (value: StoreTarget, prop: keyof StoreTar
1587
1577
  export declare const _hmr: (this: string | undefined, event: CustomEvent<{
1588
1578
  files: string[];
1589
1579
  t: number;
1590
- }>, element: Element) => void;
1580
+ }>, element: Element) => void | Promise<void>;
1591
1581
 
1592
1582
  /** @internal */
1593
1583
  export declare type _HostElement = _VNode | ISsrNode;
@@ -1702,14 +1692,14 @@ export declare const _IMMUTABLE: unique symbol;
1702
1692
  export declare const implicit$FirstArg: <FIRST, REST extends any[], RET>(fn: (qrl: QRL<FIRST>, ...rest: REST) => RET) => ((qrl: FIRST, ...rest: REST) => RET);
1703
1693
 
1704
1694
  /**
1705
- * Inject a pre-loaded value into an AsyncSignal while preserving track() subscriptions. Calls
1706
- * `invalidate({ __v })` so the compute function reads the value from `info`, then triggers an
1707
- * immediate synchronous compute via the private $computeIfNeeded$() method (which is mangled in
1708
- * core builds, so callers from other packages must go through this helper).
1695
+ * Inject a pre-loaded value into a signal while preserving subscriptions. Calls `invalidate({__v})`
1696
+ * so the compute function reads the value from `info`, then triggers an immediate synchronous
1697
+ * compute via the private `$computeIfNeeded$()` method (which is mangled in core builds, so callers
1698
+ * from other packages must go through this helper).
1709
1699
  *
1710
1700
  * @internal
1711
1701
  */
1712
- export declare const _injectAsyncSignalValue: (signal: AsyncSignal<unknown>, value: unknown) => void;
1702
+ export declare const _injectAsyncSignalValue: (signal: ComputedSignal<unknown>, value: unknown) => void;
1713
1703
 
1714
1704
  /**
1715
1705
  * Create an inlined QRL. This is mostly useful on the server side for serialization.
@@ -1851,6 +1841,27 @@ declare interface IStreamHandler {
1851
1841
  streamBlockEnd(): ValueOrPromise<void>;
1852
1842
  }
1853
1843
 
1844
+ /** Retains job metadata and also serves as the argument for CTX_ARG compute functions */
1845
+ declare class Job<T> implements ComputeCtx<T> {
1846
+ readonly $signal$: ComputedSignalImpl<T, any>;
1847
+ /** First holds the compute promise and then the cleanup promise */
1848
+ $promise$: Promise<void> | null | void;
1849
+ $cleanupRequested$: boolean;
1850
+ $canWrite$: boolean;
1851
+ $track$: Tracker | undefined;
1852
+ $cleanups$: Parameters<ComputeCtx<T>['cleanup']>[0][] | undefined;
1853
+ $abortController$: AbortController | undefined;
1854
+ info: unknown;
1855
+ $infoVersion$: number | undefined;
1856
+ constructor($signal$: ComputedSignalImpl<T, any>, info: unknown, $infoVersion$: number | undefined);
1857
+ get track(): Tracker;
1858
+ get abortSignal(): AbortSignal;
1859
+ /** Backward compatible cache method for resource */
1860
+ cache(): void;
1861
+ get previous(): T | undefined;
1862
+ cleanup(callback: () => void): void;
1863
+ }
1864
+
1854
1865
  /**
1855
1866
  * Used by the JSX transpilers to create a JSXNode. Note that the optimizer will normally not use
1856
1867
  * this, instead using _jsxSplit and _jsxSorted directly.
@@ -2056,6 +2067,7 @@ declare class LazyRef<TYPE = unknown> {
2056
2067
  readonly $symbolFn$: undefined | null | (() => Promise<Record<string, TYPE>>);
2057
2068
  $ref$?: (null | ValueOrPromise<TYPE>) | undefined;
2058
2069
  $container$: _Container | undefined;
2070
+ $hasMovedCaptures$?: boolean;
2059
2071
  dev?: QRLDev | null | undefined;
2060
2072
  qrls?: Set<any>;
2061
2073
  constructor($chunk$: string | null, $symbol$: string, $symbolFn$: undefined | null | (() => Promise<Record<string, TYPE>>), $ref$?: (null | ValueOrPromise<TYPE>) | undefined, container?: _Container | null);
@@ -2118,6 +2130,16 @@ export declare const _mapArray_get: <T>(array: (T | null)[], key: string, start:
2118
2130
  /** @internal */
2119
2131
  export declare const _mapArray_set: <T>(array: (T | null)[], key: string, value: T | null, start: number, allowNullValue?: boolean) => void;
2120
2132
 
2133
+ /**
2134
+ * Mark this signal as owned outside of the component that read it.
2135
+ *
2136
+ * Externally owned signals are preserved when found in a component's sequential scope during
2137
+ * component cleanup.
2138
+ *
2139
+ * @internal
2140
+ */
2141
+ export declare const _markSignalAsExternallyOwned: (signal: ComputedSignal<unknown>) => void;
2142
+
2121
2143
  declare class MaybeAsyncSignal {
2122
2144
  }
2123
2145
 
@@ -2182,7 +2204,7 @@ export declare const _noopQrlDEV: <T>(symbolName: string, opts: QRLDev, lexicalS
2182
2204
  * @see noSerialize
2183
2205
  */
2184
2206
  export declare type NoSerialize<T> = (T & {
2185
- __no_serialize__?: true;
2207
+ __no_serialize__: true;
2186
2208
  }) | undefined;
2187
2209
 
2188
2210
  /**
@@ -2433,6 +2455,14 @@ export declare type PublicProps<PROPS> = (PROPS extends Record<any, any> ? Omit<
2433
2455
  /** @internal */
2434
2456
  export declare interface _QDocument extends Document {
2435
2457
  qVNodeData: WeakMap<Element, string>;
2458
+ /** True once root document VNode data has been scheduled at least once. */
2459
+ qVNodeDataStarted?: boolean;
2460
+ /** True when root, segment, and patch VNode data work is fully drained. */
2461
+ qVNodeDataReady?: boolean;
2462
+ /** Internal yielding state for queued VNode data jobs. */
2463
+ qVNodeDataState?: unknown;
2464
+ /** Callbacks waiting for root, segment, and patch VNode data work to drain. */
2465
+ qVNodeDataCallbacks?: Array<() => void>;
2436
2466
  /** True once the root document VNode data has been fully processed. */
2437
2467
  qVNodeDataProcessed?: boolean;
2438
2468
  /** Processes one vnode patch script. */
@@ -2592,6 +2622,8 @@ export declare const qrl: <T = any>(chunkOrFn: string | (() => Promise<any>), sy
2592
2622
 
2593
2623
  declare type QrlArgs<T> = T extends (...args: infer ARGS) => any ? ARGS : unknown[];
2594
2624
 
2625
+ declare type QrlCaptures = Readonly<unknown[]> | string | null;
2626
+
2595
2627
  /** @public */
2596
2628
  declare interface QRLDev {
2597
2629
  file: string;
@@ -2616,8 +2648,9 @@ declare type QRLInternalMethods<TYPE> = {
2616
2648
  readonly $chunk$: string | null;
2617
2649
  readonly $symbol$: string;
2618
2650
  readonly $hash$: string;
2619
- /** If it's a string it's serialized */
2620
- readonly $captures$?: Readonly<unknown[]> | string | null;
2651
+ /** Captures are stored lazily after deserialization. */
2652
+ readonly $captures$?: QrlCaptures;
2653
+ readonly $hasMovedCaptures$?: boolean;
2621
2654
  dev?: QRLDev | null;
2622
2655
  resolve(container?: _Container): Promise<TYPE>;
2623
2656
  resolved: undefined | TYPE;
@@ -2634,7 +2667,9 @@ declare type QRLInternalMethods<TYPE> = {
2634
2667
  * method but we need to have a stable name because it gets called in user code by the optimizer,
2635
2668
  * after the $name$ props are mangled
2636
2669
  */
2637
- w(captures: Readonly<unknown[]> | string | null): _QRLInternal<TYPE>;
2670
+ w(captures: QrlCaptures): _QRLInternal<TYPE>;
2671
+ /** Mark that the handler receives captures moved to its element. */
2672
+ m(): _QRLInternal<TYPE>;
2638
2673
  /**
2639
2674
  * "set ref" - Set the ref of the QRL. It's an internal method but we need to have a stable name
2640
2675
  * because it gets called in user code by the optimizer, after the $name$ props are mangled
@@ -2963,7 +2998,7 @@ export declare const _reR: () => boolean;
2963
2998
  *
2964
2999
  * @internal
2965
3000
  */
2966
- export declare function _res(this: string | undefined, _: any, element: Element): void;
3001
+ export declare function _res(this: string | undefined, _: any, element: Element): void | Promise<void>;
2967
3002
 
2968
3003
  /** @internal */
2969
3004
  export declare const _resolveContextWithoutSequentialScope: <STATE>(context: ContextId<STATE>) => STATE | undefined;
@@ -3005,7 +3040,7 @@ export declare const _resolveContextWithoutSequentialScope: <STATE>(context: Con
3005
3040
  export declare const Resource: <T>({ value, onResolved, onPending, onRejected, }: ResourceProps<T>) => JSXOutput;
3006
3041
 
3007
3042
  /** @public */
3008
- export declare interface ResourceCtx<T = unknown> extends AsyncCtx<T> {
3043
+ export declare interface ResourceCtx<T = unknown> extends ComputeCtx<T> {
3009
3044
  /** @deprecated Does not do anything */
3010
3045
  cache(policyOrMilliseconds: number | 'immutable'): void;
3011
3046
  }
@@ -3078,9 +3113,7 @@ export declare const Reveal: typeof _reC;
3078
3113
 
3079
3114
  declare interface RevealItemLike {
3080
3115
  boundary: {
3081
- pending: {
3082
- untrackedValue: number;
3083
- };
3116
+ untrackedValue: number;
3084
3117
  };
3085
3118
  }
3086
3119
 
@@ -3375,6 +3408,25 @@ export declare abstract class _SharedContainer implements _Container {
3375
3408
  abstract $appendStyle$(content: string, styleId: string, host: _HostElement, scoped: boolean): void;
3376
3409
  }
3377
3410
 
3411
+ /** @internal */
3412
+ export declare const _shC: (props: ShowProps<any>) => JSXNode<unknown>;
3413
+
3414
+ /** @public @experimental */
3415
+ export declare const Show: ShowComponent;
3416
+
3417
+ /** @public @experimental */
3418
+ export declare type ShowComponent = <WHEN = unknown, THEN extends JSXOutput = JSXOutput, ELSE extends JSXOutput = JSXOutput>(props: PublicProps<ShowProps<WHEN, THEN, ELSE>>, key: string | null, flags: number, dev?: DevJSX) => JSXOutput;
3419
+
3420
+ /** @public @experimental */
3421
+ export declare interface ShowProps<WHEN = unknown, THEN extends JSXOutput = JSXOutput, ELSE extends JSXOutput = JSXOutput> {
3422
+ when$: QRL<() => WHEN>;
3423
+ then$: QRL<(when: WHEN) => THEN>;
3424
+ else$?: QRL<(when: WHEN) => ELSE>;
3425
+ }
3426
+
3427
+ /** @internal */
3428
+ export declare const _shT: ({ track }: TaskCtx) => ValueOrPromise<void | undefined>;
3429
+
3378
3430
  /**
3379
3431
  * A signal is a reactive value which can be read and written. When the signal is written, all tasks
3380
3432
  * which are tracking the signal will be re-run and all components that read the signal will be
@@ -3399,11 +3451,6 @@ export declare interface Signal<T = any> {
3399
3451
  trigger(): void;
3400
3452
  }
3401
3453
 
3402
- declare const enum SignalFlags {
3403
- INVALID = 1,
3404
- RUN_EFFECTS = 2
3405
- }
3406
-
3407
3454
  declare class SignalImpl<T = any> implements Signal<T> {
3408
3455
  $untrackedValue$: T;
3409
3456
  /** Store a list of effects which are dependent on this signal. */
@@ -3762,11 +3809,13 @@ export declare type SSRHintProps = {
3762
3809
  declare interface SSRInternalStreamWriter extends StreamWriter {
3763
3810
  writeRootRef(id: number): ValueOrPromise<void>;
3764
3811
  writeRootRefPath(path: number[]): ValueOrPromise<void>;
3812
+ writeRootRefDelta(id: number, base: number): ValueOrPromise<void>;
3765
3813
  toString(remap?: number[]): string;
3766
3814
  }
3767
3815
 
3768
3816
  declare const enum SsrNodeFlags {
3769
- Updatable = 1
3817
+ Updatable = 1,
3818
+ WarnedStreamedChore = 2
3770
3819
  }
3771
3820
 
3772
3821
  declare type SSROutOfOrderSegment = SegmentRenderContext;
@@ -3785,6 +3834,12 @@ declare type SSRRevealSlotProps = {
3785
3834
  coordinator: OutOfOrderRevealCoordinator;
3786
3835
  };
3787
3836
 
3837
+ /** @internal */
3838
+ declare interface SSRRootRefDeltaChunk {
3839
+ readonly id: number;
3840
+ readonly base: number;
3841
+ }
3842
+
3788
3843
  /** @internal */
3789
3844
  declare interface SSRRootRefPathChunk {
3790
3845
  readonly path: number[];
@@ -3806,6 +3861,10 @@ declare type SSRSegmentWriteChunk = string | {
3806
3861
  } | {
3807
3862
  readonly type: 'root-ref-path';
3808
3863
  readonly localPath: number[];
3864
+ } | {
3865
+ readonly type: 'root-ref-delta';
3866
+ readonly localId: number;
3867
+ readonly localBaseId: number;
3809
3868
  };
3810
3869
 
3811
3870
  /** @public */
@@ -3830,7 +3889,7 @@ export declare interface SSRStreamWriter {
3830
3889
  }
3831
3890
 
3832
3891
  /** @internal */
3833
- declare type SSRWriteChunk = string | number | SSRRootRefPathChunk;
3892
+ declare type SSRWriteChunk = string | number | SSRRootRefPathChunk | SSRRootRefDeltaChunk;
3834
3893
 
3835
3894
  declare type StackFn = () => ValueOrPromise<void>;
3836
3895
 
@@ -3881,7 +3940,6 @@ export declare const Suspense: typeof _suC;
3881
3940
  /** @public @experimental */
3882
3941
  export declare type SuspenseProps = {
3883
3942
  fallback?: JSXOutput;
3884
- showStale?: boolean;
3885
3943
  delay?: number;
3886
3944
  };
3887
3945
 
@@ -4196,16 +4254,15 @@ declare type TableCellSpecialAttrs = {
4196
4254
  };
4197
4255
 
4198
4256
  /** @internal */
4199
- export declare class _Task<T = unknown, B = T> extends BackRef implements DescriptorBase<unknown, Signal<B>> {
4200
- $flags$: number;
4257
+ export declare class _Task<T = unknown, B = T> extends BackRef {
4258
+ $flags$: TaskFlags;
4201
4259
  $index$: number;
4202
4260
  $el$: _HostElement;
4203
4261
  $qrl$: _QRLInternal<T>;
4204
- $state$: Signal<B> | undefined;
4205
4262
  $destroy$: (() => void) | null;
4206
4263
  $destroyPromise$: Promise<void> | undefined;
4207
4264
  $taskPromise$: Promise<void> | null;
4208
- constructor($flags$: number, $index$: number, $el$: _HostElement, $qrl$: _QRLInternal<T>, $state$: Signal<B> | undefined, $destroy$: (() => void) | null);
4265
+ constructor($flags$: TaskFlags, $index$: number, $el$: _HostElement, $qrl$: _QRLInternal<T>, $destroy$: (() => void) | null);
4209
4266
  }
4210
4267
 
4211
4268
  /**
@@ -4214,7 +4271,7 @@ export declare class _Task<T = unknown, B = T> extends BackRef implements Descri
4214
4271
  *
4215
4272
  * @internal
4216
4273
  */
4217
- export declare function _task(this: string, _event: Event, element: Element): void;
4274
+ export declare function _task(this: string, _event: Event, element: Element): void | Promise<void>;
4218
4275
 
4219
4276
  /** @public */
4220
4277
  export declare interface TaskCtx {
@@ -4224,6 +4281,16 @@ export declare interface TaskCtx {
4224
4281
 
4225
4282
  declare const TaskEvent = "qTask";
4226
4283
 
4284
+ /** @internal */
4285
+ declare const enum TaskFlags {
4286
+ VISIBLE_TASK = 1,
4287
+ TASK = 2,
4288
+ DIRTY = 4,
4289
+ RENDER_BLOCKING = 8,
4290
+ NEEDS_CLEANUP = 16,
4291
+ EVENTS_REGISTERED = 32
4292
+ }
4293
+
4227
4294
  /** @public */
4228
4295
  export declare type TaskFn = (ctx: TaskCtx) => ValueOrPromise<void | (() => ValueOrPromise<void>)>;
4229
4296
 
@@ -4380,11 +4447,16 @@ export declare function _updateProjectionProps(container: _Container, vnode: _Vi
4380
4447
  * will subscribe to it and return the last resolved value until the new value is ready. As soon as
4381
4448
  * the new value is ready, the subscribers will be updated.
4382
4449
  *
4450
+ * @deprecated Use `useComputed$` instead, it has async support now. It auto-tracks synchronous
4451
+ * reads; after the first `await`, use the provided `track()` like before.
4383
4452
  * @public
4384
4453
  */
4385
4454
  export declare const useAsync$: <T>(qrl: AsyncFn<T>, options?: AsyncSignalOptions<T> | undefined) => AsyncSignal<T>;
4386
4455
 
4387
- /** @internal */
4456
+ /**
4457
+ * @deprecated Use `useComputed$` instead, it has async support now.
4458
+ * @internal
4459
+ */
4388
4460
  export declare const useAsyncQrl: <T>(qrl: QRL<AsyncFn<T>>, options?: AsyncSignalOptions<T>) => AsyncSignal<T>;
4389
4461
 
4390
4462
  /**
@@ -4393,14 +4465,20 @@ export declare const useAsyncQrl: <T>(qrl: QRL<AsyncFn<T>>, options?: AsyncSigna
4393
4465
  * recalculated, and if the result changed, all tasks which are tracking the signal will be re-run
4394
4466
  * and all components that read the signal will be re-rendered.
4395
4467
  *
4396
- * The function must be synchronous and must not have any side effects.
4468
+ * Every synchronous signal or store read is tracked automatically. Reads after an `await` are not:
4469
+ * the tracking context is lost, so track them explicitly with the `track()` provided on the context
4470
+ * argument. When the function is async, the returned signal exposes the async API: reading an
4471
+ * unresolved `.value` throws the computation promise, and `.pending` and `.error` expose the
4472
+ * computation state.
4473
+ *
4474
+ * The function must not have any side effects.
4397
4475
  *
4398
4476
  * @public
4399
4477
  */
4400
- export declare const useComputed$: <T>(qrl: ComputedFn<T>, options?: ComputedOptions | undefined) => ComputedReturnType<T>;
4478
+ export declare const useComputed$: <T>(qrl: ComputedFn<T>, options?: ComputedOptions<T> | undefined) => ComputedReturnType<T>;
4401
4479
 
4402
4480
  /** @internal */
4403
- export declare const useComputedQrl: <T>(qrl: QRL<ComputedFn<T>>, options?: ComputedOptions) => ComputedReturnType<T>;
4481
+ export declare const useComputedQrl: <T>(qrl: QRL<ComputedFn<T>>, options?: ComputedOptions<T>) => ComputedReturnType<T>;
4404
4482
 
4405
4483
  /**
4406
4484
  * Stores a value which is retained for the lifetime of the component. Subsequent calls to
@@ -4660,11 +4738,11 @@ export declare const useOnWindow: <T extends KnownEventNames>(event: T | T[], ev
4660
4738
  * Be careful when using a `try/catch` statement in `useResource$`. If you catch the error and don't
4661
4739
  * re-throw it (or a new Error), the resource status will never be `rejected`.
4662
4740
  *
4663
- * @deprecated Use `useAsync$` instead, which is more powerful and flexible. `useResource$` is still
4664
- * available for backward compatibility but it is recommended to migrate to `useAsync$` for new
4665
- * code and when updating existing code.
4741
+ * @deprecated Use `useComputed$` instead, which is more powerful and flexible. `useResource$` is
4742
+ * still available for backward compatibility but it is recommended to migrate to `useComputed$`
4743
+ * for new code and when updating existing code.
4666
4744
  * @public
4667
- * @see useAsync$
4745
+ * @see useComputed$
4668
4746
  * @see Resource
4669
4747
  * @see ResourceReturn
4670
4748
  */
@@ -5023,7 +5101,7 @@ export declare const useVisibleTaskQrl: (qrl: QRL<TaskFn>, opts?: OnVisibleTaskO
5023
5101
  *
5024
5102
  * @internal
5025
5103
  */
5026
- export declare function _val(this: string | undefined, _: any, element: HTMLInputElement): void;
5104
+ export declare function _val(this: string | undefined, _: any, element: HTMLInputElement): void | Promise<void>;
5027
5105
 
5028
5106
  /**
5029
5107
  * Type representing a value which is either resolve or a promise.
@@ -5039,7 +5117,7 @@ export declare const _VAR_PROPS: unique symbol;
5039
5117
  export declare const _verifySerializable: <T>(value: T, preMessage?: string) => T;
5040
5118
 
5041
5119
  /**
5042
- * 2.0.0-beta.37-dev+82dc74d
5120
+ * 2.0.0-beta.39-dev+6fb620f
5043
5121
  *
5044
5122
  * @public
5045
5123
  */
@@ -5221,10 +5299,6 @@ export declare function withLocale<T>(locale: string, fn: () => T): T;
5221
5299
 
5222
5300
  declare type WrappedProp<T extends object, P extends keyof T> = T extends Signal ? WrappedSignalImpl<PropType<T, P>> : PropType<T, P>;
5223
5301
 
5224
- declare const enum WrappedSignalFlags {
5225
- UNWRAP = 4
5226
- }
5227
-
5228
5302
  declare class WrappedSignalImpl<T> extends SignalImpl<T> {
5229
5303
  $args$: any[];
5230
5304
  $func$: (...args: any[]) => T;
@@ -5232,7 +5306,7 @@ declare class WrappedSignalImpl<T> extends SignalImpl<T> {
5232
5306
  $flags$: AllSignalFlags;
5233
5307
  $hostElement$: _HostElement | undefined;
5234
5308
  [_EFFECT_BACK_REF]: Map<_EffectProperty | string, EffectSubscription> | undefined;
5235
- constructor(container: _Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null, flags?: SignalFlags);
5309
+ constructor(container: _Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null, flags?: AllSignalFlags);
5236
5310
  invalidate(): void;
5237
5311
  get untrackedValue(): T;
5238
5312
  $computeIfNeeded$(): void;