@usertour/helpers 0.0.4 → 0.0.6

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/index.d.cts CHANGED
@@ -13,6 +13,7 @@ export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.cj
13
13
  export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.cjs';
14
14
  export { GenerateLicenseOptions, JWTLicenseSigner, JWTLicenseSignerOptions } from './jwt-license-signer.cjs';
15
15
  export { JWTLicenseValidator } from './jwt-license-validator.cjs';
16
+ export { PRIORITIES, activedContentCondition, activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveContent, isHasActivedContents, isSameContents, isValidContent, isVisible, parseUrlParams, wait } from './conditions.cjs';
16
17
  export { default as isEqual } from 'fast-deep-equal';
17
18
  import '@usertour/types';
18
19
  import './storage.cjs';
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.js
13
13
  export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.js';
14
14
  export { GenerateLicenseOptions, JWTLicenseSigner, JWTLicenseSignerOptions } from './jwt-license-signer.js';
15
15
  export { JWTLicenseValidator } from './jwt-license-validator.js';
16
+ export { PRIORITIES, activedContentCondition, activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveContent, isHasActivedContents, isSameContents, isValidContent, isVisible, parseUrlParams, wait } from './conditions.js';
16
17
  export { default as isEqual } from 'fast-deep-equal';
17
18
  import '@usertour/types';
18
19
  import './storage.js';
package/dist/index.js CHANGED
@@ -17,10 +17,10 @@ import {
17
17
  } from "./chunk-ZNFXGN3M.js";
18
18
  import {
19
19
  JWTLicenseSigner
20
- } from "./chunk-JQ4E3IDB.js";
20
+ } from "./chunk-HWWIAVVP.js";
21
21
  import {
22
22
  JWTLicenseValidator
23
- } from "./chunk-KJJ6UD5L.js";
23
+ } from "./chunk-Y5PCSFVZ.js";
24
24
  import {
25
25
  defaultStep
26
26
  } from "./chunk-FW54TSA3.js";
@@ -31,6 +31,41 @@ import {
31
31
  storage
32
32
  } from "./chunk-FGFMTWFT.js";
33
33
  import "./chunk-3ZGH3NRU.js";
