frontend-hamroun 1.2.82 → 1.2.84

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 (47) hide show
  1. package/bin/cli.js +58 -870
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.client.cjs +1 -1
  5. package/dist/index.client.cjs.map +1 -1
  6. package/dist/index.client.js +2 -2
  7. package/dist/index.client.js.map +1 -1
  8. package/dist/index.js +116 -133
  9. package/dist/index.js.map +1 -1
  10. package/dist/jsx-runtime.cjs.map +1 -1
  11. package/dist/jsx-runtime.js.map +1 -1
  12. package/dist/renderer-DaVfBeVi.cjs +2 -0
  13. package/dist/renderer-DaVfBeVi.cjs.map +1 -0
  14. package/dist/renderer-nfT7XSpo.js +61 -0
  15. package/dist/renderer-nfT7XSpo.js.map +1 -0
  16. package/dist/server-renderer-B5b0Q0ck.cjs +2 -0
  17. package/dist/server-renderer-B5b0Q0ck.cjs.map +1 -0
  18. package/dist/{server-renderer-QHt45Ip2.js → server-renderer-C4MB-jAp.js} +89 -96
  19. package/dist/server-renderer-C4MB-jAp.js.map +1 -0
  20. package/dist/server-renderer.cjs +1 -1
  21. package/dist/server-renderer.js +1 -1
  22. package/package.json +1 -1
  23. package/templates/basic-app/src/App.tsx +397 -19
  24. package/templates/ssr-template/dist/client/assets/main-D-VH3xOb.js +1 -0
  25. package/templates/ssr-template/dist/client/index.html +23 -0
  26. package/templates/ssr-template/dist/client.js +951 -0
  27. package/templates/ssr-template/dist/server.js +739 -0
  28. package/templates/ssr-template/package.json +22 -22
  29. package/templates/ssr-template/src/App.tsx +874 -11
  30. package/templates/ssr-template/tsconfig.json +14 -10
  31. package/templates/ssr-template/vite.config.ts +19 -17
  32. package/templates/wasm/dist/assets/index-BNqTDBdE.js +295 -0
  33. package/templates/wasm/dist/example.wasm +0 -0
  34. package/templates/wasm/dist/index.html +53 -0
  35. package/templates/wasm/dist/wasm_exec.js +572 -0
  36. package/templates/wasm/package-lock.json +4577 -5307
  37. package/templates/wasm/package.json +25 -42
  38. package/templates/wasm/public/wasm_exec.js +12 -1
  39. package/templates/wasm/src/App.tsx +41 -55
  40. package/templates/wasm/vite.config.ts +24 -42
  41. package/dist/renderer-Bo9zkUZ_.js +0 -52
  42. package/dist/renderer-Bo9zkUZ_.js.map +0 -1
  43. package/dist/renderer-Din1y3YM.cjs +0 -2
  44. package/dist/renderer-Din1y3YM.cjs.map +0 -1
  45. package/dist/server-renderer-CqIpQ-od.cjs +0 -2
  46. package/dist/server-renderer-CqIpQ-od.cjs.map +0 -1
  47. package/dist/server-renderer-QHt45Ip2.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./jsx-runtime.cjs"),t=require("./renderer-Din1y3YM.cjs"),o=require("./server-renderer-CqIpQ-od.cjs"),n="/wasm_exec.js";async function r(e,t={}){const{importObject:o={},goWasmPath:r=n,loadGo:s=!0,onLoad:i,debug:a=!1}=t;"undefined"!=typeof window&&s&&await async function(e=n){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)}))}(r);try{const t="undefined"!=typeof Go?new Go:null;a&&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(),s=await WebAssembly.compile(r),c=t?{...t.importObject,...o}:o,u=await WebAssembly.instantiate(s,c);t&&t.run(u);const d=u.exports,l={};for(const e in d)if("function"==typeof d[e]){const t=d[e];if(l[e]=(...e)=>t(...e),a){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),a){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 p={instance:u,module:s,exports:d,functions:l};return i&&i(p),p}catch(c){throw console.error("[WASM] Failed to load Go WASM module:",c),c}}function s(e,t){if(!e.functions[t])throw new Error(`WASM function "${t}" not found`);return e.functions[t]}const i={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)}};function a(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 c(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||!a(e.props,t.props))}function u(e,t){return!a(e,t)}class d{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 l={async getServer(){throw new Error("Server module can only be used in Node.js environment")}},p=r,f=s,m=i,h={loadGoWasm:r,createTypedWasmFunction:s,goValues:i};const x={Fragment:e.Fragment,jsx:e.jsx,jsxs:e.jsx,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,server:l,loadGoWasm:p,createTypedWasmFunction:f,goValues:m,wasm:h,Component:d,diff:c,shouldComponentUpdate:u};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.finishRender=o.finishRender,exports.getIsBatching=o.getIsBatching,Object.defineProperty(exports,"isBatching",{enumerable:!0,get:()=>o.isBatching}),exports.prepareRender=o.prepareRender,exports.renderToString=o.renderToString,exports.setRenderCallback=o.setRenderCallback,exports.useEffect=o.useEffect,exports.useErrorBoundary=o.useErrorBoundary,exports.useMemo=o.useMemo,exports.useRef=o.useRef,exports.useState=o.useState,exports.Component=d,exports.createTypedWasmFunction=f,exports.default=x,exports.diff=c,exports.goValues=m,exports.isHydrating=!1,exports.loadGoWasm=p,exports.server=l,exports.shouldComponentUpdate=u,exports.wasm=h;
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;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/wasm.ts","../src/vdom.ts","../src/component.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Go WebAssembly Integration Utilities\r\n * \r\n * This module provides tools for loading and interacting with Go WASM modules\r\n * in browser and server environments.\r\n */\r\n\r\n// Type definitions for Go WASM integration\r\nexport interface GoWasmInstance {\r\n instance: WebAssembly.Instance;\r\n module: WebAssembly.Module;\r\n exports: any;\r\n functions: Record<string, Function>;\r\n}\r\n\r\nexport interface GoWasmOptions {\r\n importObject?: WebAssembly.Imports;\r\n goWasmPath?: string;\r\n loadGo?: boolean;\r\n onLoad?: (instance: GoWasmInstance) => void;\r\n debug?: boolean;\r\n}\r\n\r\nconst DEFAULT_GO_WASM_PATH = '/wasm_exec.js';\r\n\r\n/**\r\n * Load a Go WASM module from a URL\r\n */\r\nexport async function loadGoWasm(\r\n wasmUrl: string, \r\n options: GoWasmOptions = {}\r\n): Promise<GoWasmInstance> {\r\n const {\r\n importObject = {},\r\n goWasmPath = DEFAULT_GO_WASM_PATH,\r\n loadGo = true,\r\n onLoad,\r\n debug = false\r\n } = options;\r\n\r\n // In browser environment, load the Go WASM runtime\r\n if (typeof window !== 'undefined' && loadGo) {\r\n await loadGoRuntime(goWasmPath);\r\n }\r\n\r\n try {\r\n // Create Go instance for WASM\r\n // @ts-ignore - Go is loaded from the global scope\r\n const go = typeof Go !== 'undefined' ? new Go() : null;\r\n \r\n // Fetch and instantiate the WASM module\r\n if (debug) console.log(`[WASM] Loading module from ${wasmUrl}`);\r\n \r\n const response = await fetch(wasmUrl);\r\n \r\n if (!response.ok) {\r\n throw new Error(`Failed to fetch WASM module: ${response.statusText}`);\r\n }\r\n \r\n const buffer = await response.arrayBuffer();\r\n const module = await WebAssembly.compile(buffer);\r\n \r\n // Create imports object, combining Go runtime with custom imports\r\n const finalImportObject = go ? {\r\n ...go.importObject,\r\n ...importObject\r\n } : importObject;\r\n \r\n // Instantiate the WASM module\r\n const instance = await WebAssembly.instantiate(module, finalImportObject);\r\n \r\n // Initialize Go runtime if available\r\n if (go) {\r\n go.run(instance);\r\n }\r\n \r\n // Extract exported functions\r\n const exports = instance.exports;\r\n const functions: Record<string, Function> = {};\r\n \r\n // Generate wrapper functions for all exports that are functions\r\n for (const key in exports) {\r\n if (typeof exports[key] === 'function') {\r\n // Type assertion to ensure the exports[key] is callable\r\n const exportedFn = exports[key] as unknown as Function;\r\n functions[key] = (...args: any[]) => exportedFn(...args);\r\n \r\n if (debug) {\r\n const originalFn = functions[key];\r\n functions[key] = (...args: any[]) => {\r\n console.log(`[WASM] Calling ${key}(${args.join(', ')})`);\r\n const result = originalFn(...args);\r\n console.log(`[WASM] ${key} returned:`, result);\r\n return result;\r\n };\r\n }\r\n }\r\n }\r\n\r\n // Add any globally exported functions from Go\r\n if (typeof window !== 'undefined') {\r\n for (const key in window) {\r\n if (key.startsWith('go') && typeof (window as any)[key] === 'function') {\r\n // Type assertion to ensure the window[key] is callable\r\n const globalFn = (window as any)[key] as Function;\r\n functions[key] = (...args: any[]) => globalFn(...args);\r\n \r\n if (debug) {\r\n const originalFn = functions[key];\r\n functions[key] = (...args: any[]) => {\r\n console.log(`[WASM] Calling global ${key}(${args.join(', ')})`);\r\n const result = originalFn(...args);\r\n console.log(`[WASM] ${key} returned:`, result);\r\n return result;\r\n };\r\n }\r\n }\r\n }\r\n }\r\n \r\n const wasmInstance: GoWasmInstance = {\r\n instance,\r\n module,\r\n exports,\r\n functions\r\n };\r\n \r\n // Run onLoad callback if provided\r\n if (onLoad) {\r\n onLoad(wasmInstance);\r\n }\r\n \r\n return wasmInstance;\r\n } catch (error) {\r\n console.error('[WASM] Failed to load Go WASM module:', error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Load the Go WASM runtime script\r\n */\r\nasync function loadGoRuntime(path: string = DEFAULT_GO_WASM_PATH): Promise<void> {\r\n if (typeof window === 'undefined') return;\r\n \r\n // Check if Go runtime is already loaded\r\n if (typeof (window as any).Go !== 'undefined') {\r\n return;\r\n }\r\n \r\n // Load the Go WASM runtime script\r\n return new Promise((resolve, reject) => {\r\n const script = document.createElement('script');\r\n script.src = path;\r\n script.onload = () => resolve();\r\n script.onerror = () => reject(new Error(`Failed to load Go WASM runtime from ${path}`));\r\n document.head.appendChild(script);\r\n });\r\n}\r\n\r\n/**\r\n * Create a TypeScript-friendly wrapper for Go WASM functions\r\n */\r\nexport function createTypedWasmFunction<T extends (...args: any[]) => any>(\r\n instance: GoWasmInstance,\r\n functionName: string\r\n): T {\r\n if (!instance.functions[functionName]) {\r\n throw new Error(`WASM function \"${functionName}\" not found`);\r\n }\r\n \r\n return instance.functions[functionName] as T;\r\n}\r\n\r\n/**\r\n * Helper to convert JavaScript values to Go-compatible formats\r\n */\r\nexport const goValues = {\r\n // Convert JS string to Go string (returns memory pointer)\r\n stringToGo: (instance: GoWasmInstance, str: string): number => {\r\n if (!instance.functions.__stringToGo) {\r\n throw new Error('__stringToGo function not found in WASM module');\r\n }\r\n return instance.functions.__stringToGo(str);\r\n },\r\n \r\n // Convert Go string (memory pointer) to JS string\r\n stringFromGo: (instance: GoWasmInstance, ptr: number): string => {\r\n if (!instance.functions.__stringFromGo) {\r\n throw new Error('__stringFromGo function not found in WASM module');\r\n }\r\n return instance.functions.__stringFromGo(ptr);\r\n },\r\n \r\n // Convert JS object to Go (returns memory pointer)\r\n objectToGo: (instance: GoWasmInstance, obj: any): number => {\r\n if (!instance.functions.__objectToGo) {\r\n throw new Error('__objectToGo function not found in WASM module');\r\n }\r\n return instance.functions.__objectToGo(JSON.stringify(obj));\r\n },\r\n \r\n // Convert Go object (memory pointer) to JS object\r\n objectFromGo: (instance: GoWasmInstance, ptr: number): any => {\r\n if (!instance.functions.__objectFromGo) {\r\n throw new Error('__objectFromGo function not found in WASM module');\r\n }\r\n const str = instance.functions.__objectFromGo(ptr);\r\n return JSON.parse(str);\r\n }\r\n};\r\n","interface VNode {\r\n type: string | Function;\r\n props: Record<string, any>;\r\n key?: string | number;\r\n}\r\n\r\nfunction arePropsEqual(oldProps: any, newProps: any): boolean {\r\n const oldKeys = Object.keys(oldProps).filter(k => k !== 'children');\r\n const newKeys = Object.keys(newProps).filter(k => k !== 'children');\r\n \r\n if (oldKeys.length !== newKeys.length) return false;\r\n return oldKeys.every(key => oldProps[key] === newProps[key]);\r\n}\r\n\r\nexport function diff(oldNode: VNode | any, newNode: VNode | any): boolean {\r\n if (oldNode == null || newNode == null) return oldNode !== newNode;\r\n if (typeof oldNode !== typeof newNode) return true;\r\n if (typeof newNode === 'string' || typeof newNode === 'number')\r\n return oldNode !== newNode;\r\n if (newNode.type !== oldNode.type) return true;\r\n return !arePropsEqual(oldNode.props, newNode.props);\r\n}\r\n\r\nexport function shouldComponentUpdate(oldProps: any, newProps: any): boolean {\r\n return !arePropsEqual(oldProps, newProps);\r\n}\r\n","import { createElement } from './jsx-runtime.js';\r\n\r\nexport class Component {\r\n state: any = {};\r\n props: any;\r\n element: HTMLElement | null = null;\r\n private _mounted: boolean = false;\r\n\r\n constructor(props: any = {}) {\r\n this.props = props;\r\n }\r\n\r\n componentDidMount() {\r\n // Hook for after component is mounted\r\n }\r\n\r\n async setState(newState: any) {\r\n const prevState = { ...this.state };\r\n this.state = { ...prevState, ...newState };\r\n console.log(`${this.constructor.name} state updated:`, {\r\n prev: prevState,\r\n next: this.state\r\n });\r\n \r\n await Promise.resolve(); // Ensure state is updated before re-render\r\n if (this._mounted) {\r\n await this.update();\r\n } else {\r\n await this.update();\r\n }\r\n }\r\n\r\n private _replayEvents(oldElement: HTMLElement, newElement: HTMLElement) {\r\n const oldEvents = (oldElement as any).__events || {};\r\n Object.entries(oldEvents).forEach(([event, handler]) => {\r\n newElement.addEventListener(event as keyof HTMLElementEventMap, handler as EventListener);\r\n });\r\n (newElement as any).__events = oldEvents;\r\n }\r\n\r\n private _deepCloneWithEvents(node: HTMLElement): HTMLElement {\r\n const clone = node.cloneNode(false) as HTMLElement;\r\n \r\n // Copy events from original element\r\n const events = (node as any).__events || {};\r\n (clone as any).__events = events;\r\n Object.entries(events).forEach(([event, handler]) => {\r\n clone.addEventListener(event as keyof HTMLElementEventMap, handler as EventListener);\r\n });\r\n\r\n // Clone children\r\n Array.from(node.childNodes).forEach(child => {\r\n if (child instanceof HTMLElement) {\r\n clone.appendChild(this._deepCloneWithEvents(child));\r\n } else {\r\n clone.appendChild(child.cloneNode(true));\r\n }\r\n });\r\n\r\n return clone;\r\n }\r\n\r\n async update() {\r\n const vdom = this.render();\r\n if (!vdom) return document.createTextNode('');\r\n \r\n const rendered = await createElement(vdom);\r\n if (rendered instanceof HTMLElement) {\r\n return this._updateElement(rendered);\r\n }\r\n \r\n const wrapper = document.createElement('div');\r\n wrapper.appendChild(rendered);\r\n return this._updateElement(wrapper);\r\n }\r\n\r\n private async _updateElement(rendered: HTMLElement) {\r\n const newElement = this._deepCloneWithEvents(rendered);\r\n (newElement as any).__instance = this;\r\n \r\n if (!this.element) {\r\n this.element = newElement;\r\n if (!this._mounted) {\r\n this._mounted = true;\r\n queueMicrotask(() => this.componentDidMount());\r\n }\r\n } else if (this.element.parentNode) {\r\n this.element.parentNode.replaceChild(newElement, this.element);\r\n this.element = newElement;\r\n }\r\n \r\n return this.element;\r\n }\r\n\r\n render(): any {\r\n throw new Error('Component must implement render() method');\r\n }\r\n}\r\n","import { createElement } from './jsx-runtime.js';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks.js';\r\nimport { \r\n loadGoWasm as loadGoWasmImpl, \r\n createTypedWasmFunction as createTypedWasmFunctionImpl,\r\n goValues as goValuesImpl,\r\n type GoWasmInstance,\r\n type GoWasmOptions\r\n} from './wasm.js';\r\n\r\n// Import items needed for the default export\r\nimport { jsx, jsxs, jsxDEV, Fragment } from './jsx-runtime.js';\r\nimport { render, hydrate } from './renderer.js';\r\nimport { \r\n useState, \r\n useEffect,\r\n useMemo, \r\n useRef, \r\n useContext,\r\n useErrorBoundary\r\n} from './hooks.js';\r\nimport { createContext } from './context.js';\r\nimport { renderToString } from './server-renderer.js';\r\nimport { batchUpdates, isBatching, getIsBatching } from './batch.js';\r\nimport { diff, shouldComponentUpdate } from './vdom.js';\r\nimport { Component } from './component.js';\r\n\r\n// Re-export core modules with explicit names to ensure they appear in bundle\r\nexport { render, hydrate } from './renderer.js';\r\nexport { \r\n jsx, \r\n jsxs, \r\n jsxDEV,\r\n Fragment, \r\n createElement \r\n} from './jsx-runtime.js';\r\n\r\nexport { \r\n useState, \r\n useEffect,\r\n useMemo, \r\n useRef, \r\n useContext,\r\n useErrorBoundary,\r\n prepareRender,\r\n finishRender,\r\n setRenderCallback\r\n} from './hooks.js';\r\n\r\n// Context API\r\nexport { createContext } from './context.js';\r\n\r\n// Server-side rendering\r\nexport { renderToString } from './server-renderer.js';\r\n\r\n// Batch updates utility\r\nexport { batchUpdates, isBatching, getIsBatching } from './batch.js';\r\n\r\n// VDOM utilities\r\nexport { diff, shouldComponentUpdate } from './vdom.js';\r\n\r\n// Export Component class\r\nexport { Component } from './component.js';\r\n\r\n// Server module stub for browser environments\r\nexport const server = {\r\n async getServer() {\r\n throw new Error(\"Server module can only be used in Node.js environment\");\r\n }\r\n};\r\n\r\n// Export WASM functionality explicitly\r\nexport const loadGoWasm = loadGoWasmImpl;\r\nexport const createTypedWasmFunction = createTypedWasmFunctionImpl;\r\nexport const goValues = goValuesImpl;\r\nexport type { GoWasmInstance, GoWasmOptions } from './wasm.js';\r\n\r\n// Add wasm object to ensure compatibility with existing dist/index.js\r\nexport const wasm = {\r\n loadGoWasm: loadGoWasmImpl,\r\n createTypedWasmFunction: createTypedWasmFunctionImpl,\r\n goValues: goValuesImpl\r\n};\r\n\r\n// Re-export types\r\nexport type { Context } from './context.js';\r\nexport type { VNode } from './types.js';\r\n\r\n// Export server types from the safe type-only file\r\nexport type { \r\n Server, \r\n ServerConfig, \r\n User, \r\n DbConfig, \r\n MiddlewareFunction \r\n} from './server-types.js';\r\n\r\n// Export this so it can be properly identified in the bundle\r\nexport let isHydrating = false;\r\n\r\n// Default export for compatibility with some module systems\r\nexport default {\r\n Fragment,\r\n jsx,\r\n jsxs,\r\n createElement,\r\n render, \r\n hydrate,\r\n useState,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useContext,\r\n useErrorBoundary,\r\n createContext,\r\n renderToString,\r\n batchUpdates,\r\n server,\r\n loadGoWasm,\r\n createTypedWasmFunction,\r\n goValues,\r\n wasm,\r\n Component,\r\n diff,\r\n shouldComponentUpdate\r\n // Server functionality is exposed through the server export\r\n};\r\n"],"names":["DEFAULT_GO_WASM_PATH","async","loadGoWasm","wasmUrl","options","importObject","goWasmPath","loadGo","onLoad","debug","window","path","Go","Promise","resolve","reject","script","document","createElement","src","onload","onerror","Error","head","appendChild","loadGoRuntime","go","console","log","response","fetch","ok","statusText","buffer","arrayBuffer","module","WebAssembly","compile","finalImportObject","instance","instantiate","run","exports","functions","key","exportedFn","args","originalFn","join","result","startsWith","globalFn","wasmInstance","error","createTypedWasmFunction","functionName","goValues","stringToGo","str","__stringToGo","stringFromGo","ptr","__stringFromGo","objectToGo","obj","__objectToGo","JSON","stringify","objectFromGo","__objectFromGo","parse","arePropsEqual","oldProps","newProps","oldKeys","Object","keys","filter","k","newKeys","length","every","diff","oldNode","newNode","type","props","shouldComponentUpdate","Component","constructor","this","state","element","_mounted","componentDidMount","setState","newState","prevState","name","prev","next","update","_replayEvents","oldElement","newElement","oldEvents","__events","entries","forEach","event","handler","addEventListener","_deepCloneWithEvents","node","clone","cloneNode","events","Array","from","childNodes","child","HTMLElement","vdom","render","createTextNode","rendered","_updateElement","wrapper","__instance","parentNode","replaceChild","queueMicrotask","server","getServer","loadGoWasmImpl","createTypedWasmFunctionImpl","goValuesImpl","wasm","index","Fragment","jsx","jsxs","hydrate","useState","useEffect","useMemo","useRef","useContext","useErrorBoundary","createContext","renderToString","batchUpdates"],"mappings":"kOAuBMA,EAAuB,gBAK7BC,eAAsBC,EACpBC,EACAC,EAAyB,IAEnB,MAAAC,aACJA,EAAe,CAAC,EAAAC,WAChBA,EAAaN,EAAAO,OACbA,GAAS,EAAAC,OACTA,EAAAC,MACAA,GAAQ,GACNL,EAGkB,oBAAXM,QAA0BH,SAqGvCN,eAA6BU,EAAeX,GACtC,GAAkB,oBAAXU,OAAwB,OAG/B,QAA8B,IAAtBA,OAAeE,GACzB,OAIF,OAAO,IAAIC,SAAQ,CAACC,EAASC,KACrB,MAAAC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAMR,EACNK,EAAAI,OAAS,IAAMN,IACfE,EAAAK,QAAU,IAAMN,EAAO,IAAIO,MAAM,uCAAuCX,MACtEM,SAAAM,KAAKC,YAAYR,EAAM,GAEpC,CApHUS,CAAcnB,GAGlB,IAGF,MAAMoB,EAAmB,oBAAPd,GAAqB,IAAIA,GAAO,KAG9CH,GAAOkB,QAAQC,IAAI,8BAA8BzB,KAE/C,MAAA0B,QAAiBC,MAAM3B,GAEzB,IAAC0B,EAASE,GACZ,MAAM,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ArB,EAAad,KAAKsB,qBAAqBa,GAc7C,OAbCrB,EAAmBwB,WAAatC,KAE5BA,KAAKE,QAMCF,KAAKE,QAAQqC,aACtBvC,KAAKE,QAAQqC,WAAWC,aAAa1B,EAAYd,KAAKE,SACtDF,KAAKE,QAAUY,IAPfd,KAAKE,QAAUY,EACVd,KAAKG,WACRH,KAAKG,UAAW,EACDsC,gBAAA,IAAMzC,KAAKI,wBAOvBJ,KAAKE,OAAA,CAGd,MAAA+B,GACQ,MAAA,IAAIrG,MAAM,2CAA0C,EC9BvD,MAAM8G,EAAS,CACpB,eAAMC,GACE,MAAA,IAAI/G,MAAM,wDAAuD,GAK9DpB,EAAaoI,EACbhF,EAA0BiF,EAC1B/E,EAAWgF,EAIXC,EAAO,CAClBvI,WAAYoI,EACZhF,wBAAyBiF,EACzB/E,SAAUgF,GAoBZ,MAAeE,EAAA,CAAAC,SACbA,EAAAA,SAAAC,IACAA,EAAAA,IAAAC,KACAA,EAAAD,IAAA1H,cACAA,EAAAA,cAAAyG,OACAA,EAAAA,OAAAmB,QACAA,EAAAA,QAAAC,SACAA,EAAAA,SAAAC,UACAA,EAAAA,UAAAC,QACAA,EAAAA,QAAAC,OACAA,EAAAA,OAAAC,WACAA,EAAAA,WAAAC,iBACAA,EAAAA,iBAAAC,cACAA,EAAAA,cAAAC,eACAA,EAAAA,eAAAC,aACAA,EAAAA,aACAnB,SACAlI,aACAoD,0BACAE,WACAiF,OACAjD,YACAN,OACAK,+1BA1BuB"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/vdom.ts","../src/component.ts","../src/wasm.ts","../src/index.ts"],"sourcesContent":["interface VNode {\r\n type: string | Function;\r\n props: Record<string, any>;\r\n key?: string | number;\r\n}\r\n\r\nfunction arePropsEqual(oldProps: any, newProps: any): boolean {\r\n const oldKeys = Object.keys(oldProps).filter(k => k !== 'children');\r\n const newKeys = Object.keys(newProps).filter(k => k !== 'children');\r\n \r\n if (oldKeys.length !== newKeys.length) return false;\r\n return oldKeys.every(key => oldProps[key] === newProps[key]);\r\n}\r\n\r\nexport function diff(oldNode: VNode | any, newNode: VNode | any): boolean {\r\n if (oldNode == null || newNode == null) return oldNode !== newNode;\r\n if (typeof oldNode !== typeof newNode) return true;\r\n if (typeof newNode === 'string' || typeof newNode === 'number')\r\n return oldNode !== newNode;\r\n if (newNode.type !== oldNode.type) return true;\r\n return !arePropsEqual(oldNode.props, newNode.props);\r\n}\r\n\r\nexport function shouldComponentUpdate(oldProps: any, newProps: any): boolean {\r\n return !arePropsEqual(oldProps, newProps);\r\n}\r\n","import { createElement } from './jsx-runtime.js';\r\n\r\nexport class Component {\r\n state: any = {};\r\n props: any;\r\n element: HTMLElement | null = null;\r\n private _mounted: boolean = false;\r\n\r\n constructor(props: any = {}) {\r\n this.props = props;\r\n }\r\n\r\n componentDidMount() {\r\n // Hook for after component is mounted\r\n }\r\n\r\n async setState(newState: any) {\r\n const prevState = { ...this.state };\r\n this.state = { ...prevState, ...newState };\r\n console.log(`${this.constructor.name} state updated:`, {\r\n prev: prevState,\r\n next: this.state\r\n });\r\n \r\n await Promise.resolve(); // Ensure state is updated before re-render\r\n if (this._mounted) {\r\n await this.update();\r\n } else {\r\n await this.update();\r\n }\r\n }\r\n\r\n private _replayEvents(oldElement: HTMLElement, newElement: HTMLElement) {\r\n const oldEvents = (oldElement as any).__events || {};\r\n Object.entries(oldEvents).forEach(([event, handler]) => {\r\n newElement.addEventListener(event as keyof HTMLElementEventMap, handler as EventListener);\r\n });\r\n (newElement as any).__events = oldEvents;\r\n }\r\n\r\n private _deepCloneWithEvents(node: HTMLElement): HTMLElement {\r\n const clone = node.cloneNode(false) as HTMLElement;\r\n \r\n // Copy events from original element\r\n const events = (node as any).__events || {};\r\n (clone as any).__events = events;\r\n Object.entries(events).forEach(([event, handler]) => {\r\n clone.addEventListener(event as keyof HTMLElementEventMap, handler as EventListener);\r\n });\r\n\r\n // Clone children\r\n Array.from(node.childNodes).forEach(child => {\r\n if (child instanceof HTMLElement) {\r\n clone.appendChild(this._deepCloneWithEvents(child));\r\n } else {\r\n clone.appendChild(child.cloneNode(true));\r\n }\r\n });\r\n\r\n return clone;\r\n }\r\n\r\n async update() {\r\n const vdom = this.render();\r\n if (!vdom) return document.createTextNode('');\r\n \r\n const rendered = await createElement(vdom);\r\n if (rendered instanceof HTMLElement) {\r\n return this._updateElement(rendered);\r\n }\r\n \r\n const wrapper = document.createElement('div');\r\n wrapper.appendChild(rendered);\r\n return this._updateElement(wrapper);\r\n }\r\n\r\n private async _updateElement(rendered: HTMLElement) {\r\n const newElement = this._deepCloneWithEvents(rendered);\r\n (newElement as any).__instance = this;\r\n \r\n if (!this.element) {\r\n this.element = newElement;\r\n if (!this._mounted) {\r\n this._mounted = true;\r\n queueMicrotask(() => this.componentDidMount());\r\n }\r\n } else if (this.element.parentNode) {\r\n this.element.parentNode.replaceChild(newElement, this.element);\r\n this.element = newElement;\r\n }\r\n \r\n return this.element;\r\n }\r\n\r\n render(): any {\r\n throw new Error('Component must implement render() method');\r\n }\r\n}\r\n","/**\r\n * Go WebAssembly Integration Utilities\r\n * \r\n * This module provides tools for loading and interacting with Go WASM modules\r\n * in browser and server environments.\r\n */\r\n\r\n// Type definitions for Go WASM integration\r\nexport interface GoWasmInstance {\r\n instance: WebAssembly.Instance;\r\n module: WebAssembly.Module;\r\n exports: any;\r\n functions: Record<string, Function>;\r\n}\r\n\r\nexport interface GoWasmOptions {\r\n importObject?: WebAssembly.Imports;\r\n goWasmPath?: string;\r\n loadGo?: boolean;\r\n onLoad?: (instance: GoWasmInstance) => void;\r\n debug?: boolean;\r\n}\r\n\r\nconst DEFAULT_GO_WASM_PATH = '/wasm_exec.js';\r\n\r\n/**\r\n * Load a Go WASM module from a URL\r\n */\r\nexport async function loadGoWasm(\r\n wasmUrl: string, \r\n options: GoWasmOptions = {}\r\n): Promise<GoWasmInstance> {\r\n const {\r\n importObject = {},\r\n goWasmPath = DEFAULT_GO_WASM_PATH,\r\n loadGo = true,\r\n onLoad,\r\n debug = false\r\n } = options;\r\n\r\n // In browser environment, load the Go WASM runtime\r\n if (typeof window !== 'undefined' && loadGo) {\r\n await loadGoRuntime(goWasmPath);\r\n }\r\n\r\n try {\r\n // Create Go instance for WASM\r\n // @ts-ignore - Go is loaded from the global scope\r\n const go = typeof Go !== 'undefined' ? new Go() : null;\r\n \r\n // Fetch and instantiate the WASM module\r\n if (debug) console.log(`[WASM] Loading module from ${wasmUrl}`);\r\n \r\n const response = await fetch(wasmUrl);\r\n \r\n if (!response.ok) {\r\n throw new Error(`Failed to fetch WASM module: ${response.statusText}`);\r\n }\r\n \r\n const buffer = await response.arrayBuffer();\r\n const module = await WebAssembly.compile(buffer);\r\n \r\n // Create imports object, combining Go runtime with custom imports\r\n const finalImportObject = go ? {\r\n ...go.importObject,\r\n ...importObject\r\n } : importObject;\r\n \r\n // Instantiate the WASM module\r\n const instance = await WebAssembly.instantiate(module, finalImportObject);\r\n \r\n // Initialize Go runtime if available\r\n if (go) {\r\n go.run(instance);\r\n }\r\n \r\n // Extract exported functions\r\n const exports = instance.exports;\r\n const functions: Record<string, Function> = {};\r\n \r\n // Generate wrapper functions for all exports that are functions\r\n for (const key in exports) {\r\n if (typeof exports[key] === 'function') {\r\n // Type assertion to ensure the exports[key] is callable\r\n const exportedFn = exports[key] as unknown as Function;\r\n functions[key] = (...args: any[]) => exportedFn(...args);\r\n \r\n if (debug) {\r\n const originalFn = functions[key];\r\n functions[key] = (...args: any[]) => {\r\n console.log(`[WASM] Calling ${key}(${args.join(', ')})`);\r\n const result = originalFn(...args);\r\n console.log(`[WASM] ${key} returned:`, result);\r\n return result;\r\n };\r\n }\r\n }\r\n }\r\n\r\n // Add any globally exported functions from Go\r\n if (typeof window !== 'undefined') {\r\n for (const key in window) {\r\n if (key.startsWith('go') && typeof (window as any)[key] === 'function') {\r\n // Type assertion to ensure the window[key] is callable\r\n const globalFn = (window as any)[key] as Function;\r\n functions[key] = (...args: any[]) => globalFn(...args);\r\n \r\n if (debug) {\r\n const originalFn = functions[key];\r\n functions[key] = (...args: any[]) => {\r\n console.log(`[WASM] Calling global ${key}(${args.join(', ')})`);\r\n const result = originalFn(...args);\r\n console.log(`[WASM] ${key} returned:`, result);\r\n return result;\r\n };\r\n }\r\n }\r\n }\r\n }\r\n \r\n const wasmInstance: GoWasmInstance = {\r\n instance,\r\n module,\r\n exports,\r\n functions\r\n };\r\n \r\n // Run onLoad callback if provided\r\n if (onLoad) {\r\n onLoad(wasmInstance);\r\n }\r\n \r\n return wasmInstance;\r\n } catch (error) {\r\n console.error('[WASM] Failed to load Go WASM module:', error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Load the Go WASM runtime script\r\n */\r\nasync function loadGoRuntime(path: string = DEFAULT_GO_WASM_PATH): Promise<void> {\r\n if (typeof window === 'undefined') return;\r\n \r\n // Check if Go runtime is already loaded\r\n if (typeof (window as any).Go !== 'undefined') {\r\n return;\r\n }\r\n \r\n // Load the Go WASM runtime script\r\n return new Promise((resolve, reject) => {\r\n const script = document.createElement('script');\r\n script.src = path;\r\n script.onload = () => resolve();\r\n script.onerror = () => reject(new Error(`Failed to load Go WASM runtime from ${path}`));\r\n document.head.appendChild(script);\r\n });\r\n}\r\n\r\n/**\r\n * Create a TypeScript-friendly wrapper for Go WASM functions\r\n */\r\nexport function createTypedWasmFunction<T extends (...args: any[]) => any>(\r\n instance: GoWasmInstance,\r\n functionName: string\r\n): T {\r\n if (!instance.functions[functionName]) {\r\n throw new Error(`WASM function \"${functionName}\" not found`);\r\n }\r\n \r\n return instance.functions[functionName] as T;\r\n}\r\n\r\n/**\r\n * Helper to convert JavaScript values to Go-compatible formats\r\n */\r\nexport const goValues = {\r\n // Convert JS string to Go string (returns memory pointer)\r\n stringToGo: (instance: GoWasmInstance, str: string): number => {\r\n if (!instance.functions.__stringToGo) {\r\n throw new Error('__stringToGo function not found in WASM module');\r\n }\r\n return instance.functions.__stringToGo(str);\r\n },\r\n \r\n // Convert Go string (memory pointer) to JS string\r\n stringFromGo: (instance: GoWasmInstance, ptr: number): string => {\r\n if (!instance.functions.__stringFromGo) {\r\n throw new Error('__stringFromGo function not found in WASM module');\r\n }\r\n return instance.functions.__stringFromGo(ptr);\r\n },\r\n \r\n // Convert JS object to Go (returns memory pointer)\r\n objectToGo: (instance: GoWasmInstance, obj: any): number => {\r\n if (!instance.functions.__objectToGo) {\r\n throw new Error('__objectToGo function not found in WASM module');\r\n }\r\n return instance.functions.__objectToGo(JSON.stringify(obj));\r\n },\r\n \r\n // Convert Go object (memory pointer) to JS object\r\n objectFromGo: (instance: GoWasmInstance, ptr: number): any => {\r\n if (!instance.functions.__objectFromGo) {\r\n throw new Error('__objectFromGo function not found in WASM module');\r\n }\r\n const str = instance.functions.__objectFromGo(ptr);\r\n return JSON.parse(str);\r\n }\r\n};\r\n","// Core JSX and rendering functions\r\nexport { jsx, jsxs, jsxDEV, Fragment, createElement } from './jsx-runtime.js';\r\nexport { render, hydrate } from './renderer.js';\r\n\r\n// React-like hooks\r\nexport { \r\n useState, \r\n useEffect,\r\n useMemo, \r\n useRef, \r\n useContext,\r\n useErrorBoundary\r\n} from './hooks.js';\r\n\r\n// Context API\r\nexport { createContext } from './context.js';\r\n\r\n// Server-side rendering\r\nexport { renderToString } from './server-renderer.js';\r\n\r\n// Batch updates utility\r\nexport { batchUpdates } from './batch.js';\r\n\r\n// VDOM utilities\r\nexport { diff, shouldComponentUpdate } from './vdom.js';\r\n\r\n// Component class\r\nexport { Component } from './component.js';\r\n\r\n// WASM functionality\r\nexport { \r\n loadGoWasm, \r\n createTypedWasmFunction, \r\n goValues \r\n} from './wasm.js';\r\n\r\n// Import everything for the default export object\r\nimport { jsx, jsxs, jsxDEV, Fragment, createElement } from './jsx-runtime.js';\r\nimport { render, hydrate } from './renderer.js';\r\nimport { \r\n useState, \r\n useEffect,\r\n useMemo, \r\n useRef, \r\n useContext,\r\n useErrorBoundary\r\n} from './hooks.js';\r\nimport { createContext } from './context.js';\r\nimport { renderToString } from './server-renderer.js';\r\nimport { batchUpdates } from './batch.js';\r\nimport { diff, shouldComponentUpdate } from './vdom.js';\r\nimport { Component } from './component.js';\r\nimport { \r\n loadGoWasm, \r\n createTypedWasmFunction, \r\n goValues \r\n} from './wasm.js';\r\n\r\n// Type exports\r\nexport type { VNode, ComponentType, ReactElement, Key, Ref } from './types.js';\r\nexport type { Context } from './types.js';\r\nexport type { GoWasmInstance, GoWasmOptions } from './wasm.js';\r\nexport type { \r\n StateSetter, \r\n StateHook, \r\n EffectCallback, \r\n DependencyList, \r\n MemoFactory,\r\n RefObject,\r\n MutableRefObject \r\n} from './types.js';\r\n\r\n// Default export object for compatibility\r\nconst frontendHamroun = {\r\n // JSX\r\n jsx,\r\n jsxs: jsx,\r\n jsxDEV: jsx,\r\n Fragment,\r\n createElement,\r\n \r\n // Rendering\r\n render,\r\n hydrate,\r\n \r\n // Hooks\r\n useState,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useContext,\r\n useErrorBoundary,\r\n \r\n // Context\r\n createContext,\r\n \r\n // Server rendering\r\n renderToString,\r\n \r\n // Utilities\r\n batchUpdates,\r\n diff,\r\n shouldComponentUpdate,\r\n \r\n // Component class\r\n Component,\r\n \r\n // WASM\r\n loadGoWasm,\r\n createTypedWasmFunction,\r\n goValues\r\n};\r\n\r\nexport default frontendHamroun;"],"names":["arePropsEqual","oldProps","newProps","oldKeys","Object","keys","filter","k","newKeys","length","every","key","diff","oldNode","newNode","type","props","shouldComponentUpdate","Component","constructor","this","state","element","_mounted","componentDidMount","setState","newState","prevState","console","log","name","prev","next","Promise","resolve","update","_replayEvents","oldElement","newElement","oldEvents","__events","entries","forEach","event","handler","addEventListener","_deepCloneWithEvents","node","clone","cloneNode","events","Array","from","childNodes","child","HTMLElement","appendChild","vdom","render","document","createTextNode","rendered","createElement","_updateElement","wrapper","__instance","parentNode","replaceChild","queueMicrotask","Error","DEFAULT_GO_WASM_PATH","async","loadGoWasm","wasmUrl","options","importObject","goWasmPath","loadGo","onLoad","debug","window","path","Go","reject","script","src","onload","onerror","head","loadGoRuntime","go","response","fetch","ok","statusText","buffer","arrayBuffer","module","WebAssembly","compile","finalImportObject","instance","instantiate","run","exports","functions","exportedFn","args","originalFn","join","result","startsWith","globalFn","wasmInstance","error","createTypedWasmFunction","functionName","goValues","stringToGo","str","__stringToGo","stringFromGo","ptr","__stringFromGo","objectToGo","obj","__objectToGo","JSON","stringify","objectFromGo","__objectFromGo","parse","frontendHamroun","jsx","jsxs","jsxDEV","Fragment","hydrate","useState","useEffect","useMemo","useRef","useContext","useErrorBoundary","createContext","renderToString","batchUpdates"],"mappings":"kOAMA,SAASA,EAAcC,EAAeC,GAC9B,MAAAC,EAAUC,OAAOC,KAAKJ,GAAUK,QAAOC,GAAW,aAANA,IAC5CC,EAAUJ,OAAOC,KAAKH,GAAUI,QAAOC,GAAW,aAANA,IAElD,OAAIJ,EAAQM,SAAWD,EAAQC,QACxBN,EAAQO,OAAaC,GAAAV,EAASU,KAAST,EAASS,IACzD,CAEgB,SAAAC,EAAKC,EAAsBC,GACzC,OAAe,MAAXD,GAA8B,MAAXC,EAAwBD,IAAYC,SAChDD,UAAmBC,IACP,iBAAZA,GAA2C,iBAAZA,EACjCD,IAAYC,EACjBA,EAAQC,OAASF,EAAQE,OACrBf,EAAca,EAAQG,MAAOF,EAAQE,OAC/C,CAEgB,SAAAC,EAAsBhB,EAAeC,GAC5C,OAACF,EAAcC,EAAUC,EAClC,CCvBO,MAAMgB,EAMX,WAAAC,CAAYH,EAAa,IALzBI,KAAAC,MAAa,CAAC,EAEgBD,KAAAE,QAAA,KAC9BF,KAAQG,UAAoB,EAG1BH,KAAKJ,MAAQA,CAAA,CAGf,iBAAAQ,GAAoB,CAIpB,cAAMC,CAASC,GACb,MAAMC,EAAY,IAAKP,KAAKC,OAC5BD,KAAKC,MAAQ,IAAKM,KAAcD,GAChCE,QAAQC,IAAI,GAAGT,KAAKD,YAAYW,sBAAuB,CACrDC,KAAMJ,EACNK,KAAMZ,KAAKC,cAGP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I,EAI5DI,aAAc,CAAC5B,EAA0BqB,KACnC,IAACrB,EAASI,UAAUyB,eAChB,MAAA,IAAI7D,MAAM,oDAElB,MAAMkD,EAAMlB,EAASI,UAAUyB,eAAeR,GACvC,OAAAK,KAAKI,MAAMZ,EAAG,GCvInBa,EAAkB,CAEtBC,IAAAA,EAAAA,IACAC,KAAMD,EAAAA,IACNE,OAAQF,EAAAA,IACRG,SAAAA,EAAAA,SACA1E,cAAAA,EAAAA,cAGAJ,OAAAA,EAAAA,OACA+E,QAAAA,EAAAA,QAGAC,SAAAA,EAAAA,SACAC,UAAAA,EAAAA,UACAC,QAAAA,EAAAA,QACAC,OAAAA,EAAAA,OACAC,WAAAA,EAAAA,WACAC,iBAAAA,EAAAA,iBAGAC,cAAAA,EAAAA,cAGAC,eAAAA,EAAAA,eAGAC,aAAAA,EAAAA,aACAtI,OACAK,wBAGAC,YAGAsD,aACA2C,0BACAE"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-renderer-CqIpQ-od.cjs"),r=require("./renderer-Din1y3YM.cjs"),t=require("./jsx-runtime.cjs"),s={async getServer(){throw new Error("Server module can only be used in Node.js environment")}};exports.batchUpdates=e.batchUpdates,exports.renderToString=e.renderToString,exports.useEffect=e.useEffect,exports.useErrorBoundary=e.useErrorBoundary,exports.useMemo=e.useMemo,exports.useRef=e.useRef,exports.useState=e.useState,exports.createContext=r.createContext,exports.hydrate=r.hydrate,exports.render=r.render,exports.useContext=r.useContext,exports.Fragment=t.Fragment,exports.jsx=t.jsx,exports.jsxs=t.jsx,exports.server=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-renderer-B5b0Q0ck.cjs"),r=require("./renderer-DaVfBeVi.cjs"),t=require("./jsx-runtime.cjs"),s={async getServer(){throw new Error("Server module can only be used in Node.js environment")}};exports.batchUpdates=e.batchUpdates,exports.renderToString=e.renderToString,exports.useEffect=e.useEffect,exports.useErrorBoundary=e.useErrorBoundary,exports.useMemo=e.useMemo,exports.useRef=e.useRef,exports.useState=e.useState,exports.createContext=r.createContext,exports.hydrate=r.hydrate,exports.render=r.render,exports.useContext=r.useContext,exports.Fragment=t.Fragment,exports.jsx=t.jsx,exports.jsxs=t.jsx,exports.server=s;
2
2
  //# sourceMappingURL=index.client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.client.cjs","sources":["../src/index.client.ts"],"sourcesContent":["import { createElement } from './jsx-runtime.js';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks.js';\r\n\r\nexport { \r\n useState, \r\n useEffect, \r\n useMemo, \r\n useRef,\r\n useErrorBoundary \r\n} from './hooks.js';\r\n\r\nexport { createContext, useContext } from './context.js';\r\nexport { batchUpdates } from './batch.js';\r\nexport { jsx, jsxs, Fragment } from './jsx-runtime.js';\r\nexport { render, hydrate } from './renderer.js';\r\nexport { renderToString } from './server-renderer.js';\r\n\r\n// Re-export types for client-side usage\r\nexport type { Context } from './context.js';\r\nexport type { VNode } from './types.js';\r\n\r\n// Export server types for type checking\r\nexport type {\r\n Server,\r\n ServerConfig,\r\n User,\r\n DbConfig,\r\n MiddlewareFunction\r\n} from './server-types.js';\r\n\r\n// Provide placeholder server functionality\r\nexport const server = {\r\n async getServer() {\r\n throw new Error('Server module can only be used in Node.js environment');\r\n }\r\n};\r\n\r\nlet isHydrating = false;\r\n"],"names":["server","getServer","Error"],"mappings":"sMA+BaA,EAAS,CACpB,eAAMC,GACE,MAAA,IAAIC,MAAM,wDAAuD"}
