@runic-artifex/vite-plugin-runic 0.18.0 → 0.20.0
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/README.md +532 -12
- package/dist/access.d.ts +46 -0
- package/dist/access.js +123 -0
- package/dist/calls.d.ts +83 -0
- package/dist/calls.js +140 -0
- package/dist/channel.d.ts +58 -1
- package/dist/channel.js +20 -1
- package/dist/client.js +210 -1
- package/dist/dev-session.d.ts +19 -2
- package/dist/dev-session.js +67 -46
- package/dist/diagnostics.d.ts +2 -0
- package/dist/diagnostics.js +2 -1
- package/dist/handlers.d.ts +140 -0
- package/dist/handlers.js +773 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +226 -11
- package/dist/inspect-data.d.ts +268 -0
- package/dist/inspect-data.js +442 -0
- package/dist/inspect-edit.d.ts +164 -0
- package/dist/inspect-edit.js +273 -0
- package/dist/inspect-editor.d.ts +34 -0
- package/dist/inspect-editor.js +282 -0
- package/dist/inspect-frameworks.d.ts +72 -0
- package/dist/inspect-frameworks.js +333 -0
- package/dist/inspect-handlers.d.ts +84 -0
- package/dist/inspect-handlers.js +331 -0
- package/dist/inspect.d.ts +42 -0
- package/dist/inspect.js +783 -0
- package/dist/otlp.d.ts +80 -0
- package/dist/otlp.js +254 -0
- package/dist/requests.d.ts +17 -0
- package/dist/requests.js +67 -0
- package/dist/sources.d.ts +135 -0
- package/dist/sources.js +343 -0
- package/dist/timeline.d.ts +12 -0
- package/dist/timeline.js +14 -0
- package/dist/translations-source.d.ts +36 -0
- package/dist/translations-source.js +109 -0
- package/package.json +12 -6
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
// Runic Inspect before the first click (#976): which of the analyzed event bindings (handlers.ts, served at
|
|
2
|
+
// `/__runic/handlers`) belong to an element, found through the framework's development metadata.
|
|
3
|
+
//
|
|
4
|
+
// - React: the element's `_debugStack` (where its JSX was created), mapped to the original file and line; then the
|
|
5
|
+
// components around it, for `<Button onClick={…}>` whose `<button>` is in another file.
|
|
6
|
+
// - Svelte: `__svelte_meta.loc`, the element's file, line and column; then the components around it.
|
|
7
|
+
// - Vue: the element's listeners (`_vei`) with their compiled handlers, in the files of its component and the
|
|
8
|
+
// components around it (a listener on `<MyButton @click>` falls through to its root element).
|
|
9
|
+
// - Angular: `ng.getListeners(element)` with the compiled template listeners, in the file of the component.
|
|
10
|
+
//
|
|
11
|
+
// Nothing here is an API of the frameworks; each lookup is best effort and gives up quietly.
|
|
12
|
+
import { absolutePath, applicationFrame, parseStack, resolveFrame } from "./inspect-frameworks.js";
|
|
13
|
+
const maximumComponents = 3;
|
|
14
|
+
function reactFiberOf(node) {
|
|
15
|
+
for (const key of Object.keys(node))
|
|
16
|
+
if (key.startsWith("__reactFiber$"))
|
|
17
|
+
return node[key];
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
function reactEvents(node) {
|
|
21
|
+
for (const key of Object.keys(node)) {
|
|
22
|
+
if (!key.startsWith("__reactProps$"))
|
|
23
|
+
continue;
|
|
24
|
+
const props = node[key];
|
|
25
|
+
return props === null || typeof props !== "object" ? [] : Object.keys(props).filter((name) => /^on[A-Z]/u.test(name)
|
|
26
|
+
&& typeof props[name] === "function").map((name) => name.slice(2).replace(/Capture$/u, "").toLowerCase());
|
|
27
|
+
}
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
function reactTag(type) {
|
|
31
|
+
if (typeof type === "string")
|
|
32
|
+
return type;
|
|
33
|
+
if (typeof type === "function")
|
|
34
|
+
return type.displayName ?? type.name ?? "";
|
|
35
|
+
if (typeof type === "object" && type !== null) {
|
|
36
|
+
const wrapped = type;
|
|
37
|
+
return typeof wrapped.displayName === "string" ? wrapped.displayName : reactTag(wrapped.render ?? wrapped.type);
|
|
38
|
+
}
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
function debugFrame(fiber) {
|
|
42
|
+
try {
|
|
43
|
+
const stack = fiber["_debugStack"]?.stack;
|
|
44
|
+
return typeof stack === "string" ? applicationFrame(parseStack(stack)) : undefined;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** The element's React probes: its own JSX, then up to three components around it. */
|
|
51
|
+
export async function reactProbes(node, root, fetchText) {
|
|
52
|
+
const fiber = reactFiberOf(node);
|
|
53
|
+
if (fiber === undefined)
|
|
54
|
+
return [];
|
|
55
|
+
const events = reactEvents(node);
|
|
56
|
+
const probes = [];
|
|
57
|
+
let components = 0;
|
|
58
|
+
for (let current = fiber; current && components <= maximumComponents; current = current["return"]) {
|
|
59
|
+
const host = current === fiber;
|
|
60
|
+
if (!host && typeof current["type"] === "string")
|
|
61
|
+
continue;
|
|
62
|
+
if (!host && (typeof current["type"] !== "function" && typeof current["type"] !== "object"))
|
|
63
|
+
continue;
|
|
64
|
+
if (!host)
|
|
65
|
+
components++;
|
|
66
|
+
const frame = debugFrame(current);
|
|
67
|
+
if (frame === undefined)
|
|
68
|
+
continue;
|
|
69
|
+
try {
|
|
70
|
+
const location = await resolveFrame(frame, root, fetchText);
|
|
71
|
+
probes.push({ kind: "location", file: location.file, line: location.line, column: location.column, tag: reactTag(current["type"]), events });
|
|
72
|
+
}
|
|
73
|
+
catch { /* next */ }
|
|
74
|
+
}
|
|
75
|
+
return probes;
|
|
76
|
+
}
|
|
77
|
+
/** The element's Svelte probes: its own position, then the component tags around it. */
|
|
78
|
+
export function svelteProbes(node, root) {
|
|
79
|
+
const meta = node["__svelte_meta"];
|
|
80
|
+
const loc = meta?.loc;
|
|
81
|
+
if (typeof loc?.file !== "string" || typeof loc.line !== "number")
|
|
82
|
+
return [];
|
|
83
|
+
const tag = typeof node["localName"] === "string" ? node["localName"] : typeof node["tagName"] === "string" ? node["tagName"].toLowerCase() : "";
|
|
84
|
+
const probes = [{
|
|
85
|
+
kind: "location", file: absolutePath(loc.file, root), line: loc.line,
|
|
86
|
+
column: (typeof loc.column === "number" ? loc.column : 0) + 1, tag,
|
|
87
|
+
}];
|
|
88
|
+
let components = 0;
|
|
89
|
+
for (let parent = meta.parent; parent && components < maximumComponents; parent = parent.parent) {
|
|
90
|
+
if (parent.type !== "component" || typeof parent.file !== "string" || typeof parent.line !== "number")
|
|
91
|
+
continue;
|
|
92
|
+
components++;
|
|
93
|
+
probes.push({
|
|
94
|
+
kind: "location", file: absolutePath(parent.file, root), line: parent.line,
|
|
95
|
+
column: (typeof parent.column === "number" ? parent.column : 0) + 1,
|
|
96
|
+
tag: typeof parent.componentTag === "string" ? parent.componentTag : "",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return probes;
|
|
100
|
+
}
|
|
101
|
+
function functionText(value) {
|
|
102
|
+
try {
|
|
103
|
+
return typeof value === "function" ? Function.prototype.toString.call(value) : "";
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return "";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** The element's Vue probe: its listeners, in the files of its component and the components around it. */
|
|
110
|
+
export function vueProbes(node, root) {
|
|
111
|
+
const instance = node["__vueParentComponent"];
|
|
112
|
+
if (typeof instance !== "object" || instance === null)
|
|
113
|
+
return [];
|
|
114
|
+
const listeners = [];
|
|
115
|
+
const add = (key, value) => {
|
|
116
|
+
// Vue keys are `onClick`, `onClickOnce`, `onUpdate:modelValue`.
|
|
117
|
+
if (!/^on[A-Z]/u.test(key))
|
|
118
|
+
return;
|
|
119
|
+
const event = key.slice(2).replace(/(?:Once|Passive|Capture)+$/u, "").toLowerCase();
|
|
120
|
+
for (const handler of Array.isArray(value) ? value : [value]) {
|
|
121
|
+
if (typeof handler === "function" && !listeners.some((listener) => listener.value === handler)) {
|
|
122
|
+
listeners.push({ event, text: functionText(handler), value: handler });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
// The element's event invokers: `el[Symbol("_vei")]` in Vue 3.4+, `el._vei` before.
|
|
127
|
+
const veiKey = Object.getOwnPropertySymbols(node).find((symbol) => symbol.description === "_vei");
|
|
128
|
+
const invokers = (veiKey === undefined ? node["_vei"] : node[veiKey]);
|
|
129
|
+
if (typeof invokers === "object" && invokers !== null)
|
|
130
|
+
for (const [key, invoker] of Object.entries(invokers))
|
|
131
|
+
add(key, invoker?.value);
|
|
132
|
+
// The element's VNode props in development, with the compiled handlers.
|
|
133
|
+
const props = node["__vnode"]?.props;
|
|
134
|
+
if (typeof props === "object" && props !== null)
|
|
135
|
+
for (const [key, value] of Object.entries(props))
|
|
136
|
+
add(key, value);
|
|
137
|
+
if (listeners.length === 0)
|
|
138
|
+
return [];
|
|
139
|
+
const instances = new Map();
|
|
140
|
+
for (let current = instance; current && instances.size < maximumComponents; current = current.parent) {
|
|
141
|
+
const file = current.type?.__file;
|
|
142
|
+
if (typeof file === "string" && !instances.has(absolutePath(file, root)))
|
|
143
|
+
instances.set(absolutePath(file, root), current);
|
|
144
|
+
}
|
|
145
|
+
if (instances.size === 0)
|
|
146
|
+
return [];
|
|
147
|
+
const tag = typeof node["localName"] === "string" ? node["localName"] : "";
|
|
148
|
+
return [{
|
|
149
|
+
kind: "listeners", framework: "vue", files: [...instances.keys()], tag, listeners,
|
|
150
|
+
resolve: (file, path) => {
|
|
151
|
+
const owner = instances.get(file);
|
|
152
|
+
let value = owner?.setupState ?? owner?.proxy;
|
|
153
|
+
for (const part of path.split(".")) {
|
|
154
|
+
if (typeof value !== "object" || value === null)
|
|
155
|
+
return undefined;
|
|
156
|
+
try {
|
|
157
|
+
value = value[part];
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return value;
|
|
164
|
+
},
|
|
165
|
+
}];
|
|
166
|
+
}
|
|
167
|
+
function angularFile(instance, root) {
|
|
168
|
+
const type = typeof instance === "object" && instance !== null
|
|
169
|
+
? instance.constructor : undefined;
|
|
170
|
+
const file = type?.ɵcmp?.debugInfo?.filePath;
|
|
171
|
+
return typeof file === "string" ? absolutePath(file, root) : undefined;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The element's Angular probe: `ng.getListeners`, in the file of its component and the components around it. Angular
|
|
175
|
+
* 17+ gives the listener's wrapper, not the template's code, so each listener carries the element's position among
|
|
176
|
+
* its component's elements with the same tag and event.
|
|
177
|
+
*/
|
|
178
|
+
export function angularProbes(node, ng, root) {
|
|
179
|
+
if (ng === undefined || typeof ng.getListeners !== "function" || typeof ng.getOwningComponent !== "function")
|
|
180
|
+
return [];
|
|
181
|
+
const listeners = [];
|
|
182
|
+
const files = [];
|
|
183
|
+
const tag = typeof node["localName"] === "string" ? node["localName"] : "";
|
|
184
|
+
const events = (element) => {
|
|
185
|
+
try {
|
|
186
|
+
return (ng.getListeners(element) ?? [])
|
|
187
|
+
.filter((listener) => typeof listener.name === "string" && listener.type !== "output").map((listener) => listener.name.toLowerCase());
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
try {
|
|
194
|
+
const owner = ng.getOwningComponent(node);
|
|
195
|
+
const host = owner === undefined || owner === null ? undefined : ng.getHostElement?.(owner);
|
|
196
|
+
const peers = typeof host?.querySelectorAll === "function" && /^[a-z][\w-]*$/u.test(tag)
|
|
197
|
+
? Array.from(host.querySelectorAll(tag)).filter((element) => ng.getOwningComponent(element) === owner) : [];
|
|
198
|
+
for (const listener of ng.getListeners(node) ?? []) {
|
|
199
|
+
if (typeof listener.name !== "string" || listener.type === "output")
|
|
200
|
+
continue;
|
|
201
|
+
const event = listener.name.toLowerCase();
|
|
202
|
+
const same = peers.filter((element) => events(element).includes(event));
|
|
203
|
+
const index = same.indexOf(node);
|
|
204
|
+
listeners.push({ event, text: functionText(listener.callback), ...(index === -1 ? {} : { position: { index, count: same.length } }) });
|
|
205
|
+
}
|
|
206
|
+
let instance = owner;
|
|
207
|
+
for (let depth = 0; instance && depth < maximumComponents; depth++) {
|
|
208
|
+
const file = angularFile(instance, root);
|
|
209
|
+
if (file !== undefined && !files.includes(file))
|
|
210
|
+
files.push(file);
|
|
211
|
+
const parent = ng.getHostElement?.(instance)?.parentElement;
|
|
212
|
+
instance = parent ? ng.getOwningComponent(parent) : undefined;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch { /* best effort */ }
|
|
216
|
+
if (listeners.length === 0 || files.length === 0)
|
|
217
|
+
return [];
|
|
218
|
+
return [{ kind: "listeners", framework: "angular", files, tag, listeners }];
|
|
219
|
+
}
|
|
220
|
+
/** All probes of an element, by whichever framework rendered it. */
|
|
221
|
+
export async function findProbes(node, options) {
|
|
222
|
+
const react = await reactProbes(node, options.root, options.fetchText);
|
|
223
|
+
if (react.length > 0)
|
|
224
|
+
return react;
|
|
225
|
+
const svelte = svelteProbes(node, options.root);
|
|
226
|
+
if (svelte.length > 0)
|
|
227
|
+
return svelte;
|
|
228
|
+
const vue = vueProbes(node, options.root);
|
|
229
|
+
if (vue.length > 0)
|
|
230
|
+
return vue;
|
|
231
|
+
return angularProbes(node, options.ng, options.root);
|
|
232
|
+
}
|
|
233
|
+
/** The files the probes need the analysis of. */
|
|
234
|
+
export function probeFiles(probes) {
|
|
235
|
+
return [...new Set(probes.flatMap((probe) => probe.kind === "location" ? [probe.file] : probe.files))];
|
|
236
|
+
}
|
|
237
|
+
// Matching ----------------------------------------------------------------------------------------------------------
|
|
238
|
+
/**
|
|
239
|
+
* Handler text as tokens, without what the compilers add: `$setup.`/`_ctx.` (Vue), `ctx.`/`ctx_r1.`/`i0.` and
|
|
240
|
+
* `ɵɵresetView` (Angular), `return`, parentheses and semicolons. Tokens are separated by single spaces, with a space
|
|
241
|
+
* at both ends, so that a handler is found in compiled code only as whole tokens.
|
|
242
|
+
*/
|
|
243
|
+
export function normalizeHandler(text) {
|
|
244
|
+
const stripped = text.replace(/(?<![\w$])(?:_ctx|\$setup|\$props|\$data|\$options|__props|ctx(?:_r\d+)?|i\d+)\./gu, "")
|
|
245
|
+
.replace(/(?<![\w$])(?:ɵɵ)?resetView(?![\w$])/gu, "");
|
|
246
|
+
const tokens = stripped.match(/[\w$\u0080-\uffff]+|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\S/gu) ?? [];
|
|
247
|
+
return ` ${tokens.filter((token) => token !== "(" && token !== ")" && token !== ";" && token !== "return")
|
|
248
|
+
.map((token) => /^'.*'$/su.test(token) ? `"${token.slice(1, -1)}"` : token).join(" ")} `;
|
|
249
|
+
}
|
|
250
|
+
function containsHandler(compiled, expression) {
|
|
251
|
+
return expression.trim().length > 0 && compiled.includes(expression);
|
|
252
|
+
}
|
|
253
|
+
function locationMatches(probe, bindings) {
|
|
254
|
+
const onLine = bindings.filter((binding) => binding.file === probe.file && binding.line === probe.line);
|
|
255
|
+
const exact = onLine.filter((binding) => binding.column === probe.column);
|
|
256
|
+
if (exact.length > 0)
|
|
257
|
+
return exact;
|
|
258
|
+
const tagged = onLine.filter((binding) => binding.tag === probe.tag || binding.tag.toLowerCase() === probe.tag.toLowerCase());
|
|
259
|
+
const candidates = tagged.length > 0 ? tagged : onLine;
|
|
260
|
+
if (candidates.length === 0)
|
|
261
|
+
return [];
|
|
262
|
+
// The nearest element on the line.
|
|
263
|
+
const columns = [...new Set(candidates.map((binding) => binding.column))]
|
|
264
|
+
.sort((a, b) => Math.abs(a - probe.column) - Math.abs(b - probe.column));
|
|
265
|
+
return candidates.filter((binding) => binding.column === columns[0]);
|
|
266
|
+
}
|
|
267
|
+
function listenerMatches(probe, analyses) {
|
|
268
|
+
const matched = new Set();
|
|
269
|
+
// An Angular component's bindings are in its template file, which the analysis of the component's script names.
|
|
270
|
+
const owners = new Map();
|
|
271
|
+
for (const analysis of analyses) {
|
|
272
|
+
const file = probe.files.find((candidate) => candidate === analysis.file || candidate === analysis.requested);
|
|
273
|
+
if (file !== undefined)
|
|
274
|
+
for (const binding of analysis.bindings)
|
|
275
|
+
owners.set(binding, file);
|
|
276
|
+
}
|
|
277
|
+
for (const listener of probe.listeners) {
|
|
278
|
+
const candidates = [...owners.keys()].filter((binding) => binding.event === listener.event);
|
|
279
|
+
if (candidates.length === 0)
|
|
280
|
+
continue;
|
|
281
|
+
const compiled = normalizeHandler(listener.text);
|
|
282
|
+
const byText = candidates.filter((binding) => containsHandler(compiled, normalizeHandler(binding.expression)));
|
|
283
|
+
const byValue = probe.resolve === undefined || listener.value === undefined ? [] : candidates.filter((binding) => /^[\w$]+(?:\.[\w$]+)*$/u.test(binding.expression.trim()) && probe.resolve(owners.get(binding), binding.expression.trim()) === listener.value);
|
|
284
|
+
let found = byText.length > 0 ? byText : byValue;
|
|
285
|
+
if (found.length === 0) {
|
|
286
|
+
// Not recognizable in the compiled code: the element's binding of the event in its own component, when there
|
|
287
|
+
// is one, by its position when the template has as many as the page shows, or all when they reach the same calls.
|
|
288
|
+
const own = candidates.filter((binding) => binding.tag.toLowerCase() === probe.tag && owners.get(binding) === probe.files[0]);
|
|
289
|
+
const signature = (binding) => binding.calls.map((entry) => entry.member).sort().join(",");
|
|
290
|
+
if (own.length === 1)
|
|
291
|
+
found = own;
|
|
292
|
+
else if (own.length > 1 && listener.position !== undefined && listener.position.count === own.length)
|
|
293
|
+
found = [own[listener.position.index]];
|
|
294
|
+
else if (own.length > 1 && own.every((binding) => signature(binding) === signature(own[0])))
|
|
295
|
+
found = own;
|
|
296
|
+
}
|
|
297
|
+
for (const binding of found)
|
|
298
|
+
matched.add(binding);
|
|
299
|
+
}
|
|
300
|
+
return [...matched];
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The bindings of an element: of its own position or listeners first; components around it only while nothing with
|
|
304
|
+
* calls matched (`<Button onClick={…}>` around a `<button onClick={props.onClick}>`).
|
|
305
|
+
*/
|
|
306
|
+
export function matchBindings(probes, analyses) {
|
|
307
|
+
const all = analyses.flatMap((analysis) => analysis.bindings);
|
|
308
|
+
const bindings = [];
|
|
309
|
+
for (const probe of probes) {
|
|
310
|
+
let found = probe.kind === "location" ? locationMatches(probe, all) : listenerMatches(probe, analyses);
|
|
311
|
+
if (probe.kind === "location" && probe !== probes[0] && probe.events !== undefined && probe.events.length > 0) {
|
|
312
|
+
found = found.filter((binding) => probe.events.includes(binding.event));
|
|
313
|
+
}
|
|
314
|
+
bindings.push(...found.filter((binding) => !bindings.includes(binding)));
|
|
315
|
+
if (bindings.some((binding) => binding.calls.length > 0))
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
const calls = new Map();
|
|
319
|
+
const external = new Map();
|
|
320
|
+
for (const binding of bindings) {
|
|
321
|
+
for (const call of binding.calls)
|
|
322
|
+
if (!calls.has(call.member))
|
|
323
|
+
calls.set(call.member, call);
|
|
324
|
+
for (const entry of binding.external)
|
|
325
|
+
external.set(entry.name, entry.source);
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
bindings, calls: [...calls.values()], external: [...external].map(([name, source]) => ({ name, source })),
|
|
329
|
+
unavailable: analyses.filter((analysis) => analysis.note !== undefined).map((analysis) => `${analysis.file}: ${analysis.note}`),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type RunicInspectDescription, type RunicInspectLocation } from "./inspect-data.js";
|
|
2
|
+
/** The value at `globalThis[Symbol.for("runic.vite.inspect")]`. */
|
|
3
|
+
export interface RunicInspectApi {
|
|
4
|
+
readonly version: 1;
|
|
5
|
+
/** Whether select mode is on. */
|
|
6
|
+
readonly active: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Turns select mode on or off (the opposite of now without an argument); returns whether it is on. While it is on, the
|
|
9
|
+
* text of generated `m.*()` calls carries Runic Translations' message markers, so `describe` can name the messages.
|
|
10
|
+
*/
|
|
11
|
+
toggle(on?: boolean): boolean;
|
|
12
|
+
/** The overview of an element, as JSON-safe data. */
|
|
13
|
+
describe(element: Element): Promise<RunicInspectDescription>;
|
|
14
|
+
/** Shows the overview of an element, as clicking it in select mode does, and returns it. */
|
|
15
|
+
select(element: Element): Promise<RunicInspectDescription>;
|
|
16
|
+
/** Opens a location of an overview in the editor; resolves to whether the server accepted it. */
|
|
17
|
+
open(location: RunicInspectLocation): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A request to the development server over Vite's HMR connection (channel.ts, `requestEvent`): the source map, or
|
|
21
|
+
* opening a location. Resolves to the server's status (0 when it did not answer) and, for the map, its body.
|
|
22
|
+
*/
|
|
23
|
+
export type InspectRequest = (kind: "sources" | "handlers" | "message" | "open", target?: unknown) => Promise<{
|
|
24
|
+
readonly status: number;
|
|
25
|
+
readonly body?: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
export interface InspectOptions {
|
|
28
|
+
/** The server's base path, below which the Translations message API is (without `request`). */
|
|
29
|
+
readonly base?: string | undefined;
|
|
30
|
+
readonly root?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The development client's request over Vite's connection. With it, the source map and opening go to the Vite server
|
|
33
|
+
* whichever origin the page has (under `dotnet runic dev` the .NET host's); without it, to `/__runic/sources` and
|
|
34
|
+
* `/__runic/open` relative to the page.
|
|
35
|
+
*/
|
|
36
|
+
readonly request?: InspectRequest | undefined;
|
|
37
|
+
}
|
|
38
|
+
export declare const inspectKey: unique symbol;
|
|
39
|
+
/** Whether a page's host name is this machine's loopback, as `/__runic/open` requires of its client. */
|
|
40
|
+
export declare function isLocalHostname(hostname: string): boolean;
|
|
41
|
+
/** Installs Runic Inspect on the page; returns a function that removes it (for HMR). */
|
|
42
|
+
export declare function installInspect(options?: InspectOptions): () => void;
|