@lingo.dev/_compiler 0.1.3 → 0.1.5

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.3",
7
+ version: "0.1.5",
8
8
  description: "Lingo.dev Compiler",
9
9
  private: false,
10
10
  publishConfig: {
@@ -450,13 +450,13 @@ function getJsxScopes(node) {
450
450
  _traverse2.default.call(void 0, node, {
451
451
  JSXElement(path6) {
452
452
  const hasNonEmptyTextSiblings = path6.getAllPrevSiblings().concat(path6.getAllNextSiblings()).some(
453
- (sibling) => t7.isJSXText(sibling.node) && sibling.node.value.trim() !== ""
453
+ (sibling) => t7.isJSXText(sibling.node) && _optionalChain([sibling, 'access', _16 => _16.node, 'access', _17 => _17.value, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]) !== ""
454
454
  );
455
455
  if (hasNonEmptyTextSiblings) {
456
456
  return;
457
457
  }
458
458
  const hasNonEmptyTextChild = path6.get("children").some(
459
- (child) => t7.isJSXText(child.node) && child.node.value.trim() !== ""
459
+ (child) => t7.isJSXText(child.node) && _optionalChain([child, 'access', _20 => _20.node, 'access', _21 => _21.value, 'optionalAccess', _22 => _22.trim, 'call', _23 => _23()]) !== ""
460
460
  );
461
461
  if (hasNonEmptyTextChild) {
462
462
  result.push(path6);
@@ -693,10 +693,10 @@ var LCP = class _LCP {
693
693
  return this._setScopeField(fileKey, scopeKey, "content", content);
694
694
  }
695
695
  toJSON() {
696
- const files = _lodash2.default.call(void 0, _optionalChain([this, 'access', _16 => _16.data, 'optionalAccess', _17 => _17.files])).mapValues((file, fileName) => {
696
+ const files = _lodash2.default.call(void 0, _optionalChain([this, 'access', _24 => _24.data, 'optionalAccess', _25 => _25.files])).mapValues((file, fileName) => {
697
697
  return {
698
698
  ...file,
699
- scopes: _lodash2.default.call(void 0, _optionalChain([file, 'optionalAccess', _18 => _18.scopes])).toPairs().sortBy([0]).fromPairs().value()
699
+ scopes: _lodash2.default.call(void 0, _optionalChain([file, 'optionalAccess', _26 => _26.scopes])).toPairs().sortBy([0]).fromPairs().value()
700
700
  };
701
701
  }).toPairs().sortBy([0]).fromPairs().value();
702
702
  return { ...this.data, files };
@@ -831,7 +831,7 @@ var LCPCache = class {
831
831
  const config2 = await prettier.resolveConfig(cachePath);
832
832
  const prettierOptions = {
833
833
  ..._nullishCoalesce(config2, () => ( {})),
834
- parser: _optionalChain([config2, 'optionalAccess', _19 => _19.parser]) ? config2.parser : "typescript"
834
+ parser: _optionalChain([config2, 'optionalAccess', _27 => _27.parser]) ? config2.parser : "typescript"
835
835
  };
836
836
  return await prettier.format(cachedContent, prettierOptions);
837
837
  } catch (error) {
@@ -895,7 +895,7 @@ function getLocaleModel(localeModels, sourceLocale, targetLocale) {
895
895
  ];
896
896
  const modelKey = localeKeys.find((key) => localeModels.hasOwnProperty(key));
897
897
  if (modelKey) {
898
- const [provider, model] = _optionalChain([localeModels, 'access', _20 => _20[modelKey], 'optionalAccess', _21 => _21.split, 'call', _22 => _22(":")]);
898
+ const [provider, model] = _optionalChain([localeModels, 'access', _28 => _28[modelKey], 'optionalAccess', _29 => _29.split, 'call', _30 => _30(":")]);
899
899
  if (provider && model) {
900
900
  return { provider, model };
901
901
  }
@@ -908,7 +908,7 @@ var prompt_default = (args) => {
908
908
  return getUserSystemPrompt(args) || getBuiltInSystemPrompt(args);
909
909
  };
910
910
  function getUserSystemPrompt(args) {
911
- const userPrompt = _optionalChain([args, 'access', _23 => _23.prompt, 'optionalAccess', _24 => _24.trim, 'call', _25 => _25(), 'optionalAccess', _26 => _26.replace, 'call', _27 => _27("{SOURCE_LOCALE}", args.sourceLocale), 'optionalAccess', _28 => _28.replace, 'call', _29 => _29("{TARGET_LOCALE}", args.targetLocale)]);
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)]);
912
912
  if (userPrompt) {
913
913
  console.log("\u2728 Compiler is using user-defined prompt.");
914
914
  return userPrompt;
@@ -1115,9 +1115,7 @@ function getGroqKeyFromRc() {
1115
1115
  return result;
1116
1116
  }
1117
1117
  function getGroqKeyFromEnv() {
1118
- const ephemeralEnv = {
1119
- GROQ_API_KEY: process.env.GROQ_API_KEY
1120
- };
1118
+ const ephemeralEnv = {};
1121
1119
  dotenv.config({ processEnv: ephemeralEnv });
1122
1120
  return ephemeralEnv.GROQ_API_KEY;
1123
1121
  }
@@ -1515,12 +1513,12 @@ var LCPServer = (_class = class {
1515
1513
  const files = _lodash2.default.call(void 0, fileNames).map((fileName) => {
1516
1514
  const sourceFile = _lodash2.default.get(sourceDictionary.files, fileName);
1517
1515
  const targetFile = _lodash2.default.get(targetDictionary.files, fileName);
1518
- const entries = removeEmptyEntries ? _lodash2.default.pickBy(_optionalChain([sourceFile, 'optionalAccess', _30 => _30.entries]), (value) => value.trim().length > 0) : _optionalChain([sourceFile, 'optionalAccess', _31 => _31.entries]);
1516
+ const entries = removeEmptyEntries ? _lodash2.default.pickBy(_optionalChain([sourceFile, 'optionalAccess', _38 => _38.entries]), (value) => _optionalChain([value, 'optionalAccess', _39 => _39.trim, 'call', _40 => _40(), 'optionalAccess', _41 => _41.length]) > 0) : _optionalChain([sourceFile, 'optionalAccess', _42 => _42.entries]);
1519
1517
  return [
1520
1518
  fileName,
1521
1519
  {
1522
1520
  ...targetFile,
1523
- entries: _lodash2.default.merge(_optionalChain([targetFile, 'optionalAccess', _32 => _32.entries]), entries)
1521
+ entries: _lodash2.default.merge(_optionalChain([targetFile, 'optionalAccess', _43 => _43.entries]), entries)
1524
1522
  }
1525
1523
  ];
1526
1524
  }).fromPairs().value();
@@ -1712,7 +1710,7 @@ function jsxFragmentMutation(payload) {
1712
1710
  var jsxHtmlLangMutation = createCodeMutation((payload) => {
1713
1711
  _traverse2.default.call(void 0, payload.ast, {
1714
1712
  JSXElement: (path6) => {
1715
- if (_optionalChain([getJsxElementName, 'call', _33 => _33(path6), 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35()]) === "html") {
1713
+ if (_optionalChain([getJsxElementName, 'call', _44 => _44(path6), 'optionalAccess', _45 => _45.toLowerCase, 'call', _46 => _46()]) === "html") {
1716
1714
  const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
1717
1715
  const packagePath = mode === "client" ? "lingo.dev/react/client" /* ReactClient */ : "lingo.dev/react/rsc" /* ReactRSC */;
1718
1716
  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.3",
7
+ version: "0.1.5",
8
8
  description: "Lingo.dev Compiler",
9
9
  private: false,
10
10
  publishConfig: {
@@ -450,13 +450,13 @@ function getJsxScopes(node) {
450
450
  traverse4(node, {
451
451
  JSXElement(path6) {
452
452
  const hasNonEmptyTextSiblings = path6.getAllPrevSiblings().concat(path6.getAllNextSiblings()).some(
453
- (sibling) => t7.isJSXText(sibling.node) && sibling.node.value.trim() !== ""
453
+ (sibling) => t7.isJSXText(sibling.node) && sibling.node.value?.trim() !== ""
454
454
  );
455
455
  if (hasNonEmptyTextSiblings) {
456
456
  return;
457
457
  }
458
458
  const hasNonEmptyTextChild = path6.get("children").some(
459
- (child) => t7.isJSXText(child.node) && child.node.value.trim() !== ""
459
+ (child) => t7.isJSXText(child.node) && child.node.value?.trim() !== ""
460
460
  );
461
461
  if (hasNonEmptyTextChild) {
462
462
  result.push(path6);
@@ -1115,9 +1115,7 @@ function getGroqKeyFromRc() {
1115
1115
  return result;
1116
1116
  }
1117
1117
  function getGroqKeyFromEnv() {
1118
- const ephemeralEnv = {
1119
- GROQ_API_KEY: process.env.GROQ_API_KEY
1120
- };
1118
+ const ephemeralEnv = {};
1121
1119
  dotenv.config({ processEnv: ephemeralEnv });
1122
1120
  return ephemeralEnv.GROQ_API_KEY;
1123
1121
  }
@@ -1515,7 +1513,7 @@ var LCPServer = class {
1515
1513
  const files = _7(fileNames).map((fileName) => {
1516
1514
  const sourceFile = _7.get(sourceDictionary.files, fileName);
1517
1515
  const targetFile = _7.get(targetDictionary.files, fileName);
1518
- const entries = removeEmptyEntries ? _7.pickBy(sourceFile?.entries, (value) => value.trim().length > 0) : sourceFile?.entries;
1516
+ const entries = removeEmptyEntries ? _7.pickBy(sourceFile?.entries, (value) => value?.trim()?.length > 0) : sourceFile?.entries;
1519
1517
  return [
1520
1518
  fileName,
1521
1519
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingo.dev/_compiler",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Lingo.dev Compiler",
5
5
  "private": false,
6
6
  "publishConfig": {