@imean/sdk
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -17,2 +17,10 @@ export declare const MAIN_REPLAY_KEY = "starblazer_sdk_MAIN_REPLAY_ID"; | ||
} | { | ||
type: 'dblclick'; | ||
host: string; | ||
hostTitle: string; | ||
selector: string; | ||
href: string; | ||
value: string; | ||
img: string; | ||
} | { | ||
type: 'type'; | ||
@@ -19,0 +27,0 @@ host: string; |
declare const _default: { | ||
init: ({ hideHelp }: { | ||
init: ({ hideHelp, mode, }: { | ||
/** | ||
* 隐藏右下角帮助功能 | ||
*/ | ||
hideHelp?: boolean | undefined; | ||
/** | ||
* 集成模式 chrome插件 或者 网页 | ||
*/ | ||
mode?: "chrome" | "web" | undefined; | ||
}) => void; | ||
}; | ||
export default _default; |
@@ -17,3 +17,3 @@ "use strict"; | ||
}; | ||
STATE.steps = STATE.steps.filter(function (x) { return x.type === 'click'; }); | ||
STATE.steps = STATE.steps.filter(function (x) { return ['click', 'dblclick'].includes(x.type); }); | ||
(0, render_1.default)(STATE); | ||
@@ -39,5 +39,9 @@ } | ||
init: function (_a) { | ||
var hideHelp = _a.hideHelp; | ||
var hideHelp = _a.hideHelp, _b = _a.mode, mode = _b === void 0 ? 'web' : _b; | ||
document.addEventListener('DOMContentLoaded', function () { | ||
console.log('init starblazer sdk'); | ||
console.log(mode, document.body.getAttribute('imean_sdk_mode')); | ||
if (document.body.getAttribute('imean_sdk_mode')) { | ||
return; | ||
} | ||
document.body.setAttribute('imean_sdk_mode', mode); | ||
init(); | ||
@@ -44,0 +48,0 @@ if (!hideHelp) { |
@@ -57,3 +57,3 @@ "use strict"; | ||
var refresh = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var step, elTimer, el, elHandle, nextHandle, rePosition, observer, timer, hanelScroll; | ||
var step, elTimer, el, timer_1, elHandle, nextHandle, rePosition, observer, timer, hanelScroll; | ||
return __generator(this, function (_a) { | ||
@@ -68,3 +68,3 @@ switch (_a.label) { | ||
step = STATE.steps[STATE.currentIndex]; | ||
if (!step || step.type !== 'click') { | ||
if (!step || (step.type !== 'click' && step.type !== 'dblclick')) { | ||
(0, setCss_1.default)(elMain, { | ||
@@ -83,23 +83,25 @@ display: 'none', | ||
offset -= 1000; | ||
var reg = /html\>body\:nth\-child\((\d*)\)\>([a-zA-Z]*)\:nth\-child\((\d*)\)/; | ||
var elTemp; | ||
var match = step.selector.match(reg); | ||
console.log('match', match); | ||
if (match && match[1] && match[2] && match[3]) { | ||
var bodyCount = match[1]; | ||
var tagName = match[2]; | ||
var count = parseInt(match[3], 10); | ||
console.log('count', count); | ||
if (!isNaN(count)) { | ||
for (var index = count - 2; index < count + 2; index++) { | ||
var selector = step.selector.replace(reg, "html>body:nth-child(" + bodyCount + ")>" + tagName + ":nth-of-type(" + index + ")"); | ||
console.log('selector', selector); | ||
var temp = document.querySelector(selector); | ||
if (temp) { | ||
elTemp = temp; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
// 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) { | ||
@@ -127,2 +129,8 @@ elTemp = document.querySelector(step.selector); | ||
if (!el) { | ||
timer_1 = setInterval(function () { | ||
refresh(); | ||
}, 2000); | ||
onDestory.push(function () { | ||
clearInterval(timer_1); | ||
}); | ||
(0, setCss_1.default)(elMain, { | ||
@@ -138,9 +146,29 @@ display: 'none', | ||
nextHandle = function () { | ||
el.click(); | ||
if (step.type === 'click') { | ||
el.click(); | ||
} | ||
else if (step.type === 'dblclick') { | ||
var event = new MouseEvent('dblclick', { | ||
view: window, | ||
bubbles: true, | ||
cancelable: true, | ||
}); | ||
el.dispatchEvent(event); | ||
} | ||
}; | ||
elStepsCount.addEventListener('click', nextHandle); | ||
el.addEventListener('click', elHandle, { once: true }); | ||
if (step.type === 'click') { | ||
el.addEventListener('click', elHandle, { once: true }); | ||
} | ||
else if (step.type === 'dblclick') { | ||
el.addEventListener('dblclick', elHandle, { once: true }); | ||
} | ||
onDestory.push(function () { | ||
elStepsCount.removeEventListener('click', nextHandle); | ||
el.removeEventListener('click', elHandle); | ||
if (step.type === 'click') { | ||
el.removeEventListener('click', elHandle); | ||
} | ||
else if (step.type === 'dblclick') { | ||
el.removeEventListener('dblclick', elHandle); | ||
} | ||
}); | ||
@@ -214,3 +242,3 @@ (0, setCss_1.default)(elMain, { | ||
}); | ||
elStepsTitle.innerHTML = step.type + " " + step.value; | ||
elStepsTitle.innerHTML = step.type + " " + (step.value || ''); | ||
elStepsCount.innerHTML = "\u4E0B\u4E00\u6B65 " + (STATE.currentIndex + 1) + "/" + STATE.steps.length; | ||
@@ -217,0 +245,0 @@ return [2 /*return*/]; |
{ | ||
"name": "@imean/sdk", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50966
1154
0