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