gemi 0.16.0 → 0.16.2

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 (124) hide show
  1. package/dist/app/index.js +2 -2
  2. package/dist/app/index.js.map +1 -1
  3. package/dist/auth/AuthenticationServiceProvider.d.ts +2 -6
  4. package/dist/auth/AuthenticationServiceProvider.d.ts.map +1 -1
  5. package/dist/broadcasting/index.js +1 -1
  6. package/dist/{chunk-xttpe58q.js → chunk-2e5r9zc8.js} +2 -2
  7. package/dist/{chunk-xttpe58q.js.map → chunk-2e5r9zc8.js.map} +1 -1
  8. package/dist/chunk-3exa3rf7.js +4 -0
  9. package/dist/{chunk-f196t91j.js.map → chunk-3exa3rf7.js.map} +11 -8
  10. package/dist/{chunk-ta13zfs4.js → chunk-4kkyjz2j.js} +3 -3
  11. package/dist/{chunk-ta13zfs4.js.map → chunk-4kkyjz2j.js.map} +1 -1
  12. package/dist/{chunk-ng2p76w0.js → chunk-5g8wefgj.js} +2 -2
  13. package/dist/{chunk-ng2p76w0.js.map → chunk-5g8wefgj.js.map} +1 -1
  14. package/dist/{chunk-t7h2bfdc.js → chunk-5saeq23h.js} +3 -3
  15. package/dist/{chunk-t7h2bfdc.js.map → chunk-5saeq23h.js.map} +1 -1
  16. package/dist/{chunk-3za8zsph.js → chunk-5zy36vzw.js} +2 -2
  17. package/dist/{chunk-3za8zsph.js.map → chunk-5zy36vzw.js.map} +1 -1
  18. package/dist/chunk-662r0ncr.js +9 -0
  19. package/dist/{chunk-gbvbe40d.js.map → chunk-662r0ncr.js.map} +3 -4
  20. package/dist/{chunk-7hhtnc5w.js → chunk-8hz7nqa6.js} +2 -2
  21. package/dist/{chunk-7hhtnc5w.js.map → chunk-8hz7nqa6.js.map} +1 -1
  22. package/dist/chunk-a30zkbbx.js +4 -0
  23. package/dist/{chunk-e7jsryv0.js.map → chunk-a30zkbbx.js.map} +5 -5
  24. package/dist/{chunk-wvrm1f95.js → chunk-ac8m7p53.js} +1 -1
  25. package/dist/{chunk-j2ymcc6q.js → chunk-arayp1w0.js} +2 -2
  26. package/dist/{chunk-j2ymcc6q.js.map → chunk-arayp1w0.js.map} +1 -1
  27. package/dist/{chunk-ebkqmqqv.js → chunk-awqqsf8p.js} +3 -3
  28. package/dist/{chunk-ebkqmqqv.js.map → chunk-awqqsf8p.js.map} +1 -1
  29. package/dist/chunk-bq3ssfcb.js +27 -0
  30. package/dist/{chunk-tecykzzj.js.map → chunk-bq3ssfcb.js.map} +3 -4
  31. package/dist/chunk-d5bjn9jq.js +4 -0
  32. package/dist/{chunk-8dq9vxkx.js.map → chunk-d5bjn9jq.js.map} +2 -2
  33. package/dist/chunk-dgsssga5.js +4 -0
  34. package/dist/{chunk-29ws1r7g.js.map → chunk-dgsssga5.js.map} +2 -2
  35. package/dist/chunk-dyq4bf49.js +4 -0
  36. package/dist/{chunk-a1hr4h7e.js.map → chunk-dyq4bf49.js.map} +1 -1
  37. package/dist/{chunk-27wb042h.js → chunk-e4t6twrj.js} +2 -2
  38. package/dist/{chunk-27wb042h.js.map → chunk-e4t6twrj.js.map} +1 -1
  39. package/dist/{chunk-vs8z6vye.js → chunk-eyw5m86d.js} +2 -2
  40. package/dist/{chunk-vs8z6vye.js.map → chunk-eyw5m86d.js.map} +1 -1
  41. package/dist/chunk-fhx0vt7d.js +5 -0
  42. package/dist/{chunk-gfptwbg1.js.map → chunk-fhx0vt7d.js.map} +2 -2
  43. package/dist/chunk-hakywsfq.js +4 -0
  44. package/dist/{chunk-xs7ze1bn.js.map → chunk-hakywsfq.js.map} +1 -1
  45. package/dist/chunk-k5h445f9.js +4 -0
  46. package/dist/{chunk-byw3s9kx.js.map → chunk-k5h445f9.js.map} +2 -2
  47. package/dist/{chunk-qfy8y0cb.js → chunk-m65hegz2.js} +4 -4
  48. package/dist/{chunk-qfy8y0cb.js.map → chunk-m65hegz2.js.map} +3 -4
  49. package/dist/chunk-pdxpkd11.js +5 -0
  50. package/dist/{chunk-36metsym.js.map → chunk-pdxpkd11.js.map} +5 -5
  51. package/dist/chunk-qj8d5qgn.js +4 -0
  52. package/dist/chunk-qj8d5qgn.js.map +10 -0
  53. package/dist/{chunk-012pty5m.js → chunk-rfs3fhhw.js} +2 -2
  54. package/dist/{chunk-012pty5m.js.map → chunk-rfs3fhhw.js.map} +1 -1
  55. package/dist/chunk-tzznavpf.js +4 -0
  56. package/dist/{chunk-5cr89erj.js.map → chunk-tzznavpf.js.map} +4 -4
  57. package/dist/{chunk-tt59hv0g.js → chunk-v6kcbyg4.js} +3 -3
  58. package/dist/{chunk-tt59hv0g.js.map → chunk-v6kcbyg4.js.map} +1 -1
  59. package/dist/{chunk-11mj8m4b.js → chunk-vas2h4rh.js} +3 -3
  60. package/dist/{chunk-11mj8m4b.js.map → chunk-vas2h4rh.js.map} +1 -1
  61. package/dist/chunk-w19m1fcb.js +5 -0
  62. package/dist/{chunk-wcx72bkd.js.map → chunk-w19m1fcb.js.map} +6 -6
  63. package/dist/chunk-xsmhw13v.js +8 -0
  64. package/dist/{chunk-b5ey3qx8.js.map → chunk-xsmhw13v.js.map} +2 -2
  65. package/dist/chunk-yaeec5ch.js +4 -0
  66. package/dist/{chunk-s5y9sq5v.js.map → chunk-yaeec5ch.js.map} +5 -5
  67. package/dist/chunk-yjwabzsb.js +4 -0
  68. package/dist/{chunk-edb7bzhf.js.map → chunk-yjwabzsb.js.map} +2 -2
  69. package/dist/chunk-zv5ztmxm.js +4 -0
  70. package/dist/{chunk-pjnwtece.js.map → chunk-zv5ztmxm.js.map} +2 -2
  71. package/dist/client/ClientRouter.d.ts.map +1 -1
  72. package/dist/client/Link.d.ts +1 -1
  73. package/dist/client/Link.d.ts.map +1 -1
  74. package/dist/client/RouteTransitionProvider.d.ts +14 -0
  75. package/dist/client/RouteTransitionProvider.d.ts.map +1 -0
  76. package/dist/client/auth/useForgotPassword.d.ts +6 -3
  77. package/dist/client/auth/useForgotPassword.d.ts.map +1 -1
  78. package/dist/client/auth/useResetPassword.d.ts +7 -4
  79. package/dist/client/auth/useResetPassword.d.ts.map +1 -1
  80. package/dist/client/auth/useSignIn.d.ts +27 -14
  81. package/dist/client/auth/useSignIn.d.ts.map +1 -1
  82. package/dist/client/auth/useSignOut.d.ts +4 -1
  83. package/dist/client/auth/useSignOut.d.ts.map +1 -1
  84. package/dist/client/auth/useSignUp.d.ts +4 -6
  85. package/dist/client/auth/useSignUp.d.ts.map +1 -1
  86. package/dist/client/index.d.ts +1 -0
  87. package/dist/client/index.d.ts.map +1 -1
  88. package/dist/client/index.js +124 -74
  89. package/dist/client/index.js.map +1 -1
  90. package/dist/client/useMutation.d.ts +20 -5
  91. package/dist/client/useMutation.d.ts.map +1 -1
  92. package/dist/email/index.js +1 -1
  93. package/dist/facades/index.js +4 -4
  94. package/dist/facades/index.js.map +3 -3
  95. package/dist/http/index.js +2 -2
  96. package/dist/http/index.js.map +1 -1
  97. package/dist/i18n/index.js +1 -1
  98. package/dist/kernel/index.js +2 -2
  99. package/dist/kernel/index.js.map +1 -1
  100. package/dist/server/index.js +2 -2
  101. package/dist/server/index.js.map +1 -1
  102. package/dist/services/index.js +48 -48
  103. package/dist/services/index.js.map +5 -5
  104. package/package.json +1 -1
  105. package/dist/chunk-29ws1r7g.js +0 -4
  106. package/dist/chunk-36metsym.js +0 -5
  107. package/dist/chunk-5cr89erj.js +0 -4
  108. package/dist/chunk-7642sy4a.js +0 -3
  109. package/dist/chunk-7642sy4a.js.map +0 -15
  110. package/dist/chunk-8dq9vxkx.js +0 -4
  111. package/dist/chunk-a1hr4h7e.js +0 -4
  112. package/dist/chunk-b5ey3qx8.js +0 -8
  113. package/dist/chunk-byw3s9kx.js +0 -4
  114. package/dist/chunk-e7jsryv0.js +0 -4
  115. package/dist/chunk-edb7bzhf.js +0 -4
  116. package/dist/chunk-f196t91j.js +0 -3
  117. package/dist/chunk-gbvbe40d.js +0 -9
  118. package/dist/chunk-gfptwbg1.js +0 -5
  119. package/dist/chunk-pjnwtece.js +0 -4
  120. package/dist/chunk-s5y9sq5v.js +0 -4
  121. package/dist/chunk-tecykzzj.js +0 -27
  122. package/dist/chunk-wcx72bkd.js +0 -5
  123. package/dist/chunk-xs7ze1bn.js +0 -4
  124. /package/dist/{chunk-wvrm1f95.js.map → chunk-ac8m7p53.js.map} +0 -0
