reroute-js 0.0.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.
- package/README.md +144 -0
- package/cli/bin.d.ts +3 -0
- package/cli/bin.d.ts.map +1 -0
- package/cli/bin.js +812 -0
- package/cli/bin.js.map +15 -0
- package/cli/src/commands/build.d.ts +8 -0
- package/cli/src/commands/build.d.ts.map +1 -0
- package/cli/src/commands/dev.d.ts +8 -0
- package/cli/src/commands/dev.d.ts.map +1 -0
- package/cli/src/commands/gen.d.ts +3 -0
- package/cli/src/commands/gen.d.ts.map +1 -0
- package/cli/src/commands/init.d.ts +8 -0
- package/cli/src/commands/init.d.ts.map +1 -0
- package/cli/src/index.d.ts +8 -0
- package/cli/src/index.d.ts.map +1 -0
- package/cli/src/libs/tailwind.d.ts +18 -0
- package/cli/src/libs/tailwind.d.ts.map +1 -0
- package/core/index.d.ts +2 -0
- package/core/index.d.ts.map +1 -0
- package/core/index.js +1174 -0
- package/core/index.js.map +25 -0
- package/core/src/bundler/hash.d.ts +2 -0
- package/core/src/bundler/hash.d.ts.map +1 -0
- package/core/src/bundler/index.d.ts +3 -0
- package/core/src/bundler/index.d.ts.map +1 -0
- package/core/src/bundler/transpile.d.ts +4 -0
- package/core/src/bundler/transpile.d.ts.map +1 -0
- package/core/src/content/builder.d.ts +2 -0
- package/core/src/content/builder.d.ts.map +1 -0
- package/core/src/content/discovery.d.ts +5 -0
- package/core/src/content/discovery.d.ts.map +1 -0
- package/core/src/content/index.d.ts +5 -0
- package/core/src/content/index.d.ts.map +1 -0
- package/core/src/content/metadata.d.ts +9 -0
- package/core/src/content/metadata.d.ts.map +1 -0
- package/core/src/content/registry.d.ts +2 -0
- package/core/src/content/registry.d.ts.map +1 -0
- package/core/src/index.d.ts +7 -0
- package/core/src/index.d.ts.map +1 -0
- package/core/src/ssr/data.d.ts +9 -0
- package/core/src/ssr/data.d.ts.map +1 -0
- package/core/src/ssr/index.d.ts +4 -0
- package/core/src/ssr/index.d.ts.map +1 -0
- package/core/src/ssr/modules.d.ts +8 -0
- package/core/src/ssr/modules.d.ts.map +1 -0
- package/core/src/ssr/render.d.ts +20 -0
- package/core/src/ssr/render.d.ts.map +1 -0
- package/core/src/ssr/seed.d.ts +2 -0
- package/core/src/ssr/seed.d.ts.map +1 -0
- package/core/src/template/html.d.ts +4 -0
- package/core/src/template/html.d.ts.map +1 -0
- package/core/src/template/index.d.ts +2 -0
- package/core/src/template/index.d.ts.map +1 -0
- package/core/src/types.d.ts +50 -0
- package/core/src/types.d.ts.map +1 -0
- package/core/src/utils/cache.d.ts +12 -0
- package/core/src/utils/cache.d.ts.map +1 -0
- package/core/src/utils/compression.d.ts +5 -0
- package/core/src/utils/compression.d.ts.map +1 -0
- package/core/src/utils/index.d.ts +5 -0
- package/core/src/utils/index.d.ts.map +1 -0
- package/core/src/utils/mime.d.ts +3 -0
- package/core/src/utils/mime.d.ts.map +1 -0
- package/core/src/utils/path.d.ts +6 -0
- package/core/src/utils/path.d.ts.map +1 -0
- package/elysia/index.d.ts +2 -0
- package/elysia/index.d.ts.map +1 -0
- package/elysia/index.js +1829 -0
- package/elysia/index.js.map +32 -0
- package/elysia/src/index.d.ts +3 -0
- package/elysia/src/index.d.ts.map +1 -0
- package/elysia/src/plugin.d.ts +32 -0
- package/elysia/src/plugin.d.ts.map +1 -0
- package/elysia/src/routes/artifacts.d.ts +3 -0
- package/elysia/src/routes/artifacts.d.ts.map +1 -0
- package/elysia/src/routes/content.d.ts +3 -0
- package/elysia/src/routes/content.d.ts.map +1 -0
- package/elysia/src/routes/dev.d.ts +7 -0
- package/elysia/src/routes/dev.d.ts.map +1 -0
- package/elysia/src/routes/ssr.d.ts +18 -0
- package/elysia/src/routes/ssr.d.ts.map +1 -0
- package/elysia/src/routes/static.d.ts +19 -0
- package/elysia/src/routes/static.d.ts.map +1 -0
- package/elysia/src/types.d.ts +31 -0
- package/elysia/src/types.d.ts.map +1 -0
- package/elysia/src/utils/http.d.ts +5 -0
- package/elysia/src/utils/http.d.ts.map +1 -0
- package/package.json +74 -0
- package/react/index.d.ts +2 -0
- package/react/index.d.ts.map +1 -0
- package/react/index.js +1152 -0
- package/react/index.js.map +23 -0
- package/react/src/components/ContentRoute.d.ts +13 -0
- package/react/src/components/ContentRoute.d.ts.map +1 -0
- package/react/src/components/Link.d.ts +8 -0
- package/react/src/components/Link.d.ts.map +1 -0
- package/react/src/components/Outlet.d.ts +7 -0
- package/react/src/components/Outlet.d.ts.map +1 -0
- package/react/src/components/index.d.ts +4 -0
- package/react/src/components/index.d.ts.map +1 -0
- package/react/src/hooks/index.d.ts +7 -0
- package/react/src/hooks/index.d.ts.map +1 -0
- package/react/src/hooks/useContent.d.ts +26 -0
- package/react/src/hooks/useContent.d.ts.map +1 -0
- package/react/src/hooks/useData.d.ts +10 -0
- package/react/src/hooks/useData.d.ts.map +1 -0
- package/react/src/hooks/useNavigate.d.ts +6 -0
- package/react/src/hooks/useNavigate.d.ts.map +1 -0
- package/react/src/hooks/useParams.d.ts +6 -0
- package/react/src/hooks/useParams.d.ts.map +1 -0
- package/react/src/hooks/useRouter.d.ts +7 -0
- package/react/src/hooks/useRouter.d.ts.map +1 -0
- package/react/src/hooks/useSearchParams.d.ts +6 -0
- package/react/src/hooks/useSearchParams.d.ts.map +1 -0
- package/react/src/index.d.ts +6 -0
- package/react/src/index.d.ts.map +1 -0
- package/react/src/providers/ContentProvider.d.ts +35 -0
- package/react/src/providers/ContentProvider.d.ts.map +1 -0
- package/react/src/providers/RerouteProvider.d.ts +25 -0
- package/react/src/providers/RerouteProvider.d.ts.map +1 -0
- package/react/src/providers/RouterProvider.d.ts +23 -0
- package/react/src/providers/RouterProvider.d.ts.map +1 -0
- package/react/src/providers/index.d.ts +4 -0
- package/react/src/providers/index.d.ts.map +1 -0
- package/react/src/types/any.d.ts +3 -0
- package/react/src/types/any.d.ts.map +1 -0
- package/react/src/types/index.d.ts +3 -0
- package/react/src/types/index.d.ts.map +1 -0
- package/react/src/types/router.d.ts +32 -0
- package/react/src/types/router.d.ts.map +1 -0
- package/react/src/utils/content.d.ts +8 -0
- package/react/src/utils/content.d.ts.map +1 -0
- package/react/src/utils/head.d.ts +6 -0
- package/react/src/utils/head.d.ts.map +1 -0
- package/react/src/utils/index.d.ts +3 -0
- package/react/src/utils/index.d.ts.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Reroute
|
|
2
|
+
|
|
3
|
+
A dead simple file-based routing framework for building fullstack React apps on Bun and Elysia. No extra dependencies are required.
|
|
4
|
+
|
|
5
|
+
## β¨ Features
|
|
6
|
+
|
|
7
|
+
### π― Core Framework
|
|
8
|
+
- β‘ **Built on Bun** - Lightning-fast JavaScript runtime for everything
|
|
9
|
+
- π **File-Based Routing** - Automatic route generation from your file structure
|
|
10
|
+
- π¨ **Server-Side Rendering (SSR)** - SEO-friendly React rendering on the server
|
|
11
|
+
- π₯ **Live Reload** - Live reload in development mode with instant feedback
|
|
12
|
+
- π¦ **Zero Config** - Works out of the box with sensible defaults
|
|
13
|
+
|
|
14
|
+
### π οΈ CLI Tools
|
|
15
|
+
- π **`reroute init`** - Scaffold new projects with templates (basic, blog)
|
|
16
|
+
- π¨ **`reroute gen`** - Generate content registry and route artifacts
|
|
17
|
+
|
|
18
|
+
### π Content Management
|
|
19
|
+
- π **Content Collections** - Organize content by collections (blog posts, docs, etc.)
|
|
20
|
+
- π **Content Discovery** - Automatic scanning and indexing of content files
|
|
21
|
+
- π·οΈ **Metadata Extraction** - Support for content metadata
|
|
22
|
+
- π **Content Registry** - Pre-generated content index for fast lookups
|
|
23
|
+
- π― **Dynamic Imports** - Code-split content chunks for optimal loading
|
|
24
|
+
- π¦ **Collection Chunking** - Individual module bundles per content item
|
|
25
|
+
|
|
26
|
+
### βοΈ React Integration
|
|
27
|
+
- πͺ **Router Hooks**:
|
|
28
|
+
- `useNavigate()` - Programmatic navigation
|
|
29
|
+
- `useParams()` - Access route parameters
|
|
30
|
+
- `useSearchParams()` - Query string manipulation
|
|
31
|
+
- `useRouter()` - Access router state and utilities
|
|
32
|
+
- π **Content Hooks**:
|
|
33
|
+
- `useContent()` - Load and manage content collections with sorting
|
|
34
|
+
- π§© **Components**:
|
|
35
|
+
- `<Link>` - Client-side navigation with automatic prefetching
|
|
36
|
+
- `<Outlet>` - Render nested route components
|
|
37
|
+
- `<ContentRoute>` - Dynamic content rendering with metadata injection
|
|
38
|
+
- π **Providers**:
|
|
39
|
+
- `<RouterProvider>` - Router context for the app
|
|
40
|
+
- `<ContentProvider>` - Content system context
|
|
41
|
+
- `<RerouteProvider>` - All-in-one provider wrapper
|
|
42
|
+
- ποΈ **SSR Data**:
|
|
43
|
+
- `useData()` - Read route-level SSR data without loaders
|
|
44
|
+
- `export const ssr = { data() {} }` - Route data function executed on server
|
|
45
|
+
|
|
46
|
+
### π Performance Optimizations
|
|
47
|
+
- πΎ **Smart Caching** - LRU cache for files and bundles
|
|
48
|
+
- π **Link Prefetching** - Automatic content prefetching on hover/focus
|
|
49
|
+
- π¦ **Bundle Hashing** - Content-based hashing for optimal cache invalidation
|
|
50
|
+
- β‘ **Module Preloading** - Browser hints for critical resources
|
|
51
|
+
- π― **SSR Module Seeding** - Pre-populate modules for instant hydration
|
|
52
|
+
- π **Collection Inlining** - Inline collection data for zero-latency rendering
|
|
53
|
+
|
|
54
|
+
### π¨ Developer Experience
|
|
55
|
+
- π **Project Templates** - Quick start with `basic` or `blog` templates
|
|
56
|
+
- π **Live Reload** - Server-Sent Events (SSE) for instant browser updates
|
|
57
|
+
- π― **TypeScript Support** - Full type safety throughout the stack
|
|
58
|
+
- ποΈ **File System Watcher** - Automatic rebuilds on source changes
|
|
59
|
+
- πͺ **404 Handling** - Custom NotFound routes with pattern matching
|
|
60
|
+
- ποΈ **Layout System** - Shared layouts across route groups
|
|
61
|
+
|
|
62
|
+
### π Server Features (Elysia Plugin)
|
|
63
|
+
- π **Elysia Plugin** - Drop-in plugin for Elysia apps
|
|
64
|
+
- π¨ **SSR Routes** - Server-rendered React pages
|
|
65
|
+
- π **Static File Serving** - Optimized bundle delivery
|
|
66
|
+
- π **Content API Routes** - Dynamic content endpoints
|
|
67
|
+
- π οΈ **Dev Mode Routes** - Development tooling and live reload
|
|
68
|
+
- π¦ **Artifact Routes** - Serve generated content chunks and registry
|
|
69
|
+
|
|
70
|
+
### π― Build System
|
|
71
|
+
- π§ **Transpilation** - TypeScript/JSX to optimized JavaScript
|
|
72
|
+
- ποΈ **Minification** - Optional code minification for production
|
|
73
|
+
- πΊοΈ **Source Maps** - Debug support with source map generation
|
|
74
|
+
- π¦ **Module Bundling** - Efficient code splitting and bundling
|
|
75
|
+
- π― **Tree Shaking** - Remove unused code automatically
|
|
76
|
+
|
|
77
|
+
### π¨ Head Management
|
|
78
|
+
- π·οΈ **Meta Tags** - Automatic meta tag injection from content metadata
|
|
79
|
+
- π **Per-Page Head** - Route-specific head elements
|
|
80
|
+
- π **Language Attribute** - Dynamic `lang` attribute support
|
|
81
|
+
- π― **SEO Optimization** - Title, description, and custom meta tags
|
|
82
|
+
|
|
83
|
+
### π¦ Configuration Options
|
|
84
|
+
- π― **Custom Assets Directory** - Configure where your client files live
|
|
85
|
+
- π§ **URL Prefix** - Deploy to subdirectories with custom prefixes
|
|
86
|
+
- π« **Ignore Patterns** - Exclude files from static serving
|
|
87
|
+
- π·οΈ **Custom Headers** - Add headers to static file responses
|
|
88
|
+
- β° **Cache Control** - Configurable max-age and cache directives for static files and `__reroute_data` JSON
|
|
89
|
+
- π¨ **HTML Template** - Custom index.html with variable substitution
|
|
90
|
+
|
|
91
|
+
## π Quick Start
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Create a new project
|
|
95
|
+
bunx reroute-js init my-app
|
|
96
|
+
|
|
97
|
+
# Or with a template
|
|
98
|
+
bunx reroute-js init my-blog --template blog
|
|
99
|
+
|
|
100
|
+
# Navigate to project
|
|
101
|
+
cd my-app
|
|
102
|
+
|
|
103
|
+
# Start development
|
|
104
|
+
bun dev
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## π Learn More
|
|
108
|
+
|
|
109
|
+
- [Examples](./examples) - Example projects to get started
|
|
110
|
+
- [GitHub](https://github.com/stewones/reroute) - Source code and issues
|
|
111
|
+
|
|
112
|
+
## π SSR Data: External Requests Without Loaders
|
|
113
|
+
|
|
114
|
+
Reroute can execute route-level data fetching on the server and inline the result for instant hydration. Define an optional `ssr.data` in a route module and read it with `useData()`:
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
// routes/products/[id].tsx
|
|
118
|
+
import { useData, useParams } from 'reroute-js/react';
|
|
119
|
+
import { getProduct } from '../lib/api';
|
|
120
|
+
|
|
121
|
+
export const ssr = {
|
|
122
|
+
async data({ params }: { params: { id?: string } }) {
|
|
123
|
+
const id = Number.parseInt(params.id || '');
|
|
124
|
+
if (!Number.isFinite(id)) return { product: null };
|
|
125
|
+
const product = await getProduct(id);
|
|
126
|
+
return { product };
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default function Page() {
|
|
131
|
+
const { id } = useParams<{ id: string }>();
|
|
132
|
+
const data = useData<{ product: any }>(); // keyed by pathname
|
|
133
|
+
return <div>{data?.product?.title || `Invalid product ${id}`}</div>;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Notes:
|
|
138
|
+
- Works with Bun + Elysia SSR, no client loaders needed for initial render
|
|
139
|
+
- Data is injected as `window.__REROUTE_DATA__` and read during hydration
|
|
140
|
+
- Use with existing content features (useContent); both can be seeded in the same page
|
|
141
|
+
|
|
142
|
+
## π License
|
|
143
|
+
|
|
144
|
+
MIT
|
package/cli/bin.d.ts
ADDED
package/cli/bin.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../../packages/cli/bin.ts"],"names":[],"mappings":";AAEA,cAAc,OAAO,CAAC"}
|