gt-react 2.0.188 → 2.0.190
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.
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
interface I18NResolverProps {
|
|
3
|
-
children: Promise<ReactNode>;
|
|
3
|
+
children: ReactNode | Promise<ReactNode>;
|
|
4
4
|
fallback: ReactNode;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* I18NResolver component handles the rendering of children which may be a promise.
|
|
8
|
+
* If the promise resolves, the children are rendered inside a Suspense component.
|
|
9
|
+
* If the promise fails, the fallback is rendered permanently.
|
|
10
|
+
*
|
|
11
|
+
* @param {I18NResolverProps} props - The properties for the component.
|
|
12
|
+
* @returns {JSX.Element} - The rendered component.
|
|
13
|
+
*/
|
|
14
|
+
export default function I18NResolver({ children, fallback }: I18NResolverProps): JSX.Element;
|
|
7
15
|
export {};
|
|
8
16
|
//# sourceMappingURL=I18NResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18NResolver.d.ts","sourceRoot":"","sources":["../../../src/server/resolvers/I18NResolver.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAG9D,UAAU,iBAAiB;IACvB,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"I18NResolver.d.ts","sourceRoot":"","sources":["../../../src/server/resolvers/I18NResolver.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAG9D,UAAU,iBAAiB;IACvB,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAwC3F"}
|
|
@@ -1,26 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
3
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
13
|
exports.default = I18NResolver;
|
|
5
14
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
15
|
const react_1 = require("react");
|
|
7
16
|
const react_2 = require("react");
|
|
17
|
+
/**
|
|
18
|
+
* I18NResolver component handles the rendering of children which may be a promise.
|
|
19
|
+
* If the promise resolves, the children are rendered inside a Suspense component.
|
|
20
|
+
* If the promise fails, the fallback is rendered permanently.
|
|
21
|
+
*
|
|
22
|
+
* @param {I18NResolverProps} props - The properties for the component.
|
|
23
|
+
* @returns {JSX.Element} - The rendered component.
|
|
24
|
+
*/
|
|
8
25
|
function I18NResolver({ children, fallback }) {
|
|
9
26
|
const [resolvedChildren, setResolvedChildren] = (0, react_1.useState)(null);
|
|
10
27
|
const [hasError, setHasError] = (0, react_1.useState)(false);
|
|
11
28
|
(0, react_1.useEffect)(() => {
|
|
12
29
|
let isMounted = true;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
30
|
+
const resolveChildren = () => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
try {
|
|
32
|
+
const resolved = yield children;
|
|
33
|
+
if (isMounted) {
|
|
34
|
+
setResolvedChildren(resolved);
|
|
35
|
+
}
|
|
17
36
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (isMounted) {
|
|
39
|
+
setHasError(true);
|
|
40
|
+
}
|
|
22
41
|
}
|
|
23
42
|
});
|
|
43
|
+
if (children instanceof Promise) {
|
|
44
|
+
resolveChildren();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setResolvedChildren(children);
|
|
48
|
+
}
|
|
24
49
|
return () => {
|
|
25
50
|
isMounted = false;
|
|
26
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18NResolver.js","sourceRoot":"","sources":["../../../src/server/resolvers/I18NResolver.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA
|
|
1
|
+
{"version":3,"file":"I18NResolver.js","sourceRoot":"","sources":["../../../src/server/resolvers/I18NResolver.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;;;;;;;AAkBZ,+BAwCC;;AAxDD,iCAA8D;AAC9D,iCAAiC;AAOjC;;;;;;;GAOG;AACH,SAAwB,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAqB;IAC1E,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAmB,IAAI,CAAC,CAAC;IACjF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEhD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,SAAS,GAAG,IAAI,CAAC;QAErB,MAAM,eAAe,GAAG,GAAS,EAAE;YAC/B,IAAI,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC;gBAChC,IAAI,SAAS,EAAE,CAAC;oBACZ,mBAAmB,C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