@madojs/mado 0.10.1 → 0.11.1

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 (219) hide show
  1. package/AGENTS.md +24 -26
  2. package/CHANGELOG.md +95 -0
  3. package/README.md +22 -47
  4. package/TODO.md +52 -48
  5. package/dist/src/component.d.ts +2 -1
  6. package/dist/src/component.js +5 -2
  7. package/dist/src/component.js.map +1 -1
  8. package/dist/src/each.d.ts +1 -1
  9. package/dist/src/each.js +1 -1
  10. package/dist/src/each.js.map +1 -1
  11. package/dist/src/html/bindings.js +3 -3
  12. package/dist/src/html/bindings.js.map +1 -1
  13. package/dist/src/index.d.ts +11 -6
  14. package/dist/src/index.js +5 -3
  15. package/dist/src/index.js.map +1 -1
  16. package/dist/src/lazy.d.ts +1 -1
  17. package/dist/src/lazy.js +1 -1
  18. package/dist/src/lazy.js.map +1 -1
  19. package/dist/src/page.d.ts +17 -21
  20. package/dist/src/page.js +7 -12
  21. package/dist/src/page.js.map +1 -1
  22. package/dist/src/router/manifest.d.ts +1 -1
  23. package/dist/src/router/manifest.js +21 -13
  24. package/dist/src/router/manifest.js.map +1 -1
  25. package/dist/src/router/match.d.ts +2 -2
  26. package/dist/src/router/match.js +3 -3
  27. package/dist/src/router/match.js.map +1 -1
  28. package/dist/src/router/navigation.js +1 -1
  29. package/dist/src/router/navigation.js.map +1 -1
  30. package/dist/src/vite/index.d.ts +10 -0
  31. package/dist/src/vite/index.js +33 -0
  32. package/dist/src/vite/index.js.map +1 -0
  33. package/docs/en/00-the-mado-way.md +25 -12
  34. package/docs/en/01-routing.md +90 -142
  35. package/docs/en/02-project-layout.md +59 -53
  36. package/docs/en/03-static-bake.md +5 -6
  37. package/docs/en/05-why-mado.md +6 -6
  38. package/docs/en/06-for-backenders.md +18 -22
  39. package/docs/en/08-llm-zero-history-test.md +9 -14
  40. package/docs/en/09-shadow-vs-light-dom.md +28 -36
  41. package/docs/en/10-app-architecture.md +158 -96
  42. package/docs/en/11-layouts.md +22 -24
  43. package/docs/en/12-auth-and-api.md +89 -182
  44. package/docs/en/13-deployment.md +18 -22
  45. package/docs/en/14-testing.md +4 -4
  46. package/docs/en/16-bake-cookbook.md +11 -12
  47. package/docs/en/18-api-freeze-map.md +6 -4
  48. package/docs/en/20-v1-stability.md +1 -1
  49. package/docs/fr/00-the-mado-way.md +55 -90
  50. package/docs/fr/01-routing.md +70 -152
  51. package/docs/fr/02-project-layout.md +61 -42
  52. package/docs/fr/03-static-bake.md +1 -1
  53. package/docs/fr/05-why-mado.md +6 -6
  54. package/docs/fr/06-for-backenders.md +7 -7
  55. package/docs/fr/08-llm-zero-history-test.md +21 -48
  56. package/docs/fr/09-shadow-vs-light-dom.md +43 -162
  57. package/docs/fr/10-app-architecture.md +110 -33
  58. package/docs/fr/11-layouts.md +24 -12
  59. package/docs/fr/12-auth-and-api.md +63 -22
  60. package/docs/fr/13-deployment.md +7 -10
  61. package/docs/fr/14-testing.md +1 -1
  62. package/docs/fr/16-bake-cookbook.md +2 -2
  63. package/docs/fr/18-api-freeze-map.md +1 -1
  64. package/docs/fr/20-v1-stability.md +1 -1
  65. package/docs/recipes/nginx/README.md +13 -0
  66. package/docs/ru/00-the-mado-way.md +53 -75
  67. package/docs/ru/01-routing.md +68 -143
  68. package/docs/ru/02-project-layout.md +61 -41
  69. package/docs/ru/03-static-bake.md +2 -2
  70. package/docs/ru/05-why-mado.md +6 -6
  71. package/docs/ru/06-for-backenders.md +7 -7
  72. package/docs/ru/08-llm-zero-history-test.md +9 -14
  73. package/docs/ru/09-shadow-vs-light-dom.md +43 -178
  74. package/docs/ru/10-app-architecture.md +115 -63
  75. package/docs/ru/11-layouts.md +24 -24
  76. package/docs/ru/12-auth-and-api.md +57 -35
  77. package/docs/ru/13-deployment.md +7 -11
  78. package/docs/ru/14-testing.md +1 -1
  79. package/docs/ru/16-bake-cookbook.md +12 -6
  80. package/docs/ru/18-api-freeze-map.md +5 -3
  81. package/docs/ru/20-v1-stability.md +1 -1
  82. package/docs/uk/00-the-mado-way.md +70 -44
  83. package/docs/uk/01-routing.md +41 -47
  84. package/docs/uk/02-project-layout.md +68 -41
  85. package/docs/uk/03-static-bake.md +1 -2
  86. package/docs/uk/06-for-backenders.md +3 -3
  87. package/docs/uk/08-llm-zero-history-test.md +22 -24
  88. package/docs/uk/09-shadow-vs-light-dom.md +37 -86
  89. package/docs/uk/10-app-architecture.md +72 -31
  90. package/docs/uk/11-layouts.md +25 -12
  91. package/docs/uk/12-auth-and-api.md +58 -22
  92. package/docs/uk/13-deployment.md +4 -3
  93. package/docs/uk/14-testing.md +1 -1
  94. package/docs/uk/18-api-freeze-map.md +1 -1
  95. package/docs/uk/20-v1-stability.md +1 -1
  96. package/llms.txt +14 -15
  97. package/package.json +18 -11
  98. package/scripts/_config.mjs +15 -161
  99. package/scripts/bake.mjs +74 -63
  100. package/scripts/cli/generate.mjs +348 -0
  101. package/scripts/cli/help.mjs +27 -0
  102. package/scripts/cli/index.mjs +79 -0
  103. package/scripts/cli/init.mjs +153 -0
  104. package/scripts/cli/release.mjs +152 -0
  105. package/scripts/cli/run.mjs +96 -0
  106. package/scripts/cli.mjs +2 -621
  107. package/scripts/package-smoke.mjs +4 -1
  108. package/scripts/preview.mjs +13 -37
  109. package/scripts/size-budget.mjs +5 -2
  110. package/scripts/vite.default.mjs +11 -0
  111. package/starters/default/.editorconfig +12 -0
  112. package/starters/default/README.md +74 -0
  113. package/starters/default/eslint.config.mjs +256 -0
  114. package/starters/default/index.html +13 -0
  115. package/starters/default/package.json +30 -0
  116. package/starters/default/public/favicon.svg +4 -0
  117. package/starters/default/src/app.routes.ts +39 -0
  118. package/starters/default/src/layouts/app-shell.layout.ts +35 -0
  119. package/starters/default/src/layouts/auth-shell.layout.ts +17 -0
  120. package/starters/default/src/main.ts +16 -0
  121. package/starters/default/src/modules/auth/_contracts/auth-api.types.ts +17 -0
  122. package/starters/default/src/modules/auth/auth.connector.ts +45 -0
  123. package/starters/default/src/modules/auth/auth.guard.ts +22 -0
  124. package/starters/default/src/modules/auth/auth.public.ts +9 -0
  125. package/starters/default/src/modules/auth/auth.routes.ts +8 -0
  126. package/starters/default/src/modules/auth/auth.service.ts +71 -0
  127. package/starters/default/src/modules/auth/auth.types.ts +15 -0
  128. package/starters/default/src/modules/auth/login.page.ts +62 -0
  129. package/starters/default/src/modules/billing/_contracts/stripe.types.ts +17 -0
  130. package/starters/default/src/modules/billing/api/stripe.connector.ts +71 -0
  131. package/starters/default/src/modules/billing/billing.public.ts +5 -0
  132. package/starters/default/src/modules/billing/billing.routes.ts +9 -0
  133. package/starters/default/src/modules/billing/billing.types.ts +15 -0
  134. package/starters/default/src/modules/billing/components/invoice-status-badge.component.ts +43 -0
  135. package/starters/default/src/modules/billing/data/invoices.resource.ts +35 -0
  136. package/starters/default/src/modules/billing/pages/invoice-detail.page.ts +70 -0
  137. package/starters/default/src/modules/billing/pages/invoices-list.page.ts +73 -0
  138. package/starters/default/src/modules/home/home.page.ts +34 -0
  139. package/starters/default/src/modules/home/not-found.page.ts +11 -0
  140. package/starters/default/src/shared/http/http-client.ts +86 -0
  141. package/starters/default/src/shared/http/http-error.ts +37 -0
  142. package/starters/default/src/shared/http/interceptors.ts +59 -0
  143. package/starters/default/src/shared/lib/format-date.ts +19 -0
  144. package/starters/default/src/shared/styles/content.css +70 -0
  145. package/starters/default/src/shared/styles/reset.css +32 -0
  146. package/starters/default/src/shared/styles/shell.css +57 -0
  147. package/starters/default/src/shared/styles/tokens.css +44 -0
  148. package/starters/default/src/shared/ui/x-button.component.ts +49 -0
  149. package/starters/default/src/shared/ui/x-spinner.component.ts +22 -0
  150. package/starters/default/src/styles.d.ts +1 -0
  151. package/starters/default/src/vite-env.d.ts +1 -0
  152. package/starters/default/tsconfig.json +24 -0
  153. package/starters/default/vite.config.ts +9 -0
  154. package/MADO_V1_PLAN.md +0 -179
  155. package/ROADMAP.md +0 -178
  156. package/dist/src/html.d.ts +0 -18
  157. package/dist/src/html.js +0 -17
  158. package/dist/src/html.js.map +0 -1
  159. package/dist/src/router.d.ts +0 -13
  160. package/dist/src/router.js +0 -13
  161. package/dist/src/router.js.map +0 -1
  162. package/scripts/bundle.mjs +0 -212
  163. package/scripts/llm-zero-history-smoke.mjs +0 -93
  164. package/scripts/new.mjs +0 -80
  165. package/scripts/showcase-regression.mjs +0 -392
  166. package/server/serve.mjs +0 -455
  167. package/starters/admin/README.md +0 -63
  168. package/starters/admin/index.html +0 -28
  169. package/starters/admin/mado.config.json +0 -22
  170. package/starters/admin/package.json +0 -24
  171. package/starters/admin/public/favicon.svg +0 -4
  172. package/starters/admin/src/components/x-button.ts +0 -82
  173. package/starters/admin/src/components/x-input.ts +0 -105
  174. package/starters/admin/src/layouts/app.ts +0 -101
  175. package/starters/admin/src/layouts/auth.ts +0 -41
  176. package/starters/admin/src/lib/api.ts +0 -184
  177. package/starters/admin/src/lib/auth.ts +0 -83
  178. package/starters/admin/src/main.ts +0 -15
  179. package/starters/admin/src/pages/admin/dashboard.ts +0 -48
  180. package/starters/admin/src/pages/admin/order-detail.ts +0 -80
  181. package/starters/admin/src/pages/admin/orders.ts +0 -117
  182. package/starters/admin/src/pages/home.ts +0 -34
  183. package/starters/admin/src/pages/login.ts +0 -70
  184. package/starters/admin/src/pages/not-found.ts +0 -12
  185. package/starters/admin/src/routes.ts +0 -40
  186. package/starters/admin/src/styles/global.ts +0 -86
  187. package/starters/admin/tsconfig.json +0 -15
  188. package/starters/crud/README.md +0 -33
  189. package/starters/crud/index.html +0 -28
  190. package/starters/crud/mado.config.json +0 -20
  191. package/starters/crud/package.json +0 -24
  192. package/starters/crud/src/components/app-shell.ts +0 -56
  193. package/starters/crud/src/components/ticket-detail.ts +0 -33
  194. package/starters/crud/src/components/ticket-form.ts +0 -69
  195. package/starters/crud/src/components/ticket-list.ts +0 -66
  196. package/starters/crud/src/lib/api.ts +0 -76
  197. package/starters/crud/src/main.ts +0 -9
  198. package/starters/crud/src/pages/home.ts +0 -34
  199. package/starters/crud/src/pages/not-found.ts +0 -12
  200. package/starters/crud/src/pages/ticket-detail.ts +0 -7
  201. package/starters/crud/src/pages/ticket-new.ts +0 -7
  202. package/starters/crud/src/pages/tickets.ts +0 -7
  203. package/starters/crud/src/routes.ts +0 -11
  204. package/starters/crud/src/styles/global.ts +0 -155
  205. package/starters/crud/tsconfig.json +0 -15
  206. package/starters/minimal/README.md +0 -21
  207. package/starters/minimal/index.html +0 -28
  208. package/starters/minimal/mado.config.json +0 -20
  209. package/starters/minimal/package.json +0 -24
  210. package/starters/minimal/src/components/app-counter.ts +0 -31
  211. package/starters/minimal/src/main.ts +0 -9
  212. package/starters/minimal/src/pages/home.ts +0 -35
  213. package/starters/minimal/src/pages/not-found.ts +0 -14
  214. package/starters/minimal/src/routes.ts +0 -8
  215. package/starters/minimal/src/styles/global.ts +0 -60
  216. package/starters/minimal/tsconfig.json +0 -15
  217. package/templates/page-detail.ts +0 -63
  218. package/templates/page-form.ts +0 -94
  219. package/templates/page-list.ts +0 -79
