@qwik.dev/core 2.0.0-alpha.8 → 2.0.0-alpha.9
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.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/core-internal.d.ts +234 -22
- package/dist/core.cjs +7305 -7418
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +7299 -7418
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +1546 -1662
- package/dist/core.prod.mjs +2713 -2852
- package/dist/insights/index.qwik.cjs +1815 -1933
- package/dist/insights/index.qwik.mjs +1815 -1933
- package/dist/insights/insights.d.ts +1 -1
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +47 -17
- package/dist/optimizer.d.ts +1 -1
- package/dist/optimizer.mjs +45 -17
- package/dist/prefetch/package.json +1 -1
- package/dist/server.cjs +12 -11
- package/dist/server.mjs +12 -11
- package/dist/starters/features/auth/package.json +1 -1
- package/dist/starters/features/tailwind/package.json +2 -2
- package/dist/starters/features/tailwind-v3/.vscode/settings.json +3 -0
- package/dist/starters/features/tailwind-v3/package.json +21 -0
- package/dist/starters/features/tailwind-v3/postcss.config.cjs +6 -0
- package/dist/starters/features/tailwind-v3/src/global.css +7 -0
- package/dist/starters/features/tailwind-v3/tailwind.config.js +8 -0
- package/dist/testing/index.cjs +5461 -5373
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.mjs +5475 -5389
- package/dist/testing/package.json +1 -1
- package/package.json +3 -3
- package/public.d.ts +6 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/build/package.json
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/cli 2.0.0-alpha.
|
|
3
|
+
* @qwik.dev/core/cli 2.0.0-alpha.9-dev+56ed5bd
|
|
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-alpha.
|
|
5539
|
+
console.log("2.0.0-alpha.9-dev+56ed5bd");
|
|
5540
5540
|
}
|
|
5541
5541
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5542
5542
|
0 && (module.exports = {
|
package/dist/core-internal.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import * as CSS_2 from 'csstype';
|
|
|
2
2
|
import { isBrowser } from './build';
|
|
3
3
|
import { isDev } from './build';
|
|
4
4
|
import { isServer } from './build';
|
|
5
|
+
import { QRL as QRL_2 } from './qrl.public';
|
|
6
|
+
import { ReadonlySignal as ReadonlySignal_2 } from '..';
|
|
5
7
|
import type { StreamWriter as StreamWriter_2 } from '.';
|
|
8
|
+
import { ValueOrPromise as ValueOrPromise_2 } from '..';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Qwik Optimizer marker function.
|
|
@@ -87,6 +90,7 @@ declare type AllEventMapRaw = HTMLElementEventMap & DocumentEventMap & WindowEve
|
|
|
87
90
|
qinit: QwikInitEvent;
|
|
88
91
|
qsymbol: QwikSymbolEvent;
|
|
89
92
|
qvisible: QwikVisibleEvent;
|
|
93
|
+
qviewTransition: QwikViewTransitionEvent;
|
|
90
94
|
};
|
|
91
95
|
|
|
92
96
|
declare type AllEventsMap = Omit<AllEventMapRaw, keyof EventCorrectionMap> & EventCorrectionMap;
|
|
@@ -413,7 +417,6 @@ export declare interface ClientContainer extends Container {
|
|
|
413
417
|
document: _QDocument;
|
|
414
418
|
element: _ContainerElement;
|
|
415
419
|
qContainer: string;
|
|
416
|
-
qBase: string;
|
|
417
420
|
$locale$: string;
|
|
418
421
|
qManifestHash: string;
|
|
419
422
|
rootVNode: _ElementVNode;
|
|
@@ -528,6 +531,37 @@ export declare interface ComputedSignal<T> extends ReadonlySignal<T> {
|
|
|
528
531
|
force(): void;
|
|
529
532
|
}
|
|
530
533
|
|
|
534
|
+
/**
|
|
535
|
+
* A signal which is computed from other signals.
|
|
536
|
+
*
|
|
537
|
+
* The value is available synchronously, but the computation is done lazily.
|
|
538
|
+
*/
|
|
539
|
+
declare class ComputedSignalImpl<T> extends SignalImpl<T> implements BackRef {
|
|
540
|
+
/**
|
|
541
|
+
* The compute function is stored here.
|
|
542
|
+
*
|
|
543
|
+
* The computed functions must be executed synchronously (because of this we need to eagerly
|
|
544
|
+
* resolve the QRL during the mark dirty phase so that any call to it will be synchronous). )
|
|
545
|
+
*/
|
|
546
|
+
$computeQrl$: ComputeQRL<T>;
|
|
547
|
+
$flags$: SignalFlags;
|
|
548
|
+
$forceRunEffects$: boolean;
|
|
549
|
+
[_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | null;
|
|
550
|
+
constructor(container: Container | null, fn: ComputeQRL<T>, flags?: SignalFlags);
|
|
551
|
+
$invalidate$(): void;
|
|
552
|
+
/**
|
|
553
|
+
* Use this to force running subscribers, for example when the calculated value has mutated but
|
|
554
|
+
* remained the same object
|
|
555
|
+
*/
|
|
556
|
+
force(): void;
|
|
557
|
+
get untrackedValue(): T;
|
|
558
|
+
$computeIfNeeded$(): boolean;
|
|
559
|
+
set value(_: any);
|
|
560
|
+
get value(): any;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
declare type ComputeQRL<T> = QRLInternal<() => T>;
|
|
564
|
+
|
|
531
565
|
/** @internal */
|
|
532
566
|
export declare const _CONST_PROPS: unique symbol;
|
|
533
567
|
|
|
@@ -540,7 +574,7 @@ export declare const _CONST_PROPS: unique symbol;
|
|
|
540
574
|
* - `VNode` and `ISsrNode`: Either a component or `<Signal>`
|
|
541
575
|
* - `Signal2`: A derived signal which contains a computation function.
|
|
542
576
|
*/
|
|
543
|
-
declare type Consumer = Task | _VNode | ISsrNode |
|
|
577
|
+
declare type Consumer = Task | _VNode | ISsrNode | SignalImpl;
|
|
544
578
|
|
|
545
579
|
declare interface Container {
|
|
546
580
|
readonly $version$: string;
|
|
@@ -550,6 +584,7 @@ declare interface Container {
|
|
|
550
584
|
readonly $getObjectById$: (id: number | string) => any;
|
|
551
585
|
readonly $serverData$: Record<string, any>;
|
|
552
586
|
$currentUniqueId$: number;
|
|
587
|
+
$buildBase$: string | null;
|
|
553
588
|
handleError(err: any, $host$: HostElement): void;
|
|
554
589
|
getParentHost(host: HostElement): HostElement | null;
|
|
555
590
|
setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
|
|
@@ -735,7 +770,7 @@ export declare interface CorrectedToggleEvent extends Event {
|
|
|
735
770
|
* recalculated.
|
|
736
771
|
*
|
|
737
772
|
* The QRL must be a function which returns the value of the signal. The function must not have side
|
|
738
|
-
* effects, and it
|
|
773
|
+
* effects, and it must be synchronous.
|
|
739
774
|
*
|
|
740
775
|
* If you need the function to be async, use `useSignal` and `useTask$` instead.
|
|
741
776
|
*
|
|
@@ -744,7 +779,7 @@ export declare interface CorrectedToggleEvent extends Event {
|
|
|
744
779
|
export declare const createComputed$: <T>(qrl: () => T) => T extends Promise<any> ? never : ComputedSignal<T>;
|
|
745
780
|
|
|
746
781
|
/** @internal */
|
|
747
|
-
export declare const createComputedQrl: <T>(qrl: QRL<() => T>) =>
|
|
782
|
+
export declare const createComputedQrl: <T>(qrl: QRL<() => T>) => ComputedSignalImpl<T>;
|
|
748
783
|
|
|
749
784
|
/**
|
|
750
785
|
* Create a context ID to be used in your application. The name should be written with no spaces.
|
|
@@ -811,6 +846,21 @@ declare const createScheduler: (container: Container, scheduleDrain: () => void,
|
|
|
811
846
|
(type: ChoreType.CLEANUP_VISIBLE, task: Task): ValueOrPromise<JSXOutput>;
|
|
812
847
|
};
|
|
813
848
|
|
|
849
|
+
/**
|
|
850
|
+
* Create a signal that holds a custom serializable value. See {@link useSerializer$} for more
|
|
851
|
+
* details.
|
|
852
|
+
*
|
|
853
|
+
* @public
|
|
854
|
+
*/
|
|
855
|
+
export declare const createSerializer$: <T, S>(arg: SerializerArg<T, S>) => T extends Promise<any> ? never : SerializerSignal<T>;
|
|
856
|
+
|
|
857
|
+
/** @internal */
|
|
858
|
+
export declare const createSerializerQrl: <T, S>(arg: QRL<{
|
|
859
|
+
serialize: (data: S | undefined) => T;
|
|
860
|
+
deserialize: (data: T) => S;
|
|
861
|
+
initial?: S;
|
|
862
|
+
}>) => SerializerSignalImpl<T, S>;
|
|
863
|
+
|
|
814
864
|
/**
|
|
815
865
|
* Creates a Signal with the given value. If no value is given, the signal is created with
|
|
816
866
|
* `undefined`.
|
|
@@ -874,7 +924,6 @@ declare interface DOMAttributesBase<EL extends Element> extends QwikIntrinsicAtt
|
|
|
874
924
|
declare class DomContainer extends _SharedContainer implements ClientContainer {
|
|
875
925
|
element: _ContainerElement;
|
|
876
926
|
qContainer: string;
|
|
877
|
-
qBase: string;
|
|
878
927
|
qManifestHash: string;
|
|
879
928
|
rootVNode: _ElementVNode;
|
|
880
929
|
document: _QDocument;
|
|
@@ -903,6 +952,8 @@ declare class DomContainer extends _SharedContainer implements ClientContainer {
|
|
|
903
952
|
$getObjectById$: (id: number | string) => unknown;
|
|
904
953
|
getSyncFn(id: number): (...args: unknown[]) => unknown;
|
|
905
954
|
$appendStyle$(content: string, styleId: string, host: _VirtualVNode, scoped: boolean): void;
|
|
955
|
+
/** Set the server data for the Qwik Router. */
|
|
956
|
+
private $setServerData$;
|
|
906
957
|
}
|
|
907
958
|
export { DomContainer }
|
|
908
959
|
export { DomContainer as _DomContainer }
|
|
@@ -966,7 +1017,7 @@ Consumer,
|
|
|
966
1017
|
// EffectSubscriptionProp.CONSUMER
|
|
967
1018
|
EffectProperty | string,
|
|
968
1019
|
// EffectSubscriptionProp.PROPERTY or string for attributes
|
|
969
|
-
Set<
|
|
1020
|
+
Set<SignalImpl | TargetType> | null,
|
|
970
1021
|
// EffectSubscriptionProp.BACK_REF
|
|
971
1022
|
_EffectData | null
|
|
972
1023
|
];
|
|
@@ -1001,7 +1052,7 @@ export declare interface ErrorBoundaryStore {
|
|
|
1001
1052
|
}
|
|
1002
1053
|
|
|
1003
1054
|
/** @public */
|
|
1004
|
-
export declare const event$: <T>(qrl: T) =>
|
|
1055
|
+
export declare const event$: <T>(qrl: T) => QRL_2<T>;
|
|
1005
1056
|
|
|
1006
1057
|
declare type EventCorrectionMap = {
|
|
1007
1058
|
auxclick: PointerEvent;
|
|
@@ -1548,6 +1599,14 @@ export declare type NoSerialize<T> = (T & {
|
|
|
1548
1599
|
*/
|
|
1549
1600
|
export declare const noSerialize: <T extends object | undefined>(input: T) => NoSerialize<T>;
|
|
1550
1601
|
|
|
1602
|
+
/**
|
|
1603
|
+
* If an object has this property, it will not be serialized. Use this on prototypes to avoid having
|
|
1604
|
+
* to call `noSerialize()` on every object.
|
|
1605
|
+
*
|
|
1606
|
+
* @public
|
|
1607
|
+
*/
|
|
1608
|
+
export declare const NoSerializeSymbol: unique symbol;
|
|
1609
|
+
|
|
1551
1610
|
/** @public */
|
|
1552
1611
|
declare type Numberish = number | `${number}`;
|
|
1553
1612
|
|
|
@@ -2070,6 +2129,9 @@ export declare type QwikTransitionEvent<T = Element> = NativeTransitionEvent;
|
|
|
2070
2129
|
/** @public @deprecated Use `UIEvent` and use the second argument to the handler function for the current event target */
|
|
2071
2130
|
export declare type QwikUIEvent<T = Element> = NativeUIEvent;
|
|
2072
2131
|
|
|
2132
|
+
/** Emitted by qwik-core on document when the a view transition start @public */
|
|
2133
|
+
declare type QwikViewTransitionEvent = CustomEvent<ViewTransition>;
|
|
2134
|
+
|
|
2073
2135
|
/** Emitted by qwik-loader when an element becomes visible. Used by `useVisibleTask$` @public */
|
|
2074
2136
|
export declare type QwikVisibleEvent = CustomEvent<IntersectionObserverEntry>;
|
|
2075
2137
|
|
|
@@ -2274,7 +2336,7 @@ export declare const _restProps: (props: PropsProxy, omit: string[], target?: Pr
|
|
|
2274
2336
|
*
|
|
2275
2337
|
* @internal
|
|
2276
2338
|
*/
|
|
2277
|
-
export declare const _run: (...args: unknown[]) =>
|
|
2339
|
+
export declare const _run: (...args: unknown[]) => ValueOrPromise_2<void>;
|
|
2278
2340
|
|
|
2279
2341
|
declare type Scheduler = ReturnType<typeof createScheduler>;
|
|
2280
2342
|
|
|
@@ -2335,6 +2397,90 @@ declare interface SerializationContext {
|
|
|
2335
2397
|
*/
|
|
2336
2398
|
export declare function _serialize(data: unknown[]): Promise<string>;
|
|
2337
2399
|
|
|
2400
|
+
/**
|
|
2401
|
+
* Serialize and deserialize custom objects.
|
|
2402
|
+
*
|
|
2403
|
+
* If you need to use scoped state, you can pass a function instead of an object. The function will
|
|
2404
|
+
* be called with the current value, and you can return a new value.
|
|
2405
|
+
*
|
|
2406
|
+
* @public
|
|
2407
|
+
*/
|
|
2408
|
+
declare type SerializerArg<T, S> = SerializerArgObject<T, S> | (() => SerializerArgObject<T, S> & {
|
|
2409
|
+
/**
|
|
2410
|
+
* This gets called when reactive state used during `deserialize` changes. You may mutate the
|
|
2411
|
+
* current object, or return a new object.
|
|
2412
|
+
*
|
|
2413
|
+
* If it returns a value, that will be used as the new value, and listeners will be triggered.
|
|
2414
|
+
* If no change happened, don't return anything.
|
|
2415
|
+
*
|
|
2416
|
+
* If you mutate the current object, you must return it so that it will trigger listeners.
|
|
2417
|
+
*/
|
|
2418
|
+
update?: (current: T) => T | void;
|
|
2419
|
+
});
|
|
2420
|
+
|
|
2421
|
+
/** @public */
|
|
2422
|
+
declare type SerializerArgObject<T, S> = {
|
|
2423
|
+
/**
|
|
2424
|
+
* This will be called with initial or serialized data to reconstruct an object. If no
|
|
2425
|
+
* `initialData` is provided, it will be called with `undefined`.
|
|
2426
|
+
*
|
|
2427
|
+
* This must not return a Promise.
|
|
2428
|
+
*/
|
|
2429
|
+
deserialize: (data: Awaited<S>) => T;
|
|
2430
|
+
/** The initial value to use when deserializing. */
|
|
2431
|
+
initial?: S | undefined;
|
|
2432
|
+
/**
|
|
2433
|
+
* This will be called with the object to get the serialized data. You can return a Promise if you
|
|
2434
|
+
* need to do async work.
|
|
2435
|
+
*
|
|
2436
|
+
* The result may be anything that Qwik can serialize.
|
|
2437
|
+
*
|
|
2438
|
+
* If you do not provide it, the object will be serialized as `undefined`. However, if the object
|
|
2439
|
+
* has a `[SerializerSymbol]` property, that will be used as the serializer instead.
|
|
2440
|
+
*/
|
|
2441
|
+
serialize?: (obj: T) => S;
|
|
2442
|
+
};
|
|
2443
|
+
|
|
2444
|
+
/**
|
|
2445
|
+
* A serializer signal holds a custom serializable value. See `useSerializer$` for more details.
|
|
2446
|
+
*
|
|
2447
|
+
* @public
|
|
2448
|
+
*/
|
|
2449
|
+
declare interface SerializerSignal<T> extends ComputedSignal<T> {
|
|
2450
|
+
/** Fake property to make the serialization linter happy */
|
|
2451
|
+
__no_serialize__: true;
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
/**
|
|
2455
|
+
* A signal which provides a non-serializable value. It works like a computed signal, but it is
|
|
2456
|
+
* handled slightly differently during serdes.
|
|
2457
|
+
*
|
|
2458
|
+
* @public
|
|
2459
|
+
*/
|
|
2460
|
+
declare class SerializerSignalImpl<T, S> extends ComputedSignalImpl<T> {
|
|
2461
|
+
constructor(container: Container | null, argQrl: QRLInternal<SerializerArg<T, S>>);
|
|
2462
|
+
$didInitialize$: boolean;
|
|
2463
|
+
$computeIfNeeded$(): boolean;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
/**
|
|
2467
|
+
* If an object has this property as a function, it will be called with the object and should return
|
|
2468
|
+
* a serializable value.
|
|
2469
|
+
*
|
|
2470
|
+
* This can be used to clean up, integrate with other libraries, etc.
|
|
2471
|
+
*
|
|
2472
|
+
* The type your object should conform to is:
|
|
2473
|
+
*
|
|
2474
|
+
* ```ts
|
|
2475
|
+
* {
|
|
2476
|
+
* [SerializerSymbol]: (this: YourType, toSerialize: YourType) => YourSerializableType;
|
|
2477
|
+
* }
|
|
2478
|
+
* ```
|
|
2479
|
+
*
|
|
2480
|
+
* @public
|
|
2481
|
+
*/
|
|
2482
|
+
export declare const SerializerSymbol: unique symbol;
|
|
2483
|
+
|
|
2338
2484
|
/**
|
|
2339
2485
|
* Sets the `CorePlatform`.
|
|
2340
2486
|
*
|
|
@@ -2357,6 +2503,7 @@ export declare abstract class _SharedContainer implements Container {
|
|
|
2357
2503
|
$serverData$: Record<string, any>;
|
|
2358
2504
|
$currentUniqueId$: number;
|
|
2359
2505
|
$instanceHash$: string | null;
|
|
2506
|
+
$buildBase$: string | null;
|
|
2360
2507
|
constructor(scheduleDrain: () => void, journalFlush: () => void, serverData: Record<string, any>, locale: string);
|
|
2361
2508
|
trackSignalValue<T>(signal: Signal, subscriber: HostElement, property: string, data: _EffectData): T;
|
|
2362
2509
|
serializationCtxFactory(NodeConstructor: {
|
|
@@ -2395,7 +2542,11 @@ export declare interface Signal<T = any> extends ReadonlySignal<T> {
|
|
|
2395
2542
|
value: T;
|
|
2396
2543
|
}
|
|
2397
2544
|
|
|
2398
|
-
declare
|
|
2545
|
+
declare const enum SignalFlags {
|
|
2546
|
+
INVALID = 1
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
declare class SignalImpl<T = any> implements Signal<T> {
|
|
2399
2550
|
$untrackedValue$: T;
|
|
2400
2551
|
/** Store a list of effects which are dependent on this signal. */
|
|
2401
2552
|
$effects$: null | Set<EffectSubscription>;
|
|
@@ -2412,10 +2563,6 @@ declare class Signal_2<T = any> implements Signal<T> {
|
|
|
2412
2563
|
};
|
|
2413
2564
|
}
|
|
2414
2565
|
|
|
2415
|
-
declare const enum SignalFlags {
|
|
2416
|
-
INVALID = 1
|
|
2417
|
-
}
|
|
2418
|
-
|
|
2419
2566
|
declare interface SimplifiedServerRequestEvent<T = unknown> {
|
|
2420
2567
|
url: URL;
|
|
2421
2568
|
locale: string | undefined;
|
|
@@ -2696,7 +2843,6 @@ declare interface SSRContainer extends Container {
|
|
|
2696
2843
|
readonly prefetchResources: PrefetchResource[];
|
|
2697
2844
|
readonly serializationCtx: SerializationContext;
|
|
2698
2845
|
readonly symbolToChunkResolver: SymbolToChunkResolver;
|
|
2699
|
-
readonly buildBase: string;
|
|
2700
2846
|
additionalHeadNodes: Array<JSXNodeInternal>;
|
|
2701
2847
|
additionalBodyNodes: Array<JSXNodeInternal>;
|
|
2702
2848
|
unclaimedProjectionComponentFrameQueue: ISsrComponentFrame[];
|
|
@@ -3359,7 +3505,7 @@ export declare const useContext: UseContext;
|
|
|
3359
3505
|
export declare const useContextProvider: <STATE>(context: ContextId<STATE>, newValue: STATE) => void;
|
|
3360
3506
|
|
|
3361
3507
|
/** @public */
|
|
3362
|
-
export declare const useErrorBoundary: () =>
|
|
3508
|
+
export declare const useErrorBoundary: () => ErrorBoundaryStore;
|
|
3363
3509
|
|
|
3364
3510
|
/** @public */
|
|
3365
3511
|
export declare const useId: () => string;
|
|
@@ -3501,6 +3647,72 @@ export declare const useResource$: <T>(generatorFn: ResourceFn<T>, opts?: Resour
|
|
|
3501
3647
|
/** @internal */
|
|
3502
3648
|
export declare const useResourceQrl: <T>(qrl: QRL<ResourceFn<T>>, opts?: ResourceOptions) => ResourceReturn<T>;
|
|
3503
3649
|
|
|
3650
|
+
/**
|
|
3651
|
+
* Creates a signal which holds a custom serializable value. It requires that the value implements
|
|
3652
|
+
* the `CustomSerializable` type, which means having a function under the `[SerializeSymbol]`
|
|
3653
|
+
* property that returns a serializable value when called.
|
|
3654
|
+
*
|
|
3655
|
+
* The `fn` you pass is called with the result of the serialization (in the browser, only when the
|
|
3656
|
+
* value is needed), or `undefined` when not yet initialized. If you refer to other signals, `fn`
|
|
3657
|
+
* will be called when those change just like computed signals, and then the argument will be the
|
|
3658
|
+
* previous output, not the serialized result.
|
|
3659
|
+
*
|
|
3660
|
+
* This is useful when using third party libraries that use custom objects that are not
|
|
3661
|
+
* serializable.
|
|
3662
|
+
*
|
|
3663
|
+
* Note that the `fn` is called lazily, so it won't impact container resume.
|
|
3664
|
+
*
|
|
3665
|
+
* @example
|
|
3666
|
+
*
|
|
3667
|
+
* ```tsx
|
|
3668
|
+
* class MyCustomSerializable {
|
|
3669
|
+
* constructor(public n: number) {}
|
|
3670
|
+
* inc() {
|
|
3671
|
+
* this.n++;
|
|
3672
|
+
* }
|
|
3673
|
+
* }
|
|
3674
|
+
* const Cmp = component$(() => {
|
|
3675
|
+
* const custom = useSerializer$({
|
|
3676
|
+
* deserialize: (data) => new MyCustomSerializable(data),
|
|
3677
|
+
* serialize: (data) => data.n,
|
|
3678
|
+
* initial: 2,
|
|
3679
|
+
* });
|
|
3680
|
+
* return <div onClick$={() => custom.value.inc()}>{custom.value.n}</div>;
|
|
3681
|
+
* });
|
|
3682
|
+
* ```
|
|
3683
|
+
*
|
|
3684
|
+
* @example
|
|
3685
|
+
*
|
|
3686
|
+
* When using a Signal as the data to create the object, you need to pass the configuration as a
|
|
3687
|
+
* function, and you can then also provide the `update` function to update the object when the
|
|
3688
|
+
* signal changes.
|
|
3689
|
+
*
|
|
3690
|
+
* By returning an object from `update`, you signal that the listeners have to be notified. You can
|
|
3691
|
+
* mutate the current object but you should return it so that it will trigger listeners.
|
|
3692
|
+
*
|
|
3693
|
+
* ```tsx
|
|
3694
|
+
* const Cmp = component$(() => {
|
|
3695
|
+
* const n = useSignal(2);
|
|
3696
|
+
* const custom = useSerializer$(() =>
|
|
3697
|
+
* ({
|
|
3698
|
+
* deserialize: () => new MyCustomSerializable(n.value),
|
|
3699
|
+
* update: (current) => {
|
|
3700
|
+
* current.n = n.value;
|
|
3701
|
+
* return current;
|
|
3702
|
+
* }
|
|
3703
|
+
* })
|
|
3704
|
+
* );
|
|
3705
|
+
* return <div onClick$={() => n.value++}>{custom.value.n}</div>;
|
|
3706
|
+
* });
|
|
3707
|
+
* ```
|
|
3708
|
+
*
|
|
3709
|
+
* @public
|
|
3710
|
+
*/
|
|
3711
|
+
export declare const useSerializer$: typeof createSerializer$;
|
|
3712
|
+
|
|
3713
|
+
/** @internal */
|
|
3714
|
+
export declare const useSerializerQrl: <T, S>(qrl: QRL<SerializerArg<T, S>>) => ReadonlySignal_2<unknown>;
|
|
3715
|
+
|
|
3504
3716
|
/** @public */
|
|
3505
3717
|
export declare function useServerData<T>(key: string): T | undefined;
|
|
3506
3718
|
|
|
@@ -3700,7 +3912,7 @@ export declare const useStylesScopedQrl: (styles: QRL<string>) => UseStylesScope
|
|
|
3700
3912
|
* @public
|
|
3701
3913
|
* @see `Tracker`
|
|
3702
3914
|
*/
|
|
3703
|
-
export declare const useTask$: (
|
|
3915
|
+
export declare const useTask$: (fn: TaskFn) => void;
|
|
3704
3916
|
|
|
3705
3917
|
/** @internal */
|
|
3706
3918
|
export declare const useTaskQrl: (qrl: QRL<TaskFn>) => void;
|
|
@@ -3728,7 +3940,7 @@ export declare const useTaskQrl: (qrl: QRL<TaskFn>) => void;
|
|
|
3728
3940
|
*
|
|
3729
3941
|
* @public
|
|
3730
3942
|
*/
|
|
3731
|
-
export declare const useVisibleTask$: (
|
|
3943
|
+
export declare const useVisibleTask$: (fn: TaskFn, opts?: OnVisibleTaskOptions) => void;
|
|
3732
3944
|
|
|
3733
3945
|
/** @internal */
|
|
3734
3946
|
export declare const useVisibleTaskQrl: (qrl: QRL<TaskFn>, opts?: OnVisibleTaskOptions) => void;
|
|
@@ -3747,7 +3959,7 @@ export declare const _VAR_PROPS: unique symbol;
|
|
|
3747
3959
|
export declare const _verifySerializable: <T>(value: T, preMessage?: string) => T;
|
|
3748
3960
|
|
|
3749
3961
|
/**
|
|
3750
|
-
* 2.0.0-alpha.
|
|
3962
|
+
* 2.0.0-alpha.9-dev+56ed5bd
|
|
3751
3963
|
*
|
|
3752
3964
|
* @public
|
|
3753
3965
|
*/
|
|
@@ -3894,7 +4106,7 @@ export declare const _weakSerialize: <T extends object>(input: T) => Partial<T>;
|
|
|
3894
4106
|
*/
|
|
3895
4107
|
export declare function withLocale<T>(locale: string, fn: () => T): T;
|
|
3896
4108
|
|
|
3897
|
-
declare class WrappedSignal<T> extends
|
|
4109
|
+
declare class WrappedSignal<T> extends SignalImpl<T> implements BackRef {
|
|
3898
4110
|
$args$: any[];
|
|
3899
4111
|
$func$: (...args: any[]) => T;
|
|
3900
4112
|
$funcStr$: string | null;
|
|
@@ -3906,13 +4118,13 @@ declare class WrappedSignal<T> extends Signal_2<T> implements BackRef {
|
|
|
3906
4118
|
$invalidate$(): void;
|
|
3907
4119
|
/**
|
|
3908
4120
|
* Use this to force running subscribers, for example when the calculated value has mutated but
|
|
3909
|
-
* remained the same object
|
|
4121
|
+
* remained the same object.
|
|
3910
4122
|
*/
|
|
3911
4123
|
force(): void;
|
|
3912
4124
|
get untrackedValue(): T;
|
|
3913
4125
|
$computeIfNeeded$(): boolean;
|
|
3914
|
-
get value(): any;
|
|
3915
4126
|
set value(_: any);
|
|
4127
|
+
get value(): any;
|
|
3916
4128
|
}
|
|
3917
4129
|
|
|
3918
4130
|
declare const enum WrappedSignalFlags {
|
|
@@ -3930,7 +4142,7 @@ declare const enum WrappedSignalFlags {
|
|
|
3930
4142
|
*
|
|
3931
4143
|
* @internal
|
|
3932
4144
|
*/
|
|
3933
|
-
export declare const _wrapProp: <T extends Record<any, any>, P extends keyof T>(
|
|
4145
|
+
export declare const _wrapProp: <T extends Record<any, any>, P extends keyof T>(...args: [T, P?]) => any;
|
|
3934
4146
|
|
|
3935
4147
|
/** @internal @deprecated v1 compat */
|
|
3936
4148
|
export declare const _wrapSignal: <T extends Record<any, any>, P extends keyof T>(obj: T, prop: P) => any;
|