@cyberskill/shared 1.50.0 → 1.52.0
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/_tsup-dts-rollup.d.cts +100 -129
- package/dist/_tsup-dts-rollup.d.ts +100 -129
- package/dist/cli.cjs +1 -2146
- package/dist/cli.d.cts +1 -2
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +1 -2066
- package/dist/configs/commitlint/base.cjs +1 -64
- package/dist/configs/commitlint/base.js +1 -7
- package/dist/configs/eslint/base.cjs +1 -121
- package/dist/configs/eslint/base.js +1 -52
- package/dist/configs/eslint/nestjs.cjs +1 -155
- package/dist/configs/eslint/nestjs.js +1 -85
- package/dist/configs/eslint/nextjs.cjs +1 -155
- package/dist/configs/eslint/nextjs.js +1 -85
- package/dist/configs/eslint/nodejs.cjs +1 -156
- package/dist/configs/eslint/nodejs.js +1 -86
- package/dist/configs/eslint/vite-react.cjs +1 -159
- package/dist/configs/eslint/vite-react.js +1 -89
- package/dist/configs/graphql/graphql-codegen.cjs +1 -125
- package/dist/configs/graphql/graphql-codegen.js +1 -64
- package/dist/configs/graphql/index.cjs +1 -126
- package/dist/configs/graphql/index.js +1 -64
- package/dist/configs/i18n/react/i18next.cjs +1 -80
- package/dist/configs/i18n/react/i18next.js +1 -7
- package/dist/configs/i18n/react/index.cjs +1 -81
- package/dist/configs/i18n/react/index.js +1 -7
- package/dist/configs/index.cjs +1 -232
- package/dist/configs/index.js +1 -166
- package/dist/configs/lint-staged/base.cjs +1 -64
- package/dist/configs/lint-staged/base.js +1 -7
- package/dist/configs/vitest/react/e2e.cjs +1 -128
- package/dist/configs/vitest/react/e2e.js +1 -59
- package/dist/configs/vitest/react/unit.cjs +1 -305
- package/dist/configs/vitest/react/unit.js +1 -228
- package/dist/configs/vitest/react/unit.setup.cjs +1 -60
- package/dist/configs/vitest/react/unit.setup.js +1 -8
- package/dist/constants/index.cjs +1 -677
- package/dist/constants/index.d.cts +8 -3
- package/dist/constants/index.d.ts +8 -3
- package/dist/constants/index.js +1 -468
- package/dist/constants/path.cjs +1 -422
- package/dist/constants/path.d.cts +8 -3
- package/dist/constants/path.d.ts +8 -3
- package/dist/constants/path.js +1 -217
- package/dist/constants/response-status.cjs +1 -313
- package/dist/constants/response-status.js +1 -252
- package/dist/index.cjs +1 -4559
- package/dist/index.d.cts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.js +1 -4142
- package/dist/nodejs/index.cjs +1 -2138
- package/dist/nodejs/index.js +1 -2054
- package/dist/nodejs/mongo.cjs +1 -2137
- package/dist/nodejs/mongo.js +1 -2054
- package/dist/react/apollo-client.cjs +1 -177
- package/dist/react/apollo-client.js +1 -116
- package/dist/react/index.cjs +1 -990
- package/dist/react/index.js +1 -876
- package/dist/react/loading.cjs +1 -301
- package/dist/react/loading.js +1 -216
- package/dist/react/next-intl.cjs +1 -744
- package/dist/react/next-intl.js +1 -655
- package/dist/react/storage.cjs +1 -631
- package/dist/react/storage.js +1 -558
- package/dist/typescript/api-response.cjs +1 -48
- package/dist/typescript/apollo.cjs +1 -48
- package/dist/typescript/command.cjs +1 -68
- package/dist/typescript/command.d.cts +3 -0
- package/dist/typescript/command.d.ts +3 -0
- package/dist/typescript/command.js +1 -7
- package/dist/typescript/config.cjs +1 -48
- package/dist/typescript/fs.cjs +1 -48
- package/dist/typescript/graphql-codegen.cjs +1 -48
- package/dist/typescript/index.cjs +1 -175
- package/dist/typescript/index.d.cts +3 -0
- package/dist/typescript/index.d.ts +3 -0
- package/dist/typescript/index.js +1 -151
- package/dist/typescript/loading.cjs +1 -48
- package/dist/typescript/log.cjs +1 -48
- package/dist/typescript/mongo.cjs +1 -164
- package/dist/typescript/mongo.js +1 -145
- package/dist/typescript/next-intl.cjs +1 -48
- package/dist/typescript/react.cjs +1 -48
- package/dist/typescript/serializer.cjs +1 -48
- package/dist/typescript/string.cjs +1 -48
- package/dist/utils/command.cjs +1 -1387
- package/dist/utils/command.d.cts +2 -2
- package/dist/utils/command.d.ts +2 -2
- package/dist/utils/command.js +1 -1287
- package/dist/utils/common.cjs +1 -300
- package/dist/utils/common.js +1 -219
- package/dist/utils/config.cjs +1 -146
- package/dist/utils/config.js +1 -89
- package/dist/utils/fs.cjs +1 -132
- package/dist/utils/fs.js +1 -47
- package/dist/utils/index-nodejs.cjs +1 -1752
- package/dist/utils/index-nodejs.d.cts +2 -5
- package/dist/utils/index-nodejs.d.ts +2 -5
- package/dist/utils/index-nodejs.js +1 -1581
- package/dist/utils/index.cjs +1 -727
- package/dist/utils/index.js +1 -625
- package/dist/utils/log.cjs +1 -330
- package/dist/utils/log.js +1 -269
- package/dist/utils/package.cjs +1 -941
- package/dist/utils/package.js +1 -857
- package/dist/utils/path.cjs +1 -291
- package/dist/utils/path.d.cts +0 -3
- package/dist/utils/path.d.ts +0 -3
- package/dist/utils/path.js +1 -191
- package/dist/utils/serializer.cjs +1 -91
- package/dist/utils/serializer.js +1 -30
- package/dist/utils/storage-client.cjs +1 -349
- package/dist/utils/storage-client.js +1 -276
- package/dist/utils/storage-server.cjs +1 -636
- package/dist/utils/storage-server.js +1 -550
- package/dist/utils/string.cjs +1 -152
- package/dist/utils/string.js +1 -75
- package/dist/utils/validate.cjs +1 -90
- package/dist/utils/validate.js +1 -33
- package/package.json +15 -13
- /package/{src/public → public}/favicon/android-icon-144x144.png +0 -0
- /package/{src/public → public}/favicon/android-icon-192x192.png +0 -0
- /package/{src/public → public}/favicon/android-icon-36x36.png +0 -0
- /package/{src/public → public}/favicon/android-icon-48x48.png +0 -0
- /package/{src/public → public}/favicon/android-icon-72x72.png +0 -0
- /package/{src/public → public}/favicon/android-icon-96x96.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-114x114.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-120x120.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-144x144.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-152x152.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-180x180.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-57x57.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-60x60.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-72x72.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-76x76.png +0 -0
- /package/{src/public → public}/favicon/apple-icon-precomposed.png +0 -0
- /package/{src/public → public}/favicon/apple-icon.png +0 -0
- /package/{src/public → public}/favicon/browserconfig.xml +0 -0
- /package/{src/public → public}/favicon/favicon-16x16.png +0 -0
- /package/{src/public → public}/favicon/favicon-32x32.png +0 -0
- /package/{src/public → public}/favicon/favicon-96x96.png +0 -0
- /package/{src/public → public}/favicon/favicon.ico +0 -0
- /package/{src/public → public}/favicon/manifest.json +0 -0
- /package/{src/public → public}/favicon/ms-icon-144x144.png +0 -0
- /package/{src/public → public}/favicon/ms-icon-150x150.png +0 -0
- /package/{src/public → public}/favicon/ms-icon-310x310.png +0 -0
- /package/{src/public → public}/favicon/ms-icon-70x70.png +0 -0
package/dist/react/next-intl.js
CHANGED
|
@@ -1,655 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function _array_like_to_array(arr, len) {
|
|
3
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
-
return arr2;
|
|
6
|
-
}
|
|
7
|
-
function _array_with_holes(arr) {
|
|
8
|
-
if (Array.isArray(arr)) return arr;
|
|
9
|
-
}
|
|
10
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
|
-
try {
|
|
12
|
-
var info = gen[key](arg);
|
|
13
|
-
var value = info.value;
|
|
14
|
-
} catch (error) {
|
|
15
|
-
reject(error);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (info.done) {
|
|
19
|
-
resolve(value);
|
|
20
|
-
} else {
|
|
21
|
-
Promise.resolve(value).then(_next, _throw);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function _async_to_generator(fn) {
|
|
25
|
-
return function() {
|
|
26
|
-
var self = this, args = arguments;
|
|
27
|
-
return new Promise(function(resolve, reject) {
|
|
28
|
-
var gen = fn.apply(self, args);
|
|
29
|
-
function _next(value) {
|
|
30
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
31
|
-
}
|
|
32
|
-
function _throw(err) {
|
|
33
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
34
|
-
}
|
|
35
|
-
_next(undefined);
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function _define_property(obj, key, value) {
|
|
40
|
-
if (key in obj) {
|
|
41
|
-
Object.defineProperty(obj, key, {
|
|
42
|
-
value: value,
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
writable: true
|
|
46
|
-
});
|
|
47
|
-
} else {
|
|
48
|
-
obj[key] = value;
|
|
49
|
-
}
|
|
50
|
-
return obj;
|
|
51
|
-
}
|
|
52
|
-
function _instanceof(left, right) {
|
|
53
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
54
|
-
return !!right[Symbol.hasInstance](left);
|
|
55
|
-
} else {
|
|
56
|
-
return left instanceof right;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function _iterable_to_array_limit(arr, i) {
|
|
60
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
61
|
-
if (_i == null) return;
|
|
62
|
-
var _arr = [];
|
|
63
|
-
var _n = true;
|
|
64
|
-
var _d = false;
|
|
65
|
-
var _s, _e;
|
|
66
|
-
try {
|
|
67
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
68
|
-
_arr.push(_s.value);
|
|
69
|
-
if (i && _arr.length === i) break;
|
|
70
|
-
}
|
|
71
|
-
} catch (err) {
|
|
72
|
-
_d = true;
|
|
73
|
-
_e = err;
|
|
74
|
-
} finally{
|
|
75
|
-
try {
|
|
76
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
77
|
-
} finally{
|
|
78
|
-
if (_d) throw _e;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return _arr;
|
|
82
|
-
}
|
|
83
|
-
function _non_iterable_rest() {
|
|
84
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
85
|
-
}
|
|
86
|
-
function _object_spread(target) {
|
|
87
|
-
for(var i = 1; i < arguments.length; i++){
|
|
88
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
89
|
-
var ownKeys = Object.keys(source);
|
|
90
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
91
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
92
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
ownKeys.forEach(function(key) {
|
|
96
|
-
_define_property(target, key, source[key]);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return target;
|
|
100
|
-
}
|
|
101
|
-
function _sliced_to_array(arr, i) {
|
|
102
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
103
|
-
}
|
|
104
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
105
|
-
if (!o) return;
|
|
106
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
107
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
108
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
109
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
110
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
111
|
-
}
|
|
112
|
-
function _ts_generator(thisArg, body) {
|
|
113
|
-
var f, y, t, g, _ = {
|
|
114
|
-
label: 0,
|
|
115
|
-
sent: function() {
|
|
116
|
-
if (t[0] & 1) throw t[1];
|
|
117
|
-
return t[1];
|
|
118
|
-
},
|
|
119
|
-
trys: [],
|
|
120
|
-
ops: []
|
|
121
|
-
};
|
|
122
|
-
return g = {
|
|
123
|
-
next: verb(0),
|
|
124
|
-
"throw": verb(1),
|
|
125
|
-
"return": verb(2)
|
|
126
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
127
|
-
return this;
|
|
128
|
-
}), g;
|
|
129
|
-
function verb(n) {
|
|
130
|
-
return function(v) {
|
|
131
|
-
return step([
|
|
132
|
-
n,
|
|
133
|
-
v
|
|
134
|
-
]);
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function step(op) {
|
|
138
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
139
|
-
while(_)try {
|
|
140
|
-
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;
|
|
141
|
-
if (y = 0, t) op = [
|
|
142
|
-
op[0] & 2,
|
|
143
|
-
t.value
|
|
144
|
-
];
|
|
145
|
-
switch(op[0]){
|
|
146
|
-
case 0:
|
|
147
|
-
case 1:
|
|
148
|
-
t = op;
|
|
149
|
-
break;
|
|
150
|
-
case 4:
|
|
151
|
-
_.label++;
|
|
152
|
-
return {
|
|
153
|
-
value: op[1],
|
|
154
|
-
done: false
|
|
155
|
-
};
|
|
156
|
-
case 5:
|
|
157
|
-
_.label++;
|
|
158
|
-
y = op[1];
|
|
159
|
-
op = [
|
|
160
|
-
0
|
|
161
|
-
];
|
|
162
|
-
continue;
|
|
163
|
-
case 7:
|
|
164
|
-
op = _.ops.pop();
|
|
165
|
-
_.trys.pop();
|
|
166
|
-
continue;
|
|
167
|
-
default:
|
|
168
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
169
|
-
_ = 0;
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
173
|
-
_.label = op[1];
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
177
|
-
_.label = t[1];
|
|
178
|
-
t = op;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
if (t && _.label < t[2]) {
|
|
182
|
-
_.label = t[2];
|
|
183
|
-
_.ops.push(op);
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
if (t[2]) _.ops.pop();
|
|
187
|
-
_.trys.pop();
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
op = body.call(thisArg, _);
|
|
191
|
-
} catch (e) {
|
|
192
|
-
op = [
|
|
193
|
-
6,
|
|
194
|
-
e
|
|
195
|
-
];
|
|
196
|
-
y = 0;
|
|
197
|
-
} finally{
|
|
198
|
-
f = t = 0;
|
|
199
|
-
}
|
|
200
|
-
if (op[0] & 5) throw op[1];
|
|
201
|
-
return {
|
|
202
|
-
value: op[0] ? op[1] : void 0,
|
|
203
|
-
done: true
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
import { NextIntlClientProvider, useTranslations } from "next-intl";
|
|
208
|
-
import { createContext, use, useMemo } from "react";
|
|
209
|
-
// src/react/storage.tsx
|
|
210
|
-
import { useCallback, useEffect, useState } from "react";
|
|
211
|
-
// src/utils/serializer.ts
|
|
212
|
-
var serializer = {
|
|
213
|
-
serialize: function(value) {
|
|
214
|
-
return JSON.stringify(value, function(_, v) {
|
|
215
|
-
if (_instanceof(v, Date)) {
|
|
216
|
-
return {
|
|
217
|
-
__type: "Date",
|
|
218
|
-
value: v.toISOString()
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
return v;
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
deserialize: function(value) {
|
|
225
|
-
return JSON.parse(value, function(_, v) {
|
|
226
|
-
if ((v === null || v === void 0 ? void 0 : v.__type) === "Date") {
|
|
227
|
-
return new Date(v.value);
|
|
228
|
-
}
|
|
229
|
-
return v;
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
// src/utils/storage-client.ts
|
|
234
|
-
import localForage from "localforage";
|
|
235
|
-
var storageClient = {
|
|
236
|
-
get: function get(key) {
|
|
237
|
-
return _async_to_generator(function() {
|
|
238
|
-
var error;
|
|
239
|
-
return _ts_generator(this, function(_state) {
|
|
240
|
-
switch(_state.label){
|
|
241
|
-
case 0:
|
|
242
|
-
_state.trys.push([
|
|
243
|
-
0,
|
|
244
|
-
2,
|
|
245
|
-
,
|
|
246
|
-
3
|
|
247
|
-
]);
|
|
248
|
-
return [
|
|
249
|
-
4,
|
|
250
|
-
localForage.getItem(key)
|
|
251
|
-
];
|
|
252
|
-
case 1:
|
|
253
|
-
return [
|
|
254
|
-
2,
|
|
255
|
-
_state.sent()
|
|
256
|
-
];
|
|
257
|
-
case 2:
|
|
258
|
-
error = _state.sent();
|
|
259
|
-
console.error('❌ [Storage:get] Error getting key "'.concat(key, '":'), error);
|
|
260
|
-
return [
|
|
261
|
-
2,
|
|
262
|
-
null
|
|
263
|
-
];
|
|
264
|
-
case 3:
|
|
265
|
-
return [
|
|
266
|
-
2
|
|
267
|
-
];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
})();
|
|
271
|
-
},
|
|
272
|
-
set: function set(key, value) {
|
|
273
|
-
return _async_to_generator(function() {
|
|
274
|
-
var error;
|
|
275
|
-
return _ts_generator(this, function(_state) {
|
|
276
|
-
switch(_state.label){
|
|
277
|
-
case 0:
|
|
278
|
-
_state.trys.push([
|
|
279
|
-
0,
|
|
280
|
-
2,
|
|
281
|
-
,
|
|
282
|
-
3
|
|
283
|
-
]);
|
|
284
|
-
return [
|
|
285
|
-
4,
|
|
286
|
-
localForage.setItem(key, value)
|
|
287
|
-
];
|
|
288
|
-
case 1:
|
|
289
|
-
_state.sent();
|
|
290
|
-
return [
|
|
291
|
-
3,
|
|
292
|
-
3
|
|
293
|
-
];
|
|
294
|
-
case 2:
|
|
295
|
-
error = _state.sent();
|
|
296
|
-
console.error('❌ [Storage:set] Error setting key "'.concat(key, '":'), error);
|
|
297
|
-
return [
|
|
298
|
-
3,
|
|
299
|
-
3
|
|
300
|
-
];
|
|
301
|
-
case 3:
|
|
302
|
-
return [
|
|
303
|
-
2
|
|
304
|
-
];
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
})();
|
|
308
|
-
},
|
|
309
|
-
remove: function remove(key) {
|
|
310
|
-
return _async_to_generator(function() {
|
|
311
|
-
var error;
|
|
312
|
-
return _ts_generator(this, function(_state) {
|
|
313
|
-
switch(_state.label){
|
|
314
|
-
case 0:
|
|
315
|
-
_state.trys.push([
|
|
316
|
-
0,
|
|
317
|
-
2,
|
|
318
|
-
,
|
|
319
|
-
3
|
|
320
|
-
]);
|
|
321
|
-
return [
|
|
322
|
-
4,
|
|
323
|
-
localForage.removeItem(key)
|
|
324
|
-
];
|
|
325
|
-
case 1:
|
|
326
|
-
_state.sent();
|
|
327
|
-
return [
|
|
328
|
-
3,
|
|
329
|
-
3
|
|
330
|
-
];
|
|
331
|
-
case 2:
|
|
332
|
-
error = _state.sent();
|
|
333
|
-
console.error('❌ [Storage:remove] Error removing key "'.concat(key, '":'), error);
|
|
334
|
-
return [
|
|
335
|
-
3,
|
|
336
|
-
3
|
|
337
|
-
];
|
|
338
|
-
case 3:
|
|
339
|
-
return [
|
|
340
|
-
2
|
|
341
|
-
];
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
})();
|
|
345
|
-
},
|
|
346
|
-
keys: function keys() {
|
|
347
|
-
return _async_to_generator(function() {
|
|
348
|
-
var keys, error;
|
|
349
|
-
return _ts_generator(this, function(_state) {
|
|
350
|
-
switch(_state.label){
|
|
351
|
-
case 0:
|
|
352
|
-
_state.trys.push([
|
|
353
|
-
0,
|
|
354
|
-
2,
|
|
355
|
-
,
|
|
356
|
-
3
|
|
357
|
-
]);
|
|
358
|
-
return [
|
|
359
|
-
4,
|
|
360
|
-
localForage.keys()
|
|
361
|
-
];
|
|
362
|
-
case 1:
|
|
363
|
-
keys = _state.sent();
|
|
364
|
-
return [
|
|
365
|
-
2,
|
|
366
|
-
keys !== null && keys !== void 0 ? keys : []
|
|
367
|
-
];
|
|
368
|
-
case 2:
|
|
369
|
-
error = _state.sent();
|
|
370
|
-
console.error("❌ [Storage:keys] Error getting keys:", error);
|
|
371
|
-
return [
|
|
372
|
-
2,
|
|
373
|
-
[]
|
|
374
|
-
];
|
|
375
|
-
case 3:
|
|
376
|
-
return [
|
|
377
|
-
2
|
|
378
|
-
];
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
})();
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
// src/react/storage.tsx
|
|
385
|
-
function useStorage(key, initialValue) {
|
|
386
|
-
var serializer2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : serializer;
|
|
387
|
-
var _useState = _sliced_to_array(useState(initialValue), 2), value = _useState[0], setValue = _useState[1];
|
|
388
|
-
var _useState1 = _sliced_to_array(useState(false), 2), isLoaded = _useState1[0], setIsLoaded = _useState1[1];
|
|
389
|
-
useEffect(function() {
|
|
390
|
-
var isMounted = true;
|
|
391
|
-
var loadValue = /*#__PURE__*/ function() {
|
|
392
|
-
var _ref = _async_to_generator(function() {
|
|
393
|
-
var valueFound, parsedValue, serialized, error;
|
|
394
|
-
return _ts_generator(this, function(_state) {
|
|
395
|
-
switch(_state.label){
|
|
396
|
-
case 0:
|
|
397
|
-
_state.trys.push([
|
|
398
|
-
0,
|
|
399
|
-
6,
|
|
400
|
-
7,
|
|
401
|
-
8
|
|
402
|
-
]);
|
|
403
|
-
return [
|
|
404
|
-
4,
|
|
405
|
-
storageClient.get(key)
|
|
406
|
-
];
|
|
407
|
-
case 1:
|
|
408
|
-
valueFound = _state.sent();
|
|
409
|
-
if (!isMounted) return [
|
|
410
|
-
3,
|
|
411
|
-
5
|
|
412
|
-
];
|
|
413
|
-
if (!(valueFound !== null)) return [
|
|
414
|
-
3,
|
|
415
|
-
2
|
|
416
|
-
];
|
|
417
|
-
parsedValue = serializer2.deserialize(valueFound);
|
|
418
|
-
setValue(parsedValue);
|
|
419
|
-
return [
|
|
420
|
-
3,
|
|
421
|
-
5
|
|
422
|
-
];
|
|
423
|
-
case 2:
|
|
424
|
-
if (!(initialValue !== void 0)) return [
|
|
425
|
-
3,
|
|
426
|
-
4
|
|
427
|
-
];
|
|
428
|
-
serialized = serializer2.serialize(initialValue);
|
|
429
|
-
return [
|
|
430
|
-
4,
|
|
431
|
-
storageClient.set(key, serialized)
|
|
432
|
-
];
|
|
433
|
-
case 3:
|
|
434
|
-
_state.sent();
|
|
435
|
-
setValue(initialValue);
|
|
436
|
-
return [
|
|
437
|
-
3,
|
|
438
|
-
5
|
|
439
|
-
];
|
|
440
|
-
case 4:
|
|
441
|
-
setValue(void 0);
|
|
442
|
-
_state.label = 5;
|
|
443
|
-
case 5:
|
|
444
|
-
return [
|
|
445
|
-
3,
|
|
446
|
-
8
|
|
447
|
-
];
|
|
448
|
-
case 6:
|
|
449
|
-
error = _state.sent();
|
|
450
|
-
console.error('Error loading value for key "'.concat(key, '":'), error);
|
|
451
|
-
if (isMounted) {
|
|
452
|
-
setValue(initialValue);
|
|
453
|
-
}
|
|
454
|
-
return [
|
|
455
|
-
3,
|
|
456
|
-
8
|
|
457
|
-
];
|
|
458
|
-
case 7:
|
|
459
|
-
if (isMounted) setIsLoaded(true);
|
|
460
|
-
return [
|
|
461
|
-
7
|
|
462
|
-
];
|
|
463
|
-
case 8:
|
|
464
|
-
return [
|
|
465
|
-
2
|
|
466
|
-
];
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
|
-
return function loadValue() {
|
|
471
|
-
return _ref.apply(this, arguments);
|
|
472
|
-
};
|
|
473
|
-
}();
|
|
474
|
-
loadValue();
|
|
475
|
-
return function() {
|
|
476
|
-
isMounted = false;
|
|
477
|
-
setIsLoaded(false);
|
|
478
|
-
};
|
|
479
|
-
}, [
|
|
480
|
-
key,
|
|
481
|
-
initialValue,
|
|
482
|
-
serializer2
|
|
483
|
-
]);
|
|
484
|
-
useEffect(function() {
|
|
485
|
-
if (!isLoaded) return;
|
|
486
|
-
var saveValue = /*#__PURE__*/ function() {
|
|
487
|
-
var _ref = _async_to_generator(function() {
|
|
488
|
-
var serialized, error;
|
|
489
|
-
return _ts_generator(this, function(_state) {
|
|
490
|
-
switch(_state.label){
|
|
491
|
-
case 0:
|
|
492
|
-
_state.trys.push([
|
|
493
|
-
0,
|
|
494
|
-
3,
|
|
495
|
-
,
|
|
496
|
-
4
|
|
497
|
-
]);
|
|
498
|
-
if (!(value !== void 0)) return [
|
|
499
|
-
3,
|
|
500
|
-
2
|
|
501
|
-
];
|
|
502
|
-
serialized = serializer2.serialize(value);
|
|
503
|
-
return [
|
|
504
|
-
4,
|
|
505
|
-
storageClient.set(key, serialized)
|
|
506
|
-
];
|
|
507
|
-
case 1:
|
|
508
|
-
_state.sent();
|
|
509
|
-
_state.label = 2;
|
|
510
|
-
case 2:
|
|
511
|
-
return [
|
|
512
|
-
3,
|
|
513
|
-
4
|
|
514
|
-
];
|
|
515
|
-
case 3:
|
|
516
|
-
error = _state.sent();
|
|
517
|
-
console.error('Error saving value for key "'.concat(key, '":'), error);
|
|
518
|
-
return [
|
|
519
|
-
3,
|
|
520
|
-
4
|
|
521
|
-
];
|
|
522
|
-
case 4:
|
|
523
|
-
return [
|
|
524
|
-
2
|
|
525
|
-
];
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
});
|
|
529
|
-
return function saveValue() {
|
|
530
|
-
return _ref.apply(this, arguments);
|
|
531
|
-
};
|
|
532
|
-
}();
|
|
533
|
-
saveValue();
|
|
534
|
-
}, [
|
|
535
|
-
value,
|
|
536
|
-
key,
|
|
537
|
-
serializer2,
|
|
538
|
-
isLoaded
|
|
539
|
-
]);
|
|
540
|
-
var set = useCallback(function(newValue) {
|
|
541
|
-
setValue(function(prev) {
|
|
542
|
-
return typeof newValue === "function" ? newValue(prev) : newValue;
|
|
543
|
-
});
|
|
544
|
-
}, []);
|
|
545
|
-
var remove = useCallback(/*#__PURE__*/ _async_to_generator(function() {
|
|
546
|
-
var error;
|
|
547
|
-
return _ts_generator(this, function(_state) {
|
|
548
|
-
switch(_state.label){
|
|
549
|
-
case 0:
|
|
550
|
-
_state.trys.push([
|
|
551
|
-
0,
|
|
552
|
-
2,
|
|
553
|
-
,
|
|
554
|
-
3
|
|
555
|
-
]);
|
|
556
|
-
return [
|
|
557
|
-
4,
|
|
558
|
-
storageClient.remove(key)
|
|
559
|
-
];
|
|
560
|
-
case 1:
|
|
561
|
-
_state.sent();
|
|
562
|
-
setValue(void 0);
|
|
563
|
-
return [
|
|
564
|
-
3,
|
|
565
|
-
3
|
|
566
|
-
];
|
|
567
|
-
case 2:
|
|
568
|
-
error = _state.sent();
|
|
569
|
-
console.error('Error removing key "'.concat(key, '":'), error);
|
|
570
|
-
return [
|
|
571
|
-
3,
|
|
572
|
-
3
|
|
573
|
-
];
|
|
574
|
-
case 3:
|
|
575
|
-
return [
|
|
576
|
-
2
|
|
577
|
-
];
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
}), [
|
|
581
|
-
key
|
|
582
|
-
]);
|
|
583
|
-
return {
|
|
584
|
-
value: value,
|
|
585
|
-
set: set,
|
|
586
|
-
remove: remove
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
// src/react/next-intl.tsx
|
|
590
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
591
|
-
var NextIntlContext = createContext(void 0);
|
|
592
|
-
function useNextIntl() {
|
|
593
|
-
var context = use(NextIntlContext);
|
|
594
|
-
if (!context) {
|
|
595
|
-
throw new Error("useNextIntl must be used within a NextIntlProvider");
|
|
596
|
-
}
|
|
597
|
-
return context;
|
|
598
|
-
}
|
|
599
|
-
var useTranslateNextIntl = useTranslations;
|
|
600
|
-
function withNextIntl(Component) {
|
|
601
|
-
var PageWithI18n = function(props) {
|
|
602
|
-
var _languages_find;
|
|
603
|
-
var currentLanguage = useNextIntl().currentLanguage;
|
|
604
|
-
var messages = props.messages, languages = props.languages;
|
|
605
|
-
var defaultLang = "en";
|
|
606
|
-
var defaultMessages = messages[(currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang];
|
|
607
|
-
var timeZone = (_languages_find = languages.find(function(lang) {
|
|
608
|
-
return lang.value === (currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value);
|
|
609
|
-
})) === null || _languages_find === void 0 ? void 0 : _languages_find.timezone;
|
|
610
|
-
if (!messages) {
|
|
611
|
-
console.warn("Missing messages for language: ".concat((currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang));
|
|
612
|
-
return null;
|
|
613
|
-
}
|
|
614
|
-
return /* @__PURE__ */ jsx(NextIntlClientProvider, {
|
|
615
|
-
locale: (currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang,
|
|
616
|
-
messages: defaultMessages,
|
|
617
|
-
timeZone: timeZone,
|
|
618
|
-
children: /* @__PURE__ */ jsx(Component, _object_spread({}, props))
|
|
619
|
-
});
|
|
620
|
-
};
|
|
621
|
-
PageWithI18n.displayName = "withNextIntl(".concat(Component.displayName || Component.name || "Component", ")");
|
|
622
|
-
return PageWithI18n;
|
|
623
|
-
}
|
|
624
|
-
function LanguageWrapperBase(param) {
|
|
625
|
-
var children = param.children;
|
|
626
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
627
|
-
children: children
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
var LanguageWrapper = withNextIntl(LanguageWrapperBase);
|
|
631
|
-
function NextIntlProvider(param) {
|
|
632
|
-
var children = param.children, languages = param.languages, messages = param.messages;
|
|
633
|
-
var _languages_;
|
|
634
|
-
var _useStorage = useStorage("lang", (_languages_ = languages === null || languages === void 0 ? void 0 : languages[0]) !== null && _languages_ !== void 0 ? _languages_ : {}), value = _useStorage.value, set = _useStorage.set;
|
|
635
|
-
var contextValue = useMemo(function() {
|
|
636
|
-
return {
|
|
637
|
-
languages: languages,
|
|
638
|
-
currentLanguage: value,
|
|
639
|
-
setCurrentLanguage: set
|
|
640
|
-
};
|
|
641
|
-
}, [
|
|
642
|
-
languages,
|
|
643
|
-
set,
|
|
644
|
-
value
|
|
645
|
-
]);
|
|
646
|
-
return /* @__PURE__ */ jsx(NextIntlContext, {
|
|
647
|
-
value: contextValue,
|
|
648
|
-
children: /* @__PURE__ */ jsx(LanguageWrapper, {
|
|
649
|
-
languages: languages,
|
|
650
|
-
messages: messages,
|
|
651
|
-
children: children
|
|
652
|
-
})
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
export { NextIntlContext, NextIntlProvider, useNextIntl, useTranslateNextIntl, withNextIntl };
|
|
1
|
+
function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(e,r,t,n,a,u,o){try{var i=e[u](o);var s=i.value}catch(e){t(e);return}if(i.done){r(s)}else{Promise.resolve(s).then(n,a)}}function n(e){return function(){var r=this,n=arguments;return new Promise(function(a,u){var o=e.apply(r,n);function i(e){t(o,a,u,i,s,"next",e)}function s(e){t(o,a,u,i,s,"throw",e)}i(undefined)})}}function a(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function u(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function o(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var a=true;var u=false;var o,i;try{for(t=t.call(e);!(a=(o=t.next()).done);a=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){u=true;i=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(u)throw i}}return n}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}n.forEach(function(r){a(e,r,t[r])})}return e}function l(e,t){return r(e)||o(e,t)||c(e,t)||i()}function c(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}function f(e,r){var t,n,a,u,o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]};return u={next:i(0),"throw":i(1),"return":i(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function i(e){return function(r){return s([e,r])}}function s(u){if(t)throw new TypeError("Generator is already executing.");while(o)try{if(t=1,n&&(a=u[0]&2?n["return"]:u[0]?n["throw"]||((a=n["return"])&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;if(n=0,a)u=[u[0]&2,a.value];switch(u[0]){case 0:case 1:a=u;break;case 4:o.label++;return{value:u[1],done:false};case 5:o.label++;n=u[1];u=[0];continue;case 7:u=o.ops.pop();o.trys.pop();continue;default:if(!(a=o.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){o=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){o.label=u[1];break}if(u[0]===6&&o.label<a[1]){o.label=a[1];a=u;break}if(a&&o.label<a[2]){o.label=a[2];o.ops.push(u);break}if(a[2])o.ops.pop();o.trys.pop();continue}u=r.call(e,o)}catch(e){u=[6,e];n=0}finally{t=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}import{NextIntlClientProvider as v,useTranslations as y}from"next-intl";import{createContext as h,use as g,useMemo as d}from"react";import{useCallback as m,useEffect as p,useState as b}from"react";var w={serialize:function(e){return JSON.stringify(e,function(e,r){return u(r,Date)?{__type:"Date",value:r.toISOString()}:r})},deserialize:function(e){return JSON.parse(e,function(e,r){return(r===null||r===void 0?void 0:r.__type)==="Date"?new Date(r.value):r})}};import S from"localforage";var x={get:function e(e){return n(function(){var r;return f(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,S.getItem(e)];case 1:return[2,t.sent()];case 2:r=t.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),r),null)];case 3:return[2]}})})()},set:function e(e,r){return n(function(){var t;return f(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,S.setItem(e,r)];case 1:n.sent();return[3,3];case 2:t=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},remove:function e(e){return n(function(){var r;return f(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,S.removeItem(e)];case 1:t.sent();return[3,3];case 2:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},keys:function e(){return n(function(){var e,r;return f(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,S.keys()];case 1:return[2,(e=t.sent())!==null&&e!==void 0?e:[]];case 2:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 3:return[2]}})})()}};function I(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:w;var a=l(b(r),2),u=a[0],o=a[1],i=l(b(!1),2),s=i[0],c=i[1];p(function(){var a=!0;return n(function(){var n,u,i,s;return f(this,function(l){switch(l.label){case 0:l.trys.push([0,6,7,8]);return[4,x.get(e)];case 1:n=l.sent();if(!a)return[3,5];if(!(n!==null))return[3,2];u=t.deserialize(n);o(u);return[3,5];case 2:if(!(r!==void 0))return[3,4];i=t.serialize(r);return[4,x.set(e,i)];case 3:l.sent(),o(r);return[3,5];case 4:o(void 0);l.label=5;case 5:return[3,8];case 6:s=l.sent();console.error('Error loading value for key "'.concat(e,'":'),s),a&&o(r);return[3,8];case 7:a&&c(!0);return[7];case 8:return[2]}})})(),function(){a=!1,c(!1)}},[e,r,t]),p(function(){if(!s)return;n(function(){var r,n;return f(this,function(a){switch(a.label){case 0:a.trys.push([0,3,,4]);if(!(u!==void 0))return[3,2];r=t.serialize(u);return[4,x.set(e,r)];case 1:a.sent();a.label=2;case 2:return[3,4];case 3:n=a.sent();console.error('Error saving value for key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},[u,e,t,s]);var v=m(function(e){o(function(r){return typeof e=="function"?e(r):e})},[]),y=m(/*#__PURE__*/n(function(){var r;return f(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,x.remove(e)];case 1:t.sent(),o(void 0);return[3,3];case 2:r=t.sent();console.error('Error removing key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})}),[e]);return{value:u,set:v,remove:y}}import{Fragment as k,jsx as E}from"react/jsx-runtime";var N=h(void 0);function O(){var e=g(N);if(!e)throw new Error("useNextIntl must be used within a NextIntlProvider");return e}var P=y;function j(e){var r=function(r){var t;var n=O(),a=n.currentLanguage,u=r.messages,o=r.languages,i="en",l=u[(a===null||a===void 0?void 0:a.value)||i],c=(t=o.find(function(e){return e.value===(a===null||a===void 0?void 0:a.value)}))===null||t===void 0?void 0:t.timezone;return u?E(v,{locale:(a===null||a===void 0?void 0:a.value)||i,messages:l,timeZone:c,children:E(e,s({},r))}):(console.warn("Missing messages for language: ".concat((a===null||a===void 0?void 0:a.value)||i)),null)};return r.displayName="withNextIntl(".concat(e.displayName||e.name||"Component",")"),r}function _(e){var r=e.children;return E(k,{children:r})}var C=j(_);function z(e){var r=e.children,t=e.languages,n=e.messages;var a;var u=I("lang",(a=t===null||t===void 0?void 0:t[0])!==null&&a!==void 0?a:{}),o=u.value,i=u.set,s=d(function(){return{languages:t,currentLanguage:o,setCurrentLanguage:i}},[t,i,o]);return E(N,{value:s,children:E(C,{languages:t,messages:n,children:r})})}export{N as NextIntlContext,z as NextIntlProvider,O as useNextIntl,P as useTranslateNextIntl,j as withNextIntl};
|