@@ -0,0 +1,33 @@
1
+ import { resolve } from "node:path";
2
+ /**
3
+ * Vite integration for Mado apps.
4
+ *
5
+ * The plugin is intentionally small: Vite owns dev serving, HTML processing,
6
+ * assets and bundling; Mado keeps its runtime and static bake semantics.
7
+ */
8
+ export function mado(_options = {}) {
9
+ let root = process.cwd();
10
+ return {
11
+ name: "mado",
12
+ config(userConfig) {
13
+ root = resolve(process.cwd(), userConfig.root ?? ".");
14
+ return {
15
+ appType: "spa",
16
+ publicDir: "public",
17
+ build: {
18
+ outDir: "out",
19
+ assetsDir: "assets",
20
+ target: "es2022",
21
+ },
22
+ };
23
+ },
24
+ handleHotUpdate(ctx) {
25
+ if (/\.(ts|js)$/.test(ctx.file)) {
26
+ ctx.server.ws.send({ type: "full-reload" });
27
+ return [];
28
+ }
29
+ return undefined;
30
+ },
31
+ };
32
+ }
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAC,WAAkC,EAAE;IACvD,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAEzB,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,MAAM,CAAC,UAAU;YACf,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;YAEtD,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,QAAQ;gBACnB,KAAK,EAAE;oBACL,MAAM,EAAE,KAAK;oBACb,SAAS,EAAE,QAAQ;oBACnB,MAAM,EAAE,QAAQ;iBACjB;aACF,CAAC;QACJ,CAAC;QACD,eAAe,CAAC,GAAG;YACjB,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;gBAC5C,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -27,21 +27,31 @@ break them — types and the linter will tell you immediately.
27
27
 
