@kuratchi/js 0.0.14 → 0.0.16
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 +135 -68
- package/dist/cli.js +80 -47
- package/dist/compiler/api-route-pipeline.d.ts +8 -0
- package/dist/compiler/api-route-pipeline.js +23 -0
- package/dist/compiler/asset-pipeline.d.ts +7 -0
- package/dist/compiler/asset-pipeline.js +33 -0
- package/dist/compiler/client-module-pipeline.d.ts +25 -0
- package/dist/compiler/client-module-pipeline.js +257 -0
- package/dist/compiler/compiler-shared.d.ts +55 -0
- package/dist/compiler/compiler-shared.js +4 -0
- package/dist/compiler/component-pipeline.d.ts +15 -0
- package/dist/compiler/component-pipeline.js +163 -0
- package/dist/compiler/config-reading.d.ts +11 -0
- package/dist/compiler/config-reading.js +323 -0
- package/dist/compiler/convention-discovery.d.ts +9 -0
- package/dist/compiler/convention-discovery.js +83 -0
- package/dist/compiler/durable-object-pipeline.d.ts +9 -0
- package/dist/compiler/durable-object-pipeline.js +255 -0
- package/dist/compiler/error-page-pipeline.d.ts +1 -0
- package/dist/compiler/error-page-pipeline.js +16 -0
- package/dist/compiler/import-linking.d.ts +36 -0
- package/dist/compiler/import-linking.js +139 -0
- package/dist/compiler/index.d.ts +3 -3
- package/dist/compiler/index.js +137 -3265
- package/dist/compiler/layout-pipeline.d.ts +31 -0
- package/dist/compiler/layout-pipeline.js +155 -0
- package/dist/compiler/page-route-pipeline.d.ts +16 -0
- package/dist/compiler/page-route-pipeline.js +62 -0
- package/dist/compiler/parser.d.ts +4 -0
- package/dist/compiler/parser.js +433 -51
- package/dist/compiler/root-layout-pipeline.d.ts +10 -0
- package/dist/compiler/root-layout-pipeline.js +517 -0
- package/dist/compiler/route-discovery.d.ts +7 -0
- package/dist/compiler/route-discovery.js +87 -0
- package/dist/compiler/route-pipeline.d.ts +57 -0
- package/dist/compiler/route-pipeline.js +296 -0
- package/dist/compiler/route-state-pipeline.d.ts +25 -0
- package/dist/compiler/route-state-pipeline.js +139 -0
- package/dist/compiler/routes-module-feature-blocks.d.ts +2 -0
- package/dist/compiler/routes-module-feature-blocks.js +330 -0
- package/dist/compiler/routes-module-pipeline.d.ts +2 -0
- package/dist/compiler/routes-module-pipeline.js +6 -0
- package/dist/compiler/routes-module-runtime-shell.d.ts +2 -0
- package/dist/compiler/routes-module-runtime-shell.js +81 -0
- package/dist/compiler/routes-module-types.d.ts +44 -0
- package/dist/compiler/routes-module-types.js +1 -0
- package/dist/compiler/script-transform.d.ts +16 -0
- package/dist/compiler/script-transform.js +218 -0
- package/dist/compiler/server-module-pipeline.d.ts +13 -0
- package/dist/compiler/server-module-pipeline.js +124 -0
- package/dist/compiler/template.d.ts +13 -1
- package/dist/compiler/template.js +323 -60
- package/dist/compiler/worker-output-pipeline.d.ts +13 -0
- package/dist/compiler/worker-output-pipeline.js +37 -0
- package/dist/compiler/wrangler-sync.d.ts +14 -0
- package/dist/compiler/wrangler-sync.js +185 -0
- package/dist/runtime/app.js +15 -3
- package/dist/runtime/generated-worker.d.ts +33 -0
- package/dist/runtime/generated-worker.js +412 -0
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/router.d.ts +2 -1
- package/dist/runtime/router.js +12 -3
- package/dist/runtime/types.d.ts +8 -2
- package/package.json +5 -1
package/dist/runtime/router.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ export interface MatchResult {
|
|
|
11
11
|
index: number;
|
|
12
12
|
}
|
|
13
13
|
export declare class Router {
|
|
14
|
-
private
|
|
14
|
+
private staticRoutes;
|
|
15
|
+
private dynamicRoutes;
|
|
15
16
|
/** Register a pattern (e.g. '/blog/:slug') and associate it with an index. */
|
|
16
17
|
add(pattern: string, index: number): void;
|
|
17
18
|
/** Match a pathname against registered routes. Returns null if no match. */
|
package/dist/runtime/router.js
CHANGED
|
@@ -7,9 +7,14 @@
|
|
|
7
7
|
* /files/*rest → catch-all
|
|
8
8
|
*/
|
|
9
9
|
export class Router {
|
|
10
|
-
|
|
10
|
+
staticRoutes = new Map();
|
|
11
|
+
dynamicRoutes = [];
|
|
11
12
|
/** Register a pattern (e.g. '/blog/:slug') and associate it with an index. */
|
|
12
13
|
add(pattern, index) {
|
|
14
|
+
if (!pattern.includes(':') && !pattern.includes('*')) {
|
|
15
|
+
this.staticRoutes.set(pattern, index);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
13
18
|
const paramNames = [];
|
|
14
19
|
// Convert pattern to regex
|
|
15
20
|
// :param → named capture group
|
|
@@ -27,7 +32,7 @@ export class Router {
|
|
|
27
32
|
});
|
|
28
33
|
// Anchor
|
|
29
34
|
regexStr = `^${regexStr}$`;
|
|
30
|
-
this.
|
|
35
|
+
this.dynamicRoutes.push({
|
|
31
36
|
regex: new RegExp(regexStr),
|
|
32
37
|
paramNames,
|
|
33
38
|
index,
|
|
@@ -37,7 +42,11 @@ export class Router {
|
|
|
37
42
|
match(pathname) {
|
|
38
43
|
// Normalize: strip trailing slash (except root)
|
|
39
44
|
const normalized = pathname === '/' ? '/' : pathname.replace(/\/$/, '');
|
|
40
|
-
|
|
45
|
+
const staticIdx = this.staticRoutes.get(normalized);
|
|
46
|
+
if (staticIdx !== undefined) {
|
|
47
|
+
return { params: {}, index: staticIdx };
|
|
48
|
+
}
|
|
49
|
+
for (const route of this.dynamicRoutes) {
|
|
41
50
|
const m = normalized.match(route.regex);
|
|
42
51
|
if (m) {
|
|
43
52
|
const params = {};
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ export interface RouteContext<E extends Env = Env> {
|
|
|
18
18
|
/** Parsed URL */
|
|
19
19
|
url: URL;
|
|
20
20
|
}
|
|
21
|
+
export interface PageRenderResult {
|
|
22
|
+
html: string;
|
|
23
|
+
head?: string;
|
|
24
|
+
fragments?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
export type PageRenderOutput = string | PageRenderResult;
|
|
21
27
|
/** A compiled route module */
|
|
22
28
|
export interface RouteModule {
|
|
23
29
|
/** Pattern string (e.g., '/todos', '/blog/:slug') */
|
|
@@ -28,8 +34,8 @@ export interface RouteModule {
|
|
|
28
34
|
actions?: Record<string, (formData: FormData, env: Env, ctx: RouteContext) => Promise<any>>;
|
|
29
35
|
/** RPC functions â€" callable from client via fetch */
|
|
30
36
|
rpc?: Record<string, (args: any[], env: Env, ctx: RouteContext) => Promise<any>>;
|
|
31
|
-
/** Render function â€" returns HTML
|
|
32
|
-
render: (data: Record<string, any>) =>
|
|
37
|
+
/** Render function â€" returns route HTML and optional head content from data */
|
|
38
|
+
render: (data: Record<string, any>) => PageRenderOutput;
|
|
33
39
|
/** Layout name (default: 'default') */
|
|
34
40
|
layout?: string;
|
|
35
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kuratchi/js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "A thin, Cloudflare Workers-native web framework with Svelte-inspired syntax",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"types": "./dist/runtime/do.d.ts",
|
|
39
39
|
"import": "./dist/runtime/do.js"
|
|
40
40
|
},
|
|
41
|
+
"./runtime/generated-worker.js": {
|
|
42
|
+
"types": "./dist/runtime/generated-worker.d.ts",
|
|
43
|
+
"import": "./dist/runtime/generated-worker.js"
|
|
44
|
+
},
|
|
41
45
|
"./compiler": {
|
|
42
46
|
"types": "./dist/compiler/index.d.ts",
|
|
43
47
|
"import": "./dist/compiler/index.js"
|