@intlayer/config 8.4.0 → 8.4.2
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/{_virtual/_rolldown/runtime.cjs → chunk-D-qHiVGv.cjs} +1 -1
- package/dist/cjs/client.cjs +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 +1 -1
- package/dist/cjs/configFile/configurationSchema.cjs.map +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
- package/dist/cjs/defaultValues/build.cjs +1 -1
- package/dist/cjs/defaultValues/build.cjs.map +1 -1
- package/dist/cjs/defaultValues/compiler.cjs +1 -1
- package/dist/cjs/defaultValues/content.cjs +1 -1
- package/dist/cjs/defaultValues/content.cjs.map +1 -1
- package/dist/cjs/defaultValues/dictionary.cjs +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/internationalization.cjs +1 -1
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/log.cjs +1 -1
- package/dist/cjs/defaultValues/log.cjs.map +1 -1
- package/dist/cjs/defaultValues/routing.cjs +1 -1
- package/dist/cjs/defaultValues/routing.cjs.map +1 -1
- package/dist/cjs/defaultValues/system.cjs +1 -1
- package/dist/cjs/defaultValues/system.cjs.map +1 -1
- package/dist/cjs/loadEnvFile.cjs +1 -1
- package/dist/cjs/loadEnvFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleFile.cjs +1 -1
- package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs +1 -1
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs +1 -1
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +1 -1
- package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
- package/dist/cjs/node.cjs +1 -1
- package/dist/cjs/utils/ESMxCJSHelpers.cjs +1 -1
- package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +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 +1 -1
- package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
- package/dist/cjs/utils/cacheMemory.cjs +1 -1
- package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
- package/dist/esm/{_virtual/_rolldown/runtime.mjs → chunk-DXQkyQJp.mjs} +1 -1
- package/dist/esm/client.mjs +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 +1 -1
- package/dist/esm/configFile/configurationSchema.mjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +1 -1
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/searchConfigurationFile.mjs +1 -1
- package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
- package/dist/esm/defaultValues/build.mjs +1 -1
- package/dist/esm/defaultValues/build.mjs.map +1 -1
- package/dist/esm/defaultValues/compiler.mjs +1 -1
- package/dist/esm/defaultValues/compiler.mjs.map +1 -1
- package/dist/esm/defaultValues/content.mjs +1 -1
- package/dist/esm/defaultValues/content.mjs.map +1 -1
- package/dist/esm/defaultValues/dictionary.mjs +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/internationalization.mjs +1 -1
- package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
- package/dist/esm/defaultValues/log.mjs +1 -1
- package/dist/esm/defaultValues/log.mjs.map +1 -1
- package/dist/esm/defaultValues/routing.mjs +1 -1
- package/dist/esm/defaultValues/routing.mjs.map +1 -1
- package/dist/esm/defaultValues/system.mjs +1 -1
- package/dist/esm/defaultValues/system.mjs.map +1 -1
- package/dist/esm/loadExternalFile/loadExternalFile.mjs +1 -1
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +1 -1
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
- package/dist/esm/node.mjs +1 -1
- package/dist/esm/utils/ESMxCJSHelpers.mjs +1 -1
- package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
- package/dist/types/build-BGWWxAP2.d.ts +12 -0
- package/dist/types/build-BGWWxAP2.d.ts.map +1 -0
- package/dist/types/camelCaseToKebabCase-91HKVxf2.d.ts +9 -0
- package/dist/types/camelCaseToKebabCase-91HKVxf2.d.ts.map +1 -0
- package/dist/types/camelCaseToSentence-LKuKkD3M.d.ts +9 -0
- package/dist/types/camelCaseToSentence-LKuKkD3M.d.ts.map +1 -0
- package/dist/types/client.d.ts +5 -5
- package/dist/types/compiler-BKn6YjPf.d.ts +10 -0
- package/dist/types/compiler-BKn6YjPf.d.ts.map +1 -0
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/configFile/configurationSchema.d.ts +2 -8
- package/dist/types/configFile/configurationSchema.d.ts.map +1 -1
- package/dist/types/configFile/getConfiguration.d.ts +3 -1
- package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
- package/dist/types/configFile/loadConfigurationFile.d.ts +1 -1
- package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
- package/dist/types/configFile/searchConfigurationFile.d.ts.map +1 -1
- package/dist/types/content-CEqOvNcs.d.ts +13 -0
- package/dist/types/content-CEqOvNcs.d.ts.map +1 -0
- package/dist/types/defaultValues/build.d.ts +2 -12
- package/dist/types/defaultValues/compiler.d.ts +2 -10
- package/dist/types/defaultValues/content.d.ts +2 -13
- package/dist/types/defaultValues/dictionary.d.ts +2 -13
- package/dist/types/defaultValues/editor.d.ts +2 -15
- package/dist/types/defaultValues/index.d.ts +10 -10
- package/dist/types/defaultValues/internationalization.d.ts +2 -14
- package/dist/types/defaultValues/log.d.ts +2 -8
- package/dist/types/defaultValues/routing.d.ts +2 -16
- package/dist/types/defaultValues/system.d.ts +2 -18
- package/dist/types/dictionary-n4jBpRU_.d.ts +13 -0
- package/dist/types/dictionary-n4jBpRU_.d.ts.map +1 -0
- package/dist/types/editor-Bhh3J_sb.d.ts +15 -0
- package/dist/types/editor-Bhh3J_sb.d.ts.map +1 -0
- package/dist/types/internationalization-0cqNGQ-O.d.ts +14 -0
- package/dist/types/internationalization-0cqNGQ-O.d.ts.map +1 -0
- package/dist/types/kebabCaseToCamelCase-BR4yfbUC.d.ts +5 -0
- package/dist/types/kebabCaseToCamelCase-BR4yfbUC.d.ts.map +1 -0
- package/dist/types/loadEnvFile-Dk80Swa9.d.ts +10 -0
- package/dist/types/loadEnvFile-Dk80Swa9.d.ts.map +1 -0
- package/dist/types/loadEnvFile.d.ts +2 -10
- package/dist/types/loadExternalFile/index.d.ts +4 -4
- package/dist/types/loadExternalFile/loadExternalFile.d.ts +2 -25
- package/dist/types/loadExternalFile/parseFileContent.d.ts +2 -29
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +2 -8
- package/dist/types/loadExternalFile-CJIPA_rP.d.ts +25 -0
- package/dist/types/loadExternalFile-CJIPA_rP.d.ts.map +1 -0
- package/dist/types/log-C5gSYuVB.d.ts +8 -0
- package/dist/types/log-C5gSYuVB.d.ts.map +1 -0
- package/dist/types/node.d.ts +1 -1
- package/dist/types/parseFileContent-CriV5Luv.d.ts +29 -0
- package/dist/types/parseFileContent-CriV5Luv.d.ts.map +1 -0
- package/dist/types/routing-DlVdUHPZ.d.ts +16 -0
- package/dist/types/routing-DlVdUHPZ.d.ts.map +1 -0
- package/dist/types/system-BFYob741.d.ts +18 -0
- package/dist/types/system-BFYob741.d.ts.map +1 -0
- package/dist/types/toLowerCamelCase-CfYCuChC.d.ts +10 -0
- package/dist/types/toLowerCamelCase-CfYCuChC.d.ts.map +1 -0
- package/dist/types/transpileTSToCJS-DxeK5fRY.d.ts +19 -0
- package/dist/types/transpileTSToCJS-DxeK5fRY.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +4 -4
- package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts +2 -9
- package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts +2 -9
- package/dist/types/utils/stringFormatter/index.d.ts +4 -4
- package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts +2 -5
- package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts +2 -10
- package/package.json +2 -2
- package/dist/types/defaultValues/build.d.ts.map +0 -1
- package/dist/types/defaultValues/compiler.d.ts.map +0 -1
- package/dist/types/defaultValues/content.d.ts.map +0 -1
- package/dist/types/defaultValues/dictionary.d.ts.map +0 -1
- package/dist/types/defaultValues/editor.d.ts.map +0 -1
- package/dist/types/defaultValues/internationalization.d.ts.map +0 -1
- package/dist/types/defaultValues/log.d.ts.map +0 -1
- package/dist/types/defaultValues/routing.d.ts.map +0 -1
- package/dist/types/defaultValues/system.d.ts.map +0 -1
- package/dist/types/loadEnvFile.d.ts.map +0 -1
- package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +0 -1
- package/dist/types/loadExternalFile/parseFileContent.d.ts.map +0 -1
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +0 -1
- package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts.map +0 -1
- package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts.map +0 -1
- package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts.map +0 -1
- package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleFile.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Loader,\n type Plugin,\n} from 'esbuild';\n\nexport type ESBuildPlugin = Plugin;\n\nexport const getLoader = (extension: string): Loader => {\n switch (extension) {\n case '.js':\n return 'js';\n case '.jsx':\n return 'jsx';\n case '.mjs':\n return 'js';\n case '.ts':\n return 'ts';\n case '.tsx':\n return 'tsx';\n case '.cjs':\n return 'js';\n case '.json':\n return 'json';\n case '.md':\n return 'text';\n case '.mdx':\n return 'text';\n default:\n return 'js';\n }\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: 'node16',\n platform: 'neutral',\n write: false,\n packages: 'bundle',\n external: ['esbuild'],\n bundle: true,\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const bundleFileSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\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 ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const bundleFile = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\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 ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundleFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleFile.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Loader,\n type Plugin,\n} from 'esbuild';\n\nexport type ESBuildPlugin = Plugin;\n\nexport const getLoader = (extension: string): Loader => {\n switch (extension) {\n case '.js':\n return 'js';\n case '.jsx':\n return 'jsx';\n case '.mjs':\n return 'js';\n case '.ts':\n return 'ts';\n case '.tsx':\n return 'tsx';\n case '.cjs':\n return 'js';\n case '.json':\n return 'json';\n case '.md':\n return 'text';\n case '.mdx':\n return 'text';\n default:\n return 'js';\n }\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: 'node16',\n platform: 'neutral',\n write: false,\n packages: 'bundle',\n external: ['esbuild'],\n bundle: true,\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const bundleFileSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\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 ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const bundleFile = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\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 ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":"0KAaA,MAAa,EAAa,GAA8B,CACtD,OAAQ,EAAR,CACE,IAAK,MACH,MAAO,KACT,IAAK,OACH,MAAO,MACT,IAAK,OACH,MAAO,KACT,IAAK,MACH,MAAO,KACT,IAAK,OACH,MAAO,MACT,IAAK,OACH,MAAO,KACT,IAAK,QACH,MAAO,OACT,IAAK,MACH,MAAO,OACT,IAAK,OACH,MAAO,OACT,QACE,MAAO,OAIP,EAA4B,IAAoC,CACpE,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACD,OAAQ,MACR,OAAQ,SACR,SAAU,UACV,MAAO,GACP,SAAU,SACV,SAAU,CAAC,UAAU,CACrB,OAAQ,GACR,OAAQ,CACN,kBAAmB,KAAK,WAAA,EAAA,EAAA,eAAwB,EAAS,CAAC,KAAK,CAChE,CACF,EAEY,GACX,EACA,EACA,KAkBA,EAAA,EAAA,WAb4C,CAC1C,MAAO,CACL,SAAU,EACV,OALW,GAAA,EAAA,EAAA,SADW,EAAS,CACA,CAM/B,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,CAEsC,cAAc,GAAG,KAK9C,EAAa,MACxB,EACA,EACA,KAKkC,MAAA,EAAA,EAAA,OAAY,CAC5C,MAAO,CACL,SAAU,EACV,OALW,GAAA,EAAA,EAAA,SADW,EAAS,CACA,CAM/B,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,EAEsC,cAAc,GAAG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-D-qHiVGv.cjs`);let e=require(`esbuild`);const t={bundle:!0,format:`cjs`,platform:`node`,target:`es2019`,sourcemap:!1,logLevel:`silent`,write:!0,packages:`external`,loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`}},n=async n=>await(0,e.build)({...t,...n});exports.bundleJSFile=n;
|
|
2
2
|
//# sourceMappingURL=bundleJSFile.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleJSFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleJSFile.ts"],"sourcesContent":["import { type BuildOptions, build } from 'esbuild';\n\nconst commonBuildOptions = {\n bundle: true,\n format: 'cjs',\n platform: 'node',\n target: 'es2019',\n sourcemap: false,\n logLevel: 'silent',\n write: true,\n // Bundle relative/local files, but keep bare module imports external\n packages: 'external',\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} as const;\n\nexport const bundleJSFile = async (buildOptions: BuildOptions) =>\n await build({\n ...commonBuildOptions,\n ...buildOptions,\n });\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundleJSFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleJSFile.ts"],"sourcesContent":["import { type BuildOptions, build } from 'esbuild';\n\nconst commonBuildOptions = {\n bundle: true,\n format: 'cjs',\n platform: 'node',\n target: 'es2019',\n sourcemap: false,\n logLevel: 'silent',\n write: true,\n // Bundle relative/local files, but keep bare module imports external\n packages: 'external',\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} as const;\n\nexport const bundleJSFile = async (buildOptions: BuildOptions) =>\n await build({\n ...commonBuildOptions,\n ...buildOptions,\n });\n"],"mappings":"6HAEA,MAAM,EAAqB,CACzB,OAAQ,GACR,OAAQ,MACR,SAAU,OACV,OAAQ,SACR,UAAW,GACX,SAAU,SACV,MAAO,GAEP,SAAU,WACV,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACF,CAEY,EAAe,KAAO,IACjC,MAAA,EAAA,EAAA,OAAY,CACV,GAAG,EACH,GAAG,EACJ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-D-qHiVGv.cjs`),t=require(`../logger.cjs`),n=require(`./parseFileContent.cjs`),r=require(`./transpileTSToCJS.cjs`);let i=require(`node:fs`),a=require(`node:path`),o=require(`node:fs/promises`),s=require(`json5`);s=e.n(s);const c=s.parse||s.default?.parse,l=(e,o)=>{let s=(0,a.extname)(e)||`.json`;try{if(s===`.json`||s===`.json5`||s===`.jsonc`)return c((0,i.readFileSync)(e,`utf-8`));let a=r.transpileTSToCJSSync((0,i.readFileSync)(e,`utf-8`),e,o?.buildOptions);if(!a){t.logger(`File could not be loaded.`,{level:`error`});return}let l=n.parseFileContent(a,{projectRequire:o?.projectRequire,envVarOptions:o?.envVarOptions,additionalEnvVars:o?.additionalEnvVars,mocks:o?.mocks,aliases:o?.aliases});if(l===void 0){t.logger(`File could not be loaded. Path : ${e}`);return}return l}catch(e){t.logger([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}},u=async(e,i)=>{let s=(0,a.extname)(e);try{if(s===`.json`||s===`.json5`||s===`.jsonc`)return c(await(0,o.readFile)(e,`utf-8`));let a=await r.transpileTSToCJS(await(0,o.readFile)(e,`utf-8`),e,i?.buildOptions);if(!a){t.logger(`File could not be loaded.`,{level:`error`});return}let l=n.parseFileContent(a,{projectRequire:i?.projectRequire,envVarOptions:i?.envVarOptions,additionalEnvVars:i?.additionalEnvVars,mocks:i?.mocks,aliases:i?.aliases});if(l===void 0){t.logger(`File could not be loaded. Path : ${t.colorizePath(e)}`);return}return l}catch(e){(i?.logError??!0)&&t.logger([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}};exports.loadExternalFile=u,exports.loadExternalFileSync=l;
|
|
2
2
|
//# sourceMappingURL=loadExternalFile.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","transpileTSToCJS","colorizePath"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport
|
|
1
|
+
{"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","transpileTSToCJS","colorizePath"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport * as JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport {\n type TranspileOptions,\n transpileTSToCJS,\n transpileTSToCJSSync,\n} from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: TranspileOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":"yTAiBA,MAAM,EAAaA,EAAM,OAAUA,EAAc,SAAS,MAa7C,GACX,EACA,IACoB,CACpB,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAO,GAAA,EAAA,EAAA,cAAwB,EAAU,QAAQ,CAAC,CAMpD,IAAM,EAAyCC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O,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-D-qHiVGv.cjs`),t=require(`../utils/ESMxCJSHelpers.cjs`),n=require(`../loadEnvFile.cjs`);let r=require(`node:vm`),i=require(`esbuild`);i=e.n(i);const a=e=>{let{envVarOptions:r,projectRequire:a,additionalEnvVars:o,mocks:s,aliases:c}=e??{},l={},u=typeof a==`function`?a:t.getProjectRequire(),d=(()=>{let e=Object.assign({esbuild:i},s),t=Object.assign({},c),n=function(n){let r=t?.[n]?t[n]:n;return e&&Object.hasOwn(e,r)?e[r]:r!==n&&e&&Object.hasOwn(e,n)?e[n]:u(r)};return n.resolve=u.resolve.bind(u),n.main=u.main,n.extensions=u.extensions,n.cache=u.cache,n})();try{l={React:u(`react`)}}catch{l={React:{createElement:(e,t,...n)=>({type:e,props:{...t,children:n.length<=1?n[0]:n}}),Fragment:Symbol.for(`react.fragment`)}}}let f={exports:{default:{}},module:{exports:{}},process:{...process,env:{...process.env,...n.loadEnvFile(r),...o}},console,require:d,...l};return Object.getOwnPropertyNames(globalThis).forEach(e=>{e in f||(f[e]=globalThis[e])}),f},o=(e,t)=>{let n=a(t);(0,r.runInNewContext)(`"use strict";\n${e}`,n);let i=[n.exports?.default,n.module?.exports?.defaults,n.module?.exports?.default,n.module?.exports];for(let e of i)if(e&&typeof e==`object`&&Object.keys(e).length>0)return e};exports.getSandBoxContext=a,exports.parseFileContent=o;
|
|
2
2
|
//# sourceMappingURL=parseFileContent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFileContent.cjs","names":["getProjectRequire","loadEnvFile"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseFileContent.cjs","names":["getProjectRequire","loadEnvFile"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":"4OA0BA,MAAa,EAAqB,GAA6C,CAC7E,GAAM,CAAE,gBAAe,iBAAgB,oBAAmB,QAAO,WAC/D,GAAW,EAAE,CAEX,EAAsB,EAAE,CAEtB,EACJ,OAAO,GAAmB,WAAa,EAAiBA,EAAAA,mBAAmB,CAGvE,OAAuC,CAC3C,IAAM,EAAY,OAAO,OACvB,CACE,UACD,CACD,EACD,CACK,EAAa,OAAO,OAAO,EAAE,CAAE,EAAQ,CAEvC,EAAiB,SAAyB,EAAY,CAC1D,IAAM,EAAS,IAAa,GAAM,EAAW,GAAM,EAWnD,OATI,GAAa,OAAO,OAAO,EAAW,EAAO,CACxC,EAAU,GAIf,IAAW,GAAM,GAAa,OAAO,OAAO,EAAW,EAAG,CACrD,EAAU,GAGZ,EAAY,EAAO,EAS5B,MALA,GAAe,QAAU,EAAY,QAAQ,KAAK,EAAY,CAC9D,EAAe,KAAO,EAAY,KAClC,EAAe,WAAa,EAAY,WACxC,EAAe,MAAQ,EAAY,MAE5B,KACL,CAEJ,GAAI,CAEF,EAAsB,CACpB,MAAO,EAAY,QAAQ,CAC5B,MACY,CAIb,EAAsB,CACpB,MAAO,CACL,eAAgB,EAAW,EAAY,GAAG,KAAqB,CAC7D,OACA,MAAO,CACL,GAAG,EACH,SAAU,EAAS,QAAU,EAAI,EAAS,GAAK,EAChD,CACF,EACD,SAAU,OAAO,IAAI,iBAAiB,CACvC,CACF,CAGH,IAAM,EAA0B,CAC9B,QAAS,CACP,QAAS,EAAE,CACZ,CACD,OAAQ,CACN,QAAS,EAAE,CACZ,CACD,QAAS,CACP,GAAG,QACH,IAAK,CACH,GAAG,QAAQ,IACX,GAAGC,EAAAA,YAAY,EAAc,CAC7B,GAAG,EACJ,CACF,CACD,QACA,QAAS,EACT,GAAG,EACJ,CASD,OANA,OAAO,oBAAoB,WAAW,CAAC,QAAS,GAAQ,CAChD,KAAO,IACX,EAAe,GAAO,WAAW,KAEnC,CAEK,GAGI,GACX,EACA,IACkB,CAClB,IAAM,EAAiB,EAAkB,EAAQ,EAGjD,EAAA,EAAA,iBAAgB,kBAAkB,IAAqB,EAAe,CAEtE,IAAM,EAAwB,CAC5B,EAAe,SAAS,QACxB,EAAe,QAAQ,SAAS,SAChC,EAAe,QAAQ,SAAS,QAChC,EAAe,QAAQ,QACxB,CAED,IAAK,IAAM,KAAa,EACtB,GACE,GACA,OAAO,GAAc,UACrB,OAAO,KAAK,EAAoB,CAAC,OAAS,EAE1C,OAAO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-D-qHiVGv.cjs`);const e=require(`../utils/getPackageJsonPath.cjs`),t=require(`./bundleFile.cjs`);let n=require(`node:fs`),r=require(`node:path`),i=require(`esbuild`),a=require(`node:url`);const o=t=>{let i=(0,r.join)(e.getPackageJsonPath((0,r.dirname)(t)).baseDir,`tsconfig.json`);return(0,n.existsSync)(i)?i:void 0},s=e=>({loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`},format:`cjs`,target:`node20`,platform:`node`,write:!1,packages:`external`,bundle:!0,tsconfig:o(e),define:{"import.meta.url":JSON.stringify((0,a.pathToFileURL)(e).href)}}),c=(e,n,a)=>{let o=t.getLoader((0,r.extname)(n)),{esbuildInstance:c,...l}=a??{};return(c?.buildSync??i.buildSync)({stdin:{contents:e,loader:o,resolveDir:(0,r.dirname)(n),sourcefile:n},...s(n),...l}).outputFiles?.[0].text},l=async(e,n,a)=>{let o=t.getLoader((0,r.extname)(n)),{esbuildInstance:c,...l}=a??{};return(await(c?.build??i.build)({stdin:{contents:e,loader:o,resolveDir:(0,r.dirname)(n),sourcefile:n},...s(n),...l})).outputFiles?.[0].text};exports.transpileTSToCJS=l,exports.transpileTSToCJSSync=c;
|
|
2
2
|
//# sourceMappingURL=transpileTSToCJS.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader"],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type BuildOptions, type BuildResult, build, buildSync } from 'esbuild';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { getLoader } from './bundleFile';\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 },\n});\n\nexport const transpileTSToCJSSync = (\n code: string,\n filePath: string,\n options?:
|
|
1
|
+
{"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader","buildSync","build"],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type BuildOptions, type BuildResult, build, buildSync } 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 },\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 const esbuildBuild = esbuildInstance?.build ?? build;\n\n const moduleResult: BuildResult = await esbuildBuild({\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"],"mappings":"gRAkBA,MAAM,EAAmB,GAAyC,CAChE,IAAM,GAAA,EAAA,EAAA,MACJA,EAAAA,oBAAAA,EAAAA,EAAAA,SAA2B,EAAS,CAAC,CAAC,QACtC,gBACD,CAGD,OAAA,EAAA,EAAA,YAAkB,EAAa,CAAG,EAAe,IAAA,IAG7C,EAA4B,IAAoC,CACpE,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACD,OAAQ,MACR,OAAQ,SACR,SAAU,OACV,MAAO,GACP,SAAU,WACV,OAAQ,GACR,SAAU,EAAgB,EAAS,CACnC,OAAQ,CACN,kBAAmB,KAAK,WAAA,EAAA,EAAA,eAAwB,EAAS,CAAC,KAAK,CAChE,CACF,EAEY,GACX,EACA,EACA,IACuB,CAEvB,IAAM,EAASC,EAAAA,WAAAA,EAAAA,EAAAA,SADW,EAAS,CACA,CAE7B,CAAE,kBAAiB,GAAG,GAAiB,GAAW,EAAE,CAgB1D,OAfyB,GAAiB,WAAaC,EAAAA,WAEJ,CACjD,MAAO,CACL,SAAU,EACV,SACA,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,CAEsC,cAAc,GAAG,MAK9C,EAAmB,MAC9B,EACA,EACA,IACgC,CAEhC,IAAM,EAASD,EAAAA,WAAAA,EAAAA,EAAAA,SADW,EAAS,CACA,CAE7B,CAAE,kBAAiB,GAAG,GAAiB,GAAW,EAAE,CAgB1D,OAbkC,MAFb,GAAiB,OAASE,EAAAA,OAEM,CACnD,MAAO,CACL,SAAU,EACV,SACA,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,EAEsC,cAAc,GAAG"}
|
package/dist/cjs/node.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./configFile/buildConfigurationFields.cjs`),t=require(`./configFile/configurationSchema.cjs`),n=require(`./configFile/searchConfigurationFile.cjs`),r=require(`./configFile/getConfiguration.cjs`),i=require(`./defaultValues/index.cjs`);Object.defineProperty(exports,`DefaultValues`,{enumerable:!0,get:function(){return i.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./configFile/buildConfigurationFields.cjs`),t=require(`./configFile/configurationSchema.cjs`),n=require(`./configFile/searchConfigurationFile.cjs`),r=require(`./configFile/getConfiguration.cjs`),i=require(`./defaultValues/index.cjs`);Object.defineProperty(exports,`DefaultValues`,{enumerable:!0,get:function(){return i.t}}),exports.aiSchema=t.aiSchema,exports.buildConfigurationFields=e.buildConfigurationFields,exports.buildSchema=t.buildSchema,exports.compilerSchema=t.compilerSchema,exports.configurationFilesCandidates=n.configurationFilesCandidates,exports.contentSchema=t.contentSchema,exports.cookiesAttributesSchema=t.cookiesAttributesSchema,exports.dictionarySchema=t.dictionarySchema,exports.editorSchema=t.editorSchema,exports.getConfiguration=r.getConfiguration,exports.getConfigurationAndFilePath=r.getConfigurationAndFilePath,exports.internationalizationSchema=t.internationalizationSchema,exports.intlayerConfigSchema=t.intlayerConfigSchema,exports.logSchema=t.logSchema,exports.rewriteObjectSchema=t.rewriteObjectSchema,exports.rewriteRuleSchema=t.rewriteRuleSchema,exports.rewriteRulesSchema=t.rewriteRulesSchema,exports.routingSchema=t.routingSchema,exports.searchConfigurationFile=n.searchConfigurationFile,exports.storageAttributesSchema=t.storageAttributesSchema,exports.storageSchema=t.storageSchema,exports.systemSchema=t.systemSchema;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-D-qHiVGv.cjs`);const e=require(`./getPackageJsonPath.cjs`);let t=require(`node:module`);const n=typeof require(`url`).pathToFileURL(__filename).href==`string`,r=n=>{let{packageJsonPath:r}=e.getPackageJsonPath(n);return(0,t.createRequire)(r)},i=n?(0,t.createRequire)(require(`url`).pathToFileURL(__filename).href):require;exports.configESMxCJSRequire=i,exports.getProjectRequire=r,exports.isESModule=n;
|
|
2
2
|
//# sourceMappingURL=ESMxCJSHelpers.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ESMxCJSHelpers.cjs","names":["getPackageJsonPath"],"sources":["../../../src/utils/ESMxCJSHelpers.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { getPackageJsonPath } from './getPackageJsonPath';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\n/**\n * Require relative to the user project\n *\n * Note: Can resolve package that are installed in the user project, ex `'intlayer'`\n */\nexport const getProjectRequire = (startDir?: string): NodeJS.Require => {\n // Can fail on VSCode extensions\n const { packageJsonPath } = getPackageJsonPath(startDir);\n\n return createRequire(packageJsonPath);\n};\n\n/**\n * Require relative to the @intlayer/config package\n *\n * Note: Can resolve package that are installed in the config package, ex `'@intlayer/types'`\n */\nexport const configESMxCJSRequire: NodeJS.Require = isESModule\n ? createRequire(import.meta.url)\n : require;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ESMxCJSHelpers.cjs","names":["getPackageJsonPath"],"sources":["../../../src/utils/ESMxCJSHelpers.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { getPackageJsonPath } from './getPackageJsonPath';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\n/**\n * Require relative to the user project\n *\n * Note: Can resolve package that are installed in the user project, ex `'intlayer'`\n */\nexport const getProjectRequire = (startDir?: string): NodeJS.Require => {\n // Can fail on VSCode extensions\n const { packageJsonPath } = getPackageJsonPath(startDir);\n\n return createRequire(packageJsonPath);\n};\n\n/**\n * Require relative to the @intlayer/config package\n *\n * Note: Can resolve package that are installed in the config package, ex `'@intlayer/types'`\n */\nexport const configESMxCJSRequire: NodeJS.Require = isESModule\n ? createRequire(import.meta.url)\n : require;\n"],"mappings":"6KAGA,MAAa,EAAa,OAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,MAA2B,SAOxC,EAAqB,GAAsC,CAEtE,GAAM,CAAE,mBAAoBA,EAAAA,mBAAmB,EAAS,CAExD,OAAA,EAAA,EAAA,eAAqB,EAAgB,EAQ1B,EAAuC,GAAA,EAAA,EAAA,eAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,KAClB,CAC9B"}
|
package/dist/cjs/utils/alias.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-D-qHiVGv.cjs`);const e=require(`./getExtension.cjs`),t=require(`./normalizePath.cjs`);let n=require(`node:path`);const r=({configuration:r,format:i,formatter:a=e=>e})=>{let o=e.getExtension(r,i??r.build.outputFormat[0]??`esm`),{baseDir:s}=r.system,{mainDir:c,configDir:l}=r.system,u=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`dictionaries.${o}`)))),d=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`unmerged_dictionaries.${o}`)))),f=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`remote_dictionaries.${o}`)))),p=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`dynamic_dictionaries.${o}`)))),m=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`fetch_dictionaries.${o}`)))),h=a(t.normalizePath((0,n.relative)(s,(0,n.join)(l,`configuration.json`))));return{"@intlayer/dictionaries-entry":u,"@intlayer/unmerged-dictionaries-entry":d,"@intlayer/remote-dictionaries-entry":f,"@intlayer/dynamic-dictionaries-entry":p,"@intlayer/fetch-dictionaries-entry":m,"@intlayer/config/built":h}};exports.getAlias=r;
|
|
2
2
|
//# sourceMappingURL=alias.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias.cjs","names":["getExtension","normalizePath"],"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":"
|
|
1
|
+
{"version":3,"file":"alias.cjs","names":["getExtension","normalizePath"],"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":"sMAWA,MAAa,GAAY,CACvB,gBACA,SACA,YAAa,GAAkB,KACV,CACrB,IAAM,EAAYA,EAAAA,aAChB,EACA,GAAU,EAAc,MAAM,aAAa,IAAM,MAClD,CAEK,CAAE,WAAY,EAAc,OAC5B,CAAE,UAAS,aAAc,EAAc,OAOvC,EAAwB,EAC5BC,EAAAA,eAAAA,EAAAA,EAAAA,UAFwC,GAAA,EAAA,EAAA,MADZ,EAAS,gBAAgB,IAAY,CACC,CAE3B,CACxC,CAaK,EAAgC,EACpCA,EAAAA,eAAAA,EAAAA,EAAAA,UAJA,GAAA,EAAA,EAAA,MAJA,EACA,yBAAyB,IAC1B,CAIA,CAEgD,CAChD,CAaK,EAA8B,EAClCA,EAAAA,eAAAA,EAAAA,EAAAA,UAJA,GAAA,EAAA,EAAA,MAJA,EACA,uBAAuB,IACxB,CAIA,CAE8C,CAC9C,CAaK,EAA+B,EACnCA,EAAAA,eAAAA,EAAAA,EAAAA,UAJA,GAAA,EAAA,EAAA,MAJA,EACA,wBAAwB,IACzB,CAIA,CAE+C,CAC/C,CAaK,EAA6B,EACjCA,EAAAA,eAAAA,EAAAA,EAAAA,UAJA,GAAA,EAAA,EAAA,MAJA,EACA,sBAAsB,IACvB,CAIA,CAE6C,CAC7C,CAOK,EAAyB,EAC7BA,EAAAA,eAAAA,EAAAA,EAAAA,UAFyC,GAAA,EAAA,EAAA,MADZ,EAAW,qBAAqB,CACO,CAE5B,CACzC,CAED,MAAO,CACL,+BAAgC,EAChC,wCAAyC,EACzC,sCAAuC,EACvC,uCAAwC,EACxC,qCAAsC,EACtC,yBAA0B,EAC3B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-D-qHiVGv.cjs`),t=require(`./cacheMemory.cjs`);let n=require(`node:path`),r=require(`@intlayer/types/package.json`);r=e.n(r);let i=require(`node:fs/promises`),a=require(`node:v8`),o=require(`node:zlib`);const s={compress:!0},c=async e=>{await(0,i.mkdir)(e,{recursive:!0})},l=async(e,t,r)=>{if(r)try{await c(r)}catch{}let a=`${(0,n.basename)(e)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`,o=r?(0,n.join)(r,a):`${e}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;try{await(0,i.writeFile)(o,t),await(0,i.rename)(o,e)}catch(e){try{await(0,i.rm)(o,{force:!0})}catch{}throw e}},u=(e,t)=>t===!0||t!==!1&&e.byteLength>1024,d=(e,t,r)=>(0,n.join)(e,r?(0,n.join)(r,t):t),f=new Map,p=(e,p,m)=>{let{cacheDir:h,tempDir:g}=e.system,_=e.build.cache??!0,v=m?.persistent===!0||m?.persistent===void 0&&_,{compress:y,ttlMs:b,maxTimeMs:x,namespace:S}={...s,...m},C=t.computeKeyId(p),w=d(h,C,S),T=async()=>{try{let e=await(0,i.stat)(w).catch(()=>void 0);if(!e||typeof b==`number`&&b>0&&Date.now()-e.mtimeMs>b)return;let t=await(0,i.readFile)(w),n=t[0];t=t.subarray(1);let s=(0,a.deserialize)(n===1?(0,o.gunzipSync)(t):t),c,l=s;if(l&&typeof l==`object`&&typeof l.version==`string`&&typeof l.timestamp==`number`&&Object.hasOwn(l,`data`)){let e=l;if(e.version!==r.default.version){try{await(0,i.unlink)(w)}catch{}return}if(typeof x==`number`&&x>0&&Date.now()-e.timestamp>x){try{await(0,i.unlink)(w)}catch{}return}c=e.data}else{if(typeof x==`number`&&x>0&&Date.now()-e.mtimeMs>x){try{await(0,i.unlink)(w)}catch{}return}c=s}return f.set(C,c),c}catch{return}},E=async e=>{try{await c((0,n.dirname)(w));let t={version:r.default.version,timestamp:Date.now(),data:e},i=Buffer.from((0,a.serialize)(t)),s=u(i,y)?(0,o.gzipSync)(i):i;await l(w,Buffer.concat([Buffer.from([s===i?0:1]),s]),g)}catch{}};return{get:async()=>{let e=f.get(C);if(e!==void 0)return e;if(v&&_)return await T()},set:async e=>{f.set(C,e),v&&_&&await E(e)},clear:async()=>{f.delete(C);try{await(0,i.unlink)(w)}catch{}},clearAll:async()=>{if(t.clearAllCache(),v&&_){let e=S?(0,n.join)(h,S):h;try{await(0,i.rm)(e,{recursive:!0,force:!0})}catch{}try{await(0,i.mkdir)(e,{recursive:!0})}catch{}}},isValid:async()=>{if(f.get(C)!==void 0)return!0;if(!v||!_)return!1;try{let e=await(0,i.stat)(w).catch(()=>void 0);if(!e||typeof b==`number`&&b>0&&Date.now()-e.mtimeMs>b)return!1;let t=await(0,i.readFile)(w),n=t[0];t=t.subarray(1);let s=(0,a.deserialize)(n===1?(0,o.gunzipSync)(t):t);if(s&&typeof s==`object`&&typeof s.version==`string`&&typeof s.timestamp==`number`&&Object.hasOwn(s,`data`)){let e=s;return!(e.version!==r.default.version||typeof x==`number`&&x>0&&Date.now()-e.timestamp>x)}return!(typeof x==`number`&&x>0&&Date.now()-e.mtimeMs>x)}catch{return!1}},id:C,filePath:w}};exports.cacheDisk=p;
|
|
2
2
|
//# sourceMappingURL=cacheDisk.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheDisk.cjs","names":["computeKeyId","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":"yTA2CA,MAAM,EAA0D,CAC9D,SAAU,GACX,CAEK,EAAY,KAAO,IAAgB,CACvC,MAAA,E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9B,OAAO,OAAO,EAAU,OAAO,CAEjB,CACd,IAAM,EAAQ,EAOd,MAJA,EAFI,EAAM,UAAYA,EAAAA,QAAkB,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.cjs","names":["computeKeyId","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,\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AI,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,EAAAA,QAAkB,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,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-D-qHiVGv.cjs`);let e=require(`node:crypto`);const t=(()=>{try{return(0,e.createHash)(`xxhash64`).update(`test`).digest(),`xxhash64`}catch{}try{return(0,e.createHash)(`sha1`).update(`test`).digest(),`sha1`}catch{}return`sha256`})(),n=e=>e.toString(`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``),r={start:(e,t)=>e.update(`<${t}>`),sep:e=>e.update(`|`),end:(e,t)=>e.update(`</${t}>`),str:(e,t)=>{e.update(`${t.length}#`),e.update(t)},num:(e,t)=>e.update(Number.isNaN(t)?`NaN`:t===1/0?`Inf`:t===-1/0?`-Inf`:String(t)),big:(e,t)=>e.update(t.toString(10)),bool:(e,t)=>e.update(t?`1`:`0`)},i=(e,t,n)=>{let o=typeof t;if(t===null){r.start(e,`null`),r.end(e,`null`);return}if(o===`undefined`){r.start(e,`undef`),r.end(e,`undef`);return}if(o===`number`){r.start(e,`num`),r.num(e,t),r.end(e,`num`);return}if(o===`bigint`){r.start(e,`big`),r.big(e,t),r.end(e,`big`);return}if(o===`boolean`){r.start(e,`bool`),r.bool(e,t),r.end(e,`bool`);return}if(o===`string`){r.start(e,`str`),r.str(e,t),r.end(e,`str`);return}if(o===`symbol`){r.start(e,`sym`),r.str(e,String(t)),r.end(e,`sym`);return}if(o===`function`){let n=t;r.start(e,`fn`),r.str(e,n.name??``),r.sep(e),r.num(e,n.length),r.end(e,`fn`);return}if(Array.isArray(t)){if(n.has(t)){r.start(e,`arr`),r.str(e,`Circular`),r.end(e,`arr`);return}n.add(t),r.start(e,`arr`);for(let a=0;a<t.length;a++)r.sep(e),i(e,t[a],n);r.end(e,`arr`),n.delete(t);return}if(t instanceof Date){r.start(e,`date`),r.str(e,t.toISOString()),r.end(e,`date`);return}if(t instanceof RegExp){let n=t;r.start(e,`re`),r.str(e,n.source),r.sep(e),r.str(e,n.flags),r.end(e,`re`);return}if(t instanceof Set){let i=t;if(n.has(i)){r.start(e,`set`),r.str(e,`Circular`),r.end(e,`set`);return}n.add(i);let o=[];for(let e of i)o.push(a(e));o.sort(),r.start(e,`set`);for(let t of o)r.sep(e),r.str(e,t);r.end(e,`set`),n.delete(i);return}if(t instanceof Map){let o=t;if(n.has(o)){r.start(e,`map`),r.str(e,`Circular`),r.end(e,`map`);return}n.add(o);let s=[];for(let[e,t]of o.entries())s.push([a(e),t]);s.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),r.start(e,`map`);for(let[t,a]of s)r.sep(e),r.str(e,t),r.sep(e),i(e,a,n);r.end(e,`map`),n.delete(o);return}if(ArrayBuffer.isView(t)){let n=t;r.start(e,`typed`),r.str(e,Object.getPrototypeOf(n).constructor.name),r.sep(e),e.update(Buffer.from(n.buffer,n.byteOffset,n.byteLength)),r.end(e,`typed`);return}if(t instanceof ArrayBuffer){let n=Buffer.from(t);r.start(e,`ab`),e.update(n),r.end(e,`ab`);return}if(typeof URL<`u`&&t instanceof URL){r.start(e,`url`),r.str(e,t.toString()),r.end(e,`url`);return}if(t instanceof Error){let n=t;r.start(e,`err`),r.str(e,n.name||``),r.sep(e),r.str(e,n.message||``),r.sep(e),r.str(e,n.stack||``),r.end(e,`err`);return}if(o===`object`){let a=t;if(n.has(a)){r.start(e,`obj`),r.str(e,`Circular`),r.end(e,`obj`);return}n.add(a);let o=Object.keys(a).sort();r.start(e,`obj`);for(let t of o)r.sep(e),r.str(e,t),r.sep(e),i(e,a[t],n);r.end(e,`obj`),n.delete(a);return}r.start(e,`other`),r.str(e,String(t)),r.end(e,`other`)},a=(r,a=new WeakSet)=>{let o=(0,e.createHash)(t);return i(o,r,a),n(o.digest())},o=a=>{let o=(0,e.createHash)(t);r.start(o,`keys`);for(let e=0;e<a.length;e++)r.sep(o),i(o,a[e],new WeakSet);return r.end(o,`keys`),n(o.digest())},s=new Map,c=(...e)=>s.get(o(e)),l=(...e)=>{let t=e[e.length-1],n=e.slice(0,-1);s.set(o(n),t)},u=e=>{s.delete(e)},d=()=>{s.clear()},f={get:c,set:l,clear:u};exports.cacheMemory=f,exports.clearAllCache=d,exports.clearCache=u,exports.computeKeyId=o,exports.getCache=c,exports.setCache=l,exports.stableStringify=a;
|
|
2
2
|
//# sourceMappingURL=cacheMemory.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheMemory.cjs","names":[],"sources":["../../../src/utils/cacheMemory.ts"],"sourcesContent":["import { createHash, type Hash } from 'node:crypto';\n\n/** ------------------------- Utilities ------------------------- **/\n\n/** Prefer a fast non-crypto hash if available, then fast crypto, then sha256. */\nconst pickHashAlgorithm = (): string => {\n try {\n // Node 20+ supports xxhash64 (very fast). We feature-detect at module load.\n createHash('xxhash64').update('test').digest();\n return 'xxhash64';\n } catch {}\n try {\n // sha1 is faster than sha256 and sufficient for cache keys.\n createHash('sha1').update('test').digest();\n return 'sha1';\n } catch {}\n\n return 'sha256';\n};\nconst HASH_ALGORITHM = pickHashAlgorithm();\n\n/** Base64url without padding for compact, file-system-safe ids. */\nconst toBase64Url = (buffer: Buffer): string =>\n buffer\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/g, '');\n\n/** Token helpers to minimize collisions while streaming to the hasher. */\nconst token = {\n start: (hasher: Hash, tag: string) => hasher.update(`<${tag}>`),\n sep: (hasher: Hash) => hasher.update('|'),\n end: (hasher: Hash, tag: string) => hasher.update(`</${tag}>`),\n str: (hasher: Hash, stringValue: string) => {\n // length prefix to avoid ambiguity: len#value\n hasher.update(`${stringValue.length}#`);\n hasher.update(stringValue);\n },\n num: (hasher: Hash, numberValue: number) =>\n hasher.update(\n Number.isNaN(numberValue)\n ? 'NaN'\n : numberValue === Infinity\n ? 'Inf'\n : numberValue === -Infinity\n ? '-Inf'\n : String(numberValue)\n ),\n big: (hasher: Hash, bigintValue: bigint) =>\n hasher.update(bigintValue.toString(10)),\n bool: (hasher: Hash, booleanValue: boolean) =>\n hasher.update(booleanValue ? '1' : '0'),\n};\n\n/** ------------------- Canonical, streaming hasher ------------------- **/\n\ntype Seen = WeakSet<object>;\n\n/**\n * Streams a canonical representation of `value` into `hasher` without\n * constructing large intermediate strings. Objects/Maps/Sets are normalized.\n */\nconst stableHashValue = (hasher: Hash, value: unknown, seen: Seen): void => {\n const valueType = typeof value;\n\n if (value === null) {\n token.start(hasher, 'null');\n token.end(hasher, 'null');\n return;\n }\n\n if (valueType === 'undefined') {\n token.start(hasher, 'undef');\n token.end(hasher, 'undef');\n return;\n }\n\n if (valueType === 'number') {\n token.start(hasher, 'num');\n token.num(hasher, value as number);\n token.end(hasher, 'num');\n return;\n }\n\n if (valueType === 'bigint') {\n token.start(hasher, 'big');\n token.big(hasher, value as bigint);\n token.end(hasher, 'big');\n return;\n }\n\n if (valueType === 'boolean') {\n token.start(hasher, 'bool');\n token.bool(hasher, value as boolean);\n token.end(hasher, 'bool');\n return;\n }\n\n if (valueType === 'string') {\n token.start(hasher, 'str');\n token.str(hasher, value as string);\n token.end(hasher, 'str');\n return;\n }\n\n if (valueType === 'symbol') {\n token.start(hasher, 'sym');\n token.str(hasher, String(value));\n token.end(hasher, 'sym');\n return;\n }\n\n if (valueType === 'function') {\n // Stable-ish fingerprint: name and arity (avoid source text).\n const functionValue = value as Function;\n token.start(hasher, 'fn');\n token.str(hasher, functionValue.name ?? '');\n token.sep(hasher);\n token.num(hasher, functionValue.length);\n token.end(hasher, 'fn');\n return;\n }\n\n // Arrays and typed arrays\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n token.start(hasher, 'arr');\n token.str(hasher, 'Circular');\n token.end(hasher, 'arr');\n return;\n }\n seen.add(value);\n token.start(hasher, 'arr');\n for (let i = 0; i < value.length; i++) {\n token.sep(hasher);\n stableHashValue(hasher, value[i], seen);\n }\n token.end(hasher, 'arr');\n seen.delete(value);\n return;\n }\n\n // Node/Builtins\n if (value instanceof Date) {\n token.start(hasher, 'date');\n token.str(hasher, (value as Date).toISOString());\n token.end(hasher, 'date');\n return;\n }\n\n if (value instanceof RegExp) {\n const regex = value as RegExp;\n token.start(hasher, 're');\n token.str(hasher, regex.source);\n token.sep(hasher);\n token.str(hasher, regex.flags);\n token.end(hasher, 're');\n return;\n }\n\n if (value instanceof Set) {\n const setValue = value as Set<unknown>;\n if (seen.has(setValue)) {\n token.start(hasher, 'set');\n token.str(hasher, 'Circular');\n token.end(hasher, 'set');\n return;\n }\n seen.add(setValue);\n // Normalize by item fingerprints (strings) to sort deterministically.\n const items: string[] = [];\n for (const v of setValue) items.push(stableStringify(v)); // small, bounded use of stringify\n items.sort();\n token.start(hasher, 'set');\n for (const item of items) {\n token.sep(hasher);\n token.str(hasher, item);\n }\n token.end(hasher, 'set');\n seen.delete(setValue);\n return;\n }\n\n if (value instanceof Map) {\n const mapObject = value as Map<unknown, unknown>;\n if (seen.has(mapObject)) {\n token.start(hasher, 'map');\n token.str(hasher, 'Circular');\n token.end(hasher, 'map');\n return;\n }\n seen.add(mapObject);\n // Normalize by sorted key fingerprints.\n const entries: Array<[string, unknown]> = [];\n for (const [k, v] of mapObject.entries())\n entries.push([stableStringify(k), v]);\n entries.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));\n token.start(hasher, 'map');\n for (const [keyFingerprint, entryValue] of entries) {\n token.sep(hasher);\n token.str(hasher, keyFingerprint);\n token.sep(hasher);\n stableHashValue(hasher, entryValue, seen);\n }\n token.end(hasher, 'map');\n seen.delete(mapObject);\n return;\n }\n\n // ArrayBuffer & typed arrays\n if (ArrayBuffer.isView(value)) {\n const view = value as ArrayBufferView;\n token.start(hasher, 'typed');\n token.str(hasher, Object.getPrototypeOf(view).constructor.name);\n token.sep(hasher);\n hasher.update(Buffer.from(view.buffer, view.byteOffset, view.byteLength));\n token.end(hasher, 'typed');\n return;\n }\n if (value instanceof ArrayBuffer) {\n const buffer = Buffer.from(value as ArrayBuffer);\n token.start(hasher, 'ab');\n hasher.update(buffer);\n token.end(hasher, 'ab');\n return;\n }\n\n // URL\n if (typeof URL !== 'undefined' && value instanceof URL) {\n token.start(hasher, 'url');\n token.str(hasher, (value as URL).toString());\n token.end(hasher, 'url');\n return;\n }\n\n // Errors\n if (value instanceof Error) {\n const errorValue = value as Error;\n token.start(hasher, 'err');\n token.str(hasher, errorValue.name || '');\n token.sep(hasher);\n token.str(hasher, errorValue.message || '');\n token.sep(hasher);\n token.str(hasher, errorValue.stack || '');\n token.end(hasher, 'err');\n return;\n }\n\n // Generic objects\n if (valueType === 'object') {\n const objectValue = value as Record<string, unknown>;\n if (seen.has(objectValue)) {\n token.start(hasher, 'obj');\n token.str(hasher, 'Circular');\n token.end(hasher, 'obj');\n return;\n }\n seen.add(objectValue);\n\n const keys = Object.keys(objectValue).sort();\n token.start(hasher, 'obj');\n for (const key of keys) {\n token.sep(hasher);\n token.str(hasher, key);\n token.sep(hasher);\n stableHashValue(hasher, (objectValue as any)[key], seen);\n }\n token.end(hasher, 'obj');\n\n seen.delete(objectValue);\n return;\n }\n\n // Fallback\n token.start(hasher, 'other');\n token.str(hasher, String(value));\n token.end(hasher, 'other');\n};\n\n/** Public stringify kept for convenience / debugging (now faster & broader). */\nexport const stableStringify = (\n value: unknown,\n _stack = new WeakSet<object>()\n): string => {\n const hasher = createHash(HASH_ALGORITHM);\n stableHashValue(hasher, value, _stack);\n return toBase64Url(hasher.digest());\n};\n\n/** Compute a compact, stable id for arbitrary key tuples. */\nexport const computeKeyId = (keyParts: unknown[]): string => {\n const h = createHash(HASH_ALGORITHM);\n token.start(h, 'keys');\n for (let i = 0; i < keyParts.length; i++) {\n token.sep(h);\n stableHashValue(h, keyParts[i], new WeakSet());\n }\n token.end(h, 'keys');\n return toBase64Url(h.digest());\n};\n\n/** ------------------------- In-memory cache ------------------------- **/\n\nexport type CacheKey = unknown;\nconst cacheMap = new Map<string, any>();\n\nexport const getCache = <T>(...key: CacheKey[]): T | undefined => {\n return cacheMap.get(computeKeyId(key));\n};\n\ntype CacheSetArgs<T> = [...keys: CacheKey[], value: T];\n\nexport const setCache = <T>(...args: CacheSetArgs<T>): void => {\n const value = args[args.length - 1] as T;\n const key = args.slice(0, -1) as CacheKey[];\n cacheMap.set(computeKeyId(key), value);\n};\n\nexport const clearCache = (idOrKey: string): void => {\n // Accept either our computed id or a legacy string id the caller already computed.\n cacheMap.delete(idOrKey);\n};\n\nexport const clearAllCache = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheMemory = {\n get: getCache,\n set: setCache,\n clear: clearCache,\n};\n"],"mappings":"6IAmBA,MAAM,OAdkC,CACtC,GAAI,CAGF,OADA,EAAA,EAAA,YAAW,WAAW,CAAC,OAAO,OAAO,CAAC,QAAQ,CACvC,gBACD,EACR,GAAI,CAGF,OADA,EAAA,EAAA,YAAW,OAAO,CAAC,OAAO,OAAO,CAAC,QAAQ,CACnC,YACD,EAER,MAAO,YAEiC,CAGpC,EAAe,GACnB,EACG,SAAS,SAAS,CAClB,QAAQ,MAAO,IAAI,CACnB,QAAQ,MAAO,IAAI,CACnB,QAAQ,OAAQ,GAAG,CAGlB,EAAQ,CACZ,OAAQ,EAAc,IAAgB,EAAO,OAAO,IAAI,EAAI,GAAG,CAC/D,IAAM,GAAiB,EAAO,OAAO,IAAI,CACzC,KAA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ACX,EACA,EAAS,IAAI,UACF,CACX,IAAM,GAAA,EAAA,EAAA,YAAoB,EAAe,CAEzC,OADA,EAAgB,EAAQ,EAAO,EAAO,CAC/B,EAAY,EAAO,QAAQ,CAAC,EAIxB,EAAgB,GAAgC,CAC3D,IAAM,GAAA,EAAA,EAAA,YAAe,EAAe,CACpC,EAAM,MAAM,EAAG,OAAO,CACtB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAS,OAAQ,IACnC,EAAM,IAAI,EAAE,CACZ,EAAgB,EAAG,EAAS,GAAI,IAAI,QAAU,CAGhD,OADA,EAAM,IAAI,EAAG,OAAO,CACb,EAAY,EAAE,QAAQ,CAAC,EAM1B,EAAW,IAAI,IAER,GAAe,GAAG,IACtB,EAAS,IAAI,EAAa,EAAI,CAAC,CAK3B,GAAe,GAAG,IAAgC,CAC7D,IAAM,EAAQ,EAAK,EAAK,OAAS,GAC3B,EAAM,EAAK,MAAM,EAAG,GAAG,CAC7B,EAAS,IAAI,EAAa,EAAI,CAAE,EAAM,EAG3B,EAAc,GAA0B,CAEnD,EAAS,OAAO,EAAQ,EAGb,MAA4B,CACvC,EAAS,OAAO,EAGL,EAAc,CACzB,IAAK,EACL,IAAK,EACL,MAAO,EACR"}
|
|
1
|
+
{"version":3,"file":"cacheMemory.cjs","names":[],"sources":["../../../src/utils/cacheMemory.ts"],"sourcesContent":["import { createHash, type Hash } from 'node:crypto';\n\n/** ------------------------- Utilities ------------------------- **/\n\n/** Prefer a fast non-crypto hash if available, then fast crypto, then sha256. */\nconst pickHashAlgorithm = (): string => {\n try {\n // Node 20+ supports xxhash64 (very fast). We feature-detect at module load.\n createHash('xxhash64').update('test').digest();\n return 'xxhash64';\n } catch {}\n try {\n // sha1 is faster than sha256 and sufficient for cache keys.\n createHash('sha1').update('test').digest();\n return 'sha1';\n } catch {}\n\n return 'sha256';\n};\nconst HASH_ALGORITHM = pickHashAlgorithm();\n\n/** Base64url without padding for compact, file-system-safe ids. */\nconst toBase64Url = (buffer: Buffer): string =>\n buffer\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/g, '');\n\n/** Token helpers to minimize collisions while streaming to the hasher. */\nconst token = {\n start: (hasher: Hash, tag: string) => hasher.update(`<${tag}>`),\n sep: (hasher: Hash) => hasher.update('|'),\n end: (hasher: Hash, tag: string) => hasher.update(`</${tag}>`),\n str: (hasher: Hash, stringValue: string) => {\n // length prefix to avoid ambiguity: len#value\n hasher.update(`${stringValue.length}#`);\n hasher.update(stringValue);\n },\n num: (hasher: Hash, numberValue: number) =>\n hasher.update(\n Number.isNaN(numberValue)\n ? 'NaN'\n : numberValue === Infinity\n ? 'Inf'\n : numberValue === -Infinity\n ? '-Inf'\n : String(numberValue)\n ),\n big: (hasher: Hash, bigintValue: bigint) =>\n hasher.update(bigintValue.toString(10)),\n bool: (hasher: Hash, booleanValue: boolean) =>\n hasher.update(booleanValue ? '1' : '0'),\n};\n\n/** ------------------- Canonical, streaming hasher ------------------- **/\n\ntype Seen = WeakSet<object>;\n\n/**\n * Streams a canonical representation of `value` into `hasher` without\n * constructing large intermediate strings. Objects/Maps/Sets are normalized.\n */\nconst stableHashValue = (hasher: Hash, value: unknown, seen: Seen): void => {\n const valueType = typeof value;\n\n if (value === null) {\n token.start(hasher, 'null');\n token.end(hasher, 'null');\n return;\n }\n\n if (valueType === 'undefined') {\n token.start(hasher, 'undef');\n token.end(hasher, 'undef');\n return;\n }\n\n if (valueType === 'number') {\n token.start(hasher, 'num');\n token.num(hasher, value as number);\n token.end(hasher, 'num');\n return;\n }\n\n if (valueType === 'bigint') {\n token.start(hasher, 'big');\n token.big(hasher, value as bigint);\n token.end(hasher, 'big');\n return;\n }\n\n if (valueType === 'boolean') {\n token.start(hasher, 'bool');\n token.bool(hasher, value as boolean);\n token.end(hasher, 'bool');\n return;\n }\n\n if (valueType === 'string') {\n token.start(hasher, 'str');\n token.str(hasher, value as string);\n token.end(hasher, 'str');\n return;\n }\n\n if (valueType === 'symbol') {\n token.start(hasher, 'sym');\n token.str(hasher, String(value));\n token.end(hasher, 'sym');\n return;\n }\n\n if (valueType === 'function') {\n // Stable-ish fingerprint: name and arity (avoid source text).\n const functionValue = value as Function;\n token.start(hasher, 'fn');\n token.str(hasher, functionValue.name ?? '');\n token.sep(hasher);\n token.num(hasher, functionValue.length);\n token.end(hasher, 'fn');\n return;\n }\n\n // Arrays and typed arrays\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n token.start(hasher, 'arr');\n token.str(hasher, 'Circular');\n token.end(hasher, 'arr');\n return;\n }\n seen.add(value);\n token.start(hasher, 'arr');\n for (let i = 0; i < value.length; i++) {\n token.sep(hasher);\n stableHashValue(hasher, value[i], seen);\n }\n token.end(hasher, 'arr');\n seen.delete(value);\n return;\n }\n\n // Node/Builtins\n if (value instanceof Date) {\n token.start(hasher, 'date');\n token.str(hasher, (value as Date).toISOString());\n token.end(hasher, 'date');\n return;\n }\n\n if (value instanceof RegExp) {\n const regex = value as RegExp;\n token.start(hasher, 're');\n token.str(hasher, regex.source);\n token.sep(hasher);\n token.str(hasher, regex.flags);\n token.end(hasher, 're');\n return;\n }\n\n if (value instanceof Set) {\n const setValue = value as Set<unknown>;\n if (seen.has(setValue)) {\n token.start(hasher, 'set');\n token.str(hasher, 'Circular');\n token.end(hasher, 'set');\n return;\n }\n seen.add(setValue);\n // Normalize by item fingerprints (strings) to sort deterministically.\n const items: string[] = [];\n for (const v of setValue) items.push(stableStringify(v)); // small, bounded use of stringify\n items.sort();\n token.start(hasher, 'set');\n for (const item of items) {\n token.sep(hasher);\n token.str(hasher, item);\n }\n token.end(hasher, 'set');\n seen.delete(setValue);\n return;\n }\n\n if (value instanceof Map) {\n const mapObject = value as Map<unknown, unknown>;\n if (seen.has(mapObject)) {\n token.start(hasher, 'map');\n token.str(hasher, 'Circular');\n token.end(hasher, 'map');\n return;\n }\n seen.add(mapObject);\n // Normalize by sorted key fingerprints.\n const entries: Array<[string, unknown]> = [];\n for (const [k, v] of mapObject.entries())\n entries.push([stableStringify(k), v]);\n entries.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));\n token.start(hasher, 'map');\n for (const [keyFingerprint, entryValue] of entries) {\n token.sep(hasher);\n token.str(hasher, keyFingerprint);\n token.sep(hasher);\n stableHashValue(hasher, entryValue, seen);\n }\n token.end(hasher, 'map');\n seen.delete(mapObject);\n return;\n }\n\n // ArrayBuffer & typed arrays\n if (ArrayBuffer.isView(value)) {\n const view = value as ArrayBufferView;\n token.start(hasher, 'typed');\n token.str(hasher, Object.getPrototypeOf(view).constructor.name);\n token.sep(hasher);\n hasher.update(Buffer.from(view.buffer, view.byteOffset, view.byteLength));\n token.end(hasher, 'typed');\n return;\n }\n if (value instanceof ArrayBuffer) {\n const buffer = Buffer.from(value as ArrayBuffer);\n token.start(hasher, 'ab');\n hasher.update(buffer);\n token.end(hasher, 'ab');\n return;\n }\n\n // URL\n if (typeof URL !== 'undefined' && value instanceof URL) {\n token.start(hasher, 'url');\n token.str(hasher, (value as URL).toString());\n token.end(hasher, 'url');\n return;\n }\n\n // Errors\n if (value instanceof Error) {\n const errorValue = value as Error;\n token.start(hasher, 'err');\n token.str(hasher, errorValue.name || '');\n token.sep(hasher);\n token.str(hasher, errorValue.message || '');\n token.sep(hasher);\n token.str(hasher, errorValue.stack || '');\n token.end(hasher, 'err');\n return;\n }\n\n // Generic objects\n if (valueType === 'object') {\n const objectValue = value as Record<string, unknown>;\n if (seen.has(objectValue)) {\n token.start(hasher, 'obj');\n token.str(hasher, 'Circular');\n token.end(hasher, 'obj');\n return;\n }\n seen.add(objectValue);\n\n const keys = Object.keys(objectValue).sort();\n token.start(hasher, 'obj');\n for (const key of keys) {\n token.sep(hasher);\n token.str(hasher, key);\n token.sep(hasher);\n stableHashValue(hasher, (objectValue as any)[key], seen);\n }\n token.end(hasher, 'obj');\n\n seen.delete(objectValue);\n return;\n }\n\n // Fallback\n token.start(hasher, 'other');\n token.str(hasher, String(value));\n token.end(hasher, 'other');\n};\n\n/** Public stringify kept for convenience / debugging (now faster & broader). */\nexport const stableStringify = (\n value: unknown,\n _stack = new WeakSet<object>()\n): string => {\n const hasher = createHash(HASH_ALGORITHM);\n stableHashValue(hasher, value, _stack);\n return toBase64Url(hasher.digest());\n};\n\n/** Compute a compact, stable id for arbitrary key tuples. */\nexport const computeKeyId = (keyParts: unknown[]): string => {\n const h = createHash(HASH_ALGORITHM);\n token.start(h, 'keys');\n for (let i = 0; i < keyParts.length; i++) {\n token.sep(h);\n stableHashValue(h, keyParts[i], new WeakSet());\n }\n token.end(h, 'keys');\n return toBase64Url(h.digest());\n};\n\n/** ------------------------- In-memory cache ------------------------- **/\n\nexport type CacheKey = unknown;\nconst cacheMap = new Map<string, any>();\n\nexport const getCache = <T>(...key: CacheKey[]): T | undefined => {\n return cacheMap.get(computeKeyId(key));\n};\n\ntype CacheSetArgs<T> = [...keys: CacheKey[], value: T];\n\nexport const setCache = <T>(...args: CacheSetArgs<T>): void => {\n const value = args[args.length - 1] as T;\n const key = args.slice(0, -1) as CacheKey[];\n cacheMap.set(computeKeyId(key), value);\n};\n\nexport const clearCache = (idOrKey: string): void => {\n // Accept either our computed id or a legacy string id the caller already computed.\n cacheMap.delete(idOrKey);\n};\n\nexport const clearAllCache = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheMemory = {\n get: getCache,\n set: setCache,\n clear: clearCache,\n};\n"],"mappings":"iIAmBA,MAAM,OAdkC,CACtC,GAAI,CAGF,OADA,EAAA,EAAA,YAAW,WAAW,CAAC,OAAO,OAAO,CAAC,QAAQ,CACvC,gBACD,EACR,GAAI,CAGF,OADA,EAAA,EAAA,YAAW,OAAO,CAAC,OAAO,OAAO,CAAC,QAAQ,CACnC,YACD,EAER,MAAO,YAEiC,CAGpC,EAAe,GACnB,EACG,SAAS,SAAS,CAClB,QAAQ,MAAO,IAAI,CACnB,QAAQ,MAAO,IAAI,CACnB,QAAQ,OAAQ,GAAG,CAGlB,EAAQ,CACZ,OAAQ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,QAAQ,CAC5B,EAAM,IAAI,EAAQ,OAAO,EAAM,CAAC,CAChC,EAAM,IAAI,EAAQ,QAAQ,EAIf,GACX,EACA,EAAS,IAAI,UACF,CACX,IAAM,GAAA,EAAA,EAAA,YAAoB,EAAe,CAEzC,OADA,EAAgB,EAAQ,EAAO,EAAO,CAC/B,EAAY,EAAO,QAAQ,CAAC,EAIxB,EAAgB,GAAgC,CAC3D,IAAM,GAAA,EAAA,EAAA,YAAe,EAAe,CACpC,EAAM,MAAM,EAAG,OAAO,CACtB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAS,OAAQ,IACnC,EAAM,IAAI,EAAE,CACZ,EAAgB,EAAG,EAAS,GAAI,IAAI,QAAU,CAGhD,OADA,EAAM,IAAI,EAAG,OAAO,CACb,EAAY,EAAE,QAAQ,CAAC,EAM1B,EAAW,IAAI,IAER,GAAe,GAAG,IACtB,EAAS,IAAI,EAAa,EAAI,CAAC,CAK3B,GAAe,GAAG,IAAgC,CAC7D,IAAM,EAAQ,EAAK,EAAK,OAAS,GAC3B,EAAM,EAAK,MAAM,EAAG,GAAG,CAC7B,EAAS,IAAI,EAAa,EAAI,CAAE,EAAM,EAG3B,EAAc,GAA0B,CAEnD,EAAS,OAAO,EAAQ,EAGb,MAA4B,CACvC,EAAS,OAAO,EAGL,EAAc,CACzB,IAAK,EACL,IAAK,EACL,MAAO,EACR"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-D-qHiVGv.cjs`);const e=require(`./cacheMemory.cjs`);let t=require(`node:fs`),n=require(`node:path`);const r=(r=process.cwd())=>{let i=e.cacheMemory.get(`packageJsonPath`,r);if(i)return i;let a=r;for(let i=0;i<15;i++){let i=(0,n.join)(a,`package.json`);if((0,t.existsSync)(i))return e.cacheMemory.set(`packageJsonPath`,r,{packageJsonPath:i,baseDir:a}),{packageJsonPath:i,baseDir:a};let o=(0,n.dirname)(a);if(o===a)break;a=o}throw Error(`Could not find package.json in current directory or any of the 15 parent directories. Searched from: ${r}`)};exports.getPackageJsonPath=r;
|
|
2
2
|
//# sourceMappingURL=getPackageJsonPath.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageJsonPath.cjs","names":["cacheMemory"],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { cacheMemory } from './cacheMemory';\n\nconst MAX_LEVELS = 15;\n\ntype PackageJsonPathCache = {\n packageJsonPath: string;\n baseDir: string;\n};\n\nexport const getPackageJsonPath = (\n startDir: string = process.cwd()\n): PackageJsonPathCache => {\n const checkedCache = cacheMemory.get<PackageJsonPathCache>(\n 'packageJsonPath',\n startDir\n );\n\n if (checkedCache) return checkedCache;\n\n let currentDir = startDir;\n\n for (let level = 0; level < MAX_LEVELS; level++) {\n const packageJsonPath = join(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n cacheMemory.set('packageJsonPath', startDir, {\n packageJsonPath,\n baseDir: currentDir,\n });\n\n return { packageJsonPath, baseDir: currentDir };\n }\n\n const parentDir = dirname(currentDir);\n\n // If we've reached the root directory, stop\n if (parentDir === currentDir) {\n break;\n }\n\n currentDir = parentDir;\n }\n\n throw new Error(\n `Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPackageJsonPath.cjs","names":["cacheMemory"],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { cacheMemory } from './cacheMemory';\n\nconst MAX_LEVELS = 15;\n\ntype PackageJsonPathCache = {\n packageJsonPath: string;\n baseDir: string;\n};\n\nexport const getPackageJsonPath = (\n startDir: string = process.cwd()\n): PackageJsonPathCache => {\n const checkedCache = cacheMemory.get<PackageJsonPathCache>(\n 'packageJsonPath',\n startDir\n );\n\n if (checkedCache) return checkedCache;\n\n let currentDir = startDir;\n\n for (let level = 0; level < MAX_LEVELS; level++) {\n const packageJsonPath = join(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n cacheMemory.set('packageJsonPath', startDir, {\n packageJsonPath,\n baseDir: currentDir,\n });\n\n return { packageJsonPath, baseDir: currentDir };\n }\n\n const parentDir = dirname(currentDir);\n\n // If we've reached the root directory, stop\n if (parentDir === currentDir) {\n break;\n }\n\n currentDir = parentDir;\n }\n\n throw new Error(\n `Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`\n );\n};\n"],"mappings":"yLAIA,MAOa,GACX,EAAmB,QAAQ,KAAK,GACP,CACzB,IAAM,EAAeA,EAAAA,YAAY,IAC/B,kBACA,EACD,CAED,GAAI,EAAc,OAAO,EAEzB,IAAI,EAAa,EAEjB,IAAK,IAAI,EAAQ,EAAG,EAAQ,GAAY,IAAS,CAC/C,IAAM,GAAA,EAAA,EAAA,MAAuB,EAAY,eAAe,CAExD,IAAA,EAAA,EAAA,YAAe,EAAgB,CAM7B,OALA,EAAA,YAAY,IAAI,kBAAmB,EAAU,CAC3C,kBACA,QAAS,EACV,CAAC,CAEK,CAAE,kBAAiB,QAAS,EAAY,CAGjD,IAAM,GAAA,EAAA,EAAA,SAAoB,EAAW,CAGrC,GAAI,IAAc,EAChB,MAGF,EAAa,EAGf,MAAU,MACR,wGAAmH,IACpH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});export{t
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});export{n,t};
|
package/dist/esm/client.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizePath as e}from"./utils/normalizePath.mjs";import{extractErrorMessage as t}from"./utils/extractErrorMessage.mjs";import{logStack as n}from"./utils/logStack.mjs";import{camelCaseToKebabCase as r}from"./utils/stringFormatter/camelCaseToKebabCase.mjs";import{camelCaseToSentence as i}from"./utils/stringFormatter/camelCaseToSentence.mjs";import{kebabCaseToCamelCase as a}from"./utils/stringFormatter/kebabCaseToCamelCase.mjs";import{toLowerCamelCase as o}from"./utils/stringFormatter/toLowerCamelCase.mjs";import{
|
|
1
|
+
import{normalizePath as e}from"./utils/normalizePath.mjs";import{extractErrorMessage as t}from"./utils/extractErrorMessage.mjs";import{logStack as n}from"./utils/logStack.mjs";import{camelCaseToKebabCase as r}from"./utils/stringFormatter/camelCaseToKebabCase.mjs";import{camelCaseToSentence as i}from"./utils/stringFormatter/camelCaseToSentence.mjs";import{kebabCaseToCamelCase as a}from"./utils/stringFormatter/kebabCaseToCamelCase.mjs";import{toLowerCamelCase as o}from"./utils/stringFormatter/toLowerCamelCase.mjs";import{t as s}from"./defaultValues/index.mjs";export{s as DefaultValues,r as camelCaseToKebabCase,i as camelCaseToSentence,t as extractErrorMessage,a as kebabCaseToCamelCase,n as logStack,e as normalizePath,o as toLowerCamelCase};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e}from"../chunk-DXQkyQJp.mjs";import{OUTPUT_FORMAT as t,TRAVERSE_PATTERN as n}from"../defaultValues/build.mjs";import"../defaultValues/compiler.mjs";import{CODE_DIR as r,CONTENT_DIR as i,EXCLUDED_PATHS as a,FILE_EXTENSIONS as o}from"../defaultValues/content.mjs";import"../defaultValues/dictionary.mjs";import"../defaultValues/editor.mjs";import{DEFAULT_LOCALE as s,LOCALES as c,REQUIRED_LOCALES as l}from"../defaultValues/internationalization.mjs";import{PREFIX as u}from"../defaultValues/log.mjs";import{STORAGE as d}from"../defaultValues/routing.mjs";import"../defaultValues/system.mjs";import{getProjectRequire as f}from"../utils/ESMxCJSHelpers.mjs";import{statSync as p}from"node:fs";import{dirname as m,isAbsolute as h,join as g}from"node:path";import _ from"@intlayer/types/package.json"with{type:"json"};let v;const y=e=>({locales:e?.locales??c,requiredLocales:e?.requiredLocales??e?.locales??l,strictMode:e?.strictMode??`inclusive`,defaultLocale:e?.defaultLocale??s}),b=e=>({mode:e?.mode??`prefix-no-default`,storage:e?.storage??d,basePath:e?.basePath??``,rewrite:e?.rewrite}),x=(e,t)=>{let n=e??process.cwd(),r=e=>{let t;try{t=f(n).resolve(e,{paths:[n]})}catch{t=h(e)?e:g(n,e)}try{if(p(t).isFile())return m(t)}catch{if(/\.[a-z0-9]+$/i.test(t))return m(t)}return t},i=r(t?.dictionariesDir??`.intlayer/dictionary`);return{baseDir:n,moduleAugmentationDir:r(t?.moduleAugmentationDir??`.intlayer/types`),unmergedDictionariesDir:r(t?.unmergedDictionariesDir??`.intlayer/unmerged_dictionary`),remoteDictionariesDir:r(t?.remoteDictionariesDir??`.intlayer/remote_dictionary`),dictionariesDir:i,dynamicDictionariesDir:r(t?.dynamicDictionariesDir??`.intlayer/dynamic_dictionary`),fetchDictionariesDir:r(t?.fetchDictionariesDir??`.intlayer/fetch_dictionary`),typesDir:r(t?.typesDir??`.intlayer/types`),mainDir:r(t?.mainDir??`.intlayer/main`),configDir:r(t?.configDir??`.intlayer/config`),cacheDir:r(t?.cacheDir??`.intlayer/cache`),tempDir:r(t?.tempDir??`.intlayer/tmp`)}},S=(t,n)=>{let s=n?.fileExtensions??o,c=n=>{let r;try{r=f(t.baseDir).resolve(n,{paths:[t.baseDir]})}catch{try{r=e.resolve(n,{paths:[t.baseDir]})}catch{r=h(n)?n:g(t.baseDir,n)}}try{if(p(r).isFile())return m(r)}catch{if(/\.[a-z0-9]+$/i.test(r))return m(r)}return r};return{fileExtensions:s,contentDir:(n?.contentDir??i).map(c),codeDir:(n?.codeDir??r).map(c),excludedPath:n?.excludedPath??a,watch:n?.watch??!0,formatCommand:n?.formatCommand}},C=e=>({applicationURL:e?.applicationURL||void 0,editorURL:e?.editorURL||`http://localhost:8000`,cmsURL:e?.cmsURL||`https://app.intlayer.org`,backendURL:e?.backendURL||`https://back.intlayer.org`,port:e?.port??8e3,enabled:e?.enabled??!1,clientId:e?.clientId??void 0,clientSecret:e?.clientSecret??void 0,dictionaryPriorityStrategy:e?.dictionaryPriorityStrategy??`local_first`,liveSync:e?.liveSync??!0,liveSyncPort:e?.liveSyncPort??4e3,liveSyncURL:e?.liveSyncURL??`http://localhost:${e?.liveSyncPort??4e3}`}),w=(e,t)=>({mode:e?.mode??`default`,prefix:e?.prefix??u,error:t?.error,log:t?.log,info:t?.info,warn:t?.warn}),T=e=>({provider:e?.provider,apiKey:e?.apiKey,model:e?.model,temperature:e?.temperature,applicationContext:e?.applicationContext,baseURL:e?.baseURL,dataSerialization:e?.dataSerialization}),E=e=>({mode:e?.mode??`auto`,optimize:e?.optimize,importMode:e?.importMode,traversePattern:e?.traversePattern??n,outputFormat:e?.outputFormat??t,cache:e?.cache??!0,require:e?.require,checkTypes:e?.checkTypes??!1}),D=e=>({enabled:e?.enabled??!0,dictionaryKeyPrefix:e?.dictionaryKeyPrefix??``,transformPattern:e?.transformPattern,excludePattern:e?.excludePattern,output:e?.output,noMetadata:e?.noMetadata??!1,saveComponents:e?.saveComponents??!1}),O=e=>{let t=e?.contentAutoTransformation??!1;return{fill:e?.fill??!0,contentAutoTransformation:typeof t==`object`?{markdown:t.markdown??!1,html:t.html??!1,insertion:t.insertion??!1}:t,location:e?.location??`local`,locale:e?.locale,title:e?.title,description:e?.description,tags:e?.tags,priority:e?.priority,importMode:e?.importMode??`static`}},k=(e,t,n)=>{let r=y(e?.internationalization),i=b(e?.routing),a=x(t,e?.system);return v={internationalization:r,routing:i,content:S(a,e?.content),system:a,editor:C(e?.editor),log:w(e?.log,n),ai:T(e?.ai),build:E(e?.build),compiler:D(e?.compiler),dictionary:O(e?.dictionary),plugins:e?.plugins,schemas:e?.schemas,metadata:{name:`Intlayer`,version:_.version,doc:`https://intlayer.org/docs`}},v};export{k as buildConfigurationFields};
|
|
2
2
|
//# sourceMappingURL=buildConfigurationFields.mjs.map
|