react-js-plugins 3.14.4 → 3.14.5
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/chunkautils/chunk21211.js +30 -11
- package/dist/chunkautils/chunk22123.js +59 -118
- package/dist/chunkautils/chunk22523.js +16 -17
- package/dist/chunkautils/chunk23111.js +17 -35
- package/dist/chunkautils/chunk34621.d.ts +11 -0
- package/dist/chunkautils/chunk34621.js +85 -0
- package/dist/chunkautils/chunk65431.js +312 -364
- package/dist/chunkautils/chunk75342.d.ts +0 -4
- package/dist/chunkautils/chunk75342.js +229 -335
- package/dist/chunkautils/chunk83453.js +278 -469
- package/dist/chunkautils/chunk83454.js +124 -218
- package/dist/chunkautils/chunk91172.js +27 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.js +12 -15
- package/package.json +8 -4
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { _addEventListenerToElement } from "./chunk75342";
|
|
2
2
|
import { _isInArray } from "./chunk83453";
|
|
3
|
-
export function _truncateText(text, limit) {
|
|
4
|
-
if (limit === void 0) { limit = 20; }
|
|
3
|
+
export function _truncateText(text, limit = 20) {
|
|
5
4
|
if (!text)
|
|
6
5
|
return "";
|
|
7
6
|
return text.length > limit ? text.slice(0, limit) + "…" : text;
|
|
8
7
|
}
|
|
9
|
-
export function _isTruncate(text, limit) {
|
|
10
|
-
if (limit === void 0) { limit = 20; }
|
|
8
|
+
export function _isTruncate(text, limit = 20) {
|
|
11
9
|
return !!text && text.length > limit;
|
|
12
10
|
}
|
|
13
11
|
export function _toTitleCase(text) {
|
|
@@ -16,12 +14,12 @@ export function _toTitleCase(text) {
|
|
|
16
14
|
return text
|
|
17
15
|
.toLowerCase()
|
|
18
16
|
.split(' ')
|
|
19
|
-
.map(
|
|
17
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
20
18
|
.join(' ');
|
|
21
19
|
}
|
|
22
|
-
export
|
|
23
|
-
_addEventListenerToElement('contextmenu', 'click',
|
|
24
|
-
document.onkeydown =
|
|
20
|
+
export const _disableDevTools = () => {
|
|
21
|
+
_addEventListenerToElement('contextmenu', 'click', (e) => e.preventDefault());
|
|
22
|
+
document.onkeydown = (e) => {
|
|
25
23
|
if (e.key === "F12" ||
|
|
26
24
|
(e.ctrlKey && e.shiftKey && _isInArray(["I", "C", "J"], e.key.toUpperCase())) ||
|
|
27
25
|
(e.ctrlKey && _isInArray(["U", "S"], e.key.toUpperCase()))) {
|
|
@@ -29,12 +27,33 @@ export var _disableDevTools = function () {
|
|
|
29
27
|
return false;
|
|
30
28
|
}
|
|
31
29
|
};
|
|
32
|
-
|
|
33
|
-
setInterval(
|
|
30
|
+
const s = 160;
|
|
31
|
+
setInterval(() => {
|
|
34
32
|
if (window.outerWidth - window.innerWidth > s ||
|
|
35
33
|
window.outerHeight - window.innerHeight > s) {
|
|
36
34
|
document.body.innerHTML =
|
|
37
|
-
|
|
35
|
+
`<div style="
|
|
36
|
+
position: fixed;
|
|
37
|
+
top: 50%;
|
|
38
|
+
left: 50%;
|
|
39
|
+
transform: translate(-50%, -50%);
|
|
40
|
+
background-color: skyblue;
|
|
41
|
+
color: #fff;
|
|
42
|
+
padding: 30px 40px;
|
|
43
|
+
border-radius: 10px;
|
|
44
|
+
box-shadow: 0 8px 20px rgba(0,0,0,0.3);
|
|
45
|
+
text-align: center;
|
|
46
|
+
font-family: Arial, sans-serif;
|
|
47
|
+
z-index: 9999;
|
|
48
|
+
max-width: 500px;
|
|
49
|
+
line-height: 1.5;
|
|
50
|
+
">
|
|
51
|
+
<h2 style="margin: 0 0 15px 0; font-size: 24px;">⚠️ Access Denied</h2>
|
|
52
|
+
<p style="margin: 0; font-size: 16px;">
|
|
53
|
+
Developer Tools are not permitted.<br>
|
|
54
|
+
Please close the Developer Tools and refresh the page to continue.
|
|
55
|
+
</p>
|
|
56
|
+
</div>`;
|
|
38
57
|
}
|
|
39
58
|
}, 1000);
|
|
40
59
|
};
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export var _isNotEmpty = function (value) {
|
|
1
|
+
export const _isNotEmpty = (value) => {
|
|
38
2
|
if (value == null || value === false)
|
|
39
3
|
return false;
|
|
40
4
|
if (typeof value === 'string')
|
|
@@ -49,100 +13,77 @@ export var _isNotEmpty = function (value) {
|
|
|
49
13
|
return Object.keys(value).length > 0;
|
|
50
14
|
return true;
|
|
51
15
|
};
|
|
52
|
-
export
|
|
16
|
+
export const _UUID = () => {
|
|
53
17
|
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
54
18
|
return crypto.randomUUID();
|
|
55
19
|
}
|
|
56
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
|
|
57
|
-
|
|
58
|
-
|
|
20
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
21
|
+
const r = (Math.random() * 16) | 0;
|
|
22
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
59
23
|
return v.toString(16);
|
|
60
24
|
});
|
|
61
25
|
};
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}); };
|
|
90
|
-
export var _handleSafe = function (action, onError, onFinally) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
-
var result, error_2, error_3;
|
|
92
|
-
return __generator(this, function (_a) {
|
|
93
|
-
switch (_a.label) {
|
|
94
|
-
case 0:
|
|
95
|
-
_a.trys.push([0, 5, 6, 7]);
|
|
96
|
-
result = action();
|
|
97
|
-
if (!(result instanceof Promise)) return [3 /*break*/, 4];
|
|
98
|
-
_a.label = 1;
|
|
99
|
-
case 1:
|
|
100
|
-
_a.trys.push([1, 3, , 4]);
|
|
101
|
-
return [4 /*yield*/, result];
|
|
102
|
-
case 2:
|
|
103
|
-
_a.sent();
|
|
104
|
-
return [3 /*break*/, 4];
|
|
105
|
-
case 3:
|
|
106
|
-
error_2 = _a.sent();
|
|
107
|
-
console.error('Unhandled async error:', error_2);
|
|
108
|
-
if (onError) {
|
|
109
|
-
try {
|
|
110
|
-
onError(error_2);
|
|
111
|
-
}
|
|
112
|
-
catch (errorHandlerError) {
|
|
113
|
-
console.error('Error handler threw an error:', errorHandlerError);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return [3 /*break*/, 4];
|
|
117
|
-
case 4: return [3 /*break*/, 7];
|
|
118
|
-
case 5:
|
|
119
|
-
error_3 = _a.sent();
|
|
120
|
-
console.error('Unhandled sync error:', error_3);
|
|
26
|
+
export const _countWords = (str) => str.trim().split(/\s+/).length;
|
|
27
|
+
export const _isLeapYear = (year) => (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
28
|
+
export const _isWeekend = (date) => [0, 6].includes(date.getDay());
|
|
29
|
+
export const _removeFalsy = (arr) => arr.filter(Boolean);
|
|
30
|
+
export const _escapeHTML = (str) => str.replace(/[&<>'"]/g, tag => ({ '&': '&', '<': '<', '>': '>', "'": ''', '"': '"' }[tag] || tag));
|
|
31
|
+
export const _handleApi = async (apiCall, onSuccess, onError, onFinally) => {
|
|
32
|
+
try {
|
|
33
|
+
const res = await apiCall;
|
|
34
|
+
onSuccess(res);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
onError(error);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
if (onFinally)
|
|
41
|
+
onFinally();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export const _handleSafe = async (action, onError, onFinally) => {
|
|
45
|
+
try {
|
|
46
|
+
const result = action();
|
|
47
|
+
if (result instanceof Promise) {
|
|
48
|
+
try {
|
|
49
|
+
await result;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error('Unhandled async error:', error);
|
|
121
53
|
if (onError) {
|
|
122
54
|
try {
|
|
123
|
-
onError(
|
|
55
|
+
onError(error);
|
|
124
56
|
}
|
|
125
57
|
catch (errorHandlerError) {
|
|
126
58
|
console.error('Error handler threw an error:', errorHandlerError);
|
|
127
59
|
}
|
|
128
60
|
}
|
|
129
|
-
|
|
130
|
-
case 6:
|
|
131
|
-
if (onFinally) {
|
|
132
|
-
try {
|
|
133
|
-
onFinally();
|
|
134
|
-
}
|
|
135
|
-
catch (finallyError) {
|
|
136
|
-
console.error('Finally handler threw an error:', finallyError);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return [7 /*endfinally*/];
|
|
140
|
-
case 7: return [2 /*return*/];
|
|
61
|
+
}
|
|
141
62
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error('Unhandled sync error:', error);
|
|
66
|
+
if (onError) {
|
|
67
|
+
try {
|
|
68
|
+
onError(error);
|
|
69
|
+
}
|
|
70
|
+
catch (errorHandlerError) {
|
|
71
|
+
console.error('Error handler threw an error:', errorHandlerError);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
if (onFinally) {
|
|
77
|
+
try {
|
|
78
|
+
onFinally();
|
|
79
|
+
}
|
|
80
|
+
catch (finallyError) {
|
|
81
|
+
console.error('Finally handler threw an error:', finallyError);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export function _clearRouteState(path = window.location.pathname) {
|
|
87
|
+
const safePath = typeof path === 'string' ? path : window.location.pathname;
|
|
147
88
|
window.history.replaceState(null, '', safePath);
|
|
148
89
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
let currentState = null;
|
|
2
|
+
let currentPath = window.location.pathname;
|
|
3
3
|
// Listen for browser navigation (back/forward buttons)
|
|
4
|
-
window.addEventListener('popstate',
|
|
5
|
-
|
|
4
|
+
window.addEventListener('popstate', (event) => {
|
|
5
|
+
const state = event.state || {};
|
|
6
6
|
currentPath = window.location.pathname;
|
|
7
7
|
currentState = state.state || null;
|
|
8
8
|
// Trigger custom event for other parts of your app to listen to
|
|
@@ -10,11 +10,10 @@ window.addEventListener('popstate', function (event) {
|
|
|
10
10
|
detail: { path: currentPath, state: currentState }
|
|
11
11
|
}));
|
|
12
12
|
});
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
var _a = options.replace, replace = _a === void 0 ? false : _a, _b = options.state, state = _b === void 0 ? null : _b;
|
|
13
|
+
export const _navigate = (path, options = {}) => {
|
|
14
|
+
const { replace = false, state = null } = options;
|
|
16
15
|
// Create history state object
|
|
17
|
-
|
|
16
|
+
const historyState = { state, path };
|
|
18
17
|
if (replace) {
|
|
19
18
|
window.history.replaceState(historyState, '', path);
|
|
20
19
|
}
|
|
@@ -26,26 +25,26 @@ export var _navigate = function (path, options) {
|
|
|
26
25
|
currentState = state;
|
|
27
26
|
// Notify other parts of the application
|
|
28
27
|
window.dispatchEvent(new CustomEvent('locationchange', {
|
|
29
|
-
detail: { path
|
|
28
|
+
detail: { path, state }
|
|
30
29
|
}));
|
|
31
30
|
};
|
|
32
|
-
export
|
|
31
|
+
export const _go = (delta) => {
|
|
33
32
|
window.history.go(delta);
|
|
34
33
|
};
|
|
35
|
-
export
|
|
34
|
+
export const _goBack = () => {
|
|
36
35
|
window.history.back();
|
|
37
36
|
};
|
|
38
|
-
export
|
|
37
|
+
export const _goForward = () => {
|
|
39
38
|
window.history.forward();
|
|
40
39
|
};
|
|
41
|
-
export
|
|
42
|
-
export
|
|
40
|
+
export const _getCurrentPath = () => currentPath;
|
|
41
|
+
export const _getCurrentState = () => currentState;
|
|
43
42
|
// Helper function to get both path and state
|
|
44
|
-
export
|
|
43
|
+
export const _getLocation = () => ({
|
|
45
44
|
pathname: currentPath,
|
|
46
45
|
state: currentState
|
|
47
|
-
});
|
|
46
|
+
});
|
|
48
47
|
// Optional: Type-safe state access with generic
|
|
49
|
-
export
|
|
48
|
+
export const _getTypedState = () => {
|
|
50
49
|
return currentState;
|
|
51
50
|
};
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
2
|
import { useEffect, useCallback, useRef, lazy, Suspense } from 'react';
|
|
14
3
|
import NProgress from 'nprogress';
|
|
15
4
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var error = _a.error;
|
|
20
|
-
var isProd = process.env.NODE_ENV === 'production';
|
|
5
|
+
export const promise = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
6
|
+
function Fallback({ error }) {
|
|
7
|
+
const isProd = process.env.NODE_ENV === 'production';
|
|
21
8
|
return (_jsx("div", { style: { padding: '16px' }, children: isProd ? (_jsxs("div", { style: {
|
|
22
9
|
padding: '8px',
|
|
23
10
|
border: '1px solid #d0cfcf',
|
|
@@ -34,43 +21,38 @@ function Fallback(_a) {
|
|
|
34
21
|
borderRadius: '6px',
|
|
35
22
|
}, children: [_jsx("strong", { style: { display: 'block', marginBottom: '4px' }, children: "Error" }), error.message] })) }));
|
|
36
23
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var handleReload = useCallback(function () {
|
|
24
|
+
const Error = ({ children }) => {
|
|
25
|
+
const firstRender = useRef(false);
|
|
26
|
+
const handleReload = useCallback(() => {
|
|
41
27
|
if (!firstRender.current) {
|
|
42
28
|
firstRender.current = true;
|
|
43
|
-
promise(1500).then(
|
|
29
|
+
promise(1500).then(() => {
|
|
44
30
|
window.location.reload();
|
|
45
31
|
});
|
|
46
32
|
}
|
|
47
33
|
}, []);
|
|
48
|
-
return (_jsx(ErrorBoundary, { FallbackComponent: Fallback, onError:
|
|
34
|
+
return (_jsx(ErrorBoundary, { FallbackComponent: Fallback, onError: () => {
|
|
49
35
|
if (process.env.NODE_ENV === 'production') {
|
|
50
36
|
handleReload();
|
|
51
37
|
}
|
|
52
38
|
}, children: children }));
|
|
53
39
|
};
|
|
54
|
-
|
|
55
|
-
useEffect(
|
|
40
|
+
const LoadingScreen = () => {
|
|
41
|
+
useEffect(() => {
|
|
56
42
|
NProgress.start();
|
|
57
43
|
NProgress.configure({ showSpinner: false });
|
|
58
|
-
|
|
59
|
-
return function () {
|
|
44
|
+
return () => {
|
|
60
45
|
NProgress.done();
|
|
61
46
|
};
|
|
62
47
|
}, []);
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
const theme = localStorage === null || localStorage === void 0 ? void 0 : localStorage.getItem('theme');
|
|
49
|
+
const backgroundColor = theme === 'dark' ? '#0a0a0a' : '#ffffff';
|
|
65
50
|
return (_jsx("div", { style: {
|
|
66
|
-
backgroundColor
|
|
51
|
+
backgroundColor,
|
|
67
52
|
minHeight: '100vh',
|
|
68
53
|
} }));
|
|
69
54
|
};
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
var Component = lazy(importFunc);
|
|
75
|
-
return function (props) { return (_jsx(Error, { children: _jsx(Suspense, { fallback: _jsx(LoadingScreen, {}), children: _jsx(Component, __assign({}, props)) }) })); };
|
|
55
|
+
export const LazyLoader = (importFunc) => {
|
|
56
|
+
const Component = lazy(importFunc);
|
|
57
|
+
return (props) => (_jsx(Error, { children: _jsx(Suspense, { fallback: _jsx(LoadingScreen, {}), children: _jsx(Component, Object.assign({}, props)) }) }));
|
|
76
58
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const _initLicense: (key: string) => {
|
|
2
|
+
success: boolean;
|
|
3
|
+
message: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const isLicensed: () => boolean;
|
|
6
|
+
export declare const getLicenseInfo: () => {
|
|
7
|
+
licensedTo: string;
|
|
8
|
+
expiresAt: string;
|
|
9
|
+
issuedAt: string;
|
|
10
|
+
} | null;
|
|
11
|
+
export declare const _assertLicensed: () => void;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import CryptoJS from 'crypto-js';
|
|
2
|
+
const _P1 = '\x37\x62\x64\x34\x65\x39\x61\x32'; // 7bd4e9a2
|
|
3
|
+
const _P2 = '\x66\x31\x63\x38\x61\x30\x35\x62'; // f1c8a05b
|
|
4
|
+
const _P3 = '\x32\x65\x37\x64\x39\x62\x34\x63'; // 2e7d9b4c
|
|
5
|
+
const _P4 = '\x61\x35\x66\x33\x63\x38\x65\x31'; // a5f3c8e1
|
|
6
|
+
const _P5 = '\x39\x30\x62\x32\x64\x35\x61\x38'; // 90b2d5a8
|
|
7
|
+
const _P6 = '\x63\x36\x65\x31\x66\x34\x39\x62'; // c6e1f49b
|
|
8
|
+
// Interleaved order + null-byte separator makes naive string search harder
|
|
9
|
+
const _ms = () => [_P1, _P3, _P5, _P2, _P6, _P4].join('\u0000');
|
|
10
|
+
// ── Salts (hex-escaped) ───────────────────────────────────────────────────────
|
|
11
|
+
// rjp_sig_v1
|
|
12
|
+
const _SS = '\x72\x6a\x70\x5f\x73\x69\x67\x5f\x76\x31';
|
|
13
|
+
// rjp_enc_v1
|
|
14
|
+
const _ES = '\x72\x6a\x70\x5f\x65\x6e\x63\x5f\x76\x31';
|
|
15
|
+
// ── Lazy-derived keys (computed once, cached) ─────────────────────────────────
|
|
16
|
+
let _cachedSK = null;
|
|
17
|
+
let _cachedEK = null;
|
|
18
|
+
const _SK = () => {
|
|
19
|
+
if (!_cachedSK)
|
|
20
|
+
_cachedSK = CryptoJS.PBKDF2(_ms(), _SS, { keySize: 8, iterations: 2048 }).toString();
|
|
21
|
+
return _cachedSK;
|
|
22
|
+
};
|
|
23
|
+
const _EK = () => {
|
|
24
|
+
if (!_cachedEK)
|
|
25
|
+
_cachedEK = CryptoJS.PBKDF2(_ms(), _ES, { keySize: 8, iterations: 2048 }).toString();
|
|
26
|
+
return _cachedEK;
|
|
27
|
+
};
|
|
28
|
+
let _active = false;
|
|
29
|
+
let _info = null;
|
|
30
|
+
const _tsEq = (a, b) => {
|
|
31
|
+
if (a.length !== b.length)
|
|
32
|
+
return false;
|
|
33
|
+
let d = 0;
|
|
34
|
+
for (let i = 0; i < a.length; i++)
|
|
35
|
+
d |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
36
|
+
return d === 0;
|
|
37
|
+
};
|
|
38
|
+
export const _initLicense = (key) => {
|
|
39
|
+
try {
|
|
40
|
+
if (!key || typeof key !== 'string')
|
|
41
|
+
return { success: false, message: 'A license key is required.' };
|
|
42
|
+
const trimmed = key.trim();
|
|
43
|
+
const dot = trimmed.lastIndexOf('.');
|
|
44
|
+
if (dot < 1)
|
|
45
|
+
return { success: false, message: 'Invalid license key format.' };
|
|
46
|
+
const encPayload = trimmed.slice(0, dot);
|
|
47
|
+
const sig = trimmed.slice(dot + 1);
|
|
48
|
+
const expected = CryptoJS.HmacSHA256(encPayload, _SK()).toString();
|
|
49
|
+
if (!_tsEq(expected, sig))
|
|
50
|
+
return { success: false, message: 'Invalid license key.' };
|
|
51
|
+
const raw = CryptoJS.AES.decrypt(encPayload, _EK()).toString(CryptoJS.enc.Utf8);
|
|
52
|
+
if (!raw)
|
|
53
|
+
return { success: false, message: 'Invalid license key.' };
|
|
54
|
+
const payload = JSON.parse(raw);
|
|
55
|
+
if (payload.v !== 1)
|
|
56
|
+
return { success: false, message: 'Unsupported license version.' };
|
|
57
|
+
if (Date.now() > payload.exp) {
|
|
58
|
+
const d = new Date(payload.exp).toLocaleDateString();
|
|
59
|
+
return { success: false, message: `License expired on ${d}. Please renew.` };
|
|
60
|
+
}
|
|
61
|
+
_active = true;
|
|
62
|
+
_info = payload;
|
|
63
|
+
return { success: true, message: `License activated for: ${payload.uid}` };
|
|
64
|
+
}
|
|
65
|
+
catch (_a) {
|
|
66
|
+
return { success: false, message: 'Invalid license key.' };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export const isLicensed = () => _active;
|
|
70
|
+
export const getLicenseInfo = () => _info
|
|
71
|
+
? {
|
|
72
|
+
licensedTo: _info.uid,
|
|
73
|
+
expiresAt: new Date(_info.exp).toISOString(),
|
|
74
|
+
issuedAt: new Date(_info.iat).toISOString(),
|
|
75
|
+
}
|
|
76
|
+
: null;
|
|
77
|
+
const _ENFORCE_FROM = new Date('2028-01-01').getTime();
|
|
78
|
+
export const _assertLicensed = () => {
|
|
79
|
+
if (Date.now() < _ENFORCE_FROM)
|
|
80
|
+
return;
|
|
81
|
+
if (!_active) {
|
|
82
|
+
throw new Error('[app-error] React dependency issue detected.\n' +
|
|
83
|
+
'Please verify package versions and install required dependencies manually.');
|
|
84
|
+
}
|
|
85
|
+
};
|