@qwik.dev/core 2.0.0-beta.2 → 2.0.0-beta.4

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.
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwik.dev/core/build",
3
- "version": "2.0.0-beta.2-dev+3ddc6c7",
3
+ "version": "2.0.0-beta.4-dev+9849dcf",
4
4
  "main": "index.mjs",
5
5
  "types": "index.d.ts",
6
6
  "private": true,
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/cli 2.0.0-beta.2-dev+3ddc6c7
3
+ * @qwik.dev/core/cli 2.0.0-beta.4-dev+9849dcf
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
@@ -5536,7 +5536,7 @@ async function printHelp(app) {
5536
5536
  await runCommand2(Object.assign(app, { task: args[0], args }));
5537
5537
  }
5538
5538
  function printVersion() {
5539
- console.log("2.0.0-beta.2-dev+3ddc6c7");
5539
+ console.log("2.0.0-beta.4-dev+9849dcf");
5540
5540
  }
5541
5541
  // Annotate the CommonJS export names for ESM import in node:
5542
5542
  0 && (module.exports = {
@@ -1,9 +1,9 @@
1
+ import { ComputedSignal as ComputedSignal_2 } from '..';
1
2
  import * as CSS_2 from 'csstype';
2
3
  import { isBrowser } from './build';
3
4
  import { isDev } from './build';
4
5
  import { isServer } from './build';
5
6
  import { QRL as QRL_2 } from './qrl.public';
6
- import { ReadonlySignal as ReadonlySignal_2 } from '..';
7
7
  import type { StreamWriter as StreamWriter_2 } from '.';
8
8
  import { ValueOrPromise as ValueOrPromise_2 } from '..';
9
9
 
@@ -99,7 +99,7 @@ declare type _AllowPlainQrl<Q> = QRLEventHandlerMulti<any, any> extends Q ? Q ex
99
99
 
100
100
  declare type AllPascalEventMaps = PascalMap<AllEventsMap>;
101
101
 
102
- declare type AllSignalFlags = SignalFlags | WrappedSignalFlags;
102
+ declare type AllSignalFlags = SignalFlags | WrappedSignalFlags | ComputedSignalFlags;
103
103
 
104
104
  /**
105
105
  * TS defines these with the React syntax which is not compatible with Qwik. E.g. `ariaAtomic`
@@ -366,12 +366,43 @@ declare type AsyncComputedCtx = {
366
366
  export declare type AsyncComputedFn<T> = (ctx: AsyncComputedCtx) => Promise<T>;
367
367
 
368
368
  /** @public */
369
- export declare interface AsyncComputedReadonlySignal<T = unknown> extends ReadonlySignal<T> {
369
+ export declare interface AsyncComputedReadonlySignal<T = unknown> extends ComputedSignal<T> {
370
370
  }
371
371
 
372
372
  /** @public */
373
373
  export declare type AsyncComputedReturnType<T> = T extends Promise<infer T> ? AsyncComputedReadonlySignal<T> : AsyncComputedReadonlySignal<T>;
374
374
 
375
+ /**
376
+ * # ================================
377
+ *
378
+ * AsyncComputedSignalImpl
379
+ *
380
+ * # ================================
381
+ */
382
+ declare class AsyncComputedSignalImpl<T> extends ComputedSignalImpl<T, AsyncComputeQRL<T>> implements BackRef {
383
+ $untrackedLoading$: boolean;
384
+ $untrackedError$: Error | null;
385
+ $loadingEffects$: null | Set<EffectSubscription>;
386
+ $errorEffects$: null | Set<EffectSubscription>;
387
+ $destroy$: NoSerialize<() => void> | null;
388
+ private $promiseValue$;
389
+ [_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | null;
390
+ constructor(container: Container | null, fn: AsyncComputeQRL<T>, flags?: SignalFlags | ComputedSignalFlags);
391
+ /**
392
+ * Loading is true if the signal is still waiting for the promise to resolve, false if the promise
393
+ * has resolved or rejected.
394
+ */
395
+ get loading(): boolean;
396
+ set untrackedLoading(value: boolean);
397
+ get untrackedLoading(): boolean;
398
+ /** The error that occurred when the signal was resolved. */
399
+ get error(): Error | null;
400
+ set untrackedError(value: Error | null);
401
+ get untrackedError(): Error | null;
402
+ invalidate(): void;
403
+ $computeIfNeeded$(): boolean;
404
+ }
405
+
375
406
  declare type AsyncComputeQRL<T> = QRLInternal<AsyncComputedFn<T>>;
376
407
 
377
408
  /**
@@ -540,7 +571,13 @@ export declare const componentQrl: <PROPS extends Record<any, any>>(componentQrl
540
571
  export declare type ComputedFn<T> = () => T;
541
572
 
542
573
  /** @public */
543
- export declare type ComputedReturnType<T> = T extends Promise<any> ? never : ReadonlySignal<T>;
574
+ export declare interface ComputedOptions {
575
+ serializationStrategy?: SerializationStrategy;
576
+ container?: Container;
577
+ }
578
+
579
+ /** @public */
580
+ export declare type ComputedReturnType<T> = T extends Promise<any> ? never : ComputedSignal<T>;
544
581
 
545
582
  /**
546
583
  * A computed signal is a signal which is calculated from other signals. When the signals change,
@@ -551,10 +588,20 @@ export declare type ComputedReturnType<T> = T extends Promise<any> ? never : Rea
551
588
  */
552
589
  export declare interface ComputedSignal<T> extends ReadonlySignal<T> {
553
590
  /**
554
- * Use this to force recalculation and running subscribers, for example when the calculated value
555
- * mutates but remains the same object. Useful for third-party libraries.
591
+ * Use this to force running subscribers, for example when the calculated value mutates but
592
+ * remains the same object.
556
593
  */
557
594
  force(): void;
595
+ /**
596
+ * Use this to force recalculation and running subscribers, for example when the calculated value
597
+ * mutates but remains the same object.
598
+ */
599
+ invalidate(): void;
600
+ }
601
+
602
+ declare const enum ComputedSignalFlags {
603
+ SERIALIZATION_STRATEGY_NEVER = 8,
604
+ SERIALIZATION_STRATEGY_ALWAYS = 16
558
605
  }
559
606
 
560
607
  /**
@@ -570,11 +617,11 @@ declare class ComputedSignalImpl<T, S extends QRLInternal = ComputeQRL<T>> exten
570
617
  * resolve the QRL during the mark dirty phase so that any call to it will be synchronous). )
571
618
  */
572
619
  $computeQrl$: S;
573
- $flags$: SignalFlags;
620
+ $flags$: SignalFlags | ComputedSignalFlags;
574
621
  $forceRunEffects$: boolean;
575
622
  [_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | null;
576
- constructor(container: Container | null, fn: S, flags?: SignalFlags);
577
- $invalidate$(): void;
623
+ constructor(container: Container | null, fn: S, flags?: SignalFlags | ComputedSignalFlags);
624
+ invalidate(): void;
578
625
  /**
579
626
  * Use this to force running subscribers, for example when the calculated value has mutated but
580
627
  * remained the same object
@@ -789,6 +836,21 @@ export declare interface CorrectedToggleEvent extends Event {
789
836
  readonly prevState: 'open' | 'closed';
790
837
  }
791
838
 
839
+ /**
840
+ * Create an async computed signal which is calculated from the given QRL. A computed signal is a
841
+ * signal which is calculated from other signals or async operation. When the signals change, the
842
+ * computed signal is recalculated.
843
+ *
844
+ * The QRL must be a function which returns the value of the signal. The function must not have side
845
+ * effects, and it can be async.
846
+ *
847
+ * @public
848
+ */
849
+ export declare const createAsyncComputed$: <T>(qrl: () => Promise<T>, options?: ComputedOptions) => AsyncComputedReturnType<T>;
850
+
851
+ /** @internal */
852
+ export declare const createAsyncComputedQrl: <T>(qrl: QRL<(ctx: AsyncComputedCtx) => Promise<T>>, options?: ComputedOptions) => AsyncComputedSignalImpl<T>;
853
+
792
854
  /**
793
855
  * Create a computed signal which is calculated from the given QRL. A computed signal is a signal
794
856
  * which is calculated from other signals. When the signals change, the computed signal is
@@ -797,14 +859,14 @@ export declare interface CorrectedToggleEvent extends Event {
797
859
  * The QRL must be a function which returns the value of the signal. The function must not have side
798
860
  * effects, and it must be synchronous.
799
861
  *
800
- * If you need the function to be async, use `useSignal` and `useTask$` instead.
862
+ * If you need the function to be async, use `useAsyncComputed$` instead.
801
863
  *
802
864
  * @public
803
865
  */
804
- export declare const createComputed$: <T>(qrl: () => T) => T extends Promise<any> ? never : ComputedSignal<T>;
866
+ export declare const createComputed$: <T>(qrl: () => T, options?: ComputedOptions) => ComputedReturnType<T>;
805
867
 
806
868
  /** @internal */
807
- export declare const createComputedQrl: <T>(qrl: QRL<() => T>) => ComputedSignalImpl<T>;
869
+ export declare const createComputedQrl: <T>(qrl: QRL<() => T>, options?: ComputedOptions) => ComputedSignalImpl<T>;
808
870
 
809
871
  /**
810
872
  * Create a context ID to be used in your application. The name should be written with no spaces.
@@ -1164,6 +1226,9 @@ export declare type FunctionComponent<P = unknown> = {
1164
1226
  renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput;
1165
1227
  }['renderFn'];
1166
1228
 
1229
+ /** @internal */
1230
+ export declare const _getContextContainer: () => ClientContainer | undefined;
1231
+
1167
1232
  /** @internal */
1168
1233
  export declare const _getContextElement: () => unknown;
1169
1234
 
@@ -1293,7 +1358,7 @@ declare interface HTMLAttributesBase extends AriaAttributes {
1293
1358
  declare type HTMLCrossOriginAttribute = 'anonymous' | 'use-credentials' | '' | undefined;
1294
1359
 
1295
1360
  /** @public */
1296
- export declare interface HTMLElementAttrs extends HTMLAttributesBase, FilterBase<HTMLElement> {
1361
+ declare interface HTMLElementAttrs extends HTMLAttributesBase, FilterBase<HTMLElement> {
1297
1362
  }
1298
1363
 
1299
1364
  /** @public */
@@ -2049,13 +2114,12 @@ declare type QRLInternalMethods<TYPE> = {
2049
2114
  $captureRef$: unknown[] | null;
2050
2115
  dev: QRLDev | null;
2051
2116
  resolved: undefined | TYPE;
2052
- resolve(): Promise<TYPE>;
2117
+ resolve(containerEl?: Element): Promise<TYPE>;
2053
2118
  getSymbol(): string;
2054
2119
  getHash(): string;
2055
2120
  getCaptured(): unknown[] | null;
2056
2121
  getFn(currentCtx?: InvokeContext | InvokeTuple, beforeFn?: () => void): TYPE extends (...args: any) => any ? (...args: Parameters<TYPE>) => ValueOrPromise<ReturnType<TYPE>> : unknown;
2057
2122
  $setContainer$(containerEl: Element | undefined): Element | undefined;
2058
- $resolveLazy$(containerEl?: Element): ValueOrPromise<TYPE>;
2059
2123
  };
2060
2124
 
2061
2125
  declare type QrlReturn<T> = T extends (...args: any) => infer R ? Awaited<R> : unknown;
@@ -2387,6 +2451,13 @@ export declare const render: (parent: Element | Document, jsxNode: JSXOutput | F
2387
2451
 
2388
2452
  declare const RenderEvent = "qRender";
2389
2453
 
2454
+ declare interface RenderInvokeContext extends InvokeContext {
2455
+ $hostElement$: HostElement;
2456
+ $event$: PossibleEvents;
2457
+ $waitOn$: Promise<unknown>[];
2458
+ $container$: Container;
2459
+ }
2460
+
2390
2461
  /** @public */
2391
2462
  export declare const RenderOnce: FunctionComponent<{
2392
2463
  children?: unknown;
@@ -2602,7 +2673,7 @@ declare interface SerializationContext {
2602
2673
  $addRootPath$: (obj: any) => string | number;
2603
2674
  $seen$: (obj: unknown, parent: unknown | null, index: number) => void;
2604
2675
  $roots$: unknown[];
2605
- $pathMap$: Map<unknown, string | number>;
2676
+ $objectPathStringCache$: Map<unknown, string | number>;
2606
2677
  $addSyncFn$($funcStr$: string | null, argsCount: number, fn: Function): number;
2607
2678
  $isSsrNode$: (obj: unknown) => obj is SsrNode;
2608
2679
  $isDomRef$: (obj: unknown) => obj is DomRef;
@@ -2617,6 +2688,17 @@ declare interface SerializationContext {
2617
2688
  $setProp$: (obj: any, prop: string, value: any) => void;
2618
2689
  }
2619
2690
 
2691
+ /** @public */
2692
+ export declare type SerializationStrategy = 'never' | 'always';
2693
+
2694
+ declare class SerializationWeakRef {
2695
+ $obj$: unknown;
2696
+ constructor($obj$: unknown);
2697
+ }
2698
+
2699
+ /** @internal */
2700
+ export declare const _serializationWeakRef: (obj: unknown) => SerializationWeakRef;
2701
+
2620
2702
  /**
2621
2703
  * Serialize data to string using SerializationContext.
2622
2704
  *
@@ -3462,7 +3544,7 @@ export declare interface SVGAttributes<T extends Element = Element> extends Aria
3462
3544
  }
3463
3545
 
3464
3546
  /** @public */
3465
- export declare interface SVGProps<T extends Element> extends SVGAttributes, QwikAttributes<T> {
3547
+ declare interface SVGProps<T extends Element> extends SVGAttributes, QwikAttributes<T> {
3466
3548
  }
3467
3549
 
3468
3550
  /** @public */
@@ -3631,6 +3713,9 @@ export declare interface Tracker {
3631
3713
  <T extends object, P extends keyof T>(obj: T, prop: P): T[P];
3632
3714
  }
3633
3715
 
3716
+ /** @internal */
3717
+ export declare const _UNINITIALIZED: unique symbol;
3718
+
3634
3719
  /**
3635
3720
  * Don't track listeners for this callback
3636
3721
  *
@@ -3658,10 +3743,10 @@ export declare const unwrapStore: <T>(value: T) => T;
3658
3743
  *
3659
3744
  * @public
3660
3745
  */
3661
- export declare const useAsyncComputed$: <T>(qrl: AsyncComputedFn<T>) => AsyncComputedReturnType<T>;
3746
+ export declare const useAsyncComputed$: <T>(qrl: AsyncComputedFn<T>, options?: ComputedOptions | undefined) => AsyncComputedReturnType<T>;
3662
3747
 
3663
3748
  /** @internal */
3664
- export declare const useAsyncComputedQrl: <T>(qrl: QRL<AsyncComputedFn<T>>) => AsyncComputedReturnType<T>;
3749
+ export declare const useAsyncComputedQrl: <T>(qrl: QRL<AsyncComputedFn<T>>, options?: ComputedOptions) => AsyncComputedReturnType<T>;
3665
3750
 
3666
3751
  /**
3667
3752
  * Creates a computed signal which is calculated from the given function. A computed signal is a
@@ -3673,10 +3758,10 @@ export declare const useAsyncComputedQrl: <T>(qrl: QRL<AsyncComputedFn<T>>) => A
3673
3758
  *
3674
3759
  * @public
3675
3760
  */
3676
- export declare const useComputed$: <T>(qrl: ComputedFn<T>) => ComputedReturnType<T>;
3761
+ export declare const useComputed$: <T>(qrl: ComputedFn<T>, options?: ComputedOptions | undefined) => ComputedReturnType<T>;
3677
3762
 
3678
3763
  /** @internal */
3679
- export declare const useComputedQrl: <T>(qrl: QRL<ComputedFn<T>>) => ComputedReturnType<T>;
3764
+ export declare const useComputedQrl: <T>(qrl: QRL<ComputedFn<T>>, options?: ComputedOptions) => ComputedReturnType<T>;
3680
3765
 
3681
3766
  /**
3682
3767
  * Stores a value which is retained for the lifetime of the component. Subsequent calls to
@@ -3801,6 +3886,9 @@ export declare const useErrorBoundary: () => ErrorBoundaryStore;
3801
3886
  /** @public */
3802
3887
  export declare const useId: () => string;
3803
3888
 
3889
+ /** @internal */
3890
+ export declare const _useInvokeContext: () => RenderInvokeContext;
3891
+
3804
3892
  /**
3805
3893
  * Used by the Qwik Optimizer to restore the lexically scoped variables.
3806
3894
  *
@@ -4002,7 +4090,7 @@ export declare const useResourceQrl: <T>(qrl: QRL<ResourceFn<T>>, opts?: Resourc
4002
4090
  export declare const useSerializer$: typeof createSerializer$;
4003
4091
 
4004
4092
  /** @internal */
4005
- export declare const useSerializerQrl: <T, S>(qrl: QRL<SerializerArg<T, S>>) => ReadonlySignal_2<unknown>;
4093
+ export declare const useSerializerQrl: <T, S>(qrl: QRL<SerializerArg<T, S>>) => ComputedSignal_2<unknown>;
4006
4094
 
4007
4095
  /** @public */
4008
4096
  export declare function useServerData<T>(key: string): T | undefined;
@@ -4250,7 +4338,7 @@ export declare const _VAR_PROPS: unique symbol;
4250
4338
  export declare const _verifySerializable: <T>(value: T, preMessage?: string) => T;
4251
4339
 
4252
4340
  /**
4253
- * 2.0.0-beta.2-dev+3ddc6c7
4341
+ * 2.0.0-beta.4-dev+9849dcf
4254
4342
  *
4255
4343
  * @public
4256
4344
  */
@@ -4390,9 +4478,6 @@ export declare function _walkJSX(ssr: SSRContainer, value: JSXOutput, options: {
4390
4478
  parentComponentFrame: ISsrComponentFrame | null;
4391
4479
  }): Promise<void>;
4392
4480
 
4393
- /** @internal */
4394
- export declare const _weakSerialize: <T extends object>(input: T) => Partial<T>;
4395
-
4396
4481
  /**
4397
4482
  * Override the `getLocale` with `lang` within the `fn` execution.
4398
4483
  *
@@ -4413,7 +4498,7 @@ declare class WrappedSignalImpl<T> extends SignalImpl<T> implements BackRef {
4413
4498
  $forceRunEffects$: boolean;
4414
4499
  [_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | null;
4415
4500
  constructor(container: Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null, flags?: SignalFlags);
4416
- $invalidate$(): void;
4501
+ invalidate(): void;
4417
4502
  /**
4418
4503
  * Use this to force running subscribers, for example when the calculated value has mutated but
4419
4504
  * remained the same object.
@@ -4441,7 +4526,4 @@ export declare const _wrapProp: <T extends Record<any, any>, P extends keyof T>(
4441
4526
  /** @internal @deprecated v1 compat */
4442
4527
  export declare const _wrapSignal: <T extends Record<any, any>, P extends keyof T>(obj: T, prop: P) => any;
4443
4528
 
4444
- /** @internal */
4445
- export declare const _wrapStore: <T extends Record<any, any>, P extends keyof T>(obj: T, prop: P) => Signal<T>;
4446
-
4447
4529
  export { }