eleva 1.0.0-rc.6 → 1.0.0-rc.9
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 +139 -10
- package/dist/eleva-plugins.cjs.js +675 -1
- package/dist/eleva-plugins.cjs.js.map +1 -1
- package/dist/eleva-plugins.esm.js +675 -2
- package/dist/eleva-plugins.esm.js.map +1 -1
- package/dist/eleva-plugins.umd.js +675 -1
- package/dist/eleva-plugins.umd.js.map +1 -1
- package/dist/eleva-plugins.umd.min.js +2 -2
- package/dist/eleva-plugins.umd.min.js.map +1 -1
- package/dist/eleva.cjs.js +39 -28
- package/dist/eleva.cjs.js.map +1 -1
- package/dist/eleva.d.ts +63 -2
- package/dist/eleva.esm.js +39 -28
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.umd.js +39 -28
- package/dist/eleva.umd.js.map +1 -1
- package/dist/eleva.umd.min.js +2 -2
- package/dist/eleva.umd.min.js.map +1 -1
- package/dist/plugins/store.umd.js +684 -0
- package/dist/plugins/store.umd.js.map +1 -0
- package/dist/plugins/store.umd.min.js +3 -0
- package/dist/plugins/store.umd.min.js.map +1 -0
- package/package.json +17 -16
- package/src/core/Eleva.js +42 -27
- package/src/plugins/Store.js +741 -0
- package/src/plugins/index.js +6 -1
- package/types/core/Eleva.d.ts +14 -2
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/plugins/Store.d.ts +86 -0
- package/types/plugins/Store.d.ts.map +1 -0
- package/types/plugins/index.d.ts +1 -0
package/src/plugins/index.js
CHANGED
|
@@ -22,14 +22,19 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* // Import multiple plugins
|
|
25
|
-
* import { Attr, Router } from 'eleva/plugins';
|
|
25
|
+
* import { Attr, Router, Store } from 'eleva/plugins';
|
|
26
26
|
*
|
|
27
27
|
* const app = new Eleva("myApp");
|
|
28
28
|
* app.use(Attr);
|
|
29
29
|
* app.use(Router);
|
|
30
|
+
* app.use(Store, {
|
|
31
|
+
* state: { counter: 0 },
|
|
32
|
+
* actions: { increment: (state) => state.counter.value++ }
|
|
33
|
+
* });
|
|
30
34
|
*/
|
|
31
35
|
|
|
32
36
|
// Export plugins with clean names
|
|
33
37
|
export { AttrPlugin as Attr } from "./Attr.js";
|
|
34
38
|
export { RouterPlugin as Router } from "./Router.js";
|
|
35
39
|
export { PropsPlugin as Props } from "./Props.js";
|
|
40
|
+
export { StorePlugin as Store } from "./Store.js";
|
package/types/core/Eleva.d.ts
CHANGED
|
@@ -121,14 +121,14 @@ export class Eleva {
|
|
|
121
121
|
public emitter: Emitter;
|
|
122
122
|
/** @public {typeof Signal} Static reference to the Signal class for creating reactive state */
|
|
123
123
|
public signal: typeof Signal;
|
|
124
|
+
/** @public {typeof TemplateEngine} Static reference to the TemplateEngine class for template parsing */
|
|
125
|
+
public templateEngine: typeof TemplateEngine;
|
|
124
126
|
/** @public {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
125
127
|
public renderer: Renderer;
|
|
126
128
|
/** @private {Map<string, ComponentDefinition>} Registry of all component definitions by name */
|
|
127
129
|
private _components;
|
|
128
130
|
/** @private {Map<string, ElevaPlugin>} Collection of installed plugin instances by name */
|
|
129
131
|
private _plugins;
|
|
130
|
-
/** @private {boolean} Flag indicating if the root component is currently mounted */
|
|
131
|
-
private _isMounted;
|
|
132
132
|
/** @private {number} Counter for generating unique component IDs */
|
|
133
133
|
private _componentCounter;
|
|
134
134
|
/**
|
|
@@ -136,12 +136,23 @@ export class Eleva {
|
|
|
136
136
|
* The plugin's install function will be called with the Eleva instance and provided options.
|
|
137
137
|
* After installation, the plugin will be available for use by components.
|
|
138
138
|
*
|
|
139
|
+
* Note: Plugins that wrap core methods (e.g., mount) must be uninstalled in reverse order
|
|
140
|
+
* of installation (LIFO - Last In, First Out) to avoid conflicts.
|
|
141
|
+
*
|
|
139
142
|
* @public
|
|
140
143
|
* @param {ElevaPlugin} plugin - The plugin object which must have an `install` function.
|
|
141
144
|
* @param {Object<string, unknown>} [options={}] - Optional configuration options for the plugin.
|
|
142
145
|
* @returns {Eleva} The Eleva instance (for method chaining).
|
|
143
146
|
* @example
|
|
144
147
|
* app.use(myPlugin, { option1: "value1" });
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* // Correct uninstall order (LIFO)
|
|
151
|
+
* app.use(PluginA);
|
|
152
|
+
* app.use(PluginB);
|
|
153
|
+
* // Uninstall in reverse order:
|
|
154
|
+
* PluginB.uninstall(app);
|
|
155
|
+
* PluginA.uninstall(app);
|
|
145
156
|
*/
|
|
146
157
|
public use(plugin: ElevaPlugin, options?: {
|
|
147
158
|
[x: string]: unknown;
|
|
@@ -350,5 +361,6 @@ export type ElevaPlugin = {
|
|
|
350
361
|
};
|
|
351
362
|
import { Emitter } from "../modules/Emitter.js";
|
|
352
363
|
import { Signal } from "../modules/Signal.js";
|
|
364
|
+
import { TemplateEngine } from "../modules/TemplateEngine.js";
|
|
353
365
|
import { Renderer } from "../modules/Renderer.js";
|
|
354
366
|
//# sourceMappingURL=Eleva.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Eleva.d.ts","sourceRoot":"","sources":["../../src/core/Eleva.js"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;GAQG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IACE;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAfW,MAAM,WACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAkCjC;IAnBC,0EAA0E;IAC1E,oBAAgB;IAChB,6FAA6F;IAC7F,uCAAoB;IACpB,oFAAoF;IACpF,wBAA4B;IAC5B,+FAA+F;IAC/F,6BAAoB;IACpB,wFAAwF;IACxF,0BAA8B;IAE9B,gGAAgG;IA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,CAAC,CAAC,CAAC;;;;cAEtF,CAAC,CAAS,IAAgB,EAAhB,gBAAgB,KAAG,MAAM,GAAC,OAAO,CAAC,MAAM,CAAC,CAAC;;;;6BAE1C,gBAAgB,KAAG,MAAM;;;;;;;;;;WAQnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;aAEvB,OAAO;;;;;;;;;4BAIE,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;;;;sBAEpC,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;;;;6BAEpC,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;;;;uBAEpC,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;;;;wBAEpC,kBAAkB,KAAG,OAAO,CAAC,IAAI,CAAC;;;;;;eAM3C,WAAW;;;;aAEX,gBAAgB;;;;;;eAMhB,WAAW;;;;aAEX,gBAAgB;;;;aAEhB;QACT,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;QAC5B,SAAS,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;QAC7B,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;KAC7B;;;;;;eAMU,WAAW;;;;UAEX,gBAAgB;;;;aAEhB,MAAY,OAAO,CAAC,IAAI,CAAC;;;;;;aAMzB,CAAS,IAAK,EAAL,KAAK,EAAE,IAAuB,EAAvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;;;;UAE9C,MAAM;;wBAvEI,uBAAuB;uBADxB,sBAAsB;+BADd,8BAA8B;yBAGpC,wBAAwB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export namespace StorePlugin {
|
|
2
|
+
let name: string;
|
|
3
|
+
let version: string;
|
|
4
|
+
let description: string;
|
|
5
|
+
/**
|
|
6
|
+
* Installs the plugin into the Eleva instance
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} eleva - The Eleva instance
|
|
9
|
+
* @param {Object} options - Plugin configuration options
|
|
10
|
+
* @param {Object} [options.state={}] - Initial state object
|
|
11
|
+
* @param {Object} [options.actions={}] - Action functions for state mutations
|
|
12
|
+
* @param {Object} [options.namespaces={}] - Namespaced modules for organizing store
|
|
13
|
+
* @param {Object} [options.persistence] - Persistence configuration
|
|
14
|
+
* @param {boolean} [options.persistence.enabled=false] - Enable state persistence
|
|
15
|
+
* @param {string} [options.persistence.key="eleva-store"] - Storage key
|
|
16
|
+
* @param {"localStorage" | "sessionStorage"} [options.persistence.storage="localStorage"] - Storage type
|
|
17
|
+
* @param {Array<string>} [options.persistence.include] - State keys to persist (if not provided, all state is persisted)
|
|
18
|
+
* @param {Array<string>} [options.persistence.exclude] - State keys to exclude from persistence
|
|
19
|
+
* @param {boolean} [options.devTools=false] - Enable development tools integration
|
|
20
|
+
* @param {Function} [options.onError=null] - Error handler function
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Basic installation
|
|
24
|
+
* app.use(StorePlugin, {
|
|
25
|
+
* state: { count: 0, user: null },
|
|
26
|
+
* actions: {
|
|
27
|
+
* increment: (state) => state.count.value++,
|
|
28
|
+
* setUser: (state, user) => state.user.value = user
|
|
29
|
+
* }
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Advanced installation with persistence and namespaces
|
|
33
|
+
* app.use(StorePlugin, {
|
|
34
|
+
* state: { theme: "light" },
|
|
35
|
+
* namespaces: {
|
|
36
|
+
* auth: {
|
|
37
|
+
* state: { user: null, token: null },
|
|
38
|
+
* actions: {
|
|
39
|
+
* login: (state, { user, token }) => {
|
|
40
|
+
* state.user.value = user;
|
|
41
|
+
* state.token.value = token;
|
|
42
|
+
* },
|
|
43
|
+
* logout: (state) => {
|
|
44
|
+
* state.user.value = null;
|
|
45
|
+
* state.token.value = null;
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* },
|
|
50
|
+
* persistence: {
|
|
51
|
+
* enabled: true,
|
|
52
|
+
* include: ["theme", "auth.user"]
|
|
53
|
+
* }
|
|
54
|
+
* });
|
|
55
|
+
*/
|
|
56
|
+
function install(eleva: Object, options?: {
|
|
57
|
+
state?: Object | undefined;
|
|
58
|
+
actions?: Object | undefined;
|
|
59
|
+
namespaces?: Object | undefined;
|
|
60
|
+
persistence?: {
|
|
61
|
+
enabled?: boolean | undefined;
|
|
62
|
+
key?: string | undefined;
|
|
63
|
+
storage?: "localStorage" | "sessionStorage" | undefined;
|
|
64
|
+
include?: string[] | undefined;
|
|
65
|
+
exclude?: string[] | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
devTools?: boolean | undefined;
|
|
68
|
+
onError?: Function | undefined;
|
|
69
|
+
}): void;
|
|
70
|
+
/**
|
|
71
|
+
* Uninstalls the plugin from the Eleva instance
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} eleva - The Eleva instance
|
|
74
|
+
*
|
|
75
|
+
* @description
|
|
76
|
+
* Restores the original Eleva methods and removes all plugin-specific
|
|
77
|
+
* functionality. This method should be called when the plugin is no
|
|
78
|
+
* longer needed.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // Uninstall the plugin
|
|
82
|
+
* StorePlugin.uninstall(app);
|
|
83
|
+
*/
|
|
84
|
+
function uninstall(eleva: Object): void;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=Store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Store.d.ts","sourceRoot":"","sources":["../../src/plugins/Store.js"],"names":[],"mappings":";cA4DY,MAAM;iBAMN,MAAM;qBAMN,MAAM;IAKhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkDG;IACH,wBAhDW,MAAM,YAEd;QAAyB,KAAK;QACL,OAAO;QACP,UAAU;QACV,WAAW;;;;;;;QAMV,QAAQ;QACP,OAAO;KAElC,QAwlBF;IAED;;;;;;;;;;;;;OAaG;IACH,0BAXW,MAAM,QAwChB"}
|
package/types/plugins/index.d.ts
CHANGED