@alepha/react 0.12.0 → 0.12.1

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
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
15
19
  }
16
20
  return to;
17
21
  };
@@ -94,7 +98,7 @@ var ReactPageService = class {
94
98
  * const userProfile = $page({
95
99
  * path: "/users/:id",
96
100
  * schema: {
97
- * params: t.object({ id: t.int() }),
101
+ * params: t.object({ id: t.integer() }),
98
102
  * query: t.object({ tab: t.optional(t.text()) })
99
103
  * },
100
104
  * resolve: async ({ params }) => {
@@ -1550,7 +1554,7 @@ var ReactRouter = class {
1550
1554
  path(name, config = {}) {
1551
1555
  return this.pageApi.pathname(name, {
1552
1556
  params: {
1553
- ...this.state.params,
1557
+ ...this.state?.params,
1554
1558
  ...config.params
1555
1559
  },
1556
1560
  query: config.query
@@ -1648,38 +1652,6 @@ const useInject = (service) => {
1648
1652
  return (0, react.useMemo)(() => alepha$1.inject(service), []);
1649
1653
  };
1650
1654
 
1651
- //#endregion
1652
- //#region src/core/hooks/useRouter.ts
1653
- /**
1654
- * Use this hook to access the React Router instance.
1655
- *
1656
- * You can add a type parameter to specify the type of your application.
1657
- * This will allow you to use the router in a typesafe way.
1658
- *
1659
- * @example
1660
- * class App {
1661
- * home = $page();
1662
- * }
1663
- *
1664
- * const router = useRouter<App>();
1665
- * router.go("home"); // typesafe
1666
- */
1667
- const useRouter = () => {
1668
- return useInject(ReactRouter);
1669
- };
1670
-
1671
- //#endregion
1672
- //#region src/core/components/Link.tsx
1673
- const Link = (props) => {
1674
- const router = useRouter();
1675
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1676
- ...props,
1677
- ...router.anchor(props.href),
1678
- children: props.children
1679
- });
1680
- };
1681
- var Link_default = Link;
1682
-
1683
1655
  //#endregion
1684
1656
  //#region src/core/hooks/useAction.ts
1685
1657
  /**
@@ -1907,6 +1879,83 @@ function useAction(options, deps) {
1907
1879
  };
1908
1880
  }
1909
1881
 
1882
+ //#endregion
1883
+ //#region src/core/hooks/useClient.ts
1884
+ /**
1885
+ * Hook to get a virtual client for the specified scope.
1886
+ *
1887
+ * It's the React-hook version of `$client()`, from `AlephaServerLinks` module.
1888
+ */
1889
+ const useClient = (scope) => {
1890
+ return useInject(alepha_server_links.LinkProvider).client(scope);
1891
+ };
1892
+
1893
+ //#endregion
1894
+ //#region src/core/hooks/useSchema.ts
1895
+ const useSchema = (action) => {
1896
+ const name = action.name;
1897
+ const alepha$1 = useAlepha();
1898
+ const httpClient = useInject(alepha_server.HttpClient);
1899
+ const [schema, setSchema] = (0, react.useState)(ssrSchemaLoading(alepha$1, name));
1900
+ (0, react.useEffect)(() => {
1901
+ if (!schema.loading) return;
1902
+ httpClient.fetch(`${alepha_server_links.LinkProvider.path.apiLinks}/${name}/schema`, { localCache: true }).then((it) => setSchema(it.data));
1903
+ }, [name]);
1904
+ return schema;
1905
+ };
1906
+ /**
1907
+ * Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
1908
+ */
1909
+ const ssrSchemaLoading = (alepha$1, name) => {
1910
+ if (!alepha$1.isBrowser()) {
1911
+ const linkProvider = alepha$1.inject(alepha_server_links.LinkProvider);
1912
+ const can = linkProvider.getServerLinks().find((link) => link.name === name);
1913
+ if (can) {
1914
+ const schema$1 = linkProvider.links.find((it) => it.name === name)?.schema;
1915
+ if (schema$1) {
1916
+ can.schema = schema$1;
1917
+ return schema$1;
1918
+ }
1919
+ }
1920
+ return { loading: true };
1921
+ }
1922
+ const schema = alepha$1.inject(alepha_server_links.LinkProvider).links.find((it) => it.name === name)?.schema;
1923
+ if (schema) return schema;
1924
+ return { loading: true };
1925
+ };
1926
+
1927
+ //#endregion
1928
+ //#region src/core/hooks/useRouter.ts
1929
+ /**
1930
+ * Use this hook to access the React Router instance.
1931
+ *
1932
+ * You can add a type parameter to specify the type of your application.
1933
+ * This will allow you to use the router in a typesafe way.
1934
+ *
1935
+ * @example
1936
+ * class App {
1937
+ * home = $page();
1938
+ * }
1939
+ *
1940
+ * const router = useRouter<App>();
1941
+ * router.go("home"); // typesafe
1942
+ */
1943
+ const useRouter = () => {
1944
+ return useInject(ReactRouter);
1945
+ };
1946
+
1947
+ //#endregion
1948
+ //#region src/core/components/Link.tsx
1949
+ const Link = (props) => {
1950
+ const router = useRouter();
1951
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1952
+ ...props,
1953
+ ...router.anchor(props.href),
1954
+ children: props.children
1955
+ });
1956
+ };
1957
+ var Link_default = Link;
1958
+
1910
1959
  //#endregion
1911
1960
  //#region src/core/hooks/useActive.ts
1912
1961
  const useActive = (args) => {
@@ -1940,17 +1989,6 @@ const useActive = (args) => {
1940
1989
  };
1941
1990
  };
1942
1991
 
1943
- //#endregion
1944
- //#region src/core/hooks/useClient.ts
1945
- /**
1946
- * Hook to get a virtual client for the specified scope.
1947
- *
1948
- * It's the React-hook version of `$client()`, from `AlephaServerLinks` module.
1949
- */
1950
- const useClient = (scope) => {
1951
- return useInject(alepha_server_links.LinkProvider).client(scope);
1952
- };
1953
-
1954
1992
  //#endregion
1955
1993
  //#region src/core/hooks/useQueryParams.ts
1956
1994
  /**
@@ -1986,40 +2024,6 @@ const decode = (alepha$1, schema, data) => {
1986
2024
  }
1987
2025
  };
1988
2026
 
1989
- //#endregion
1990
- //#region src/core/hooks/useSchema.ts
1991
- const useSchema = (action) => {
1992
- const name = action.name;
1993
- const alepha$1 = useAlepha();
1994
- const httpClient = useInject(alepha_server.HttpClient);
1995
- const [schema, setSchema] = (0, react.useState)(ssrSchemaLoading(alepha$1, name));
1996
- (0, react.useEffect)(() => {
1997
- if (!schema.loading) return;
1998
- httpClient.fetch(`${alepha_server_links.LinkProvider.path.apiLinks}/${name}/schema`, { localCache: true }).then((it) => setSchema(it.data));
1999
- }, [name]);
2000
- return schema;
2001
- };
2002
- /**
2003
- * Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
2004
- */
2005
- const ssrSchemaLoading = (alepha$1, name) => {
2006
- if (!alepha$1.isBrowser()) {
2007
- const linkProvider = alepha$1.inject(alepha_server_links.LinkProvider);
2008
- const can = linkProvider.getServerLinks().find((link) => link.name === name);
2009
- if (can) {
2010
- const schema$1 = linkProvider.links.find((it) => it.name === name)?.schema;
2011
- if (schema$1) {
2012
- can.schema = schema$1;
2013
- return schema$1;
2014
- }
2015
- }
2016
- return { loading: true };
2017
- }
2018
- const schema = alepha$1.inject(alepha_server_links.LinkProvider).links.find((it) => it.name === name)?.schema;
2019
- if (schema) return schema;
2020
- return { loading: true };
2021
- };
2022
-
2023
2027
  //#endregion
2024
2028
  //#region src/core/index.ts
2025
2029
  /**