1
+ {"version":3,"file":"index.client.cjs","sources":["../src/index.client.ts"],"sourcesContent":["import { createElement } from './jsx-runtime.js';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks.js';\r\n\r\nexport { \r\n useState, \r\n useEffect, \r\n useMemo, \r\n useRef,\r\n useErrorBoundary \r\n} from './hooks.js';\r\n\r\nexport { createContext, useContext } from './context.js';\r\nexport { batchUpdates } from './batch.js';\r\nexport { jsx, jsxs, Fragment } from './jsx-runtime.js';\r\nexport { render, hydrate } from './renderer.js';\r\nexport { renderToString } from './server-renderer.js';\r\n\r\n// Re-export types for client-side usage\r\nexport type { Context } from './types.js';\r\nexport type { VNode } from './types.js';\r\n\r\n// Export server types for type checking\r\nexport type {\r\n Server,\r\n ServerConfig,\r\n User,\r\n DbConfig,\r\n MiddlewareFunction\r\n} from './server-types.js';\r\n\r\n// Provide placeholder server functionality\r\nexport const server = {\r\n async getServer() {\r\n throw new Error('Server module can only be used in Node.js environment');\r\n }\r\n};\r\n\r\nlet isHydrating = false;\r\n"],"names":["server","getServer","Error"],"mappings":"sMA+BaA,EAAS,CACpB,eAAMC,GACE,MAAA,IAAIC,MAAM,wDAAuD"}
@@ -1,5 +1,5 @@
1
- import { b, r, d, u, c, a, e } from "./server-renderer-QHt45Ip2.js";
2
- import { c as c2, h, r as r2, u as u2 } from "./renderer-Bo9zkUZ_.js";
1
+ import { b, r, d, u, c, a, e } from "./server-renderer-C4MB-jAp.js";
2
+ import { c as c2, h, r as r2, u as u2 } from "./renderer-nfT7XSpo.js";
3
3
  import { Fragment, jsx, jsx as jsx2 } from "./jsx-runtime.js";
