@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
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { convertSettings, convertToCssVars, mergeThemeDefaultSettings } from './convert-settings.cjs';
|
|
2
|
+
export { conditionsIsSame, isMatchUrlPattern } from './condition.cjs';
|
|
3
|
+
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
|
+
export { getCodeError, getContentError, getCurrentTimeError, getElementError, getErrorMessage, getNavitateError, getSegmentError, getStepError, getTextFillError, getTextInputError, getUrlPatternError, getUserAttrError, getWaitError, hasActionError, hasError, isValidSelector } from './error.cjs';
|
|
6
|
+
export { getAuthToken, removeAuthToken, setAuthToken, storage } from './auth.cjs';
|
|
7
|
+
export { defaultStep } from './settings.cjs';
|
|
8
|
+
export { isUrl } from './is-url.cjs';
|
|
9
|
+
export { AbortController, ArrayProto, XMLHttpRequest, assignableWindow, document, fetch, location, nativeForEach, nativeIndexOf, navigator, userAgent, window } from './globals.cjs';
|
|
10
|
+
export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from './content.cjs';
|
|
11
|
+
export { deepClone } from './utils.cjs';
|
|
12
|
+
export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.cjs';
|
|
13
|
+
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.cjs';
|
|
14
|
+
export { default as isEqual } from 'fast-deep-equal';
|
|
15
|
+
import '@usertour/types';
|
|
16
|
+
import './storage.cjs';
|
|
17
|
+
import '@usertour/types/';
|
|
18
|
+
import 'clsx';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { convertSettings, convertToCssVars, mergeThemeDefaultSettings } from './convert-settings.js';
|
|
2
|
+
export { conditionsIsSame, isMatchUrlPattern } from './condition.js';
|
|
3
|
+
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
|
+
export { getCodeError, getContentError, getCurrentTimeError, getElementError, getErrorMessage, getNavitateError, getSegmentError, getStepError, getTextFillError, getTextInputError, getUrlPatternError, getUserAttrError, getWaitError, hasActionError, hasError, isValidSelector } from './error.js';
|
|
6
|
+
export { getAuthToken, removeAuthToken, setAuthToken, storage } from './auth.js';
|
|
7
|
+
export { defaultStep } from './settings.js';
|
|
8
|
+
export { isUrl } from './is-url.js';
|
|
9
|
+
export { AbortController, ArrayProto, XMLHttpRequest, assignableWindow, document, fetch, location, nativeForEach, nativeIndexOf, navigator, userAgent, window } from './globals.js';
|
|
10
|
+
export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from './content.js';
|
|
11
|
+
export { deepClone } from './utils.js';
|
|
12
|
+
export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.js';
|
|
13
|
+
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.js';
|
|
14
|
+
export { default as isEqual } from 'fast-deep-equal';
|
|
15
|
+
import '@usertour/types';
|
|
16
|
+
import './storage.js';
|
|
17
|
+
import '@usertour/types/';
|
|
18
|
+
import 'clsx';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
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 {
|
|
13
|
+
isUrl
|
|
14
|
+
} from "./chunk-ZNFXGN3M.js";
|
|
15
|
+
import {
|
|
16
|
+
defaultStep
|
|
17
|
+
} from "./chunk-FW54TSA3.js";
|
|
18
|
+
import {
|
|
19
|
+
deepClone
|
|
20
|
+
} from "./chunk-2AEGAICC.js";
|
|
21
|
+
import {
|
|
22
|
+
getAuthToken,
|
|
23
|
+
removeAuthToken,
|
|
24
|
+
setAuthToken,
|
|
25
|
+
storage
|
|
26
|
+
} from "./chunk-FGFMTWFT.js";
|
|
27
|
+
import "./chunk-3ZGH3NRU.js";
|
|
28
|
+
import {
|
|
29
|
+
conditionsIsSame,
|
|
30
|
+
isEqual,
|
|
31
|
+
isMatchUrlPattern
|
|
32
|
+
} from "./chunk-FNQIIEWK.js";
|
|
33
|
+
import {
|
|
34
|
+
autoStartConditions,
|
|
35
|
+
buildConfig,
|
|
36
|
+
defaultContentConfig
|
|
37
|
+
} from "./chunk-64BFWPHJ.js";
|
|
38
|
+
import {
|
|
39
|
+
isPublishedAtLeastOneEnvironment,
|
|
40
|
+
isPublishedInAllEnvironments
|
|
41
|
+
} from "./chunk-BBPZYUJR.js";
|
|
42
|
+
import {
|
|
43
|
+
convertSettings,
|
|
44
|
+
convertToCssVars,
|
|
45
|
+
mergeThemeDefaultSettings
|
|
46
|
+
} from "./chunk-USHOKNHQ.js";
|
|
47
|
+
import {
|
|
48
|
+
isArray,
|
|
49
|
+
isBoolean,
|
|
50
|
+
isDate,
|
|
51
|
+
isDocument,
|
|
52
|
+
isEmptyObject,
|
|
53
|
+
isEmptyString,
|
|
54
|
+
isFile,
|
|
55
|
+
isFormData,
|
|
56
|
+
isFunction,
|
|
57
|
+
isNull,
|
|
58
|
+
isNullish,
|
|
59
|
+
isNumber,
|
|
60
|
+
isObject,
|
|
61
|
+
isString,
|
|
62
|
+
isUint8Array,
|
|
63
|
+
isUndefined
|
|
64
|
+
} from "./chunk-GFH3VWOC.js";
|
|
65
|
+
import {
|
|
66
|
+
generateAutoStateColors,
|
|
67
|
+
hexToHSLString,
|
|
68
|
+
hexToRGBStr
|
|
69
|
+
} from "./chunk-VT24VOAZ.js";
|
|
70
|
+
import {
|
|
71
|
+
getCodeError,
|
|
72
|
+
getContentError,
|
|
73
|
+
getCurrentTimeError,
|
|
74
|
+
getElementError,
|
|
75
|
+
getErrorMessage,
|
|
76
|
+
getNavitateError,
|
|
77
|
+
getSegmentError,
|
|
78
|
+
getStepError,
|
|
79
|
+
getTextFillError,
|
|
80
|
+
getTextInputError,
|
|
81
|
+
getUrlPatternError,
|
|
82
|
+
getUserAttrError,
|
|
83
|
+
getWaitError,
|
|
84
|
+
hasActionError,
|
|
85
|
+
hasError,
|
|
86
|
+
isValidSelector
|
|
87
|
+
} from "./chunk-G5P7KULU.js";
|
|
88
|
+
import {
|
|
89
|
+
AbortController,
|
|
90
|
+
ArrayProto,
|
|
91
|
+
XMLHttpRequest,
|
|
92
|
+
assignableWindow,
|
|
93
|
+
document,
|
|
94
|
+
fetch,
|
|
95
|
+
location,
|
|
96
|
+
nativeForEach,
|
|
97
|
+
nativeIndexOf,
|
|
98
|
+
navigator,
|
|
99
|
+
userAgent,
|
|
100
|
+
win
|
|
101
|
+
} from "./chunk-H7VA3ML2.js";
|
|
102
|
+
import "./chunk-XEO3YXBM.js";
|
|
103
|
+
export {
|
|
104
|
+
AbortController,
|
|
105
|
+
ArrayProto,
|
|
106
|
+
XMLHttpRequest,
|
|
107
|
+
absoluteUrl,
|
|
108
|
+
assignableWindow,
|
|
109
|
+
autoStartConditions,
|
|
110
|
+
buildConfig,
|
|
111
|
+
cn,
|
|
112
|
+
conditionsIsSame,
|
|
113
|
+
convertSettings,
|
|
114
|
+
convertToCssVars,
|
|
115
|
+
cuid,
|
|
116
|
+
deepClone,
|
|
117
|
+
defaultContentConfig,
|
|
118
|
+
defaultStep,
|
|
119
|
+
document,
|
|
120
|
+
evalCode,
|
|
121
|
+
fetch,
|
|
122
|
+
formatDate,
|
|
123
|
+
generateAutoStateColors,
|
|
124
|
+
getAuthToken,
|
|
125
|
+
getCodeError,
|
|
126
|
+
getContentError,
|
|
127
|
+
getCurrentTimeError,
|
|
128
|
+
getElementError,
|
|
129
|
+
getErrorMessage,
|
|
130
|
+
getNavitateError,
|
|
131
|
+
getRandomColor,
|
|
132
|
+
getSegmentError,
|
|
133
|
+
getStepError,
|
|
134
|
+
getTextFillError,
|
|
135
|
+
getTextInputError,
|
|
136
|
+
getUrlPatternError,
|
|
137
|
+
getUserAttrError,
|
|
138
|
+
getWaitError,
|
|
139
|
+
hasActionError,
|
|
140
|
+
hasError,
|
|
141
|
+
hexToHSLString,
|
|
142
|
+
hexToRGBStr,
|
|
143
|
+
hexToRgb,
|
|
144
|
+
isArray,
|
|
145
|
+
isBoolean,
|
|
146
|
+
isDark,
|
|
147
|
+
isDate,
|
|
148
|
+
isDocument,
|
|
149
|
+
isEmptyObject,
|
|
150
|
+
isEmptyString,
|
|
151
|
+
isEqual,
|
|
152
|
+
isFile,
|
|
153
|
+
isFormData,
|
|
154
|
+
isFunction,
|
|
155
|
+
isMatchUrlPattern,
|
|
156
|
+
isNull,
|
|
157
|
+
isNullish,
|
|
158
|
+
isNumber,
|
|
159
|
+
isObject,
|
|
160
|
+
isPublishedAtLeastOneEnvironment,
|
|
161
|
+
isPublishedInAllEnvironments,
|
|
162
|
+
isString,
|
|
163
|
+
isUint8Array,
|
|
164
|
+
isUndefined,
|
|
165
|
+
isUrl,
|
|
166
|
+
isValidSelector,
|
|
167
|
+
location,
|
|
168
|
+
mergeThemeDefaultSettings,
|
|
169
|
+
nativeForEach,
|
|
170
|
+
nativeIndexOf,
|
|
171
|
+
navigator,
|
|
172
|
+
removeAuthToken,
|
|
173
|
+
setAuthToken,
|
|
174
|
+
storage,
|
|
175
|
+
userAgent,
|
|
176
|
+
uuidV4,
|
|
177
|
+
win as window
|
|
178
|
+
};
|
package/dist/is-url.cjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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/is-url.ts
|
|
21
|
+
var is_url_exports = {};
|
|
22
|
+
__export(is_url_exports, {
|
|
23
|
+
isUrl: () => isUrl
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(is_url_exports);
|
|
26
|
+
var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
|
27
|
+
var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
|
|
28
|
+
var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
|
|
29
|
+
function isUrl(string) {
|
|
30
|
+
if (typeof string !== "string") {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const match = string.match(protocolAndDomainRE);
|
|
34
|
+
if (!match) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const everythingAfterProtocol = match[1];
|
|
38
|
+
if (!everythingAfterProtocol) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
isUrl
|
|
49
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RegExps.
|
|
3
|
+
* A URL must match #1 and then at least one of #2/#3.
|
|
4
|
+
* Use two levels of REs to avoid REDOS.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Loosely validate a URL `string`.
|
|
8
|
+
*
|
|
9
|
+
* @param {String} string
|
|
10
|
+
* @return {Boolean}
|
|
11
|
+
*/
|
|
12
|
+
declare function isUrl(string: string): boolean;
|
|
13
|
+
|
|
14
|
+
export { isUrl };
|
package/dist/is-url.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RegExps.
|
|
3
|
+
* A URL must match #1 and then at least one of #2/#3.
|
|
4
|
+
* Use two levels of REs to avoid REDOS.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Loosely validate a URL `string`.
|
|
8
|
+
*
|
|
9
|
+
* @param {String} string
|
|
10
|
+
* @return {Boolean}
|
|
11
|
+
*/
|
|
12
|
+
declare function isUrl(string: string): boolean;
|
|
13
|
+
|
|
14
|
+
export { isUrl };
|
package/dist/is-url.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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/settings.ts
|
|
21
|
+
var settings_exports = {};
|
|
22
|
+
__export(settings_exports, {
|
|
23
|
+
defaultStep: () => defaultStep
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(settings_exports);
|
|
26
|
+
var defaultStep = {
|
|
27
|
+
name: "step",
|
|
28
|
+
type: "tooltip",
|
|
29
|
+
sequence: 0,
|
|
30
|
+
setting: {
|
|
31
|
+
height: 0,
|
|
32
|
+
width: 250,
|
|
33
|
+
skippable: true,
|
|
34
|
+
enabledBackdrop: false,
|
|
35
|
+
enabledBlockTarget: false,
|
|
36
|
+
explicitCompletionStep: false,
|
|
37
|
+
align: "center",
|
|
38
|
+
side: "bottom",
|
|
39
|
+
sideOffset: 0,
|
|
40
|
+
alignOffset: 0,
|
|
41
|
+
alignType: "auto",
|
|
42
|
+
position: "center",
|
|
43
|
+
positionOffsetX: 0,
|
|
44
|
+
positionOffsetY: 0
|
|
45
|
+
},
|
|
46
|
+
data: [
|
|
47
|
+
{
|
|
48
|
+
type: "paragraph",
|
|
49
|
+
children: [{ text: "" }]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
target: {
|
|
53
|
+
selectors: null,
|
|
54
|
+
content: "",
|
|
55
|
+
sequence: "1st",
|
|
56
|
+
precision: "stricter",
|
|
57
|
+
isDynamicContent: false,
|
|
58
|
+
customSelector: "",
|
|
59
|
+
type: "auto"
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
defaultStep
|
|
65
|
+
});
|
package/dist/settings.js
ADDED
package/dist/storage.cjs
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/storage.ts
|
|
26
|
+
var storage_exports = {};
|
|
27
|
+
__export(storage_exports, {
|
|
28
|
+
AppStorage: () => AppStorage
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(storage_exports);
|
|
31
|
+
|
|
32
|
+
// src/globals.ts
|
|
33
|
+
var win = typeof window !== "undefined" ? window : void 0;
|
|
34
|
+
var global = typeof globalThis !== "undefined" ? globalThis : win;
|
|
35
|
+
var ArrayProto = Array.prototype;
|
|
36
|
+
var nativeForEach = ArrayProto.forEach;
|
|
37
|
+
var nativeIndexOf = ArrayProto.indexOf;
|
|
38
|
+
var navigator = global == null ? void 0 : global.navigator;
|
|
39
|
+
var document = global == null ? void 0 : global.document;
|
|
40
|
+
var location = global == null ? void 0 : global.location;
|
|
41
|
+
var fetch = global == null ? void 0 : global.fetch;
|
|
42
|
+
var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
|
|
43
|
+
var AbortController = global == null ? void 0 : global.AbortController;
|
|
44
|
+
var userAgent = navigator == null ? void 0 : navigator.userAgent;
|
|
45
|
+
var assignableWindow = win != null ? win : {};
|
|
46
|
+
|
|
47
|
+
// src/storage.ts
|
|
48
|
+
var AppStorage = class {
|
|
49
|
+
constructor(prefix, defaultExpire) {
|
|
50
|
+
__publicField(this, "prefix", "USERTOUR@0.0.1");
|
|
51
|
+
__publicField(this, "defaultExpire", 5);
|
|
52
|
+
__publicField(this, "setStorage", (type, key, inputValue, inputExpire = -1) => {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
const value = inputValue === "" || inputValue === void 0 ? null : inputValue;
|
|
55
|
+
const expire = Number.isNaN(inputExpire) ? this.defaultExpire : inputExpire;
|
|
56
|
+
const data = {
|
|
57
|
+
value,
|
|
58
|
+
time: Date.now(),
|
|
59
|
+
expire
|
|
60
|
+
};
|
|
61
|
+
try {
|
|
62
|
+
const stringifyData = JSON.stringify(data);
|
|
63
|
+
(_b = (_a = win) == null ? void 0 : _a[type]) == null ? void 0 : _b.setItem(this.autoAddPrefix(key), stringifyData);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.error(`[APP_STORAGE] setStorage error: ${e}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
__publicField(this, "getStorage", (type, key) => {
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
|
+
const prefixKey = this.autoAddPrefix(key);
|
|
71
|
+
if (!((_b = (_a = win) == null ? void 0 : _a[type]) == null ? void 0 : _b.getItem(prefixKey))) {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
let storage = void 0;
|
|
75
|
+
try {
|
|
76
|
+
const stringifyData = (_d = (_c = win) == null ? void 0 : _c[type]) == null ? void 0 : _d.getItem(prefixKey);
|
|
77
|
+
if (stringifyData === null || stringifyData === void 0) {
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
storage = JSON.parse(stringifyData);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.error(`[APP_STORAGE] getStorage error: ${e}`);
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
const nowTime = Date.now();
|
|
86
|
+
if (storage === void 0) {
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
if (storage.expire > -1 && storage.expire * 60 * 1e3 < nowTime - storage.time) {
|
|
90
|
+
this.removeStorage(type, key);
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
this.setStorage(type, key, storage.value, storage.expire);
|
|
94
|
+
return storage.value;
|
|
95
|
+
});
|
|
96
|
+
__publicField(this, "clearStorage", (type) => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
(_b = (_a = win) == null ? void 0 : _a[type]) == null ? void 0 : _b.clear();
|
|
99
|
+
});
|
|
100
|
+
__publicField(this, "removeStorage", (type, key) => {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
(_b = (_a = win) == null ? void 0 : _a[type]) == null ? void 0 : _b.removeItem(this.autoAddPrefix(key));
|
|
103
|
+
});
|
|
104
|
+
__publicField(this, "setLocalStorage", (key, value, expire) => {
|
|
105
|
+
this.setStorage("localStorage", key, value, expire);
|
|
106
|
+
});
|
|
107
|
+
__publicField(this, "getLocalStorage", (key) => {
|
|
108
|
+
return this.getStorage("localStorage", key);
|
|
109
|
+
});
|
|
110
|
+
__publicField(this, "clearLocalStorage", () => {
|
|
111
|
+
this.clearStorage("localStorage");
|
|
112
|
+
});
|
|
113
|
+
__publicField(this, "removeLocalStorage", (key) => {
|
|
114
|
+
this.removeStorage("localStorage", key);
|
|
115
|
+
});
|
|
116
|
+
__publicField(this, "setSessionStorage", (key, value, expire) => {
|
|
117
|
+
this.setStorage("sessionStorage", key, value, expire);
|
|
118
|
+
});
|
|
119
|
+
__publicField(this, "getSessionStorage", (key) => {
|
|
120
|
+
return this.getStorage("sessionStorage", key);
|
|
121
|
+
});
|
|
122
|
+
__publicField(this, "clearSessionStorage", () => {
|
|
123
|
+
this.clearStorage("sessionStorage");
|
|
124
|
+
});
|
|
125
|
+
__publicField(this, "removeSessionStorage", (key) => {
|
|
126
|
+
this.removeStorage("sessionStorage", key);
|
|
127
|
+
});
|
|
128
|
+
if (prefix !== void 0) {
|
|
129
|
+
this.prefix = prefix;
|
|
130
|
+
}
|
|
131
|
+
if (defaultExpire !== void 0) {
|
|
132
|
+
this.defaultExpire = defaultExpire;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
autoAddPrefix(key) {
|
|
136
|
+
return `${this.prefix}/${key}`;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
140
|
+
0 && (module.exports = {
|
|
141
|
+
AppStorage
|
|
142
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface StorageDataShape {
|
|
2
|
+
value: unknown;
|
|
3
|
+
time: number;
|
|
4
|
+
expire: number;
|
|
5
|
+
}
|
|
6
|
+
declare class AppStorage {
|
|
7
|
+
prefix: string;
|
|
8
|
+
defaultExpire: number;
|
|
9
|
+
constructor(prefix?: string, defaultExpire?: number);
|
|
10
|
+
private autoAddPrefix;
|
|
11
|
+
private setStorage;
|
|
12
|
+
private getStorage;
|
|
13
|
+
private clearStorage;
|
|
14
|
+
private removeStorage;
|
|
15
|
+
setLocalStorage: (key: string, value: unknown, expire?: number) => void;
|
|
16
|
+
getLocalStorage: (key: string) => unknown;
|
|
17
|
+
clearLocalStorage: () => void;
|
|
18
|
+
removeLocalStorage: (key: string) => void;
|
|
19
|
+
setSessionStorage: (key: string, value: unknown, expire?: number) => void;
|
|
20
|
+
getSessionStorage: (key: string) => unknown;
|
|
21
|
+
clearSessionStorage: () => void;
|
|
22
|
+
removeSessionStorage: (key: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { AppStorage, type StorageDataShape };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface StorageDataShape {
|
|
2
|
+
value: unknown;
|
|
3
|
+
time: number;
|
|
4
|
+
expire: number;
|
|
5
|
+
}
|
|
6
|
+
declare class AppStorage {
|
|
7
|
+
prefix: string;
|
|
8
|
+
defaultExpire: number;
|
|
9
|
+
constructor(prefix?: string, defaultExpire?: number);
|
|
10
|
+
private autoAddPrefix;
|
|
11
|
+
private setStorage;
|
|
12
|
+
private getStorage;
|
|
13
|
+
private clearStorage;
|
|
14
|
+
private removeStorage;
|
|
15
|
+
setLocalStorage: (key: string, value: unknown, expire?: number) => void;
|
|
16
|
+
getLocalStorage: (key: string) => unknown;
|
|
17
|
+
clearLocalStorage: () => void;
|
|
18
|
+
removeLocalStorage: (key: string) => void;
|
|
19
|
+
setSessionStorage: (key: string, value: unknown, expire?: number) => void;
|
|
20
|
+
getSessionStorage: (key: string) => unknown;
|
|
21
|
+
clearSessionStorage: () => void;
|
|
22
|
+
removeSessionStorage: (key: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { AppStorage, type StorageDataShape };
|