28
28
  ```
29
29
  src/
30
- ├── routes.ts route manifest, one file per project
31
- ├── main.ts entry point: providers + mount <x-app>
32
- ├── pages/ one page = one file = `export default page({...})`
33
- ├── components/ reusable components, side-effect registration
34
- ├── lib/ ← contexts, API clients, business logic without UI
35
- └── styles/ ← shared styles (if needed), .ts files with css``
30
+ ├── main.ts boot: global CSS/providers + render router
31
+ ├── app.routes.ts one readable app map, exports `manifest` + default routes()
32
+ ├── layouts/ app-zone wrappers (`page({ view: ({ child }) => ... })`)
33
+ ├── shared/ UI bricks, http client, pure lib, global CSS
34
+ └── modules/ bounded contexts
35
+ └── billing/
36
+ ├── billing.routes.ts
37
+ ├── billing.public.ts
38
+ ├── billing.types.ts
39
+ ├── pages/
40
+ ├── data/
41
+ ├── api/
42
+ └── _contracts/
36
43
  ```
37
44
 
38
45
  This is **mandatory**, not optional. If a project has 10 developers — they must
39
46
  all write the same way.
40
47
 
48
+ The default starter is the canonical version of this shape. Use it as the
49
+ reference when docs and examples disagree.
50
+
41
51
  ### One component = one file
