@lingo.dev/_compiler 0.1.12 → 0.1.13
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/index.cjs +53 -8
- package/build/index.mjs +53 -8
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var _unplugin = require('unplugin');
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@lingo.dev/_compiler",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.13",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -449,6 +449,9 @@ function getJsxScopes(node) {
|
|
|
449
449
|
const result = [];
|
|
450
450
|
_traverse2.default.call(void 0, node, {
|
|
451
451
|
JSXElement(path6) {
|
|
452
|
+
if (getJsxElementName(path6) === "LingoProvider") {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
452
455
|
const hasNonEmptyTextSiblings = path6.getAllPrevSiblings().concat(path6.getAllNextSiblings()).some(
|
|
453
456
|
(sibling) => t7.isJSXText(sibling.node) && _optionalChain([sibling, 'access', _16 => _16.node, 'access', _17 => _17.value, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]) !== ""
|
|
454
457
|
);
|
|
@@ -1264,13 +1267,11 @@ var LCPAPI = class {
|
|
|
1264
1267
|
sourceLocale,
|
|
1265
1268
|
targetLocale
|
|
1266
1269
|
);
|
|
1267
|
-
} catch (
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
files: {}
|
|
1273
|
-
};
|
|
1270
|
+
} catch (error) {
|
|
1271
|
+
this._failGroqFailureLocal(
|
|
1272
|
+
targetLocale,
|
|
1273
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
1274
|
+
);
|
|
1274
1275
|
}
|
|
1275
1276
|
if (isRunningInCIOrDocker()) {
|
|
1276
1277
|
const groqFromEnv = getGroqKeyFromEnv();
|
|
@@ -1365,6 +1366,50 @@ var LCPAPI = class {
|
|
|
1365
1366
|
);
|
|
1366
1367
|
process.exit(1);
|
|
1367
1368
|
}
|
|
1369
|
+
static _failGroqFailureLocal(targetLocale, errorMessage) {
|
|
1370
|
+
const isInvalidApiKey = errorMessage.match("Invalid API Key");
|
|
1371
|
+
if (isInvalidApiKey) {
|
|
1372
|
+
console.log(_dedent2.default`
|
|
1373
|
+
\n
|
|
1374
|
+
⚠️ Lingo.dev Compiler requires a valid Groq API key to translate your application.
|
|
1375
|
+
|
|
1376
|
+
It looks like you set Groq API key but it is not valid. Please check your API key and try again.
|
|
1377
|
+
|
|
1378
|
+
Error details from Groq API: ${errorMessage}
|
|
1379
|
+
|
|
1380
|
+
👉 You can set the API key in one of the following ways:
|
|
1381
|
+
1. User-wide: Run npx lingo.dev@latest config set llm.groqApiKey <your-api-key>
|
|
1382
|
+
2. Project-wide: Add GROQ_API_KEY=<your-api-key> to .env file in every project that uses Lingo.dev Localization Compiler
|
|
1383
|
+
3. Session-wide: Run export GROQ_API_KEY=<your-api-key> in your terminal before running the compiler to set the API key for the current session
|
|
1384
|
+
|
|
1385
|
+
⭐️ Also:
|
|
1386
|
+
1. If you don't yet have a GROQ API key, get one for free at https://groq.com
|
|
1387
|
+
2. If you want to use a different LLM, raise an issue in our open-source repo: https://lingo.dev/go/gh
|
|
1388
|
+
3. If you have questions, feature requests, or would like to contribute, join our Discord: https://lingo.dev/go/discord
|
|
1389
|
+
|
|
1390
|
+
✨
|
|
1391
|
+
`);
|
|
1392
|
+
} else {
|
|
1393
|
+
console.log(
|
|
1394
|
+
_dedent2.default`
|
|
1395
|
+
\n
|
|
1396
|
+
⚠️ Lingo.dev Compiler tried to translate your application to "${targetLocale}" locale via Groq but it failed.
|
|
1397
|
+
|
|
1398
|
+
Error details from Groq API: ${errorMessage}
|
|
1399
|
+
|
|
1400
|
+
This error comes from Groq API, please check their documentation for more details: https://console.groq.com/docs/errors
|
|
1401
|
+
|
|
1402
|
+
⭐️ Also:
|
|
1403
|
+
1. Did you set GROQ_API_KEY environment variable?
|
|
1404
|
+
2. Did you reach any limits of your Groq account?
|
|
1405
|
+
3. If you have questions, feature requests, or would like to contribute, join our Discord: https://lingo.dev/go/discord
|
|
1406
|
+
|
|
1407
|
+
✨
|
|
1408
|
+
`
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
process.exit(1);
|
|
1412
|
+
}
|
|
1368
1413
|
};
|
|
1369
1414
|
|
|
1370
1415
|
// src/lib/lcp/server.ts
|
package/build/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createUnplugin } from "unplugin";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@lingo.dev/_compiler",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.13",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -449,6 +449,9 @@ function getJsxScopes(node) {
|
|
|
449
449
|
const result = [];
|
|
450
450
|
traverse4(node, {
|
|
451
451
|
JSXElement(path6) {
|
|
452
|
+
if (getJsxElementName(path6) === "LingoProvider") {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
452
455
|
const hasNonEmptyTextSiblings = path6.getAllPrevSiblings().concat(path6.getAllNextSiblings()).some(
|
|
453
456
|
(sibling) => t7.isJSXText(sibling.node) && sibling.node.value?.trim() !== ""
|
|
454
457
|
);
|
|
@@ -1264,13 +1267,11 @@ var LCPAPI = class {
|
|
|
1264
1267
|
sourceLocale,
|
|
1265
1268
|
targetLocale
|
|
1266
1269
|
);
|
|
1267
|
-
} catch (
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
files: {}
|
|
1273
|
-
};
|
|
1270
|
+
} catch (error) {
|
|
1271
|
+
this._failGroqFailureLocal(
|
|
1272
|
+
targetLocale,
|
|
1273
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
1274
|
+
);
|
|
1274
1275
|
}
|
|
1275
1276
|
if (isRunningInCIOrDocker()) {
|
|
1276
1277
|
const groqFromEnv = getGroqKeyFromEnv();
|
|
@@ -1365,6 +1366,50 @@ var LCPAPI = class {
|
|
|
1365
1366
|
);
|
|
1366
1367
|
process.exit(1);
|
|
1367
1368
|
}
|
|
1369
|
+
static _failGroqFailureLocal(targetLocale, errorMessage) {
|
|
1370
|
+
const isInvalidApiKey = errorMessage.match("Invalid API Key");
|
|
1371
|
+
if (isInvalidApiKey) {
|
|
1372
|
+
console.log(dedent2`
|
|
1373
|
+
\n
|
|
1374
|
+
⚠️ Lingo.dev Compiler requires a valid Groq API key to translate your application.
|
|
1375
|
+
|
|
1376
|
+
It looks like you set Groq API key but it is not valid. Please check your API key and try again.
|
|
1377
|
+
|
|
1378
|
+
Error details from Groq API: ${errorMessage}
|
|
1379
|
+
|
|
1380
|
+
👉 You can set the API key in one of the following ways:
|
|
1381
|
+
1. User-wide: Run npx lingo.dev@latest config set llm.groqApiKey <your-api-key>
|
|
1382
|
+
2. Project-wide: Add GROQ_API_KEY=<your-api-key> to .env file in every project that uses Lingo.dev Localization Compiler
|
|
1383
|
+
3. Session-wide: Run export GROQ_API_KEY=<your-api-key> in your terminal before running the compiler to set the API key for the current session
|
|
1384
|
+
|
|
1385
|
+
⭐️ Also:
|
|
1386
|
+
1. If you don't yet have a GROQ API key, get one for free at https://groq.com
|
|
1387
|
+
2. If you want to use a different LLM, raise an issue in our open-source repo: https://lingo.dev/go/gh
|
|
1388
|
+
3. If you have questions, feature requests, or would like to contribute, join our Discord: https://lingo.dev/go/discord
|
|
1389
|
+
|
|
1390
|
+
✨
|
|
1391
|
+
`);
|
|
1392
|
+
} else {
|
|
1393
|
+
console.log(
|
|
1394
|
+
dedent2`
|
|
1395
|
+
\n
|
|
1396
|
+
⚠️ Lingo.dev Compiler tried to translate your application to "${targetLocale}" locale via Groq but it failed.
|
|
1397
|
+
|
|
1398
|
+
Error details from Groq API: ${errorMessage}
|
|
1399
|
+
|
|
1400
|
+
This error comes from Groq API, please check their documentation for more details: https://console.groq.com/docs/errors
|
|
1401
|
+
|
|
1402
|
+
⭐️ Also:
|
|
1403
|
+
1. Did you set GROQ_API_KEY environment variable?
|
|
1404
|
+
2. Did you reach any limits of your Groq account?
|
|
1405
|
+
3. If you have questions, feature requests, or would like to contribute, join our Discord: https://lingo.dev/go/discord
|
|
1406
|
+
|
|
1407
|
+
✨
|
|
1408
|
+
`
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
process.exit(1);
|
|
1412
|
+
}
|
|
1368
1413
|
};
|
|
1369
1414
|
|
|
1370
1415
|
// src/lib/lcp/server.ts
|