frontend-hamroun 1.2.79 → 1.2.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +129 -1513
- package/bin/cli.js +505 -144
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.client.cjs +2 -0
- package/dist/index.client.cjs.map +1 -0
- package/dist/index.client.js +26 -0
- package/dist/index.client.js.map +1 -0
- package/dist/index.js +298 -1
- package/dist/index.js.map +1 -0
- package/dist/jsx-runtime.cjs +2 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.js +93 -1
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/renderer-Bo9zkUZ_.js +52 -0
- package/dist/renderer-Bo9zkUZ_.js.map +1 -0
- package/dist/renderer-Din1y3YM.cjs +2 -0
- package/dist/renderer-Din1y3YM.cjs.map +1 -0
- package/dist/server-renderer-CqIpQ-od.cjs +2 -0
- package/dist/server-renderer-CqIpQ-od.cjs.map +1 -0
- package/dist/server-renderer-QHt45Ip2.js +255 -0
- package/dist/server-renderer-QHt45Ip2.js.map +1 -0
- package/dist/server-renderer.cjs +2 -0
- package/dist/server-renderer.cjs.map +1 -0
- package/dist/server-renderer.js +5 -1
- package/dist/server-renderer.js.map +1 -0
- package/package.json +77 -120
- package/templates/basic-app/build.js +22 -0
- package/templates/basic-app/bun.lock +196 -0
- package/templates/basic-app/dev.js +27 -0
- package/templates/basic-app/docs/rapport_pfe.aux +27 -27
- package/templates/basic-app/docs/rapport_pfe.out +10 -10
- package/templates/basic-app/docs/rapport_pfe.toc +14 -14
- package/templates/basic-app/esbuild.config.js +28 -0
- package/templates/basic-app/index.html +1 -1
- package/templates/{fullstack-app → basic-app}/package-lock.json +4185 -5094
- package/templates/basic-app/package.json +29 -28
- package/templates/basic-app/server.js +24 -0
- package/templates/basic-app/src/App.tsx +26 -0
- package/templates/basic-app/src/client.tsx +11 -0
- package/templates/basic-app/src/components/Counter.tsx +18 -0
- package/templates/basic-app/src/jsx-shim.ts +4 -0
- package/templates/basic-app/src/main.tsx +0 -1
- package/templates/basic-app/src/server.ts +52 -0
- package/templates/basic-app/tsconfig.server.json +11 -0
- package/templates/fullstack-app/build/main.css +874 -874
- package/templates/fullstack-app/build/main.css.map +7 -7
- package/templates/fullstack-app/build/main.js +967 -967
- package/templates/fullstack-app/build/main.js.map +7 -7
- package/templates/fullstack-app/public/styles.css +768 -768
- package/templates/go/example.go +99 -154
- package/templates/go-wasm-app/babel.config.js +2 -8
- package/templates/go-wasm-app/package.json +12 -21
- package/templates/go-wasm-app/public/wasm/wasm_exec.js +561 -561
- package/templates/go-wasm-app/public/wasm/wasm_exec_node.js +39 -39
- package/templates/go-wasm-app/server.js +510 -59
- package/templates/go-wasm-app/src/app.js +2 -22
- package/templates/go-wasm-app/src/wasm/example.go +75 -75
- package/templates/go-wasm-app/vite.config.js +5 -16
- package/templates/ssr-template/server.js +2 -2
- package/templates/ssr-template/vite.config.js +5 -16
- package/dist/Counter.d.ts +0 -0
- package/dist/batch/package.json +0 -16
- package/dist/client-router/package.json +0 -16
- package/dist/component/package.json +0 -16
- package/dist/context/package.json +0 -16
- package/dist/event-bus/package.json +0 -16
- package/dist/forms/package.json +0 -16
- package/dist/hooks/package.json +0 -16
- package/dist/hooks-0728361a.cjs +0 -1
- package/dist/hooks-b58f947c.js +0 -133
- package/dist/hooks.js +0 -1
- package/dist/hooks.mjs +0 -13
- package/dist/index.mjs +0 -137
- package/dist/jsx-runtime/package.json +0 -16
- package/dist/jsx-runtime.mjs +0 -64
- package/dist/lifecycle-events/package.json +0 -16
- package/dist/package.json +0 -71
- package/dist/render-component/package.json +0 -16
- package/dist/renderer/package.json +0 -16
- package/dist/renderer.js +0 -1
- package/dist/renderer.mjs +0 -27
- package/dist/router/package.json +0 -16
- package/dist/server/package.json +0 -17
- package/dist/server/src/batch.d.ts +0 -3
- package/dist/server/src/batch.js +0 -23
- package/dist/server/src/batch.js.map +0 -1
- package/dist/server/src/client-router.d.ts +0 -60
- package/dist/server/src/client-router.js +0 -210
- package/dist/server/src/client-router.js.map +0 -1
- package/dist/server/src/component.d.ts +0 -14
- package/dist/server/src/component.js +0 -106
- package/dist/server/src/component.js.map +0 -1
- package/dist/server/src/context.d.ts +0 -13
- package/dist/server/src/context.js +0 -21
- package/dist/server/src/context.js.map +0 -1
- package/dist/server/src/event-bus.d.ts +0 -23
- package/dist/server/src/event-bus.js +0 -75
- package/dist/server/src/event-bus.js.map +0 -1
- package/dist/server/src/forms.d.ts +0 -40
- package/dist/server/src/forms.js +0 -148
- package/dist/server/src/forms.js.map +0 -1
- package/dist/server/src/hooks.d.ts +0 -12
- package/dist/server/src/hooks.js +0 -170
- package/dist/server/src/hooks.js.map +0 -1
- package/dist/server/src/index.client.d.ts +0 -12
- package/dist/server/src/index.client.js +0 -14
- package/dist/server/src/index.client.js.map +0 -1
- package/dist/server/src/index.d.ts +0 -88
- package/dist/server/src/index.js +0 -79
- package/dist/server/src/index.js.map +0 -1
- package/dist/server/src/jsx-runtime/jsx-dev-runtime.d.ts +0 -1
- package/dist/server/src/jsx-runtime/jsx-dev-runtime.js +0 -2
- package/dist/server/src/jsx-runtime/jsx-dev-runtime.js.map +0 -1
- package/dist/server/src/jsx-runtime/jsx-runtime.d.ts +0 -4
- package/dist/server/src/jsx-runtime/jsx-runtime.js +0 -41
- package/dist/server/src/jsx-runtime/jsx-runtime.js.map +0 -1
- package/dist/server/src/jsx-runtime.d.ts +0 -20
- package/dist/server/src/jsx-runtime.js +0 -105
- package/dist/server/src/jsx-runtime.js.map +0 -1
- package/dist/server/src/lifecycle-events.d.ts +0 -108
- package/dist/server/src/lifecycle-events.js +0 -177
- package/dist/server/src/lifecycle-events.js.map +0 -1
- package/dist/server/src/renderComponent.d.ts +0 -13
- package/dist/server/src/renderComponent.js +0 -30
- package/dist/server/src/renderComponent.js.map +0 -1
- package/dist/server/src/renderer.d.ts +0 -2
- package/dist/server/src/renderer.js +0 -31
- package/dist/server/src/renderer.js.map +0 -1
- package/dist/server/src/router.d.ts +0 -55
- package/dist/server/src/router.js +0 -166
- package/dist/server/src/router.js.map +0 -1
- package/dist/server/src/server/api-router.d.ts +0 -15
- package/dist/server/src/server/api-router.js +0 -111
- package/dist/server/src/server/api-router.js.map +0 -1
- package/dist/server/src/server/auth.d.ts +0 -32
- package/dist/server/src/server/auth.js +0 -80
- package/dist/server/src/server/auth.js.map +0 -1
- package/dist/server/src/server/database.d.ts +0 -24
- package/dist/server/src/server/database.js +0 -135
- package/dist/server/src/server/database.js.map +0 -1
- package/dist/server/src/server/index.d.ts +0 -116
- package/dist/server/src/server/index.js +0 -508
- package/dist/server/src/server/index.js.map +0 -1
- package/dist/server/src/server/middleware.d.ts +0 -11
- package/dist/server/src/server/middleware.js +0 -46
- package/dist/server/src/server/middleware.js.map +0 -1
- package/dist/server/src/server/server.d.ts +0 -9
- package/dist/server/src/server/server.js +0 -87
- package/dist/server/src/server/server.js.map +0 -1
- package/dist/server/src/server/templates.d.ts +0 -30
- package/dist/server/src/server/templates.js +0 -208
- package/dist/server/src/server/templates.js.map +0 -1
- package/dist/server/src/server/types.d.ts +0 -38
- package/dist/server/src/server/types.js +0 -4
- package/dist/server/src/server/types.js.map +0 -1
- package/dist/server/src/server/utils.d.ts +0 -70
- package/dist/server/src/server/utils.js +0 -156
- package/dist/server/src/server/utils.js.map +0 -1
- package/dist/server/src/server/wasm.d.ts +0 -9
- package/dist/server/src/server/wasm.js +0 -117
- package/dist/server/src/server/wasm.js.map +0 -1
- package/dist/server/src/server-renderer.d.ts +0 -5
- package/dist/server/src/server-renderer.js +0 -106
- package/dist/server/src/server-renderer.js.map +0 -1
- package/dist/server/src/server-types.d.ts +0 -42
- package/dist/server/src/server-types.js +0 -6
- package/dist/server/src/server-types.js.map +0 -1
- package/dist/server/src/store.d.ts +0 -41
- package/dist/server/src/store.js +0 -99
- package/dist/server/src/store.js.map +0 -1
- package/dist/server/src/types.d.ts +0 -19
- package/dist/server/src/types.js +0 -2
- package/dist/server/src/types.js.map +0 -1
- package/dist/server/src/utils.d.ts +0 -46
- package/dist/server/src/utils.js +0 -144
- package/dist/server/src/utils.js.map +0 -1
- package/dist/server/src/vdom.d.ts +0 -8
- package/dist/server/src/vdom.js +0 -22
- package/dist/server/src/vdom.js.map +0 -1
- package/dist/server/src/wasm.d.ts +0 -36
- package/dist/server/src/wasm.js +0 -159
- package/dist/server/src/wasm.js.map +0 -1
- package/dist/server/tsconfig.server.tsbuildinfo +0 -1
- package/dist/server-renderer/package.json +0 -16
- package/dist/server-renderer.mjs +0 -64
- package/dist/store/package.json +0 -16
- package/dist/types/package.json +0 -16
- package/dist/utils/package.json +0 -16
- package/dist/vdom/package.json +0 -16
- package/dist/wasm/package.json +0 -16
- package/dist/wasm.js +0 -1
- package/dist/wasm.mjs +0 -103
- package/templates/basic-app/docs/rapport_pfe.log +0 -399
- package/templates/complete-app/client.js +0 -58
- package/templates/complete-app/package-lock.json +0 -2536
- package/templates/complete-app/package.json +0 -17
- package/templates/complete-app/pages/about.js +0 -119
- package/templates/complete-app/pages/index.js +0 -157
- package/templates/complete-app/pages/wasm-demo.js +0 -290
- package/templates/complete-app/public/client.js +0 -80
- package/templates/complete-app/public/index.html +0 -47
- package/templates/complete-app/public/styles.css +0 -579
- package/templates/complete-app/readme.md +0 -188
- package/templates/complete-app/server.js +0 -417
- package/templates/complete-app/server.ts +0 -275
- package/templates/complete-app/src/App.tsx +0 -59
- package/templates/complete-app/src/client.ts +0 -61
- package/templates/complete-app/src/client.tsx +0 -18
- package/templates/complete-app/src/pages/index.tsx +0 -51
- package/templates/complete-app/src/server.ts +0 -218
- package/templates/complete-app/tsconfig.json +0 -22
- package/templates/complete-app/tsconfig.server.json +0 -19
- package/templates/complete-app/vite.config.js +0 -57
- package/templates/complete-app/vite.config.ts +0 -30
- package/templates/go-wasm-app/build.config.js +0 -62
- package/templates/go-wasm-app/build.js +0 -218
- package/templates/go-wasm-app/package-lock.json +0 -3732
package/dist/index.cjs
ADDED
@@ -0,0 +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;
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
@@ -0,0 +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\nimport { AuthService } from './server/auth.js';\r\n// Default export for compatibility with some module systems\r\nexport default {\r\n Fragment: Fragment,\r\n jsx: jsx,\r\n jsxs: jsxs,\r\n createElement: createElement,\r\n render: render, \r\n hydrate: hydrate,\r\n useState: useState,\r\n useEffect: useEffect,\r\n useMemo: useMemo,\r\n useRef: useRef,\r\n useContext: useContext,\r\n useErrorBoundary: useErrorBoundary,\r\n createContext: createContext,\r\n renderToString: renderToString,\r\n batchUpdates: batchUpdates,\r\n server: server,\r\n loadGoWasm: loadGoWasm,\r\n createTypedWasmFunction: createTypedWasmFunction,\r\n goValues: goValues,\r\n wasm: wasm,\r\n Component: Component,\r\n diff: diff,\r\n shouldComponentUpdate: shouldComponentUpdate\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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EAAAA,cAAAC,eACAA,EAAAA,eAAAC,aACAA,EAAAA,aACAnB,SACAlI,aACAoD,0BACAE,WACAiF,OACAjD,YACAN,OACAK,+1BA1BuB"}
|
@@ -0,0 +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;
|
2
|
+
//# sourceMappingURL=index.client.cjs.map
|
@@ -0,0 +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"}
|
@@ -0,0 +1,26 @@
|
|
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";
|
3
|
+
import { Fragment, jsx, jsx as jsx2 } from "./jsx-runtime.js";
|
4
|
+
const server = {
|
5
|
+
async getServer() {
|
6
|
+
throw new Error("Server module can only be used in Node.js environment");
|
7
|
+
}
|
8
|
+
};
|
9
|
+
export {
|
10
|
+
Fragment,
|
11
|
+
b as batchUpdates,
|
12
|
+
c2 as createContext,
|
13
|
+
h as hydrate,
|
14
|
+
jsx,
|
15
|
+
jsx2 as jsxs,
|
16
|
+
r2 as render,
|
17
|
+
r as renderToString,
|
18
|
+
server,
|
19
|
+
u2 as useContext,
|
20
|
+
d as useEffect,
|
21
|
+
u as useErrorBoundary,
|
22
|
+
c as useMemo,
|
23
|
+
a as useRef,
|
24
|
+
e as useState
|
25
|
+
};
|
26
|
+
//# sourceMappingURL=index.client.js.map
|
@@ -0,0 +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;"}
|
package/dist/index.js
CHANGED
@@ -1 +1,298 @@
|
|
1
|
-
|
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";
|
5
|
+
const DEFAULT_GO_WASM_PATH = "/wasm_exec.js";
|
6
|
+
async function loadGoWasm$1(wasmUrl, options = {}) {
|
7
|
+
const {
|
8
|
+
importObject = {},
|
9
|
+
goWasmPath = DEFAULT_GO_WASM_PATH,
|
10
|
+
loadGo = true,
|
11
|
+
onLoad,
|
12
|
+
debug = false
|
13
|
+
} = options;
|
14
|
+
if (typeof window !== "undefined" && loadGo) {
|
15
|
+
await loadGoRuntime(goWasmPath);
|
16
|
+
}
|
17
|
+
try {
|
18
|
+
const go = typeof Go !== "undefined" ? new Go() : null;
|
19
|
+
if (debug) console.log(`[WASM] Loading module from ${wasmUrl}`);
|
20
|
+
const response = await fetch(wasmUrl);
|
21
|
+
if (!response.ok) {
|
22
|
+
throw new Error(`Failed to fetch WASM module: ${response.statusText}`);
|
23
|
+
}
|
24
|
+
const buffer = await response.arrayBuffer();
|
25
|
+
const module = await WebAssembly.compile(buffer);
|
26
|
+
const finalImportObject = go ? {
|
27
|
+
...go.importObject,
|
28
|
+
...importObject
|
29
|
+
} : importObject;
|
30
|
+
const instance = await WebAssembly.instantiate(module, finalImportObject);
|
31
|
+
if (go) {
|
32
|
+
go.run(instance);
|
33
|
+
}
|
34
|
+
const exports = instance.exports;
|
35
|
+
const functions = {};
|
36
|
+
for (const key in exports) {
|
37
|
+
if (typeof exports[key] === "function") {
|
38
|
+
const exportedFn = exports[key];
|
39
|
+
functions[key] = (...args) => exportedFn(...args);
|
40
|
+
if (debug) {
|
41
|
+
const originalFn = functions[key];
|
42
|
+
functions[key] = (...args) => {
|
43
|
+
console.log(`[WASM] Calling ${key}(${args.join(", ")})`);
|
44
|
+
const result = originalFn(...args);
|
45
|
+
console.log(`[WASM] ${key} returned:`, result);
|
46
|
+
return result;
|
47
|
+
};
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
if (typeof window !== "undefined") {
|
52
|
+
for (const key in window) {
|
53
|
+
if (key.startsWith("go") && typeof window[key] === "function") {
|
54
|
+
const globalFn = window[key];
|
55
|
+
functions[key] = (...args) => globalFn(...args);
|
56
|
+
if (debug) {
|
57
|
+
const originalFn = functions[key];
|
58
|
+
functions[key] = (...args) => {
|
59
|
+
console.log(`[WASM] Calling global ${key}(${args.join(", ")})`);
|
60
|
+
const result = originalFn(...args);
|
61
|
+
console.log(`[WASM] ${key} returned:`, result);
|
62
|
+
return result;
|
63
|
+
};
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
const wasmInstance = {
|
69
|
+
instance,
|
70
|
+
module,
|
71
|
+
exports,
|
72
|
+
functions
|
73
|
+
};
|
74
|
+
if (onLoad) {
|
75
|
+
onLoad(wasmInstance);
|
76
|
+
}
|
77
|
+
return wasmInstance;
|
78
|
+
} catch (error) {
|
79
|
+
console.error("[WASM] Failed to load Go WASM module:", error);
|
80
|
+
throw error;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
async function loadGoRuntime(path = DEFAULT_GO_WASM_PATH) {
|
84
|
+
if (typeof window === "undefined") return;
|
85
|
+
if (typeof window.Go !== "undefined") {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
return new Promise((resolve, reject) => {
|
89
|
+
const script = document.createElement("script");
|
90
|
+
script.src = path;
|
91
|
+
script.onload = () => resolve();
|
92
|
+
script.onerror = () => reject(new Error(`Failed to load Go WASM runtime from ${path}`));
|
93
|
+
document.head.appendChild(script);
|
94
|
+
});
|
95
|
+
}
|
96
|
+
function createTypedWasmFunction$1(instance, functionName) {
|
97
|
+
if (!instance.functions[functionName]) {
|
98
|
+
throw new Error(`WASM function "${functionName}" not found`);
|
99
|
+
}
|
100
|
+
return instance.functions[functionName];
|
101
|
+
}
|
102
|
+
const goValues$1 = {
|
103
|
+
// Convert JS string to Go string (returns memory pointer)
|
104
|
+
stringToGo: (instance, str) => {
|
105
|
+
if (!instance.functions.__stringToGo) {
|
106
|
+
throw new Error("__stringToGo function not found in WASM module");
|
107
|
+
}
|
108
|
+
return instance.functions.__stringToGo(str);
|
109
|
+
},
|
110
|
+
// Convert Go string (memory pointer) to JS string
|
111
|
+
stringFromGo: (instance, ptr) => {
|
112
|
+
if (!instance.functions.__stringFromGo) {
|
113
|
+
throw new Error("__stringFromGo function not found in WASM module");
|
114
|
+
}
|
115
|
+
return instance.functions.__stringFromGo(ptr);
|
116
|
+
},
|
117
|
+
// Convert JS object to Go (returns memory pointer)
|
118
|
+
objectToGo: (instance, obj) => {
|
119
|
+
if (!instance.functions.__objectToGo) {
|
120
|
+
throw new Error("__objectToGo function not found in WASM module");
|
121
|
+
}
|
122
|
+
return instance.functions.__objectToGo(JSON.stringify(obj));
|
123
|
+
},
|
124
|
+
// Convert Go object (memory pointer) to JS object
|
125
|
+
objectFromGo: (instance, ptr) => {
|
126
|
+
if (!instance.functions.__objectFromGo) {
|
127
|
+
throw new Error("__objectFromGo function not found in WASM module");
|
128
|
+
}
|
129
|
+
const str = instance.functions.__objectFromGo(ptr);
|
130
|
+
return JSON.parse(str);
|
131
|
+
}
|
132
|
+
};
|
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,
|
242
|
+
jsx,
|
243
|
+
jsxs: jsx,
|
244
|
+
createElement,
|
245
|
+
render,
|
246
|
+
hydrate,
|
247
|
+
useState,
|
248
|
+
useEffect,
|
249
|
+
useMemo,
|
250
|
+
useRef,
|
251
|
+
useContext,
|
252
|
+
useErrorBoundary,
|
253
|
+
createContext,
|
254
|
+
renderToString,
|
255
|
+
batchUpdates,
|
256
|
+
server,
|
257
|
+
loadGoWasm,
|
258
|
+
createTypedWasmFunction,
|
259
|
+
goValues,
|
260
|
+
wasm,
|
261
|
+
Component,
|
262
|
+
diff,
|
263
|
+
shouldComponentUpdate
|
264
|
+
};
|
265
|
+
export {
|
266
|
+
Component,
|
267
|
+
Fragment,
|
268
|
+
batchUpdates,
|
269
|
+
createContext,
|
270
|
+
createElement,
|
271
|
+
createTypedWasmFunction,
|
272
|
+
index as default,
|
273
|
+
diff,
|
274
|
+
f as finishRender,
|
275
|
+
g as getIsBatching,
|
276
|
+
goValues,
|
277
|
+
hydrate,
|
278
|
+
i as isBatching,
|
279
|
+
isHydrating,
|
280
|
+
jsx,
|
281
|
+
jsx as jsxDEV,
|
282
|
+
jsx as jsxs,
|
283
|
+
loadGoWasm,
|
284
|
+
p as prepareRender,
|
285
|
+
render,
|
286
|
+
renderToString,
|
287
|
+
server,
|
288
|
+
s as setRenderCallback,
|
289
|
+
shouldComponentUpdate,
|
290
|
+
useContext,
|
291
|
+
useEffect,
|
292
|
+
useErrorBoundary,
|
293
|
+
useMemo,
|
294
|
+
useRef,
|
295
|
+
useState,
|
296
|
+
wasm
|
297
|
+
};
|
298
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +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\nimport { AuthService } from './server/auth.js';\r\n// Default export for compatibility with some module systems\r\nexport default {\r\n Fragment: Fragment,\r\n jsx: jsx,\r\n jsxs: jsxs,\r\n createElement: createElement,\r\n render: render, \r\n hydrate: hydrate,\r\n useState: useState,\r\n useEffect: useEffect,\r\n useMemo: useMemo,\r\n useRef: useRef,\r\n useContext: useContext,\r\n useErrorBoundary: useErrorBoundary,\r\n createContext: createContext,\r\n renderToString: renderToString,\r\n batchUpdates: batchUpdates,\r\n server: server,\r\n loadGoWasm: loadGoWasm,\r\n createTypedWasmFunction: createTypedWasmFunction,\r\n goValues: goValues,\r\n wasm: wasm,\r\n Component: Component,\r\n diff: diff,\r\n shouldComponentUpdate: shouldComponentUpdate\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,MAAA,OAAO,WAAW,eAAe,QAAQ;AAC3C,UAAM,cAAc,UAAU;AAAA,EAAA;AAG5B,MAAA;AAGF,UAAM,KAAK,OAAO,OAAO,cAAc,IAAI,GAAO,IAAA;AAGlD,QAAI,MAAO,SAAQ,IAAI,8BAA8B,OAAO,EAAE;AAExD,UAAA,WAAW,MAAM,MAAM,OAAO;AAEhC,QAAA,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,gCAAgC,SAAS,UAAU,EAAE;AAAA,IAAA;AAGjE,UAAA,SAAS,MAAM,SAAS,YAAY;AAC1C,UAAM,SAAS,MAAM,YAAY,QAAQ,MAAM;AAG/C,UAAM,oBAAoB,KAAK;AAAA,MAC7B,GAAG,GAAG;AAAA,MACN,GAAG;AAAA,IAAA,IACD;AAGJ,UAAM,WAAW,MAAM,YAAY,YAAY,QAAQ,iBAAiB;AAGxE,QAAI,IAAI;AACN,SAAG,IAAI,QAAQ;AAAA,IAAA;AAIjB,UAAM,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AAS;AACjB,WAAK,UAAU;AACX,UAAA,CAAC,KAAK,UAAU;AAClB,aAAK,WAAW;AACD,uBAAA,MAAM,KAAK,mBAAmB;AAAA,MAAA;AAAA,IAC/C,WACS,KAAK,QAAQ,YAAY;AAClC,WAAK,QAAQ,WAAW,aAAa,YAAY,KAAK,OAAO;AAC7D,WAAK,UAAU;AAAA,IAAA;AAGjB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,SAAc;AACN,UAAA,IAAI,MAAM,0CAA0C;AAAA,EAAA;AAE9D;AChCO,MAAM,SAAS;AAAA,EACpB,MAAM,YAAY;AACV,UAAA,IAAI,MAAM,uDAAuD;AAAA,EAAA;AAE3E;AAGO,MAAM,aAAaC;AACnB,MAAM,0BAA0BC;AAChC,MAAM,WAAWC;AAIjB,MAAM,OAAO;AAAA,EAClB,YAAYF;AAAAA,EACZ,yBAAyBC;AAAAA,EACzB,UAAUC;AACZ;AAgBO,IAAI,cAAc;AAGzB,MAAe,QAAA;AAAA,EACb;AAAA,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;AACF;"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";function e(e,t){console.log("JSX Transform:",{type:e,props:t});const n={...t};return arguments.length>2&&(n.children=Array.prototype.slice.call(arguments,2)),{type:e,props:n}}Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=({children:e})=>e;async function n(e){if(console.log("Creating element from:",e),null==e)return document.createTextNode("");if("boolean"==typeof e)return document.createTextNode("");if("number"==typeof e||"string"==typeof e)return document.createTextNode(String(e));if(Array.isArray(e)){const t=document.createDocumentFragment();for(const r of e){const e=await n(r);t.appendChild(e)}return t}if("type"in e&&void 0!==e.props){const{type:r,props:o}=e;if("function"==typeof r)try{const e=await r(o||{}),t=await n(e);return t instanceof Element&&t.setAttribute("data-component-id",r.name||r.toString()),t}catch(t){return console.error("Error rendering component:",t),document.createTextNode("")}const s=document.createElement(r);for(const[e,t]of Object.entries(o||{}))if("children"!==e)if(e.startsWith("on")&&"function"==typeof t){const n=e.toLowerCase().slice(2),r=s.__events?.[n];r&&s.removeEventListener(n,r),s.addEventListener(n,t),s.__events||(s.__events={}),s.__events[n]=t}else"style"===e&&"object"==typeof t?Object.assign(s.style,t):"className"===e?s.setAttribute("class",String(t)):"key"!==e&&"ref"!==e&&s.setAttribute(e,String(t));const c=o?.children;if(null!=c){const e=Array.isArray(c)?c.flat():[c];for(const t of e){const e=await n(t);s.appendChild(e)}}return s}return document.createTextNode(String(e))}const r={jsx:e,jsxs:e,jsxDEV:e,Fragment:t,createElement:n};exports.Fragment=t,exports.createElement=n,exports.default=r,exports.jsx=e,exports.jsxDEV=e,exports.jsxs=e;
|
2
|
+
//# sourceMappingURL=jsx-runtime.cjs.map
|
@@ -0,0 +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,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+
function jsx(type, props) {
|
2
|
+
console.log("JSX Transform:", { type, props });
|
3
|
+
const processedProps = { ...props };
|
4
|
+
if (arguments.length > 2) {
|
5
|
+
processedProps.children = Array.prototype.slice.call(arguments, 2);
|
6
|
+
}
|
7
|
+
return { type, props: processedProps };
|
8
|
+
}
|
9
|
+
const Fragment = ({ children }) => children;
|
10
|
+
async function createElement(vnode) {
|
11
|
+
console.log("Creating element from:", vnode);
|
12
|
+
if (vnode == null) {
|
13
|
+
return document.createTextNode("");
|
14
|
+
}
|
15
|
+
if (typeof vnode === "boolean") {
|
16
|
+
return document.createTextNode("");
|
17
|
+
}
|
18
|
+
if (typeof vnode === "number" || typeof vnode === "string") {
|
19
|
+
return document.createTextNode(String(vnode));
|
20
|
+
}
|
21
|
+
if (Array.isArray(vnode)) {
|
22
|
+
const fragment = document.createDocumentFragment();
|
23
|
+
for (const child of vnode) {
|
24
|
+
const node = await createElement(child);
|
25
|
+
fragment.appendChild(node);
|
26
|
+
}
|
27
|
+
return fragment;
|
28
|
+
}
|
29
|
+
if ("type" in vnode && vnode.props !== void 0) {
|
30
|
+
const { type, props } = vnode;
|
31
|
+
if (typeof type === "function") {
|
32
|
+
try {
|
33
|
+
const result = await type(props || {});
|
34
|
+
const node = await createElement(result);
|
35
|
+
if (node instanceof Element) {
|
36
|
+
node.setAttribute("data-component-id", type.name || type.toString());
|
37
|
+
}
|
38
|
+
return node;
|
39
|
+
} catch (error) {
|
40
|
+
console.error("Error rendering component:", error);
|
41
|
+
return document.createTextNode("");
|
42
|
+
}
|
43
|
+
}
|
44
|
+
const element = document.createElement(type);
|
45
|
+
for (const [key, value] of Object.entries(props || {})) {
|
46
|
+
if (key === "children") continue;
|
47
|
+
if (key.startsWith("on") && typeof value === "function") {
|
48
|
+
const eventName = key.toLowerCase().slice(2);
|
49
|
+
const existingHandler = element.__events?.[eventName];
|
50
|
+
if (existingHandler) {
|
51
|
+
element.removeEventListener(eventName, existingHandler);
|
52
|
+
}
|
53
|
+
element.addEventListener(eventName, value);
|
54
|
+
if (!element.__events) {
|
55
|
+
element.__events = {};
|
56
|
+
}
|
57
|
+
element.__events[eventName] = value;
|
58
|
+
} else if (key === "style" && typeof value === "object") {
|
59
|
+
Object.assign(element.style, value);
|
60
|
+
} else if (key === "className") {
|
61
|
+
element.setAttribute("class", String(value));
|
62
|
+
} else if (key !== "key" && key !== "ref") {
|
63
|
+
element.setAttribute(key, String(value));
|
64
|
+
}
|
65
|
+
}
|
66
|
+
const children = props?.children;
|
67
|
+
if (children != null) {
|
68
|
+
const childArray = Array.isArray(children) ? children.flat() : [children];
|
69
|
+
for (const child of childArray) {
|
70
|
+
const childNode = await createElement(child);
|
71
|
+
element.appendChild(childNode);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
return element;
|
75
|
+
}
|
76
|
+
return document.createTextNode(String(vnode));
|
77
|
+
}
|
78
|
+
const jsxRuntime = {
|
79
|
+
jsx,
|
80
|
+
jsxs: jsx,
|
81
|
+
jsxDEV: jsx,
|
82
|
+
Fragment,
|
83
|
+
createElement
|
84
|
+
};
|
85
|
+
export {
|
86
|
+
Fragment,
|
87
|
+
createElement,
|
88
|
+
jsxRuntime as default,
|
89
|
+
jsx,
|
90
|
+
jsx as jsxDEV,
|
91
|
+
jsx as jsxs
|
92
|
+
};
|
93
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","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":[],"mappings":"AAOA,SAAS,IAAI,MAAyB,OAAmB;AACvD,UAAQ,IAAI,kBAAkB,EAAE,MAAM,OAAO;AACvC,QAAA,iBAAiB,EAAE,GAAG,MAAM;AAG9B,MAAA,UAAU,SAAS,GAAG;AACxB,mBAAe,WAAW,MAAM,UAAU,MAAM,KAAK,WAAW,CAAC;AAAA,EAAA;AAG5D,SAAA,EAAE,MAAM,OAAO,eAAe;AACvC;AAEA,MAAM,WAAW,CAAC,EAAE,eAAkC;AAEtD,eAAe,cAAc,OAAmC;AACtD,UAAA,IAAI,0BAA0B,KAAK;AAG3C,MAAI,SAAS,MAAM;AACV,WAAA,SAAS,eAAe,EAAE;AAAA,EAAA;AAG/B,MAAA,OAAO,UAAU,WAAW;AACvB,WAAA,SAAS,eAAe,EAAE;AAAA,EAAA;AAGnC,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;AAC1D,WAAO,SAAS,eAAe,OAAO,KAAK,CAAC;AAAA,EAAA;AAI1C,MAAA,MAAM,QAAQ,KAAK,GAAG;AAClB,UAAA,WAAW,SAAS,uBAAuB;AACjD,eAAW,SAAS,OAAO;AACnB,YAAA,OAAO,MAAM,cAAc,KAAK;AACtC,eAAS,YAAY,IAAI;AAAA,IAAA;AAEpB,WAAA;AAAA,EAAA;AAIT,MAAI,UAAU,SAAS,MAAM,UAAU,QAA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