eleva 1.0.1 → 1.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 (97) hide show
  1. package/README.md +21 -10
  2. package/dist/{eleva-plugins.cjs.js → eleva-plugins.cjs} +1002 -292
  3. package/dist/eleva-plugins.cjs.map +1 -0
  4. package/dist/eleva-plugins.d.cts +1352 -0
  5. package/dist/eleva-plugins.d.cts.map +1 -0
  6. package/dist/eleva-plugins.d.ts +1352 -0
  7. package/dist/eleva-plugins.d.ts.map +1 -0
  8. package/dist/{eleva-plugins.esm.js → eleva-plugins.js} +1002 -292
  9. package/dist/eleva-plugins.js.map +1 -0
  10. package/dist/eleva-plugins.umd.js +1001 -291
  11. package/dist/eleva-plugins.umd.js.map +1 -1
  12. package/dist/eleva-plugins.umd.min.js +1 -1
  13. package/dist/eleva-plugins.umd.min.js.map +1 -1
  14. package/dist/{eleva.cjs.js → eleva.cjs} +421 -191
  15. package/dist/eleva.cjs.map +1 -0
  16. package/dist/eleva.d.cts +1329 -0
  17. package/dist/eleva.d.cts.map +1 -0
  18. package/dist/eleva.d.ts +473 -226
  19. package/dist/eleva.d.ts.map +1 -0
  20. package/dist/{eleva.esm.js → eleva.js} +422 -192
  21. package/dist/eleva.js.map +1 -0
  22. package/dist/eleva.umd.js +420 -190
  23. package/dist/eleva.umd.js.map +1 -1
  24. package/dist/eleva.umd.min.js +1 -1
  25. package/dist/eleva.umd.min.js.map +1 -1
  26. package/dist/plugins/attr.cjs +279 -0
  27. package/dist/plugins/attr.cjs.map +1 -0
  28. package/dist/plugins/attr.d.cts +101 -0
  29. package/dist/plugins/attr.d.cts.map +1 -0
  30. package/dist/plugins/attr.d.ts +101 -0
  31. package/dist/plugins/attr.d.ts.map +1 -0
  32. package/dist/plugins/attr.js +276 -0
  33. package/dist/plugins/attr.js.map +1 -0
  34. package/dist/plugins/attr.umd.js +111 -22
  35. package/dist/plugins/attr.umd.js.map +1 -1
  36. package/dist/plugins/attr.umd.min.js +1 -1
  37. package/dist/plugins/attr.umd.min.js.map +1 -1
  38. package/dist/plugins/router.cjs +1873 -0
  39. package/dist/plugins/router.cjs.map +1 -0
  40. package/dist/plugins/router.d.cts +1296 -0
  41. package/dist/plugins/router.d.cts.map +1 -0
  42. package/dist/plugins/router.d.ts +1296 -0
  43. package/dist/plugins/router.d.ts.map +1 -0
  44. package/dist/plugins/router.js +1870 -0
  45. package/dist/plugins/router.js.map +1 -0
  46. package/dist/plugins/router.umd.js +482 -186
  47. package/dist/plugins/router.umd.js.map +1 -1
  48. package/dist/plugins/router.umd.min.js +1 -1
  49. package/dist/plugins/router.umd.min.js.map +1 -1
  50. package/dist/plugins/store.cjs +920 -0
  51. package/dist/plugins/store.cjs.map +1 -0
  52. package/dist/plugins/store.d.cts +266 -0
  53. package/dist/plugins/store.d.cts.map +1 -0
  54. package/dist/plugins/store.d.ts +266 -0
  55. package/dist/plugins/store.d.ts.map +1 -0
  56. package/dist/plugins/store.js +917 -0
  57. package/dist/plugins/store.js.map +1 -0
  58. package/dist/plugins/store.umd.js +410 -85
  59. package/dist/plugins/store.umd.js.map +1 -1
  60. package/dist/plugins/store.umd.min.js +1 -1
  61. package/dist/plugins/store.umd.min.js.map +1 -1
  62. package/package.json +112 -68
  63. package/src/core/Eleva.js +195 -115
  64. package/src/index.cjs +10 -0
  65. package/src/index.js +11 -0
  66. package/src/modules/Emitter.js +68 -20
  67. package/src/modules/Renderer.js +82 -20
  68. package/src/modules/Signal.js +43 -15
  69. package/src/modules/TemplateEngine.js +50 -9
  70. package/src/plugins/Attr.js +121 -19
  71. package/src/plugins/Router.js +526 -181
  72. package/src/plugins/Store.js +448 -69
  73. package/src/plugins/index.js +1 -0
  74. package/types/core/Eleva.d.ts +263 -169
  75. package/types/core/Eleva.d.ts.map +1 -1
  76. package/types/index.d.cts +3 -0
  77. package/types/index.d.cts.map +1 -0
  78. package/types/index.d.ts +5 -0
  79. package/types/index.d.ts.map +1 -1
  80. package/types/modules/Emitter.d.ts +73 -30
  81. package/types/modules/Emitter.d.ts.map +1 -1
  82. package/types/modules/Renderer.d.ts +48 -18
  83. package/types/modules/Renderer.d.ts.map +1 -1
  84. package/types/modules/Signal.d.ts +44 -16
  85. package/types/modules/Signal.d.ts.map +1 -1
  86. package/types/modules/TemplateEngine.d.ts +46 -11
  87. package/types/modules/TemplateEngine.d.ts.map +1 -1
  88. package/types/plugins/Attr.d.ts +83 -16
  89. package/types/plugins/Attr.d.ts.map +1 -1
  90. package/types/plugins/Router.d.ts +498 -207
  91. package/types/plugins/Router.d.ts.map +1 -1
  92. package/types/plugins/Store.d.ts +211 -37
  93. package/types/plugins/Store.d.ts.map +1 -1
  94. package/dist/eleva-plugins.cjs.js.map +0 -1
  95. package/dist/eleva-plugins.esm.js.map +0 -1
  96. package/dist/eleva.cjs.js.map +0 -1
  97. package/dist/eleva.esm.js.map +0 -1
