intor 2.2.0 → 2.2.1
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.
|
@@ -275,10 +275,7 @@ var determineInitialLocale = async (config) => {
|
|
|
275
275
|
};
|
|
276
276
|
|
|
277
277
|
// src/adapters/next/middleware/handle-prefix/handle-prefix-all.ts
|
|
278
|
-
var handlePrefixAll = async ({
|
|
279
|
-
request,
|
|
280
|
-
config
|
|
281
|
-
}) => {
|
|
278
|
+
var handlePrefixAll = async (config, request) => {
|
|
282
279
|
const { cookie, routing } = config;
|
|
283
280
|
const { maybeLocale, isLocalePrefixed } = extractPathname({
|
|
284
281
|
config,
|
|
@@ -316,10 +313,7 @@ var handlePrefixAll = async ({
|
|
|
316
313
|
};
|
|
317
314
|
|
|
318
315
|
// src/adapters/next/middleware/handle-prefix/handle-prefix-except-default.ts
|
|
319
|
-
var handlePrefixExceptDefault = async ({
|
|
320
|
-
request,
|
|
321
|
-
config
|
|
322
|
-
}) => {
|
|
316
|
+
var handlePrefixExceptDefault = async (config, request) => {
|
|
323
317
|
const { defaultLocale, cookie, routing } = config;
|
|
324
318
|
const { maybeLocale, isLocalePrefixed } = extractPathname({
|
|
325
319
|
config,
|
|
@@ -369,10 +363,7 @@ var handlePrefixExceptDefault = async ({
|
|
|
369
363
|
};
|
|
370
364
|
|
|
371
365
|
// src/adapters/next/middleware/handle-prefix/handle-prefix-none.ts
|
|
372
|
-
var handlePrefixNone = async ({
|
|
373
|
-
request,
|
|
374
|
-
config
|
|
375
|
-
}) => {
|
|
366
|
+
var handlePrefixNone = async (config, request) => {
|
|
376
367
|
let locale = request.cookies.get(config.cookie.name)?.value;
|
|
377
368
|
if (!locale) {
|
|
378
369
|
locale = await determineInitialLocale(config);
|
|
@@ -381,18 +372,15 @@ var handlePrefixNone = async ({
|
|
|
381
372
|
};
|
|
382
373
|
|
|
383
374
|
// src/adapters/next/middleware/intor-middleware.ts
|
|
384
|
-
async function intorMiddleware({
|
|
385
|
-
request,
|
|
386
|
-
config
|
|
387
|
-
}) {
|
|
375
|
+
async function intorMiddleware(config, request) {
|
|
388
376
|
const { prefix } = config.routing;
|
|
389
377
|
if (prefix === "none") {
|
|
390
|
-
return handlePrefixNone(
|
|
378
|
+
return handlePrefixNone(config, request);
|
|
391
379
|
}
|
|
392
380
|
if (prefix === "except-default") {
|
|
393
|
-
return await handlePrefixExceptDefault(
|
|
381
|
+
return await handlePrefixExceptDefault(config, request);
|
|
394
382
|
}
|
|
395
|
-
return await handlePrefixAll(
|
|
383
|
+
return await handlePrefixAll(config, request);
|
|
396
384
|
}
|
|
397
385
|
|
|
398
386
|
exports.PATHNAME_HEADER_NAME = PATHNAME_HEADER_NAME;
|
|
@@ -120,14 +120,10 @@ type IntorResolvedConfig = (WithLoader | WithoutLoader) & {
|
|
|
120
120
|
readonly cache: CacheResolvedOptions;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
interface IntorMiddlewareParams<Req extends NextRequest = NextRequest> {
|
|
124
|
-
request: Req;
|
|
125
|
-
config: IntorResolvedConfig;
|
|
126
|
-
}
|
|
127
123
|
/**
|
|
128
124
|
* Handle locale routing based on prefix config
|
|
129
125
|
*/
|
|
130
|
-
declare function intorMiddleware<Req extends NextRequest = NextRequest>(
|
|
126
|
+
declare function intorMiddleware<Req extends NextRequest = NextRequest>(config: IntorResolvedConfig, request: Req): Promise<Response>;
|
|
131
127
|
|
|
132
128
|
declare const PATHNAME_HEADER_NAME = "x-intor-pathname";
|
|
133
129
|
|
|
@@ -120,14 +120,10 @@ type IntorResolvedConfig = (WithLoader | WithoutLoader) & {
|
|
|
120
120
|
readonly cache: CacheResolvedOptions;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
interface IntorMiddlewareParams<Req extends NextRequest = NextRequest> {
|
|
124
|
-
request: Req;
|
|
125
|
-
config: IntorResolvedConfig;
|
|
126
|
-
}
|
|
127
123
|
/**
|
|
128
124
|
* Handle locale routing based on prefix config
|
|
129
125
|
*/
|
|
130
|
-
declare function intorMiddleware<Req extends NextRequest = NextRequest>(
|
|
126
|
+
declare function intorMiddleware<Req extends NextRequest = NextRequest>(config: IntorResolvedConfig, request: Req): Promise<Response>;
|
|
131
127
|
|
|
132
128
|
declare const PATHNAME_HEADER_NAME = "x-intor-pathname";
|
|
133
129
|
|
|
@@ -273,10 +273,7 @@ var determineInitialLocale = async (config) => {
|
|
|
273
273
|
};
|
|
274
274
|
|
|
275
275
|
// src/adapters/next/middleware/handle-prefix/handle-prefix-all.ts
|
|
276
|
-
var handlePrefixAll = async ({
|
|
277
|
-
request,
|
|
278
|
-
config
|
|
279
|
-
}) => {
|
|
276
|
+
var handlePrefixAll = async (config, request) => {
|
|
280
277
|
const { cookie, routing } = config;
|
|
281
278
|
const { maybeLocale, isLocalePrefixed } = extractPathname({
|
|
282
279
|
config,
|
|
@@ -314,10 +311,7 @@ var handlePrefixAll = async ({
|
|
|
314
311
|
};
|
|
315
312
|
|
|
316
313
|
// src/adapters/next/middleware/handle-prefix/handle-prefix-except-default.ts
|
|
317
|
-
var handlePrefixExceptDefault = async ({
|
|
318
|
-
request,
|
|
319
|
-
config
|
|
320
|
-
}) => {
|
|
314
|
+
var handlePrefixExceptDefault = async (config, request) => {
|
|
321
315
|
const { defaultLocale, cookie, routing } = config;
|
|
322
316
|
const { maybeLocale, isLocalePrefixed } = extractPathname({
|
|
323
317
|
config,
|
|
@@ -367,10 +361,7 @@ var handlePrefixExceptDefault = async ({
|
|
|
367
361
|
};
|
|
368
362
|
|
|
369
363
|
// src/adapters/next/middleware/handle-prefix/handle-prefix-none.ts
|
|
370
|
-
var handlePrefixNone = async ({
|
|
371
|
-
request,
|
|
372
|
-
config
|
|
373
|
-
}) => {
|
|
364
|
+
var handlePrefixNone = async (config, request) => {
|
|
374
365
|
let locale = request.cookies.get(config.cookie.name)?.value;
|
|
375
366
|
if (!locale) {
|
|
376
367
|
locale = await determineInitialLocale(config);
|
|
@@ -379,18 +370,15 @@ var handlePrefixNone = async ({
|
|
|
379
370
|
};
|
|
380
371
|
|
|
381
372
|
// src/adapters/next/middleware/intor-middleware.ts
|
|
382
|
-
async function intorMiddleware({
|
|
383
|
-
request,
|
|
384
|
-
config
|
|
385
|
-
}) {
|
|
373
|
+
async function intorMiddleware(config, request) {
|
|
386
374
|
const { prefix } = config.routing;
|
|
387
375
|
if (prefix === "none") {
|
|
388
|
-
return handlePrefixNone(
|
|
376
|
+
return handlePrefixNone(config, request);
|
|
389
377
|
}
|
|
390
378
|
if (prefix === "except-default") {
|
|
391
|
-
return await handlePrefixExceptDefault(
|
|
379
|
+
return await handlePrefixExceptDefault(config, request);
|
|
392
380
|
}
|
|
393
|
-
return await handlePrefixAll(
|
|
381
|
+
return await handlePrefixAll(config, request);
|
|
394
382
|
}
|
|
395
383
|
|
|
396
384
|
export { PATHNAME_HEADER_NAME, intorMiddleware };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intor",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A modular and extensible i18n core designed for TypeScript and JavaScript projects. Intor enables custom translation logic with support for both frontend and backend environments, featuring runtime configuration, caching, adapters, and message loaders.",
|
|
5
5
|
"author": "Yiming Liao",
|
|
6
6
|
"license": "MIT",
|