gemi 0.4.44 → 0.4.46

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 (115) hide show
  1. package/dist/app/App.d.ts.map +1 -1
  2. package/dist/app/index.js +19 -19
  3. package/dist/chunk-00e9dad0734d9761.js +1 -1
  4. package/dist/chunk-00ecc27f03e2e84a.js +2 -0
  5. package/dist/chunk-03c8e645c994d40a.js +1 -1
  6. package/dist/chunk-08e9ab1091d7383e.js +3 -0
  7. package/dist/chunk-0db33ac43bd1d504.js +2 -0
  8. package/dist/chunk-107dbe753ed86605.js +2 -0
  9. package/dist/chunk-132c71db605759c9.js +2 -0
  10. package/dist/chunk-14d5491e97673c7d.js +2 -0
  11. package/dist/chunk-1874b66d572fb0db.js +6 -0
  12. package/dist/chunk-1900e90c372bb1d6.js +1 -1
  13. package/dist/chunk-1d2c062034e3ed2d.js +9 -0
  14. package/dist/chunk-2665dffd37ead1d9.js +2 -0
  15. package/dist/chunk-2a328e3beda74e4f.js +2 -0
  16. package/dist/chunk-3bedef94ef8dba4a.js +2 -0
  17. package/dist/chunk-3cbc1c9cdc091b43.js +2 -0
  18. package/dist/chunk-4cc2463d985f6882.js +9 -0
  19. package/dist/chunk-4d80485e7efb826f.js +2 -0
  20. package/dist/chunk-4e5485d3cfe9dc4e.js +2 -0
  21. package/dist/chunk-515c26d532207095.js +2 -0
  22. package/dist/chunk-55f76d4f6116f296.js +9 -0
  23. package/dist/chunk-590bd43a75f48606.js +18 -0
  24. package/dist/chunk-5a75eae6c32c2ba3.js +2 -0
  25. package/dist/chunk-5d51afe60efaf99e.js +2 -0
  26. package/dist/chunk-5d86d49d66db1c22.js +2 -0
  27. package/dist/chunk-5e13846c554dc272.js +2 -0
  28. package/dist/chunk-5fd67245740e3908.js +1 -1
  29. package/dist/chunk-63c5605bcce508ea.js +1 -0
  30. package/dist/chunk-64c89cee4d4bd9a9.js +2 -0
  31. package/dist/chunk-65626c3d72d4e071.js +2 -0
  32. package/dist/chunk-69ff5047661fe699.js +2 -0
  33. package/dist/chunk-6c461d293fa213f1.js +2 -0
  34. package/dist/chunk-6e06660ab4e9d4da.js +6 -0
  35. package/dist/chunk-7195a8718fcd8215.js +1 -0
  36. package/dist/chunk-73fb3bb4d001bb2e.js +1 -0
  37. package/dist/chunk-782dde0748025b5a.js +2 -0
  38. package/dist/chunk-7de7f34d46c76019.js +18 -0
  39. package/dist/chunk-80b17f9853d76e98.js +2 -0
  40. package/dist/chunk-81f5123a24c19089.js +2 -0
  41. package/dist/chunk-827d2c67c03d1a52.js +2 -0
  42. package/dist/chunk-8581aa9e876d46fb.js +2 -0
  43. package/dist/chunk-869d80d2e475b938.js +3 -0
  44. package/dist/chunk-895d9b1ef7a65211.js +1 -1
  45. package/dist/chunk-8c2b349a7198788f.js +6 -0
  46. package/dist/chunk-90c5196ff1f827a8.js +2 -0
  47. package/dist/chunk-934ebff128f86ef1.js +1 -0
  48. package/dist/chunk-98126e4b5bd19831.js +2 -0
  49. package/dist/chunk-99ba9dfd7c11383b.js +18 -0
  50. package/dist/chunk-a63e13c410e92923.js +2 -0
  51. package/dist/chunk-a7f3e9d5b7cf7c42.js +2 -0
  52. package/dist/chunk-a88c3919c74b7877.js +18 -0
  53. package/dist/chunk-acd4530b2ff92aff.js +18 -0
  54. package/dist/chunk-ae50ef54d7de9179.js +2 -0
  55. package/dist/chunk-ae7b1bdf00266d88.js +2 -0
  56. package/dist/chunk-af6b79a6ce7388ee.js +18 -0
  57. package/dist/chunk-b0cc82fa84d5362d.js +1 -1
  58. package/dist/chunk-b2bc43f60314d1a9.js +2 -0
  59. package/dist/chunk-b8d3d76e1dd9affe.js +2 -0
  60. package/dist/chunk-b9f4c1fce7152fc8.js +9 -0
  61. package/dist/chunk-c3e4a396dc7a5fe7.js +2 -0
  62. package/dist/chunk-c609d06153ed09ce.js +1 -1
  63. package/dist/chunk-c882d0c175c22c17.js +2 -0
  64. package/dist/chunk-ccfd101ce72e80bf.js +1 -0
  65. package/dist/chunk-d0806df6defd9dce.js +1 -1
  66. package/dist/chunk-d535b1e3078465f8.js +2 -0
  67. package/dist/chunk-d54843c1d8516c75.js +2 -0
  68. package/dist/chunk-d665d3ee2a62d48b.js +2 -0
  69. package/dist/chunk-d9762bab5df03532.js +2 -0
  70. package/dist/chunk-e1a08bb52ee7ea09.js +1 -1
  71. package/dist/chunk-e3e996b3821027e1.js +2 -0
  72. package/dist/chunk-e64d5a7b7e0fa2c5.js +6 -0
  73. package/dist/chunk-f077321ef55ea627.js +1 -0
  74. package/dist/chunk-f32726d374c6bee5.js +1 -0
  75. package/dist/chunk-f5200f44395bf49d.js +3 -0
  76. package/dist/chunk-f900b5868b14827e.js +2 -0
  77. package/dist/chunk-f9a17b871b527bff.js +2 -0
  78. package/dist/chunk-feaaa37d30cd1e9b.js +2 -0
  79. package/dist/client/ClientRouter.d.ts.map +1 -1
  80. package/dist/client/ClientRouterContext.d.ts +4 -0
  81. package/dist/client/ClientRouterContext.d.ts.map +1 -1
  82. package/dist/client/Link.d.ts +2 -1
  83. package/dist/client/Link.d.ts.map +1 -1
  84. package/dist/client/ProgressManager.d.ts +16 -0
  85. package/dist/client/ProgressManager.d.ts.map +1 -0
  86. package/dist/client/i18n/I18nContext.d.ts +1 -1
  87. package/dist/client/i18n/I18nContext.d.ts.map +1 -1
  88. package/dist/client/i18n/useScopedTranslator.d.ts +3 -6
  89. package/dist/client/i18n/useScopedTranslator.d.ts.map +1 -1
  90. package/dist/client/index.d.ts +3 -1
  91. package/dist/client/index.d.ts.map +1 -1
  92. package/dist/client/index.js +205 -31
  93. package/dist/client/useIsNavigationPending.d.ts +2 -0
  94. package/dist/client/useIsNavigationPending.d.ts.map +1 -0
  95. package/dist/client/useNavigate.d.ts.map +1 -1
  96. package/dist/client/useNavigationProgress.d.ts +2 -0
  97. package/dist/client/useNavigationProgress.d.ts.map +1 -0
  98. package/dist/facades/I18n.d.ts +4 -2
  99. package/dist/facades/I18n.d.ts.map +1 -1
  100. package/dist/facades/index.js +1 -1
  101. package/dist/http/HttpRequest.d.ts +4 -1
  102. package/dist/http/HttpRequest.d.ts.map +1 -1
  103. package/dist/http/I18nServiceContainer.d.ts +1 -0
  104. package/dist/http/I18nServiceContainer.d.ts.map +1 -1
  105. package/dist/http/index.js +1 -1
  106. package/dist/kernel/index.js +2 -2
  107. package/dist/server/index.js +1 -1
  108. package/dist/storage/index.js +4 -4
  109. package/dist/utils/applyTranslationParams.d.ts +2 -0
  110. package/dist/utils/applyTranslationParams.d.ts.map +1 -0
  111. package/dist/utils/sleep.d.ts +2 -0
  112. package/dist/utils/sleep.d.ts.map +1 -0
  113. package/dist/utils/type.d.ts +3 -0
  114. package/dist/utils/type.d.ts.map +1 -1
  115. package/package.json +1 -1
