@junejs/server 0.1.3 → 0.2.1
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-D0UnYBuN.d.ts +64 -0
- package/dist/adapter.d.ts +2 -56
- package/dist/adapter.js +107 -6
- 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/assets.d.ts +23 -0
- package/dist/assets.js +123 -0
- package/dist/blob.d.ts +4 -5
- package/dist/build.d.ts +8 -30
- package/dist/build.js +143 -298
- package/dist/client-bundle.d.ts +8 -9
- package/dist/client-bundle.js +1 -1
- package/dist/config-freeze-r5p-vTWv.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 +6 -7
- 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 +51 -38
- 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 -57
- package/dist/worker.js +69 -27
- package/package.json +28 -9
- package/src/adapter.ts +149 -4
- 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/assets.ts +200 -0
- package/src/build.ts +241 -449
- 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-scan.ts +161 -0
- package/src/router.ts +66 -54
- 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 +131 -35
package/dist/assets.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
//#region src/assets.ts
|
|
4
|
+
const STALE_TEMP_MS = 36e5;
|
|
5
|
+
const TEMP_PREFIX = ".june-tmp-";
|
|
6
|
+
function assetCache(opts) {
|
|
7
|
+
const fetcher = opts.fetch ?? fetch;
|
|
8
|
+
const urlsFor = opts.urls ?? ((ref) => ref.urls);
|
|
9
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
10
|
+
let swept;
|
|
11
|
+
const pathOf = (ref) => join(opts.dir, safeName(ref.name));
|
|
12
|
+
async function readMatching(ref) {
|
|
13
|
+
const path = pathOf(ref);
|
|
14
|
+
let info;
|
|
15
|
+
try {
|
|
16
|
+
info = await stat(path);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
if (err.code === "ENOENT") return void 0;
|
|
19
|
+
throw err;
|
|
20
|
+
}
|
|
21
|
+
if (!info.isFile()) throw new Error(`${path} is in the way of ${ref.name}: it isn't a file`);
|
|
22
|
+
if (info.size !== ref.size) return void 0;
|
|
23
|
+
const bytes = new Uint8Array(await readFile(path));
|
|
24
|
+
return await sha256(bytes) === ref.sha256 ? bytes : void 0;
|
|
25
|
+
}
|
|
26
|
+
async function get(ref) {
|
|
27
|
+
pathOf(ref);
|
|
28
|
+
const hit = await readMatching(ref);
|
|
29
|
+
if (hit) return hit;
|
|
30
|
+
if (opts.offline) {
|
|
31
|
+
const state = await stat(pathOf(ref)).then(() => true, () => false) ? `in ${opts.dir} but doesn't match` : `not in ${opts.dir}`;
|
|
32
|
+
throw new Error(`${ref.name} is ${state}, and this cache is offline: copy the file with sha256 ${ref.sha256} (${ref.size} bytes) to ${pathOf(ref)} — it is at ${ref.urls.join(" or ")}`);
|
|
33
|
+
}
|
|
34
|
+
await (swept ??= sweepTemps(opts.dir).catch(() => {}));
|
|
35
|
+
const bytes = await download(ref, urlsFor(ref), fetcher);
|
|
36
|
+
await mkdir(opts.dir, { recursive: true });
|
|
37
|
+
const temp = join(opts.dir, `${TEMP_PREFIX}${crypto.randomUUID()}-${safeName(ref.name)}`);
|
|
38
|
+
try {
|
|
39
|
+
await writeFile(temp, bytes);
|
|
40
|
+
await rename(temp, pathOf(ref));
|
|
41
|
+
} catch (err) {
|
|
42
|
+
await rm(temp, { force: true }).catch(() => {});
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
return bytes;
|
|
46
|
+
}
|
|
47
|
+
const cache = ((ref) => {
|
|
48
|
+
const key = `${ref.name}\0${ref.sha256}\0${ref.size}`;
|
|
49
|
+
const running = inflight.get(key);
|
|
50
|
+
if (running) return running;
|
|
51
|
+
const p = get(ref).finally(() => inflight.delete(key));
|
|
52
|
+
inflight.set(key, p);
|
|
53
|
+
return p;
|
|
54
|
+
});
|
|
55
|
+
cache.cached = async (ref) => await readMatching(ref) !== void 0;
|
|
56
|
+
cache.egress = async (refs) => {
|
|
57
|
+
if (opts.offline) return [];
|
|
58
|
+
const missing = (await Promise.all(refs.map(async (r) => await cache.cached(r) ? [] : urlsFor(r)))).flat();
|
|
59
|
+
return [...new Set(missing.map((u) => new URL(u).host))].map((host) => ({
|
|
60
|
+
host,
|
|
61
|
+
sends: "nothing"
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
return cache;
|
|
65
|
+
}
|
|
66
|
+
async function download(ref, urls, fetcher) {
|
|
67
|
+
const failures = [];
|
|
68
|
+
for (const url of urls) try {
|
|
69
|
+
const res = await fetcher(url);
|
|
70
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
71
|
+
const declared = Number(res.headers.get("content-length") ?? NaN);
|
|
72
|
+
if (declared > ref.size) throw new Error(`${declared} bytes declared, expected ${ref.size}`);
|
|
73
|
+
const bytes = await readCapped(res, ref.size);
|
|
74
|
+
const digest = await sha256(bytes);
|
|
75
|
+
if (bytes.length !== ref.size || digest !== ref.sha256) throw new Error(`got ${bytes.length} bytes with sha256 ${digest}, expected ${ref.size} with ${ref.sha256}`);
|
|
76
|
+
return bytes;
|
|
77
|
+
} catch (err) {
|
|
78
|
+
failures.push(`${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
79
|
+
}
|
|
80
|
+
throw new Error(`${ref.name} could not be fetched (${failures.join("; ") || "no URLs"}). To run without the network, copy the file into the cache directory and pass offline: true`);
|
|
81
|
+
}
|
|
82
|
+
async function readCapped(res, size) {
|
|
83
|
+
if (!res.body) return new Uint8Array(await res.arrayBuffer());
|
|
84
|
+
const out = new Uint8Array(size + 1);
|
|
85
|
+
let length = 0;
|
|
86
|
+
const reader = res.body.getReader();
|
|
87
|
+
for (;;) {
|
|
88
|
+
const { done, value } = await reader.read();
|
|
89
|
+
if (done) break;
|
|
90
|
+
if (length + value.length >= out.length) {
|
|
91
|
+
out.set(value.subarray(0, out.length - length), length);
|
|
92
|
+
length = out.length;
|
|
93
|
+
await reader.cancel();
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
out.set(value, length);
|
|
97
|
+
length += value.length;
|
|
98
|
+
}
|
|
99
|
+
return out.subarray(0, length);
|
|
100
|
+
}
|
|
101
|
+
async function sha256(bytes) {
|
|
102
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
103
|
+
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
104
|
+
}
|
|
105
|
+
function safeName(name) {
|
|
106
|
+
if (!name || name === "." || name === ".." || /[\\/]/.test(name) || name.startsWith(TEMP_PREFIX)) throw new Error(`unsafe asset name: ${JSON.stringify(name)}`);
|
|
107
|
+
return name;
|
|
108
|
+
}
|
|
109
|
+
async function sweepTemps(dir) {
|
|
110
|
+
let names;
|
|
111
|
+
try {
|
|
112
|
+
names = await readdir(dir);
|
|
113
|
+
} catch {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const now = Date.now();
|
|
117
|
+
await Promise.all(names.filter((n) => n.startsWith(TEMP_PREFIX)).map(async (n) => {
|
|
118
|
+
const s = await stat(join(dir, n)).catch(() => void 0);
|
|
119
|
+
if (s && now - s.mtimeMs > STALE_TEMP_MS) await rm(join(dir, n), { force: true });
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { assetCache };
|
package/dist/blob.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BlobFactory } from "@junejs/core/resources";
|
|
2
2
|
//#region src/blob.d.ts
|
|
3
|
-
declare function localBlob(opts?: {
|
|
3
|
+
export declare function localBlob(opts?: {
|
|
4
4
|
dir?: string;
|
|
5
5
|
}): BlobFactory;
|
|
6
6
|
interface R2ObjectBody {
|
|
7
7
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
8
8
|
}
|
|
9
|
-
interface R2Bucket {
|
|
9
|
+
export interface R2Bucket {
|
|
10
10
|
get(key: string): Promise<R2ObjectBody | null>;
|
|
11
11
|
put(key: string, data: ArrayBuffer | Uint8Array | string): Promise<unknown>;
|
|
12
12
|
delete(key: string): Promise<void>;
|
|
@@ -18,6 +18,5 @@ interface R2Bucket {
|
|
|
18
18
|
}[];
|
|
19
19
|
}>;
|
|
20
20
|
}
|
|
21
|
-
declare function r2(bucket: R2Bucket): BlobFactory;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { R2Bucket, localBlob, r2 };
|
|
21
|
+
export declare function r2(bucket: R2Bucket): BlobFactory;
|
|
22
|
+
//#endregion
|
package/dist/build.d.ts
CHANGED
|
@@ -1,41 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { a as scanAppRoutes, o as scanRoutes, t as RouteEntry } from "./route-scan-BMbBzPIB.js";
|
|
2
|
+
import { t as generateContent } from "./content-freeze-CyiW2fRK.js";
|
|
3
|
+
import { i as workerName, n as normalizeBase, r as resolveDeployAdapter, t as freezeConfig } from "./config-freeze-r5p-vTWv.js";
|
|
4
|
+
import { n as buildManifest } from "./manifest-CwTT1zVs.js";
|
|
5
5
|
//#region src/build.d.ts
|
|
6
|
-
type BuildResult = {
|
|
6
|
+
export type BuildResult = {
|
|
7
7
|
outFile: string;
|
|
8
8
|
routes: string[];
|
|
9
9
|
dynamicRoutes: string[];
|
|
10
10
|
contentCollections: string[];
|
|
11
11
|
prerendered: string[];
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
file: string;
|
|
16
|
-
dynamic: boolean;
|
|
17
|
-
resource?: boolean;
|
|
18
|
-
generated?: boolean;
|
|
19
|
-
layouts: string[];
|
|
20
|
-
loading?: string;
|
|
21
|
-
};
|
|
22
|
-
declare const isBunSpecifier: (id: string) => boolean;
|
|
23
|
-
declare function resolveDeployAdapter(deploy: JuneConfig["deploy"]): JuneAdapter;
|
|
24
|
-
declare function scanRoutes(appDir: string, dir?: string, layouts?: string[], out?: RouteEntry[], loading?: string): Promise<RouteEntry[]>;
|
|
25
|
-
declare function generateContent(appRoot: string): Promise<string[]>;
|
|
26
|
-
declare function freezeConfig(appRoot: string): Promise<{
|
|
27
|
-
document: DocumentConfig;
|
|
28
|
-
agent: WorkerManifest["agent"];
|
|
29
|
-
i18n: WorkerManifest["i18n"];
|
|
30
|
-
earlyHints: string[];
|
|
31
|
-
buildExternal: string[];
|
|
32
|
-
}>;
|
|
33
|
-
declare function normalizeBase(base?: string): string;
|
|
34
|
-
declare function workerName(raw: string): string;
|
|
35
|
-
declare function buildManifest(appRoot: string): Promise<WorkerManifest>;
|
|
36
|
-
declare function juneBuild(appRoot: string, options?: {
|
|
13
|
+
export declare const isBunSpecifier: (id: string) => boolean;
|
|
14
|
+
export declare function juneBuild(appRoot: string, options?: {
|
|
37
15
|
outDir?: string;
|
|
38
16
|
external?: string[];
|
|
39
17
|
}): Promise<BuildResult>;
|
|
40
18
|
//#endregion
|
|
41
|
-
export {
|
|
19
|
+
export { type RouteEntry, buildManifest, freezeConfig, generateContent, normalizeBase, resolveDeployAdapter, scanAppRoutes, scanRoutes, workerName };
|