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

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 (136) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.linux-x64-gnu.node +0 -0
  3. package/bindings/qwik.win32-x64-msvc.node +0 -0
  4. package/bindings/qwik_wasm_bg.wasm +0 -0
  5. package/dist/backpatch/index.d.ts +2 -0
  6. package/dist/backpatch/index.mjs +5 -0
  7. package/dist/backpatch/package.json +8 -0
  8. package/dist/backpatch-executor.debug.js +39 -0
  9. package/dist/backpatch-executor.js +1 -0
  10. package/dist/build/package.json +1 -1
  11. package/dist/cli.mjs +5633 -0
  12. package/dist/core-internal.d.ts +673 -396
  13. package/dist/core.min.mjs +2 -1
  14. package/dist/core.mjs +10168 -8294
  15. package/dist/core.mjs.map +1 -1
  16. package/dist/core.prod.mjs +5745 -4592
  17. package/dist/insights/vite/index.mjs +10 -10
  18. package/dist/loader/index.mjs +2 -2
  19. package/dist/loader/package.json +1 -1
  20. package/dist/optimizer.d.ts +16 -38
  21. package/dist/optimizer.mjs +2608 -3719
  22. package/dist/preloader.mjs +8 -11
  23. package/dist/qwikloader.debug.js +152 -132
  24. package/dist/qwikloader.js +1 -1
  25. package/dist/server.d.ts +38 -15
  26. package/dist/server.mjs +1209 -927
  27. package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/{vite.config.mts → vite.config.ts} +2 -2
  28. package/dist/starters/adapters/aws-lambda/package.json +3 -2
  29. package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +2 -6
  30. package/dist/starters/adapters/azure-swa/adapters/azure-swa/{vite.config.mts → vite.config.ts} +2 -2
  31. package/dist/starters/adapters/azure-swa/package.json +3 -2
  32. package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +2 -3
  33. package/dist/starters/adapters/bun/adapters/bun/{vite.config.mts → vite.config.ts} +3 -3
  34. package/dist/starters/adapters/bun/package.json +3 -2
  35. package/dist/starters/adapters/bun/src/entry.bun.ts +0 -2
  36. package/dist/starters/adapters/cloud-run/adapters/cloud-run/{vite.config.mts → vite.config.ts} +2 -2
  37. package/dist/starters/adapters/cloud-run/package.json +3 -2
  38. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
  39. package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/{vite.config.mts → vite.config.ts} +2 -2
  40. package/dist/starters/adapters/cloudflare-pages/package.json +3 -2
  41. package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +2 -3
  42. package/dist/starters/adapters/cloudflare-workers/README.md +52 -0
  43. package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +15 -0
  44. package/dist/starters/adapters/cloudflare-workers/gitignore +3 -0
  45. package/dist/starters/adapters/cloudflare-workers/package.json +31 -0
  46. package/dist/starters/adapters/cloudflare-workers/public/.assetsignore +4 -0
  47. package/dist/starters/adapters/cloudflare-workers/public/_headers +11 -0
  48. package/dist/starters/adapters/cloudflare-workers/public/_redirects +1 -0
  49. package/dist/starters/adapters/cloudflare-workers/src/entry.cloudflare-pages.tsx +23 -0
  50. package/dist/starters/adapters/cloudflare-workers/worker-configuration.d.ts +5 -0
  51. package/dist/starters/adapters/cloudflare-workers/wrangler.jsonc +41 -0
  52. package/dist/starters/adapters/deno/adapters/deno/{vite.config.mts → vite.config.ts} +2 -2
  53. package/dist/starters/adapters/deno/package.json +3 -2
  54. package/dist/starters/adapters/deno/src/entry.deno.ts +0 -2
  55. package/dist/starters/adapters/express/adapters/express/{vite.config.mts → vite.config.ts} +2 -2
  56. package/dist/starters/adapters/express/package.json +4 -3
  57. package/dist/starters/adapters/express/src/entry.express.tsx +1 -3
  58. package/dist/starters/adapters/fastify/adapters/fastify/{vite.config.mts → vite.config.ts} +2 -2
  59. package/dist/starters/adapters/fastify/package.json +3 -2
  60. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +1 -1
  61. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +1 -2
  62. package/dist/starters/adapters/firebase/adapters/firebase/{vite.config.mts → vite.config.ts} +2 -2
  63. package/dist/starters/adapters/firebase/package.json +3 -2
  64. package/dist/starters/adapters/firebase/src/entry-firebase.tsx +2 -3
  65. package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/{vite.config.mts → vite.config.ts} +2 -2
  66. package/dist/starters/adapters/netlify-edge/package.json +3 -2
  67. package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +2 -3
  68. package/dist/starters/adapters/node-server/adapters/node-server/{vite.config.mts → vite.config.ts} +2 -2
  69. package/dist/starters/adapters/node-server/package.json +3 -2
  70. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +0 -2
  71. package/dist/starters/adapters/{static/adapters/static/vite.config.mts → ssg/adapters/ssg/vite.config.ts} +3 -3
  72. package/dist/starters/adapters/ssg/package.json +20 -0
  73. package/dist/starters/adapters/vercel-edge/README.md +2 -2
  74. package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/{vite.config.mts → vite.config.ts} +2 -2
  75. package/dist/starters/adapters/vercel-edge/package.json +3 -2
  76. package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +2 -3
  77. package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
  78. package/dist/starters/features/auth/package.json +1 -1
  79. package/dist/starters/features/compiled-i18n/package.json +37 -0
  80. package/dist/starters/features/compiled-i18n/src/components/locale-selector/locale-selector.tsx +30 -0
  81. package/dist/starters/features/compiled-i18n/src/entry.ssr.tsx +31 -0
  82. package/dist/starters/features/compiled-i18n/src/routes/plugin@compiled-i18n.ts +28 -0
  83. package/dist/starters/features/csr/index.html +23 -0
  84. package/dist/starters/features/csr/package.json +29 -0
  85. package/dist/starters/features/csr/src/root.tsx +15 -0
  86. package/dist/starters/features/csr/vite.config.ts +13 -0
  87. package/dist/starters/features/cypress/src/actions/example.action.ts +5 -0
  88. package/dist/starters/features/cypress/src/components/example/example.cy.tsx +50 -8
  89. package/dist/starters/features/cypress/src/components/example/example.tsx +13 -3
  90. package/dist/starters/features/cypress/src/loaders/example.loader.ts +5 -0
  91. package/dist/starters/features/pandacss/package.json +1 -1
  92. package/dist/starters/features/playwright/playwright-report/index.html +953 -930
  93. package/dist/starters/features/postcss/postcss.config.js +1 -1
  94. package/dist/starters/features/storybook/.storybook/tsconfig.json +0 -1
  95. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  96. package/dist/starters/features/tailwind/package.json +2 -2
  97. package/dist/starters/features/tailwind/prettier.config.js +10 -0
  98. package/dist/starters/features/tailwind-v3/package.json +1 -1
  99. package/dist/starters/features/tailwind-v3/prettier.config.js +10 -0
  100. package/dist/testing/index.d.ts +775 -6
  101. package/dist/testing/index.mjs +14298 -10837
  102. package/dist/testing/package.json +1 -1
  103. package/handlers.mjs +1 -1
  104. package/package.json +30 -55
  105. package/public.d.ts +3 -1
  106. package/{qwik-cli.cjs → qwik-cli.mjs} +1 -1
  107. package/server.d.ts +2 -0
  108. package/bindings/qwik.darwin-x64.node +0 -0
  109. package/bindings/qwik.wasm.cjs +0 -471
  110. package/dist/build/index.cjs +0 -35
  111. package/dist/build/index.cjs.map +0 -7
  112. package/dist/build/index.dev.cjs +0 -37
  113. package/dist/build/index.dev.cjs.map +0 -7
  114. package/dist/build/index.prod.cjs +0 -37
  115. package/dist/build/index.prod.cjs.map +0 -7
  116. package/dist/cli.cjs +0 -5545
  117. package/dist/core.cjs +0 -11754
  118. package/dist/core.cjs.map +0 -1
  119. package/dist/core.prod.cjs +0 -5647
  120. package/dist/insights/index.qwik.cjs +0 -1
  121. package/dist/insights/vite/index.cjs +0 -1
  122. package/dist/loader/index.cjs +0 -4
  123. package/dist/optimizer.cjs +0 -4020
  124. package/dist/preloader.cjs +0 -269
  125. package/dist/server.cjs +0 -3027
  126. package/dist/starters/adapters/static/package.json +0 -19
  127. package/dist/starters/features/localize/package.json +0 -37
  128. package/dist/starters/features/localize/src/entry.ssr.tsx +0 -30
  129. package/dist/starters/features/localize/src/locales/message.en.json +0 -8
  130. package/dist/starters/features/localize/src/locales/message.it.json +0 -8
  131. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +0 -94
  132. package/dist/starters/features/localize/src/routes/[locale]/index.tsx +0 -52
  133. package/dist/starters/features/localize/src/routes/[locale]/layout.tsx +0 -12
  134. package/dist/starters/features/tailwind/.prettierrc.js +0 -3
  135. package/dist/testing/index.cjs +0 -33287
  136. /package/dist/starters/adapters/{static → ssg}/README.md +0 -0
