@usertour/helpers 0.0.14 → 0.0.17

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 (58) hide show
  1. package/dist/__tests__/attribute.test.cjs +1036 -0
  2. package/dist/__tests__/attribute.test.d.cts +2 -0
  3. package/dist/__tests__/attribute.test.d.ts +2 -0
  4. package/dist/__tests__/attribute.test.js +802 -0
  5. package/dist/__tests__/time.test.cjs +73 -0
  6. package/dist/__tests__/time.test.d.cts +2 -0
  7. package/dist/__tests__/time.test.d.ts +2 -0
  8. package/dist/__tests__/time.test.js +48 -0
  9. package/dist/__tests__/url.test.cjs +259 -0
  10. package/dist/__tests__/url.test.d.cts +2 -0
  11. package/dist/__tests__/url.test.d.ts +2 -0
  12. package/dist/__tests__/url.test.js +197 -0
  13. package/dist/{chunk-BBPZYUJR.js → chunk-4LLDSAHJ.js} +37 -1
  14. package/dist/chunk-7CC4WXB3.js +60 -0
  15. package/dist/chunk-7ODE2AIC.js +0 -0
  16. package/dist/{chunk-FNQIIEWK.js → chunk-BC7KXBMF.js} +5 -56
  17. package/dist/chunk-CEK3SCQO.js +31 -0
  18. package/dist/chunk-PBZSPV5R.js +239 -0
  19. package/dist/conditions/attribute.cjs +264 -0
  20. package/dist/conditions/attribute.d.cts +28 -0
  21. package/dist/conditions/attribute.d.ts +28 -0
  22. package/dist/conditions/attribute.js +9 -0
  23. package/dist/conditions/condition.cjs +95 -0
  24. package/dist/{condition.d.cts → conditions/condition.d.cts} +1 -2
  25. package/dist/{condition.d.ts → conditions/condition.d.ts} +1 -2
  26. package/dist/conditions/condition.js +9 -0
  27. package/dist/conditions/index.cjs +379 -0
  28. package/dist/conditions/index.d.cts +6 -0
  29. package/dist/conditions/index.d.ts +6 -0
  30. package/dist/conditions/index.js +24 -0
  31. package/dist/conditions/time.cjs +55 -0
  32. package/dist/conditions/time.d.cts +10 -0
  33. package/dist/conditions/time.d.ts +10 -0
  34. package/dist/conditions/time.js +7 -0
  35. package/dist/{condition.cjs → conditions/url.cjs} +9 -71
  36. package/dist/conditions/url.d.cts +6 -0
  37. package/dist/conditions/url.d.ts +6 -0
  38. package/dist/conditions/url.js +9 -0
  39. package/dist/content.cjs +36 -0
  40. package/dist/content.d.cts +4 -2
  41. package/dist/content.d.ts +4 -2
  42. package/dist/content.js +5 -1
  43. package/dist/index.cjs +328 -504
  44. package/dist/index.d.cts +5 -4
  45. package/dist/index.d.ts +5 -4
  46. package/dist/index.js +44 -61
  47. package/package.json +15 -9
  48. package/dist/chunk-64BFWPHJ.js +0 -50
  49. package/dist/chunk-SYVTGB2A.js +0 -462
  50. package/dist/condition.js +0 -11
  51. package/dist/conditions.cjs +0 -615
  52. package/dist/conditions.d.cts +0 -35
  53. package/dist/conditions.d.ts +0 -35
  54. package/dist/conditions.js +0 -50
  55. package/dist/content-settings.cjs +0 -76
  56. package/dist/content-settings.d.cts +0 -7
  57. package/dist/content-settings.d.ts +0 -7
  58. package/dist/content-settings.js +0 -11
package/dist/index.d.cts CHANGED
@@ -1,17 +1,18 @@
1
1
  export { convertSettings, convertToCssVars, mergeThemeDefaultSettings } from './convert-settings.cjs';
2
- export { conditionsIsSame, isMatchUrlPattern } from './condition.cjs';
3
2
  export { isArray, isBoolean, isDate, isDocument, isEmptyObject, isEmptyString, isFile, isFormData, isFunction, isNull, isNullish, isNumber, isObject, isString, isUint8Array, isUndefined } from './type-utils.cjs';
