@tempots/dom 18.0.0 → 19.1.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.
Files changed (49) hide show
  1. package/dom/animatable.d.ts +12 -12
  2. package/dom/attr.d.ts +14 -7
  3. package/dom/dom-context.d.ts +47 -2
  4. package/dom/dom-utils.d.ts +6 -3
  5. package/dom/handle-anchor-click.d.ts +13 -2
  6. package/dom/ssr.d.ts +48 -16
  7. package/index.cjs +1 -1
  8. package/index.js +1000 -755
  9. package/package.json +1 -1
  10. package/renderable/async.d.ts +33 -3
  11. package/renderable/attribute.d.ts +24 -7
  12. package/renderable/bind.d.ts +43 -13
  13. package/renderable/conjunction.d.ts +23 -4
  14. package/renderable/consumers.d.ts +54 -1
  15. package/renderable/domnode.d.ts +10 -2
  16. package/renderable/element.d.ts +50 -3
  17. package/renderable/empty.d.ts +5 -0
  18. package/renderable/ensure.d.ts +10 -0
  19. package/renderable/foreach.d.ts +12 -2
  20. package/renderable/fragment.d.ts +11 -0
  21. package/renderable/handler.d.ts +64 -10
  22. package/renderable/map-signal.d.ts +15 -0
  23. package/renderable/not-empty.d.ts +13 -1
  24. package/renderable/onctx.d.ts +9 -2
  25. package/renderable/oneof.d.ts +138 -16
  26. package/renderable/onmount.d.ts +8 -0
  27. package/renderable/onunmount.d.ts +6 -0
  28. package/renderable/portal.d.ts +12 -3
  29. package/renderable/providers.d.ts +39 -6
  30. package/renderable/render.d.ts +39 -3
  31. package/renderable/repeat.d.ts +11 -2
  32. package/renderable/style.d.ts +4 -0
  33. package/renderable/task.d.ts +18 -2
  34. package/renderable/text.d.ts +16 -3
  35. package/renderable/when.d.ts +21 -3
  36. package/std/interpolate.d.ts +56 -5
  37. package/std/position.d.ts +46 -2
  38. package/std/signal-utils.d.ts +195 -19
  39. package/std/signal.d.ts +401 -30
  40. package/types/aria-attributes.d.ts +5 -0
  41. package/types/css-styles.d.ts +11 -0
  42. package/types/domain.d.ts +62 -2
  43. package/types/html-attributes.d.ts +10 -0
  44. package/types/html-events.d.ts +5 -0
  45. package/types/html-tags.d.ts +5 -0
  46. package/types/mathml-attributes.d.ts +5 -0
  47. package/types/mathml-tags.d.ts +4 -0
  48. package/types/svg-attributes.d.ts +5 -0
  49. package/types/svg-tags.d.ts +5 -0
package/std/signal.d.ts CHANGED
@@ -1,80 +1,451 @@
1
1
  import { Value } from '../types/domain';
2
2
 
3
- declare const $isSignal = "$__signal__";
4
- declare const $isProp = "$__prop__";
5
- declare const $isComputed = "$__computed__";
3
+ /**
4
+ * Represents any type of signal.
5
+ * It can be a Signal, Prop, or Computed.
6
+ *
7
+ * @typeParam T - The type of value the signal holds.
8
+ * @public
9
+ */
6
10
  export type AnySignal<T = any> = Signal<T> | Prop<T> | Computed<T>;
