@junejs/server 1.0.0-dev.29 → 1.0.0-dev.42

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 (77) hide show
  1. package/dist/agent-compile.d.ts +8 -9
  2. package/dist/agent-discover.d.ts +3 -4
  3. package/dist/agent-durable.d.ts +38 -20
  4. package/dist/agent-durable.js +159 -13
  5. package/dist/agent-native.d.ts +15 -12
  6. package/dist/agent-native.js +72 -8
  7. package/dist/app.d.ts +4 -5
  8. package/dist/app.js +2 -1
  9. package/dist/blob.d.ts +4 -5
  10. package/dist/build.d.ts +6 -6
  11. package/dist/build.js +38 -7
  12. package/dist/client-bundle.d.ts +8 -9
  13. package/dist/{config-freeze-DwI-Rmvq.d.ts → config-freeze-ZWC_Qd4h.d.ts} +1 -1
  14. package/dist/config-freeze.d.ts +1 -1
  15. package/dist/config-loader.d.ts +3 -4
  16. package/dist/connection-auth.d.ts +8 -9
  17. package/dist/content.d.ts +9 -10
  18. package/dist/core-version.d.ts +3 -4
  19. package/dist/core-version.js +1 -1
  20. package/dist/css-modules-ambient.d.ts +2 -1
  21. package/dist/css-modules.d.ts +10 -11
  22. package/dist/css.d.ts +9 -10
  23. package/dist/d1-migrate.d.ts +6 -7
  24. package/dist/d1-migrate.js +3 -2
  25. package/dist/db.d.ts +2 -2
  26. package/dist/deploy.d.ts +3 -4
  27. package/dist/deploy.js +3 -2
  28. package/dist/dev-reload.d.ts +3 -4
  29. package/dist/dev.d.ts +4 -5
  30. package/dist/favicon.d.ts +16 -17
  31. package/dist/host.d.ts +5 -5
  32. package/dist/icon-letter.d.ts +2 -3
  33. package/dist/index.d.ts +4 -4
  34. package/dist/instrumentation.d.ts +2 -3
  35. package/dist/instrumentation.js +2 -1
  36. package/dist/island-registry.d.ts +6 -7
  37. package/dist/isolate-local.d.ts +4 -5
  38. package/dist/kv.d.ts +3 -4
  39. package/dist/llms-links.d.ts +8 -5
  40. package/dist/llms-links.js +31 -1
  41. package/dist/{manifest-gcNWqWoI.d.ts → manifest-DSNX4I-G.d.ts} +2 -2
  42. package/dist/manifest.d.ts +1 -1
  43. package/dist/negotiate.d.ts +4 -3
  44. package/dist/negotiate.js +24 -14
  45. package/dist/{pipeline-cCR6MGNK.d.ts → pipeline-BHUjBO0G.d.ts} +5 -1
  46. package/dist/pipeline.d.ts +2 -2
  47. package/dist/pipeline.js +260 -41
  48. package/dist/resources.d.ts +5 -6
  49. package/dist/router.d.ts +12 -13
  50. package/dist/rsc-build.d.ts +6 -7
  51. package/dist/rsc-bundle.d.ts +6 -7
  52. package/dist/rsc-manifest.d.ts +5 -6
  53. package/dist/rsc-runtime/flight-render-routes.d.ts +3 -4
  54. package/dist/rsc-runtime/flight-render.d.ts +2 -3
  55. package/dist/rsc-runtime/flight-to-html.d.ts +2 -3
  56. package/dist/rsc-runtime/flight-to-html.js +3 -2
  57. package/dist/rsc-runtime/rsdw-shims.d.ts +2 -1
  58. package/dist/segment.d.ts +4 -5
  59. package/dist/sqlite-driver.d.ts +10 -11
  60. package/dist/static-files.d.ts +4 -5
  61. package/dist/tsconfig-jsx.d.ts +4 -5
  62. package/dist/turn-events.d.ts +2 -3
  63. package/dist/web-manifest.d.ts +3 -4
  64. package/dist/web-manifest.js +2 -6
  65. package/dist/{worker-BkFHGtxp.d.ts → worker-Dv4l6Ybs.d.ts} +4 -2
  66. package/dist/worker.d.ts +1 -1
  67. package/dist/worker.js +35 -18
  68. package/package.json +5 -5
  69. package/src/agent-durable.ts +203 -21
  70. package/src/agent-native.ts +94 -7
  71. package/src/build.ts +67 -5
  72. package/src/core-version.ts +1 -1
  73. package/src/llms-links.ts +46 -1
  74. package/src/negotiate.ts +39 -15
  75. package/src/pipeline.ts +433 -45
  76. package/src/web-manifest.ts +2 -6
  77. package/src/worker.ts +55 -17