4
- export { autoStartConditions, buildConfig, defaultContentConfig } from './content-settings.cjs';
5
3
  export { getCodeError, getContentError, getCurrentTimeError, getElementError, getErrorMessage, getNavitateError, getSegmentError, getStepError, getTextFillError, getTextInputError, getUrlPatternError, getUserAttrError, getWaitError, hasActionError, hasError, isValidSelector } from './error.cjs';
6
4
  export { getAuthToken, removeAuthToken, setAuthToken, storage } from './auth.cjs';
7
5
  export { defaultStep } from './settings.cjs';
8
6
  export { isUrl } from './is-url.cjs';
9
7
  export { AbortController, ArrayProto, XMLHttpRequest, assignableWindow, document, fetch, location, nativeForEach, nativeIndexOf, navigator, userAgent, window } from './globals.cjs';
10
- export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from './content.cjs';
8
+ export { buildConfig, defaultContentConfig, isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from './content.cjs';
11
9
  export { deepClone } from './utils.cjs';
12
10
  export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.cjs';
13
11
  export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.cjs';
14
- export { activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveRulesByCurrentTime, isValidContent, parseUrlParams } from './conditions.cjs';
12
+ export { conditionsIsSame } from './conditions/condition.cjs';
13
+ export { evaluateUrlCondition, isMatchUrlPattern } from './conditions/url.cjs';
14
+ export { evaluateTimeCondition } from './conditions/time.cjs';
15
+ export { evaluateAttributeCondition } from './conditions/attribute.cjs';
15
16
  export { default as isEqual } from 'fast-deep-equal';
16
17
  import '@usertour/types';
17
18
  import './storage.cjs';
package/dist/index.d.ts CHANGED
@@ -1,17 +1,18 @@
1
1
  export { convertSettings, convertToCssVars, mergeThemeDefaultSettings } from './convert-settings.js';
2
- export { conditionsIsSame, isMatchUrlPattern } from './condition.js';
3
2
  export { isArray, isBoolean, isDate, isDocument, isEmptyObject, isEmptyString, isFile, isFormData, isFunction, isNull, isNullish, isNumber, isObject, isString, isUint8Array, isUndefined } from './type-utils.js';
4
- export { autoStartConditions, buildConfig, defaultContentConfig } from './content-settings.js';
5
3
  export { getCodeError, getContentError, getCurrentTimeError, getElementError, getErrorMessage, getNavitateError, getSegmentError, getStepError, getTextFillError, getTextInputError, getUrlPatternError, getUserAttrError, getWaitError, hasActionError, hasError, isValidSelector } from './error.js';
6
4
  export { getAuthToken, removeAuthToken, setAuthToken, storage } from './auth.js';
7
5
  export { defaultStep } from './settings.js';
8
6
  export { isUrl } from './is-url.js';
9
7
  export { AbortController, ArrayProto, XMLHttpRequest, assignableWindow, document, fetch, location, nativeForEach, nativeIndexOf, navigator, userAgent, window } from './globals.js';
10
- export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from './content.js';
8
+ export { buildConfig, defaultContentConfig, isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from './content.js';
11
9
  export { deepClone } from './utils.js';
12
10
  export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.js';
13
11
  export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.js';
14
- export { activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveRulesByCurrentTime, isValidContent, parseUrlParams } from './conditions.js';
12
+ export { conditionsIsSame } from './conditions/condition.js';
13
+ export { evaluateUrlCondition, isMatchUrlPattern } from './conditions/url.js';
14
+ export { evaluateTimeCondition } from './conditions/time.js';
15
+ export { evaluateAttributeCondition } from './conditions/attribute.js';
15
16
  export { default as isEqual } from 'fast-deep-equal';
16
17
  import '@usertour/types';
17
18
  import './storage.js';
package/dist/index.js CHANGED
@@ -1,14 +1,8 @@
1
+ import "./chunk-7ODE2AIC.js";
1
2
  import {
2
- absoluteUrl,
3
- cn,
4
- cuid,
5
- evalCode,
6
- formatDate,
7
- getRandomColor,
8
- hexToRgb,
9
- isDark,
10
- uuidV4
11
- } from "./chunk-3KG2HTZ3.js";
3
+ conditionsIsSame,
4
+ isEqual
5
+ } from "./chunk-7CC4WXB3.js";
12
6
  import {
13
7
  isUrl
14
8
  } from "./chunk-ZNFXGN3M.js";
@@ -18,6 +12,16 @@ import {
18
12
  import {
19
13
  deepClone
20
14
  } from "./chunk-2AEGAICC.js";
15
+ import {
16
+ evaluateAttributeCondition
17
+ } from "./chunk-PBZSPV5R.js";
18
+ import {
19
+ evaluateTimeCondition
20
+ } from "./chunk-CEK3SCQO.js";
21
+ import {
22
+ evaluateUrlCondition,
23
+ isMatchUrlPattern
24
+ } from "./chunk-BC7KXBMF.js";
21
25
  import {
22
26
  getAuthToken,
23
27
  removeAuthToken,
@@ -26,47 +30,11 @@ import {
26
30
  } from "./chunk-FGFMTWFT.js";
27
31
  import "./chunk-3ZGH3NRU.js";
28
32
  import {
29
- AbortController,
30
- ArrayProto,
31
- XMLHttpRequest,
32
- assignableWindow,
33
- document,
34
- fetch,
35
- location,
36
- nativeForEach,
37
- nativeIndexOf,
38
- navigator,
39
- userAgent,
40
- win
41
- } from "./chunk-H7VA3ML2.js";
42
- import {
43
- activedContentRulesConditions,
44
- activedRulesConditions,
45
- checklistIsDimissed,
46
- checklistIsSeen,
47
- filterAutoStartContent,
48
- findLatestEvent,
49
- flowIsDismissed,
50
- flowIsSeen,
51
- isActive,
52
- isActiveRulesByCurrentTime,
53
- isValidContent,
54
- parseUrlParams
55
- } from "./chunk-SYVTGB2A.js";
56
- import {
57
- conditionsIsSame,
58
- isEqual,
59
- isMatchUrlPattern
60
- } from "./chunk-FNQIIEWK.js";
61
- import {
62
- autoStartConditions,
63
33
  buildConfig,
64
- defaultContentConfig
65
- } from "./chunk-64BFWPHJ.js";
66
- import {
34
+ defaultContentConfig,
67
35
  isPublishedAtLeastOneEnvironment,
68
36
  isPublishedInAllEnvironments
69
- } from "./chunk-BBPZYUJR.js";
37
+ } from "./chunk-4LLDSAHJ.js";
70
38
  import {
71
39
  convertSettings,
72
40
  convertToCssVars,
@@ -113,19 +81,39 @@ import {
113
81
  hasError,
114
82
  isValidSelector
115
83
  } from "./chunk-G5P7KULU.js";
84
+ import {
85
+ AbortController,
86
+ ArrayProto,
87
+ XMLHttpRequest,
88
+ assignableWindow,
89
+ document,
90
+ fetch,
91
+ location,
92
+ nativeForEach,
93
+ nativeIndexOf,
94
+ navigator,
95
+ userAgent,
96
+ win
97
+ } from "./chunk-H7VA3ML2.js";
98
+ import {
99
+ absoluteUrl,
100
+ cn,
101
+ cuid,
102
+ evalCode,
103
+ formatDate,
104
+ getRandomColor,
105
+ hexToRgb,
106
+ isDark,
107
+ uuidV4
108
+ } from "./chunk-3KG2HTZ3.js";
116
109
  import "./chunk-XEO3YXBM.js";
117
110
  export {
118
111
  AbortController,
119
112
  ArrayProto,
120
113
  XMLHttpRequest,
121
114
  absoluteUrl,
122
- activedContentRulesConditions,
123
- activedRulesConditions,
124
115
  assignableWindow,
125
- autoStartConditions,
126
116
  buildConfig,
127
- checklistIsDimissed,
128
- checklistIsSeen,
129
117
  cn,
130
118
  conditionsIsSame,
131
119
  convertSettings,
@@ -136,11 +124,10 @@ export {
136
124
  defaultStep,
137
125
  document,
138
126
  evalCode,
127
+ evaluateAttributeCondition,
128
+ evaluateTimeCondition,
129
+ evaluateUrlCondition,
139
130
  fetch,
140
- filterAutoStartContent,
141
- findLatestEvent,
142
- flowIsDismissed,
143
- flowIsSeen,
144
131
  formatDate,
145
132
  generateAutoStateColors,
146
133
  getAuthToken,
@@ -163,8 +150,6 @@ export {
163
150
  hexToHSLString,
164
151
  hexToRGBStr,
165
152
  hexToRgb,
166
- isActive,
167
- isActiveRulesByCurrentTime,
168
153
  isArray,
169
154
  isBoolean,
170
155
  isDark,
@@ -187,14 +172,12 @@ export {
187
172
  isUint8Array,
188
173
  isUndefined,
189
174
  isUrl,
190
- isValidContent,
191
175
  isValidSelector,
192
176
  location,
193
177
  mergeThemeDefaultSettings,
194
178
  nativeForEach,
195
179
  nativeIndexOf,
196
180
  navigator,
197
- parseUrlParams,
198
181
  removeAuthToken,
199
182
  setAuthToken,
200
183
  storage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usertour/helpers",
3
- "version": "0.0.14",
3
+ "version": "0.0.17",
4
4
  "type": "module",
5
5
  "description": "Utility functions and helpers shared across the UserTour project",
6
6
  "homepage": "https://www.usertour.io",
@@ -23,26 +23,32 @@
23
23
  "clean": "rimraf dist .turbo",
24
24
  "typecheck": "tsc --noEmit",
25
25
  "build:fast": "tsup src",
26
- "prepublishOnly": "pnpm build"
26
+ "prepublishOnly": "pnpm build",
27
+ "test": "jest",
28
+ "test:watch": "jest --watch"
27
29
  },
28
30
  "dependencies": {
29
- "@usertour/types": "^0.0.6",
30
- "fast-deep-equal": "^3.1.3",
31
- "chroma-js": "^3.1.2",
32
- "deepmerge-ts": "^7.1.3",
33
31
  "@paralleldrive/cuid2": "^2.2.2",
32
+ "@usertour/types": "^0.0.9",
33
+ "chroma-js": "^3.1.2",
34
34
  "class-variance-authority": "^0.4.0",
35
35
  "clsx": "^1.2.1",
36
- "tailwind-merge": "^1.13.2",
37
36
  "date-fns": "^2.30.0",
37
+ "deepmerge-ts": "^7.1.3",
38
+ "fast-deep-equal": "^3.1.3",
39
+ "tailwind-merge": "^1.13.2",
38
40
  "uuid": "^9.0.1"
39
41
  },
40
42
  "devDependencies": {
41
- "@typescript-eslint/eslint-plugin": "^5.59.0",
42
- "@typescript-eslint/parser": "^5.59.0",
43
+ "@jest/types": "^29.6.3",
43
44
  "@types/chroma-js": "^3.1.1",
45
+ "@types/jest": "29.4.0",
44
46
  "@types/uuid": "^9.0.6",
47
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
48
+ "@typescript-eslint/parser": "^5.59.0",
45
49
  "eslint": "^8.38.0",
50
+ "jest": "29.5.0",
51
+ "ts-jest": "29.0.5",
46
52
  "typescript": "^5.0.2"
47
53
  },
48
54
  "tsup": {
@@ -1,50 +0,0 @@
1
- // src/content-settings.ts
2
- import { ContentPriority } from "@usertour/types";
3
- import { deepmerge } from "deepmerge-ts";
4
- var rulesSetting = {
5
- // frequency: {
6
- // frequency: Frequency.ONCE,
7
- // every: { duration: 0, times: 1, unit: FrequencyUnits.MINUTES },
8
- // atLeast: { duration: 0, unit: FrequencyUnits.MINUTES },
9
- // },
10
- startIfNotComplete: false,
11
- priority: ContentPriority.MEDIUM,
12
- wait: 0
13
- };
14
- var hideRulesSetting = {};
15
- var defaultContentConfig = {
16
- enabledAutoStartRules: false,
17
- enabledHideRules: false,
18
- autoStartRules: [],
19
- hideRules: [],
20
- autoStartRulesSetting: rulesSetting,
21
- hideRulesSetting
22
- };
23
- var autoStartConditions = {
24
- ...defaultContentConfig,
25
- enabledAutoStartRules: true,
26
- autoStartRules: [
27
- {
28
- data: { excludes: [], includes: ["/*"] },
29
- type: "current-page",
30
- operators: "and"
31
- }
32
- ]
33
- };
34
- var buildConfig = (config) => {
35
- return {
36
- ...defaultContentConfig,
37
- ...config,
38
- autoStartRulesSetting: deepmerge(
39
- defaultContentConfig.autoStartRulesSetting,
40
- (config == null ? void 0 : config.autoStartRulesSetting) || {}
41
- ),
42
- hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
43
- };
44
- };
45
-
46
- export {
47
- defaultContentConfig,
48
- autoStartConditions,
49
- buildConfig
50
- };