@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.
Files changed (81) hide show
  1. package/README.md +68 -0
  2. package/dist/auth.cjs +161 -0
  3. package/dist/auth.d.cts +8 -0
  4. package/dist/auth.d.ts +8 -0
  5. package/dist/auth.js +15 -0
  6. package/dist/chunk-2AEGAICC.js +13 -0
  7. package/dist/chunk-3KG2HTZ3.js +79 -0
  8. package/dist/chunk-3ZGH3NRU.js +103 -0
  9. package/dist/chunk-64BFWPHJ.js +50 -0
  10. package/dist/chunk-BBPZYUJR.js +28 -0
  11. package/dist/chunk-FGFMTWFT.js +23 -0
  12. package/dist/chunk-FNQIIEWK.js +121 -0
  13. package/dist/chunk-FW54TSA3.js +41 -0
  14. package/dist/chunk-G5P7KULU.js +223 -0
  15. package/dist/chunk-GFH3VWOC.js +70 -0
  16. package/dist/chunk-H7VA3ML2.js +29 -0
  17. package/dist/chunk-USHOKNHQ.js +243 -0
  18. package/dist/chunk-VT24VOAZ.js +48 -0
  19. package/dist/chunk-XEO3YXBM.js +10 -0
  20. package/dist/chunk-ZNFXGN3M.js +25 -0
  21. package/dist/color.cjs +84 -0
  22. package/dist/color.d.cts +29 -0
  23. package/dist/color.d.ts +29 -0
  24. package/dist/color.js +11 -0
  25. package/dist/condition.cjs +157 -0
  26. package/dist/condition.d.cts +7 -0
  27. package/dist/condition.d.ts +7 -0
  28. package/dist/condition.js +11 -0
  29. package/dist/content-settings.cjs +76 -0
  30. package/dist/content-settings.d.cts +7 -0
  31. package/dist/content-settings.d.ts +7 -0
  32. package/dist/content-settings.js +11 -0
  33. package/dist/content.cjs +53 -0
  34. package/dist/content.d.cts +6 -0
  35. package/dist/content.d.ts +6 -0
  36. package/dist/content.js +9 -0
  37. package/dist/convert-settings.cjs +308 -0
  38. package/dist/convert-settings.d.cts +7 -0
  39. package/dist/convert-settings.d.ts +7 -0
  40. package/dist/convert-settings.js +13 -0
  41. package/dist/error.cjs +259 -0
  42. package/dist/error.d.cts +56 -0
  43. package/dist/error.d.ts +56 -0
  44. package/dist/error.js +37 -0
  45. package/dist/globals.cjs +64 -0
  46. package/dist/globals.d.cts +27 -0
  47. package/dist/globals.d.ts +27 -0
  48. package/dist/globals.js +29 -0
  49. package/dist/helper.cjs +111 -0
  50. package/dist/helper.d.cts +17 -0
  51. package/dist/helper.d.ts +17 -0
  52. package/dist/helper.js +23 -0
  53. package/dist/index.cjs +1165 -0
  54. package/dist/index.d.cts +18 -0
  55. package/dist/index.d.ts +18 -0
  56. package/dist/index.js +178 -0
  57. package/dist/is-url.cjs +49 -0
  58. package/dist/is-url.d.cts +14 -0
  59. package/dist/is-url.d.ts +14 -0
  60. package/dist/is-url.js +7 -0
  61. package/dist/settings.cjs +65 -0
  62. package/dist/settings.d.cts +5 -0
  63. package/dist/settings.d.ts +5 -0
  64. package/dist/settings.js +7 -0
  65. package/dist/storage.cjs +142 -0
  66. package/dist/storage.d.cts +25 -0
  67. package/dist/storage.d.ts +25 -0
  68. package/dist/storage.js +8 -0
  69. package/dist/type-utils.cjs +109 -0
  70. package/dist/type-utils.d.cts +18 -0
  71. package/dist/type-utils.d.ts +18 -0
  72. package/dist/type-utils.js +37 -0
  73. package/dist/utils.cjs +37 -0
  74. package/dist/utils.d.cts +8 -0
  75. package/dist/utils.d.ts +8 -0
  76. package/dist/utils.js +7 -0
  77. package/dist/vite-env.d.cjs +1 -0
  78. package/dist/vite-env.d.d.cts +1 -0
  79. package/dist/vite-env.d.d.ts +1 -0
  80. package/dist/vite-env.d.js +0 -0
  81. package/package.json +56 -0
