Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@imean/sdk

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@imean/sdk - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

8

lib/def.d.ts

@@ -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;

9

lib/index.d.ts
declare const _default: {
init: ({ hideHelp }: {
init: ({ hideHelp, mode, }: {
/**
* 隐藏右下角帮助功能
*/
hideHelp?: boolean | undefined;
/**
* 集成模式 chrome插件 或者 网页
*/
mode?: "chrome" | "web" | undefined;
}) => void;
};
export default _default;

10

lib/index.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc