@udixio/theme 1.0.0-beta.5 → 1.0.0-beta.6

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.
@@ -2,372 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
- var common = require('@nestjs/common');
5
+ var awilix = require('awilix');
7
6
  var materialColorUtilities = require('@material/material-color-utilities');
8
7
  var mergeDeep = require('merge-deep');
9
- var core = require('@nestjs/core');
10
-
11
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
12
- try {
13
- var i = n[a](c),
14
- u = i.value;
15
- } catch (n) {
16
- return void e(n);
17
- }
18
- i.done ? t(u) : Promise.resolve(u).then(r, o);
19
- }
20
- function _asyncToGenerator(n) {
21
- return function () {
22
- var t = this,
23
- e = arguments;
24
- return new Promise(function (r, o) {
25
- var a = n.apply(t, e);
26
- function _next(n) {
27
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
28
- }
29
- function _throw(n) {
30
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
31
- }
32
- _next(void 0);
33
- });
34
- };
35
- }
36
- function _defineProperties(e, r) {
37
- for (var t = 0; t < r.length; t++) {
38
- var o = r[t];
39
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
40
- }
41
- }
42
- function _createClass(e, r, t) {
43
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
44
- writable: !1
45
- }), e;
46
- }
47
- function _extends() {
48
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
49
- for (var e = 1; e < arguments.length; e++) {
50
- var t = arguments[e];
51
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
52
- }
53
- return n;
54
- }, _extends.apply(null, arguments);
55
- }
56
- function _regeneratorRuntime() {
57
- _regeneratorRuntime = function () {
58
- return e;
59
- };
60
- var t,
61
- e = {},
62
- r = Object.prototype,
63
- n = r.hasOwnProperty,
64
- o = Object.defineProperty || function (t, e, r) {
65
- t[e] = r.value;
66
- },
67
- i = "function" == typeof Symbol ? Symbol : {},
68
- a = i.iterator || "@@iterator",
69
- c = i.asyncIterator || "@@asyncIterator",
70
- u = i.toStringTag || "@@toStringTag";
71
- function define(t, e, r) {
72
- return Object.defineProperty(t, e, {
73
- value: r,
74
- enumerable: !0,
75
- configurable: !0,
76
- writable: !0
77
- }), t[e];
78
- }
79
- try {
80
- define({}, "");
81
- } catch (t) {
82
- define = function (t, e, r) {
83
- return t[e] = r;
84
- };
85
- }
86
- function wrap(t, e, r, n) {
87
- var i = e && e.prototype instanceof Generator ? e : Generator,
88
- a = Object.create(i.prototype),
89
- c = new Context(n || []);
90
- return o(a, "_invoke", {
91
- value: makeInvokeMethod(t, r, c)
92
- }), a;
93
- }
94
- function tryCatch(t, e, r) {
95
- try {
96
- return {
97
- type: "normal",
98
- arg: t.call(e, r)
99
- };
100
- } catch (t) {
101
- return {
102
- type: "throw",
103
- arg: t
104
- };
105
- }
106
- }
107
- e.wrap = wrap;
108
- var h = "suspendedStart",
109
- l = "suspendedYield",
110
- f = "executing",
111
- s = "completed",
112
- y = {};
113
- function Generator() {}
114
- function GeneratorFunction() {}
115
- function GeneratorFunctionPrototype() {}
116
- var p = {};
117
- define(p, a, function () {
118
- return this;
119
- });
120
- var d = Object.getPrototypeOf,
121
- v = d && d(d(values([])));
122
- v && v !== r && n.call(v, a) && (p = v);
123
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
124
- function defineIteratorMethods(t) {
125
- ["next", "throw", "return"].forEach(function (e) {
126
- define(t, e, function (t) {
127
- return this._invoke(e, t);
128
- });
129
- });
130
- }
131
- function AsyncIterator(t, e) {
132
- function invoke(r, o, i, a) {
133
- var c = tryCatch(t[r], t, o);
134
- if ("throw" !== c.type) {
135
- var u = c.arg,
136
- h = u.value;
137
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
138
- invoke("next", t, i, a);
139
- }, function (t) {
140
- invoke("throw", t, i, a);
141
- }) : e.resolve(h).then(function (t) {
142
- u.value = t, i(u);
143
- }, function (t) {
144
- return invoke("throw", t, i, a);
145
- });
146
- }
147
- a(c.arg);
148
- }
149
- var r;
150
- o(this, "_invoke", {
151
- value: function (t, n) {
152
- function callInvokeWithMethodAndArg() {
153
- return new e(function (e, r) {
154
- invoke(t, n, e, r);
155
- });
156
- }
157
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
158
- }
159
- });
160
- }
161
- function makeInvokeMethod(e, r, n) {
162
- var o = h;
163
- return function (i, a) {
164
- if (o === f) throw Error("Generator is already running");
165
- if (o === s) {
166
- if ("throw" === i) throw a;
167
- return {
168
- value: t,
169
- done: !0
170
- };
171
- }
172
- for (n.method = i, n.arg = a;;) {
173
- var c = n.delegate;
174
- if (c) {
175
- var u = maybeInvokeDelegate(c, n);
176
- if (u) {
177
- if (u === y) continue;
178
- return u;
179
- }
180
- }
181
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
182
- if (o === h) throw o = s, n.arg;
183
- n.dispatchException(n.arg);
184
- } else "return" === n.method && n.abrupt("return", n.arg);
185
- o = f;
186
- var p = tryCatch(e, r, n);
187
- if ("normal" === p.type) {
188
- if (o = n.done ? s : l, p.arg === y) continue;
189
- return {
190
- value: p.arg,
191
- done: n.done
192
- };
193
- }
194
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
195
- }
196
- };
197
- }
198
- function maybeInvokeDelegate(e, r) {
199
- var n = r.method,
200
- o = e.iterator[n];
201
- 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;
202
- var i = tryCatch(o, e.iterator, r.arg);
203
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
204
- var a = i.arg;
205
- 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);
206
- }
207
- function pushTryEntry(t) {
208
- var e = {
209
- tryLoc: t[0]
210
- };
211
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
212
- }
213
- function resetTryEntry(t) {
214
- var e = t.completion || {};
215
- e.type = "normal", delete e.arg, t.completion = e;
216
- }
217
- function Context(t) {
218
- this.tryEntries = [{
219
- tryLoc: "root"
220
- }], t.forEach(pushTryEntry, this), this.reset(!0);
221
- }
222
- function values(e) {
223
- if (e || "" === e) {
224
- var r = e[a];
225
- if (r) return r.call(e);
226
- if ("function" == typeof e.next) return e;
227
- if (!isNaN(e.length)) {
228
- var o = -1,
229
- i = function next() {
230
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
231
- return next.value = t, next.done = !0, next;
232
- };
233
- return i.next = i;
234
- }
235
- }
236
- throw new TypeError(typeof e + " is not iterable");
237
- }
238
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
239
- value: GeneratorFunctionPrototype,
240
- configurable: !0
241
- }), o(GeneratorFunctionPrototype, "constructor", {
242
- value: GeneratorFunction,
243
- configurable: !0
244
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
245
- var e = "function" == typeof t && t.constructor;
246
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
247
- }, e.mark = function (t) {
248
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
249
- }, e.awrap = function (t) {
250
- return {
251
- __await: t
252
- };
253
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
254
- return this;
255
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
256
- void 0 === i && (i = Promise);
257
- var a = new AsyncIterator(wrap(t, r, n, o), i);
258
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
259
- return t.done ? t.value : a.next();
260
- });
261
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
262
- return this;
263
- }), define(g, "toString", function () {
264
- return "[object Generator]";
265
- }), e.keys = function (t) {
266
- var e = Object(t),
267
- r = [];
268
- for (var n in e) r.push(n);
269
- return r.reverse(), function next() {
270
- for (; r.length;) {
271
- var t = r.pop();
272
- if (t in e) return next.value = t, next.done = !1, next;
273
- }
274
- return next.done = !0, next;
275
- };
276
- }, e.values = values, Context.prototype = {
277
- constructor: Context,
278
- reset: function (e) {
279
- 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);
280
- },
281
- stop: function () {
282
- this.done = !0;
283
- var t = this.tryEntries[0].completion;
284
- if ("throw" === t.type) throw t.arg;
285
- return this.rval;
286
- },
287
- dispatchException: function (e) {
288
- if (this.done) throw e;
289
- var r = this;
290
- function handle(n, o) {
291
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
292
- }
293
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
294
- var i = this.tryEntries[o],
295
- a = i.completion;
296
- if ("root" === i.tryLoc) return handle("end");
297
- if (i.tryLoc <= this.prev) {
298
- var c = n.call(i, "catchLoc"),
299
- u = n.call(i, "finallyLoc");
300
- if (c && u) {
301
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
302
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
303
- } else if (c) {
304
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
305
- } else {
306
- if (!u) throw Error("try statement without catch or finally");
307
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
308
- }
309
- }
310
- }
311
- },
312
- abrupt: function (t, e) {
313
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
314
- var o = this.tryEntries[r];
315
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
316
- var i = o;
317
- break;
318
- }
319
- }
320
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
321
- var a = i ? i.completion : {};
322
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
323
- },
324
- complete: function (t, e) {
325
- if ("throw" === t.type) throw t.arg;
326
- 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;
327
- },
328
- finish: function (t) {
329
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
330
- var r = this.tryEntries[e];
331
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
332
- }
333
- },
334
- catch: function (t) {
335
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
336
- var r = this.tryEntries[e];
337
- if (r.tryLoc === t) {
338
- var n = r.completion;
339
- if ("throw" === n.type) {
340
- var o = n.arg;
341
- resetTryEntry(r);
342
- }
343
- return o;
344
- }
345
- }
346
- throw Error("illegal catch attempt");
347
- },
348
- delegateYield: function (e, r, n) {
349
- return this.delegate = {
350
- iterator: values(e),
351
- resultName: r,
352
- nextLoc: n
353
- }, "next" === this.method && (this.arg = t), y;
354
- }
355
- }, e;
356
- }
357
- function _toPrimitive(t, r) {
358
- if ("object" != typeof t || !t) return t;
359
- var e = t[Symbol.toPrimitive];
360
- if (void 0 !== e) {
361
- var i = e.call(t, r || "default");
362
- if ("object" != typeof i) return i;
363
- throw new TypeError("@@toPrimitive must return a primitive value.");
364
- }
365
- return ("string" === r ? String : Number)(t);
366
- }
367
- function _toPropertyKey(t) {
368
- var i = _toPrimitive(t, "string");
369
- return "symbol" == typeof i ? i : i + "";
370
- }
371
8
 
