frontend-hamroun 1.2.85 → 1.2.89

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 (96) hide show
  1. package/dist/batch.d.ts +4 -0
  2. package/dist/batch.d.ts.map +1 -0
  3. package/dist/batch.js +22 -0
  4. package/dist/client-router.d.ts +61 -0
  5. package/dist/client-router.d.ts.map +1 -0
  6. package/dist/client-router.js +209 -0
  7. package/dist/component.d.ts +15 -0
  8. package/dist/component.d.ts.map +1 -0
  9. package/dist/component.js +84 -0
  10. package/dist/components/Counter.d.ts +1 -0
  11. package/dist/components/Counter.d.ts.map +1 -0
  12. package/dist/components/Counter.js +2 -0
  13. package/dist/context.d.ts +5 -0
  14. package/dist/context.d.ts.map +1 -0
  15. package/dist/context.js +23 -0
  16. package/dist/event-bus.d.ts +24 -0
  17. package/dist/event-bus.d.ts.map +1 -0
  18. package/dist/event-bus.js +74 -0
  19. package/dist/forms.d.ts +41 -0
  20. package/dist/forms.d.ts.map +1 -0
  21. package/dist/forms.js +147 -0
  22. package/dist/hooks.d.ts +12 -0
  23. package/dist/hooks.d.ts.map +1 -0
  24. package/dist/hooks.js +142 -0
  25. package/dist/index.cjs +1231 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.client.d.ts +13 -0
  28. package/dist/index.client.d.ts.map +1 -0
  29. package/dist/index.client.js +12 -25
  30. package/dist/index.d.ts +68 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +1153 -265
  33. package/dist/index.js.map +1 -1
  34. package/dist/jsx-dev-runtime.cjs +102 -0
  35. package/dist/jsx-dev-runtime.cjs.map +1 -0
  36. package/dist/jsx-dev-runtime.d.ts +3 -0
  37. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  38. package/dist/jsx-dev-runtime.js +96 -0
  39. package/dist/jsx-dev-runtime.js.map +1 -0
  40. package/dist/jsx-runtime/jsx-runtime.d.ts +5 -0
  41. package/dist/jsx-runtime/jsx-runtime.d.ts.map +1 -0
  42. package/dist/jsx-runtime/jsx-runtime.js +40 -0
  43. package/dist/jsx-runtime.cjs +112 -1
  44. package/dist/jsx-runtime.cjs.map +1 -1
  45. package/dist/jsx-runtime.d.ts +18 -0
  46. package/dist/jsx-runtime.d.ts.map +1 -0
  47. package/dist/jsx-runtime.js +90 -79
  48. package/dist/jsx-runtime.js.map +1 -1
  49. package/dist/lifecycle-events.d.ts +109 -0
  50. package/dist/lifecycle-events.d.ts.map +1 -0
  51. package/dist/lifecycle-events.js +176 -0
  52. package/dist/renderComponent.d.ts +14 -0
  53. package/dist/renderComponent.d.ts.map +1 -0
  54. package/dist/renderComponent.js +29 -0
  55. package/dist/renderer.d.ts +4 -0
  56. package/dist/renderer.d.ts.map +1 -0
  57. package/dist/renderer.js +49 -0
  58. package/dist/router.d.ts +56 -0
  59. package/dist/router.d.ts.map +1 -0
  60. package/dist/router.js +165 -0
  61. package/dist/server-renderer.d.ts +2 -0
  62. package/dist/server-renderer.d.ts.map +1 -0
  63. package/dist/server-renderer.js +111 -5
  64. package/dist/server-types.d.ts +43 -0
  65. package/dist/server-types.d.ts.map +1 -0
  66. package/dist/server-types.js +5 -0
  67. package/dist/store.d.ts +42 -0
  68. package/dist/store.d.ts.map +1 -0
  69. package/dist/store.js +98 -0
  70. package/dist/types.d.ts +272 -0
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/types.js +2 -0
  73. package/dist/utils.d.ts +47 -0
  74. package/dist/utils.d.ts.map +1 -0
  75. package/dist/utils.js +143 -0
  76. package/dist/vdom.d.ts +9 -0
  77. package/dist/vdom.d.ts.map +1 -0
  78. package/dist/vdom.js +21 -0
  79. package/dist/wasm.d.ts +37 -0
  80. package/dist/wasm.d.ts.map +1 -0
  81. package/dist/wasm.js +158 -0
  82. package/package.json +54 -83
  83. package/dist/index.client.cjs +0 -2
  84. package/dist/index.client.cjs.map +0 -1
  85. package/dist/index.client.js.map +0 -1
  86. package/dist/renderer-DaVfBeVi.cjs +0 -2
  87. package/dist/renderer-DaVfBeVi.cjs.map +0 -1
  88. package/dist/renderer-nfT7XSpo.js +0 -61
  89. package/dist/renderer-nfT7XSpo.js.map +0 -1
  90. package/dist/server-renderer-B5b0Q0ck.cjs +0 -2
  91. package/dist/server-renderer-B5b0Q0ck.cjs.map +0 -1
  92. package/dist/server-renderer-C4MB-jAp.js +0 -248
  93. package/dist/server-renderer-C4MB-jAp.js.map +0 -1
  94. package/dist/server-renderer.cjs +0 -2
  95. package/dist/server-renderer.cjs.map +0 -1
  96. package/dist/server-renderer.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,2 +1,1232 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./jsx-runtime.cjs"),t=require("./renderer-DaVfBeVi.cjs"),o=require("./server-renderer-B5b0Q0ck.cjs");function n(e,t){const o=Object.keys(e).filter((e=>"children"!==e)),n=Object.keys(t).filter((e=>"children"!==e));return o.length===n.length&&o.every((o=>e[o]===t[o]))}function r(e,t){return null==e||null==t?e!==t:typeof e!=typeof t||("string"==typeof t||"number"==typeof t?e!==t:t.type!==e.type||!n(e.props,t.props))}function s(e,t){return!n(e,t)}class i{constructor(e={}){this.state={},this.element=null,this._mounted=!1,this.props=e}componentDidMount(){}async setState(e){const t={...this.state};this.state={...t,...e},console.log(`${this.constructor.name} state updated:`,{prev:t,next:this.state}),await Promise.resolve(),this._mounted,await this.update()}_replayEvents(e,t){const o=e.__events||{};Object.entries(o).forEach((([e,o])=>{t.addEventListener(e,o)})),t.__events=o}_deepCloneWithEvents(e){const t=e.cloneNode(!1),o=e.__events||{};return t.__events=o,Object.entries(o).forEach((([e,o])=>{t.addEventListener(e,o)})),Array.from(e.childNodes).forEach((e=>{e instanceof HTMLElement?t.appendChild(this._deepCloneWithEvents(e)):t.appendChild(e.cloneNode(!0))})),t}async update(){const t=this.render();if(!t)return document.createTextNode("");const o=await e.createElement(t);if(o instanceof HTMLElement)return this._updateElement(o);const n=document.createElement("div");return n.appendChild(o),this._updateElement(n)}async _updateElement(e){const t=this._deepCloneWithEvents(e);return t.__instance=this,this.element?this.element.parentNode&&(this.element.parentNode.replaceChild(t,this.element),this.element=t):(this.element=t,this._mounted||(this._mounted=!0,queueMicrotask((()=>this.componentDidMount())))),this.element}render(){throw new Error("Component must implement render() method")}}const c="/wasm_exec.js";async function u(e,t={}){const{importObject:o={},goWasmPath:n=c,loadGo:r=!0,onLoad:s,debug:i=!1}=t;"undefined"!=typeof window&&r&&await async function(e=c){if("undefined"==typeof window)return;if(void 0!==window.Go)return;return new Promise(((t,o)=>{const n=document.createElement("script");n.src=e,n.onload=()=>t(),n.onerror=()=>o(new Error(`Failed to load Go WASM runtime from ${e}`)),document.head.appendChild(n)}))}(n);try{const t="undefined"!=typeof Go?new Go:null;i&&console.log(`[WASM] Loading module from ${e}`);const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch WASM module: ${n.statusText}`);const r=await n.arrayBuffer(),c=await WebAssembly.compile(r),u=t?{...t.importObject,...o}:o,a=await WebAssembly.instantiate(c,u);t&&t.run(a);const d=a.exports,l={};for(const e in d)if("function"==typeof d[e]){const t=d[e];if(l[e]=(...e)=>t(...e),i){const t=l[e];l[e]=(...o)=>{console.log(`[WASM] Calling ${e}(${o.join(", ")})`);const n=t(...o);return console.log(`[WASM] ${e} returned:`,n),n}}}if("undefined"!=typeof window)for(const e in window)if(e.startsWith("go")&&"function"==typeof window[e]){const t=window[e];if(l[e]=(...e)=>t(...e),i){const t=l[e];l[e]=(...o)=>{console.log(`[WASM] Calling global ${e}(${o.join(", ")})`);const n=t(...o);return console.log(`[WASM] ${e} returned:`,n),n}}}const f={instance:a,module:c,exports:d,functions:l};return s&&s(f),f}catch(u){throw console.error("[WASM] Failed to load Go WASM module:",u),u}}function a(e,t){if(!e.functions[t])throw new Error(`WASM function "${t}" not found`);return e.functions[t]}const d={stringToGo:(e,t)=>{if(!e.functions.__stringToGo)throw new Error("__stringToGo function not found in WASM module");return e.functions.__stringToGo(t)},stringFromGo:(e,t)=>{if(!e.functions.__stringFromGo)throw new Error("__stringFromGo function not found in WASM module");return e.functions.__stringFromGo(t)},objectToGo:(e,t)=>{if(!e.functions.__objectToGo)throw new Error("__objectToGo function not found in WASM module");return e.functions.__objectToGo(JSON.stringify(t))},objectFromGo:(e,t)=>{if(!e.functions.__objectFromGo)throw new Error("__objectFromGo function not found in WASM module");const o=e.functions.__objectFromGo(t);return JSON.parse(o)}},l={jsx:e.jsx,jsxs:e.jsx,jsxDEV:e.jsx,Fragment:e.Fragment,createElement:e.createElement,render:t.render,hydrate:t.hydrate,useState:o.useState,useEffect:o.useEffect,useMemo:o.useMemo,useRef:o.useRef,useContext:t.useContext,useErrorBoundary:o.useErrorBoundary,createContext:t.createContext,renderToString:o.renderToString,batchUpdates:o.batchUpdates,diff:r,shouldComponentUpdate:s,Component:i,loadGoWasm:u,createTypedWasmFunction:a,goValues:d};exports.Fragment=e.Fragment,exports.createElement=e.createElement,exports.jsx=e.jsx,exports.jsxDEV=e.jsx,exports.jsxs=e.jsx,exports.createContext=t.createContext,exports.hydrate=t.hydrate,exports.render=t.render,exports.useContext=t.useContext,exports.batchUpdates=o.batchUpdates,exports.renderToString=o.renderToString,exports.useEffect=o.useEffect,exports.useErrorBoundary=o.useErrorBoundary,exports.useMemo=o.useMemo,exports.useRef=o.useRef,exports.useState=o.useState,exports.Component=i,exports.createTypedWasmFunction=a,exports.default=l,exports.diff=r,exports.goValues=d,exports.loadGoWasm=u,exports.shouldComponentUpdate=s;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function jsx(type, props) {
