@usertour/helpers 0.0.10 → 0.0.12
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/{chunk-7IK5Q5N2.js → chunk-UT6OPCUX.js} +14 -145
- package/dist/conditions.cjs +17 -407
- package/dist/conditions.d.cts +13 -3
- package/dist/conditions.d.ts +13 -3
- package/dist/conditions.js +7 -6
- package/dist/globals.d.cts +1 -1
- package/dist/globals.d.ts +1 -1
- package/dist/index.cjs +21 -474
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +24 -33
- package/package.json +8 -10
- package/dist/chunk-DEG6MTU7.js +0 -318
- package/dist/chunk-Y6FPPOKF.js +0 -28
- package/dist/finderx.cjs +0 -346
- package/dist/finderx.d.cts +0 -47
- package/dist/finderx.d.ts +0 -47
- package/dist/finderx.js +0 -15
- package/dist/listener.cjs +0 -68
- package/dist/listener.d.cts +0 -7
- package/dist/listener.d.ts +0 -7
- package/dist/listener.js +0 -16
package/dist/index.cjs
CHANGED
|
@@ -49,6 +49,7 @@ __export(src_exports, {
|
|
|
49
49
|
checklistIsDimissed: () => checklistIsDimissed,
|
|
50
50
|
checklistIsSeen: () => checklistIsSeen,
|
|
51
51
|
cn: () => cn,
|
|
52
|
+
completeEventMapping: () => completeEventMapping,
|
|
52
53
|
conditionsIsSame: () => conditionsIsSame,
|
|
53
54
|
convertSettings: () => convertSettings,
|
|
54
55
|
convertToCssVars: () => convertToCssVars,
|
|
@@ -56,14 +57,11 @@ __export(src_exports, {
|
|
|
56
57
|
deepClone: () => deepClone,
|
|
57
58
|
defaultContentConfig: () => defaultContentConfig,
|
|
58
59
|
defaultStep: () => defaultStep,
|
|
59
|
-
document: () =>
|
|
60
|
+
document: () => document,
|
|
60
61
|
evalCode: () => evalCode,
|
|
61
62
|
fetch: () => fetch,
|
|
62
63
|
filterAutoStartContent: () => filterAutoStartContent,
|
|
63
64
|
findLatestEvent: () => findLatestEvent,
|
|
64
|
-
finder: () => finder,
|
|
65
|
-
finderV2: () => finderV2,
|
|
66
|
-
finderX: () => finderX,
|
|
67
65
|
flowIsDismissed: () => flowIsDismissed,
|
|
68
66
|
flowIsSeen: () => flowIsSeen,
|
|
69
67
|
formatDate: () => formatDate,
|
|
@@ -94,6 +92,7 @@ __export(src_exports, {
|
|
|
94
92
|
isBoolean: () => isBoolean,
|
|
95
93
|
isDark: () => isDark,
|
|
96
94
|
isDate: () => isDate,
|
|
95
|
+
isDismissedEventMapping: () => isDismissedEventMapping,
|
|
97
96
|
isDocument: () => isDocument,
|
|
98
97
|
isEmptyObject: () => isEmptyObject,
|
|
99
98
|
isEmptyString: () => isEmptyString,
|
|
@@ -116,16 +115,14 @@ __export(src_exports, {
|
|
|
116
115
|
isUrl: () => isUrl,
|
|
117
116
|
isValidContent: () => isValidContent,
|
|
118
117
|
isValidSelector: () => isValidSelector,
|
|
119
|
-
|
|
120
|
-
location: () => location,
|
|
118
|
+
location: () => location2,
|
|
121
119
|
mergeThemeDefaultSettings: () => mergeThemeDefaultSettings,
|
|
122
120
|
nativeForEach: () => nativeForEach,
|
|
123
121
|
nativeIndexOf: () => nativeIndexOf,
|
|
124
122
|
navigator: () => navigator,
|
|
125
123
|
parseUrlParams: () => parseUrlParams,
|
|
126
|
-
parserV2: () => parserV2,
|
|
127
|
-
parserX: () => parserX,
|
|
128
124
|
removeAuthToken: () => removeAuthToken,
|
|
125
|
+
rulesTypes: () => rulesTypes,
|
|
129
126
|
setAuthToken: () => setAuthToken,
|
|
130
127
|
storage: () => storage,
|
|
131
128
|
userAgent: () => userAgent,
|
|
@@ -834,8 +831,8 @@ var ArrayProto = Array.prototype;
|
|
|
834
831
|
var nativeForEach = ArrayProto.forEach;
|
|
835
832
|
var nativeIndexOf = ArrayProto.indexOf;
|
|
836
833
|
var navigator = global == null ? void 0 : global.navigator;
|
|
837
|
-
var
|
|
838
|
-
var
|
|
834
|
+
var document = global == null ? void 0 : global.document;
|
|
835
|
+
var location2 = global == null ? void 0 : global.location;
|
|
839
836
|
var fetch = global == null ? void 0 : global.fetch;
|
|
840
837
|
var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
|
|
841
838
|
var AbortController = global == null ? void 0 : global.AbortController;
|
|
@@ -1110,338 +1107,9 @@ var getRandomColor = () => {
|
|
|
1110
1107
|
return colors[Math.floor(Math.random() * colors.length)];
|
|
1111
1108
|
};
|
|
1112
1109
|
|
|
1113
|
-
// src/conditions.ts
|
|
1114
|
-
var import_dom = require("@floating-ui/dom");
|
|
1115
|
-
|
|
1116
|
-
// src/finderx.ts
|
|
1117
|
-
var import_finder = require("@medv/finder");
|
|
1118
|
-
var finderAttrs = [
|
|
1119
|
-
"data-for",
|
|
1120
|
-
"data-id",
|
|
1121
|
-
"data-testid",
|
|
1122
|
-
"data-test-id",
|
|
1123
|
-
"for",
|
|
1124
|
-
"id",
|
|
1125
|
-
"name",
|
|
1126
|
-
"placeholder",
|
|
1127
|
-
"role"
|
|
1128
|
-
];
|
|
1129
|
-
var defaultConfig = {
|
|
1130
|
-
idName: () => false,
|
|
1131
|
-
className: () => false,
|
|
1132
|
-
tagName: () => false,
|
|
1133
|
-
attr: () => false,
|
|
1134
|
-
seedMinLength: 1,
|
|
1135
|
-
optimizedMinLength: 2,
|
|
1136
|
-
threshold: 1e3,
|
|
1137
|
-
maxNumberOfTries: 1e4
|
|
1138
|
-
};
|
|
1139
|
-
var finderConfigs = [
|
|
1140
|
-
{
|
|
1141
|
-
...defaultConfig,
|
|
1142
|
-
tagName: () => true
|
|
1143
|
-
},
|
|
1144
|
-
{
|
|
1145
|
-
...defaultConfig,
|
|
1146
|
-
idName: () => true
|
|
1147
|
-
},
|
|
1148
|
-
{
|
|
1149
|
-
...defaultConfig,
|
|
1150
|
-
tagName: () => true,
|
|
1151
|
-
attr: (name) => finderAttrs.includes(name)
|
|
1152
|
-
},
|
|
1153
|
-
{
|
|
1154
|
-
...defaultConfig,
|
|
1155
|
-
className: () => true,
|
|
1156
|
-
attr: (name) => finderAttrs.includes(name)
|
|
1157
|
-
},
|
|
1158
|
-
{
|
|
1159
|
-
...defaultConfig,
|
|
1160
|
-
tagName: () => true,
|
|
1161
|
-
idName: () => true,
|
|
1162
|
-
className: () => true,
|
|
1163
|
-
attr: () => false
|
|
1164
|
-
},
|
|
1165
|
-
{
|
|
1166
|
-
...defaultConfig,
|
|
1167
|
-
tagName: () => true,
|
|
1168
|
-
idName: () => true,
|
|
1169
|
-
className: () => true,
|
|
1170
|
-
attr: (name) => finderAttrs.includes(name)
|
|
1171
|
-
}
|
|
1172
|
-
];
|
|
1173
|
-
function getMaxDepth(node) {
|
|
1174
|
-
if (node.parentNode) {
|
|
1175
|
-
return getMaxDepth(node.parentNode);
|
|
1176
|
-
}
|
|
1177
|
-
return node.depth;
|
|
1178
|
-
}
|
|
1179
|
-
function queryNodeListBySelectors(selectors, rootDocument, removeRepeat = true) {
|
|
1180
|
-
const nodes = [];
|
|
1181
|
-
if (!selectors) {
|
|
1182
|
-
return nodes;
|
|
1183
|
-
}
|
|
1184
|
-
for (const s of selectors) {
|
|
1185
|
-
const els = rootDocument.querySelectorAll(s.replace(/\\\\/g, "\\"));
|
|
1186
|
-
if (els && els.length > 0) {
|
|
1187
|
-
nodes.push(...Array.from(els));
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
return removeRepeat ? [...new Set(nodes)] : nodes;
|
|
1191
|
-
}
|
|
1192
|
-
function findMostRecurringNode(nodes) {
|
|
1193
|
-
const m = /* @__PURE__ */ new Map();
|
|
1194
|
-
let finalNode = nodes[0];
|
|
1195
|
-
let count = 0;
|
|
1196
|
-
for (const node of nodes) {
|
|
1197
|
-
const i = m.get(node) ? m.get(node) + 1 : 1;
|
|
1198
|
-
m.set(node, i);
|
|
1199
|
-
}
|
|
1200
|
-
m.forEach((value, key) => {
|
|
1201
|
-
if (value > count) {
|
|
1202
|
-
count = value;
|
|
1203
|
-
finalNode = key;
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1206
|
-
return finalNode;
|
|
1207
|
-
}
|
|
1208
|
-
function compareParentNode(node, el, rootDocument, isCompareSibings = false) {
|
|
1209
|
-
let nodeParentNode = node.parentNode;
|
|
1210
|
-
let elParentElement = el.parentElement;
|
|
1211
|
-
const maxDepth = getMaxDepth(node);
|
|
1212
|
-
const xresult = {
|
|
1213
|
-
maxDepth,
|
|
1214
|
-
failedDepth: 0,
|
|
1215
|
-
success: true
|
|
1216
|
-
};
|
|
1217
|
-
while (nodeParentNode && elParentElement) {
|
|
1218
|
-
if (elParentElement === rootDocument) {
|
|
1219
|
-
break;
|
|
1220
|
-
}
|
|
1221
|
-
if (elParentElement === document.body || elParentElement === document.documentElement || elParentElement.parentElement === document.body) {
|
|
1222
|
-
break;
|
|
1223
|
-
}
|
|
1224
|
-
const parentNodes = queryNodeListBySelectors(nodeParentNode.selectors, rootDocument);
|
|
1225
|
-
const isMatchSibings = isCompareSibings ? compareSibingsNode(nodeParentNode, elParentElement, rootDocument) : true;
|
|
1226
|
-
if (!parentNodes || parentNodes.length === 0 || !parentNodes.includes(elParentElement) || !isMatchSibings) {
|
|
1227
|
-
xresult.failedDepth = nodeParentNode.depth;
|
|
1228
|
-
xresult.success = false;
|
|
1229
|
-
}
|
|
1230
|
-
nodeParentNode = nodeParentNode.parentNode;
|
|
1231
|
-
elParentElement = elParentElement.parentElement;
|
|
1232
|
-
}
|
|
1233
|
-
return xresult;
|
|
1234
|
-
}
|
|
1235
|
-
function compareSibingsNode(node, el, rootDocument) {
|
|
1236
|
-
let isMatchNext = true;
|
|
1237
|
-
let isMatchPrevious = true;
|
|
1238
|
-
const { previousElementSelectors, nextElementSelectors } = node;
|
|
1239
|
-
if (nextElementSelectors && nextElementSelectors.length > 0) {
|
|
1240
|
-
const nextElementSiblings = queryNodeListBySelectors(nextElementSelectors, rootDocument);
|
|
1241
|
-
isMatchNext = el.nextElementSibling && nextElementSiblings.includes(el.nextElementSibling);
|
|
1242
|
-
}
|
|
1243
|
-
if (previousElementSelectors && previousElementSelectors.length > 0) {
|
|
1244
|
-
const previousElementSiblings = queryNodeListBySelectors(
|
|
1245
|
-
previousElementSelectors,
|
|
1246
|
-
rootDocument
|
|
1247
|
-
);
|
|
1248
|
-
isMatchPrevious = el.previousElementSibling && previousElementSiblings.includes(el.previousElementSibling);
|
|
1249
|
-
}
|
|
1250
|
-
return isMatchNext && isMatchPrevious;
|
|
1251
|
-
}
|
|
1252
|
-
function queryElementSelectors(input) {
|
|
1253
|
-
const classes = Array.from(input.classList);
|
|
1254
|
-
const selectors = [];
|
|
1255
|
-
const configs = [...finderConfigs];
|
|
1256
|
-
for (const className of classes) {
|
|
1257
|
-
configs.push({
|
|
1258
|
-
...defaultConfig,
|
|
1259
|
-
className: (name) => {
|
|
1260
|
-
if (classes.filter((cn2) => cn2 !== className).includes(name)) {
|
|
1261
|
-
return false;
|
|
1262
|
-
}
|
|
1263
|
-
return true;
|
|
1264
|
-
}
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1267
|
-
try {
|
|
1268
|
-
for (const cfg of configs) {
|
|
1269
|
-
selectors.push(finder(input, cfg));
|
|
1270
|
-
}
|
|
1271
|
-
} catch (_) {
|
|
1272
|
-
return selectors;
|
|
1273
|
-
}
|
|
1274
|
-
return [...new Set(selectors)];
|
|
1275
|
-
}
|
|
1276
|
-
function parseSelectorsTree(input, parentNode, depth = 0) {
|
|
1277
|
-
const selectors = queryElementSelectors(input);
|
|
1278
|
-
if (selectors.length === 0) {
|
|
1279
|
-
return parentNode;
|
|
1280
|
-
}
|
|
1281
|
-
const currentNode = {
|
|
1282
|
-
previousElementSelectors: [],
|
|
1283
|
-
nextElementSelectors: [],
|
|
1284
|
-
selectors,
|
|
1285
|
-
depth
|
|
1286
|
-
};
|
|
1287
|
-
if (input.previousElementSibling) {
|
|
1288
|
-
currentNode.previousElementSelectors = queryElementSelectors(input.previousElementSibling);
|
|
1289
|
-
}
|
|
1290
|
-
if (input.nextElementSibling) {
|
|
1291
|
-
currentNode.nextElementSelectors = queryElementSelectors(input.nextElementSibling);
|
|
1292
|
-
}
|
|
1293
|
-
if (parentNode === null) {
|
|
1294
|
-
if (input.parentElement) {
|
|
1295
|
-
parseSelectorsTree(input.parentElement, currentNode, depth + 1);
|
|
1296
|
-
}
|
|
1297
|
-
return currentNode;
|
|
1298
|
-
}
|
|
1299
|
-
parentNode.parentNode = currentNode;
|
|
1300
|
-
if (input.parentElement) {
|
|
1301
|
-
parseSelectorsTree(input.parentElement, currentNode, depth + 1);
|
|
1302
|
-
}
|
|
1303
|
-
return parentNode;
|
|
1304
|
-
}
|
|
1305
|
-
function finderMostPrecisionElement(elements, node, rootDocument, precision) {
|
|
1306
|
-
const successEls = [];
|
|
1307
|
-
let failedData = {
|
|
1308
|
-
el: null,
|
|
1309
|
-
failedDepth: 0,
|
|
1310
|
-
maxDepth: 0
|
|
1311
|
-
};
|
|
1312
|
-
for (const el of elements) {
|
|
1313
|
-
const { success, failedDepth, maxDepth } = compareParentNode(node, el, rootDocument);
|
|
1314
|
-
if (success) {
|
|
1315
|
-
successEls.push(el);
|
|
1316
|
-
} else if (!failedData.el || failedDepth > failedData.failedDepth) {
|
|
1317
|
-
failedData = { el, failedDepth, maxDepth };
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
if (successEls.length === 1) {
|
|
1321
|
-
return successEls[0];
|
|
1322
|
-
}
|
|
1323
|
-
if (successEls.length > 1) {
|
|
1324
|
-
let tempEl = successEls[0];
|
|
1325
|
-
let tempFailedDepth = 0;
|
|
1326
|
-
for (const el of successEls) {
|
|
1327
|
-
const { success, failedDepth } = compareParentNode(node, el, rootDocument, true);
|
|
1328
|
-
if (success) {
|
|
1329
|
-
return el;
|
|
1330
|
-
}
|
|
1331
|
-
if (failedDepth > tempFailedDepth) {
|
|
1332
|
-
tempFailedDepth = failedDepth;
|
|
1333
|
-
tempEl = el;
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
return tempEl;
|
|
1337
|
-
}
|
|
1338
|
-
if (failedData.el) {
|
|
1339
|
-
const { failedDepth, maxDepth, el } = failedData;
|
|
1340
|
-
const rate = (failedDepth - 1) / maxDepth * 10;
|
|
1341
|
-
if (rate >= precision) {
|
|
1342
|
-
return el;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
return null;
|
|
1346
|
-
}
|
|
1347
|
-
function finder(input, options) {
|
|
1348
|
-
return (0, import_finder.finder)(input, options);
|
|
1349
|
-
}
|
|
1350
|
-
function parserX(input) {
|
|
1351
|
-
return parseSelectorsTree(input, null);
|
|
1352
|
-
}
|
|
1353
|
-
function parserV2(element) {
|
|
1354
|
-
var _a;
|
|
1355
|
-
const content = (_a = element.innerText) != null ? _a : "";
|
|
1356
|
-
const selectors = parseSelectorsTree(element, null);
|
|
1357
|
-
const selectorsList = queryElementSelectors(element);
|
|
1358
|
-
return { content, selectors, selectorsList };
|
|
1359
|
-
}
|
|
1360
|
-
function finderV2(target, root) {
|
|
1361
|
-
const {
|
|
1362
|
-
selectors,
|
|
1363
|
-
content = "",
|
|
1364
|
-
sequence = 0,
|
|
1365
|
-
precision = "strict",
|
|
1366
|
-
isDynamicContent = false,
|
|
1367
|
-
customSelector = "",
|
|
1368
|
-
type = "auto"
|
|
1369
|
-
} = target;
|
|
1370
|
-
if (type === "auto") {
|
|
1371
|
-
const mapping = {
|
|
1372
|
-
looser: 1,
|
|
1373
|
-
loose: 3,
|
|
1374
|
-
loosest: 5,
|
|
1375
|
-
strict: 7,
|
|
1376
|
-
stricter: 8,
|
|
1377
|
-
strictest: 10
|
|
1378
|
-
};
|
|
1379
|
-
const el = finderX(selectors, root, mapping[precision]);
|
|
1380
|
-
if (el) {
|
|
1381
|
-
if (isDynamicContent && content && el.innerText !== content) {
|
|
1382
|
-
return null;
|
|
1383
|
-
}
|
|
1384
|
-
return el;
|
|
1385
|
-
}
|
|
1386
|
-
} else {
|
|
1387
|
-
const sequenceMapping = {
|
|
1388
|
-
"1st": 0,
|
|
1389
|
-
"2st": 1,
|
|
1390
|
-
"3st": 2,
|
|
1391
|
-
"4st": 3,
|
|
1392
|
-
"5st": 4
|
|
1393
|
-
};
|
|
1394
|
-
if (customSelector) {
|
|
1395
|
-
const selector = customSelector.replace(/\\\\/g, "\\");
|
|
1396
|
-
const els = root.querySelectorAll(selector);
|
|
1397
|
-
if (els.length > 0) {
|
|
1398
|
-
const el = els[sequenceMapping[sequence]] || els[0];
|
|
1399
|
-
if (content && el.innerText.trim() !== content) {
|
|
1400
|
-
return null;
|
|
1401
|
-
}
|
|
1402
|
-
return el;
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
return null;
|
|
1407
|
-
}
|
|
1408
|
-
function finderX(node, root, precision = 10) {
|
|
1409
|
-
if (!node || node.selectors.length === 0) {
|
|
1410
|
-
return null;
|
|
1411
|
-
}
|
|
1412
|
-
const rootDocument = root || document;
|
|
1413
|
-
const elements = [];
|
|
1414
|
-
const nodeList = queryNodeListBySelectors(node.selectors, rootDocument, false);
|
|
1415
|
-
if (!nodeList || nodeList.length === 0) {
|
|
1416
|
-
return null;
|
|
1417
|
-
}
|
|
1418
|
-
if ([...new Set(nodeList)].length !== nodeList.length) {
|
|
1419
|
-
const el = findMostRecurringNode(nodeList);
|
|
1420
|
-
elements.push(el);
|
|
1421
|
-
} else {
|
|
1422
|
-
elements.push(...nodeList);
|
|
1423
|
-
}
|
|
1424
|
-
return finderMostPrecisionElement(elements, node, rootDocument, precision);
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
1110
|
// src/conditions.ts
|
|
1428
1111
|
var import_types4 = require("@usertour/types");
|
|
1429
1112
|
var import_date_fns = require("date-fns");
|
|
1430
|
-
|
|
1431
|
-
// src/listener.ts
|
|
1432
|
-
function on(obj, ...args) {
|
|
1433
|
-
if (obj == null ? void 0 : obj.addEventListener) {
|
|
1434
|
-
obj.addEventListener(...args);
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
function off(obj, ...args) {
|
|
1438
|
-
if (obj == null ? void 0 : obj.removeEventListener) {
|
|
1439
|
-
obj.removeEventListener(...args);
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
// src/conditions.ts
|
|
1444
|
-
var rulesTypes = Object.values(import_types4.RulesType);
|
|
1445
1113
|
var PRIORITIES = [
|
|
1446
1114
|
import_types4.ContentPriority.HIGHEST,
|
|
1447
1115
|
import_types4.ContentPriority.HIGH,
|
|
@@ -1449,6 +1117,7 @@ var PRIORITIES = [
|
|
|
1449
1117
|
import_types4.ContentPriority.LOW,
|
|
1450
1118
|
import_types4.ContentPriority.LOWEST
|
|
1451
1119
|
];
|
|
1120
|
+
var rulesTypes = Object.values(import_types4.RulesType);
|
|
1452
1121
|
var isActiveRulesByCurrentPage = (rules) => {
|
|
1453
1122
|
const { excludes, includes } = rules.data;
|
|
1454
1123
|
if (location) {
|
|
@@ -1490,129 +1159,6 @@ var isActivedContentRulesCondition = (rules, contentSession) => {
|
|
|
1490
1159
|
}
|
|
1491
1160
|
return false;
|
|
1492
1161
|
};
|
|
1493
|
-
var isVisible = async (el) => {
|
|
1494
|
-
var _a, _b;
|
|
1495
|
-
if (!((_a = document2) == null ? void 0 : _a.body)) {
|
|
1496
|
-
return false;
|
|
1497
|
-
}
|
|
1498
|
-
const { middlewareData } = await (0, import_dom.computePosition)(el, document2.body, {
|
|
1499
|
-
strategy: "fixed",
|
|
1500
|
-
middleware: [(0, import_dom.hide)()]
|
|
1501
|
-
});
|
|
1502
|
-
if ((_b = middlewareData == null ? void 0 : middlewareData.hide) == null ? void 0 : _b.referenceHidden) {
|
|
1503
|
-
return false;
|
|
1504
|
-
}
|
|
1505
|
-
return true;
|
|
1506
|
-
};
|
|
1507
|
-
var cache = /* @__PURE__ */ new Map();
|
|
1508
|
-
var isClicked = (el) => {
|
|
1509
|
-
if (cache.has(el)) {
|
|
1510
|
-
return cache.get(el);
|
|
1511
|
-
}
|
|
1512
|
-
const onClick = () => {
|
|
1513
|
-
cache.set(el, true);
|
|
1514
|
-
off(el, "click", onClick);
|
|
1515
|
-
};
|
|
1516
|
-
on(el, "click", onClick);
|
|
1517
|
-
cache.set(el, false);
|
|
1518
|
-
return false;
|
|
1519
|
-
};
|
|
1520
|
-
var isActiveRulesByElement = async (rules) => {
|
|
1521
|
-
const { data } = rules;
|
|
1522
|
-
if (!document2) {
|
|
1523
|
-
return false;
|
|
1524
|
-
}
|
|
1525
|
-
const el = finderV2(data.elementData, document2);
|
|
1526
|
-
const isPresent = el ? await isVisible(el) : false;
|
|
1527
|
-
const isDisabled = el ? el.disabled : false;
|
|
1528
|
-
switch (data.logic) {
|
|
1529
|
-
case import_types4.ElementConditionLogic.PRESENT:
|
|
1530
|
-
return isPresent;
|
|
1531
|
-
case import_types4.ElementConditionLogic.UNPRESENT:
|
|
1532
|
-
return !isPresent;
|
|
1533
|
-
case import_types4.ElementConditionLogic.DISABLED:
|
|
1534
|
-
return el && isDisabled;
|
|
1535
|
-
case import_types4.ElementConditionLogic.UNDISABLED:
|
|
1536
|
-
return el && !isDisabled;
|
|
1537
|
-
case import_types4.ElementConditionLogic.CLICKED:
|
|
1538
|
-
return el && isClicked(el);
|
|
1539
|
-
case import_types4.ElementConditionLogic.UNCLICKED:
|
|
1540
|
-
return el && !isClicked(el);
|
|
1541
|
-
default:
|
|
1542
|
-
return false;
|
|
1543
|
-
}
|
|
1544
|
-
};
|
|
1545
|
-
var isActiveRulesByTextInput = async (rules) => {
|
|
1546
|
-
const {
|
|
1547
|
-
data: { elementData, logic, value }
|
|
1548
|
-
} = rules;
|
|
1549
|
-
if (!document2) {
|
|
1550
|
-
return false;
|
|
1551
|
-
}
|
|
1552
|
-
const el = finderV2(elementData, document2);
|
|
1553
|
-
if (!el) {
|
|
1554
|
-
return false;
|
|
1555
|
-
}
|
|
1556
|
-
const elValue = el.value;
|
|
1557
|
-
switch (logic) {
|
|
1558
|
-
case import_types4.StringConditionLogic.IS:
|
|
1559
|
-
return elValue === value;
|
|
1560
|
-
case import_types4.StringConditionLogic.NOT:
|
|
1561
|
-
return elValue !== value;
|
|
1562
|
-
case import_types4.StringConditionLogic.CONTAINS:
|
|
1563
|
-
return elValue.includes(value);
|
|
1564
|
-
case import_types4.StringConditionLogic.NOT_CONTAIN:
|
|
1565
|
-
return !elValue.includes(value);
|
|
1566
|
-
case import_types4.StringConditionLogic.STARTS_WITH:
|
|
1567
|
-
return elValue.startsWith(value);
|
|
1568
|
-
case import_types4.StringConditionLogic.ENDS_WITH:
|
|
1569
|
-
return elValue.endsWith(value);
|
|
1570
|
-
case import_types4.StringConditionLogic.MATCH:
|
|
1571
|
-
return elValue.search(value) !== -1;
|
|
1572
|
-
case import_types4.StringConditionLogic.UNMATCH:
|
|
1573
|
-
return elValue.search(value) === -1;
|
|
1574
|
-
case import_types4.StringConditionLogic.ANY:
|
|
1575
|
-
return true;
|
|
1576
|
-
case import_types4.StringConditionLogic.EMPTY:
|
|
1577
|
-
return !elValue;
|
|
1578
|
-
default:
|
|
1579
|
-
return false;
|
|
1580
|
-
}
|
|
1581
|
-
};
|
|
1582
|
-
var fillCache = /* @__PURE__ */ new Map();
|
|
1583
|
-
var isActiveRulesByTextFill = async (rules) => {
|
|
1584
|
-
const {
|
|
1585
|
-
data: { elementData }
|
|
1586
|
-
} = rules;
|
|
1587
|
-
if (!document2) {
|
|
1588
|
-
return false;
|
|
1589
|
-
}
|
|
1590
|
-
const el = finderV2(elementData, document2);
|
|
1591
|
-
if (!el) {
|
|
1592
|
-
return false;
|
|
1593
|
-
}
|
|
1594
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
1595
|
-
const onKeyup = () => {
|
|
1596
|
-
const cacheData = fillCache.get(el);
|
|
1597
|
-
const data = { ...cacheData, timestamp: (/* @__PURE__ */ new Date()).getTime() };
|
|
1598
|
-
fillCache.set(el, data);
|
|
1599
|
-
};
|
|
1600
|
-
if (fillCache.has(el)) {
|
|
1601
|
-
const { timestamp, value, isActive: isActive2 } = fillCache.get(el);
|
|
1602
|
-
if (isActive2) {
|
|
1603
|
-
return true;
|
|
1604
|
-
}
|
|
1605
|
-
if (timestamp !== -1 && now - timestamp > 1e3 && value !== el.value) {
|
|
1606
|
-
off(document2, "click", onKeyup);
|
|
1607
|
-
fillCache.set(el, { timestamp, value, isActive: true });
|
|
1608
|
-
return true;
|
|
1609
|
-
}
|
|
1610
|
-
return false;
|
|
1611
|
-
}
|
|
1612
|
-
on(document2, "keyup", onKeyup);
|
|
1613
|
-
fillCache.set(el, { timestamp: -1, value: el.value, isActive: false });
|
|
1614
|
-
return false;
|
|
1615
|
-
};
|
|
1616
1162
|
var isValidRulesType = (type) => {
|
|
1617
1163
|
return rulesTypes.includes(type);
|
|
1618
1164
|
};
|
|
@@ -1625,12 +1171,6 @@ var isActiveRules = async (rules) => {
|
|
|
1625
1171
|
return isActiveRulesByCurrentPage(rules);
|
|
1626
1172
|
case import_types4.RulesType.TIME:
|
|
1627
1173
|
return isActiveRulesByCurrentTime(rules);
|
|
1628
|
-
case import_types4.RulesType.ELEMENT:
|
|
1629
|
-
return await isActiveRulesByElement(rules);
|
|
1630
|
-
case import_types4.RulesType.TEXT_INPUT:
|
|
1631
|
-
return await isActiveRulesByTextInput(rules);
|
|
1632
|
-
case import_types4.RulesType.TEXT_FILL:
|
|
1633
|
-
return await isActiveRulesByTextFill(rules);
|
|
1634
1174
|
default:
|
|
1635
1175
|
return rules.actived;
|
|
1636
1176
|
}
|
|
@@ -1799,11 +1339,21 @@ var findLatestEvent = (bizEvents) => {
|
|
|
1799
1339
|
);
|
|
1800
1340
|
return lastEvent;
|
|
1801
1341
|
};
|
|
1342
|
+
var completeEventMapping = {
|
|
1343
|
+
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_COMPLETED,
|
|
1344
|
+
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_ACTIVATED,
|
|
1345
|
+
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_COMPLETED
|
|
1346
|
+
};
|
|
1802
1347
|
var showEventMapping = {
|
|
1803
1348
|
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_STEP_SEEN,
|
|
1804
1349
|
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_SEEN,
|
|
1805
1350
|
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_SEEN
|
|
1806
1351
|
};
|
|
1352
|
+
var isDismissedEventMapping = {
|
|
1353
|
+
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_ENDED,
|
|
1354
|
+
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_DISMISSED,
|
|
1355
|
+
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_DISMISSED
|
|
1356
|
+
};
|
|
1807
1357
|
var isGreaterThenDuration = (dateLeft, dateRight, unit, duration) => {
|
|
1808
1358
|
switch (unit) {
|
|
1809
1359
|
case import_types4.FrequencyUnits.SECONDS: {
|
|
@@ -1990,6 +1540,7 @@ var wait = (seconds) => {
|
|
|
1990
1540
|
checklistIsDimissed,
|
|
1991
1541
|
checklistIsSeen,
|
|
1992
1542
|
cn,
|
|
1543
|
+
completeEventMapping,
|
|
1993
1544
|
conditionsIsSame,
|
|
1994
1545
|
convertSettings,
|
|
1995
1546
|
convertToCssVars,
|
|
@@ -2002,9 +1553,6 @@ var wait = (seconds) => {
|
|
|
2002
1553
|
fetch,
|
|
2003
1554
|
filterAutoStartContent,
|
|
2004
1555
|
findLatestEvent,
|
|
2005
|
-
finder,
|
|
2006
|
-
finderV2,
|
|
2007
|
-
finderX,
|
|
2008
1556
|
flowIsDismissed,
|
|
2009
1557
|
flowIsSeen,
|
|
2010
1558
|
formatDate,
|
|
@@ -2035,6 +1583,7 @@ var wait = (seconds) => {
|
|
|
2035
1583
|
isBoolean,
|
|
2036
1584
|
isDark,
|
|
2037
1585
|
isDate,
|
|
1586
|
+
isDismissedEventMapping,
|
|
2038
1587
|
isDocument,
|
|
2039
1588
|
isEmptyObject,
|
|
2040
1589
|
isEmptyString,
|
|
@@ -2057,16 +1606,14 @@ var wait = (seconds) => {
|
|
|
2057
1606
|
isUrl,
|
|
2058
1607
|
isValidContent,
|
|
2059
1608
|
isValidSelector,
|
|
2060
|
-
isVisible,
|
|
2061
1609
|
location,
|
|
2062
1610
|
mergeThemeDefaultSettings,
|
|
2063
1611
|
nativeForEach,
|
|
2064
1612
|
nativeIndexOf,
|
|
2065
1613
|
navigator,
|
|
2066
1614
|
parseUrlParams,
|
|
2067
|
-
parserV2,
|
|
2068
|
-
parserX,
|
|
2069
1615
|
removeAuthToken,
|
|
1616
|
+
rulesTypes,
|
|
2070
1617
|
setAuthToken,
|
|
2071
1618
|
storage,
|
|
2072
1619
|
userAgent,
|
package/dist/index.d.cts
CHANGED
|
@@ -11,8 +11,7 @@ export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from '
|
|
|
11
11
|
export { deepClone } from './utils.cjs';
|
|
12
12
|
export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.cjs';
|
|
13
13
|
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.cjs';
|
|
14
|
-
export { PRIORITIES, activedContentCondition, activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveContent, isHasActivedContents, isSameContents, isValidContent,
|
|
15
|
-
export { Options, Target, TargetResult, XData, XNode, XResult, finder, finderV2, finderX, parserV2, parserX } from './finderx.cjs';
|
|
14
|
+
export { PRIORITIES, activedContentCondition, activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, completeEventMapping, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveContent, isDismissedEventMapping, isHasActivedContents, isSameContents, isValidContent, parseUrlParams, rulesTypes, wait } from './conditions.cjs';
|
|
16
15
|
export { default as isEqual } from 'fast-deep-equal';
|
|
17
16
|
import '@usertour/types';
|
|
18
17
|
import './storage.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,7 @@ export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from '
|
|
|
11
11
|
export { deepClone } from './utils.js';
|
|
12
12
|
export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.js';
|
|
13
13
|
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.js';
|
|
14
|
-
export { PRIORITIES, activedContentCondition, activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveContent, isHasActivedContents, isSameContents, isValidContent,
|
|
15
|
-
export { Options, Target, TargetResult, XData, XNode, XResult, finder, finderV2, finderX, parserV2, parserX } from './finderx.js';
|
|
14
|
+
export { PRIORITIES, activedContentCondition, activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, completeEventMapping, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveContent, isDismissedEventMapping, isHasActivedContents, isSameContents, isValidContent, parseUrlParams, rulesTypes, wait } from './conditions.js';
|
|
16
15
|
export { default as isEqual } from 'fast-deep-equal';
|
|
17
16
|
import '@usertour/types';
|
|
18
17
|
import './storage.js';
|