@@ -10,7 +10,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
12
  var _i, _n, _t, _e, _s, _l, _o, _d, _p, _g, _H_instances, r_fn, R_fn, b_fn, u_fn, m_fn, a_fn, P_fn, E_fn, S_fn, O_fn, k_fn, x_fn, h_fn, f_fn, T_fn, A_fn, y_fn, w_fn, c_fn, C_fn, _a, _i2, _n2, _t2, _e2, _s2, _l2, _b;
13
- import require$$1, { createContext, useRef, useContext, useState, useEffect, useCallback, useMemo, useSyncExternalStore, lazy, memo, StrictMode, useTransition, isValidElement, createElement, Fragment as Fragment$1 } from "react";
13
+ import require$$1, { createContext, useRef, useContext, useState, useEffect, useCallback, useMemo, useSyncExternalStore, memo, lazy, StrictMode, useTransition, isValidElement, createElement, Fragment as Fragment$1 } from "react";
14
14
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
15
15
  import require$$2, { createPortal } from "react-dom";
16
16
  class Subject {
@@ -356,6 +356,64 @@ function useMutation(method, url, ...args) {
356
356
  () => new AbortController()
357
357
  );
358
358
  const formData = useRef(new FormData());
359
+ async function trigger(input) {
360
+ setState({
361
+ data: state.data,
362
+ error: state.error,
363
+ loading: true
364
+ });
365
+ const [inputs = {}, options = defaultOptions] = args ?? [];
366
+ const params = "params" in inputs ? { ..._params, ...inputs.params } : _params;
367
+ const finalUrl = applyParams(String(url).replace(`${method}:`, ""), params);
368
+ let body = null;
369
+ const contentType = typeof input === "undefined" || input instanceof FormData ? {} : { "Content-Type": "application/json" };
370
+ if (input instanceof FormData) {
371
+ body = input;
372
+ } else if (typeof input === "undefined") {
373
+ body = formData.current;
374
+ } else if (input) {
375
+ body = JSON.stringify(input);
376
+ }
377
+ try {
378
+ const response = await fetch2(`${host}/api${finalUrl}`, {
379
+ method,
380
+ headers: {
381
+ ...contentType
382
+ },
383
+ ...body ? { body } : {},
384
+ signal: abortController.signal
385
+ });
386
+ formData.current = new FormData();
387
+ const data = await response.json();
388
+ if (!response.ok) {
389
+ setState({
390
+ data: null,
391
+ error: data.error,
392
+ loading: false
393
+ });
394
+ options.onError(data);
395
+ return;
396
+ }
397
+ options.onSuccess(data);
398
+ setState({
399
+ data,
400
+ error: null,
401
+ loading: false
402
+ });
403
+ return data;
404
+ } catch (error) {
405
+ formData.current = new FormData();
406
+ options.onError(error);
407
+ setState({
408
+ data: null,
409
+ error,
410
+ loading: false
411
+ });
412
+ }
413
+ }
414
+ trigger.formData = (formData2) => {
415
+ return trigger(formData2);
416
+ };
359
417
  return {
360
418
  data: state.data,
361
419
  error: state.error,
@@ -373,64 +431,7 @@ function useMutation(method, url, ...args) {
373
431
  formData.current = new FormData();
374
432
  options.onCanceled();
375
433
  },
376
- trigger: async (input) => {
377
- setState({
378
- data: state.data,
379
- error: state.error,
380
- loading: true
381
- });
382
- const [inputs = {}, options = defaultOptions] = args ?? [];
383
- const params = "params" in inputs ? { ..._params, ...inputs.params } : _params;
384
- const finalUrl = applyParams(
385
- String(url).replace(`${method}:`, ""),
386
- params
387
- );
388
- let body = null;
389
- const contentType = typeof input === "undefined" || input instanceof FormData ? {} : { "Content-Type": "application/json" };
390
- if (input instanceof FormData) {
391
- body = input;
392
- } else if (typeof input === "undefined") {
393
- body = formData.current;
394
- } else if (input) {
395
- body = JSON.stringify(input);
396
- }
397
- try {
398
- const response = await fetch2(`${host}/api${finalUrl}`, {
399
- method,
400
- headers: {
401
- ...contentType
402
- },
403
- ...body ? { body } : {},
404
- signal: abortController.signal
405
- });
406
- formData.current = new FormData();
407
- const data = await response.json();
408
- if (!response.ok) {
409
- setState({
410
- data: null,
411
- error: data.error,
412
- loading: false
413
- });
414
- options.onError(data);
415
- return;
416
- }
417
- options.onSuccess(data);
418
- setState({
419
- data,
420
- error: null,
421
- loading: false
422
- });
423
- return data;
424
- } catch (error) {
425
- formData.current = new FormData();
426
- options.onError(error);
427
- setState({
428
- data: null,
429
- error,
430
- loading: false
431
- });
432
- }
433
- }
434
+ trigger
434
435
  };
435
436
  }
