@intlayer/config 7.6.0-canary.0 → 8.0.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.
- package/dist/cjs/alias.cjs +2 -1
- package/dist/cjs/alias.cjs.map +1 -1
- package/dist/cjs/client.cjs +2 -0
- package/dist/cjs/configFile/buildConfigurationFields.cjs +58 -32
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/defaultValues/content.cjs +3 -33
- package/dist/cjs/defaultValues/content.cjs.map +1 -1
- package/dist/cjs/defaultValues/index.cjs +9 -1
- package/dist/cjs/defaultValues/index.cjs.map +1 -1
- package/dist/cjs/defaultValues/system.cjs +47 -0
- package/dist/cjs/defaultValues/system.cjs.map +1 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/logger.cjs +11 -1
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/cjs/utils/cacheDisk.cjs +1 -1
- package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
- package/dist/esm/alias.mjs +2 -1
- package/dist/esm/alias.mjs.map +1 -1
- package/dist/esm/client.mjs +2 -2
- package/dist/esm/configFile/buildConfigurationFields.mjs +52 -26
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/defaultValues/content.mjs +3 -23
- package/dist/esm/defaultValues/content.mjs.map +1 -1
- package/dist/esm/defaultValues/index.mjs +4 -2
- package/dist/esm/defaultValues/index.mjs.map +1 -1
- package/dist/esm/defaultValues/system.mjs +31 -0
- package/dist/esm/defaultValues/system.mjs.map +1 -0
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/logger.mjs +10 -2
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/esm/utils/cacheDisk.mjs +1 -1
- package/dist/esm/utils/cacheDisk.mjs.map +1 -1
- package/dist/types/alias.d.ts.map +1 -1
- package/dist/types/client.d.ts +2 -2
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/defaultValues/content.d.ts +3 -13
- package/dist/types/defaultValues/content.d.ts.map +1 -1
- package/dist/types/defaultValues/index.d.ts +3 -2
- package/dist/types/defaultValues/system.d.ts +17 -0
- package/dist/types/defaultValues/system.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -1
- package/dist/types/logger.d.ts +3 -1
- package/dist/types/logger.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/esm/logger.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.mjs","names":["color","text"],"sources":["../../src/logger.ts"],"sourcesContent":["import type { CustomIntlayerConfig, Locale } from '@intlayer/types';\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\nexport const logger: Logger = (content, details) => {\n const isVerbose = details?.isVerbose ?? false;\n const mode = details?.config?.mode ?? 'default';\n const level = details?.level ?? 'info';\n const prefix = details?.config?.prefix
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":["color","text"],"sources":["../../src/logger.ts"],"sourcesContent":["import type { CustomIntlayerConfig, Locale } from '@intlayer/types';\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 isVerbose = details?.isVerbose ?? false;\n const mode = details?.config?.mode ?? 'default';\n const level = details?.level ?? 'info';\n const prefix = getPrefix(details?.config?.prefix);\n const log = details?.config?.log ?? console.log;\n const info = details?.config?.info ?? console.info;\n const warn = details?.config?.warn ?? console.warn;\n const error = details?.config?.error ?? console.error;\n const debug = details?.config?.debug ?? console.debug;\n\n if (mode === 'disabled') return;\n\n if (isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (level === 'debug') {\n return debug(...flatContent);\n }\n\n if (level === 'info') {\n return info(...flatContent);\n }\n\n if (level === 'warn') {\n return warn(...flatContent);\n }\n\n if (level === 'error') {\n return error(...flatContent);\n }\n\n log(...flatContent);\n};\n\nexport enum ANSIColors {\n RESET = '\\x1b[0m',\n GREY = '\\x1b[90m',\n GREY_DARK = '\\x1b[38;5;239m',\n GREY_LIGHT = '\\x1b[38;5;252m',\n BLUE = '\\x1b[34m',\n RED = '\\x1b[31m',\n GREEN = '\\x1b[32m',\n YELLOW = '\\x1b[38;5;226m',\n MAGENTA = '\\x1b[35m',\n BEIGE = '\\x1b[38;5;3m',\n ORANGE = '\\x1b[38;5;208m',\n CYAN = '\\x1b[36m',\n WHITE = '\\x1b[37m',\n BOLD = '\\x1b[1m',\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?: CustomIntlayerConfig, 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 s: string,\n color?: ANSIColors,\n reset?: boolean | ANSIColors\n): string =>\n color\n ? `${color}${s}${reset ? (typeof reset === 'boolean' ? ANSIColors.RESET : reset) : ANSIColors.RESET}`\n : s;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color = ANSIColors.GREEN,\n reset: boolean | ANSIColors = ANSIColors.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 = ANSIColors.BEIGE,\n reset: boolean | ANSIColors = ANSIColors.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 = ANSIColors.GREY,\n reset: boolean | ANSIColors = ANSIColors.RESET\n) =>\n [path]\n .flat()\n .map((p) => colorize(p, color, reset))\n .join(`, `);\n\n/**\n * Colorize numeric value using Intl.NumberFormat and optional ANSI colors.\n *\n * Examples:\n * colorizeNumber(2, [{ pluralRule: 'one' , color: ANSIColors.GREEN}, { pluralRule: 'other' , color: ANSIColors.RED}]) // \"'\\x1b[31m2\\x1b[0m\"\n */\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColors>> = {\n zero: ANSIColors.BLUE,\n one: ANSIColors.BLUE,\n two: ANSIColors.BLUE,\n few: ANSIColors.BLUE,\n many: ANSIColors.BLUE,\n other: ANSIColors.BLUE,\n }\n): string => {\n if (number === 0) {\n const color = options.zero ?? ANSIColors.GREEN;\n return colorize(number.toString(), color);\n }\n\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 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 (Array.isArray(length) && length.every((l) => typeof l === 'string')) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'number')) {\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, padChar } = {\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('✗', ANSIColors.RED);\nexport const v = colorize('✓', ANSIColors.GREEN);\nexport const clock = colorize('⏲', ANSIColors.BLUE);\n"],"mappings":";AAUA,IAAI;AAEJ,MAAa,aAAa,WAA+B;AACvD,gBAAe;;AAGjB,MAAa,aAAa,iBAA8C;AACtE,KAAI,OAAO,iBAAiB,YAC1B,QAAO;AAGT,QAAO;;AAGT,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,YAAY,SAAS,aAAa;CACxC,MAAM,OAAO,SAAS,QAAQ,QAAQ;CACtC,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,SAAS,UAAU,SAAS,QAAQ,OAAO;CACjD,MAAM,MAAM,SAAS,QAAQ,OAAO,QAAQ;CAC5C,MAAM,OAAO,SAAS,QAAQ,QAAQ,QAAQ;CAC9C,MAAM,OAAO,SAAS,QAAQ,QAAQ,QAAQ;CAC9C,MAAM,QAAQ,SAAS,QAAQ,SAAS,QAAQ;CAChD,MAAM,QAAQ,SAAS,QAAQ,SAAS,QAAQ;AAEhD,KAAI,SAAS,WAAY;AAEzB,KAAI,aAAa,SAAS,UAAW;CAErC,MAAM,cAAc,SAAS,CAAC,QAAQ,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Q,OACV,QAAO,GAAG,IAAI,OAAO,aAAa,GAAGA;AAGvC,QAAO,GAAGA,SAAO,IAAI,OAAO,aAAa;EACzC,CACD,KAAK,GAAG;AAEb,MAAa,IAAI,SAAS,KAAK,WAAW,IAAI;AAC9C,MAAa,IAAI,SAAS,KAAK,WAAW,MAAM;AAChD,MAAa,QAAQ,SAAS,KAAK,WAAW,KAAK"}
|
|
@@ -21,7 +21,7 @@ const cachePath = (cacheDir, id, ns) => join(cacheDir, ns ? join(ns, id) : id);
|
|
|
21
21
|
/** ------------------------- Local cache facade ------------------------- **/
|
|
22
22
|
const cacheMap = /* @__PURE__ */ new Map();
|
|
23
23
|
const cacheDisk = (intlayerConfig, keys, options) => {
|
|
24
|
-
const { cacheDir } = intlayerConfig.
|
|
24
|
+
const { cacheDir } = intlayerConfig.system;
|
|
25
25
|
const buildCacheEnabled = intlayerConfig.build.cache ?? true;
|
|
26
26
|
const persistent = options?.persistent === true || typeof options?.persistent === "undefined" && buildCacheEnabled;
|
|
27
27
|
const { compress, ttlMs, maxTimeMs, namespace } = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheDisk.mjs","names":["configPackageJson"],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (file: string, data: Buffer) => {\n const tmp = `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n await writeFile(tmp, data);\n await rename(tmp, file);\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir } = intlayerConfig.content;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,OAAM,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;;AAGvC,MAAM,kBAAkB,OAAO,MAAc,SAAiB;CAC5D,MAAM,MAAM,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;AAC7E,OAAM,UAAU,KAAK,KAAK;AAC1B,OAAM,OAAO,KAAK,KAAK;;AAGzB,MAAM,wBAAwB,KAAa,UACzC,UAAU,QAAS,UAAU,SAAS,IAAI,aAAa;;AAGzD,MAAM,aAAa,UAAkB,IAAY,OAC/C,KAAK,UAAU,KAAK,KAAK,IAAI,GAAG,GAAG,GAAG;;AAIxC,MAAM,2BAAW,IAAI,KAAkB;AAEvC,MAAa,aACX,gBACA,MACA,YACG;CACH,MAAM,EAAE,aAAa,eAAe;CACpC,MAAM,oBAAoB,eAAe,MAAM,SAAS;CACxD,MAAM,aACJ,SAAS,eAAe,QACvB,OAAO,SAAS,eAAe,eAAe;CAEjD,MAAM,EAAE,UAAU,OAAO,WAAW,cAAc;EAChD,GAAG;EACH,GAAG;EACJ;CAGD,MAAM,KAAK,aAAa,KAAK;CAC7B,MAAM,WAAW,UAAU,UAAU,IAAI,UAAU;CAEnD,MAAM,eAAe,YAA0C;AAC7D,MAAI;GACF,MAAM,YAAY,MAAM,KAAK,SAAS,CAAC,YAAY,OAAU;AAE7D,OAAI,CAAC,UAAW,QAAO;AAEvB,OAAI,OAAO,UAAU,YAAY,QAAQ,GAEvC;QADY,KAAK,KAAK,GAAG,UAAU,UACzB,MAAO,QAAO;;G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,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;EAIX;EAEA;EACD"}
|
|
1
|
+
{"version":3,"file":"cacheDisk.mjs","names":["configPackageJson"],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (file: string, data: Buffer) => {\n const tmp = `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n await writeFile(tmp, data);\n await rename(tmp, file);\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,OAAM,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;;AAGvC,MAAM,kBAAkB,OAAO,MAAc,SAAiB;CAC5D,MAAM,MAAM,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;AAC7E,OAAM,UAAU,KAAK,KAAK;AAC1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ACF,WAAM,MAAM,MAAM,EAAE,WAAW,MAAM,CAAC;YAChC;;;EAIZ,SAAS,YAA8B;AAErC,OADoB,SAAS,IAAI,GAAG,KAChB,OAAW,QAAO;AAGtC,OAAI,CAAC,cAAc,CAAC,kBAAmB,QAAO;AAE9C,OAAI;IACF,MAAM,YAAY,MAAM,KAAK,SAAS,CAAC,YAAY,OAAU;AAC7D,QAAI,CAAC,UAAW,QAAO;AAEvB,QAAI,OAAO,UAAU,YAAY,QAAQ,GAEvC;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,MAAO,QAAO;;IAG1B,IAAI,MAAM,MAAM,SAAS,SAAS;IAClC,MAAM,OAAO,IAAI;AACjB,UAAM,IAAI,SAAS,EAAE;IAIrB,MAAM,WAFe,YADL,SAAS,IAAO,WAAW,IAAI,GAAG,IACT;AAUzC,QANE,CAAC,CAAC,YACF,OAAO,aAAa,YACpB,OAAO,SAAS,YAAY,YAC5B,OAAO,SAAS,cAAc,YAC9B,OAAO,OAAO,UAAU,OAAO,EAEjB;KACd,MAAM,QAAQ;AACd,SAAI,MAAM,YAAYA,YAAkB,QAAS,QAAO;AAExD,SAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;UADY,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;EAIX;EAEA;EACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias.d.ts","names":[],"sources":["../../src/alias.ts"],"sourcesContent":[],"mappings":";;;KAKY,eAAA;iBACK;EADL,MAAA,CAAA,EAAA,KAAA,GAAA,KAAe;EAMd,SAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"alias.d.ts","names":[],"sources":["../../src/alias.ts"],"sourcesContent":[],"mappings":";;;KAKY,eAAA;iBACK;EADL,MAAA,CAAA,EAAA,KAAA,GAAA,KAAe;EAMd,SAAA,CAAA,EAgGZ,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,MAAA;CAhGwB;AAAA,cAAZ,QAAY,EAAA,CAAA;EAAA,aAAA;EAAA,MAAA;EAAA;AAAA,CAAA,EAItB,eAJsB,EAAA,GAAA;EAAA,SAAA,8BAAA,EAAA,MAAA;EAItB,SAAA,uCAAA,EAAA,MAAA;EAAe,SAAA,qCAAA,EAAA,MAAA"}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { index_d_exports } from "./defaultValues/index.js";
|
|
2
|
-
import { ANSIColors, Details, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logger, removeColor, spinnerFrames, v, x } from "./logger.js";
|
|
2
|
+
import { ANSIColors, Details, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, getPrefix, logger, removeColor, setPrefix, spinnerFrames, v, x } from "./logger.js";
|
|
3
3
|
import { extractErrorMessage } from "./utils/extractErrorMessage.js";
|
|
4
4
|
import { logStack } from "./utils/logStack.js";
|
|
5
5
|
import { normalizePath } from "./utils/normalizePath.js";
|
|
@@ -7,4 +7,4 @@ import { camelCaseToKebabCase } from "./utils/stringFormatter/camelCaseToKebabCa
|
|
|
7
7
|
import { camelCaseToSentence } from "./utils/stringFormatter/camelCaseToSentence.js";
|
|
8
8
|
import { kebabCaseToCamelCase } from "./utils/stringFormatter/kebabCaseToCamelCase.js";
|
|
9
9
|
import { toLowerCamelCase } from "./utils/stringFormatter/toLowerCamelCase.js";
|
|
10
|
-
export { ANSIColors, index_d_exports as DefaultValues, Details, Logger, camelCaseToKebabCase, camelCaseToSentence, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, extractErrorMessage, getAppLogger, kebabCaseToCamelCase, logStack, logger, normalizePath, removeColor, spinnerFrames, toLowerCamelCase, v, x };
|
|
10
|
+
export { ANSIColors, index_d_exports as DefaultValues, Details, Logger, camelCaseToKebabCase, camelCaseToSentence, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, extractErrorMessage, getAppLogger, getPrefix, kebabCaseToCamelCase, logStack, logger, normalizePath, removeColor, setPrefix, spinnerFrames, toLowerCamelCase, v, x };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":[],"mappings":";;;;;;AA6rBA;AACwB,cADX,wBACW,EAAA,CAAA,mBAAA,CAAA,EAAA,oBAAA,EAAA,OAAA,CAAA,EAAA,MAAA,EAAA,YAAA,CAAA,EAEP,YAFO,EAAA,GAGrB,cAHqB"}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
declare namespace content_d_exports {
|
|
2
|
-
export {
|
|
2
|
+
export { CODE_DIR, CONTENT_DIR, EXCLUDED_PATHS, FILE_EXTENSIONS, I18NEXT_DICTIONARIES_DIR, REACT_INTL_MESSAGES_DIR, WATCH };
|
|
3
3
|
}
|
|
4
4
|
declare const FILE_EXTENSIONS: string[];
|
|
5
5
|
declare const EXCLUDED_PATHS: string[];
|
|
6
6
|
declare const CONTENT_DIR: string[];
|
|
7
|
-
declare const
|
|
8
|
-
declare const DICTIONARIES_DIR = ".intlayer/dictionary";
|
|
9
|
-
declare const MASKS_DIR = ".intlayer/mask";
|
|
10
|
-
declare const REMOTE_DICTIONARIES_DIR = ".intlayer/remote_dictionary";
|
|
11
|
-
declare const UNMERGED_DICTIONARIES_DIR = ".intlayer/unmerged_dictionary";
|
|
12
|
-
declare const DYNAMIC_DICTIONARIES_DIR = ".intlayer/dynamic_dictionary";
|
|
13
|
-
declare const FETCH_DICTIONARIES_DIR = ".intlayer/fetch_dictionary";
|
|
14
|
-
declare const TYPES_DIR = ".intlayer/types";
|
|
15
|
-
declare const MODULE_AUGMENTATION_DIR = ".intlayer/types";
|
|
7
|
+
declare const CODE_DIR: string[];
|
|
16
8
|
declare const I18NEXT_DICTIONARIES_DIR = "i18next_resources";
|
|
17
9
|
declare const REACT_INTL_MESSAGES_DIR = "intl_messages";
|
|
18
|
-
declare const CONFIG_DIR = ".intlayer/config";
|
|
19
|
-
declare const CACHE_DIR = ".intlayer/cache";
|
|
20
10
|
declare const WATCH: boolean;
|
|
21
11
|
//#endregion
|
|
22
|
-
export {
|
|
12
|
+
export { CODE_DIR, CONTENT_DIR, EXCLUDED_PATHS, FILE_EXTENSIONS, I18NEXT_DICTIONARIES_DIR, REACT_INTL_MESSAGES_DIR, WATCH, content_d_exports };
|
|
23
13
|
//# sourceMappingURL=content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","names":[],"sources":["../../../src/defaultValues/content.ts"],"sourcesContent":[],"mappings":";;;cAAa;cAaA;cAaA;cAEA
|
|
1
|
+
{"version":3,"file":"content.d.ts","names":[],"sources":["../../../src/defaultValues/content.ts"],"sourcesContent":[],"mappings":";;;cAAa;cAaA;cAaA;cAEA;cAEA,wBAAA;cAEA,uBAAA;cAEA"}
|
|
@@ -4,11 +4,12 @@ import { editor_d_exports } from "./editor.js";
|
|
|
4
4
|
import { internationalization_d_exports } from "./internationalization.js";
|
|
5
5
|
import { log_d_exports } from "./log.js";
|
|
6
6
|
import { routing_d_exports } from "./routing.js";
|
|
7
|
+
import { system_d_exports } from "./system.js";
|
|
7
8
|
|
|
8
9
|
//#region src/defaultValues/index.d.ts
|
|
9
10
|
declare namespace index_d_exports {
|
|
10
|
-
export { build_d_exports as Build, content_d_exports as Content, editor_d_exports as Editor, internationalization_d_exports as Internationalization, log_d_exports as Log, routing_d_exports as Routing };
|
|
11
|
+
export { build_d_exports as Build, content_d_exports as Content, editor_d_exports as Editor, internationalization_d_exports as Internationalization, log_d_exports as Log, routing_d_exports as Routing, system_d_exports as System };
|
|
11
12
|
}
|
|
12
13
|
//#endregion
|
|
13
|
-
export { build_d_exports as Build, content_d_exports as Content, editor_d_exports as Editor, internationalization_d_exports as Internationalization, log_d_exports as Log, routing_d_exports as Routing, index_d_exports };
|
|
14
|
+
export { build_d_exports as Build, content_d_exports as Content, editor_d_exports as Editor, internationalization_d_exports as Internationalization, log_d_exports as Log, routing_d_exports as Routing, system_d_exports as System, index_d_exports };
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare namespace system_d_exports {
|
|
2
|
+
export { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR };
|
|
3
|
+
}
|
|
4
|
+
declare const MAIN_DIR = ".intlayer/main";
|
|
5
|
+
declare const DICTIONARIES_DIR = ".intlayer/dictionary";
|
|
6
|
+
declare const MASKS_DIR = ".intlayer/mask";
|
|
7
|
+
declare const REMOTE_DICTIONARIES_DIR = ".intlayer/remote_dictionary";
|
|
8
|
+
declare const UNMERGED_DICTIONARIES_DIR = ".intlayer/unmerged_dictionary";
|
|
9
|
+
declare const DYNAMIC_DICTIONARIES_DIR = ".intlayer/dynamic_dictionary";
|
|
10
|
+
declare const FETCH_DICTIONARIES_DIR = ".intlayer/fetch_dictionary";
|
|
11
|
+
declare const TYPES_DIR = ".intlayer/types";
|
|
12
|
+
declare const MODULE_AUGMENTATION_DIR = ".intlayer/types";
|
|
13
|
+
declare const CONFIG_DIR = ".intlayer/config";
|
|
14
|
+
declare const CACHE_DIR = ".intlayer/cache";
|
|
15
|
+
//#endregion
|
|
16
|
+
export { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR, system_d_exports };
|
|
17
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":[],"mappings":";;;cAAa,QAAA;cAEA,gBAAA;cAEA,SAAA;cAEA,uBAAA;cAEA,yBAAA;cAEA,wBAAA;cAEA,sBAAA;cAEA,SAAA;cAEA,uBAAA;cAEA,UAAA;cAEA,SAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAlias } from "./alias.js";
|
|
2
2
|
import { bundleJSFile } from "./bundleJSFile.js";
|
|
3
3
|
import { index_d_exports } from "./defaultValues/index.js";
|
|
4
|
-
import { ANSIColors, Details, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logger, removeColor, spinnerFrames, v, x } from "./logger.js";
|
|
4
|
+
import { ANSIColors, Details, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, getPrefix, logger, removeColor, setPrefix, spinnerFrames, v, x } from "./logger.js";
|
|
5
5
|
import { extractErrorMessage } from "./utils/extractErrorMessage.js";
|
|
6
6
|
import { logStack } from "./utils/logStack.js";
|
|
7
7
|
import { normalizePath } from "./utils/normalizePath.js";
|
|
@@ -24,4 +24,4 @@ import { compareVersions } from "./utils/compareVersions.js";
|
|
|
24
24
|
import { configESMxCJSRequire, getProjectRequire, isESModule } from "./utils/ESMxCJSHelpers.js";
|
|
25
25
|
import { getExtension } from "./utils/getExtension.js";
|
|
26
26
|
import { getPackageJsonPath } from "./utils/getPackageJsonPath.js";
|
|
27
|
-
export { ANSIColors, index_d_exports as DefaultValues, Details, type ESBuildPlugin, type GetConfigurationAndFilePathResult, type GetConfigurationOptions, Logger, buildConfigurationFields, bundleFile, bundleFileSync, bundleJSFile, cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearModuleCache, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, compareVersions, configESMxCJSRequire, configurationFilesCandidates, extractErrorMessage, getAlias, getAppLogger, getConfiguration, getConfigurationAndFilePath, getEnvFilePath, getExtension, getPackageJsonPath, getProjectRequire, isESModule, kebabCaseToCamelCase, loadEnvFile, loadExternalFile, loadExternalFileSync, logStack, logger, normalizePath, parseFileContent, removeColor, retryManager, searchConfigurationFile, spinnerFrames, toLowerCamelCase, v, x };
|
|
27
|
+
export { ANSIColors, index_d_exports as DefaultValues, Details, type ESBuildPlugin, type GetConfigurationAndFilePathResult, type GetConfigurationOptions, Logger, buildConfigurationFields, bundleFile, bundleFileSync, bundleJSFile, cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearModuleCache, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, compareVersions, configESMxCJSRequire, configurationFilesCandidates, extractErrorMessage, getAlias, getAppLogger, getConfiguration, getConfigurationAndFilePath, getEnvFilePath, getExtension, getPackageJsonPath, getPrefix, getProjectRequire, isESModule, kebabCaseToCamelCase, loadEnvFile, loadExternalFile, loadExternalFileSync, logStack, logger, normalizePath, parseFileContent, removeColor, retryManager, searchConfigurationFile, setPrefix, spinnerFrames, toLowerCamelCase, v, x };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpileTSToCJS.d.ts","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":[],"mappings":";;;KAaY,aAAA,GAAgB;cAoCf,iEAGD;AAvCA,cA4DC,gBA5De,
|
|
1
|
+
{"version":3,"file":"transpileTSToCJS.d.ts","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":[],"mappings":";;;KAaY,aAAA,GAAgB;cAoCf,iEAGD;AAvCA,cA4DC,gBA5De,EAAA,CAAM,IAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EA+DtB,YA/DsB,EAAA,GAgE/B,OAhE+B,CAAA,MAAA,GAAA,SAAA,CAAA"}
|
package/dist/types/logger.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ type Details = {
|
|
|
7
7
|
config?: CustomIntlayerConfig['log'];
|
|
8
8
|
};
|
|
9
9
|
type Logger = (content: any, details?: Details) => void;
|
|
10
|
+
declare const setPrefix: (prefix: string | undefined) => void;
|
|
11
|
+
declare const getPrefix: (configPrefix?: string) => string | undefined;
|
|
10
12
|
declare const logger: Logger;
|
|
11
13
|
declare enum ANSIColors {
|
|
12
14
|
RESET = "\u001B[0m",
|
|
@@ -60,5 +62,5 @@ declare const x: string;
|
|
|
60
62
|
declare const v: string;
|
|
61
63
|
declare const clock: string;
|
|
62
64
|
//#endregion
|
|
63
|
-
export { ANSIColors, Details, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logger, removeColor, spinnerFrames, v, x };
|
|
65
|
+
export { ANSIColors, Details, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, getPrefix, logger, removeColor, setPrefix, spinnerFrames, v, x };
|
|
64
66
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","names":[],"sources":["../../src/logger.ts"],"sourcesContent":[],"mappings":";;;KAEY,OAAA;;EAAA,KAAA,CAAA,EAAA,MAAO,GAAA,MAGR,GAAA,OAAA,GAAA,OAAoB;EAGnB,MAAA,CAAA,EAHD,oBAG0C,CAAA,KAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","names":[],"sources":["../../src/logger.ts"],"sourcesContent":[],"mappings":";;;KAEY,OAAA;;EAAA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AA,OAAA,EA7HxC,MA6HwC,GA7H/B,MA6H+B,EAAA,EAAA,KAAA,CAAA,EA5HjD,UA4HiD,EAAA,KAAA,CAAA,EAAA,OAAA,GA3HhC,UA2HgC,EAAA,GAAA,MAAA;cApHtC,kDAEX,8BACiB;cAON,gDAEX,8BACiB;;;;;;;cAaN,oDAEF,QAAQ,OAAO,IAAA,CAAK,gBAAgB;cAmBlC;;;;;;;cAmCA;;;;;;;cAgCA;cACA;cACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.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": [
|
|
@@ -96,14 +96,14 @@
|
|
|
96
96
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@intlayer/types": "
|
|
99
|
+
"@intlayer/types": "8.0.0-canary.0",
|
|
100
100
|
"defu": "6.1.4",
|
|
101
101
|
"dotenv": "16.6.1",
|
|
102
102
|
"esbuild": "0.27.2",
|
|
103
103
|
"json5": "^2.2.3"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
|
-
"@types/node": "25.0.
|
|
106
|
+
"@types/node": "25.0.9",
|
|
107
107
|
"@utils/ts-config": "1.0.4",
|
|
108
108
|
"@utils/ts-config-types": "1.0.4",
|
|
109
109
|
"@utils/tsdown-config": "1.0.4",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"vitest": "4.0.17"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
|
-
"intlayer": "
|
|
116
|
+
"intlayer": "8.0.0-canary.0",
|
|
117
117
|
"react": ">=16.0.0"
|
|
118
118
|
},
|
|
119
119
|
"peerDependenciesMeta": {
|