@fluenti/next 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-DyIg6Wiv.js +7 -0
- package/dist/i18n-config.cjs +1 -1
- package/dist/i18n-config.cjs.map +1 -1
- package/dist/index.cjs +69 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +188 -124
- package/dist/index.js.map +1 -1
- package/dist/loader.cjs +1 -1
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.js +5 -0
- package/dist/loader.js.map +1 -1
- package/dist/middleware.cjs +1 -1
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.js +66 -71
- package/dist/middleware.js.map +1 -1
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.js +61 -63
- package/dist/navigation.js.map +1 -1
- package/dist/{client-provider.d.ts → packages/next-plugin/src/client-provider.d.ts} +1 -1
- package/dist/packages/next-plugin/src/client-provider.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/create-navigation.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/dev-runner.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/dev-watcher.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/generate-server-module.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/i18n-config.d.ts.map +1 -0
- package/dist/{index.d.ts → packages/next-plugin/src/index.d.ts} +32 -29
- package/dist/packages/next-plugin/src/index.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/middleware.d.ts.map +1 -0
- package/dist/{navigation.d.ts → packages/next-plugin/src/navigation.d.ts} +2 -2
- package/dist/packages/next-plugin/src/navigation.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/provider.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/read-config.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/routing.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/server.d.ts.map +1 -0
- package/dist/{types.d.ts → packages/next-plugin/src/types.d.ts} +11 -1
- package/dist/packages/next-plugin/src/types.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/with-fluenti.d.ts.map +1 -0
- package/dist/packages/next-plugin/src/with-locale.d.ts.map +1 -0
- package/dist/provider.cjs +1 -1
- package/dist/provider.cjs.map +1 -1
- package/dist/routing-CRln5Gw7.js +65 -0
- package/dist/routing-CRln5Gw7.js.map +1 -0
- package/dist/routing-D4p8HvMH.cjs +2 -0
- package/dist/routing-D4p8HvMH.cjs.map +1 -0
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/package.json +16 -16
- package/dist/client-provider.d.ts.map +0 -1
- package/dist/create-navigation.d.ts.map +0 -1
- package/dist/dev-runner.d.ts.map +0 -1
- package/dist/dev-watcher.d.ts.map +0 -1
- package/dist/generate-server-module.d.ts.map +0 -1
- package/dist/i18n-config.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/middleware.d.ts.map +0 -1
- package/dist/navigation.d.ts.map +0 -1
- package/dist/provider.d.ts.map +0 -1
- package/dist/read-config.d.ts.map +0 -1
- package/dist/routing-DBVu_7tk.js +0 -72
- package/dist/routing-DBVu_7tk.js.map +0 -1
- package/dist/routing-Dy57-Uao.cjs +0 -2
- package/dist/routing-Dy57-Uao.cjs.map +0 -1
- package/dist/routing.d.ts.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/with-fluenti.d.ts.map +0 -1
- package/dist/with-locale.d.ts.map +0 -1
- /package/dist/{create-navigation.d.ts → packages/next-plugin/src/create-navigation.d.ts} +0 -0
- /package/dist/{dev-runner.d.ts → packages/next-plugin/src/dev-runner.d.ts} +0 -0
- /package/dist/{dev-watcher.d.ts → packages/next-plugin/src/dev-watcher.d.ts} +0 -0
- /package/dist/{generate-server-module.d.ts → packages/next-plugin/src/generate-server-module.d.ts} +0 -0
- /package/dist/{i18n-config.d.ts → packages/next-plugin/src/i18n-config.d.ts} +0 -0
- /package/dist/{middleware.d.ts → packages/next-plugin/src/middleware.d.ts} +0 -0
- /package/dist/{provider.d.ts → packages/next-plugin/src/provider.d.ts} +0 -0
- /package/dist/{read-config.d.ts → packages/next-plugin/src/read-config.d.ts} +0 -0
- /package/dist/{routing.d.ts → packages/next-plugin/src/routing.d.ts} +0 -0
- /package/dist/{server.d.ts → packages/next-plugin/src/server.d.ts} +0 -0
- /package/dist/{with-fluenti.d.ts → packages/next-plugin/src/with-fluenti.d.ts} +0 -0
- /package/dist/{with-locale.d.ts → packages/next-plugin/src/with-locale.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as e } from "./chunk-DyIg6Wiv.js";
|
|
2
|
+
import { t } from "./routing-CRln5Gw7.js";
|
|
3
|
+
import { existsSync as n, mkdirSync as r, watch as i, writeFileSync as a } from "node:fs";
|
|
4
|
+
import { execSync as o } from "node:child_process";
|
|
5
|
+
import { createRequire as s } from "node:module";
|
|
4
6
|
import { dirname as c, join as l, relative as u, resolve as d } from "node:path";
|
|
5
7
|
import { fileURLToPath as f } from "node:url";
|
|
6
8
|
import { DEFAULT_FLUENTI_CONFIG as p, loadConfigSync as m } from "@fluenti/core/config";
|
|
7
9
|
import { validateLocale as h } from "@fluenti/core";
|
|
8
|
-
import { resolveLocaleCodes as g } from "@fluenti/core/
|
|
9
|
-
import {
|
|
10
|
-
import { msg as v } from "@fluenti/react";
|
|
10
|
+
import { resolveLocaleCodes as g } from "@fluenti/core/compiler";
|
|
11
|
+
import { msg as _ } from "@fluenti/react";
|
|
11
12
|
//#region src/read-config.ts
|
|
12
|
-
function
|
|
13
|
+
function v(e, t) {
|
|
13
14
|
let n;
|
|
14
15
|
n = t?.config && typeof t.config == "object" ? {
|
|
15
16
|
...p,
|
|
@@ -18,50 +19,71 @@ function y(e, t) {
|
|
|
18
19
|
...p,
|
|
19
20
|
locales: t.locales
|
|
20
21
|
} : m(typeof t?.config == "string" ? t.config : void 0, e);
|
|
21
|
-
let r = t?.serverModuleOutDir ?? ".fluenti", i = t?.cookieName ?? "locale", a = {
|
|
22
|
+
let r = t?.serverModuleOutDir ?? ".fluenti", i = t?.cookieName ?? "locale", a = t?.runtimeInterpolate ?? !0, o = {
|
|
22
23
|
fluentiConfig: n,
|
|
23
24
|
serverModule: t?.serverModule ?? null,
|
|
24
25
|
serverModuleOutDir: r,
|
|
25
|
-
cookieName: i
|
|
26
|
+
cookieName: i,
|
|
27
|
+
runtimeInterpolate: a
|
|
26
28
|
};
|
|
27
|
-
return t?.resolveLocale && (
|
|
29
|
+
return t?.resolveLocale && (o.resolveLocale = t.resolveLocale), o;
|
|
28
30
|
}
|
|
29
31
|
//#endregion
|
|
30
32
|
//#region src/generate-server-module.ts
|
|
31
|
-
function
|
|
33
|
+
function y(e, t) {
|
|
32
34
|
try {
|
|
33
|
-
|
|
35
|
+
a(e, t, "utf-8");
|
|
34
36
|
} catch (t) {
|
|
35
37
|
throw Error(`[fluenti] Failed to write generated module at ${e}: ${t instanceof Error ? t.message : String(t)}`);
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
|
-
function
|
|
40
|
+
function b(e, t) {
|
|
39
41
|
if (t.serverModule) return d(e, t.serverModule);
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
let s = g(t.fluentiConfig.locales), c = t.fluentiConfig.defaultLocale ?? t.fluentiConfig.sourceLocale, l = t.fluentiConfig.compileOutDir, f = t.fluentiConfig.fallbackChain, p = t.fluentiConfig.dateFormats, m = t.fluentiConfig.numberFormats, _ =
|
|
42
|
+
let i = d(e, t.serverModuleOutDir), a = d(i, "server.js"), o = d(i, "server.d.ts");
|
|
43
|
+
n(i) || r(i, { recursive: !0 });
|
|
44
|
+
let s = g(t.fluentiConfig.locales), c = t.fluentiConfig.defaultLocale ?? t.fluentiConfig.sourceLocale, l = t.fluentiConfig.compileOutDir, f = t.fluentiConfig.fallbackChain, p = t.fluentiConfig.dateFormats, m = t.fluentiConfig.numberFormats, _ = x(t.cookieName), v = x(c);
|
|
43
45
|
for (let e of s) h(e, "next-plugin");
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
+
let b = S(u(i, d(e, l))), E = s.map((e) => ` case ${x(e)}: return import(${x(`${b}/${e}`)})`).join("\n"), D = f ? JSON.stringify(f) : "undefined", O = d(i, "client-provider.js"), k = p === void 0 ? "undefined" : JSON.stringify(p), A = m === void 0 ? "undefined" : JSON.stringify(m), j = t.runtimeInterpolate ? "import { interpolate as __interpolate } from '@fluenti/core/runtime'\n" : "", M = t.runtimeInterpolate ? ", interpolate: __interpolate" : "", N = t.runtimeInterpolate ? " interpolate: __interpolate,\n" : "";
|
|
47
|
+
y(O, `"use client";
|
|
46
48
|
// Auto-generated by @fluenti/next — do not edit
|
|
47
49
|
// @ts-nocheck
|
|
48
50
|
import { createElement } from 'react'
|
|
49
51
|
import { I18nProvider } from '@fluenti/react'
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
${j}
|
|
53
|
+
const __dateFormats = ${k}
|
|
54
|
+
const __numberFormats = ${A}
|
|
55
|
+
|
|
56
|
+
export function ClientI18nProvider({ locale, fallbackLocale, messages, loadMessages, fallbackChain, children }) {
|
|
57
|
+
return createElement(I18nProvider, { locale, fallbackLocale, messages, loadMessages, fallbackChain, dateFormats: __dateFormats, numberFormats: __numberFormats${M} }, children)
|
|
58
|
+
}
|
|
59
|
+
`), y(d(i, "client-provider.d.ts"), "// Auto-generated by @fluenti/next — do not edit\nimport type { ReactNode, ReactElement } from 'react'\nimport type { AllMessages, Messages } from '@fluenti/core'\n\nexport declare function ClientI18nProvider(props: {\n locale: string\n fallbackLocale: string\n messages: AllMessages\n loadMessages: (locale: string) => Promise<Messages | { default: Messages }>\n fallbackChain?: Record<string, string[]>\n children: ReactNode\n}): ReactElement\n");
|
|
60
|
+
for (let e of s) {
|
|
61
|
+
let t = d(i, C(e)), n = T(e, c, f, s);
|
|
62
|
+
y(t, `"use client";
|
|
63
|
+
// Auto-generated by @fluenti/next — do not edit
|
|
64
|
+
// @ts-nocheck
|
|
65
|
+
import { createElement } from 'react'
|
|
66
|
+
import { ClientI18nProvider as __FluentiClientI18nProvider } from './client-provider.js'
|
|
67
|
+
${n.map((e) => `import ${w(e)} from ${x(`${b}/${e}`)}`).join("\n")}
|
|
52
68
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
const __messages = { ${n.map((e) => `${x(e)}: ${w(e)}`).join(", ")} }
|
|
70
|
+
|
|
71
|
+
async function __loadMessages(locale) {
|
|
72
|
+
switch (locale) {
|
|
73
|
+
${s.map((e) => {
|
|
74
|
+
let t = x(`${b}/${e}`);
|
|
75
|
+
return n.includes(e) ? ` case ${x(e)}: return ${w(e)}` : ` case ${x(e)}: return import(${t})`;
|
|
76
|
+
}).join("\n")}
|
|
77
|
+
default: return import(${x(`${b}/${c}`)})
|
|
78
|
+
}
|
|
79
|
+
}
|
|
59
80
|
|
|
60
81
|
export function ClientI18nProvider({ locale, fallbackLocale, fallbackChain, children }) {
|
|
61
|
-
return createElement(
|
|
82
|
+
return createElement(__FluentiClientI18nProvider, { locale, fallbackLocale, messages: __messages, loadMessages: __loadMessages, fallbackChain }, children)
|
|
62
83
|
}
|
|
63
|
-
`)
|
|
64
|
-
|
|
84
|
+
`);
|
|
85
|
+
}
|
|
86
|
+
let P = t.resolveLocale ? `import __resolveLocale from ${x(S(u(i, d(e, t.resolveLocale))))}` : null, F = t.resolveLocale ? "resolveLocale: __resolveLocale," : `resolveLocale: async () => {
|
|
65
87
|
try {
|
|
66
88
|
const { cookies, headers } = await import('next/headers')
|
|
67
89
|
const [cookieStore, headerStore] = await Promise.all([cookies(), headers()])
|
|
@@ -71,7 +93,7 @@ export function ClientI18nProvider({ locale, fallbackLocale, fallbackChain, chil
|
|
|
71
93
|
if (fromMiddleware && __locales.includes(fromMiddleware)) return fromMiddleware
|
|
72
94
|
|
|
73
95
|
// 1. Cookie (configurable name)
|
|
74
|
-
const fromCookie = cookieStore.get(
|
|
96
|
+
const fromCookie = cookieStore.get(${_})?.value
|
|
75
97
|
if (fromCookie && __locales.includes(fromCookie)) return fromCookie
|
|
76
98
|
|
|
77
99
|
// 2. Accept-Language header
|
|
@@ -86,30 +108,28 @@ export function ClientI18nProvider({ locale, fallbackLocale, fallbackChain, chil
|
|
|
86
108
|
}
|
|
87
109
|
}
|
|
88
110
|
|
|
89
|
-
return
|
|
111
|
+
return ${v}
|
|
90
112
|
} catch {
|
|
91
|
-
return
|
|
113
|
+
return ${v}
|
|
92
114
|
}
|
|
93
|
-
},`,
|
|
94
|
-
|
|
115
|
+
},`, I = JSON.stringify(s);
|
|
116
|
+
y(a, `// Auto-generated by @fluenti/next — do not edit
|
|
95
117
|
// @ts-nocheck
|
|
96
118
|
import { createServerI18n } from '@fluenti/react/server'
|
|
97
119
|
import { createElement } from 'react'
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const __locales = ${D}
|
|
120
|
+
${j}${P ? `${P}\n` : ""}
|
|
121
|
+
const __locales = ${I}
|
|
101
122
|
|
|
102
123
|
const serverI18n = createServerI18n({
|
|
103
|
-
|
|
104
|
-
loadMessages: async (locale) => {
|
|
124
|
+
${N} loadMessages: async (locale) => {
|
|
105
125
|
switch (locale) {
|
|
106
|
-
${
|
|
107
|
-
default: return import(
|
|
126
|
+
${E}
|
|
127
|
+
default: return import(${x(`${b}/${c}`)})
|
|
108
128
|
}
|
|
109
129
|
},
|
|
110
|
-
fallbackLocale:
|
|
111
|
-
fallbackChain: ${
|
|
112
|
-
${
|
|
130
|
+
fallbackLocale: ${v},
|
|
131
|
+
fallbackChain: ${D},
|
|
132
|
+
${F}
|
|
113
133
|
})
|
|
114
134
|
|
|
115
135
|
export const setLocale = serverI18n.setLocale
|
|
@@ -135,41 +155,57 @@ export const NumberFormat = serverI18n.NumberFormat
|
|
|
135
155
|
* Sets up both server-side (React.cache) and client-side (I18nProvider) i18n.
|
|
136
156
|
*/
|
|
137
157
|
export async function I18nProvider({ locale, children }) {
|
|
138
|
-
const activeLocale = (locale && locale.trim()) ? locale :
|
|
158
|
+
const activeLocale = (locale && locale.trim()) ? locale : ${v}
|
|
139
159
|
|
|
140
160
|
// 1. Initialize server-side i18n (React.cache scoped)
|
|
141
161
|
serverI18n.setLocale(activeLocale)
|
|
142
162
|
await serverI18n.getI18n()
|
|
143
163
|
|
|
144
|
-
// 2. Import the
|
|
145
|
-
//
|
|
146
|
-
const { ClientI18nProvider } = await
|
|
164
|
+
// 2. Import the locale-specific client provider chunk. It eagerly bundles the
|
|
165
|
+
// active locale plus only the fallback locales relevant to that locale.
|
|
166
|
+
const { ClientI18nProvider } = await (async () => {
|
|
167
|
+
switch (activeLocale) {
|
|
168
|
+
${s.map((e) => ` case ${x(e)}: return import(${x(`./${C(e)}`)})`).join("\n")}
|
|
169
|
+
default: return import(${x(`./${C(c)}`)})
|
|
170
|
+
}
|
|
171
|
+
})()
|
|
147
172
|
|
|
148
173
|
return createElement(ClientI18nProvider, {
|
|
149
174
|
locale: activeLocale,
|
|
150
|
-
fallbackLocale:
|
|
151
|
-
fallbackChain: ${
|
|
175
|
+
fallbackLocale: ${v},
|
|
176
|
+
fallbackChain: ${D},
|
|
152
177
|
}, children)
|
|
153
178
|
}
|
|
154
|
-
`),
|
|
155
|
-
let
|
|
156
|
-
return
|
|
157
|
-
export const locales = ${
|
|
158
|
-
export const sourceLocale =
|
|
159
|
-
export const cookieName =
|
|
160
|
-
`),
|
|
179
|
+
`), y(o, "// Auto-generated by @fluenti/next — do not edit\nimport type { ReactNode, ReactElement } from 'react'\nimport type { CompileTimeT, FluentiCoreInstanceFull } from '@fluenti/core'\n\nexport declare function setLocale(locale: string): void\nexport declare function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }>\nexport declare const t: CompileTimeT\n\nexport declare function Trans(props: {\n children: ReactNode\n id?: string\n context?: string\n comment?: string\n render?: (translation: ReactNode) => ReactNode\n}): Promise<ReactElement>\n\nexport declare function Plural(props: {\n value: number\n id?: string\n context?: string\n comment?: string\n zero?: ReactNode\n one?: ReactNode\n two?: ReactNode\n few?: ReactNode\n many?: ReactNode\n other: ReactNode\n offset?: number\n}): Promise<ReactElement>\n\nexport declare function Select(props: {\n value: string\n id?: string\n context?: string\n comment?: string\n other: ReactNode\n options?: Record<string, ReactNode>\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}): Promise<ReactElement>\n\nexport declare function DateTime(props: {\n value: Date | number\n format?: string\n}): Promise<ReactElement>\n\nexport declare function NumberFormat(props: {\n value: number\n format?: string\n}): Promise<ReactElement>\n\nexport declare function I18nProvider(props: {\n locale?: string\n children: ReactNode\n}): Promise<ReactElement>\n");
|
|
180
|
+
let L = d(i, "i18n-config.js"), R = d(i, "i18n-config.d.ts");
|
|
181
|
+
return y(L, `// Auto-generated by @fluenti/next — do not edit
|
|
182
|
+
export const locales = ${I}
|
|
183
|
+
export const sourceLocale = ${v}
|
|
184
|
+
export const cookieName = ${_}
|
|
185
|
+
`), y(R, "// Auto-generated by @fluenti/next — do not edit\nexport declare const locales: string[]\nexport declare const sourceLocale: string\nexport declare const cookieName: string\n"), a;
|
|
186
|
+
}
|
|
187
|
+
function x(e) {
|
|
188
|
+
return `'${e.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\0/g, "\\0")}'`;
|
|
161
189
|
}
|
|
162
190
|
function S(e) {
|
|
163
|
-
return e.
|
|
191
|
+
return e.split("\\").join("/");
|
|
164
192
|
}
|
|
165
193
|
function C(e) {
|
|
166
|
-
return e.
|
|
194
|
+
return `client-provider-${e.replace(/[^a-zA-Z0-9]/g, "_")}.js`;
|
|
195
|
+
}
|
|
196
|
+
function w(e) {
|
|
197
|
+
return `__messages_${e.replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
198
|
+
}
|
|
199
|
+
function T(e, t, n, r) {
|
|
200
|
+
let i = new Set([e, t]), a = n?.[e] ?? [];
|
|
201
|
+
for (let e of a) r.includes(e) && i.add(e);
|
|
202
|
+
return Array.from(i);
|
|
167
203
|
}
|
|
168
204
|
//#endregion
|
|
169
205
|
//#region src/dev-runner.ts
|
|
170
|
-
async function
|
|
206
|
+
async function E(e) {
|
|
171
207
|
if (e.compileOnly) try {
|
|
172
|
-
let { runCompile: t } =
|
|
208
|
+
let { runCompile: t } = s(l(e.cwd, "package.json"))("@fluenti/cli");
|
|
173
209
|
await t(e.cwd), console.log("[fluenti] Compiling... done"), e.onSuccess?.();
|
|
174
210
|
return;
|
|
175
211
|
} catch (t) {
|
|
@@ -180,7 +216,7 @@ async function w(e) {
|
|
|
180
216
|
}
|
|
181
217
|
let t = null;
|
|
182
218
|
try {
|
|
183
|
-
t =
|
|
219
|
+
t = s(l(e.cwd, "package.json"))("@fluenti/cli");
|
|
184
220
|
} catch {}
|
|
185
221
|
if (t) try {
|
|
186
222
|
await t.runExtract(e.cwd), e.parallelCompile ? await t.runCompile(e.cwd, { parallel: !0 }) : await t.runCompile(e.cwd), console.log("[fluenti] Extracting and compiling... done"), e.onSuccess?.();
|
|
@@ -195,12 +231,12 @@ async function w(e) {
|
|
|
195
231
|
if (e.throwOnError) throw Error(n);
|
|
196
232
|
console.warn(n), e.onError?.(Error(n));
|
|
197
233
|
}
|
|
198
|
-
function
|
|
234
|
+
function D(e, t = 300) {
|
|
199
235
|
let n = null, r = !1, i = !1;
|
|
200
236
|
async function a() {
|
|
201
237
|
r = !0;
|
|
202
238
|
try {
|
|
203
|
-
await
|
|
239
|
+
await E(e);
|
|
204
240
|
} finally {
|
|
205
241
|
r = !1, i && (i = !1, o());
|
|
206
242
|
}
|
|
@@ -214,8 +250,8 @@ function T(e, t = 300) {
|
|
|
214
250
|
}
|
|
215
251
|
//#endregion
|
|
216
252
|
//#region src/dev-watcher.ts
|
|
217
|
-
var
|
|
218
|
-
function
|
|
253
|
+
var O = null;
|
|
254
|
+
function k(e, t) {
|
|
219
255
|
if (!t || t.length === 0) return [d(e, "src")];
|
|
220
256
|
let n = /* @__PURE__ */ new Set();
|
|
221
257
|
for (let e of t) {
|
|
@@ -224,30 +260,30 @@ function D(e, t) {
|
|
|
224
260
|
}
|
|
225
261
|
return [...n].map((t) => d(e, t));
|
|
226
262
|
}
|
|
227
|
-
function
|
|
228
|
-
|
|
229
|
-
let { cwd: t, compiledDir: n, delay: r = 1e3, include:
|
|
230
|
-
|
|
231
|
-
let
|
|
232
|
-
|
|
233
|
-
let
|
|
234
|
-
n && /\.[jt]sx?$/.test(n) && (n.includes("node_modules") || n.includes(".next") || d(e, n).startsWith(
|
|
235
|
-
})),
|
|
236
|
-
for (let e of
|
|
237
|
-
|
|
263
|
+
function A(e) {
|
|
264
|
+
O && O();
|
|
265
|
+
let { cwd: t, compiledDir: n, delay: r = 1e3, include: a, exclude: o, parallelCompile: c } = e, l = d(t, n), u = s(typeof __filename < "u" ? __filename : import.meta.url)("picomatch"), f = o?.length ? u(o) : () => !1, p = { cwd: t };
|
|
266
|
+
c && (p.parallelCompile = !0);
|
|
267
|
+
let m = D(p, r);
|
|
268
|
+
m();
|
|
269
|
+
let h = k(t, a).map((e) => i(e, { recursive: !0 }, (t, n) => {
|
|
270
|
+
n && /\.[jt]sx?$/.test(n) && (n.includes("node_modules") || n.includes(".next") || d(e, n).startsWith(l) || f(n) || m());
|
|
271
|
+
})), g = () => {
|
|
272
|
+
for (let e of h) e.close();
|
|
273
|
+
O = null;
|
|
238
274
|
};
|
|
239
|
-
return
|
|
275
|
+
return O = g, g;
|
|
240
276
|
}
|
|
241
277
|
//#endregion
|
|
242
278
|
//#region src/with-fluenti.ts
|
|
243
|
-
function
|
|
244
|
-
if (e && !
|
|
279
|
+
function j(e) {
|
|
280
|
+
if (e && !M(e)) return N({}, e);
|
|
245
281
|
let t = e ?? {};
|
|
246
282
|
return function(e) {
|
|
247
|
-
return
|
|
283
|
+
return N(t, e ?? {});
|
|
248
284
|
};
|
|
249
285
|
}
|
|
250
|
-
function
|
|
286
|
+
function M(e) {
|
|
251
287
|
return [
|
|
252
288
|
"config",
|
|
253
289
|
"locales",
|
|
@@ -255,15 +291,16 @@ function A(e) {
|
|
|
255
291
|
"serverModuleOutDir",
|
|
256
292
|
"resolveLocale",
|
|
257
293
|
"cookieName",
|
|
294
|
+
"runtimeInterpolate",
|
|
258
295
|
"loaderEnforce"
|
|
259
296
|
].some((t) => t in e);
|
|
260
297
|
}
|
|
261
|
-
function
|
|
262
|
-
let a = process.cwd(),
|
|
263
|
-
|
|
264
|
-
let
|
|
265
|
-
(
|
|
266
|
-
let
|
|
298
|
+
function N(t, i) {
|
|
299
|
+
let a = process.cwd(), l = v(a, t), p = l.fluentiConfig, m = p.compileOutDir, h = d(a, m);
|
|
300
|
+
n(h) || r(h, { recursive: !0 });
|
|
301
|
+
let g = d(a, "app", "[locale]"), _ = d(a, "src", "app", "[locale]");
|
|
302
|
+
(n(g) || n(_)) && ("rewriteDefaultLocale" in t || (l._autoRewriteDefaultLocale = !0));
|
|
303
|
+
let y = b(a, l), x = d(typeof __dirname < "u" ? __dirname : c(f(import.meta.url)), "loader.js"), S = i.webpack, C = !1, w = Object.fromEntries([
|
|
267
304
|
"*.ts",
|
|
268
305
|
"*.tsx",
|
|
269
306
|
"*.js",
|
|
@@ -271,58 +308,62 @@ function j(e, n) {
|
|
|
271
308
|
].map((e) => [e, {
|
|
272
309
|
condition: { not: "foreign" },
|
|
273
310
|
loaders: ["@fluenti/next/loader"]
|
|
274
|
-
}])),
|
|
275
|
-
"@fluenti/next":
|
|
276
|
-
"@fluenti/next/i18n-config":
|
|
277
|
-
}, k = process.env.NODE_ENV === "development" || process.argv.some((e) => e === "dev"),
|
|
278
|
-
if (!k &&
|
|
279
|
-
|
|
311
|
+
}])), T = d(c(y), "i18n-config.js"), E = "./" + u(a, y).split("\\").join("/"), D = "./" + u(a, T).split("\\").join("/"), O = {
|
|
312
|
+
"@fluenti/next": E,
|
|
313
|
+
"@fluenti/next/i18n-config": D
|
|
314
|
+
}, k = process.env.NODE_ENV === "development" || process.argv.some((e) => e === "dev"), j = p.buildAutoCompile ?? !0;
|
|
315
|
+
if (!k && j && !C) {
|
|
316
|
+
C = !0;
|
|
280
317
|
try {
|
|
281
|
-
s("
|
|
318
|
+
o(`node "${d(c(s(d(a, "noop.js")).resolve("@fluenti/cli")), "cli.js")}" compile` + (p.parallelCompile ? " --parallel" : ""), {
|
|
282
319
|
cwd: a,
|
|
283
320
|
stdio: "inherit"
|
|
284
321
|
});
|
|
285
|
-
} catch {
|
|
322
|
+
} catch (e) {
|
|
323
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
324
|
+
throw Error(`[fluenti] Production auto-compile failed. Run "fluenti compile" successfully before continuing the Next.js build.
|
|
325
|
+
${t}`);
|
|
326
|
+
}
|
|
286
327
|
}
|
|
287
|
-
let
|
|
288
|
-
if (k &&
|
|
328
|
+
let M = p.devAutoCompile ?? !0;
|
|
329
|
+
if (k && M) {
|
|
289
330
|
let e = {
|
|
290
331
|
cwd: a,
|
|
291
|
-
compiledDir:
|
|
292
|
-
delay:
|
|
332
|
+
compiledDir: m,
|
|
333
|
+
delay: p.devAutoCompileDelay ?? 1e3
|
|
293
334
|
};
|
|
294
|
-
|
|
335
|
+
p.parallelCompile && (e.parallelCompile = !0), p.include && (e.include = p.include), p.exclude && (e.exclude = p.exclude), A(e);
|
|
295
336
|
}
|
|
296
337
|
let N = 15;
|
|
297
338
|
try {
|
|
298
|
-
let
|
|
299
|
-
|
|
339
|
+
let t = e("next/package.json");
|
|
340
|
+
t.version && (N = parseInt(t.version.split(".")[0], 10) || 15);
|
|
300
341
|
} catch {}
|
|
301
|
-
let
|
|
302
|
-
rules:
|
|
303
|
-
resolveAlias:
|
|
304
|
-
}),
|
|
305
|
-
...
|
|
306
|
-
turbo:
|
|
342
|
+
let F = P(N >= 15 ? i.turbopack : i.experimental?.turbo, {
|
|
343
|
+
rules: w,
|
|
344
|
+
resolveAlias: O
|
|
345
|
+
}), I = N >= 15 ? { turbopack: F } : { experimental: {
|
|
346
|
+
...i.experimental ?? {},
|
|
347
|
+
turbo: F
|
|
307
348
|
} };
|
|
308
349
|
return {
|
|
309
|
-
...
|
|
310
|
-
...
|
|
311
|
-
webpack(
|
|
312
|
-
let r =
|
|
313
|
-
return
|
|
350
|
+
...i,
|
|
351
|
+
...I,
|
|
352
|
+
webpack(e, n) {
|
|
353
|
+
let r = t.loaderEnforce === void 0 && !("loaderEnforce" in t) ? "pre" : t.loaderEnforce;
|
|
354
|
+
return e.module.rules.push({
|
|
314
355
|
test: /\.[jt]sx?$/,
|
|
315
356
|
...r ? { enforce: r } : {},
|
|
316
357
|
exclude: [/node_modules/, /\.next/],
|
|
317
358
|
use: [{
|
|
318
|
-
loader:
|
|
319
|
-
options: { serverModulePath:
|
|
359
|
+
loader: x,
|
|
360
|
+
options: { serverModulePath: y }
|
|
320
361
|
}]
|
|
321
|
-
}),
|
|
362
|
+
}), e.resolve = e.resolve ?? {}, e.resolve.alias = e.resolve.alias ?? {}, e.resolve.alias["@fluenti/next$"] = y, e.resolve.alias["@fluenti/next/i18n-config$"] = T, S ? S(e, n) : e;
|
|
322
363
|
}
|
|
323
364
|
};
|
|
324
365
|
}
|
|
325
|
-
function
|
|
366
|
+
function P(e, t) {
|
|
326
367
|
let n = e ?? {}, r = n.rules ?? {}, i = Object.keys(t.rules).filter((e) => e in r);
|
|
327
368
|
return i.length > 0 && console.warn(`[fluenti] Your turbopack.rules override Fluenti's loader for: ${i.join(", ")}.\n Fluenti's t\`\` transform will NOT run on these file types.\n If this is intentional, you can suppress this warning with { devAutoCompile: false }.`), {
|
|
328
369
|
...n,
|
|
@@ -338,13 +379,36 @@ function M(e, t) {
|
|
|
338
379
|
}
|
|
339
380
|
//#endregion
|
|
340
381
|
//#region src/index.ts
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
382
|
+
var F = [
|
|
383
|
+
"[fluenti] `@fluenti/next` was imported before `withFluenti()` generated the server module.",
|
|
384
|
+
"Fix this by:",
|
|
385
|
+
" 1. Wrapping next.config.ts with `withFluenti()` from '@fluenti/next'",
|
|
386
|
+
" 2. Restarting the Next dev server after the generated module is written",
|
|
387
|
+
" 3. Importing client runtime APIs from '@fluenti/react' and server APIs from '@fluenti/next'"
|
|
388
|
+
].join("\n");
|
|
389
|
+
function I() {
|
|
390
|
+
throw Error(F);
|
|
391
|
+
}
|
|
392
|
+
var L = I, R = I, z = I;
|
|
393
|
+
async function B(e) {
|
|
394
|
+
return I();
|
|
395
|
+
}
|
|
396
|
+
async function V(e) {
|
|
397
|
+
return I();
|
|
398
|
+
}
|
|
399
|
+
async function H(e) {
|
|
400
|
+
return I();
|
|
401
|
+
}
|
|
402
|
+
async function U(e) {
|
|
403
|
+
return I();
|
|
404
|
+
}
|
|
405
|
+
async function W(e) {
|
|
406
|
+
return I();
|
|
407
|
+
}
|
|
408
|
+
async function G(e) {
|
|
409
|
+
return I();
|
|
345
410
|
}
|
|
346
|
-
var F = P, I = P, L = P, R = P, z = P, B = P, V = P, H = P, U = P;
|
|
347
411
|
//#endregion
|
|
348
|
-
export {
|
|
412
|
+
export { U as DateTime, G as I18nProvider, W as NumberFormat, V as Plural, H as Select, B as Trans, t as defineRouting, R as getI18n, _ as msg, L as setLocale, z as t, j as withFluenti };
|
|
349
413
|
|
|
350
414
|
//# sourceMappingURL=index.js.map
|