spikijs 1.1.35 → 1.1.36
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/package.json +1 -1
- package/spiki.d.ts +9 -2
package/package.json
CHANGED
package/spiki.d.ts
CHANGED
|
@@ -52,15 +52,22 @@ export interface SpikiInstance {
|
|
|
52
52
|
* Helper type for the data factory function.
|
|
53
53
|
* Ensures 'this' includes your data + Spiki internals.
|
|
54
54
|
*/
|
|
55
|
-
export type ComponentFactory<T
|
|
55
|
+
export type ComponentFactory<T extends object = Record<string, any>> = (this: T & SpikiInstance) => T & ThisType<T & SpikiInstance>;
|
|
56
56
|
|
|
57
57
|
export interface Spiki {
|
|
58
58
|
/**
|
|
59
59
|
* Registers a new component with one or more modules/factories.
|
|
60
60
|
* @param name Name matching 's-data' in HTML.
|
|
61
|
+
* @param factory Factory function returning state.
|
|
62
|
+
*/
|
|
63
|
+
data<T extends object>(name: string, factory: ComponentFactory<T>): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Registers a new component with multiple modules/factories.
|
|
67
|
+
* @param name Name matching 's-data' in HTML.
|
|
61
68
|
* @param modules Factory functions or objects returning/containing state.
|
|
62
69
|
*/
|
|
63
|
-
data(name: string, ...modules: any[]): void;
|
|
70
|
+
data<T extends object>(name: string, ...modules: (ComponentFactory<any> | object)[]): void;
|
|
64
71
|
|
|
65
72
|
/**
|
|
66
73
|
* Scans the document and mounts all components.
|