@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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { deno, staticSite, vercel, workers } from "./adapter.js";
|
|
2
|
+
import { CLIENT_SCRIPT_URL, findClientEntry } from "./client-bundle.js";
|
|
3
|
+
import { STYLES_URL, findGlobalCss, globalCssUsesTailwind } from "./css.js";
|
|
4
|
+
import { publicFileCheck, resolveIcons } from "./favicon.js";
|
|
5
|
+
import { loadJuneConfig } from "./config-loader.js";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { deployOrigin, resolveAgent, resolveClientRouter, resolveSpeculationRules } from "@junejs/core/config";
|
|
8
|
+
//#region src/config-freeze.ts
|
|
9
|
+
function resolveDeployAdapter(deploy) {
|
|
10
|
+
if (deploy?.adapter) return deploy.adapter;
|
|
11
|
+
switch (deploy?.target) {
|
|
12
|
+
case "static": return staticSite();
|
|
13
|
+
case "vercel": return vercel();
|
|
14
|
+
case "deno": return deno();
|
|
15
|
+
default: return workers({
|
|
16
|
+
name: deploy?.name,
|
|
17
|
+
domain: deploy?.domain
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function freezeConfig(appRoot) {
|
|
22
|
+
const cfg = await loadJuneConfig(appRoot);
|
|
23
|
+
const hasClient = findClientEntry(join(appRoot, "app")) !== void 0 || findClientEntry(join(appRoot, ".june", "routes")) !== void 0;
|
|
24
|
+
const hasCss = findGlobalCss(join(appRoot, "app")) !== null;
|
|
25
|
+
return {
|
|
26
|
+
document: {
|
|
27
|
+
site: cfg.site ?? {},
|
|
28
|
+
deployOrigin: deployOrigin(cfg),
|
|
29
|
+
speculationRules: resolveSpeculationRules(cfg.speculation ?? void 0),
|
|
30
|
+
speculationDelivery: "inline",
|
|
31
|
+
viewTransitions: cfg.viewTransitions ?? true,
|
|
32
|
+
cssReset: cfg.cssReset ?? !globalCssUsesTailwind(join(appRoot, "app")),
|
|
33
|
+
clientRouter: resolveClientRouter(cfg.clientRouter),
|
|
34
|
+
clientScript: hasClient ? CLIENT_SCRIPT_URL : null,
|
|
35
|
+
styles: hasCss ? STYLES_URL : null,
|
|
36
|
+
basePath: normalizeBase(cfg.basePath),
|
|
37
|
+
icons: resolveIcons(cfg.site ?? {}, publicFileCheck(join(appRoot, "public"))).icons
|
|
38
|
+
},
|
|
39
|
+
agent: resolveAgent(cfg.agent),
|
|
40
|
+
i18n: cfg.i18n,
|
|
41
|
+
earlyHints: cfg.earlyHints ?? [],
|
|
42
|
+
buildExternal: cfg.build?.external ?? []
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function normalizeBase(base) {
|
|
46
|
+
if (!base) return "";
|
|
47
|
+
const b = base.startsWith("/") ? base : `/${base}`;
|
|
48
|
+
return b.endsWith("/") ? b.slice(0, -1) : b;
|
|
49
|
+
}
|
|
50
|
+
function workerName(raw) {
|
|
51
|
+
return raw.replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "app";
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { freezeConfig, normalizeBase, resolveDeployAdapter, workerName };
|
package/dist/config-loader.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { JuneConfig } from "@junejs/core/config";
|
|
|
3
3
|
/** The config file loadJuneConfig would import, or null. Exported so callers that need a FRESH
|
|
4
4
|
* load (a subprocess probe — see generateContent's bootstrap retry) target the same file the
|
|
5
5
|
* in-process loader would. */
|
|
6
|
-
declare function findJuneConfigPath(appDir: string): string | null;
|
|
7
|
-
declare function loadJuneConfig(appDir: string): Promise<JuneConfig>;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { findJuneConfigPath, loadJuneConfig };
|
|
6
|
+
export declare function findJuneConfigPath(appDir: string): string | null;
|
|
7
|
+
export declare function loadJuneConfig(appDir: string): Promise<JuneConfig>;
|
|
8
|
+
//#endregion
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ActionContext } from "@junejs/core/context";
|
|
2
|
+
//#region src/connection-auth.d.ts
|
|
3
|
+
export type AccountTokenStore = (args: {
|
|
4
|
+
userId: string;
|
|
5
|
+
providerId: string;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
accessToken: string;
|
|
8
|
+
} | null> | {
|
|
9
|
+
accessToken: string;
|
|
10
|
+
} | null;
|
|
11
|
+
export type LinkedAccountAuthOptions = {
|
|
12
|
+
providerId: string;
|
|
13
|
+
store: AccountTokenStore;
|
|
14
|
+
};
|
|
15
|
+
export type ConnectionAuth = (ctx?: ActionContext) => Promise<{
|
|
16
|
+
token: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function linkedAccountAuth(opts: LinkedAccountAuthOptions): ConnectionAuth;
|
|
19
|
+
export type BetterAuthLike = {
|
|
20
|
+
api: {
|
|
21
|
+
getAccessToken: (input: {
|
|
22
|
+
body: {
|
|
23
|
+
providerId: string;
|
|
24
|
+
userId?: string;
|
|
25
|
+
accountId?: string;
|
|
26
|
+
};
|
|
27
|
+
headers?: HeadersInit;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
accessToken?: string;
|
|
30
|
+
token?: string;
|
|
31
|
+
} | null | undefined>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare function betterAuthAccountTokenStore(auth: BetterAuthLike): AccountTokenStore;
|
|
35
|
+
export declare function betterAuthAccessToken(auth: BetterAuthLike, opts: {
|
|
36
|
+
providerId: string;
|
|
37
|
+
}): ConnectionAuth;
|
|
38
|
+
//#endregion
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/connection-auth.ts
|
|
2
|
+
function linkedAccountAuth(opts) {
|
|
3
|
+
return async (ctx) => {
|
|
4
|
+
const userId = ctx?.user?.id;
|
|
5
|
+
if (!userId) throw new Error(`connection auth (${opts.providerId}): no authenticated principal — set requiresPrincipal and resolve identity on the surface`);
|
|
6
|
+
const record = await opts.store({
|
|
7
|
+
userId,
|
|
8
|
+
providerId: opts.providerId
|
|
9
|
+
});
|
|
10
|
+
if (!record?.accessToken) throw new Error(`connection auth (${opts.providerId}): user "${userId}" has no linked "${opts.providerId}" account`);
|
|
11
|
+
return { token: record.accessToken };
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function betterAuthAccountTokenStore(auth) {
|
|
15
|
+
return async ({ userId, providerId }) => {
|
|
16
|
+
const res = await auth.api.getAccessToken({ body: {
|
|
17
|
+
providerId,
|
|
18
|
+
userId
|
|
19
|
+
} });
|
|
20
|
+
const accessToken = res?.accessToken ?? res?.token;
|
|
21
|
+
return accessToken ? { accessToken } : null;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function betterAuthAccessToken(auth, opts) {
|
|
25
|
+
return linkedAccountAuth({
|
|
26
|
+
providerId: opts.providerId,
|
|
27
|
+
store: betterAuthAccountTokenStore(auth)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { betterAuthAccessToken, betterAuthAccountTokenStore, linkedAccountAuth };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { findJuneConfigPath, loadJuneConfig } from "./config-loader.js";
|
|
2
|
+
import { generateContentModule } from "./content.js";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
|
+
import { join, resolve } from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import { execFileSync } from "node:child_process";
|
|
8
|
+
//#region src/content-freeze.ts
|
|
9
|
+
async function generateContent(appRoot) {
|
|
10
|
+
const contentDir = join(appRoot, "content");
|
|
11
|
+
await mkdir(join(appRoot, "app"), { recursive: true });
|
|
12
|
+
const emit = async (sources, knownLocales) => {
|
|
13
|
+
const { code, names } = generateContentModule(contentDir, knownLocales, sources);
|
|
14
|
+
await writeFile(join(appRoot, "app", "_content.ts"), code);
|
|
15
|
+
return names;
|
|
16
|
+
};
|
|
17
|
+
const resolveSources = (sources) => sources.map((s) => ({
|
|
18
|
+
...s,
|
|
19
|
+
dir: resolve(appRoot, s.dir)
|
|
20
|
+
}));
|
|
21
|
+
const declaredLocales = (config) => config.i18n ? [.../* @__PURE__ */ new Set([config.i18n.defaultLocale, ...Object.keys(config.i18n.locales)])] : [];
|
|
22
|
+
let config = null;
|
|
23
|
+
try {
|
|
24
|
+
config = await loadJuneConfig(appRoot);
|
|
25
|
+
} catch {}
|
|
26
|
+
if (config) return emit(resolveSources(config.content?.sources ?? []), declaredLocales(config));
|
|
27
|
+
const names = await emit([], void 0);
|
|
28
|
+
await seedContentImports(appRoot);
|
|
29
|
+
const probed = probeConfigFresh(appRoot);
|
|
30
|
+
if (probed === null) {
|
|
31
|
+
console.warn("[june gen] june.config.ts failed to load — content.sources/i18n locales (if any) not applied");
|
|
32
|
+
return names;
|
|
33
|
+
}
|
|
34
|
+
return emit(resolveSources(probed.sources), probed.locales);
|
|
35
|
+
}
|
|
36
|
+
async function seedContentImports(appRoot) {
|
|
37
|
+
const cfgPath = findJuneConfigPath(appRoot);
|
|
38
|
+
if (!cfgPath) return;
|
|
39
|
+
const contentFile = join(appRoot, "app", "_content.ts");
|
|
40
|
+
const current = existsSync(contentFile) ? await readFile(contentFile, "utf8") : "";
|
|
41
|
+
const cfgSrc = await readFile(cfgPath, "utf8");
|
|
42
|
+
const isIdent = (s) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(s);
|
|
43
|
+
const seen = /* @__PURE__ */ new Set();
|
|
44
|
+
const stubs = [];
|
|
45
|
+
for (const m of cfgSrc.matchAll(/import\s*(?:type\s+)?\{([^}]*)\}\s*from\s*["'][^"']*app\/_content(?:\.\w+)?["']/g)) {
|
|
46
|
+
const inner = (m[1] ?? "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
|
|
47
|
+
for (const part of inner.split(",")) {
|
|
48
|
+
const name = part.replace(/\btype\b/g, "").split(/\s+as\s+/).pop()?.trim();
|
|
49
|
+
if (!name || !isIdent(name) || seen.has(name)) continue;
|
|
50
|
+
seen.add(name);
|
|
51
|
+
const reName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
52
|
+
if (!new RegExp(`export (?:const|function|type) ${reName}\\b`).test(current)) stubs.push(`export const ${name}: ContentEntry[] = [];`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (stubs.length) await writeFile(contentFile, current + stubs.join("\n") + "\n");
|
|
56
|
+
}
|
|
57
|
+
function probeConfigFresh(appRoot) {
|
|
58
|
+
const path = findJuneConfigPath(appRoot);
|
|
59
|
+
if (!path) return {
|
|
60
|
+
sources: [],
|
|
61
|
+
locales: []
|
|
62
|
+
};
|
|
63
|
+
const code = `import(${JSON.stringify(pathToFileURL(path).href)}).then((m) => { const c = m.default ?? {}; process.stdout.write("\\n__JUNE_CONTENT__" + JSON.stringify({ sources: c.content?.sources ?? [], locales: c.i18n ? [...new Set([c.i18n.defaultLocale, ...Object.keys(c.i18n.locales ?? {})])] : [] }) + "__END__"); }, () => process.exit(42));`;
|
|
64
|
+
try {
|
|
65
|
+
const m = execFileSync(process.execPath, [
|
|
66
|
+
...process.execArgv,
|
|
67
|
+
"-e",
|
|
68
|
+
code
|
|
69
|
+
], {
|
|
70
|
+
encoding: "utf8",
|
|
71
|
+
stdio: [
|
|
72
|
+
"ignore",
|
|
73
|
+
"pipe",
|
|
74
|
+
"ignore"
|
|
75
|
+
]
|
|
76
|
+
}).match(/__JUNE_CONTENT__(.*?)__END__/s);
|
|
77
|
+
return m ? JSON.parse(m[1]) : null;
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { generateContent };
|
package/dist/content.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { ContentSource } from "@junejs/core/config";
|
|
2
2
|
//#region src/content.d.ts
|
|
3
|
-
type
|
|
3
|
+
export type Heading = {
|
|
4
|
+
depth: number;
|
|
5
|
+
text: string;
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function headingIds(html: string): {
|
|
9
|
+
html: string;
|
|
10
|
+
headings: Heading[];
|
|
11
|
+
};
|
|
12
|
+
export type ContentEntry = {
|
|
4
13
|
slug: string;
|
|
5
14
|
file: string;
|
|
6
15
|
/** Parsed frontmatter (string values; `tags`-style lists become string[]). */
|
|
@@ -9,31 +18,35 @@ type ContentEntry = {
|
|
|
9
18
|
body: string;
|
|
10
19
|
/** The authored file, verbatim — the agent-facing .md projection. */
|
|
11
20
|
original: string;
|
|
12
|
-
/** The body rendered to HTML (CommonMark + GFM, via @momiji-rs/sparkdown/gfm wasm).
|
|
21
|
+
/** The body rendered to HTML (CommonMark + GFM, via @momiji-rs/sparkdown/gfm wasm).
|
|
22
|
+
* Every heading carries a GitHub-compatible `id` (see @junejs/core/slug) and nothing
|
|
23
|
+
* else — no injected links or classes; how an anchor looks is the app's call. */
|
|
13
24
|
html: string;
|
|
25
|
+
/** The headings of `html`, in document order: their depth (1–6), plain text, and the
|
|
26
|
+
* `id` each carries in `html` — for a table of contents, or a structured projection. */
|
|
27
|
+
headings: Heading[];
|
|
14
28
|
/** The locale this entry was authored in — set for files under a `<locale>/`
|
|
15
29
|
* subdir, undefined for the flat (default-locale) files. */
|
|
16
30
|
locale?: string;
|
|
17
31
|
};
|
|
18
|
-
type ScannedCollection = {
|
|
32
|
+
export type ScannedCollection = {
|
|
19
33
|
default: ContentEntry[];
|
|
20
34
|
byLocale: Record<string, ContentEntry[]>;
|
|
21
35
|
};
|
|
22
|
-
declare function scanCollection(dir: string, knownLocales?: readonly string[]): ScannedCollection;
|
|
36
|
+
export declare function scanCollection(dir: string, knownLocales?: readonly string[]): ScannedCollection;
|
|
23
37
|
/** All entries in a content directory, newest-first by `date` (then slug). With
|
|
24
38
|
* a `locale`, each entry is its locale variant when present, else the default
|
|
25
39
|
* (so a reader sees the whole collection, localized where available). */
|
|
26
|
-
declare function collection(dir: string, locale?: string): ContentEntry[];
|
|
40
|
+
export declare function collection(dir: string, locale?: string): ContentEntry[];
|
|
27
41
|
/** One entry by slug, or null. With a `locale`, prefer `<dir>/<locale>/<slug>`,
|
|
28
42
|
* falling back to the flat default (a dev-warn flags a partial translation).
|
|
29
43
|
* `fallback: false` is STRICT — a missing variant returns null (so a route can
|
|
30
44
|
* 404 rather than serve default-language content). */
|
|
31
|
-
declare function entry(dir: string, slug: string, locale?: string, opts?: {
|
|
45
|
+
export declare function entry(dir: string, slug: string, locale?: string, opts?: {
|
|
32
46
|
fallback?: boolean;
|
|
33
47
|
}): ContentEntry | null;
|
|
34
|
-
declare function generateContentModule(contentDir: string, knownLocales?: readonly string[], sources?: readonly ContentSource[]): {
|
|
48
|
+
export declare function generateContentModule(contentDir: string, knownLocales?: readonly string[], sources?: readonly ContentSource[]): {
|
|
35
49
|
code: string;
|
|
36
50
|
names: string[];
|
|
37
51
|
};
|
|
38
|
-
//#endregion
|
|
39
|
-
export { ContentEntry, ScannedCollection, collection, entry, generateContentModule, scanCollection };
|
|
52
|
+
//#endregion
|
package/dist/content.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { initSync, toHtmlSync } from "@momiji-rs/sparkdown/gfm";
|
|
4
|
+
import { createSlugger } from "@junejs/core/slug";
|
|
4
5
|
//#region src/content.ts
|
|
5
6
|
let wasmReady = false;
|
|
6
7
|
const ensureWasm = () => {
|
|
@@ -9,6 +10,42 @@ const ensureWasm = () => {
|
|
|
9
10
|
wasmReady = true;
|
|
10
11
|
}
|
|
11
12
|
};
|
|
13
|
+
const NAMED = {
|
|
14
|
+
amp: "&",
|
|
15
|
+
lt: "<",
|
|
16
|
+
gt: ">",
|
|
17
|
+
quot: "\"",
|
|
18
|
+
apos: "'"
|
|
19
|
+
};
|
|
20
|
+
const decodeEntities = (s) => s.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (m, e) => e[0] === "#" ? String.fromCodePoint(e[1] === "x" || e[1] === "X" ? parseInt(e.slice(2), 16) : Number(e.slice(1))) : NAMED[e.toLowerCase()] ?? m);
|
|
21
|
+
const ID_ATTR = /\sid\s*=\s*(?:"([^"]*)"|'([^']*)')/i;
|
|
22
|
+
function headingIds(html) {
|
|
23
|
+
const slug = createSlugger();
|
|
24
|
+
const taken = /* @__PURE__ */ new Set();
|
|
25
|
+
for (const m of html.matchAll(new RegExp(ID_ATTR.source, "gi"))) taken.add(m[1] ?? m[2]);
|
|
26
|
+
const headings = [];
|
|
27
|
+
return {
|
|
28
|
+
html: html.replace(/<h([1-6])(\s[^>]*)?>([\s\S]*?)<\/h\1>/gi, (_m, depth, attrs, inner) => {
|
|
29
|
+
const text = decodeEntities(inner.replace(/<[^>]*>/g, "")).trim();
|
|
30
|
+
const own = attrs ? ID_ATTR.exec(attrs) : null;
|
|
31
|
+
const authored = own ? own[1] ?? own[2] : void 0;
|
|
32
|
+
let id = authored;
|
|
33
|
+
if (!id) {
|
|
34
|
+
do
|
|
35
|
+
id = slug(text);
|
|
36
|
+
while (taken.has(id));
|
|
37
|
+
taken.add(id);
|
|
38
|
+
}
|
|
39
|
+
headings.push({
|
|
40
|
+
depth: Number(depth),
|
|
41
|
+
text,
|
|
42
|
+
id
|
|
43
|
+
});
|
|
44
|
+
return authored ? _m : `<h${depth}${(attrs ?? "").replace(ID_ATTR, "")} id="${id}">${inner}</h${depth}>`;
|
|
45
|
+
}),
|
|
46
|
+
headings
|
|
47
|
+
};
|
|
48
|
+
}
|
|
12
49
|
function parseFrontmatter(raw) {
|
|
13
50
|
if (!raw.startsWith("---")) return {
|
|
14
51
|
data: {},
|
|
@@ -48,13 +85,15 @@ function loadEntry(file, slug, locale) {
|
|
|
48
85
|
if (h1?.[1]) data.title = h1[1];
|
|
49
86
|
}
|
|
50
87
|
ensureWasm();
|
|
88
|
+
const { html, headings } = headingIds(toHtmlSync(body));
|
|
51
89
|
const entry = {
|
|
52
90
|
slug,
|
|
53
91
|
file,
|
|
54
92
|
data,
|
|
55
93
|
body,
|
|
56
94
|
original,
|
|
57
|
-
html
|
|
95
|
+
html,
|
|
96
|
+
headings,
|
|
58
97
|
...locale ? { locale } : {}
|
|
59
98
|
};
|
|
60
99
|
memo.set(key, {
|
|
@@ -160,6 +199,7 @@ function generateContentModule(contentDir, knownLocales, sources) {
|
|
|
160
199
|
body: e.body,
|
|
161
200
|
original: e.original,
|
|
162
201
|
html: e.html,
|
|
202
|
+
headings: e.headings,
|
|
163
203
|
...e.locale ? { locale: e.locale } : {}
|
|
164
204
|
});
|
|
165
205
|
const collections = /* @__PURE__ */ new Map();
|
|
@@ -193,9 +233,9 @@ function generateContentModule(contentDir, knownLocales, sources) {
|
|
|
193
233
|
names.push(name);
|
|
194
234
|
}
|
|
195
235
|
return {
|
|
196
|
-
code: "// AUTO-GENERATED by `june build` — edit content/**/*.md, not this file.\n" + (anyLocale ? "export type ContentEntry = { slug: string; data: Record<string, string | string[]>; body: string; original: string; html: string; locale?: string };\n" : "export type ContentEntry = { slug: string; data: Record<string, string | string[]>; body: string; original: string; html: string };\n") + body,
|
|
236
|
+
code: "// AUTO-GENERATED by `june build` — edit content/**/*.md, not this file.\n" + (anyLocale ? "export type ContentEntry = { slug: string; data: Record<string, string | string[]>; body: string; original: string; html: string; headings: Array<{ depth: number; text: string; id: string }>; locale?: string };\n" : "export type ContentEntry = { slug: string; data: Record<string, string | string[]>; body: string; original: string; html: string; headings: Array<{ depth: number; text: string; id: string }> };\n") + body,
|
|
197
237
|
names
|
|
198
238
|
};
|
|
199
239
|
}
|
|
200
240
|
//#endregion
|
|
201
|
-
export { collection, entry, generateContentModule, scanCollection };
|
|
241
|
+
export { collection, entry, generateContentModule, headingIds, scanCollection };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as coreRuntime from "@junejs/core/agent-runtime";
|
|
2
|
+
//#region src/core-version.ts
|
|
3
|
+
const EXPECTED_CORE_RUNTIME_API = 7;
|
|
4
|
+
function assertCoreRuntimeVersion(surface) {
|
|
5
|
+
checkCoreRuntimeVersion(surface, coreRuntime.RUNTIME_API_VERSION);
|
|
6
|
+
}
|
|
7
|
+
function checkCoreRuntimeVersion(surface, actual, expected = EXPECTED_CORE_RUNTIME_API) {
|
|
8
|
+
if (actual === expected) return;
|
|
9
|
+
throw new Error(`${surface}: @junejs/server is built against @junejs/core runtime API v${expected}, but the @junejs/core it resolved provides ${actual === void 0 ? "no RUNTIME_API_VERSION (a pre-0.1.1-dev.16 core)" : `v${actual}`} — two copies of @junejs/core are likely installed (one nested under @junejs/server). Align the app's @junejs/core with @junejs/server's peer range, then reinstall/dedupe so one copy remains.`);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { assertCoreRuntimeVersion, checkCoreRuntimeVersion };
|
package/dist/css-modules.d.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
//#region src/css-modules.d.ts
|
|
2
|
-
declare const MODULE_STYLES_URL = "/_june/modules.css";
|
|
3
|
-
declare const isModuleCss: (id: string) => boolean;
|
|
4
|
-
declare function stableKey(appRoot: string, file: string): string;
|
|
5
|
-
declare function transformCssModule(file: string, appRoot: string): Promise<{
|
|
2
|
+
export declare const MODULE_STYLES_URL = "/_june/modules.css";
|
|
3
|
+
export declare const isModuleCss: (id: string) => boolean;
|
|
4
|
+
export declare function stableKey(appRoot: string, file: string): string;
|
|
5
|
+
export declare function transformCssModule(file: string, appRoot: string): Promise<{
|
|
6
6
|
map: Record<string, string>;
|
|
7
7
|
css: string;
|
|
8
8
|
}>;
|
|
9
|
-
declare const moduleJs: (map: Record<string, string>) => string;
|
|
10
|
-
type ModuleMaps = Record<string, Record<string, string>>;
|
|
11
|
-
declare function buildModuleCss(appDir: string, appRoot: string): Promise<{
|
|
9
|
+
export declare const moduleJs: (map: Record<string, string>) => string;
|
|
10
|
+
export type ModuleMaps = Record<string, Record<string, string>>;
|
|
11
|
+
export declare function buildModuleCss(appDir: string, appRoot: string): Promise<{
|
|
12
12
|
maps: ModuleMaps;
|
|
13
13
|
css: string | null;
|
|
14
14
|
}>;
|
|
15
|
-
declare function rolldownCssModulesPlugin(maps: ModuleMaps): {
|
|
15
|
+
export declare function rolldownCssModulesPlugin(maps: ModuleMaps): {
|
|
16
16
|
name: string;
|
|
17
17
|
load(id: string): {
|
|
18
18
|
code: string;
|
|
19
19
|
moduleType: "js";
|
|
20
20
|
} | null;
|
|
21
21
|
};
|
|
22
|
-
declare function registerCssModules(maps: ModuleMaps): Promise<void>;
|
|
23
|
-
//#endregion
|
|
24
|
-
export { MODULE_STYLES_URL, ModuleMaps, buildModuleCss, isModuleCss, moduleJs, registerCssModules, rolldownCssModulesPlugin, stableKey, transformCssModule };
|
|
22
|
+
export declare function registerCssModules(maps: ModuleMaps): Promise<void>;
|
|
23
|
+
//#endregion
|
package/dist/css.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Targets } from "lightningcss";
|
|
2
2
|
//#region src/css.d.ts
|
|
3
|
-
declare const STYLES_URL = "/_june/global.css";
|
|
4
|
-
declare function findGlobalCss(appDir: string): string | null;
|
|
5
|
-
declare function globalCssUsesTailwind(appDir: string): boolean;
|
|
6
|
-
declare function cssTargets(appDir: string): Promise<Targets>;
|
|
7
|
-
declare function processCssCached(appDir: string): Promise<string | null>;
|
|
8
|
-
declare function invalidateCss(): void;
|
|
9
|
-
declare function minifyCss(css: string, filename?: string, targets?: Targets): Promise<string>;
|
|
10
|
-
declare function processCss(appDir: string, opts?: {
|
|
3
|
+
export declare const STYLES_URL = "/_june/global.css";
|
|
4
|
+
export declare function findGlobalCss(appDir: string): string | null;
|
|
5
|
+
export declare function globalCssUsesTailwind(appDir: string): boolean;
|
|
6
|
+
export declare function cssTargets(appDir: string): Promise<Targets>;
|
|
7
|
+
export declare function processCssCached(appDir: string): Promise<string | null>;
|
|
8
|
+
export declare function invalidateCss(): void;
|
|
9
|
+
export declare function minifyCss(css: string, filename?: string, targets?: Targets): Promise<string>;
|
|
10
|
+
export declare function processCss(appDir: string, opts?: {
|
|
11
11
|
minify?: boolean;
|
|
12
12
|
}): Promise<string | null>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { STYLES_URL, cssTargets, findGlobalCss, globalCssUsesTailwind, invalidateCss, minifyCss, processCss, processCssCached };
|
|
13
|
+
//#endregion
|
package/dist/d1-migrate.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as MigrateResult } from "./migrate-BbWt-PuB.js";
|
|
2
2
|
import { JuneDb } from "@junejs/core/resources";
|
|
3
3
|
//#region src/d1-migrate.d.ts
|
|
4
|
-
type D1Exec = (req: {
|
|
4
|
+
export type D1Exec = (req: {
|
|
5
5
|
sql: string;
|
|
6
6
|
mode: "command" | "file";
|
|
7
7
|
json: boolean;
|
|
@@ -10,16 +10,16 @@ type D1Exec = (req: {
|
|
|
10
10
|
stderr: string;
|
|
11
11
|
exitCode: number;
|
|
12
12
|
}>;
|
|
13
|
-
declare function inlineParams(sql: string, params: readonly unknown[]): string;
|
|
14
|
-
declare function wranglerD1(opts: {
|
|
13
|
+
export declare function inlineParams(sql: string, params: readonly unknown[]): string;
|
|
14
|
+
export declare function wranglerD1(opts: {
|
|
15
15
|
database: string;
|
|
16
16
|
configPath: string;
|
|
17
17
|
cwd: string;
|
|
18
18
|
wranglerVersion?: string;
|
|
19
19
|
exec?: D1Exec;
|
|
20
20
|
}): JuneDb;
|
|
21
|
-
declare function resolveD1Database(appRoot: string, configPath: string): Promise<string | null>;
|
|
22
|
-
declare function migrateD1(opts: {
|
|
21
|
+
export declare function resolveD1Database(appRoot: string, configPath: string): Promise<string | null>;
|
|
22
|
+
export declare function migrateD1(opts: {
|
|
23
23
|
appRoot: string;
|
|
24
24
|
database: string;
|
|
25
25
|
configPath: string;
|
|
@@ -27,5 +27,4 @@ declare function migrateD1(opts: {
|
|
|
27
27
|
exec?: D1Exec;
|
|
28
28
|
now?: string;
|
|
29
29
|
}): Promise<MigrateResult>;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { D1Exec, inlineParams, migrateD1, resolveD1Database, wranglerD1 };
|
|
30
|
+
//#endregion
|
package/dist/d1-migrate.js
CHANGED
|
@@ -142,12 +142,13 @@ async function resolveD1Database(appRoot, configPath) {
|
|
|
142
142
|
return `${(pkgName ?? basename(appRoot)).replace(/[^a-z0-9-]/gi, "-").toLowerCase()}-db`;
|
|
143
143
|
}
|
|
144
144
|
async function migrateD1(opts) {
|
|
145
|
-
|
|
145
|
+
const db = wranglerD1({
|
|
146
146
|
database: opts.database,
|
|
147
147
|
configPath: opts.configPath,
|
|
148
148
|
cwd: opts.appRoot,
|
|
149
149
|
exec: opts.exec
|
|
150
|
-
})
|
|
150
|
+
});
|
|
151
|
+
return migrate(db, join(opts.appRoot, "db", "migrations"), {
|
|
151
152
|
allowDestructive: opts.allowDestructive,
|
|
152
153
|
now: opts.now
|
|
153
154
|
});
|
package/dist/db.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { n as mysql, r as mysqlJuneDb, t as MysqlConnLike } from "./mysql-driver
|
|
|
4
4
|
import { i as turso, r as libsqlJuneDb, t as LibsqlClientLike } from "./turso-driver-C1wEigMZ.js";
|
|
5
5
|
import { DbFactory } from "@junejs/core/resources";
|
|
6
6
|
//#region src/db.d.ts
|
|
7
|
-
declare function sqlite(opts?: {
|
|
7
|
+
export declare function sqlite(opts?: {
|
|
8
8
|
path?: string;
|
|
9
9
|
}): DbFactory;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { type D1Database, type LibsqlClientLike, type MysqlConnLike, type PgClientLike, d1, libsqlJuneDb, mysql, mysqlJuneDb, pgJuneDb, postgres,
|
|
11
|
+
export { type D1Database, type LibsqlClientLike, type MysqlConnLike, type PgClientLike, d1, libsqlJuneDb, mysql, mysqlJuneDb, pgJuneDb, postgres, turso };
|
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
|
|
72
|
-
if (/no runtime entrypoint|build config/i.test(out)) throw new Error("Deno Deploy build failed —
|
|
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 {
|
package/dist/dev-reload.d.ts
CHANGED
|
@@ -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,16 @@
|
|
|
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
|
+
hostname?: string;
|
|
6
7
|
host?: JuneHost;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
export declare function devUrl(hostname: string, port: number): string;
|
|
10
|
+
export declare function devAllowedHosts(configured: readonly string[] | undefined, hostname: string): string[];
|
|
11
|
+
export type DevServer = Omit<ServeHandle, "stop"> & {
|
|
9
12
|
url: string;
|
|
13
|
+
stop(force?: boolean): Promise<void>;
|
|
10
14
|
};
|
|
11
|
-
declare function startDevServer({ appDir, port, host }: DevServerOptions): Promise<DevServer>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { DevServer, DevServerOptions, startDevServer };
|
|
15
|
+
export declare function startDevServer({ appDir, port, hostname, host }: DevServerOptions): Promise<DevServer>;
|
|
16
|
+
//#endregion
|