aipeek 0.1.4 → 0.1.5
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/{chunk-AFSKSPDG.js → chunk-4PG5UWRS.js} +9 -34
- package/dist/{chunk-HNRFA6MN.cjs → chunk-P73WZQ2R.cjs} +14 -39
- package/dist/index.cjs +2 -18
- package/dist/index.d.cts +3 -14
- package/dist/index.d.ts +3 -14
- package/dist/index.js +3 -19
- package/dist/plugin.cjs +2 -2
- package/dist/plugin.js +1 -1
- package/package.json +2 -3
|
@@ -248,7 +248,7 @@ function truncate(s, max) {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// src/detail.ts
|
|
251
|
-
|
|
251
|
+
function detail(raw, section, index, full) {
|
|
252
252
|
switch (section) {
|
|
253
253
|
case "ui":
|
|
254
254
|
return full ? raw.ui || null : compactUI(raw.ui) || null;
|
|
@@ -279,7 +279,7 @@ function detailConsole(logs, index, full) {
|
|
|
279
279
|
}
|
|
280
280
|
return `[${log.level}] ${truncate2(log.text, 200)}`;
|
|
281
281
|
}
|
|
282
|
-
|
|
282
|
+
function detailNetwork(requests, index, full) {
|
|
283
283
|
const i = Number.parseInt(index ?? "");
|
|
284
284
|
if (isNaN(i) || i < 0 || i >= requests.length)
|
|
285
285
|
return null;
|
|
@@ -311,9 +311,9 @@ ${req.responseBody}`);
|
|
|
311
311
|
if (req.requestBody) {
|
|
312
312
|
lines.push(`request-body: ${byteSize(req.requestBody)}`);
|
|
313
313
|
if (req.requestSample) {
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
316
|
-
lines.push(
|
|
314
|
+
const schema = jsonSchema(req.requestSample);
|
|
315
|
+
if (schema)
|
|
316
|
+
lines.push(schema);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
if (req.responseBody) {
|
|
@@ -321,10 +321,10 @@ ${req.responseBody}`);
|
|
|
321
321
|
lines.push(`response-body: ${byteSize(req.responseBody)} "${truncate2(req.responseBody, 100)}"`);
|
|
322
322
|
} else {
|
|
323
323
|
if (req.responseSample) {
|
|
324
|
-
const ts = await quickTypeOrFallback(req.responseSample, "ResponseBody");
|
|
325
324
|
lines.push(`response-body: ${byteSize(req.responseBody)}`);
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
const schema = jsonSchema(req.responseSample);
|
|
326
|
+
if (schema)
|
|
327
|
+
lines.push(schema);
|
|
328
328
|
} else {
|
|
329
329
|
lines.push(`response-body: ${byteSize(req.responseBody)} ${truncate2(req.responseBody, 100)}`);
|
|
330
330
|
}
|
|
@@ -333,23 +333,6 @@ ${req.responseBody}`);
|
|
|
333
333
|
}
|
|
334
334
|
return lines.join("\n");
|
|
335
335
|
}
|
|
336
|
-
async function quickTypeOrFallback(sample, typeName) {
|
|
337
|
-
try {
|
|
338
|
-
const { InputData, jsonInputForTargetLanguage, quicktype } = await import("quicktype-core");
|
|
339
|
-
const jsonInput = jsonInputForTargetLanguage("typescript");
|
|
340
|
-
await jsonInput.addSource({ name: typeName, samples: [sample] });
|
|
341
|
-
const inputData = new InputData();
|
|
342
|
-
inputData.addInput(jsonInput);
|
|
343
|
-
const { lines } = await quicktype({
|
|
344
|
-
inputData,
|
|
345
|
-
lang: "typescript",
|
|
346
|
-
rendererOptions: { "just-types": "true", "acronym-style": "original" }
|
|
347
|
-
});
|
|
348
|
-
return lines.join("\n");
|
|
349
|
-
} catch {
|
|
350
|
-
return jsonSchema(sample);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
336
|
function detailError(errors, index, full) {
|
|
354
337
|
const i = Number.parseInt(index ?? "");
|
|
355
338
|
if (isNaN(i) || i < 0 || i >= errors.length)
|
|
@@ -583,7 +566,7 @@ function aipeekPlugin() {
|
|
|
583
566
|
if (parts.length >= 1) {
|
|
584
567
|
if (!lastRaw)
|
|
585
568
|
lastRaw = await collectFromClient();
|
|
586
|
-
const result =
|
|
569
|
+
const result = detail(lastRaw, parts[0], parts[1], full);
|
|
587
570
|
if (result !== null) {
|
|
588
571
|
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
|
|
589
572
|
res.end(result);
|
|
@@ -609,13 +592,5 @@ function aipeekPlugin() {
|
|
|
609
592
|
}
|
|
610
593
|
|
|
611
594
|
export {
|
|
612
|
-
compactUI,
|
|
613
|
-
compactConsole,
|
|
614
|
-
compactNetwork,
|
|
615
|
-
compactErrors,
|
|
616
|
-
compactState,
|
|
617
|
-
compact,
|
|
618
|
-
detail,
|
|
619
|
-
emit,
|
|
620
595
|
aipeekPlugin
|
|
621
596
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/plugin.ts
|
|
2
2
|
var _fs = require('fs');
|
|
3
3
|
var _path = require('path');
|
|
4
4
|
var _url = require('url');
|
|
@@ -248,7 +248,7 @@ function truncate(s, max) {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// src/detail.ts
|
|
251
|
-
|
|
251
|
+
function detail(raw, section, index, full) {
|
|
252
252
|
switch (section) {
|
|
253
253
|
case "ui":
|
|
254
254
|
return full ? raw.ui || null : compactUI(raw.ui) || null;
|
|
@@ -279,7 +279,7 @@ function detailConsole(logs, index, full) {
|
|
|
279
279
|
}
|
|
280
280
|
return `[${log.level}] ${truncate2(log.text, 200)}`;
|
|
281
281
|
}
|
|
282
|
-
|
|
282
|
+
function detailNetwork(requests, index, full) {
|
|
283
283
|
const i = Number.parseInt(_nullishCoalesce(index, () => ( "")));
|
|
284
284
|
if (isNaN(i) || i < 0 || i >= requests.length)
|
|
285
285
|
return null;
|
|
@@ -311,9 +311,9 @@ ${req.responseBody}`);
|
|
|
311
311
|
if (req.requestBody) {
|
|
312
312
|
lines.push(`request-body: ${byteSize(req.requestBody)}`);
|
|
313
313
|
if (req.requestSample) {
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
316
|
-
lines.push(
|
|
314
|
+
const schema = jsonSchema(req.requestSample);
|
|
315
|
+
if (schema)
|
|
316
|
+
lines.push(schema);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
if (req.responseBody) {
|
|
@@ -321,10 +321,10 @@ ${req.responseBody}`);
|
|
|
321
321
|
lines.push(`response-body: ${byteSize(req.responseBody)} "${truncate2(req.responseBody, 100)}"`);
|
|
322
322
|
} else {
|
|
323
323
|
if (req.responseSample) {
|
|
324
|
-
const ts = await quickTypeOrFallback(req.responseSample, "ResponseBody");
|
|
325
324
|
lines.push(`response-body: ${byteSize(req.responseBody)}`);
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
const schema = jsonSchema(req.responseSample);
|
|
326
|
+
if (schema)
|
|
327
|
+
lines.push(schema);
|
|
328
328
|
} else {
|
|
329
329
|
lines.push(`response-body: ${byteSize(req.responseBody)} ${truncate2(req.responseBody, 100)}`);
|
|
330
330
|
}
|
|
@@ -333,23 +333,6 @@ ${req.responseBody}`);
|
|
|
333
333
|
}
|
|
334
334
|
return lines.join("\n");
|
|
335
335
|
}
|
|
336
|
-
async function quickTypeOrFallback(sample, typeName) {
|
|
337
|
-
try {
|
|
338
|
-
const { InputData, jsonInputForTargetLanguage, quicktype } = await Promise.resolve().then(() => _interopRequireWildcard(require("quicktype-core")));
|
|
339
|
-
const jsonInput = jsonInputForTargetLanguage("typescript");
|
|
340
|
-
await jsonInput.addSource({ name: typeName, samples: [sample] });
|
|
341
|
-
const inputData = new InputData();
|
|
342
|
-
inputData.addInput(jsonInput);
|
|
343
|
-
const { lines } = await quicktype({
|
|
344
|
-
inputData,
|
|
345
|
-
lang: "typescript",
|
|
346
|
-
rendererOptions: { "just-types": "true", "acronym-style": "original" }
|
|
347
|
-
});
|
|
348
|
-
return lines.join("\n");
|
|
349
|
-
} catch (e3) {
|
|
350
|
-
return jsonSchema(sample);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
336
|
function detailError(errors, index, full) {
|
|
354
337
|
const i = Number.parseInt(_nullishCoalesce(index, () => ( "")));
|
|
355
338
|
if (isNaN(i) || i < 0 || i >= errors.length)
|
|
@@ -385,7 +368,7 @@ function detailState(state, name, full) {
|
|
|
385
368
|
if (full) {
|
|
386
369
|
try {
|
|
387
370
|
return JSON.stringify(value, null, 2);
|
|
388
|
-
} catch (
|
|
371
|
+
} catch (e3) {
|
|
389
372
|
return String(value);
|
|
390
373
|
}
|
|
391
374
|
}
|
|
@@ -416,7 +399,7 @@ function formatSummaryValue(v) {
|
|
|
416
399
|
function jsonSchema(sample) {
|
|
417
400
|
try {
|
|
418
401
|
return schemaOf(JSON.parse(sample), 0);
|
|
419
|
-
} catch (
|
|
402
|
+
} catch (e4) {
|
|
420
403
|
return null;
|
|
421
404
|
}
|
|
422
405
|
}
|
|
@@ -538,7 +521,7 @@ ${snippet}`);
|
|
|
538
521
|
const before = content.slice(0, start).trimEnd();
|
|
539
522
|
const after = content.slice(end);
|
|
540
523
|
_fs.writeFileSync.call(void 0, path, before + (before ? "\n" : "") + snippet + after);
|
|
541
|
-
} catch (
|
|
524
|
+
} catch (e5) {
|
|
542
525
|
}
|
|
543
526
|
}
|
|
544
527
|
function aipeekPlugin() {
|
|
@@ -583,7 +566,7 @@ function aipeekPlugin() {
|
|
|
583
566
|
if (parts.length >= 1) {
|
|
584
567
|
if (!lastRaw)
|
|
585
568
|
lastRaw = await collectFromClient();
|
|
586
|
-
const result =
|
|
569
|
+
const result = detail(lastRaw, parts[0], parts[1], full);
|
|
587
570
|
if (result !== null) {
|
|
588
571
|
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
|
|
589
572
|
res.end(result);
|
|
@@ -610,12 +593,4 @@ function aipeekPlugin() {
|
|
|
610
593
|
|
|
611
594
|
|
|
612
595
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
exports.compactUI = compactUI; exports.compactConsole = compactConsole; exports.compactNetwork = compactNetwork; exports.compactErrors = compactErrors; exports.compactState = compactState; exports.compact = compact; exports.detail = detail; exports.emit = emit; exports.aipeekPlugin = aipeekPlugin;
|
|
596
|
+
exports.aipeekPlugin = aipeekPlugin;
|
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
var _chunkP73WZQ2Rcjs = require('./chunk-P73WZQ2R.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _chunkHNRFA6MNcjs = require('./chunk-HNRFA6MN.cjs');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exports.aipeekPlugin = _chunkHNRFA6MNcjs.aipeekPlugin; exports.compact = _chunkHNRFA6MNcjs.compact; exports.compactConsole = _chunkHNRFA6MNcjs.compactConsole; exports.compactErrors = _chunkHNRFA6MNcjs.compactErrors; exports.compactNetwork = _chunkHNRFA6MNcjs.compactNetwork; exports.compactState = _chunkHNRFA6MNcjs.compactState; exports.compactUI = _chunkHNRFA6MNcjs.compactUI; exports.detail = _chunkHNRFA6MNcjs.detail; exports.emit = _chunkHNRFA6MNcjs.emit;
|
|
6
|
+
exports.aipeekPlugin = _chunkP73WZQ2Rcjs.aipeekPlugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
+
declare function aipeekPlugin(): Plugin;
|
|
4
|
+
|
|
3
5
|
interface LogEntry {
|
|
4
6
|
level: 'error' | 'warn' | 'info' | 'debug' | 'log';
|
|
5
7
|
text: string;
|
|
@@ -53,17 +55,4 @@ interface CompactState {
|
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
declare function compactConsole(logs: LogEntry[]): string;
|
|
58
|
-
declare function compactNetwork(requests: NetworkRequest[]): string;
|
|
59
|
-
declare function compactErrors(errors: ErrorEntry[]): string;
|
|
60
|
-
declare function compactState(state: Record<string, unknown>): string;
|
|
61
|
-
declare function compact(raw: RawState): CompactState;
|
|
62
|
-
|
|
63
|
-
declare function detail(raw: RawState, section: string, index: string | undefined, full: boolean): Promise<string | null>;
|
|
64
|
-
|
|
65
|
-
declare function emit(state: CompactState): string;
|
|
66
|
-
|
|
67
|
-
declare function aipeekPlugin(): Plugin;
|
|
68
|
-
|
|
69
|
-
export { type CompactState, type ErrorEntry, type LogEntry, type NetworkRequest, type RawState, aipeekPlugin, compact, compactConsole, compactErrors, compactNetwork, compactState, compactUI, detail, emit };
|
|
58
|
+
export { type CompactState, type RawState, aipeekPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
+
declare function aipeekPlugin(): Plugin;
|
|
4
|
+
|
|
3
5
|
interface LogEntry {
|
|
4
6
|
level: 'error' | 'warn' | 'info' | 'debug' | 'log';
|
|
5
7
|
text: string;
|
|
@@ -53,17 +55,4 @@ interface CompactState {
|
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
declare function compactConsole(logs: LogEntry[]): string;
|
|
58
|
-
declare function compactNetwork(requests: NetworkRequest[]): string;
|
|
59
|
-
declare function compactErrors(errors: ErrorEntry[]): string;
|
|
60
|
-
declare function compactState(state: Record<string, unknown>): string;
|
|
61
|
-
declare function compact(raw: RawState): CompactState;
|
|
62
|
-
|
|
63
|
-
declare function detail(raw: RawState, section: string, index: string | undefined, full: boolean): Promise<string | null>;
|
|
64
|
-
|
|
65
|
-
declare function emit(state: CompactState): string;
|
|
66
|
-
|
|
67
|
-
declare function aipeekPlugin(): Plugin;
|
|
68
|
-
|
|
69
|
-
export { type CompactState, type ErrorEntry, type LogEntry, type NetworkRequest, type RawState, aipeekPlugin, compact, compactConsole, compactErrors, compactNetwork, compactState, compactUI, detail, emit };
|
|
58
|
+
export { type CompactState, type RawState, aipeekPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
aipeekPlugin
|
|
3
|
-
|
|
4
|
-
compactConsole,
|
|
5
|
-
compactErrors,
|
|
6
|
-
compactNetwork,
|
|
7
|
-
compactState,
|
|
8
|
-
compactUI,
|
|
9
|
-
detail,
|
|
10
|
-
emit
|
|
11
|
-
} from "./chunk-AFSKSPDG.js";
|
|
2
|
+
aipeekPlugin
|
|
3
|
+
} from "./chunk-4PG5UWRS.js";
|
|
12
4
|
export {
|
|
13
|
-
aipeekPlugin
|
|
14
|
-
compact,
|
|
15
|
-
compactConsole,
|
|
16
|
-
compactErrors,
|
|
17
|
-
compactNetwork,
|
|
18
|
-
compactState,
|
|
19
|
-
compactUI,
|
|
20
|
-
detail,
|
|
21
|
-
emit
|
|
5
|
+
aipeekPlugin
|
|
22
6
|
};
|
package/dist/plugin.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkP73WZQ2Rcjs = require('./chunk-P73WZQ2R.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
exports.aipeekPlugin =
|
|
6
|
+
exports.aipeekPlugin = _chunkP73WZQ2Rcjs.aipeekPlugin;
|
package/dist/plugin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aipeek",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Gives AI a peek into your running browser app — UI tree, console, network, errors, state",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
"test:watch": "vitest"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"picocolors": "^1.1.1"
|
|
30
|
-
"quicktype-core": "^23.2.6"
|
|
29
|
+
"picocolors": "^1.1.1"
|
|
31
30
|
},
|
|
32
31
|
"peerDependencies": {
|
|
33
32
|
"vite": ">=5.0.0"
|