@udixio/theme 1.1.0 → 1.3.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/bin/main.ts +85 -0
  3. package/dist/API.d.ts +1 -0
  4. package/dist/API.d.ts.map +1 -1
  5. package/dist/bin.cjs +64 -0
  6. package/dist/bin.js +63 -0
  7. package/dist/browser.cjs +39 -0
  8. package/dist/browser.js +39 -0
  9. package/dist/color/color.manager.d.ts.map +1 -1
  10. package/dist/color/default-color.d.ts.map +1 -1
  11. package/dist/config/config.interface.d.ts.map +1 -0
  12. package/dist/config/define-config.d.ts.map +1 -0
  13. package/dist/config/index.d.ts +3 -0
  14. package/dist/config/index.d.ts.map +1 -0
  15. package/dist/config/index.node.d.ts +2 -0
  16. package/dist/config/index.node.d.ts.map +1 -0
  17. package/dist/config/resolver-config.d.ts +11 -0
  18. package/dist/config/resolver-config.d.ts.map +1 -0
  19. package/dist/define-config-B1QPKKY_.js +430 -0
  20. package/dist/define-config-BGgVazsr.cjs +429 -0
  21. package/dist/index.browser.d.ts +2 -0
  22. package/dist/index.browser.d.ts.map +1 -0
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.node.d.ts +4 -0
  26. package/dist/index.node.d.ts.map +1 -0
  27. package/dist/load-from-path-BSrT4DOj.js +39 -0
  28. package/dist/load-from-path-BuN8RpOs.cjs +78 -0
  29. package/dist/loader/index.d.ts +2 -0
  30. package/dist/loader/index.d.ts.map +1 -0
  31. package/dist/loader/index.node.d.ts +3 -0
  32. package/dist/loader/index.node.d.ts.map +1 -0
  33. package/dist/loader/load-from-path.d.ts +5 -0
  34. package/dist/loader/load-from-path.d.ts.map +1 -0
  35. package/dist/loader/loader.d.ts +3 -0
  36. package/dist/loader/loader.d.ts.map +1 -0
  37. package/dist/loader/unplugin.d.ts +16 -0
  38. package/dist/loader/unplugin.d.ts.map +1 -0
  39. package/dist/{index.js → loader-Bc0bstAD.js} +172 -661
  40. package/dist/{index.cjs → loader-YNN5hAF3.cjs} +148 -678
  41. package/dist/material-color-utilities/dynamic_color.d.ts +9 -15
  42. package/dist/material-color-utilities/dynamic_color.d.ts.map +1 -1
  43. package/dist/material-color-utilities/toneDeltaPair.d.ts +9 -2
  44. package/dist/material-color-utilities/toneDeltaPair.d.ts.map +1 -1
  45. package/dist/node.cjs +191 -0
  46. package/dist/node.js +170 -0
  47. package/dist/plugin/plugin.api.d.ts +1 -1
  48. package/dist/plugin/plugin.api.d.ts.map +1 -1
  49. package/dist/theme/scheme.d.ts +1 -1
  50. package/dist/theme/scheme.d.ts.map +1 -1
  51. package/dist/theme/variants/fidelity.variant.d.ts +3 -0
  52. package/dist/theme/variants/fidelity.variant.d.ts.map +1 -0
  53. package/dist/theme/variants/index.d.ts +1 -0
  54. package/dist/theme/variants/index.d.ts.map +1 -1
  55. package/package.json +27 -10
  56. package/src/API.ts +4 -0
  57. package/src/color/color.manager.ts +10 -8
  58. package/src/color/default-color.ts +82 -34
  59. package/src/config/index.node.ts +1 -0
  60. package/src/{adapter → config}/index.ts +0 -1
  61. package/src/config/resolver-config.ts +49 -0
  62. package/src/index.browser.ts +1 -0
  63. package/src/index.node.ts +3 -0
  64. package/src/index.ts +2 -2
  65. package/src/loader/index.node.ts +2 -0
  66. package/src/loader/index.ts +1 -0
  67. package/src/loader/load-from-path.ts +9 -0
  68. package/src/{adapter/adapter.abstract.ts → loader/loader.ts} +23 -28
  69. package/src/loader/unplugin.ts +158 -0
  70. package/src/material-color-utilities/dynamic_color.ts +18 -120
  71. package/src/material-color-utilities/toneDeltaPair.ts +91 -2
  72. package/src/plugin/plugin.api.ts +4 -4
  73. package/src/theme/scheme.ts +7 -1
  74. package/src/theme/variants/fidelity.variant.ts +38 -0
  75. package/src/theme/variants/index.ts +2 -0
  76. package/vite.config.ts +18 -4
  77. package/dist/adapter/adapter.abstract.d.ts +0 -10
  78. package/dist/adapter/adapter.abstract.d.ts.map +0 -1
  79. package/dist/adapter/config.interface.d.ts.map +0 -1
  80. package/dist/adapter/define-config.d.ts.map +0 -1
  81. package/dist/adapter/file-adapter.mixin.d.ts +0 -18
  82. package/dist/adapter/file-adapter.mixin.d.ts.map +0 -1
  83. package/dist/adapter/index.d.ts +0 -4
  84. package/dist/adapter/index.d.ts.map +0 -1
  85. package/dist/adapters/index.d.ts +0 -3
  86. package/dist/adapters/index.d.ts.map +0 -1
  87. package/dist/adapters/node.adapter.d.ts +0 -7
  88. package/dist/adapters/node.adapter.d.ts.map +0 -1
  89. package/dist/adapters/vite.adapter.d.ts +0 -3
  90. package/dist/adapters/vite.adapter.d.ts.map +0 -1
  91. package/src/adapter/file-adapter.mixin.ts +0 -72
  92. package/src/adapters/index.ts +0 -2
  93. package/src/adapters/node.adapter.ts +0 -57
  94. package/src/adapters/vite.adapter.ts +0 -79
  95. /package/dist/{adapter → config}/config.interface.d.ts +0 -0
  96. /package/dist/{adapter → config}/define-config.d.ts +0 -0
  97. /package/src/{adapter → config}/config.interface.ts +0 -0
  98. /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");