372
9
  /**
373
10
  * @license
@@ -832,6 +469,41 @@ function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
832
469
  this.stayTogether = stayTogether;
833
470
  };
834
471
 
472
+ function _defineProperties(e, r) {
473
+ for (var t = 0; t < r.length; t++) {
474
+ var o = r[t];
475
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
476
+ }
477
+ }
478
+ function _createClass(e, r, t) {
479
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
480
+ writable: !1
481
+ }), e;
482
+ }
483
+ function _extends() {
484
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
485
+ for (var e = 1; e < arguments.length; e++) {
486
+ var t = arguments[e];
487
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
488
+ }
489
+ return n;
490
+ }, _extends.apply(null, arguments);
491
+ }
492
+ function _toPrimitive(t, r) {
493
+ if ("object" != typeof t || !t) return t;
494
+ var e = t[Symbol.toPrimitive];
495
+ if (void 0 !== e) {
496
+ var i = e.call(t, r || "default");
497
+ if ("object" != typeof i) return i;
498
+ throw new TypeError("@@toPrimitive must return a primitive value.");
499
+ }
500
+ return ("string" === r ? String : Number)(t);
501
+ }
502
+ function _toPropertyKey(t) {
503
+ var i = _toPrimitive(t, "string");
504
+ return "symbol" == typeof i ? i : i + "";
505
+ }
506
+
835
507
  var ColorEntity = /*#__PURE__*/function () {
836
508
  function ColorEntity(option, schemeService, colorService) {
837
509
  this.option = void 0;
@@ -867,95 +539,17 @@ var ColorEntity = /*#__PURE__*/function () {
867
539
  return ColorEntity;
868
540
  }();
869
541
 
870
- var SchemeEntity = /*#__PURE__*/function () {
871
- function SchemeEntity(options) {
872
- this.options = void 0;
873
- this.options = options;
874
- }
875
- var _proto = SchemeEntity.prototype;
876
- _proto.getPalette = function getPalette(key) {
877
- if (!this.options) {
878
- throw new Error('Scheme options is not set');
879
- }
880
- var palette = this.options.palettes.get(key);
881
- if (!palette) {
882
- throw new Error("Palette " + key + " not found");
883
- }
884
- return palette;
885
- };
886
- return _createClass(SchemeEntity, [{
887
- key: "contrastLevel",
888
- get: function get() {
889
- if (!this.options) {
890
- throw new Error('Scheme options is not set');
891
- }
892
- return this.options.contrastLevel;
893
- }
894
- }, {
895
- key: "isDark",
896
- get: function get() {
897
- if (!this.options) {
898
- throw new Error('Scheme options is not set');
899
- }
900
- return this.options.isDark;
901
- }
902
- }, {
903
- key: "sourceColorHct",
904
- get: function get() {
905
- if (!this.options) {
906
- throw new Error('Scheme options is not set');
907
- }
908
- return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
909
- }
910
- }]);
911
- }();
912
-
913
- exports.SchemeService = /*#__PURE__*/function () {
914
- function SchemeService() {
915
- this.schemeEntity = void 0;
916
- this.options = void 0;
917
- }
918
- var _proto = SchemeService.prototype;
919
- _proto.createOrUpdate = function createOrUpdate(options) {
920
- this.options = mergeDeep(options, this.options);
921
- var palettes = new Map();
922
- var sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourceColorHex);
923
- var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
924
- if (!this.options.palettes) {
925
- return;
926
- }
927
- for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
928
- var _Object$entries$_i = _Object$entries[_i],
929
- key = _Object$entries$_i[0],
930
- paletteFunction = _Object$entries$_i[1];
931
- var palette = paletteFunction(sourceColorHct);
932
- palettes.set(key, palette);
933
- }
934
- this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
935
- palettes: palettes,
936
- sourceColorArgb: sourceColorArgb
937
- }));
938
- };
939
- _proto.get = function get() {
940
- if (!this.schemeEntity) {
941
- throw new Error('Scheme is not created');
942
- }
943
- return this.schemeEntity;
944
- };
945
- return SchemeService;
946
- }();
947
- exports.SchemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable()], exports.SchemeService);
948
-
949
542
  function capitalizeFirstLetter(string) {
950
543
  return string.charAt(0).toUpperCase() + string.slice(1);
951
544
  }
