@lingo.dev/_compiler 0.2.0 → 0.2.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.
Files changed (3) hide show
  1. package/build/index.cjs +126 -117
  2. package/build/index.mjs +129 -120
  3. 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.2.0",
7
+ version: "0.2.1",
8
8
  description: "Lingo.dev Compiler",
9
9
  private: false,
10
10
  publishConfig: {
@@ -174,9 +174,9 @@ function extractAttributeValue(attribute) {
174
174
  function getJsxRoots(node) {
175
175
  const result = [];
176
176
  _traverse2.default.call(void 0, node, {
177
- JSXElement(path6) {
178
- result.push(path6);
179
- path6.skip();
177
+ JSXElement(path7) {
178
+ result.push(path7);
179
+ path7.skip();
180
180
  }
181
181
  });
182
182
  return result;
@@ -203,14 +203,14 @@ function getOrCreateImport(ast, params) {
203
203
  function findExistingImport(ast, exportedName, moduleName) {
204
204
  let result = null;
205
205
  _traverse2.default.call(void 0, ast, {
206
- ImportDeclaration(path6) {
207
- if (path6.node.source.value !== moduleName) {
206
+ ImportDeclaration(path7) {
207
+ if (path7.node.source.value !== moduleName) {
208
208
  return;
209
209
  }
210
- for (const specifier of path6.node.specifiers) {
210
+ for (const specifier of path7.node.specifiers) {
211
211
  if (t2.isImportSpecifier(specifier) && (t2.isIdentifier(specifier.imported) && specifier.imported.name === exportedName || specifier.importKind === "value" && t2.isIdentifier(specifier.local) && specifier.local.name === exportedName)) {
212
212
  result = specifier.local.name;
213
- path6.stop();
213
+ path7.stop();
214
214
  return;
215
215
  }
216
216
  }
@@ -221,8 +221,8 @@ function findExistingImport(ast, exportedName, moduleName) {
221
221
  function generateUniqueImportName(ast, baseName) {
222
222
  const usedNames = /* @__PURE__ */ new Set();
223
223
  _traverse2.default.call(void 0, ast, {
224
- Identifier(path6) {
225
- usedNames.add(path6.node.name);
224
+ Identifier(path7) {
225
+ usedNames.add(path7.node.name);
226
226
  }
227
227
  });
228
228
  if (!usedNames.has(baseName)) {
@@ -238,12 +238,12 @@ function generateUniqueImportName(ast, baseName) {
238
238
  }
239
239
  function createImportDeclaration(ast, localName, exportedName, moduleName) {
240
240
  _traverse2.default.call(void 0, ast, {
241
- Program(path6) {
241
+ Program(path7) {
242
242
  const importSpecifier2 = t2.importSpecifier(
243
243
  t2.identifier(localName),
244
244
  t2.identifier(exportedName)
245
245
  );
246
- const existingImport = path6.get("body").find(
246
+ const existingImport = path7.get("body").find(
247
247
  (nodePath) => t2.isImportDeclaration(nodePath.node) && nodePath.node.source.value === moduleName
248
248
  );
249
249
  if (existingImport && t2.isImportDeclaration(existingImport.node)) {
@@ -253,10 +253,10 @@ function createImportDeclaration(ast, localName, exportedName, moduleName) {
253
253
  [importSpecifier2],
254
254
  t2.stringLiteral(moduleName)
255
255
  );
256
- const lastImportIndex = findLastImportIndex(path6);
257
- path6.node.body.splice(lastImportIndex + 1, 0, importDeclaration2);
256
+ const lastImportIndex = findLastImportIndex(path7);
257
+ path7.node.body.splice(lastImportIndex + 1, 0, importDeclaration2);
258
258
  }
259
- path6.stop();
259
+ path7.stop();
260
260
  }
261
261
  });
262
262
  }
@@ -272,10 +272,10 @@ function findLastImportIndex(programPath) {
272
272
  function _hasFileDirective(ast, directiveValue) {
273
273
  let hasDirective = false;
274
274
  _traverse2.default.call(void 0, ast, {
275
- Directive(path6) {
276
- if (path6.node.value.value === directiveValue) {
275
+ Directive(path7) {
276
+ if (path7.node.value.value === directiveValue) {
277
277
  hasDirective = true;
278
- path6.stop();
278
+ path7.stop();
279
279
  }
280
280
  }
281
281
  });
@@ -325,9 +325,9 @@ function getJsxElementName(nodePath) {
325
325
  function getNestedJsxElements(nodePath) {
326
326
  const nestedElements = [];
327
327
  nodePath.traverse({
328
- JSXElement(path6) {
329
- if (path6.node !== nodePath.node) {
330
- nestedElements.push(path6.node);
328
+ JSXElement(path7) {
329
+ if (path7.node !== nodePath.node) {
330
+ nestedElements.push(path7.node);
331
331
  }
332
332
  }
333
333
  });
@@ -350,8 +350,8 @@ var LCP_DICTIONARY_FILE_NAME = "dictionary.js";
350
350
  // src/jsx-provider.ts
351
351
  var jsxProviderMutation = createCodeMutation((payload) => {
352
352
  _traverse2.default.call(void 0, payload.ast, {
353
- JSXElement: (path6) => {
354
- if (_optionalChain([getJsxElementName, 'call', _12 => _12(path6), 'optionalAccess', _13 => _13.toLowerCase, 'call', _14 => _14()]) === "html") {
353
+ JSXElement: (path7) => {
354
+ if (_optionalChain([getJsxElementName, 'call', _12 => _12(path7), 'optionalAccess', _13 => _13.toLowerCase, 'call', _14 => _14()]) === "html") {
355
355
  const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
356
356
  if (mode === "client") {
357
357
  return;
@@ -385,11 +385,11 @@ var jsxProviderMutation = createCodeMutation((payload) => {
385
385
  t4.jsxClosingElement(
386
386
  t4.jsxIdentifier(lingoProviderImport.importedName)
387
387
  ),
388
- [path6.node],
388
+ [path7.node],
389
389
  false
390
390
  );
391
- path6.replaceWith(provider);
392
- path6.skip();
391
+ path7.replaceWith(provider);
392
+ path7.skip();
393
393
  }
394
394
  }
395
395
  });
@@ -438,10 +438,10 @@ function getAstKey(nodePath) {
438
438
  function collectJsxScopes(ast) {
439
439
  const jsxScopes = [];
440
440
  _traverse2.default.call(void 0, ast, {
441
- JSXElement: (path6) => {
442
- if (!hasJsxScopeAttribute(path6)) return;
443
- path6.skip();
444
- jsxScopes.push(path6);
441
+ JSXElement: (path7) => {
442
+ if (!hasJsxScopeAttribute(path7)) return;
443
+ path7.skip();
444
+ jsxScopes.push(path7);
445
445
  }
446
446
  });
447
447
  return jsxScopes;
@@ -449,32 +449,32 @@ function collectJsxScopes(ast) {
449
449
  function getJsxScopes(node) {
450
450
  const result = [];
451
451
  _traverse2.default.call(void 0, node, {
452
- JSXElement(path6) {
453
- if (getJsxElementName(path6) === "LingoProvider") {
452
+ JSXElement(path7) {
453
+ if (getJsxElementName(path7) === "LingoProvider") {
454
454
  return;
455
455
  }
456
- const hasNonEmptyTextSiblings = path6.getAllPrevSiblings().concat(path6.getAllNextSiblings()).some(
456
+ const hasNonEmptyTextSiblings = path7.getAllPrevSiblings().concat(path7.getAllNextSiblings()).some(
457
457
  (sibling) => t7.isJSXText(sibling.node) && _optionalChain([sibling, 'access', _16 => _16.node, 'access', _17 => _17.value, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]) !== ""
458
458
  );
459
459
  if (hasNonEmptyTextSiblings) {
460
460
  return;
461
461
  }
462
- const hasNonEmptyTextChild = path6.get("children").some(
462
+ const hasNonEmptyTextChild = path7.get("children").some(
463
463
  (child) => t7.isJSXText(child.node) && _optionalChain([child, 'access', _20 => _20.node, 'access', _21 => _21.value, 'optionalAccess', _22 => _22.trim, 'call', _23 => _23()]) !== ""
464
464
  );
465
465
  if (hasNonEmptyTextChild) {
466
- result.push(path6);
467
- path6.skip();
466
+ result.push(path7);
467
+ path7.skip();
468
468
  }
469
469
  }
470
470
  });
471
471
  return result;
472
472
  }
473
- function hasJsxScopeAttribute(path6) {
474
- return !!getJsxScopeAttribute(path6);
473
+ function hasJsxScopeAttribute(path7) {
474
+ return !!getJsxScopeAttribute(path7);
475
475
  }
476
- function getJsxScopeAttribute(path6) {
477
- const attribute = path6.node.openingElement.attributes.find(
476
+ function getJsxScopeAttribute(path7) {
477
+ const attribute = path7.node.openingElement.attributes.find(
478
478
  (attr) => attr.type === "JSXAttribute" && attr.name.name === "data-jsx-scope"
479
479
  );
480
480
  return attribute && t7.isJSXAttribute(attribute) && t7.isStringLiteral(attribute.value) ? attribute.value.value : void 0;
@@ -506,11 +506,11 @@ var jsx_scope_flag_default = jsxScopeFlagMutation;
506
506
  function collectJsxAttributeScopes(node) {
507
507
  const result = [];
508
508
  _traverse2.default.call(void 0, node, {
509
- JSXElement(path6) {
510
- if (!hasJsxAttributeScopeAttribute(path6)) return;
511
- const localizableAttributes = getJsxAttributeScopeAttribute(path6);
509
+ JSXElement(path7) {
510
+ if (!hasJsxAttributeScopeAttribute(path7)) return;
511
+ const localizableAttributes = getJsxAttributeScopeAttribute(path7);
512
512
  if (!localizableAttributes) return;
513
- result.push([path6, localizableAttributes]);
513
+ result.push([path7, localizableAttributes]);
514
514
  }
515
515
  });
516
516
  return result;
@@ -529,8 +529,8 @@ function getJsxAttributeScopes(node) {
529
529
  "subtitle"
530
530
  ];
531
531
  _traverse2.default.call(void 0, node, {
532
- JSXElement(path6) {
533
- const openingElement = path6.node.openingElement;
532
+ JSXElement(path7) {
533
+ const openingElement = path7.node.openingElement;
534
534
  const elementName = openingElement.name;
535
535
  if (!t9.isJSXIdentifier(elementName) || !elementName.name) {
536
536
  return;
@@ -551,17 +551,17 @@ function getJsxAttributeScopes(node) {
551
551
  }
552
552
  ).map((attr) => attr.name.name);
553
553
  if (localizableAttrs.length > 0) {
554
- result.push([path6, localizableAttrs]);
554
+ result.push([path7, localizableAttrs]);
555
555
  }
556
556
  }
557
557
  });
558
558
  return result;
559
559
  }
560
- function hasJsxAttributeScopeAttribute(path6) {
561
- return !!getJsxAttributeScopeAttribute(path6);
560
+ function hasJsxAttributeScopeAttribute(path7) {
561
+ return !!getJsxAttributeScopeAttribute(path7);
562
562
  }
563
- function getJsxAttributeScopeAttribute(path6) {
564
- const attribute = path6.node.openingElement.attributes.find(
563
+ function getJsxAttributeScopeAttribute(path7) {
564
+ const attribute = path7.node.openingElement.attributes.find(
565
565
  (attr) => attr.type === "JSXAttribute" && attr.name.name === "data-jsx-attribute-scope"
566
566
  );
567
567
  if (!attribute || !t9.isJSXAttribute(attribute)) {
@@ -1155,10 +1155,19 @@ function getRc() {
1155
1155
  // src/utils/llm-api-key.ts
1156
1156
 
1157
1157
  var _dotenv = require('dotenv'); var dotenv = _interopRequireWildcard(_dotenv);
1158
+
1158
1159
  function getKeyFromEnv(envVarName) {
1159
- const ephemeralEnv = {};
1160
- dotenv.config({ processEnv: ephemeralEnv });
1161
- return ephemeralEnv[envVarName];
1160
+ if (process.env[envVarName]) {
1161
+ return process.env[envVarName];
1162
+ }
1163
+ const result = dotenv.config({
1164
+ path: [
1165
+ path.default.resolve(process.cwd(), ".env"),
1166
+ path.default.resolve(process.cwd(), ".env.local"),
1167
+ path.default.resolve(process.cwd(), ".env.development")
1168
+ ]
1169
+ });
1170
+ return _optionalChain([result, 'optionalAccess', _39 => _39.parsed, 'optionalAccess', _40 => _40[envVarName]]);
1162
1171
  }
1163
1172
  function getKeyFromRc(rcPath) {
1164
1173
  const rc = getRc();
@@ -1689,14 +1698,14 @@ var LCPServer = (_class = class {
1689
1698
  const sourceFile = _lodash2.default.get(sourceDictionary.files, fileName);
1690
1699
  const targetFile = _lodash2.default.get(targetDictionary.files, fileName);
1691
1700
  const entries = removeEmptyEntries ? _lodash2.default.pickBy(
1692
- _optionalChain([sourceFile, 'optionalAccess', _39 => _39.entries]) || {},
1693
- (value) => _optionalChain([String, 'call', _40 => _40(value || ""), 'optionalAccess', _41 => _41.trim, 'optionalCall', _42 => _42(), 'optionalAccess', _43 => _43.length]) > 0
1694
- ) : _optionalChain([sourceFile, 'optionalAccess', _44 => _44.entries]) || {};
1701
+ _optionalChain([sourceFile, 'optionalAccess', _41 => _41.entries]) || {},
1702
+ (value) => _optionalChain([String, 'call', _42 => _42(value || ""), 'optionalAccess', _43 => _43.trim, 'optionalCall', _44 => _44(), 'optionalAccess', _45 => _45.length]) > 0
1703
+ ) : _optionalChain([sourceFile, 'optionalAccess', _46 => _46.entries]) || {};
1695
1704
  return [
1696
1705
  fileName,
1697
1706
  {
1698
1707
  ...targetFile,
1699
- entries: _lodash2.default.merge(_optionalChain([targetFile, 'optionalAccess', _45 => _45.entries]) || {}, entries)
1708
+ entries: _lodash2.default.merge(_optionalChain([targetFile, 'optionalAccess', _47 => _47.entries]) || {}, entries)
1700
1709
  }
1701
1710
  ];
1702
1711
  }).fromPairs().value();
@@ -1721,10 +1730,10 @@ var LCPServer = (_class = class {
1721
1730
  function findInvokations(ast, params) {
1722
1731
  const result = [];
1723
1732
  _traverse2.default.call(void 0, ast, {
1724
- ImportDeclaration(path6) {
1725
- if (path6.node.source.value !== params.moduleName) return;
1733
+ ImportDeclaration(path7) {
1734
+ if (path7.node.source.value !== params.moduleName) return;
1726
1735
  const importNames = /* @__PURE__ */ new Map();
1727
- const specifiers = path6.node.specifiers;
1736
+ const specifiers = path7.node.specifiers;
1728
1737
  specifiers.forEach((specifier) => {
1729
1738
  if (t11.isImportSpecifier(specifier) && t11.isIdentifier(specifier.imported) && specifier.imported.name === params.functionName) {
1730
1739
  importNames.set(specifier.local.name, true);
@@ -1734,13 +1743,13 @@ function findInvokations(ast, params) {
1734
1743
  importNames.set(specifier.local.name, "namespace");
1735
1744
  }
1736
1745
  });
1737
- collectCallExpressions(path6, importNames, result, params.functionName);
1746
+ collectCallExpressions(path7, importNames, result, params.functionName);
1738
1747
  }
1739
1748
  });
1740
1749
  return result;
1741
1750
  }
1742
- function collectCallExpressions(path6, importNames, result, functionName) {
1743
- const program = path6.findParent(
1751
+ function collectCallExpressions(path7, importNames, result, functionName) {
1752
+ const program = path7.findParent(
1744
1753
  (p) => p.isProgram()
1745
1754
  );
1746
1755
  if (!program) return;
@@ -1850,18 +1859,18 @@ function jsxFragmentMutation(payload) {
1850
1859
  let foundFragments = false;
1851
1860
  let fragmentImportName = null;
1852
1861
  _traverse2.default.call(void 0, ast, {
1853
- ImportDeclaration(path6) {
1854
- if (path6.node.source.value !== "react") return;
1855
- for (const specifier of path6.node.specifiers) {
1862
+ ImportDeclaration(path7) {
1863
+ if (path7.node.source.value !== "react") return;
1864
+ for (const specifier of path7.node.specifiers) {
1856
1865
  if (t14.isImportSpecifier(specifier) && t14.isIdentifier(specifier.imported) && specifier.imported.name === "Fragment") {
1857
1866
  fragmentImportName = specifier.local.name;
1858
- path6.stop();
1867
+ path7.stop();
1859
1868
  }
1860
1869
  }
1861
1870
  }
1862
1871
  });
1863
1872
  _traverse2.default.call(void 0, ast, {
1864
- JSXFragment(path6) {
1873
+ JSXFragment(path7) {
1865
1874
  foundFragments = true;
1866
1875
  if (!fragmentImportName) {
1867
1876
  const result = getOrCreateImport(ast, {
@@ -1873,10 +1882,10 @@ function jsxFragmentMutation(payload) {
1873
1882
  const fragmentElement = t14.jsxElement(
1874
1883
  t14.jsxOpeningElement(t14.jsxIdentifier(fragmentImportName), [], false),
1875
1884
  t14.jsxClosingElement(t14.jsxIdentifier(fragmentImportName)),
1876
- path6.node.children,
1885
+ path7.node.children,
1877
1886
  false
1878
1887
  );
1879
- path6.replaceWith(fragmentElement);
1888
+ path7.replaceWith(fragmentElement);
1880
1889
  }
1881
1890
  });
1882
1891
  return payload;
@@ -1887,23 +1896,23 @@ function jsxFragmentMutation(payload) {
1887
1896
 
1888
1897
  var jsxHtmlLangMutation = createCodeMutation((payload) => {
1889
1898
  _traverse2.default.call(void 0, payload.ast, {
1890
- JSXElement: (path6) => {
1891
- if (_optionalChain([getJsxElementName, 'call', _46 => _46(path6), 'optionalAccess', _47 => _47.toLowerCase, 'call', _48 => _48()]) === "html") {
1899
+ JSXElement: (path7) => {
1900
+ if (_optionalChain([getJsxElementName, 'call', _48 => _48(path7), 'optionalAccess', _49 => _49.toLowerCase, 'call', _50 => _50()]) === "html") {
1892
1901
  const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
1893
1902
  const packagePath = mode === "client" ? "lingo.dev/react/client" /* ReactClient */ : "lingo.dev/react/rsc" /* ReactRSC */;
1894
1903
  const lingoHtmlComponentImport = getOrCreateImport(payload.ast, {
1895
1904
  moduleName: packagePath,
1896
1905
  exportedName: "LingoHtmlComponent"
1897
1906
  });
1898
- path6.node.openingElement.name = t15.jsxIdentifier(
1907
+ path7.node.openingElement.name = t15.jsxIdentifier(
1899
1908
  lingoHtmlComponentImport.importedName
1900
1909
  );
1901
- if (path6.node.closingElement) {
1902
- path6.node.closingElement.name = t15.jsxIdentifier(
1910
+ if (path7.node.closingElement) {
1911
+ path7.node.closingElement.name = t15.jsxIdentifier(
1903
1912
  lingoHtmlComponentImport.importedName
1904
1913
  );
1905
1914
  }
1906
- path6.skip();
1915
+ path7.skip();
1907
1916
  }
1908
1917
  }
1909
1918
  });
@@ -1970,22 +1979,22 @@ var WHITESPACE_PLACEHOLDER = "[lingo-whitespace-placeholder]";
1970
1979
  function extractJsxContent(nodePath, replaceWhitespacePlaceholders = true) {
1971
1980
  const chunks = [];
1972
1981
  nodePath.traverse({
1973
- JSXElement(path6) {
1974
- if (path6.parent === nodePath.node) {
1975
- const content = extractJsxContent(path6, false);
1976
- const name = getJsxElementName(path6);
1982
+ JSXElement(path7) {
1983
+ if (path7.parent === nodePath.node) {
1984
+ const content = extractJsxContent(path7, false);
1985
+ const name = getJsxElementName(path7);
1977
1986
  chunks.push(`<element:${name}>${content}</element:${name}>`);
1978
- path6.skip();
1987
+ path7.skip();
1979
1988
  }
1980
1989
  },
1981
- JSXText(path6) {
1982
- chunks.push(path6.node.value);
1990
+ JSXText(path7) {
1991
+ chunks.push(path7.node.value);
1983
1992
  },
1984
- JSXExpressionContainer(path6) {
1985
- if (path6.parent !== nodePath.node) {
1993
+ JSXExpressionContainer(path7) {
1994
+ if (path7.parent !== nodePath.node) {
1986
1995
  return;
1987
1996
  }
1988
- const expr = path6.node.expression;
1997
+ const expr = path7.node.expression;
1989
1998
  if (t16.isCallExpression(expr)) {
1990
1999
  let key = "";
1991
2000
  if (t16.isIdentifier(expr.callee)) {
@@ -2031,12 +2040,12 @@ function extractJsxContent(nodePath, replaceWhitespacePlaceholders = true) {
2031
2040
  parts.unshift(current.name);
2032
2041
  chunks.push(`{${parts.join(".").replaceAll(".[", "[")}}`);
2033
2042
  }
2034
- } else if (isWhitespace(path6)) {
2043
+ } else if (isWhitespace(path7)) {
2035
2044
  chunks.push(WHITESPACE_PLACEHOLDER);
2036
- } else if (isExpression2(path6)) {
2045
+ } else if (isExpression2(path7)) {
2037
2046
  chunks.push("<expression/>");
2038
2047
  }
2039
- path6.skip();
2048
+ path7.skip();
2040
2049
  }
2041
2050
  });
2042
2051
  const result = chunks.join("");
@@ -2187,14 +2196,14 @@ var lingoJsxAttributeScopeInjectMutation = createCodeMutation(
2187
2196
  var getJsxVariables = (nodePath) => {
2188
2197
  const variables = /* @__PURE__ */ new Set();
2189
2198
  nodePath.traverse({
2190
- JSXOpeningElement(path6) {
2191
- path6.skip();
2199
+ JSXOpeningElement(path7) {
2200
+ path7.skip();
2192
2201
  },
2193
- JSXExpressionContainer(path6) {
2194
- if (t18.isIdentifier(path6.node.expression)) {
2195
- variables.add(path6.node.expression.name);
2196
- } else if (t18.isMemberExpression(path6.node.expression)) {
2197
- let current = path6.node.expression;
2202
+ JSXExpressionContainer(path7) {
2203
+ if (t18.isIdentifier(path7.node.expression)) {
2204
+ variables.add(path7.node.expression.name);
2205
+ } else if (t18.isMemberExpression(path7.node.expression)) {
2206
+ let current = path7.node.expression;
2198
2207
  const parts = [];
2199
2208
  while (t18.isMemberExpression(current)) {
2200
2209
  if (t18.isIdentifier(current.property)) {
@@ -2211,7 +2220,7 @@ var getJsxVariables = (nodePath) => {
2211
2220
  variables.add(parts.join(".").replaceAll(".[", "["));
2212
2221
  }
2213
2222
  }
2214
- path6.skip();
2223
+ path7.skip();
2215
2224
  }
2216
2225
  });
2217
2226
  const properties = Array.from(variables).map(
@@ -2227,16 +2236,16 @@ var getJsxFunctions = (nodePath) => {
2227
2236
  const functions = /* @__PURE__ */ new Map();
2228
2237
  let fnCounter = 0;
2229
2238
  nodePath.traverse({
2230
- JSXOpeningElement(path6) {
2231
- path6.skip();
2239
+ JSXOpeningElement(path7) {
2240
+ path7.skip();
2232
2241
  },
2233
- JSXExpressionContainer(path6) {
2234
- if (t19.isCallExpression(path6.node.expression)) {
2242
+ JSXExpressionContainer(path7) {
2243
+ if (t19.isCallExpression(path7.node.expression)) {
2235
2244
  let key = "";
2236
- if (t19.isIdentifier(path6.node.expression.callee)) {
2237
- key = `${path6.node.expression.callee.name}`;
2238
- } else if (t19.isMemberExpression(path6.node.expression.callee)) {
2239
- let firstCallee = path6.node.expression.callee;
2245
+ if (t19.isIdentifier(path7.node.expression.callee)) {
2246
+ key = `${path7.node.expression.callee.name}`;
2247
+ } else if (t19.isMemberExpression(path7.node.expression.callee)) {
2248
+ let firstCallee = path7.node.expression.callee;
2240
2249
  while (t19.isMemberExpression(firstCallee) && t19.isCallExpression(firstCallee.object)) {
2241
2250
  firstCallee = firstCallee.object.callee;
2242
2251
  }
@@ -2257,10 +2266,10 @@ var getJsxFunctions = (nodePath) => {
2257
2266
  key = parts.join(".");
2258
2267
  }
2259
2268
  const existing = _nullishCoalesce(functions.get(key), () => ( []));
2260
- functions.set(key, [...existing, path6.node.expression]);
2269
+ functions.set(key, [...existing, path7.node.expression]);
2261
2270
  fnCounter++;
2262
2271
  }
2263
- path6.skip();
2272
+ path7.skip();
2264
2273
  }
2265
2274
  });
2266
2275
  const properties = Array.from(functions.entries()).map(
@@ -2274,15 +2283,15 @@ var getJsxFunctions = (nodePath) => {
2274
2283
  var getJsxExpressions = (nodePath) => {
2275
2284
  const expressions = [];
2276
2285
  nodePath.traverse({
2277
- JSXOpeningElement(path6) {
2278
- path6.skip();
2286
+ JSXOpeningElement(path7) {
2287
+ path7.skip();
2279
2288
  },
2280
- JSXExpressionContainer(path6) {
2281
- const expr = path6.node.expression;
2289
+ JSXExpressionContainer(path7) {
2290
+ const expr = path7.node.expression;
2282
2291
  if (!t20.isJSXEmptyExpression(expr) && !t20.isIdentifier(expr) && !t20.isMemberExpression(expr) && !t20.isCallExpression(expr) && !(t20.isStringLiteral(expr) && expr.value === " ")) {
2283
2292
  expressions.push(expr);
2284
2293
  }
2285
- path6.skip();
2294
+ path7.skip();
2286
2295
  }
2287
2296
  });
2288
2297
  return t20.arrayExpression(expressions);
@@ -2407,8 +2416,8 @@ var jsxRemoveAttributesMutation = createCodeMutation(
2407
2416
  "data-jsx-attribute-scope"
2408
2417
  ];
2409
2418
  _traverse2.default.call(void 0, payload.ast, {
2410
- JSXElement(path6) {
2411
- const openingElement = path6.node.openingElement;
2419
+ JSXElement(path7) {
2420
+ const openingElement = path7.node.openingElement;
2412
2421
  openingElement.attributes = openingElement.attributes.filter((attr) => {
2413
2422
  const removeAttr = t22.isJSXAttribute(attr) && t22.isJSXIdentifier(attr.name) && ATTRIBUTES_TO_REMOVE.includes(attr.name.name);
2414
2423
  return !removeAttr;
@@ -2614,8 +2623,8 @@ function validateLLMKeyDetails(models) {
2614
2623
  const details = providerDetails[providerId];
2615
2624
  const checkers = keyCheckers[providerId];
2616
2625
  if (!details || !checkers) continue;
2617
- const foundInEnv = checkers.checkEnv() !== void 0;
2618
- const foundInRc = checkers.checkRc() !== void 0;
2626
+ const foundInEnv = !!checkers.checkEnv();
2627
+ const foundInRc = !!checkers.checkRc();
2619
2628
  keyStatuses[providerId] = { foundInEnv, foundInRc, details };
2620
2629
  if (!foundInEnv && !foundInRc) {
2621
2630
  missingProviders.push(providerId);
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.2.0",
7
+ version: "0.2.1",
8
8
  description: "Lingo.dev Compiler",
9
9
  private: false,
10
10
  publishConfig: {
@@ -174,9 +174,9 @@ function extractAttributeValue(attribute) {
174
174
  function getJsxRoots(node) {
175
175
  const result = [];
176
176
  traverse(node, {
177
- JSXElement(path6) {
178
- result.push(path6);
179
- path6.skip();
177
+ JSXElement(path7) {
178
+ result.push(path7);
179
+ path7.skip();
180
180
  }
181
181
  });
182
182
  return result;
@@ -203,14 +203,14 @@ function getOrCreateImport(ast, params) {
203
203
  function findExistingImport(ast, exportedName, moduleName) {
204
204
  let result = null;
205
205
  traverse(ast, {
206
- ImportDeclaration(path6) {
207
- if (path6.node.source.value !== moduleName) {
206
+ ImportDeclaration(path7) {
207
+ if (path7.node.source.value !== moduleName) {
208
208
  return;
209
209
  }
210
- for (const specifier of path6.node.specifiers) {
210
+ for (const specifier of path7.node.specifiers) {
211
211
  if (t2.isImportSpecifier(specifier) && (t2.isIdentifier(specifier.imported) && specifier.imported.name === exportedName || specifier.importKind === "value" && t2.isIdentifier(specifier.local) && specifier.local.name === exportedName)) {
212
212
  result = specifier.local.name;
213
- path6.stop();
213
+ path7.stop();
214
214
  return;
215
215
  }
216
216
  }
@@ -221,8 +221,8 @@ function findExistingImport(ast, exportedName, moduleName) {
221
221
  function generateUniqueImportName(ast, baseName) {
222
222
  const usedNames = /* @__PURE__ */ new Set();
223
223
  traverse(ast, {
224
- Identifier(path6) {
225
- usedNames.add(path6.node.name);
224
+ Identifier(path7) {
225
+ usedNames.add(path7.node.name);
226
226
  }
227
227
  });
228
228
  if (!usedNames.has(baseName)) {
@@ -238,12 +238,12 @@ function generateUniqueImportName(ast, baseName) {
238
238
  }
239
239
  function createImportDeclaration(ast, localName, exportedName, moduleName) {
240
240
  traverse(ast, {
241
- Program(path6) {
241
+ Program(path7) {
242
242
  const importSpecifier2 = t2.importSpecifier(
243
243
  t2.identifier(localName),
244
244
  t2.identifier(exportedName)
245
245
  );
246
- const existingImport = path6.get("body").find(
246
+ const existingImport = path7.get("body").find(
247
247
  (nodePath) => t2.isImportDeclaration(nodePath.node) && nodePath.node.source.value === moduleName
248
248
  );
249
249
  if (existingImport && t2.isImportDeclaration(existingImport.node)) {
@@ -253,10 +253,10 @@ function createImportDeclaration(ast, localName, exportedName, moduleName) {
253
253
  [importSpecifier2],
254
254
  t2.stringLiteral(moduleName)
255
255
  );
256
- const lastImportIndex = findLastImportIndex(path6);
257
- path6.node.body.splice(lastImportIndex + 1, 0, importDeclaration2);
256
+ const lastImportIndex = findLastImportIndex(path7);
257
+ path7.node.body.splice(lastImportIndex + 1, 0, importDeclaration2);
258
258
  }
259
- path6.stop();
259
+ path7.stop();
260
260
  }
261
261
  });
262
262
  }
@@ -272,10 +272,10 @@ function findLastImportIndex(programPath) {
272
272
  function _hasFileDirective(ast, directiveValue) {
273
273
  let hasDirective = false;
274
274
  traverse(ast, {
275
- Directive(path6) {
276
- if (path6.node.value.value === directiveValue) {
275
+ Directive(path7) {
276
+ if (path7.node.value.value === directiveValue) {
277
277
  hasDirective = true;
278
- path6.stop();
278
+ path7.stop();
279
279
  }
280
280
  }
281
281
  });
@@ -325,9 +325,9 @@ function getJsxElementName(nodePath) {
325
325
  function getNestedJsxElements(nodePath) {
326
326
  const nestedElements = [];
327
327
  nodePath.traverse({
328
- JSXElement(path6) {
329
- if (path6.node !== nodePath.node) {
330
- nestedElements.push(path6.node);
328
+ JSXElement(path7) {
329
+ if (path7.node !== nodePath.node) {
330
+ nestedElements.push(path7.node);
331
331
  }
332
332
  }
333
333
  });
@@ -350,8 +350,8 @@ var LCP_DICTIONARY_FILE_NAME = "dictionary.js";
350
350
  // src/jsx-provider.ts
351
351
  var jsxProviderMutation = createCodeMutation((payload) => {
352
352
  traverse2(payload.ast, {
353
- JSXElement: (path6) => {
354
- if (getJsxElementName(path6)?.toLowerCase() === "html") {
353
+ JSXElement: (path7) => {
354
+ if (getJsxElementName(path7)?.toLowerCase() === "html") {
355
355
  const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
356
356
  if (mode === "client") {
357
357
  return;
@@ -385,11 +385,11 @@ var jsxProviderMutation = createCodeMutation((payload) => {
385
385
  t4.jsxClosingElement(
386
386
  t4.jsxIdentifier(lingoProviderImport.importedName)
387
387
  ),
388
- [path6.node],
388
+ [path7.node],
389
389
  false
390
390
  );
391
- path6.replaceWith(provider);
392
- path6.skip();
391
+ path7.replaceWith(provider);
392
+ path7.skip();
393
393
  }
394
394
  }
395
395
  });
@@ -438,10 +438,10 @@ import traverse4 from "@babel/traverse";
438
438
  function collectJsxScopes(ast) {
439
439
  const jsxScopes = [];
440
440
  traverse4(ast, {
441
- JSXElement: (path6) => {
442
- if (!hasJsxScopeAttribute(path6)) return;
443
- path6.skip();
444
- jsxScopes.push(path6);
441
+ JSXElement: (path7) => {
442
+ if (!hasJsxScopeAttribute(path7)) return;
443
+ path7.skip();
444
+ jsxScopes.push(path7);
445
445
  }
446
446
  });
447
447
  return jsxScopes;
@@ -449,32 +449,32 @@ function collectJsxScopes(ast) {
449
449
  function getJsxScopes(node) {
450
450
  const result = [];
451
451
  traverse4(node, {
452
- JSXElement(path6) {
453
- if (getJsxElementName(path6) === "LingoProvider") {
452
+ JSXElement(path7) {
453
+ if (getJsxElementName(path7) === "LingoProvider") {
454
454
  return;
455
455
  }
456
- const hasNonEmptyTextSiblings = path6.getAllPrevSiblings().concat(path6.getAllNextSiblings()).some(
456
+ const hasNonEmptyTextSiblings = path7.getAllPrevSiblings().concat(path7.getAllNextSiblings()).some(
457
457
  (sibling) => t7.isJSXText(sibling.node) && sibling.node.value?.trim() !== ""
458
458
  );
459
459
  if (hasNonEmptyTextSiblings) {
460
460
  return;
461
461
  }
462
- const hasNonEmptyTextChild = path6.get("children").some(
462
+ const hasNonEmptyTextChild = path7.get("children").some(
463
463
  (child) => t7.isJSXText(child.node) && child.node.value?.trim() !== ""
464
464
  );
465
465
  if (hasNonEmptyTextChild) {
466
- result.push(path6);
467
- path6.skip();
466
+ result.push(path7);
467
+ path7.skip();
468
468
  }
469
469
  }
470
470
  });
471
471
  return result;
472
472
  }
473
- function hasJsxScopeAttribute(path6) {
474
- return !!getJsxScopeAttribute(path6);
473
+ function hasJsxScopeAttribute(path7) {
474
+ return !!getJsxScopeAttribute(path7);
475
475
  }
476
- function getJsxScopeAttribute(path6) {
477
- const attribute = path6.node.openingElement.attributes.find(
476
+ function getJsxScopeAttribute(path7) {
477
+ const attribute = path7.node.openingElement.attributes.find(
478
478
  (attr) => attr.type === "JSXAttribute" && attr.name.name === "data-jsx-scope"
479
479
  );
480
480
  return attribute && t7.isJSXAttribute(attribute) && t7.isStringLiteral(attribute.value) ? attribute.value.value : void 0;
@@ -506,11 +506,11 @@ import traverse5 from "@babel/traverse";
506
506
  function collectJsxAttributeScopes(node) {
507
507
  const result = [];
508
508
  traverse5(node, {
509
- JSXElement(path6) {
510
- if (!hasJsxAttributeScopeAttribute(path6)) return;
511
- const localizableAttributes = getJsxAttributeScopeAttribute(path6);
509
+ JSXElement(path7) {
510
+ if (!hasJsxAttributeScopeAttribute(path7)) return;
511
+ const localizableAttributes = getJsxAttributeScopeAttribute(path7);
512
512
  if (!localizableAttributes) return;
513
- result.push([path6, localizableAttributes]);
513
+ result.push([path7, localizableAttributes]);
514
514
  }
515
515
  });
516
516
  return result;
@@ -529,8 +529,8 @@ function getJsxAttributeScopes(node) {
529
529
  "subtitle"
530
530
  ];
531
531
  traverse5(node, {
532
- JSXElement(path6) {
533
- const openingElement = path6.node.openingElement;
532
+ JSXElement(path7) {
533
+ const openingElement = path7.node.openingElement;
534
534
  const elementName = openingElement.name;
535
535
  if (!t9.isJSXIdentifier(elementName) || !elementName.name) {
536
536
  return;
@@ -551,17 +551,17 @@ function getJsxAttributeScopes(node) {
551
551
  }
552
552
  ).map((attr) => attr.name.name);
553
553
  if (localizableAttrs.length > 0) {
554
- result.push([path6, localizableAttrs]);
554
+ result.push([path7, localizableAttrs]);
555
555
  }
556
556
  }
557
557
  });
558
558
  return result;
559
559
  }
560
- function hasJsxAttributeScopeAttribute(path6) {
561
- return !!getJsxAttributeScopeAttribute(path6);
560
+ function hasJsxAttributeScopeAttribute(path7) {
561
+ return !!getJsxAttributeScopeAttribute(path7);
562
562
  }
563
- function getJsxAttributeScopeAttribute(path6) {
564
- const attribute = path6.node.openingElement.attributes.find(
563
+ function getJsxAttributeScopeAttribute(path7) {
564
+ const attribute = path7.node.openingElement.attributes.find(
565
565
  (attr) => attr.type === "JSXAttribute" && attr.name.name === "data-jsx-attribute-scope"
566
566
  );
567
567
  if (!attribute || !t9.isJSXAttribute(attribute)) {
@@ -604,7 +604,7 @@ var jsxAttributeFlagMutation = createCodeMutation(
604
604
  var jsx_attribute_flag_default = jsxAttributeFlagMutation;
605
605
 
606
606
  // src/index.ts
607
- import path5 from "path";
607
+ import path6 from "path";
608
608
 
609
609
  // src/utils/module-params.ts
610
610
  function parseParametrizedModuleId(rawId) {
@@ -1155,10 +1155,19 @@ function getRc() {
1155
1155
  // src/utils/llm-api-key.ts
1156
1156
  import _5 from "lodash";
1157
1157
  import * as dotenv from "dotenv";
1158
+ import path4 from "path";
1158
1159
  function getKeyFromEnv(envVarName) {
1159
- const ephemeralEnv = {};
1160
- dotenv.config({ processEnv: ephemeralEnv });
1161
- return ephemeralEnv[envVarName];
1160
+ if (process.env[envVarName]) {
1161
+ return process.env[envVarName];
1162
+ }
1163
+ const result = dotenv.config({
1164
+ path: [
1165
+ path4.resolve(process.cwd(), ".env"),
1166
+ path4.resolve(process.cwd(), ".env.local"),
1167
+ path4.resolve(process.cwd(), ".env.development")
1168
+ ]
1169
+ });
1170
+ return result?.parsed?.[envVarName];
1162
1171
  }
1163
1172
  function getKeyFromRc(rcPath) {
1164
1173
  const rc = getRc();
@@ -1721,10 +1730,10 @@ import traverse6 from "@babel/traverse";
1721
1730
  function findInvokations(ast, params) {
1722
1731
  const result = [];
1723
1732
  traverse6(ast, {
1724
- ImportDeclaration(path6) {
1725
- if (path6.node.source.value !== params.moduleName) return;
1733
+ ImportDeclaration(path7) {
1734
+ if (path7.node.source.value !== params.moduleName) return;
1726
1735
  const importNames = /* @__PURE__ */ new Map();
1727
- const specifiers = path6.node.specifiers;
1736
+ const specifiers = path7.node.specifiers;
1728
1737
  specifiers.forEach((specifier) => {
1729
1738
  if (t11.isImportSpecifier(specifier) && t11.isIdentifier(specifier.imported) && specifier.imported.name === params.functionName) {
1730
1739
  importNames.set(specifier.local.name, true);
@@ -1734,13 +1743,13 @@ function findInvokations(ast, params) {
1734
1743
  importNames.set(specifier.local.name, "namespace");
1735
1744
  }
1736
1745
  });
1737
- collectCallExpressions(path6, importNames, result, params.functionName);
1746
+ collectCallExpressions(path7, importNames, result, params.functionName);
1738
1747
  }
1739
1748
  });
1740
1749
  return result;
1741
1750
  }
1742
- function collectCallExpressions(path6, importNames, result, functionName) {
1743
- const program = path6.findParent(
1751
+ function collectCallExpressions(path7, importNames, result, functionName) {
1752
+ const program = path7.findParent(
1744
1753
  (p) => p.isProgram()
1745
1754
  );
1746
1755
  if (!program) return;
@@ -1850,18 +1859,18 @@ function jsxFragmentMutation(payload) {
1850
1859
  let foundFragments = false;
1851
1860
  let fragmentImportName = null;
1852
1861
  traverse7(ast, {
1853
- ImportDeclaration(path6) {
1854
- if (path6.node.source.value !== "react") return;
1855
- for (const specifier of path6.node.specifiers) {
1862
+ ImportDeclaration(path7) {
1863
+ if (path7.node.source.value !== "react") return;
1864
+ for (const specifier of path7.node.specifiers) {
1856
1865
  if (t14.isImportSpecifier(specifier) && t14.isIdentifier(specifier.imported) && specifier.imported.name === "Fragment") {
1857
1866
  fragmentImportName = specifier.local.name;
1858
- path6.stop();
1867
+ path7.stop();
1859
1868
  }
1860
1869
  }
1861
1870
  }
1862
1871
  });
1863
1872
  traverse7(ast, {
1864
- JSXFragment(path6) {
1873
+ JSXFragment(path7) {
1865
1874
  foundFragments = true;
1866
1875
  if (!fragmentImportName) {
1867
1876
  const result = getOrCreateImport(ast, {
@@ -1873,10 +1882,10 @@ function jsxFragmentMutation(payload) {
1873
1882
  const fragmentElement = t14.jsxElement(
1874
1883
  t14.jsxOpeningElement(t14.jsxIdentifier(fragmentImportName), [], false),
1875
1884
  t14.jsxClosingElement(t14.jsxIdentifier(fragmentImportName)),
1876
- path6.node.children,
1885
+ path7.node.children,
1877
1886
  false
1878
1887
  );
1879
- path6.replaceWith(fragmentElement);
1888
+ path7.replaceWith(fragmentElement);
1880
1889
  }
1881
1890
  });
1882
1891
  return payload;
@@ -1887,23 +1896,23 @@ import traverse8 from "@babel/traverse";
1887
1896
  import * as t15 from "@babel/types";
1888
1897
  var jsxHtmlLangMutation = createCodeMutation((payload) => {
1889
1898
  traverse8(payload.ast, {
1890
- JSXElement: (path6) => {
1891
- if (getJsxElementName(path6)?.toLowerCase() === "html") {
1899
+ JSXElement: (path7) => {
1900
+ if (getJsxElementName(path7)?.toLowerCase() === "html") {
1892
1901
  const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
1893
1902
  const packagePath = mode === "client" ? "lingo.dev/react/client" /* ReactClient */ : "lingo.dev/react/rsc" /* ReactRSC */;
1894
1903
  const lingoHtmlComponentImport = getOrCreateImport(payload.ast, {
1895
1904
  moduleName: packagePath,
1896
1905
  exportedName: "LingoHtmlComponent"
1897
1906
  });
1898
- path6.node.openingElement.name = t15.jsxIdentifier(
1907
+ path7.node.openingElement.name = t15.jsxIdentifier(
1899
1908
  lingoHtmlComponentImport.importedName
1900
1909
  );
1901
- if (path6.node.closingElement) {
1902
- path6.node.closingElement.name = t15.jsxIdentifier(
1910
+ if (path7.node.closingElement) {
1911
+ path7.node.closingElement.name = t15.jsxIdentifier(
1903
1912
  lingoHtmlComponentImport.importedName
1904
1913
  );
1905
1914
  }
1906
- path6.skip();
1915
+ path7.skip();
1907
1916
  }
1908
1917
  }
1909
1918
  });
@@ -1970,22 +1979,22 @@ var WHITESPACE_PLACEHOLDER = "[lingo-whitespace-placeholder]";
1970
1979
  function extractJsxContent(nodePath, replaceWhitespacePlaceholders = true) {
1971
1980
  const chunks = [];
1972
1981
  nodePath.traverse({
1973
- JSXElement(path6) {
1974
- if (path6.parent === nodePath.node) {
1975
- const content = extractJsxContent(path6, false);
1976
- const name = getJsxElementName(path6);
1982
+ JSXElement(path7) {
1983
+ if (path7.parent === nodePath.node) {
1984
+ const content = extractJsxContent(path7, false);
1985
+ const name = getJsxElementName(path7);
1977
1986
  chunks.push(`<element:${name}>${content}</element:${name}>`);
1978
- path6.skip();
1987
+ path7.skip();
1979
1988
  }
1980
1989
  },
1981
- JSXText(path6) {
1982
- chunks.push(path6.node.value);
1990
+ JSXText(path7) {
1991
+ chunks.push(path7.node.value);
1983
1992
  },
1984
- JSXExpressionContainer(path6) {
1985
- if (path6.parent !== nodePath.node) {
1993
+ JSXExpressionContainer(path7) {
1994
+ if (path7.parent !== nodePath.node) {
1986
1995
  return;
1987
1996
  }
1988
- const expr = path6.node.expression;
1997
+ const expr = path7.node.expression;
1989
1998
  if (t16.isCallExpression(expr)) {
1990
1999
  let key = "";
1991
2000
  if (t16.isIdentifier(expr.callee)) {
@@ -2031,12 +2040,12 @@ function extractJsxContent(nodePath, replaceWhitespacePlaceholders = true) {
2031
2040
  parts.unshift(current.name);
2032
2041
  chunks.push(`{${parts.join(".").replaceAll(".[", "[")}}`);
2033
2042
  }
2034
- } else if (isWhitespace(path6)) {
2043
+ } else if (isWhitespace(path7)) {
2035
2044
  chunks.push(WHITESPACE_PLACEHOLDER);
2036
- } else if (isExpression2(path6)) {
2045
+ } else if (isExpression2(path7)) {
2037
2046
  chunks.push("<expression/>");
2038
2047
  }
2039
- path6.skip();
2048
+ path7.skip();
2040
2049
  }
2041
2050
  });
2042
2051
  const result = chunks.join("");
@@ -2187,14 +2196,14 @@ import * as t18 from "@babel/types";
2187
2196
  var getJsxVariables = (nodePath) => {
2188
2197
  const variables = /* @__PURE__ */ new Set();
2189
2198
  nodePath.traverse({
2190
- JSXOpeningElement(path6) {
2191
- path6.skip();
2199
+ JSXOpeningElement(path7) {
2200
+ path7.skip();
2192
2201
  },
2193
- JSXExpressionContainer(path6) {
2194
- if (t18.isIdentifier(path6.node.expression)) {
2195
- variables.add(path6.node.expression.name);
2196
- } else if (t18.isMemberExpression(path6.node.expression)) {
2197
- let current = path6.node.expression;
2202
+ JSXExpressionContainer(path7) {
2203
+ if (t18.isIdentifier(path7.node.expression)) {
2204
+ variables.add(path7.node.expression.name);
2205
+ } else if (t18.isMemberExpression(path7.node.expression)) {
2206
+ let current = path7.node.expression;
2198
2207
  const parts = [];
2199
2208
  while (t18.isMemberExpression(current)) {
2200
2209
  if (t18.isIdentifier(current.property)) {
@@ -2211,7 +2220,7 @@ var getJsxVariables = (nodePath) => {
2211
2220
  variables.add(parts.join(".").replaceAll(".[", "["));
2212
2221
  }
2213
2222
  }
2214
- path6.skip();
2223
+ path7.skip();
2215
2224
  }
2216
2225
  });
2217
2226
  const properties = Array.from(variables).map(
@@ -2227,16 +2236,16 @@ var getJsxFunctions = (nodePath) => {
2227
2236
  const functions = /* @__PURE__ */ new Map();
2228
2237
  let fnCounter = 0;
2229
2238
  nodePath.traverse({
2230
- JSXOpeningElement(path6) {
2231
- path6.skip();
2239
+ JSXOpeningElement(path7) {
2240
+ path7.skip();
2232
2241
  },
2233
- JSXExpressionContainer(path6) {
2234
- if (t19.isCallExpression(path6.node.expression)) {
2242
+ JSXExpressionContainer(path7) {
2243
+ if (t19.isCallExpression(path7.node.expression)) {
2235
2244
  let key = "";
2236
- if (t19.isIdentifier(path6.node.expression.callee)) {
2237
- key = `${path6.node.expression.callee.name}`;
2238
- } else if (t19.isMemberExpression(path6.node.expression.callee)) {
2239
- let firstCallee = path6.node.expression.callee;
2245
+ if (t19.isIdentifier(path7.node.expression.callee)) {
2246
+ key = `${path7.node.expression.callee.name}`;
2247
+ } else if (t19.isMemberExpression(path7.node.expression.callee)) {
2248
+ let firstCallee = path7.node.expression.callee;
2240
2249
  while (t19.isMemberExpression(firstCallee) && t19.isCallExpression(firstCallee.object)) {
2241
2250
  firstCallee = firstCallee.object.callee;
2242
2251
  }
@@ -2257,10 +2266,10 @@ var getJsxFunctions = (nodePath) => {
2257
2266
  key = parts.join(".");
2258
2267
  }
2259
2268
  const existing = functions.get(key) ?? [];
2260
- functions.set(key, [...existing, path6.node.expression]);
2269
+ functions.set(key, [...existing, path7.node.expression]);
2261
2270
  fnCounter++;
2262
2271
  }
2263
- path6.skip();
2272
+ path7.skip();
2264
2273
  }
2265
2274
  });
2266
2275
  const properties = Array.from(functions.entries()).map(
@@ -2274,15 +2283,15 @@ import * as t20 from "@babel/types";
2274
2283
  var getJsxExpressions = (nodePath) => {
2275
2284
  const expressions = [];
2276
2285
  nodePath.traverse({
2277
- JSXOpeningElement(path6) {
2278
- path6.skip();
2286
+ JSXOpeningElement(path7) {
2287
+ path7.skip();
2279
2288
  },
2280
- JSXExpressionContainer(path6) {
2281
- const expr = path6.node.expression;
2289
+ JSXExpressionContainer(path7) {
2290
+ const expr = path7.node.expression;
2282
2291
  if (!t20.isJSXEmptyExpression(expr) && !t20.isIdentifier(expr) && !t20.isMemberExpression(expr) && !t20.isCallExpression(expr) && !(t20.isStringLiteral(expr) && expr.value === " ")) {
2283
2292
  expressions.push(expr);
2284
2293
  }
2285
- path6.skip();
2294
+ path7.skip();
2286
2295
  }
2287
2296
  });
2288
2297
  return t20.arrayExpression(expressions);
@@ -2407,8 +2416,8 @@ var jsxRemoveAttributesMutation = createCodeMutation(
2407
2416
  "data-jsx-attribute-scope"
2408
2417
  ];
2409
2418
  traverse9(payload.ast, {
2410
- JSXElement(path6) {
2411
- const openingElement = path6.node.openingElement;
2419
+ JSXElement(path7) {
2420
+ const openingElement = path7.node.openingElement;
2412
2421
  openingElement.attributes = openingElement.attributes.filter((attr) => {
2413
2422
  const removeAttr = t22.isJSXAttribute(attr) && t22.isJSXIdentifier(attr.name) && ATTRIBUTES_TO_REMOVE.includes(attr.name.name);
2414
2423
  return !removeAttr;
@@ -2422,18 +2431,18 @@ var jsxRemoveAttributesMutation = createCodeMutation(
2422
2431
  );
2423
2432
 
2424
2433
  // src/client-dictionary-loader.ts
2425
- import path4 from "path";
2434
+ import path5 from "path";
2426
2435
  import * as t23 from "@babel/types";
2427
2436
  var clientDictionaryLoaderMutation = createCodeMutation((payload) => {
2428
- const lingoDir = path4.resolve(
2437
+ const lingoDir = path5.resolve(
2429
2438
  process.cwd(),
2430
2439
  payload.params.sourceRoot,
2431
2440
  payload.params.lingoDir
2432
2441
  );
2433
- const currentDir = path4.dirname(
2434
- path4.resolve(process.cwd(), payload.params.sourceRoot, payload.fileKey)
2442
+ const currentDir = path5.dirname(
2443
+ path5.resolve(process.cwd(), payload.params.sourceRoot, payload.fileKey)
2435
2444
  );
2436
- const relativeLingoPath = path4.relative(currentDir, lingoDir);
2445
+ const relativeLingoPath = path5.relative(currentDir, lingoDir);
2437
2446
  const invokations = findInvokations(payload.ast, {
2438
2447
  moduleName: "lingo.dev/react/client" /* ReactClient */,
2439
2448
  functionName: "loadDictionary"
@@ -2543,7 +2552,7 @@ var unplugin = createUnplugin(
2543
2552
  const result = _11.chain({
2544
2553
  code,
2545
2554
  params,
2546
- fileKey: path5.relative(path5.resolve(process.cwd(), params.sourceRoot), id).split(path5.sep).join("/")
2555
+ fileKey: path6.relative(path6.resolve(process.cwd(), params.sourceRoot), id).split(path6.sep).join("/")
2547
2556
  // Always normalize for consistent dictionaries
2548
2557
  }).thru(createPayload).thru(
2549
2558
  composeMutations(
@@ -2614,8 +2623,8 @@ function validateLLMKeyDetails(models) {
2614
2623
  const details = providerDetails[providerId];
2615
2624
  const checkers = keyCheckers[providerId];
2616
2625
  if (!details || !checkers) continue;
2617
- const foundInEnv = checkers.checkEnv() !== void 0;
2618
- const foundInRc = checkers.checkRc() !== void 0;
2626
+ const foundInEnv = !!checkers.checkEnv();
2627
+ const foundInRc = !!checkers.checkRc();
2619
2628
  keyStatuses[providerId] = { foundInEnv, foundInRc, details };
2620
2629
  if (!foundInEnv && !foundInRc) {
2621
2630
  missingProviders.push(providerId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingo.dev/_compiler",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Lingo.dev Compiler",
5
5
  "private": false,
6
6
  "publishConfig": {