@krate/runtime 0.5.0-rc.14 → 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.js +5 -1
- 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/island-swap.js +7 -1
- package/dist/krate-core.js +1 -1
- package/dist/krate-dev.js +441 -871
- package/dist/krate-f-list.js +1 -1
- package/dist/krate-f-navigation.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/request-context.d.ts +10 -0
- package/dist/request-context.js +24 -0
- package/dist/server-handler.d.ts +2 -0
- package/dist/server-handler.js +1 -1
- package/dist/server-renderer.js +6 -2
- package/dist/server.js +2 -2
- package/dist/signal.d.ts +8 -0
- package/dist/signal.js +4 -0
- package/dist/ssr-core.d.ts +3 -0
- package/dist/ssr-core.js +44 -5
- package/package.json +1 -1
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
|
}
|
|
@@ -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
|
+
}
|