@junejs/server 1.0.0-dev.19 → 1.0.0-dev.20
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/dist/adapter-DcZ-W1-7.d.ts +62 -0
- package/dist/adapter.d.ts +1 -61
- package/dist/build.d.ts +5 -26
- package/dist/build.js +10 -276
- package/dist/config-freeze-DwI-Rmvq.d.ts +17 -0
- package/dist/config-freeze.d.ts +2 -0
- package/dist/config-freeze.js +51 -0
- package/dist/connection-auth.d.ts +39 -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/index.d.ts +9 -4
- package/dist/index.js +7 -2
- package/dist/manifest-gcNWqWoI.d.ts +11 -0
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.js +111 -0
- package/dist/route-scan-DMlwoESy.d.ts +13 -0
- package/dist/route-scan.d.ts +2 -0
- package/dist/route-scan.js +55 -0
- package/dist/worker-BkFHGtxp.d.ts +61 -0
- package/dist/worker.d.ts +1 -60
- package/package.json +2 -2
- package/src/agent-discover.ts +8 -5
- package/src/build.ts +26 -440
- package/src/config-freeze.ts +104 -0
- package/src/connection-auth.ts +101 -0
- package/src/content-freeze.ts +151 -0
- package/src/index.ts +14 -0
- package/src/manifest.ts +128 -0
- package/src/route-scan.ts +84 -0
|
@@ -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/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as ResourcePlan, c as staticSite, i as JuneAdapter, l as vercel, n as AdapterEmitContext, o as deno, r as AdapterEntry, t as AdapterCapabilities, u as workers } from "./adapter-DcZ-W1-7.js";
|
|
2
2
|
import { AGENT_MODULE_FILE, AgentDirScan, emitAgentModule, findAgentDir, generateAgentModule, scanAgentDir } from "./agent-compile.js";
|
|
3
3
|
import { CreateAppOptions, JuneApp, createApp } from "./app.js";
|
|
4
4
|
import { R2Bucket, localBlob, r2 } from "./blob.js";
|
|
5
|
+
import { r as scanRoutes } from "./route-scan-DMlwoESy.js";
|
|
6
|
+
import { t as generateContent } from "./content-freeze-CyiW2fRK.js";
|
|
5
7
|
import { a as Pipeline, d as createPipeline, n as LayoutComponent, o as PipelineConfig, s as Resolved, u as RouteResolver } from "./pipeline-cCR6MGNK.js";
|
|
6
|
-
import { WorkerManifest, createWorker } from "./worker.js";
|
|
7
|
-
import {
|
|
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";
|
|
11
|
+
import { BuildResult, juneBuild } from "./build.js";
|
|
8
12
|
import { loadJuneConfig } from "./config-loader.js";
|
|
13
|
+
import { AccountTokenStore, BetterAuthLike, ConnectionAuth, LinkedAccountAuthOptions, betterAuthAccessToken, betterAuthAccountTokenStore, linkedAccountAuth } from "./connection-auth.js";
|
|
9
14
|
import { ContentEntry, collection, entry } from "./content.js";
|
|
10
15
|
import { a as blockedMessage, c as migrateApp, l as readMigrations, n as MigrateResult, o as classify, r as Migration, s as migrate, u as typesApp } from "./migrate-BbWt-PuB.js";
|
|
11
16
|
import { D1Exec, migrateD1, resolveD1Database, wranglerD1 } from "./d1-migrate.js";
|
|
@@ -25,4 +30,4 @@ import { Negotiated, negotiate } from "./negotiate.js";
|
|
|
25
30
|
import { blob, currentServices, db, kv } from "@junejs/db";
|
|
26
31
|
import { ServicesConfig, defineServices } from "@junejs/core/config";
|
|
27
32
|
import { I18nConfig, LOCALE_COOKIE, LocaleConfig, LocaleMatch, dirForLang, localeDir, localeHref, matchPinnedLocale, negotiateLocale, parseAcceptLanguage, resolveRequestLocale } from "@junejs/core/i18n";
|
|
28
|
-
export { AGENT_MODULE_FILE, type AdapterCapabilities, type AdapterEmitContext, type AdapterEntry, type AgentDirScan, type BuildResult, type ContentEntry, type CreateAppOptions, type D1Database, type D1Exec, type DeployResult, type DevServer, type DevServerOptions, type I18nConfig, type JuneAdapter, type JuneApp, type JuneDb, type JuneHost, LOCALE_COOKIE, type LayoutComponent, type LocaleConfig, type LocaleMatch, type MatchOptions, type MigrateResult, type Migration, type Negotiated, type Pipeline, type PipelineConfig, type R2Bucket, type Resolved, type ResourceFlags, type ResourcePlan, type RouteMatch, type RouteResolver, type RouteTreeMatch, type RunResult, type SegmentMatch, type ServeHandle, type ServicesConfig, type SpawnedModule, type WorkerEnv, type WorkerManifest, bindWorkerResources, blob, blockedMessage, buildManifest, classify, collection, createApp, createPipeline, createWorker, currentServices, d1, db, defineServices, deno, dirForLang, emitAgentModule, entry, findAgentDir, freezeConfig, generateAgentModule, generateContent, host, installAsyncContext, juneBuild, juneDeploy, kv, listRoutes, loadJuneConfig, localBlob, localeDir, localeHref, matchPinnedLocale, matchRoute, matchRouteTree, memoizeResources, memoryKv, migrate, migrateApp, migrateD1, mysql, negotiate, negotiateLocale, parseAcceptLanguage, postgres, r2, readMigrations, redisKv, resolveD1Database, resolveNotFound, resolveRequestLocale, scanAgentDir, scanRoutes, sqlite, startDevServer, staticSite, turso, typesApp, vercel, workers, wranglerD1 };
|
|
33
|
+
export { AGENT_MODULE_FILE, type AccountTokenStore, type AdapterCapabilities, type AdapterEmitContext, type AdapterEntry, type AgentDirScan, type BetterAuthLike, type BuildResult, type ConnectionAuth, type ContentEntry, type CreateAppOptions, type D1Database, type D1Exec, type DeployResult, type DevServer, type DevServerOptions, type I18nConfig, type JuneAdapter, type JuneApp, type JuneDb, type JuneHost, LOCALE_COOKIE, type LayoutComponent, type LinkedAccountAuthOptions, type LocaleConfig, type LocaleMatch, type MatchOptions, type MigrateResult, type Migration, type Negotiated, type Pipeline, type PipelineConfig, type R2Bucket, type Resolved, type ResourceFlags, type ResourcePlan, type RouteMatch, type RouteResolver, type RouteTreeMatch, type RunResult, type SegmentMatch, type ServeHandle, type ServicesConfig, type SpawnedModule, type WorkerEnv, type WorkerManifest, betterAuthAccessToken, betterAuthAccountTokenStore, bindWorkerResources, blob, blockedMessage, buildManifest, classify, collection, createApp, createPipeline, createWorker, currentServices, d1, db, defineServices, deno, dirForLang, emitAgentModule, entry, findAgentDir, freezeConfig, generateAgentModule, generateContent, host, installAsyncContext, juneBuild, juneDeploy, kv, linkedAccountAuth, listRoutes, loadJuneConfig, localBlob, localeDir, localeHref, matchPinnedLocale, matchRoute, matchRouteTree, memoizeResources, memoryKv, migrate, migrateApp, migrateD1, mysql, negotiate, negotiateLocale, parseAcceptLanguage, postgres, r2, readMigrations, redisKv, resolveD1Database, resolveNotFound, resolveRequestLocale, scanAgentDir, scanRoutes, sqlite, startDevServer, staticSite, turso, typesApp, vercel, workers, wranglerD1 };
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,14 @@ import { bindWorkerResources, memoizeResources } from "./resources.js";
|
|
|
8
8
|
import { createApp } from "./app.js";
|
|
9
9
|
import { localBlob, r2 } from "./blob.js";
|
|
10
10
|
import { loadJuneConfig } from "./config-loader.js";
|
|
11
|
+
import { freezeConfig } from "./config-freeze.js";
|
|
11
12
|
import { collection, entry } from "./content.js";
|
|
13
|
+
import { generateContent } from "./content-freeze.js";
|
|
12
14
|
import { createWorker } from "./worker.js";
|
|
13
|
-
import {
|
|
15
|
+
import { scanRoutes } from "./route-scan.js";
|
|
16
|
+
import { buildManifest } from "./manifest.js";
|
|
17
|
+
import { juneBuild } from "./build.js";
|
|
18
|
+
import { betterAuthAccessToken, betterAuthAccountTokenStore, linkedAccountAuth } from "./connection-auth.js";
|
|
14
19
|
import { blockedMessage, classify, migrate, migrateApp, readMigrations, typesApp } from "./migrate.js";
|
|
15
20
|
import { migrateD1, resolveD1Database, wranglerD1 } from "./d1-migrate.js";
|
|
16
21
|
import { postgres } from "./postgres-driver.js";
|
|
@@ -25,4 +30,4 @@ import { memoryKv, redisKv } from "./kv.js";
|
|
|
25
30
|
import { blob, currentServices, db, kv } from "@junejs/db";
|
|
26
31
|
import { defineServices } from "@junejs/core/config";
|
|
27
32
|
import { LOCALE_COOKIE, dirForLang, localeDir, localeHref, matchPinnedLocale, negotiateLocale, parseAcceptLanguage, resolveRequestLocale } from "@junejs/core/i18n";
|
|
28
|
-
export { AGENT_MODULE_FILE, LOCALE_COOKIE, bindWorkerResources, blob, blockedMessage, buildManifest, classify, collection, createApp, createPipeline, createWorker, currentServices, d1, db, defineServices, deno, dirForLang, emitAgentModule, entry, findAgentDir, freezeConfig, generateAgentModule, generateContent, host, installAsyncContext, juneBuild, juneDeploy, kv, listRoutes, loadJuneConfig, localBlob, localeDir, localeHref, matchPinnedLocale, matchRoute, matchRouteTree, memoizeResources, memoryKv, migrate, migrateApp, migrateD1, mysql, negotiate, negotiateLocale, parseAcceptLanguage, postgres, r2, readMigrations, redisKv, resolveD1Database, resolveNotFound, resolveRequestLocale, scanAgentDir, scanRoutes, sqlite, startDevServer, staticSite, turso, typesApp, vercel, workers, wranglerD1 };
|
|
33
|
+
export { AGENT_MODULE_FILE, LOCALE_COOKIE, betterAuthAccessToken, betterAuthAccountTokenStore, bindWorkerResources, blob, blockedMessage, buildManifest, classify, collection, createApp, createPipeline, createWorker, currentServices, d1, db, defineServices, deno, dirForLang, emitAgentModule, entry, findAgentDir, freezeConfig, generateAgentModule, generateContent, host, installAsyncContext, juneBuild, juneDeploy, kv, linkedAccountAuth, listRoutes, loadJuneConfig, localBlob, localeDir, localeHref, matchPinnedLocale, matchRoute, matchRouteTree, memoizeResources, memoryKv, migrate, migrateApp, migrateD1, mysql, negotiate, negotiateLocale, parseAcceptLanguage, postgres, r2, readMigrations, redisKv, resolveD1Database, resolveNotFound, resolveRequestLocale, scanAgentDir, scanRoutes, sqlite, startDevServer, staticSite, turso, typesApp, vercel, workers, wranglerD1 };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { n as LayoutComponent } from "./pipeline-cCR6MGNK.js";
|
|
2
|
+
import { n as WorkerManifest } from "./worker-BkFHGtxp.js";
|
|
3
|
+
//#region src/manifest.d.ts
|
|
4
|
+
type ImportedLayout = {
|
|
5
|
+
component: LayoutComponent;
|
|
6
|
+
boundary: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare function importLayout(file: string): Promise<ImportedLayout | null>;
|
|
9
|
+
declare function buildManifest(appRoot: string): Promise<WorkerManifest>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { buildManifest as n, importLayout as r, ImportedLayout as t };
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { findMiddlewareFile } from "./router.js";
|
|
2
|
+
import { resolveBoundary } from "./segment.js";
|
|
3
|
+
import { freezeConfig } from "./config-freeze.js";
|
|
4
|
+
import { scanAppRoutes } from "./route-scan.js";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { basename, join } from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { routeFromModule } from "@junejs/core/route";
|
|
9
|
+
//#region src/manifest.ts
|
|
10
|
+
async function importLayout(file) {
|
|
11
|
+
const mod = await import(pathToFileURL(file).href);
|
|
12
|
+
return typeof mod.default === "function" ? {
|
|
13
|
+
component: mod.default,
|
|
14
|
+
boundary: mod.segmentBoundary === true
|
|
15
|
+
} : null;
|
|
16
|
+
}
|
|
17
|
+
async function buildManifest(appRoot) {
|
|
18
|
+
const appDir = join(appRoot, "app");
|
|
19
|
+
const frozen = await freezeConfig(appRoot);
|
|
20
|
+
const scanned = await scanAppRoutes(appRoot);
|
|
21
|
+
const layoutCache = /* @__PURE__ */ new Map();
|
|
22
|
+
const loadCached = async (f) => {
|
|
23
|
+
if (!layoutCache.has(f)) layoutCache.set(f, await importLayout(f));
|
|
24
|
+
return layoutCache.get(f) ?? null;
|
|
25
|
+
};
|
|
26
|
+
const componentsFor = async (files) => {
|
|
27
|
+
const items = [];
|
|
28
|
+
for (const f of files) {
|
|
29
|
+
const c = await loadCached(f);
|
|
30
|
+
items.push({
|
|
31
|
+
file: f,
|
|
32
|
+
entry: c?.component ?? null,
|
|
33
|
+
boundary: !!c?.boundary
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return resolveBoundary(items);
|
|
37
|
+
};
|
|
38
|
+
const loadingCache = /* @__PURE__ */ new Map();
|
|
39
|
+
const loadingFor = async (file) => {
|
|
40
|
+
if (!file) return void 0;
|
|
41
|
+
if (!loadingCache.has(file)) {
|
|
42
|
+
const loaded = await importLayout(file);
|
|
43
|
+
loadingCache.set(file, loaded ? loaded.component : null);
|
|
44
|
+
}
|
|
45
|
+
return loadingCache.get(file) ?? void 0;
|
|
46
|
+
};
|
|
47
|
+
const routes = {};
|
|
48
|
+
const dynamicRoutes = [];
|
|
49
|
+
const resourceRoutes = [];
|
|
50
|
+
const layoutChains = {};
|
|
51
|
+
const layoutBoundaries = {};
|
|
52
|
+
const loadings = {};
|
|
53
|
+
for (const r of scanned) {
|
|
54
|
+
const mod = await import(pathToFileURL(r.file).href);
|
|
55
|
+
if (r.resource) {
|
|
56
|
+
const handler = mod.default;
|
|
57
|
+
if (typeof handler === "function") resourceRoutes.push({
|
|
58
|
+
pattern: r.path,
|
|
59
|
+
handler
|
|
60
|
+
});
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const def = routeFromModule(mod);
|
|
64
|
+
if (!def) continue;
|
|
65
|
+
const { chain, boundaryIndex, key } = await componentsFor(r.layouts);
|
|
66
|
+
const loading = await loadingFor(r.loading);
|
|
67
|
+
if (r.dynamic) {
|
|
68
|
+
dynamicRoutes.push({
|
|
69
|
+
pattern: r.path,
|
|
70
|
+
def
|
|
71
|
+
});
|
|
72
|
+
layoutChains[r.path] = chain;
|
|
73
|
+
} else {
|
|
74
|
+
routes[r.path] = def;
|
|
75
|
+
layoutChains[r.path] = chain;
|
|
76
|
+
}
|
|
77
|
+
if (boundaryIndex !== null && key !== null) layoutBoundaries[r.path] = {
|
|
78
|
+
index: boundaryIndex,
|
|
79
|
+
key
|
|
80
|
+
};
|
|
81
|
+
if (loading) loadings[r.path] = loading;
|
|
82
|
+
}
|
|
83
|
+
let extra;
|
|
84
|
+
const extraFile = findMiddlewareFile(appDir);
|
|
85
|
+
if (extraFile) {
|
|
86
|
+
const mod = await import(pathToFileURL(extraFile).href);
|
|
87
|
+
if (typeof mod.default === "function") extra = mod.default;
|
|
88
|
+
}
|
|
89
|
+
let agentName;
|
|
90
|
+
const agentDir = join(appDir, frozen.agent.runtime.dir);
|
|
91
|
+
if (frozen.agent.runtime.enabled && existsSync(agentDir)) {
|
|
92
|
+
const cfgFile = join(agentDir, "agent.ts");
|
|
93
|
+
agentName = (existsSync(cfgFile) ? (await import(pathToFileURL(cfgFile).href)).default : void 0)?.name ?? basename(agentDir);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
routes,
|
|
97
|
+
dynamicRoutes,
|
|
98
|
+
resourceRoutes,
|
|
99
|
+
layoutChains,
|
|
100
|
+
layoutBoundaries,
|
|
101
|
+
loadings,
|
|
102
|
+
document: frozen.document,
|
|
103
|
+
agent: frozen.agent,
|
|
104
|
+
agentName,
|
|
105
|
+
i18n: frozen.i18n,
|
|
106
|
+
earlyHints: frozen.earlyHints,
|
|
107
|
+
extra
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { buildManifest, importLayout };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/route-scan.d.ts
|
|
2
|
+
type RouteEntry = {
|
|
3
|
+
path: string;
|
|
4
|
+
file: string;
|
|
5
|
+
dynamic: boolean;
|
|
6
|
+
resource?: boolean;
|
|
7
|
+
layouts: string[];
|
|
8
|
+
loading?: string;
|
|
9
|
+
};
|
|
10
|
+
declare function scanRoutes(appDir: string, dir?: string, layouts?: string[], out?: RouteEntry[], loading?: string): Promise<RouteEntry[]>;
|
|
11
|
+
declare function scanAppRoutes(appRoot: string): Promise<RouteEntry[]>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { scanAppRoutes as n, scanRoutes as r, RouteEntry as t };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readdir } from "node:fs/promises";
|
|
3
|
+
import { basename, join, relative, sep } from "node:path";
|
|
4
|
+
//#region src/route-scan.ts
|
|
5
|
+
const PAGE_BASENAMES = /* @__PURE__ */ new Set(["page", "index"]);
|
|
6
|
+
const ROUTE_EXTS = [
|
|
7
|
+
".tsx",
|
|
8
|
+
".jsx",
|
|
9
|
+
".ts",
|
|
10
|
+
".js"
|
|
11
|
+
];
|
|
12
|
+
const isRouteGroup = (name) => /^\(.+\)$/.test(name);
|
|
13
|
+
function segmentFile(dir, base) {
|
|
14
|
+
return ROUTE_EXTS.map((e) => join(dir, `${base}${e}`)).find(existsSync);
|
|
15
|
+
}
|
|
16
|
+
async function scanRoutes(appDir, dir = appDir, layouts = [], out = [], loading) {
|
|
17
|
+
const ownLayout = segmentFile(dir, "layout");
|
|
18
|
+
const chain = ownLayout ? [...layouts, ownLayout] : layouts;
|
|
19
|
+
const nearestLoading = segmentFile(dir, "loading") ?? loading;
|
|
20
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
21
|
+
for (const e of entries) {
|
|
22
|
+
if (e.name.startsWith("_") || e.name.startsWith(".")) continue;
|
|
23
|
+
const full = join(dir, e.name);
|
|
24
|
+
if (e.isDirectory()) {
|
|
25
|
+
await scanRoutes(appDir, full, chain, out, nearestLoading);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const ext = e.name.match(/\.[^.]+$/)?.[0] ?? "";
|
|
29
|
+
if (!ROUTE_EXTS.includes(ext)) continue;
|
|
30
|
+
const base = basename(e.name, ext);
|
|
31
|
+
const resource = base === "route";
|
|
32
|
+
if (!PAGE_BASENAMES.has(base) && !resource) continue;
|
|
33
|
+
const relDir = relative(appDir, dir);
|
|
34
|
+
const path = "/" + (relDir === "" ? [] : relDir.split(sep).filter((s) => !isRouteGroup(s))).join("/");
|
|
35
|
+
out.push({
|
|
36
|
+
path: path === "/" ? "/" : path,
|
|
37
|
+
file: full,
|
|
38
|
+
dynamic: /\[.+\]/.test(path),
|
|
39
|
+
resource,
|
|
40
|
+
layouts: chain,
|
|
41
|
+
loading: nearestLoading
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
async function scanAppRoutes(appRoot) {
|
|
47
|
+
const appDir = join(appRoot, "app");
|
|
48
|
+
const juneRoutesDir = join(appRoot, ".june", "routes");
|
|
49
|
+
const appRoutes = await scanRoutes(appDir);
|
|
50
|
+
const frameworkRoutes = existsSync(juneRoutesDir) ? await scanRoutes(juneRoutesDir) : [];
|
|
51
|
+
const appPaths = new Set(appRoutes.map((r) => r.path));
|
|
52
|
+
return [...appRoutes, ...frameworkRoutes.filter((r) => !appPaths.has(r.path))].sort((a, b) => a.path.localeCompare(b.path));
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { scanAppRoutes, scanRoutes };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { l as ResourceHandler, n as LayoutComponent, r as LoadingComponent, t as ExtraHandler } from "./pipeline-cCR6MGNK.js";
|
|
2
|
+
import { Channel, ChannelFactory } from "@junejs/core/agent-config";
|
|
3
|
+
import { BrandedRoute } from "@junejs/core/route";
|
|
4
|
+
import { AgentConfig } from "@junejs/core/config";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { DocumentConfig } from "@junejs/core/document";
|
|
7
|
+
import { I18nConfig } from "@junejs/core/i18n";
|
|
8
|
+
import { Resources } from "@junejs/core/resources";
|
|
9
|
+
//#region src/worker.d.ts
|
|
10
|
+
type WorkerExecutionContext = {
|
|
11
|
+
waitUntil?(p: Promise<unknown>): void;
|
|
12
|
+
};
|
|
13
|
+
type WorkerManifest = {
|
|
14
|
+
routes: Record<string, BrandedRoute>;
|
|
15
|
+
dynamicRoutes?: Array<{
|
|
16
|
+
pattern: string;
|
|
17
|
+
def: BrandedRoute;
|
|
18
|
+
}>;
|
|
19
|
+
resourceRoutes?: Array<{
|
|
20
|
+
pattern: string;
|
|
21
|
+
handler: ResourceHandler;
|
|
22
|
+
}>;
|
|
23
|
+
layoutChains?: Record<string, LayoutComponent[]>;
|
|
24
|
+
layoutBoundaries?: Record<string, {
|
|
25
|
+
index: number;
|
|
26
|
+
key: string;
|
|
27
|
+
}>;
|
|
28
|
+
loadings?: Record<string, LoadingComponent>;
|
|
29
|
+
document: DocumentConfig;
|
|
30
|
+
agent: AgentConfig;
|
|
31
|
+
agentName?: string;
|
|
32
|
+
agentChannels?: (Channel | ChannelFactory)[];
|
|
33
|
+
i18n?: I18nConfig;
|
|
34
|
+
earlyHints?: string[];
|
|
35
|
+
htmlCacheControl?: string;
|
|
36
|
+
notFound?: React.ComponentType<{
|
|
37
|
+
pathname: string;
|
|
38
|
+
}>;
|
|
39
|
+
extra?: ExtraHandler;
|
|
40
|
+
resources?: (env?: unknown) => Promise<Resources> | Resources;
|
|
41
|
+
services?: (env?: unknown) => unknown;
|
|
42
|
+
};
|
|
43
|
+
declare function createWorker(manifest: WorkerManifest): {
|
|
44
|
+
fetch(request: Request, env?: unknown, ctx?: WorkerExecutionContext): Promise<Response>;
|
|
45
|
+
};
|
|
46
|
+
type AssetEnv = {
|
|
47
|
+
ASSETS?: {
|
|
48
|
+
fetch(request: Request): Promise<Response>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type FetchPipeline = {
|
|
52
|
+
fetch(request: Request, env?: unknown, ctx?: WorkerExecutionContext): Promise<Response>;
|
|
53
|
+
};
|
|
54
|
+
declare function withAssets(pipeline: FetchPipeline, opts?: {
|
|
55
|
+
link?: string | null;
|
|
56
|
+
}): {
|
|
57
|
+
fetch(request: Request, env?: AssetEnv, ctx?: WorkerExecutionContext): Promise<Response>;
|
|
58
|
+
};
|
|
59
|
+
declare function withDenoAssets(pipeline: FetchPipeline): (request: Request) => Promise<Response>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { withDenoAssets as a, withAssets as i, WorkerManifest as n, createWorker as r, WorkerExecutionContext as t };
|
package/dist/worker.d.ts
CHANGED
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Channel, ChannelFactory } from "@junejs/core/agent-config";
|
|
3
|
-
import { BrandedRoute } from "@junejs/core/route";
|
|
4
|
-
import { AgentConfig } from "@junejs/core/config";
|
|
5
|
-
import React from "react";
|
|
6
|
-
import { DocumentConfig } from "@junejs/core/document";
|
|
7
|
-
import { I18nConfig } from "@junejs/core/i18n";
|
|
8
|
-
import { Resources } from "@junejs/core/resources";
|
|
9
|
-
//#region src/worker.d.ts
|
|
10
|
-
type WorkerExecutionContext = {
|
|
11
|
-
waitUntil?(p: Promise<unknown>): void;
|
|
12
|
-
};
|
|
13
|
-
type WorkerManifest = {
|
|
14
|
-
routes: Record<string, BrandedRoute>;
|
|
15
|
-
dynamicRoutes?: Array<{
|
|
16
|
-
pattern: string;
|
|
17
|
-
def: BrandedRoute;
|
|
18
|
-
}>;
|
|
19
|
-
resourceRoutes?: Array<{
|
|
20
|
-
pattern: string;
|
|
21
|
-
handler: ResourceHandler;
|
|
22
|
-
}>;
|
|
23
|
-
layoutChains?: Record<string, LayoutComponent[]>;
|
|
24
|
-
layoutBoundaries?: Record<string, {
|
|
25
|
-
index: number;
|
|
26
|
-
key: string;
|
|
27
|
-
}>;
|
|
28
|
-
loadings?: Record<string, LoadingComponent>;
|
|
29
|
-
document: DocumentConfig;
|
|
30
|
-
agent: AgentConfig;
|
|
31
|
-
agentName?: string;
|
|
32
|
-
agentChannels?: (Channel | ChannelFactory)[];
|
|
33
|
-
i18n?: I18nConfig;
|
|
34
|
-
earlyHints?: string[];
|
|
35
|
-
htmlCacheControl?: string;
|
|
36
|
-
notFound?: React.ComponentType<{
|
|
37
|
-
pathname: string;
|
|
38
|
-
}>;
|
|
39
|
-
extra?: ExtraHandler;
|
|
40
|
-
resources?: (env?: unknown) => Promise<Resources> | Resources;
|
|
41
|
-
services?: (env?: unknown) => unknown;
|
|
42
|
-
};
|
|
43
|
-
declare function createWorker(manifest: WorkerManifest): {
|
|
44
|
-
fetch(request: Request, env?: unknown, ctx?: WorkerExecutionContext): Promise<Response>;
|
|
45
|
-
};
|
|
46
|
-
type AssetEnv = {
|
|
47
|
-
ASSETS?: {
|
|
48
|
-
fetch(request: Request): Promise<Response>;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
type FetchPipeline = {
|
|
52
|
-
fetch(request: Request, env?: unknown, ctx?: WorkerExecutionContext): Promise<Response>;
|
|
53
|
-
};
|
|
54
|
-
declare function withAssets(pipeline: FetchPipeline, opts?: {
|
|
55
|
-
link?: string | null;
|
|
56
|
-
}): {
|
|
57
|
-
fetch(request: Request, env?: AssetEnv, ctx?: WorkerExecutionContext): Promise<Response>;
|
|
58
|
-
};
|
|
59
|
-
declare function withDenoAssets(pipeline: FetchPipeline): (request: Request) => Promise<Response>;
|
|
60
|
-
//#endregion
|
|
1
|
+
import { a as withDenoAssets, i as withAssets, n as WorkerManifest, r as createWorker, t as WorkerExecutionContext } from "./worker-BkFHGtxp.js";
|
|
61
2
|
export { WorkerExecutionContext, WorkerManifest, createWorker, withAssets, withDenoAssets };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junejs/server",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.20",
|
|
4
4
|
"description": "June host adapters + dev server. Host-coupled; depends on the pure @junejs/core contract layer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"rolldown": "^1.1.0"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@junejs/core": ">=0.2.0-dev.
|
|
141
|
+
"@junejs/core": ">=0.2.0-dev.38",
|
|
142
142
|
"react": "^19.2.0",
|
|
143
143
|
"react-dom": "^19.2.0",
|
|
144
144
|
"react-server-dom-webpack": "19.2.7",
|
package/src/agent-discover.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
// agent.ts → default-exports a plain config { name, model?, surfaces? }
|
|
7
7
|
// instructions.md → base system prompt
|
|
8
8
|
// instructions.<source>.md → per-surface instruction variant (#149)
|
|
9
|
-
// tools/*.ts → each default-exports a defineAction (a tool)
|
|
9
|
+
// tools/*.ts → each default-exports a defineAction (a tool),
|
|
10
|
+
// OR an array of defineActions (an integration
|
|
11
|
+
// shipping several tools, e.g. googleDriveTools())
|
|
10
12
|
// skills/*.md → each a procedure, loaded on demand (progressive disclosure)
|
|
11
13
|
// channels/*.ts → each default-exports a Channel (an inbound edge — pure transport)
|
|
12
14
|
// channels/*.md → DEPRECATED overlay location (warned; use instructions.<source>.md)
|
|
@@ -24,8 +26,7 @@ import { readdir, readFile } from "node:fs/promises";
|
|
|
24
26
|
import { basename, extname, join } from "node:path";
|
|
25
27
|
import { pathToFileURL } from "node:url";
|
|
26
28
|
|
|
27
|
-
import type
|
|
28
|
-
import { assembleAgent, parseSkill, type AgentConfigFile, type AgentDefinition, type AgentModule, type Channel, type ChannelFactory, type Skill } from "@junejs/core/agent-config";
|
|
29
|
+
import { assembleAgent, parseSkill, type AgentConfigFile, type AgentDefinition, type AgentModule, type Channel, type ChannelFactory, type Skill, type ToolEntry } from "@junejs/core/agent-config";
|
|
29
30
|
import type { Connection } from "@junejs/core/connections";
|
|
30
31
|
|
|
31
32
|
// `_`-prefixed files are private by convention (mirrors the app/ router) — most
|
|
@@ -72,10 +73,12 @@ export async function discoverAgentModule(dir: string): Promise<AgentModule> {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
// A tool file default-exports one tool OR an array of tools (an integration
|
|
77
|
+
// like googleDriveTools()); assembly flattens arrays.
|
|
78
|
+
const tools: ToolEntry[] = [];
|
|
76
79
|
for (const f of await scan(join(dir, "tools"), ".ts")) {
|
|
77
80
|
const mod = await import(pathToFileURL(f).href);
|
|
78
|
-
if (mod.default) tools.push(mod.default as
|
|
81
|
+
if (mod.default) tools.push(mod.default as ToolEntry);
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
const skills: Skill[] = [];
|