@alepha/react 0.12.0 → 0.13.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 (85) hide show
  1. package/dist/auth/chunk-DhGyd7sr.js +28 -0
  2. package/dist/auth/index.browser.js +394 -114
  3. package/dist/auth/index.browser.js.map +1 -1
  4. package/dist/auth/index.cjs +80 -1927
  5. package/dist/auth/index.cjs.map +1 -1
  6. package/dist/auth/index.d.cts +1130 -420
  7. package/dist/auth/index.d.ts +1130 -420
  8. package/dist/auth/index.js +72 -1918
  9. package/dist/auth/index.js.map +1 -1
  10. package/dist/core/chunk-DhGyd7sr.js +28 -0
  11. package/dist/core/index.browser.js +79 -79
  12. package/dist/core/index.browser.js.map +1 -1
  13. package/dist/core/index.cjs +89 -85
  14. package/dist/core/index.cjs.map +1 -1
  15. package/dist/core/index.d.cts +1654 -154
  16. package/dist/core/index.d.ts +1654 -154
  17. package/dist/core/index.js +79 -79
  18. package/dist/core/index.js.map +1 -1
  19. package/dist/form/chunk-DhGyd7sr.js +28 -0
  20. package/dist/form/index.cjs +28 -8
  21. package/dist/form/index.cjs.map +1 -1
  22. package/dist/form/index.d.cts +215 -7
  23. package/dist/form/index.d.ts +215 -7
  24. package/dist/form/index.js +18 -3
  25. package/dist/form/index.js.map +1 -1
  26. package/dist/head/chunk-DhGyd7sr.js +28 -0
  27. package/dist/head/index.browser.js +385 -59
  28. package/dist/head/index.browser.js.map +1 -1
  29. package/dist/head/index.cjs +12 -8
  30. package/dist/head/index.cjs.map +1 -1
  31. package/dist/head/index.d.cts +1230 -24
  32. package/dist/head/index.d.ts +1230 -29
  33. package/dist/head/index.js +2 -2
  34. package/dist/head/index.js.map +1 -1
  35. package/dist/i18n/chunk-DhGyd7sr.js +28 -0
  36. package/dist/i18n/index.cjs +33 -20
  37. package/dist/i18n/index.cjs.map +1 -1
  38. package/dist/i18n/index.d.cts +282 -13
  39. package/dist/i18n/index.d.ts +282 -13
  40. package/dist/i18n/index.js +23 -14
  41. package/dist/i18n/index.js.map +1 -1
  42. package/dist/websocket/index.cjs +21 -8
  43. package/dist/websocket/index.cjs.map +1 -1
  44. package/dist/websocket/index.js +11 -2
  45. package/dist/websocket/index.js.map +1 -1
  46. package/package.json +7 -6
  47. package/src/auth/index.browser.ts +3 -6
  48. package/src/auth/index.shared.ts +0 -1
  49. package/src/auth/index.ts +3 -16
  50. package/src/auth/providers/ReactAuthProvider.ts +1 -614
  51. package/src/auth/services/ReactAuth.ts +6 -17
  52. package/src/core/descriptors/$page.ts +1 -1
  53. package/src/core/index.browser.ts +1 -0
  54. package/src/core/index.native.ts +21 -0
  55. package/src/core/index.shared-router.ts +15 -0
  56. package/src/core/index.shared.ts +0 -14
  57. package/src/core/index.ts +1 -0
  58. package/src/core/services/ReactRouter.ts +2 -2
  59. package/src/form/errors/FormValidationError.ts +20 -0
  60. package/src/form/hooks/useForm.ts +1 -1
  61. package/src/form/index.ts +1 -0
  62. package/src/head/providers/BrowserHeadProvider.ts +1 -1
  63. package/src/i18n/descriptors/$dictionary.ts +7 -3
  64. package/src/i18n/providers/I18nProvider.ts +9 -10
  65. package/src/websocket/hooks/useRoom.tsx +21 -2
  66. package/dist/auth/index.d.cts.map +0 -1
  67. package/dist/auth/index.d.ts.map +0 -1
  68. package/dist/core/index.d.cts.map +0 -1
  69. package/dist/core/index.d.ts.map +0 -1
  70. package/dist/form/index.d.cts.map +0 -1
  71. package/dist/form/index.d.ts.map +0 -1
  72. package/dist/head/index.d.cts.map +0 -1
  73. package/dist/head/index.d.ts.map +0 -1
  74. package/dist/i18n/index.d.cts.map +0 -1
  75. package/dist/i18n/index.d.ts.map +0 -1
  76. package/dist/websocket/index.d.cts.map +0 -1
  77. package/dist/websocket/index.d.ts.map +0 -1
  78. package/src/auth/descriptors/$auth.ts +0 -436
  79. package/src/auth/descriptors/$authApple.ts +0 -8
  80. package/src/auth/descriptors/$authGithub.ts +0 -81
  81. package/src/auth/descriptors/$authGoogle.ts +0 -38
  82. package/src/auth/errors/SessionExpiredError.ts +0 -6
  83. package/src/auth/schemas/tokenResponseSchema.ts +0 -11
  84. package/src/auth/schemas/tokensSchema.ts +0 -21
  85. package/src/auth/schemas/userinfoResponseSchema.ts +0 -10