6
+ console.log('JSX Transform:', { type, props });
7
+ const processedProps = { ...props };
8
+ // Handle children properly
9
+ if (arguments.length > 2) {
10
+ processedProps.children = Array.prototype.slice.call(arguments, 2);
11
+ }
12
+ return { type, props: processedProps };
13
+ }
14
+ const Fragment = ({ children }) => children;
15
+ async function createElement(vnode) {
16
+ console.log('Creating element from:', vnode);
17
+ // Handle primitives and null
18
+ if (vnode == null) {
19
+ return document.createTextNode('');
20
+ }
21
+ if (typeof vnode === 'boolean') {
22
+ return document.createTextNode('');
23
+ }
24
+ if (typeof vnode === 'number' || typeof vnode === 'string') {
25
+ return document.createTextNode(String(vnode));
26
+ }
27
+ // Handle arrays
28
+ if (Array.isArray(vnode)) {
29
+ const fragment = document.createDocumentFragment();
30
+ for (const child of vnode) {
31
+ const node = await createElement(child);
32
+ fragment.appendChild(node);
33
+ }
34
+ return fragment;
35
+ }
36
+ // Handle VNode
37
+ if ('type' in vnode && vnode.props !== undefined) {
38
+ const { type, props } = vnode;
39
+ // Handle function components
40
+ if (typeof type === 'function') {
41
+ try {
42
+ const result = await type(props || {});
43
+ const node = await createElement(result);
44
+ if (node instanceof Element) {
45
+ node.setAttribute('data-component-id', type.name || type.toString());
46
+ }
47
+ return node;
48
+ }
49
+ catch (error) {
50
+ console.error('Error rendering component:', error);
51
+ return document.createTextNode('');
52
+ }
53
+ }
54
+ // Create DOM element
55
+ const element = document.createElement(type);
56
+ // Handle props
57
+ for (const [key, value] of Object.entries(props || {})) {
58
+ if (key === 'children')
59
+ continue;
60
+ if (key.startsWith('on') && typeof value === 'function') {
61
+ const eventName = key.toLowerCase().slice(2);
62
+ // Remove existing event listener if any
63
+ const existingHandler = element.__events?.[eventName];
64
+ if (existingHandler) {
65
+ element.removeEventListener(eventName, existingHandler);
66
+ }
67
+ // Add new event listener
68
+ element.addEventListener(eventName, value);
69
+ if (!element.__events) {
70
+ element.__events = {};
71
+ }
72
+ element.__events[eventName] = value;
73
+ }
74
+ else if (key === 'style' && typeof value === 'object') {
75
+ Object.assign(element.style, value);
76
+ }
77
+ else if (key === 'className') {
78
+ element.setAttribute('class', String(value));
79
+ }
80
+ else if (key !== 'key' && key !== 'ref') {
81
+ element.setAttribute(key, String(value));
82
+ }
83
+ }
84
+ // Handle children
85
+ const children = props?.children;
86
+ if (children != null) {
87
+ const childArray = Array.isArray(children) ? children.flat() : [children];
88
+ for (const child of childArray) {
89
+ const childNode = await createElement(child);
90
+ element.appendChild(childNode);
91
+ }
92
+ }
93
+ return element;
94
+ }
95
+ // Handle other objects by converting to string
96
+ return document.createTextNode(String(vnode));
97
+ }
98
+
99
+ let isBatching = false;
100
+ const queue = [];
101
+ function batchUpdates(fn) {
102
+ if (isBatching) {
103
+ queue.push(fn);
104
+ return;
105
+ }
106
+ isBatching = true;
107
+ try {
108
+ fn();
109
+ while (queue.length > 0) {
110
+ const nextFn = queue.shift();
111
+ nextFn?.();
112
+ }
113
+ }
114
+ finally {
115
+ isBatching = false;
116
+ }
117
+ }
118
+
119
+ const contexts = new Map();
120
+ function createContext(defaultValue) {
121
+ const contextId = Symbol('context');
122
+ const Provider = ({ value, children }) => {
123
+ contexts.set(contextId, value);
124
+ return children;
125
+ };
126
+ const Consumer = ({ children }) => {
127
+ const value = contexts.get(contextId) ?? defaultValue;
128
+ return children(value);
129
+ };
130
+ const context = {
131
+ Provider,
132
+ Consumer,
133
+ displayName: 'Context'
134
+ };
135
+ return context;
136
+ }
137
+ function useContext(context) {
138
+ // In a real implementation, this would access the context value from the component tree
139
+ // For now, returning a default value to satisfy TypeScript
140
+ return {};
141
+ }
142
+
143
+ // Current render ID counter
144
+ let currentRender = 0;
145
+ // State storage
146
+ const states = new Map();
147
+ const stateIndices = new Map();
148
+ const effects = new Map();
149
+ const memos = new Map();
150
+ const refs = new Map();
151
+ // Rendering callbacks
152
+ let globalRenderCallback = null;
153
+ let globalContainer = null;
154
+ let currentElement = null;
155
+ function setRenderCallback(callback, element, container) {
156
+ globalRenderCallback = callback;
157
+ globalContainer = container;
158
+ currentElement = element;
159
+ }
160
+ function prepareRender(component = null) {
161
+ currentRender++;
162
+ stateIndices.set(currentRender, 0);
163
+ return currentRender;
164
+ }
165
+ function finishRender() {
166
+ currentRender = 0;
167
+ }
168
+ function useState(initial) {
169
+ if (!currentRender) {
170
+ throw new Error("useState must be called within a render");
171
+ }
172
+ if (!states.has(currentRender)) {
173
+ states.set(currentRender, []);
174
+ }
175
+ const componentStates = states.get(currentRender);
176
+ const index = stateIndices.get(currentRender) || 0;
177
+ if (index >= componentStates.length) {
178
+ componentStates.push(initial);
179
+ }
180
+ const state = componentStates[index];
181
+ const setState = (newValue) => {
182
+ const nextValue = typeof newValue === 'function'
183
+ ? newValue(componentStates[index])
184
+ : newValue;
185
+ if (componentStates[index] === nextValue)
186
+ return;
187
+ componentStates[index] = nextValue;
188
+ if (isBatching) {
189
+ batchUpdates(() => rerender(currentRender));
190
+ }
191
+ else {
192
+ rerender(currentRender);
193
+ }
194
+ };
195
+ stateIndices.set(currentRender, index + 1);
196
+ return [state, setState];
197
+ }
198
+ function useEffect(callback, deps) {
199
+ if (!currentRender)
200
+ throw new Error("useEffect must be called within a render");
201
+ const effectIndex = stateIndices.get(currentRender) || 0;
202
+ if (!effects.has(currentRender)) {
203
+ effects.set(currentRender, []);
204
+ }
205
+ const componentEffects = effects.get(currentRender);
206
+ const prevEffect = componentEffects[effectIndex];
207
+ if (!prevEffect || !deps || !prevEffect.deps || deps.some((dep, i) => dep !== prevEffect.deps[i])) {
208
+ if (prevEffect?.cleanup) {
209
+ prevEffect.cleanup();
210
+ }
211
+ // Schedule effect execution after render is complete
212
+ queueMicrotask(() => {
213
+ const cleanup = callback() || undefined;
214
+ componentEffects[effectIndex] = { cleanup, deps: deps || [] };
215
+ });
216
+ }
217
+ stateIndices.set(currentRender, effectIndex + 1);
218
+ }
219
+ function useMemo(factory, deps) {
220
+ if (!currentRender)
221
+ throw new Error("useMemo must be called within a render");
222
+ const memoIndex = stateIndices.get(currentRender) || 0;
223
+ if (!memos.has(currentRender)) {
224
+ memos.set(currentRender, []);
225
+ }
226
+ const componentMemos = memos.get(currentRender);
227
+ const prevMemo = componentMemos[memoIndex];
228
+ if (!prevMemo || (deps && deps.some((dep, i) => !Object.is(dep, prevMemo.deps[i])))) {
229
+ const value = factory();
230
+ componentMemos[memoIndex] = { value, deps: deps || [] };
231
+ stateIndices.set(currentRender, memoIndex + 1);
232
+ return value;
233
+ }
234
+ stateIndices.set(currentRender, memoIndex + 1);
235
+ return prevMemo.value;
236
+ }
237
+ function useRef(initial) {
238
+ if (!currentRender)
239
+ throw new Error("useRef must be called within a render");
240
+ const refIndex = stateIndices.get(currentRender) || 0;
241
+ if (!refs.has(currentRender)) {
242
+ refs.set(currentRender, []);
243
+ }
244
+ const componentRefs = refs.get(currentRender);
245
+ if (refIndex >= componentRefs.length) {
246
+ const ref = { current: initial };
247
+ componentRefs.push(ref);
248
+ stateIndices.set(currentRender, refIndex + 1);
249
+ return ref;
250
+ }
251
+ const ref = componentRefs[refIndex];
252
+ stateIndices.set(currentRender, refIndex + 1);
253
+ return ref;
254
+ }
255
+ async function rerender(rendererId) {
256
+ try {
257
+ // Clean up effects
258
+ const componentEffects = effects.get(rendererId);
259
+ if (componentEffects) {
260
+ componentEffects.forEach(effect => {
261
+ if (effect.cleanup)
262
+ effect.cleanup();
263
+ });
264
+ effects.set(rendererId, []);
265
+ }
266
+ // Trigger re-render
267
+ if (globalRenderCallback && globalContainer && currentElement) {
268
+ await globalRenderCallback(currentElement, globalContainer);
269
+ }
270
+ }
271
+ catch (error) {
272
+ console.error('Error during rerender:', error);
273
+ }
274
+ }
275
+ function useErrorBoundary() {
276
+ const [error, setError] = useState(null);
277
+ return [error, () => setError(null)];
278
+ }
279
+
280
+ // Render function for client-side rendering
281
+ async function render(element, container) {
282
+ try {
283
+ // Set up render callback for state updates
284
+ setRenderCallback(render, element, container);
285
+ // Prepare render context
286
+ const renderId = prepareRender(element);
287
+ // Create DOM nodes from virtual elements
288
+ const domNode = await createElement(element);
289
+ // Clear container and append new content
290
+ // Handle both Element and DocumentFragment cases
291
+ if (container instanceof Element) {
292
+ container.innerHTML = '';
293
+ }
294
+ else {
295
+ // For DocumentFragment, clear all children
296
+ while (container.firstChild) {
297
+ container.removeChild(container.firstChild);
298
+ }
299
+ }
300
+ container.appendChild(domNode);
301
+ // Finish render
302
+ finishRender();
303
+ console.log('Render completed successfully');
304
+ }
305
+ catch (error) {
306
+ console.error('Error during render:', error);
307
+ // Clean up render context on error
308
+ finishRender();
309
+ throw error;
310
+ }
311
+ }
312
+ // Hydrate function for client-side hydration of SSR content
313
+ async function hydrate(element, container) {
314
+ try {
315
+ console.log('Starting hydration...');
316
+ // For now, hydrate works the same as render
317
+ // In a more advanced implementation, this would preserve existing DOM
318
+ // and only attach event listeners and initialize state
319
+ await render(element, container);
320
+ console.log('Hydration completed successfully');
321
+ }
322
+ catch (error) {
323
+ console.error('Error during hydration:', error);
324
+ throw error;
325
+ }
326
+ }
327
+
328
+ async function renderToString(element) {
329
+ prepareRender(true); // Mark as SSR
330
+ try {
331
+ const html = await renderNodeToString(element);
332
+ return html;
333
+ }
334
+ finally {
335
+ finishRender();
336
+ }
337
+ }
338
+ async function renderNodeToString(node) {
339
+ // Handle null, undefined, boolean
340
+ if (node == null || typeof node === 'boolean') {
341
+ return '';
342
+ }
343
+ // Handle primitives
344
+ if (typeof node === 'string' || typeof node === 'number') {
345
+ return escapeHtml(String(node));
346
+ }
347
+ // Handle arrays
348
+ if (Array.isArray(node)) {
349
+ const results = await Promise.all(node.map(child => renderNodeToString(child)));
350
+ return results.join('');
351
+ }
352
+ // Handle objects with type and props (React-like elements)
353
+ if (node && typeof node === 'object' && 'type' in node) {
354
+ const { type, props = {} } = node;
355
+ // Handle function components
356
+ if (typeof type === 'function') {
357
+ try {
358
+ const result = await type(props);
359
+ return await renderNodeToString(result);
360
+ }
361
+ catch (error) {
362
+ console.error('Error rendering component:', error);
363
+ return `<!-- Error rendering component: ${error.message} -->`;
364
+ }
365
+ }
366
+ // Handle DOM elements
367
+ if (typeof type === 'string') {
368
+ return await renderDOMElement(type, props);
369
+ }
370
+ }
371
+ // Fallback for other objects
372
+ if (typeof node === 'object') {
373
+ return escapeHtml(JSON.stringify(node));
374
+ }
375
+ return escapeHtml(String(node));
376
+ }
377
+ async function renderDOMElement(tagName, props) {
378
+ const { children, ...attrs } = props;
379
+ // Self-closing tags
380
+ const voidElements = new Set([
381
+ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
382
+ 'link', 'meta', 'param', 'source', 'track', 'wbr'
383
+ ]);
384
+ // Build attributes string
385
+ const attributeString = Object.entries(attrs)
386
+ .filter(([key, value]) => {
387
+ // Filter out React-specific props and event handlers
388
+ if (key.startsWith('on') || key === 'key' || key === 'ref')
389
+ return false;
390
+ if (value == null || value === false)
391
+ return false;
392
+ return true;
393
+ })
394
+ .map(([key, value]) => {
395
+ // Handle className -> class
396
+ if (key === 'className')
397
+ key = 'class';
398
+ // Handle boolean attributes
399
+ if (value === true)
400
+ return key;
401
+ // Handle style objects
402
+ if (key === 'style' && typeof value === 'object' && value !== null) {
403
+ const styleString = Object.entries(value)
404
+ .map(([prop, val]) => `${kebabCase(prop)}:${val}`)
405
+ .join(';');
406
+ return `style="${escapeHtml(styleString)}"`;
407
+ }
408
+ return `${key}="${escapeHtml(String(value))}"`;
409
+ })
410
+ .join(' ');
411
+ const openTag = `<${tagName}${attributeString ? ' ' + attributeString : ''}>`;
412
+ // Self-closing elements
413
+ if (voidElements.has(tagName)) {
414
+ return openTag.slice(0, -1) + '/>';
415
+ }
416
+ // Elements with children
417
+ const closeTag = `</${tagName}>`;
418
+ if (children != null) {
419
+ const childrenString = await renderNodeToString(children);
420
+ return openTag + childrenString + closeTag;
421
+ }
422
+ return openTag + closeTag;
423
+ }
424
+ function escapeHtml(text) {
425
+ const htmlEscapes = {
426
+ '&': '&amp;',
427
+ '<': '&lt;',
428
+ '>': '&gt;',
429
+ '"': '&quot;',
430
+ "'": '&#x27;',
431
+ '/': '&#x2F;'
432
+ };
433
+ return text.replace(/[&<>"'/]/g, (match) => htmlEscapes[match]);
434
+ }
435
+ function kebabCase(str) {
436
+ return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
437
+ }
438
+
439
+ function arePropsEqual(oldProps, newProps) {
440
+ const oldKeys = Object.keys(oldProps).filter(k => k !== 'children');
441
+ const newKeys = Object.keys(newProps).filter(k => k !== 'children');
442
+ if (oldKeys.length !== newKeys.length)
443
+ return false;
444
+ return oldKeys.every(key => oldProps[key] === newProps[key]);
445
+ }
446
+ function diff(oldNode, newNode) {
447
+ if (oldNode == null || newNode == null)
448
+ return oldNode !== newNode;
449
+ if (typeof oldNode !== typeof newNode)
450
+ return true;
451
+ if (typeof newNode === 'string' || typeof newNode === 'number')
452
+ return oldNode !== newNode;
453
+ if (newNode.type !== oldNode.type)
454
+ return true;
455
+ return !arePropsEqual(oldNode.props, newNode.props);
456
+ }
457
+ function shouldComponentUpdate(oldProps, newProps) {
458
+ return !arePropsEqual(oldProps, newProps);
459
+ }
460
+
461
+ class Component {
462
+ constructor(props = {}) {
463
+ this.state = {};
464
+ this.element = null;
465
+ this._mounted = false;
466
+ this.props = props;
467
+ }
468
+ componentDidMount() {
469
+ // Hook for after component is mounted
470
+ }
471
+ async setState(newState) {
472
+ const prevState = { ...this.state };
473
+ this.state = { ...prevState, ...newState };
474
+ console.log(`${this.constructor.name} state updated:`, {
475
+ prev: prevState,
476
+ next: this.state
477
+ });
478
+ await Promise.resolve(); // Ensure state is updated before re-render
479
+ if (this._mounted) {
480
+ await this.update();
481
+ }
482
+ else {
483
+ await this.update();
484
+ }
485
+ }
486
+ _replayEvents(oldElement, newElement) {
487
+ const oldEvents = oldElement.__events || {};
488
+ Object.entries(oldEvents).forEach(([event, handler]) => {
489
+ newElement.addEventListener(event, handler);
490
+ });
491
+ newElement.__events = oldEvents;
492
+ }
493
+ _deepCloneWithEvents(node) {
494
+ const clone = node.cloneNode(false);
495
+ // Copy events from original element
496
+ const events = node.__events || {};
497
+ clone.__events = events;
498
+ Object.entries(events).forEach(([event, handler]) => {
499
+ clone.addEventListener(event, handler);
500
+ });
501
+ // Clone children
502
+ Array.from(node.childNodes).forEach(child => {
503
+ if (child instanceof HTMLElement) {
504
+ clone.appendChild(this._deepCloneWithEvents(child));
505
+ }
506
+ else {
507
+ clone.appendChild(child.cloneNode(true));
508
+ }
509
+ });
510
+ return clone;
511
+ }
512
+ async update() {
513
+ const vdom = this.render();
514
+ if (!vdom)
515
+ return document.createTextNode('');
516
+ const rendered = await createElement(vdom);
517
+ if (rendered instanceof HTMLElement) {
518
+ return this._updateElement(rendered);
519
+ }
520
+ const wrapper = document.createElement('div');
521
+ wrapper.appendChild(rendered);
522
+ return this._updateElement(wrapper);
523
+ }
524
+ async _updateElement(rendered) {
525
+ const newElement = this._deepCloneWithEvents(rendered);
526
+ newElement.__instance = this;
527
+ if (!this.element) {
528
+ this.element = newElement;
529
+ if (!this._mounted) {
530
+ this._mounted = true;
531
+ queueMicrotask(() => this.componentDidMount());
532
+ }
533
+ }
534
+ else if (this.element.parentNode) {
535
+ this.element.parentNode.replaceChild(newElement, this.element);
536
+ this.element = newElement;
537
+ }
538
+ return this.element;
539
+ }
540
+ render() {
541
+ throw new Error('Component must implement render() method');
542
+ }
543
+ }
544
+
545
+ /**
546
+ * Client-side router for single-page applications
547
+ */
548
+ // Create context for router
549
+ const RouterContext = createContext({
550
+ location: {
551
+ pathname: '/',
552
+ search: '',
553
+ hash: ''
554
+ },
555
+ params: {},
556
+ navigate: () => { },
557
+ match: () => false
558
+ });
559
+ // Parse path pattern into regex
560
+ function parsePath(path) {
561
+ // Convert :param syntax to capture groups
562
+ const pattern = path
563
+ .replace(/\/+$/, '') // Remove trailing slashes
564
+ .replace(/^\/+/, '/') // Ensure leading slash
565
+ .replace(/\/:([^/]+)/g, '/([^/]+)');
566
+ // Get param names
567
+ const paramNames = [];
568
+ path.replace(/\/:([^/]+)/g, (_, paramName) => {
569
+ paramNames.push(paramName);
570
+ return '';
571
+ });
572
+ return { pattern, paramNames };
573
+ }
574
+ // Match a path against a pattern
575
+ function matchPath(pathname, route) {
576
+ const { path, exact = false } = route;
577
+ const { pattern, paramNames } = parsePath(path);
578
+ // Create regex with or without exact matching
579
+ const regex = new RegExp(`^${pattern}${exact ? '$' : ''}`);
580
+ const match = pathname.match(regex);
581
+ if (!match)
582
+ return null;
583
+ // Extract params
584
+ const params = {};
585
+ paramNames.forEach((name, index) => {
586
+ params[name] = match[index + 1];
587
+ });
588
+ return params;
589
+ }
590
+ // Router Provider component
591
+ function RouterProvider({ routes, children }) {
592
+ // Get initial location from window if available
593
+ const getInitialLocation = () => {
594
+ if (typeof window === 'undefined') {
595
+ return { pathname: '/', search: '', hash: '' };
596
+ }
597
+ return {
598
+ pathname: window.location.pathname,
599
+ search: window.location.search,
600
+ hash: window.location.hash
601
+ };
602
+ };
603
+ // Fix: Call the function to get the initial value instead of passing the function itself
604
+ const [location, setLocation] = useState(getInitialLocation());
605
+ const [params, setParams] = useState({});
606
+ // Update params when location changes
607
+ useEffect(() => {
608
+ for (const route of routes) {
609
+ const matchedParams = matchPath(location.pathname, route);
610
+ if (matchedParams) {
611
+ setParams(matchedParams);
612
+ break;
613
+ }
614
+ }
615
+ }, [location, routes]);
616
+ // Listen for popstate events
617
+ useEffect(() => {
618
+ if (typeof window === 'undefined')
619
+ return;
620
+ const handlePopState = () => {
621
+ setLocation({
622
+ pathname: window.location.pathname,
623
+ search: window.location.search,
624
+ hash: window.location.hash
625
+ });
626
+ };
627
+ window.addEventListener('popstate', handlePopState);
628
+ return () => window.removeEventListener('popstate', handlePopState);
629
+ }, []);
630
+ // Navigation function
631
+ const navigate = (to, options = {}) => {
632
+ if (typeof window === 'undefined')
633
+ return;
634
+ const { replace = false, state = null } = options;
635
+ if (replace) {
636
+ window.history.replaceState(state, '', to);
637
+ }
638
+ else {
639
+ window.history.pushState(state, '', to);
640
+ }
641
+ // Update location
642
+ setLocation({
643
+ pathname: window.location.pathname,
644
+ search: window.location.search,
645
+ hash: window.location.hash
646
+ });
647
+ };
648
+ // Match function to test if a path matches the current location
649
+ const match = (path) => {
650
+ const { pattern } = parsePath(path);
651
+ const regex = new RegExp(`^${pattern}`);
652
+ return regex.test(location.pathname);
653
+ };
654
+ // Router context value
655
+ const routerValue = {
656
+ location: {
657
+ pathname: location.pathname,
658
+ search: location.search,
659
+ hash: location.hash
660
+ },
661
+ params,
662
+ navigate,
663
+ match
664
+ };
665
+ return jsx(RouterContext.Provider, { value: routerValue, children });
666
+ }
667
+ // Route component
668
+ function Route({ path, component: Component, props = {} }) {
669
+ const context = useContext();
670
+ const params = context.params;
671
+ const locationPathname = context.location.pathname;
672
+ const routeToMatch = { path, component: Component };
673
+ const match = matchPath(locationPathname, routeToMatch);
674
+ if (!match)
675
+ return null;
676
+ return jsx(Component, { ...props, params });
677
+ }
678
+ // Switch component
679
+ function Switch({ children }) {
680
+ const context = useContext();
681
+ const locationPathname = context.location.pathname;
682
+ // Find the first matching route
683
+ const child = Array.isArray(children)
684
+ ? children.find(child => {
685
+ if (!child || typeof child.type !== 'function' || !child.props.path)
686
+ return false;
687
+ const routeObj = {
688
+ path: child.props.path,
689
+ component: child.type,
690
+ exact: child.props.exact || false
691
+ };
692
+ return matchPath(locationPathname, routeObj);
693
+ })
694
+ : children;
695
+ return child || null;
696
+ }
697
+ // Link component
698
+ function Link({ to, replace = false, state = null, className = '', activeClassName = '', children, ...rest }) {
699
+ const context = useContext();
700
+ const navigate = context.navigate;
701
+ const match = context.match;
702
+ const handleClick = (e) => {
703
+ e.preventDefault();
704
+ navigate(to, { replace, state });
705
+ };
706
+ const isActive = match(to);
707
+ const classes = [
708
+ className,
709
+ isActive ? activeClassName : ''
710
+ ].filter(Boolean).join(' ');
711
+ return jsx('a', {
712
+ href: to,
713
+ className: classes || undefined,
714
+ onClick: handleClick,
715
+ ...rest,
716
+ children
717
+ });
718
+ }
719
+ // Redirect component
720
+ function Redirect({ to, replace = true }) {
721
+ const context = useContext();
722
+ const navigate = context.navigate;
723
+ useEffect(() => {
724
+ navigate(to, { replace });
725
+ }, [to]);
726
+ return null;
727
+ }
728
+ // Hooks
729
+ function useLocation() {
730
+ const context = useContext();
731
+ return context.location;
732
+ }
733
+ function useParams() {
734
+ const context = useContext();
735
+ return context.params;
736
+ }
737
+ function useNavigate() {
738
+ const context = useContext();
739
+ return context.navigate;
740
+ }
741
+
742
+ /**
743
+ * Form handling utilities for the framework
744
+ */
745
+ function useForm(options) {
746
+ const { initialValues, validate, onSubmit } = options;
747
+ const [values, setValues] = useState(initialValues);
748
+ const [errors, setErrors] = useState({});
749
+ const [touched, setTouched] = useState({});
750
+ const [dirty, setDirty] = useState({});
751
+ const [isSubmitting, setIsSubmitting] = useState(false);
752
+ const [submitCount, setSubmitCount] = useState(0);
753
+ // Track form validity and dirty state
754
+ const isValid = Object.keys(errors).length === 0;
755
+ const isDirty = Object.values(dirty).some(Boolean);
756
+ // Validate form when values or validate function changes
757
+ useEffect(() => {
758
+ if (validate) {
759
+ const validationErrors = validate(values);
760
+ setErrors(validationErrors || {});
761
+ }
762
+ }, [values, validate]);
763
+ // Handle form input changes
764
+ const handleChange = (e) => {
765
+ const { name, value, type, checked } = e.target;
766
+ const fieldValue = type === 'checkbox' ? checked : value;
767
+ setValues(prev => ({
768
+ ...prev,
769
+ [name]: fieldValue
770
+ }));
771
+ setDirty(prev => ({
772
+ ...prev,
773
+ [name]: true
774
+ }));
775
+ };
776
+ // Handle field blur
777
+ const handleBlur = (e) => {
778
+ const { name } = e.target;
779
+ setTouched(prev => ({
780
+ ...prev,
781
+ [name]: true
782
+ }));
783
+ };
784
+ // Set field value programmatically
785
+ const setFieldValue = (field, value) => {
786
+ setValues(prev => ({
787
+ ...prev,
788
+ [field]: value
789
+ }));
790
+ setDirty(prev => ({
791
+ ...prev,
792
+ [field]: true
793
+ }));
794
+ };
795
+ // Set field error programmatically
796
+ const setFieldError = (field, error) => {
797
+ setErrors(prev => ({
798
+ ...prev,
799
+ [field]: error
800
+ }));
801
+ };
802
+ // Update multiple values at once
803
+ const updateValues = (newValues) => {
804
+ setValues(prev => ({
805
+ ...prev,
806
+ ...newValues
807
+ }));
808
+ // Mark changed fields as dirty
809
+ const dirtyFields = {};
810
+ Object.keys(newValues).forEach(key => {
811
+ dirtyFields[key] = true;
812
+ });
813
+ setDirty(prev => ({
814
+ ...prev,
815
+ ...dirtyFields
816
+ }));
817
+ };
818
+ // Reset form to initial state
819
+ const resetForm = () => {
820
+ setValues(initialValues);
821
+ setErrors({});
822
+ setTouched({});
823
+ setDirty({});
824
+ setIsSubmitting(false);
825
+ };
826
+ // Handle form submission
827
+ const handleSubmit = async (e) => {
828
+ e.preventDefault();
829
+ // Mark all fields as touched
830
+ const allTouched = {};
831
+ Object.keys(values).forEach(key => {
832
+ allTouched[key] = true;
833
+ });
834
+ setTouched(allTouched);
835
+ // Validate before submission
836
+ let validationErrors = {};
837
+ if (validate) {
838
+ validationErrors = validate(values);
839
+ setErrors(validationErrors || {});
840
+ }
841
+ // Only proceed if valid
842
+ if (Object.keys(validationErrors).length === 0 && onSubmit) {
843
+ setIsSubmitting(true);
844
+ setSubmitCount(count => count + 1);
845
+ try {
846
+ await onSubmit(values, {
847
+ fields: Object.keys(values).reduce((acc, key) => {
848
+ acc[key] = {
849
+ value: values[key],
850
+ error: errors[key],
851
+ touched: touched[key] || false,
852
+ dirty: dirty[key] || false
853
+ };
854
+ return acc;
855
+ }, {}),
856
+ isValid,
857
+ isDirty,
858
+ isSubmitting: true,
859
+ submitCount: submitCount + 1
860
+ });
861
+ }
862
+ finally {
863
+ setIsSubmitting(false);
864
+ }
865
+ }
866
+ };
867
+ return {
868
+ values,
869
+ errors,
870
+ touched,
871
+ dirty,
872
+ isValid,
873
+ isDirty,
874
+ isSubmitting,
875
+ submitCount,
876
+ handleChange,
877
+ handleBlur,
878
+ handleSubmit,
879
+ setFieldValue,
880
+ setFieldError,
881
+ setValues: updateValues,
882
+ resetForm
883
+ };
884
+ }
885
+
886
+ function createEventBus() {
887
+ const events = new Map();
888
+ const onceHandlers = new WeakMap();
889
+ const on = (event, handler) => {
890
+ if (!events.has(event)) {
891
+ events.set(event, new Set());
892
+ }
893
+ events.get(event).add(handler);
894
+ // Return a function to remove this handler
895
+ return () => off(event, handler);
896
+ };
897
+ const once = (event, handler) => {
898
+ // Create a wrapper that will call the handler and remove itself
899
+ const onceWrapper = (...args) => {
900
+ off(event, onceWrapper);
901
+ handler(...args);
902
+ };
903
+ // Store the mapping between the original handler and the wrapper
904
+ onceHandlers.set(handler, onceWrapper);
905
+ // Register the wrapper
906
+ return on(event, onceWrapper);
907
+ };
908
+ const off = (event, handler) => {
909
+ // If no handler is provided, remove all handlers for the event
910
+ if (!handler) {
911
+ events.delete(event);
912
+ return;
913
+ }
914
+ // Check if it's a once handler wrapper
915
+ const wrappedHandler = onceHandlers.get(handler);
916
+ const handlerToRemove = wrappedHandler || handler;
917
+ if (events.has(event)) {
918
+ events.get(event).delete(handlerToRemove);
919
+ // Clean up empty event sets
920
+ if (events.get(event).size === 0) {
921
+ events.delete(event);
922
+ }
923
+ }
924
+ };
925
+ const emit = (event, ...args) => {
926
+ if (!events.has(event)) {
927
+ return;
928
+ }
929
+ // Create a copy of the handlers to avoid issues if handlers modify the set
930
+ const handlers = Array.from(events.get(event));
931
+ // Call each handler with the arguments
932
+ for (const handler of handlers) {
933
+ handler(...args);
934
+ }
935
+ };
936
+ const clear = (event) => {
937
+ if (event) {
938
+ events.delete(event);
939
+ }
940
+ else {
941
+ events.clear();
942
+ }
943
+ };
944
+ return { on, once, off, emit, clear };
945
+ }
946
+ // Create a global event bus instance
947
+ const globalEventBus = createEventBus();
948
+ // Hook to use the event bus in components
949
+ function useEvent(event, handler, options = {}) {
950
+ return options.once
951
+ ? globalEventBus.once(event, handler)
952
+ : globalEventBus.on(event, handler);
953
+ }
954
+
955
+ /**
956
+ * Global state management solution similar to Redux
957
+ */
958
+ function createStore(reducer, initialState, middlewares = []) {
959
+ let state = initialState;
960
+ let listeners = [];
961
+ // Apply middlewares
962
+ let dispatch = (action) => {
963
+ state = reducer(state, action);
964
+ listeners.forEach(listener => listener());
965
+ return action;
966
+ };
967
+ // Chain middlewares
968
+ if (middlewares.length > 0) {
969
+ const middlewareAPI = {
970
+ getState: () => state,
971
+ dispatch: (action) => dispatch(action),
972
+ subscribe: (listener) => subscribe(listener)
973
+ };
974
+ const chain = middlewares.map(middleware => middleware(middlewareAPI));
975
+ dispatch = chain.reduce((a, b) => (next) => a(b(next)))(dispatch);
976
+ }
977
+ // Subscribe to store changes
978
+ function subscribe(listener) {
979
+ listeners.push(listener);
980
+ return function unsubscribe() {
981
+ listeners = listeners.filter(l => l !== listener);
982
+ };
983
+ }
984
+ // Initialize store with default state
985
+ dispatch({ type: '@@INIT' });
986
+ return {
987
+ getState: () => state,
988
+ dispatch,
989
+ subscribe
990
+ };
991
+ }
992
+ const StoreContext = createContext({
993
+ store: {
994
+ getState: () => ({}),
995
+ dispatch: () => { },
996
+ subscribe: () => () => { }
997
+ },
998
+ state: {}
999
+ });
1000
+ function StoreProvider({ store, children }) {
1001
+ const [state, setState] = useState(store.getState());
1002
+ useEffect(() => {
1003
+ const unsubscribe = store.subscribe(() => {
1004
+ setState(store.getState());
1005
+ });
1006
+ return unsubscribe;
1007
+ }, [store]);
1008
+ return jsx(StoreContext.Provider, {
1009
+ value: { store, state },
1010
+ children
1011
+ });
1012
+ }
1013
+ function useSelector(selector) {
1014
+ const context = useContext();
1015
+ return selector(context.state);
1016
+ }
1017
+ function useDispatch() {
1018
+ const context = useContext();
1019
+ return context.store.dispatch;
1020
+ }
1021
+ function useStore() {
1022
+ const context = useContext();
1023
+ return context.store;
1024
+ }
1025
+ // Common middlewares
1026
+ const logger = (store) => (next) => (action) => {
1027
+ console.group(action.type);
1028
+ console.log('Previous state:', store.getState());
1029
+ console.log('Action:', action);
1030
+ const result = next(action);
1031
+ console.log('Next state:', store.getState());
1032
+ console.groupEnd();
1033
+ return result;
1034
+ };
1035
+ const thunk = (store) => (next) => (action) => {
1036
+ if (typeof action === 'function') {
1037
+ return action(store.dispatch, store.getState);
1038
+ }
1039
+ return next(action);
1040
+ };
1041
+
1042
+ /**
1043
+ * Lifecycle events for components and application
1044
+ */
1045
+ exports.LifecycleEvents = void 0;
1046
+ (function (LifecycleEvents) {
1047
+ LifecycleEvents["APP_INIT"] = "app:init";
1048
+ LifecycleEvents["APP_MOUNTED"] = "app:mounted";
1049
+ LifecycleEvents["APP_UPDATED"] = "app:updated";
1050
+ LifecycleEvents["APP_ERROR"] = "app:error";
1051
+ LifecycleEvents["APP_DESTROYED"] = "app:destroyed";
1052
+ LifecycleEvents["COMPONENT_CREATED"] = "component:created";
1053
+ LifecycleEvents["COMPONENT_MOUNTED"] = "component:mounted";
1054
+ LifecycleEvents["COMPONENT_UPDATED"] = "component:updated";
1055
+ LifecycleEvents["COMPONENT_ERROR"] = "component:error";
1056
+ LifecycleEvents["COMPONENT_UNMOUNTED"] = "component:unmounted";
1057
+ LifecycleEvents["ROUTER_BEFORE_CHANGE"] = "router:before-change";
1058
+ LifecycleEvents["ROUTER_AFTER_CHANGE"] = "router:after-change";
1059
+ LifecycleEvents["ROUTER_ERROR"] = "router:error";
1060
+ LifecycleEvents["STORE_INITIALIZED"] = "store:initialized";
1061
+ LifecycleEvents["STORE_BEFORE_ACTION"] = "store:before-action";
1062
+ LifecycleEvents["STORE_AFTER_ACTION"] = "store:after-action";
1063
+ LifecycleEvents["STORE_ERROR"] = "store:error";
1064
+ })(exports.LifecycleEvents || (exports.LifecycleEvents = {}));
1065
+ // Event emitters
1066
+ function emitAppInit(data) {
1067
+ globalEventBus.emit(exports.LifecycleEvents.APP_INIT, data);
1068
+ }
1069
+ function emitAppMounted(rootElement) {
1070
+ globalEventBus.emit(exports.LifecycleEvents.APP_MOUNTED, rootElement);
1071
+ }
1072
+ function emitAppUpdated() {
1073
+ globalEventBus.emit(exports.LifecycleEvents.APP_UPDATED);
1074
+ }
1075
+ function emitAppError(error) {
1076
+ globalEventBus.emit(exports.LifecycleEvents.APP_ERROR, error);
1077
+ }
1078
+ function emitAppDestroyed() {
1079
+ globalEventBus.emit(exports.LifecycleEvents.APP_DESTROYED);
1080
+ }
1081
+ function emitComponentCreated(info) {
1082
+ globalEventBus.emit(exports.LifecycleEvents.COMPONENT_CREATED, info);
1083
+ }
1084
+ function emitComponentMounted(info, element) {
1085
+ globalEventBus.emit(exports.LifecycleEvents.COMPONENT_MOUNTED, info, element);
1086
+ }
1087
+ function emitComponentUpdated(info, prevProps, newProps) {
1088
+ globalEventBus.emit(exports.LifecycleEvents.COMPONENT_UPDATED, info, prevProps, newProps);
1089
+ }
1090
+ function emitComponentError(info, error) {
1091
+ globalEventBus.emit(exports.LifecycleEvents.COMPONENT_ERROR, info, error);
1092
+ }
1093
+ function emitComponentUnmounted(info) {
1094
+ globalEventBus.emit(exports.LifecycleEvents.COMPONENT_UNMOUNTED, info);
1095
+ }
1096
+ // Event listeners
1097
+ function onAppInit(handler) {
1098
+ return globalEventBus.on(exports.LifecycleEvents.APP_INIT, handler);
1099
+ }
1100
+ function onAppMounted(handler) {
1101
+ return globalEventBus.on(exports.LifecycleEvents.APP_MOUNTED, handler);
1102
+ }
1103
+ function onAppUpdated(handler) {
1104
+ return globalEventBus.on(exports.LifecycleEvents.APP_UPDATED, handler);
1105
+ }
1106
+ function onAppError(handler) {
1107
+ return globalEventBus.on(exports.LifecycleEvents.APP_ERROR, handler);
1108
+ }
1109
+ function onAppDestroyed(handler) {
1110
+ return globalEventBus.on(exports.LifecycleEvents.APP_DESTROYED, handler);
1111
+ }
1112
+ function onComponentCreated(handler) {
1113
+ return globalEventBus.on(exports.LifecycleEvents.COMPONENT_CREATED, handler);
1114
+ }
1115
+ function onComponentMounted(handler) {
1116
+ return globalEventBus.on(exports.LifecycleEvents.COMPONENT_MOUNTED, handler);
1117
+ }
1118
+ function onComponentUpdated(handler) {
1119
+ return globalEventBus.on(exports.LifecycleEvents.COMPONENT_UPDATED, handler);
1120
+ }
1121
+ function onComponentError(handler) {
1122
+ return globalEventBus.on(exports.LifecycleEvents.COMPONENT_ERROR, handler);
1123
+ }
1124
+ function onComponentUnmounted(handler) {
1125
+ return globalEventBus.on(exports.LifecycleEvents.COMPONENT_UNMOUNTED, handler);
1126
+ }
1127
+
1128
+ // Core JSX and rendering functions
1129
+ // Default export object for compatibility
1130
+ const frontendHamroun = {
1131
+ // JSX
1132
+ jsx,
1133
+ jsxs: jsx,
1134
+ jsxDEV: jsx,
1135
+ Fragment,
1136
+ createElement,
1137
+ // Rendering
1138
+ render,
1139
+ hydrate,
1140
+ renderToString,
1141
+ // Hooks
1142
+ useState,
1143
+ useEffect,
1144
+ useMemo,
1145
+ useRef,
1146
+ useContext,
1147
+ useErrorBoundary,
1148
+ // Context
1149
+ createContext,
1150
+ // Utilities
1151
+ batchUpdates,
1152
+ diff,
1153
+ shouldComponentUpdate,
1154
+ // Component class
1155
+ Component,
1156
+ // Router
1157
+ RouterProvider,
1158
+ Route,
1159
+ Switch,
1160
+ Link,
1161
+ Redirect,
1162
+ useLocation,
1163
+ useParams,
1164
+ useNavigate,
1165
+ // Forms
1166
+ useForm,
1167
+ // Event bus
1168
+ createEventBus,
1169
+ useEvent,
1170
+ eventBus: globalEventBus
1171
+ };
1172
+
1173
+ exports.Component = Component;
1174
+ exports.Fragment = Fragment;
1175
+ exports.Link = Link;
1176
+ exports.Redirect = Redirect;
1177
+ exports.Route = Route;
1178
+ exports.RouterProvider = RouterProvider;
1179
+ exports.StoreProvider = StoreProvider;
1180
+ exports.Switch = Switch;
1181
+ exports.batchUpdates = batchUpdates;
1182
+ exports.createContext = createContext;
1183
+ exports.createElement = createElement;
1184
+ exports.createEventBus = createEventBus;
1185
+ exports.createStore = createStore;
1186
+ exports.default = frontendHamroun;
1187
+ exports.diff = diff;
1188
+ exports.emitAppDestroyed = emitAppDestroyed;
1189
+ exports.emitAppError = emitAppError;
1190
+ exports.emitAppInit = emitAppInit;
1191
+ exports.emitAppMounted = emitAppMounted;
1192
+ exports.emitAppUpdated = emitAppUpdated;
1193
+ exports.emitComponentCreated = emitComponentCreated;
1194
+ exports.emitComponentError = emitComponentError;
1195
+ exports.emitComponentMounted = emitComponentMounted;
1196
+ exports.emitComponentUnmounted = emitComponentUnmounted;
1197
+ exports.emitComponentUpdated = emitComponentUpdated;
1198
+ exports.eventBus = globalEventBus;
1199
+ exports.hydrate = hydrate;
1200
+ exports.jsx = jsx;
1201
+ exports.jsxDEV = jsx;
1202
+ exports.jsxs = jsx;
1203
+ exports.logger = logger;
1204
+ exports.onAppDestroyed = onAppDestroyed;
1205
+ exports.onAppError = onAppError;
1206
+ exports.onAppInit = onAppInit;
1207
+ exports.onAppMounted = onAppMounted;
1208
+ exports.onAppUpdated = onAppUpdated;
1209
+ exports.onComponentCreated = onComponentCreated;
1210
+ exports.onComponentError = onComponentError;
1211
+ exports.onComponentMounted = onComponentMounted;
1212
+ exports.onComponentUnmounted = onComponentUnmounted;
1213
+ exports.onComponentUpdated = onComponentUpdated;
1214
+ exports.render = render;
1215
+ exports.renderToString = renderToString;
1216
+ exports.shouldComponentUpdate = shouldComponentUpdate;
1217
+ exports.thunk = thunk;
1218
+ exports.useContext = useContext;
1219
+ exports.useDispatch = useDispatch;
1220
+ exports.useEffect = useEffect;
1221
+ exports.useErrorBoundary = useErrorBoundary;
1222
+ exports.useEvent = useEvent;
1223
+ exports.useForm = useForm;
1224
+ exports.useLocation = useLocation;
1225
+ exports.useMemo = useMemo;
1226
+ exports.useNavigate = useNavigate;
1227
+ exports.useParams = useParams;
1228
+ exports.useRef = useRef;
1229
+ exports.useSelector = useSelector;
1230
+ exports.useState = useState;
1231
+ exports.useStore = useStore;
2
1232
  //# sourceMappingURL=index.cjs.map