@udixio/theme 1.0.0-beta.8 → 1.0.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/.eslintrc.mjs +22 -0
- package/CHANGELOG.md +174 -0
- package/README.md +6 -68
- package/dist/API.d.ts +14 -0
- package/dist/API.d.ts.map +1 -0
- package/dist/LICENSE +202 -0
- package/dist/adapter/adapter.abstract.d.ts +10 -0
- package/dist/adapter/adapter.abstract.d.ts.map +1 -0
- package/dist/adapter/config.interface.d.ts +14 -0
- package/dist/adapter/config.interface.d.ts.map +1 -0
- package/dist/adapter/define-config.d.ts +3 -0
- package/dist/adapter/define-config.d.ts.map +1 -0
- package/dist/adapter/file-adapter.mixin.d.ts +18 -0
- package/dist/adapter/file-adapter.mixin.d.ts.map +1 -0
- package/dist/adapter/index.d.ts +4 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/node.adapter.d.ts +7 -0
- package/dist/adapters/node.adapter.d.ts.map +1 -0
- package/dist/adapters/vite.adapter.d.ts +3 -0
- package/dist/adapters/vite.adapter.d.ts.map +1 -0
- package/dist/app.container.d.ts +5 -5
- package/dist/app.container.d.ts.map +1 -0
- package/dist/app.module.d.ts +1 -0
- package/dist/app.module.d.ts.map +1 -0
- package/dist/bootstrap.d.ts +3 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/color/color.api.d.ts +39 -0
- package/dist/color/color.api.d.ts.map +1 -0
- package/dist/color/color.manager.d.ts +24 -0
- package/dist/color/color.manager.d.ts.map +1 -0
- package/dist/color/color.module.d.ts +1 -0
- package/dist/color/color.module.d.ts.map +1 -0
- package/dist/color/color.utils.d.ts +8 -0
- package/dist/color/color.utils.d.ts.map +1 -0
- package/dist/color/configurable-color.d.ts +31 -0
- package/dist/color/configurable-color.d.ts.map +1 -0
- package/dist/color/default-color.d.ts +3 -0
- package/dist/color/default-color.d.ts.map +1 -0
- package/dist/color/index.d.ts +5 -4
- package/dist/color/index.d.ts.map +1 -0
- package/dist/index.cjs +3215 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3175 -7
- package/dist/material-color-utilities/contrastCurve.d.ts +1 -0
- package/dist/material-color-utilities/contrastCurve.d.ts.map +1 -0
- package/dist/material-color-utilities/dynamic_color.d.ts +89 -76
- package/dist/material-color-utilities/dynamic_color.d.ts.map +1 -0
- package/dist/material-color-utilities/hct_solver.d.ts +131 -0
- package/dist/material-color-utilities/hct_solver.d.ts.map +1 -0
- package/dist/material-color-utilities/htc.d.ts +77 -0
- package/dist/material-color-utilities/htc.d.ts.map +1 -0
- package/dist/material-color-utilities/index.d.ts +1 -0
- package/dist/material-color-utilities/index.d.ts.map +1 -0
- package/dist/material-color-utilities/toneDeltaPair.d.ts +19 -25
- package/dist/material-color-utilities/toneDeltaPair.d.ts.map +1 -0
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/plugin.abstract.d.ts +19 -5
- package/dist/plugin/plugin.abstract.d.ts.map +1 -0
- package/dist/plugin/plugin.api.d.ts +10 -0
- package/dist/plugin/plugin.api.d.ts.map +1 -0
- package/dist/plugin/plugin.module.d.ts +1 -0
- package/dist/plugin/plugin.module.d.ts.map +1 -0
- package/dist/plugins/font/font.plugin.d.ts +50 -0
- package/dist/plugins/font/font.plugin.d.ts.map +1 -0
- package/dist/plugins/font/index.d.ts +2 -0
- package/dist/plugins/font/index.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/theme/index.d.ts +7 -3
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/scheme.d.ts +20 -0
- package/dist/theme/scheme.d.ts.map +1 -0
- package/dist/theme/scheme.manager.d.ts +31 -0
- package/dist/theme/scheme.manager.d.ts.map +1 -0
- package/dist/theme/theme.api.d.ts +23 -0
- package/dist/theme/theme.api.d.ts.map +1 -0
- package/dist/theme/theme.module.d.ts +1 -0
- package/dist/theme/theme.module.d.ts.map +1 -0
- package/dist/theme/variant.d.ts +36 -0
- package/dist/theme/variant.d.ts.map +1 -0
- package/dist/theme/variant.manager.d.ts +14 -0
- package/dist/theme/variant.manager.d.ts.map +1 -0
- package/dist/theme/variants/expressive.variant.d.ts +3 -0
- package/dist/theme/variants/expressive.variant.d.ts.map +1 -0
- package/dist/theme/variants/index.d.ts +11 -0
- package/dist/theme/variants/index.d.ts.map +1 -0
- package/dist/theme/variants/neutral.variant.d.ts +3 -0
- package/dist/theme/variants/neutral.variant.d.ts.map +1 -0
- package/dist/theme/variants/tonal-spot.variant.d.ts +3 -0
- package/dist/theme/variants/tonal-spot.variant.d.ts.map +1 -0
- package/dist/theme/variants/vibrant.variant.d.ts +3 -0
- package/dist/theme/variants/vibrant.variant.d.ts.map +1 -0
- package/package.json +24 -86
- package/src/API.ts +23 -0
- package/src/adapter/adapter.abstract.ts +64 -0
- package/src/adapter/config.interface.ts +14 -0
- package/src/adapter/define-config.ts +11 -0
- package/src/adapter/file-adapter.mixin.ts +72 -0
- package/src/adapter/index.ts +3 -0
- package/src/adapters/index.ts +2 -0
- package/src/adapters/node.adapter.ts +49 -0
- package/src/adapters/vite.adapter.ts +79 -0
- package/src/app.container.ts +12 -36
- package/src/app.module.ts +2 -2
- package/src/bootstrap.ts +6 -0
- package/src/color/color.api.ts +75 -0
- package/src/color/color.manager.ts +213 -0
- package/src/color/color.module.ts +4 -4
- package/src/color/color.utils.ts +126 -0
- package/src/color/configurable-color.ts +67 -0
- package/src/color/default-color.ts +832 -0
- package/src/color/index.ts +4 -4
- package/src/index.test.ts +5 -0
- package/src/index.ts +6 -4
- package/src/material-color-utilities/dynamic_color.ts +286 -222
- package/src/material-color-utilities/hct_solver.ts +536 -0
- package/src/material-color-utilities/htc.ts +198 -0
- package/src/material-color-utilities/toneDeltaPair.ts +29 -11
- package/src/plugin/index.ts +3 -0
- package/src/plugin/plugin.abstract.ts +45 -4
- package/src/plugin/plugin.api.ts +51 -0
- package/src/plugin/plugin.module.ts +2 -2
- package/src/plugins/font/font.plugin.ts +203 -0
- package/src/plugins/font/index.ts +1 -0
- package/src/plugins/index.ts +1 -0
- package/src/theme/index.ts +6 -3
- package/src/theme/{services/scheme.service.ts → scheme.manager.ts} +39 -19
- package/src/theme/{entities/scheme.entity.ts → scheme.ts} +20 -4
- package/src/theme/{services/theme.service.ts → theme.api.ts} +23 -19
- package/src/theme/theme.module.ts +6 -4
- package/src/theme/variant.manager.ts +58 -0
- package/src/theme/variant.ts +53 -0
- package/src/theme/variants/expressive.variant.ts +81 -0
- package/src/theme/variants/index.ts +16 -0
- package/src/theme/variants/neutral.variant.ts +45 -0
- package/src/theme/variants/tonal-spot.variant.ts +35 -0
- package/src/theme/variants/vibrant.variant.ts +72 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +33 -0
- package/tsconfig.spec.json +36 -0
- package/vite.config.ts +54 -0
- package/LICENSE +0 -21
- package/dist/app.service.d.ts +0 -13
- package/dist/color/color.interface.d.ts +0 -8
- package/dist/color/entities/color.entity.d.ts +0 -42
- package/dist/color/entities/index.d.ts +0 -1
- package/dist/color/models/default-color.model.d.ts +0 -3
- package/dist/color/models/index.d.ts +0 -1
- package/dist/color/services/color-manager.service.d.ts +0 -18
- package/dist/color/services/color.service.d.ts +0 -21
- package/dist/color/services/index.d.ts +0 -2
- package/dist/config/config.interface.d.ts +0 -14
- package/dist/config/config.module.d.ts +0 -2
- package/dist/config/config.service.d.ts +0 -12
- package/dist/config/index.d.ts +0 -2
- package/dist/main.d.ts +0 -3
- package/dist/plugin/plugin.service.d.ts +0 -9
- package/dist/theme/entities/index.d.ts +0 -2
- package/dist/theme/entities/scheme.entity.d.ts +0 -15
- package/dist/theme/entities/variant.entity.d.ts +0 -7
- package/dist/theme/models/index.d.ts +0 -1
- package/dist/theme/models/variant.model.d.ts +0 -8
- package/dist/theme/services/index.d.ts +0 -3
- package/dist/theme/services/scheme.service.d.ts +0 -17
- package/dist/theme/services/theme.service.d.ts +0 -22
- package/dist/theme/services/variant.service.d.ts +0 -13
- package/dist/theme.cjs.development.js +0 -1975
- package/dist/theme.cjs.development.js.map +0 -1
- package/dist/theme.cjs.production.min.js +0 -2
- package/dist/theme.cjs.production.min.js.map +0 -1
- package/dist/theme.esm.js +0 -1947
- package/dist/theme.esm.js.map +0 -1
- package/src/app.service.spec.ts +0 -15
- package/src/app.service.ts +0 -23
- package/src/color/color.interface.ts +0 -13
- package/src/color/entities/color.entity.ts +0 -71
- package/src/color/entities/index.ts +0 -1
- package/src/color/models/default-color.model.ts +0 -300
- package/src/color/models/index.ts +0 -1
- package/src/color/services/color-manager.service.ts +0 -191
- package/src/color/services/color.service.spec.ts +0 -28
- package/src/color/services/color.service.ts +0 -75
- package/src/color/services/index.ts +0 -2
- package/src/config/config.interface.ts +0 -15
- package/src/config/config.module.ts +0 -7
- package/src/config/config.service.ts +0 -68
- package/src/config/index.ts +0 -2
- package/src/main.ts +0 -14
- package/src/plugin/plugin.service.ts +0 -26
- package/src/theme/entities/index.ts +0 -2
- package/src/theme/entities/variant.entity.ts +0 -39
- package/src/theme/models/index.ts +0 -1
- package/src/theme/models/variant.model.ts +0 -63
- package/src/theme/services/index.ts +0 -3
- package/src/theme/services/variant.service.ts +0 -52
package/dist/theme.esm.js
DELETED
|
@@ -1,1947 +0,0 @@
|
|
|
1
|
-
import { asClass, createContainer, InjectionMode } from 'awilix';
|
|
2
|
-
import { lerp, Contrast, clampDouble, hexFromArgb, Hct, argbFromHex, TonalPalette, DislikeAnalyzer, sanitizeDegreesDouble } from '@material/material-color-utilities';
|
|
3
|
-
import { resolve } from 'path';
|
|
4
|
-
|
|
5
|
-
var ColorService = /*#__PURE__*/function () {
|
|
6
|
-
function ColorService(_ref) {
|
|
7
|
-
var colorManagerService = _ref.colorManagerService;
|
|
8
|
-
this.colorManagerService = void 0;
|
|
9
|
-
this.colorManagerService = colorManagerService;
|
|
10
|
-
}
|
|
11
|
-
var _proto = ColorService.prototype;
|
|
12
|
-
_proto.getColors = function getColors() {
|
|
13
|
-
return this.colorManagerService.getAll();
|
|
14
|
-
}
|
|
15
|
-
// getColors() {
|
|
16
|
-
// const colors: Record<string, string> = {};
|
|
17
|
-
//
|
|
18
|
-
// for (const [key, value] of this.colorManagerService.getAll()) {
|
|
19
|
-
// colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
|
|
20
|
-
// }
|
|
21
|
-
//
|
|
22
|
-
// return colors;
|
|
23
|
-
// }
|
|
24
|
-
;
|
|
25
|
-
_proto.addColor = function addColor(key, color) {
|
|
26
|
-
return this.colorManagerService.createOrUpdate(key, color);
|
|
27
|
-
};
|
|
28
|
-
_proto.addColors = function addColors(args) {
|
|
29
|
-
var _this = this;
|
|
30
|
-
if (!Array.isArray(args)) args = [args];
|
|
31
|
-
args.forEach(function (args) {
|
|
32
|
-
if (typeof args === 'function') {
|
|
33
|
-
args = args(_this);
|
|
34
|
-
}
|
|
35
|
-
if (args.fromPalettes) {
|
|
36
|
-
if (!Array.isArray(args.fromPalettes)) args.fromPalettes = [args.fromPalettes];
|
|
37
|
-
args.fromPalettes.map(function (paletteKey) {
|
|
38
|
-
_this.colorManagerService.addFromPalette(paletteKey);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (args.colors) {
|
|
42
|
-
Object.keys(args.colors).map(function (key) {
|
|
43
|
-
return _this.addColor(key, args.colors[key]);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
_proto.getColor = function getColor(key) {
|
|
49
|
-
return this.colorManagerService.get(key);
|
|
50
|
-
};
|
|
51
|
-
_proto.removeColor = function removeColor(key) {
|
|
52
|
-
return this.colorManagerService.remove(key);
|
|
53
|
-
};
|
|
54
|
-
_proto.updateColor = function updateColor(key, newColor) {
|
|
55
|
-
return this.colorManagerService.createOrUpdate(key, newColor);
|
|
56
|
-
};
|
|
57
|
-
return ColorService;
|
|
58
|
-
}();
|
|
59
|
-
|
|
60
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
61
|
-
try {
|
|
62
|
-
var i = n[a](c),
|
|
63
|
-
u = i.value;
|
|
64
|
-
} catch (n) {
|
|
65
|
-
return void e(n);
|
|
66
|
-
}
|
|
67
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
68
|
-
}
|
|
69
|
-
function _asyncToGenerator(n) {
|
|
70
|
-
return function () {
|
|
71
|
-
var t = this,
|
|
72
|
-
e = arguments;
|
|
73
|
-
return new Promise(function (r, o) {
|
|
74
|
-
var a = n.apply(t, e);
|
|
75
|
-
function _next(n) {
|
|
76
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
77
|
-
}
|
|
78
|
-
function _throw(n) {
|
|
79
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
80
|
-
}
|
|
81
|
-
_next(void 0);
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function _defineProperties(e, r) {
|
|
86
|
-
for (var t = 0; t < r.length; t++) {
|
|
87
|
-
var o = r[t];
|
|
88
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function _createClass(e, r, t) {
|
|
92
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
93
|
-
writable: !1
|
|
94
|
-
}), e;
|
|
95
|
-
}
|
|
96
|
-
function _extends() {
|
|
97
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
98
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
99
|
-
var t = arguments[e];
|
|
100
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
101
|
-
}
|
|
102
|
-
return n;
|
|
103
|
-
}, _extends.apply(null, arguments);
|
|
104
|
-
}
|
|
105
|
-
function _regeneratorRuntime() {
|
|
106
|
-
_regeneratorRuntime = function () {
|
|
107
|
-
return e;
|
|
108
|
-
};
|
|
109
|
-
var t,
|
|
110
|
-
e = {},
|
|
111
|
-
r = Object.prototype,
|
|
112
|
-
n = r.hasOwnProperty,
|
|
113
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
114
|
-
t[e] = r.value;
|
|
115
|
-
},
|
|
116
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
117
|
-
a = i.iterator || "@@iterator",
|
|
118
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
119
|
-
u = i.toStringTag || "@@toStringTag";
|
|
120
|
-
function define(t, e, r) {
|
|
121
|
-
return Object.defineProperty(t, e, {
|
|
122
|
-
value: r,
|
|
123
|
-
enumerable: !0,
|
|
124
|
-
configurable: !0,
|
|
125
|
-
writable: !0
|
|
126
|
-
}), t[e];
|
|
127
|
-
}
|
|
128
|
-
try {
|
|
129
|
-
define({}, "");
|
|
130
|
-
} catch (t) {
|
|
131
|
-
define = function (t, e, r) {
|
|
132
|
-
return t[e] = r;
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function wrap(t, e, r, n) {
|
|
136
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
137
|
-
a = Object.create(i.prototype),
|
|
138
|
-
c = new Context(n || []);
|
|
139
|
-
return o(a, "_invoke", {
|
|
140
|
-
value: makeInvokeMethod(t, r, c)
|
|
141
|
-
}), a;
|
|
142
|
-
}
|
|
143
|
-
function tryCatch(t, e, r) {
|
|
144
|
-
try {
|
|
145
|
-
return {
|
|
146
|
-
type: "normal",
|
|
147
|
-
arg: t.call(e, r)
|
|
148
|
-
};
|
|
149
|
-
} catch (t) {
|
|
150
|
-
return {
|
|
151
|
-
type: "throw",
|
|
152
|
-
arg: t
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
e.wrap = wrap;
|
|
157
|
-
var h = "suspendedStart",
|
|
158
|
-
l = "suspendedYield",
|
|
159
|
-
f = "executing",
|
|
160
|
-
s = "completed",
|
|
161
|
-
y = {};
|
|
162
|
-
function Generator() {}
|
|
163
|
-
function GeneratorFunction() {}
|
|
164
|
-
function GeneratorFunctionPrototype() {}
|
|
165
|
-
var p = {};
|
|
166
|
-
define(p, a, function () {
|
|
167
|
-
return this;
|
|
168
|
-
});
|
|
169
|
-
var d = Object.getPrototypeOf,
|
|
170
|
-
v = d && d(d(values([])));
|
|
171
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
172
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
173
|
-
function defineIteratorMethods(t) {
|
|
174
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
175
|
-
define(t, e, function (t) {
|
|
176
|
-
return this._invoke(e, t);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function AsyncIterator(t, e) {
|
|
181
|
-
function invoke(r, o, i, a) {
|
|
182
|
-
var c = tryCatch(t[r], t, o);
|
|
183
|
-
if ("throw" !== c.type) {
|
|
184
|
-
var u = c.arg,
|
|
185
|
-
h = u.value;
|
|
186
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
187
|
-
invoke("next", t, i, a);
|
|
188
|
-
}, function (t) {
|
|
189
|
-
invoke("throw", t, i, a);
|
|
190
|
-
}) : e.resolve(h).then(function (t) {
|
|
191
|
-
u.value = t, i(u);
|
|
192
|
-
}, function (t) {
|
|
193
|
-
return invoke("throw", t, i, a);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
a(c.arg);
|
|
197
|
-
}
|
|
198
|
-
var r;
|
|
199
|
-
o(this, "_invoke", {
|
|
200
|
-
value: function (t, n) {
|
|
201
|
-
function callInvokeWithMethodAndArg() {
|
|
202
|
-
return new e(function (e, r) {
|
|
203
|
-
invoke(t, n, e, r);
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
function makeInvokeMethod(e, r, n) {
|
|
211
|
-
var o = h;
|
|
212
|
-
return function (i, a) {
|
|
213
|
-
if (o === f) throw Error("Generator is already running");
|
|
214
|
-
if (o === s) {
|
|
215
|
-
if ("throw" === i) throw a;
|
|
216
|
-
return {
|
|
217
|
-
value: t,
|
|
218
|
-
done: !0
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
for (n.method = i, n.arg = a;;) {
|
|
222
|
-
var c = n.delegate;
|
|
223
|
-
if (c) {
|
|
224
|
-
var u = maybeInvokeDelegate(c, n);
|
|
225
|
-
if (u) {
|
|
226
|
-
if (u === y) continue;
|
|
227
|
-
return u;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
231
|
-
if (o === h) throw o = s, n.arg;
|
|
232
|
-
n.dispatchException(n.arg);
|
|
233
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
234
|
-
o = f;
|
|
235
|
-
var p = tryCatch(e, r, n);
|
|
236
|
-
if ("normal" === p.type) {
|
|
237
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
238
|
-
return {
|
|
239
|
-
value: p.arg,
|
|
240
|
-
done: n.done
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
function maybeInvokeDelegate(e, r) {
|
|
248
|
-
var n = r.method,
|
|
249
|
-
o = e.iterator[n];
|
|
250
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
251
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
252
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
253
|
-
var a = i.arg;
|
|
254
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
255
|
-
}
|
|
256
|
-
function pushTryEntry(t) {
|
|
257
|
-
var e = {
|
|
258
|
-
tryLoc: t[0]
|
|
259
|
-
};
|
|
260
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
261
|
-
}
|
|
262
|
-
function resetTryEntry(t) {
|
|
263
|
-
var e = t.completion || {};
|
|
264
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
265
|
-
}
|
|
266
|
-
function Context(t) {
|
|
267
|
-
this.tryEntries = [{
|
|
268
|
-
tryLoc: "root"
|
|
269
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
270
|
-
}
|
|
271
|
-
function values(e) {
|
|
272
|
-
if (e || "" === e) {
|
|
273
|
-
var r = e[a];
|
|
274
|
-
if (r) return r.call(e);
|
|
275
|
-
if ("function" == typeof e.next) return e;
|
|
276
|
-
if (!isNaN(e.length)) {
|
|
277
|
-
var o = -1,
|
|
278
|
-
i = function next() {
|
|
279
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
280
|
-
return next.value = t, next.done = !0, next;
|
|
281
|
-
};
|
|
282
|
-
return i.next = i;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
286
|
-
}
|
|
287
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
288
|
-
value: GeneratorFunctionPrototype,
|
|
289
|
-
configurable: !0
|
|
290
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
291
|
-
value: GeneratorFunction,
|
|
292
|
-
configurable: !0
|
|
293
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
294
|
-
var e = "function" == typeof t && t.constructor;
|
|
295
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
296
|
-
}, e.mark = function (t) {
|
|
297
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
298
|
-
}, e.awrap = function (t) {
|
|
299
|
-
return {
|
|
300
|
-
__await: t
|
|
301
|
-
};
|
|
302
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
303
|
-
return this;
|
|
304
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
305
|
-
void 0 === i && (i = Promise);
|
|
306
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
307
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
308
|
-
return t.done ? t.value : a.next();
|
|
309
|
-
});
|
|
310
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
311
|
-
return this;
|
|
312
|
-
}), define(g, "toString", function () {
|
|
313
|
-
return "[object Generator]";
|
|
314
|
-
}), e.keys = function (t) {
|
|
315
|
-
var e = Object(t),
|
|
316
|
-
r = [];
|
|
317
|
-
for (var n in e) r.push(n);
|
|
318
|
-
return r.reverse(), function next() {
|
|
319
|
-
for (; r.length;) {
|
|
320
|
-
var t = r.pop();
|
|
321
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
322
|
-
}
|
|
323
|
-
return next.done = !0, next;
|
|
324
|
-
};
|
|
325
|
-
}, e.values = values, Context.prototype = {
|
|
326
|
-
constructor: Context,
|
|
327
|
-
reset: function (e) {
|
|
328
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
329
|
-
},
|
|
330
|
-
stop: function () {
|
|
331
|
-
this.done = !0;
|
|
332
|
-
var t = this.tryEntries[0].completion;
|
|
333
|
-
if ("throw" === t.type) throw t.arg;
|
|
334
|
-
return this.rval;
|
|
335
|
-
},
|
|
336
|
-
dispatchException: function (e) {
|
|
337
|
-
if (this.done) throw e;
|
|
338
|
-
var r = this;
|
|
339
|
-
function handle(n, o) {
|
|
340
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
341
|
-
}
|
|
342
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
343
|
-
var i = this.tryEntries[o],
|
|
344
|
-
a = i.completion;
|
|
345
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
346
|
-
if (i.tryLoc <= this.prev) {
|
|
347
|
-
var c = n.call(i, "catchLoc"),
|
|
348
|
-
u = n.call(i, "finallyLoc");
|
|
349
|
-
if (c && u) {
|
|
350
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
351
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
352
|
-
} else if (c) {
|
|
353
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
354
|
-
} else {
|
|
355
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
356
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
abrupt: function (t, e) {
|
|
362
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
363
|
-
var o = this.tryEntries[r];
|
|
364
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
365
|
-
var i = o;
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
370
|
-
var a = i ? i.completion : {};
|
|
371
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
372
|
-
},
|
|
373
|
-
complete: function (t, e) {
|
|
374
|
-
if ("throw" === t.type) throw t.arg;
|
|
375
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
376
|
-
},
|
|
377
|
-
finish: function (t) {
|
|
378
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
379
|
-
var r = this.tryEntries[e];
|
|
380
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
catch: function (t) {
|
|
384
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
385
|
-
var r = this.tryEntries[e];
|
|
386
|
-
if (r.tryLoc === t) {
|
|
387
|
-
var n = r.completion;
|
|
388
|
-
if ("throw" === n.type) {
|
|
389
|
-
var o = n.arg;
|
|
390
|
-
resetTryEntry(r);
|
|
391
|
-
}
|
|
392
|
-
return o;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
throw Error("illegal catch attempt");
|
|
396
|
-
},
|
|
397
|
-
delegateYield: function (e, r, n) {
|
|
398
|
-
return this.delegate = {
|
|
399
|
-
iterator: values(e),
|
|
400
|
-
resultName: r,
|
|
401
|
-
nextLoc: n
|
|
402
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
403
|
-
}
|
|
404
|
-
}, e;
|
|
405
|
-
}
|
|
406
|
-
function _toPrimitive(t, r) {
|
|
407
|
-
if ("object" != typeof t || !t) return t;
|
|
408
|
-
var e = t[Symbol.toPrimitive];
|
|
409
|
-
if (void 0 !== e) {
|
|
410
|
-
var i = e.call(t, r || "default");
|
|
411
|
-
if ("object" != typeof i) return i;
|
|
412
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
413
|
-
}
|
|
414
|
-
return ("string" === r ? String : Number)(t);
|
|
415
|
-
}
|
|
416
|
-
function _toPropertyKey(t) {
|
|
417
|
-
var i = _toPrimitive(t, "string");
|
|
418
|
-
return "symbol" == typeof i ? i : i + "";
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* @license
|
|
423
|
-
* Copyright 2023 Google LLC
|
|
424
|
-
*
|
|
425
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
426
|
-
* you may not use this file except in compliance with the License.
|
|
427
|
-
* You may obtain a copy of the License at
|
|
428
|
-
*
|
|
429
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
430
|
-
*
|
|
431
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
432
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
433
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
434
|
-
* See the License for the specific language governing permissions and
|
|
435
|
-
* limitations under the License.
|
|
436
|
-
*/
|
|
437
|
-
/**
|
|
438
|
-
* A class containing a value that changes with the contrast level.
|
|
439
|
-
*
|
|
440
|
-
* Usually represents the contrast requirements for a dynamic color on its
|
|
441
|
-
* background. The four values correspond to values for contrast levels -1.0,
|
|
442
|
-
* 0.0, 0.5, and 1.0, respectively.
|
|
443
|
-
*/
|
|
444
|
-
var ContrastCurve = /*#__PURE__*/function () {
|
|
445
|
-
/**
|
|
446
|
-
* Creates a `ContrastCurve` object.
|
|
447
|
-
*
|
|
448
|
-
* @param low Value for contrast level -1.0
|
|
449
|
-
* @param normal Value for contrast level 0.0
|
|
450
|
-
* @param medium Value for contrast level 0.5
|
|
451
|
-
* @param high Value for contrast level 1.0
|
|
452
|
-
*/
|
|
453
|
-
function ContrastCurve(low, normal, medium, high) {
|
|
454
|
-
this.low = void 0;
|
|
455
|
-
this.normal = void 0;
|
|
456
|
-
this.medium = void 0;
|
|
457
|
-
this.high = void 0;
|
|
458
|
-
this.low = low;
|
|
459
|
-
this.normal = normal;
|
|
460
|
-
this.medium = medium;
|
|
461
|
-
this.high = high;
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Returns the value at a given contrast level.
|
|
465
|
-
*
|
|
466
|
-
* @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
|
|
467
|
-
* is the lowest; 1.0 is the highest.
|
|
468
|
-
* @return The value. For contrast ratios, a number between 1.0 and 21.0.
|
|
469
|
-
*/
|
|
470
|
-
var _proto = ContrastCurve.prototype;
|
|
471
|
-
_proto.get = function get(contrastLevel) {
|
|
472
|
-
if (contrastLevel <= -1.0) {
|
|
473
|
-
return this.low;
|
|
474
|
-
} else if (contrastLevel < 0.0) {
|
|
475
|
-
return lerp(this.low, this.normal, (contrastLevel - -1) / 1);
|
|
476
|
-
} else if (contrastLevel < 0.5) {
|
|
477
|
-
return lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);
|
|
478
|
-
} else if (contrastLevel < 1.0) {
|
|
479
|
-
return lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);
|
|
480
|
-
} else {
|
|
481
|
-
return this.high;
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
return ContrastCurve;
|
|
485
|
-
}();
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* @license
|
|
489
|
-
* Copyright 2022 Google LLC
|
|
490
|
-
*
|
|
491
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
492
|
-
* you may not use this file except in compliance with the License.
|
|
493
|
-
* You may obtain a copy of the License at
|
|
494
|
-
*
|
|
495
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
496
|
-
*
|
|
497
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
498
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
499
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
500
|
-
* See the License for the specific language governing permissions and
|
|
501
|
-
* limitations under the License.
|
|
502
|
-
*/
|
|
503
|
-
/**
|
|
504
|
-
* A color that adjusts itself based on UI state provided by SchemeEntity.
|
|
505
|
-
*
|
|
506
|
-
* Colors without backgrounds do not change tone when contrast changes. Colors
|
|
507
|
-
* with backgrounds become closer to their background as contrast lowers, and
|
|
508
|
-
* further when contrast increases.
|
|
509
|
-
*
|
|
510
|
-
* Prefer static constructors. They require either a hexcode, a palette and
|
|
511
|
-
* tone, or a hue and chroma. Optionally, they can provide a background
|
|
512
|
-
* DynamicColor.
|
|
513
|
-
*/
|
|
514
|
-
var DynamicColor = /*#__PURE__*/function () {
|
|
515
|
-
/**
|
|
516
|
-
* The base constructor for DynamicColor.
|
|
517
|
-
*
|
|
518
|
-
* _Strongly_ prefer using one of the convenience constructors. This class is
|
|
519
|
-
* arguably too flexible to ensure it can support any scenario. Functional
|
|
520
|
-
* arguments allow overriding without risks that come with subclasses.
|
|
521
|
-
*
|
|
522
|
-
* For example, the default behavior of adjust tone at max contrast
|
|
523
|
-
* to be at a 7.0 ratio with its background is principled and
|
|
524
|
-
* matches accessibility guidance. That does not mean it's the desired
|
|
525
|
-
* approach for _every_ design system, and every color pairing,
|
|
526
|
-
* always, in every case.
|
|
527
|
-
*
|
|
528
|
-
* @param name The name of the dynamic color. Defaults to empty.
|
|
529
|
-
* @param palette Function that provides a TonalPalette given
|
|
530
|
-
* SchemeEntity. A TonalPalette is defined by a hue and chroma, so this
|
|
531
|
-
* replaces the need to specify hue/chroma. By providing a tonal palette, when
|
|
532
|
-
* contrast adjustments are made, intended chroma can be preserved.
|
|
533
|
-
* @param tone Function that provides a tone, given a SchemeEntity.
|
|
534
|
-
* @param isBackground Whether this dynamic color is a background, with
|
|
535
|
-
* some other color as the foreground. Defaults to false.
|
|
536
|
-
* @param background The background of the dynamic color (as a function of a
|
|
537
|
-
* `SchemeEntity`), if it exists.
|
|
538
|
-
* @param secondBackground A second background of the dynamic color (as a
|
|
539
|
-
* function of a `SchemeEntity`), if it
|
|
540
|
-
* exists.
|
|
541
|
-
* @param contrastCurve A `ContrastCurve` object specifying how its contrast
|
|
542
|
-
* against its background should behave in various contrast levels options.
|
|
543
|
-
* @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
|
|
544
|
-
* constraint between two colors. One of them must be the color being
|
|
545
|
-
* constructed.
|
|
546
|
-
*/
|
|
547
|
-
function DynamicColor(name, palette, tone, isBackground, background, secondBackground, contrastCurve, toneDeltaPair) {
|
|
548
|
-
this.name = void 0;
|
|
549
|
-
this.palette = void 0;
|
|
550
|
-
this.tone = void 0;
|
|
551
|
-
this.isBackground = void 0;
|
|
552
|
-
this.background = void 0;
|
|
553
|
-
this.secondBackground = void 0;
|
|
554
|
-
this.contrastCurve = void 0;
|
|
555
|
-
this.toneDeltaPair = void 0;
|
|
556
|
-
this.hctCache = new Map();
|
|
557
|
-
this.name = name;
|
|
558
|
-
this.palette = palette;
|
|
559
|
-
this.tone = tone;
|
|
560
|
-
this.isBackground = isBackground;
|
|
561
|
-
this.background = background;
|
|
562
|
-
this.secondBackground = secondBackground;
|
|
563
|
-
this.contrastCurve = contrastCurve;
|
|
564
|
-
this.toneDeltaPair = toneDeltaPair;
|
|
565
|
-
if (!background && secondBackground) {
|
|
566
|
-
throw new Error("Color " + name + " has secondBackground" + "defined, but background is not defined.");
|
|
567
|
-
}
|
|
568
|
-
if (!background && contrastCurve) {
|
|
569
|
-
throw new Error("Color " + name + " has contrastCurve" + "defined, but background is not defined.");
|
|
570
|
-
}
|
|
571
|
-
if (background && !contrastCurve) {
|
|
572
|
-
throw new Error("Color " + name + " has background" + "defined, but contrastCurve is not defined.");
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Create a DynamicColor defined by a TonalPalette and HCT tone.
|
|
577
|
-
*
|
|
578
|
-
* @param args Functions with SchemeEntity as input. Must provide a palette
|
|
579
|
-
* and tone. May provide a background DynamicColor and ToneDeltaConstraint.
|
|
580
|
-
*/
|
|
581
|
-
DynamicColor.fromPalette = function fromPalette(args) {
|
|
582
|
-
var _args$name, _args$isBackground;
|
|
583
|
-
return new DynamicColor((_args$name = args.name) != null ? _args$name : '', args.palette, args.tone, (_args$isBackground = args.isBackground) != null ? _args$isBackground : false, args.background, args.secondBackground, args.contrastCurve, args.toneDeltaPair);
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Given a background tone, find a foreground tone, while ensuring they reach
|
|
587
|
-
* a contrast ratio that is as close to [ratio] as possible.
|
|
588
|
-
*
|
|
589
|
-
* @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it
|
|
590
|
-
* falls outside that range.
|
|
591
|
-
* @param ratio The contrast ratio desired between bgTone and the return
|
|
592
|
-
* value.
|
|
593
|
-
*/;
|
|
594
|
-
DynamicColor.foregroundTone = function foregroundTone(bgTone, ratio) {
|
|
595
|
-
var lighterTone = Contrast.lighterUnsafe(bgTone, ratio);
|
|
596
|
-
var darkerTone = Contrast.darkerUnsafe(bgTone, ratio);
|
|
597
|
-
var lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone);
|
|
598
|
-
var darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);
|
|
599
|
-
var preferLighter = DynamicColor.tonePrefersLightForeground(bgTone);
|
|
600
|
-
if (preferLighter) {
|
|
601
|
-
// This handles an edge case where the initial contrast ratio is high
|
|
602
|
-
// (ex. 13.0), and the ratio passed to the function is that high
|
|
603
|
-
// ratio, and both the lighter and darker ratio fails to pass that
|
|
604
|
-
// ratio.
|
|
605
|
-
//
|
|
606
|
-
// This was observed with Tonal Spot's On Primary Container turning
|
|
607
|
-
// black momentarily between high and max contrast in light mode. PC's
|
|
608
|
-
// standard tone was T90, OPC's was T10, it was light mode, and the
|
|
609
|
-
// contrast value was 0.6568521221032331.
|
|
610
|
-
var negligibleDifference = Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio && darkerRatio < ratio;
|
|
611
|
-
return lighterRatio >= ratio || lighterRatio >= darkerRatio || negligibleDifference ? lighterTone : darkerTone;
|
|
612
|
-
} else {
|
|
613
|
-
return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone : lighterTone;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* Returns whether [tone] prefers a light foreground.
|
|
618
|
-
*
|
|
619
|
-
* People prefer white foregrounds on ~T60-70. Observed over time, and also
|
|
620
|
-
* by Andrew Somers during research for APCA.
|
|
621
|
-
*
|
|
622
|
-
* T60 used as to create the smallest discontinuity possible when skipping
|
|
623
|
-
* down to T49 in order to ensure light foregrounds.
|
|
624
|
-
* Since `tertiaryContainer` in dark monochrome scheme requires a tone of
|
|
625
|
-
* 60, it should not be adjusted. Therefore, 60 is excluded here.
|
|
626
|
-
*/;
|
|
627
|
-
DynamicColor.tonePrefersLightForeground = function tonePrefersLightForeground(tone) {
|
|
628
|
-
return Math.round(tone) < 60.0;
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
|
|
632
|
-
* color.
|
|
633
|
-
*/;
|
|
634
|
-
DynamicColor.toneAllowsLightForeground = function toneAllowsLightForeground(tone) {
|
|
635
|
-
return Math.round(tone) <= 49.0;
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Adjust a tone such that white has 4.5 contrast, if the tone is
|
|
639
|
-
* reasonably close to supporting it.
|
|
640
|
-
*/;
|
|
641
|
-
DynamicColor.enableLightForeground = function enableLightForeground(tone) {
|
|
642
|
-
if (DynamicColor.tonePrefersLightForeground(tone) && !DynamicColor.toneAllowsLightForeground(tone)) {
|
|
643
|
-
return 49.0;
|
|
644
|
-
}
|
|
645
|
-
return tone;
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Return a ARGB integer (i.e. a hex code).
|
|
649
|
-
*
|
|
650
|
-
* @param scheme Defines the conditions of the user interface, for example,
|
|
651
|
-
* whether or not it is dark mode or light mode, and what the desired
|
|
652
|
-
* contrast level is.
|
|
653
|
-
*/;
|
|
654
|
-
var _proto = DynamicColor.prototype;
|
|
655
|
-
_proto.getArgb = function getArgb(scheme) {
|
|
656
|
-
return this.getHct(scheme).toInt();
|
|
657
|
-
}
|
|
658
|
-
/**
|
|
659
|
-
* Return a color, expressed in the HCT color space, that this
|
|
660
|
-
* DynamicColor is under the conditions in scheme.
|
|
661
|
-
*
|
|
662
|
-
* @param scheme Defines the conditions of the user interface, for example,
|
|
663
|
-
* whether or not it is dark mode or light mode, and what the desired
|
|
664
|
-
* contrast level is.
|
|
665
|
-
*/;
|
|
666
|
-
_proto.getHct = function getHct(scheme) {
|
|
667
|
-
var cachedAnswer = this.hctCache.get(scheme);
|
|
668
|
-
if (cachedAnswer != null) {
|
|
669
|
-
return cachedAnswer;
|
|
670
|
-
}
|
|
671
|
-
var tone = this.getTone(scheme);
|
|
672
|
-
var answer = this.palette(scheme).getHct(tone);
|
|
673
|
-
if (this.hctCache.size > 4) {
|
|
674
|
-
this.hctCache.clear();
|
|
675
|
-
}
|
|
676
|
-
this.hctCache.set(scheme, answer);
|
|
677
|
-
return answer;
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Return a tone, T in the HCT color space, that this DynamicColor is under
|
|
681
|
-
* the conditions in scheme.
|
|
682
|
-
*
|
|
683
|
-
* @param scheme Defines the conditions of the user interface, for example,
|
|
684
|
-
* whether or not it is dark mode or light mode, and what the desired
|
|
685
|
-
* contrast level is.
|
|
686
|
-
*/;
|
|
687
|
-
_proto.getTone = function getTone(scheme) {
|
|
688
|
-
var decreasingContrast = scheme.contrastLevel < 0;
|
|
689
|
-
// Case 1: dual foreground, pair of colors with delta constraint.
|
|
690
|
-
if (this.toneDeltaPair) {
|
|
691
|
-
var toneDeltaPair = this.toneDeltaPair(scheme);
|
|
692
|
-
var roleA = toneDeltaPair.roleA;
|
|
693
|
-
var roleB = toneDeltaPair.roleB;
|
|
694
|
-
var delta = toneDeltaPair.delta;
|
|
695
|
-
var polarity = toneDeltaPair.polarity;
|
|
696
|
-
var stayTogether = toneDeltaPair.stayTogether;
|
|
697
|
-
var bg = this.background(scheme);
|
|
698
|
-
var bgTone = bg.getTone(scheme);
|
|
699
|
-
var aIsNearer = polarity === 'nearer' || polarity === 'lighter' && !scheme.isDark || polarity === 'darker' && scheme.isDark;
|
|
700
|
-
var nearer = aIsNearer ? roleA : roleB;
|
|
701
|
-
var farther = aIsNearer ? roleB : roleA;
|
|
702
|
-
var amNearer = this.name === nearer.name;
|
|
703
|
-
var expansionDir = scheme.isDark ? 1 : -1;
|
|
704
|
-
// 1st round: solve to min, each
|
|
705
|
-
var nContrast = nearer.contrastCurve.get(scheme.contrastLevel);
|
|
706
|
-
var fContrast = farther.contrastCurve.get(scheme.contrastLevel);
|
|
707
|
-
// If a color is good enough, it is not adjusted.
|
|
708
|
-
// Initial and adjusted tones for `nearer`
|
|
709
|
-
var nInitialTone = nearer.tone(scheme);
|
|
710
|
-
var nTone = Contrast.ratioOfTones(bgTone, nInitialTone) >= nContrast ? nInitialTone : DynamicColor.foregroundTone(bgTone, nContrast);
|
|
711
|
-
// Initial and adjusted tones for `farther`
|
|
712
|
-
var fInitialTone = farther.tone(scheme);
|
|
713
|
-
var fTone = Contrast.ratioOfTones(bgTone, fInitialTone) >= fContrast ? fInitialTone : DynamicColor.foregroundTone(bgTone, fContrast);
|
|
714
|
-
if (decreasingContrast) {
|
|
715
|
-
// If decreasing contrast, adjust color to the "bare minimum"
|
|
716
|
-
// that satisfies contrast.
|
|
717
|
-
nTone = DynamicColor.foregroundTone(bgTone, nContrast);
|
|
718
|
-
fTone = DynamicColor.foregroundTone(bgTone, fContrast);
|
|
719
|
-
}
|
|
720
|
-
if ((fTone - nTone) * expansionDir >= delta) ; else {
|
|
721
|
-
// 2nd round: expand farther to match delta.
|
|
722
|
-
fTone = clampDouble(0, 100, nTone + delta * expansionDir);
|
|
723
|
-
if ((fTone - nTone) * expansionDir >= delta) ; else {
|
|
724
|
-
// 3rd round: contract nearer to match delta.
|
|
725
|
-
nTone = clampDouble(0, 100, fTone - delta * expansionDir);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
// Avoids the 50-59 awkward zone.
|
|
729
|
-
if (50 <= nTone && nTone < 60) {
|
|
730
|
-
// If `nearer` is in the awkward zone, move it away, together with
|
|
731
|
-
// `farther`.
|
|
732
|
-
if (expansionDir > 0) {
|
|
733
|
-
nTone = 60;
|
|
734
|
-
fTone = Math.max(fTone, nTone + delta * expansionDir);
|
|
735
|
-
} else {
|
|
736
|
-
nTone = 49;
|
|
737
|
-
fTone = Math.min(fTone, nTone + delta * expansionDir);
|
|
738
|
-
}
|
|
739
|
-
} else if (50 <= fTone && fTone < 60) {
|
|
740
|
-
if (stayTogether) {
|
|
741
|
-
// Fixes both, to avoid two colors on opposite sides of the "awkward
|
|
742
|
-
// zone".
|
|
743
|
-
if (expansionDir > 0) {
|
|
744
|
-
nTone = 60;
|
|
745
|
-
fTone = Math.max(fTone, nTone + delta * expansionDir);
|
|
746
|
-
} else {
|
|
747
|
-
nTone = 49;
|
|
748
|
-
fTone = Math.min(fTone, nTone + delta * expansionDir);
|
|
749
|
-
}
|
|
750
|
-
} else {
|
|
751
|
-
// Not required to stay together; fixes just one.
|
|
752
|
-
if (expansionDir > 0) {
|
|
753
|
-
fTone = 60;
|
|
754
|
-
} else {
|
|
755
|
-
fTone = 49;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
// Returns `nTone` if this color is `nearer`, otherwise `fTone`.
|
|
760
|
-
return amNearer ? nTone : fTone;
|
|
761
|
-
} else {
|
|
762
|
-
// Case 2: No contrast pair; just solve for itself.
|
|
763
|
-
var answer = this.tone(scheme);
|
|
764
|
-
if (this.background == null) {
|
|
765
|
-
return answer; // No adjustment for colors with no background.
|
|
766
|
-
}
|
|
767
|
-
var _bgTone = this.background(scheme).getTone(scheme);
|
|
768
|
-
var desiredRatio = this.contrastCurve.get(scheme.contrastLevel);
|
|
769
|
-
if (Contrast.ratioOfTones(_bgTone, answer) >= desiredRatio) ; else {
|
|
770
|
-
// Rough improvement.
|
|
771
|
-
answer = DynamicColor.foregroundTone(_bgTone, desiredRatio);
|
|
772
|
-
}
|
|
773
|
-
if (decreasingContrast) {
|
|
774
|
-
answer = DynamicColor.foregroundTone(_bgTone, desiredRatio);
|
|
775
|
-
}
|
|
776
|
-
if (this.isBackground && 50 <= answer && answer < 60) {
|
|
777
|
-
// Must adjust
|
|
778
|
-
if (Contrast.ratioOfTones(49, _bgTone) >= desiredRatio) {
|
|
779
|
-
answer = 49;
|
|
780
|
-
} else {
|
|
781
|
-
answer = 60;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
if (this.secondBackground) {
|
|
785
|
-
// Case 3: Adjust for dual backgrounds.
|
|
786
|
-
var _ref = [this.background, this.secondBackground],
|
|
787
|
-
bg1 = _ref[0],
|
|
788
|
-
bg2 = _ref[1];
|
|
789
|
-
var _ref2 = [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)],
|
|
790
|
-
bgTone1 = _ref2[0],
|
|
791
|
-
bgTone2 = _ref2[1];
|
|
792
|
-
var _ref3 = [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)],
|
|
793
|
-
upper = _ref3[0],
|
|
794
|
-
lower = _ref3[1];
|
|
795
|
-
if (Contrast.ratioOfTones(upper, answer) >= desiredRatio && Contrast.ratioOfTones(lower, answer) >= desiredRatio) {
|
|
796
|
-
return answer;
|
|
797
|
-
}
|
|
798
|
-
// The darkest light tone that satisfies the desired ratio,
|
|
799
|
-
// or -1 if such ratio cannot be reached.
|
|
800
|
-
var lightOption = Contrast.lighter(upper, desiredRatio);
|
|
801
|
-
// The lightest dark tone that satisfies the desired ratio,
|
|
802
|
-
// or -1 if such ratio cannot be reached.
|
|
803
|
-
var darkOption = Contrast.darker(lower, desiredRatio);
|
|
804
|
-
// Tones suitable for the foreground.
|
|
805
|
-
var availables = [];
|
|
806
|
-
if (lightOption !== -1) availables.push(lightOption);
|
|
807
|
-
if (darkOption !== -1) availables.push(darkOption);
|
|
808
|
-
var prefersLight = DynamicColor.tonePrefersLightForeground(bgTone1) || DynamicColor.tonePrefersLightForeground(bgTone2);
|
|
809
|
-
if (prefersLight) {
|
|
810
|
-
return lightOption < 0 ? 100 : lightOption;
|
|
811
|
-
}
|
|
812
|
-
if (availables.length === 1) {
|
|
813
|
-
return availables[0];
|
|
814
|
-
}
|
|
815
|
-
return darkOption < 0 ? 0 : darkOption;
|
|
816
|
-
}
|
|
817
|
-
return answer;
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
return DynamicColor;
|
|
821
|
-
}();
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* @license
|
|
825
|
-
* Copyright 2023 Google LLC
|
|
826
|
-
*
|
|
827
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
828
|
-
* you may not use this file except in compliance with the License.
|
|
829
|
-
* You may obtain a copy of the License at
|
|
830
|
-
*
|
|
831
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
832
|
-
*
|
|
833
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
834
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
835
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
836
|
-
* See the License for the specific language governing permissions and
|
|
837
|
-
* limitations under the License.
|
|
838
|
-
*/
|
|
839
|
-
/**
|
|
840
|
-
* Documents a constraint between two DynamicColors, in which their tones must
|
|
841
|
-
* have a certain distance from each other.
|
|
842
|
-
*
|
|
843
|
-
* Prefer a DynamicColor with a background, this is for special cases when
|
|
844
|
-
* designers want tonal distance, literally contrast, between two colors that
|
|
845
|
-
* don't have a background / foreground relationship or a contrast guarantee.
|
|
846
|
-
*/
|
|
847
|
-
var ToneDeltaPair =
|
|
848
|
-
/**
|
|
849
|
-
* Documents a constraint in tone distance between two DynamicColors.
|
|
850
|
-
*
|
|
851
|
-
* The polarity is an adjective that describes "A", compared to "B".
|
|
852
|
-
*
|
|
853
|
-
* For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
|
|
854
|
-
* A's tone should be at least 15 darker than B's.
|
|
855
|
-
*
|
|
856
|
-
* 'nearer' and 'farther' describes closeness to the surface roles. For
|
|
857
|
-
* instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
|
|
858
|
-
* should be 10 lighter than B in light mode, and 10 darker than B in dark
|
|
859
|
-
* mode.
|
|
860
|
-
*
|
|
861
|
-
* @param roleA The first role in a pair.
|
|
862
|
-
* @param roleB The second role in a pair.
|
|
863
|
-
* @param delta Required difference between tones. Absolute value, negative
|
|
864
|
-
* values have undefined behavior.
|
|
865
|
-
* @param polarity The relative relation between tones of roleA and roleB,
|
|
866
|
-
* as described above.
|
|
867
|
-
* @param stayTogether Whether these two roles should stay on the same side of
|
|
868
|
-
* the "awkward zone" (T50-59). This is necessary for certain cases where
|
|
869
|
-
* one role has two backgrounds.
|
|
870
|
-
*/
|
|
871
|
-
function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
|
|
872
|
-
this.roleA = void 0;
|
|
873
|
-
this.roleB = void 0;
|
|
874
|
-
this.delta = void 0;
|
|
875
|
-
this.polarity = void 0;
|
|
876
|
-
this.stayTogether = void 0;
|
|
877
|
-
this.roleA = roleA;
|
|
878
|
-
this.roleB = roleB;
|
|
879
|
-
this.delta = delta;
|
|
880
|
-
this.polarity = polarity;
|
|
881
|
-
this.stayTogether = stayTogether;
|
|
882
|
-
};
|
|
883
|
-
|
|
884
|
-
function argbToRgb(argb) {
|
|
885
|
-
return {
|
|
886
|
-
r: argb >> 16 & 0xff,
|
|
887
|
-
g: argb >> 8 & 0xff,
|
|
888
|
-
b: argb & 0xff
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
|
-
var ColorEntity = /*#__PURE__*/function () {
|
|
892
|
-
function ColorEntity(option, schemeService, colorService) {
|
|
893
|
-
this.option = void 0;
|
|
894
|
-
this.schemeService = void 0;
|
|
895
|
-
this.colorService = void 0;
|
|
896
|
-
this.dynamicColor = null;
|
|
897
|
-
this.option = option;
|
|
898
|
-
this.schemeService = schemeService;
|
|
899
|
-
this.colorService = colorService;
|
|
900
|
-
}
|
|
901
|
-
var _proto = ColorEntity.prototype;
|
|
902
|
-
_proto.update = function update(args) {
|
|
903
|
-
this.dynamicColor = null;
|
|
904
|
-
this.option = _extends({}, this.option, args);
|
|
905
|
-
};
|
|
906
|
-
_proto.getHex = function getHex() {
|
|
907
|
-
return hexFromArgb(this.getArgb());
|
|
908
|
-
};
|
|
909
|
-
_proto.getArgb = function getArgb() {
|
|
910
|
-
return this.getDynamicColor().getArgb(this.schemeService.get());
|
|
911
|
-
};
|
|
912
|
-
_proto.getRgb = function getRgb() {
|
|
913
|
-
return argbToRgb(this.getArgb());
|
|
914
|
-
};
|
|
915
|
-
_proto.getName = function getName() {
|
|
916
|
-
return this.option.name.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
917
|
-
};
|
|
918
|
-
_proto.getDynamicColor = function getDynamicColor() {
|
|
919
|
-
if (!this.dynamicColor) {
|
|
920
|
-
this.dynamicColor = DynamicColor.fromPalette(_extends({}, this.option, {
|
|
921
|
-
name: this.getName()
|
|
922
|
-
}));
|
|
923
|
-
}
|
|
924
|
-
return this.dynamicColor;
|
|
925
|
-
};
|
|
926
|
-
return ColorEntity;
|
|
927
|
-
}();
|
|
928
|
-
|
|
929
|
-
function capitalizeFirstLetter(string) {
|
|
930
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
931
|
-
}
|
|
932
|
-
var highestSurface = function highestSurface(s, colorService) {
|
|
933
|
-
if (colorService instanceof ColorService) {
|
|
934
|
-
return s.isDark ? colorService.getColor('surfaceBright').getDynamicColor() : colorService.getColor('surfaceDim').getDynamicColor();
|
|
935
|
-
} else {
|
|
936
|
-
return s.isDark ? colorService.get('surfaceBright').getDynamicColor() : colorService.get('surfaceDim').getDynamicColor();
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
var ColorManagerService = /*#__PURE__*/function () {
|
|
940
|
-
function ColorManagerService(_ref) {
|
|
941
|
-
var schemeService = _ref.schemeService;
|
|
942
|
-
this.colorMap = new Map();
|
|
943
|
-
this.schemeService = void 0;
|
|
944
|
-
this.schemeService = schemeService;
|
|
945
|
-
}
|
|
946
|
-
var _proto = ColorManagerService.prototype;
|
|
947
|
-
_proto.createOrUpdate = function createOrUpdate(key, args) {
|
|
948
|
-
var colorEntity = this.colorMap.get(key);
|
|
949
|
-
if (!colorEntity) {
|
|
950
|
-
var palette = args.palette,
|
|
951
|
-
tone = args.tone;
|
|
952
|
-
if (palette && tone) {
|
|
953
|
-
colorEntity = new ColorEntity(_extends({}, args, {
|
|
954
|
-
palette: palette,
|
|
955
|
-
tone: tone,
|
|
956
|
-
name: key
|
|
957
|
-
}), this.schemeService, this);
|
|
958
|
-
this.colorMap.set(key, colorEntity);
|
|
959
|
-
} else {
|
|
960
|
-
throw new Error("Palette " + key + " does not exist");
|
|
961
|
-
}
|
|
962
|
-
} else {
|
|
963
|
-
colorEntity.update(_extends({}, args, {
|
|
964
|
-
name: key
|
|
965
|
-
}));
|
|
966
|
-
this.colorMap.set(key, colorEntity);
|
|
967
|
-
}
|
|
968
|
-
return colorEntity;
|
|
969
|
-
};
|
|
970
|
-
_proto.remove = function remove(key) {
|
|
971
|
-
return this.colorMap["delete"](key);
|
|
972
|
-
};
|
|
973
|
-
_proto.get = function get(key) {
|
|
974
|
-
var colorEntity = this.colorMap.get(key);
|
|
975
|
-
if (colorEntity) {
|
|
976
|
-
return colorEntity;
|
|
977
|
-
} else {
|
|
978
|
-
throw new Error("Color " + key + " does not exist");
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
_proto.getAll = function getAll() {
|
|
982
|
-
return this.colorMap;
|
|
983
|
-
};
|
|
984
|
-
_proto.addFromPalette = function addFromPalette(key) {
|
|
985
|
-
var _this = this;
|
|
986
|
-
var colorKey = key;
|
|
987
|
-
var ColorKey = capitalizeFirstLetter(key);
|
|
988
|
-
var onColorKey = 'on' + ColorKey;
|
|
989
|
-
var colorKeyContainer = colorKey + 'Container';
|
|
990
|
-
var onColorKeyContainer = 'on' + ColorKey + 'Container';
|
|
991
|
-
var inverseColorKey = 'inverse' + ColorKey;
|
|
992
|
-
var colorKeyFixed = colorKey + 'Fixed';
|
|
993
|
-
var colorKeyFixedDim = colorKey + 'FixedDim';
|
|
994
|
-
var onColorKeyFixed = 'on' + ColorKey + 'Fixed';
|
|
995
|
-
var onColorKeyFixedVariant = 'on' + ColorKey + 'FixedVariant';
|
|
996
|
-
this.createOrUpdate(colorKey, {
|
|
997
|
-
palette: function palette(s) {
|
|
998
|
-
return s.getPalette(key);
|
|
999
|
-
},
|
|
1000
|
-
tone: function tone(s) {
|
|
1001
|
-
return s.isDark ? 80 : 40;
|
|
1002
|
-
},
|
|
1003
|
-
isBackground: true,
|
|
1004
|
-
background: function background(s) {
|
|
1005
|
-
return highestSurface(s, _this);
|
|
1006
|
-
},
|
|
1007
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1008
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1009
|
-
return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 15, 'nearer', false);
|
|
1010
|
-
}
|
|
1011
|
-
});
|
|
1012
|
-
this.createOrUpdate(onColorKey, {
|
|
1013
|
-
palette: function palette(s) {
|
|
1014
|
-
return s.getPalette(key);
|
|
1015
|
-
},
|
|
1016
|
-
tone: function tone(s) {
|
|
1017
|
-
return s.isDark ? 20 : 100;
|
|
1018
|
-
},
|
|
1019
|
-
background: function background(s) {
|
|
1020
|
-
return _this.get(colorKey).getDynamicColor();
|
|
1021
|
-
},
|
|
1022
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1023
|
-
});
|
|
1024
|
-
this.createOrUpdate(colorKeyContainer, {
|
|
1025
|
-
palette: function palette(s) {
|
|
1026
|
-
return s.getPalette(key);
|
|
1027
|
-
},
|
|
1028
|
-
tone: function tone(s) {
|
|
1029
|
-
return s.isDark ? 30 : 90;
|
|
1030
|
-
},
|
|
1031
|
-
isBackground: true,
|
|
1032
|
-
background: function background(s) {
|
|
1033
|
-
return highestSurface(s, _this);
|
|
1034
|
-
},
|
|
1035
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1036
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1037
|
-
return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 15, 'nearer', false);
|
|
1038
|
-
}
|
|
1039
|
-
});
|
|
1040
|
-
this.createOrUpdate(onColorKeyContainer, {
|
|
1041
|
-
palette: function palette(s) {
|
|
1042
|
-
return s.getPalette(key);
|
|
1043
|
-
},
|
|
1044
|
-
tone: function tone(s) {
|
|
1045
|
-
return s.isDark ? 90 : 10;
|
|
1046
|
-
},
|
|
1047
|
-
background: function background(s) {
|
|
1048
|
-
return _this.get(colorKeyContainer).getDynamicColor();
|
|
1049
|
-
},
|
|
1050
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1051
|
-
});
|
|
1052
|
-
this.createOrUpdate(inverseColorKey, {
|
|
1053
|
-
palette: function palette(s) {
|
|
1054
|
-
return s.getPalette(key);
|
|
1055
|
-
},
|
|
1056
|
-
tone: function tone(s) {
|
|
1057
|
-
return s.isDark ? 40 : 80;
|
|
1058
|
-
},
|
|
1059
|
-
background: function background(s) {
|
|
1060
|
-
return _this.get('inverseSurface').getDynamicColor();
|
|
1061
|
-
},
|
|
1062
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1063
|
-
});
|
|
1064
|
-
this.createOrUpdate(colorKeyFixed, {
|
|
1065
|
-
palette: function palette(s) {
|
|
1066
|
-
return s.getPalette(key);
|
|
1067
|
-
},
|
|
1068
|
-
tone: function tone(s) {
|
|
1069
|
-
return 90.0;
|
|
1070
|
-
},
|
|
1071
|
-
isBackground: true,
|
|
1072
|
-
background: function background(s) {
|
|
1073
|
-
return highestSurface(s, _this);
|
|
1074
|
-
},
|
|
1075
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1076
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1077
|
-
return new ToneDeltaPair(_this.get(colorKeyFixed).getDynamicColor(), _this.get(colorKeyFixedDim).getDynamicColor(), 10, 'lighter', true);
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1080
|
-
this.createOrUpdate(colorKeyFixedDim, {
|
|
1081
|
-
palette: function palette(s) {
|
|
1082
|
-
return s.getPalette(key);
|
|
1083
|
-
},
|
|
1084
|
-
tone: function tone(s) {
|
|
1085
|
-
return 80.0;
|
|
1086
|
-
},
|
|
1087
|
-
isBackground: true,
|
|
1088
|
-
background: function background(s) {
|
|
1089
|
-
return highestSurface(s, _this);
|
|
1090
|
-
},
|
|
1091
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1092
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1093
|
-
return new ToneDeltaPair(_this.get(colorKeyFixed).getDynamicColor(), _this.get(colorKeyFixedDim).getDynamicColor(), 10, 'lighter', true);
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
this.createOrUpdate(onColorKeyFixed, {
|
|
1097
|
-
palette: function palette(s) {
|
|
1098
|
-
return s.getPalette(key);
|
|
1099
|
-
},
|
|
1100
|
-
tone: function tone(s) {
|
|
1101
|
-
return 10.0;
|
|
1102
|
-
},
|
|
1103
|
-
background: function background(s) {
|
|
1104
|
-
return _this.get(colorKeyFixedDim).getDynamicColor();
|
|
1105
|
-
},
|
|
1106
|
-
secondBackground: function secondBackground(s) {
|
|
1107
|
-
return _this.get(colorKeyFixed).getDynamicColor();
|
|
1108
|
-
},
|
|
1109
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1110
|
-
});
|
|
1111
|
-
this.createOrUpdate(onColorKeyFixedVariant, {
|
|
1112
|
-
palette: function palette(s) {
|
|
1113
|
-
return s.getPalette(key);
|
|
1114
|
-
},
|
|
1115
|
-
tone: function tone(s) {
|
|
1116
|
-
return 30.0;
|
|
1117
|
-
},
|
|
1118
|
-
background: function background(s) {
|
|
1119
|
-
return _this.get(colorKeyFixedDim).getDynamicColor();
|
|
1120
|
-
},
|
|
1121
|
-
secondBackground: function secondBackground(s) {
|
|
1122
|
-
return _this.get(colorKeyFixed).getDynamicColor();
|
|
1123
|
-
},
|
|
1124
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1125
|
-
});
|
|
1126
|
-
};
|
|
1127
|
-
return ColorManagerService;
|
|
1128
|
-
}();
|
|
1129
|
-
|
|
1130
|
-
var ColorModule = {
|
|
1131
|
-
colorManagerService: /*#__PURE__*/asClass(ColorManagerService).singleton(),
|
|
1132
|
-
colorService: /*#__PURE__*/asClass(ColorService).singleton()
|
|
1133
|
-
};
|
|
1134
|
-
|
|
1135
|
-
var SchemeEntity = /*#__PURE__*/function () {
|
|
1136
|
-
function SchemeEntity(options) {
|
|
1137
|
-
this.options = void 0;
|
|
1138
|
-
this.options = options;
|
|
1139
|
-
}
|
|
1140
|
-
var _proto = SchemeEntity.prototype;
|
|
1141
|
-
_proto.getPalette = function getPalette(key) {
|
|
1142
|
-
if (!this.options) {
|
|
1143
|
-
throw new Error('Scheme options is not set');
|
|
1144
|
-
}
|
|
1145
|
-
var palette = this.options.palettes.get(key);
|
|
1146
|
-
if (!palette) {
|
|
1147
|
-
throw new Error("Palette " + key + " not found");
|
|
1148
|
-
}
|
|
1149
|
-
return palette;
|
|
1150
|
-
};
|
|
1151
|
-
return _createClass(SchemeEntity, [{
|
|
1152
|
-
key: "contrastLevel",
|
|
1153
|
-
get: function get() {
|
|
1154
|
-
if (!this.options) {
|
|
1155
|
-
throw new Error('Scheme options is not set');
|
|
1156
|
-
}
|
|
1157
|
-
return this.options.contrastLevel;
|
|
1158
|
-
}
|
|
1159
|
-
}, {
|
|
1160
|
-
key: "isDark",
|
|
1161
|
-
get: function get() {
|
|
1162
|
-
if (!this.options) {
|
|
1163
|
-
throw new Error('Scheme options is not set');
|
|
1164
|
-
}
|
|
1165
|
-
return this.options.isDark;
|
|
1166
|
-
}
|
|
1167
|
-
}, {
|
|
1168
|
-
key: "sourceColorHct",
|
|
1169
|
-
get: function get() {
|
|
1170
|
-
if (!this.options) {
|
|
1171
|
-
throw new Error('Scheme options is not set');
|
|
1172
|
-
}
|
|
1173
|
-
return Hct.fromInt(this.options.sourceColorArgb);
|
|
1174
|
-
}
|
|
1175
|
-
}]);
|
|
1176
|
-
}();
|
|
1177
|
-
|
|
1178
|
-
var SchemeService = /*#__PURE__*/function () {
|
|
1179
|
-
function SchemeService() {
|
|
1180
|
-
this.schemeEntity = void 0;
|
|
1181
|
-
this.options = void 0;
|
|
1182
|
-
}
|
|
1183
|
-
var _proto = SchemeService.prototype;
|
|
1184
|
-
_proto.createOrUpdate = function createOrUpdate(options) {
|
|
1185
|
-
var _this$options, _this$options2;
|
|
1186
|
-
this.options = _extends({}, this.options, options, {
|
|
1187
|
-
sourcesColorHex: _extends({}, (_this$options = this.options) == null ? void 0 : _this$options.sourcesColorHex, options.sourcesColorHex),
|
|
1188
|
-
palettes: _extends({}, (_this$options2 = this.options) == null ? void 0 : _this$options2.palettes, options.palettes)
|
|
1189
|
-
});
|
|
1190
|
-
var palettes = new Map();
|
|
1191
|
-
if (!this.options.sourcesColorHex.primary) {
|
|
1192
|
-
throw new Error('Primary source color is not set');
|
|
1193
|
-
}
|
|
1194
|
-
var sourceColorArgb = argbFromHex(this.options.sourcesColorHex.primary);
|
|
1195
|
-
var sourceColorHct = Hct.fromInt(sourceColorArgb);
|
|
1196
|
-
if (!this.options.palettes) {
|
|
1197
|
-
return;
|
|
1198
|
-
}
|
|
1199
|
-
for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
|
|
1200
|
-
var _Object$entries$_i = _Object$entries[_i],
|
|
1201
|
-
key = _Object$entries$_i[0],
|
|
1202
|
-
_Object$entries$_i$ = _Object$entries$_i[1],
|
|
1203
|
-
sourceColorkey = _Object$entries$_i$.sourceColorkey,
|
|
1204
|
-
paletteFunction = _Object$entries$_i$.tonalPalette;
|
|
1205
|
-
var palette = void 0;
|
|
1206
|
-
if (!sourceColorkey) {
|
|
1207
|
-
palette = paletteFunction(sourceColorHct);
|
|
1208
|
-
} else {
|
|
1209
|
-
var _sourceColorArgb = argbFromHex(this.options.sourcesColorHex[sourceColorkey]);
|
|
1210
|
-
var _sourceColorHct = Hct.fromInt(_sourceColorArgb);
|
|
1211
|
-
palette = paletteFunction(_sourceColorHct);
|
|
1212
|
-
}
|
|
1213
|
-
palettes.set(key, palette);
|
|
1214
|
-
}
|
|
1215
|
-
this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
|
|
1216
|
-
palettes: palettes,
|
|
1217
|
-
sourceColorArgb: sourceColorArgb
|
|
1218
|
-
}));
|
|
1219
|
-
};
|
|
1220
|
-
_proto.get = function get() {
|
|
1221
|
-
if (!this.schemeEntity) {
|
|
1222
|
-
throw new Error('Scheme is not created');
|
|
1223
|
-
}
|
|
1224
|
-
return this.schemeEntity;
|
|
1225
|
-
};
|
|
1226
|
-
return SchemeService;
|
|
1227
|
-
}();
|
|
1228
|
-
|
|
1229
|
-
var ThemeService = /*#__PURE__*/function () {
|
|
1230
|
-
function ThemeService(_ref) {
|
|
1231
|
-
var schemeService = _ref.schemeService,
|
|
1232
|
-
variantService = _ref.variantService;
|
|
1233
|
-
this.schemeService = void 0;
|
|
1234
|
-
this.variantService = void 0;
|
|
1235
|
-
this.schemeService = schemeService;
|
|
1236
|
-
this.variantService = variantService;
|
|
1237
|
-
// this.addPalette({key: "primary", addDefaultColors: true})
|
|
1238
|
-
// this.addPalette({key: "secondary", addDefaultColors: true})
|
|
1239
|
-
// this.addPalette({key: "tertiary", addDefaultColors: true})
|
|
1240
|
-
// this.addPalette({key: "error", palette: TonalPalette.fromHueAndChroma(25.0, 84.0)})
|
|
1241
|
-
// this.addPalette({key: "neutral"})
|
|
1242
|
-
// this.addPalette({key: "neutralVariant"})
|
|
1243
|
-
}
|
|
1244
|
-
// addPalette({key, palette, addDefaultColors}: {key: string; palette: TonalPalette; addDefaultColors: boolean}) {
|
|
1245
|
-
// this.themeOptions.palettes.set(key, palette);
|
|
1246
|
-
// if (addDefaultColors){
|
|
1247
|
-
// this.colorService.addPalette(key)
|
|
1248
|
-
// }
|
|
1249
|
-
// }
|
|
1250
|
-
// create(args: ThemeOptions): SchemeService {
|
|
1251
|
-
// return new SchemeService(args, this.colorService)
|
|
1252
|
-
// }
|
|
1253
|
-
//
|
|
1254
|
-
// update(options: Partial<ThemeOptions>): SchemeService {
|
|
1255
|
-
// Object.assign(this.themeOptions, options);
|
|
1256
|
-
// return this.theme();
|
|
1257
|
-
// }
|
|
1258
|
-
var _proto = ThemeService.prototype;
|
|
1259
|
-
_proto.create = function create(options) {
|
|
1260
|
-
this.schemeService.createOrUpdate(_extends({}, options, {
|
|
1261
|
-
sourcesColorHex: {
|
|
1262
|
-
primary: options.sourceColorHex
|
|
1263
|
-
}
|
|
1264
|
-
}));
|
|
1265
|
-
this.variantService.set(options.variant);
|
|
1266
|
-
};
|
|
1267
|
-
_proto.update = function update(options) {
|
|
1268
|
-
var themeOptions = _extends({}, options);
|
|
1269
|
-
if (options.sourceColorHex) themeOptions.sourcesColorHex = {
|
|
1270
|
-
primary: options.sourceColorHex
|
|
1271
|
-
};
|
|
1272
|
-
this.schemeService.createOrUpdate(themeOptions);
|
|
1273
|
-
if (options.variant) this.variantService.set(options.variant);
|
|
1274
|
-
};
|
|
1275
|
-
_proto.addCustomPalette = function addCustomPalette(key, colorHex) {
|
|
1276
|
-
this.variantService.addCustomPalette(key, colorHex);
|
|
1277
|
-
};
|
|
1278
|
-
return ThemeService;
|
|
1279
|
-
}();
|
|
1280
|
-
|
|
1281
|
-
var VariantService = /*#__PURE__*/function () {
|
|
1282
|
-
function VariantService(_ref) {
|
|
1283
|
-
var schemeService = _ref.schemeService;
|
|
1284
|
-
this.customPalettes = {};
|
|
1285
|
-
this.variantEntity = void 0;
|
|
1286
|
-
this.schemeService = void 0;
|
|
1287
|
-
this.schemeService = schemeService;
|
|
1288
|
-
}
|
|
1289
|
-
var _proto = VariantService.prototype;
|
|
1290
|
-
_proto.addCustomPalette = function addCustomPalette(key, colorHex) {
|
|
1291
|
-
this.customPalettes[key] = colorHex;
|
|
1292
|
-
this.update();
|
|
1293
|
-
};
|
|
1294
|
-
_proto.set = function set(variantEntity) {
|
|
1295
|
-
this.variantEntity = variantEntity;
|
|
1296
|
-
if (!variantEntity.palettes.error) {
|
|
1297
|
-
variantEntity.palettes.error = function () {
|
|
1298
|
-
return TonalPalette.fromHueAndChroma(25.0, 84.0);
|
|
1299
|
-
};
|
|
1300
|
-
}
|
|
1301
|
-
this.update();
|
|
1302
|
-
};
|
|
1303
|
-
_proto.update = function update() {
|
|
1304
|
-
var _this = this;
|
|
1305
|
-
if (!this.variantEntity) return;
|
|
1306
|
-
var palettes = {};
|
|
1307
|
-
Object.keys(this.variantEntity.palettes).forEach(function (key) {
|
|
1308
|
-
palettes[key] = {
|
|
1309
|
-
tonalPalette: _this.variantEntity.palettes[key]
|
|
1310
|
-
};
|
|
1311
|
-
});
|
|
1312
|
-
if (this.variantEntity.customPalettes) {
|
|
1313
|
-
Object.keys(this.customPalettes).forEach(function (key) {
|
|
1314
|
-
palettes[key] = {
|
|
1315
|
-
sourceColorkey: key,
|
|
1316
|
-
tonalPalette: _this.variantEntity.customPalettes
|
|
1317
|
-
};
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
this.schemeService.createOrUpdate({
|
|
1321
|
-
sourcesColorHex: this.customPalettes,
|
|
1322
|
-
palettes: palettes
|
|
1323
|
-
});
|
|
1324
|
-
};
|
|
1325
|
-
return VariantService;
|
|
1326
|
-
}();
|
|
1327
|
-
|
|
1328
|
-
var ThemeModule = {
|
|
1329
|
-
schemeService: /*#__PURE__*/asClass(SchemeService).singleton(),
|
|
1330
|
-
variantService: /*#__PURE__*/asClass(VariantService).singleton(),
|
|
1331
|
-
themeService: /*#__PURE__*/asClass(ThemeService).singleton()
|
|
1332
|
-
};
|
|
1333
|
-
|
|
1334
|
-
var AppService = function AppService(_ref) {
|
|
1335
|
-
var colorService = _ref.colorService,
|
|
1336
|
-
themeService = _ref.themeService,
|
|
1337
|
-
pluginService = _ref.pluginService;
|
|
1338
|
-
this.colorService = void 0;
|
|
1339
|
-
this.themeService = void 0;
|
|
1340
|
-
this.pluginService = void 0;
|
|
1341
|
-
this.pluginService = pluginService;
|
|
1342
|
-
this.colorService = colorService;
|
|
1343
|
-
this.themeService = themeService;
|
|
1344
|
-
};
|
|
1345
|
-
|
|
1346
|
-
var AppModule = {
|
|
1347
|
-
appService: /*#__PURE__*/asClass(AppService).singleton()
|
|
1348
|
-
};
|
|
1349
|
-
|
|
1350
|
-
function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
|
|
1351
|
-
var answer = tone;
|
|
1352
|
-
var closestToChroma = Hct.from(hue, chroma, tone);
|
|
1353
|
-
if (closestToChroma.chroma < chroma) {
|
|
1354
|
-
var chromaPeak = closestToChroma.chroma;
|
|
1355
|
-
while (closestToChroma.chroma < chroma) {
|
|
1356
|
-
answer += byDecreasingTone ? -1.0 : 1.0;
|
|
1357
|
-
var potentialSolution = Hct.from(hue, chroma, answer);
|
|
1358
|
-
if (chromaPeak > potentialSolution.chroma) {
|
|
1359
|
-
break;
|
|
1360
|
-
}
|
|
1361
|
-
if (Math.abs(potentialSolution.chroma - chroma) < 0.4) {
|
|
1362
|
-
break;
|
|
1363
|
-
}
|
|
1364
|
-
var potentialDelta = Math.abs(potentialSolution.chroma - chroma);
|
|
1365
|
-
var currentDelta = Math.abs(closestToChroma.chroma - chroma);
|
|
1366
|
-
if (potentialDelta < currentDelta) {
|
|
1367
|
-
closestToChroma = potentialSolution;
|
|
1368
|
-
}
|
|
1369
|
-
chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
return answer;
|
|
1373
|
-
}
|
|
1374
|
-
var defaultColors = function defaultColors(colorService) {
|
|
1375
|
-
return {
|
|
1376
|
-
fromPalettes: ['primary', 'secondary', 'tertiary'],
|
|
1377
|
-
colors: {
|
|
1378
|
-
background: {
|
|
1379
|
-
palette: function palette(s) {
|
|
1380
|
-
return s.getPalette('neutral');
|
|
1381
|
-
},
|
|
1382
|
-
tone: function tone(s) {
|
|
1383
|
-
return s.isDark ? 6 : 98;
|
|
1384
|
-
},
|
|
1385
|
-
isBackground: true
|
|
1386
|
-
},
|
|
1387
|
-
onBackground: {
|
|
1388
|
-
palette: function palette(s) {
|
|
1389
|
-
return s.getPalette('neutral');
|
|
1390
|
-
},
|
|
1391
|
-
tone: function tone(s) {
|
|
1392
|
-
return s.isDark ? 90 : 10;
|
|
1393
|
-
},
|
|
1394
|
-
background: function background(s) {
|
|
1395
|
-
return colorService.getColor('background').getDynamicColor();
|
|
1396
|
-
},
|
|
1397
|
-
contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
|
|
1398
|
-
},
|
|
1399
|
-
surface: {
|
|
1400
|
-
palette: function palette(s) {
|
|
1401
|
-
return s.getPalette('neutral');
|
|
1402
|
-
},
|
|
1403
|
-
tone: function tone(s) {
|
|
1404
|
-
return s.isDark ? 6 : 98;
|
|
1405
|
-
},
|
|
1406
|
-
isBackground: true
|
|
1407
|
-
},
|
|
1408
|
-
surfaceDim: {
|
|
1409
|
-
palette: function palette(s) {
|
|
1410
|
-
return s.getPalette('neutral');
|
|
1411
|
-
},
|
|
1412
|
-
tone: function tone(s) {
|
|
1413
|
-
return s.isDark ? 6 : 87;
|
|
1414
|
-
},
|
|
1415
|
-
isBackground: true
|
|
1416
|
-
},
|
|
1417
|
-
surfaceBright: {
|
|
1418
|
-
palette: function palette(s) {
|
|
1419
|
-
return s.getPalette('neutral');
|
|
1420
|
-
},
|
|
1421
|
-
tone: function tone(s) {
|
|
1422
|
-
return s.isDark ? 24 : 98;
|
|
1423
|
-
},
|
|
1424
|
-
isBackground: true
|
|
1425
|
-
},
|
|
1426
|
-
surfaceContainerLowest: {
|
|
1427
|
-
palette: function palette(s) {
|
|
1428
|
-
return s.getPalette('neutral');
|
|
1429
|
-
},
|
|
1430
|
-
tone: function tone(s) {
|
|
1431
|
-
return s.isDark ? 4 : 100;
|
|
1432
|
-
},
|
|
1433
|
-
isBackground: true
|
|
1434
|
-
},
|
|
1435
|
-
surfaceContainerLow: {
|
|
1436
|
-
palette: function palette(s) {
|
|
1437
|
-
return s.getPalette('neutral');
|
|
1438
|
-
},
|
|
1439
|
-
tone: function tone(s) {
|
|
1440
|
-
return s.isDark ? 10 : 96;
|
|
1441
|
-
},
|
|
1442
|
-
isBackground: true
|
|
1443
|
-
},
|
|
1444
|
-
surfaceContainer: {
|
|
1445
|
-
palette: function palette(s) {
|
|
1446
|
-
return s.getPalette('neutral');
|
|
1447
|
-
},
|
|
1448
|
-
tone: function tone(s) {
|
|
1449
|
-
return s.isDark ? 12 : 94;
|
|
1450
|
-
},
|
|
1451
|
-
isBackground: true
|
|
1452
|
-
},
|
|
1453
|
-
surfaceContainerHigh: {
|
|
1454
|
-
palette: function palette(s) {
|
|
1455
|
-
return s.getPalette('neutral');
|
|
1456
|
-
},
|
|
1457
|
-
tone: function tone(s) {
|
|
1458
|
-
return s.isDark ? 17 : 92;
|
|
1459
|
-
},
|
|
1460
|
-
isBackground: true
|
|
1461
|
-
},
|
|
1462
|
-
surfaceContainerHighest: {
|
|
1463
|
-
palette: function palette(s) {
|
|
1464
|
-
return s.getPalette('neutral');
|
|
1465
|
-
},
|
|
1466
|
-
tone: function tone(s) {
|
|
1467
|
-
return s.isDark ? 22 : 90;
|
|
1468
|
-
},
|
|
1469
|
-
isBackground: true
|
|
1470
|
-
},
|
|
1471
|
-
onSurface: {
|
|
1472
|
-
palette: function palette(s) {
|
|
1473
|
-
return s.getPalette('neutral');
|
|
1474
|
-
},
|
|
1475
|
-
tone: function tone(s) {
|
|
1476
|
-
return s.isDark ? 90 : 10;
|
|
1477
|
-
},
|
|
1478
|
-
background: function background(s) {
|
|
1479
|
-
return highestSurface(s, colorService);
|
|
1480
|
-
},
|
|
1481
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1482
|
-
},
|
|
1483
|
-
surfaceVariant: {
|
|
1484
|
-
palette: function palette(s) {
|
|
1485
|
-
return s.getPalette('neutralVariant');
|
|
1486
|
-
},
|
|
1487
|
-
tone: function tone(s) {
|
|
1488
|
-
return s.isDark ? 30 : 90;
|
|
1489
|
-
},
|
|
1490
|
-
isBackground: true
|
|
1491
|
-
},
|
|
1492
|
-
onSurfaceVariant: {
|
|
1493
|
-
palette: function palette(s) {
|
|
1494
|
-
return s.getPalette('neutralVariant');
|
|
1495
|
-
},
|
|
1496
|
-
tone: function tone(s) {
|
|
1497
|
-
return s.isDark ? 80 : 30;
|
|
1498
|
-
},
|
|
1499
|
-
background: function background(s) {
|
|
1500
|
-
return highestSurface(s, colorService);
|
|
1501
|
-
},
|
|
1502
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1503
|
-
},
|
|
1504
|
-
inverseSurface: {
|
|
1505
|
-
palette: function palette(s) {
|
|
1506
|
-
return s.getPalette('neutral');
|
|
1507
|
-
},
|
|
1508
|
-
tone: function tone(s) {
|
|
1509
|
-
return s.isDark ? 90 : 20;
|
|
1510
|
-
}
|
|
1511
|
-
},
|
|
1512
|
-
inverseOnSurface: {
|
|
1513
|
-
palette: function palette(s) {
|
|
1514
|
-
return s.getPalette('neutral');
|
|
1515
|
-
},
|
|
1516
|
-
tone: function tone(s) {
|
|
1517
|
-
return s.isDark ? 20 : 95;
|
|
1518
|
-
},
|
|
1519
|
-
background: function background(s) {
|
|
1520
|
-
return colorService.getColor('inverseSurface').getDynamicColor();
|
|
1521
|
-
},
|
|
1522
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1523
|
-
},
|
|
1524
|
-
outline: {
|
|
1525
|
-
palette: function palette(s) {
|
|
1526
|
-
return s.getPalette('neutralVariant');
|
|
1527
|
-
},
|
|
1528
|
-
tone: function tone(s) {
|
|
1529
|
-
return s.isDark ? 60 : 50;
|
|
1530
|
-
},
|
|
1531
|
-
background: function background(s) {
|
|
1532
|
-
return highestSurface(s, colorService);
|
|
1533
|
-
},
|
|
1534
|
-
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
|
|
1535
|
-
},
|
|
1536
|
-
outlineVariant: {
|
|
1537
|
-
palette: function palette(s) {
|
|
1538
|
-
return s.getPalette('neutralVariant');
|
|
1539
|
-
},
|
|
1540
|
-
tone: function tone(s) {
|
|
1541
|
-
return s.isDark ? 30 : 80;
|
|
1542
|
-
},
|
|
1543
|
-
background: function background(s) {
|
|
1544
|
-
return highestSurface(s, colorService);
|
|
1545
|
-
},
|
|
1546
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7)
|
|
1547
|
-
},
|
|
1548
|
-
shadow: {
|
|
1549
|
-
palette: function palette(s) {
|
|
1550
|
-
return s.getPalette('neutral');
|
|
1551
|
-
},
|
|
1552
|
-
tone: function tone(s) {
|
|
1553
|
-
return 0;
|
|
1554
|
-
}
|
|
1555
|
-
},
|
|
1556
|
-
scrim: {
|
|
1557
|
-
palette: function palette(s) {
|
|
1558
|
-
return s.getPalette('neutral');
|
|
1559
|
-
},
|
|
1560
|
-
tone: function tone(s) {
|
|
1561
|
-
return 0;
|
|
1562
|
-
}
|
|
1563
|
-
},
|
|
1564
|
-
surfaceTint: {
|
|
1565
|
-
palette: function palette(s) {
|
|
1566
|
-
return s.getPalette('neutral');
|
|
1567
|
-
},
|
|
1568
|
-
tone: function tone(s) {
|
|
1569
|
-
return s.isDark ? 80 : 40;
|
|
1570
|
-
},
|
|
1571
|
-
isBackground: true
|
|
1572
|
-
},
|
|
1573
|
-
secondaryContainer: {
|
|
1574
|
-
tone: function tone(s) {
|
|
1575
|
-
var initialTone = s.isDark ? 30 : 90;
|
|
1576
|
-
return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
|
|
1577
|
-
}
|
|
1578
|
-
},
|
|
1579
|
-
onSecondaryContainer: {
|
|
1580
|
-
tone: function tone(s) {
|
|
1581
|
-
return DynamicColor.foregroundTone(colorService.getColor('secondaryContainer').getDynamicColor().tone(s), 4.5);
|
|
1582
|
-
}
|
|
1583
|
-
},
|
|
1584
|
-
tertiaryContainer: {
|
|
1585
|
-
palette: function palette(s) {
|
|
1586
|
-
return s.getPalette('tertiary');
|
|
1587
|
-
},
|
|
1588
|
-
tone: function tone(s) {
|
|
1589
|
-
var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
|
|
1590
|
-
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
1591
|
-
}
|
|
1592
|
-
},
|
|
1593
|
-
onTertiaryContainer: {
|
|
1594
|
-
palette: function palette(s) {
|
|
1595
|
-
return s.getPalette('tertiary');
|
|
1596
|
-
},
|
|
1597
|
-
tone: function tone(s) {
|
|
1598
|
-
return DynamicColor.foregroundTone(colorService.getColor('tertiaryContainer').getDynamicColor().tone(s), 4.5);
|
|
1599
|
-
}
|
|
1600
|
-
},
|
|
1601
|
-
error: {
|
|
1602
|
-
palette: function palette(s) {
|
|
1603
|
-
return s.getPalette('error');
|
|
1604
|
-
},
|
|
1605
|
-
tone: function tone(s) {
|
|
1606
|
-
return s.isDark ? 80 : 40;
|
|
1607
|
-
},
|
|
1608
|
-
isBackground: true,
|
|
1609
|
-
background: function background(s) {
|
|
1610
|
-
return highestSurface(s, colorService);
|
|
1611
|
-
},
|
|
1612
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1613
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1614
|
-
return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
|
|
1615
|
-
}
|
|
1616
|
-
},
|
|
1617
|
-
onError: {
|
|
1618
|
-
palette: function palette(s) {
|
|
1619
|
-
return s.getPalette('error');
|
|
1620
|
-
},
|
|
1621
|
-
tone: function tone(s) {
|
|
1622
|
-
return s.isDark ? 20 : 100;
|
|
1623
|
-
},
|
|
1624
|
-
background: function background(s) {
|
|
1625
|
-
return colorService.getColor('error').getDynamicColor();
|
|
1626
|
-
},
|
|
1627
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1628
|
-
},
|
|
1629
|
-
errorContainer: {
|
|
1630
|
-
palette: function palette(s) {
|
|
1631
|
-
return s.getPalette('error');
|
|
1632
|
-
},
|
|
1633
|
-
tone: function tone(s) {
|
|
1634
|
-
return s.isDark ? 30 : 90;
|
|
1635
|
-
},
|
|
1636
|
-
isBackground: true,
|
|
1637
|
-
background: function background(s) {
|
|
1638
|
-
return highestSurface(s, colorService);
|
|
1639
|
-
},
|
|
1640
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1641
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1642
|
-
return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
|
|
1643
|
-
}
|
|
1644
|
-
},
|
|
1645
|
-
onErrorContainer: {
|
|
1646
|
-
palette: function palette(s) {
|
|
1647
|
-
return s.getPalette('error');
|
|
1648
|
-
},
|
|
1649
|
-
tone: function tone(s) {
|
|
1650
|
-
return s.isDark ? 90 : 10;
|
|
1651
|
-
},
|
|
1652
|
-
background: function background(s) {
|
|
1653
|
-
return colorService.getColor('errorContainer').getDynamicColor();
|
|
1654
|
-
},
|
|
1655
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1656
|
-
},
|
|
1657
|
-
onTertiaryFixed: {
|
|
1658
|
-
palette: function palette(s) {
|
|
1659
|
-
return s.getPalette('tertiary');
|
|
1660
|
-
},
|
|
1661
|
-
tone: function tone(s) {
|
|
1662
|
-
return 10.0;
|
|
1663
|
-
},
|
|
1664
|
-
background: function background(s) {
|
|
1665
|
-
return colorService.getColor('tertiaryFixedDim').getDynamicColor();
|
|
1666
|
-
},
|
|
1667
|
-
secondBackground: function secondBackground(s) {
|
|
1668
|
-
return colorService.getColor('tertiaryFixed').getDynamicColor();
|
|
1669
|
-
},
|
|
1670
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1671
|
-
},
|
|
1672
|
-
onTertiaryFixedVariant: {
|
|
1673
|
-
palette: function palette(s) {
|
|
1674
|
-
return s.getPalette('tertiary');
|
|
1675
|
-
},
|
|
1676
|
-
tone: function tone(s) {
|
|
1677
|
-
return 30.0;
|
|
1678
|
-
},
|
|
1679
|
-
background: function background(s) {
|
|
1680
|
-
return colorService.getColor('tertiaryFixedDim').getDynamicColor();
|
|
1681
|
-
},
|
|
1682
|
-
secondBackground: function secondBackground(s) {
|
|
1683
|
-
return colorService.getColor('tertiaryFixed').getDynamicColor();
|
|
1684
|
-
},
|
|
1685
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
};
|
|
1690
|
-
|
|
1691
|
-
var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
|
|
1692
|
-
var sourceHue = sourceColor.hue;
|
|
1693
|
-
if (hues.length !== rotations.length) {
|
|
1694
|
-
throw new Error("mismatch between hue length " + hues.length + " & rotations " + rotations.length);
|
|
1695
|
-
}
|
|
1696
|
-
if (rotations.length === 1) {
|
|
1697
|
-
return sanitizeDegreesDouble(sourceColor.hue + rotations[0]);
|
|
1698
|
-
}
|
|
1699
|
-
var size = hues.length;
|
|
1700
|
-
for (var i = 0; i <= size - 2; i++) {
|
|
1701
|
-
var thisHue = hues[i];
|
|
1702
|
-
var nextHue = hues[i + 1];
|
|
1703
|
-
if (thisHue < sourceHue && sourceHue < nextHue) {
|
|
1704
|
-
return sanitizeDegreesDouble(sourceHue + rotations[i]);
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
// If this statement executes, something is wrong, there should have been a
|
|
1708
|
-
// rotation found using the arrays.
|
|
1709
|
-
return sourceHue;
|
|
1710
|
-
};
|
|
1711
|
-
var VariantEntity = function VariantEntity(palettes, customPalettes) {
|
|
1712
|
-
if (palettes === void 0) {
|
|
1713
|
-
palettes = {};
|
|
1714
|
-
}
|
|
1715
|
-
this.palettes = void 0;
|
|
1716
|
-
this.customPalettes = void 0;
|
|
1717
|
-
this.palettes = palettes;
|
|
1718
|
-
this.customPalettes = customPalettes;
|
|
1719
|
-
};
|
|
1720
|
-
|
|
1721
|
-
var _VariantModel;
|
|
1722
|
-
var VariantModel = function VariantModel() {};
|
|
1723
|
-
_VariantModel = VariantModel;
|
|
1724
|
-
VariantModel.tonalSpot = {
|
|
1725
|
-
palettes: {
|
|
1726
|
-
primary: function primary(sourceColorHct) {
|
|
1727
|
-
return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 36.0);
|
|
1728
|
-
},
|
|
1729
|
-
secondary: function secondary(sourceColorHct) {
|
|
1730
|
-
return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16.0);
|
|
1731
|
-
},
|
|
1732
|
-
tertiary: function tertiary(sourceColorHct) {
|
|
1733
|
-
return TonalPalette.fromHueAndChroma(sanitizeDegreesDouble(sourceColorHct.hue + 60.0), 24.0);
|
|
1734
|
-
},
|
|
1735
|
-
neutral: function neutral(sourceColorHct) {
|
|
1736
|
-
return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
|
|
1737
|
-
},
|
|
1738
|
-
neutralVariant: function neutralVariant(sourceColorHct) {
|
|
1739
|
-
return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
|
|
1740
|
-
}
|
|
1741
|
-
},
|
|
1742
|
-
customPalettes: function customPalettes(colorHct) {
|
|
1743
|
-
return TonalPalette.fromHueAndChroma(colorHct.hue, 16);
|
|
1744
|
-
}
|
|
1745
|
-
};
|
|
1746
|
-
VariantModel.vibrant = {
|
|
1747
|
-
palettes: {
|
|
1748
|
-
primary: function primary(sourceColorHct) {
|
|
1749
|
-
return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200.0);
|
|
1750
|
-
},
|
|
1751
|
-
secondary: function secondary(sourceColorHct) {
|
|
1752
|
-
return TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
|
|
1753
|
-
},
|
|
1754
|
-
tertiary: function tertiary(sourceColorHct) {
|
|
1755
|
-
return TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.tertiaryRotations), 32.0);
|
|
1756
|
-
},
|
|
1757
|
-
neutral: function neutral(sourceColorHct) {
|
|
1758
|
-
return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
|
|
1759
|
-
},
|
|
1760
|
-
neutralVariant: function neutralVariant(sourceColorHct) {
|
|
1761
|
-
return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
|
|
1762
|
-
}
|
|
1763
|
-
},
|
|
1764
|
-
customPalettes: function customPalettes(colorHct) {
|
|
1765
|
-
return TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
|
|
1766
|
-
}
|
|
1767
|
-
};
|
|
1768
|
-
VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
|
|
1769
|
-
VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
|
|
1770
|
-
VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
|
|
1771
|
-
|
|
1772
|
-
function defineConfig(configObject) {
|
|
1773
|
-
if (!configObject || typeof configObject !== 'object') {
|
|
1774
|
-
throw new Error('The configuration is missing or not an object');
|
|
1775
|
-
}
|
|
1776
|
-
if (!('sourceColor' in configObject)) {
|
|
1777
|
-
throw new Error('Invalid configuration');
|
|
1778
|
-
}
|
|
1779
|
-
return configObject;
|
|
1780
|
-
}
|
|
1781
|
-
var ConfigService = /*#__PURE__*/function () {
|
|
1782
|
-
function ConfigService(_ref) {
|
|
1783
|
-
var appService = _ref.appService;
|
|
1784
|
-
this.configPath = './theme.config.ts';
|
|
1785
|
-
this.appService = void 0;
|
|
1786
|
-
this.appService = appService;
|
|
1787
|
-
}
|
|
1788
|
-
var _proto = ConfigService.prototype;
|
|
1789
|
-
_proto.loadConfig = /*#__PURE__*/function () {
|
|
1790
|
-
var _loadConfig = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1791
|
-
var _this$appService, themeService, colorService, pluginService, _yield$this$getConfig, sourceColor, _yield$this$getConfig2, contrastLevel, _yield$this$getConfig3, isDark, _yield$this$getConfig4, variant, palettes, colors, _yield$this$getConfig5, useDefaultColors, plugins;
|
|
1792
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1793
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1794
|
-
case 0:
|
|
1795
|
-
_this$appService = this.appService, themeService = _this$appService.themeService, colorService = _this$appService.colorService, pluginService = _this$appService.pluginService;
|
|
1796
|
-
_context.next = 3;
|
|
1797
|
-
return this.getConfig();
|
|
1798
|
-
case 3:
|
|
1799
|
-
_yield$this$getConfig = _context.sent;
|
|
1800
|
-
sourceColor = _yield$this$getConfig.sourceColor;
|
|
1801
|
-
_yield$this$getConfig2 = _yield$this$getConfig.contrastLevel;
|
|
1802
|
-
contrastLevel = _yield$this$getConfig2 === void 0 ? 0 : _yield$this$getConfig2;
|
|
1803
|
-
_yield$this$getConfig3 = _yield$this$getConfig.isDark;
|
|
1804
|
-
isDark = _yield$this$getConfig3 === void 0 ? false : _yield$this$getConfig3;
|
|
1805
|
-
_yield$this$getConfig4 = _yield$this$getConfig.variant;
|
|
1806
|
-
variant = _yield$this$getConfig4 === void 0 ? VariantModel.tonalSpot : _yield$this$getConfig4;
|
|
1807
|
-
palettes = _yield$this$getConfig.palettes;
|
|
1808
|
-
colors = _yield$this$getConfig.colors;
|
|
1809
|
-
_yield$this$getConfig5 = _yield$this$getConfig.useDefaultColors;
|
|
1810
|
-
useDefaultColors = _yield$this$getConfig5 === void 0 ? true : _yield$this$getConfig5;
|
|
1811
|
-
plugins = _yield$this$getConfig.plugins;
|
|
1812
|
-
themeService.create({
|
|
1813
|
-
contrastLevel: contrastLevel,
|
|
1814
|
-
isDark: isDark,
|
|
1815
|
-
sourceColorHex: sourceColor,
|
|
1816
|
-
variant: variant
|
|
1817
|
-
});
|
|
1818
|
-
if (palettes) {
|
|
1819
|
-
Object.entries(palettes).forEach(function (_ref2) {
|
|
1820
|
-
var key = _ref2[0],
|
|
1821
|
-
value = _ref2[1];
|
|
1822
|
-
return themeService.addCustomPalette(key, value);
|
|
1823
|
-
});
|
|
1824
|
-
}
|
|
1825
|
-
if (useDefaultColors) {
|
|
1826
|
-
colorService.addColors(defaultColors);
|
|
1827
|
-
}
|
|
1828
|
-
if (colors) {
|
|
1829
|
-
colorService.addColors(colors);
|
|
1830
|
-
}
|
|
1831
|
-
if (plugins) {
|
|
1832
|
-
plugins.forEach(function (plugin) {
|
|
1833
|
-
return pluginService.addPlugin(plugin);
|
|
1834
|
-
});
|
|
1835
|
-
pluginService.loadPlugins(this.appService);
|
|
1836
|
-
}
|
|
1837
|
-
case 21:
|
|
1838
|
-
case "end":
|
|
1839
|
-
return _context.stop();
|
|
1840
|
-
}
|
|
1841
|
-
}, _callee, this);
|
|
1842
|
-
}));
|
|
1843
|
-
function loadConfig() {
|
|
1844
|
-
return _loadConfig.apply(this, arguments);
|
|
1845
|
-
}
|
|
1846
|
-
return loadConfig;
|
|
1847
|
-
}();
|
|
1848
|
-
_proto.getConfig = /*#__PURE__*/function () {
|
|
1849
|
-
var _getConfig = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1850
|
-
var path, configImport, config;
|
|
1851
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1852
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
1853
|
-
case 0:
|
|
1854
|
-
path = resolve(this.configPath);
|
|
1855
|
-
_context2.next = 3;
|
|
1856
|
-
return import(path);
|
|
1857
|
-
case 3:
|
|
1858
|
-
configImport = _context2.sent;
|
|
1859
|
-
config = configImport["default"];
|
|
1860
|
-
return _context2.abrupt("return", config);
|
|
1861
|
-
case 6:
|
|
1862
|
-
case "end":
|
|
1863
|
-
return _context2.stop();
|
|
1864
|
-
}
|
|
1865
|
-
}, _callee2, this);
|
|
1866
|
-
}));
|
|
1867
|
-
function getConfig() {
|
|
1868
|
-
return _getConfig.apply(this, arguments);
|
|
1869
|
-
}
|
|
1870
|
-
return getConfig;
|
|
1871
|
-
}();
|
|
1872
|
-
return ConfigService;
|
|
1873
|
-
}();
|
|
1874
|
-
|
|
1875
|
-
var ConfigModule = {
|
|
1876
|
-
configService: /*#__PURE__*/asClass(ConfigService).singleton()
|
|
1877
|
-
};
|
|
1878
|
-
|
|
1879
|
-
var PluginService = /*#__PURE__*/function () {
|
|
1880
|
-
function PluginService() {
|
|
1881
|
-
this.pluginInstances = new Map();
|
|
1882
|
-
this.pluginConstructors = new Map();
|
|
1883
|
-
}
|
|
1884
|
-
var _proto = PluginService.prototype;
|
|
1885
|
-
_proto.addPlugin = function addPlugin(plugin) {
|
|
1886
|
-
this.pluginConstructors.set(plugin.name, plugin);
|
|
1887
|
-
};
|
|
1888
|
-
_proto.loadPlugins = function loadPlugins(appService) {
|
|
1889
|
-
var _this = this;
|
|
1890
|
-
this.pluginConstructors.forEach(function (plugin) {
|
|
1891
|
-
_this.pluginInstances.set(plugin.name, new plugin(appService));
|
|
1892
|
-
});
|
|
1893
|
-
};
|
|
1894
|
-
_proto.getPlugin = function getPlugin(plugin) {
|
|
1895
|
-
return this.pluginInstances.get(plugin.name);
|
|
1896
|
-
};
|
|
1897
|
-
return PluginService;
|
|
1898
|
-
}();
|
|
1899
|
-
|
|
1900
|
-
var PluginModule = {
|
|
1901
|
-
pluginService: /*#__PURE__*/asClass(PluginService).singleton()
|
|
1902
|
-
};
|
|
1903
|
-
|
|
1904
|
-
function importContainer(container, services) {
|
|
1905
|
-
services.forEach(function (service) {
|
|
1906
|
-
Object.entries(service).forEach(function (_ref) {
|
|
1907
|
-
var name = _ref[0],
|
|
1908
|
-
serviceClass = _ref[1];
|
|
1909
|
-
container.register(name, serviceClass);
|
|
1910
|
-
});
|
|
1911
|
-
});
|
|
1912
|
-
return container;
|
|
1913
|
-
}
|
|
1914
|
-
var AppContainer = /*#__PURE__*/createContainer({
|
|
1915
|
-
injectionMode: InjectionMode.PROXY
|
|
1916
|
-
});
|
|
1917
|
-
importContainer(AppContainer, [ConfigModule, AppModule, PluginModule, ColorModule, ThemeModule]);
|
|
1918
|
-
|
|
1919
|
-
function bootstrap() {
|
|
1920
|
-
return AppContainer.resolve('appService');
|
|
1921
|
-
}
|
|
1922
|
-
function bootstrapFromConfig(_x) {
|
|
1923
|
-
return _bootstrapFromConfig.apply(this, arguments);
|
|
1924
|
-
}
|
|
1925
|
-
function _bootstrapFromConfig() {
|
|
1926
|
-
_bootstrapFromConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path) {
|
|
1927
|
-
var configService;
|
|
1928
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1929
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1930
|
-
case 0:
|
|
1931
|
-
configService = AppContainer.resolve('configService');
|
|
1932
|
-
if (path) configService.configPath = path;
|
|
1933
|
-
_context.next = 4;
|
|
1934
|
-
return configService.loadConfig();
|
|
1935
|
-
case 4:
|
|
1936
|
-
return _context.abrupt("return", AppContainer.resolve('appService'));
|
|
1937
|
-
case 5:
|
|
1938
|
-
case "end":
|
|
1939
|
-
return _context.stop();
|
|
1940
|
-
}
|
|
1941
|
-
}, _callee);
|
|
1942
|
-
}));
|
|
1943
|
-
return _bootstrapFromConfig.apply(this, arguments);
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
export { AppContainer, AppModule, AppService, ColorEntity, ColorManagerService, ColorModule, ColorService, ConfigService, ContrastCurve, DynamicColor, SchemeEntity, SchemeService, ThemeModule, ThemeService, ToneDeltaPair, VariantEntity, VariantModel, VariantService, bootstrap, bootstrapFromConfig, defaultColors, defineConfig, getRotatedHue, highestSurface, importContainer };
|
|
1947
|
-
//# sourceMappingURL=theme.esm.js.map
|