@@ -1,4 +1,5 @@
1
- import { ClientContainer } from '../internal';
1
+ import { ClientContainer } from '..';
2
+ import type { ClientContainer as ClientContainer_2 } from '../internal';
2
3
  import type { CorePlatform } from '..';
3
4
  import type { _DomContainer } from '../internal';
4
5
  import type { _ElementVNode } from '../internal';
@@ -10,6 +11,147 @@ import type { _Stringifiable } from '../internal';
10
11
  import type { _VirtualVNode } from '../internal';
11
12
  import type { _VNode } from '../internal';
12
13
 
14
+ declare interface AddRootFn {
15
+ (obj: unknown, returnRef?: never): number;
16
+ (obj: unknown, returnRef: true): SeenRef;
17
+ }
18
+
19
+ declare type AllSignalFlags = SignalFlags | WrappedSignalFlags | SerializationSignalFlags;
20
+
21
+ /** Class for back reference to the EffectSubscription */
22
+ declare abstract class BackRef {
23
+ [_EFFECT_BACK_REF]: Map<any, any> | undefined;
24
+ }
25
+
26
+ declare type BivariantQrlFn<ARGS extends any[], RETURN> = {
27
+ /**
28
+ * Resolve the QRL of closure and invoke it.
29
+ *
30
+ * @param args - Closure arguments.
31
+ * @returns A promise of the return value of the closure.
32
+ */
33
+ bivarianceHack(...args: ARGS): Promise<RETURN>;
34
+ }['bivarianceHack'];
35
+
36
+ declare const enum ChoreBits {
37
+ NONE = 0,
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
46
+ }
47
+
48
+ /**
49
+ * Effect is something which needs to happen (side-effect) due to signal value change.
50
+ *
51
+ * There are three types of effects:
52
+ *
53
+ * - `Task`: `useTask`, `useVisibleTask`, `useResource`
54
+ * - `VNode` and `ISsrNode`: Either a component or `<Signal>`
55
+ * - `Signal2`: A derived signal which contains a computation function.
56
+ */
57
+ declare type Consumer = Task | VNode | SignalImpl | ISsrNode;
58
+
59
+ /** @internal */
60
+ declare interface Container {
61
+ readonly $version$: string;
62
+ readonly $storeProxyMap$: ObjToProxyMap;
63
+ readonly $locale$: string;
64
+ readonly $getObjectById$: (id: number | string) => any;
65
+ readonly $serverData$: Record<string, any>;
66
+ $currentUniqueId$: number;
67
+ $buildBase$: string | null;
68
+ $renderPromise$: Promise<void> | null;
69
+ $resolveRenderPromise$: (() => void) | null;
70
+ $cursorCount$: number;
71
+ $pausedCursorCount$: number;
72
+ handleError(err: any, $host$: HostElement | null): void;
73
+ getParentHost(host: HostElement): HostElement | null;
74
+ setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
75
+ resolveContext<T>(host: HostElement, contextId: ContextId<T>): T | undefined;
76
+ setHostProp<T>(host: HostElement, name: string, value: T): void;
77
+ getHostProp<T>(host: HostElement, name: string): T | null;
78
+ $appendStyle$(content: string, styleId: string, host: HostElement, scoped: boolean): void;
79
+ /**
80
+ * When component is about to be executed, it may add/remove children. This can cause problems
81
+ * with the projection because deleting content will prevent the projection references from
82
+ * looking up vnodes. Therefore before we execute the component we need to ensure that all of its
83
+ * references to vnode are resolved.
84
+ *
85
+ * @param renderHost - Host element to ensure projection is resolved.
86
+ */
87
+ ensureProjectionResolved(host: HostElement): void;
88
+ serializationCtxFactory(NodeConstructor: {
89
+ new (...rest: any[]): {
90
+ __brand__: 'SsrNode';
91
+ };
92
+ } | null, DomRefConstructor: {
93
+ new (...rest: any[]): {
94
+ __brand__: 'DomRef';
95
+ };
96
+ } | null, symbolToChunkResolver: SymbolToChunkResolver, writer?: StreamWriter): SerializationContext;
97
+ }
98
+
99
+ /**
100
+ * ContextId is a typesafe ID for your context.
101
+ *
102
+ * Context is a way to pass stores to the child components without prop-drilling.
103
+ *
104
+ * Use `createContextId()` to create a `ContextId`. A `ContextId` is just a serializable identifier
105
+ * for the context. It is not the context value itself. See `useContextProvider()` and
106
+ * `useContext()` for the values. Qwik needs a serializable ID for the context so that the it can
107
+ * track context providers and consumers in a way that survives resumability.
108
+ *
109
+ * ### Example
110
+ *
111
+ * ```tsx
112
+ * // Declare the Context type.
113
+ * interface TodosStore {
114
+ * items: string[];
115
+ * }
116
+ * // Create a Context ID (no data is saved here.)
117
+ * // You will use this ID to both create and retrieve the Context.
118
+ * export const TodosContext = createContextId<TodosStore>('Todos');
119
+ *
120
+ * // Example of providing context to child components.
121
+ * export const App = component$(() => {
122
+ * useContextProvider(
123
+ * TodosContext,
124
+ * useStore<TodosStore>({
125
+ * items: ['Learn Qwik', 'Build Qwik app', 'Profit'],
126
+ * })
127
+ * );
128
+ *
129
+ * return <Items />;
130
+ * });
131
+ *
132
+ * // Example of retrieving the context provided by a parent component.
133
+ * export const Items = component$(() => {
134
+ * const todos = useContext(TodosContext);
135
+ * return (
136
+ * <ul>
137
+ * {todos.items.map((item) => (
138
+ * <li>{item}</li>
139
+ * ))}
140
+ * </ul>
141
+ * );
142
+ * });
143
+ *
144
+ * ```
145
+ *
146
+ * @public
147
+ */
148
+ declare interface ContextId<STATE> {
149
+ /** Design-time property to store type information for the context. */
150
+ readonly __brand_context_type__: STATE;
151
+ /** A unique ID for the context. */
152
+ readonly id: string;
153
+ }
154
+
13
155
  /**
14
156
  * Create emulated `Document` for server environment. Does not implement the full browser `document`
15
157
  * and `window` API. This api may be removed in the future.
@@ -31,6 +173,19 @@ export declare const createDOM: ({ html }?: {
31
173
  userEvent: (queryOrElement: string | Element | keyof HTMLElementTagNameMap | null, eventNameCamel: string | keyof WindowEventMap, eventPayload?: any) => Promise<void>;
32
174
  }>;
33
175
 
176
+ declare interface DescriptorBase<T = unknown, B = unknown> extends BackRef {
177
+ $flags$: number;
178
+ $index$: number;
179
+ $el$: HostElement;
180
+ $qrl$: QRLInternal<T>;
181
+ $state$: B | undefined;
182
+ $destroy$: NoSerialize<() => void> | null;
183
+ }
184
+
185
+ declare type DomRef = {
186
+ $ssrNode$: SsrNode;
187
+ };
188
+
34
189
  /** @public */