@@ -0,0 +1,279 @@
1
+ /*! Eleva Attr Plugin v1.1.0 | MIT License | https://elevajs.com */
2
+ 'use strict';
3
+
4
+ /**
5
+ * @module eleva/plugins/attr
6
+ * @fileoverview Attribute plugin providing ARIA, data, boolean, and dynamic attribute handling.
7
+ */ // ============================================================================
8
+ // TYPE DEFINITIONS
9
+ // ============================================================================
10
+ // -----------------------------------------------------------------------------
11
+ // External Type Imports
12
+ // -----------------------------------------------------------------------------
13
+ /**
14
+ * Type imports from the Eleva core library.
15
+ * @typedef {import('eleva').Eleva} Eleva
16
+ */ // -----------------------------------------------------------------------------
17
+ // Attr Type Definitions
18
+ // -----------------------------------------------------------------------------
19
+ /**
20
+ * Configuration options for the AttrPlugin.
21
+ * @typedef {Object} AttrPluginOptions
22
+ * @property {boolean} [enableAria=true]
23
+ * Enable ARIA attribute handling.
24
+ * @property {boolean} [enableData=true]
25
+ * Enable data attribute handling.
26
+ * @property {boolean} [enableBoolean=true]
27
+ * Enable boolean attribute handling.
28
+ * @property {boolean} [enableDynamic=true]
29
+ * Enable dynamic property detection.
30
+ * @description Configuration options passed to AttrPlugin.install().
31
+ */ /**
32
+ * Function signature for attribute update operations.
33
+ * @typedef {(oldEl: HTMLElement, newEl: HTMLElement) => void} AttributeUpdateFunction
34
+ * @description Updates attributes on oldEl to match newEl's attributes.
35
+ */ /**
36
+ * A regular expression to match hyphenated lowercase letters.
37
+ * @private
38
+ * @type {RegExp}
39
+ */ const CAMEL_RE = /-([a-z])/g;
40
+ /**
41
+ * @class 🎯 AttrPlugin
42
+ * @classdesc A plugin that provides advanced attribute handling for Eleva components.
43
+ * This plugin extends the renderer with sophisticated attribute processing including:
44
+ * - ARIA attribute handling with proper property mapping
45
+ * - Data attribute management
46
+ * - Boolean attribute processing
47
+ * - Dynamic property detection and mapping
48
+ * - Attribute cleanup and removal
49
+ *
50
+ * @example
51
+ * // Install the plugin
52
+ * const app = new Eleva("myApp");
53
+ * app.use(AttrPlugin);
54
+ *
55
+ * // Use advanced attributes in components
56
+ * app.component("myComponent", {
57
+ * template: (ctx) => `
58
+ * <button
59
+ * aria-expanded="${ctx.isExpanded.value}"
60
+ * data-user-id="${ctx.userId.value}"
61
+ * disabled="${ctx.isLoading.value}"
62
+ * class="btn ${ctx.variant.value}"
63
+ * >
64
+ * ${ctx.text.value}
65
+ * </button>
66
+ * `
67
+ * });
68
+ */ const AttrPlugin = {
69
+ /**
70
+ * Unique identifier for the plugin
71
+ * @type {string}
72
+ */ name: "attr",
73
+ /**
74
+ * Plugin version
75
+ * @type {string}
76
+ */ version: "1.1.0",
77
+ /**
78
+ * Plugin description
79
+ * @type {string}
80
+ */ description: "Advanced attribute handling for Eleva components",
81
+ /**
82
+ * Installs the plugin into the Eleva instance.
83
+ *
84
+ * @public
85
+ * Method wrapping behavior:
86
+ * - Stores original `_patchNode` in `renderer._originalPatchNode`
87
+ * - Overrides `renderer._patchNode` to use enhanced attribute handling
88
+ * - Adds `renderer.updateAttributes` and `eleva.updateElementAttributes` helpers
89
+ * - Call `uninstall()` to restore original behavior
90
+ *
91
+ * @param {Eleva} eleva - The Eleva instance to enhance.
92
+ * @param {AttrPluginOptions} options - Plugin configuration options.
93
+ * @param {boolean} [options.enableAria=true] - Enable ARIA attribute handling.
94
+ * Maps aria-* attributes to DOM properties (e.g., aria-expanded → ariaExpanded).
95
+ * @param {boolean} [options.enableData=true] - Enable data attribute handling.
96
+ * Syncs data-* attributes with element.dataset for consistent access.
97
+ * @param {boolean} [options.enableBoolean=true] - Enable boolean attribute handling.
98
+ * Treats empty strings and attribute names as true, "false" string as false.
99
+ * @param {boolean} [options.enableDynamic=true] - Enable dynamic property detection.
100
+ * Searches element prototype chain for property matches (useful for custom elements).
101
+ * @returns {void}
102
+ * @example
103
+ * // Basic installation with defaults
104
+ * app.use(AttrPlugin);
105
+ *
106
+ * @example
107
+ * // Custom configuration
108
+ * app.use(AttrPlugin, {
109
+ * enableAria: true,
110
+ * enableData: true,
111
+ * enableBoolean: true,
112
+ * enableDynamic: false // Disable for performance
113
+ * });
114
+ *
115
+ * @example
116
+ * // Using ARIA attributes in templates
117
+ * template: (ctx) => `
118
+ * <div role="dialog" aria-modal="true" aria-labelledby="title">
119
+ * <h2 id="title">Modal Title</h2>
120
+ * <button aria-expanded="${ctx.isOpen.value}">Toggle</button>
121
+ * </div>
122
+ * `
123
+ * @see uninstall - Remove the plugin and restore original behavior.
124
+ */ install (eleva, options = {}) {
125
+ const { enableAria = true, enableData = true, enableBoolean = true, enableDynamic = true } = options;
126
+ /**
127
+ * Updates the attributes of an element to match a new element's attributes.
128
+ *
129
+ * Processing order:
130
+ * 1. Skip event attributes (@click, @input) - handled by Eleva's event system
131
+ * 2. Skip unchanged attributes - optimization
132
+ * 3. ARIA attributes (aria-*): Map to DOM properties (aria-expanded → ariaExpanded)
133
+ * 4. Data attributes (data-*): Update both dataset and attribute
134
+ * 5. Boolean attributes: Handle empty string as true, "false" as false
135
+ * 6. Other attributes: Map to properties with dynamic detection for custom elements
136
+ * 7. Remove old attributes not present in new element
137
+ *
138
+ * Dynamic property detection (when enableDynamic=true):
139
+ * - Checks if property exists directly on element
140
+ * - Searches element's prototype chain for case-insensitive matches
141
+ * - Enables compatibility with custom elements and Web Components
142
+ *
143
+ * @inner
144
+ * @param {HTMLElement} oldEl - The original element to update (modified in-place).
145
+ * @param {HTMLElement} newEl - The reference element with desired attributes.
146
+ * @returns {void}
147
+ */ const updateAttributes = (oldEl, newEl)=>{
148
+ const oldAttrs = oldEl.attributes;
149
+ const newAttrs = newEl.attributes;
150
+ // Process new attributes
151
+ for(let i = 0; i < newAttrs.length; i++){
152
+ const { name, value } = newAttrs[i];
153
+ // Skip event attributes (handled by event system)
154
+ if (name.startsWith("@")) continue;
155
+ // Skip if attribute hasn't changed
156
+ if (oldEl.getAttribute(name) === value) continue;
157
+ // Handle ARIA attributes
158
+ if (enableAria && name.startsWith("aria-")) {
159
+ const prop = "aria" + name.slice(5).replace(CAMEL_RE, (_, l)=>l.toUpperCase());
160
+ oldEl[prop] = value;
161
+ oldEl.setAttribute(name, value);
162
+ } else if (enableData && name.startsWith("data-")) {
163
+ oldEl.dataset[name.slice(5)] = value;
164
+ oldEl.setAttribute(name, value);
165
+ } else {
166
+ let prop = name.replace(CAMEL_RE, (_, l)=>l.toUpperCase());
167
+ // Dynamic property detection
168
+ if (enableDynamic && !(prop in oldEl) && !Object.getOwnPropertyDescriptor(Object.getPrototypeOf(oldEl), prop)) {
169
+ const elementProps = Object.getOwnPropertyNames(Object.getPrototypeOf(oldEl));
170
+ const matchingProp = elementProps.find((p)=>p.toLowerCase() === name.toLowerCase() || p.toLowerCase().includes(name.toLowerCase()) || name.toLowerCase().includes(p.toLowerCase()));
171
+ if (matchingProp) {
172
+ prop = matchingProp;
173
+ }
174
+ }
175
+ const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(oldEl), prop);
176
+ const hasProperty = prop in oldEl || descriptor;
177
+ if (hasProperty) {
178
+ // Boolean attribute handling
179
+ if (enableBoolean) {
180
+ const isBoolean = typeof oldEl[prop] === "boolean" || descriptor?.get && typeof descriptor.get.call(oldEl) === "boolean";
181
+ if (isBoolean) {
182
+ const boolValue = value !== "false" && (value === "" || value === prop || value === "true");
183
+ oldEl[prop] = boolValue;
184
+ if (boolValue) {
185
+ oldEl.setAttribute(name, "");
186
+ } else {
187
+ oldEl.removeAttribute(name);
188
+ }
189
+ } else {
190
+ oldEl[prop] = value;
191
+ oldEl.setAttribute(name, value);
192
+ }
193
+ } else {
194
+ oldEl[prop] = value;
195
+ oldEl.setAttribute(name, value);
196
+ }
197
+ } else {
198
+ oldEl.setAttribute(name, value);
199
+ }
200
+ }
201
+ }
202
+ // Remove old attributes that are no longer present
203
+ for(let i = oldAttrs.length - 1; i >= 0; i--){
204
+ const name = oldAttrs[i].name;
205
+ if (!newEl.hasAttribute(name)) {
206
+ oldEl.removeAttribute(name);
207
+ }
208
+ }
209
+ };
210
+ // Extend the renderer with the advanced attribute handler
211
+ if (eleva.renderer) {
212
+ eleva.renderer.updateAttributes = updateAttributes;
213
+ // Store the original _patchNode method
214
+ const originalPatchNode = eleva.renderer._patchNode;
215
+ eleva.renderer._originalPatchNode = originalPatchNode;
216
+ /**
217
+ * Overridden _patchNode method that uses enhanced attribute handling.
218
+ * Delegates to `updateAttributes` instead of the basic `_updateAttributes`.
219
+ *
220
+ * @param {Node} oldNode - The original DOM node to update.
221
+ * @param {Node} newNode - The new DOM node with desired state.
222
+ * @returns {void}
223
+ */ eleva.renderer._patchNode = function(oldNode, newNode) {
224
+ if (oldNode?._eleva_instance) return;
225
+ if (oldNode.nodeType === Node.TEXT_NODE) {
226
+ if (oldNode.nodeValue !== newNode.nodeValue) {
227
+ oldNode.nodeValue = newNode.nodeValue;
228
+ }
229
+ } else if (oldNode.nodeType === Node.ELEMENT_NODE) {
230
+ // Use advanced attribute handler instead of basic _updateAttributes
231
+ updateAttributes(oldNode, newNode);
232
+ this._diff(oldNode, newNode);
233
+ }
234
+ };
235
+ }
236
+ // Add plugin metadata to the Eleva instance
237
+ if (!eleva.plugins) {
238
+ eleva.plugins = new Map();
239
+ }
240
+ eleva.plugins.set(this.name, {
241
+ name: this.name,
242
+ version: this.version,
243
+ description: this.description,
244
+ options
245
+ });
246
+ // Add utility methods for manual attribute updates
247
+ /** @type {AttributeUpdateFunction} */ eleva.updateElementAttributes = updateAttributes;
248
+ },
249
+ /**
250
+ * Uninstalls the plugin from the Eleva instance.
251
+ *
252
+ * @public
253
+ * @param {Eleva} eleva - The Eleva instance.
254
+ * @returns {void}
255
+ * @description
256
+ * Restores the original renderer patching behavior and removes
257
+ * `eleva.updateElementAttributes`.
258
+ * @example
259
+ * // Uninstall the plugin
260
+ * AttrPlugin.uninstall(app);
261
+ * @see install - Install the plugin.
262
+ */ uninstall (eleva) {
263
+ // Restore original _patchNode method if it exists
264
+ if (eleva.renderer && eleva.renderer._originalPatchNode) {
265
+ eleva.renderer._patchNode = eleva.renderer._originalPatchNode;
266
+ delete eleva.renderer._originalPatchNode;
267
+ }
268
+ // Remove plugin metadata
269
+ if (eleva.plugins) {
270
+ eleva.plugins.delete(this.name);
271
+ }
272
+ // Remove utility methods
273
+ delete eleva.updateElementAttributes;
274
+ }
275
+ };
276
+
277
+ exports.Attr = AttrPlugin;
278
+ exports.AttrPlugin = AttrPlugin;
279
+ //# sourceMappingURL=attr.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attr.cjs","sources":["../../src/plugins/Attr.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @module eleva/plugins/attr\n * @fileoverview Attribute plugin providing ARIA, data, boolean, and dynamic attribute handling.\n */\n\n// ============================================================================\n// TYPE DEFINITIONS\n// ============================================================================\n\n// -----------------------------------------------------------------------------\n// External Type Imports\n// -----------------------------------------------------------------------------\n\n/**\n * Type imports from the Eleva core library.\n * @typedef {import('eleva').Eleva} Eleva\n */\n\n// -----------------------------------------------------------------------------\n// Attr Type Definitions\n// -----------------------------------------------------------------------------\n\n/**\n * Configuration options for the AttrPlugin.\n * @typedef {Object} AttrPluginOptions\n * @property {boolean} [enableAria=true]\n * Enable ARIA attribute handling.\n * @property {boolean} [enableData=true]\n * Enable data attribute handling.\n * @property {boolean} [enableBoolean=true]\n * Enable boolean attribute handling.\n * @property {boolean} [enableDynamic=true]\n * Enable dynamic property detection.\n * @description Configuration options passed to AttrPlugin.install().\n */\n\n/**\n * Function signature for attribute update operations.\n * @typedef {(oldEl: HTMLElement, newEl: HTMLElement) => void} AttributeUpdateFunction\n * @description Updates attributes on oldEl to match newEl's attributes.\n */\n\n/**\n * A regular expression to match hyphenated lowercase letters.\n * @private\n * @type {RegExp}\n */\nconst CAMEL_RE = /-([a-z])/g;\n\n/**\n * @class 🎯 AttrPlugin\n * @classdesc A plugin that provides advanced attribute handling for Eleva components.\n * This plugin extends the renderer with sophisticated attribute processing including:\n * - ARIA attribute handling with proper property mapping\n * - Data attribute management\n * - Boolean attribute processing\n * - Dynamic property detection and mapping\n * - Attribute cleanup and removal\n *\n * @example\n * // Install the plugin\n * const app = new Eleva(\"myApp\");\n * app.use(AttrPlugin);\n *\n * // Use advanced attributes in components\n * app.component(\"myComponent\", {\n * template: (ctx) => `\n * <button\n * aria-expanded=\"${ctx.isExpanded.value}\"\n * data-user-id=\"${ctx.userId.value}\"\n * disabled=\"${ctx.isLoading.value}\"\n * class=\"btn ${ctx.variant.value}\"\n * >\n * ${ctx.text.value}\n * </button>\n * `\n * });\n */\nexport const AttrPlugin = {\n /**\n * Unique identifier for the plugin\n * @type {string}\n */\n name: \"attr\",\n\n /**\n * Plugin version\n * @type {string}\n */\n version: \"1.1.0\",\n\n /**\n * Plugin description\n * @type {string}\n */\n description: \"Advanced attribute handling for Eleva components\",\n\n /**\n * Installs the plugin into the Eleva instance.\n *\n * @public\n * Method wrapping behavior:\n * - Stores original `_patchNode` in `renderer._originalPatchNode`\n * - Overrides `renderer._patchNode` to use enhanced attribute handling\n * - Adds `renderer.updateAttributes` and `eleva.updateElementAttributes` helpers\n * - Call `uninstall()` to restore original behavior\n *\n * @param {Eleva} eleva - The Eleva instance to enhance.\n * @param {AttrPluginOptions} options - Plugin configuration options.\n * @param {boolean} [options.enableAria=true] - Enable ARIA attribute handling.\n * Maps aria-* attributes to DOM properties (e.g., aria-expanded → ariaExpanded).\n * @param {boolean} [options.enableData=true] - Enable data attribute handling.\n * Syncs data-* attributes with element.dataset for consistent access.\n * @param {boolean} [options.enableBoolean=true] - Enable boolean attribute handling.\n * Treats empty strings and attribute names as true, \"false\" string as false.\n * @param {boolean} [options.enableDynamic=true] - Enable dynamic property detection.\n * Searches element prototype chain for property matches (useful for custom elements).\n * @returns {void}\n * @example\n * // Basic installation with defaults\n * app.use(AttrPlugin);\n *\n * @example\n * // Custom configuration\n * app.use(AttrPlugin, {\n * enableAria: true,\n * enableData: true,\n * enableBoolean: true,\n * enableDynamic: false // Disable for performance\n * });\n *\n * @example\n * // Using ARIA attributes in templates\n * template: (ctx) => `\n * <div role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"title\">\n * <h2 id=\"title\">Modal Title</h2>\n * <button aria-expanded=\"${ctx.isOpen.value}\">Toggle</button>\n * </div>\n * `\n * @see uninstall - Remove the plugin and restore original behavior.\n */\n install(eleva, options = {}) {\n const {\n enableAria = true,\n enableData = true,\n enableBoolean = true,\n enableDynamic = true,\n } = options;\n\n /**\n * Updates the attributes of an element to match a new element's attributes.\n *\n * Processing order:\n * 1. Skip event attributes (@click, @input) - handled by Eleva's event system\n * 2. Skip unchanged attributes - optimization\n * 3. ARIA attributes (aria-*): Map to DOM properties (aria-expanded → ariaExpanded)\n * 4. Data attributes (data-*): Update both dataset and attribute\n * 5. Boolean attributes: Handle empty string as true, \"false\" as false\n * 6. Other attributes: Map to properties with dynamic detection for custom elements\n * 7. Remove old attributes not present in new element\n *\n * Dynamic property detection (when enableDynamic=true):\n * - Checks if property exists directly on element\n * - Searches element's prototype chain for case-insensitive matches\n * - Enables compatibility with custom elements and Web Components\n *\n * @inner\n * @param {HTMLElement} oldEl - The original element to update (modified in-place).\n * @param {HTMLElement} newEl - The reference element with desired attributes.\n * @returns {void}\n */\n const updateAttributes = (oldEl, newEl) => {\n const oldAttrs = oldEl.attributes;\n const newAttrs = newEl.attributes;\n\n // Process new attributes\n for (let i = 0; i < newAttrs.length; i++) {\n const { name, value } = newAttrs[i];\n\n // Skip event attributes (handled by event system)\n if (name.startsWith(\"@\")) continue;\n\n // Skip if attribute hasn't changed\n if (oldEl.getAttribute(name) === value) continue;\n\n // Handle ARIA attributes\n if (enableAria && name.startsWith(\"aria-\")) {\n const prop =\n \"aria\" + name.slice(5).replace(CAMEL_RE, (_, l) => l.toUpperCase());\n oldEl[prop] = value;\n oldEl.setAttribute(name, value);\n }\n // Handle data attributes\n else if (enableData && name.startsWith(\"data-\")) {\n oldEl.dataset[name.slice(5)] = value;\n oldEl.setAttribute(name, value);\n }\n // Handle other attributes\n else {\n let prop = name.replace(CAMEL_RE, (_, l) => l.toUpperCase());\n\n // Dynamic property detection\n if (\n enableDynamic &&\n !(prop in oldEl) &&\n !Object.getOwnPropertyDescriptor(Object.getPrototypeOf(oldEl), prop)\n ) {\n const elementProps = Object.getOwnPropertyNames(\n Object.getPrototypeOf(oldEl)\n );\n const matchingProp = elementProps.find(\n (p) =>\n p.toLowerCase() === name.toLowerCase() ||\n p.toLowerCase().includes(name.toLowerCase()) ||\n name.toLowerCase().includes(p.toLowerCase())\n );\n\n if (matchingProp) {\n prop = matchingProp;\n }\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(oldEl),\n prop\n );\n const hasProperty = prop in oldEl || descriptor;\n\n if (hasProperty) {\n // Boolean attribute handling\n if (enableBoolean) {\n const isBoolean =\n typeof oldEl[prop] === \"boolean\" ||\n (descriptor?.get &&\n typeof descriptor.get.call(oldEl) === \"boolean\");\n\n if (isBoolean) {\n const boolValue =\n value !== \"false\" &&\n (value === \"\" || value === prop || value === \"true\");\n oldEl[prop] = boolValue;\n\n if (boolValue) {\n oldEl.setAttribute(name, \"\");\n } else {\n oldEl.removeAttribute(name);\n }\n } else {\n oldEl[prop] = value;\n oldEl.setAttribute(name, value);\n }\n } else {\n oldEl[prop] = value;\n oldEl.setAttribute(name, value);\n }\n } else {\n oldEl.setAttribute(name, value);\n }\n }\n }\n\n // Remove old attributes that are no longer present\n for (let i = oldAttrs.length - 1; i >= 0; i--) {\n const name = oldAttrs[i].name;\n if (!newEl.hasAttribute(name)) {\n oldEl.removeAttribute(name);\n }\n }\n };\n\n // Extend the renderer with the advanced attribute handler\n if (eleva.renderer) {\n eleva.renderer.updateAttributes = updateAttributes;\n\n // Store the original _patchNode method\n const originalPatchNode = eleva.renderer._patchNode;\n eleva.renderer._originalPatchNode = originalPatchNode;\n\n /**\n * Overridden _patchNode method that uses enhanced attribute handling.\n * Delegates to `updateAttributes` instead of the basic `_updateAttributes`.\n *\n * @param {Node} oldNode - The original DOM node to update.\n * @param {Node} newNode - The new DOM node with desired state.\n * @returns {void}\n */\n eleva.renderer._patchNode = function (oldNode, newNode) {\n if (oldNode?._eleva_instance) return;\n\n if (oldNode.nodeType === Node.TEXT_NODE) {\n if (oldNode.nodeValue !== newNode.nodeValue) {\n oldNode.nodeValue = newNode.nodeValue;\n }\n } else if (oldNode.nodeType === Node.ELEMENT_NODE) {\n // Use advanced attribute handler instead of basic _updateAttributes\n updateAttributes(oldNode, newNode);\n this._diff(oldNode, newNode);\n }\n };\n }\n\n // Add plugin metadata to the Eleva instance\n if (!eleva.plugins) {\n eleva.plugins = new Map();\n }\n eleva.plugins.set(this.name, {\n name: this.name,\n version: this.version,\n description: this.description,\n options,\n });\n\n // Add utility methods for manual attribute updates\n /** @type {AttributeUpdateFunction} */\n eleva.updateElementAttributes = updateAttributes;\n },\n\n /**\n * Uninstalls the plugin from the Eleva instance.\n *\n * @public\n * @param {Eleva} eleva - The Eleva instance.\n * @returns {void}\n * @description\n * Restores the original renderer patching behavior and removes\n * `eleva.updateElementAttributes`.\n * @example\n * // Uninstall the plugin\n * AttrPlugin.uninstall(app);\n * @see install - Install the plugin.\n */\n uninstall(eleva) {\n // Restore original _patchNode method if it exists\n if (eleva.renderer && eleva.renderer._originalPatchNode) {\n eleva.renderer._patchNode = eleva.renderer._originalPatchNode;\n delete eleva.renderer._originalPatchNode;\n }\n\n // Remove plugin metadata\n if (eleva.plugins) {\n eleva.plugins.delete(this.name);\n }\n\n // Remove utility methods\n delete eleva.updateElementAttributes;\n },\n};\n\n// Short name export for convenience\nexport { AttrPlugin as Attr };\n"],"names":["CAMEL_RE","AttrPlugin","name","version","description","install","eleva","options","enableAria","enableData","enableBoolean","enableDynamic","updateAttributes","oldEl","newEl","oldAttrs","attributes","newAttrs","i","length","value","startsWith","getAttribute","prop","slice","replace","_","l","toUpperCase","setAttribute","dataset","Object","getOwnPropertyDescriptor","getPrototypeOf","elementProps","getOwnPropertyNames","matchingProp","find","p","toLowerCase","includes","descriptor","hasProperty","isBoolean","get","call","boolValue","removeAttribute","hasAttribute","renderer","originalPatchNode","_patchNode","_originalPatchNode","oldNode","newNode","_eleva_instance","nodeType","Node","TEXT_NODE","nodeValue","ELEMENT_NODE","_diff","plugins","Map","set","updateElementAttributes","uninstall","delete"],"mappings":";;;AAEA;;;AAGC;AAGD;AACA;AAEA;AACA;AACA;AAEA;;;AAGC;AAGD;AACA;AAEA;;;;;;;;;;;;;;;;;;;;AAwBC,IACD,MAAMA,QAAAA,GAAW,WAAA;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6BaC,UAAAA,GAAa;AACxB;;;AAGC,MACDC,IAAAA,EAAM,MAAA;AAEN;;;AAGC,MACDC,OAAAA,EAAS,OAAA;AAET;;;AAGC,MACDC,WAAAA,EAAa,kDAAA;AAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CC,MACDC,OAAAA,CAAAA,CAAQC,KAAK,EAAEC,OAAAA,GAAU,EAAE,EAAA;AACzB,QAAA,MAAM,EACJC,UAAAA,GAAa,IAAI,EACjBC,UAAAA,GAAa,IAAI,EACjBC,aAAAA,GAAgB,IAAI,EACpBC,aAA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AA;;AAEb,QAAA,IAAIA,MAAM2C,QAAQ,IAAI3C,MAAM2C,QAAQ,CAACG,kBAAkB,EAAE;AACvD9C,YAAAA,KAAAA,CAAM2C,QAAQ,CAACE,UAAU,GAAG7C,KAAAA,CAAM2C,QAAQ,CAACG,kBAAkB;YAC7D,OAAO9C,KAAAA,CAAM2C,QAAQ,CAACG,kBAAkB;AAC1C,QAAA;;QAGA,IAAI9C,KAAAA,CAAMwD,OAAO,EAAE;AACjBxD,YAAAA,KAAAA,CAAMwD,OAAO,CAACK,MAAM,CAAC,IAAI,CAACjE,IAAI,CAAA;AAChC,QAAA;;AAGA,QAAA,OAAOI,MAAM2D,uBAAuB;AACtC,IAAA;AACF;;;;;"}
@@ -0,0 +1,101 @@
1
+ import * as eleva from 'eleva';
2
+
3
+ declare namespace AttrPlugin {
4
+ let name: string;
5
+ let version: string;
6
+ let description: string;
7
+ /**
8
+ * Installs the plugin into the Eleva instance.
9
+ *
10
+ * @public
11
+ * Method wrapping behavior:
12
+ * - Stores original `_patchNode` in `renderer._originalPatchNode`
13
+ * - Overrides `renderer._patchNode` to use enhanced attribute handling
14
+ * - Adds `renderer.updateAttributes` and `eleva.updateElementAttributes` helpers
15
+ * - Call `uninstall()` to restore original behavior
16
+ *
17
+ * @param {Eleva} eleva - The Eleva instance to enhance.
18
+ * @param {AttrPluginOptions} options - Plugin configuration options.
19
+ * @param {boolean} [options.enableAria=true] - Enable ARIA attribute handling.
20
+ * Maps aria-* attributes to DOM properties (e.g., aria-expanded → ariaExpanded).
21
+ * @param {boolean} [options.enableData=true] - Enable data attribute handling.
22
+ * Syncs data-* attributes with element.dataset for consistent access.
23
+ * @param {boolean} [options.enableBoolean=true] - Enable boolean attribute handling.
24
+ * Treats empty strings and attribute names as true, "false" string as false.
25
+ * @param {boolean} [options.enableDynamic=true] - Enable dynamic property detection.
26
+ * Searches element prototype chain for property matches (useful for custom elements).
27
+ * @returns {void}
28
+ * @example
29
+ * // Basic installation with defaults
30
+ * app.use(AttrPlugin);
31
+ *
32
+ * @example
33
+ * // Custom configuration
34
+ * app.use(AttrPlugin, {
35
+ * enableAria: true,
36
+ * enableData: true,
37
+ * enableBoolean: true,
38
+ * enableDynamic: false // Disable for performance
39
+ * });
40
+ *
41
+ * @example
42
+ * // Using ARIA attributes in templates
43
+ * template: (ctx) => `
44
+ * <div role="dialog" aria-modal="true" aria-labelledby="title">
45
+ * <h2 id="title">Modal Title</h2>
46
+ * <button aria-expanded="${ctx.isOpen.value}">Toggle</button>
47
+ * </div>
48
+ * `
49
+ * @see uninstall - Remove the plugin and restore original behavior.
50
+ */
51
+ function install(eleva: Eleva, options?: AttrPluginOptions): void;
52
+ /**
53
+ * Uninstalls the plugin from the Eleva instance.
54
+ *
55
+ * @public
56
+ * @param {Eleva} eleva - The Eleva instance.
57
+ * @returns {void}
58
+ * @description
59
+ * Restores the original renderer patching behavior and removes
60
+ * `eleva.updateElementAttributes`.
61
+ * @example
62
+ * // Uninstall the plugin
63
+ * AttrPlugin.uninstall(app);
64
+ * @see install - Install the plugin.
65
+ */
66
+ function uninstall(eleva: Eleva): void;
67
+ }
68
+
69
+ /**
70
+ * Type imports from the Eleva core library.
71
+ */
72
+ type Eleva = eleva.Eleva;
73
+ /**
74
+ * Configuration options for the AttrPlugin.
75
+ */
76
+ type AttrPluginOptions = {
77
+ /**
78
+ * Enable ARIA attribute handling.
79
+ */
80
+ enableAria?: boolean | undefined;
81
+ /**
82
+ * Enable data attribute handling.
83
+ */
84
+ enableData?: boolean | undefined;
85
+ /**
86
+ * Enable boolean attribute handling.
87
+ */
88
+ enableBoolean?: boolean | undefined;
89
+ /**
90
+ * Enable dynamic property detection.
91
+ */
92
+ enableDynamic?: boolean | undefined;
93
+ };
94
+ /**
95
+ * Function signature for attribute update operations.
96
+ */
97
+ type AttributeUpdateFunction = (oldEl: HTMLElement, newEl: HTMLElement) => void;
98
+
99
+ export { AttrPlugin as Attr, AttrPlugin };
100
+ export type { AttrPluginOptions, AttributeUpdateFunction, Eleva };
101
+ //# sourceMappingURL=attr.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attr.d.cts","sources":["../../types/plugins/Attr.d.ts"],"sourcesContent":["export namespace AttrPlugin {\n let name: string;\n let version: string;\n let description: string;\n /**\n * Installs the plugin into the Eleva instance.\n *\n * @public\n * Method wrapping behavior:\n * - Stores original `_patchNode` in `renderer._originalPatchNode`\n * - Overrides `renderer._patchNode` to use enhanced attribute handling\n * - Adds `renderer.updateAttributes` and `eleva.updateElementAttributes` helpers\n * - Call `uninstall()` to restore original behavior\n *\n * @param {Eleva} eleva - The Eleva instance to enhance.\n * @param {AttrPluginOptions} options - Plugin configuration options.\n * @param {boolean} [options.enableAria=true] - Enable ARIA attribute handling.\n * Maps aria-* attributes to DOM properties (e.g., aria-expanded → ariaExpanded).\n * @param {boolean} [options.enableData=true] - Enable data attribute handling.\n * Syncs data-* attributes with element.dataset for consistent access.\n * @param {boolean} [options.enableBoolean=true] - Enable boolean attribute handling.\n * Treats empty strings and attribute names as true, \"false\" string as false.\n * @param {boolean} [options.enableDynamic=true] - Enable dynamic property detection.\n * Searches element prototype chain for property matches (useful for custom elements).\n * @returns {void}\n * @example\n * // Basic installation with defaults\n * app.use(AttrPlugin);\n *\n * @example\n * // Custom configuration\n * app.use(AttrPlugin, {\n * enableAria: true,\n * enableData: true,\n * enableBoolean: true,\n * enableDynamic: false // Disable for performance\n * });\n *\n * @example\n * // Using ARIA attributes in templates\n * template: (ctx) => `\n * <div role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"title\">\n * <h2 id=\"title\">Modal Title</h2>\n * <button aria-expanded=\"${ctx.isOpen.value}\">Toggle</button>\n * </div>\n * `\n * @see uninstall - Remove the plugin and restore original behavior.\n */\n function install(eleva: Eleva, options?: AttrPluginOptions): void;\n /**\n * Uninstalls the plugin from the Eleva instance.\n *\n * @public\n * @param {Eleva} eleva - The Eleva instance.\n * @returns {void}\n * @description\n * Restores the original renderer patching behavior and removes\n * `eleva.updateElementAttributes`.\n * @example\n * // Uninstall the plugin\n * AttrPlugin.uninstall(app);\n * @see install - Install the plugin.\n */\n function uninstall(eleva: Eleva): void;\n}\nexport { AttrPlugin as Attr };\n/**\n * Type imports from the Eleva core library.\n */\nexport type Eleva = import(\"eleva\").Eleva;\n/**\n * Configuration options for the AttrPlugin.\n */\nexport type AttrPluginOptions = {\n /**\n * Enable ARIA attribute handling.\n */\n enableAria?: boolean | undefined;\n /**\n * Enable data attribute handling.\n */\n enableData?: boolean | undefined;\n /**\n * Enable boolean attribute handling.\n */\n enableBoolean?: boolean | undefined;\n /**\n * Enable dynamic property detection.\n */\n enableDynamic?: boolean | undefined;\n};\n/**\n * Function signature for attribute update operations.\n */\nexport type AttributeUpdateFunction = (oldEl: HTMLElement, newEl: HTMLElement) => void;\n//# sourceMappingURL=Attr.d.ts.map"],"names":[],"mappings":";;AAAO,kBAAA,UAAA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAAA,KAAA,YAAA,iBAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAAA,KAAA;AACA;;AAEA;AACA;AACA;AACO,KAAA,KAAA,GAAa,KAAe,CAAA,KAAA;AACnC;AACA;AACA;AACO,KAAA,iBAAA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,KAAA,uBAAA,WAAA,WAAA,SAAA,WAAA;;;;"}
@@ -0,0 +1,101 @@
1
+ import * as eleva from 'eleva';
2
+
3
+ declare namespace AttrPlugin {
4
+ let name: string;
5
+ let version: string;
6
+ let description: string;
7
+ /**
8
+ * Installs the plugin into the Eleva instance.
9
+ *
10
+ * @public
11
+ * Method wrapping behavior:
12
+ * - Stores original `_patchNode` in `renderer._originalPatchNode`
13
+ * - Overrides `renderer._patchNode` to use enhanced attribute handling
14
+ * - Adds `renderer.updateAttributes` and `eleva.updateElementAttributes` helpers
15
+ * - Call `uninstall()` to restore original behavior
16
+ *
17
+ * @param {Eleva} eleva - The Eleva instance to enhance.
18
+ * @param {AttrPluginOptions} options - Plugin configuration options.
19
+ * @param {boolean} [options.enableAria=true] - Enable ARIA attribute handling.
20
+ * Maps aria-* attributes to DOM properties (e.g., aria-expanded → ariaExpanded).
21
+ * @param {boolean} [options.enableData=true] - Enable data attribute handling.
22
+ * Syncs data-* attributes with element.dataset for consistent access.
23
+ * @param {boolean} [options.enableBoolean=true] - Enable boolean attribute handling.
24
+ * Treats empty strings and attribute names as true, "false" string as false.
25
+ * @param {boolean} [options.enableDynamic=true] - Enable dynamic property detection.
26
+ * Searches element prototype chain for property matches (useful for custom elements).
27
+ * @returns {void}
28
+ * @example
29
+ * // Basic installation with defaults
30
+ * app.use(AttrPlugin);
31
+ *
32
+ * @example
33
+ * // Custom configuration
34
+ * app.use(AttrPlugin, {
35
+ * enableAria: true,
36
+ * enableData: true,
37
+ * enableBoolean: true,
38
+ * enableDynamic: false // Disable for performance
39
+ * });
40
+ *
41
+ * @example
42
+ * // Using ARIA attributes in templates
43
+ * template: (ctx) => `
44
+ * <div role="dialog" aria-modal="true" aria-labelledby="title">
45
+ * <h2 id="title">Modal Title</h2>
46
+ * <button aria-expanded="${ctx.isOpen.value}">Toggle</button>
47
+ * </div>
48
+ * `
49
+ * @see uninstall - Remove the plugin and restore original behavior.
50
+ */
51
+ function install(eleva: Eleva, options?: AttrPluginOptions): void;
52
+ /**
53
+ * Uninstalls the plugin from the Eleva instance.
54
+ *
55
+ * @public
56
+ * @param {Eleva} eleva - The Eleva instance.
57
+ * @returns {void}
58
+ * @description
59
+ * Restores the original renderer patching behavior and removes
60
+ * `eleva.updateElementAttributes`.
61
+ * @example
62
+ * // Uninstall the plugin
63
+ * AttrPlugin.uninstall(app);
64
+ * @see install - Install the plugin.
65
+ */
66
+ function uninstall(eleva: Eleva): void;
67
+ }
68
+
69
+ /**
70
+ * Type imports from the Eleva core library.
71
+ */
72
+ type Eleva = eleva.Eleva;
73
+ /**
74
+ * Configuration options for the AttrPlugin.
75
+ */
76
+ type AttrPluginOptions = {
77
+ /**
78
+ * Enable ARIA attribute handling.
79
+ */
80
+ enableAria?: boolean | undefined;
81
+ /**
82
+ * Enable data attribute handling.
83
+ */
84
+ enableData?: boolean | undefined;
85
+ /**
86
+ * Enable boolean attribute handling.
87
+ */
88
+ enableBoolean?: boolean | undefined;
89
+ /**
90
+ * Enable dynamic property detection.
91
+ */
92
+ enableDynamic?: boolean | undefined;
93
+ };
94
+ /**
95
+ * Function signature for attribute update operations.
96
+ */
97
+ type AttributeUpdateFunction = (oldEl: HTMLElement, newEl: HTMLElement) => void;
98
+
99
+ export { AttrPlugin as Attr, AttrPlugin };
100
+ export type { AttrPluginOptions, AttributeUpdateFunction, Eleva };
101
+ //# sourceMappingURL=attr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attr.d.ts","sources":["../../types/plugins/Attr.d.ts"],"sourcesContent":["export namespace AttrPlugin {\n let name: string;\n let version: string;\n let description: string;\n /**\n * Installs the plugin into the Eleva instance.\n *\n * @public\n * Method wrapping behavior:\n * - Stores original `_patchNode` in `renderer._originalPatchNode`\n * - Overrides `renderer._patchNode` to use enhanced attribute handling\n * - Adds `renderer.updateAttributes` and `eleva.updateElementAttributes` helpers\n * - Call `uninstall()` to restore original behavior\n *\n * @param {Eleva} eleva - The Eleva instance to enhance.\n * @param {AttrPluginOptions} options - Plugin configuration options.\n * @param {boolean} [options.enableAria=true] - Enable ARIA attribute handling.\n * Maps aria-* attributes to DOM properties (e.g., aria-expanded → ariaExpanded).\n * @param {boolean} [options.enableData=true] - Enable data attribute handling.\n * Syncs data-* attributes with element.dataset for consistent access.\n * @param {boolean} [options.enableBoolean=true] - Enable boolean attribute handling.\n * Treats empty strings and attribute names as true, \"false\" string as false.\n * @param {boolean} [options.enableDynamic=true] - Enable dynamic property detection.\n * Searches element prototype chain for property matches (useful for custom elements).\n * @returns {void}\n * @example\n * // Basic installation with defaults\n * app.use(AttrPlugin);\n *\n * @example\n * // Custom configuration\n * app.use(AttrPlugin, {\n * enableAria: true,\n * enableData: true,\n * enableBoolean: true,\n * enableDynamic: false // Disable for performance\n * });\n *\n * @example\n * // Using ARIA attributes in templates\n * template: (ctx) => `\n * <div role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"title\">\n * <h2 id=\"title\">Modal Title</h2>\n * <button aria-expanded=\"${ctx.isOpen.value}\">Toggle</button>\n * </div>\n * `\n * @see uninstall - Remove the plugin and restore original behavior.\n */\n function install(eleva: Eleva, options?: AttrPluginOptions): void;\n /**\n * Uninstalls the plugin from the Eleva instance.\n *\n * @public\n * @param {Eleva} eleva - The Eleva instance.\n * @returns {void}\n * @description\n * Restores the original renderer patching behavior and removes\n * `eleva.updateElementAttributes`.\n * @example\n * // Uninstall the plugin\n * AttrPlugin.uninstall(app);\n * @see install - Install the plugin.\n */\n function uninstall(eleva: Eleva): void;\n}\nexport { AttrPlugin as Attr };\n/**\n * Type imports from the Eleva core library.\n */\nexport type Eleva = import(\"eleva\").Eleva;\n/**\n * Configuration options for the AttrPlugin.\n */\nexport type AttrPluginOptions = {\n /**\n * Enable ARIA attribute handling.\n */\n enableAria?: boolean | undefined;\n /**\n * Enable data attribute handling.\n */\n enableData?: boolean | undefined;\n /**\n * Enable boolean attribute handling.\n */\n enableBoolean?: boolean | undefined;\n /**\n * Enable dynamic property detection.\n */\n enableDynamic?: boolean | undefined;\n};\n/**\n * Function signature for attribute update operations.\n */\nexport type AttributeUpdateFunction = (oldEl: HTMLElement, newEl: HTMLElement) => void;\n//# sourceMappingURL=Attr.d.ts.map"],"names":[],"mappings":";;AAAO,kBAAA,UAAA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAAA,KAAA,YAAA,iBAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAAA,KAAA;AACA;;AAEA;AACA;AACA;AACO,KAAA,KAAA,GAAa,KAAe,CAAA,KAAA;AACnC;AACA;AACA;AACO,KAAA,iBAAA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,KAAA,uBAAA,WAAA,WAAA,SAAA,WAAA;;;;"}