resuxjs 0.1.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.
- package/README.md +442 -0
- package/dist/compiler/index.d.ts +106 -0
- package/dist/compiler/index.js +1599 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/create.d.ts +2 -0
- package/dist/create.js +283 -0
- package/dist/create.js.map +1 -0
- package/dist/globals.d.ts +43 -0
- package/dist/globals.js +2 -0
- package/dist/globals.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1314 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/index.d.ts +304 -0
- package/dist/runtime/index.js +2291 -0
- package/dist/runtime/index.js.map +1 -0
- package/package.json +71 -0
- package/templates/default/.dockerignore +7 -0
- package/templates/default/.resux-nitro/handler.ts +4 -0
- package/templates/default/DEPLOYMENT.md +42 -0
- package/templates/default/Dockerfile +15 -0
- package/templates/default/README.md +14 -0
- package/templates/default/_gitignore +6 -0
- package/templates/default/app.vue +5 -0
- package/templates/default/env.d.ts +1 -0
- package/templates/default/error.vue +18 -0
- package/templates/default/islands/vue/CounterIsland.vue +16 -0
- package/templates/default/layouts/default.vue +12 -0
- package/templates/default/nitro.config.ts +51 -0
- package/templates/default/pages/about.vue +14 -0
- package/templates/default/pages/index.vue +60 -0
- package/templates/default/public/styles.css +220 -0
- package/templates/default/resux.config.ts +23 -0
- package/templates/default/server/api/status.ts +5 -0
- package/templates/default/tsconfig.json +16 -0
package/README.md
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# Resux
|
|
2
|
+
|
|
3
|
+
Resux is an experimental web framework prototype 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
|
+
This is an MVP, not a production-ready framework.
|
|
8
|
+
|
|
9
|
+
## Create App
|
|
10
|
+
|
|
11
|
+
Resux is published as one npm package. After publishing, users can scaffold an app with the same package they install in the app:
|
|
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": "^0.1.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For local development before publishing:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm install
|
|
43
|
+
npm run build
|
|
44
|
+
npm run create:local -- my-app --no-install
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then run the generated app:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
cd my-app
|
|
51
|
+
npm install
|
|
52
|
+
npm run dev
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Package Layout
|
|
56
|
+
|
|
57
|
+
```txt
|
|
58
|
+
src/
|
|
59
|
+
compiler/ SFC parser, route manifest builder, code generator
|
|
60
|
+
runtime/ SSR renderer, composables, client resume loader source
|
|
61
|
+
index.ts Resux CLI, Node server, and public node handler
|
|
62
|
+
create.ts App scaffolder used by `resux init`
|
|
63
|
+
|
|
64
|
+
templates/ Starter files copied by `resux init`
|
|
65
|
+
tests/ Compiler, SSR, and client resume tests
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Development
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
npm install
|
|
72
|
+
npm run build
|
|
73
|
+
npm test
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Run the full publish-readiness check:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
npm run pack:check
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This builds, tests, and dry-runs npm packing for the single `resuxjs` package.
|
|
83
|
+
|
|
84
|
+
## Publishing
|
|
85
|
+
|
|
86
|
+
Publish the single package:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
npm publish --access public
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
After `resuxjs` is published, users can run `npx resuxjs@latest init`.
|
|
93
|
+
|
|
94
|
+
## Compatibility Policy
|
|
95
|
+
|
|
96
|
+
Resux follows npm semver starting with the `0.1.x` release line.
|
|
97
|
+
|
|
98
|
+
- Patch releases, such as `0.1.1`, preserve compatibility for documented APIs, generated starter structure, CLI commands, config keys, file-based routing conventions, and runtime payload formats.
|
|
99
|
+
- Minor releases before `1.0.0`, such as `0.2.0`, may include breaking changes, but they must be documented in release notes and migration guidance before publishing.
|
|
100
|
+
- Experimental or undocumented internals, including generated files under `.resux`, may change between releases unless they are explicitly documented as public API.
|
|
101
|
+
|
|
102
|
+
## CLI
|
|
103
|
+
|
|
104
|
+
The `resux` CLI supports:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
resux init <project-dir>
|
|
108
|
+
resux dev <app-root>
|
|
109
|
+
resux build <app-root>
|
|
110
|
+
resux preview <app-root>
|
|
111
|
+
resux start <app-root>
|
|
112
|
+
resux inspect <app-root>
|
|
113
|
+
resux deploy <app-root>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
If `<app-root>` is omitted, Resux uses the current directory.
|
|
117
|
+
|
|
118
|
+
Useful server flags:
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
resux dev --port 4000
|
|
122
|
+
resux preview --host 0.0.0.0 --port 4000
|
|
123
|
+
resux start --host 0.0.0.0 --port 3000
|
|
124
|
+
resux inspect
|
|
125
|
+
resux inspect --json
|
|
126
|
+
resux deploy . --preset docker
|
|
127
|
+
resux deploy . --preset nitro
|
|
128
|
+
resux --help
|
|
129
|
+
resux --version
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Build output is written to:
|
|
133
|
+
|
|
134
|
+
```txt
|
|
135
|
+
<app-root>/.resux
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## App Types
|
|
139
|
+
|
|
140
|
+
Generated apps include `env.d.ts` and `tsconfig.json` wired to `resuxjs/globals`, so app files can use the Resux-style globals without imports:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
const count = useState("count", () => 0)
|
|
144
|
+
const route = useRoute()
|
|
145
|
+
useSeoMeta({
|
|
146
|
+
title: "My App",
|
|
147
|
+
description: "My app description",
|
|
148
|
+
ogTitle: "My App"
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
export default defineResuxConfig({
|
|
152
|
+
app: {
|
|
153
|
+
head: {
|
|
154
|
+
title: "My App"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Vite
|
|
161
|
+
|
|
162
|
+
Resux uses Vite in both main app commands:
|
|
163
|
+
|
|
164
|
+
- `resux dev` emits Resux client modules into `.resux/vite-client` and serves the resume runtime plus handler modules through Vite middleware.
|
|
165
|
+
- `resux dev` also opens a dev-only update channel at `/__resux/dev-events`; when source files change, Resux rebuilds, re-imports active client component modules with a cache-busting revision, and patches active resumable scopes without a full document reload.
|
|
166
|
+
- `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`.
|
|
167
|
+
|
|
168
|
+
The generated starter keeps Resux-style scripts:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"scripts": {
|
|
173
|
+
"dev": "resux dev .",
|
|
174
|
+
"build": "resux build .",
|
|
175
|
+
"preview": "resux preview .",
|
|
176
|
+
"start": "resux start .",
|
|
177
|
+
"inspect": "resux inspect ."
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Deployment
|
|
183
|
+
|
|
184
|
+
Build and serve with the Node server:
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
npm run build
|
|
188
|
+
npm run start
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
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:
|
|
192
|
+
|
|
193
|
+
```sh
|
|
194
|
+
resux start . --no-security-headers
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
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.
|
|
198
|
+
|
|
199
|
+
Existing apps can generate or refresh deployment files without changing application code:
|
|
200
|
+
|
|
201
|
+
```sh
|
|
202
|
+
resux deploy . --preset node
|
|
203
|
+
resux deploy . --preset docker --force
|
|
204
|
+
resux deploy . --preset nitro --force
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The Nitro preset writes `nitro.config.ts` and a small `.resux-nitro/handler.ts` adapter. Build Resux first, then let Nitro produce provider-specific output:
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
npm run build
|
|
211
|
+
npx nitro build
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
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.
|
|
215
|
+
|
|
216
|
+
Production and dev servers expose a health endpoint for hosts and uptime checks:
|
|
217
|
+
|
|
218
|
+
```txt
|
|
219
|
+
/__resux/health
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Modules And Route Rules
|
|
223
|
+
|
|
224
|
+
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:
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
export default defineResuxConfig({
|
|
228
|
+
modules: [
|
|
229
|
+
["resux:seo", {
|
|
230
|
+
title: "My App",
|
|
231
|
+
description: "A Resux application.",
|
|
232
|
+
themeColor: "#2563eb"
|
|
233
|
+
}],
|
|
234
|
+
"resux:security",
|
|
235
|
+
["resux:performance", { assetMaxAge: 31536000 }],
|
|
236
|
+
["./modules/security.ts", { header: "enabled" }]
|
|
237
|
+
],
|
|
238
|
+
routeRules: {
|
|
239
|
+
"/old": { redirect: { to: "/", statusCode: 301 } },
|
|
240
|
+
"/admin/**": { headers: { "x-robots-tag": "noindex" } }
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Built-in modules:
|
|
246
|
+
|
|
247
|
+
- `resux:seo`: adds title, description, Open Graph, Twitter card, theme color, and optional link tags.
|
|
248
|
+
- `resux:security`: adds default production hardening headers and optional custom headers or CSP through route rules.
|
|
249
|
+
- `resux:performance`: adds immutable cache rules for built Resux runtime/handler assets and `no-store` for route payloads.
|
|
250
|
+
|
|
251
|
+
Modules can be built-in `resux:*` specifiers, npm package specifiers, local files, inline functions, or objects returned by `defineResuxModule`.
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
// modules/security.ts
|
|
255
|
+
export default defineResuxModule({
|
|
256
|
+
defaults: { header: "enabled" },
|
|
257
|
+
setup(options, resux) {
|
|
258
|
+
resux.addCss("/module.css")
|
|
259
|
+
resux.addHead({ meta: [{ name: "module", content: options.header }] })
|
|
260
|
+
resux.addRouteRule("/secure/**", {
|
|
261
|
+
headers: { "x-module": options.header },
|
|
262
|
+
cache: { maxAge: 60, swr: 30 }
|
|
263
|
+
})
|
|
264
|
+
resux.extendRuntimeConfig({
|
|
265
|
+
public: { securityModule: options.header }
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The module API includes `addCss`, `addHead`, `addRouteRule`, and `extendRuntimeConfig`. Route rules currently support redirects, response headers, status codes, cache headers, and CORS headers.
|
|
272
|
+
|
|
273
|
+
## Server Middleware
|
|
274
|
+
|
|
275
|
+
Files in `server/middleware` run for each request before server handlers, public files, and page rendering:
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
export default defineServerMiddleware((event) => {
|
|
279
|
+
event.node.res.setHeader("x-app", "resux")
|
|
280
|
+
|
|
281
|
+
if (event.path.startsWith("/private")) {
|
|
282
|
+
return { type: "redirect", to: "/login", statusCode: 302 }
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Server middleware can continue by returning nothing, end the Node response directly, return a `Response`, return a JSON-serializable value, return `false` to send `403`, or return a redirect/abort object.
|
|
288
|
+
|
|
289
|
+
## What Works
|
|
290
|
+
|
|
291
|
+
- `.vue`-style SFC files with `<template>` and `<script setup lang="ts">`.
|
|
292
|
+
- File-based routing from `pages/`.
|
|
293
|
+
- Dynamic route params like `pages/post/[id].vue`.
|
|
294
|
+
- `app.vue` with `<ResuxPage />`.
|
|
295
|
+
- Layouts with `<ResuxLayout>`, `<slot />`, and `definePageMeta({ layout })`.
|
|
296
|
+
- `<ResuxLink to="...">` rendered as an `<a href="...">` and intercepted for client-side navigation.
|
|
297
|
+
- Static and dynamic component props with `defineProps()`.
|
|
298
|
+
- Server-side rendering.
|
|
299
|
+
- Head/meta rendering from `resux.config.ts`, `definePageMeta`, `useHead`, and `useSeoMeta`.
|
|
300
|
+
- Route middleware from `middleware/`, including `.global` middleware.
|
|
301
|
+
- Request-time server middleware from `server/middleware`.
|
|
302
|
+
- Plugins from `plugins/` with `defineResuxPlugin`.
|
|
303
|
+
- Server API/routes from `server/api` and `server/routes`.
|
|
304
|
+
- Server handler helpers: `readBody(event)` and `getQuery(event)`.
|
|
305
|
+
- `error.vue` for custom 404/500 rendering.
|
|
306
|
+
- Public file serving from `public/`.
|
|
307
|
+
- Built-in health checks at `/__resux/health`.
|
|
308
|
+
- Basic `resux.config.ts` support for `runtimeConfig`, `app.head`, and `css`.
|
|
309
|
+
- Built-in and package/local Resux modules for extending CSS, head, route rules, and runtime config during build.
|
|
310
|
+
- Route rules for redirects, response headers, status codes, cache headers, and CORS headers.
|
|
311
|
+
- Default production security headers with an opt-out flag.
|
|
312
|
+
- Vite-powered dev serving, production client/server bundling, and minification for the resume runtime and handler chunks.
|
|
313
|
+
- Component-level dev hot updates after successful rebuilds, without adding Vue hydration.
|
|
314
|
+
- `resux inspect` and `resux inspect --json` for route and build diagnostics.
|
|
315
|
+
- `resux deploy --preset node|docker|nitro` for deployment file generation.
|
|
316
|
+
- Serialized route, state, and async data payloads.
|
|
317
|
+
- Resumable event handlers such as `@click="increment"`.
|
|
318
|
+
- Lazy client handler chunks loaded on first interaction.
|
|
319
|
+
- Client-side navigation, persistent same-layout DOM, built-in route transition progress, and hover/focus route payload prefetch for same-origin links.
|
|
320
|
+
- MVP composables: `useState`, `useAsyncData`, `useRoute`, `useHead`, `useSeoMeta`, `useRuntimeConfig`, `useResuxApp`, `useFetch`, `$fetch`, and `onMounted`.
|
|
321
|
+
- `useAsyncData` returns a resource with `value`, `pending`, and `error` state, and still works with `await` when you want to block setup.
|
|
322
|
+
|
|
323
|
+
## Component Syntax
|
|
324
|
+
|
|
325
|
+
```vue
|
|
326
|
+
<script setup lang="ts">
|
|
327
|
+
const count = useState("count", () => 0)
|
|
328
|
+
|
|
329
|
+
function increment() {
|
|
330
|
+
count.value++
|
|
331
|
+
}
|
|
332
|
+
</script>
|
|
333
|
+
|
|
334
|
+
<template>
|
|
335
|
+
<button @click="increment">
|
|
336
|
+
Count: {{ count.value }}
|
|
337
|
+
</button>
|
|
338
|
+
</template>
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
On the server, Resux renders the button as HTML and serializes `count`.
|
|
342
|
+
|
|
343
|
+
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.
|
|
344
|
+
|
|
345
|
+
## Async Data Skeletons
|
|
346
|
+
|
|
347
|
+
For a Next-style loading skeleton, call `useAsyncData` without `await` and branch on `pending`:
|
|
348
|
+
|
|
349
|
+
```vue
|
|
350
|
+
<script setup lang="ts">
|
|
351
|
+
const stats = useAsyncData("stats", async () => {
|
|
352
|
+
await new Promise((resolve) => setTimeout(resolve, 700))
|
|
353
|
+
return { response: "14 ms" }
|
|
354
|
+
})
|
|
355
|
+
</script>
|
|
356
|
+
|
|
357
|
+
<template>
|
|
358
|
+
<div v-if="stats.pending" class="skeleton"></div>
|
|
359
|
+
<strong v-if="!stats.pending">{{ stats.value.response }}</strong>
|
|
360
|
+
</template>
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
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.
|
|
364
|
+
|
|
365
|
+
## Supported Syntax
|
|
366
|
+
|
|
367
|
+
The MVP compiler supports:
|
|
368
|
+
|
|
369
|
+
- Static elements and text.
|
|
370
|
+
- Interpolation: `{{ value }}`.
|
|
371
|
+
- Static attributes: `class="box"`.
|
|
372
|
+
- Dynamic attributes: `:class="className"`.
|
|
373
|
+
- Dynamic class arrays/objects and style objects for `:class` and `:style`.
|
|
374
|
+
- Plain named events: `@click="increment"`.
|
|
375
|
+
- Inline event expressions that only capture resumable values, such as `@click="count.value++"`.
|
|
376
|
+
- Resumability-safe event modifiers: `.prevent`, `.stop`, `.self`, `.once`, system/mouse modifiers, and key filters such as `.enter`.
|
|
377
|
+
- `v-if`.
|
|
378
|
+
- `v-show`.
|
|
379
|
+
- `v-text`.
|
|
380
|
+
- Sanitized `v-html`.
|
|
381
|
+
- Basic `v-model` for form values.
|
|
382
|
+
- Simple `v-for`, such as `item in items` or `(item, index) in items`.
|
|
383
|
+
- Component tags from `components/`.
|
|
384
|
+
- `<ResuxPage />`.
|
|
385
|
+
- `<ResuxLayout />`.
|
|
386
|
+
- `<slot />` inside layouts.
|
|
387
|
+
- `<ResuxLink to="/path">`.
|
|
388
|
+
- `defineProps()` in components.
|
|
389
|
+
- `definePageMeta({ layout, middleware, title, meta })`.
|
|
390
|
+
- `useHead({ title, meta, link })`.
|
|
391
|
+
- `useSeoMeta({ title, description, ogTitle, ogImage, twitterCard })`.
|
|
392
|
+
- `onMounted()`, run when the component scope is first resumed in the browser.
|
|
393
|
+
- Vue runtime islands via `<VueIsland name="CounterIsland" :props="{ start: 1 }" />` and files in `islands/vue`.
|
|
394
|
+
|
|
395
|
+
Handlers and inline event expressions must only capture resumable values, such as refs returned by `useState`.
|
|
396
|
+
|
|
397
|
+
## Current Limits
|
|
398
|
+
|
|
399
|
+
Resux intentionally rejects or does not support many advanced framework/Vue features yet:
|
|
400
|
+
|
|
401
|
+
- Vue runtime is island-only; Resux components still do not hydrate through Vue.
|
|
402
|
+
- Nitro support is an adapter/deployment preset, not the primary dev server.
|
|
403
|
+
- Event `.capture` and `.passive` are accepted in templates, but the browser runtime still uses delegated resumable listeners.
|
|
404
|
+
- No fallback hydration for unsupported components.
|
|
405
|
+
|
|
406
|
+
Unsupported resumability patterns should fail at compile time instead of silently hydrating.
|
|
407
|
+
|
|
408
|
+
## Architecture
|
|
409
|
+
|
|
410
|
+
Resux is one package with four internal parts:
|
|
411
|
+
|
|
412
|
+
- Compiler: parses `.vue` files, creates routes, validates resumable handlers, and emits server/client modules.
|
|
413
|
+
- Runtime: renders HTML on the server, provides Resux-style composables, runs plugins, applies layouts, collects head entries, and serializes payloads.
|
|
414
|
+
- CLI: builds apps, starts the dev server, and previews generated output.
|
|
415
|
+
- Create CLI: scaffolds a starter app for `resux init`.
|
|
416
|
+
|
|
417
|
+
The browser initially receives only server-rendered HTML, the serialized payload, and the small resume loader.
|
|
418
|
+
|
|
419
|
+
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.
|
|
420
|
+
|
|
421
|
+
## Testing
|
|
422
|
+
|
|
423
|
+
Run:
|
|
424
|
+
|
|
425
|
+
```sh
|
|
426
|
+
npm test
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
The tests cover:
|
|
430
|
+
|
|
431
|
+
- Route generation.
|
|
432
|
+
- SFC compiler output.
|
|
433
|
+
- Compile errors for unsupported resumability captures.
|
|
434
|
+
- Sanitized `v-html`, `v-model`, inline handlers, and mounted resume hooks.
|
|
435
|
+
- SSR payload serialization.
|
|
436
|
+
- Dynamic route params.
|
|
437
|
+
- Layout rendering.
|
|
438
|
+
- Head/meta rendering.
|
|
439
|
+
- Runtime config and plugin provides.
|
|
440
|
+
- Project discovery for layouts, middleware, server middleware, plugins, API routes, and config.
|
|
441
|
+
- Extended route-rule serialization.
|
|
442
|
+
- Client resume behavior after interaction.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type PageMeta, type TemplateNode } from "../runtime/index.js";
|
|
2
|
+
export interface CompileErrorLocation {
|
|
3
|
+
file: string;
|
|
4
|
+
line: number;
|
|
5
|
+
column: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class ResuxCompileError extends Error {
|
|
8
|
+
readonly location?: CompileErrorLocation;
|
|
9
|
+
constructor(message: string, location?: CompileErrorLocation);
|
|
10
|
+
}
|
|
11
|
+
export interface CompiledComponent {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
file: string;
|
|
15
|
+
serverSource: string;
|
|
16
|
+
clientSource: string;
|
|
17
|
+
template: TemplateNode[];
|
|
18
|
+
handlers: string[];
|
|
19
|
+
meta?: PageMeta;
|
|
20
|
+
}
|
|
21
|
+
export interface RouteManifestRecord {
|
|
22
|
+
id: string;
|
|
23
|
+
path: string;
|
|
24
|
+
file: string;
|
|
25
|
+
params: string[];
|
|
26
|
+
componentId: string;
|
|
27
|
+
meta?: PageMeta;
|
|
28
|
+
}
|
|
29
|
+
export interface CompiledPlugin {
|
|
30
|
+
id: string;
|
|
31
|
+
file: string;
|
|
32
|
+
mode: "all" | "server" | "client";
|
|
33
|
+
source: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CompiledMiddleware {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
file: string;
|
|
39
|
+
global: boolean;
|
|
40
|
+
source: string;
|
|
41
|
+
}
|
|
42
|
+
export interface CompiledServerMiddleware {
|
|
43
|
+
id: string;
|
|
44
|
+
file: string;
|
|
45
|
+
source: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ServerHandlerRecord {
|
|
48
|
+
id: string;
|
|
49
|
+
path: string;
|
|
50
|
+
file: string;
|
|
51
|
+
params: string[];
|
|
52
|
+
source: string;
|
|
53
|
+
}
|
|
54
|
+
export interface VueIslandRecord {
|
|
55
|
+
name: string;
|
|
56
|
+
file: string;
|
|
57
|
+
}
|
|
58
|
+
export interface RouteRuleConfig {
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
redirect?: string | {
|
|
61
|
+
to: string;
|
|
62
|
+
statusCode?: number;
|
|
63
|
+
};
|
|
64
|
+
statusCode?: number;
|
|
65
|
+
cache?: false | string | {
|
|
66
|
+
maxAge?: number;
|
|
67
|
+
swr?: number;
|
|
68
|
+
};
|
|
69
|
+
cors?: boolean | {
|
|
70
|
+
origin?: string;
|
|
71
|
+
methods?: string[];
|
|
72
|
+
headers?: string[];
|
|
73
|
+
credentials?: boolean;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface BuildResult {
|
|
77
|
+
appRoot: string;
|
|
78
|
+
outDir: string;
|
|
79
|
+
routes: RouteManifestRecord[];
|
|
80
|
+
components: CompiledComponent[];
|
|
81
|
+
layouts: CompiledComponent[];
|
|
82
|
+
plugins: CompiledPlugin[];
|
|
83
|
+
middleware: CompiledMiddleware[];
|
|
84
|
+
serverMiddleware: CompiledServerMiddleware[];
|
|
85
|
+
serverHandlers: ServerHandlerRecord[];
|
|
86
|
+
vueIslands: VueIslandRecord[];
|
|
87
|
+
routeRules: Record<string, RouteRuleConfig>;
|
|
88
|
+
app?: CompiledComponent;
|
|
89
|
+
error?: CompiledComponent;
|
|
90
|
+
}
|
|
91
|
+
export interface BuildOptions {
|
|
92
|
+
vite?: "build" | "dev";
|
|
93
|
+
server?: "bundle" | "modules";
|
|
94
|
+
}
|
|
95
|
+
export declare function buildProject(appRoot: string, outDir?: string, options?: BuildOptions): Promise<BuildResult>;
|
|
96
|
+
export declare function compileVueFile(file: string, options: {
|
|
97
|
+
id: string;
|
|
98
|
+
name?: string;
|
|
99
|
+
}): Promise<CompiledComponent>;
|
|
100
|
+
export declare function compileVueSource(source: string, options: {
|
|
101
|
+
file: string;
|
|
102
|
+
id: string;
|
|
103
|
+
name: string;
|
|
104
|
+
}): CompiledComponent;
|
|
105
|
+
export declare function createRouteManifest(root: string, files: string[], idByFile?: Map<string, string>, compiledByFile?: Map<string, CompiledComponent>): RouteManifestRecord[];
|
|
106
|
+
export declare function fileUrl(file: string): string;
|