42
52
 
43
53
  ```ts
44
- // src/components/user-card.ts
54
+ // src/shared/ui/x-user-card.component.ts
45
55
  import { component, html, css } from "@madojs/mado";
46
56
 
47
57
  component(
@@ -59,7 +69,7 @@ component(
59
69
  );
60
70
  ```
61
71
 
62
- `import './components/user-card.js'` **registers** the component via
72
+ `import "./shared/ui/x-user-card.component.js"` **registers** the component via
63
73
  `customElements.define`. This is a side effect. Import where the component is needed.
64
74
 
65
75
  ### One way to load data
@@ -79,17 +89,20 @@ This provides caching, cancellation, error handling, and auto-invalidation.
79
89
  ### One way to describe a page
80
90
 
81
91
  ```ts
82
- // src/pages/user-profile.ts
92
+ // src/modules/users/pages/user-profile.page.ts
83
93
  import { page, html, resource, jsonFetcher } from "@madojs/mado";
84
94
 
85
95
  export default page({
86
96
  title: ({ id }) => `User #${id}`,
87
- view: ({ params }) => html`...`,
97
+ view: ({ params }) => {
98
+ const user = resource(() => `/api/users/${params.id}`, jsonFetcher());
99
+ return html`...`;
100
+ },
88
101
  });
89
102
  ```
90
103
 
91
- Three slots `title`, `load`, `view`. No others. Want something else — that is
92
- a component or a helper.
104
+ Keep page-local signals, resources and forms inside `view()`. Module-wide state
105
+ belongs in `*.service.ts`.
93
106
 
94
107
  ### One way to declare routes
95
108
 
@@ -1,204 +1,152 @@
1
1
  # Routing
2
2
 
3
- > One manifest file. No folder scanners. No special characters.
3
+ > One app map. No folder scanners. No special path syntax.
4
4
 
5
- ## Why not file-based
5
+ Mado does not infer routes from files. The browser sees files as files; route
6
+ composition should be readable in one place.
6
7
 
7
- In Next/SvelteKit/SolidStart routes appear "magically" from file names. This has
8
- advantages (URL structure visible in `pages/`), but in production it means:
8
+ ## App Manifest
9
9
 
10
- - An invisible plugin-scanner in the build. Without it the files are just files.
11
- - Special characters in paths: `[id]`, `(group)`, `_layout`, `+page.svelte`, `...slug`.
12
- - Server-routes and client-routes get confused.
13
- - Testing routing is a pain: you need a build-tool emulator.
10
+ Use `src/app.routes.ts` as the application map:
14
11
 
15
- Mado considers this **too much magic**. We do it differently.
12
+ ```ts
13
+ import { layout, routes } from "@madojs/mado";
14
+ import { requireAuth } from "./modules/auth/auth.public";
15
+ import { authRoutes } from "./modules/auth/auth.routes";
16
+ import { billingRoutes } from "./modules/billing/billing.routes";
17
+
18
+ export const manifest = {
19
+ "/": () => import("./modules/home/home.page.js"),
20
+ "/login": layout({
21
+ layout: () => import("./layouts/auth-shell.layout.js"),
22
+ routes: authRoutes,
23
+ }),
24
+ "/billing": layout({
25
+ layout: () => import("./layouts/app-shell.layout.js"),
26
+ guard: requireAuth,
27
+ routes: billingRoutes,
28
+ }),
29
+ "*": () => import("./modules/home/not-found.page.js"),
30
+ };
31
+
32
+ export default routes(manifest);
33
+ ```
16
34
 
17
- ## Manifest
35
+ Open `app.routes.ts` and you can see the whole app: public pages, auth zone,
36
+ protected app zones, guards and shells.
18
37
 
19
- One file `src/routes.ts`. One object. Read top to bottom.
38
+ Exporting `manifest` is important because `mado bake` reads it.
39
+
40
+ ## Module Routes
41
+
42
+ Modules export plain route maps. They do not call `layout()` and they do not
43
+ decide which shell wraps them.
20
44
 
21
45
  ```ts
