@abbox/inspector 0.4.1 → 0.4.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-abbox-inspector.d.ts","sourceRoot":"","sources":["../../src/next/with-abbox-inspector.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,CACR,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACpC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAIF,eAAO,MAAM,8BAA8B,
|
|
1
|
+
{"version":3,"file":"with-abbox-inspector.d.ts","sourceRoot":"","sources":["../../src/next/with-abbox-inspector.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,CACR,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACpC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAIF,eAAO,MAAM,8BAA8B,UAU1C,CAAC;AAcF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,yBAA8B,GACtC,CAAC,CAgFH"}
|
|
@@ -4,6 +4,10 @@ const require = createRequire(fileURLToPath(import.meta.url));
|
|
|
4
4
|
import { isAbboxInspectorBuildEnabled } from "./preview-env.js";
|
|
5
5
|
export const DEFAULT_VIEWER_FRAME_ANCESTORS = [
|
|
6
6
|
"https://viewer.abbox.com",
|
|
7
|
+
// The hosted product embeds the Viewer, so browsers require the product
|
|
8
|
+
// origin to be allowed as an ancestor as well as the immediate Viewer.
|
|
9
|
+
"https://www.abbox.com",
|
|
10
|
+
"https://abbox.com",
|
|
7
11
|
"http://localhost:5173",
|
|
8
12
|
"http://127.0.0.1:5173",
|
|
9
13
|
"http://localhost:4173",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChangeMarker } from "../protocol.js";
|
|
2
|
+
export type DomMatchConfidence = "exact" | "probable" | "ambiguous" | "unresolved";
|
|
3
|
+
export type ChangeMarkerResolution = {
|
|
4
|
+
changeId: string;
|
|
5
|
+
confidence: DomMatchConfidence;
|
|
6
|
+
candidateCount: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function resolveChangeMarker(marker: ChangeMarker, doc: Document, pathname: string, refIdToElement: Map<string, Element>): {
|
|
9
|
+
element: Element | null;
|
|
10
|
+
resolution: ChangeMarkerResolution;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=resolve-change-marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-change-marker.d.ts","sourceRoot":"","sources":["../../src/runtime/resolve-change-marker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;AAEnF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAiCF,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,QAAQ,EACb,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC;IAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,sBAAsB,CAAA;CAAE,CAqEjE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
function routeMatches(markerRoute, pathname) {
|
|
2
|
+
if (!markerRoute?.trim())
|
|
3
|
+
return true;
|
|
4
|
+
const route = markerRoute.trim();
|
|
5
|
+
if (route === pathname)
|
|
6
|
+
return true;
|
|
7
|
+
if (route.endsWith("*") && pathname.startsWith(route.slice(0, -1)))
|
|
8
|
+
return true;
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
function collectSourcePrefixMatches(doc, prefix) {
|
|
12
|
+
const matches = [];
|
|
13
|
+
const nodes = doc.querySelectorAll("[data-abbox-src]");
|
|
14
|
+
for (const node of nodes) {
|
|
15
|
+
const attr = node.getAttribute("data-abbox-src");
|
|
16
|
+
if (attr?.startsWith(prefix)) {
|
|
17
|
+
matches.push(node);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return matches;
|
|
21
|
+
}
|
|
22
|
+
function collectElementIdMatches(doc, elementId) {
|
|
23
|
+
const escaped = elementId.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
24
|
+
const byId = doc.querySelectorAll(`[id="${escaped}"]`);
|
|
25
|
+
if (byId.length > 0)
|
|
26
|
+
return [...byId];
|
|
27
|
+
const byData = doc.querySelectorAll(`[data-abbox-element-id="${escaped}"]`);
|
|
28
|
+
return [...byData];
|
|
29
|
+
}
|
|
30
|
+
export function resolveChangeMarker(marker, doc, pathname, refIdToElement) {
|
|
31
|
+
const base = {
|
|
32
|
+
changeId: marker.elementRefId,
|
|
33
|
+
confidence: "unresolved",
|
|
34
|
+
candidateCount: 0,
|
|
35
|
+
};
|
|
36
|
+
if (!routeMatches(marker.route, pathname)) {
|
|
37
|
+
return { element: null, resolution: base };
|
|
38
|
+
}
|
|
39
|
+
const byRef = refIdToElement.get(marker.elementRefId);
|
|
40
|
+
if (byRef) {
|
|
41
|
+
return {
|
|
42
|
+
element: byRef,
|
|
43
|
+
resolution: { ...base, confidence: "exact", candidateCount: 1 },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let candidates = [];
|
|
47
|
+
if (marker.compilerElementId?.trim()) {
|
|
48
|
+
candidates = collectElementIdMatches(doc, marker.compilerElementId.trim());
|
|
49
|
+
if (candidates.length === 1) {
|
|
50
|
+
return {
|
|
51
|
+
element: candidates[0],
|
|
52
|
+
resolution: { ...base, confidence: "exact", candidateCount: 1 },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (candidates.length > 1) {
|
|
56
|
+
return {
|
|
57
|
+
element: null,
|
|
58
|
+
resolution: { ...base, confidence: "ambiguous", candidateCount: candidates.length },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const prefix = marker.sourceKeyPrefix?.trim();
|
|
63
|
+
if (prefix) {
|
|
64
|
+
candidates = collectSourcePrefixMatches(doc, prefix);
|
|
65
|
+
if (marker.interactionId) {
|
|
66
|
+
// Narrow by label hint when multiple nodes share a source line.
|
|
67
|
+
const label = marker.label.toLowerCase();
|
|
68
|
+
const narrowed = candidates.filter((el) => {
|
|
69
|
+
const text = (el.textContent ?? "").toLowerCase();
|
|
70
|
+
return label.length > 0 && text.includes(label.slice(0, 24));
|
|
71
|
+
});
|
|
72
|
+
if (narrowed.length === 1) {
|
|
73
|
+
return {
|
|
74
|
+
element: narrowed[0],
|
|
75
|
+
resolution: { ...base, confidence: "probable", candidateCount: 1 },
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (candidates.length === 1) {
|
|
80
|
+
return {
|
|
81
|
+
element: candidates[0],
|
|
82
|
+
resolution: { ...base, confidence: "probable", candidateCount: 1 },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (candidates.length > 1) {
|
|
86
|
+
return {
|
|
87
|
+
element: null,
|
|
88
|
+
resolution: { ...base, confidence: "ambiguous", candidateCount: candidates.length },
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return { element: null, resolution: base };
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abbox/inspector",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"README.md"
|
|
58
58
|
],
|
|
59
59
|
"scripts": {
|
|
60
|
+
"prepare": "npm run build",
|
|
60
61
|
"build": "tsc -p tsconfig.build.json && node -e \"const fs=require('fs');const p='dist/next';fs.mkdirSync(p,{recursive:true});fs.copyFileSync('src/next/webpack-instrumentation.cjs',p+'/webpack-instrumentation.cjs');fs.copyFileSync('src/next/abbox-pre-swc-loader.cjs',p+'/abbox-pre-swc-loader.cjs');fs.copyFileSync('src/next/babel-config.cjs',p+'/babel-config.cjs');\"",
|
|
61
62
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
62
63
|
"test": "npm run build && vitest run",
|