create-fluixi 0.1.0-alpha.9 → 1.0.0-alpha.99
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/LICENSE +1 -1
- package/README.md +7 -3
- package/dist/index.js +887 -140
- package/package.json +19 -2
- package/template-spa/README.md +16 -0
- package/template-spa/_gitignore +1 -0
- package/template-spa/fluixi.config.ts +18 -0
- package/template-spa/index.html +3 -3
- package/template-spa/package.json +15 -7
- package/template-spa/src/app.tsx +30 -7
- package/template-spa/src/entry-client.tsx +8 -0
- package/template-spa/src/entry-server.ts +22 -0
- package/template-spa/src/routes/about.tsx +8 -0
- package/template-spa/src/routes/index.tsx +24 -0
- package/template-spa/tsconfig.json +2 -2
- package/template-spa-html/README.md +19 -0
- package/template-spa-html/_gitignore +1 -0
- package/template-spa-html/fluixi.config.ts +18 -0
- package/template-spa-html/index.html +3 -3
- package/template-spa-html/package.json +15 -6
- package/template-spa-html/src/app.ts +28 -7
- package/template-spa-html/src/entry-client.ts +8 -0
- package/template-spa-html/src/entry-server.ts +22 -0
- package/template-spa-html/src/routes/about.ts +10 -0
- package/template-spa-html/src/routes/index.ts +24 -0
- package/template-spa-html/tsconfig.json +2 -2
- package/template-ssr/_gitignore +1 -0
- package/template-ssr/fluixi.config.ts +3 -3
- package/template-ssr/package.json +9 -4
- package/template-ssr/src/app.tsx +5 -5
- package/template-ssr/src/entry-client.tsx +2 -2
- package/template-ssr/src/entry-server.ts +7 -2
- package/template-ssr/src/routes/index.tsx +2 -3
- package/template-ssr-html/_gitignore +1 -0
- package/template-ssr-html/fluixi.config.ts +3 -3
- package/template-ssr-html/package.json +10 -4
- package/template-ssr-html/src/app.ts +4 -4
- package/template-ssr-html/src/entry-client.ts +2 -2
- package/template-ssr-html/src/entry-server.ts +7 -2
- package/template-ssr-html/src/routes/index.ts +2 -3
- package/template-spa/src/main.tsx +0 -5
- package/template-spa/vite.config.ts +0 -13
- package/template-spa-html/src/main.ts +0 -5
- package/template-spa-html/vite.config.ts +0 -13
|
@@ -10,15 +10,21 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fluixi/cli": "alpha",
|
|
13
|
-
"@fluixi/start": "alpha",
|
|
14
13
|
"@fluixi/core": "alpha",
|
|
15
|
-
"@fluixi/
|
|
14
|
+
"@fluixi/di": "alpha",
|
|
15
|
+
"@fluixi/dom": "alpha",
|
|
16
|
+
"@fluixi/head": "alpha",
|
|
17
|
+
"@fluixi/jsx": "alpha",
|
|
16
18
|
"@fluixi/reactive": "alpha",
|
|
17
|
-
"@fluixi/
|
|
19
|
+
"@fluixi/router": "alpha",
|
|
20
|
+
"@fluixi/server": "alpha",
|
|
21
|
+
"@fluixi/start": "alpha",
|
|
22
|
+
"@fluixi/storage": "alpha"
|
|
18
23
|
},
|
|
19
24
|
"devDependencies": {
|
|
20
25
|
"@fluixi/ts-plugin": "alpha",
|
|
21
26
|
"@types/node": "^20.0.0",
|
|
22
|
-
"
|
|
27
|
+
"typescript": "^7.0.2",
|
|
28
|
+
"vite": "^8.3.2"
|
|
23
29
|
}
|
|
24
30
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Router, Outlet, createMemoryHistory } from '@fluixi/start/router';
|
|
1
|
+
import { Router, Outlet, createMemoryHistory, Link } from '@fluixi/start/router';
|
|
2
2
|
import { Suspense } from '@fluixi/core';
|
|
3
3
|
import { html } from '@fluixi/start';
|
|
4
4
|
import { routes } from '@fluixi/core/routes';
|
|
5
5
|
|
|
6
6
|
// Shell layout around the routed page. File-routes (src/routes/*) are lazy, so the
|
|
7
|
-
// <Outlet/> sits under <Suspense
|
|
7
|
+
// <Outlet/> sits under <Suspense>: async SSR resolves their content server-side.
|
|
8
8
|
// Components are interpolated as `<${Comp}/>` so TypeScript sees them referenced.
|
|
9
9
|
function RootLayout() {
|
|
10
10
|
return html`
|
|
11
11
|
<div class="app">
|
|
12
12
|
<nav>
|
|
13
|
-
|
|
13
|
+
<${Link} href="/">home<//> · <${Link} href="/about">about<//>
|
|
14
14
|
</nav>
|
|
15
15
|
<main>
|
|
16
16
|
<${Suspense} fallback=${html`<p>loading…</p>`}>
|
|
@@ -21,7 +21,7 @@ function RootLayout() {
|
|
|
21
21
|
`;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
// Exported so entry-client can hand it to startClient
|
|
24
|
+
// Exported so entry-client can hand it to startClient, it preloads the current route's
|
|
25
25
|
// lazy chunk before hydrating, so the server-rendered DOM is adopted in place (flash-free).
|
|
26
26
|
export const appRoutes = [{ path: '/', component: RootLayout, children: routes as any }];
|
|
27
27
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// Client entry
|
|
1
|
+
// Client entry: hydrates the server-rendered markup. The app HTML is injected into
|
|
2
2
|
// `#root` (the @fluixi/start mountId), so hydrate that container.
|
|
3
3
|
import { startClient } from '@fluixi/core/client';
|
|
4
4
|
import App, { appRoutes } from './app.js';
|
|
5
5
|
|
|
6
6
|
// Passing the route tree lets startClient preload the matched route's lazy chunk before
|
|
7
|
-
// hydrating
|
|
7
|
+
// hydrating: the lazy file-route then resolves synchronously and adopts the server DOM in
|
|
8
8
|
// place (no first-paint flash, no duplicate). It also enables auto-hydration of the
|
|
9
9
|
// server-rendered root.
|
|
10
10
|
startClient(App, { root: '#root', routes: appRoutes });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SSR entry
|
|
1
|
+
// SSR entry: @fluixi/start's dev/build/start load this. It calls `renderStream`
|
|
2
2
|
// (streaming: head flushed first, body streamed) when present, else `render` (string).
|
|
3
3
|
import App from './app.js';
|
|
4
4
|
import { renderRequestAsync, renderToBodyStream } from '@fluixi/server';
|
|
@@ -11,7 +11,12 @@ export function renderStream(url: string): ReadableStream<Uint8Array> {
|
|
|
11
11
|
return renderToBodyStream(App, { url });
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
// Server-function RPC dispatch
|
|
14
|
+
// Server-function RPC dispatch: re-exported so the dispatcher shares the registry that
|
|
15
15
|
// this app's `"use server"` modules populate. @fluixi/start routes RPC calls here.
|
|
16
16
|
import '@fluixi/start/server-fns'; // registers every "use server" module (incl. lazy routes)
|
|
17
17
|
export { isServerFnRequest, handleServerFn } from '@fluixi/start/server-fn';
|
|
18
|
+
|
|
19
|
+
// File-based API routes under src/api. The dev server dispatches to them itself; a built
|
|
20
|
+
// server finds them through this, and without it every /api request would fall through
|
|
21
|
+
// to the page renderer. Harmless when there are no routes.
|
|
22
|
+
export { isApiRequest, handleApiRequest } from '@fluixi/start/api-routes';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createResource } from '@fluixi/reactive/signal';
|
|
2
1
|
import { seo } from '@fluixi/start/head';
|
|
3
2
|
import { html } from '@fluixi/start';
|
|
4
3
|
|
|
@@ -7,9 +6,9 @@ const tick = <T,>(v: T, ms = 30) => new Promise<T>((r) => setTimeout(() => r(v),
|
|
|
7
6
|
// A data-gated route, like a real page: the resource is awaited during SSR so the
|
|
8
7
|
// content (not the spinner) is server-rendered, then hydrated.
|
|
9
8
|
export default function Home() {
|
|
10
|
-
const
|
|
9
|
+
const data = $resource(() => tick('Hello from Fluixi Start 👋'));
|
|
11
10
|
|
|
12
|
-
// Per-route document head
|
|
11
|
+
// Per-route document head: rendered into <head> on the server (great for crawlers/links)
|
|
13
12
|
// and kept reactive on the client. seo() is optional; call it where you want metadata.
|
|
14
13
|
seo({
|
|
15
14
|
title: 'Fluixi Start',
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import { fluixi } from '@fluixi/vite-plugin';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
plugins: [
|
|
6
|
-
fluixi({
|
|
7
|
-
// Where a capitalised tag with no import in scope comes from. One pattern covers
|
|
8
|
-
// the whole folder, so a new component needs no config — `fluixi g component Card`
|
|
9
|
-
// and `<Card />` just works. Delete this if you'd rather import every component.
|
|
10
|
-
resolve: [{ match: /^([A-Z]\w+)$/, module: '/src/components/$1.tsx' }],
|
|
11
|
-
}),
|
|
12
|
-
],
|
|
13
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import { fluixi } from '@fluixi/vite-plugin';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
plugins: [
|
|
6
|
-
fluixi({
|
|
7
|
-
// Where a capitalised tag with no import in scope comes from. One pattern covers
|
|
8
|
-
// the whole folder, so a new component needs no config — `fluixi g component Card`
|
|
9
|
-
// and `<Card />` just works. Delete this if you'd rather import every component.
|
|
10
|
-
resolve: [{ match: /^([A-Z]\w+)$/, module: '/src/components/$1.ts' }],
|
|
11
|
-
}),
|
|
12
|
-
],
|
|
13
|
-
});
|