22
- // src/routes.ts
23
- import { routes } from '@madojs/mado';
24
-
25
- export default routes({
26
- '/': () => import('./pages/home.js'),
27
- '/about': () => import('./pages/about.js'),
28
- '/users/:id': () => import('./pages/user-profile.js'),
29
- '/users/:id/edit':() => import('./pages/user-edit.js'),
30
- '*': () => import('./pages/not-found.js'),
31
- });
46
+ // src/modules/billing/billing.routes.ts
47
+ export const billingRoutes = {
48
+ "/invoices": () => import("./pages/invoices-list.page.js"),
49
+ "/invoices/:id": () => import("./pages/invoice-detail.page.js"),
50
+ };
32
51
  ```
33
52
 
34
- Want to see all routes? Open `routes.ts`. No surprises.
35
-
36
- ## What goes on the right side of a path
53
+ The prefix is applied by `src/app.routes.ts` when the module is mounted under
54
+ `"/billing"`.
37
55
 
38
- Every entry is **one of three things**:
56
+ ## What Goes On The Right Side
39
57
 
40
- ### 1. Lazy import (recommended)
58
+ ### Lazy page import
41
59
 
42
60
  ```ts
43
- '/posts': () => import('./pages/posts.js'),
61
+ "/users/:id": () => import("./modules/users/pages/user-profile.page.js"),
44
62
  ```
45
63
 
46
- - The browser makes its own chunk when bundling (esbuild --bundle --splitting).
47
- - The module is loaded only when the user visits the route.
48
- - Subsequent navigations use the cached result.
64
+ Vite creates a separate chunk for dynamic imports in production.
49
65
 
50
- ### 2. Ready Page (eager)
66
+ ### Eager page
51
67
 
52
68
  ```ts
53
- import about from './pages/about.js';
69
+ import home from "./modules/home/home.page.js";
54
70
 
55
- '/about': about,
71
+ export const manifest = {
72
+ "/": home,
73
+ };
56
74
  ```
57
75
 
58
- In the bundle immediately, no delay. Use for critical pages (home, login).
76
+ Use this only for tiny critical pages.
59
77
 
60
- ### 3. Nested with layout
78
+ ### Layout group
61
79
 
62
80
  ```ts
63
- import { routes, nested } from '@madojs/mado';
64
-
65
- export default routes({
66
- '/': () => import('./pages/home.js'),
67
-
68
- '/admin/*': nested({
69
- layout: () => import('./layouts/admin.js'),
70
- routes: {
71
- '': () => import('./pages/admin/dashboard.js'),
72
- 'users': () => import('./pages/admin/users.js'),
73
- 'logs': () => import('./pages/admin/logs.js'),
74
- },
75
- }),
76
- });
81
+ "/admin": layout({
82
+ layout: () => import("./layouts/app-shell.layout.js"),
83
+ guard: requireAuth,
84
+ routes: adminRoutes,
85
+ }),
77
86
  ```
78
87
 
79
- A layout is just a regular `page({...})` that renders `ctx.child` wherever it wants:
88
+ A layout is a normal `page({...})` file:
80
89
 
81
90
  ```ts
82
- // src/layouts/admin.ts
83
- import { page, html, css, component } from '@madojs/mado';
91
+ import { html, page } from "@madojs/mado";
84
92
 
85
93
  export default page({
86
94
  view: ({ child }) => html`
87
- <div class="admin">
88
- <aside><nav>...</nav></aside>
89
- <main>${child}</main>
95
+ <div class="layout layout--app">
96
+ <main class="app-main">${child}</main>
90
97
  </div>
91
98
  `,
92
99
  });
93
100
  ```
94
101
 
95
- ## Page contract
102
+ Keep layout views stateless. Put page-specific signals, resources and forms in
103
+ pages/components/resources, not in layout locals.
96
104
 
97
- ```ts
98
- import { page, html, resource, jsonFetcher } from '@madojs/mado';
99
-
100
- export default page({
101
- title: ({ id }) => `User #${id}`, // string | (params) => string
102
- load: ({ id }) => resource(...), // optional, returns Resource or data
103
- view: ({ params, data, path, child }) => html`...`, // REQUIRED
104
- });
105
- ```
106
-
107
- Three slots, that's all. If you export something other than `page({...})`, a plain
108
- function for instance — `routes()` throws a clear error:
109
-
110
- ```
111
- [Mado] Lazy route did not return page({...}) as the default export.
112
- ```
113
-
114
- ## URL parameters
105
+ ## Page Contract
115
106
 
116
107
  ```ts