952
545
  var highestSurface = function highestSurface(s, colorManagerService) {
953
546
  return s.isDark ? colorManagerService.get('surfaceBright').getDynamicColor() : colorManagerService.get('surfaceDim').getDynamicColor();
954
547
  };
955
- exports.ColorManagerService = /*#__PURE__*/function () {
956
- function ColorManagerService(schemeService) {
957
- this.schemeService = void 0;
548
+ var ColorManagerService = /*#__PURE__*/function () {
549
+ function ColorManagerService(_ref) {
550
+ var schemeService = _ref.schemeService;
958
551
  this.colorMap = new Map();
552
+ this.schemeService = void 0;
959
553
  this.schemeService = schemeService;
960
554
  }
961
555
  var _proto = ColorManagerService.prototype;
@@ -1141,7 +735,6 @@ exports.ColorManagerService = /*#__PURE__*/function () {
1141
735
  };
1142
736
  return ColorManagerService;
1143
737
  }();
1144
- exports.ColorManagerService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService])], exports.ColorManagerService);
1145
738
 
1146
739
  function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1147
740
  var answer = tone;
@@ -1481,8 +1074,9 @@ var defaultColors = function defaultColors(colorManagerService) {
1481
1074
  };
1482
1075
  };
1483
1076
 
1484
- exports.ColorService = /*#__PURE__*/function () {
1485
- function ColorService(colorManagerService) {
1077
+ var ColorService = /*#__PURE__*/function () {
1078
+ function ColorService(_ref) {
1079
+ var colorManagerService = _ref.colorManagerService;
1486
1080
  this.colorManagerService = void 0;
1487
1081
  this.colorManagerService = colorManagerService;
1488
1082
  }
@@ -1532,28 +1126,94 @@ exports.ColorService = /*#__PURE__*/function () {
1532
1126
  };
1533
1127
  return ColorService;
1534
1128
  }();
1535
- exports.ColorService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.ColorManagerService])], exports.ColorService);
1536
1129
 
