gt-next 11.0.3 → 11.0.4
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/CHANGELOG.md +16 -0
- package/dist/condition-store/AsyncConditionStore.d.ts.map +1 -1
- package/dist/condition-store/AsyncConditionStore.js +1 -4
- package/dist/condition-store/AsyncConditionStore.js.map +1 -1
- package/dist/condition-store/AsyncConditionStore.mjs +2 -5
- package/dist/condition-store/AsyncConditionStore.mjs.map +1 -1
- package/dist/errors/createErrors.d.ts +2 -0
- package/dist/errors/createErrors.d.ts.map +1 -1
- package/dist/errors/createErrors.js +19 -1
- package/dist/errors/createErrors.js.map +1 -1
- package/dist/errors/createErrors.mjs +18 -2
- package/dist/errors/createErrors.mjs.map +1 -1
- package/dist/errors/ssg.d.ts +1 -0
- package/dist/errors/ssg.d.ts.map +1 -1
- package/dist/errors/ssg.js +9 -1
- package/dist/errors/ssg.js.map +1 -1
- package/dist/errors/ssg.mjs +7 -1
- package/dist/errors/ssg.mjs.map +1 -1
- package/dist/index.client.d.ts +3 -1
- package/dist/index.client.d.ts.map +1 -1
- package/dist/index.client.js +5 -0
- package/dist/index.client.js.map +1 -1
- package/dist/index.client.mjs +5 -1
- package/dist/index.client.mjs.map +1 -1
- package/dist/index.rsc.d.ts +7 -1
- package/dist/index.rsc.d.ts.map +1 -1
- package/dist/index.rsc.js +8 -0
- package/dist/index.rsc.js.map +1 -1
- package/dist/index.rsc.mjs +9 -2
- package/dist/index.rsc.mjs.map +1 -1
- package/dist/index.server.d.ts +2 -0
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.server.js +2 -0
- package/dist/index.server.js.map +1 -1
- package/dist/index.server.mjs +2 -1
- package/dist/index.server.mjs.map +1 -1
- package/dist/index.types.d.ts +7 -1
- package/dist/index.types.d.ts.map +1 -1
- package/dist/index.types.js +8 -0
- package/dist/index.types.js.map +1 -1
- package/dist/index.types.mjs +8 -1
- package/dist/index.types.mjs.map +1 -1
- package/dist/middleware-dir/utils.d.ts.map +1 -1
- package/dist/middleware-dir/utils.js +2 -4
- package/dist/middleware-dir/utils.js.map +1 -1
- package/dist/middleware-dir/utils.mjs +2 -4
- package/dist/middleware-dir/utils.mjs.map +1 -1
- package/dist/pages-dir/parseLocale.d.ts.map +1 -1
- package/dist/pages-dir/parseLocale.js +2 -4
- package/dist/pages-dir/parseLocale.js.map +1 -1
- package/dist/pages-dir/parseLocale.mjs +2 -4
- package/dist/pages-dir/parseLocale.mjs.map +1 -1
- package/dist/pages-dir/withGTStaticProps.d.ts +18 -0
- package/dist/pages-dir/withGTStaticProps.d.ts.map +1 -0
- package/dist/pages-dir/withGTStaticProps.js +34 -0
- package/dist/pages-dir/withGTStaticProps.js.map +1 -0
- package/dist/pages-dir/withGTStaticProps.mjs +32 -0
- package/dist/pages-dir/withGTStaticProps.mjs.map +1 -0
- package/dist/utils/client-boundary.js +1 -1
- package/dist/utils/client-boundary.js.map +1 -1
- package/dist/utils/client-boundary.mjs +2 -2
- package/dist/utils/client-boundary.mjs.map +1 -1
- package/package.json +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# gt-next
|
|
2
2
|
|
|
3
|
+
## 11.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1847](https://github.com/generaltranslation/gt/pull/1847) [`d8938b6`](https://github.com/generaltranslation/gt/commit/d8938b68ed8247b304d0cc0c22db3d3cc3a0b2ac) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add `withGTStaticProps()` for hydrating each statically generated Pages Router locale with its relevant translation snapshot. Pages Router locale routing is required so Next.js generates the page once per locale.
|
|
8
|
+
|
|
9
|
+
- [#1848](https://github.com/generaltranslation/gt/pull/1848) [`1f33d5f`](https://github.com/generaltranslation/gt/commit/1f33d5f76ffc879d2d21aa2508e07e1d3b66c4e3) Thanks [@bgub](https://github.com/bgub)! - Remove unused dependencies: `@generaltranslation/supported-locales` from gt-react, gt-next, gt-i18n, and @generaltranslation/react-core, and `@generaltranslation/format` from gt-react. Nothing in these packages imports them, so this only reduces install weight.
|
|
10
|
+
|
|
11
|
+
- [#1851](https://github.com/generaltranslation/gt/pull/1851) [`604889b`](https://github.com/generaltranslation/gt/commit/604889bf0cb833ecafbbe2febae842c81e161d10) Thanks [@bgub](https://github.com/bgub)! - Make `@generaltranslation/compiler` an optional peer dependency instead of a hard dependency. It is only used by the experimental `experimentalCompilerOptions.type: 'babel'` webpack path, which already degrades gracefully with a warning when the package cannot be resolved. Users who enable the experimental babel compiler must now install `@generaltranslation/compiler` themselves; everyone else saves ~8.5MB of install weight (the compiler plus its Babel toolchain).
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`006e071`](https://github.com/generaltranslation/gt/commit/006e071bf87ffe80f2d18958ddfa8f18cc2d85d2), [`7fb4a74`](https://github.com/generaltranslation/gt/commit/7fb4a74c52065694a40deafcf4596acc09e17f58), [`d23766c`](https://github.com/generaltranslation/gt/commit/d23766c78a2c1be278d85e896d2521453734a6eb), [`1f33d5f`](https://github.com/generaltranslation/gt/commit/1f33d5f76ffc879d2d21aa2508e07e1d3b66c4e3)]:
|
|
14
|
+
- @generaltranslation/compiler@1.3.26
|
|
15
|
+
- gt-i18n@1.0.2
|
|
16
|
+
- gt-react@11.0.4
|
|
17
|
+
- @generaltranslation/react-core@11.0.4
|
|
18
|
+
|
|
3
19
|
## 11.0.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncConditionStore.d.ts","sourceRoot":"","sources":["../../src/condition-store/AsyncConditionStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"AsyncConditionStore.d.ts","sourceRoot":"","sources":["../../src/condition-store/AsyncConditionStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,wBAAwB,CAAC;AAiB9E,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,eAAO,MACc,sBAAsB,6BACtB,sBAAsB,qCAY1C,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,oCAAoC;IAC9E,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,WAAW,CAA4B;gBAEnC,EACV,SAAS,EACT,SAAS,EACT,UAAiB,EACjB,UAAoC,EACpC,UAAoC,EACpC,gBAA0C,EAC1C,wBAAgC,GACjC,EAAE,yBAAyB;IActB,SAAS;IAQT,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIxC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAKvC,SAAS,CAAC,MAAM,EAAE,MAAM;CAGzB"}
|
|
@@ -61,10 +61,7 @@ function createDefaultGetLocale({ headerName, cookieName, ignorePreferredLanguag
|
|
|
61
61
|
if (headerLocale) preferredLocales.push(headerLocale);
|
|
62
62
|
const cookieLocale = (await (0, next_headers_js.cookies)()).get(cookieName);
|
|
63
63
|
if (cookieLocale?.value) preferredLocales.push(cookieLocale.value);
|
|
64
|
-
if (!ignorePreferredLanguages)
|
|
65
|
-
const acceptedLocales = headersList.get("accept-language")?.split(",").map((item) => item.split(";")?.[0].trim());
|
|
66
|
-
if (acceptedLocales) preferredLocales.push(...acceptedLocales);
|
|
67
|
-
}
|
|
64
|
+
if (!ignorePreferredLanguages) preferredLocales.push(...(0, gt_i18n_internal.parseAcceptLanguage)(headersList.get("accept-language")));
|
|
68
65
|
if (preferredLocales.length === 0 && !ignorePreferredLanguages) console.warn(require_errors_ssg.noLocalesCouldBeDeterminedWarning);
|
|
69
66
|
const i18nConfig = (0, gt_i18n_internal.getI18nConfig)();
|
|
70
67
|
return i18nConfig.determineSupportedLocale(preferredLocales) || i18nConfig.getDefaultLocale();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncConditionStore.js","names":["defaultLocaleHeaderName","defaultLocaleCookieName","defaultRegionCookieName","AsyncLocalStorage","resolveLocaleOrDefault","noLocalesCouldBeDeterminedWarning"],"sources":["../../src/condition-store/AsyncConditionStore.ts"],"sourcesContent":["import { AsyncReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { cookies, headers } from 'next/headers';\nimport { noLocalesCouldBeDeterminedWarning } from '../errors/ssg';\nimport {
|
|
1
|
+
{"version":3,"file":"AsyncConditionStore.js","names":["defaultLocaleHeaderName","defaultLocaleCookieName","defaultRegionCookieName","AsyncLocalStorage","resolveLocaleOrDefault","noLocalesCouldBeDeterminedWarning"],"sources":["../../src/condition-store/AsyncConditionStore.ts"],"sourcesContent":["import { AsyncReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { cookies, headers } from 'next/headers';\nimport { noLocalesCouldBeDeterminedWarning } from '../errors/ssg';\nimport {\n createConditionStoreSingleton,\n getI18nConfig,\n parseAcceptLanguage,\n} from 'gt-i18n/internal';\nimport {\n defaultLocaleCookieName,\n defaultRegionCookieName,\n} from '@generaltranslation/react-core/pure';\nimport { defaultLocaleHeaderName } from '../utils/headers';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { resolveLocaleOrDefault } from '../request/localeValidation';\n\nexport type AsyncConditionStoreParams = {\n getLocale?: () => Promise<string>;\n getRegion?: () => Promise<string | undefined>;\n enableI18n?: boolean;\n headerName?: string;\n cookieName?: string;\n regionCookieName?: string;\n ignorePreferredLanguages?: boolean;\n};\n\nexport const {\n getConditionStore: getAsyncConditionStore,\n setConditionStore: setAsyncConditionStore,\n} = createConditionStoreSingleton<AsyncConditionStore>(\n createDiagnosticMessage({\n source: 'gt-next',\n severity: 'Error',\n whatHappened:\n 'Cannot read request locale state before GT has been initialized',\n why: 'the internal ConditionStore singleton is unavailable in this server runtime',\n fix: \"Import GT server APIs from the 'gt-next' or 'gt-next/server' entry points so initialization runs before use.\",\n wayOut:\n 'If this only happens in certain deployments (e.g. edge or serverless), check that your bundler preserves gt-next import side effects and resolves a single copy of the package.',\n })\n);\n\n/**\n * Server-side (app router) condition store\n *\n * Note that this gets used by RSC, but SSR (aka 'use client' bondary on server)\n * uses context to access this condition store\n */\nexport class AsyncConditionStore implements AsyncReadonlyConditionStoreInterface {\n private getLocaleFn: () => Promise<string>;\n private getRegionFn: () => Promise<string | undefined>;\n private enableI18n: boolean;\n private localeStore: AsyncLocalStorage<string>;\n\n constructor({\n getLocale,\n getRegion,\n enableI18n = true,\n headerName = defaultLocaleHeaderName,\n cookieName = defaultLocaleCookieName,\n regionCookieName = defaultRegionCookieName,\n ignorePreferredLanguages = false,\n }: AsyncConditionStoreParams) {\n this.localeStore = new AsyncLocalStorage<string>();\n this.getLocaleFn =\n getLocale ??\n createDefaultGetLocale({\n headerName,\n cookieName,\n ignorePreferredLanguages,\n });\n this.getRegionFn =\n getRegion ?? createDefaultGetRegion({ regionCookieName });\n this.enableI18n = enableI18n;\n }\n\n async getLocale() {\n // If a locale has been registered for this request, return it\n const registeredLocale = this.localeStore.getStore();\n if (registeredLocale) return registeredLocale;\n\n return resolveLocaleOrDefault(await this.getLocaleFn());\n }\n\n async getRegion(): Promise<string | undefined> {\n return await this.getRegionFn();\n }\n\n async getEnableI18n(): Promise<boolean> {\n // Technically does not need async, but good for parity\n return this.enableI18n;\n }\n\n enterWith(locale: string) {\n this.localeStore.enterWith(locale);\n }\n}\n\n/**\n * Default behavior is to read from the headers and cookies\n * this can be overridden by the user\n */\nfunction createDefaultGetLocale({\n headerName,\n cookieName,\n ignorePreferredLanguages,\n}: {\n headerName: string;\n cookieName: string;\n ignorePreferredLanguages: boolean;\n}): () => Promise<string> {\n return async () => {\n const preferredLocales: string[] = [];\n const headersList = await headers();\n\n // Language set by GT\n const headerLocale = headersList.get(headerName);\n if (headerLocale) {\n preferredLocales.push(headerLocale);\n }\n const cookieLocale = (await cookies()).get(cookieName);\n if (cookieLocale?.value) {\n preferredLocales.push(cookieLocale.value);\n }\n\n // Preferred languages\n if (!ignorePreferredLanguages) {\n preferredLocales.push(\n ...parseAcceptLanguage(headersList.get('accept-language'))\n );\n }\n\n // Warn if no locales found\n if (preferredLocales.length === 0 && !ignorePreferredLanguages) {\n console.warn(noLocalesCouldBeDeterminedWarning);\n }\n\n const i18nConfig = getI18nConfig();\n return (\n i18nConfig.determineSupportedLocale(preferredLocales) ||\n i18nConfig.getDefaultLocale()\n );\n };\n}\n\n/**\n * Default behavior is to read the region from the built-in region cookie\n * this can be overridden by the user\n */\nfunction createDefaultGetRegion({\n regionCookieName,\n}: {\n regionCookieName: string;\n}): () => Promise<string | undefined> {\n return async () => {\n const cookieRegion = (await cookies()).get(regionCookieName);\n return cookieRegion?.value || undefined;\n };\n}\n"],"mappings":";;;;;;;;;;;AA2BA,MAAa,EACX,mBAAmB,wBACnB,mBAAmB,4BAAA,GAAA,iBAAA,gCAAA,GAAA,4BAAA,yBAEK;CACtB,QAAQ;CACR,UAAU;CACV,cACE;CACF,KAAK;CACL,KAAK;CACL,QACE;CACH,CAAC,CACH;;;;;;;AAQD,IAAa,sBAAb,MAAiF;CAM/E,YAAY,EACV,WACA,WACA,aAAa,MACb,aAAaA,sBAAAA,yBACb,aAAaC,oCAAAA,yBACb,mBAAmBC,oCAAAA,y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7 +3,7 @@ import { resolveLocaleOrDefault } from "../request/localeValidation.mjs";
|
|
|
3
3
|
import { noLocalesCouldBeDeterminedWarning } from "../errors/ssg.mjs";
|
|
4
4
|
import { createDiagnosticMessage } from "generaltranslation/internal";
|
|
5
5
|
import { defaultLocaleCookieName, defaultRegionCookieName } from "@generaltranslation/react-core/pure";
|
|
6
|
-
import { createConditionStoreSingleton, getI18nConfig as getI18nConfig$1 } from "gt-i18n/internal";
|
|
6
|
+
import { createConditionStoreSingleton, getI18nConfig as getI18nConfig$1, parseAcceptLanguage } from "gt-i18n/internal";
|
|
7
7
|
import { cookies, headers } from "next/headers.js";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
9
|
//#region src/condition-store/AsyncConditionStore.ts
|
|
@@ -59,10 +59,7 @@ function createDefaultGetLocale({ headerName, cookieName, ignorePreferredLanguag
|
|
|
59
59
|
if (headerLocale) preferredLocales.push(headerLocale);
|
|
60
60
|
const cookieLocale = (await cookies()).get(cookieName);
|
|
61
61
|
if (cookieLocale?.value) preferredLocales.push(cookieLocale.value);
|
|
62
|
-
if (!ignorePreferredLanguages)
|
|
63
|
-
const acceptedLocales = headersList.get("accept-language")?.split(",").map((item) => item.split(";")?.[0].trim());
|
|
64
|
-
if (acceptedLocales) preferredLocales.push(...acceptedLocales);
|
|
65
|
-
}
|
|
62
|
+
if (!ignorePreferredLanguages) preferredLocales.push(...parseAcceptLanguage(headersList.get("accept-language")));
|
|
66
63
|
if (preferredLocales.length === 0 && !ignorePreferredLanguages) console.warn(noLocalesCouldBeDeterminedWarning);
|
|
67
64
|
const i18nConfig = getI18nConfig$1();
|
|
68
65
|
return i18nConfig.determineSupportedLocale(preferredLocales) || i18nConfig.getDefaultLocale();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncConditionStore.mjs","names":["getI18nConfig"],"sources":["../../src/condition-store/AsyncConditionStore.ts"],"sourcesContent":["import { AsyncReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { cookies, headers } from 'next/headers';\nimport { noLocalesCouldBeDeterminedWarning } from '../errors/ssg';\nimport {
|
|
1
|
+
{"version":3,"file":"AsyncConditionStore.mjs","names":["getI18nConfig"],"sources":["../../src/condition-store/AsyncConditionStore.ts"],"sourcesContent":["import { AsyncReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { cookies, headers } from 'next/headers';\nimport { noLocalesCouldBeDeterminedWarning } from '../errors/ssg';\nimport {\n createConditionStoreSingleton,\n getI18nConfig,\n parseAcceptLanguage,\n} from 'gt-i18n/internal';\nimport {\n defaultLocaleCookieName,\n defaultRegionCookieName,\n} from '@generaltranslation/react-core/pure';\nimport { defaultLocaleHeaderName } from '../utils/headers';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { resolveLocaleOrDefault } from '../request/localeValidation';\n\nexport type AsyncConditionStoreParams = {\n getLocale?: () => Promise<string>;\n getRegion?: () => Promise<string | undefined>;\n enableI18n?: boolean;\n headerName?: string;\n cookieName?: string;\n regionCookieName?: string;\n ignorePreferredLanguages?: boolean;\n};\n\nexport const {\n getConditionStore: getAsyncConditionStore,\n setConditionStore: setAsyncConditionStore,\n} = createConditionStoreSingleton<AsyncConditionStore>(\n createDiagnosticMessage({\n source: 'gt-next',\n severity: 'Error',\n whatHappened:\n 'Cannot read request locale state before GT has been initialized',\n why: 'the internal ConditionStore singleton is unavailable in this server runtime',\n fix: \"Import GT server APIs from the 'gt-next' or 'gt-next/server' entry points so initialization runs before use.\",\n wayOut:\n 'If this only happens in certain deployments (e.g. edge or serverless), check that your bundler preserves gt-next import side effects and resolves a single copy of the package.',\n })\n);\n\n/**\n * Server-side (app router) condition store\n *\n * Note that this gets used by RSC, but SSR (aka 'use client' bondary on server)\n * uses context to access this condition store\n */\nexport class AsyncConditionStore implements AsyncReadonlyConditionStoreInterface {\n private getLocaleFn: () => Promise<string>;\n private getRegionFn: () => Promise<string | undefined>;\n private enableI18n: boolean;\n private localeStore: AsyncLocalStorage<string>;\n\n constructor({\n getLocale,\n getRegion,\n enableI18n = true,\n headerName = defaultLocaleHeaderName,\n cookieName = defaultLocaleCookieName,\n regionCookieName = defaultRegionCookieName,\n ignorePreferredLanguages = false,\n }: AsyncConditionStoreParams) {\n this.localeStore = new AsyncLocalStorage<string>();\n this.getLocaleFn =\n getLocale ??\n createDefaultGetLocale({\n headerName,\n cookieName,\n ignorePreferredLanguages,\n });\n this.getRegionFn =\n getRegion ?? createDefaultGetRegion({ regionCookieName });\n this.enableI18n = enableI18n;\n }\n\n async getLocale() {\n // If a locale has been registered for this request, return it\n const registeredLocale = this.localeStore.getStore();\n if (registeredLocale) return registeredLocale;\n\n return resolveLocaleOrDefault(await this.getLocaleFn());\n }\n\n async getRegion(): Promise<string | undefined> {\n return await this.getRegionFn();\n }\n\n async getEnableI18n(): Promise<boolean> {\n // Technically does not need async, but good for parity\n return this.enableI18n;\n }\n\n enterWith(locale: string) {\n this.localeStore.enterWith(locale);\n }\n}\n\n/**\n * Default behavior is to read from the headers and cookies\n * this can be overridden by the user\n */\nfunction createDefaultGetLocale({\n headerName,\n cookieName,\n ignorePreferredLanguages,\n}: {\n headerName: string;\n cookieName: string;\n ignorePreferredLanguages: boolean;\n}): () => Promise<string> {\n return async () => {\n const preferredLocales: string[] = [];\n const headersList = await headers();\n\n // Language set by GT\n const headerLocale = headersList.get(headerName);\n if (headerLocale) {\n preferredLocales.push(headerLocale);\n }\n const cookieLocale = (await cookies()).get(cookieName);\n if (cookieLocale?.value) {\n preferredLocales.push(cookieLocale.value);\n }\n\n // Preferred languages\n if (!ignorePreferredLanguages) {\n preferredLocales.push(\n ...parseAcceptLanguage(headersList.get('accept-language'))\n );\n }\n\n // Warn if no locales found\n if (preferredLocales.length === 0 && !ignorePreferredLanguages) {\n console.warn(noLocalesCouldBeDeterminedWarning);\n }\n\n const i18nConfig = getI18nConfig();\n return (\n i18nConfig.determineSupportedLocale(preferredLocales) ||\n i18nConfig.getDefaultLocale()\n );\n };\n}\n\n/**\n * Default behavior is to read the region from the built-in region cookie\n * this can be overridden by the user\n */\nfunction createDefaultGetRegion({\n regionCookieName,\n}: {\n regionCookieName: string;\n}): () => Promise<string | undefined> {\n return async () => {\n const cookieRegion = (await cookies()).get(regionCookieName);\n return cookieRegion?.value || undefined;\n };\n}\n"],"mappings":";;;;;;;;;AA2BA,MAAa,EACX,mBAAmB,wBACnB,mBAAmB,2BACjB,8BACF,wBAAwB;CACtB,QAAQ;CACR,UAAU;CACV,cACE;CACF,KAAK;CACL,KAAK;CACL,QACE;CACH,CAAC,CACH;;;;;;;AAQD,IAAa,sBAAb,MAAiF;CAM/E,YAAY,EACV,WACA,WACA,aAAa,MACb,aAAa,yBACb,aAAa,yBACb,mBAAmB,yBACnB,2BAA2B,SACC;AAC5B,OAAK,cAAc,IAAI,mBAA2B;AAClD,OAAK,cACH,aACA,uBAAuB;GACrB;GACA;GACA;GACD,CAAC;AACJ,OAAK,cACH,aAAa,uBAAuB,EAAE,kBAAkB,CAAC;AAC3D,OAAK,aAAa;;CAGpB,MAAM,YAAY;EAEhB,MAAM,mBAAmB,KAAK,YAAY,UAAU;AACpD,MAAI,iBAAkB,QAAO;AAE7B,SAAO,uBAAuB,MAAM,KAAK,aAAa,CAAC;;CAGzD,MAAM,YAAyC;AAC7C,SAAO,MAAM,KAAK,aAAa;;CAGjC,MAAM,gBAAkC;AAEtC,SAAO,KAAK;;CAGd,UAAU,QAAgB;AACxB,OAAK,YAAY,UAAU,OAAO;;;;;;;AAQtC,SAAS,uBAAuB,EAC9B,YACA,YACA,4BAKwB;AACxB,QAAO,YAAY;EACjB,MAAM,mBAA6B,EAAE;EACrC,MAAM,cAAc,MAAM,SAAS;EAGnC,MAAM,eAAe,YAAY,IAAI,WAAW;AAChD,MAAI,aACF,kBAAiB,KAAK,aAAa;EAErC,MAAM,gBAAgB,MAAM,SAAS,EAAE,IAAI,WAAW;AACtD,MAAI,cAAc,MAChB,kBAAiB,KAAK,aAAa,MAAM;AAI3C,MAAI,CAAC,yBACH,kBAAiB,KACf,GAAG,oBAAoB,YAAY,IAAI,kBAAkB,CAAC,CAC3D;AAIH,MAAI,iBAAiB,WAAW,KAAK,CAAC,yBACpC,SAAQ,KAAK,kCAAkC;EAGjD,MAAM,aAAaA,iBAAe;AAClC,SACE,WAAW,yBAAyB,iBAAiB,IACrD,WAAW,kBAAkB;;;;;;;AASnC,SAAS,uBAAuB,EAC9B,oBAGoC;AACpC,QAAO,YAAY;AAEjB,UADsB,MAAM,SAAS,EAAE,IAAI,iBACxB,EAAE,SAAS,KAAA"}
|
|
@@ -12,6 +12,8 @@ export declare const unresolvedLoadTranslationsBuildError: (path: string) => str
|
|
|
12
12
|
export declare const conflictingConfigurationBuildError: (conflicts: string[]) => string;
|
|
13
13
|
export declare const typesFileError: string;
|
|
14
14
|
export declare const getTranslationsSnapshotRscError: string;
|
|
15
|
+
export declare const withGTStaticPropsClientError: string;
|
|
16
|
+
export declare const withGTStaticPropsRscError: string;
|
|
15
17
|
export declare const invalidLocalesError: (locales: string[]) => string;
|
|
16
18
|
export declare const invalidCanonicalLocalesError: (locales: string[]) => string;
|
|
17
19
|
export declare const createInvalidRequestLocaleWarning: (locale: string, defaultLocale: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createErrors.d.ts","sourceRoot":"","sources":["../../src/errors/createErrors.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,uBAAuB,QAKlC,CAAC;AAEH,eAAO,MAAM,2BAA2B,GAAI,SAAQ,MAAW,WAK3D,CAAC;AAEL,eAAO,MAAM,2BAA2B,GAAI,SAAQ,MAAW,WAK3D,CAAC;AAEL,eAAO,MAAM,gCAAgC,GAAI,OAAO,KAAK,WAMzD,CAAC;AAEL,eAAO,MAAM,iCAAiC,GAAI,OAAO,KAAK,WAM1D,CAAC;AAEL,eAAO,MAAM,kCAAkC,QA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C;AAEH,eAAO,MAAM,iBAAiB,QAG5B,CAAC;AAEH,eAAO,MAAM,0BAA0B,GAAI,SAAS,MAAM,EAAE,WACiF,CAAC;AAE9I,eAAO,MAAM,mCAAmC,GAAI,SAAS,MAAM,EAAE,WACkF,CAAC;AAExJ,eAAO,MAAM,iCAAiC,GAAI,MAAM,OAAO,GAAG,KAAK,WAOnE,CAAC;AAEL,eAAO,MAAM,gCAAgC,QAI3C,CAAC;AAEH,eAAO,MAAM,gCAAgC,QAI3C,CAAC;AAEH,eAAO,MAAM,kCAAkC,GAAI,MAAM,OAAO,GAAG,KAAK,4NAGyD,CAAC;AAElI,eAAO,MAAM,wCAAwC,QAE8C,CAAC;AAEpG,eAAO,MAAM,+BAA+B,0FAA0F,CAAC;AAEvI,eAAO,MAAM,mCAAmC,0JAAyK,CAAC"}
|
|
@@ -74,6 +74,18 @@ const getTranslationsSnapshotRscError = require_errors_diagnostics.createGtNextD
|
|
|
74
74
|
whatHappened: "getTranslationsSnapshot() is not available for React Server Components",
|
|
75
75
|
fix: "Use gt-next build-time translation helpers in the App Router, or call getTranslationsSnapshot() from a Pages Router entry point"
|
|
76
76
|
});
|
|
77
|
+
const withGTStaticPropsClientError = require_errors_diagnostics.createGtNextDiagnostic({
|
|
78
|
+
severity: "Error",
|
|
79
|
+
whatHappened: "withGTStaticProps() cannot run in the browser",
|
|
80
|
+
why: "Static props are generated on the server by the Pages Router",
|
|
81
|
+
fix: "Export withGTStaticProps() from a Pages Router page module"
|
|
82
|
+
});
|
|
83
|
+
const withGTStaticPropsRscError = require_errors_diagnostics.createGtNextDiagnostic({
|
|
84
|
+
severity: "Error",
|
|
85
|
+
whatHappened: "withGTStaticProps() is not available for React Server Components",
|
|
86
|
+
why: "This helper supports the Pages Router, not the App Router",
|
|
87
|
+
fix: "Use gt-next build-time translation helpers in the App Router, or export withGTStaticProps() from a Pages Router page module"
|
|
88
|
+
});
|
|
77
89
|
const invalidLocalesError = (locales) => require_errors_diagnostics.createGtNextDiagnostic({
|
|
78
90
|
severity: "Error",
|
|
79
91
|
whatHappened: "Invalid locale codes in your configuration",
|
|
@@ -117,7 +129,11 @@ const APIKeyMissingWarn = require_errors_diagnostics.createGtNextPluginDiagnosti
|
|
|
117
129
|
});
|
|
118
130
|
const standardizedLocalesWarning = (locales) => `gt-next: The following locales were standardized: ${locales.join(", ")}. Use the standardized codes in your config to avoid this warning.`;
|
|
119
131
|
const standardizedCanonicalLocalesWarning = (locales) => `gt-next: The following canonical locales were standardized: ${locales.join(", ")}. Use the standardized codes in your config to avoid this warning.`;
|
|
120
|
-
const createGTCompilerUnresolvedWarning = (type) =>
|
|
132
|
+
const createGTCompilerUnresolvedWarning = (type) => require_errors_diagnostics.createGtNextPluginDiagnostic({
|
|
133
|
+
whatHappened: `The GT ${type} compiler could not be resolved`,
|
|
134
|
+
wayOut: "Skipping compiler optimizations",
|
|
135
|
+
...type === "babel" && { fix: "Install @generaltranslation/compiler to enable the experimental babel compiler" }
|
|
136
|
+
});
|
|
121
137
|
const customGetLocaleUnresolvedWarning = require_errors_diagnostics.createGtNextDiagnostic({
|
|
122
138
|
whatHappened: "Custom getLocale() could not be resolved",
|
|
123
139
|
wayOut: "gt-next will fall back to default locale detection",
|
|
@@ -164,5 +180,7 @@ exports.unresolvedCustomLoadDictionaryError = unresolvedCustomLoadDictionaryErro
|
|
|
164
180
|
exports.unresolvedCustomLoadTranslationsError = unresolvedCustomLoadTranslationsError;
|
|
165
181
|
exports.unresolvedLoadDictionaryBuildError = unresolvedLoadDictionaryBuildError;
|
|
166
182
|
exports.unresolvedLoadTranslationsBuildError = unresolvedLoadTranslationsBuildError;
|
|
183
|
+
exports.withGTStaticPropsClientError = withGTStaticPropsClientError;
|
|
184
|
+
exports.withGTStaticPropsRscError = withGTStaticPropsRscError;
|
|
167
185
|
|
|
168
186
|
//# sourceMappingURL=createErrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createErrors.js","names":["createGtNextDiagnostic","createGtNextPluginDiagnostic","SWC_PLUGIN_SUPPORT","BABEL_PLUGIN_SUPPORT"],"sources":["../../src/errors/createErrors.ts"],"sourcesContent":["// ---- ERRORS ---- //\n\nimport { getLocaleProperties } from '@generaltranslation/format';\nimport {\n createGtNextDiagnostic,\n createGtNextPluginDiagnostic,\n formatDiagnosticErrorDetails,\n} from './diagnostics';\nimport { BABEL_PLUGIN_SUPPORT, SWC_PLUGIN_SUPPORT } from '../plugin/constants';\n\nexport const remoteTranslationsError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Remote translations could not be loaded',\n fix: 'Check your project ID, API key, and network connection, then try again',\n wayOut: 'Source content will render as a fallback',\n});\n\nexport const customLoadTranslationsError = (locale: string = '') =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `Locally stored translations could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadTranslations(), make sure it returns translations for the requested locale',\n });\n\nexport const customLoadDictionaryWarning = (locale: string = '') =>\n createGtNextDiagnostic({\n severity: 'Warning',\n whatHappened: `The local dictionary could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadDictionary(), make sure it returns a dictionary for the requested locale',\n });\n\nexport const createUnresolvedNextVersionError = (error: Error) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'The installed Next.js version could not be resolved',\n fix: 'Check that next is installed in this project',\n details: error.message,\n });\n\nexport const createUnresolvedReactVersionError = (error: Error) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'The installed React version could not be resolved',\n fix: 'Check that react is installed in this project',\n details: error.message,\n });\n\nexport const devApiKeyIncludedInProductionError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Production builds cannot use a development API key',\n fix: 'Replace it with a production API key',\n});\n\nexport const createDictionarySubsetError = (id: string, functionName: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `${functionName} with id \"${id}\" could not read a valid dictionary subtree`,\n fix: 'Make sure the id maps to the correct subroute of the dictionary',\n });\n\nexport const unresolvedCustomLoadDictionaryError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'loadDictionary() was found during the build but could not be resolved at runtime',\n fix: 'Export a loadDictionary() function from the configured file',\n});\n\nexport const unresolvedCustomLoadTranslationsError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'loadTranslations() was found during the build but could not be resolved at runtime',\n fix: 'Export a loadTranslations() function from the configured file',\n});\n\nexport const unresolvedLoadDictionaryBuildError = (path: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `The file defining loadDictionary() could not be resolved at ${path}`,\n fix: 'Check the configured path and try again',\n });\n\nexport const unresolvedLoadTranslationsBuildError = (path: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `The file defining loadTranslations() could not be resolved at ${path}`,\n fix: 'Check the configured path and try again',\n });\n\nexport const conflictingConfigurationBuildError = (conflicts: string[]) =>\n `gt-next Error: Conflicting configuration${\n conflicts.length > 1 ? 's' : ''\n } detected. Resolve the following conflicts before building your app:\\n${conflicts.join(\n '\\n'\n )}`;\n\nexport const typesFileError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'A types-only entry point was executed at runtime',\n fix: 'Import from the appropriate gt-next runtime entry point instead',\n});\n\nexport const getTranslationsSnapshotRscError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'getTranslationsSnapshot() is not available for React Server Components',\n fix: 'Use gt-next build-time translation helpers in the App Router, or call getTranslationsSnapshot() from a Pages Router entry point',\n});\n\nexport const invalidLocalesError = (locales: string[]) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid locale codes in your configuration',\n fix: 'Specify a list of valid locales or use \"customMapping\" to define aliases for the invalid locales',\n details: locales,\n });\n\nexport const invalidCanonicalLocalesError = (locales: string[]) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid canonical locale codes in your configuration',\n fix: 'Use valid BCP 47 locale codes before starting translation',\n details: locales,\n });\n\nexport const createInvalidRequestLocaleWarning = (\n locale: string,\n defaultLocale: string\n) =>\n createGtNextDiagnostic({\n severity: 'Warning',\n whatHappened: `Locale \"${locale}\" is not valid or is not supported by this app`,\n wayOut: `The default locale \"${defaultLocale}\" will be used for this request`,\n fix: 'Use a valid BCP 47 locale code, add a custom mapping, or configure the locale in gt-next',\n });\n\nexport const createInvalidPathRegexError = (\n pathRegex: string,\n error: unknown\n) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `pathRegex \"${pathRegex}\" is not a valid regular expression`,\n fix: 'Pass a valid JavaScript regular expression string to withGTConfig()',\n details: formatDiagnosticErrorDetails(error),\n });\n\n// ---- WARNINGS ---- //\n\nexport const createBadFilepathWarning = (filename: string, dir: string[]) =>\n createGtNextDiagnostic({\n whatHappened: `${filename} was found in ${dir.join(' or ')}, which is not supported`,\n fix: 'Move it to your project root so gt-next can load it',\n });\n\nexport const createUnsupportedLocalesWarning = (locales: string[]) =>\n `gt-next: The following locales are currently unsupported by our service: ${locales\n .map((locale) => {\n const { name } = getLocaleProperties(locale);\n return `${locale} (${name})`;\n })\n .join(', ')}`;\n\nexport const projectIdMissingWarn = createGtNextDiagnostic({\n whatHappened: 'Runtime translation needs a project ID',\n fix: 'Set GT_PROJECT_ID in your environment or pass projectId to withGTConfig()',\n docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const APIKeyMissingWarn = createGtNextPluginDiagnostic({\n whatHappened: 'Runtime translation needs a development API key',\n fix: 'Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation',\n});\n\nexport const standardizedLocalesWarning = (locales: string[]) =>\n `gt-next: The following locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const standardizedCanonicalLocalesWarning = (locales: string[]) =>\n `gt-next: The following canonical locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const createGTCompilerUnresolvedWarning = (type: 'babel' | 'swc') =>\n `gt-next (plugin): The GT ${type} compiler could not be resolved. Skipping compiler optimizations.`;\n\nexport const customGetLocaleUnresolvedWarning = createGtNextDiagnostic({\n whatHappened: 'Custom getLocale() could not be resolved',\n wayOut: 'gt-next will fall back to default locale detection',\n fix: 'Export a getLocale() function from the configured request file',\n});\n\nexport const customGetRegionUnresolvedWarning = createGtNextDiagnostic({\n whatHappened: 'Custom getRegion() could not be resolved',\n wayOut: 'gt-next will fall back to default region detection',\n fix: 'Export a getRegion() function from the configured request file',\n});\n\nexport const createGTCompilerUnavailableWarning = (type: 'babel' | 'swc') =>\n type === 'swc'\n ? `gt-next (plugin): The GT swc compiler is compatible with < next@${SWC_PLUGIN_SUPPORT}. Skipping compiler optimizations.`\n : `gt-next (plugin): The GT babel compiler requires react@${BABEL_PLUGIN_SUPPORT} or newer. Skipping compiler optimizations.`;\n\nexport const babelCompilerTurbopackUnavailableWarning =\n `gt-next (plugin): The GT babel compiler is not compatible with Turbopack. ` +\n `To use compiler optimizations with Turbopack, set experimentalCompilerOptions: { type: 'swc' }.`;\n\nexport const disablingCompileTimeHashWarning = `gt-next (plugin): Compile-time hash is disabled. Compiler optimizations are inactive.`;\n\nexport const swcPluginCompatibilityChangeWarning = `gt-next (plugin): As of gt-next@6.12.4, SWC plugin support is disabled for Next.js versions prior to ${SWC_PLUGIN_SUPPORT}. Update to the latest version of Next.js.`;\n"],"mappings":";;;;;;;AAUA,MAAa,0BAA0BA,2BAAAA,uBAAuB;CAC5D,UAAU;CACV,cAAc;CACd,KAAK;CACL,QAAQ;CACT,CAAC;AAEF,MAAa,+BAA+B,SAAiB,OAC3DA,2BAAAA,uBAAuB;CACrB,UAAU;CACV,cAAc,kDAAkD,SAAS,SAAS,OAAO,KAAK;CAC9F,KAAK;CACN,CAAC;AAEJ,MAAa,+BAA+B,SAAiB,OAC3DA,2BAAAA,uBAAuB;CACrB,UAAU;CACV,cAAc,2CAA2C,SAAS,SAAS,OAAO,KAAK;CACvF,KA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kCAAkC;AAE/C,MAAa,sCAAsC,wGAAwGD,yBAAAA,mBAAmB"}
|
|
1
|
+
{"version":3,"file":"createErrors.js","names":["createGtNextDiagnostic","createGtNextPluginDiagnostic","SWC_PLUGIN_SUPPORT","BABEL_PLUGIN_SUPPORT"],"sources":["../../src/errors/createErrors.ts"],"sourcesContent":["// ---- ERRORS ---- //\n\nimport { getLocaleProperties } from '@generaltranslation/format';\nimport {\n createGtNextDiagnostic,\n createGtNextPluginDiagnostic,\n formatDiagnosticErrorDetails,\n} from './diagnostics';\nimport { BABEL_PLUGIN_SUPPORT, SWC_PLUGIN_SUPPORT } from '../plugin/constants';\n\nexport const remoteTranslationsError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Remote translations could not be loaded',\n fix: 'Check your project ID, API key, and network connection, then try again',\n wayOut: 'Source content will render as a fallback',\n});\n\nexport const customLoadTranslationsError = (locale: string = '') =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `Locally stored translations could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadTranslations(), make sure it returns translations for the requested locale',\n });\n\nexport const customLoadDictionaryWarning = (locale: string = '') =>\n createGtNextDiagnostic({\n severity: 'Warning',\n whatHappened: `The local dictionary could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadDictionary(), make sure it returns a dictionary for the requested locale',\n });\n\nexport const createUnresolvedNextVersionError = (error: Error) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'The installed Next.js version could not be resolved',\n fix: 'Check that next is installed in this project',\n details: error.message,\n });\n\nexport const createUnresolvedReactVersionError = (error: Error) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'The installed React version could not be resolved',\n fix: 'Check that react is installed in this project',\n details: error.message,\n });\n\nexport const devApiKeyIncludedInProductionError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Production builds cannot use a development API key',\n fix: 'Replace it with a production API key',\n});\n\nexport const createDictionarySubsetError = (id: string, functionName: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `${functionName} with id \"${id}\" could not read a valid dictionary subtree`,\n fix: 'Make sure the id maps to the correct subroute of the dictionary',\n });\n\nexport const unresolvedCustomLoadDictionaryError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'loadDictionary() was found during the build but could not be resolved at runtime',\n fix: 'Export a loadDictionary() function from the configured file',\n});\n\nexport const unresolvedCustomLoadTranslationsError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'loadTranslations() was found during the build but could not be resolved at runtime',\n fix: 'Export a loadTranslations() function from the configured file',\n});\n\nexport const unresolvedLoadDictionaryBuildError = (path: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `The file defining loadDictionary() could not be resolved at ${path}`,\n fix: 'Check the configured path and try again',\n });\n\nexport const unresolvedLoadTranslationsBuildError = (path: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `The file defining loadTranslations() could not be resolved at ${path}`,\n fix: 'Check the configured path and try again',\n });\n\nexport const conflictingConfigurationBuildError = (conflicts: string[]) =>\n `gt-next Error: Conflicting configuration${\n conflicts.length > 1 ? 's' : ''\n } detected. Resolve the following conflicts before building your app:\\n${conflicts.join(\n '\\n'\n )}`;\n\nexport const typesFileError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'A types-only entry point was executed at runtime',\n fix: 'Import from the appropriate gt-next runtime entry point instead',\n});\n\nexport const getTranslationsSnapshotRscError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'getTranslationsSnapshot() is not available for React Server Components',\n fix: 'Use gt-next build-time translation helpers in the App Router, or call getTranslationsSnapshot() from a Pages Router entry point',\n});\n\nexport const withGTStaticPropsClientError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'withGTStaticProps() cannot run in the browser',\n why: 'Static props are generated on the server by the Pages Router',\n fix: 'Export withGTStaticProps() from a Pages Router page module',\n});\n\nexport const withGTStaticPropsRscError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'withGTStaticProps() is not available for React Server Components',\n why: 'This helper supports the Pages Router, not the App Router',\n fix: 'Use gt-next build-time translation helpers in the App Router, or export withGTStaticProps() from a Pages Router page module',\n});\n\nexport const invalidLocalesError = (locales: string[]) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid locale codes in your configuration',\n fix: 'Specify a list of valid locales or use \"customMapping\" to define aliases for the invalid locales',\n details: locales,\n });\n\nexport const invalidCanonicalLocalesError = (locales: string[]) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid canonical locale codes in your configuration',\n fix: 'Use valid BCP 47 locale codes before starting translation',\n details: locales,\n });\n\nexport const createInvalidRequestLocaleWarning = (\n locale: string,\n defaultLocale: string\n) =>\n createGtNextDiagnostic({\n severity: 'Warning',\n whatHappened: `Locale \"${locale}\" is not valid or is not supported by this app`,\n wayOut: `The default locale \"${defaultLocale}\" will be used for this request`,\n fix: 'Use a valid BCP 47 locale code, add a custom mapping, or configure the locale in gt-next',\n });\n\nexport const createInvalidPathRegexError = (\n pathRegex: string,\n error: unknown\n) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `pathRegex \"${pathRegex}\" is not a valid regular expression`,\n fix: 'Pass a valid JavaScript regular expression string to withGTConfig()',\n details: formatDiagnosticErrorDetails(error),\n });\n\n// ---- WARNINGS ---- //\n\nexport const createBadFilepathWarning = (filename: string, dir: string[]) =>\n createGtNextDiagnostic({\n whatHappened: `${filename} was found in ${dir.join(' or ')}, which is not supported`,\n fix: 'Move it to your project root so gt-next can load it',\n });\n\nexport const createUnsupportedLocalesWarning = (locales: string[]) =>\n `gt-next: The following locales are currently unsupported by our service: ${locales\n .map((locale) => {\n const { name } = getLocaleProperties(locale);\n return `${locale} (${name})`;\n })\n .join(', ')}`;\n\nexport const projectIdMissingWarn = createGtNextDiagnostic({\n whatHappened: 'Runtime translation needs a project ID',\n fix: 'Set GT_PROJECT_ID in your environment or pass projectId to withGTConfig()',\n docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const APIKeyMissingWarn = createGtNextPluginDiagnostic({\n whatHappened: 'Runtime translation needs a development API key',\n fix: 'Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation',\n});\n\nexport const standardizedLocalesWarning = (locales: string[]) =>\n `gt-next: The following locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const standardizedCanonicalLocalesWarning = (locales: string[]) =>\n `gt-next: The following canonical locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const createGTCompilerUnresolvedWarning = (type: 'babel' | 'swc') =>\n createGtNextPluginDiagnostic({\n whatHappened: `The GT ${type} compiler could not be resolved`,\n wayOut: 'Skipping compiler optimizations',\n ...(type === 'babel' && {\n fix: 'Install @generaltranslation/compiler to enable the experimental babel compiler',\n }),\n });\n\nexport const customGetLocaleUnresolvedWarning = createGtNextDiagnostic({\n whatHappened: 'Custom getLocale() could not be resolved',\n wayOut: 'gt-next will fall back to default locale detection',\n fix: 'Export a getLocale() function from the configured request file',\n});\n\nexport const customGetRegionUnresolvedWarning = createGtNextDiagnostic({\n whatHappened: 'Custom getRegion() could not be resolved',\n wayOut: 'gt-next will fall back to default region detection',\n fix: 'Export a getRegion() function from the configured request file',\n});\n\nexport const createGTCompilerUnavailableWarning = (type: 'babel' | 'swc') =>\n type === 'swc'\n ? `gt-next (plugin): The GT swc compiler is compatible with < next@${SWC_PLUGIN_SUPPORT}. Skipping compiler optimizations.`\n : `gt-next (plugin): The GT babel compiler requires react@${BABEL_PLUGIN_SUPPORT} or newer. Skipping compiler optimizations.`;\n\nexport const babelCompilerTurbopackUnavailableWarning =\n `gt-next (plugin): The GT babel compiler is not compatible with Turbopack. ` +\n `To use compiler optimizations with Turbopack, set experimentalCompilerOptions: { type: 'swc' }.`;\n\nexport const disablingCompileTimeHashWarning = `gt-next (plugin): Compile-time hash is disabled. Compiler optimizations are inactive.`;\n\nexport const swcPluginCompatibilityChangeWarning = `gt-next (plugin): As of gt-next@6.12.4, SWC plugin support is disabled for Next.js versions prior to ${SWC_PLUGIN_SUPPORT}. Update to the latest version of Next.js.`;\n"],"mappings":";;;;;;;AAUA,MAAa,0BAA0BA,2BAAAA,uBAAuB;CAC5D,UAAU;CACV,cAAc;CACd,KAAK;CACL,QAAQ;CACT,CAAC;AAEF,MAAa,+BAA+B,SAAiB,OAC3DA,2BAAAA,uBAAuB;CACrB,UAAU;CACV,cAAc,kDAAkD,SAAS,SAAS,OAAO,KAAK;CAC9F,KAAK;CACN,CAAC;AAEJ,MAAa,+BAA+B,SAAiB,OAC3DA,2BAAAA,uBAAuB;CACrB,UAAU;CACV,cAAc,2CAA2C,SAAS,SAAS,OAAO,KAAK;CACvF,KAAK;CACN,CAAC;AAEJ,MAAa,oCAAoC,UAC/CA,2BAAAA,uBAAuB;CACrB,UAAU;CACV,cAAc;CACd,KAAK;CACL,SAAS,MAAM;CAChB,CAAC;AAEJ,MAAa,qCAAqC,UAChDA,2BAAAA,uBAAuB;CACrB,UAAU;CACV,cAAc;CACd,KAAK;CACL,SAAS,MAAM;CAChB,CAAC;AAEJ,MAAa,qCAAqCA,2BAAAA,uBAAuB;CACvE,UAAU;CACV,cAAc;CACd,KAAK;CACN,CAAC;AAEF,MAAa,+BAA+B,IAAY,iBACtDA,2BAAAA,uBAAuB;CACrB,UAAU;CACV,cAAc,GAAG,aAAa,YAAY,GAAG;CAC7C,KAAK;CACN,CAAC;AAEJ,MAAa,sCAAsCA,2BAAAA,uBAAuB;CACxE,UAAU;CACV,cACE;CACF,KAAK;CACN,CAAC;AAEF,MAAa,wCAAwCA,2BAAAA,uBAAuB;CAC1E,UAAU;CACV,cACE;CACF,KAAK;CACN,CAAC;AAEF,MAAa,sCAAsC,SACjDA,2BAAAA,uBAAuB;CACrB,UAAU;CACV,cAAc,+DAA+D;CAC7E,KAAK;CACN,C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,EAAE,UAAA,GAAA,2BAAA,qBAA6B,OAAO;AAC5C,QAAO,GAAG,OAAO,IAAI,KAAK;EAC1B,CACD,KAAK,KAAK;AAEf,MAAa,uBAAuBA,2BAAAA,uBAAuB;CACzD,cAAc;CACd,KAAK;CACL,SAAS;CACV,CAAC;AAEF,MAAa,oBAAoBC,2BAAAA,6BAA6B;CAC5D,cAAc;CACd,KAAK;CACN,CAAC;AAEF,MAAa,8BAA8B,YACzC,qDAAqD,QAAQ,KAAK,KAAK,CAAC;AAE1E,MAAa,uCAAuC,YAClD,+DAA+D,QAAQ,KAAK,KAAK,CAAC;AAEpF,MAAa,qCAAqC,SAChDA,2BAAAA,6BAA6B;CAC3B,cAAc,UAAU,KAAK;CAC7B,QAAQ;CACR,GAAI,SAAS,WAAW,EACtB,KAAK,kFACN;CACF,CAAC;AAEJ,MAAa,mCAAmCD,2BAAAA,uBAAuB;CACrE,cAAc;CACd,QAAQ;CACR,KAAK;CACN,CAAC;AAEF,MAAa,mCAAmCA,2BAAAA,uBAAuB;CACrE,cAAc;CACd,QAAQ;CACR,KAAK;CACN,CAAC;AAEF,MAAa,sCAAsC,SACjD,SAAS,QACL,mEAAmEE,yBAAAA,mBAAmB,sCACtF,0DAA0DC,yBAAAA,qBAAqB;AAErF,MAAa,2CACX;AAGF,MAAa,kCAAkC;AAE/C,MAAa,sCAAsC,wGAAwGD,yBAAAA,mBAAmB"}
|
|
@@ -71,6 +71,18 @@ const getTranslationsSnapshotRscError = createGtNextDiagnostic({
|
|
|
71
71
|
whatHappened: "getTranslationsSnapshot() is not available for React Server Components",
|
|
72
72
|
fix: "Use gt-next build-time translation helpers in the App Router, or call getTranslationsSnapshot() from a Pages Router entry point"
|
|
73
73
|
});
|
|
74
|
+
const withGTStaticPropsClientError = createGtNextDiagnostic({
|
|
75
|
+
severity: "Error",
|
|
76
|
+
whatHappened: "withGTStaticProps() cannot run in the browser",
|
|
77
|
+
why: "Static props are generated on the server by the Pages Router",
|
|
78
|
+
fix: "Export withGTStaticProps() from a Pages Router page module"
|
|
79
|
+
});
|
|
80
|
+
const withGTStaticPropsRscError = createGtNextDiagnostic({
|
|
81
|
+
severity: "Error",
|
|
82
|
+
whatHappened: "withGTStaticProps() is not available for React Server Components",
|
|
83
|
+
why: "This helper supports the Pages Router, not the App Router",
|
|
84
|
+
fix: "Use gt-next build-time translation helpers in the App Router, or export withGTStaticProps() from a Pages Router page module"
|
|
85
|
+
});
|
|
74
86
|
const invalidLocalesError = (locales) => createGtNextDiagnostic({
|
|
75
87
|
severity: "Error",
|
|
76
88
|
whatHappened: "Invalid locale codes in your configuration",
|
|
@@ -114,7 +126,11 @@ const APIKeyMissingWarn = createGtNextPluginDiagnostic({
|
|
|
114
126
|
});
|
|
115
127
|
const standardizedLocalesWarning = (locales) => `gt-next: The following locales were standardized: ${locales.join(", ")}. Use the standardized codes in your config to avoid this warning.`;
|
|
116
128
|
const standardizedCanonicalLocalesWarning = (locales) => `gt-next: The following canonical locales were standardized: ${locales.join(", ")}. Use the standardized codes in your config to avoid this warning.`;
|
|
117
|
-
const createGTCompilerUnresolvedWarning = (type) =>
|
|
129
|
+
const createGTCompilerUnresolvedWarning = (type) => createGtNextPluginDiagnostic({
|
|
130
|
+
whatHappened: `The GT ${type} compiler could not be resolved`,
|
|
131
|
+
wayOut: "Skipping compiler optimizations",
|
|
132
|
+
...type === "babel" && { fix: "Install @generaltranslation/compiler to enable the experimental babel compiler" }
|
|
133
|
+
});
|
|
118
134
|
const customGetLocaleUnresolvedWarning = createGtNextDiagnostic({
|
|
119
135
|
whatHappened: "Custom getLocale() could not be resolved",
|
|
120
136
|
wayOut: "gt-next will fall back to default locale detection",
|
|
@@ -130,6 +146,6 @@ const babelCompilerTurbopackUnavailableWarning = "gt-next (plugin): The GT babel
|
|
|
130
146
|
const disablingCompileTimeHashWarning = `gt-next (plugin): Compile-time hash is disabled. Compiler optimizations are inactive.`;
|
|
131
147
|
const swcPluginCompatibilityChangeWarning = `gt-next (plugin): As of gt-next@6.12.4, SWC plugin support is disabled for Next.js versions prior to ${SWC_PLUGIN_SUPPORT}. Update to the latest version of Next.js.`;
|
|
132
148
|
//#endregion
|
|
133
|
-
export { APIKeyMissingWarn, babelCompilerTurbopackUnavailableWarning, conflictingConfigurationBuildError, createBadFilepathWarning, createDictionarySubsetError, createGTCompilerUnavailableWarning, createGTCompilerUnresolvedWarning, createInvalidPathRegexError, createInvalidRequestLocaleWarning, createUnresolvedNextVersionError, createUnresolvedReactVersionError, createUnsupportedLocalesWarning, customGetLocaleUnresolvedWarning, customGetRegionUnresolvedWarning, customLoadDictionaryWarning, customLoadTranslationsError, devApiKeyIncludedInProductionError, disablingCompileTimeHashWarning, getTranslationsSnapshotRscError, invalidCanonicalLocalesError, invalidLocalesError, projectIdMissingWarn, remoteTranslationsError, standardizedCanonicalLocalesWarning, standardizedLocalesWarning, swcPluginCompatibilityChangeWarning, typesFileError, unresolvedCustomLoadDictionaryError, unresolvedCustomLoadTranslationsError, unresolvedLoadDictionaryBuildError, unresolvedLoadTranslationsBuildError };
|
|
149
|
+
export { APIKeyMissingWarn, babelCompilerTurbopackUnavailableWarning, conflictingConfigurationBuildError, createBadFilepathWarning, createDictionarySubsetError, createGTCompilerUnavailableWarning, createGTCompilerUnresolvedWarning, createInvalidPathRegexError, createInvalidRequestLocaleWarning, createUnresolvedNextVersionError, createUnresolvedReactVersionError, createUnsupportedLocalesWarning, customGetLocaleUnresolvedWarning, customGetRegionUnresolvedWarning, customLoadDictionaryWarning, customLoadTranslationsError, devApiKeyIncludedInProductionError, disablingCompileTimeHashWarning, getTranslationsSnapshotRscError, invalidCanonicalLocalesError, invalidLocalesError, projectIdMissingWarn, remoteTranslationsError, standardizedCanonicalLocalesWarning, standardizedLocalesWarning, swcPluginCompatibilityChangeWarning, typesFileError, unresolvedCustomLoadDictionaryError, unresolvedCustomLoadTranslationsError, unresolvedLoadDictionaryBuildError, unresolvedLoadTranslationsBuildError, withGTStaticPropsClientError, withGTStaticPropsRscError };
|
|
134
150
|
|
|
135
151
|
//# sourceMappingURL=createErrors.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createErrors.mjs","names":[],"sources":["../../src/errors/createErrors.ts"],"sourcesContent":["// ---- ERRORS ---- //\n\nimport { getLocaleProperties } from '@generaltranslation/format';\nimport {\n createGtNextDiagnostic,\n createGtNextPluginDiagnostic,\n formatDiagnosticErrorDetails,\n} from './diagnostics';\nimport { BABEL_PLUGIN_SUPPORT, SWC_PLUGIN_SUPPORT } from '../plugin/constants';\n\nexport const remoteTranslationsError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Remote translations could not be loaded',\n fix: 'Check your project ID, API key, and network connection, then try again',\n wayOut: 'Source content will render as a fallback',\n});\n\nexport const customLoadTranslationsError = (locale: string = '') =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `Locally stored translations could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadTranslations(), make sure it returns translations for the requested locale',\n });\n\nexport const customLoadDictionaryWarning = (locale: string = '') =>\n createGtNextDiagnostic({\n severity: 'Warning',\n whatHappened: `The local dictionary could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadDictionary(), make sure it returns a dictionary for the requested locale',\n });\n\nexport const createUnresolvedNextVersionError = (error: Error) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'The installed Next.js version could not be resolved',\n fix: 'Check that next is installed in this project',\n details: error.message,\n });\n\nexport const createUnresolvedReactVersionError = (error: Error) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'The installed React version could not be resolved',\n fix: 'Check that react is installed in this project',\n details: error.message,\n });\n\nexport const devApiKeyIncludedInProductionError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Production builds cannot use a development API key',\n fix: 'Replace it with a production API key',\n});\n\nexport const createDictionarySubsetError = (id: string, functionName: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `${functionName} with id \"${id}\" could not read a valid dictionary subtree`,\n fix: 'Make sure the id maps to the correct subroute of the dictionary',\n });\n\nexport const unresolvedCustomLoadDictionaryError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'loadDictionary() was found during the build but could not be resolved at runtime',\n fix: 'Export a loadDictionary() function from the configured file',\n});\n\nexport const unresolvedCustomLoadTranslationsError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'loadTranslations() was found during the build but could not be resolved at runtime',\n fix: 'Export a loadTranslations() function from the configured file',\n});\n\nexport const unresolvedLoadDictionaryBuildError = (path: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `The file defining loadDictionary() could not be resolved at ${path}`,\n fix: 'Check the configured path and try again',\n });\n\nexport const unresolvedLoadTranslationsBuildError = (path: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `The file defining loadTranslations() could not be resolved at ${path}`,\n fix: 'Check the configured path and try again',\n });\n\nexport const conflictingConfigurationBuildError = (conflicts: string[]) =>\n `gt-next Error: Conflicting configuration${\n conflicts.length > 1 ? 's' : ''\n } detected. Resolve the following conflicts before building your app:\\n${conflicts.join(\n '\\n'\n )}`;\n\nexport const typesFileError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'A types-only entry point was executed at runtime',\n fix: 'Import from the appropriate gt-next runtime entry point instead',\n});\n\nexport const getTranslationsSnapshotRscError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'getTranslationsSnapshot() is not available for React Server Components',\n fix: 'Use gt-next build-time translation helpers in the App Router, or call getTranslationsSnapshot() from a Pages Router entry point',\n});\n\nexport const invalidLocalesError = (locales: string[]) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid locale codes in your configuration',\n fix: 'Specify a list of valid locales or use \"customMapping\" to define aliases for the invalid locales',\n details: locales,\n });\n\nexport const invalidCanonicalLocalesError = (locales: string[]) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid canonical locale codes in your configuration',\n fix: 'Use valid BCP 47 locale codes before starting translation',\n details: locales,\n });\n\nexport const createInvalidRequestLocaleWarning = (\n locale: string,\n defaultLocale: string\n) =>\n createGtNextDiagnostic({\n severity: 'Warning',\n whatHappened: `Locale \"${locale}\" is not valid or is not supported by this app`,\n wayOut: `The default locale \"${defaultLocale}\" will be used for this request`,\n fix: 'Use a valid BCP 47 locale code, add a custom mapping, or configure the locale in gt-next',\n });\n\nexport const createInvalidPathRegexError = (\n pathRegex: string,\n error: unknown\n) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `pathRegex \"${pathRegex}\" is not a valid regular expression`,\n fix: 'Pass a valid JavaScript regular expression string to withGTConfig()',\n details: formatDiagnosticErrorDetails(error),\n });\n\n// ---- WARNINGS ---- //\n\nexport const createBadFilepathWarning = (filename: string, dir: string[]) =>\n createGtNextDiagnostic({\n whatHappened: `${filename} was found in ${dir.join(' or ')}, which is not supported`,\n fix: 'Move it to your project root so gt-next can load it',\n });\n\nexport const createUnsupportedLocalesWarning = (locales: string[]) =>\n `gt-next: The following locales are currently unsupported by our service: ${locales\n .map((locale) => {\n const { name } = getLocaleProperties(locale);\n return `${locale} (${name})`;\n })\n .join(', ')}`;\n\nexport const projectIdMissingWarn = createGtNextDiagnostic({\n whatHappened: 'Runtime translation needs a project ID',\n fix: 'Set GT_PROJECT_ID in your environment or pass projectId to withGTConfig()',\n docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const APIKeyMissingWarn = createGtNextPluginDiagnostic({\n whatHappened: 'Runtime translation needs a development API key',\n fix: 'Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation',\n});\n\nexport const standardizedLocalesWarning = (locales: string[]) =>\n `gt-next: The following locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const standardizedCanonicalLocalesWarning = (locales: string[]) =>\n `gt-next: The following canonical locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const createGTCompilerUnresolvedWarning = (type: 'babel' | 'swc') =>\n `gt-next (plugin): The GT ${type} compiler could not be resolved. Skipping compiler optimizations.`;\n\nexport const customGetLocaleUnresolvedWarning = createGtNextDiagnostic({\n whatHappened: 'Custom getLocale() could not be resolved',\n wayOut: 'gt-next will fall back to default locale detection',\n fix: 'Export a getLocale() function from the configured request file',\n});\n\nexport const customGetRegionUnresolvedWarning = createGtNextDiagnostic({\n whatHappened: 'Custom getRegion() could not be resolved',\n wayOut: 'gt-next will fall back to default region detection',\n fix: 'Export a getRegion() function from the configured request file',\n});\n\nexport const createGTCompilerUnavailableWarning = (type: 'babel' | 'swc') =>\n type === 'swc'\n ? `gt-next (plugin): The GT swc compiler is compatible with < next@${SWC_PLUGIN_SUPPORT}. Skipping compiler optimizations.`\n : `gt-next (plugin): The GT babel compiler requires react@${BABEL_PLUGIN_SUPPORT} or newer. Skipping compiler optimizations.`;\n\nexport const babelCompilerTurbopackUnavailableWarning =\n `gt-next (plugin): The GT babel compiler is not compatible with Turbopack. ` +\n `To use compiler optimizations with Turbopack, set experimentalCompilerOptions: { type: 'swc' }.`;\n\nexport const disablingCompileTimeHashWarning = `gt-next (plugin): Compile-time hash is disabled. Compiler optimizations are inactive.`;\n\nexport const swcPluginCompatibilityChangeWarning = `gt-next (plugin): As of gt-next@6.12.4, SWC plugin support is disabled for Next.js versions prior to ${SWC_PLUGIN_SUPPORT}. Update to the latest version of Next.js.`;\n"],"mappings":";;;;AAUA,MAAa,0BAA0B,uBAAuB;CAC5D,UAAU;CACV,cAAc;CACd,KAAK;CACL,QAAQ;CACT,CAAC;AAEF,MAAa,+BAA+B,SAAiB,OAC3D,uBAAuB;CACrB,UAAU;CACV,cAAc,kDAAkD,SAAS,SAAS,OAAO,KAAK;CAC9F,KAAK;CACN,CAAC;AAEJ,MAAa,+BAA+B,SAAiB,OAC3D,uBAAuB;CACrB,UAAU;CACV,cAAc,2CAA2C,SAAS,SAAS,OAAO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OAAO;CAChC,QAAQ,uBAAuB,cAAc;CAC7C,KAAK;CACN,CAAC;AAEJ,MAAa,+BACX,WACA,UAEA,uBAAuB;CACrB,UAAU;CACV,cAAc,cAAc,UAAU;CACtC,KAAK;CACL,SAAS,6BAA6B,MAAM;CAC7C,CAAC;AAIJ,MAAa,4BAA4B,UAAkB,QACzD,uBAAuB;CACrB,cAAc,GAAG,SAAS,gBAAgB,IAAI,KAAK,OAAO,CAAC;CAC3D,KAAK;CACN,CAAC;AAEJ,MAAa,mCAAmC,YAC9C,4EAA4E,QACzE,KAAK,WAAW;CACf,MAAM,EAAE,SAAS,oBAAoB,OAAO;AAC5C,QAAO,GAAG,OAAO,IAAI,KAAK;EAC1B,CACD,KAAK,KAAK;AAEf,MAAa,uBAAuB,uBAAuB;CACzD,cAAc;CACd,KAAK;CACL,SAAS;CACV,CAAC;AAEF,MAAa,oBAAoB,6BAA6B;CAC5D,cAAc;CACd,KAAK;CACN,CAAC;AAEF,MAAa,8BAA8B,YACzC,qDAAqD,QAAQ,KAAK,KAAK,CAAC;AAE1E,MAAa,uCAAuC,YAClD,+DAA+D,QAAQ,KAAK,KAAK,CAAC;AAEpF,MAAa,qCAAqC,SAChD,4BAA4B,KAAK;AAEnC,MAAa,mCAAmC,uBAAuB;CACrE,cAAc;CACd,QAAQ;CACR,KAAK;CACN,CAAC;AAEF,MAAa,mCAAmC,uBAAuB;CACrE,cAAc;CACd,QAAQ;CACR,KAAK;CACN,CAAC;AAEF,MAAa,sCAAsC,SACjD,SAAS,QACL,mEAAmE,mBAAmB,sCACtF,0DAA0D,qBAAqB;AAErF,MAAa,2CACX;AAGF,MAAa,kCAAkC;AAE/C,MAAa,sCAAsC,wGAAwG,mBAAmB"}
|
|
1
|
+
{"version":3,"file":"createErrors.mjs","names":[],"sources":["../../src/errors/createErrors.ts"],"sourcesContent":["// ---- ERRORS ---- //\n\nimport { getLocaleProperties } from '@generaltranslation/format';\nimport {\n createGtNextDiagnostic,\n createGtNextPluginDiagnostic,\n formatDiagnosticErrorDetails,\n} from './diagnostics';\nimport { BABEL_PLUGIN_SUPPORT, SWC_PLUGIN_SUPPORT } from '../plugin/constants';\n\nexport const remoteTranslationsError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Remote translations could not be loaded',\n fix: 'Check your project ID, API key, and network connection, then try again',\n wayOut: 'Source content will render as a fallback',\n});\n\nexport const customLoadTranslationsError = (locale: string = '') =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `Locally stored translations could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadTranslations(), make sure it returns translations for the requested locale',\n });\n\nexport const customLoadDictionaryWarning = (locale: string = '') =>\n createGtNextDiagnostic({\n severity: 'Warning',\n whatHappened: `The local dictionary could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadDictionary(), make sure it returns a dictionary for the requested locale',\n });\n\nexport const createUnresolvedNextVersionError = (error: Error) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'The installed Next.js version could not be resolved',\n fix: 'Check that next is installed in this project',\n details: error.message,\n });\n\nexport const createUnresolvedReactVersionError = (error: Error) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'The installed React version could not be resolved',\n fix: 'Check that react is installed in this project',\n details: error.message,\n });\n\nexport const devApiKeyIncludedInProductionError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Production builds cannot use a development API key',\n fix: 'Replace it with a production API key',\n});\n\nexport const createDictionarySubsetError = (id: string, functionName: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `${functionName} with id \"${id}\" could not read a valid dictionary subtree`,\n fix: 'Make sure the id maps to the correct subroute of the dictionary',\n });\n\nexport const unresolvedCustomLoadDictionaryError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'loadDictionary() was found during the build but could not be resolved at runtime',\n fix: 'Export a loadDictionary() function from the configured file',\n});\n\nexport const unresolvedCustomLoadTranslationsError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'loadTranslations() was found during the build but could not be resolved at runtime',\n fix: 'Export a loadTranslations() function from the configured file',\n});\n\nexport const unresolvedLoadDictionaryBuildError = (path: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `The file defining loadDictionary() could not be resolved at ${path}`,\n fix: 'Check the configured path and try again',\n });\n\nexport const unresolvedLoadTranslationsBuildError = (path: string) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `The file defining loadTranslations() could not be resolved at ${path}`,\n fix: 'Check the configured path and try again',\n });\n\nexport const conflictingConfigurationBuildError = (conflicts: string[]) =>\n `gt-next Error: Conflicting configuration${\n conflicts.length > 1 ? 's' : ''\n } detected. Resolve the following conflicts before building your app:\\n${conflicts.join(\n '\\n'\n )}`;\n\nexport const typesFileError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'A types-only entry point was executed at runtime',\n fix: 'Import from the appropriate gt-next runtime entry point instead',\n});\n\nexport const getTranslationsSnapshotRscError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'getTranslationsSnapshot() is not available for React Server Components',\n fix: 'Use gt-next build-time translation helpers in the App Router, or call getTranslationsSnapshot() from a Pages Router entry point',\n});\n\nexport const withGTStaticPropsClientError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'withGTStaticProps() cannot run in the browser',\n why: 'Static props are generated on the server by the Pages Router',\n fix: 'Export withGTStaticProps() from a Pages Router page module',\n});\n\nexport const withGTStaticPropsRscError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'withGTStaticProps() is not available for React Server Components',\n why: 'This helper supports the Pages Router, not the App Router',\n fix: 'Use gt-next build-time translation helpers in the App Router, or export withGTStaticProps() from a Pages Router page module',\n});\n\nexport const invalidLocalesError = (locales: string[]) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid locale codes in your configuration',\n fix: 'Specify a list of valid locales or use \"customMapping\" to define aliases for the invalid locales',\n details: locales,\n });\n\nexport const invalidCanonicalLocalesError = (locales: string[]) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid canonical locale codes in your configuration',\n fix: 'Use valid BCP 47 locale codes before starting translation',\n details: locales,\n });\n\nexport const createInvalidRequestLocaleWarning = (\n locale: string,\n defaultLocale: string\n) =>\n createGtNextDiagnostic({\n severity: 'Warning',\n whatHappened: `Locale \"${locale}\" is not valid or is not supported by this app`,\n wayOut: `The default locale \"${defaultLocale}\" will be used for this request`,\n fix: 'Use a valid BCP 47 locale code, add a custom mapping, or configure the locale in gt-next',\n });\n\nexport const createInvalidPathRegexError = (\n pathRegex: string,\n error: unknown\n) =>\n createGtNextDiagnostic({\n severity: 'Error',\n whatHappened: `pathRegex \"${pathRegex}\" is not a valid regular expression`,\n fix: 'Pass a valid JavaScript regular expression string to withGTConfig()',\n details: formatDiagnosticErrorDetails(error),\n });\n\n// ---- WARNINGS ---- //\n\nexport const createBadFilepathWarning = (filename: string, dir: string[]) =>\n createGtNextDiagnostic({\n whatHappened: `${filename} was found in ${dir.join(' or ')}, which is not supported`,\n fix: 'Move it to your project root so gt-next can load it',\n });\n\nexport const createUnsupportedLocalesWarning = (locales: string[]) =>\n `gt-next: The following locales are currently unsupported by our service: ${locales\n .map((locale) => {\n const { name } = getLocaleProperties(locale);\n return `${locale} (${name})`;\n })\n .join(', ')}`;\n\nexport const projectIdMissingWarn = createGtNextDiagnostic({\n whatHappened: 'Runtime translation needs a project ID',\n fix: 'Set GT_PROJECT_ID in your environment or pass projectId to withGTConfig()',\n docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const APIKeyMissingWarn = createGtNextPluginDiagnostic({\n whatHappened: 'Runtime translation needs a development API key',\n fix: 'Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation',\n});\n\nexport const standardizedLocalesWarning = (locales: string[]) =>\n `gt-next: The following locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const standardizedCanonicalLocalesWarning = (locales: string[]) =>\n `gt-next: The following canonical locales were standardized: ${locales.join(', ')}. Use the standardized codes in your config to avoid this warning.`;\n\nexport const createGTCompilerUnresolvedWarning = (type: 'babel' | 'swc') =>\n createGtNextPluginDiagnostic({\n whatHappened: `The GT ${type} compiler could not be resolved`,\n wayOut: 'Skipping compiler optimizations',\n ...(type === 'babel' && {\n fix: 'Install @generaltranslation/compiler to enable the experimental babel compiler',\n }),\n });\n\nexport const customGetLocaleUnresolvedWarning = createGtNextDiagnostic({\n whatHappened: 'Custom getLocale() could not be resolved',\n wayOut: 'gt-next will fall back to default locale detection',\n fix: 'Export a getLocale() function from the configured request file',\n});\n\nexport const customGetRegionUnresolvedWarning = createGtNextDiagnostic({\n whatHappened: 'Custom getRegion() could not be resolved',\n wayOut: 'gt-next will fall back to default region detection',\n fix: 'Export a getRegion() function from the configured request file',\n});\n\nexport const createGTCompilerUnavailableWarning = (type: 'babel' | 'swc') =>\n type === 'swc'\n ? `gt-next (plugin): The GT swc compiler is compatible with < next@${SWC_PLUGIN_SUPPORT}. Skipping compiler optimizations.`\n : `gt-next (plugin): The GT babel compiler requires react@${BABEL_PLUGIN_SUPPORT} or newer. Skipping compiler optimizations.`;\n\nexport const babelCompilerTurbopackUnavailableWarning =\n `gt-next (plugin): The GT babel compiler is not compatible with Turbopack. ` +\n `To use compiler optimizations with Turbopack, set experimentalCompilerOptions: { type: 'swc' }.`;\n\nexport const disablingCompileTimeHashWarning = `gt-next (plugin): Compile-time hash is disabled. Compiler optimizations are inactive.`;\n\nexport const swcPluginCompatibilityChangeWarning = `gt-next (plugin): As of gt-next@6.12.4, SWC plugin support is disabled for Next.js versions prior to ${SWC_PLUGIN_SUPPORT}. Update to the latest version of Next.js.`;\n"],"mappings":";;;;AAUA,MAAa,0BAA0B,uBAAuB;CAC5D,UAAU;CACV,cAAc;CACd,KAAK;CACL,QAAQ;CACT,CAAC;AAEF,MAAa,+BAA+B,SAAiB,O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ACrE,cAAc;CACd,QAAQ;CACR,KAAK;CACN,CAAC;AAEF,MAAa,mCAAmC,uBAAuB;CACrE,cAAc;CACd,QAAQ;CACR,KAAK;CACN,CAAC;AAEF,MAAa,sCAAsC,SACjD,SAAS,QACL,mEAAmE,mBAAmB,sCACtF,0DAA0D,qBAAqB;AAErF,MAAa,2CACX;AAGF,MAAa,kCAAkC;AAE/C,MAAa,sCAAsC,wGAAwG,mBAAmB"}
|
package/dist/errors/ssg.d.ts
CHANGED
package/dist/errors/ssg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssg.d.ts","sourceRoot":"","sources":["../../src/errors/ssg.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iCAAiC,QAM5C,CAAC"}
|
|
1
|
+
{"version":3,"file":"ssg.d.ts","sourceRoot":"","sources":["../../src/errors/ssg.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iCAAiC,QAM5C,CAAC;AAEH,eAAO,MAAM,mCAAmC,QAM9C,CAAC"}
|
package/dist/errors/ssg.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_errors_diagnostics = require("./diagnostics.js");
|
|
2
3
|
//#region src/errors/ssg.ts
|
|
3
|
-
const noLocalesCouldBeDeterminedWarning =
|
|
4
|
+
const noLocalesCouldBeDeterminedWarning = require_errors_diagnostics.createGtNextDiagnostic({
|
|
4
5
|
whatHappened: "No locale could be determined for this request",
|
|
5
6
|
wayOut: "gt-next will fall back to the default locale",
|
|
6
7
|
fix: "If you use SSG, configure locale resolution",
|
|
7
8
|
docsUrl: "https://generaltranslation.com/en/docs/next/guides/ssg#ssg-custom-get-locale"
|
|
8
9
|
});
|
|
10
|
+
const withGTStaticPropsLocaleRoutingError = require_errors_diagnostics.createGtNextDiagnostic({
|
|
11
|
+
severity: "Error",
|
|
12
|
+
whatHappened: "withGTStaticProps() could not determine the statically generated locale",
|
|
13
|
+
why: "Without Pages Router locale routing, Next.js generates only one version of this page",
|
|
14
|
+
fix: "Add i18n locales and defaultLocale to your Next.js configuration"
|
|
15
|
+
});
|
|
9
16
|
//#endregion
|
|
10
17
|
exports.noLocalesCouldBeDeterminedWarning = noLocalesCouldBeDeterminedWarning;
|
|
18
|
+
exports.withGTStaticPropsLocaleRoutingError = withGTStaticPropsLocaleRoutingError;
|
|
11
19
|
|
|
12
20
|
//# sourceMappingURL=ssg.js.map
|
package/dist/errors/ssg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssg.js","names":["createGtNextDiagnostic"],"sources":["../../src/errors/ssg.ts"],"sourcesContent":["import { createGtNextDiagnostic } from './diagnostics';\n\n// ========== WARNINGS ========== //\n\n// This was (1) triggered by SSG without running middleware, or (2) triggered by a request with no locale headers (also no middleware).\nexport const noLocalesCouldBeDeterminedWarning = createGtNextDiagnostic({\n whatHappened: 'No locale could be determined for this request',\n wayOut: 'gt-next will fall back to the default locale',\n fix: 'If you use SSG, configure locale resolution',\n docsUrl:\n 'https://generaltranslation.com/en/docs/next/guides/ssg#ssg-custom-get-locale',\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ssg.js","names":["createGtNextDiagnostic"],"sources":["../../src/errors/ssg.ts"],"sourcesContent":["import { createGtNextDiagnostic } from './diagnostics';\n\n// ========== WARNINGS ========== //\n\n// This was (1) triggered by SSG without running middleware, or (2) triggered by a request with no locale headers (also no middleware).\nexport const noLocalesCouldBeDeterminedWarning = createGtNextDiagnostic({\n whatHappened: 'No locale could be determined for this request',\n wayOut: 'gt-next will fall back to the default locale',\n fix: 'If you use SSG, configure locale resolution',\n docsUrl:\n 'https://generaltranslation.com/en/docs/next/guides/ssg#ssg-custom-get-locale',\n});\n\nexport const withGTStaticPropsLocaleRoutingError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'withGTStaticProps() could not determine the statically generated locale',\n why: 'Without Pages Router locale routing, Next.js generates only one version of this page',\n fix: 'Add i18n locales and defaultLocale to your Next.js configuration',\n});\n"],"mappings":";;;AAKA,MAAa,oCAAoCA,2BAAAA,uBAAuB;CACtE,cAAc;CACd,QAAQ;CACR,KAAK;CACL,SACE;CACH,CAAC;AAEF,MAAa,sCAAsCA,2BAAAA,uBAAuB;CACxE,UAAU;CACV,cACE;CACF,KAAK;CACL,KAAK;CACN,CAAC"}
|
package/dist/errors/ssg.mjs
CHANGED
|
@@ -6,7 +6,13 @@ const noLocalesCouldBeDeterminedWarning = createGtNextDiagnostic({
|
|
|
6
6
|
fix: "If you use SSG, configure locale resolution",
|
|
7
7
|
docsUrl: "https://generaltranslation.com/en/docs/next/guides/ssg#ssg-custom-get-locale"
|
|
8
8
|
});
|
|
9
|
+
const withGTStaticPropsLocaleRoutingError = createGtNextDiagnostic({
|
|
10
|
+
severity: "Error",
|
|
11
|
+
whatHappened: "withGTStaticProps() could not determine the statically generated locale",
|
|
12
|
+
why: "Without Pages Router locale routing, Next.js generates only one version of this page",
|
|
13
|
+
fix: "Add i18n locales and defaultLocale to your Next.js configuration"
|
|
14
|
+
});
|
|
9
15
|
//#endregion
|
|
10
|
-
export { noLocalesCouldBeDeterminedWarning };
|
|
16
|
+
export { noLocalesCouldBeDeterminedWarning, withGTStaticPropsLocaleRoutingError };
|
|
11
17
|
|
|
12
18
|
//# sourceMappingURL=ssg.mjs.map
|
package/dist/errors/ssg.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssg.mjs","names":[],"sources":["../../src/errors/ssg.ts"],"sourcesContent":["import { createGtNextDiagnostic } from './diagnostics';\n\n// ========== WARNINGS ========== //\n\n// This was (1) triggered by SSG without running middleware, or (2) triggered by a request with no locale headers (also no middleware).\nexport const noLocalesCouldBeDeterminedWarning = createGtNextDiagnostic({\n whatHappened: 'No locale could be determined for this request',\n wayOut: 'gt-next will fall back to the default locale',\n fix: 'If you use SSG, configure locale resolution',\n docsUrl:\n 'https://generaltranslation.com/en/docs/next/guides/ssg#ssg-custom-get-locale',\n});\n"],"mappings":";;AAKA,MAAa,oCAAoC,uBAAuB;CACtE,cAAc;CACd,QAAQ;CACR,KAAK;CACL,SACE;CACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"ssg.mjs","names":[],"sources":["../../src/errors/ssg.ts"],"sourcesContent":["import { createGtNextDiagnostic } from './diagnostics';\n\n// ========== WARNINGS ========== //\n\n// This was (1) triggered by SSG without running middleware, or (2) triggered by a request with no locale headers (also no middleware).\nexport const noLocalesCouldBeDeterminedWarning = createGtNextDiagnostic({\n whatHappened: 'No locale could be determined for this request',\n wayOut: 'gt-next will fall back to the default locale',\n fix: 'If you use SSG, configure locale resolution',\n docsUrl:\n 'https://generaltranslation.com/en/docs/next/guides/ssg#ssg-custom-get-locale',\n});\n\nexport const withGTStaticPropsLocaleRoutingError = createGtNextDiagnostic({\n severity: 'Error',\n whatHappened:\n 'withGTStaticProps() could not determine the statically generated locale',\n why: 'Without Pages Router locale routing, Next.js generates only one version of this page',\n fix: 'Add i18n locales and defaultLocale to your Next.js configuration',\n});\n"],"mappings":";;AAKA,MAAa,oCAAoC,uBAAuB;CACtE,cAAc;CACd,QAAQ;CACR,KAAK;CACL,SACE;CACH,CAAC;AAEF,MAAa,sCAAsC,uBAAuB;CACxE,UAAU;CACV,cACE;CACF,KAAK;CACL,KAAK;CACN,CAAC"}
|
package/dist/index.client.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { GetServerSideProps, GetServerSidePropsContext, PreviewData } from 'next';
|
|
2
2
|
import type { ParsedUrlQuery } from 'querystring';
|
|
3
3
|
import type { WithGTServerSideProps } from './pages-dir/withGTServerSideProps';
|
|
4
|
+
import type { WithGTStaticProps, WithGTStaticPropsFunction } from './pages-dir/withGTStaticProps';
|
|
4
5
|
export declare function parseLocale<Params extends ParsedUrlQuery = ParsedUrlQuery, Preview extends PreviewData = PreviewData>(_: GetServerSidePropsContext<Params, Preview>): string;
|
|
5
6
|
export declare function withGTServerSideProps<Props extends Record<string, unknown> = Record<string, unknown>, Params extends ParsedUrlQuery = ParsedUrlQuery, Preview extends PreviewData = PreviewData>(_?: GetServerSideProps<Props, Params, Preview>): GetServerSideProps<WithGTServerSideProps<Props>, Params, Preview>;
|
|
7
|
+
export declare const withGTStaticProps: WithGTStaticPropsFunction;
|
|
6
8
|
export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RegionSelector, RelativeTime, T, Var, } from 'gt-react';
|
|
7
9
|
export { useDefaultLocale, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useLocaleSelector, useMessages, useRegion, useSetLocale, useTranslations, } from 'gt-react';
|
|
8
10
|
export { decodeMsg, decodeOptions, decodeVars, declareVar, derive, getDefaultLocale, getLocaleProperties, getLocales, resolveCanonicalLocale, getTranslationsSnapshot, getVersionId, gtFallback, mFallback, msg, } from 'gt-react';
|
|
9
11
|
export { isLocaleSupported } from './request/localeValidation';
|
|
10
12
|
export type { GTTranslationOptions, RuntimeTranslationOptions } from 'gt-react';
|
|
11
|
-
export type { WithGTServerSideProps };
|
|
13
|
+
export type { WithGTServerSideProps, WithGTStaticProps };
|
|
12
14
|
//# sourceMappingURL=index.client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../src/index.client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,WAAW,EACZ,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../src/index.client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,WAAW,EACZ,MAAM,MAAM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BAAuB,EACvB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,GAAG,GACJ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAChF,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/index.client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("./_virtual/_rolldown/runtime.js");
|
|
4
|
+
const require_errors_createErrors = require("./errors/createErrors.js");
|
|
4
5
|
const require_setup_initGT_client = require("./setup/initGT.client.js");
|
|
5
6
|
const require_request_localeValidation = require("./request/localeValidation.js");
|
|
6
7
|
let gt_react = require("gt-react");
|
|
@@ -12,6 +13,9 @@ function parseLocale(_) {
|
|
|
12
13
|
function withGTServerSideProps(_) {
|
|
13
14
|
throw new Error("withGTServerSideProps() is only available from gt-next on the server.");
|
|
14
15
|
}
|
|
16
|
+
const withGTStaticProps = () => {
|
|
17
|
+
throw new Error(require_errors_createErrors.withGTStaticPropsClientError);
|
|
18
|
+
};
|
|
15
19
|
//#endregion
|
|
16
20
|
Object.defineProperty(exports, "Branch", {
|
|
17
21
|
enumerable: true,
|
|
@@ -238,5 +242,6 @@ Object.defineProperty(exports, "useTranslations", {
|
|
|
238
242
|
}
|
|
239
243
|
});
|
|
240
244
|
exports.withGTServerSideProps = withGTServerSideProps;
|
|
245
|
+
exports.withGTStaticProps = withGTStaticProps;
|
|
241
246
|
|
|
242
247
|
//# sourceMappingURL=index.client.js.map
|
package/dist/index.client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.js","names":["initializeGTClient"],"sources":["../src/index.client.ts"],"sourcesContent":["'use client';\n\nimport { initializeGTClient } from './setup/initGT.client';\ninitializeGTClient();\n\nimport type {\n GetServerSideProps,\n GetServerSidePropsContext,\n PreviewData,\n} from 'next';\nimport type { ParsedUrlQuery } from 'querystring';\nimport type { WithGTServerSideProps } from './pages-dir/withGTServerSideProps';\n\n// ===== Unsupported Server APIs ===== //\nexport function parseLocale<\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(_: GetServerSidePropsContext<Params, Preview>): string {\n throw new Error(\n 'parseLocale() is only available from gt-next on the server.'\n );\n}\n\nexport function withGTServerSideProps<\n Props extends Record<string, unknown> = Record<string, unknown>,\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(\n _?: GetServerSideProps<Props, Params, Preview>\n): GetServerSideProps<WithGTServerSideProps<Props>, Params, Preview> {\n throw new Error(\n 'withGTServerSideProps() is only available from gt-next on the server.'\n );\n}\n\n// ===== Components ===== //\nexport {\n Branch,\n Currency,\n DateTime,\n Derive,\n GTProvider,\n LocaleSelector,\n Num,\n Plural,\n RegionSelector,\n RelativeTime,\n T,\n Var,\n} from 'gt-react';\n\n// ===== Hooks ===== //\nexport {\n useDefaultLocale,\n useGT,\n useLocale,\n useLocaleDirection,\n useLocaleProperties,\n useLocales,\n useLocaleSelector,\n useMessages,\n useRegion,\n useSetLocale,\n useTranslations,\n} from 'gt-react';\n\n// ===== Functions ===== //\nexport {\n decodeMsg,\n decodeOptions,\n decodeVars,\n declareVar,\n derive,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getTranslationsSnapshot,\n getVersionId,\n gtFallback,\n mFallback,\n msg,\n} from 'gt-react';\nexport { isLocaleSupported } from './request/localeValidation';\n\n// ===== Types ===== //\nexport type { GTTranslationOptions, RuntimeTranslationOptions } from 'gt-react';\nexport type { WithGTServerSideProps };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.client.js","names":["initializeGTClient","withGTStaticPropsClientError"],"sources":["../src/index.client.ts"],"sourcesContent":["'use client';\n\nimport { initializeGTClient } from './setup/initGT.client';\ninitializeGTClient();\n\nimport type {\n GetServerSideProps,\n GetServerSidePropsContext,\n PreviewData,\n} from 'next';\nimport type { ParsedUrlQuery } from 'querystring';\nimport type { WithGTServerSideProps } from './pages-dir/withGTServerSideProps';\nimport type {\n WithGTStaticProps,\n WithGTStaticPropsFunction,\n} from './pages-dir/withGTStaticProps';\nimport { withGTStaticPropsClientError } from './errors/createErrors';\n\n// ===== Unsupported Server APIs ===== //\nexport function parseLocale<\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(_: GetServerSidePropsContext<Params, Preview>): string {\n throw new Error(\n 'parseLocale() is only available from gt-next on the server.'\n );\n}\n\nexport function withGTServerSideProps<\n Props extends Record<string, unknown> = Record<string, unknown>,\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(\n _?: GetServerSideProps<Props, Params, Preview>\n): GetServerSideProps<WithGTServerSideProps<Props>, Params, Preview> {\n throw new Error(\n 'withGTServerSideProps() is only available from gt-next on the server.'\n );\n}\n\nexport const withGTStaticProps: WithGTStaticPropsFunction = () => {\n throw new Error(withGTStaticPropsClientError);\n};\n\n// ===== Components ===== //\nexport {\n Branch,\n Currency,\n DateTime,\n Derive,\n GTProvider,\n LocaleSelector,\n Num,\n Plural,\n RegionSelector,\n RelativeTime,\n T,\n Var,\n} from 'gt-react';\n\n// ===== Hooks ===== //\nexport {\n useDefaultLocale,\n useGT,\n useLocale,\n useLocaleDirection,\n useLocaleProperties,\n useLocales,\n useLocaleSelector,\n useMessages,\n useRegion,\n useSetLocale,\n useTranslations,\n} from 'gt-react';\n\n// ===== Functions ===== //\nexport {\n decodeMsg,\n decodeOptions,\n decodeVars,\n declareVar,\n derive,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getTranslationsSnapshot,\n getVersionId,\n gtFallback,\n mFallback,\n msg,\n} from 'gt-react';\nexport { isLocaleSupported } from './request/localeValidation';\n\n// ===== Types ===== //\nexport type { GTTranslationOptions, RuntimeTranslationOptions } from 'gt-react';\nexport type { WithGTServerSideProps, WithGTStaticProps };\n"],"mappings":";;;;;;;;AAGAA,4BAAAA,oBAAoB;AAgBpB,SAAgB,YAGd,GAAuD;AACvD,OAAM,IAAI,MACR,8DACD;;AAGH,SAAgB,sBAKd,GACmE;AACnE,OAAM,IAAI,MACR,wEACD;;AAGH,MAAa,0BAAqD;AAChE,OAAM,IAAI,MAAMC,4BAAAA,6BAA6B"}
|
package/dist/index.client.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { withGTStaticPropsClientError } from "./errors/createErrors.mjs";
|
|
2
3
|
import { initializeGTClient } from "./setup/initGT.client.mjs";
|
|
3
4
|
import { isLocaleSupported } from "./request/localeValidation.mjs";
|
|
4
5
|
import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RegionSelector, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getLocaleProperties, getLocales, getTranslationsSnapshot, getVersionId, gtFallback, mFallback, msg, resolveCanonicalLocale, useDefaultLocale, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useSetLocale, useTranslations } from "gt-react";
|
|
@@ -10,7 +11,10 @@ function parseLocale(_) {
|
|
|
10
11
|
function withGTServerSideProps(_) {
|
|
11
12
|
throw new Error("withGTServerSideProps() is only available from gt-next on the server.");
|
|
12
13
|
}
|
|
14
|
+
const withGTStaticProps = () => {
|
|
15
|
+
throw new Error(withGTStaticPropsClientError);
|
|
16
|
+
};
|
|
13
17
|
//#endregion
|
|
14
|
-
export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RegionSelector, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getLocaleProperties, getLocales, getTranslationsSnapshot, getVersionId, gtFallback, isLocaleSupported, mFallback, msg, parseLocale, resolveCanonicalLocale, useDefaultLocale, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useSetLocale, useTranslations, withGTServerSideProps };
|
|
18
|
+
export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RegionSelector, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getLocaleProperties, getLocales, getTranslationsSnapshot, getVersionId, gtFallback, isLocaleSupported, mFallback, msg, parseLocale, resolveCanonicalLocale, useDefaultLocale, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useSetLocale, useTranslations, withGTServerSideProps, withGTStaticProps };
|
|
15
19
|
|
|
16
20
|
//# sourceMappingURL=index.client.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.mjs","names":[],"sources":["../src/index.client.ts"],"sourcesContent":["'use client';\n\nimport { initializeGTClient } from './setup/initGT.client';\ninitializeGTClient();\n\nimport type {\n GetServerSideProps,\n GetServerSidePropsContext,\n PreviewData,\n} from 'next';\nimport type { ParsedUrlQuery } from 'querystring';\nimport type { WithGTServerSideProps } from './pages-dir/withGTServerSideProps';\n\n// ===== Unsupported Server APIs ===== //\nexport function parseLocale<\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(_: GetServerSidePropsContext<Params, Preview>): string {\n throw new Error(\n 'parseLocale() is only available from gt-next on the server.'\n );\n}\n\nexport function withGTServerSideProps<\n Props extends Record<string, unknown> = Record<string, unknown>,\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(\n _?: GetServerSideProps<Props, Params, Preview>\n): GetServerSideProps<WithGTServerSideProps<Props>, Params, Preview> {\n throw new Error(\n 'withGTServerSideProps() is only available from gt-next on the server.'\n );\n}\n\n// ===== Components ===== //\nexport {\n Branch,\n Currency,\n DateTime,\n Derive,\n GTProvider,\n LocaleSelector,\n Num,\n Plural,\n RegionSelector,\n RelativeTime,\n T,\n Var,\n} from 'gt-react';\n\n// ===== Hooks ===== //\nexport {\n useDefaultLocale,\n useGT,\n useLocale,\n useLocaleDirection,\n useLocaleProperties,\n useLocales,\n useLocaleSelector,\n useMessages,\n useRegion,\n useSetLocale,\n useTranslations,\n} from 'gt-react';\n\n// ===== Functions ===== //\nexport {\n decodeMsg,\n decodeOptions,\n decodeVars,\n declareVar,\n derive,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getTranslationsSnapshot,\n getVersionId,\n gtFallback,\n mFallback,\n msg,\n} from 'gt-react';\nexport { isLocaleSupported } from './request/localeValidation';\n\n// ===== Types ===== //\nexport type { GTTranslationOptions, RuntimeTranslationOptions } from 'gt-react';\nexport type { WithGTServerSideProps };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.client.mjs","names":[],"sources":["../src/index.client.ts"],"sourcesContent":["'use client';\n\nimport { initializeGTClient } from './setup/initGT.client';\ninitializeGTClient();\n\nimport type {\n GetServerSideProps,\n GetServerSidePropsContext,\n PreviewData,\n} from 'next';\nimport type { ParsedUrlQuery } from 'querystring';\nimport type { WithGTServerSideProps } from './pages-dir/withGTServerSideProps';\nimport type {\n WithGTStaticProps,\n WithGTStaticPropsFunction,\n} from './pages-dir/withGTStaticProps';\nimport { withGTStaticPropsClientError } from './errors/createErrors';\n\n// ===== Unsupported Server APIs ===== //\nexport function parseLocale<\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(_: GetServerSidePropsContext<Params, Preview>): string {\n throw new Error(\n 'parseLocale() is only available from gt-next on the server.'\n );\n}\n\nexport function withGTServerSideProps<\n Props extends Record<string, unknown> = Record<string, unknown>,\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(\n _?: GetServerSideProps<Props, Params, Preview>\n): GetServerSideProps<WithGTServerSideProps<Props>, Params, Preview> {\n throw new Error(\n 'withGTServerSideProps() is only available from gt-next on the server.'\n );\n}\n\nexport const withGTStaticProps: WithGTStaticPropsFunction = () => {\n throw new Error(withGTStaticPropsClientError);\n};\n\n// ===== Components ===== //\nexport {\n Branch,\n Currency,\n DateTime,\n Derive,\n GTProvider,\n LocaleSelector,\n Num,\n Plural,\n RegionSelector,\n RelativeTime,\n T,\n Var,\n} from 'gt-react';\n\n// ===== Hooks ===== //\nexport {\n useDefaultLocale,\n useGT,\n useLocale,\n useLocaleDirection,\n useLocaleProperties,\n useLocales,\n useLocaleSelector,\n useMessages,\n useRegion,\n useSetLocale,\n useTranslations,\n} from 'gt-react';\n\n// ===== Functions ===== //\nexport {\n decodeMsg,\n decodeOptions,\n decodeVars,\n declareVar,\n derive,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getTranslationsSnapshot,\n getVersionId,\n gtFallback,\n mFallback,\n msg,\n} from 'gt-react';\nexport { isLocaleSupported } from './request/localeValidation';\n\n// ===== Types ===== //\nexport type { GTTranslationOptions, RuntimeTranslationOptions } from 'gt-react';\nexport type { WithGTServerSideProps, WithGTStaticProps };\n"],"mappings":";;;;;;AAGA,oBAAoB;AAgBpB,SAAgB,YAGd,GAAuD;AACvD,OAAM,IAAI,MACR,8DACD;;AAGH,SAAgB,sBAKd,GACmE;AACnE,OAAM,IAAI,MACR,wEACD;;AAGH,MAAa,0BAAqD;AAChE,OAAM,IAAI,MAAM,6BAA6B"}
|
package/dist/index.rsc.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import 'server-only';
|
|
|
2
2
|
import type { GetServerSideProps, GetServerSidePropsContext, PreviewData } from 'next';
|
|
3
3
|
import type { ParsedUrlQuery } from 'querystring';
|
|
4
4
|
import type { WithGTServerSideProps } from './pages-dir/withGTServerSideProps';
|
|
5
|
+
import type { WithGTStaticProps, WithGTStaticPropsFunction } from './pages-dir/withGTStaticProps';
|
|
5
6
|
export { Branch } from './branches/Branch';
|
|
6
7
|
export { Currency } from './variables/Currency';
|
|
7
8
|
export { DateTime } from './variables/DateTime';
|
|
@@ -32,10 +33,15 @@ export declare function parseLocale<Params extends ParsedUrlQuery = ParsedUrlQue
|
|
|
32
33
|
* This function is for next-pages use, not next-app use
|
|
33
34
|
*/
|
|
34
35
|
export declare function withGTServerSideProps<Props extends Record<string, unknown> = Record<string, unknown>, Params extends ParsedUrlQuery = ParsedUrlQuery, Preview extends PreviewData = PreviewData>(_?: GetServerSideProps<Props, Params, Preview>): GetServerSideProps<WithGTServerSideProps<Props>, Params, Preview>;
|
|
36
|
+
/**
|
|
37
|
+
* Placeholder for withGTStaticProps()
|
|
38
|
+
* This function is for next-pages use, not next-app use
|
|
39
|
+
*/
|
|
40
|
+
export declare const withGTStaticProps: WithGTStaticPropsFunction;
|
|
35
41
|
export { Derive } from 'gt-react';
|
|
36
42
|
export { useDefaultLocale, useLocaleProperties, useLocales } from 'gt-react';
|
|
37
43
|
export { decodeMsg, decodeOptions, decodeVars, declareVar, derive, getDefaultLocale, getLocaleProperties, getLocales, resolveCanonicalLocale, getVersionId, gtFallback, mFallback, msg, } from 'gt-react';
|
|
38
44
|
export { isLocaleSupported } from './request/localeValidation';
|
|
39
45
|
export type { GTTranslationOptions, RuntimeTranslationOptions } from 'gt-react';
|
|
40
|
-
export type { WithGTServerSideProps };
|
|
46
|
+
export type { WithGTServerSideProps, WithGTStaticProps };
|
|
41
47
|
//# sourceMappingURL=index.rsc.d.ts.map
|
package/dist/index.rsc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.rsc.d.ts","sourceRoot":"","sources":["../src/index.rsc.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,WAAW,EACZ,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM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