@imean/sdk
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -8,2 +8,3 @@ "use strict"; | ||
var _a; | ||
var stopReplayInner; | ||
var isNewReplay = false; | ||
@@ -18,4 +19,4 @@ var handle = function (e) { | ||
}; | ||
STATE.steps = STATE.steps.filter(function (x) { return ['click', 'dblclick'].includes(x.type); }); | ||
(0, render_1.default)(STATE); | ||
STATE.steps = STATE.steps.filter(function (x) { return ['click', 'dblclick', 'type'].includes(x.type); }); | ||
stopReplayInner = (0, render_1.default)(STATE); | ||
} | ||
@@ -31,3 +32,4 @@ }; | ||
var STATE = JSON.parse(localStorage.getItem(def_1.STORAGE_KEY) || ''); | ||
(0, render_1.default)(STATE); | ||
console.log('localStorage', STATE); | ||
stopReplayInner = (0, render_1.default)(STATE); | ||
} | ||
@@ -37,3 +39,9 @@ catch (error) { | ||
} | ||
}, 1000); | ||
}, 2000); | ||
window.addEventListener('message', function (e) { | ||
console.log('stop_replay'); | ||
if (e.data && e.data.method === 'stop_replay') { | ||
stopReplayInner(); | ||
} | ||
}); | ||
}; | ||
@@ -40,0 +48,0 @@ exports.default = { |
import { ISTATE } from '../def'; | ||
export default function render(STATE: ISTATE): void; | ||
export default function render(STATE: ISTATE): () => void; |
@@ -67,3 +67,3 @@ "use strict"; | ||
step = STATE.steps[STATE.currentIndex]; | ||
if (!step || (step.type !== 'click' && step.type !== 'dblclick')) { | ||
if (!step || (step.type !== 'click' && step.type !== 'dblclick' && step.type !== 'type')) { | ||
(0, setCss_1.default)(elMain, { | ||
@@ -81,29 +81,4 @@ display: 'none', | ||
var func = function () { | ||
offset -= 1000; | ||
var elTemp; | ||
// const reg = /html\>body\:nth\-child\((\d*)\)\>([a-zA-Z]*)\:nth\-child\((\d*)\)/; | ||
// const match = step.selector.match(reg); | ||
// if (match && match[1] && match[2] && match[3]) { | ||
// const bodyCount = match[1]; | ||
// const tagName = match[2]; | ||
// const count = parseInt(match[3], 10); | ||
// console.log('count', count); | ||
// if (!isNaN(count)) { | ||
// for (let index = count - 2; index < count + 2; index++) { | ||
// const selector = step.selector.replace( | ||
// reg, | ||
// `html>body:nth-child(${bodyCount})>${tagName}:nth-of-type(${index})`, | ||
// ); | ||
// console.log('selector', selector); | ||
// const temp = document.querySelector(selector) as HTMLElement; | ||
// if (temp) { | ||
// elTemp = temp; | ||
// break; | ||
// } | ||
// } | ||
// } | ||
// } | ||
if (!elTemp) { | ||
elTemp = document.querySelector(step.selector); | ||
} | ||
offset -= 200; | ||
var elTemp = document.querySelector(step.selector); | ||
if (elTemp) { | ||
@@ -115,3 +90,3 @@ resolve({ el: elTemp }); | ||
if (offset >= 0) { | ||
elTimer = setTimeout(func, 1000); | ||
elTimer = setTimeout(func, 200); | ||
} | ||
@@ -123,3 +98,5 @@ else { | ||
}; | ||
func(); | ||
setTimeout(function () { | ||
func(); | ||
}, 200); | ||
})]; | ||
@@ -130,7 +107,7 @@ case 1: | ||
if (!el) { | ||
timer_1 = setInterval(function () { | ||
timer_1 = setTimeout(function () { | ||
refresh(); | ||
}, 2000); | ||
onDestory.push(function () { | ||
clearInterval(timer_1); | ||
clearTimeout(timer_1); | ||
}); | ||
@@ -189,3 +166,3 @@ (0, setCss_1.default)(elMain, { | ||
} | ||
var padding = 20; | ||
var padding = 10; | ||
var box = [rect.left - padding / 2, rect.top - padding / 2, rect.width + padding, rect.height + padding]; | ||
@@ -238,3 +215,3 @@ (0, setCss_1.default)(elOver, { | ||
ctx.fillStyle = 'rgba(0,0,0,1)'; | ||
ctx.fillRect(box[0], box[1], box[2], box[3]); | ||
ctx.fillRect(box[0] + 1, box[1] + 1, box[2], box[3]); // +1 是border的一半 | ||
ctx.restore(); | ||
@@ -276,3 +253,4 @@ }; | ||
dblclick: '双击', | ||
}[step.type] + " " + (step.value || ''); | ||
type: '输入', | ||
}[step.type] + " " + (step.type === 'type' ? '' : step.value || ''); | ||
elStepsCount.innerHTML = "\u4E0B\u4E00\u6B65 " + (STATE.currentIndex + 1) + "/" + STATE.steps.length; | ||
@@ -284,3 +262,8 @@ return [2 /*return*/]; | ||
refresh(); | ||
return function () { | ||
STATE.currentIndex = -1; | ||
STATE.steps = []; | ||
refresh(); | ||
}; | ||
} | ||
exports.default = render; |
{ | ||
"name": "@imean/sdk", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "lib/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52980
1215