@udixio/theme 1.0.0 → 1.2.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/CHANGELOG.md +37 -0
- package/bin/main.ts +85 -0
- package/dist/API.d.ts +1 -0
- package/dist/API.d.ts.map +1 -1
- package/dist/bin.cjs +64 -0
- package/dist/bin.js +63 -0
- package/dist/browser.cjs +40 -0
- package/dist/browser.js +40 -0
- package/dist/config/config.interface.d.ts.map +1 -0
- package/dist/config/define-config.d.ts.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.node.d.ts +2 -0
- package/dist/config/index.node.d.ts.map +1 -0
- package/dist/config/resolver-config.d.ts +11 -0
- package/dist/config/resolver-config.d.ts.map +1 -0
- package/dist/define-config-BFo7Sy7c.cjs +399 -0
- package/dist/define-config-CGG8l3fb.js +400 -0
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.node.d.ts +4 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/load-from-path-BvdfXUD0.cjs +78 -0
- package/dist/load-from-path-CFpw2P_Y.js +39 -0
- package/dist/loader/index.d.ts +2 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/index.node.d.ts +3 -0
- package/dist/loader/index.node.d.ts.map +1 -0
- package/dist/loader/load-from-path.d.ts +5 -0
- package/dist/loader/load-from-path.d.ts.map +1 -0
- package/dist/loader/loader.d.ts +3 -0
- package/dist/loader/loader.d.ts.map +1 -0
- package/dist/loader/unplugin.d.ts +16 -0
- package/dist/loader/unplugin.d.ts.map +1 -0
- package/dist/{index.js → loader-C_BIrsO2.js} +58 -549
- package/dist/{index.cjs → loader-TksB6_mM.cjs} +32 -563
- package/dist/node.cjs +192 -0
- package/dist/node.js +171 -0
- package/dist/plugin/plugin.api.d.ts +1 -1
- package/dist/plugin/plugin.api.d.ts.map +1 -1
- package/package.json +29 -10
- package/src/API.ts +4 -0
- package/src/config/index.node.ts +1 -0
- package/src/{adapter → config}/index.ts +0 -1
- package/src/config/resolver-config.ts +49 -0
- package/src/index.browser.ts +1 -0
- package/src/index.node.ts +3 -0
- package/src/index.ts +2 -2
- package/src/loader/index.node.ts +2 -0
- package/src/loader/index.ts +1 -0
- package/src/loader/load-from-path.ts +9 -0
- package/src/{adapter/adapter.abstract.ts → loader/loader.ts} +27 -28
- package/src/loader/unplugin.ts +158 -0
- package/src/plugin/plugin.api.ts +4 -4
- package/vite.config.ts +18 -4
- package/dist/adapter/adapter.abstract.d.ts +0 -10
- package/dist/adapter/adapter.abstract.d.ts.map +0 -1
- package/dist/adapter/config.interface.d.ts.map +0 -1
- package/dist/adapter/define-config.d.ts.map +0 -1
- package/dist/adapter/file-adapter.mixin.d.ts +0 -18
- package/dist/adapter/file-adapter.mixin.d.ts.map +0 -1
- package/dist/adapter/index.d.ts +0 -4
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/adapters/index.d.ts +0 -3
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/node.adapter.d.ts +0 -7
- package/dist/adapters/node.adapter.d.ts.map +0 -1
- package/dist/adapters/vite.adapter.d.ts +0 -3
- package/dist/adapters/vite.adapter.d.ts.map +0 -1
- package/src/adapter/file-adapter.mixin.ts +0 -72
- package/src/adapters/index.ts +0 -2
- package/src/adapters/node.adapter.ts +0 -49
- package/src/adapters/vite.adapter.ts +0 -79
- /package/dist/{adapter → config}/config.interface.d.ts +0 -0
- /package/dist/{adapter → config}/define-config.d.ts +0 -0
- /package/src/{adapter → config}/config.interface.ts +0 -0
- /package/src/{adapter → config}/define-config.ts +0 -0
|
@@ -3,9 +3,6 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { asClass, createContainer, InjectionMode, asValue } from "awilix";
|
|
5
5
|
import { lerp, argbFromLstar, sanitizeDegreesDouble, yFromLstar, argbFromLinrgb, Cam16, signum, matrixMultiply, ViewingConditions, lstarFromArgb, lstarFromY, Contrast, clampDouble, hexFromArgb, argbFromHex, DynamicColor as DynamicColor$1, TonalPalette } from "@material/material-color-utilities";
|
|
6
|
-
import { loadConfigFromFile } from "vite";
|
|
7
|
-
import * as path from "node:path";
|
|
8
|
-
import * as fs from "node:fs";
|
|
9
6
|
class ColorApi {
|
|
10
7
|
constructor({ colorManager }) {
|
|
11
8
|
__publicField(this, "colorManager");
|
|
@@ -1767,106 +1764,6 @@ class Variant {
|
|
|
1767
1764
|
this.colors = colors;
|
|
1768
1765
|
}
|
|
1769
1766
|
}
|
|
1770
|
-
const getExpressiveNeutralHue = (sourceColorHct) => {
|
|
1771
|
-
const hue = getRotatedHue(
|
|
1772
|
-
sourceColorHct,
|
|
1773
|
-
[0, 71, 124, 253, 278, 300, 360],
|
|
1774
|
-
[10, 0, 10, 0, 10, 0]
|
|
1775
|
-
);
|
|
1776
|
-
return hue;
|
|
1777
|
-
};
|
|
1778
|
-
const getExpressiveNeutralChroma = (sourceColorHct, isDark) => {
|
|
1779
|
-
const neutralHue = getExpressiveNeutralHue(sourceColorHct);
|
|
1780
|
-
return isDark ? Hct.isYellow(neutralHue) ? 6 : 14 : 18;
|
|
1781
|
-
};
|
|
1782
|
-
const expressiveVariant = {
|
|
1783
|
-
name: "expressive",
|
|
1784
|
-
palettes: {
|
|
1785
|
-
primary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 36 : 48),
|
|
1786
|
-
secondary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(
|
|
1787
|
-
getRotatedHue(
|
|
1788
|
-
sourceColorHct,
|
|
1789
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1790
|
-
[-160, 155, -100, 96, -96, -156, -165, -160]
|
|
1791
|
-
),
|
|
1792
|
-
isDark ? 16 : 24
|
|
1793
|
-
),
|
|
1794
|
-
tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1795
|
-
getRotatedHue(
|
|
1796
|
-
sourceColorHct,
|
|
1797
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1798
|
-
[-165, 160, -105, 101, -101, -160, -170, -165]
|
|
1799
|
-
),
|
|
1800
|
-
48
|
|
1801
|
-
),
|
|
1802
|
-
neutral: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(
|
|
1803
|
-
getExpressiveNeutralHue(sourceColorHct),
|
|
1804
|
-
getExpressiveNeutralChroma(sourceColorHct, isDark)
|
|
1805
|
-
),
|
|
1806
|
-
neutralVariant: ({ sourceColorHct, isDark }) => {
|
|
1807
|
-
const expressiveNeutralHue = getExpressiveNeutralHue(sourceColorHct);
|
|
1808
|
-
const expressiveNeutralChroma = getExpressiveNeutralChroma(
|
|
1809
|
-
sourceColorHct,
|
|
1810
|
-
isDark
|
|
1811
|
-
);
|
|
1812
|
-
return TonalPalette.fromHueAndChroma(
|
|
1813
|
-
expressiveNeutralHue,
|
|
1814
|
-
expressiveNeutralChroma * (expressiveNeutralHue >= 105 && expressiveNeutralHue < 125 ? 1.6 : 2.3)
|
|
1815
|
-
);
|
|
1816
|
-
},
|
|
1817
|
-
error: ({ sourceColorHct }) => {
|
|
1818
|
-
const errorHue = getPiecewiseHue(
|
|
1819
|
-
sourceColorHct,
|
|
1820
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1821
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1822
|
-
);
|
|
1823
|
-
return TonalPalette.fromHueAndChroma(errorHue, 64);
|
|
1824
|
-
}
|
|
1825
|
-
},
|
|
1826
|
-
customPalettes: ({ colorHct, isDark }) => TonalPalette.fromHueAndChroma(
|
|
1827
|
-
getRotatedHue(
|
|
1828
|
-
colorHct,
|
|
1829
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1830
|
-
[-160, 155, -100, 96, -96, -156, -165, -160]
|
|
1831
|
-
),
|
|
1832
|
-
isDark ? 16 : 24
|
|
1833
|
-
)
|
|
1834
|
-
};
|
|
1835
|
-
const neutralVariant = {
|
|
1836
|
-
name: "neutral",
|
|
1837
|
-
palettes: {
|
|
1838
|
-
primary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1839
|
-
sourceColorHct.hue,
|
|
1840
|
-
Hct.isBlue(sourceColorHct.hue) ? 12 : 8
|
|
1841
|
-
),
|
|
1842
|
-
secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1843
|
-
sourceColorHct.hue,
|
|
1844
|
-
Hct.isBlue(sourceColorHct.hue) ? 6 : 4
|
|
1845
|
-
),
|
|
1846
|
-
tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1847
|
-
getRotatedHue(
|
|
1848
|
-
sourceColorHct,
|
|
1849
|
-
[0, 38, 105, 161, 204, 278, 333, 360],
|
|
1850
|
-
[-32, 26, 10, -39, 24, -15, -32]
|
|
1851
|
-
),
|
|
1852
|
-
20
|
|
1853
|
-
),
|
|
1854
|
-
neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4),
|
|
1855
|
-
neutralVariant: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4 * 2.2),
|
|
1856
|
-
error: ({ sourceColorHct }) => {
|
|
1857
|
-
const errorHue = getPiecewiseHue(
|
|
1858
|
-
sourceColorHct,
|
|
1859
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1860
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1861
|
-
);
|
|
1862
|
-
return TonalPalette.fromHueAndChroma(errorHue, 50);
|
|
1863
|
-
}
|
|
1864
|
-
},
|
|
1865
|
-
customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(
|
|
1866
|
-
colorHct.hue,
|
|
1867
|
-
Hct.isBlue(colorHct.hue) ? 6 : 4
|
|
1868
|
-
)
|
|
1869
|
-
};
|
|
1870
1767
|
const tonalSpotVariant = {
|
|
1871
1768
|
name: "tonalSpot",
|
|
1872
1769
|
palettes: {
|
|
@@ -1893,73 +1790,6 @@ const tonalSpotVariant = {
|
|
|
1893
1790
|
},
|
|
1894
1791
|
customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(colorHct.hue, 16)
|
|
1895
1792
|
};
|
|
1896
|
-
const getVibrantNeutralHue = (sourceColorHct) => {
|
|
1897
|
-
return getRotatedHue(
|
|
1898
|
-
sourceColorHct,
|
|
1899
|
-
[0, 38, 105, 140, 333, 360],
|
|
1900
|
-
[-14, 10, -14, 10, -14]
|
|
1901
|
-
);
|
|
1902
|
-
};
|
|
1903
|
-
const getVibrantNeutralChroma = (sourceColorHct) => {
|
|
1904
|
-
getVibrantNeutralHue(sourceColorHct);
|
|
1905
|
-
return 28;
|
|
1906
|
-
};
|
|
1907
|
-
const vibrantVariant = {
|
|
1908
|
-
name: "vibrant",
|
|
1909
|
-
palettes: {
|
|
1910
|
-
primary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 74),
|
|
1911
|
-
secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1912
|
-
getRotatedHue(
|
|
1913
|
-
sourceColorHct,
|
|
1914
|
-
[0, 38, 105, 140, 333, 360],
|
|
1915
|
-
[-14, 10, -14, 10, -14]
|
|
1916
|
-
),
|
|
1917
|
-
56
|
|
1918
|
-
),
|
|
1919
|
-
tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1920
|
-
getRotatedHue(
|
|
1921
|
-
sourceColorHct,
|
|
1922
|
-
[0, 38, 71, 105, 140, 161, 253, 333, 360],
|
|
1923
|
-
[-72, 35, 24, -24, 62, 50, 62, -72]
|
|
1924
|
-
),
|
|
1925
|
-
56
|
|
1926
|
-
),
|
|
1927
|
-
neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1928
|
-
getVibrantNeutralHue(sourceColorHct),
|
|
1929
|
-
getVibrantNeutralChroma(sourceColorHct)
|
|
1930
|
-
),
|
|
1931
|
-
neutralVariant: ({ sourceColorHct }) => {
|
|
1932
|
-
const vibrantNeutralHue = getVibrantNeutralHue(sourceColorHct);
|
|
1933
|
-
const vibrantNeutralChroma = getVibrantNeutralChroma(sourceColorHct);
|
|
1934
|
-
return TonalPalette.fromHueAndChroma(
|
|
1935
|
-
vibrantNeutralHue,
|
|
1936
|
-
vibrantNeutralChroma * 1.29
|
|
1937
|
-
);
|
|
1938
|
-
},
|
|
1939
|
-
error: ({ sourceColorHct }) => {
|
|
1940
|
-
const errorHue = getPiecewiseHue(
|
|
1941
|
-
sourceColorHct,
|
|
1942
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1943
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1944
|
-
);
|
|
1945
|
-
return TonalPalette.fromHueAndChroma(errorHue, 80);
|
|
1946
|
-
}
|
|
1947
|
-
},
|
|
1948
|
-
customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(
|
|
1949
|
-
getRotatedHue(
|
|
1950
|
-
colorHct,
|
|
1951
|
-
[0, 38, 105, 140, 333, 360],
|
|
1952
|
-
[-14, 10, -14, 10, -14]
|
|
1953
|
-
),
|
|
1954
|
-
56
|
|
1955
|
-
)
|
|
1956
|
-
};
|
|
1957
|
-
const Variants = {
|
|
1958
|
-
Expressive: expressiveVariant,
|
|
1959
|
-
Neutral: neutralVariant,
|
|
1960
|
-
TonalSpot: tonalSpotVariant,
|
|
1961
|
-
Vibrant: vibrantVariant
|
|
1962
|
-
};
|
|
1963
1793
|
const defaultColors = (colorService) => {
|
|
1964
1794
|
const getColor = (key) => {
|
|
1965
1795
|
return colorService.getColor(key).getMaterialColor();
|
|
@@ -2707,37 +2537,13 @@ class API {
|
|
|
2707
2537
|
this.colors = colorApi;
|
|
2708
2538
|
this.themes = themeApi;
|
|
2709
2539
|
}
|
|
2540
|
+
async load() {
|
|
2541
|
+
return this.plugins.loadPlugins();
|
|
2542
|
+
}
|
|
2710
2543
|
}
|
|
2711
2544
|
const AppModule = {
|
|
2712
2545
|
api: asClass(API).singleton()
|
|
2713
2546
|
};
|
|
2714
|
-
class PluginAbstract {
|
|
2715
|
-
constructor(options) {
|
|
2716
|
-
__publicField(this, "options");
|
|
2717
|
-
__publicField(this, "pluginInstance");
|
|
2718
|
-
this.options = options;
|
|
2719
|
-
}
|
|
2720
|
-
init(api) {
|
|
2721
|
-
var _a, _b;
|
|
2722
|
-
this.pluginInstance = new this.pluginClass(api, this.options);
|
|
2723
|
-
(_b = (_a = this.pluginInstance).onInit) == null ? void 0 : _b.call(_a);
|
|
2724
|
-
return this;
|
|
2725
|
-
}
|
|
2726
|
-
getInstance() {
|
|
2727
|
-
if (!this.pluginInstance) {
|
|
2728
|
-
throw new Error(`Plugin ${this.name} is not initialized`);
|
|
2729
|
-
}
|
|
2730
|
-
return this.pluginInstance;
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
class PluginImplAbstract {
|
|
2734
|
-
constructor(api, options) {
|
|
2735
|
-
var _a;
|
|
2736
|
-
this.api = api;
|
|
2737
|
-
this.options = options;
|
|
2738
|
-
(_a = this.onInit) == null ? void 0 : _a.call(this);
|
|
2739
|
-
}
|
|
2740
|
-
}
|
|
2741
2547
|
class PluginApi {
|
|
2742
2548
|
constructor() {
|
|
2743
2549
|
__publicField(this, "plugins", /* @__PURE__ */ new Map());
|
|
@@ -2766,11 +2572,11 @@ class PluginApi {
|
|
|
2766
2572
|
"Some plugins couldn't be loaded due to missing dependencies: " + Array.from(plugins.keys())
|
|
2767
2573
|
);
|
|
2768
2574
|
}
|
|
2769
|
-
loadPlugins() {
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
(_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a);
|
|
2773
|
-
}
|
|
2575
|
+
async loadPlugins() {
|
|
2576
|
+
var _a, _b;
|
|
2577
|
+
for (const plugin of this.plugins.values()) {
|
|
2578
|
+
await ((_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a));
|
|
2579
|
+
}
|
|
2774
2580
|
}
|
|
2775
2581
|
getPlugin(plugin) {
|
|
2776
2582
|
const pluginInstance = this.plugins.get(new plugin().name);
|
|
@@ -2796,19 +2602,16 @@ registerModule(AppModule, PluginModule, ColorModule, ThemeModule);
|
|
|
2796
2602
|
function bootstrap() {
|
|
2797
2603
|
return AppContainer.resolve("api");
|
|
2798
2604
|
}
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
if (config == null) {
|
|
2810
|
-
return;
|
|
2811
|
-
}
|
|
2605
|
+
const initializeApi = () => {
|
|
2606
|
+
const api = bootstrap();
|
|
2607
|
+
registerModule({
|
|
2608
|
+
adapter: asValue(void 0)
|
|
2609
|
+
});
|
|
2610
|
+
return api;
|
|
2611
|
+
};
|
|
2612
|
+
const loader = async (config) => {
|
|
2613
|
+
const api = initializeApi();
|
|
2614
|
+
const init = () => {
|
|
2812
2615
|
const {
|
|
2813
2616
|
sourceColor,
|
|
2814
2617
|
contrastLevel = 0,
|
|
@@ -2819,7 +2622,7 @@ class AdapterAbstract {
|
|
|
2819
2622
|
useDefaultColors = true,
|
|
2820
2623
|
plugins
|
|
2821
2624
|
} = config;
|
|
2822
|
-
|
|
2625
|
+
api.themes.create({
|
|
2823
2626
|
contrastLevel,
|
|
2824
2627
|
isDark,
|
|
2825
2628
|
sourceColorHex: sourceColor,
|
|
@@ -2827,350 +2630,56 @@ class AdapterAbstract {
|
|
|
2827
2630
|
});
|
|
2828
2631
|
if (palettes) {
|
|
2829
2632
|
Object.entries(palettes).forEach(
|
|
2830
|
-
([key, value]) =>
|
|
2633
|
+
([key, value]) => api.themes.addCustomPalette(key, value)
|
|
2831
2634
|
);
|
|
2832
2635
|
}
|
|
2833
2636
|
if (useDefaultColors) {
|
|
2834
|
-
|
|
2637
|
+
api.colors.addColors(defaultColors);
|
|
2835
2638
|
}
|
|
2836
2639
|
if (colors) {
|
|
2837
|
-
|
|
2640
|
+
api.colors.addColors(colors);
|
|
2838
2641
|
}
|
|
2839
2642
|
if (plugins) {
|
|
2840
2643
|
plugins.forEach((plugin) => {
|
|
2841
|
-
|
|
2644
|
+
api.plugins.addPlugin(plugin);
|
|
2842
2645
|
});
|
|
2843
|
-
|
|
2844
|
-
}
|
|
2845
|
-
}
|
|
2846
|
-
load() {
|
|
2847
|
-
this.api.plugins.loadPlugins();
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
function defineConfig(configObject) {
|
|
2851
|
-
if (!configObject || typeof configObject !== "object") {
|
|
2852
|
-
throw new Error("The configuration is missing or not an object");
|
|
2853
|
-
}
|
|
2854
|
-
if (!("sourceColor" in configObject)) {
|
|
2855
|
-
throw new Error("Invalid configuration");
|
|
2856
|
-
}
|
|
2857
|
-
return configObject;
|
|
2858
|
-
}
|
|
2859
|
-
class NodeAdapter extends AdapterAbstract {
|
|
2860
|
-
constructor(configPath = "./theme.config") {
|
|
2861
|
-
super();
|
|
2862
|
-
this.configPath = configPath;
|
|
2863
|
-
}
|
|
2864
|
-
async getConfig() {
|
|
2865
|
-
if (typeof process !== "undefined" && process.release && process.release.name === "node") {
|
|
2866
|
-
const path2 = (await import("path")).default;
|
|
2867
|
-
const fs2 = (await import("fs")).default;
|
|
2868
|
-
const base = path2.resolve(this.configPath);
|
|
2869
|
-
const extensions = [".js", ".ts", ".mjs", ".cjs"];
|
|
2870
|
-
let configImport = null;
|
|
2871
|
-
for (const ext of extensions) {
|
|
2872
|
-
const path22 = base + ext;
|
|
2873
|
-
if (fs2.existsSync(path22)) {
|
|
2874
|
-
configImport = (await import(path22)).default;
|
|
2875
|
-
break;
|
|
2876
|
-
}
|
|
2877
|
-
}
|
|
2878
|
-
if (!configImport) {
|
|
2879
|
-
throw new Error(
|
|
2880
|
-
`Configuration file not found, looked for: ${base} with extensions: ${extensions.join(", ")}`
|
|
2881
|
-
);
|
|
2882
|
-
}
|
|
2883
|
-
let config;
|
|
2884
|
-
if ("default" in configImport) {
|
|
2885
|
-
config = configImport.default;
|
|
2886
|
-
} else {
|
|
2887
|
-
config = configImport;
|
|
2888
|
-
}
|
|
2889
|
-
return config;
|
|
2890
|
-
} else {
|
|
2891
|
-
throw new Error(
|
|
2892
|
-
"You must provide configuration object when using this library in a browser."
|
|
2893
|
-
);
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
const udixioVite = async (configPath = "./theme.config") => {
|
|
2898
|
-
if (global.NX_GRAPH_CREATION) {
|
|
2899
|
-
return;
|
|
2900
|
-
}
|
|
2901
|
-
class ViteAdapter extends AdapterAbstract {
|
|
2902
|
-
constructor(configPath2) {
|
|
2903
|
-
super();
|
|
2904
|
-
__publicField(this, "configExtension");
|
|
2905
|
-
this.configPath = configPath2;
|
|
2906
|
-
}
|
|
2907
|
-
getConfigPath() {
|
|
2908
|
-
if (!this.configExtension) {
|
|
2909
|
-
throw new Error("config extension not found");
|
|
2910
|
-
}
|
|
2911
|
-
return path.resolve(this.configPath + this.configExtension);
|
|
2912
|
-
}
|
|
2913
|
-
async getConfig() {
|
|
2914
|
-
const resolvedPath = path.resolve(this.configPath);
|
|
2915
|
-
const result = await loadConfigFromFile(
|
|
2916
|
-
{ command: "serve", mode: "development" },
|
|
2917
|
-
// ou 'build'
|
|
2918
|
-
resolvedPath
|
|
2919
|
-
);
|
|
2920
|
-
if (!(result == null ? void 0 : result.config)) {
|
|
2921
|
-
throw new Error("config not found");
|
|
2922
|
-
}
|
|
2923
|
-
if (!this.configExtension) {
|
|
2924
|
-
this.configExtension = path.extname(result.dependencies[0]);
|
|
2925
|
-
}
|
|
2926
|
-
return result.config;
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
const adapter = new ViteAdapter(configPath);
|
|
2930
|
-
await adapter.init();
|
|
2931
|
-
configPath = adapter.getConfigPath();
|
|
2932
|
-
return {
|
|
2933
|
-
name: "vite:udixio-theme",
|
|
2934
|
-
async buildStart() {
|
|
2935
|
-
if (fs.existsSync(configPath)) {
|
|
2936
|
-
this.addWatchFile(configPath);
|
|
2937
|
-
}
|
|
2938
|
-
adapter.load();
|
|
2939
|
-
},
|
|
2940
|
-
async generateBundle() {
|
|
2941
|
-
adapter.load();
|
|
2942
|
-
},
|
|
2943
|
-
// Handles Hot Module Replacement in dev server
|
|
2944
|
-
async handleHotUpdate({ server, file, modules }) {
|
|
2945
|
-
if (configPath === file) {
|
|
2946
|
-
const adapter2 = new ViteAdapter(configPath);
|
|
2947
|
-
await adapter2.init();
|
|
2948
|
-
adapter2.load();
|
|
2949
|
-
server.ws.send({ type: "full-reload", path: "*" });
|
|
2950
|
-
return modules;
|
|
2951
|
-
}
|
|
2952
|
-
return;
|
|
2646
|
+
api.plugins.initPlugins(api);
|
|
2953
2647
|
}
|
|
2954
2648
|
};
|
|
2649
|
+
const load = async () => {
|
|
2650
|
+
await api.plugins.loadPlugins();
|
|
2651
|
+
};
|
|
2652
|
+
init();
|
|
2653
|
+
await load();
|
|
2654
|
+
return api;
|
|
2955
2655
|
};
|
|
2956
|
-
var FontFamily = /* @__PURE__ */ ((FontFamily2) => {
|
|
2957
|
-
FontFamily2["Expressive"] = "expressive";
|
|
2958
|
-
FontFamily2["Neutral"] = "neutral";
|
|
2959
|
-
return FontFamily2;
|
|
2960
|
-
})(FontFamily || {});
|
|
2961
|
-
class FontPlugin extends PluginAbstract {
|
|
2962
|
-
constructor() {
|
|
2963
|
-
super(...arguments);
|
|
2964
|
-
__publicField(this, "dependencies", []);
|
|
2965
|
-
__publicField(this, "name", "font");
|
|
2966
|
-
__publicField(this, "pluginClass", FontPluginImpl);
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
class FontPluginImpl extends PluginImplAbstract {
|
|
2970
|
-
constructor() {
|
|
2971
|
-
super(...arguments);
|
|
2972
|
-
__publicField(this, "_fontFamily");
|
|
2973
|
-
__publicField(this, "_fontStyles");
|
|
2974
|
-
}
|
|
2975
|
-
get fontFamily() {
|
|
2976
|
-
if (!this._fontFamily) throw new Error("Font family not initialized");
|
|
2977
|
-
return this._fontFamily;
|
|
2978
|
-
}
|
|
2979
|
-
set fontFamily(value) {
|
|
2980
|
-
this._fontFamily = value;
|
|
2981
|
-
}
|
|
2982
|
-
get fontStyles() {
|
|
2983
|
-
if (!this._fontStyles) throw new Error("Font styles not initialized");
|
|
2984
|
-
return this._fontStyles;
|
|
2985
|
-
}
|
|
2986
|
-
set fontStyles(value) {
|
|
2987
|
-
this._fontStyles = value;
|
|
2988
|
-
}
|
|
2989
|
-
getFonts() {
|
|
2990
|
-
return {
|
|
2991
|
-
fontStyles: this.fontStyles,
|
|
2992
|
-
fontFamily: this.fontFamily
|
|
2993
|
-
};
|
|
2994
|
-
}
|
|
2995
|
-
onInit() {
|
|
2996
|
-
var _a, _b, _c, _d;
|
|
2997
|
-
this.fontFamily = {
|
|
2998
|
-
expressive: ((_b = (_a = this.options) == null ? void 0 : _a.fontFamily) == null ? void 0 : _b.expressive) ?? [
|
|
2999
|
-
"Roboto",
|
|
3000
|
-
"sans-serif"
|
|
3001
|
-
],
|
|
3002
|
-
neutral: ((_d = (_c = this.options) == null ? void 0 : _c.fontFamily) == null ? void 0 : _d.neutral) ?? ["Roboto", "sans-serif"]
|
|
3003
|
-
};
|
|
3004
|
-
this.fontStyles = {
|
|
3005
|
-
display: {
|
|
3006
|
-
large: {
|
|
3007
|
-
fontWeight: 400,
|
|
3008
|
-
fontSize: 3.5625,
|
|
3009
|
-
lineHeight: 4,
|
|
3010
|
-
letterSpacing: -0.015625,
|
|
3011
|
-
fontFamily: "expressive"
|
|
3012
|
-
/* Expressive */
|
|
3013
|
-
},
|
|
3014
|
-
medium: {
|
|
3015
|
-
fontWeight: 400,
|
|
3016
|
-
fontSize: 2.8125,
|
|
3017
|
-
lineHeight: 3.25,
|
|
3018
|
-
fontFamily: "expressive"
|
|
3019
|
-
/* Expressive */
|
|
3020
|
-
},
|
|
3021
|
-
small: {
|
|
3022
|
-
fontWeight: 400,
|
|
3023
|
-
fontSize: 2.25,
|
|
3024
|
-
lineHeight: 2.75,
|
|
3025
|
-
fontFamily: "expressive"
|
|
3026
|
-
/* Expressive */
|
|
3027
|
-
}
|
|
3028
|
-
},
|
|
3029
|
-
headline: {
|
|
3030
|
-
large: {
|
|
3031
|
-
fontWeight: 400,
|
|
3032
|
-
fontSize: 2,
|
|
3033
|
-
lineHeight: 2.5,
|
|
3034
|
-
fontFamily: "expressive"
|
|
3035
|
-
/* Expressive */
|
|
3036
|
-
},
|
|
3037
|
-
medium: {
|
|
3038
|
-
fontWeight: 400,
|
|
3039
|
-
fontSize: 1.75,
|
|
3040
|
-
lineHeight: 2.25,
|
|
3041
|
-
fontFamily: "expressive"
|
|
3042
|
-
/* Expressive */
|
|
3043
|
-
},
|
|
3044
|
-
small: {
|
|
3045
|
-
fontWeight: 400,
|
|
3046
|
-
fontSize: 1.5,
|
|
3047
|
-
lineHeight: 2,
|
|
3048
|
-
fontFamily: "expressive"
|
|
3049
|
-
/* Expressive */
|
|
3050
|
-
}
|
|
3051
|
-
},
|
|
3052
|
-
title: {
|
|
3053
|
-
large: {
|
|
3054
|
-
fontWeight: 400,
|
|
3055
|
-
fontSize: 1.375,
|
|
3056
|
-
lineHeight: 1.75,
|
|
3057
|
-
fontFamily: "neutral"
|
|
3058
|
-
/* Neutral */
|
|
3059
|
-
},
|
|
3060
|
-
medium: {
|
|
3061
|
-
fontWeight: 500,
|
|
3062
|
-
fontSize: 1,
|
|
3063
|
-
lineHeight: 1.5,
|
|
3064
|
-
fontFamily: "neutral",
|
|
3065
|
-
letterSpacing: 9375e-6
|
|
3066
|
-
},
|
|
3067
|
-
small: {
|
|
3068
|
-
fontWeight: 500,
|
|
3069
|
-
fontSize: 0.875,
|
|
3070
|
-
lineHeight: 1.25,
|
|
3071
|
-
fontFamily: "neutral",
|
|
3072
|
-
letterSpacing: 625e-5
|
|
3073
|
-
}
|
|
3074
|
-
},
|
|
3075
|
-
label: {
|
|
3076
|
-
large: {
|
|
3077
|
-
fontWeight: 500,
|
|
3078
|
-
fontSize: 0.875,
|
|
3079
|
-
lineHeight: 1.25,
|
|
3080
|
-
fontFamily: "neutral",
|
|
3081
|
-
letterSpacing: 625e-5
|
|
3082
|
-
},
|
|
3083
|
-
medium: {
|
|
3084
|
-
fontWeight: 500,
|
|
3085
|
-
fontSize: 0.75,
|
|
3086
|
-
lineHeight: 1,
|
|
3087
|
-
fontFamily: "neutral",
|
|
3088
|
-
letterSpacing: 0.03125
|
|
3089
|
-
},
|
|
3090
|
-
small: {
|
|
3091
|
-
fontWeight: 500,
|
|
3092
|
-
fontSize: 0.6875,
|
|
3093
|
-
lineHeight: 1,
|
|
3094
|
-
fontFamily: "neutral",
|
|
3095
|
-
letterSpacing: 0.03125
|
|
3096
|
-
}
|
|
3097
|
-
},
|
|
3098
|
-
body: {
|
|
3099
|
-
large: {
|
|
3100
|
-
fontWeight: 400,
|
|
3101
|
-
fontSize: 1,
|
|
3102
|
-
lineHeight: 1.5625,
|
|
3103
|
-
fontFamily: "neutral",
|
|
3104
|
-
letterSpacing: 0.03125
|
|
3105
|
-
},
|
|
3106
|
-
medium: {
|
|
3107
|
-
fontWeight: 400,
|
|
3108
|
-
fontSize: 0.875,
|
|
3109
|
-
lineHeight: 1.25,
|
|
3110
|
-
fontFamily: "neutral",
|
|
3111
|
-
letterSpacing: 0.015625
|
|
3112
|
-
},
|
|
3113
|
-
small: {
|
|
3114
|
-
fontWeight: 400,
|
|
3115
|
-
fontSize: 0.75,
|
|
3116
|
-
lineHeight: 1,
|
|
3117
|
-
fontFamily: "neutral",
|
|
3118
|
-
letterSpacing: 0.025
|
|
3119
|
-
}
|
|
3120
|
-
}
|
|
3121
|
-
};
|
|
3122
|
-
if (this.options && this.options.fontStyles)
|
|
3123
|
-
Object.entries(this.options.fontStyles).forEach(([key, fontParam]) => {
|
|
3124
|
-
const fontRole = key;
|
|
3125
|
-
Object.entries(fontParam).forEach(([size, fontStyle]) => {
|
|
3126
|
-
const fontSize = size;
|
|
3127
|
-
if (fontStyle) {
|
|
3128
|
-
this.fontStyles[fontRole][fontSize] = {
|
|
3129
|
-
...this.fontStyles[fontRole][fontSize],
|
|
3130
|
-
...fontStyle
|
|
3131
|
-
};
|
|
3132
|
-
}
|
|
3133
|
-
});
|
|
3134
|
-
});
|
|
3135
|
-
}
|
|
3136
|
-
}
|
|
3137
2656
|
export {
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
ThemeModule,
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
expressiveVariant,
|
|
3167
|
-
extendSpecVersion,
|
|
3168
|
-
getPiecewiseHue,
|
|
3169
|
-
getRotatedHue,
|
|
3170
|
-
highestSurface,
|
|
3171
|
-
neutralVariant,
|
|
3172
|
-
registerModule,
|
|
3173
|
-
tonalSpotVariant,
|
|
3174
|
-
udixioVite,
|
|
3175
|
-
vibrantVariant
|
|
2657
|
+
AppContainer as A,
|
|
2658
|
+
ColorApi as C,
|
|
2659
|
+
DynamicColor as D,
|
|
2660
|
+
Hct as H,
|
|
2661
|
+
PluginModule as P,
|
|
2662
|
+
SchemeManager as S,
|
|
2663
|
+
ToneDeltaPair as T,
|
|
2664
|
+
Variant as V,
|
|
2665
|
+
AppModule as a,
|
|
2666
|
+
API as b,
|
|
2667
|
+
ColorManager as c,
|
|
2668
|
+
ColorModule as d,
|
|
2669
|
+
ConfigurableColor as e,
|
|
2670
|
+
defaultColors as f,
|
|
2671
|
+
bootstrap as g,
|
|
2672
|
+
highestSurface as h,
|
|
2673
|
+
ContrastCurve as i,
|
|
2674
|
+
extendSpecVersion as j,
|
|
2675
|
+
PluginApi as k,
|
|
2676
|
+
loader as l,
|
|
2677
|
+
ThemeModule as m,
|
|
2678
|
+
Scheme as n,
|
|
2679
|
+
ThemeApi as o,
|
|
2680
|
+
getPiecewiseHue as p,
|
|
2681
|
+
getRotatedHue as q,
|
|
2682
|
+
registerModule as r,
|
|
2683
|
+
VariantManager as s,
|
|
2684
|
+
tonalSpotVariant as t
|
|
3176
2685
|
};
|