@vizejs/vite-plugin-musea 0.83.0 → 0.85.0
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/index.mjs +16 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1805,7 +1805,7 @@ async function parseTokens(tokensPath) {
|
|
|
1805
1805
|
* Parse tokens from a directory.
|
|
1806
1806
|
*/
|
|
1807
1807
|
async function parseTokenDirectory(dirPath) {
|
|
1808
|
-
const mergedTokens =
|
|
1808
|
+
const mergedTokens = createRecord();
|
|
1809
1809
|
await mergeTokenDirectory(mergedTokens, dirPath);
|
|
1810
1810
|
return flattenTokens(mergedTokens);
|
|
1811
1811
|
}
|
|
@@ -1829,7 +1829,7 @@ function deepMergeTokenTrees(target, source) {
|
|
|
1829
1829
|
deepMergeTokenTrees(existing, value);
|
|
1830
1830
|
continue;
|
|
1831
1831
|
}
|
|
1832
|
-
target[key] = value;
|
|
1832
|
+
target[key] = cloneTokenTree(value);
|
|
1833
1833
|
}
|
|
1834
1834
|
}
|
|
1835
1835
|
/**
|
|
@@ -1855,10 +1855,19 @@ function flattenTokens(tokens, prefix = []) {
|
|
|
1855
1855
|
* Extract token values from an object.
|
|
1856
1856
|
*/
|
|
1857
1857
|
function extractTokens(obj) {
|
|
1858
|
-
const tokens =
|
|
1858
|
+
const tokens = createRecord();
|
|
1859
1859
|
for (const [key, value] of Object.entries(obj)) if (isTokenValue(value)) tokens[key] = normalizeToken(value);
|
|
1860
1860
|
return tokens;
|
|
1861
1861
|
}
|
|
1862
|
+
function cloneTokenTree(value) {
|
|
1863
|
+
if (Array.isArray(value)) return value.map(cloneTokenTree);
|
|
1864
|
+
if (isPlainObject(value)) {
|
|
1865
|
+
const cloned = createRecord();
|
|
1866
|
+
for (const [key, child] of Object.entries(value)) cloned[key] = cloneTokenTree(child);
|
|
1867
|
+
return cloned;
|
|
1868
|
+
}
|
|
1869
|
+
return value;
|
|
1870
|
+
}
|
|
1862
1871
|
/**
|
|
1863
1872
|
* Check if a value is a token definition.
|
|
1864
1873
|
*/
|
|
@@ -1870,6 +1879,9 @@ function isTokenValue(value) {
|
|
|
1870
1879
|
function isPlainObject(value) {
|
|
1871
1880
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1872
1881
|
}
|
|
1882
|
+
function createRecord() {
|
|
1883
|
+
return Object.create(null);
|
|
1884
|
+
}
|
|
1873
1885
|
/**
|
|
1874
1886
|
* Normalize token to DesignToken interface.
|
|
1875
1887
|
*/
|
|
@@ -2013,7 +2025,7 @@ function parseTokenPath(dotPath) {
|
|
|
2013
2025
|
* Flatten nested categories into a flat map keyed by dot-path.
|
|
2014
2026
|
*/
|
|
2015
2027
|
function buildTokenMap(categories, prefix = []) {
|
|
2016
|
-
const map =
|
|
2028
|
+
const map = Object.create(null);
|
|
2017
2029
|
for (const cat of categories) {
|
|
2018
2030
|
const catKey = cat.name.toLowerCase().replace(/\s+/g, "-");
|
|
2019
2031
|
const catPath = [...prefix, catKey];
|