34
+ import {
35
+ PRIORITIES,
36
+ activedContentCondition,
37
+ activedContentRulesConditions,
38
+ activedRulesConditions,
39
+ checklistIsDimissed,
40
+ checklistIsSeen,
41
+ filterAutoStartContent,
42
+ findLatestEvent,
43
+ flowIsDismissed,
44
+ flowIsSeen,
45
+ isActive,
46
+ isActiveContent,
47
+ isHasActivedContents,
48
+ isSameContents,
49
+ isValidContent,
50
+ isVisible,
51
+ parseUrlParams,
52
+ wait
53
+ } from "./chunk-OASNBRBF.js";
54
+ import "./chunk-Y6FPPOKF.js";
55
+ import {
56
+ AbortController,
57
+ ArrayProto,
58
+ XMLHttpRequest,
59
+ assignableWindow,
60
+ document,
61
+ fetch,
62
+ location,
63
+ nativeForEach,
64
+ nativeIndexOf,
65
+ navigator,
66
+ userAgent,
67
+ win
68
+ } from "./chunk-H7VA3ML2.js";
34
69
  import {
35
70
  conditionsIsSame,
36
71
  isEqual,
@@ -91,31 +126,23 @@ import {
91
126
  hasError,
92
127
  isValidSelector
93
128
  } from "./chunk-G5P7KULU.js";
94
- import {
95
- AbortController,
96
- ArrayProto,
97
- XMLHttpRequest,
98
- assignableWindow,
99
- document,
100
- fetch,
101
- location,
102
- nativeForEach,
103
- nativeIndexOf,
104
- navigator,
105
- userAgent,
106
- win
107
- } from "./chunk-H7VA3ML2.js";
108
129
  import "./chunk-XEO3YXBM.js";
109
130
  export {
110
131
  AbortController,
111
132
  ArrayProto,
112
133
  JWTLicenseSigner,
113
134
  JWTLicenseValidator,
135
+ PRIORITIES,
114
136
  XMLHttpRequest,
115
137
  absoluteUrl,
138
+ activedContentCondition,
139
+ activedContentRulesConditions,
140
+ activedRulesConditions,
116
141
  assignableWindow,
117
142
  autoStartConditions,
118
143
  buildConfig,
144
+ checklistIsDimissed,
145
+ checklistIsSeen,
119
146
  cn,
120
147
  conditionsIsSame,
121
148
  convertSettings,
@@ -127,6 +154,10 @@ export {
127
154
  document,
128
155
  evalCode,
129
156
  fetch,
157
+ filterAutoStartContent,
158
+ findLatestEvent,
159
+ flowIsDismissed,
160
+ flowIsSeen,
130
161
  formatDate,
131
162
  generateAutoStateColors,
132
163
  getAuthToken,
@@ -149,6 +180,8 @@ export {
149
180
  hexToHSLString,
150
181
  hexToRGBStr,
151
182
  hexToRgb,
183
+ isActive,
184
+ isActiveContent,
152
185
  isArray,
153
186
  isBoolean,
154
187
  isDark,
@@ -160,6 +193,7 @@ export {
160
193
  isFile,
161
194
  isFormData,
162
195
  isFunction,
196
+ isHasActivedContents,
163
197
  isMatchUrlPattern,
164
198
  isNull,
165
199
  isNullish,
@@ -167,20 +201,25 @@ export {
167
201
  isObject,
168
202
  isPublishedAtLeastOneEnvironment,
169
203
  isPublishedInAllEnvironments,
204
+ isSameContents,
170
205
  isString,
171
206
  isUint8Array,
172
207
  isUndefined,
173
208
  isUrl,
209
+ isValidContent,
174
210
  isValidSelector,
211
+ isVisible,
175
212
  location,
176
213
  mergeThemeDefaultSettings,
177
214
  nativeForEach,
178
215
  nativeIndexOf,
179
216
  navigator,
217
+ parseUrlParams,
180
218
  removeAuthToken,
181
219
  setAuthToken,
182
220
  storage,
183
221
  userAgent,
184
222
  uuidV4,
223
+ wait,
185
224
  win as window
186
225
  };
@@ -40,7 +40,7 @@ __export(jwt_license_signer_exports, {
40
40
  module.exports = __toCommonJS(jwt_license_signer_exports);
41
41
  var fs = __toESM(require("fs"), 1);
42
42
  var path = __toESM(require("path"), 1);
43
- var jwt = __toESM(require("jsonwebtoken"), 1);
43
+ var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
44
44
  var JWTLicenseSigner = class {
45
45
  constructor(options) {
46
46
  __publicField(this, "privateKey");
@@ -77,7 +77,7 @@ var JWTLicenseSigner = class {
77
77
  features: options.features
78
78
  };
79
79
  try {
80
- return jwt.sign(payload, this.privateKey, {
80
+ return import_jsonwebtoken.default.sign(payload, this.privateKey, {
81
81
  algorithm: this.algorithm,
82
82
  issuer: this.issuer
83
83
  });
@@ -100,7 +100,7 @@ var JWTLicenseSigner = class {
100
100
  issuer: options.issuer || this.issuer,
101
101
  features: options.features
102
102
  };
103
- const token = jwt.sign(payload, this.privateKey, {
103
+ const token = import_jsonwebtoken.default.sign(payload, this.privateKey, {
104
104
  algorithm: this.algorithm,
105
105
  issuer: this.issuer
106
106
  });
@@ -115,7 +115,7 @@ var JWTLicenseSigner = class {
115
115
  */
116
116
  decodeToken(token) {
117
117
  try {
118
- return jwt.decode(token);
118
+ return import_jsonwebtoken.default.decode(token);
119
119
  } catch (error) {
120
120
  console.error("Failed to decode JWT token:", error);
121
121
  return null;
@@ -126,7 +126,7 @@ var JWTLicenseSigner = class {
126
126
  */
127
127
  getTokenInfo(token) {
128
128
  try {
129
- const decoded = jwt.decode(token, { complete: true });
129
+ const decoded = import_jsonwebtoken.default.decode(token, { complete: true });
130
130
  if (!decoded || typeof decoded === "string") {
131
131
  return null;
132
132
  }
@@ -1,4 +1,4 @@
1
- import * as jwt from 'jsonwebtoken';
1
+ import jwt from 'jsonwebtoken';
2
2
  import { JWTLicensePayload } from '@usertour/types';
3
3
 
4
4
  interface JWTLicenseSignerOptions {
@@ -1,4 +1,4 @@
1
- import * as jwt from 'jsonwebtoken';
1
+ import jwt from 'jsonwebtoken';
2
2
  import { JWTLicensePayload } from '@usertour/types';
3
3
 
4
4
  interface JWTLicenseSignerOptions {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JWTLicenseSigner
3
- } from "./chunk-JQ4E3IDB.js";
3
+ } from "./chunk-HWWIAVVP.js";
4
4
  import "./chunk-XEO3YXBM.js";
5
5
  export {
6
6
  JWTLicenseSigner
@@ -33,7 +33,7 @@ __export(jwt_license_validator_exports, {
33
33
  JWTLicenseValidator: () => JWTLicenseValidator
34
34
  });
35
35
  module.exports = __toCommonJS(jwt_license_validator_exports);
36
- var jwt = __toESM(require("jsonwebtoken"), 1);
36
+ var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
37
37
  var JWTLicenseValidator = {
38
38
  /**
39
39
  * Validate a JWT license
@@ -45,7 +45,7 @@ var JWTLicenseValidator = {
45
45
  validateLicense(license, publicKey, options = {}) {
46
46
  try {
47
47
  const { checkExpiration = true, currentTime = /* @__PURE__ */ new Date() } = options;
48
- const decoded = jwt.verify(license, publicKey, {
48
+ const decoded = import_jsonwebtoken.default.verify(license, publicKey, {
49
49
  algorithms: ["RS256"],
50
50
  ignoreExpiration: !checkExpiration
51
51
  });
@@ -69,13 +69,13 @@ var JWTLicenseValidator = {
69
69
  hasFeature
70
70
  };
71
71
  } catch (error) {
72
- if (error instanceof jwt.JsonWebTokenError) {
72
+ if (error instanceof import_jsonwebtoken.default.JsonWebTokenError) {
73
73
  return {
74
74
  isValid: false,
75
75
  error: `JWT validation failed: ${error.message}`
76
76
  };
77
77
  }
78
- if (error instanceof jwt.TokenExpiredError) {
78
+ if (error instanceof import_jsonwebtoken.default.TokenExpiredError) {
79
79
  return {
80
80
  isValid: false,
81
81
  error: `License expired: ${error.message}`,
@@ -204,7 +204,7 @@ var JWTLicenseValidator = {
204
204
  */
205
205
  decodeLicense(license) {
206
206
  try {
207
- const decoded = jwt.decode(license);
207
+ const decoded = import_jsonwebtoken.default.decode(license);
208
208
  return decoded;
209
209
  } catch {
210
210
  return null;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JWTLicenseValidator
3
- } from "./chunk-KJJ6UD5L.js";
3
+ } from "./chunk-Y5PCSFVZ.js";
4
4
  import "./chunk-XEO3YXBM.js";
5
5
  export {
6
6
  JWTLicenseValidator
@@ -0,0 +1,68 @@
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/listener.ts
21
+ var listener_exports = {};
22
+ __export(listener_exports, {
23
+ isBrowser: () => isBrowser,
24
+ isNavigator: () => isNavigator,
25
+ noop: () => noop,
26
+ off: () => off,
27
+ on: () => on
28
+ });
29
+ module.exports = __toCommonJS(listener_exports);
30
+
31
+ // src/globals.ts
32
+ var win = typeof window !== "undefined" ? window : void 0;
33
+ var global = typeof globalThis !== "undefined" ? globalThis : win;
34
+ var ArrayProto = Array.prototype;
35
+ var nativeForEach = ArrayProto.forEach;
36
+ var nativeIndexOf = ArrayProto.indexOf;
37
+ var navigator = global == null ? void 0 : global.navigator;
38
+ var document = global == null ? void 0 : global.document;
39
+ var location = global == null ? void 0 : global.location;
40
+ var fetch = global == null ? void 0 : global.fetch;
41
+ var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
42
+ var AbortController = global == null ? void 0 : global.AbortController;
43
+ var userAgent = navigator == null ? void 0 : navigator.userAgent;
44
+ var assignableWindow = win != null ? win : {};
45
+
46
+ // src/listener.ts
47
+ var noop = () => {
48
+ };
49
+ function on(obj, ...args) {
50
+ if (obj == null ? void 0 : obj.addEventListener) {
51
+ obj.addEventListener(...args);
52
+ }
53
+ }
54
+ function off(obj, ...args) {
55
+ if (obj == null ? void 0 : obj.removeEventListener) {
56
+ obj.removeEventListener(...args);
57
+ }
58
+ }
59
+ var isBrowser = typeof win !== "undefined";
60
+ var isNavigator = typeof navigator !== "undefined";
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ isBrowser,
64
+ isNavigator,
65
+ noop,
66
+ off,
67
+ on
68
+ });
@@ -0,0 +1,7 @@
1
+ declare const noop: () => void;
2
+ declare function on<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['addEventListener']> | [string, (...args: any[]) => void, ...any]): void;
3
+ declare function off<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['removeEventListener']> | [string, (...args: any[]) => void, ...any]): void;
4
+ declare const isBrowser: boolean;
5
+ declare const isNavigator: boolean;
6
+
7
+ export { isBrowser, isNavigator, noop, off, on };
@@ -0,0 +1,7 @@
1
+ declare const noop: () => void;
2
+ declare function on<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['addEventListener']> | [string, (...args: any[]) => void, ...any]): void;
3
+ declare function off<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['removeEventListener']> | [string, (...args: any[]) => void, ...any]): void;
4
+ declare const isBrowser: boolean;
5
+ declare const isNavigator: boolean;
6
+
7
+ export { isBrowser, isNavigator, noop, off, on };
@@ -0,0 +1,16 @@
1
+ import {
2
+ isBrowser,
3
+ isNavigator,
4
+ noop,
5
+ off,
6
+ on
7
+ } from "./chunk-Y6FPPOKF.js";
8
+ import "./chunk-H7VA3ML2.js";
9
+ import "./chunk-XEO3YXBM.js";
10
+ export {
11
+ isBrowser,
12
+ isNavigator,
13
+ noop,
14
+ off,
15
+ on
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usertour/helpers",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "description": "Utility functions and helpers shared across the UserTour project",
6
6
  "homepage": "https://www.usertour.io",
@@ -26,7 +26,7 @@
26
26
  "prepublishOnly": "pnpm build"
27
27
  },
28
28
  "dependencies": {
29
- "@usertour/types": "^0.0.4",
29
+ "@usertour/types": "^0.0.5",
30
30
  "fast-deep-equal": "^3.1.3",
31
31
  "chroma-js": "^3.1.2",
32
32
  "deepmerge-ts": "^7.1.3",
@@ -35,7 +35,10 @@
35
35
  "clsx": "^1.2.1",
36
36
  "tailwind-merge": "^1.13.2",
37
37
  "jsonwebtoken": "^9.0.2",
38
+ "@floating-ui/dom": "^1.4.4",
38
39
  "@types/jsonwebtoken": "^9.0.10",
40
+ "@usertour-packages/finder": "workspace:^",
41
+ "date-fns": "^2.30.0",
39
42
  "uuid": "^9.0.1"
40
43
  },
41
44
  "devDependencies": {