vite-intlayer 8.2.2 → 8.2.3
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/esm/intlayerPlugin.mjs +1 -1
- package/dist/esm/intlayerPlugin.mjs.map +1 -1
- package/dist/esm/packages/@intlayer/svelte-compiler/dist/esm/index.mjs +1 -1
- package/dist/esm/packages/@intlayer/svelte-compiler/dist/esm/svelte-intlayer-extract.mjs +2 -2
- package/dist/esm/packages/@intlayer/svelte-compiler/dist/esm/svelte-intlayer-extract.mjs.map +1 -1
- package/dist/esm/packages/@intlayer/vue-compiler/dist/esm/index.mjs +1 -1
- package/dist/esm/packages/@intlayer/vue-compiler/dist/esm/vue-intlayer-extract.mjs +2 -2
- package/dist/esm/packages/@intlayer/vue-compiler/dist/esm/vue-intlayer-extract.mjs.map +1 -1
- package/dist/types/intlayerPlugin.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{intlayerPrune as e}from"./intlayerPrunePlugin.mjs";import{resolve as t}from"node:path";import{prepareIntlayer as n}from"@intlayer/chokidar/build";import{getConfiguration as r}from"@intlayer/config/node";import{
|
|
1
|
+
import{intlayerPrune as e}from"./intlayerPrunePlugin.mjs";import{resolve as t}from"node:path";import{prepareIntlayer as n}from"@intlayer/chokidar/build";import{getConfiguration as r}from"@intlayer/config/node";import{logConfigDetails as i}from"@intlayer/chokidar/cli";import{watch as a}from"@intlayer/chokidar/watcher";import{getAlias as o}from"@intlayer/config/utils";const s=s=>{let c=r(s);i(s);let l=o({configuration:c,formatter:e=>t(e)}),u=Object.keys(l),d=[{name:`vite-intlayer-plugin`,config:async(e,t)=>{let{mode:r}=c.build,i=t.command===`serve`&&t.mode===`development`,a=t.command===`build`;if((i||a||r===`auto`)&&await n(c,{clean:a,cacheTimeoutMs:a?1e3*30:1e3*60*60}),e.resolve={...e.resolve,alias:{...e.resolve?.alias,...l}},e.optimizeDeps={...e.optimizeDeps,exclude:[...e.optimizeDeps?.exclude??[],...u]},e.ssr?.noExternal!==!0){let t=Array.isArray(e.ssr?.noExternal)?e.ssr.noExternal:e.ssr?.noExternal?[e.ssr.noExternal]:[];e.ssr={...e.ssr,noExternal:[...t,/(^@intlayer\/|intlayer$)/]}}return e},configureServer:async e=>{e.config.mode===`development`&&a({configuration:c})}}];return d.push(e(c)),d},c=s,l=s;export{l as intLayerPlugin,c as intlayer,s as intlayerPlugin};
|
|
2
2
|
//# sourceMappingURL=intlayerPlugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.mjs","names":[],"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport type { PluginOption } from 'vite';\nimport { intlayerPrune } from './intlayerPrunePlugin';\n\n/**\n * Vite plugin that integrates Intlayer into the Vite build process.\n *\n * It handles:\n * 1. Preparing Intlayer resources (dictionaries) before build.\n * 2. Configuring Vite aliases for dictionary access.\n * 3. Setting up dev-server watchers for content changes.\n * 4. Applying build optimizations (tree-shaking dictionaries).\n *\n * @param configOptions - Optional configuration to override default Intlayer settings.\n * @returns A Vite plugin option.\n *\n * @example\n * ```ts\n * import { intlayer } from 'vite-intlayer';\n *\n * export default defineConfig({\n * plugins: [intlayer()],\n * });\n * ```\n */\nexport const intlayerPlugin = (\n configOptions?: GetConfigurationOptions\n): PluginOption => {\n const intlayerConfig = getConfiguration(configOptions);\n\n const alias = getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value),\n });\n\n const aliasPackages = Object.keys(alias);\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n config: async (config, env) => {\n const { mode } = intlayerConfig.build;\n\n const isDevCommand =\n env.command === 'serve' && env.mode === 'development';\n const isBuildCommand = env.command === 'build';\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (isDevCommand || isBuildCommand || mode === 'auto') {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n });\n }\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n ...alias,\n },\n };\n\n config.optimizeDeps = {\n ...config.optimizeDeps,\n exclude: [...(config.optimizeDeps?.exclude ?? []), ...aliasPackages],\n };\n\n // Update Vite's SSR Externalization\n // We must ensure that intlayer packages are processed by Vite (bundled)\n // so that the aliases defined above are actually applied\n if (config.ssr?.noExternal !== true) {\n const currentNoExternal = Array.isArray(config.ssr?.noExternal)\n ? config.ssr.noExternal\n : config.ssr?.noExternal\n ? [config.ssr.noExternal]\n : [];\n\n config.ssr = {\n ...config.ssr,\n noExternal: [\n ...(currentNoExternal as (string | RegExp)[]),\n // Regex to bundle all intlayer related packages\n /(^@intlayer\\/|intlayer$)/,\n ],\n };\n }\n\n return config;\n },\n\n configureServer: async (server) => {\n if (server.config.mode === 'development') {\n // Start watching (assuming watch is also async)\n watch({ configuration: intlayerConfig });\n }\n },\n },\n ];\n\n // Add Babel transform plugin if enabled\n plugins.push(intlayerPrune(intlayerConfig));\n\n return plugins;\n};\n\n/**\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intlayer = intlayerPlugin;\n/**\n * @deprecated Rename to intlayer instead\n *\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intLayerPlugin = intlayerPlugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.mjs","names":[],"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport type { PluginOption } from 'vite';\nimport { intlayerPrune } from './intlayerPrunePlugin';\n\n/**\n * Vite plugin that integrates Intlayer into the Vite build process.\n *\n * It handles:\n * 1. Preparing Intlayer resources (dictionaries) before build.\n * 2. Configuring Vite aliases for dictionary access.\n * 3. Setting up dev-server watchers for content changes.\n * 4. Applying build optimizations (tree-shaking dictionaries).\n *\n * @param configOptions - Optional configuration to override default Intlayer settings.\n * @returns A Vite plugin option.\n *\n * @example\n * ```ts\n * import { intlayer } from 'vite-intlayer';\n *\n * export default defineConfig({\n * plugins: [intlayer()],\n * });\n * ```\n */\nexport const intlayerPlugin = (\n configOptions?: GetConfigurationOptions\n): PluginOption => {\n const intlayerConfig = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const alias = getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value),\n });\n\n const aliasPackages = Object.keys(alias);\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n config: async (config, env) => {\n const { mode } = intlayerConfig.build;\n\n const isDevCommand =\n env.command === 'serve' && env.mode === 'development';\n const isBuildCommand = env.command === 'build';\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (isDevCommand || isBuildCommand || mode === 'auto') {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n });\n }\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n ...alias,\n },\n };\n\n config.optimizeDeps = {\n ...config.optimizeDeps,\n exclude: [...(config.optimizeDeps?.exclude ?? []), ...aliasPackages],\n };\n\n // Update Vite's SSR Externalization\n // We must ensure that intlayer packages are processed by Vite (bundled)\n // so that the aliases defined above are actually applied\n if (config.ssr?.noExternal !== true) {\n const currentNoExternal = Array.isArray(config.ssr?.noExternal)\n ? config.ssr.noExternal\n : config.ssr?.noExternal\n ? [config.ssr.noExternal]\n : [];\n\n config.ssr = {\n ...config.ssr,\n noExternal: [\n ...(currentNoExternal as (string | RegExp)[]),\n // Regex to bundle all intlayer related packages\n /(^@intlayer\\/|intlayer$)/,\n ],\n };\n }\n\n return config;\n },\n\n configureServer: async (server) => {\n if (server.config.mode === 'development') {\n // Start watching (assuming watch is also async)\n watch({ configuration: intlayerConfig });\n }\n },\n },\n ];\n\n // Add Babel transform plugin if enabled\n plugins.push(intlayerPrune(intlayerConfig));\n\n return plugins;\n};\n\n/**\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intlayer = intlayerPlugin;\n/**\n * @deprecated Rename to intlayer instead\n *\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intLayerPlugin = intl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|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
`)}\n`;if(D){let t=D.index+D[0].indexOf(`>`)+1;v.appendLeft(t,e)}else v.prepend(`<script>\n ${N}\n ${O?`import { get } from 'svelte/store';`:``}\n ${F}\n<\/script>\n\n`)}return p&&p({dictionaryKey:x,filePath:
|
|
1
|
+
import"node:fs/promises";import e from"/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs";import{parse as t,traverse as n,types as r}from"@babel/core";import*as i from"/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/svelte@5.0.0/node_modules/svelte/src/compiler/index.js";const a=(e,t)=>{if(!e)return!1;if(!t||t.length===0)return!0;let n=e.replace(/\\/g,`/`);return t.some(e=>e.replace(/\\/g,`/`)===n)},o=(o,s,c={})=>{let{defaultLocale:l=`en`,packageName:u=`svelte-intlayer`,filesList:d,shouldExtract:f,onExtract:p,dictionaryKey:m,attributesToExtract:h=[],extractDictionaryKeyFromPath:g,generateKey:_}=c;if(!a(s,d)||!s.endsWith(`.svelte`))return null;let v=new e(o),y={},b=new Set,x=m??g?.(s)??``,S=[],C;try{C=i.parse(o)}catch(e){return console.warn(`Svelte extraction: Failed to parse Svelte AST for ${s}`,e),null}let w=e=>e.type===`Text`||e.type===3,T=e=>e.type===`Attribute`||e.type===6,E=e=>{if(w(e)){let t=e.data??e.content??``;if(f?.(t)&&_){let n=_(t,b);b.add(n),S.push({start:e.start,end:e.end,replacement:`{$content.${n}}`,key:n,value:t.replace(/\s+/g,` `).trim()})}}else if(T(e)&&h.includes(e.name)&&e.value&&e.value.length===1&&w(e.value[0])){let t=e.value[0].data??e.value[0].content??``;if(f?.(t)&&_){let n=_(t,b);b.add(n),S.push({start:e.start,end:e.end,replacement:`${e.name}={$content.${n}}`,key:n,value:t.trim()})}}let t=e.children??e.fragment?.nodes??e.fragment?.children;t&&t.forEach(E),e.attributes&&e.attributes.forEach(E)};C.html&&E(C.html);let D=/<script[^>]*>([\s\S]*?)<\/script>/.exec(o),O=!1,k=D?D[1]:``;if(D){let e=D[0].indexOf(`>`)+1,i=D.index+e;try{let e=t(k,{parserOpts:{sourceType:`module`,plugins:[`typescript`,`jsx`]}});e&&n(e,{StringLiteral(e){if(e.parentPath.isImportDeclaration()||e.parentPath.isExportDeclaration()||e.parentPath.isImportSpecifier()||e.parentPath.isObjectProperty()&&e.key===`key`)return;if(e.parentPath.isCallExpression()){let t=e.parentPath.node.callee;if(r.isMemberExpression(t)&&r.isIdentifier(t.object)&&t.object.name===`console`||r.isIdentifier(t)&&(t.name===`useIntlayer`||t.name===`t`)||t.type===`Import`||r.isIdentifier(t)&&t.name===`require`)return}let t=e.node.value;if(f?.(t)&&_){let n=_(t,b);b.add(n),O=!0,e.node.start!=null&&e.node.end!=null&&S.push({start:i+e.node.start,end:i+e.node.end,replacement:`get(content).${n}`,key:n,value:t.trim()})}}})}catch(e){console.warn(`Svelte extraction: Failed to parse script content for ${s}`,e)}}if(S.length===0)return null;S.sort((e,t)=>t.start-e.start);for(let{start:e,end:t,replacement:n,key:r,value:i}of S)v.overwrite(e,t,n),y[r]=i;let A=/import\s*{[^}]*useIntlayer[^}]*}\s*from\s*['"][^'"]+['"]/.test(k)||/import\s+useIntlayer\s+from\s*['"][^'"]+['"]/.test(k),j=/import\s*{[^}]*get[^}]*}\s*from\s*['"]svelte\/store['"]/.test(k),M=/const\s+content\s*=\s*useIntlayer\s*\(/.test(k),N=A?``:`import { useIntlayer } from '${u}';`,P=O&&!j?`import { get } from 'svelte/store';`:``,F=M?``:`const content = useIntlayer('${x}');`,I=[N,P,F].filter(Boolean);if(I.length>0){let e=`\n ${I.join(`
|
|
2
|
+
`)}\n`;if(D){let t=D.index+D[0].indexOf(`>`)+1;v.appendLeft(t,e)}else v.prepend(`<script>\n ${N}\n ${O?`import { get } from 'svelte/store';`:``}\n ${F}\n<\/script>\n\n`)}return p&&p({dictionaryKey:x,filePath:s,content:{...y},locale:l}),{code:v.toString(),map:v.generateMap({source:s,includeContent:!0}),extracted:!0}};export{o as c,a as s};
|
|
3
3
|
//# sourceMappingURL=svelte-intlayer-extract.mjs.map
|
package/dist/esm/packages/@intlayer/svelte-compiler/dist/esm/svelte-intlayer-extract.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svelte-intlayer-extract.mjs","names":["n","r","i","e","t"],"sources":["../../../../../../../../@intlayer/svelte-compiler/dist/esm/svelte-intlayer-extract.mjs"],"sourcesContent":["import{readFile as e,writeFile as t}from\"node:fs/promises\";import{parse as n,traverse as r,types as i}from\"@babel/core\";import a from\"magic-string\";import*as o from\"svelte/compiler\";const s=(e,t)=>{if(!e)return!1;if(!t||t.length===0)return!0;let n=e.replace(/\\\\/g,`/`);return t.some(e=>e.replace(/\\\\/g,`/`)===n)},c=(e,t,c={})=>{let{defaultLocale:l=`en`,packageName:u=`svelte-intlayer`,filesList:d,shouldExtract:f,onExtract:p,dictionaryKey:m,attributesToExtract:h=[],extractDictionaryKeyFromPath:g,generateKey:_}=c;if(!s(t,d)||!t.endsWith(`.svelte`))return null;let v=new a(e),y={},b=new Set,x=m??g?.(t)??``,S=[],C;try{C=o.parse(e)}catch(e){return console.warn(`Svelte extraction: Failed to parse Svelte AST for ${t}`,e),null}let w=e=>e.type===`Text`||e.type===3,T=e=>e.type===`Attribute`||e.type===6,E=e=>{if(w(e)){let t=e.data??e.content??``;if(f?.(t)&&_){let n=_(t,b);b.add(n),S.push({start:e.start,end:e.end,replacement:`{$content.${n}}`,key:n,value:t.replace(/\\s+/g,` `).trim()})}}else if(T(e)&&h.includes(e.name)&&e.value&&e.value.length===1&&w(e.value[0])){let t=e.value[0].data??e.value[0].content??``;if(f?.(t)&&_){let n=_(t,b);b.add(n),S.push({start:e.start,end:e.end,replacement:`${e.name}={$content.${n}}`,key:n,value:t.trim()})}}let t=e.children??e.fragment?.nodes??e.fragment?.children;t&&t.forEach(E),e.attributes&&e.attributes.forEach(E)};C.html&&E(C.html);let D=/<script[^>]*>([\\s\\S]*?)<\\/script>/.exec(e),O=!1,k=D?D[1]:``;if(D){let e=D[0].indexOf(`>`)+1,a=D.index+e;try{let e=n(k,{parserOpts:{sourceType:`module`,plugins:[`typescript`,`jsx`]}});e&&r(e,{StringLiteral(e){if(e.parentPath.isImportDeclaration()||e.parentPath.isExportDeclaration()||e.parentPath.isImportSpecifier()||e.parentPath.isObjectProperty()&&e.key===`key`)return;if(e.parentPath.isCallExpression()){let t=e.parentPath.node.callee;if(i.isMemberExpression(t)&&i.isIdentifier(t.object)&&t.object.name===`console`||i.isIdentifier(t)&&(t.name===`useIntlayer`||t.name===`t`)||t.type===`Import`||i.isIdentifier(t)&&t.name===`require`)return}let t=e.node.value;if(f?.(t)&&_){let n=_(t,b);b.add(n),O=!0,e.node.start!=null&&e.node.end!=null&&S.push({start:a+e.node.start,end:a+e.node.end,replacement:`get(content).${n}`,key:n,value:t.trim()})}}})}catch(e){console.warn(`Svelte extraction: Failed to parse script content for ${t}`,e)}}if(S.length===0)return null;S.sort((e,t)=>t.start-e.start);for(let{start:e,end:t,replacement:n,key:r,value:i}of S)v.overwrite(e,t,n),y[r]=i;let A=/import\\s*{[^}]*useIntlayer[^}]*}\\s*from\\s*['\"][^'\"]+['\"]/.test(k)||/import\\s+useIntlayer\\s+from\\s*['\"][^'\"]+['\"]/.test(k),j=/import\\s*{[^}]*get[^}]*}\\s*from\\s*['\"]svelte\\/store['\"]/.test(k),M=/const\\s+content\\s*=\\s*useIntlayer\\s*\\(/.test(k),N=A?``:`import { useIntlayer } from '${u}';`,P=O&&!j?`import { get } from 'svelte/store';`:``,F=M?``:`const content = useIntlayer('${x}');`,I=[N,P,F].filter(Boolean);if(I.length>0){let e=`\\n ${I.join(`\n `)}\\n`;if(D){let t=D.index+D[0].indexOf(`>`)+1;v.appendLeft(t,e)}else v.prepend(`<script>\\n ${N}\\n ${O?`import { get } from 'svelte/store';`:``}\\n ${F}\\n<\\/script>\\n\\n`)}return p&&p({dictionaryKey:x,filePath:t,content:{...y},locale:l}),{code:v.toString(),map:v.generateMap({source:t,includeContent:!0}),extracted:!0}},l=async(n,r,i,a,o=!0)=>{let s=await e(n,`utf-8`),l=null,u=c(s,n,{packageName:i,dictionaryKey:r,shouldExtract:a.shouldExtract,generateKey:a.generateKey,extractDictionaryKeyFromPath:a.extractDictionaryKeyFromPath,attributesToExtract:a.attributesToExtract,onExtract:e=>{l=e.content}});return u?(o&&await t(n,u.code),l):null};export{c as intlayerSvelteExtract,l as processSvelteFile,s as shouldProcessFile};\n//# sourceMappingURL=svelte-intlayer-extract.mjs.map"],"mappings":"
|
|
1
|
+
{"version":3,"file":"svelte-intlayer-extract.mjs","names":["n","r","i","e","t"],"sources":["../../../../../../../../@intlayer/svelte-compiler/dist/esm/svelte-intlayer-extract.mjs"],"sourcesContent":["import{readFile as e,writeFile as t}from\"node:fs/promises\";import{parse as n,traverse as r,types as i}from\"@babel/core\";import a from\"magic-string\";import*as o from\"svelte/compiler\";const s=(e,t)=>{if(!e)return!1;if(!t||t.length===0)return!0;let n=e.replace(/\\\\/g,`/`);return t.some(e=>e.replace(/\\\\/g,`/`)===n)},c=(e,t,c={})=>{let{defaultLocale:l=`en`,packageName:u=`svelte-intlayer`,filesList:d,shouldExtract:f,onExtract:p,dictionaryKey:m,attributesToExtract:h=[],extractDictionaryKeyFromPath:g,generateKey:_}=c;if(!s(t,d)||!t.endsWith(`.svelte`))return null;let v=new a(e),y={},b=new Set,x=m??g?.(t)??``,S=[],C;try{C=o.parse(e)}catch(e){return console.warn(`Svelte extraction: Failed to parse Svelte AST for ${t}`,e),null}let w=e=>e.type===`Text`||e.type===3,T=e=>e.type===`Attribute`||e.type===6,E=e=>{if(w(e)){let t=e.data??e.content??``;if(f?.(t)&&_){let n=_(t,b);b.add(n),S.push({start:e.start,end:e.end,replacement:`{$content.${n}}`,key:n,value:t.replace(/\\s+/g,` `).trim()})}}else if(T(e)&&h.includes(e.name)&&e.value&&e.value.length===1&&w(e.value[0])){let t=e.value[0].data??e.value[0].content??``;if(f?.(t)&&_){let n=_(t,b);b.add(n),S.push({start:e.start,end:e.end,replacement:`${e.name}={$content.${n}}`,key:n,value:t.trim()})}}let t=e.children??e.fragment?.nodes??e.fragment?.children;t&&t.forEach(E),e.attributes&&e.attributes.forEach(E)};C.html&&E(C.html);let D=/<script[^>]*>([\\s\\S]*?)<\\/script>/.exec(e),O=!1,k=D?D[1]:``;if(D){let e=D[0].indexOf(`>`)+1,a=D.index+e;try{let e=n(k,{parserOpts:{sourceType:`module`,plugins:[`typescript`,`jsx`]}});e&&r(e,{StringLiteral(e){if(e.parentPath.isImportDeclaration()||e.parentPath.isExportDeclaration()||e.parentPath.isImportSpecifier()||e.parentPath.isObjectProperty()&&e.key===`key`)return;if(e.parentPath.isCallExpression()){let t=e.parentPath.node.callee;if(i.isMemberExpression(t)&&i.isIdentifier(t.object)&&t.object.name===`console`||i.isIdentifier(t)&&(t.name===`useIntlayer`||t.name===`t`)||t.type===`Import`||i.isIdentifier(t)&&t.name===`require`)return}let t=e.node.value;if(f?.(t)&&_){let n=_(t,b);b.add(n),O=!0,e.node.start!=null&&e.node.end!=null&&S.push({start:a+e.node.start,end:a+e.node.end,replacement:`get(content).${n}`,key:n,value:t.trim()})}}})}catch(e){console.warn(`Svelte extraction: Failed to parse script content for ${t}`,e)}}if(S.length===0)return null;S.sort((e,t)=>t.start-e.start);for(let{start:e,end:t,replacement:n,key:r,value:i}of S)v.overwrite(e,t,n),y[r]=i;let A=/import\\s*{[^}]*useIntlayer[^}]*}\\s*from\\s*['\"][^'\"]+['\"]/.test(k)||/import\\s+useIntlayer\\s+from\\s*['\"][^'\"]+['\"]/.test(k),j=/import\\s*{[^}]*get[^}]*}\\s*from\\s*['\"]svelte\\/store['\"]/.test(k),M=/const\\s+content\\s*=\\s*useIntlayer\\s*\\(/.test(k),N=A?``:`import { useIntlayer } from '${u}';`,P=O&&!j?`import { get } from 'svelte/store';`:``,F=M?``:`const content = useIntlayer('${x}');`,I=[N,P,F].filter(Boolean);if(I.length>0){let e=`\\n ${I.join(`\n `)}\\n`;if(D){let t=D.index+D[0].indexOf(`>`)+1;v.appendLeft(t,e)}else v.prepend(`<script>\\n ${N}\\n ${O?`import { get } from 'svelte/store';`:``}\\n ${F}\\n<\\/script>\\n\\n`)}return p&&p({dictionaryKey:x,filePath:t,content:{...y},locale:l}),{code:v.toString(),map:v.generateMap({source:t,includeContent:!0}),extracted:!0}},l=async(n,r,i,a,o=!0)=>{let s=await e(n,`utf-8`),l=null,u=c(s,n,{packageName:i,dictionaryKey:r,shouldExtract:a.shouldExtract,generateKey:a.generateKey,extractDictionaryKeyFromPath:a.extractDictionaryKeyFromPath,attributesToExtract:a.attributesToExtract,onExtract:e=>{l=e.content}});return u?(o&&await t(n,u.code),l):null};export{c as intlayerSvelteExtract,l as processSvelteFile,s as shouldProcessFile};\n//# sourceMappingURL=svelte-intlayer-extract.mjs.map"],"mappings":"4WAAsL,MAAM,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,MAAM,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,EAAE,QAAQ,MAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,YAAY,EAAE,kBAAkB,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,EAAE,CAAC,6BAA6B,EAAE,YAAY,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,EAAE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E,YAAY,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,2DAA2D,KAAK,EAAE,EAAE,+CAA+C,KAAK,EAAE,CAAC,EAAE,0DAA0D,KAAK,EAAE,CAAC,EAAE,yCAAyC,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,gCAAgC,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,sCAAsC,GAAG,EAAE,EAAE,GAAG,gCAAgC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK;IACh1F,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,QAAQ,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,QAAQ,eAAe,EAAE,MAAM,EAAE,sCAAsC,GAAG,MAAM,EAAE,kBAAkB,CAAC,OAAO,GAAG,EAAE,CAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e
|
|
1
|
+
import{c as e}from"./vue-intlayer-extract.mjs";export{e as intlayerVueExtract};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
`)}\n`;b.descriptor.scriptSetup?x.appendLeft(b.descriptor.scriptSetup.loc.start.offset,e):b.descriptor.script?x.appendLeft(b.descriptor.script.loc.start.offset,e):x.prepend(`<script setup>\n${A}\n${j}\n<\/script>\n`)}return p&&p({dictionaryKey:w,filePath:
|
|
1
|
+
import"node:fs/promises";import{parse as e,traverse as t,types as n}from"@babel/core";import r from"/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@vue+compiler-sfc@3.5.29/node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js";const i=(e,t)=>{if(!e)return!1;if(!t||t.length===0)return!0;let n=e.replace(/\\/g,`/`);return t.some(e=>e.replace(/\\/g,`/`)===n)},a={TEXT:2,ELEMENT:1,ATTRIBUTE:6},o=async(o,s,c={})=>{let{defaultLocale:l=`en`,packageName:u=`vue-intlayer`,filesList:d,shouldExtract:f,onExtract:p,dictionaryKey:m,attributesToExtract:h=[],extractDictionaryKeyFromPath:g,generateKey:_}=c;if(!i(s,d)||!s.endsWith(`.vue`))return null;let v,y;try{v=r.parse}catch{return console.warn(`Vue extraction: @vue/compiler-sfc not found.`),null}try{y=(await import(`/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs`)).default}catch{return console.warn(`Vue extraction: magic-string not found.`),null}let b=v(o),x=new y(o),S={},C=new Set,w=m??g?.(s)??``,T=[];if(b.descriptor.template){let e=t=>{if(t.type===a.TEXT){let e=t.content??``;if(f?.(e)&&_){let n=_(e,C);C.add(n),T.push({start:t.loc.start.offset,end:t.loc.end.offset,replacement:`{{ content.${n} }}`,key:n,value:e.replace(/\s+/g,` `).trim()})}}else t.type===a.ELEMENT&&t.props?.forEach(e=>{if(e.type===a.ATTRIBUTE&&h.includes(e.name)&&e.value){let t=e.value.content;if(f?.(t)&&_){let n=_(t,C);C.add(n),T.push({start:e.loc.start.offset,end:e.loc.end.offset,replacement:`:${e.name}="content.${n}"`,key:n,value:t.trim()})}}});t.children&&t.children.forEach(e)};e(b.descriptor.template.ast)}let E=b.descriptor.scriptSetup??b.descriptor.script;if(E){let r=E.content,i=E.loc.start.offset;try{let a=e(r,{parserOpts:{sourceType:`module`,plugins:[`typescript`,`jsx`]}});a&&t(a,{StringLiteral(e){if(e.parentPath.isImportDeclaration()||e.parentPath.isExportDeclaration()||e.parentPath.isImportSpecifier()||e.parentPath.isObjectProperty()&&e.key===`key`)return;if(e.parentPath.isCallExpression()){let t=e.parentPath.node.callee;if(n.isMemberExpression(t)&&n.isIdentifier(t.object)&&t.object.name===`console`||n.isIdentifier(t)&&(t.name===`useIntlayer`||t.name===`t`)||t.type===`Import`||n.isIdentifier(t)&&t.name===`require`)return}let t=e.node.value;if(f?.(t)&&_){let n=_(t,C);C.add(n),e.node.start!=null&&e.node.end!=null&&T.push({start:i+e.node.start,end:i+e.node.end,replacement:`content.${n}`,key:n,value:t.trim()})}}})}catch(e){console.warn(`Vue extraction: Failed to parse script content for ${s}`,e)}}if(T.length===0)return null;T.sort((e,t)=>t.start-e.start);for(let{start:e,end:t,replacement:n,key:r,value:i}of T)x.overwrite(e,t,n),S[r]=i;let D=E?.content??``,O=/import\s*{[^}]*useIntlayer[^}]*}\s*from\s*['"][^'"]+['"]/.test(D)||/import\s+useIntlayer\s+from\s*['"][^'"]+['"]/.test(D),k=/const\s+content\s*=\s*useIntlayer\s*\(/.test(D),A=O?``:`import { useIntlayer } from '${u}';`,j=k?``:`const content = useIntlayer('${w}');`,M=[A,j].filter(Boolean);if(M.length>0){let e=`\n${M.join(`
|
|
2
|
+
`)}\n`;b.descriptor.scriptSetup?x.appendLeft(b.descriptor.scriptSetup.loc.start.offset,e):b.descriptor.script?x.appendLeft(b.descriptor.script.loc.start.offset,e):x.prepend(`<script setup>\n${A}\n${j}\n<\/script>\n`)}return p&&p({dictionaryKey:w,filePath:s,content:{...S},locale:l}),{code:x.toString(),map:x.generateMap({source:s,includeContent:!0}),extracted:!0}};export{o as c,i as o};
|
|
3
3
|
//# sourceMappingURL=vue-intlayer-extract.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue-intlayer-extract.mjs","names":["n","r","i","e","t"],"sources":["../../../../../../../../@intlayer/vue-compiler/dist/esm/vue-intlayer-extract.mjs"],"sourcesContent":["import{readFile as e,writeFile as t}from\"node:fs/promises\";import{parse as n,traverse as r,types as i}from\"@babel/core\";import a from\"@vue/compiler-sfc\";const o=(e,t)=>{if(!e)return!1;if(!t||t.length===0)return!0;let n=e.replace(/\\\\/g,`/`);return t.some(e=>e.replace(/\\\\/g,`/`)===n)},s={TEXT:2,ELEMENT:1,ATTRIBUTE:6},c=async(e,t,c={})=>{let{defaultLocale:l=`en`,packageName:u=`vue-intlayer`,filesList:d,shouldExtract:f,onExtract:p,dictionaryKey:m,attributesToExtract:h=[],extractDictionaryKeyFromPath:g,generateKey:_}=c;if(!o(t,d)||!t.endsWith(`.vue`))return null;let v,y;try{v=a.parse}catch{return console.warn(`Vue extraction: @vue/compiler-sfc not found.`),null}try{y=(await import(`magic-string`)).default}catch{return console.warn(`Vue extraction: magic-string not found.`),null}let b=v(e),x=new y(e),S={},C=new Set,w=m??g?.(t)??``,T=[];if(b.descriptor.template){let e=t=>{if(t.type===s.TEXT){let e=t.content??``;if(f?.(e)&&_){let n=_(e,C);C.add(n),T.push({start:t.loc.start.offset,end:t.loc.end.offset,replacement:`{{ content.${n} }}`,key:n,value:e.replace(/\\s+/g,` `).trim()})}}else t.type===s.ELEMENT&&t.props?.forEach(e=>{if(e.type===s.ATTRIBUTE&&h.includes(e.name)&&e.value){let t=e.value.content;if(f?.(t)&&_){let n=_(t,C);C.add(n),T.push({start:e.loc.start.offset,end:e.loc.end.offset,replacement:`:${e.name}=\"content.${n}\"`,key:n,value:t.trim()})}}});t.children&&t.children.forEach(e)};e(b.descriptor.template.ast)}let E=b.descriptor.scriptSetup??b.descriptor.script;if(E){let e=E.content,a=E.loc.start.offset;try{let t=n(e,{parserOpts:{sourceType:`module`,plugins:[`typescript`,`jsx`]}});t&&r(t,{StringLiteral(e){if(e.parentPath.isImportDeclaration()||e.parentPath.isExportDeclaration()||e.parentPath.isImportSpecifier()||e.parentPath.isObjectProperty()&&e.key===`key`)return;if(e.parentPath.isCallExpression()){let t=e.parentPath.node.callee;if(i.isMemberExpression(t)&&i.isIdentifier(t.object)&&t.object.name===`console`||i.isIdentifier(t)&&(t.name===`useIntlayer`||t.name===`t`)||t.type===`Import`||i.isIdentifier(t)&&t.name===`require`)return}let t=e.node.value;if(f?.(t)&&_){let n=_(t,C);C.add(n),e.node.start!=null&&e.node.end!=null&&T.push({start:a+e.node.start,end:a+e.node.end,replacement:`content.${n}`,key:n,value:t.trim()})}}})}catch(e){console.warn(`Vue extraction: Failed to parse script content for ${t}`,e)}}if(T.length===0)return null;T.sort((e,t)=>t.start-e.start);for(let{start:e,end:t,replacement:n,key:r,value:i}of T)x.overwrite(e,t,n),S[r]=i;let D=E?.content??``,O=/import\\s*{[^}]*useIntlayer[^}]*}\\s*from\\s*['\"][^'\"]+['\"]/.test(D)||/import\\s+useIntlayer\\s+from\\s*['\"][^'\"]+['\"]/.test(D),k=/const\\s+content\\s*=\\s*useIntlayer\\s*\\(/.test(D),A=O?``:`import { useIntlayer } from '${u}';`,j=k?``:`const content = useIntlayer('${w}');`,M=[A,j].filter(Boolean);if(M.length>0){let e=`\\n${M.join(`\n`)}\\n`;b.descriptor.scriptSetup?x.appendLeft(b.descriptor.scriptSetup.loc.start.offset,e):b.descriptor.script?x.appendLeft(b.descriptor.script.loc.start.offset,e):x.prepend(`<script setup>\\n${A}\\n${j}\\n<\\/script>\\n`)}return p&&p({dictionaryKey:w,filePath:t,content:{...S},locale:l}),{code:x.toString(),map:x.generateMap({source:t,includeContent:!0}),extracted:!0}},l=async(n,r,i,a,o=!0)=>{let s=await e(n,`utf-8`),l={},u=await c(s,n,{packageName:i,dictionaryKey:r,shouldExtract:a.shouldExtract,generateKey:a.generateKey,extractDictionaryKeyFromPath:a.extractDictionaryKeyFromPath,attributesToExtract:a.attributesToExtract,onExtract:e=>{l=e.content}});return u?(o&&await t(n,u.code),l):null};export{c as intlayerVueExtract,l as processVueFile,o as shouldProcessFile};\n//# sourceMappingURL=vue-intlayer-extract.mjs.map"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vue-intlayer-extract.mjs","names":["n","r","i","e","t"],"sources":["../../../../../../../../@intlayer/vue-compiler/dist/esm/vue-intlayer-extract.mjs"],"sourcesContent":["import{readFile as e,writeFile as t}from\"node:fs/promises\";import{parse as n,traverse as r,types as i}from\"@babel/core\";import a from\"@vue/compiler-sfc\";const o=(e,t)=>{if(!e)return!1;if(!t||t.length===0)return!0;let n=e.replace(/\\\\/g,`/`);return t.some(e=>e.replace(/\\\\/g,`/`)===n)},s={TEXT:2,ELEMENT:1,ATTRIBUTE:6},c=async(e,t,c={})=>{let{defaultLocale:l=`en`,packageName:u=`vue-intlayer`,filesList:d,shouldExtract:f,onExtract:p,dictionaryKey:m,attributesToExtract:h=[],extractDictionaryKeyFromPath:g,generateKey:_}=c;if(!o(t,d)||!t.endsWith(`.vue`))return null;let v,y;try{v=a.parse}catch{return console.warn(`Vue extraction: @vue/compiler-sfc not found.`),null}try{y=(await import(`magic-string`)).default}catch{return console.warn(`Vue extraction: magic-string not found.`),null}let b=v(e),x=new y(e),S={},C=new Set,w=m??g?.(t)??``,T=[];if(b.descriptor.template){let e=t=>{if(t.type===s.TEXT){let e=t.content??``;if(f?.(e)&&_){let n=_(e,C);C.add(n),T.push({start:t.loc.start.offset,end:t.loc.end.offset,replacement:`{{ content.${n} }}`,key:n,value:e.replace(/\\s+/g,` `).trim()})}}else t.type===s.ELEMENT&&t.props?.forEach(e=>{if(e.type===s.ATTRIBUTE&&h.includes(e.name)&&e.value){let t=e.value.content;if(f?.(t)&&_){let n=_(t,C);C.add(n),T.push({start:e.loc.start.offset,end:e.loc.end.offset,replacement:`:${e.name}=\"content.${n}\"`,key:n,value:t.trim()})}}});t.children&&t.children.forEach(e)};e(b.descriptor.template.ast)}let E=b.descriptor.scriptSetup??b.descriptor.script;if(E){let e=E.content,a=E.loc.start.offset;try{let t=n(e,{parserOpts:{sourceType:`module`,plugins:[`typescript`,`jsx`]}});t&&r(t,{StringLiteral(e){if(e.parentPath.isImportDeclaration()||e.parentPath.isExportDeclaration()||e.parentPath.isImportSpecifier()||e.parentPath.isObjectProperty()&&e.key===`key`)return;if(e.parentPath.isCallExpression()){let t=e.parentPath.node.callee;if(i.isMemberExpression(t)&&i.isIdentifier(t.object)&&t.object.name===`console`||i.isIdentifier(t)&&(t.name===`useIntlayer`||t.name===`t`)||t.type===`Import`||i.isIdentifier(t)&&t.name===`require`)return}let t=e.node.value;if(f?.(t)&&_){let n=_(t,C);C.add(n),e.node.start!=null&&e.node.end!=null&&T.push({start:a+e.node.start,end:a+e.node.end,replacement:`content.${n}`,key:n,value:t.trim()})}}})}catch(e){console.warn(`Vue extraction: Failed to parse script content for ${t}`,e)}}if(T.length===0)return null;T.sort((e,t)=>t.start-e.start);for(let{start:e,end:t,replacement:n,key:r,value:i}of T)x.overwrite(e,t,n),S[r]=i;let D=E?.content??``,O=/import\\s*{[^}]*useIntlayer[^}]*}\\s*from\\s*['\"][^'\"]+['\"]/.test(D)||/import\\s+useIntlayer\\s+from\\s*['\"][^'\"]+['\"]/.test(D),k=/const\\s+content\\s*=\\s*useIntlayer\\s*\\(/.test(D),A=O?``:`import { useIntlayer } from '${u}';`,j=k?``:`const content = useIntlayer('${w}');`,M=[A,j].filter(Boolean);if(M.length>0){let e=`\\n${M.join(`\n`)}\\n`;b.descriptor.scriptSetup?x.appendLeft(b.descriptor.scriptSetup.loc.start.offset,e):b.descriptor.script?x.appendLeft(b.descriptor.script.loc.start.offset,e):x.prepend(`<script setup>\\n${A}\\n${j}\\n<\\/script>\\n`)}return p&&p({dictionaryKey:w,filePath:t,content:{...S},locale:l}),{code:x.toString(),map:x.generateMap({source:t,includeContent:!0}),extracted:!0}},l=async(n,r,i,a,o=!0)=>{let s=await e(n,`utf-8`),l={},u=await c(s,n,{packageName:i,dictionaryKey:r,shouldExtract:a.shouldExtract,generateKey:a.generateKey,extractDictionaryKeyFromPath:a.extractDictionaryKeyFromPath,attributesToExtract:a.attributesToExtract,onExtract:e=>{l=e.content}});return u?(o&&await t(n,u.code),l):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O,EAAE,CAAC,EAAE,QAAQ,mBAAmB,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,GAAG,EAAE,CAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;AAkCA;;;;;;;;;AAmGA;;;;;;;;;AAaA;cAhHa,cAAA,GACX,aAAA,GAAgB,uBAAA,KACf,YAAA;;;;;;;;;;;cAiGU,QAAA,GAAQ,aAAA,GAlGH,uBAAA,KACf,YAAA;;;;;;;;;;;;;cA8GU,cAAA,GAAc,aAAA,GA/GT,uBAAA,KACf,YAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-intlayer",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Vite plugin for seamless internationalization (i18n), providing locale detection, redirection, and environment-based configuration",
|
|
6
6
|
"keywords": [
|
|
@@ -77,21 +77,21 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@babel/core": "7.29.0",
|
|
80
|
-
"@intlayer/babel": "8.2.
|
|
81
|
-
"@intlayer/chokidar": "8.2.
|
|
82
|
-
"@intlayer/config": "8.2.
|
|
83
|
-
"@intlayer/core": "8.2.
|
|
84
|
-
"@intlayer/dictionaries-entry": "8.2.
|
|
85
|
-
"@intlayer/types": "8.2.
|
|
86
|
-
"intlayer": "8.2.
|
|
80
|
+
"@intlayer/babel": "8.2.3",
|
|
81
|
+
"@intlayer/chokidar": "8.2.3",
|
|
82
|
+
"@intlayer/config": "8.2.3",
|
|
83
|
+
"@intlayer/core": "8.2.3",
|
|
84
|
+
"@intlayer/dictionaries-entry": "8.2.3",
|
|
85
|
+
"@intlayer/types": "8.2.3",
|
|
86
|
+
"intlayer": "8.2.3"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@types/node": "25.3.
|
|
89
|
+
"@types/node": "25.3.5",
|
|
90
90
|
"@utils/ts-config": "1.0.4",
|
|
91
91
|
"@utils/ts-config-types": "1.0.4",
|
|
92
92
|
"@utils/tsdown-config": "1.0.4",
|
|
93
93
|
"rimraf": "6.1.3",
|
|
94
|
-
"tsdown": "0.
|
|
94
|
+
"tsdown": "0.21.0",
|
|
95
95
|
"typescript": "5.9.3",
|
|
96
96
|
"vitest": "4.0.18"
|
|
97
97
|
},
|