1537
- exports.VariantService = /*#__PURE__*/function () {
1538
- function VariantService(schemeService) {
1539
- this.schemeService = void 0;
1540
- this.schemeService = schemeService;
1130
+ var ColorModule = {
1131
+ colorManagerService: /*#__PURE__*/awilix.asClass(ColorManagerService).singleton(),
1132
+ colorService: /*#__PURE__*/awilix.asClass(ColorService).singleton()
1133
+ };
1134
+
1135
+ var SchemeEntity = /*#__PURE__*/function () {
1136
+ function SchemeEntity(options) {
1137
+ this.options = void 0;
1138
+ this.options = options;
1541
1139
  }
1542
- var _proto = VariantService.prototype;
1543
- _proto.set = function set(variantEntity) {
1544
- if (!variantEntity.palettes.error) {
1545
- variantEntity.palettes.error = function () {
1546
- return materialColorUtilities.TonalPalette.fromHueAndChroma(25.0, 84.0);
1547
- };
1140
+ var _proto = SchemeEntity.prototype;
1141
+ _proto.getPalette = function getPalette(key) {
1142
+ if (!this.options) {
1143
+ throw new Error('Scheme options is not set');
1548
1144
  }
1549
- this.schemeService.createOrUpdate(variantEntity);
1145
+ var palette = this.options.palettes.get(key);
1146
+ if (!palette) {
1147
+ throw new Error("Palette " + key + " not found");
1148
+ }
1149
+ return palette;
1550
1150
  };
1551
- return VariantService;
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 materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
1174
+ }
1175
+ }]);
1552
1176
  }();
