@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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
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
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { };
|
|
@@ -66,7 +66,7 @@ var ReactPageService = class {
|
|
|
66
66
|
* const userProfile = $page({
|
|
67
67
|
* path: "/users/:id",
|
|
68
68
|
* schema: {
|
|
69
|
-
* params: t.object({ id: t.
|
|
69
|
+
* params: t.object({ id: t.integer() }),
|
|
70
70
|
* query: t.object({ tab: t.optional(t.text()) })
|
|
71
71
|
* },
|
|
72
72
|
* resolve: async ({ params }) => {
|
|
@@ -1212,7 +1212,7 @@ var ReactRouter = class {
|
|
|
1212
1212
|
path(name, config = {}) {
|
|
1213
1213
|
return this.pageApi.pathname(name, {
|
|
1214
1214
|
params: {
|
|
1215
|
-
...this.state
|
|
1215
|
+
...this.state?.params,
|
|
1216
1216
|
...config.params
|
|
1217
1217
|
},
|
|
1218
1218
|
query: config.query
|
|
@@ -1310,38 +1310,6 @@ const useInject = (service) => {
|
|
|
1310
1310
|
return useMemo(() => alepha.inject(service), []);
|
|
1311
1311
|
};
|
|
1312
1312
|
|
|
1313
|
-
//#endregion
|
|
1314
|
-
//#region src/core/hooks/useRouter.ts
|
|
1315
|
-
/**
|
|
1316
|
-
* Use this hook to access the React Router instance.
|
|
1317
|
-
*
|
|
1318
|
-
* You can add a type parameter to specify the type of your application.
|
|
1319
|
-
* This will allow you to use the router in a typesafe way.
|
|
1320
|
-
*
|
|
1321
|
-
* @example
|
|
1322
|
-
* class App {
|
|
1323
|
-
* home = $page();
|
|
1324
|
-
* }
|
|
1325
|
-
*
|
|
1326
|
-
* const router = useRouter<App>();
|
|
1327
|
-
* router.go("home"); // typesafe
|
|
1328
|
-
*/
|
|
1329
|
-
const useRouter = () => {
|
|
1330
|
-
return useInject(ReactRouter);
|
|
1331
|
-
};
|
|
1332
|
-
|
|
1333
|
-
//#endregion
|
|
1334
|
-
//#region src/core/components/Link.tsx
|
|
1335
|
-
const Link = (props) => {
|
|
1336
|
-
const router = useRouter();
|
|
1337
|
-
return /* @__PURE__ */ jsx("a", {
|
|
1338
|
-
...props,
|
|
1339
|
-
...router.anchor(props.href),
|
|
1340
|
-
children: props.children
|
|
1341
|
-
});
|
|
1342
|
-
};
|
|
1343
|
-
var Link_default = Link;
|
|
1344
|
-
|
|
1345
1313
|
//#endregion
|
|
1346
1314
|
//#region src/core/hooks/useAction.ts
|
|
1347
1315
|
/**
|
|
@@ -1569,6 +1537,83 @@ function useAction(options, deps) {
|
|
|
1569
1537
|
};
|
|
1570
1538
|
}
|
|
1571
1539
|
|
|
1540
|
+
//#endregion
|
|
1541
|
+
//#region src/core/hooks/useClient.ts
|
|
1542
|
+
/**
|
|
1543
|
+
* Hook to get a virtual client for the specified scope.
|
|
1544
|
+
*
|
|
1545
|
+
* It's the React-hook version of `$client()`, from `AlephaServerLinks` module.
|
|
1546
|
+
*/
|
|
1547
|
+
const useClient = (scope) => {
|
|
1548
|
+
return useInject(LinkProvider).client(scope);
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
//#endregion
|
|
1552
|
+
//#region src/core/hooks/useSchema.ts
|
|
1553
|
+
const useSchema = (action) => {
|
|
1554
|
+
const name = action.name;
|
|
1555
|
+
const alepha = useAlepha();
|
|
1556
|
+
const httpClient = useInject(HttpClient);
|
|
1557
|
+
const [schema, setSchema] = useState(ssrSchemaLoading(alepha, name));
|
|
1558
|
+
useEffect(() => {
|
|
1559
|
+
if (!schema.loading) return;
|
|
1560
|
+
httpClient.fetch(`${LinkProvider.path.apiLinks}/${name}/schema`, { localCache: true }).then((it) => setSchema(it.data));
|
|
1561
|
+
}, [name]);
|
|
1562
|
+
return schema;
|
|
1563
|
+
};
|
|
1564
|
+
/**
|
|
1565
|
+
* Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
|
|
1566
|
+
*/
|
|
1567
|
+
const ssrSchemaLoading = (alepha, name) => {
|
|
1568
|
+
if (!alepha.isBrowser()) {
|
|
1569
|
+
const linkProvider = alepha.inject(LinkProvider);
|
|
1570
|
+
const can = linkProvider.getServerLinks().find((link) => link.name === name);
|
|
1571
|
+
if (can) {
|
|
1572
|
+
const schema$1 = linkProvider.links.find((it) => it.name === name)?.schema;
|
|
1573
|
+
if (schema$1) {
|
|
1574
|
+
can.schema = schema$1;
|
|
1575
|
+
return schema$1;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
return { loading: true };
|
|
1579
|
+
}
|
|
1580
|
+
const schema = alepha.inject(LinkProvider).links.find((it) => it.name === name)?.schema;
|
|
1581
|
+
if (schema) return schema;
|
|
1582
|
+
return { loading: true };
|
|
1583
|
+
};
|
|
1584
|
+
|
|
1585
|
+
//#endregion
|
|
1586
|
+
//#region src/core/hooks/useRouter.ts
|
|
1587
|
+
/**
|
|
1588
|
+
* Use this hook to access the React Router instance.
|
|
1589
|
+
*
|
|
1590
|
+
* You can add a type parameter to specify the type of your application.
|
|
1591
|
+
* This will allow you to use the router in a typesafe way.
|
|
1592
|
+
*
|
|
1593
|
+
* @example
|
|
1594
|
+
* class App {
|
|
1595
|
+
* home = $page();
|
|
1596
|
+
* }
|
|
1597
|
+
*
|
|
1598
|
+
* const router = useRouter<App>();
|
|
1599
|
+
* router.go("home"); // typesafe
|
|
1600
|
+
*/
|
|
1601
|
+
const useRouter = () => {
|
|
1602
|
+
return useInject(ReactRouter);
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1605
|
+
//#endregion
|
|
1606
|
+
//#region src/core/components/Link.tsx
|
|
1607
|
+
const Link = (props) => {
|
|
1608
|
+
const router = useRouter();
|
|
1609
|
+
return /* @__PURE__ */ jsx("a", {
|
|
1610
|
+
...props,
|
|
1611
|
+
...router.anchor(props.href),
|
|
1612
|
+
children: props.children
|
|
1613
|
+
});
|
|
1614
|
+
};
|
|
1615
|
+
var Link_default = Link;
|
|
1616
|
+
|
|
1572
1617
|
//#endregion
|
|
1573
1618
|
//#region src/core/hooks/useActive.ts
|
|
1574
1619
|
const useActive = (args) => {
|
|
@@ -1602,17 +1647,6 @@ const useActive = (args) => {
|
|
|
1602
1647
|
};
|
|
1603
1648
|
};
|
|
1604
1649
|
|
|
1605
|
-
//#endregion
|
|
1606
|
-
//#region src/core/hooks/useClient.ts
|
|
1607
|
-
/**
|
|
1608
|
-
* Hook to get a virtual client for the specified scope.
|
|
1609
|
-
*
|
|
1610
|
-
* It's the React-hook version of `$client()`, from `AlephaServerLinks` module.
|
|
1611
|
-
*/
|
|
1612
|
-
const useClient = (scope) => {
|
|
1613
|
-
return useInject(LinkProvider).client(scope);
|
|
1614
|
-
};
|
|
1615
|
-
|
|
1616
1650
|
//#endregion
|
|
1617
1651
|
//#region src/core/hooks/useQueryParams.ts
|
|
1618
1652
|
/**
|
|
@@ -1648,40 +1682,6 @@ const decode = (alepha, schema, data) => {
|
|
|
1648
1682
|
}
|
|
1649
1683
|
};
|
|
1650
1684
|
|
|
1651
|
-
//#endregion
|
|
1652
|
-
//#region src/core/hooks/useSchema.ts
|
|
1653
|
-
const useSchema = (action) => {
|
|
1654
|
-
const name = action.name;
|
|
1655
|
-
const alepha = useAlepha();
|
|
1656
|
-
const httpClient = useInject(HttpClient);
|
|
1657
|
-
const [schema, setSchema] = useState(ssrSchemaLoading(alepha, name));
|
|
1658
|
-
useEffect(() => {
|
|
1659
|
-
if (!schema.loading) return;
|
|
1660
|
-
httpClient.fetch(`${LinkProvider.path.apiLinks}/${name}/schema`, { localCache: true }).then((it) => setSchema(it.data));
|
|
1661
|
-
}, [name]);
|
|
1662
|
-
return schema;
|
|
1663
|
-
};
|
|
1664
|
-
/**
|
|
1665
|
-
* Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
|
|
1666
|
-
*/
|
|
1667
|
-
const ssrSchemaLoading = (alepha, name) => {
|
|
1668
|
-
if (!alepha.isBrowser()) {
|
|
1669
|
-
const linkProvider = alepha.inject(LinkProvider);
|
|
1670
|
-
const can = linkProvider.getServerLinks().find((link) => link.name === name);
|
|
1671
|
-
if (can) {
|
|
1672
|
-
const schema$1 = linkProvider.links.find((it) => it.name === name)?.schema;
|
|
1673
|
-
if (schema$1) {
|
|
1674
|
-
can.schema = schema$1;
|
|
1675
|
-
return schema$1;
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
return { loading: true };
|
|
1679
|
-
}
|
|
1680
|
-
const schema = alepha.inject(LinkProvider).links.find((it) => it.name === name)?.schema;
|
|
1681
|
-
if (schema) return schema;
|
|
1682
|
-
return { loading: true };
|
|
1683
|
-
};
|
|
1684
|
-
|
|
1685
1685
|
//#endregion
|
|
1686
1686
|
//#region src/core/index.browser.ts
|
|
1687
1687
|
const AlephaReact = $module({
|