@junejs/server 0.1.2 → 0.2.0
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/assets/icon-latin.LICENSE.txt +92 -0
- package/assets/icon-latin.ttf +0 -0
- package/dist/adapter-DcZ-W1-7.d.ts +62 -0
- package/dist/adapter.d.ts +2 -56
- package/dist/adapter.js +62 -5
- package/dist/agent-compile.d.ts +38 -0
- package/dist/agent-compile.js +145 -0
- package/dist/agent-discover.d.ts +4 -4
- package/dist/agent-discover.js +30 -44
- package/dist/agent-durable.d.ts +94 -19
- package/dist/agent-durable.js +647 -32
- package/dist/agent-native.d.ts +44 -13
- package/dist/agent-native.js +264 -27
- package/dist/app.d.ts +5 -5
- package/dist/app.js +42 -10
- package/dist/blob.d.ts +4 -5
- package/dist/build.d.ts +8 -29
- package/dist/build.js +138 -289
- package/dist/client-bundle.d.ts +8 -9
- package/dist/client-bundle.js +1 -1
- package/dist/config-freeze-CyXvNqi2.d.ts +17 -0
- package/dist/config-freeze.d.ts +2 -0
- package/dist/config-freeze.js +54 -0
- package/dist/config-loader.d.ts +3 -4
- package/dist/connection-auth.d.ts +38 -0
- package/dist/connection-auth.js +31 -0
- package/dist/content-freeze-CyiW2fRK.d.ts +4 -0
- package/dist/content-freeze.d.ts +2 -0
- package/dist/content-freeze.js +83 -0
- package/dist/content.d.ts +22 -9
- package/dist/content.js +43 -3
- package/dist/core-version.d.ts +4 -0
- package/dist/core-version.js +12 -0
- package/dist/css-modules-ambient.d.ts +2 -1
- package/dist/css-modules.d.ts +10 -11
- package/dist/css.d.ts +9 -10
- package/dist/d1-migrate.d.ts +6 -7
- package/dist/d1-migrate.js +3 -2
- package/dist/db.d.ts +2 -2
- package/dist/deploy.d.ts +3 -4
- package/dist/deploy.js +3 -2
- package/dist/dev-reload.d.ts +3 -4
- package/dist/dev.d.ts +8 -5
- package/dist/dev.js +40 -9
- package/dist/favicon.d.ts +37 -0
- package/dist/favicon.js +248 -0
- package/dist/host.d.ts +6 -5
- package/dist/host.js +2 -1
- package/dist/icon-letter.d.ts +3 -0
- package/dist/icon-letter.js +8 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +9 -3
- package/dist/instrumentation.d.ts +2 -3
- package/dist/instrumentation.js +2 -1
- package/dist/island-registry.d.ts +6 -7
- package/dist/isolate-local.d.ts +5 -0
- package/dist/isolate-local.js +12 -0
- package/dist/kv.d.ts +3 -4
- package/dist/llms-links.d.ts +9 -0
- package/dist/llms-links.js +65 -0
- package/dist/manifest-CwTT1zVs.d.ts +11 -0
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.js +113 -0
- package/dist/negotiate.d.ts +4 -3
- package/dist/negotiate.js +24 -14
- package/dist/{pipeline-CCp9idQ4.d.ts → pipeline-BHUjBO0G.d.ts} +13 -1
- package/dist/pipeline.d.ts +2 -2
- package/dist/pipeline.js +286 -35
- package/dist/resources.d.ts +5 -6
- package/dist/route-rank.d.ts +10 -0
- package/dist/route-rank.js +38 -0
- package/dist/route-scan-BMbBzPIB.d.ts +20 -0
- package/dist/route-scan.d.ts +2 -0
- package/dist/route-scan.js +100 -0
- package/dist/router.d.ts +12 -13
- package/dist/router.js +58 -44
- package/dist/rsc-build.d.ts +6 -7
- package/dist/rsc-bundle.d.ts +6 -7
- package/dist/rsc-manifest.d.ts +5 -6
- package/dist/rsc-runtime/flight-render-routes.d.ts +3 -4
- package/dist/rsc-runtime/flight-render.d.ts +2 -3
- package/dist/rsc-runtime/flight-to-html.d.ts +2 -3
- package/dist/rsc-runtime/flight-to-html.js +3 -2
- package/dist/rsc-runtime/rsc-worker.js +11 -8
- package/dist/rsc-runtime/rsdw-shims.d.ts +2 -1
- package/dist/segment.d.ts +4 -5
- package/dist/sqlite-driver.d.ts +11 -11
- package/dist/sqlite-driver.js +17 -4
- package/dist/static-files.d.ts +4 -5
- package/dist/tsconfig-jsx.d.ts +4 -4
- package/dist/tsconfig-jsx.js +1 -1
- package/dist/turn-events.d.ts +4 -0
- package/dist/turn-events.js +46 -0
- package/dist/web-manifest.d.ts +5 -0
- package/dist/web-manifest.js +42 -0
- package/dist/worker-2qbQjj2c.d.ts +64 -0
- package/dist/worker.d.ts +2 -56
- package/dist/worker.js +121 -103
- package/package.json +22 -9
- package/src/adapter.ts +84 -3
- package/src/agent-compile.ts +271 -0
- package/src/agent-discover.ts +77 -63
- package/src/agent-durable.ts +998 -30
- package/src/agent-native.ts +370 -35
- package/src/app.ts +75 -6
- package/src/build.ts +237 -444
- package/src/config-freeze.ts +109 -0
- package/src/connection-auth.ts +101 -0
- package/src/content-freeze.ts +151 -0
- package/src/content.ts +55 -4
- package/src/core-version.ts +34 -0
- package/src/dev.ts +41 -8
- package/src/favicon.ts +325 -0
- package/src/host.ts +4 -3
- package/src/icon-letter.ts +14 -0
- package/src/index.ts +22 -0
- package/src/isolate-local.ts +33 -0
- package/src/llms-links.ts +96 -0
- package/src/manifest.ts +130 -0
- package/src/negotiate.ts +39 -15
- package/src/pipeline.ts +494 -44
- package/src/route-rank.ts +60 -0
- package/src/route-scan.ts +161 -0
- package/src/router.ts +75 -58
- package/src/rsc-runtime/rsc-worker.tsx +5 -4
- package/src/sqlite-driver.ts +36 -6
- package/src/tsconfig-jsx.ts +2 -2
- package/src/turn-events.ts +43 -0
- package/src/web-manifest.ts +38 -0
- package/src/worker.ts +197 -117
package/src/negotiate.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// header — a link is unambiguous; Accept is a hint. The clean pathname (with
|
|
7
7
|
// the projection extension stripped) is what the router matches.
|
|
8
8
|
|
|
9
|
+
import { FRAGMENT_ACCEPT } from "@junejs/core/nav-protocol";
|
|
9
10
|
import type { RenderTarget } from "@junejs/core/route";
|
|
10
11
|
|
|
11
12
|
// The fragment media type + title header are the client-router wire protocol —
|
|
@@ -18,12 +19,43 @@ const EXT_TARGET: Record<string, RenderTarget> = {
|
|
|
18
19
|
".md": "md",
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
// RFC 9110 §12.4.2 qvalue: 0–1 with at most three decimals ("0", "0.5", "1.000").
|
|
23
|
+
const QVALUE = /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/;
|
|
24
|
+
|
|
25
|
+
// Parse an Accept header into media-range → q (RFC 9110 §12.5.1). A q outside the
|
|
26
|
+
// qvalue grammar ("2", "-0.5", "0.1234") is malformed and reads as the default 1:
|
|
27
|
+
// the client still listed the type, so it stays acceptable at the default weight
|
|
28
|
+
// rather than being dropped or excluded. Parameters other than q are ignored.
|
|
29
|
+
function acceptRanges(accept: string): Map<string, number> {
|
|
30
|
+
const ranges = new Map<string, number>();
|
|
31
|
+
for (const part of accept.split(",")) {
|
|
32
|
+
const [type, ...params] = part.split(";").map((s) => s.trim().toLowerCase());
|
|
33
|
+
if (!type) continue;
|
|
34
|
+
const raw = params.find((p) => p.startsWith("q="))?.slice(2).trim();
|
|
35
|
+
ranges.set(type, raw !== undefined && QVALUE.test(raw) ? Number(raw) : 1);
|
|
36
|
+
}
|
|
37
|
+
return ranges;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The projection an Accept header asks for — null when it asks for none of the
|
|
41
|
+
// agent projections (→ the HTML view). ONE decision shared by the pipeline and
|
|
42
|
+
// the deployed worker's asset layer (withAssets), so the two can't disagree.
|
|
43
|
+
// - The client router's fragment media type (exact range, q > 0) wins outright.
|
|
44
|
+
// - Markdown / JSON are chosen when listed with q > 0 and at least as preferred
|
|
45
|
+
// as HTML; HTML's quality is text/html's, else the text/* or */* wildcard's.
|
|
46
|
+
// So `text/markdown, text/html;q=0.9` → md, `text/html, text/markdown;q=0.5`
|
|
47
|
+
// → HTML, and a plain browser Accept (no markdown/json) → HTML.
|
|
48
|
+
// - Ties go to the agent projection (md before json), as they always have.
|
|
49
|
+
export function acceptTarget(accept: string): RenderTarget | null {
|
|
50
|
+
const ranges = acceptRanges(accept);
|
|
51
|
+
if ((ranges.get(FRAGMENT_ACCEPT) ?? 0) > 0) return "fragment";
|
|
52
|
+
const html = ranges.get("text/html") ?? ranges.get("text/*") ?? ranges.get("*/*") ?? 0;
|
|
53
|
+
const md = ranges.get("text/markdown") ?? 0;
|
|
54
|
+
const json = ranges.get("application/json") ?? 0;
|
|
55
|
+
const best = Math.max(md, json);
|
|
56
|
+
if (best <= 0 || best < html) return null;
|
|
57
|
+
return md >= json ? "md" : "json";
|
|
58
|
+
}
|
|
27
59
|
|
|
28
60
|
export type Negotiated = {
|
|
29
61
|
target: RenderTarget;
|
|
@@ -61,15 +93,7 @@ export function negotiate(url: URL, request: Request, basePath?: string): Negoti
|
|
|
61
93
|
pathname = original;
|
|
62
94
|
}
|
|
63
95
|
|
|
64
|
-
if (!target)
|
|
65
|
-
const accept = request.headers.get("accept") ?? "";
|
|
66
|
-
for (const [re, t] of ACCEPT_TARGET) {
|
|
67
|
-
if (re.test(accept)) {
|
|
68
|
-
target = t;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
96
|
+
if (!target) target = acceptTarget(request.headers.get("accept") ?? "");
|
|
73
97
|
|
|
74
98
|
// A speculative request (Sec-Purpose: prefetch / prerender) may never be seen
|
|
75
99
|
// — load()s read it to skip side effects (analytics, rate limits, counters).
|