@@ -1,8 +1,5 @@
1
1
  import type { I18nDictionary } from "../rpc";
2
- import type { IsEmptyObject } from "../../utils/type";
3
- type ParseTranslationParams<T extends string> = T extends `${infer _Start}{${infer Param}}${infer Rest}` ? {
4
- [K in Param]: string;
5
- } & ParseTranslationParams<Rest> : {};
6
- export declare function useScopedTranslator<T extends keyof I18nDictionary>(scope: T): <K extends keyof I18nDictionary[T], U extends Record<string, string> = ParseTranslationParams<I18nDictionary[T][K]["en"]>>(key: K, ...args: IsEmptyObject<U> extends true ? [] : [params: U]) => string | K;
7
- export {};
2
+ import type { IsEmptyObject, ParseTranslationParams } from "../../utils/type";
3
+ export declare function useScopedTranslator<T extends keyof I18nDictionary>(scope: T extends "server" ? never : T): <K extends keyof I18nDictionary[T], U extends Record<string, string> = ParseTranslationParams<I18nDictionary[T][K]["default"]>>(key: K, ...args: IsEmptyObject<U> extends true ? [] : [params: U]) => string | K;
4
+ export declare function useTranslator(): <K extends string | number | symbol, U extends Record<string, string> = ParseTranslationParams<never[K]["default"]>>(key: K, ...args: IsEmptyObject<U> extends true ? [] : [params: U]) => string | K;
8
5
  //# sourceMappingURL=useScopedTranslator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScopedTranslator.d.ts","sourceRoot":"","sources":["../../../client/i18n/useScopedTranslator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAItD,KAAK,sBAAsB,CAAC,CAAC,SAAS,MAAM,IAC1C,CAAC,SAAS,GAAG,MAAM,MAAM,IAAI,MAAM,KAAK,IAAI,MAAM,IAAI,EAAE,GACpD;KAAG,CAAC,IAAI,KAAK,GAAG,MAAM;CAAE,GAAG,sBAAsB,CAAC,IAAI,CAAC,GACvD,EAAE,CAAC;AAET,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,cAAc,EAAE,KAAK,EAAE,CAAC,IAIxE,CAAC,SAAS,MAAM,cAAc,CAAC,CAAC,CAAC,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,4DAI3B,CAAC,WACG,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,gBAW5D"}
1
+ {"version":3,"file":"useScopedTranslator.d.ts","sourceRoot":"","sources":["../../../client/i18n/useScopedTranslator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAK9E,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,cAAc,EAChE,KAAK,EAAE,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC,IAKnC,CAAC,SAAS,MAAM,cAAc,CAAC,CAAC,CAAC,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,iEAI3B,CAAC,WACG,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,gBAW5D;AAED,wBAAgB,aAAa,KAnBzB,CAAC,mCACD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,iIAqBnC"}
@@ -4,6 +4,8 @@ export { Form, FormError, useMutationStatus, ValidationErrors, FormField, } from
4
4
  export { useLocation, useParams } from "./ClientRouterContext";
5
5
  export { useSearchParams } from "./useSearchParams";
6
6
  export { useRoute } from "./useRoute";
7
+ export { useIsNavigationPending } from "./useIsNavigationPending";
8
+ export { useNavigationProgress } from "./useNavigationProgress";
7
9
  export { useNavigate } from "./useNavigate";
8
10
  export { Link } from "./Link";
9
11
  export { init } from "./init";
@@ -17,6 +19,6 @@ export { useSignUp } from "./auth/useSignUp";
17
19
  export { useSignOut } from "./auth/useSignOut";
18
20
  export { useResetPassword } from "./auth/useResetPassword";
19
21
  export { useUser } from "./auth/useUser";
20
- export { useScopedTranslator } from "./i18n/useScopedTranslator";
22
+ export { useScopedTranslator, useTranslator } from "./i18n/useScopedTranslator";
21
23
  export { useLocale } from "./i18n/useLocale";
22
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,IAAI,EACJ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAA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,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
@@ -33,7 +33,7 @@ class Subject {
33
33
  return this.value;
34
34
  }
35
35
  }
