@usertour/helpers 0.0.13 → 0.0.15
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-BBPZYUJR.js → chunk-B4DTY6GN.js} +49 -1
- package/dist/{chunk-FNQIIEWK.js → chunk-IZFZYGPU.js} +1 -1
- package/dist/conditions.cjs +6 -464
- package/dist/conditions.d.cts +5 -33
- package/dist/conditions.d.ts +5 -33
- package/dist/conditions.js +7 -46
- package/dist/content.cjs +49 -0
- package/dist/content.d.cts +5 -2
- package/dist/content.d.ts +5 -2
- package/dist/content.js +7 -1
- package/dist/index.cjs +138 -475
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +28 -50
- package/package.json +2 -2
- package/dist/chunk-64BFWPHJ.js +0 -50
- package/dist/chunk-SYVTGB2A.js +0 -462
- package/dist/condition.cjs +0 -157
- package/dist/condition.d.cts +0 -7
- package/dist/condition.d.ts +0 -7
- package/dist/condition.js +0 -11
- package/dist/content-settings.cjs +0 -76
- package/dist/content-settings.d.cts +0 -7
- package/dist/content-settings.d.ts +0 -7
- package/dist/content-settings.js +0 -11
package/dist/index.cjs
CHANGED
|
@@ -39,12 +39,9 @@ __export(src_exports, {
|
|
|
39
39
|
ArrayProto: () => ArrayProto,
|
|
40
40
|
XMLHttpRequest: () => XMLHttpRequest,
|
|
41
41
|
absoluteUrl: () => absoluteUrl,
|
|
42
|
-
activedContentRulesConditions: () => activedContentRulesConditions,
|
|
43
42
|
assignableWindow: () => assignableWindow,
|
|
44
43
|
autoStartConditions: () => autoStartConditions,
|
|
45
44
|
buildConfig: () => buildConfig,
|
|
46
|
-
checklistIsDimissed: () => checklistIsDimissed,
|
|
47
|
-
checklistIsSeen: () => checklistIsSeen,
|
|
48
45
|
cn: () => cn,
|
|
49
46
|
conditionsIsSame: () => conditionsIsSame,
|
|
50
47
|
convertSettings: () => convertSettings,
|
|
@@ -56,9 +53,6 @@ __export(src_exports, {
|
|
|
56
53
|
document: () => document,
|
|
57
54
|
evalCode: () => evalCode,
|
|
58
55
|
fetch: () => fetch,
|
|
59
|
-
filterAutoStartContent: () => filterAutoStartContent,
|
|
60
|
-
flowIsDismissed: () => flowIsDismissed,
|
|
61
|
-
flowIsSeen: () => flowIsSeen,
|
|
62
56
|
formatDate: () => formatDate,
|
|
63
57
|
generateAutoStateColors: () => generateAutoStateColors,
|
|
64
58
|
getAuthToken: () => getAuthToken,
|
|
@@ -81,7 +75,6 @@ __export(src_exports, {
|
|
|
81
75
|
hexToHSLString: () => hexToHSLString,
|
|
82
76
|
hexToRGBStr: () => hexToRGBStr,
|
|
83
77
|
hexToRgb: () => hexToRgb,
|
|
84
|
-
isActiveRulesByCurrentTime: () => isActiveRulesByCurrentTime,
|
|
85
78
|
isArray: () => isArray,
|
|
86
79
|
isBoolean: () => isBoolean,
|
|
87
80
|
isDark: () => isDark,
|
|
@@ -104,14 +97,12 @@ __export(src_exports, {
|
|
|
104
97
|
isUint8Array: () => isUint8Array,
|
|
105
98
|
isUndefined: () => isUndefined,
|
|
106
99
|
isUrl: () => isUrl,
|
|
107
|
-
isValidContent: () => isValidContent,
|
|
108
100
|
isValidSelector: () => isValidSelector,
|
|
109
|
-
location: () =>
|
|
101
|
+
location: () => location,
|
|
110
102
|
mergeThemeDefaultSettings: () => mergeThemeDefaultSettings,
|
|
111
103
|
nativeForEach: () => nativeForEach,
|
|
112
104
|
nativeIndexOf: () => nativeIndexOf,
|
|
113
105
|
navigator: () => navigator,
|
|
114
|
-
parseUrlParams: () => parseUrlParams,
|
|
115
106
|
removeAuthToken: () => removeAuthToken,
|
|
116
107
|
setAuthToken: () => setAuthToken,
|
|
117
108
|
storage: () => storage,
|
|
@@ -450,169 +441,8 @@ var convertToCssVars = (settings, type = "tooltip") => {
|
|
|
450
441
|
return css;
|
|
451
442
|
};
|
|
452
443
|
|
|
453
|
-
// src/condition.ts
|
|
454
|
-
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
455
|
-
var parseUrl = (url) => {
|
|
456
|
-
const urlPatterns = url.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);
|
|
457
|
-
if (!urlPatterns) {
|
|
458
|
-
return null;
|
|
459
|
-
}
|
|
460
|
-
const [, , scheme = "", domain = "", path = "", , query = "", fragment = ""] = urlPatterns;
|
|
461
|
-
return { scheme, domain, path, query, fragment };
|
|
462
|
-
};
|
|
463
|
-
var replaceWildcard = (input, s1, s2) => {
|
|
464
|
-
const withSpecialWords = replaceSpecialWords(input);
|
|
465
|
-
const withWildcard = withSpecialWords.replace(/\\\*/g, `${s1}*`);
|
|
466
|
-
if (!s2) {
|
|
467
|
-
return withWildcard;
|
|
468
|
-
}
|
|
469
|
-
return withWildcard.replace(/:[a-z0-9_]+/g, `[^${s2}]+`);
|
|
470
|
-
};
|
|
471
|
-
var replaceSpecialWords = (str) => {
|
|
472
|
-
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
473
|
-
};
|
|
474
|
-
var parsePattern = (pattern) => {
|
|
475
|
-
if (!pattern || !pattern.trim()) {
|
|
476
|
-
return null;
|
|
477
|
-
}
|
|
478
|
-
const _pattern = parseUrl(pattern);
|
|
479
|
-
if (!_pattern) {
|
|
480
|
-
console.error("Invalid URL pattern:", pattern);
|
|
481
|
-
return null;
|
|
482
|
-
}
|
|
483
|
-
const { scheme, domain, path, query, fragment } = _pattern;
|
|
484
|
-
const _scheme = scheme ? replaceSpecialWords(scheme) : "[a-z\\d]+";
|
|
485
|
-
const _domain = domain ? replaceWildcard(domain, "[^/]", ".") : "[^/]*";
|
|
486
|
-
const _fragment = fragment ? replaceWildcard(fragment, ".", "/") : "(#.*)?";
|
|
487
|
-
const _path = path ? replaceWildcard(path, "[^?#]", "/") : "/[^?#]*";
|
|
488
|
-
let _query = "(\\?[^#]*)?";
|
|
489
|
-
if (query) {
|
|
490
|
-
new URLSearchParams(query).forEach((value, key) => {
|
|
491
|
-
const _str = value === "" ? "=?" : value === "*" ? "(=[^&#]*)?" : `=${replaceWildcard(value, "[^#]")}`;
|
|
492
|
-
_query += `(?=.*[?&]${replaceSpecialWords(key)}${_str}([&#]|$))`;
|
|
493
|
-
});
|
|
494
|
-
_query += "\\?[^#]*";
|
|
495
|
-
}
|
|
496
|
-
return new RegExp(`^${_scheme}://${_domain}(:\\d+)?${_path}${_query}${_fragment}$`);
|
|
497
|
-
};
|
|
498
|
-
var isMatchUrlPattern = (_url, includes, excludes) => {
|
|
499
|
-
const isMatchIncludesConditions = includes.length > 0 ? includes.some((_include) => {
|
|
500
|
-
const reg = parsePattern(_include);
|
|
501
|
-
if (reg) {
|
|
502
|
-
return reg.test(_url);
|
|
503
|
-
}
|
|
504
|
-
return false;
|
|
505
|
-
}) : true;
|
|
506
|
-
const isMatchExcludesConditions = excludes.length > 0 ? excludes.some((_exclude) => {
|
|
507
|
-
const reg = parsePattern(_exclude);
|
|
508
|
-
if (reg) {
|
|
509
|
-
return reg.test(_url);
|
|
510
|
-
}
|
|
511
|
-
return false;
|
|
512
|
-
}) : false;
|
|
513
|
-
return isMatchIncludesConditions && !isMatchExcludesConditions;
|
|
514
|
-
};
|
|
515
|
-
var compareConditionsItem = (item1, item2) => {
|
|
516
|
-
const { data = {}, ...others1 } = item1;
|
|
517
|
-
const { data: data2 = {}, ...others2 } = item2;
|
|
518
|
-
if (!(0, import_fast_deep_equal.default)(others2, others1)) {
|
|
519
|
-
return false;
|
|
520
|
-
}
|
|
521
|
-
for (const key in data) {
|
|
522
|
-
if (!(0, import_fast_deep_equal.default)(data[key], data2[key])) {
|
|
523
|
-
return false;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return true;
|
|
527
|
-
};
|
|
528
|
-
var conditionsIsSame = (rr1, rr2) => {
|
|
529
|
-
const r1 = [...rr1];
|
|
530
|
-
const r2 = [...rr2];
|
|
531
|
-
if (r1.length === 0 && r2.length === 0) {
|
|
532
|
-
return true;
|
|
533
|
-
}
|
|
534
|
-
if (r1.length !== r2.length) {
|
|
535
|
-
return false;
|
|
536
|
-
}
|
|
537
|
-
const group1 = r1.filter((item) => item.type === "group");
|
|
538
|
-
const group2 = r2.filter((item) => item.type === "group");
|
|
539
|
-
if (group1.length !== group2.length) {
|
|
540
|
-
return false;
|
|
541
|
-
}
|
|
542
|
-
for (let index = 0; index < r1.length; index++) {
|
|
543
|
-
const item1 = r1[index];
|
|
544
|
-
const item2 = r2[index];
|
|
545
|
-
if (!item1 || !item2) {
|
|
546
|
-
return false;
|
|
547
|
-
}
|
|
548
|
-
if (item1.type === "group") {
|
|
549
|
-
if (!item2.conditions) {
|
|
550
|
-
return false;
|
|
551
|
-
}
|
|
552
|
-
const c1 = item1.conditions;
|
|
553
|
-
const c2 = item2.conditions;
|
|
554
|
-
if (item1.operators !== item2.operators) {
|
|
555
|
-
return false;
|
|
556
|
-
}
|
|
557
|
-
if (!conditionsIsSame(c1, c2)) {
|
|
558
|
-
return false;
|
|
559
|
-
}
|
|
560
|
-
} else {
|
|
561
|
-
if (!compareConditionsItem(item1, item2)) {
|
|
562
|
-
return false;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
return true;
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
// src/content-settings.ts
|
|
570
|
-
var import_types2 = require("@usertour/types");
|
|
571
|
-
var import_deepmerge_ts2 = require("deepmerge-ts");
|
|
572
|
-
var rulesSetting = {
|
|
573
|
-
// frequency: {
|
|
574
|
-
// frequency: Frequency.ONCE,
|
|
575
|
-
// every: { duration: 0, times: 1, unit: FrequencyUnits.MINUTES },
|
|
576
|
-
// atLeast: { duration: 0, unit: FrequencyUnits.MINUTES },
|
|
577
|
-
// },
|
|
578
|
-
startIfNotComplete: false,
|
|
579
|
-
priority: import_types2.ContentPriority.MEDIUM,
|
|
580
|
-
wait: 0
|
|
581
|
-
};
|
|
582
|
-
var hideRulesSetting = {};
|
|
583
|
-
var defaultContentConfig = {
|
|
584
|
-
enabledAutoStartRules: false,
|
|
585
|
-
enabledHideRules: false,
|
|
586
|
-
autoStartRules: [],
|
|
587
|
-
hideRules: [],
|
|
588
|
-
autoStartRulesSetting: rulesSetting,
|
|
589
|
-
hideRulesSetting
|
|
590
|
-
};
|
|
591
|
-
var autoStartConditions = {
|
|
592
|
-
...defaultContentConfig,
|
|
593
|
-
enabledAutoStartRules: true,
|
|
594
|
-
autoStartRules: [
|
|
595
|
-
{
|
|
596
|
-
data: { excludes: [], includes: ["/*"] },
|
|
597
|
-
type: "current-page",
|
|
598
|
-
operators: "and"
|
|
599
|
-
}
|
|
600
|
-
]
|
|
601
|
-
};
|
|
602
|
-
var buildConfig = (config) => {
|
|
603
|
-
return {
|
|
604
|
-
...defaultContentConfig,
|
|
605
|
-
...config,
|
|
606
|
-
autoStartRulesSetting: (0, import_deepmerge_ts2.deepmerge)(
|
|
607
|
-
defaultContentConfig.autoStartRulesSetting,
|
|
608
|
-
(config == null ? void 0 : config.autoStartRulesSetting) || {}
|
|
609
|
-
),
|
|
610
|
-
hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
|
|
611
|
-
};
|
|
612
|
-
};
|
|
613
|
-
|
|
614
444
|
// src/error.ts
|
|
615
|
-
var
|
|
445
|
+
var import_types2 = require("@usertour/types");
|
|
616
446
|
var isValidSelector = (selector) => {
|
|
617
447
|
if (!selector) {
|
|
618
448
|
return false;
|
|
@@ -634,9 +464,9 @@ var getUserAttrError = (data, attributes) => {
|
|
|
634
464
|
} else if ((data == null ? void 0 : data.logic) === "between" && (!(data == null ? void 0 : data.value) || !(data == null ? void 0 : data.value2))) {
|
|
635
465
|
ret.showError = true;
|
|
636
466
|
ret.errorInfo = "Please enter a value";
|
|
637
|
-
} else if ((item == null ? void 0 : item.dataType) !==
|
|
467
|
+
} else if ((item == null ? void 0 : item.dataType) !== import_types2.AttributeDataType.Boolean) {
|
|
638
468
|
if (data.logic !== "any" && data.logic !== "empty") {
|
|
639
|
-
if ((item == null ? void 0 : item.dataType) ===
|
|
469
|
+
if ((item == null ? void 0 : item.dataType) === import_types2.AttributeDataType.List) {
|
|
640
470
|
if (!data.listValues || data.listValues.length === 0) {
|
|
641
471
|
ret.showError = true;
|
|
642
472
|
ret.errorInfo = "Please enter a value";
|
|
@@ -774,10 +604,10 @@ var hasError = (conds, attributes) => {
|
|
|
774
604
|
return false;
|
|
775
605
|
};
|
|
776
606
|
var errorActionHandlerMapping = {
|
|
777
|
-
[
|
|
778
|
-
[
|
|
779
|
-
[
|
|
780
|
-
[
|
|
607
|
+
[import_types2.ContentActionsItemType.STEP_GOTO]: getStepError,
|
|
608
|
+
[import_types2.ContentActionsItemType.PAGE_NAVIGATE]: getNavitateError,
|
|
609
|
+
[import_types2.ContentActionsItemType.FLOW_START]: getContentError,
|
|
610
|
+
[import_types2.ContentActionsItemType.JAVASCRIPT_EVALUATE]: getCodeError
|
|
781
611
|
};
|
|
782
612
|
var hasActionError = (conds) => {
|
|
783
613
|
for (const cond of conds) {
|
|
@@ -821,7 +651,7 @@ var nativeForEach = ArrayProto.forEach;
|
|
|
821
651
|
var nativeIndexOf = ArrayProto.indexOf;
|
|
822
652
|
var navigator = global == null ? void 0 : global.navigator;
|
|
823
653
|
var document = global == null ? void 0 : global.document;
|
|
824
|
-
var
|
|
654
|
+
var location = global == null ? void 0 : global.location;
|
|
825
655
|
var fetch = global == null ? void 0 : global.fetch;
|
|
826
656
|
var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
|
|
827
657
|
var AbortController = global == null ? void 0 : global.AbortController;
|
|
@@ -995,6 +825,8 @@ function isUrl(string) {
|
|
|
995
825
|
}
|
|
996
826
|
|
|
997
827
|
// src/content.ts
|
|
828
|
+
var import_types3 = require("@usertour/types");
|
|
829
|
+
var import_deepmerge_ts2 = require("deepmerge-ts");
|
|
998
830
|
var isPublishedInAllEnvironments = (content, environmentList, version) => {
|
|
999
831
|
const isPublishedInAllEnvironments2 = environmentList == null ? void 0 : environmentList.every(
|
|
1000
832
|
(env) => {
|
|
@@ -1017,6 +849,47 @@ var isPublishedAtLeastOneEnvironment = (content) => {
|
|
|
1017
849
|
}
|
|
1018
850
|
return false;
|
|
1019
851
|
};
|
|
852
|
+
var rulesSetting = {
|
|
853
|
+
// frequency: {
|
|
854
|
+
// frequency: Frequency.ONCE,
|
|
855
|
+
// every: { duration: 0, times: 1, unit: FrequencyUnits.MINUTES },
|
|
856
|
+
// atLeast: { duration: 0, unit: FrequencyUnits.MINUTES },
|
|
857
|
+
// },
|
|
858
|
+
startIfNotComplete: false,
|
|
859
|
+
priority: import_types3.ContentPriority.MEDIUM,
|
|
860
|
+
wait: 0
|
|
861
|
+
};
|
|
862
|
+
var hideRulesSetting = {};
|
|
863
|
+
var defaultContentConfig = {
|
|
864
|
+
enabledAutoStartRules: false,
|
|
865
|
+
enabledHideRules: false,
|
|
866
|
+
autoStartRules: [],
|
|
867
|
+
hideRules: [],
|
|
868
|
+
autoStartRulesSetting: rulesSetting,
|
|
869
|
+
hideRulesSetting
|
|
870
|
+
};
|
|
871
|
+
var autoStartConditions = {
|
|
872
|
+
...defaultContentConfig,
|
|
873
|
+
enabledAutoStartRules: true,
|
|
874
|
+
autoStartRules: [
|
|
875
|
+
{
|
|
876
|
+
data: { excludes: [], includes: ["/*"] },
|
|
877
|
+
type: "current-page",
|
|
878
|
+
operators: "and"
|
|
879
|
+
}
|
|
880
|
+
]
|
|
881
|
+
};
|
|
882
|
+
var buildConfig = (config) => {
|
|
883
|
+
return {
|
|
884
|
+
...defaultContentConfig,
|
|
885
|
+
...config,
|
|
886
|
+
autoStartRulesSetting: (0, import_deepmerge_ts2.deepmerge)(
|
|
887
|
+
defaultContentConfig.autoStartRulesSetting,
|
|
888
|
+
(config == null ? void 0 : config.autoStartRulesSetting) || {}
|
|
889
|
+
),
|
|
890
|
+
hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
|
|
891
|
+
};
|
|
892
|
+
};
|
|
1020
893
|
|
|
1021
894
|
// src/utils.ts
|
|
1022
895
|
var deepClone = (obj) => {
|
|
@@ -1097,320 +970,119 @@ var getRandomColor = () => {
|
|
|
1097
970
|
};
|
|
1098
971
|
|
|
1099
972
|
// src/conditions.ts
|
|
1100
|
-
var
|
|
1101
|
-
var
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
];
|
|
1109
|
-
var rulesTypes = Object.values(import_types4.RulesType);
|
|
1110
|
-
var isActiveRulesByCurrentTime = (rules) => {
|
|
1111
|
-
const { endDate, endDateHour, endDateMinute, startDate, startDateHour, startDateMinute } = rules.data;
|
|
1112
|
-
const startTime = /* @__PURE__ */ new Date(`${startDate} ${startDateHour}:${startDateMinute}:00`);
|
|
1113
|
-
const endTime = /* @__PURE__ */ new Date(`${endDate} ${endDateHour}:${endDateMinute}:00`);
|
|
1114
|
-
const now = /* @__PURE__ */ new Date();
|
|
1115
|
-
if (!endDate) {
|
|
1116
|
-
return (0, import_date_fns.isAfter)(now, startTime);
|
|
1117
|
-
}
|
|
1118
|
-
return (0, import_date_fns.isAfter)(now, startTime) && (0, import_date_fns.isBefore)(now, endTime);
|
|
973
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
974
|
+
var parseUrl = (url) => {
|
|
975
|
+
const urlPatterns = url.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);
|
|
976
|
+
if (!urlPatterns) {
|
|
977
|
+
return null;
|
|
978
|
+
}
|
|
979
|
+
const [, , scheme = "", domain = "", path = "", , query = "", fragment = ""] = urlPatterns;
|
|
980
|
+
return { scheme, domain, path, query, fragment };
|
|
1119
981
|
};
|
|
1120
|
-
var
|
|
1121
|
-
const
|
|
1122
|
-
const
|
|
1123
|
-
if (!
|
|
1124
|
-
return
|
|
982
|
+
var replaceWildcard = (input, s1, s2) => {
|
|
983
|
+
const withSpecialWords = replaceSpecialWords(input);
|
|
984
|
+
const withWildcard = withSpecialWords.replace(/\\\*/g, `${s1}*`);
|
|
985
|
+
if (!s2) {
|
|
986
|
+
return withWildcard;
|
|
1125
987
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
988
|
+
return withWildcard.replace(/:[a-z0-9_]+/g, `[^${s2}]+`);
|
|
989
|
+
};
|
|
990
|
+
var replaceSpecialWords = (str) => {
|
|
991
|
+
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
992
|
+
};
|
|
993
|
+
var parsePattern = (pattern) => {
|
|
994
|
+
if (!pattern || !pattern.trim()) {
|
|
995
|
+
return null;
|
|
1132
996
|
}
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
return
|
|
997
|
+
const _pattern = parseUrl(pattern);
|
|
998
|
+
if (!_pattern) {
|
|
999
|
+
console.error("Invalid URL pattern:", pattern);
|
|
1000
|
+
return null;
|
|
1137
1001
|
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1002
|
+
const { scheme, domain, path, query, fragment } = _pattern;
|
|
1003
|
+
const _scheme = scheme ? replaceSpecialWords(scheme) : "[a-z\\d]+";
|
|
1004
|
+
const _domain = domain ? replaceWildcard(domain, "[^/]", ".") : "[^/]*";
|
|
1005
|
+
const _fragment = fragment ? replaceWildcard(fragment, ".", "/") : "(#.*)?";
|
|
1006
|
+
const _path = path ? replaceWildcard(path, "[^?#]", "/") : "/[^?#]*";
|
|
1007
|
+
let _query = "(\\?[^#]*)?";
|
|
1008
|
+
if (query) {
|
|
1009
|
+
new URLSearchParams(query).forEach((value, key) => {
|
|
1010
|
+
const _str = value === "" ? "=?" : value === "*" ? "(=[^&#]*)?" : `=${replaceWildcard(value, "[^#]")}`;
|
|
1011
|
+
_query += `(?=.*[?&]${replaceSpecialWords(key)}${_str}([&#]|$))`;
|
|
1012
|
+
});
|
|
1013
|
+
_query += "\\?[^#]*";
|
|
1140
1014
|
}
|
|
1141
|
-
return
|
|
1015
|
+
return new RegExp(`^${_scheme}://${_domain}(:\\d+)?${_path}${_query}${_fragment}$`);
|
|
1142
1016
|
};
|
|
1143
|
-
var
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
if (rules.type === import_types4.RulesType.CONTENT) {
|
|
1149
|
-
const content = contents.find((c) => c.contentId === rules.data.contentId);
|
|
1150
|
-
if (content) {
|
|
1151
|
-
const contentSession = {
|
|
1152
|
-
contentId: content.contentId,
|
|
1153
|
-
latestSession: content.latestSession,
|
|
1154
|
-
totalSessions: content.totalSessions,
|
|
1155
|
-
dismissedSessions: content.dismissedSessions,
|
|
1156
|
-
completedSessions: content.completedSessions,
|
|
1157
|
-
seenSessions: content.seenSessions
|
|
1158
|
-
};
|
|
1159
|
-
rulesCondition[j].actived = isActivedContentRulesCondition(rules, contentSession);
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
} else if (rules.conditions) {
|
|
1163
|
-
rulesCondition[j].conditions = await activedContentRulesConditions(
|
|
1164
|
-
rules.conditions,
|
|
1165
|
-
contents
|
|
1166
|
-
);
|
|
1017
|
+
var isMatchUrlPattern = (_url, includes, excludes) => {
|
|
1018
|
+
const isMatchIncludesConditions = includes.length > 0 ? includes.some((_include) => {
|
|
1019
|
+
const reg = parsePattern(_include);
|
|
1020
|
+
if (reg) {
|
|
1021
|
+
return reg.test(_url);
|
|
1167
1022
|
}
|
|
1168
|
-
}
|
|
1169
|
-
return rulesCondition;
|
|
1170
|
-
};
|
|
1171
|
-
var isActive = (autoStartRules) => {
|
|
1172
|
-
if (!autoStartRules || autoStartRules.length === 0) {
|
|
1173
1023
|
return false;
|
|
1174
|
-
}
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
if (
|
|
1178
|
-
return
|
|
1024
|
+
}) : true;
|
|
1025
|
+
const isMatchExcludesConditions = excludes.length > 0 ? excludes.some((_exclude) => {
|
|
1026
|
+
const reg = parsePattern(_exclude);
|
|
1027
|
+
if (reg) {
|
|
1028
|
+
return reg.test(_url);
|
|
1179
1029
|
}
|
|
1180
|
-
return isActive(rule.conditions);
|
|
1181
|
-
});
|
|
1182
|
-
return operator === "and" ? actives.length === autoStartRules.length : actives.length > 0;
|
|
1183
|
-
};
|
|
1184
|
-
var isActiveContent = (content) => {
|
|
1185
|
-
const { enabledAutoStartRules, autoStartRules } = content.config;
|
|
1186
|
-
if (!enabledAutoStartRules || !isActive(autoStartRules)) {
|
|
1187
1030
|
return false;
|
|
1188
|
-
}
|
|
1189
|
-
return
|
|
1190
|
-
};
|
|
1191
|
-
var priorityCompare = (a, b) => {
|
|
1192
|
-
var _a, _b, _c, _d;
|
|
1193
|
-
const a1 = (_b = (_a = a == null ? void 0 : a.config) == null ? void 0 : _a.autoStartRulesSetting) == null ? void 0 : _b.priority;
|
|
1194
|
-
const a2 = (_d = (_c = b == null ? void 0 : b.config) == null ? void 0 : _c.autoStartRulesSetting) == null ? void 0 : _d.priority;
|
|
1195
|
-
if (!a1 || !a2) {
|
|
1196
|
-
return 0;
|
|
1197
|
-
}
|
|
1198
|
-
const index1 = PRIORITIES.indexOf(a1);
|
|
1199
|
-
const index2 = PRIORITIES.indexOf(a2);
|
|
1200
|
-
if (index1 > index2) {
|
|
1201
|
-
return 1;
|
|
1202
|
-
}
|
|
1203
|
-
if (index1 < index2) {
|
|
1204
|
-
return -1;
|
|
1205
|
-
}
|
|
1206
|
-
return 0;
|
|
1207
|
-
};
|
|
1208
|
-
var filterAutoStartContent = (contents, type) => {
|
|
1209
|
-
return contents.filter((content) => {
|
|
1210
|
-
const isActive2 = isActiveContent(content);
|
|
1211
|
-
const isValid = isValidContent(content, contents);
|
|
1212
|
-
return content.type === type && isActive2 && isValid;
|
|
1213
|
-
}).sort(priorityCompare);
|
|
1031
|
+
}) : false;
|
|
1032
|
+
return isMatchIncludesConditions && !isMatchExcludesConditions;
|
|
1214
1033
|
};
|
|
1215
|
-
var
|
|
1216
|
-
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
for (let index = 0; index < contents.length; index++) {
|
|
1221
|
-
const content = contents[index];
|
|
1222
|
-
if (content.id === contentId || content.type !== contentType) {
|
|
1223
|
-
continue;
|
|
1224
|
-
}
|
|
1225
|
-
const sessionBizEvents = (_a = content.latestSession) == null ? void 0 : _a.bizEvent;
|
|
1226
|
-
if (sessionBizEvents && sessionBizEvents.length > 0) {
|
|
1227
|
-
bizEvents.push(...sessionBizEvents.filter((e) => {
|
|
1228
|
-
var _a2;
|
|
1229
|
-
return ((_a2 = e == null ? void 0 : e.event) == null ? void 0 : _a2.codeName) === eventCodeName;
|
|
1230
|
-
}));
|
|
1231
|
-
}
|
|
1034
|
+
var compareConditionsItem = (item1, item2) => {
|
|
1035
|
+
const { data = {}, ...others1 } = item1;
|
|
1036
|
+
const { data: data2 = {}, ...others2 } = item2;
|
|
1037
|
+
if (!(0, import_fast_deep_equal.default)(others2, others1)) {
|
|
1038
|
+
return false;
|
|
1232
1039
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
var findLatestEvent = (bizEvents) => {
|
|
1236
|
-
const initialValue = bizEvents[0];
|
|
1237
|
-
const lastEvent = bizEvents.reduce(
|
|
1238
|
-
(accumulator, currentValue) => {
|
|
1239
|
-
if ((0, import_date_fns.isAfter)(new Date(currentValue.createdAt), new Date(accumulator.createdAt))) {
|
|
1240
|
-
return currentValue;
|
|
1241
|
-
}
|
|
1242
|
-
return accumulator;
|
|
1243
|
-
},
|
|
1244
|
-
initialValue
|
|
1245
|
-
);
|
|
1246
|
-
return lastEvent;
|
|
1247
|
-
};
|
|
1248
|
-
var completeEventMapping = {
|
|
1249
|
-
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_COMPLETED,
|
|
1250
|
-
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_ACTIVATED,
|
|
1251
|
-
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_COMPLETED
|
|
1252
|
-
};
|
|
1253
|
-
var showEventMapping = {
|
|
1254
|
-
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_STEP_SEEN,
|
|
1255
|
-
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_SEEN,
|
|
1256
|
-
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_SEEN
|
|
1257
|
-
};
|
|
1258
|
-
var isDismissedEventMapping = {
|
|
1259
|
-
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_ENDED,
|
|
1260
|
-
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_DISMISSED,
|
|
1261
|
-
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_DISMISSED
|
|
1262
|
-
};
|
|
1263
|
-
var isGreaterThenDuration = (dateLeft, dateRight, unit, duration) => {
|
|
1264
|
-
switch (unit) {
|
|
1265
|
-
case import_types4.FrequencyUnits.SECONDS: {
|
|
1266
|
-
if ((0, import_date_fns.differenceInSeconds)(dateLeft, dateRight) >= duration) {
|
|
1267
|
-
return true;
|
|
1268
|
-
}
|
|
1040
|
+
for (const key in data) {
|
|
1041
|
+
if (!(0, import_fast_deep_equal.default)(data[key], data2[key])) {
|
|
1269
1042
|
return false;
|
|
1270
1043
|
}
|
|
1271
|
-
case import_types4.FrequencyUnits.MINUTES:
|
|
1272
|
-
if ((0, import_date_fns.differenceInMinutes)(dateLeft, dateRight) >= duration) {
|
|
1273
|
-
return true;
|
|
1274
|
-
}
|
|
1275
|
-
return false;
|
|
1276
|
-
case import_types4.FrequencyUnits.HOURS:
|
|
1277
|
-
if ((0, import_date_fns.differenceInHours)(dateLeft, dateRight) >= duration) {
|
|
1278
|
-
return true;
|
|
1279
|
-
}
|
|
1280
|
-
return false;
|
|
1281
|
-
case import_types4.FrequencyUnits.DAYES:
|
|
1282
|
-
if ((0, import_date_fns.differenceInDays)(dateLeft, dateRight) >= duration) {
|
|
1283
|
-
return true;
|
|
1284
|
-
}
|
|
1285
|
-
return false;
|
|
1286
|
-
default:
|
|
1287
|
-
return false;
|
|
1288
1044
|
}
|
|
1045
|
+
return true;
|
|
1289
1046
|
};
|
|
1290
|
-
var
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
var _a2;
|
|
1295
|
-
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.CHECKLIST_DISMISSED;
|
|
1296
|
-
}
|
|
1297
|
-
);
|
|
1298
|
-
};
|
|
1299
|
-
var flowIsDismissed = (latestSession) => {
|
|
1300
|
-
var _a;
|
|
1301
|
-
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find((event) => {
|
|
1302
|
-
var _a2;
|
|
1303
|
-
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.FLOW_ENDED;
|
|
1304
|
-
});
|
|
1305
|
-
};
|
|
1306
|
-
var flowIsSeen = (latestSession) => {
|
|
1307
|
-
var _a;
|
|
1308
|
-
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find(
|
|
1309
|
-
(event) => {
|
|
1310
|
-
var _a2;
|
|
1311
|
-
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.FLOW_STEP_SEEN;
|
|
1312
|
-
}
|
|
1313
|
-
);
|
|
1314
|
-
};
|
|
1315
|
-
var checklistIsSeen = (latestSession) => {
|
|
1316
|
-
var _a;
|
|
1317
|
-
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find(
|
|
1318
|
-
(event) => {
|
|
1319
|
-
var _a2;
|
|
1320
|
-
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.CHECKLIST_SEEN;
|
|
1321
|
-
}
|
|
1322
|
-
);
|
|
1323
|
-
};
|
|
1324
|
-
var isValidContent = (content, contents) => {
|
|
1325
|
-
var _a;
|
|
1326
|
-
const now = /* @__PURE__ */ new Date();
|
|
1327
|
-
if (content.type === import_types4.ContentDataType.FLOW) {
|
|
1328
|
-
if (!content.steps || content.steps.length === 0) {
|
|
1329
|
-
return false;
|
|
1330
|
-
}
|
|
1331
|
-
} else {
|
|
1332
|
-
if (!content.data) {
|
|
1333
|
-
return false;
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
if (!content.config.autoStartRulesSetting) {
|
|
1047
|
+
var conditionsIsSame = (rr1, rr2) => {
|
|
1048
|
+
const r1 = [...rr1];
|
|
1049
|
+
const r2 = [...rr2];
|
|
1050
|
+
if (r1.length === 0 && r2.length === 0) {
|
|
1337
1051
|
return true;
|
|
1338
1052
|
}
|
|
1339
|
-
|
|
1340
|
-
const completedSessions = content.completedSessions;
|
|
1341
|
-
const dismissedSessions = content.dismissedSessions;
|
|
1342
|
-
if (startIfNotComplete && completedSessions > 0) {
|
|
1053
|
+
if (r1.length !== r2.length) {
|
|
1343
1054
|
return false;
|
|
1344
1055
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
const contentType = content.type;
|
|
1349
|
-
const lastEventName = showEventMapping[contentType];
|
|
1350
|
-
const lastEvent = getLatestEvent(content, contents, lastEventName);
|
|
1351
|
-
const contentEvents = (_a = content.latestSession) == null ? void 0 : _a.bizEvent;
|
|
1352
|
-
if (lastEvent && frequency && frequency.atLeast && !isGreaterThenDuration(
|
|
1353
|
-
now,
|
|
1354
|
-
new Date(lastEvent.createdAt),
|
|
1355
|
-
frequency.atLeast.unit,
|
|
1356
|
-
frequency.atLeast.duration
|
|
1357
|
-
)) {
|
|
1056
|
+
const group1 = r1.filter((item) => item.type === "group");
|
|
1057
|
+
const group2 = r2.filter((item) => item.type === "group");
|
|
1058
|
+
if (group1.length !== group2.length) {
|
|
1358
1059
|
return false;
|
|
1359
1060
|
}
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
return true;
|
|
1365
|
-
}
|
|
1366
|
-
const showEventName = showEventMapping[contentType];
|
|
1367
|
-
const showEvents = contentEvents == null ? void 0 : contentEvents.filter(
|
|
1368
|
-
(e) => {
|
|
1369
|
-
var _a2, _b;
|
|
1370
|
-
return ((_a2 = e == null ? void 0 : e.event) == null ? void 0 : _a2.codeName) === showEventName && (contentType === import_types4.ContentDataType.FLOW ? ((_b = e == null ? void 0 : e.data) == null ? void 0 : _b.flow_step_number) === 0 : true);
|
|
1371
|
-
}
|
|
1372
|
-
);
|
|
1373
|
-
if (!showEvents || showEvents.length === 0) {
|
|
1374
|
-
return true;
|
|
1375
|
-
}
|
|
1376
|
-
const lastShowEvent = findLatestEvent(showEvents);
|
|
1377
|
-
const lastShowEventDate = new Date(lastShowEvent.createdAt);
|
|
1378
|
-
if (frequency.frequency === import_types4.Frequency.MULTIPLE) {
|
|
1379
|
-
if (frequency.every.times && dismissedSessions >= frequency.every.times) {
|
|
1380
|
-
return false;
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
if (frequency.frequency === import_types4.Frequency.MULTIPLE || frequency.frequency === import_types4.Frequency.UNLIMITED) {
|
|
1384
|
-
if (!isGreaterThenDuration(now, lastShowEventDate, frequency.every.unit, frequency.every.duration)) {
|
|
1061
|
+
for (let index = 0; index < r1.length; index++) {
|
|
1062
|
+
const item1 = r1[index];
|
|
1063
|
+
const item2 = r2[index];
|
|
1064
|
+
if (!item1 || !item2) {
|
|
1385
1065
|
return false;
|
|
1386
1066
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
if (hashSearch) {
|
|
1403
|
-
const hashParams = new URLSearchParams(hashSearch);
|
|
1404
|
-
if (hashParams.has(paramName)) {
|
|
1405
|
-
return hashParams.get(paramName);
|
|
1406
|
-
}
|
|
1067
|
+
if (item1.type === "group") {
|
|
1068
|
+
if (!item2.conditions) {
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
const c1 = item1.conditions;
|
|
1072
|
+
const c2 = item2.conditions;
|
|
1073
|
+
if (item1.operators !== item2.operators) {
|
|
1074
|
+
return false;
|
|
1075
|
+
}
|
|
1076
|
+
if (!conditionsIsSame(c1, c2)) {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
} else {
|
|
1080
|
+
if (!compareConditionsItem(item1, item2)) {
|
|
1081
|
+
return false;
|
|
1407
1082
|
}
|
|
1408
1083
|
}
|
|
1409
|
-
return null;
|
|
1410
|
-
} catch (error) {
|
|
1411
|
-
console.error("Error parsing URL:", error);
|
|
1412
|
-
return null;
|
|
1413
1084
|
}
|
|
1085
|
+
return true;
|
|
1414
1086
|
};
|
|
1415
1087
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1416
1088
|
0 && (module.exports = {
|
|
@@ -1418,12 +1090,9 @@ var parseUrlParams = (url, paramName) => {
|
|
|
1418
1090
|
ArrayProto,
|
|
1419
1091
|
XMLHttpRequest,
|
|
1420
1092
|
absoluteUrl,
|
|
1421
|
-
activedContentRulesConditions,
|
|
1422
1093
|
assignableWindow,
|
|
1423
1094
|
autoStartConditions,
|
|
1424
1095
|
buildConfig,
|
|
1425
|
-
checklistIsDimissed,
|
|
1426
|
-
checklistIsSeen,
|
|
1427
1096
|
cn,
|
|
1428
1097
|
conditionsIsSame,
|
|
1429
1098
|
convertSettings,
|
|
@@ -1435,9 +1104,6 @@ var parseUrlParams = (url, paramName) => {
|
|
|
1435
1104
|
document,
|
|
1436
1105
|
evalCode,
|
|
1437
1106
|
fetch,
|
|
1438
|
-
filterAutoStartContent,
|
|
1439
|
-
flowIsDismissed,
|
|
1440
|
-
flowIsSeen,
|
|
1441
1107
|
formatDate,
|
|
1442
1108
|
generateAutoStateColors,
|
|
1443
1109
|
getAuthToken,
|
|
@@ -1460,7 +1126,6 @@ var parseUrlParams = (url, paramName) => {
|
|
|
1460
1126
|
hexToHSLString,
|
|
1461
1127
|
hexToRGBStr,
|
|
1462
1128
|
hexToRgb,
|
|
1463
|
-
isActiveRulesByCurrentTime,
|
|
1464
1129
|
isArray,
|
|
1465
1130
|
isBoolean,
|
|
1466
1131
|
isDark,
|
|
@@ -1483,14 +1148,12 @@ var parseUrlParams = (url, paramName) => {
|
|
|
1483
1148
|
isUint8Array,
|
|
1484
1149
|
isUndefined,
|
|
1485
1150
|
isUrl,
|
|
1486
|
-
isValidContent,
|
|
1487
1151
|
isValidSelector,
|
|
1488
1152
|
location,
|
|
1489
1153
|
mergeThemeDefaultSettings,
|
|
1490
1154
|
nativeForEach,
|
|
1491
1155
|
nativeIndexOf,
|
|
1492
1156
|
navigator,
|
|
1493
|
-
parseUrlParams,
|
|
1494
1157
|
removeAuthToken,
|
|
1495
1158
|
setAuthToken,
|
|
1496
1159
|
storage,
|