@@ -0,0 +1,56 @@
1
+ import { ElementSelectorPropsData, RulesUserAttributeData, Attribute, RulesCondition } from '@usertour/types';
2
+
3
+ declare const isValidSelector: (selector: ElementSelectorPropsData) => boolean;
4
+ declare const getUserAttrError: (data: RulesUserAttributeData | undefined, attributes: Attribute[]) => {
5
+ showError: boolean;
6
+ errorInfo: string;
7
+ };
8
+ declare const getUrlPatternError: (data: any) => {
9
+ showError: boolean;
10
+ errorInfo: string;
11
+ };
12
+ declare const getCurrentTimeError: (data: any) => {
13
+ showError: boolean;
14
+ errorInfo: string;
15
+ };
16
+ declare const getWaitError: (data: any) => {
17
+ showError: boolean;
18
+ errorInfo: string;
19
+ };
20
+ declare const getElementError: (data: any) => {
21
+ showError: boolean;
22
+ errorInfo: string;
23
+ };
24
+ declare const getTextInputError: (data: any) => {
25
+ showError: boolean;
26
+ errorInfo: string;
27
+ };
28
+ declare const getTextFillError: (data: any) => {
29
+ showError: boolean;
30
+ errorInfo: string;
31
+ };
32
+ declare const getSegmentError: (data: any) => {
33
+ showError: boolean;
34
+ errorInfo: string;
35
+ };
36
+ declare const getContentError: (data: any) => {
37
+ showError: boolean;
38
+ errorInfo: string;
39
+ };
40
+ declare const getStepError: (data: any) => {
41
+ showError: boolean;
42
+ errorInfo: string;
43
+ };
44
+ declare const getNavitateError: (data: any) => {
45
+ showError: boolean;
46
+ errorInfo: string;
47
+ };
48
+ declare const getCodeError: (data: any) => {
49
+ showError: boolean;
50
+ errorInfo: string;
51
+ };
52
+ declare const hasError: (conds: RulesCondition[], attributes: Attribute[]) => boolean;
53
+ declare const hasActionError: (conds: RulesCondition[]) => boolean;
54
+ declare function getErrorMessage(error: unknown): string;
55
+
56
+ export { getCodeError, getContentError, getCurrentTimeError, getElementError, getErrorMessage, getNavitateError, getSegmentError, getStepError, getTextFillError, getTextInputError, getUrlPatternError, getUserAttrError, getWaitError, hasActionError, hasError, isValidSelector };
package/dist/error.js ADDED
@@ -0,0 +1,37 @@
1
+ import {
2
+ getCodeError,
3
+ getContentError,
4
+ getCurrentTimeError,
5
+ getElementError,
6
+ getErrorMessage,
7
+ getNavitateError,
8
+ getSegmentError,
9
+ getStepError,
10
+ getTextFillError,
11
+ getTextInputError,
12
+ getUrlPatternError,
13
+ getUserAttrError,
14
+ getWaitError,
15
+ hasActionError,
16
+ hasError,
17
+ isValidSelector
18
+ } from "./chunk-G5P7KULU.js";
19
+ import "./chunk-XEO3YXBM.js";
20
+ export {
21
+ getCodeError,
22
+ getContentError,
23
+ getCurrentTimeError,
24
+ getElementError,
25
+ getErrorMessage,
26
+ getNavitateError,
27
+ getSegmentError,
28
+ getStepError,
29
+ getTextFillError,
30
+ getTextInputError,
31
+ getUrlPatternError,
32
+ getUserAttrError,
33
+ getWaitError,
34
+ hasActionError,
35
+ hasError,
36
+ isValidSelector
37
+ };
@@ -0,0 +1,64 @@
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/globals.ts
21
+ var globals_exports = {};
22
+ __export(globals_exports, {
23
+ AbortController: () => AbortController,
24
+ ArrayProto: () => ArrayProto,
25
+ XMLHttpRequest: () => XMLHttpRequest,
26
+ assignableWindow: () => assignableWindow,
27
+ document: () => document,
28
+ fetch: () => fetch,
29
+ location: () => location,
30
+ nativeForEach: () => nativeForEach,
31
+ nativeIndexOf: () => nativeIndexOf,
32
+ navigator: () => navigator,
33
+ userAgent: () => userAgent,
34
+ window: () => win
35
+ });
36
+ module.exports = __toCommonJS(globals_exports);
37
+ var win = typeof window !== "undefined" ? window : void 0;
38
+ var global = typeof globalThis !== "undefined" ? globalThis : win;
39
+ var ArrayProto = Array.prototype;
40
+ var nativeForEach = ArrayProto.forEach;
41
+ var nativeIndexOf = ArrayProto.indexOf;
42
+ var navigator = global == null ? void 0 : global.navigator;
43
+ var document = global == null ? void 0 : global.document;
44
+ var location = global == null ? void 0 : global.location;
45
+ var fetch = global == null ? void 0 : global.fetch;
46
+ var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
47
+ var AbortController = global == null ? void 0 : global.AbortController;
48
+ var userAgent = navigator == null ? void 0 : navigator.userAgent;
49
+ var assignableWindow = win != null ? win : {};
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ AbortController,
53
+ ArrayProto,
54
+ XMLHttpRequest,
55
+ assignableWindow,
56
+ document,
57
+ fetch,
58
+ location,
59
+ nativeForEach,
60
+ nativeIndexOf,
61
+ navigator,
62
+ userAgent,
63
+ window
64
+ });
@@ -0,0 +1,27 @@
1
+ import { UserTourTypes } from '@usertour/types/';
2
+
3
+ declare const win: (UserTourTypes.WindowWithUsertour & typeof globalThis) | undefined;
4
+ declare const ArrayProto: any[];
5
+ declare const nativeForEach: (callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void;
6
+ declare const nativeIndexOf: (searchElement: any, fromIndex?: number | undefined) => number;
7
+ declare const navigator: Navigator | undefined;
8
+ declare const document: Document | undefined;
9
+ declare const location: Location | undefined;
10
+ declare const fetch: typeof globalThis.fetch | undefined;
11
+ declare const XMLHttpRequest: {
12
+ new (): XMLHttpRequest;
13
+ prototype: XMLHttpRequest;
14
+ readonly UNSENT: 0;
15
+ readonly OPENED: 1;
16
+ readonly HEADERS_RECEIVED: 2;
17
+ readonly LOADING: 3;
18
+ readonly DONE: 4;
19
+ } | undefined;
20
+ declare const AbortController: {
21
+ new (): AbortController;
22
+ prototype: AbortController;
23
+ } | undefined;
24
+ declare const userAgent: string | undefined;
25
+ declare const assignableWindow: Window & typeof globalThis & Record<string, any>;
26
+
27
+ export { AbortController, ArrayProto, XMLHttpRequest, assignableWindow, document, fetch, location, nativeForEach, nativeIndexOf, navigator, userAgent, win as window };
@@ -0,0 +1,27 @@
1
+ import { UserTourTypes } from '@usertour/types/';
2
+
3
+ declare const win: (UserTourTypes.WindowWithUsertour & typeof globalThis) | undefined;
4
+ declare const ArrayProto: any[];
5
+ declare const nativeForEach: (callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void;
6
+ declare const nativeIndexOf: (searchElement: any, fromIndex?: number | undefined) => number;
7
+ declare const navigator: Navigator | undefined;
8
+ declare const document: Document | undefined;
9
+ declare const location: Location | undefined;
10
+ declare const fetch: typeof globalThis.fetch | undefined;
11
+ declare const XMLHttpRequest: {
12
+ new (): XMLHttpRequest;
13
+ prototype: XMLHttpRequest;
14
+ readonly UNSENT: 0;
15
+ readonly OPENED: 1;
16
+ readonly HEADERS_RECEIVED: 2;
17
+ readonly LOADING: 3;
18
+ readonly DONE: 4;
19
+ } | undefined;
20
+ declare const AbortController: {
21
+ new (): AbortController;
22
+ prototype: AbortController;
23
+ } | undefined;
24
+ declare const userAgent: string | undefined;
25
+ declare const assignableWindow: Window & typeof globalThis & Record<string, any>;
26
+
27
+ export { AbortController, ArrayProto, XMLHttpRequest, assignableWindow, document, fetch, location, nativeForEach, nativeIndexOf, navigator, userAgent, win as window };
@@ -0,0 +1,29 @@
1
+ import {
2
+ AbortController,
3
+ ArrayProto,
4
+ XMLHttpRequest,
5
+ assignableWindow,
6
+ document,
7
+ fetch,
8
+ location,
9
+ nativeForEach,
10
+ nativeIndexOf,
11
+ navigator,
12
+ userAgent,
13
+ win
14
+ } from "./chunk-H7VA3ML2.js";
15
+ import "./chunk-XEO3YXBM.js";
16
+ export {
17
+ AbortController,
18
+ ArrayProto,
19
+ XMLHttpRequest,
20
+ assignableWindow,
21
+ document,
22
+ fetch,
23
+ location,
24
+ nativeForEach,
25
+ nativeIndexOf,
26
+ navigator,
27
+ userAgent,
28
+ win as window
29
+ };
@@ -0,0 +1,111 @@
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/helper.ts
21
+ var helper_exports = {};
22
+ __export(helper_exports, {
23
+ absoluteUrl: () => absoluteUrl,
24
+ cn: () => cn,
25
+ cuid: () => cuid,
26
+ evalCode: () => evalCode,
27
+ formatDate: () => formatDate,
28
+ getRandomColor: () => getRandomColor,
29
+ hexToRgb: () => hexToRgb,
30
+ isDark: () => isDark,
31
+ uuidV4: () => uuidV4
32
+ });
33
+ module.exports = __toCommonJS(helper_exports);
34
+ var import_clsx = require("clsx");
35
+ var import_tailwind_merge = require("tailwind-merge");
36
+ var import_uuid = require("uuid");
37
+ var import_cuid2 = require("@paralleldrive/cuid2");
38
+ function cn(...inputs) {
39
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
40
+ }
41
+ var cuid = () => {
42
+ return (0, import_cuid2.createId)();
43
+ };
44
+ function formatDate(input) {
45
+ const date = new Date(input);
46
+ return date.toLocaleDateString("en-US", {
47
+ month: "long",
48
+ day: "numeric",
49
+ year: "numeric"
50
+ });
51
+ }
52
+ function absoluteUrl(path) {
53
+ return `${path}`;
54
+ }
55
+ var uuidV4 = () => {
56
+ return (0, import_uuid.v4)();
57
+ };
58
+ function hexToRgb(hex) {
59
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
60
+ return result ? {
61
+ r: Number.parseInt(result[1], 16),
62
+ g: Number.parseInt(result[2], 16),
63
+ b: Number.parseInt(result[3], 16)
64
+ } : null;
65
+ }
66
+ var isDark = (hex) => {
67
+ const rgb = hexToRgb(hex);
68
+ if (!rgb) {
69
+ return null;
70
+ }
71
+ const { r, g, b } = rgb;
72
+ if (r * 0.299 + g * 0.587 + b * 0.114 > 186) {
73
+ return true;
74
+ }
75
+ return false;
76
+ };
77
+ var evalCode = (code) => {
78
+ try {
79
+ return eval(code);
80
+ } catch (error) {
81
+ console.error("Usertour.js: Error evaluating code:", error);
82
+ return null;
83
+ }
84
+ };
85
+ var getRandomColor = () => {
86
+ const colors = [
87
+ "bg-red-500",
88
+ "bg-orange-500",
89
+ "bg-yellow-500",
90
+ "bg-green-500",
91
+ "bg-teal-500",
92
+ "bg-blue-500",
93
+ "bg-indigo-500",
94
+ "bg-purple-500",
95
+ "bg-pink-500",
96
+ "bg-rose-500"
97
+ ];
98
+ return colors[Math.floor(Math.random() * colors.length)];
99
+ };
100
+ // Annotate the CommonJS export names for ESM import in node:
101
+ 0 && (module.exports = {
102
+ absoluteUrl,
103
+ cn,
104
+ cuid,
105
+ evalCode,
106
+ formatDate,
107
+ getRandomColor,
108
+ hexToRgb,
109
+ isDark,
110
+ uuidV4
111
+ });
@@ -0,0 +1,17 @@
1
+ import { ClassValue } from 'clsx';
2
+
3
+ declare function cn(...inputs: ClassValue[]): string;
4
+ declare const cuid: () => string;
5
+ declare function formatDate(input: string | number): string;
6
+ declare function absoluteUrl(path: string): string;
7
+ declare const uuidV4: () => string;
8
+ declare function hexToRgb(hex: string): {
9
+ r: number;
10
+ g: number;
11
+ b: number;
12
+ } | null;
13
+ declare const isDark: (hex: string) => boolean | null;
14
+ declare const evalCode: (code: string) => any;
15
+ declare const getRandomColor: () => string;
16
+
17
+ export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 };
@@ -0,0 +1,17 @@
1
+ import { ClassValue } from 'clsx';
2
+
3
+ declare function cn(...inputs: ClassValue[]): string;
4
+ declare const cuid: () => string;
5
+ declare function formatDate(input: string | number): string;
6
+ declare function absoluteUrl(path: string): string;
7
+ declare const uuidV4: () => string;
8
+ declare function hexToRgb(hex: string): {
9
+ r: number;
10
+ g: number;
11
+ b: number;
12
+ } | null;
13
+ declare const isDark: (hex: string) => boolean | null;
14
+ declare const evalCode: (code: string) => any;
15
+ declare const getRandomColor: () => string;
16
+
17
+ export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 };
package/dist/helper.js ADDED
@@ -0,0 +1,23 @@
1
+ import {
2
+ absoluteUrl,
3
+ cn,
4
+ cuid,
5
+ evalCode,
6
+ formatDate,
7
+ getRandomColor,
8
+ hexToRgb,
9
+ isDark,
10
+ uuidV4
11
+ } from "./chunk-3KG2HTZ3.js";
12
+ import "./chunk-XEO3YXBM.js";
13
+ export {
14
+ absoluteUrl,
15
+ cn,
16
+ cuid,
17
+ evalCode,
18
+ formatDate,
19
+ getRandomColor,
20
+ hexToRgb,
21
+ isDark,
22
+ uuidV4
23
+ };