35
190
  export declare function domRender(jsx: JSXOutput, opts?: {
36
191
  debug?: boolean;
@@ -41,6 +196,58 @@ export declare function domRender(jsx: JSXOutput, opts?: {
41
196
  getStyles: () => Record<string, string | string[]>;
42
197
  }>;
43
198
 
199
+ /** @internal */
200
+ declare const _EFFECT_BACK_REF: unique symbol;
201
+
202
+ declare const enum EffectProperty {
203
+ COMPONENT = ":",
204
+ VNODE = "."
205
+ }
206
+
207
+ /**
208
+ * An effect consumer plus type of effect, back references to producers and additional data
209
+ *
210
+ * An effect can be trigger by one or more of signal inputs. The first step of re-running an effect
211
+ * is to clear its subscriptions so that the effect can re add new set of subscriptions. In order to
212
+ * clear the subscriptions we need to store them here.
213
+ *
214
+ * Imagine you have effect such as:
215
+ *
216
+ * ```
217
+ * function effect1() {
218
+ * console.log(signalA.value ? signalB.value : 'default');
219
+ * }
220
+ * ```
221
+ *
222
+ * In the above case the `signalB` needs to be unsubscribed when `signalA` is falsy. We do this by
223
+ * always clearing all of the subscriptions
224
+ *
225
+ * The `EffectSubscription` stores
226
+ *
227
+ * ```
228
+ * subscription1 = [effectConsumer1, EffectProperty.COMPONENT, Set[(signalA, signalB)]];
229
+ * ```
230
+ *
231
+ * The `signal1` and `signal2` back references are needed to "clear" existing subscriptions.
232
+ *
233
+ * Both `signalA` as well as `signalB` will have a reference to `subscription` to the so that the
234
+ * effect can be scheduled if either `signalA` or `signalB` triggers. The `subscription1` is shared
235
+ * between the signals.
236
+ *
237
+ * The second position `EffectProperty|string` store the property name of the effect.
238
+ *
239
+ * - Property name of the VNode
240
+ * - `EffectProperty.COMPONENT` if component
241
+ * - `EffectProperty.VNODE` if VNode
242
+ */
243
+ declare class EffectSubscription {
244
+ consumer: Consumer;
245
+ property: EffectProperty | string;
246
+ backRef: Set<SignalImpl | StoreTarget> | null;
247
+ data: SubscriptionData | null;
248
+ constructor(consumer: Consumer, property: EffectProperty | string, backRef?: Set<SignalImpl | StoreTarget> | null, data?: SubscriptionData | null);
249
+ }
250
+
44
251
  /**
45
252
  * Creates a simple DOM structure for testing components.
46
253
  *
@@ -79,6 +286,33 @@ export declare function expectDOM(actual: Element, expected: string): Promise<vo
79
286
  /** @public */
80
287
  export declare function getTestPlatform(): TestPlatform;
81
288
 
289
+ declare type HostElement = VNode | ISsrNode;
290
+
291
+ /** The shared state during an invoke() call */
292
+ declare interface InvokeContext {
293
+ /** The Virtual parent component for the current component code */
294
+ $hostElement$: HostElement | undefined;
295
+ /** The event we're currently handling */
296
+ $event$: PossibleEvents | undefined;
297
+ $effectSubscriber$: EffectSubscription | undefined;
298
+ $locale$: string | undefined;
299
+ $container$: Container | undefined;
300
+ }
301
+
302
+ declare interface ISsrNode {
303
+ id: string;
304
+ flags: SsrNodeFlags;
305
+ dirty: ChoreBits;
306
+ parentComponent: ISsrNode | null;
307
+ vnodeData: VNodeData;
308
+ currentFile: string | null;
309
+ setProp(name: string, value: any): void;
310
+ getProp(name: string): any;
311
+ removeProp(name: string): void;
312
+ addChild(child: ISsrNode): void;
313
+ setTreeNonUpdatable(): void;
314
+ }
315
+
82
316
  /** @public */
83
317
  declare interface MockDocument extends Document {
84
318
  }
@@ -98,39 +332,549 @@ declare interface MockWindow extends Window {
98
332
  document: MockDocument;
99
333
  }
100
334
 
335
+ declare interface NodePropData {
336
+ $scopedStyleIdPrefix$: string | null;
337
+ $isConst$: boolean;
338
+ }
339
+
340
+ /**
341
+ * Returned type of the `noSerialize()` function. It will be TYPE or undefined.
342
+ *
343
+ * @public
344
+ * @see noSerialize
345
+ */
346
+ declare type NoSerialize<T> = (T & {
347
+ __no_serialize__: true;
348
+ }) | undefined;
349
+
350
+ declare type ObjToProxyMap = WeakMap<any, any>;
351
+
352
+ declare type PossibleEvents = Event | SimplifiedServerRequestEvent | typeof TaskEvent | typeof RenderEvent | typeof ResourceEvent;
353
+
354
+ declare type Props = Record<string, unknown>;
355
+
356
+ /**
357
+ * The `QRL` type represents a lazy-loadable AND serializable resource.
358
+ *
359
+ * QRL stands for Qwik URL.
360
+ *
361
+ * Use `QRL` when you want to refer to a lazy-loaded resource. `QRL`s are most often used for code
362
+ * (functions) but can also be used for other resources such as `string`s in the case of styles.
363
+ *
364
+ * `QRL` is an opaque token that is generated by the Qwik Optimizer. (Do not rely on any properties
365
+ * in `QRL` as it may change between versions.)
366
+ *
367
+ * ## Creating `QRL` references
368
+ *
369
+ * Creating `QRL` is done using `$(...)` function. `$(...)` is a special marker for the Qwik
370
+ * Optimizer that marks that the code should be extracted into a lazy-loaded symbol.
371
+ *
372
+ * ```tsx
373
+ * useOnDocument(
374
+ * 'mousemove',
375
+ * $((event) => console.log('mousemove', event))
376
+ * );
377
+ * ```
378
+ *
379
+ * In the above code, the Qwik Optimizer detects `$(...)` and transforms the code as shown below:
380
+ *
381
+ * ```tsx
382
+ * // FILE: <current file>
383
+ * useOnDocument('mousemove', qrl('./chunk-abc.js', 'onMousemove'));
384
+ *
385
+ * // FILE: chunk-abc.js
386
+ * export const onMousemove = () => console.log('mousemove');
387
+ * ```
388
+ *
389
+ * NOTE: `qrl(...)` is a result of Qwik Optimizer transformation. You should never have to invoke
390
+ * this function directly in your application. The `qrl(...)` function should be invoked only after
391
+ * the Qwik Optimizer transformation.
392
+ *
393
+ * ## Using `QRL`s
394
+ *
395
+ * Use `QRL` type in your application when you want to get a lazy-loadable reference to a resource
396
+ * (most likely a function).
397
+ *
398
+ * ```tsx
399
+ * // Example of declaring a custom functions which takes callback as QRL.
400
+ * export function useMyFunction(callback: QRL<() => void>) {
401
+ * doExtraStuff();
402
+ * // The callback passed to `onDocument` requires `QRL`.
403
+ * useOnDocument('mousemove', callback);
404
+ * }
405
+ * ```
406
+ *
407
+ * In the above example, the way to think about the code is that you are not asking for a callback
408
+ * function but rather a reference to a lazy-loadable callback function. Specifically, the function
409
+ * loading should be delayed until it is actually needed. In the above example, the function would
410
+ * not load until after a `mousemove` event on `document` fires.
411
+ *
412
+ * ## Resolving `QRL` references
413
+ *
414
+ * At times it may be necessary to resolve a `QRL` reference to the actual value. This can be
415
+ * performed using `QRL.resolve(..)` function.
416
+ *
417
+ * ```tsx
418
+ * // Assume you have QRL reference to a greet function
419
+ * const lazyGreet: QRL<() => void> = $(() => console.log('Hello World!'));
420
+ *
421
+ * // Use `qrlImport` to load / resolve the reference.
422
+ * const greet: () => void = await lazyGreet.resolve();
423
+ *
424
+ * // Invoke it
425
+ * greet();
426
+ * ```
427
+ *
428
+ * NOTE: `element` is needed because `QRL`s are relative and need a base location to resolve
429
+ * against. The base location is encoded in the HTML in the form of `<div q:base="/url">`.
430
+ *
431
+ * ## `QRL.resolved`
432
+ *
433
+ * Once `QRL.resolve()` returns, the value is stored under `QRL.resolved`. This allows the value to
434
+ * be used without having to await `QRL.resolve()` again.
435
+ *
436
+ * ## Question: Why not just use `import()`?
437
+ *
438
+ * At first glance, `QRL` serves the same purpose as `import()`. However, there are three subtle
439
+ * differences that need to be taken into account.
440
+ *
441
+ * 1. `QRL`s must be serializable into HTML.
442
+ * 2. `QRL`s must be resolved by framework relative to `q:base`.
443
+ * 3. `QRL`s must be able to capture lexically scoped variables.
444
+ * 4. `QRL`s encapsulate the difference between running with and without Qwik Optimizer.
445
+ * 5. `QRL`s allow expressing lazy-loaded boundaries without thinking about chunk and symbol names.
446
+ *
447
+ * Let's assume that you intend to write code such as this:
448
+ *
449
+ * ```tsx
450
+ * return <button onClick={() => (await import('./chunk-abc.js')).onClick}>
451
+ * ```
452
+ *
453
+ * The above code needs to be serialized into DOM such as:
454
+ *
455
+ * ```
456
+ * <div q:base="/build/">
457
+ * <button q-e:click="./chunk-abc.js#onClick">...</button>
458
+ * </div>
459
+ * ```
460
+ *
461
+ * 1. Notice there is no easy way to extract chunk (`./chunk-abc.js`) and symbol (`onClick`) into HTML.
462
+ * 2. Notice that even if you could extract it, the `import('./chunk-abc.js')` would become relative to
463
+ * where the `import()` file is declared. Because it is our framework doing the load, the
464
+ * `./chunk-abc.js` would become relative to the framework file. This is not correct, as it
465
+ * should be relative to the original file generated by the bundler.
466
+ * 3. Next, the framework needs to resolve the `./chunk-abc.js` and needs a base location that is
467
+ * encoded in the HTML.
468
+ * 4. The QRL needs to be able to capture lexically scoped variables. (`import()` only allows loading
469
+ * top-level symbols which don't capture variables.)
470
+ * 5. As a developer, you don't want to think about `import` and naming the chunks and symbols. You
471
+ * just want to say: "this should be lazy."
472
+ *
473
+ * These are the main reasons why Qwik introduces its own concept of `QRL`.
474
+ *
475
+ * @public
476
+ * @see `$`
477
+ */
478
+ declare type QRL<TYPE = unknown> = {
479
+ __qwik_serializable__?: any;
480
+ __brand__QRL__?: TYPE;
481
+ /** Resolve the QRL and return the actual value. */
482
+ resolve(): Promise<TYPE>;
483
+ /** The resolved value, once `resolve()` returns. */
484
+ resolved: undefined | TYPE;
485
+ getCaptured(): unknown[] | null;
486
+ getSymbol(): string;
487
+ getHash(): string;
488
+ dev?: QRLDev | null;
489
+ } & BivariantQrlFn<QrlArgs<TYPE>, QrlReturn<TYPE>>;
490
+
491
+ declare type QrlArgs<T> = T extends (...args: infer ARGS) => any ? ARGS : unknown[];
492
+
493
+ /** @public */
494
+ declare interface QRLDev {
495
+ file: string;
496
+ lo: number;
497
+ hi: number;
498
+ }
499
+
500
+ /** @internal */
501
+ declare type QRLInternal<TYPE = unknown> = QRL<TYPE> & QRLInternalMethods<TYPE>;
502
+
503
+ declare type QRLInternalMethods<TYPE> = {
504
+ readonly $chunk$: string | null;
505
+ readonly $symbol$: string;
506
+ readonly $hash$: string;
507
+ /** If it's a string it's serialized */
508
+ $captures$: Readonly<unknown[]> | string | null;
509
+ dev: QRLDev | null;
510
+ resolve(container?: Container): Promise<TYPE>;
511
+ resolved: undefined | TYPE;
512
+ getSymbol(): string;
513
+ getHash(): string;
514
+ getCaptured(): unknown[] | null;
515
+ getFn(currentCtx?: InvokeContext, beforeFn?: () => void): TYPE extends (...args: any) => any ? (...args: Parameters<TYPE>) => ValueOrPromise<ReturnType<TYPE>> : unknown;
516
+ /**
517
+ * Needed for deserialization and importing. We don't always have the container while creating
518
+ * qrls in async sections of code
519
+ */
520
+ $container$: Container | null;
521
+ /** Only in dev mode */
522
+ $symbolRef$?: null | ValueOrPromise<TYPE>;
523
+ };
524
+
525
+ declare type QrlReturn<T> = T extends (...args: any) => infer R ? Awaited<R> : unknown;
526
+
527
+ /** @public */
528
+ declare interface ReadonlySignal<T = unknown> {
529
+ readonly value: T;
530
+ }
531
+
532
+ declare const RenderEvent = "qRender";
533
+
534
+ declare const ResourceEvent = "qResource";
535
+
536
+ declare interface ResourceReturnInternal<T> {
537
+ __brand: 'resource';
538
+ _state: 'pending' | 'resolved' | 'rejected';
539
+ _resolved: T | undefined;
540
+ _error: Error | undefined;
541
+ _cache: number;
542
+ _timeout: number;
543
+ _generation: number;
544
+ value: Promise<T>;
545
+ loading: boolean;
546
+ }
547
+
548
+ /** Stores the location of an object. If no parent, it's a root. */
549
+ declare type SeenRef = {
550
+ $index$: number;
551
+ $parent$?: SeenRef | null;
552
+ };
553
+
554
+ declare interface SerializationContext {
555
+ $serialize$: () => void;
556
+ $symbolToChunkResolver$: SymbolToChunkResolver;
557
+ /**
558
+ * Map from object to parent and index reference.
559
+ *
560
+ * If object is found in `objMap` will return the parent reference and index path.
561
+ *
562
+ * `objMap` return:
563
+ *
564
+ * - `{ parent, index }` - The parent object and the index within that parent.
565
+ * - `undefined` - Object has not been seen yet.
566
+ */
567
+ getSeenRef: (obj: unknown) => SeenRef | undefined;
568
+ /** Returns the root index of the object, if it is a root. Otherwise returns undefined. */
569
+ $hasRootId$: (obj: unknown) => number | undefined;
570
+ /**
571
+ * Root objects which need to be serialized.
572
+ *
573
+ * Roots are entry points into the object graph. Typically the roots are held by the listeners.
574
+ *
575
+ * Returns the index of the root object.
576
+ */
577
+ $addRoot$: AddRootFn;
578
+ /** Mark an object as seen during serialization. This is used to handle backreferences and cycles */
579
+ $markSeen$: (obj: unknown, parent: SeenRef | undefined, index: number) => SeenRef;
580
+ $roots$: unknown[];
581
+ $promoteToRoot$: (ref: SeenRef, index?: number) => void;
582
+ $addSyncFn$($funcStr$: string | null, argsCount: number, fn: Function): number;
583
+ $isSsrNode$: (obj: unknown) => obj is SsrNode;
584
+ $isDomRef$: (obj: unknown) => obj is DomRef;
585
+ $writer$: StreamWriter;
586
+ $syncFns$: string[];
587
+ $eventQrls$: Set<QRL>;
588
+ $eventNames$: Set<string>;
589
+ $resources$: Set<ResourceReturnInternal<unknown>>;
590
+ $renderSymbols$: Set<string>;
591
+ $storeProxyMap$: ObjToProxyMap;
592
+ $getProp$: (obj: any, prop: string) => any;
593
+ $setProp$: (obj: any, prop: string, value: any) => void;
594
+ }
595
+
596
+ declare const enum SerializationSignalFlags {
597
+ SERIALIZATION_STRATEGY_NEVER = 8,
598
+ SERIALIZATION_STRATEGY_ALWAYS = 16
599
+ }
600
+
601
+ /**
602
+ * A signal is a reactive value which can be read and written. When the signal is written, all tasks
603
+ * which are tracking the signal will be re-run and all components that read the signal will be
604
+ * re-rendered.
605
+ *
606
+ * Furthermore, when a signal value is passed as a prop to a component, the optimizer will
607
+ * automatically forward the signal. This means that `return <div title={signal.value}>hi</div>`
608
+ * will update the `title` attribute when the signal changes without having to re-render the
609
+ * component.
610
+ *
611
+ * @public
612
+ */
613
+ declare interface Signal<T = any> extends ReadonlySignal<T> {
614
+ value: T;
615
+ }
616
+
617
+ declare const enum SignalFlags {
618
+ INVALID = 1,
619
+ RUN_EFFECTS = 2
620
+ }
621
+
622
+ declare class SignalImpl<T = any> implements Signal<T> {
623
+ $untrackedValue$: T;
624
+ /** Store a list of effects which are dependent on this signal. */
625
+ $effects$: undefined | Set<EffectSubscription>;
626
+ $container$: Container | null;
627
+ $wrappedSignal$: WrappedSignalImpl<T> | null;
628
+ constructor(container: Container | null, value: T);
629
+ /**
630
+ * Use this to force running subscribers, for example when the calculated value has mutated but
631
+ * remained the same object
632
+ */
633
+ force(): void;
634
+ get untrackedValue(): T;
635
+ set untrackedValue(value: T);
636
+ get value(): T;
637
+ set value(value: T);
638
+ valueOf(): void;
639
+ toString(): string;
640
+ toJSON(): {
641
+ value: T;
642
+ };
643
+ }
644
+
645
+ declare type SimpleSsrAttrValue = string | Signal<SimpleSsrAttrValue> | boolean | object | null;
646
+
647
+ declare interface SimplifiedServerRequestEvent<T = unknown> {
648
+ url: URL;
649
+ locale: string | undefined;
650
+ request: Request;
651
+ }
652
+
653
+ declare type SsrAttrKey = string;
654
+
655
+ declare type SsrAttrs = Array<SsrAttrKey | SsrAttrValue>;
656
+
657
+ declare type SsrAttrValue = SimpleSsrAttrValue | Promise<SimpleSsrAttrValue>;
658
+
659
+ /** A selection of attributes of the real thing */
660
+ declare type SsrNode = {
661
+ id: string;
662
+ children: ISsrNode[] | null;
663
+ vnodeData: VNodeData;
664
+ [_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | null;
665
+ };
666
+
667
+ declare const enum SsrNodeFlags {
668
+ Updatable = 1
669
+ }
670
+
101
671
  /** @public */
102
672
  export declare function ssrRenderToDom(jsx: JSXOutput, opts?: {
673
+ /** Print debug information to console. */
103
674
  debug?: boolean;
675
+ /** Treat JSX as raw, (don't wrap in in head/body) */
104
676
  raw?: boolean;
677
+ /** Include QwikLoader */
678
+ qwikLoader?: boolean;
679
+ /** Inject nodes into the document before test runs (for testing purposes) */
680
+ onBeforeResume?: (document: Document) => void;
105
681
  }): Promise<{
106
682
  container: _DomContainer;
107
683
  document: Document;
108
- vNode: _VirtualVNode | null;
684
+ vNode: _VNode | null;
109
685
  getStyles: () => Record<string, string | string[]>;
110
686
  }>;
111
687
 
688
+ declare type StoreTarget = Record<string | symbol, any>;
689
+
690
+ /** @internal */
691
+ declare interface StreamWriter {
692
+ write(chunk: string): void;
693
+ }
694
+
695
+ /** @internal */
696
+ declare class SubscriptionData {
697
+ data: NodePropData;
698
+ constructor(data: NodePropData);
699
+ }
700
+
701
+ declare type SymbolToChunkResolver = (symbol: string) => string;
702
+
703
+ declare class Task<T = unknown, B = T> extends BackRef implements DescriptorBase<unknown, Signal<B> | ResourceReturnInternal<B>> {
704
+ $flags$: number;
705
+ $index$: number;
706
+ $el$: HostElement;
707
+ $qrl$: QRLInternal<T>;
708
+ $state$: Signal<B> | ResourceReturnInternal<B> | undefined;
709
+ $destroy$: NoSerialize<() => void> | null;
710
+ constructor($flags$: number, $index$: number, $el$: HostElement, $qrl$: QRLInternal<T>, $state$: Signal<B> | ResourceReturnInternal<B> | undefined, $destroy$: NoSerialize<() => void> | null);
711
+ }
712
+
713
+ declare const TaskEvent = "qTask";
714
+
112
715
  /** @public */
113
716
  declare interface TestPlatform extends CorePlatform {
717
+ /**
718
+ * @deprecated No longer used, please use {@link waitForDrain} instead.
719
+ * @example With `ssrRenderToDom`
720
+ *
721
+ * ```ts
722
+ * import { waitForDrain } from '@qwik.dev/testing';
723
+ *
724
+ * const { container } = ssrRenderToDom(...);
725
+ * await waitForDrain(container);
726
+ * ```
727
+ *
728
+ * @example With `domRender`
729
+ *
730
+ * ```ts
731
+ * import { waitForDrain } from '@qwik.dev/testing';
732
+ *
733
+ * const { container } = domRender(...);
734
+ * await waitForDrain(container);
735
+ * ```
736
+ */
114
737
  flush: () => Promise<void>;
115
738
  }
116
739
 
117
740
  /**
118
- * Trigger an event in unit tests on an element.
741
+ * Trigger an event in unit tests on an element. Needs to be kept in sync with the Qwik Loader event
742
+ * dispatching.
743
+ *
744
+ * Events can be either case sensitive element-scoped events or scoped kebab-case.
119
745
  *
120
746
  * Future deprecation candidate.
121
747
  *
122
748
  * @public
123
749
  */
124
- export declare function trigger(root: Element, queryOrElement: string | Element | keyof HTMLElementTagNameMap | null, eventName: string, eventPayload?: any): Promise<void>;
750
+ export declare function trigger(root: Element, queryOrElement: string | Element | keyof HTMLElementTagNameMap | null, eventName: string, eventPayload?: any, options?: {
751
+ waitForIdle?: boolean;
752
+ }): Promise<void>;
753
+
754
+ /**
755
+ * Type representing a value which is either resolve or a promise.
756
+ *
757
+ * @public
758
+ */
759
+ declare type ValueOrPromise<T> = T | Promise<T>;
760
+
761
+ /** @internal */
762
+ declare abstract class VNode implements BackRef {
763
+ flags: VNodeFlags;
764
+ parent: VNode | null;
765
+ previousSibling: VNode | null | undefined;
766
+ nextSibling: VNode | null | undefined;
767
+ props: Props | null;
768
+ [_EFFECT_BACK_REF]: Map<any, any> | undefined;
769
+ slotParent: VNode | null;
770
+ dirty: ChoreBits;
771
+ dirtyChildren: VNode[] | null;
772
+ nextDirtyChildIndex: number;
773
+ constructor(flags: VNodeFlags, parent: VNode | null, previousSibling: VNode | null | undefined, nextSibling: VNode | null | undefined, props: Props | null);
774
+ toString(): string;
775
+ }
125
776
 
126
777
  /** @public */
127
778
  export declare function vnode_fromJSX(jsx: JSXOutput): {
128
- vParent: _ElementVNode;
779
+ vParent: _VirtualVNode | _ElementVNode;
129
780
  vNode: _VNode | null;
130
781
  document: _QDocument;
131
- container: ClientContainer;
782
+ container: ClientContainer_2;
132
783
  };
133
784
 
785
+ /**
786
+ * Array of numbers which describes virtual nodes in the tree.
787
+ *
788
+ * HTML can't account for:
789
+ *
790
+ * - Multiple text nodes in a row. (it treats it as a single text node)
791
+ * - Empty text nodes. (it ignores them)
792
+ * - And virtual nodes such as `<Fragment/>` or `<MyComponent/>`
793
+ *
794
+ * So we need to encode all of that information into the VNodeData.
795
+ *
796
+ * Encoding:
797
+ *
798
+ * - First position is special and encodes state information and stores VNodeDataFlag.
799
+ * - Positive numbers are text node lengths. (0 is a special case for empty text node)
800
+ * - Negative numbers are element counts.
801
+ * - `OPEN_FRAGMENT` is start of virtual node.
802
+ *
803
+ * - If `OPEN_FRAGMENT` than the previous node is an `Array` which contains the props (see
804
+ * `SsrAttrs`). NOTE: The array is never going to be the last item in the VNodeData, so we can
805
+ * always assume that the last item in `vNodeData` is a number.
806
+ * - `CLOSE_FRAGMENT` is end of virtual node.
807
+ *
808
+ * NOTE: This is how we store the information during the SSR streaming, once the SSR is complete
809
+ * this data needs to be serialized into a string and stored in the DOM as a script tag which has
810
+ * deferent serialization format.
811
+ */
812
+ declare type VNodeData = [VNodeDataFlag, ...(SsrAttrs | number)[]];
813
+
814
+ /**
815
+ * Flags for VNodeData (Flags con be bitwise combined)
816
+ *
817
+ * @internal
818
+ */
819
+ declare const enum VNodeDataFlag {
820
+ NONE = 0,
821
+ TEXT_DATA = 1,
822
+ VIRTUAL_NODE = 2,
823
+ ELEMENT_NODE = 4,
824
+ REFERENCE = 8,
825
+ SERIALIZE = 16
826
+ }
827
+
828
+ /**
829
+ * Flags for VNode.
830
+ *
831
+ * # Materialize vs Inflation
832
+ *
833
+ * - Materialized: The node has all of its children. Specifically `firstChild`/`lastChild` are NOT
834
+ * `undefined`. Materialization creates lazy instantiation of the children. NOTE: Only
835
+ * ElementVNode need to be materialized.
836
+ * - Inflation:
837
+ *
838
+ * - If Text: It means that it is safe to write to the node. When Text nodes are first Deserialized
839
+ * multiple text nodes can share the same DOM node. On write the sibling text nodes need to be
840
+ * converted into separate text nodes.
841
+ * - If Element: It means that the element tag attributes have not yet been read from the DOM.
842
+ *
843
+ * Inflation and materialization are not the same, they are two independent things.
844
+ *
845
+ * @internal
846
+ */
847
+ declare const enum VNodeFlags {
848
+ Element = 1,
849
+ Virtual = 2,
850
+ ELEMENT_OR_VIRTUAL_MASK = 3,
851
+ Text = 4,
852
+ ELEMENT_OR_TEXT_MASK = 5,
853
+ TYPE_MASK = 7,
854
+ INFLATED_TYPE_MASK = 15,
855
+ Inflated = 8,
856
+ Resolved = 16,
857
+ Deleted = 32,
858
+ HasIterationItems = 64,
859
+ InflatedIterationItems = 128,
860
+ Cursor = 256,
861
+ NAMESPACE_MASK = 1536,
862
+ NEGATED_NAMESPACE_MASK = -1537,
863
+ NS_html = 0,// http://www.w3.org/1999/xhtml
864
+ NS_svg = 512,// http://www.w3.org/2000/svg
865
+ NS_math = 1024
866
+ }
867
+
868
+ /**
869
+ * Wait for the scheduler to drain.
870
+ *
871
+ * This is useful when testing async code.
872
+ *
873
+ * @param container - The application container.
874
+ * @public
875
+ */
876
+ export declare function waitForDrain(container: Container): Promise<void>;
877
+
134
878
  /** @public */
135
879
  export declare function walkJSX(jsx: JSXOutput, apply: {
136
880
  enter: (jsx: JSXNodeInternal) => void;
@@ -138,4 +882,29 @@ export declare function walkJSX(jsx: JSXOutput, apply: {
138
882
  text: (text: _Stringifiable) => void;
139
883
  }): void;
140
884
 
885
+ declare const enum WrappedSignalFlags {
886
+ UNWRAP = 4
887
+ }
888
+
889
+ declare class WrappedSignalImpl<T> extends SignalImpl<T> implements BackRef {
890
+ $args$: any[];
891
+ $func$: (...args: any[]) => T;
892
+ $funcStr$: string | null;
893
+ $flags$: AllSignalFlags;
894
+ $hostElement$: HostElement | undefined;
895
+ [_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | undefined;
896
+ constructor(container: Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null, flags?: SignalFlags);
897
+ invalidate(): void;
898
+ /**
899
+ * Use this to force running subscribers, for example when the calculated value has mutated but
900
+ * remained the same object.
901
+ */
902
+ force(): void;
903
+ get untrackedValue(): T;
904
+ $computeIfNeeded$(): void;
905
+ $unwrapIfSignal$(): SignalImpl<T> | WrappedSignalImpl<T>;
906
+ set value(_: any);
907
+ get value(): any;
908
+ }
909
+
141
910
  export { }