frontend-hamroun 1.2.84 → 1.2.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/batch.d.ts +4 -0
- package/dist/batch.d.ts.map +1 -0
- package/dist/batch.js +22 -0
- package/dist/client-router.d.ts +61 -0
- package/dist/client-router.d.ts.map +1 -0
- package/dist/client-router.js +209 -0
- package/dist/component.d.ts +15 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/component.js +84 -0
- package/dist/components/Counter.d.ts +1 -0
- package/dist/components/Counter.d.ts.map +1 -0
- package/dist/components/Counter.js +2 -0
- package/dist/context.d.ts +5 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +23 -0
- package/dist/event-bus.d.ts +24 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-bus.js +74 -0
- package/dist/forms.d.ts +41 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/forms.js +147 -0
- package/dist/hooks.d.ts +12 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +142 -0
- package/dist/index.cjs +1118 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.client.d.ts +13 -0
- package/dist/index.client.d.ts.map +1 -0
- package/dist/index.client.js +12 -25
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1040 -264
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.cjs +102 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +3 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +96 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime/jsx-runtime.d.ts +5 -0
- package/dist/jsx-runtime/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime/jsx-runtime.js +40 -0
- package/dist/jsx-runtime.cjs +112 -1
- package/dist/jsx-runtime.cjs.map +1 -1
- package/dist/jsx-runtime.d.ts +18 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +90 -79
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/lifecycle-events.d.ts +109 -0
- package/dist/lifecycle-events.d.ts.map +1 -0
- package/dist/lifecycle-events.js +176 -0
- package/dist/renderComponent.d.ts +14 -0
- package/dist/renderComponent.d.ts.map +1 -0
- package/dist/renderComponent.js +29 -0
- package/dist/renderer.d.ts +4 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +49 -0
- package/dist/router.d.ts +56 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +165 -0
- package/dist/server-renderer.d.ts +2 -0
- package/dist/server-renderer.d.ts.map +1 -0
- package/dist/server-renderer.js +111 -5
- package/dist/server-types.d.ts +43 -0
- package/dist/server-types.d.ts.map +1 -0
- package/dist/server-types.js +5 -0
- package/dist/store.d.ts +42 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +98 -0
- package/dist/types.d.ts +272 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/utils.d.ts +47 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +143 -0
- package/dist/vdom.d.ts +9 -0
- package/dist/vdom.d.ts.map +1 -0
- package/dist/vdom.js +21 -0
- package/dist/wasm.d.ts +37 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +158 -0
- package/package.json +54 -83
- package/templates/basic-app/build.d.ts +2 -0
- package/templates/basic-app/build.d.ts.map +1 -0
- package/templates/basic-app/dev.d.ts +2 -0
- package/templates/basic-app/dev.d.ts.map +1 -0
- package/templates/basic-app/esbuild.config.d.ts +2 -0
- package/templates/basic-app/esbuild.config.d.ts.map +1 -0
- package/templates/basic-app/postcss.config.d.ts +8 -0
- package/templates/basic-app/postcss.config.d.ts.map +1 -0
- package/templates/basic-app/server.d.ts +2 -0
- package/templates/basic-app/server.d.ts.map +1 -0
- package/templates/basic-app/src/App.d.ts +2 -0
- package/templates/basic-app/src/App.d.ts.map +1 -0
- package/templates/basic-app/src/App.js +148 -0
- package/templates/basic-app/src/client.d.ts +2 -0
- package/templates/basic-app/src/client.d.ts.map +1 -0
- package/templates/basic-app/src/client.js +6 -0
- package/templates/basic-app/src/components/Counter.d.ts +4 -0
- package/templates/basic-app/src/components/Counter.d.ts.map +1 -0
- package/templates/basic-app/src/components/Counter.js +9 -0
- package/templates/basic-app/src/jsx-shim.d.ts +8 -0
- package/templates/basic-app/src/jsx-shim.d.ts.map +1 -0
- package/templates/basic-app/src/main.d.ts +2 -0
- package/templates/basic-app/src/main.d.ts.map +1 -0
- package/templates/basic-app/src/main.js +57 -0
- package/templates/basic-app/src/server.d.ts +2 -0
- package/templates/basic-app/src/server.d.ts.map +1 -0
- package/templates/basic-app/tailwind.config.d.ts +9 -0
- package/templates/basic-app/tailwind.config.d.ts.map +1 -0
- package/templates/basic-app/vite.config.d.ts +3 -0
- package/templates/basic-app/vite.config.d.ts.map +1 -0
- package/templates/basic-app/vite.config.js +7 -0
- package/templates/complete-app/api/hello.d.ts +1 -0
- package/templates/complete-app/api/hello.d.ts.map +1 -0
- package/templates/complete-app/client.d.ts +2 -0
- package/templates/complete-app/client.d.ts.map +1 -0
- package/templates/complete-app/lib/frontend-hamroun.d.ts +18 -0
- package/templates/complete-app/lib/frontend-hamroun.d.ts.map +1 -0
- package/templates/complete-app/pages/about.d.ts +7 -0
- package/templates/complete-app/pages/about.d.ts.map +1 -0
- package/templates/complete-app/pages/index.d.ts +7 -0
- package/templates/complete-app/pages/index.d.ts.map +1 -0
- package/templates/complete-app/pages/wasm-demo.d.ts +7 -0
- package/templates/complete-app/pages/wasm-demo.d.ts.map +1 -0
- package/templates/complete-app/public/client.d.ts +17 -0
- package/templates/complete-app/public/client.d.ts.map +1 -0
- package/templates/complete-app/server.d.ts +2 -0
- package/templates/complete-app/server.d.ts.map +1 -0
- package/templates/complete-app/server.js +236 -218
- package/templates/complete-app/src/App.d.ts +2 -0
- package/templates/complete-app/src/App.d.ts.map +1 -0
- package/templates/complete-app/src/App.js +27 -0
- package/templates/complete-app/src/client.d.ts +2 -0
- package/templates/complete-app/src/client.d.ts.map +1 -0
- package/templates/complete-app/src/client.js +52 -0
- package/templates/complete-app/src/pages/index.d.ts +2 -0
- package/templates/complete-app/src/pages/index.d.ts.map +1 -0
- package/templates/complete-app/src/pages/index.js +19 -0
- package/templates/complete-app/src/server.d.ts +2 -0
- package/templates/complete-app/src/server.d.ts.map +1 -0
- package/templates/complete-app/src/server.js +192 -0
- package/templates/complete-app/vite.config.d.ts +3 -0
- package/templates/complete-app/vite.config.d.ts.map +1 -0
- package/templates/complete-app/vite.config.js +29 -57
- package/templates/fullstack-app/api/hello.d.ts +4 -0
- package/templates/fullstack-app/api/hello.d.ts.map +1 -0
- package/templates/fullstack-app/api/hello.js +14 -11
- package/templates/fullstack-app/api/users/[id].d.ts +5 -0
- package/templates/fullstack-app/api/users/[id].d.ts.map +1 -0
- package/templates/fullstack-app/api/users/[id].js +52 -0
- package/templates/fullstack-app/api/users/index.d.ts +4 -0
- package/templates/fullstack-app/api/users/index.d.ts.map +1 -0
- package/templates/fullstack-app/api/users/index.js +25 -0
- package/templates/fullstack-app/build/main.d.ts +211 -0
- package/templates/fullstack-app/build/main.d.ts.map +1 -0
- package/templates/fullstack-app/build.d.ts +2 -0
- package/templates/fullstack-app/build.d.ts.map +1 -0
- package/templates/fullstack-app/build.js +190 -0
- package/templates/fullstack-app/postcss.config.d.ts +5 -0
- package/templates/fullstack-app/postcss.config.d.ts.map +1 -0
- package/templates/fullstack-app/process-tailwind.d.ts +2 -0
- package/templates/fullstack-app/process-tailwind.d.ts.map +1 -0
- package/templates/fullstack-app/public/route-handler.d.ts +1 -0
- package/templates/fullstack-app/public/route-handler.d.ts.map +1 -0
- package/templates/fullstack-app/server.d.ts +2 -0
- package/templates/fullstack-app/server.d.ts.map +1 -0
- package/templates/fullstack-app/server.js +428 -266
- package/templates/fullstack-app/src/client.d.ts +2 -0
- package/templates/fullstack-app/src/client.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/ClientHome.d.ts +1 -0
- package/templates/fullstack-app/src/components/ClientHome.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/ClientHome.js +1 -0
- package/templates/fullstack-app/src/components/ErrorBoundary.d.ts +7 -0
- package/templates/fullstack-app/src/components/ErrorBoundary.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/ErrorBoundary.js +12 -0
- package/templates/fullstack-app/src/components/Layout.d.ts +7 -0
- package/templates/fullstack-app/src/components/Layout.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/Layout.js +4 -0
- package/templates/fullstack-app/src/components/StateDemo.d.ts +2 -0
- package/templates/fullstack-app/src/components/StateDemo.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/StateDemo.js +86 -0
- package/templates/fullstack-app/src/components/UserList.d.ts +11 -0
- package/templates/fullstack-app/src/components/UserList.d.ts.map +1 -0
- package/templates/fullstack-app/src/components/UserList.js +7 -0
- package/templates/fullstack-app/src/config.d.ts +29 -0
- package/templates/fullstack-app/src/config.d.ts.map +1 -0
- package/templates/fullstack-app/src/config.js +36 -0
- package/templates/fullstack-app/src/data/api.d.ts +35 -0
- package/templates/fullstack-app/src/data/api.d.ts.map +1 -0
- package/templates/fullstack-app/src/data/api.js +173 -0
- package/templates/fullstack-app/src/main.d.ts +7 -0
- package/templates/fullstack-app/src/main.d.ts.map +1 -0
- package/templates/fullstack-app/src/main.js +130 -0
- package/templates/fullstack-app/src/middleware.d.ts +10 -0
- package/templates/fullstack-app/src/middleware.d.ts.map +1 -0
- package/templates/fullstack-app/src/middleware.js +14 -0
- package/templates/fullstack-app/src/pages/404.d.ts +4 -0
- package/templates/fullstack-app/src/pages/404.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/404.js +4 -0
- package/templates/fullstack-app/src/pages/[id].d.ts +1 -0
- package/templates/fullstack-app/src/pages/[id].d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/[id].js +1 -0
- package/templates/fullstack-app/src/pages/_app.d.ts +6 -0
- package/templates/fullstack-app/src/pages/_app.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/_app.js +6 -0
- package/templates/fullstack-app/src/pages/_document.d.ts +7 -0
- package/templates/fullstack-app/src/pages/_document.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/_document.js +4 -0
- package/templates/fullstack-app/src/pages/_error.d.ts +4 -0
- package/templates/fullstack-app/src/pages/_error.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/_error.js +8 -0
- package/templates/fullstack-app/src/pages/about/index.d.ts +5 -0
- package/templates/fullstack-app/src/pages/about/index.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/about/index.js +6 -0
- package/templates/fullstack-app/src/pages/about.d.ts +10 -0
- package/templates/fullstack-app/src/pages/about.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/about.js +21 -0
- package/templates/fullstack-app/src/pages/api/users/[id].d.ts +6 -0
- package/templates/fullstack-app/src/pages/api/users/[id].d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/api/users/[id].js +51 -0
- package/templates/fullstack-app/src/pages/api/users/index.d.ts +4 -0
- package/templates/fullstack-app/src/pages/api/users/index.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/api/users/index.js +33 -0
- package/templates/fullstack-app/src/pages/index.d.ts +21 -0
- package/templates/fullstack-app/src/pages/index.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/index.js +66 -0
- package/templates/fullstack-app/src/pages/users/[id].d.ts +38 -0
- package/templates/fullstack-app/src/pages/users/[id].d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/users/[id].js +79 -0
- package/templates/fullstack-app/src/pages/users.d.ts +14 -0
- package/templates/fullstack-app/src/pages/users.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/users.js +14 -0
- package/templates/fullstack-app/src/pages/wasm-demo.d.ts +1 -0
- package/templates/fullstack-app/src/pages/wasm-demo.d.ts.map +1 -0
- package/templates/fullstack-app/src/pages/wasm-demo.js +2 -0
- package/templates/fullstack-app/src/router.d.ts +22 -0
- package/templates/fullstack-app/src/router.d.ts.map +1 -0
- package/templates/fullstack-app/src/router.js +210 -0
- package/templates/fullstack-app/tailwind.config.d.ts +3 -0
- package/templates/fullstack-app/tailwind.config.d.ts.map +1 -0
- package/templates/fullstack-app/vite.config.d.ts +3 -0
- package/templates/fullstack-app/vite.config.d.ts.map +1 -0
- package/templates/ssr-template/dist/client/assets/main-D-VH3xOb.d.ts +2 -0
- package/templates/ssr-template/dist/client/assets/main-D-VH3xOb.d.ts.map +1 -0
- package/templates/ssr-template/dist/client.d.ts +85 -0
- package/templates/ssr-template/dist/client.d.ts.map +1 -0
- package/templates/ssr-template/dist/server.d.ts +2 -0
- package/templates/ssr-template/dist/server.d.ts.map +1 -0
- package/templates/ssr-template/esbuild.config.d.ts +2 -0
- package/templates/ssr-template/esbuild.config.d.ts.map +1 -0
- package/templates/ssr-template/jsx-shim.d.ts +2 -0
- package/templates/ssr-template/jsx-shim.d.ts.map +1 -0
- package/templates/ssr-template/src/App.d.ts +2 -0
- package/templates/ssr-template/src/App.d.ts.map +1 -0
- package/templates/ssr-template/src/App.js +625 -0
- package/templates/ssr-template/src/client.d.ts +2 -0
- package/templates/ssr-template/src/client.d.ts.map +1 -0
- package/templates/ssr-template/src/client.js +3 -0
- package/templates/ssr-template/src/server.d.ts +2 -0
- package/templates/ssr-template/src/server.d.ts.map +1 -0
- package/templates/ssr-template/src/server.js +29 -0
- package/templates/ssr-template/vite.config.d.ts +3 -0
- package/templates/ssr-template/vite.config.d.ts.map +1 -0
- package/templates/ssr-template/vite.config.js +30 -0
- package/templates/wasm/build-wasm.d.ts +2 -0
- package/templates/wasm/build-wasm.d.ts.map +1 -0
- package/templates/wasm/dist/assets/index-BNqTDBdE.d.ts +30 -0
- package/templates/wasm/dist/assets/index-BNqTDBdE.d.ts.map +1 -0
- package/templates/wasm/dist/wasm_exec.d.ts +1 -0
- package/templates/wasm/dist/wasm_exec.d.ts.map +1 -0
- package/templates/wasm/esbuild.config.d.ts +2 -0
- package/templates/wasm/esbuild.config.d.ts.map +1 -0
- package/templates/wasm/go/wasm_exec.d.ts +1 -0
- package/templates/wasm/go/wasm_exec.d.ts.map +1 -0
- package/templates/wasm/jsx-shim.d.ts +5 -0
- package/templates/wasm/jsx-shim.d.ts.map +1 -0
- package/templates/wasm/public/wasm_exec.d.ts +1 -0
- package/templates/wasm/public/wasm_exec.d.ts.map +1 -0
- package/templates/wasm/src/App.d.ts +2 -0
- package/templates/wasm/src/App.d.ts.map +1 -0
- package/templates/wasm/src/App.js +381 -0
- package/templates/wasm/src/client.d.ts +2 -0
- package/templates/wasm/src/client.d.ts.map +1 -0
- package/templates/wasm/src/client.js +210 -0
- package/templates/wasm/src/index.d.ts +2 -0
- package/templates/wasm/src/index.d.ts.map +1 -0
- package/templates/wasm/src/index.js +20 -0
- package/templates/wasm/src/server.d.ts +2 -0
- package/templates/wasm/src/server.d.ts.map +1 -0
- package/templates/wasm/src/server.js +131 -0
- package/templates/wasm/vite.config.d.ts +3 -0
- package/templates/wasm/vite.config.d.ts.map +1 -0
- package/templates/wasm/vite.config.js +36 -0
- package/templates/wasm/wasm-loader.d.ts +6 -0
- package/templates/wasm/wasm-loader.d.ts.map +1 -0
- package/dist/index.client.cjs +0 -2
- package/dist/index.client.cjs.map +0 -1
- package/dist/index.client.js.map +0 -1
- package/dist/renderer-DaVfBeVi.cjs +0 -2
- package/dist/renderer-DaVfBeVi.cjs.map +0 -1
- package/dist/renderer-nfT7XSpo.js +0 -61
- package/dist/renderer-nfT7XSpo.js.map +0 -1
- package/dist/server-renderer-B5b0Q0ck.cjs +0 -2
- package/dist/server-renderer-B5b0Q0ck.cjs.map +0 -1
- package/dist/server-renderer-C4MB-jAp.js +0 -248
- package/dist/server-renderer-C4MB-jAp.js.map +0 -1
- package/dist/server-renderer.cjs +0 -2
- package/dist/server-renderer.cjs.map +0 -1
- package/dist/server-renderer.js.map +0 -1
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
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,UAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
function jsx(type, props) {
|
4
|
+
console.log('JSX Transform:', { type, props });
|
5
|
+
const processedProps = { ...props };
|
6
|
+
// Handle children properly
|
7
|
+
if (arguments.length > 2) {
|
8
|
+
processedProps.children = Array.prototype.slice.call(arguments, 2);
|
9
|
+
}
|
10
|
+
return { type, props: processedProps };
|
11
|
+
}
|
12
|
+
const Fragment = ({ children }) => children;
|
13
|
+
async function createElement(vnode) {
|
14
|
+
console.log('Creating element from:', vnode);
|
15
|
+
// Handle primitives and null
|
16
|
+
if (vnode == null) {
|
17
|
+
return document.createTextNode('');
|
18
|
+
}
|
19
|
+
if (typeof vnode === 'boolean') {
|
20
|
+
return document.createTextNode('');
|
21
|
+
}
|
22
|
+
if (typeof vnode === 'number' || typeof vnode === 'string') {
|
23
|
+
return document.createTextNode(String(vnode));
|
24
|
+
}
|
25
|
+
// Handle arrays
|
26
|
+
if (Array.isArray(vnode)) {
|
27
|
+
const fragment = document.createDocumentFragment();
|
28
|
+
for (const child of vnode) {
|
29
|
+
const node = await createElement(child);
|
30
|
+
fragment.appendChild(node);
|
31
|
+
}
|
32
|
+
return fragment;
|
33
|
+
}
|
34
|
+
// Handle VNode
|
35
|
+
if ('type' in vnode && vnode.props !== undefined) {
|
36
|
+
const { type, props } = vnode;
|
37
|
+
// Handle function components
|
38
|
+
if (typeof type === 'function') {
|
39
|
+
try {
|
40
|
+
const result = await type(props || {});
|
41
|
+
const node = await createElement(result);
|
42
|
+
if (node instanceof Element) {
|
43
|
+
node.setAttribute('data-component-id', type.name || type.toString());
|
44
|
+
}
|
45
|
+
return node;
|
46
|
+
}
|
47
|
+
catch (error) {
|
48
|
+
console.error('Error rendering component:', error);
|
49
|
+
return document.createTextNode('');
|
50
|
+
}
|
51
|
+
}
|
52
|
+
// Create DOM element
|
53
|
+
const element = document.createElement(type);
|
54
|
+
// Handle props
|
55
|
+
for (const [key, value] of Object.entries(props || {})) {
|
56
|
+
if (key === 'children')
|
57
|
+
continue;
|
58
|
+
if (key.startsWith('on') && typeof value === 'function') {
|
59
|
+
const eventName = key.toLowerCase().slice(2);
|
60
|
+
// Remove existing event listener if any
|
61
|
+
const existingHandler = element.__events?.[eventName];
|
62
|
+
if (existingHandler) {
|
63
|
+
element.removeEventListener(eventName, existingHandler);
|
64
|
+
}
|
65
|
+
// Add new event listener
|
66
|
+
element.addEventListener(eventName, value);
|
67
|
+
if (!element.__events) {
|
68
|
+
element.__events = {};
|
69
|
+
}
|
70
|
+
element.__events[eventName] = value;
|
71
|
+
}
|
72
|
+
else if (key === 'style' && typeof value === 'object') {
|
73
|
+
Object.assign(element.style, value);
|
74
|
+
}
|
75
|
+
else if (key === 'className') {
|
76
|
+
element.setAttribute('class', String(value));
|
77
|
+
}
|
78
|
+
else if (key !== 'key' && key !== 'ref') {
|
79
|
+
element.setAttribute(key, String(value));
|
80
|
+
}
|
81
|
+
}
|
82
|
+
// Handle children
|
83
|
+
const children = props?.children;
|
84
|
+
if (children != null) {
|
85
|
+
const childArray = Array.isArray(children) ? children.flat() : [children];
|
86
|
+
for (const child of childArray) {
|
87
|
+
const childNode = await createElement(child);
|
88
|
+
element.appendChild(childNode);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
return element;
|
92
|
+
}
|
93
|
+
// Handle other objects by converting to string
|
94
|
+
return document.createTextNode(String(vnode));
|
95
|
+
}
|
96
|
+
|
97
|
+
exports.Fragment = Fragment;
|
98
|
+
exports.createElement = createElement;
|
99
|
+
exports.jsx = jsx;
|
100
|
+
exports.jsxDEV = jsx;
|
101
|
+
exports.jsxs = jsx;
|
102
|
+
//# sourceMappingURL=jsx-dev-runtime.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG3D,cAAc,kBAAkB,CAAC"}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
function jsx(type, props) {
|
2
|
+
console.log('JSX Transform:', { type, props });
|
3
|
+
const processedProps = { ...props };
|
4
|
+
// Handle children properly
|
5
|
+
if (arguments.length > 2) {
|
6
|
+
processedProps.children = Array.prototype.slice.call(arguments, 2);
|
7
|
+
}
|
8
|
+
return { type, props: processedProps };
|
9
|
+
}
|
10
|
+
const Fragment = ({ children }) => children;
|
11
|
+
async function createElement(vnode) {
|
12
|
+
console.log('Creating element from:', vnode);
|
13
|
+
// Handle primitives and null
|
14
|
+
if (vnode == null) {
|
15
|
+
return document.createTextNode('');
|
16
|
+
}
|
17
|
+
if (typeof vnode === 'boolean') {
|
18
|
+
return document.createTextNode('');
|
19
|
+
}
|
20
|
+
if (typeof vnode === 'number' || typeof vnode === 'string') {
|
21
|
+
return document.createTextNode(String(vnode));
|
22
|
+
}
|
23
|
+
// Handle arrays
|
24
|
+
if (Array.isArray(vnode)) {
|
25
|
+
const fragment = document.createDocumentFragment();
|
26
|
+
for (const child of vnode) {
|
27
|
+
const node = await createElement(child);
|
28
|
+
fragment.appendChild(node);
|
29
|
+
}
|
30
|
+
return fragment;
|
31
|
+
}
|
32
|
+
// Handle VNode
|
33
|
+
if ('type' in vnode && vnode.props !== undefined) {
|
34
|
+
const { type, props } = vnode;
|
35
|
+
// Handle function components
|
36
|
+
if (typeof type === 'function') {
|
37
|
+
try {
|
38
|
+
const result = await type(props || {});
|
39
|
+
const node = await createElement(result);
|
40
|
+
if (node instanceof Element) {
|
41
|
+
node.setAttribute('data-component-id', type.name || type.toString());
|
42
|
+
}
|
43
|
+
return node;
|
44
|
+
}
|
45
|
+
catch (error) {
|
46
|
+
console.error('Error rendering component:', error);
|
47
|
+
return document.createTextNode('');
|
48
|
+
}
|
49
|
+
}
|
50
|
+
// Create DOM element
|
51
|
+
const element = document.createElement(type);
|
52
|
+
// Handle props
|
53
|
+
for (const [key, value] of Object.entries(props || {})) {
|
54
|
+
if (key === 'children')
|
55
|
+
continue;
|
56
|
+
if (key.startsWith('on') && typeof value === 'function') {
|
57
|
+
const eventName = key.toLowerCase().slice(2);
|
58
|
+
// Remove existing event listener if any
|
59
|
+
const existingHandler = element.__events?.[eventName];
|
60
|
+
if (existingHandler) {
|
61
|
+
element.removeEventListener(eventName, existingHandler);
|
62
|
+
}
|
63
|
+
// Add new event listener
|
64
|
+
element.addEventListener(eventName, value);
|
65
|
+
if (!element.__events) {
|
66
|
+
element.__events = {};
|
67
|
+
}
|
68
|
+
element.__events[eventName] = value;
|
69
|
+
}
|
70
|
+
else if (key === 'style' && typeof value === 'object') {
|
71
|
+
Object.assign(element.style, value);
|
72
|
+
}
|
73
|
+
else if (key === 'className') {
|
74
|
+
element.setAttribute('class', String(value));
|
75
|
+
}
|
76
|
+
else if (key !== 'key' && key !== 'ref') {
|
77
|
+
element.setAttribute(key, String(value));
|
78
|
+
}
|
79
|
+
}
|
80
|
+
// Handle children
|
81
|
+
const children = props?.children;
|
82
|
+
if (children != null) {
|
83
|
+
const childArray = Array.isArray(children) ? children.flat() : [children];
|
84
|
+
for (const child of childArray) {
|
85
|
+
const childNode = await createElement(child);
|
86
|
+
element.appendChild(childNode);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return element;
|
90
|
+
}
|
91
|
+
// Handle other objects by converting to string
|
92
|
+
return document.createTextNode(String(vnode));
|
93
|
+
}
|
94
|
+
|
95
|
+
export { Fragment, createElement, jsx, jsx as jsxDEV, jsx as jsxs };
|
96
|
+
//# sourceMappingURL=jsx-dev-runtime.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export declare function jsx(type: string | Function, props: any, key?: string): any;
|
2
|
+
export declare function jsxs(type: string | Function, props: any, key?: string): any;
|
3
|
+
export declare function createElement(vnode: any): HTMLElement | Text;
|
4
|
+
export declare const Fragment: unique symbol;
|
5
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx-runtime/jsx-runtime.ts"],"names":[],"mappings":"AACA,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAM1E;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAE3E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,WAAW,GAAG,IAAI,CA6B5D;AAED,eAAO,MAAM,QAAQ,eAAqB,CAAC"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// This file serves as the entry point for the library, re-exporting core functionalities
|
2
|
+
export function jsx(type, props, key) {
|
3
|
+
return {
|
4
|
+
type,
|
5
|
+
props: props || {},
|
6
|
+
key
|
7
|
+
};
|
8
|
+
}
|
9
|
+
export function jsxs(type, props, key) {
|
10
|
+
return jsx(type, props, key);
|
11
|
+
}
|
12
|
+
export function createElement(vnode) {
|
13
|
+
if (typeof vnode === 'string' || typeof vnode === 'number') {
|
14
|
+
return document.createTextNode(String(vnode));
|
15
|
+
}
|
16
|
+
if (typeof vnode.type === 'function') {
|
17
|
+
const result = vnode.type(vnode.props);
|
18
|
+
return createElement(result);
|
19
|
+
}
|
20
|
+
const element = document.createElement(vnode.type);
|
21
|
+
Object.entries(vnode.props || {}).forEach(([name, value]) => {
|
22
|
+
if (name === 'children') {
|
23
|
+
const children = Array.isArray(value) ? value : [value];
|
24
|
+
children.forEach((child) => {
|
25
|
+
if (child != null) {
|
26
|
+
element.appendChild(createElement(child));
|
27
|
+
}
|
28
|
+
});
|
29
|
+
}
|
30
|
+
else if (name.startsWith('on')) {
|
31
|
+
const eventName = name.toLowerCase().substring(2);
|
32
|
+
element.addEventListener(eventName, value);
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
element.setAttribute(name, value);
|
36
|
+
}
|
37
|
+
});
|
38
|
+
return element;
|
39
|
+
}
|
40
|
+
export const Fragment = Symbol('Fragment');
|
package/dist/jsx-runtime.cjs
CHANGED
@@ -1,2 +1,113 @@
|
|
1
|
-
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
function jsx(type, props) {
|
6
|
+
console.log('JSX Transform:', { type, props });
|
7
|
+
const processedProps = { ...props };
|
8
|
+
// Handle children properly
|
9
|
+
if (arguments.length > 2) {
|
10
|
+
processedProps.children = Array.prototype.slice.call(arguments, 2);
|
11
|
+
}
|
12
|
+
return { type, props: processedProps };
|
13
|
+
}
|
14
|
+
const Fragment = ({ children }) => children;
|
15
|
+
async function createElement(vnode) {
|
16
|
+
console.log('Creating element from:', vnode);
|
17
|
+
// Handle primitives and null
|
18
|
+
if (vnode == null) {
|
19
|
+
return document.createTextNode('');
|
20
|
+
}
|
21
|
+
if (typeof vnode === 'boolean') {
|
22
|
+
return document.createTextNode('');
|
23
|
+
}
|
24
|
+
if (typeof vnode === 'number' || typeof vnode === 'string') {
|
25
|
+
return document.createTextNode(String(vnode));
|
26
|
+
}
|
27
|
+
// Handle arrays
|
28
|
+
if (Array.isArray(vnode)) {
|
29
|
+
const fragment = document.createDocumentFragment();
|
30
|
+
for (const child of vnode) {
|
31
|
+
const node = await createElement(child);
|
32
|
+
fragment.appendChild(node);
|
33
|
+
}
|
34
|
+
return fragment;
|
35
|
+
}
|
36
|
+
// Handle VNode
|
37
|
+
if ('type' in vnode && vnode.props !== undefined) {
|
38
|
+
const { type, props } = vnode;
|
39
|
+
// Handle function components
|
40
|
+
if (typeof type === 'function') {
|
41
|
+
try {
|
42
|
+
const result = await type(props || {});
|
43
|
+
const node = await createElement(result);
|
44
|
+
if (node instanceof Element) {
|
45
|
+
node.setAttribute('data-component-id', type.name || type.toString());
|
46
|
+
}
|
47
|
+
return node;
|
48
|
+
}
|
49
|
+
catch (error) {
|
50
|
+
console.error('Error rendering component:', error);
|
51
|
+
return document.createTextNode('');
|
52
|
+
}
|
53
|
+
}
|
54
|
+
// Create DOM element
|
55
|
+
const element = document.createElement(type);
|
56
|
+
// Handle props
|
57
|
+
for (const [key, value] of Object.entries(props || {})) {
|
58
|
+
if (key === 'children')
|
59
|
+
continue;
|
60
|
+
if (key.startsWith('on') && typeof value === 'function') {
|
61
|
+
const eventName = key.toLowerCase().slice(2);
|
62
|
+
// Remove existing event listener if any
|
63
|
+
const existingHandler = element.__events?.[eventName];
|
64
|
+
if (existingHandler) {
|
65
|
+
element.removeEventListener(eventName, existingHandler);
|
66
|
+
}
|
67
|
+
// Add new event listener
|
68
|
+
element.addEventListener(eventName, value);
|
69
|
+
if (!element.__events) {
|
70
|
+
element.__events = {};
|
71
|
+
}
|
72
|
+
element.__events[eventName] = value;
|
73
|
+
}
|
74
|
+
else if (key === 'style' && typeof value === 'object') {
|
75
|
+
Object.assign(element.style, value);
|
76
|
+
}
|
77
|
+
else if (key === 'className') {
|
78
|
+
element.setAttribute('class', String(value));
|
79
|
+
}
|
80
|
+
else if (key !== 'key' && key !== 'ref') {
|
81
|
+
element.setAttribute(key, String(value));
|
82
|
+
}
|
83
|
+
}
|
84
|
+
// Handle children
|
85
|
+
const children = props?.children;
|
86
|
+
if (children != null) {
|
87
|
+
const childArray = Array.isArray(children) ? children.flat() : [children];
|
88
|
+
for (const child of childArray) {
|
89
|
+
const childNode = await createElement(child);
|
90
|
+
element.appendChild(childNode);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
return element;
|
94
|
+
}
|
95
|
+
// Handle other objects by converting to string
|
96
|
+
return document.createTextNode(String(vnode));
|
97
|
+
}
|
98
|
+
// Named exports object
|
99
|
+
const jsxRuntime = {
|
100
|
+
jsx,
|
101
|
+
jsxs: jsx,
|
102
|
+
jsxDEV: jsx,
|
103
|
+
Fragment,
|
104
|
+
createElement
|
105
|
+
};
|
106
|
+
|
107
|
+
exports.Fragment = Fragment;
|
108
|
+
exports.createElement = createElement;
|
109
|
+
exports.default = jsxRuntime;
|
110
|
+
exports.jsx = jsx;
|
111
|
+
exports.jsxDEV = jsx;
|
112
|
+
exports.jsxs = jsx;
|
2
113
|
//# sourceMappingURL=jsx-runtime.cjs.map
|
package/dist/jsx-runtime.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jsx-runtime.cjs","sources":[
|
1
|
+
{"version":3,"file":"jsx-runtime.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type { VNode } from './types.js';
|
2
|
+
declare function jsx(type: string | Function, props: any): VNode;
|
3
|
+
declare const Fragment: ({ children }: {
|
4
|
+
children: any;
|
5
|
+
}) => any;
|
6
|
+
declare function createElement(vnode: VNode | any): Promise<Node>;
|
7
|
+
export { jsx, jsx as jsxs, jsx as jsxDEV, Fragment, createElement };
|
8
|
+
declare const jsxRuntime: {
|
9
|
+
jsx: typeof jsx;
|
10
|
+
jsxs: typeof jsx;
|
11
|
+
jsxDEV: typeof jsx;
|
12
|
+
Fragment: ({ children }: {
|
13
|
+
children: any;
|
14
|
+
}) => any;
|
15
|
+
createElement: typeof createElement;
|
16
|
+
};
|
17
|
+
export default jsxRuntime;
|
18
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAoC,MAAM,YAAY,CAAC;AAE1E,iBAAS,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,CAUvD;AAED,QAAA,MAAM,QAAQ,iBAAkB;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,QAAa,CAAC;AAE/D,iBAAe,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAyF9D;AAGD,OAAO,EACL,GAAG,EACH,GAAG,IAAI,IAAI,EACX,GAAG,IAAI,MAAM,EACb,QAAQ,EACR,aAAa,EACd,CAAC;AAGF,QAAA,MAAM,UAAU;;;;6BAvGgB;QAAE,QAAQ,EAAE,GAAG,CAAA;KAAE;;CA6GhD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|