11
+ /**
12
+ * Represents a type that maps each property of `T` to a `Signal` of its corresponding type.
13
+ * @typeParam T - The type of the object.
14
+ * @public
15
+ */
16
+ export type AtGetter<T> = {
17
+ [K in keyof T]-?: Signal<T[K]>;
18
+ };
19
+ /**
20
+ * Represents a signal that holds a value and notifies its listeners when the value changes.
21
+ * @typeParam T - The type of the value held by the signal.
22
+ * @public
23
+ */
7
24
  export declare class Signal<T> {
8
25
  readonly equals: (a: T, b: T) => boolean;
9
- static ofPromise<T>(promise: Promise<T>, init: T, recover?: (error: unknown) => T, equals?: (a: T, b: T) => boolean): Signal<T>;
10
- static is<T = unknown>(value: unknown): value is Signal<T>;
11
- static wrap<T>(value: T | Signal<T>, equals?: (a: T, b: T) => boolean): Signal<T>;
12
- static maybeWrap<T>(value: T | Signal<T> | null | undefined): Signal<T> | undefined | null;
13
- static unwrap<T>(value: Signal<T> | T): T;
14
- static map<T, U>(value: Value<T>, fn: (value: T) => U): Value<U>;
15
- protected readonly [$isSignal] = true;
26
+ /**
27
+ * Creates a Signal that holds the result of a Promise.
28
+ *
29
+ * @typeParam O - The type of the value returned by the Promise.
30
+ * @param promise - The Promise to use to feed the Signal.
31
+ * @param init - The initial value of the Signal before the Promise resolves.
32
+ * @param recover - A function to recover from Promise rejection and provide an alternative value for the Signal.
33
+ * @param equals - A function to compare two values of type O for equality. Defaults to strict equality (===).
34
+ * @returns - A Signal that represents the result of the Promise.
35
+ */
36
+ static readonly ofPromise: <O>(promise: Promise<O>, init: O, recover?: (error: unknown) => O, equals?: (a: O, b: O) => boolean) => Signal<O>;
37
+ /**
38
+ * Checks if a value is a Signal.
39
+ *
40
+ * @param value - The value to check.
41
+ * @returns `true` if the value is a Signal, `false` otherwise.
42
+ */
43
+ static readonly is: <O = unknown>(value: unknown) => value is Signal<O>;
44
+ /**
45
+ * Wraps a value or a Signal instance into a Signal.
46
+ * If the value is already a Signal, it returns the value itself.
47
+ * If the value is not a Signal, it creates a new Signal instance with the given value.
48
+ *
49
+ * @typeParam O - The type of the value.
50
+ * @param value - The value or Signal instance to wrap.
51
+ * @param equals - A function that determines if two values are equal. Defaults to strict equality (===).
52
+ * @returns A Signal instance.
53
+ */
54
+ static readonly wrap: <O>(value: O | Signal<O>, equals?: (a: O, b: O) => boolean) => Signal<O>;
55
+ /**
56
+ * Wraps a value in a `Signal` if it is not already a `Signal`.
57
+ * If the value is `null` or `undefined`, it returns `null` or `undefined` respectively.
58
+ * @param value - The value to wrap or check.
59
+ * @returns The wrapped value if it is not `null` or `undefined`, otherwise `null` or `undefined`.
60
+ */
61
+ static readonly maybeWrap: <O>(value: O | Signal<O> | null | undefined) => Signal<O> | undefined | null;
62
+ /**
63
+ * Unwraps a value from a `Signal` if it is a `Signal`, otherwise returns the value as is.
64
+ *
65
+ * @param value - The value to unwrap.
66
+ * @returns The unwrapped value.
67
+ */
68
+ static readonly unwrap: <O>(value: Signal<O> | O) => O;
69
+ /**
70
+ * Maps the value of a `Signal` or a regular value using the provided mapping function.
71
+ * If the input value is a `Signal`, the mapping function is applied to its value.
72
+ * If the input value is not a `Signal`, the mapping function is directly applied to the value.
73
+ *
74
+ * @param value - The input value to be mapped.
75
+ * @param fn - The mapping function to be applied to the value.
76
+ * @returns A new `Signal` with the mapped value if the input value is a `Signal`,
77
+ * otherwise, the result of applying the mapping function to the value.
78
+ *
79
+ * @typeParam N - The type of the input value.
80
+ * @typeParam O - The type of the mapped value.
81
+ */
82
+ static readonly map: <N, O>(value: Value<N>, fn: (value: N) => O) => Value<O>;
83
+ /**
84
+ * @internal
85
+ */
86
+ protected readonly $__signal__ = true;
87
+ /**
88
+ * @internal
89
+ */
16
90
  protected _value: T;
91
+ /**
92
+ * @internal
93
+ */
17
94
  protected readonly _derivatives: Array<Computed<unknown>>;
95
+ /**
96
+ * @internal
97
+ */
18
98
  protected readonly _onValueListeners: Array<(value: T) => void>;
99
+ /**
100
+ * @internal
101
+ */
19
102
  protected readonly _onDisposeListeners: Array<() => void>;
103
+ /**
104
+ * Represents a signal with a value of type T.
105
+ *
106
+ * @param value - The initial value of the signal.
107
+ * @param equals - A function that determines whether two values of type T are equal.
108
+ * @public
109
+ */
20
110
  constructor(value: T, equals: (a: T, b: T) => boolean);
111
+ /**
112
+ * Gets the current value of the signal.
113
+ * @returns The current value of the signal.
114
+ */
21
115
  readonly get: () => T;
116
+ /**
117
+ * Gets the value of the signal.
118
+ * @returns The current value of the signal.
119
+ */
22
120
  get value(): T;
121
+ /**
122
+ * Checks if the signal has any registered listeners.
123
+ * @returns `true` if the signal has listeners, `false` otherwise.
124
+ */
23
125
  readonly hasListeners: () => boolean;
126
+ /**
127
+ * Registers a listener function to be called whenever the value of the signal changes.
128
+ * The listener function will be immediately called with the current value of the signal.
129
+ * Returns a function that can be called to unregister the listener.
130
+ *
131
+ * @param listener - The listener function to be called when the value of the signal changes.
132
+ */
24
133
  readonly on: (listener: (value: T) => void) => () => void;
134
+ /**
135
+ * @internal
136
+ */
25
137
  protected readonly _setAndNotify: (newV: T, forceNotifications: boolean) => void;
138
+ /**
139
+ * @internal
140
+ */
26
141
  protected _disposed: boolean;
142
+ /**
143
+ * Checks whether the signal is disposed.
144
+ * @returns True if the signal is disposed, false otherwise.
145
+ */
27
146
  readonly isDisposed: () => boolean;
147
+ /**
148
+ * Adds a listener function to be called when the object is disposed.
149
+ * @param listener - The listener function to be called when the object is disposed.
150
+ * @returns A function that can be called to remove the listener.
151
+ */
28
152
  readonly onDispose: (listener: () => void) => void;
153
+ /**
154
+ * Disposes the signal, releasing any resources associated with it.
155
+ */
29
156
  readonly dispose: () => void;
30
- readonly map: <U>(fn: (value: T) => U, equals?: (a: U, b: U) => boolean) => Computed<U>;
31
- readonly flatMap: <U>(fn: (value: T) => Signal<U>, equals?: (a: U, b: U) => boolean) => Computed<U>;
157
+ /**
158
+ * Returns a new Computed instance that applies the given mapping function to the value of this Signal.
159
+ * The mapping function is called whenever the value of this Signal changes.
160
+ *
161
+ * @typeParam O - The type of the mapped value.
162
+ * @param fn - The mapping function to apply to the value of this Signal.
163
+ * @param equals - Optional equality function to determine if two mapped values are equal.
164
+ * @returns - A new Computed instance with the mapped value.
165
+ */
166
+ readonly map: <O>(fn: (value: T) => O, equals?: (a: O, b: O) => boolean) => Computed<O>;
167
+ /**
168
+ * Returns a new Signal that applies the given function to the value of the current Signal,
169
+ * and then flattens the resulting Signal.
170
+ *
171
+ * @typeParam O - The type of the value emitted by the resulting Signal.
172
+ * @param fn - The function to apply to the value of the current Signal.
173
+ * @param equals - A function that determines whether two values of type O are equal.
174
+ * Defaults to a strict equality check (===).
175
+ * @returns A new Signal that emits the values of the resulting Signal.
176
+ */
177
+ readonly flatMap: <O>(fn: (value: T) => Signal<O>, equals?: (a: O, b: O) => boolean) => Computed<O>;
178
+ /**
179
+ * Invokes a callback function with the current value of the signal, without modifying the signal.
180
+ *
181
+ * @param fn - The callback function to be invoked with the current value of the signal.
182
+ * @returns A new signal that emits the same value as the original signal and invokes the callback function.
183
+ */
32
184
  readonly tap: (fn: (value: T) => void) => Computed<T>;
185
+ /**
186
+ * Returns a new Signal that emits the value at the specified key of the current value.
187
+ *
188
+ * @param key - The key of the value to retrieve.
189
+ * @returns A new Signal that emits the value at the specified key.
190
+ */
33
191
  readonly at: <K extends keyof T>(key: K) => Signal<T[K]>;
34
- readonly $: { [K in keyof T]: Signal<T[K]>; };
192
+ /**
193
+ * Represents a collection of signals for each key in the value of the signal.
194
+ * @typeParam T - The type of the signals.
195
+ */
196
+ readonly $: AtGetter<T>;
35
197
  readonly filter: (fn: (value: T) => boolean, startValue?: T) => Computed<T>;
36
- readonly filterMap: <U>(fn: (value: T) => U | undefined | null, startValue: U, equals?: (a: U, b: U) => boolean) => Computed<U>;
37
- readonly mapAsync: <U>(fn: (value: T) => Promise<U>, alt: U, recover?: (error: unknown) => U, equals?: (a: U, b: U) => boolean) => Prop<U>;
38
- readonly mapMaybe: <U>(fn: (value: T) => U | undefined | null, alt: U) => Computed<U>;
198
+ /**
199
+ * Returns a new Computed object that applies the provided mapping function to the value of this Signal,
200
+ * and filters out values that are `undefined` or `null`.
201
+ *
202
+ * @typeParam O - The type of the mapped value.
203
+ * @param fn - The mapping function to apply to the value of this Signal.
204
+ * @param startValue - The initial value for the Computed object.
205
+ * @param equals - Optional equality function to determine if two values are equal.
206
+ * @returns - A new Computed object with the mapped and filtered values.
207
+ */
208
+ readonly filterMap: <O>(fn: (value: T) => O | undefined | null, startValue: O, equals?: (a: O, b: O) => boolean) => Computed<O>;
209
+ /**
210
+ * Maps the values emitted by the signal to a new value asynchronously using the provided function.
211
+ * If the function throws an error, it will be caught and logged.
212
+ * If a recovery function is provided, it will be called with the error and its return value will be used as the mapped value.
213
+ * If no recovery function is provided, the error will be logged as an unhandled promise rejection.
214
+ *
215
+ * @typeParam O - The type of the mapped value.
216
+ * @param fn - The function to map the values emitted by the signal. The second argument to this function allows to cancel the previously running mapping function if it has not completed by the time a new value is emitted.
217
+ * @param alt - The alternate value to use if the signal is disposed or the mapping function throws an error.
218
+ * @param recover - The recovery function to handle errors thrown by the mapping function.
219
+ * @param equals - The equality function to compare the mapped values for equality.
220
+ * @returns A property that holds the mapped value and can be observed for changes.
221
+ */
222
+ readonly mapAsync: <O>(fn: (value: T, options: {
223
+ abortSignal: AbortSignal;
224
+ }) => Promise<O>, alt: O, recover?: (error: unknown) => O, equals?: (a: O, b: O) => boolean) => Prop<O>;
225
+ /**
226
+ * Maps the values of the signal using the provided function `fn`, and returns a new signal
227
+ * containing the mapped values. If the mapped value is `undefined` or `null`, it is replaced
228
+ * with the provided `alt` value.
229
+ *
230
+ * @typeParam O - The type of the mapped value.
231
+ * @param fn - The function used to map the values of the signal.
232
+ * @param alt - The alternative value to use when the mapped value is `undefined` or `null`.
233
+ * @returns A new signal containing the mapped values.
234
+ */
235
+ readonly mapMaybe: <O>(fn: (value: T) => O | undefined | null, alt: O) => Computed<O>;
236
+ /**
237
+ * Feeds a property into the signal and sets up disposal behavior.
238
+ * @param prop - The property to feed into the signal.
239
+ * @param autoDisposeProp - Determines whether the property should be automatically disposed when the signal is disposed.
240
+ * @returns The input property.
241
+ */
39
242
  readonly feedProp: (prop: Prop<T>, autoDisposeProp?: boolean) => Prop<T>;
243
+ /**
244
+ * Derives a new property from the current signal.
245
+ * @param autoDisposeProp - Determines whether the derived property should be automatically disposed.
246
+ * @returns The derived property.
247
+ */
40
248
  readonly deriveProp: (autoDisposeProp?: boolean) => Prop<T>;
249
+ /**
250
+ * Returns a signal that emits the count of values received so far.
251
+ * @returns A signal that emits the count of values received so far.
252
+ */
41
253
  readonly count: () => Computed<number>;
42
- readonly setDerivative: <U>(computed: Computed<U>) => void;
254
+ /**
255
+ * Adds a computed value as a derivative of the signal.
256
+ * When the computed value is disposed, it is automatically removed from the derivatives list.
257
+ * Additionally, when the computed value is disposed, it sets the signal as dirty.
258
+ * @param computed - The computed value to add as a derivative.
259
+ */
260
+ readonly setDerivative: <O>(computed: Computed<O>) => void;
43
261
  }
