@lingo.dev/_compiler 0.3.0 → 0.3.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/index.cjs +28 -15
- package/build/index.mjs +28 -15
- package/package.json +1 -1
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.3.
|
|
7
|
+
version: "0.3.1",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -834,10 +834,9 @@ var LCPCache = class {
|
|
|
834
834
|
}
|
|
835
835
|
// merge dictionary with current cache, sort files, entries and locales to minimize diffs
|
|
836
836
|
static _mergeLocaleDictionary(currentCache, dictionary, lcp) {
|
|
837
|
-
const
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
const cachedEntry = _nullishCoalesce(_lodash2.default.get(currentCache, ["files", fileName, "entries", entryName]), () => ( {}));
|
|
837
|
+
const newCache = _lodash2.default.cloneDeep(currentCache);
|
|
838
|
+
for (const [fileName, fileData] of Object.entries(dictionary.files)) {
|
|
839
|
+
for (const [entryName, entryValue] of Object.entries(fileData.entries)) {
|
|
841
840
|
const hash = _lodash2.default.get(lcp, [
|
|
842
841
|
"files",
|
|
843
842
|
fileName,
|
|
@@ -845,19 +844,33 @@ var LCPCache = class {
|
|
|
845
844
|
entryName,
|
|
846
845
|
"hash"
|
|
847
846
|
]);
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
847
|
+
const existingEntry = _lodash2.default.get(newCache, [
|
|
848
|
+
"files",
|
|
849
|
+
fileName,
|
|
850
|
+
"entries",
|
|
851
|
+
entryName
|
|
852
|
+
]) || {
|
|
853
|
+
content: {},
|
|
854
|
+
hash
|
|
855
|
+
};
|
|
856
|
+
const mergedContent = _lodash2.default.call(void 0, {
|
|
857
|
+
...existingEntry.content,
|
|
858
|
+
[dictionary.locale]: entryValue
|
|
852
859
|
}).toPairs().sortBy([0]).fromPairs().value();
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
860
|
+
_lodash2.default.set(newCache, ["files", fileName, "entries", entryName], {
|
|
861
|
+
content: mergedContent,
|
|
862
|
+
hash
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
const sortedFiles = _lodash2.default.call(void 0, newCache.files).toPairs().sortBy([0]).map(([fileName, file]) => {
|
|
867
|
+
const sortedEntries = _lodash2.default.call(void 0, file.entries).toPairs().sortBy([0]).fromPairs().value();
|
|
868
|
+
return [fileName, { entries: sortedEntries }];
|
|
869
|
+
}).fromPairs().value();
|
|
870
|
+
return {
|
|
857
871
|
version: dictionary.version,
|
|
858
|
-
files
|
|
872
|
+
files: sortedFiles
|
|
859
873
|
};
|
|
860
|
-
return newCache;
|
|
861
874
|
}
|
|
862
875
|
// extract dictionary from cache for given locale, validate entry hash from LCP schema
|
|
863
876
|
static _extractLocaleDictionary(cache, locale, lcp) {
|
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.3.
|
|
7
|
+
version: "0.3.1",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -834,10 +834,9 @@ var LCPCache = class {
|
|
|
834
834
|
}
|
|
835
835
|
// merge dictionary with current cache, sort files, entries and locales to minimize diffs
|
|
836
836
|
static _mergeLocaleDictionary(currentCache, dictionary, lcp) {
|
|
837
|
-
const
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
const cachedEntry = _3.get(currentCache, ["files", fileName, "entries", entryName]) ?? {};
|
|
837
|
+
const newCache = _3.cloneDeep(currentCache);
|
|
838
|
+
for (const [fileName, fileData] of Object.entries(dictionary.files)) {
|
|
839
|
+
for (const [entryName, entryValue] of Object.entries(fileData.entries)) {
|
|
841
840
|
const hash = _3.get(lcp, [
|
|
842
841
|
"files",
|
|
843
842
|
fileName,
|
|
@@ -845,19 +844,33 @@ var LCPCache = class {
|
|
|
845
844
|
entryName,
|
|
846
845
|
"hash"
|
|
847
846
|
]);
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
847
|
+
const existingEntry = _3.get(newCache, [
|
|
848
|
+
"files",
|
|
849
|
+
fileName,
|
|
850
|
+
"entries",
|
|
851
|
+
entryName
|
|
852
|
+
]) || {
|
|
853
|
+
content: {},
|
|
854
|
+
hash
|
|
855
|
+
};
|
|
856
|
+
const mergedContent = _3({
|
|
857
|
+
...existingEntry.content,
|
|
858
|
+
[dictionary.locale]: entryValue
|
|
852
859
|
}).toPairs().sortBy([0]).fromPairs().value();
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
860
|
+
_3.set(newCache, ["files", fileName, "entries", entryName], {
|
|
861
|
+
content: mergedContent,
|
|
862
|
+
hash
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
const sortedFiles = _3(newCache.files).toPairs().sortBy([0]).map(([fileName, file]) => {
|
|
867
|
+
const sortedEntries = _3(file.entries).toPairs().sortBy([0]).fromPairs().value();
|
|
868
|
+
return [fileName, { entries: sortedEntries }];
|
|
869
|
+
}).fromPairs().value();
|
|
870
|
+
return {
|
|
857
871
|
version: dictionary.version,
|
|
858
|
-
files
|
|
872
|
+
files: sortedFiles
|
|
859
873
|
};
|
|
860
|
-
return newCache;
|
|
861
874
|
}
|
|
862
875
|
// extract dictionary from cache for given locale, validate entry hash from LCP schema
|
|
863
876
|
static _extractLocaleDictionary(cache, locale, lcp) {
|