frontend-hamroun 1.2.79 → 1.2.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +129 -1513
  3. package/bin/cli.js +506 -145
  4. package/dist/index.cjs +2 -0
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.client.cjs +2 -0
  7. package/dist/index.client.cjs.map +1 -0
  8. package/dist/index.client.js +26 -0
  9. package/dist/index.client.js.map +1 -0
  10. package/dist/index.js +299 -1
  11. package/dist/index.js.map +1 -0
  12. package/dist/jsx-runtime.cjs +2 -0
  13. package/dist/jsx-runtime.cjs.map +1 -0
  14. package/dist/jsx-runtime.js +93 -1
  15. package/dist/jsx-runtime.js.map +1 -0
  16. package/dist/renderer-Bo9zkUZ_.js +52 -0
  17. package/dist/renderer-Bo9zkUZ_.js.map +1 -0
  18. package/dist/renderer-Din1y3YM.cjs +2 -0
  19. package/dist/renderer-Din1y3YM.cjs.map +1 -0
  20. package/dist/server-renderer-CqIpQ-od.cjs +2 -0
  21. package/dist/server-renderer-CqIpQ-od.cjs.map +1 -0
  22. package/dist/server-renderer-QHt45Ip2.js +255 -0
  23. package/dist/server-renderer-QHt45Ip2.js.map +1 -0
  24. package/dist/server-renderer.cjs +2 -0
  25. package/dist/server-renderer.cjs.map +1 -0
  26. package/dist/server-renderer.js +5 -1
  27. package/dist/server-renderer.js.map +1 -0
  28. package/package.json +77 -120
  29. package/templates/basic-app/build.js +22 -0
  30. package/templates/basic-app/dev.js +27 -0
  31. package/templates/basic-app/esbuild.config.js +28 -0
  32. package/templates/basic-app/index.html +1 -1
  33. package/templates/basic-app/package.json +29 -28
  34. package/templates/basic-app/server.js +24 -0
  35. package/templates/basic-app/src/App.jsx +16 -0
  36. package/templates/basic-app/src/App.tsx +26 -0
  37. package/templates/basic-app/src/client.jsx +5 -0
  38. package/templates/basic-app/src/client.tsx +11 -0
  39. package/templates/basic-app/src/components/Counter.jsx +13 -0
  40. package/templates/basic-app/src/components/Counter.tsx +18 -0
  41. package/templates/basic-app/src/jsx-shim.js +3 -0
  42. package/templates/basic-app/src/jsx-shim.ts +11 -0
  43. package/templates/basic-app/src/main.jsx +98 -0
  44. package/templates/basic-app/src/main.tsx +0 -1
  45. package/templates/basic-app/src/server.js +47 -0
  46. package/templates/basic-app/src/server.ts +52 -0
  47. package/templates/basic-app/tsconfig.server.json +11 -0
  48. package/templates/complete-app/lib/frontend-hamroun.js +182 -0
  49. package/templates/complete-app/package.json +2 -1
  50. package/templates/complete-app/pages/about.jsx +0 -0
  51. package/templates/complete-app/pages/index.jsx +0 -0
  52. package/templates/complete-app/pages/wasm-demo.jsx +0 -0
  53. package/templates/complete-app/public/client.js +58 -49
  54. package/templates/complete-app/public/index.html +88 -17
  55. package/templates/complete-app/public/styles.css +30 -533
  56. package/templates/complete-app/server.js +31 -222
  57. package/templates/complete-app/wasm/build.bat +0 -0
  58. package/templates/complete-app/wasm/build.sh +0 -0
  59. package/templates/complete-app/wasm/example.go +0 -0
  60. package/templates/fullstack-app/build/main.js +130 -101
  61. package/templates/fullstack-app/build/main.js.map +4 -4
  62. package/templates/fullstack-app/package-lock.json +1773 -566
  63. package/templates/ssr-template/esbuild.config.js +33 -0
  64. package/templates/ssr-template/jsx-shim.js +1 -0
  65. package/templates/ssr-template/package.json +22 -16
  66. package/templates/ssr-template/src/App.tsx +12 -52
  67. package/templates/ssr-template/src/client.tsx +3 -17
  68. package/templates/ssr-template/src/server.ts +21 -204
  69. package/templates/ssr-template/tsconfig.json +10 -13
  70. package/templates/ssr-template/tsconfig.server.json +6 -14
  71. package/templates/wasm/build-wasm.js +228 -0
  72. package/templates/wasm/esbuild.config.js +63 -0
  73. package/templates/wasm/go/main.go +256 -0
  74. package/templates/wasm/go/wasm_exec.js +0 -0
  75. package/templates/wasm/index.html +97 -0
  76. package/templates/wasm/jsx-shim.js +9 -0
  77. package/templates/{go-wasm-app → wasm}/package-lock.json +5307 -3732
  78. package/templates/wasm/package.json +42 -0
  79. package/templates/wasm/public/example.wasm +0 -0
  80. package/templates/wasm/src/App.tsx +564 -0
  81. package/templates/wasm/src/client.tsx +220 -0
  82. package/templates/wasm/src/index.tsx +21 -0
  83. package/templates/wasm/src/server.ts +145 -0
  84. package/templates/wasm/tsconfig.json +21 -0
  85. package/templates/wasm/tsconfig.node.json +13 -0
  86. package/templates/wasm/tsconfig.server.json +23 -0
  87. package/templates/wasm/vite.config.ts +56 -0
  88. package/templates/wasm/wasm-loader.js +103 -0
  89. package/dist/batch/package.json +0 -16
  90. package/dist/client-router/package.json +0 -16
  91. package/dist/component/package.json +0 -16
  92. package/dist/context/package.json +0 -16
  93. package/dist/event-bus/package.json +0 -16
  94. package/dist/forms/package.json +0 -16
  95. package/dist/hooks/package.json +0 -16
  96. package/dist/hooks-0728361a.cjs +0 -1
  97. package/dist/hooks-b58f947c.js +0 -133
  98. package/dist/hooks.js +0 -1
  99. package/dist/hooks.mjs +0 -13
  100. package/dist/index.mjs +0 -137
  101. package/dist/jsx-runtime/package.json +0 -16
  102. package/dist/jsx-runtime.mjs +0 -64
  103. package/dist/lifecycle-events/package.json +0 -16
  104. package/dist/package.json +0 -71
  105. package/dist/render-component/package.json +0 -16
  106. package/dist/renderer/package.json +0 -16
  107. package/dist/renderer.js +0 -1
  108. package/dist/renderer.mjs +0 -27
  109. package/dist/router/package.json +0 -16
  110. package/dist/server/package.json +0 -17
  111. package/dist/server/src/batch.d.ts +0 -3
  112. package/dist/server/src/batch.js +0 -23
  113. package/dist/server/src/batch.js.map +0 -1
  114. package/dist/server/src/client-router.d.ts +0 -60
  115. package/dist/server/src/client-router.js +0 -210
  116. package/dist/server/src/client-router.js.map +0 -1
  117. package/dist/server/src/component.d.ts +0 -14
  118. package/dist/server/src/component.js +0 -106
  119. package/dist/server/src/component.js.map +0 -1
  120. package/dist/server/src/context.d.ts +0 -13
  121. package/dist/server/src/context.js +0 -21
  122. package/dist/server/src/context.js.map +0 -1
  123. package/dist/server/src/event-bus.d.ts +0 -23
  124. package/dist/server/src/event-bus.js +0 -75
  125. package/dist/server/src/event-bus.js.map +0 -1
  126. package/dist/server/src/forms.d.ts +0 -40
  127. package/dist/server/src/forms.js +0 -148
  128. package/dist/server/src/forms.js.map +0 -1
  129. package/dist/server/src/hooks.d.ts +0 -12
  130. package/dist/server/src/hooks.js +0 -170
  131. package/dist/server/src/hooks.js.map +0 -1
  132. package/dist/server/src/index.client.d.ts +0 -12
  133. package/dist/server/src/index.client.js +0 -14
  134. package/dist/server/src/index.client.js.map +0 -1
  135. package/dist/server/src/index.d.ts +0 -88
  136. package/dist/server/src/index.js +0 -79
  137. package/dist/server/src/index.js.map +0 -1
  138. package/dist/server/src/jsx-runtime/jsx-dev-runtime.d.ts +0 -1
  139. package/dist/server/src/jsx-runtime/jsx-dev-runtime.js +0 -2
  140. package/dist/server/src/jsx-runtime/jsx-dev-runtime.js.map +0 -1
  141. package/dist/server/src/jsx-runtime/jsx-runtime.d.ts +0 -4
  142. package/dist/server/src/jsx-runtime/jsx-runtime.js +0 -41
  143. package/dist/server/src/jsx-runtime/jsx-runtime.js.map +0 -1
  144. package/dist/server/src/jsx-runtime.d.ts +0 -20
  145. package/dist/server/src/jsx-runtime.js +0 -105
  146. package/dist/server/src/jsx-runtime.js.map +0 -1
  147. package/dist/server/src/lifecycle-events.d.ts +0 -108
  148. package/dist/server/src/lifecycle-events.js +0 -177
  149. package/dist/server/src/lifecycle-events.js.map +0 -1
  150. package/dist/server/src/renderComponent.d.ts +0 -13
  151. package/dist/server/src/renderComponent.js +0 -30
  152. package/dist/server/src/renderComponent.js.map +0 -1
  153. package/dist/server/src/renderer.d.ts +0 -2
  154. package/dist/server/src/renderer.js +0 -31
  155. package/dist/server/src/renderer.js.map +0 -1
  156. package/dist/server/src/router.d.ts +0 -55
  157. package/dist/server/src/router.js +0 -166
  158. package/dist/server/src/router.js.map +0 -1
  159. package/dist/server/src/server/api-router.d.ts +0 -15
  160. package/dist/server/src/server/api-router.js +0 -111
  161. package/dist/server/src/server/api-router.js.map +0 -1
  162. package/dist/server/src/server/auth.d.ts +0 -32
  163. package/dist/server/src/server/auth.js +0 -80
  164. package/dist/server/src/server/auth.js.map +0 -1
  165. package/dist/server/src/server/database.d.ts +0 -24
  166. package/dist/server/src/server/database.js +0 -135
  167. package/dist/server/src/server/database.js.map +0 -1
  168. package/dist/server/src/server/index.d.ts +0 -116
  169. package/dist/server/src/server/index.js +0 -508
  170. package/dist/server/src/server/index.js.map +0 -1
  171. package/dist/server/src/server/middleware.d.ts +0 -11
  172. package/dist/server/src/server/middleware.js +0 -46
  173. package/dist/server/src/server/middleware.js.map +0 -1
  174. package/dist/server/src/server/server.d.ts +0 -9
  175. package/dist/server/src/server/server.js +0 -87
  176. package/dist/server/src/server/server.js.map +0 -1
  177. package/dist/server/src/server/templates.d.ts +0 -30
  178. package/dist/server/src/server/templates.js +0 -208
  179. package/dist/server/src/server/templates.js.map +0 -1
  180. package/dist/server/src/server/types.d.ts +0 -38
  181. package/dist/server/src/server/types.js +0 -4
  182. package/dist/server/src/server/types.js.map +0 -1
  183. package/dist/server/src/server/utils.d.ts +0 -70
  184. package/dist/server/src/server/utils.js +0 -156
  185. package/dist/server/src/server/utils.js.map +0 -1
  186. package/dist/server/src/server/wasm.d.ts +0 -9
  187. package/dist/server/src/server/wasm.js +0 -117
  188. package/dist/server/src/server/wasm.js.map +0 -1
  189. package/dist/server/src/server-renderer.d.ts +0 -5
  190. package/dist/server/src/server-renderer.js +0 -106
  191. package/dist/server/src/server-renderer.js.map +0 -1
  192. package/dist/server/src/server-types.d.ts +0 -42
  193. package/dist/server/src/server-types.js +0 -6
  194. package/dist/server/src/server-types.js.map +0 -1
  195. package/dist/server/src/store.d.ts +0 -41
  196. package/dist/server/src/store.js +0 -99
  197. package/dist/server/src/store.js.map +0 -1
  198. package/dist/server/src/types.d.ts +0 -19
  199. package/dist/server/src/types.js +0 -2
  200. package/dist/server/src/types.js.map +0 -1
  201. package/dist/server/src/utils.d.ts +0 -46
  202. package/dist/server/src/utils.js +0 -144
  203. package/dist/server/src/utils.js.map +0 -1
  204. package/dist/server/src/vdom.d.ts +0 -8
  205. package/dist/server/src/vdom.js +0 -22
  206. package/dist/server/src/vdom.js.map +0 -1
  207. package/dist/server/src/wasm.d.ts +0 -36
  208. package/dist/server/src/wasm.js +0 -159
  209. package/dist/server/src/wasm.js.map +0 -1
  210. package/dist/server/tsconfig.server.tsbuildinfo +0 -1
  211. package/dist/server-renderer/package.json +0 -16
  212. package/dist/server-renderer.mjs +0 -64
  213. package/dist/store/package.json +0 -16
  214. package/dist/types/package.json +0 -16
  215. package/dist/utils/package.json +0 -16
  216. package/dist/vdom/package.json +0 -16
  217. package/dist/wasm/package.json +0 -16
  218. package/dist/wasm.js +0 -1
  219. package/dist/wasm.mjs +0 -103
  220. package/templates/basic-app/docs/rapport_pfe.aux +0 -27
  221. package/templates/basic-app/docs/rapport_pfe.log +0 -399
  222. package/templates/basic-app/docs/rapport_pfe.out +0 -10
  223. package/templates/basic-app/docs/rapport_pfe.pdf +0 -0
  224. package/templates/basic-app/docs/rapport_pfe.tex +0 -68
  225. package/templates/basic-app/docs/rapport_pfe.toc +0 -14
  226. package/templates/complete-app/package-lock.json +0 -2536
  227. package/templates/go-wasm-app/README.md +0 -38
  228. package/templates/go-wasm-app/babel.config.js +0 -21
  229. package/templates/go-wasm-app/build-client.js +0 -49
  230. package/templates/go-wasm-app/build-wasm.js +0 -237
  231. package/templates/go-wasm-app/build.config.js +0 -62
  232. package/templates/go-wasm-app/build.js +0 -218
  233. package/templates/go-wasm-app/package.json +0 -32
  234. package/templates/go-wasm-app/public/index.html +0 -128
  235. package/templates/go-wasm-app/public/styles.css +0 -197
  236. package/templates/go-wasm-app/public/wasm/example.wasm +0 -0
  237. package/templates/go-wasm-app/public/wasm/wasm_exec_node.js +0 -39
  238. package/templates/go-wasm-app/server.js +0 -70
  239. package/templates/go-wasm-app/src/App.jsx +0 -38
  240. package/templates/go-wasm-app/src/app.js +0 -173
  241. package/templates/go-wasm-app/src/client.js +0 -57
  242. package/templates/go-wasm-app/src/components/Footer.jsx +0 -13
  243. package/templates/go-wasm-app/src/components/Header.jsx +0 -19
  244. package/templates/go-wasm-app/src/components/WasmDemo.jsx +0 -120
  245. package/templates/go-wasm-app/src/main.jsx +0 -12
  246. package/templates/go-wasm-app/src/wasm/example.go +0 -75
  247. package/templates/go-wasm-app/tsconfig.server.json +0 -18
  248. package/templates/go-wasm-app/vite.config.js +0 -45
  249. package/templates/ssr-template/client.js +0 -58
  250. package/templates/ssr-template/package-lock.json +0 -2478
  251. package/templates/ssr-template/public/index.html +0 -47
  252. package/templates/ssr-template/readme.md +0 -188
  253. package/templates/ssr-template/server.js +0 -369
  254. package/templates/ssr-template/server.ts +0 -275
  255. package/templates/ssr-template/src/client.ts +0 -61
  256. package/templates/ssr-template/src/pages/index.tsx +0 -51
  257. package/templates/ssr-template/vite.config.js +0 -57
  258. /package/{dist/Counter.d.ts → templates/complete-app/api/hello.js} +0 -0
  259. /package/templates/{go-wasm-app/public/wasm → wasm/public}/wasm_exec.js +0 -0
