@runlot/next 0.1.0-rc.15 → 0.1.0-rc.151
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 +223 -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 +14 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -25
- package/dist/index.js.map +1 -1
- 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/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @runlot/next
|
|
2
2
|
|
|
3
|
-
Next.js
|
|
3
|
+
Next.js 어댑터입니다. 이 문서는 패키지 사용법을 설명합니다.
|
|
4
4
|
|
|
5
|
-
> **npm 이름은
|
|
5
|
+
> **npm 패키지 이름은 `@runlot/next` 입니다.** 예제와 템플릿의 import 지정자도 같습니다.
|
|
6
6
|
> 랜딩의 코드 예시와 템플릿이 쓰는 지정자는 `runlot/next` 다 (`import { env }
|
|
7
7
|
> from "runlot/next"`). 게시할 때 이름을 바꾸는 자리가 여기 하나뿐이도록,
|
|
8
8
|
> 이 패키지 안에서는 자기 이름을 문자열로 쓰지 않는다 — 예외는 빌드가 만드는
|
|
@@ -11,9 +11,9 @@ Next.js 어댑터. 설계는 `docs/nextjs.md` 에 있고, 이 문서는 표면
|
|
|
11
11
|
## 표면
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { env, request, waitUntil } from "runlot/next";
|
|
14
|
+
import { env, request, waitUntil } from "@runlot/next";
|
|
15
15
|
|
|
16
|
-
const user = await env.auth.user(); // 요청은 어댑터가
|
|
16
|
+
const user = await env.auth.user(); // 요청은 어댑터가 알아서 넘깁니다
|
|
17
17
|
const rows = await env.db.exec("select 1");
|
|
18
18
|
const url = await env.storage.presign("covers/a.png");
|
|
19
19
|
const token = env.MY_SECRET; // 나머지는 문자열이다
|
|
@@ -21,15 +21,15 @@ const token = env.MY_SECRET; // 나머지는 문자열이다
|
|
|
21
21
|
|
|
22
22
|
| 이름 | 무엇 |
|
|
23
23
|
|---|---|
|
|
24
|
-
| `env` | 이 요청의 바인딩. **요청 밖에서 읽으면
|
|
24
|
+
| `env` | 이 요청의 바인딩. **요청 밖에서 읽으면 오류를 냅니다** |
|
|
25
25
|
| `env.auth.user(request?)` | 인자가 없으면 이 요청. `signOut` 도 같다 |
|
|
26
26
|
| `request()` | 이 요청의 `Request` |
|
|
27
27
|
| `waitUntil(p)` | 응답 뒤에도 끝까지 도는 일 |
|
|
28
28
|
| `inRequest()` | 지금 요청 안인가. 라이브러리가 갈래를 나눌 때만 |
|
|
29
|
-
| `wrap(worker)` (
|
|
30
|
-
| `buildNext(opts)` (
|
|
29
|
+
| `wrap(worker)` (`@runlot/next/entry`) | 빌드가 세우는 진입 wrapper |
|
|
30
|
+
| `buildNext(opts)` (`@runlot/next/build`) | `runlot deploy` 가 부릅니다 |
|
|
31
31
|
|
|
32
|
-
`env` 가 요청 밖에서
|
|
32
|
+
`env` 가 요청 밖에서 오류를 내는 것은 의도된 설계입니다. 모듈 최상단과 빌드 시점 정적 렌더가
|
|
33
33
|
그 자리이고, 거기서 조용히 빈 값을 주면 **모든 페이지가 로그아웃 상태로**
|
|
34
34
|
보인다 (`docs/auth.md §4` 의 같은 문장).
|
|
35
35
|
|
|
@@ -55,7 +55,7 @@ const token = env.MY_SECRET; // 나머지는 문자열이다
|
|
|
55
55
|
| queue | OpenNext 의 `memory-queue` (`WORKER_SELF_REFERENCE` 를 쓴다) | — |
|
|
56
56
|
| enableCacheInterception | `true` | — |
|
|
57
57
|
|
|
58
|
-
## wrangler 는 의존이
|
|
58
|
+
## wrangler 는 의존이 아닙니다
|
|
59
59
|
|
|
60
60
|
`@opennextjs/cloudflare` 의 `peerDependencies` 에 `wrangler` 가 있지만, 런타임에
|
|
61
61
|
그것을 import 하는 것은 `dist/cli/commands/*` 뿐이다. 우리가 부르는
|
|
@@ -63,7 +63,7 @@ const token = env.MY_SECRET; // 나머지는 문자열이다
|
|
|
63
63
|
`dependencies` 에 두지 않는다 — pnpm 이 peer 를 자동 설치하는 워크스페이스에서는
|
|
64
64
|
스토어에 내려와 있을 수 있지만, 우리 코드 경로는 그것을 부르지 않는다.
|
|
65
65
|
|
|
66
|
-
##
|
|
66
|
+
## 요청 상태는 globalThis 의 심볼에 둡니다
|
|
67
67
|
|
|
68
68
|
`Symbol.for("runlot.next.store")`. 모듈 인스턴스가 하나라는 보장이 없어서다:
|
|
69
69
|
OpenNext 의 `worker.js` 는 이미 묶인 번들이라 그 안에 이 패키지의 사본이 있고,
|
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/** A JSON Schema object accepted by `responseFormat` and `inputJsonSchema`. */
|
|
2
|
+
export type AIJsonSchema = Record<string, unknown>;
|
|
3
|
+
/** One conversational message. System instructions belong in `AIRunOptions.system`. */
|
|
4
|
+
export interface AIMessage {
|
|
5
|
+
role: "user" | "assistant";
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
/** Token usage returned by a chat run and accumulated across tool rounds. */
|
|
9
|
+
export interface AIUsage {
|
|
10
|
+
inputTokens: number;
|
|
11
|
+
outputTokens: number;
|
|
12
|
+
cachedInputTokens: number;
|
|
13
|
+
}
|
|
14
|
+
/** Every reasoning-effort value currently advertised by the model catalog. */
|
|
15
|
+
export type AIReasoningEffort = "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
16
|
+
export interface AIReasoning {
|
|
17
|
+
effort: AIReasoningEffort;
|
|
18
|
+
}
|
|
19
|
+
/** Ask a supported model for JSON conforming to `schema`. */
|
|
20
|
+
export interface AIResponseFormat {
|
|
21
|
+
type: "json_schema";
|
|
22
|
+
/** Optional provider-facing schema name. The runtime defaults it to `response`. */
|
|
23
|
+
name?: string;
|
|
24
|
+
schema: AIJsonSchema;
|
|
25
|
+
}
|
|
26
|
+
export interface AIToolContext {
|
|
27
|
+
/** Aborted when the caller aborts the run or the remote tool session ends. */
|
|
28
|
+
signal: AbortSignal;
|
|
29
|
+
/** The id that correlates this callback with the model's tool call. */
|
|
30
|
+
callId: string;
|
|
31
|
+
model: string;
|
|
32
|
+
}
|
|
33
|
+
/** A normal tool result. A thrown error is converted to `{ text, isError: true }`. */
|
|
34
|
+
export interface AIToolResult<Data = unknown> {
|
|
35
|
+
text?: string;
|
|
36
|
+
data?: Data;
|
|
37
|
+
isError?: boolean;
|
|
38
|
+
stop?: false;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A terminal tool result. The facade acknowledges remote cancellation instead
|
|
42
|
+
* of submitting it to the model, then returns without another model round.
|
|
43
|
+
*/
|
|
44
|
+
export interface AITerminalToolResult<Data = unknown> {
|
|
45
|
+
stop: true;
|
|
46
|
+
text?: string;
|
|
47
|
+
data?: Data;
|
|
48
|
+
}
|
|
49
|
+
/** A non-object return is wrapped as the tool result's `data` field. */
|
|
50
|
+
export type AIToolRawResult = string | number | boolean | null | undefined | readonly unknown[];
|
|
51
|
+
export type AIToolExecuteResult<Data = unknown> = AIToolResult<Data> | AITerminalToolResult<Data> | AIToolRawResult;
|
|
52
|
+
/** A callback tool whose closure remains in the originating app worker. */
|
|
53
|
+
export interface AITool<Args extends Record<string, unknown> = Record<string, unknown>, Data = unknown> {
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
inputJsonSchema: AIJsonSchema;
|
|
57
|
+
execute(args: Args, context: AIToolContext): AIToolExecuteResult<Data> | Promise<AIToolExecuteResult<Data>>;
|
|
58
|
+
}
|
|
59
|
+
export interface AIFinalTool<Args extends Record<string, unknown> = Record<string, unknown>, Data = unknown> {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
args: Args;
|
|
63
|
+
result: AITerminalToolResult<Data>;
|
|
64
|
+
}
|
|
65
|
+
/** Provider stop reasons are open-ended; `tool_stop` is added by Runlot. */
|
|
66
|
+
export type AIStopReason = "tool_stop" | (string & {});
|
|
67
|
+
export interface AIRunResult {
|
|
68
|
+
text: string;
|
|
69
|
+
model: string;
|
|
70
|
+
stopReason: AIStopReason;
|
|
71
|
+
usage: AIUsage;
|
|
72
|
+
/** False means `usage` is the amount observed before termination, not an exact final total. */
|
|
73
|
+
usageComplete: boolean;
|
|
74
|
+
/** Present when a callback returned `{ stop: true }`. */
|
|
75
|
+
finalTool?: AIFinalTool;
|
|
76
|
+
}
|
|
77
|
+
export interface AIToolStopResult extends AIRunResult {
|
|
78
|
+
stopReason: "tool_stop";
|
|
79
|
+
finalTool: AIFinalTool;
|
|
80
|
+
}
|
|
81
|
+
type AIRunInput = {
|
|
82
|
+
prompt: string;
|
|
83
|
+
messages?: string | readonly AIMessage[];
|
|
84
|
+
} | {
|
|
85
|
+
messages: string | readonly AIMessage[];
|
|
86
|
+
prompt?: string;
|
|
87
|
+
};
|
|
88
|
+
interface AIRunSettings {
|
|
89
|
+
system?: string;
|
|
90
|
+
maxTokens?: number;
|
|
91
|
+
temperature?: number;
|
|
92
|
+
reasoning?: AIReasoning;
|
|
93
|
+
responseFormat?: AIResponseFormat;
|
|
94
|
+
tools?: readonly AITool[];
|
|
95
|
+
/** Defaults to 8 and is bounded by the runtime. */
|
|
96
|
+
maxToolRounds?: number;
|
|
97
|
+
/** Used by the app-worker tool loop. */
|
|
98
|
+
signal?: AbortSignal;
|
|
99
|
+
}
|
|
100
|
+
/** Options shared by streaming and non-streaming model runs. */
|
|
101
|
+
export type AIRunOptions = AIRunInput & AIRunSettings & {
|
|
102
|
+
stream?: boolean;
|
|
103
|
+
};
|
|
104
|
+
export type AIStream = ReadableStream<Uint8Array>;
|
|
105
|
+
/** A text frame in the public SSE stream. */
|
|
106
|
+
export interface AIStreamDelta {
|
|
107
|
+
delta: string;
|
|
108
|
+
}
|
|
109
|
+
/** A usage frame emitted by a tool-bearing stream after a completed round. */
|
|
110
|
+
export interface AIStreamUsage extends AIUsage {
|
|
111
|
+
/** True for a provider's cumulative total, absent for per-round usage. */
|
|
112
|
+
cumulative?: boolean;
|
|
113
|
+
round?: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The `done` payload. Plain model streams guarantee `model`; tool-bearing
|
|
117
|
+
* streams also include the accumulated result fields.
|
|
118
|
+
*/
|
|
119
|
+
export interface AIStreamDone {
|
|
120
|
+
model: string;
|
|
121
|
+
text?: string;
|
|
122
|
+
stopReason?: AIStopReason;
|
|
123
|
+
usage?: AIUsage;
|
|
124
|
+
/** False means `usage` is only what was observable before the stream stopped. */
|
|
125
|
+
usageComplete?: boolean;
|
|
126
|
+
finalTool?: AIFinalTool;
|
|
127
|
+
}
|
|
128
|
+
/** A mid-stream failure payload. Rich context is present on tool-bearing runs. */
|
|
129
|
+
export interface AIStreamError {
|
|
130
|
+
message: string;
|
|
131
|
+
code?: string;
|
|
132
|
+
text?: string;
|
|
133
|
+
model?: string;
|
|
134
|
+
usage?: AIUsage;
|
|
135
|
+
/** Tool errors report partial observed usage; plain streams may omit this. */
|
|
136
|
+
usageComplete?: false;
|
|
137
|
+
/** Present when the terminal callback completed but remote cancellation failed. */
|
|
138
|
+
finalTool?: AIFinalTool;
|
|
139
|
+
}
|
|
140
|
+
/** Fields attached to errors returned before an HTTP stream starts. */
|
|
141
|
+
export interface AIHTTPError extends Error {
|
|
142
|
+
status: number;
|
|
143
|
+
code: string;
|
|
144
|
+
text?: string;
|
|
145
|
+
usage?: AIUsage;
|
|
146
|
+
model?: string;
|
|
147
|
+
/** Pre-stream failures have no final usage; when present this is false. */
|
|
148
|
+
usageComplete?: false;
|
|
149
|
+
}
|
|
150
|
+
/** Fields attached when a tool loop fails after producing partial work. */
|
|
151
|
+
export interface AIToolRunError extends Error {
|
|
152
|
+
code?: string;
|
|
153
|
+
text: string;
|
|
154
|
+
usage: AIUsage;
|
|
155
|
+
/** Errors report partial observed usage, so this is false. */
|
|
156
|
+
usageComplete: boolean;
|
|
157
|
+
model: string;
|
|
158
|
+
/** Present when the terminal callback completed but remote cancellation failed. */
|
|
159
|
+
finalTool?: AIFinalTool;
|
|
160
|
+
status?: number;
|
|
161
|
+
}
|
|
162
|
+
/** The union useful when narrowing an unknown `env.ai` failure. */
|
|
163
|
+
export type AIError = AIHTTPError | AIToolRunError;
|
|
164
|
+
/** Every task type currently accepted by the task-aware embedding model. */
|
|
165
|
+
export type AIEmbeddingTaskType = "RETRIEVAL_QUERY" | "RETRIEVAL_DOCUMENT" | "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY";
|
|
166
|
+
export interface AIEmbedOptions {
|
|
167
|
+
dimensions?: number;
|
|
168
|
+
/** Omit this to retain the model's own default embedding space. */
|
|
169
|
+
taskType?: AIEmbeddingTaskType;
|
|
170
|
+
}
|
|
171
|
+
export interface AIEmbedUsage {
|
|
172
|
+
inputTokens: number;
|
|
173
|
+
}
|
|
174
|
+
export interface AIEmbedResult {
|
|
175
|
+
/** `vectors[i]` belongs to `input[i]`. */
|
|
176
|
+
vectors: number[][];
|
|
177
|
+
dimensions: number;
|
|
178
|
+
model: string;
|
|
179
|
+
usage: AIEmbedUsage;
|
|
180
|
+
/** Echoed only when the request supplied a task type. */
|
|
181
|
+
taskType?: AIEmbeddingTaskType;
|
|
182
|
+
}
|
|
183
|
+
export type AIModelLane = "frontier" | "value";
|
|
184
|
+
interface AIModelBase {
|
|
185
|
+
id: string;
|
|
186
|
+
lane: AIModelLane;
|
|
187
|
+
display: string;
|
|
188
|
+
vendor: string;
|
|
189
|
+
contextTokens: number;
|
|
190
|
+
maxInputTokens: number;
|
|
191
|
+
maxOutputTokens: number;
|
|
192
|
+
frontier: boolean;
|
|
193
|
+
}
|
|
194
|
+
export interface AIChatModel extends AIModelBase {
|
|
195
|
+
kind: "chat";
|
|
196
|
+
effortLevels?: AIReasoningEffort[];
|
|
197
|
+
/** Present as `true` only when this model accepts `responseFormat`. */
|
|
198
|
+
structuredOutput?: true;
|
|
199
|
+
dimensions?: never;
|
|
200
|
+
dimensionOptions?: never;
|
|
201
|
+
}
|
|
202
|
+
export interface AIEmbeddingModel extends AIModelBase {
|
|
203
|
+
kind: "embedding";
|
|
204
|
+
dimensions: number;
|
|
205
|
+
dimensionOptions?: number[];
|
|
206
|
+
effortLevels?: never;
|
|
207
|
+
structuredOutput?: never;
|
|
208
|
+
}
|
|
209
|
+
export type AIModel = AIChatModel | AIEmbeddingModel;
|
|
210
|
+
/** The public `env.ai` binding. */
|
|
211
|
+
export interface RunlotAI {
|
|
212
|
+
run(model: string, options: AIRunOptions & {
|
|
213
|
+
stream: true;
|
|
214
|
+
}): Promise<AIStream>;
|
|
215
|
+
run(model: string, options: AIRunOptions & {
|
|
216
|
+
stream?: false;
|
|
217
|
+
}): Promise<AIRunResult>;
|
|
218
|
+
run(model: string, options: AIRunOptions): Promise<AIRunResult | AIStream>;
|
|
219
|
+
embed(model: string, input: string | readonly string[], options?: AIEmbedOptions): Promise<AIEmbedResult>;
|
|
220
|
+
models(): Promise<AIModel[]>;
|
|
221
|
+
}
|
|
222
|
+
export {};
|
|
223
|
+
//# sourceMappingURL=ai.d.ts.map
|
package/dist/ai.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnD,uFAAuF;AACvF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6EAA6E;AAC7E,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAErF,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,6DAA6D;AAC7D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,8EAA8E;IAC9E,MAAM,EAAE,WAAW,CAAC;IACpB,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,sFAAsF;AACtF,MAAM,WAAW,YAAY,CAAC,IAAI,GAAG,OAAO;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IA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B,CAAC,EAAE,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,gBAAgB,CAAC,EAAE,KAAK,CAAC;CAC1B;AAED,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAErD,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChF,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG;QAAE,MAAM,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACrF,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,GAAG,QAAQ,CAAC,CAAC;IAE3E,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1G,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC9B"}
|
package/dist/ai.js
ADDED
package/dist/ai.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":""}
|
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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AAiB,EAAE;gBAChD,CAAC,CAAC,EAAE,CAAC;YACP,mEAAmE;YACnE,iEAAiE;YACjE,sEAAsE;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 {
|