@lingo.dev/compiler 0.3.10 → 0.3.11
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/metadata/manager.cjs +7 -4
- package/build/metadata/manager.mjs +6 -3
- package/build/metadata/manager.mjs.map +1 -1
- package/build/react/server/ServerLingoProvider.d.cts +2 -2
- package/build/react/server/ServerLingoProvider.d.mts +2 -2
- package/build/react/shared/LingoProvider.d.cts +2 -2
- package/build/react/shared/LingoProvider.d.mts +2 -2
- package/build/react/shared/LocaleSwitcher.d.cts +2 -2
- package/build/react/shared/LocaleSwitcher.d.mts +2 -2
- package/package.json +2 -2
|
@@ -5,7 +5,6 @@ let path = require("path");
|
|
|
5
5
|
path = require_rolldown_runtime.__toESM(path);
|
|
6
6
|
let fs = require("fs");
|
|
7
7
|
fs = require_rolldown_runtime.__toESM(fs);
|
|
8
|
-
let lmdb = require("lmdb");
|
|
9
8
|
|
|
10
9
|
//#region src/metadata/manager.ts
|
|
11
10
|
const METADATA_DIR_DEV = "metadata-dev";
|
|
@@ -15,11 +14,15 @@ const METADATA_DIR_BUILD = "metadata-build";
|
|
|
15
14
|
*
|
|
16
15
|
* lmdb-js deduplicates open() calls to the same path (ref-counted at C++ level),
|
|
17
16
|
* so this is cheap. Each open() also clears stale readers from terminated workers.
|
|
17
|
+
*
|
|
18
|
+
* lmdb is loaded via dynamic import() to prevent bundlers and require hooks
|
|
19
|
+
* from transforming its CJS bundle, which contains syntax they can't handle.
|
|
18
20
|
*/
|
|
19
|
-
function openDatabaseConnection(dbPath, noSync) {
|
|
21
|
+
async function openDatabaseConnection(dbPath, noSync) {
|
|
20
22
|
try {
|
|
21
23
|
fs.default.mkdirSync(dbPath, { recursive: true });
|
|
22
|
-
|
|
24
|
+
const { open } = await import("lmdb");
|
|
25
|
+
return open({
|
|
23
26
|
path: dbPath,
|
|
24
27
|
compression: true,
|
|
25
28
|
noSync
|
|
@@ -45,7 +48,7 @@ async function closeDatabaseConnection(db, dbPath) {
|
|
|
45
48
|
* is closed afterwards.
|
|
46
49
|
*/
|
|
47
50
|
async function runWithDbConnection(dbPath, noSync, fn) {
|
|
48
|
-
const db = openDatabaseConnection(dbPath, noSync);
|
|
51
|
+
const db = await openDatabaseConnection(dbPath, noSync);
|
|
49
52
|
try {
|
|
50
53
|
return fn(db);
|
|
51
54
|
} finally {
|
|
@@ -2,7 +2,6 @@ import { logger } from "../utils/logger.mjs";
|
|
|
2
2
|
import { getLingoDir } from "../utils/path-helpers.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import fs from "fs";
|
|
5
|
-
import { open } from "lmdb";
|
|
6
5
|
|
|
7
6
|
//#region src/metadata/manager.ts
|
|
8
7
|
const METADATA_DIR_DEV = "metadata-dev";
|
|
@@ -12,10 +11,14 @@ const METADATA_DIR_BUILD = "metadata-build";
|
|
|
12
11
|
*
|
|
13
12
|
* lmdb-js deduplicates open() calls to the same path (ref-counted at C++ level),
|
|
14
13
|
* so this is cheap. Each open() also clears stale readers from terminated workers.
|
|
14
|
+
*
|
|
15
|
+
* lmdb is loaded via dynamic import() to prevent bundlers and require hooks
|
|
16
|
+
* from transforming its CJS bundle, which contains syntax they can't handle.
|
|
15
17
|
*/
|
|
16
|
-
function openDatabaseConnection(dbPath, noSync) {
|
|
18
|
+
async function openDatabaseConnection(dbPath, noSync) {
|
|
17
19
|
try {
|
|
18
20
|
fs.mkdirSync(dbPath, { recursive: true });
|
|
21
|
+
const { open } = await import("lmdb");
|
|
19
22
|
return open({
|
|
20
23
|
path: dbPath,
|
|
21
24
|
compression: true,
|
|
@@ -42,7 +45,7 @@ async function closeDatabaseConnection(db, dbPath) {
|
|
|
42
45
|
* is closed afterwards.
|
|
43
46
|
*/
|
|
44
47
|
async function runWithDbConnection(dbPath, noSync, fn) {
|
|
45
|
-
const db = openDatabaseConnection(dbPath, noSync);
|
|
48
|
+
const db = await openDatabaseConnection(dbPath, noSync);
|
|
46
49
|
try {
|
|
47
50
|
return fn(db);
|
|
48
51
|
} finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.mjs","names":["entries: MetadataSchema"],"sources":["../../src/metadata/manager.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport {
|
|
1
|
+
{"version":3,"file":"manager.mjs","names":["entries: MetadataSchema"],"sources":["../../src/metadata/manager.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport type { RootDatabase } from \"lmdb\";\nimport type { MetadataSchema, PathConfig, TranslationEntry } from \"../types\";\nimport { getLingoDir } from \"../utils/path-helpers\";\nimport { logger } from \"../utils/logger\";\n\nconst METADATA_DIR_DEV = \"metadata-dev\";\nconst METADATA_DIR_BUILD = \"metadata-build\";\n\n/**\n * Opens an LMDB connection for a single operation.\n *\n * lmdb-js deduplicates open() calls to the same path (ref-counted at C++ level),\n * so this is cheap. Each open() also clears stale readers from terminated workers.\n *\n * lmdb is loaded via dynamic import() to prevent bundlers and require hooks\n * from transforming its CJS bundle, which contains syntax they can't handle.\n */\nasync function openDatabaseConnection(dbPath: string, noSync: boolean): Promise<RootDatabase> {\n try {\n fs.mkdirSync(dbPath, { recursive: true });\n const { open } = await import(\"lmdb\");\n return open({\n path: dbPath,\n compression: true,\n noSync,\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to open LMDB at ${dbPath}: ${message}`);\n }\n}\n\n/**\n * Closes the LMDB connection. Also prevents EBUSY/EPERM on Windows during\n * directory cleanup.\n */\nasync function closeDatabaseConnection(\n db: RootDatabase,\n dbPath: string,\n): Promise<void> {\n try {\n await db.close();\n } catch (e) {\n logger.debug(`Error closing database at ${dbPath}: ${e}`);\n }\n}\n\n/**\n * Opens a database connection, runs the callback, and ensures the connection\n * is closed afterwards.\n */\nasync function runWithDbConnection<T>(\n dbPath: string,\n noSync: boolean,\n fn: (db: RootDatabase) => T,\n): Promise<T> {\n const db = await openDatabaseConnection(dbPath, noSync);\n try {\n return fn(db);\n } finally {\n await closeDatabaseConnection(db, dbPath);\n }\n}\n\nfunction readEntriesFromDb(db: RootDatabase): MetadataSchema {\n const entries: MetadataSchema = {};\n\n for (const { key, value } of db.getRange()) {\n entries[key as string] = value as TranslationEntry;\n }\n\n return entries;\n}\n\nexport async function loadMetadata(\n dbPath: string,\n noSync = false,\n): Promise<MetadataSchema> {\n return runWithDbConnection(dbPath, noSync, readEntriesFromDb);\n}\n\n/**\n * Persists translation entries to LMDB in a single atomic transaction.\n */\nexport async function saveMetadata(\n dbPath: string,\n entries: TranslationEntry[],\n noSync = false,\n): Promise<void> {\n return runWithDbConnection(dbPath, noSync, (db) => {\n db.transactionSync(() => {\n for (const entry of entries) {\n db.putSync(entry.hash, entry);\n }\n });\n });\n}\n\nexport function cleanupExistingMetadata(metadataDbPath: string): void {\n logger.debug(`Cleaning up metadata database: ${metadataDbPath}`);\n\n try {\n fs.rmSync(metadataDbPath, { recursive: true, force: true });\n logger.info(`🧹 Cleaned up metadata database: ${metadataDbPath}`);\n } catch (error) {\n const code =\n error instanceof Error && \"code\" in error\n ? (error as NodeJS.ErrnoException).code\n : undefined;\n const message = error instanceof Error ? error.message : String(error);\n\n if (code === \"ENOENT\") {\n logger.debug(\n `Metadata database already deleted or doesn't exist: ${metadataDbPath}`,\n );\n return;\n }\n\n logger.warn(`Failed to cleanup metadata database: ${message}`);\n }\n}\n\nexport function getMetadataPath(config: PathConfig): string {\n const dirname =\n config.environment === \"development\"\n ? METADATA_DIR_DEV\n : METADATA_DIR_BUILD;\n return path.join(getLingoDir(config), dirname);\n}\n"],"mappings":";;;;;;AAOA,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;;;;;;;;;;AAW3B,eAAe,uBAAuB,QAAgB,QAAwC;AAC5F,KAAI;AACF,KAAG,UAAU,QAAQ,EAAE,WAAW,MAAM,CAAC;EACzC,MAAM,EAAE,SAAS,MAAM,OAAO;AAC9B,SAAO,KAAK;GACV,MAAM;GACN,aAAa;GACb;GACD,CAAC;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B;CAC1D,MAAM,UACJ,OAAO,gBAAgB,gBACnB,mBACA;AACN,QAAO,KAAK,KAAK,YAAY,OAAO,EAAE,QAAQ"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LingoProviderProps } from "../shared/LingoProvider.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/react/server/ServerLingoProvider.d.ts
|
|
5
5
|
declare function LingoProvider({
|
|
6
6
|
initialLocale,
|
|
7
7
|
initialTranslations,
|
|
8
8
|
...rest
|
|
9
|
-
}: LingoProviderProps): Promise<
|
|
9
|
+
}: LingoProviderProps): Promise<react_jsx_runtime2.JSX.Element>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { LingoProvider };
|
|
12
12
|
//# sourceMappingURL=ServerLingoProvider.d.cts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LingoProviderProps } from "../shared/LingoProvider.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/react/server/ServerLingoProvider.d.ts
|
|
5
5
|
declare function LingoProvider({
|
|
6
6
|
initialLocale,
|
|
7
7
|
initialTranslations,
|
|
8
8
|
...rest
|
|
9
|
-
}: LingoProviderProps): Promise<
|
|
9
|
+
}: LingoProviderProps): Promise<react_jsx_runtime2.JSX.Element>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { LingoProvider };
|
|
12
12
|
//# sourceMappingURL=ServerLingoProvider.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LocaleCode } from "lingo.dev/spec";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
3
3
|
import { PropsWithChildren } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/react/shared/LingoProvider.d.ts
|
|
@@ -70,7 +70,7 @@ declare function LingoProvider__Dev({
|
|
|
70
70
|
router,
|
|
71
71
|
devWidget,
|
|
72
72
|
children
|
|
73
|
-
}: LingoProviderProps):
|
|
73
|
+
}: LingoProviderProps): react_jsx_runtime1.JSX.Element;
|
|
74
74
|
//#endregion
|
|
75
75
|
export { LingoProvider, LingoProviderProps };
|
|
76
76
|
//# sourceMappingURL=LingoProvider.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
3
|
import { LocaleCode } from "lingo.dev/spec";
|
|
4
4
|
|
|
5
5
|
//#region src/react/shared/LingoProvider.d.ts
|
|
@@ -70,7 +70,7 @@ declare function LingoProvider__Dev({
|
|
|
70
70
|
router,
|
|
71
71
|
devWidget,
|
|
72
72
|
children
|
|
73
|
-
}: LingoProviderProps):
|
|
73
|
+
}: LingoProviderProps): react_jsx_runtime3.JSX.Element;
|
|
74
74
|
//#endregion
|
|
75
75
|
export { LingoProvider, LingoProviderProps };
|
|
76
76
|
//# sourceMappingURL=LingoProvider.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LocaleCode } from "lingo.dev/spec";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
3
|
import { CSSProperties } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/react/shared/LocaleSwitcher.d.ts
|
|
@@ -65,7 +65,7 @@ declare function LocaleSwitcher({
|
|
|
65
65
|
style,
|
|
66
66
|
className,
|
|
67
67
|
showLoadingState
|
|
68
|
-
}: LocaleSwitcherProps):
|
|
68
|
+
}: LocaleSwitcherProps): react_jsx_runtime3.JSX.Element;
|
|
69
69
|
//#endregion
|
|
70
70
|
export { LocaleSwitcher };
|
|
71
71
|
//# sourceMappingURL=LocaleSwitcher.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
3
3
|
import { LocaleCode } from "lingo.dev/spec";
|
|
4
4
|
|
|
5
5
|
//#region src/react/shared/LocaleSwitcher.d.ts
|
|
@@ -65,7 +65,7 @@ declare function LocaleSwitcher({
|
|
|
65
65
|
style,
|
|
66
66
|
className,
|
|
67
67
|
showLoadingState
|
|
68
|
-
}: LocaleSwitcherProps):
|
|
68
|
+
}: LocaleSwitcherProps): react_jsx_runtime1.JSX.Element;
|
|
69
69
|
//#endregion
|
|
70
70
|
export { LocaleSwitcher };
|
|
71
71
|
//# sourceMappingURL=LocaleSwitcher.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingo.dev/compiler",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Lingo.dev Compiler",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"posthog-node": "5.14.0",
|
|
162
162
|
"lmdb": "3.2.6",
|
|
163
163
|
"ws": "8.18.3",
|
|
164
|
-
"lingo.dev": "^0.132.
|
|
164
|
+
"lingo.dev": "^0.132.5"
|
|
165
165
|
},
|
|
166
166
|
"peerDependencies": {
|
|
167
167
|
"next": "^15.0.0 || ^16.0.4",
|