@lingo.dev/_compiler 0.5.1 → 0.5.3
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-42EM6MWM.cjs → chunk-23GDRLDY.cjs} +2 -1
- package/build/{chunk-XCIXY6J2.mjs → chunk-S326ZU7C.mjs} +1 -0
- package/build/index.cjs +116 -29
- package/build/index.mjs +93 -6
- package/build/lingo-turbopack-loader.cjs +3 -3
- package/build/lingo-turbopack-loader.mjs +1 -1
- package/package.json +4 -2
|
@@ -2703,4 +2703,5 @@ function transformComponent(options) {
|
|
|
2703
2703
|
|
|
2704
2704
|
|
|
2705
2705
|
|
|
2706
|
-
|
|
2706
|
+
|
|
2707
|
+
exports.__require = __require; exports.defaultParams = defaultParams; exports.LCP_DICTIONARY_FILE_NAME = LCP_DICTIONARY_FILE_NAME; exports.LCPCache = LCPCache; exports.getInvalidLocales = getInvalidLocales; exports.getRc = getRc; exports.getGroqKeyFromRc = getGroqKeyFromRc; exports.getGroqKeyFromEnv = getGroqKeyFromEnv; exports.getLingoDotDevKeyFromEnv = getLingoDotDevKeyFromEnv; exports.getLingoDotDevKeyFromRc = getLingoDotDevKeyFromRc; exports.getGoogleKeyFromRc = getGoogleKeyFromRc; exports.getGoogleKeyFromEnv = getGoogleKeyFromEnv; exports.getMistralKeyFromRc = getMistralKeyFromRc; exports.getMistralKeyFromEnv = getMistralKeyFromEnv; exports.isRunningInCIOrDocker = isRunningInCIOrDocker; exports.providerDetails = providerDetails; exports.loadDictionary = loadDictionary; exports.transformComponent = transformComponent;
|
package/build/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
var _chunk23GDRLDYcjs = require('./chunk-23GDRLDY.cjs');
|
|
20
21
|
|
|
21
22
|
// src/index.ts
|
|
22
23
|
var _unplugin = require('unplugin');
|
|
@@ -24,7 +25,7 @@ var _unplugin = require('unplugin');
|
|
|
24
25
|
// package.json
|
|
25
26
|
var package_default = {
|
|
26
27
|
name: "@lingo.dev/_compiler",
|
|
27
|
-
version: "0.5.
|
|
28
|
+
version: "0.5.3",
|
|
28
29
|
description: "Lingo.dev Compiler",
|
|
29
30
|
private: false,
|
|
30
31
|
publishConfig: {
|
|
@@ -81,7 +82,9 @@ var package_default = {
|
|
|
81
82
|
prettier: "^3.4.2",
|
|
82
83
|
unplugin: "^2.1.2",
|
|
83
84
|
vitest: "^2.1.4",
|
|
84
|
-
zod: "^3.24.1"
|
|
85
|
+
zod: "^3.24.1",
|
|
86
|
+
"posthog-node": "^4.17.0",
|
|
87
|
+
"node-machine-id": "^1.1.12"
|
|
85
88
|
},
|
|
86
89
|
packageManager: "pnpm@9.12.3"
|
|
87
90
|
};
|
|
@@ -89,35 +92,109 @@ var package_default = {
|
|
|
89
92
|
// src/index.ts
|
|
90
93
|
var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
91
94
|
var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
|
|
95
|
+
|
|
96
|
+
// src/utils/observability.ts
|
|
97
|
+
var _nodemachineid = require('node-machine-id');
|
|
98
|
+
async function trackEvent(event, properties) {
|
|
99
|
+
if (process.env.DO_NOT_TRACK) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const actualId = await getActualId();
|
|
104
|
+
const { PostHog } = await Promise.resolve().then(() => _interopRequireWildcard(require("posthog-node")));
|
|
105
|
+
const posthog = new PostHog(
|
|
106
|
+
"phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk",
|
|
107
|
+
{
|
|
108
|
+
host: "https://eu.i.posthog.com",
|
|
109
|
+
flushAt: 1,
|
|
110
|
+
flushInterval: 0
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
await posthog.capture({
|
|
114
|
+
distinctId: actualId,
|
|
115
|
+
event,
|
|
116
|
+
properties: {
|
|
117
|
+
...properties,
|
|
118
|
+
isByokMode: _optionalChain([properties, 'optionalAccess', _2 => _2.models]) !== "lingo.dev",
|
|
119
|
+
meta: {
|
|
120
|
+
version: process.env.npm_package_version,
|
|
121
|
+
isCi: process.env.CI === "true"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
await posthog.shutdown();
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (process.env.DEBUG) {
|
|
128
|
+
console.error(error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function getActualId() {
|
|
133
|
+
const rc = _chunk23GDRLDYcjs.getRc.call(void 0, );
|
|
134
|
+
const apiKey = process.env.LINGODOTDEV_API_KEY || _optionalChain([rc, 'optionalAccess', _3 => _3.auth, 'optionalAccess', _4 => _4.apiKey]);
|
|
135
|
+
const apiUrl = process.env.LINGODOTDEV_API_URL || _optionalChain([rc, 'optionalAccess', _5 => _5.auth, 'optionalAccess', _6 => _6.apiUrl]) || "https://engine.lingo.dev";
|
|
136
|
+
if (apiKey) {
|
|
137
|
+
try {
|
|
138
|
+
const res = await fetch(`${apiUrl}/whoami`, {
|
|
139
|
+
method: "POST",
|
|
140
|
+
headers: {
|
|
141
|
+
Authorization: `Bearer ${apiKey}`,
|
|
142
|
+
ContentType: "application/json"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
if (res.ok) {
|
|
146
|
+
const payload = await res.json();
|
|
147
|
+
if (_optionalChain([payload, 'optionalAccess', _7 => _7.email])) {
|
|
148
|
+
return payload.email;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const id = await _nodemachineid.machineId.call(void 0, );
|
|
155
|
+
return `device-${id}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/index.ts
|
|
92
159
|
var keyCheckers = {
|
|
93
160
|
groq: {
|
|
94
|
-
checkEnv:
|
|
95
|
-
checkRc:
|
|
161
|
+
checkEnv: _chunk23GDRLDYcjs.getGroqKeyFromEnv,
|
|
162
|
+
checkRc: _chunk23GDRLDYcjs.getGroqKeyFromRc
|
|
96
163
|
},
|
|
97
164
|
google: {
|
|
98
|
-
checkEnv:
|
|
99
|
-
checkRc:
|
|
165
|
+
checkEnv: _chunk23GDRLDYcjs.getGoogleKeyFromEnv,
|
|
166
|
+
checkRc: _chunk23GDRLDYcjs.getGoogleKeyFromRc
|
|
100
167
|
},
|
|
101
168
|
mistral: {
|
|
102
|
-
checkEnv:
|
|
103
|
-
checkRc:
|
|
169
|
+
checkEnv: _chunk23GDRLDYcjs.getMistralKeyFromEnv,
|
|
170
|
+
checkRc: _chunk23GDRLDYcjs.getMistralKeyFromRc
|
|
104
171
|
},
|
|
105
172
|
"lingo.dev": {
|
|
106
|
-
checkEnv:
|
|
107
|
-
checkRc:
|
|
173
|
+
checkEnv: _chunk23GDRLDYcjs.getLingoDotDevKeyFromEnv,
|
|
174
|
+
checkRc: _chunk23GDRLDYcjs.getLingoDotDevKeyFromRc
|
|
108
175
|
}
|
|
109
176
|
};
|
|
177
|
+
var alreadySentBuildEvent = { value: false };
|
|
178
|
+
function sendBuildEvent(framework, config, isDev) {
|
|
179
|
+
if (alreadySentBuildEvent.value) return;
|
|
180
|
+
alreadySentBuildEvent.value = true;
|
|
181
|
+
trackEvent("compiler.build.start", {
|
|
182
|
+
framework,
|
|
183
|
+
configuration: config,
|
|
184
|
+
isDevMode: isDev
|
|
185
|
+
});
|
|
186
|
+
}
|
|
110
187
|
var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
111
188
|
(_params, _meta) => {
|
|
112
189
|
console.log("\u2139\uFE0F Starting Lingo.dev compiler...");
|
|
113
|
-
const params = _lodash2.default.defaults(_params,
|
|
114
|
-
if (!
|
|
190
|
+
const params = _lodash2.default.defaults(_params, _chunk23GDRLDYcjs.defaultParams);
|
|
191
|
+
if (!_chunk23GDRLDYcjs.isRunningInCIOrDocker.call(void 0, )) {
|
|
115
192
|
if (params.models === "lingo.dev") {
|
|
116
193
|
validateLLMKeyDetails(["lingo.dev"]);
|
|
117
194
|
} else {
|
|
118
195
|
const configuredProviders = getConfiguredProviders(params.models);
|
|
119
196
|
validateLLMKeyDetails(configuredProviders);
|
|
120
|
-
const invalidLocales =
|
|
197
|
+
const invalidLocales = _chunk23GDRLDYcjs.getInvalidLocales.call(void 0,
|
|
121
198
|
params.models,
|
|
122
199
|
params.sourceLocale,
|
|
123
200
|
params.targetLocales
|
|
@@ -140,16 +217,17 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
140
217
|
}
|
|
141
218
|
}
|
|
142
219
|
}
|
|
143
|
-
|
|
220
|
+
_chunk23GDRLDYcjs.LCPCache.ensureDictionaryFile({
|
|
144
221
|
sourceRoot: params.sourceRoot,
|
|
145
222
|
lingoDir: params.lingoDir
|
|
146
223
|
});
|
|
147
224
|
const isDev = "dev" in _meta ? !!_meta.dev : process.env.NODE_ENV !== "production";
|
|
225
|
+
sendBuildEvent("unplugin", params, isDev);
|
|
148
226
|
return {
|
|
149
227
|
name: package_default.name,
|
|
150
|
-
loadInclude: (id) => !!id.match(
|
|
228
|
+
loadInclude: (id) => !!id.match(_chunk23GDRLDYcjs.LCP_DICTIONARY_FILE_NAME),
|
|
151
229
|
async load(id) {
|
|
152
|
-
const dictionary = await
|
|
230
|
+
const dictionary = await _chunk23GDRLDYcjs.loadDictionary.call(void 0, {
|
|
153
231
|
resourcePath: id,
|
|
154
232
|
resourceQuery: "",
|
|
155
233
|
params: {
|
|
@@ -165,7 +243,6 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
165
243
|
if (!dictionary) {
|
|
166
244
|
return null;
|
|
167
245
|
}
|
|
168
|
-
console.log(JSON.stringify(dictionary, null, 2));
|
|
169
246
|
return {
|
|
170
247
|
code: `export default ${JSON.stringify(dictionary, null, 2)}`
|
|
171
248
|
};
|
|
@@ -174,7 +251,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
174
251
|
enforce: "pre",
|
|
175
252
|
transform(code, id) {
|
|
176
253
|
try {
|
|
177
|
-
const result =
|
|
254
|
+
const result = _chunk23GDRLDYcjs.transformComponent.call(void 0, {
|
|
178
255
|
code,
|
|
179
256
|
params,
|
|
180
257
|
resourcePath: id,
|
|
@@ -194,7 +271,7 @@ var src_default = {
|
|
|
194
271
|
next: (compilerParams) => (nextConfig = {}) => {
|
|
195
272
|
const mergedParams = _lodash2.default.merge(
|
|
196
273
|
{},
|
|
197
|
-
|
|
274
|
+
_chunk23GDRLDYcjs.defaultParams,
|
|
198
275
|
{
|
|
199
276
|
rsc: true,
|
|
200
277
|
turbopack: {
|
|
@@ -204,13 +281,15 @@ var src_default = {
|
|
|
204
281
|
},
|
|
205
282
|
compilerParams
|
|
206
283
|
);
|
|
284
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
285
|
+
sendBuildEvent("Next.js", mergedParams, isDev);
|
|
207
286
|
let turbopackEnabled;
|
|
208
|
-
if (_optionalChain([mergedParams, 'access',
|
|
287
|
+
if (_optionalChain([mergedParams, 'access', _8 => _8.turbopack, 'optionalAccess', _9 => _9.enabled]) === "auto") {
|
|
209
288
|
turbopackEnabled = process.env.TURBOPACK === "1" || process.env.TURBOPACK === "true";
|
|
210
289
|
} else {
|
|
211
|
-
turbopackEnabled = _optionalChain([mergedParams, 'access',
|
|
290
|
+
turbopackEnabled = _optionalChain([mergedParams, 'access', _10 => _10.turbopack, 'optionalAccess', _11 => _11.enabled]) === true;
|
|
212
291
|
}
|
|
213
|
-
const supportLegacyTurbo = _optionalChain([mergedParams, 'access',
|
|
292
|
+
const supportLegacyTurbo = _optionalChain([mergedParams, 'access', _12 => _12.turbopack, 'optionalAccess', _13 => _13.useLegacyTurbo]) === true;
|
|
214
293
|
const hasWebpackConfig = typeof nextConfig.webpack === "function";
|
|
215
294
|
const hasTurbopackConfig = typeof nextConfig.turbopack === "function";
|
|
216
295
|
if (hasWebpackConfig && turbopackEnabled) {
|
|
@@ -243,7 +322,7 @@ var src_default = {
|
|
|
243
322
|
turbopackConfigPath.rules ??= {};
|
|
244
323
|
const rules = turbopackConfigPath.rules;
|
|
245
324
|
const lingoGlob = `**/*.{ts,tsx,js,jsx}`;
|
|
246
|
-
const lingoLoaderPath =
|
|
325
|
+
const lingoLoaderPath = _chunk23GDRLDYcjs.__require.resolve("./lingo-turbopack-loader");
|
|
247
326
|
rules[lingoGlob] = {
|
|
248
327
|
loaders: [
|
|
249
328
|
{
|
|
@@ -256,15 +335,23 @@ var src_default = {
|
|
|
256
335
|
return nextConfig;
|
|
257
336
|
},
|
|
258
337
|
vite: (compilerParams) => (config) => {
|
|
259
|
-
|
|
260
|
-
|
|
338
|
+
const mergedParams = _lodash2.default.merge(
|
|
339
|
+
{},
|
|
340
|
+
_chunk23GDRLDYcjs.defaultParams,
|
|
341
|
+
{ rsc: false },
|
|
342
|
+
compilerParams
|
|
261
343
|
);
|
|
344
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
345
|
+
const isReactRouter = _optionalChain([config, 'access', _14 => _14.plugins, 'optionalAccess', _15 => _15.flat, 'call', _16 => _16(), 'optionalAccess', _17 => _17.some, 'call', _18 => _18((plugin) => plugin.name === "react-router")]);
|
|
346
|
+
const framework = isReactRouter ? "React Router" : "Vite";
|
|
347
|
+
sendBuildEvent(framework, mergedParams, isDev);
|
|
348
|
+
config.plugins.unshift(unplugin.vite(mergedParams));
|
|
262
349
|
return config;
|
|
263
350
|
}
|
|
264
351
|
};
|
|
265
352
|
function getConfiguredProviders(models) {
|
|
266
353
|
return _lodash2.default.chain(Object.values(models)).map((modelString) => modelString.split(":")[0]).filter(Boolean).uniq().filter(
|
|
267
|
-
(providerId) =>
|
|
354
|
+
(providerId) => _chunk23GDRLDYcjs.providerDetails.hasOwnProperty(providerId) && keyCheckers.hasOwnProperty(providerId)
|
|
268
355
|
).value();
|
|
269
356
|
}
|
|
270
357
|
function validateLLMKeyDetails(configuredProviders) {
|
|
@@ -275,7 +362,7 @@ function validateLLMKeyDetails(configuredProviders) {
|
|
|
275
362
|
const missingProviders = [];
|
|
276
363
|
const foundProviders = [];
|
|
277
364
|
for (const providerId of configuredProviders) {
|
|
278
|
-
const details =
|
|
365
|
+
const details = _chunk23GDRLDYcjs.providerDetails[providerId];
|
|
279
366
|
const checkers = keyCheckers[providerId];
|
|
280
367
|
if (!details || !checkers) continue;
|
|
281
368
|
const foundInEnv = !!checkers.checkEnv();
|
package/build/index.mjs
CHANGED
|
@@ -12,11 +12,12 @@ import {
|
|
|
12
12
|
getLingoDotDevKeyFromRc,
|
|
13
13
|
getMistralKeyFromEnv,
|
|
14
14
|
getMistralKeyFromRc,
|
|
15
|
+
getRc,
|
|
15
16
|
isRunningInCIOrDocker,
|
|
16
17
|
loadDictionary,
|
|
17
18
|
providerDetails,
|
|
18
19
|
transformComponent
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-S326ZU7C.mjs";
|
|
20
21
|
|
|
21
22
|
// src/index.ts
|
|
22
23
|
import { createUnplugin } from "unplugin";
|
|
@@ -24,7 +25,7 @@ import { createUnplugin } from "unplugin";
|
|
|
24
25
|
// package.json
|
|
25
26
|
var package_default = {
|
|
26
27
|
name: "@lingo.dev/_compiler",
|
|
27
|
-
version: "0.5.
|
|
28
|
+
version: "0.5.3",
|
|
28
29
|
description: "Lingo.dev Compiler",
|
|
29
30
|
private: false,
|
|
30
31
|
publishConfig: {
|
|
@@ -81,7 +82,9 @@ var package_default = {
|
|
|
81
82
|
prettier: "^3.4.2",
|
|
82
83
|
unplugin: "^2.1.2",
|
|
83
84
|
vitest: "^2.1.4",
|
|
84
|
-
zod: "^3.24.1"
|
|
85
|
+
zod: "^3.24.1",
|
|
86
|
+
"posthog-node": "^4.17.0",
|
|
87
|
+
"node-machine-id": "^1.1.12"
|
|
85
88
|
},
|
|
86
89
|
packageManager: "pnpm@9.12.3"
|
|
87
90
|
};
|
|
@@ -89,6 +92,70 @@ var package_default = {
|
|
|
89
92
|
// src/index.ts
|
|
90
93
|
import _ from "lodash";
|
|
91
94
|
import dedent from "dedent";
|
|
95
|
+
|
|
96
|
+
// src/utils/observability.ts
|
|
97
|
+
import { machineId } from "node-machine-id";
|
|
98
|
+
async function trackEvent(event, properties) {
|
|
99
|
+
if (process.env.DO_NOT_TRACK) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const actualId = await getActualId();
|
|
104
|
+
const { PostHog } = await import("posthog-node");
|
|
105
|
+
const posthog = new PostHog(
|
|
106
|
+
"phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk",
|
|
107
|
+
{
|
|
108
|
+
host: "https://eu.i.posthog.com",
|
|
109
|
+
flushAt: 1,
|
|
110
|
+
flushInterval: 0
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
await posthog.capture({
|
|
114
|
+
distinctId: actualId,
|
|
115
|
+
event,
|
|
116
|
+
properties: {
|
|
117
|
+
...properties,
|
|
118
|
+
isByokMode: properties?.models !== "lingo.dev",
|
|
119
|
+
meta: {
|
|
120
|
+
version: process.env.npm_package_version,
|
|
121
|
+
isCi: process.env.CI === "true"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
await posthog.shutdown();
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (process.env.DEBUG) {
|
|
128
|
+
console.error(error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function getActualId() {
|
|
133
|
+
const rc = getRc();
|
|
134
|
+
const apiKey = process.env.LINGODOTDEV_API_KEY || rc?.auth?.apiKey;
|
|
135
|
+
const apiUrl = process.env.LINGODOTDEV_API_URL || rc?.auth?.apiUrl || "https://engine.lingo.dev";
|
|
136
|
+
if (apiKey) {
|
|
137
|
+
try {
|
|
138
|
+
const res = await fetch(`${apiUrl}/whoami`, {
|
|
139
|
+
method: "POST",
|
|
140
|
+
headers: {
|
|
141
|
+
Authorization: `Bearer ${apiKey}`,
|
|
142
|
+
ContentType: "application/json"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
if (res.ok) {
|
|
146
|
+
const payload = await res.json();
|
|
147
|
+
if (payload?.email) {
|
|
148
|
+
return payload.email;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const id = await machineId();
|
|
155
|
+
return `device-${id}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/index.ts
|
|
92
159
|
var keyCheckers = {
|
|
93
160
|
groq: {
|
|
94
161
|
checkEnv: getGroqKeyFromEnv,
|
|
@@ -107,6 +174,16 @@ var keyCheckers = {
|
|
|
107
174
|
checkRc: getLingoDotDevKeyFromRc
|
|
108
175
|
}
|
|
109
176
|
};
|
|
177
|
+
var alreadySentBuildEvent = { value: false };
|
|
178
|
+
function sendBuildEvent(framework, config, isDev) {
|
|
179
|
+
if (alreadySentBuildEvent.value) return;
|
|
180
|
+
alreadySentBuildEvent.value = true;
|
|
181
|
+
trackEvent("compiler.build.start", {
|
|
182
|
+
framework,
|
|
183
|
+
configuration: config,
|
|
184
|
+
isDevMode: isDev
|
|
185
|
+
});
|
|
186
|
+
}
|
|
110
187
|
var unplugin = createUnplugin(
|
|
111
188
|
(_params, _meta) => {
|
|
112
189
|
console.log("\u2139\uFE0F Starting Lingo.dev compiler...");
|
|
@@ -145,6 +222,7 @@ var unplugin = createUnplugin(
|
|
|
145
222
|
lingoDir: params.lingoDir
|
|
146
223
|
});
|
|
147
224
|
const isDev = "dev" in _meta ? !!_meta.dev : process.env.NODE_ENV !== "production";
|
|
225
|
+
sendBuildEvent("unplugin", params, isDev);
|
|
148
226
|
return {
|
|
149
227
|
name: package_default.name,
|
|
150
228
|
loadInclude: (id) => !!id.match(LCP_DICTIONARY_FILE_NAME),
|
|
@@ -165,7 +243,6 @@ var unplugin = createUnplugin(
|
|
|
165
243
|
if (!dictionary) {
|
|
166
244
|
return null;
|
|
167
245
|
}
|
|
168
|
-
console.log(JSON.stringify(dictionary, null, 2));
|
|
169
246
|
return {
|
|
170
247
|
code: `export default ${JSON.stringify(dictionary, null, 2)}`
|
|
171
248
|
};
|
|
@@ -204,6 +281,8 @@ var src_default = {
|
|
|
204
281
|
},
|
|
205
282
|
compilerParams
|
|
206
283
|
);
|
|
284
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
285
|
+
sendBuildEvent("Next.js", mergedParams, isDev);
|
|
207
286
|
let turbopackEnabled;
|
|
208
287
|
if (mergedParams.turbopack?.enabled === "auto") {
|
|
209
288
|
turbopackEnabled = process.env.TURBOPACK === "1" || process.env.TURBOPACK === "true";
|
|
@@ -256,9 +335,17 @@ var src_default = {
|
|
|
256
335
|
return nextConfig;
|
|
257
336
|
},
|
|
258
337
|
vite: (compilerParams) => (config) => {
|
|
259
|
-
|
|
260
|
-
|
|
338
|
+
const mergedParams = _.merge(
|
|
339
|
+
{},
|
|
340
|
+
defaultParams,
|
|
341
|
+
{ rsc: false },
|
|
342
|
+
compilerParams
|
|
261
343
|
);
|
|
344
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
345
|
+
const isReactRouter = config.plugins?.flat()?.some((plugin) => plugin.name === "react-router");
|
|
346
|
+
const framework = isReactRouter ? "React Router" : "Vite";
|
|
347
|
+
sendBuildEvent(framework, mergedParams, isDev);
|
|
348
|
+
config.plugins.unshift(unplugin.vite(mergedParams));
|
|
262
349
|
return config;
|
|
263
350
|
}
|
|
264
351
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk23GDRLDYcjs = require('./chunk-23GDRLDY.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 _chunk23GDRLDYcjs.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 = _chunk23GDRLDYcjs.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.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Lingo.dev Compiler",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -50,7 +50,9 @@
|
|
|
50
50
|
"unplugin": "^2.1.2",
|
|
51
51
|
"vitest": "^2.1.4",
|
|
52
52
|
"zod": "^3.24.1",
|
|
53
|
-
"
|
|
53
|
+
"posthog-node": "^4.17.0",
|
|
54
|
+
"node-machine-id": "^1.1.12",
|
|
55
|
+
"@lingo.dev/_sdk": "0.9.6"
|
|
54
56
|
},
|
|
55
57
|
"scripts": {
|
|
56
58
|
"dev": "tsup --watch",
|