@@ -1,13 +0,0 @@
1
- import { jsx } from 'frontend-hamroun';
2
-
3
- export default function Footer() {
4
- return (
5
- <footer>
6
- <p>
7
- Built with <a href="https://github.com/hamroun/frontend-hamroun" target="_blank" rel="noopener noreferrer">
8
- Frontend Hamroun
9
- </a> and Go WebAssembly
10
- </p>
11
- </footer>
12
- );
13
- }
@@ -1,19 +0,0 @@
1
- import { jsx } from 'frontend-hamroun';
2
-
3
- export default function Header({ isSSR, isHydrated }) {
4
- return (
5
- <header>
6
- <h1>Frontend Hamroun + Go WebAssembly</h1>
7
- <p>A powerful combination for high-performance web applications</p>
8
-
9
- <div className="rendering-info">
10
- <span className={`badge ${isSSR ? 'active' : ''}`}>
11
- Server Rendered
12
- </span>
13
- <span className={`badge ${isHydrated ? 'active' : ''}`}>
14
- Hydrated
15
- </span>
16
- </div>
17
- </header>
18
- );
19
- }
@@ -1,120 +0,0 @@
1
- import { jsx, useState } from 'frontend-hamroun';
2
-
3
- export default function WasmDemo({ wasm }) {
4
- // Addition demo state
5
- const [num1, setNum1] = useState(5);
6
- const [num2, setNum2] = useState(7);
7
- const [sum, setSum] = useState(null);
8
-
9
- // Data processing demo state
10
- const [processInput, setProcessInput] = useState(JSON.stringify({
11
- name: 'Test data',
12
- source: 'client',
13
- values: [10, 20, 30, 40, 50],
14
- timestamp: new Date().toISOString()
15
- }, null, 2));
16
- const [processResult, setProcessResult] = useState(null);
17
-
18
- // Error state
19
- const [error, setError] = useState(null);
20
-
21
- // Handle addition with Go WASM
22
- const handleCalculate = () => {
23
- try {
24
- setError(null);
25
- // Get the goAdd function from the WASM instance
26
- const goAdd = wasm.functions.goAdd;
27
- // Call the Go function and get the result
28
- const result = goAdd(parseInt(num1), parseInt(num2));
29
- setSum(result);
30
- } catch (err) {
31
- console.error('Error calling Go function:', err);
32
- setError(`Error: ${err.message}`);
33
- }
34
- };
35
-
36
- // Handle complex data processing with Go WASM
37
- const handleProcessData = () => {
38
- try {
39
- setError(null);
40
- // Parse the input JSON
41
- const inputData = JSON.parse(processInput);
42
- // Get the goProcessData function from the WASM instance
43
- const goProcessData = wasm.functions.goProcessData;
44
- // Call the Go function with the data
45
- const result = goProcessData(inputData);
46
- // Parse the returned JSON and format it
47
- setProcessResult(JSON.parse(result));
48
- } catch (err) {
49
- console.error('Error processing data with Go:', err);
50
- setError(`Error: ${err.message}`);
51
- }
52
- };
53
-
54
- return (
55
- <div className="wasm-demo">
56
- {error && (
57
- <div className="error-message">
58
- {error}
59
- </div>
60
- )}
61
-
62
- <section className="demo-section">
63
- <h2>Simple Addition with Go</h2>
64
- <p>Call a Go WASM function to add two numbers:</p>
65
- <div className="input-row">
66
- <input
67
- type="number"
68
- value={num1}
69
- onChange={(e) => setNum1(e.target.value)}
70
- />
71
- <span className="operator">+</span>
72
- <input
73
- type="number"
74
- value={num2}
75
- onChange={(e) => setNum2(e.target.value)}
76
- />
77
- <button onClick={handleCalculate}>Calculate</button>
78
- </div>
79
-
80
- {sum !== null && (
81
- <div className="result">
82
- <h3>Result:</h3>
83
- <pre>{sum}</pre>
84
- </div>
85
- )}
86
- </section>
87
-
88
- <section className="demo-section">
89
- <h2>Complex Data Processing with Go</h2>
90
- <p>Process JSON data using a Go WASM function:</p>
91
- <div className="json-editor">
92
- <textarea
93
- value={processInput}
94
- onChange={(e) => setProcessInput(e.target.value)}
95
- rows={10}
96
- />
97
- <button onClick={handleProcessData}>Process Data</button>
98
- </div>
99
-
100
- {processResult && (
101
- <div className="result">
102
- <h3>Processed Result:</h3>
103
- <pre>{JSON.stringify(processResult, null, 2)}</pre>
104
- </div>
105
- )}
106
- </section>
107
-
108
- <section className="info-section">
109
- <h2>How It Works</h2>
110
- <p>This demo demonstrates the integration between Frontend Hamroun and Go WebAssembly with SSR:</p>
111
- <ol>
112
- <li>Server renders the initial HTML using the same React-like components</li>
113
- <li>Server can process data with Go WASM before sending the response</li>
114
- <li>Browser hydrates the app and loads its own WASM module</li>
115
- <li>The same Go code runs in both server and browser environments</li>
116
- </ol>
117
- </section>
118
- </div>
119
- );
120
- }
@@ -1,12 +0,0 @@
1
- import { hydrate } from 'frontend-hamroun';
2
- import App from './App';
3
-
4
- // Get initial state from server
5
- const initialState = window.__INITIAL_STATE__ || {
6
- path: window.location.pathname,
7
- ssrRendered: false,
8
- wasmAvailable: false
9
- };
10
-
11
- // Hydrate the application
12
- hydrate(<App initialState={initialState} />, document.getElementById('root'));
@@ -1,75 +0,0 @@
1
- //go:build js && wasm
2
- // +build js,wasm
3
-
4
- package main
5
-
6
- import (
7
- "encoding/json"
8
- "fmt"
9
- "syscall/js"
10
- )
11
-
12
- // Example Go function to be called from JavaScript
13
- func add(this js.Value, args []js.Value) interface{} {
14
- if len(args) != 2 {
15
- return js.ValueOf("Error: Expected two arguments")
16
- }
17
-
18
- a := args[0].Int()
19
- b := args[1].Int()
20
- return js.ValueOf(a + b)
21
- }
22
-
23
- // Process complex data in Go
24
- func processData(this js.Value, args []js.Value) interface{} {
25
- if len(args) == 0 {
26
- return js.ValueOf("Error: Expected at least one argument")
27
- }
28
-
29
- // Get input data
30
- data := args[0]
31
- if data.Type() != js.TypeObject {
32
- return js.ValueOf("Error: Expected JSON object")
33
- }
34
-
35
- // Convert JS object to Go map
36
- jsonStr := js.Global().Get("JSON").Call("stringify", data).String()
37
- var inputMap map[string]interface{}
38
- if err := json.Unmarshal([]byte(jsonStr), &inputMap); err != nil {
39
- return js.ValueOf(fmt.Sprintf("Error parsing JSON: %s", err.Error()))
40
- }
41
-
42
- // Add new fields
43
- inputMap["processed"] = true
44
- inputMap["processor"] = "Go WASM"
45
-
46
- // Add some computed fields
47
- if values, ok := inputMap["values"].([]interface{}); ok {
48
- sum := 0.0
49
- for _, v := range values {
50
- if num, ok := v.(float64); ok {
51
- sum += num
52
- }
53
- }
54
- inputMap["sum"] = sum
55
- }
56
-
57
- // Convert back to JS
58
- resultJSON, err := json.Marshal(inputMap)
59
- if err != nil {
60
- return js.ValueOf(fmt.Sprintf("Error generating JSON: %s", err.Error()))
61
- }
62
-
63
- return js.ValueOf(string(resultJSON))
64
- }
65
-
66
- func main() {
67
- fmt.Println("Go WASM Module initialized")
68
-
69
- // Register functions to be callable from JavaScript
70
- js.Global().Set("goAdd", js.FuncOf(add))
71
- js.Global().Set("goProcessData", js.FuncOf(processData))
72
-
73
- // Keep the program running
74
- <-make(chan bool)
75
- }
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "Node",
6
- "esModuleInterop": true,
7
- "strict": true,
8
- "skipLibCheck": true,
9
- "outDir": "dist/server",
10
- "jsx": "react",
11
- "jsxFactory": "jsx",
12
- "jsxFragmentFactory": "Fragment",
13
- "allowJs": true,
14
- "declaration": false
15
- },
16
- "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"],
17
- "exclude": ["node_modules"]
18
- }
@@ -1,45 +0,0 @@
1
- import { defineConfig } from 'vite';
2
- import { resolve } from 'path';
3
-
4
- export default defineConfig({
5
- // Configure JSX
6
- esbuild: {
7
- jsxFactory: 'createElement',
8
- jsxFragment: 'Fragment',
9
- jsxInject: `import { createElement, Fragment } from 'frontend-hamroun'`
10
- },
11
-
12
- // Configure build
13
- build: {
14
- outDir: 'dist',
15
- emptyOutDir: true,
16
- rollupOptions: {
17
- input: {
18
- client: resolve(__dirname, 'src/client.js')
19
- },
20
- output: [
21
- {
22
- // ESM output
23
- entryFileNames: 'assets/[name].mjs',
24
- chunkFileNames: 'assets/[name]-[hash].mjs',
25
- assetFileNames: 'assets/[name]-[hash].[ext]',
26
- format: 'es',
27
- },
28
- {
29
- // CommonJS output
30
- entryFileNames: 'assets/[name].js',
31
- chunkFileNames: 'assets/[name]-[hash].js',
32
- assetFileNames: 'assets/[name]-[hash].[ext]',
33
- format: 'cjs',
34
- }
35
- ]
36
- }
37
- },
38
-
39
- // Resolve aliases for better imports
40
- resolve: {
41
- alias: {
42
- '@': resolve(__dirname, 'src')
43
- }
44
- }
45
- });
@@ -1,58 +0,0 @@
1
- import { hydrate, jsx } from 'frontend-hamroun';
2
-
3
- // Create a sample virtual DOM matching what was rendered on the server
4
- const app = {
5
- type: 'div',
6
- props: {
7
- id: 'app',
8
- children: [
9
- {
10
- type: 'h1',
11
- props: {
12
- children: 'Hello from Server-Side Rendering!'
13
- }
14
- },
15
- {
16
- type: 'p',
17
- props: {
18
- children: `This page was rendered at ${new Date().toISOString()}`
19
- }
20
- },
21
- {
22
- type: 'button',
23
- props: {
24
- id: 'counter-btn',
25
- className: 'btn',
26
- onClick: () => {
27
- let count = 1; // Start at 1 since we're updating
28
- const btn = document.getElementById('counter-btn');
29
- if (btn) {
30
- btn.textContent = `Click me (${count})`;
31
- btn.addEventListener('click', () => {
32
- count++;
33
- btn.textContent = `Click me (${count})`;
34
- });
35
- }
36
- },
37
- children: 'Click me (0)'
38
- }
39
- }
40
- ]
41
- }
42
- };
43
-
44
- // Wait for DOM to be fully loaded before hydrating
45
- window.addEventListener('DOMContentLoaded', () => {
46
- console.log('Hydrating client-side content...');
47
-
48
- // Get the container element
49
- const container = document.getElementById('app');
50
- if (!container) {
51
- console.error('Could not find app container for hydration');
52
- return;
53
- }
54
-
55
- // Hydrate the app
56
- hydrate(app, container);
57
- console.log('Hydration complete!');
58
- });