@oyerinde/caliper 0.2.0 → 0.2.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.
- package/CHANGELOG.md +27 -0
- package/README.md +1 -9
- package/dist/bridge.cjs +12 -12
- package/dist/bridge.d.cts +3 -1
- package/dist/bridge.d.ts +3 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-3W2YKDGV.cjs → chunk-2SVFU7M3.cjs} +77 -29
- package/dist/{chunk-OSQHATBH.cjs → chunk-AHX2GS7J.cjs} +79 -44
- package/dist/{chunk-ACV6FK43.js → chunk-PRUCSUJA.js} +78 -30
- package/dist/{chunk-XYBNY4BT.js → chunk-YLE25XII.js} +79 -44
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +19 -16
- package/dist/index.d.ts +19 -16
- package/dist/index.global.js +12 -12
- package/dist/index.global.js.map +1 -1
- package/dist/index.global.min.js +4 -4
- package/dist/index.global.min.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +88 -52
- package/dist/mcp.js +89 -53
- package/dist/preset.cjs +6 -6
- package/dist/preset.d.cts +20 -20
- package/dist/preset.d.ts +20 -20
- package/dist/preset.js +3 -3
- package/dist/version.json +2 -2
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { JSONRPCErrorResponseSchema as JSONRPCErrorResponseSchema$1
|
|
2
|
+
import { JSONRPCErrorResponseSchema as JSONRPCErrorResponseSchema$1 } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @name @oyerinde/caliper
|
|
@@ -228,7 +228,6 @@ var WalkOptionsSchema = z.object({
|
|
|
228
228
|
minElementSize: z.number().optional(),
|
|
229
229
|
ignoreSelectors: z.array(z.string()).optional()
|
|
230
230
|
});
|
|
231
|
-
var JSONRPCResultResponseSchema = JSONRPCResultResponseSchema$1;
|
|
232
231
|
var JSONRPCErrorResponseSchema = JSONRPCErrorResponseSchema$1;
|
|
233
232
|
var ViewportSchema = z.object({
|
|
234
233
|
width: z.number(),
|
|
@@ -288,8 +287,20 @@ var SourceHintsSchema = z.object({
|
|
|
288
287
|
tagName: z.string()
|
|
289
288
|
});
|
|
290
289
|
var CaliperActionResultSchema = z.union([
|
|
291
|
-
z.object({
|
|
292
|
-
|
|
290
|
+
z.object({
|
|
291
|
+
success: z.literal(true),
|
|
292
|
+
method: z.literal(CALIPER_METHODS.SELECT),
|
|
293
|
+
selector: z.string(),
|
|
294
|
+
selection: SelectionMetadataSchema,
|
|
295
|
+
timestamp: z.number()
|
|
296
|
+
}),
|
|
297
|
+
z.object({
|
|
298
|
+
success: z.literal(true),
|
|
299
|
+
method: z.literal(CALIPER_METHODS.MEASURE),
|
|
300
|
+
selector: z.string(),
|
|
301
|
+
measurement: MeasurementResultSchema,
|
|
302
|
+
timestamp: z.number()
|
|
303
|
+
}),
|
|
293
304
|
z.object({
|
|
294
305
|
success: z.literal(true),
|
|
295
306
|
method: z.literal(CALIPER_METHODS.INSPECT),
|
|
@@ -310,8 +321,16 @@ var CaliperActionResultSchema = z.union([
|
|
|
310
321
|
sourceHints: SourceHintsSchema.optional(),
|
|
311
322
|
timestamp: z.number()
|
|
312
323
|
}),
|
|
313
|
-
z.object({
|
|
314
|
-
|
|
324
|
+
z.object({
|
|
325
|
+
success: z.literal(true),
|
|
326
|
+
method: z.literal(CALIPER_METHODS.FREEZE),
|
|
327
|
+
timestamp: z.number()
|
|
328
|
+
}),
|
|
329
|
+
z.object({
|
|
330
|
+
success: z.literal(true),
|
|
331
|
+
method: z.literal(CALIPER_METHODS.CLEAR),
|
|
332
|
+
timestamp: z.number()
|
|
333
|
+
}),
|
|
315
334
|
z.object({
|
|
316
335
|
success: z.literal(true),
|
|
317
336
|
method: z.literal(CALIPER_METHODS.WALK_DOM),
|
|
@@ -398,11 +417,7 @@ var CaliperNotificationSchema = z.union([
|
|
|
398
417
|
params: CaliperAgentStateSchema
|
|
399
418
|
})
|
|
400
419
|
]);
|
|
401
|
-
z.union([
|
|
402
|
-
CaliperResponseSchema,
|
|
403
|
-
CaliperNotificationSchema,
|
|
404
|
-
JSONRPCResultResponseSchema
|
|
405
|
-
]);
|
|
420
|
+
z.union([CaliperResponseSchema, CaliperNotificationSchema]);
|
|
406
421
|
var CaliperSelectPayloadSchema = z.object({
|
|
407
422
|
selector: z.string()
|
|
408
423
|
});
|
|
@@ -1360,10 +1375,12 @@ var Logger = class {
|
|
|
1360
1375
|
isGlobalEnabled = enabled;
|
|
1361
1376
|
}
|
|
1362
1377
|
debug(...args) {
|
|
1363
|
-
return;
|
|
1378
|
+
if (!isGlobalEnabled) return;
|
|
1379
|
+
console.debug(this.prefix, ...args);
|
|
1364
1380
|
}
|
|
1365
1381
|
info(...args) {
|
|
1366
|
-
return;
|
|
1382
|
+
if (!isGlobalEnabled) return;
|
|
1383
|
+
console.info(this.prefix, ...args);
|
|
1367
1384
|
}
|
|
1368
1385
|
warn(...args) {
|
|
1369
1386
|
if (!isGlobalEnabled) return;
|
|
@@ -1374,7 +1391,8 @@ var Logger = class {
|
|
|
1374
1391
|
console.error(this.prefix, ...args);
|
|
1375
1392
|
}
|
|
1376
1393
|
log(...args) {
|
|
1377
|
-
return;
|
|
1394
|
+
if (!isGlobalEnabled) return;
|
|
1395
|
+
console.log(this.prefix, ...args);
|
|
1378
1396
|
}
|
|
1379
1397
|
};
|
|
1380
1398
|
new Logger({ prefix: "Caliper" });
|
|
@@ -15072,7 +15090,7 @@ var JSONRPCNotificationSchema = object({
|
|
|
15072
15090
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
15073
15091
|
...NotificationSchema.shape
|
|
15074
15092
|
}).strict();
|
|
15075
|
-
var
|
|
15093
|
+
var JSONRPCResultResponseSchema = object({
|
|
15076
15094
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
15077
15095
|
id: RequestIdSchema,
|
|
15078
15096
|
result: ResultSchema
|
|
@@ -15109,10 +15127,10 @@ var JSONRPCErrorResponseSchema2 = object({
|
|
|
15109
15127
|
union([
|
|
15110
15128
|
JSONRPCRequestSchema,
|
|
15111
15129
|
JSONRPCNotificationSchema,
|
|
15112
|
-
|
|
15130
|
+
JSONRPCResultResponseSchema,
|
|
15113
15131
|
JSONRPCErrorResponseSchema2
|
|
15114
15132
|
]);
|
|
15115
|
-
union([
|
|
15133
|
+
union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema2]);
|
|
15116
15134
|
var EmptyResultSchema = ResultSchema.strict();
|
|
15117
15135
|
var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
15118
15136
|
/**
|
|
@@ -16676,7 +16694,7 @@ var WalkOptionsSchema2 = external_exports.object({
|
|
|
16676
16694
|
});
|
|
16677
16695
|
var JSONRPCRequestSchema2 = JSONRPCRequestSchema;
|
|
16678
16696
|
var JSONRPCNotificationSchema2 = JSONRPCNotificationSchema;
|
|
16679
|
-
var
|
|
16697
|
+
var JSONRPCResultResponseSchema2 = JSONRPCResultResponseSchema;
|
|
16680
16698
|
var JSONRPCErrorResponseSchema22 = JSONRPCErrorResponseSchema2;
|
|
16681
16699
|
var ViewportSchema2 = external_exports.object({
|
|
16682
16700
|
width: external_exports.number(),
|
|
@@ -16736,8 +16754,20 @@ var SourceHintsSchema2 = external_exports.object({
|
|
|
16736
16754
|
tagName: external_exports.string()
|
|
16737
16755
|
});
|
|
16738
16756
|
var CaliperActionResultSchema2 = external_exports.union([
|
|
16739
|
-
external_exports.object({
|
|
16740
|
-
|
|
16757
|
+
external_exports.object({
|
|
16758
|
+
success: external_exports.literal(true),
|
|
16759
|
+
method: external_exports.literal(CALIPER_METHODS2.SELECT),
|
|
16760
|
+
selector: external_exports.string(),
|
|
16761
|
+
selection: SelectionMetadataSchema2,
|
|
16762
|
+
timestamp: external_exports.number()
|
|
16763
|
+
}),
|
|
16764
|
+
external_exports.object({
|
|
16765
|
+
success: external_exports.literal(true),
|
|
16766
|
+
method: external_exports.literal(CALIPER_METHODS2.MEASURE),
|
|
16767
|
+
selector: external_exports.string(),
|
|
16768
|
+
measurement: MeasurementResultSchema2,
|
|
16769
|
+
timestamp: external_exports.number()
|
|
16770
|
+
}),
|
|
16741
16771
|
external_exports.object({
|
|
16742
16772
|
success: external_exports.literal(true),
|
|
16743
16773
|
method: external_exports.literal(CALIPER_METHODS2.INSPECT),
|
|
@@ -16758,8 +16788,16 @@ var CaliperActionResultSchema2 = external_exports.union([
|
|
|
16758
16788
|
sourceHints: SourceHintsSchema2.optional(),
|
|
16759
16789
|
timestamp: external_exports.number()
|
|
16760
16790
|
}),
|
|
16761
|
-
external_exports.object({
|
|
16762
|
-
|
|
16791
|
+
external_exports.object({
|
|
16792
|
+
success: external_exports.literal(true),
|
|
16793
|
+
method: external_exports.literal(CALIPER_METHODS2.FREEZE),
|
|
16794
|
+
timestamp: external_exports.number()
|
|
16795
|
+
}),
|
|
16796
|
+
external_exports.object({
|
|
16797
|
+
success: external_exports.literal(true),
|
|
16798
|
+
method: external_exports.literal(CALIPER_METHODS2.CLEAR),
|
|
16799
|
+
timestamp: external_exports.number()
|
|
16800
|
+
}),
|
|
16763
16801
|
external_exports.object({
|
|
16764
16802
|
success: external_exports.literal(true),
|
|
16765
16803
|
method: external_exports.literal(CALIPER_METHODS2.WALK_DOM),
|
|
@@ -16819,13 +16857,21 @@ var RpcFactory = class {
|
|
|
16819
16857
|
return JSONRPCRequestSchema2.parse({ jsonrpc: "2.0", method, params, id });
|
|
16820
16858
|
}
|
|
16821
16859
|
static response(id, result) {
|
|
16822
|
-
return
|
|
16860
|
+
return JSONRPCResultResponseSchema2.parse({ jsonrpc: "2.0", id, result });
|
|
16823
16861
|
}
|
|
16824
16862
|
static error(id, code, message, data) {
|
|
16825
|
-
return JSONRPCErrorResponseSchema22.parse({
|
|
16863
|
+
return JSONRPCErrorResponseSchema22.parse({
|
|
16864
|
+
jsonrpc: "2.0",
|
|
16865
|
+
id,
|
|
16866
|
+
error: { code, message, data }
|
|
16867
|
+
});
|
|
16826
16868
|
}
|
|
16827
16869
|
static notification(method, params) {
|
|
16828
|
-
return JSONRPCNotificationSchema2.parse({
|
|
16870
|
+
return JSONRPCNotificationSchema2.parse({
|
|
16871
|
+
jsonrpc: "2.0",
|
|
16872
|
+
method,
|
|
16873
|
+
params
|
|
16874
|
+
});
|
|
16829
16875
|
}
|
|
16830
16876
|
};
|
|
16831
16877
|
var CaliperResponseSchema2 = external_exports.union([
|
|
@@ -16860,11 +16906,7 @@ var CaliperNotificationSchema2 = external_exports.union([
|
|
|
16860
16906
|
params: CaliperAgentStateSchema2
|
|
16861
16907
|
})
|
|
16862
16908
|
]);
|
|
16863
|
-
external_exports.union([
|
|
16864
|
-
CaliperResponseSchema2,
|
|
16865
|
-
CaliperNotificationSchema2,
|
|
16866
|
-
JSONRPCResultResponseSchema22
|
|
16867
|
-
]);
|
|
16909
|
+
external_exports.union([CaliperResponseSchema2, CaliperNotificationSchema2]);
|
|
16868
16910
|
external_exports.object({
|
|
16869
16911
|
selector: external_exports.string()
|
|
16870
16912
|
});
|
|
@@ -18562,6 +18604,12 @@ function CaliperBridge(config2) {
|
|
|
18562
18604
|
const disposeSync = initStateSync(stateStore, systems, (state) => {
|
|
18563
18605
|
wsBridge.sendStateUpdate(state);
|
|
18564
18606
|
config2.onStateChange?.(state);
|
|
18607
|
+
if (config2.onStateChangeGlobal) {
|
|
18608
|
+
const globalCallback = window[config2.onStateChangeGlobal];
|
|
18609
|
+
if (typeof globalCallback === "function") {
|
|
18610
|
+
globalCallback(state);
|
|
18611
|
+
}
|
|
18612
|
+
}
|
|
18565
18613
|
});
|
|
18566
18614
|
window.dispatchCaliperIntent = async (intent) => {
|
|
18567
18615
|
if (!intentHandler) {
|
|
@@ -2850,8 +2850,7 @@ function getConfig() {
|
|
|
2850
2850
|
...parsed,
|
|
2851
2851
|
theme: { ...windowConfig.theme, ...parsed.theme },
|
|
2852
2852
|
commands: { ...windowConfig.commands, ...parsed.commands },
|
|
2853
|
-
animation: { ...windowConfig.animation, ...parsed.animation }
|
|
2854
|
-
bridge: { ...windowConfig.bridge, ...parsed.bridge }
|
|
2853
|
+
animation: { ...windowConfig.animation, ...parsed.animation }
|
|
2855
2854
|
};
|
|
2856
2855
|
} catch (e) {
|
|
2857
2856
|
console.warn("[CALIPER] Failed to parse data-config attribute", e);
|
|
@@ -3031,10 +3030,12 @@ var Logger = class {
|
|
|
3031
3030
|
isGlobalEnabled = enabled;
|
|
3032
3031
|
}
|
|
3033
3032
|
debug(...args) {
|
|
3034
|
-
return;
|
|
3033
|
+
if (!isGlobalEnabled) return;
|
|
3034
|
+
console.debug(this.prefix, ...args);
|
|
3035
3035
|
}
|
|
3036
3036
|
info(...args) {
|
|
3037
|
-
return;
|
|
3037
|
+
if (!isGlobalEnabled) return;
|
|
3038
|
+
console.info(this.prefix, ...args);
|
|
3038
3039
|
}
|
|
3039
3040
|
warn(...args) {
|
|
3040
3041
|
if (!isGlobalEnabled) return;
|
|
@@ -3045,7 +3046,8 @@ var Logger = class {
|
|
|
3045
3046
|
console.error(this.prefix, ...args);
|
|
3046
3047
|
}
|
|
3047
3048
|
log(...args) {
|
|
3048
|
-
return;
|
|
3049
|
+
if (!isGlobalEnabled) return;
|
|
3050
|
+
console.log(this.prefix, ...args);
|
|
3049
3051
|
}
|
|
3050
3052
|
};
|
|
3051
3053
|
var logger = new Logger({ prefix: "Caliper" });
|
|
@@ -3434,11 +3436,11 @@ function MeasurementLinesWithCalculator(props) {
|
|
|
3434
3436
|
};
|
|
3435
3437
|
}
|
|
3436
3438
|
if (line.type === "top" || line.type === "bottom") {
|
|
3437
|
-
if (line.
|
|
3438
|
-
else
|
|
3439
|
+
if (line.type === "top") start.x = end.x;
|
|
3440
|
+
else end.x = start.x;
|
|
3439
3441
|
} else if (line.type === "left" || line.type === "right") {
|
|
3440
|
-
if (line.
|
|
3441
|
-
else
|
|
3442
|
+
if (line.type === "left") start.y = end.y;
|
|
3443
|
+
else end.y = start.y;
|
|
3442
3444
|
}
|
|
3443
3445
|
let liveValue = 0;
|
|
3444
3446
|
if (line.type === "top" || line.type === "bottom") {
|
|
@@ -3536,11 +3538,11 @@ function MeasurementLabels(props) {
|
|
|
3536
3538
|
};
|
|
3537
3539
|
}
|
|
3538
3540
|
if (line.type === "top" || line.type === "bottom") {
|
|
3539
|
-
if (line.
|
|
3540
|
-
else
|
|
3541
|
+
if (line.type === "top") start.x = end.x;
|
|
3542
|
+
else end.x = start.x;
|
|
3541
3543
|
} else if (line.type === "left" || line.type === "right") {
|
|
3542
|
-
if (line.
|
|
3543
|
-
else
|
|
3544
|
+
if (line.type === "left") start.y = end.y;
|
|
3545
|
+
else end.y = start.y;
|
|
3544
3546
|
}
|
|
3545
3547
|
const naturalX = (start.x + end.x) / 2;
|
|
3546
3548
|
const naturalY = (start.y + end.y) / 2;
|
|
@@ -3755,16 +3757,27 @@ function BoundaryBoxes(props) {
|
|
|
3755
3757
|
height: next.height
|
|
3756
3758
|
};
|
|
3757
3759
|
};
|
|
3758
|
-
const
|
|
3760
|
+
const isDegenerate = (geo) => geo !== null && geo.width === 0 && geo.height === 0;
|
|
3761
|
+
const liveSelectionTarget = createMemo((prev) => {
|
|
3759
3762
|
props.viewport.version;
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
+
if (prev && props.metadata.element && !document.contains(props.metadata.element)) {
|
|
3764
|
+
return prev;
|
|
3765
|
+
}
|
|
3766
|
+
const geo = getLiveGeometry(props.metadata.rect, props.metadata.scrollHierarchy, props.metadata.position, props.metadata.stickyConfig, props.metadata.initialWindowX, props.metadata.initialWindowY);
|
|
3767
|
+
if (isDegenerate(geo)) return prev;
|
|
3768
|
+
return geo;
|
|
3769
|
+
}, null);
|
|
3770
|
+
const liveSecondaryTarget = createMemo((prev) => {
|
|
3763
3771
|
props.viewport.version;
|
|
3764
3772
|
const res = props.result;
|
|
3765
3773
|
if (!(props.isActivatePressed || props.isFrozen) || !res) return null;
|
|
3766
|
-
|
|
3767
|
-
|
|
3774
|
+
if (prev && res.secondaryElement && !document.contains(res.secondaryElement)) {
|
|
3775
|
+
return prev;
|
|
3776
|
+
}
|
|
3777
|
+
const geo = getLiveGeometry(res.secondary, res.secondaryHierarchy, res.secondaryPosition, res.secondarySticky, res.secondaryWinX, res.secondaryWinY);
|
|
3778
|
+
if (isDegenerate(geo)) return prev;
|
|
3779
|
+
return geo;
|
|
3780
|
+
}, null);
|
|
3768
3781
|
createEffect(on([liveSelectionTarget, liveSecondaryTarget, () => props.animation.lerpFactor, () => props.metadata.element], ([selection, secondary, factor, element]) => {
|
|
3769
3782
|
if (!selection) {
|
|
3770
3783
|
setAnchor(null);
|
|
@@ -5093,27 +5106,48 @@ function Root(config) {
|
|
|
5093
5106
|
contextEvent.preventDefault();
|
|
5094
5107
|
contextEvent.stopImmediatePropagation();
|
|
5095
5108
|
let clipboardContent = "";
|
|
5096
|
-
if (contextEvent.shiftKey
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
})
|
|
5113
|
-
}
|
|
5109
|
+
if (contextEvent.shiftKey) {
|
|
5110
|
+
if (measurementResult && system && selectionSystem) {
|
|
5111
|
+
const primaryElement = selectionSystem.getSelected();
|
|
5112
|
+
const secondaryElement = system.getSecondaryElement();
|
|
5113
|
+
if (primaryElement && secondaryElement) {
|
|
5114
|
+
clipboardContent = JSON.stringify({
|
|
5115
|
+
primary: buildSelectorInfo(primaryElement, selectionMetadata()),
|
|
5116
|
+
secondary: buildSelectorInfo(secondaryElement, {
|
|
5117
|
+
rect: measurementResult.secondary,
|
|
5118
|
+
scrollHierarchy: measurementResult.secondaryHierarchy,
|
|
5119
|
+
position: measurementResult.secondaryPosition,
|
|
5120
|
+
stickyConfig: measurementResult.secondarySticky,
|
|
5121
|
+
initialWindowX: measurementResult.secondaryWinX,
|
|
5122
|
+
initialWindowY: measurementResult.secondaryWinY,
|
|
5123
|
+
hasContainingBlock: measurementResult.secondaryHasContainingBlock
|
|
5124
|
+
})
|
|
5125
|
+
});
|
|
5126
|
+
}
|
|
5127
|
+
} else if (selectedElement) {
|
|
5128
|
+
clipboardContent = JSON.stringify(buildSelectorInfo(selectedElement, selectionMetadata()));
|
|
5129
|
+
}
|
|
5130
|
+
} else {
|
|
5131
|
+
const ensureAgentId = (el) => {
|
|
5132
|
+
let id = el.getAttribute("data-caliper-agent-id");
|
|
5133
|
+
if (!id) {
|
|
5134
|
+
id = generateId("caliper");
|
|
5135
|
+
el.setAttribute("data-caliper-agent-id", id);
|
|
5136
|
+
}
|
|
5137
|
+
return id;
|
|
5138
|
+
};
|
|
5139
|
+
if (measurementResult && system && selectionSystem) {
|
|
5140
|
+
const primaryElement = selectionSystem.getSelected();
|
|
5141
|
+
const secondaryElement = system.getSecondaryElement();
|
|
5142
|
+
if (primaryElement && secondaryElement) {
|
|
5143
|
+
clipboardContent = JSON.stringify({
|
|
5144
|
+
primary: ensureAgentId(primaryElement),
|
|
5145
|
+
secondary: ensureAgentId(secondaryElement)
|
|
5146
|
+
});
|
|
5147
|
+
}
|
|
5148
|
+
} else if (selectedElement) {
|
|
5149
|
+
clipboardContent = ensureAgentId(selectedElement);
|
|
5114
5150
|
}
|
|
5115
|
-
} else if (selectedElement) {
|
|
5116
|
-
clipboardContent = JSON.stringify(buildSelectorInfo(selectedElement, selectionMetadata()));
|
|
5117
5151
|
}
|
|
5118
5152
|
if (clipboardContent) {
|
|
5119
5153
|
navigator.clipboard.writeText(clipboardContent).then(() => {
|
|
@@ -5170,12 +5204,13 @@ function Root(config) {
|
|
|
5170
5204
|
if (selectedElement) {
|
|
5171
5205
|
const hoveredElement = getTopElementAtPoint(e.clientX, e.clientY);
|
|
5172
5206
|
const isAncestor = hoveredElement && lastHoveredElement && hoveredElement.contains(lastHoveredElement) && hoveredElement !== lastHoveredElement;
|
|
5207
|
+
const lastHoveredDetached = lastHoveredElement && !document.contains(lastHoveredElement);
|
|
5173
5208
|
if (isAlt) {
|
|
5174
5209
|
if (system) {
|
|
5175
5210
|
measureDelegate.execute(!!isAncestor, selectedElement, cursorPoint, hoveredElement);
|
|
5176
5211
|
}
|
|
5177
5212
|
} else if (state !== "FROZEN") {
|
|
5178
|
-
if (hoveredElement) {
|
|
5213
|
+
if (hoveredElement && !lastHoveredDetached) {
|
|
5179
5214
|
selectionDelegate.execute(!!isAncestor, hoveredElement);
|
|
5180
5215
|
}
|
|
5181
5216
|
}
|
|
@@ -5553,14 +5588,14 @@ function Root(config) {
|
|
|
5553
5588
|
let secondaryChanged = false;
|
|
5554
5589
|
const runUpdates2 = () => {
|
|
5555
5590
|
if (sentinelResized || primaryChanged) {
|
|
5556
|
-
if (observedPrimary) {
|
|
5591
|
+
if (observedPrimary && document.contains(observedPrimary)) {
|
|
5557
5592
|
const rect = observedPrimary.getBoundingClientRect();
|
|
5558
5593
|
selectionSystem?.updateRect(rect);
|
|
5559
5594
|
if (system) system.updatePrimaryRect(rect);
|
|
5560
5595
|
}
|
|
5561
5596
|
}
|
|
5562
5597
|
if (sentinelResized || secondaryChanged) {
|
|
5563
|
-
if (observedSecondary) {
|
|
5598
|
+
if (observedSecondary && document.contains(observedSecondary)) {
|
|
5564
5599
|
const rect = observedSecondary.getBoundingClientRect();
|
|
5565
5600
|
system?.updateSecondaryRect(rect);
|
|
5566
5601
|
}
|
|
@@ -5875,11 +5910,11 @@ function createOverlay(config) {
|
|
|
5875
5910
|
return instance;
|
|
5876
5911
|
}
|
|
5877
5912
|
if (IS_BROWSER2) {
|
|
5878
|
-
showVersionInfo("0.2.
|
|
5913
|
+
showVersionInfo("0.2.2").catch(() => {
|
|
5879
5914
|
});
|
|
5880
5915
|
}
|
|
5881
5916
|
|
|
5882
5917
|
// src/index.ts
|
|
5883
|
-
var VERSION = "0.2.
|
|
5918
|
+
var VERSION = "0.2.2";
|
|
5884
5919
|
|
|
5885
5920
|
export { VERSION, caliperProps, createOverlay, getConfig, setConfig };
|
package/dist/index.cjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAHX2GS7J_cjs = require('./chunk-AHX2GS7J.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "VERSION", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkAHX2GS7J_cjs.VERSION; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "caliperProps", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkAHX2GS7J_cjs.caliperProps; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getConfig", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkAHX2GS7J_cjs.getConfig; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "init", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkAHX2GS7J_cjs.createOverlay; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "setConfig", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkAHX2GS7J_cjs.setConfig; }
|
|
26
26
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -7,6 +7,8 @@ export declare interface AgentBridgeConfig {
|
|
|
7
7
|
wsPort?: number;
|
|
8
8
|
/** Callback for agent state changes */
|
|
9
9
|
onStateChange?: (state: CaliperAgentState) => void;
|
|
10
|
+
/** Name of a global window function to call on state changes (IIFE/CDN-safe, JSON-serializable) */
|
|
11
|
+
onStateChangeGlobal?: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export declare interface AnimationConfig {
|
|
@@ -439,6 +441,17 @@ declare const CaliperAgentStateSchema: z.ZodObject<{
|
|
|
439
441
|
lastUpdated: z.ZodNumber;
|
|
440
442
|
}, z.core.$strip>;
|
|
441
443
|
|
|
444
|
+
export declare interface CaliperConfig {
|
|
445
|
+
/** Customize the visual appearance of the overlay (colors, shadows). */
|
|
446
|
+
theme?: ThemeConfig;
|
|
447
|
+
/** Customize keyboard shortcuts for all interactions. */
|
|
448
|
+
commands?: CommandsConfig;
|
|
449
|
+
/** Control the boundary box lerp animation behavior. */
|
|
450
|
+
animation?: AnimationConfig;
|
|
451
|
+
/** Enable debug logging (default: true). All logs are stripped from production builds. */
|
|
452
|
+
debug?: boolean;
|
|
453
|
+
}
|
|
454
|
+
|
|
442
455
|
/**
|
|
443
456
|
* A plugin allows extending Caliper's functionality by accessing the
|
|
444
457
|
* OverlayInstance and internal systems.
|
|
@@ -491,9 +504,9 @@ export declare interface CommandsConfig {
|
|
|
491
504
|
* 1. Global window object (`window.__CALIPER_CONFIG__`)
|
|
492
505
|
* 2. `data-config` attribute on the script tag (useful for UMD/CDN usage)
|
|
493
506
|
*
|
|
494
|
-
* @returns The resolved
|
|
507
|
+
* @returns The resolved CaliperConfig object.
|
|
495
508
|
*/
|
|
496
|
-
export declare function getConfig():
|
|
509
|
+
export declare function getConfig(): CaliperConfig;
|
|
497
510
|
|
|
498
511
|
/**
|
|
499
512
|
* Core factory function to create and mount the Caliper overlay.
|
|
@@ -523,7 +536,7 @@ export declare function getConfig(): OverlayConfig;
|
|
|
523
536
|
* @param config - The initial configuration object to merge with global defaults.
|
|
524
537
|
* @returns An OverlayInstance with mount, dispose, and plugin management capabilities.
|
|
525
538
|
*/
|
|
526
|
-
export declare function init(config?:
|
|
539
|
+
export declare function init(config?: CaliperConfig): OverlayInstance;
|
|
527
540
|
|
|
528
541
|
export declare type MeasurementLine = MeasurementLine_2;
|
|
529
542
|
|
|
@@ -729,18 +742,8 @@ export declare interface MeasurementSystem {
|
|
|
729
742
|
|
|
730
743
|
export declare type MeasurementSystemListener = () => void;
|
|
731
744
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
theme?: ThemeConfig;
|
|
735
|
-
/** Customize keyboard shortcuts for all interactions. */
|
|
736
|
-
commands?: CommandsConfig;
|
|
737
|
-
/** Control the boundary box lerp animation behavior. */
|
|
738
|
-
animation?: AnimationConfig;
|
|
739
|
-
/** Configure the Agent Bridge for AI/MCP integration. */
|
|
740
|
-
bridge?: AgentBridgeConfig;
|
|
741
|
-
/** Enable debug logging (default: true). All logs are stripped from production builds. */
|
|
742
|
-
debug?: boolean;
|
|
743
|
-
}
|
|
745
|
+
/** @deprecated Use CaliperConfig instead */
|
|
746
|
+
export declare type OverlayConfig = CaliperConfig;
|
|
744
747
|
|
|
745
748
|
/**
|
|
746
749
|
* Handle to a running Caliper overlay.
|
|
@@ -948,7 +951,7 @@ export declare interface SelectionSystem {
|
|
|
948
951
|
* });
|
|
949
952
|
* ```
|
|
950
953
|
*/
|
|
951
|
-
export declare function setConfig(config:
|
|
954
|
+
export declare function setConfig(config: CaliperConfig): void;
|
|
952
955
|
|
|
953
956
|
export declare interface Systems {
|
|
954
957
|
measurementSystem: MeasurementSystem;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export declare interface AgentBridgeConfig {
|
|
|
7
7
|
wsPort?: number;
|
|
8
8
|
/** Callback for agent state changes */
|
|
9
9
|
onStateChange?: (state: CaliperAgentState) => void;
|
|
10
|
+
/** Name of a global window function to call on state changes (IIFE/CDN-safe, JSON-serializable) */
|
|
11
|
+
onStateChangeGlobal?: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export declare interface AnimationConfig {
|
|
@@ -439,6 +441,17 @@ declare const CaliperAgentStateSchema: z.ZodObject<{
|
|
|
439
441
|
lastUpdated: z.ZodNumber;
|
|
440
442
|
}, z.core.$strip>;
|
|
441
443
|
|
|
444
|
+
export declare interface CaliperConfig {
|
|
445
|
+
/** Customize the visual appearance of the overlay (colors, shadows). */
|
|
446
|
+
theme?: ThemeConfig;
|
|
447
|
+
/** Customize keyboard shortcuts for all interactions. */
|
|
448
|
+
commands?: CommandsConfig;
|
|
449
|
+
/** Control the boundary box lerp animation behavior. */
|
|
450
|
+
animation?: AnimationConfig;
|
|
451
|
+
/** Enable debug logging (default: true). All logs are stripped from production builds. */
|
|
452
|
+
debug?: boolean;
|
|
453
|
+
}
|
|
454
|
+
|
|
442
455
|
/**
|
|
443
456
|
* A plugin allows extending Caliper's functionality by accessing the
|
|
444
457
|
* OverlayInstance and internal systems.
|
|
@@ -491,9 +504,9 @@ export declare interface CommandsConfig {
|
|
|
491
504
|
* 1. Global window object (`window.__CALIPER_CONFIG__`)
|
|
492
505
|
* 2. `data-config` attribute on the script tag (useful for UMD/CDN usage)
|
|
493
506
|
*
|
|
494
|
-
* @returns The resolved
|
|
507
|
+
* @returns The resolved CaliperConfig object.
|
|
495
508
|
*/
|
|
496
|
-
export declare function getConfig():
|
|
509
|
+
export declare function getConfig(): CaliperConfig;
|
|
497
510
|
|
|
498
511
|
/**
|
|
499
512
|
* Core factory function to create and mount the Caliper overlay.
|
|
@@ -523,7 +536,7 @@ export declare function getConfig(): OverlayConfig;
|
|
|
523
536
|
* @param config - The initial configuration object to merge with global defaults.
|
|
524
537
|
* @returns An OverlayInstance with mount, dispose, and plugin management capabilities.
|
|
525
538
|
*/
|
|
526
|
-
export declare function init(config?:
|
|
539
|
+
export declare function init(config?: CaliperConfig): OverlayInstance;
|
|
527
540
|
|
|
528
541
|
export declare type MeasurementLine = MeasurementLine_2;
|
|
529
542
|
|
|
@@ -729,18 +742,8 @@ export declare interface MeasurementSystem {
|
|
|
729
742
|
|
|
730
743
|
export declare type MeasurementSystemListener = () => void;
|
|
731
744
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
theme?: ThemeConfig;
|
|
735
|
-
/** Customize keyboard shortcuts for all interactions. */
|
|
736
|
-
commands?: CommandsConfig;
|
|
737
|
-
/** Control the boundary box lerp animation behavior. */
|
|
738
|
-
animation?: AnimationConfig;
|
|
739
|
-
/** Configure the Agent Bridge for AI/MCP integration. */
|
|
740
|
-
bridge?: AgentBridgeConfig;
|
|
741
|
-
/** Enable debug logging (default: true). All logs are stripped from production builds. */
|
|
742
|
-
debug?: boolean;
|
|
743
|
-
}
|
|
745
|
+
/** @deprecated Use CaliperConfig instead */
|
|
746
|
+
export declare type OverlayConfig = CaliperConfig;
|
|
744
747
|
|
|
745
748
|
/**
|
|
746
749
|
* Handle to a running Caliper overlay.
|
|
@@ -948,7 +951,7 @@ export declare interface SelectionSystem {
|
|
|
948
951
|
* });
|
|
949
952
|
* ```
|
|
950
953
|
*/
|
|
951
|
-
export declare function setConfig(config:
|
|
954
|
+
export declare function setConfig(config: CaliperConfig): void;
|
|
952
955
|
|
|
953
956
|
export declare interface Systems {
|
|
954
957
|
measurementSystem: MeasurementSystem;
|