@but212/atom-effect-jquery 0.25.0 → 0.26.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/README.md +1 -1
- package/dist/atom-effect-jquery.min.js +2 -2
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +56 -0
- package/dist/index.mjs +377 -351
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,19 @@ declare type AsyncReactiveValue<T> = T | ReadonlyAtom<T | Promise<T>> | Promise<
|
|
|
19
19
|
|
|
20
20
|
export { atom }
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Creates a two-way "lens" for a specific property path on an object-based atom.
|
|
24
|
+
* Optimized for performance using structural sharing and equality guards.
|
|
25
|
+
*
|
|
26
|
+
* This "fake" atom allows fine-grained binding to deep properties of a
|
|
27
|
+
* monolithic state atom without extra memory or complex computed logic.
|
|
28
|
+
*
|
|
29
|
+
* @param atom The source atom containing the object.
|
|
30
|
+
* @param path Dot-separated path to the property (e.g. 'user.profile.name').
|
|
31
|
+
* @returns A WritableAtom that reads from and writes to the specified path.
|
|
32
|
+
*/
|
|
33
|
+
export declare function atomLens<T extends object, P extends Paths<T>>(atom: WritableAtom<T>, path: P): WritableAtom<PathValue<T, P>>;
|
|
34
|
+
|
|
22
35
|
export { batch }
|
|
23
36
|
|
|
24
37
|
/**
|
|
@@ -88,6 +101,15 @@ declare class BindingRegistry {
|
|
|
88
101
|
*/
|
|
89
102
|
export declare type ComponentFn<P = Record<string, unknown>> = ($el: JQuery, props: P) => EffectResult;
|
|
90
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Composes an existing lens with a sub-path to create a deeper lens.
|
|
106
|
+
*
|
|
107
|
+
* @param lens The parent lens.
|
|
108
|
+
* @param path Sub-path relative to the parent lens.
|
|
109
|
+
* @returns A new lens pointing to the deeper path.
|
|
110
|
+
*/
|
|
111
|
+
export declare function composeLens<T extends object, P extends Paths<T>>(lens: WritableAtom<T>, path: P): WritableAtom<PathValue<T, P>>;
|
|
112
|
+
|
|
91
113
|
export { computed }
|
|
92
114
|
|
|
93
115
|
export { ComputedAtom }
|
|
@@ -199,6 +221,16 @@ declare type KeysOfType<T, V> = {
|
|
|
199
221
|
[K in keyof T]: T[K] extends V ? K : never;
|
|
200
222
|
}[keyof T];
|
|
201
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Creates a lens factory bound to a specific atom.
|
|
226
|
+
* Eliminates the need to pass the atom reference on every call.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* const lens = lensFor(userAtom);
|
|
230
|
+
* const email = lens('settings.notifications.email'); // WritableAtom<boolean>
|
|
231
|
+
*/
|
|
232
|
+
export declare function lensFor<T extends object>(atom: WritableAtom<T>): <P extends Paths<T>>(path: P) => WritableAtom<PathValue<T, P>>;
|
|
233
|
+
|
|
202
234
|
/** Key type for Map/Set inside list.ts */
|
|
203
235
|
declare type ListKey = string | number;
|
|
204
236
|
|
|
@@ -238,6 +270,12 @@ export declare interface ListOptions<T> {
|
|
|
238
270
|
/** Possible return types for render() / empty */
|
|
239
271
|
declare type ListRenderResult = string | Element | DocumentFragment | JQuery;
|
|
240
272
|
|
|
273
|
+
/**
|
|
274
|
+
* Maximum recursion depth for path generation.
|
|
275
|
+
* Prevents TypeScript compiler from hitting recursion limits on deeply nested types.
|
|
276
|
+
*/
|
|
277
|
+
declare type MaxDepth = 8;
|
|
278
|
+
|
|
241
279
|
/**
|
|
242
280
|
* Resolves after all pending microtask-scheduled reactive effects have flushed.
|
|
243
281
|
*
|
|
@@ -257,6 +295,18 @@ declare type ListRenderResult = string | Element | DocumentFragment | JQuery;
|
|
|
257
295
|
*/
|
|
258
296
|
export declare function nextTick(): Promise<void>;
|
|
259
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Generates a union of all valid dot-separated paths for type T.
|
|
300
|
+
*/
|
|
301
|
+
export declare type Paths<T, D extends unknown[] = []> = D['length'] extends MaxDepth ? never : T extends object ? {
|
|
302
|
+
[K in keyof T & (string | number)]-?: `${K}` | (T[K] extends object ? `${K}.${Paths<T[K], [...D, 1]>}` : never);
|
|
303
|
+
}[keyof T & (string | number)] : never;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Extracts the value type at path P within type T.
|
|
307
|
+
*/
|
|
308
|
+
export declare type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? StringKeyToNumber<K> extends keyof T ? PathValue<T[StringKeyToNumber<K> & keyof T], Rest> : never : StringKeyToNumber<P> extends keyof T ? T[StringKeyToNumber<P> & keyof T] : never;
|
|
309
|
+
|
|
260
310
|
/**
|
|
261
311
|
* Values allowed for DOM properties and attributes.
|
|
262
312
|
*/
|
|
@@ -308,6 +358,12 @@ export declare interface Router {
|
|
|
308
358
|
destroy: () => void;
|
|
309
359
|
}
|
|
310
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Helper to convert a numeric string to a number type, otherwise returns the string.
|
|
363
|
+
* Used for array indexing in paths.
|
|
364
|
+
*/
|
|
365
|
+
declare type StringKeyToNumber<S extends string> = S extends `${infer N extends number}` ? N : S;
|
|
366
|
+
|
|
311
367
|
export declare interface TemplateRoute extends RouteLifecycle {
|
|
312
368
|
template: string;
|
|
313
369
|
render?: never;
|