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