436
437
  function usePost(url, ...args) {
@@ -2103,13 +2104,42 @@ function useBreadcrumbs() {
2103
2104
  }
2104
2105
  return breadcrumbs.filter((breadcrumb) => (breadcrumb == null ? void 0 : breadcrumb.label.length) > 0);
2105
2106
  }
2107
+ const RouteTransitionContext = createContext({
2108
+ isTransitioning: false,
2109
+ targetPath: "",
2110
+ currentPath: ""
2111
+ });
2112
+ const RouteTransitionProvider = (props) => {
2113
+ const { isPending, isFetching, transitionPath } = props;
2114
+ return /* @__PURE__ */ jsx(
2115
+ RouteTransitionContext.Provider,
2116
+ {
2117
+ value: {
2118
+ isTransitioning: isPending || isFetching,
2119
+ targetPath: transitionPath[1],
2120
+ currentPath: transitionPath[0] || ""
2121
+ },
2122
+ children: props.children
2123
+ }
2124
+ );
2125
+ };
2126
+ function useRouteTransition() {
2127
+ const context = useContext(RouteTransitionContext);
2128
+ if (!context) {
2129
+ throw new Error(
2130
+ "useRouteTransition must be used within a RouteTransitionProvider"
2131
+ );
2132
+ }
2133
+ return context;
2134
+ }
2106
2135
  function normalizeSearch(search) {
2107
2136
  return Object.fromEntries(
2108
2137
  Object.entries(search).filter(([_k, v2]) => v2 !== void 0 && v2 !== null).map(([k2, v2]) => [k2, String(v2)])
2109
2138
  );
2110
2139
  }