@@ -70,7 +70,7 @@ var ReactPageService = class {
70
70
  * const userProfile = $page({
71
71
  * path: "/users/:id",
72
72
  * schema: {
73
- * params: t.object({ id: t.int() }),
73
+ * params: t.object({ id: t.integer() }),
74
74
  * query: t.object({ tab: t.optional(t.text()) })
75
75
  * },
76
76
  * resolve: async ({ params }) => {
@@ -1526,7 +1526,7 @@ var ReactRouter = class {
1526
1526
  path(name, config = {}) {
1527
1527
  return this.pageApi.pathname(name, {
1528
1528
  params: {
1529
- ...this.state.params,
1529
+ ...this.state?.params,
1530
1530
  ...config.params
1531
1531
  },
1532
1532
  query: config.query
@@ -1624,38 +1624,6 @@ const useInject = (service) => {
1624
1624
  return useMemo(() => alepha.inject(service), []);
1625
1625
  };
1626
1626
 
1627
- //#endregion
1628
- //#region src/core/hooks/useRouter.ts
1629
- /**
1630
- * Use this hook to access the React Router instance.
1631
- *
1632
- * You can add a type parameter to specify the type of your application.
1633
- * This will allow you to use the router in a typesafe way.
1634
- *
1635
- * @example
1636
- * class App {
1637
- * home = $page();
1638
- * }
1639
- *
1640
- * const router = useRouter<App>();
1641
- * router.go("home"); // typesafe
1642
- */
1643
- const useRouter = () => {
1644
- return useInject(ReactRouter);
1645
- };
1646
-
1647
- //#endregion
1648
- //#region src/core/components/Link.tsx
1649
- const Link = (props) => {
1650
- const router = useRouter();
1651
- return /* @__PURE__ */ jsx("a", {
1652
- ...props,
1653
- ...router.anchor(props.href),
1654
- children: props.children
1655
- });
1656
- };
1657
- var Link_default = Link;
1658
-
1659
1627
  //#endregion
1660
1628
  //#region src/core/hooks/useAction.ts
1661
1629
  /**
@@ -1883,6 +1851,83 @@ function useAction(options, deps) {
1883
1851
  };
1884
1852
  }
1885
1853
 
1854
+ //#endregion
1855
+ //#region src/core/hooks/useClient.ts
1856
+ /**
1857
+ * Hook to get a virtual client for the specified scope.
1858
+ *
1859
+ * It's the React-hook version of `$client()`, from `AlephaServerLinks` module.
1860
+ */
1861
+ const useClient = (scope) => {
1862
+ return useInject(LinkProvider).client(scope);
1863
+ };
1864
+
1865
+ //#endregion
1866
+ //#region src/core/hooks/useSchema.ts
1867
+ const useSchema = (action) => {
1868
+ const name = action.name;
1869
+ const alepha = useAlepha();
1870
+ const httpClient = useInject(HttpClient);
1871
+ const [schema, setSchema] = useState(ssrSchemaLoading(alepha, name));
1872
+ useEffect(() => {
1873
+ if (!schema.loading) return;
1874
+ httpClient.fetch(`${LinkProvider.path.apiLinks}/${name}/schema`, { localCache: true }).then((it) => setSchema(it.data));
1875
+ }, [name]);
1876
+ return schema;
1877
+ };
1878
+ /**
1879
+ * Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
1880
+ */
1881
+ const ssrSchemaLoading = (alepha, name) => {
1882
+ if (!alepha.isBrowser()) {
1883
+ const linkProvider = alepha.inject(LinkProvider);
1884
+ const can = linkProvider.getServerLinks().find((link) => link.name === name);
1885
+ if (can) {
1886
+ const schema$1 = linkProvider.links.find((it) => it.name === name)?.schema;
1887
+ if (schema$1) {
1888
+ can.schema = schema$1;
1889
+ return schema$1;
1890
+ }
1891
+ }
1892
+ return { loading: true };
1893
+ }
1894
+ const schema = alepha.inject(LinkProvider).links.find((it) => it.name === name)?.schema;
1895
+ if (schema) return schema;
1896
+ return { loading: true };
1897
+ };
1898
+
1899
+ //#endregion
1900
+ //#region src/core/hooks/useRouter.ts
1901
+ /**
1902
+ * Use this hook to access the React Router instance.
1903
+ *
1904
+ * You can add a type parameter to specify the type of your application.
1905
+ * This will allow you to use the router in a typesafe way.
1906
+ *
1907
+ * @example
1908
+ * class App {
1909
+ * home = $page();
1910
+ * }
1911
+ *
1912
+ * const router = useRouter<App>();
1913
+ * router.go("home"); // typesafe
1914
+ */
1915
+ const useRouter = () => {
1916
+ return useInject(ReactRouter);
1917
+ };
1918
+
1919
+ //#endregion
1920
+ //#region src/core/components/Link.tsx
1921
+ const Link = (props) => {
1922
+ const router = useRouter();
1923
+ return /* @__PURE__ */ jsx("a", {
1924
+ ...props,
1925
+ ...router.anchor(props.href),
1926
+ children: props.children
1927
+ });
1928
+ };
1929
+ var Link_default = Link;
1930
+
1886
1931
  //#endregion
1887
1932
  //#region src/core/hooks/useActive.ts
1888
1933
  const useActive = (args) => {
@@ -1916,17 +1961,6 @@ const useActive = (args) => {
1916
1961
  };
1917
1962
  };
1918
1963
 
1919
- //#endregion
1920
- //#region src/core/hooks/useClient.ts
1921
- /**
1922
- * Hook to get a virtual client for the specified scope.
1923
- *
1924
- * It's the React-hook version of `$client()`, from `AlephaServerLinks` module.
1925
- */
1926
- const useClient = (scope) => {
1927
- return useInject(LinkProvider).client(scope);
1928
- };
1929
-
1930
1964
  //#endregion
1931
1965
  //#region src/core/hooks/useQueryParams.ts
1932
1966
  /**
@@ -1962,40 +1996,6 @@ const decode = (alepha, schema, data) => {
1962
1996
  }
1963
1997
  };
1964
1998
 
1965
- //#endregion
1966
- //#region src/core/hooks/useSchema.ts
1967
- const useSchema = (action) => {
1968
- const name = action.name;
1969
- const alepha = useAlepha();
1970
- const httpClient = useInject(HttpClient);
1971
- const [schema, setSchema] = useState(ssrSchemaLoading(alepha, name));
1972
- useEffect(() => {
1973
- if (!schema.loading) return;
1974
- httpClient.fetch(`${LinkProvider.path.apiLinks}/${name}/schema`, { localCache: true }).then((it) => setSchema(it.data));
1975
- }, [name]);
1976
- return schema;
1977
- };
1978
- /**
1979
- * Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
1980
- */
1981
- const ssrSchemaLoading = (alepha, name) => {
1982
- if (!alepha.isBrowser()) {
1983
- const linkProvider = alepha.inject(LinkProvider);
1984
- const can = linkProvider.getServerLinks().find((link) => link.name === name);
1985
- if (can) {
1986
- const schema$1 = linkProvider.links.find((it) => it.name === name)?.schema;
1987
- if (schema$1) {
1988
- can.schema = schema$1;
1989
- return schema$1;
1990
- }
1991
- }
1992
- return { loading: true };
1993
- }
1994
- const schema = alepha.inject(LinkProvider).links.find((it) => it.name === name)?.schema;
1995
- if (schema) return schema;
1996
- return { loading: true };
1997
- };
1998
-
1999
1999
  //#endregion
2000
2000
  //#region src/core/index.ts
2001
2001
  /**