frontend-hamroun 1.2.85 → 1.2.88

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