@intlayer/config 9.0.0-canary.8 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/built.cjs +2 -0
- package/dist/cjs/built.cjs.map +1 -1
- package/dist/cjs/bundle/index.cjs +1 -1
- package/dist/cjs/bundle/index.cjs.map +1 -1
- package/dist/cjs/bundle/logBundle.cjs.map +1 -1
- package/dist/cjs/callers/base.cjs +42 -0
- package/dist/cjs/callers/base.cjs.map +1 -0
- package/dist/cjs/callers/compat/i18next.cjs +27 -0
- package/dist/cjs/callers/compat/i18next.cjs.map +1 -0
- package/dist/cjs/callers/compat/lingui.cjs +82 -0
- package/dist/cjs/callers/compat/lingui.cjs.map +1 -0
- package/dist/cjs/callers/compat/nextIntl.cjs +44 -0
- package/dist/cjs/callers/compat/nextIntl.cjs.map +1 -0
- package/dist/cjs/callers/compat/reactI18next.cjs +50 -0
- package/dist/cjs/callers/compat/reactI18next.cjs.map +1 -0
- package/dist/cjs/callers/compat/reactIntl.cjs +31 -0
- package/dist/cjs/callers/compat/reactIntl.cjs.map +1 -0
- package/dist/cjs/callers/compat/useIntl.cjs +46 -0
- package/dist/cjs/callers/compat/useIntl.cjs.map +1 -0
- package/dist/cjs/callers/compat/vueI18n.cjs +26 -0
- package/dist/cjs/callers/compat/vueI18n.cjs.map +1 -0
- package/dist/cjs/callers/index.cjs +87 -0
- package/dist/cjs/callers/index.cjs.map +1 -0
- package/dist/cjs/callers/transform.cjs +46 -0
- package/dist/cjs/callers/transform.cjs.map +1 -0
- package/dist/cjs/callers/types.cjs +0 -0
- package/dist/cjs/client.cjs +1 -0
- package/dist/cjs/configFile/buildBrowserConfiguration.cjs +47 -3
- package/dist/cjs/configFile/buildBrowserConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/buildConfigurationFields.cjs +9 -3
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/configurationSchema.cjs +7 -0
- package/dist/cjs/configFile/configurationSchema.cjs.map +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs +10 -3
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/index.cjs +2 -0
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs +0 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
- package/dist/cjs/defaultValues/analytics.cjs +16 -0
- package/dist/cjs/defaultValues/analytics.cjs.map +1 -0
- package/dist/cjs/defaultValues/build.cjs.map +1 -1
- package/dist/cjs/defaultValues/content.cjs.map +1 -1
- package/dist/cjs/defaultValues/index.cjs +4 -0
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/routing.cjs.map +1 -1
- package/dist/cjs/envVars/envVars.cjs +2 -1
- package/dist/cjs/envVars/envVars.cjs.map +1 -1
- package/dist/cjs/loadEnvFile.cjs +44 -7
- package/dist/cjs/loadEnvFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleFile.cjs +4 -3
- package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs +0 -1
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/index.cjs +1 -0
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs +11 -6
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +52 -17
- package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +99 -10
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
- package/dist/cjs/logger.cjs +2 -1
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/cjs/node.cjs +2 -0
- package/dist/cjs/utils/ESMxCJSHelpers.cjs +0 -1
- package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
- package/dist/cjs/utils/alias.cjs +0 -1
- package/dist/cjs/utils/alias.cjs.map +1 -1
- package/dist/cjs/utils/builtConfigKeys.cjs +38 -0
- package/dist/cjs/utils/builtConfigKeys.cjs.map +1 -0
- package/dist/cjs/utils/cacheDisk.cjs +2 -1
- package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
- package/dist/cjs/utils/cacheMemory.cjs +0 -1
- package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
- package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
- package/dist/cjs/utils/compareVersions.cjs.map +1 -1
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
- package/dist/cjs/utils/getDictionarySelectorUsage.cjs.map +1 -1
- package/dist/cjs/utils/getExtension.cjs.map +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs +0 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
- package/dist/cjs/utils/getStorageAttributes.cjs +2 -1
- package/dist/cjs/utils/getStorageAttributes.cjs.map +1 -1
- package/dist/cjs/utils/getUsedNodeTypes.cjs +0 -1
- package/dist/cjs/utils/getUsedNodeTypes.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +2 -0
- package/dist/cjs/utils/logStack.cjs.map +1 -1
- package/dist/cjs/utils/normalizePath.cjs.map +1 -1
- package/dist/cjs/utils/parseFilePathPattern.cjs.map +1 -1
- package/dist/cjs/utils/pathSecurity.cjs +0 -1
- package/dist/cjs/utils/pathSecurity.cjs.map +1 -1
- package/dist/cjs/utils/retryManager.cjs.map +1 -1
- package/dist/cjs/utils/setIntlayerIdentifier.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs.map +1 -1
- package/dist/esm/built.mjs +2 -1
- package/dist/esm/built.mjs.map +1 -1
- package/dist/esm/bundle/index.mjs +2 -2
- package/dist/esm/bundle/index.mjs.map +1 -1
- package/dist/esm/bundle/logBundle.mjs.map +1 -1
- package/dist/esm/callers/base.mjs +40 -0
- package/dist/esm/callers/base.mjs.map +1 -0
- package/dist/esm/callers/compat/i18next.mjs +25 -0
- package/dist/esm/callers/compat/i18next.mjs.map +1 -0
- package/dist/esm/callers/compat/lingui.mjs +80 -0
- package/dist/esm/callers/compat/lingui.mjs.map +1 -0
- package/dist/esm/callers/compat/nextIntl.mjs +42 -0
- package/dist/esm/callers/compat/nextIntl.mjs.map +1 -0
- package/dist/esm/callers/compat/reactI18next.mjs +48 -0
- package/dist/esm/callers/compat/reactI18next.mjs.map +1 -0
- package/dist/esm/callers/compat/reactIntl.mjs +29 -0
- package/dist/esm/callers/compat/reactIntl.mjs.map +1 -0
- package/dist/esm/callers/compat/useIntl.mjs +44 -0
- package/dist/esm/callers/compat/useIntl.mjs.map +1 -0
- package/dist/esm/callers/compat/vueI18n.mjs +24 -0
- package/dist/esm/callers/compat/vueI18n.mjs.map +1 -0
- package/dist/esm/callers/index.mjs +72 -0
- package/dist/esm/callers/index.mjs.map +1 -0
- package/dist/esm/callers/transform.mjs +43 -0
- package/dist/esm/callers/transform.mjs.map +1 -0
- package/dist/esm/callers/types.mjs +0 -0
- package/dist/esm/client.mjs +2 -2
- package/dist/esm/configFile/buildBrowserConfiguration.mjs +47 -4
- package/dist/esm/configFile/buildBrowserConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/buildConfigurationFields.mjs +10 -4
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/configurationSchema.mjs +7 -1
- package/dist/esm/configFile/configurationSchema.mjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +10 -2
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/index.mjs +3 -3
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
- package/dist/esm/defaultValues/analytics.mjs +12 -0
- package/dist/esm/defaultValues/analytics.mjs.map +1 -0
- package/dist/esm/defaultValues/build.mjs.map +1 -1
- package/dist/esm/defaultValues/content.mjs.map +1 -1
- package/dist/esm/defaultValues/index.mjs +2 -1
- package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
- package/dist/esm/defaultValues/routing.mjs.map +1 -1
- package/dist/esm/envVars/envVars.mjs +2 -1
- package/dist/esm/envVars/envVars.mjs.map +1 -1
- package/dist/esm/loadEnvFile.mjs +45 -8
- package/dist/esm/loadEnvFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleFile.mjs +4 -2
- package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleJSFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/index.mjs +2 -2
- package/dist/esm/loadExternalFile/loadExternalFile.mjs +11 -6
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/parseFileContent.mjs +52 -17
- package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +102 -13
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
- package/dist/esm/logger.mjs +2 -1
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/esm/node.mjs +3 -3
- package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
- package/dist/esm/utils/alias.mjs.map +1 -1
- package/dist/esm/utils/builtConfigKeys.mjs +36 -0
- package/dist/esm/utils/builtConfigKeys.mjs.map +1 -0
- package/dist/esm/utils/cacheDisk.mjs +6 -5
- package/dist/esm/utils/cacheDisk.mjs.map +1 -1
- package/dist/esm/utils/cacheMemory.mjs.map +1 -1
- package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
- package/dist/esm/utils/compareVersions.mjs.map +1 -1
- package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
- package/dist/esm/utils/getDictionarySelectorUsage.mjs.map +1 -1
- package/dist/esm/utils/getExtension.mjs.map +1 -1
- package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
- package/dist/esm/utils/getStorageAttributes.mjs +2 -1
- package/dist/esm/utils/getStorageAttributes.mjs.map +1 -1
- package/dist/esm/utils/getUsedNodeTypes.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +2 -1
- package/dist/esm/utils/logStack.mjs.map +1 -1
- package/dist/esm/utils/normalizePath.mjs.map +1 -1
- package/dist/esm/utils/parseFilePathPattern.mjs.map +1 -1
- package/dist/esm/utils/pathSecurity.mjs.map +1 -1
- package/dist/esm/utils/retryManager.mjs.map +1 -1
- package/dist/esm/utils/setIntlayerIdentifier.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs.map +1 -1
- package/dist/types/built.d.ts +2 -1
- package/dist/types/built.d.ts.map +1 -1
- package/dist/types/bundle/index.d.ts +2 -4
- package/dist/types/bundle/index.d.ts.map +1 -1
- package/dist/types/bundle/logBundle.d.ts +0 -1
- package/dist/types/bundle/logBundle.d.ts.map +1 -1
- package/dist/types/callers/base.d.ts +13 -0
- package/dist/types/callers/base.d.ts.map +1 -0
- package/dist/types/callers/compat/i18next.d.ts +11 -0
- package/dist/types/callers/compat/i18next.d.ts.map +1 -0
- package/dist/types/callers/compat/lingui.d.ts +6 -0
- package/dist/types/callers/compat/lingui.d.ts.map +1 -0
- package/dist/types/callers/compat/nextIntl.d.ts +12 -0
- package/dist/types/callers/compat/nextIntl.d.ts.map +1 -0
- package/dist/types/callers/compat/reactI18next.d.ts +14 -0
- package/dist/types/callers/compat/reactI18next.d.ts.map +1 -0
- package/dist/types/callers/compat/reactIntl.d.ts +15 -0
- package/dist/types/callers/compat/reactIntl.d.ts.map +1 -0
- package/dist/types/callers/compat/useIntl.d.ts +11 -0
- package/dist/types/callers/compat/useIntl.d.ts.map +1 -0
- package/dist/types/callers/compat/vueI18n.d.ts +11 -0
- package/dist/types/callers/compat/vueI18n.d.ts.map +1 -0
- package/dist/types/callers/index.d.ts +48 -0
- package/dist/types/callers/index.d.ts.map +1 -0
- package/dist/types/callers/transform.d.ts +60 -0
- package/dist/types/callers/transform.d.ts.map +1 -0
- package/dist/types/callers/types.d.ts +160 -0
- package/dist/types/callers/types.d.ts.map +1 -0
- package/dist/types/client.d.ts +2 -2
- package/dist/types/colors.d.ts +14 -14
- package/dist/types/colors.d.ts.map +1 -1
- package/dist/types/configFile/buildBrowserConfiguration.d.ts +24 -4
- package/dist/types/configFile/buildBrowserConfiguration.d.ts.map +1 -1
- package/dist/types/configFile/buildConfigurationFields.d.ts +8 -4
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/configFile/configurationSchema.d.ts +43 -34
- package/dist/types/configFile/configurationSchema.d.ts.map +1 -1
- package/dist/types/configFile/getConfiguration.d.ts +0 -1
- package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
- package/dist/types/configFile/index.d.ts +3 -3
- package/dist/types/configFile/loadConfigurationFile.d.ts +1 -2
- package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
- package/dist/types/configFile/searchConfigurationFile.d.ts +1 -1
- package/dist/types/configFile/searchConfigurationFile.d.ts.map +1 -1
- package/dist/types/defaultValues/analytics.d.ts +11 -0
- package/dist/types/defaultValues/analytics.d.ts.map +1 -0
- package/dist/types/defaultValues/build.d.ts.map +1 -1
- package/dist/types/defaultValues/compiler.d.ts.map +1 -1
- package/dist/types/defaultValues/content.d.ts.map +1 -1
- package/dist/types/defaultValues/dictionary.d.ts +0 -1
- package/dist/types/defaultValues/dictionary.d.ts.map +1 -1
- package/dist/types/defaultValues/editor.d.ts.map +1 -1
- package/dist/types/defaultValues/index.d.ts +2 -1
- package/dist/types/defaultValues/internationalization.d.ts +0 -1
- package/dist/types/defaultValues/internationalization.d.ts.map +1 -1
- package/dist/types/defaultValues/log.d.ts.map +1 -1
- package/dist/types/defaultValues/routing.d.ts +0 -1
- package/dist/types/defaultValues/routing.d.ts.map +1 -1
- package/dist/types/defaultValues/system.d.ts.map +1 -1
- package/dist/types/envVars/envVars.d.ts +0 -1
- package/dist/types/envVars/envVars.d.ts.map +1 -1
- package/dist/types/loadEnvFile.d.ts +1 -1
- package/dist/types/loadEnvFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/bundleFile.d.ts +0 -1
- package/dist/types/loadExternalFile/bundleFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/bundleJSFile.d.ts +57 -59
- package/dist/types/loadExternalFile/bundleJSFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/index.d.ts +2 -2
- package/dist/types/loadExternalFile/loadExternalFile.d.ts +0 -1
- package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/parseFileContent.d.ts +9 -1
- package/dist/types/loadExternalFile/parseFileContent.d.ts.map +1 -1
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +4 -4
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -1
- package/dist/types/logger.d.ts +2 -3
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/node.d.ts +3 -3
- package/dist/types/utils/ESMxCJSHelpers.d.ts.map +1 -1
- package/dist/types/utils/alias.d.ts +1 -6
- package/dist/types/utils/alias.d.ts.map +1 -1
- package/dist/types/utils/builtConfigKeys.d.ts +25 -0
- package/dist/types/utils/builtConfigKeys.d.ts.map +1 -0
- package/dist/types/utils/cacheDisk.d.ts +22 -11
- package/dist/types/utils/cacheDisk.d.ts.map +1 -1
- package/dist/types/utils/cacheMemory.d.ts +3 -3
- package/dist/types/utils/cacheMemory.d.ts.map +1 -1
- package/dist/types/utils/clearModuleCache.d.ts.map +1 -1
- package/dist/types/utils/compareVersions.d.ts +1 -1
- package/dist/types/utils/compareVersions.d.ts.map +1 -1
- package/dist/types/utils/extractErrorMessage.d.ts.map +1 -1
- package/dist/types/utils/getDictionarySelectorUsage.d.ts +0 -1
- package/dist/types/utils/getDictionarySelectorUsage.d.ts.map +1 -1
- package/dist/types/utils/getExtension.d.ts +1 -2
- package/dist/types/utils/getExtension.d.ts.map +1 -1
- package/dist/types/utils/getPackageJsonPath.d.ts.map +1 -1
- package/dist/types/utils/getStorageAttributes.d.ts +0 -1
- package/dist/types/utils/getStorageAttributes.d.ts.map +1 -1
- package/dist/types/utils/getUsedNodeTypes.d.ts +0 -1
- package/dist/types/utils/getUsedNodeTypes.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/logStack.d.ts.map +1 -1
- package/dist/types/utils/normalizePath.d.ts.map +1 -1
- package/dist/types/utils/parseFilePathPattern.d.ts +0 -1
- package/dist/types/utils/parseFilePathPattern.d.ts.map +1 -1
- package/dist/types/utils/pathSecurity.d.ts.map +1 -1
- package/dist/types/utils/retryManager.d.ts +8 -9
- package/dist/types/utils/retryManager.d.ts.map +1 -1
- package/dist/types/utils/setIntlayerIdentifier.d.ts.map +1 -1
- package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts.map +1 -1
- package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts.map +1 -1
- package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts.map +1 -1
- package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts.map +1 -1
- package/package.json +11 -7
- package/dist/cjs/built.browser.cjs +0 -46
- package/dist/cjs/built.browser.cjs.map +0 -1
- package/dist/esm/built.browser.mjs +0 -32
- package/dist/esm/built.browser.mjs.map +0 -1
- package/dist/types/built.browser.d.ts +0 -27
- package/dist/types/built.browser.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","buildConfigurationFields","cacheMemory","searchConfigurationFile","loadConfigurationFile"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport type { LoadExternalFileOptions } from '../loadExternalFile/loadExternalFile';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { cacheMemory } from '../utils/cacheMemory';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n // cache\n cache?: boolean;\n // Build options for TypeScript transpilation (e.g. custom esbuild instance)\n buildOptions?: LoadExternalFileOptions['buildOptions'];\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n customConfiguration: CustomIntlayerConfig | undefined;\n numCustomConfiguration: number;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n let baseDir: string | undefined;\n\n try {\n // Can fail in some environments (e.g. MCP server, VScode extension)\n baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n } catch (_err) {\n // Return default config if the package.json is not found\n return {\n configuration: buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n ),\n customConfiguration: undefined,\n numCustomConfiguration: 0,\n configurationFilePath: undefined,\n };\n }\n\n const cachedConfiguration =\n cacheMemory.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n let storedConfiguration: IntlayerConfig;\n let customConfiguration: CustomIntlayerConfig | undefined;\n\n if (configurationFilePath) {\n // Load the custom configuration\n customConfiguration = loadConfigurationFile(configurationFilePath, {\n projectRequire: options?.require,\n // Dotenv options\n envVarOptions: {\n env: options?.env,\n envFile: options?.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: options?.additionalEnvVars,\n aliases: options?.aliases,\n // Build options for TypeScript transpilation (e.g. custom esbuild instance)\n buildOptions: options?.buildOptions,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n options?.baseDir,\n options?.logFunctions\n );\n } else {\n // No configuration file found, use default configuration\n storedConfiguration = buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n );\n }\n\n // Log warning if multiple configuration files are found\n const projectRequireConfig: CustomIntlayerConfig = options?.require\n ? {\n build: {\n require: options?.require,\n cache: options?.cache,\n },\n }\n : {};\n\n const configWithProjectRequire = defu(\n projectRequireConfig,\n storedConfiguration\n ) as IntlayerConfig;\n\n const configuration = defu(\n options?.override ?? {},\n configWithProjectRequire\n ) as IntlayerConfig;\n\n cacheMemory.set(options, {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n });\n\n return {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","buildConfigurationFields","cacheMemory","searchConfigurationFile","loadEnvFile","loadConfigurationFile"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport { loadEnvFile } from '../loadEnvFile';\nimport type { LoadExternalFileOptions } from '../loadExternalFile/loadExternalFile';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { cacheMemory } from '../utils/cacheMemory';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n // cache\n cache?: boolean;\n // Build options for TypeScript transpilation (e.g. custom esbuild instance)\n buildOptions?: LoadExternalFileOptions['buildOptions'];\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n customConfiguration: CustomIntlayerConfig | undefined;\n numCustomConfiguration: number;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n let baseDir: string | undefined;\n\n try {\n // Can fail in some environments (e.g. MCP server, VScode extension)\n baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n } catch (_err) {\n // Return default config if the package.json is not found\n return {\n configuration: buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n ),\n customConfiguration: undefined,\n numCustomConfiguration: 0,\n configurationFilePath: undefined,\n };\n }\n\n const cachedConfiguration =\n cacheMemory.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Merge the variables from the resolved env file (e.g. the CLI `--env-file`)\n // on top of `process.env` without mutating the real environment. This lets\n // credential fallbacks (`INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET`) be\n // resolved from the env file even when the configuration file does not wire\n // `process.env` into `editor.clientId` / `editor.clientSecret` itself.\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n ...loadEnvFile({ env: options?.env, envFile: options?.envFile }),\n };\n\n let storedConfiguration: IntlayerConfig;\n let customConfiguration: CustomIntlayerConfig | undefined;\n\n if (configurationFilePath) {\n // Load the custom configuration\n customConfiguration = loadConfigurationFile(configurationFilePath, {\n projectRequire: options?.require,\n // Dotenv options\n envVarOptions: {\n env: options?.env,\n envFile: options?.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: options?.additionalEnvVars,\n aliases: options?.aliases,\n // Build options for TypeScript transpilation (e.g. custom esbuild instance)\n buildOptions: options?.buildOptions,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n options?.baseDir,\n options?.logFunctions,\n env\n );\n } else {\n // No configuration file found, use default configuration\n storedConfiguration = buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions,\n env\n );\n }\n\n // Log warning if multiple configuration files are found\n const projectRequireConfig: CustomIntlayerConfig = options?.require\n ? {\n build: {\n require: options?.require,\n cache: options?.cache,\n },\n }\n : {};\n\n const configWithProjectRequire = defu(\n projectRequireConfig,\n storedConfiguration\n ) as IntlayerConfig;\n\n const configuration = defu(\n options?.override ?? {},\n configWithProjectRequire\n ) as IntlayerConfig;\n\n cacheMemory.set(options, {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n });\n\n return {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n"],"mappings":";;;;;;;;;;;;;AAyCA,MAAa,+BACX,YACsC;CACtC,IAAI;CAEJ,IAAI;EAEF,UAAU,SAAS,WAAWA,oDAAmB,CAAC,CAAC;CACrD,SAAS,MAAM;EAEb,OAAO;GACL,eAAeC,qEACb,CAAC,GACD,SAAS,SACT,SAAS,YACX;GACA,qBAAqB;GACrB,wBAAwB;GACxB,uBAAuB;EACzB;CACF;CAEA,MAAM,sBACJC,sCAAY,IAAuC,OAAO;CAE5D,IAAI,qBAAqB,OAAO;CAGhC,MAAM,EAAE,uBAAuB,2BAC7BC,mEAAwB,OAAO;CAOjC,MAAM,MAAyB;EAC7B,GAAG,QAAQ;EACX,GAAGC,gCAAY;GAAE,KAAK,SAAS;GAAK,SAAS,SAAS;EAAQ,CAAC;CACjE;CAEA,IAAI;CACJ,IAAI;CAEJ,IAAI,uBAAuB;EAEzB,sBAAsBC,+DAAsB,uBAAuB;GACjE,gBAAgB,SAAS;GAEzB,eAAe;IACb,KAAK,SAAS;IACd,SAAS,SAAS;GACpB;GAEA,mBAAmB,SAAS;GAC5B,SAAS,SAAS;GAElB,cAAc,SAAS;EACzB,CAAC;EAGD,sBAAsBJ,qEACpB,qBACA,SAAS,SACT,SAAS,cACT,GACF;CACF,OAEE,sBAAsBA,qEACpB,CAAC,GACD,SAAS,SACT,SAAS,cACT,GACF;CAaF,MAAM,0CAT6C,SAAS,UACxD,EACE,OAAO;EACL,SAAS,SAAS;EAClB,OAAO,SAAS;CAClB,EACF,IACA,CAAC,GAIH,mBACF;CAEA,MAAM,+BACJ,SAAS,YAAY,CAAC,GACtB,wBACF;CAEA,sCAAY,IAAI,SAAS;EACvB;EACA;EACA;EACA;CACF,CAAC;CAED,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;;;;AAKA,MAAa,oBACX,YACmB,4BAA4B,OAAO,CAAC,CAAC"}
|
|
@@ -6,6 +6,8 @@ const require_configFile_searchConfigurationFile = require('./searchConfiguratio
|
|
|
6
6
|
const require_configFile_getConfiguration = require('./getConfiguration.cjs');
|
|
7
7
|
|
|
8
8
|
exports.aiSchema = require_configFile_configurationSchema.aiSchema;
|
|
9
|
+
exports.analyticsSchema = require_configFile_configurationSchema.analyticsSchema;
|
|
10
|
+
exports.buildAnalyticsFields = require_configFile_buildBrowserConfiguration.buildAnalyticsFields;
|
|
9
11
|
exports.buildBrowserConfiguration = require_configFile_buildBrowserConfiguration.buildBrowserConfiguration;
|
|
10
12
|
exports.buildConfigurationFields = require_configFile_buildConfigurationFields.buildConfigurationFields;
|
|
11
13
|
exports.buildEditorFields = require_configFile_buildBrowserConfiguration.buildEditorFields;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfigurationFile.cjs","names":["configESMxCJSRequire","loadExternalFileSync"],"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport {\n type LoadExternalFileOptions,\n loadExternalFileSync,\n} from '../loadExternalFile/loadExternalFile';\nimport { configESMxCJSRequire } from '../utils/ESMxCJSHelpers';\n\nconst getAliases = (\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n) => {\n // Can fail if CJS hot removed from the module (e.g. in Tanstack Start + Nitro)\n try {\n return {\n ...options?.aliases,\n // Replace intlayer with @intlayer/types to avoid circular dependency intlayer -> @intlayer/config -> intlayer\n intlayer: configESMxCJSRequire.resolve('@intlayer/types'),\n };\n } catch {\n return options?.aliases;\n }\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n): CustomIntlayerConfig | undefined => {\n const fileContent = loadExternalFileSync(configFilePath, {\n ...options,\n aliases: getAliases(options),\n });\n\n return fileContent;\n};\n"],"mappings":";;;;;AAOA,MAAM,cACJ,YACG;
|
|
1
|
+
{"version":3,"file":"loadConfigurationFile.cjs","names":["configESMxCJSRequire","loadExternalFileSync"],"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport {\n type LoadExternalFileOptions,\n loadExternalFileSync,\n} from '../loadExternalFile/loadExternalFile';\nimport { configESMxCJSRequire } from '../utils/ESMxCJSHelpers';\n\nconst getAliases = (\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n) => {\n // Can fail if CJS hot removed from the module (e.g. in Tanstack Start + Nitro)\n try {\n return {\n ...options?.aliases,\n // Replace intlayer with @intlayer/types to avoid circular dependency intlayer -> @intlayer/config -> intlayer\n intlayer: configESMxCJSRequire.resolve('@intlayer/types'),\n };\n } catch {\n return options?.aliases;\n }\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n): CustomIntlayerConfig | undefined => {\n const fileContent = loadExternalFileSync(configFilePath, {\n ...options,\n aliases: getAliases(options),\n });\n\n return fileContent;\n};\n"],"mappings":";;;;;AAOA,MAAM,cACJ,YACG;CAEH,IAAI;EACF,OAAO;GACL,GAAG,SAAS;GAEZ,UAAUA,kDAAqB,QAAQ,iBAAiB;EAC1D;CACF,QAAQ;EACN,OAAO,SAAS;CAClB;AACF;;;;;;;AAQA,MAAa,yBACX,gBACA,YACqC;CAMrC,OALoBC,+DAAqB,gBAAgB;EACvD,GAAG;EACH,SAAS,WAAW,OAAO;CAC7B,CAEiB;AACnB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
|
|
4
3
|
const require_logger = require('../logger.cjs');
|
|
5
4
|
let node_fs = require("node:fs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchConfigurationFile.cjs","names":["getPackageJsonPath"],"sources":["../../../src/configFile/searchConfigurationFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { logger } from '../logger';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\n\nexport const configurationFilesCandidates = [\n 'intlayer.config.ts',\n 'intlayer.config.js',\n 'intlayer.config.json',\n 'intlayer.config.json5',\n 'intlayer.config.jsonc',\n 'intlayer.config.cjs',\n 'intlayer.config.mjs',\n '.intlayerrc',\n] as const;\n\ntype SearchConfigurationFileResult = {\n configurationFilePath?: string;\n numCustomConfiguration: number;\n};\n\n// CACHE: Store results to avoid re-walking the file system for the same path\nconst rootPathCache = new Map<string, SearchConfigurationFileResult>();\n\n/**\n * Search for the configuration file in the given path\n *\n * List of detected configuration files:\n * - intlayer.config.ts\n * - intlayer.config.js\n * - intlayer.config.json\n * - intlayer.config.cjs\n * - intlayer.config.mjs\n * - .intlayerrc\n */\nexport const searchConfigurationFile = (\n startDir: string\n): SearchConfigurationFileResult => {\n let configurationFilePath: string | undefined;\n let numCustomConfiguration = 0;\n\n // OPTIMIZATION: Return cached result immediately\n if (rootPathCache.has(startDir)) {\n return rootPathCache.get(startDir) as SearchConfigurationFileResult;\n }\n\n const { baseDir } = getPackageJsonPath(startDir);\n\n for (const fileName of configurationFilesCandidates) {\n try {\n const filePath = resolve(baseDir, fileName);\n\n // Check if the file exists\n if (!existsSync(filePath)) {\n } else {\n numCustomConfiguration += 1;\n\n if (!configurationFilePath) {\n configurationFilePath = filePath;\n }\n }\n } catch (error) {\n // Return \"Cannot use import statement outside a module\"\n logger(`${fileName}: ${error as string}`, { level: 'error' });\n }\n }\n\n return { configurationFilePath, numCustomConfiguration };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"searchConfigurationFile.cjs","names":["getPackageJsonPath"],"sources":["../../../src/configFile/searchConfigurationFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { logger } from '../logger';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\n\nexport const configurationFilesCandidates = [\n 'intlayer.config.ts',\n 'intlayer.config.js',\n 'intlayer.config.json',\n 'intlayer.config.json5',\n 'intlayer.config.jsonc',\n 'intlayer.config.cjs',\n 'intlayer.config.mjs',\n '.intlayerrc',\n] as const;\n\ntype SearchConfigurationFileResult = {\n configurationFilePath?: string;\n numCustomConfiguration: number;\n};\n\n// CACHE: Store results to avoid re-walking the file system for the same path\nconst rootPathCache = new Map<string, SearchConfigurationFileResult>();\n\n/**\n * Search for the configuration file in the given path\n *\n * List of detected configuration files:\n * - intlayer.config.ts\n * - intlayer.config.js\n * - intlayer.config.json\n * - intlayer.config.cjs\n * - intlayer.config.mjs\n * - .intlayerrc\n */\nexport const searchConfigurationFile = (\n startDir: string\n): SearchConfigurationFileResult => {\n let configurationFilePath: string | undefined;\n let numCustomConfiguration = 0;\n\n // OPTIMIZATION: Return cached result immediately\n if (rootPathCache.has(startDir)) {\n return rootPathCache.get(startDir) as SearchConfigurationFileResult;\n }\n\n const { baseDir } = getPackageJsonPath(startDir);\n\n for (const fileName of configurationFilesCandidates) {\n try {\n const filePath = resolve(baseDir, fileName);\n\n // Check if the file exists\n if (!existsSync(filePath)) {\n } else {\n numCustomConfiguration += 1;\n\n if (!configurationFilePath) {\n configurationFilePath = filePath;\n }\n }\n } catch (error) {\n // Return \"Cannot use import statement outside a module\"\n logger(`${fileName}: ${error as string}`, { level: 'error' });\n }\n }\n\n return { configurationFilePath, numCustomConfiguration };\n};\n"],"mappings":";;;;;;;AAKA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAQA,MAAM,gCAAgB,IAAI,IAA2C;;;;;;;;;;;;AAarE,MAAa,2BACX,aACkC;CAClC,IAAI;CACJ,IAAI,yBAAyB;CAG7B,IAAI,cAAc,IAAI,QAAQ,GAC5B,OAAO,cAAc,IAAI,QAAQ;CAGnC,MAAM,EAAE,YAAYA,oDAAmB,QAAQ;CAE/C,KAAK,MAAM,YAAY,8BACrB,IAAI;EACF,MAAM,kCAAmB,SAAS,QAAQ;EAG1C,IAAI,yBAAY,QAAQ,GAAG,CAC3B,OAAO;GACL,0BAA0B;GAE1B,IAAI,CAAC,uBACH,wBAAwB;EAE5B;CACF,SAAS,OAAO;EAEd,sBAAO,GAAG,SAAS,IAAI,SAAmB,EAAE,OAAO,QAAQ,CAAC;CAC9D;CAGF,OAAO;EAAE;EAAuB;CAAuB;AACzD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
//#region src/defaultValues/analytics.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default values for the `analytics` configuration block.
|
|
6
|
+
* Analytics is strictly opt-in — disabled unless the user enables it.
|
|
7
|
+
*/
|
|
8
|
+
const ANALYTICS_ENABLED = false;
|
|
9
|
+
const ANALYTICS_FLUSH_INTERVAL = 2e4;
|
|
10
|
+
const ANALYTICS_SAMPLE_RATE = 1;
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.ANALYTICS_ENABLED = ANALYTICS_ENABLED;
|
|
14
|
+
exports.ANALYTICS_FLUSH_INTERVAL = ANALYTICS_FLUSH_INTERVAL;
|
|
15
|
+
exports.ANALYTICS_SAMPLE_RATE = ANALYTICS_SAMPLE_RATE;
|
|
16
|
+
//# sourceMappingURL=analytics.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.cjs","names":[],"sources":["../../../src/defaultValues/analytics.ts"],"sourcesContent":["/**\n * Default values for the `analytics` configuration block.\n * Analytics is strictly opt-in — disabled unless the user enables it.\n */\nexport const ANALYTICS_ENABLED = false;\nexport const ANALYTICS_FLUSH_INTERVAL = 20_000;\nexport const ANALYTICS_SAMPLE_RATE = 1;\n"],"mappings":";;;;;;;AAIA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACxC,MAAa,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.cjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const TRAVERSE_PATTERN = [\n // Included files to parse\n '**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,astro}',\n\n // Excluded paths\n '!**/node_modules/**',\n '!**/dist/**',\n '!**/build/**',\n '!**/.intlayer/**',\n '!**/.next/**',\n '!**/.nuxt/**',\n '!**/.expo/**',\n '!**/.vercel/**',\n '!**/.turbo/**',\n '!**/.tanstack/**',\n '!**/.output/**',\n '!**/.svelte-kit/**',\n '!**/*.config.*',\n '!**/*.test.*',\n '!**/*.spec.*',\n '!**/*.stories.*',\n '!**/*.d.ts',\n '!**/*.d.ts.map',\n '!**/*.map',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['esm', 'cjs'];\n\nexport const CACHE = true;\n\nexport const TYPE_CHECKING = false;\n\nexport const MINIFY = false;\n\nexport const PURGE = false;\n"],"mappings":";;;AAAA,MAAa,aAAa;AAE1B,MAAa,WAAW;AAExB,MAAa,mBAAmB;CAE9B;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"build.cjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const TRAVERSE_PATTERN = [\n // Included files to parse\n '**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,astro}',\n\n // Excluded paths\n '!**/node_modules/**',\n '!**/dist/**',\n '!**/build/**',\n '!**/.intlayer/**',\n '!**/.next/**',\n '!**/.nuxt/**',\n '!**/.expo/**',\n '!**/.vercel/**',\n '!**/.turbo/**',\n '!**/.tanstack/**',\n '!**/.output/**',\n '!**/.svelte-kit/**',\n '!**/*.config.*',\n '!**/*.test.*',\n '!**/*.spec.*',\n '!**/*.stories.*',\n '!**/*.d.ts',\n '!**/*.d.ts.map',\n '!**/*.map',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['esm', 'cjs'];\n\nexport const CACHE = true;\n\nexport const TYPE_CHECKING = false;\n\nexport const MINIFY = false;\n\nexport const PURGE = false;\n"],"mappings":";;;AAAA,MAAa,aAAa;AAE1B,MAAa,WAAW;AAExB,MAAa,mBAAmB;CAE9B;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,gBAAmC,CAAC,OAAO,KAAK;AAE7D,MAAa,QAAQ;AAErB,MAAa,gBAAgB;AAE7B,MAAa,SAAS;AAEtB,MAAa,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.cjs","names":[],"sources":["../../../src/defaultValues/content.ts"],"sourcesContent":["export const FILE_EXTENSIONS = [\n '.content.ts',\n '.content.js',\n '.content.cjs',\n '.content.mjs',\n '.content.json',\n '.content.json5',\n '.content.jsonc',\n '.content.tsx',\n '.content.jsx',\n '.content.md',\n '.content.mdx',\n '.content.yaml',\n '.content.yml',\n];\n\nexport const EXCLUDED_PATHS = [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.expo/**',\n '**/.vercel/**',\n '**/.turbo/**',\n '**/.tanstack/**',\n '**/.output/**',\n '**/.svelte-kit/**',\n];\n\nexport const CONTENT_DIR = ['.'];\n\nexport const CODE_DIR = ['.'];\n\nexport const I18NEXT_DICTIONARIES_DIR = 'i18next_resources';\n\nexport const REACT_INTL_MESSAGES_DIR = 'intl_messages';\n\nexport const WATCH = true;\n"],"mappings":";;;AAAA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"content.cjs","names":[],"sources":["../../../src/defaultValues/content.ts"],"sourcesContent":["export const FILE_EXTENSIONS = [\n '.content.ts',\n '.content.js',\n '.content.cjs',\n '.content.mjs',\n '.content.json',\n '.content.json5',\n '.content.jsonc',\n '.content.tsx',\n '.content.jsx',\n '.content.md',\n '.content.mdx',\n '.content.yaml',\n '.content.yml',\n];\n\nexport const EXCLUDED_PATHS = [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.expo/**',\n '**/.vercel/**',\n '**/.turbo/**',\n '**/.tanstack/**',\n '**/.output/**',\n '**/.svelte-kit/**',\n];\n\nexport const CONTENT_DIR = ['.'];\n\nexport const CODE_DIR = ['.'];\n\nexport const I18NEXT_DICTIONARIES_DIR = 'i18next_resources';\n\nexport const REACT_INTL_MESSAGES_DIR = 'intl_messages';\n\nexport const WATCH = true;\n"],"mappings":";;;AAAA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,cAAc,CAAC,GAAG;AAE/B,MAAa,WAAW,CAAC,GAAG;AAE5B,MAAa,2BAA2B;AAExC,MAAa,0BAA0B;AAEvC,MAAa,QAAQ"}
|
|
@@ -5,10 +5,14 @@ const require_defaultValues_content = require('./content.cjs');
|
|
|
5
5
|
const require_defaultValues_dictionary = require('./dictionary.cjs');
|
|
6
6
|
const require_defaultValues_system = require('./system.cjs');
|
|
7
7
|
const require_defaultValues_routing = require('./routing.cjs');
|
|
8
|
+
const require_defaultValues_analytics = require('./analytics.cjs');
|
|
8
9
|
const require_defaultValues_editor = require('./editor.cjs');
|
|
9
10
|
const require_defaultValues_internationalization = require('./internationalization.cjs');
|
|
10
11
|
const require_defaultValues_log = require('./log.cjs');
|
|
11
12
|
|
|
13
|
+
exports.ANALYTICS_ENABLED = require_defaultValues_analytics.ANALYTICS_ENABLED;
|
|
14
|
+
exports.ANALYTICS_FLUSH_INTERVAL = require_defaultValues_analytics.ANALYTICS_FLUSH_INTERVAL;
|
|
15
|
+
exports.ANALYTICS_SAMPLE_RATE = require_defaultValues_analytics.ANALYTICS_SAMPLE_RATE;
|
|
12
16
|
exports.APPLICATION_URL = require_defaultValues_editor.APPLICATION_URL;
|
|
13
17
|
exports.BACKEND_URL = require_defaultValues_editor.BACKEND_URL;
|
|
14
18
|
exports.BASE_PATH = require_defaultValues_routing.BASE_PATH;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internationalization.cjs","names":[],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictMode } from '@intlayer/types/config';\n\nexport const LOCALES: Locale[] = ['en'];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = 'en';\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":";;;AAGA,MAAa,UAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"internationalization.cjs","names":[],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictMode } from '@intlayer/types/config';\n\nexport const LOCALES: Locale[] = ['en'];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = 'en';\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":";;;AAGA,MAAa,UAAoB,CAAC,IAAI;AAEtC,MAAa,mBAA6B,CAAC;AAE3C,MAAa,iBAAyB;AAEtC,MAAa,cAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.cjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingStorageInput } from '@intlayer/types/config';\n\nexport const HEADER_NAME = 'x-intlayer-locale';\n\nexport const COOKIE_NAME = 'INTLAYER_LOCALE';\nexport const LOCALE_STORAGE_NAME = 'INTLAYER_LOCALE';\n\nexport const BASE_PATH = '';\n\nexport const SERVER_SET_COOKIE = 'always';\n\nexport const ROUTING_MODE = 'prefix-no-default';\n\nexport const ENABLE_PROXY = true;\n\nexport const STORAGE: RoutingStorageInput = ['cookie', 'header'];\n"],"mappings":";;;AAEA,MAAa,cAAc;AAE3B,MAAa,cAAc;AAC3B,MAAa,sBAAsB;AAEnC,MAAa,YAAY;AAEzB,MAAa,oBAAoB;AAEjC,MAAa,eAAe;AAE5B,MAAa,eAAe;AAE5B,MAAa,UAA+B,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"routing.cjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingStorageInput } from '@intlayer/types/config';\n\nexport const HEADER_NAME = 'x-intlayer-locale';\n\nexport const COOKIE_NAME = 'INTLAYER_LOCALE';\nexport const LOCALE_STORAGE_NAME = 'INTLAYER_LOCALE';\n\nexport const BASE_PATH = '';\n\nexport const SERVER_SET_COOKIE = 'always';\n\nexport const ROUTING_MODE = 'prefix-no-default';\n\nexport const ENABLE_PROXY = true;\n\nexport const STORAGE: RoutingStorageInput = ['cookie', 'header'];\n"],"mappings":";;;AAEA,MAAa,cAAc;AAE3B,MAAa,cAAc;AAC3B,MAAa,sBAAsB;AAEnC,MAAa,YAAY;AAEzB,MAAa,oBAAoB;AAEjC,MAAa,eAAe;AAE5B,MAAa,eAAe;AAE5B,MAAa,UAA+B,CAAC,UAAU,QAAQ"}
|
|
@@ -57,7 +57,7 @@ const formatDictionarySelectorEnvVar = (hasDictionarySelector, wrapKey = (key) =
|
|
|
57
57
|
* // { 'process.env.INTLAYER_ROUTING_MODE': '"prefix-no-default"', ... }
|
|
58
58
|
*/
|
|
59
59
|
const getConfigEnvVars = (config, wrapKey = (key) => key, wrapValue = (value) => value) => {
|
|
60
|
-
const { routing, editor } = config;
|
|
60
|
+
const { routing, editor, analytics } = config;
|
|
61
61
|
const envVars = { [wrapKey("INTLAYER_ROUTING_MODE")]: wrapValue(routing.mode) };
|
|
62
62
|
if (routing.enableProxy === false) envVars[wrapKey("INTLAYER_ROUTING_ENABLE_PROXY")] = wrapValue("false");
|
|
63
63
|
if (!routing.rewrite) envVars[wrapKey("INTLAYER_ROUTING_REWRITE_RULES")] = wrapValue("false");
|
|
@@ -67,6 +67,7 @@ const getConfigEnvVars = (config, wrapKey = (key) => key, wrapValue = (value) =>
|
|
|
67
67
|
if (!routing.storage.sessionStorage || routing.storage.sessionStorage.length === 0) envVars[wrapKey("INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE")] = wrapValue("false");
|
|
68
68
|
if (!routing.storage.headers || routing.storage.headers.length === 0) envVars[wrapKey("INTLAYER_ROUTING_STORAGE_HEADERS")] = wrapValue("false");
|
|
69
69
|
if (editor?.enabled === false) envVars[wrapKey("INTLAYER_EDITOR_ENABLED")] = wrapValue("false");
|
|
70
|
+
if (analytics?.enabled !== true || !editor?.clientId) envVars[wrapKey("INTLAYER_ANALYTICS_ENABLED")] = wrapValue("false");
|
|
70
71
|
return envVars;
|
|
71
72
|
};
|
|
72
73
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envVars.cjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a camelCase node-type string to SCREAMING_SNAKE_CASE so that\n * the generated env-var name matches what the plugin source files check.\n *\n * @example\n * toScreamingSnakeCase('reactNode') // 'REACT_NODE'\n * toScreamingSnakeCase('markdown') // 'MARKDOWN'\n */\nconst toScreamingSnakeCase = (str: string): string =>\n str\n .replace(/([A-Z])/g, '_$1')\n .toUpperCase()\n .replace(/^_/, ''); // strip any leading underscore\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['reactNode'], (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_NODE_TYPE_REACT_NODE': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[wrapKey(`INTLAYER_NODE_TYPE_${toScreamingSnakeCase(nodeType)}`)] =\n wrapValue('false');\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns the env-var definition disabling the dictionary-selector resolution\n * path (collections, variants) when no built dictionary declares\n * a qualifier. Set to `\"false\"` so bundlers can dead-code-eliminate the\n * selector branch in `getIntlayer` / `useIntlayer`.\n *\n * Emits nothing when selectors are used, leaving the runtime default in place.\n *\n * @example\n * formatDictionarySelectorEnvVar(false)\n * // { INTLAYER_DICTIONARY_SELECTOR: '\"false\"' }\n *\n * formatDictionarySelectorEnvVar(true)\n * // {}\n *\n * formatDictionarySelectorEnvVar(false, (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_DICTIONARY_SELECTOR': '\"false\"' }\n */\nexport const formatDictionarySelectorEnvVar = (\n hasDictionarySelector: boolean,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n hasDictionarySelector\n ? {}\n : { [wrapKey('INTLAYER_DICTIONARY_SELECTOR')]: wrapValue('false') };\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> => {\n const { routing, editor } = config;\n\n const envVars: Record<string, string> = {\n [wrapKey('INTLAYER_ROUTING_MODE')]: wrapValue(routing.mode),\n };\n\n if (routing.enableProxy === false) {\n envVars[wrapKey('INTLAYER_ROUTING_ENABLE_PROXY')] = wrapValue('false');\n }\n\n if (!routing.rewrite) {\n envVars[wrapKey('INTLAYER_ROUTING_REWRITE_RULES')] = wrapValue('false');\n }\n\n if (!routing.domains || Object.keys(routing.domains).length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_DOMAINS')] = wrapValue('false');\n }\n\n if (!routing.storage.cookies || routing.storage.cookies.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_COOKIES')] = wrapValue('false');\n }\n\n if (\n !routing.storage.localStorage ||\n routing.storage.localStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_LOCALSTORAGE')] =\n wrapValue('false');\n }\n\n if (\n !routing.storage.sessionStorage ||\n routing.storage.sessionStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE')] =\n wrapValue('false');\n }\n\n if (!routing.storage.headers || routing.storage.headers.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_HEADERS')] = wrapValue('false');\n }\n\n if (editor?.enabled === false) {\n envVars[wrapKey('INTLAYER_EDITOR_ENABLED')] = wrapValue('false');\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,wBAAwB,QAC5B,IACG,QAAQ,YAAY,
|
|
1
|
+
{"version":3,"file":"envVars.cjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a camelCase node-type string to SCREAMING_SNAKE_CASE so that\n * the generated env-var name matches what the plugin source files check.\n *\n * @example\n * toScreamingSnakeCase('reactNode') // 'REACT_NODE'\n * toScreamingSnakeCase('markdown') // 'MARKDOWN'\n */\nconst toScreamingSnakeCase = (str: string): string =>\n str\n .replace(/([A-Z])/g, '_$1')\n .toUpperCase()\n .replace(/^_/, ''); // strip any leading underscore\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['reactNode'], (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_NODE_TYPE_REACT_NODE': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[wrapKey(`INTLAYER_NODE_TYPE_${toScreamingSnakeCase(nodeType)}`)] =\n wrapValue('false');\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns the env-var definition disabling the dictionary-selector resolution\n * path (collections, variants) when no built dictionary declares\n * a qualifier. Set to `\"false\"` so bundlers can dead-code-eliminate the\n * selector branch in `getIntlayer` / `useIntlayer`.\n *\n * Emits nothing when selectors are used, leaving the runtime default in place.\n *\n * @example\n * formatDictionarySelectorEnvVar(false)\n * // { INTLAYER_DICTIONARY_SELECTOR: '\"false\"' }\n *\n * formatDictionarySelectorEnvVar(true)\n * // {}\n *\n * formatDictionarySelectorEnvVar(false, (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_DICTIONARY_SELECTOR': '\"false\"' }\n */\nexport const formatDictionarySelectorEnvVar = (\n hasDictionarySelector: boolean,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n hasDictionarySelector\n ? {}\n : { [wrapKey('INTLAYER_DICTIONARY_SELECTOR')]: wrapValue('false') };\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> => {\n const { routing, editor, analytics } = config;\n\n const envVars: Record<string, string> = {\n [wrapKey('INTLAYER_ROUTING_MODE')]: wrapValue(routing.mode),\n };\n\n if (routing.enableProxy === false) {\n envVars[wrapKey('INTLAYER_ROUTING_ENABLE_PROXY')] = wrapValue('false');\n }\n\n if (!routing.rewrite) {\n envVars[wrapKey('INTLAYER_ROUTING_REWRITE_RULES')] = wrapValue('false');\n }\n\n if (!routing.domains || Object.keys(routing.domains).length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_DOMAINS')] = wrapValue('false');\n }\n\n if (!routing.storage.cookies || routing.storage.cookies.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_COOKIES')] = wrapValue('false');\n }\n\n if (\n !routing.storage.localStorage ||\n routing.storage.localStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_LOCALSTORAGE')] =\n wrapValue('false');\n }\n\n if (\n !routing.storage.sessionStorage ||\n routing.storage.sessionStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE')] =\n wrapValue('false');\n }\n\n if (!routing.storage.headers || routing.storage.headers.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_HEADERS')] = wrapValue('false');\n }\n\n if (editor?.enabled === false) {\n envVars[wrapKey('INTLAYER_EDITOR_ENABLED')] = wrapValue('false');\n }\n\n // Analytics is strictly opt-in (`analytics.enabled === true`) and requires a\n // project key (`editor.clientId`) for attribution. Otherwise, disable it so\n // bundlers dead-code-eliminate the whole `@intlayer/analytics` integration\n // (providers + node plugins).\n if (analytics?.enabled !== true || !editor?.clientId) {\n envVars[wrapKey('INTLAYER_ANALYTICS_ENABLED')] = wrapValue('false');\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,wBAAwB,QAC5B,IACG,QAAQ,YAAY,KAAK,CAAC,CAC1B,YAAY,CAAC,CACb,QAAQ,MAAM,EAAE;;;;;;;;;;;;AAarB,MAAa,0BACX,WACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UAE/B,UAAU,QACP,KAAK,aAAa;CACjB,IAAI,QAAQ,sBAAsB,qBAAqB,QAAQ,GAAG,KAChE,UAAU,OAAO;CACnB,OAAO;AACT,GACA,CAAC,CACH;;;;;;;;;;;;;;;;;;;AAoBF,MAAa,kCACX,uBACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UAE/B,wBACI,CAAC,IACD,GAAG,QAAQ,8BAA8B,IAAI,UAAU,OAAO,EAAE;;;;;;;;;;;;;AActE,MAAa,oBACX,QACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UACJ;CAC3B,MAAM,EAAE,SAAS,QAAQ,cAAc;CAEvC,MAAM,UAAkC,GACrC,QAAQ,uBAAuB,IAAI,UAAU,QAAQ,IAAI,EAC5D;CAEA,IAAI,QAAQ,gBAAgB,OAC1B,QAAQ,QAAQ,+BAA+B,KAAK,UAAU,OAAO;CAGvE,IAAI,CAAC,QAAQ,SACX,QAAQ,QAAQ,gCAAgC,KAAK,UAAU,OAAO;CAGxE,IAAI,CAAC,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,CAAC,CAAC,WAAW,GAC9D,QAAQ,QAAQ,0BAA0B,KAAK,UAAU,OAAO;CAGlE,IAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,GACjE,QAAQ,QAAQ,kCAAkC,KAAK,UAAU,OAAO;CAG1E,IACE,CAAC,QAAQ,QAAQ,gBACjB,QAAQ,QAAQ,aAAa,WAAW,GAExC,QAAQ,QAAQ,uCAAuC,KACrD,UAAU,OAAO;CAGrB,IACE,CAAC,QAAQ,QAAQ,kBACjB,QAAQ,QAAQ,eAAe,WAAW,GAE1C,QAAQ,QAAQ,yCAAyC,KACvD,UAAU,OAAO;CAGrB,IAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,GACjE,QAAQ,QAAQ,kCAAkC,KAAK,UAAU,OAAO;CAG1E,IAAI,QAAQ,YAAY,OACtB,QAAQ,QAAQ,yBAAyB,KAAK,UAAU,OAAO;CAOjE,IAAI,WAAW,YAAY,QAAQ,CAAC,QAAQ,UAC1C,QAAQ,QAAQ,4BAA4B,KAAK,UAAU,OAAO;CAGpE,OAAO;AACT"}
|
package/dist/cjs/loadEnvFile.cjs
CHANGED
|
@@ -14,16 +14,53 @@ const getEnvFilePath = (env = process.env.NODE_ENV ?? "development", envFile) =>
|
|
|
14
14
|
".env"
|
|
15
15
|
]).find(node_fs.existsSync);
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Cache of parsed env files keyed by `cwd|env|envFile`. Loading content
|
|
19
|
+
* declarations calls `loadEnvFile` once per file; without this every call pays
|
|
20
|
+
* up to 4 `existsSync` probes plus a dotenv read+parse. A cached hit is
|
|
21
|
+
* validated with a single `stat` so edits to the env file are still picked up.
|
|
22
|
+
*/
|
|
23
|
+
const envFileCache = /* @__PURE__ */ new Map();
|
|
24
|
+
const parseEnvFile = (envFilePath) => {
|
|
25
|
+
const parsedEnv = {};
|
|
21
26
|
dotenv.default.config({
|
|
22
|
-
path:
|
|
23
|
-
processEnv:
|
|
27
|
+
path: envFilePath,
|
|
28
|
+
processEnv: parsedEnv,
|
|
24
29
|
quiet: true
|
|
25
30
|
});
|
|
26
|
-
return
|
|
31
|
+
return parsedEnv;
|
|
32
|
+
};
|
|
33
|
+
const loadEnvFile = (options) => {
|
|
34
|
+
const env = options?.env ?? DEFAULT_ENV;
|
|
35
|
+
const cacheKey = `${process.cwd()}|${env}|${options?.envFile ?? ""}`;
|
|
36
|
+
const cachedEntry = envFileCache.get(cacheKey);
|
|
37
|
+
if (cachedEntry) if (cachedEntry.envFilePath === void 0) {
|
|
38
|
+
if (!getEnvFilePath(env, options?.envFile)) return cachedEntry.parsedEnv;
|
|
39
|
+
} else try {
|
|
40
|
+
const stats = (0, node_fs.statSync)(cachedEntry.envFilePath);
|
|
41
|
+
if (stats.mtimeMs === cachedEntry.mtimeMs && stats.size === cachedEntry.size) return cachedEntry.parsedEnv;
|
|
42
|
+
} catch {}
|
|
43
|
+
const envFilePath = getEnvFilePath(env, options?.envFile);
|
|
44
|
+
if (!envFilePath) {
|
|
45
|
+
envFileCache.set(cacheKey, {
|
|
46
|
+
envFilePath: void 0,
|
|
47
|
+
mtimeMs: 0,
|
|
48
|
+
size: 0,
|
|
49
|
+
parsedEnv: {}
|
|
50
|
+
});
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
const parsedEnv = parseEnvFile(envFilePath);
|
|
54
|
+
try {
|
|
55
|
+
const stats = (0, node_fs.statSync)(envFilePath);
|
|
56
|
+
envFileCache.set(cacheKey, {
|
|
57
|
+
envFilePath,
|
|
58
|
+
mtimeMs: stats.mtimeMs,
|
|
59
|
+
size: stats.size,
|
|
60
|
+
parsedEnv
|
|
61
|
+
});
|
|
62
|
+
} catch {}
|
|
63
|
+
return parsedEnv;
|
|
27
64
|
};
|
|
28
65
|
|
|
29
66
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadEnvFile.cjs","names":["existsSync"],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions
|
|
1
|
+
{"version":3,"file":"loadEnvFile.cjs","names":["existsSync"],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\ntype EnvFileCacheEntry = {\n /** The env file that was resolved and parsed (undefined if none exists). */\n envFilePath: string | undefined;\n /** Fingerprint of the parsed file, used to detect edits. */\n mtimeMs: number;\n size: number;\n /** The parsed env variables. */\n parsedEnv: Record<string, string>;\n};\n\n/**\n * Cache of parsed env files keyed by `cwd|env|envFile`. Loading content\n * declarations calls `loadEnvFile` once per file; without this every call pays\n * up to 4 `existsSync` probes plus a dotenv read+parse. A cached hit is\n * validated with a single `stat` so edits to the env file are still picked up.\n */\nconst envFileCache = new Map<string, EnvFileCacheEntry>();\n\nconst parseEnvFile = (envFilePath: string): Record<string, string> => {\n const parsedEnv: Record<string, string> = {};\n\n dotenv.config({\n path: envFilePath,\n processEnv: parsedEnv,\n quiet: true,\n });\n\n return parsedEnv;\n};\n\nexport const loadEnvFile = (\n options?: Partial<LoadEnvFileOptions>\n): Record<string, string> => {\n const env = options?.env ?? DEFAULT_ENV;\n\n // Env file candidates are resolved relative to the working directory\n const cacheKey = `${process.cwd()}|${env}|${options?.envFile ?? ''}`;\n\n const cachedEntry = envFileCache.get(cacheKey);\n\n if (cachedEntry) {\n if (cachedEntry.envFilePath === undefined) {\n // No env file existed. Re-probe cheaply in case one was created since.\n const envFilePath = getEnvFilePath(env, options?.envFile);\n if (!envFilePath) return cachedEntry.parsedEnv;\n } else {\n try {\n const stats = statSync(cachedEntry.envFilePath);\n if (\n stats.mtimeMs === cachedEntry.mtimeMs &&\n stats.size === cachedEntry.size\n ) {\n return cachedEntry.parsedEnv;\n }\n } catch {\n // File was removed — fall through and re-resolve\n }\n }\n }\n\n const envFilePath = getEnvFilePath(env, options?.envFile);\n\n if (!envFilePath) {\n envFileCache.set(cacheKey, {\n envFilePath: undefined,\n mtimeMs: 0,\n size: 0,\n parsedEnv: {},\n });\n return {};\n }\n\n const parsedEnv = parseEnvFile(envFilePath);\n\n try {\n const stats = statSync(envFilePath);\n envFileCache.set(cacheKey, {\n envFilePath,\n mtimeMs: stats.mtimeMs,\n size: stats.size,\n parsedEnv,\n });\n } catch {\n // Race: file removed between parse and stat — skip caching this round\n }\n\n return parsedEnv; // Return the parsed env object\n};\n"],"mappings":";;;;;;;AAGA,MAAM,cAAc,QAAQ,IAAI,YAAY;AAO5C,MAAa,kBACX,MAAc,QAAQ,IAAI,YAAY,eACtC,YACuB;CAKvB,QAJiB,UACb,CAAC,OAAO,IACR;EAAC,QAAQ,IAAI;EAAS,QAAQ;EAAO;EAAc;CAAM,EAE9C,CAAC,KAAKA,kBAAU;AACjC;;;;;;;AAkBA,MAAM,+BAAe,IAAI,IAA+B;AAExD,MAAM,gBAAgB,gBAAgD;CACpE,MAAM,YAAoC,CAAC;CAE3C,eAAO,OAAO;EACZ,MAAM;EACN,YAAY;EACZ,OAAO;CACT,CAAC;CAED,OAAO;AACT;AAEA,MAAa,eACX,YAC2B;CAC3B,MAAM,MAAM,SAAS,OAAO;CAG5B,MAAM,WAAW,GAAG,QAAQ,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,WAAW;CAEhE,MAAM,cAAc,aAAa,IAAI,QAAQ;CAE7C,IAAI,aACF,IAAI,YAAY,gBAAgB,QAG9B;MAAI,CADgB,eAAe,KAAK,SAAS,OAClC,GAAG,OAAO,YAAY;CAAS,OAE9C,IAAI;EACF,MAAM,8BAAiB,YAAY,WAAW;EAC9C,IACE,MAAM,YAAY,YAAY,WAC9B,MAAM,SAAS,YAAY,MAE3B,OAAO,YAAY;CAEvB,QAAQ,CAER;CAIJ,MAAM,cAAc,eAAe,KAAK,SAAS,OAAO;CAExD,IAAI,CAAC,aAAa;EAChB,aAAa,IAAI,UAAU;GACzB,aAAa;GACb,SAAS;GACT,MAAM;GACN,WAAW,CAAC;EACd,CAAC;EACD,OAAO,CAAC;CACV;CAEA,MAAM,YAAY,aAAa,WAAW;CAE1C,IAAI;EACF,MAAM,8BAAiB,WAAW;EAClC,aAAa,IAAI,UAAU;GACzB;GACA,SAAS,MAAM;GACf,MAAM,MAAM;GACZ;EACF,CAAC;CACH,QAAQ,CAER;CAEA,OAAO;AACT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
let node_path = require("node:path");
|
|
4
3
|
let esbuild = require("esbuild");
|
|
5
4
|
let node_url = require("node:url");
|
|
@@ -41,10 +40,11 @@ const getTransformationOptions = (filePath) => ({
|
|
|
41
40
|
define: { "import.meta.url": JSON.stringify((0, node_url.pathToFileURL)(filePath).href) }
|
|
42
41
|
});
|
|
43
42
|
const bundleFileSync = (code, filePath, options) => {
|
|
43
|
+
const extension = (0, node_path.extname)(filePath);
|
|
44
44
|
return (0, esbuild.buildSync)({
|
|
45
45
|
stdin: {
|
|
46
46
|
contents: code,
|
|
47
|
-
loader: getLoader(
|
|
47
|
+
loader: getLoader(extension),
|
|
48
48
|
resolveDir: (0, node_path.dirname)(filePath),
|
|
49
49
|
sourcefile: filePath
|
|
50
50
|
},
|
|
@@ -53,10 +53,11 @@ const bundleFileSync = (code, filePath, options) => {
|
|
|
53
53
|
}).outputFiles?.[0].text;
|
|
54
54
|
};
|
|
55
55
|
const bundleFile = async (code, filePath, options) => {
|
|
56
|
+
const extension = (0, node_path.extname)(filePath);
|
|
56
57
|
return (await (0, esbuild.build)({
|
|
57
58
|
stdin: {
|
|
58
59
|
contents: code,
|
|
59
|
-
loader: getLoader(
|
|
60
|
+
loader: getLoader(extension),
|
|
60
61
|
resolveDir: (0, node_path.dirname)(filePath),
|
|
61
62
|
sourcefile: filePath
|
|
62
63
|
},
|
|
@@ -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":";;;;;;AAaA,MAAa,aAAa,cAA8B;CACtD,QAAQ,WAAR;EACE,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;CACV;CACA,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,UAAU,CAAC,SAAS;CACpB,QAAQ;CACR,QAAQ,EACN,mBAAmB,KAAK,sCAAwB,QAAQ,CAAC,CAAC,IAAI,EAChE;AACF;AAEA,MAAa,kBACX,MACA,UACA,YACuB;CACvB,MAAM,mCAAoB,QAAQ;CAgBlC,8BAb4C;EAC1C,OAAO;GACL,UAAU;GACV,QALW,UAAU,SAKhB;GACL,mCAAoB,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAEsC,CAAC,CAAC,cAAc,EAAE,CAAC;AAG3D;AAEA,MAAa,aAAa,OACxB,MACA,UACA,YACgC;CAChC,MAAM,mCAAoB,QAAQ;CAgBlC,QAF2B,yBAXmB;EAC5C,OAAO;GACL,UAAU;GACV,QALW,UAAU,SAKhB;GACL,mCAAoB,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAAC,EAEsC,CAAC,cAAc,EAAE,CAAC;AAG3D"}
|
|
@@ -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":";;;;AAEA,MAAM,qBAAqB;CACzB,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,WAAW;CACX,UAAU;CACV,OAAO;CAEP,UAAU;CACV,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;CACV;AACF;AAEA,MAAa,eAAe,OAAO,iBACjC,yBAAY;CACV,GAAG;CACH,GAAG;AACL,CAAC"}
|
|
@@ -8,6 +8,7 @@ const require_loadExternalFile_bundleJSFile = require('./bundleJSFile.cjs');
|
|
|
8
8
|
exports.bundleFile = require_loadExternalFile_bundleFile.bundleFile;
|
|
9
9
|
exports.bundleFileSync = require_loadExternalFile_bundleFile.bundleFileSync;
|
|
10
10
|
exports.bundleJSFile = require_loadExternalFile_bundleJSFile.bundleJSFile;
|
|
11
|
+
exports.clearTranspileCache = require_loadExternalFile_transpileTSToCJS.clearTranspileCache;
|
|
11
12
|
exports.getLoader = require_loadExternalFile_bundleFile.getLoader;
|
|
12
13
|
exports.getSandBoxContext = require_loadExternalFile_parseFileContent.getSandBoxContext;
|
|
13
14
|
exports.loadExternalFile = require_loadExternalFile_loadExternalFile.loadExternalFile;
|
|
@@ -25,13 +25,13 @@ const loadExternalFileSync = (filePath, options) => {
|
|
|
25
25
|
require_logger.logger("File could not be loaded.", { level: "error" });
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const fileContent = require_loadExternalFile_parseFileContent.parseFileContent(moduleResultString, {
|
|
28
|
+
const fileContent = withPreloadedGlobals(options?.preloadGlobals, () => require_loadExternalFile_parseFileContent.parseFileContent(moduleResultString, {
|
|
29
29
|
projectRequire: options?.projectRequire,
|
|
30
30
|
envVarOptions: options?.envVarOptions,
|
|
31
31
|
additionalEnvVars: options?.additionalEnvVars,
|
|
32
32
|
mocks: options?.mocks,
|
|
33
33
|
aliases: options?.aliases
|
|
34
|
-
});
|
|
34
|
+
}));
|
|
35
35
|
if (typeof fileContent === "undefined") {
|
|
36
36
|
require_logger.logger(`File could not be loaded. Path : ${filePath}`);
|
|
37
37
|
return;
|
|
@@ -44,15 +44,17 @@ const loadExternalFileSync = (filePath, options) => {
|
|
|
44
44
|
const withPreloadedGlobals = (globals, fn) => {
|
|
45
45
|
if (!globals) return fn();
|
|
46
46
|
const globalVars = globalThis;
|
|
47
|
-
const
|
|
47
|
+
const previousValues = {};
|
|
48
|
+
const previouslyPresent = {};
|
|
48
49
|
for (const [key, value] of Object.entries(globals)) {
|
|
49
|
-
|
|
50
|
+
previouslyPresent[key] = key in globalVars;
|
|
51
|
+
previousValues[key] = globalVars[key];
|
|
50
52
|
globalVars[key] = value;
|
|
51
53
|
}
|
|
52
54
|
try {
|
|
53
55
|
return fn();
|
|
54
56
|
} finally {
|
|
55
|
-
for (const key of Object.keys(globals)) if (
|
|
57
|
+
for (const key of Object.keys(globals)) if (previouslyPresent[key]) globalVars[key] = previousValues[key];
|
|
56
58
|
else delete globalVars[key];
|
|
57
59
|
}
|
|
58
60
|
};
|
|
@@ -64,7 +66,10 @@ const withPreloadedGlobals = (globals, fn) => {
|
|
|
64
66
|
const loadExternalFile = async (filePath, options) => {
|
|
65
67
|
const fileExtension = (0, node_path.extname)(filePath);
|
|
66
68
|
try {
|
|
67
|
-
if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc")
|
|
69
|
+
if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") {
|
|
70
|
+
const fileContent = await (0, node_fs_promises.readFile)(filePath, "utf-8");
|
|
71
|
+
return parseJSON5(fileContent);
|
|
72
|
+
}
|
|
68
73
|
const moduleResultString = await require_loadExternalFile_transpileTSToCJS.transpileTSToCJS(await (0, node_fs_promises.readFile)(filePath, "utf-8"), filePath, options?.buildOptions);
|
|
69
74
|
if (!moduleResultString) {
|
|
70
75
|
require_logger.logger("File could not be loaded.", { level: "error" });
|
|
@@ -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 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 /**\n * Key-value pairs to temporarily set on the main Node.js `globalThis` for the\n * synchronous duration of `parseFileContent` / `runInNewContext`. External modules\n * loaded via `require()` inside the VM (e.g. `@intlayer/core`'s `file()` helper)\n * run in the main context and read from the real `globalThis`, not the VM sandbox.\n * Values are restored (or deleted) after `runInNewContext` returns.\n */\n preloadGlobals?: Record<string, unknown>;\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
|
|
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 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 /**\n * Key-value pairs to temporarily set on the main Node.js `globalThis` for the\n * synchronous duration of `parseFileContent` / `runInNewContext`. External modules\n * loaded via `require()` inside the VM (e.g. `@intlayer/core`'s `file()` helper)\n * run in the main context and read from the real `globalThis`, not the VM sandbox.\n * Values are restored (or deleted) after `runInNewContext` returns.\n */\n preloadGlobals?: Record<string, unknown>;\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 // parseFileContent/runInNewContext is synchronous, so withPreloadedGlobals\n // fully restores the globals before returning.\n const fileContent = withPreloadedGlobals(options?.preloadGlobals, () =>\n 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\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\nconst withPreloadedGlobals = <T>(\n globals: Record<string, unknown> | undefined,\n fn: () => T\n): T => {\n if (!globals) return fn();\n\n const globalVars = globalThis as Record<string, unknown>;\n const previousValues: Record<string, unknown> = {};\n const previouslyPresent: Record<string, boolean> = {};\n\n for (const [key, value] of Object.entries(globals)) {\n previouslyPresent[key] = key in globalVars;\n previousValues[key] = globalVars[key];\n globalVars[key] = value;\n }\n\n try {\n return fn();\n } finally {\n for (const key of Object.keys(globals)) {\n // `in` check (not `!== undefined`) so a global that legitimately held\n // `undefined` is restored rather than deleted.\n if (previouslyPresent[key]) {\n globalVars[key] = previousValues[key];\n } else {\n delete globalVars[key];\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 // parseFileContent/runInNewContext is synchronous, so withPreloadedGlobals\n // has no interleaving risk even when multiple files are processed concurrently.\n const fileContent = withPreloadedGlobals(options?.preloadGlobals, () =>\n 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\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":";;;;;;;;;;;;AAiBA,MAAM,aAAaA,cAAM,SAAUA,cAAc,SAAS;;;;;;AAqB1D,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,uCAAwB,QAAQ,KAAK;CAE3C,IAAI;EACF,IACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,UAGlB,OAAO,qCAAwB,UAAU,OAAO,CAAC;EAMnD,MAAM,qBAAyCC,yFAFrB,UAAU,OAG/B,GACH,UACA,SAAS,YACX;EAEA,IAAI,CAAC,oBAAoB;GACvB,sBAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;GACtD;EACF;EAIA,MAAM,cAAc,qBAAqB,SAAS,sBAChDC,2DAAiB,oBAAoB;GACnC,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;EACpB,CAAC,CACH;EAEA,IAAI,OAAO,gBAAgB,aAAa;GACtC,sBAAO,oCAAoC,UAAU;GACrD;EACF;EAEA,OAAO;CACT,SAAS,OAAO;EACd,sBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAChD,GACA,EACE,OAAO,QACT,CACF;CACF;AACF;AAEA,MAAM,wBACJ,SACA,OACM;CACN,IAAI,CAAC,SAAS,OAAO,GAAG;CAExB,MAAM,aAAa;CACnB,MAAM,iBAA0C,CAAC;CACjD,MAAM,oBAA6C,CAAC;CAEpD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;EAClD,kBAAkB,OAAO,OAAO;EAChC,eAAe,OAAO,WAAW;EACjC,WAAW,OAAO;CACpB;CAEA,IAAI;EACF,OAAO,GAAG;CACZ,UAAU;EACR,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,GAGnC,IAAI,kBAAkB,MACpB,WAAW,OAAO,eAAe;OAEjC,OAAO,WAAW;CAGxB;AACF;;;;;;AAOA,MAAa,mBAAmB,OAC9B,UACA,YAC6B;CAC7B,MAAM,uCAAwB,QAAQ;CAEtC,IAAI;EACF,IACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,UAClB;GAEA,MAAM,cAAc,qCAAe,UAAU,OAAO;GACpD,OAAO,WAAW,WAAW;EAC/B;EAKA,MAAM,qBAAyC,MAAMC,2DACnD,qCAH0B,UAAU,OAAO,GAI3C,UACA,SAAS,YACX;EAEA,IAAI,CAAC,oBAAoB;GACvB,sBAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;GACtD;EACF;EAIA,MAAM,cAAc,qBAAqB,SAAS,sBAChDD,2DAAiB,oBAAoB;GACnC,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;EACpB,CAAC,CACH;EAEA,IAAI,OAAO,gBAAgB,aAAa;GACtC,sBAAO,oCAAoCE,4BAAa,QAAQ,GAAG;GACnE;EACF;EAEA,OAAO;CACT,SAAS,OAAO;EACd,IAAI,SAAS,YAAY,MACvB,sBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAChD,GACA,EACE,OAAO,QACT,CACF;CAEJ;AACF"}
|
|
@@ -27,9 +27,58 @@ const NODE_GLOBALS = [
|
|
|
27
27
|
"crypto",
|
|
28
28
|
"structuredClone"
|
|
29
29
|
];
|
|
30
|
+
/**
|
|
31
|
+
* Cache of the project's React module (or the JSX-capturing fallback) keyed by
|
|
32
|
+
* the require's resolution paths. Node does not cache *failed* resolutions, so
|
|
33
|
+
* without this every sandbox creation in a non-React project (Vue, Svelte,
|
|
34
|
+
* Angular…) pays a full node_modules walk that ends in a throw.
|
|
35
|
+
*/
|
|
36
|
+
const reactModuleCache = /* @__PURE__ */ new Map();
|
|
37
|
+
/**
|
|
38
|
+
* Fallback React implementation used when React is not installed in the
|
|
39
|
+
* project. It captures JSX elements as plain objects so JSX can be used in
|
|
40
|
+
* content declarations (esbuild's tsx loader defaults to React.createElement).
|
|
41
|
+
*/
|
|
42
|
+
const createFallbackReact = () => ({
|
|
43
|
+
createElement: (type, props, ...children) => ({
|
|
44
|
+
type,
|
|
45
|
+
props: {
|
|
46
|
+
...props,
|
|
47
|
+
children: children.length <= 1 ? children[0] : children
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
Fragment: Symbol.for("react.fragment")
|
|
51
|
+
});
|
|
52
|
+
const getReactGlobal = (baseRequire) => {
|
|
53
|
+
const resolutionKey = baseRequire.resolve.paths?.("react")?.join("|") ?? "<default>";
|
|
54
|
+
const cachedReactModule = reactModuleCache.get(resolutionKey);
|
|
55
|
+
if (cachedReactModule) return cachedReactModule;
|
|
56
|
+
let reactGlobal;
|
|
57
|
+
try {
|
|
58
|
+
reactGlobal = { React: baseRequire("react") };
|
|
59
|
+
} catch (_err) {
|
|
60
|
+
reactGlobal = { React: createFallbackReact() };
|
|
61
|
+
}
|
|
62
|
+
reactModuleCache.set(resolutionKey, reactGlobal);
|
|
63
|
+
return reactGlobal;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Snapshot of the non-env `process` properties, taken once at module load.
|
|
67
|
+
* Spreading `process` enumerates ~100 properties (some behind getters); doing
|
|
68
|
+
* it per sandbox is wasteful since everything except `env` is static.
|
|
69
|
+
*/
|
|
70
|
+
const processSnapshot = { ...process };
|
|
71
|
+
/**
|
|
72
|
+
* Builds the global context handed to `runInNewContext`.
|
|
73
|
+
*
|
|
74
|
+
* SECURITY NOTE: this sandbox exists for global-scope hygiene (fresh
|
|
75
|
+
* module/exports, controlled env), NOT for containment. It exposes the real
|
|
76
|
+
* project `require`, a copy of `process`, and `fetch` — code executed here has
|
|
77
|
+
* full host privileges. Only ever run trusted, build-time project files
|
|
78
|
+
* (same trust model as `vite.config.ts`).
|
|
79
|
+
*/
|
|
30
80
|
const getSandBoxContext = (options) => {
|
|
31
81
|
const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } = options ?? {};
|
|
32
|
-
let additionalGlobalVar = {};
|
|
33
82
|
const baseRequire = typeof projectRequire === "function" ? projectRequire : require_utils_ESMxCJSHelpers.getProjectRequire();
|
|
34
83
|
const mockedRequire = (() => {
|
|
35
84
|
const mockTable = Object.assign({ esbuild }, mocks);
|
|
@@ -46,25 +95,11 @@ const getSandBoxContext = (options) => {
|
|
|
46
95
|
wrappedRequire.cache = baseRequire.cache;
|
|
47
96
|
return wrappedRequire;
|
|
48
97
|
})();
|
|
49
|
-
try {
|
|
50
|
-
additionalGlobalVar = { React: baseRequire("react") };
|
|
51
|
-
} catch (_err) {
|
|
52
|
-
additionalGlobalVar = { React: {
|
|
53
|
-
createElement: (type, props, ...children) => ({
|
|
54
|
-
type,
|
|
55
|
-
props: {
|
|
56
|
-
...props,
|
|
57
|
-
children: children.length <= 1 ? children[0] : children
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
Fragment: Symbol.for("react.fragment")
|
|
61
|
-
} };
|
|
62
|
-
}
|
|
63
98
|
const sandboxContext = {
|
|
64
99
|
exports: { default: {} },
|
|
65
100
|
module: { exports: {} },
|
|
66
101
|
process: {
|
|
67
|
-
...
|
|
102
|
+
...processSnapshot,
|
|
68
103
|
env: {
|
|
69
104
|
...process.env,
|
|
70
105
|
...require_loadEnvFile.loadEnvFile(envVarOptions),
|
|
@@ -73,7 +108,7 @@ const getSandBoxContext = (options) => {
|
|
|
73
108
|
},
|
|
74
109
|
console,
|
|
75
110
|
require: mockedRequire,
|
|
76
|
-
...
|
|
111
|
+
...getReactGlobal(baseRequire)
|
|
77
112
|
};
|
|
78
113
|
for (const key of NODE_GLOBALS) if (!(key in sandboxContext) && key in globalThis) sandboxContext[key] = globalThis[key];
|
|
79
114
|
return sandboxContext;
|