intor 2.3.25 → 2.3.27
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/core/export/index.js +1 -0
- package/dist/core/src/core/messages/internal-metadata.js +16 -0
- package/dist/express/src/adapters/express/middleware/create-intor.js +2 -1
- package/dist/express/src/server/shared/utils/parse-cookie-header.js +22 -0
- package/dist/types/export/index.d.ts +1 -1
- package/dist/types/export/internal/index.d.ts +2 -1
- package/dist/types/src/server/index.d.ts +1 -0
- package/dist/types/src/server/shared/utils/index.d.ts +1 -0
- package/dist/types/src/server/shared/utils/parse-cookie-header.d.ts +4 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ export { clearLoggerPool } from '../src/core/logger/global-logger-pool.js';
|
|
|
7
7
|
export { isValidMessages } from '../src/core/messages/utils/is-valid-messages.js';
|
|
8
8
|
export { clearMessagesPool } from '../src/core/messages/global-messages-pool.js';
|
|
9
9
|
export { mergeMessages } from '../src/core/messages/merge-messages.js';
|
|
10
|
+
export { INTOR_MESSAGES_KIND, INTOR_MESSAGES_KIND_KEY, INTOR_PREFIX, getMessagesKind } from '../src/core/messages/internal-metadata.js';
|
|
10
11
|
export { defineIntorConfig } from '../src/config/define-intor-config.js';
|
|
11
12
|
import '../src/config/constants/cookie.js';
|
|
12
13
|
export { localizePathname } from '../src/routing/pathname/localize-pathname.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const INTOR_PREFIX = "__intor_";
|
|
2
|
+
const INTOR_MESSAGES_KIND_KEY = `${INTOR_PREFIX}kind`;
|
|
3
|
+
const INTOR_MESSAGES_KIND = {
|
|
4
|
+
markdown: "markdown",
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Read the Intor internal kind from a message container.
|
|
8
|
+
*/
|
|
9
|
+
function getMessagesKind(value) {
|
|
10
|
+
if (!value || typeof value !== "object")
|
|
11
|
+
return;
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
return value[INTOR_MESSAGES_KIND_KEY];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { INTOR_MESSAGES_KIND, INTOR_MESSAGES_KIND_KEY, INTOR_PREFIX, getMessagesKind };
|
|
@@ -9,6 +9,7 @@ import 'p-limit';
|
|
|
9
9
|
import 'node:fs/promises';
|
|
10
10
|
import 'intor-translator';
|
|
11
11
|
import { getTranslator } from '../../../server/helpers/get-translator.js';
|
|
12
|
+
import { parseCookieHeader } from '../../../server/shared/utils/parse-cookie-header.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Resolves locale-aware routing for the current execution context.
|
|
@@ -31,7 +32,7 @@ function createIntor(config, options) {
|
|
|
31
32
|
const { locale, localeSource, pathname } = await resolveInbound(config, req.path, false, {
|
|
32
33
|
host: req.hostname,
|
|
33
34
|
query: normalizeQuery(req.query),
|
|
34
|
-
cookie: req.
|
|
35
|
+
cookie: parseCookieHeader(req.headers.cookie)[config.cookie.name],
|
|
35
36
|
detected: localeFromAcceptLanguage || config.defaultLocale,
|
|
36
37
|
});
|
|
37
38
|
// --------------------------------------------------
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a raw HTTP Cookie header into a key-value record.
|
|
3
|
+
*/
|
|
4
|
+
function parseCookieHeader(cookieHeader) {
|
|
5
|
+
if (!cookieHeader)
|
|
6
|
+
return {};
|
|
7
|
+
const record = {};
|
|
8
|
+
// Split the Cookie header into individual key-value pairs
|
|
9
|
+
const pairs = cookieHeader.split(";");
|
|
10
|
+
for (const pair of pairs) {
|
|
11
|
+
// Locate the first "=" to separate key and value
|
|
12
|
+
const index = pair.indexOf("=");
|
|
13
|
+
if (index === -1)
|
|
14
|
+
continue;
|
|
15
|
+
const key = pair.slice(0, index).trim();
|
|
16
|
+
const value = pair.slice(index + 1).trim();
|
|
17
|
+
record[key] = decodeURIComponent(value);
|
|
18
|
+
}
|
|
19
|
+
return record;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { parseCookieHeader };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PREFIX_PLACEHOLDER, IntorError, IntorErrorCode, deepMerge, type DeepMergeOverrideEvent, resolveLoaderOptions, clearLoggerPool, clearMessagesPool, mergeMessages, isValidMessages, type MessagesReader, type MessagesReaders, } from "../src/core";
|
|
1
|
+
export { PREFIX_PLACEHOLDER, IntorError, IntorErrorCode, deepMerge, type DeepMergeOverrideEvent, resolveLoaderOptions, clearLoggerPool, clearMessagesPool, mergeMessages, isValidMessages, type MessagesReader, type MessagesReaders, INTOR_PREFIX, INTOR_MESSAGES_KIND_KEY, INTOR_MESSAGES_KIND, getMessagesKind, type IntorMessagesKind, } from "../src/core";
|
|
2
2
|
export { defineIntorConfig, type IntorRawConfig, type IntorResolvedConfig, } from "../src/config";
|
|
3
3
|
export { localizePathname } from "../src/routing";
|
|
4
4
|
export { Translator, type TranslatorPlugin, type TranslateContext, type TranslateHook, type TranslateHandlers, type HandlerContext, type FormatHandler, type LoadingHandler, type MissingHandler, type LocaleMessages, type MessageObject, type MessageValue, tokenize, type Token, } from "intor-translator";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { INTOR_GENERATED_KEY, GenConfigKeys, GenConfig, GenMessages, GenLocale, TranslatorInstance, } from "../../src/core";
|
|
2
|
+
export type { TranslatorInstanceReact } from "../../src/client/react/translator/translator-instance";
|
|
@@ -2,3 +2,4 @@ export { intor, type IntorValue } from "./intor";
|
|
|
2
2
|
export { loadMessages } from "./messages";
|
|
3
3
|
export { type TranslatorInstanceServer } from "./translator";
|
|
4
4
|
export { getTranslator, type GetTranslatorParams, loadMessagesFromUrl, } from "./helpers";
|
|
5
|
+
export { parseCookieHeader } from "./shared/utils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseCookieHeader } from "./parse-cookie-header";
|