@intlayer/config 8.10.0 → 8.11.0-canary.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.
@@ -4,6 +4,7 @@ const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cj
4
4
  const require_loadExternalFile_bundleFile = require('./bundleFile.cjs');
5
5
  let node_fs = require("node:fs");
6
6
  let node_path = require("node:path");
7
+ let node_module = require("node:module");
7
8
  let esbuild = require("esbuild");
8
9
  let node_url = require("node:url");
9
10
 
@@ -39,7 +40,13 @@ const getTransformationOptions = (filePath) => ({
39
40
  const transpileTSToCJSSync = (code, filePath, options) => {
40
41
  const loader = require_loadExternalFile_bundleFile.getLoader((0, node_path.extname)(filePath));
41
42
  const { esbuildInstance, ...buildOptions } = options ?? {};
42
- return (esbuildInstance?.buildSync ?? esbuild.buildSync)({
43
+ const esbuildBuildSync = esbuildInstance?.buildSync ?? esbuild.buildSync;
44
+ if (typeof globalThis.__filename !== "string") try {
45
+ const esbuildEntry = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href).resolve("esbuild");
46
+ globalThis.__filename = esbuildEntry;
47
+ globalThis.__dirname = (0, node_path.dirname)(esbuildEntry);
48
+ } catch {}
49
+ return esbuildBuildSync({
43
50
  stdin: {
44
51
  contents: code,
45
52
  loader,
@@ -1 +1 @@
1
- {"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader","buildSync","context"],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\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 const moduleResult: BuildResult = 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\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":";;;;;;;;;;AAuBA,MAAM,mBAAmB,aAAyC;CAChE,MAAM,mCACJA,2EAA2B,QAAQ,CAAC,EAAE,SACtC,eACF;CAGA,+BAAkB,YAAY,IAAI,eAAe;AACnD;AAEA,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;CACV;CACA,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CACR,UAAU,gBAAgB,QAAQ;CAClC,QAAQ;EACN,mBAAmB,KAAK,sCAAwB,QAAQ,EAAE,IAAI;EAC9D,mBAAmB;CACrB;AACF;AAEA,MAAa,wBACX,MACA,UACA,YACuB;CAEvB,MAAM,SAASC,qEADW,QACO,CAAC;CAElC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,CAAC;CAgBzD,QAfyB,iBAAiB,aAAaC,mBAEJ;EACjD,OAAO;GACL,UAAU;GACV;GACA,mCAAoB,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAEsC,EAAE,cAAc,GAAG;AAG3D;AAEA,MAAa,mBAAmB,OAC9B,MACA,UACA,YACgC;CAEhC,MAAM,SAASD,qEADW,QACO,CAAC;CAElC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,CAAC;CAMzD,MAAM,MAAM,OAFW,iBAAiB,WAAWE,iBAElB;EAC/B,OAAO;GACL,UAAU;GACV;GACA,mCAAoB,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAAC;CAED,IAAI;EAEF,QAAO,MADoB,IAAI,QAAQ,GACnB,cAAc,GAAG;CACvC,UAAU;EACR,MAAM,IAAI,QAAQ;CACpB;AACF"}
1
+ {"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader","buildSync","context"],"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 if (typeof (globalThis as Record<string, unknown>).__filename !== 'string') {\n try {\n const _require = createRequire(import.meta.url);\n const esbuildEntry = _require.resolve('esbuild');\n (globalThis as Record<string, unknown>).__filename = esbuildEntry;\n (globalThis as Record<string, unknown>).__dirname = dirname(esbuildEntry);\n } catch {\n // Best-effort: if esbuild can't be resolved the caller's catch handles it\n }\n }\n\n const moduleResult: BuildResult = 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\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?.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GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAAC;CAED,IAAI;EAEF,QAAO,MADoB,IAAI,QAAQ,GACnB,cAAc,GAAG;CACvC,UAAU;EACR,MAAM,IAAI,QAAQ;CACpB;AACF"}
@@ -72,11 +72,14 @@ const colorizeObject = (obj, indentLevel = 0, indentSize = 2, key) => {
72
72
  if (typeof obj === "string") {
73
73
  const isDateString = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(obj);
74
74
  const isUrl = obj.startsWith("http://") || obj.startsWith("https://");
75
+ const isGlob = obj.includes("*") || obj.includes("?") || obj.includes("{");
75
76
  const isPath = obj.startsWith("/") || obj.startsWith("./") || obj.startsWith("../") || /\.[a-zA-Z0-9]{2,5}$/.test(obj);
76
77
  const isSecret = /^[0-9a-fA-F]{24,}$/.test(obj) || obj.length >= 40 && !/\s/.test(obj);
77
78
  const hasSpaces = /\s/.test(obj);
78
79
  if (isDateString) return colorize(`"${obj}"`, require_colors.BEIGE);
79
- if (isUrl || isPath) return colorize(`"${obj}"`, require_colors.GREY_DARK);
80
+ if (isUrl) return colorize(`"${obj}"`, require_colors.GREY_DARK);
81
+ if (isGlob) return colorize(`"${obj}"`, require_colors.GREY);
82
+ if (isPath) return colorize(`"${obj}"`, require_colors.GREY_DARK);
80
83
  if (isSecret) return colorize(`"${obj}"`, require_colors.GREY);
81
84
  if (hasSpaces) return colorize(`"${obj}"`, require_colors.WHITE);
82
85
  return colorize(`"${obj}"`, require_colors.BLUE);
@@ -1 +1 @@
1
- {"version":3,"file":"logger.cjs","names":["RESET","GREEN","BEIGE","GREY","BLUE","GREY_DARK","WHITE","GREY_LIGHT","RED"],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport {\n BEIGE,\n BLUE,\n GREEN,\n GREY,\n GREY_DARK,\n GREY_LIGHT,\n RED,\n RESET,\n WHITE,\n} from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: Pick<IntlayerConfig, 'log'>, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const colorizeObject = (\n obj: any,\n indentLevel = 0,\n indentSize = 2,\n key?: string\n): string => {\n const indent = ' '.repeat(indentLevel * indentSize);\n const nextIndent = ' '.repeat((indentLevel + 1) * indentSize);\n\n if (obj === null) {\n return colorize('null', BLUE);\n }\n\n if (typeof obj === 'boolean') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'number') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'string') {\n const isDateString = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/.test(obj);\n const isUrl = obj.startsWith('http://') || obj.startsWith('https://');\n const isPath =\n obj.startsWith('/') ||\n obj.startsWith('./') ||\n obj.startsWith('../') ||\n /\\.[a-zA-Z0-9]{2,5}$/.test(obj);\n const isSecret =\n /^[0-9a-fA-F]{24,}$/.test(obj) || (obj.length >= 40 && !/\\s/.test(obj));\n const hasSpaces = /\\s/.test(obj);\n\n if (isDateString) return colorize(`\"${obj}\"`, BEIGE);\n if (isUrl || isPath) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isSecret) return colorize(`\"${obj}\"`, GREY);\n if (hasSpaces) return colorize(`\"${obj}\"`, WHITE);\n return colorize(`\"${obj}\"`, BLUE);\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) {\n return '[]';\n }\n const items = obj\n .map(\n (item) =>\n `${nextIndent}${colorizeObject(item, indentLevel + 1, indentSize, key)}`\n )\n .join(',\\n');\n return `[\\n${items}\\n${indent}]`;\n }\n\n if (typeof obj === 'object') {\n const keys = Object.keys(obj);\n\n if (keys.length === 0) {\n return '{}';\n }\n\n const fields = keys\n .map((key) => {\n const coloredKey = colorize(`\"${key}\"`, GREY_LIGHT);\n const value = obj[key];\n const coloredValue = colorizeObject(\n value,\n indentLevel + 1,\n indentSize,\n key\n );\n return `${nextIndent}${coloredKey}: ${coloredValue}`;\n })\n .join(',\\n');\n return `{\\n${fields}\\n${indent}}`;\n }\n\n return colorize(String(obj), GREY);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;;AA6BA,IAAI;AAEJ,MAAa,aAAa,WAA+B;CACvD,eAAe;AACjB;AAEA,MAAa,aAAa,iBAA8C;CACtE,IAAI,OAAO,iBAAiB,aAC1B,OAAO;CAGT,OAAO;AACT;AAEA,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,SAAS,SAAS,UAAU,CAAC;CACnC,MAAM,OAAO,OAAO,QAAQ;CAE5B,IAAI,SAAS,cAAe,SAAS,aAAa,SAAS,WAAY;CAEvE,MAAM,SAAS,UAAU,OAAO,MAAM;CACtC,MAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK;CAC5E,MAAM,QAAQ,SAAS,SAAS;CAKhC,CAFE,OAAO,UAAU,QAAQ,UAAU,OAAO,OAAO,QAAQ,KAEjD,GAAG,WAAW;AAC1B;AAEA,MAAa,gBAAgB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;;;;;;AAO9E,MAAa,gBACV,eAA6C,mBAC7C,SAAc,YACb,OAAO,SAAS;CACd,GAAI,WAAW,CAAC;CAChB,QAAQ;EACN,GAAG,eAAe;EAClB,GAAG,eAAe;EAClB,GAAI,SAAS,UAAU,CAAC;CAC1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type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport {\n BEIGE,\n BLUE,\n GREEN,\n GREY,\n GREY_DARK,\n GREY_LIGHT,\n RED,\n RESET,\n WHITE,\n} from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: Pick<IntlayerConfig, 'log'>, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const colorizeObject = (\n obj: any,\n indentLevel = 0,\n indentSize = 2,\n key?: string\n): string => {\n const indent = ' '.repeat(indentLevel * indentSize);\n const nextIndent = ' '.repeat((indentLevel + 1) * indentSize);\n\n if (obj === null) {\n return colorize('null', BLUE);\n }\n\n if (typeof obj === 'boolean') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'number') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'string') {\n const isDateString = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/.test(obj);\n const isUrl = obj.startsWith('http://') || obj.startsWith('https://');\n const isGlob = obj.includes('*') || obj.includes('?') || obj.includes('{');\n const isPath =\n obj.startsWith('/') ||\n obj.startsWith('./') ||\n obj.startsWith('../') ||\n /\\.[a-zA-Z0-9]{2,5}$/.test(obj);\n const isSecret =\n /^[0-9a-fA-F]{24,}$/.test(obj) || (obj.length >= 40 && !/\\s/.test(obj));\n const hasSpaces = /\\s/.test(obj);\n\n if (isDateString) return colorize(`\"${obj}\"`, BEIGE);\n if (isUrl) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isGlob) return colorize(`\"${obj}\"`, GREY);\n if (isPath) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isSecret) return colorize(`\"${obj}\"`, GREY);\n if (hasSpaces) return colorize(`\"${obj}\"`, WHITE);\n return colorize(`\"${obj}\"`, BLUE);\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) {\n return '[]';\n }\n const items = obj\n .map(\n (item) =>\n `${nextIndent}${colorizeObject(item, indentLevel + 1, indentSize, key)}`\n )\n .join(',\\n');\n return `[\\n${items}\\n${indent}]`;\n }\n\n if (typeof obj === 'object') {\n const keys = Object.keys(obj);\n\n if (keys.length === 0) {\n return '{}';\n }\n\n const fields = keys\n .map((key) => {\n const coloredKey = colorize(`\"${key}\"`, GREY_LIGHT);\n const value = obj[key];\n const coloredValue = colorizeObject(\n value,\n indentLevel + 1,\n indentSize,\n key\n );\n return `${nextIndent}${coloredKey}: ${coloredValue}`;\n })\n .join(',\\n');\n return `{\\n${fields}\\n${indent}}`;\n }\n\n return colorize(String(obj), GREY);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;;AA6BA,IAAI;AAEJ,MAAa,aAAa,WAA+B;CACvD,eAAe;AACjB;AAEA,MAAa,aAAa,iBAA8C;CACtE,IAAI,OAAO,iBAAiB,aAC1B,OAAO;CAGT,OAAO;AACT;AAEA,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,SAAS,SAAS,UAAU,CAAC;CACnC,MAAM,OAAO,OAAO,QAAQ;CAE5B,IAAI,SAAS,cAAe,SAAS,aAAa,SAAS,WAAY;CAEvE,MAAM,SAAS,UAAU,OAAO,MAAM;CACtC,MAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK;CAC5E,MAAM,QAAQ,SAAS,SAAS;CAKhC,CAFE,OAAO,UAAU,QAAQ,UAAU,OAAO,OAAO,QAAQ,KAEjD,GAAG,WAAW;AAC1B;AAEA,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K,IACxB,SACA,KAAK,IAAI,SAAU,SAAS,YAAY,IAAI,EAAE,MAAM,CACtD;CAEA,IAAI,QAAQ,QACV,OAAO,GAAG,IAAI,OAAO,YAAY,IAAI;CAGvC,OAAO,GAAG,OAAO,IAAI,OAAO,YAAY;AAC1C,CAAC,EACA,KAAK,EAAE;AAEZ,MAAa,IAAI,SAAS,KAAKK,kBAAG;AAClC,MAAa,IAAI,SAAS,KAAKP,oBAAK;AACpC,MAAa,QAAQ,SAAS,KAAKG,mBAAI"}
@@ -1,7 +1,7 @@
1
1
  import { getAlias } from "../utils/alias.mjs";
2
2
  import { getConfiguration } from "../configFile/getConfiguration.mjs";
3
- import { BundleLogger } from "./logBundle.mjs";
4
3
  import { getConfigEnvVars } from "../envVars/envVars.mjs";
4
+ import { BundleLogger } from "./logBundle.mjs";
5
5
  import { isAbsolute, join, resolve } from "node:path";
6
6
  import { mkdir, rm, writeFile } from "node:fs/promises";
7
7
  import packageJSON from "@intlayer/types/package.json" with { type: "json" };
@@ -2,6 +2,7 @@ import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
2
2
  import { getLoader } from "./bundleFile.mjs";
3
3
  import { existsSync } from "node:fs";
4
4
  import { dirname, extname, join } from "node:path";
5
+ import { createRequire } from "node:module";
5
6
  import { buildSync, context } from "esbuild";
6
7
  import { pathToFileURL } from "node:url";
7
8
 
@@ -37,7 +38,13 @@ const getTransformationOptions = (filePath) => ({
37
38
  const transpileTSToCJSSync = (code, filePath, options) => {
38
39
  const loader = getLoader(extname(filePath));
39
40
  const { esbuildInstance, ...buildOptions } = options ?? {};
40
- return (esbuildInstance?.buildSync ?? buildSync)({
41
+ const esbuildBuildSync = esbuildInstance?.buildSync ?? buildSync;
42
+ if (typeof globalThis.__filename !== "string") try {
43
+ const esbuildEntry = createRequire(import.meta.url).resolve("esbuild");
44
+ globalThis.__filename = esbuildEntry;
45
+ globalThis.__dirname = dirname(esbuildEntry);
46
+ } catch {}
47
+ return esbuildBuildSync({
41
48
  stdin: {
42
49
  contents: code,
43
50
  loader,
@@ -1 +1 @@
1
- {"version":3,"file":"transpileTSToCJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\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 const moduleResult: BuildResult = 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\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":";;;;;;;;AAuBA,MAAM,mBAAmB,aAAyC;CAChE,MAAM,eAAe,KACnB,mBAAmB,QAAQ,QAAQ,CAAC,EAAE,SACtC,eACF;CAGA,OAAO,WAAW,YAAY,IAAI,eAAe;AACnD;AAEA,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;CACV;CACA,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CACR,UAAU,gBAAgB,QAAQ;CAClC,QAAQ;EACN,mBAAmB,KAAK,UAAU,cAAc,QAAQ,EAAE,IAAI;EAC9D,mBAAmB;CACrB;AACF;AAEA,MAAa,wBACX,MACA,UACA,YACuB;CAEvB,MAAM,SAAS,UADG,QAAQ,QACO,CAAC;CAElC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,CAAC;CAgBzD,QAfyB,iBAAiB,aAAa,WAEJ;EACjD,OAAO;GACL,UAAU;GACV;GACA,YAAY,QAAQ,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAEsC,EAAE,cAAc,GAAG;AAG3D;AAEA,MAAa,mBAAmB,OAC9B,MACA,UACA,YACgC;CAEhC,MAAM,SAAS,UADG,QAAQ,QACO,CAAC;CAElC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,CAAC;CAMzD,MAAM,MAAM,OAFW,iBAAiB,WAAW,SAElB;EAC/B,OAAO;GACL,UAAU;GACV;GACA,YAAY,QAAQ,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAAC;CAED,IAAI;EAEF,QAAO,MADoB,IAAI,QAAQ,GACnB,cAAc,GAAG;CACvC,UAAU;EACR,MAAM,IAAI,QAAQ;CACpB;AACF"}
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 if (typeof (globalThis as Record<string, unknown>).__filename !== 'string') {\n try {\n const _require = createRequire(import.meta.url);\n const esbuildEntry = _require.resolve('esbuild');\n (globalThis as Record<string, unknown>).__filename = esbuildEntry;\n (globalThis as Record<string, unknown>).__dirname = dirname(esbuildEntry);\n } catch {\n // Best-effort: if esbuild can't be resolved the caller's catch handles it\n }\n }\n\n const moduleResult: BuildResult = 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\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,QAAQ,CAAC,EAAE,SACtC,eACF;CAGA,OAAO,WAAW,YAAY,IAAI,eAAe;AACnD;AAEA,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;CACV;CACA,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CACR,UAAU,gBAAgB,QAAQ;CAClC,QAAQ;EACN,mBAAmB,KAAK,UAAU,cAAc,QAAQ,EAAE,IAAI;EAC9D,mBAAmB;CACrB;AACF;AAEA,MAAa,wBACX,MACA,UACA,YACuB;CAEvB,MAAM,SAAS,UADG,QAAQ,QACO,CAAC;CAElC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,CAAC;CACzD,MAAM,mBAAmB,iBAAiB,aAAa;CAQvD,IAAI,OAAQ,WAAuC,eAAe,UAChE,IAAI;EAEF,MAAM,eADW,cAAc,OAAO,KAAK,GACf,EAAE,QAAQ,SAAS;EAC/C,AAAC,WAAuC,aAAa;EACrD,AAAC,WAAuC,YAAY,QAAQ,YAAY;CAC1E,QAAQ,CAER;CAgBF,OAbkC,iBAAiB;EACjD,OAAO;GACL,UAAU;GACV;GACA,YAAY,QAAQ,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAEsC,EAAE,cAAc,GAAG;AAG3D;AAEA,MAAa,mBAAmB,OAC9B,MACA,UACA,YACgC;CAEhC,MAAM,SAAS,UADG,QAAQ,QACO,CAAC;CAElC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,CAAC;CAMzD,MAAM,MAAM,OAFW,iBAAiB,WAAW,SAElB;EAC/B,OAAO;GACL,UAAU;GACV;GACA,YAAY,QAAQ,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAAC;CAED,IAAI;EAEF,QAAO,MADoB,IAAI,QAAQ,GACnB,cAAc,GAAG;CACvC,UAAU;EACR,MAAM,IAAI,QAAQ;CACpB;AACF"}
@@ -71,11 +71,14 @@ const colorizeObject = (obj, indentLevel = 0, indentSize = 2, key) => {
71
71
  if (typeof obj === "string") {
72
72
  const isDateString = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(obj);
73
73
  const isUrl = obj.startsWith("http://") || obj.startsWith("https://");
74
+ const isGlob = obj.includes("*") || obj.includes("?") || obj.includes("{");
74
75
  const isPath = obj.startsWith("/") || obj.startsWith("./") || obj.startsWith("../") || /\.[a-zA-Z0-9]{2,5}$/.test(obj);
75
76
  const isSecret = /^[0-9a-fA-F]{24,}$/.test(obj) || obj.length >= 40 && !/\s/.test(obj);
76
77
  const hasSpaces = /\s/.test(obj);
77
78
  if (isDateString) return colorize(`"${obj}"`, BEIGE);
78
- if (isUrl || isPath) return colorize(`"${obj}"`, GREY_DARK);
79
+ if (isUrl) return colorize(`"${obj}"`, GREY_DARK);
80
+ if (isGlob) return colorize(`"${obj}"`, GREY);
81
+ if (isPath) return colorize(`"${obj}"`, GREY_DARK);
79
82
  if (isSecret) return colorize(`"${obj}"`, GREY);
80
83
  if (hasSpaces) return colorize(`"${obj}"`, WHITE);
81
84
  return colorize(`"${obj}"`, BLUE);
@@ -1 +1 @@
1
- {"version":3,"file":"logger.mjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport {\n BEIGE,\n BLUE,\n GREEN,\n GREY,\n GREY_DARK,\n GREY_LIGHT,\n RED,\n RESET,\n WHITE,\n} from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: Pick<IntlayerConfig, 'log'>, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const colorizeObject = (\n obj: any,\n indentLevel = 0,\n indentSize = 2,\n key?: string\n): string => {\n const indent = ' '.repeat(indentLevel * indentSize);\n const nextIndent = ' '.repeat((indentLevel + 1) * indentSize);\n\n if (obj === null) {\n return colorize('null', BLUE);\n }\n\n if (typeof obj === 'boolean') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'number') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'string') {\n const isDateString = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/.test(obj);\n const isUrl = obj.startsWith('http://') || obj.startsWith('https://');\n const isPath =\n obj.startsWith('/') ||\n obj.startsWith('./') ||\n obj.startsWith('../') ||\n /\\.[a-zA-Z0-9]{2,5}$/.test(obj);\n const isSecret =\n /^[0-9a-fA-F]{24,}$/.test(obj) || (obj.length >= 40 && !/\\s/.test(obj));\n const hasSpaces = /\\s/.test(obj);\n\n if (isDateString) return colorize(`\"${obj}\"`, BEIGE);\n if (isUrl || isPath) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isSecret) return colorize(`\"${obj}\"`, GREY);\n if (hasSpaces) return colorize(`\"${obj}\"`, WHITE);\n return colorize(`\"${obj}\"`, BLUE);\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) {\n return '[]';\n }\n const items = obj\n .map(\n (item) =>\n `${nextIndent}${colorizeObject(item, indentLevel + 1, indentSize, key)}`\n )\n .join(',\\n');\n return `[\\n${items}\\n${indent}]`;\n }\n\n if (typeof obj === 'object') {\n const keys = Object.keys(obj);\n\n if (keys.length === 0) {\n return '{}';\n }\n\n const fields = keys\n .map((key) => {\n const coloredKey = colorize(`\"${key}\"`, GREY_LIGHT);\n const value = obj[key];\n const coloredValue = colorizeObject(\n value,\n indentLevel + 1,\n indentSize,\n key\n );\n return `${nextIndent}${coloredKey}: ${coloredValue}`;\n })\n .join(',\\n');\n return `{\\n${fields}\\n${indent}}`;\n }\n\n return colorize(String(obj), GREY);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;AA6BA,IAAI;AAEJ,MAAa,aAAa,WAA+B;CACvD,eAAe;AACjB;AAEA,MAAa,aAAa,iBAA8C;CACtE,IAAI,OAAO,iBAAiB,aAC1B,OAAO;CAGT,OAAO;AACT;AAEA,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,SAAS,SAAS,UAAU,CAAC;CACnC,MAAM,OAAO,OAAO,QAAQ;CAE5B,IAAI,SAAS,cAAe,SAAS,aAAa,SAAS,WAAY;CAEvE,MAAM,SAAS,UAAU,OAAO,MAAM;CACtC,MAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK;C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,IAAI;CAGvC,OAAO,GAAG,OAAO,IAAI,OAAO,YAAY;AAC1C,CAAC,EACA,KAAK,EAAE;AAEZ,MAAa,IAAI,SAAS,KAAK,GAAG;AAClC,MAAa,IAAI,SAAS,KAAK,KAAK;AACpC,MAAa,QAAQ,SAAS,KAAK,IAAI"}
1
+ {"version":3,"file":"logger.mjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport {\n BEIGE,\n BLUE,\n GREEN,\n GREY,\n GREY_DARK,\n GREY_LIGHT,\n RED,\n RESET,\n WHITE,\n} from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: Pick<IntlayerConfig, 'log'>, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const colorizeObject = (\n obj: any,\n indentLevel = 0,\n indentSize = 2,\n key?: string\n): string => {\n const indent = ' '.repeat(indentLevel * indentSize);\n const nextIndent = ' '.repeat((indentLevel + 1) * indentSize);\n\n if (obj === null) {\n return colorize('null', BLUE);\n }\n\n if (typeof obj === 'boolean') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'number') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'string') {\n const isDateString = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/.test(obj);\n const isUrl = obj.startsWith('http://') || obj.startsWith('https://');\n const isGlob = obj.includes('*') || obj.includes('?') || obj.includes('{');\n const isPath =\n obj.startsWith('/') ||\n obj.startsWith('./') ||\n obj.startsWith('../') ||\n /\\.[a-zA-Z0-9]{2,5}$/.test(obj);\n const isSecret =\n /^[0-9a-fA-F]{24,}$/.test(obj) || (obj.length >= 40 && !/\\s/.test(obj));\n const hasSpaces = /\\s/.test(obj);\n\n if (isDateString) return colorize(`\"${obj}\"`, BEIGE);\n if (isUrl) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isGlob) return colorize(`\"${obj}\"`, GREY);\n if (isPath) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isSecret) return colorize(`\"${obj}\"`, GREY);\n if (hasSpaces) return colorize(`\"${obj}\"`, WHITE);\n return colorize(`\"${obj}\"`, BLUE);\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) {\n return '[]';\n }\n const items = obj\n .map(\n (item) =>\n `${nextIndent}${colorizeObject(item, indentLevel + 1, indentSize, key)}`\n )\n .join(',\\n');\n return `[\\n${items}\\n${indent}]`;\n }\n\n if (typeof obj === 'object') {\n const keys = Object.keys(obj);\n\n if (keys.length === 0) {\n return '{}';\n }\n\n const fields = keys\n .map((key) => {\n const coloredKey = colorize(`\"${key}\"`, GREY_LIGHT);\n const value = obj[key];\n const coloredValue = colorizeObject(\n value,\n indentLevel + 1,\n indentSize,\n key\n );\n return `${nextIndent}${coloredKey}: ${coloredValue}`;\n })\n .join(',\\n');\n return `{\\n${fields}\\n${indent}}`;\n }\n\n return colorize(String(obj), GREY);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;AA6BA,IAAI;AAEJ,MAAa,aAAa,WAA+B;CACvD,eAAe;AACjB;AAEA,MAAa,aAAa,iBAA8C;CACtE,IAAI,OAAO,iBAAiB,aAC1B,OAAO;CAGT,OAAO;AACT;AAEA,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,SAAS,SAAS,UAAU,CAAC;CACnC,MAAM,OAAO,OAAO,QAAQ;CAE5B,IAAI,SAAS,cAAe,SAAS,aAAa,SAAS,WAAY;CAEvE,MA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QA,MAAa,SACX,MACA,YAQA,CAAC,IAAI,EACF,KAAK,EACL,KAAK,SAAS;CACb,MAAM,EAAE,SAAS,SAAS,SAAS,QAAQ;EACzC,GAAG;EACH,GAAI,WAAW,CAAC;CAClB;CAEA,MAAM,SAAS,UAAU,OAAO;CAChC,MAAM,eAAe,KAAK,IACxB,SACA,KAAK,IAAI,SAAU,SAAS,YAAY,IAAI,EAAE,MAAM,CACtD;CAEA,IAAI,QAAQ,QACV,OAAO,GAAG,IAAI,OAAO,YAAY,IAAI;CAGvC,OAAO,GAAG,OAAO,IAAI,OAAO,YAAY;AAC1C,CAAC,EACA,KAAK,EAAE;AAEZ,MAAa,IAAI,SAAS,KAAK,GAAG;AAClC,MAAa,IAAI,SAAS,KAAK,KAAK;AACpC,MAAa,QAAQ,SAAS,KAAK,IAAI"}
@@ -20,9 +20,9 @@ declare const cookiesAttributesSchema: z.ZodObject<{
20
20
  secure: z.ZodOptional<z.ZodBoolean>;
21
21
  httpOnly: z.ZodOptional<z.ZodBoolean>;
22
22
  sameSite: z.ZodOptional<z.ZodEnum<{
23
- none: "none";
24
23
  strict: "strict";
25
24
  lax: "lax";
25
+ none: "none";
26
26
  }>>;
27
27
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
28
28
  }, z.core.$strip>;
@@ -47,9 +47,9 @@ declare const storageSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodEnum
47
47
  secure: z.ZodOptional<z.ZodBoolean>;
48
48
  httpOnly: z.ZodOptional<z.ZodBoolean>;
49
49
  sameSite: z.ZodOptional<z.ZodEnum<{
50
- none: "none";
51
50
  strict: "strict";
52
51
  lax: "lax";
52
+ none: "none";
53
53
  }>>;
54
54
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
55
55
  }, z.core.$strip>, z.ZodObject<{
@@ -72,9 +72,9 @@ declare const storageSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodEnum
72
72
  secure: z.ZodOptional<z.ZodBoolean>;
73
73
  httpOnly: z.ZodOptional<z.ZodBoolean>;
74
74
  sameSite: z.ZodOptional<z.ZodEnum<{
75
- none: "none";
76
75
  strict: "strict";
77
76
  lax: "lax";
77
+ none: "none";
78
78
  }>>;
79
79
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
80
80
  }, z.core.$strip>, z.ZodObject<{
@@ -155,9 +155,9 @@ declare const routingSchema: z.ZodObject<{
155
155
  secure: z.ZodOptional<z.ZodBoolean>;
156
156
  httpOnly: z.ZodOptional<z.ZodBoolean>;
157
157
  sameSite: z.ZodOptional<z.ZodEnum<{
158
- none: "none";
159
158
  strict: "strict";
160
159
  lax: "lax";
160
+ none: "none";
161
161
  }>>;
162
162
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
163
163
  }, z.core.$strip>, z.ZodObject<{
@@ -180,9 +180,9 @@ declare const routingSchema: z.ZodObject<{
180
180
  secure: z.ZodOptional<z.ZodBoolean>;
181
181
  httpOnly: z.ZodOptional<z.ZodBoolean>;
182
182
  sameSite: z.ZodOptional<z.ZodEnum<{
183
- none: "none";
184
183
  strict: "strict";
185
184
  lax: "lax";
185
+ none: "none";
186
186
  }>>;
187
187
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
188
188
  }, z.core.$strip>, z.ZodObject<{
@@ -350,9 +350,9 @@ declare const intlayerConfigSchema: z.ZodObject<{
350
350
  secure: z.ZodOptional<z.ZodBoolean>;
351
351
  httpOnly: z.ZodOptional<z.ZodBoolean>;
352
352
  sameSite: z.ZodOptional<z.ZodEnum<{
353
- none: "none";
354
353
  strict: "strict";
355
354
  lax: "lax";
355
+ none: "none";
356
356
  }>>;
357
357
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
358
358
  }, z.core.$strip>, z.ZodObject<{
@@ -375,9 +375,9 @@ declare const intlayerConfigSchema: z.ZodObject<{
375
375
  secure: z.ZodOptional<z.ZodBoolean>;
376
376
  httpOnly: z.ZodOptional<z.ZodBoolean>;
377
377
  sameSite: z.ZodOptional<z.ZodEnum<{
378
- none: "none";
379
378
  strict: "strict";
380
379
  lax: "lax";
380
+ none: "none";
381
381
  }>>;
382
382
  expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodNumber]>>;
383
383
  }, z.core.$strip>, z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"transpileTSToCJS.d.ts","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"mappings":";;;KAYY,gBAAA,GAAmB,YAAY;;AAA3C;;;;AAQiB;AAsCjB;EAtCE,eAAe;AAAA;AAAA,cAsCJ,oBAAA,GACX,IAAA,UACA,QAAA,UACA,OAAA,GAAU,gBAAgB;AAAA,cAwBf,gBAAA,GACX,IAAA,UACA,QAAA,UACA,OAAA,GAAU,gBAAA,KACT,OAAO"}
1
+ {"version":3,"file":"transpileTSToCJS.d.ts","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"mappings":";;;KAaY,gBAAA,GAAmB,YAAY;;AAA3C;;;;AAQiB;AAsCjB;EAtCE,eAAe;AAAA;AAAA,cAsCJ,oBAAA,GACX,IAAA,UACA,QAAA,UACA,OAAA,GAAU,gBAAgB;AAAA,cAyCf,gBAAA,GACX,IAAA,UACA,QAAA,UACA,OAAA,GAAU,gBAAA,KACT,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","names":[],"sources":["../../src/logger.ts"],"mappings":";;;;;KAkBY,cAAA,WACF,gBAAA,eAA8B,gBAAe;AAAA,KAE3C,OAAA;EACV,SAAA;EACA,KAAA;EACA,MAAA,GAAS,oBAAoB;AAAA;AAAA,KAGnB,MAAA,IAAU,OAAA,OAAc,OAAA,GAAU,OAAO;AAAA,cAIxC,SAAA,GAAa,MAA0B;AAAA,cAIvC,SAAA,GAAa,YAAqB;A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,YAAA,GACV,aAAA,GAAgB,IAAA,CAAK,cAAA,UAAwB,aAAA,GAAgB,OAAA,MAC7D,OAAA,OAAc,OAAA,GAAU,OAAA;AAAA,cAUd,QAAA,GACX,MAAA,UACA,KAAA,GAAQ,cAAA,EACR,KAAA,aAAkB,cAAc;AAAA,cAMrB,eAAA,GACX,OAAA,EAAS,MAAA,GAAS,MAAA,IAClB,KAAA,GAAO,cAAA,EACP,KAAA,aAAiB,cAAA;AAAA,cAON,WAAA,GACX,OAAA,qBACA,KAAA,GAAO,cAAA,EACP,KAAA,aAAiB,cAAsB;AAAA,cAO5B,YAAA,GACX,IAAA,qBACA,KAAA,GAAO,cAAA,EACP,KAAA,aAAiB,cAAsB;AAAA,cAO5B,cAAA,GACX,MAAA,mBACA,OAAA,GAAS,OAAA,CAAQ,MAAA,CAAO,IAAA,CAAK,cAAA,EAAgB,cAAA;AAAA,cAqBlC,cAAA,GACX,GAAA,OACA,WAAA,WACA,UAAA,WACA,GAAA;AAAA,cA8EW,WAAA,GAAe,IAAY;;AAnMa;AAIrD;;;;cAwOa,KAAA,GACX,IAAA,qBACA,OAAA;EACE,OAAA;EACA,OAAA;EACA,OAAA;EACA,GAAA;EACA,OAAA;AAAA;AAAA,cAyBS,CAAA;AAAA,cACA,CAAA;AAAA,cACA,KAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/config",
3
- "version": "8.10.0",
3
+ "version": "8.11.0-canary.0",
4
4
  "private": false,
5
5
  "description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
6
6
  "keywords": [
@@ -160,7 +160,7 @@
160
160
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
161
161
  },
162
162
  "dependencies": {
163
- "@intlayer/types": "8.10.0",
163
+ "@intlayer/types": "8.11.0-canary.0",
164
164
  "defu": "6.1.7",
165
165
  "dotenv": "17.4.2",
166
166
  "esbuild": "0.28.0",
@@ -175,7 +175,7 @@
175
175
  "rimraf": "6.1.3",
176
176
  "tsdown": "0.22.00",
177
177
  "typescript": "6.0.3",
178
- "vitest": "4.1.6"
178
+ "vitest": "4.1.7"
179
179
  },
180
180
  "peerDependencies": {
181
181
  "react": ">=16.0.0"