262
+ /**
263
+ * Represents a computed signal that derives its value from a function.
264
+ * It extends the `Signal` class.
265
+ *
266
+ * @typeParam T - The type of the computed value.
267
+ * @public
268
+ */
44
269
  export declare class Computed<T> extends Signal<T> {
45
270
  private readonly _fn;
271
+ /**
272
+ * Checks if a value is an instance of `Computed`.
273
+ *
274
+ * @param value - The value to check.
275
+ * @returns `true` if the value is an instance of `Computed`, `false` otherwise.
276
+ */
46
277
  static is<T = unknown>(value: unknown): value is Computed<T>;
47
- protected readonly [$isComputed] = true;
278
+ /**
279
+ * @internal
280
+ */
281
+ protected readonly $__computed__ = true;
282
+ /**
283
+ * @internal
284
+ */
48
285
  protected _isDirty: boolean;
286
+ /**
287
+ * Represents a Signal object.
288
+ * @param _fn - The function that returns the value of the signal.
289
+ * @param equals - The function used to compare two values of type T for equality.
290
+ */
49
291
  constructor(_fn: () => T, equals: (a: T, b: T) => boolean);
292
+ /**
293
+ * Marks the signal as dirty, indicating that its value has changed and needs to be recalculated.
294
+ * If the signal is already dirty or disposed, this method does nothing.
295
+ * It also marks all dependent signals as dirty and schedules a notification to update their values.
296
+ */
50
297
  readonly setDirty: () => void;
298
+ /**
299
+ * @internal
300
+ */
51
301
  protected _scheduleCount: number;
52
- protected readonly scheduleNotify: () => void;
302
+ /**
303
+ * Schedules a notification to be executed asynchronously.
304
+ * If the signal is dirty, it will be updated and notified.
305
+ * @internal
306
+ */
307
+ protected readonly _scheduleNotify: () => void;
53
308
  /** {@inheritDoc Signal.get} */
54
309
  readonly get: () => T;
55
310
  /** {@inheritDoc Signal.value} */
56
311
  get value(): T;
57
312
  }
