@manyducks.co/dolla 3.1.0 → 3.3.0
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/dist/core/index.d.ts +1 -1
- package/dist/core/signals.d.ts +56 -2
- package/dist/core-BRSu5hVw.js +1054 -0
- package/dist/core-BRSu5hVw.js.map +1 -0
- package/dist/index.js +2 -4
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/router/types.d.ts +4 -3
- package/dist/router/utils.d.ts +1 -1
- package/dist/router.js +166 -168
- package/dist/router.js.map +1 -1
- package/dist/translate.js +33 -33
- package/package.json +1 -1
- package/dist/context-B5blupD2.js +0 -363
- package/dist/context-B5blupD2.js.map +0 -1
- package/dist/core-JHktdqjt.js +0 -242
- package/dist/core-JHktdqjt.js.map +0 -1
- package/dist/signals-CMJPGr_M.js +0 -354
- package/dist/signals-CMJPGr_M.js.map +0 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createRoot } from "./root.js";
|
|
2
2
|
export type { DollaPlugin } from "./root.js";
|
|
3
|
-
export { batch, compose, createAtom, createEffect, peek, subscribe, unwrap } from "./signals.js";
|
|
3
|
+
export { batch, compose, createAtom, createEffect, createSetter, createStream, peek, subscribe, unwrap, } from "./signals.js";
|
|
4
4
|
export type { Getter, Setter } from "./signals.js";
|
|
5
5
|
export { addStore, getNearestViewNode, getRootElement, getStore, onCleanup, onEffect, onMount } from "./context.js";
|
|
6
6
|
export type { Context } from "./context.js";
|
package/dist/core/signals.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Context } from "./index.js";
|
|
1
2
|
/**
|
|
2
3
|
* Returns the currently held value. Registers the state as a dependency when called within a tracking context.
|
|
3
4
|
*/
|
|
@@ -41,7 +42,25 @@ export declare function createAtom<T>(): AtomAccessors<T | undefined>;
|
|
|
41
42
|
* getValue("overwritten");
|
|
42
43
|
* getInputValue(); // "overwritten"
|
|
43
44
|
*/
|
|
44
|
-
export declare function createAtom<T>(
|
|
45
|
+
export declare function createAtom<T>(initialValue: Getter<T>): AtomAccessors<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new atom with a value computed from an existing getter.
|
|
48
|
+
* This is usually used to create a 'settable' getter, in which you can store
|
|
49
|
+
* a temporary value until it gets overwritten by a _real_ update.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const [getValue, setValue] = createAtom("");
|
|
53
|
+
* const [getInputValue, setInputValue] = createAtom(getValue);
|
|
54
|
+
*
|
|
55
|
+
* setInputValue("temporary");
|
|
56
|
+
* getValue("");
|
|
57
|
+
* getInputValue(); // "temporary"
|
|
58
|
+
*
|
|
59
|
+
* setValue("overwritten");
|
|
60
|
+
* getValue("overwritten");
|
|
61
|
+
* getInputValue(); // "overwritten"
|
|
62
|
+
*/
|
|
63
|
+
export declare function createAtom<T>(initialValue: MaybeGetter<T>): AtomAccessors<T>;
|
|
45
64
|
/**
|
|
46
65
|
* Creates a new atom with an initial value.
|
|
47
66
|
* Returns a `[getter, setter]` function tuple.
|
|
@@ -50,7 +69,11 @@ export declare function createAtom<T>(compute: Getter<T>): AtomAccessors<T>;
|
|
|
50
69
|
* const [getCount, setCount] = createAtom(5);
|
|
51
70
|
*/
|
|
52
71
|
export declare function createAtom<T>(initialValue: T): AtomAccessors<T>;
|
|
53
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Creates a customsetter with a `getter` as its source.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createSetter<T>(getter: Getter<T>, callback: (current: T) => T | void): Setter<T>;
|
|
76
|
+
export declare function compose<T>(getter: T | ((previousValue?: T) => Getter<T> | T)): Getter<T>;
|
|
54
77
|
export declare function createEffect(fn: () => void): () => void;
|
|
55
78
|
/**
|
|
56
79
|
* Unwraps a `MaybeGetter<T>` into a plain `T`.
|
|
@@ -68,3 +91,34 @@ export declare function peek<T>(value: T | Getter<T>): T;
|
|
|
68
91
|
*/
|
|
69
92
|
export declare function batch(callback: () => void): void;
|
|
70
93
|
export declare function subscribe<T>(target: Getter<T>, fn: (value: T) => any): () => void;
|
|
94
|
+
export interface StreamOptions<T> {
|
|
95
|
+
/**
|
|
96
|
+
* An initial value for non-nullable streams.
|
|
97
|
+
*/
|
|
98
|
+
initialValue?: T;
|
|
99
|
+
/**
|
|
100
|
+
* Cancel pending `next` listeners when this context is unmounted.
|
|
101
|
+
*/
|
|
102
|
+
context?: Context;
|
|
103
|
+
/**
|
|
104
|
+
* Number of emitted values to keep. Defaults to 0 (latest value only).
|
|
105
|
+
*/
|
|
106
|
+
history?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface StreamOptionsWithValue<T> extends StreamOptions<T> {
|
|
109
|
+
initialValue: T;
|
|
110
|
+
}
|
|
111
|
+
export interface Stream<T> {
|
|
112
|
+
readonly latest: T;
|
|
113
|
+
current: Getter<T>;
|
|
114
|
+
next(): Promise<T>;
|
|
115
|
+
map<O>(callback: (value: T, previous?: O) => O): Stream<O>;
|
|
116
|
+
reduce<O>(callback: (reduced: O, value: T) => O, initialValue: O): Stream<O>;
|
|
117
|
+
filter(callback: (value: T, previous?: T) => boolean, defaultValue: T): Stream<T>;
|
|
118
|
+
filter(callback: (value: T, previous?: T) => boolean, defaultValue?: T): Stream<T | undefined>;
|
|
119
|
+
throttle(milliseconds: number): Stream<T>;
|
|
120
|
+
debounce(milliseconds: number): Stream<T>;
|
|
121
|
+
delay(milliseconds: number, initialValue?: T): Stream<T>;
|
|
122
|
+
}
|
|
123
|
+
export declare function createStream<T>(options: StreamOptionsWithValue<T>): [Stream<T>, Setter<T>];
|
|
124
|
+
export declare function createStream<T>(options: StreamOptions<T>): [Stream<T | undefined>, Setter<T | undefined>];
|