@qwik.dev/core 2.0.0-alpha.7 → 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 +245 -20
- package/dist/core.cjs +7280 -7339
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +7273 -7339
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +1646 -1735
- package/dist/core.prod.mjs +2737 -2849
- package/dist/insights/index.qwik.cjs +1854 -1958
- package/dist/insights/index.qwik.mjs +1854 -1958
- package/dist/insights/insights.d.ts +1 -1
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +65 -18
- package/dist/optimizer.d.ts +1 -1
- package/dist/optimizer.mjs +62 -18
- package/dist/prefetch/package.json +1 -1
- package/dist/server.cjs +42 -41
- package/dist/server.mjs +42 -41
- 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 +3723 -3615
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.mjs +3995 -3888
- 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;
|
|
@@ -95,6 +99,8 @@ declare type _AllowPlainQrl<Q> = QRLEventHandlerMulti<any, any> extends Q ? Q ex
|
|
|
95
99
|
|
|
96
100
|
declare type AllPascalEventMaps = PascalMap<AllEventsMap>;
|
|
97
101
|
|
|
102
|
+
declare type AllSignalFlags = SignalFlags | WrappedSignalFlags;
|
|
103
|
+
|
|
98
104
|
/**
|
|
99
105
|
* TS defines these with the React syntax which is not compatible with Qwik. E.g. `ariaAtomic`
|
|
100
106
|
* instead of `aria-atomic`.
|
|
@@ -411,7 +417,6 @@ export declare interface ClientContainer extends Container {
|
|
|
411
417
|
document: _QDocument;
|
|
412
418
|
element: _ContainerElement;
|
|
413
419
|
qContainer: string;
|
|
414
|
-
qBase: string;
|
|
415
420
|
$locale$: string;
|
|
416
421
|
qManifestHash: string;
|
|
417
422
|
rootVNode: _ElementVNode;
|
|
@@ -526,6 +531,37 @@ export declare interface ComputedSignal<T> extends ReadonlySignal<T> {
|
|
|
526
531
|
force(): void;
|
|
527
532
|
}
|
|
528
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
|
+
|
|
529
565
|
/** @internal */
|
|
530
566
|
export declare const _CONST_PROPS: unique symbol;
|
|
531
567
|
|
|
@@ -538,7 +574,7 @@ export declare const _CONST_PROPS: unique symbol;
|
|
|
538
574
|
* - `VNode` and `ISsrNode`: Either a component or `<Signal>`
|
|
539
575
|
* - `Signal2`: A derived signal which contains a computation function.
|
|
540
576
|
*/
|
|
541
|
-
declare type Consumer = Task | _VNode | ISsrNode |
|
|
577
|
+
declare type Consumer = Task | _VNode | ISsrNode | SignalImpl;
|
|
542
578
|
|
|
543
579
|
declare interface Container {
|
|
544
580
|
readonly $version$: string;
|
|
@@ -548,6 +584,7 @@ declare interface Container {
|
|
|
548
584
|
readonly $getObjectById$: (id: number | string) => any;
|
|
549
585
|
readonly $serverData$: Record<string, any>;
|
|
550
586
|
$currentUniqueId$: number;
|
|
587
|
+
$buildBase$: string | null;
|
|
551
588
|
handleError(err: any, $host$: HostElement): void;
|
|
552
589
|
getParentHost(host: HostElement): HostElement | null;
|
|
553
590
|
setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
|
|
@@ -733,7 +770,7 @@ export declare interface CorrectedToggleEvent extends Event {
|
|
|
733
770
|
* recalculated.
|
|
734
771
|
*
|
|
735
772
|
* The QRL must be a function which returns the value of the signal. The function must not have side
|
|
736
|
-
* effects, and it
|
|
773
|
+
* effects, and it must be synchronous.
|
|
737
774
|
*
|
|
738
775
|
* If you need the function to be async, use `useSignal` and `useTask$` instead.
|
|
739
776
|
*
|
|
@@ -742,7 +779,7 @@ export declare interface CorrectedToggleEvent extends Event {
|
|
|
742
779
|
export declare const createComputed$: <T>(qrl: () => T) => T extends Promise<any> ? never : ComputedSignal<T>;
|
|
743
780
|
|
|
744
781
|
/** @internal */
|
|
745
|
-
export declare const createComputedQrl: <T>(qrl: QRL<() => T>) =>
|
|
782
|
+
export declare const createComputedQrl: <T>(qrl: QRL<() => T>) => ComputedSignalImpl<T>;
|
|
746
783
|
|
|
747
784
|
/**
|
|
748
785
|
* Create a context ID to be used in your application. The name should be written with no spaces.
|
|
@@ -809,6 +846,21 @@ declare const createScheduler: (container: Container, scheduleDrain: () => void,
|
|
|
809
846
|
(type: ChoreType.CLEANUP_VISIBLE, task: Task): ValueOrPromise<JSXOutput>;
|
|
810
847
|
};
|
|
811
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
|
+
|
|
812
864
|
/**
|
|
813
865
|
* Creates a Signal with the given value. If no value is given, the signal is created with
|
|
814
866
|
* `undefined`.
|
|
@@ -872,7 +924,6 @@ declare interface DOMAttributesBase<EL extends Element> extends QwikIntrinsicAtt
|
|
|
872
924
|
declare class DomContainer extends _SharedContainer implements ClientContainer {
|
|
873
925
|
element: _ContainerElement;
|
|
874
926
|
qContainer: string;
|
|
875
|
-
qBase: string;
|
|
876
927
|
qManifestHash: string;
|
|
877
928
|
rootVNode: _ElementVNode;
|
|
878
929
|
document: _QDocument;
|
|
@@ -901,6 +952,8 @@ declare class DomContainer extends _SharedContainer implements ClientContainer {
|
|
|
901
952
|
$getObjectById$: (id: number | string) => unknown;
|
|
902
953
|
getSyncFn(id: number): (...args: unknown[]) => unknown;
|
|
903
954
|
$appendStyle$(content: string, styleId: string, host: _VirtualVNode, scoped: boolean): void;
|
|
955
|
+
/** Set the server data for the Qwik Router. */
|
|
956
|
+
private $setServerData$;
|
|
904
957
|
}
|
|
905
958
|
export { DomContainer }
|
|
906
959
|
export { DomContainer as _DomContainer }
|
|
@@ -964,7 +1017,7 @@ Consumer,
|
|
|
964
1017
|
// EffectSubscriptionProp.CONSUMER
|
|
965
1018
|
EffectProperty | string,
|
|
966
1019
|
// EffectSubscriptionProp.PROPERTY or string for attributes
|
|
967
|
-
Set<
|
|
1020
|
+
Set<SignalImpl | TargetType> | null,
|
|
968
1021
|
// EffectSubscriptionProp.BACK_REF
|
|
969
1022
|
_EffectData | null
|
|
970
1023
|
];
|
|
@@ -999,7 +1052,7 @@ export declare interface ErrorBoundaryStore {
|
|
|
999
1052
|
}
|
|
1000
1053
|
|
|
1001
1054
|
/** @public */
|
|
1002
|
-
export declare const event$: <T>(qrl: T) =>
|
|
1055
|
+
export declare const event$: <T>(qrl: T) => QRL_2<T>;
|
|
1003
1056
|
|
|
1004
1057
|
declare type EventCorrectionMap = {
|
|
1005
1058
|
auxclick: PointerEvent;
|
|
@@ -1546,6 +1599,14 @@ export declare type NoSerialize<T> = (T & {
|
|
|
1546
1599
|
*/
|
|
1547
1600
|
export declare const noSerialize: <T extends object | undefined>(input: T) => NoSerialize<T>;
|
|
1548
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
|
+
|
|
1549
1610
|
/** @public */
|
|
1550
1611
|
declare type Numberish = number | `${number}`;
|
|
1551
1612
|
|
|
@@ -2068,6 +2129,9 @@ export declare type QwikTransitionEvent<T = Element> = NativeTransitionEvent;
|
|
|
2068
2129
|
/** @public @deprecated Use `UIEvent` and use the second argument to the handler function for the current event target */
|
|
2069
2130
|
export declare type QwikUIEvent<T = Element> = NativeUIEvent;
|
|
2070
2131
|
|
|
2132
|
+
/** Emitted by qwik-core on document when the a view transition start @public */
|
|
2133
|
+
declare type QwikViewTransitionEvent = CustomEvent<ViewTransition>;
|
|
2134
|
+
|
|
2071
2135
|
/** Emitted by qwik-loader when an element becomes visible. Used by `useVisibleTask$` @public */
|
|
2072
2136
|
export declare type QwikVisibleEvent = CustomEvent<IntersectionObserverEntry>;
|
|
2073
2137
|
|
|
@@ -2272,7 +2336,7 @@ export declare const _restProps: (props: PropsProxy, omit: string[], target?: Pr
|
|
|
2272
2336
|
*
|
|
2273
2337
|
* @internal
|
|
2274
2338
|
*/
|
|
2275
|
-
export declare const _run: (...args: unknown[]) =>
|
|
2339
|
+
export declare const _run: (...args: unknown[]) => ValueOrPromise_2<void>;
|
|
2276
2340
|
|
|
2277
2341
|
declare type Scheduler = ReturnType<typeof createScheduler>;
|
|
2278
2342
|
|
|
@@ -2333,6 +2397,90 @@ declare interface SerializationContext {
|
|
|
2333
2397
|
*/
|
|
2334
2398
|
export declare function _serialize(data: unknown[]): Promise<string>;
|
|
2335
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
|
+
|
|
2336
2484
|
/**
|
|
2337
2485
|
* Sets the `CorePlatform`.
|
|
2338
2486
|
*
|
|
@@ -2355,6 +2503,7 @@ export declare abstract class _SharedContainer implements Container {
|
|
|
2355
2503
|
$serverData$: Record<string, any>;
|
|
2356
2504
|
$currentUniqueId$: number;
|
|
2357
2505
|
$instanceHash$: string | null;
|
|
2506
|
+
$buildBase$: string | null;
|
|
2358
2507
|
constructor(scheduleDrain: () => void, journalFlush: () => void, serverData: Record<string, any>, locale: string);
|
|
2359
2508
|
trackSignalValue<T>(signal: Signal, subscriber: HostElement, property: string, data: _EffectData): T;
|
|
2360
2509
|
serializationCtxFactory(NodeConstructor: {
|
|
@@ -2393,7 +2542,11 @@ export declare interface Signal<T = any> extends ReadonlySignal<T> {
|
|
|
2393
2542
|
value: T;
|
|
2394
2543
|
}
|
|
2395
2544
|
|
|
2396
|
-
declare
|
|
2545
|
+
declare const enum SignalFlags {
|
|
2546
|
+
INVALID = 1
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
declare class SignalImpl<T = any> implements Signal<T> {
|
|
2397
2550
|
$untrackedValue$: T;
|
|
2398
2551
|
/** Store a list of effects which are dependent on this signal. */
|
|
2399
2552
|
$effects$: null | Set<EffectSubscription>;
|
|
@@ -2690,7 +2843,6 @@ declare interface SSRContainer extends Container {
|
|
|
2690
2843
|
readonly prefetchResources: PrefetchResource[];
|
|
2691
2844
|
readonly serializationCtx: SerializationContext;
|
|
2692
2845
|
readonly symbolToChunkResolver: SymbolToChunkResolver;
|
|
2693
|
-
readonly buildBase: string;
|
|
2694
2846
|
additionalHeadNodes: Array<JSXNodeInternal>;
|
|
2695
2847
|
additionalBodyNodes: Array<JSXNodeInternal>;
|
|
2696
2848
|
unclaimedProjectionComponentFrameQueue: ISsrComponentFrame[];
|
|
@@ -3353,7 +3505,7 @@ export declare const useContext: UseContext;
|
|
|
3353
3505
|
export declare const useContextProvider: <STATE>(context: ContextId<STATE>, newValue: STATE) => void;
|
|
3354
3506
|
|
|
3355
3507
|
/** @public */
|
|
3356
|
-
export declare const useErrorBoundary: () =>
|
|
3508
|
+
export declare const useErrorBoundary: () => ErrorBoundaryStore;
|
|
3357
3509
|
|
|
3358
3510
|
/** @public */
|
|
3359
3511
|
export declare const useId: () => string;
|
|
@@ -3495,6 +3647,72 @@ export declare const useResource$: <T>(generatorFn: ResourceFn<T>, opts?: Resour
|
|
|
3495
3647
|
/** @internal */
|
|
3496
3648
|
export declare const useResourceQrl: <T>(qrl: QRL<ResourceFn<T>>, opts?: ResourceOptions) => ResourceReturn<T>;
|
|
3497
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
|
+
|
|
3498
3716
|
/** @public */
|
|
3499
3717
|
export declare function useServerData<T>(key: string): T | undefined;
|
|
3500
3718
|
|
|
@@ -3694,7 +3912,7 @@ export declare const useStylesScopedQrl: (styles: QRL<string>) => UseStylesScope
|
|
|
3694
3912
|
* @public
|
|
3695
3913
|
* @see `Tracker`
|
|
3696
3914
|
*/
|
|
3697
|
-
export declare const useTask$: (
|
|
3915
|
+
export declare const useTask$: (fn: TaskFn) => void;
|
|
3698
3916
|
|
|
3699
3917
|
/** @internal */
|
|
3700
3918
|
export declare const useTaskQrl: (qrl: QRL<TaskFn>) => void;
|
|
@@ -3722,7 +3940,7 @@ export declare const useTaskQrl: (qrl: QRL<TaskFn>) => void;
|
|
|
3722
3940
|
*
|
|
3723
3941
|
* @public
|
|
3724
3942
|
*/
|
|
3725
|
-
export declare const useVisibleTask$: (
|
|
3943
|
+
export declare const useVisibleTask$: (fn: TaskFn, opts?: OnVisibleTaskOptions) => void;
|
|
3726
3944
|
|
|
3727
3945
|
/** @internal */
|
|
3728
3946
|
export declare const useVisibleTaskQrl: (qrl: QRL<TaskFn>, opts?: OnVisibleTaskOptions) => void;
|
|
@@ -3741,7 +3959,7 @@ export declare const _VAR_PROPS: unique symbol;
|
|
|
3741
3959
|
export declare const _verifySerializable: <T>(value: T, preMessage?: string) => T;
|
|
3742
3960
|
|
|
3743
3961
|
/**
|
|
3744
|
-
* 2.0.0-alpha.
|
|
3962
|
+
* 2.0.0-alpha.9-dev+56ed5bd
|
|
3745
3963
|
*
|
|
3746
3964
|
* @public
|
|
3747
3965
|
*/
|
|
@@ -3888,25 +4106,29 @@ export declare const _weakSerialize: <T extends object>(input: T) => Partial<T>;
|
|
|
3888
4106
|
*/
|
|
3889
4107
|
export declare function withLocale<T>(locale: string, fn: () => T): T;
|
|
3890
4108
|
|
|
3891
|
-
declare class WrappedSignal<T> extends
|
|
4109
|
+
declare class WrappedSignal<T> extends SignalImpl<T> implements BackRef {
|
|
3892
4110
|
$args$: any[];
|
|
3893
4111
|
$func$: (...args: any[]) => T;
|
|
3894
4112
|
$funcStr$: string | null;
|
|
3895
|
-
$
|
|
4113
|
+
$flags$: AllSignalFlags;
|
|
3896
4114
|
$hostElement$: HostElement | null;
|
|
3897
4115
|
$forceRunEffects$: boolean;
|
|
3898
4116
|
[_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | null;
|
|
3899
|
-
constructor(container: Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null);
|
|
4117
|
+
constructor(container: Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null, flags?: SignalFlags);
|
|
3900
4118
|
$invalidate$(): void;
|
|
3901
4119
|
/**
|
|
3902
4120
|
* Use this to force running subscribers, for example when the calculated value has mutated but
|
|
3903
|
-
* remained the same object
|
|
4121
|
+
* remained the same object.
|
|
3904
4122
|
*/
|
|
3905
4123
|
force(): void;
|
|
3906
4124
|
get untrackedValue(): T;
|
|
3907
4125
|
$computeIfNeeded$(): boolean;
|
|
3908
|
-
get value(): any;
|
|
3909
4126
|
set value(_: any);
|
|
4127
|
+
get value(): any;
|
|
4128
|
+
}
|
|
4129
|
+
|
|
4130
|
+
declare const enum WrappedSignalFlags {
|
|
4131
|
+
UNWRAP = 2
|
|
3910
4132
|
}
|
|
3911
4133
|
|
|
3912
4134
|
/**
|
|
@@ -3920,9 +4142,12 @@ declare class WrappedSignal<T> extends Signal_2<T> implements BackRef {
|
|
|
3920
4142
|
*
|
|
3921
4143
|
* @internal
|
|
3922
4144
|
*/
|
|
3923
|
-
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;
|
|
3924
4146
|
|
|
3925
4147
|
/** @internal @deprecated v1 compat */
|
|
3926
4148
|
export declare const _wrapSignal: <T extends Record<any, any>, P extends keyof T>(obj: T, prop: P) => any;
|
|
3927
4149
|
|
|
4150
|
+
/** @internal */
|
|
4151
|
+
export declare const _wrapStore: <T extends Record<any, any>, P extends keyof T>(obj: T, prop: P) => Signal<T>;
|
|
4152
|
+
|
|
3928
4153
|
export { }
|