gemi 0.4.40 → 0.4.42
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/app/App.d.ts +1 -0
- package/dist/app/App.d.ts.map +1 -1
- package/dist/app/createFlatApiRoutes.d.ts +6 -4
- package/dist/app/createFlatApiRoutes.d.ts.map +1 -1
- package/dist/app/createFlatViewRoutes.d.ts +6 -4
- package/dist/app/createFlatViewRoutes.d.ts.map +1 -1
- package/dist/app/index.js +65 -65
- package/dist/chunk-00935722c776a294.js +2 -0
- package/dist/chunk-030b4fb955329860.js +16 -0
- package/dist/chunk-05fa767ab29abb0f.js +2 -0
- package/dist/chunk-08539d08fa7362f7.js +2 -0
- package/dist/chunk-09dd89e1046786a5.js +2 -0
- package/dist/chunk-187a09f46e2b36e5.js +2 -0
- package/dist/chunk-21fe96d1a3bb5a27.js +2 -0
- package/dist/chunk-26a5c9db5d17f5e7.js +3 -0
- package/dist/chunk-29c46abebbc0f09b.js +2 -0
- package/dist/chunk-2b3eabd01b2ae3f8.js +2 -0
- package/dist/chunk-2f6867d08b95f2d2.js +2 -0
- package/dist/chunk-3567e8e424a60c99.js +18 -0
- package/dist/chunk-3a3092db69408490.js +2 -0
- package/dist/chunk-3aecba8553e036bf.js +6 -0
- package/dist/chunk-40c21fe243675250.js +2 -0
- package/dist/chunk-488b4db0c522d44a.js +1 -0
- package/dist/chunk-4960e27e19bbe42a.js +2 -0
- package/dist/chunk-4d19e16340534ed0.js +1 -1
- package/dist/chunk-4eeee2f82b1fa8bb.js +2 -0
- package/dist/chunk-51bad63147c3be4e.js +6 -0
- package/dist/chunk-584e33c96b1a78e4.js +2 -0
- package/dist/chunk-60f3b8242209ac3e.js +18 -0
- package/dist/chunk-61abf77c3eee8698.js +2 -0
- package/dist/chunk-625025af819f55f5.js +2 -0
- package/dist/chunk-6259cd13f53334df.js +2 -0
- package/dist/chunk-66ab377654806d08.js +2 -0
- package/dist/chunk-68af0a6f6be163ce.js +2 -0
- package/dist/chunk-6a28d299b5726bba.js +2 -0
- package/dist/chunk-6e415d0e12fc9539.js +1 -0
- package/dist/chunk-722f2aeae58daaa3.js +18 -0
- package/dist/chunk-76a525af0575486d.js +5 -0
- package/dist/chunk-798f550643937b6d.js +2 -0
- package/dist/chunk-7ce930fe69575c87.js +2 -0
- package/dist/chunk-7e9d5eea3aa359ad.js +2 -0
- package/dist/chunk-7ea1baca4032004f.js +2 -0
- package/dist/chunk-7ffe2ce59a054e35.js +2 -0
- package/dist/chunk-8133ed564834cff3.js +2 -0
- package/dist/chunk-81ce9b491b290639.js +1 -0
- package/dist/chunk-8a993922ea970923.js +2 -0
- package/dist/chunk-8af626a703659719.js +18 -0
- package/dist/chunk-901e700a2c2d43f3.js +18 -0
- package/dist/chunk-9326224d1e4c1a64.js +2 -0
- package/dist/chunk-9501e589e3e86a96.js +2 -0
- package/dist/chunk-955e2bfcdb7a7e71.js +2 -0
- package/dist/chunk-a2fcc46e344ae7ae.js +2 -0
- package/dist/chunk-a3f85d0d3261ae44.js +9 -0
- package/dist/chunk-a693f8ec2e8af8ca.js +2 -0
- package/dist/chunk-a719a1f305964521.js +1 -1
- package/dist/chunk-b05e4833f4bb2f8f.js +9 -0
- package/dist/chunk-b3bfe533d66f6a17.js +2 -0
- package/dist/chunk-b5d6eb761760b2a7.js +6 -0
- package/dist/chunk-b66a9e50afbac035.js +1 -1
- package/dist/chunk-b7b365f7e6038104.js +2 -0
- package/dist/chunk-b9e4546aaa58319c.js +2 -0
- package/dist/chunk-bd2888a454e50cfd.js +1 -0
- package/dist/chunk-be095501304df604.js +9 -0
- package/dist/chunk-bee6075c5738d87a.js +1 -1
- package/dist/chunk-bfccfb070c1630e9.js +2 -0
- package/dist/chunk-c041f058dc3d571b.js +1 -0
- package/dist/chunk-c0bd8e19395d722b.js +2 -0
- package/dist/chunk-c124bf801cec12d9.js +2 -0
- package/dist/chunk-c153b192112b0d44.js +2 -0
- package/dist/chunk-c72bfaa252a03f6f.js +2 -0
- package/dist/chunk-c85fc7168a708cb6.js +3 -0
- package/dist/chunk-cb65fe402653c65e.js +1 -1
- package/dist/chunk-d0806df6defd9dce.js +2 -0
- package/dist/chunk-d2e057b6f3f9d500.js +2 -0
- package/dist/chunk-d33a0e61ccf1bab5.js +2 -0
- package/dist/chunk-da1c673d9685624e.js +2 -0
- package/dist/chunk-dcc432bd72fb7e46.js +3 -0
- package/dist/chunk-ddef8961cbf08a05.js +6 -0
- package/dist/chunk-dfc390f0bbdf5a81.js +1 -0
- package/dist/chunk-e53fdd0a1888c5e8.js +2 -0
- package/dist/chunk-e9695f3cdafee20b.js +2 -0
- package/dist/chunk-edeefd833c30a5ed.js +2 -0
- package/dist/chunk-ee4ff285d7f4ccdf.js +1 -1
- package/dist/chunk-f08ca4bd263b132b.js +2 -0
- package/dist/chunk-f2dca6305fcba70b.js +1 -1
- package/dist/chunk-f99bdfc336b2ac57.js +1 -1
- package/dist/chunk-ffe161a589b4c44b.js +1 -0
- package/dist/client/ClientRouter.d.ts.map +1 -1
- package/dist/client/ClientRouterContext.d.ts +3 -11
- package/dist/client/ClientRouterContext.d.ts.map +1 -1
- package/dist/client/Link.d.ts +13 -0
- package/dist/client/Link.d.ts.map +1 -0
- package/dist/client/QueryManager.d.ts.map +1 -1
- package/dist/client/ServerDataProvider.d.ts +2 -0
- package/dist/client/ServerDataProvider.d.ts.map +1 -1
- package/dist/client/auth/useForgotPassword.d.ts.map +1 -1
- package/dist/client/auth/useResetPassword.d.ts.map +1 -1
- package/dist/client/auth/useSignIn.d.ts.map +1 -1
- package/dist/client/auth/useSignOut.d.ts.map +1 -1
- package/dist/client/auth/useUser.d.ts.map +1 -1
- package/dist/client/i18n/I18nContext.d.ts +18 -0
- package/dist/client/i18n/I18nContext.d.ts.map +1 -0
- package/dist/client/i18n/useLocale.d.ts +2 -0
- package/dist/client/i18n/useLocale.d.ts.map +1 -0
- package/dist/client/i18n/useScopedTranslator.d.ts +8 -0
- package/dist/client/i18n/useScopedTranslator.d.ts.map +1 -0
- package/dist/client/i18n/useTranslator.d.ts +2 -0
- package/dist/client/i18n/useTranslator.d.ts.map +1 -0
- package/dist/client/index.d.ts +7 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +305 -141
- package/dist/client/rpc.d.ts +6 -5
- package/dist/client/rpc.d.ts.map +1 -1
- package/dist/client/types.d.ts +9 -0
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/useRouter.d.ts +15 -0
- package/dist/client/useRouter.d.ts.map +1 -0
- package/dist/client/useSearchParams.d.ts +21 -0
- package/dist/client/useSearchParams.d.ts.map +1 -0
- package/dist/email/index.js +1 -1
- package/dist/facades/I18n.d.ts +5 -0
- package/dist/facades/I18n.d.ts.map +1 -0
- package/dist/facades/index.d.ts +1 -0
- package/dist/facades/index.d.ts.map +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/http/HttpRequest.d.ts +2 -0
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/I18nServiceContainer.d.ts +31 -0
- package/dist/http/I18nServiceContainer.d.ts.map +1 -0
- package/dist/http/I18nServiceProvider.d.ts +10 -0
- package/dist/http/I18nServiceProvider.d.ts.map +1 -0
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/http/requestContext.d.ts +2 -0
- package/dist/http/requestContext.d.ts.map +1 -1
- package/dist/kernel/Kernel.d.ts +5 -0
- package/dist/kernel/Kernel.d.ts.map +1 -1
- package/dist/kernel/context.d.ts +6 -2
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/server/index.js +1 -1
- package/dist/storage/index.js +4 -4
- package/dist/utils/applyParams.d.ts +2 -0
- package/dist/utils/applyParams.d.ts.map +1 -0
- package/dist/utils/type.d.ts +1 -0
- package/dist/utils/type.d.ts.map +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -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, useState, useEffect, useContext, useSyncExternalStore, useRef, lazy,
|
|
13
|
+
import require$$1, { createContext, useState, useEffect, useContext, useSyncExternalStore, useRef, lazy, StrictMode, Suspense } from "react";
|
|
14
14
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import require$$2 from "react-dom";
|
|
16
16
|
class Subject {
|
|
@@ -33,15 +33,19 @@ class Subject {
|
|
|
33
33
|
return this.value;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function applyParams$
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
function applyParams$2(url, params) {
|
|
37
|
+
return url.replace(/:([^/]+)/g, (_2, key) => {
|
|
38
|
+
const isOptional = key.endsWith("?");
|
|
39
|
+
const paramName = isOptional ? key.slice(0, -1) : key;
|
|
40
|
+
const value = params[paramName];
|
|
41
|
+
if (value === void 0) {
|
|
42
|
+
if (isOptional) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`Missing parameter: ${paramName}`);
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
return value;
|
|
48
|
+
}).replace(/\/\//g, "/");
|
|
45
49
|
}
|
|
46
50
|
class Resource {
|
|
47
51
|
constructor(key, fallbackData = null) {
|
|
@@ -89,7 +93,7 @@ class Resource {
|
|
|
89
93
|
const { query, params } = options;
|
|
90
94
|
const url = key.split("GET:")[1];
|
|
91
95
|
const searchParams = new URLSearchParams(query);
|
|
92
|
-
const finalUrl = [applyParams$
|
|
96
|
+
const finalUrl = [applyParams$2(url, params), searchParams.toString()].filter((s) => s.length > 0).join("?");
|
|
93
97
|
const { data, error } = this.state.getValue();
|
|
94
98
|
this.state.next({
|
|
95
99
|
data,
|
|
@@ -183,7 +187,7 @@ function useQuery(url, ...args) {
|
|
|
183
187
|
mutate: resource.mutate.bind(resource)
|
|
184
188
|
};
|
|
185
189
|
}
|
|
186
|
-
function applyParams(url, params = {}) {
|
|
190
|
+
function applyParams$1(url, params = {}) {
|
|
187
191
|
let out = url;
|
|
188
192
|
for (const [key, value] of Object.entries(params)) {
|
|
189
193
|
out = out.replace(`:${key}?`, value).replace(`:${key}`, value);
|
|
@@ -218,7 +222,7 @@ function useMutation(url, ...args) {
|
|
|
218
222
|
const params = "params" in inputs ? inputs.params : {};
|
|
219
223
|
const [method] = String(url).split(":");
|
|
220
224
|
const finalUrl = [
|
|
221
|
-
applyParams(String(url).replace(`${method}:`, ""), params),
|
|
225
|
+
applyParams$1(String(url).replace(`${method}:`, ""), params),
|
|
222
226
|
new URLSearchParams(query).toString()
|
|
223
227
|
].join("?");
|
|
224
228
|
let body = null;
|
|
@@ -600,31 +604,6 @@ function parsePath(path) {
|
|
|
600
604
|
}
|
|
601
605
|
return parsedPath;
|
|
602
606
|
}
|
|
603
|
-
function flattenComponentTree(componentTree) {
|
|
604
|
-
let out = [];
|
|
605
|
-
for (const [root, branches] of componentTree) {
|
|
606
|
-
out.push(root, ...flattenComponentTree(branches).flat());
|
|
607
|
-
}
|
|
608
|
-
return Array.from(new Set(out));
|
|
609
|
-
}
|
|
610
|
-
let viewImportMap = null;
|
|
611
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV !== "test") {
|
|
612
|
-
viewImportMap = {};
|
|
613
|
-
const { componentTree } = window.__GEMI_DATA__;
|
|
614
|
-
for (const viewName of flattenComponentTree(componentTree)) {
|
|
615
|
-
viewImportMap[viewName] = lazy(window.loaders[viewName]);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
const ComponentsContext = createContext({ viewImportMap });
|
|
619
|
-
const ComponentsProvider = (props) => {
|
|
620
|
-
return /* @__PURE__ */ jsx(
|
|
621
|
-
ComponentsContext.Provider,
|
|
622
|
-
{
|
|
623
|
-
value: { viewImportMap: props.viewImportMap ?? viewImportMap },
|
|
624
|
-
children: props.children
|
|
625
|
-
}
|
|
626
|
-
);
|
|
627
|
-
};
|
|
628
607
|
var R = class {
|
|
629
608
|
constructor(t, r, n, o, c, l) {
|
|
630
609
|
__publicField(this, "type", 3);
|
|
@@ -1368,24 +1347,35 @@ const ClientRouterProvider = (props) => {
|
|
|
1368
1347
|
window.scrollY
|
|
1369
1348
|
);
|
|
1370
1349
|
};
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1373
|
-
|
|
1350
|
+
const findMatchingRouteFromParams = (pathname2) => {
|
|
1351
|
+
const candidates = [];
|
|
1352
|
+
for (const route2 of Object.keys(routeManifest)) {
|
|
1353
|
+
const urlPattern = new me({ pathname: route2 });
|
|
1374
1354
|
if (urlPattern.test({ pathname: pathname2 })) {
|
|
1375
|
-
|
|
1355
|
+
candidates.push(route2);
|
|
1376
1356
|
}
|
|
1377
1357
|
}
|
|
1378
|
-
|
|
1358
|
+
const sortedCandidates = candidates.sort((a, b2) => {
|
|
1359
|
+
const x2 = a.split("/").length + a.split(":").length;
|
|
1360
|
+
const y2 = b2.split("/").length + b2.split(":").length;
|
|
1361
|
+
return x2 - y2;
|
|
1362
|
+
});
|
|
1363
|
+
const [route] = sortedCandidates ?? [];
|
|
1364
|
+
return route;
|
|
1365
|
+
};
|
|
1366
|
+
const getViewPathsFromPathname = (pathname2) => {
|
|
1367
|
+
const route = findMatchingRouteFromParams(pathname2);
|
|
1368
|
+
return routeManifest[route] ?? [];
|
|
1369
|
+
};
|
|
1370
|
+
const getRoutePathnameFromHref = (href) => {
|
|
1371
|
+
const route = findMatchingRouteFromParams(href);
|
|
1372
|
+
return route;
|
|
1379
1373
|
};
|
|
1380
1374
|
const getParams = (pathname2) => {
|
|
1381
1375
|
var _a2;
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
return (_a2 = urlPattern.exec({ pathname: pathname2 })) == null ? void 0 : _a2.pathname.groups;
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
return {};
|
|
1376
|
+
const route = findMatchingRouteFromParams(pathname2);
|
|
1377
|
+
const urlPattern = new me({ pathname: route });
|
|
1378
|
+
return (_a2 = urlPattern.exec({ pathname: pathname2 })) == null ? void 0 : _a2.pathname.groups;
|
|
1389
1379
|
};
|
|
1390
1380
|
useEffect(() => {
|
|
1391
1381
|
history == null ? void 0 : history.listen(({ location }) => {
|
|
@@ -1430,7 +1420,8 @@ const ClientRouterProvider = (props) => {
|
|
|
1430
1420
|
},
|
|
1431
1421
|
viewEntriesSubject: viewEntriesSubject.current,
|
|
1432
1422
|
updatePageData,
|
|
1433
|
-
getPageData
|
|
1423
|
+
getPageData,
|
|
1424
|
+
getRoutePathnameFromHref
|
|
1434
1425
|
},
|
|
1435
1426
|
children
|
|
1436
1427
|
}
|
|
@@ -1456,84 +1447,221 @@ function useParams() {
|
|
|
1456
1447
|
const { params } = useContext(ClientRouterContext);
|
|
1457
1448
|
return params;
|
|
1458
1449
|
}
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1450
|
+
const ServerDataContext = createContext({});
|
|
1451
|
+
const ServerDataProvider = (props) => {
|
|
1452
|
+
let _value = props.value;
|
|
1453
|
+
if (props.value) {
|
|
1454
|
+
_value = props.value;
|
|
1455
|
+
} else {
|
|
1456
|
+
_value = window.__GEMI_DATA__;
|
|
1457
|
+
}
|
|
1458
|
+
return /* @__PURE__ */ jsx(ServerDataContext.Provider, { value: _value, children: props.children });
|
|
1459
|
+
};
|
|
1460
|
+
const I18nContext = createContext({});
|
|
1461
|
+
const I18nProvider = (props) => {
|
|
1462
|
+
const { i18n } = useContext(ServerDataContext);
|
|
1463
|
+
const locale = Object.keys(i18n)[0];
|
|
1464
|
+
const [currentLocale, setCurrentLocale] = useState(locale);
|
|
1465
|
+
const [dictionary] = useState(() => {
|
|
1466
|
+
const dictionary2 = /* @__PURE__ */ new Map();
|
|
1467
|
+
for (const [locale2, value] of Object.entries(i18n)) {
|
|
1468
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
1469
|
+
for (const [scope, translations] of Object.entries(value)) {
|
|
1470
|
+
scopes.set(scope, translations);
|
|
1471
|
+
}
|
|
1472
|
+
dictionary2.set(locale2, scopes);
|
|
1473
|
+
}
|
|
1474
|
+
return dictionary2;
|
|
1475
|
+
});
|
|
1476
|
+
const [currentTranslations, setCurrentTranslations] = useState(() => {
|
|
1477
|
+
if (!dictionary.has(currentLocale)) {
|
|
1478
|
+
return {};
|
|
1479
|
+
}
|
|
1480
|
+
return Object.fromEntries(dictionary.get(currentLocale).entries());
|
|
1481
|
+
});
|
|
1482
|
+
function updateDictionary(translations) {
|
|
1483
|
+
for (const [locale2, value] of Object.entries(translations)) {
|
|
1484
|
+
if (!dictionary.has(locale2)) {
|
|
1485
|
+
dictionary.set(locale2, /* @__PURE__ */ new Map());
|
|
1486
|
+
}
|
|
1487
|
+
const scopes = dictionary.get(locale2);
|
|
1488
|
+
for (const [scope, translations2] of Object.entries(value)) {
|
|
1489
|
+
if (!scopes.has(scope)) {
|
|
1490
|
+
scopes.set(scope, {});
|
|
1491
|
+
}
|
|
1492
|
+
scopes.set(scope, translations2);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
setCurrentTranslations(
|
|
1496
|
+
Object.fromEntries(dictionary.get(currentLocale).entries())
|
|
1497
|
+
);
|
|
1498
|
+
}
|
|
1499
|
+
const changeLocale = (locale2) => {
|
|
1500
|
+
if (dictionary.has(locale2)) {
|
|
1501
|
+
setCurrentLocale(locale2);
|
|
1502
|
+
setCurrentTranslations(
|
|
1503
|
+
Object.fromEntries(dictionary.get(locale2).entries())
|
|
1504
|
+
);
|
|
1505
|
+
}
|
|
1475
1506
|
};
|
|
1476
|
-
|
|
1477
|
-
|
|
1507
|
+
const fetchTranslations = async (pathname, locale2) => {
|
|
1508
|
+
const response = await fetch(
|
|
1509
|
+
`/api/__gemi__/services/i18n/translations?scope=${pathname}&locale=${locale2 || currentLocale}`
|
|
1510
|
+
);
|
|
1511
|
+
const translations = await response.json();
|
|
1512
|
+
updateDictionary(translations);
|
|
1513
|
+
};
|
|
1514
|
+
return /* @__PURE__ */ jsx(
|
|
1515
|
+
I18nContext.Provider,
|
|
1516
|
+
{
|
|
1517
|
+
value: {
|
|
1518
|
+
locale: currentLocale,
|
|
1519
|
+
translations: currentTranslations,
|
|
1520
|
+
changeLocale,
|
|
1521
|
+
updateDictionary,
|
|
1522
|
+
fetchTranslations
|
|
1523
|
+
},
|
|
1524
|
+
children: props.children
|
|
1525
|
+
}
|
|
1526
|
+
);
|
|
1527
|
+
};
|
|
1478
1528
|
function useRouter() {
|
|
1479
|
-
const {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
}
|
|
1529
|
+
const {
|
|
1530
|
+
updatePageData,
|
|
1531
|
+
history,
|
|
1532
|
+
getViewPathsFromPathname,
|
|
1533
|
+
getRoutePathnameFromHref
|
|
1534
|
+
} = useContext(ClientRouterContext);
|
|
1535
|
+
const { fetchTranslations } = useContext(I18nContext);
|
|
1536
|
+
function action(pushOrReplace) {
|
|
1537
|
+
return async (path, ...args) => {
|
|
1538
|
+
const [options = {}] = args;
|
|
1539
|
+
const {
|
|
1540
|
+
search = {},
|
|
1541
|
+
params = {},
|
|
1542
|
+
shallow
|
|
1543
|
+
} = {
|
|
1544
|
+
params: {},
|
|
1545
|
+
shallow: false,
|
|
1546
|
+
...options
|
|
1547
|
+
};
|
|
1548
|
+
const urlSearchParams = new URLSearchParams(search);
|
|
1549
|
+
const basePath = applyParams$2(path, params);
|
|
1550
|
+
const navigationPath = [
|
|
1551
|
+
applyParams$2(path, params),
|
|
1552
|
+
urlSearchParams.toString()
|
|
1553
|
+
].join("?");
|
|
1498
1554
|
const components = getViewPathsFromPathname(path);
|
|
1499
|
-
const
|
|
1555
|
+
const fetchUrlSearchParams = new URLSearchParams(urlSearchParams);
|
|
1556
|
+
fetchUrlSearchParams.set("json", "true");
|
|
1557
|
+
const fetchPath = [basePath, fetchUrlSearchParams.toString()].join("?");
|
|
1558
|
+
urlSearchParams.set("json", "true");
|
|
1559
|
+
if (shallow) {
|
|
1560
|
+
history == null ? void 0 : history[pushOrReplace](navigationPath);
|
|
1561
|
+
return;
|
|
1562
|
+
}
|
|
1563
|
+
const routePathname = getRoutePathnameFromHref(path);
|
|
1500
1564
|
const [res] = await Promise.all([
|
|
1501
1565
|
fetch(fetchPath),
|
|
1566
|
+
fetchTranslations(routePathname),
|
|
1502
1567
|
...components.map((component) => window.loaders[component]())
|
|
1503
1568
|
]);
|
|
1504
1569
|
if (res.ok) {
|
|
1505
1570
|
const { data, is404 = false } = await res.json();
|
|
1506
1571
|
updatePageData(data);
|
|
1507
|
-
history == null ? void 0 : history
|
|
1572
|
+
history == null ? void 0 : history[pushOrReplace](navigationPath, is404 ? { status: 404 } : {});
|
|
1508
1573
|
window.scrollTo(0, 0);
|
|
1509
1574
|
}
|
|
1510
|
-
}
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
return {
|
|
1578
|
+
push: action("push"),
|
|
1579
|
+
replace: action("replace")
|
|
1511
1580
|
};
|
|
1512
1581
|
}
|
|
1582
|
+
class SearchParams {
|
|
1583
|
+
constructor(searchParams, callback) {
|
|
1584
|
+
this.searchParams = searchParams;
|
|
1585
|
+
this.callback = callback;
|
|
1586
|
+
}
|
|
1587
|
+
get(key) {
|
|
1588
|
+
return this.searchParams.get(key);
|
|
1589
|
+
}
|
|
1590
|
+
set(key, value) {
|
|
1591
|
+
let entries = {};
|
|
1592
|
+
if (typeof key === "string") {
|
|
1593
|
+
entries[key] = value;
|
|
1594
|
+
} else {
|
|
1595
|
+
entries = key ?? {};
|
|
1596
|
+
}
|
|
1597
|
+
for (const [key2, value2] of Object.entries(entries)) {
|
|
1598
|
+
this.searchParams.set(key2, value2);
|
|
1599
|
+
}
|
|
1600
|
+
return this;
|
|
1601
|
+
}
|
|
1602
|
+
append(key, value) {
|
|
1603
|
+
this.searchParams.append(key, value);
|
|
1604
|
+
return this;
|
|
1605
|
+
}
|
|
1606
|
+
sort() {
|
|
1607
|
+
this.searchParams.sort();
|
|
1608
|
+
return this;
|
|
1609
|
+
}
|
|
1610
|
+
clear() {
|
|
1611
|
+
this.searchParams = new URLSearchParams();
|
|
1612
|
+
return this;
|
|
1613
|
+
}
|
|
1614
|
+
delete(key) {
|
|
1615
|
+
const keys = Array.isArray(key) ? key : [key];
|
|
1616
|
+
for (const key2 of keys) {
|
|
1617
|
+
this.searchParams.delete(key2);
|
|
1618
|
+
}
|
|
1619
|
+
return this;
|
|
1620
|
+
}
|
|
1621
|
+
toJSON() {
|
|
1622
|
+
return Object.fromEntries(this.searchParams.entries());
|
|
1623
|
+
}
|
|
1624
|
+
toString() {
|
|
1625
|
+
return this.searchParams.toString();
|
|
1626
|
+
}
|
|
1627
|
+
push(mode = "hard") {
|
|
1628
|
+
this.callback(this.toJSON(), mode === "soft");
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
function useSearchParams() {
|
|
1632
|
+
const { push } = useRouter();
|
|
1633
|
+
const location = useLocation();
|
|
1634
|
+
const callback = (search, shallow) => push(location.pathname, {
|
|
1635
|
+
search,
|
|
1636
|
+
shallow
|
|
1637
|
+
});
|
|
1638
|
+
const searchParams = new SearchParams(
|
|
1639
|
+
new URLSearchParams(location.search),
|
|
1640
|
+
callback
|
|
1641
|
+
);
|
|
1642
|
+
return searchParams;
|
|
1643
|
+
}
|
|
1513
1644
|
const Link = (props) => {
|
|
1514
|
-
const {
|
|
1645
|
+
const {
|
|
1646
|
+
href,
|
|
1647
|
+
onClick,
|
|
1648
|
+
active = false,
|
|
1649
|
+
params = {},
|
|
1650
|
+
search = {},
|
|
1651
|
+
...rest
|
|
1652
|
+
} = { params: {}, ...props };
|
|
1515
1653
|
const { push } = useRouter();
|
|
1516
1654
|
const { pathname } = useLocation();
|
|
1517
|
-
|
|
1518
|
-
if (typeof href === "string") {
|
|
1519
|
-
path = `${href}`;
|
|
1520
|
-
} else {
|
|
1521
|
-
const { hash, pathname: pathname2, search } = href;
|
|
1522
|
-
const urlSearchParams = new URLSearchParams(search);
|
|
1523
|
-
path = `${pathname2}${urlSearchParams.toString()}${hash}`;
|
|
1524
|
-
}
|
|
1525
|
-
const p = typeof href === "string" ? href : href.pathname;
|
|
1655
|
+
const path = applyParams$2(href, params);
|
|
1526
1656
|
return /* @__PURE__ */ jsx(
|
|
1527
1657
|
"a",
|
|
1528
1658
|
{
|
|
1529
|
-
"data-active": active || pathname ===
|
|
1659
|
+
"data-active": active || pathname === path,
|
|
1530
1660
|
href: path,
|
|
1531
1661
|
onClick: (e) => {
|
|
1532
1662
|
e.preventDefault();
|
|
1533
1663
|
onClick == null ? void 0 : onClick(e);
|
|
1534
|
-
|
|
1535
|
-
push(href);
|
|
1536
|
-
});
|
|
1664
|
+
push(href, { search, params });
|
|
1537
1665
|
},
|
|
1538
1666
|
...rest
|
|
1539
1667
|
}
|
|
@@ -5262,7 +5390,7 @@ function requireReactDomClient_production() {
|
|
|
5262
5390
|
workInProgressRootSkippedLanes |= hook;
|
|
5263
5391
|
return prevValue;
|
|
5264
5392
|
}
|
|
5265
|
-
function
|
|
5393
|
+
function startTransition(fiber, queue, pendingState, finishedState, callback) {
|
|
5266
5394
|
var previousPriority = ReactDOMSharedInternals.p;
|
|
5267
5395
|
ReactDOMSharedInternals.p = 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8;
|
|
5268
5396
|
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
@@ -5294,7 +5422,7 @@ function requireReactDomClient_production() {
|
|
|
5294
5422
|
function startHostTransition(formFiber, pendingState, action, formData) {
|
|
5295
5423
|
if (5 !== formFiber.tag) throw Error(formatProdErrorMessage(476));
|
|
5296
5424
|
var queue = ensureFormComponentIsStateful(formFiber).queue;
|
|
5297
|
-
|
|
5425
|
+
startTransition(
|
|
5298
5426
|
formFiber,
|
|
5299
5427
|
queue,
|
|
5300
5428
|
pendingState,
|
|
@@ -5549,7 +5677,7 @@ function requireReactDomClient_production() {
|
|
|
5549
5677
|
},
|
|
5550
5678
|
useTransition: function() {
|
|
5551
5679
|
var stateHook = mountStateImpl(false);
|
|
5552
|
-
stateHook =
|
|
5680
|
+
stateHook = startTransition.bind(
|
|
5553
5681
|
null,
|
|
5554
5682
|
currentlyRenderingFiber$1,
|
|
5555
5683
|
stateHook.queue,
|
|
@@ -17706,7 +17834,7 @@ function requireReactDomClient_development() {
|
|
|
17706
17834
|
workInProgressRootSkippedLanes |= hook;
|
|
17707
17835
|
return prevValue;
|
|
17708
17836
|
}
|
|
17709
|
-
function
|
|
17837
|
+
function startTransition(fiber, queue, pendingState, finishedState, callback) {
|
|
17710
17838
|
var previousPriority = ReactDOMSharedInternals.p;
|
|
17711
17839
|
ReactDOMSharedInternals.p = 0 !== previousPriority && previousPriority < ContinuousEventPriority ? previousPriority : ContinuousEventPriority;
|
|
17712
17840
|
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
@@ -17742,7 +17870,7 @@ function requireReactDomClient_development() {
|
|
|
17742
17870
|
"Expected the form instance to be a HostComponent. This is a bug in React."
|
|
17743
17871
|
);
|
|
17744
17872
|
var queue = ensureFormComponentIsStateful(formFiber).queue;
|
|
17745
|
-
|
|
17873
|
+
startTransition(
|
|
17746
17874
|
formFiber,
|
|
17747
17875
|
queue,
|
|
17748
17876
|
pendingState,
|
|
@@ -17797,7 +17925,7 @@ function requireReactDomClient_development() {
|
|
|
17797
17925
|
}
|
|
17798
17926
|
function mountTransition() {
|
|
17799
17927
|
var stateHook = mountStateImpl(false);
|
|
17800
|
-
stateHook =
|
|
17928
|
+
stateHook = startTransition.bind(
|
|
17801
17929
|
null,
|
|
17802
17930
|
currentlyRenderingFiber$1,
|
|
17803
17931
|
stateHook.queue,
|
|
@@ -30174,15 +30302,30 @@ if (process.env.NODE_ENV === "production") {
|
|
|
30174
30302
|
client.exports = requireReactDomClient_development();
|
|
30175
30303
|
}
|
|
30176
30304
|
var clientExports = client.exports;
|
|
30177
|
-
|
|
30178
|
-
|
|
30179
|
-
|
|
30180
|
-
|
|
30181
|
-
_value = props.value;
|
|
30182
|
-
} else {
|
|
30183
|
-
_value = window.__GEMI_DATA__;
|
|
30305
|
+
function flattenComponentTree(componentTree) {
|
|
30306
|
+
let out = [];
|
|
30307
|
+
for (const [root, branches] of componentTree) {
|
|
30308
|
+
out.push(root, ...flattenComponentTree(branches).flat());
|
|
30184
30309
|
}
|
|
30185
|
-
return
|
|
30310
|
+
return Array.from(new Set(out));
|
|
30311
|
+
}
|
|
30312
|
+
let viewImportMap = null;
|
|
30313
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV !== "test") {
|
|
30314
|
+
viewImportMap = {};
|
|
30315
|
+
const { componentTree } = window.__GEMI_DATA__;
|
|
30316
|
+
for (const viewName of flattenComponentTree(componentTree)) {
|
|
30317
|
+
viewImportMap[viewName] = lazy(window.loaders[viewName]);
|
|
30318
|
+
}
|
|
30319
|
+
}
|
|
30320
|
+
const ComponentsContext = createContext({ viewImportMap });
|
|
30321
|
+
const ComponentsProvider = (props) => {
|
|
30322
|
+
return /* @__PURE__ */ jsx(
|
|
30323
|
+
ComponentsContext.Provider,
|
|
30324
|
+
{
|
|
30325
|
+
value: { viewImportMap: props.viewImportMap ?? viewImportMap },
|
|
30326
|
+
children: props.children
|
|
30327
|
+
}
|
|
30328
|
+
);
|
|
30186
30329
|
};
|
|
30187
30330
|
const Route = (props) => {
|
|
30188
30331
|
const { componentPath } = props;
|
|
@@ -30223,7 +30366,7 @@ const Routes = (props) => {
|
|
|
30223
30366
|
const ClientRouter = (props) => {
|
|
30224
30367
|
const { RootLayout } = props;
|
|
30225
30368
|
const { routeManifest, router, componentTree, pageData, auth } = useContext(ServerDataContext);
|
|
30226
|
-
return /* @__PURE__ */ jsx(QueryManagerProvider, { children: /* @__PURE__ */ jsx(ComponentsProvider, { viewImportMap: props.viewImportMap, children: /* @__PURE__ */ jsx(
|
|
30369
|
+
return /* @__PURE__ */ jsx(I18nProvider, { children: /* @__PURE__ */ jsx(QueryManagerProvider, { children: /* @__PURE__ */ jsx(ComponentsProvider, { viewImportMap: props.viewImportMap, children: /* @__PURE__ */ jsx(
|
|
30227
30370
|
ClientRouterProvider,
|
|
30228
30371
|
{
|
|
30229
30372
|
searchParams: router.searchParams,
|
|
@@ -30235,7 +30378,7 @@ const ClientRouter = (props) => {
|
|
|
30235
30378
|
routeManifest,
|
|
30236
30379
|
children: /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(RootLayout, { children: /* @__PURE__ */ jsx(Routes, { componentTree }) }) })
|
|
30237
30380
|
}
|
|
30238
|
-
) }) });
|
|
30381
|
+
) }) }) });
|
|
30239
30382
|
};
|
|
30240
30383
|
function init(RootLayout) {
|
|
30241
30384
|
clientExports.hydrateRoot(
|
|
@@ -30311,10 +30454,9 @@ const defaultArgs$3 = {
|
|
|
30311
30454
|
};
|
|
30312
30455
|
function useForgotPassword(args = defaultArgs$3) {
|
|
30313
30456
|
return useMutation(
|
|
30314
|
-
"POST:/forgot-password",
|
|
30457
|
+
"POST:/auth/forgot-password",
|
|
30315
30458
|
{},
|
|
30316
30459
|
{
|
|
30317
|
-
pathPrefix: "/auth",
|
|
30318
30460
|
onSuccess: () => {
|
|
30319
30461
|
args.onSuccess();
|
|
30320
30462
|
}
|
|
@@ -30326,16 +30468,11 @@ const defaultArgs$2 = {
|
|
|
30326
30468
|
}
|
|
30327
30469
|
};
|
|
30328
30470
|
function useSignIn(args = defaultArgs$2) {
|
|
30329
|
-
const { mutate } = useQuery(
|
|
30330
|
-
"GET:/me",
|
|
30331
|
-
{ params: {}, query: {} },
|
|
30332
|
-
{ pathPrefix: "/auth" }
|
|
30333
|
-
);
|
|
30471
|
+
const { mutate } = useQuery("GET:/auth/me", { params: {}, query: {} });
|
|
30334
30472
|
return useMutation(
|
|
30335
|
-
"POST:/sign-in",
|
|
30473
|
+
"POST:/auth/sign-in",
|
|
30336
30474
|
{},
|
|
30337
30475
|
{
|
|
30338
|
-
pathPrefix: "/auth",
|
|
30339
30476
|
onSuccess: ({ user }) => {
|
|
30340
30477
|
args.onSuccess(user);
|
|
30341
30478
|
mutate(user);
|
|
@@ -30344,23 +30481,18 @@ function useSignIn(args = defaultArgs$2) {
|
|
|
30344
30481
|
);
|
|
30345
30482
|
}
|
|
30346
30483
|
function useSignUp() {
|
|
30347
|
-
return useMutation("POST:/sign-up", {}
|
|
30484
|
+
return useMutation("POST:/auth/sign-up", {});
|
|
30348
30485
|
}
|
|
30349
30486
|
const defaultArgs$1 = {
|
|
30350
30487
|
onSuccess: () => {
|
|
30351
30488
|
}
|
|
30352
30489
|
};
|
|
30353
30490
|
function useSignOut(args = defaultArgs$1) {
|
|
30354
|
-
const { mutate } = useQuery(
|
|
30355
|
-
"GET:/me",
|
|
30356
|
-
{ params: {}, query: {} },
|
|
30357
|
-
{ pathPrefix: "/auth" }
|
|
30358
|
-
);
|
|
30491
|
+
const { mutate } = useQuery("GET:/auth/me", { params: {}, query: {} });
|
|
30359
30492
|
return useMutation(
|
|
30360
|
-
"POST:/sign-out",
|
|
30493
|
+
"POST:/auth/sign-out",
|
|
30361
30494
|
{},
|
|
30362
30495
|
{
|
|
30363
|
-
pathPrefix: "/auth",
|
|
30364
30496
|
onSuccess: () => {
|
|
30365
30497
|
args.onSuccess();
|
|
30366
30498
|
mutate(null);
|
|
@@ -30374,10 +30506,9 @@ const defaultArgs = {
|
|
|
30374
30506
|
};
|
|
30375
30507
|
function useResetPassword(args = defaultArgs) {
|
|
30376
30508
|
return useMutation(
|
|
30377
|
-
"POST:/reset-password",
|
|
30509
|
+
"POST:/auth/reset-password",
|
|
30378
30510
|
{},
|
|
30379
30511
|
{
|
|
30380
|
-
pathPrefix: "/auth",
|
|
30381
30512
|
onSuccess: () => {
|
|
30382
30513
|
args.onSuccess();
|
|
30383
30514
|
}
|
|
@@ -30387,10 +30518,9 @@ function useResetPassword(args = defaultArgs) {
|
|
|
30387
30518
|
function useUser() {
|
|
30388
30519
|
const { auth } = useContext(ServerDataContext);
|
|
30389
30520
|
const { data, loading, error } = useQuery(
|
|
30390
|
-
"GET:/me",
|
|
30521
|
+
"GET:/auth/me",
|
|
30391
30522
|
{ params: {}, query: {} },
|
|
30392
30523
|
{
|
|
30393
|
-
pathPrefix: "/auth",
|
|
30394
30524
|
fallbackData: auth.user ? { user: auth == null ? void 0 : auth.user } : null
|
|
30395
30525
|
}
|
|
30396
30526
|
);
|
|
@@ -30399,6 +30529,38 @@ function useUser() {
|
|
|
30399
30529
|
}
|
|
30400
30530
|
return { user: data == null ? void 0 : data.user, loading, error };
|
|
30401
30531
|
}
|
|
30532
|
+
function useScopedTranslator(scope) {
|
|
30533
|
+
const { translations } = useContext(I18nContext);
|
|
30534
|
+
return (key, ...args) => {
|
|
30535
|
+
const [params = {}] = args;
|
|
30536
|
+
const _scope = translations[scope];
|
|
30537
|
+
const translation = _scope == null ? void 0 : _scope[key];
|
|
30538
|
+
if (!translation) {
|
|
30539
|
+
return key;
|
|
30540
|
+
}
|
|
30541
|
+
return applyParams(translation, params);
|
|
30542
|
+
};
|
|
30543
|
+
}
|
|
30544
|
+
function applyParams(str, params) {
|
|
30545
|
+
return str.replace(/{([^}]+)}/g, (_2, key) => {
|
|
30546
|
+
const value = params[key];
|
|
30547
|
+
if (value === void 0) {
|
|
30548
|
+
throw new Error(`Missing parameter: ${key}`);
|
|
30549
|
+
}
|
|
30550
|
+
return value;
|
|
30551
|
+
});
|
|
30552
|
+
}
|
|
30553
|
+
function useLocale() {
|
|
30554
|
+
const { changeLocale, locale, fetchTranslations } = useContext(I18nContext);
|
|
30555
|
+
const { getRoutePathnameFromHref } = useContext(ClientRouterContext);
|
|
30556
|
+
const { pathname } = useLocation();
|
|
30557
|
+
const setLocale = async (locale2) => {
|
|
30558
|
+
const x2 = getRoutePathnameFromHref(pathname);
|
|
30559
|
+
await fetchTranslations(x2, locale2);
|
|
30560
|
+
changeLocale(locale2);
|
|
30561
|
+
};
|
|
30562
|
+
return [locale, setLocale];
|
|
30563
|
+
}
|
|
30402
30564
|
export {
|
|
30403
30565
|
Form,
|
|
30404
30566
|
FormError,
|
|
@@ -30409,6 +30571,7 @@ export {
|
|
|
30409
30571
|
createRoot,
|
|
30410
30572
|
init,
|
|
30411
30573
|
useForgotPassword,
|
|
30574
|
+
useLocale,
|
|
30412
30575
|
useLocation,
|
|
30413
30576
|
useMutation,
|
|
30414
30577
|
useMutationStatus,
|
|
@@ -30416,6 +30579,7 @@ export {
|
|
|
30416
30579
|
useQuery,
|
|
30417
30580
|
useResetPassword,
|
|
30418
30581
|
useRouter,
|
|
30582
|
+
useScopedTranslator,
|
|
30419
30583
|
useSearchParams,
|
|
30420
30584
|
useSignIn,
|
|
30421
30585
|
useSignOut,
|
package/dist/client/rpc.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type AuthApiRouter } from "../auth/AuthenticationServiceProvider";
|
|
2
|
-
import { type ViewHandler } from "../http/ViewRouter";
|
|
1
|
+
import { type AuthApiRouter, type AuthViewRouter } from "../auth/AuthenticationServiceProvider";
|
|
3
2
|
import type { CreateRPC } from "../http/ApiRouter";
|
|
4
|
-
|
|
3
|
+
import type { CreateViewRPC } from "../http/ViewRouter";
|
|
4
|
+
export interface RPC extends CreateRPC<AuthApiRouter, "/auth"> {
|
|
5
5
|
}
|
|
6
|
-
export interface ViewRPC {
|
|
6
|
+
export interface ViewRPC extends CreateViewRPC<AuthViewRouter, "/auth"> {
|
|
7
|
+
}
|
|
8
|
+
export interface I18nDictionary {
|
|
7
9
|
}
|
|
8
|
-
export type ViewProps<T extends keyof ViewRPC> = ViewRPC[T] extends ViewHandler<infer I, infer O, infer P> ? O : never;
|
|
9
10
|
//# sourceMappingURL=rpc.d.ts.map
|