@qwik.dev/core 2.0.0-beta.42 → 2.0.0-beta.45

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.
@@ -0,0 +1,3 @@
1
+ import type { AsyncLocalStorage } from 'node:async_hooks';
2
+ /** @internal */
3
+ export declare const getAsyncLocalStorage: () => (new <T>() => AsyncLocalStorage<T>) | undefined;
@@ -0,0 +1,8 @@
1
+ // packages/qwik/src/core/shared/platform/async-local-storage.ts
2
+ var getAsyncLocalStorage = () => {
3
+ const process = globalThis.process;
4
+ return process?.getBuiltinModule?.("node:async_hooks")?.AsyncLocalStorage;
5
+ };
6
+ export {
7
+ getAsyncLocalStorage
8
+ };
@@ -0,0 +1,6 @@
1
+ // packages/qwik/src/core/shared/platform/async-local-storage.node.ts
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+ var getAsyncLocalStorage = () => AsyncLocalStorage;
4
+ export {
5
+ getAsyncLocalStorage
6
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwik.dev/core/backpatch",
3
- "version": "2.0.0-beta.42-dev+3473a49",
3
+ "version": "2.0.0-beta.45-dev+596de70",
4
4
  "main": "index.mjs",
5
5
  "types": "index.d.ts",
6
6
  "private": true,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwik.dev/core/build",
3
- "version": "2.0.0-beta.42-dev+3473a49",
3
+ "version": "2.0.0-beta.45-dev+596de70",
4
4
  "main": "index.mjs",
5
5
  "types": "index.d.ts",
6
6
  "private": true,
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/cli 2.0.0-beta.42-dev+3473a49
3
+ * @qwik.dev/core/cli 2.0.0-beta.45-dev+596de70
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
@@ -4244,7 +4244,7 @@ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
4244
4244
  var figures_default = figures;
4245
4245
  var replacements = Object.entries(specialMainSymbols);
4246
4246
 
4247
- // node_modules/.pnpm/yoctocolors@2.1.2/node_modules/yoctocolors/base.js
4247
+ // node_modules/.pnpm/yoctocolors@2.2.0/node_modules/yoctocolors/base.js
4248
4248
  import tty from "node:tty";
4249
4249
  var hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false;
4250
4250
  var format = (open, close) => {
@@ -4277,6 +4277,10 @@ var bold2 = format(1, 22);
4277
4277
  var dim2 = format(2, 22);
4278
4278
  var italic2 = format(3, 23);
4279
4279
  var underline2 = format(4, 24);
4280
+ var underlineDouble = format("4:2", 24);
4281
+ var underlineCurly = format("4:3", 24);
4282
+ var underlineDotted = format("4:4", 24);
4283
+ var underlineDashed = format("4:5", 24);
4280
4284
  var overline = format(53, 55);
4281
4285
  var inverse2 = format(7, 27);
4282
4286
  var hidden2 = format(8, 28);
@@ -4313,6 +4317,22 @@ var bgBlueBright = format(104, 49);
4313
4317
  var bgMagentaBright = format(105, 49);
4314
4318
  var bgCyanBright = format(106, 49);
4315
4319
  var bgWhiteBright = format(107, 49);
4320
+ var underlineBlack = format("58;5;0", 59);
4321
+ var underlineRed = format("58;5;1", 59);
4322
+ var underlineGreen = format("58;5;2", 59);
4323
+ var underlineYellow = format("58;5;3", 59);
4324
+ var underlineBlue = format("58;5;4", 59);
4325
+ var underlineMagenta = format("58;5;5", 59);
4326
+ var underlineCyan = format("58;5;6", 59);
4327
+ var underlineWhite = format("58;5;7", 59);
4328
+ var underlineGray = format("58;5;8", 59);
4329
+ var underlineRedBright = format("58;5;9", 59);
4330
+ var underlineGreenBright = format("58;5;10", 59);
4331
+ var underlineYellowBright = format("58;5;11", 59);
4332
+ var underlineBlueBright = format("58;5;12", 59);
4333
+ var underlineMagentaBright = format("58;5;13", 59);
4334
+ var underlineCyanBright = format("58;5;14", 59);
4335
+ var underlineWhiteBright = format("58;5;15", 59);
4316
4336
 
4317
4337
  // node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/verbose/default.js
4318
4338
  var defaultVerboseFunction = ({
@@ -6698,7 +6718,7 @@ function parseMilliseconds(milliseconds) {
6698
6718
  throw new TypeError("Expected a finite number or bigint");
6699
6719
  }
6700
6720
 
6701
- // node_modules/.pnpm/pretty-ms@9.3.0/node_modules/pretty-ms/index.js
6721
+ // node_modules/.pnpm/pretty-ms@9.3.1/node_modules/pretty-ms/index.js
6702
6722
  var isZero = (value) => value === 0 || value === 0n;
6703
6723
  var pluralize = (word, count2) => count2 === 1 || count2 === 1n ? word : `${word}s`;
6704
6724
  var SECOND_ROUNDING_EPSILON = 1e-7;
@@ -6771,7 +6791,8 @@ function prettyMilliseconds(milliseconds, options) {
6771
6791
  const millisecondsAndBelow = milliseconds2 + microseconds / 1e3 + nanoseconds / 1e6;
6772
6792
  const millisecondsDecimalDigits = typeof options.millisecondsDecimalDigits === "number" ? options.millisecondsDecimalDigits : 0;
6773
6793
  const roundedMilliseconds = millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
6774
- const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : roundedMilliseconds;
6794
+ const maximumMilliseconds = 1e3 - 10 ** -millisecondsDecimalDigits;
6795
+ const millisecondsString = millisecondsDecimalDigits ? Math.min(millisecondsAndBelow, maximumMilliseconds).toFixed(millisecondsDecimalDigits) : Math.min(roundedMilliseconds, maximumMilliseconds);
6775
6796
  add(
6776
6797
  Number.parseFloat(millisecondsString),
6777
6798
  "millisecond",
@@ -12966,7 +12987,7 @@ async function printHelp(app) {
12966
12987
  await runCommand2(Object.assign(app, { task: args[0], args }));
12967
12988
  }
12968
12989
  function printVersion() {
12969
- console.log("2.0.0-beta.42-dev+3473a49");
12990
+ console.log("2.0.0-beta.45-dev+596de70");
12970
12991
  }
12971
12992
  export {
12972
12993
  runCli,
@@ -1,5 +1,5 @@
1
- import type { AsyncLocalStorage } from 'node:async_hooks';
2
1
  import type * as CSS_2 from 'csstype';
2
+ import { getAsyncLocalStorage as _getAsyncLocalStorage } from './async-local-storage';
3
3
  import { isBrowser } from './build';
4
4
  import { isDev } from './build';
5
5
  import { isServer } from './build';
@@ -381,12 +381,6 @@ declare type AsyncQRL<T> = ComputeQRL<T>;
381
381
  * changed, all tasks which are tracking the AsyncSignal will be re-run and all subscribers
382
382
  * (components, tasks etc) that read the AsyncSignal will be updated.
383
383
  *
384
- * If the async function throws an error, the AsyncSignal will capture the error and set the `error`
385
- * property. The error can be cleared by re-running the async function successfully.
386
- *
387
- * While the async function is running, the `.loading` property will be set to `true`. Once the
388
- * function completes, `loading` will be set to `false`.
389
- *
390
384
  * If the value has not yet been resolved, reading the AsyncSignal will throw a Promise, which will
391
385
  * retry the component or task once the value resolves.
392
386
  *
@@ -394,8 +388,7 @@ declare type AsyncQRL<T> = ComputeQRL<T>;
394
388
  * will subscribe to it and return the last resolved value until the new value is ready. As soon as
395
389
  * the new value is ready, the subscribers will be updated.
396
390
  *
397
- * If the async function threw an error, reading the `.value` will throw that same error. Read from
398
- * `.error` to check if there was an error.
391
+ * If the async function threw an error, reading the `.value` will throw that same error.
399
392
  *
400
393
  * @deprecated Use `ComputedSignal` instead, it has async support now.
401
394
  * @public
@@ -700,40 +693,6 @@ export declare interface ComputedSignal<T> extends Signal<T> {
700
693
  * throw the computation promise) instead of the stale value while the new value computes.
701
694
  */
702
695
  clear(): void;
703
- /**
704
- * Whether the signal is currently loading. This will trigger lazy computation of the signal, so
705
- * you can use it like this:
706
- *
707
- * ```tsx
708
- * signal.pending ? <Loading /> : signal.error ? <Error /> : <Component
709
- * value={signal.value} />
710
- * ```
711
- */
712
- pending: boolean;
713
- /**
714
- * Lets you read the pending state without subscribing to `.pending` updates. It also triggers
715
- * lazy computation of the signal.
716
- *
717
- * Setting it will trigger listeners for `.pending`.
718
- */
719
- untrackedPending: boolean;
720
- /** @deprecated Use `pending` instead */
721
- loading: boolean;
722
- /** @deprecated Use `untrackedPending` instead */
723
- untrackedLoading: boolean;
724
- /**
725
- * The error that occurred while computing the signal, if any, including synchronous throws. This
726
- * will be cleared when the signal is successfully computed. It also triggers lazy computation of
727
- * the signal. While the error is set, reading `.value` throws it.
728
- */
729
- error: Error | undefined;
730
- /**
731
- * Lets you read the error state without subscribing to `.error` updates. It also triggers lazy
732
- * computation of the signal.
733
- *
734
- * Setting it will trigger listeners for `.error`.
735
- */
736
- untrackedError: Error | undefined;
737
696
  /** A promise that resolves when the value is computed or rejected. */
738
697
  promise(): Promise<void>;
739
698
  /** Abort the current computation and run cleanups if needed. */
@@ -778,6 +737,7 @@ declare class ComputedSignalImpl<T, S extends _QRLInternal = ComputeQRL<T>> exte
778
737
  $timeoutMs$: number | undefined;
779
738
  $loadingEffects$: undefined | Set<EffectSubscription>;
780
739
  $errorEffects$: undefined | Set<EffectSubscription>;
740
+ $disposed$: boolean | undefined;
781
741
  $computationTimeoutId$: ReturnType<typeof setTimeout> | undefined;
782
742
  $info$: unknown | undefined;
783
743
  $infoVersion$: number | undefined;
@@ -855,7 +815,9 @@ declare class ComputedSignalImpl<T, S extends _QRLInternal = ComputeQRL<T>> exte
855
815
  * AbortErrors.
856
816
  */
857
817
  $setError$(job: Job<T>, error: Error): void;
858
- /** Called after SSR/unmount */
818
+ /** Permanently stop computations; keep this cross-package name stable. */
819
+ $dispose(): void;
820
+ /** Clean computations after SSR while preserving dependencies for serialization. */
859
821
  $destroy$(): Promise<void>;
860
822
  private $hasSubscribers$;
861
823
  $requestCleanups$(job: Job<T>, reason?: any): void;
@@ -865,6 +827,48 @@ declare class ComputedSignalImpl<T, S extends _QRLInternal = ComputeQRL<T>> exte
865
827
  $runCleanups$(job: Job<T>): Promise<void> | undefined;
866
828
  }
867
829
 
830
+ /**
831
+ * A computed signal with its pending and error state exposed.
832
+ *
833
+ * @internal
834
+ */
835
+ export declare interface _ComputedSignalInternal<T> extends ComputedSignal<T> {
836
+ /**
837
+ * Whether the signal is currently loading. This will trigger lazy computation of the signal, so
838
+ * you can use it like this:
839
+ *
840
+ * ```tsx
841
+ * signal.pending ? <Loading /> : signal.error ? <Error /> : <Component
842
+ * value={signal.value} />
843
+ * ```
844
+ */
845
+ pending: boolean;
846
+ /**
847
+ * Lets you read the pending state without subscribing to `.pending` updates. It also triggers
848
+ * lazy computation of the signal.
849
+ *
850
+ * Setting it will trigger listeners for `.pending`.
851
+ */
852
+ untrackedPending: boolean;
853
+ /** @deprecated Use `pending` instead */
854
+ loading: boolean;
855
+ /** @deprecated Use `untrackedPending` instead */
856
+ untrackedLoading: boolean;
857
+ /**
858
+ * The error that occurred while computing the signal, if any, including synchronous throws. This
859
+ * will be cleared when the signal is successfully computed. It also triggers lazy computation of
860
+ * the signal. While the error is set, reading `.value` throws it.
861
+ */
862
+ error: Error | undefined;
863
+ /**
864
+ * Lets you read the error state without subscribing to `.error` updates. It also triggers lazy
865
+ * computation of the signal.
866
+ *
867
+ * Setting it will trigger listeners for `.error`.
868
+ */
869
+ untrackedError: Error | undefined;
870
+ }
871
+
868
872
  declare type ComputeQRL<T> = _QRLInternal<ComputedFn<T>>;
869
873
 
870
874
  /** @internal */
@@ -1089,9 +1093,9 @@ export declare const createAsyncQrl: <T>(qrl: QRL<ComputedFn<T>>, options?: Asyn
1089
1093
  *
1090
1094
  * The QRL must be a function which returns the value of the signal. The function must not have side
1091
1095
  * effects. Every synchronous signal or store read is tracked automatically; reads after the first
1092
- * `await` must use the `track()` provided on the context argument. When the function is async, the
1093
- * returned signal exposes the async API (`.pending`, `.error`, `.promise()`), and reading an
1094
- * unresolved `.value` throws the computation promise.
1096
+ * `await` must use the `track()` provided on the context argument. When the function is async,
1097
+ * reading an unresolved `.value` throws the computation promise, and reading a failed `.value`
1098
+ * throws the error.
1095
1099
  *
1096
1100
  * @public
1097
1101
  */
@@ -1528,8 +1532,7 @@ export declare type FunctionComponent<P = unknown> = {
1528
1532
  renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput;
1529
1533
  }['renderFn'];
1530
1534
 
1531
- /** @internal */
1532
- export declare const _getAsyncLocalStorage: () => (new <T>() => AsyncLocalStorage<T>) | undefined;
1535
+ export { _getAsyncLocalStorage }
1533
1536
 
1534
1537
  /**
1535
1538
  * Returns the client build manifest, which includes the mappings from symbols to bundles, the
@@ -1905,7 +1908,7 @@ declare class Job<T> implements ComputeCtx<T> {
1905
1908
  /** Backward compatible cache method for resource */
1906
1909
  cache(): void;
1907
1910
  get previous(): T | undefined;
1908
- cleanup(callback: () => void): void;
1911
+ cleanup: (callback: () => void) => void;
1909
1912
  }
1910
1913
 
1911
1914
  /**
@@ -2348,7 +2351,7 @@ declare type Passive = {
2348
2351
 
2349
2352
  declare type PopoverTargetAction = 'hide' | 'show' | 'toggle';
2350
2353
 
2351
- declare type PossibleEvents = Event | SimplifiedServerRequestEvent | typeof TaskEvent | typeof RenderEvent;
2354
+ declare type PossibleEvents = Event | typeof TaskEvent | typeof RenderEvent;
2352
2355
 
2353
2356
  /**
2354
2357
  * @deprecated This is no longer needed as the preloading happens automatically in qrl-class. You
@@ -3068,21 +3071,13 @@ export declare const _resolveContextWithoutSequentialScope: <STATE>(context: Con
3068
3071
  * return (
3069
3072
  * <div>
3070
3073
  * <input name="city" bind:value={city} />
3071
- * <div>
3072
- * Temperature:{' '}
3073
- * {weather.pending
3074
- * ? 'Loading...'
3075
- * : weather.error
3076
- * ? `Error: ${weather.error.message}`
3077
- * : weather.value.temp}
3078
- * </div>
3074
+ * <div>Temperature: {weather.value.temp}</div>
3079
3075
  * </div>
3080
3076
  * );
3081
3077
  * });
3082
3078
  * ```
3083
3079
  *
3084
- * @deprecated Use `useComputed$` instead. Read the `pending` and `error` properties from the
3085
- * returned signal to determine the status.
3080
+ * @deprecated Use `useComputed$` instead.
3086
3081
  * @public
3087
3082
  */
3088
3083
  export declare const Resource: <T>({ value, onResolved, onPending, onRejected, }: ResourceProps<T>) => JSXOutput;
@@ -3137,7 +3132,7 @@ declare interface ResourceReturnInternal<T> {
3137
3132
  __brand: 'resource';
3138
3133
  value: Promise<T>;
3139
3134
  loading: boolean;
3140
- signal: AsyncSignal<{
3135
+ signal: _ComputedSignalInternal<{
3141
3136
  r: T;
3142
3137
  }>;
3143
3138
  }
@@ -3524,12 +3519,6 @@ declare class SignalImpl<T = any> implements Signal<T> {
3524
3519
  };
3525
3520
  }
3526
3521
 
3527
- declare interface SimplifiedServerRequestEvent<T = unknown> {
3528
- url: URL;
3529
- locale: string | undefined;
3530
- request: Request;
3531
- }
3532
-
3533
3522
  /** @public */
3534
3523
  declare type Size = number | string;
3535
3524
 
@@ -4346,7 +4335,8 @@ declare const enum TaskFlags {
4346
4335
  DIRTY = 4,
4347
4336
  RENDER_BLOCKING = 8,
4348
4337
  NEEDS_CLEANUP = 16,
4349
- EVENTS_REGISTERED = 32
4338
+ EVENTS_REGISTERED = 32,
4339
+ EXECUTED = 64
4350
4340
  }
4351
4341
 
4352
4342
  /** @public */
@@ -4494,9 +4484,8 @@ export declare function _updateProjectionProps(container: _Container, vnode: _Vi
4494
4484
  *
4495
4485
  * Every synchronous signal or store read is tracked automatically. Reads after an `await` are not:
4496
4486
  * the tracking context is lost, so track them explicitly with the `track()` provided on the context
4497
- * argument. When the function is async, the returned signal exposes the async API: reading an
4498
- * unresolved `.value` throws the computation promise, and `.pending` and `.error` expose the
4499
- * computation state.
4487
+ * argument. When the function is async, reading an unresolved `.value` throws the computation
4488
+ * promise, and reading a failed `.value` throws the error.
4500
4489
  *
4501
4490
  * The function must not have any side effects.
4502
4491
  *
@@ -5141,7 +5130,7 @@ export declare const _VAR_PROPS: unique symbol;
5141
5130
  export declare const _verifySerializable: <T>(value: T, preMessage?: string) => T;
5142
5131
 
5143
5132
  /**
5144
- * 2.0.0-beta.42-dev+3473a49
5133
+ * 2.0.0-beta.45-dev+596de70
5145
5134
  *
5146
5135
  * @public
5147
5136
  */
@@ -5318,6 +5307,9 @@ export declare function _walkJSX(ssr: SSRContainer, value: JSXOutput, options: S
5318
5307
  /**
5319
5308
  * Override the `getLocale` with `lang` within the `fn` execution.
5320
5309
  *
5310
+ * `fn` may be async. The locale stays set until the returned promise settles, even when
5311
+ * AsyncLocalStorage is not available.
5312
+ *
5321
5313
  * @public
5322
5314
  */
5323
5315
  export declare function withLocale<T>(locale: string, fn: () => T): T;