@abbox/inspector 0.4.17 → 0.4.19
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/host/client-bridge.d.ts.map +1 -1
- package/dist/host/client-bridge.js +7 -2
- package/dist/host/host-bridge.d.ts +4 -1
- package/dist/host/host-bridge.d.ts.map +1 -1
- package/dist/host/host-bridge.js +7 -1
- package/dist/protocol.d.ts +22 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/runtime/inspector.d.ts +4 -1
- package/dist/runtime/inspector.d.ts.map +1 -1
- package/dist/runtime/inspector.js +25 -4
- package/dist/runtime/styles.d.ts +15 -0
- package/dist/runtime/styles.d.ts.map +1 -0
- package/dist/runtime/styles.js +95 -0
- package/package.json +1 -1
- package/dist/runtime/resolve-change-marker.d.ts +0 -12
- package/dist/runtime/resolve-change-marker.d.ts.map +0 -1
- package/dist/runtime/resolve-change-marker.js +0 -93
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-bridge.d.ts","sourceRoot":"","sources":["../../src/host/client-bridge.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,eAAe,
|
|
1
|
+
{"version":3,"file":"client-bridge.d.ts","sourceRoot":"","sources":["../../src/host/client-bridge.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,eAAe,CAuFjB"}
|
|
@@ -42,8 +42,8 @@ export function createInspectorClient(options) {
|
|
|
42
42
|
onChangeMarkerSelected: (changeId) => {
|
|
43
43
|
send({ ...base(), type: "CHANGE_MARKER_SELECTED", changeId });
|
|
44
44
|
},
|
|
45
|
-
onRouteChange: (path) => {
|
|
46
|
-
send({ ...base(), type: "ROUTE_CHANGED", path });
|
|
45
|
+
onRouteChange: (path, href) => {
|
|
46
|
+
send({ ...base(), type: "ROUTE_CHANGED", path, href });
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
49
|
// The last minute of activity, for bug reports from the Viewer.
|
|
@@ -64,6 +64,11 @@ export function createInspectorClient(options) {
|
|
|
64
64
|
if (msg.type === "APPLY_CHANGE_MARKERS") {
|
|
65
65
|
runtime.setChangeMarkers(msg.markers);
|
|
66
66
|
}
|
|
67
|
+
if (msg.type === "APPLY_STYLE_OVERRIDES") {
|
|
68
|
+
runtime.applyStyleOverrides(msg.elementRefId, msg.styles);
|
|
69
|
+
}
|
|
70
|
+
if (msg.type === "CLEAR_STYLE_OVERRIDES")
|
|
71
|
+
runtime.clearStyleOverrides();
|
|
67
72
|
if (msg.type === "REQUEST_RECORDING") {
|
|
68
73
|
send({ ...base(), type: "RECORDING", steps: recorder.snapshot() });
|
|
69
74
|
}
|
|
@@ -19,7 +19,7 @@ export type InspectorHostHandlers = {
|
|
|
19
19
|
onSelect?: (payload: SelectPayload) => void;
|
|
20
20
|
onCleared?: () => void;
|
|
21
21
|
onChangeMarkerSelected?: (changeId: string) => void;
|
|
22
|
-
onRouteChange?: (path: string) => void;
|
|
22
|
+
onRouteChange?: (path: string, href?: string) => void;
|
|
23
23
|
onRecording?: (steps: RecordedStep[]) => void;
|
|
24
24
|
onError?: (code: string, message: string) => void;
|
|
25
25
|
};
|
|
@@ -33,6 +33,9 @@ export type InspectorHost = {
|
|
|
33
33
|
pingPreview: () => void;
|
|
34
34
|
/** Ask the preview for its last minute of activity (answered via onRecording). */
|
|
35
35
|
requestRecording: () => void;
|
|
36
|
+
/** Live Design tab edits on one element; an empty object restores it. Needs inspector 0.4.18 in the preview. */
|
|
37
|
+
applyStyleOverrides: (elementRefId: string, styles: Record<string, string>) => void;
|
|
38
|
+
clearStyleOverrides: () => void;
|
|
36
39
|
};
|
|
37
40
|
export declare function createInspectorHost(options: InspectorHostOptions, handlers: InspectorHostHandlers): InspectorHost;
|
|
38
41
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-bridge.d.ts","sourceRoot":"","sources":["../../src/host/host-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAGxB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF,KAAK,YAAY,GAAG,OAAO,CACzB,mBAAmB,EACnB;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAC5B,CAAC,SAAS,CAAC,CAAC;AACb,KAAK,aAAa,GAAG,OAAO,CAC1B,mBAAmB,EACnB;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAC7B,CAAC,SAAS,CAAC,CAAC;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CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,kBAAkB,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IACtD,0EAA0E;IAC1E,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,kFAAkF;IAClF,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,gHAAgH;IAChH,mBAAmB,EAAE,CACnB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3B,IAAI,CAAC;IACV,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,qBAAqB,GAC9B,aAAa,CA8Ef"}
|
package/dist/host/host-bridge.js
CHANGED
|
@@ -36,7 +36,7 @@ export function createInspectorHost(options, handlers) {
|
|
|
36
36
|
handlers.onChangeMarkerSelected?.(msg.changeId);
|
|
37
37
|
}
|
|
38
38
|
if (msg.type === "ROUTE_CHANGED") {
|
|
39
|
-
handlers.onRouteChange?.(msg.path);
|
|
39
|
+
handlers.onRouteChange?.(msg.path, msg.href);
|
|
40
40
|
}
|
|
41
41
|
if (msg.type === "RECORDING") {
|
|
42
42
|
handlers.onRecording?.(msg.steps);
|
|
@@ -64,6 +64,12 @@ export function createInspectorHost(options, handlers) {
|
|
|
64
64
|
requestRecording: () => {
|
|
65
65
|
send({ ...base(), type: "REQUEST_RECORDING" });
|
|
66
66
|
},
|
|
67
|
+
applyStyleOverrides: (elementRefId, styles) => {
|
|
68
|
+
send({ ...base(), type: "APPLY_STYLE_OVERRIDES", elementRefId, styles });
|
|
69
|
+
},
|
|
70
|
+
clearStyleOverrides: () => {
|
|
71
|
+
send({ ...base(), type: "CLEAR_STYLE_OVERRIDES" });
|
|
72
|
+
},
|
|
67
73
|
pingPreview: () => {
|
|
68
74
|
send({
|
|
69
75
|
...base(),
|
package/dist/protocol.d.ts
CHANGED
|
@@ -74,6 +74,11 @@ export type ElementHoverPayload = {
|
|
|
74
74
|
metadata: ElementMetadata;
|
|
75
75
|
source: SourceLocation | null;
|
|
76
76
|
mappingStatus: SourceMappingStatus;
|
|
77
|
+
/**
|
|
78
|
+
* Computed styles of a selected element, for the Design tab (CSS property →
|
|
79
|
+
* value). Sent with selections only; absent from inspectors before 0.4.18.
|
|
80
|
+
*/
|
|
81
|
+
styles?: Record<string, string>;
|
|
77
82
|
};
|
|
78
83
|
export type ElementSelectedPayload = ElementHoverPayload;
|
|
79
84
|
export type ElementHoveredMessage = InspectorMessageBase & {
|
|
@@ -117,10 +122,12 @@ export type ChangeMarkerSelectedMessage = InspectorMessageBase & {
|
|
|
117
122
|
type: "CHANGE_MARKER_SELECTED";
|
|
118
123
|
changeId: string;
|
|
119
124
|
};
|
|
120
|
-
/** The preview navigated (client-side or full load) to a new path. */
|
|
125
|
+
/** The preview navigated (client-side or full load) to a new path or query. */
|
|
121
126
|
export type RouteChangedMessage = InspectorMessageBase & {
|
|
122
127
|
type: "ROUTE_CHANGED";
|
|
123
128
|
path: string;
|
|
129
|
+
/** The full address, query included (0.4.19+), so the Viewer can show and restore it. */
|
|
130
|
+
href?: string;
|
|
124
131
|
};
|
|
125
132
|
export type ApplyChangeMarkersMessage = InspectorMessageBase & {
|
|
126
133
|
type: "APPLY_CHANGE_MARKERS";
|
|
@@ -144,6 +151,19 @@ export type RecordedStep = {
|
|
|
144
151
|
status?: number;
|
|
145
152
|
durationMs?: number;
|
|
146
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* Live style edits from the Design tab: replaces any earlier overrides on the
|
|
156
|
+
* element; an empty `styles` restores it. Only design properties are applied.
|
|
157
|
+
*/
|
|
158
|
+
export type ApplyStyleOverridesMessage = InspectorMessageBase & {
|
|
159
|
+
type: "APPLY_STYLE_OVERRIDES";
|
|
160
|
+
elementRefId: string;
|
|
161
|
+
styles: Record<string, string>;
|
|
162
|
+
};
|
|
163
|
+
/** Removes every live style edit, e.g. when the Design tab closes. */
|
|
164
|
+
export type ClearStyleOverridesMessage = InspectorMessageBase & {
|
|
165
|
+
type: "CLEAR_STYLE_OVERRIDES";
|
|
166
|
+
};
|
|
147
167
|
export type RequestRecordingMessage = InspectorMessageBase & {
|
|
148
168
|
type: "REQUEST_RECORDING";
|
|
149
169
|
};
|
|
@@ -151,7 +171,7 @@ export type RecordingMessage = InspectorMessageBase & {
|
|
|
151
171
|
type: "RECORDING";
|
|
152
172
|
steps: RecordedStep[];
|
|
153
173
|
};
|
|
154
|
-
export type HostToClientMessage = InspectorEnableMessage | InspectorDisableMessage | InspectorHostHelloMessage | ApplyChangeMarkersMessage | RequestRecordingMessage;
|
|
174
|
+
export type HostToClientMessage = InspectorEnableMessage | InspectorDisableMessage | InspectorHostHelloMessage | ApplyChangeMarkersMessage | ApplyStyleOverridesMessage | ClearStyleOverridesMessage | RequestRecordingMessage;
|
|
155
175
|
export type ClientToHostMessage = InspectorReadyMessage | ElementHoveredMessage | ElementSelectedMessage | ElementClearedMessage | ChangeMarkerSelectedMessage | RouteChangedMessage | RecordingMessage | InspectorErrorMessage;
|
|
156
176
|
export type InspectorMessage = HostToClientMessage | ClientToHostMessage;
|
|
157
177
|
export declare function isInspectorMessage(value: unknown): value is InspectorMessage;
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAE3C,eAAO,MAAM,wBAAwB,EAAG,iBAA0B,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,wBAAwB,CAAC;IACzC,OAAO,EAAE,OAAO,gBAAgB,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GAAG;IACzD,IAAI,EAAE,iBAAiB,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,GAAG;IAC1D,IAAI,EAAE,kBAAkB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG;IAC3D,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,yBAAyB,GAAG,oBAAoB,GAAG;IAC7D,IAAI,EAAE,sBAAsB,CAAC;IAC7B,qFAAqF;IACrF,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,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MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF,sEAAsE;AACtE,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG;IAC9D,IAAI,EAAE,uBAAuB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG;IAC3D,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG;IACpD,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,sBAAsB,GACtB,uBAAuB,GACvB,yBAAyB,GACzB,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,uBAAuB,CAAC;AAE5B,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,2BAA2B,GAC3B,mBAAmB,GACnB,gBAAgB,GAChB,qBAAqB,CAAC;AAE1B,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAEzE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAS5E"}
|
|
@@ -6,7 +6,7 @@ export type InspectorRuntimeOptions = {
|
|
|
6
6
|
onSelect?: (payload: ElementHoverPayload) => void;
|
|
7
7
|
onClear?: () => void;
|
|
8
8
|
onChangeMarkerSelected?: (changeId: string) => void;
|
|
9
|
-
onRouteChange?: (path: string) => void;
|
|
9
|
+
onRouteChange?: (path: string, href: string) => void;
|
|
10
10
|
};
|
|
11
11
|
export type InspectorRuntime = {
|
|
12
12
|
enable: () => void;
|
|
@@ -14,6 +14,9 @@ export type InspectorRuntime = {
|
|
|
14
14
|
isEnabled: () => boolean;
|
|
15
15
|
setChangeMarkers: (markers: ChangeMarker[]) => void;
|
|
16
16
|
getElementByRefId: (refId: string) => Element | null;
|
|
17
|
+
/** Live Design tab edits; an empty object restores the element. */
|
|
18
|
+
applyStyleOverrides: (refId: string, styles: Record<string, string>) => void;
|
|
19
|
+
clearStyleOverrides: () => void;
|
|
17
20
|
destroy: () => void;
|
|
18
21
|
};
|
|
19
22
|
export declare function createInspectorRuntime(options: InspectorRuntimeOptions): InspectorRuntime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":["../../src/runtime/inspector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":["../../src/runtime/inspector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AA0CxE,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,gBAAgB,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IACpD,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IACrD,mEAAmE;IACnE,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAC7E,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CA4XlB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { runtimeElementRefFor } from "./element-ref.js";
|
|
2
2
|
import { extractMetadata, findSourceLocation, sourceKeyFor, sourceMappingStatus, } from "./metadata.js";
|
|
3
3
|
import { createOverlay, hideHighlight, hideSelectedHighlight, positionHighlight, positionSelectedHighlight, rectForElement, renderChangeMarkers, } from "./overlay.js";
|
|
4
|
+
import { createStyleOverrides, readDesignStyles } from "./styles.js";
|
|
4
5
|
const SOURCE_LINE_TOLERANCE = 2;
|
|
5
6
|
function parseSourceKey(raw) {
|
|
6
7
|
const m = raw ? /^(.*?):(\d+)(?::\d+)?$/.exec(raw) : null;
|
|
@@ -105,7 +106,8 @@ export function createInspectorRuntime(options) {
|
|
|
105
106
|
renderChangeMarkers(overlay.markerLayer, markers, (id) => refIdToElement.get(id) ?? null, options.onChangeMarkerSelected);
|
|
106
107
|
}
|
|
107
108
|
};
|
|
108
|
-
|
|
109
|
+
const styleOverrides = createStyleOverrides();
|
|
110
|
+
function payloadFor(el, withStyles = false) {
|
|
109
111
|
const source = findSourceLocation(el);
|
|
110
112
|
const sourceKey = sourceKeyFor(source);
|
|
111
113
|
const elementRef = runtimeElementRefFor(el, sourceKey);
|
|
@@ -116,6 +118,7 @@ export function createInspectorRuntime(options) {
|
|
|
116
118
|
metadata: extractMetadata(el),
|
|
117
119
|
source,
|
|
118
120
|
mappingStatus: sourceMappingStatus(source),
|
|
121
|
+
...(withStyles ? { styles: readDesignStyles(el, win) } : {}),
|
|
119
122
|
};
|
|
120
123
|
}
|
|
121
124
|
function setHover(el) {
|
|
@@ -138,7 +141,7 @@ export function createInspectorRuntime(options) {
|
|
|
138
141
|
return;
|
|
139
142
|
reportedSize = sizeKey(selected);
|
|
140
143
|
positionSelectedHighlight(overlay.selectedHighlight, rectForElement(selected));
|
|
141
|
-
options.onSelect?.(payloadFor(selected));
|
|
144
|
+
options.onSelect?.(payloadFor(selected, true));
|
|
142
145
|
});
|
|
143
146
|
function select(el) {
|
|
144
147
|
selected = el;
|
|
@@ -148,7 +151,7 @@ export function createInspectorRuntime(options) {
|
|
|
148
151
|
sizeObserver?.disconnect();
|
|
149
152
|
reportedSize = sizeKey(el);
|
|
150
153
|
sizeObserver?.observe(el);
|
|
151
|
-
options.onSelect?.(payloadFor(el));
|
|
154
|
+
options.onSelect?.(payloadFor(el, true));
|
|
152
155
|
}
|
|
153
156
|
const onCurrentRoute = (marker) => !marker.route ||
|
|
154
157
|
win.location.pathname.replace(/\/$/, "") ===
|
|
@@ -250,6 +253,7 @@ export function createInspectorRuntime(options) {
|
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
let lastPath = win.location.pathname;
|
|
256
|
+
let lastSearch = win.location.search;
|
|
253
257
|
let refreshFrame = 0;
|
|
254
258
|
/** SPA navigation and async data swap the DOM after markers arrive. */
|
|
255
259
|
const scheduleRefresh = () => {
|
|
@@ -259,10 +263,16 @@ export function createInspectorRuntime(options) {
|
|
|
259
263
|
refreshFrame = 0;
|
|
260
264
|
if (win.location.pathname !== lastPath) {
|
|
261
265
|
lastPath = win.location.pathname;
|
|
266
|
+
lastSearch = win.location.search;
|
|
262
267
|
// The selection belonged to the previous page.
|
|
263
268
|
if (selected)
|
|
264
269
|
clearSelection();
|
|
265
|
-
options.onRouteChange?.(lastPath);
|
|
270
|
+
options.onRouteChange?.(lastPath, win.location.href);
|
|
271
|
+
}
|
|
272
|
+
else if (win.location.search !== lastSearch) {
|
|
273
|
+
// Same page, new query (filters, tabs): report it, keep the selection.
|
|
274
|
+
lastSearch = win.location.search;
|
|
275
|
+
options.onRouteChange?.(lastPath, win.location.href);
|
|
266
276
|
}
|
|
267
277
|
else if (selected && !selected.isConnected) {
|
|
268
278
|
// The app re-rendered without the selected element.
|
|
@@ -326,7 +336,18 @@ export function createInspectorRuntime(options) {
|
|
|
326
336
|
refreshMarkers();
|
|
327
337
|
},
|
|
328
338
|
getElementByRefId: (id) => refIdToElement.get(id) ?? null,
|
|
339
|
+
applyStyleOverrides: (id, styles) => {
|
|
340
|
+
const el = refIdToElement.get(id);
|
|
341
|
+
if (!el?.isConnected)
|
|
342
|
+
return;
|
|
343
|
+
styleOverrides.apply(el, styles);
|
|
344
|
+
if (el === selected) {
|
|
345
|
+
positionSelectedHighlight(overlay.selectedHighlight, rectForElement(el));
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
clearStyleOverrides: () => styleOverrides.clearAll(),
|
|
329
349
|
destroy: () => {
|
|
350
|
+
styleOverrides.clearAll();
|
|
330
351
|
if (enabled) {
|
|
331
352
|
enabled = false;
|
|
332
353
|
teardownListeners();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computed styles the Viewer's Design tab shows and edits, and live overrides
|
|
3
|
+
* of them. Overrides are inline `!important` declarations so they win over
|
|
4
|
+
* class-based styles; the element's original `style` attribute is restored
|
|
5
|
+
* when they are cleared.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DESIGN_STYLE_PROPERTIES: readonly ["display", "position", "width", "height", "padding-top", "padding-right", "padding-bottom", "padding-left", "margin-top", "margin-right", "margin-bottom", "margin-left", "gap", "flex-direction", "justify-content", "align-items", "background-color", "background-image", "opacity", "border-top-width", "border-top-style", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-bottom-right-radius", "border-bottom-left-radius", "box-shadow", "color", "font-family", "font-size", "font-weight", "line-height", "letter-spacing", "text-align", "text-transform", "text-decoration-line"];
|
|
8
|
+
export declare function readDesignStyles(el: Element, win: Window): Record<string, string>;
|
|
9
|
+
export type StyleOverrides = {
|
|
10
|
+
/** Replaces all overrides on `el`; an empty object restores it. */
|
|
11
|
+
apply: (el: Element, styles: Record<string, string>) => void;
|
|
12
|
+
clearAll: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function createStyleOverrides(): StyleOverrides;
|
|
15
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/runtime/styles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,0mBAqC1B,CAAC;AAIX,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,MAAM,GACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB;AAYD,MAAM,MAAM,cAAc,GAAG;IAC3B,mEAAmE;IACnE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAC7D,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,wBAAgB,oBAAoB,IAAI,cAAc,CA+BrD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computed styles the Viewer's Design tab shows and edits, and live overrides
|
|
3
|
+
* of them. Overrides are inline `!important` declarations so they win over
|
|
4
|
+
* class-based styles; the element's original `style` attribute is restored
|
|
5
|
+
* when they are cleared.
|
|
6
|
+
*/
|
|
7
|
+
export const DESIGN_STYLE_PROPERTIES = [
|
|
8
|
+
"display",
|
|
9
|
+
"position",
|
|
10
|
+
"width",
|
|
11
|
+
"height",
|
|
12
|
+
"padding-top",
|
|
13
|
+
"padding-right",
|
|
14
|
+
"padding-bottom",
|
|
15
|
+
"padding-left",
|
|
16
|
+
"margin-top",
|
|
17
|
+
"margin-right",
|
|
18
|
+
"margin-bottom",
|
|
19
|
+
"margin-left",
|
|
20
|
+
"gap",
|
|
21
|
+
"flex-direction",
|
|
22
|
+
"justify-content",
|
|
23
|
+
"align-items",
|
|
24
|
+
"background-color",
|
|
25
|
+
"background-image",
|
|
26
|
+
"opacity",
|
|
27
|
+
"border-top-width",
|
|
28
|
+
"border-top-style",
|
|
29
|
+
"border-top-color",
|
|
30
|
+
"border-top-left-radius",
|
|
31
|
+
"border-top-right-radius",
|
|
32
|
+
"border-bottom-right-radius",
|
|
33
|
+
"border-bottom-left-radius",
|
|
34
|
+
"box-shadow",
|
|
35
|
+
"color",
|
|
36
|
+
"font-family",
|
|
37
|
+
"font-size",
|
|
38
|
+
"font-weight",
|
|
39
|
+
"line-height",
|
|
40
|
+
"letter-spacing",
|
|
41
|
+
"text-align",
|
|
42
|
+
"text-transform",
|
|
43
|
+
"text-decoration-line",
|
|
44
|
+
];
|
|
45
|
+
const ALLOWED = new Set(DESIGN_STYLE_PROPERTIES);
|
|
46
|
+
export function readDesignStyles(el, win) {
|
|
47
|
+
const computed = win.getComputedStyle(el);
|
|
48
|
+
const styles = {};
|
|
49
|
+
for (const property of DESIGN_STYLE_PROPERTIES) {
|
|
50
|
+
styles[property] = computed.getPropertyValue(property).trim();
|
|
51
|
+
}
|
|
52
|
+
return styles;
|
|
53
|
+
}
|
|
54
|
+
/** Shorthands the Design tab may send besides the longhands above. */
|
|
55
|
+
const SHORTHANDS = new Set([
|
|
56
|
+
"padding",
|
|
57
|
+
"margin",
|
|
58
|
+
"border-width",
|
|
59
|
+
"border-style",
|
|
60
|
+
"border-color",
|
|
61
|
+
"border-radius",
|
|
62
|
+
]);
|
|
63
|
+
export function createStyleOverrides() {
|
|
64
|
+
const originals = new Map();
|
|
65
|
+
const restore = (el) => {
|
|
66
|
+
if (!originals.has(el))
|
|
67
|
+
return;
|
|
68
|
+
const original = originals.get(el) ?? null;
|
|
69
|
+
if (original === null)
|
|
70
|
+
el.removeAttribute("style");
|
|
71
|
+
else
|
|
72
|
+
el.setAttribute("style", original);
|
|
73
|
+
originals.delete(el);
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
apply: (el, styles) => {
|
|
77
|
+
if (!(el instanceof HTMLElement || el instanceof SVGElement))
|
|
78
|
+
return;
|
|
79
|
+
restore(el);
|
|
80
|
+
const entries = Object.entries(styles).filter(([property, value]) => (ALLOWED.has(property) || SHORTHANDS.has(property)) &&
|
|
81
|
+
typeof value === "string" &&
|
|
82
|
+
value.length <= 500);
|
|
83
|
+
if (entries.length === 0)
|
|
84
|
+
return;
|
|
85
|
+
originals.set(el, el.getAttribute("style"));
|
|
86
|
+
for (const [property, value] of entries) {
|
|
87
|
+
el.style.setProperty(property, value, "important");
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
clearAll: () => {
|
|
91
|
+
for (const el of [...originals.keys()])
|
|
92
|
+
restore(el);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,93 +0,0 @@
|
|
|
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
|
-
}
|