117
- '/users/:id': () => import('./pages/user.js'),
118
- ```
108
+ import { html, page } from "@madojs/mado";
119
109
 
120
- ```ts
121
110
  export default page<{ id: string }>({
122
111
  title: ({ id }) => `User ${id}`,
123
- view: ({ params }) => html`<h1>${params.id}</h1>`,
112
+ view: ({ params }) => html`<h1>${params.id}</h1>`,
124
113
  });
125
114
  ```
126
115
 
127
- Types are passed in `page<Params>` `tsc` verifies that you don't access
128
- `params.foo` which doesn't exist in the route.
129
-
130
- ## Global options
131
-
132
- ```ts
133
- export default routes(
134
- { '/': home, '/about': about, '*': nf },
135
- {
136
- titleSuffix: ' · MyApp', // → "Home · MyApp"
137
- loading: () => html`<x-spinner/>`, // while module loads
138
- error: (err) => html`<x-fatal-error .err=${err}/>`,
139
- },
140
- );
141
- ```
116
+ If a lazy route does not default-export `page({...})`, `routes()` throws a clear
117
+ error.
142
118
 
143
- ## Programmatic navigation
119
+ ## Navigation
144
120
 
145
121
  ```ts
146
- import route from './routes.js';
122
+ import appRoutes from "./app.routes.js";
147
123
 
148
- route.navigate('/posts');
149
- route.navigate('/posts?page=2');
150
- route.navigate('/posts', { replace: true });
124
+ appRoutes.navigate("/billing/invoices");
125
+ appRoutes.navigate("/billing/invoices?page=2");
126
+ appRoutes.navigate("/login", { replace: true });
151
127
  ```
152
128
 
153
- Clicks on `<a href="/foo" data-link>` are intercepted globally (without the
154
- attribute the browser does a full reload, as expected for external links).
129
+ Clicks on `<a href="/foo">` are intercepted for same-origin SPA navigation.
130
+ External links still use normal browser navigation.
155
131
 
156
- ## Query parameters
132
+ ## Query Parameters
157
133
 
158
134
  ```ts
159
- import { queryParam } from '@madojs/mado';
135
+ import { queryParam } from "@madojs/mado";
160
136
 
161
- const page = queryParam('page', '1');
162
- page(); // '1'
163
- page.set('2'); // history.replaceState + re-render
164
- page.set(null); // delete the parameter
165
- page.set('3', { push: true }); // history.pushState
137
+ const page = queryParam("page", "1");
138
+ page();
139
+ page.set("2");
140
+ page.set(null);
141
+ page.set("3", { push: true });
166
142
  ```
167
143
 
168
- `queryParam` is a normal signal. Use it anywhere: in pages, components, computed.
169
-
170
- ## What is intentionally absent
171
-
172
- - ❌ Auto-scan of `pages/`. **One explicit manifest file**.
173
- - ❌ Special characters in paths (`[id]`, `(group)`, `_layout`). **Parameters are
174
- `:name` only, nothing else**.
175
- - ❌ Server-side routing in the same manifest. Mado is a client-side framework.
176
- - ❌ Auto-prefetch on hover. If you really need it — do it manually:
177
- `link.addEventListener('mouseenter', loader)`. Usually unnecessary.
178
-
179
- ## FAQ
180
-
181
- **What if I have 100 routes? Won't the file get huge?**
182
- It will grow to ~150 lines. That is still **one source of truth** versus a hundred
183
- files in `pages/` with magic names. In practice even large projects (1000+ pages)
184
- can split into feature manifests:
185
-
186
- ```ts
187
- import { routes } from '@madojs/mado';
188
- import adminRoutes from './features/admin/routes.js';
189
- import billingRoutes from './features/billing/routes.js';
190
-
191
- export default routes({
192
- ...adminRoutes,
193
- ...billingRoutes,
194
- '*': () => import('./pages/not-found.js'),
195
- });
196
- ```
144
+ `queryParam()` is a signal. Use it in pages or components when URL state is part
145
+ of the UI.
197
146
 
198
- **How do I test routing?**
199
- Import `routes.ts` — it is just an object. Substitute your mock router. No build
200
- tool emulation needed.
147
+ ## What Is Intentionally Absent
201
148
 
202
- **Does code splitting work?**
203
- Yes. With `esbuild --bundle --splitting --format=esm` every
204
- `() => import('./pages/x.js')` becomes its own chunk.
149
+ - No auto-scan of page folders.
150
+ - No special filesystem route syntax like `[id]`, `(group)`, `_layout`.
151
+ - No server routes in the client manifest.
152
+ - No hidden layout discovery. App zones are explicit in `app.routes.ts`.
@@ -8,40 +8,42 @@ things live.
8
8
  my-app/
9
9
  ├── package.json # exactly one runtime dep: @madojs/mado
10
10
  ├── tsconfig.json # strict TS, ES2022, Bundler resolution
11
- ├── mado.config.json # single config file (dev/build/bake/bundle)
12
- ├── index.html # SPA shell (also the template for `mado bake`)
11
+ ├── vite.config.ts # optional; use mado() from @madojs/mado/vite
12
+ ├── index.html # Vite entry + SPA shell
13
13
  ├── public/ # static assets (favicons, images, robots.txt)
14
14
  └── src/
15
15
  ├── main.ts # entry: mount router into #app
16
- ├── routes.ts # route manifest (default + named `manifest`)
17
- ├── layouts/ # `page({ child })` layouts for nested routes
18
- ├── pages/ # one page = one file
19
- ├── components/ # reusable x-* Web Components
20
- └── lib/
21
- ├── api.ts # API client + error type
22
- ├── auth.ts # auth recipe (token + guard)
23
- └── ... # contexts, helpers, business rules
16
+ ├── app.routes.ts # one app map (default + named `manifest`)
17
+ ├── layouts/ # app-zone layouts, not domain modules
18
+ ├── shared/ # ui, http, lib, styles
19
+ └── modules/ # bounded contexts
20
+ └── billing/
21
+ ├── billing.routes.ts
22
+ ├── billing.public.ts
23
+ ├── billing.types.ts
24
+ ├── pages/
25
+ ├── data/
26
+ ├── api/
27
+ └── _contracts/
24
28
  ```
