foldkit-plus 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -28
- package/dist/cli.mjs +10389 -35
- package/dist/cli.mjs.map +1 -1
- package/dist/docs.d.mts +89 -0
- package/dist/docs.d.mts.map +1 -0
- package/dist/docs.mjs +290 -0
- package/dist/docs.mjs.map +1 -0
- package/dist/mixins-crud/recipes.d.mts +1 -0
- package/dist/mixins-crud/recipes.mjs +2 -0
- package/dist/mixins-form/recipes.d.mts +1 -0
- package/dist/mixins-form/recipes.mjs +2 -0
- package/dist/project.d.mts +45 -0
- package/dist/project.d.mts.map +1 -0
- package/dist/project.mjs +205 -0
- package/dist/project.mjs.map +1 -0
- package/dist/remote/testing.d.mts +1 -0
- package/dist/remote/testing.mjs +2 -0
- package/dist/setup.d.mts +35 -7
- package/dist/setup.d.mts.map +1 -1
- package/dist/setup.mjs +148 -24
- package/dist/setup.mjs.map +1 -1
- package/dist/testing/peer.d.mts +8 -0
- package/dist/testing/peer.d.mts.map +1 -0
- package/dist/testing/peer.mjs +19 -0
- package/dist/testing/peer.mjs.map +1 -0
- package/dist/testing/playwright.d.mts +49 -0
- package/dist/testing/playwright.d.mts.map +1 -0
- package/dist/testing/playwright.mjs +171 -0
- package/dist/testing/playwright.mjs.map +1 -0
- package/dist/testing/workers.d.mts +103 -0
- package/dist/testing/workers.d.mts.map +1 -0
- package/dist/testing/workers.mjs +320 -0
- package/dist/testing/workers.mjs.map +1 -0
- package/package.json +100 -59
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { peer } from "./peer.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { Option, Schema } from "effect";
|
|
4
|
+
import { watch } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
7
|
+
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
8
|
+
// src/testing/workers.ts
|
|
9
|
+
/**
|
|
10
|
+
* `foldkit-plus/testing/workers`: a Worker on a local workerd, configured by
|
|
11
|
+
* its own Wrangler configuration.
|
|
12
|
+
*
|
|
13
|
+
* Wrangler's test harness reads the configuration, so bindings, the
|
|
14
|
+
* compatibility date and flags, `.dev.vars` and D1 migrations mean here what
|
|
15
|
+
* they mean to `wrangler deploy`. This module owns only what Wrangler cannot
|
|
16
|
+
* know: the bundle. esbuild builds the entry with the workspace's source
|
|
17
|
+
* condition into a directory of the stack's own, and the harness runs the
|
|
18
|
+
* configuration with `main` pointed there.
|
|
19
|
+
*
|
|
20
|
+
* `wrangler` and `esbuild` are optional peers of `foldkit-plus`, loaded on the
|
|
21
|
+
* first call; Miniflare is read from Wrangler's own copy, so the date check
|
|
22
|
+
* asks the runtime Wrangler starts.
|
|
23
|
+
*/
|
|
24
|
+
const SUBPATH = "testing/workers";
|
|
25
|
+
const wrangler = () => peer(SUBPATH, "wrangler", () => import("wrangler"));
|
|
26
|
+
const esbuild = () => peer(SUBPATH, "esbuild", () => import("esbuild"));
|
|
27
|
+
/**
|
|
28
|
+
* The part of the configuration the stack reads itself. Wrangler validates
|
|
29
|
+
* the whole of it when the harness loads it.
|
|
30
|
+
*/
|
|
31
|
+
const Config = Schema.Struct({
|
|
32
|
+
main: Schema.String,
|
|
33
|
+
compatibility_date: Schema.String,
|
|
34
|
+
no_bundle: Schema.Literal(true),
|
|
35
|
+
d1_databases: Schema.optional(Schema.Array(Schema.Struct({ binding: Schema.String })))
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* The newest date the workerd Wrangler starts supports, from Wrangler's own
|
|
39
|
+
* Miniflare: an application's own `miniflare` may be another release. Call it
|
|
40
|
+
* after `wrangler()`, which says so when Wrangler is missing.
|
|
41
|
+
*/
|
|
42
|
+
const supportedDate = () => {
|
|
43
|
+
const fromWrangler = createRequire(createRequire(import.meta.url).resolve("wrangler"));
|
|
44
|
+
return Schema.decodeUnknownSync(Schema.Struct({ supportedCompatibilityDate: Schema.String }))(fromWrangler("miniflare")).supportedCompatibilityDate;
|
|
45
|
+
};
|
|
46
|
+
const readConfig = async (path) => {
|
|
47
|
+
const { experimental_readRawConfig } = await wrangler();
|
|
48
|
+
const { rawConfig: raw } = experimental_readRawConfig({ config: path });
|
|
49
|
+
if ("env" in raw) throw new Error(`${path}: the local stack runs the top-level Worker; [env.*] is not read.`);
|
|
50
|
+
const config = Schema.decodeUnknownSync(Config)(raw);
|
|
51
|
+
const supported = supportedDate();
|
|
52
|
+
if (config.compatibility_date > supported) throw new Error(`${path} asks for compatibility_date ${config.compatibility_date}, but the installed workerd supports up to ${supported}. Move wrangler to a release that knows it.`);
|
|
53
|
+
return {
|
|
54
|
+
raw,
|
|
55
|
+
config
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* How the entry is bundled, for the stack and for `wrangler deploy`: the
|
|
60
|
+
* script at `outfile`, and beside it any `.wasm` it imports, which `no_bundle`
|
|
61
|
+
* Wrangler loads as a compiled module. `node:*` stays external for
|
|
62
|
+
* `nodejs_compat`.
|
|
63
|
+
*/
|
|
64
|
+
const bundleOptions = (options, outfile) => ({
|
|
65
|
+
entryPoints: [options.entry],
|
|
66
|
+
bundle: true,
|
|
67
|
+
format: "esm",
|
|
68
|
+
platform: "browser",
|
|
69
|
+
conditions: ["foldkit-plus:source"],
|
|
70
|
+
external: ["cloudflare:workers", "node:*"],
|
|
71
|
+
loader: { ".wasm": "copy" },
|
|
72
|
+
plugins: [...options.plugins ?? []],
|
|
73
|
+
outdir: dirname(outfile),
|
|
74
|
+
entryNames: basename(outfile, ".js"),
|
|
75
|
+
write: false,
|
|
76
|
+
logLevel: "silent"
|
|
77
|
+
});
|
|
78
|
+
const writeOutputs = async (files) => {
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
await mkdir(dirname(file.path), { recursive: true });
|
|
81
|
+
await writeFile(file.path, file.contents);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const identityOf = (files) => files.map((file) => `${file.path}:${file.hash}`).join();
|
|
85
|
+
/** Node's console method for each level workerd writes; any other prints as a log. */
|
|
86
|
+
const printers = /* @__PURE__ */ new Map([
|
|
87
|
+
["debug", (line) => console.debug(line)],
|
|
88
|
+
["info", (line) => console.info(line)],
|
|
89
|
+
["warn", (line) => console.warn(line)],
|
|
90
|
+
["error", (line) => console.error(line)]
|
|
91
|
+
]);
|
|
92
|
+
const print = (log) => (printers.get(log.level) ?? ((line) => console.log(line)))(`[worker] ${log.message}`);
|
|
93
|
+
const errorText = (error) => error instanceof Error ? error.message : String(error);
|
|
94
|
+
/** Writes the bundle where `main` says, for `wrangler deploy`. */
|
|
95
|
+
const writeBundle = async (options) => {
|
|
96
|
+
const { config } = await readConfig(options.wrangler);
|
|
97
|
+
const outfile = resolve(dirname(options.wrangler), config.main);
|
|
98
|
+
const { build } = await esbuild();
|
|
99
|
+
await writeOutputs((await build(bundleOptions(options, outfile))).outputFiles);
|
|
100
|
+
};
|
|
101
|
+
const migrate = async (worker, config) => {
|
|
102
|
+
for (const database of config.d1_databases ?? []) await worker.applyD1Migrations(database.binding);
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Starts the Worker with a fresh, migrated D1 for each `[[d1_databases]]`,
|
|
106
|
+
* and empty R2 and Durable Object storage. Each call is a stack of its own,
|
|
107
|
+
* so test files running side by side share nothing.
|
|
108
|
+
*/
|
|
109
|
+
const start = async (options) => {
|
|
110
|
+
const { raw, config } = await readConfig(options.wrangler);
|
|
111
|
+
const { build, context } = await esbuild();
|
|
112
|
+
const { createTestHarness } = await wrangler();
|
|
113
|
+
const directory = join(tmpdir(), `foldkit-workers-${crypto.randomUUID()}`);
|
|
114
|
+
const outfile = join(directory, basename(config.main));
|
|
115
|
+
const trialDirectory = join(directory, "trial");
|
|
116
|
+
const bundle = bundleOptions(options, outfile);
|
|
117
|
+
const first = (await build(bundle)).outputFiles;
|
|
118
|
+
const optionsFor = (raw, main, vars) => ({
|
|
119
|
+
root: dirname(options.wrangler),
|
|
120
|
+
workers: [{
|
|
121
|
+
config: {
|
|
122
|
+
...raw,
|
|
123
|
+
main
|
|
124
|
+
},
|
|
125
|
+
vars,
|
|
126
|
+
secrets: options.secrets
|
|
127
|
+
}]
|
|
128
|
+
});
|
|
129
|
+
const given = options.vars;
|
|
130
|
+
let vars = typeof given === "function" ? void 0 : given;
|
|
131
|
+
const harness = createTestHarness(optionsFor(raw, outfile, vars));
|
|
132
|
+
const kept = [];
|
|
133
|
+
const drain = () => {
|
|
134
|
+
const fresh = harness.getLogs();
|
|
135
|
+
harness.clearLogs();
|
|
136
|
+
if (options.console !== "quiet") fresh.forEach(print);
|
|
137
|
+
kept.push(...fresh);
|
|
138
|
+
};
|
|
139
|
+
const draining = setInterval(drain, 100);
|
|
140
|
+
draining.unref();
|
|
141
|
+
let watching = Option.none();
|
|
142
|
+
let configWatcher = Option.none();
|
|
143
|
+
let rereading = Option.none();
|
|
144
|
+
let swaps = Promise.resolve();
|
|
145
|
+
let stopping = Option.none();
|
|
146
|
+
const dispose = async (watcher) => {
|
|
147
|
+
const opened = await watcher.then(Option.some, () => Option.none());
|
|
148
|
+
if (Option.isSome(opened)) await opened.value.dispose();
|
|
149
|
+
};
|
|
150
|
+
const stopOnce = async () => {
|
|
151
|
+
clearInterval(draining);
|
|
152
|
+
Option.map(rereading, clearTimeout);
|
|
153
|
+
Option.map(configWatcher, (watcher) => watcher.close());
|
|
154
|
+
try {
|
|
155
|
+
const watcher = watching;
|
|
156
|
+
watching = Option.none();
|
|
157
|
+
if (Option.isSome(watcher)) await dispose(watcher.value);
|
|
158
|
+
await swaps;
|
|
159
|
+
} finally {
|
|
160
|
+
try {
|
|
161
|
+
await harness.close();
|
|
162
|
+
} finally {
|
|
163
|
+
drain();
|
|
164
|
+
await rm(directory, {
|
|
165
|
+
recursive: true,
|
|
166
|
+
force: true
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const stop = () => Option.getOrElse(stopping, () => {
|
|
172
|
+
const once = stopOnce();
|
|
173
|
+
stopping = Option.some(once);
|
|
174
|
+
return once;
|
|
175
|
+
});
|
|
176
|
+
try {
|
|
177
|
+
await writeOutputs(first);
|
|
178
|
+
const { url } = await harness.listen();
|
|
179
|
+
if (typeof given === "function") {
|
|
180
|
+
vars = given(url.origin);
|
|
181
|
+
await harness.update(optionsFor(raw, outfile, vars));
|
|
182
|
+
}
|
|
183
|
+
const worker = harness.getWorker();
|
|
184
|
+
await migrate(worker, config);
|
|
185
|
+
const watch$1 = async (listener) => {
|
|
186
|
+
if (Option.isSome(stopping)) throw new Error("This stack has stopped.");
|
|
187
|
+
if (Option.isSome(watching)) throw new Error("This stack is already watching.");
|
|
188
|
+
let running = Option.some({
|
|
189
|
+
raw,
|
|
190
|
+
config,
|
|
191
|
+
files: first
|
|
192
|
+
});
|
|
193
|
+
/**
|
|
194
|
+
* Starts `next` on a workerd of its own, then swaps it in. A Worker
|
|
195
|
+
* that does not start is refused there, and the stack's harness, which
|
|
196
|
+
* a failed update tears down with its storage, never sees it.
|
|
197
|
+
*/
|
|
198
|
+
const swap = async (next) => {
|
|
199
|
+
try {
|
|
200
|
+
await writeOutputs(next.files.map((file) => ({
|
|
201
|
+
path: join(trialDirectory, relative(directory, file.path)),
|
|
202
|
+
contents: file.contents
|
|
203
|
+
})));
|
|
204
|
+
const trial = createTestHarness(optionsFor(next.raw, join(trialDirectory, basename(outfile)), vars));
|
|
205
|
+
try {
|
|
206
|
+
await trial.listen();
|
|
207
|
+
await migrate(trial.getWorker(), next.config);
|
|
208
|
+
} finally {
|
|
209
|
+
await trial.close();
|
|
210
|
+
}
|
|
211
|
+
} catch (error) {
|
|
212
|
+
listener.onRefused(errorText(error));
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
await writeOutputs(next.files);
|
|
217
|
+
await harness.update(optionsFor(next.raw, outfile, vars));
|
|
218
|
+
} catch (error) {
|
|
219
|
+
running = Option.none();
|
|
220
|
+
listener.onStopped(errorText(error));
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
running = Option.some(next);
|
|
224
|
+
try {
|
|
225
|
+
await migrate(harness.getWorker(), next.config);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
listener.onRefused(`The Worker was swapped in, but a migration failed: ${errorText(error)}`);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
listener.onSwap();
|
|
231
|
+
};
|
|
232
|
+
/** Queues a swap of what `change` makes of the running stack, which may be none. */
|
|
233
|
+
const enqueue = (change) => {
|
|
234
|
+
const step = swaps.then(async () => {
|
|
235
|
+
if (Option.isNone(running) || Option.isSome(stopping)) return;
|
|
236
|
+
const next = await change(running.value);
|
|
237
|
+
if (Option.isSome(next)) await swap(next.value);
|
|
238
|
+
});
|
|
239
|
+
swaps = step.catch(() => void 0);
|
|
240
|
+
return step;
|
|
241
|
+
};
|
|
242
|
+
const watcher = context({
|
|
243
|
+
...bundle,
|
|
244
|
+
plugins: [...bundle.plugins, {
|
|
245
|
+
name: "foldkit-swap",
|
|
246
|
+
setup: (build) => build.onEnd((result) => enqueue(async (now) => {
|
|
247
|
+
if (result.errors.length > 0) {
|
|
248
|
+
listener.onRefused(result.errors.map((error) => error.text).join("\n"));
|
|
249
|
+
return Option.none();
|
|
250
|
+
}
|
|
251
|
+
const files = result.outputFiles ?? [];
|
|
252
|
+
if (files.some((file) => file.path === outfile && file.contents.length === 0)) {
|
|
253
|
+
listener.onRefused(`${options.entry} bundles to no code, so no Worker could start.`);
|
|
254
|
+
return Option.none();
|
|
255
|
+
}
|
|
256
|
+
return identityOf(files) === identityOf(now.files) ? Option.none() : Option.some({
|
|
257
|
+
...now,
|
|
258
|
+
files
|
|
259
|
+
});
|
|
260
|
+
}))
|
|
261
|
+
}]
|
|
262
|
+
});
|
|
263
|
+
watching = Option.some(watcher);
|
|
264
|
+
try {
|
|
265
|
+
await (await watcher).watch();
|
|
266
|
+
} catch (error) {
|
|
267
|
+
if (Option.contains(watching, watcher)) {
|
|
268
|
+
watching = Option.none();
|
|
269
|
+
await dispose(watcher);
|
|
270
|
+
}
|
|
271
|
+
throw error;
|
|
272
|
+
}
|
|
273
|
+
if (Option.isSome(stopping)) return;
|
|
274
|
+
const reread = () => enqueue(async (now) => {
|
|
275
|
+
return (await readConfig(options.wrangler).then(Option.some, (error) => {
|
|
276
|
+
listener.onRefused(errorText(error));
|
|
277
|
+
return Option.none();
|
|
278
|
+
})).pipe(Option.filter(({ raw }) => JSON.stringify(raw) !== JSON.stringify(now.raw)), Option.map(({ raw, config }) => ({
|
|
279
|
+
...now,
|
|
280
|
+
raw,
|
|
281
|
+
config
|
|
282
|
+
})));
|
|
283
|
+
});
|
|
284
|
+
const name = basename(options.wrangler);
|
|
285
|
+
configWatcher = Option.some(watch(dirname(options.wrangler), (_, changed) => {
|
|
286
|
+
if (changed !== name) return;
|
|
287
|
+
Option.map(rereading, clearTimeout);
|
|
288
|
+
rereading = Option.some(setTimeout(() => void reread(), 50));
|
|
289
|
+
}).on("error", (error) => listener.onRefused(`The configuration is no longer watched: ${errorText(error)}`)));
|
|
290
|
+
};
|
|
291
|
+
const env = () => harness.getWorker().getEnv();
|
|
292
|
+
const logs = () => {
|
|
293
|
+
drain();
|
|
294
|
+
return kept.splice(0);
|
|
295
|
+
};
|
|
296
|
+
return {
|
|
297
|
+
origin: url.origin,
|
|
298
|
+
env,
|
|
299
|
+
dispatch: worker.fetch,
|
|
300
|
+
logs,
|
|
301
|
+
watch: watch$1,
|
|
302
|
+
stop
|
|
303
|
+
};
|
|
304
|
+
} catch (error) {
|
|
305
|
+
await stop().catch(() => void 0);
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* The local Workers stack. `Stack.start` runs the Worker for tests and
|
|
311
|
+
* development; `Stack.writeBundle` writes what `wrangler deploy` uploads,
|
|
312
|
+
* bundled the same way.
|
|
313
|
+
*/
|
|
314
|
+
const Stack = {
|
|
315
|
+
start,
|
|
316
|
+
writeBundle
|
|
317
|
+
};
|
|
318
|
+
export { Stack };
|
|
319
|
+
|
|
320
|
+
//# sourceMappingURL=workers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workers.mjs","names":["watch","watchFile"],"sources":["../../src/testing/workers.ts"],"sourcesContent":["/**\n * `foldkit-plus/testing/workers`: a Worker on a local workerd, configured by\n * its own Wrangler configuration.\n *\n * Wrangler's test harness reads the configuration, so bindings, the\n * compatibility date and flags, `.dev.vars` and D1 migrations mean here what\n * they mean to `wrangler deploy`. This module owns only what Wrangler cannot\n * know: the bundle. esbuild builds the entry with the workspace's source\n * condition into a directory of the stack's own, and the harness runs the\n * configuration with `main` pointed there.\n *\n * `wrangler` and `esbuild` are optional peers of `foldkit-plus`, loaded on the\n * first call; Miniflare is read from Wrangler's own copy, so the date check\n * asks the runtime Wrangler starts.\n */\nimport { Option, Schema } from 'effect'\nimport type { BuildContext, BuildOptions, OutputFile, Plugin } from 'esbuild'\nimport type { TestHarness, WorkerHandle } from 'wrangler'\nimport { watch as watchFile, type FSWatcher } from 'node:fs'\nimport { mkdir, rm, writeFile } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { tmpdir } from 'node:os'\nimport { basename, dirname, join, relative, resolve } from 'node:path'\nimport { peer } from './peer.js'\n\nconst SUBPATH = 'testing/workers'\n\nconst wrangler = () => peer(SUBPATH, 'wrangler', () => import('wrangler'))\nconst esbuild = () => peer(SUBPATH, 'esbuild', () => import('esbuild'))\n\nexport interface StackOptions {\n /** The Worker's Wrangler configuration (`wrangler.toml`, `.json` or `.jsonc`). */\n readonly wrangler: string\n /** The source esbuild bundles into what `main` names. */\n readonly entry: string\n /**\n * Local values for vars the deployed Worker is given elsewhere. As a\n * function, of the origin the stack answers at: the Worker has them from\n * its first request (`origin => ({ ORIGIN: origin })`).\n */\n readonly vars?: Vars | ((origin: string) => Vars)\n /** Local values for secrets, over any in `.dev.vars`. */\n readonly secrets?: Readonly<Record<string, string>>\n /** esbuild plugins for the bundle, the deploy's and the stack's alike. */\n readonly plugins?: ReadonlyArray<Plugin>\n /**\n * Whether each line the Worker writes to its console is printed here, by\n * its level, as it arrives (`'print'`, the default). `logs()` keeps them either way.\n */\n readonly console?: 'print' | 'quiet'\n}\n\ntype Vars = Readonly<Record<string, string>>\n\n/** A line the Worker wrote to its console. An `Error` logged carries its stack in `message`. */\nexport interface WorkerLog {\n /** As workerd names it: `debug`, `info`, `log`, `warn` or `error`. */\n readonly level: string\n readonly message: string\n readonly timestamp: number\n}\n\n/**\n * What a watched stack reports after each change to the bundle's sources or\n * to the Wrangler configuration.\n */\nexport interface WatchListener {\n /** The new Worker answers at the same origin, over the same storage. */\n readonly onSwap: () => void\n /**\n * The change was not swapped in, and the Worker running keeps answering\n * over the same storage. It did not build, built no code (as an entry saved\n * in place reads for a moment), did not start when tried on a workerd of\n * its own, or is a configuration the stack refuses. Or it was swapped in,\n * and a D1 migration then failed on the running database; the message says so.\n */\n readonly onRefused: (message: string) => void\n /**\n * A Worker that started when tried did not start in the stack. Wrangler's\n * harness tears its runtime down with it, storage included, so the stack\n * has stopped answering and watches no more: call `stop`, and start again.\n */\n readonly onStopped: (message: string) => void\n}\n\nexport interface Stack<Env> {\n /** Where the Worker answers over real HTTP. */\n readonly origin: string\n /**\n * The Worker's bindings, as the Worker sees them. A swap retires the ones\n * read before it (Miniflare's \"poisoned stub\"), so read them after.\n */\n readonly env: () => Promise<Env>\n /** A request straight to the Worker; an upgrade answers with its socket. */\n readonly dispatch: WorkerHandle['fetch']\n /**\n * Takes what the Worker wrote to its console since the last call, oldest\n * first. The lines come from workerd beside the response, not on it, so a\n * line written for a request may arrive after it: poll.\n */\n readonly logs: () => ReadonlyArray<WorkerLog>\n /**\n * Rebuilds on every change to a file the bundle read, and rereads the\n * Wrangler configuration when it changes. Each change is first started on\n * a workerd of its own, then swapped in at the same origin, and the D1\n * migrations not yet applied are applied. D1, R2 and Durable Object storage stay.\n */\n readonly watch: (listener: WatchListener) => Promise<void>\n /**\n * Stops watching, stops workerd and removes the bundle's directory, each\n * even when one before it failed. A change not yet being tried swaps\n * nothing and reports nothing; one being tried finishes first. A second\n * call returns the first one's promise.\n */\n readonly stop: () => Promise<void>\n}\n\n/**\n * The part of the configuration the stack reads itself. Wrangler validates\n * the whole of it when the harness loads it.\n */\nconst Config = Schema.Struct({\n main: Schema.String,\n compatibility_date: Schema.String,\n // The stack bundles; Wrangler bundling `main` again would deploy other code.\n no_bundle: Schema.Literal(true),\n d1_databases: Schema.optional(Schema.Array(Schema.Struct({ binding: Schema.String }))),\n})\n\n/**\n * The newest date the workerd Wrangler starts supports, from Wrangler's own\n * Miniflare: an application's own `miniflare` may be another release. Call it\n * after `wrangler()`, which says so when Wrangler is missing.\n */\nconst supportedDate = (): string => {\n const fromWrangler = createRequire(createRequire(import.meta.url).resolve('wrangler'))\n return Schema.decodeUnknownSync(Schema.Struct({ supportedCompatibilityDate: Schema.String }))(\n fromWrangler('miniflare'),\n ).supportedCompatibilityDate\n}\n\nconst readConfig = async (path: string) => {\n const { experimental_readRawConfig } = await wrangler()\n const { rawConfig: raw } = experimental_readRawConfig({ config: path })\n if ('env' in raw)\n throw new Error(`${path}: the local stack runs the top-level Worker; [env.*] is not read.`)\n const config = Schema.decodeUnknownSync(Config)(raw)\n // Miniflare would run a date it does not know at its own latest, with a\n // warning nobody reads, and the tests would pass on a runtime the deploy does not get.\n const supported = supportedDate()\n if (config.compatibility_date > supported)\n throw new Error(\n `${path} asks for compatibility_date ${config.compatibility_date}, but the installed ` +\n `workerd supports up to ${supported}. Move wrangler to a release that knows it.`,\n )\n return { raw, config }\n}\n\n/**\n * How the entry is bundled, for the stack and for `wrangler deploy`: the\n * script at `outfile`, and beside it any `.wasm` it imports, which `no_bundle`\n * Wrangler loads as a compiled module. `node:*` stays external for\n * `nodejs_compat`.\n */\nconst bundleOptions = (options: StackOptions, outfile: string) =>\n ({\n entryPoints: [options.entry],\n bundle: true,\n format: 'esm',\n platform: 'browser',\n conditions: ['foldkit-plus:source'],\n external: ['cloudflare:workers', 'node:*'],\n loader: { '.wasm': 'copy' },\n plugins: [...(options.plugins ?? [])],\n outdir: dirname(outfile),\n entryNames: basename(outfile, '.js'),\n write: false,\n logLevel: 'silent',\n }) satisfies BuildOptions\n\ntype OutputFiles = ReadonlyArray<OutputFile>\n\nconst writeOutputs = async (\n files: ReadonlyArray<{ readonly path: string; readonly contents: Uint8Array }>,\n) => {\n for (const file of files) {\n await mkdir(dirname(file.path), { recursive: true })\n await writeFile(file.path, file.contents)\n }\n}\n\nconst identityOf = (files: OutputFiles) => files.map(file => `${file.path}:${file.hash}`).join()\n\n/** Node's console method for each level workerd writes; any other prints as a log. */\nconst printers = new Map<string, (line: string) => void>([\n ['debug', line => console.debug(line)],\n ['info', line => console.info(line)],\n ['warn', line => console.warn(line)],\n ['error', line => console.error(line)],\n])\n\nconst print = (log: WorkerLog) =>\n (printers.get(log.level) ?? (line => console.log(line)))(`[worker] ${log.message}`)\n\nconst errorText = (error: unknown) => (error instanceof Error ? error.message : String(error))\n\n/** Writes the bundle where `main` says, for `wrangler deploy`. */\nconst writeBundle = async (options: Omit<StackOptions, 'vars' | 'secrets'>): Promise<void> => {\n const { config } = await readConfig(options.wrangler)\n const outfile = resolve(dirname(options.wrangler), config.main)\n const { build } = await esbuild()\n await writeOutputs((await build(bundleOptions(options, outfile))).outputFiles)\n}\n\ntype Raw = Awaited<ReturnType<typeof readConfig>>['raw']\n\n/** What the stack runs: a configuration and a bundle, swapped in together. */\ninterface Running {\n readonly raw: Raw\n readonly config: typeof Config.Type\n readonly files: OutputFiles\n}\n\nconst migrate = async (worker: WorkerHandle, config: typeof Config.Type) => {\n for (const database of config.d1_databases ?? []) await worker.applyD1Migrations(database.binding)\n}\n\n/**\n * Starts the Worker with a fresh, migrated D1 for each `[[d1_databases]]`,\n * and empty R2 and Durable Object storage. Each call is a stack of its own,\n * so test files running side by side share nothing.\n */\nconst start = async <Env>(options: StackOptions): Promise<Stack<Env>> => {\n const { raw, config } = await readConfig(options.wrangler)\n const { build, context } = await esbuild()\n const { createTestHarness } = await wrangler()\n const directory = join(tmpdir(), `foldkit-workers-${crypto.randomUUID()}`)\n const outfile = join(directory, basename(config.main))\n // Where a change is started on a workerd of its own before the swap.\n const trialDirectory = join(directory, 'trial')\n const bundle = bundleOptions(options, outfile)\n // In memory: a source that does not build fails here, before anything exists to clean up.\n const first = (await build(bundle)).outputFiles\n\n const optionsFor = (raw: Raw, main: string, vars: Vars | undefined) => ({\n root: dirname(options.wrangler),\n workers: [{ config: { ...raw, main }, vars, secrets: options.secrets }],\n })\n const given = options.vars\n // Given here, or once the stack knows its origin.\n let vars = typeof given === 'function' ? undefined : given\n const harness: TestHarness = createTestHarness(optionsFor(raw, outfile, vars))\n // The harness keeps workerd's console and offers no handler, so it is drained:\n // read and cleared in one synchronous step, nothing is read twice or missed.\n const kept: Array<WorkerLog> = []\n const drain = () => {\n const fresh = harness.getLogs()\n harness.clearLogs()\n if (options.console !== 'quiet') fresh.forEach(print)\n kept.push(...fresh)\n }\n const draining = setInterval(drain, 100)\n draining.unref()\n let watching = Option.none<Promise<BuildContext>>()\n let configWatcher = Option.none<FSWatcher>()\n let rereading = Option.none<ReturnType<typeof setTimeout>>()\n // Swaps run one at a time, in the order their changes arrived.\n let swaps: Promise<void> = Promise.resolve()\n let stopping = Option.none<Promise<void>>()\n const dispose = async (watcher: Promise<BuildContext>) => {\n // A context that never opened has nothing to dispose; its failure was the watch's to report.\n const opened = await watcher.then(Option.some, () => Option.none<BuildContext>())\n if (Option.isSome(opened)) await opened.value.dispose()\n }\n // Each step runs however the one before it ended: a step skipped leaves\n // workerd running, or the bundle's directory behind.\n const stopOnce = async () => {\n clearInterval(draining)\n Option.map(rereading, clearTimeout)\n Option.map(configWatcher, watcher => watcher.close())\n try {\n const watcher = watching\n watching = Option.none()\n // Waits for a rebuild in flight, whose step sees `stopping`.\n if (Option.isSome(watcher)) await dispose(watcher.value)\n await swaps\n } finally {\n try {\n await harness.close()\n } finally {\n // What the Worker wrote since the last drain, up to its end, is printed and kept.\n drain()\n await rm(directory, { recursive: true, force: true })\n }\n }\n }\n const stop = () =>\n Option.getOrElse(stopping, () => {\n const once = stopOnce()\n stopping = Option.some(once)\n return once\n })\n\n try {\n await writeOutputs(first)\n const { url } = await harness.listen()\n // A reload at the same origin, as a swap is, before any request of the caller's.\n if (typeof given === 'function') {\n vars = given(url.origin)\n await harness.update(optionsFor(raw, outfile, vars))\n }\n const worker = harness.getWorker()\n await migrate(worker, config)\n\n const watch = async (listener: WatchListener) => {\n if (Option.isSome(stopping)) throw new Error('This stack has stopped.')\n if (Option.isSome(watching)) throw new Error('This stack is already watching.')\n // None once a swap failed after its trial and took the runtime with it.\n let running = Option.some<Running>({ raw, config, files: first })\n\n /**\n * Starts `next` on a workerd of its own, then swaps it in. A Worker\n * that does not start is refused there, and the stack's harness, which\n * a failed update tears down with its storage, never sees it.\n */\n const swap = async (next: Running) => {\n try {\n await writeOutputs(\n next.files.map(file => ({\n path: join(trialDirectory, relative(directory, file.path)),\n contents: file.contents,\n })),\n )\n const trial = createTestHarness(\n optionsFor(next.raw, join(trialDirectory, basename(outfile)), vars),\n )\n try {\n await trial.listen()\n await migrate(trial.getWorker(), next.config)\n } finally {\n await trial.close()\n }\n } catch (error) {\n listener.onRefused(errorText(error))\n return\n }\n try {\n await writeOutputs(next.files)\n await harness.update(optionsFor(next.raw, outfile, vars))\n } catch (error) {\n running = Option.none()\n listener.onStopped(errorText(error))\n return\n }\n running = Option.some(next)\n try {\n await migrate(harness.getWorker(), next.config)\n } catch (error) {\n listener.onRefused(\n `The Worker was swapped in, but a migration failed: ${errorText(error)}`,\n )\n return\n }\n listener.onSwap()\n }\n /** Queues a swap of what `change` makes of the running stack, which may be none. */\n const enqueue = (change: (now: Running) => Promise<Option.Option<Running>>) => {\n const step = swaps.then(async () => {\n // A step that runs once `stop` began swaps nothing: `stop` waits for\n // it before closing the harness, so it would swap into a closing stack.\n if (Option.isNone(running) || Option.isSome(stopping)) return\n const next = await change(running.value)\n if (Option.isSome(next)) await swap(next.value)\n })\n // A listener that throws fails its own step, not the ones after it.\n swaps = step.catch(() => undefined)\n return step\n }\n\n const watcher = context({\n ...bundle,\n plugins: [\n ...bundle.plugins,\n {\n name: 'foldkit-swap',\n setup: build =>\n build.onEnd(result =>\n enqueue(async now => {\n if (result.errors.length > 0) {\n listener.onRefused(result.errors.map(error => error.text).join('\\n'))\n return Option.none()\n }\n const files = result.outputFiles ?? []\n // An editor saving in place empties the file before writing it, and a\n // rebuild can read it then; the write's own rebuild swaps.\n if (files.some(file => file.path === outfile && file.contents.length === 0)) {\n listener.onRefused(\n `${options.entry} bundles to no code, so no Worker could start.`,\n )\n return Option.none()\n }\n return identityOf(files) === identityOf(now.files)\n ? Option.none()\n : Option.some({ ...now, files })\n }),\n ),\n },\n ],\n })\n watching = Option.some(watcher)\n try {\n await (await watcher).watch()\n } catch (error) {\n // Not watching after all: `stop` must not wait on this context, nor a second `watch` be refused.\n if (Option.contains(watching, watcher)) {\n watching = Option.none()\n await dispose(watcher)\n }\n throw error\n }\n // A `stop` that began while the context opened would close no watcher made now.\n if (Option.isSome(stopping)) return\n\n const reread = () =>\n enqueue(async now => {\n const read = await readConfig(options.wrangler).then(Option.some, (error: unknown) => {\n listener.onRefused(errorText(error))\n return Option.none<Awaited<ReturnType<typeof readConfig>>>()\n })\n // A save that changed nothing the configuration says.\n return read.pipe(\n Option.filter(({ raw }) => JSON.stringify(raw) !== JSON.stringify(now.raw)),\n Option.map(({ raw, config }) => ({ ...now, raw, config })),\n )\n })\n // The directory, not the file: an editor that renames a temporary over the\n // file replaces what a file watcher watches.\n const name = basename(options.wrangler)\n configWatcher = Option.some(\n watchFile(dirname(options.wrangler), (_, changed) => {\n if (changed !== name) return\n // One reread for the burst of events a single save makes.\n Option.map(rereading, clearTimeout)\n rereading = Option.some(setTimeout(() => void reread(), 50))\n }).on('error', error =>\n listener.onRefused(`The configuration is no longer watched: ${errorText(error)}`),\n ),\n )\n }\n\n const env = () => harness.getWorker<Env>().getEnv()\n const logs = () => {\n drain()\n return kept.splice(0)\n }\n return { origin: url.origin, env, dispatch: worker.fetch, logs, watch, stop }\n } catch (error) {\n // The start's failure is the one to report; a failure cleaning up after it would hide it.\n await stop().catch(() => undefined)\n throw error\n }\n}\n\n/**\n * The local Workers stack. `Stack.start` runs the Worker for tests and\n * development; `Stack.writeBundle` writes what `wrangler deploy` uploads,\n * bundled the same way.\n */\nexport const Stack = { start, writeBundle } as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,UAAU;AAEhB,MAAM,iBAAiB,KAAK,SAAS,kBAAkB,OAAO,WAAW;AACzE,MAAM,gBAAgB,KAAK,SAAS,iBAAiB,OAAO,UAAU;;;;;AA6FtE,MAAM,SAAS,OAAO,OAAO;CAC3B,MAAM,OAAO;CACb,oBAAoB,OAAO;CAE3B,WAAW,OAAO,QAAQ,IAAI;CAC9B,cAAc,OAAO,SAAS,OAAO,MAAM,OAAO,OAAO,EAAE,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC;AACvF,CAAC;;;;;;AAOD,MAAM,sBAA8B;CAClC,MAAM,eAAe,cAAc,cAAc,YAAY,GAAG,CAAC,CAAC,QAAQ,UAAU,CAAC;CACrF,OAAO,OAAO,kBAAkB,OAAO,OAAO,EAAE,4BAA4B,OAAO,OAAO,CAAC,CAAC,CAAC,CAC3F,aAAa,WAAW,CAC1B,CAAC,CAAC;AACJ;AAEA,MAAM,aAAa,OAAO,SAAiB;CACzC,MAAM,EAAE,+BAA+B,MAAM,SAAS;CACtD,MAAM,EAAE,WAAW,QAAQ,2BAA2B,EAAE,QAAQ,KAAK,CAAC;CACtE,IAAI,SAAS,KACX,MAAM,IAAI,MAAM,GAAG,KAAK,kEAAkE;CAC5F,MAAM,SAAS,OAAO,kBAAkB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AAQ,EAAE,UAAU,KAAK,UAAU,GAAG,MAAM,KAAK,UAAU,IAAI,GAAG,CAAC,GAC1E,OAAO,KAAK,EAAE,KAAK,cAAc;KAAE,GAAG;KAAK;KAAK;IAAO,EAAE,CAC3D;GACF,CAAC;GAGH,MAAM,OAAO,SAAS,QAAQ,QAAQ;GACtC,gBAAgB,OAAO,KACrBC,MAAU,QAAQ,QAAQ,QAAQ,IAAI,GAAG,YAAY;IACnD,IAAI,YAAY,MAAM;IAEtB,OAAO,IAAI,WAAW,YAAY;IAClC,YAAY,OAAO,KAAK,iBAAiB,KAAK,OAAO,GAAG,EAAE,CAAC;GAC7D,CAAC,CAAC,CAAC,GAAG,UAAS,UACb,SAAS,UAAU,2CAA2C,UAAU,KAAK,GAAG,CAClF,CACF;EACF;EAEA,MAAM,YAAY,QAAQ,UAAe,CAAC,CAAC,OAAO;EAClD,MAAM,aAAa;GACjB,MAAM;GACN,OAAO,KAAK,OAAO,CAAC;EACtB;EACA,OAAO;GAAE,QAAQ,IAAI;GAAQ;GAAK,UAAU,OAAO;GAAO;GAAM,OAAA;GAAO;EAAK;CAC9E,SAAS,OAAO;EAEd,MAAM,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;EAClC,MAAM;CACR;AACF;;;;;;AAOA,MAAa,QAAQ;CAAE;CAAO;AAAY"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-plus",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Every Foldkit Plus package in one install,
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "Every Foldkit Plus package in one install, `npx foldkit-plus setup`, which tells a coding agent how to start, and `npx foldkit-plus docs`, which answers from the installed docs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
7
7
|
"effect",
|
|
@@ -33,6 +33,16 @@
|
|
|
33
33
|
"types": "./dist/index.d.mts",
|
|
34
34
|
"import": "./dist/index.mjs"
|
|
35
35
|
},
|
|
36
|
+
"./testing/workers": {
|
|
37
|
+
"foldkit-plus:source": "./src/testing/workers.ts",
|
|
38
|
+
"types": "./dist/testing/workers.d.mts",
|
|
39
|
+
"import": "./dist/testing/workers.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./testing/playwright": {
|
|
42
|
+
"foldkit-plus:source": "./src/testing/playwright.ts",
|
|
43
|
+
"types": "./dist/testing/playwright.d.mts",
|
|
44
|
+
"import": "./dist/testing/playwright.mjs"
|
|
45
|
+
},
|
|
36
46
|
"./agent": {
|
|
37
47
|
"foldkit-plus:source": "./src/agent.ts",
|
|
38
48
|
"types": "./dist/agent.d.mts",
|
|
@@ -323,6 +333,11 @@
|
|
|
323
333
|
"types": "./dist/mixins-crud.d.mts",
|
|
324
334
|
"import": "./dist/mixins-crud.mjs"
|
|
325
335
|
},
|
|
336
|
+
"./mixins-crud/recipes": {
|
|
337
|
+
"foldkit-plus:source": "./src/mixins-crud/recipes.ts",
|
|
338
|
+
"types": "./dist/mixins-crud/recipes.d.mts",
|
|
339
|
+
"import": "./dist/mixins-crud/recipes.mjs"
|
|
340
|
+
},
|
|
326
341
|
"./mixins-data-grid": {
|
|
327
342
|
"foldkit-plus:source": "./src/mixins-data-grid.ts",
|
|
328
343
|
"types": "./dist/mixins-data-grid.d.mts",
|
|
@@ -333,6 +348,11 @@
|
|
|
333
348
|
"types": "./dist/mixins-form/ui.d.mts",
|
|
334
349
|
"import": "./dist/mixins-form/ui.mjs"
|
|
335
350
|
},
|
|
351
|
+
"./mixins-form/recipes": {
|
|
352
|
+
"foldkit-plus:source": "./src/mixins-form/recipes.ts",
|
|
353
|
+
"types": "./dist/mixins-form/recipes.d.mts",
|
|
354
|
+
"import": "./dist/mixins-form/recipes.mjs"
|
|
355
|
+
},
|
|
336
356
|
"./mixins-form": {
|
|
337
357
|
"foldkit-plus:source": "./src/mixins-form.ts",
|
|
338
358
|
"types": "./dist/mixins-form.d.mts",
|
|
@@ -428,6 +448,11 @@
|
|
|
428
448
|
"types": "./dist/remote/port.d.mts",
|
|
429
449
|
"import": "./dist/remote/port.mjs"
|
|
430
450
|
},
|
|
451
|
+
"./remote/testing": {
|
|
452
|
+
"foldkit-plus:source": "./src/remote/testing.ts",
|
|
453
|
+
"types": "./dist/remote/testing.d.mts",
|
|
454
|
+
"import": "./dist/remote/testing.mjs"
|
|
455
|
+
},
|
|
431
456
|
"./remote-drizzle": {
|
|
432
457
|
"foldkit-plus:source": "./src/remote-drizzle.ts",
|
|
433
458
|
"types": "./dist/remote-drizzle.d.mts",
|
|
@@ -570,55 +595,58 @@
|
|
|
570
595
|
"LICENSE"
|
|
571
596
|
],
|
|
572
597
|
"dependencies": {
|
|
573
|
-
"foldkit-agent-a2a": "0.
|
|
574
|
-
"foldkit-agent": "0.
|
|
575
|
-
"foldkit-agent-mcp": "0.
|
|
576
|
-
"foldkit-agent-webmcp": "0.
|
|
577
|
-
"foldkit-
|
|
578
|
-
"foldkit-
|
|
579
|
-
"foldkit-
|
|
580
|
-
"foldkit-
|
|
581
|
-
"foldkit-
|
|
582
|
-
"foldkit-data-grid": "0.
|
|
583
|
-
"foldkit-
|
|
584
|
-
"foldkit-
|
|
585
|
-
"foldkit-entity": "0.
|
|
586
|
-
"foldkit-form": "0.
|
|
587
|
-
"foldkit-form-recipes": "0.
|
|
588
|
-
"foldkit-guard": "0.
|
|
589
|
-
"foldkit-media": "0.
|
|
598
|
+
"foldkit-agent-a2a": "0.7.0",
|
|
599
|
+
"foldkit-agent": "0.9.0",
|
|
600
|
+
"foldkit-agent-mcp": "0.8.0",
|
|
601
|
+
"foldkit-agent-webmcp": "0.8.0",
|
|
602
|
+
"foldkit-builder": "0.4.0",
|
|
603
|
+
"foldkit-cms": "0.9.0",
|
|
604
|
+
"foldkit-bundle": "0.9.0",
|
|
605
|
+
"foldkit-composition": "0.4.0",
|
|
606
|
+
"foldkit-crud": "0.12.0",
|
|
607
|
+
"foldkit-data-grid": "0.4.0",
|
|
608
|
+
"foldkit-durable": "0.10.0",
|
|
609
|
+
"foldkit-bundle-surface": "0.5.0",
|
|
610
|
+
"foldkit-entity": "0.14.0",
|
|
611
|
+
"foldkit-form": "0.9.0",
|
|
612
|
+
"foldkit-form-recipes": "0.2.0",
|
|
613
|
+
"foldkit-guard": "0.7.0",
|
|
614
|
+
"foldkit-media": "0.4.0",
|
|
590
615
|
"foldkit-metadata": "0.1.0",
|
|
591
|
-
"foldkit-
|
|
592
|
-
"foldkit-mixins": "0.
|
|
593
|
-
"foldkit-
|
|
594
|
-
"foldkit-mixins-crud": "0.
|
|
595
|
-
"foldkit-mixins-data-grid": "0.
|
|
596
|
-
"foldkit-mixins-form": "0.
|
|
597
|
-
"foldkit-mixins-richtext": "0.
|
|
598
|
-
"foldkit-mixins-surface": "0.
|
|
599
|
-
"foldkit-
|
|
600
|
-
"foldkit-
|
|
601
|
-
"foldkit-remote": "0.
|
|
602
|
-
"foldkit-richtext": "0.
|
|
603
|
-
"foldkit-
|
|
604
|
-
"foldkit-
|
|
605
|
-
"foldkit-richtext-
|
|
606
|
-
"foldkit-
|
|
607
|
-
"foldkit-
|
|
608
|
-
"foldkit-
|
|
609
|
-
"foldkit-
|
|
616
|
+
"foldkit-mirror": "0.7.0",
|
|
617
|
+
"foldkit-mixins": "0.21.0",
|
|
618
|
+
"foldkit-mixins-builder": "0.4.0",
|
|
619
|
+
"foldkit-mixins-crud": "0.10.0",
|
|
620
|
+
"foldkit-mixins-data-grid": "0.3.0",
|
|
621
|
+
"foldkit-mixins-form": "0.11.0",
|
|
622
|
+
"foldkit-mixins-richtext": "0.6.0",
|
|
623
|
+
"foldkit-mixins-surface": "0.7.0",
|
|
624
|
+
"foldkit-primitives": "0.16.0",
|
|
625
|
+
"foldkit-richtext": "0.6.0",
|
|
626
|
+
"foldkit-remote-server": "0.19.0",
|
|
627
|
+
"foldkit-richtext-dom": "0.7.0",
|
|
628
|
+
"foldkit-remote": "0.22.0",
|
|
629
|
+
"foldkit-richtext-code": "0.3.0",
|
|
630
|
+
"foldkit-richtext-markdown": "0.4.0",
|
|
631
|
+
"foldkit-ssr": "0.9.0",
|
|
632
|
+
"foldkit-site": "0.5.0",
|
|
633
|
+
"foldkit-surface": "0.11.0",
|
|
634
|
+
"foldkit-sync": "0.13.0"
|
|
610
635
|
},
|
|
611
636
|
"peerDependencies": {
|
|
612
|
-
"effect": "^4.
|
|
613
|
-
"foldkit": "^0.
|
|
614
|
-
"
|
|
615
|
-
"
|
|
616
|
-
"
|
|
617
|
-
"foldkit-
|
|
618
|
-
"foldkit-
|
|
619
|
-
"foldkit-
|
|
620
|
-
"foldkit-
|
|
621
|
-
"foldkit-
|
|
637
|
+
"effect": "^4.1.0",
|
|
638
|
+
"foldkit": "^0.170.0",
|
|
639
|
+
"esbuild": "^0.28.0",
|
|
640
|
+
"playwright": "^1.64.0",
|
|
641
|
+
"wrangler": "^4.116.0",
|
|
642
|
+
"foldkit-agent-native": "^0.7.0",
|
|
643
|
+
"foldkit-auth": "^0.2.0",
|
|
644
|
+
"foldkit-react": "^0.5.0",
|
|
645
|
+
"foldkit-mixins-ui": "^0.22.0",
|
|
646
|
+
"foldkit-cms-drizzle": "^0.7.0",
|
|
647
|
+
"foldkit-react-codegen": "^0.3.0",
|
|
648
|
+
"foldkit-remote-drizzle": "^0.16.0",
|
|
649
|
+
"foldkit-richtext-code-shiki": "^0.3.0"
|
|
622
650
|
},
|
|
623
651
|
"peerDependenciesMeta": {
|
|
624
652
|
"foldkit-agent-native": {
|
|
@@ -644,26 +672,39 @@
|
|
|
644
672
|
},
|
|
645
673
|
"foldkit-richtext-code-shiki": {
|
|
646
674
|
"optional": true
|
|
675
|
+
},
|
|
676
|
+
"esbuild": {
|
|
677
|
+
"optional": true
|
|
678
|
+
},
|
|
679
|
+
"playwright": {
|
|
680
|
+
"optional": true
|
|
681
|
+
},
|
|
682
|
+
"wrangler": {
|
|
683
|
+
"optional": true
|
|
647
684
|
}
|
|
648
685
|
},
|
|
649
686
|
"devDependencies": {
|
|
650
|
-
"
|
|
651
|
-
"
|
|
687
|
+
"@cloudflare/workers-types": "5.20261022.1",
|
|
688
|
+
"effect": "^4.1.0",
|
|
689
|
+
"esbuild": "0.28.2",
|
|
690
|
+
"foldkit": "0.170.0",
|
|
691
|
+
"playwright": "^1.64.1",
|
|
652
692
|
"tsdown": "^0.23.1",
|
|
653
693
|
"tsx": "^4.23.15",
|
|
654
694
|
"typescript": "7.0.2",
|
|
655
|
-
"
|
|
656
|
-
"foldkit-
|
|
657
|
-
"foldkit-
|
|
695
|
+
"wrangler": "4.116.0",
|
|
696
|
+
"foldkit-agent-native": "0.7.0",
|
|
697
|
+
"foldkit-auth": "0.2.0",
|
|
698
|
+
"foldkit-mixins-ui": "0.22.0",
|
|
699
|
+
"foldkit-cms-drizzle": "0.7.0",
|
|
700
|
+
"foldkit-react": "0.5.0",
|
|
658
701
|
"foldkit-react-codegen": "0.3.0",
|
|
659
|
-
"foldkit-
|
|
660
|
-
"foldkit-
|
|
661
|
-
"foldkit-remote-drizzle": "0.14.0",
|
|
662
|
-
"foldkit-richtext-code-shiki": "0.2.4"
|
|
702
|
+
"foldkit-remote-drizzle": "0.16.0",
|
|
703
|
+
"foldkit-richtext-code-shiki": "0.3.0"
|
|
663
704
|
},
|
|
664
705
|
"setup": {
|
|
665
|
-
"foldkit": "0.
|
|
666
|
-
"effect": "4.
|
|
706
|
+
"foldkit": "0.170.0",
|
|
707
|
+
"effect": "4.1.0"
|
|
667
708
|
},
|
|
668
709
|
"scripts": {
|
|
669
710
|
"build": "tsdown",
|