2111
- const Link = (props) => {
2140
+ const Link = memo((props) => {
2112
2141
  const _params = useParams();
2142
+ const { isTransitioning, targetPath } = useRouteTransition();
2113
2143
  const {
2114
2144
  href,
2115
2145
  onClick,
@@ -2119,7 +2149,7 @@ const Link = (props) => {
2119
2149
  search = {},
2120
2150
  ...rest
2121
2151
  } = { params: _params, search: {}, ...props };
2122
- const { defaultLocale, ...i18 } = useContext(I18nContext);
2152
+ const { defaultLocale } = useContext(I18nContext);
2123
2153
  const { push } = useNavigate();
2124
2154
  const location = useLocation();
2125
2155
  const searchParams = new URLSearchParams(normalizeSearch(search));
@@ -2138,7 +2168,7 @@ const Link = (props) => {
2138
2168
  "a",
2139
2169
  {
2140
2170
  "data-active": active || currentHref === targetHref,
2141
- "data-current": currentHref,
2171
+ "data-pending": href === targetPath && isTransitioning,
2142
2172
  href: targetHref,
2143
2173
  onClick: (e) => {
2144
2174
  if (typeof window !== "undefined") {
@@ -2164,7 +2194,7 @@ const Link = (props) => {
2164
2194
  ...rest
2165
2195
  }
2166
2196
  );
2167
- };
2197
+ });
2168
2198
  const Redirect = (props) => {
2169
2199
  const { href, params = {}, search = {}, action } = props;
2170
2200
  const { push, replace } = useNavigate();
@@ -31826,9 +31856,14 @@ const Tree = memo(
31826
31856
  );
31827
31857
  const Routes = (props) => {
31828
31858
  const { componentTree } = props;
31829
- const [, startTransition] = useTransition();
31859
+ const [isPending, startTransition] = useTransition();
31860
+ const [isFetching, setIsFetching] = useState(false);
31830
31861
  const { fetch: fetch2, host } = useContext(HttpClientContext);
31831
31862
  const { routerSubject, fetchRouteCSS } = useContext(ClientRouterContext);
31863
+ const [transitionPath, setTransitionPath] = useState([
31864
+ null,
31865
+ routerSubject.getValue().pathname
31866
+ ]);
31832
31867
  const { breadcrumbs, pageData, i18n, prefetchedData } = useContext(ServerDataContext);
31833
31868
  const [routeState, setRouteState] = useState({
31834
31869
  params: routerSubject.getValue().params,
@@ -31849,6 +31884,10 @@ const Routes = (props) => {
31849
31884
  useEffect(() => {
31850
31885
  return routerSubject.subscribe(async (routerState) => {
31851
31886
  const { pathname, search, state, views } = routerState;
31887
+ setTransitionPath((current) => {
31888
+ const [, prevTarget] = current;
31889
+ return [prevTarget, pathname];
31890
+ });
31852
31891
  if (routerState.views.length === 0) {
31853
31892
  setRouteState((routerState2) => ({
31854
31893
  ...routerState2,
@@ -31867,6 +31906,7 @@ const Routes = (props) => {
31867
31906
  const _pathname = localeSegment.length > 0 && pathname === "/" ? "" : pathname;
31868
31907
  const pathnameWithLocaleSegment = `${localeSegment}${_pathname}`;
31869
31908
  const url = `${host}${pathnameWithLocaleSegment}.json${search}`;
31909
+ setIsFetching(true);
31870
31910
  const [res] = await Promise.all([
31871
31911
  fetch2(url),
31872
31912
  fetchRouteCSS(pathname),
@@ -31912,17 +31952,26 @@ const Routes = (props) => {
31912
31952
  });
31913
31953
  });
31914
31954
  }
31955
+ setIsFetching(false);
31915
31956
  });
31916
31957
  }, [routerSubject, fetchRouteCSS, fetch2, host, replace]);
31917
- return /* @__PURE__ */ jsx(RouteStateProvider, { state: routeState, children: /* @__PURE__ */ jsx(
31918
- Tree,
31958
+ return /* @__PURE__ */ jsx(
31959
+ RouteTransitionProvider,
31919
31960
  {
31920
- action: routeState.action,
31921
- pathname: applyParams$1(routeState.pathname ?? "/", routeState.params),
31922
- tree: componentTree,
31923
- entries: routeState.pathname ? routeState.views : ["404"]
31961
+ isPending,
31962
+ isFetching,
31963
+ transitionPath,
31964
+ children: /* @__PURE__ */ jsx(RouteStateProvider, { state: routeState, children: /* @__PURE__ */ jsx(
31965
+ Tree,
31966
+ {
31967
+ action: routeState.action,
31968
+ pathname: applyParams$1(routeState.pathname ?? "/", routeState.params),
31969
+ tree: componentTree,
31970
+ entries: routeState.pathname ? routeState.views : ["404"]
31971
+ }
31972
+ ) })
31924
31973
  }
31925
- ) });
31974
+ );
31926
31975
  };
31927
31976
  const ClientRouter = (props) => {
31928
31977
  const { RootLayout } = props;
@@ -32231,9 +32280,9 @@ function useTranslator(component) {
32231
32280
  };
32232
32281
  return parse;
32233
32282
  }
32234
- const deleteLocaleCookie = async (locale) => {
32283
+ const setCookie = async (locale) => {
32235
32284
  try {
32236
- return await globalThis.cookieStore.delete("i18n-locale");
32285
+ return await globalThis.cookieStore.set("i18n-locale", locale);
32237
32286
  } catch (err) {
32238
32287
  return await fetch(`/api/__gemi__/services/i18n/set-locale/${locale}`);
32239
32288
  }
@@ -32245,7 +32294,7 @@ function useLocale() {
32245
32294
  const params = useParams();
32246
32295
  const setLocale = async (locale) => {
32247
32296
  const urlSearchParams = new URLSearchParams(search);
32248
- deleteLocaleCookie(locale).then(() => {
32297
+ setCookie(locale).then(() => {
32249
32298
  replace(pathname, {
32250
32299
  locale,
32251
32300
  // TODO: fix: this conversion is wrong, because there can be multiple
@@ -32327,6 +32376,7 @@ export {
32327
32376
  useQuery,
32328
32377
  useResetPassword,
32329
32378
  useRoute,
32379
+ useRouteTransition,
32330
32380
  useSearchParams,
32331
32381
  useSignIn,
32332
32382
  useSignOut,