spikijs 1.1.35 → 1.1.37

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 (2) hide show
  1. package/package.json +1 -1
  2. package/spiki.d.ts +8 -5
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "spikijs",
3
3
  "license": "MIT",
4
- "version": "1.1.35",
4
+ "version": "1.1.37",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
package/spiki.d.ts CHANGED
@@ -42,10 +42,6 @@ export interface SpikiInstance {
42
42
  */
43
43
  destroy?(): void;
44
44
 
45
- /**
46
- * Allows dynamic properties (e.g. variables from s-for).
47
- */
48
- [key: string]: any;
49
45
  }
50
46
 
51
47
  /**
@@ -55,12 +51,19 @@ export interface SpikiInstance {
55
51
  export type ComponentFactory<T> = () => T & ThisType<T & SpikiInstance>;
56
52
 
57
53
  export interface Spiki {
54
+ /**
55
+ * Registers a new component with a factory function.
56
+ * @param name Name matching 's-data' in HTML.
57
+ * @param factory Factory function returning state.
58
+ */
59
+ data<T>(name: string, factory: ComponentFactory<T>): void;
60
+
58
61
  /**
59
62
  * Registers a new component with one or more modules/factories.
60
63
  * @param name Name matching 's-data' in HTML.
61
64
  * @param modules Factory functions or objects returning/containing state.
62
65
  */
63
- data(name: string, ...modules: any[]): void;
66
+ data<T extends object>(name: string, ...modules: (ComponentFactory<any> | object)[]): void;
64
67
 
65
68
  /**
66
69
  * Scans the document and mounts all components.