@lingo.dev/_compiler 0.1.8 → 0.1.10
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 +27 -15
- package/build/index.mjs +27 -15
- 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.10",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -615,6 +615,7 @@ function parseParametrizedModuleId(rawId) {
|
|
|
615
615
|
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs); var fs2 = _interopRequireWildcard(_fs);
|
|
616
616
|
|
|
617
617
|
|
|
618
|
+
|
|
618
619
|
var LCP_FILE_NAME = "meta.json";
|
|
619
620
|
var LCP = class _LCP {
|
|
620
621
|
constructor(filePath, data = {
|
|
@@ -719,8 +720,21 @@ var LCP = class _LCP {
|
|
|
719
720
|
const dir = path.dirname(this.filePath);
|
|
720
721
|
const filePath = path.resolve(dir, LCP_DICTIONARY_FILE_NAME);
|
|
721
722
|
if (fs.existsSync(filePath)) {
|
|
722
|
-
|
|
723
|
-
|
|
723
|
+
try {
|
|
724
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
725
|
+
fs.utimesSync(filePath, now, now);
|
|
726
|
+
} catch (error) {
|
|
727
|
+
if (_optionalChain([error, 'optionalAccess', _27 => _27.code]) === "EINVAL") {
|
|
728
|
+
console.warn(
|
|
729
|
+
_dedent2.default`
|
|
730
|
+
⚠️ Lingo: Auto-reload disabled - system blocks Node.js timestamp updates.
|
|
731
|
+
💡 Fix: Adjust security settings to allow Node.js file modifications.
|
|
732
|
+
⚡ Workaround: Manually refresh browser after translation changes.
|
|
733
|
+
💬 Need help? Join our Discord: https://lingo.dev/go/discord.
|
|
734
|
+
`
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
724
738
|
}
|
|
725
739
|
}
|
|
726
740
|
_setScopeField(fileKey, scopeKey, field, value) {
|
|
@@ -831,7 +845,7 @@ var LCPCache = class {
|
|
|
831
845
|
const config2 = await prettier.resolveConfig(cachePath);
|
|
832
846
|
const prettierOptions = {
|
|
833
847
|
..._nullishCoalesce(config2, () => ( {})),
|
|
834
|
-
parser: _optionalChain([config2, 'optionalAccess',
|
|
848
|
+
parser: _optionalChain([config2, 'optionalAccess', _28 => _28.parser]) ? config2.parser : "typescript"
|
|
835
849
|
};
|
|
836
850
|
return await prettier.format(cachedContent, prettierOptions);
|
|
837
851
|
} catch (error) {
|
|
@@ -895,7 +909,7 @@ function getLocaleModel(localeModels, sourceLocale, targetLocale) {
|
|
|
895
909
|
];
|
|
896
910
|
const modelKey = localeKeys.find((key) => localeModels.hasOwnProperty(key));
|
|
897
911
|
if (modelKey) {
|
|
898
|
-
const [provider, model] = _optionalChain([localeModels, 'access',
|
|
912
|
+
const [provider, model] = _optionalChain([localeModels, 'access', _29 => _29[modelKey], 'optionalAccess', _30 => _30.split, 'call', _31 => _31(":")]);
|
|
899
913
|
if (provider && model) {
|
|
900
914
|
return { provider, model };
|
|
901
915
|
}
|
|
@@ -908,7 +922,7 @@ var prompt_default = (args) => {
|
|
|
908
922
|
return getUserSystemPrompt(args) || getBuiltInSystemPrompt(args);
|
|
909
923
|
};
|
|
910
924
|
function getUserSystemPrompt(args) {
|
|
911
|
-
const userPrompt = _optionalChain([args, 'access',
|
|
925
|
+
const userPrompt = _optionalChain([args, 'access', _32 => _32.prompt, 'optionalAccess', _33 => _33.trim, 'call', _34 => _34(), 'optionalAccess', _35 => _35.replace, 'call', _36 => _36("{SOURCE_LOCALE}", args.sourceLocale), 'optionalAccess', _37 => _37.replace, 'call', _38 => _38("{TARGET_LOCALE}", args.targetLocale)]);
|
|
912
926
|
if (userPrompt) {
|
|
913
927
|
console.log("\u2728 Compiler is using user-defined prompt.");
|
|
914
928
|
return userPrompt;
|
|
@@ -1514,14 +1528,14 @@ var LCPServer = (_class = class {
|
|
|
1514
1528
|
const sourceFile = _lodash2.default.get(sourceDictionary.files, fileName);
|
|
1515
1529
|
const targetFile = _lodash2.default.get(targetDictionary.files, fileName);
|
|
1516
1530
|
const entries = removeEmptyEntries ? _lodash2.default.pickBy(
|
|
1517
|
-
_optionalChain([sourceFile, 'optionalAccess',
|
|
1518
|
-
(value) => _optionalChain([String, 'call',
|
|
1519
|
-
) : _optionalChain([sourceFile, 'optionalAccess',
|
|
1531
|
+
_optionalChain([sourceFile, 'optionalAccess', _39 => _39.entries]) || {},
|
|
1532
|
+
(value) => _optionalChain([String, 'call', _40 => _40(value || ""), 'optionalAccess', _41 => _41.trim, 'optionalCall', _42 => _42(), 'optionalAccess', _43 => _43.length]) > 0
|
|
1533
|
+
) : _optionalChain([sourceFile, 'optionalAccess', _44 => _44.entries]) || {};
|
|
1520
1534
|
return [
|
|
1521
1535
|
fileName,
|
|
1522
1536
|
{
|
|
1523
1537
|
...targetFile,
|
|
1524
|
-
entries: _lodash2.default.merge(_optionalChain([targetFile, 'optionalAccess',
|
|
1538
|
+
entries: _lodash2.default.merge(_optionalChain([targetFile, 'optionalAccess', _45 => _45.entries]) || {}, entries)
|
|
1525
1539
|
}
|
|
1526
1540
|
];
|
|
1527
1541
|
}).fromPairs().value();
|
|
@@ -1713,7 +1727,7 @@ function jsxFragmentMutation(payload) {
|
|
|
1713
1727
|
var jsxHtmlLangMutation = createCodeMutation((payload) => {
|
|
1714
1728
|
_traverse2.default.call(void 0, payload.ast, {
|
|
1715
1729
|
JSXElement: (path6) => {
|
|
1716
|
-
if (_optionalChain([getJsxElementName, 'call',
|
|
1730
|
+
if (_optionalChain([getJsxElementName, 'call', _46 => _46(path6), 'optionalAccess', _47 => _47.toLowerCase, 'call', _48 => _48()]) === "html") {
|
|
1717
1731
|
const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
|
|
1718
1732
|
const packagePath = mode === "client" ? "lingo.dev/react/client" /* ReactClient */ : "lingo.dev/react/rsc" /* ReactRSC */;
|
|
1719
1733
|
const lingoHtmlComponentImport = getOrCreateImport(payload.ast, {
|
|
@@ -2356,10 +2370,8 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
2356
2370
|
const result = _lodash2.default.chain({
|
|
2357
2371
|
code,
|
|
2358
2372
|
params,
|
|
2359
|
-
fileKey: path.default.relative(
|
|
2360
|
-
|
|
2361
|
-
id
|
|
2362
|
-
)
|
|
2373
|
+
fileKey: path.default.relative(path.default.resolve(process.cwd(), params.sourceRoot), id).split(path.default.sep).join("/")
|
|
2374
|
+
// Always normalize for consistent dictionaries
|
|
2363
2375
|
}).thru(createPayload).thru(
|
|
2364
2376
|
composeMutations(
|
|
2365
2377
|
i18n_directive_default,
|
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.10",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -61,7 +61,7 @@ var package_default = {
|
|
|
61
61
|
|
|
62
62
|
// src/index.ts
|
|
63
63
|
import _11 from "lodash";
|
|
64
|
-
import
|
|
64
|
+
import dedent3 from "dedent";
|
|
65
65
|
|
|
66
66
|
// src/_base.ts
|
|
67
67
|
import generate from "@babel/generator";
|
|
@@ -615,6 +615,7 @@ function parseParametrizedModuleId(rawId) {
|
|
|
615
615
|
import * as fs from "fs";
|
|
616
616
|
import _2 from "lodash";
|
|
617
617
|
import * as path from "path";
|
|
618
|
+
import dedent from "dedent";
|
|
618
619
|
var LCP_FILE_NAME = "meta.json";
|
|
619
620
|
var LCP = class _LCP {
|
|
620
621
|
constructor(filePath, data = {
|
|
@@ -719,8 +720,21 @@ var LCP = class _LCP {
|
|
|
719
720
|
const dir = path.dirname(this.filePath);
|
|
720
721
|
const filePath = path.resolve(dir, LCP_DICTIONARY_FILE_NAME);
|
|
721
722
|
if (fs.existsSync(filePath)) {
|
|
722
|
-
|
|
723
|
-
|
|
723
|
+
try {
|
|
724
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
725
|
+
fs.utimesSync(filePath, now, now);
|
|
726
|
+
} catch (error) {
|
|
727
|
+
if (error?.code === "EINVAL") {
|
|
728
|
+
console.warn(
|
|
729
|
+
dedent`
|
|
730
|
+
⚠️ Lingo: Auto-reload disabled - system blocks Node.js timestamp updates.
|
|
731
|
+
💡 Fix: Adjust security settings to allow Node.js file modifications.
|
|
732
|
+
⚡ Workaround: Manually refresh browser after translation changes.
|
|
733
|
+
💬 Need help? Join our Discord: https://lingo.dev/go/discord.
|
|
734
|
+
`
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
724
738
|
}
|
|
725
739
|
}
|
|
726
740
|
_setScopeField(fileKey, scopeKey, field, value) {
|
|
@@ -1121,7 +1135,7 @@ function getGroqKeyFromEnv() {
|
|
|
1121
1135
|
}
|
|
1122
1136
|
|
|
1123
1137
|
// src/lib/lcp/api/index.ts
|
|
1124
|
-
import
|
|
1138
|
+
import dedent2 from "dedent";
|
|
1125
1139
|
|
|
1126
1140
|
// src/utils/env.ts
|
|
1127
1141
|
import fs4 from "fs";
|
|
@@ -1299,7 +1313,7 @@ var LCPAPI = class {
|
|
|
1299
1313
|
*/
|
|
1300
1314
|
static _failMissingGroqKeyCi() {
|
|
1301
1315
|
console.log(
|
|
1302
|
-
|
|
1316
|
+
dedent2`
|
|
1303
1317
|
\n
|
|
1304
1318
|
💡 You're using Lingo.dev Localization Compiler, and it detected unlocalized components in your app.
|
|
1305
1319
|
|
|
@@ -2308,7 +2322,7 @@ var unplugin = createUnplugin(
|
|
|
2308
2322
|
params.targetLocales
|
|
2309
2323
|
);
|
|
2310
2324
|
if (invalidLocales.length > 0) {
|
|
2311
|
-
console.log(
|
|
2325
|
+
console.log(dedent3`
|
|
2312
2326
|
\n
|
|
2313
2327
|
⚠️ Lingo.dev Localization Compiler requires LLM model setup for the following locales: ${invalidLocales.join(", ")}.
|
|
2314
2328
|
|
|
@@ -2356,10 +2370,8 @@ var unplugin = createUnplugin(
|
|
|
2356
2370
|
const result = _11.chain({
|
|
2357
2371
|
code,
|
|
2358
2372
|
params,
|
|
2359
|
-
fileKey: path5.relative(
|
|
2360
|
-
|
|
2361
|
-
id
|
|
2362
|
-
)
|
|
2373
|
+
fileKey: path5.relative(path5.resolve(process.cwd(), params.sourceRoot), id).split(path5.sep).join("/")
|
|
2374
|
+
// Always normalize for consistent dictionaries
|
|
2363
2375
|
}).thru(createPayload).thru(
|
|
2364
2376
|
composeMutations(
|
|
2365
2377
|
i18n_directive_default,
|
|
@@ -2421,7 +2433,7 @@ function validateGroqKeyDetails() {
|
|
|
2421
2433
|
fromRc: getGroqKeyFromRc()
|
|
2422
2434
|
};
|
|
2423
2435
|
if (!groq.fromEnv && !groq.fromRc) {
|
|
2424
|
-
console.log(
|
|
2436
|
+
console.log(dedent3`
|
|
2425
2437
|
\n
|
|
2426
2438
|
💡 You're using Lingo.dev Localization Compiler in your project, which requires a GROQ API key to work.
|
|
2427
2439
|
|
|
@@ -2440,7 +2452,7 @@ function validateGroqKeyDetails() {
|
|
|
2440
2452
|
process.exit(1);
|
|
2441
2453
|
} else if (groq.fromEnv && groq.fromRc) {
|
|
2442
2454
|
console.log(
|
|
2443
|
-
|
|
2455
|
+
dedent3`
|
|
2444
2456
|
🔑 GROQ API key detected in both environment variables and your user-wide configuration.
|
|
2445
2457
|
|
|
2446
2458
|
👉 The compiler will use the key from the environment because it has higher priority.
|
|
@@ -2452,7 +2464,7 @@ function validateGroqKeyDetails() {
|
|
|
2452
2464
|
);
|
|
2453
2465
|
} else if (groq.fromEnv && !groq.fromRc) {
|
|
2454
2466
|
console.log(
|
|
2455
|
-
|
|
2467
|
+
dedent3`
|
|
2456
2468
|
🔑 GROQ API key loaded from environment variables.
|
|
2457
2469
|
|
|
2458
2470
|
• You can also save the key user-wide with: npx lingo.dev@latest config set llm.groqApiKey <your-api-key>
|
|
@@ -2461,7 +2473,7 @@ function validateGroqKeyDetails() {
|
|
|
2461
2473
|
);
|
|
2462
2474
|
} else if (!groq.fromEnv && groq.fromRc) {
|
|
2463
2475
|
console.log(
|
|
2464
|
-
|
|
2476
|
+
dedent3`
|
|
2465
2477
|
🔑 GROQ API key loaded from your user-wide configuration.
|
|
2466
2478
|
`
|
|
2467
2479
|
);
|