58
- export type ReducerEffect<S, A> = (data: {
313
+ /**
314
+ * Represents the data passed to a reducer effect.
315
+ *
316
+ * @typeParam S - The type of the state.
317
+ * @typeParam A - The type of the action.
318
+ * @public
319
+ */
320
+ export type ReducerEffectData<S, A> = {
321
+ /**
322
+ * The previous state before the action was dispatched.
323
+ */
59
324
  previousState: S;
325
+ /**
326
+ * The current state after the action was dispatched.
327
+ */
60
328
  state: S;
329
+ /**
330
+ * The action that was dispatched.
331
+ */
61
332
  action: A;
333
+ /**
334
+ * A function to dispatch a new action.
335
+ */
62
336
  dispatch: (action: A) => void;
63
- }) => void;
337
+ };
338
+ /**
339
+ * Represents a function that defines a reducer effect.
340
+ * A reducer effect is a function that takes in the previous state, current state, action, and a dispatch function,
341
+ * and performs some side effects based on the state and action.
342
+ *
343
+ * @typeParam S - The type of the state.
344
+ * @typeParam A - The type of the action.
345
+ *
346
+ * @param data - An object containing the previous state, current state, action, and dispatch function.
347
+ * @public
348
+ */
349
+ export type ReducerEffect<S, A> = (data: ReducerEffectData<S, A>) => void;
350
+ /**
351
+ * Represents a property signal that holds a value of type T.
352
+ * It extends the `Signal` class.
353
+ *
354
+ * @typeParam T - The type of the property value.
355
+ * @public
356
+ */
64
357
  export declare class Prop<T> extends Signal<T> {
65
- static is<T = unknown>(value: unknown): value is Prop<T>;
66
- protected readonly [$isProp] = true;
358
+ /**
359
+ * Checks if a value is a Prop.
360
+ * @param value - The value to check.
361
+ * @returns `true` if the value is a Prop, `false` otherwise.
362
+ */
363
+ static is: <T_1 = unknown>(value: unknown) => value is Prop<T_1>;
364
+ /**
365
+ * @internal
366
+ */
367
+ protected readonly $__prop__ = true;
368
+ /**
369
+ * Changes the value of the property and notifies its listeners.
370
+ *
371
+ * @param value - The new value of the property.
372
+ */
67
373
  readonly set: (value: T) => void;
374
+ /**
375
+ * Updates the value of the signal by applying the provided function to the current value.
376
+ * @param fn - The function to apply to the current value.
377
+ */
68
378
  readonly update: (fn: (value: T) => T) => void;
379
+ /**
380
+ * Creates a reducer function that combines the provided reducer function and effects.
381
+ * @param fn - The reducer function that takes the current state and an action, and returns the new state.
382
+ * @param effects - An array of effects to be executed after the state is updated.
383
+ * @returns A dispatch function that can be used to update the state and trigger the effects.
384
+ */
69
385
  readonly reducer: <A>(fn: (acc: T, value: A) => T, ...effects: ReducerEffect<T, A>[]) => (action: A) => void;
70
- readonly iso: <U>(to: (value: T) => U, from: (value: U) => T, equals?: (a: U, b: U) => boolean) => Prop<U>;
386
+ /**
387
+ * Creates an isomorphism for the Signal.
388
+ * An isomorphism is a pair of functions that convert values between two types,
389
+ * along with an equality function to compare values of the second type.
390
+ *
391
+ * @param to - A function that converts values from type T to type O.
392
+ * @param from - A function that converts values from type O to type T.
393
+ * @param equals - An optional function that compares values of type O for equality.
394
+ * Defaults to a strict equality check (===).
395
+ * @returns A Prop object representing the isomorphism.
396
+ */
397
+ readonly iso: <O>(to: (value: T) => O, from: (value: O) => T, equals?: (a: O, b: O) => boolean) => Prop<O>;
398
+ /**
399
+ * Returns a `Prop` that represents the value at the specified key of the current value.
400
+ *
401
+ * @param key - The key of the value to access.
402
+ * @returns A `Prop` that represents the value at the specified key.
403
+ */
71
404
  readonly atProp: <K extends keyof T>(key: K) => Prop<T[K]>;
72
- /** {@inheritDoc Signal.get} */
405
+ /**
406
+ * Access for the current value of the property.
407
+ */
73
408
  get value(): T;
74
409
  set value(value: T);
75
410
  }