36
- function applyParams$2(url, params) {
36
+ function applyParams$1(url, params) {
37
37
  return url.replace(/:([^/]+)/g, (_2, key) => {
38
38
  const isOptional = key.endsWith("?");
39
39
  const paramName = isOptional ? key.slice(0, -1) : key;
@@ -93,7 +93,7 @@ class Resource {
93
93
  const { query, params } = options;
94
94
  const url = key.split("GET:")[1];
95
95
  const searchParams = new URLSearchParams(query);
96
- const finalUrl = [applyParams$2(url, params), searchParams.toString()].filter((s) => s.length > 0).join("?");
96
+ const finalUrl = [applyParams$1(url, params), searchParams.toString()].filter((s) => s.length > 0).join("?");
97
97
  const { data, error } = this.state.getValue();
98
98
  this.state.next({
99
99
  data,
@@ -187,7 +187,7 @@ function useQuery(url, ...args) {
187
187
  mutate: resource.mutate.bind(resource)
188
188
  };
189
189
  }
190
- function applyParams$1(url, params = {}) {
190
+ function applyParams(url, params = {}) {
191
191
  let out = url;
192
192
  for (const [key, value] of Object.entries(params)) {
193
193
  out = out.replace(`:${key}?`, value).replace(`:${key}`, value);
@@ -222,7 +222,7 @@ function useMutation(url, ...args) {
222
222
  const params = "params" in inputs ? inputs.params : {};
223
223
  const [method] = String(url).split(":");
224
224
  const finalUrl = [
225
- applyParams$1(String(url).replace(`${method}:`, ""), params),
225
+ applyParams(String(url).replace(`${method}:`, ""), params),
226
226
  new URLSearchParams(query).toString()
227
227
  ].join("?");
228
228
  let body = null;
@@ -1306,6 +1306,104 @@ var me = (_b = class {
1306
1306
  if (!globalThis.URLPattern) {
1307
1307
  globalThis.URLPattern = me;
1308
1308
  }
1309
+ function sleep(time) {
1310
+ return new Promise((resolve) => setTimeout(resolve, time));
1311
+ }
1312
+ class ProgressManager {
1313
+ constructor(subject) {
1314
+ __publicField(this, "state", new Subject(100));
1315
+ __publicField(this, "unsubscribe");
1316
+ __publicField(this, "timer");
1317
+ __publicField(this, "tick", 0);
1318
+ __publicField(this, "isTicking", false);
1319
+ this.unsubscribe = subject.subscribe((state) => {
1320
+ if (state) {
1321
+ this.start();
1322
+ } else {
1323
+ this.end();
1324
+ }
1325
+ });
1326
+ }
1327
+ getNextIncrement() {
1328
+ const current = this.state.getValue();
1329
+ if (current === 100) {
1330
+ return Math.ceil(Math.random() * 10);
1331
+ }
1332
+ if (current <= 20) {
1333
+ if (Math.ceil(Math.random() * 100) > 80) {
1334
+ return current;
1335
+ }
1336
+ return current + Math.ceil(Math.random() * 5) + 1;
1337
+ }
1338
+ if (current <= 50) {
1339
+ if (Math.ceil(Math.random() * 100) > 50) {
1340
+ return current;
1341
+ }
1342
+ return Math.min(current + Math.ceil(Math.random() * 10), 70);
1343
+ }
1344
+ if (current <= 70) {
1345
+ if (Math.ceil(Math.random() * 100) > 60) {
1346
+ return current;
1347
+ }
1348
+ return Math.min(current + Math.ceil(Math.random() * 3), 80);
1349
+ }
1350
+ if (current <= 80) {
1351
+ return Math.min(current + Math.ceil(Math.random() * 1), 90);
1352
+ }
1353
+ if (current <= 90) {
1354
+ const x2 = Math.ceil(Math.random() * 100) > 50 ? 0 : 1;
1355
+ return Math.min(current + x2, 94);
1356
+ }
1357
+ if (current <= 94) {
1358
+ const x2 = Math.ceil(Math.random() * 100) > 20 ? 0 : 1;
1359
+ return Math.min(current + x2, 99);
1360
+ }
1361
+ }
1362
+ getNextInterval() {
1363
+ if (this.tick === 0) {
1364
+ this.tick = 1;
1365
+ return 200;
1366
+ }
1367
+ const current = this.state.getValue();
1368
+ if (current >= 88) {
1369
+ return 400;
1370
+ }
1371
+ if (current >= 94) {
1372
+ return 1e3;
1373
+ }
1374
+ if (current >= 98) {
1375
+ return 2e3;
1376
+ }
1377
+ return 100;
1378
+ }
1379
+ async nextTick() {
1380
+ if (!this.isTicking) {
1381
+ return;
1382
+ }
1383
+ await sleep(this.getNextInterval());
1384
+ if (!this.isTicking) {
1385
+ return;
1386
+ }
1387
+ const increment = this.getNextIncrement();
1388
+ this.state.next(Math.min(increment, 96));
1389
+ await this.nextTick();
1390
+ }
1391
+ start() {
1392
+ this.isTicking = true;
1393
+ this.nextTick();
1394
+ }
1395
+ end() {
1396
+ this.state.next(99);
1397
+ this.isTicking = false;
1398
+ this.tick = 0;
1399
+ setTimeout(() => {
1400
+ this.state.next(100);
1401
+ }, 200);
1402
+ }
1403
+ destroy() {
1404
+ this.unsubscribe();
1405
+ }
1406
+ }
1309
1407
  const ClientRouterContext = createContext(
1310
1408
  {}
1311
1409
  );
@@ -1321,6 +1419,11 @@ const ClientRouterProvider = (props) => {
1321
1419
  searchParams
1322
1420
  } = props;
1323
1421
  const [parameters, setParameters] = useState(params);
1422
+ const navigationAbortControllerRef = useRef(new AbortController());
1423
+ const [isNavigatingSubject] = useState(() => {
1424
+ return new Subject(false);
1425
+ });
1426
+ const [progressManager] = useState(new ProgressManager(isNavigatingSubject));
1324
1427
  const pageDataRef = useRef(structuredClone(pageData));
1325
1428
  const scrollHistoryRef = useRef(/* @__PURE__ */ new Map());
1326
1429
  const initalViewEntries = is404 ? ["404"] : routeManifest[pathname] ?? ["404"];
@@ -1407,10 +1510,15 @@ const ClientRouterProvider = (props) => {
1407
1510
  const getPageData = (key) => {
1408
1511
  return pageDataRef.current[locationSubject.getValue().pathname][key];
1409
1512
  };
1513
+ const setNavigationAbortController = (controller) => {
1514
+ navigationAbortControllerRef.current.abort();
1515
+ navigationAbortControllerRef.current = controller;
1516
+ };
1410
1517
  return /* @__PURE__ */ jsx(
1411
1518
  ClientRouterContext.Provider,
1412
1519
  {
1413
1520
  value: {
1521
+ isNavigatingSubject,
1414
1522
  getViewPathsFromPathname,
1415
1523
  history,
1416
1524
  params: parameters,
@@ -1421,7 +1529,9 @@ const ClientRouterProvider = (props) => {
1421
1529
  viewEntriesSubject: viewEntriesSubject.current,
1422
1530
  updatePageData,
1423
1531
  getPageData,
1424
- getRoutePathnameFromHref
1532
+ getRoutePathnameFromHref,
1533
+ setNavigationAbortController,
1534
+ progressManager
1425
1535
  },
1426
1536
  children
1427
1537
  }
@@ -1504,9 +1614,15 @@ const I18nProvider = (props) => {
1504
1614
  );
1505
1615
  }
1506
1616
  };
1507
- const fetchTranslations = async (pathname, locale2) => {
1617
+ const fetchTranslations = async (pathname, locale2, signal) => {
1618
+ if (Object.keys(i18n).length === 0) {
1619
+ return;
1620
+ }
1508
1621
  const response = await fetch(
1509
- `/api/__gemi__/services/i18n/translations?scope=${pathname}&locale=${locale2 || currentLocale}`
1622
+ `/api/__gemi__/services/i18n/translations?scope=${pathname}&locale=${locale2 || currentLocale}`,
1623
+ {
1624
+ signal
1625
+ }
1510
1626
  );
1511
1627
  const translations = await response.json();
1512
1628
  updateDictionary(translations);
@@ -1530,11 +1646,15 @@ function useNavigate() {
1530
1646
  updatePageData,
1531
1647
  history,
1532
1648
  getViewPathsFromPathname,
1533
- getRoutePathnameFromHref
1649
+ getRoutePathnameFromHref,
1650
+ isNavigatingSubject,
1651
+ setNavigationAbortController
1534
1652
  } = useContext(ClientRouterContext);
1535
1653
  const { fetchTranslations } = useContext(I18nContext);
1536
1654
  function action(pushOrReplace) {
1537
1655
  return async (path, ...args) => {
1656
+ const navigationAbortController = new AbortController();
1657
+ setNavigationAbortController(navigationAbortController);
1538
1658
  const [options = {}] = args;
1539
1659
  const {
1540
1660
  search = {},
@@ -1546,9 +1666,9 @@ function useNavigate() {
1546
1666
  ...options
1547
1667
  };
1548
1668
  const urlSearchParams = new URLSearchParams(search);
1549
- const basePath = applyParams$2(path, params);
1669
+ const basePath = applyParams$1(path, params);
1550
1670
  const navigationPath = [
1551
- applyParams$2(path, params),
1671
+ applyParams$1(path, params),
1552
1672
  urlSearchParams.toString()
1553
1673
  ].join("?");
1554
1674
  const components = getViewPathsFromPathname(path);
@@ -1561,17 +1681,32 @@ function useNavigate() {
1561
1681
  return;
1562
1682
  }
1563
1683
  const routePathname = getRoutePathnameFromHref(path);
1564
- const [res] = await Promise.all([
1565
- fetch(fetchPath),
1566
- fetchTranslations(routePathname),
1567
- ...components.map((component) => window.loaders[component]())
1568
- ]);
1569
- if (res.ok) {
1570
- const { data, is404 = false } = await res.json();
1571
- updatePageData(data);
1572
- history == null ? void 0 : history[pushOrReplace](navigationPath, is404 ? { status: 404 } : {});
1573
- window.scrollTo(0, 0);
1684
+ isNavigatingSubject.next(true);
1685
+ try {
1686
+ const [res] = await Promise.all([
1687
+ fetch(fetchPath, { signal: navigationAbortController.signal }),
1688
+ fetchTranslations(
1689
+ routePathname,
1690
+ void 0,
1691
+ navigationAbortController.signal
1692
+ ),
1693
+ ...components.map(
1694
+ (component) => window.loaders[component]()
1695
+ )
1696
+ ]);
1697
+ if (res.ok) {
1698
+ const { data, is404 = false } = await res.json();
1699
+ updatePageData(data);
1700
+ history == null ? void 0 : history[pushOrReplace](
1701
+ navigationPath,
1702
+ is404 ? { status: 404 } : {}
1703
+ );
1704
+ window.scrollTo(0, 0);
1705
+ }
1706
+ } catch (err) {
1707
+ isNavigatingSubject.next(false);
1574
1708
  }
1709
+ isNavigatingSubject.next(false);
1575
1710
  };
1576
1711
  }
1577
1712
  return {
@@ -1652,6 +1787,31 @@ function useRoute() {
1652
1787
  }
1653
1788
  };
1654
1789
  }
1790
+ function useIsNavigationPending() {
1791
+ const { isNavigatingSubject } = useContext(ClientRouterContext);
1792
+ const isNavigating = useSyncExternalStore(
1793
+ isNavigatingSubject.subscribe,
1794
+ isNavigatingSubject.getValue,
1795
+ isNavigatingSubject.getValue
1796
+ );
1797
+ return isNavigating;
1798
+ }
1799
+ function useNavigationProgress() {
1800
+ const { progressManager } = useContext(ClientRouterContext);
1801
+ const [progress, setProgress] = useState(progressManager.state.getValue());
1802
+ useEffect(() => {
1803
+ const unsub = progressManager.state.subscribe((p) => setProgress(p));
1804
+ return () => {
1805
+ unsub();
1806
+ };
1807
+ }, []);
1808
+ return progress;
1809
+ }
1810
+ function normalizeSearch(search) {
1811
+ return Object.fromEntries(
1812
+ Object.entries(search).filter(([k2, v2]) => v2 === void 0 || v2 === null).map(([k2, v2]) => [k2, String(v2)])
1813
+ );
1814
+ }
1655
1815
  const Link = (props) => {
1656
1816
  const {
1657
1817
  href,
@@ -1663,13 +1823,21 @@ const Link = (props) => {
1663
1823
  } = { params: {}, ...props };
1664
1824
  const { push } = useNavigate();
1665
1825
  const { pathname } = useLocation();
1666
- const path = applyParams$2(href, params);
1826
+ const searchParams = new URLSearchParams(normalizeSearch(search));
1827
+ const path = applyParams$1(href, params);
1828
+ const _href = [path, searchParams.toString()].filter((s) => s.length > 0).join("?");
1667
1829
  return /* @__PURE__ */ jsx(
1668
1830
  "a",
1669
1831
  {
1670
1832
  "data-active": active || pathname === path,
1671
- href: path,
1833
+ href: _href,
1672
1834
  onClick: (e) => {
1835
+ if (typeof window !== "undefined") {
1836
+ if (`${window.location.pathname}${window.location.search}` === _href) {
1837
+ e.preventDefault();
1838
+ return;
1839
+ }
1840
+ }
1673
1841
  e.preventDefault();
1674
1842
  onClick == null ? void 0 : onClick(e);
1675
1843
  push(href, { search, params });
@@ -30540,6 +30708,15 @@ function useUser() {
30540
30708
  }
30541
30709
  return { user: data == null ? void 0 : data.user, loading, error };
30542
30710
  }
30711
+ function applyTranslationParams(str, params) {
30712
+ return str.replace(/{{([^}]+)}}/g, (_2, key) => {
30713
+ const value = params[key];
30714
+ if (value === void 0) {
30715
+ throw new Error(`Missing parameter: ${key}`);
30716
+ }
30717
+ return value;
30718
+ });
30719
+ }
30543
30720
  function useScopedTranslator(scope) {
30544
30721
  const { translations } = useContext(I18nContext);
30545
30722
  return (key, ...args) => {
@@ -30549,17 +30726,11 @@ function useScopedTranslator(scope) {
30549
30726
  if (!translation) {
30550
30727
  return key;
30551
30728
  }
30552
- return applyParams(translation, params);
30729
+ return applyTranslationParams(translation, params);
30553
30730
  };
30554
30731
  }
30555
- function applyParams(str, params) {
30556
- return str.replace(/{([^}]+)}/g, (_2, key) => {
30557
- const value = params[key];
30558
- if (value === void 0) {
30559
- throw new Error(`Missing parameter: ${key}`);
30560
- }
30561
- return value;
30562
- });
30732
+ function useTranslator() {
30733
+ return useScopedTranslator("global");
30563
30734
  }
30564
30735
  function useLocale() {
30565
30736
  const { changeLocale, locale, fetchTranslations } = useContext(I18nContext);
@@ -30582,11 +30753,13 @@ export {
30582
30753
  createRoot,
30583
30754
  init,
30584
30755
  useForgotPassword,
30756
+ useIsNavigationPending,
30585
30757
  useLocale,
30586
30758
  useLocation,
30587
30759
  useMutation,
30588
30760
  useMutationStatus,
30589
30761
  useNavigate,
30762
+ useNavigationProgress,
30590
30763
  useParams,
30591
30764
  useQuery,
30592
30765
  useResetPassword,
@@ -30596,5 +30769,6 @@ export {
30596
30769
  useSignIn,
30597
30770
  useSignOut,
30598
30771
  useSignUp,
30772
+ useTranslator,
30599
30773
  useUser
30600
30774
  };
@@ -0,0 +1,2 @@
1
+ export declare function useIsNavigationPending(): boolean;
2
+ //# sourceMappingURL=useIsNavigationPending.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsNavigationPending.d.ts","sourceRoot":"","sources":["../../client/useIsNavigationPending.ts"],"names":[],"mappings":"AAGA,wBAAgB,sBAAsB,YASrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigate.d.ts","sourceRoot":"","sources":["../../client/useNavigate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpD,KAAK,OAAO,CAAC,CAAC,SAAS,SAAS,IAC9B,SAAS,CAAC,CAAC,CAAC,SAAS,KAAK,GACtB;IACE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACtE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAER,wBAAgB,WAAW;WAWT,CAAC,SAAS,SAAS,QACzB,CAAC,WACE,SAAS,CAAC,CAAC,CAAC,SAAS,KAAK,GAC/B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACtB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;cAJb,CAAC,SAAS,SAAS,QACzB,CAAC,WACE,SAAS,CAAC,CAAC,CAAC,SAAS,KAAK,GAC/B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACtB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;EAwD9B"}
1
+ {"version":3,"file":"useNavigate.d.ts","sourceRoot":"","sources":["../../client/useNavigate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpD,KAAK,OAAO,CAAC,CAAC,SAAS,SAAS,IAC9B,SAAS,CAAC,CAAC,CAAC,SAAS,KAAK,GACtB;IACE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACtE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAER,wBAAgB,WAAW;WAYT,CAAC,SAAS,SAAS,QACzB,CAAC,WACE,SAAS,CAAC,CAAC,CAAC,SAAS,KAAK,GAC/B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACtB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;cAJb,CAAC,SAAS,SAAS,QACzB,CAAC,WACE,SAAS,CAAC,CAAC,CAAC,SAAS,KAAK,GAC/B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACtB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;EA6E9B"}
@@ -0,0 +1,2 @@
1
+ export declare function useNavigationProgress(): number;
2
+ //# sourceMappingURL=useNavigationProgress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNavigationProgress.d.ts","sourceRoot":"","sources":["../../client/useNavigationProgress.ts"],"names":[],"mappings":"AAGA,wBAAgB,qBAAqB,WAYpC"}
@@ -1,5 +1,7 @@
1
- import type { ViewRPC } from "../client/rpc";
1
+ import type { ViewRPC, I18nDictionary } from "../client/rpc";
2
+ import type { IsEmptyObject, ParseTranslationParams } from "../utils/type";
2
3
  export declare class I18n {
3
- static scope<T extends keyof ViewRPC>(scope: T): T;
4
+ static scope<T extends keyof ViewRPC | "global" | "server">(scope: T): T;
5
+ static translate<T extends keyof I18nDictionary["server"], U = ParseTranslationParams<I18nDictionary["server"][T]["default"]>>(key: T, ...args: IsEmptyObject<U> extends true ? [] : [params: U]): any;
4
6
  }
5
7
  //# sourceMappingURL=I18n.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"I18n.d.ts","sourceRoot":"","sources":["../../facades/I18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,qBAAa,IAAI;IACf,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,KAAK,EAAE,CAAC;CAG/C"}
1
+ {"version":3,"file":"I18n.d.ts","sourceRoot":"","sources":["../../facades/I18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI7D,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE3E,qBAAa,IAAI;IACf,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC;IAGxE,MAAM,CAAC,SAAS,CAEd,CAAC,SAAS,MAAM,cAAc,CAAC,QAAQ,CAAC,EAExC,CAAC,GAAG,sBAAsB,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAClE,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;CAYpE"}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{f as R,g as d,k as m,m as o} from"../http/index.js";import"../chunk-7ce930fe69575c87.js";class p{static async user(){const a=d.getStore(),c=a.req.cookies.get("access_token");let r=a.user;if(!r)r=(await m.getStore().authenticationServiceProvider.adapter.findSession({token:c,userAgent:a.req.headers.get("User-Agent")}))?.user,a.setUser(r);if(r)return r;return null}static async guard(a){const c=await p.user();if(!c)throw new o;try{if(!await a(c))throw new o}catch(r){throw new o}}static async guardSafe(a){const c=await p.user();if(!c)return!1;try{return await a(c)}catch(r){return!1}}}class i extends R{constructor(a){super("Redirect error");this.name="RedirectError",this.payload={api:{status:302,data:{error:"Redirect error"}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:a}}}}}class w{static to(a){throw new i(a)}}class l{static scope(a){return a}}export{w as Redirect,l as I18n,p as Auth};export{p as q};
2
+ import{f as p,g as c,k as s,m as n} from"../http/index.js";import"../chunk-7ce930fe69575c87.js";class i{static async user(){const r=c.getStore(),a=r.req.cookies.get("access_token");let t=r.user;if(!t)t=(await s.getStore().authenticationServiceProvider.adapter.findSession({token:a,userAgent:r.req.headers.get("User-Agent")}))?.user,r.setUser(t);if(t)return t;return null}static async guard(r){const a=await i.user();if(!a)throw new n;try{if(!await r(a))throw new n}catch(t){throw new n}}static async guardSafe(r){const a=await i.user();if(!a)return!1;try{return await r(a)}catch(t){return!1}}}class l extends p{constructor(r){super("Redirect error");this.name="RedirectError",this.payload={api:{status:302,data:{error:"Redirect error"}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:r}}}}}class m{static to(r){throw new l(r)}}function d(r,a){return r.replace(/{{([^}]+)}}/g,(t,o)=>{const e=a[o];if(e===void 0)throw new Error(`Missing parameter: ${o}`);return e})}class g{static scope(r){return r}static translate(r,...a){const t=s.getStore().i18nServiceContainer,o=t.detectLocale(c.getStore().req),e=t.translations.get(`${o}.server`)?.[r];if(!e)return r;return d(e,a[0])}}export{m as Redirect,g as I18n,i as Auth};export{i as q};
@@ -12,7 +12,10 @@ type BooleanType = "boolean";
12
12
  type MinLengthType = `min:${number}`;
13
13
  type MaxLengthType = `max:${number}`;
14
14
  type RequiredType = "required";
15
- type SchemaKey = StringType | NumberType | BooleanType | MinLengthType | MaxLengthType | RequiredType;
15
+ type FileType = "file";
16
+ type FileTypeType = "fileType:${string}";
17
+ type FileSizeType = "fileSize:${string}";
18
+ type SchemaKey = StringType | NumberType | BooleanType | MinLengthType | MaxLengthType | RequiredType | FileType | FileTypeType | FileSizeType;
16
19
  export type Schema<T extends Body> = Record<keyof T, Partial<Record<SchemaKey, string>>>;
17
20
  export type Body = Record<string, any>;
18
21
  export declare class HttpRequest<T extends Body = Record<string, never>, Params = Record<string, never>> {
@@ -1 +1 @@
1
- {"version":3,"file":"HttpRequest.d.ts","sourceRoot":"","sources":["../../http/HttpRequest.ts"],"names":[],"mappings":"AAIA,cAAM,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3B,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,CAAC;IAEpB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAI7B,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAInC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC;IAIhB,MAAM,IAAI,CAAC;CAGnB;AA4CD,KAAK,UAAU,GAAG,QAAQ,CAAC;AAC3B,KAAK,UAAU,GAAG,QAAQ,CAAC;AAC3B,KAAK,WAAW,GAAG,SAAS,CAAC;AAC7B,KAAK,aAAa,GAAG,OAAO,MAAM,EAAE,CAAC;AACrC,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ends ApiRouter {
16
16
  export declare class I18nServiceContainer {
17
17
  private service;
18
18
  constructor(service: I18nServiceProvider);
19
+ isEnabled: boolean;
19
20
  translations: Map<any, any>;
20
21
  supportedLocales: string[];
21
22
  routers: {
@@ -1 +1 @@
1
- {"version":3,"file":"I18nServiceContainer.d.ts","sourceRoot":"","sources":["../../http/I18nServiceContainer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,cAAM,MAAO,SAAQ,SAAS;IAC5B,MAAM;;mBAE+B,MAAM;qBAAW,MAAM;;;;;;MA6B1D;CACH;AAED,qBAAa,oBAAoB;IACnB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,mBAAmB;IAEhD,YAAY,gBAAa;IACzB,gBAAgB,EAAE,MAAM,EAAE,CAAM;IAChC,OAAO;;MAEL;IAEF,IAAI;IA0BJ,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC;IA0BvC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;CAsBlD"}
1
+ {"version":3,"file":"I18nServiceContainer.d.ts","sourceRoot":"","sources":["../../http/I18nServiceContainer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,cAAM,MAAO,SAAQ,SAAS;IAC5B,MAAM;;mBAE+B,MAAM;qBAAW,MAAM;;;;;;MA6B1D;CACH;AAED,qBAAa,oBAAoB;IACnB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,mBAAmB;IAEhD,SAAS,UAAS;IAClB,YAAY,gBAAa;IACzB,gBAAgB,EAAE,MAAM,EAAE,CAAM;IAChC,OAAO;;MAEL;IAEF,IAAI;IA6BJ,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC;IA0BvC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;CAsBlD"}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"../chunk-7ce930fe69575c87.js";class T{requests={};static kind="controller";constructor(){}}class C extends T{constructor(){super(...arguments)}}function H(e){return typeof e==="function"&&e.prototype!==void 0}var v=function(e){return H(e)};class u{e;t;r;middlewares=[];constructor(e,t,r){this.method=e;this.handler=t;this.methodName=r;this.handler=t,this.methodName=r,this.method=e}run(e){let t=e;if(v(this.handler)){const r=new this.handler,n=r[this.methodName].bind(r);return t=r.requests[this.methodName]?new r.requests[this.methodName](e.rawRequest,e.params):t,n(t)}else return this.handler(e)}middleware(e){return this.middlewares=e,this}}class K{constructor(...e){return new u(...e)}}class P{routes={};middlewares=[];middleware(e){}get(e,t){return new u("GET",e,t)}post(e,t){return new u("POST",e,t)}put(e,t){return new u("PUT",e,t)}patch(e,t){return new u("PATCH",e,t)}delete(e,t){return new u("DELETE",e,t)}resource(e){class t extends P{constructor(){super(...arguments)}routes={"/":{list:this.get(e,"list"),create:this.post(e,"create")},"/:id":{show:this.get(e,"show"),update:this.put(e,"update"),delete:this.delete(e,"delete")}}}return t}file(e,t){return new K("GET",e,t)}}class g{e;middlewares=[];handler;constructor(e,t){this.viewPath=e;if(!t)this.handler=()=>({});else if(typeof t==="function")this.handler=t;else{const[r,n]=t,s=new r,o=s[n].bind(s);this.handler=(a)=>{let i=a;return i=s.requests[n]?new s.requests[n](a.rawRequest,a.params):i,o(a)}}}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class O{e;children;middlewares=[];handler=()=>({});constructor(e,t,r){this.viewPath=e;if(typeof t==="function")this.handler=t,this.children=class extends d{routes=r??{}};else if(Array.isArray(t)){const[n,s]=t,o=new n,a=o[s].bind(o);this.handler=(i)=>{let w=i;return w=o.requests[s]?new o.requests[s](i.rawRequest,i.params):w,a(i)},this.children=class extends d{routes=r??{}}}else this.children=class extends d{routes=t},this.handler=()=>({})}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class d{middlewares=[];routes={};view(e,t){return new g(e,t)}layout(e,t,r){return new O(e,t,r)}}var W="GEMI_REQUEST_BREAKER_ERROR";class l extends Error{constructor(){super(...arguments)}kind="GEMI_REQUEST_BREAKER_ERROR";payload={api:{},view:{}}}class p extends l{errors={};constructor(e){super("Validation error");this.name="ValidationError",this.errors=e,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:e}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}import{AsyncLocalStorage as L} from"async_hooks";class h{e;t;r;constructor(e,t,r={}){this.name=e;this.value=t;this.options=r}toString(){return[`${this.name}=${this.value}`,this.options.maxAge?`Max-Age=${this.options.maxAge}`:"",this.options.httpOnly?"HttpOnly":"",this.options.secure?"Secure":"",this.options.sameSite?`SameSite=${this.options.sameSite}`:"SameSite=Strict",this.options.path?`Path=${this.options.path}`:"Path=/",this.options.domain?`Domain=${this.options.domain}`:"",this.options.expires?`Expires=${this.options.expires.toUTCString()}`:"",this.options.partitioned?"Partitioned":""].filter((e)=>e!=="").join("; ")}}var m=new L;class I{cookies=new Set;headers=new Headers;user=null;req=null;constructor(){}setCookie(e,t,r={}){this.cookies.add(new h(e,t,r))}setHeaders(e,t){this.headers.set(e,t)}setUser(e){this.user=e}setRequest(e){this.req=e}}class c{static getStore(){return m.getStore()}static setRequest(e){m.getStore().req=e}static async run(e){return m.run(new I,e)}}var U=function(e){const[t,r]=e.split(":");switch(t){case"required":return(n)=>{return n!==null&&n!==void 0&&n?.length>0};case"password":return(n)=>{return/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(n)};case"number":return(n)=>{if(typeof n!=="number")return!1;return!isNaN(n)};case"min":return(n)=>{return n?.length>=parseInt(r)};case"max":return(n)=>{return n?.length<=parseInt(r)};case"email":return(n)=>{return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)};default:return()=>!0}};class R{e;constructor(e){this.data=e}get(e){return this.data[e]}set(e,t){this.data[e]=t}has(e){return this.data[e]!==void 0}toJSON(){return this.data}}class M{rawRequest;headers;cookies;schema={};params;ctx=c.getStore();constructor(e,t){this.params=t,this.rawRequest=e,this.headers=e.headers;const r=this.rawRequest.headers.get("Cookie"),n=new Map;if(r){const s=r.split(";");for(let o of s){const[a,i]=o.split("=");n.set(a.trim(),i.trim())}}this.cookies=n}refine(e){return{}}async parseBody(){const e=new R({});if(this.rawRequest.headers.get("Content-Type")==="application/json"){const t=await this.rawRequest.json();for(let[r,n]of Object.entries(t))e.set(r,n)}if(this.rawRequest.headers.get("Content-Type")==="application/x-www-form-urlencoded"){const t=await this.rawRequest.formData();for(let[r,n]of t)e.set(r,n)}if(this.rawRequest.headers.get("Content-Type").startsWith("multipart/form-data")){const t=await this.rawRequest.formData();for(let[r,n]of t)if(e.has(r)){const s=e.get(r);if(Array.isArray(s))s.push(n),e.set(r,s);else e.set(r,[s,n])}else e.set(r,n)}return e}validateInput(e){const t={};for(let[r,n]of Object.entries(this.schema))for(let[s,o]of Object.entries(n))if(!U(s)(e.get(r))){if(!t[r])t[r]=[];if(s==="required"){t[r]=[String(o)];break}else t[r].push(String(o))}for(let[r,n]of Object.entries(this.refine(e.toJSON())??{})){if(!t[r])t[r]=[];t[r]=[...t[r],n]}if(Object.keys(t).length>0)throw new p(t);else return e}async input(){if(this.rawRequest.method==="GET"){const e=new URL(this.rawRequest.url),t=Object.fromEntries(e.searchParams.entries());return this.validateInput(new R(t))}return this.validateInput(await this.parseBody())}async safeInput(){const e=await this.parseBody();try{return this.validateInput(e),{isValid:!0,errors:{},input:e}}catch(t){if(!(t instanceof p))throw t;return{isValid:!1,errors:t.errors,input:e}}}async terminate(e){throw"not implemented"}}class x{async run(e){return{}}}function _(e){const t=e.headers.get("cookie");if(!t)return new Map;const r=new Map,n=t.split(";");for(let s of n){const[o,a]=s.split("=");r.set(o.trim(),a)}return r}class b{aliases={}}import{AsyncLocalStorage as D} from"async_hooks";var q=new D;class f{static getStore=()=>q.getStore()}class E extends l{error;constructor(e="Not authorized"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class A extends l{error;constructor(e="Insufficient permissions"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class y extends l{constructor(){super("Authentication error");this.name="AuthenticationError"}payload={api:{status:401,data:{error:"Authentication error"}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:"/auth/sign-in"}}}}class S extends x{constructor(){super(...arguments)}async run(e){const t=c.getStore(),r=t.req.cookies.get("access_token");if(!r)throw new y;let n=t.user;if(!n){const s=await f.getStore().authenticationServiceProvider.adapter.findSession({token:r,userAgent:t.req.headers.get("User-Agent")});if(!s)throw new y;n=s?.user,t.setUser(n)}return{}}}class V{policiesList={};constructor(){const e=this.register();for(let t of e){const r=new t;this.policiesList[t.name]=r}}register(){return[]}}class ${all(e,t){return!0}}class k{dictionary={};supportedLocales=[];defaultLocale="en-US";async init(){}detectLocale(e){return this.defaultLocale}}export{_ as getCookies,d as ViewRouter,p as ValidationError,C as ResourceController,l as RequestBreakerError,V as PoliciesServiceProvider,$ as Policies,b as MiddlewareServiceProvider,x as Middleware,A as InsufficientPermissionsError,k as I18nServiceProvider,M as HttpRequest,T as Controller,E as AuthorizationError,S as AuthenticationMiddleware,y as AuthenticationError,P as ApiRouter};export{T as a,H as b,P as c,d,W as e,l as f,c as g,M as h,b as i,q as j,f as k,E as l,A as m,y as n,V as o,k as p};
2
+ import"../chunk-7ce930fe69575c87.js";class P{requests={};static kind="controller";constructor(){}}class f extends P{constructor(){super(...arguments)}}function H(e){return typeof e==="function"&&e.prototype!==void 0}var L=function(e){return H(e)};class u{e;t;n;middlewares=[];constructor(e,t,n){this.method=e;this.handler=t;this.methodName=n;this.handler=t,this.methodName=n,this.method=e}run(e){let t=e;if(L(this.handler)){const n=new this.handler,r=n[this.methodName].bind(n);return t=n.requests[this.methodName]?new n.requests[this.methodName](e.rawRequest,e.params):t,r(t)}else return this.handler(e)}middleware(e){return this.middlewares=e,this}}class K{constructor(...e){return new u(...e)}}class h{routes={};middlewares=[];middleware(e){}get(e,t){return new u("GET",e,t)}post(e,t){return new u("POST",e,t)}put(e,t){return new u("PUT",e,t)}patch(e,t){return new u("PATCH",e,t)}delete(e,t){return new u("DELETE",e,t)}resource(e){class t extends h{constructor(){super(...arguments)}routes={"/":{list:this.get(e,"list"),create:this.post(e,"create")},"/:id":{show:this.get(e,"show"),update:this.put(e,"update"),delete:this.delete(e,"delete")}}}return t}file(e,t){return new K("GET",e,t)}}class g{e;middlewares=[];handler;constructor(e,t){this.viewPath=e;if(!t)this.handler=()=>({});else if(typeof t==="function")this.handler=t;else{const[n,r]=t,s=new n,o=s[r].bind(s);this.handler=(i)=>{let a=i;return a=s.requests[r]?new s.requests[r](i.rawRequest,i.params):a,o(i)}}}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class O{e;children;middlewares=[];handler=()=>({});constructor(e,t,n){this.viewPath=e;if(typeof t==="function")this.handler=t,this.children=class extends p{routes=n??{}};else if(Array.isArray(t)){const[r,s]=t,o=new r,i=o[s].bind(o);this.handler=(a)=>{let d=a;return d=o.requests[s]?new o.requests[s](a.rawRequest,a.params):d,i(a)},this.children=class extends p{routes=n??{}}}else this.children=class extends p{routes=t},this.handler=()=>({})}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class p{middlewares=[];routes={};view(e,t){return new g(e,t)}layout(e,t,n){return new O(e,t,n)}}var Z="GEMI_REQUEST_BREAKER_ERROR";class l extends Error{constructor(){super(...arguments)}kind="GEMI_REQUEST_BREAKER_ERROR";payload={api:{},view:{}}}class c extends l{errors={};constructor(e){super("Validation error");this.name="ValidationError",this.errors=e,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:e}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}import{AsyncLocalStorage as U} from"async_hooks";class m{e;t;n;constructor(e,t,n={}){this.name=e;this.value=t;this.options=n}toString(){return[`${this.name}=${this.value}`,this.options.maxAge?`Max-Age=${this.options.maxAge}`:"",this.options.httpOnly?"HttpOnly":"",this.options.secure?"Secure":"",this.options.sameSite?`SameSite=${this.options.sameSite}`:"SameSite=Strict",this.options.path?`Path=${this.options.path}`:"Path=/",this.options.domain?`Domain=${this.options.domain}`:"",this.options.expires?`Expires=${this.options.expires.toUTCString()}`:"",this.options.partitioned?"Partitioned":""].filter((e)=>e!=="").join("; ")}}var R=new U;class I{cookies=new Set;headers=new Headers;user=null;req=null;constructor(){}setCookie(e,t,n={}){this.cookies.add(new m(e,t,n))}setHeaders(e,t){this.headers.set(e,t)}setUser(e){this.user=e}setRequest(e){this.req=e}}class y{static getStore(){return R.getStore()}static setRequest(e){R.getStore().req=e}static async run(e){return R.run(new I,e)}}var v=function(e){const[t,n]=e.match(/\d+|\D+/g)??[];if(!t||!n)return 0;const r=parseInt(t);switch(n){case"B":return r;case"KB":return r*1024;case"MB":return r*1024*1024;case"GB":return r*1024*1024*1024;case"TB":return r*1024*1024*1024*1024;default:return 0}},D=function(e){switch(e){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return e}},G=function(e){const[t,n]=e.split(":");switch(t){case"required":return(r)=>{if(r instanceof Blob)return r.size>0;return r!==null&&r!==void 0&&r?.length>0};case"password":return(r)=>{return/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(r)};case"number":return(r)=>{if(typeof r!=="number")return!1;return!isNaN(r)};case"min":return(r)=>{return r?.length>=parseInt(n)};case"max":return(r)=>{return r?.length<=parseInt(n)};case"email":return(r)=>{return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)};case"file":return(r)=>{return r instanceof Blob};case"fileType":return(r)=>{if(r instanceof Blob){const s=D(n);return r.type.startsWith(s)}};case"fileSize":return(r)=>{if(r instanceof Blob){const s=v(n);return r.size<=s}};default:return()=>!0}};class w{e;constructor(e){this.data=e}get(e){return this.data[e]}set(e,t){this.data[e]=t}has(e){return this.data[e]!==void 0}toJSON(){return this.data}}class M{rawRequest;headers;cookies;schema={};params;ctx=y.getStore();constructor(e,t){this.params=t,this.rawRequest=e,this.headers=e.headers;const n=this.rawRequest.headers.get("Cookie"),r=new Map;if(n){const s=n.split(";");for(let o of s){const[i,a]=o.split("=");r.set(i.trim(),a.trim())}}this.cookies=r}refine(e){return{}}async parseBody(){const e=new w({});if(this.rawRequest.headers.get("Content-Type")==="application/json"){const t=await this.rawRequest.json();for(let[n,r]of Object.entries(t))e.set(n,r)}if(this.rawRequest.headers.get("Content-Type")==="application/x-www-form-urlencoded"){const t=await this.rawRequest.formData();for(let[n,r]of t)e.set(n,r)}if(this.rawRequest.headers.get("Content-Type").startsWith("multipart/form-data")){const t=await this.rawRequest.formData();for(let[n,r]of t)if(e.has(n)){const s=e.get(n);if(Array.isArray(s))s.push(r),e.set(n,s);else e.set(n,[s,r])}else e.set(n,r)}return e}validateInput(e){const t={};for(let[n,r]of Object.entries(this.schema))for(let[s,o]of Object.entries(r)){const i=G(s);let a=o,d=!1;if(typeof o==="function")a=o(e.get(n)),d=typeof a==="undefined";else d=i(e.get(n));if(d)continue;if(!t[n])t[n]=[];if(s==="required"){t[n]=[String(a)];break}else t[n].push(String(a))}for(let[n,r]of Object.entries(this.refine(e.toJSON())??{})){if(!t[n])t[n]=[];t[n]=[...t[n],r]}if(Object.keys(t).length>0)throw new c(t);else return e}async input(){if(this.rawRequest.method==="GET"){const e=new URL(this.rawRequest.url),t=Object.fromEntries(e.searchParams.entries());return this.validateInput(new w(t))}return this.validateInput(await this.parseBody())}async safeInput(){const e=await this.parseBody();try{return this.validateInput(e),{isValid:!0,errors:{},input:e}}catch(t){if(!(t instanceof c))throw t;return{isValid:!1,errors:t.errors,input:e}}}async terminate(e){throw"not implemented"}}class T{async run(e){return{}}}function N(e){const t=e.headers.get("cookie");if(!t)return new Map;const n=new Map,r=t.split(";");for(let s of r){const[o,i]=s.split("=");n.set(o.trim(),i)}return n}class q{aliases={}}import{AsyncLocalStorage as _} from"async_hooks";var b=new _;class C{static getStore=()=>b.getStore()}class E extends l{error;constructor(e="Not authorized"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class A extends l{error;constructor(e="Insufficient permissions"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class x extends l{constructor(){super("Authentication error");this.name="AuthenticationError"}payload={api:{status:401,data:{error:"Authentication error"}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:"/auth/sign-in"}}}}class V extends T{constructor(){super(...arguments)}async run(e){const t=y.getStore(),n=t.req.cookies.get("access_token");if(!n)throw new x;let r=t.user;if(!r){const s=await C.getStore().authenticationServiceProvider.adapter.findSession({token:n,userAgent:t.req.headers.get("User-Agent")});if(!s)throw new x;r=s?.user,t.setUser(r)}return{}}}class ${policiesList={};constructor(){const e=this.register();for(let t of e){const n=new t;this.policiesList[t.name]=n}}register(){return[]}}class k{all(e,t){return!0}}class S{dictionary={};supportedLocales=[];defaultLocale="en-US";async init(){}detectLocale(e){return this.defaultLocale}}export{N as getCookies,p as ViewRouter,c as ValidationError,f as ResourceController,l as RequestBreakerError,$ as PoliciesServiceProvider,k as Policies,q as MiddlewareServiceProvider,T as Middleware,A as InsufficientPermissionsError,S as I18nServiceProvider,M as HttpRequest,P as Controller,E as AuthorizationError,V as AuthenticationMiddleware,x as AuthenticationError,h as ApiRouter};export{P as a,H as b,h as c,p as d,Z as e,l as f,y as g,M as h,q as i,b as j,C as k,E as l,A as m,x as n,$ as o,S as p};