@intlayer/config 9.0.0-canary.9 → 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.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 +3 -3
- 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":"getStorageAttributes.mjs","names":[],"sources":["../../../src/utils/getStorageAttributes.ts"],"sourcesContent":["import type {\n CookiesAttributes,\n ProcessedCookieAttributes,\n ProcessedStorageAttributes,\n RoutingStorageInput,\n StorageAttributes,\n} from '@intlayer/types/config';\nimport {\n COOKIE_NAME,\n HEADER_NAME,\n LOCALE_STORAGE_NAME,\n} from '../defaultValues/routing';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: ProcessedCookieAttributes;\n};\n\n/** Number of seconds in a day, used to convert a `number` of days. */\nconst SECONDS_PER_DAY = 60 * 60 * 24;\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Merges the user-facing `expires` and `maxAge` into a single, normalized and\n * serialization-safe expiry consumed by the client runtime.\n *\n * Precedence and normalization:\n * - `maxAge` (seconds) wins when set and is the internal unit (relative);\n * - `expires` as a `number` is interpreted as **days** and converted to\n * seconds (relative);\n * - `expires` as a `Date` (possibly a cross-realm instance, since config files\n * run in a `node:vm` sandbox) or an ISO string becomes an ISO **string**\n * (absolute). Strings survive `JSON.stringify`, unlike a `Date`.\n *\n * The result is therefore: a `number` = seconds from creation, a `string` =\n * absolute ISO date, or `undefined` for a session cookie.\n */\nconst normalizeCookieExpiry = (\n expires: CookiesAttributes['expires'],\n maxAge: CookiesAttributes['maxAge']\n): number | string | undefined => {\n if (typeof maxAge === 'number') return maxAge;\n if (expires === undefined) return undefined;\n if (\n expires instanceof Date ||\n Object.prototype.toString.call(expires) === '[object Date]'\n ) {\n return (expires as Date).toISOString();\n }\n if (typeof expires === 'string') return expires;\n return expires * SECONDS_PER_DAY;\n};\n\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const {\n name,\n path = '/',\n expires,\n maxAge,\n domain,\n secure,\n sameSite,\n httpOnly,\n } = options ?? {};\n return {\n name: name ?? COOKIE_NAME,\n attributes: {\n path,\n expires: normalizeCookieExpiry(expires, maxAge),\n domain,\n secure,\n sameSite,\n httpOnly,\n },\n };\n};\n\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => ({\n name: options?.name ?? LOCALE_STORAGE_NAME,\n});\n\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => ({\n name: options?.name ?? HEADER_NAME,\n});\n\nconst isCookieEntry = (entry: unknown): boolean => {\n if (typeof entry !== 'object' || entry === null) return false;\n const e = entry as Record<string, unknown>;\n return (\n e['type'] === 'cookie' ||\n 'sameSite' in e ||\n 'httpOnly' in e ||\n 'secure' in e\n );\n};\n\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' =>\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header';\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n if (entry === 'cookie') return { cookies: [createCookieEntry()] };\n if (entry === 'localStorage')\n return { localStorage: [createWebStorageEntry()] };\n if (entry === 'sessionStorage')\n return { sessionStorage: [createWebStorageEntry()] };\n if (entry === 'header') return { headers: [createHeaderEntry()] };\n }\n\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n return {\n localStorage: [createWebStorageEntry(typedEntry as StorageAttributes)],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n return {\n sessionStorage: [\n createWebStorageEntry(typedEntry as StorageAttributes),\n ],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'header') {\n return { headers: [createHeaderEntry(typedEntry as StorageAttributes)] };\n }\n // Default to localStorage for ambiguous objects\n return {\n localStorage: [\n createWebStorageEntry(typedEntry as Omit<StorageAttributes, 'type'>),\n ],\n };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => ({\n cookies: [...(accumulated.cookies ?? []), ...(partial.cookies ?? [])],\n localStorage: [\n ...(accumulated.localStorage ?? []),\n ...(partial.localStorage ?? []),\n ],\n sessionStorage: [\n ...(accumulated.sessionStorage ?? []),\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...(accumulated.headers ?? []), ...(partial.headers ?? [])],\n});\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type.\n * Called at config-build time so the result is pre-computed and stored in the config.\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, sessionStorage and headers\n */\nexport const getStorageAttributes = (\n options: RoutingStorageInput\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n if (options === false || options === undefined) return {};\n\n const result = Array.isArray(options)\n ? options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult)\n : mergeStorageAttributes(emptyResult, processStorageEntry(options));\n\n // Remove empty arrays\n const cleanedResult: ProcessedStorageAttributes = {};\n\n if (result.cookies && result.cookies.length > 0) {\n cleanedResult.cookies = result.cookies;\n }\n\n if (result.localStorage && result.localStorage.length > 0) {\n cleanedResult.localStorage = result.localStorage;\n }\n\n if (result.sessionStorage && result.sessionStorage.length > 0) {\n cleanedResult.sessionStorage = result.sessionStorage;\n }\n\n if (result.headers && result.headers.length > 0) {\n cleanedResult.headers = result.headers;\n }\n\n return cleanedResult;\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"getStorageAttributes.mjs","names":[],"sources":["../../../src/utils/getStorageAttributes.ts"],"sourcesContent":["import type {\n CookiesAttributes,\n ProcessedCookieAttributes,\n ProcessedStorageAttributes,\n RoutingStorageInput,\n StorageAttributes,\n} from '@intlayer/types/config';\nimport {\n COOKIE_NAME,\n HEADER_NAME,\n LOCALE_STORAGE_NAME,\n} from '../defaultValues/routing';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: ProcessedCookieAttributes;\n};\n\n/** Number of seconds in a day, used to convert a `number` of days. */\nconst SECONDS_PER_DAY = 60 * 60 * 24;\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Merges the user-facing `expires` and `maxAge` into a single, normalized and\n * serialization-safe expiry consumed by the client runtime.\n *\n * Precedence and normalization:\n * - `maxAge` (seconds) wins when set and is the internal unit (relative);\n * - `expires` as a `number` is interpreted as **days** and converted to\n * seconds (relative);\n * - `expires` as a `Date` (possibly a cross-realm instance, since config files\n * run in a `node:vm` sandbox) or an ISO string becomes an ISO **string**\n * (absolute). Strings survive `JSON.stringify`, unlike a `Date`.\n *\n * The result is therefore: a `number` = seconds from creation, a `string` =\n * absolute ISO date, or `undefined` for a session cookie.\n */\nconst normalizeCookieExpiry = (\n expires: CookiesAttributes['expires'],\n maxAge: CookiesAttributes['maxAge']\n): number | string | undefined => {\n if (typeof maxAge === 'number') return maxAge;\n if (expires === undefined) return undefined;\n if (\n expires instanceof Date ||\n Object.prototype.toString.call(expires) === '[object Date]'\n ) {\n return (expires as Date).toISOString();\n }\n if (typeof expires === 'string') return expires;\n return expires * SECONDS_PER_DAY;\n};\n\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const {\n name,\n path = '/',\n expires,\n maxAge,\n domain,\n secure,\n sameSite,\n httpOnly,\n } = options ?? {};\n return {\n name: name ?? COOKIE_NAME,\n attributes: {\n path,\n expires: normalizeCookieExpiry(expires, maxAge),\n domain,\n secure,\n sameSite,\n httpOnly,\n },\n };\n};\n\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => ({\n name: options?.name ?? LOCALE_STORAGE_NAME,\n});\n\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => ({\n name: options?.name ?? HEADER_NAME,\n});\n\nconst isCookieEntry = (entry: unknown): boolean => {\n if (typeof entry !== 'object' || entry === null) return false;\n const e = entry as Record<string, unknown>;\n return (\n e['type'] === 'cookie' ||\n 'sameSite' in e ||\n 'httpOnly' in e ||\n 'secure' in e\n );\n};\n\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' =>\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header';\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n if (entry === 'cookie') return { cookies: [createCookieEntry()] };\n if (entry === 'localStorage')\n return { localStorage: [createWebStorageEntry()] };\n if (entry === 'sessionStorage')\n return { sessionStorage: [createWebStorageEntry()] };\n if (entry === 'header') return { headers: [createHeaderEntry()] };\n }\n\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n return {\n localStorage: [createWebStorageEntry(typedEntry as StorageAttributes)],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n return {\n sessionStorage: [\n createWebStorageEntry(typedEntry as StorageAttributes),\n ],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'header') {\n return { headers: [createHeaderEntry(typedEntry as StorageAttributes)] };\n }\n // Default to localStorage for ambiguous objects\n return {\n localStorage: [\n createWebStorageEntry(typedEntry as Omit<StorageAttributes, 'type'>),\n ],\n };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => ({\n cookies: [...(accumulated.cookies ?? []), ...(partial.cookies ?? [])],\n localStorage: [\n ...(accumulated.localStorage ?? []),\n ...(partial.localStorage ?? []),\n ],\n sessionStorage: [\n ...(accumulated.sessionStorage ?? []),\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...(accumulated.headers ?? []), ...(partial.headers ?? [])],\n});\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type.\n * Called at config-build time so the result is pre-computed and stored in the config.\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, sessionStorage and headers\n */\nexport const getStorageAttributes = (\n options: RoutingStorageInput\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n if (options === false || options === undefined) return {};\n\n const result = Array.isArray(options)\n ? options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult)\n : mergeStorageAttributes(emptyResult, processStorageEntry(options));\n\n // Remove empty arrays\n const cleanedResult: ProcessedStorageAttributes = {};\n\n if (result.cookies && result.cookies.length > 0) {\n cleanedResult.cookies = result.cookies;\n }\n\n if (result.localStorage && result.localStorage.length > 0) {\n cleanedResult.localStorage = result.localStorage;\n }\n\n if (result.sessionStorage && result.sessionStorage.length > 0) {\n cleanedResult.sessionStorage = result.sessionStorage;\n }\n\n if (result.headers && result.headers.length > 0) {\n cleanedResult.headers = result.headers;\n }\n\n return cleanedResult;\n};\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUsedNodeTypes.mjs","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport {\n PLUGIN_NODE_TYPES,\n PREACT_NODE,\n REACT_NODE,\n SOLID_NODE,\n} from '@intlayer/types/nodeType';\n\nexport type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];\n\n/**\n * Detect whether a plain object looks like a serialized React element.\n * React serializes JSX as: { key, props, _owner, _store }.\n * Preact serializes VNodes similarly with a `_store` field.\n */\nconst isReactLikeElement = (obj: Record<string, unknown>): boolean =>\n typeof obj.props !== 'undefined' &&\n 'key' in obj &&\n typeof obj._store !== 'undefined';\n\n/**\n * Detect whether a plain object looks like a serialized Solid element.\n * Solid JSX is serialized as: { type, props } without the React-specific\n * `_store` / `_owner` internal fields.\n */\nconst isSolidLikeElement = (obj: Record<string, unknown>): boolean =>\n typeof obj.props !== 'undefined' &&\n typeof obj._store === 'undefined' &&\n typeof obj.nodeType === 'undefined' &&\n 'type' in obj;\n\n/** Recursively collect every `nodeType` string found in a value. */\nconst collectNodeTypes = (value: unknown, result: Set<string>): void => {\n if (!value || typeof value !== 'object') return;\n\n if (Array.isArray(value)) {\n for (const item of value) collectNodeTypes(item, result);\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n if (typeof obj.nodeType === 'string') {\n result.add(obj.nodeType);\n } else if (isReactLikeElement(obj)) {\n // Serialized React / Preact JSX element — both use { key, props, _store }\n result.add(REACT_NODE);\n result.add(PREACT_NODE);\n } else if (isSolidLikeElement(obj)) {\n result.add(SOLID_NODE);\n }\n\n for (const key of Object.keys(obj)) {\n collectNodeTypes(obj[key], result);\n }\n};\n\n/**\n * Returns the set of NodeType strings actually used across the given\n * built dictionaries.\n *\n * @example\n * const used = getUsedNodeTypes(getDictionaries(config));\n * // Set { 'translation', 'enumeration' }\n */\nexport const getUsedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): PluginNodeType[] => {\n const result = new Set<PluginNodeType>();\n const dicts = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n for (const dict of dicts) {\n collectNodeTypes(dict.content, result);\n }\n\n return [...result];\n};\n\nexport const getUnusedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): PluginNodeType[] => {\n const usedNodeTypes = getUsedNodeTypes(dictionaries);\n\n return PLUGIN_NODE_TYPES.filter(\n (nodeType) => !usedNodeTypes.includes(nodeType)\n );\n};\n\nexport const getUsedNodeTypesAsync = async (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Promise<PluginNodeType[]> => {\n const dictionariesArray = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n const results = await Promise.all(\n dictionariesArray.map(async (dictionary) => {\n const result = new Set<PluginNodeType>();\n\n collectNodeTypes(dictionary.content, result as Set<string>);\n\n return result;\n })\n );\n\n const finalResult = new Set<PluginNodeType>();\n\n for (const res of results) {\n for (const val of res) {\n finalResult.add(val);\n }\n }\n\n return [...finalResult];\n};\n\nexport const getUnusedNodeTypesAsync = async (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Promise<PluginNodeType[]> => {\n const usedNodeTypes = await getUsedNodeTypesAsync(dictionaries);\n\n return PLUGIN_NODE_TYPES.filter(\n (nodeType) => !usedNodeTypes.includes(nodeType)\n );\n};\n"],"mappings":";;;;;;;;AAeA,MAAM,sBAAsB,QAC1B,OAAO,IAAI,UAAU,eACrB,SAAS,OACT,OAAO,IAAI,WAAW;;;;;;AAOxB,MAAM,sBAAsB,QAC1B,OAAO,IAAI,UAAU,eACrB,OAAO,IAAI,WAAW,eACtB,OAAO,IAAI,aAAa,eACxB,UAAU;;AAGZ,MAAM,oBAAoB,OAAgB,WAA8B;
|
|
1
|
+
{"version":3,"file":"getUsedNodeTypes.mjs","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport {\n PLUGIN_NODE_TYPES,\n PREACT_NODE,\n REACT_NODE,\n SOLID_NODE,\n} from '@intlayer/types/nodeType';\n\nexport type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];\n\n/**\n * Detect whether a plain object looks like a serialized React element.\n * React serializes JSX as: { key, props, _owner, _store }.\n * Preact serializes VNodes similarly with a `_store` field.\n */\nconst isReactLikeElement = (obj: Record<string, unknown>): boolean =>\n typeof obj.props !== 'undefined' &&\n 'key' in obj &&\n typeof obj._store !== 'undefined';\n\n/**\n * Detect whether a plain object looks like a serialized Solid element.\n * Solid JSX is serialized as: { type, props } without the React-specific\n * `_store` / `_owner` internal fields.\n */\nconst isSolidLikeElement = (obj: Record<string, unknown>): boolean =>\n typeof obj.props !== 'undefined' &&\n typeof obj._store === 'undefined' &&\n typeof obj.nodeType === 'undefined' &&\n 'type' in obj;\n\n/** Recursively collect every `nodeType` string found in a value. */\nconst collectNodeTypes = (value: unknown, result: Set<string>): void => {\n if (!value || typeof value !== 'object') return;\n\n if (Array.isArray(value)) {\n for (const item of value) collectNodeTypes(item, result);\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n if (typeof obj.nodeType === 'string') {\n result.add(obj.nodeType);\n } else if (isReactLikeElement(obj)) {\n // Serialized React / Preact JSX element — both use { key, props, _store }\n result.add(REACT_NODE);\n result.add(PREACT_NODE);\n } else if (isSolidLikeElement(obj)) {\n result.add(SOLID_NODE);\n }\n\n for (const key of Object.keys(obj)) {\n collectNodeTypes(obj[key], result);\n }\n};\n\n/**\n * Returns the set of NodeType strings actually used across the given\n * built dictionaries.\n *\n * @example\n * const used = getUsedNodeTypes(getDictionaries(config));\n * // Set { 'translation', 'enumeration' }\n */\nexport const getUsedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): PluginNodeType[] => {\n const result = new Set<PluginNodeType>();\n const dicts = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n for (const dict of dicts) {\n collectNodeTypes(dict.content, result);\n }\n\n return [...result];\n};\n\nexport const getUnusedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): PluginNodeType[] => {\n const usedNodeTypes = getUsedNodeTypes(dictionaries);\n\n return PLUGIN_NODE_TYPES.filter(\n (nodeType) => !usedNodeTypes.includes(nodeType)\n );\n};\n\nexport const getUsedNodeTypesAsync = async (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Promise<PluginNodeType[]> => {\n const dictionariesArray = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n const results = await Promise.all(\n dictionariesArray.map(async (dictionary) => {\n const result = new Set<PluginNodeType>();\n\n collectNodeTypes(dictionary.content, result as Set<string>);\n\n return result;\n })\n );\n\n const finalResult = new Set<PluginNodeType>();\n\n for (const res of results) {\n for (const val of res) {\n finalResult.add(val);\n }\n }\n\n return [...finalResult];\n};\n\nexport const getUnusedNodeTypesAsync = async (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Promise<PluginNodeType[]> => {\n const usedNodeTypes = await getUsedNodeTypesAsync(dictionaries);\n\n return PLUGIN_NODE_TYPES.filter(\n (nodeType) => !usedNodeTypes.includes(nodeType)\n );\n};\n"],"mappings":";;;;;;;;AAeA,MAAM,sBAAsB,QAC1B,OAAO,IAAI,UAAU,eACrB,SAAS,OACT,OAAO,IAAI,WAAW;;;;;;AAOxB,MAAM,sBAAsB,QAC1B,OAAO,IAAI,UAAU,eACrB,OAAO,IAAI,WAAW,eACtB,OAAO,IAAI,aAAa,eACxB,UAAU;;AAGZ,MAAM,oBAAoB,OAAgB,WAA8B;CACtE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU;CAEzC,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,KAAK,MAAM,QAAQ,OAAO,iBAAiB,MAAM,MAAM;EACvD;CACF;CAEA,MAAM,MAAM;CAEZ,IAAI,OAAO,IAAI,aAAa,UAC1B,OAAO,IAAI,IAAI,QAAQ;MAClB,IAAI,mBAAmB,GAAG,GAAG;EAElC,OAAO,IAAI,UAAU;EACrB,OAAO,IAAI,WAAW;CACxB,OAAO,IAAI,mBAAmB,GAAG,GAC/B,OAAO,IAAI,UAAU;CAGvB,KAAK,MAAM,OAAO,OAAO,KAAK,GAAG,GAC/B,iBAAiB,IAAI,MAAM,MAAM;AAErC;;;;;;;;;AAUA,MAAa,oBACX,iBACqB;CACrB,MAAM,yBAAS,IAAI,IAAoB;CACvC,MAAM,QAAQ,MAAM,QAAQ,YAAY,IACpC,eACA,OAAO,OAAO,YAAY;CAE9B,KAAK,MAAM,QAAQ,OACjB,iBAAiB,KAAK,SAAS,MAAM;CAGvC,OAAO,CAAC,GAAG,MAAM;AACnB;AAEA,MAAa,sBACX,iBACqB;CACrB,MAAM,gBAAgB,iBAAiB,YAAY;CAEnD,OAAO,kBAAkB,QACtB,aAAa,CAAC,cAAc,SAAS,QAAQ,CAChD;AACF;AAEA,MAAa,wBAAwB,OACnC,iBAC8B;CAC9B,MAAM,oBAAoB,MAAM,QAAQ,YAAY,IAChD,eACA,OAAO,OAAO,YAAY;CAE9B,MAAM,UAAU,MAAM,QAAQ,IAC5B,kBAAkB,IAAI,OAAO,eAAe;EAC1C,MAAM,yBAAS,IAAI,IAAoB;EAEvC,iBAAiB,WAAW,SAAS,MAAqB;EAE1D,OAAO;CACT,CAAC,CACH;CAEA,MAAM,8BAAc,IAAI,IAAoB;CAE5C,KAAK,MAAM,OAAO,SAChB,KAAK,MAAM,OAAO,KAChB,YAAY,IAAI,GAAG;CAIvB,OAAO,CAAC,GAAG,WAAW;AACxB;AAEA,MAAa,0BAA0B,OACrC,iBAC8B;CAC9B,MAAM,gBAAgB,MAAM,sBAAsB,YAAY;CAE9D,OAAO,kBAAkB,QACtB,aAAa,CAAC,cAAc,SAAS,QAAQ,CAChD;AACF"}
|
package/dist/esm/utils/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getExtension } from "./getExtension.mjs";
|
|
2
2
|
import { normalizePath } from "./normalizePath.mjs";
|
|
3
3
|
import { getAlias } from "./alias.mjs";
|
|
4
|
+
import { BUILT_CONFIG_KEYS } from "./builtConfigKeys.mjs";
|
|
4
5
|
import { cacheMemory, clearAllCache, clearCache, computeKeyId, getCache, setCache, stableStringify } from "./cacheMemory.mjs";
|
|
5
6
|
import { cacheDisk, clearDiskCacheMemory } from "./cacheDisk.mjs";
|
|
6
7
|
import { getPackageJsonPath } from "./getPackageJsonPath.mjs";
|
|
@@ -21,4 +22,4 @@ import { camelCaseToSentence } from "./stringFormatter/camelCaseToSentence.mjs";
|
|
|
21
22
|
import { kebabCaseToCamelCase } from "./stringFormatter/kebabCaseToCamelCase.mjs";
|
|
22
23
|
import { toLowerCamelCase } from "./stringFormatter/toLowerCamelCase.mjs";
|
|
23
24
|
|
|
24
|
-
export { assertPathWithin, cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearDiskCacheMemory, clearModuleCache, compareVersions, computeKeyId, configESMxCJSRequire, extractErrorMessage, getAlias, getCache, getExtension, getHasDictionarySelector, getPackageJsonPath, getProjectRequire, getStorageAttributes, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, isESModule, kebabCaseToCamelCase, logStack, normalizePath, parseFilePathPattern, parseStringPattern, retryManager, setCache, setIntlayerIdentifier, stableStringify, toLowerCamelCase };
|
|
25
|
+
export { BUILT_CONFIG_KEYS, assertPathWithin, cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearDiskCacheMemory, clearModuleCache, compareVersions, computeKeyId, configESMxCJSRequire, extractErrorMessage, getAlias, getCache, getExtension, getHasDictionarySelector, getPackageJsonPath, getProjectRequire, getStorageAttributes, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, isESModule, kebabCaseToCamelCase, logStack, normalizePath, parseFilePathPattern, parseStringPattern, retryManager, setCache, setIntlayerIdentifier, stableStringify, toLowerCamelCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logStack.mjs","names":["ANSIColors.YELLOW","ANSIColors.BLUE"],"sources":["../../../src/utils/logStack.ts"],"sourcesContent":["import * as ANSIColors from '../colors';\nimport { colorize } from '../logger';\n\nexport const logStack = (\n message: string,\n options: { limit: number } = { limit: 50 }\n) => {\n Error.stackTraceLimit = options.limit;\n\n try {\n throw new Error('test');\n } catch (error) {\n console.log(colorize(message, ANSIColors.YELLOW));\n console.log(colorize((error as Error).stack ?? '', ANSIColors.BLUE));\n }\n};\n"],"mappings":";;;;AAGA,MAAa,YACX,SACA,UAA6B,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"logStack.mjs","names":["ANSIColors.YELLOW","ANSIColors.BLUE"],"sources":["../../../src/utils/logStack.ts"],"sourcesContent":["import * as ANSIColors from '../colors';\nimport { colorize } from '../logger';\n\nexport const logStack = (\n message: string,\n options: { limit: number } = { limit: 50 }\n) => {\n Error.stackTraceLimit = options.limit;\n\n try {\n throw new Error('test');\n } catch (error) {\n console.log(colorize(message, ANSIColors.YELLOW));\n console.log(colorize((error as Error).stack ?? '', ANSIColors.BLUE));\n }\n};\n"],"mappings":";;;;AAGA,MAAa,YACX,SACA,UAA6B,EAAE,OAAO,GAAG,MACtC;CACH,MAAM,kBAAkB,QAAQ;CAEhC,IAAI;EACF,MAAM,IAAI,MAAM,MAAM;CACxB,SAAS,OAAO;EACd,QAAQ,IAAI,SAAS,SAASA,MAAiB,CAAC;EAChD,QAAQ,IAAI,SAAU,MAAgB,SAAS,IAAIC,IAAe,CAAC;CACrE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizePath.mjs","names":[],"sources":["../../../src/utils/normalizePath.ts"],"sourcesContent":["/**\n * Normalize a path for glob by replacing backslashes with forward slashes\n *\n * Utils for Windows compatibility, as Glob pattern as `**\\\\*.js` is not supported\n *\n * C:\\\\Users\\\\John\\\\Desktop\\\\test.txt -> C:/Users/John/Desktop/test.txt\n *\n * @param path - The path to normalize\n * @returns The normalized path\n */\nexport const normalizePath = (path: string): string => path.replace(/\\\\/g, '/');\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,iBAAiB,SAAyB,KAAK,QAAQ,OAAO,
|
|
1
|
+
{"version":3,"file":"normalizePath.mjs","names":[],"sources":["../../../src/utils/normalizePath.ts"],"sourcesContent":["/**\n * Normalize a path for glob by replacing backslashes with forward slashes\n *\n * Utils for Windows compatibility, as Glob pattern as `**\\\\*.js` is not supported\n *\n * C:\\\\Users\\\\John\\\\Desktop\\\\test.txt -> C:/Users/John/Desktop/test.txt\n *\n * @param path - The path to normalize\n * @returns The normalized path\n */\nexport const normalizePath = (path: string): string => path.replace(/\\\\/g, '/');\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,iBAAiB,SAAyB,KAAK,QAAQ,OAAO,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFilePathPattern.mjs","names":[],"sources":["../../../src/utils/parseFilePathPattern.ts"],"sourcesContent":["import type {\n FilePathPattern,\n FilePathPatternContext,\n} from '@intlayer/types/filePathPattern';\n\n/**\n * Parses a FilePathPattern configuration string or function to a final string path.\n * Resolves context variables like `{{locale}}`, `{{key}}`, `{{fileName}}`, `{{extension}}`.\n */\nexport const parseFilePathPattern = async (\n pattern: FilePathPattern,\n context: FilePathPatternContext\n): Promise<string> => {\n if (typeof pattern === 'function') {\n return await (pattern as any)(context);\n }\n\n if (typeof pattern === 'object' && pattern !== null && context.locale) {\n const localePattern = (pattern as any)[context.locale];\n\n if (localePattern) {\n if (typeof localePattern === 'function') {\n return await localePattern(context);\n }\n return parseStringPattern(localePattern, context);\n }\n }\n\n if (typeof pattern === 'string') {\n return parseStringPattern(pattern, context);\n }\n\n return '';\n};\n\nexport const parseStringPattern = (\n pattern: string,\n context: FilePathPatternContext\n): string =>\n pattern\n .replaceAll(/\\{\\{\\s*locale\\s*\\}\\}/g, context.locale ?? '')\n .replaceAll(/\\{\\{\\s*key\\s*\\}\\}/g, context.key ?? '')\n .replaceAll(/\\{\\{\\s*fileName\\s*\\}\\}/g, context.fileName ?? '')\n .replaceAll(/\\{\\{\\s*extension\\s*\\}\\}/g, context.extension ?? '')\n .replaceAll(\n /\\{\\{\\s*componentFileName\\s*\\}\\}/g,\n context.componentFileName ?? ''\n )\n .replaceAll(\n /\\{\\{\\s*componentExtension\\s*\\}\\}/g,\n context.componentExtension ?? ''\n )\n .replaceAll(/\\{\\{\\s*format\\s*\\}\\}/g, context.format ?? '')\n .replaceAll(/\\{\\{\\s*componentFormat\\s*\\}\\}/g, context.componentFormat ?? '')\n .replaceAll(\n /\\{\\{\\s*componentDirPath\\s*\\}\\}/g,\n context.componentDirPath ?? ''\n );\n"],"mappings":";;;;;AASA,MAAa,uBAAuB,OAClC,SACA,YACoB;
|
|
1
|
+
{"version":3,"file":"parseFilePathPattern.mjs","names":[],"sources":["../../../src/utils/parseFilePathPattern.ts"],"sourcesContent":["import type {\n FilePathPattern,\n FilePathPatternContext,\n} from '@intlayer/types/filePathPattern';\n\n/**\n * Parses a FilePathPattern configuration string or function to a final string path.\n * Resolves context variables like `{{locale}}`, `{{key}}`, `{{fileName}}`, `{{extension}}`.\n */\nexport const parseFilePathPattern = async (\n pattern: FilePathPattern,\n context: FilePathPatternContext\n): Promise<string> => {\n if (typeof pattern === 'function') {\n return await (pattern as any)(context);\n }\n\n if (typeof pattern === 'object' && pattern !== null && context.locale) {\n const localePattern = (pattern as any)[context.locale];\n\n if (localePattern) {\n if (typeof localePattern === 'function') {\n return await localePattern(context);\n }\n return parseStringPattern(localePattern, context);\n }\n }\n\n if (typeof pattern === 'string') {\n return parseStringPattern(pattern, context);\n }\n\n return '';\n};\n\nexport const parseStringPattern = (\n pattern: string,\n context: FilePathPatternContext\n): string =>\n pattern\n .replaceAll(/\\{\\{\\s*locale\\s*\\}\\}/g, context.locale ?? '')\n .replaceAll(/\\{\\{\\s*key\\s*\\}\\}/g, context.key ?? '')\n .replaceAll(/\\{\\{\\s*fileName\\s*\\}\\}/g, context.fileName ?? '')\n .replaceAll(/\\{\\{\\s*extension\\s*\\}\\}/g, context.extension ?? '')\n .replaceAll(\n /\\{\\{\\s*componentFileName\\s*\\}\\}/g,\n context.componentFileName ?? ''\n )\n .replaceAll(\n /\\{\\{\\s*componentExtension\\s*\\}\\}/g,\n context.componentExtension ?? ''\n )\n .replaceAll(/\\{\\{\\s*format\\s*\\}\\}/g, context.format ?? '')\n .replaceAll(/\\{\\{\\s*componentFormat\\s*\\}\\}/g, context.componentFormat ?? '')\n .replaceAll(\n /\\{\\{\\s*componentDirPath\\s*\\}\\}/g,\n context.componentDirPath ?? ''\n );\n"],"mappings":";;;;;AASA,MAAa,uBAAuB,OAClC,SACA,YACoB;CACpB,IAAI,OAAO,YAAY,YACrB,OAAO,MAAO,QAAgB,OAAO;CAGvC,IAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,QAAQ,QAAQ;EACrE,MAAM,gBAAiB,QAAgB,QAAQ;EAE/C,IAAI,eAAe;GACjB,IAAI,OAAO,kBAAkB,YAC3B,OAAO,MAAM,cAAc,OAAO;GAEpC,OAAO,mBAAmB,eAAe,OAAO;EAClD;CACF;CAEA,IAAI,OAAO,YAAY,UACrB,OAAO,mBAAmB,SAAS,OAAO;CAG5C,OAAO;AACT;AAEA,MAAa,sBACX,SACA,YAEA,QACG,WAAW,yBAAyB,QAAQ,UAAU,EAAE,CAAC,CACzD,WAAW,sBAAsB,QAAQ,OAAO,EAAE,CAAC,CACnD,WAAW,2BAA2B,QAAQ,YAAY,EAAE,CAAC,CAC7D,WAAW,4BAA4B,QAAQ,aAAa,EAAE,CAAC,CAC/D,WACC,oCACA,QAAQ,qBAAqB,EAC/B,CAAC,CACA,WACC,qCACA,QAAQ,sBAAsB,EAChC,CAAC,CACA,WAAW,yBAAyB,QAAQ,UAAU,EAAE,CAAC,CACzD,WAAW,kCAAkC,QAAQ,mBAAmB,EAAE,CAAC,CAC3E,WACC,mCACA,QAAQ,oBAAoB,EAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathSecurity.mjs","names":[],"sources":["../../../src/utils/pathSecurity.ts"],"sourcesContent":["import { resolve, sep } from 'node:path';\n\n/**\n * Throws if `resolvedPath` escapes `baseDir`.\n * Use this before any file operation whose path is derived from user-controlled\n * input (e.g. dictionary keys, filePath fields from dictionary data) to prevent\n * path-traversal attacks.\n */\nexport const assertPathWithin = (\n resolvedPath: string,\n baseDir: string\n): void => {\n const normalizedBase = resolve(baseDir);\n const normalizedPath = resolve(resolvedPath);\n if (\n normalizedPath !== normalizedBase &&\n !normalizedPath.startsWith(normalizedBase + sep)\n ) {\n throw new Error(\n `Path traversal detected: \"${resolvedPath}\" escapes the base directory \"${baseDir}\"`\n );\n }\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,oBACX,cACA,YACS;CACT,MAAM,iBAAiB,QAAQ,
|
|
1
|
+
{"version":3,"file":"pathSecurity.mjs","names":[],"sources":["../../../src/utils/pathSecurity.ts"],"sourcesContent":["import { resolve, sep } from 'node:path';\n\n/**\n * Throws if `resolvedPath` escapes `baseDir`.\n * Use this before any file operation whose path is derived from user-controlled\n * input (e.g. dictionary keys, filePath fields from dictionary data) to prevent\n * path-traversal attacks.\n */\nexport const assertPathWithin = (\n resolvedPath: string,\n baseDir: string\n): void => {\n const normalizedBase = resolve(baseDir);\n const normalizedPath = resolve(resolvedPath);\n if (\n normalizedPath !== normalizedBase &&\n !normalizedPath.startsWith(normalizedBase + sep)\n ) {\n throw new Error(\n `Path traversal detected: \"${resolvedPath}\" escapes the base directory \"${baseDir}\"`\n );\n }\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,oBACX,cACA,YACS;CACT,MAAM,iBAAiB,QAAQ,OAAO;CACtC,MAAM,iBAAiB,QAAQ,YAAY;CAC3C,IACE,mBAAmB,kBACnB,CAAC,eAAe,WAAW,iBAAiB,GAAG,GAE/C,MAAM,IAAI,MACR,6BAA6B,aAAa,gCAAgC,QAAQ,EACpF;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryManager.mjs","names":[],"sources":["../../../src/utils/retryManager.ts"],"sourcesContent":["import { logger } from '../logger';\nimport { extractErrorMessage } from './extractErrorMessage';\n\nexport type RetryManagerOptions = {\n /** maximum number of retries before giving up */\n maxRetry?: number;\n /** delay between attempts, in milliseconds */\n delay?: number;\n /** function to call when an error occurs */\n onError?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n /** function to call when the maximum number of retries is reached */\n onMaxTryReached?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n};\n\nconst DEFAULT_MAX_RETRY = 3;\nconst DEFAULT_DELAY = 0;\n\n/**\n * Wrap an async function `fn` so it’s retried on failure.\n *\n * @param fn The async function to wrap\n * @param options { maxRetry, delay }\n * @returns A new function with the same signature as `fn`\n */\nexport const retryManager =\n <Args extends any[], R>(\n fn: (...args: Args) => Promise<R>,\n {\n maxRetry = DEFAULT_MAX_RETRY,\n delay = DEFAULT_DELAY,\n onError,\n onMaxTryReached,\n }: RetryManagerOptions = {}\n ): ((...args: Args) => Promise<R>) =>\n // ───────────────────────────────^ returned wrapper function\n async (...args: Args): Promise<R> => {\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetry; attempt++) {\n try {\n return await fn(...args);\n } catch (err) {\n lastError = err;\n const error = extractErrorMessage(err);\n\n // If this was the last attempt, handle max retry reached\n if (attempt >= maxRetry) {\n if (onMaxTryReached) {\n onMaxTryReached?.({ error, attempt, maxRetry });\n return null as R;\n }\n\n // Otherwise, throw the error\n throw err;\n }\n\n if (onError) {\n onError?.({ error, attempt, maxRetry });\n } else {\n logger(error, {\n level: 'error',\n });\n }\n\n // Wait before retrying\n if (delay > 0) {\n await new Promise((res) => setTimeout(res, delay));\n }\n }\n }\n\n // This should never be reached, but TypeScript needs it\n throw (\n lastError ?? new Error('Unexpected: retry loop completed without result')\n );\n };\n"],"mappings":";;;;AAsBA,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;;;;;;;;AAStB,MAAa,gBAET,IACA,EACE,WAAW,mBACX,QAAQ,eACR,SACA,oBACuB,
|
|
1
|
+
{"version":3,"file":"retryManager.mjs","names":[],"sources":["../../../src/utils/retryManager.ts"],"sourcesContent":["import { logger } from '../logger';\nimport { extractErrorMessage } from './extractErrorMessage';\n\nexport type RetryManagerOptions = {\n /** maximum number of retries before giving up */\n maxRetry?: number;\n /** delay between attempts, in milliseconds */\n delay?: number;\n /** function to call when an error occurs */\n onError?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n /** function to call when the maximum number of retries is reached */\n onMaxTryReached?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n};\n\nconst DEFAULT_MAX_RETRY = 3;\nconst DEFAULT_DELAY = 0;\n\n/**\n * Wrap an async function `fn` so it’s retried on failure.\n *\n * @param fn The async function to wrap\n * @param options { maxRetry, delay }\n * @returns A new function with the same signature as `fn`\n */\nexport const retryManager =\n <Args extends any[], R>(\n fn: (...args: Args) => Promise<R>,\n {\n maxRetry = DEFAULT_MAX_RETRY,\n delay = DEFAULT_DELAY,\n onError,\n onMaxTryReached,\n }: RetryManagerOptions = {}\n ): ((...args: Args) => Promise<R>) =>\n // ───────────────────────────────^ returned wrapper function\n async (...args: Args): Promise<R> => {\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetry; attempt++) {\n try {\n return await fn(...args);\n } catch (err) {\n lastError = err;\n const error = extractErrorMessage(err);\n\n // If this was the last attempt, handle max retry reached\n if (attempt >= maxRetry) {\n if (onMaxTryReached) {\n onMaxTryReached?.({ error, attempt, maxRetry });\n return null as R;\n }\n\n // Otherwise, throw the error\n throw err;\n }\n\n if (onError) {\n onError?.({ error, attempt, maxRetry });\n } else {\n logger(error, {\n level: 'error',\n });\n }\n\n // Wait before retrying\n if (delay > 0) {\n await new Promise((res) => setTimeout(res, delay));\n }\n }\n }\n\n // This should never be reached, but TypeScript needs it\n throw (\n lastError ?? new Error('Unexpected: retry loop completed without result')\n );\n };\n"],"mappings":";;;;AAsBA,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;;;;;;;;AAStB,MAAa,gBAET,IACA,EACE,WAAW,mBACX,QAAQ,eACR,SACA,oBACuB,CAAC,MAG5B,OAAO,GAAG,SAA2B;CACnC,IAAI;CAEJ,KAAK,IAAI,UAAU,GAAG,WAAW,UAAU,WACzC,IAAI;EACF,OAAO,MAAM,GAAG,GAAG,IAAI;CACzB,SAAS,KAAK;EACZ,YAAY;EACZ,MAAM,QAAQ,oBAAoB,GAAG;EAGrC,IAAI,WAAW,UAAU;GACvB,IAAI,iBAAiB;IACnB,kBAAkB;KAAE;KAAO;KAAS;IAAS,CAAC;IAC9C,OAAO;GACT;GAGA,MAAM;EACR;EAEA,IAAI,SACF,UAAU;GAAE;GAAO;GAAS;EAAS,CAAC;OAEtC,OAAO,OAAO,EACZ,OAAO,QACT,CAAC;EAIH,IAAI,QAAQ,GACV,MAAM,IAAI,SAAS,QAAQ,WAAW,KAAK,KAAK,CAAC;CAErD;CAIF,MACE,6BAAa,IAAI,MAAM,iDAAiD;AAE5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setIntlayerIdentifier.mjs","names":[],"sources":["../../../src/utils/setIntlayerIdentifier.ts"],"sourcesContent":["type Meta = {\n enabled: true;\n};\n\nexport type WindowsWithIntlayer = typeof window & {\n intlayer?: Meta;\n};\n\n/**\n * Sets the version of Intlayer in the window object.\n * This is used for Intlayer detection in the browser.\n */\nexport const setIntlayerIdentifier = (): void => {\n if (typeof window !== 'undefined') {\n (window as WindowsWithIntlayer).intlayer = {\n enabled: true,\n };\n }\n};\n"],"mappings":";;;;;AAYA,MAAa,8BAAoC;
|
|
1
|
+
{"version":3,"file":"setIntlayerIdentifier.mjs","names":[],"sources":["../../../src/utils/setIntlayerIdentifier.ts"],"sourcesContent":["type Meta = {\n enabled: true;\n};\n\nexport type WindowsWithIntlayer = typeof window & {\n intlayer?: Meta;\n};\n\n/**\n * Sets the version of Intlayer in the window object.\n * This is used for Intlayer detection in the browser.\n */\nexport const setIntlayerIdentifier = (): void => {\n if (typeof window !== 'undefined') {\n (window as WindowsWithIntlayer).intlayer = {\n enabled: true,\n };\n }\n};\n"],"mappings":";;;;;AAYA,MAAa,8BAAoC;CAC/C,IAAI,OAAO,WAAW,aACpB,AAAC,OAA+B,WAAW,EACzC,SAAS,KACX;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camelCaseToKebabCase.mjs","names":[],"sources":["../../../../src/utils/stringFormatter/camelCaseToKebabCase.ts"],"sourcesContent":["/**\n * Convert a string to kebab-case\n * e.g. \"MyNewComponent\" => \"my-new-component\"\n */\nexport const camelCaseToKebabCase = (str: string): string => {\n // Split on transition from lower->upper: \"MyNewComponent\" => [\"My\", \"New\", \"Component\"]\n // Then lowercase each chunk and join by \"-\"\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .toLowerCase();\n};\n"],"mappings":";;;;;AAIA,MAAa,wBAAwB,QAAwB;
|
|
1
|
+
{"version":3,"file":"camelCaseToKebabCase.mjs","names":[],"sources":["../../../../src/utils/stringFormatter/camelCaseToKebabCase.ts"],"sourcesContent":["/**\n * Convert a string to kebab-case\n * e.g. \"MyNewComponent\" => \"my-new-component\"\n */\nexport const camelCaseToKebabCase = (str: string): string => {\n // Split on transition from lower->upper: \"MyNewComponent\" => [\"My\", \"New\", \"Component\"]\n // Then lowercase each chunk and join by \"-\"\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .toLowerCase();\n};\n"],"mappings":";;;;;AAIA,MAAa,wBAAwB,QAAwB;CAG3D,OAAO,IACJ,QAAQ,mBAAmB,OAAO,CAAC,CACnC,QAAQ,wBAAwB,OAAO,CAAC,CACxC,QAAQ,WAAW,GAAG,CAAC,CACvB,YAAY;AACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camelCaseToSentence.mjs","names":[],"sources":["../../../../src/utils/stringFormatter/camelCaseToSentence.ts"],"sourcesContent":["/**\n * Convert a string to sentence case\n * e.g. 'my-new-component' → 'My new component'\n */\nexport const camelCaseToSentence = (value: string): string => {\n if (!value) return '';\n if (typeof value !== 'string') return '';\n\n // Insert space before all caps that follow lowercase letters\n const withSpaces = value\n .replace(/([a-z])([A-Z])/g, '$1 $2')\n // Insert space between sequences like \"XMLParser\" → \"XML Parser\"\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2');\n\n // Lowercase everything except the first character\n return withSpaces.charAt(0).toUpperCase() + withSpaces.slice(1).toLowerCase();\n};\n"],"mappings":";;;;;AAIA,MAAa,uBAAuB,UAA0B;
|
|
1
|
+
{"version":3,"file":"camelCaseToSentence.mjs","names":[],"sources":["../../../../src/utils/stringFormatter/camelCaseToSentence.ts"],"sourcesContent":["/**\n * Convert a string to sentence case\n * e.g. 'my-new-component' → 'My new component'\n */\nexport const camelCaseToSentence = (value: string): string => {\n if (!value) return '';\n if (typeof value !== 'string') return '';\n\n // Insert space before all caps that follow lowercase letters\n const withSpaces = value\n .replace(/([a-z])([A-Z])/g, '$1 $2')\n // Insert space between sequences like \"XMLParser\" → \"XML Parser\"\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2');\n\n // Lowercase everything except the first character\n return withSpaces.charAt(0).toUpperCase() + withSpaces.slice(1).toLowerCase();\n};\n"],"mappings":";;;;;AAIA,MAAa,uBAAuB,UAA0B;CAC5D,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,OAAO,UAAU,UAAU,OAAO;CAGtC,MAAM,aAAa,MAChB,QAAQ,mBAAmB,OAAO,CAAC,CAEnC,QAAQ,yBAAyB,OAAO;CAG3C,OAAO,WAAW,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,WAAW,MAAM,CAAC,CAAC,CAAC,YAAY;AAC9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kebabCaseToCamelCase.mjs","names":[],"sources":["../../../../src/utils/stringFormatter/kebabCaseToCamelCase.ts"],"sourcesContent":["export const kebabCaseToCamelCase = (name: string): string => {\n return name\n .split(/[^a-zA-Z0-9]+/) // Split on any non-alphanumeric character\n .filter(Boolean) // Remove any empty strings\n .map((word) => {\n // Convert the entire word to lowercase first\n const lowerWord = word.toLowerCase();\n\n // Capitalize the first character\n let capitalized = lowerWord.charAt(0).toUpperCase() + lowerWord.slice(1);\n\n // Capitalize any letter that follows a number\n capitalized = capitalized.replace(\n /(\\d)([a-z])/g,\n (_, number, char) => number + char.toUpperCase()\n );\n\n return capitalized;\n })\n .join(''); // Concatenate all parts into a single string\n};\n"],"mappings":";AAAA,MAAa,wBAAwB,SAAyB;
|
|
1
|
+
{"version":3,"file":"kebabCaseToCamelCase.mjs","names":[],"sources":["../../../../src/utils/stringFormatter/kebabCaseToCamelCase.ts"],"sourcesContent":["export const kebabCaseToCamelCase = (name: string): string => {\n return name\n .split(/[^a-zA-Z0-9]+/) // Split on any non-alphanumeric character\n .filter(Boolean) // Remove any empty strings\n .map((word) => {\n // Convert the entire word to lowercase first\n const lowerWord = word.toLowerCase();\n\n // Capitalize the first character\n let capitalized = lowerWord.charAt(0).toUpperCase() + lowerWord.slice(1);\n\n // Capitalize any letter that follows a number\n capitalized = capitalized.replace(\n /(\\d)([a-z])/g,\n (_, number, char) => number + char.toUpperCase()\n );\n\n return capitalized;\n })\n .join(''); // Concatenate all parts into a single string\n};\n"],"mappings":";AAAA,MAAa,wBAAwB,SAAyB;CAC5D,OAAO,KACJ,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,SAAS;EAEb,MAAM,YAAY,KAAK,YAAY;EAGnC,IAAI,cAAc,UAAU,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,UAAU,MAAM,CAAC;EAGvE,cAAc,YAAY,QACxB,iBACC,GAAG,QAAQ,SAAS,SAAS,KAAK,YAAY,CACjD;EAEA,OAAO;CACT,CAAC,CAAC,CACD,KAAK,EAAE;AACZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toLowerCamelCase.mjs","names":[],"sources":["../../../../src/utils/stringFormatter/toLowerCamelCase.ts"],"sourcesContent":["/**\n * Convert a string to lowerCamelCase\n * e.g. \"MyComponent\" => \"myComponent\"\n * e.g. \"auth-middleware\" => \"authMiddleware\"\n */\nexport const toLowerCamelCase = (str: string): string => {\n if (!str) {\n return '';\n }\n\n // Handle kebab-case: \"auth-middleware\" => \"authMiddleware\"\n if (str.includes('-')) {\n return str\n .split('-')\n .map((word, index) => {\n if (index === 0) {\n return word.toLowerCase();\n }\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n })\n .join('');\n }\n\n // Handle PascalCase: \"MyComponent\" => \"myComponent\"\n return str.charAt(0).toLowerCase() + str.slice(1);\n};\n"],"mappings":";;;;;;AAKA,MAAa,oBAAoB,QAAwB;
|
|
1
|
+
{"version":3,"file":"toLowerCamelCase.mjs","names":[],"sources":["../../../../src/utils/stringFormatter/toLowerCamelCase.ts"],"sourcesContent":["/**\n * Convert a string to lowerCamelCase\n * e.g. \"MyComponent\" => \"myComponent\"\n * e.g. \"auth-middleware\" => \"authMiddleware\"\n */\nexport const toLowerCamelCase = (str: string): string => {\n if (!str) {\n return '';\n }\n\n // Handle kebab-case: \"auth-middleware\" => \"authMiddleware\"\n if (str.includes('-')) {\n return str\n .split('-')\n .map((word, index) => {\n if (index === 0) {\n return word.toLowerCase();\n }\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n })\n .join('');\n }\n\n // Handle PascalCase: \"MyComponent\" => \"myComponent\"\n return str.charAt(0).toLowerCase() + str.slice(1);\n};\n"],"mappings":";;;;;;AAKA,MAAa,oBAAoB,QAAwB;CACvD,IAAI,CAAC,KACH,OAAO;CAIT,IAAI,IAAI,SAAS,GAAG,GAClB,OAAO,IACJ,MAAM,GAAG,CAAC,CACV,KAAK,MAAM,UAAU;EACpB,IAAI,UAAU,GACZ,OAAO,KAAK,YAAY;EAE1B,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY;CAClE,CAAC,CAAC,CACD,KAAK,EAAE;CAIZ,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,CAAC;AAClD"}
|
package/dist/types/built.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ declare const routing: any;
|
|
|
9
9
|
declare const content: any;
|
|
10
10
|
declare const system: any;
|
|
11
11
|
declare const editor: any;
|
|
12
|
+
declare const analytics: any;
|
|
12
13
|
declare const log: any;
|
|
13
14
|
declare const ai: any;
|
|
14
15
|
declare const build: any;
|
|
@@ -16,5 +17,5 @@ declare const compiler: any;
|
|
|
16
17
|
declare const schemas: any;
|
|
17
18
|
declare const plugins: any;
|
|
18
19
|
//#endregion
|
|
19
|
-
export { ai, build, compiler, content, dictionary, editor, internationalization, log, plugins, routing, schemas, system };
|
|
20
|
+
export { ai, analytics, build, compiler, content, dictionary, editor, internationalization, log, plugins, routing, schemas, system };
|
|
20
21
|
//# sourceMappingURL=built.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built.d.ts","names":[],"sources":["../../src/built.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"built.d.ts","names":[],"sources":["../../src/built.ts"],"mappings":";;;;;cAaa;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { GetConfigurationOptions } from "../configFile/getConfiguration.js";
|
|
2
|
-
import * as _$esbuild from "esbuild";
|
|
3
2
|
import { BuildOptions } from "esbuild";
|
|
4
|
-
|
|
5
3
|
//#region src/bundle/index.d.ts
|
|
6
|
-
declare const packageList: readonly [
|
|
4
|
+
declare const packageList: readonly ['next-intlayer', 'react-intlayer', 'vue-intlayer', 'svelte-intlayer', 'preact-intlayer', 'solid-intlayer', 'angular-intlayer', 'lit-intlayer', 'express-intlayer', 'hono-intlayer', 'fastify-intlayer', 'adonis-intlayer', 'vanilla-intlayer', 'intlayer'];
|
|
7
5
|
type BundleIntlayerOptions = {
|
|
8
6
|
outfile?: string;
|
|
9
7
|
configOptions?: GetConfigurationOptions;
|
|
@@ -17,7 +15,7 @@ type BundleIntlayerOptions = {
|
|
|
17
15
|
* @param options - Bundle options including entryPoint, outfile, and esbuild options.
|
|
18
16
|
* @returns The build result.
|
|
19
17
|
*/
|
|
20
|
-
declare const bundleIntlayer: (options: BundleIntlayerOptions) => Promise<
|
|
18
|
+
declare const bundleIntlayer: (options: BundleIntlayerOptions) => Promise<import("esbuild").BuildResult<BuildOptions>>;
|
|
21
19
|
//#endregion
|
|
22
20
|
export { BundleIntlayerOptions, bundleIntlayer, packageList };
|
|
23
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/bundle/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/bundle/index.ts"],"mappings":";;;cAgBa;KAmBD;EACV;EACA,gBAAgB;EAChB;EACA;IACE;;;;;;;;cASS,iBAAc,SAAmB,0BAAqB,0BAAA,YAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logBundle.d.ts","names":[],"sources":["../../../src/bundle/logBundle.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"logBundle.d.ts","names":[],"sources":["../../../src/bundle/logBundle.ts"],"mappings":";;cAKa;UACH;UAEA;UACA;UACA;UACA;mBACS;UACT;UACA;EAER,YAAY,gBAAgB;EAI5B,UAAU;EAWV,SAAS;UAOD;UAQA;UAMA;UAMA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CallerDescriptor } from "./types.js";
|
|
2
|
+
//#region src/callers/base.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Base intlayer getters — always active, independent of any compat library.
|
|
5
|
+
*
|
|
6
|
+
* Their result is the dictionary content object itself: fields are consumed
|
|
7
|
+
* through member access (`content.title`) or destructuring
|
|
8
|
+
* (`const { title } = useIntlayer('home')`).
|
|
9
|
+
*/
|
|
10
|
+
declare const BASE_CALLERS: CallerDescriptor[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BASE_CALLERS };
|
|
13
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":[],"sources":["../../../src/callers/base.ts"],"mappings":";;;;;;;;;cASa,cAAc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
//#region src/callers/compat/i18next.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* i18next — `@intlayer/i18next` compat adapter.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `compat/i18next/src/plugin/index.ts` (`I18NEXT_COMPAT_CALLERS`).
|
|
7
|
+
*/
|
|
8
|
+
declare const I18NEXT_CALLERS: CallerDescriptor[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { I18NEXT_CALLERS };
|
|
11
|
+
//# sourceMappingURL=i18next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18next.d.ts","names":[],"sources":["../../../../src/callers/compat/i18next.ts"],"mappings":";;;;;;;cAOa,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lingui.d.ts","names":[],"sources":["../../../../src/callers/compat/lingui.ts"],"mappings":";;cAwBa,gBAAgB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
//#region src/callers/compat/nextIntl.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* next-intl — `@intlayer/next-intl` compat adapter.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `compat/next-intl/src/plugin/index.ts` (`NEXT_INTL_SWC_CALLERS`),
|
|
7
|
+
* adding the `getTranslations({ locale, namespace })` object overload.
|
|
8
|
+
*/
|
|
9
|
+
declare const NEXT_INTL_CALLERS: CallerDescriptor[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { NEXT_INTL_CALLERS };
|
|
12
|
+
//# sourceMappingURL=nextIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextIntl.d.ts","names":[],"sources":["../../../../src/callers/compat/nextIntl.ts"],"mappings":";;;;;;;;cAQa,mBAAmB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
//#region src/callers/compat/reactI18next.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* react-i18next / next-i18next — `@intlayer/react-i18next` and
|
|
5
|
+
* `@intlayer/next-i18next` compat adapters (next-i18next re-exports the
|
|
6
|
+
* react-i18next hook, so both libraries share the same callers).
|
|
7
|
+
*
|
|
8
|
+
* Mirrors `compat/react-i18next/src/plugin/index.ts` and
|
|
9
|
+
* `compat/next-i18next/src/plugin/index.ts`.
|
|
10
|
+
*/
|
|
11
|
+
declare const REACT_I18NEXT_CALLERS: CallerDescriptor[];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { REACT_I18NEXT_CALLERS };
|
|
14
|
+
//# sourceMappingURL=reactI18next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactI18next.d.ts","names":[],"sources":["../../../../src/callers/compat/reactI18next.ts"],"mappings":";;;;;;;;;;cAUa,uBAAuB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
//#region src/callers/compat/reactIntl.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* react-intl (FormatJS) — `@intlayer/react-intl` compat adapter.
|
|
5
|
+
*
|
|
6
|
+
* The full dotted message id encodes both the dictionary key and the field
|
|
7
|
+
* path: `formatMessage({ id: 'home.title' })` → dictionary `home`, field
|
|
8
|
+
* `title`.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors `compat/react-intl/src/plugin/index.ts`.
|
|
11
|
+
*/
|
|
12
|
+
declare const REACT_INTL_CALLERS: CallerDescriptor[];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { REACT_INTL_CALLERS };
|
|
15
|
+
//# sourceMappingURL=reactIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactIntl.d.ts","names":[],"sources":["../../../../src/callers/compat/reactIntl.ts"],"mappings":";;;;;;;;;;;cAWa,oBAAoB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
//#region src/callers/compat/useIntl.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* use-intl — `@intlayer/use-intl` compat adapter.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `compat/use-intl/src/plugin/index.ts`.
|
|
7
|
+
*/
|
|
8
|
+
declare const USE_INTL_CALLERS: CallerDescriptor[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { USE_INTL_CALLERS };
|
|
11
|
+
//# sourceMappingURL=useIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../../src/callers/compat/useIntl.ts"],"mappings":";;;;;;;cAOa,kBAAkB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CallerDescriptor } from "../types.js";
|
|
2
|
+
//#region src/callers/compat/vueI18n.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* vue-i18n — `@intlayer/vue-i18n` compat adapter.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `compat/vue-i18n/src/plugin/index.ts`.
|
|
7
|
+
*/
|
|
8
|
+
declare const VUE_I18N_CALLERS: CallerDescriptor[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { VUE_I18N_CALLERS };
|
|
11
|
+
//# sourceMappingURL=vueI18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vueI18n.d.ts","names":[],"sources":["../../../../src/callers/compat/vueI18n.ts"],"mappings":";;;;;;;cAOa,kBAAkB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CallerDescriptor, CallerResultShape, CallerValueSource } from "./types.js";
|
|
2
|
+
import { BASE_CALLERS } from "./base.js";
|
|
3
|
+
import { I18NEXT_CALLERS } from "./compat/i18next.js";
|
|
4
|
+
import { LINGUI_CALLERS } from "./compat/lingui.js";
|
|
5
|
+
import { NEXT_INTL_CALLERS } from "./compat/nextIntl.js";
|
|
6
|
+
import { REACT_I18NEXT_CALLERS } from "./compat/reactI18next.js";
|
|
7
|
+
import { REACT_INTL_CALLERS } from "./compat/reactIntl.js";
|
|
8
|
+
import { USE_INTL_CALLERS } from "./compat/useIntl.js";
|
|
9
|
+
import { VUE_I18N_CALLERS } from "./compat/vueI18n.js";
|
|
10
|
+
import { SwcExtraCallerConfig, getRewritableCallers, toSwcExtraCallers } from "./transform.js";
|
|
11
|
+
//#region src/callers/index.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Compat-adapter callers, grouped in one list. Each compat package's bundler
|
|
14
|
+
* plugin injects its own slice (e.g. `REACT_I18NEXT_CALLERS`) into the build
|
|
15
|
+
* pipeline; this aggregate exists for consumers that need every syntax at
|
|
16
|
+
* once, such as the LSP.
|
|
17
|
+
*/
|
|
18
|
+
declare const COMPAT_CALLERS: CallerDescriptor[];
|
|
19
|
+
/** Base + compat callers — the full registry the matchers run against. */
|
|
20
|
+
declare const ALL_CALLERS: CallerDescriptor[];
|
|
21
|
+
/**
|
|
22
|
+
* Descriptors indexed by caller name. A name can map to several descriptors
|
|
23
|
+
* (e.g. `Trans` exists in both react-i18next and lingui with different
|
|
24
|
+
* attributes); matchers try them in registry order.
|
|
25
|
+
*/
|
|
26
|
+
declare const CALLERS_BY_NAME: Map<string, CallerDescriptor[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Caller names whose dictionary key can appear as a positional string literal
|
|
29
|
+
* argument (`caller('key', …)` / `caller(locale, 'key', …)`). Used to build
|
|
30
|
+
* text-search regexes over project source files (find-references) and the
|
|
31
|
+
* completion trigger pattern. Callers whose key never appears positionally
|
|
32
|
+
* (fixed namespace, options object, JSX-only) are excluded on purpose.
|
|
33
|
+
*/
|
|
34
|
+
declare const getPositionalKeyCallerNames: () => string[];
|
|
35
|
+
/**
|
|
36
|
+
* Returns `true` when the descriptor may participate in matching for a file
|
|
37
|
+
* importing from `importSources`. Descriptors flagged `requiresImport` only
|
|
38
|
+
* activate when the file imports from one of their declared modules;
|
|
39
|
+
* everything else is always active (results are still validated against the
|
|
40
|
+
* project's dictionaries downstream).
|
|
41
|
+
*
|
|
42
|
+
* @param descriptor - The caller descriptor to gate.
|
|
43
|
+
* @param fileImportSources - Module specifiers imported by the analysed file.
|
|
44
|
+
*/
|
|
45
|
+
declare const isCallerActive: (descriptor: CallerDescriptor, fileImportSources: ReadonlySet<string>) => boolean;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { ALL_CALLERS, BASE_CALLERS, CALLERS_BY_NAME, COMPAT_CALLERS, type CallerDescriptor, type CallerResultShape, type CallerValueSource, I18NEXT_CALLERS, LINGUI_CALLERS, NEXT_INTL_CALLERS, REACT_I18NEXT_CALLERS, REACT_INTL_CALLERS, type SwcExtraCallerConfig, USE_INTL_CALLERS, VUE_I18N_CALLERS, getPositionalKeyCallerNames, getRewritableCallers, isCallerActive, toSwcExtraCallers };
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/callers/index.ts"],"mappings":";;;;;;;;;;;;;;;;;cAmCa,gBAAgB;;cAWhB,aAAa;;;;;;cAUb,iBAAiB,YAAY;;;;;;;;cAuB7B;;;;;;;;;;;cAwBA,iBAAc,YACb,kBAAgB,mBACT"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CallerDescriptor } from "./types.js";
|
|
2
|
+
//#region src/callers/transform.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Wire format of an extra caller forwarded to the `@intlayer/swc` plugin.
|
|
5
|
+
*
|
|
6
|
+
* Field names mirror the serde attributes of `ExtraCallerConfig` in
|
|
7
|
+
* `packages/@intlayer/swc/src/lib.rs` — both sides must stay in sync.
|
|
8
|
+
*/
|
|
9
|
+
type SwcExtraCallerConfig = {
|
|
10
|
+
/** The function name the user calls, e.g. `"useTranslation"`. */
|
|
11
|
+
callerName: string;
|
|
12
|
+
/** Module specifiers exporting the function (original + `@intlayer/*`). */
|
|
13
|
+
importSources: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Zero-based index of the positional argument holding the namespace string.
|
|
16
|
+
* Omitted for fixed/option namespace callers.
|
|
17
|
+
*/
|
|
18
|
+
namespaceArgIndex?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Compile-time constant namespace — the dictionary ident is inserted as a
|
|
21
|
+
* new first argument (lingui's `useLingui()`).
|
|
22
|
+
*/
|
|
23
|
+
fixedNamespace?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Namespace read from a property of an options-object argument — the
|
|
26
|
+
* dictionary ident is inserted as a new first argument and the property is
|
|
27
|
+
* rewritten to the key-prefix remainder (vue-i18n's `useI18n({ namespace })`).
|
|
28
|
+
*/
|
|
29
|
+
namespaceOption?: {
|
|
30
|
+
argumentIndex: number;
|
|
31
|
+
property: string;
|
|
32
|
+
};
|
|
33
|
+
/** Replacement function name for static import mode, e.g. `"useDictionary"`. */
|
|
34
|
+
staticReplacement: string;
|
|
35
|
+
/** Replacement function name for dynamic/fetch mode, e.g. `"useDictionaryDynamic"`. */
|
|
36
|
+
dynamicReplacement: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Returns the callers of a registry slice that the optimize pass can rewrite
|
|
40
|
+
* at build time: plain imported functions carrying both replacement names.
|
|
41
|
+
*
|
|
42
|
+
* Method-matched callers (`i18n.getFixedT`) and JSX components are excluded —
|
|
43
|
+
* their call sites cannot be re-pointed through an import specifier rename.
|
|
44
|
+
*/
|
|
45
|
+
declare const getRewritableCallers: (descriptors: CallerDescriptor[]) => CallerDescriptor[];
|
|
46
|
+
/**
|
|
47
|
+
* Serialises the rewritable callers of a registry slice into the
|
|
48
|
+
* `@intlayer/swc` plugin wire format (`extraCallers` option).
|
|
49
|
+
*
|
|
50
|
+
* Callers whose namespace can only be derived per-message id
|
|
51
|
+
* (`path-first-segment`) are skipped: the transform cannot bind a single
|
|
52
|
+
* dictionary to the call site.
|
|
53
|
+
*
|
|
54
|
+
* @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.
|
|
55
|
+
* @returns Configs ready to pass as `swcExtraCallers` / `extraCallers`.
|
|
56
|
+
*/
|
|
57
|
+
declare const toSwcExtraCallers: (descriptors: CallerDescriptor[]) => SwcExtraCallerConfig[];
|
|
58
|
+
//#endregion
|
|
59
|
+
export { SwcExtraCallerConfig, getRewritableCallers, toSwcExtraCallers };
|
|
60
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","names":[],"sources":["../../../src/callers/transform.ts"],"mappings":";;;;;;;;KAQY;;EAEV;;EAEA;;;;;EAKA;;;;;EAKA;;;;;;EAMA;IAAoB;IAAuB;;;EAE3C;;EAEA;;;;;;;;;cAUW,uBAAoB,aAClB,uBACZ;;;;;;;;;;;;cA6BU,oBAAiB,aACf,uBACZ"}
|