@lingo.dev/_compiler 0.1.4 → 0.1.6

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.4",
7
+ version: "0.1.6",
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;
@@ -1513,12 +1513,15 @@ var LCPServer = (_class = class {
1513
1513
  const files = _lodash2.default.call(void 0, fileNames).map((fileName) => {
1514
1514
  const sourceFile = _lodash2.default.get(sourceDictionary.files, fileName);
1515
1515
  const targetFile = _lodash2.default.get(targetDictionary.files, fileName);
1516
- 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(
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]) || {};
1517
1520
  return [
1518
1521
  fileName,
1519
1522
  {
1520
1523
  ...targetFile,
1521
- entries: _lodash2.default.merge(_optionalChain([targetFile, 'optionalAccess', _32 => _32.entries]), entries)
1524
+ entries: _lodash2.default.merge(_optionalChain([targetFile, 'optionalAccess', _44 => _44.entries]) || {}, entries)
1522
1525
  }
1523
1526
  ];
1524
1527
  }).fromPairs().value();
@@ -1710,7 +1713,7 @@ function jsxFragmentMutation(payload) {
1710
1713
  var jsxHtmlLangMutation = createCodeMutation((payload) => {
1711
1714
  _traverse2.default.call(void 0, payload.ast, {
1712
1715
  JSXElement: (path6) => {
1713
- if (_optionalChain([getJsxElementName, 'call', _33 => _33(path6), 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35()]) === "html") {
1716
+ if (_optionalChain([getJsxElementName, 'call', _45 => _45(path6), 'optionalAccess', _46 => _46.toLowerCase, 'call', _47 => _47()]) === "html") {
1714
1717
  const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
1715
1718
  const packagePath = mode === "client" ? "lingo.dev/react/client" /* ReactClient */ : "lingo.dev/react/rsc" /* ReactRSC */;
1716
1719
  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.4",
7
+ version: "0.1.6",
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);
@@ -1513,12 +1513,15 @@ var LCPServer = class {
1513
1513
  const files = _7(fileNames).map((fileName) => {
1514
1514
  const sourceFile = _7.get(sourceDictionary.files, fileName);
1515
1515
  const targetFile = _7.get(targetDictionary.files, fileName);
1516
- const entries = removeEmptyEntries ? _7.pickBy(sourceFile?.entries, (value) => value.trim().length > 0) : sourceFile?.entries;
1516
+ const entries = removeEmptyEntries ? _7.pickBy(
1517
+ sourceFile?.entries || {},
1518
+ (value) => String(value || "")?.trim?.()?.length > 0
1519
+ ) : sourceFile?.entries || {};
1517
1520
  return [
1518
1521
  fileName,
1519
1522
  {
1520
1523
  ...targetFile,
1521
- entries: _7.merge(targetFile?.entries, entries)
1524
+ entries: _7.merge(targetFile?.entries || {}, entries)
1522
1525
  }
1523
1526
  ];
1524
1527
  }).fromPairs().value();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingo.dev/_compiler",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Lingo.dev Compiler",
5
5
  "private": false,
6
6
  "publishConfig": {