@@ -945,34 +899,6 @@ class Hct {
945
899
  * See the License for the specific language governing permissions and
946
900
  * limitations under the License.
947
901
  */
948
- function extendSpecVersion(originlColor, extendedColor) {
949
- return DynamicColor.fromPalette({
950
- name: originlColor.name,
951
- palette: (s) => extendedColor.palette(s),
952
- tone: (s) => extendedColor.tone(s),
953
- isBackground: originlColor.isBackground,
954
- chromaMultiplier: (s) => {
955
- const chromaMultiplier = extendedColor.chromaMultiplier;
956
- return chromaMultiplier !== void 0 ? chromaMultiplier(s) : 1;
957
- },
958
- background: (s) => {
959
- const background = extendedColor.background;
960
- return background !== void 0 ? background(s) : void 0;
961
- },
962
- secondBackground: (s) => {
963
- const secondBackground = extendedColor.secondBackground;
964
- return secondBackground !== void 0 ? secondBackground(s) : void 0;
965
- },
966
- contrastCurve: (s) => {
967
- const contrastCurve = extendedColor.contrastCurve;
968
- return contrastCurve !== void 0 ? contrastCurve(s) : void 0;
969
- },
970
- toneDeltaPair: (s) => {
971
- const toneDeltaPair = extendedColor.toneDeltaPair;
972
- return toneDeltaPair !== void 0 ? toneDeltaPair(s) : void 0;
973
- }
974
- });
975
- }
976
902
  class DynamicColor {
977
903
  /**
978
904
  * The base constructor for DynamicColor.
@@ -1003,11 +929,11 @@ class DynamicColor {
1003
929
  * @param contrastCurve A `ContrastCurve` object specifying how its contrast
1004
930
  * against its background should behave in various contrast levels
1005
931
  * options.
1006
- * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
932
+ * @param adjustTone A `AdjustTone` object specifying a tone delta
1007
933
  * constraint between two colors. One of them must be the color being
1008
934
  * constructed.
1009
935
  */
1010
- constructor(name, palette, tone, isBackground, chromaMultiplier, background, secondBackground, contrastCurve, toneDeltaPair) {
936
+ constructor(name, palette, tone, isBackground, chromaMultiplier, background, secondBackground, contrastCurve, adjustTone) {
1011
937
  __publicField(this, "hctCache", /* @__PURE__ */ new Map());
1012
938
  this.name = name;
1013
939
  this.palette = palette;
@@ -1017,7 +943,7 @@ class DynamicColor {
1017
943
  this.background = background;
1018
944
  this.secondBackground = secondBackground;
1019
945
  this.contrastCurve = contrastCurve;
1020
- this.toneDeltaPair = toneDeltaPair;
946
+ this.adjustTone = adjustTone;
1021
947
  if (!background && secondBackground) {
1022
948
  throw new Error(
1023
949
  `Color ${name} has secondBackgrounddefined, but background is not defined.`
@@ -1050,7 +976,7 @@ class DynamicColor {
1050
976
  args.background,
1051
977
  args.secondBackground,
1052
978
  args.contrastCurve,
1053
- args.toneDeltaPair
979
+ args.adjustTone
1054
980
  );
1055
981
  }
1056
982
  static getInitialToneFromBackground(background) {
@@ -1125,7 +1051,7 @@ class DynamicColor {
1125
1051
  background: this.background,
1126
1052
  secondBackground: this.secondBackground,
1127
1053
  contrastCurve: this.contrastCurve,
1128
- toneDeltaPair: this.toneDeltaPair
1054
+ adjustTone: this.adjustTone
1129
1055
  });
1130
1056
  }
1131
1057
  /**
@@ -1169,59 +1095,9 @@ class DynamicColor {
1169
1095
  * contrast level is.
1170
1096
  */
1171
1097
  getTone(scheme) {
1172
- const toneDeltaPair = this.toneDeltaPair ? this.toneDeltaPair(scheme) : void 0;
1173
- if (toneDeltaPair) {
1174
- const roleA = toneDeltaPair.roleA;
1175
- const roleB = toneDeltaPair.roleB;
1176
- const polarity = toneDeltaPair.polarity;
1177
- const constraint = toneDeltaPair.constraint;
1178
- const absoluteDelta = polarity === "darker" || polarity === "relative_lighter" && scheme.isDark || polarity === "relative_darker" && !scheme.isDark ? -toneDeltaPair.delta : toneDeltaPair.delta;
1179
- const amRoleA = this.name === roleA.name;
1180
- const selfRole = amRoleA ? roleA : roleB;
1181
- const refRole = amRoleA ? roleB : roleA;
1182
- let selfTone = selfRole.tone(scheme);
1183
- const refTone = refRole.getTone(scheme);
1184
- const relativeDelta = absoluteDelta * (amRoleA ? 1 : -1);
1185
- if (constraint === "exact") {
1186
- selfTone = materialColorUtilities.clampDouble(0, 100, refTone + relativeDelta);
1187
- } else if (constraint === "nearer") {
1188
- if (relativeDelta > 0) {
1189
- selfTone = materialColorUtilities.clampDouble(
1190
- 0,
1191
- 100,
1192
- materialColorUtilities.clampDouble(refTone, refTone + relativeDelta, selfTone)
1193
- );
1194
- } else {
1195
- selfTone = materialColorUtilities.clampDouble(
1196
- 0,
1197
- 100,
1198
- materialColorUtilities.clampDouble(refTone + relativeDelta, refTone, selfTone)
1199
- );
1200
- }
1201
- } else if (constraint === "farther") {
1202
- if (relativeDelta > 0) {
1203
- selfTone = materialColorUtilities.clampDouble(refTone + relativeDelta, 100, selfTone);
1204
- } else {
1205
- selfTone = materialColorUtilities.clampDouble(0, refTone + relativeDelta, selfTone);
1206
- }
1207
- }
1208
- if (this.background && this.contrastCurve) {
1209
- const background = this.background(scheme);
1210
- const contrastCurve = this.contrastCurve(scheme);
1211
- if (background && contrastCurve) {
1212
- const bgTone = background.getTone(scheme);
1213
- const selfContrast = contrastCurve.get(scheme.contrastLevel);
1214
- selfTone = materialColorUtilities.Contrast.ratioOfTones(bgTone, selfTone) >= selfContrast && scheme.contrastLevel >= 0 ? selfTone : DynamicColor.foregroundTone(bgTone, selfContrast);
1215
- }
1216
- }
1217
- if (this.isBackground && !this.name.endsWith("_fixed_dim")) {
1218
- if (selfTone >= 57) {
1219
- selfTone = materialColorUtilities.clampDouble(65, 100, selfTone);
1220
- } else {
1221
- selfTone = materialColorUtilities.clampDouble(0, 49, selfTone);
1222
- }
1223
- }
1224
- return selfTone;
1098
+ const adjustTone = this.adjustTone ? this.adjustTone(scheme) : void 0;
1099
+ if (adjustTone) {
1100
+ return adjustTone({ scheme, dynamicColor: this });
1225
1101
  } else {
1226
1102
  let answer = this.tone(scheme);
1227
1103
  if (this.background == void 0 || this.background(scheme) === void 0 || this.contrastCurve == void 0 || this.contrastCurve(scheme) === void 0) {
@@ -1321,7 +1197,66 @@ class ToneDeltaPair {
1321
1197
  this.constraint = constraint;
1322
1198
  this.constraint = constraint ?? "exact";
1323
1199
  }
1200
+ adjustedTone({
1201
+ scheme,
1202
+ dynamicColor
1203
+ }) {
1204
+ const roleA = this.roleA;
1205
+ const roleB = this.roleB;
1206
+ const polarity = this.polarity;
1207
+ const constraint = this.constraint;
1208
+ const absoluteDelta = polarity === "darker" || polarity === "relative_lighter" && scheme.isDark || polarity === "relative_darker" && !scheme.isDark ? -this.delta : this.delta;
1209
+ const amRoleA = dynamicColor.name === roleA.name;
1210
+ const selfRole = amRoleA ? roleA : roleB;
1211
+ const refRole = amRoleA ? roleB : roleA;
1212
+ let selfTone = selfRole.tone(scheme);
1213
+ const refTone = refRole.getTone(scheme);
1214
+ const relativeDelta = absoluteDelta * (amRoleA ? 1 : -1);
1215
+ if (constraint === "exact") {
1216
+ selfTone = materialColorUtilities.clampDouble(0, 100, refTone + relativeDelta);
1217
+ } else if (constraint === "nearer") {
1218
+ if (relativeDelta > 0) {
1219
+ selfTone = materialColorUtilities.clampDouble(
1220
+ 0,
1221
+ 100,
1222
+ materialColorUtilities.clampDouble(refTone, refTone + relativeDelta, selfTone)
1223
+ );
1224
+ } else {
1225
+ selfTone = materialColorUtilities.clampDouble(
1226
+ 0,
1227
+ 100,
1228
+ materialColorUtilities.clampDouble(refTone + relativeDelta, refTone, selfTone)
1229
+ );
1230
+ }
1231
+ } else if (constraint === "farther") {
1232
+ if (relativeDelta > 0) {
1233
+ selfTone = materialColorUtilities.clampDouble(refTone + relativeDelta, 100, selfTone);
1234
+ } else {
1235
+ selfTone = materialColorUtilities.clampDouble(0, refTone + relativeDelta, selfTone);
1236
+ }
1237
+ }
1238
+ if (dynamicColor.background && dynamicColor.contrastCurve) {
1239
+ const background = dynamicColor.background(scheme);
1240
+ const contrastCurve = dynamicColor.contrastCurve(scheme);
1241
+ if (background && contrastCurve) {
1242
+ const bgTone = background.getTone(scheme);
1243
+ const selfContrast = contrastCurve.get(scheme.contrastLevel);
1244
+ selfTone = materialColorUtilities.Contrast.ratioOfTones(bgTone, selfTone) >= selfContrast && scheme.contrastLevel >= 0 ? selfTone : DynamicColor.foregroundTone(bgTone, selfContrast);
1245
+ }
1246
+ }
1247
+ if (dynamicColor.isBackground && !dynamicColor.name.endsWith("_fixed_dim")) {
1248
+ if (selfTone >= 57) {
1249
+ selfTone = materialColorUtilities.clampDouble(65, 100, selfTone);
1250
+ } else {
1251
+ selfTone = materialColorUtilities.clampDouble(0, 49, selfTone);
1252
+ }
1253
+ }
1254
+ return selfTone;
1255
+ }
1324
1256
  }
1257
+ const toneDeltaPair = (...params) => {
1258
+ return (args) => new ToneDeltaPair(...params).adjustedTone(args);
1259
+ };
1325
1260
  function argbToRgb(argb) {
1326
1261
  return {
1327
1262
  r: argb >> 16 & 255,
@@ -1500,7 +1435,7 @@ class ColorManager {
1500
1435
  isBackground: true,
1501
1436
  background: (s) => highestSurface(s, this),
1502
1437
  contrastCurve: (s) => getCurve(4.5),
1503
- toneDeltaPair: (s) => new ToneDeltaPair(
1438
+ adjustTone: (s) => toneDeltaPair(
1504
1439
  this.get(colorContainerKey).getMaterialColor(),
1505
1440
  this.get(colorKey).getMaterialColor(),
1506
1441
  5,
@@ -1521,7 +1456,7 @@ class ColorManager {
1521
1456
  isBackground: true,
1522
1457
  background: (s) => this.get("surfaceContainerHigh").getMaterialColor(),
1523
1458
  contrastCurve: (s) => getCurve(4.5),
1524
- toneDeltaPair: (s) => new ToneDeltaPair(
1459
+ adjustTone: (s) => toneDeltaPair(
1525
1460
  this.get(colorDimKey).getMaterialColor(),
1526
1461
  this.get(colorKey).getMaterialColor(),
1527
1462
  5,
@@ -1548,7 +1483,7 @@ class ColorManager {
1548
1483
  },
1549
1484
  isBackground: true,
1550
1485
  background: (s) => highestSurface(s, this),
1551
- toneDeltaPair: (s) => void 0,
1486
+ adjustTone: (s) => void 0,
1552
1487
  contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
1553
1488
  });
1554
1489
  this.createOrUpdate(onColorContainerKey, {
@@ -1570,7 +1505,7 @@ class ColorManager {
1570
1505
  palette: (s) => s.getPalette(colorKey),
1571
1506
  tone: (s) => this.get(colorFixedKey).getMaterialColor().getTone(s),
1572
1507
  isBackground: true,
1573
- toneDeltaPair: (s) => new ToneDeltaPair(
1508
+ adjustTone: (s) => toneDeltaPair(
1574
1509
  this.get(colorFixedDimKey).getMaterialColor(),
1575
1510
  this.get(colorFixedKey).getMaterialColor(),
1576
1511
  5,
@@ -1811,106 +1746,6 @@ class Variant {
1811
1746
  this.colors = colors;
1812
1747
  }
1813
1748
  }
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
1749
  const tonalSpotVariant = {
1915
1750
  name: "tonalSpot",
1916
1751
  palettes: {
@@ -1937,72 +1772,8 @@ const tonalSpotVariant = {
1937
1772
  },
1938
1773
  customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16)
1939
1774
  };
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
1775
+ const inverseTone = (tone) => {
1776
+ return 100 - tone;
2006
1777
  };
2007
1778
  const defaultColors = (colorService) => {
2008
1779
  const getColor = (key) => {
@@ -2018,6 +1789,9 @@ const defaultColors = (colorService) => {
2018
1789
  if (s.isDark) {
2019
1790
  return 4;
2020
1791
  } else {
1792
+ if (s.variant == "fidelity") {
1793
+ return 100;
1794
+ }
2021
1795
  if (Hct.isYellow(s.getPalette("neutral").hue)) {
2022
1796
  return 99;
2023
1797
  } else if (s.variant === "vibrant") {
@@ -2313,6 +2087,8 @@ const defaultColors = (colorService) => {
2313
2087
  0,
2314
2088
  Hct.isYellow(s.getPalette("primary").hue) ? 25 : Hct.isCyan(s.getPalette("primary").hue) ? 88 : 98
2315
2089
  );
2090
+ } else if (s.variant == "fidelity") {
2091
+ return s.sourceColorHct.tone;
2316
2092
  } else {
2317
2093
  return tMaxC(
2318
2094
  s.getPalette("primary"),
@@ -2324,7 +2100,18 @@ const defaultColors = (colorService) => {
2324
2100
  isBackground: true,
2325
2101
  background: (s) => highestSurface(s, colorService),
2326
2102
  contrastCurve: (s) => getCurve(4.5),
2327
- toneDeltaPair: (s) => new ToneDeltaPair(
2103
+ adjustTone: (s) => s.variant == "fidelity" ? () => {
2104
+ const surfaceTone = colorService.getColor("surface").getMaterialColor().tone(s);
2105
+ const primaryTone = colorService.getColor("primary").getMaterialColor().tone(s);
2106
+ let selfTone = primaryTone;
2107
+ if (materialColorUtilities.Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
2108
+ const result = inverseTone(primaryTone);
2109
+ if (materialColorUtilities.Contrast.ratioOfTones(surfaceTone, result) >= 3) {
2110
+ selfTone = result;
2111
+ }
2112
+ }
2113
+ return selfTone;
2114
+ } : toneDeltaPair(
2328
2115
  colorService.getColor("primaryContainer").getMaterialColor(),
2329
2116
  colorService.getColor("primary").getMaterialColor(),
2330
2117
  5,
@@ -2347,7 +2134,7 @@ const defaultColors = (colorService) => {
2347
2134
  isBackground: true,
2348
2135
  background: (s) => getColor("surfaceContainerHigh"),
2349
2136
  contrastCurve: (s) => getCurve(4.5),
2350
- toneDeltaPair: (s) => new ToneDeltaPair(
2137
+ adjustTone: (s) => toneDeltaPair(
2351
2138
  colorService.getColor("primaryDim").getMaterialColor(),
2352
2139
  colorService.getColor("primary").getMaterialColor(),
2353
2140
  5,
@@ -2374,6 +2161,13 @@ const defaultColors = (colorService) => {
2374
2161
  78,
2375
2162
  Hct.isCyan(s.getPalette("primary").hue) ? 88 : 90
2376
2163
  );
2164
+ }
2165
+ if (s.variant == "fidelity") {
2166
+ return s.isDark ? tMaxC(s.getPalette("primary"), 30, 93) : tMaxC(
2167
+ s.getPalette("primary"),
2168
+ 78,
2169
+ Hct.isCyan(s.getPalette("primary").hue) ? 88 : 90
2170
+ );
2377
2171
  } else {
2378
2172
  return s.isDark ? tMinC(s.getPalette("primary"), 66, 93) : tMaxC(
2379
2173
  s.getPalette("primary"),
@@ -2384,7 +2178,14 @@ const defaultColors = (colorService) => {
2384
2178
  },
2385
2179
  isBackground: true,
2386
2180
  background: (s) => highestSurface(s, colorService),
2387
- toneDeltaPair: (s) => void 0,
2181
+ adjustTone: (s) => s.variant == "fidelity" ? toneDeltaPair(
2182
+ colorService.getColor("primary").getMaterialColor(),
2183
+ colorService.getColor("primaryContainer").getMaterialColor(),
2184
+ 15,
2185
+ "relative_darker",
2186
+ true,
2187
+ "farther"
2188
+ ) : void 0,
2388
2189
  contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2389
2190
  },
2390
2191
  onPrimaryContainer: {
@@ -2410,7 +2211,7 @@ const defaultColors = (colorService) => {
2410
2211
  palette: (s) => s.getPalette("primary"),
2411
2212
  tone: (s) => colorService.getColor("primaryFixed").getMaterialColor().getTone(s),
2412
2213
  isBackground: true,
2413
- toneDeltaPair: (s) => new ToneDeltaPair(
2214
+ adjustTone: (s) => toneDeltaPair(
2414
2215
  getColor("primaryFixedDim"),
2415
2216
  getColor("primaryFixed"),
2416
2217
  5,
@@ -2452,7 +2253,7 @@ const defaultColors = (colorService) => {
2452
2253
  isBackground: true,
2453
2254
  background: (s) => highestSurface(s, colorService),
2454
2255
  contrastCurve: (s) => getCurve(4.5),
2455
- toneDeltaPair: (s) => new ToneDeltaPair(
2256
+ adjustTone: (s) => toneDeltaPair(
2456
2257
  getColor("secondaryContainer"),
2457
2258
  getColor("secondary"),
2458
2259
  5,
@@ -2473,7 +2274,7 @@ const defaultColors = (colorService) => {
2473
2274
  isBackground: true,
2474
2275
  background: (s) => getColor("surfaceContainerHigh"),
2475
2276
  contrastCurve: (s) => getCurve(4.5),
2476
- toneDeltaPair: (s) => new ToneDeltaPair(
2277
+ adjustTone: (s) => toneDeltaPair(
2477
2278
  getColor("secondaryDim"),
2478
2279
  getColor("secondary"),
2479
2280
  5,
@@ -2500,7 +2301,7 @@ const defaultColors = (colorService) => {
2500
2301
  },
2501
2302
  isBackground: true,
2502
2303
  background: (s) => highestSurface(s, colorService),
2503
- toneDeltaPair: (s) => void 0,
2304
+ adjustTone: (s) => void 0,
2504
2305
  contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2505
2306
  },
2506
2307
  onSecondaryContainer: {
@@ -2526,7 +2327,7 @@ const defaultColors = (colorService) => {
2526
2327
  palette: (s) => s.getPalette("secondary"),
2527
2328
  tone: (s) => getColor("secondaryFixed").getTone(s),
2528
2329
  isBackground: true,
2529
- toneDeltaPair: (s) => new ToneDeltaPair(
2330
+ adjustTone: (s) => toneDeltaPair(
2530
2331
  getColor("secondaryFixedDim"),
2531
2332
  getColor("secondaryFixed"),
2532
2333
  5,
@@ -2564,7 +2365,7 @@ const defaultColors = (colorService) => {
2564
2365
  isBackground: true,
2565
2366
  background: (s) => highestSurface(s, colorService),
2566
2367
  contrastCurve: (s) => getCurve(4.5),
2567
- toneDeltaPair: (s) => new ToneDeltaPair(
2368
+ adjustTone: (s) => toneDeltaPair(
2568
2369
  getColor("tertiaryContainer"),
2569
2370
  getColor("tertiary"),
2570
2371
  5,
@@ -2585,7 +2386,7 @@ const defaultColors = (colorService) => {
2585
2386
  isBackground: true,
2586
2387
  background: (s) => getColor("surfaceContainerHigh"),
2587
2388
  contrastCurve: (s) => getCurve(4.5),
2588
- toneDeltaPair: (s) => new ToneDeltaPair(
2389
+ adjustTone: (s) => toneDeltaPair(
2589
2390
  getColor("tertiaryDim"),
2590
2391
  getColor("tertiary"),
2591
2392
  5,
@@ -2618,7 +2419,7 @@ const defaultColors = (colorService) => {
2618
2419
  },
2619
2420
  isBackground: true,
2620
2421
  background: (s) => highestSurface(s, colorService),
2621
- toneDeltaPair: (s) => void 0,
2422
+ adjustTone: (s) => void 0,
2622
2423
  contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2623
2424
  },
2624
2425
  onTertiaryContainer: {
@@ -2644,7 +2445,7 @@ const defaultColors = (colorService) => {
2644
2445
  palette: (s) => s.getPalette("tertiary"),
2645
2446
  tone: (s) => getColor("tertiaryFixed").getTone(s),
2646
2447
  isBackground: true,
2647
- toneDeltaPair: (s) => new ToneDeltaPair(
2448
+ adjustTone: (s) => toneDeltaPair(
2648
2449
  getColor("tertiaryFixedDim"),
2649
2450
  getColor("tertiaryFixed"),
2650
2451
  5,
@@ -2674,7 +2475,7 @@ const defaultColors = (colorService) => {
2674
2475
  isBackground: true,
2675
2476
  background: (s) => highestSurface(s, colorService),
2676
2477
  contrastCurve: (s) => getCurve(4.5),
2677
- toneDeltaPair: (s) => new ToneDeltaPair(
2478
+ adjustTone: (s) => toneDeltaPair(
2678
2479
  colorService.getColor("errorContainer").getMaterialColor(),
2679
2480
  colorService.getColor("error").getMaterialColor(),
2680
2481
  5,
@@ -2689,7 +2490,7 @@ const defaultColors = (colorService) => {
2689
2490
  isBackground: true,
2690
2491
  background: (s) => getColor("surfaceContainerHigh"),
2691
2492
  contrastCurve: (s) => getCurve(4.5),
2692
- toneDeltaPair: (s) => new ToneDeltaPair(
2493
+ adjustTone: (s) => toneDeltaPair(
2693
2494
  getColor("errorDim"),
2694
2495
  getColor("error"),
2695
2496
  5,
@@ -2710,7 +2511,7 @@ const defaultColors = (colorService) => {
2710
2511
  },
2711
2512
  isBackground: true,
2712
2513
  background: (s) => highestSurface(s, colorService),
2713
- toneDeltaPair: (s) => void 0,
2514
+ adjustTone: (s) => void 0,
2714
2515
  contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
2715
2516
  },
2716
2517
  onErrorContainer: {
@@ -2751,37 +2552,13 @@ class API {
2751
2552
  this.colors = colorApi;
2752
2553
  this.themes = themeApi;
2753
2554
  }
2555
+ async load() {
2556
+ return this.plugins.loadPlugins();
2557
+ }
2754
2558
  }
2755
2559
  const AppModule = {
2756
2560
  api: awilix.asClass(API).singleton()
2757
2561
  };
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
2562
  class PluginApi {
2786
2563
  constructor() {
2787
2564
  __publicField(this, "plugins", /* @__PURE__ */ new Map());
@@ -2810,11 +2587,11 @@ class PluginApi {
2810
2587
  "Some plugins couldn't be loaded due to missing dependencies: " + Array.from(plugins.keys())
2811
2588
  );
2812
2589
  }
2813
- loadPlugins() {
2814
- this.plugins.forEach((plugin) => {
2815
- var _a, _b;
2816
- (_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a);
2817
- });
2590
+ async loadPlugins() {
2591
+ var _a, _b;
2592
+ for (const plugin of this.plugins.values()) {
2593
+ await ((_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a));
2594
+ }
2818
2595
  }
2819
2596
  getPlugin(plugin) {
2820
2597
  const pluginInstance = this.plugins.get(new plugin().name);
@@ -2840,19 +2617,16 @@ registerModule(AppModule, PluginModule, ColorModule, ThemeModule);
2840
2617
  function bootstrap() {
2841
2618
  return AppContainer.resolve("api");
2842
2619
  }
2843
- class AdapterAbstract {
2844
- constructor() {
2845
- __publicField(this, "api");
2846
- this.api = bootstrap();
2847
- registerModule({
2848
- adapter: awilix.asValue(this)
2849
- });
2850
- }
2851
- async init() {
2852
- const config = await this.getConfig();
2853
- if (config == null) {
2854
- return;
2855
- }
2620
+ const initializeApi = () => {
2621
+ const api = bootstrap();
2622
+ registerModule({
2623
+ adapter: awilix.asValue(void 0)
2624
+ });
2625
+ return api;
2626
+ };
2627
+ const loader = async (config) => {
2628
+ const api = initializeApi();
2629
+ const init = () => {
2856
2630
  const {
2857
2631
  sourceColor,
2858
2632
  contrastLevel = 0,
@@ -2863,7 +2637,7 @@ class AdapterAbstract {
2863
2637
  useDefaultColors = true,
2864
2638
  plugins
2865
2639
  } = config;
2866
- this.api.themes.create({
2640
+ api.themes.create({
2867
2641
  contrastLevel,
2868
2642
  isDark,
2869
2643
  sourceColorHex: sourceColor,
@@ -2871,321 +2645,27 @@ class AdapterAbstract {
2871
2645
  });
2872
2646
  if (palettes) {
2873
2647
  Object.entries(palettes).forEach(
2874
- ([key, value]) => this.api.themes.addCustomPalette(key, value)
2648
+ ([key, value]) => api.themes.addCustomPalette(key, value)
2875
2649
  );
2876
2650
  }
2877
2651
  if (useDefaultColors) {
2878
- this.api.colors.addColors(defaultColors);
2652
+ api.colors.addColors(defaultColors);
2879
2653
  }
2880
2654
  if (colors) {
2881
- this.api.colors.addColors(colors);
2655
+ api.colors.addColors(colors);
2882
2656
  }
2883
2657
  if (plugins) {
2884
2658
  plugins.forEach((plugin) => {
2885
- this.api.plugins.addPlugin(plugin);
2659
+ api.plugins.addPlugin(plugin);
2886
2660
  });
2887
- this.api.plugins.initPlugins(this.api);
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;
2661
+ api.plugins.initPlugins(api);
3003
2662
  }
3004
2663
  };
2664
+ init();
2665
+ await api.load();
2666
+ return api;
3005
2667
  };
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
2668
  exports.API = API;
3188
- exports.AdapterAbstract = AdapterAbstract;
3189
2669
  exports.AppContainer = AppContainer;
3190
2670
  exports.AppModule = AppModule;
3191
2671
  exports.ColorApi = ColorApi;
@@ -3194,31 +2674,21 @@ exports.ColorModule = ColorModule;
3194
2674
  exports.ConfigurableColor = ConfigurableColor;
3195
2675
  exports.ContrastCurve = ContrastCurve;
3196
2676
  exports.DynamicColor = DynamicColor;
3197
- exports.FontFamily = FontFamily;
3198
- exports.FontPlugin = FontPlugin;
3199
- exports.NodeAdapter = NodeAdapter;
3200
- exports.PluginAbstract = PluginAbstract;
2677
+ exports.Hct = Hct;
3201
2678
  exports.PluginApi = PluginApi;
3202
- exports.PluginImplAbstract = PluginImplAbstract;
3203
2679
  exports.PluginModule = PluginModule;
3204
2680
  exports.Scheme = Scheme;
3205
2681
  exports.SchemeManager = SchemeManager;
3206
2682
  exports.ThemeApi = ThemeApi;
3207
2683
  exports.ThemeModule = ThemeModule;
3208
- exports.ToneDeltaPair = ToneDeltaPair;
3209
2684
  exports.Variant = Variant;
3210
2685
  exports.VariantManager = VariantManager;
3211
- exports.Variants = Variants;
3212
2686
  exports.bootstrap = bootstrap;
3213
2687
  exports.defaultColors = defaultColors;
3214
- exports.defineConfig = defineConfig;
3215
- exports.expressiveVariant = expressiveVariant;
3216
- exports.extendSpecVersion = extendSpecVersion;
3217
2688
  exports.getPiecewiseHue = getPiecewiseHue;
3218
2689
  exports.getRotatedHue = getRotatedHue;
3219
2690
  exports.highestSurface = highestSurface;
3220
- exports.neutralVariant = neutralVariant;
2691
+ exports.loader = loader;
3221
2692
  exports.registerModule = registerModule;
3222
2693
  exports.tonalSpotVariant = tonalSpotVariant;
3223
- exports.udixioVite = udixioVite;
3224
- exports.vibrantVariant = vibrantVariant;
2694
+ exports.toneDeltaPair = toneDeltaPair;