@runlot/next 0.1.0-rc.21 → 0.1.0-rc.211
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/README.md +10 -10
- package/dist/ai.d.ts +576 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +2 -0
- package/dist/ai.js.map +1 -0
- package/dist/build.d.ts +22 -17
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +48 -32
- package/dist/build.js.map +1 -1
- package/dist/entry.d.ts +4 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +11 -9
- package/dist/entry.js.map +1 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -25
- package/dist/index.js.map +1 -1
- package/dist/judge.d.ts +36 -0
- package/dist/judge.d.ts.map +1 -0
- package/dist/judge.js +27 -0
- package/dist/judge.js.map +1 -0
- package/dist/opennext/context.d.ts +6 -3
- package/dist/opennext/context.d.ts.map +1 -1
- package/dist/opennext/context.js +17 -12
- package/dist/opennext/context.js.map +1 -1
- package/dist/opennext/incremental-cache.d.ts +2 -1
- package/dist/opennext/incremental-cache.d.ts.map +1 -1
- package/dist/opennext/incremental-cache.js +18 -12
- package/dist/opennext/incremental-cache.js.map +1 -1
- package/dist/opennext/tag-cache.d.ts +3 -3
- package/dist/opennext/tag-cache.d.ts.map +1 -1
- package/dist/opennext/tag-cache.js +15 -11
- package/dist/opennext/tag-cache.js.map +1 -1
- package/dist/store.d.ts +14 -9
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +22 -20
- package/dist/store.js.map +1 -1
- package/package.json +5 -5
package/dist/build.d.ts
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Where the generated OpenNext config lives. It is kept outside `.open-next`
|
|
2
|
+
* because the build erases that every time. */
|
|
2
3
|
export declare const WORK_DIR = ".runlot-next";
|
|
3
4
|
export declare const ENTRY_NAME = "runlot-entry.js";
|
|
4
5
|
export interface BuildNextOptions {
|
|
5
|
-
/** Next
|
|
6
|
+
/** The Next project root (where `runlot.json` is). */
|
|
6
7
|
dir: string;
|
|
7
|
-
/** `
|
|
8
|
+
/** The `compatibilityDate` from `runlot.json`. OpenNext uses it only for one
|
|
9
|
+
* warning line. */
|
|
8
10
|
compatibilityDate?: string;
|
|
9
11
|
log?: (line: string) => void;
|
|
10
12
|
}
|
|
11
13
|
export interface BuildNextResult {
|
|
12
|
-
/**
|
|
14
|
+
/** The entry point to hand to our bundler (an absolute path). */
|
|
13
15
|
worker: string;
|
|
14
|
-
/**
|
|
16
|
+
/** The static asset directory (an absolute path). */
|
|
15
17
|
assets: string;
|
|
16
|
-
/** OpenNext
|
|
18
|
+
/** The OpenNext output directory (an absolute path). It is the bundler's
|
|
19
|
+
* `absWorkingDir`. */
|
|
17
20
|
outputDir: string;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
23
|
+
* The entry point we stand up.
|
|
21
24
|
*
|
|
22
|
-
* OpenNext
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
+
* It wraps the default export of OpenNext's `worker.js` and lets the other
|
|
26
|
+
* exports (Durable Object classes and so on) pass straight through. `export *`
|
|
27
|
+
* does not re-export the default, so the two lines do not collide.
|
|
25
28
|
*/
|
|
26
|
-
export declare const ENTRY_SOURCE = "//
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
export declare const ENTRY_SOURCE = "// This file was made by runlot. Edits are overwritten on the next deploy.\nimport worker from \"./worker.js\";\nimport { wrap } from \"@runlot/next/entry\";\n\nexport * from \"./worker.js\";\nexport default wrap(worker);\n";
|
|
30
|
+
/** The OpenNext config we use when the user has not put down one of their own
|
|
31
|
+
* (the table in docs/nextjs.md §2). */
|
|
32
|
+
export declare const OPEN_NEXT_CONFIG_SOURCE = "// This file was made by runlot. Edits are overwritten on the next deploy.\n// To handle it yourself, put an open-next.config.ts in the project root \u2014 if one\n// is there, that is the one we use.\nimport { defineCloudflareConfig } from \"@opennextjs/cloudflare\";\nimport queue from \"@opennextjs/cloudflare/overrides/queue/memory-queue\";\nimport incrementalCache from \"@runlot/next/opennext/incremental-cache\";\nimport tagCache from \"@runlot/next/opennext/tag-cache\";\n\nexport default defineCloudflareConfig({\n incrementalCache,\n tagCache,\n queue,\n enableCacheInterception: true,\n});\n";
|
|
33
|
+
/** Gives the path of the project's own OpenNext config when it has one, and
|
|
34
|
+
* otherwise creates ours and gives that path. */
|
|
30
35
|
export declare function openNextConfigPath(dir: string, log: (line: string) => void): string;
|
|
31
36
|
/**
|
|
32
|
-
* `next build` → OpenNext →
|
|
37
|
+
* `next build` → OpenNext → our entry point.
|
|
33
38
|
*
|
|
34
|
-
* `process.cwd()`
|
|
35
|
-
*
|
|
39
|
+
* It moves `process.cwd()` to the project: OpenNext's `normalizeOptions` builds
|
|
40
|
+
* the app path and the output path out of the cwd. It is moved back at the end.
|
|
36
41
|
*/
|
|
37
42
|
export declare function buildNext(opts: BuildNextOptions): Promise<BuildNextResult>;
|
|
38
43
|
//# sourceMappingURL=build.d.ts.map
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAgBA;gDACgD;AAChD,eAAO,MAAM,QAAQ,iBAAiB,CAAC;AACvC,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAE5C,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ;wBACoB;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf;2BACuB;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,oOAMxB,CAAC;AAEF;wCACwC;AACxC,eAAO,MAAM,uBAAuB,mmBAcnC,CAAC;AAIF;kDACkD;AAClD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CAanF;AAWD;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAqFhF"}
|
package/dist/build.js
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
|
-
// `@runlot/next/build` — `runlot deploy`
|
|
2
|
-
// (docs/nextjs.md §2).
|
|
1
|
+
// `@runlot/next/build` — the one function `runlot deploy` calls in a Next
|
|
2
|
+
// project (docs/nextjs.md §2).
|
|
3
3
|
//
|
|
4
|
-
// OpenNext
|
|
5
|
-
// wrangler
|
|
6
|
-
//
|
|
7
|
-
// `
|
|
4
|
+
// It calls OpenNext's **build function directly, not its CLI**. The CLI carries
|
|
5
|
+
// yargs and wrangler's `unstable_readConfig`, and the only values it actually
|
|
6
|
+
// reads out of that config are `compatibility_date` and
|
|
7
|
+
// `assets.run_worker_first`. We supply those two from `runlot.json` — no
|
|
8
|
+
// `wrangler.toml` is created.
|
|
8
9
|
//
|
|
9
|
-
//
|
|
10
|
+
// This file runs in node (not in a worker). That is why it uses `node:fs`
|
|
11
|
+
// directly.
|
|
10
12
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
11
13
|
import { createRequire } from "node:module";
|
|
12
14
|
import { dirname, join, resolve } from "node:path";
|
|
13
15
|
import { pathToFileURL } from "node:url";
|
|
14
|
-
/**
|
|
16
|
+
/** Where the generated OpenNext config lives. It is kept outside `.open-next`
|
|
17
|
+
* because the build erases that every time. */
|
|
15
18
|
export const WORK_DIR = ".runlot-next";
|
|
16
19
|
export const ENTRY_NAME = "runlot-entry.js";
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
21
|
+
* The entry point we stand up.
|
|
19
22
|
*
|
|
20
|
-
* OpenNext
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
+
* It wraps the default export of OpenNext's `worker.js` and lets the other
|
|
24
|
+
* exports (Durable Object classes and so on) pass straight through. `export *`
|
|
25
|
+
* does not re-export the default, so the two lines do not collide.
|
|
23
26
|
*/
|
|
24
|
-
export const ENTRY_SOURCE = `// runlot
|
|
27
|
+
export const ENTRY_SOURCE = `// This file was made by runlot. Edits are overwritten on the next deploy.
|
|
25
28
|
import worker from "./worker.js";
|
|
26
29
|
import { wrap } from "@runlot/next/entry";
|
|
27
30
|
|
|
28
31
|
export * from "./worker.js";
|
|
29
32
|
export default wrap(worker);
|
|
30
33
|
`;
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
/** The OpenNext config we use when the user has not put down one of their own
|
|
35
|
+
* (the table in docs/nextjs.md §2). */
|
|
36
|
+
export const OPEN_NEXT_CONFIG_SOURCE = `// This file was made by runlot. Edits are overwritten on the next deploy.
|
|
37
|
+
// To handle it yourself, put an open-next.config.ts in the project root — if one
|
|
38
|
+
// is there, that is the one we use.
|
|
34
39
|
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
|
|
35
40
|
import queue from "@opennextjs/cloudflare/overrides/queue/memory-queue";
|
|
36
41
|
import incrementalCache from "@runlot/next/opennext/incremental-cache";
|
|
@@ -44,12 +49,13 @@ export default defineCloudflareConfig({
|
|
|
44
49
|
});
|
|
45
50
|
`;
|
|
46
51
|
const USER_CONFIG_NAMES = ["open-next.config.ts", "open-next.config.mjs", "open-next.config.js"];
|
|
47
|
-
/**
|
|
52
|
+
/** Gives the path of the project's own OpenNext config when it has one, and
|
|
53
|
+
* otherwise creates ours and gives that path. */
|
|
48
54
|
export function openNextConfigPath(dir, log) {
|
|
49
55
|
for (const name of USER_CONFIG_NAMES) {
|
|
50
56
|
const path = join(dir, name);
|
|
51
57
|
if (existsSync(path)) {
|
|
52
|
-
log(
|
|
58
|
+
log(`Found ${name}. Building with this configuration.`);
|
|
53
59
|
return path;
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -63,10 +69,10 @@ async function load(path) {
|
|
|
63
69
|
return (await import(pathToFileURL(path).href));
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
|
-
* `next build` → OpenNext →
|
|
72
|
+
* `next build` → OpenNext → our entry point.
|
|
67
73
|
*
|
|
68
|
-
* `process.cwd()`
|
|
69
|
-
*
|
|
74
|
+
* It moves `process.cwd()` to the project: OpenNext's `normalizeOptions` builds
|
|
75
|
+
* the app path and the output path out of the cwd. It is moved back at the end.
|
|
70
76
|
*/
|
|
71
77
|
export async function buildNext(opts) {
|
|
72
78
|
const dir = resolve(opts.dir);
|
|
@@ -77,10 +83,11 @@ export async function buildNext(opts) {
|
|
|
77
83
|
apiIndex = here.resolve("@opennextjs/cloudflare");
|
|
78
84
|
}
|
|
79
85
|
catch {
|
|
80
|
-
throw new Error("@opennextjs/cloudflare
|
|
86
|
+
throw new Error("Could not find @opennextjs/cloudflare. Reinstall @runlot/next.");
|
|
81
87
|
}
|
|
82
|
-
//
|
|
83
|
-
//
|
|
88
|
+
// The package's exports only open `dist/api/*`. The build function is under
|
|
89
|
+
// `dist/cli/`, so it cannot be reached by specifier; we walk sideways from
|
|
90
|
+
// the resolved path.
|
|
84
91
|
const distDir = resolve(dirname(apiIndex), "..");
|
|
85
92
|
const fromCloudflare = createRequire(apiIndex);
|
|
86
93
|
const awsIndex = fromCloudflare.resolve("@opennextjs/aws/index.js");
|
|
@@ -88,14 +95,15 @@ export async function buildNext(opts) {
|
|
|
88
95
|
const { ensureCloudflareConfig } = await load(join(distDir, "cli", "build", "utils", "ensure-cf-config.js"));
|
|
89
96
|
const { compileOpenNextConfig } = await load(fromCloudflare.resolve("@opennextjs/aws/build/compileConfig.js"));
|
|
90
97
|
const { normalizeOptions } = await load(fromCloudflare.resolve("@opennextjs/aws/build/helper.js"));
|
|
91
|
-
// Next
|
|
98
|
+
// Next itself belongs to the user's project. Using ours would split the
|
|
99
|
+
// versions.
|
|
92
100
|
const fromProject = createRequire(join(dir, "package.json"));
|
|
93
101
|
let nextBin;
|
|
94
102
|
try {
|
|
95
103
|
nextBin = fromProject.resolve("next/dist/bin/next");
|
|
96
104
|
}
|
|
97
105
|
catch {
|
|
98
|
-
throw new Error(
|
|
106
|
+
throw new Error(`Could not find next in ${dir}. Run \`npm i next\`, then deploy again.`);
|
|
99
107
|
}
|
|
100
108
|
const configPath = openNextConfigPath(dir, log);
|
|
101
109
|
const previousCwd = process.cwd();
|
|
@@ -103,22 +111,30 @@ export async function buildNext(opts) {
|
|
|
103
111
|
try {
|
|
104
112
|
const { config, buildDir } = await compileOpenNextConfig(configPath, { compileEdge: true });
|
|
105
113
|
ensureCloudflareConfig(config);
|
|
106
|
-
//
|
|
107
|
-
// `npm run build
|
|
108
|
-
//
|
|
114
|
+
// Call the next binary directly rather than the user's `package.json`
|
|
115
|
+
// scripts. It is common for `npm run build` to also do deployment, linting
|
|
116
|
+
// and type checking, and running those again is not something our deploy
|
|
117
|
+
// promised to do.
|
|
109
118
|
config.buildCommand = [JSON.stringify(process.execPath), JSON.stringify(nextBin), "build"].join(" ");
|
|
110
119
|
const options = normalizeOptions(config, dirname(awsIndex), buildDir);
|
|
111
|
-
log("Next.js
|
|
120
|
+
log("Building Next.js…");
|
|
112
121
|
await openNextBuild(options, config, { sourceDir: dir, skipNextBuild: false, skipWranglerConfigCheck: true, minify: true }, {
|
|
113
122
|
...(opts.compatibilityDate !== undefined
|
|
114
123
|
? { compatibility_date: opts.compatibilityDate }
|
|
115
124
|
: {}),
|
|
116
|
-
|
|
125
|
+
// **The worker is first here.** On Cloudflare the platform answers
|
|
126
|
+
// static paths before the worker sees them, and OpenNext's asset
|
|
127
|
+
// resolver reads this flag to decide whether it has to look at ASSETS
|
|
128
|
+
// itself. runlot's socket hands every request to `main`
|
|
129
|
+
// (node/internal/workerd/config.go), so with `false` the resolver
|
|
130
|
+
// returned early and Next answered its own 404 for a file that was
|
|
131
|
+
// sitting right there in the bundle (docs/nextjs.md §8).
|
|
132
|
+
assets: { run_worker_first: true },
|
|
117
133
|
}, false);
|
|
118
134
|
const outputDir = join(dir, ".open-next");
|
|
119
135
|
const worker = join(outputDir, ENTRY_NAME);
|
|
120
136
|
if (!existsSync(join(outputDir, "worker.js"))) {
|
|
121
|
-
throw new Error(
|
|
137
|
+
throw new Error(`Could not find ${outputDir}/worker.js. The OpenNext build did not complete.`);
|
|
122
138
|
}
|
|
123
139
|
writeFileSync(worker, ENTRY_SOURCE);
|
|
124
140
|
return { worker, assets: join(outputDir, "assets"), outputDir };
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,+BAA+B;AAC/B,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,wDAAwD;AACxD,yEAAyE;AACzE,8BAA8B;AAC9B,EAAE;AACF,0EAA0E;AAC1E,YAAY;AACZ,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;gDACgD;AAChD,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAi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AsE;YACtE,wDAAwD;YACxD,kEAAkE;YAClE,mEAAmE;YACnE,yDAAyD;YACzD,MAAM,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE;SACnC,EACD,KAAK,CACN,CAAC;QAEF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,kBAAkB,SAAS,kDAAkD,CAAC,CAAC;QACjG,CAAC;QACD,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACpC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IAClE,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
package/dist/entry.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ export interface FetchHandler {
|
|
|
5
5
|
fetch(request: Request, env: RunlotEnv, ctx: RunlotContext): Response | Promise<Response>;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* OpenNext
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Wraps OpenNext's worker. The exports other than `fetch` (Durable Object
|
|
9
|
+
* classes and so on) are re-exported as they are by the generated
|
|
10
|
+
* `runlot-entry.js`, not by this function — because the only thing that needs
|
|
11
|
+
* wrapping is the request path.
|
|
11
12
|
*/
|
|
12
13
|
export declare function wrap(handler: FetchHandler): FetchHandler;
|
|
13
14
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAaA,OAAO,EAAO,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExF,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC3F;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAMxD"}
|
package/dist/entry.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
//
|
|
1
|
+
// The entry wrapper (docs/nextjs.md §4).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// The build emits `.open-next/runlot-entry.js`, and that file wraps the default
|
|
4
|
+
// export of OpenNext's `worker.js` with this:
|
|
5
5
|
//
|
|
6
6
|
// import worker from "./worker.js";
|
|
7
7
|
// import { wrap } from "@runlot/next/entry";
|
|
8
8
|
// export default wrap(worker);
|
|
9
9
|
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
10
|
+
// It does one thing — it puts one request's `(request, env, ctx)` into the
|
|
11
|
+
// store and calls OpenNext's fetch inside it. That is what lets
|
|
12
|
+
// `env.auth.user()` inside a server component find its own request without an
|
|
13
|
+
// argument.
|
|
13
14
|
import { als } from "./store.js";
|
|
14
15
|
export { als } from "./store.js";
|
|
15
16
|
/**
|
|
16
|
-
* OpenNext
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Wraps OpenNext's worker. The exports other than `fetch` (Durable Object
|
|
18
|
+
* classes and so on) are re-exported as they are by the generated
|
|
19
|
+
* `runlot-entry.js`, not by this function — because the only thing that needs
|
|
20
|
+
* wrapping is the request path.
|
|
19
21
|
*/
|
|
20
22
|
export function wrap(handler) {
|
|
21
23
|
return {
|
package/dist/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,gFAAgF;AAChF,8CAA8C;AAC9C,EAAE;AACF,sCAAsC;AACtC,+CAA+C;AAC/C,iCAAiC;AACjC,EAAE;AACF,2EAA2E;AAC3E,gEAAgE;AAChE,8EAA8E;AAC9E,YAAY;AACZ,OAAO,EAAE,GAAG,EAAsC,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAOjC;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAC,OAAqB;IACxC,OAAO;QACL,KAAK,CAAC,OAAgB,EAAE,GAAc,EAAE,GAAkB;YACxD,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAChF,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { type RunlotEnv } from "./store.js";
|
|
2
2
|
export { als, OUTSIDE_REQUEST } from "./store.js";
|
|
3
|
+
export { noul, choice, score, box } from "./judge.js";
|
|
3
4
|
export type { RunlotAuth, RunlotBindings, RunlotContext, RunlotEnv, RunlotStore, } from "./store.js";
|
|
4
5
|
export type { User, SignOutHeaders } from "@runlot/auth";
|
|
5
6
|
export type { Db, DbSession, Storage, StorageObject } from "@runlot/pg";
|
|
7
|
+
export type { AICallMetadata, AIChatModel, AIEmbedOptions, AIEmbedResult, AIEmbedUsage, AIEmbeddingModel, AIEmbeddingTaskType, AIDecisionModel, AIDecisionMediaLimit, AIJudgeAnswer, AIJudgeAnswerFor, AIJudgeAsset, AIJudgeBoxAnswer, AIJudgeBoxQuestion, AIJudgeChoiceAnswer, AIJudgeChoiceQuestion, AIJudgeNoulAnswer, AIJudgeNoulQuestion, AIJudgeOptions, AIJudgeQuestion, AIJudgeQuestions, AIJudgeRefusal, AIJudgeResult, AIJudgeScoreAnswer, AIJudgeScoreQuestion, AIError, AIFinalTool, AIHTTPError, AIJsonSchema, AIMessage, AIUserMessage, AIAssistantMessage, AIContentPart, AIUserPart, AIAssistantPart, AITextPart, AIToolCallPart, AIToolResultPart, AIReasoningPart, AIToolDefinition, AIToolCall, AIReturnRunOptions, AIReturnRunResult, AIFeature, AIModel, AIModelLane, AIReasoning, AIReasoningEffort, AIResponseFormat, AIRunOptions, AIRunResult, AIStopReason, AIStream, AIStreamDelta, AIStreamDone, AIStreamError, AIStreamUsage, AITerminalToolResult, AITool, AIToolContext, AIToolExecuteResult, AIToolRawResult, AIToolResult, AIToolRunError, AIToolStopResult, AIUsage, RunlotAI, } from "./ai.js";
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* The bindings of this request.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
+
* The name is the single `env`, but at every moment of reading it belongs to
|
|
12
|
+
* that request. Reading it outside a request throws an `Error`
|
|
13
|
+
* (`OUTSIDE_REQUEST`).
|
|
11
14
|
*/
|
|
12
15
|
export declare const env: RunlotEnv;
|
|
13
|
-
/**
|
|
16
|
+
/** The `Request` of this request. For when you need to look at the headers or
|
|
17
|
+
* the URL directly. */
|
|
14
18
|
export declare function request(): Request;
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
20
|
+
* Work that runs to the end even after the response has been sent. Shipping
|
|
21
|
+
* logs and filling a cache are those places.
|
|
17
22
|
*
|
|
18
|
-
* `ctx.waitUntil`
|
|
19
|
-
*
|
|
23
|
+
* In a deployment with no `ctx.waitUntil` (a fake context for tests, say) it
|
|
24
|
+
* does nothing and hands the promise back — it swallows the rejection so a
|
|
25
|
+
* floating one does not kill the process.
|
|
20
26
|
*/
|
|
21
27
|
export declare function waitUntil(promise: Promise<unknown>): void;
|
|
22
|
-
/**
|
|
28
|
+
/** Are we inside a request right now? Only for a library that needs to branch
|
|
29
|
+
* — app code just reads `env`. */
|
|
23
30
|
export declare function inRequest(): boolean;
|
|
24
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EACV,UAAU,EACV,cAAc,EACd,aAAa,EACb,SAAS,EACT,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACzD,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxE,YAAY,EACV,cAAc,EACd,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,MAAM,EACN,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,QAAQ,GACT,MAAM,SAAS,CAAC;AA6BjB;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,EAAE,SAgChB,CAAC;AAEH;wBACwB;AACxB,wBAAgB,OAAO,IAAI,OAAO,CAEjC;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAOzD;AAED;mCACmC;AACnC,wBAAgB,SAAS,IAAI,OAAO,CAEnC"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
// `runlot/next` — Next.js
|
|
1
|
+
// `runlot/next` — the bindings as seen from inside Next.js (docs/nextjs.md §4).
|
|
2
2
|
//
|
|
3
3
|
// import { env } from "runlot/next";
|
|
4
|
-
// const user = await env.auth.user(); //
|
|
4
|
+
// const user = await env.auth.user(); // the adapter hides the request
|
|
5
5
|
// const rows = await env.db.exec("select 1");
|
|
6
6
|
//
|
|
7
|
-
// `env`
|
|
8
|
-
//
|
|
9
|
-
//
|
|
7
|
+
// `env` is a Proxy, not a value. That is the only way to call a bundle that
|
|
8
|
+
// differs per request by one module-level name, and it is why **reading it
|
|
9
|
+
// outside a request throws** — module top level and build-time static rendering
|
|
10
|
+
// are those places.
|
|
10
11
|
//
|
|
11
|
-
//
|
|
12
|
+
// Package name: `@runlot/next` inside the workspace, `runlot/next` on npm.
|
|
12
13
|
import { als, store } from "./store.js";
|
|
13
14
|
export { als, OUTSIDE_REQUEST } from "./store.js";
|
|
15
|
+
export { noul, choice, score, box } from "./judge.js";
|
|
14
16
|
/**
|
|
15
|
-
* `env.auth
|
|
16
|
-
*
|
|
17
|
+
* One layer over `env.auth`. When `user()` or `signOut()` is called without an
|
|
18
|
+
* argument it puts in the request from the store, and everything else
|
|
19
|
+
* (`users`, `sessions`, the flat aliases) is passed straight through.
|
|
17
20
|
*/
|
|
18
21
|
function wrapAuth(auth, request) {
|
|
19
22
|
return new Proxy(auth, {
|
|
@@ -21,29 +24,39 @@ function wrapAuth(auth, request) {
|
|
|
21
24
|
const value = Reflect.get(target, prop, receiver);
|
|
22
25
|
if (typeof value !== "function")
|
|
23
26
|
return value;
|
|
27
|
+
// **`target` is a workerd RPC stub, not an object.** Reading `.call` or
|
|
28
|
+
// `.bind` off one of its methods does not reach Function.prototype — it
|
|
29
|
+
// asks the *remote* side for a method by that name, and the answer is
|
|
30
|
+
// `TypeError: The RPC receiver does not implement the method "call"`.
|
|
31
|
+
// Measured on dev, not in tests: the unit tests pass a plain object, and
|
|
32
|
+
// on a plain object both work (docs/nextjs.md §9). Go through the
|
|
33
|
+
// property on every invocation instead, which is right for both.
|
|
34
|
+
const invoke = (...args) => target[prop](...args);
|
|
24
35
|
if (prop === "user" || prop === "signOut") {
|
|
25
|
-
return (given) =>
|
|
36
|
+
return (given) => invoke(given ?? request);
|
|
26
37
|
}
|
|
27
|
-
return
|
|
38
|
+
return invoke;
|
|
28
39
|
},
|
|
29
40
|
});
|
|
30
41
|
}
|
|
31
42
|
/**
|
|
32
|
-
*
|
|
43
|
+
* The bindings of this request.
|
|
33
44
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
45
|
+
* The name is the single `env`, but at every moment of reading it belongs to
|
|
46
|
+
* that request. Reading it outside a request throws an `Error`
|
|
47
|
+
* (`OUTSIDE_REQUEST`).
|
|
36
48
|
*/
|
|
37
49
|
export const env = new Proxy({}, {
|
|
38
50
|
get(_target, prop) {
|
|
39
51
|
const s = store();
|
|
40
52
|
if (prop === "auth") {
|
|
41
53
|
const auth = s.env["auth"];
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
54
|
+
// For a project with no binding (login turned off) it
|
|
55
|
+
// is undefined. Wrapping it would raise a "user is not a function"
|
|
56
|
+
// TypeError from inside our proxy, so instead we say right here what is
|
|
57
|
+
// missing.
|
|
45
58
|
if (auth === undefined || auth === null) {
|
|
46
|
-
throw new Error("env.auth
|
|
59
|
+
throw new Error("There is no env.auth binding: login is off for this project. Turn it on with `runlot auth on` and deploy again.");
|
|
47
60
|
}
|
|
48
61
|
return wrapAuth(auth, s.request);
|
|
49
62
|
}
|
|
@@ -57,23 +70,27 @@ export const env = new Proxy({}, {
|
|
|
57
70
|
},
|
|
58
71
|
getOwnPropertyDescriptor(_target, prop) {
|
|
59
72
|
const d = Reflect.getOwnPropertyDescriptor(store().env, prop);
|
|
60
|
-
//
|
|
61
|
-
//
|
|
73
|
+
// The target is an empty object. Returning `configurable: false` as it is
|
|
74
|
+
// violates a proxy invariant and makes `Object.keys(env)` throw a
|
|
75
|
+
// TypeError.
|
|
62
76
|
return d === undefined ? undefined : { ...d, configurable: true };
|
|
63
77
|
},
|
|
64
78
|
set() {
|
|
65
|
-
throw new Error("env
|
|
79
|
+
throw new Error("env is read-only. To change a value, change a secret or a binding.");
|
|
66
80
|
},
|
|
67
81
|
});
|
|
68
|
-
/**
|
|
82
|
+
/** The `Request` of this request. For when you need to look at the headers or
|
|
83
|
+
* the URL directly. */
|
|
69
84
|
export function request() {
|
|
70
85
|
return store().request;
|
|
71
86
|
}
|
|
72
87
|
/**
|
|
73
|
-
*
|
|
88
|
+
* Work that runs to the end even after the response has been sent. Shipping
|
|
89
|
+
* logs and filling a cache are those places.
|
|
74
90
|
*
|
|
75
|
-
* `ctx.waitUntil`
|
|
76
|
-
*
|
|
91
|
+
* In a deployment with no `ctx.waitUntil` (a fake context for tests, say) it
|
|
92
|
+
* does nothing and hands the promise back — it swallows the rejection so a
|
|
93
|
+
* floating one does not kill the process.
|
|
77
94
|
*/
|
|
78
95
|
export function waitUntil(promise) {
|
|
79
96
|
const { ctx } = store();
|
|
@@ -83,7 +100,8 @@ export function waitUntil(promise) {
|
|
|
83
100
|
}
|
|
84
101
|
void promise.catch(() => { });
|
|
85
102
|
}
|
|
86
|
-
/**
|
|
103
|
+
/** Are we inside a request right now? Only for a library that needs to branch
|
|
104
|
+
* — app code just reads `env`. */
|
|
87
105
|
export function inRequest() {
|
|
88
106
|
return als.getStore() !== undefined;
|
|
89
107
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,uCAAuC;AACvC,kFAAkF;AAClF,gDAAgD;AAChD,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,gFAAgF;AAChF,oBAAoB;AACpB,EAAE;AACF,2EAA2E;AAC3E,OAAO,EAAE,GAAG,EAAE,KAAK,EAAmC,MAAM,YAAY,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE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AAU,SAAS;IACvB,OAAO,GAAG,CAAC,QAAQ,EAAE,KAAK,SAAS,CAAC;AACtC,CAAC"}
|
package/dist/judge.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AIJudgeBoxQuestion } from "./ai.js";
|
|
2
|
+
/** A yes/no question; the answer is the probability of yes. */
|
|
3
|
+
export declare function noul<const I>(instructions: I, criteria?: {
|
|
4
|
+
readonly true?: unknown;
|
|
5
|
+
readonly false?: unknown;
|
|
6
|
+
}): {
|
|
7
|
+
readonly type: "noul";
|
|
8
|
+
readonly instructions: I;
|
|
9
|
+
readonly criteria?: {
|
|
10
|
+
readonly true?: unknown;
|
|
11
|
+
readonly false?: unknown;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/** One option of a set, option name → description; the answer names one. */
|
|
15
|
+
export declare function choice<const I, const O extends {
|
|
16
|
+
readonly [option: string]: unknown;
|
|
17
|
+
}>(instructions: I, options: O): {
|
|
18
|
+
readonly type: "choice";
|
|
19
|
+
readonly instructions: I;
|
|
20
|
+
readonly criteria: O;
|
|
21
|
+
};
|
|
22
|
+
/** A position on an ordered rubric, levels lowest first. */
|
|
23
|
+
export declare function score<const I, const L extends readonly unknown[]>(instructions: I, levels: L): {
|
|
24
|
+
readonly type: "score";
|
|
25
|
+
readonly instructions: I;
|
|
26
|
+
readonly criteria: L;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Where something is in an image — on a model whose `questionTypes` lists
|
|
30
|
+
* `box`, with an image in `options.assets`. The answer is one box; there is no
|
|
31
|
+
* "not found", so ask a `noul` beside it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function box<const I>(instructions: I): AIJudgeBoxQuestion & {
|
|
34
|
+
readonly instructions: I;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=judge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judge.d.ts","sourceRoot":"","sources":["../src/judge.ts"],"names":[],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CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,kBAAkB,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAA;CAAE,CAE/F"}
|
package/dist/judge.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Question builders for `env.ai.judge` (docs/decision-models.md "As built").
|
|
2
|
+
//
|
|
3
|
+
// Each returns the plain question object System One defines — nothing is
|
|
4
|
+
// wrapped, nothing calls a vendor SDK — and its literal type, so `judge` can
|
|
5
|
+
// type each answer by its question: a choice's `choice` is the union of the
|
|
6
|
+
// option names you wrote.
|
|
7
|
+
/** A yes/no question; the answer is the probability of yes. */
|
|
8
|
+
export function noul(instructions, criteria) {
|
|
9
|
+
return criteria === undefined ? { type: "noul", instructions } : { type: "noul", instructions, criteria };
|
|
10
|
+
}
|
|
11
|
+
/** One option of a set, option name → description; the answer names one. */
|
|
12
|
+
export function choice(instructions, options) {
|
|
13
|
+
return { type: "choice", instructions, criteria: options };
|
|
14
|
+
}
|
|
15
|
+
/** A position on an ordered rubric, levels lowest first. */
|
|
16
|
+
export function score(instructions, levels) {
|
|
17
|
+
return { type: "score", instructions, criteria: levels };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Where something is in an image — on a model whose `questionTypes` lists
|
|
21
|
+
* `box`, with an image in `options.assets`. The answer is one box; there is no
|
|
22
|
+
* "not found", so ask a `noul` beside it.
|
|
23
|
+
*/
|
|
24
|
+
export function box(instructions) {
|
|
25
|
+
return { type: "box", instructions };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=judge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judge.js","sourceRoot":"","sources":["../src/judge.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,4EAA4E;AAC5E,0BAA0B;AAI1B,+DAA+D;AAC/D,MAAM,UAAU,IAAI,CAClB,YAAe,EACf,QAAgE;IAEhE,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAC5G,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,MAAM,CACpB,YAAe,EACf,OAAU;IAEV,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC7D,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,KAAK,CACnB,YAAe,EACf,MAAS;IAET,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAU,YAAe;IAC1C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;AACvC,CAAC"}
|