1553
- exports.VariantService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService])], exports.VariantService);
1554
1177
 
1555
- exports.ThemeService = /*#__PURE__*/function () {
1556
- function ThemeService(schemeService, variantService) {
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
+ this.options = mergeDeep(options, this.options);
1186
+ var palettes = new Map();
1187
+ var sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourceColorHex);
1188
+ var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
1189
+ if (!this.options.palettes) {
1190
+ return;
1191
+ }
1192
+ for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
1193
+ var _Object$entries$_i = _Object$entries[_i],
1194
+ key = _Object$entries$_i[0],
1195
+ paletteFunction = _Object$entries$_i[1];
1196
+ var palette = paletteFunction(sourceColorHct);
1197
+ palettes.set(key, palette);
1198
+ }
1199
+ this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
1200
+ palettes: palettes,
1201
+ sourceColorArgb: sourceColorArgb
1202
+ }));
1203
+ };
1204
+ _proto.get = function get() {
1205
+ if (!this.schemeEntity) {
1206
+ throw new Error('Scheme is not created');
1207
+ }
1208
+ return this.schemeEntity;
1209
+ };
1210
+ return SchemeService;
1211
+ }();
1212
+
1213
+ var ThemeService = /*#__PURE__*/function () {
1214
+ function ThemeService(_ref) {
1215
+ var schemeService = _ref.schemeService,
1216
+ variantService = _ref.variantService;
1557
1217
  this.schemeService = void 0;
1558
1218
  this.variantService = void 0;
1559
1219
  this.schemeService = schemeService;
@@ -1591,60 +1251,61 @@ exports.ThemeService = /*#__PURE__*/function () {
1591
1251
  };
1592
1252
  return ThemeService;
1593
1253
  }();
1594
- exports.ThemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService, exports.VariantService])], exports.ThemeService);
1595
1254
 
1596
- exports.AppService = function AppService(colorService, themeService) {
1255
+ var VariantService = /*#__PURE__*/function () {
1256
+ function VariantService(_ref) {
1257
+ var schemeService = _ref.schemeService;
1258
+ this.schemeService = void 0;
1259
+ this.schemeService = schemeService;
1260
+ }
1261
+ var _proto = VariantService.prototype;
1262
+ _proto.set = function set(variantEntity) {
1263
+ if (!variantEntity.palettes.error) {
1264
+ variantEntity.palettes.error = function () {
1265
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(25.0, 84.0);
1266
+ };
1267
+ }
1268
+ this.schemeService.createOrUpdate(variantEntity);
1269
+ };
1270
+ return VariantService;
1271
+ }();
1272
+
1273
+ var ThemeModule = {
1274
+ schemeService: /*#__PURE__*/awilix.asClass(SchemeService).singleton(),
1275
+ variantService: /*#__PURE__*/awilix.asClass(VariantService).singleton(),
1276
+ themeService: /*#__PURE__*/awilix.asClass(ThemeService).singleton()
1277
+ };
1278
+
1279
+ var AppService = function AppService(_ref) {
1280
+ var colorService = _ref.colorService,
1281
+ themeService = _ref.themeService;
1597
1282
  this.colorService = void 0;
1598
1283
  this.themeService = void 0;
1599
1284
  this.colorService = colorService;
1600
1285
  this.themeService = themeService;
1601
1286
  };
1602
- exports.AppService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.ColorService, exports.ThemeService])], exports.AppService);
1603
-
1604
- exports.ThemeModule = function ThemeModule() {};
1605
- exports.ThemeModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1606
- providers: [exports.SchemeService, exports.ThemeService, exports.VariantService],
1607
- exports: [exports.ThemeService, exports.SchemeService]
1608
- })], exports.ThemeModule);
1609
1287
 