25
29
 
26
30
  ## The three artifact states (read this once, never wonder again)
27
31
 
28
32
  | Folder | What it is | Who writes | Who reads | Deploy? |
29
33
  |-------------|----------------------------------------------------------------|-------------------|----------------------------|-------------------|
30
- | `src/` | your source (TypeScript) | you | `tsc`, `esbuild` | ❌ no |
31
- | `dist/` | `tsc` output native ESM `.js` for the browser | `mado build` | `mado dev` (during dev) | ❌ no (internal) |
32
- | `public/` | static assets you authored (favicon, images, robots.txt) | you | `mado release` copies it | ✅ via `out/` |
33
- | `out/` | **the deploy artifact**: SPA shell + bundles + baked HTML | `mado release` | nginx / CDN / Cloudflare | ✅ **yes** |
34
+ | `src/` | your source (TypeScript) | you | Vite, `tsc --noEmit` | ❌ no |
35
+ | `public/` | static assets copied as-is (favicon, images, robots.txt) | you | Vite build | via `out/` |
36
+ | `out/` | **the deploy artifact**: SPA shell + assets + baked HTML | `mado release` | nginx / CDN / Cloudflare | ✅ **yes** |
34
37
 
35
38
  One-liner to remember:
36
39
  > Develop with `mado dev`. To ship: run `mado release`, then upload `out/`.
37
40
 
38
- `mado release` = `typecheck` + `build` (tsc → `dist/`) + `bundle` (esbuild
39
- `out/assets/`) + `bake` (HTML `out/baked/`) + promote baked HTML and
40
- `sitemap.xml` into deployable `out/` paths + copy `public/*` → `out/`.
41
+ `mado release` = `typecheck` + Vite build (`out/index.html`, `out/assets/`,
42
+ `public/*`) + `bake` directly into deployable route paths + `sitemap.xml` +
43
+ precompressed assets and CDN helper files.
41
44
 
42
- You almost never need to look inside `dist/`. It exists so the dev browser can
43
- load native ESM modules without a bundler during development. In production
44
- the equivalent code is bundled and hashed into `out/assets/`.
45
+ `index.html` belongs at the project root because Vite treats it as an entry
46
+ template, not as a static public file. Put only copy-as-is files in `public/`.
45
47
 
46
48
  ### Quick deployment matrix
47
49
 
@@ -57,14 +59,19 @@ See `docs/en/13-deployment.md` for full recipes.
57
59
 
58
60
  | What | Where |
59
61
  |-------------------------------------|------------------------------------------------------|
60
- | Page for a new URL | `src/pages/<name>.ts` + add to `src/routes.ts` |
61
- | Layout for a group of routes | `src/layouts/<name>.ts` (referenced from `routes.ts`)|
62
- | Reusable UI widget | `src/components/<x-name>.ts` |
63
- | API call | `src/lib/api.ts` (add a method) |
64
- | Auth/session | `src/lib/auth.ts` |
65
- | Global context (theme, user, i18n) | `src/lib/<name>.ts` |
66
- | Pure function with no UI | `src/lib/util/<name>.ts` |
62
+ | Page for a new URL | `src/modules/<module>/pages/<name>.page.ts` + module routes |
63
+ | Module route map | `src/modules/<module>/<module>.routes.ts` |
64
+ | App shell/layout | `src/layouts/<zone>.layout.ts` |
65
+ | Reusable shared UI widget | `src/shared/ui/<x-name>.component.ts` |
66
+ | Module-only UI widget | `src/modules/<module>/components/<name>.component.ts` |
67
+ | API connector | `src/modules/<module>/api/<provider>.connector.ts` |
68
+ | Data resource/mutation | `src/modules/<module>/data/<name>.resource.ts` |
69
+ | Auth/session | `src/modules/auth/` |
70
+ | Public module surface | `src/modules/<module>/<module>.public.ts` |
71
+ | Pure function with no UI | `src/shared/lib/<name>.ts` |
67
72
  | Static image / favicon | `public/<file>` |
