@lingo.dev/_compiler 0.6.2 → 0.7.0

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.
@@ -1677,19 +1677,42 @@ function isWhitespace(nodePath) {
1677
1677
  return t22.isStringLiteral(expr) && expr.value === " ";
1678
1678
  }
1679
1679
  function normalizeJsxWhitespace(input) {
1680
+ if (!input.includes("\n")) {
1681
+ const trimmed = input.trim();
1682
+ if (trimmed.length === 0) return "";
1683
+ const leadingMatch = input.match(/^\s*/);
1684
+ const trailingMatch = input.match(/\s*$/);
1685
+ const leadingSpaces = leadingMatch ? leadingMatch[0].length : 0;
1686
+ const trailingSpaces = trailingMatch ? trailingMatch[0].length : 0;
1687
+ if (leadingSpaces > 1 || trailingSpaces > 1) {
1688
+ return input.replace(/\s+/g, " ").trim();
1689
+ } else {
1690
+ return input.replace(/\s{2,}/g, " ");
1691
+ }
1692
+ }
1680
1693
  const lines = input.split("\n");
1681
1694
  let result = "";
1682
1695
  for (let i = 0; i < lines.length; i++) {
1683
- const line = lines[i].trim();
1684
- if (line === "") continue;
1685
- if (i > 0 && (line.startsWith("<element:") || line.startsWith("<function:") || line.startsWith("{") || line.startsWith("<expression/>"))) {
1686
- result += line;
1696
+ const line = lines[i];
1697
+ const trimmedLine = line.trim();
1698
+ if (trimmedLine === "") continue;
1699
+ if (trimmedLine.includes(WHITESPACE_PLACEHOLDER)) {
1700
+ result += trimmedLine;
1701
+ } else if (trimmedLine.startsWith("<element:") || trimmedLine.startsWith("<function:") || trimmedLine.startsWith("{") || trimmedLine.startsWith("<expression/>")) {
1702
+ const shouldAddSpace = result && !result.endsWith(" ") && !result.endsWith(WHITESPACE_PLACEHOLDER) && /\w$/.test(result) && // Check if element content starts with space by looking for "> " pattern
1703
+ trimmedLine.includes("> ");
1704
+ if (shouldAddSpace) {
1705
+ result += " ";
1706
+ }
1707
+ result += trimmedLine;
1687
1708
  } else {
1688
- if (result && !result.endsWith(" ")) result += " ";
1689
- result += line;
1709
+ if (result && !result.endsWith(" ") && !result.endsWith(WHITESPACE_PLACEHOLDER)) {
1710
+ result += " ";
1711
+ }
1712
+ result += trimmedLine;
1690
1713
  }
1691
1714
  }
1692
- result = result.replace(/\s+/g, " ");
1715
+ result = result.replace(/\s{2,}/g, " ");
1693
1716
  return result.trim();
1694
1717
  }
1695
1718
 
@@ -1677,19 +1677,42 @@ function isWhitespace(nodePath) {
1677
1677
  return t22.isStringLiteral(expr) && expr.value === " ";
1678
1678
  }
1679
1679
  function normalizeJsxWhitespace(input) {
1680
+ if (!input.includes("\n")) {
1681
+ const trimmed = input.trim();
1682
+ if (trimmed.length === 0) return "";
1683
+ const leadingMatch = input.match(/^\s*/);
1684
+ const trailingMatch = input.match(/\s*$/);
1685
+ const leadingSpaces = leadingMatch ? leadingMatch[0].length : 0;
1686
+ const trailingSpaces = trailingMatch ? trailingMatch[0].length : 0;
1687
+ if (leadingSpaces > 1 || trailingSpaces > 1) {
1688
+ return input.replace(/\s+/g, " ").trim();
1689
+ } else {
1690
+ return input.replace(/\s{2,}/g, " ");
1691
+ }
1692
+ }
1680
1693
  const lines = input.split("\n");
1681
1694
  let result = "";
1682
1695
  for (let i = 0; i < lines.length; i++) {
1683
- const line = lines[i].trim();
1684
- if (line === "") continue;
1685
- if (i > 0 && (line.startsWith("<element:") || line.startsWith("<function:") || line.startsWith("{") || line.startsWith("<expression/>"))) {
1686
- result += line;
1696
+ const line = lines[i];
1697
+ const trimmedLine = line.trim();
1698
+ if (trimmedLine === "") continue;
1699
+ if (trimmedLine.includes(WHITESPACE_PLACEHOLDER)) {
1700
+ result += trimmedLine;
1701
+ } else if (trimmedLine.startsWith("<element:") || trimmedLine.startsWith("<function:") || trimmedLine.startsWith("{") || trimmedLine.startsWith("<expression/>")) {
1702
+ const shouldAddSpace = result && !result.endsWith(" ") && !result.endsWith(WHITESPACE_PLACEHOLDER) && /\w$/.test(result) && // Check if element content starts with space by looking for "> " pattern
1703
+ trimmedLine.includes("> ");
1704
+ if (shouldAddSpace) {
1705
+ result += " ";
1706
+ }
1707
+ result += trimmedLine;
1687
1708
  } else {
1688
- if (result && !result.endsWith(" ")) result += " ";
1689
- result += line;
1709
+ if (result && !result.endsWith(" ") && !result.endsWith(WHITESPACE_PLACEHOLDER)) {
1710
+ result += " ";
1711
+ }
1712
+ result += trimmedLine;
1690
1713
  }
1691
1714
  }
1692
- result = result.replace(/\s+/g, " ");
1715
+ result = result.replace(/\s{2,}/g, " ");
1693
1716
  return result.trim();
1694
1717
  }
1695
1718
 
package/build/index.cjs CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
 
19
19
 
20
- var _chunk6E2XDW5Xcjs = require('./chunk-6E2XDW5X.cjs');
20
+ var _chunk6W6K5RIWcjs = require('./chunk-6W6K5RIW.cjs');
21
21
 
22
22
  // src/index.ts
23
23
  var _unplugin = require('unplugin');
@@ -25,7 +25,7 @@ var _unplugin = require('unplugin');
25
25
  // package.json
26
26
  var package_default = {
27
27
  name: "@lingo.dev/_compiler",
28
- version: "0.6.2",
28
+ version: "0.7.0",
29
29
  description: "Lingo.dev Compiler",
30
30
  private: false,
31
31
  publishConfig: {
@@ -131,7 +131,7 @@ async function trackEvent(event, properties) {
131
131
  }
132
132
  }
133
133
  async function getActualId() {
134
- const rc = _chunk6E2XDW5Xcjs.getRc.call(void 0, );
134
+ const rc = _chunk6W6K5RIWcjs.getRc.call(void 0, );
135
135
  const apiKey = process.env.LINGODOTDEV_API_KEY || _optionalChain([rc, 'optionalAccess', _3 => _3.auth, 'optionalAccess', _4 => _4.apiKey]);
136
136
  const apiUrl = process.env.LINGODOTDEV_API_URL || _optionalChain([rc, 'optionalAccess', _5 => _5.auth, 'optionalAccess', _6 => _6.apiUrl]) || "https://engine.lingo.dev";
137
137
  if (apiKey) {
@@ -159,20 +159,20 @@ async function getActualId() {
159
159
  // src/index.ts
160
160
  var keyCheckers = {
161
161
  groq: {
162
- checkEnv: _chunk6E2XDW5Xcjs.getGroqKeyFromEnv,
163
- checkRc: _chunk6E2XDW5Xcjs.getGroqKeyFromRc
162
+ checkEnv: _chunk6W6K5RIWcjs.getGroqKeyFromEnv,
163
+ checkRc: _chunk6W6K5RIWcjs.getGroqKeyFromRc
164
164
  },
165
165
  google: {
166
- checkEnv: _chunk6E2XDW5Xcjs.getGoogleKeyFromEnv,
167
- checkRc: _chunk6E2XDW5Xcjs.getGoogleKeyFromRc
166
+ checkEnv: _chunk6W6K5RIWcjs.getGoogleKeyFromEnv,
167
+ checkRc: _chunk6W6K5RIWcjs.getGoogleKeyFromRc
168
168
  },
169
169
  mistral: {
170
- checkEnv: _chunk6E2XDW5Xcjs.getMistralKeyFromEnv,
171
- checkRc: _chunk6E2XDW5Xcjs.getMistralKeyFromRc
170
+ checkEnv: _chunk6W6K5RIWcjs.getMistralKeyFromEnv,
171
+ checkRc: _chunk6W6K5RIWcjs.getMistralKeyFromRc
172
172
  },
173
173
  "lingo.dev": {
174
- checkEnv: _chunk6E2XDW5Xcjs.getLingoDotDevKeyFromEnv,
175
- checkRc: _chunk6E2XDW5Xcjs.getLingoDotDevKeyFromRc
174
+ checkEnv: _chunk6W6K5RIWcjs.getLingoDotDevKeyFromEnv,
175
+ checkRc: _chunk6W6K5RIWcjs.getLingoDotDevKeyFromRc
176
176
  }
177
177
  };
178
178
  var alreadySentBuildEvent = { value: false };
@@ -188,14 +188,14 @@ function sendBuildEvent(framework, config, isDev) {
188
188
  var unplugin = _unplugin.createUnplugin.call(void 0,
189
189
  (_params, _meta) => {
190
190
  console.log("\u2139\uFE0F Starting Lingo.dev compiler...");
191
- const params = _lodash2.default.defaults(_params, _chunk6E2XDW5Xcjs.defaultParams);
192
- if (!_chunk6E2XDW5Xcjs.isRunningInCIOrDocker.call(void 0, )) {
191
+ const params = _lodash2.default.defaults(_params, _chunk6W6K5RIWcjs.defaultParams);
192
+ if (!_chunk6W6K5RIWcjs.isRunningInCIOrDocker.call(void 0, )) {
193
193
  if (params.models === "lingo.dev") {
194
194
  validateLLMKeyDetails(["lingo.dev"]);
195
195
  } else {
196
196
  const configuredProviders = getConfiguredProviders(params.models);
197
197
  validateLLMKeyDetails(configuredProviders);
198
- const invalidLocales = _chunk6E2XDW5Xcjs.getInvalidLocales.call(void 0,
198
+ const invalidLocales = _chunk6W6K5RIWcjs.getInvalidLocales.call(void 0,
199
199
  params.models,
200
200
  params.sourceLocale,
201
201
  params.targetLocales
@@ -218,7 +218,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
218
218
  }
219
219
  }
220
220
  }
221
- _chunk6E2XDW5Xcjs.LCPCache.ensureDictionaryFile({
221
+ _chunk6W6K5RIWcjs.LCPCache.ensureDictionaryFile({
222
222
  sourceRoot: params.sourceRoot,
223
223
  lingoDir: params.lingoDir
224
224
  });
@@ -226,9 +226,9 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
226
226
  sendBuildEvent("unplugin", params, isDev);
227
227
  return {
228
228
  name: package_default.name,
229
- loadInclude: (id) => !!id.match(_chunk6E2XDW5Xcjs.LCP_DICTIONARY_FILE_NAME),
229
+ loadInclude: (id) => !!id.match(_chunk6W6K5RIWcjs.LCP_DICTIONARY_FILE_NAME),
230
230
  async load(id) {
231
- const dictionary = await _chunk6E2XDW5Xcjs.loadDictionary.call(void 0, {
231
+ const dictionary = await _chunk6W6K5RIWcjs.loadDictionary.call(void 0, {
232
232
  resourcePath: id,
233
233
  resourceQuery: "",
234
234
  params: {
@@ -252,7 +252,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
252
252
  enforce: "pre",
253
253
  transform(code, id) {
254
254
  try {
255
- const result = _chunk6E2XDW5Xcjs.transformComponent.call(void 0, {
255
+ const result = _chunk6W6K5RIWcjs.transformComponent.call(void 0, {
256
256
  code,
257
257
  params,
258
258
  resourcePath: id,
@@ -272,7 +272,7 @@ var src_default = {
272
272
  next: (compilerParams) => (nextConfig = {}) => {
273
273
  const mergedParams = _lodash2.default.merge(
274
274
  {},
275
- _chunk6E2XDW5Xcjs.defaultParams,
275
+ _chunk6W6K5RIWcjs.defaultParams,
276
276
  {
277
277
  rsc: true,
278
278
  turbopack: {
@@ -323,7 +323,7 @@ var src_default = {
323
323
  turbopackConfigPath.rules ??= {};
324
324
  const rules = turbopackConfigPath.rules;
325
325
  const lingoGlob = `**/*.{ts,tsx,js,jsx}`;
326
- const lingoLoaderPath = _chunk6E2XDW5Xcjs.__require.resolve("./lingo-turbopack-loader");
326
+ const lingoLoaderPath = _chunk6W6K5RIWcjs.__require.resolve("./lingo-turbopack-loader");
327
327
  rules[lingoGlob] = {
328
328
  loaders: [
329
329
  {
@@ -338,7 +338,7 @@ var src_default = {
338
338
  vite: (compilerParams) => (config) => {
339
339
  const mergedParams = _lodash2.default.merge(
340
340
  {},
341
- _chunk6E2XDW5Xcjs.defaultParams,
341
+ _chunk6W6K5RIWcjs.defaultParams,
342
342
  { rsc: false },
343
343
  compilerParams
344
344
  );
@@ -352,7 +352,7 @@ var src_default = {
352
352
  };
353
353
  function getConfiguredProviders(models) {
354
354
  return _lodash2.default.chain(Object.values(models)).map((modelString) => modelString.split(":")[0]).filter(Boolean).uniq().filter(
355
- (providerId) => _chunk6E2XDW5Xcjs.providerDetails.hasOwnProperty(providerId) && keyCheckers.hasOwnProperty(providerId)
355
+ (providerId) => _chunk6W6K5RIWcjs.providerDetails.hasOwnProperty(providerId) && keyCheckers.hasOwnProperty(providerId)
356
356
  ).value();
357
357
  }
358
358
  function validateLLMKeyDetails(configuredProviders) {
@@ -363,7 +363,7 @@ function validateLLMKeyDetails(configuredProviders) {
363
363
  const missingProviders = [];
364
364
  const foundProviders = [];
365
365
  for (const providerId of configuredProviders) {
366
- const details = _chunk6E2XDW5Xcjs.providerDetails[providerId];
366
+ const details = _chunk6W6K5RIWcjs.providerDetails[providerId];
367
367
  const checkers = keyCheckers[providerId];
368
368
  if (!details || !checkers) continue;
369
369
  const foundInEnv = !!checkers.checkEnv();
package/build/index.mjs CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  loadDictionary,
18
18
  providerDetails,
19
19
  transformComponent
20
- } from "./chunk-MMSXDFQL.mjs";
20
+ } from "./chunk-2HDSJRXT.mjs";
21
21
 
22
22
  // src/index.ts
23
23
  import { createUnplugin } from "unplugin";
@@ -25,7 +25,7 @@ import { createUnplugin } from "unplugin";
25
25
  // package.json
26
26
  var package_default = {
27
27
  name: "@lingo.dev/_compiler",
28
- version: "0.6.2",
28
+ version: "0.7.0",
29
29
  description: "Lingo.dev Compiler",
30
30
  private: false,
31
31
  publishConfig: {
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunk6E2XDW5Xcjs = require('./chunk-6E2XDW5X.cjs');
4
+ var _chunk6W6K5RIWcjs = require('./chunk-6W6K5RIW.cjs');
5
5
 
6
6
  // src/lingo-turbopack-loader.ts
7
7
  async function lingo_turbopack_loader_default(source) {
@@ -9,7 +9,7 @@ async function lingo_turbopack_loader_default(source) {
9
9
  const params = this.getOptions();
10
10
  const isDev = process.env.NODE_ENV !== "production";
11
11
  try {
12
- const dictionary = await _chunk6E2XDW5Xcjs.loadDictionary.call(void 0, {
12
+ const dictionary = await _chunk6W6K5RIWcjs.loadDictionary.call(void 0, {
13
13
  resourcePath: this.resourcePath,
14
14
  resourceQuery: this.resourceQuery,
15
15
  params,
@@ -21,7 +21,7 @@ async function lingo_turbopack_loader_default(source) {
21
21
  const code = `export default ${JSON.stringify(dictionary, null, 2)};`;
22
22
  return callback(null, code);
23
23
  }
24
- const result = _chunk6E2XDW5Xcjs.transformComponent.call(void 0, {
24
+ const result = _chunk6W6K5RIWcjs.transformComponent.call(void 0, {
25
25
  code: source,
26
26
  params,
27
27
  resourcePath: this.resourcePath,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  loadDictionary,
3
3
  transformComponent
4
- } from "./chunk-MMSXDFQL.mjs";
4
+ } from "./chunk-2HDSJRXT.mjs";
5
5
 
6
6
  // src/lingo-turbopack-loader.ts
7
7
  async function lingo_turbopack_loader_default(source) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingo.dev/_compiler",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Lingo.dev Compiler",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -52,8 +52,8 @@
52
52
  "zod": "^3.25.76",
53
53
  "posthog-node": "^4.17.0",
54
54
  "node-machine-id": "^1.1.12",
55
- "@lingo.dev/_sdk": "0.10.1",
56
- "@lingo.dev/_spec": "0.39.2"
55
+ "@lingo.dev/_sdk": "0.10.2",
56
+ "@lingo.dev/_spec": "0.39.3"
57
57
  },
58
58
  "scripts": {
59
59
  "dev": "tsup --watch",