@lingo.dev/_compiler 0.4.1 → 0.5.1
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/build/{chunk-OO4SG7IH.cjs → chunk-42EM6MWM.cjs} +62 -5
- package/build/{chunk-YT6JFNHK.mjs → chunk-XCIXY6J2.mjs} +61 -4
- package/build/index.cjs +37 -23
- package/build/index.mjs +19 -5
- package/build/lingo-turbopack-loader.cjs +3 -3
- package/build/lingo-turbopack-loader.mjs +1 -1
- package/package.json +4 -2
|
@@ -301,6 +301,15 @@ function getOpenRouterKeyFromRc() {
|
|
|
301
301
|
function getOpenRouterKeyFromEnv() {
|
|
302
302
|
return getKeyFromEnv("OPENROUTER_API_KEY");
|
|
303
303
|
}
|
|
304
|
+
function getMistralKey() {
|
|
305
|
+
return getMistralKeyFromEnv() || getMistralKeyFromRc();
|
|
306
|
+
}
|
|
307
|
+
function getMistralKeyFromRc() {
|
|
308
|
+
return getKeyFromRc("llm.mistralApiKey");
|
|
309
|
+
}
|
|
310
|
+
function getMistralKeyFromEnv() {
|
|
311
|
+
return getKeyFromEnv("MISTRAL_API_KEY");
|
|
312
|
+
}
|
|
304
313
|
|
|
305
314
|
// src/utils/env.ts
|
|
306
315
|
|
|
@@ -339,6 +348,13 @@ var providerDetails = {
|
|
|
339
348
|
// Ollama doesn't require an API key
|
|
340
349
|
getKeyLink: "https://ollama.com/download",
|
|
341
350
|
docsLink: "https://github.com/ollama/ollama/tree/main/docs"
|
|
351
|
+
},
|
|
352
|
+
mistral: {
|
|
353
|
+
name: "Mistral",
|
|
354
|
+
apiKeyEnvVar: "MISTRAL_API_KEY",
|
|
355
|
+
apiKeyConfigKey: "llm.mistralApiKey",
|
|
356
|
+
getKeyLink: "https://console.mistral.ai",
|
|
357
|
+
docsLink: "https://docs.mistral.ai"
|
|
342
358
|
}
|
|
343
359
|
};
|
|
344
360
|
|
|
@@ -775,6 +791,19 @@ function getJsxElementName(nodePath) {
|
|
|
775
791
|
if (t9.isJSXIdentifier(openingElement.name)) {
|
|
776
792
|
return openingElement.name.name;
|
|
777
793
|
}
|
|
794
|
+
if (t9.isJSXMemberExpression(openingElement.name)) {
|
|
795
|
+
const memberExpr = openingElement.name;
|
|
796
|
+
const parts = [];
|
|
797
|
+
let current = memberExpr;
|
|
798
|
+
while (t9.isJSXMemberExpression(current)) {
|
|
799
|
+
parts.unshift(current.property.name);
|
|
800
|
+
current = current.object;
|
|
801
|
+
}
|
|
802
|
+
if (t9.isJSXIdentifier(current)) {
|
|
803
|
+
parts.unshift(current.name);
|
|
804
|
+
}
|
|
805
|
+
return parts.join(".");
|
|
806
|
+
}
|
|
778
807
|
return null;
|
|
779
808
|
}
|
|
780
809
|
function getNestedJsxElements(nodePath) {
|
|
@@ -995,7 +1024,7 @@ var LCP = class _LCP {
|
|
|
995
1024
|
return { ...this.data, files };
|
|
996
1025
|
}
|
|
997
1026
|
toString() {
|
|
998
|
-
return JSON.stringify(this.toJSON(), null, 2);
|
|
1027
|
+
return JSON.stringify(this.toJSON(), null, 2) + "\n";
|
|
999
1028
|
}
|
|
1000
1029
|
save() {
|
|
1001
1030
|
const hasChanges = !fs4.existsSync(this.filePath) || fs4.readFileSync(this.filePath, "utf8") !== this.toString();
|
|
@@ -1704,6 +1733,7 @@ var _groq = require('@ai-sdk/groq');
|
|
|
1704
1733
|
var _google = require('@ai-sdk/google');
|
|
1705
1734
|
var _aisdkprovider = require('@openrouter/ai-sdk-provider');
|
|
1706
1735
|
var _ollamaaiprovider = require('ollama-ai-provider');
|
|
1736
|
+
var _mistral = require('@ai-sdk/mistral');
|
|
1707
1737
|
var _ai = require('ai');
|
|
1708
1738
|
var __sdk = require('@lingo.dev/_sdk');
|
|
1709
1739
|
|
|
@@ -2165,9 +2195,27 @@ var LCPAPI = class {
|
|
|
2165
2195
|
);
|
|
2166
2196
|
return _ollamaaiprovider.createOllama.call(void 0, )(modelId);
|
|
2167
2197
|
}
|
|
2198
|
+
case "mistral": {
|
|
2199
|
+
if (isRunningInCIOrDocker()) {
|
|
2200
|
+
const mistralFromEnv = getMistralKeyFromEnv();
|
|
2201
|
+
if (!mistralFromEnv) {
|
|
2202
|
+
this._failMissingLLMKeyCi(providerId);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
const mistralKey = getMistralKey();
|
|
2206
|
+
if (!mistralKey) {
|
|
2207
|
+
throw new Error(
|
|
2208
|
+
"\u26A0\uFE0F Mistral API key not found. Please set MISTRAL_API_KEY environment variable or configure it user-wide."
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
console.log(
|
|
2212
|
+
`Creating Mistral client for ${targetLocale} using model ${modelId}`
|
|
2213
|
+
);
|
|
2214
|
+
return _mistral.createMistral.call(void 0, { apiKey: mistralKey })(modelId);
|
|
2215
|
+
}
|
|
2168
2216
|
default: {
|
|
2169
2217
|
throw new Error(
|
|
2170
|
-
`\u26A0\uFE0F Provider "${providerId}" for locale "${targetLocale}" is not supported. Only "groq" and "
|
|
2218
|
+
`\u26A0\uFE0F Provider "${providerId}" for locale "${targetLocale}" is not supported. Only "groq", "google", "openrouter", "ollama", and "mistral" providers are supported at the moment.`
|
|
2171
2219
|
);
|
|
2172
2220
|
}
|
|
2173
2221
|
}
|
|
@@ -2573,9 +2621,16 @@ function parseParametrizedModuleId(rawId) {
|
|
|
2573
2621
|
|
|
2574
2622
|
// src/_loader-utils.ts
|
|
2575
2623
|
async function loadDictionary(options) {
|
|
2576
|
-
const {
|
|
2624
|
+
const {
|
|
2625
|
+
resourcePath,
|
|
2626
|
+
resourceQuery = "",
|
|
2627
|
+
params,
|
|
2628
|
+
sourceRoot,
|
|
2629
|
+
lingoDir,
|
|
2630
|
+
isDev
|
|
2631
|
+
} = options;
|
|
2577
2632
|
const fullResourcePath = `${resourcePath}${resourceQuery}`;
|
|
2578
|
-
if (!resourcePath.
|
|
2633
|
+
if (!resourcePath.match(LCP_DICTIONARY_FILE_NAME)) {
|
|
2579
2634
|
return null;
|
|
2580
2635
|
}
|
|
2581
2636
|
const moduleInfo = parseParametrizedModuleId(fullResourcePath);
|
|
@@ -2646,4 +2701,6 @@ function transformComponent(options) {
|
|
|
2646
2701
|
|
|
2647
2702
|
|
|
2648
2703
|
|
|
2649
|
-
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
exports.__require = __require; exports.defaultParams = defaultParams; exports.LCP_DICTIONARY_FILE_NAME = LCP_DICTIONARY_FILE_NAME; exports.LCPCache = LCPCache; exports.getInvalidLocales = getInvalidLocales; exports.getGroqKeyFromRc = getGroqKeyFromRc; exports.getGroqKeyFromEnv = getGroqKeyFromEnv; exports.getLingoDotDevKeyFromEnv = getLingoDotDevKeyFromEnv; exports.getLingoDotDevKeyFromRc = getLingoDotDevKeyFromRc; exports.getGoogleKeyFromRc = getGoogleKeyFromRc; exports.getGoogleKeyFromEnv = getGoogleKeyFromEnv; exports.getMistralKeyFromRc = getMistralKeyFromRc; exports.getMistralKeyFromEnv = getMistralKeyFromEnv; exports.isRunningInCIOrDocker = isRunningInCIOrDocker; exports.providerDetails = providerDetails; exports.loadDictionary = loadDictionary; exports.transformComponent = transformComponent;
|
|
@@ -301,6 +301,15 @@ function getOpenRouterKeyFromRc() {
|
|
|
301
301
|
function getOpenRouterKeyFromEnv() {
|
|
302
302
|
return getKeyFromEnv("OPENROUTER_API_KEY");
|
|
303
303
|
}
|
|
304
|
+
function getMistralKey() {
|
|
305
|
+
return getMistralKeyFromEnv() || getMistralKeyFromRc();
|
|
306
|
+
}
|
|
307
|
+
function getMistralKeyFromRc() {
|
|
308
|
+
return getKeyFromRc("llm.mistralApiKey");
|
|
309
|
+
}
|
|
310
|
+
function getMistralKeyFromEnv() {
|
|
311
|
+
return getKeyFromEnv("MISTRAL_API_KEY");
|
|
312
|
+
}
|
|
304
313
|
|
|
305
314
|
// src/utils/env.ts
|
|
306
315
|
import fs3 from "fs";
|
|
@@ -339,6 +348,13 @@ var providerDetails = {
|
|
|
339
348
|
// Ollama doesn't require an API key
|
|
340
349
|
getKeyLink: "https://ollama.com/download",
|
|
341
350
|
docsLink: "https://github.com/ollama/ollama/tree/main/docs"
|
|
351
|
+
},
|
|
352
|
+
mistral: {
|
|
353
|
+
name: "Mistral",
|
|
354
|
+
apiKeyEnvVar: "MISTRAL_API_KEY",
|
|
355
|
+
apiKeyConfigKey: "llm.mistralApiKey",
|
|
356
|
+
getKeyLink: "https://console.mistral.ai",
|
|
357
|
+
docsLink: "https://docs.mistral.ai"
|
|
342
358
|
}
|
|
343
359
|
};
|
|
344
360
|
|
|
@@ -775,6 +791,19 @@ function getJsxElementName(nodePath) {
|
|
|
775
791
|
if (t9.isJSXIdentifier(openingElement.name)) {
|
|
776
792
|
return openingElement.name.name;
|
|
777
793
|
}
|
|
794
|
+
if (t9.isJSXMemberExpression(openingElement.name)) {
|
|
795
|
+
const memberExpr = openingElement.name;
|
|
796
|
+
const parts = [];
|
|
797
|
+
let current = memberExpr;
|
|
798
|
+
while (t9.isJSXMemberExpression(current)) {
|
|
799
|
+
parts.unshift(current.property.name);
|
|
800
|
+
current = current.object;
|
|
801
|
+
}
|
|
802
|
+
if (t9.isJSXIdentifier(current)) {
|
|
803
|
+
parts.unshift(current.name);
|
|
804
|
+
}
|
|
805
|
+
return parts.join(".");
|
|
806
|
+
}
|
|
778
807
|
return null;
|
|
779
808
|
}
|
|
780
809
|
function getNestedJsxElements(nodePath) {
|
|
@@ -995,7 +1024,7 @@ var LCP = class _LCP {
|
|
|
995
1024
|
return { ...this.data, files };
|
|
996
1025
|
}
|
|
997
1026
|
toString() {
|
|
998
|
-
return JSON.stringify(this.toJSON(), null, 2);
|
|
1027
|
+
return JSON.stringify(this.toJSON(), null, 2) + "\n";
|
|
999
1028
|
}
|
|
1000
1029
|
save() {
|
|
1001
1030
|
const hasChanges = !fs4.existsSync(this.filePath) || fs4.readFileSync(this.filePath, "utf8") !== this.toString();
|
|
@@ -1704,6 +1733,7 @@ import { createGroq } from "@ai-sdk/groq";
|
|
|
1704
1733
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
1705
1734
|
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
|
1706
1735
|
import { createOllama } from "ollama-ai-provider";
|
|
1736
|
+
import { createMistral } from "@ai-sdk/mistral";
|
|
1707
1737
|
import { generateText } from "ai";
|
|
1708
1738
|
import { LingoDotDevEngine } from "@lingo.dev/_sdk";
|
|
1709
1739
|
import _9 from "lodash";
|
|
@@ -2165,9 +2195,27 @@ var LCPAPI = class {
|
|
|
2165
2195
|
);
|
|
2166
2196
|
return createOllama()(modelId);
|
|
2167
2197
|
}
|
|
2198
|
+
case "mistral": {
|
|
2199
|
+
if (isRunningInCIOrDocker()) {
|
|
2200
|
+
const mistralFromEnv = getMistralKeyFromEnv();
|
|
2201
|
+
if (!mistralFromEnv) {
|
|
2202
|
+
this._failMissingLLMKeyCi(providerId);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
const mistralKey = getMistralKey();
|
|
2206
|
+
if (!mistralKey) {
|
|
2207
|
+
throw new Error(
|
|
2208
|
+
"\u26A0\uFE0F Mistral API key not found. Please set MISTRAL_API_KEY environment variable or configure it user-wide."
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
console.log(
|
|
2212
|
+
`Creating Mistral client for ${targetLocale} using model ${modelId}`
|
|
2213
|
+
);
|
|
2214
|
+
return createMistral({ apiKey: mistralKey })(modelId);
|
|
2215
|
+
}
|
|
2168
2216
|
default: {
|
|
2169
2217
|
throw new Error(
|
|
2170
|
-
`\u26A0\uFE0F Provider "${providerId}" for locale "${targetLocale}" is not supported. Only "groq" and "
|
|
2218
|
+
`\u26A0\uFE0F Provider "${providerId}" for locale "${targetLocale}" is not supported. Only "groq", "google", "openrouter", "ollama", and "mistral" providers are supported at the moment.`
|
|
2171
2219
|
);
|
|
2172
2220
|
}
|
|
2173
2221
|
}
|
|
@@ -2573,9 +2621,16 @@ function parseParametrizedModuleId(rawId) {
|
|
|
2573
2621
|
|
|
2574
2622
|
// src/_loader-utils.ts
|
|
2575
2623
|
async function loadDictionary(options) {
|
|
2576
|
-
const {
|
|
2624
|
+
const {
|
|
2625
|
+
resourcePath,
|
|
2626
|
+
resourceQuery = "",
|
|
2627
|
+
params,
|
|
2628
|
+
sourceRoot,
|
|
2629
|
+
lingoDir,
|
|
2630
|
+
isDev
|
|
2631
|
+
} = options;
|
|
2577
2632
|
const fullResourcePath = `${resourcePath}${resourceQuery}`;
|
|
2578
|
-
if (!resourcePath.
|
|
2633
|
+
if (!resourcePath.match(LCP_DICTIONARY_FILE_NAME)) {
|
|
2579
2634
|
return null;
|
|
2580
2635
|
}
|
|
2581
2636
|
const moduleInfo = parseParametrizedModuleId(fullResourcePath);
|
|
@@ -2642,6 +2697,8 @@ export {
|
|
|
2642
2697
|
getLingoDotDevKeyFromRc,
|
|
2643
2698
|
getGoogleKeyFromRc,
|
|
2644
2699
|
getGoogleKeyFromEnv,
|
|
2700
|
+
getMistralKeyFromRc,
|
|
2701
|
+
getMistralKeyFromEnv,
|
|
2645
2702
|
isRunningInCIOrDocker,
|
|
2646
2703
|
providerDetails,
|
|
2647
2704
|
loadDictionary,
|
package/build/index.cjs
CHANGED
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunk42EM6MWMcjs = require('./chunk-42EM6MWM.cjs');
|
|
18
20
|
|
|
19
21
|
// src/index.ts
|
|
20
22
|
var _unplugin = require('unplugin');
|
|
@@ -22,7 +24,7 @@ var _unplugin = require('unplugin');
|
|
|
22
24
|
// package.json
|
|
23
25
|
var package_default = {
|
|
24
26
|
name: "@lingo.dev/_compiler",
|
|
25
|
-
version: "0.
|
|
27
|
+
version: "0.5.1",
|
|
26
28
|
description: "Lingo.dev Compiler",
|
|
27
29
|
private: false,
|
|
28
30
|
publishConfig: {
|
|
@@ -60,12 +62,14 @@ var package_default = {
|
|
|
60
62
|
dependencies: {
|
|
61
63
|
"@ai-sdk/google": "^1.2.19",
|
|
62
64
|
"@ai-sdk/groq": "^1.2.3",
|
|
65
|
+
"@ai-sdk/mistral": "^1.2.8",
|
|
63
66
|
"@babel/generator": "^7.26.5",
|
|
64
67
|
"@babel/parser": "^7.26.7",
|
|
65
68
|
"@babel/traverse": "^7.27.4",
|
|
66
69
|
"@babel/types": "^7.26.7",
|
|
67
70
|
"@lingo.dev/_sdk": "workspace:*",
|
|
68
71
|
"@openrouter/ai-sdk-provider": "^0.7.1",
|
|
72
|
+
"@prettier/sync": "^0.6.1",
|
|
69
73
|
ai: "^4.2.10",
|
|
70
74
|
dedent: "^1.6.0",
|
|
71
75
|
dotenv: "^16.4.5",
|
|
@@ -87,29 +91,33 @@ var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
|
87
91
|
var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
|
|
88
92
|
var keyCheckers = {
|
|
89
93
|
groq: {
|
|
90
|
-
checkEnv:
|
|
91
|
-
checkRc:
|
|
94
|
+
checkEnv: _chunk42EM6MWMcjs.getGroqKeyFromEnv,
|
|
95
|
+
checkRc: _chunk42EM6MWMcjs.getGroqKeyFromRc
|
|
92
96
|
},
|
|
93
97
|
google: {
|
|
94
|
-
checkEnv:
|
|
95
|
-
checkRc:
|
|
98
|
+
checkEnv: _chunk42EM6MWMcjs.getGoogleKeyFromEnv,
|
|
99
|
+
checkRc: _chunk42EM6MWMcjs.getGoogleKeyFromRc
|
|
100
|
+
},
|
|
101
|
+
mistral: {
|
|
102
|
+
checkEnv: _chunk42EM6MWMcjs.getMistralKeyFromEnv,
|
|
103
|
+
checkRc: _chunk42EM6MWMcjs.getMistralKeyFromRc
|
|
96
104
|
},
|
|
97
105
|
"lingo.dev": {
|
|
98
|
-
checkEnv:
|
|
99
|
-
checkRc:
|
|
106
|
+
checkEnv: _chunk42EM6MWMcjs.getLingoDotDevKeyFromEnv,
|
|
107
|
+
checkRc: _chunk42EM6MWMcjs.getLingoDotDevKeyFromRc
|
|
100
108
|
}
|
|
101
109
|
};
|
|
102
110
|
var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
103
111
|
(_params, _meta) => {
|
|
104
112
|
console.log("\u2139\uFE0F Starting Lingo.dev compiler...");
|
|
105
|
-
const params = _lodash2.default.defaults(_params,
|
|
106
|
-
if (!
|
|
113
|
+
const params = _lodash2.default.defaults(_params, _chunk42EM6MWMcjs.defaultParams);
|
|
114
|
+
if (!_chunk42EM6MWMcjs.isRunningInCIOrDocker.call(void 0, )) {
|
|
107
115
|
if (params.models === "lingo.dev") {
|
|
108
116
|
validateLLMKeyDetails(["lingo.dev"]);
|
|
109
117
|
} else {
|
|
110
118
|
const configuredProviders = getConfiguredProviders(params.models);
|
|
111
119
|
validateLLMKeyDetails(configuredProviders);
|
|
112
|
-
const invalidLocales =
|
|
120
|
+
const invalidLocales = _chunk42EM6MWMcjs.getInvalidLocales.call(void 0,
|
|
113
121
|
params.models,
|
|
114
122
|
params.sourceLocale,
|
|
115
123
|
params.targetLocales
|
|
@@ -117,7 +125,9 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
117
125
|
if (invalidLocales.length > 0) {
|
|
118
126
|
console.log(_dedent2.default`
|
|
119
127
|
\n
|
|
120
|
-
⚠️ Lingo.dev Localization Compiler requires LLM model setup for the following locales: ${invalidLocales.join(
|
|
128
|
+
⚠️ Lingo.dev Localization Compiler requires LLM model setup for the following locales: ${invalidLocales.join(
|
|
129
|
+
", "
|
|
130
|
+
)}.
|
|
121
131
|
|
|
122
132
|
⭐️ Next steps:
|
|
123
133
|
1. Refer to documentation for help: https://lingo.dev/compiler
|
|
@@ -130,16 +140,16 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
}
|
|
133
|
-
|
|
143
|
+
_chunk42EM6MWMcjs.LCPCache.ensureDictionaryFile({
|
|
134
144
|
sourceRoot: params.sourceRoot,
|
|
135
145
|
lingoDir: params.lingoDir
|
|
136
146
|
});
|
|
137
147
|
const isDev = "dev" in _meta ? !!_meta.dev : process.env.NODE_ENV !== "production";
|
|
138
148
|
return {
|
|
139
149
|
name: package_default.name,
|
|
140
|
-
loadInclude: (id) => !!id.match(
|
|
150
|
+
loadInclude: (id) => !!id.match(_chunk42EM6MWMcjs.LCP_DICTIONARY_FILE_NAME),
|
|
141
151
|
async load(id) {
|
|
142
|
-
const dictionary = await
|
|
152
|
+
const dictionary = await _chunk42EM6MWMcjs.loadDictionary.call(void 0, {
|
|
143
153
|
resourcePath: id,
|
|
144
154
|
resourceQuery: "",
|
|
145
155
|
params: {
|
|
@@ -164,7 +174,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
164
174
|
enforce: "pre",
|
|
165
175
|
transform(code, id) {
|
|
166
176
|
try {
|
|
167
|
-
const result =
|
|
177
|
+
const result = _chunk42EM6MWMcjs.transformComponent.call(void 0, {
|
|
168
178
|
code,
|
|
169
179
|
params,
|
|
170
180
|
resourcePath: id,
|
|
@@ -184,7 +194,7 @@ var src_default = {
|
|
|
184
194
|
next: (compilerParams) => (nextConfig = {}) => {
|
|
185
195
|
const mergedParams = _lodash2.default.merge(
|
|
186
196
|
{},
|
|
187
|
-
|
|
197
|
+
_chunk42EM6MWMcjs.defaultParams,
|
|
188
198
|
{
|
|
189
199
|
rsc: true,
|
|
190
200
|
turbopack: {
|
|
@@ -233,7 +243,7 @@ var src_default = {
|
|
|
233
243
|
turbopackConfigPath.rules ??= {};
|
|
234
244
|
const rules = turbopackConfigPath.rules;
|
|
235
245
|
const lingoGlob = `**/*.{ts,tsx,js,jsx}`;
|
|
236
|
-
const lingoLoaderPath =
|
|
246
|
+
const lingoLoaderPath = _chunk42EM6MWMcjs.__require.resolve("./lingo-turbopack-loader");
|
|
237
247
|
rules[lingoGlob] = {
|
|
238
248
|
loaders: [
|
|
239
249
|
{
|
|
@@ -247,14 +257,14 @@ var src_default = {
|
|
|
247
257
|
},
|
|
248
258
|
vite: (compilerParams) => (config) => {
|
|
249
259
|
config.plugins.unshift(
|
|
250
|
-
unplugin.vite(_lodash2.default.merge({},
|
|
260
|
+
unplugin.vite(_lodash2.default.merge({}, _chunk42EM6MWMcjs.defaultParams, { rsc: false }, compilerParams))
|
|
251
261
|
);
|
|
252
262
|
return config;
|
|
253
263
|
}
|
|
254
264
|
};
|
|
255
265
|
function getConfiguredProviders(models) {
|
|
256
266
|
return _lodash2.default.chain(Object.values(models)).map((modelString) => modelString.split(":")[0]).filter(Boolean).uniq().filter(
|
|
257
|
-
(providerId) =>
|
|
267
|
+
(providerId) => _chunk42EM6MWMcjs.providerDetails.hasOwnProperty(providerId) && keyCheckers.hasOwnProperty(providerId)
|
|
258
268
|
).value();
|
|
259
269
|
}
|
|
260
270
|
function validateLLMKeyDetails(configuredProviders) {
|
|
@@ -265,7 +275,7 @@ function validateLLMKeyDetails(configuredProviders) {
|
|
|
265
275
|
const missingProviders = [];
|
|
266
276
|
const foundProviders = [];
|
|
267
277
|
for (const providerId of configuredProviders) {
|
|
268
|
-
const details =
|
|
278
|
+
const details = _chunk42EM6MWMcjs.providerDetails[providerId];
|
|
269
279
|
const checkers = keyCheckers[providerId];
|
|
270
280
|
if (!details || !checkers) continue;
|
|
271
281
|
const foundInEnv = !!checkers.checkEnv();
|
|
@@ -280,7 +290,9 @@ function validateLLMKeyDetails(configuredProviders) {
|
|
|
280
290
|
if (missingProviders.length > 0) {
|
|
281
291
|
console.log(_dedent2.default`
|
|
282
292
|
\n
|
|
283
|
-
💡 Lingo.dev Localization Compiler is configured to use the following LLM provider(s): ${configuredProviders.join(
|
|
293
|
+
💡 Lingo.dev Localization Compiler is configured to use the following LLM provider(s): ${configuredProviders.join(
|
|
294
|
+
", "
|
|
295
|
+
)}.
|
|
284
296
|
|
|
285
297
|
The compiler requires API keys for these providers to work, but the following keys are missing:
|
|
286
298
|
`);
|
|
@@ -311,7 +323,9 @@ function validateLLMKeyDetails(configuredProviders) {
|
|
|
311
323
|
} else if (foundProviders.length > 0) {
|
|
312
324
|
console.log(_dedent2.default`
|
|
313
325
|
\n
|
|
314
|
-
🔑 LLM API keys detected for configured providers: ${foundProviders.join(
|
|
326
|
+
🔑 LLM API keys detected for configured providers: ${foundProviders.join(
|
|
327
|
+
", "
|
|
328
|
+
)}.
|
|
315
329
|
`);
|
|
316
330
|
for (const providerId of foundProviders) {
|
|
317
331
|
const status = keyStatuses[providerId];
|
package/build/index.mjs
CHANGED
|
@@ -10,11 +10,13 @@ import {
|
|
|
10
10
|
getInvalidLocales,
|
|
11
11
|
getLingoDotDevKeyFromEnv,
|
|
12
12
|
getLingoDotDevKeyFromRc,
|
|
13
|
+
getMistralKeyFromEnv,
|
|
14
|
+
getMistralKeyFromRc,
|
|
13
15
|
isRunningInCIOrDocker,
|
|
14
16
|
loadDictionary,
|
|
15
17
|
providerDetails,
|
|
16
18
|
transformComponent
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-XCIXY6J2.mjs";
|
|
18
20
|
|
|
19
21
|
// src/index.ts
|
|
20
22
|
import { createUnplugin } from "unplugin";
|
|
@@ -22,7 +24,7 @@ import { createUnplugin } from "unplugin";
|
|
|
22
24
|
// package.json
|
|
23
25
|
var package_default = {
|
|
24
26
|
name: "@lingo.dev/_compiler",
|
|
25
|
-
version: "0.
|
|
27
|
+
version: "0.5.1",
|
|
26
28
|
description: "Lingo.dev Compiler",
|
|
27
29
|
private: false,
|
|
28
30
|
publishConfig: {
|
|
@@ -60,12 +62,14 @@ var package_default = {
|
|
|
60
62
|
dependencies: {
|
|
61
63
|
"@ai-sdk/google": "^1.2.19",
|
|
62
64
|
"@ai-sdk/groq": "^1.2.3",
|
|
65
|
+
"@ai-sdk/mistral": "^1.2.8",
|
|
63
66
|
"@babel/generator": "^7.26.5",
|
|
64
67
|
"@babel/parser": "^7.26.7",
|
|
65
68
|
"@babel/traverse": "^7.27.4",
|
|
66
69
|
"@babel/types": "^7.26.7",
|
|
67
70
|
"@lingo.dev/_sdk": "workspace:*",
|
|
68
71
|
"@openrouter/ai-sdk-provider": "^0.7.1",
|
|
72
|
+
"@prettier/sync": "^0.6.1",
|
|
69
73
|
ai: "^4.2.10",
|
|
70
74
|
dedent: "^1.6.0",
|
|
71
75
|
dotenv: "^16.4.5",
|
|
@@ -94,6 +98,10 @@ var keyCheckers = {
|
|
|
94
98
|
checkEnv: getGoogleKeyFromEnv,
|
|
95
99
|
checkRc: getGoogleKeyFromRc
|
|
96
100
|
},
|
|
101
|
+
mistral: {
|
|
102
|
+
checkEnv: getMistralKeyFromEnv,
|
|
103
|
+
checkRc: getMistralKeyFromRc
|
|
104
|
+
},
|
|
97
105
|
"lingo.dev": {
|
|
98
106
|
checkEnv: getLingoDotDevKeyFromEnv,
|
|
99
107
|
checkRc: getLingoDotDevKeyFromRc
|
|
@@ -117,7 +125,9 @@ var unplugin = createUnplugin(
|
|
|
117
125
|
if (invalidLocales.length > 0) {
|
|
118
126
|
console.log(dedent`
|
|
119
127
|
\n
|
|
120
|
-
⚠️ Lingo.dev Localization Compiler requires LLM model setup for the following locales: ${invalidLocales.join(
|
|
128
|
+
⚠️ Lingo.dev Localization Compiler requires LLM model setup for the following locales: ${invalidLocales.join(
|
|
129
|
+
", "
|
|
130
|
+
)}.
|
|
121
131
|
|
|
122
132
|
⭐️ Next steps:
|
|
123
133
|
1. Refer to documentation for help: https://lingo.dev/compiler
|
|
@@ -280,7 +290,9 @@ function validateLLMKeyDetails(configuredProviders) {
|
|
|
280
290
|
if (missingProviders.length > 0) {
|
|
281
291
|
console.log(dedent`
|
|
282
292
|
\n
|
|
283
|
-
💡 Lingo.dev Localization Compiler is configured to use the following LLM provider(s): ${configuredProviders.join(
|
|
293
|
+
💡 Lingo.dev Localization Compiler is configured to use the following LLM provider(s): ${configuredProviders.join(
|
|
294
|
+
", "
|
|
295
|
+
)}.
|
|
284
296
|
|
|
285
297
|
The compiler requires API keys for these providers to work, but the following keys are missing:
|
|
286
298
|
`);
|
|
@@ -311,7 +323,9 @@ function validateLLMKeyDetails(configuredProviders) {
|
|
|
311
323
|
} else if (foundProviders.length > 0) {
|
|
312
324
|
console.log(dedent`
|
|
313
325
|
\n
|
|
314
|
-
🔑 LLM API keys detected for configured providers: ${foundProviders.join(
|
|
326
|
+
🔑 LLM API keys detected for configured providers: ${foundProviders.join(
|
|
327
|
+
", "
|
|
328
|
+
)}.
|
|
315
329
|
`);
|
|
316
330
|
for (const providerId of foundProviders) {
|
|
317
331
|
const status = keyStatuses[providerId];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk42EM6MWMcjs = require('./chunk-42EM6MWM.cjs');
|
|
5
5
|
|
|
6
6
|
// src/lingo-turbopack-loader.ts
|
|
7
7
|
async function lingo_turbopack_loader_default(source) {
|
|
@@ -9,7 +9,7 @@ async function lingo_turbopack_loader_default(source) {
|
|
|
9
9
|
const params = this.getOptions();
|
|
10
10
|
const isDev = process.env.NODE_ENV !== "production";
|
|
11
11
|
try {
|
|
12
|
-
const dictionary = await
|
|
12
|
+
const dictionary = await _chunk42EM6MWMcjs.loadDictionary.call(void 0, {
|
|
13
13
|
resourcePath: this.resourcePath,
|
|
14
14
|
resourceQuery: this.resourceQuery,
|
|
15
15
|
params,
|
|
@@ -21,7 +21,7 @@ async function lingo_turbopack_loader_default(source) {
|
|
|
21
21
|
const code = `export default ${JSON.stringify(dictionary, null, 2)};`;
|
|
22
22
|
return callback(null, code);
|
|
23
23
|
}
|
|
24
|
-
const result =
|
|
24
|
+
const result = _chunk42EM6MWMcjs.transformComponent.call(void 0, {
|
|
25
25
|
code: source,
|
|
26
26
|
params,
|
|
27
27
|
resourcePath: this.resourcePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingo.dev/_compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Lingo.dev Compiler",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,11 +31,13 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@ai-sdk/google": "^1.2.19",
|
|
33
33
|
"@ai-sdk/groq": "^1.2.3",
|
|
34
|
+
"@ai-sdk/mistral": "^1.2.8",
|
|
34
35
|
"@babel/generator": "^7.26.5",
|
|
35
36
|
"@babel/parser": "^7.26.7",
|
|
36
37
|
"@babel/traverse": "^7.27.4",
|
|
37
38
|
"@babel/types": "^7.26.7",
|
|
38
39
|
"@openrouter/ai-sdk-provider": "^0.7.1",
|
|
40
|
+
"@prettier/sync": "^0.6.1",
|
|
39
41
|
"ai": "^4.2.10",
|
|
40
42
|
"dedent": "^1.6.0",
|
|
41
43
|
"dotenv": "^16.4.5",
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"unplugin": "^2.1.2",
|
|
49
51
|
"vitest": "^2.1.4",
|
|
50
52
|
"zod": "^3.24.1",
|
|
51
|
-
"@lingo.dev/_sdk": "0.9.
|
|
53
|
+
"@lingo.dev/_sdk": "0.9.4"
|
|
52
54
|
},
|
|
53
55
|
"scripts": {
|
|
54
56
|
"dev": "tsup --watch",
|