@krate/runtime 0.5.0-rc.13 → 0.5.0-rc.15
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.d.ts +2 -0
- package/dist/action-context.js +12 -1
- package/dist/action-seal.d.ts +5 -0
- package/dist/action-seal.js +105 -0
- package/dist/actions.js +7 -1
- package/dist/cache-scope.d.ts +2 -0
- package/dist/dev/api.d.ts +93 -0
- package/dist/dev/api.js +2 -0
- package/dist/dev/app.d.ts +165 -0
- package/dist/dev/app.js +1204 -0
- package/dist/dev/commands.d.ts +49 -0
- package/dist/dev/commands.js +114 -0
- package/dist/dev/highlight.d.ts +4 -0
- package/dist/dev/highlight.js +126 -0
- package/dist/dev/icons.d.ts +4 -0
- package/dist/dev/icons.js +57 -0
- package/dist/dev/inspect.d.ts +55 -0
- package/dist/dev/inspect.js +256 -0
- package/dist/dev/inspector.d.ts +39 -0
- package/dist/dev/inspector.js +348 -0
- package/dist/dev/issues.d.ts +83 -0
- package/dist/dev/issues.js +166 -0
- package/dist/dev/modal.d.ts +16 -0
- package/dist/dev/modal.js +836 -0
- package/dist/dev/native.d.ts +53 -0
- package/dist/dev/native.js +95 -0
- package/dist/dev/palette.d.ts +9 -0
- package/dist/dev/palette.js +250 -0
- package/dist/dev/panel.d.ts +31 -0
- package/dist/dev/panel.js +848 -0
- package/dist/dev/requests.d.ts +36 -0
- package/dist/dev/requests.js +150 -0
- package/dist/dev/settings.d.ts +32 -0
- package/dist/dev/settings.js +78 -0
- package/dist/dev/sourcemap.d.ts +22 -0
- package/dist/dev/sourcemap.js +148 -0
- package/dist/dev/stack.d.ts +38 -0
- package/dist/dev/stack.js +115 -0
- package/dist/dev/styles.d.ts +1 -0
- package/dist/dev/styles.js +424 -0
- package/dist/dev/util.d.ts +63 -0
- package/dist/dev/util.js +190 -0
- package/dist/dev-overlay.d.ts +9 -83
- package/dist/dev-overlay.js +17 -1038
- package/dist/flight-props.d.ts +2 -0
- package/dist/flight-props.js +12 -1
- package/dist/handler-routing.js +7 -1
- package/dist/island-swap.js +10 -1
- package/dist/krate-core.js +1 -1
- package/dist/krate-dev.js +441 -871
- package/dist/krate-f-actions.js +1 -1
- package/dist/krate-f-list.js +1 -1
- package/dist/krate-f-navigation.js +1 -1
- package/dist/krate-f-router.js +1 -1
- package/dist/krate-hydrate-lite.js +5 -5
- package/dist/krate-hydrate.js +5 -5
- package/dist/krate-island-swap.js +1 -1
- package/dist/krate-runtime.js +5 -5
- package/dist/list.js +23 -1
- package/dist/metadata.js +23 -12
- package/dist/navigation-server.d.ts +1 -2
- package/dist/navigation-server.js +1 -2
- package/dist/navigation.d.ts +1 -1
- package/dist/navigation.js +7 -2
- package/dist/process-guard.d.ts +23 -0
- package/dist/process-guard.js +45 -0
- package/dist/react-types.d.ts +29 -0
- package/dist/react-types.js +1 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +3 -0
- package/dist/request-context.d.ts +15 -0
- package/dist/request-context.js +41 -0
- package/dist/router.js +17 -0
- package/dist/server-handler.d.ts +4 -0
- package/dist/server-handler.js +43 -8
- package/dist/server-renderer.js +94 -2
- package/dist/server.d.ts +1 -1
- package/dist/server.js +57 -11
- package/dist/signal.d.ts +8 -0
- package/dist/signal.js +4 -0
- package/dist/ssr-core.d.ts +5 -0
- package/dist/ssr-core.js +49 -7
- package/package.json +5 -1
package/dist/action-context.d.ts
CHANGED
|
@@ -58,3 +58,5 @@ export declare function cookies(): ActionCookies;
|
|
|
58
58
|
* `{ redirect: url }` from the action has the same effect.
|
|
59
59
|
*/
|
|
60
60
|
export declare function redirect(url: string): never;
|
|
61
|
+
/** redirect() that a page or API route answers with 308 instead of 307 (a server action still navigates the client). */
|
|
62
|
+
export declare function permanentRedirect(url: string): never;
|
package/dist/action-context.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* read that scope, so they only work while a server action is executing.
|
|
7
7
|
*/
|
|
8
8
|
import { markNoStore } from './cache-scope.js';
|
|
9
|
-
import { getRequestContext, requestCookies, thenable } from './request-context.js';
|
|
9
|
+
import { dynamicUsageError, getRequestContext, requestCookies, thenable } from './request-context.js';
|
|
10
10
|
/** The current action context, or undefined outside a server action. */
|
|
11
11
|
export function getActionContext() {
|
|
12
12
|
const store = globalThis[Symbol.for('krate.action.store')];
|
|
@@ -55,6 +55,8 @@ export function headers() {
|
|
|
55
55
|
return awaitableHeaders(action.headers);
|
|
56
56
|
const req = getRequestContext();
|
|
57
57
|
if (req) {
|
|
58
|
+
if (req.prerender)
|
|
59
|
+
throw dynamicUsageError('headers()');
|
|
58
60
|
markNoStore();
|
|
59
61
|
return awaitableHeaders(req.headers);
|
|
60
62
|
}
|
|
@@ -71,6 +73,8 @@ export function cookies() {
|
|
|
71
73
|
return awaitableActionCookies(action.cookies);
|
|
72
74
|
const req = getRequestContext();
|
|
73
75
|
if (req) {
|
|
76
|
+
if (req.prerender)
|
|
77
|
+
throw dynamicUsageError('cookies()');
|
|
74
78
|
markNoStore();
|
|
75
79
|
return requestCookies(req.cookies);
|
|
76
80
|
}
|
|
@@ -101,3 +105,10 @@ export function redirect(url) {
|
|
|
101
105
|
err.__krateRedirect = url;
|
|
102
106
|
throw err;
|
|
103
107
|
}
|
|
108
|
+
/** redirect() that a page or API route answers with 308 instead of 307 (a server action still navigates the client). */
|
|
109
|
+
export function permanentRedirect(url) {
|
|
110
|
+
const err = new Error('Server action redirect to ' + url);
|
|
111
|
+
err.__krateRedirect = url;
|
|
112
|
+
err.__krateRedirectStatus = 308;
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Seals the arguments a server action was bound to with .bind() when the action
|
|
2
|
+
// crosses into a client component, in the format of the closure tokens of inline
|
|
3
|
+
// server actions (compiler/internal/build/inline_actions.go): AES-256-GCM, the
|
|
4
|
+
// action id as associated data, a "k1." prefix. The server action endpoint opens
|
|
5
|
+
// the token and puts the values in front of the client's own arguments, so the
|
|
6
|
+
// browser never sees or sends them.
|
|
7
|
+
const MAX_URL_TOKEN = 3500;
|
|
8
|
+
function builtin(name) {
|
|
9
|
+
const get = globalThis.process?.getBuiltinModule;
|
|
10
|
+
if (typeof get !== 'function') {
|
|
11
|
+
throw new Error('sealing bound server action arguments needs Node.js (process.getBuiltinModule)');
|
|
12
|
+
}
|
|
13
|
+
return get(name);
|
|
14
|
+
}
|
|
15
|
+
function actionSecret() {
|
|
16
|
+
const proc = globalThis.process;
|
|
17
|
+
let secret = proc?.env?.KRATE_ACTION_SECRET || '';
|
|
18
|
+
if (!secret && !globalThis[Symbol.for('krate.action.deployed')]) {
|
|
19
|
+
const fs = builtin('node:fs');
|
|
20
|
+
const path = builtin('node:path');
|
|
21
|
+
const dir = proc?.env?.KRATE_ACTION_DIR || path.join(proc?.env?.KRATE_ROOT || proc?.cwd?.() || '.', '.krate', 'actions');
|
|
22
|
+
try {
|
|
23
|
+
secret = JSON.parse(fs.readFileSync(path.join(dir, 'manifest.json'), 'utf8')).key || '';
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
secret = '';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!secret) {
|
|
30
|
+
throw new Error('bound server action arguments need an encryption key: set KRATE_ACTION_SECRET, or run the server from a build whose .krate/actions/manifest.json holds one');
|
|
31
|
+
}
|
|
32
|
+
return secret;
|
|
33
|
+
}
|
|
34
|
+
function describe(v) {
|
|
35
|
+
if (typeof v === 'function')
|
|
36
|
+
return 'a function';
|
|
37
|
+
if (typeof v === 'symbol')
|
|
38
|
+
return 'a symbol';
|
|
39
|
+
if (typeof v === 'number')
|
|
40
|
+
return 'the number ' + v;
|
|
41
|
+
if (v && typeof v.then === 'function')
|
|
42
|
+
return 'a Promise (await it before binding it)';
|
|
43
|
+
const proto = v && Object.getPrototypeOf(v);
|
|
44
|
+
return proto && proto.constructor && proto.constructor.name ? 'a ' + proto.constructor.name + ' instance' : 'a non-plain object';
|
|
45
|
+
}
|
|
46
|
+
function encode(v, where, seen) {
|
|
47
|
+
if (v === null || typeof v === 'string' || typeof v === 'boolean')
|
|
48
|
+
return v;
|
|
49
|
+
if (typeof v === 'number') {
|
|
50
|
+
if (!Number.isFinite(v))
|
|
51
|
+
throw new TypeError(where + ', which is ' + describe(v));
|
|
52
|
+
return v;
|
|
53
|
+
}
|
|
54
|
+
if (v === undefined)
|
|
55
|
+
return { $: 'u' };
|
|
56
|
+
if (typeof v === 'bigint')
|
|
57
|
+
return { $: 'n', v: v.toString() };
|
|
58
|
+
if (v instanceof Date)
|
|
59
|
+
return { $: 'd', v: v.toISOString() };
|
|
60
|
+
if (typeof v === 'function' || typeof v === 'symbol')
|
|
61
|
+
throw new TypeError(where + ', which is ' + describe(v));
|
|
62
|
+
if (seen.has(v))
|
|
63
|
+
throw new TypeError(where + ', which is circular');
|
|
64
|
+
seen.add(v);
|
|
65
|
+
try {
|
|
66
|
+
if (Array.isArray(v))
|
|
67
|
+
return v.map((x, i) => encode(x, where + '[' + i + ']', seen));
|
|
68
|
+
const proto = Object.getPrototypeOf(v);
|
|
69
|
+
if (proto !== Object.prototype && proto !== null)
|
|
70
|
+
throw new TypeError(where + ', which is ' + describe(v));
|
|
71
|
+
const out = {};
|
|
72
|
+
for (const k of Object.keys(v))
|
|
73
|
+
out[k] = encode(v[k], where + '.' + k, seen);
|
|
74
|
+
return Object.prototype.hasOwnProperty.call(out, '$') ? { $: 'o', v: out } : out;
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
seen.delete(v);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the sealed token for the values `action.bind(null, ...values)` fixed.
|
|
82
|
+
* `path` names the prop for error messages (`props.action`).
|
|
83
|
+
*/
|
|
84
|
+
export function sealBoundArgs(id, values, path) {
|
|
85
|
+
const encoded = values.map((v, i) => {
|
|
86
|
+
try {
|
|
87
|
+
return encode(v, `argument ${i + 1}`, new Set());
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
throw new TypeError(`Prop \`${path}\` is a server action bound to a value that cannot be sent to a client component: ${e.message}. ` +
|
|
91
|
+
'Only strings, numbers, booleans, null, undefined, bigint, Date, and plain objects and arrays of those can be bound; read anything else inside the action.');
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const crypto = builtin('node:crypto');
|
|
95
|
+
const key = crypto.createHash('sha256').update('krate-inline-action\0' + actionSecret()).digest();
|
|
96
|
+
const iv = crypto.randomBytes(12);
|
|
97
|
+
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
|
|
98
|
+
cipher.setAAD(Buffer.from(id));
|
|
99
|
+
const body = Buffer.concat([cipher.update(JSON.stringify(encoded), 'utf8'), cipher.final()]);
|
|
100
|
+
const token = 'k1.' + Buffer.concat([iv, body, cipher.getAuthTag()]).toString('base64url');
|
|
101
|
+
if (token.length > MAX_URL_TOKEN) {
|
|
102
|
+
throw new RangeError(`Prop \`${path}\` is a server action bound to ${token.length} bytes of data; bind ids and look the rest up inside the action`);
|
|
103
|
+
}
|
|
104
|
+
return token;
|
|
105
|
+
}
|
package/dist/actions.js
CHANGED
|
@@ -413,9 +413,15 @@ export function stripActionURL(url) {
|
|
|
413
413
|
try {
|
|
414
414
|
const raw = new URLSearchParams(url.slice(i + 1)).get(ACTION_ARGS_FIELD);
|
|
415
415
|
const leading = raw ? JSON.parse(raw) : null;
|
|
416
|
+
const bound = new URLSearchParams(url.slice(i + 1)).get('__krate_bound');
|
|
417
|
+
const keep = [];
|
|
416
418
|
if (Array.isArray(leading) && typeof leading[0] === 'string' && leading[0].startsWith('k1.')) {
|
|
417
|
-
|
|
419
|
+
keep.push(ACTION_ARGS_FIELD + '=' + encodeURIComponent(JSON.stringify([leading[0]])));
|
|
418
420
|
}
|
|
421
|
+
if (bound && bound.startsWith('k1.'))
|
|
422
|
+
keep.push('__krate_bound=' + encodeURIComponent(bound));
|
|
423
|
+
if (keep.length > 0)
|
|
424
|
+
return base + '?' + keep.join('&');
|
|
419
425
|
}
|
|
420
426
|
catch {
|
|
421
427
|
// not a token: strip like any native query
|
package/dist/cache-scope.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export interface CacheScope {
|
|
|
32
32
|
errorCaught?: boolean;
|
|
33
33
|
/** Head tags the render asked for (react-dom preload, preconnect, ...), deduplicated. */
|
|
34
34
|
hints?: Set<string>;
|
|
35
|
+
/** Islands rendered so far, by module and export: the next one's occurrence number (see islandIdPrefix). */
|
|
36
|
+
islands?: Map<string, number>;
|
|
35
37
|
}
|
|
36
38
|
/** Minimal AsyncLocalStorage shape (the Node class satisfies it). */
|
|
37
39
|
export interface AsyncStore<T> {
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export interface BuildPhase {
|
|
2
|
+
name: string;
|
|
3
|
+
ms: number;
|
|
4
|
+
}
|
|
5
|
+
export interface BuildRecord {
|
|
6
|
+
id: number;
|
|
7
|
+
start: number;
|
|
8
|
+
durationMs: number;
|
|
9
|
+
kind: string;
|
|
10
|
+
files: string[];
|
|
11
|
+
routes: string[];
|
|
12
|
+
pages: number;
|
|
13
|
+
ok: boolean;
|
|
14
|
+
diagnostics: number;
|
|
15
|
+
phases?: BuildPhase[];
|
|
16
|
+
}
|
|
17
|
+
export interface ActivityData {
|
|
18
|
+
builds: BuildRecord[];
|
|
19
|
+
lastGoodAt?: number;
|
|
20
|
+
building?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface DevInfo {
|
|
23
|
+
version?: string;
|
|
24
|
+
startedAt?: number;
|
|
25
|
+
logFile?: string;
|
|
26
|
+
docsURL?: string;
|
|
27
|
+
editor?: {
|
|
28
|
+
configured?: string;
|
|
29
|
+
available?: {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
}[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface RouteData {
|
|
36
|
+
path?: string;
|
|
37
|
+
pattern: string;
|
|
38
|
+
source?: string;
|
|
39
|
+
mode?: string;
|
|
40
|
+
revalidate?: number;
|
|
41
|
+
params?: Record<string, string>;
|
|
42
|
+
dynamic?: boolean;
|
|
43
|
+
staticPaths?: number;
|
|
44
|
+
layouts?: string[];
|
|
45
|
+
sizes?: {
|
|
46
|
+
html?: number;
|
|
47
|
+
js?: number;
|
|
48
|
+
css?: number;
|
|
49
|
+
gzipHtml?: number;
|
|
50
|
+
gzipJs?: number;
|
|
51
|
+
gzipCss?: number;
|
|
52
|
+
gzipRuntime?: number;
|
|
53
|
+
gzipIslands?: number;
|
|
54
|
+
};
|
|
55
|
+
islands?: {
|
|
56
|
+
id: string;
|
|
57
|
+
chunk: string;
|
|
58
|
+
gzip: number;
|
|
59
|
+
}[];
|
|
60
|
+
budget?: {
|
|
61
|
+
js?: number;
|
|
62
|
+
hydration?: number;
|
|
63
|
+
islandJS?: number;
|
|
64
|
+
route?: number;
|
|
65
|
+
};
|
|
66
|
+
/** The page as checks.budget measures it (raw bytes), to compare with budget. */
|
|
67
|
+
budgetUsage?: {
|
|
68
|
+
js?: number;
|
|
69
|
+
hydration?: number;
|
|
70
|
+
islandJS?: number;
|
|
71
|
+
route?: number;
|
|
72
|
+
};
|
|
73
|
+
builtAt?: number;
|
|
74
|
+
document?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface LogLine {
|
|
77
|
+
seq: number;
|
|
78
|
+
t: number;
|
|
79
|
+
src: string;
|
|
80
|
+
lvl: 'info' | 'warn' | 'error';
|
|
81
|
+
text: string;
|
|
82
|
+
/** Captured in this tab rather than by the dev server. */
|
|
83
|
+
local?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export interface FixChange {
|
|
86
|
+
file: string;
|
|
87
|
+
line: number;
|
|
88
|
+
col: number;
|
|
89
|
+
code: string;
|
|
90
|
+
from: string;
|
|
91
|
+
to: string;
|
|
92
|
+
}
|
|
93
|
+
export declare const DEFAULT_DOCS_URL = "https://krate.js.org/docs/reference/diagnostics/#";
|
package/dist/dev/api.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { type BuildRecord, type DevInfo, type FixChange, type LogLine, type RouteData } from './api.js';
|
|
2
|
+
import type { RouteInfo } from './commands.js';
|
|
3
|
+
import { type CodeFrame, type DevClientError, type DevDiagnostic, type Issue } from './issues.js';
|
|
4
|
+
import { RequestLog } from './requests.js';
|
|
5
|
+
import { type Settings } from './settings.js';
|
|
6
|
+
import { type ResolvedConfig } from './util.js';
|
|
7
|
+
import { type Tab } from './panel.js';
|
|
8
|
+
import { Inspector } from './inspector.js';
|
|
9
|
+
export declare class KrateDev {
|
|
10
|
+
cfg: ResolvedConfig;
|
|
11
|
+
settings: Settings;
|
|
12
|
+
host: HTMLElement;
|
|
13
|
+
shadow: ShadowRoot;
|
|
14
|
+
root: HTMLElement;
|
|
15
|
+
dock?: HTMLElement;
|
|
16
|
+
panel?: HTMLElement;
|
|
17
|
+
toastEl?: HTMLElement;
|
|
18
|
+
modal?: HTMLElement;
|
|
19
|
+
pal?: HTMLElement;
|
|
20
|
+
inspector: Inspector;
|
|
21
|
+
conn: 'connecting' | 'open' | 'down';
|
|
22
|
+
building: boolean;
|
|
23
|
+
buildFiles: string[];
|
|
24
|
+
lastBuild?: BuildRecord;
|
|
25
|
+
lastGoodAt?: number;
|
|
26
|
+
builds: BuildRecord[];
|
|
27
|
+
activity: 'unknown' | 'ok' | 'missing';
|
|
28
|
+
info?: DevInfo | null;
|
|
29
|
+
route?: RouteData | null;
|
|
30
|
+
routeFor: string;
|
|
31
|
+
routes?: RouteInfo[] | null;
|
|
32
|
+
issues: Issue[];
|
|
33
|
+
ignored: Set<string>;
|
|
34
|
+
cur: number;
|
|
35
|
+
modalOpen: boolean;
|
|
36
|
+
seen: Set<string>;
|
|
37
|
+
frames: Map<string, CodeFrame | null>;
|
|
38
|
+
/** Log lines around a server crash, with their source and time. */
|
|
39
|
+
tails: Map<string, LogLine[]>;
|
|
40
|
+
fixes: Map<string, FixChange[] | null>;
|
|
41
|
+
busy: Set<string>;
|
|
42
|
+
runtimeTab: 'stack' | 'console' | 'requests';
|
|
43
|
+
/** Failed fetch/XHR requests of the page, for the runtime error's Request tab. */
|
|
44
|
+
requests: RequestLog;
|
|
45
|
+
/**
|
|
46
|
+
* The build failed and the error overlay was dismissed with "Show last good
|
|
47
|
+
* page": the page on screen is the last good build until a build passes.
|
|
48
|
+
*/
|
|
49
|
+
staleView: boolean;
|
|
50
|
+
/** Registry entries of diagnostic codes (null: unknown), from /code. */
|
|
51
|
+
codes: Map<string, {
|
|
52
|
+
title: string;
|
|
53
|
+
explanation: string;
|
|
54
|
+
} | null>;
|
|
55
|
+
/** The code whose "What this means" popover is open. */
|
|
56
|
+
codePop: string;
|
|
57
|
+
unfold: Set<string>;
|
|
58
|
+
panelOpen: boolean;
|
|
59
|
+
tab: Tab;
|
|
60
|
+
hiddenAll: boolean;
|
|
61
|
+
peek: boolean;
|
|
62
|
+
serverLogs: LogLine[];
|
|
63
|
+
localLogs: LogLine[];
|
|
64
|
+
logSeq: number;
|
|
65
|
+
logsMissing: boolean;
|
|
66
|
+
logFilter: 'all' | 'server' | 'api' | 'browser';
|
|
67
|
+
logQuery: string;
|
|
68
|
+
errorsOnly: boolean;
|
|
69
|
+
logsClearedAt: number;
|
|
70
|
+
logsSeenAt: number;
|
|
71
|
+
logOpen: Set<string>;
|
|
72
|
+
localSeq: number;
|
|
73
|
+
hostSeq: number;
|
|
74
|
+
hostRows: string[];
|
|
75
|
+
timers: number[];
|
|
76
|
+
/** Undo functions for listeners outside the shadow root (destroy). */
|
|
77
|
+
private unbind;
|
|
78
|
+
sse?: EventSource;
|
|
79
|
+
private toastTimer?;
|
|
80
|
+
private restoreFocus?;
|
|
81
|
+
private suppressClick;
|
|
82
|
+
init(): void;
|
|
83
|
+
/** Stops timers and removes the overlay (tests). */
|
|
84
|
+
private listen;
|
|
85
|
+
destroy(): void;
|
|
86
|
+
applySettings(): void;
|
|
87
|
+
setSettings(patch: Partial<Settings>): void;
|
|
88
|
+
apiURL(path: string, params?: Record<string, string | number | undefined>): string;
|
|
89
|
+
/** GETs a dev endpoint; null when the host has no such endpoint or it fails. */
|
|
90
|
+
getJSON<T>(path: string, params?: Record<string, string | number | undefined>): Promise<T | null>;
|
|
91
|
+
postJSON(path: string, body: unknown): Promise<{
|
|
92
|
+
status: number;
|
|
93
|
+
data: any;
|
|
94
|
+
}>;
|
|
95
|
+
loadStartup(): Promise<void>;
|
|
96
|
+
loadRoute(force?: boolean): Promise<void>;
|
|
97
|
+
loadRoutes(): Promise<RouteInfo[] | null>;
|
|
98
|
+
/** The route pattern and mode of the page on screen. */
|
|
99
|
+
pageRoute(): {
|
|
100
|
+
route: string;
|
|
101
|
+
mode: string;
|
|
102
|
+
source?: string;
|
|
103
|
+
};
|
|
104
|
+
openInEditor(file: string | undefined, line?: number | string, col?: number | string): Promise<void>;
|
|
105
|
+
runAction(action: string, extra?: Record<string, unknown>): Promise<boolean>;
|
|
106
|
+
renderDock(): void;
|
|
107
|
+
setPeek(on: boolean): void;
|
|
108
|
+
private initDrag;
|
|
109
|
+
togglePanel(tab?: Tab, force?: boolean): void;
|
|
110
|
+
setTab(tab: Tab): void;
|
|
111
|
+
visibleIssues(): Issue[];
|
|
112
|
+
openModal(): void;
|
|
113
|
+
closeModal(): void;
|
|
114
|
+
/** Re-renders whatever shows issues after the list changed. */
|
|
115
|
+
issuesChanged(open: boolean): void;
|
|
116
|
+
ignore(id: string): void;
|
|
117
|
+
toggleHidden(): void;
|
|
118
|
+
toast(text: string, meta?: string, kind?: 'check' | 'x'): void;
|
|
119
|
+
private onClick;
|
|
120
|
+
private onInput;
|
|
121
|
+
private onKey;
|
|
122
|
+
/** Keep the dock route label in sync with SPA (history) navigation. */
|
|
123
|
+
private watchLocation;
|
|
124
|
+
private setConn;
|
|
125
|
+
private connectSSE;
|
|
126
|
+
/**
|
|
127
|
+
* Krate Native: the same events as SSE, as `{hmr: {type, ...}}` frames on a
|
|
128
|
+
* streaming fetch. Reconnects after the stream ends; a second "connected"
|
|
129
|
+
* means the shell restarted, so the page is stale.
|
|
130
|
+
*/
|
|
131
|
+
private connectFrames;
|
|
132
|
+
onBuildStart(d: any): void;
|
|
133
|
+
onBuildEnd(d: any): void;
|
|
134
|
+
onReload(d: any): void;
|
|
135
|
+
onBuildError(d: any): void;
|
|
136
|
+
/** The warnings of the latest build (build-end, build-warnings). */
|
|
137
|
+
onBuildWarnings(d: any): void;
|
|
138
|
+
setWarnings(list: DevDiagnostic[]): void;
|
|
139
|
+
/** Replaces every build issue (errors and warnings), keeping the times of those already on screen. */
|
|
140
|
+
private replaceBuildIssues;
|
|
141
|
+
/** "Show last good page": the overlay closes and the dock says what is on screen. */
|
|
142
|
+
showLastGood(): void;
|
|
143
|
+
onClientError(d: {
|
|
144
|
+
clientError?: DevClientError;
|
|
145
|
+
} | null): void;
|
|
146
|
+
/**
|
|
147
|
+
* Apply a CSS-only rebuild without a full reload: fetch the freshly built
|
|
148
|
+
* document, add its stylesheet links, and drop the ones it no longer has.
|
|
149
|
+
* Inline <style> changes cannot be diffed safely, so they fall back to a
|
|
150
|
+
* reload (the caller reloads when this rejects).
|
|
151
|
+
*/
|
|
152
|
+
swapStylesheets(): Promise<void>;
|
|
153
|
+
private captureRuntimeErrors;
|
|
154
|
+
private captureConsole;
|
|
155
|
+
localLog(lvl: LogLine['lvl'], text: string): void;
|
|
156
|
+
private onConsole;
|
|
157
|
+
private onResourceError;
|
|
158
|
+
private onError;
|
|
159
|
+
private onRejection;
|
|
160
|
+
private report;
|
|
161
|
+
private send;
|
|
162
|
+
addRuntime(origin: NonNullable<Issue['origin']>, message: string, stack?: string, hostStack?: string): void;
|
|
163
|
+
docsURL(code: string): string;
|
|
164
|
+
logFile(): string;
|
|
165
|
+
}
|