resuxjs 0.2.42 → 0.3.0

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 (266) hide show
  1. package/README.md +991 -666
  2. package/dist/cli.js +1990 -355
  3. package/dist/cli.js.map +1 -1
  4. package/dist/compiler/adapter.d.ts +17 -0
  5. package/dist/compiler/adapter.js +106 -0
  6. package/dist/compiler/adapter.js.map +1 -0
  7. package/dist/compiler/dev-warnings.d.ts +11 -0
  8. package/dist/compiler/dev-warnings.js +360 -0
  9. package/dist/compiler/dev-warnings.js.map +1 -0
  10. package/dist/compiler/directives.d.ts +13 -0
  11. package/dist/compiler/directives.js +167 -0
  12. package/dist/compiler/directives.js.map +1 -0
  13. package/dist/compiler/implementation.d.ts +129 -0
  14. package/dist/compiler/implementation.js +3745 -0
  15. package/dist/compiler/implementation.js.map +1 -0
  16. package/dist/compiler/index.d.ts +9 -103
  17. package/dist/compiler/index.js +74 -1971
  18. package/dist/compiler/index.js.map +1 -1
  19. package/dist/core/config.d.ts +8 -0
  20. package/dist/core/config.js +21 -0
  21. package/dist/core/config.js.map +1 -0
  22. package/dist/core/hooks.d.ts +133 -0
  23. package/dist/core/hooks.js +54 -0
  24. package/dist/core/hooks.js.map +1 -0
  25. package/dist/core/index.d.ts +4 -0
  26. package/dist/core/index.js +5 -0
  27. package/dist/core/index.js.map +1 -0
  28. package/dist/core/module-container.d.ts +100 -0
  29. package/dist/core/module-container.js +171 -0
  30. package/dist/core/module-container.js.map +1 -0
  31. package/dist/core/resux.d.ts +18 -0
  32. package/dist/core/resux.js +18 -0
  33. package/dist/core/resux.js.map +1 -0
  34. package/dist/create.d.ts +1 -0
  35. package/dist/create.js +878 -22
  36. package/dist/create.js.map +1 -1
  37. package/dist/deploy/cloudflare.js +17 -3
  38. package/dist/deploy/cloudflare.js.map +1 -1
  39. package/dist/deploy/common.js +4 -3
  40. package/dist/deploy/common.js.map +1 -1
  41. package/dist/fonts/index.d.ts +16 -0
  42. package/dist/fonts/index.js +154 -0
  43. package/dist/fonts/index.js.map +1 -0
  44. package/dist/globals.d.ts +27 -2
  45. package/dist/halal-core/ai/classifyProject.d.ts +4 -0
  46. package/dist/halal-core/ai/classifyProject.js +104 -0
  47. package/dist/halal-core/ai/classifyProject.js.map +1 -0
  48. package/dist/halal-core/ai/createProjectSummary.d.ts +39 -0
  49. package/dist/halal-core/ai/createProjectSummary.js +42 -0
  50. package/dist/halal-core/ai/createProjectSummary.js.map +1 -0
  51. package/dist/halal-core/ai/halalClassifierPrompt.d.ts +1 -0
  52. package/dist/halal-core/ai/halalClassifierPrompt.js +20 -0
  53. package/dist/halal-core/ai/halalClassifierPrompt.js.map +1 -0
  54. package/dist/halal-core/ai/redactSensitiveData.d.ts +1 -0
  55. package/dist/halal-core/ai/redactSensitiveData.js +139 -0
  56. package/dist/halal-core/ai/redactSensitiveData.js.map +1 -0
  57. package/dist/halal-core/ai/validateAiResponse.d.ts +2 -0
  58. package/dist/halal-core/ai/validateAiResponse.js +97 -0
  59. package/dist/halal-core/ai/validateAiResponse.js.map +1 -0
  60. package/dist/halal-core/cli/check.d.ts +1 -0
  61. package/dist/halal-core/cli/check.js +36 -0
  62. package/dist/halal-core/cli/check.js.map +1 -0
  63. package/dist/halal-core/cli/explain.d.ts +1 -0
  64. package/dist/halal-core/cli/explain.js +35 -0
  65. package/dist/halal-core/cli/explain.js.map +1 -0
  66. package/dist/halal-core/cli/report.d.ts +1 -0
  67. package/dist/halal-core/cli/report.js +15 -0
  68. package/dist/halal-core/cli/report.js.map +1 -0
  69. package/dist/halal-core/cli/submitReview.d.ts +1 -0
  70. package/dist/halal-core/cli/submitReview.js +12 -0
  71. package/dist/halal-core/cli/submitReview.js.map +1 -0
  72. package/dist/halal-core/cli/verifyReview.d.ts +1 -0
  73. package/dist/halal-core/cli/verifyReview.js +19 -0
  74. package/dist/halal-core/cli/verifyReview.js.map +1 -0
  75. package/dist/halal-core/config.d.ts +40 -0
  76. package/dist/halal-core/config.js +128 -0
  77. package/dist/halal-core/config.js.map +1 -0
  78. package/dist/halal-core/crypto/integrity.d.ts +9 -0
  79. package/dist/halal-core/crypto/integrity.js +101 -0
  80. package/dist/halal-core/crypto/integrity.js.map +1 -0
  81. package/dist/halal-core/enforce.d.ts +5 -0
  82. package/dist/halal-core/enforce.js +119 -0
  83. package/dist/halal-core/enforce.js.map +1 -0
  84. package/dist/halal-core/index.d.ts +14 -0
  85. package/dist/halal-core/index.js +17 -0
  86. package/dist/halal-core/index.js.map +1 -0
  87. package/dist/halal-core/lifecycle.d.ts +1 -0
  88. package/dist/halal-core/lifecycle.js +15 -0
  89. package/dist/halal-core/lifecycle.js.map +1 -0
  90. package/dist/halal-core/policy.d.ts +2 -0
  91. package/dist/halal-core/policy.js +5 -0
  92. package/dist/halal-core/policy.js.map +1 -0
  93. package/dist/halal-core/report/formatBrowserOverlay.d.ts +2 -0
  94. package/dist/halal-core/report/formatBrowserOverlay.js +41 -0
  95. package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -0
  96. package/dist/halal-core/report/formatTerminalReport.d.ts +2 -0
  97. package/dist/halal-core/report/formatTerminalReport.js +39 -0
  98. package/dist/halal-core/report/formatTerminalReport.js.map +1 -0
  99. package/dist/halal-core/report/generateHalalReport.d.ts +7 -0
  100. package/dist/halal-core/report/generateHalalReport.js +46 -0
  101. package/dist/halal-core/report/generateHalalReport.js.map +1 -0
  102. package/dist/halal-core/report/signReport.d.ts +3 -0
  103. package/dist/halal-core/report/signReport.js +17 -0
  104. package/dist/halal-core/report/signReport.js.map +1 -0
  105. package/dist/halal-core/report/verifyReport.d.ts +11 -0
  106. package/dist/halal-core/report/verifyReport.js +45 -0
  107. package/dist/halal-core/report/verifyReport.js.map +1 -0
  108. package/dist/halal-core/review/createReviewRequest.d.ts +2 -0
  109. package/dist/halal-core/review/createReviewRequest.js +21 -0
  110. package/dist/halal-core/review/createReviewRequest.js.map +1 -0
  111. package/dist/halal-core/review/reviewPolicy.d.ts +3 -0
  112. package/dist/halal-core/review/reviewPolicy.js +21 -0
  113. package/dist/halal-core/review/reviewPolicy.js.map +1 -0
  114. package/dist/halal-core/review/signedReviewFile.d.ts +13 -0
  115. package/dist/halal-core/review/signedReviewFile.js +28 -0
  116. package/dist/halal-core/review/signedReviewFile.js.map +1 -0
  117. package/dist/halal-core/review/verifyReviewApproval.d.ts +10 -0
  118. package/dist/halal-core/review/verifyReviewApproval.js +68 -0
  119. package/dist/halal-core/review/verifyReviewApproval.js.map +1 -0
  120. package/dist/halal-core/rules/adultContentRules.d.ts +2 -0
  121. package/dist/halal-core/rules/adultContentRules.js +26 -0
  122. package/dist/halal-core/rules/adultContentRules.js.map +1 -0
  123. package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +2 -0
  124. package/dist/halal-core/rules/alcoholDrugVapeRules.js +25 -0
  125. package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -0
  126. package/dist/halal-core/rules/childSafetyRules.d.ts +2 -0
  127. package/dist/halal-core/rules/childSafetyRules.js +22 -0
  128. package/dist/halal-core/rules/childSafetyRules.js.map +1 -0
  129. package/dist/halal-core/rules/coreCategories.d.ts +7 -0
  130. package/dist/halal-core/rules/coreCategories.js +112 -0
  131. package/dist/halal-core/rules/coreCategories.js.map +1 -0
  132. package/dist/halal-core/rules/cyberAbuseRules.d.ts +2 -0
  133. package/dist/halal-core/rules/cyberAbuseRules.js +30 -0
  134. package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -0
  135. package/dist/halal-core/rules/defaultBlockedRules.d.ts +20 -0
  136. package/dist/halal-core/rules/defaultBlockedRules.js +216 -0
  137. package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -0
  138. package/dist/halal-core/rules/dependencyRules.d.ts +9 -0
  139. package/dist/halal-core/rules/dependencyRules.js +59 -0
  140. package/dist/halal-core/rules/dependencyRules.js.map +1 -0
  141. package/dist/halal-core/rules/endpointRules.d.ts +6 -0
  142. package/dist/halal-core/rules/endpointRules.js +26 -0
  143. package/dist/halal-core/rules/endpointRules.js.map +1 -0
  144. package/dist/halal-core/rules/environmentalHarmRules.d.ts +2 -0
  145. package/dist/halal-core/rules/environmentalHarmRules.js +20 -0
  146. package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -0
  147. package/dist/halal-core/rules/financeRibaRules.d.ts +2 -0
  148. package/dist/halal-core/rules/financeRibaRules.js +23 -0
  149. package/dist/halal-core/rules/financeRibaRules.js.map +1 -0
  150. package/dist/halal-core/rules/gamblingRules.d.ts +2 -0
  151. package/dist/halal-core/rules/gamblingRules.js +25 -0
  152. package/dist/halal-core/rules/gamblingRules.js.map +1 -0
  153. package/dist/halal-core/rules/generalHarmRules.d.ts +2 -0
  154. package/dist/halal-core/rules/generalHarmRules.js +18 -0
  155. package/dist/halal-core/rules/generalHarmRules.js.map +1 -0
  156. package/dist/halal-core/rules/healthHarmRules.d.ts +2 -0
  157. package/dist/halal-core/rules/healthHarmRules.js +22 -0
  158. package/dist/halal-core/rules/healthHarmRules.js.map +1 -0
  159. package/dist/halal-core/rules/keywordRules.d.ts +10 -0
  160. package/dist/halal-core/rules/keywordRules.js +41 -0
  161. package/dist/halal-core/rules/keywordRules.js.map +1 -0
  162. package/dist/halal-core/rules/privacyAbuseRules.d.ts +2 -0
  163. package/dist/halal-core/rules/privacyAbuseRules.js +24 -0
  164. package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -0
  165. package/dist/halal-core/rules/scamFraudRules.d.ts +2 -0
  166. package/dist/halal-core/rules/scamFraudRules.js +32 -0
  167. package/dist/halal-core/rules/scamFraudRules.js.map +1 -0
  168. package/dist/halal-core/rules/selfHarmRules.d.ts +2 -0
  169. package/dist/halal-core/rules/selfHarmRules.js +20 -0
  170. package/dist/halal-core/rules/selfHarmRules.js.map +1 -0
  171. package/dist/halal-core/rules/violenceExtremismRules.d.ts +2 -0
  172. package/dist/halal-core/rules/violenceExtremismRules.js +33 -0
  173. package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -0
  174. package/dist/halal-core/scanner/scanApiRoutes.d.ts +1 -0
  175. package/dist/halal-core/scanner/scanApiRoutes.js +40 -0
  176. package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -0
  177. package/dist/halal-core/scanner/scanComponents.d.ts +1 -0
  178. package/dist/halal-core/scanner/scanComponents.js +17 -0
  179. package/dist/halal-core/scanner/scanComponents.js.map +1 -0
  180. package/dist/halal-core/scanner/scanContent.d.ts +5 -0
  181. package/dist/halal-core/scanner/scanContent.js +302 -0
  182. package/dist/halal-core/scanner/scanContent.js.map +1 -0
  183. package/dist/halal-core/scanner/scanDependencies.d.ts +1 -0
  184. package/dist/halal-core/scanner/scanDependencies.js +19 -0
  185. package/dist/halal-core/scanner/scanDependencies.js.map +1 -0
  186. package/dist/halal-core/scanner/scanDomains.d.ts +4 -0
  187. package/dist/halal-core/scanner/scanDomains.js +14 -0
  188. package/dist/halal-core/scanner/scanDomains.js.map +1 -0
  189. package/dist/halal-core/scanner/scanEnvNames.d.ts +1 -0
  190. package/dist/halal-core/scanner/scanEnvNames.js +30 -0
  191. package/dist/halal-core/scanner/scanEnvNames.js.map +1 -0
  192. package/dist/halal-core/scanner/scanMetadata.d.ts +6 -0
  193. package/dist/halal-core/scanner/scanMetadata.js +33 -0
  194. package/dist/halal-core/scanner/scanMetadata.js.map +1 -0
  195. package/dist/halal-core/scanner/scanPages.d.ts +1 -0
  196. package/dist/halal-core/scanner/scanPages.js +19 -0
  197. package/dist/halal-core/scanner/scanPages.js.map +1 -0
  198. package/dist/halal-core/scanner/scanProject.d.ts +13 -0
  199. package/dist/halal-core/scanner/scanProject.js +62 -0
  200. package/dist/halal-core/scanner/scanProject.js.map +1 -0
  201. package/dist/halal-core/scanner/scanRoutes.d.ts +1 -0
  202. package/dist/halal-core/scanner/scanRoutes.js +43 -0
  203. package/dist/halal-core/scanner/scanRoutes.js.map +1 -0
  204. package/dist/halal-core/scanner/scanTranslations.d.ts +1 -0
  205. package/dist/halal-core/scanner/scanTranslations.js +32 -0
  206. package/dist/halal-core/scanner/scanTranslations.js.map +1 -0
  207. package/dist/halal-core/status.d.ts +14 -0
  208. package/dist/halal-core/status.js +2 -0
  209. package/dist/halal-core/status.js.map +1 -0
  210. package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +1 -0
  211. package/dist/halal-core/tamper/verifyCoreIntegrity.js +28 -0
  212. package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -0
  213. package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +1 -0
  214. package/dist/halal-core/tamper/verifyLifecycleHooks.js +14 -0
  215. package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -0
  216. package/dist/halal-core/tamper/verifyReportSignature.d.ts +5 -0
  217. package/dist/halal-core/tamper/verifyReportSignature.js +18 -0
  218. package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -0
  219. package/dist/i18n/index.d.ts +45 -0
  220. package/dist/i18n/index.js +284 -0
  221. package/dist/i18n/index.js.map +1 -0
  222. package/dist/i18n/shared.d.ts +35 -0
  223. package/dist/i18n/shared.js +270 -0
  224. package/dist/i18n/shared.js.map +1 -0
  225. package/dist/icons/index.d.ts +159 -0
  226. package/dist/icons/index.js +286 -0
  227. package/dist/icons/index.js.map +1 -0
  228. package/dist/kit/index.d.ts +29 -0
  229. package/dist/kit/index.js +72 -0
  230. package/dist/kit/index.js.map +1 -0
  231. package/dist/nitro-server/index.d.ts +7 -0
  232. package/dist/nitro-server/index.js +4 -0
  233. package/dist/nitro-server/index.js.map +1 -0
  234. package/dist/reactivity/computed.js +9 -4
  235. package/dist/reactivity/computed.js.map +1 -1
  236. package/dist/reactivity/effect.d.ts +3 -1
  237. package/dist/reactivity/effect.js +56 -6
  238. package/dist/reactivity/effect.js.map +1 -1
  239. package/dist/reactivity/reactive.js +64 -15
  240. package/dist/reactivity/reactive.js.map +1 -1
  241. package/dist/reactivity/ref.d.ts +1 -0
  242. package/dist/reactivity/ref.js +13 -6
  243. package/dist/reactivity/ref.js.map +1 -1
  244. package/dist/reactivity/scheduler.js +36 -4
  245. package/dist/reactivity/scheduler.js.map +1 -1
  246. package/dist/reactivity/watch.js +27 -5
  247. package/dist/reactivity/watch.js.map +1 -1
  248. package/dist/runtime/index.d.ts +226 -3
  249. package/dist/runtime/index.js +13344 -6395
  250. package/dist/runtime/index.js.map +1 -1
  251. package/dist/ui/index.d.ts +1828 -0
  252. package/dist/ui/index.js +938 -0
  253. package/dist/ui/index.js.map +1 -0
  254. package/dist/vite-builder/index.d.ts +6 -0
  255. package/dist/vite-builder/index.js +4 -0
  256. package/dist/vite-builder/index.js.map +1 -0
  257. package/package.json +145 -105
  258. package/templates/default/.env.example +1 -0
  259. package/templates/default/README.md +18 -14
  260. package/templates/default/_gitignore +8 -5
  261. package/templates/default/assets/css/main.css +4 -0
  262. package/templates/default/nitro.config.ts +9 -5
  263. package/templates/default/pages/index.vue +102 -87
  264. package/templates/default/public/favicon.svg +4 -0
  265. package/templates/default/types/app.d.ts +3 -0
  266. package/templates/default/.resux-nitro/handler.ts +0 -21