76
- export declare function useComputed<T>(fn: () => T, dependencies: Array<AnySignal>, equals?: (a: T, b: T) => boolean): Computed<T>;
77
- export declare function useEffect(fn: () => void, signals: Array<AnySignal>): () => void;
78
- export declare function useProp<T>(value: T, equals?: (a: T, b: T) => boolean): Prop<T>;
79
- export declare function useSignal<T>(value: T, equals?: (a: T, b: T) => boolean): Signal<T>;
80
- export {};
411
+ /**
412
+ * Creates a computed signal that depends on other signals and updates when any of the dependencies change.
413
+ *
414
+ * @typeParam T - The type of the computed value.
415
+ * @param fn - The function that computes the value.
416
+ * @param dependencies - The array of signals that the computed value depends on.
417
+ * @param equals - The equality function used to compare the previous and current computed values.
418
+ * @returns - The computed signal.
419
+ * @public
420
+ */
421
+ export declare const makeComputed: <T>(fn: () => T, dependencies: Array<AnySignal>, equals?: (a: T, b: T) => boolean) => Computed<T>;
422
+ /**
423
+ * Executes the provided function `fn` whenever any of the signals in the `signals` array change.
424
+ * Returns a disposable object that can be used to stop the effect.
425
+ *
426
+ * @param fn - The function to execute when the signals change.
427
+ * @param signals - An array of signals to watch for changes.
428
+ * @returns A disposable object that can be used to stop the effect.
429
+ * @public
430
+ */
431
+ export declare const makeEffect: (fn: () => void, signals: Array<AnySignal>) => () => void;
432
+ /**
433
+ * Creates a new Prop object with the specified value and equality function.
434
+ *
435
+ * @typeParam T - The type of the value.
436
+ * @param value - The initial value of the Prop.
437
+ * @param equals - The equality function used to compare values. Defaults to strict equality (===).
438
+ * @returns A new Prop object.
439
+ * @public
440
+ */
441
+ export declare const makeProp: <T>(value: T, equals?: (a: T, b: T) => boolean) => Prop<T>;
442
+ /**
443
+ * Creates a signal with the specified initial value and equality function.
444
+ *
445
+ * @typeParam T - The type of the signal value.
446
+ * @param value - The initial value of the signal.
447
+ * @param equals - The equality function used to compare signal values. Defaults to a strict equality check (`===`).
448
+ * @returns A new Signal instance.
449
+ * @public
450
+ */
451
+ export declare const makeSignal: <T>(value: T, equals?: (a: T, b: T) => boolean) => Signal<T>;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Represents a collection of ARIA attributes and their corresponding types.
3
+ *
4
+ * @public
5
+ */
1
6
  export type AriaAttributes = {
2
7
  activedescendant: string;
3
8
  atomic: boolean;
@@ -1,2 +1,13 @@
1
+ /**
2
+ * Represents a set of properties or values that are excluded from the CSSStyleDeclaration interface.
3
+ *
4
+ * @public
5
+ */
1
6
  export type ExcludeFromStyle = 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty' | 'parentRule' | 'length' | 'name' | number;
7
+ /**
8
+ * Represents a subset of CSS styles.
9
+ * It is a type that excludes certain properties from the `CSSStyleDeclaration` type.
10
+ *
11
+ * @public
12
+ */
2
13
  export type CSSStyles = Omit<CSSStyleDeclaration, ExcludeFromStyle>;
package/types/domain.d.ts CHANGED
@@ -1,20 +1,80 @@
1
1
  import { DOMContext } from '../dom/dom-context';
2
2
  import { Signal } from '../std/signal';
3
3
 
4
+ /**
5
+ * Represents a function that can be rendered in the DOM.
6
+ * @param ctx - The DOM context for rendering.
7
+ * @returns A function that clears the rendered content.
8
+ * @public
9
+ */
4
10
  export type Renderable = (ctx: DOMContext) => Clear;
11
+ /**
12
+ * Represents a node in the rendering tree.
13
+ * It can be a renderable element, a string value, undefined, null, or an array of renderable elements.
14
+ * @public
15
+ */
5
16
  export type TNode = Renderable | Value<string> | undefined | null | Renderable[];
17
+ /**
18
+ * Represents a function that clears a resource.
19
+ * @param removeTree - A boolean value indicating whether to remove the tree associated with the resource.
20
+ * @public
21
+ */
6
22
  export type Clear = (removeTree: boolean) => void;
23
+ /**
24
+ * Represents a provider mark.
25
+ * @typeParam T - The type of the mark.
26
+ * @public
27
+ */
7
28
  export type ProviderMark<T> = symbol & {
8
29
  readonly __type: T;
9
30
  };
31
+ /**
32
+ * Represents a collection of providers.
33
+ * The keys of the record are ProviderMark types, and the values are of unknown type.
34
+ * @public
35
+ */
10
36
  export type Providers = Record<ProviderMark<unknown>, unknown>;
11
- export interface Size {
37
+ /**
38
+ * Represents the size of an object with width and height.
39
+ * @public
40
+ */
41
+ export type Size = {
42
+ /**
43
+ * The width of the object.
44
+ */
12
45
  readonly width: number;
46
+ /**
47
+ * The height of the object.
48
+ */
13
49
  readonly height: number;
14
- }
50
+ };
51
+ /**
52
+ * Represents a value that can either be a `Signal<T>` or a generic type `T`.
53
+ *
54
+ * @public
55
+ */
15
56
  export type Value<T> = Signal<T> | T;
57
+ /**
58
+ * Represents a nullable value or a signal of a nullable value.
59
+ * @typeParam T - The type of the value.
60
+ * @public
61
+ */
16
62
  export type NValue<T> = Value<T> | Value<T | null> | Value<T | undefined> | Value<T | null | undefined> | null | undefined;
63
+ /**
64
+ * Gets the value type of a given Value type.
65
+ * If the type is a `Signal`, it returns the inferred value type.
66
+ * Otherwise, it returns the type itself.
67
+ * @public
68
+ */
17
69
  export type GetValueType<T> = T extends Signal<infer V> ? V : T;
70
+ /**
71
+ * Removes signals from a given object type and returns a new object type
72
+ * with only the non-signal properties.
73
+ *
74
+ * @typeParam T - The input object type.
75
+ * @typeParam K - The keys of the input object type to keep (optional).
76
+ * @public
77
+ */
18
78
  export type RemoveSignals<T extends Record<string | number | symbol, Value<unknown>>, K extends (string | number | symbol) & keyof T = keyof T> = {
19
79
  [k in K]: GetValueType<T[k]>;
20
80
  };
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Represents the HTML attributes that can be used in an HTML element.
3
+ *
4
+ * @public
5
+ */
1
6
  export type HTMLAttributes = {
2
7
  accept: string;
3
8
  'accept-charset': string;
@@ -113,4 +118,9 @@ export type HTMLAttributes = {
113
118
  innerHTML: string;
114
119
  outerHTML: string;
115
120
  };
121
+ /**
122
+ * Represents the possible input types for HTML input elements.
123
+ *
124
+ * @public
125
+ */
116
126
  export type InputTypes = 'text' | 'number' | 'checkbox' | 'radio' | 'file' | 'password' | 'button' | 'submit' | 'reset' | 'date' | 'range' | 'color' | 'hidden' | 'image' | 'month' | 'time' | 'week' | 'email' | 'tel' | 'url' | 'search' | 'datetime-local';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Represents a mapping of HTML event names to their corresponding event types.
3
+ *
4
+ * @public
5
+ */
1
6
  export type HTMLEvents = {
2
7
  abort: Event;
3
8
  animationcancel: AnimationEvent;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Represents a mapping of HTML tag names to their corresponding element types.
3
+ *
4
+ * @public
5
+ */
1
6
  export type HTMLTags = {
2
7
  a: HTMLAnchorElement;
3
8
  abbr: HTMLElement;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Represents the attributes used in MathML elements.
3
+ *
4
+ * @public
5
+ */
1
6
  export type MathMLAttributes = {
2
7
  accent: string;
3
8
  accentunder: string;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Represents a collection of MathML tags.
3
+ * @public
4
+ */
1
5
  export type MathMLTags = {
2
6
  maction: MathMLElement;
3
7
  math: MathMLElement;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Represents the attributes that can be used in SVG elements.
3
+ *
4
+ * @public
5
+ */
1
6
  export type SVGAttributes = {
2
7
  accentHeight: number;
3
8
  accumulate: 'none' | 'sum';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Represents a mapping of SVG tag names to their corresponding SVG element types.
3
+ *
4
+ * @public
5
+ */
1
6
  export type SVGTags = {
2
7
  a: SVGAElement;
3
8
  animate: SVGAnimateElement;