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