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.
Files changed (136) hide show
  1. package/README.md +144 -0
  2. package/cli/bin.d.ts +3 -0
  3. package/cli/bin.d.ts.map +1 -0
  4. package/cli/bin.js +812 -0
  5. package/cli/bin.js.map +15 -0
  6. package/cli/src/commands/build.d.ts +8 -0
  7. package/cli/src/commands/build.d.ts.map +1 -0
  8. package/cli/src/commands/dev.d.ts +8 -0
  9. package/cli/src/commands/dev.d.ts.map +1 -0
  10. package/cli/src/commands/gen.d.ts +3 -0
  11. package/cli/src/commands/gen.d.ts.map +1 -0
  12. package/cli/src/commands/init.d.ts +8 -0
  13. package/cli/src/commands/init.d.ts.map +1 -0
  14. package/cli/src/index.d.ts +8 -0
  15. package/cli/src/index.d.ts.map +1 -0
  16. package/cli/src/libs/tailwind.d.ts +18 -0
  17. package/cli/src/libs/tailwind.d.ts.map +1 -0
  18. package/core/index.d.ts +2 -0
  19. package/core/index.d.ts.map +1 -0
  20. package/core/index.js +1174 -0
  21. package/core/index.js.map +25 -0
  22. package/core/src/bundler/hash.d.ts +2 -0
  23. package/core/src/bundler/hash.d.ts.map +1 -0
  24. package/core/src/bundler/index.d.ts +3 -0
  25. package/core/src/bundler/index.d.ts.map +1 -0
  26. package/core/src/bundler/transpile.d.ts +4 -0
  27. package/core/src/bundler/transpile.d.ts.map +1 -0
  28. package/core/src/content/builder.d.ts +2 -0
  29. package/core/src/content/builder.d.ts.map +1 -0
  30. package/core/src/content/discovery.d.ts +5 -0
  31. package/core/src/content/discovery.d.ts.map +1 -0
  32. package/core/src/content/index.d.ts +5 -0
  33. package/core/src/content/index.d.ts.map +1 -0
  34. package/core/src/content/metadata.d.ts +9 -0
  35. package/core/src/content/metadata.d.ts.map +1 -0
  36. package/core/src/content/registry.d.ts +2 -0
  37. package/core/src/content/registry.d.ts.map +1 -0
  38. package/core/src/index.d.ts +7 -0
  39. package/core/src/index.d.ts.map +1 -0
  40. package/core/src/ssr/data.d.ts +9 -0
  41. package/core/src/ssr/data.d.ts.map +1 -0
  42. package/core/src/ssr/index.d.ts +4 -0
  43. package/core/src/ssr/index.d.ts.map +1 -0
  44. package/core/src/ssr/modules.d.ts +8 -0
  45. package/core/src/ssr/modules.d.ts.map +1 -0
  46. package/core/src/ssr/render.d.ts +20 -0
  47. package/core/src/ssr/render.d.ts.map +1 -0
  48. package/core/src/ssr/seed.d.ts +2 -0
  49. package/core/src/ssr/seed.d.ts.map +1 -0
  50. package/core/src/template/html.d.ts +4 -0
  51. package/core/src/template/html.d.ts.map +1 -0
  52. package/core/src/template/index.d.ts +2 -0
  53. package/core/src/template/index.d.ts.map +1 -0
  54. package/core/src/types.d.ts +50 -0
  55. package/core/src/types.d.ts.map +1 -0
  56. package/core/src/utils/cache.d.ts +12 -0
  57. package/core/src/utils/cache.d.ts.map +1 -0
  58. package/core/src/utils/compression.d.ts +5 -0
  59. package/core/src/utils/compression.d.ts.map +1 -0
  60. package/core/src/utils/index.d.ts +5 -0
  61. package/core/src/utils/index.d.ts.map +1 -0
  62. package/core/src/utils/mime.d.ts +3 -0
  63. package/core/src/utils/mime.d.ts.map +1 -0
  64. package/core/src/utils/path.d.ts +6 -0
  65. package/core/src/utils/path.d.ts.map +1 -0
  66. package/elysia/index.d.ts +2 -0
  67. package/elysia/index.d.ts.map +1 -0
  68. package/elysia/index.js +1829 -0
  69. package/elysia/index.js.map +32 -0
  70. package/elysia/src/index.d.ts +3 -0
  71. package/elysia/src/index.d.ts.map +1 -0
  72. package/elysia/src/plugin.d.ts +32 -0
  73. package/elysia/src/plugin.d.ts.map +1 -0
  74. package/elysia/src/routes/artifacts.d.ts +3 -0
  75. package/elysia/src/routes/artifacts.d.ts.map +1 -0
  76. package/elysia/src/routes/content.d.ts +3 -0
  77. package/elysia/src/routes/content.d.ts.map +1 -0
  78. package/elysia/src/routes/dev.d.ts +7 -0
  79. package/elysia/src/routes/dev.d.ts.map +1 -0
  80. package/elysia/src/routes/ssr.d.ts +18 -0
  81. package/elysia/src/routes/ssr.d.ts.map +1 -0
  82. package/elysia/src/routes/static.d.ts +19 -0
  83. package/elysia/src/routes/static.d.ts.map +1 -0
  84. package/elysia/src/types.d.ts +31 -0
  85. package/elysia/src/types.d.ts.map +1 -0
  86. package/elysia/src/utils/http.d.ts +5 -0
  87. package/elysia/src/utils/http.d.ts.map +1 -0
  88. package/package.json +74 -0
  89. package/react/index.d.ts +2 -0
  90. package/react/index.d.ts.map +1 -0
  91. package/react/index.js +1152 -0
  92. package/react/index.js.map +23 -0
  93. package/react/src/components/ContentRoute.d.ts +13 -0
  94. package/react/src/components/ContentRoute.d.ts.map +1 -0
  95. package/react/src/components/Link.d.ts +8 -0
  96. package/react/src/components/Link.d.ts.map +1 -0
  97. package/react/src/components/Outlet.d.ts +7 -0
  98. package/react/src/components/Outlet.d.ts.map +1 -0
  99. package/react/src/components/index.d.ts +4 -0
  100. package/react/src/components/index.d.ts.map +1 -0
  101. package/react/src/hooks/index.d.ts +7 -0
  102. package/react/src/hooks/index.d.ts.map +1 -0
  103. package/react/src/hooks/useContent.d.ts +26 -0
  104. package/react/src/hooks/useContent.d.ts.map +1 -0
  105. package/react/src/hooks/useData.d.ts +10 -0
  106. package/react/src/hooks/useData.d.ts.map +1 -0
  107. package/react/src/hooks/useNavigate.d.ts +6 -0
  108. package/react/src/hooks/useNavigate.d.ts.map +1 -0
  109. package/react/src/hooks/useParams.d.ts +6 -0
  110. package/react/src/hooks/useParams.d.ts.map +1 -0
  111. package/react/src/hooks/useRouter.d.ts +7 -0
  112. package/react/src/hooks/useRouter.d.ts.map +1 -0
  113. package/react/src/hooks/useSearchParams.d.ts +6 -0
  114. package/react/src/hooks/useSearchParams.d.ts.map +1 -0
  115. package/react/src/index.d.ts +6 -0
  116. package/react/src/index.d.ts.map +1 -0
  117. package/react/src/providers/ContentProvider.d.ts +35 -0
  118. package/react/src/providers/ContentProvider.d.ts.map +1 -0
  119. package/react/src/providers/RerouteProvider.d.ts +25 -0
  120. package/react/src/providers/RerouteProvider.d.ts.map +1 -0
  121. package/react/src/providers/RouterProvider.d.ts +23 -0
  122. package/react/src/providers/RouterProvider.d.ts.map +1 -0
  123. package/react/src/providers/index.d.ts +4 -0
  124. package/react/src/providers/index.d.ts.map +1 -0
  125. package/react/src/types/any.d.ts +3 -0
  126. package/react/src/types/any.d.ts.map +1 -0
  127. package/react/src/types/index.d.ts +3 -0
  128. package/react/src/types/index.d.ts.map +1 -0
  129. package/react/src/types/router.d.ts +32 -0
  130. package/react/src/types/router.d.ts.map +1 -0
  131. package/react/src/utils/content.d.ts +8 -0
  132. package/react/src/utils/content.d.ts.map +1 -0
  133. package/react/src/utils/head.d.ts +6 -0
  134. package/react/src/utils/head.d.ts.map +1 -0
  135. package/react/src/utils/index.d.ts +3 -0
  136. 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
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ export * from './src';
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../../packages/cli/bin.ts"],"names":[],"mappings":";AAEA,cAAc,OAAO,CAAC"}