@intlayer/config 8.2.3 → 8.3.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/built.cjs.map +1 -1
- package/dist/cjs/configFile/buildConfigurationFields.cjs +1 -1
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/configurationSchema.cjs +2 -0
- package/dist/cjs/configFile/configurationSchema.cjs.map +1 -0
- package/dist/cjs/configFile/getConfiguration.cjs +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/index.cjs +1 -1
- package/dist/cjs/configFile/loadConfigurationFile.cjs +1 -1
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs +1 -1
- package/dist/cjs/defaultValues/compiler.cjs +1 -1
- package/dist/cjs/defaultValues/compiler.cjs.map +1 -1
- package/dist/cjs/defaultValues/dictionary.cjs.map +1 -1
- package/dist/cjs/defaultValues/editor.cjs +1 -1
- package/dist/cjs/defaultValues/editor.cjs.map +1 -1
- package/dist/cjs/defaultValues/index.cjs +1 -1
- package/dist/cjs/defaultValues/index.cjs.map +1 -1
- package/dist/cjs/defaultValues/internationalization.cjs +1 -1
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/routing.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/logger.cjs +1 -1
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/cjs/node.cjs +1 -1
- package/dist/cjs/utils/alias.cjs +1 -1
- package/dist/cjs/utils/alias.cjs.map +1 -1
- package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
- package/dist/cjs/utils/getExtension.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/utils/parseFilePathPattern.cjs +2 -0
- package/dist/cjs/utils/parseFilePathPattern.cjs.map +1 -0
- package/dist/esm/built.mjs.map +1 -1
- package/dist/esm/configFile/buildConfigurationFields.mjs +1 -1
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/configurationSchema.mjs +2 -0
- package/dist/esm/configFile/configurationSchema.mjs.map +1 -0
- package/dist/esm/configFile/getConfiguration.mjs +1 -1
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/index.mjs +1 -1
- package/dist/esm/configFile/loadConfigurationFile.mjs +1 -1
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/configFile/searchConfigurationFile.mjs +1 -1
- package/dist/esm/defaultValues/compiler.mjs +1 -1
- package/dist/esm/defaultValues/compiler.mjs.map +1 -1
- package/dist/esm/defaultValues/dictionary.mjs.map +1 -1
- package/dist/esm/defaultValues/editor.mjs +1 -1
- package/dist/esm/defaultValues/editor.mjs.map +1 -1
- package/dist/esm/defaultValues/index.mjs +1 -1
- package/dist/esm/defaultValues/index.mjs.map +1 -1
- package/dist/esm/defaultValues/internationalization.mjs +1 -1
- package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
- package/dist/esm/defaultValues/routing.mjs.map +1 -1
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/logger.mjs +1 -1
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/esm/node.mjs +1 -1
- package/dist/esm/utils/alias.mjs +1 -1
- package/dist/esm/utils/alias.mjs.map +1 -1
- package/dist/esm/utils/cacheDisk.mjs.map +1 -1
- package/dist/esm/utils/getExtension.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/parseFilePathPattern.mjs +2 -0
- package/dist/esm/utils/parseFilePathPattern.mjs.map +1 -0
- package/dist/types/built.d.ts +1 -1
- package/dist/types/configFile/buildConfigurationFields.d.ts +1 -1
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/configFile/configurationSchema.d.ts +513 -0
- package/dist/types/configFile/configurationSchema.d.ts.map +1 -0
- package/dist/types/configFile/getConfiguration.d.ts +2 -1
- package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
- package/dist/types/configFile/index.d.ts +2 -1
- package/dist/types/configFile/loadConfigurationFile.d.ts +1 -1
- package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
- package/dist/types/defaultValues/compiler.d.ts +8 -4
- package/dist/types/defaultValues/compiler.d.ts.map +1 -1
- package/dist/types/defaultValues/dictionary.d.ts +1 -1
- package/dist/types/defaultValues/editor.d.ts +1 -1
- package/dist/types/defaultValues/index.d.ts +3 -2
- package/dist/types/defaultValues/internationalization.d.ts +2 -1
- package/dist/types/defaultValues/internationalization.d.ts.map +1 -1
- package/dist/types/defaultValues/routing.d.ts +1 -1
- package/dist/types/loadExternalFile/loadExternalFile.d.ts +1 -1
- package/dist/types/logger.d.ts +2 -1
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/node.d.ts +2 -1
- package/dist/types/utils/alias.d.ts +1 -1
- package/dist/types/utils/cacheDisk.d.ts +1 -1
- package/dist/types/utils/getExtension.d.ts +1 -1
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/parseFilePathPattern.d.ts +12 -0
- package/dist/types/utils/parseFilePathPattern.d.ts.map +1 -0
- package/package.json +15 -14
package/dist/esm/logger.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.mjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { CustomIntlayerConfig } from '@intlayer/types/config';\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 } = {\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":"AAWA,IAAI,EAEJ,MAAa,EAAa,GAA+B,CACvD,EAAe,GAGJ,EAAa,GACb,IAAiB,OAIrB,EAHE,EAME,GAAkB,EAAS,IAAY,CAClD,IAAM,EAAY,GAAS,WAAa,GAClC,EAAO,GAAS,QAAQ,MAAQ,UAChC,EAAQ,GAAS,OAAS,OAC1B,EAAS,EAAU,GAAS,QAAQ,OAAO,CAC3C,EAAM,GAAS,QAAQ,KAAO,QAAQ,IACtC,EAAO,GAAS,QAAQ,MAAQ,QAAQ,KACxC,EAAO,GA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CACH,MAAM,CACN,IAAK,GAAS,CACb,GAAM,CAAE,UAAS,UAAS,UAAS,OAAQ,CACzC,GAAG,EACH,GAAI,GAAW,EAAE,CAClB,CAEK,EAAS,EAAU,EAAQ,CAC3B,EAAe,KAAK,IACxB,EACA,KAAK,IAAI,EAAU,EAAS,EAAY,EAAK,CAAC,OAAO,CACtD,CAMD,OAJI,IAAQ,OACH,GAAG,IAAI,OAAO,EAAa,GAAG,IAGhC,GAAG,IAAO,IAAI,OAAO,EAAa,IACzC,CACD,KAAK,GAAG,CAEA,EAAI,EAAS,IAAK,EAAW,IAAI,CACjC,EAAI,EAAS,IAAK,EAAW,MAAM,CACnC,EAAQ,EAAS,IAAK,EAAW,KAAK"}
|
package/dist/esm/node.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildConfigurationFields as e}from"./configFile/buildConfigurationFields.mjs";import{
|
|
1
|
+
import{buildConfigurationFields as e}from"./configFile/buildConfigurationFields.mjs";import{aiSchema as t,buildSchema as n,compilerSchema as r,contentSchema as i,cookiesAttributesSchema as a,dictionarySchema as o,editorSchema as s,internationalizationSchema as c,intlayerConfigSchema as l,logSchema as u,rewriteObjectSchema as d,rewriteRuleSchema as f,rewriteRulesSchema as p,routingSchema as m,storageAttributesSchema as h,storageSchema as g,systemSchema as _}from"./configFile/configurationSchema.mjs";import{configurationFilesCandidates as v,searchConfigurationFile as y}from"./configFile/searchConfigurationFile.mjs";import{getConfiguration as b,getConfigurationAndFilePath as x}from"./configFile/getConfiguration.mjs";import{defaultValues_exports as S}from"./defaultValues/index.mjs";export{S as DefaultValues,t as aiSchema,e as buildConfigurationFields,n as buildSchema,r as compilerSchema,v as configurationFilesCandidates,i as contentSchema,a as cookiesAttributesSchema,o as dictionarySchema,s as editorSchema,b as getConfiguration,x as getConfigurationAndFilePath,c as internationalizationSchema,l as intlayerConfigSchema,u as logSchema,d as rewriteObjectSchema,f as rewriteRuleSchema,p as rewriteRulesSchema,m as routingSchema,y as searchConfigurationFile,h as storageAttributesSchema,g as storageSchema,_ as systemSchema};
|
package/dist/esm/utils/alias.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getExtension as e}from"./getExtension.mjs";import{normalizePath as t}from"./normalizePath.mjs";import{join as n,relative as r}from"node:path";const i=({configuration:i,format:a,formatter:o=e=>e})=>{let s=e(i,a??i.build.outputFormat[0]??`esm`),{baseDir:c}=i.
|
|
1
|
+
import{getExtension as e}from"./getExtension.mjs";import{normalizePath as t}from"./normalizePath.mjs";import{join as n,relative as r}from"node:path";const i=({configuration:i,format:a,formatter:o=e=>e})=>{let s=e(i,a??i.build.outputFormat[0]??`esm`),{baseDir:c}=i.system,{mainDir:l,configDir:u}=i.system,d=o(t(r(c,n(l,`dictionaries.${s}`)))),f=o(t(r(c,n(l,`unmerged_dictionaries.${s}`)))),p=o(t(r(c,n(l,`remote_dictionaries.${s}`)))),m=o(t(r(c,n(l,`dynamic_dictionaries.${s}`)))),h=o(t(r(c,n(l,`fetch_dictionaries.${s}`)))),g=o(t(r(c,n(u,`configuration.json`))));return{"@intlayer/dictionaries-entry":d,"@intlayer/unmerged-dictionaries-entry":f,"@intlayer/remote-dictionaries-entry":p,"@intlayer/dynamic-dictionaries-entry":m,"@intlayer/fetch-dictionaries-entry":h,"@intlayer/config/built":g}};export{i as getAlias};
|
|
2
2
|
//# sourceMappingURL=alias.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias.mjs","names":[],"sources":["../../../src/utils/alias.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { getExtension } from './getExtension';\nimport { normalizePath } from './normalizePath';\n\nexport type GetAliasOptions = {\n configuration: IntlayerConfig;\n format?: 'esm' | 'cjs';\n formatter?: (value: string) => string;\n};\n\nexport const getAlias = ({\n configuration,\n format,\n formatter = (value: string) => value,\n}: GetAliasOptions) => {\n const extension = getExtension(\n configuration,\n format ?? configuration.build.outputFormat[0] ?? 'esm'\n );\n\n const { baseDir } = configuration.
|
|
1
|
+
{"version":3,"file":"alias.mjs","names":[],"sources":["../../../src/utils/alias.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getExtension } from './getExtension';\nimport { normalizePath } from './normalizePath';\n\nexport type GetAliasOptions = {\n configuration: IntlayerConfig;\n format?: 'esm' | 'cjs';\n formatter?: (value: string) => string;\n};\n\nexport const getAlias = ({\n configuration,\n format,\n formatter = (value: string) => value,\n}: GetAliasOptions) => {\n const extension = getExtension(\n configuration,\n format ?? configuration.build.outputFormat[0] ?? 'esm'\n );\n\n const { baseDir } = configuration.system;\n const { mainDir, configDir } = configuration.system;\n\n /**\n * Dictionaries\n */\n const dictionariesPath = join(mainDir, `dictionaries.${extension}`);\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n const fixedDictionariesPath = formatter(\n normalizePath(relativeDictionariesPath)\n );\n\n /**\n * Unmerged dictionaries\n */\n const unmergedDictionariesPath = join(\n mainDir,\n `unmerged_dictionaries.${extension}`\n );\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n const fixedUnmergedDictionariesPath = formatter(\n normalizePath(relativeUnmergedDictionariesPath)\n );\n\n /**\n * Remote dictionaries\n */\n const remoteDictionariesPath = join(\n mainDir,\n `remote_dictionaries.${extension}`\n );\n const relativeRemoteDictionariesPath = relative(\n baseDir,\n remoteDictionariesPath\n );\n const fixedRemoteDictionariesPath = formatter(\n normalizePath(relativeRemoteDictionariesPath)\n );\n\n /**\n * Dynamic dictionaries\n */\n const dynamicDictionariesPath = join(\n mainDir,\n `dynamic_dictionaries.${extension}`\n );\n const relativeDynamicDictionariesPath = relative(\n baseDir,\n dynamicDictionariesPath\n );\n const fixedDynamicDictionariesPath = formatter(\n normalizePath(relativeDynamicDictionariesPath)\n );\n\n /**\n * Fetch dictionaries\n */\n const fetchDictionariesPath = join(\n mainDir,\n `fetch_dictionaries.${extension}`\n );\n const relativeFetchDictionariesPath = relative(\n baseDir,\n fetchDictionariesPath\n );\n const fixedFetchDictionariesPath = formatter(\n normalizePath(relativeFetchDictionariesPath)\n );\n\n /**\n * Configuration\n */\n const configurationPath = join(configDir, `configuration.json`);\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n const fixedConfigurationPath = formatter(\n normalizePath(relativeConfigurationPath)\n );\n\n return {\n '@intlayer/dictionaries-entry': fixedDictionariesPath,\n '@intlayer/unmerged-dictionaries-entry': fixedUnmergedDictionariesPath,\n '@intlayer/remote-dictionaries-entry': fixedRemoteDictionariesPath,\n '@intlayer/dynamic-dictionaries-entry': fixedDynamicDictionariesPath,\n '@intlayer/fetch-dictionaries-entry': fixedFetchDictionariesPath,\n '@intlayer/config/built': fixedConfigurationPath,\n } as const;\n};\n"],"mappings":"qJAWA,MAAa,GAAY,CACvB,gBACA,SACA,YAAa,GAAkB,KACV,CACrB,IAAM,EAAY,EAChB,EACA,GAAU,EAAc,MAAM,aAAa,IAAM,MAClD,CAEK,CAAE,WAAY,EAAc,OAC5B,CAAE,UAAS,aAAc,EAAc,OAOvC,EAAwB,EAC5B,EAF+B,EAAS,EADjB,EAAK,EAAS,gBAAgB,IAAY,CACC,CAE3B,CACxC,CAaK,EAAgC,EACpC,EALuC,EACvC,EAL+B,EAC/B,EACA,yBAAyB,IAC1B,CAIA,CAEgD,CAChD,CAaK,EAA8B,EAClC,EALqC,EACrC,EAL6B,EAC7B,EACA,uBAAuB,IACxB,CAIA,CAE8C,CAC9C,CAaK,EAA+B,EACnC,EALsC,EACtC,EAL8B,EAC9B,EACA,wBAAwB,IACzB,CAIA,CAE+C,CAC/C,CAaK,EAA6B,EACjC,EALoC,EACpC,EAL4B,EAC5B,EACA,sBAAsB,IACvB,CAIA,CAE6C,CAC7C,CAOK,EAAyB,EAC7B,EAFgC,EAAS,EADjB,EAAK,EAAW,qBAAqB,CACO,CAE5B,CACzC,CAED,MAAO,CACL,+BAAgC,EAChC,wCAAyC,EACzC,sCAAuC,EACvC,uCAAwC,EACxC,qCAAsC,EACtC,yBAA0B,EAC3B"}
|
|
@@ -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 { basename, 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 (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\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, tempDir } = 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, tempDir);\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":"uZA2CA,MAAM,EAA0D,CAC9D,SAAU,GACX,CAEK,EAAY,KAAO,IAAgB,CACvC,MAAM,EAAM,EAAK,CAAE,UAAW,GAAM,CAAC,EAGjC,EAAkB,MACtB,EACA,EACA,IACG,CACH,GAAI,EACF,GAAI,CACF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F,MAAM,EAAO,EAAS,MAChB,IAGV,SAAU,SAA2B,CAEnC,GADA,GAAe,CACX,GAAc,EAAmB,CAEnC,IAAM,EAAO,EAAY,EAAK,EAAU,EAAU,CAAG,EAErD,GAAI,CACF,MAAM,EAAG,EAAM,CAAE,UAAW,GAAM,MAAO,GAAM,CAAC,MAC1C,EAER,GAAI,CACF,MAAM,EAAM,EAAM,CAAE,UAAW,GAAM,CAAC,MAChC,KAIZ,QAAS,SAA8B,CAErC,GADoB,EAAS,IAAI,EAAG,GAChB,IAAA,GAAW,MAAO,GAGtC,GAAI,CAAC,GAAc,CAAC,EAAmB,MAAO,GAE9C,GAAI,CACF,IAAM,EAAY,MAAM,EAAK,EAAS,CAAC,UAAY,IAAA,GAAU,CAG7D,GAFI,CAAC,GAED,OAAO,GAAU,UAAY,EAAQ,GAC3B,KAAK,KAAK,CAAG,EAAU,QACzB,EAAO,MAAO,GAG1B,IAAI,EAAM,MAAM,EAAS,EAAS,CAC5B,EAAO,EAAI,GACjB,EAAM,EAAI,SAAS,EAAE,CAIrB,IAAM,EAFe,EADL,IAAS,EAAO,EAAW,EAAI,CAAG,EACT,CAUzC,GANI,GACF,OAAO,GAAa,UACpB,OAAO,EAAS,SAAY,UAC5B,OAAO,EAAS,WAAc,UAC9B,OAAO,OAAO,EAAU,OAAO,CAEjB,CACd,IAAM,EAAQ,EAOd,MAJA,EAFI,EAAM,UAAYA,EAAkB,SAEpC,OAAO,GAAc,UAAY,EAAY,GACnC,KAAK,KAAK,CAAG,EAAM,UACrB,GASd,MAJA,EAAI,OAAO,GAAc,UAAY,EAAY,GACnC,KAAK,KAAK,CAAG,EAAU,QACzB,QAGN,CACN,MAAO,KAIX,KAEA,WACD"}
|
|
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 { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\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 (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\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, tempDir } = 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, tempDir);\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":"uZA2CA,MAAM,EAA0D,CAC9D,SAAU,GACX,CAEK,EAAY,KAAO,IAAgB,CACvC,MAAM,EAAM,EAAK,CAAE,UAAW,GAAM,CAAC,EAGjC,EAAkB,MACtB,EACA,EACA,IACG,CACH,GAAI,EACF,GAAI,CACF,MAAM,EAAU,EAAQ,MAClB,EAGV,IAAM,EAAe,GAAG,EAAS,EAAK,CAAC,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,GAC1F,EAAM,EACR,EAAK,EAAS,EAAa,CAC3B,GAAG,EAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM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,MAChC,KAIZ,QAAS,SAA8B,CAErC,GADoB,EAAS,IAAI,EAAG,GAChB,IAAA,GAAW,MAAO,GAGtC,GAAI,CAAC,GAAc,CAAC,EAAmB,MAAO,GAE9C,GAAI,CACF,IAAM,EAAY,MAAM,EAAK,EAAS,CAAC,UAAY,IAAA,GAAU,CAG7D,GAFI,CAAC,GAED,OAAO,GAAU,UAAY,EAAQ,GAC3B,KAAK,KAAK,CAAG,EAAU,QACzB,EAAO,MAAO,GAG1B,IAAI,EAAM,MAAM,EAAS,EAAS,CAC5B,EAAO,EAAI,GACjB,EAAM,EAAI,SAAS,EAAE,CAIrB,IAAM,EAFe,EADL,IAAS,EAAO,EAAW,EAAI,CAAG,EACT,CAUzC,GANI,GACF,OAAO,GAAa,UACpB,OAAO,EAAS,SAAY,UAC5B,OAAO,EAAS,WAAc,UAC9B,OAAO,OAAO,EAAU,OAAO,CAEjB,CACd,IAAM,EAAQ,EAOd,MAJA,EAFI,EAAM,UAAYA,EAAkB,SAEpC,OAAO,GAAc,UAAY,EAAY,GACnC,KAAK,KAAK,CAAG,EAAM,UACrB,GASd,MAJA,EAAI,OAAO,GAAc,UAAY,EAAY,GACnC,KAAK,KAAK,CAAG,EAAU,QACzB,QAGN,CACN,MAAO,KAIX,KAEA,WACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExtension.mjs","names":[],"sources":["../../../src/utils/getExtension.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\n\nexport const getExtension = (\n configuration: IntlayerConfig,\n format?: 'esm' | 'cjs' | undefined\n) => {\n const outputFormats = configuration.build.outputFormat;\n\n if (format === 'cjs') return 'cjs';\n if (format === 'esm') return 'mjs';\n\n if (outputFormats.includes('cjs')) return 'cjs';\n if (outputFormats.includes('esm')) return 'mjs';\n\n return 'cjs';\n};\n"],"mappings":"AAEA,MAAa,GACX,EACA,IACG,CACH,IAAM,EAAgB,EAAc,MAAM,aAQ1C,OANI,IAAW,MAAc,MACzB,IAAW,MAAc,MAEzB,EAAc,SAAS,MAAM,CAAS,MACtC,EAAc,SAAS,MAAM,CAAS,MAEnC"}
|
|
1
|
+
{"version":3,"file":"getExtension.mjs","names":[],"sources":["../../../src/utils/getExtension.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const getExtension = (\n configuration: IntlayerConfig,\n format?: 'esm' | 'cjs' | undefined\n) => {\n const outputFormats = configuration.build.outputFormat;\n\n if (format === 'cjs') return 'cjs';\n if (format === 'esm') return 'mjs';\n\n if (outputFormats.includes('cjs')) return 'cjs';\n if (outputFormats.includes('esm')) return 'mjs';\n\n return 'cjs';\n};\n"],"mappings":"AAEA,MAAa,GACX,EACA,IACG,CACH,IAAM,EAAgB,EAAc,MAAM,aAQ1C,OANI,IAAW,MAAc,MACzB,IAAW,MAAc,MAEzB,EAAc,SAAS,MAAM,CAAS,MACtC,EAAc,SAAS,MAAM,CAAS,MAEnC"}
|
package/dist/esm/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getExtension as e}from"./getExtension.mjs";import{normalizePath as t}from"./normalizePath.mjs";import{getAlias as n}from"./alias.mjs";import{cacheMemory as r,clearAllCache as i,clearCache as a,computeKeyId as o,getCache as s,setCache as c,stableStringify as l}from"./cacheMemory.mjs";import{cacheDisk as u}from"./cacheDisk.mjs";import{getPackageJsonPath as d}from"./getPackageJsonPath.mjs";import{configESMxCJSRequire as f,getProjectRequire as p,isESModule as m}from"./ESMxCJSHelpers.mjs";import{clearModuleCache as h}from"./clearModuleCache.mjs";import{compareVersions as g}from"./compareVersions.mjs";import{extractErrorMessage as _}from"./extractErrorMessage.mjs";import{logStack as v}from"./logStack.mjs";import{parseFilePathPattern as y,parseStringPattern as b}from"./parseFilePathPattern.mjs";import{retryManager as x}from"./retryManager.mjs";import{camelCaseToKebabCase as S}from"./stringFormatter/camelCaseToKebabCase.mjs";import{camelCaseToSentence as C}from"./stringFormatter/camelCaseToSentence.mjs";import{kebabCaseToCamelCase as w}from"./stringFormatter/kebabCaseToCamelCase.mjs";import{toLowerCamelCase as T}from"./stringFormatter/toLowerCamelCase.mjs";export{u as cacheDisk,r as cacheMemory,S as camelCaseToKebabCase,C as camelCaseToSentence,i as clearAllCache,a as clearCache,h as clearModuleCache,g as compareVersions,o as computeKeyId,f as configESMxCJSRequire,_ as extractErrorMessage,n as getAlias,s as getCache,e as getExtension,d as getPackageJsonPath,p as getProjectRequire,m as isESModule,w as kebabCaseToCamelCase,v as logStack,t as normalizePath,y as parseFilePathPattern,b as parseStringPattern,x as retryManager,c as setCache,l as stableStringify,T as toLowerCamelCase};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=async(e,n)=>{if(typeof e==`function`)return await e(n);if(typeof e==`object`&&e&&n.locale){let r=e[n.locale];if(r)return typeof r==`function`?await r(n):t(r,n)}return typeof e==`string`?t(e,n):``},t=(e,t)=>e.replaceAll(/\{\{\s*locale\s*\}\}/g,t.locale??``).replaceAll(/\{\{\s*key\s*\}\}/g,t.key??``).replaceAll(/\{\{\s*fileName\s*\}\}/g,t.fileName??``).replaceAll(/\{\{\s*extension\s*\}\}/g,t.extension??``).replaceAll(/\{\{\s*componentFileName\s*\}\}/g,t.componentFileName??``).replaceAll(/\{\{\s*componentExtension\s*\}\}/g,t.componentExtension??``).replaceAll(/\{\{\s*format\s*\}\}/g,t.format??``).replaceAll(/\{\{\s*componentFormat\s*\}\}/g,t.componentFormat??``).replaceAll(/\{\{\s*dirPath\s*\}\}/g,t.dirPath??``);export{e as parseFilePathPattern,t as parseStringPattern};
|
|
2
|
+
//# sourceMappingURL=parseFilePathPattern.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseFilePathPattern.mjs","names":[],"sources":["../../../src/utils/parseFilePathPattern.ts"],"sourcesContent":["import type {\n FilePathPattern,\n FilePathPatternContext,\n} from '@intlayer/types/filePathPattern';\n\n/**\n * Parses a FilePathPattern configuration string or function to a final string path.\n * Resolves context variables like `{{locale}}`, `{{key}}`, `{{fileName}}`, `{{extension}}`.\n */\nexport const parseFilePathPattern = async (\n pattern: FilePathPattern,\n context: FilePathPatternContext\n): Promise<string> => {\n if (typeof pattern === 'function') {\n return await (pattern as any)(context);\n }\n\n if (typeof pattern === 'object' && pattern !== null && context.locale) {\n const localePattern = (pattern as any)[context.locale];\n\n if (localePattern) {\n if (typeof localePattern === 'function') {\n return await localePattern(context);\n }\n return parseStringPattern(localePattern, context);\n }\n }\n\n if (typeof pattern === 'string') {\n return parseStringPattern(pattern, context);\n }\n\n return '';\n};\n\nexport const parseStringPattern = (\n pattern: string,\n context: FilePathPatternContext\n): string =>\n pattern\n .replaceAll(/\\{\\{\\s*locale\\s*\\}\\}/g, context.locale ?? '')\n .replaceAll(/\\{\\{\\s*key\\s*\\}\\}/g, context.key ?? '')\n .replaceAll(/\\{\\{\\s*fileName\\s*\\}\\}/g, context.fileName ?? '')\n .replaceAll(/\\{\\{\\s*extension\\s*\\}\\}/g, context.extension ?? '')\n .replaceAll(\n /\\{\\{\\s*componentFileName\\s*\\}\\}/g,\n context.componentFileName ?? ''\n )\n .replaceAll(\n /\\{\\{\\s*componentExtension\\s*\\}\\}/g,\n context.componentExtension ?? ''\n )\n .replaceAll(/\\{\\{\\s*format\\s*\\}\\}/g, context.format ?? '')\n .replaceAll(/\\{\\{\\s*componentFormat\\s*\\}\\}/g, context.componentFormat ?? '')\n .replaceAll(/\\{\\{\\s*dirPath\\s*\\}\\}/g, context.dirPath ?? '');\n"],"mappings":"AASA,MAAa,EAAuB,MAClC,EACA,IACoB,CACpB,GAAI,OAAO,GAAY,WACrB,OAAO,MAAO,EAAgB,EAAQ,CAGxC,GAAI,OAAO,GAAY,UAAY,GAAoB,EAAQ,OAAQ,CACrE,IAAM,EAAiB,EAAgB,EAAQ,QAE/C,GAAI,EAIF,OAHI,OAAO,GAAkB,WACpB,MAAM,EAAc,EAAQ,CAE9B,EAAmB,EAAe,EAAQ,CAQrD,OAJI,OAAO,GAAY,SACd,EAAmB,EAAS,EAAQ,CAGtC,IAGI,GACX,EACA,IAEA,EACG,WAAW,wBAAyB,EAAQ,QAAU,GAAG,CACzD,WAAW,qBAAsB,EAAQ,KAAO,GAAG,CACnD,WAAW,0BAA2B,EAAQ,UAAY,GAAG,CAC7D,WAAW,2BAA4B,EAAQ,WAAa,GAAG,CAC/D,WACC,mCACA,EAAQ,mBAAqB,GAC9B,CACA,WACC,oCACA,EAAQ,oBAAsB,GAC/B,CACA,WAAW,wBAAyB,EAAQ,QAAU,GAAG,CACzD,WAAW,iCAAkC,EAAQ,iBAAmB,GAAG,CAC3E,WAAW,yBAA0B,EAAQ,SAAW,GAAG"}
|
package/dist/types/built.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"mappings":";;;;;AAq0BA;cAAa,wBAAA,GACX,mBAAA,GAAsB,oBAAA,EACtB,OAAA,WACA,YAAA,GAAe,YAAA,KACd,cAAA"}
|