@krate/runtime 0.5.0-rc.1 → 0.5.0-rc.10
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/dist/action-context.js +1 -1
- package/dist/actions.d.ts +7 -0
- package/dist/actions.js +34 -10
- package/dist/after.d.ts +28 -0
- package/dist/after.js +48 -0
- package/dist/assets-static.d.ts +10 -1
- package/dist/assets-static.js +10 -2
- package/dist/base-path.d.ts +7 -0
- package/dist/base-path.js +20 -0
- package/dist/boundary.js +1 -1
- package/dist/builtin-tags.d.ts +12 -0
- package/dist/builtin-tags.js +42 -0
- package/dist/cache-adapter.js +1 -1
- package/dist/cache-scope.d.ts +8 -0
- package/dist/cache-scope.js +14 -1
- package/dist/cloudflare-workers.d.ts +2 -0
- package/dist/cloudflare-workers.js +27 -0
- package/dist/context.d.ts +5 -0
- package/dist/context.js +28 -17
- package/dist/dev-overlay.d.ts +54 -3
- package/dist/dev-overlay.js +470 -77
- package/dist/dom.js +18 -3
- package/dist/effects.js +2 -2
- package/dist/flight-props.d.ts +7 -0
- package/dist/flight-props.js +105 -0
- package/dist/handler-html.js +4 -4
- package/dist/handler-routing.d.ts +2 -23
- package/dist/handler-routing.js +9 -190
- package/dist/handler-segments.d.ts +6 -0
- package/dist/handler-segments.js +18 -4
- package/dist/head-tags.d.ts +9 -0
- package/dist/head-tags.js +93 -6
- package/dist/highlight-bind.js +1 -1
- package/dist/highlight.d.ts +3 -2
- package/dist/highlight.js +17 -12
- package/dist/hints.d.ts +25 -2
- package/dist/hints.js +147 -74
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/island-swap.d.ts +47 -0
- package/dist/island-swap.js +635 -0
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-types.d.ts +99 -3
- package/dist/krate-core.js +1 -1
- package/dist/krate-dev.js +385 -66
- package/dist/krate-f-actions.js +1 -1
- package/dist/krate-f-classes.js +1 -1
- package/dist/krate-f-highlight.js +1 -1
- package/dist/krate-f-list.js +1 -1
- package/dist/krate-f-navigation.js +1 -1
- package/dist/krate-f-router-lite.js +1 -1
- package/dist/krate-f-router.js +1 -1
- package/dist/krate-features.json +454 -0
- package/dist/krate-hydrate-lite.js +5 -5
- package/dist/krate-hydrate.js +5 -5
- package/dist/krate-island-swap.js +1 -0
- package/dist/krate-runtime.js +5 -5
- package/dist/list.d.ts +14 -4
- package/dist/list.js +4 -5
- package/dist/metadata.js +5 -2
- package/dist/navigation-react.d.ts +13 -0
- package/dist/navigation-react.js +86 -0
- package/dist/navigation.d.ts +19 -0
- package/dist/navigation.js +35 -0
- package/dist/node-server.js +3 -3
- package/dist/og.js +1 -1
- package/dist/platform.d.ts +52 -0
- package/dist/platform.js +57 -0
- package/dist/react-compat.d.ts +39 -0
- package/dist/react-compat.js +359 -0
- package/dist/react-server.d.ts +63 -0
- package/dist/react-server.js +125 -0
- package/dist/region-wire.d.ts +10 -0
- package/dist/region-wire.js +154 -0
- package/dist/request-context.js +1 -1
- package/dist/request-extras.d.ts +4 -0
- package/dist/request-extras.js +51 -0
- package/dist/resp.js +1 -1
- package/dist/route-source.d.ts +39 -0
- package/dist/route-source.js +532 -0
- package/dist/router-lite.js +3 -9
- package/dist/router.d.ts +1 -1
- package/dist/router.js +628 -98
- package/dist/server-handler.d.ts +69 -1
- package/dist/server-handler.js +515 -96
- package/dist/server-renderer.js +16 -7
- package/dist/server.d.ts +73 -16
- package/dist/server.js +619 -102
- package/dist/sha256.js +9 -9
- package/dist/signal.js +0 -6
- package/dist/site-config.d.ts +15 -0
- package/dist/site-config.js +28 -0
- package/dist/slot.d.ts +12 -0
- package/dist/slot.js +23 -0
- package/dist/ssr-core.d.ts +2 -0
- package/dist/ssr-core.js +12 -4
- package/dist/testing.d.ts +62 -0
- package/dist/testing.js +90 -0
- package/dist/use-id.js +1 -1
- package/package.json +28 -3
- package/dist/action-context.test.d.ts +0 -1
- package/dist/action-context.test.js +0 -72
- package/dist/actions.test.d.ts +0 -1
- package/dist/actions.test.js +0 -477
- package/dist/cache-adapter.test.d.ts +0 -1
- package/dist/cache-adapter.test.js +0 -244
- package/dist/cache.test.d.ts +0 -1
- package/dist/cache.test.js +0 -233
- package/dist/class-component.test.d.ts +0 -1
- package/dist/class-component.test.js +0 -462
- package/dist/class-helpers.test.d.ts +0 -1
- package/dist/class-helpers.test.js +0 -169
- package/dist/context.test.d.ts +0 -1
- package/dist/context.test.js +0 -57
- package/dist/derived.test.d.ts +0 -1
- package/dist/derived.test.js +0 -140
- package/dist/dev-overlay.test.d.ts +0 -1
- package/dist/dev-overlay.test.js +0 -165
- package/dist/discrete.test.d.ts +0 -1
- package/dist/discrete.test.js +0 -100
- package/dist/dom.test.d.ts +0 -1
- package/dist/dom.test.js +0 -39
- package/dist/effect-errors.test.d.ts +0 -1
- package/dist/effect-errors.test.js +0 -199
- package/dist/effects.test.d.ts +0 -1
- package/dist/effects.test.js +0 -485
- package/dist/events.test.d.ts +0 -1
- package/dist/events.test.js +0 -447
- package/dist/handler-html.test.d.ts +0 -1
- package/dist/handler-html.test.js +0 -256
- package/dist/handler-routing.test.d.ts +0 -1
- package/dist/handler-routing.test.js +0 -99
- package/dist/handler-segments.test.d.ts +0 -1
- package/dist/handler-segments.test.js +0 -217
- package/dist/head-tags.test.d.ts +0 -1
- package/dist/head-tags.test.js +0 -131
- package/dist/highlight-bind.test.d.ts +0 -1
- package/dist/highlight-bind.test.js +0 -124
- package/dist/highlight.test.d.ts +0 -1
- package/dist/highlight.test.js +0 -56
- package/dist/lanes.test.d.ts +0 -1
- package/dist/lanes.test.js +0 -59
- package/dist/list.test.d.ts +0 -1
- package/dist/list.test.js +0 -435
- package/dist/metadata.test.d.ts +0 -1
- package/dist/metadata.test.js +0 -167
- package/dist/navigation.test.d.ts +0 -1
- package/dist/navigation.test.js +0 -130
- package/dist/node-server.test.d.ts +0 -1
- package/dist/node-server.test.js +0 -492
- package/dist/optimistic-lanes.test.d.ts +0 -1
- package/dist/optimistic-lanes.test.js +0 -45
- package/dist/patterns.test.d.ts +0 -1
- package/dist/patterns.test.js +0 -125
- package/dist/portal.test.d.ts +0 -1
- package/dist/portal.test.js +0 -99
- package/dist/react-effects.test.d.ts +0 -1
- package/dist/react-effects.test.js +0 -133
- package/dist/react-suspense.test.d.ts +0 -1
- package/dist/react-suspense.test.js +0 -194
- package/dist/react.test.d.ts +0 -1
- package/dist/react.test.js +0 -60
- package/dist/react19.test.d.ts +0 -1
- package/dist/react19.test.js +0 -176
- package/dist/reactivity-core.test.d.ts +0 -1
- package/dist/reactivity-core.test.js +0 -152
- package/dist/reconcile.test.d.ts +0 -1
- package/dist/reconcile.test.js +0 -110
- package/dist/refs.test.d.ts +0 -1
- package/dist/refs.test.js +0 -257
- package/dist/router-layout.test.d.ts +0 -1
- package/dist/router-layout.test.js +0 -249
- package/dist/router-nav.test.d.ts +0 -1
- package/dist/router-nav.test.js +0 -559
- package/dist/router-slots.test.d.ts +0 -1
- package/dist/router-slots.test.js +0 -144
- package/dist/router-speculation.test.d.ts +0 -1
- package/dist/router-speculation.test.js +0 -25
- package/dist/router-styles.test.d.ts +0 -1
- package/dist/router-styles.test.js +0 -98
- package/dist/router.test.d.ts +0 -1
- package/dist/router.test.js +0 -36
- package/dist/server-async.test.d.ts +0 -1
- package/dist/server-async.test.js +0 -216
- package/dist/server-handler.test.d.ts +0 -1
- package/dist/server-handler.test.js +0 -535
- package/dist/server-highlight.test.d.ts +0 -1
- package/dist/server-highlight.test.js +0 -32
- package/dist/server-renderer.test.d.ts +0 -1
- package/dist/server-renderer.test.js +0 -266
- package/dist/server.test.d.ts +0 -1
- package/dist/server.test.js +0 -88
- package/dist/sha256.test.d.ts +0 -1
- package/dist/sha256.test.js +0 -13
- package/dist/signal-lanes.test.d.ts +0 -1
- package/dist/signal-lanes.test.js +0 -32
- package/dist/signal.test.d.ts +0 -1
- package/dist/signal.test.js +0 -68
- package/dist/slots.test.d.ts +0 -1
- package/dist/slots.test.js +0 -187
- package/dist/snapshots.test.d.ts +0 -1
- package/dist/snapshots.test.js +0 -208
- package/dist/ssr-core-behavior.test.d.ts +0 -1
- package/dist/ssr-core-behavior.test.js +0 -620
- package/dist/ssr-core.test.d.ts +0 -1
- package/dist/ssr-core.test.js +0 -324
- package/dist/static-memory.test.d.ts +0 -1
- package/dist/static-memory.test.js +0 -26
- package/dist/storage.test.d.ts +0 -1
- package/dist/storage.test.js +0 -46
- package/dist/suspense-actions.test.d.ts +0 -1
- package/dist/suspense-actions.test.js +0 -72
- package/dist/suspense.test.d.ts +0 -1
- package/dist/suspense.test.js +0 -556
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Binary frames for the /__krate/regions response. HTML travels as raw UTF-8
|
|
2
|
+
// bytes, with no JSON string escaping. The Go server asks for them with
|
|
3
|
+
// "Accept: application/vnd.krate.frames"; without it the renderer answers
|
|
4
|
+
// NDJSON as it always has. The format is documented in
|
|
5
|
+
// packages/compiler/internal/regionwire/frame.go.
|
|
6
|
+
export const REGION_FRAMES_TYPE = "application/vnd.krate.frames";
|
|
7
|
+
const TYPES = { region: 1, skip: 2, error: 3, end: 4 };
|
|
8
|
+
const TYPE_NAMES = ["", "region", "skip", "error", "end"];
|
|
9
|
+
const F_NOT_FOUND = 0x01;
|
|
10
|
+
const F_NO_STORE = 0x02;
|
|
11
|
+
const F_ERROR_CAUGHT = 0x04;
|
|
12
|
+
const F_FATAL = 0x08;
|
|
13
|
+
const STRING_FIELDS = ["id", "kind", "cacheStatus", "redirect", "error", "digest", "stack", "title", "head", "html"];
|
|
14
|
+
/** True when the request's Accept header asks for the binary frames. */
|
|
15
|
+
export function wantsRegionFrames(accept) {
|
|
16
|
+
if (!accept)
|
|
17
|
+
return false;
|
|
18
|
+
return (Array.isArray(accept) ? accept.join(",") : accept).includes(REGION_FRAMES_TYPE);
|
|
19
|
+
}
|
|
20
|
+
function uvarintLen(n) {
|
|
21
|
+
let l = 1;
|
|
22
|
+
while (n >= 0x80) {
|
|
23
|
+
n = Math.floor(n / 128);
|
|
24
|
+
l++;
|
|
25
|
+
}
|
|
26
|
+
return l;
|
|
27
|
+
}
|
|
28
|
+
function putUvarint(buf, off, n) {
|
|
29
|
+
while (n >= 0x80) {
|
|
30
|
+
buf[off++] = (n % 128) | 0x80;
|
|
31
|
+
n = Math.floor(n / 128);
|
|
32
|
+
}
|
|
33
|
+
buf[off++] = n;
|
|
34
|
+
return off;
|
|
35
|
+
}
|
|
36
|
+
function num(v) {
|
|
37
|
+
return typeof v === "number" && Number.isFinite(v) && v > 0 ? Math.floor(v) : 0;
|
|
38
|
+
}
|
|
39
|
+
function str(v) {
|
|
40
|
+
if (v === undefined || v === null)
|
|
41
|
+
return "";
|
|
42
|
+
return typeof v === "string" ? v : String(v);
|
|
43
|
+
}
|
|
44
|
+
/** Encodes one frame object (the shape the renderer writes as an NDJSON line). */
|
|
45
|
+
export function encodeFrame(frame) {
|
|
46
|
+
const code = TYPES[frame.type];
|
|
47
|
+
if (!code)
|
|
48
|
+
throw new Error(`unknown frame type ${String(frame.type)}`);
|
|
49
|
+
let flags = 0;
|
|
50
|
+
if (frame.notFound)
|
|
51
|
+
flags |= F_NOT_FOUND;
|
|
52
|
+
if (frame.noStore)
|
|
53
|
+
flags |= F_NO_STORE;
|
|
54
|
+
if (frame.errorCaught)
|
|
55
|
+
flags |= F_ERROR_CAUGHT;
|
|
56
|
+
if (frame.fatal)
|
|
57
|
+
flags |= F_FATAL;
|
|
58
|
+
const status = num(frame.status);
|
|
59
|
+
const denied = num(frame.denied);
|
|
60
|
+
const count = num(frame.count);
|
|
61
|
+
const strs = [];
|
|
62
|
+
const lens = [];
|
|
63
|
+
let size = 2 + uvarintLen(status) + uvarintLen(denied) + uvarintLen(count);
|
|
64
|
+
for (const k of STRING_FIELDS) {
|
|
65
|
+
const s = str(frame[k]);
|
|
66
|
+
const l = s === "" ? 0 : Buffer.byteLength(s, "utf8");
|
|
67
|
+
strs.push(s);
|
|
68
|
+
lens.push(l);
|
|
69
|
+
size += uvarintLen(l) + l;
|
|
70
|
+
}
|
|
71
|
+
const buf = Buffer.allocUnsafe(4 + size);
|
|
72
|
+
buf.writeUInt32BE(size, 0);
|
|
73
|
+
buf[4] = code;
|
|
74
|
+
buf[5] = flags;
|
|
75
|
+
let off = putUvarint(buf, 6, status);
|
|
76
|
+
off = putUvarint(buf, off, denied);
|
|
77
|
+
off = putUvarint(buf, off, count);
|
|
78
|
+
for (let i = 0; i < strs.length; i++) {
|
|
79
|
+
off = putUvarint(buf, off, lens[i]);
|
|
80
|
+
if (lens[i] > 0)
|
|
81
|
+
off += buf.write(strs[i], off, lens[i], "utf8");
|
|
82
|
+
}
|
|
83
|
+
return buf;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Decodes a whole response body of frames. The sidecar never reads frames; the
|
|
87
|
+
* tests and tooling do. A truncated or corrupt stream throws.
|
|
88
|
+
*/
|
|
89
|
+
export function decodeFrames(data) {
|
|
90
|
+
const buf = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
91
|
+
const out = [];
|
|
92
|
+
let pos = 0;
|
|
93
|
+
while (pos < buf.length) {
|
|
94
|
+
if (buf.length - pos < 4)
|
|
95
|
+
throw new Error("truncated frame length");
|
|
96
|
+
const n = buf.readUInt32BE(pos);
|
|
97
|
+
pos += 4;
|
|
98
|
+
if (n < 2 || n > buf.length - pos)
|
|
99
|
+
throw new Error("truncated or corrupt frame");
|
|
100
|
+
out.push(decodeBody(buf.subarray(pos, pos + n)));
|
|
101
|
+
pos += n;
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function decodeBody(b) {
|
|
106
|
+
let off = 2;
|
|
107
|
+
const uvarint = () => {
|
|
108
|
+
let x = 0;
|
|
109
|
+
let mul = 1;
|
|
110
|
+
for (let i = 0; i < 6; i++) {
|
|
111
|
+
if (off >= b.length)
|
|
112
|
+
throw new Error("corrupt frame");
|
|
113
|
+
const c = b[off++];
|
|
114
|
+
x += (c & 0x7F) * mul;
|
|
115
|
+
if (c < 0x80)
|
|
116
|
+
return x;
|
|
117
|
+
mul *= 128;
|
|
118
|
+
}
|
|
119
|
+
throw new Error("corrupt frame");
|
|
120
|
+
};
|
|
121
|
+
const type = TYPE_NAMES[b[0]];
|
|
122
|
+
if (!type)
|
|
123
|
+
throw new Error("corrupt frame: unknown type");
|
|
124
|
+
const flags = b[1];
|
|
125
|
+
const frame = { type };
|
|
126
|
+
const status = uvarint();
|
|
127
|
+
const denied = uvarint();
|
|
128
|
+
const count = uvarint();
|
|
129
|
+
if (status)
|
|
130
|
+
frame.status = status;
|
|
131
|
+
if (denied)
|
|
132
|
+
frame.denied = denied;
|
|
133
|
+
if (count)
|
|
134
|
+
frame.count = count;
|
|
135
|
+
for (const k of STRING_FIELDS) {
|
|
136
|
+
const l = uvarint();
|
|
137
|
+
if (l > b.length - off)
|
|
138
|
+
throw new Error("corrupt frame");
|
|
139
|
+
if (l > 0)
|
|
140
|
+
frame[k] = b.toString("utf8", off, off + l);
|
|
141
|
+
off += l;
|
|
142
|
+
}
|
|
143
|
+
if (off !== b.length)
|
|
144
|
+
throw new Error("corrupt frame: trailing bytes");
|
|
145
|
+
if (flags & F_NOT_FOUND)
|
|
146
|
+
frame.notFound = true;
|
|
147
|
+
if (flags & F_NO_STORE)
|
|
148
|
+
frame.noStore = true;
|
|
149
|
+
if (flags & F_ERROR_CAUGHT)
|
|
150
|
+
frame.errorCaught = true;
|
|
151
|
+
if (flags & F_FATAL)
|
|
152
|
+
frame.fatal = true;
|
|
153
|
+
return frame;
|
|
154
|
+
}
|
package/dist/request-context.js
CHANGED
|
@@ -54,7 +54,7 @@ export function thenable(value, resolved) {
|
|
|
54
54
|
}
|
|
55
55
|
/** thenableRecord wraps a plain record (route params, search params). */
|
|
56
56
|
export function thenableRecord(rec) {
|
|
57
|
-
const plain = { ...
|
|
57
|
+
const plain = { ...rec };
|
|
58
58
|
return thenable({ ...plain }, () => ({ ...plain }));
|
|
59
59
|
}
|
|
60
60
|
export function requestCookies(jar) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function requestCookiesOf(headers: Headers): Map<string, string>;
|
|
2
|
+
export declare function attachCookies(request: Request, basePath?: string): Request;
|
|
3
|
+
/** A URL carrying Next's NextURL extras: basePath (pathname never includes it) and clone(). */
|
|
4
|
+
export declare function makeNextUrl(href: string, basePath: string): URL;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Next's request extras on a route handler's Request: a read-only
|
|
2
|
+
// request.cookies and request.nextUrl. Shared by the server handler and
|
|
3
|
+
// @krate/runtime/testing so tests see what the server passes.
|
|
4
|
+
export function requestCookiesOf(headers) {
|
|
5
|
+
const jar = new Map();
|
|
6
|
+
for (const part of String(headers.get("cookie") || "").split(";")) {
|
|
7
|
+
const i = part.indexOf("=");
|
|
8
|
+
if (i <= 0)
|
|
9
|
+
continue;
|
|
10
|
+
const name = part.slice(0, i).trim();
|
|
11
|
+
if (!name || jar.has(name))
|
|
12
|
+
continue;
|
|
13
|
+
// Same parsing as the action context and the Node sidecar: unquote, then percent-decode.
|
|
14
|
+
let value = part.slice(i + 1).trim();
|
|
15
|
+
if (value.startsWith('"') && value.endsWith('"'))
|
|
16
|
+
value = value.slice(1, -1);
|
|
17
|
+
try {
|
|
18
|
+
value = decodeURIComponent(value);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// keep the raw value
|
|
22
|
+
}
|
|
23
|
+
jar.set(name, value);
|
|
24
|
+
}
|
|
25
|
+
return jar;
|
|
26
|
+
}
|
|
27
|
+
export function attachCookies(request, basePath = "") {
|
|
28
|
+
try {
|
|
29
|
+
const jar = requestCookiesOf(request.headers);
|
|
30
|
+
Object.defineProperty(request, "cookies", {
|
|
31
|
+
value: {
|
|
32
|
+
get: (n) => (jar.has(String(n)) ? { name: String(n), value: jar.get(String(n)) } : undefined),
|
|
33
|
+
getAll: (n) => [...jar].filter(([k]) => n === undefined || k === String(n)).map(([name, value]) => ({ name, value })),
|
|
34
|
+
has: (n) => jar.has(String(n)),
|
|
35
|
+
},
|
|
36
|
+
enumerable: false,
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(request, "nextUrl", { value: makeNextUrl(request.url, basePath), enumerable: false });
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// frozen request objects keep working without the cookies accessor
|
|
42
|
+
}
|
|
43
|
+
return request;
|
|
44
|
+
}
|
|
45
|
+
/** A URL carrying Next's NextURL extras: basePath (pathname never includes it) and clone(). */
|
|
46
|
+
export function makeNextUrl(href, basePath) {
|
|
47
|
+
const u = new URL(href);
|
|
48
|
+
Object.defineProperty(u, "basePath", { value: basePath, enumerable: false });
|
|
49
|
+
Object.defineProperty(u, "clone", { value: () => makeNextUrl(u.href, basePath), enumerable: false });
|
|
50
|
+
return u;
|
|
51
|
+
}
|
package/dist/resp.js
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type SourceKind = "redirect" | "rewrite" | "header";
|
|
2
|
+
export interface RouteCondition {
|
|
3
|
+
type: "query" | "header" | "cookie" | "host" | string;
|
|
4
|
+
key?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface MatchResult {
|
|
8
|
+
params: Record<string, string>;
|
|
9
|
+
mods: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export interface CompiledSource {
|
|
12
|
+
match(path: string): MatchResult | null;
|
|
13
|
+
}
|
|
14
|
+
/** Compiles a source. It throws when the source cannot be matched. */
|
|
15
|
+
export declare function compileSource(source: string, kind: SourceKind): CompiledSource;
|
|
16
|
+
export interface CondRequest {
|
|
17
|
+
headers: Headers;
|
|
18
|
+
url: URL;
|
|
19
|
+
}
|
|
20
|
+
export interface Conditions {
|
|
21
|
+
match(req: CondRequest): Record<string, string> | null;
|
|
22
|
+
}
|
|
23
|
+
/** Compiles has/missing; null when there are none. It throws on an invalid item. */
|
|
24
|
+
export declare function compileConditions(has?: RouteCondition[], missing?: RouteCondition[]): Conditions | null;
|
|
25
|
+
/** A compiled rule: source plus conditions. */
|
|
26
|
+
export interface RouteMatcher {
|
|
27
|
+
match(path: string, req: CondRequest): MatchResult | null;
|
|
28
|
+
}
|
|
29
|
+
export declare function compileMatcher(source: string, kind: SourceKind, has?: RouteCondition[], missing?: RouteCondition[]): RouteMatcher;
|
|
30
|
+
/** url.PathEscape of Go: segment-escapes everything but unreserved and $&+=:@. */
|
|
31
|
+
export declare function pathEscape(s: string): string;
|
|
32
|
+
/** Percent-encodes a matched (decoded) value segment by segment, keeping "/" between segments. */
|
|
33
|
+
export declare function escapeRedirectValue(v: string): string;
|
|
34
|
+
/** Keeps a substituted path destination on-site (no "//host" or "/\\host" results). */
|
|
35
|
+
export declare function sanitizeRedirectTarget(configured: string, out: string): string;
|
|
36
|
+
/** Fills ":splat" and ":name" placeholders of a destination from a match. */
|
|
37
|
+
export declare function buildDestination(destination: string, m: MatchResult): string;
|
|
38
|
+
/** Adds the request's query to the destination's own; the destination's keys win. */
|
|
39
|
+
export declare function mergeRequestQuery(dest: string, rawQuery: string): string;
|