toiljs 0.0.116 → 0.0.118
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/CHANGELOG.md +14 -0
- package/README.md +16 -7
- package/build/backend/.tsbuildinfo +1 -1
- package/build/cli/.tsbuildinfo +1 -1
- package/build/cli/index.js +2375 -258
- package/build/client/.tsbuildinfo +1 -1
- package/build/client/auth.d.ts +3 -0
- package/build/client/auth.js +19 -10
- package/build/client/dev/devtools.js +1 -1
- package/build/client/dev/error-overlay.js +1 -1
- package/build/client/index.d.ts +1 -1
- package/build/client/index.js +1 -1
- package/build/client/navigation/navigation.js +28 -3
- package/build/client/routing/Router.js +5 -2
- package/build/client/routing/mount.js +1 -1
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/auth-emails.js +7 -3
- package/build/compiler/emails.js +1 -1
- package/build/compiler/index.d.ts +1 -0
- package/build/compiler/index.js +26 -5
- package/build/compiler/pages.js +2 -3
- package/build/compiler/prerender.d.ts +3 -8
- package/build/compiler/prerender.js +88 -127
- package/build/compiler/ssg.js +3 -4
- package/build/compiler/template-build.js +3 -4
- package/build/compiler/toil-docs.generated.js +8 -7
- package/build/compiler/vite.js +4 -6
- package/build/devserver/.tsbuildinfo +1 -1
- package/build/devserver/db/database.js +7 -3
- package/build/devserver/db/types.js +1 -1
- package/build/devserver/production.js +4 -3
- package/build/devserver/runtime/crypto.d.ts +1 -1
- package/build/io/.tsbuildinfo +1 -1
- package/build/logger/.tsbuildinfo +1 -1
- package/build/shared/.tsbuildinfo +1 -1
- package/examples/basic/client/routes/analytics.tsx +7 -5
- package/examples/basic/client/routes/pq.tsx +2 -1
- package/examples/basic/server/tsconfig.json +1 -3
- package/package.json +45 -44
- package/presets/no-uint8array-tostring.js +120 -153
- package/presets/oxlint.d.ts +5 -0
- package/presets/oxlint.js +224 -0
- package/server/auth/AuthController.ts +53 -14
- package/server/auth/FactorSettings.ts +41 -0
- package/server/auth/SessionEpochs.ts +58 -0
- package/server/auth/SessionRevocations.ts +13 -0
- package/server/globals/auth.ts +27 -2
- package/server/runtime/tsconfig.json +1 -3
- package/tsconfig.json +2 -11
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -43
- package/.github/changelog-config.json +0 -45
- package/.github/dependabot.yml +0 -27
- package/.github/workflows/ci.yml +0 -222
- package/.vscode/settings.json +0 -10
- package/docs/README.md +0 -107
- package/docs/auth/README.md +0 -104
- package/docs/auth/configuration.md +0 -105
- package/docs/auth/emails.md +0 -92
- package/docs/auth/extending.md +0 -202
- package/docs/auth/how-it-works.md +0 -138
- package/docs/auth/usage.md +0 -188
- package/docs/backend/README.md +0 -143
- package/docs/backend/data.md +0 -351
- package/docs/backend/rest.md +0 -402
- package/docs/backend/rpc.md +0 -226
- package/docs/background/README.md +0 -114
- package/docs/background/daemons.md +0 -276
- package/docs/background/derive.md +0 -179
- package/docs/cli/README.md +0 -379
- package/docs/concepts/ai-guide.md +0 -132
- package/docs/concepts/config.md +0 -416
- package/docs/concepts/decorators.md +0 -127
- package/docs/concepts/security.md +0 -108
- package/docs/concepts/tiers.md +0 -166
- package/docs/concepts/types.md +0 -216
- package/docs/database/README.md +0 -143
- package/docs/database/capacity.md +0 -350
- package/docs/database/counters.md +0 -174
- package/docs/database/documents.md +0 -277
- package/docs/database/events.md +0 -307
- package/docs/database/membership.md +0 -246
- package/docs/database/setup.md +0 -155
- package/docs/database/unique.md +0 -216
- package/docs/database/views.md +0 -246
- package/docs/frontend/README.md +0 -104
- package/docs/frontend/components.md +0 -286
- package/docs/frontend/data-fetching.md +0 -260
- package/docs/frontend/images.md +0 -148
- package/docs/frontend/metadata.md +0 -344
- package/docs/frontend/navigation.md +0 -296
- package/docs/frontend/rendering.md +0 -236
- package/docs/frontend/routing.md +0 -346
- package/docs/frontend/scripts.md +0 -118
- package/docs/frontend/search.md +0 -191
- package/docs/frontend/styling.md +0 -147
- package/docs/frontend/toil-global.md +0 -216
- package/docs/getting-started/README.md +0 -81
- package/docs/getting-started/create-project.md +0 -131
- package/docs/getting-started/deploy.md +0 -101
- package/docs/getting-started/first-app.md +0 -215
- package/docs/getting-started/installation.md +0 -124
- package/docs/getting-started/migrating.md +0 -125
- package/docs/getting-started/project-structure.md +0 -163
- package/docs/introduction/README.md +0 -66
- package/docs/introduction/design-principles.md +0 -81
- package/docs/introduction/distributed.md +0 -91
- package/docs/introduction/how-it-works.md +0 -121
- package/docs/introduction/hyperscale.md +0 -70
- package/docs/introduction/modern-stack.md +0 -85
- package/docs/introduction/vs-other-frameworks.md +0 -64
- package/docs/introduction/why-toil.md +0 -99
- package/docs/llms.txt +0 -95
- package/docs/realtime/README.md +0 -102
- package/docs/realtime/channels.md +0 -211
- package/docs/realtime/streams.md +0 -369
- package/docs/services/README.md +0 -60
- package/docs/services/analytics.md +0 -279
- package/docs/services/caching.md +0 -175
- package/docs/services/cookies.md +0 -235
- package/docs/services/crypto.md +0 -209
- package/docs/services/email.md +0 -289
- package/docs/services/environment.md +0 -141
- package/docs/services/ratelimit.md +0 -174
- package/docs/services/time.md +0 -85
- package/eslint.config.js +0 -57
- package/examples/basic/client/routes/docs/[...slug].tsx +0 -12
- package/presets/eslint.js +0 -88
- package/src/backend/index.ts +0 -204
- package/src/cli/configure.ts +0 -363
- package/src/cli/create.ts +0 -924
- package/src/cli/db.ts +0 -158
- package/src/cli/diagnostics.ts +0 -665
- package/src/cli/doctor.ts +0 -982
- package/src/cli/features.ts +0 -170
- package/src/cli/index.ts +0 -326
- package/src/cli/notify.ts +0 -120
- package/src/cli/proc.ts +0 -56
- package/src/cli/ui.ts +0 -169
- package/src/cli/update.ts +0 -248
- package/src/cli/updates.ts +0 -92
- package/src/cli/validate.ts +0 -31
- package/src/cli/version-check.ts +0 -125
- package/src/client/auth.ts +0 -869
- package/src/client/channel/channel.ts +0 -146
- package/src/client/components/Form.tsx +0 -65
- package/src/client/components/Image.tsx +0 -160
- package/src/client/components/Script.tsx +0 -113
- package/src/client/components/Slot.tsx +0 -21
- package/src/client/dev/devtools.tsx +0 -1089
- package/src/client/dev/error-overlay.tsx +0 -225
- package/src/client/errors.ts +0 -11
- package/src/client/head/head.ts +0 -182
- package/src/client/head/metadata.ts +0 -110
- package/src/client/index.ts +0 -130
- package/src/client/navigation/Link.tsx +0 -108
- package/src/client/navigation/NavLink.tsx +0 -86
- package/src/client/navigation/navigation.ts +0 -235
- package/src/client/navigation/prefetch.ts +0 -169
- package/src/client/navigation/scroll.ts +0 -53
- package/src/client/routing/Router.tsx +0 -216
- package/src/client/routing/action.ts +0 -122
- package/src/client/routing/error-boundary.tsx +0 -43
- package/src/client/routing/hooks.ts +0 -140
- package/src/client/routing/lazy.ts +0 -77
- package/src/client/routing/loader.ts +0 -381
- package/src/client/routing/match.ts +0 -47
- package/src/client/routing/mount.tsx +0 -90
- package/src/client/routing/params-context.ts +0 -10
- package/src/client/routing/slot-context.ts +0 -7
- package/src/client/rpc.ts +0 -97
- package/src/client/search/search.ts +0 -189
- package/src/client/search/use-page-search.ts +0 -73
- package/src/client/ssr/markers.tsx +0 -172
- package/src/client/stream/client.ts +0 -237
- package/src/client/types.ts +0 -73
- package/src/compiler/auth-emails.ts +0 -312
- package/src/compiler/config.ts +0 -369
- package/src/compiler/docs.ts +0 -127
- package/src/compiler/email-preview.ts +0 -314
- package/src/compiler/emails.ts +0 -404
- package/src/compiler/fonts.ts +0 -89
- package/src/compiler/generate.ts +0 -471
- package/src/compiler/image-blur.ts +0 -42
- package/src/compiler/image-report.ts +0 -88
- package/src/compiler/index.ts +0 -1362
- package/src/compiler/pages.ts +0 -49
- package/src/compiler/plugin.ts +0 -391
- package/src/compiler/prerender.ts +0 -263
- package/src/compiler/routes.ts +0 -170
- package/src/compiler/seo.ts +0 -415
- package/src/compiler/sri.ts +0 -144
- package/src/compiler/ssg.ts +0 -177
- package/src/compiler/ssr-codegen.ts +0 -85
- package/src/compiler/template-build.ts +0 -676
- package/src/compiler/template.ts +0 -262
- package/src/compiler/toil-docs.generated.ts +0 -77
- package/src/compiler/vite.ts +0 -245
- package/src/devserver/analytics/index.ts +0 -317
- package/src/devserver/config/dotenv.ts +0 -102
- package/src/devserver/config/env.ts +0 -30
- package/src/devserver/config/ratelimit.ts +0 -123
- package/src/devserver/daemon/catalog.ts +0 -120
- package/src/devserver/daemon/cron.ts +0 -87
- package/src/devserver/daemon/host.ts +0 -134
- package/src/devserver/daemon/index.ts +0 -369
- package/src/devserver/daemon/runtime.ts +0 -48
- package/src/devserver/db/catalog.ts +0 -109
- package/src/devserver/db/database.ts +0 -1834
- package/src/devserver/db/derives.ts +0 -121
- package/src/devserver/db/index.ts +0 -20
- package/src/devserver/db/routeKinds.ts +0 -191
- package/src/devserver/db/types.ts +0 -168
- package/src/devserver/email/caps.ts +0 -0
- package/src/devserver/email/config.ts +0 -141
- package/src/devserver/email/console.ts +0 -348
- package/src/devserver/email/index.ts +0 -155
- package/src/devserver/email/providers.ts +0 -131
- package/src/devserver/email/status.ts +0 -23
- package/src/devserver/email/validate.ts +0 -37
- package/src/devserver/email/wire.ts +0 -55
- package/src/devserver/http/cache.ts +0 -0
- package/src/devserver/http/envelope.ts +0 -157
- package/src/devserver/http/proxy.ts +0 -172
- package/src/devserver/http/runtime.ts +0 -387
- package/src/devserver/index.ts +0 -43
- package/src/devserver/production-ipc.ts +0 -63
- package/src/devserver/production-worker.ts +0 -83
- package/src/devserver/production.ts +0 -718
- package/src/devserver/runtime/crypto.ts +0 -587
- package/src/devserver/runtime/host.ts +0 -427
- package/src/devserver/runtime/module.ts +0 -442
- package/src/devserver/server.ts +0 -251
- package/src/devserver/ssr.ts +0 -208
- package/src/devserver/stream/catalog.ts +0 -106
- package/src/devserver/stream/host.ts +0 -42
- package/src/devserver/stream/index.ts +0 -301
- package/src/devserver/stream/manager.ts +0 -167
- package/src/devserver/stream/router.ts +0 -101
- package/src/devserver/stream/wire.ts +0 -58
- package/src/devserver/stream/ws.ts +0 -78
- package/src/devserver/wasm/sections.ts +0 -59
- package/src/devserver/wasm/surface.ts +0 -115
- package/src/io/FastMap.ts +0 -151
- package/src/io/FastSet.ts +0 -113
- package/src/io/codec.ts +0 -362
- package/src/io/index.ts +0 -10
- package/src/io/lengths.ts +0 -14
- package/src/io/types.ts +0 -19
- package/src/logger/index.ts +0 -22
- package/src/shared/index.ts +0 -46
- package/test/analytics-dev.test.ts +0 -113
- package/test/assembly/aspect-shim.ts +0 -33
- package/test/assembly/cookie.spec.ts +0 -303
- package/test/assembly/example.spec.ts +0 -22
- package/test/assembly/ssr.spec.ts +0 -95
- package/test/assembly.test.ts +0 -59
- package/test/auth-emails.test.ts +0 -118
- package/test/built-ssr.test.ts +0 -148
- package/test/channel.test.ts +0 -21
- package/test/config-host-port.test.ts +0 -59
- package/test/configure.test.ts +0 -94
- package/test/daemon-build.test.ts +0 -278
- package/test/daemon-catalog.test.ts +0 -349
- package/test/daemon-emulation.test.ts +0 -256
- package/test/db.test.ts +0 -0
- package/test/devserver-database.test.ts +0 -1102
- package/test/devserver-email.test.ts +0 -306
- package/test/devserver-pqauth.test.ts +0 -93
- package/test/devserver-secrets.test.ts +0 -63
- package/test/devserver.test.ts +0 -259
- package/test/doctor.test.ts +0 -298
- package/test/dom/Image.test.tsx +0 -144
- package/test/dom/Link.test.tsx +0 -67
- package/test/dom/NavLink.test.tsx +0 -37
- package/test/dom/Script.test.tsx +0 -48
- package/test/dom/action.test.tsx +0 -146
- package/test/dom/error-overlay.test.tsx +0 -44
- package/test/dom/loader.test.tsx +0 -121
- package/test/dom/navigation.test.ts +0 -59
- package/test/dom/revalidate.test.tsx +0 -38
- package/test/dom/route-head.test.tsx +0 -56
- package/test/dom/router-loading.test.tsx +0 -44
- package/test/dom/scroll.test.ts +0 -56
- package/test/dom/slot.test.tsx +0 -131
- package/test/dom/use-metadata.test.tsx +0 -58
- package/test/dom/view-transitions.test.tsx +0 -53
- package/test/dynamic-routing.test.ts +0 -132
- package/test/email-console.test.ts +0 -86
- package/test/email-preview.test.ts +0 -73
- package/test/emails.test.ts +0 -58
- package/test/errors.test.ts +0 -21
- package/test/example-guestbook.test.ts +0 -123
- package/test/features.test.ts +0 -149
- package/test/fixtures/bignum-wire/spec.ts +0 -25
- package/test/fixtures/daemon-app.ts +0 -65
- package/test/fixtures/stream-echo.ts +0 -26
- package/test/fixtures/stream-gate.ts +0 -28
- package/test/fixtures/stream-trap.ts +0 -18
- package/test/fixtures/stream-typed.ts +0 -41
- package/test/fonts.test.ts +0 -28
- package/test/global-setup.ts +0 -17
- package/test/head.test.ts +0 -42
- package/test/image-blur.test.ts +0 -50
- package/test/io.test.ts +0 -117
- package/test/metadata.test.ts +0 -40
- package/test/navlink.test.ts +0 -28
- package/test/pages.test.ts +0 -105
- package/test/placeholder.test.ts +0 -9
- package/test/pqauth-e2e.test.ts +0 -216
- package/test/pqauth-email.test.ts +0 -801
- package/test/prerender.test.ts +0 -116
- package/test/prettier-plugin.test.ts +0 -46
- package/test/routes.test.ts +0 -76
- package/test/rpc-bignum-wire.test.ts +0 -164
- package/test/rpc-dispatch.test.ts +0 -132
- package/test/rpc-kinds.test.ts +0 -18
- package/test/rpc.test.ts +0 -66
- package/test/search.test.ts +0 -114
- package/test/seo.test.ts +0 -175
- package/test/slot-layouts.test.ts +0 -69
- package/test/sri.test.ts +0 -129
- package/test/ssg.test.ts +0 -36
- package/test/ssr-hydration.test.tsx +0 -122
- package/test/ssr-render.test.ts +0 -197
- package/test/ssr-template.test.tsx +0 -482
- package/test/stream-emulation.test.ts +0 -479
- package/test/ui.test.ts +0 -40
- package/test/update.test.ts +0 -58
- package/test/validate.test.ts +0 -42
- package/test/version-check.test.ts +0 -130
- package/tests/data-parity/generated-parity.ts +0 -99
- package/tests/data-parity/parity.ts +0 -80
- package/tests/data-parity/spec.ts +0 -46
package/src/compiler/config.ts
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
-
|
|
5
|
-
import { type InlineConfig } from 'vite';
|
|
6
|
-
import { type EmailBackendConfig } from 'toiljs/shared';
|
|
7
|
-
|
|
8
|
-
import { type SeoConfig } from './seo.js';
|
|
9
|
-
|
|
10
|
-
export type { SeoConfig } from './seo.js';
|
|
11
|
-
export type { EmailBackendConfig, SmtpBackendConfig } from 'toiljs/shared';
|
|
12
|
-
|
|
13
|
-
/** Built-in AI providers the dev toolbar can proxy to. */
|
|
14
|
-
export enum AiProvider {
|
|
15
|
-
Anthropic = 'anthropic',
|
|
16
|
-
OpenAI = 'openai',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** Dev toolbar AI integration (dev only; the key stays server-side). */
|
|
20
|
-
export interface DevtoolsAiConfig {
|
|
21
|
-
/** Built-in provider. With `endpoint` set, that takes precedence. */
|
|
22
|
-
readonly provider?: AiProvider;
|
|
23
|
-
/** Model id (e.g. `claude-sonnet-4-6`, `gpt-4o`). */
|
|
24
|
-
readonly model?: string;
|
|
25
|
-
/** Name of the env var holding the API key (read by the dev server, never sent to the client). */
|
|
26
|
-
readonly apiKeyEnv?: string;
|
|
27
|
-
/** Custom POST endpoint (`{ prompt }` in, `{ text }` out); overrides `provider`. */
|
|
28
|
-
readonly endpoint?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Dev toolbar configuration. */
|
|
32
|
-
export interface DevtoolsConfig {
|
|
33
|
-
readonly ai?: DevtoolsAiConfig;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Client-side (TSX/React/Vite) configuration. All fields optional; sensible defaults applied.
|
|
38
|
-
*/
|
|
39
|
-
export interface ClientConfig {
|
|
40
|
-
/** Client source directory, relative to root. Default `client`. */
|
|
41
|
-
readonly srcDir?: string;
|
|
42
|
-
/** Routes directory, relative to `srcDir`. Default `routes`. */
|
|
43
|
-
readonly routesDir?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Static assets directory, relative to root. Default `<srcDir>/public` (e.g. `client/public`).
|
|
46
|
-
* Holds the `index.html` template (owned and edited by you) plus any files served as-is at the
|
|
47
|
-
* base path (favicons, images, and the like).
|
|
48
|
-
*/
|
|
49
|
-
readonly publicDir?: string;
|
|
50
|
-
/** Production output directory, relative to root. Default `build/client`. */
|
|
51
|
-
readonly outDir?: string;
|
|
52
|
-
/** Public base path. Default `/`. */
|
|
53
|
-
readonly base?: string;
|
|
54
|
-
/** Port the dev server AND the self-host (`toiljs start`) listen on. Default `3000`.
|
|
55
|
-
* Overridden by the `--port` CLI flag and the `PORT` env var (in that precedence). */
|
|
56
|
-
readonly port?: number;
|
|
57
|
-
/** Bind host for the dev server AND the self-host. Default `127.0.0.1` (loopback only).
|
|
58
|
-
* Set to `0.0.0.0` (or a specific interface) to accept LAN / public connections.
|
|
59
|
-
* Overridden by the `--host` CLI flag and the `HOST` env var (in that precedence). */
|
|
60
|
-
readonly host?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Optimize imported images at build time (resize/convert via `vite-imagetools` + sharp): an
|
|
63
|
-
* import like `logo.png?w=400;800&format=webp&as=srcset` emits resized, compressed variants.
|
|
64
|
-
* Default `true`. Set `false` to disable the pipeline (images are then served as-is).
|
|
65
|
-
*/
|
|
66
|
-
readonly images?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Preload bundled fonts at build time: injects `<link rel="preload" as="font">` for each
|
|
69
|
-
* `@font-face` font so it loads in parallel with the CSS (faster text paint). Default `true`.
|
|
70
|
-
*/
|
|
71
|
-
readonly fonts?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Animate cross-page navigations with the browser View Transitions API (a crossfade by default;
|
|
74
|
-
* add `view-transition-name` in CSS for shared-element transitions). Respects
|
|
75
|
-
* `prefers-reduced-motion`. Default `false`.
|
|
76
|
-
*/
|
|
77
|
-
readonly viewTransitions?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Wrap client navigations in a React transition, keeping the current page visible while the next
|
|
80
|
-
* route's loader runs instead of showing its `loading.tsx` right away. Default `false` (a
|
|
81
|
-
* navigation commits eagerly, so the loading state appears immediately).
|
|
82
|
-
*/
|
|
83
|
-
readonly transitions?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* The dev toolbar (a floating panel in `toiljs dev` with route/build info, errors, and live
|
|
86
|
-
* controls). `true` (default) / `false` to disable, or an object to configure its AI integration.
|
|
87
|
-
* Never included in production builds. The AI key is read server-side from `apiKeyEnv` and never
|
|
88
|
-
* reaches the browser; the toolbar always offers Claude/ChatGPT hand-off links regardless.
|
|
89
|
-
*/
|
|
90
|
-
readonly devtools?: boolean | DevtoolsConfig;
|
|
91
|
-
/**
|
|
92
|
-
* Build-time SEO: bakes site-level metadata into the HTML `<head>` (so JS-less crawlers and AI
|
|
93
|
-
* bots see real tags) and generates `robots.txt`, `sitemap.xml`, and `llms.txt`. Omit to skip.
|
|
94
|
-
*/
|
|
95
|
-
readonly seo?: SeoConfig;
|
|
96
|
-
/**
|
|
97
|
-
* Raw Vite escape hatch, deep-merged over the framework's opinionated config.
|
|
98
|
-
* This is NOT the client config itself, toil owns the Vite setup; use this only
|
|
99
|
-
* to override specific Vite options.
|
|
100
|
-
*/
|
|
101
|
-
readonly vite?: InlineConfig;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Dev node mode: which layer the single dev process emulates. `hot` runs only the
|
|
106
|
-
* request path (today's behavior); `regional`/`continental` would run streams off
|
|
107
|
-
* `release-hot.wasm` (Phase 4); `daemon` runs `release-cold.wasm`; `all` runs every
|
|
108
|
-
* surface in one process (the default for a full local run). DEV / self-host knob;
|
|
109
|
-
* the production edge reads the authoritative role from per-host TCF + the plan.
|
|
110
|
-
*/
|
|
111
|
-
export type DevNodeMode = 'hot' | 'regional' | 'continental' | 'daemon' | 'all';
|
|
112
|
-
|
|
113
|
-
/** Daemon (L4) config mirror (dev / self-host). All optional. */
|
|
114
|
-
export interface DaemonConfig {
|
|
115
|
-
/** Region the daemon is pinned to (informational in dev; the dev process is leader). */
|
|
116
|
-
readonly region?: string;
|
|
117
|
-
/** Warm standby region (informational in dev). */
|
|
118
|
-
readonly standbyRegion?: string;
|
|
119
|
-
/** Default `@scheduled` interval (ms) when a task declares none. Default 60000. */
|
|
120
|
-
readonly defaultIntervalMs?: number;
|
|
121
|
-
/** Per-tick wall-clock budget (ms) before the dev scheduler logs an overrun. Default 30000. */
|
|
122
|
-
readonly tickBudgetMs?: number;
|
|
123
|
-
/** Per-tick gas cap (dev stub; charged-then-ignored). Mirrors `plan.gas_scheduled`. */
|
|
124
|
-
readonly gasTick?: number;
|
|
125
|
-
/** Max number of `@scheduled` tasks (mirrors `max_scheduled_tasks`). Default 64. */
|
|
126
|
-
readonly maxTasks?: number;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Server-side (toilscript → WASM) configuration.
|
|
131
|
-
*/
|
|
132
|
-
export interface ServerConfig {
|
|
133
|
-
/** Server source directory, relative to root. Default `server`. */
|
|
134
|
-
readonly srcDir?: string;
|
|
135
|
-
/** Server build output directory, relative to root. Default `build/server`. */
|
|
136
|
-
readonly outDir?: string;
|
|
137
|
-
/**
|
|
138
|
-
* Email backend config (the dev server and the future Node self-host). The
|
|
139
|
-
* non-secret pieces — provider, `from`, send caps, SMTP host/port/user. The
|
|
140
|
-
* API key / SMTP password is a SECRET and lives ONLY in `.env.secrets`
|
|
141
|
-
* (`TOIL_EMAIL_API_KEY`); any `TOIL_EMAIL_*` env var overrides the matching
|
|
142
|
-
* field here. The production edge ignores this (it reads `TOIL_EMAIL_*` from
|
|
143
|
-
* the per-tenant env store); this drives `toiljs dev` / self-host.
|
|
144
|
-
*/
|
|
145
|
-
readonly email?: EmailBackendConfig;
|
|
146
|
-
/** Which layer the dev process emulates. Default `all`. */
|
|
147
|
-
readonly nodeMode?: DevNodeMode;
|
|
148
|
-
/**
|
|
149
|
-
* Built-in auth. `true` opts into the framework's post-quantum login: the
|
|
150
|
-
* build appends a shipped `@rest('auth')` controller + its `@user` shape to
|
|
151
|
-
* the toilscript entry set, so the app gets the full `/auth/register|login`
|
|
152
|
-
* API + sessions (`/auth/me`, `/auth/logout`) with no hand-written boilerplate.
|
|
153
|
-
* Default `false`. (The escape hatch `import 'toiljs/server/auth'` in
|
|
154
|
-
* `server/main.ts` does the same without this flag.) An app that opts in must
|
|
155
|
-
* NOT declare its own `@user` — the built-in owns the single per-program one.
|
|
156
|
-
*/
|
|
157
|
-
readonly auth?: boolean;
|
|
158
|
-
/** Daemon (L4) config mirror (dev / self-host). */
|
|
159
|
-
readonly daemon?: DaemonConfig;
|
|
160
|
-
/**
|
|
161
|
-
* Self-host HTTP worker count for `toiljs start`. Default `auto`
|
|
162
|
-
* (`os.availableParallelism()`). Set `1` to disable the worker pool.
|
|
163
|
-
*/
|
|
164
|
-
readonly threads?: number | 'auto';
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** Fully-resolved {@link DaemonConfig}; every field non-optional, defaults applied. */
|
|
168
|
-
export interface ResolvedDaemonConfig {
|
|
169
|
-
readonly region: string | null;
|
|
170
|
-
readonly standbyRegion: string | null;
|
|
171
|
-
readonly defaultIntervalMs: number;
|
|
172
|
-
readonly tickBudgetMs: number;
|
|
173
|
-
readonly gasTick: number;
|
|
174
|
-
readonly maxTasks: number;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* The `toil.config` schema. All fields optional; sensible defaults applied.
|
|
179
|
-
* Client and server are configured in separate sections.
|
|
180
|
-
*/
|
|
181
|
-
export interface ToilConfig {
|
|
182
|
-
/** Project root. Defaults to the current working directory. */
|
|
183
|
-
readonly root?: string;
|
|
184
|
-
/** Client (TSX/React/Vite) configuration. */
|
|
185
|
-
readonly client?: ClientConfig;
|
|
186
|
-
/** Server (toilscript/WASM) configuration. */
|
|
187
|
-
readonly server?: ServerConfig;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** Fully-resolved config with absolute paths, used internally by the compiler. */
|
|
191
|
-
export interface ResolvedToilConfig {
|
|
192
|
-
readonly root: string;
|
|
193
|
-
readonly srcDir: string;
|
|
194
|
-
readonly clientAbsDir: string;
|
|
195
|
-
readonly routesAbsDir: string;
|
|
196
|
-
/** Absolute path to the static-assets dir (holds the `index.html` template). */
|
|
197
|
-
readonly publicDir: string;
|
|
198
|
-
readonly toilDir: string;
|
|
199
|
-
readonly outDir: string;
|
|
200
|
-
readonly base: string;
|
|
201
|
-
readonly port: number;
|
|
202
|
-
/** Bind host for the dev server + self-host (`toiljs start`). Default `127.0.0.1`. */
|
|
203
|
-
readonly host: string;
|
|
204
|
-
/** Whether build-time image optimization (`vite-imagetools`) is enabled. */
|
|
205
|
-
readonly images: boolean;
|
|
206
|
-
/** Whether build-time font preloading is enabled. */
|
|
207
|
-
readonly fonts: boolean;
|
|
208
|
-
/** Whether animated View Transitions are enabled for navigation. */
|
|
209
|
-
readonly viewTransitions: boolean;
|
|
210
|
-
/** Whether navigations are wrapped in a React transition (keep current page while loading). */
|
|
211
|
-
readonly transitions: boolean;
|
|
212
|
-
/** Whether the dev toolbar is enabled (dev only). */
|
|
213
|
-
readonly devtools: boolean;
|
|
214
|
-
/** Dev toolbar AI config (dev only), or `null` when not configured. */
|
|
215
|
-
readonly devtoolsAi: DevtoolsAiConfig | null;
|
|
216
|
-
/** Build-time SEO config, or `null` when not configured. */
|
|
217
|
-
readonly seo: SeoConfig | null;
|
|
218
|
-
/** The `server.email` backend config (dev / self-host), or `null` when unset. */
|
|
219
|
-
readonly email: EmailBackendConfig | null;
|
|
220
|
-
/** Which layer the dev process emulates (dev / self-host). Default `all`. */
|
|
221
|
-
readonly nodeMode: DevNodeMode;
|
|
222
|
-
/** Whether the built-in `/auth/*` PQ-login controller is compiled + mounted. */
|
|
223
|
-
readonly auth: boolean;
|
|
224
|
-
/** Daemon (L4) config mirror (dev / self-host), every field resolved. */
|
|
225
|
-
readonly daemon: ResolvedDaemonConfig;
|
|
226
|
-
/** Self-host HTTP worker count for `toiljs start`. */
|
|
227
|
-
readonly threads: number | 'auto';
|
|
228
|
-
/** Absolute path to the framework client runtime (`toiljs/client`). */
|
|
229
|
-
readonly runtimePath: string;
|
|
230
|
-
readonly vite: InlineConfig;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/** Identity helper for typed config files: `export default defineConfig({ ... })`. */
|
|
234
|
-
export function defineConfig(config: ToilConfig): ToilConfig {
|
|
235
|
-
return config;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const CONFIG_NAMES = [
|
|
239
|
-
'toil.config.ts',
|
|
240
|
-
'toil.config.mts',
|
|
241
|
-
'toil.config.js',
|
|
242
|
-
'toil.config.mjs',
|
|
243
|
-
'toiljs.config.ts',
|
|
244
|
-
'toiljs.config.mts',
|
|
245
|
-
'toiljs.config.js',
|
|
246
|
-
'toiljs.config.mjs',
|
|
247
|
-
];
|
|
248
|
-
|
|
249
|
-
/** Path to the built client runtime (`build/client/index.js`), sibling to `build/compiler`. */
|
|
250
|
-
function resolveRuntimePath(): string {
|
|
251
|
-
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../client/index.js');
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** Finds and loads `toil.config.*` or `toiljs.config.*` from `root`, then resolves defaults. */
|
|
255
|
-
export async function loadConfig(
|
|
256
|
-
opts: { root?: string; port?: number; host?: string } = {},
|
|
257
|
-
): Promise<ResolvedToilConfig> {
|
|
258
|
-
const root = path.resolve(opts.root ?? process.cwd());
|
|
259
|
-
|
|
260
|
-
let user: ToilConfig = {};
|
|
261
|
-
for (const name of CONFIG_NAMES) {
|
|
262
|
-
const candidate = path.join(root, name);
|
|
263
|
-
if (fs.existsSync(candidate)) {
|
|
264
|
-
const loaded = (await import(pathToFileURL(candidate).href)) as {
|
|
265
|
-
default?: ToilConfig;
|
|
266
|
-
};
|
|
267
|
-
if (loaded.default) user = loaded.default;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const client = user.client ?? {};
|
|
273
|
-
const srcDir = client.srcDir ?? 'client';
|
|
274
|
-
const routesDir = client.routesDir ?? 'routes';
|
|
275
|
-
const clientAbsDir = path.join(root, srcDir);
|
|
276
|
-
|
|
277
|
-
return {
|
|
278
|
-
root,
|
|
279
|
-
srcDir,
|
|
280
|
-
clientAbsDir,
|
|
281
|
-
routesAbsDir: path.join(clientAbsDir, routesDir),
|
|
282
|
-
publicDir: client.publicDir
|
|
283
|
-
? path.resolve(root, client.publicDir)
|
|
284
|
-
: path.join(clientAbsDir, 'public'),
|
|
285
|
-
toilDir: path.join(root, '.toil'),
|
|
286
|
-
outDir: client.outDir ?? 'build/client',
|
|
287
|
-
base: client.base ?? '/',
|
|
288
|
-
// Port + bind host for the dev server and the self-host, resolved with the
|
|
289
|
-
// precedence: CLI flag (opts) > env (PORT/HOST) > config (client.*) > default.
|
|
290
|
-
// `PORT`/`HOST` are the conventional PaaS env vars; a platform that injects
|
|
291
|
-
// `PORT` (Heroku, Render, Fly, containers) works with zero config.
|
|
292
|
-
port: opts.port ?? envPort() ?? client.port ?? 3000,
|
|
293
|
-
host: opts.host ?? envHost() ?? client.host ?? '127.0.0.1',
|
|
294
|
-
images: client.images ?? true,
|
|
295
|
-
fonts: client.fonts ?? true,
|
|
296
|
-
viewTransitions: client.viewTransitions ?? false,
|
|
297
|
-
transitions: client.transitions ?? false,
|
|
298
|
-
devtools: client.devtools !== false,
|
|
299
|
-
devtoolsAi:
|
|
300
|
-
client.devtools != null && typeof client.devtools === 'object'
|
|
301
|
-
? (client.devtools.ai ?? null)
|
|
302
|
-
: null,
|
|
303
|
-
seo: client.seo ?? null,
|
|
304
|
-
email: user.server?.email ?? null,
|
|
305
|
-
nodeMode: resolveNodeMode(user.server?.nodeMode),
|
|
306
|
-
auth: user.server?.auth === true,
|
|
307
|
-
daemon: resolveDaemonConfig(user.server?.daemon),
|
|
308
|
-
threads: resolveThreads(user.server?.threads),
|
|
309
|
-
runtimePath: resolveRuntimePath(),
|
|
310
|
-
vite: client.vite ?? {},
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/** The `PORT` env var as a positive integer, or `undefined` when unset/invalid
|
|
315
|
-
* (so it falls through to the config value / default rather than binding to 0). */
|
|
316
|
-
function envPort(): number | undefined {
|
|
317
|
-
const v = process.env.PORT;
|
|
318
|
-
if (v == null || v.trim() === '') return undefined;
|
|
319
|
-
const n = Number(v);
|
|
320
|
-
return Number.isFinite(n) && n > 0 ? Math.floor(n) : undefined;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/** The `HOST` env var (trimmed), or `undefined` when unset/blank. */
|
|
324
|
-
function envHost(): string | undefined {
|
|
325
|
-
const v = process.env.HOST;
|
|
326
|
-
return v != null && v.trim() !== '' ? v.trim() : undefined;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
const DEV_NODE_MODES: readonly DevNodeMode[] = ['hot', 'regional', 'continental', 'daemon', 'all'];
|
|
330
|
-
|
|
331
|
-
/** A `nodeMode` outside the enum falls back to `all` with a warning (fail-soft:
|
|
332
|
-
* the authoritative role is the edge's TCF + plan, so dev never bricks on it). */
|
|
333
|
-
function resolveNodeMode(mode: DevNodeMode | undefined): DevNodeMode {
|
|
334
|
-
if (mode === undefined) return 'all';
|
|
335
|
-
if (DEV_NODE_MODES.includes(mode)) return mode;
|
|
336
|
-
process.stdout.write(
|
|
337
|
-
` ! server.nodeMode '${mode}' is not a valid node mode; falling back to 'all'\n`,
|
|
338
|
-
);
|
|
339
|
-
return 'all';
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/** Resolve the daemon config with defaults + light, fail-soft clamping (never
|
|
343
|
-
* throws; the authoritative caps are the edge's). */
|
|
344
|
-
function resolveDaemonConfig(d: DaemonConfig | undefined): ResolvedDaemonConfig {
|
|
345
|
-
// The dev scheduler uses setInterval; a sub-second loop floods the console.
|
|
346
|
-
let defaultIntervalMs = d?.defaultIntervalMs ?? 60000;
|
|
347
|
-
if (defaultIntervalMs < 1000) {
|
|
348
|
-
process.stdout.write(
|
|
349
|
-
` ! server.daemon.defaultIntervalMs ${String(defaultIntervalMs)} < 1000; clamping to 1000\n`,
|
|
350
|
-
);
|
|
351
|
-
defaultIntervalMs = 1000;
|
|
352
|
-
}
|
|
353
|
-
let maxTasks = d?.maxTasks ?? 64;
|
|
354
|
-
if (maxTasks <= 0 || maxTasks > 1024) maxTasks = Math.min(1024, Math.max(1, maxTasks || 64));
|
|
355
|
-
return {
|
|
356
|
-
region: d?.region ?? null,
|
|
357
|
-
standbyRegion: d?.standbyRegion ?? null,
|
|
358
|
-
defaultIntervalMs,
|
|
359
|
-
tickBudgetMs: d?.tickBudgetMs ?? 30000,
|
|
360
|
-
gasTick: d?.gasTick ?? 0,
|
|
361
|
-
maxTasks,
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function resolveThreads(threads: number | 'auto' | undefined): number | 'auto' {
|
|
366
|
-
if (threads === undefined || threads === 'auto') return 'auto';
|
|
367
|
-
if (!Number.isFinite(threads)) return 'auto';
|
|
368
|
-
return Math.max(1, Math.min(128, Math.floor(threads)));
|
|
369
|
-
}
|
package/src/compiler/docs.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI-assistant helper files. `toiljs create` writes a small pointer file for each tool at the
|
|
3
|
-
* project root (committed, yours to edit); the real documentation lives under `.toil/docs/`,
|
|
4
|
-
* regenerated on every `toiljs dev` / `toiljs build` so it stays in sync with the installed
|
|
5
|
-
* toiljs version. The pointer files just tell the agent to read `.toil/docs/`.
|
|
6
|
-
*/
|
|
7
|
-
import fs from 'node:fs';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { TOIL_DOCS } from './toil-docs.generated.js';
|
|
10
|
-
|
|
11
|
-
export { TOIL_DOCS };
|
|
12
|
-
|
|
13
|
-
/** First-level `# ` heading of a Markdown doc, used as the bullet label. */
|
|
14
|
-
function docTitle(content: string): string {
|
|
15
|
-
const m = content.match(/^#\s+(.+)$/m);
|
|
16
|
-
return m ? m[1].trim() : '';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The pointer files' navigation list, derived from the generated `TOIL_DOCS` map so it never
|
|
21
|
-
* drifts from the docs actually written into `.toil/docs/` (no second hand-kept list). We list
|
|
22
|
-
* the section landing pages (each folder's `README.md`, plus the root one) rather than all
|
|
23
|
-
* fifty-plus pages; every landing links onward to its own topic pages, and
|
|
24
|
-
* `.toil/docs/README.md` is the root map.
|
|
25
|
-
*/
|
|
26
|
-
const DOC_POINTERS = Object.keys(TOIL_DOCS)
|
|
27
|
-
.filter((name) => name === 'README.md' || name.endsWith('/README.md'))
|
|
28
|
-
.map((name) => {
|
|
29
|
-
const summary = docTitle(TOIL_DOCS[name]);
|
|
30
|
-
return `- \`.toil/docs/${name}\`${summary ? `, ${summary}` : ''}`;
|
|
31
|
-
})
|
|
32
|
-
.join('\n');
|
|
33
|
-
|
|
34
|
-
/** Shared body for the per-tool pointer files. */
|
|
35
|
-
const POINTER_BODY = `# toiljs, AI assistant guide
|
|
36
|
-
|
|
37
|
-
This is a **toiljs** project, a full-stack React framework (React + Vite client, file-based
|
|
38
|
-
routing, and a toilscript→WebAssembly server).
|
|
39
|
-
|
|
40
|
-
**Before editing this project, read the generated documentation in \`.toil/docs/\`, starting at
|
|
41
|
-
\`.toil/docs/README.md\`.** It describes the conventions you must follow. The sections, each a
|
|
42
|
-
folder whose \`README.md\` links onward to its topic pages:
|
|
43
|
-
|
|
44
|
-
${DOC_POINTERS}
|
|
45
|
-
|
|
46
|
-
## Rules you must follow
|
|
47
|
-
|
|
48
|
-
Read \`.toil/docs/concepts/ai-guide.md\` first, it is the concise correct-usage cheat-sheet. The essentials:
|
|
49
|
-
|
|
50
|
-
- **Never call the toiljs backend with raw \`fetch\`.** Use the generated typed client:
|
|
51
|
-
\`Server.REST.<controller>.<route>(args)\` for \`@rest\` HTTP controllers, or
|
|
52
|
-
\`Server.<service>.<method>(args)\` / \`Server.<remote>(args)\` for \`@service\` / \`@remote\` RPC. \`Server\` is a
|
|
53
|
-
global (no import). Raw \`fetch\` to your own backend throws away type safety and the wire codec and
|
|
54
|
-
breaks silently on a rename. Wrong: \`await fetch('/account/session', { method: 'POST' })\`. Right:
|
|
55
|
-
\`await Server.REST.account.session()\`. \`fetch\` is only for third-party URLs.
|
|
56
|
-
- Use the ambient \`Toil.*\` globals with NO import (\`Toil.Link\`, \`Toil.useLoaderData\`, \`Toil.Image\`,
|
|
57
|
-
\`Toil.Form\`, \`Toil.useHead\`, ...). \`Server\`, \`FastMap\`, \`FastSet\`, \`DataWriter\`, \`DataReader\` are bare
|
|
58
|
-
globals too. Load page data with \`export const loader\` + \`Toil.useLoaderData(loader)\`, NOT a \`useEffect\`
|
|
59
|
-
fetch; mutate with \`Toil.useAction\` / \`<Toil.Form>\` then revalidate.
|
|
60
|
-
- Client \`getUser()\` is DISPLAY-ONLY and forgeable, never gate real access on it. Enforce access on the
|
|
61
|
-
SERVER with \`@auth\` (it re-verifies the signed session, so inside an \`@auth\` handler
|
|
62
|
-
\`AuthService.getUser()!\` is guaranteed non-null).
|
|
63
|
-
- Server code is strict AssemblyScript: explicit value types (\`i32\`/\`u32\`/\`i64\`/\`u64\`/\`f64\`/\`bool\`/
|
|
64
|
-
\`string\`/\`Uint8Array\`), no \`any\`, no plain \`number\`, no usable \`RegExp\`. Structured values are \`@data\`
|
|
65
|
-
classes; exactly one \`@user\` per project; read config with \`Environment.get\` and secrets with
|
|
66
|
-
\`Environment.getSecure\`.
|
|
67
|
-
- Never hand-edit \`shared/server.ts\` or anything under \`.toil/\` (both are generated).
|
|
68
|
-
|
|
69
|
-
See \`.toil/docs/frontend/data-fetching.md\`, \`.toil/docs/frontend/toil-global.md\`, and
|
|
70
|
-
\`.toil/docs/concepts/decorators.md\` for detail.
|
|
71
|
-
|
|
72
|
-
\`.toil/docs/\` is regenerated by toiljs; do not edit it by hand. This pointer file is yours to edit.
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
|
-
/** A selectable AI coding-tool helper: its id, label, and the root pointer file(s) it scaffolds. */
|
|
76
|
-
export interface AiHelper {
|
|
77
|
-
readonly id: string;
|
|
78
|
-
readonly label: string;
|
|
79
|
-
readonly files: Record<string, string>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Per-tool pointer files, individually selectable in `toiljs create`. Each tool reads its own
|
|
84
|
-
* conventional file: Claude Code → CLAUDE.md, Codex / others → AGENTS.md, Cursor → .cursor/rules,
|
|
85
|
-
* GitHub Copilot → .github/copilot-instructions.md. Written once by `create`; not regenerated.
|
|
86
|
-
*/
|
|
87
|
-
export const AI_HELPERS: readonly AiHelper[] = [
|
|
88
|
-
{ id: 'claude', label: 'Claude Code (CLAUDE.md)', files: { 'CLAUDE.md': POINTER_BODY } },
|
|
89
|
-
{ id: 'codex', label: 'Codex / AGENTS.md', files: { 'AGENTS.md': POINTER_BODY } },
|
|
90
|
-
{
|
|
91
|
-
id: 'cursor',
|
|
92
|
-
label: 'Cursor (.cursor/rules)',
|
|
93
|
-
files: {
|
|
94
|
-
'.cursor/rules/toiljs.mdc': `---\ndescription: toiljs project conventions\nalwaysApply: true\n---\n\n${POINTER_BODY}`,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
id: 'copilot',
|
|
99
|
-
label: 'GitHub Copilot (.github/copilot-instructions.md)',
|
|
100
|
-
files: { '.github/copilot-instructions.md': POINTER_BODY },
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
|
|
104
|
-
/** All AI helper ids (the default selection). */
|
|
105
|
-
export const AI_HELPER_IDS: readonly string[] = AI_HELPERS.map((h) => h.id);
|
|
106
|
-
|
|
107
|
-
/** Merges the pointer files for the given helper ids into one path → content map. */
|
|
108
|
-
export function aiHelperFiles(ids: readonly string[]): Record<string, string> {
|
|
109
|
-
const out: Record<string, string> = {};
|
|
110
|
-
for (const helper of AI_HELPERS) {
|
|
111
|
-
if (ids.includes(helper.id)) Object.assign(out, helper.files);
|
|
112
|
-
}
|
|
113
|
-
return out;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** Writes the framework docs into `<toilDir>/docs/`. Called by `generate` each dev/build. */
|
|
117
|
-
export function writeDocs(toilDir: string): void {
|
|
118
|
-
const dir = path.join(toilDir, 'docs');
|
|
119
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
120
|
-
for (const [name, content] of Object.entries(TOIL_DOCS)) {
|
|
121
|
-
const dest = path.join(dir, name);
|
|
122
|
-
// Doc keys can be nested (e.g. "auth/configuration.md"), so ensure the
|
|
123
|
-
// file's parent directory exists before writing it.
|
|
124
|
-
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
125
|
-
fs.writeFileSync(dest, content);
|
|
126
|
-
}
|
|
127
|
-
}
|