@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.
- package/dist/auth/chunk-DhGyd7sr.js +28 -0
- package/dist/auth/index.browser.js +394 -114
- package/dist/auth/index.browser.js.map +1 -1
- package/dist/auth/index.cjs +80 -1927
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +1130 -420
- package/dist/auth/index.d.ts +1130 -420
- package/dist/auth/index.js +72 -1918
- package/dist/auth/index.js.map +1 -1
- package/dist/core/chunk-DhGyd7sr.js +28 -0
- package/dist/core/index.browser.js +79 -79
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.cjs +89 -85
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +1654 -154
- package/dist/core/index.d.ts +1654 -154
- package/dist/core/index.js +79 -79
- package/dist/core/index.js.map +1 -1
- package/dist/form/chunk-DhGyd7sr.js +28 -0
- package/dist/form/index.cjs +28 -8
- package/dist/form/index.cjs.map +1 -1
- package/dist/form/index.d.cts +215 -7
- package/dist/form/index.d.ts +215 -7
- package/dist/form/index.js +18 -3
- package/dist/form/index.js.map +1 -1
- package/dist/head/chunk-DhGyd7sr.js +28 -0
- package/dist/head/index.browser.js +385 -59
- package/dist/head/index.browser.js.map +1 -1
- package/dist/head/index.cjs +12 -8
- package/dist/head/index.cjs.map +1 -1
- package/dist/head/index.d.cts +1230 -24
- package/dist/head/index.d.ts +1230 -29
- package/dist/head/index.js +2 -2
- package/dist/head/index.js.map +1 -1
- package/dist/i18n/chunk-DhGyd7sr.js +28 -0
- package/dist/i18n/index.cjs +33 -20
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +282 -13
- package/dist/i18n/index.d.ts +282 -13
- package/dist/i18n/index.js +23 -14
- package/dist/i18n/index.js.map +1 -1
- package/dist/websocket/index.cjs +21 -8
- package/dist/websocket/index.cjs.map +1 -1
- package/dist/websocket/index.js +11 -2
- package/dist/websocket/index.js.map +1 -1
- package/package.json +7 -6
- package/src/auth/index.browser.ts +3 -6
- package/src/auth/index.shared.ts +0 -1
- package/src/auth/index.ts +3 -16
- package/src/auth/providers/ReactAuthProvider.ts +1 -614
- package/src/auth/services/ReactAuth.ts +6 -17
- package/src/core/descriptors/$page.ts +1 -1
- package/src/core/index.browser.ts +1 -0
- package/src/core/index.native.ts +21 -0
- package/src/core/index.shared-router.ts +15 -0
- package/src/core/index.shared.ts +0 -14
- package/src/core/index.ts +1 -0
- package/src/core/services/ReactRouter.ts +2 -2
- package/src/form/errors/FormValidationError.ts +20 -0
- package/src/form/hooks/useForm.ts +1 -1
- package/src/form/index.ts +1 -0
- package/src/head/providers/BrowserHeadProvider.ts +1 -1
- package/src/i18n/descriptors/$dictionary.ts +7 -3
- package/src/i18n/providers/I18nProvider.ts +9 -10
- package/src/websocket/hooks/useRoom.tsx +21 -2
- package/dist/auth/index.d.cts.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/core/index.d.cts.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/form/index.d.cts.map +0 -1
- package/dist/form/index.d.ts.map +0 -1
- package/dist/head/index.d.cts.map +0 -1
- package/dist/head/index.d.ts.map +0 -1
- package/dist/i18n/index.d.cts.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/websocket/index.d.cts.map +0 -1
- package/dist/websocket/index.d.ts.map +0 -1
- package/src/auth/descriptors/$auth.ts +0 -436
- package/src/auth/descriptors/$authApple.ts +0 -8
- package/src/auth/descriptors/$authGithub.ts +0 -81
- package/src/auth/descriptors/$authGoogle.ts +0 -38
- package/src/auth/errors/SessionExpiredError.ts +0 -6
- package/src/auth/schemas/tokenResponseSchema.ts +0 -11
- package/src/auth/schemas/tokensSchema.ts +0 -21
- package/src/auth/schemas/userinfoResponseSchema.ts +0 -10
package/dist/core/index.js
CHANGED
|
@@ -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.
|
|
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
|
|
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
|
/**
|