@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
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,25 +15,15 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
- // src/condition.ts
31
- var condition_exports = {};
32
- __export(condition_exports, {
33
- conditionsIsSame: () => conditionsIsSame,
34
- isEqual: () => import_fast_deep_equal.default,
20
+ // src/conditions/url.ts
21
+ var url_exports = {};
22
+ __export(url_exports, {
23
+ evaluateUrlCondition: () => evaluateUrlCondition,
35
24
  isMatchUrlPattern: () => isMatchUrlPattern
36
25
  });
37
- module.exports = __toCommonJS(condition_exports);
38
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
26
+ module.exports = __toCommonJS(url_exports);
39
27
  var parseUrl = (url) => {
40
28
  const urlPatterns = url.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);
41
29
  if (!urlPatterns) {
@@ -96,62 +84,12 @@ var isMatchUrlPattern = (_url, includes, excludes) => {
96
84
  }) : false;
97
85
  return isMatchIncludesConditions && !isMatchExcludesConditions;
98
86
  };
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;
87
+ var evaluateUrlCondition = (rules, url) => {
88
+ const { excludes, includes } = rules.data;
89
+ return isMatchUrlPattern(url, includes, excludes);
151
90
  };
152
91
  // Annotate the CommonJS export names for ESM import in node:
153
92
  0 && (module.exports = {
154
- conditionsIsSame,
155
- isEqual,
93
+ evaluateUrlCondition,
156
94
  isMatchUrlPattern
157
95
  });
@@ -0,0 +1,6 @@
1
+ import { RulesCondition } from '@usertour/types';
2
+
3
+ declare const isMatchUrlPattern: (_url: string, includes: string[], excludes: string[]) => boolean;
4
+ declare const evaluateUrlCondition: (rules: RulesCondition, url: string) => boolean;
5
+
6
+ export { evaluateUrlCondition, isMatchUrlPattern };
@@ -0,0 +1,6 @@
1
+ import { RulesCondition } from '@usertour/types';
2
+
3
+ declare const isMatchUrlPattern: (_url: string, includes: string[], excludes: string[]) => boolean;
4
+ declare const evaluateUrlCondition: (rules: RulesCondition, url: string) => boolean;
5
+
6
+ export { evaluateUrlCondition, isMatchUrlPattern };
@@ -0,0 +1,9 @@
1
+ import {
2
+ evaluateUrlCondition,
3
+ isMatchUrlPattern
4
+ } from "../chunk-BC7KXBMF.js";
5
+ import "../chunk-XEO3YXBM.js";
6
+ export {
7
+ evaluateUrlCondition,
8
+ isMatchUrlPattern
9
+ };
package/dist/content.cjs CHANGED
@@ -20,10 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/content.ts
21
21
  var content_exports = {};
22
22
  __export(content_exports, {
23
+ buildConfig: () => buildConfig,
24
+ defaultContentConfig: () => defaultContentConfig,
23
25
  isPublishedAtLeastOneEnvironment: () => isPublishedAtLeastOneEnvironment,
24
26
  isPublishedInAllEnvironments: () => isPublishedInAllEnvironments
25
27
  });
26
28
  module.exports = __toCommonJS(content_exports);
29
+ var import_types = require("@usertour/types");
30
+ var import_deepmerge_ts = require("deepmerge-ts");
27
31
  var isPublishedInAllEnvironments = (content, environmentList, version) => {
28
32
  const isPublishedInAllEnvironments2 = environmentList == null ? void 0 : environmentList.every(
29
33
  (env) => {
@@ -46,8 +50,40 @@ var isPublishedAtLeastOneEnvironment = (content) => {
46
50
  }
47
51
  return false;
48
52
  };
53
+ var rulesSetting = {
54
+ // frequency: {
55
+ // frequency: Frequency.ONCE,
56
+ // every: { duration: 0, times: 1, unit: FrequencyUnits.MINUTES },
57
+ // atLeast: { duration: 0, unit: FrequencyUnits.MINUTES },
58
+ // },
59
+ startIfNotComplete: false,
60
+ priority: import_types.ContentPriority.MEDIUM,
61
+ wait: 0
62
+ };
63
+ var hideRulesSetting = {};
64
+ var defaultContentConfig = {
65
+ enabledAutoStartRules: false,
66
+ enabledHideRules: false,
67
+ autoStartRules: [],
68
+ hideRules: [],
69
+ autoStartRulesSetting: rulesSetting,
70
+ hideRulesSetting
71
+ };
72
+ var buildConfig = (config) => {
73
+ return {
74
+ ...defaultContentConfig,
75
+ ...config,
76
+ autoStartRulesSetting: (0, import_deepmerge_ts.deepmerge)(
77
+ defaultContentConfig.autoStartRulesSetting,
78
+ (config == null ? void 0 : config.autoStartRulesSetting) || {}
79
+ ),
80
+ hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
81
+ };
82
+ };
49
83
  // Annotate the CommonJS export names for ESM import in node:
50
84
  0 && (module.exports = {
85
+ buildConfig,
86
+ defaultContentConfig,
51
87
  isPublishedAtLeastOneEnvironment,
52
88
  isPublishedInAllEnvironments
53
89
  });
@@ -1,6 +1,8 @@
1
- import { Content, Environment, ContentVersion } from '@usertour/types';
1
+ import { Content, Environment, ContentVersion, ContentConfigObject } from '@usertour/types';
2
2
 
3
3
  declare const isPublishedInAllEnvironments: (content: Content | null, environmentList: Environment[] | null, version: ContentVersion | null) => boolean;
4
4
  declare const isPublishedAtLeastOneEnvironment: (content: Content | null) => boolean;
5
+ declare const defaultContentConfig: ContentConfigObject;
6
+ declare const buildConfig: (config: ContentConfigObject | undefined) => ContentConfigObject;
5
7
 
6
- export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments };
8
+ export { buildConfig, defaultContentConfig, isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments };
package/dist/content.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { Content, Environment, ContentVersion } from '@usertour/types';
1
+ import { Content, Environment, ContentVersion, ContentConfigObject } from '@usertour/types';
2
2
 
3
3
  declare const isPublishedInAllEnvironments: (content: Content | null, environmentList: Environment[] | null, version: ContentVersion | null) => boolean;
4
4
  declare const isPublishedAtLeastOneEnvironment: (content: Content | null) => boolean;
5
+ declare const defaultContentConfig: ContentConfigObject;
6
+ declare const buildConfig: (config: ContentConfigObject | undefined) => ContentConfigObject;
5
7
 
6
- export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments };
8
+ export { buildConfig, defaultContentConfig, isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments };
package/dist/content.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import {
2
+ buildConfig,
3
+ defaultContentConfig,
2
4
  isPublishedAtLeastOneEnvironment,
3
5
  isPublishedInAllEnvironments
4
- } from "./chunk-BBPZYUJR.js";
6
+ } from "./chunk-4LLDSAHJ.js";
5
7
  import "./chunk-XEO3YXBM.js";
6
8
  export {
9
+ buildConfig,
10
+ defaultContentConfig,
7
11
  isPublishedAtLeastOneEnvironment,
8
12
  isPublishedInAllEnvironments
9
13
  };