@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.
- package/CHANGELOG.md +35 -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 +39 -0
- package/dist/browser.js +39 -0
- package/dist/color/color.manager.d.ts.map +1 -1
- package/dist/color/default-color.d.ts.map +1 -1
- 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-B1QPKKY_.js +430 -0
- package/dist/define-config-BGgVazsr.cjs +429 -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-BSrT4DOj.js +39 -0
- package/dist/load-from-path-BuN8RpOs.cjs +78 -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-Bc0bstAD.js} +172 -661
- package/dist/{index.cjs → loader-YNN5hAF3.cjs} +148 -678
- package/dist/material-color-utilities/dynamic_color.d.ts +9 -15
- package/dist/material-color-utilities/dynamic_color.d.ts.map +1 -1
- package/dist/material-color-utilities/toneDeltaPair.d.ts +9 -2
- package/dist/material-color-utilities/toneDeltaPair.d.ts.map +1 -1
- package/dist/node.cjs +191 -0
- package/dist/node.js +170 -0
- package/dist/plugin/plugin.api.d.ts +1 -1
- package/dist/plugin/plugin.api.d.ts.map +1 -1
- package/dist/theme/scheme.d.ts +1 -1
- package/dist/theme/scheme.d.ts.map +1 -1
- package/dist/theme/variants/fidelity.variant.d.ts +3 -0
- package/dist/theme/variants/fidelity.variant.d.ts.map +1 -0
- package/dist/theme/variants/index.d.ts +1 -0
- package/dist/theme/variants/index.d.ts.map +1 -1
- package/package.json +27 -10
- package/src/API.ts +4 -0
- package/src/color/color.manager.ts +10 -8
- package/src/color/default-color.ts +82 -34
- 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} +23 -28
- package/src/loader/unplugin.ts +158 -0
- package/src/material-color-utilities/dynamic_color.ts +18 -120
- package/src/material-color-utilities/toneDeltaPair.ts +91 -2
- package/src/plugin/plugin.api.ts +4 -4
- package/src/theme/scheme.ts +7 -1
- package/src/theme/variants/fidelity.variant.ts +38 -0
- package/src/theme/variants/index.ts +2 -0
- package/vite.config.ts +18 -4
- package/dist/adapter/adapter.abstract.d.ts +0 -10
- package/dist/adapter/adapter.abstract.d.ts.map +0 -1
- package/dist/adapter/config.interface.d.ts.map +0 -1
- package/dist/adapter/define-config.d.ts.map +0 -1
- package/dist/adapter/file-adapter.mixin.d.ts +0 -18
- package/dist/adapter/file-adapter.mixin.d.ts.map +0 -1
- package/dist/adapter/index.d.ts +0 -4
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/adapters/index.d.ts +0 -3
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/node.adapter.d.ts +0 -7
- package/dist/adapters/node.adapter.d.ts.map +0 -1
- package/dist/adapters/vite.adapter.d.ts +0 -3
- package/dist/adapters/vite.adapter.d.ts.map +0 -1
- package/src/adapter/file-adapter.mixin.ts +0 -72
- package/src/adapters/index.ts +0 -2
- package/src/adapters/node.adapter.ts +0 -57
- package/src/adapters/vite.adapter.ts +0 -79
- /package/dist/{adapter → config}/config.interface.d.ts +0 -0
- /package/dist/{adapter → config}/define-config.d.ts +0 -0
- /package/src/{adapter → config}/config.interface.ts +0 -0
- /package/src/{adapter → config}/define-config.ts +0 -0
|
@@ -3,11 +3,6 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { asClass, createContainer, InjectionMode, asValue } from "awilix";
|
|
5
5
|
import { lerp, argbFromLstar, sanitizeDegreesDouble, yFromLstar, argbFromLinrgb, Cam16, signum, matrixMultiply, ViewingConditions, lstarFromArgb, lstarFromY, Contrast, clampDouble, hexFromArgb, argbFromHex, DynamicColor as DynamicColor$1, TonalPalette } from "@material/material-color-utilities";
|
|
6
|
-
import { resolve } from "pathe";
|
|
7
|
-
import { createJiti } from "jiti";
|
|
8
|
-
import { loadConfigFromFile } from "vite";
|
|
9
|
-
import * as path from "node:path";
|
|
10
|
-
import * as fs from "node:fs";
|
|
11
6
|
class ColorApi {
|
|
12
7
|
constructor({ colorManager }) {
|
|
13
8
|
__publicField(this, "colorManager");
|
|
@@ -903,34 +898,6 @@ class Hct {
|
|
|
903
898
|
* See the License for the specific language governing permissions and
|
|
904
899
|
* limitations under the License.
|
|
905
900
|
*/
|
|
906
|
-
function extendSpecVersion(originlColor, extendedColor) {
|
|
907
|
-
return DynamicColor.fromPalette({
|
|
908
|
-
name: originlColor.name,
|
|
909
|
-
palette: (s) => extendedColor.palette(s),
|
|
910
|
-
tone: (s) => extendedColor.tone(s),
|
|
911
|
-
isBackground: originlColor.isBackground,
|
|
912
|
-
chromaMultiplier: (s) => {
|
|
913
|
-
const chromaMultiplier = extendedColor.chromaMultiplier;
|
|
914
|
-
return chromaMultiplier !== void 0 ? chromaMultiplier(s) : 1;
|
|
915
|
-
},
|
|
916
|
-
background: (s) => {
|
|
917
|
-
const background = extendedColor.background;
|
|
918
|
-
return background !== void 0 ? background(s) : void 0;
|
|
919
|
-
},
|
|
920
|
-
secondBackground: (s) => {
|
|
921
|
-
const secondBackground = extendedColor.secondBackground;
|
|
922
|
-
return secondBackground !== void 0 ? secondBackground(s) : void 0;
|
|
923
|
-
},
|
|
924
|
-
contrastCurve: (s) => {
|
|
925
|
-
const contrastCurve = extendedColor.contrastCurve;
|
|
926
|
-
return contrastCurve !== void 0 ? contrastCurve(s) : void 0;
|
|
927
|
-
},
|
|
928
|
-
toneDeltaPair: (s) => {
|
|
929
|
-
const toneDeltaPair = extendedColor.toneDeltaPair;
|
|
930
|
-
return toneDeltaPair !== void 0 ? toneDeltaPair(s) : void 0;
|
|
931
|
-
}
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
901
|
class DynamicColor {
|
|
935
902
|
/**
|
|
936
903
|
* The base constructor for DynamicColor.
|
|
@@ -961,11 +928,11 @@ class DynamicColor {
|
|
|
961
928
|
* @param contrastCurve A `ContrastCurve` object specifying how its contrast
|
|
962
929
|
* against its background should behave in various contrast levels
|
|
963
930
|
* options.
|
|
964
|
-
* @param
|
|
931
|
+
* @param adjustTone A `AdjustTone` object specifying a tone delta
|
|
965
932
|
* constraint between two colors. One of them must be the color being
|
|
966
933
|
* constructed.
|
|
967
934
|
*/
|
|
968
|
-
constructor(name, palette, tone, isBackground, chromaMultiplier, background, secondBackground, contrastCurve,
|
|
935
|
+
constructor(name, palette, tone, isBackground, chromaMultiplier, background, secondBackground, contrastCurve, adjustTone) {
|
|
969
936
|
__publicField(this, "hctCache", /* @__PURE__ */ new Map());
|
|
970
937
|
this.name = name;
|
|
971
938
|
this.palette = palette;
|
|
@@ -975,7 +942,7 @@ class DynamicColor {
|
|
|
975
942
|
this.background = background;
|
|
976
943
|
this.secondBackground = secondBackground;
|
|
977
944
|
this.contrastCurve = contrastCurve;
|
|
978
|
-
this.
|
|
945
|
+
this.adjustTone = adjustTone;
|
|
979
946
|
if (!background && secondBackground) {
|
|
980
947
|
throw new Error(
|
|
981
948
|
`Color ${name} has secondBackgrounddefined, but background is not defined.`
|
|
@@ -1008,7 +975,7 @@ class DynamicColor {
|
|
|
1008
975
|
args.background,
|
|
1009
976
|
args.secondBackground,
|
|
1010
977
|
args.contrastCurve,
|
|
1011
|
-
args.
|
|
978
|
+
args.adjustTone
|
|
1012
979
|
);
|
|
1013
980
|
}
|
|
1014
981
|
static getInitialToneFromBackground(background) {
|
|
@@ -1083,7 +1050,7 @@ class DynamicColor {
|
|
|
1083
1050
|
background: this.background,
|
|
1084
1051
|
secondBackground: this.secondBackground,
|
|
1085
1052
|
contrastCurve: this.contrastCurve,
|
|
1086
|
-
|
|
1053
|
+
adjustTone: this.adjustTone
|
|
1087
1054
|
});
|
|
1088
1055
|
}
|
|
1089
1056
|
/**
|
|
@@ -1127,59 +1094,9 @@ class DynamicColor {
|
|
|
1127
1094
|
* contrast level is.
|
|
1128
1095
|
*/
|
|
1129
1096
|
getTone(scheme) {
|
|
1130
|
-
const
|
|
1131
|
-
if (
|
|
1132
|
-
|
|
1133
|
-
const roleB = toneDeltaPair.roleB;
|
|
1134
|
-
const polarity = toneDeltaPair.polarity;
|
|
1135
|
-
const constraint = toneDeltaPair.constraint;
|
|
1136
|
-
const absoluteDelta = polarity === "darker" || polarity === "relative_lighter" && scheme.isDark || polarity === "relative_darker" && !scheme.isDark ? -toneDeltaPair.delta : toneDeltaPair.delta;
|
|
1137
|
-
const amRoleA = this.name === roleA.name;
|
|
1138
|
-
const selfRole = amRoleA ? roleA : roleB;
|
|
1139
|
-
const refRole = amRoleA ? roleB : roleA;
|
|
1140
|
-
let selfTone = selfRole.tone(scheme);
|
|
1141
|
-
const refTone = refRole.getTone(scheme);
|
|
1142
|
-
const relativeDelta = absoluteDelta * (amRoleA ? 1 : -1);
|
|
1143
|
-
if (constraint === "exact") {
|
|
1144
|
-
selfTone = clampDouble(0, 100, refTone + relativeDelta);
|
|
1145
|
-
} else if (constraint === "nearer") {
|
|
1146
|
-
if (relativeDelta > 0) {
|
|
1147
|
-
selfTone = clampDouble(
|
|
1148
|
-
0,
|
|
1149
|
-
100,
|
|
1150
|
-
clampDouble(refTone, refTone + relativeDelta, selfTone)
|
|
1151
|
-
);
|
|
1152
|
-
} else {
|
|
1153
|
-
selfTone = clampDouble(
|
|
1154
|
-
0,
|
|
1155
|
-
100,
|
|
1156
|
-
clampDouble(refTone + relativeDelta, refTone, selfTone)
|
|
1157
|
-
);
|
|
1158
|
-
}
|
|
1159
|
-
} else if (constraint === "farther") {
|
|
1160
|
-
if (relativeDelta > 0) {
|
|
1161
|
-
selfTone = clampDouble(refTone + relativeDelta, 100, selfTone);
|
|
1162
|
-
} else {
|
|
1163
|
-
selfTone = clampDouble(0, refTone + relativeDelta, selfTone);
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
if (this.background && this.contrastCurve) {
|
|
1167
|
-
const background = this.background(scheme);
|
|
1168
|
-
const contrastCurve = this.contrastCurve(scheme);
|
|
1169
|
-
if (background && contrastCurve) {
|
|
1170
|
-
const bgTone = background.getTone(scheme);
|
|
1171
|
-
const selfContrast = contrastCurve.get(scheme.contrastLevel);
|
|
1172
|
-
selfTone = Contrast.ratioOfTones(bgTone, selfTone) >= selfContrast && scheme.contrastLevel >= 0 ? selfTone : DynamicColor.foregroundTone(bgTone, selfContrast);
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
if (this.isBackground && !this.name.endsWith("_fixed_dim")) {
|
|
1176
|
-
if (selfTone >= 57) {
|
|
1177
|
-
selfTone = clampDouble(65, 100, selfTone);
|
|
1178
|
-
} else {
|
|
1179
|
-
selfTone = clampDouble(0, 49, selfTone);
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
return selfTone;
|
|
1097
|
+
const adjustTone = this.adjustTone ? this.adjustTone(scheme) : void 0;
|
|
1098
|
+
if (adjustTone) {
|
|
1099
|
+
return adjustTone({ scheme, dynamicColor: this });
|
|
1183
1100
|
} else {
|
|
1184
1101
|
let answer = this.tone(scheme);
|
|
1185
1102
|
if (this.background == void 0 || this.background(scheme) === void 0 || this.contrastCurve == void 0 || this.contrastCurve(scheme) === void 0) {
|
|
@@ -1279,7 +1196,66 @@ class ToneDeltaPair {
|
|
|
1279
1196
|
this.constraint = constraint;
|
|
1280
1197
|
this.constraint = constraint ?? "exact";
|
|
1281
1198
|
}
|
|
1199
|
+
adjustedTone({
|
|
1200
|
+
scheme,
|
|
1201
|
+
dynamicColor
|
|
1202
|
+
}) {
|
|
1203
|
+
const roleA = this.roleA;
|
|
1204
|
+
const roleB = this.roleB;
|
|
1205
|
+
const polarity = this.polarity;
|
|
1206
|
+
const constraint = this.constraint;
|
|
1207
|
+
const absoluteDelta = polarity === "darker" || polarity === "relative_lighter" && scheme.isDark || polarity === "relative_darker" && !scheme.isDark ? -this.delta : this.delta;
|
|
1208
|
+
const amRoleA = dynamicColor.name === roleA.name;
|
|
1209
|
+
const selfRole = amRoleA ? roleA : roleB;
|
|
1210
|
+
const refRole = amRoleA ? roleB : roleA;
|
|
1211
|
+
let selfTone = selfRole.tone(scheme);
|
|
1212
|
+
const refTone = refRole.getTone(scheme);
|
|
1213
|
+
const relativeDelta = absoluteDelta * (amRoleA ? 1 : -1);
|
|
1214
|
+
if (constraint === "exact") {
|
|
1215
|
+
selfTone = clampDouble(0, 100, refTone + relativeDelta);
|
|
1216
|
+
} else if (constraint === "nearer") {
|
|
1217
|
+
if (relativeDelta > 0) {
|
|
1218
|
+
selfTone = clampDouble(
|
|
1219
|
+
0,
|
|
1220
|
+
100,
|
|
1221
|
+
clampDouble(refTone, refTone + relativeDelta, selfTone)
|
|
1222
|
+
);
|
|
1223
|
+
} else {
|
|
1224
|
+
selfTone = clampDouble(
|
|
1225
|
+
0,
|
|
1226
|
+
100,
|
|
1227
|
+
clampDouble(refTone + relativeDelta, refTone, selfTone)
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
} else if (constraint === "farther") {
|
|
1231
|
+
if (relativeDelta > 0) {
|
|
1232
|
+
selfTone = clampDouble(refTone + relativeDelta, 100, selfTone);
|
|
1233
|
+
} else {
|
|
1234
|
+
selfTone = clampDouble(0, refTone + relativeDelta, selfTone);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
if (dynamicColor.background && dynamicColor.contrastCurve) {
|
|
1238
|
+
const background = dynamicColor.background(scheme);
|
|
1239
|
+
const contrastCurve = dynamicColor.contrastCurve(scheme);
|
|
1240
|
+
if (background && contrastCurve) {
|
|
1241
|
+
const bgTone = background.getTone(scheme);
|
|
1242
|
+
const selfContrast = contrastCurve.get(scheme.contrastLevel);
|
|
1243
|
+
selfTone = Contrast.ratioOfTones(bgTone, selfTone) >= selfContrast && scheme.contrastLevel >= 0 ? selfTone : DynamicColor.foregroundTone(bgTone, selfContrast);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
if (dynamicColor.isBackground && !dynamicColor.name.endsWith("_fixed_dim")) {
|
|
1247
|
+
if (selfTone >= 57) {
|
|
1248
|
+
selfTone = clampDouble(65, 100, selfTone);
|
|
1249
|
+
} else {
|
|
1250
|
+
selfTone = clampDouble(0, 49, selfTone);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
return selfTone;
|
|
1254
|
+
}
|
|
1282
1255
|
}
|
|
1256
|
+
const toneDeltaPair = (...params) => {
|
|
1257
|
+
return (args) => new ToneDeltaPair(...params).adjustedTone(args);
|
|
1258
|
+
};
|
|
1283
1259
|
function argbToRgb(argb) {
|
|
1284
1260
|
return {
|
|
1285
1261
|
r: argb >> 16 & 255,
|
|
@@ -1458,7 +1434,7 @@ class ColorManager {
|
|
|
1458
1434
|
isBackground: true,
|
|
1459
1435
|
background: (s) => highestSurface(s, this),
|
|
1460
1436
|
contrastCurve: (s) => getCurve(4.5),
|
|
1461
|
-
|
|
1437
|
+
adjustTone: (s) => toneDeltaPair(
|
|
1462
1438
|
this.get(colorContainerKey).getMaterialColor(),
|
|
1463
1439
|
this.get(colorKey).getMaterialColor(),
|
|
1464
1440
|
5,
|
|
@@ -1479,7 +1455,7 @@ class ColorManager {
|
|
|
1479
1455
|
isBackground: true,
|
|
1480
1456
|
background: (s) => this.get("surfaceContainerHigh").getMaterialColor(),
|
|
1481
1457
|
contrastCurve: (s) => getCurve(4.5),
|
|
1482
|
-
|
|
1458
|
+
adjustTone: (s) => toneDeltaPair(
|
|
1483
1459
|
this.get(colorDimKey).getMaterialColor(),
|
|
1484
1460
|
this.get(colorKey).getMaterialColor(),
|
|
1485
1461
|
5,
|
|
@@ -1506,7 +1482,7 @@ class ColorManager {
|
|
|
1506
1482
|
},
|
|
1507
1483
|
isBackground: true,
|
|
1508
1484
|
background: (s) => highestSurface(s, this),
|
|
1509
|
-
|
|
1485
|
+
adjustTone: (s) => void 0,
|
|
1510
1486
|
contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
1511
1487
|
});
|
|
1512
1488
|
this.createOrUpdate(onColorContainerKey, {
|
|
@@ -1528,7 +1504,7 @@ class ColorManager {
|
|
|
1528
1504
|
palette: (s) => s.getPalette(colorKey),
|
|
1529
1505
|
tone: (s) => this.get(colorFixedKey).getMaterialColor().getTone(s),
|
|
1530
1506
|
isBackground: true,
|
|
1531
|
-
|
|
1507
|
+
adjustTone: (s) => toneDeltaPair(
|
|
1532
1508
|
this.get(colorFixedDimKey).getMaterialColor(),
|
|
1533
1509
|
this.get(colorFixedKey).getMaterialColor(),
|
|
1534
1510
|
5,
|
|
@@ -1769,106 +1745,6 @@ class Variant {
|
|
|
1769
1745
|
this.colors = colors;
|
|
1770
1746
|
}
|
|
1771
1747
|
}
|
|
1772
|
-
const getExpressiveNeutralHue = (sourceColorHct) => {
|
|
1773
|
-
const hue = getRotatedHue(
|
|
1774
|
-
sourceColorHct,
|
|
1775
|
-
[0, 71, 124, 253, 278, 300, 360],
|
|
1776
|
-
[10, 0, 10, 0, 10, 0]
|
|
1777
|
-
);
|
|
1778
|
-
return hue;
|
|
1779
|
-
};
|
|
1780
|
-
const getExpressiveNeutralChroma = (sourceColorHct, isDark) => {
|
|
1781
|
-
const neutralHue = getExpressiveNeutralHue(sourceColorHct);
|
|
1782
|
-
return isDark ? Hct.isYellow(neutralHue) ? 6 : 14 : 18;
|
|
1783
|
-
};
|
|
1784
|
-
const expressiveVariant = {
|
|
1785
|
-
name: "expressive",
|
|
1786
|
-
palettes: {
|
|
1787
|
-
primary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 36 : 48),
|
|
1788
|
-
secondary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(
|
|
1789
|
-
getRotatedHue(
|
|
1790
|
-
sourceColorHct,
|
|
1791
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1792
|
-
[-160, 155, -100, 96, -96, -156, -165, -160]
|
|
1793
|
-
),
|
|
1794
|
-
isDark ? 16 : 24
|
|
1795
|
-
),
|
|
1796
|
-
tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1797
|
-
getRotatedHue(
|
|
1798
|
-
sourceColorHct,
|
|
1799
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1800
|
-
[-165, 160, -105, 101, -101, -160, -170, -165]
|
|
1801
|
-
),
|
|
1802
|
-
48
|
|
1803
|
-
),
|
|
1804
|
-
neutral: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(
|
|
1805
|
-
getExpressiveNeutralHue(sourceColorHct),
|
|
1806
|
-
getExpressiveNeutralChroma(sourceColorHct, isDark)
|
|
1807
|
-
),
|
|
1808
|
-
neutralVariant: ({ sourceColorHct, isDark }) => {
|
|
1809
|
-
const expressiveNeutralHue = getExpressiveNeutralHue(sourceColorHct);
|
|
1810
|
-
const expressiveNeutralChroma = getExpressiveNeutralChroma(
|
|
1811
|
-
sourceColorHct,
|
|
1812
|
-
isDark
|
|
1813
|
-
);
|
|
1814
|
-
return TonalPalette.fromHueAndChroma(
|
|
1815
|
-
expressiveNeutralHue,
|
|
1816
|
-
expressiveNeutralChroma * (expressiveNeutralHue >= 105 && expressiveNeutralHue < 125 ? 1.6 : 2.3)
|
|
1817
|
-
);
|
|
1818
|
-
},
|
|
1819
|
-
error: ({ sourceColorHct }) => {
|
|
1820
|
-
const errorHue = getPiecewiseHue(
|
|
1821
|
-
sourceColorHct,
|
|
1822
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1823
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1824
|
-
);
|
|
1825
|
-
return TonalPalette.fromHueAndChroma(errorHue, 64);
|
|
1826
|
-
}
|
|
1827
|
-
},
|
|
1828
|
-
customPalettes: ({ colorHct, isDark }) => TonalPalette.fromHueAndChroma(
|
|
1829
|
-
getRotatedHue(
|
|
1830
|
-
colorHct,
|
|
1831
|
-
[0, 105, 140, 204, 253, 278, 300, 333, 360],
|
|
1832
|
-
[-160, 155, -100, 96, -96, -156, -165, -160]
|
|
1833
|
-
),
|
|
1834
|
-
isDark ? 16 : 24
|
|
1835
|
-
)
|
|
1836
|
-
};
|
|
1837
|
-
const neutralVariant = {
|
|
1838
|
-
name: "neutral",
|
|
1839
|
-
palettes: {
|
|
1840
|
-
primary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1841
|
-
sourceColorHct.hue,
|
|
1842
|
-
Hct.isBlue(sourceColorHct.hue) ? 12 : 8
|
|
1843
|
-
),
|
|
1844
|
-
secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1845
|
-
sourceColorHct.hue,
|
|
1846
|
-
Hct.isBlue(sourceColorHct.hue) ? 6 : 4
|
|
1847
|
-
),
|
|
1848
|
-
tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1849
|
-
getRotatedHue(
|
|
1850
|
-
sourceColorHct,
|
|
1851
|
-
[0, 38, 105, 161, 204, 278, 333, 360],
|
|
1852
|
-
[-32, 26, 10, -39, 24, -15, -32]
|
|
1853
|
-
),
|
|
1854
|
-
20
|
|
1855
|
-
),
|
|
1856
|
-
neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4),
|
|
1857
|
-
neutralVariant: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4 * 2.2),
|
|
1858
|
-
error: ({ sourceColorHct }) => {
|
|
1859
|
-
const errorHue = getPiecewiseHue(
|
|
1860
|
-
sourceColorHct,
|
|
1861
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1862
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1863
|
-
);
|
|
1864
|
-
return TonalPalette.fromHueAndChroma(errorHue, 50);
|
|
1865
|
-
}
|
|
1866
|
-
},
|
|
1867
|
-
customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(
|
|
1868
|
-
colorHct.hue,
|
|
1869
|
-
Hct.isBlue(colorHct.hue) ? 6 : 4
|
|
1870
|
-
)
|
|
1871
|
-
};
|
|
1872
1748
|
const tonalSpotVariant = {
|
|
1873
1749
|
name: "tonalSpot",
|
|
1874
1750
|
palettes: {
|
|
@@ -1895,72 +1771,8 @@ const tonalSpotVariant = {
|
|
|
1895
1771
|
},
|
|
1896
1772
|
customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(colorHct.hue, 16)
|
|
1897
1773
|
};
|
|
1898
|
-
const
|
|
1899
|
-
return
|
|
1900
|
-
sourceColorHct,
|
|
1901
|
-
[0, 38, 105, 140, 333, 360],
|
|
1902
|
-
[-14, 10, -14, 10, -14]
|
|
1903
|
-
);
|
|
1904
|
-
};
|
|
1905
|
-
const getVibrantNeutralChroma = (sourceColorHct) => {
|
|
1906
|
-
getVibrantNeutralHue(sourceColorHct);
|
|
1907
|
-
return 28;
|
|
1908
|
-
};
|
|
1909
|
-
const vibrantVariant = {
|
|
1910
|
-
name: "vibrant",
|
|
1911
|
-
palettes: {
|
|
1912
|
-
primary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 74),
|
|
1913
|
-
secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1914
|
-
getRotatedHue(
|
|
1915
|
-
sourceColorHct,
|
|
1916
|
-
[0, 38, 105, 140, 333, 360],
|
|
1917
|
-
[-14, 10, -14, 10, -14]
|
|
1918
|
-
),
|
|
1919
|
-
56
|
|
1920
|
-
),
|
|
1921
|
-
tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1922
|
-
getRotatedHue(
|
|
1923
|
-
sourceColorHct,
|
|
1924
|
-
[0, 38, 71, 105, 140, 161, 253, 333, 360],
|
|
1925
|
-
[-72, 35, 24, -24, 62, 50, 62, -72]
|
|
1926
|
-
),
|
|
1927
|
-
56
|
|
1928
|
-
),
|
|
1929
|
-
neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
|
|
1930
|
-
getVibrantNeutralHue(sourceColorHct),
|
|
1931
|
-
getVibrantNeutralChroma(sourceColorHct)
|
|
1932
|
-
),
|
|
1933
|
-
neutralVariant: ({ sourceColorHct }) => {
|
|
1934
|
-
const vibrantNeutralHue = getVibrantNeutralHue(sourceColorHct);
|
|
1935
|
-
const vibrantNeutralChroma = getVibrantNeutralChroma(sourceColorHct);
|
|
1936
|
-
return TonalPalette.fromHueAndChroma(
|
|
1937
|
-
vibrantNeutralHue,
|
|
1938
|
-
vibrantNeutralChroma * 1.29
|
|
1939
|
-
);
|
|
1940
|
-
},
|
|
1941
|
-
error: ({ sourceColorHct }) => {
|
|
1942
|
-
const errorHue = getPiecewiseHue(
|
|
1943
|
-
sourceColorHct,
|
|
1944
|
-
[0, 3, 13, 23, 33, 43, 153, 273, 360],
|
|
1945
|
-
[12, 22, 32, 12, 22, 32, 22, 12]
|
|
1946
|
-
);
|
|
1947
|
-
return TonalPalette.fromHueAndChroma(errorHue, 80);
|
|
1948
|
-
}
|
|
1949
|
-
},
|
|
1950
|
-
customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(
|
|
1951
|
-
getRotatedHue(
|
|
1952
|
-
colorHct,
|
|
1953
|
-
[0, 38, 105, 140, 333, 360],
|
|
1954
|
-
[-14, 10, -14, 10, -14]
|
|
1955
|
-
),
|
|
1956
|
-
56
|
|
1957
|
-
)
|
|
1958
|
-
};
|
|
1959
|
-
const Variants = {
|
|
1960
|
-
Expressive: expressiveVariant,
|
|
1961
|
-
Neutral: neutralVariant,
|
|
1962
|
-
TonalSpot: tonalSpotVariant,
|
|
1963
|
-
Vibrant: vibrantVariant
|
|
1774
|
+
const inverseTone = (tone) => {
|
|
1775
|
+
return 100 - tone;
|
|
1964
1776
|
};
|
|
1965
1777
|
const defaultColors = (colorService) => {
|
|
1966
1778
|
const getColor = (key) => {
|
|
@@ -1976,6 +1788,9 @@ const defaultColors = (colorService) => {
|
|
|
1976
1788
|
if (s.isDark) {
|
|
1977
1789
|
return 4;
|
|
1978
1790
|
} else {
|
|
1791
|
+
if (s.variant == "fidelity") {
|
|
1792
|
+
return 100;
|
|
1793
|
+
}
|
|
1979
1794
|
if (Hct.isYellow(s.getPalette("neutral").hue)) {
|
|
1980
1795
|
return 99;
|
|
1981
1796
|
} else if (s.variant === "vibrant") {
|
|
@@ -2271,6 +2086,8 @@ const defaultColors = (colorService) => {
|
|
|
2271
2086
|
0,
|
|
2272
2087
|
Hct.isYellow(s.getPalette("primary").hue) ? 25 : Hct.isCyan(s.getPalette("primary").hue) ? 88 : 98
|
|
2273
2088
|
);
|
|
2089
|
+
} else if (s.variant == "fidelity") {
|
|
2090
|
+
return s.sourceColorHct.tone;
|
|
2274
2091
|
} else {
|
|
2275
2092
|
return tMaxC(
|
|
2276
2093
|
s.getPalette("primary"),
|
|
@@ -2282,7 +2099,18 @@ const defaultColors = (colorService) => {
|
|
|
2282
2099
|
isBackground: true,
|
|
2283
2100
|
background: (s) => highestSurface(s, colorService),
|
|
2284
2101
|
contrastCurve: (s) => getCurve(4.5),
|
|
2285
|
-
|
|
2102
|
+
adjustTone: (s) => s.variant == "fidelity" ? () => {
|
|
2103
|
+
const surfaceTone = colorService.getColor("surface").getMaterialColor().tone(s);
|
|
2104
|
+
const primaryTone = colorService.getColor("primary").getMaterialColor().tone(s);
|
|
2105
|
+
let selfTone = primaryTone;
|
|
2106
|
+
if (Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
|
|
2107
|
+
const result = inverseTone(primaryTone);
|
|
2108
|
+
if (Contrast.ratioOfTones(surfaceTone, result) >= 3) {
|
|
2109
|
+
selfTone = result;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
return selfTone;
|
|
2113
|
+
} : toneDeltaPair(
|
|
2286
2114
|
colorService.getColor("primaryContainer").getMaterialColor(),
|
|
2287
2115
|
colorService.getColor("primary").getMaterialColor(),
|
|
2288
2116
|
5,
|
|
@@ -2305,7 +2133,7 @@ const defaultColors = (colorService) => {
|
|
|
2305
2133
|
isBackground: true,
|
|
2306
2134
|
background: (s) => getColor("surfaceContainerHigh"),
|
|
2307
2135
|
contrastCurve: (s) => getCurve(4.5),
|
|
2308
|
-
|
|
2136
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2309
2137
|
colorService.getColor("primaryDim").getMaterialColor(),
|
|
2310
2138
|
colorService.getColor("primary").getMaterialColor(),
|
|
2311
2139
|
5,
|
|
@@ -2332,6 +2160,13 @@ const defaultColors = (colorService) => {
|
|
|
2332
2160
|
78,
|
|
2333
2161
|
Hct.isCyan(s.getPalette("primary").hue) ? 88 : 90
|
|
2334
2162
|
);
|
|
2163
|
+
}
|
|
2164
|
+
if (s.variant == "fidelity") {
|
|
2165
|
+
return s.isDark ? tMaxC(s.getPalette("primary"), 30, 93) : tMaxC(
|
|
2166
|
+
s.getPalette("primary"),
|
|
2167
|
+
78,
|
|
2168
|
+
Hct.isCyan(s.getPalette("primary").hue) ? 88 : 90
|
|
2169
|
+
);
|
|
2335
2170
|
} else {
|
|
2336
2171
|
return s.isDark ? tMinC(s.getPalette("primary"), 66, 93) : tMaxC(
|
|
2337
2172
|
s.getPalette("primary"),
|
|
@@ -2342,7 +2177,14 @@ const defaultColors = (colorService) => {
|
|
|
2342
2177
|
},
|
|
2343
2178
|
isBackground: true,
|
|
2344
2179
|
background: (s) => highestSurface(s, colorService),
|
|
2345
|
-
|
|
2180
|
+
adjustTone: (s) => s.variant == "fidelity" ? toneDeltaPair(
|
|
2181
|
+
colorService.getColor("primary").getMaterialColor(),
|
|
2182
|
+
colorService.getColor("primaryContainer").getMaterialColor(),
|
|
2183
|
+
15,
|
|
2184
|
+
"relative_darker",
|
|
2185
|
+
true,
|
|
2186
|
+
"farther"
|
|
2187
|
+
) : void 0,
|
|
2346
2188
|
contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2347
2189
|
},
|
|
2348
2190
|
onPrimaryContainer: {
|
|
@@ -2368,7 +2210,7 @@ const defaultColors = (colorService) => {
|
|
|
2368
2210
|
palette: (s) => s.getPalette("primary"),
|
|
2369
2211
|
tone: (s) => colorService.getColor("primaryFixed").getMaterialColor().getTone(s),
|
|
2370
2212
|
isBackground: true,
|
|
2371
|
-
|
|
2213
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2372
2214
|
getColor("primaryFixedDim"),
|
|
2373
2215
|
getColor("primaryFixed"),
|
|
2374
2216
|
5,
|
|
@@ -2410,7 +2252,7 @@ const defaultColors = (colorService) => {
|
|
|
2410
2252
|
isBackground: true,
|
|
2411
2253
|
background: (s) => highestSurface(s, colorService),
|
|
2412
2254
|
contrastCurve: (s) => getCurve(4.5),
|
|
2413
|
-
|
|
2255
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2414
2256
|
getColor("secondaryContainer"),
|
|
2415
2257
|
getColor("secondary"),
|
|
2416
2258
|
5,
|
|
@@ -2431,7 +2273,7 @@ const defaultColors = (colorService) => {
|
|
|
2431
2273
|
isBackground: true,
|
|
2432
2274
|
background: (s) => getColor("surfaceContainerHigh"),
|
|
2433
2275
|
contrastCurve: (s) => getCurve(4.5),
|
|
2434
|
-
|
|
2276
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2435
2277
|
getColor("secondaryDim"),
|
|
2436
2278
|
getColor("secondary"),
|
|
2437
2279
|
5,
|
|
@@ -2458,7 +2300,7 @@ const defaultColors = (colorService) => {
|
|
|
2458
2300
|
},
|
|
2459
2301
|
isBackground: true,
|
|
2460
2302
|
background: (s) => highestSurface(s, colorService),
|
|
2461
|
-
|
|
2303
|
+
adjustTone: (s) => void 0,
|
|
2462
2304
|
contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2463
2305
|
},
|
|
2464
2306
|
onSecondaryContainer: {
|
|
@@ -2484,7 +2326,7 @@ const defaultColors = (colorService) => {
|
|
|
2484
2326
|
palette: (s) => s.getPalette("secondary"),
|
|
2485
2327
|
tone: (s) => getColor("secondaryFixed").getTone(s),
|
|
2486
2328
|
isBackground: true,
|
|
2487
|
-
|
|
2329
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2488
2330
|
getColor("secondaryFixedDim"),
|
|
2489
2331
|
getColor("secondaryFixed"),
|
|
2490
2332
|
5,
|
|
@@ -2522,7 +2364,7 @@ const defaultColors = (colorService) => {
|
|
|
2522
2364
|
isBackground: true,
|
|
2523
2365
|
background: (s) => highestSurface(s, colorService),
|
|
2524
2366
|
contrastCurve: (s) => getCurve(4.5),
|
|
2525
|
-
|
|
2367
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2526
2368
|
getColor("tertiaryContainer"),
|
|
2527
2369
|
getColor("tertiary"),
|
|
2528
2370
|
5,
|
|
@@ -2543,7 +2385,7 @@ const defaultColors = (colorService) => {
|
|
|
2543
2385
|
isBackground: true,
|
|
2544
2386
|
background: (s) => getColor("surfaceContainerHigh"),
|
|
2545
2387
|
contrastCurve: (s) => getCurve(4.5),
|
|
2546
|
-
|
|
2388
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2547
2389
|
getColor("tertiaryDim"),
|
|
2548
2390
|
getColor("tertiary"),
|
|
2549
2391
|
5,
|
|
@@ -2576,7 +2418,7 @@ const defaultColors = (colorService) => {
|
|
|
2576
2418
|
},
|
|
2577
2419
|
isBackground: true,
|
|
2578
2420
|
background: (s) => highestSurface(s, colorService),
|
|
2579
|
-
|
|
2421
|
+
adjustTone: (s) => void 0,
|
|
2580
2422
|
contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2581
2423
|
},
|
|
2582
2424
|
onTertiaryContainer: {
|
|
@@ -2602,7 +2444,7 @@ const defaultColors = (colorService) => {
|
|
|
2602
2444
|
palette: (s) => s.getPalette("tertiary"),
|
|
2603
2445
|
tone: (s) => getColor("tertiaryFixed").getTone(s),
|
|
2604
2446
|
isBackground: true,
|
|
2605
|
-
|
|
2447
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2606
2448
|
getColor("tertiaryFixedDim"),
|
|
2607
2449
|
getColor("tertiaryFixed"),
|
|
2608
2450
|
5,
|
|
@@ -2632,7 +2474,7 @@ const defaultColors = (colorService) => {
|
|
|
2632
2474
|
isBackground: true,
|
|
2633
2475
|
background: (s) => highestSurface(s, colorService),
|
|
2634
2476
|
contrastCurve: (s) => getCurve(4.5),
|
|
2635
|
-
|
|
2477
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2636
2478
|
colorService.getColor("errorContainer").getMaterialColor(),
|
|
2637
2479
|
colorService.getColor("error").getMaterialColor(),
|
|
2638
2480
|
5,
|
|
@@ -2647,7 +2489,7 @@ const defaultColors = (colorService) => {
|
|
|
2647
2489
|
isBackground: true,
|
|
2648
2490
|
background: (s) => getColor("surfaceContainerHigh"),
|
|
2649
2491
|
contrastCurve: (s) => getCurve(4.5),
|
|
2650
|
-
|
|
2492
|
+
adjustTone: (s) => toneDeltaPair(
|
|
2651
2493
|
getColor("errorDim"),
|
|
2652
2494
|
getColor("error"),
|
|
2653
2495
|
5,
|
|
@@ -2668,7 +2510,7 @@ const defaultColors = (colorService) => {
|
|
|
2668
2510
|
},
|
|
2669
2511
|
isBackground: true,
|
|
2670
2512
|
background: (s) => highestSurface(s, colorService),
|
|
2671
|
-
|
|
2513
|
+
adjustTone: (s) => void 0,
|
|
2672
2514
|
contrastCurve: (s) => s.contrastLevel > 0 ? getCurve(1.5) : void 0
|
|
2673
2515
|
},
|
|
2674
2516
|
onErrorContainer: {
|
|
@@ -2709,37 +2551,13 @@ class API {
|
|
|
2709
2551
|
this.colors = colorApi;
|
|
2710
2552
|
this.themes = themeApi;
|
|
2711
2553
|
}
|
|
2554
|
+
async load() {
|
|
2555
|
+
return this.plugins.loadPlugins();
|
|
2556
|
+
}
|
|
2712
2557
|
}
|
|
2713
2558
|
const AppModule = {
|
|
2714
2559
|
api: asClass(API).singleton()
|
|
2715
2560
|
};
|
|
2716
|
-
class PluginAbstract {
|
|
2717
|
-
constructor(options) {
|
|
2718
|
-
__publicField(this, "options");
|
|
2719
|
-
__publicField(this, "pluginInstance");
|
|
2720
|
-
this.options = options;
|
|
2721
|
-
}
|
|
2722
|
-
init(api) {
|
|
2723
|
-
var _a, _b;
|
|
2724
|
-
this.pluginInstance = new this.pluginClass(api, this.options);
|
|
2725
|
-
(_b = (_a = this.pluginInstance).onInit) == null ? void 0 : _b.call(_a);
|
|
2726
|
-
return this;
|
|
2727
|
-
}
|
|
2728
|
-
getInstance() {
|
|
2729
|
-
if (!this.pluginInstance) {
|
|
2730
|
-
throw new Error(`Plugin ${this.name} is not initialized`);
|
|
2731
|
-
}
|
|
2732
|
-
return this.pluginInstance;
|
|
2733
|
-
}
|
|
2734
|
-
}
|
|
2735
|
-
class PluginImplAbstract {
|
|
2736
|
-
constructor(api, options) {
|
|
2737
|
-
var _a;
|
|
2738
|
-
this.api = api;
|
|
2739
|
-
this.options = options;
|
|
2740
|
-
(_a = this.onInit) == null ? void 0 : _a.call(this);
|
|
2741
|
-
}
|
|
2742
|
-
}
|
|
2743
2561
|
class PluginApi {
|
|
2744
2562
|
constructor() {
|
|
2745
2563
|
__publicField(this, "plugins", /* @__PURE__ */ new Map());
|
|
@@ -2768,11 +2586,11 @@ class PluginApi {
|
|
|
2768
2586
|
"Some plugins couldn't be loaded due to missing dependencies: " + Array.from(plugins.keys())
|
|
2769
2587
|
);
|
|
2770
2588
|
}
|
|
2771
|
-
loadPlugins() {
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
(_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a);
|
|
2775
|
-
}
|
|
2589
|
+
async loadPlugins() {
|
|
2590
|
+
var _a, _b;
|
|
2591
|
+
for (const plugin of this.plugins.values()) {
|
|
2592
|
+
await ((_b = (_a = plugin.getInstance()).onLoad) == null ? void 0 : _b.call(_a));
|
|
2593
|
+
}
|
|
2776
2594
|
}
|
|
2777
2595
|
getPlugin(plugin) {
|
|
2778
2596
|
const pluginInstance = this.plugins.get(new plugin().name);
|
|
@@ -2798,19 +2616,16 @@ registerModule(AppModule, PluginModule, ColorModule, ThemeModule);
|
|
|
2798
2616
|
function bootstrap() {
|
|
2799
2617
|
return AppContainer.resolve("api");
|
|
2800
2618
|
}
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
if (config == null) {
|
|
2812
|
-
return;
|
|
2813
|
-
}
|
|
2619
|
+
const initializeApi = () => {
|
|
2620
|
+
const api = bootstrap();
|
|
2621
|
+
registerModule({
|
|
2622
|
+
adapter: asValue(void 0)
|
|
2623
|
+
});
|
|
2624
|
+
return api;
|
|
2625
|
+
};
|
|
2626
|
+
const loader = async (config) => {
|
|
2627
|
+
const api = initializeApi();
|
|
2628
|
+
const init = () => {
|
|
2814
2629
|
const {
|
|
2815
2630
|
sourceColor,
|
|
2816
2631
|
contrastLevel = 0,
|
|
@@ -2821,7 +2636,7 @@ class AdapterAbstract {
|
|
|
2821
2636
|
useDefaultColors = true,
|
|
2822
2637
|
plugins
|
|
2823
2638
|
} = config;
|
|
2824
|
-
|
|
2639
|
+
api.themes.create({
|
|
2825
2640
|
contrastLevel,
|
|
2826
2641
|
isDark,
|
|
2827
2642
|
sourceColorHex: sourceColor,
|
|
@@ -2829,356 +2644,52 @@ class AdapterAbstract {
|
|
|
2829
2644
|
});
|
|
2830
2645
|
if (palettes) {
|
|
2831
2646
|
Object.entries(palettes).forEach(
|
|
2832
|
-
([key, value]) =>
|
|
2647
|
+
([key, value]) => api.themes.addCustomPalette(key, value)
|
|
2833
2648
|
);
|
|
2834
2649
|
}
|
|
2835
2650
|
if (useDefaultColors) {
|
|
2836
|
-
|
|
2651
|
+
api.colors.addColors(defaultColors);
|
|
2837
2652
|
}
|
|
2838
2653
|
if (colors) {
|
|
2839
|
-
|
|
2654
|
+
api.colors.addColors(colors);
|
|
2840
2655
|
}
|
|
2841
2656
|
if (plugins) {
|
|
2842
2657
|
plugins.forEach((plugin) => {
|
|
2843
|
-
|
|
2658
|
+
api.plugins.addPlugin(plugin);
|
|
2844
2659
|
});
|
|
2845
|
-
|
|
2846
|
-
}
|
|
2847
|
-
}
|
|
2848
|
-
load() {
|
|
2849
|
-
this.api.plugins.loadPlugins();
|
|
2850
|
-
}
|
|
2851
|
-
}
|
|
2852
|
-
function defineConfig(configObject) {
|
|
2853
|
-
if (!configObject || typeof configObject !== "object") {
|
|
2854
|
-
throw new Error("The configuration is missing or not an object");
|
|
2855
|
-
}
|
|
2856
|
-
if (!("sourceColor" in configObject)) {
|
|
2857
|
-
throw new Error("Invalid configuration");
|
|
2858
|
-
}
|
|
2859
|
-
return configObject;
|
|
2860
|
-
}
|
|
2861
|
-
class NodeAdapter extends AdapterAbstract {
|
|
2862
|
-
constructor(configPath = "./theme.config") {
|
|
2863
|
-
super();
|
|
2864
|
-
this.configPath = configPath;
|
|
2865
|
-
}
|
|
2866
|
-
async getConfig() {
|
|
2867
|
-
if (typeof process !== "undefined" && process.release && process.release.name === "node") {
|
|
2868
|
-
const fs2 = (await import("fs")).default;
|
|
2869
|
-
const jiti = createJiti(import.meta.url, {
|
|
2870
|
-
// Options optionnelles
|
|
2871
|
-
debug: process.env.NODE_ENV === "development",
|
|
2872
|
-
cache: true,
|
|
2873
|
-
// Cache les transpilations
|
|
2874
|
-
interopDefault: true
|
|
2875
|
-
// Gère automatiquement les exports par défaut
|
|
2876
|
-
});
|
|
2877
|
-
const base = resolve(this.configPath);
|
|
2878
|
-
const extensions = [".ts", ".js", ".mjs", ".cjs"];
|
|
2879
|
-
let config = null;
|
|
2880
|
-
for (const ext of extensions) {
|
|
2881
|
-
const configFilePath = base + ext;
|
|
2882
|
-
if (fs2.existsSync(configFilePath)) {
|
|
2883
|
-
try {
|
|
2884
|
-
config = await jiti.import(configFilePath, { default: true });
|
|
2885
|
-
break;
|
|
2886
|
-
} catch (error) {
|
|
2887
|
-
console.warn(`Failed to load ${configFilePath}:`, error);
|
|
2888
|
-
continue;
|
|
2889
|
-
}
|
|
2890
|
-
}
|
|
2891
|
-
}
|
|
2892
|
-
if (!config) {
|
|
2893
|
-
throw new Error(
|
|
2894
|
-
`Configuration file not found, looked for: ${base} with extensions: ${extensions.join(", ")}`
|
|
2895
|
-
);
|
|
2896
|
-
}
|
|
2897
|
-
return config;
|
|
2898
|
-
} else {
|
|
2899
|
-
throw new Error(
|
|
2900
|
-
"You must provide configuration object when using this library in a browser."
|
|
2901
|
-
);
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
}
|
|
2905
|
-
const udixioVite = async (configPath = "./theme.config") => {
|
|
2906
|
-
if (global.NX_GRAPH_CREATION) {
|
|
2907
|
-
return;
|
|
2908
|
-
}
|
|
2909
|
-
class ViteAdapter extends AdapterAbstract {
|
|
2910
|
-
constructor(configPath2) {
|
|
2911
|
-
super();
|
|
2912
|
-
__publicField(this, "configExtension");
|
|
2913
|
-
this.configPath = configPath2;
|
|
2914
|
-
}
|
|
2915
|
-
getConfigPath() {
|
|
2916
|
-
if (!this.configExtension) {
|
|
2917
|
-
throw new Error("config extension not found");
|
|
2918
|
-
}
|
|
2919
|
-
return path.resolve(this.configPath + this.configExtension);
|
|
2920
|
-
}
|
|
2921
|
-
async getConfig() {
|
|
2922
|
-
const resolvedPath = path.resolve(this.configPath);
|
|
2923
|
-
const result = await loadConfigFromFile(
|
|
2924
|
-
{ command: "serve", mode: "development" },
|
|
2925
|
-
// ou 'build'
|
|
2926
|
-
resolvedPath
|
|
2927
|
-
);
|
|
2928
|
-
if (!(result == null ? void 0 : result.config)) {
|
|
2929
|
-
throw new Error("config not found");
|
|
2930
|
-
}
|
|
2931
|
-
if (!this.configExtension) {
|
|
2932
|
-
this.configExtension = path.extname(result.dependencies[0]);
|
|
2933
|
-
}
|
|
2934
|
-
return result.config;
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
const adapter = new ViteAdapter(configPath);
|
|
2938
|
-
await adapter.init();
|
|
2939
|
-
configPath = adapter.getConfigPath();
|
|
2940
|
-
return {
|
|
2941
|
-
name: "vite:udixio-theme",
|
|
2942
|
-
async buildStart() {
|
|
2943
|
-
if (fs.existsSync(configPath)) {
|
|
2944
|
-
this.addWatchFile(configPath);
|
|
2945
|
-
}
|
|
2946
|
-
adapter.load();
|
|
2947
|
-
},
|
|
2948
|
-
async generateBundle() {
|
|
2949
|
-
adapter.load();
|
|
2950
|
-
},
|
|
2951
|
-
// Handles Hot Module Replacement in dev server
|
|
2952
|
-
async handleHotUpdate({ server, file, modules }) {
|
|
2953
|
-
if (configPath === file) {
|
|
2954
|
-
const adapter2 = new ViteAdapter(configPath);
|
|
2955
|
-
await adapter2.init();
|
|
2956
|
-
adapter2.load();
|
|
2957
|
-
server.ws.send({ type: "full-reload", path: "*" });
|
|
2958
|
-
return modules;
|
|
2959
|
-
}
|
|
2960
|
-
return;
|
|
2660
|
+
api.plugins.initPlugins(api);
|
|
2961
2661
|
}
|
|
2962
2662
|
};
|
|
2663
|
+
init();
|
|
2664
|
+
await api.load();
|
|
2665
|
+
return api;
|
|
2963
2666
|
};
|
|
2964
|
-
var FontFamily = /* @__PURE__ */ ((FontFamily2) => {
|
|
2965
|
-
FontFamily2["Expressive"] = "expressive";
|
|
2966
|
-
FontFamily2["Neutral"] = "neutral";
|
|
2967
|
-
return FontFamily2;
|
|
2968
|
-
})(FontFamily || {});
|
|
2969
|
-
class FontPlugin extends PluginAbstract {
|
|
2970
|
-
constructor() {
|
|
2971
|
-
super(...arguments);
|
|
2972
|
-
__publicField(this, "dependencies", []);
|
|
2973
|
-
__publicField(this, "name", "font");
|
|
2974
|
-
__publicField(this, "pluginClass", FontPluginImpl);
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
class FontPluginImpl extends PluginImplAbstract {
|
|
2978
|
-
constructor() {
|
|
2979
|
-
super(...arguments);
|
|
2980
|
-
__publicField(this, "_fontFamily");
|
|
2981
|
-
__publicField(this, "_fontStyles");
|
|
2982
|
-
}
|
|
2983
|
-
get fontFamily() {
|
|
2984
|
-
if (!this._fontFamily) throw new Error("Font family not initialized");
|
|
2985
|
-
return this._fontFamily;
|
|
2986
|
-
}
|
|
2987
|
-
set fontFamily(value) {
|
|
2988
|
-
this._fontFamily = value;
|
|
2989
|
-
}
|
|
2990
|
-
get fontStyles() {
|
|
2991
|
-
if (!this._fontStyles) throw new Error("Font styles not initialized");
|
|
2992
|
-
return this._fontStyles;
|
|
2993
|
-
}
|
|
2994
|
-
set fontStyles(value) {
|
|
2995
|
-
this._fontStyles = value;
|
|
2996
|
-
}
|
|
2997
|
-
getFonts() {
|
|
2998
|
-
return {
|
|
2999
|
-
fontStyles: this.fontStyles,
|
|
3000
|
-
fontFamily: this.fontFamily
|
|
3001
|
-
};
|
|
3002
|
-
}
|
|
3003
|
-
onInit() {
|
|
3004
|
-
var _a, _b, _c, _d;
|
|
3005
|
-
this.fontFamily = {
|
|
3006
|
-
expressive: ((_b = (_a = this.options) == null ? void 0 : _a.fontFamily) == null ? void 0 : _b.expressive) ?? [
|
|
3007
|
-
"Roboto",
|
|
3008
|
-
"sans-serif"
|
|
3009
|
-
],
|
|
3010
|
-
neutral: ((_d = (_c = this.options) == null ? void 0 : _c.fontFamily) == null ? void 0 : _d.neutral) ?? ["Roboto", "sans-serif"]
|
|
3011
|
-
};
|
|
3012
|
-
this.fontStyles = {
|
|
3013
|
-
display: {
|
|
3014
|
-
large: {
|
|
3015
|
-
fontWeight: 400,
|
|
3016
|
-
fontSize: 3.5625,
|
|
3017
|
-
lineHeight: 4,
|
|
3018
|
-
letterSpacing: -0.015625,
|
|
3019
|
-
fontFamily: "expressive"
|
|
3020
|
-
/* Expressive */
|
|
3021
|
-
},
|
|
3022
|
-
medium: {
|
|
3023
|
-
fontWeight: 400,
|
|
3024
|
-
fontSize: 2.8125,
|
|
3025
|
-
lineHeight: 3.25,
|
|
3026
|
-
fontFamily: "expressive"
|
|
3027
|
-
/* Expressive */
|
|
3028
|
-
},
|
|
3029
|
-
small: {
|
|
3030
|
-
fontWeight: 400,
|
|
3031
|
-
fontSize: 2.25,
|
|
3032
|
-
lineHeight: 2.75,
|
|
3033
|
-
fontFamily: "expressive"
|
|
3034
|
-
/* Expressive */
|
|
3035
|
-
}
|
|
3036
|
-
},
|
|
3037
|
-
headline: {
|
|
3038
|
-
large: {
|
|
3039
|
-
fontWeight: 400,
|
|
3040
|
-
fontSize: 2,
|
|
3041
|
-
lineHeight: 2.5,
|
|
3042
|
-
fontFamily: "expressive"
|
|
3043
|
-
/* Expressive */
|
|
3044
|
-
},
|
|
3045
|
-
medium: {
|
|
3046
|
-
fontWeight: 400,
|
|
3047
|
-
fontSize: 1.75,
|
|
3048
|
-
lineHeight: 2.25,
|
|
3049
|
-
fontFamily: "expressive"
|
|
3050
|
-
/* Expressive */
|
|
3051
|
-
},
|
|
3052
|
-
small: {
|
|
3053
|
-
fontWeight: 400,
|
|
3054
|
-
fontSize: 1.5,
|
|
3055
|
-
lineHeight: 2,
|
|
3056
|
-
fontFamily: "expressive"
|
|
3057
|
-
/* Expressive */
|
|
3058
|
-
}
|
|
3059
|
-
},
|
|
3060
|
-
title: {
|
|
3061
|
-
large: {
|
|
3062
|
-
fontWeight: 400,
|
|
3063
|
-
fontSize: 1.375,
|
|
3064
|
-
lineHeight: 1.75,
|
|
3065
|
-
fontFamily: "neutral"
|
|
3066
|
-
/* Neutral */
|
|
3067
|
-
},
|
|
3068
|
-
medium: {
|
|
3069
|
-
fontWeight: 500,
|
|
3070
|
-
fontSize: 1,
|
|
3071
|
-
lineHeight: 1.5,
|
|
3072
|
-
fontFamily: "neutral",
|
|
3073
|
-
letterSpacing: 9375e-6
|
|
3074
|
-
},
|
|
3075
|
-
small: {
|
|
3076
|
-
fontWeight: 500,
|
|
3077
|
-
fontSize: 0.875,
|
|
3078
|
-
lineHeight: 1.25,
|
|
3079
|
-
fontFamily: "neutral",
|
|
3080
|
-
letterSpacing: 625e-5
|
|
3081
|
-
}
|
|
3082
|
-
},
|
|
3083
|
-
label: {
|
|
3084
|
-
large: {
|
|
3085
|
-
fontWeight: 500,
|
|
3086
|
-
fontSize: 0.875,
|
|
3087
|
-
lineHeight: 1.25,
|
|
3088
|
-
fontFamily: "neutral",
|
|
3089
|
-
letterSpacing: 625e-5
|
|
3090
|
-
},
|
|
3091
|
-
medium: {
|
|
3092
|
-
fontWeight: 500,
|
|
3093
|
-
fontSize: 0.75,
|
|
3094
|
-
lineHeight: 1,
|
|
3095
|
-
fontFamily: "neutral",
|
|
3096
|
-
letterSpacing: 0.03125
|
|
3097
|
-
},
|
|
3098
|
-
small: {
|
|
3099
|
-
fontWeight: 500,
|
|
3100
|
-
fontSize: 0.6875,
|
|
3101
|
-
lineHeight: 1,
|
|
3102
|
-
fontFamily: "neutral",
|
|
3103
|
-
letterSpacing: 0.03125
|
|
3104
|
-
}
|
|
3105
|
-
},
|
|
3106
|
-
body: {
|
|
3107
|
-
large: {
|
|
3108
|
-
fontWeight: 400,
|
|
3109
|
-
fontSize: 1,
|
|
3110
|
-
lineHeight: 1.5625,
|
|
3111
|
-
fontFamily: "neutral",
|
|
3112
|
-
letterSpacing: 0.03125
|
|
3113
|
-
},
|
|
3114
|
-
medium: {
|
|
3115
|
-
fontWeight: 400,
|
|
3116
|
-
fontSize: 0.875,
|
|
3117
|
-
lineHeight: 1.25,
|
|
3118
|
-
fontFamily: "neutral",
|
|
3119
|
-
letterSpacing: 0.015625
|
|
3120
|
-
},
|
|
3121
|
-
small: {
|
|
3122
|
-
fontWeight: 400,
|
|
3123
|
-
fontSize: 0.75,
|
|
3124
|
-
lineHeight: 1,
|
|
3125
|
-
fontFamily: "neutral",
|
|
3126
|
-
letterSpacing: 0.025
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
};
|
|
3130
|
-
if (this.options && this.options.fontStyles)
|
|
3131
|
-
Object.entries(this.options.fontStyles).forEach(([key, fontParam]) => {
|
|
3132
|
-
const fontRole = key;
|
|
3133
|
-
Object.entries(fontParam).forEach(([size, fontStyle]) => {
|
|
3134
|
-
const fontSize = size;
|
|
3135
|
-
if (fontStyle) {
|
|
3136
|
-
this.fontStyles[fontRole][fontSize] = {
|
|
3137
|
-
...this.fontStyles[fontRole][fontSize],
|
|
3138
|
-
...fontStyle
|
|
3139
|
-
};
|
|
3140
|
-
}
|
|
3141
|
-
});
|
|
3142
|
-
});
|
|
3143
|
-
}
|
|
3144
|
-
}
|
|
3145
2667
|
export {
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
defineConfig,
|
|
3174
|
-
expressiveVariant,
|
|
3175
|
-
extendSpecVersion,
|
|
3176
|
-
getPiecewiseHue,
|
|
3177
|
-
getRotatedHue,
|
|
3178
|
-
highestSurface,
|
|
3179
|
-
neutralVariant,
|
|
3180
|
-
registerModule,
|
|
3181
|
-
tonalSpotVariant,
|
|
3182
|
-
udixioVite,
|
|
3183
|
-
vibrantVariant
|
|
2668
|
+
AppContainer as A,
|
|
2669
|
+
ColorApi as C,
|
|
2670
|
+
DynamicColor as D,
|
|
2671
|
+
Hct as H,
|
|
2672
|
+
PluginModule as P,
|
|
2673
|
+
SchemeManager as S,
|
|
2674
|
+
ThemeModule as T,
|
|
2675
|
+
Variant as V,
|
|
2676
|
+
AppModule as a,
|
|
2677
|
+
API as b,
|
|
2678
|
+
ColorManager as c,
|
|
2679
|
+
ColorModule as d,
|
|
2680
|
+
ConfigurableColor as e,
|
|
2681
|
+
defaultColors as f,
|
|
2682
|
+
bootstrap as g,
|
|
2683
|
+
highestSurface as h,
|
|
2684
|
+
ContrastCurve as i,
|
|
2685
|
+
PluginApi as j,
|
|
2686
|
+
tonalSpotVariant as k,
|
|
2687
|
+
loader as l,
|
|
2688
|
+
Scheme as m,
|
|
2689
|
+
ThemeApi as n,
|
|
2690
|
+
getPiecewiseHue as o,
|
|
2691
|
+
getRotatedHue as p,
|
|
2692
|
+
VariantManager as q,
|
|
2693
|
+
registerModule as r,
|
|
2694
|
+
toneDeltaPair as t
|
|
3184
2695
|
};
|