@usertour/helpers 0.0.36 → 0.0.38
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/__tests__/condition.test.js +2 -2
- package/dist/{chunk-G5P7KULU.js → chunk-QWYOGIRR.js} +20 -1
- package/dist/conditions/condition.js +2 -2
- package/dist/conditions/index.js +4 -4
- package/dist/convert-settings.js +2 -2
- package/dist/error.cjs +34 -1
- package/dist/error.js +3 -1
- package/dist/index.cjs +152 -136
- package/dist/index.js +28 -28
- package/package.json +4 -4
- package/dist/{chunk-3UOSPZEP.js → chunk-E3B3AWMJ.js} +3 -3
- package/dist/{chunk-USHOKNHQ.js → chunk-F7ZHCELE.js} +3 -3
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
evaluateRulesConditions,
|
|
3
3
|
filterConditionsByType,
|
|
4
4
|
isConditionsActived
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-E3B3AWMJ.js";
|
|
6
6
|
import "../chunk-YYIGUZNZ.js";
|
|
7
7
|
import "../chunk-PAESAL23.js";
|
|
8
|
-
import "../chunk-JQWKLXW6.js";
|
|
9
8
|
import "../chunk-KYDXF7SU.js";
|
|
9
|
+
import "../chunk-JQWKLXW6.js";
|
|
10
10
|
import "../chunk-GFH3VWOC.js";
|
|
11
11
|
import "../chunk-3KG2HTZ3.js";
|
|
12
12
|
import "../chunk-XEO3YXBM.js";
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isTimeConditionDataLegacy,
|
|
3
|
+
isTimeConditionDataV2
|
|
4
|
+
} from "./chunk-JQWKLXW6.js";
|
|
5
|
+
|
|
1
6
|
// src/error.ts
|
|
2
7
|
import {
|
|
3
8
|
AttributeDataType,
|
|
@@ -53,7 +58,21 @@ var getUrlPatternError = (data) => {
|
|
|
53
58
|
};
|
|
54
59
|
var getCurrentTimeError = (data) => {
|
|
55
60
|
const ret = { showError: false, errorInfo: "" };
|
|
56
|
-
if (
|
|
61
|
+
if (isTimeConditionDataV2(data)) {
|
|
62
|
+
if (!data.startTime && !data.endTime) {
|
|
63
|
+
ret.showError = true;
|
|
64
|
+
ret.errorInfo = "Either start or end time be filled in";
|
|
65
|
+
}
|
|
66
|
+
return ret;
|
|
67
|
+
}
|
|
68
|
+
if (isTimeConditionDataLegacy(data)) {
|
|
69
|
+
if (!data.startDate && !data.endDate) {
|
|
70
|
+
ret.showError = true;
|
|
71
|
+
ret.errorInfo = "Either start or end time be filled in";
|
|
72
|
+
}
|
|
73
|
+
return ret;
|
|
74
|
+
}
|
|
75
|
+
if (!data || typeof data === "object" && Object.keys(data).length === 0) {
|
|
57
76
|
ret.showError = true;
|
|
58
77
|
ret.errorInfo = "Either start or end time be filled in";
|
|
59
78
|
}
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
isConditionsActived,
|
|
9
9
|
isEqual,
|
|
10
10
|
regenerateConditionIds
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-E3B3AWMJ.js";
|
|
12
12
|
import "../chunk-YYIGUZNZ.js";
|
|
13
13
|
import "../chunk-PAESAL23.js";
|
|
14
|
-
import "../chunk-JQWKLXW6.js";
|
|
15
14
|
import "../chunk-KYDXF7SU.js";
|
|
15
|
+
import "../chunk-JQWKLXW6.js";
|
|
16
16
|
import "../chunk-GFH3VWOC.js";
|
|
17
17
|
import "../chunk-3KG2HTZ3.js";
|
|
18
18
|
import "../chunk-XEO3YXBM.js";
|
package/dist/conditions/index.js
CHANGED
|
@@ -9,12 +9,15 @@ import {
|
|
|
9
9
|
isConditionsActived,
|
|
10
10
|
isEqual,
|
|
11
11
|
regenerateConditionIds
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-E3B3AWMJ.js";
|
|
13
13
|
import {
|
|
14
14
|
evaluateUrlCondition,
|
|
15
15
|
isMatchUrlPattern
|
|
16
16
|
} from "../chunk-YYIGUZNZ.js";
|
|
17
17
|
import "../chunk-PAESAL23.js";
|
|
18
|
+
import {
|
|
19
|
+
evaluateAttributeCondition
|
|
20
|
+
} from "../chunk-KYDXF7SU.js";
|
|
18
21
|
import {
|
|
19
22
|
convertTimeConditionLegacyToV2,
|
|
20
23
|
evaluateTimeCondition,
|
|
@@ -22,9 +25,6 @@ import {
|
|
|
22
25
|
isTimeConditionDataV2,
|
|
23
26
|
normalizeTimeConditionData
|
|
24
27
|
} from "../chunk-JQWKLXW6.js";
|
|
25
|
-
import {
|
|
26
|
-
evaluateAttributeCondition
|
|
27
|
-
} from "../chunk-KYDXF7SU.js";
|
|
28
28
|
import "../chunk-GFH3VWOC.js";
|
|
29
29
|
import "../chunk-3KG2HTZ3.js";
|
|
30
30
|
import "../chunk-XEO3YXBM.js";
|
package/dist/convert-settings.js
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
convertSettings,
|
|
3
3
|
convertToCssVars,
|
|
4
4
|
mergeThemeDefaultSettings
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-GFH3VWOC.js";
|
|
5
|
+
} from "./chunk-F7ZHCELE.js";
|
|
7
6
|
import "./chunk-VT24VOAZ.js";
|
|
7
|
+
import "./chunk-GFH3VWOC.js";
|
|
8
8
|
import "./chunk-XEO3YXBM.js";
|
|
9
9
|
export {
|
|
10
10
|
convertSettings,
|
package/dist/error.cjs
CHANGED
|
@@ -39,6 +39,25 @@ __export(error_exports, {
|
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(error_exports);
|
|
41
41
|
var import_types = require("@usertour/types");
|
|
42
|
+
|
|
43
|
+
// src/conditions/time.ts
|
|
44
|
+
var import_date_fns = require("date-fns");
|
|
45
|
+
|
|
46
|
+
// src/type-utils.ts
|
|
47
|
+
var nativeIsArray = Array.isArray;
|
|
48
|
+
var ObjProto = Object.prototype;
|
|
49
|
+
var objToString = ObjProto.toString;
|
|
50
|
+
var objHasOwn = ObjProto.hasOwnProperty;
|
|
51
|
+
|
|
52
|
+
// src/conditions/time.ts
|
|
53
|
+
function isTimeConditionDataV2(data) {
|
|
54
|
+
return data && ("startTime" in data || "endTime" in data);
|
|
55
|
+
}
|
|
56
|
+
function isTimeConditionDataLegacy(data) {
|
|
57
|
+
return data && ("startDate" in data || "startDateHour" in data);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/error.ts
|
|
42
61
|
var isValidSelector = (selector) => {
|
|
43
62
|
if (!selector) {
|
|
44
63
|
return false;
|
|
@@ -89,7 +108,21 @@ var getUrlPatternError = (data) => {
|
|
|
89
108
|
};
|
|
90
109
|
var getCurrentTimeError = (data) => {
|
|
91
110
|
const ret = { showError: false, errorInfo: "" };
|
|
92
|
-
if (
|
|
111
|
+
if (isTimeConditionDataV2(data)) {
|
|
112
|
+
if (!data.startTime && !data.endTime) {
|
|
113
|
+
ret.showError = true;
|
|
114
|
+
ret.errorInfo = "Either start or end time be filled in";
|
|
115
|
+
}
|
|
116
|
+
return ret;
|
|
117
|
+
}
|
|
118
|
+
if (isTimeConditionDataLegacy(data)) {
|
|
119
|
+
if (!data.startDate && !data.endDate) {
|
|
120
|
+
ret.showError = true;
|
|
121
|
+
ret.errorInfo = "Either start or end time be filled in";
|
|
122
|
+
}
|
|
123
|
+
return ret;
|
|
124
|
+
}
|
|
125
|
+
if (!data || typeof data === "object" && Object.keys(data).length === 0) {
|
|
93
126
|
ret.showError = true;
|
|
94
127
|
ret.errorInfo = "Either start or end time be filled in";
|
|
95
128
|
}
|
package/dist/error.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -461,6 +461,143 @@ var convertToCssVars = (settings, type = "tooltip") => {
|
|
|
461
461
|
|
|
462
462
|
// src/error.ts
|
|
463
463
|
var import_types2 = require("@usertour/types");
|
|
464
|
+
|
|
465
|
+
// src/conditions/time.ts
|
|
466
|
+
var import_date_fns = require("date-fns");
|
|
467
|
+
function isEmpty(value) {
|
|
468
|
+
return isNullish(value) || isEmptyString(value);
|
|
469
|
+
}
|
|
470
|
+
function hasRequiredFields(data, type) {
|
|
471
|
+
if (type === "start") {
|
|
472
|
+
return !isEmpty(data.startDate) && !isEmpty(data.startDateHour) && !isEmpty(data.startDateMinute);
|
|
473
|
+
}
|
|
474
|
+
return !isEmpty(data.endDate) && !isEmpty(data.endDateHour) && !isEmpty(data.endDateMinute);
|
|
475
|
+
}
|
|
476
|
+
function parseLegacyDate(dateStr) {
|
|
477
|
+
const [month, day, year] = dateStr.split("/");
|
|
478
|
+
if (!month || !day || !year) {
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
return {
|
|
482
|
+
month: Number.parseInt(month),
|
|
483
|
+
day: Number.parseInt(day),
|
|
484
|
+
year: Number.parseInt(year)
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function createLegacyDateTime(data, type) {
|
|
488
|
+
const dateStr = type === "start" ? data.startDate : data.endDate;
|
|
489
|
+
const hourStr = type === "start" ? data.startDateHour : data.endDateHour;
|
|
490
|
+
const minuteStr = type === "start" ? data.startDateMinute : data.endDateMinute;
|
|
491
|
+
if (!dateStr || !hourStr || !minuteStr) {
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
const dateParts = parseLegacyDate(dateStr);
|
|
495
|
+
if (!dateParts) {
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
const dateTime = new Date(
|
|
499
|
+
dateParts.year,
|
|
500
|
+
dateParts.month - 1,
|
|
501
|
+
dateParts.day,
|
|
502
|
+
Number.parseInt(hourStr),
|
|
503
|
+
Number.parseInt(minuteStr),
|
|
504
|
+
0
|
|
505
|
+
);
|
|
506
|
+
return (0, import_date_fns.isValid)(dateTime) ? dateTime : null;
|
|
507
|
+
}
|
|
508
|
+
function isTimeConditionDataV2(data) {
|
|
509
|
+
return data && ("startTime" in data || "endTime" in data);
|
|
510
|
+
}
|
|
511
|
+
function isTimeConditionDataLegacy(data) {
|
|
512
|
+
return data && ("startDate" in data || "startDateHour" in data);
|
|
513
|
+
}
|
|
514
|
+
function convertTimeConditionLegacyToV2(legacyData) {
|
|
515
|
+
try {
|
|
516
|
+
if (!hasRequiredFields(legacyData, "start")) {
|
|
517
|
+
return null;
|
|
518
|
+
}
|
|
519
|
+
const startDateTime = createLegacyDateTime(legacyData, "start");
|
|
520
|
+
if (!startDateTime) {
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
const result = {
|
|
524
|
+
startTime: startDateTime.toISOString()
|
|
525
|
+
};
|
|
526
|
+
if (hasRequiredFields(legacyData, "end")) {
|
|
527
|
+
const endDateTime = createLegacyDateTime(legacyData, "end");
|
|
528
|
+
if (endDateTime) {
|
|
529
|
+
result.endTime = endDateTime.toISOString();
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return result;
|
|
533
|
+
} catch {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function normalizeTimeConditionData(data) {
|
|
538
|
+
if (!data) {
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
if (isTimeConditionDataV2(data)) {
|
|
542
|
+
return data;
|
|
543
|
+
}
|
|
544
|
+
if (isTimeConditionDataLegacy(data)) {
|
|
545
|
+
return convertTimeConditionLegacyToV2(data);
|
|
546
|
+
}
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
function evaluateTimeConditionV2(data) {
|
|
550
|
+
if (!data.startTime) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
const startTime = (0, import_date_fns.parseISO)(data.startTime);
|
|
554
|
+
if (!(0, import_date_fns.isValid)(startTime)) {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
const now = /* @__PURE__ */ new Date();
|
|
558
|
+
if (!data.endTime) {
|
|
559
|
+
return (0, import_date_fns.isAfter)(now, startTime);
|
|
560
|
+
}
|
|
561
|
+
const endTime = (0, import_date_fns.parseISO)(data.endTime);
|
|
562
|
+
if (!(0, import_date_fns.isValid)(endTime)) {
|
|
563
|
+
return false;
|
|
564
|
+
}
|
|
565
|
+
return (0, import_date_fns.isAfter)(now, startTime) && (0, import_date_fns.isBefore)(now, endTime);
|
|
566
|
+
}
|
|
567
|
+
function evaluateTimeConditionLegacy(data) {
|
|
568
|
+
if (!hasRequiredFields(data, "start")) {
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
const startDateTime = createLegacyDateTime(data, "start");
|
|
572
|
+
if (!startDateTime) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
const now = /* @__PURE__ */ new Date();
|
|
576
|
+
if (!hasRequiredFields(data, "end")) {
|
|
577
|
+
return (0, import_date_fns.isAfter)(now, startDateTime);
|
|
578
|
+
}
|
|
579
|
+
const endDateTime = createLegacyDateTime(data, "end");
|
|
580
|
+
if (!endDateTime) {
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
return (0, import_date_fns.isAfter)(now, startDateTime) && (0, import_date_fns.isBefore)(now, endDateTime);
|
|
584
|
+
}
|
|
585
|
+
var evaluateTimeCondition = (rules) => {
|
|
586
|
+
try {
|
|
587
|
+
const data = rules.data || {};
|
|
588
|
+
if (isTimeConditionDataV2(data)) {
|
|
589
|
+
return evaluateTimeConditionV2(data);
|
|
590
|
+
}
|
|
591
|
+
if (isTimeConditionDataLegacy(data)) {
|
|
592
|
+
return evaluateTimeConditionLegacy(data);
|
|
593
|
+
}
|
|
594
|
+
return false;
|
|
595
|
+
} catch {
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
// src/error.ts
|
|
464
601
|
var isValidSelector = (selector) => {
|
|
465
602
|
if (!selector) {
|
|
466
603
|
return false;
|
|
@@ -511,7 +648,21 @@ var getUrlPatternError = (data) => {
|
|
|
511
648
|
};
|
|
512
649
|
var getCurrentTimeError = (data) => {
|
|
513
650
|
const ret = { showError: false, errorInfo: "" };
|
|
514
|
-
if (
|
|
651
|
+
if (isTimeConditionDataV2(data)) {
|
|
652
|
+
if (!data.startTime && !data.endTime) {
|
|
653
|
+
ret.showError = true;
|
|
654
|
+
ret.errorInfo = "Either start or end time be filled in";
|
|
655
|
+
}
|
|
656
|
+
return ret;
|
|
657
|
+
}
|
|
658
|
+
if (isTimeConditionDataLegacy(data)) {
|
|
659
|
+
if (!data.startDate && !data.endDate) {
|
|
660
|
+
ret.showError = true;
|
|
661
|
+
ret.errorInfo = "Either start or end time be filled in";
|
|
662
|
+
}
|
|
663
|
+
return ret;
|
|
664
|
+
}
|
|
665
|
+
if (!data || typeof data === "object" && Object.keys(data).length === 0) {
|
|
515
666
|
ret.showError = true;
|
|
516
667
|
ret.errorInfo = "Either start or end time be filled in";
|
|
517
668
|
}
|
|
@@ -1105,141 +1256,6 @@ var evaluateUrlCondition = (rules, url) => {
|
|
|
1105
1256
|
return isMatchUrlPattern(url, includes, excludes);
|
|
1106
1257
|
};
|
|
1107
1258
|
|
|
1108
|
-
// src/conditions/time.ts
|
|
1109
|
-
var import_date_fns = require("date-fns");
|
|
1110
|
-
function isEmpty(value) {
|
|
1111
|
-
return isNullish(value) || isEmptyString(value);
|
|
1112
|
-
}
|
|
1113
|
-
function hasRequiredFields(data, type) {
|
|
1114
|
-
if (type === "start") {
|
|
1115
|
-
return !isEmpty(data.startDate) && !isEmpty(data.startDateHour) && !isEmpty(data.startDateMinute);
|
|
1116
|
-
}
|
|
1117
|
-
return !isEmpty(data.endDate) && !isEmpty(data.endDateHour) && !isEmpty(data.endDateMinute);
|
|
1118
|
-
}
|
|
1119
|
-
function parseLegacyDate(dateStr) {
|
|
1120
|
-
const [month, day, year] = dateStr.split("/");
|
|
1121
|
-
if (!month || !day || !year) {
|
|
1122
|
-
return null;
|
|
1123
|
-
}
|
|
1124
|
-
return {
|
|
1125
|
-
month: Number.parseInt(month),
|
|
1126
|
-
day: Number.parseInt(day),
|
|
1127
|
-
year: Number.parseInt(year)
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
function createLegacyDateTime(data, type) {
|
|
1131
|
-
const dateStr = type === "start" ? data.startDate : data.endDate;
|
|
1132
|
-
const hourStr = type === "start" ? data.startDateHour : data.endDateHour;
|
|
1133
|
-
const minuteStr = type === "start" ? data.startDateMinute : data.endDateMinute;
|
|
1134
|
-
if (!dateStr || !hourStr || !minuteStr) {
|
|
1135
|
-
return null;
|
|
1136
|
-
}
|
|
1137
|
-
const dateParts = parseLegacyDate(dateStr);
|
|
1138
|
-
if (!dateParts) {
|
|
1139
|
-
return null;
|
|
1140
|
-
}
|
|
1141
|
-
const dateTime = new Date(
|
|
1142
|
-
dateParts.year,
|
|
1143
|
-
dateParts.month - 1,
|
|
1144
|
-
dateParts.day,
|
|
1145
|
-
Number.parseInt(hourStr),
|
|
1146
|
-
Number.parseInt(minuteStr),
|
|
1147
|
-
0
|
|
1148
|
-
);
|
|
1149
|
-
return (0, import_date_fns.isValid)(dateTime) ? dateTime : null;
|
|
1150
|
-
}
|
|
1151
|
-
function isTimeConditionDataV2(data) {
|
|
1152
|
-
return data && ("startTime" in data || "endTime" in data);
|
|
1153
|
-
}
|
|
1154
|
-
function isTimeConditionDataLegacy(data) {
|
|
1155
|
-
return data && ("startDate" in data || "startDateHour" in data);
|
|
1156
|
-
}
|
|
1157
|
-
function convertTimeConditionLegacyToV2(legacyData) {
|
|
1158
|
-
try {
|
|
1159
|
-
if (!hasRequiredFields(legacyData, "start")) {
|
|
1160
|
-
return null;
|
|
1161
|
-
}
|
|
1162
|
-
const startDateTime = createLegacyDateTime(legacyData, "start");
|
|
1163
|
-
if (!startDateTime) {
|
|
1164
|
-
return null;
|
|
1165
|
-
}
|
|
1166
|
-
const result = {
|
|
1167
|
-
startTime: startDateTime.toISOString()
|
|
1168
|
-
};
|
|
1169
|
-
if (hasRequiredFields(legacyData, "end")) {
|
|
1170
|
-
const endDateTime = createLegacyDateTime(legacyData, "end");
|
|
1171
|
-
if (endDateTime) {
|
|
1172
|
-
result.endTime = endDateTime.toISOString();
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
return result;
|
|
1176
|
-
} catch {
|
|
1177
|
-
return null;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
function normalizeTimeConditionData(data) {
|
|
1181
|
-
if (!data) {
|
|
1182
|
-
return null;
|
|
1183
|
-
}
|
|
1184
|
-
if (isTimeConditionDataV2(data)) {
|
|
1185
|
-
return data;
|
|
1186
|
-
}
|
|
1187
|
-
if (isTimeConditionDataLegacy(data)) {
|
|
1188
|
-
return convertTimeConditionLegacyToV2(data);
|
|
1189
|
-
}
|
|
1190
|
-
return null;
|
|
1191
|
-
}
|
|
1192
|
-
function evaluateTimeConditionV2(data) {
|
|
1193
|
-
if (!data.startTime) {
|
|
1194
|
-
return false;
|
|
1195
|
-
}
|
|
1196
|
-
const startTime = (0, import_date_fns.parseISO)(data.startTime);
|
|
1197
|
-
if (!(0, import_date_fns.isValid)(startTime)) {
|
|
1198
|
-
return false;
|
|
1199
|
-
}
|
|
1200
|
-
const now = /* @__PURE__ */ new Date();
|
|
1201
|
-
if (!data.endTime) {
|
|
1202
|
-
return (0, import_date_fns.isAfter)(now, startTime);
|
|
1203
|
-
}
|
|
1204
|
-
const endTime = (0, import_date_fns.parseISO)(data.endTime);
|
|
1205
|
-
if (!(0, import_date_fns.isValid)(endTime)) {
|
|
1206
|
-
return false;
|
|
1207
|
-
}
|
|
1208
|
-
return (0, import_date_fns.isAfter)(now, startTime) && (0, import_date_fns.isBefore)(now, endTime);
|
|
1209
|
-
}
|
|
1210
|
-
function evaluateTimeConditionLegacy(data) {
|
|
1211
|
-
if (!hasRequiredFields(data, "start")) {
|
|
1212
|
-
return false;
|
|
1213
|
-
}
|
|
1214
|
-
const startDateTime = createLegacyDateTime(data, "start");
|
|
1215
|
-
if (!startDateTime) {
|
|
1216
|
-
return false;
|
|
1217
|
-
}
|
|
1218
|
-
const now = /* @__PURE__ */ new Date();
|
|
1219
|
-
if (!hasRequiredFields(data, "end")) {
|
|
1220
|
-
return (0, import_date_fns.isAfter)(now, startDateTime);
|
|
1221
|
-
}
|
|
1222
|
-
const endDateTime = createLegacyDateTime(data, "end");
|
|
1223
|
-
if (!endDateTime) {
|
|
1224
|
-
return false;
|
|
1225
|
-
}
|
|
1226
|
-
return (0, import_date_fns.isAfter)(now, startDateTime) && (0, import_date_fns.isBefore)(now, endDateTime);
|
|
1227
|
-
}
|
|
1228
|
-
var evaluateTimeCondition = (rules) => {
|
|
1229
|
-
try {
|
|
1230
|
-
const data = rules.data || {};
|
|
1231
|
-
if (isTimeConditionDataV2(data)) {
|
|
1232
|
-
return evaluateTimeConditionV2(data);
|
|
1233
|
-
}
|
|
1234
|
-
if (isTimeConditionDataLegacy(data)) {
|
|
1235
|
-
return evaluateTimeConditionLegacy(data);
|
|
1236
|
-
}
|
|
1237
|
-
return false;
|
|
1238
|
-
} catch {
|
|
1239
|
-
return false;
|
|
1240
|
-
}
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1243
1259
|
// src/conditions/attribute.ts
|
|
1244
1260
|
var import_types4 = require("@usertour/types");
|
|
1245
1261
|
var import_date_fns2 = require("date-fns");
|
package/dist/index.js
CHANGED
|
@@ -20,19 +20,12 @@ import {
|
|
|
20
20
|
isConditionsActived,
|
|
21
21
|
isEqual,
|
|
22
22
|
regenerateConditionIds
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-E3B3AWMJ.js";
|
|
24
24
|
import {
|
|
25
25
|
evaluateUrlCondition,
|
|
26
26
|
isMatchUrlPattern
|
|
27
27
|
} from "./chunk-YYIGUZNZ.js";
|
|
28
28
|
import "./chunk-PAESAL23.js";
|
|
29
|
-
import {
|
|
30
|
-
convertTimeConditionLegacyToV2,
|
|
31
|
-
evaluateTimeCondition,
|
|
32
|
-
isTimeConditionDataLegacy,
|
|
33
|
-
isTimeConditionDataV2,
|
|
34
|
-
normalizeTimeConditionData
|
|
35
|
-
} from "./chunk-JQWKLXW6.js";
|
|
36
29
|
import {
|
|
37
30
|
evaluateAttributeCondition
|
|
38
31
|
} from "./chunk-KYDXF7SU.js";
|
|
@@ -58,25 +51,7 @@ import {
|
|
|
58
51
|
convertSettings,
|
|
59
52
|
convertToCssVars,
|
|
60
53
|
mergeThemeDefaultSettings
|
|
61
|
-
} from "./chunk-
|
|
62
|
-
import {
|
|
63
|
-
isArray,
|
|
64
|
-
isBoolean,
|
|
65
|
-
isDate,
|
|
66
|
-
isDocument,
|
|
67
|
-
isEmptyObject,
|
|
68
|
-
isEmptyString,
|
|
69
|
-
isFile,
|
|
70
|
-
isFormData,
|
|
71
|
-
isFunction,
|
|
72
|
-
isNull,
|
|
73
|
-
isNullish,
|
|
74
|
-
isNumber,
|
|
75
|
-
isObject,
|
|
76
|
-
isString,
|
|
77
|
-
isUint8Array,
|
|
78
|
-
isUndefined
|
|
79
|
-
} from "./chunk-GFH3VWOC.js";
|
|
54
|
+
} from "./chunk-F7ZHCELE.js";
|
|
80
55
|
import {
|
|
81
56
|
generateAutoStateColors,
|
|
82
57
|
hexToHSLString,
|
|
@@ -99,7 +74,32 @@ import {
|
|
|
99
74
|
hasActionError,
|
|
100
75
|
hasError,
|
|
101
76
|
isValidSelector
|
|
102
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-QWYOGIRR.js";
|
|
78
|
+
import {
|
|
79
|
+
convertTimeConditionLegacyToV2,
|
|
80
|
+
evaluateTimeCondition,
|
|
81
|
+
isTimeConditionDataLegacy,
|
|
82
|
+
isTimeConditionDataV2,
|
|
83
|
+
normalizeTimeConditionData
|
|
84
|
+
} from "./chunk-JQWKLXW6.js";
|
|
85
|
+
import {
|
|
86
|
+
isArray,
|
|
87
|
+
isBoolean,
|
|
88
|
+
isDate,
|
|
89
|
+
isDocument,
|
|
90
|
+
isEmptyObject,
|
|
91
|
+
isEmptyString,
|
|
92
|
+
isFile,
|
|
93
|
+
isFormData,
|
|
94
|
+
isFunction,
|
|
95
|
+
isNull,
|
|
96
|
+
isNullish,
|
|
97
|
+
isNumber,
|
|
98
|
+
isObject,
|
|
99
|
+
isString,
|
|
100
|
+
isUint8Array,
|
|
101
|
+
isUndefined
|
|
102
|
+
} from "./chunk-GFH3VWOC.js";
|
|
103
103
|
import {
|
|
104
104
|
AbortController,
|
|
105
105
|
ArrayProto,
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usertour/helpers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Utility functions and helpers shared across the UserTour project",
|
|
6
6
|
"homepage": "https://www.usertour.io",
|
|
7
7
|
"author": "Usertour, Inc. <support@usertour.io>",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
|
-
"main": "./dist/index.
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
10
|
"module": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"import": "./dist/index.js",
|
|
15
|
-
"require": "./dist/index.
|
|
15
|
+
"require": "./dist/index.cjs",
|
|
16
16
|
"types": "./dist/index.d.ts"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
32
|
-
"@usertour/types": "^0.0.
|
|
32
|
+
"@usertour/types": "^0.0.29",
|
|
33
33
|
"chroma-js": "^3.1.2",
|
|
34
34
|
"class-variance-authority": "^0.4.0",
|
|
35
35
|
"clsx": "^1.2.1",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
evaluateUrlCondition
|
|
3
3
|
} from "./chunk-YYIGUZNZ.js";
|
|
4
|
-
import {
|
|
5
|
-
evaluateTimeCondition
|
|
6
|
-
} from "./chunk-JQWKLXW6.js";
|
|
7
4
|
import {
|
|
8
5
|
evaluateAttributeCondition
|
|
9
6
|
} from "./chunk-KYDXF7SU.js";
|
|
7
|
+
import {
|
|
8
|
+
evaluateTimeCondition
|
|
9
|
+
} from "./chunk-JQWKLXW6.js";
|
|
10
10
|
import {
|
|
11
11
|
cuid
|
|
12
12
|
} from "./chunk-3KG2HTZ3.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isUndefined
|
|
3
|
-
} from "./chunk-GFH3VWOC.js";
|
|
4
1
|
import {
|
|
5
2
|
hexToHSLString,
|
|
6
3
|
hexToRGBStr
|
|
7
4
|
} from "./chunk-VT24VOAZ.js";
|
|
5
|
+
import {
|
|
6
|
+
isUndefined
|
|
7
|
+
} from "./chunk-GFH3VWOC.js";
|
|
8
8
|
|
|
9
9
|
// src/convert-settings.ts
|
|
10
10
|
import { defaultSettings } from "@usertour/types";
|