Repository navigation
Replies: 1 comment
|
just making this public from a few months ago in case people feel inspired to help us finish building this out. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Ripple Metaframework Design
Overview
This document outlines the design for a Ripple metaframework that provides SSR
(Server-Side Rendering) capabilities while maintaining simplicity and leveraging
standard Web APIs. The design prioritizes:
fetch,Request,Responsethroughoutbasictemplate with SSR as an optionenv, adapter, etc.
Architecture
High-Level Flow
Core Components
1. Ripple Server Core (
ripplepackage)Platform-agnostic server functionality built on standard Web APIs.
Location: Inside the main
ripplepackage (not separate)Key Functions:
createApp(options)- Creates the main application instancerender(Component)- Server-side renderingEnvironment Handling:
2. Adapters (e.g.,
@ripple-ts/adapter-node)Platform-specific implementations that translate between platform I/O and standard
Web APIs.
Characteristics:
Example: Node Adapter
Example: Cloudflare Adapter (Future)
3. Configuration (
ripple.config)Combines Ripple options, feature flags, route config, service worker config
NOTE: The format is TBD as it will evolve depending on how each piece pans out
Questions:
just vite.config.js?
4. App Server Entry (
ripple/meta/server.js)User-defined application that wires everything together.
5. Route Configuration (
src/routes.js)ripple.configRoute Types:
Middleware System
Middleware functions receive Context parameter and follow standard Web API
patterns.
Middleware Signature
Parameter Details
context: Mutable request-scoped statenext: Function to continue the middleware chainContext Details
request: Standard Web API Request objectapp: Immutable application stateThe structure is TBD
state: Mutable user-maintained stateThe default is
Map<string, any>, users should provide their own typeMiddleware Examples
Logging Middleware
Authentication Middleware
CORS Middleware
Data Loading Middleware
Type-Safe Navigation
The routing system provides type-safe navigation utilities.
Navigation API:
Component-Level Server Code
Using Ripple's
#serverblocks for co-located server logic.#serverreInstallation & Project Setup
Create New Project
CLI Options:
--ssr: Install SSR development server and dependencies (default: false)--mode: Which mode to start after installation:client|server(default:serverif ssr, otherwiseclient)--adapter: Adapter to install:node|cloudflare|vercel(default:node)Project Structure
package.json Scripts
{ "name": "my-app", "scripts": { "dev": "vite --host", "dev:ssr": "node src/server.js", "build:client": "vite build --outDir dist/client", "build:ssr": "vite build --ssr src/server.js --outDir dist/server", "build": "pnpm run build:client && pnpm run build:ssr", "preview": "node dist/server/server.js" }, "dependencies": { "ripple": "latest" }, "devDependencies": { "@ripple-ts/vite-plugin": "latest", "@ripple-ts/adapter-node": "latest", "vite": "latest" } }Configuration Variations
1. Client-Only Mode
package.json:
{ "scripts": { "dev": "vite", "build": "vite build" } }2. SSR with Streaming
3. Hybrid Mode (Some SSR, Some Client-Only)
4. Static Site Generation (Pre-rendering)
package.json:
{ "scripts": { "build": "vite build && node scripts/generate-static.js" } }Advanced Features
Server Components
Components that only render on the server and don't hydrate on the client.
Service Worker Configuration
File-Based Routing (Community Package)
Implementation Notes
Development vs Production
Development:
vite.ssrLoadModule()for dynamic importsvite.transformIndexHtml()for HTML processingProduction:
Key Principle: User code is identical in both modes. The framework handles the
differences internally.
HTML Assembly
Template:
index.htmlServer processing:
Adapters Implementation Strategy
Each adapter follows the same pattern:
fetch(request, platformContext)Platform context is passed through the
appobject in middleware, allowingplatform-specific features while keeping core code portable.
Migration Path
From Client-Only to SSR
npm install @ripple-ts/adapter-nodesrc/server.jsentrysrc/routes.jsconfigurationpackage.jsonscriptsnpm run dev:ssrFrom Existing SSR to This Design
createApp()Future Extensions
Potential Community Packages
@ripple-ts/file-routing- File-based routing@ripple-ts/adapter-cloudflare- Cloudflare Workers adapter@ripple-ts/adapter-vercel- Vercel Edge Functions adapter@ripple-ts/adapter-deno- Deno adapter@ripple-ts/adapter-bun- Bun adapter@ripple-ts/sw-generator- Service worker generation@ripple-ts/static-gen- Static site generation utilitiesAdditional Features
Summary
This metaframework design provides:
The design balances simplicity for getting started with power for advanced use
cases, all while maintaining the ergonomics and performance that make Ripple
unique.
All reactions