4
4
  const server = {
5
5
  async getServer() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.client.js","sources":["../src/index.client.ts"],"sourcesContent":["import { createElement } from './jsx-runtime.js';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks.js';\r\n\r\nexport { \r\n useState, \r\n useEffect, \r\n useMemo, \r\n useRef,\r\n useErrorBoundary \r\n} from './hooks.js';\r\n\r\nexport { createContext, useContext } from './context.js';\r\nexport { batchUpdates } from './batch.js';\r\nexport { jsx, jsxs, Fragment } from './jsx-runtime.js';\r\nexport { render, hydrate } from './renderer.js';\r\nexport { renderToString } from './server-renderer.js';\r\n\r\n// Re-export types for client-side usage\r\nexport type { Context } from './context.js';\r\nexport type { VNode } from './types.js';\r\n\r\n// Export server types for type checking\r\nexport type {\r\n Server,\r\n ServerConfig,\r\n User,\r\n DbConfig,\r\n MiddlewareFunction\r\n} from './server-types.js';\r\n\r\n// Provide placeholder server functionality\r\nexport const server = {\r\n async getServer() {\r\n throw new Error('Server module can only be used in Node.js environment');\r\n }\r\n};\r\n\r\nlet isHydrating = false;\r\n"],"names":[],"mappings":";;;AA+BO,MAAM,SAAS;AAAA,EACpB,MAAM,YAAY;AACV,UAAA,IAAI,MAAM,uDAAuD;AAAA,EAAA;AAE3E;"}
1
+ {"version":3,"file":"index.client.js","sources":["../src/index.client.ts"],"sourcesContent":["import { createElement } from './jsx-runtime.js';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks.js';\r\n\r\nexport { \r\n useState, \r\n useEffect, \r\n useMemo, \r\n useRef,\r\n useErrorBoundary \r\n} from './hooks.js';\r\n\r\nexport { createContext, useContext } from './context.js';\r\nexport { batchUpdates } from './batch.js';\r\nexport { jsx, jsxs, Fragment } from './jsx-runtime.js';\r\nexport { render, hydrate } from './renderer.js';\r\nexport { renderToString } from './server-renderer.js';\r\n\r\n// Re-export types for client-side usage\r\nexport type { Context } from './types.js';\r\nexport type { VNode } from './types.js';\r\n\r\n// Export server types for type checking\r\nexport type {\r\n Server,\r\n ServerConfig,\r\n User,\r\n DbConfig,\r\n MiddlewareFunction\r\n} from './server-types.js';\r\n\r\n// Provide placeholder server functionality\r\nexport const server = {\r\n async getServer() {\r\n throw new Error('Server module can only be used in Node.js environment');\r\n }\r\n};\r\n\r\nlet isHydrating = false;\r\n"],"names":[],"mappings":";;;AA+BO,MAAM,SAAS;AAAA,EACpB,MAAM,YAAY;AACV,UAAA,IAAI,MAAM,uDAAuD;AAAA,EAAA;AAE3E;"}
package/dist/index.js CHANGED
@@ -1,9 +1,101 @@
1
- import { createElement, jsx, Fragment } from "./jsx-runtime.js";
2
- import { c as createContext, u as useContext, h as hydrate, r as render } from "./renderer-Bo9zkUZ_.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-QHt45Ip2.js";
4
- import { f, g, i, p, s } from "./server-renderer-QHt45Ip2.js";
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";
4
+ 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]);
9
+ }
10
+ 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);
17
+ }
18
+ function shouldComponentUpdate(oldProps, newProps) {
19
+ return !arePropsEqual(oldProps, newProps);
20
+ }
21
+ 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);
57
+ });
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
+ }
64
+ });
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
+ }
5
97
  const DEFAULT_GO_WASM_PATH = "/wasm_exec.js";