package/README.md CHANGED
@@ -1,666 +1,991 @@
1
- # Resux
2
-
3
- Resux is an experimental web framework with a custom resumable runtime.
4
-
5
- It uses familiar `.vue` files and `pages/` routing, but normal Resux components do not use Vue hydration or the Vue runtime. The compiler parses a small Vue-like SFC subset, renders HTML on the server, serializes route and component state, then loads client code only when an event is triggered. Vue runtime is available as an opt-in island escape hatch for complex client widgets.
6
-
7
- The v1 release line treats the documented compiler, SSR renderer, resume runtime, routing, and CLI commands as the stable core. Advanced Vue compatibility, Vue islands, Nitro adapter behavior, and unsupported Vue SFC syntax are still experimental and should fail loudly instead of silently falling back to hydration.
8
-
9
- ## Create App
10
-
11
- Create a new app with the latest published Resux package:
12
-
13
- ```sh
14
- npx resuxjs@latest init
15
- ```
16
-
17
- With a project directory:
18
-
19
- ```sh
20
- npx resuxjs@latest init my-app
21
- ```
22
-
23
- With create options:
24
-
25
- ```sh
26
- npx resuxjs@latest init my-app --no-install
27
- ```
28
-
29
- Generated apps use a single Resux dependency, similar to Nuxt apps installing `nuxt`:
30
-
31
- ```json
32
- {
33
- "dependencies": {
34
- "resuxjs": "^<current-version>"
35
- }
36
- }
37
- ```
38
-
39
- For local development before publishing:
40
-
41
- ```sh
42
- npm install
43
- npm run typecheck
44
- npm run build
45
- npm run create:local -- my-app --no-install
46
- ```
47
-
48
- Then run the generated app:
49
-
50
- ```sh
51
- cd my-app
52
- npm install
53
- npm run dev
54
- ```
55
-
56
- ## Package Layout
57
-
58
- ```txt
59
- src/
60
- compiler/ SFC parser, route manifest builder, code generator
61
- runtime/ SSR renderer, composables, client resume loader source
62
- index.ts Runtime-only public root export
63
- cli.ts Resux CLI, dev server, preview server, deploy helpers
64
- node.ts Node server handler export for adapters
65
- create.ts App scaffolder used by `resux init`
66
-
67
- templates/ Starter files copied by `resux init`
68
- tests/ Compiler, SSR, and client resume tests
69
- ```
70
-
71
- Public imports are split so browser/client bundles do not accidentally pull compiler or server code:
72
-
73
- ```ts
74
- import { renderApp } from "resuxjs/runtime"
75
- import { createResuxNodeHandler } from "resuxjs/node"
76
- ```
77
-
78
- ## Development
79
-
80
- ```sh
81
- npm install
82
- npm run typecheck
83
- npm run build
84
- npm test
85
- ```
86
-
87
- Run the full publish-readiness check:
88
-
89
- ```sh
90
- npm run pack:check
91
- ```
92
-
93
- This builds, tests, and dry-runs npm packing for the single `resuxjs` package.
94
-
95
- CI runs on every push and pull request with `npm ci`, optional linting, typecheck, build, tests, and package dry-run checks.
96
-
97
- ## Release Process
98
-
99
- Normal pushes never publish to npm. They only run CI. Publishing is intentionally gated to version tags or GitHub Releases so an ordinary `main` push cannot publish a broken package.
100
-
101
- To release:
102
-
103
- 1. Update the version and create the release commit/tag with `npm version 1.0.0`.
104
- 2. Push the release commit with `git push origin main`.
105
- 3. Push the version tag with `git push origin v1.0.0`.
106
- 4. The GitHub Action publishes `resuxjs@1.0.0` to npm.
107
-
108
- The npm publish workflow validates that the tag matches `package.json`, runs `npm ci` and `npm run pack:check`, skips publishing if the package version already exists, then publishes with `NPM_TOKEN` and npm provenance.
109
-
110
- ## CLI
111
-
112
- The `resux` CLI supports:
113
-
114
- ```sh
115
- resux init <project-dir>
116
- resux dev <app-root>
117
- resux build <app-root>
118
- resux preview <app-root>
119
- resux start <app-root>
120
- resux inspect <app-root>
121
- resux deploy <app-root>
122
- ```
123
-
124
- If `<app-root>` is omitted, Resux uses the current directory.
125
-
126
- Useful server flags:
127
-
128
- ```sh
129
- resux dev --port 4000
130
- resux preview --host 0.0.0.0 --port 4000
131
- resux start --host 0.0.0.0 --port 3000
132
- resux inspect
133
- resux inspect --json
134
- resux deploy . --preset docker
135
- resux deploy . --preset nitro
136
- resux --help
137
- resux --version
138
- ```
139
-
140
- Build output is written to:
141
-
142
- ```txt
143
- <app-root>/.resux
144
- ```
145
-
146
- ## App Types
147
-
148
- Generated apps include `env.d.ts` and `tsconfig.json` wired to `resuxjs/globals`, so app files can use the Resux-style globals without imports:
149
-
150
- ```ts
151
- const count = useState("count", () => 0)
152
- const route = useRoute()
153
- const router = useRouter()
154
- useSeoMeta({
155
- title: "My App",
156
- description: "My app description",
157
- ogTitle: "My App"
158
- })
159
-
160
- function openAbout() {
161
- router.push("/about")
162
- }
163
-
164
- export default defineResuxConfig({
165
- app: {
166
- head: {
167
- title: "My App"
168
- }
169
- }
170
- })
171
- ```
172
-
173
- ## Reactivity APIs
174
-
175
- Resux includes a native reactivity layer for resumable components. You can use it with globals in app files, or import directly:
176
-
177
- ```ts
178
- import {
179
- ref,
180
- reactive,
181
- computed,
182
- watch,
183
- watchEffect,
184
- readonly,
185
- toRef,
186
- toRefs,
187
- unref,
188
- isRef,
189
- isReactive,
190
- isReadonly,
191
- nextTick
192
- } from "resuxjs"
193
- ```
194
-
195
- Or from the focused subpath:
196
-
197
- ```ts
198
- import { ref, reactive, computed } from "resuxjs/reactivity"
199
- ```
200
-
201
- These APIs are Resux-native. Normal Resux components do not depend on Vue hydration runtime.
202
-
203
- ## Vite
204
-
205
- Resux uses Vite in both main app commands:
206
-
207
- - `resux dev` emits Resux client modules into `.resux/vite-client` and serves the resume runtime plus handler modules through Vite middleware.
208
- - `resux dev` also opens a dev-only update channel at `/__resux/dev-events`; when source files change, Resux rebuilds and reloads the browser so route, template, and style changes are visible without restarting the dev server.
209
- - `resux build` uses Vite production bundling for the resume runtime, handler chunks, and server manifest, then writes optimized output into `.resux/client` and `.resux/server-bundle` before producing a Nitro `.output` server.
210
-
211
- The generated starter keeps Resux-style scripts:
212
-
213
- ```json
214
- {
215
- "scripts": {
216
- "dev": "resux dev .",
217
- "build": "resux build .",
218
- "preview": "resux preview .",
219
- "start": "node .output/server/index.mjs",
220
- "inspect": "resux inspect ."
221
- }
222
- }
223
- ```
224
-
225
- Tailwind can stay Nuxt-style simple too. If your app has `assets/css/tailwind.css` and `tailwindcss` installed, `resux dev` automatically runs Tailwind in watch mode and `resux build` generates a minified `public/tailwind.css` before bundling. No separate `concurrently` script is required.
226
-
227
- ## Deployment
228
-
229
- Build and serve with the Node server:
230
-
231
- ```sh
232
- npm run build
233
- npm run start
234
- ```
235
-
236
- Production serving enables default hardening headers such as `x-content-type-options`, `referrer-policy`, `x-frame-options`, `cross-origin-opener-policy`, and a restrictive `permissions-policy`. Disable them only when the host or reverse proxy owns those headers:
237
-
238
- ```sh
239
- resux start . --no-security-headers
240
- ```
241
-
242
- Generated apps include a `Dockerfile`, `.dockerignore`, and `DEPLOYMENT.md`. Use `resux inspect --json` in CI to capture the built routes, server handlers, route rules, feature flags, and diagnostics.
243
-
244
- Existing apps can generate or refresh deployment files without changing application code:
245
-
246
- ```sh
247
- resux deploy . --preset node
248
- resux deploy . --preset docker --force
249
- resux deploy . --preset nitro --force
250
- ```
251
-
252
- The Nitro preset writes `nitro.config.ts` and a small `.resux-nitro/handler.ts` adapter. `resux build` now produces Nuxt-style `.output` by default:
253
-
254
- ```sh
255
- npm run build
256
- node .output/server/index.mjs
257
- ```
258
-
259
- The generated Nitro config is conservative for resumability: SSR pages, API routes, and route payloads use `cache-control: no-store`, while build-stable Resux runtime and handler assets use long immutable caching. Nitro prerender crawling is disabled by default.
260
-
261
- Deployment target selection is automatic by default (`deploy.target = "auto"`). Resux resolves target/preset from:
262
-
263
- - explicit `deploy.target` / `deploy.nitroPreset` in `resux.config.ts`
264
- - `NITRO_PRESET` / `RESUX_NITRO_PRESET`
265
- - provider environment variables
266
- - project build config detection (`vercel.json`, `netlify.toml`, `wrangler.*`)
267
- - package scripts heuristics
268
-
269
- You can pin target behavior explicitly:
270
-
271
- ```ts
272
- export default defineResuxConfig({
273
- deploy: {
274
- target: "vercel", // "auto" | "node" | "netlify" | "cloudflare" | "static"
275
- nitroPreset: "vercel"
276
- }
277
- })
278
- ```
279
-
280
- Cloudflare worker presets are opt-in via `deploy.target = "cloudflare"` (or explicit `deploy.nitroPreset`) so Node-style Nitro adapters do not get selected automatically in auto mode.
281
-
282
- Production and dev servers expose a health endpoint for hosts and uptime checks:
283
-
284
- ```txt
285
- /__resux/health
286
- ```
287
-
288
- ## Modules And Route Rules
289
-
290
- Resux supports first-party and third-party build-time modules in `resux.config.ts`. Modules run during the Resux build and can extend config without adding hydration:
291
-
292
- ```ts
293
- export default defineResuxConfig({
294
- modules: [
295
- "resux:security",
296
- ["resux:performance", { assetMaxAge: 31536000 }],
297
- ["./modules/security.ts", { header: "enabled" }]
298
- ],
299
- routeRules: {
300
- "/old": { redirect: { to: "/", statusCode: 301 } },
301
- "/admin/**": { headers: { "x-robots-tag": "noindex" } }
302
- }
303
- })
304
- ```
305
-
306
- Built-in modules:
307
-
308
- - `resux:security`: adds default production hardening headers and optional custom headers or CSP through route rules.
309
- - `resux:performance`: adds immutable cache rules for built Resux runtime/handler assets and `no-store` for route payloads.
310
-
311
- Modules can be built-in `resux:*` specifiers, npm package specifiers, local files, inline functions, or objects returned by `defineResuxModule`.
312
-
313
- ```ts
314
- // modules/security.ts
315
- export default defineResuxModule({
316
- defaults: { header: "enabled" },
317
- setup(options, resux) {
318
- resux.addCss("/module.css")
319
- resux.addHead({ meta: [{ name: "module", content: options.header }] })
320
- resux.addRouteRule("/secure/**", {
321
- headers: { "x-module": options.header },
322
- cache: { maxAge: 60, swr: 30 }
323
- })
324
- resux.extendRuntimeConfig({
325
- public: { securityModule: options.header }
326
- })
327
- }
328
- })
329
- ```
330
-
331
- The module API includes `addCss`, `addHead`, `addRouteRule`, and `extendRuntimeConfig`. Route rules currently support redirects, response headers, status codes, cache headers, and CORS headers.
332
-
333
- ## Plugins
334
-
335
- Resux auto-discovers app plugins from `plugins/` (and `app/plugins/`) without manual imports:
336
-
337
- - `plugins/*.ts`
338
- - `plugins/**/*.ts`
339
- - `plugins/*.client.ts`
340
- - `plugins/*.server.ts`
341
-
342
- Use `defineResuxPlugin`:
343
-
344
- ```ts
345
- // plugins/01.api.ts
346
- export default defineResuxPlugin((resuxApp) => {
347
- resuxApp.provide("apiBase", "/api")
348
- })
349
- ```
350
-
351
- Plugin execution order is deterministic and sorted by discovered filename path. Numeric prefixes are supported, for example `01.auth.ts` runs before `02.analytics.ts`.
352
-
353
- Mode behavior:
354
-
355
- - `.client` plugins run only in the browser.
356
- - `.server` plugins run only on the server.
357
- - Unsuffixed plugins run on both server and client.
358
-
359
- Use `useResuxApp()` inside setup code to access provided values:
360
-
361
- ```ts
362
- const app = useResuxApp()
363
- const apiBase = String(app.provides.apiBase ?? "/api")
364
- ```
365
-
366
- TypeScript app helpers are available globally when your app includes:
367
-
368
- ```ts
369
- /// <reference types="resuxjs/globals" />
370
- ```
371
-
372
- For typed plugin injections, augment `ResuxAppInjections`:
373
-
374
- ```ts
375
- declare module "resuxjs/runtime" {
376
- interface ResuxAppInjections {
377
- apiBase: string
378
- }
379
- }
380
- ```
381
-
382
- ## Route Middleware
383
-
384
- Resux auto-discovers route middleware from `middleware/` (and `app/middleware/`) without manual imports:
385
-
386
- - `middleware/*.ts`
387
- - `middleware/**/*.ts`
388
- - `middleware/*.global.ts`
389
- - `middleware/*.client.ts`
390
- - `middleware/*.server.ts`
391
-
392
- Create middleware with `defineResuxRouteMiddleware`:
393
-
394
- ```ts
395
- // middleware/auth.ts
396
- export default defineResuxRouteMiddleware((to) => {
397
- if (to.path.startsWith("/admin")) {
398
- return navigateTo("/login")
399
- }
400
- })
401
- ```
402
-
403
- Apply named middleware from page meta:
404
-
405
- ```ts
406
- definePageMeta({ middleware: "auth" })
407
- definePageMeta({ middleware: ["auth", "admin"] })
408
- ```
409
-
410
- Global middleware (`*.global.ts`) runs for every route. Middleware return handling:
411
-
412
- - `undefined` or no return: continue
413
- - `false`: abort with `403`
414
- - `"/path"`: redirect
415
- - `{ redirect: "/path" }` or `{ redirect: { to: "/path", statusCode: 302 } }`: redirect
416
- - `navigateTo("/path")`: redirect helper
417
- - `abortNavigation("message")`: abort helper
418
-
419
- Mode behavior:
420
-
421
- - `.client` middleware runs in browser navigation.
422
- - `.server` middleware runs only during server rendering/navigation handling.
423
- - Unsuffixed middleware runs on server route resolution.
424
-
425
- ## Server Middleware
426
-
427
- Files in `server/middleware` run for each request before server handlers, public files, and page rendering:
428
-
429
- ```ts
430
- export default defineServerMiddleware((event) => {
431
- setHeader(event, "x-app", "resux")
432
-
433
- if (event.path.startsWith("/private")) {
434
- return { type: "redirect", to: "/login", statusCode: 302 }
435
- }
436
- })
437
- ```
438
-
439
- Server middleware can continue by returning nothing, use h3-style helpers such as `setHeader(event, name, value)`, end the Node response directly when necessary, return a `Response`, return a JSON-serializable value, return `false` to send `403`, or return a redirect/abort object.
440
-
441
- `server/middleware` is request middleware for raw HTTP handling and API/page requests. Route middleware in `middleware/` is navigation middleware for page routing decisions (`definePageMeta({ middleware })` + globals).
442
-
443
- ## What Works
444
-
445
- - `.vue`-style SFC files with `<template>`, `<script setup lang="ts">`, and plain CSS `<style>` blocks.
446
- - File-based routing from `pages/`.
447
- - Dynamic route params like `pages/post/[id].vue`.
448
- - Catch-all route params like `pages/docs/[...slug].vue`.
449
- - `app.vue` with `<ResuxPage />`.
450
- - Layouts with `<ResuxLayout>`, `<slot />`, and `definePageMeta({ layout })`.
451
- - `<ResuxLink to="...">` rendered as an `<a href="...">` and intercepted for client-side navigation.
452
- - Static and dynamic component props with `defineProps()`.
453
- - Server-side rendering.
454
- - Head/meta rendering from `resux.config.ts`, `definePageMeta`, `useHead`, and `useSeoMeta`.
455
- - Component CSS from `<style>` and `<style scoped>`, included in SSR output and updated during client-side navigation.
456
- - Auto-discovered route middleware from `middleware/**/*`, including `.global`, `.client`, and `.server` files.
457
- - Request-time server middleware from `server/middleware`.
458
- - Auto-discovered plugins from `plugins/**/*` with `.client` / `.server` mode suffix support and stable filename ordering.
459
- - Server API/routes from `server/api` and `server/routes`.
460
- - Server handler helpers: `readBody(event)`, `getQuery(event)`, and `setHeader(event, name, value)`, backed by h3.
461
- - `error.vue` for custom 404/500 rendering.
462
- - Public file serving from `public/`.
463
- - Built-in health checks at `/__resux/health`.
464
- - Basic `resux.config.ts` support for `runtimeConfig`, `app.head`, and `css`.
465
- - Built-in and package/local Resux modules for extending CSS, head, route rules, and runtime config during build.
466
- - Route rules for redirects, response headers, status codes, cache headers, and CORS headers.
467
- - Default production security headers with an opt-out flag.
468
- - Vite-powered dev serving, production client/server bundling, and minification for the resume runtime and handler chunks.
469
- - Dev rebuilds with automatic browser reloads, without adding Vue hydration.
470
- - `resux inspect` and `resux inspect --json` for route and build diagnostics.
471
- - `resux deploy --preset node|docker|nitro` for deployment file generation.
472
- - Serialized route, state, and async data payloads.
473
- - Resumable event handlers such as `@click="increment"`.
474
- - Lazy client handler chunks loaded on first interaction.
475
- - Client-side navigation, persistent same-layout DOM, built-in route transition progress, and hover/focus route payload prefetch for same-origin links.
476
- - Stable core composables: `useState`, `useAsyncData`, `useRoute`, `useRouter`, `useHead`, `useSeoMeta`, `useRuntimeConfig`, `useResuxApp`, `apiURL`, `useFetch`, `$fetch`, and `onMounted`.
477
- - `useAsyncData` returns a Nuxt-like resource with reactive `data`, `pending`, and `error` refs, plus `value` as a data alias for compatibility. Use `await useAsyncData(...)` when you want SSR to fetch before rendering the page; omit `await` when you intentionally want an SSR skeleton that resumes in the browser.
478
-
479
- ## Component Syntax
480
-
481
- ```vue
482
- <script setup lang="ts">
483
- const count = useState("count", () => 0)
484
-
485
- function increment() {
486
- count.value++
487
- }
488
- </script>
489
-
490
- <template>
491
- <button @click="increment">
492
- Count: {{ count }}
493
- </button>
494
- </template>
495
- ```
496
-
497
- On the server, Resux renders the button as HTML and serializes `count`.
498
-
499
- In the browser, Resux installs a tiny delegated event listener. The component handler module is not imported until the user clicks the button. After that, the scope is resumed from serialized state and only the marked DOM bindings are patched.
500
-
501
- ## Async Data Skeletons
502
-
503
- To fetch during SSR and render the resolved data in the first HTML response, await the call:
504
-
505
- ```vue
506
- <script setup lang="ts">
507
- type Stats = {
508
- response: string
509
- }
510
-
511
- const { data, pending, error } = await useAsyncData("stats", ({ signal }) => {
512
- return $fetch<Stats>("/api/stats", { signal })
513
- })
514
- </script>
515
-
516
- <template>
517
- <p v-if="pending">Loading</p>
518
- <p v-if="error">{{ error.message }}</p>
519
- <strong v-if="data">{{ data.response }}</strong>
520
- </template>
521
- ```
522
-
523
- For a Next-style loading skeleton, call `useAsyncData` without `await` and branch on `pending`:
524
-
525
- ```vue
526
- <script setup lang="ts">
527
- type Stats = {
528
- response: string
529
- }
530
-
531
- const { data, pending, error } = useAsyncData("stats", ({ signal }) => {
532
- return $fetch<Stats>("/api/stats", { signal })
533
- })
534
- </script>
535
-
536
- <template>
537
- <div v-if="pending" class="skeleton"></div>
538
- <p v-if="error">{{ error.message }}</p>
539
- <strong v-if="!pending && !error && data">{{ data.response }}</strong>
540
- </template>
541
- ```
542
-
543
- Resux serializes the pending state, renders the skeleton immediately, resumes only scopes with pending async data in the browser, and patches the marked DOM blocks after the data resolves. The handler receives an abort `signal`; pass it to `$fetch` or `fetch` so pending client requests are aborted when the user leaves the route before data resolves.
544
-
545
- Templates auto-unwrap refs returned from `useState`, `useAsyncData`, `useFetch`, Vue `ref`, and `computed`, so template examples use `count`, `pending`, and `data.response`. In `<script setup>`, keep using `.value` when mutating refs, such as `count.value++`.
546
-
547
- ## Server API Fetches
548
-
549
- Browser-only fetches can use relative API URLs:
550
-
551
- ```ts
552
- await fetch("/api/test")
553
- ```
554
-
555
- Code that can run during SSR should use `$fetch()` for internal APIs. Resux automatically resolves internal `/api/...` URLs to an absolute request-origin URL on the server, while keeping them relative in the browser:
556
-
557
- ```vue
558
- <script setup lang="ts">
559
- const { data, pending, error } = useAsyncData("test", ({ signal }) => {
560
- return $fetch("/api/test", { signal })
561
- })
562
- </script>
563
-
564
- <template>
565
- <p v-if="pending">Loading</p>
566
- <p v-if="error">{{ error.message }}</p>
567
- <pre v-if="data">{{ data }}</pre>
568
- </template>
569
- ```
570
-
571
- On the server, `$fetch("/api/test")` uses the current request origin, then configured public origins such as `runtimeConfig.public.appOrigin`, and finally `http://localhost:3000`. In the browser it keeps `/api/test` relative. Use `apiURL("/api/test")` only when you call native `fetch()` yourself in code that can run during SSR.
572
-
573
- ## Supported Syntax
574
-
575
- The v1 compiler supports:
576
-
577
- - Static elements and text.
578
- - Interpolation: `{{ value }}`.
579
- - Static attributes: `class="box"`.
580
- - Dynamic attributes: `:class="className"`.
581
- - Dynamic class arrays/objects and style objects for `:class` and `:style`.
582
- - Plain CSS `<style>` blocks, including `<style scoped>`.
583
- - Plain named events: `@click="increment"`.
584
- - Inline event expressions that only capture resumable values, plus named handlers such as `@click="increment"`.
585
- - Resumability-safe event modifiers: `.prevent`, `.stop`, `.self`, `.once`, system/mouse modifiers, and key filters such as `.enter`.
586
- - `v-if`, `v-else-if`, and `v-else`.
587
- - `v-show`.
588
- - `v-text`.
589
- - Sanitized `v-html`.
590
- - Basic `v-model` for form values.
591
- - Simple `v-for`, such as `item in items` or `(item, index) in items`.
592
- - Component tags from `components/`.
593
- - `<ResuxPage />`.
594
- - `<ResuxLayout />`.
595
- - `<slot />` inside layouts.
596
- - `<ResuxLink to="/path">`.
597
- - `defineProps()` in components.
598
- - `definePageMeta({ layout, middleware, title, meta })`.
599
- - `useRoute()` for the current path, params, and query.
600
- - `useRouter().push("/path")`, `replace`, `back`, `forward`, and `go`.
601
- - `useHead({ title, meta, link })`.
602
- - `useSeoMeta({ title, description, ogTitle, ogImage, twitterCard })`.
603
- - `apiURL("/api/path")` for SSR-safe API fetch URLs.
604
- - `onMounted()`, run when the component scope is first resumed in the browser.
605
- - Vue runtime islands via `<VueIsland name="CounterIsland" :props="{ start: 1 }" />` and files in `islands/vue`.
606
-
607
- Handlers and inline event expressions must only capture resumable values, such as refs returned by `useState`.
608
-
609
- ## Current Limits
610
-
611
- Resux intentionally rejects or does not support many advanced framework/Vue features yet:
612
-
613
- - Vue runtime is island-only; Resux components still do not hydrate through Vue.
614
- - Nitro support is an adapter/deployment preset, not the primary dev server.
615
- - SFC styles support plain CSS only; preprocessors like SCSS and CSS modules are not implemented for resumable components yet.
616
- - Event `.capture` and `.passive` are accepted in templates, but the browser runtime still uses delegated resumable listeners.
617
- - No fallback hydration for unsupported components.
618
-
619
- Unsupported resumability patterns should fail at compile time instead of silently hydrating.
620
-
621
- ## Troubleshooting
622
-
623
- - `Failed to parse URL from /api/...` during SSR: use `apiURL("/api/...")` or `$fetch("/api/...")` from Resux setup code so server-side fetches get an absolute URL.
624
- - Skeletons that never disappear: render `error` from `useAsyncData` and guard success UI with `!pending && !error && data`.
625
- - Dev edits do not appear: keep `resux dev .` running and make sure the browser is connected to `/__resux/dev-events`; Resux reloads the page after successful rebuilds.
626
- - Port already in use: pass another port, for example `resux dev --port 4000`.
627
- - Handler capture compile errors: move non-serializable values out of resumable handlers or store resumable state with `useState`.
628
-
629
- ## Architecture
630
-
631
- Resux is one package with five internal parts:
632
-
633
- - Compiler: parses `.vue` files, creates routes, validates resumable handlers, and emits server/client modules.
634
- - Runtime: renders HTML on the server, provides Resux-style composables, runs plugins, applies layouts, collects head entries, and serializes payloads.
635
- - CLI and Node server: builds apps, starts the dev server, previews generated output, and exposes `resuxjs/node`.
636
- - Create CLI: scaffolds a starter app for `resux init`.
637
- - Package entrypoints: keep the root runtime-only while `resuxjs/compiler`, `resuxjs/runtime`, `resuxjs/node`, `resuxjs/globals`, and `resuxjs/create` expose focused surfaces.
638
-
639
- The browser initially receives only server-rendered HTML, the serialized payload, and the small resume loader.
640
-
641
- For internal navigation, the client runtime prefetches route payloads on hover/focus, intercepts same-origin links, fetches a fresh SSR route payload from `/__resux/route`, updates a server-rendered transition progress shell through start/fetch/swap/complete/error phases, keeps the active layout DOM when the layout name matches, swaps the page slot, updates `<head>`, updates browser history, and clears only non-persistent resumed page scopes.
642
-
643
- ## Testing
644
-
645
- Run:
646
-
647
- ```sh
648
- npm test
649
- ```
650
-
651
- The tests cover:
652
-
653
- - Route generation.
654
- - SFC compiler output.
655
- - Compile errors for unsupported resumability captures.
656
- - Sanitized `v-html`, `v-model`, inline handlers, and mounted resume hooks.
657
- - SSR payload serialization.
658
- - Dynamic route params and catch-all params.
659
- - Layout rendering.
660
- - Head/meta rendering.
661
- - Runtime config and plugin provides.
662
- - Recursive project discovery for layouts, middleware, server middleware, plugins, API routes, and config.
663
- - Plugin order and client/server mode filtering.
664
- - Route middleware execution for SSR and client navigation.
665
- - Extended route-rule serialization.
666
- - Client resume behavior after interaction.
1
+ # Resux
2
+
3
+ Resux is an experimental web framework with a custom resumable runtime.
4
+
5
+ It uses familiar `.vue` files and `pages/` routing, but normal Resux components do not use Vue hydration or the Vue runtime. The compiler parses a small Vue-like SFC subset, renders HTML on the server, serializes route and component state, then loads client code only when an event is triggered. Vue runtime is available as an opt-in island escape hatch for complex client widgets.
6
+
7
+ The v1 release line treats the documented compiler, SSR renderer, resume runtime, routing, and CLI commands as the stable core. Advanced Vue compatibility, Vue islands, Nitro adapter behavior, and unsupported Vue SFC syntax are still experimental and should fail loudly instead of silently falling back to hydration.
8
+
9
+ ## Create App
10
+
11
+ Create a new app with the latest published Resux package:
12
+
13
+ ```sh
14
+ npx resuxjs@latest init
15
+ ```
16
+
17
+ You can also use the lightweight create wrapper:
18
+
19
+ ```sh
20
+ npx create-resuxjs@latest
21
+ ```
22
+
23
+ With a project directory:
24
+
25
+ ```sh
26
+ npx resuxjs@latest init my-app
27
+ ```
28
+
29
+ With create options:
30
+
31
+ ```sh
32
+ npx resuxjs@latest init my-app --no-install
33
+ ```
34
+
35
+ Choose optional starter features:
36
+
37
+ ```sh
38
+ npx resuxjs@latest init my-app --features i18n,pwa
39
+ ```
40
+
41
+ Enable i18n hreflang alternate links explicitly:
42
+
43
+ ```sh
44
+ npx resuxjs@latest init my-app --features i18n --hreflang
45
+ ```
46
+
47
+ Generated apps use a single Resux dependency, similar to Nuxt apps installing `nuxt`:
48
+
49
+ ```json
50
+ {
51
+ "dependencies": {
52
+ "resuxjs": "^<current-version>"
53
+ }
54
+ }
55
+ ```
56
+
57
+ For local development before publishing:
58
+
59
+ ```sh
60
+ npm install
61
+ npm run typecheck
62
+ npm run build
63
+ npm run create:local -- my-app --no-install
64
+ ```
65
+
66
+ Then run the generated app:
67
+
68
+ ```sh
69
+ cd my-app
70
+ npm install
71
+ npm run dev
72
+ ```
73
+
74
+ ## Package Layout
75
+
76
+ ```txt
77
+ src/
78
+ compiler/ SFC parser, route manifest builder, code generator
79
+ runtime/ SSR renderer, composables, client resume loader source
80
+ index.ts Runtime-only public root export
81
+ cli.ts Resux CLI, dev server, preview server, deploy helpers
82
+ node.ts Node server handler export for adapters
83
+ create.ts App scaffolder used by `resux init`
84
+
85
+ templates/ Starter files copied by `resux init`
86
+ tests/ Compiler, SSR, and client resume tests
87
+ ```
88
+
89
+ Public imports are split so browser/client bundles do not accidentally pull compiler or server code:
90
+
91
+ ```ts
92
+ import { renderApp } from "resuxjs/runtime"
93
+ import { createResuxNodeHandler } from "resuxjs/node"
94
+ ```
95
+
96
+ Optional modules and features stay tree-shakable and are only included when configured.
97
+
98
+ ## Optional i18n
99
+
100
+ Resux i18n is opt-in through the `resuxjs/i18n` module. It is not included in default runtime output unless enabled.
101
+
102
+ ```ts
103
+ export default defineResuxConfig({
104
+ modules: ["resuxjs/i18n"],
105
+ i18n: {
106
+ defaultLocale: "en",
107
+ fallbackLocale: "en",
108
+ strategy: "prefix_except_default",
109
+ locales: [
110
+ { code: "en", name: "English", dir: "ltr" },
111
+ { code: "ar", name: "العربية", dir: "rtl" }
112
+ ],
113
+ messages: {
114
+ en: () => import("./locales/en.json"),
115
+ ar: () => import("./locales/ar.json")
116
+ },
117
+ seo: {
118
+ hreflang: true
119
+ }
120
+ }
121
+ })
122
+ ```
123
+
124
+ Use i18n helpers in pages/components:
125
+
126
+ ```ts
127
+ import { useI18n } from "resuxjs/i18n"
128
+
129
+ const i18n = useI18n()
130
+ const title = i18n.t("demo.title")
131
+ const toArabic = i18n.switchLocalePath("ar")
132
+ ```
133
+
134
+ ## Icons (`resuxjs/icons`)
135
+
136
+ The `resuxjs/icons` module enables dynamic Iconify SVG fetching, pre-populated collections, and viewport visibility lazy loading.
137
+
138
+ ```ts
139
+ export default defineResuxConfig({
140
+ modules: [
141
+ ["resuxjs/icons", {
142
+ component: "Icon",
143
+ mode: "svg",
144
+ apiProvider: "https://api.iconify.design",
145
+ collections: ["material-symbols", "mdi", "mingcute", "cib", "uil", "line-md", "solar", "ph"],
146
+ lazy: true
147
+ }]
148
+ ]
149
+ })
150
+ ```
151
+
152
+ Use `<Icon>` or `<ResuxIcon>` natively in templates without manual imports:
153
+
154
+ ```vue
155
+ <template>
156
+ <!-- Eager / Pre-registered Icon -->
157
+ <Icon name="material-symbols:call" size="1.5rem" />
158
+
159
+ <!-- Dynamic Iconify Icon -->
160
+ <Icon name="ph:check-circle-thin" size="2rem" />
161
+
162
+ <!-- Viewport IntersectionObserver Lazy Loaded Icon -->
163
+ <Icon name="solar:leaf-outline" size="2rem" lazy />
164
+ </template>
165
+ ```
166
+
167
+ ## Fonts (`resuxjs/fonts`)
168
+
169
+ The `resuxjs/fonts` module manages preconnect optimizations, Google Fonts URL building, font loading priority strategies (`lazy`, `preload`, `eager`), and post-onload deferral.
170
+
171
+ ```ts
172
+ export default defineResuxConfig({
173
+ modules: [
174
+ ["resuxjs/fonts", {
175
+ preconnect: true,
176
+ strategy: "lazy",
177
+ deferUntilPageLoad: true,
178
+ google: [
179
+ { name: "Inter", weights: [400, 500, 600, 700, 800], display: "swap" },
180
+ { name: "Alexandria", weights: [300, 400, 500, 600, 700], display: "swap" }
181
+ ]
182
+ }]
183
+ ]
184
+ })
185
+ ```
186
+
187
+ ## UI & Animations (`resuxjs/ui`)
188
+
189
+ The `resuxjs/ui` module provides design tokens, Web Animations API (WAAPI) helpers (`useAnimate()`), scroll-reveal directives (`v-anime`), and animation presets.
190
+
191
+ ```ts
192
+ export default defineResuxConfig({
193
+ modules: [
194
+ ["resuxjs/ui", {
195
+ tokens: {
196
+ accent: "#03C8BF"
197
+ },
198
+ animations: {
199
+ enabled: true,
200
+ defaultPreset: "fade-up"
201
+ }
202
+ }]
203
+ ]
204
+ })
205
+ ```
206
+
207
+ Use the `v-anime` directive or `useAnimate` composable in components:
208
+
209
+ ```vue
210
+ <template>
211
+ <div v-anime="'fade-up'">
212
+ <h2>Title</h2>
213
+ </div>
214
+
215
+ <button v-anime="{ type: 'scale-in', duration: 400, delay: 100 }">
216
+ Animate Me
217
+ </button>
218
+ </template>
219
+ ```
220
+
221
+ ## Halal Core integrity keys
222
+
223
+ Local reports use a deterministic `sha256:` checksum when no key is configured. Production server and deployment guards require authenticated HMAC reports. Configure private keys with at least 32 characters before building production artifacts:
224
+
225
+ ```sh
226
+ export RESUX_HALAL_REPORT_SIGNING_SECRET="replace-with-a-private-random-secret"
227
+ export RESUX_HALAL_REVIEW_SIGNING_SECRET="replace-with-a-different-private-random-secret"
228
+ ```
229
+
230
+ Do not commit these values. The report key signs the complete generated report; the review key authenticates human review approval files. Optional remote AI classification also requires an HTTPS endpoint (localhost HTTP is allowed for development) and supports `RESUX_AI_TIMEOUT_MS`.
231
+
232
+ ## Development
233
+
234
+ ```sh
235
+ npm install
236
+ npm run typecheck
237
+ npm run build
238
+ npm test
239
+ npm run test:templates
240
+ ```
241
+
242
+ Run the full publish-readiness check:
243
+
244
+ ```sh
245
+ npm run pack:check
246
+ ```
247
+
248
+ This builds, tests, and dry-runs npm packing for the single `resuxjs` package.
249
+
250
+ CI runs on every push and pull request with `npm ci`, optional linting, typecheck, build, tests, and package dry-run checks.
251
+
252
+ ## Release Process
253
+
254
+ Normal pushes never publish to npm. They only run CI. Publishing is intentionally gated to version tags or GitHub Releases so an ordinary `main` push cannot publish a broken package.
255
+
256
+ To release:
257
+
258
+ 1. Update the version and create the release commit/tag with `npm version 1.0.0`.
259
+ 2. Push the release commit with `git push origin main`.
260
+ 3. Push the version tag with `git push origin v1.0.0`.
261
+ 4. The GitHub Action publishes `resuxjs@1.0.0` to npm.
262
+
263
+ The npm publish workflow validates that the tag matches `package.json`, installs only the locked dependency graph, runs typecheck, build, tests, and package checks, skips versions that already exist, then publishes through npm Trusted Publishing (GitHub OIDC) with provenance. Configure the npm Trusted Publisher for repository `MahmoudAbdalrhmanMohamed/resux` and workflow `npm-publish.yml`; no long-lived `NPM_TOKEN` is used.
264
+
265
+ ## CLI
266
+
267
+ The `resux` CLI supports:
268
+
269
+ ```sh
270
+ resux init <project-dir>
271
+ resux dev <app-root>
272
+ resux build <app-root>
273
+ resux prepare <app-root>
274
+ resux preview <app-root>
275
+ resux start <app-root>
276
+ resux inspect <app-root>
277
+ resux check <app-root>
278
+ resux deploy <app-root>
279
+ ```
280
+
281
+ If `<app-root>` is omitted, Resux uses the current directory.
282
+
283
+ Starter templates are selectable from `resux init` / `npm create resuxjs@latest`:
284
+
285
+ ```sh
286
+ npx create-resuxjs@latest my-app --template default
287
+ # templates: minimal, default, full, i18n, pwa, media, package-compatibility, dashboard
288
+ ```
289
+
290
+ Useful server flags:
291
+
292
+ ```sh
293
+ resux dev --port 4000
294
+ resux preview --host 0.0.0.0 --port 4000
295
+ resux start --host 0.0.0.0 --port 3000
296
+ resux inspect
297
+ resux inspect --json
298
+ resux inspect routes
299
+ resux inspect packages
300
+ resux inspect bundles --json
301
+ resux inspect seo --json
302
+ resux check
303
+ resux check --json
304
+ resux check --fix
305
+ resux prepare
306
+ resux deploy . --preset docker
307
+ resux deploy . --preset nitro
308
+ resux --help
309
+ resux --version
310
+ ```
311
+
312
+ Build output is written to:
313
+
314
+ ```txt
315
+ <app-root>/.resux
316
+ ```
317
+
318
+ Generated integration directories are bootstrapped automatically by `resux dev`, `resux build`, `resux preview`, `resux prepare`, and `resux check --fix`:
319
+
320
+ ```txt
321
+ <app-root>/.resux
322
+ <app-root>/.resux-nitro
323
+ <app-root>/.nitro
324
+ ```
325
+
326
+ ## App Types
327
+
328
+ Generated apps include `env.d.ts` and `tsconfig.json` wired to `resuxjs/globals`, so app files can use the Resux-style globals without imports:
329
+
330
+ ```ts
331
+ const count = useState("count", () => 0)
332
+ const route = useRoute()
333
+ const router = useRouter()
334
+ useSeoMeta({
335
+ title: "My App",
336
+ description: "My app description",
337
+ ogTitle: "My App"
338
+ })
339
+
340
+ function openAbout() {
341
+ router.push("/about")
342
+ }
343
+
344
+ export default defineResuxConfig({
345
+ app: {
346
+ head: {
347
+ title: "My App"
348
+ }
349
+ }
350
+ })
351
+ ```
352
+
353
+ ## Reactivity APIs
354
+
355
+ Resux includes a native reactivity layer for resumable components. You can use it with globals in app files, or import directly:
356
+
357
+ ```ts
358
+ import {
359
+ ref,
360
+ reactive,
361
+ computed,
362
+ watch,
363
+ watchEffect,
364
+ readonly,
365
+ toRef,
366
+ toRefs,
367
+ unref,
368
+ isRef,
369
+ isReactive,
370
+ isReadonly,
371
+ nextTick
372
+ } from "resuxjs"
373
+ ```
374
+
375
+ Or from the focused subpath:
376
+
377
+ ```ts
378
+ import { ref, reactive, computed } from "resuxjs/reactivity"
379
+ ```
380
+
381
+ These APIs are Resux-native. Normal Resux components do not depend on Vue hydration runtime.
382
+
383
+ ## Vite
384
+
385
+ Resux uses Vite in both main app commands:
386
+
387
+ - `resux dev` emits Resux client modules into `.resux/vite-client` and serves the resume runtime plus handler modules through Vite middleware.
388
+ - `resux dev` also opens a dev-only update channel at `/__resux/dev-events`; when source files change, Resux rebuilds and reloads the browser so route, template, and style changes are visible without restarting the dev server.
389
+ - `resux build` uses Vite production bundling for the resume runtime, handler chunks, and server manifest, then writes optimized output into `.resux/client` and `.resux/server-bundle` before producing a Nitro `.output` server.
390
+
391
+ The generated starter keeps Resux-style scripts:
392
+
393
+ ```json
394
+ {
395
+ "scripts": {
396
+ "prepare": "resux prepare",
397
+ "dev": "resux dev",
398
+ "build": "resux build",
399
+ "preview": "resux preview",
400
+ "start": "resux start",
401
+ "inspect": "resux inspect",
402
+ "typecheck": "vue-tsc --noEmit"
403
+ }
404
+ }
405
+ ```
406
+
407
+ Tailwind can stay Nuxt-style simple too. If your app has `assets/css/tailwind.css` and `tailwindcss` installed, `resux dev` automatically runs Tailwind in watch mode and `resux build` generates a minified `public/tailwind.css` before bundling. No separate `concurrently` script is required.
408
+
409
+ ## Deployment
410
+
411
+ Build and serve with the Node server:
412
+
413
+ ```sh
414
+ npm run build
415
+ npm run start
416
+ ```
417
+
418
+ Production serving enables default hardening headers such as `x-content-type-options`, `referrer-policy`, `x-frame-options`, `cross-origin-opener-policy`, and a restrictive `permissions-policy`. Disable them only when the host or reverse proxy owns those headers:
419
+
420
+ ```sh
421
+ resux start . --no-security-headers
422
+ ```
423
+
424
+ Generated apps include a `Dockerfile`, `.dockerignore`, and `DEPLOYMENT.md`. Use `resux inspect --json` in CI to capture the built routes, server handlers, route rules, feature flags, and diagnostics.
425
+
426
+ Existing apps can generate or refresh deployment files without changing application code:
427
+
428
+ ```sh
429
+ resux deploy . --preset node
430
+ resux deploy . --preset docker --force
431
+ resux deploy . --preset nitro --force
432
+ ```
433
+
434
+ The Nitro preset writes `nitro.config.ts` and a small `.resux-nitro/handler.ts` adapter. `resux build` now produces Nuxt-style `.output` by default:
435
+
436
+ ```sh
437
+ npm run build
438
+ node .output/server/index.mjs
439
+ ```
440
+
441
+ The generated Nitro config is conservative for resumability: SSR pages, API routes, and route payloads use `cache-control: no-store`, while build-stable Resux runtime and handler assets use long immutable caching. Nitro prerender crawling is disabled by default.
442
+
443
+ Deployment target selection is automatic by default (`deploy.target = "auto"`). Resux resolves target/preset from:
444
+
445
+ - explicit `deploy.target` / `deploy.nitroPreset` in `resux.config.ts`
446
+ - `NITRO_PRESET` / `RESUX_NITRO_PRESET`
447
+ - provider environment variables
448
+ - project build config detection (`vercel.json`, `netlify.toml`, `wrangler.*`)
449
+ - package scripts heuristics
450
+
451
+ You can pin target behavior explicitly:
452
+
453
+ ```ts
454
+ export default defineResuxConfig({
455
+ deploy: {
456
+ target: "vercel", // "auto" | "node" | "netlify" | "cloudflare" | "static"
457
+ nitroPreset: "vercel"
458
+ }
459
+ })
460
+ ```
461
+
462
+ Cloudflare worker presets are opt-in via `deploy.target = "cloudflare"` (or explicit `deploy.nitroPreset`) so Node-style Nitro adapters do not get selected automatically in auto mode.
463
+
464
+ Production and dev servers expose a health endpoint for hosts and uptime checks:
465
+
466
+ ```txt
467
+ /__resux/health
468
+ ```
469
+
470
+ ## Modules And Route Rules
471
+
472
+ Resux supports first-party and third-party build-time modules in `resux.config.ts`. Modules run during the Resux build and can extend config without adding hydration:
473
+
474
+ ```ts
475
+ export default defineResuxConfig({
476
+ modules: [
477
+ "resux:security",
478
+ ["resux:performance", { assetMaxAge: 31536000 }],
479
+ ["./modules/security.ts", { header: "enabled" }]
480
+ ],
481
+ routeRules: {
482
+ "/old": { redirect: { to: "/", statusCode: 301 } },
483
+ "/admin/**": { headers: { "x-robots-tag": "noindex" } }
484
+ }
485
+ })
486
+ ```
487
+
488
+ Built-in modules:
489
+
490
+ - `resux:security`: adds default production hardening headers and optional custom headers or CSP through route rules.
491
+ - `resux:performance`: adds immutable cache rules for built Resux runtime/handler assets and `no-store` for route payloads.
492
+
493
+ Modules can be built-in `resux:*` specifiers, npm package specifiers, local files, inline functions, or objects returned by `defineResuxModule`.
494
+
495
+ ```ts
496
+ // modules/security.ts
497
+ export default defineResuxModule({
498
+ defaults: { header: "enabled" },
499
+ setup(options, resux) {
500
+ resux.addCss("/module.css")
501
+ resux.addHead({ meta: [{ name: "module", content: options.header }] })
502
+ resux.addRouteRule("/secure/**", {
503
+ headers: { "x-module": options.header },
504
+ cache: { maxAge: 60, swr: 30 }
505
+ })
506
+ resux.extendRuntimeConfig({
507
+ public: { securityModule: options.header }
508
+ })
509
+ }
510
+ })
511
+ ```
512
+
513
+ The module API includes `addCss`, `addHead`, `addRouteRule`, and `extendRuntimeConfig`. Route rules currently support redirects, response headers, status codes, cache headers, and CORS headers.
514
+
515
+ ## Plugins
516
+
517
+ Resux auto-discovers app plugins from `plugins/` (and `app/plugins/`) without manual imports:
518
+
519
+ - `plugins/*.ts`
520
+ - `plugins/**/*.ts`
521
+ - `plugins/*.client.ts`
522
+ - `plugins/*.server.ts`
523
+
524
+ Use `defineResuxPlugin`:
525
+
526
+ ```ts
527
+ // plugins/01.api.ts
528
+ export default defineResuxPlugin((resuxApp) => {
529
+ resuxApp.provide("apiBase", "/api")
530
+ })
531
+ ```
532
+
533
+ Plugin execution order is deterministic and sorted by discovered filename path. Numeric prefixes are supported, for example `01.auth.ts` runs before `02.analytics.ts`.
534
+
535
+ Mode behavior:
536
+
537
+ - `.client` plugins run only in the browser.
538
+ - `.server` plugins run only on the server.
539
+ - Unsuffixed plugins run on both server and client.
540
+
541
+ Use `useResuxApp()` inside setup code to access provided values:
542
+
543
+ ```ts
544
+ const app = useResuxApp()
545
+ const apiBase = String(app.provides.apiBase ?? "/api")
546
+ ```
547
+
548
+ TypeScript app helpers are available globally when your app includes:
549
+
550
+ ```ts
551
+ /// <reference types="resuxjs/globals" />
552
+ ```
553
+
554
+ For typed plugin injections, augment `ResuxAppInjections`:
555
+
556
+ ```ts
557
+ declare module "resuxjs/runtime" {
558
+ interface ResuxAppInjections {
559
+ apiBase: string
560
+ }
561
+ }
562
+ ```
563
+
564
+ ## Route Middleware
565
+
566
+ Resux auto-discovers route middleware from `middleware/` (and `app/middleware/`) without manual imports:
567
+
568
+ - `middleware/*.ts`
569
+ - `middleware/**/*.ts`
570
+ - `middleware/*.global.ts`
571
+ - `middleware/*.client.ts`
572
+ - `middleware/*.server.ts`
573
+
574
+ Create middleware with `defineResuxRouteMiddleware`:
575
+
576
+ ```ts
577
+ // middleware/auth.ts
578
+ export default defineResuxRouteMiddleware((to) => {
579
+ if (to.path.startsWith("/admin")) {
580
+ return navigateTo("/login")
581
+ }
582
+ })
583
+ ```
584
+
585
+ Apply named middleware from page meta:
586
+
587
+ ```ts
588
+ definePageMeta({ middleware: "auth" })
589
+ definePageMeta({ middleware: ["auth", "admin"] })
590
+ ```
591
+
592
+ Global middleware (`*.global.ts`) runs for every route. Middleware return handling:
593
+
594
+ - `undefined` or no return: continue
595
+ - `false`: abort with `403`
596
+ - `"/path"`: redirect
597
+ - `{ redirect: "/path" }` or `{ redirect: { to: "/path", statusCode: 302 } }`: redirect
598
+ - `navigateTo("/path")`: redirect helper
599
+ - `abortNavigation("message")`: abort helper
600
+
601
+ Mode behavior:
602
+
603
+ - `.client` middleware runs in browser navigation.
604
+ - `.server` middleware runs only during server rendering/navigation handling.
605
+ - Unsuffixed middleware runs on server route resolution.
606
+
607
+ ## Server Middleware
608
+
609
+ Files in `server/middleware` run for each request before server handlers, public files, and page rendering:
610
+
611
+ ```ts
612
+ export default defineServerMiddleware((event) => {
613
+ setHeader(event, "x-app", "resux")
614
+
615
+ if (event.path.startsWith("/private")) {
616
+ return { type: "redirect", to: "/login", statusCode: 302 }
617
+ }
618
+ })
619
+ ```
620
+
621
+ Server middleware can continue by returning nothing, use h3-style helpers such as `setHeader(event, name, value)`, end the Node response directly when necessary, return a `Response`, return a JSON-serializable value, return `false` to send `403`, or return a redirect/abort object.
622
+
623
+ `server/middleware` is request middleware for raw HTTP handling and API/page requests. Route middleware in `middleware/` is navigation middleware for page routing decisions (`definePageMeta({ middleware })` + globals).
624
+
625
+ ## What Works
626
+
627
+ - `.vue`-style SFC files with `<template>`, `<script setup lang="ts">`, and plain CSS `<style>` blocks.
628
+ - File-based routing from `pages/`.
629
+ - Dynamic route params like `pages/post/[id].vue`.
630
+ - Catch-all route params like `pages/docs/[...slug].vue`.
631
+ - `app.vue` with `<ResuxPage />`.
632
+ - Layouts with `<ResuxLayout>`, `<slot />`, and `definePageMeta({ layout })`.
633
+ - `<ResuxLink to="...">` rendered as an `<a href="...">` and intercepted for client-side navigation.
634
+ - Static and dynamic component props with `defineProps()`.
635
+ - Server-side rendering.
636
+ - Head/meta rendering from `resux.config.ts`, `definePageMeta`, `useHead`, and `useSeoMeta`.
637
+ - Component CSS from `<style>` and `<style scoped>`, included in SSR output and updated during client-side navigation.
638
+ - Auto-discovered route middleware from `middleware/**/*`, including `.global`, `.client`, and `.server` files.
639
+ - Request-time server middleware from `server/middleware`.
640
+ - Auto-discovered plugins from `plugins/**/*` plus client enhancement entries from `enhancements/**/*` and `client-enhancements/**/*` (including `app/*` variants), with `.client` / `.server` mode suffix support and stable filename ordering.
641
+ - Server API/routes from `server/api` and `server/routes`.
642
+ - Server handler helpers: `readBody(event)`, `getQuery(event)`, and `setHeader(event, name, value)`, backed by h3.
643
+ - `error.vue` for custom 404/500 rendering.
644
+ - Public file serving from `public/`.
645
+ - Built-in health checks at `/__resux/health`.
646
+ - Basic `resux.config.ts` support for `runtimeConfig`, `app.head`, and `css`.
647
+ - Built-in and package/local Resux modules for extending CSS, head, route rules, and runtime config during build.
648
+ - Route rules for redirects, response headers, status codes, cache headers, and CORS headers.
649
+ - Default production security headers with an opt-out flag.
650
+ - Vite-powered dev serving, production client/server bundling, and minification for the resume runtime and handler chunks.
651
+ - Dev rebuilds with automatic browser reloads, without adding Vue hydration.
652
+ - `resux inspect` and `resux inspect --json` for route and build diagnostics.
653
+ - `resux inspect routes|plugins|middleware|imports|components|build|images|server|packages|templates|bundles|seo`.
654
+ - `resux check`, `resux check --json`, and `resux check --fix` for project readiness checks and safe file scaffolding.
655
+ - `resux deploy --preset node|docker|nitro` for deployment file generation.
656
+ - Serialized route, state, and async data payloads.
657
+ - Resumable event handlers such as `@click="increment"`.
658
+ - Lazy client handler chunks loaded on first interaction.
659
+ - Client-side navigation, persistent same-layout DOM, built-in route transition progress, and hover/focus route payload prefetch for same-origin links.
660
+ - Stable core composables: `useState`, `useAsyncData`, `useRoute`, `useRouter`, `useHead`, `useSeoMeta`, `useRuntimeConfig`, `useResuxApp`, `apiURL`, `useFetch`, `$fetch`, `useError`, `clearError`, `showError`, `createError`, and `onMounted`.
661
+ - Lazy package helpers: `useLazyPackage`, `useClientPackage`, `usePackageReady`, `defineLazyPackage`, `defineClientOnlyPackage`, `defineClientEnhancement`, and `useClientEnhancement`.
662
+ - Package mode classification via `packages.mode` (`ssr`, `clientOnly`, `serverOnly`, `progressive`) with diagnostics in `resux inspect packages`.
663
+ - Client runtime package registries are generated with static importers (no raw `import(packageName)` in generated runtime), including package API calls that use const string identifiers and package subpaths (for example `swiper/modules` and `swiper/css/*`).
664
+ - `useAsyncData` returns a Nuxt-like resource with reactive `data`, `pending`, and `error` refs, plus `value` as a data alias for compatibility. Use `await useAsyncData(...)` when you want SSR to fetch before rendering the page; omit `await` when you intentionally want an SSR skeleton that resumes in the browser.
665
+
666
+ ## SSR-First Package Enhancements
667
+
668
+ Use semantic SSR markup first, then enhance only in the browser:
669
+
670
+ ```vue
671
+ <section
672
+ use-client-enhancement="swiper-carousel"
673
+ data-trigger="visible"
674
+ >
675
+ <ul class="swiper-wrapper">
676
+ <li class="swiper-slide">...</li>
677
+ </ul>
678
+ </section>
679
+ ```
680
+
681
+ Register the enhancement in a client-only support file (for example `client-enhancements/swiper-carousel.client.ts`):
682
+
683
+ ```ts
684
+ defineClientEnhancement("swiper-carousel", async (target) => {
685
+ const [
686
+ { default: Swiper },
687
+ { Navigation, Pagination },
688
+ ] = await Promise.all([
689
+ useClientPackage("swiper"),
690
+ useClientPackage("swiper/modules", { preferDefault: false }),
691
+ ])
692
+ await useClientPackage("swiper", {
693
+ css: ["swiper/css", "swiper/css/navigation", "swiper/css/pagination"],
694
+ })
695
+ const instance = new Swiper(target.querySelector(".swiper") as HTMLElement, {
696
+ modules: [Navigation, Pagination],
697
+ })
698
+ return () => instance.destroy?.(true, true)
699
+ })
700
+ ```
701
+
702
+ Resux injects runtime helper imports for support modules automatically, so `defineClientEnhancement` and `useClientPackage` are available without global assumptions. This pattern keeps package instances inside client-only closures and avoids resumability-unsafe captures in template handlers.
703
+
704
+ In dev, enhancement and package lifecycles emit events you can observe in custom status UIs:
705
+ - `resux:enhancement:found|triggered|loading|ready|error|cleanup-ready`
706
+ - `resux:package:loading|loaded|error`
707
+ - `resux:package-css:loaded`
708
+
709
+ ## Component Syntax
710
+
711
+ ```vue
712
+ <script setup lang="ts">
713
+ const count = useState("count", () => 0)
714
+
715
+ function increment() {
716
+ count.value++
717
+ }
718
+ </script>
719
+
720
+ <template>
721
+ <button @click="increment">
722
+ Count: {{ count }}
723
+ </button>
724
+ </template>
725
+ ```
726
+
727
+ On the server, Resux renders the button as HTML and serializes `count`.
728
+
729
+ In the browser, Resux installs a tiny delegated event listener. The component handler module is not imported until the user clicks the button. After that, the scope is resumed from serialized state and only the marked DOM bindings are patched.
730
+
731
+ ## Async Data Skeletons
732
+
733
+ To fetch during SSR and render the resolved data in the first HTML response, await the call:
734
+
735
+ ```vue
736
+ <script setup lang="ts">
737
+ type Stats = {
738
+ response: string
739
+ }
740
+
741
+ const { data, pending, error } = await useAsyncData("stats", ({ signal }) => {
742
+ return $fetch<Stats>("/api/stats", { signal })
743
+ })
744
+ </script>
745
+
746
+ <template>
747
+ <p v-if="pending">Loading</p>
748
+ <p v-if="error">{{ error.message }}</p>
749
+ <strong v-if="data">{{ data.response }}</strong>
750
+ </template>
751
+ ```
752
+
753
+ For a Next-style loading skeleton, call `useAsyncData` without `await` and branch on `pending`:
754
+
755
+ ```vue
756
+ <script setup lang="ts">
757
+ type Stats = {
758
+ response: string
759
+ }
760
+
761
+ const { data, pending, error } = useAsyncData("stats", ({ signal }) => {
762
+ return $fetch<Stats>("/api/stats", { signal })
763
+ })
764
+ </script>
765
+
766
+ <template>
767
+ <div v-if="pending" class="skeleton"></div>
768
+ <p v-if="error">{{ error.message }}</p>
769
+ <strong v-if="!pending && !error && data">{{ data.response }}</strong>
770
+ </template>
771
+ ```
772
+
773
+ Resux serializes the pending state, renders the skeleton immediately, resumes only scopes with pending async data in the browser, and patches the marked DOM blocks after the data resolves. The handler receives an abort `signal`; pass it to `$fetch` or `fetch` so pending client requests are aborted when the user leaves the route before data resolves.
774
+
775
+ Templates auto-unwrap refs returned from `useState`, `useAsyncData`, `useFetch`, Vue `ref`, and `computed`, so template examples use `count`, `pending`, and `data.response`. In `<script setup>`, keep using `.value` when mutating refs, such as `count.value++`.
776
+
777
+ ## Server API Fetches
778
+
779
+ Browser-only fetches can use relative API URLs:
780
+
781
+ ```ts
782
+ await fetch("/api/test")
783
+ ```
784
+
785
+ Code that can run during SSR should use `$fetch()` for internal APIs. Resux automatically resolves internal `/api/...` URLs to an absolute request-origin URL on the server, while keeping them relative in the browser:
786
+
787
+ ```vue
788
+ <script setup lang="ts">
789
+ const { data, pending, error } = useAsyncData("test", ({ signal }) => {
790
+ return $fetch("/api/test", { signal })
791
+ })
792
+ </script>
793
+
794
+ <template>
795
+ <p v-if="pending">Loading</p>
796
+ <p v-if="error">{{ error.message }}</p>
797
+ <pre v-if="data">{{ data }}</pre>
798
+ </template>
799
+ ```
800
+
801
+ On the server, `$fetch("/api/test")` uses the current request origin, then configured public origins such as `runtimeConfig.public.appOrigin`, and finally `http://localhost:3000`. In the browser it keeps `/api/test` relative. Use `apiURL("/api/test")` only when you call native `fetch()` yourself in code that can run during SSR.
802
+
803
+ ## Media Components
804
+
805
+ ### `ResuxVideo`
806
+
807
+ `ResuxVideo` supports resumable click zones without hydration. By default, the surface is divided into horizontal thirds:
808
+
809
+ - left third: skip backward
810
+ - center third: single click play/pause
811
+ - center third double click: fullscreen
812
+ - right third: skip forward
813
+
814
+ Controls remain interactive because zones exclude the controls hit area and control targets are ignored.
815
+
816
+ ```vue
817
+ <ResuxVideo
818
+ src="/media-test/videos/sample-720.mp4"
819
+ poster="/media-test/images/sample-poster.jpg"
820
+ controls
821
+ skip-seconds="10"
822
+ side-click-skip
823
+ click-to-play
824
+ double-click-fullscreen
825
+ />
826
+ ```
827
+
828
+ `ResuxVideo` props (media interaction subset):
829
+
830
+ - `controls` default `true`
831
+ - `nativeControls` optional
832
+ - `customControls` optional
833
+ - `speedControl`, `speeds`, `defaultSpeed`, `persistSpeed`
834
+ - `qualityControl`, `qualities`, `defaultQuality`
835
+ - `sources` supports `{ src, type, quality }`
836
+ - `skipSeconds` default `10`
837
+ - `sideClickSkip` default `true`
838
+ - `clickToPlay` default `true`
839
+ - `doubleClickFullscreen` default `true`
840
+ - `lazy`, `priority`, `preload`, `poster`, `placeholder`
841
+ - optional transforms: `format`, `formats`, `quality` (for resolution height)
842
+
843
+ Video state attributes:
844
+
845
+ - `data-resux-video="idle|loading|ready|playing|paused|error"`
846
+ - `data-rx-video-controls-ready="true|false"`
847
+ - `data-resux-video-control` on interactive control elements
848
+ - `data-resux-video-zone="left|center|right"` on surface zones
849
+
850
+ Optional video transforms can generate cacheable assets in `public/_resux/generated/videos/*` when enabled:
851
+
852
+ ```ts
853
+ export default defineResuxConfig({
854
+ video: {
855
+ transforms: {
856
+ enabled: true,
857
+ formats: ["mp4", "webm"],
858
+ qualities: [480, 720, 1080],
859
+ cache: "1d"
860
+ }
861
+ }
862
+ })
863
+ ```
864
+
865
+ When transforms are requested (for example `format="webm"` or `:qualities="[480,720]"`), Resux emits deterministic URLs under `/_resux/generated/videos/*` and serves them through the built-in `__resux/video` runtime endpoint. If `ffmpeg` is unavailable, Resux falls back with a clear 501 error instead of breaking standard video rendering.
866
+
867
+ ### `ResuxImg` and `ResuxPicture`
868
+
869
+ `ResuxImg` and `ResuxPicture` keep placeholders active until the real image load/decode completes.
870
+
871
+ ```vue
872
+ <ResuxImg
873
+ src="/media-test/images/hero-large.jpg"
874
+ width="1600"
875
+ height="900"
876
+ priority
877
+ placeholder="blur"
878
+ sizes="(min-width: 1280px) 960px, 100vw"
879
+ />
880
+ ```
881
+
882
+ Placeholder modes:
883
+
884
+ - `placeholder="empty"`
885
+ - `placeholder="blur"`
886
+ - `placeholder="skeleton"`
887
+ - `placeholder="spinner"`
888
+ - `placeholder="/custom-placeholder.svg"`
889
+
890
+ Image state attributes:
891
+
892
+ - `data-resux-img="idle|loading|loaded|error"`
893
+ - `data-rx-placeholder-active="true"` while placeholder is visible
894
+ - `data-rx-lazy-image="true"` for deferred lazy sources
895
+
896
+ Priority images emit preload links near the top of `<head>` with `fetchpriority="high"` and responsive `imagesrcset`/`imagesizes`.
897
+
898
+ ## Supported Syntax
899
+
900
+ The v1 compiler supports:
901
+
902
+ - Static elements and text.
903
+ - Interpolation: `{{ value }}`.
904
+ - Static attributes: `class="box"`.
905
+ - Dynamic attributes: `:class="className"`.
906
+ - Dynamic class arrays/objects and style objects for `:class` and `:style`.
907
+ - Plain CSS `<style>` blocks, including `<style scoped>`.
908
+ - Plain named events: `@click="increment"`.
909
+ - Inline event expressions that only capture resumable values, plus named handlers such as `@click="increment"`.
910
+ - Resumability-safe event modifiers: `.prevent`, `.stop`, `.self`, `.once`, system/mouse modifiers, and key filters such as `.enter`.
911
+ - `v-if`, `v-else-if`, and `v-else`.
912
+ - `v-show`.
913
+ - `v-text`.
914
+ - Sanitized `v-html`.
915
+ - Basic `v-model` for form values.
916
+ - Simple `v-for`, such as `item in items` or `(item, index) in items`.
917
+ - Component tags from `components/`.
918
+ - `<ResuxPage />`.
919
+ - `<ResuxLayout />`.
920
+ - `<slot />` inside layouts.
921
+ - `<ResuxLink to="/path">`.
922
+ - `defineProps()` in components.
923
+ - `definePageMeta({ layout, middleware, title, meta })`.
924
+ - `useRoute()` for the current path, params, and query.
925
+ - `useRouter().push("/path")`, `replace`, `back`, `forward`, and `go`.
926
+ - `useHead({ title, meta, link })`.
927
+ - `useSeoMeta({ title, description, ogTitle, ogImage, twitterCard })`.
928
+ - `apiURL("/api/path")` for SSR-safe API fetch URLs.
929
+ - `onMounted()`, run when the component scope is first resumed in the browser.
930
+ - Vue runtime islands via `<VueIsland name="CounterIsland" :props="{ start: 1 }" />` and files in `islands/vue`.
931
+
932
+ Handlers and inline event expressions must only capture resumable values, such as refs returned by `useState`.
933
+
934
+ ## Current Limits
935
+
936
+ Resux intentionally rejects or does not support many advanced framework/Vue features yet:
937
+
938
+ - Vue runtime is island-only; Resux components still do not hydrate through Vue.
939
+ - Nitro support is an adapter/deployment preset, not the primary dev server.
940
+ - SFC styles support plain CSS only; preprocessors like SCSS and CSS modules are not implemented for resumable components yet.
941
+ - Event `.capture` and `.passive` are accepted in templates, but the browser runtime still uses delegated resumable listeners.
942
+ - No fallback hydration for unsupported components.
943
+
944
+ Unsupported resumability patterns should fail at compile time instead of silently hydrating.
945
+
946
+ ## Troubleshooting
947
+
948
+ - `Failed to parse URL from /api/...` during SSR: use `apiURL("/api/...")` or `$fetch("/api/...")` from Resux setup code so server-side fetches get an absolute URL.
949
+ - Skeletons that never disappear: render `error` from `useAsyncData` and guard success UI with `!pending && !error && data`.
950
+ - Dev edits do not appear: keep `resux dev .` running and make sure the browser is connected to `/__resux/dev-events`; Resux reloads the page after successful rebuilds.
951
+ - Port already in use: pass another port, for example `resux dev --port 4000`.
952
+ - Handler capture compile errors: move non-serializable values out of resumable handlers or store resumable state with `useState`.
953
+
954
+ ## Architecture
955
+
956
+ Resux is one package with five internal parts:
957
+
958
+ - Compiler: parses `.vue` files, creates routes, validates resumable handlers, and emits server/client modules.
959
+ - Runtime: renders HTML on the server, provides Resux-style composables, runs plugins, applies layouts, collects head entries, and serializes payloads.
960
+ - CLI and Node server: builds apps, starts the dev server, previews generated output, and exposes `resuxjs/node`.
961
+ - Create CLI: scaffolds a starter app for `resux init`.
962
+ - Package entrypoints: keep the root runtime-only while `resuxjs/compiler`, `resuxjs/runtime`, `resuxjs/node`, `resuxjs/globals`, and `resuxjs/create` expose focused surfaces.
963
+
964
+ The browser initially receives only server-rendered HTML, the serialized payload, and the small resume loader.
965
+
966
+ For internal navigation, the client runtime prefetches route payloads on hover/focus, intercepts same-origin links, fetches a fresh SSR route payload from `/__resux/route`, updates a server-rendered transition progress shell through start/fetch/swap/complete/error phases, keeps the active layout DOM when the layout name matches, swaps the page slot, updates `<head>`, updates browser history, and clears only non-persistent resumed page scopes.
967
+
968
+ ## Testing
969
+
970
+ Run:
971
+
972
+ ```sh
973
+ npm test
974
+ ```
975
+
976
+ The tests cover:
977
+
978
+ - Route generation.
979
+ - SFC compiler output.
980
+ - Compile errors for unsupported resumability captures.
981
+ - Sanitized `v-html`, `v-model`, inline handlers, and mounted resume hooks.
982
+ - SSR payload serialization.
983
+ - Dynamic route params and catch-all params.
984
+ - Layout rendering.
985
+ - Head/meta rendering.
986
+ - Runtime config and plugin provides.
987
+ - Recursive project discovery for layouts, middleware, server middleware, plugins, API routes, and config.
988
+ - Plugin order and client/server mode filtering.
989
+ - Route middleware execution for SSR and client navigation.
990
+ - Extended route-rule serialization.
991
+ - Client resume behavior after interaction.