1610
- exports.ColorModule = function ColorModule() {};
1611
- exports.ColorModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1612
- imports: [exports.ThemeModule],
1613
- providers: [exports.ColorService, exports.ColorManagerService],
1614
- exports: [exports.ColorService]
1615
- })], exports.ColorModule);
1288
+ var AppModule = {
1289
+ appService: /*#__PURE__*/awilix.asClass(AppService).singleton()
1290
+ };
1616
1291
 
1617
- exports.AppModule = function AppModule() {};
1618
- exports.AppModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1619
- imports: [exports.ColorModule, exports.ThemeModule],
1620
- providers: [exports.AppService]
1621
- })], exports.AppModule);
1292
+ function importContainer(container, services) {
1293
+ services.forEach(function (service) {
1294
+ Object.entries(service).forEach(function (_ref) {
1295
+ var name = _ref[0],
1296
+ serviceClass = _ref[1];
1297
+ container.register(name, serviceClass);
1298
+ });
1299
+ });
1300
+ return container;
1301
+ }
1302
+ var AppContainer = /*#__PURE__*/awilix.createContainer({
1303
+ injectionMode: awilix.InjectionMode.PROXY
1304
+ });
1305
+ importContainer(AppContainer, [AppModule, ColorModule, ThemeModule]);
1622
1306
 
1623
1307
  function main() {
1624
- return _main.apply(this, arguments);
1625
- }
1626
- function _main() {
1627
- _main = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1628
- var app, appService, close;
1629
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1630
- while (1) switch (_context.prev = _context.next) {
1631
- case 0:
1632
- _context.next = 2;
1633
- return core.NestFactory.create(exports.AppModule);
1634
- case 2:
1635
- app = _context.sent;
1636
- appService = app.get(exports.AppService);
1637
- close = function close() {
1638
- return app.close();
1639
- };
1640
- return _context.abrupt("return", [appService, close]);
1641
- case 6:
1642
- case "end":
1643
- return _context.stop();
1644
- }
1645
- }, _callee);
1646
- }));
1647
- return _main.apply(this, arguments);
1308
+ return AppContainer.resolve('appService');
1648
1309
  }
1649
1310
 
1650
1311
  var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
@@ -1720,15 +1381,24 @@ VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
1720
1381
  VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
1721
1382
  VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
1722
1383
 
1384
+ exports.AppService = AppService;
1723
1385
  exports.ColorEntity = ColorEntity;
1386
+ exports.ColorManagerService = ColorManagerService;
1387
+ exports.ColorModule = ColorModule;
1388
+ exports.ColorService = ColorService;
1724
1389
  exports.ContrastCurve = ContrastCurve;
1725
1390
  exports.DynamicColor = DynamicColor;
1726
1391
  exports.SchemeEntity = SchemeEntity;
1392
+ exports.SchemeService = SchemeService;
1393
+ exports.ThemeModule = ThemeModule;
1394
+ exports.ThemeService = ThemeService;
1727
1395
  exports.ToneDeltaPair = ToneDeltaPair;
1728
1396
  exports.VariantEntity = VariantEntity;
1729
1397
  exports.VariantModel = VariantModel;
1398
+ exports.VariantService = VariantService;
1730
1399
  exports.defaultColors = defaultColors;
1731
1400
  exports.getRotatedHue = getRotatedHue;
1732
1401
  exports.highestSurface = highestSurface;
1402
+ exports.importContainer = importContainer;
1733
1403
  exports.main = main;
1734
1404
  //# sourceMappingURL=theme.cjs.development.js.map