gt-react 3.0.0 → 3.0.2

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 (35) hide show
  1. package/dist/I18N/createI18NComponent.d.ts +1 -1
  2. package/dist/I18N/createI18NComponent.d.ts.map +1 -1
  3. package/dist/I18N/createI18NComponent.js +1 -1
  4. package/dist/I18N/createI18NComponent.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/server/ServerI18N.d.ts +12 -0
  8. package/dist/server/ServerI18N.d.ts.map +1 -0
  9. package/dist/server/ServerI18N.js +84 -0
  10. package/dist/server/ServerI18N.js.map +1 -0
  11. package/dist/server/createI18NComponent.d.ts +9 -0
  12. package/dist/server/createI18NComponent.d.ts.map +1 -0
  13. package/dist/server/createI18NComponent.js +29 -0
  14. package/dist/server/createI18NComponent.js.map +1 -0
  15. package/dist/server/helpers/addGTIdentifier.d.ts +11 -0
  16. package/dist/server/helpers/addGTIdentifier.d.ts.map +1 -0
  17. package/dist/server/helpers/addGTIdentifier.js +158 -0
  18. package/dist/server/helpers/addGTIdentifier.js.map +1 -0
  19. package/dist/server/helpers/generateHash.d.ts +12 -0
  20. package/dist/server/helpers/generateHash.d.ts.map +1 -0
  21. package/dist/server/helpers/generateHash.js +34 -0
  22. package/dist/server/helpers/generateHash.js.map +1 -0
  23. package/dist/server/helpers/writeChildrenAsObjects.d.ts +11 -0
  24. package/dist/server/helpers/writeChildrenAsObjects.d.ts.map +1 -0
  25. package/dist/server/helpers/writeChildrenAsObjects.js +129 -0
  26. package/dist/server/helpers/writeChildrenAsObjects.js.map +1 -0
  27. package/dist/server/renderChildren.d.ts +24 -0
  28. package/dist/server/renderChildren.d.ts.map +1 -0
  29. package/dist/server/renderChildren.js +180 -0
  30. package/dist/server/renderChildren.js.map +1 -0
  31. package/dist/server/resolvers/I18NResolver.d.ts +16 -0
  32. package/dist/server/resolvers/I18NResolver.d.ts.map +1 -0
  33. package/dist/server/resolvers/I18NResolver.js +59 -0
  34. package/dist/server/resolvers/I18NResolver.js.map +1 -0
  35. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import I18NConfiguration from "../config/I18NConfiguration";
