@qwik.dev/core 2.0.0-beta.15 → 2.0.0-beta.17

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,19 +18,9 @@ declare interface AddRootFn {
18
18
 
19
19
  declare type AllSignalFlags = SignalFlags | WrappedSignalFlags | SerializationSignalFlags;
20
20
 
21
- declare type AsyncComputedCtx = {
22
- track: Tracker;
23
- cleanup: (callback: () => void) => void;
24
- };
25
-
26
- /** @public */
27
- declare type AsyncComputedFn<T> = (ctx: AsyncComputedCtx) => Promise<T>;
28
-
29
- declare type AsyncComputeQRL<T> = QRLInternal<AsyncComputedFn<T>>;
30
-
31
21
  /** Class for back reference to the EffectSubscription */
32
22
  declare abstract class BackRef {
33
- [_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | undefined;
23
+ [_EFFECT_BACK_REF]: Map<any, any> | undefined;
34
24
  }
35
25
 
36
26
  declare type BivariantQrlFn<ARGS extends any[], RETURN> = {
@@ -43,58 +33,18 @@ declare type BivariantQrlFn<ARGS extends any[], RETURN> = {
43
33
  bivarianceHack(...args: ARGS): Promise<RETURN>;
44
34
  }['bivarianceHack'];
45
35
 
46
- declare interface Chore<T extends ChoreType = ChoreType> {
47
- $type$: T;
48
- $idx$: number | string;
49
- $host$: HostElement;
50
- $target$: ChoreTarget | null;
51
- $payload$: unknown;
52
- $state$: ChoreState;
53
- $blockedChores$: ChoreArray | null;
54
- $startTime$: number | undefined;
55
- $endTime$: number | undefined;
56
- $resolve$: ((value: any) => void) | undefined;
57
- $reject$: ((reason?: any) => void) | undefined;
58
- $returnValue$: ValueOrPromise<ChoreReturnValue<T>>;
59
- }
60
-
61
- declare class ChoreArray extends Array<Chore> {
62
- add(value: Chore): number;
63
- delete(value: Chore): number;
64
- }
65
-
66
- declare type ChoreReturnValue<T extends ChoreType = ChoreType> = T extends ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS | ChoreType.WAIT_FOR_QUEUE | ChoreType.NODE_PROP ? void : T extends ChoreType.NODE_DIFF | ChoreType.COMPONENT ? JSXOutput_2 : unknown;
67
-
68
- declare enum ChoreState {
36
+ declare const enum ChoreBits {
69
37
  NONE = 0,
70
- RUNNING = 1,
71
- FAILED = 2,
72
- DONE = 3
38
+ TASKS = 1,
39
+ NODE_DIFF = 2,
40
+ COMPONENT = 4,
41
+ NODE_PROPS = 8,
42
+ COMPUTE = 16,
43
+ CHILDREN = 32,
44
+ CLEANUP = 64,
45
+ DIRTY_MASK = 127
73
46
  }
74
47
 
75
- declare type ChoreTarget = HostElement | QRLInternal<(...args: unknown[]) => unknown> | Signal | StoreTarget;
76
-
77
- declare const enum ChoreType {
78
- MACRO = 240,
79
- MICRO = 15,
80
- /** Ensure that the QRL promise is resolved before processing next chores in the queue */
81
- QRL_RESOLVE = 1,
82
- RUN_QRL = 2,
83
- TASK = 3,
84
- NODE_DIFF = 4,
85
- NODE_PROP = 5,
86
- COMPONENT = 6,
87
- RECOMPUTE_AND_SCHEDULE_EFFECTS = 7,
88
- VISIBLE = 16,
89
- CLEANUP_VISIBLE = 32,
90
- WAIT_FOR_QUEUE = 255
91
- }
92
-
93
- /** @public */
94
- declare type ComputedFn<T> = () => T;
95
-
96
- declare type ComputeQRL<T> = QRLInternal<ComputedFn<T>>;
97
-
98
48
  /**
99
49
  * Effect is something which needs to happen (side-effect) due to signal value change.
100
50
  *
@@ -104,17 +54,19 @@ declare type ComputeQRL<T> = QRLInternal<ComputedFn<T>>;
104
54
  * - `VNode` and `ISsrNode`: Either a component or `<Signal>`
105
55
  * - `Signal2`: A derived signal which contains a computation function.
106
56
  */
107
- declare type Consumer = Task | VNode | ISsrNode | SignalImpl;
57
+ declare type Consumer = Task | VNode | SignalImpl | ISsrNode;
108
58
 
109
59
  declare interface Container {
110
60
  readonly $version$: string;
111
- readonly $scheduler$: Scheduler;
112
61
  readonly $storeProxyMap$: ObjToProxyMap;
113
62
  readonly $locale$: string;
114
63
  readonly $getObjectById$: (id: number | string) => any;
115
64
  readonly $serverData$: Record<string, any>;
116
65
  $currentUniqueId$: number;
117
66
  $buildBase$: string | null;
67
+ $renderPromise$: Promise<void> | null;
68
+ $resolveRenderPromise$: (() => void) | null;
69
+ $cursorCount$: number;
118
70
  handleError(err: any, $host$: HostElement | null): void;
119
71
  getParentHost(host: HostElement): HostElement | null;
120
72
  setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
@@ -219,18 +171,6 @@ export declare const createDOM: ({ html }?: {
219
171
  userEvent: (queryOrElement: string | Element | keyof HTMLElementTagNameMap | null, eventNameCamel: string | keyof WindowEventMap, eventPayload?: any) => Promise<void>;
220
172
  }>;
221
173
 
222
- declare const createScheduler: (container: Container, journalFlush: () => void, choreQueue: ChoreArray, blockedChores: ChoreArray, runningChores: Set<Chore>) => {
223
- (type: ChoreType.QRL_RESOLVE, ignore: null, target: ComputeQRL<any> | AsyncComputeQRL<any>): Chore<ChoreType.QRL_RESOLVE>;
224
- (type: ChoreType.WAIT_FOR_QUEUE): Chore<ChoreType.WAIT_FOR_QUEUE>;
225
- (type: ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, host: HostElement | undefined, target: Signal<unknown> | StoreTarget, effects: Set<EffectSubscription> | undefined): Chore<ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS>;
226
- (type: ChoreType.TASK | ChoreType.VISIBLE, task: Task): Chore<ChoreType.TASK | ChoreType.VISIBLE>;
227
- (type: ChoreType.RUN_QRL, host: HostElement, target: QRLInternal<(...args: unknown[]) => unknown>, args: unknown[]): Chore<ChoreType.RUN_QRL>;
228
- (type: ChoreType.COMPONENT, host: HostElement, qrl: QRLInternal<OnRenderFn<unknown>>, props: Props | null): Chore<ChoreType.COMPONENT>;
229
- (type: ChoreType.NODE_DIFF, host: HostElement, target: HostElement, value: JSXOutput_2 | Signal): Chore<ChoreType.NODE_DIFF>;
230
- (type: ChoreType.NODE_PROP, host: HostElement, prop: string, value: any): Chore<ChoreType.NODE_PROP>;
231
- (type: ChoreType.CLEANUP_VISIBLE, task: Task): Chore<ChoreType.CLEANUP_VISIBLE>;
232
- };
233
-
234
174
  declare interface DescriptorBase<T = unknown, B = unknown> extends BackRef {
235
175
  $flags$: number;
236
176
  $index$: number;
@@ -240,14 +180,6 @@ declare interface DescriptorBase<T = unknown, B = unknown> extends BackRef {
240
180
  $destroy$: NoSerialize<() => void> | null;
241
181
  }
242
182
 
243
- /** @public */
244
- declare interface DevJSX {
245
- fileName: string;
246
- lineNumber: number;
247
- columnNumber: number;
248
- stack?: string;
249
- }
250
-
251
183
  declare type DomRef = {
252
184
  $ssrNode$: SsrNode;
253
185
  };
@@ -345,32 +277,12 @@ declare interface ElementFixtureOptions {
345
277
  html?: string;
346
278
  }
347
279
 
348
- /** @internal */
349
- declare class ElementVNode extends VNode {
350
- firstChild: VNode | null | undefined;
351
- lastChild: VNode | null | undefined;
352
- element: QElement;
353
- elementName: string | undefined;
354
- constructor(flags: VNodeFlags, parent: ElementVNode | VirtualVNode | null, previousSibling: VNode | null | undefined, nextSibling: VNode | null | undefined, firstChild: VNode | null | undefined, lastChild: VNode | null | undefined, element: QElement, elementName: string | undefined);
355
- }
356
-
357
280
  /** @public */
358
281
  export declare function emulateExecutionOfQwikFuncs(document: Document): void;
359
282
 
360
283
  /** @public */
361
284
  export declare function expectDOM(actual: Element, expected: string): Promise<void>;
362
285
 
363
- /**
364
- * Any function taking a props object that returns JSXOutput.
365
- *
366
- * The `key`, `flags` and `dev` parameters are for internal use.
367
- *
368
- * @public
369
- */
370
- declare type FunctionComponent<P = unknown> = {
371
- renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput_2;
372
- }['renderFn'];
373
-
374
286
  /** @public */
375
287
  export declare function getTestPlatform(): TestPlatform;
376
288
 
@@ -381,8 +293,6 @@ declare interface InvokeContext {
381
293
  $url$: URL | undefined;
382
294
  /** The Virtual parent component for the current component code */
383
295
  $hostElement$: HostElement | undefined;
384
- /** The current DOM element */
385
- $element$: Element | undefined;
386
296
  /** The event we're currently handling */
387
297
  $event$: PossibleEvents | undefined;
388
298
  /** The QRL function we're currently executing */
@@ -397,6 +307,7 @@ declare type InvokeTuple = [Element, Event, URL?];
397
307
  declare interface ISsrNode {
398
308
  id: string;
399
309
  flags: SsrNodeFlags;
310
+ dirty: ChoreBits;
400
311
  parentComponent: ISsrNode | null;
401
312
  vnodeData: VNodeData;
402
313
  currentFile: string | null;
@@ -407,29 +318,6 @@ declare interface ISsrNode {
407
318
  setTreeNonUpdatable(): void;
408
319
  }
409
320
 
410
- /** @public */
411
- declare type JSXChildren = string | number | boolean | null | undefined | Function | RegExp | JSXChildren[] | Promise<JSXChildren> | Signal<JSXChildren> | JSXNode;
412
-
413
- /**
414
- * A JSX Node, an internal structure. You probably want to use `JSXOutput` instead.
415
- *
416
- * @public
417
- */
418
- declare interface JSXNode<T extends string | FunctionComponent | unknown = unknown> {
419
- type: T;
420
- props: T extends FunctionComponent<infer P> ? P : Record<any, unknown>;
421
- children: JSXChildren | null;
422
- key: string | null;
423
- dev?: DevJSX;
424
- }
425
-
426
- /**
427
- * Any valid output for a component
428
- *
429
- * @public
430
- */
431
- declare type JSXOutput_2 = JSXNode | string | number | boolean | null | undefined | JSXOutput_2[];
432
-
433
321
  /** @public */
434
322
  declare interface MockDocument extends Document {
435
323
  }
@@ -466,18 +354,10 @@ declare type NoSerialize<T> = (T & {
466
354
 
467
355
  declare type ObjToProxyMap = WeakMap<any, any>;
468
356
 
469
- /** @public */
470
- declare type OnRenderFn<PROPS> = (props: PROPS) => JSXOutput_2;
471
-
472
357
  declare type PossibleEvents = Event | SimplifiedServerRequestEvent | typeof TaskEvent | typeof RenderEvent | typeof ResourceEvent;
473
358
 
474
359
  declare type Props = Record<string, unknown>;
475
360
 
476
- declare interface QElement extends Element {
477
- qDispatchEvent?: (event: Event, scope: QwikLoaderEventScope) => ValueOrPromise<unknown>;
478
- vNode?: VNode;
479
- }
480
-
481
361
  /**
482
362
  * The `QRL` type represents a lazy-loadable AND serializable resource.
483
363
  *
@@ -622,6 +502,7 @@ declare interface QRLDev {
622
502
  hi: number;
623
503
  }
624
504
 
505
+ /** @internal */
625
506
  declare type QRLInternal<TYPE = unknown> = QRL<TYPE> & QRLInternalMethods<TYPE>;
626
507
 
627
508
  declare type QRLInternalMethods<TYPE> = {
@@ -642,8 +523,6 @@ declare type QRLInternalMethods<TYPE> = {
642
523
 
643
524
  declare type QrlReturn<T> = T extends (...args: any) => infer R ? Awaited<R> : unknown;
644
525
 
645
- declare type QwikLoaderEventScope = '-document' | '-window' | '';
646
-
647
526
  /** @public */
648
527
  declare interface ReadonlySignal<T = unknown> {
649
528
  readonly value: T;
@@ -660,12 +539,11 @@ declare interface ResourceReturnInternal<T> {
660
539
  _error: Error | undefined;
661
540
  _cache: number;
662
541
  _timeout: number;
542
+ _generation: number;
663
543
  value: Promise<T>;
664
544
  loading: boolean;
665
545
  }
666
546
 
667
- declare type Scheduler = ReturnType<typeof createScheduler>;
668
-
669
547
  /** Stores the location of an object. If no parent, it's a root. */
670
548
  declare type SeenRef = {
671
549
  $index$: number;
@@ -856,91 +734,6 @@ declare interface TestPlatform extends CorePlatform {
856
734
  flush: () => Promise<void>;
857
735
  }
858
736
 
859
- /**
860
- * Used to signal to Qwik which state should be watched for changes.
861
- *
862
- * The `Tracker` is passed into the `taskFn` of `useTask`. It is intended to be used to wrap state
863
- * objects in a read proxy which signals to Qwik which properties should be watched for changes. A
864
- * change to any of the properties causes the `taskFn` to rerun.
865
- *
866
- * ### Example
867
- *
868
- * The `obs` passed into the `taskFn` is used to mark `state.count` as a property of interest. Any
869
- * changes to the `state.count` property will cause the `taskFn` to rerun.
870
- *
871
- * ```tsx
872
- * const Cmp = component$(() => {
873
- * const store = useStore({ count: 0, doubleCount: 0 });
874
- * const signal = useSignal(0);
875
- * useTask$(({ track }) => {
876
- * // Any signals or stores accessed inside the task will be tracked
877
- * const count = track(() => store.count);
878
- * // You can also pass a signal to track() directly
879
- * const signalCount = track(signal);
880
- * store.doubleCount = count + signalCount;
881
- * });
882
- * return (
883
- * <div>
884
- * <span>
885
- * {store.count} / {store.doubleCount}
886
- * </span>
887
- * <button
888
- * onClick$={() => {
889
- * store.count++;
890
- * signal.value++;
891
- * }}
892
- * >
893
- * +
894
- * </button>
895
- * </div>
896
- * );
897
- * });
898
- * ```
899
- *
900
- * @public
901
- * @see `useTask`
902
- */
903
- declare interface Tracker {
904
- /**
905
- * Include the expression using stores / signals to track:
906
- *
907
- * ```tsx
908
- * track(() => store.count);
909
- * ```
910
- *
911
- * The `track()` function also returns the value of the scoped expression:
912
- *
913
- * ```tsx
914
- * const count = track(() => store.count);
915
- * ```
916
- */
917
- <T>(fn: () => T): T;
918
- /**
919
- * Used to track the whole object. If any property of the passed store changes, the task will be
920
- * scheduled to run. Also accepts signals.
921
- *
922
- * Note that the change tracking is not deep. If you want to track changes to nested properties,
923
- * you need to use `track` on each of them.
924
- *
925
- * ```tsx
926
- * track(store); // returns store
927
- * track(signal); // returns signal.value
928
- * ```
929
- */
930
- <T extends object>(obj: T): T extends Signal<infer U> ? U : T;
931
- /**
932
- * Used to track to track a specific property of an object.
933
- *
934
- * Note that the change tracking is not deep. If you want to track changes to nested properties,
935
- * you need to use `track` on each of them.
936
- *
937
- * ```tsx
938
- * track(store, 'propA'); // returns store.propA
939
- * ```
940
- */
941
- <T extends object, P extends keyof T>(obj: T, prop: P): T[P];
942
- }
943
-
944
737
  /**
945
738
  * Trigger an event in unit tests on an element. Needs to be kept in sync with the Qwik Loader event
946
739
  * dispatching.
@@ -960,28 +753,18 @@ export declare function trigger(root: Element, queryOrElement: string | Element
960
753
  */
961
754
  declare type ValueOrPromise<T> = T | Promise<T>;
962
755
 
963
- /** @internal */
964
- declare class VirtualVNode extends VNode {
965
- firstChild: VNode | null | undefined;
966
- lastChild: VNode | null | undefined;
967
- constructor(flags: VNodeFlags, parent: ElementVNode | VirtualVNode | null, previousSibling: VNode | null | undefined, nextSibling: VNode | null | undefined, firstChild: VNode | null | undefined, lastChild: VNode | null | undefined);
968
- }
969
-
970
756
  /** @internal */
971
757
  declare abstract class VNode extends BackRef {
972
758
  flags: VNodeFlags;
973
- parent: ElementVNode | VirtualVNode | null;
759
+ parent: VNode | null;
974
760
  previousSibling: VNode | null | undefined;
975
761
  nextSibling: VNode | null | undefined;
976
- props: unknown[] | null;
762
+ props: Props | null;
977
763
  slotParent: VNode | null;
978
- chores: ChoreArray | null;
979
- blockedChores: ChoreArray | null;
980
- constructor(flags: VNodeFlags, parent: ElementVNode | VirtualVNode | null, previousSibling: VNode | null | undefined, nextSibling: VNode | null | undefined);
981
- getProp<T>(key: string, getObject: ((id: string) => any) | null): T | null;
982
- setProp(key: string, value: any): void;
983
- getAttr(key: string): string | null;
984
- setAttr(key: string, value: string | null | boolean, journal: VNodeJournal | null): void;
764
+ dirty: ChoreBits;
765
+ dirtyChildren: VNode[] | null;
766
+ nextDirtyChildIndex: number;
767
+ constructor(flags: VNodeFlags, parent: VNode | null, previousSibling: VNode | null | undefined, nextSibling: VNode | null | undefined, props: Props | null);
985
768
  toString(): string;
986
769
  }
987
770
 
@@ -1066,30 +849,12 @@ declare const enum VNodeFlags {
1066
849
  Inflated = 8,
1067
850
  Resolved = 16,
1068
851
  Deleted = 32,
1069
- NAMESPACE_MASK = 192,
1070
- NEGATED_NAMESPACE_MASK = -193,
852
+ Cursor = 64,
853
+ NAMESPACE_MASK = 384,
854
+ NEGATED_NAMESPACE_MASK = -385,
1071
855
  NS_html = 0,// http://www.w3.org/1999/xhtml
1072
- NS_svg = 64,// http://www.w3.org/2000/svg
1073
- NS_math = 128
1074
- }
1075
-
1076
- declare type VNodeJournal = Array<VNodeJournalOpCode | Document | Element | Text | string | boolean | null>;
1077
-
1078
- /**
1079
- * Fundamental DOM operations are:
1080
- *
1081
- * - Insert new DOM element/text
1082
- * - Remove DOM element/text
1083
- * - Set DOM element attributes
1084
- * - Set text node value
1085
- */
1086
- declare const enum VNodeJournalOpCode {
1087
- SetText = 1,// ------ [SetAttribute, target, text]
1088
- SetAttribute = 2,// - [SetAttribute, target, ...(key, values)]]
1089
- HoistStyles = 3,// -- [HoistStyles, document]
1090
- Remove = 4,// ------- [Remove, target(parent), ...nodes]
1091
- RemoveAll = 5,// ------- [RemoveAll, target(parent)]
1092
- Insert = 6
856
+ NS_svg = 128,// http://www.w3.org/2000/svg
857
+ NS_math = 256
1093
858
  }
1094
859
 
1095
860
  /**