@qwik.dev/core 2.0.0-beta.23 → 2.0.0-beta.25

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.
@@ -18,37 +18,9 @@ declare interface AddRootFn {
18
18
 
19
19
  declare type AllSignalFlags = SignalFlags | WrappedSignalFlags | SerializationSignalFlags | AsyncSignalFlags;
20
20
 
21
- /** @public */
22
- declare interface AsyncSignal<T = unknown> extends ComputedSignal<T> {
23
- /**
24
- * Whether the signal is currently loading. This will trigger lazy loading of the signal, so you
25
- * can use it like this:
26
- *
27
- * ```tsx
28
- * signal.loading ? <Loading /> : signal.error ? <Error /> : <Component
29
- * value={signal.value} />
30
- * ```
31
- */
32
- loading: boolean;
33
- /**
34
- * The error that occurred while computing the signal, if any. This will be cleared when the
35
- * signal is successfully computed.
36
- */
37
- error: Error | undefined;
38
- /**
39
- * Poll interval in ms. Writable and immediately effective when the signal has consumers. If set
40
- * to `0`, polling stops.
41
- */
42
- interval: number;
43
- /** A promise that resolves when the value is computed or rejected. */
44
- promise(): Promise<void>;
45
- /** Abort the current computation and run cleanups if needed. */
46
- abort(reason?: any): void;
47
- }
48
-
49
21
  declare const enum AsyncSignalFlags {
50
22
  EAGER_CLEANUP = 32,
51
- AWAIT_PREVIOUS = 64
23
+ CLIENT_ONLY = 64
52
24
  }
53
25
 
54
26
  /** Class for back reference to the EffectSubscription */
@@ -78,25 +50,8 @@ declare const enum ChoreBits {
78
50
  DIRTY_MASK = 127
79
51
  }
80
52
 
81
- /**
82
- * A computed signal is a signal which is calculated from other signals. When the signals change,
83
- * the computed signal is recalculated, and if the result changed, all tasks which are tracking the
84
- * signal will be re-run and all components that read the signal will be re-rendered.
85
- *
86
- * @public
87
- */
88
- declare interface ComputedSignal<T> extends ReadonlySignal<T> {
89
- /**
90
- * Use this to force running subscribers, for example when the calculated value mutates but
91
- * remains the same object.
92
- */
93
- force(): void;
94
- /**
95
- * Use this to force recalculation and running subscribers, for example when the calculated value
96
- * mutates but remains the same object.
97
- */
98
- invalidate(): void;
99
- }
53
+ /** @internal */
54
+ declare const _CONST_PROPS: unique symbol;
100
55
 
101
56
  /**
102
57
  * Effect is something which needs to happen (side-effect) due to signal value change.
@@ -235,6 +190,14 @@ declare interface DescriptorBase<T = unknown, B = unknown> extends BackRef {
235
190
  $destroy$: (() => void) | null;
236
191
  }
237
192
 
193
+ /** @public */
194
+ declare interface DevJSX {
195
+ fileName: string;
196
+ lineNumber: number;
197
+ columnNumber: number;
198
+ stack?: string;
199
+ }
200
+
238
201
  declare type DomRef = {
239
202
  $ssrNode$: SsrNode;
240
203
  };
@@ -252,6 +215,8 @@ export declare function domRender(jsx: JSXOutput, opts?: {
252
215
  /** @internal */
253
216
  declare const _EFFECT_BACK_REF: unique symbol;
254
217
 
218
+ declare type EffectBackRef = SignalImpl | StoreTarget | PropsProxy;
219
+
255
220
  declare const enum EffectProperty {
256
221
  COMPONENT = ":",
257
222
  VNODE = "."
@@ -296,9 +261,9 @@ declare const enum EffectProperty {
296
261
  declare class EffectSubscription {
297
262
  consumer: Consumer;
298
263
  property: EffectProperty | string;
299
- backRef: Set<SignalImpl | StoreTarget> | null;
264
+ backRef: Set<EffectBackRef> | null;
300
265
  data: SubscriptionData | null;
301
- constructor(consumer: Consumer, property: EffectProperty | string, backRef?: Set<SignalImpl | StoreTarget> | null, data?: SubscriptionData | null);
266
+ constructor(consumer: Consumer, property: EffectProperty | string, backRef?: Set<EffectBackRef> | null, data?: SubscriptionData | null);
302
267
  }
303
268
 
304
269
  /**
@@ -336,6 +301,17 @@ export declare function emulateExecutionOfQwikFuncs(document: Document): void;
336
301
  /** @public */
337
302
  export declare function expectDOM(actual: Element, expected: string): Promise<void>;
338
303
 
304
+ /**
305
+ * Any function taking a props object that returns JSXOutput.
306
+ *
307
+ * The `key`, `flags` and `dev` parameters are for internal use.
308
+ *
309
+ * @public
310
+ */
311
+ declare type FunctionComponent<P = unknown> = {
312
+ renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput_2;
313
+ }['renderFn'];
314
+
339
315
  /** @public */
340
316
  export declare function getTestPlatform(): TestPlatform;
341
317
 
@@ -366,6 +342,84 @@ declare interface ISsrNode {
366
342
  setTreeNonUpdatable(): void;
367
343
  }
368
344
 
345
+ /** @public */
346
+ declare type JSXChildren = string | number | boolean | null | undefined | Function | RegExp | JSXChildren[] | Promise<JSXChildren> | Signal<JSXChildren> | JSXNode;
347
+
348
+ /**
349
+ * A JSX Node, an internal structure. You probably want to use `JSXOutput` instead.
350
+ *
351
+ * @public
352
+ */
353
+ declare interface JSXNode<T extends string | FunctionComponent | unknown = unknown> {
354
+ type: T;
355
+ props: T extends FunctionComponent<infer P> ? P : Record<any, unknown>;
356
+ children: JSXChildren | null;
357
+ key: string | null;
358
+ dev?: DevJSX;
359
+ }
360
+
361
+ declare class JSXNodeImpl<T = unknown> implements JSXNodeInternal_2<T> {
362
+ type: T;
363
+ children: JSXChildren;
364
+ toSort: boolean;
365
+ key: string | null;
366
+ varProps: Props;
367
+ constProps: Props | null;
368
+ dev?: DevJSX & {
369
+ stack: string | undefined;
370
+ };
371
+ _proxy: Props | null;
372
+ constructor(type: T, varProps: Props | null, constProps: Props | null, children: JSXChildren, key: string | number | null | undefined, toSort?: boolean, dev?: DevJSX);
373
+ get props(): T extends FunctionComponent<infer PROPS> ? PROPS : Props;
374
+ }
375
+
376
+ /**
377
+ * The internal representation of a JSX Node.
378
+ *
379
+ * @internal
380
+ */
381
+ declare interface JSXNodeInternal_2<T extends string | FunctionComponent | unknown = unknown> extends JSXNode<T> {
382
+ /** The type of node */
383
+ type: T;
384
+ /** Do the varProps need sorting */
385
+ toSort: boolean;
386
+ /** The key property */
387
+ key: string | null;
388
+ /**
389
+ * Props that are not guaranteed shallow equal across runs.
390
+ *
391
+ * Any prop that is in `constProps` takes precedence over `varProps`.
392
+ *
393
+ * Does not contain `children` or `key`.
394
+ *
395
+ * `onEvent$` props are normalized to the html `q-x:event` version
396
+ */
397
+ varProps: Props;
398
+ /**
399
+ * Props that will be shallow equal across runs. Does not contain any props that are in varProps.
400
+ *
401
+ * Any prop that is in `constProps` takes precedence over `varProps`.
402
+ *
403
+ * Does not contain `children` or `key`.
404
+ *
405
+ * `onEvent$` props are normalized to the html `q-x:event` version
406
+ */
407
+ constProps: Props | null;
408
+ /** The children of the node */
409
+ children: JSXChildren;
410
+ /** Filename etc for debugging */
411
+ dev?: DevJSX & {
412
+ stack: string | undefined;
413
+ };
414
+ }
415
+
416
+ /**
417
+ * Any valid output for a component
418
+ *
419
+ * @public
420
+ */
421
+ declare type JSXOutput_2 = JSXNode | string | number | boolean | null | undefined | JSXOutput_2[];
422
+
369
423
  /** @public */
370
424
  declare interface MockDocument extends Document {
371
425
  }
@@ -392,10 +446,36 @@ declare interface NodePropData {
392
446
 
393
447
  declare type ObjToProxyMap = WeakMap<any, any>;
394
448
 
449
+ /** @internal */
450
+ declare const _OWNER: unique symbol;
451
+
395
452
  declare type PossibleEvents = Event | SimplifiedServerRequestEvent | typeof TaskEvent | typeof RenderEvent;
396
453
 
397
454
  declare type Props = Record<string, unknown>;
398
455
 
456
+ /** @internal */
457
+ declare const _PROPS_HANDLER: unique symbol;
458
+
459
+ declare type PropsProxy = {
460
+ [_VAR_PROPS]: Props;
461
+ [_CONST_PROPS]: Props | null;
462
+ [_OWNER]: JSXNodeInternal_2;
463
+ [_PROPS_HANDLER]: PropsProxyHandler;
464
+ } & Record<string | symbol, unknown>;
465
+
466
+ declare class PropsProxyHandler implements ProxyHandler<any> {
467
+ owner: JSXNodeImpl;
468
+ $effects$: undefined | Map<string | symbol, Set<EffectSubscription>>;
469
+ $container$: Container | null;
470
+ constructor(owner: JSXNodeImpl);
471
+ get(_: any, prop: string | symbol): any;
472
+ set(_: any, prop: string | symbol, value: any): boolean;
473
+ deleteProperty(_: any, prop: string | symbol): boolean;
474
+ has(_: any, prop: string | symbol): boolean;
475
+ getOwnPropertyDescriptor(_: any, p: string | symbol): PropertyDescriptor | undefined;
476
+ ownKeys(): string[];
477
+ }
478
+
399
479
  /**
400
480
  * The `QRL` type represents a lazy-loadable AND serializable resource.
401
481
  *
@@ -567,22 +647,8 @@ declare type QRLInternalMethods<TYPE> = {
567
647
 
568
648
  declare type QrlReturn<T> = T extends (...args: any) => infer R ? Awaited<R> : unknown;
569
649
 
570
- /** @public */
571
- declare interface ReadonlySignal<T = unknown> {
572
- readonly value: T;
573
- }
574
-
575
650
  declare const RenderEvent = "qRender";
576
651
 
577
- declare interface ResourceReturnInternal<T> {
578
- __brand: 'resource';
579
- value: Promise<T>;
580
- loading: boolean;
581
- signal: AsyncSignal<{
582
- r: T;
583
- }>;
584
- }
585
-
586
652
  /** Stores the location of an object. If no parent, it's a root. */
587
653
  declare type SeenRef = {
588
654
  $index$: number;
@@ -627,14 +693,13 @@ declare interface SerializationContext {
627
693
  $renderSymbols$: Set<string>;
628
694
  $storeProxyMap$: ObjToProxyMap;
629
695
  $eagerResume$: Set<unknown>;
630
- $resources$: Set<ResourceReturnInternal<any>>;
631
- $getProp$: (obj: any, prop: string) => any;
632
696
  $setProp$: (obj: any, prop: string, value: any) => void;
633
697
  }
634
698
 
635
699
  declare const enum SerializationSignalFlags {
636
700
  SERIALIZATION_STRATEGY_NEVER = 8,
637
- SERIALIZATION_STRATEGY_ALWAYS = 16
701
+ SERIALIZATION_STRATEGY_ALWAYS = 16,
702
+ SERIALIZATION_ALL_STRATEGIES = 24
638
703
  }
639
704
 
640
705
  /**
@@ -649,8 +714,16 @@ declare const enum SerializationSignalFlags {
649
714
  *
650
715
  * @public
651
716
  */
652
- declare interface Signal<T = any> extends ReadonlySignal<T> {
717
+ declare interface Signal<T = any> {
718
+ /** Reading from this subscribes to updates; writing to this triggers updates. */
653
719
  value: T;
720
+ /** Reading from this does not subscribe to updates; writing to this does not trigger updates. */
721
+ untrackedValue: T;
722
+ /**
723
+ * Use this to trigger running subscribers, for example when the value mutated but remained the
724
+ * same object.
725
+ */
726
+ trigger(): void;
654
727
  }
655
728
 
656
729
  declare const enum SignalFlags {
@@ -666,9 +739,11 @@ declare class SignalImpl<T = any> implements Signal<T> {
666
739
  $wrappedSignal$: WrappedSignalImpl<T> | null;
667
740
  constructor(container: Container | null, value: T);
668
741
  /**
669
- * Use this to force running subscribers, for example when the calculated value has mutated but
742
+ * Use this to trigger running subscribers, for example when the calculated value has mutated but
670
743
  * remained the same object
671
744
  */
745
+ trigger(): void;
746
+ /** @deprecated Use `trigger()` instead */
672
747
  force(): void;
673
748
  get untrackedValue(): T;
674
749
  set untrackedValue(value: T);
@@ -681,20 +756,12 @@ declare class SignalImpl<T = any> implements Signal<T> {
681
756
  };
682
757
  }
683
758
 
684
- declare type SimpleSsrAttrValue = string | Signal<SimpleSsrAttrValue> | boolean | object | null;
685
-
686
759
  declare interface SimplifiedServerRequestEvent<T = unknown> {
687
760
  url: URL;
688
761
  locale: string | undefined;
689
762
  request: Request;
690
763
  }
691
764
 
692
- declare type SsrAttrKey = string;
693
-
694
- declare type SsrAttrs = Array<SsrAttrKey | SsrAttrValue>;
695
-
696
- declare type SsrAttrValue = SimpleSsrAttrValue | Promise<SimpleSsrAttrValue>;
697
-
698
765
  /** A selection of attributes of the real thing */
699
766
  declare type SsrNode = {
700
767
  id: string;
@@ -797,6 +864,9 @@ export declare function trigger(root: Element, queryOrElement: string | Element
797
864
  */
798
865
  declare type ValueOrPromise<T> = T | Promise<T>;
799
866
 
867
+ /** @internal */
868
+ declare const _VAR_PROPS: unique symbol;
869
+
800
870
  /** @internal */
801
871
  declare abstract class VNode implements BackRef {
802
872
  flags: VNodeFlags;
@@ -848,7 +918,7 @@ export declare function vnode_fromJSX(jsx: JSXOutput): {
848
918
  * this data needs to be serialized into a string and stored in the DOM as a script tag which has
849
919
  * deferent serialization format.
850
920
  */
851
- declare type VNodeData = [VNodeDataFlag, ...(SsrAttrs | number)[]];
921
+ declare type VNodeData = [VNodeDataFlag, ...(Props | number)[]];
852
922
 
853
923
  /**
854
924
  * Flags for VNodeData (Flags con be bitwise combined)
@@ -925,7 +995,7 @@ declare const enum WrappedSignalFlags {
925
995
  UNWRAP = 4
926
996
  }
927
997
 
928
- declare class WrappedSignalImpl<T> extends SignalImpl<T> implements BackRef {
998
+ declare class WrappedSignalImpl<T> extends SignalImpl<T> {
929
999
  $args$: any[];
930
1000
  $func$: (...args: any[]) => T;
931
1001
  $funcStr$: string | null;