toiljs 0.0.127 → 0.0.129
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 +29 -0
- package/assets/image-codec-LICENSES.txt +4599 -0
- package/assets/image-codec-build.json +10 -0
- package/assets/image-codec.wasm +0 -0
- package/build/backend/index.d.ts +1 -0
- package/build/backend/index.js +8 -3
- package/build/backend/security.d.ts +4 -0
- package/build/backend/security.js +31 -0
- package/build/cli/index.js +11 -39
- package/build/client/components/Script.js +28 -17
- package/build/client/files.d.ts +17 -0
- package/build/client/files.js +119 -0
- package/build/client/html.d.ts +1 -0
- package/build/client/html.js +8 -0
- package/build/client/index.d.ts +1 -0
- package/build/client/index.js +1 -0
- package/build/client/security.d.ts +4 -0
- package/build/client/security.js +55 -0
- package/build/client/ssr/markers.js +6 -1
- package/build/compiler/config.d.ts +2 -0
- package/build/compiler/config.js +1 -0
- package/build/compiler/generate.d.ts +1 -1
- package/build/compiler/generate.js +1 -37
- package/build/compiler/index.d.ts +1 -0
- package/build/compiler/index.js +56 -1
- package/build/compiler/security-deployment.d.ts +3 -0
- package/build/compiler/security-deployment.js +88 -0
- package/build/compiler/security.d.ts +7 -0
- package/build/compiler/security.js +74 -0
- package/build/compiler/sri.js +10 -3
- package/build/compiler/toil-docs.generated.js +35 -28
- package/build/compiler/vite.js +2 -0
- package/build/devserver/config/env.d.ts +6 -0
- package/build/devserver/config/env.js +10 -2
- package/build/devserver/daemon/catalog.d.ts +1 -0
- package/build/devserver/daemon/catalog.js +10 -4
- package/build/devserver/daemon/host.d.ts +5 -1
- package/build/devserver/daemon/host.js +8 -4
- package/build/devserver/daemon/http.d.ts +14 -0
- package/build/devserver/daemon/http.js +90 -0
- package/build/devserver/daemon/index.d.ts +21 -1
- package/build/devserver/daemon/index.js +109 -21
- package/build/devserver/db/atomic.d.ts +8 -0
- package/build/devserver/db/atomic.js +133 -0
- package/build/devserver/db/catalog.d.ts +7 -0
- package/build/devserver/db/catalog.js +17 -0
- package/build/devserver/db/changes.d.ts +5 -0
- package/build/devserver/db/changes.js +49 -0
- package/build/devserver/db/database.d.ts +7 -0
- package/build/devserver/db/database.js +251 -41
- package/build/devserver/db/derives.d.ts +4 -5
- package/build/devserver/db/derives.js +7 -76
- package/build/devserver/db/document-scan.d.ts +2 -0
- package/build/devserver/db/document-scan.js +123 -0
- package/build/devserver/db/limits.d.ts +16 -0
- package/build/devserver/db/limits.js +92 -14
- package/build/devserver/db/types.d.ts +15 -0
- package/build/devserver/db/types.js +9 -0
- package/build/devserver/files/dev.d.ts +3 -0
- package/build/devserver/files/dev.js +29 -0
- package/build/devserver/files/disk.d.ts +17 -0
- package/build/devserver/files/disk.js +369 -0
- package/build/devserver/files/signatures.d.ts +16 -0
- package/build/devserver/files/signatures.js +151 -0
- package/build/devserver/http/proxy.js +11 -3
- package/build/devserver/http/runtime.js +36 -9
- package/build/devserver/images/index.d.ts +9 -0
- package/build/devserver/images/index.js +87 -0
- package/build/devserver/images/worker.d.mts +1 -0
- package/build/devserver/images/worker.mjs +24 -0
- package/build/devserver/index.d.ts +3 -1
- package/build/devserver/production.js +5 -3
- package/build/devserver/runtime/host.d.ts +4 -0
- package/build/devserver/runtime/host.js +6 -2
- package/build/devserver/runtime/module.d.ts +15 -0
- package/build/devserver/runtime/module.js +105 -7
- package/build/devserver/server.js +13 -1
- package/build/devserver/stream/host.d.ts +2 -0
- package/build/devserver/stream/host.js +2 -1
- package/build/devserver/stream/index.js +2 -0
- package/build/io/derive-metadata.d.ts +7 -0
- package/build/io/derive-metadata.js +44 -0
- package/build/io/index.d.ts +1 -0
- package/build/io/index.js +1 -0
- package/build/shared/index.d.ts +1 -0
- package/build/shared/index.js +1 -0
- package/build/shared/security.d.ts +5 -0
- package/build/shared/security.js +80 -0
- package/docs/auth/vectors-v1.json +41 -0
- package/examples/basic/client/routes/rest.tsx +1 -1
- package/examples/basic/server/routes/Guestbook.ts +1 -1
- package/package.json +20 -7
- package/scripts/build-image-codec.mjs +79 -0
- package/scripts/gen-auth-vectors.mjs +132 -0
- package/scripts/gen-native-atomic-fixture.mjs +39 -0
- package/scripts/gen-native-blob-fixture.mjs +42 -0
- package/scripts/gen-native-image-fixture.mjs +65 -0
- package/scripts/gen-native-staging-fixture.mjs +41 -0
- package/scripts/gen-server-types.mjs +82 -0
- package/scripts/gen-toil-docs.mjs +19 -7
- package/server/auth/AuthController.ts +15 -234
- package/server/auth/AuthMaintenance.ts +177 -0
- package/server/auth/AuthStore.ts +198 -0
- package/server/auth/SessionEpochs.ts +38 -9
- package/server/globals/auth.ts +56 -0
- package/server/globals/userid.ts +4 -5
- package/server/globals.d.ts +37 -0
- package/server/runtime/envelope.ts +2 -1
- package/server/runtime/exports/index.ts +2 -1
- package/server/runtime/files/blobs.ts +341 -0
- package/server/runtime/files/images.ts +36 -0
- package/server/runtime/http/percent.ts +5 -4
- package/server/runtime/index.ts +5 -0
- package/server/runtime/response.ts +20 -0
- package/server/runtime/rest/RouteContext.ts +5 -4
- package/std/server/abort/abort.d.ts +25 -0
- package/std/server/env/Server.d.ts +47 -0
- package/std/server/envelope.d.ts +38 -0
- package/std/server/exports/index.d.ts +20 -0
- package/std/server/exports/render.d.ts +15 -0
- package/std/server/files/blobs.d.ts +50 -0
- package/std/server/files/images.d.ts +36 -0
- package/std/server/handlers/ToilHandler.d.ts +29 -0
- package/std/server/http/base64.d.ts +21 -0
- package/std/server/http/cookie.d.ts +127 -0
- package/std/server/http/cookies.d.ts +56 -0
- package/std/server/http/date.d.ts +17 -0
- package/std/server/http/percent.d.ts +19 -0
- package/std/server/http/securecookies.d.ts +55 -0
- package/std/server/index.d.ts +34 -0
- package/std/server/lang/Potential.d.ts +6 -0
- package/std/server/memory.d.ts +42 -0
- package/std/server/request.d.ts +47 -0
- package/std/server/response.d.ts +90 -0
- package/std/server/rest/Rest.d.ts +23 -0
- package/std/server/rest/RestHandler.d.ts +14 -0
- package/std/server/rest/RouteContext.d.ts +33 -0
- package/std/server/rest/match.d.ts +14 -0
- package/std/server/rpc/Rpc.d.ts +37 -0
- package/std/server/ssr/Ssr.d.ts +27 -0
- package/std/server/ssr/encode.d.ts +26 -0
- package/std/server/ssr/escape.d.ts +22 -0
- package/std/server/ssr/slots.d.ts +91 -0
- package/std/server/time.d.ts +24 -0
- package/tsconfig.json +11 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* A drop-in handler for REST-only projects: dispatches to every `@rest`
|
|
4
|
+
* controller and 404s on a miss. Wire it with
|
|
5
|
+
* `Server.handler = () => new RestHandler()`. If you need custom logic, skip
|
|
6
|
+
* this and call `Rest.dispatch(req)` from your own `ToilHandler` instead.
|
|
7
|
+
*/
|
|
8
|
+
import { Request } from '../request';
|
|
9
|
+
import { Response } from '../response';
|
|
10
|
+
import { ToilHandler } from '../handlers/ToilHandler';
|
|
11
|
+
export declare class RestHandler extends ToilHandler {
|
|
12
|
+
/** Dispatches to the registered `@rest` controllers; an unhandled-marked 404 when none match. */
|
|
13
|
+
handle(req: Request): Response;
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* Per-request context handed to a `@route` method. Carries the captured path
|
|
4
|
+
* params (`/todos/:id`), the parsed query string, and the raw `Request`. The
|
|
5
|
+
* compiler builds one of these for you and injects it into any route method
|
|
6
|
+
* that declares a `RouteContext` parameter.
|
|
7
|
+
*/
|
|
8
|
+
import { Request } from '../request';
|
|
9
|
+
export declare class RouteContext {
|
|
10
|
+
/** The raw incoming request (method, path, headers, body). */
|
|
11
|
+
request: Request;
|
|
12
|
+
private paramKeys;
|
|
13
|
+
private paramVals;
|
|
14
|
+
private queryKeys;
|
|
15
|
+
private queryVals;
|
|
16
|
+
constructor(request: Request, paramKeys: Array<string>, paramVals: Array<string>);
|
|
17
|
+
/** A captured path parameter (`/todos/:id` gives `param("id")`), or "" if absent. */
|
|
18
|
+
param(name: string): string;
|
|
19
|
+
/** A decoded query value, or "" if absent. Percent escapes and form `+` are decoded once. */
|
|
20
|
+
query(name: string): string;
|
|
21
|
+
/** Case-insensitive request header, or null. Delegates to `Request.header`. */
|
|
22
|
+
header(name: string): string | null;
|
|
23
|
+
/** The raw request body decoded as UTF-8 text (used by the JSON stream codec). */
|
|
24
|
+
text(): string;
|
|
25
|
+
/**
|
|
26
|
+
* The connecting client's IP as a string ("203.0.113.7" or an IPv6 form),
|
|
27
|
+
* or "" if unavailable. This is the TRUSTED socket peer the edge observed,
|
|
28
|
+
* not a forgeable header like X-Forwarded-For, so it is safe to key rate
|
|
29
|
+
* limits, geo, or audit logs on it.
|
|
30
|
+
*/
|
|
31
|
+
clientIp(): string;
|
|
32
|
+
private ensureQuery;
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* Compile-time route patterns (`/api/todos/:id`) matched against a request path
|
|
4
|
+
* at runtime, capturing `:params`. The compiler emits one `matchRoute(...)` call
|
|
5
|
+
* per route inside a controller's injected `__tryRoute`.
|
|
6
|
+
*/
|
|
7
|
+
import { Request } from '../request';
|
|
8
|
+
import { RouteContext } from './RouteContext';
|
|
9
|
+
/**
|
|
10
|
+
* Match `pattern` against `req.path`. Static segments must be equal; a `:name`
|
|
11
|
+
* segment captures the corresponding path segment. The query string is ignored
|
|
12
|
+
* for matching. Returns a populated `RouteContext` on a match, `null` on a miss.
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchRoute(pattern: string, req: Request): RouteContext | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* The auto-populated RPC dispatcher. Every `@service` method and free `@remote`
|
|
4
|
+
* function self-registers here at module init (compiler-injected), keyed by a
|
|
5
|
+
* deterministic method id (FNV-1a of `"Service.method"` / `"fnName"` — the same
|
|
6
|
+
* hash the generated client sends). The wasm `handle` export dispatches a
|
|
7
|
+
* reserved `POST /__toil_rpc` (method id in the `dacely-rpc` header, `@data`-encoded
|
|
8
|
+
* args in the body) to the matching method and returns its `@data`-encoded
|
|
9
|
+
* result. Mirrors `Rest` (../rest/Rest.ts); calls are STATELESS — a fresh service
|
|
10
|
+
* instance per call, exactly like a `@rest` controller.
|
|
11
|
+
*/
|
|
12
|
+
import { Request } from '../request';
|
|
13
|
+
import { Response } from '../response';
|
|
14
|
+
/** The reserved path a generated RPC client POSTs to. */
|
|
15
|
+
export declare const RPC_PATH: string;
|
|
16
|
+
/** The request header carrying the decimal `u32` method id. */
|
|
17
|
+
export declare const RPC_HEADER: string;
|
|
18
|
+
/** A registered RPC method: takes the encoded-args body and returns a `Response` - the encoded result
|
|
19
|
+
* (`Response.bytes`) on success, or a guard's `401`/`429` when the method carries `@auth`/`@ratelimit`.
|
|
20
|
+
* The compiler injects these (see toilscript injectService/injectRemote). */
|
|
21
|
+
export type RpcFn = (body: Uint8Array) => Response;
|
|
22
|
+
export declare class RpcRegistry {
|
|
23
|
+
private ids;
|
|
24
|
+
private fns;
|
|
25
|
+
/** Compiler-injected: register one `@service` method / `@remote` function by id. Not for direct use. */
|
|
26
|
+
register(id: u32, fn: RpcFn): void;
|
|
27
|
+
/**
|
|
28
|
+
* Dispatch a reserved `POST /__toil_rpc` call to its registered method. Returns `null` for ANY
|
|
29
|
+
* non-RPC request (wrong method, wrong path, no id header) so the caller falls through to the
|
|
30
|
+
* normal handler; returns a `400` for a well-formed RPC call whose id is unknown.
|
|
31
|
+
*/
|
|
32
|
+
dispatch(req: Request): Response | null;
|
|
33
|
+
/** Number of registered methods (diagnostics / tests). */
|
|
34
|
+
get size(): i32;
|
|
35
|
+
}
|
|
36
|
+
/** The process-wide RPC dispatcher singleton. */
|
|
37
|
+
export declare const Rpc: RpcRegistry;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* The auto-populated SSR render router. Every compiler-generated route render
|
|
4
|
+
* self-registers here at module init; the `render` wasm export calls
|
|
5
|
+
* `Ssr.dispatch(req)` to find the one whose path matches. The host has already
|
|
6
|
+
* decided this is a template route, but the guest re-derives WHICH route from
|
|
7
|
+
* the request path (the template name is not in the request envelope), exactly
|
|
8
|
+
* as a `@rest` controller matches its own prefix.
|
|
9
|
+
*
|
|
10
|
+
* First matching render wins; `null` means no route matched (a guest/host
|
|
11
|
+
* coherence problem) and the export emits a fail-safe empty result.
|
|
12
|
+
*/
|
|
13
|
+
import { Request } from '../request';
|
|
14
|
+
import { SlotValues } from './slots';
|
|
15
|
+
/** A route render: returns filled hole values on a path hit, null on a miss. */
|
|
16
|
+
export type RenderFn = (req: Request) => SlotValues | null;
|
|
17
|
+
export declare class SsrRegistry {
|
|
18
|
+
private fns;
|
|
19
|
+
/** Compiler-injected: registers a route's render. Not for direct use. */
|
|
20
|
+
register(fn: RenderFn): void;
|
|
21
|
+
/** Try every registered render in registration order; first match wins. */
|
|
22
|
+
dispatch(req: Request): SlotValues | null;
|
|
23
|
+
/** Number of registered renders (diagnostics / tests). */
|
|
24
|
+
get size(): i32;
|
|
25
|
+
}
|
|
26
|
+
/** The process-wide SSR render router singleton. */
|
|
27
|
+
export declare const Ssr: SsrRegistry;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* Serialiser for the SSR **values envelope** (guest -> host), byte-for-byte
|
|
4
|
+
* compatible with `toil-backend/src/host/template/assemble.rs::decode_values`.
|
|
5
|
+
*
|
|
6
|
+
* Layout (LE, no padding):
|
|
7
|
+
*
|
|
8
|
+
* u16 status
|
|
9
|
+
* [32] template_hash
|
|
10
|
+
* u16 n_headers
|
|
11
|
+
* for each header: u16 name_len, u16 val_len, [u8] name, [u8] val
|
|
12
|
+
* u16 n_slots
|
|
13
|
+
* for each value: u16 slot_id, u8 kind, u32 value_len, [u8] value
|
|
14
|
+
*
|
|
15
|
+
* The host keys values by `slot_id` and inserts each at the manifest-fixed
|
|
16
|
+
* offset, so the guest can never choose where bytes land.
|
|
17
|
+
*/
|
|
18
|
+
import { SlotValues } from './slots';
|
|
19
|
+
/** Serialise `v` into linear memory at `dst_ofs`; returns bytes written. On any
|
|
20
|
+
* representability violation (counts/lengths over their field widths, or a
|
|
21
|
+
* wrong-sized hash) a minimal 500 envelope is written instead so the host never
|
|
22
|
+
* sees an encoder fault. */
|
|
23
|
+
export declare function encodeValues(v: SlotValues, dst_ofs: usize): u32;
|
|
24
|
+
/** Upper bound on the encoded size of `v`, used to size the response slot the
|
|
25
|
+
* `render` export allocates before encoding. */
|
|
26
|
+
export declare function valuesEncodedBound(v: SlotValues): usize;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* HTML escaping for edge-SSR hole values, byte-for-byte identical to
|
|
4
|
+
* react-dom/server's `escapeTextForBrowser` (the regex `/["'&<>]/`). React
|
|
5
|
+
* runs the SAME escaper for text children and attribute values, so a single
|
|
6
|
+
* function serves both kinds. Matching React exactly is load-bearing: the
|
|
7
|
+
* browser's `hydrateRoot` compares the server markup to its own first render,
|
|
8
|
+
* and any escaping difference triggers a hydration mismatch.
|
|
9
|
+
*
|
|
10
|
+
* Note the entities: `'` becomes `'` (React's choice, NOT `'` or
|
|
11
|
+
* `'`), and `"` becomes `"`. Do not "simplify" these.
|
|
12
|
+
*/
|
|
13
|
+
/** React-exact HTML text/attribute escape. */
|
|
14
|
+
export declare function escapeHtml(s: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Escape a JSON string for safe embedding inside a `<script>` element (the
|
|
17
|
+
* `__toil_state` hydration blob). Neutralises `<`, `>`, `&` and the JS line
|
|
18
|
+
* terminators U+2028/U+2029 to their `\uXXXX` forms so the JSON can never
|
|
19
|
+
* close the script element or break the parse. Mirrors the standard
|
|
20
|
+
* "serialize-javascript"/Next.js approach; the bytes stay valid JSON.
|
|
21
|
+
*/
|
|
22
|
+
export declare function escapeJsonForScript(json: string): string;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* The values the guest `render` returns for one request: the hole values the
|
|
4
|
+
* edge splices into the precompiled template. The guest never emits the static
|
|
5
|
+
* template bytes (the host has those, mmap'd); it only fills the holes.
|
|
6
|
+
*
|
|
7
|
+
* Authoring is normally generated by the toiljs compiler from the route's JSX,
|
|
8
|
+
* but the typed API here is hand-writable too (it is the escape hatch). A
|
|
9
|
+
* generated render looks like:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* export function renderProfile(req: Request): SlotValues {
|
|
13
|
+
* const v = new SlotValues(HASH);
|
|
14
|
+
* v.setText(Slot.username, params(req, 'name'));
|
|
15
|
+
* v.setRaw(Slot.bio, bioHtml);
|
|
16
|
+
* const rows = new HtmlBuilder();
|
|
17
|
+
* for (let i = 0; i < posts.length; i++) rows.raw('<li>').text(posts[i]).raw('</li>');
|
|
18
|
+
* v.setRepeat(Slot.posts, rows);
|
|
19
|
+
* return v;
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { Header } from '../request';
|
|
24
|
+
/** Slot kind discriminants. Mirror `toil-backend` `SlotKind` and the on-disk
|
|
25
|
+
* `.slots` manifest; do not reorder. */
|
|
26
|
+
export declare namespace SlotKind {
|
|
27
|
+
const TEXT: u8;
|
|
28
|
+
const RAW: u8;
|
|
29
|
+
const ATTR: u8;
|
|
30
|
+
const REPEAT: u8;
|
|
31
|
+
}
|
|
32
|
+
/** Number of bytes in the coherence hash; must match the host's `HASH_LEN`. */
|
|
33
|
+
export declare const HASH_LEN: i32;
|
|
34
|
+
/** One filled hole: its stable id, kind, and the already-escaped bytes. The id
|
|
35
|
+
* is held as `i32` so a generated `Slot` enum member (AS enums are `i32`) is
|
|
36
|
+
* passed without a cast; it is narrowed to `u16` only at encode time. */
|
|
37
|
+
export declare class SlotValue {
|
|
38
|
+
slotId: i32;
|
|
39
|
+
kind: u8;
|
|
40
|
+
bytes: Uint8Array;
|
|
41
|
+
constructor(slotId: i32, kind: u8, bytes: Uint8Array);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Append-only HTML byte builder for repeat regions (and any place the
|
|
45
|
+
* generated code assembles a run of static chunks + escaped values). `raw`
|
|
46
|
+
* appends verbatim template bytes; `text`/`attr` append React-escaped values.
|
|
47
|
+
* Chaining keeps generated loops terse.
|
|
48
|
+
*/
|
|
49
|
+
export declare class HtmlBuilder {
|
|
50
|
+
private parts;
|
|
51
|
+
raw(s: string): HtmlBuilder;
|
|
52
|
+
text(s: string): HtmlBuilder;
|
|
53
|
+
/** Attribute escaping is identical to text escaping in React. */
|
|
54
|
+
attr(s: string): HtmlBuilder;
|
|
55
|
+
toBytes(): Uint8Array;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The render result: status, coherence hash, response headers, and the ordered
|
|
59
|
+
* filled holes. Serialised by `encodeValues` into the values envelope the host
|
|
60
|
+
* splices against the template manifest.
|
|
61
|
+
*/
|
|
62
|
+
export declare class SlotValues {
|
|
63
|
+
templateHash: StaticArray<u8>;
|
|
64
|
+
status: u16;
|
|
65
|
+
headers: Array<Header>;
|
|
66
|
+
slots: Array<SlotValue>;
|
|
67
|
+
/** `hash` is the route's compiled-in coherence hash (32 bytes); the host
|
|
68
|
+
* rejects the response if it does not match the deployed template. */
|
|
69
|
+
constructor(templateHash: StaticArray<u8>);
|
|
70
|
+
/** A text hole: React-escaped. */
|
|
71
|
+
setText(slotId: i32, value: string): SlotValues;
|
|
72
|
+
/** A raw-HTML hole: inserted verbatim. The author owns sanitisation, same
|
|
73
|
+
* as React `dangerouslySetInnerHTML`. */
|
|
74
|
+
setRaw(slotId: i32, html: string): SlotValues;
|
|
75
|
+
/** An attribute-value hole. */
|
|
76
|
+
setAttr(slotId: i32, value: string): SlotValues;
|
|
77
|
+
/** A repeat region: the guest pre-stamped + concatenated rows (built via
|
|
78
|
+
* [`HtmlBuilder`]); the host inserts them verbatim at the region offset. */
|
|
79
|
+
setRepeat(slotId: i32, rows: HtmlBuilder): SlotValues;
|
|
80
|
+
/** Add a response header (e.g. a Set-Cookie or Cache-Control). */
|
|
81
|
+
setHeader(name: string, value: string): SlotValues;
|
|
82
|
+
/** Set the document `<title>` for THIS request, overriding the template's baked title. Use for
|
|
83
|
+
* data-driven titles on SSR routes (e.g. a blog post's title from its loader). React-escaped.
|
|
84
|
+
* Carried as an internal `x-toil-ssr-title` header the host consumes — it replaces the `<title>`
|
|
85
|
+
* and strips the header, so it never reaches the client. */
|
|
86
|
+
setTitle(title: string): SlotValues;
|
|
87
|
+
setStatus(status: u16): SlotValues;
|
|
88
|
+
}
|
|
89
|
+
/** A zeroed 32-byte hash. Used for the fail-safe empty result, which the host
|
|
90
|
+
* rejects as a hash mismatch (-> 500) rather than serving a broken page. */
|
|
91
|
+
export declare function zeroHash(): StaticArray<u8>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated from server/runtime by scripts/gen-server-types.mjs.
|
|
2
|
+
/**
|
|
3
|
+
* `Time` — the guest's wall-clock, backed by the host's `Date.now()` binding
|
|
4
|
+
* (`env.Date.now`). Both the edge (`toil-backend` `date_now_import.rs`) and the
|
|
5
|
+
* dev server (`toiljs/src/devserver/host.ts`) provide it, so time behaves the
|
|
6
|
+
* same in `toiljs dev` and in production.
|
|
7
|
+
*
|
|
8
|
+
* This is the toiljs-blessed way to read the clock; prefer it over a raw
|
|
9
|
+
* `Date.now()` so the host boundary (and its single millisecond unit) is
|
|
10
|
+
* explicit and easy to find. Like browser `Date.now()` it is WALL-CLOCK, not
|
|
11
|
+
* monotonic: it can step backward across an NTP correction, so never use it to
|
|
12
|
+
* measure elapsed time, only to stamp/compare absolute instants (session
|
|
13
|
+
* `iat`/`exp`, challenge expiry, cache ages).
|
|
14
|
+
*
|
|
15
|
+
* Exposed as an ambient global (`@global`, usable with no import in a handler)
|
|
16
|
+
* and re-exported from `toiljs/server/runtime`.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Time {
|
|
19
|
+
/** Milliseconds since the Unix epoch (the host `Date.now()` value). */
|
|
20
|
+
static nowMillis(): u64;
|
|
21
|
+
/** Whole seconds since the Unix epoch (`nowMillis() / 1000`), the unit used
|
|
22
|
+
* for session and challenge timestamps. */
|
|
23
|
+
static nowSeconds(): u64;
|
|
24
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
"noEmit": true,
|
|
9
9
|
"incremental": false
|
|
10
10
|
},
|
|
11
|
-
"include": [
|
|
12
|
-
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.ts",
|
|
13
|
+
"src/**/*.tsx",
|
|
14
|
+
"src/**/*.mjs",
|
|
15
|
+
"std/client/index.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules",
|
|
19
|
+
"build",
|
|
20
|
+
"server"
|
|
21
|
+
]
|
|
13
22
|
}
|