intor 2.3.19 → 2.3.21
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/config/define-intor-config.js +2 -0
- package/dist/core/src/config/symbol.js +3 -0
- package/dist/core/src/server/messages/load-local-messages/read-locale-messages/collect-file-entries/collect-file-entries.js +14 -13
- package/dist/express/src/server/messages/load-local-messages/read-locale-messages/collect-file-entries/collect-file-entries.js +14 -13
- package/dist/next/src/server/messages/load-local-messages/read-locale-messages/collect-file-entries/collect-file-entries.js +14 -13
- package/dist/types/export/index.d.ts +1 -1
- package/dist/types/src/config/define-intor-config.d.ts +1 -1
- package/dist/types/src/config/index.d.ts +1 -0
- package/dist/types/src/config/symbol.d.ts +1 -0
- package/dist/types/src/config/types/intor-config.d.ts +3 -0
- package/package.json +1 -1
|
@@ -9,5 +9,6 @@ export { clearMessagesPool } from '../src/core/messages/global-messages-pool.js'
|
|
|
9
9
|
export { mergeMessages } from '../src/core/messages/merge-messages.js';
|
|
10
10
|
export { defineIntorConfig } from '../src/config/define-intor-config.js';
|
|
11
11
|
import '../src/config/constants/cookie.js';
|
|
12
|
+
export { INTOR_CONFIG_SYMBOL } from '../src/config/symbol.js';
|
|
12
13
|
export { localizePathname } from '../src/routing/pathname/localize-pathname.js';
|
|
13
14
|
export { Translator, tokenize } from 'intor-translator';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveCookieOptions } from './resolvers/resolve-cookie-options.js';
|
|
2
2
|
import { resolveFallbackLocales } from './resolvers/resolve-fallback-locales.js';
|
|
3
3
|
import { resolveRoutingOptions } from './resolvers/resolve-routing-options.js';
|
|
4
|
+
import { INTOR_CONFIG_SYMBOL } from './symbol.js';
|
|
4
5
|
import { validateDefaultLocale } from './validators/validate-default-locale.js';
|
|
5
6
|
import { validateId } from './validators/validate-id.js';
|
|
6
7
|
import { validateSupportedLocales } from './validators/validate-supported-locales.js';
|
|
@@ -42,6 +43,7 @@ const defineIntorConfig = (config) => {
|
|
|
42
43
|
logger: { id, ...config.logger },
|
|
43
44
|
client: config.client,
|
|
44
45
|
server: config.server,
|
|
46
|
+
[INTOR_CONFIG_SYMBOL]: true,
|
|
45
47
|
};
|
|
46
48
|
};
|
|
47
49
|
|
|
@@ -20,7 +20,7 @@ import { getLogger } from '../../../../../core/logger/get-logger.js';
|
|
|
20
20
|
* }, ... ];
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [
|
|
23
|
+
async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [], loggerOptions, }) {
|
|
24
24
|
const baseLogger = getLogger(loggerOptions);
|
|
25
25
|
const logger = baseLogger.child({ scope: "collect-file-entries" });
|
|
26
26
|
const supportedExts = new Set(["json", ...exts]);
|
|
@@ -41,22 +41,23 @@ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, l
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
// -------------------------------------------------------------------------
|
|
44
|
-
//
|
|
44
|
+
// 1. Recurse into sub-directories (control flow, no limit)
|
|
45
45
|
// -------------------------------------------------------------------------
|
|
46
|
-
const
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
if (!entry.isDirectory())
|
|
48
|
+
continue;
|
|
49
|
+
await walk(path.join(currentDir, entry.name));
|
|
50
|
+
}
|
|
51
|
+
// -------------------------------------------------------------------------
|
|
52
|
+
// 2. Process files (IO-bound, concurrency-limited)
|
|
53
|
+
// -------------------------------------------------------------------------
|
|
54
|
+
const tasks = entries
|
|
55
|
+
.filter((entry) => entry.isFile())
|
|
56
|
+
.map((entry) => limit(async () => {
|
|
47
57
|
const fullPath = path.join(currentDir, entry.name);
|
|
48
|
-
|
|
49
|
-
if (entry.isDirectory()) {
|
|
50
|
-
await walk(fullPath);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
// Skip unsupported file extensions
|
|
54
|
-
const ext = path.extname(entry.name).slice(1); // "json", "yaml"
|
|
58
|
+
const ext = path.extname(entry.name).slice(1);
|
|
55
59
|
if (!ext || !supportedExts.has(ext))
|
|
56
60
|
return;
|
|
57
|
-
// ---------------------------------------------------------------------
|
|
58
|
-
// Resolve file entry
|
|
59
|
-
// ---------------------------------------------------------------------
|
|
60
61
|
const relativePath = path.relative(rootDir, fullPath);
|
|
61
62
|
const withoutExt = relativePath.slice(0, relativePath.length - (ext.length + 1));
|
|
62
63
|
const segments = withoutExt.split(path.sep).filter(Boolean);
|
|
@@ -20,7 +20,7 @@ import { getLogger } from '../../../../../core/logger/get-logger.js';
|
|
|
20
20
|
* }, ... ];
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [
|
|
23
|
+
async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [], loggerOptions, }) {
|
|
24
24
|
const baseLogger = getLogger(loggerOptions);
|
|
25
25
|
const logger = baseLogger.child({ scope: "collect-file-entries" });
|
|
26
26
|
const supportedExts = new Set(["json", ...exts]);
|
|
@@ -41,22 +41,23 @@ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, l
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
// -------------------------------------------------------------------------
|
|
44
|
-
//
|
|
44
|
+
// 1. Recurse into sub-directories (control flow, no limit)
|
|
45
45
|
// -------------------------------------------------------------------------
|
|
46
|
-
const
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
if (!entry.isDirectory())
|
|
48
|
+
continue;
|
|
49
|
+
await walk(path.join(currentDir, entry.name));
|
|
50
|
+
}
|
|
51
|
+
// -------------------------------------------------------------------------
|
|
52
|
+
// 2. Process files (IO-bound, concurrency-limited)
|
|
53
|
+
// -------------------------------------------------------------------------
|
|
54
|
+
const tasks = entries
|
|
55
|
+
.filter((entry) => entry.isFile())
|
|
56
|
+
.map((entry) => limit(async () => {
|
|
47
57
|
const fullPath = path.join(currentDir, entry.name);
|
|
48
|
-
|
|
49
|
-
if (entry.isDirectory()) {
|
|
50
|
-
await walk(fullPath);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
// Skip unsupported file extensions
|
|
54
|
-
const ext = path.extname(entry.name).slice(1); // "json", "yaml"
|
|
58
|
+
const ext = path.extname(entry.name).slice(1);
|
|
55
59
|
if (!ext || !supportedExts.has(ext))
|
|
56
60
|
return;
|
|
57
|
-
// ---------------------------------------------------------------------
|
|
58
|
-
// Resolve file entry
|
|
59
|
-
// ---------------------------------------------------------------------
|
|
60
61
|
const relativePath = path.relative(rootDir, fullPath);
|
|
61
62
|
const withoutExt = relativePath.slice(0, relativePath.length - (ext.length + 1));
|
|
62
63
|
const segments = withoutExt.split(path.sep).filter(Boolean);
|
|
@@ -20,7 +20,7 @@ import { getLogger } from '../../../../../core/logger/get-logger.js';
|
|
|
20
20
|
* }, ... ];
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [
|
|
23
|
+
async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [], loggerOptions, }) {
|
|
24
24
|
const baseLogger = getLogger(loggerOptions);
|
|
25
25
|
const logger = baseLogger.child({ scope: "collect-file-entries" });
|
|
26
26
|
const supportedExts = new Set(["json", ...exts]);
|
|
@@ -41,22 +41,23 @@ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, l
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
// -------------------------------------------------------------------------
|
|
44
|
-
//
|
|
44
|
+
// 1. Recurse into sub-directories (control flow, no limit)
|
|
45
45
|
// -------------------------------------------------------------------------
|
|
46
|
-
const
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
if (!entry.isDirectory())
|
|
48
|
+
continue;
|
|
49
|
+
await walk(path.join(currentDir, entry.name));
|
|
50
|
+
}
|
|
51
|
+
// -------------------------------------------------------------------------
|
|
52
|
+
// 2. Process files (IO-bound, concurrency-limited)
|
|
53
|
+
// -------------------------------------------------------------------------
|
|
54
|
+
const tasks = entries
|
|
55
|
+
.filter((entry) => entry.isFile())
|
|
56
|
+
.map((entry) => limit(async () => {
|
|
47
57
|
const fullPath = path.join(currentDir, entry.name);
|
|
48
|
-
|
|
49
|
-
if (entry.isDirectory()) {
|
|
50
|
-
await walk(fullPath);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
// Skip unsupported file extensions
|
|
54
|
-
const ext = path.extname(entry.name).slice(1); // "json", "yaml"
|
|
58
|
+
const ext = path.extname(entry.name).slice(1);
|
|
55
59
|
if (!ext || !supportedExts.has(ext))
|
|
56
60
|
return;
|
|
57
|
-
// ---------------------------------------------------------------------
|
|
58
|
-
// Resolve file entry
|
|
59
|
-
// ---------------------------------------------------------------------
|
|
60
61
|
const relativePath = path.relative(rootDir, fullPath);
|
|
61
62
|
const withoutExt = relativePath.slice(0, relativePath.length - (ext.length + 1));
|
|
62
63
|
const segments = withoutExt.split(path.sep).filter(Boolean);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { PREFIX_PLACEHOLDER, IntorError, IntorErrorCode, deepMerge, type DeepMergeOverrideEvent, resolveLoaderOptions, clearLoggerPool, clearMessagesPool, mergeMessages, isValidMessages, type MessagesReader, type MessagesReaders, } from "../src/core";
|
|
2
|
-
export { defineIntorConfig, type IntorRawConfig, type IntorResolvedConfig, } from "../src/config";
|
|
2
|
+
export { defineIntorConfig, type IntorRawConfig, type IntorResolvedConfig, INTOR_CONFIG_SYMBOL, } 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,3 +1,4 @@
|
|
|
1
1
|
export { defineIntorConfig } from "./define-intor-config";
|
|
2
2
|
export { DEFAULT_ROUTING_OPTIONS, DEFAULT_COOKIE_OPTIONS } from "./constants";
|
|
3
3
|
export type { IntorRawConfig, IntorResolvedConfig, LoaderOptions, RemoteHeaders, TranslatorOptions, RoutingResolvedOptions, CookieResolvedOptions, LoggerOptions, } from "./types";
|
|
4
|
+
export { INTOR_CONFIG_SYMBOL } from "./symbol";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const INTOR_CONFIG_SYMBOL: unique symbol;
|
|
@@ -2,6 +2,7 @@ import type { CookieRawOptions, CookieResolvedOptions } from "./cookie";
|
|
|
2
2
|
import type { ClientLoaderOptions, LoaderOptions, ServerLoaderOptions } from "./loader";
|
|
3
3
|
import type { LoggerOptions } from "./logger";
|
|
4
4
|
import type { RoutingRawOptions, RoutingResolvedOptions } from "./routing";
|
|
5
|
+
import type { INTOR_CONFIG_SYMBOL } from "../symbol";
|
|
5
6
|
import type { TranslatorOptions } from "./translator";
|
|
6
7
|
import type { FallbackLocalesMap, Locale, LocaleMessages } from "intor-translator";
|
|
7
8
|
/** Raw configuration object used to define Intor behavior. */
|
|
@@ -53,4 +54,6 @@ export type IntorResolvedConfig = {
|
|
|
53
54
|
loader?: ClientLoaderOptions;
|
|
54
55
|
};
|
|
55
56
|
readonly logger: LoggerOptions;
|
|
57
|
+
/** Internal identity marker. */
|
|
58
|
+
[INTOR_CONFIG_SYMBOL]?: true;
|
|
56
59
|
};
|