@mercurjs/dashboard-sdk 2.3.4-canary.7 → 2.3.4-canary.8
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/dist/vite.cjs +38 -6
- package/dist/vite.js +38 -6
- package/package.json +1 -1
package/dist/vite.cjs
CHANGED
|
@@ -620,14 +620,46 @@ function findI18nIndex(srcDir) {
|
|
|
620
620
|
}
|
|
621
621
|
return null;
|
|
622
622
|
}
|
|
623
|
-
function generateI18n({ srcDir }) {
|
|
623
|
+
function generateI18n({ srcDir, pluginExtensions }) {
|
|
624
624
|
const indexFile = findI18nIndex(srcDir);
|
|
625
|
-
|
|
626
|
-
|
|
625
|
+
const imports = [
|
|
626
|
+
...indexFile ? [`import appI18n from "${normalizePath(indexFile)}"`] : [],
|
|
627
|
+
...pluginExtensions.map(
|
|
628
|
+
(ext, i) => `import __plugin${i} from "${normalizePath(ext)}"`
|
|
629
|
+
)
|
|
630
|
+
];
|
|
631
|
+
const sources = [
|
|
632
|
+
...pluginExtensions.map((_, i) => `(__plugin${i}.i18nModule ?? {})`),
|
|
633
|
+
...indexFile ? ["appI18n"] : []
|
|
634
|
+
];
|
|
635
|
+
return `${imports.join("\n")}
|
|
636
|
+
|
|
637
|
+
function deepMerge(target, source) {
|
|
638
|
+
const result = { ...target }
|
|
639
|
+
for (const key of Object.keys(source)) {
|
|
640
|
+
const a = target[key]
|
|
641
|
+
const b = source[key]
|
|
642
|
+
result[key] =
|
|
643
|
+
a && b && typeof a === "object" && typeof b === "object" && !Array.isArray(a) && !Array.isArray(b)
|
|
644
|
+
? deepMerge(a, b)
|
|
645
|
+
: b
|
|
627
646
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
647
|
+
return result
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function mergeResources(target, source) {
|
|
651
|
+
const result = { ...target }
|
|
652
|
+
for (const lng of Object.keys(source)) {
|
|
653
|
+
result[lng] = { ...(result[lng] ?? {}) }
|
|
654
|
+
for (const ns of Object.keys(source[lng])) {
|
|
655
|
+
result[lng][ns] = deepMerge(result[lng][ns] ?? {}, source[lng][ns])
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return result
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
export default [${sources.join(", ")}].reduce(mergeResources, {})
|
|
662
|
+
`;
|
|
631
663
|
}
|
|
632
664
|
|
|
633
665
|
// src/widgets.ts
|
package/dist/vite.js
CHANGED
|
@@ -600,14 +600,46 @@ function findI18nIndex(srcDir) {
|
|
|
600
600
|
}
|
|
601
601
|
return null;
|
|
602
602
|
}
|
|
603
|
-
function generateI18n({ srcDir }) {
|
|
603
|
+
function generateI18n({ srcDir, pluginExtensions }) {
|
|
604
604
|
const indexFile = findI18nIndex(srcDir);
|
|
605
|
-
|
|
606
|
-
|
|
605
|
+
const imports = [
|
|
606
|
+
...indexFile ? [`import appI18n from "${normalizePath(indexFile)}"`] : [],
|
|
607
|
+
...pluginExtensions.map(
|
|
608
|
+
(ext, i) => `import __plugin${i} from "${normalizePath(ext)}"`
|
|
609
|
+
)
|
|
610
|
+
];
|
|
611
|
+
const sources = [
|
|
612
|
+
...pluginExtensions.map((_, i) => `(__plugin${i}.i18nModule ?? {})`),
|
|
613
|
+
...indexFile ? ["appI18n"] : []
|
|
614
|
+
];
|
|
615
|
+
return `${imports.join("\n")}
|
|
616
|
+
|
|
617
|
+
function deepMerge(target, source) {
|
|
618
|
+
const result = { ...target }
|
|
619
|
+
for (const key of Object.keys(source)) {
|
|
620
|
+
const a = target[key]
|
|
621
|
+
const b = source[key]
|
|
622
|
+
result[key] =
|
|
623
|
+
a && b && typeof a === "object" && typeof b === "object" && !Array.isArray(a) && !Array.isArray(b)
|
|
624
|
+
? deepMerge(a, b)
|
|
625
|
+
: b
|
|
607
626
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
627
|
+
return result
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function mergeResources(target, source) {
|
|
631
|
+
const result = { ...target }
|
|
632
|
+
for (const lng of Object.keys(source)) {
|
|
633
|
+
result[lng] = { ...(result[lng] ?? {}) }
|
|
634
|
+
for (const ns of Object.keys(source[lng])) {
|
|
635
|
+
result[lng][ns] = deepMerge(result[lng][ns] ?? {}, source[lng][ns])
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return result
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export default [${sources.join(", ")}].reduce(mergeResources, {})
|
|
642
|
+
`;
|
|
611
643
|
}
|
|
612
644
|
|
|
613
645
|
// src/widgets.ts
|