2
- export default function createI18NComponent({ I18NConfig, getLocale, ...metadata }: {
2
+ export default function createI18NComponent({ I18NConfig, ...metadata }: {
3
3
  I18NConfig: I18NConfiguration;
4
4
  [key: string]: any;
5
5
  }): ({ children, ...props }: {
@@ -1 +1 @@
1
- {"version":3,"file":"createI18NComponent.d.ts","sourceRoot":"","sources":["../../src/i18n/createI18NComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAE5D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EACxC,UAAU,EAAE,SAAS,EAAE,GAAG,QAAQ,EACrC,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,4BACpB;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,6CAKzE"}
1
+ {"version":3,"file":"createI18NComponent.d.ts","sourceRoot":"","sources":["../../src/i18n/createI18NComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAE5D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EACxC,UAAU,EAAE,GAAG,QAAQ,EAC1B,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,4BACpB;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,6CAKzE"}
@@ -18,7 +18,7 @@ exports.default = createI18NComponent;
18
18
  const jsx_runtime_1 = require("react/jsx-runtime");
19
19
  const ServerI18N_1 = __importDefault(require("./ServerI18N"));
20
20
  function createI18NComponent(_a) {
21
- var { I18NConfig, getLocale } = _a, metadata = __rest(_a, ["I18NConfig", "getLocale"]);
21
+ var { I18NConfig } = _a, metadata = __rest(_a, ["I18NConfig"]);
22
22
  return (_a) => {
23
23
  var { children } = _a, props = __rest(_a, ["children"]);
24
24
  const locale = I18NConfig.getLocale();
@@ -1 +1 @@
1
- {"version":3,"file":"createI18NComponent.js","sourceRoot":"","sources":["../../src/i18n/createI18NComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,sCAQC;;AAXD,8DAAsC;AAGtC,SAAwB,mBAAmB,CAAC,EAEY;QAFZ,EACxC,UAAU,EAAE,SAAS,OAC+B,EAD1B,QAAQ,cADM,2BAE3C,CADqC;IAElC,OAAO,CAAC,EAA8D,EAAE,EAAE;YAAlE,EAAE,QAAQ,OAAoD,EAA/C,KAAK,cAApB,YAAsB,CAAF;QACxB,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;QACtC,uCAAuC;QACvC,OAAO,uBAAC,oBAAU,kBAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAM,QAAQ,EAAM,KAAK,cAAG,QAAQ,IAAc,CAAA;IAC/G,CAAC,CAAA;AACL,CAAC"}
1
+ {"version":3,"file":"createI18NComponent.js","sourceRoot":"","sources":["../../src/i18n/createI18NComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,sCAQC;;AAXD,8DAAsC;AAGtC,SAAwB,mBAAmB,CAAC,EAEY;QAFZ,EACxC,UAAU,OAC0C,EADrC,QAAQ,cADiB,cAE3C,CAD0B;IAEvB,OAAO,CAAC,EAA8D,EAAE,EAAE;YAAlE,EAAE,QAAQ,OAAoD,EAA/C,KAAK,cAApB,YAAsB,CAAF;QACxB,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;QACtC,uCAAuC;QACvC,OAAO,uBAAC,oBAAU,kBAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAM,QAAQ,EAAM,KAAK,cAAG,QAAQ,IAAc,CAAA;IAC/G,CAAC,CAAA;AACL,CAAC"}
package/dist/index.js CHANGED
@@ -18,9 +18,9 @@ exports.createGT = createGT;
18
18
  exports.createVariables = createVariables;
19
19
  require("server-only");
20
20
  const getDefaultFromEnv_1 = __importDefault(require("./local/getDefaultFromEnv"));
21
+ const createI18NComponent_1 = __importDefault(require("./server/createI18NComponent"));
21
22
  const I18NConfiguration_1 = __importDefault(require("./config/I18NConfiguration"));
22
23
  const createIntlFunction_1 = __importDefault(require("./intl/createIntlFunction"));
23
- const createI18NComponent_1 = __importDefault(require("./i18n/createI18NComponent"));
24
24
  const createGTProviderComponent_1 = __importDefault(require("./client/createGTProviderComponent"));
25
25
  const createTFunction_1 = __importDefault(require("./dictionary/createTFunction"));
26
26
  const createDictFunction_1 = __importDefault(require("./dictionary/createDictFunction"));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAsCA,4BAqFC;AAYD,0CA0BC;AAjKD,uBAAoB;AAEpB,kFAA0D;AAC1D,mFAA2D;AAC3D,mFAA2D;AAC3D,qFAA6D;AAC7D,mGAA2E;AAE3E,mFAA2D;AAC3D,yFAAiE;AACjE,mGAA2E;AAC3E,yGAAiF;AACjF,sHAA8F;AAC9F,wIAAgH;AAChH,kIAA0G;AAC1G,8IAAsH;AAItH;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,QAAQ,CAAC,KAoBE;IACvB,MAAM,EAAE,IAAA,2BAAiB,EAAC,YAAY,CAAC;IACvC,SAAS,EAAE,IAAA,2BAAiB,EAAC,eAAe,CAAC;IAC7C,QAAQ,EAAE,uBAAuB;IACjC,OAAO,EAAE,sBAAsB;IAC/B,eAAe,EAAE,EAAE;IACnB,aAAa,EAAE,IAAI;IACnB,SAA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gCAAsB,EAAC,SAAS,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,IAAA,iCAAuB,GAAE,CAAC;IAC3C,MAAM,cAAc,GAAG,IAAA,uCAA6B,EAAC,SAAS,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,IAAA,qCAA2B,EAAC,SAAS,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,IAAA,yCAA+B,EAAC,SAAS,CAAC,CAAC;IAEpE,OAAO;QACH,KAAK,EAAE,OAAO,EAAE,QAAQ;QACxB,cAAc,EAAE,YAAY,EAAE,gBAAgB;KACjD,CAAA;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ import I18NConfiguration from '../config/I18NConfiguration.js';
3
+ type ServerI18NProps = {
4
+ I18NConfig: I18NConfiguration;
5
+ children: any;
6
+ locale: string;
7
+ id?: string;
8
+ [key: string]: any;
9
+ };
10
+ export default function ServerI18N({ I18NConfig, children, locale, ...props }: ServerI18NProps): Promise<ReactNode>;
11
+ export {};
12
+ //# sourceMappingURL=ServerI18N.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerI18N.d.ts","sourceRoot":"","sources":["../../src/server/ServerI18N.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAOxC,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAE/D,KAAK,eAAe,GAAG;IACnB,UAAU,EAAE,iBAAiB,CAAA;IAC7B,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AAED,wBAA8B,UAAU,CAAC,EACrC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EACzC,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAgFtC"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.default = ServerI18N;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const addGTIdentifier_js_1 = __importDefault(require("./helpers/addGTIdentifier.js"));
29
+ const writeChildrenAsObjects_js_1 = __importDefault(require("./helpers/writeChildrenAsObjects.js"));
30
+ const generateHash_js_1 = __importDefault(require("./helpers/generateHash.js"));
31
+ const renderChildren_js_1 = __importDefault(require("./renderChildren.js"));
32
+ const I18NResolver_js_1 = __importDefault(require("./resolvers/I18NResolver.js"));
33
+ const generaltranslation_1 = require("generaltranslation");
34
+ function ServerI18N(_a) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ var { I18NConfig, children, locale } = _a, props = __rest(_a, ["I18NConfig", "children", "locale"]);
37
+ // Handle case where translation is not required, for example if the user's browser is in the default locale
38
+ const translationRequired = (children && I18NConfig.translationRequired(locale)) ? true : false;
39
+ if (!translationRequired) {
40
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
41
+ }
42
+ // Fetch translations
43
+ const translationsPromise = I18NConfig.getTranslations(locale, props.dictionaryName);
44
+ const defaultLocale = I18NConfig.getDefaultLocale();
45
+ let renderAttributes = {};
46
+ const dir = (0, generaltranslation_1.getLanguageDirection)(locale);
47
+ if (dir === 'rtl')
48
+ renderAttributes = Object.assign(Object.assign({}, renderAttributes), { dir });
49
+ const taggedChildren = (0, addGTIdentifier_js_1.default)(children);
50
+ const childrenAsObjects = (0, writeChildrenAsObjects_js_1.default)(taggedChildren);
51
+ const key = yield (0, generateHash_js_1.default)(childrenAsObjects);
52
+ const id = props.id ? props.id : key;
53
+ const translations = yield translationsPromise;
54
+ const translation = (translations && translations[id] && translations[id].k === key) ? translations[id].t : null;
55
+ // Check if a translation for this site already exists and return it if it does
56
+ const translationExists = translation ? true : false;
57
+ if (translationExists) {
58
+ const I18NChildren = (0, renderChildren_js_1.default)({ source: taggedChildren, target: translation, renderAttributes, locale, defaultLocale });
59
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: I18NChildren }));
60
+ }
61
+ // Create a new translation for this site and render it
62
+ const I18NChildrenPromise = I18NConfig.translateChildren({ children: childrenAsObjects, targetLanguage: locale, metadata: Object.assign({}, props) });
63
+ const renderMethod = (props === null || props === void 0 ? void 0 : props.renderMethod) || I18NConfig.getRenderMethod();
64
+ if (renderMethod === "replace") {
65
+ // Return the site in the default language
66
+ // Replace with translated site when ready
67
+ const InnerResolver = () => __awaiter(this, void 0, void 0, function* () {
68
+ const I18NChildren = yield I18NChildrenPromise;
69
+ return (0, renderChildren_js_1.default)({ source: taggedChildren, target: I18NChildren, renderAttributes, locale, defaultLocale });
70
+ });
71
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(I18NResolver_js_1.default, { fallback: children, children: (0, jsx_runtime_1.jsx)(InnerResolver, {}) }) }));
72
+ }
73
+ if (renderMethod === "hang") {
74
+ // Wait until the site is translated to return
75
+ const I18NChildren = (0, renderChildren_js_1.default)({ source: taggedChildren, target: yield I18NChildrenPromise, renderAttributes, locale, defaultLocale });
76
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: I18NChildren }));
77
+ }
78
+ return (
79
+ // return the children, with no special rendering
80
+ // a translation may be available from a cached translation dictionary next time the component is loaded
81
+ (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
82
+ });
83
+ }
84
+ //# sourceMappingURL=ServerI18N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerI18N.js","sourceRoot":"","sources":["../../src/server/ServerI18N.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,6BAkFC;;AAlGD,sFAA2D;AAC3D,oGAAyE;AACzE,gFAAqD;AACrD,4EAAiD;AACjD,kFAAuD;AACvD,2DAA0D;AAW1D,SAA8B,UAAU,CAAC,EAEvB;;YAFuB,EACrC,UAAU,EAAE,QAAQ,EAAE,MAAM,OACd,EADmB,KAAK,cADD,oCAExC,CADyC;QAGtC,4GAA4G;QAC5G,MAAM,mBAAmB,GAAY,CAAC,QAAQ,IAAI,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QACzG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACvB,OAAO,CACH,2DACK,QAAQ,GACV,CACN,CAAA;QACL,CAAC;QAED,qBAAqB;QACrB,MAAM,mBAAmB,GAAG,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;QAErF,MAAM,aAAa,GAAG,UAAU,CAAC,gBAAgB,EAAE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,oBAAO,KAAK,CAAE,EAAE,CAAC,CAAC;QAC1I,MAAM,YAAY,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAAY,KAAI,UAAU,CAAC,eAAe,EAAE,CAAC;QAEzE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC7B,0CAA0C;YAC1C,0CAA0C;YAE1C,MAAM,aAAa,GAAG,GAAS,EAAE;gBAC7B,MAAM,YAAY,GAAG,MAAM,mBAAmB,CAAC;gBAC/C,OAAO,IAAA,2BAAc,EAAC,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;YACrH,CAAC,CAAA,CAAA;YAED,OAAO,CACH,2DAEI,uBAAC,yBAAY,IAAC,QAAQ,EAAE,QAAQ,YAAE,uBAAC,aAAa,KAAE,GAAe,GAClE,CACN,CAAA;QACL,CAAC;QAED,IAAI,YAAY,KAAK,MAAM,EAAE,CAAC;YAC1B,8CAA8C;YAC9C,MAAM,YAAY,GAAG,IAAA,2BAAc,EAAC,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;YAC5I,OAAO,CACH,2DACK,YAAY,GACd,CACN,CAAA;QACL,CAAC;QAED,OAAO;QACH,iDAAiD;QACjD,wGAAwG;QACxG,2DACK,QAAQ,GACV,CACN,CAAA;IAEL,CAAC;CAAA"}
@@ -0,0 +1,9 @@
1
+ import I18NConfiguration from "../config/I18NConfiguration";
2
+ export default function createI18NComponent({ I18NConfig, ...metadata }: {
3
+ I18NConfig: I18NConfiguration;
4
+ [key: string]: any;
5
+ }): ({ children, ...props }: {
6
+ children?: any;
7
+ [key: string]: any;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=createI18NComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createI18NComponent.d.ts","sourceRoot":"","sources":["../../src/server/createI18NComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAE5D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EACxC,UAAU,EAAE,GAAG,QAAQ,EAC1B,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,4BACpB;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,6CAKzE"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.default = createI18NComponent;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const ServerI18N_1 = __importDefault(require("./ServerI18N"));
20
+ function createI18NComponent(_a) {
21
+ var { I18NConfig } = _a, metadata = __rest(_a, ["I18NConfig"]);
22
+ return (_a) => {
23
+ var { children } = _a, props = __rest(_a, ["children"]);
24
+ const locale = I18NConfig.getLocale();
25
+ /* @ts-expect-error Server Component */
26
+ return (0, jsx_runtime_1.jsx)(ServerI18N_1.default, Object.assign({ I18NConfig: I18NConfig, locale: locale }, metadata, props, { children: children }));
27
+ };
28
+ }
29
+ //# sourceMappingURL=createI18NComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createI18NComponent.js","sourceRoot":"","sources":["../../src/server/createI18NComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,sCAQC;;AAXD,8DAAsC;AAGtC,SAAwB,mBAAmB,CAAC,EAEY;QAFZ,EACxC,UAAU,OAC0C,EADrC,QAAQ,cADiB,cAE3C,CAD0B;IAEvB,OAAO,CAAC,EAA8D,EAAE,EAAE;YAAlE,EAAE,QAAQ,OAAoD,EAA/C,KAAK,cAApB,YAAsB,CAAF;QACxB,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;QACtC,uCAAuC;QACvC,OAAO,uBAAC,oBAAU,kBAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAM,QAAQ,EAAM,KAAK,cAAG,QAAQ,IAAc,CAAA;IAC/G,CAAC,CAAA;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import React, { ReactNode } from 'react';
2
+ type Child = ReactNode | Record<string, any>;
3
+ type Children = Child[] | Child;
4
+ /**
5
+ * Main function to add GT (General Translation) identifiers to the children
6
+ * @param children - The children elements to which GT identifiers will be added
7
+ * @returns - The children with added GT identifiers
8
+ */
9
+ export default function addGTIdentifier(children: Children): string | number | boolean | Record<string, any> | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | (string | number | boolean | Record<string, any> | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined)[] | null | undefined;
10
+ export {};
11
+ //# sourceMappingURL=addGTIdentifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addGTIdentifier.d.ts","sourceRoot":"","sources":["../../../src/server/helpers/addGTIdentifier.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAgB,MAAM,OAAO,CAAA;AAGtD,KAAK,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC7C,KAAK,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;AAkBhC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,QAAQ,EAAE,QAAQ,iVAkJzD"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.default = addGTIdentifier;
18
+ const react_1 = __importDefault(require("react"));
19
+ const processBranches_1 = __importDefault(require("../../primitives/value/processBranches"));
20
+ /**
21
+ * Helper function to validate the properties of the component to prevent nested translations
22
+ * @param props - The properties of the current React element
23
+ */
24
+ const validateProps = (props) => {
25
+ if (props && props['data-generaltranslation'] && typeof props['data-generaltranslation'].id === 'number') {
26
+ throw new Error(`Nesting of I18N components is not permitted. This prevents components from being translated twice.
27
+ Found nested component with ID: ${props['data-generaltranslation'].id}`);
28
+ }
29
+ };
30
+ /**
31
+ * Main function to add GT (General Translation) identifiers to the children
32
+ * @param children - The children elements to which GT identifiers will be added
33
+ * @returns - The children with added GT identifiers
34
+ */
35
+ function addGTIdentifier(children) {
36
+ // Object to keep track of the current index for GT IDs
37
+ let indexObject = { index: 0 };
38
+ /**
39
+ * Function to create a GTProp object for a ReactElement
40
+ * @param child - The ReactElement for which the GTProp is created
41
+ * @returns - The GTProp object
42
+ */
43
+ const createGTProp = (child) => {
44
+ const { type, props } = child;
45
+ indexObject.index += 1;
46
+ let result = { id: indexObject.index };
47
+ const transformation = typeof type === 'function' ? (type.gtTransformation || '') : '';
48
+ if (transformation) {
49
+ const transformationParts = transformation.split('-');
50
+ if (transformationParts[0] === "variable") {
51
+ result.variableType = (transformationParts === null || transformationParts === void 0 ? void 0 : transformationParts[1]) || "variable";
52
+ }
53
+ result.transformation = transformationParts[0];
54
+ if (transformation === "private") {
55
+ if (typeof props.label === 'string') {
56
+ result.label = props.label;
57
+ }
58
+ }
59
+ }
60
+ return result;
61
+ };
62
+ /**
63
+ * Function to handle valid React elements and add GT identifiers
64
+ * @param child - The ReactElement to handle
65
+ * @returns - The new ReactElement with added GT identifiers
66
+ */
67
+ const handleValidReactElement = (child) => {
68
+ // Destructure the props from the child element
69
+ const { props } = child;
70
+ // Validate the props to ensure there are no nested translations
71
+ validateProps(props);
72
+ // Create new props for the element, including the GT identifier and a key
73
+ let generaltranslation = createGTProp(child);
74
+ let newProps = Object.assign(Object.assign({}, props), { 'data-generaltranslation': generaltranslation, key: generaltranslation.id });
75
+ // If branches are needed for a number or value variable
76
+ const transformation = generaltranslation.transformation;
77
+ if (transformation === "numeric" || transformation === "value") {
78
+ // Updates indices to keep a consistent identification system across branches
79
+ let frozenIndex = indexObject.index;
80
+ let championIndex = indexObject.index;
81
+ const updateIndices = () => {
82
+ if (indexObject.index > frozenIndex) {
83
+ if (indexObject.index > championIndex) {
84
+ championIndex = indexObject.index;
85
+ }
86
+ indexObject.index = frozenIndex;
87
+ }
88
+ };
89
+ // Adds ID to children
90
+ if (props.children) {
91
+ newProps.children = addIdentifierRecursively(props.children);
92
+ }
93
+ // define branches
94
+ let branches = {};
95
+ // add identifier to number branches (e.g. singular, plural, ranges)
96
+ if (transformation === "numeric") {
97
+ const { n, children } = props, options = __rest(props, ["n", "children"]);
98
+ let { ranges } = options, others = __rest(options, ["ranges"]);
99
+ if (ranges)
100
+ branches.ranges = options.ranges.map((range) => {
101
+ updateIndices();
102
+ return { min: range.min, max: range.max, children: addIdentifierRecursively(range.children) };
103
+ });
104
+ for (const option of Object.keys(others)) {
105
+ updateIndices();
106
+ branches[option] = addIdentifierRecursively(others[option]);
107
+ }
108
+ newProps = Object.assign(Object.assign({}, newProps), branches);
109
+ }
110
+ // or add identifier to value branches, e.g. name={"Kernighan"}
111
+ else if (transformation === "value") {
112
+ const { "branches": rawBranches } = props;
113
+ if (rawBranches) {
114
+ branches = (0, processBranches_1.default)(rawBranches, (branch) => { updateIndices(); return addIdentifierRecursively(branch); });
115
+ }
116
+ newProps.branches = branches;
117
+ }
118
+ // modify newProps if necessary
119
+ if (Object.keys(branches).length > 0)
120
+ newProps['data-generaltranslation'].branches = branches;
121
+ if (newProps.children)
122
+ newProps['data-generaltranslation'].defaultChildren = newProps.children;
123
+ // reset index
124
+ indexObject.index = championIndex;
125
+ }
126
+ // if no transformation is required
127
+ if (!transformation) {
128
+ if (props.children) {
129
+ newProps.children = addIdentifierRecursively(props.children);
130
+ }
131
+ }
132
+ // return the element with new props
133
+ return react_1.default.cloneElement(child, newProps);
134
+ };
135
+ /**
136
+ * Function to handle a single child element and determine if it's a valid React element
137
+ * @param child - The child element to handle
138
+ * @returns - The handled child element
139
+ */
140
+ const handleSingleChild = (child) => {
141
+ if (react_1.default.isValidElement(child))
142
+ return handleValidReactElement(child);
143
+ return child;
144
+ };
145
+ /**
146
+ * Recursive function to add GT identifiers to all child elements
147
+ * @param children - The children elements to process
148
+ * @returns - The children elements with added GT identifiers
149
+ */
150
+ const addIdentifierRecursively = (children) => {
151
+ if (Array.isArray(children)) {
152
+ return children.map(child => handleSingleChild(child));
153
+ }
154
+ return handleSingleChild(children);
155
+ };
156
+ return addIdentifierRecursively(children);
157
+ }
158
+ //# sourceMappingURL=addGTIdentifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addGTIdentifier.js","sourceRoot":"","sources":["../../../src/server/helpers/addGT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AC,CAAC;IACvC,CAAC,CAAA;IAED,OAAO,wBAAwB,CAAC,QAAQ,CAAC,CAAC;AAE9C,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Generates a SHA-256 hash for the given message.
3
+ *
4
+ * @param {any} message - The message to be hashed. This can be of any type.
5
+ * If the message is an object or array, it will be
6
+ * converted to a JSON string.
7
+ * @returns {Promise<string>} A promise that resolves to the SHA-256 hash of the
8
+ * message in hexadecimal format. If the message is
9
+ * falsy, an empty string is returned.
10
+ */
11
+ export default function generateHash(message: any): Promise<string>;
12
+ //# sourceMappingURL=generateHash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateHash.d.ts","sourceRoot":"","sources":["../../../src/server/helpers/generateHash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAA8B,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxE"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.default = generateHash;
13
+ /**
14
+ * Generates a SHA-256 hash for the given message.
15
+ *
16
+ * @param {any} message - The message to be hashed. This can be of any type.
17
+ * If the message is an object or array, it will be
18
+ * converted to a JSON string.
19
+ * @returns {Promise<string>} A promise that resolves to the SHA-256 hash of the
20
+ * message in hexadecimal format. If the message is
21
+ * falsy, an empty string is returned.
22
+ */
23
+ function generateHash(message) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ message = JSON.stringify(message);
26
+ const msgBuffer = new TextEncoder().encode(message);
27
+ const hashBuffer = yield crypto.subtle.digest('SHA-256', msgBuffer);
28
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
29
+ const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
30
+ return hashHex;
31
+ });
32
+ }
33
+ ;
34
+ //# sourceMappingURL=generateHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateHash.js","sourceRoot":"","sources":["../../../src/server/helpers/generateHash.ts"],"names":[],"mappings":";;;;;;;;;;;AAUA,+BAOC;AAjBD;;;;;;;;;GASG;AACH,SAA8B,YAAY,CAAC,OAAY;;QACnD,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAClC,MAAM,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAc,CAAC,CAAC;QAC3D,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACpE,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7E,OAAO,OAAO,CAAC;IACnB,CAAC;CAAA;AAAA,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ type Child = ReactNode | Record<string, any>;
3
+ type Children = Child | Child[];
4
+ /**
5
+ * Transforms children elements into objects, processing each child recursively if needed.
6
+ * @param {Children} children - The children to process.
7
+ * @returns {object} - The processed children as objects.
8
+ */
9
+ export default function writeChildrenAsObjects(children: Children): any;
10
+ export {};
11
+ //# sourceMappingURL=writeChildrenAsObjects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeChildrenAsObjects.d.ts","sourceRoot":"","sources":["../../../src/server/helpers/writeChildrenAsObjects.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAgB,MAAM,OAAO,CAAA;AAItD,KAAK,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC7C,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;AA2GhC;;;;EAIE;AACF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAKtE"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.default = writeChildrenAsObjects;
18
+ const react_1 = __importDefault(require("react"));
19
+ const processBranches_1 = __importDefault(require("../../primitives/value/processBranches"));
20
+ const defaultVariableNames_1 = __importDefault(require("../../primitives/helpers/defaultVariableNames"));
21
+ /**
22
+ * Checks if the props indicate that the component should be not be processed.
23
+ * @param {Record<string, any>} props - The props to check.
24
+ * @returns {boolean} - True if the component is private, otherwise false.
25
+ */
26
+ const isPrivate = (props) => { var _a; return ((_a = props['data-generaltranslation']) === null || _a === void 0 ? void 0 : _a.transformation) === "private"; };
27
+ /**
28
+ * Gets the tag name of a React element.
29
+ * @param {ReactElement} child - The React element.
30
+ * @returns {string} - The tag name of the React element.
31
+ */
32
+ const getTagName = (child) => {
33
+ var _a;
34
+ if (!child)
35
+ return '';
36
+ const { type, props } = child;
37
+ if (type && typeof type === 'function') {
38
+ if ('displayName' in type && typeof type.displayName === 'string' && type.displayName)
39
+ return type.displayName;
40
+ if ('name' in type && typeof type.name === 'string' && type.name)
41
+ return type.name;
42
+ }
43
+ if (type && typeof type === 'string')
44
+ return type;
45
+ if (props.href)
46
+ return 'a';
47
+ if ((_a = props['data-generaltranslation']) === null || _a === void 0 ? void 0 : _a.id)
48
+ return `C${props['data-generaltranslation'].id}`;
49
+ return 'function';
50
+ };
51
+ /**
52
+ * Handles processing of a valid React element, transforming its properties and children as needed.
53
+ * @param {ReactElement} child - The React element to process.
54
+ * @returns {object} - The processed element with its type and transformed props.
55
+ */
56
+ const handleValidReactElement = (child) => {
57
+ const { type, props } = child;
58
+ let newProps = {};
59
+ // Transform children if they exist and are not private
60
+ if (props.children && !isPrivate(props)) {
61
+ newProps.children = writeChildrenAsObjects(props.children);
62
+ }
63
+ // Write the branches of 'data-generaltranslation' as objects
64
+ if (props['data-generaltranslation']) {
65
+ const generaltranslation = props['data-generaltranslation'];
66
+ let result = Object.assign({}, generaltranslation);
67
+ if (generaltranslation.transformation && generaltranslation.transformation === "variable") {
68
+ const variableName = props.name || defaultVariableNames_1.default[generaltranslation.variableType] || "value";
69
+ return { variable: generaltranslation.variableType || "variable", key: variableName };
70
+ }
71
+ // Write all the branches as objects
72
+ if (generaltranslation.transformation && generaltranslation.branches) {
73
+ const transformation = generaltranslation.transformation;
74
+ // Write the branches of a number variable transformation
75
+ if (transformation === "numeric") {
76
+ const _a = generaltranslation.branches, { ranges } = _a, others = __rest(_a, ["ranges"]);
77
+ if (ranges) {
78
+ result.branches.ranges = ranges.map((range) => {
79
+ return { min: range.min, max: range.max, children: writeChildrenAsObjects(range.children) };
80
+ });
81
+ }
82
+ for (const option of Object.keys(others)) {
83
+ result.branches[option] = writeChildrenAsObjects(others[option]);
84
+ }
85
+ }
86
+ // Write the branches of a value variable transformation
87
+ else if (transformation === "value") {
88
+ if (generaltranslation.branches) {
89
+ result.branches = (0, processBranches_1.default)(generaltranslation.branches, (branch) => writeChildrenAsObjects(branch));
90
+ }
91
+ }
92
+ // Write defaultChildren
93
+ if (generaltranslation.defaultChildren) {
94
+ result.defaultChildren = writeChildrenAsObjects(generaltranslation.defaultChildren);
95
+ }
96
+ }
97
+ newProps['data-generaltranslation'] = result;
98
+ }
99
+ return {
100
+ type: getTagName(child),
101
+ props: newProps
102
+ };
103
+ };
104
+ /**
105
+ * Handles processing of a single child, determining if it is a valid React element or an object.
106
+ * @param {any} child - The child to process.
107
+ * @returns {object} - The processed child or the original child if no transformation is needed.
108
+ */
109
+ const handleSingleChild = (child) => {
110
+ if (react_1.default.isValidElement(child))
111
+ return handleValidReactElement(child);
112
+ else if (child && typeof child === 'object') {
113
+ return { variable: true, keys: Object.keys(child) };
114
+ }
115
+ else
116
+ return child;
117
+ };
118
+ /**
119
+ * Transforms children elements into objects, processing each child recursively if needed.
120
+ * @param {Children} children - The children to process.
121
+ * @returns {object} - The processed children as objects.
122
+ */
123
+ function writeChildrenAsObjects(children) {
124
+ if (Array.isArray(children)) {
125
+ return children.map(child => handleSingleChild(child));
126
+ }
127
+ return handleSingleChild(children);
128
+ }
129
+ //# sourceMappingURL=writeChildrenAsObjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeChildrenAsObjects.js","sourceRoot":"","sources":["../../../src/server/helpers/writeChildrenAsObjects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAqHA,yCAKC;AA1HD,kDAAsD;AACtD,6FAAqE;AACrE,yGAAiF;AAKjF;;;;GAIG;AACH,MAAM,SAAS,GAAG,CAAC,KAA0B,EAAW,EAAE,WAAC,OAAA,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,CAAC,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1D,CAAC;IACD,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAA;AACtC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { ReactNode } from 'react';
2
+ type TargetElement = Record<string, any>;
3
+ type TargetChild = TargetElement | string | number | boolean | object;
4
+ type Target = TargetChild | TargetChild[];
5
+ type SourceChild = ReactNode | Record<string, any>;
6
+ type Source = SourceChild | SourceChild[];
7
+ /**
8
+ * Renders children elements based on the provided source and target.
9
+ * Handles transformations and branching for number and value variables.
10
+ *
11
+ * @param {Source} source - The source elements to be rendered.
12
+ * @param {Target} [target] - The target elements that may alter the rendering of the source.
13
+ * @param {Record<string, Source>} [variables] - An optional set of variables for transformations and branching.
14
+ *
15
+ * @returns {ReactNode} The rendered children elements.
16
+ */
17
+ export default function renderChildren({ source, target, ...metadata }: {
18
+ source: Source;
19
+ target?: Target;
20
+ variables?: Record<string, Source>;
21
+ [key: string]: any;
22
+ }): ReactNode;
23
+ export {};
24
+ //# sourceMappingURL=renderChildren.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderChildren.d.ts","sourceRoot":"","sources":["../../src/server/renderChildren.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAA;AAWtD,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACzC,KAAK,WAAW,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AACtE,KAAK,MAAM,GAAG,WAAW,GAAG,WAAW,EAAE,CAAC;AAE1C,KAAK,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACnD,KAAK,MAAM,GAAG,WAAW,GAAG,WAAW,EAAE,CAAC;AA6E1C;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACnC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAC9B,EAAE;IACC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,GAAG,SAAS,CAoGZ"}
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.default = renderChildren;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const react_1 = __importDefault(require("react"));
20
+ const getNumericBranch_1 = __importDefault(require("../primitives/helpers/getNumericBranch"));
21
+ const getValueBranch_1 = __importDefault(require("../primitives/helpers/getValueBranch"));
22
+ const isValidReactNode_1 = __importDefault(require("../primitives/helpers/isValidReactNode"));
23
+ const Variable_1 = __importDefault(require("../primitives/variables/Variable/Variable"));
24
+ const DateVariable_1 = __importDefault(require("../primitives/variables/DateVariable/DateVariable"));
25
+ const NumberVariable_1 = __importDefault(require("../primitives/variables/NumberVariable/NumberVariable"));
26
+ const CurrencyVariable_1 = __importDefault(require("../primitives/variables/CurrencyVariable/CurrencyVariable"));
27
+ const defaultVariableNames_1 = __importDefault(require("../primitives/helpers/defaultVariableNames"));
28
+ /**
29
+ * Renders a React element based on the provided source and target elements.
30
+ * Handles transformation and variable branching if necessary.
31
+ *
32
+ * @param {ReactElement} sourceElement - The original React element to be rendered.
33
+ * @param {TargetElement} targetElement - The target element that may alter the rendering of the source element.
34
+ * @param {Record<string, Source>} variables - An optional set of variables for transformations and branching.
35
+ *
36
+ * @returns {ReactElement} The rendered React element.
37
+ */
38
+ const renderElement = (_a) => {
39
+ var _b, _c;
40
+ var { sourceElement, targetElement } = _a, metadata = __rest(_a, ["sourceElement", "targetElement"]);
41
+ const { props } = sourceElement;
42
+ if (((_b = props === null || props === void 0 ? void 0 : props['data-generaltranslation']) === null || _b === void 0 ? void 0 : _b.transformation) === "private") {
43
+ return sourceElement;
44
+ }
45
+ if (props.children) {
46
+ const { 'data-generaltranslation': generaltranslation } = props;
47
+ const targetProps = targetElement === null || targetElement === void 0 ? void 0 : targetElement.props;
48
+ const targetChildren = targetProps === null || targetProps === void 0 ? void 0 : targetProps.children;
49
+ const targetBranches = (_c = targetProps === null || targetProps === void 0 ? void 0 : targetProps['data-generaltranslation']) === null || _c === void 0 ? void 0 : _c.branches;
50
+ // If an alternative branch (from a transformation) is necessary
51
+ if ((generaltranslation === null || generaltranslation === void 0 ? void 0 : generaltranslation.transformation) && targetBranches) {
52
+ const transformation = generaltranslation.transformation;
53
+ // handle number variable branching
54
+ if (transformation === "numeric") {
55
+ const { 'data-generaltranslation': generaltranslation, n } = props, branches = __rest(props, ['data-generaltranslation', "n"]); // 'data-generaltranslation' necessary here to fully destructure relevant ...branches
56
+ const sourceBranch = (0, getNumericBranch_1.default)(n, metadata.locale || metadata.defaultLocale, branches) || props.children;
57
+ const targetBranch = (0, getNumericBranch_1.default)(n, metadata.locale || metadata.defaultLocale, targetBranches) || targetChildren;
58
+ const children = renderChildren(Object.assign({ source: sourceBranch, target: targetBranch, variables: Object.assign(Object.assign({}, metadata.variables), { n: n }) }, metadata));
59
+ return react_1.default.createElement('span', Object.assign(Object.assign({}, metadata.renderAttributes), { children: children }));
60
+ }
61
+ // or handle value variable branching
62
+ if (transformation === "value") {
63
+ const { 'data-generaltranslation': generaltranslation, branches } = props, values = __rest(props, ['data-generaltranslation', "branches"]); // 'data-generaltranslation' necessary here to fully destructure relevant ...values
64
+ const sourceBranch = (0, getValueBranch_1.default)(values, branches) || props.children;
65
+ const targetBranch = (0, getValueBranch_1.default)(values, targetBranches) || targetChildren;
66
+ const children = renderChildren(Object.assign({ source: sourceBranch, target: targetBranch, variables: Object.assign(Object.assign({}, metadata.variables), values) }, metadata));
67
+ return react_1.default.createElement('span', Object.assign(Object.assign({}, metadata.renderAttributes), { children: children }));
68
+ }
69
+ }
70
+ // otherwise, just clone the element
71
+ return react_1.default.cloneElement(sourceElement, Object.assign(Object.assign(Object.assign({}, props), metadata.renderAttributes), { children: renderChildren(Object.assign({ source: props.children, target: targetChildren }, metadata)) }));
72
+ }
73
+ return react_1.default.cloneElement(sourceElement, Object.assign(Object.assign({}, metadata.renderAttributes), sourceElement === null || sourceElement === void 0 ? void 0 : sourceElement.props));
74
+ };
75
+ /**
76
+ * Renders children elements based on the provided source and target.
77
+ * Handles transformations and branching for number and value variables.
78
+ *
79
+ * @param {Source} source - The source elements to be rendered.
80
+ * @param {Target} [target] - The target elements that may alter the rendering of the source.
81
+ * @param {Record<string, Source>} [variables] - An optional set of variables for transformations and branching.
82
+ *
83
+ * @returns {ReactNode} The rendered children elements.
84
+ */
85
+ function renderChildren(_a) {
86
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
87
+ var { source, target } = _a, metadata = __rest(_a, ["source", "target"]);
88
+ // Most straightforward case, return a valid React node
89
+ if ((target === null || typeof target === 'undefined') && (0, isValidReactNode_1.default)(source))
90
+ return source;
91
+ // Extremely important due to GTProvider and t() discrepancy on whether to use async intl()
92
+ if (typeof target !== null && typeof target !== 'undefined' && (0, isValidReactNode_1.default)(target))
93
+ return target;
94
+ // If target and source are both arrays of children
95
+ if (Array.isArray(source) && Array.isArray(target)) {
96
+ // Filter for variables and valid source children
97
+ let validSourceElements = [];
98
+ for (const sourceChild of source) {
99
+ if (((_c = (_b = sourceChild === null || sourceChild === void 0 ? void 0 : sourceChild.props) === null || _b === void 0 ? void 0 : _b['data-generaltranslation']) === null || _c === void 0 ? void 0 : _c.transformation) === "variable") {
100
+ const variableName = sourceChild.props.name || defaultVariableNames_1.default[(_e = (_d = sourceChild === null || sourceChild === void 0 ? void 0 : sourceChild.props) === null || _d === void 0 ? void 0 : _d['data-generaltranslation']) === null || _e === void 0 ? void 0 : _e.variableType];
101
+ const variableValue = sourceChild.props.defaultValue || sourceChild.props.children;
102
+ if (variableName && variableValue && typeof ((_f = metadata === null || metadata === void 0 ? void 0 : metadata.variables) === null || _f === void 0 ? void 0 : _f[variableName]) === 'undefined') {
103
+ metadata.variables = Object.assign(Object.assign({}, metadata.variables), { [variableName]: variableValue });
104
+ }
105
+ const variableType = ((_h = (_g = sourceChild === null || sourceChild === void 0 ? void 0 : sourceChild.props) === null || _g === void 0 ? void 0 : _g['data-generaltranslation']) === null || _h === void 0 ? void 0 : _h.variableType) || "variable";
106
+ if (variableType === "number" || variableType === "currency" || variableType === "date") {
107
+ const variableOptions = (_j = sourceChild === null || sourceChild === void 0 ? void 0 : sourceChild.props) === null || _j === void 0 ? void 0 : _j.options;
108
+ if (variableOptions)
109
+ metadata.variableOptions = Object.assign(Object.assign({}, metadata.variableOptions), { [variableName]: Object.assign({}, variableOptions) });
110
+ }
111
+ if (variableType === "currency") {
112
+ const variableCurrency = (_k = sourceChild === null || sourceChild === void 0 ? void 0 : sourceChild.props) === null || _k === void 0 ? void 0 : _k.currency;
113
+ if (variableCurrency)
114
+ metadata.variableOptions = Object.assign(Object.assign({}, metadata.variableOptions), { [variableName]: Object.assign({ currency: variableCurrency }, (_l = metadata.variableOptions) === null || _l === void 0 ? void 0 : _l[variableName]) });
115
+ }
116
+ }
117
+ else if (react_1.default.isValidElement(sourceChild)) {
118
+ validSourceElements.push(sourceChild);
119
+ }
120
+ }
121
+ // Find matching source elements based on ID
122
+ const findMatchingSource = (targetElement) => {
123
+ return validSourceElements.find(sourceChild => {
124
+ var _a, _b, _c;
125
+ const { props } = sourceChild;
126
+ if (typeof ((_a = props === null || props === void 0 ? void 0 : props['data-generaltranslation']) === null || _a === void 0 ? void 0 : _a.id) !== 'undefined') {
127
+ const sourceID = props['data-generaltranslation'].id;
128
+ const targetID = (_c = (_b = targetElement === null || targetElement === void 0 ? void 0 : targetElement.props) === null || _b === void 0 ? void 0 : _b['data-generaltranslation']) === null || _c === void 0 ? void 0 : _c.id;
129
+ return sourceID === targetID;
130
+ }
131
+ return false;
132
+ });
133
+ };
134
+ // Return targets
135
+ return target.map((targetChild, index) => {
136
+ var _a, _b, _c, _d, _e;
137
+ // Most straightforward case, return a valid React node
138
+ if ((0, isValidReactNode_1.default)(targetChild)) {
139
+ return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: targetChild }, `string_${index}`);
140
+ }
141
+ // If target is a variable
142
+ if ((targetChild === null || targetChild === void 0 ? void 0 : targetChild.variable) && typeof targetChild.key === 'string') {
143
+ const key = targetChild.key;
144
+ let value;
145
+ if (metadata.variables && (typeof metadata.variables[key] !== null && typeof metadata.variables[key] !== 'undefined')) {
146
+ value = metadata.variables[key];
147
+ }
148
+ if (targetChild.variable === "number") {
149
+ return (0, jsx_runtime_1.jsx)(NumberVariable_1.default, { locale: metadata.locale, defaultValue: value, name: key, options: Object.assign({}, (_a = metadata === null || metadata === void 0 ? void 0 : metadata.variableOptions) === null || _a === void 0 ? void 0 : _a[key]) }, `var_${index}`);
150
+ }
151
+ if (targetChild.variable === "date") {
152
+ return (0, jsx_runtime_1.jsx)(DateVariable_1.default, { locale: metadata.locale, defaultValue: value, name: key, options: Object.assign({}, (_b = metadata === null || metadata === void 0 ? void 0 : metadata.variableOptions) === null || _b === void 0 ? void 0 : _b[key]) }, `var_${index}`);
153
+ }
154
+ if (targetChild.variable === "currency") {
155
+ return (0, jsx_runtime_1.jsx)(CurrencyVariable_1.default, { locale: metadata.locale, defaultValue: value, name: key, currency: ((_d = (_c = metadata === null || metadata === void 0 ? void 0 : metadata.variableOptions) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.currency) || undefined, options: Object.assign({}, (_e = metadata === null || metadata === void 0 ? void 0 : metadata.variableOptions) === null || _e === void 0 ? void 0 : _e[key]) }, `var_${index}`);
156
+ }
157
+ return (0, jsx_runtime_1.jsx)(Variable_1.default, { defaultValue: (0, isValidReactNode_1.default)(value) ? value : undefined, name: key }, `var_${index}`);
158
+ }
159
+ // If target is a normal ReactElement
160
+ const matchingSource = findMatchingSource(targetChild);
161
+ if (react_1.default.isValidElement(matchingSource)) {
162
+ return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: renderElement(Object.assign({ sourceElement: matchingSource, targetElement: targetChild }, metadata)) }, `element_${index}`);
163
+ }
164
+ });
165
+ }
166
+ // Target is a single object, could be a component or a variable
167
+ if (typeof target === 'object') {
168
+ if (react_1.default.isValidElement(source)) {
169
+ return renderElement(Object.assign({ sourceElement: source, targetElement: target }, metadata));
170
+ }
171
+ if ((target === null || target === void 0 ? void 0 : target.variable) && (target === null || target === void 0 ? void 0 : target.keys) && typeof source === 'object' && source !== null) {
172
+ for (const key of target.keys) {
173
+ if (source.hasOwnProperty(key)) {
174
+ return source[key];
175
+ }
176
+ }
177
+ }
178
+ }
179
+ }
180
+ //# sourceMappingURL=renderChildren.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderChildren.js","sourceRoot":"","sources":["../../src/server/renderChildren.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuGA,iCA2GC;;AAlND,kDAAsD;AAEtD,8FAAsE;AACtE,0FAAkE;AAClE,8FAAqE;AACrE,yFAAgE;AAChE,qGAA4E;AAC5E,2GAAkF;AAClF,iHAAwF;AACxF,sGAA8E;AAS9E;;;;;;;;;GASG;AACH,MAAM,aAAa,GAAG,CAAC,EAA4M,EAA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5
+ }
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;
15
+ export {};
16
+ //# sourceMappingURL=I18NResolver.d.ts.map
@@ -0,0 +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,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,CA0C3F"}
@@ -0,0 +1,59 @@
1
+ "use strict";
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
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.default = I18NResolver;
14
+ const jsx_runtime_1 = require("react/jsx-runtime");
15
+ const react_1 = require("react");
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
+ */
25
+ function I18NResolver({ children, fallback }) {
26
+ const [resolvedChildren, setResolvedChildren] = (0, react_1.useState)(fallback);
27
+ const [hasError, setHasError] = (0, react_1.useState)(false);
28
+ (0, react_1.useEffect)(() => {
29
+ let isMounted = true;
30
+ const resolveChildren = () => __awaiter(this, void 0, void 0, function* () {
31
+ try {
32
+ const resolved = yield children;
33
+ if (isMounted) {
34
+ setResolvedChildren(resolved);
35
+ }
36
+ }
37
+ catch (error) {
38
+ console.error(error);
39
+ if (isMounted) {
40
+ setHasError(true);
41
+ }
42
+ }
43
+ });
44
+ if (children instanceof Promise) {
45
+ resolveChildren();
46
+ }
47
+ else {
48
+ setResolvedChildren(children);
49
+ }
50
+ return () => {
51
+ isMounted = false;
52
+ };
53
+ }, [children]);
54
+ if (hasError) {
55
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fallback });
56
+ }
57
+ return ((0, jsx_runtime_1.jsx)(react_2.Suspense, { fallback: fallback, children: resolvedChildren }));
58
+ }
59
+ //# sourceMappingURL=I18NResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"I18NResolver.js","sourceRoot":"","sources":["../../../src/server/resolvers/I18NResolver.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;;;;;;;AAkBZ,+BA0CC;;AA1DD,iCAA8D;AAC9D,iCAAiC;AAOjC;;;;;;;GAOG;AACH,SAAwB,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAqB;IAE1E,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAY,QAAQ,CAAC,CAAC;IAC9E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EA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