@usertour/helpers 0.0.1
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/README.md +68 -0
- package/dist/auth.cjs +161 -0
- package/dist/auth.d.cts +8 -0
- package/dist/auth.d.ts +8 -0
- package/dist/auth.js +15 -0
- package/dist/chunk-2AEGAICC.js +13 -0
- package/dist/chunk-3KG2HTZ3.js +79 -0
- package/dist/chunk-3ZGH3NRU.js +103 -0
- package/dist/chunk-64BFWPHJ.js +50 -0
- package/dist/chunk-BBPZYUJR.js +28 -0
- package/dist/chunk-FGFMTWFT.js +23 -0
- package/dist/chunk-FNQIIEWK.js +121 -0
- package/dist/chunk-FW54TSA3.js +41 -0
- package/dist/chunk-G5P7KULU.js +223 -0
- package/dist/chunk-GFH3VWOC.js +70 -0
- package/dist/chunk-H7VA3ML2.js +29 -0
- package/dist/chunk-USHOKNHQ.js +243 -0
- package/dist/chunk-VT24VOAZ.js +48 -0
- package/dist/chunk-XEO3YXBM.js +10 -0
- package/dist/chunk-ZNFXGN3M.js +25 -0
- package/dist/color.cjs +84 -0
- package/dist/color.d.cts +29 -0
- package/dist/color.d.ts +29 -0
- package/dist/color.js +11 -0
- package/dist/condition.cjs +157 -0
- package/dist/condition.d.cts +7 -0
- package/dist/condition.d.ts +7 -0
- package/dist/condition.js +11 -0
- package/dist/content-settings.cjs +76 -0
- package/dist/content-settings.d.cts +7 -0
- package/dist/content-settings.d.ts +7 -0
- package/dist/content-settings.js +11 -0
- package/dist/content.cjs +53 -0
- package/dist/content.d.cts +6 -0
- package/dist/content.d.ts +6 -0
- package/dist/content.js +9 -0
- package/dist/convert-settings.cjs +308 -0
- package/dist/convert-settings.d.cts +7 -0
- package/dist/convert-settings.d.ts +7 -0
- package/dist/convert-settings.js +13 -0
- package/dist/error.cjs +259 -0
- package/dist/error.d.cts +56 -0
- package/dist/error.d.ts +56 -0
- package/dist/error.js +37 -0
- package/dist/globals.cjs +64 -0
- package/dist/globals.d.cts +27 -0
- package/dist/globals.d.ts +27 -0
- package/dist/globals.js +29 -0
- package/dist/helper.cjs +111 -0
- package/dist/helper.d.cts +17 -0
- package/dist/helper.d.ts +17 -0
- package/dist/helper.js +23 -0
- package/dist/index.cjs +1165 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +178 -0
- package/dist/is-url.cjs +49 -0
- package/dist/is-url.d.cts +14 -0
- package/dist/is-url.d.ts +14 -0
- package/dist/is-url.js +7 -0
- package/dist/settings.cjs +65 -0
- package/dist/settings.d.cts +5 -0
- package/dist/settings.d.ts +5 -0
- package/dist/settings.js +7 -0
- package/dist/storage.cjs +142 -0
- package/dist/storage.d.cts +25 -0
- package/dist/storage.d.ts +25 -0
- package/dist/storage.js +8 -0
- package/dist/type-utils.cjs +109 -0
- package/dist/type-utils.d.cts +18 -0
- package/dist/type-utils.d.ts +18 -0
- package/dist/type-utils.js +37 -0
- package/dist/utils.cjs +37 -0
- package/dist/utils.d.cts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +7 -0
- package/dist/vite-env.d.cjs +1 -0
- package/dist/vite-env.d.d.cts +1 -0
- package/dist/vite-env.d.d.ts +1 -0
- package/dist/vite-env.d.js +0 -0
- package/package.json +56 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/is-url.ts
|
|
2
|
+
var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
|
3
|
+
var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
|
|
4
|
+
var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
|
|
5
|
+
function isUrl(string) {
|
|
6
|
+
if (typeof string !== "string") {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const match = string.match(protocolAndDomainRE);
|
|
10
|
+
if (!match) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const everythingAfterProtocol = match[1];
|
|
14
|
+
if (!everythingAfterProtocol) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol)) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
isUrl
|
|
25
|
+
};
|
package/dist/color.cjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/color.ts
|
|
31
|
+
var color_exports = {};
|
|
32
|
+
__export(color_exports, {
|
|
33
|
+
generateAutoStateColors: () => generateAutoStateColors,
|
|
34
|
+
hexToHSLString: () => hexToHSLString,
|
|
35
|
+
hexToRGBStr: () => hexToRGBStr
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(color_exports);
|
|
38
|
+
var import_chroma_js = __toESM(require("chroma-js"), 1);
|
|
39
|
+
function hexToHSLString(hexColor) {
|
|
40
|
+
try {
|
|
41
|
+
const color = (0, import_chroma_js.default)(hexColor);
|
|
42
|
+
const [h, s, l] = color.hsl();
|
|
43
|
+
const hDeg = Math.round(h || 0);
|
|
44
|
+
const sPct = Math.round(s * 100);
|
|
45
|
+
const lPct = Math.round(l * 100);
|
|
46
|
+
return `${hDeg} ${sPct}% ${lPct}%`;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.warn(`Failed to convert ${hexColor} to HSL string:`, error);
|
|
49
|
+
return "0 0% 0%";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
var hexToRGBStr = (hex) => {
|
|
53
|
+
try {
|
|
54
|
+
const color = (0, import_chroma_js.default)(hex);
|
|
55
|
+
const [r, g, b] = color.rgb();
|
|
56
|
+
return `${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}`;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.warn(`Failed to convert ${hex} to RGB string:`, error);
|
|
59
|
+
return "0, 0, 0";
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function generateAutoStateColors(baseColor, brandColor, hoverRatio = 0.12, activeRatio = 0.24) {
|
|
63
|
+
const isBaseLight = (0, import_chroma_js.default)(baseColor).luminance() > 0.8;
|
|
64
|
+
const isBaseBrand = import_chroma_js.default.distance(baseColor, brandColor) < 10;
|
|
65
|
+
let hover;
|
|
66
|
+
let active;
|
|
67
|
+
if (isBaseBrand) {
|
|
68
|
+
hover = import_chroma_js.default.mix(baseColor, "#fff", hoverRatio, "rgb").hex();
|
|
69
|
+
active = import_chroma_js.default.mix(baseColor, "#fff", activeRatio, "rgb").hex();
|
|
70
|
+
} else if (isBaseLight) {
|
|
71
|
+
hover = import_chroma_js.default.mix(baseColor, brandColor, hoverRatio, "rgb").hex();
|
|
72
|
+
active = import_chroma_js.default.mix(baseColor, brandColor, activeRatio, "rgb").hex();
|
|
73
|
+
} else {
|
|
74
|
+
hover = import_chroma_js.default.mix(baseColor, brandColor, hoverRatio, "rgb").hex();
|
|
75
|
+
active = import_chroma_js.default.mix(baseColor, brandColor, activeRatio, "rgb").hex();
|
|
76
|
+
}
|
|
77
|
+
return { hover, active };
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
generateAutoStateColors,
|
|
82
|
+
hexToHSLString,
|
|
83
|
+
hexToRGBStr
|
|
84
|
+
});
|
package/dist/color.d.cts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert hex color to HSL string format for Tailwind CSS
|
|
3
|
+
* @param hexColor - Hex color string (e.g., "#FFFFFF")
|
|
4
|
+
* @returns HSL string format (e.g., "0 0% 100%")
|
|
5
|
+
*/
|
|
6
|
+
declare function hexToHSLString(hexColor: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Convert hex color to RGB string format (e.g., "255, 255, 255")
|
|
9
|
+
* @param hex - Hex color string (e.g., "#FFFFFF")
|
|
10
|
+
* @returns RGB string format without alpha
|
|
11
|
+
*/
|
|
12
|
+
declare const hexToRGBStr: (hex: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Automatically generate hover and active colors based on baseColor and brandColor.
|
|
15
|
+
* If baseColor is similar to brandColor, hover is mixed with white (LAB), active is darkened.
|
|
16
|
+
* If baseColor is light (e.g., white), hover/active are mixed with brandColor (LAB).
|
|
17
|
+
* Otherwise, hover is mixed with brandColor (LAB), active is darkened.
|
|
18
|
+
* @param baseColor - The base color (e.g., button or content background)
|
|
19
|
+
* @param brandColor - The brand color
|
|
20
|
+
* @param hoverRatio - Mix ratio for hover state (default 0.15)
|
|
21
|
+
* @param activeDarken - Darken factor for active state (default 0.12)
|
|
22
|
+
* @returns An object with hover and active color hex strings
|
|
23
|
+
*/
|
|
24
|
+
declare function generateAutoStateColors(baseColor: string, brandColor: string, hoverRatio?: number, activeRatio?: number): {
|
|
25
|
+
hover: string;
|
|
26
|
+
active: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { generateAutoStateColors, hexToHSLString, hexToRGBStr };
|
package/dist/color.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert hex color to HSL string format for Tailwind CSS
|
|
3
|
+
* @param hexColor - Hex color string (e.g., "#FFFFFF")
|
|
4
|
+
* @returns HSL string format (e.g., "0 0% 100%")
|
|
5
|
+
*/
|
|
6
|
+
declare function hexToHSLString(hexColor: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Convert hex color to RGB string format (e.g., "255, 255, 255")
|
|
9
|
+
* @param hex - Hex color string (e.g., "#FFFFFF")
|
|
10
|
+
* @returns RGB string format without alpha
|
|
11
|
+
*/
|
|
12
|
+
declare const hexToRGBStr: (hex: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Automatically generate hover and active colors based on baseColor and brandColor.
|
|
15
|
+
* If baseColor is similar to brandColor, hover is mixed with white (LAB), active is darkened.
|
|
16
|
+
* If baseColor is light (e.g., white), hover/active are mixed with brandColor (LAB).
|
|
17
|
+
* Otherwise, hover is mixed with brandColor (LAB), active is darkened.
|
|
18
|
+
* @param baseColor - The base color (e.g., button or content background)
|
|
19
|
+
* @param brandColor - The brand color
|
|
20
|
+
* @param hoverRatio - Mix ratio for hover state (default 0.15)
|
|
21
|
+
* @param activeDarken - Darken factor for active state (default 0.12)
|
|
22
|
+
* @returns An object with hover and active color hex strings
|
|
23
|
+
*/
|
|
24
|
+
declare function generateAutoStateColors(baseColor: string, brandColor: string, hoverRatio?: number, activeRatio?: number): {
|
|
25
|
+
hover: string;
|
|
26
|
+
active: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { generateAutoStateColors, hexToHSLString, hexToRGBStr };
|
package/dist/color.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/condition.ts
|
|
31
|
+
var condition_exports = {};
|
|
32
|
+
__export(condition_exports, {
|
|
33
|
+
conditionsIsSame: () => conditionsIsSame,
|
|
34
|
+
isEqual: () => import_fast_deep_equal.default,
|
|
35
|
+
isMatchUrlPattern: () => isMatchUrlPattern
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(condition_exports);
|
|
38
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
39
|
+
var parseUrl = (url) => {
|
|
40
|
+
const urlPatterns = url.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);
|
|
41
|
+
if (!urlPatterns) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const [, , scheme = "", domain = "", path = "", , query = "", fragment = ""] = urlPatterns;
|
|
45
|
+
return { scheme, domain, path, query, fragment };
|
|
46
|
+
};
|
|
47
|
+
var replaceWildcard = (input, s1, s2) => {
|
|
48
|
+
const withSpecialWords = replaceSpecialWords(input);
|
|
49
|
+
const withWildcard = withSpecialWords.replace(/\\\*/g, `${s1}*`);
|
|
50
|
+
if (!s2) {
|
|
51
|
+
return withWildcard;
|
|
52
|
+
}
|
|
53
|
+
return withWildcard.replace(/:[a-z0-9_]+/g, `[^${s2}]+`);
|
|
54
|
+
};
|
|
55
|
+
var replaceSpecialWords = (str) => {
|
|
56
|
+
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
57
|
+
};
|
|
58
|
+
var parsePattern = (pattern) => {
|
|
59
|
+
if (!pattern || !pattern.trim()) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const _pattern = parseUrl(pattern);
|
|
63
|
+
if (!_pattern) {
|
|
64
|
+
console.error("Invalid URL pattern:", pattern);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const { scheme, domain, path, query, fragment } = _pattern;
|
|
68
|
+
const _scheme = scheme ? replaceSpecialWords(scheme) : "[a-z\\d]+";
|
|
69
|
+
const _domain = domain ? replaceWildcard(domain, "[^/]", ".") : "[^/]*";
|
|
70
|
+
const _fragment = fragment ? replaceWildcard(fragment, ".", "/") : "(#.*)?";
|
|
71
|
+
const _path = path ? replaceWildcard(path, "[^?#]", "/") : "/[^?#]*";
|
|
72
|
+
let _query = "(\\?[^#]*)?";
|
|
73
|
+
if (query) {
|
|
74
|
+
new URLSearchParams(query).forEach((value, key) => {
|
|
75
|
+
const _str = value === "" ? "=?" : value === "*" ? "(=[^&#]*)?" : `=${replaceWildcard(value, "[^#]")}`;
|
|
76
|
+
_query += `(?=.*[?&]${replaceSpecialWords(key)}${_str}([&#]|$))`;
|
|
77
|
+
});
|
|
78
|
+
_query += "\\?[^#]*";
|
|
79
|
+
}
|
|
80
|
+
return new RegExp(`^${_scheme}://${_domain}(:\\d+)?${_path}${_query}${_fragment}$`);
|
|
81
|
+
};
|
|
82
|
+
var isMatchUrlPattern = (_url, includes, excludes) => {
|
|
83
|
+
const isMatchIncludesConditions = includes.length > 0 ? includes.some((_include) => {
|
|
84
|
+
const reg = parsePattern(_include);
|
|
85
|
+
if (reg) {
|
|
86
|
+
return reg.test(_url);
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}) : true;
|
|
90
|
+
const isMatchExcludesConditions = excludes.length > 0 ? excludes.some((_exclude) => {
|
|
91
|
+
const reg = parsePattern(_exclude);
|
|
92
|
+
if (reg) {
|
|
93
|
+
return reg.test(_url);
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}) : false;
|
|
97
|
+
return isMatchIncludesConditions && !isMatchExcludesConditions;
|
|
98
|
+
};
|
|
99
|
+
var compareConditionsItem = (item1, item2) => {
|
|
100
|
+
const { data = {}, ...others1 } = item1;
|
|
101
|
+
const { data: data2 = {}, ...others2 } = item2;
|
|
102
|
+
if (!(0, import_fast_deep_equal.default)(others2, others1)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
for (const key in data) {
|
|
106
|
+
if (!(0, import_fast_deep_equal.default)(data[key], data2[key])) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
var conditionsIsSame = (rr1, rr2) => {
|
|
113
|
+
const r1 = [...rr1];
|
|
114
|
+
const r2 = [...rr2];
|
|
115
|
+
if (r1.length === 0 && r2.length === 0) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (r1.length !== r2.length) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
const group1 = r1.filter((item) => item.type === "group");
|
|
122
|
+
const group2 = r2.filter((item) => item.type === "group");
|
|
123
|
+
if (group1.length !== group2.length) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
for (let index = 0; index < r1.length; index++) {
|
|
127
|
+
const item1 = r1[index];
|
|
128
|
+
const item2 = r2[index];
|
|
129
|
+
if (!item1 || !item2) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
if (item1.type === "group") {
|
|
133
|
+
if (!item2.conditions) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
const c1 = item1.conditions;
|
|
137
|
+
const c2 = item2.conditions;
|
|
138
|
+
if (item1.operators !== item2.operators) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (!conditionsIsSame(c1, c2)) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
if (!compareConditionsItem(item1, item2)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
};
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {
|
|
154
|
+
conditionsIsSame,
|
|
155
|
+
isEqual,
|
|
156
|
+
isMatchUrlPattern
|
|
157
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RulesCondition } from '@usertour/types';
|
|
2
|
+
export { default as isEqual } from 'fast-deep-equal';
|
|
3
|
+
|
|
4
|
+
declare const isMatchUrlPattern: (_url: string, includes: string[], excludes: string[]) => boolean;
|
|
5
|
+
declare const conditionsIsSame: (rr1: RulesCondition[], rr2: RulesCondition[]) => boolean;
|
|
6
|
+
|
|
7
|
+
export { conditionsIsSame, isMatchUrlPattern };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RulesCondition } from '@usertour/types';
|
|
2
|
+
export { default as isEqual } from 'fast-deep-equal';
|
|
3
|
+
|
|
4
|
+
declare const isMatchUrlPattern: (_url: string, includes: string[], excludes: string[]) => boolean;
|
|
5
|
+
declare const conditionsIsSame: (rr1: RulesCondition[], rr2: RulesCondition[]) => boolean;
|
|
6
|
+
|
|
7
|
+
export { conditionsIsSame, isMatchUrlPattern };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/content-settings.ts
|
|
21
|
+
var content_settings_exports = {};
|
|
22
|
+
__export(content_settings_exports, {
|
|
23
|
+
autoStartConditions: () => autoStartConditions,
|
|
24
|
+
buildConfig: () => buildConfig,
|
|
25
|
+
defaultContentConfig: () => defaultContentConfig
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(content_settings_exports);
|
|
28
|
+
var import_types = require("@usertour/types");
|
|
29
|
+
var import_deepmerge_ts = require("deepmerge-ts");
|
|
30
|
+
var rulesSetting = {
|
|
31
|
+
// frequency: {
|
|
32
|
+
// frequency: Frequency.ONCE,
|
|
33
|
+
// every: { duration: 0, times: 1, unit: FrequencyUnits.MINUTES },
|
|
34
|
+
// atLeast: { duration: 0, unit: FrequencyUnits.MINUTES },
|
|
35
|
+
// },
|
|
36
|
+
startIfNotComplete: false,
|
|
37
|
+
priority: import_types.ContentPriority.MEDIUM,
|
|
38
|
+
wait: 0
|
|
39
|
+
};
|
|
40
|
+
var hideRulesSetting = {};
|
|
41
|
+
var defaultContentConfig = {
|
|
42
|
+
enabledAutoStartRules: false,
|
|
43
|
+
enabledHideRules: false,
|
|
44
|
+
autoStartRules: [],
|
|
45
|
+
hideRules: [],
|
|
46
|
+
autoStartRulesSetting: rulesSetting,
|
|
47
|
+
hideRulesSetting
|
|
48
|
+
};
|
|
49
|
+
var autoStartConditions = {
|
|
50
|
+
...defaultContentConfig,
|
|
51
|
+
enabledAutoStartRules: true,
|
|
52
|
+
autoStartRules: [
|
|
53
|
+
{
|
|
54
|
+
data: { excludes: [], includes: ["/*"] },
|
|
55
|
+
type: "current-page",
|
|
56
|
+
operators: "and"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
var buildConfig = (config) => {
|
|
61
|
+
return {
|
|
62
|
+
...defaultContentConfig,
|
|
63
|
+
...config,
|
|
64
|
+
autoStartRulesSetting: (0, import_deepmerge_ts.deepmerge)(
|
|
65
|
+
defaultContentConfig.autoStartRulesSetting,
|
|
66
|
+
(config == null ? void 0 : config.autoStartRulesSetting) || {}
|
|
67
|
+
),
|
|
68
|
+
hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
autoStartConditions,
|
|
74
|
+
buildConfig,
|
|
75
|
+
defaultContentConfig
|
|
76
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ContentConfigObject } from '@usertour/types';
|
|
2
|
+
|
|
3
|
+
declare const defaultContentConfig: ContentConfigObject;
|
|
4
|
+
declare const autoStartConditions: ContentConfigObject;
|
|
5
|
+
declare const buildConfig: (config: ContentConfigObject | undefined) => ContentConfigObject;
|
|
6
|
+
|
|
7
|
+
export { autoStartConditions, buildConfig, defaultContentConfig };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ContentConfigObject } from '@usertour/types';
|
|
2
|
+
|
|
3
|
+
declare const defaultContentConfig: ContentConfigObject;
|
|
4
|
+
declare const autoStartConditions: ContentConfigObject;
|
|
5
|
+
declare const buildConfig: (config: ContentConfigObject | undefined) => ContentConfigObject;
|
|
6
|
+
|
|
7
|
+
export { autoStartConditions, buildConfig, defaultContentConfig };
|
package/dist/content.cjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/content.ts
|
|
21
|
+
var content_exports = {};
|
|
22
|
+
__export(content_exports, {
|
|
23
|
+
isPublishedAtLeastOneEnvironment: () => isPublishedAtLeastOneEnvironment,
|
|
24
|
+
isPublishedInAllEnvironments: () => isPublishedInAllEnvironments
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(content_exports);
|
|
27
|
+
var isPublishedInAllEnvironments = (content, environmentList, version) => {
|
|
28
|
+
const isPublishedInAllEnvironments2 = environmentList == null ? void 0 : environmentList.every(
|
|
29
|
+
(env) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return (_a = content == null ? void 0 : content.contentOnEnvironments) == null ? void 0 : _a.find(
|
|
32
|
+
(item) => item.published && item.publishedVersionId === (version == null ? void 0 : version.id) && item.environment.id === env.id
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
const isPublishedInOneEnvironment = (content == null ? void 0 : content.published) && (content == null ? void 0 : content.publishedVersionId) === (version == null ? void 0 : version.id) && environmentList && (environmentList == null ? void 0 : environmentList.length) === 1;
|
|
37
|
+
return (content == null ? void 0 : content.contentOnEnvironments) && (content == null ? void 0 : content.contentOnEnvironments.length) > 0 ? Boolean(isPublishedInAllEnvironments2) : Boolean(isPublishedInOneEnvironment);
|
|
38
|
+
};
|
|
39
|
+
var isPublishedAtLeastOneEnvironment = (content) => {
|
|
40
|
+
var _a;
|
|
41
|
+
if ((content == null ? void 0 : content.contentOnEnvironments) && ((_a = content == null ? void 0 : content.contentOnEnvironments) == null ? void 0 : _a.length) > 0) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if ((content == null ? void 0 : content.published) && (content == null ? void 0 : content.publishedVersionId)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
};
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
isPublishedAtLeastOneEnvironment,
|
|
52
|
+
isPublishedInAllEnvironments
|
|
53
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Content, Environment, ContentVersion } from '@usertour/types';
|
|
2
|
+
|
|
3
|
+
declare const isPublishedInAllEnvironments: (content: Content | null, environmentList: Environment[] | null, version: ContentVersion | null) => boolean;
|
|
4
|
+
declare const isPublishedAtLeastOneEnvironment: (content: Content | null) => boolean;
|
|
5
|
+
|
|
6
|
+
export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Content, Environment, ContentVersion } from '@usertour/types';
|
|
2
|
+
|
|
3
|
+
declare const isPublishedInAllEnvironments: (content: Content | null, environmentList: Environment[] | null, version: ContentVersion | null) => boolean;
|
|
4
|
+
declare const isPublishedAtLeastOneEnvironment: (content: Content | null) => boolean;
|
|
5
|
+
|
|
6
|
+
export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments };
|