checkpoint-cli 0.3.5 → 0.3.6
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/index.js +1 -1
- package/dist/tracking-script-minimal.js +47 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1606,7 +1606,7 @@ const program = new commander_1.Command();
|
|
|
1606
1606
|
program
|
|
1607
1607
|
.name('checkpoint')
|
|
1608
1608
|
.description('Share your localhost with reviewers — get visual feedback directly on the page')
|
|
1609
|
-
.version('0.3.
|
|
1609
|
+
.version('0.3.6');
|
|
1610
1610
|
// ── checkpoint login ──
|
|
1611
1611
|
program
|
|
1612
1612
|
.command('login')
|
|
@@ -209,6 +209,38 @@ function buildMinimalTrackingScript() {
|
|
|
209
209
|
return score;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
function getTargetDocPoint(payload,metrics){
|
|
213
|
+
var fallback=payload&&payload.coord_fallback;
|
|
214
|
+
if(!fallback||typeof fallback!=='object') return null;
|
|
215
|
+
var docW=(typeof fallback.doc_width==='number'&&fallback.doc_width>0)
|
|
216
|
+
? fallback.doc_width
|
|
217
|
+
: (metrics.docWidth||metrics.viewWidth||1);
|
|
218
|
+
var docH=(typeof fallback.doc_height==='number'&&fallback.doc_height>0)
|
|
219
|
+
? fallback.doc_height
|
|
220
|
+
: (metrics.docHeight||metrics.viewHeight||1);
|
|
221
|
+
if(typeof fallback.doc_x_percent==='number'&&typeof fallback.doc_y_percent==='number'){
|
|
222
|
+
return {
|
|
223
|
+
x:(fallback.doc_x_percent/100)*docW,
|
|
224
|
+
y:(fallback.doc_y_percent/100)*docH
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
if(typeof fallback.x_percent==='number'&&typeof fallback.y_percent==='number'){
|
|
228
|
+
var viewW=(typeof fallback.viewport_width==='number'&&fallback.viewport_width>0)
|
|
229
|
+
? fallback.viewport_width
|
|
230
|
+
: (metrics.viewWidth||1);
|
|
231
|
+
var viewH=(typeof fallback.viewport_height==='number'&&fallback.viewport_height>0)
|
|
232
|
+
? fallback.viewport_height
|
|
233
|
+
: (metrics.viewHeight||1);
|
|
234
|
+
var scrollX=typeof fallback.scroll_x==='number'?fallback.scroll_x:metrics.scrollX;
|
|
235
|
+
var scrollY=typeof fallback.scroll_y==='number'?fallback.scroll_y:metrics.scrollY;
|
|
236
|
+
return {
|
|
237
|
+
x:(fallback.x_percent/100)*viewW+scrollX,
|
|
238
|
+
y:(fallback.y_percent/100)*viewH+scrollY
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
|
|
212
244
|
function getElementAtPoint(x,y){
|
|
213
245
|
try{
|
|
214
246
|
if(pickShield) pickShield.style.pointerEvents='none';
|
|
@@ -269,7 +301,7 @@ function buildMinimalTrackingScript() {
|
|
|
269
301
|
};
|
|
270
302
|
}
|
|
271
303
|
|
|
272
|
-
function findBySource(sourceAnchor,scope){
|
|
304
|
+
function findBySource(sourceAnchor,payload,scope){
|
|
273
305
|
if(!sourceAnchor||typeof sourceAnchor!=='object') return null;
|
|
274
306
|
var searchScope=scope||document;
|
|
275
307
|
if(sourceAnchor.explicit_id){
|
|
@@ -283,10 +315,22 @@ function buildMinimalTrackingScript() {
|
|
|
283
315
|
}catch(e){ nodes=[]; }
|
|
284
316
|
if(nodes.length>1800) nodes=nodes.slice(0,1800);
|
|
285
317
|
var best=null;
|
|
286
|
-
var bestScore
|
|
318
|
+
var bestScore=-Infinity;
|
|
319
|
+
var metrics=getMetrics();
|
|
320
|
+
var targetDocPoint=getTargetDocPoint(payload,metrics);
|
|
287
321
|
for(var i=0;i<nodes.length;i++){
|
|
288
322
|
var node=nodes[i];
|
|
289
323
|
var score=sourceMatchScore(node,sourceAnchor);
|
|
324
|
+
if(score<=0) continue;
|
|
325
|
+
if(targetDocPoint&&node.getBoundingClientRect){
|
|
326
|
+
var r=node.getBoundingClientRect();
|
|
327
|
+
var centerX=r.left+(r.width/2)+metrics.scrollX;
|
|
328
|
+
var centerY=r.top+(r.height/2)+metrics.scrollY;
|
|
329
|
+
var dx=centerX-targetDocPoint.x;
|
|
330
|
+
var dy=centerY-targetDocPoint.y;
|
|
331
|
+
var distance=Math.sqrt(dx*dx+dy*dy);
|
|
332
|
+
score-=Math.min(280,distance*0.85);
|
|
333
|
+
}
|
|
290
334
|
if(score>bestScore){
|
|
291
335
|
best=node;
|
|
292
336
|
bestScore=score;
|
|
@@ -300,7 +344,7 @@ function buildMinimalTrackingScript() {
|
|
|
300
344
|
return { coordFallback:null, strategy:'none', matchedSelector:null, status:'none' };
|
|
301
345
|
}
|
|
302
346
|
if(payload.source_anchor){
|
|
303
|
-
var match=findBySource(payload.source_anchor,document);
|
|
347
|
+
var match=findBySource(payload.source_anchor,payload,document);
|
|
304
348
|
if(match&&match.getBoundingClientRect){
|
|
305
349
|
var rect=match.getBoundingClientRect();
|
|
306
350
|
var clientX=rect.left+Math.max(1,Math.min(Math.max(2,rect.width)-1,rect.width/2));
|