6
- async function loadGoWasm$1(wasmUrl, options = {}) {
98
+ async function loadGoWasm(wasmUrl, options = {}) {
7
99
  const {
8
100
  importObject = {},
9
101
  goWasmPath = DEFAULT_GO_WASM_PATH,
@@ -93,13 +185,13 @@ async function loadGoRuntime(path = DEFAULT_GO_WASM_PATH) {
93
185
  document.head.appendChild(script);
94
186
  });
95
187
  }
96
- function createTypedWasmFunction$1(instance, functionName) {
188
+ function createTypedWasmFunction(instance, functionName) {
97
189
  if (!instance.functions[functionName]) {
98
190
  throw new Error(`WASM function "${functionName}" not found`);
99
191
  }
100
192
  return instance.functions[functionName];
101
193
  }
102
- const goValues$1 = {
194
+ const goValues = {
103
195
  // Convert JS string to Go string (returns memory pointer)
104
196
  stringToGo: (instance, str) => {
105
197
  if (!instance.functions.__stringToGo) {
@@ -130,138 +222,37 @@ const goValues$1 = {
130
222
  return JSON.parse(str);
131
223
  }
132
224
  };
133
- function arePropsEqual(oldProps, newProps) {
134
- const oldKeys = Object.keys(oldProps).filter((k) => k !== "children");
135
- const newKeys = Object.keys(newProps).filter((k) => k !== "children");
136
- if (oldKeys.length !== newKeys.length) return false;
137
- return oldKeys.every((key) => oldProps[key] === newProps[key]);
138
- }
139
- function diff(oldNode, newNode) {
140
- if (oldNode == null || newNode == null) return oldNode !== newNode;
141
- if (typeof oldNode !== typeof newNode) return true;
142
- if (typeof newNode === "string" || typeof newNode === "number")
143
- return oldNode !== newNode;
144
- if (newNode.type !== oldNode.type) return true;
145
- return !arePropsEqual(oldNode.props, newNode.props);
146
- }
147
- function shouldComponentUpdate(oldProps, newProps) {
148
- return !arePropsEqual(oldProps, newProps);
149
- }
150
- class Component {
151
- constructor(props = {}) {
152
- this.state = {};
153
- this.element = null;
154
- this._mounted = false;
155
- this.props = props;
156
- }
157
- componentDidMount() {
158
- }
159
- async setState(newState) {
160
- const prevState = { ...this.state };
161
- this.state = { ...prevState, ...newState };
162
- console.log(`${this.constructor.name} state updated:`, {
163
- prev: prevState,
164
- next: this.state
165
- });
166
- await Promise.resolve();
167
- if (this._mounted) {
168
- await this.update();
169
- } else {
170
- await this.update();
171
- }
172
- }
173
- _replayEvents(oldElement, newElement) {
174
- const oldEvents = oldElement.__events || {};
175
- Object.entries(oldEvents).forEach(([event, handler]) => {
176
- newElement.addEventListener(event, handler);
177
- });
178
- newElement.__events = oldEvents;
179
- }
180
- _deepCloneWithEvents(node) {
181
- const clone = node.cloneNode(false);
182
- const events = node.__events || {};
183
- clone.__events = events;
184
- Object.entries(events).forEach(([event, handler]) => {
185
- clone.addEventListener(event, handler);
186
- });
187
- Array.from(node.childNodes).forEach((child) => {
188
- if (child instanceof HTMLElement) {
189
- clone.appendChild(this._deepCloneWithEvents(child));
190
- } else {
191
- clone.appendChild(child.cloneNode(true));
192
- }
193
- });
194
- return clone;
195
- }
196
- async update() {
197
- const vdom = this.render();
198
- if (!vdom) return document.createTextNode("");
199
- const rendered = await createElement(vdom);
200
- if (rendered instanceof HTMLElement) {
201
- return this._updateElement(rendered);
202
- }
203
- const wrapper = document.createElement("div");
204
- wrapper.appendChild(rendered);
205
- return this._updateElement(wrapper);
206
- }
207
- async _updateElement(rendered) {
208
- const newElement = this._deepCloneWithEvents(rendered);
209
- newElement.__instance = this;
210
- if (!this.element) {
211
- this.element = newElement;
212
- if (!this._mounted) {
213
- this._mounted = true;
214
- queueMicrotask(() => this.componentDidMount());
215
- }
216
- } else if (this.element.parentNode) {
217
- this.element.parentNode.replaceChild(newElement, this.element);
218
- this.element = newElement;
219
- }
220
- return this.element;
221
- }
222
- render() {
223
- throw new Error("Component must implement render() method");
224
- }
225
- }
226
- const server = {
227
- async getServer() {
228
- throw new Error("Server module can only be used in Node.js environment");
229
- }
230
- };
231
- const loadGoWasm = loadGoWasm$1;
232
- const createTypedWasmFunction = createTypedWasmFunction$1;
233
- const goValues = goValues$1;
234
- const wasm = {
235
- loadGoWasm: loadGoWasm$1,
236
- createTypedWasmFunction: createTypedWasmFunction$1,
237
- goValues: goValues$1
238
- };
239
- let isHydrating = false;
240
- const index = {
241
- Fragment,
225
+ const frontendHamroun = {
226
+ // JSX
242
227
  jsx,
243
228
  jsxs: jsx,
229
+ jsxDEV: jsx,
230
+ Fragment,
244
231
  createElement,
232
+ // Rendering
245
233
  render,
246
234
  hydrate,
235
+ // Hooks
247
236
  useState,
248
237
  useEffect,
249
238
  useMemo,
250
239
  useRef,
251
240
  useContext,
252
241
  useErrorBoundary,
242
+ // Context
253
243
  createContext,
244
+ // Server rendering
254
245
  renderToString,
246
+ // Utilities
255
247
  batchUpdates,
256
- server,
248
+ diff,
249
+ shouldComponentUpdate,
250
+ // Component class
251
+ Component,
252
+ // WASM
257
253
  loadGoWasm,
258
254
  createTypedWasmFunction,
259
- goValues,
260
- wasm,
261
- Component,
262
- diff,
263
- shouldComponentUpdate
264
- // Server functionality is exposed through the server export
255
+ goValues
265
256
  };
266
257
  export {
267
258
  Component,
@@ -270,30 +261,22 @@ export {
270
261
  createContext,
271
262
  createElement,
272
263
  createTypedWasmFunction,
273
- index as default,
264
+ frontendHamroun as default,
274
265
  diff,
275
- f as finishRender,
276
- g as getIsBatching,
277
266
  goValues,
278
267
  hydrate,
279
- i as isBatching,
280
- isHydrating,
281
268
  jsx,
282
269
  jsx as jsxDEV,
283
270
  jsx as jsxs,
284
271
  loadGoWasm,
285
- p as prepareRender,
286
272
  render,
287
273
  renderToString,
288
- server,
289
- s as setRenderCallback,
290
274
  shouldComponentUpdate,
291
275
  useContext,
292
276
  useEffect,
293
277
  useErrorBoundary,
294
278
  useMemo,
295
279
  useRef,
296
- useState,
297
- wasm
280
+ useState
298
281
  };
299
282
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/wasm.ts","../src/vdom.ts","../src/component.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Go WebAssembly Integration Utilities\r\n * \r\n * This module provides tools for loading and interacting with Go WASM modules\r\n * in browser and server environments.\r\n */\r\n\r\n// Type definitions for Go WASM integration\r\nexport interface GoWasmInstance {\r\n instance: WebAssembly.Instance;\r\n module: WebAssembly.Module;\r\n exports: any;\r\n functions: Record<string, Function>;\r\n}\r\n\r\nexport interface GoWasmOptions {\r\n importObject?: WebAssembly.Imports;\r\n goWasmPath?: string;\r\n loadGo?: boolean;\r\n onLoad?: (instance: GoWasmInstance) => void;\r\n debug?: boolean;\r\n}\r\n\r\nconst DEFAULT_GO_WASM_PATH = '/wasm_exec.js';\r\n\r\n/**\r\n * Load a Go WASM module from a URL\r\n */\r\nexport async function loadGoWasm(\r\n wasmUrl: string, \r\n options: GoWasmOptions = {}\r\n): Promise<GoWasmInstance> {\r\n const {\r\n importObject = {},\r\n goWasmPath = DEFAULT_GO_WASM_PATH,\r\n loadGo = true,\r\n onLoad,\r\n debug = false\r\n } = options;\r\n\r\n // In browser environment, load the Go WASM runtime\r\n if (typeof window !== 'undefined' && loadGo) {\r\n await loadGoRuntime(goWasmPath);\r\n }\r\n\r\n try {\r\n // Create Go instance for WASM\r\n // @ts-ignore - Go is loaded from the global scope\r\n const go = typeof Go !== 'undefined' ? new Go() : null;\r\n \r\n // Fetch and instantiate the WASM module\r\n if (debug) console.log(`[WASM] Loading module from ${wasmUrl}`);\r\n \r\n const response = await fetch(wasmUrl);\r\n \r\n if (!response.ok) {\r\n throw new Error(`Failed to fetch WASM module: ${response.statusText}`);\r\n }\r\n \r\n const buffer = await response.arrayBuffer();\r\n const module = await WebAssembly.compile(buffer);\r\n \r\n // Create imports object, combining Go runtime with custom imports\r\n const finalImportObject = go ? {\r\n ...go.importObject,\r\n ...importObject\r\n } : importObject;\r\n \r\n // Instantiate the WASM module\r\n const instance = await WebAssembly.instantiate(module, finalImportObject);\r\n \r\n // Initialize Go runtime if available\r\n if (go) {\r\n go.run(instance);\r\n }\r\n \r\n // Extract exported functions\r\n const exports = instance.exports;\r\n const functions: Record<string, Function> = {};\r\n \r\n // Generate wrapper functions for all exports that are functions\r\n for (const key in exports) {\r\n if (typeof exports[key] === 'function') {\r\n // Type assertion to ensure the exports[key] is callable\r\n const exportedFn = exports[key] as unknown as Function;\r\n functions[key] = (...args: any[]) => exportedFn(...args);\r\n \r\n if (debug) {\r\n const originalFn = functions[key];\r\n functions[key] = (...args: any[]) => {\r\n console.log(`[WASM] Calling ${key}(${args.join(', ')})`);\r\n const result = originalFn(...args);\r\n console.log(`[WASM] ${key} returned:`, result);\r\n return result;\r\n };\r\n }\r\n }\r\n }\r\n\r\n // Add any globally exported functions from Go\r\n if (typeof window !== 'undefined') {\r\n for (const key in window) {\r\n if (key.startsWith('go') && typeof (window as any)[key] === 'function') {\r\n // Type assertion to ensure the window[key] is callable\r\n const globalFn = (window as any)[key] as Function;\r\n functions[key] = (...args: any[]) => globalFn(...args);\r\n \r\n if (debug) {\r\n const originalFn = functions[key];\r\n functions[key] = (...args: any[]) => {\r\n console.log(`[WASM] Calling global ${key}(${args.join(', ')})`);\r\n const result = originalFn(...args);\r\n console.log(`[WASM] ${key} returned:`, result);\r\n return result;\r\n };\r\n }\r\n }\r\n }\r\n }\r\n \r\n const wasmInstance: GoWasmInstance = {\r\n instance,\r\n module,\r\n exports,\r\n functions\r\n };\r\n \r\n // Run onLoad callback if provided\r\n if (onLoad) {\r\n onLoad(wasmInstance);\r\n }\r\n \r\n return wasmInstance;\r\n } catch (error) {\r\n console.error('[WASM] Failed to load Go WASM module:', error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Load the Go WASM runtime script\r\n */\r\nasync function loadGoRuntime(path: string = DEFAULT_GO_WASM_PATH): Promise<void> {\r\n if (typeof window === 'undefined') return;\r\n \r\n // Check if Go runtime is already loaded\r\n if (typeof (window as any).Go !== 'undefined') {\r\n return;\r\n }\r\n \r\n // Load the Go WASM runtime script\r\n return new Promise((resolve, reject) => {\r\n const script = document.createElement('script');\r\n script.src = path;\r\n script.onload = () => resolve();\r\n script.onerror = () => reject(new Error(`Failed to load Go WASM runtime from ${path}`));\r\n document.head.appendChild(script);\r\n });\r\n}\r\n\r\n/**\r\n * Create a TypeScript-friendly wrapper for Go WASM functions\r\n */\r\nexport function createTypedWasmFunction<T extends (...args: any[]) => any>(\r\n instance: GoWasmInstance,\r\n functionName: string\r\n): T {\r\n if (!instance.functions[functionName]) {\r\n throw new Error(`WASM function \"${functionName}\" not found`);\r\n }\r\n \r\n return instance.functions[functionName] as T;\r\n}\r\n\r\n/**\r\n * Helper to convert JavaScript values to Go-compatible formats\r\n */\r\nexport const goValues = {\r\n // Convert JS string to Go string (returns memory pointer)\r\n stringToGo: (instance: GoWasmInstance, str: string): number => {\r\n if (!instance.functions.__stringToGo) {\r\n throw new Error('__stringToGo function not found in WASM module');\r\n }\r\n return instance.functions.__stringToGo(str);\r\n },\r\n \r\n // Convert Go string (memory pointer) to JS string\r\n stringFromGo: (instance: GoWasmInstance, ptr: number): string => {\r\n if (!instance.functions.__stringFromGo) {\r\n throw new Error('__stringFromGo function not found in WASM module');\r\n }\r\n return instance.functions.__stringFromGo(ptr);\r\n },\r\n \r\n // Convert JS object to Go (returns memory pointer)\r\n objectToGo: (instance: GoWasmInstance, obj: any): number => {\r\n if (!instance.functions.__objectToGo) {\r\n throw new Error('__objectToGo function not found in WASM module');\r\n }\r\n return instance.functions.__objectToGo(JSON.stringify(obj));\r\n },\r\n \r\n // Convert Go object (memory pointer) to JS object\r\n objectFromGo: (instance: GoWasmInstance, ptr: number): any => {\r\n if (!instance.functions.__objectFromGo) {\r\n throw new Error('__objectFromGo function not found in WASM module');\r\n }\r\n const str = instance.functions.__objectFromGo(ptr);\r\n return JSON.parse(str);\r\n }\r\n};\r\n","interface VNode {\r\n type: string | Function;\r\n props: Record<string, any>;\r\n key?: string | number;\r\n}\r\n\r\nfunction arePropsEqual(oldProps: any, newProps: any): boolean {\r\n const oldKeys = Object.keys(oldProps).filter(k => k !== 'children');\r\n const newKeys = Object.keys(newProps).filter(k => k !== 'children');\r\n \r\n if (oldKeys.length !== newKeys.length) return false;\r\n return oldKeys.every(key => oldProps[key] === newProps[key]);\r\n}\r\n\r\nexport function diff(oldNode: VNode | any, newNode: VNode | any): boolean {\r\n if (oldNode == null || newNode == null) return oldNode !== newNode;\r\n if (typeof oldNode !== typeof newNode) return true;\r\n if (typeof newNode === 'string' || typeof newNode === 'number')\r\n return oldNode !== newNode;\r\n if (newNode.type !== oldNode.type) return true;\r\n return !arePropsEqual(oldNode.props, newNode.props);\r\n}\r\n\r\nexport function shouldComponentUpdate(oldProps: any, newProps: any): boolean {\r\n return !arePropsEqual(oldProps, newProps);\r\n}\r\n","import { createElement } from './jsx-runtime.js';\r\n\r\nexport class Component {\r\n state: any = {};\r\n props: any;\r\n element: HTMLElement | null = null;\r\n private _mounted: boolean = false;\r\n\r\n constructor(props: any = {}) {\r\n this.props = props;\r\n }\r\n\r\n componentDidMount() {\r\n // Hook for after component is mounted\r\n }\r\n\r\n async setState(newState: any) {\r\n const prevState = { ...this.state };\r\n this.state = { ...prevState, ...newState };\r\n console.log(`${this.constructor.name} state updated:`, {\r\n prev: prevState,\r\n next: this.state\r\n });\r\n \r\n await Promise.resolve(); // Ensure state is updated before re-render\r\n if (this._mounted) {\r\n await this.update();\r\n } else {\r\n await this.update();\r\n }\r\n }\r\n\r\n private _replayEvents(oldElement: HTMLElement, newElement: HTMLElement) {\r\n const oldEvents = (oldElement as any).__events || {};\r\n Object.entries(oldEvents).forEach(([event, handler]) => {\r\n newElement.addEventListener(event as keyof HTMLElementEventMap, handler as EventListener);\r\n });\r\n (newElement as any).__events = oldEvents;\r\n }\r\n\r\n private _deepCloneWithEvents(node: HTMLElement): HTMLElement {\r\n const clone = node.cloneNode(false) as HTMLElement;\r\n \r\n // Copy events from original element\r\n const events = (node as any).__events || {};\r\n (clone as any).__events = events;\r\n Object.entries(events).forEach(([event, handler]) => {\r\n clone.addEventListener(event as keyof HTMLElementEventMap, handler as EventListener);\r\n });\r\n\r\n // Clone children\r\n Array.from(node.childNodes).forEach(child => {\r\n if (child instanceof HTMLElement) {\r\n clone.appendChild(this._deepCloneWithEvents(child));\r\n } else {\r\n clone.appendChild(child.cloneNode(true));\r\n }\r\n });\r\n\r\n return clone;\r\n }\r\n\r\n async update() {\r\n const vdom = this.render();\r\n if (!vdom) return document.createTextNode('');\r\n \r\n const rendered = await createElement(vdom);\r\n if (rendered instanceof HTMLElement) {\r\n return this._updateElement(rendered);\r\n }\r\n \r\n const wrapper = document.createElement('div');\r\n wrapper.appendChild(rendered);\r\n return this._updateElement(wrapper);\r\n }\r\n\r\n private async _updateElement(rendered: HTMLElement) {\r\n const newElement = this._deepCloneWithEvents(rendered);\r\n (newElement as any).__instance = this;\r\n \r\n if (!this.element) {\r\n this.element = newElement;\r\n if (!this._mounted) {\r\n this._mounted = true;\r\n queueMicrotask(() => this.componentDidMount());\r\n }\r\n } else if (this.element.parentNode) {\r\n this.element.parentNode.replaceChild(newElement, this.element);\r\n this.element = newElement;\r\n }\r\n \r\n return this.element;\r\n }\r\n\r\n render(): any {\r\n throw new Error('Component must implement render() method');\r\n }\r\n}\r\n","import { createElement } from './jsx-runtime.js';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks.js';\r\nimport { \r\n loadGoWasm as loadGoWasmImpl, \r\n createTypedWasmFunction as createTypedWasmFunctionImpl,\r\n goValues as goValuesImpl,\r\n type GoWasmInstance,\r\n type GoWasmOptions\r\n} from './wasm.js';\r\n\r\n// Import items needed for the default export\r\nimport { jsx, jsxs, jsxDEV, Fragment } from './jsx-runtime.js';\r\nimport { render, hydrate } from './renderer.js';\r\nimport { \r\n useState, \r\n useEffect,\r\n useMemo, \r\n useRef, \r\n useContext,\r\n useErrorBoundary\r\n} from './hooks.js';\r\nimport { createContext } from './context.js';\r\nimport { renderToString } from './server-renderer.js';\r\nimport { batchUpdates, isBatching, getIsBatching } from './batch.js';\r\nimport { diff, shouldComponentUpdate } from './vdom.js';\r\nimport { Component } from './component.js';\r\n\r\n// Re-export core modules with explicit names to ensure they appear in bundle\r\nexport { render, hydrate } from './renderer.js';\r\nexport { \r\n jsx, \r\n jsxs, \r\n jsxDEV,\r\n Fragment, \r\n createElement \r\n} from './jsx-runtime.js';\r\n\r\nexport { \r\n useState, \r\n useEffect,\r\n useMemo, \r\n useRef, \r\n useContext,\r\n useErrorBoundary,\r\n prepareRender,\r\n finishRender,\r\n setRenderCallback\r\n} from './hooks.js';\r\n\r\n// Context API\r\nexport { createContext } from './context.js';\r\n\r\n// Server-side rendering\r\nexport { renderToString } from './server-renderer.js';\r\n\r\n// Batch updates utility\r\nexport { batchUpdates, isBatching, getIsBatching } from './batch.js';\r\n\r\n// VDOM utilities\r\nexport { diff, shouldComponentUpdate } from './vdom.js';\r\n\r\n// Export Component class\r\nexport { Component } from './component.js';\r\n\r\n// Server module stub for browser environments\r\nexport const server = {\r\n async getServer() {\r\n throw new Error(\"Server module can only be used in Node.js environment\");\r\n }\r\n};\r\n\r\n// Export WASM functionality explicitly\r\nexport const loadGoWasm = loadGoWasmImpl;\r\nexport const createTypedWasmFunction = createTypedWasmFunctionImpl;\r\nexport const goValues = goValuesImpl;\r\nexport type { GoWasmInstance, GoWasmOptions } from './wasm.js';\r\n\r\n// Add wasm object to ensure compatibility with existing dist/index.js\r\nexport const wasm = {\r\n loadGoWasm: loadGoWasmImpl,\r\n createTypedWasmFunction: createTypedWasmFunctionImpl,\r\n goValues: goValuesImpl\r\n};\r\n\r\n// Re-export types\r\nexport type { Context } from './context.js';\r\nexport type { VNode } from './types.js';\r\n\r\n// Export server types from the safe type-only file\r\nexport type { \r\n Server, \r\n ServerConfig, \r\n User, \r\n DbConfig, \r\n MiddlewareFunction \r\n} from './server-types.js';\r\n\r\n// Export this so it can be properly identified in the bundle\r\nexport let isHydrating = false;\r\n\r\n// Default export for compatibility with some module systems\r\nexport default {\r\n Fragment,\r\n jsx,\r\n jsxs,\r\n createElement,\r\n render, \r\n hydrate,\r\n useState,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useContext,\r\n useErrorBoundary,\r\n createContext,\r\n renderToString,\r\n batchUpdates,\r\n server,\r\n loadGoWasm,\r\n createTypedWasmFunction,\r\n goValues,\r\n wasm,\r\n Component,\r\n diff,\r\n shouldComponentUpdate\r\n // Server functionality is exposed through the server export\r\n};\r\n"],"names":["loadGoWasm","createTypedWasmFunction","goValues","loadGoWasmImpl","createTypedWasmFunctionImpl","goValuesImpl","jsxs"],"mappings":";;;;AAuBA,MAAM,uBAAuB;AAK7B,eAAsBA,aACpB,SACA,UAAyB,IACA;AACnB,QAAA;AAAA,IACJ,eAAe,CAAC;AAAA,IAChB,aAAa;AAAA,IACb,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,EAAA,IACN;AAGA,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AAA,EACA;AAAA,EAAA,MACAC;AAAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAEF;"}
1
+ {"version":3,"file":"index.js","sources":["../src/vdom.ts","../src/component.ts","../src/wasm.ts","../src/index.ts"],"sourcesContent":["interface VNode {\r\n type: string | Function;\r\n props: Record<string, any>;\r\n key?: string | number;\r\n}\r\n\r\nfunction arePropsEqual(oldProps: any, newProps: any): boolean {\r\n const oldKeys = Object.keys(oldProps).filter(k => k !== 'children');\r\n const newKeys = Object.keys(newProps).filter(k => k !== 'children');\r\n \r\n if (oldKeys.length !== newKeys.length) return false;\r\n return oldKeys.every(key => oldProps[key] === newProps[key]);\r\n}\r\n\r\nexport function diff(oldNode: VNode | any, newNode: VNode | any): boolean {\r\n if (oldNode == null || newNode == null) return oldNode !== newNode;\r\n if (typeof oldNode !== typeof newNode) return true;\r\n if (typeof newNode === 'string' || typeof newNode === 'number')\r\n return oldNode !== newNode;\r\n if (newNode.type !== oldNode.type) return true;\r\n return !arePropsEqual(oldNode.props, newNode.props);\r\n}\r\n\r\nexport function shouldComponentUpdate(oldProps: any, newProps: any): boolean {\r\n return !arePropsEqual(oldProps, newProps);\r\n}\r\n","import { createElement } from './jsx-runtime.js';\r\n\r\nexport class Component {\r\n state: any = {};\r\n props: any;\r\n element: HTMLElement | null = null;\r\n private _mounted: boolean = false;\r\n\r\n constructor(props: any = {}) {\r\n this.props = props;\r\n }\r\n\r\n componentDidMount() {\r\n // Hook for after component is mounted\r\n }\r\n\r\n async setState(newState: any) {\r\n const prevState = { ...this.state };\r\n this.state = { ...prevState, ...newState };\r\n console.log(`${this.constructor.name} state updated:`, {\r\n prev: prevState,\r\n next: this.state\r\n });\r\n \r\n await Promise.resolve(); // Ensure state is updated before re-render\r\n if (this._mounted) {\r\n await this.update();\r\n } else {\r\n await this.update();\r\n }\r\n }\r\n\r\n private _replayEvents(oldElement: HTMLElement, newElement: HTMLElement) {\r\n const oldEvents = (oldElement as any).__events || {};\r\n Object.entries(oldEvents).forEach(([event, handler]) => {\r\n newElement.addEventListener(event as keyof HTMLElementEventMap, handler as EventListener);\r\n });\r\n (newElement as any).__events = oldEvents;\r\n }\r\n\r\n private _deepCloneWithEvents(node: HTMLElement): HTMLElement {\r\n const clone = node.cloneNode(false) as HTMLElement;\r\n \r\n // Copy events from original element\r\n const events = (node as any).__events || {};\r\n (clone as any).__events = events;\r\n Object.entries(events).forEach(([event, handler]) => {\r\n clone.addEventListener(event as keyof HTMLElementEventMap, handler as EventListener);\r\n });\r\n\r\n // Clone children\r\n Array.from(node.childNodes).forEach(child => {\r\n if (child instanceof HTMLElement) {\r\n clone.appendChild(this._deepCloneWithEvents(child));\r\n } else {\r\n clone.appendChild(child.cloneNode(true));\r\n }\r\n });\r\n\r\n return clone;\r\n }\r\n\r\n async update() {\r\n const vdom = this.render();\r\n if (!vdom) return document.createTextNode('');\r\n \r\n const rendered = await createElement(vdom);\r\n if (rendered instanceof HTMLElement) {\r\n return this._updateElement(rendered);\r\n }\r\n \r\n const wrapper = document.createElement('div');\r\n wrapper.appendChild(rendered);\r\n return this._updateElement(wrapper);\r\n }\r\n\r\n private async _updateElement(rendered: HTMLElement) {\r\n const newElement = this._deepCloneWithEvents(rendered);\r\n (newElement as any).__instance = this;\r\n \r\n if (!this.element) {\r\n this.element = newElement;\r\n if (!this._mounted) {\r\n this._mounted = true;\r\n queueMicrotask(() => this.componentDidMount());\r\n }\r\n } else if (this.element.parentNode) {\r\n this.element.parentNode.replaceChild(newElement, this.element);\r\n this.element = newElement;\r\n }\r\n \r\n return this.element;\r\n }\r\n\r\n render(): any {\r\n throw new Error('Component must implement render() method');\r\n }\r\n}\r\n","/**\r\n * Go WebAssembly Integration Utilities\r\n * \r\n * This module provides tools for loading and interacting with Go WASM modules\r\n * in browser and server environments.\r\n */\r\n\r\n// Type definitions for Go WASM integration\r\nexport interface GoWasmInstance {\r\n instance: WebAssembly.Instance;\r\n module: WebAssembly.Module;\r\n exports: any;\r\n functions: Record<string, Function>;\r\n}\r\n\r\nexport interface GoWasmOptions {\r\n importObject?: WebAssembly.Imports;\r\n goWasmPath?: string;\r\n loadGo?: boolean;\r\n onLoad?: (instance: GoWasmInstance) => void;\r\n debug?: boolean;\r\n}\r\n\r\nconst DEFAULT_GO_WASM_PATH = '/wasm_exec.js';\r\n\r\n/**\r\n * Load a Go WASM module from a URL\r\n */\r\nexport async function loadGoWasm(\r\n wasmUrl: string, \r\n options: GoWasmOptions = {}\r\n): Promise<GoWasmInstance> {\r\n const {\r\n importObject = {},\r\n goWasmPath = DEFAULT_GO_WASM_PATH,\r\n loadGo = true,\r\n onLoad,\r\n debug = false\r\n } = options;\r\n\r\n // In browser environment, load the Go WASM runtime\r\n if (typeof window !== 'undefined' && loadGo) {\r\n await loadGoRuntime(goWasmPath);\r\n }\r\n\r\n try {\r\n // Create Go instance for WASM\r\n // @ts-ignore - Go is loaded from the global scope\r\n const go = typeof Go !== 'undefined' ? new Go() : null;\r\n \r\n // Fetch and instantiate the WASM module\r\n if (debug) console.log(`[WASM] Loading module from ${wasmUrl}`);\r\n \r\n const response = await fetch(wasmUrl);\r\n \r\n if (!response.ok) {\r\n throw new Error(`Failed to fetch WASM module: ${response.statusText}`);\r\n }\r\n \r\n const buffer = await response.arrayBuffer();\r\n const module = await WebAssembly.compile(buffer);\r\n \r\n // Create imports object, combining Go runtime with custom imports\r\n const finalImportObject = go ? {\r\n ...go.importObject,\r\n ...importObject\r\n } : importObject;\r\n \r\n // Instantiate the WASM module\r\n const instance = await WebAssembly.instantiate(module, finalImportObject);\r\n \r\n // Initialize Go runtime if available\r\n if (go) {\r\n go.run(instance);\r\n }\r\n \r\n // Extract exported functions\r\n const exports = instance.exports;\r\n const functions: Record<string, Function> = {};\r\n \r\n // Generate wrapper functions for all exports that are functions\r\n for (const key in exports) {\r\n if (typeof exports[key] === 'function') {\r\n // Type assertion to ensure the exports[key] is callable\r\n const exportedFn = exports[key] as unknown as Function;\r\n functions[key] = (...args: any[]) => exportedFn(...args);\r\n \r\n if (debug) {\r\n const originalFn = functions[key];\r\n functions[key] = (...args: any[]) => {\r\n console.log(`[WASM] Calling ${key}(${args.join(', ')})`);\r\n const result = originalFn(...args);\r\n console.log(`[WASM] ${key} returned:`, result);\r\n return result;\r\n };\r\n }\r\n }\r\n }\r\n\r\n // Add any globally exported functions from Go\r\n if (typeof window !== 'undefined') {\r\n for (const key in window) {\r\n if (key.startsWith('go') && typeof (window as any)[key] === 'function') {\r\n // Type assertion to ensure the window[key] is callable\r\n const globalFn = (window as any)[key] as Function;\r\n functions[key] = (...args: any[]) => globalFn(...args);\r\n \r\n if (debug) {\r\n const originalFn = functions[key];\r\n functions[key] = (...args: any[]) => {\r\n console.log(`[WASM] Calling global ${key}(${args.join(', ')})`);\r\n const result = originalFn(...args);\r\n console.log(`[WASM] ${key} returned:`, result);\r\n return result;\r\n };\r\n }\r\n }\r\n }\r\n }\r\n \r\n const wasmInstance: GoWasmInstance = {\r\n instance,\r\n module,\r\n exports,\r\n functions\r\n };\r\n \r\n // Run onLoad callback if provided\r\n if (onLoad) {\r\n onLoad(wasmInstance);\r\n }\r\n \r\n return wasmInstance;\r\n } catch (error) {\r\n console.error('[WASM] Failed to load Go WASM module:', error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Load the Go WASM runtime script\r\n */\r\nasync function loadGoRuntime(path: string = DEFAULT_GO_WASM_PATH): Promise<void> {\r\n if (typeof window === 'undefined') return;\r\n \r\n // Check if Go runtime is already loaded\r\n if (typeof (window as any).Go !== 'undefined') {\r\n return;\r\n }\r\n \r\n // Load the Go WASM runtime script\r\n return new Promise((resolve, reject) => {\r\n const script = document.createElement('script');\r\n script.src = path;\r\n script.onload = () => resolve();\r\n script.onerror = () => reject(new Error(`Failed to load Go WASM runtime from ${path}`));\r\n document.head.appendChild(script);\r\n });\r\n}\r\n\r\n/**\r\n * Create a TypeScript-friendly wrapper for Go WASM functions\r\n */\r\nexport function createTypedWasmFunction<T extends (...args: any[]) => any>(\r\n instance: GoWasmInstance,\r\n functionName: string\r\n): T {\r\n if (!instance.functions[functionName]) {\r\n throw new Error(`WASM function \"${functionName}\" not found`);\r\n }\r\n \r\n return instance.functions[functionName] as T;\r\n}\r\n\r\n/**\r\n * Helper to convert JavaScript values to Go-compatible formats\r\n */\r\nexport const goValues = {\r\n // Convert JS string to Go string (returns memory pointer)\r\n stringToGo: (instance: GoWasmInstance, str: string): number => {\r\n if (!instance.functions.__stringToGo) {\r\n throw new Error('__stringToGo function not found in WASM module');\r\n }\r\n return instance.functions.__stringToGo(str);\r\n },\r\n \r\n // Convert Go string (memory pointer) to JS string\r\n stringFromGo: (instance: GoWasmInstance, ptr: number): string => {\r\n if (!instance.functions.__stringFromGo) {\r\n throw new Error('__stringFromGo function not found in WASM module');\r\n }\r\n return instance.functions.__stringFromGo(ptr);\r\n },\r\n \r\n // Convert JS object to Go (returns memory pointer)\r\n objectToGo: (instance: GoWasmInstance, obj: any): number => {\r\n if (!instance.functions.__objectToGo) {\r\n throw new Error('__objectToGo function not found in WASM module');\r\n }\r\n return instance.functions.__objectToGo(JSON.stringify(obj));\r\n },\r\n \r\n // Convert Go object (memory pointer) to JS object\r\n objectFromGo: (instance: GoWasmInstance, ptr: number): any => {\r\n if (!instance.functions.__objectFromGo) {\r\n throw new Error('__objectFromGo function not found in WASM module');\r\n }\r\n const str = instance.functions.__objectFromGo(ptr);\r\n return JSON.parse(str);\r\n }\r\n};\r\n","// Core JSX and rendering functions\r\nexport { jsx, jsxs, jsxDEV, Fragment, createElement } from './jsx-runtime.js';\r\nexport { render, hydrate } from './renderer.js';\r\n\r\n// React-like hooks\r\nexport { \r\n useState, \r\n useEffect,\r\n useMemo, \r\n useRef, \r\n useContext,\r\n useErrorBoundary\r\n} from './hooks.js';\r\n\r\n// Context API\r\nexport { createContext } from './context.js';\r\n\r\n// Server-side rendering\r\nexport { renderToString } from './server-renderer.js';\r\n\r\n// Batch updates utility\r\nexport { batchUpdates } from './batch.js';\r\n\r\n// VDOM utilities\r\nexport { diff, shouldComponentUpdate } from './vdom.js';\r\n\r\n// Component class\r\nexport { Component } from './component.js';\r\n\r\n// WASM functionality\r\nexport { \r\n loadGoWasm, \r\n createTypedWasmFunction, \r\n goValues \r\n} from './wasm.js';\r\n\r\n// Import everything for the default export object\r\nimport { jsx, jsxs, jsxDEV, Fragment, createElement } from './jsx-runtime.js';\r\nimport { render, hydrate } from './renderer.js';\r\nimport { \r\n useState, \r\n useEffect,\r\n useMemo, \r\n useRef, \r\n useContext,\r\n useErrorBoundary\r\n} from './hooks.js';\r\nimport { createContext } from './context.js';\r\nimport { renderToString } from './server-renderer.js';\r\nimport { batchUpdates } from './batch.js';\r\nimport { diff, shouldComponentUpdate } from './vdom.js';\r\nimport { Component } from './component.js';\r\nimport { \r\n loadGoWasm, \r\n createTypedWasmFunction, \r\n goValues \r\n} from './wasm.js';\r\n\r\n// Type exports\r\nexport type { VNode, ComponentType, ReactElement, Key, Ref } from './types.js';\r\nexport type { Context } from './types.js';\r\nexport type { GoWasmInstance, GoWasmOptions } from './wasm.js';\r\nexport type { \r\n StateSetter, \r\n StateHook, \r\n EffectCallback, \r\n DependencyList, \r\n MemoFactory,\r\n RefObject,\r\n MutableRefObject \r\n} from './types.js';\r\n\r\n// Default export object for compatibility\r\nconst frontendHamroun = {\r\n // JSX\r\n jsx,\r\n jsxs: jsx,\r\n jsxDEV: jsx,\r\n Fragment,\r\n createElement,\r\n \r\n // Rendering\r\n render,\r\n hydrate,\r\n \r\n // Hooks\r\n useState,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useContext,\r\n useErrorBoundary,\r\n \r\n // Context\r\n createContext,\r\n \r\n // Server rendering\r\n renderToString,\r\n \r\n // Utilities\r\n batchUpdates,\r\n diff,\r\n shouldComponentUpdate,\r\n \r\n // Component class\r\n Component,\r\n \r\n // WASM\r\n loadGoWasm,\r\n createTypedWasmFunction,\r\n goValues\r\n};\r\n\r\nexport default frontendHamroun;"],"names":["jsx"],"mappings":";;;AAMA,SAAS,cAAc,UAAe,UAAwB;AACtD,QAAA,UAAU,OAAO,KAAK,QAAQ,EAAE,OAAO,CAAA,MAAK,MAAM,UAAU;AAC5D,QAAA,UAAU,OAAO,KAAK,QAAQ,EAAE,OAAO,CAAA,MAAK,MAAM,UAAU;AAElE,MAAI,QAAQ,WAAW,QAAQ,OAAe,QAAA;AACvC,SAAA,QAAQ,MAAM,CAAO,QAAA,SAAS,GAAG,MAAM,SAAS,GAAG,CAAC;AAC7D;AAEgB,SAAA,KAAK,SAAsB,SAA+B;AACxE,MAAI,WAAW,QAAQ,WAAW,aAAa,YAAY;AAC3D,MAAI,OAAO,YAAY,OAAO,QAAgB,QAAA;AAC9C,MAAI,OAAO,YAAY,YAAY,OAAO,YAAY;AACpD,WAAO,YAAY;AACrB,MAAI,QAAQ,SAAS,QAAQ,KAAa,QAAA;AAC1C,SAAO,CAAC,cAAc,QAAQ,OAAO,QAAQ,KAAK;AACpD;AAEgB,SAAA,sBAAsB,UAAe,UAAwB;AACpE,SAAA,CAAC,cAAc,UAAU,QAAQ;AAC1C;ACvBO,MAAM,UAAU;AAAA,EAMrB,YAAY,QAAa,IAAI;AAL7B,SAAA,QAAa,CAAC;AAEgB,SAAA,UAAA;AAC9B,SAAQ,WAAoB;AAG1B,SAAK,QAAQ;AAAA,EAAA;AAAA,EAGf,oBAAoB;AAAA,EAAA;AAAA,EAIpB,MAAM,SAAS,UAAe;AAC5B,UAAM,YAAY,EAAE,GAAG,KAAK,MAAM;AAClC,SAAK,QAAQ,EAAE,GAAG,WAAW,GAAG,SAAS;AACzC,YAAQ,IAAI,GAAG,KAAK,YAAY,IAAI,mBAAmB;AAAA,MACrD,MAAM;AAAA,MACN,MAAM,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,GAAG;AAC1C,WAAA,KAAK,MAAM,GAAG;AAAA,EAAA;AAEzB;ACzIA,MAAM,kBAAkB;AAAA;AAAA,EAEtB;AAAA,EACA,MAAMA;AAAAA,EACN,QAAQA;AAAAA,EACR;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.cjs","sources":["../src/jsx-runtime.ts"],"sourcesContent":["import type { Component } from './component.js';\r\n\r\ninterface VNode {\r\n type: string | Function;\r\n props: Record<string, any>;\r\n}\r\n\r\nfunction jsx(type: string | Function, props: any): VNode {\r\n console.log('JSX Transform:', { type, props });\r\n const processedProps = { ...props };\r\n \r\n // Handle children properly\r\n if (arguments.length > 2) {\r\n processedProps.children = Array.prototype.slice.call(arguments, 2);\r\n }\r\n \r\n return { type, props: processedProps };\r\n}\r\n\r\nconst Fragment = ({ children }: { children: any }) => children;\r\n\r\nasync function createElement(vnode: VNode | any): Promise<Node> {\r\n console.log('Creating element from:', vnode);\r\n\r\n // Handle primitives and null\r\n if (vnode == null) {\r\n return document.createTextNode('');\r\n }\r\n \r\n if (typeof vnode === 'boolean') {\r\n return document.createTextNode('');\r\n }\r\n\r\n if (typeof vnode === 'number' || typeof vnode === 'string') {\r\n return document.createTextNode(String(vnode));\r\n }\r\n\r\n // Handle arrays\r\n if (Array.isArray(vnode)) {\r\n const fragment = document.createDocumentFragment();\r\n for (const child of vnode) {\r\n const node = await createElement(child);\r\n fragment.appendChild(node);\r\n }\r\n return fragment;\r\n }\r\n\r\n // Handle VNode\r\n if ('type' in vnode && vnode.props !== undefined) {\r\n const { type, props } = vnode;\r\n \r\n // Handle function components\r\n if (typeof type === 'function') {\r\n try {\r\n const result = await type(props || {});\r\n const node = await createElement(result);\r\n if (node instanceof Element) {\r\n node.setAttribute('data-component-id', type.name || type.toString());\r\n }\r\n return node;\r\n } catch (error) {\r\n console.error('Error rendering component:', error);\r\n return document.createTextNode('');\r\n }\r\n }\r\n\r\n // Create DOM element\r\n const element = document.createElement(type as string);\r\n \r\n // Handle props\r\n for (const [key, value] of Object.entries(props || {})) {\r\n if (key === 'children') continue;\r\n if (key.startsWith('on') && typeof value === 'function') {\r\n const eventName = key.toLowerCase().slice(2);\r\n // Remove existing event listener if any\r\n const existingHandler = (element as any).__events?.[eventName];\r\n if (existingHandler) {\r\n element.removeEventListener(eventName, existingHandler);\r\n }\r\n \r\n // Add new event listener\r\n element.addEventListener(eventName, value as EventListener);\r\n if (!(element as any).__events) {\r\n (element as any).__events = {};\r\n }\r\n (element as any).__events[eventName] = value;\r\n } else if (key === 'style' && typeof value === 'object') {\r\n Object.assign(element.style, value);\r\n } else if (key === 'className') {\r\n element.setAttribute('class', String(value));\r\n } else if (key !== 'key' && key !== 'ref') {\r\n element.setAttribute(key, String(value));\r\n }\r\n }\r\n\r\n // Handle children\r\n const children = props?.children;\r\n if (children != null) {\r\n const childArray = Array.isArray(children) ? children.flat() : [children];\r\n for (const child of childArray) {\r\n const childNode = await createElement(child);\r\n element.appendChild(childNode);\r\n }\r\n }\r\n\r\n return element;\r\n }\r\n\r\n // Handle other objects by converting to string\r\n return document.createTextNode(String(vnode));\r\n}\r\n\r\n// Export named functions and aliases without duplicates\r\nexport {\r\n jsx,\r\n jsx as jsxs,\r\n jsx as jsxDEV,\r\n Fragment,\r\n createElement\r\n};\r\n\r\n// Named exports object\r\nconst jsxRuntime = {\r\n jsx,\r\n jsxs: jsx,\r\n jsxDEV: jsx,\r\n Fragment,\r\n createElement\r\n};\r\n\r\nexport default jsxRuntime;\r\n"],"names":["jsx","type","props","console","log","processedProps","arguments","length","children","Array","prototype","slice","call","Fragment","async","createElement","vnode","document","createTextNode","String","isArray","fragment","createDocumentFragment","child","node","appendChild","result","Element","setAttribute","name","toString","error","element","key","value","Object","entries","startsWith","eventName","toLowerCase","existingHandler","__events","removeEventListener","addEventListener","assign","style","childArray","flat","childNode","jsxRuntime","jsxs","jsxDEV"],"mappings":"aAOA,SAASA,EAAIC,EAAyBC,GACpCC,QAAQC,IAAI,iBAAkB,CAAEH,OAAMC,UAChC,MAAAG,EAAiB,IAAKH,GAOrB,OAJHI,UAAUC,OAAS,IACrBF,EAAeG,SAAWC,MAAMC,UAAUC,MAAMC,KAAKN,UAAW,IAG3D,CAAEL,OAAMC,MAAOG,EACxB,gGAEA,MAAMQ,EAAW,EAAGL,cAAkCA,EAEtDM,eAAeC,EAAcC,GAI3B,GAHQb,QAAAC,IAAI,yBAA0BY,GAGzB,MAATA,EACK,OAAAC,SAASC,eAAe,IAG7B,GAAiB,kBAAVF,EACF,OAAAC,SAASC,eAAe,IAGjC,GAAqB,iBAAVF,GAAuC,iBAAVA,EACtC,OAAOC,SAASC,eAAeC,OAAOH,IAIpC,GAAAP,MAAMW,QAAQJ,GAAQ,CAClB,MAAAK,EAAWJ,SAASK,yBAC1B,IAAA,MAAWC,KAASP,EAAO,CACnB,MAAAQ,QAAaT,EAAcQ,GACjCF,EAASI,YAAYD,EAAI,CAEpB,OAAAH,CAAA,CAIT,GAAI,SAAUL,QAAyB,IAAhBA,EAAMd,MAAqB,CAC1C,MAAAD,KAAEA,EAAMC,MAAAA,GAAUc,EAGpB,GAAgB,mBAATf,EACL,IACF,MAAMyB,QAAezB,EAAKC,GAAS,CAAA,GAC7BsB,QAAaT,EAAcW,GAI1B,OAHHF,aAAgBG,SAClBH,EAAKI,aAAa,oBAAqB3B,EAAK4B,MAAQ5B,EAAK6B,YAEpDN,QACAO,GAEA,OADC5B,QAAA4B,MAAM,6BAA8BA,GACrCd,SAASC,eAAe,GAAE,CAK/B,MAAAc,EAAUf,SAASF,cAAcd,GAG5B,IAAA,MAACgC,EAAKC,KAAUC,OAAOC,QAAQlC,GAAS,CAAA,GACjD,GAAY,aAAR+B,EACJ,GAAIA,EAAII,WAAW,OAA0B,mBAAVH,EAAsB,CACvD,MAAMI,EAAYL,EAAIM,cAAc5B,MAAM,GAEpC6B,EAAmBR,EAAgBS,WAAWH,GAChDE,GACMR,EAAAU,oBAAoBJ,EAAWE,GAIjCR,EAAAW,iBAAiBL,EAAWJ,GAC9BF,EAAgBS,WACnBT,EAAgBS,SAAW,CAAC,GAEdT,EAAAS,SAASH,GAAaJ,CAC9B,KAAQ,UAARD,GAAoC,iBAAVC,EAC5BC,OAAAS,OAAOZ,EAAQa,MAAOX,GACZ,cAARD,EACTD,EAAQJ,aAAa,QAAST,OAAOe,IACpB,QAARD,GAAyB,QAARA,GAC1BD,EAAQJ,aAAaK,EAAKd,OAAOe,IAKrC,MAAM1B,EAAWN,GAAOM,SACxB,GAAgB,MAAZA,EAAkB,CACd,MAAAsC,EAAarC,MAAMW,QAAQZ,GAAYA,EAASuC,OAAS,CAACvC,GAChE,IAAA,MAAWe,KAASuB,EAAY,CACxB,MAAAE,QAAkBjC,EAAcQ,GACtCS,EAAQP,YAAYuB,EAAS,CAC/B,CAGK,OAAAhB,CAAA,CAIT,OAAOf,SAASC,eAAeC,OAAOH,GACxC,CAYA,MAAMiC,EAAa,CACjBjD,MACAkD,KAAMlD,EACNmD,OAAQnD,EACRa,WACAE"}
1
+ {"version":3,"file":"jsx-runtime.cjs","sources":["../src/jsx-runtime.ts"],"sourcesContent":["import type { VNode, ComponentType, Key, ReactElement } from './types.js';\r\n\r\nfunction jsx(type: string | Function, props: any): VNode {\r\n console.log('JSX Transform:', { type, props });\r\n const processedProps = { ...props };\r\n \r\n // Handle children properly\r\n if (arguments.length > 2) {\r\n processedProps.children = Array.prototype.slice.call(arguments, 2);\r\n }\r\n \r\n return { type, props: processedProps };\r\n}\r\n\r\nconst Fragment = ({ children }: { children: any }) => children;\r\n\r\nasync function createElement(vnode: VNode | any): Promise<Node> {\r\n console.log('Creating element from:', vnode);\r\n\r\n // Handle primitives and null\r\n if (vnode == null) {\r\n return document.createTextNode('');\r\n }\r\n \r\n if (typeof vnode === 'boolean') {\r\n return document.createTextNode('');\r\n }\r\n\r\n if (typeof vnode === 'number' || typeof vnode === 'string') {\r\n return document.createTextNode(String(vnode));\r\n }\r\n\r\n // Handle arrays\r\n if (Array.isArray(vnode)) {\r\n const fragment = document.createDocumentFragment();\r\n for (const child of vnode) {\r\n const node = await createElement(child);\r\n fragment.appendChild(node);\r\n }\r\n return fragment;\r\n }\r\n\r\n // Handle VNode\r\n if ('type' in vnode && vnode.props !== undefined) {\r\n const { type, props } = vnode;\r\n \r\n // Handle function components\r\n if (typeof type === 'function') {\r\n try {\r\n const result = await type(props || {});\r\n const node = await createElement(result);\r\n if (node instanceof Element) {\r\n node.setAttribute('data-component-id', type.name || type.toString());\r\n }\r\n return node;\r\n } catch (error) {\r\n console.error('Error rendering component:', error);\r\n return document.createTextNode('');\r\n }\r\n }\r\n\r\n // Create DOM element\r\n const element = document.createElement(type as string);\r\n \r\n // Handle props\r\n for (const [key, value] of Object.entries(props || {})) {\r\n if (key === 'children') continue;\r\n if (key.startsWith('on') && typeof value === 'function') {\r\n const eventName = key.toLowerCase().slice(2);\r\n // Remove existing event listener if any\r\n const existingHandler = (element as any).__events?.[eventName];\r\n if (existingHandler) {\r\n element.removeEventListener(eventName, existingHandler);\r\n }\r\n \r\n // Add new event listener\r\n element.addEventListener(eventName, value as EventListener);\r\n if (!(element as any).__events) {\r\n (element as any).__events = {};\r\n }\r\n (element as any).__events[eventName] = value;\r\n } else if (key === 'style' && typeof value === 'object') {\r\n Object.assign(element.style, value);\r\n } else if (key === 'className') {\r\n element.setAttribute('class', String(value));\r\n } else if (key !== 'key' && key !== 'ref') {\r\n element.setAttribute(key, String(value));\r\n }\r\n }\r\n\r\n // Handle children\r\n const children = props?.children;\r\n if (children != null) {\r\n const childArray = Array.isArray(children) ? children.flat() : [children];\r\n for (const child of childArray) {\r\n const childNode = await createElement(child);\r\n element.appendChild(childNode);\r\n }\r\n }\r\n\r\n return element;\r\n }\r\n\r\n // Handle other objects by converting to string\r\n return document.createTextNode(String(vnode));\r\n}\r\n\r\n// Export named functions and aliases\r\nexport {\r\n jsx,\r\n jsx as jsxs,\r\n jsx as jsxDEV,\r\n Fragment,\r\n createElement\r\n};\r\n\r\n// Named exports object\r\nconst jsxRuntime = {\r\n jsx,\r\n jsxs: jsx,\r\n jsxDEV: jsx,\r\n Fragment,\r\n createElement\r\n};\r\n\r\nexport default jsxRuntime;\r\n"],"names":["jsx","type","props","console","log","processedProps","arguments","length","children","Array","prototype","slice","call","Fragment","async","createElement","vnode","document","createTextNode","String","isArray","fragment","createDocumentFragment","child","node","appendChild","result","Element","setAttribute","name","toString","error","element","key","value","Object","entries","startsWith","eventName","toLowerCase","existingHandler","__events","removeEventListener","addEventListener","assign","style","childArray","flat","childNode","jsxRuntime","jsxs","jsxDEV"],"mappings":"aAEA,SAASA,EAAIC,EAAyBC,GACpCC,QAAQC,IAAI,iBAAkB,CAAEH,OAAMC,UAChC,MAAAG,EAAiB,IAAKH,GAOrB,OAJHI,UAAUC,OAAS,IACrBF,EAAeG,SAAWC,MAAMC,UAAUC,MAAMC,KAAKN,UAAW,IAG3D,CAAEL,OAAMC,MAAOG,EACxB,gGAEA,MAAMQ,EAAW,EAAGL,cAAkCA,EAEtDM,eAAeC,EAAcC,GAI3B,GAHQb,QAAAC,IAAI,yBAA0BY,GAGzB,MAATA,EACK,OAAAC,SAASC,eAAe,IAG7B,GAAiB,kBAAVF,EACF,OAAAC,SAASC,eAAe,IAGjC,GAAqB,iBAAVF,GAAuC,iBAAVA,EACtC,OAAOC,SAASC,eAAeC,OAAOH,IAIpC,GAAAP,MAAMW,QAAQJ,GAAQ,CAClB,MAAAK,EAAWJ,SAASK,yBAC1B,IAAA,MAAWC,KAASP,EAAO,CACnB,MAAAQ,QAAaT,EAAcQ,GACjCF,EAASI,YAAYD,EAAI,CAEpB,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