@intlayer/config 9.0.0-canary.11 → 9.0.0-canary.14
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/cjs/bundle/index.cjs +1 -1
- package/dist/cjs/callers/base.cjs +42 -0
- package/dist/cjs/callers/base.cjs.map +1 -0
- package/dist/cjs/callers/compat/i18next.cjs +27 -0
- package/dist/cjs/callers/compat/i18next.cjs.map +1 -0
- package/dist/cjs/callers/compat/lingui.cjs +82 -0
- package/dist/cjs/callers/compat/lingui.cjs.map +1 -0
- package/dist/cjs/callers/compat/nextIntl.cjs +44 -0
- package/dist/cjs/callers/compat/nextIntl.cjs.map +1 -0
- package/dist/cjs/callers/compat/reactI18next.cjs +50 -0
- package/dist/cjs/callers/compat/reactI18next.cjs.map +1 -0
- package/dist/cjs/callers/compat/reactIntl.cjs +31 -0
- package/dist/cjs/callers/compat/reactIntl.cjs.map +1 -0
- package/dist/cjs/callers/compat/useIntl.cjs +46 -0
- package/dist/cjs/callers/compat/useIntl.cjs.map +1 -0
- package/dist/cjs/callers/compat/vueI18n.cjs +26 -0
- package/dist/cjs/callers/compat/vueI18n.cjs.map +1 -0
- package/dist/cjs/callers/index.cjs +87 -0
- package/dist/cjs/callers/index.cjs.map +1 -0
- package/dist/cjs/callers/transform.cjs +46 -0
- package/dist/cjs/callers/transform.cjs.map +1 -0
- package/dist/cjs/callers/types.cjs +0 -0
- package/dist/cjs/loadEnvFile.cjs +44 -7
- package/dist/cjs/loadEnvFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/index.cjs +1 -0
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs +7 -5
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +52 -17
- package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +99 -9
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
- package/dist/esm/callers/base.mjs +40 -0
- package/dist/esm/callers/base.mjs.map +1 -0
- package/dist/esm/callers/compat/i18next.mjs +25 -0
- package/dist/esm/callers/compat/i18next.mjs.map +1 -0
- package/dist/esm/callers/compat/lingui.mjs +80 -0
- package/dist/esm/callers/compat/lingui.mjs.map +1 -0
- package/dist/esm/callers/compat/nextIntl.mjs +42 -0
- package/dist/esm/callers/compat/nextIntl.mjs.map +1 -0
- package/dist/esm/callers/compat/reactI18next.mjs +48 -0
- package/dist/esm/callers/compat/reactI18next.mjs.map +1 -0
- package/dist/esm/callers/compat/reactIntl.mjs +29 -0
- package/dist/esm/callers/compat/reactIntl.mjs.map +1 -0
- package/dist/esm/callers/compat/useIntl.mjs +44 -0
- package/dist/esm/callers/compat/useIntl.mjs.map +1 -0
- package/dist/esm/callers/compat/vueI18n.mjs +24 -0
- package/dist/esm/callers/compat/vueI18n.mjs.map +1 -0
- package/dist/esm/callers/index.mjs +72 -0
- package/dist/esm/callers/index.mjs.map +1 -0
- package/dist/esm/callers/transform.mjs +43 -0
- package/dist/esm/callers/transform.mjs.map +1 -0
- package/dist/esm/callers/types.mjs +0 -0
- package/dist/esm/loadEnvFile.mjs +45 -8
- package/dist/esm/loadEnvFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/index.mjs +2 -2
- package/dist/esm/loadExternalFile/loadExternalFile.mjs +7 -5
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/parseFileContent.mjs +52 -17
- package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +102 -13
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
- package/dist/types/callers/base.d.ts +14 -0
- package/dist/types/callers/base.d.ts.map +1 -0
- package/dist/types/callers/compat/i18next.d.ts +12 -0
- package/dist/types/callers/compat/i18next.d.ts.map +1 -0
- package/dist/types/callers/compat/lingui.d.ts +7 -0
- package/dist/types/callers/compat/lingui.d.ts.map +1 -0
- package/dist/types/callers/compat/nextIntl.d.ts +13 -0
- package/dist/types/callers/compat/nextIntl.d.ts.map +1 -0
- package/dist/types/callers/compat/reactI18next.d.ts +15 -0
- package/dist/types/callers/compat/reactI18next.d.ts.map +1 -0
- package/dist/types/callers/compat/reactIntl.d.ts +16 -0
- package/dist/types/callers/compat/reactIntl.d.ts.map +1 -0
- package/dist/types/callers/compat/useIntl.d.ts +12 -0
- package/dist/types/callers/compat/useIntl.d.ts.map +1 -0
- package/dist/types/callers/compat/vueI18n.d.ts +12 -0
- package/dist/types/callers/compat/vueI18n.d.ts.map +1 -0
- package/dist/types/callers/index.d.ts +49 -0
- package/dist/types/callers/index.d.ts.map +1 -0
- package/dist/types/callers/transform.d.ts +57 -0
- package/dist/types/callers/transform.d.ts.map +1 -0
- package/dist/types/callers/types.d.ts +152 -0
- package/dist/types/callers/types.d.ts.map +1 -0
- package/dist/types/configFile/configurationSchema.d.ts +2 -2
- package/dist/types/loadEnvFile.d.ts +1 -1
- package/dist/types/loadEnvFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/index.d.ts +2 -2
- package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/parseFileContent.d.ts +9 -0
- package/dist/types/loadExternalFile/parseFileContent.d.ts.map +1 -1
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +3 -1
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -1
- package/package.json +7 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFileContent.mjs","names":[],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\n// Inject only Node.js-specific globals that are absent from a plain V8 context.\n// JS built-ins (Object, Array, Promise, Math, Date, JSON, Symbol, etc.) are\n// provided automatically by runInNewContext — no need to copy them.\n// Copying all of globalThis would retain hundreds of references (including the\n// full module cache via `global`) inside every sandbox, causing a memory leak.\nconst NODE_GLOBALS = [\n 'Buffer',\n 'setTimeout',\n 'clearTimeout',\n 'setInterval',\n 'clearInterval',\n 'setImmediate',\n 'clearImmediate',\n 'queueMicrotask',\n 'URL',\n 'URLSearchParams',\n 'TextEncoder',\n 'TextDecoder',\n 'AbortController',\n 'AbortSignal',\n 'performance',\n 'fetch',\n 'crypto',\n 'structuredClone',\n] as const;\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n
|
|
1
|
+
{"version":3,"file":"parseFileContent.mjs","names":[],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\n// Inject only Node.js-specific globals that are absent from a plain V8 context.\n// JS built-ins (Object, Array, Promise, Math, Date, JSON, Symbol, etc.) are\n// provided automatically by runInNewContext — no need to copy them.\n// Copying all of globalThis would retain hundreds of references (including the\n// full module cache via `global`) inside every sandbox, causing a memory leak.\nconst NODE_GLOBALS = [\n 'Buffer',\n 'setTimeout',\n 'clearTimeout',\n 'setInterval',\n 'clearInterval',\n 'setImmediate',\n 'clearImmediate',\n 'queueMicrotask',\n 'URL',\n 'URLSearchParams',\n 'TextEncoder',\n 'TextDecoder',\n 'AbortController',\n 'AbortSignal',\n 'performance',\n 'fetch',\n 'crypto',\n 'structuredClone',\n] as const;\n\n/**\n * Cache of the project's React module (or the JSX-capturing fallback) keyed by\n * the require's resolution paths. Node does not cache *failed* resolutions, so\n * without this every sandbox creation in a non-React project (Vue, Svelte,\n * Angular…) pays a full node_modules walk that ends in a throw.\n */\nconst reactModuleCache = new Map<string, { React: unknown }>();\n\n/**\n * Fallback React implementation used when React is not installed in the\n * project. It captures JSX elements as plain objects so JSX can be used in\n * content declarations (esbuild's tsx loader defaults to React.createElement).\n */\nconst createFallbackReact = () => ({\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n});\n\nconst getReactGlobal = (baseRequire: NodeJS.Require): { React: unknown } => {\n // resolve.paths() is computed in-memory (no fs access) and identifies the\n // node_modules chain this require instance resolves against.\n const resolutionKey =\n baseRequire.resolve.paths?.('react')?.join('|') ?? '<default>';\n\n const cachedReactModule = reactModuleCache.get(resolutionKey);\n if (cachedReactModule) return cachedReactModule;\n\n let reactGlobal: { React: unknown };\n try {\n // Dynamically try to require React if it's installed in the project\n reactGlobal = { React: baseRequire('react') };\n } catch (_err) {\n reactGlobal = { React: createFallbackReact() };\n }\n\n reactModuleCache.set(resolutionKey, reactGlobal);\n\n return reactGlobal;\n};\n\n/**\n * Snapshot of the non-env `process` properties, taken once at module load.\n * Spreading `process` enumerates ~100 properties (some behind getters); doing\n * it per sandbox is wasteful since everything except `env` is static.\n */\nconst processSnapshot = { ...process };\n\n/**\n * Builds the global context handed to `runInNewContext`.\n *\n * SECURITY NOTE: this sandbox exists for global-scope hygiene (fresh\n * module/exports, controlled env), NOT for containment. It exposes the real\n * project `require`, a copy of `process`, and `fetch` — code executed here has\n * full host privileges. Only ever run trusted, build-time project files\n * (same trust model as `vite.config.ts`).\n */\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...processSnapshot,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...getReactGlobal(baseRequire),\n };\n\n for (const key of NODE_GLOBALS) {\n if (!(key in sandboxContext) && key in globalThis) {\n (sandboxContext as Record<string, unknown>)[key] =\n globalThis[key as keyof typeof globalThis];\n }\n }\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n let result: T | undefined;\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n result = candidate as T;\n break;\n }\n }\n\n // Drop heavy references so the V8 context created by runInNewContext can be\n // garbage-collected promptly. The extracted `result` is a plain data object\n // and does not retain the sandbox.\n (sandboxContext as Record<string, unknown>).require = undefined;\n (sandboxContext as Record<string, unknown>).process = undefined;\n (sandboxContext as Record<string, unknown>).React = undefined;\n (sandboxContext as Record<string, unknown>).module = undefined;\n (sandboxContext as Record<string, unknown>).exports = undefined;\n\n return result;\n};\n"],"mappings":";;;;;;AA+BA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;AAQD,MAAM,mCAAmB,IAAI,KAAiC;;;;;;AAO9D,MAAM,6BAA6B;CACjC,gBAAgB,MAAW,OAAY,GAAG,cAAqB;EAC7D;EACA,OAAO;GACL,GAAG;GACH,UAAU,SAAS,UAAU,IAAI,SAAS,KAAK;GAChD;EACF;CACD,UAAU,OAAO,IAAI,iBAAiB;CACvC;AAED,MAAM,kBAAkB,gBAAoD;CA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ACT,GAAG,eAAe,YAAY;EAC/B;AAED,MAAK,MAAM,OAAO,aAChB,KAAI,EAAE,OAAO,mBAAmB,OAAO,WACrC,CAAC,eAA2C,OAC1C,WAAW;AAIjB,QAAO;;AAGT,MAAa,oBACX,mBACA,YACkB;CAClB,MAAM,iBAAiB,kBAAkB,QAAQ;AAGjD,iBAAgB,kBAAkB,qBAAqB,eAAe;CAEtE,MAAM,aAAwB;EAC5B,eAAe,SAAS;EACxB,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ;EACxB;CAED,IAAI;AACJ,MAAK,MAAM,aAAa,WACtB,KACE,aACA,OAAO,cAAc,YACrB,OAAO,KAAK,UAAoB,CAAC,SAAS,GAC1C;AACA,WAAS;AACT;;AAOJ,CAAC,eAA2C,UAAU;AACtD,CAAC,eAA2C,UAAU;AACtD,CAAC,eAA2C,QAAQ;AACpD,CAAC,eAA2C,SAAS;AACrD,CAAC,eAA2C,UAAU;AAEtD,QAAO"}
|
|
@@ -1,15 +1,30 @@
|
|
|
1
|
+
import { computeKeyId } from "../utils/cacheMemory.mjs";
|
|
1
2
|
import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
|
|
2
3
|
import { getLoader } from "./bundleFile.mjs";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
|
-
import { dirname, extname, join } from "node:path";
|
|
4
|
+
import { existsSync, statSync } from "node:fs";
|
|
5
|
+
import { dirname, extname, isAbsolute, join, resolve } from "node:path";
|
|
5
6
|
import { createRequire } from "node:module";
|
|
6
|
-
import {
|
|
7
|
+
import { build, buildSync } from "esbuild";
|
|
7
8
|
import { pathToFileURL } from "node:url";
|
|
8
9
|
|
|
9
10
|
//#region src/loadExternalFile/transpileTSToCJS.ts
|
|
11
|
+
/**
|
|
12
|
+
* Cache of resolved tsconfig paths keyed by the file's directory.
|
|
13
|
+
* Avoids re-walking to package.json + existsSync on every transpilation.
|
|
14
|
+
*/
|
|
15
|
+
const tsConfigPathCache = /* @__PURE__ */ new Map();
|
|
10
16
|
const getTsConfigPath = (filePath) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
17
|
+
const fileDirectory = dirname(filePath);
|
|
18
|
+
if (tsConfigPathCache.has(fileDirectory)) return tsConfigPathCache.get(fileDirectory);
|
|
19
|
+
let resolvedPath;
|
|
20
|
+
try {
|
|
21
|
+
const tsconfigPath = join(getPackageJsonPath(fileDirectory).baseDir, "tsconfig.json");
|
|
22
|
+
resolvedPath = existsSync(tsconfigPath) ? tsconfigPath : void 0;
|
|
23
|
+
} catch {
|
|
24
|
+
resolvedPath = void 0;
|
|
25
|
+
}
|
|
26
|
+
tsConfigPathCache.set(fileDirectory, resolvedPath);
|
|
27
|
+
return resolvedPath;
|
|
13
28
|
};
|
|
14
29
|
const getTransformationOptions = (filePath) => ({
|
|
15
30
|
loader: {
|
|
@@ -29,15 +44,85 @@ const getTransformationOptions = (filePath) => ({
|
|
|
29
44
|
write: false,
|
|
30
45
|
packages: "external",
|
|
31
46
|
bundle: true,
|
|
47
|
+
metafile: true,
|
|
32
48
|
tsconfig: getTsConfigPath(filePath),
|
|
33
49
|
define: {
|
|
34
50
|
"import.meta.url": JSON.stringify(pathToFileURL(filePath).href),
|
|
35
51
|
"import.meta.env": "process.env"
|
|
36
52
|
}
|
|
37
53
|
});
|
|
54
|
+
/**
|
|
55
|
+
* In-memory cache of transpiled outputs keyed by entry file path (one entry
|
|
56
|
+
* per file, so re-transpilations replace rather than accumulate).
|
|
57
|
+
* The entry file is validated by content hash; bundled relative imports are
|
|
58
|
+
* validated by mtime + size so an edited dependency invalidates the cache.
|
|
59
|
+
*/
|
|
60
|
+
const transpileCache = /* @__PURE__ */ new Map();
|
|
61
|
+
const isInputUnchanged = (input) => {
|
|
62
|
+
try {
|
|
63
|
+
const stats = statSync(input.path);
|
|
64
|
+
return stats.mtimeMs === input.mtimeMs && stats.size === input.size;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const getCachedTranspilation = (filePath, codeHash, optionsKey) => {
|
|
70
|
+
const cacheEntry = transpileCache.get(filePath);
|
|
71
|
+
if (!cacheEntry) return void 0;
|
|
72
|
+
if (cacheEntry.codeHash !== codeHash) return void 0;
|
|
73
|
+
if (cacheEntry.optionsKey !== optionsKey) return void 0;
|
|
74
|
+
if (!cacheEntry.inputs.every(isInputUnchanged)) return void 0;
|
|
75
|
+
return cacheEntry.output;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Extracts the fingerprints of every bundled input from the esbuild metafile.
|
|
79
|
+
* Returns `undefined` when an input cannot be fingerprinted (the result should
|
|
80
|
+
* then not be cached, as invalidation would be unreliable).
|
|
81
|
+
*/
|
|
82
|
+
const getInputFingerprints = (metafile, entryFilePath) => {
|
|
83
|
+
if (!metafile) return void 0;
|
|
84
|
+
const resolvedEntryFilePath = resolve(entryFilePath);
|
|
85
|
+
const inputs = [];
|
|
86
|
+
for (const inputPath of Object.keys(metafile.inputs)) {
|
|
87
|
+
if (inputPath === "<stdin>") continue;
|
|
88
|
+
if (inputPath.includes(":") && !isAbsolute(inputPath)) return void 0;
|
|
89
|
+
const absoluteInputPath = isAbsolute(inputPath) ? inputPath : resolve(process.cwd(), inputPath);
|
|
90
|
+
if (absoluteInputPath === resolvedEntryFilePath) continue;
|
|
91
|
+
try {
|
|
92
|
+
const stats = statSync(absoluteInputPath);
|
|
93
|
+
inputs.push({
|
|
94
|
+
path: absoluteInputPath,
|
|
95
|
+
mtimeMs: stats.mtimeMs,
|
|
96
|
+
size: stats.size
|
|
97
|
+
});
|
|
98
|
+
} catch {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return inputs;
|
|
103
|
+
};
|
|
104
|
+
const setCachedTranspilation = (filePath, codeHash, optionsKey, moduleResult, output) => {
|
|
105
|
+
const inputs = getInputFingerprints(moduleResult.metafile, filePath);
|
|
106
|
+
if (!inputs) return;
|
|
107
|
+
transpileCache.set(filePath, {
|
|
108
|
+
codeHash,
|
|
109
|
+
optionsKey,
|
|
110
|
+
output,
|
|
111
|
+
inputs
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
/** Clears the in-memory transpilation cache (mainly for tests). */
|
|
115
|
+
const clearTranspileCache = () => {
|
|
116
|
+
transpileCache.clear();
|
|
117
|
+
tsConfigPathCache.clear();
|
|
118
|
+
};
|
|
38
119
|
const transpileTSToCJSSync = (code, filePath, options) => {
|
|
39
120
|
const loader = getLoader(extname(filePath));
|
|
40
121
|
const { esbuildInstance, ...buildOptions } = options ?? {};
|
|
122
|
+
const codeHash = computeKeyId([code]);
|
|
123
|
+
const optionsKey = computeKeyId([buildOptions]);
|
|
124
|
+
const cachedOutput = getCachedTranspilation(filePath, codeHash, optionsKey);
|
|
125
|
+
if (typeof cachedOutput === "string") return cachedOutput;
|
|
41
126
|
const esbuildBuildSync = esbuildInstance?.buildSync ?? buildSync;
|
|
42
127
|
const g = globalThis;
|
|
43
128
|
const hadFilename = typeof g.__filename === "string";
|
|
@@ -68,12 +153,18 @@ const transpileTSToCJSSync = (code, filePath, options) => {
|
|
|
68
153
|
else g.__dirname = prevDirname;
|
|
69
154
|
}
|
|
70
155
|
}
|
|
71
|
-
|
|
156
|
+
const moduleResultString = moduleResult.outputFiles?.[0]?.text;
|
|
157
|
+
if (typeof moduleResultString === "string") setCachedTranspilation(filePath, codeHash, optionsKey, moduleResult, moduleResultString);
|
|
158
|
+
return moduleResultString;
|
|
72
159
|
};
|
|
73
160
|
const transpileTSToCJS = async (code, filePath, options) => {
|
|
74
161
|
const loader = getLoader(extname(filePath));
|
|
75
162
|
const { esbuildInstance, ...buildOptions } = options ?? {};
|
|
76
|
-
const
|
|
163
|
+
const codeHash = computeKeyId([code]);
|
|
164
|
+
const optionsKey = computeKeyId([buildOptions]);
|
|
165
|
+
const cachedOutput = getCachedTranspilation(filePath, codeHash, optionsKey);
|
|
166
|
+
if (typeof cachedOutput === "string") return cachedOutput;
|
|
167
|
+
const moduleResult = await (esbuildInstance?.build ?? build)({
|
|
77
168
|
stdin: {
|
|
78
169
|
contents: code,
|
|
79
170
|
loader,
|
|
@@ -83,13 +174,11 @@ const transpileTSToCJS = async (code, filePath, options) => {
|
|
|
83
174
|
...getTransformationOptions(filePath),
|
|
84
175
|
...buildOptions
|
|
85
176
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await ctx.dispose();
|
|
90
|
-
}
|
|
177
|
+
const moduleResultString = moduleResult.outputFiles?.[0]?.text;
|
|
178
|
+
if (typeof moduleResultString === "string") setCachedTranspilation(filePath, codeHash, optionsKey, moduleResult, moduleResultString);
|
|
179
|
+
return moduleResultString;
|
|
91
180
|
};
|
|
92
181
|
|
|
93
182
|
//#endregion
|
|
94
|
-
export { transpileTSToCJS, transpileTSToCJSSync };
|
|
183
|
+
export { clearTranspileCache, transpileTSToCJS, transpileTSToCJSSync };
|
|
95
184
|
//# sourceMappingURL=transpileTSToCJS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpileTSToCJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n buildSync,\n context,\n} from 'esbuild';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { getLoader } from './bundleFile';\n\nexport type TranspileOptions = BuildOptions & {\n /**\n * Optional custom esbuild instance to use for transpilation.\n * Useful in environments (e.g. VS Code extensions) where the bundled\n * esbuild binary may not match the host platform.\n * When provided, its `buildSync`/`build` methods are used instead of\n * the ones imported from the `esbuild` package.\n */\n esbuildInstance?: typeof import('esbuild');\n};\n\nconst getTsConfigPath = (filePath: string): string | undefined => {\n const tsconfigPath = join(\n getPackageJsonPath(dirname(filePath)).baseDir,\n 'tsconfig.json'\n );\n\n // Only return the tsconfig path if it exists\n return existsSync(tsconfigPath) ? tsconfigPath : undefined;\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node20',\n platform: 'node',\n write: false,\n packages: 'external',\n bundle: true,\n tsconfig: getTsConfigPath(filePath),\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n 'import.meta.env': 'process.env',\n },\n});\n\nexport const transpileTSToCJSSync = (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n const esbuildBuildSync = esbuildInstance?.buildSync ?? buildSync;\n\n // esbuild's worker thread service calls `new Worker(__filename, …)` on first use.\n // In Vite's SSR module runner the SSR-optimised chunk is ESM and __filename is\n // never declared (confirmed: accessing it throws ReferenceError, not undefined).\n // Because there is no local declaration the bare `__filename` lookup falls\n // through to globalThis, so we set it there to esbuild's own CJS entry-point –\n // the exact path esbuild would use if it were loaded in a normal CJS context.\n //\n // IMPORTANT: We save/restore the globals so this temporary shim does not leak\n // to other Vite plugins (e.g. `@vitejs/plugin-react-swc`) that check\n // `typeof __dirname !== \"undefined\"` to locate their own assets.\n const g = globalThis as Record<string, unknown>;\n const hadFilename = typeof g.__filename === 'string';\n const prevFilename = g.__filename;\n const prevDirname = g.__dirname;\n\n if (!hadFilename) {\n try {\n const _require = createRequire(import.meta.url);\n const esbuildEntry = _require.resolve('esbuild');\n g.__filename = esbuildEntry;\n g.__dirname = dirname(esbuildEntry);\n } catch {\n // Best-effort: if esbuild can't be resolved the caller's catch handles it\n }\n }\n\n let moduleResult: BuildResult;\n try {\n moduleResult = esbuildBuildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n } finally {\n // Always restore the previous values so the globals don't linger.\n if (!hadFilename) {\n if (prevFilename === undefined) {\n delete g.__filename;\n } else {\n g.__filename = prevFilename;\n }\n if (prevDirname === undefined) {\n delete g.__dirname;\n } else {\n g.__dirname = prevDirname;\n }\n }\n }\n\n const moduleResultString = moduleResult!.outputFiles?.[0]?.text;\n\n return moduleResultString;\n};\n\nexport const transpileTSToCJS = async (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n // Use context() + rebuild() + dispose() so esbuild deterministically releases\n // Go-subprocess resources for each one-shot transpilation, preventing them\n // from accumulating between rapid HMR-driven file changes.\n const esbuildContext = esbuildInstance?.context ?? context;\n\n const ctx = await esbuildContext({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath),\n sourcefile: filePath,\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n\n try {\n const moduleResult = await ctx.rebuild();\n return moduleResult.outputFiles?.[0].text;\n } finally {\n await ctx.dispose();\n }\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAM,mBAAmB,aAAyC;CAChE,MAAM,eAAe,KACnB,mBAAmB,QAAQ,SAAS,CAAC,CAAC,SACtC,gBACD;AAGD,QAAO,WAAW,aAAa,GAAG,eAAe;;AAGnD,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CACR,UAAU,gBAAgB,SAAS;CACnC,Q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S"}
|
|
1
|
+
{"version":3,"file":"transpileTSToCJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, extname, isAbsolute, join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Metafile,\n} from 'esbuild';\nimport { computeKeyId } from '../utils/cacheMemory';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { getLoader } from './bundleFile';\n\nexport type TranspileOptions = BuildOptions & {\n /**\n * Optional custom esbuild instance to use for transpilation.\n * Useful in environments (e.g. VS Code extensions) where the bundled\n * esbuild binary may not match the host platform.\n * When provided, its `buildSync`/`build` methods are used instead of\n * the ones imported from the `esbuild` package.\n */\n esbuildInstance?: typeof import('esbuild');\n};\n\n/**\n * Cache of resolved tsconfig paths keyed by the file's directory.\n * Avoids re-walking to package.json + existsSync on every transpilation.\n */\nconst tsConfigPathCache = new Map<string, string | undefined>();\n\nconst getTsConfigPath = (filePath: string): string | undefined => {\n const fileDirectory = dirname(filePath);\n\n if (tsConfigPathCache.has(fileDirectory)) {\n return tsConfigPathCache.get(fileDirectory);\n }\n\n let resolvedPath: string | undefined;\n try {\n const tsconfigPath = join(\n getPackageJsonPath(fileDirectory).baseDir,\n 'tsconfig.json'\n );\n\n // Only return the tsconfig path if it exists\n resolvedPath = existsSync(tsconfigPath) ? tsconfigPath : undefined;\n } catch {\n // No package.json found up the tree — transpile without a tsconfig\n resolvedPath = undefined;\n }\n\n tsConfigPathCache.set(fileDirectory, resolvedPath);\n\n return resolvedPath;\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node20',\n platform: 'node',\n write: false,\n packages: 'external',\n bundle: true,\n // The metafile lists every bundled input, which the transpile cache uses to\n // invalidate when an imported file changes (the entry itself is keyed by hash).\n metafile: true,\n tsconfig: getTsConfigPath(filePath),\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n 'import.meta.env': 'process.env',\n },\n});\n\n/** Fingerprint of a bundled input file, used to detect changes without re-reading it. */\ntype TranspileCacheInput = {\n path: string;\n mtimeMs: number;\n size: number;\n};\n\ntype TranspileCacheEntry = {\n /** Hash of the entry file's source code. */\n codeHash: string;\n /** Hash of the build options, so different option sets don't collide. */\n optionsKey: string;\n /** The transpiled CJS output. */\n output: string;\n /** Fingerprints of every non-entry input bundled into the output. */\n inputs: TranspileCacheInput[];\n};\n\n/**\n * In-memory cache of transpiled outputs keyed by entry file path (one entry\n * per file, so re-transpilations replace rather than accumulate).\n * The entry file is validated by content hash; bundled relative imports are\n * validated by mtime + size so an edited dependency invalidates the cache.\n */\nconst transpileCache = new Map<string, TranspileCacheEntry>();\n\nconst isInputUnchanged = (input: TranspileCacheInput): boolean => {\n try {\n const stats = statSync(input.path);\n return stats.mtimeMs === input.mtimeMs && stats.size === input.size;\n } catch {\n // File removed or unreadable — treat as changed\n return false;\n }\n};\n\nconst getCachedTranspilation = (\n filePath: string,\n codeHash: string,\n optionsKey: string\n): string | undefined => {\n const cacheEntry = transpileCache.get(filePath);\n\n if (!cacheEntry) return undefined;\n if (cacheEntry.codeHash !== codeHash) return undefined;\n if (cacheEntry.optionsKey !== optionsKey) return undefined;\n if (!cacheEntry.inputs.every(isInputUnchanged)) return undefined;\n\n return cacheEntry.output;\n};\n\n/**\n * Extracts the fingerprints of every bundled input from the esbuild metafile.\n * Returns `undefined` when an input cannot be fingerprinted (the result should\n * then not be cached, as invalidation would be unreliable).\n */\nconst getInputFingerprints = (\n metafile: Metafile | undefined,\n entryFilePath: string\n): TranspileCacheInput[] | undefined => {\n if (!metafile) return undefined;\n\n const resolvedEntryFilePath = resolve(entryFilePath);\n const inputs: TranspileCacheInput[] = [];\n\n for (const inputPath of Object.keys(metafile.inputs)) {\n // The entry itself is provided via stdin and validated by content hash.\n // esbuild labels it \"<stdin>\", or with the sourcefile path when set.\n if (inputPath === '<stdin>') continue;\n // Virtual modules from plugins (e.g. \"plugin:...\") cannot be fingerprinted\n if (inputPath.includes(':') && !isAbsolute(inputPath)) return undefined;\n\n const absoluteInputPath = isAbsolute(inputPath)\n ? inputPath\n : resolve(process.cwd(), inputPath);\n\n if (absoluteInputPath === resolvedEntryFilePath) continue;\n\n try {\n const stats = statSync(absoluteInputPath);\n inputs.push({\n path: absoluteInputPath,\n mtimeMs: stats.mtimeMs,\n size: stats.size,\n });\n } catch {\n return undefined;\n }\n }\n\n return inputs;\n};\n\nconst setCachedTranspilation = (\n filePath: string,\n codeHash: string,\n optionsKey: string,\n moduleResult: BuildResult,\n output: string\n): void => {\n const inputs = getInputFingerprints(moduleResult.metafile, filePath);\n\n // Without a usable metafile the cache cannot be invalidated reliably — skip\n if (!inputs) return;\n\n transpileCache.set(filePath, { codeHash, optionsKey, output, inputs });\n};\n\n/** Clears the in-memory transpilation cache (mainly for tests). */\nexport const clearTranspileCache = (): void => {\n transpileCache.clear();\n tsConfigPathCache.clear();\n};\n\nexport const transpileTSToCJSSync = (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n\n const codeHash = computeKeyId([code]);\n const optionsKey = computeKeyId([buildOptions]);\n\n const cachedOutput = getCachedTranspilation(filePath, codeHash, optionsKey);\n if (typeof cachedOutput === 'string') return cachedOutput;\n\n const esbuildBuildSync = esbuildInstance?.buildSync ?? buildSync;\n\n // esbuild's worker thread service calls `new Worker(__filename, …)` on first use.\n // In Vite's SSR module runner the SSR-optimised chunk is ESM and __filename is\n // never declared (confirmed: accessing it throws ReferenceError, not undefined).\n // Because there is no local declaration the bare `__filename` lookup falls\n // through to globalThis, so we set it there to esbuild's own CJS entry-point –\n // the exact path esbuild would use if it were loaded in a normal CJS context.\n //\n // IMPORTANT: We save/restore the globals so this temporary shim does not leak\n // to other Vite plugins (e.g. `@vitejs/plugin-react-swc`) that check\n // `typeof __dirname !== \"undefined\"` to locate their own assets.\n const g = globalThis as Record<string, unknown>;\n const hadFilename = typeof g.__filename === 'string';\n const prevFilename = g.__filename;\n const prevDirname = g.__dirname;\n\n if (!hadFilename) {\n try {\n const _require = createRequire(import.meta.url);\n const esbuildEntry = _require.resolve('esbuild');\n g.__filename = esbuildEntry;\n g.__dirname = dirname(esbuildEntry);\n } catch {\n // Best-effort: if esbuild can't be resolved the caller's catch handles it\n }\n }\n\n let moduleResult: BuildResult;\n try {\n moduleResult = esbuildBuildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n } finally {\n // Always restore the previous values so the globals don't linger.\n if (!hadFilename) {\n if (prevFilename === undefined) {\n // biome-ignore lint/performance/noDelete: the global must be truly absent — assigning undefined would leave the key present and break `typeof __filename` checks in other tools\n delete g.__filename;\n } else {\n g.__filename = prevFilename;\n }\n if (prevDirname === undefined) {\n // biome-ignore lint/performance/noDelete: same as __filename above\n delete g.__dirname;\n } else {\n g.__dirname = prevDirname;\n }\n }\n }\n\n const moduleResultString = moduleResult!.outputFiles?.[0]?.text;\n\n if (typeof moduleResultString === 'string') {\n setCachedTranspilation(\n filePath,\n codeHash,\n optionsKey,\n moduleResult!,\n moduleResultString\n );\n }\n\n return moduleResultString;\n};\n\nexport const transpileTSToCJS = async (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n\n const codeHash = computeKeyId([code]);\n const optionsKey = computeKeyId([buildOptions]);\n\n const cachedOutput = getCachedTranspilation(filePath, codeHash, optionsKey);\n if (typeof cachedOutput === 'string') return cachedOutput;\n\n // A one-shot build() releases its Go-side resources on completion and costs a\n // single service round-trip (context()+rebuild()+dispose() costs three).\n const esbuildBuild = esbuildInstance?.build ?? build;\n\n const moduleResult = await esbuildBuild({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath),\n sourcefile: filePath,\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0]?.text;\n\n if (typeof moduleResultString === 'string') {\n setCachedTranspilation(\n filePath,\n codeHash,\n optionsKey,\n moduleResult,\n moduleResultString\n );\n }\n\n return moduleResultString;\n};\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,oCAAoB,IAAI,KAAiC;AAE/D,MAAM,mBAAmB,aAAyC;CAChE,MAAM,gBAAgB,QAAQ,SAAS;AAEvC,KAAI,kBAAkB,IAAI,cAAc,CACtC,QAAO,kBAAkB,IAAI,cAAc;CAG7C,IAAI;AACJ,KAAI;EACF,MAAM,eAAe,KACnB,mBAAmB,cAAc,CAAC,SAClC,gBACD;AAGD,iBAAe,WAAW,aAAa,GAAG,eAAe;SACnD;AAEN,iBAAe;;AAGjB,mBAAkB,IAAI,eAAe,aAAa;AAElD,QAAO;;AAGT,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CAGR,UAAU;CACV,UAAU,gBAAgB,SAAS;CACnC,QAAQ;EACN,mBAAmB,KAAK,UAAU,cAAc,SAAS,CAAC,KAAK;EAC/D,mBAAmB;EACpB;CACF;;;;;;;AA0BD,MAAM,iCAAiB,IAAI,KAAkC;AAE7D,MAA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AAO,iBAAiB,SAAU,QAAO;CAM7C,MAAM,eAAe,OAFA,iBAAiB,SAAS,OAEP;EACtC,OAAO;GACL,UAAU;GACV;GACA,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC;CAEF,MAAM,qBAAqB,aAAa,cAAc,IAAI;AAE1D,KAAI,OAAO,uBAAuB,SAChC,wBACE,UACA,UACA,YACA,cACA,mBACD;AAGH,QAAO"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CallerDescriptor } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/callers/base.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Base intlayer getters — always active, independent of any compat library.
|
|
6
|
+
*
|
|
7
|
+
* Their result is the dictionary content object itself: fields are consumed
|
|
8
|
+
* through member access (`content.title`) or destructuring
|
|
9
|
+
* (`const { title } = useIntlayer('home')`).
|
|
10
|
+
*/
|
|
11
|
+
declare const BASE_CALLERS: CallerDescriptor[];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { BASE_CALLERS };
|
|
14
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":[],"sources":["../../../src/callers/base.ts"],"mappings":";;;;;AASA;;;;;cAAa,YAAA,EAAc,gBAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/callers/compat/i18next.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* i18next — `@intlayer/i18next` compat adapter.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `compat/i18next/src/plugin/index.ts` (`I18NEXT_COMPAT_CALLERS`).
|
|
8
|
+
*/
|
|
9
|
+
declare const I18NEXT_CALLERS: CallerDescriptor[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { I18NEXT_CALLERS };
|
|
12
|
+
//# sourceMappingURL=i18next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18next.d.ts","names":[],"sources":["../../../../src/callers/compat/i18next.ts"],"mappings":";;;;;AAOA;;;cAAa,eAAA,EAAiB,gBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lingui.d.ts","names":[],"sources":["../../../../src/callers/compat/lingui.ts"],"mappings":";;;cAwBa,cAAA,EAAgB,gBAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/callers/compat/nextIntl.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* next-intl — `@intlayer/next-intl` compat adapter.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `compat/next-intl/src/plugin/index.ts` (`NEXT_INTL_SWC_CALLERS`),
|
|
8
|
+
* adding the `getTranslations({ locale, namespace })` object overload.
|
|
9
|
+
*/
|
|
10
|
+
declare const NEXT_INTL_CALLERS: CallerDescriptor[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { NEXT_INTL_CALLERS };
|
|
13
|
+
//# sourceMappingURL=nextIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextIntl.d.ts","names":[],"sources":["../../../../src/callers/compat/nextIntl.ts"],"mappings":";;;;;AAQA;;;;cAAa,iBAAA,EAAmB,gBAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/callers/compat/reactI18next.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* react-i18next / next-i18next — `@intlayer/react-i18next` and
|
|
6
|
+
* `@intlayer/next-i18next` compat adapters (next-i18next re-exports the
|
|
7
|
+
* react-i18next hook, so both libraries share the same callers).
|
|
8
|
+
*
|
|
9
|
+
* Mirrors `compat/react-i18next/src/plugin/index.ts` and
|
|
10
|
+
* `compat/next-i18next/src/plugin/index.ts`.
|
|
11
|
+
*/
|
|
12
|
+
declare const REACT_I18NEXT_CALLERS: CallerDescriptor[];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { REACT_I18NEXT_CALLERS };
|
|
15
|
+
//# sourceMappingURL=reactI18next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactI18next.d.ts","names":[],"sources":["../../../../src/callers/compat/reactI18next.ts"],"mappings":";;;;;AAUA;;;;;;cAAa,qBAAA,EAAuB,gBAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/callers/compat/reactIntl.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* react-intl (FormatJS) — `@intlayer/react-intl` compat adapter.
|
|
6
|
+
*
|
|
7
|
+
* The full dotted message id encodes both the dictionary key and the field
|
|
8
|
+
* path: `formatMessage({ id: 'home.title' })` → dictionary `home`, field
|
|
9
|
+
* `title`.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors `compat/react-intl/src/plugin/index.ts`.
|
|
12
|
+
*/
|
|
13
|
+
declare const REACT_INTL_CALLERS: CallerDescriptor[];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { REACT_INTL_CALLERS };
|
|
16
|
+
//# sourceMappingURL=reactIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactIntl.d.ts","names":[],"sources":["../../../../src/callers/compat/reactIntl.ts"],"mappings":";;;;;AAWA;;;;;;;cAAa,kBAAA,EAAoB,gBAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/callers/compat/useIntl.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* use-intl — `@intlayer/use-intl` compat adapter.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `compat/use-intl/src/plugin/index.ts`.
|
|
8
|
+
*/
|
|
9
|
+
declare const USE_INTL_CALLERS: CallerDescriptor[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { USE_INTL_CALLERS };
|
|
12
|
+
//# sourceMappingURL=useIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../../src/callers/compat/useIntl.ts"],"mappings":";;;;;AAOA;;;cAAa,gBAAA,EAAkB,gBAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/callers/compat/vueI18n.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* vue-i18n — `@intlayer/vue-i18n` compat adapter.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `compat/vue-i18n/src/plugin/index.ts`.
|
|
8
|
+
*/
|
|
9
|
+
declare const VUE_I18N_CALLERS: CallerDescriptor[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { VUE_I18N_CALLERS };
|
|
12
|
+
//# sourceMappingURL=vueI18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vueI18n.d.ts","names":[],"sources":["../../../../src/callers/compat/vueI18n.ts"],"mappings":";;;;;AAOA;;;cAAa,gBAAA,EAAkB,gBAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CallerDescriptor, CallerResultShape, CallerValueSource } from "./types.js";
|
|
2
|
+
import { BASE_CALLERS } from "./base.js";
|
|
3
|
+
import { I18NEXT_CALLERS } from "./compat/i18next.js";
|
|
4
|
+
import { LINGUI_CALLERS } from "./compat/lingui.js";
|
|
5
|
+
import { NEXT_INTL_CALLERS } from "./compat/nextIntl.js";
|
|
6
|
+
import { REACT_I18NEXT_CALLERS } from "./compat/reactI18next.js";
|
|
7
|
+
import { REACT_INTL_CALLERS } from "./compat/reactIntl.js";
|
|
8
|
+
import { USE_INTL_CALLERS } from "./compat/useIntl.js";
|
|
9
|
+
import { VUE_I18N_CALLERS } from "./compat/vueI18n.js";
|
|
10
|
+
import { SwcExtraCallerConfig, getRewritableCallers, toSwcExtraCallers } from "./transform.js";
|
|
11
|
+
|
|
12
|
+
//#region src/callers/index.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Compat-adapter callers, grouped in one list. Each compat package's bundler
|
|
15
|
+
* plugin injects its own slice (e.g. `REACT_I18NEXT_CALLERS`) into the build
|
|
16
|
+
* pipeline; this aggregate exists for consumers that need every syntax at
|
|
17
|
+
* once, such as the LSP.
|
|
18
|
+
*/
|
|
19
|
+
declare const COMPAT_CALLERS: CallerDescriptor[];
|
|
20
|
+
/** Base + compat callers — the full registry the matchers run against. */
|
|
21
|
+
declare const ALL_CALLERS: CallerDescriptor[];
|
|
22
|
+
/**
|
|
23
|
+
* Descriptors indexed by caller name. A name can map to several descriptors
|
|
24
|
+
* (e.g. `Trans` exists in both react-i18next and lingui with different
|
|
25
|
+
* attributes); matchers try them in registry order.
|
|
26
|
+
*/
|
|
27
|
+
declare const CALLERS_BY_NAME: Map<string, CallerDescriptor[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Caller names whose dictionary key can appear as a positional string literal
|
|
30
|
+
* argument (`caller('key', …)` / `caller(locale, 'key', …)`). Used to build
|
|
31
|
+
* text-search regexes over project source files (find-references) and the
|
|
32
|
+
* completion trigger pattern. Callers whose key never appears positionally
|
|
33
|
+
* (fixed namespace, options object, JSX-only) are excluded on purpose.
|
|
34
|
+
*/
|
|
35
|
+
declare const getPositionalKeyCallerNames: () => string[];
|
|
36
|
+
/**
|
|
37
|
+
* Returns `true` when the descriptor may participate in matching for a file
|
|
38
|
+
* importing from `importSources`. Descriptors flagged `requiresImport` only
|
|
39
|
+
* activate when the file imports from one of their declared modules;
|
|
40
|
+
* everything else is always active (results are still validated against the
|
|
41
|
+
* project's dictionaries downstream).
|
|
42
|
+
*
|
|
43
|
+
* @param descriptor - The caller descriptor to gate.
|
|
44
|
+
* @param fileImportSources - Module specifiers imported by the analysed file.
|
|
45
|
+
*/
|
|
46
|
+
declare const isCallerActive: (descriptor: CallerDescriptor, fileImportSources: ReadonlySet<string>) => boolean;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { ALL_CALLERS, BASE_CALLERS, CALLERS_BY_NAME, COMPAT_CALLERS, type CallerDescriptor, type CallerResultShape, type CallerValueSource, I18NEXT_CALLERS, LINGUI_CALLERS, NEXT_INTL_CALLERS, REACT_I18NEXT_CALLERS, REACT_INTL_CALLERS, type SwcExtraCallerConfig, USE_INTL_CALLERS, VUE_I18N_CALLERS, getPositionalKeyCallerNames, getRewritableCallers, isCallerActive, toSwcExtraCallers };
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/callers/index.ts"],"mappings":";;;;;;;;;;;;;AAmCA;;;;;cAAa,cAAA,EAAgB,gBAAA;;cAWhB,WAAA,EAAa,gBAAA;;;AAU1B;;;cAAa,eAAA,EAAiB,GAAA,SAAY,gBAAA;;AAuB1C;;;;;AAwBA;cAxBa,2BAAA;;;;;;;;;;;cAwBA,cAAA,GACX,UAAA,EAAY,gBAAA,EACZ,iBAAA,EAAmB,WAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CallerDescriptor } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/callers/transform.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Wire format of an extra caller forwarded to the `@intlayer/swc` plugin.
|
|
6
|
+
*
|
|
7
|
+
* Field names mirror the serde attributes of `ExtraCallerConfig` in
|
|
8
|
+
* `packages/@intlayer/swc/src/lib.rs` — both sides must stay in sync.
|
|
9
|
+
*/
|
|
10
|
+
type SwcExtraCallerConfig = {
|
|
11
|
+
/** The function name the user calls, e.g. `"useTranslation"`. */callerName: string; /** Module specifiers exporting the function (original + `@intlayer/*`). */
|
|
12
|
+
importSources: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Zero-based index of the positional argument holding the namespace string.
|
|
15
|
+
* Omitted for fixed/option namespace callers.
|
|
16
|
+
*/
|
|
17
|
+
namespaceArgIndex?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Compile-time constant namespace — the dictionary ident is inserted as a
|
|
20
|
+
* new first argument (lingui's `useLingui()`).
|
|
21
|
+
*/
|
|
22
|
+
fixedNamespace?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Namespace read from a property of an options-object argument — the
|
|
25
|
+
* dictionary ident is inserted as a new first argument and the property is
|
|
26
|
+
* rewritten to the key-prefix remainder (vue-i18n's `useI18n({ namespace })`).
|
|
27
|
+
*/
|
|
28
|
+
namespaceOption?: {
|
|
29
|
+
argumentIndex: number;
|
|
30
|
+
property: string;
|
|
31
|
+
}; /** Replacement function name for static import mode, e.g. `"useDictionary"`. */
|
|
32
|
+
staticReplacement: string; /** Replacement function name for dynamic/fetch mode, e.g. `"useDictionaryDynamic"`. */
|
|
33
|
+
dynamicReplacement: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Returns the callers of a registry slice that the optimize pass can rewrite
|
|
37
|
+
* at build time: plain imported functions carrying both replacement names.
|
|
38
|
+
*
|
|
39
|
+
* Method-matched callers (`i18n.getFixedT`) and JSX components are excluded —
|
|
40
|
+
* their call sites cannot be re-pointed through an import specifier rename.
|
|
41
|
+
*/
|
|
42
|
+
declare const getRewritableCallers: (descriptors: CallerDescriptor[]) => CallerDescriptor[];
|
|
43
|
+
/**
|
|
44
|
+
* Serialises the rewritable callers of a registry slice into the
|
|
45
|
+
* `@intlayer/swc` plugin wire format (`extraCallers` option).
|
|
46
|
+
*
|
|
47
|
+
* Callers whose namespace can only be derived per-message id
|
|
48
|
+
* (`path-first-segment`) are skipped: the transform cannot bind a single
|
|
49
|
+
* dictionary to the call site.
|
|
50
|
+
*
|
|
51
|
+
* @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.
|
|
52
|
+
* @returns Configs ready to pass as `swcExtraCallers` / `extraCallers`.
|
|
53
|
+
*/
|
|
54
|
+
declare const toSwcExtraCallers: (descriptors: CallerDescriptor[]) => SwcExtraCallerConfig[];
|
|
55
|
+
//#endregion
|
|
56
|
+
export { SwcExtraCallerConfig, getRewritableCallers, toSwcExtraCallers };
|
|
57
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","names":[],"sources":["../../../src/callers/transform.ts"],"mappings":";;;;;AAQA;;;;KAAY,oBAAA;EAIV,iEAFA,UAAA,UAYA;EAVA,aAAA;EAgBoB;;;;EAXpB,iBAAA;EAekB;AAUpB;;;EApBE,cAAA;EAqBa;;;;;EAfb,eAAA;IAAoB,aAAA;IAAuB,QAAA;EAAA,GA8C9B;EA5Cb,iBAAA,UA6CC;EA3CD,kBAAA;AAAA;;;;;;;;cAUW,oBAAA,GACX,WAAA,EAAa,gBAAA,OACZ,gBAAA;;;;;;;;;;;;cA6BU,iBAAA,GACX,WAAA,EAAa,gBAAA,OACZ,oBAAA"}
|