73
+ | App-zone shell CSS | `src/shared/styles/shell.css` |
74
+ | Page-level table/form/prose CSS | `src/shared/styles/content.css` |
68
75
 
69
76
  If you don't know where — that is a signal that **the architecture is
70
77
  suffering**. Ask the team and **record** the answer in `docs/`. Don't invent a
@@ -80,39 +87,38 @@ new top-level folder.
80
87
  | Signal | camelCase | `userId`, `isLoggedIn` |
81
88
  | Page-internal element | `x-<route>-page` | `<x-posts-page>` |
82
89
 
83
- ## `mado.config.json` in one screen
90
+ ## Vite config
84
91
 
85
- ```jsonc
86
- {
87
- "dev": {
88
- "port": 5173,
89
- "proxy": { "/api": "http://localhost:3000" } // dev → backend
90
- },
91
- "build": {
92
- "out": "out",
93
- "dist": "dist",
94
- "publicDir": "public"
92
+ App/dev/build settings live in `vite.config.ts`.
93
+
94
+ ```ts
95
+ import { defineConfig } from "vite";
96
+ import { mado } from "@madojs/mado/vite";
97
+
98
+ export default defineConfig({
99
+ plugins: [mado()],
100
+ css: {
101
+ transformer: "lightningcss",
95
102
  },
96
- "bake": {
97
- "entry": "src/routes.ts",
98
- "template": "index.html",
99
- "baseUrl": "https://example.com"
103
+ server: {
104
+ proxy: { "/api": "http://localhost:3000" },
100
105
  },
101
- "bundle": {
102
- "splitting": true,
103
- "compress": ["gz", "br"]
104
- }
105
- }
106
+ });
106
107
  ```
107
108
 
108
- Precedence: built-in defaults < `mado.config.json` < CLI flags
109
- (< legacy env vars). All keys are optional.
109
+ The default starter opts into Vite's Lightning CSS transformer. CSS
110
+ minification is already handled by Vite; the explicit transformer keeps
111
+ prefixing and modern CSS lowering in Vite instead of in Mado.
112
+
113
+ `mado bake` uses conventions by default: `src/app.routes.ts` first,
114
+ then `src/routes.ts`, `index.html` as the template, and `out/` as output.
115
+ Use CLI flags (`--entry`, `--template`, `--out`, `--base-url`) for the few
116
+ values that are specific to prerendering.
110
117
 
111
118
  ## What does NOT go in `src/`
112
119
 
113
- - ❌ Build tool configs (webpack, rollup, vite) we don't have any.
114
- - ❌ `.env` files — read env in `src/lib/config.ts` from `import.meta.env` /
120
+ - ❌ Extra build tool configs use `vite.config.ts` with `mado()` when needed.
121
+ - ❌ `.env` files — read env in `src/shared/lib/config.ts` from `import.meta.env` /
115
122
  `process.env` and import that one module everywhere.
116
123
  - ❌ Tests mixed with code — put them in `test/`.
117
- - ❌ `examples/` folder — the framework repository has examples, your app
118
- does not need one.
124
+ - ❌ `examples/` folder — keep large demos outside the app repo.
@@ -40,7 +40,7 @@ The `npm run bake` command traverses all `page` entries with `bake`, generates H
40
40
  ## Example
41
41
 
42
42
  ```ts
43
- // src/pages/product.ts
43
+ // src/modules/<module>/pages/product.ts
44
44
  import { page, component, html } from "@madojs/mado";
45
45
  import { findProduct, products, type Product } from "../lib/products.js";
46
46
 
@@ -84,7 +84,7 @@ export default page<{ slug: string }, Product | undefined>({
84
84
  ```
85
85
 
86
86
  ```ts
87
- // src/routes.ts
87
+ // src/app.routes.ts
88
88
  import { routes, type RoutesMap } from "@madojs/mado";
89
89
 
90
90
  // Export BOTH default (RouterApi for runtime) AND manifest (for the bake script).
@@ -100,8 +100,7 @@ export default routes(manifest, { titleSuffix: " · MyShop" });
100
100
  ## Running
101
101
 
102
102
  ```bash
103
- npm install -D linkedom esbuild
104
- npm run build
103
+ npm install -D linkedom vite
105
104
  npm run bake
106
105
  ```
107
106
 
@@ -144,7 +143,7 @@ out/
144
143
  {"slug":"mado-mug","name":"Mado Mug","price":12,"..."}
145
144
  </script>
146
145
 
147
- <script type="module" src="/dist/examples/main.js"></script>
146
+ <script type="module" src="/assets/index-HASH.js"></script>
148
147
  </body>
149
148
  ```
150
149
 
@@ -174,7 +173,7 @@ export const allPosts = () =>
174
173
  ```
175
174
 
176
175
  ```ts
177
- // src/pages/blog-post.ts
176
+ // src/modules/<module>/pages/blog-post.ts
178
177
  import { page, html } from "@madojs/mado";
179
178
  import { allPosts } from "../lib/posts.js";
180
179