@lingo.dev/_compiler 0.5.5 → 0.6.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.
- package/build/{chunk-PO4OCL2U.cjs → chunk-6E2XDW5X.cjs} +7 -0
- package/build/{chunk-ZXNG22MO.mjs → chunk-MMSXDFQL.mjs} +7 -0
- package/build/index.cjs +24 -23
- package/build/index.d.cts +38 -3
- package/build/index.d.ts +38 -3
- package/build/index.mjs +3 -2
- package/build/lingo-turbopack-loader.cjs +3 -3
- package/build/lingo-turbopack-loader.mjs +1 -1
- package/package.json +3 -2
|
@@ -356,6 +356,13 @@ var providerDetails = {
|
|
|
356
356
|
apiKeyConfigKey: "llm.mistralApiKey",
|
|
357
357
|
getKeyLink: "https://console.mistral.ai",
|
|
358
358
|
docsLink: "https://docs.mistral.ai"
|
|
359
|
+
},
|
|
360
|
+
"lingo.dev": {
|
|
361
|
+
name: "Lingo.dev",
|
|
362
|
+
apiKeyEnvVar: "LINGO_API_KEY",
|
|
363
|
+
apiKeyConfigKey: "auth.apiKey",
|
|
364
|
+
getKeyLink: "https://lingo.dev",
|
|
365
|
+
docsLink: "https://lingo.dev/docs"
|
|
359
366
|
}
|
|
360
367
|
};
|
|
361
368
|
|
|
@@ -356,6 +356,13 @@ var providerDetails = {
|
|
|
356
356
|
apiKeyConfigKey: "llm.mistralApiKey",
|
|
357
357
|
getKeyLink: "https://console.mistral.ai",
|
|
358
358
|
docsLink: "https://docs.mistral.ai"
|
|
359
|
+
},
|
|
360
|
+
"lingo.dev": {
|
|
361
|
+
name: "Lingo.dev",
|
|
362
|
+
apiKeyEnvVar: "LINGO_API_KEY",
|
|
363
|
+
apiKeyConfigKey: "auth.apiKey",
|
|
364
|
+
getKeyLink: "https://lingo.dev",
|
|
365
|
+
docsLink: "https://lingo.dev/docs"
|
|
359
366
|
}
|
|
360
367
|
};
|
|
361
368
|
|
package/build/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunk6E2XDW5Xcjs = require('./chunk-6E2XDW5X.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.
|
|
28
|
+
version: "0.6.1",
|
|
29
29
|
description: "Lingo.dev Compiler",
|
|
30
30
|
private: false,
|
|
31
31
|
publishConfig: {
|
|
@@ -69,6 +69,7 @@ var package_default = {
|
|
|
69
69
|
"@babel/traverse": "^7.27.4",
|
|
70
70
|
"@babel/types": "^7.26.7",
|
|
71
71
|
"@lingo.dev/_sdk": "workspace:*",
|
|
72
|
+
"@lingo.dev/_spec": "workspace:*",
|
|
72
73
|
"@openrouter/ai-sdk-provider": "^0.7.1",
|
|
73
74
|
"@prettier/sync": "^0.6.1",
|
|
74
75
|
ai: "^4.2.10",
|
|
@@ -130,7 +131,7 @@ async function trackEvent(event, properties) {
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
async function getActualId() {
|
|
133
|
-
const rc =
|
|
134
|
+
const rc = _chunk6E2XDW5Xcjs.getRc.call(void 0, );
|
|
134
135
|
const apiKey = process.env.LINGODOTDEV_API_KEY || _optionalChain([rc, 'optionalAccess', _3 => _3.auth, 'optionalAccess', _4 => _4.apiKey]);
|
|
135
136
|
const apiUrl = process.env.LINGODOTDEV_API_URL || _optionalChain([rc, 'optionalAccess', _5 => _5.auth, 'optionalAccess', _6 => _6.apiUrl]) || "https://engine.lingo.dev";
|
|
136
137
|
if (apiKey) {
|
|
@@ -158,20 +159,20 @@ async function getActualId() {
|
|
|
158
159
|
// src/index.ts
|
|
159
160
|
var keyCheckers = {
|
|
160
161
|
groq: {
|
|
161
|
-
checkEnv:
|
|
162
|
-
checkRc:
|
|
162
|
+
checkEnv: _chunk6E2XDW5Xcjs.getGroqKeyFromEnv,
|
|
163
|
+
checkRc: _chunk6E2XDW5Xcjs.getGroqKeyFromRc
|
|
163
164
|
},
|
|
164
165
|
google: {
|
|
165
|
-
checkEnv:
|
|
166
|
-
checkRc:
|
|
166
|
+
checkEnv: _chunk6E2XDW5Xcjs.getGoogleKeyFromEnv,
|
|
167
|
+
checkRc: _chunk6E2XDW5Xcjs.getGoogleKeyFromRc
|
|
167
168
|
},
|
|
168
169
|
mistral: {
|
|
169
|
-
checkEnv:
|
|
170
|
-
checkRc:
|
|
170
|
+
checkEnv: _chunk6E2XDW5Xcjs.getMistralKeyFromEnv,
|
|
171
|
+
checkRc: _chunk6E2XDW5Xcjs.getMistralKeyFromRc
|
|
171
172
|
},
|
|
172
173
|
"lingo.dev": {
|
|
173
|
-
checkEnv:
|
|
174
|
-
checkRc:
|
|
174
|
+
checkEnv: _chunk6E2XDW5Xcjs.getLingoDotDevKeyFromEnv,
|
|
175
|
+
checkRc: _chunk6E2XDW5Xcjs.getLingoDotDevKeyFromRc
|
|
175
176
|
}
|
|
176
177
|
};
|
|
177
178
|
var alreadySentBuildEvent = { value: false };
|
|
@@ -187,14 +188,14 @@ function sendBuildEvent(framework, config, isDev) {
|
|
|
187
188
|
var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
188
189
|
(_params, _meta) => {
|
|
189
190
|
console.log("\u2139\uFE0F Starting Lingo.dev compiler...");
|
|
190
|
-
const params = _lodash2.default.defaults(_params,
|
|
191
|
-
if (!
|
|
191
|
+
const params = _lodash2.default.defaults(_params, _chunk6E2XDW5Xcjs.defaultParams);
|
|
192
|
+
if (!_chunk6E2XDW5Xcjs.isRunningInCIOrDocker.call(void 0, )) {
|
|
192
193
|
if (params.models === "lingo.dev") {
|
|
193
194
|
validateLLMKeyDetails(["lingo.dev"]);
|
|
194
195
|
} else {
|
|
195
196
|
const configuredProviders = getConfiguredProviders(params.models);
|
|
196
197
|
validateLLMKeyDetails(configuredProviders);
|
|
197
|
-
const invalidLocales =
|
|
198
|
+
const invalidLocales = _chunk6E2XDW5Xcjs.getInvalidLocales.call(void 0,
|
|
198
199
|
params.models,
|
|
199
200
|
params.sourceLocale,
|
|
200
201
|
params.targetLocales
|
|
@@ -217,7 +218,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
|
-
|
|
221
|
+
_chunk6E2XDW5Xcjs.LCPCache.ensureDictionaryFile({
|
|
221
222
|
sourceRoot: params.sourceRoot,
|
|
222
223
|
lingoDir: params.lingoDir
|
|
223
224
|
});
|
|
@@ -225,9 +226,9 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
225
226
|
sendBuildEvent("unplugin", params, isDev);
|
|
226
227
|
return {
|
|
227
228
|
name: package_default.name,
|
|
228
|
-
loadInclude: (id) => !!id.match(
|
|
229
|
+
loadInclude: (id) => !!id.match(_chunk6E2XDW5Xcjs.LCP_DICTIONARY_FILE_NAME),
|
|
229
230
|
async load(id) {
|
|
230
|
-
const dictionary = await
|
|
231
|
+
const dictionary = await _chunk6E2XDW5Xcjs.loadDictionary.call(void 0, {
|
|
231
232
|
resourcePath: id,
|
|
232
233
|
resourceQuery: "",
|
|
233
234
|
params: {
|
|
@@ -251,7 +252,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
251
252
|
enforce: "pre",
|
|
252
253
|
transform(code, id) {
|
|
253
254
|
try {
|
|
254
|
-
const result =
|
|
255
|
+
const result = _chunk6E2XDW5Xcjs.transformComponent.call(void 0, {
|
|
255
256
|
code,
|
|
256
257
|
params,
|
|
257
258
|
resourcePath: id,
|
|
@@ -271,7 +272,7 @@ var src_default = {
|
|
|
271
272
|
next: (compilerParams) => (nextConfig = {}) => {
|
|
272
273
|
const mergedParams = _lodash2.default.merge(
|
|
273
274
|
{},
|
|
274
|
-
|
|
275
|
+
_chunk6E2XDW5Xcjs.defaultParams,
|
|
275
276
|
{
|
|
276
277
|
rsc: true,
|
|
277
278
|
turbopack: {
|
|
@@ -322,7 +323,7 @@ var src_default = {
|
|
|
322
323
|
turbopackConfigPath.rules ??= {};
|
|
323
324
|
const rules = turbopackConfigPath.rules;
|
|
324
325
|
const lingoGlob = `**/*.{ts,tsx,js,jsx}`;
|
|
325
|
-
const lingoLoaderPath =
|
|
326
|
+
const lingoLoaderPath = _chunk6E2XDW5Xcjs.__require.resolve("./lingo-turbopack-loader");
|
|
326
327
|
rules[lingoGlob] = {
|
|
327
328
|
loaders: [
|
|
328
329
|
{
|
|
@@ -337,7 +338,7 @@ var src_default = {
|
|
|
337
338
|
vite: (compilerParams) => (config) => {
|
|
338
339
|
const mergedParams = _lodash2.default.merge(
|
|
339
340
|
{},
|
|
340
|
-
|
|
341
|
+
_chunk6E2XDW5Xcjs.defaultParams,
|
|
341
342
|
{ rsc: false },
|
|
342
343
|
compilerParams
|
|
343
344
|
);
|
|
@@ -351,7 +352,7 @@ var src_default = {
|
|
|
351
352
|
};
|
|
352
353
|
function getConfiguredProviders(models) {
|
|
353
354
|
return _lodash2.default.chain(Object.values(models)).map((modelString) => modelString.split(":")[0]).filter(Boolean).uniq().filter(
|
|
354
|
-
(providerId) =>
|
|
355
|
+
(providerId) => _chunk6E2XDW5Xcjs.providerDetails.hasOwnProperty(providerId) && keyCheckers.hasOwnProperty(providerId)
|
|
355
356
|
).value();
|
|
356
357
|
}
|
|
357
358
|
function validateLLMKeyDetails(configuredProviders) {
|
|
@@ -362,7 +363,7 @@ function validateLLMKeyDetails(configuredProviders) {
|
|
|
362
363
|
const missingProviders = [];
|
|
363
364
|
const foundProviders = [];
|
|
364
365
|
for (const providerId of configuredProviders) {
|
|
365
|
-
const details =
|
|
366
|
+
const details = _chunk6E2XDW5Xcjs.providerDetails[providerId];
|
|
366
367
|
const checkers = keyCheckers[providerId];
|
|
367
368
|
if (!details || !checkers) continue;
|
|
368
369
|
const foundInEnv = !!checkers.checkEnv();
|
package/build/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NextConfig } from 'next';
|
|
2
|
+
import { LocaleCode } from '@lingo.dev/_spec';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Options for configuring Lingo.dev Compiler.
|
|
@@ -14,7 +15,7 @@ type CompilerParams = {
|
|
|
14
15
|
*
|
|
15
16
|
* @default "en"
|
|
16
17
|
*/
|
|
17
|
-
sourceLocale:
|
|
18
|
+
sourceLocale: LocaleCode;
|
|
18
19
|
/**
|
|
19
20
|
* The locale(s) to translate to.
|
|
20
21
|
*
|
|
@@ -25,7 +26,7 @@ type CompilerParams = {
|
|
|
25
26
|
*
|
|
26
27
|
* @default ["es"]
|
|
27
28
|
*/
|
|
28
|
-
targetLocales:
|
|
29
|
+
targetLocales: LocaleCode[];
|
|
29
30
|
/**
|
|
30
31
|
* The name of the directory where translation files will be stored, relative to `sourceRoot`.
|
|
31
32
|
*
|
|
@@ -76,7 +77,7 @@ type CompilerParams = {
|
|
|
76
77
|
*
|
|
77
78
|
* @default {}
|
|
78
79
|
*/
|
|
79
|
-
models: "lingo.dev" |
|
|
80
|
+
models: "lingo.dev" | ModelMap;
|
|
80
81
|
/**
|
|
81
82
|
* Custom system prompt for the translation engine. If set, this prompt will override the default system prompt defined in Compiler.
|
|
82
83
|
* Only works with custom models, not with Lingo.dev Engine.
|
|
@@ -87,6 +88,40 @@ type CompilerParams = {
|
|
|
87
88
|
*/
|
|
88
89
|
prompt?: string | null;
|
|
89
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* A mapping between locale pairings and the model to use to translate that pairing.
|
|
93
|
+
*/
|
|
94
|
+
type ModelMap = {
|
|
95
|
+
[key in SourceTargetLocale]?: ModelIdentifier;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* A pairing of a source and target locale.
|
|
99
|
+
*/
|
|
100
|
+
type SourceTargetLocale = LocalePair | AnyTargetLocale | AnySourceLocale | AnyLocale;
|
|
101
|
+
/**
|
|
102
|
+
* A translation from a specific source locale to a specific target locale.
|
|
103
|
+
*/
|
|
104
|
+
type LocalePair = `${LocaleCode}:${LocaleCode}`;
|
|
105
|
+
/**
|
|
106
|
+
* A translation from a specific source locale to any target locale.
|
|
107
|
+
*/
|
|
108
|
+
type AnyTargetLocale = `${LocaleCode}:${LocaleWildcard}`;
|
|
109
|
+
/**
|
|
110
|
+
* A translation from any source locale to a specific target locale.
|
|
111
|
+
*/
|
|
112
|
+
type AnySourceLocale = `${LocaleWildcard}:${LocaleCode}`;
|
|
113
|
+
/**
|
|
114
|
+
* A translation from any source locale to any target locale.
|
|
115
|
+
*/
|
|
116
|
+
type AnyLocale = `${LocaleWildcard}:${LocaleWildcard}`;
|
|
117
|
+
/**
|
|
118
|
+
* A wildcard symbol that matches any locale.
|
|
119
|
+
*/
|
|
120
|
+
type LocaleWildcard = "*";
|
|
121
|
+
/**
|
|
122
|
+
* The colon-separated identifier of a model to use for translation.
|
|
123
|
+
*/
|
|
124
|
+
type ModelIdentifier = `${string}:${string}`;
|
|
90
125
|
declare const defaultParams: CompilerParams;
|
|
91
126
|
|
|
92
127
|
declare const _default: {
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NextConfig } from 'next';
|
|
2
|
+
import { LocaleCode } from '@lingo.dev/_spec';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Options for configuring Lingo.dev Compiler.
|
|
@@ -14,7 +15,7 @@ type CompilerParams = {
|
|
|
14
15
|
*
|
|
15
16
|
* @default "en"
|
|
16
17
|
*/
|
|
17
|
-
sourceLocale:
|
|
18
|
+
sourceLocale: LocaleCode;
|
|
18
19
|
/**
|
|
19
20
|
* The locale(s) to translate to.
|
|
20
21
|
*
|
|
@@ -25,7 +26,7 @@ type CompilerParams = {
|
|
|
25
26
|
*
|
|
26
27
|
* @default ["es"]
|
|
27
28
|
*/
|
|
28
|
-
targetLocales:
|
|
29
|
+
targetLocales: LocaleCode[];
|
|
29
30
|
/**
|
|
30
31
|
* The name of the directory where translation files will be stored, relative to `sourceRoot`.
|
|
31
32
|
*
|
|
@@ -76,7 +77,7 @@ type CompilerParams = {
|
|
|
76
77
|
*
|
|
77
78
|
* @default {}
|
|
78
79
|
*/
|
|
79
|
-
models: "lingo.dev" |
|
|
80
|
+
models: "lingo.dev" | ModelMap;
|
|
80
81
|
/**
|
|
81
82
|
* Custom system prompt for the translation engine. If set, this prompt will override the default system prompt defined in Compiler.
|
|
82
83
|
* Only works with custom models, not with Lingo.dev Engine.
|
|
@@ -87,6 +88,40 @@ type CompilerParams = {
|
|
|
87
88
|
*/
|
|
88
89
|
prompt?: string | null;
|
|
89
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* A mapping between locale pairings and the model to use to translate that pairing.
|
|
93
|
+
*/
|
|
94
|
+
type ModelMap = {
|
|
95
|
+
[key in SourceTargetLocale]?: ModelIdentifier;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* A pairing of a source and target locale.
|
|
99
|
+
*/
|
|
100
|
+
type SourceTargetLocale = LocalePair | AnyTargetLocale | AnySourceLocale | AnyLocale;
|
|
101
|
+
/**
|
|
102
|
+
* A translation from a specific source locale to a specific target locale.
|
|
103
|
+
*/
|
|
104
|
+
type LocalePair = `${LocaleCode}:${LocaleCode}`;
|
|
105
|
+
/**
|
|
106
|
+
* A translation from a specific source locale to any target locale.
|
|
107
|
+
*/
|
|
108
|
+
type AnyTargetLocale = `${LocaleCode}:${LocaleWildcard}`;
|
|
109
|
+
/**
|
|
110
|
+
* A translation from any source locale to a specific target locale.
|
|
111
|
+
*/
|
|
112
|
+
type AnySourceLocale = `${LocaleWildcard}:${LocaleCode}`;
|
|
113
|
+
/**
|
|
114
|
+
* A translation from any source locale to any target locale.
|
|
115
|
+
*/
|
|
116
|
+
type AnyLocale = `${LocaleWildcard}:${LocaleWildcard}`;
|
|
117
|
+
/**
|
|
118
|
+
* A wildcard symbol that matches any locale.
|
|
119
|
+
*/
|
|
120
|
+
type LocaleWildcard = "*";
|
|
121
|
+
/**
|
|
122
|
+
* The colon-separated identifier of a model to use for translation.
|
|
123
|
+
*/
|
|
124
|
+
type ModelIdentifier = `${string}:${string}`;
|
|
90
125
|
declare const defaultParams: CompilerParams;
|
|
91
126
|
|
|
92
127
|
declare const _default: {
|
package/build/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
loadDictionary,
|
|
18
18
|
providerDetails,
|
|
19
19
|
transformComponent
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-MMSXDFQL.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.
|
|
28
|
+
version: "0.6.1",
|
|
29
29
|
description: "Lingo.dev Compiler",
|
|
30
30
|
private: false,
|
|
31
31
|
publishConfig: {
|
|
@@ -69,6 +69,7 @@ var package_default = {
|
|
|
69
69
|
"@babel/traverse": "^7.27.4",
|
|
70
70
|
"@babel/types": "^7.26.7",
|
|
71
71
|
"@lingo.dev/_sdk": "workspace:*",
|
|
72
|
+
"@lingo.dev/_spec": "workspace:*",
|
|
72
73
|
"@openrouter/ai-sdk-provider": "^0.7.1",
|
|
73
74
|
"@prettier/sync": "^0.6.1",
|
|
74
75
|
ai: "^4.2.10",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk6E2XDW5Xcjs = require('./chunk-6E2XDW5X.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
|
|
12
|
+
const dictionary = await _chunk6E2XDW5Xcjs.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 =
|
|
24
|
+
const result = _chunk6E2XDW5Xcjs.transformComponent.call(void 0, {
|
|
25
25
|
code: source,
|
|
26
26
|
params,
|
|
27
27
|
resourcePath: this.resourcePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingo.dev/_compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Lingo.dev Compiler",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"zod": "^3.24.1",
|
|
53
53
|
"posthog-node": "^4.17.0",
|
|
54
54
|
"node-machine-id": "^1.1.12",
|
|
55
|
-
"@lingo.dev/_sdk": "0.
|
|
55
|
+
"@lingo.dev/_sdk": "0.10.0",
|
|
56
|
+
"@lingo.dev/_spec": "0.39.1"
|
|
56
57
|
},
|
|
57
58
|
"scripts": {
|
|
58
59
|
"dev": "tsup --watch",
|