@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
|
@@ -1,55 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
26
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
27
5
|
const awilix = require("awilix");
|
|
28
6
|
const materialColorUtilities = require("@material/material-color-utilities");
|
|
29
|
-
const pathe = require("pathe");
|
|
30
|
-
const jiti = require("jiti");
|
|
31
|
-
const vite = require("vite");
|
|
32
|
-
const path = require("node:path");
|
|
33
|
-
const fs = require("node:fs");
|
|
34
|
-
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
35
|
-
function _interopNamespaceDefault(e) {
|
|
36
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
37
|
-
if (e) {
|
|
38
|
-
for (const k in e) {
|
|
39
|
-
if (k !== "default") {
|
|
40
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
41
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: () => e[k]
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
n.default = e;
|
|
49
|
-
return Object.freeze(n);
|
|
50
|
-
}
|
|
51
|
-
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
52
|
-
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
53
7
|
class ColorApi {
|
|
54
8
|
constructor({ colorManager }) {
|
|
55
9
|
__publicField(this, "colorManager");
|
|
@@ -1811,106 +1765,6 @@ class Variant {
|
|
|
1811
1765
|
this.colors = colors;
|
|
1812
1766
|
}
|
|
1813
1767
|
}
|
|
1814
|
-
const getExpressiveNeutralHue = (sourceColorHct) => {
|
|
1815
|
-
const hue = getRotatedHue(
|
|
1816
|
-
sourceColorHct,
|
|
1817
|
-
[0, 71, 124, 253, 278, 300, 360],
|
|
1818
|
-
[10, 0, 10, 0, 10, 0]
|
|
1819
|
-
);
|
|
1820
|
-
return hue;
|
|
1821
|
-
};
|
|
1822
|
-
const getExpressiveNeutralChroma = (sourceColorHct, isDark) => {
|
|
1823
|
-
const neutralHue = getExpressiveNeutralHue(sourceColorHct);
|
|
1824
|
-
return isDark ? Hct.isYellow(neutralHue) ? 6 : 14 : 18;
|
|
1825
|
-
};
|
|
1826
|
-
const expressiveVariant = {
|
|
1827
|
-
name: "expressive",
|
|
1828
|
-
palettes: {
|
|
1829
|
-
primary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 36 : 48),
|
|
1830
|
-
secondary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1831
|
-
getRotatedHue(
|
|
1832
|
-
sourceColorHct,
|
|
1833
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1834
|
-
[-160, 155, -100, 96, -96, -156, -165, -160]
|
|
1835
|
-
),
|
|
1836
|
-
isDark ? 16 : 24
|
|
1837
|
-
),
|
|
1838
|
-
tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1839
|
-
getRotatedHue(
|
|
1840
|
-
sourceColorHct,
|
|
1841
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1842
|
-
[-165, 160, -105, 101, -101, -160, -170, -165]
|
|
1843
|
-
),
|
|
1844
|
-
48
|
|
1845
|
-
),
|
|
1846
|
-
neutral: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1847
|
-
getExpressiveNeutralHue(sourceColorHct),
|
|
1848
|
-
getExpressiveNeutralChroma(sourceColorHct, isDark)
|
|
1849
|
-
),
|
|
1850
|
-
neutralVariant: ({ sourceColorHct, isDark }) => {
|
|
1851
|
-
const expressiveNeutralHue = getExpressiveNeutralHue(sourceColorHct);
|
|
1852
|
-
const expressiveNeutralChroma = getExpressiveNeutralChroma(
|
|
1853
|
-
sourceColorHct,
|
|
1854
|
-
isDark
|
|
1855
|
-
);
|
|
1856
|
-
return materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1857
|
-
expressiveNeutralHue,
|
|
1858
|
-
expressiveNeutralChroma * (expressiveNeutralHue >= 105 && expressiveNeutralHue < 125 ? 1.6 : 2.3)
|
|
1859
|
-
);
|
|
1860
|
-
},
|
|
1861
|
-
error: ({ sourceColorHct }) => {
|
|
1862
|
-
const errorHue = getPiecewiseHue(
|
|
1863
|
-
sourceColorHct,
|
|
1864
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1865
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1866
|
-
);
|
|
1867
|
-
return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 64);
|
|
1868
|
-
}
|
|
1869
|
-
},
|
|
1870
|
-
customPalettes: ({ colorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1871
|
-
getRotatedHue(
|
|
1872
|
-
colorHct,
|
|
1873
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1874
|
-
[-160, 155, -100, 96, -96, -156, -165, -160]
|
|
1875
|
-
),
|
|
1876
|
-
isDark ? 16 : 24
|
|
1877
|
-
)
|
|
1878
|
-
};
|
|
1879
|
-
const neutralVariant = {
|
|
1880
|
-
name: "neutral",
|
|
1881
|
-
palettes: {
|
|
1882
|
-
primary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1883
|
-
sourceColorHct.hue,
|
|
1884
|
-
Hct.isBlue(sourceColorHct.hue) ? 12 : 8
|
|
1885
|
-
),
|
|
1886
|
-
secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1887
|
-
sourceColorHct.hue,
|
|
1888
|
-
Hct.isBlue(sourceColorHct.hue) ? 6 : 4
|
|
1889
|
-
),
|
|
1890
|
-
tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1891
|
-
getRotatedHue(
|
|
1892
|
-
sourceColorHct,
|
|
1893
|
-
[0, 38, 105, 161, 204, 278, 333, 360],
|
|
1894
|
-
[-32, 26, 10, -39, 24, -15, -32]
|
|
1895
|
-
),
|
|
1896
|
-
20
|
|
1897
|
-
),
|
|
1898
|
-
neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4),
|
|
1899
|
-
neutralVariant: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4 * 2.2),
|
|
1900
|
-
error: ({ sourceColorHct }) => {
|
|
1901
|
-
const errorHue = getPiecewiseHue(
|
|
1902
|
-
sourceColorHct,
|
|
1903
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1904
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1905
|
-
);
|
|
1906
|
-
return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 50);
|
|
1907
|
-
}
|
|
1908
|
-
},
|
|
1909
|
-
customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1910
|
-
colorHct.hue,
|
|
1911
|
-
Hct.isBlue(colorHct.hue) ? 6 : 4
|
|
1912
|
-
)
|
|
1913
|
-
};
|
|
1914
1768
|
const tonalSpotVariant = {
|
|
1915
1769
|
name: "tonalSpot",
|
|
1916
1770
|
palettes: {
|
|
@@ -1937,73 +1791,6 @@ const tonalSpotVariant = {
|
|
|
1937
1791
|
},
|
|
1938
1792
|
customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16)
|
|
1939
1793
|
};
|
|
1940
|
-
const getVibrantNeutralHue = (sourceColorHct) => {
|
|
1941
|
-
return getRotatedHue(
|
|
1942
|
-
sourceColorHct,
|
|
1943
|
-
[0, 38, 105, 140, 333, 360],
|
|
1944
|
-
[-14, 10, -14, 10, -14]
|
|
1945
|
-
);
|
|
1946
|
-
};
|
|
1947
|
-
const getVibrantNeutralChroma = (sourceColorHct) => {
|
|
1948
|
-
getVibrantNeutralHue(sourceColorHct);
|
|
1949
|
-
return 28;
|
|
1950
|
-
};
|
|
1951
|
-
const vibrantVariant = {
|
|
1952
|
-
name: "vibrant",
|
|
1953
|
-
palettes: {
|
|
1954
|
-
primary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 74),
|
|
1955
|
-
secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1956
|
-
getRotatedHue(
|
|
1957
|
-
sourceColorHct,
|
|
1958
|
-
[0, 38, 105, 140, 333, 360],
|
|
1959
|
-
[-14, 10, -14, 10, -14]
|
|
1960
|
-
),
|
|
1961
|
-
56
|
|
1962
|
-
),
|
|
1963
|
-
tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1964
|
-
getRotatedHue(
|
|
1965
|
-
sourceColorHct,
|
|
1966
|
-
[0, 38, 71, 105, 140, 161, 253, 333, 360],
|
|
1967
|
-
[-72, 35, 24, -24, 62, 50, 62, -72]
|
|
1968
|
-
),
|
|
1969
|
-
56
|
|
1970
|
-
),
|
|
1971
|
-
neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1972
|
-
getVibrantNeutralHue(sourceColorHct),
|
|
1973
|
-
getVibrantNeutralChroma(sourceColorHct)
|
|
1974
|
-
),
|
|
1975
|
-
neutralVariant: ({ sourceColorHct }) => {
|
|
1976
|
-
const vibrantNeutralHue = getVibrantNeutralHue(sourceColorHct);
|
|
1977
|
-
const vibrantNeutralChroma = getVibrantNeutralChroma(sourceColorHct);
|
|
1978
|
-
return materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1979
|
-
vibrantNeutralHue,
|
|
1980
|
-
vibrantNeutralChroma * 1.29
|
|
1981
|
-
);
|
|
1982
|
-
},
|
|
1983
|
-
error: ({ sourceColorHct }) => {
|
|
1984
|
-
const errorHue = getPiecewiseHue(
|
|
1985
|
-
sourceColorHct,
|
|
1986
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1987
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1988
|
-
);
|
|
1989
|
-
return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 80);
|
|
1990
|
-
}
|
|
1991
|
-
},
|
|
1992
|
-
customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(
|
|
1993
|
-
getRotatedHue(
|
|
1994
|
-
colorHct,
|
|
1995
|
-
[0, 38, 105, 140, 333, 360],
|
|
1996
|
-
[-14, 10, -14, 10, -14]
|
|
1997
|
-
),
|
|
1998
|
-
56
|
|
1999
|
-
)
|
|
2000
|
-
};
|
|
2001
|
-
const Variants = {
|
|
2002
|
-
Expressive: expressiveVariant,
|
|
2003
|
-
Neutral: neutralVariant,
|
|
2004
|
-
TonalSpot: tonalSpotVariant,
|
|
2005
|
-
Vibrant: vibrantVariant
|
|
2006
|
-
};
|
|
2007
1794
|
const defaultColors = (colorService) => {
|
|
2008
1795
|
const getColor = (key) => {
|
|
2009
1796
|
return colorService.getColor(key).getMaterialColor();
|
|
@@ -2751,37 +2538,13 @@ class API {
|
|
|
2751
2538
|
this.colors = colorApi;
|
|
2752
2539
|
this.themes = themeApi;
|
|
2753
2540
|
}
|
|
2541
|
+
async load() {
|
|
2542
|
+
return this.plugins.loadPlugins();
|
|
2543
|
+
}
|
|
2754
2544
|
}
|
|
2755
2545
|
const AppModule = {
|
|
2756
2546
|
api: awilix.asClass(API).singleton()
|
|
2757
2547
|
};
|
|
2758
|
-
class PluginAbstract {
|
|
2759
|
-
constructor(options) {
|
|
2760
|
-
__publicField(this, "options");
|
|
2761
|
-
__publicField(this, "pluginInstance");
|
|
2762
|
-
this.options = options;
|
|
2763
|
-
}
|
|
2764
|
-
init(api) {
|
|
2765
|
-
var _a, _b;
|
|
2766
|
-
this.pluginInstance = new this.pluginClass(api, this.options);
|
|
2767
|
-
(_b = (_a = this.pluginInstance).onInit) == null ? void 0 : _b.call(_a);
|
|
2768
|
-
return this;
|
|
2769
|
-
}
|
|
2770
|
-
getInstance() {
|
|
2771
|
-
if (!this.pluginInstance) {
|
|
2772
|
-
throw new Error(`Plugin ${this.name} is not initialized`);
|
|
2773
|
-
}
|
|
2774
|
-
return this.pluginInstance;
|
|
2775
|
-
}
|
|
2776
|
-
}
|
|
2777
|
-
class PluginImplAbstract {
|
|
2778
|
-
constructor(api, options) {
|
|
2779
|
-
var _a;
|
|
2780
|
-
this.api = api;
|
|
2781
|
-
this.options = options;
|
|
2782
|
-
(_a = this.onInit) == null ? void 0 : _a.call(this);
|
|
2783
|
-
}
|
|
2784
|
-
}
|
|
2785
2548
|
class PluginApi {
|
|
2786
2549
|
constructor() {
|
|
2787
2550
|
__publicField(this, "plugins", /* @__PURE__ */ new Map());
|
|
@@ -2810,11 +2573,11 @@ class PluginApi {
|
|
|
2810
2573
|
"Some plugins couldn't be loaded due to missing dependencies: " + Array.from(plugins.keys())
|
|
2811
2574
|
);
|
|
2812
2575
|
}
|
|
2813
|
-
loadPlugins() {
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
(_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a);
|
|
2817
|
-
}
|
|
2576
|
+
async loadPlugins() {
|
|
2577
|
+
var _a, _b;
|
|
2578
|
+
for (const plugin of this.plugins.values()) {
|
|
2579
|
+
await ((_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a));
|
|
2580
|
+
}
|
|
2818
2581
|
}
|
|
2819
2582
|
getPlugin(plugin) {
|
|
2820
2583
|
const pluginInstance = this.plugins.get(new plugin().name);
|
|
@@ -2840,19 +2603,16 @@ registerModule(AppModule, PluginModule, ColorModule, ThemeModule);
|
|
|
2840
2603
|
function bootstrap() {
|
|
2841
2604
|
return AppContainer.resolve("api");
|
|
2842
2605
|
}
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
if (config == null) {
|
|
2854
|
-
return;
|
|
2855
|
-
}
|
|
2606
|
+
const initializeApi = () => {
|
|
2607
|
+
const api = bootstrap();
|
|
2608
|
+
registerModule({
|
|
2609
|
+
adapter: awilix.asValue(void 0)
|
|
2610
|
+
});
|
|
2611
|
+
return api;
|
|
2612
|
+
};
|
|
2613
|
+
const loader = async (config) => {
|
|
2614
|
+
const api = initializeApi();
|
|
2615
|
+
const init = () => {
|
|
2856
2616
|
const {
|
|
2857
2617
|
sourceColor,
|
|
2858
2618
|
contrastLevel = 0,
|
|
@@ -2863,7 +2623,7 @@ class AdapterAbstract {
|
|
|
2863
2623
|
useDefaultColors = true,
|
|
2864
2624
|
plugins
|
|
2865
2625
|
} = config;
|
|
2866
|
-
|
|
2626
|
+
api.themes.create({
|
|
2867
2627
|
contrastLevel,
|
|
2868
2628
|
isDark,
|
|
2869
2629
|
sourceColorHex: sourceColor,
|
|
@@ -2871,321 +2631,30 @@ class AdapterAbstract {
|
|
|
2871
2631
|
});
|
|
2872
2632
|
if (palettes) {
|
|
2873
2633
|
Object.entries(palettes).forEach(
|
|
2874
|
-
([key, value]) =>
|
|
2634
|
+
([key, value]) => api.themes.addCustomPalette(key, value)
|
|
2875
2635
|
);
|
|
2876
2636
|
}
|
|
2877
2637
|
if (useDefaultColors) {
|
|
2878
|
-
|
|
2638
|
+
api.colors.addColors(defaultColors);
|
|
2879
2639
|
}
|
|
2880
2640
|
if (colors) {
|
|
2881
|
-
|
|
2641
|
+
api.colors.addColors(colors);
|
|
2882
2642
|
}
|
|
2883
2643
|
if (plugins) {
|
|
2884
2644
|
plugins.forEach((plugin) => {
|
|
2885
|
-
|
|
2645
|
+
api.plugins.addPlugin(plugin);
|
|
2886
2646
|
});
|
|
2887
|
-
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
load() {
|
|
2891
|
-
this.api.plugins.loadPlugins();
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
function defineConfig(configObject) {
|
|
2895
|
-
if (!configObject || typeof configObject !== "object") {
|
|
2896
|
-
throw new Error("The configuration is missing or not an object");
|
|
2897
|
-
}
|
|
2898
|
-
if (!("sourceColor" in configObject)) {
|
|
2899
|
-
throw new Error("Invalid configuration");
|
|
2900
|
-
}
|
|
2901
|
-
return configObject;
|
|
2902
|
-
}
|
|
2903
|
-
class NodeAdapter extends AdapterAbstract {
|
|
2904
|
-
constructor(configPath = "./theme.config") {
|
|
2905
|
-
super();
|
|
2906
|
-
this.configPath = configPath;
|
|
2907
|
-
}
|
|
2908
|
-
async getConfig() {
|
|
2909
|
-
if (typeof process !== "undefined" && process.release && process.release.name === "node") {
|
|
2910
|
-
const fs2 = (await import("fs")).default;
|
|
2911
|
-
const jiti$1 = jiti.createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href, {
|
|
2912
|
-
// Options optionnelles
|
|
2913
|
-
debug: process.env.NODE_ENV === "development",
|
|
2914
|
-
cache: true,
|
|
2915
|
-
// Cache les transpilations
|
|
2916
|
-
interopDefault: true
|
|
2917
|
-
// Gère automatiquement les exports par défaut
|
|
2918
|
-
});
|
|
2919
|
-
const base = pathe.resolve(this.configPath);
|
|
2920
|
-
const extensions = [".ts", ".js", ".mjs", ".cjs"];
|
|
2921
|
-
let config = null;
|
|
2922
|
-
for (const ext of extensions) {
|
|
2923
|
-
const configFilePath = base + ext;
|
|
2924
|
-
if (fs2.existsSync(configFilePath)) {
|
|
2925
|
-
try {
|
|
2926
|
-
config = await jiti$1.import(configFilePath, { default: true });
|
|
2927
|
-
break;
|
|
2928
|
-
} catch (error) {
|
|
2929
|
-
console.warn(`Failed to load ${configFilePath}:`, error);
|
|
2930
|
-
continue;
|
|
2931
|
-
}
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
if (!config) {
|
|
2935
|
-
throw new Error(
|
|
2936
|
-
`Configuration file not found, looked for: ${base} with extensions: ${extensions.join(", ")}`
|
|
2937
|
-
);
|
|
2938
|
-
}
|
|
2939
|
-
return config;
|
|
2940
|
-
} else {
|
|
2941
|
-
throw new Error(
|
|
2942
|
-
"You must provide configuration object when using this library in a browser."
|
|
2943
|
-
);
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
const udixioVite = async (configPath = "./theme.config") => {
|
|
2948
|
-
if (global.NX_GRAPH_CREATION) {
|
|
2949
|
-
return;
|
|
2950
|
-
}
|
|
2951
|
-
class ViteAdapter extends AdapterAbstract {
|
|
2952
|
-
constructor(configPath2) {
|
|
2953
|
-
super();
|
|
2954
|
-
__publicField(this, "configExtension");
|
|
2955
|
-
this.configPath = configPath2;
|
|
2956
|
-
}
|
|
2957
|
-
getConfigPath() {
|
|
2958
|
-
if (!this.configExtension) {
|
|
2959
|
-
throw new Error("config extension not found");
|
|
2960
|
-
}
|
|
2961
|
-
return path__namespace.resolve(this.configPath + this.configExtension);
|
|
2962
|
-
}
|
|
2963
|
-
async getConfig() {
|
|
2964
|
-
const resolvedPath = path__namespace.resolve(this.configPath);
|
|
2965
|
-
const result = await vite.loadConfigFromFile(
|
|
2966
|
-
{ command: "serve", mode: "development" },
|
|
2967
|
-
// ou 'build'
|
|
2968
|
-
resolvedPath
|
|
2969
|
-
);
|
|
2970
|
-
if (!(result == null ? void 0 : result.config)) {
|
|
2971
|
-
throw new Error("config not found");
|
|
2972
|
-
}
|
|
2973
|
-
if (!this.configExtension) {
|
|
2974
|
-
this.configExtension = path__namespace.extname(result.dependencies[0]);
|
|
2975
|
-
}
|
|
2976
|
-
return result.config;
|
|
2977
|
-
}
|
|
2978
|
-
}
|
|
2979
|
-
const adapter = new ViteAdapter(configPath);
|
|
2980
|
-
await adapter.init();
|
|
2981
|
-
configPath = adapter.getConfigPath();
|
|
2982
|
-
return {
|
|
2983
|
-
name: "vite:udixio-theme",
|
|
2984
|
-
async buildStart() {
|
|
2985
|
-
if (fs__namespace.existsSync(configPath)) {
|
|
2986
|
-
this.addWatchFile(configPath);
|
|
2987
|
-
}
|
|
2988
|
-
adapter.load();
|
|
2989
|
-
},
|
|
2990
|
-
async generateBundle() {
|
|
2991
|
-
adapter.load();
|
|
2992
|
-
},
|
|
2993
|
-
// Handles Hot Module Replacement in dev server
|
|
2994
|
-
async handleHotUpdate({ server, file, modules }) {
|
|
2995
|
-
if (configPath === file) {
|
|
2996
|
-
const adapter2 = new ViteAdapter(configPath);
|
|
2997
|
-
await adapter2.init();
|
|
2998
|
-
adapter2.load();
|
|
2999
|
-
server.ws.send({ type: "full-reload", path: "*" });
|
|
3000
|
-
return modules;
|
|
3001
|
-
}
|
|
3002
|
-
return;
|
|
2647
|
+
api.plugins.initPlugins(api);
|
|
3003
2648
|
}
|
|
3004
2649
|
};
|
|
2650
|
+
const load = async () => {
|
|
2651
|
+
await api.plugins.loadPlugins();
|
|
2652
|
+
};
|
|
2653
|
+
init();
|
|
2654
|
+
await load();
|
|
2655
|
+
return api;
|
|
3005
2656
|
};
|
|
3006
|
-
var FontFamily = /* @__PURE__ */ ((FontFamily2) => {
|
|
3007
|
-
FontFamily2["Expressive"] = "expressive";
|
|
3008
|
-
FontFamily2["Neutral"] = "neutral";
|
|
3009
|
-
return FontFamily2;
|
|
3010
|
-
})(FontFamily || {});
|
|
3011
|
-
class FontPlugin extends PluginAbstract {
|
|
3012
|
-
constructor() {
|
|
3013
|
-
super(...arguments);
|
|
3014
|
-
__publicField(this, "dependencies", []);
|
|
3015
|
-
__publicField(this, "name", "font");
|
|
3016
|
-
__publicField(this, "pluginClass", FontPluginImpl);
|
|
3017
|
-
}
|
|
3018
|
-
}
|
|
3019
|
-
class FontPluginImpl extends PluginImplAbstract {
|
|
3020
|
-
constructor() {
|
|
3021
|
-
super(...arguments);
|
|
3022
|
-
__publicField(this, "_fontFamily");
|
|
3023
|
-
__publicField(this, "_fontStyles");
|
|
3024
|
-
}
|
|
3025
|
-
get fontFamily() {
|
|
3026
|
-
if (!this._fontFamily) throw new Error("Font family not initialized");
|
|
3027
|
-
return this._fontFamily;
|
|
3028
|
-
}
|
|
3029
|
-
set fontFamily(value) {
|
|
3030
|
-
this._fontFamily = value;
|
|
3031
|
-
}
|
|
3032
|
-
get fontStyles() {
|
|
3033
|
-
if (!this._fontStyles) throw new Error("Font styles not initialized");
|
|
3034
|
-
return this._fontStyles;
|
|
3035
|
-
}
|
|
3036
|
-
set fontStyles(value) {
|
|
3037
|
-
this._fontStyles = value;
|
|
3038
|
-
}
|
|
3039
|
-
getFonts() {
|
|
3040
|
-
return {
|
|
3041
|
-
fontStyles: this.fontStyles,
|
|
3042
|
-
fontFamily: this.fontFamily
|
|
3043
|
-
};
|
|
3044
|
-
}
|
|
3045
|
-
onInit() {
|
|
3046
|
-
var _a, _b, _c, _d;
|
|
3047
|
-
this.fontFamily = {
|
|
3048
|
-
expressive: ((_b = (_a = this.options) == null ? void 0 : _a.fontFamily) == null ? void 0 : _b.expressive) ?? [
|
|
3049
|
-
"Roboto",
|
|
3050
|
-
"sans-serif"
|
|
3051
|
-
],
|
|
3052
|
-
neutral: ((_d = (_c = this.options) == null ? void 0 : _c.fontFamily) == null ? void 0 : _d.neutral) ?? ["Roboto", "sans-serif"]
|
|
3053
|
-
};
|
|
3054
|
-
this.fontStyles = {
|
|
3055
|
-
display: {
|
|
3056
|
-
large: {
|
|
3057
|
-
fontWeight: 400,
|
|
3058
|
-
fontSize: 3.5625,
|
|
3059
|
-
lineHeight: 4,
|
|
3060
|
-
letterSpacing: -0.015625,
|
|
3061
|
-
fontFamily: "expressive"
|
|
3062
|
-
/* Expressive */
|
|
3063
|
-
},
|
|
3064
|
-
medium: {
|
|
3065
|
-
fontWeight: 400,
|
|
3066
|
-
fontSize: 2.8125,
|
|
3067
|
-
lineHeight: 3.25,
|
|
3068
|
-
fontFamily: "expressive"
|
|
3069
|
-
/* Expressive */
|
|
3070
|
-
},
|
|
3071
|
-
small: {
|
|
3072
|
-
fontWeight: 400,
|
|
3073
|
-
fontSize: 2.25,
|
|
3074
|
-
lineHeight: 2.75,
|
|
3075
|
-
fontFamily: "expressive"
|
|
3076
|
-
/* Expressive */
|
|
3077
|
-
}
|
|
3078
|
-
},
|
|
3079
|
-
headline: {
|
|
3080
|
-
large: {
|
|
3081
|
-
fontWeight: 400,
|
|
3082
|
-
fontSize: 2,
|
|
3083
|
-
lineHeight: 2.5,
|
|
3084
|
-
fontFamily: "expressive"
|
|
3085
|
-
/* Expressive */
|
|
3086
|
-
},
|
|
3087
|
-
medium: {
|
|
3088
|
-
fontWeight: 400,
|
|
3089
|
-
fontSize: 1.75,
|
|
3090
|
-
lineHeight: 2.25,
|
|
3091
|
-
fontFamily: "expressive"
|
|
3092
|
-
/* Expressive */
|
|
3093
|
-
},
|
|
3094
|
-
small: {
|
|
3095
|
-
fontWeight: 400,
|
|
3096
|
-
fontSize: 1.5,
|
|
3097
|
-
lineHeight: 2,
|
|
3098
|
-
fontFamily: "expressive"
|
|
3099
|
-
/* Expressive */
|
|
3100
|
-
}
|
|
3101
|
-
},
|
|
3102
|
-
title: {
|
|
3103
|
-
large: {
|
|
3104
|
-
fontWeight: 400,
|
|
3105
|
-
fontSize: 1.375,
|
|
3106
|
-
lineHeight: 1.75,
|
|
3107
|
-
fontFamily: "neutral"
|
|
3108
|
-
/* Neutral */
|
|
3109
|
-
},
|
|
3110
|
-
medium: {
|
|
3111
|
-
fontWeight: 500,
|
|
3112
|
-
fontSize: 1,
|
|
3113
|
-
lineHeight: 1.5,
|
|
3114
|
-
fontFamily: "neutral",
|
|
3115
|
-
letterSpacing: 9375e-6
|
|
3116
|
-
},
|
|
3117
|
-
small: {
|
|
3118
|
-
fontWeight: 500,
|
|
3119
|
-
fontSize: 0.875,
|
|
3120
|
-
lineHeight: 1.25,
|
|
3121
|
-
fontFamily: "neutral",
|
|
3122
|
-
letterSpacing: 625e-5
|
|
3123
|
-
}
|
|
3124
|
-
},
|
|
3125
|
-
label: {
|
|
3126
|
-
large: {
|
|
3127
|
-
fontWeight: 500,
|
|
3128
|
-
fontSize: 0.875,
|
|
3129
|
-
lineHeight: 1.25,
|
|
3130
|
-
fontFamily: "neutral",
|
|
3131
|
-
letterSpacing: 625e-5
|
|
3132
|
-
},
|
|
3133
|
-
medium: {
|
|
3134
|
-
fontWeight: 500,
|
|
3135
|
-
fontSize: 0.75,
|
|
3136
|
-
lineHeight: 1,
|
|
3137
|
-
fontFamily: "neutral",
|
|
3138
|
-
letterSpacing: 0.03125
|
|
3139
|
-
},
|
|
3140
|
-
small: {
|
|
3141
|
-
fontWeight: 500,
|
|
3142
|
-
fontSize: 0.6875,
|
|
3143
|
-
lineHeight: 1,
|
|
3144
|
-
fontFamily: "neutral",
|
|
3145
|
-
letterSpacing: 0.03125
|
|
3146
|
-
}
|
|
3147
|
-
},
|
|
3148
|
-
body: {
|
|
3149
|
-
large: {
|
|
3150
|
-
fontWeight: 400,
|
|
3151
|
-
fontSize: 1,
|
|
3152
|
-
lineHeight: 1.5625,
|
|
3153
|
-
fontFamily: "neutral",
|
|
3154
|
-
letterSpacing: 0.03125
|
|
3155
|
-
},
|
|
3156
|
-
medium: {
|
|
3157
|
-
fontWeight: 400,
|
|
3158
|
-
fontSize: 0.875,
|
|
3159
|
-
lineHeight: 1.25,
|
|
3160
|
-
fontFamily: "neutral",
|
|
3161
|
-
letterSpacing: 0.015625
|
|
3162
|
-
},
|
|
3163
|
-
small: {
|
|
3164
|
-
fontWeight: 400,
|
|
3165
|
-
fontSize: 0.75,
|
|
3166
|
-
lineHeight: 1,
|
|
3167
|
-
fontFamily: "neutral",
|
|
3168
|
-
letterSpacing: 0.025
|
|
3169
|
-
}
|
|
3170
|
-
}
|
|
3171
|
-
};
|
|
3172
|
-
if (this.options && this.options.fontStyles)
|
|
3173
|
-
Object.entries(this.options.fontStyles).forEach(([key, fontParam]) => {
|
|
3174
|
-
const fontRole = key;
|
|
3175
|
-
Object.entries(fontParam).forEach(([size, fontStyle]) => {
|
|
3176
|
-
const fontSize = size;
|
|
3177
|
-
if (fontStyle) {
|
|
3178
|
-
this.fontStyles[fontRole][fontSize] = {
|
|
3179
|
-
...this.fontStyles[fontRole][fontSize],
|
|
3180
|
-
...fontStyle
|
|
3181
|
-
};
|
|
3182
|
-
}
|
|
3183
|
-
});
|
|
3184
|
-
});
|
|
3185
|
-
}
|
|
3186
|
-
}
|
|
3187
2657
|
exports.API = API;
|
|
3188
|
-
exports.AdapterAbstract = AdapterAbstract;
|
|
3189
2658
|
exports.AppContainer = AppContainer;
|
|
3190
2659
|
exports.AppModule = AppModule;
|
|
3191
2660
|
exports.ColorApi = ColorApi;
|
|
@@ -3194,12 +2663,8 @@ exports.ColorModule = ColorModule;
|
|
|
3194
2663
|
exports.ConfigurableColor = ConfigurableColor;
|
|
3195
2664
|
exports.ContrastCurve = ContrastCurve;
|
|
3196
2665
|
exports.DynamicColor = DynamicColor;
|
|
3197
|
-
exports.
|
|
3198
|
-
exports.FontPlugin = FontPlugin;
|
|
3199
|
-
exports.NodeAdapter = NodeAdapter;
|
|
3200
|
-
exports.PluginAbstract = PluginAbstract;
|
|
2666
|
+
exports.Hct = Hct;
|
|
3201
2667
|
exports.PluginApi = PluginApi;
|
|
3202
|
-
exports.PluginImplAbstract = PluginImplAbstract;
|
|
3203
2668
|
exports.PluginModule = PluginModule;
|
|
3204
2669
|
exports.Scheme = Scheme;
|
|
3205
2670
|
exports.SchemeManager = SchemeManager;
|
|
@@ -3208,17 +2673,12 @@ exports.ThemeModule = ThemeModule;
|
|
|
3208
2673
|
exports.ToneDeltaPair = ToneDeltaPair;
|
|
3209
2674
|
exports.Variant = Variant;
|
|
3210
2675
|
exports.VariantManager = VariantManager;
|
|
3211
|
-
exports.Variants = Variants;
|
|
3212
2676
|
exports.bootstrap = bootstrap;
|
|
3213
2677
|
exports.defaultColors = defaultColors;
|
|
3214
|
-
exports.defineConfig = defineConfig;
|
|
3215
|
-
exports.expressiveVariant = expressiveVariant;
|
|
3216
2678
|
exports.extendSpecVersion = extendSpecVersion;
|
|
3217
2679
|
exports.getPiecewiseHue = getPiecewiseHue;
|
|
3218
2680
|
exports.getRotatedHue = getRotatedHue;
|
|
3219
2681
|
exports.highestSurface = highestSurface;
|
|
3220
|
-
exports.
|
|
2682
|
+
exports.loader = loader;
|
|
3221
2683
|
exports.registerModule = registerModule;
|
|
3222
2684
|
exports.tonalSpotVariant = tonalSpotVariant;
|
|
3223
|
-
exports.udixioVite = udixioVite;
|
|
3224
|
-
exports.vibrantVariant = vibrantVariant;
|