@lingo.dev/_compiler 0.1.9 → 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 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.9",
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
- const now = Date.now();
723
- fs.utimesSync(filePath, now, now);
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', _27 => _27.parser]) ? config2.parser : "typescript"
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', _28 => _28[modelKey], 'optionalAccess', _29 => _29.split, 'call', _30 => _30(":")]);
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', _31 => _31.prompt, 'optionalAccess', _32 => _32.trim, 'call', _33 => _33(), 'optionalAccess', _34 => _34.replace, 'call', _35 => _35("{SOURCE_LOCALE}", args.sourceLocale), 'optionalAccess', _36 => _36.replace, 'call', _37 => _37("{TARGET_LOCALE}", args.targetLocale)]);
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', _38 => _38.entries]) || {},
1518
- (value) => _optionalChain([String, 'call', _39 => _39(value || ""), 'optionalAccess', _40 => _40.trim, 'optionalCall', _41 => _41(), 'optionalAccess', _42 => _42.length]) > 0
1519
- ) : _optionalChain([sourceFile, 'optionalAccess', _43 => _43.entries]) || {};
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', _44 => _44.entries]) || {}, entries)
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', _45 => _45(path6), 'optionalAccess', _46 => _46.toLowerCase, 'call', _47 => _47()]) === "html") {
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, {
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.9",
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 dedent2 from "dedent";
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
- const now = Date.now();
723
- fs.utimesSync(filePath, now, now);
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 dedent from "dedent";
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
- dedent`
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(dedent2`
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
 
@@ -2419,7 +2433,7 @@ function validateGroqKeyDetails() {
2419
2433
  fromRc: getGroqKeyFromRc()
2420
2434
  };
2421
2435
  if (!groq.fromEnv && !groq.fromRc) {
2422
- console.log(dedent2`
2436
+ console.log(dedent3`
2423
2437
  \n
2424
2438
  💡 You're using Lingo.dev Localization Compiler in your project, which requires a GROQ API key to work.
2425
2439
 
@@ -2438,7 +2452,7 @@ function validateGroqKeyDetails() {
2438
2452
  process.exit(1);
2439
2453
  } else if (groq.fromEnv && groq.fromRc) {
2440
2454
  console.log(
2441
- dedent2`
2455
+ dedent3`
2442
2456
  🔑 GROQ API key detected in both environment variables and your user-wide configuration.
2443
2457
 
2444
2458
  👉 The compiler will use the key from the environment because it has higher priority.
@@ -2450,7 +2464,7 @@ function validateGroqKeyDetails() {
2450
2464
  );
2451
2465
  } else if (groq.fromEnv && !groq.fromRc) {
2452
2466
  console.log(
2453
- dedent2`
2467
+ dedent3`
2454
2468
  🔑 GROQ API key loaded from environment variables.
2455
2469
 
2456
2470
  • You can also save the key user-wide with: npx lingo.dev@latest config set llm.groqApiKey <your-api-key>
@@ -2459,7 +2473,7 @@ function validateGroqKeyDetails() {
2459
2473
  );
2460
2474
  } else if (!groq.fromEnv && groq.fromRc) {
2461
2475
  console.log(
2462
- dedent2`
2476
+ dedent3`
2463
2477
  🔑 GROQ API key loaded from your user-wide configuration.
2464
2478
  `
2465
2479
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingo.dev/_compiler",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Lingo.dev Compiler",
5
5
  "private": false,
6
6
  "publishConfig": {