package/dist/deploy.d.ts CHANGED
@@ -5,7 +5,7 @@ type CliRun = (args: string[], cwd: string) => Promise<{
5
5
  stderr: string;
6
6
  exitCode: number;
7
7
  }>;
8
- type DeployResult = {
8
+ export type DeployResult = {
9
9
  url: string | null;
10
10
  dryRun: boolean;
11
11
  configPath: string;
@@ -20,6 +20,5 @@ type DeployOptions = {
20
20
  d1Exec?: D1Exec;
21
21
  runCli?: CliRun;
22
22
  };
23
- declare function juneDeploy(appRoot: string, options?: DeployOptions): Promise<DeployResult>;
24
- //#endregion
25
- export { DeployResult, juneDeploy };
23
+ export declare function juneDeploy(appRoot: string, options?: DeployOptions): Promise<DeployResult>;
24
+ //#endregion
package/dist/deploy.js CHANGED
@@ -49,6 +49,7 @@ async function deployStatic(appRoot) {
49
49
  migrated: []
50
50
  };
51
51
  }
52
+ const DENO_CREATE_HINT = "first deploy? provision the app in dynamic mode (auto-detect won't find an entrypoint):\n deno deploy create --org=<org> --app=<app> --source=local \\\n --do-not-use-detected-build-config --runtime-mode=dynamic --entrypoint=worker.js";
52
53
  async function deployDeno(appRoot, cfg, options, run) {
53
54
  const dist = join(appRoot, "dist");
54
55
  if (!existsSync(join(dist, "worker.js"))) throw new Error(`no built bundle (expected ${join(dist, "worker.js")}) — run june build first`);
@@ -68,8 +69,8 @@ async function deployDeno(appRoot, cfg, options, run) {
68
69
  if (stdout.trim()) console.log(stdout.trimEnd());
69
70
  if (exitCode !== 0) {
70
71
  const out = stderr + stdout;
71
- if (/token|login|unauthorized|forbidden|organization was not found|app.*not found/i.test(out)) throw new Error("Deno Deploy auth/org failed — set DENO_DEPLOY_TOKEN (or `deno deploy login`) and the\n org/app in deno({ org, app }).\n first deploy? provision the app in dynamic mode (auto-detect won't find an entrypoint):\n deno deploy create --org=<org> --app=<app> --source=local \\\n --do-not-use-detected-build-config --runtime-mode=dynamic --entrypoint=worker.js\n" + stderr.trim());
72
- if (/no runtime entrypoint|build config/i.test(out)) throw new Error("Deno Deploy build failed — first deploy? provision the app in dynamic mode (auto-detect won't find an entrypoint):\n deno deploy create --org=<org> --app=<app> --source=local \\\n --do-not-use-detected-build-config --runtime-mode=dynamic --entrypoint=worker.js\n" + stderr.trim());
72
+ if (/token|login|unauthorized|forbidden|organization was not found|app.*not found/i.test(out)) throw new Error("Deno Deploy auth/org failed — set DENO_DEPLOY_TOKEN (or `deno deploy login`) and the\n org/app in deno({ org, app }).\n " + DENO_CREATE_HINT + "\n" + stderr.trim());
73
+ if (/no runtime entrypoint|build config/i.test(out)) throw new Error("Deno Deploy build failed — " + DENO_CREATE_HINT + "\n" + stderr.trim());
73
74
  throw new Error(`deno deploy failed (exit ${exitCode})\n${stderr.trim()}`);
74
75
  }
75
76
  return {
@@ -1,5 +1,4 @@
1
1
  //#region src/dev-reload.d.ts
2
- declare function notifyCssChange(): void;
3
- declare function withLiveReload(fetchApp: (req: Request) => Promise<Response>): (req: Request) => Promise<Response>;
4
- //#endregion
5
- export { notifyCssChange, withLiveReload };
2
+ export declare function notifyCssChange(): void;
3
+ export declare function withLiveReload(fetchApp: (req: Request) => Promise<Response>): (req: Request) => Promise<Response>;
4
+ //#endregion
package/dist/dev.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  import { JuneHost, ServeHandle } from "./host.js";
2
2
  //#region src/dev.d.ts
3
- type DevServerOptions = {
3
+ export type DevServerOptions = {
4
4
  appDir: string;
5
5
  port?: number;
6
6
  host?: JuneHost;
7
7
  };
8
- type DevServer = ServeHandle & {
8
+ export type DevServer = ServeHandle & {
9
9
  url: string;
10
10
  };
11
- declare function startDevServer({ appDir, port, host }: DevServerOptions): Promise<DevServer>;
12
- //#endregion
13
- export { DevServer, DevServerOptions, startDevServer };
11
+ export declare function startDevServer({ appDir, port, host }: DevServerOptions): Promise<DevServer>;
12
+ //#endregion
package/dist/favicon.d.ts CHANGED
@@ -1,26 +1,26 @@
1
1
  import { DocumentConfig } from "@junejs/core/document";
2
2
  //#region src/favicon.d.ts
3
3
  type Site = DocumentConfig["site"];
4
- declare const ICON_BG = "#1d1d1f";
5
- declare const ICON_FG = "#fbfbf8";
6
- declare const GENERATED_ICONS: readonly ["apple-touch-icon.png", "icon.png", "favicon.ico", "icon-192.png", "icon-512.png"];
7
- type GeneratedIconFile = (typeof GENERATED_ICONS)[number];
8
- declare function publicFileCheck(publicDir: string): (file: string) => boolean;
9
- declare function resolveIcons(site: Site, inPublic: (file: string) => boolean): {
4
+ export declare const ICON_BG = "#1d1d1f";
5
+ export declare const ICON_FG = "#fbfbf8";
6
+ export declare const GENERATED_ICONS: readonly ["apple-touch-icon.png", "icon.png", "favicon.ico", "icon-192.png", "icon-512.png"];
7
+ export type GeneratedIconFile = (typeof GENERATED_ICONS)[number];
8
+ export declare function publicFileCheck(publicDir: string): (file: string) => boolean;
9
+ export declare function resolveIcons(site: Site, inPublic: (file: string) => boolean): {
10
10
  generate: boolean;
11
11
  icons: NonNullable<DocumentConfig["icons"]>;
12
12
  };
13
- declare function hanFamily(lang: string | undefined): string;
14
- declare function iconFamily(ch: string, lang: string | undefined): string | null | undefined;
15
- type FontFetcher = (family: string, text: string) => Promise<Uint8Array | null>;
16
- declare function googleFontFetcher(cacheDir: string, opts?: {
13
+ export declare function hanFamily(lang: string | undefined): string;
14
+ export declare function iconFamily(ch: string, lang: string | undefined): string | null | undefined;
15
+ export type FontFetcher = (family: string, text: string) => Promise<Uint8Array | null>;
16
+ export declare function googleFontFetcher(cacheDir: string, opts?: {
17
17
  fetch?: typeof fetch;
18
18
  timeoutMs?: number;
19
19
  }): FontFetcher;
20
- declare const INK_H = 28;
21
- declare const INK_W = 40;
22
- declare function pngToIco(png: Uint8Array, size: number): Uint8Array<ArrayBuffer>;
23
- type GeneratedIcons = {
20
+ export declare const INK_H = 28;
21
+ export declare const INK_W = 40;
22
+ export declare function pngToIco(png: Uint8Array, size: number): Uint8Array<ArrayBuffer>;
23
+ export type GeneratedIcons = {
24
24
  "apple-touch-icon.png": Uint8Array<ArrayBuffer>;
25
25
  "icon.png": Uint8Array<ArrayBuffer>;
26
26
  "favicon.ico": Uint8Array<ArrayBuffer>;
@@ -29,10 +29,9 @@ type GeneratedIcons = {
29
29
  letter: string;
30
30
  family: string | null;
31
31
  };
32
- declare function renderIcons(opts: {
32
+ export declare function renderIcons(opts: {
33
33
  site: Site;
34
34
  fetchFont: FontFetcher;
35
35
  warn?: (msg: string) => void;
36
36
  }): Promise<GeneratedIcons>;
37
- //#endregion
38
- export { FontFetcher, GENERATED_ICONS, GeneratedIconFile, GeneratedIcons, ICON_BG, ICON_FG, INK_H, INK_W, googleFontFetcher, hanFamily, iconFamily, pngToIco, publicFileCheck, renderIcons, resolveIcons };
37
+ //#endregion
package/dist/host.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { JuneDb, RunResult } from "@junejs/core/resources";
2
2
  //#region src/host.d.ts
3
- type ServeHandle = {
3
+ export type ServeHandle = {
4
4
  port: number;
5
5
  stop(force?: boolean): void;
6
6
  };
7
- type SpawnedModule = {
7
+ export type SpawnedModule = {
8
8
  stdout: ReadableStream<Uint8Array>;
9
9
  stderrText(): Promise<string>;
10
10
  exited: Promise<number>;
11
11
  };
12
- interface JuneHost {
12
+ export interface JuneHost {
13
13
  readonly name: "bun" | "node";
14
14
  serve(handler: (req: Request) => Promise<Response>, opts: {
15
15
  port: number;
@@ -20,6 +20,6 @@ interface JuneHost {
20
20
  }): SpawnedModule;
21
21
  openDb(path: string): Promise<JuneDb>;
22
22
  }
23
- declare const host: JuneHost;
23
+ export declare const host: JuneHost;
24
24
  //#endregion
25
- export { type JuneDb, JuneHost, type RunResult, ServeHandle, SpawnedModule, host };
25
+ export type { JuneDb, RunResult };
@@ -1,4 +1,3 @@
1
1
  //#region src/icon-letter.d.ts
2
- declare function iconLetter(name: string | undefined): string;
3
- //#endregion
4
- export { iconLetter };
2
+ export declare function iconLetter(name: string | undefined): string;
3
+ //#endregion
package/dist/index.d.ts CHANGED
@@ -4,10 +4,10 @@ import { CreateAppOptions, JuneApp, createApp } from "./app.js";
4
4
  import { R2Bucket, localBlob, r2 } from "./blob.js";
5
5
  import { r as scanRoutes } from "./route-scan-DMlwoESy.js";
6
6
  import { t as generateContent } from "./content-freeze-CyiW2fRK.js";
7
- import { a as Pipeline, d as createPipeline, n as LayoutComponent, o as PipelineConfig, s as Resolved, u as RouteResolver } from "./pipeline-cCR6MGNK.js";
8
- import { n as WorkerManifest, r as createWorker } from "./worker-BkFHGtxp.js";
9
- import { t as freezeConfig } from "./config-freeze-DwI-Rmvq.js";
10
- import { n as buildManifest } from "./manifest-gcNWqWoI.js";
7
+ import { a as Pipeline, d as createPipeline, n as LayoutComponent, o as PipelineConfig, s as Resolved, u as RouteResolver } from "./pipeline-BHUjBO0G.js";
8
+ import { n as WorkerManifest, r as createWorker } from "./worker-Dv4l6Ybs.js";
9
+ import { t as freezeConfig } from "./config-freeze-ZWC_Qd4h.js";
10
+ import { n as buildManifest } from "./manifest-DSNX4I-G.js";
11
11
  import { BuildResult, juneBuild } from "./build.js";
12
12
  import { loadJuneConfig } from "./config-loader.js";
13
13
  import { AccountTokenStore, BetterAuthLike, ConnectionAuth, LinkedAccountAuthOptions, betterAuthAccessToken, betterAuthAccountTokenStore, linkedAccountAuth } from "./connection-auth.js";
@@ -1,4 +1,3 @@
1
1
  //#region src/instrumentation.d.ts
2
- declare function installAsyncContext(): Promise<boolean>;
3
- //#endregion
4
- export { installAsyncContext };
2
+ export declare function installAsyncContext(): Promise<boolean>;
3
+ //#endregion
@@ -4,7 +4,8 @@ let installed = false;
4
4
  async function installAsyncContext() {
5
5
  if (installed) return true;
6
6
  try {
7
- installTraceContext(new (await (import("node:async_hooks"))).AsyncLocalStorage());
7
+ const mod = await import("node:async_hooks");
8
+ installTraceContext(new mod.AsyncLocalStorage());
8
9
  installed = true;
9
10
  return true;
10
11
  } catch {
@@ -1,8 +1,7 @@
1
1
  //#region src/island-registry.d.ts
2
- declare const ISLAND_REGISTRY_FILE = "_islands.gen.ts";
3
- declare function walk(dir: string): string[];
4
- declare function firstStatementIsDirective(src: string, directive: string): boolean;
5
- declare function exportNames(src: string): string[];
6
- declare function generateIslandRegistry(appDir: string): Promise<number>;
7
- //#endregion
8
- export { ISLAND_REGISTRY_FILE, exportNames, firstStatementIsDirective, generateIslandRegistry, walk };
2
+ export declare const ISLAND_REGISTRY_FILE = "_islands.gen.ts";
3
+ export declare function walk(dir: string): string[];
4
+ export declare function firstStatementIsDirective(src: string, directive: string): boolean;
5
+ export declare function exportNames(src: string): string[];
6
+ export declare function generateIslandRegistry(appDir: string): Promise<number>;
7
+ //#endregion
@@ -1,6 +1,5 @@
1
1
  //#region src/isolate-local.d.ts
2
- type IsolateLocal = <T>(key: string | symbol, make: () => T) => T;
3
- declare function makeIsolateLocalFallback(): IsolateLocal;
4
- declare const isolateLocal: IsolateLocal;
5
- //#endregion
6
- export { IsolateLocal, isolateLocal, makeIsolateLocalFallback };
2
+ export type IsolateLocal = <T>(key: string | symbol, make: () => T) => T;
3
+ export declare function makeIsolateLocalFallback(): IsolateLocal;
4
+ export declare const isolateLocal: IsolateLocal;
5
+ //#endregion
package/dist/kv.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { KvFactory } from "@junejs/core/resources";
2
2
  //#region src/kv.d.ts
3
- declare function memoryKv(): KvFactory;
4
- declare function redisKv(opts: {
3
+ export declare function memoryKv(): KvFactory;
4
+ export declare function redisKv(opts: {
5
5
  url: string;
6
6
  }): KvFactory;
7
- //#endregion
8
- export { memoryKv, redisKv };
7
+ //#endregion
@@ -1,6 +1,9 @@
1
- import { u as RouteResolver } from "./pipeline-cCR6MGNK.js";
2
- import { LlmsLink } from "@junejs/core/discovery";
1
+ import { u as RouteResolver } from "./pipeline-BHUjBO0G.js";
2
+ import { LlmsLink, SitemapPage } from "@junejs/core/discovery";
3
3
  //#region src/llms-links.d.ts
4
- declare function collectLlmsLinks(origin: string, routes: string[], resolve: RouteResolver): Promise<LlmsLink[]>;
5
- //#endregion
6
- export { collectLlmsLinks };
4
+ export declare function collectLlmsLinks(origin: string, routes: string[], resolve: RouteResolver): Promise<LlmsLink[]>;
5
+ export declare function collectSitemapPages(routes: string[], resolve: RouteResolver, opts?: {
6
+ i18n?: boolean;
7
+ staticPaths?: boolean;
8
+ }): Promise<SitemapPage[]>;
9
+ //#endregion
@@ -31,5 +31,35 @@ async function collectLlmsLinks(origin, routes, resolve) {
31
31
  }
32
32
  return links;
33
33
  }
34
+ async function collectSitemapPages(routes, resolve, opts = {}) {
35
+ const pages = /* @__PURE__ */ new Map();
36
+ const add = (path, lastModified) => {
37
+ const key = path === "/" ? "/" : path.replace(/\/+$/, "");
38
+ const prev = pages.get(key);
39
+ if (!prev) pages.set(key, lastModified ? {
40
+ path: key,
41
+ lastModified
42
+ } : { path: key });
43
+ else if (lastModified && !prev.lastModified) prev.lastModified = lastModified;
44
+ };
45
+ for (const route of routes) {
46
+ const resolved = await resolve(route);
47
+ if (!resolved || !("def" in resolved)) continue;
48
+ const { def } = resolved;
49
+ const dynamic = route.includes("[");
50
+ const declared = def.llms ? typeof def.llms === "function" ? await def.llms() : def.llms : void 0;
51
+ const entries = declared ? Array.isArray(declared) ? declared : [declared] : [];
52
+ if (!dynamic) {
53
+ add(route, entries.find((e) => (e.path ?? route) === route)?.lastModified);
54
+ continue;
55
+ }
56
+ for (const e of entries) if (e.path) add(e.path, e.lastModified);
57
+ if (opts.staticPaths && !opts.i18n && def.staticPaths) {
58
+ const sp = typeof def.staticPaths === "function" ? await def.staticPaths() : def.staticPaths;
59
+ for (const p of sp) add(p);
60
+ }
61
+ }
62
+ return [...pages.values()];
63
+ }
34
64
  //#endregion
35
- export { collectLlmsLinks };
65
+ export { collectLlmsLinks, collectSitemapPages };
@@ -1,5 +1,5 @@
1
- import { n as LayoutComponent } from "./pipeline-cCR6MGNK.js";
2
- import { n as WorkerManifest } from "./worker-BkFHGtxp.js";
1
+ import { n as LayoutComponent } from "./pipeline-BHUjBO0G.js";
2
+ import { n as WorkerManifest } from "./worker-Dv4l6Ybs.js";
3
3
  //#region src/manifest.d.ts
4
4
  type ImportedLayout = {
5
5
  component: LayoutComponent;
@@ -1,2 +1,2 @@
1
- import { n as buildManifest, r as importLayout, t as ImportedLayout } from "./manifest-gcNWqWoI.js";
1
+ import { n as buildManifest, r as importLayout, t as ImportedLayout } from "./manifest-DSNX4I-G.js";
2
2
  export { ImportedLayout, buildManifest, importLayout };
@@ -1,11 +1,12 @@
1
1
  import { RenderTarget } from "@junejs/core/route";
2
2
  import { FRAGMENT_ACCEPT, SEGMENT_HEADER, TITLE_HEADER, encodeTitle } from "@junejs/core/nav-protocol";
3
3
  //#region src/negotiate.d.ts
4
- type Negotiated = {
4
+ export declare function acceptTarget(accept: string): RenderTarget | null;
5
+ export type Negotiated = {
5
6
  target: RenderTarget;
6
7
  pathname: string;
7
8
  speculative: boolean;
8
9
  };
9
- declare function negotiate(url: URL, request: Request, basePath?: string): Negotiated;
10
+ export declare function negotiate(url: URL, request: Request, basePath?: string): Negotiated;
10
11
  //#endregion
11
- export { FRAGMENT_ACCEPT, Negotiated, SEGMENT_HEADER, TITLE_HEADER, encodeTitle, negotiate };
12
+ export { FRAGMENT_ACCEPT, SEGMENT_HEADER, TITLE_HEADER, encodeTitle };
package/dist/negotiate.js CHANGED
@@ -1,14 +1,30 @@
1
- import { FRAGMENT_ACCEPT, SEGMENT_HEADER, TITLE_HEADER, encodeTitle } from "@junejs/core/nav-protocol";
1
+ import { FRAGMENT_ACCEPT, FRAGMENT_ACCEPT as FRAGMENT_ACCEPT$1, SEGMENT_HEADER, TITLE_HEADER, encodeTitle } from "@junejs/core/nav-protocol";
2
2
  //#region src/negotiate.ts
3
3
  const EXT_TARGET = {
4
4
  ".json": "json",
5
5
  ".md": "md"
6
6
  };
7
- const ACCEPT_TARGET = [
8
- [/text\/vnd\.june\.fragment\+html/, "fragment"],
9
- [/text\/markdown/, "md"],
10
- [/application\/json/, "json"]
11
- ];
7
+ const QVALUE = /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/;
8
+ function acceptRanges(accept) {
9
+ const ranges = /* @__PURE__ */ new Map();
10
+ for (const part of accept.split(",")) {
11
+ const [type, ...params] = part.split(";").map((s) => s.trim().toLowerCase());
12
+ if (!type) continue;
13
+ const raw = params.find((p) => p.startsWith("q="))?.slice(2).trim();
14
+ ranges.set(type, raw !== void 0 && QVALUE.test(raw) ? Number(raw) : 1);
15
+ }
16
+ return ranges;
17
+ }
18
+ function acceptTarget(accept) {
19
+ const ranges = acceptRanges(accept);
20
+ if ((ranges.get(FRAGMENT_ACCEPT$1) ?? 0) > 0) return "fragment";
21
+ const html = ranges.get("text/html") ?? ranges.get("text/*") ?? ranges.get("*/*") ?? 0;
22
+ const md = ranges.get("text/markdown") ?? 0;
23
+ const json = ranges.get("application/json") ?? 0;
24
+ const best = Math.max(md, json);
25
+ if (best <= 0 || best < html) return null;
26
+ return md >= json ? "md" : "json";
27
+ }
12
28
  function negotiate(url, request, basePath) {
13
29
  const original = basePath ?? url.pathname;
14
30
  let pathname = original;
@@ -20,13 +36,7 @@ function negotiate(url, request, basePath) {
20
36
  }
21
37
  if (pathname === "/index") pathname = "/";
22
38
  else if (target && pathname === "/") pathname = original;
23
- if (!target) {
24
- const accept = request.headers.get("accept") ?? "";
25
- for (const [re, t] of ACCEPT_TARGET) if (re.test(accept)) {
26
- target = t;
27
- break;
28
- }
29
- }
39
+ if (!target) target = acceptTarget(request.headers.get("accept") ?? "");
30
40
  const purpose = request.headers.get("sec-purpose") ?? "";
31
41
  const speculative = /prefetch|prerender/.test(purpose);
32
42
  return {
@@ -36,4 +46,4 @@ function negotiate(url, request, basePath) {
36
46
  };
37
47
  }
38
48
  //#endregion
39
- export { FRAGMENT_ACCEPT, SEGMENT_HEADER, TITLE_HEADER, encodeTitle, negotiate };
49
+ export { FRAGMENT_ACCEPT, SEGMENT_HEADER, TITLE_HEADER, acceptTarget, encodeTitle, negotiate };
@@ -31,6 +31,7 @@ type PipelineConfig = {
31
31
  i18n?: I18nConfig;
32
32
  routeList: () => Promise<string[]> | string[];
33
33
  resolve: RouteResolver;
34
+ staticBuild?: boolean;
34
35
  resources?: () => Promise<Resources> | Resources;
35
36
  services?: () => Promise<unknown> | unknown;
36
37
  identity?: (request: Request) => Promise<{
@@ -53,6 +54,9 @@ type ExtraHandler = MiddlewareHandler;
53
54
  type Pipeline = {
54
55
  fetch(request: Request): Promise<Response>;
55
56
  };
57
+ declare function markdownPath(pathname: string, isHome: boolean): string;
58
+ declare function htmlPath(pathname: string, isHome: boolean): string;
59
+ declare function isDecodablePath(pathname: string): boolean;
56
60
  declare function createPipeline(cfg: PipelineConfig): Pipeline;
57
61
  //#endregion
58
- export { Pipeline as a, ResolvedResource as c, createPipeline as d, MiddlewareHandler as i, ResourceHandler as l, LayoutComponent as n, PipelineConfig as o, LoadingComponent as r, Resolved as s, ExtraHandler as t, RouteResolver as u };
62
+ export { Pipeline as a, ResolvedResource as c, createPipeline as d, htmlPath as f, MiddlewareHandler as i, ResourceHandler as l, markdownPath as m, LayoutComponent as n, PipelineConfig as o, isDecodablePath as p, LoadingComponent as r, Resolved as s, ExtraHandler as t, RouteResolver as u };
@@ -1,2 +1,2 @@
1
- import { a as Pipeline, c as ResolvedResource, d as createPipeline, i as MiddlewareHandler, l as ResourceHandler, n as LayoutComponent, o as PipelineConfig, r as LoadingComponent, s as Resolved, t as ExtraHandler, u as RouteResolver } from "./pipeline-cCR6MGNK.js";
2
- export { ExtraHandler, LayoutComponent, LoadingComponent, MiddlewareHandler, Pipeline, PipelineConfig, Resolved, ResolvedResource, ResourceHandler, RouteResolver, createPipeline };
1
+ import { a as Pipeline, c as ResolvedResource, d as createPipeline, f as htmlPath, i as MiddlewareHandler, l as ResourceHandler, m as markdownPath, n as LayoutComponent, o as PipelineConfig, p as isDecodablePath, r as LoadingComponent, s as Resolved, t as ExtraHandler, u as RouteResolver } from "./pipeline-BHUjBO0G.js";
2
+ export { ExtraHandler, LayoutComponent, LoadingComponent, MiddlewareHandler, Pipeline, PipelineConfig, Resolved, ResolvedResource, ResourceHandler, RouteResolver, createPipeline, htmlPath, isDecodablePath, markdownPath };