@lolyjs/core 0.1.0-alpha.0 → 0.1.0-alpha.10
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 +31 -31
- package/dist/cli.cjs +3 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +69 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +70 -32
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +66 -28
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +67 -29
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Loly Framework
|
|
1
|
+
# Loly Framework EXPERIMENTAL
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
5
|
**A modern, production-ready React framework with file-based routing, SSR, SSG, and built-in security**
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/@lolyjs/core)
|
|
8
8
|
[](https://opensource.org/licenses/ISC)
|
|
9
9
|
|
|
10
10
|
*Built with React 19, Express, Rspack, and TypeScript*
|
|
@@ -32,9 +32,9 @@ Loly is a full-stack React framework that combines the simplicity of file-based
|
|
|
32
32
|
### Installation
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
npm install @
|
|
35
|
+
npm install @lolyjs/core react react-dom
|
|
36
36
|
# or
|
|
37
|
-
pnpm add @
|
|
37
|
+
pnpm add @lolyjs/core react react-dom
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
### Create Your First App
|
|
@@ -56,8 +56,8 @@ export default function Home() {
|
|
|
56
56
|
|
|
57
57
|
```tsx
|
|
58
58
|
// bootstrap.tsx
|
|
59
|
-
import { bootstrapClient } from "@
|
|
60
|
-
import routes from "@
|
|
59
|
+
import { bootstrapClient } from "@lolyjs/core/runtime";
|
|
60
|
+
import routes from "@lolyjs/core/runtime";
|
|
61
61
|
|
|
62
62
|
bootstrapClient(routes);
|
|
63
63
|
```
|
|
@@ -99,7 +99,7 @@ Use `server.hook.ts` to fetch data on the server:
|
|
|
99
99
|
|
|
100
100
|
```tsx
|
|
101
101
|
// app/blog/[slug]/server.hook.ts
|
|
102
|
-
import type { ServerLoader } from "@
|
|
102
|
+
import type { ServerLoader } from "@lolyjs/core";
|
|
103
103
|
|
|
104
104
|
export const getServerSideProps: ServerLoader = async (ctx) => {
|
|
105
105
|
const { slug } = ctx.params;
|
|
@@ -117,7 +117,7 @@ export const getServerSideProps: ServerLoader = async (ctx) => {
|
|
|
117
117
|
|
|
118
118
|
```tsx
|
|
119
119
|
// app/blog/[slug]/page.tsx
|
|
120
|
-
import { usePageProps } from "@
|
|
120
|
+
import { usePageProps } from "@lolyjs/core/hooks";
|
|
121
121
|
|
|
122
122
|
export default function BlogPost() {
|
|
123
123
|
const { props } = usePageProps();
|
|
@@ -137,7 +137,7 @@ export default function BlogPost() {
|
|
|
137
137
|
Fast page transitions without full reloads:
|
|
138
138
|
|
|
139
139
|
```tsx
|
|
140
|
-
import { Link } from "@
|
|
140
|
+
import { Link } from "@lolyjs/core/components";
|
|
141
141
|
|
|
142
142
|
export default function Navigation() {
|
|
143
143
|
return (
|
|
@@ -154,7 +154,7 @@ export default function Navigation() {
|
|
|
154
154
|
Invalidate and refresh route data:
|
|
155
155
|
|
|
156
156
|
```tsx
|
|
157
|
-
import { revalidatePath, revalidate } from "@
|
|
157
|
+
import { revalidatePath, revalidate } from "@lolyjs/core/client-cache";
|
|
158
158
|
|
|
159
159
|
// Revalidate a specific route
|
|
160
160
|
revalidatePath('/posts');
|
|
@@ -194,7 +194,7 @@ Components using `usePageProps()` automatically update when you call `revalidate
|
|
|
194
194
|
### Server Loader
|
|
195
195
|
|
|
196
196
|
```tsx
|
|
197
|
-
import type { ServerLoader } from "@
|
|
197
|
+
import type { ServerLoader } from "@lolyjs/core";
|
|
198
198
|
|
|
199
199
|
export const getServerSideProps: ServerLoader = async (ctx) => {
|
|
200
200
|
const { req, res, params, pathname, locals } = ctx;
|
|
@@ -227,7 +227,7 @@ export const getServerSideProps: ServerLoader = async (ctx) => {
|
|
|
227
227
|
### Static Site Generation
|
|
228
228
|
|
|
229
229
|
```tsx
|
|
230
|
-
import type { ServerLoader, GenerateStaticParams } from "@
|
|
230
|
+
import type { ServerLoader, GenerateStaticParams } from "@lolyjs/core";
|
|
231
231
|
|
|
232
232
|
export const dynamic = "force-static" as const;
|
|
233
233
|
|
|
@@ -246,8 +246,8 @@ export const getServerSideProps: ServerLoader = async (ctx) => {
|
|
|
246
246
|
### API Routes
|
|
247
247
|
|
|
248
248
|
```tsx
|
|
249
|
-
import type { ApiContext } from "@
|
|
250
|
-
import { validate } from "@
|
|
249
|
+
import type { ApiContext } from "@lolyjs/core";
|
|
250
|
+
import { validate } from "@lolyjs/core";
|
|
251
251
|
import { z } from "zod";
|
|
252
252
|
|
|
253
253
|
const schema = z.object({
|
|
@@ -270,7 +270,7 @@ export async function POST(ctx: ApiContext) {
|
|
|
270
270
|
### Middleware
|
|
271
271
|
|
|
272
272
|
```tsx
|
|
273
|
-
import type { RouteMiddleware } from "@
|
|
273
|
+
import type { RouteMiddleware } from "@lolyjs/core";
|
|
274
274
|
|
|
275
275
|
export const requireAuth: RouteMiddleware = async (ctx, next) => {
|
|
276
276
|
const user = await getUser(ctx.req);
|
|
@@ -298,7 +298,7 @@ export const getServerSideProps: ServerLoader = async (ctx) => {
|
|
|
298
298
|
### Cache Management
|
|
299
299
|
|
|
300
300
|
```tsx
|
|
301
|
-
import { revalidatePath, revalidate } from "@
|
|
301
|
+
import { revalidatePath, revalidate } from "@lolyjs/core/client-cache";
|
|
302
302
|
|
|
303
303
|
// Revalidate a specific route (removes from cache)
|
|
304
304
|
revalidatePath('/posts');
|
|
@@ -313,7 +313,7 @@ await revalidate();
|
|
|
313
313
|
### Client Hooks
|
|
314
314
|
|
|
315
315
|
```tsx
|
|
316
|
-
import { usePageProps } from "@
|
|
316
|
+
import { usePageProps } from "@lolyjs/core/hooks";
|
|
317
317
|
|
|
318
318
|
export default function Page() {
|
|
319
319
|
const { params, props } = usePageProps();
|
|
@@ -425,7 +425,7 @@ export default function BlogLayout({ children }) {
|
|
|
425
425
|
### Themes
|
|
426
426
|
|
|
427
427
|
```tsx
|
|
428
|
-
import { ThemeProvider } from "@
|
|
428
|
+
import { ThemeProvider } from "@lolyjs/core/themes";
|
|
429
429
|
|
|
430
430
|
export default function RootLayout({ children, theme }) {
|
|
431
431
|
return (
|
|
@@ -439,7 +439,7 @@ export default function RootLayout({ children, theme }) {
|
|
|
439
439
|
### Validation & Sanitization
|
|
440
440
|
|
|
441
441
|
```tsx
|
|
442
|
-
import { validate, safeValidate, sanitizeString } from "@
|
|
442
|
+
import { validate, safeValidate, sanitizeString } from "@lolyjs/core";
|
|
443
443
|
import { z } from "zod";
|
|
444
444
|
|
|
445
445
|
const schema = z.object({
|
|
@@ -463,7 +463,7 @@ const clean = sanitizeString(userInput);
|
|
|
463
463
|
### Logging
|
|
464
464
|
|
|
465
465
|
```tsx
|
|
466
|
-
import { getRequestLogger, createModuleLogger } from "@
|
|
466
|
+
import { getRequestLogger, createModuleLogger } from "@lolyjs/core";
|
|
467
467
|
|
|
468
468
|
// In server hooks or API routes
|
|
469
469
|
export const getServerSideProps: ServerLoader = async (ctx) => {
|
|
@@ -491,7 +491,7 @@ import type {
|
|
|
491
491
|
ApiContext,
|
|
492
492
|
RouteMiddleware,
|
|
493
493
|
ApiMiddleware,
|
|
494
|
-
} from "@
|
|
494
|
+
} from "@lolyjs/core";
|
|
495
495
|
|
|
496
496
|
// Fully typed server loader
|
|
497
497
|
export const getServerSideProps: ServerLoader = async (ctx) => {
|
|
@@ -552,7 +552,7 @@ loly start [--port 3000] [--appDir app]
|
|
|
552
552
|
|
|
553
553
|
```tsx
|
|
554
554
|
// Server
|
|
555
|
-
import { startDevServer, startProdServer, buildApp } from "@
|
|
555
|
+
import { startDevServer, startProdServer, buildApp } from "@lolyjs/core";
|
|
556
556
|
|
|
557
557
|
// Types
|
|
558
558
|
import type {
|
|
@@ -562,23 +562,23 @@ import type {
|
|
|
562
562
|
RouteMiddleware,
|
|
563
563
|
ApiMiddleware,
|
|
564
564
|
GenerateStaticParams,
|
|
565
|
-
} from "@
|
|
565
|
+
} from "@lolyjs/core";
|
|
566
566
|
|
|
567
567
|
// Validation
|
|
568
|
-
import { validate, safeValidate, ValidationError } from "@
|
|
568
|
+
import { validate, safeValidate, ValidationError } from "@lolyjs/core";
|
|
569
569
|
|
|
570
570
|
// Security
|
|
571
|
-
import { sanitizeString, sanitizeObject } from "@
|
|
572
|
-
import { strictRateLimiter, lenientRateLimiter } from "@
|
|
571
|
+
import { sanitizeString, sanitizeObject } from "@lolyjs/core";
|
|
572
|
+
import { strictRateLimiter, lenientRateLimiter } from "@lolyjs/core";
|
|
573
573
|
|
|
574
574
|
// Logging
|
|
575
|
-
import { logger, createModuleLogger, getRequestLogger } from "@
|
|
575
|
+
import { logger, createModuleLogger, getRequestLogger } from "@lolyjs/core";
|
|
576
576
|
|
|
577
577
|
// Client
|
|
578
|
-
import { Link } from "@
|
|
579
|
-
import { usePageProps } from "@
|
|
580
|
-
import { ThemeProvider } from "@
|
|
581
|
-
import { revalidatePath, revalidate } from "@
|
|
578
|
+
import { Link } from "@lolyjs/core/components";
|
|
579
|
+
import { usePageProps } from "@lolyjs/core/hooks";
|
|
580
|
+
import { ThemeProvider } from "@lolyjs/core/themes";
|
|
581
|
+
import { revalidatePath, revalidate } from "@lolyjs/core/client-cache";
|
|
582
582
|
```
|
|
583
583
|
|
|
584
584
|
---
|
package/dist/cli.cjs
CHANGED
|
@@ -634,7 +634,7 @@ function writeClientBoostrapManifest(projectRoot) {
|
|
|
634
634
|
lines.push(` errorRoute,`);
|
|
635
635
|
lines.push(`} from "./routes-client";`);
|
|
636
636
|
lines.push("");
|
|
637
|
-
lines.push(`import { bootstrapClient } from "@
|
|
637
|
+
lines.push(`import { bootstrapClient } from "@lolyjs/core/runtime"`);
|
|
638
638
|
lines.push("");
|
|
639
639
|
lines.push(
|
|
640
640
|
"bootstrapClient(routes as ClientRouteLoaded[], notFoundRoute, errorRoute);"
|
|
@@ -1610,7 +1610,7 @@ async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params)
|
|
|
1610
1610
|
initialData,
|
|
1611
1611
|
meta: loaderResult.metadata,
|
|
1612
1612
|
titleFallback: "My Framework Dev",
|
|
1613
|
-
descriptionFallback: "Static page generated by @
|
|
1613
|
+
descriptionFallback: "Static page generated by @lolyjs/core.",
|
|
1614
1614
|
chunkHref,
|
|
1615
1615
|
clientJsPath,
|
|
1616
1616
|
clientCssPath
|
|
@@ -3953,7 +3953,7 @@ function createLogger(options = {}) {
|
|
|
3953
3953
|
const baseConfig = {
|
|
3954
3954
|
level,
|
|
3955
3955
|
base: {
|
|
3956
|
-
name: "@
|
|
3956
|
+
name: "@lolyjs/core",
|
|
3957
3957
|
env: process.env.NODE_ENV || "development"
|
|
3958
3958
|
},
|
|
3959
3959
|
timestamp: import_pino.default.stdTimeFunctions.isoTime,
|