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

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,8 @@
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
- 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
7
 
372
8
  /**
373
9
  * @license
@@ -832,6 +468,41 @@ function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
832
468
  this.stayTogether = stayTogether;
833
469
  };
834
470
 
471
+ function _defineProperties(e, r) {
472
+ for (var t = 0; t < r.length; t++) {
473
+ var o = r[t];
474
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
475
+ }
476
+ }
477
+ function _createClass(e, r, t) {
478
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
479
+ writable: !1
480
+ }), e;
481
+ }
482
+ function _extends() {
483
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
484
+ for (var e = 1; e < arguments.length; e++) {
485
+ var t = arguments[e];
486
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
487
+ }
488
+ return n;
489
+ }, _extends.apply(null, arguments);
490
+ }
491
+ function _toPrimitive(t, r) {
492
+ if ("object" != typeof t || !t) return t;
493
+ var e = t[Symbol.toPrimitive];
494
+ if (void 0 !== e) {
495
+ var i = e.call(t, r || "default");
496
+ if ("object" != typeof i) return i;
497
+ throw new TypeError("@@toPrimitive must return a primitive value.");
498
+ }
499
+ return ("string" === r ? String : Number)(t);
500
+ }
501
+ function _toPropertyKey(t) {
502
+ var i = _toPrimitive(t, "string");
503
+ return "symbol" == typeof i ? i : i + "";
504
+ }
505
+
835
506
  var ColorEntity = /*#__PURE__*/function () {
836
507
  function ColorEntity(option, schemeService, colorService) {
837
508
  this.option = void 0;
@@ -867,95 +538,17 @@ var ColorEntity = /*#__PURE__*/function () {
867
538
  return ColorEntity;
868
539
  }();
869
540
 
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
541
  function capitalizeFirstLetter(string) {
950
542
  return string.charAt(0).toUpperCase() + string.slice(1);
951
543
  }
952
544
  var highestSurface = function highestSurface(s, colorManagerService) {
953
545
  return s.isDark ? colorManagerService.get('surfaceBright').getDynamicColor() : colorManagerService.get('surfaceDim').getDynamicColor();
954
546
  };
955
- exports.ColorManagerService = /*#__PURE__*/function () {
956
- function ColorManagerService(schemeService) {
957
- this.schemeService = void 0;
547
+ var ColorManagerService = /*#__PURE__*/function () {
548
+ function ColorManagerService(_ref) {
549
+ var schemeService = _ref.schemeService;
958
550
  this.colorMap = new Map();
551
+ this.schemeService = void 0;
959
552
  this.schemeService = schemeService;
960
553
  }
961
554
  var _proto = ColorManagerService.prototype;
@@ -1141,7 +734,6 @@ exports.ColorManagerService = /*#__PURE__*/function () {
1141
734
  };
1142
735
  return ColorManagerService;
1143
736
  }();
1144
- exports.ColorManagerService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService])], exports.ColorManagerService);
1145
737
 
1146
738
  function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1147
739
  var answer = tone;
@@ -1481,8 +1073,9 @@ var defaultColors = function defaultColors(colorManagerService) {
1481
1073
  };
1482
1074
  };
1483
1075
 
1484
- exports.ColorService = /*#__PURE__*/function () {
1485
- function ColorService(colorManagerService) {
1076
+ var ColorService = /*#__PURE__*/function () {
1077
+ function ColorService(_ref) {
1078
+ var colorManagerService = _ref.colorManagerService;
1486
1079
  this.colorManagerService = void 0;
1487
1080
  this.colorManagerService = colorManagerService;
1488
1081
  }
@@ -1532,28 +1125,97 @@ exports.ColorService = /*#__PURE__*/function () {
1532
1125
  };
1533
1126
  return ColorService;
1534
1127
  }();
1535
- exports.ColorService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.ColorManagerService])], exports.ColorService);
1536
1128
 
1537
- exports.VariantService = /*#__PURE__*/function () {
1538
- function VariantService(schemeService) {
1539
- this.schemeService = void 0;
1540
- this.schemeService = schemeService;
1129
+ var ColorModule = {
1130
+ colorManagerService: /*#__PURE__*/awilix.asClass(ColorManagerService).singleton(),
1131
+ colorService: /*#__PURE__*/awilix.asClass(ColorService).singleton()
1132
+ };
1133
+
1134
+ var SchemeEntity = /*#__PURE__*/function () {
1135
+ function SchemeEntity(options) {
1136
+ this.options = void 0;
1137
+ this.options = options;
1541
1138
  }
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
- };
1139
+ var _proto = SchemeEntity.prototype;
1140
+ _proto.getPalette = function getPalette(key) {
1141
+ if (!this.options) {
1142
+ throw new Error('Scheme options is not set');
1548
1143
  }
1549
- this.schemeService.createOrUpdate(variantEntity);
1144
+ var palette = this.options.palettes.get(key);
1145
+ if (!palette) {
1146
+ throw new Error("Palette " + key + " not found");
1147
+ }
1148
+ return palette;
1550
1149
  };
1551
- return VariantService;
1150
+ return _createClass(SchemeEntity, [{
1151
+ key: "contrastLevel",
1152
+ get: function get() {
1153
+ if (!this.options) {
1154
+ throw new Error('Scheme options is not set');
1155
+ }
1156
+ return this.options.contrastLevel;
1157
+ }
1158
+ }, {
1159
+ key: "isDark",
1160
+ get: function get() {
1161
+ if (!this.options) {
1162
+ throw new Error('Scheme options is not set');
1163
+ }
1164
+ return this.options.isDark;
1165
+ }
1166
+ }, {
1167
+ key: "sourceColorHct",
1168
+ get: function get() {
1169
+ if (!this.options) {
1170
+ throw new Error('Scheme options is not set');
1171
+ }
1172
+ return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
1173
+ }
1174
+ }]);
1552
1175
  }();
1553
- exports.VariantService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService])], exports.VariantService);
1554
1176
 
1555
- exports.ThemeService = /*#__PURE__*/function () {
1556
- function ThemeService(schemeService, variantService) {
1177
+ var SchemeService = /*#__PURE__*/function () {
1178
+ function SchemeService() {
1179
+ this.schemeEntity = void 0;
1180
+ this.options = void 0;
1181
+ }
1182
+ var _proto = SchemeService.prototype;
1183
+ _proto.createOrUpdate = function createOrUpdate(options) {
1184
+ var _this$options;
1185
+ this.options = _extends({}, this.options, options, {
1186
+ palettes: _extends({}, (_this$options = this.options) == null ? void 0 : _this$options.palettes, options.palettes)
1187
+ });
1188
+ var palettes = new Map();
1189
+ var sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourceColorHex);
1190
+ var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
1191
+ if (!this.options.palettes) {
1192
+ return;
1193
+ }
1194
+ for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
1195
+ var _Object$entries$_i = _Object$entries[_i],
1196
+ key = _Object$entries$_i[0],
1197
+ paletteFunction = _Object$entries$_i[1];
1198
+ var palette = paletteFunction(sourceColorHct);
1199
+ palettes.set(key, palette);
1200
+ }
1201
+ this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
1202
+ palettes: palettes,
1203
+ sourceColorArgb: sourceColorArgb
1204
+ }));
1205
+ };
1206
+ _proto.get = function get() {
1207
+ if (!this.schemeEntity) {
1208
+ throw new Error('Scheme is not created');
1209
+ }
1210
+ return this.schemeEntity;
1211
+ };
1212
+ return SchemeService;
1213
+ }();
1214
+
1215
+ var ThemeService = /*#__PURE__*/function () {
1216
+ function ThemeService(_ref) {
1217
+ var schemeService = _ref.schemeService,
1218
+ variantService = _ref.variantService;
1557
1219
  this.schemeService = void 0;
1558
1220
  this.variantService = void 0;
1559
1221
  this.schemeService = schemeService;
@@ -1591,60 +1253,61 @@ exports.ThemeService = /*#__PURE__*/function () {
1591
1253
  };
1592
1254
  return ThemeService;
1593
1255
  }();
1594
- exports.ThemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService, exports.VariantService])], exports.ThemeService);
1595
1256
 
1596
- exports.AppService = function AppService(colorService, themeService) {
1257
+ var VariantService = /*#__PURE__*/function () {
1258
+ function VariantService(_ref) {
1259
+ var schemeService = _ref.schemeService;
1260
+ this.schemeService = void 0;
1261
+ this.schemeService = schemeService;
1262
+ }
1263
+ var _proto = VariantService.prototype;
1264
+ _proto.set = function set(variantEntity) {
1265
+ if (!variantEntity.palettes.error) {
1266
+ variantEntity.palettes.error = function () {
1267
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(25.0, 84.0);
1268
+ };
1269
+ }
1270
+ this.schemeService.createOrUpdate(variantEntity);
1271
+ };
1272
+ return VariantService;
1273
+ }();
1274
+
1275
+ var ThemeModule = {
1276
+ schemeService: /*#__PURE__*/awilix.asClass(SchemeService).singleton(),
1277
+ variantService: /*#__PURE__*/awilix.asClass(VariantService).singleton(),
1278
+ themeService: /*#__PURE__*/awilix.asClass(ThemeService).singleton()
1279
+ };
1280
+
1281
+ var AppService = function AppService(_ref) {
1282
+ var colorService = _ref.colorService,
1283
+ themeService = _ref.themeService;
1597
1284
  this.colorService = void 0;
1598
1285
  this.themeService = void 0;
1599
1286
  this.colorService = colorService;
1600
1287
  this.themeService = themeService;
1601
1288
  };
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
1289
 
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);
1290
+ var AppModule = {
1291
+ appService: /*#__PURE__*/awilix.asClass(AppService).singleton()
1292
+ };
1616
1293
 
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);
1294
+ function importContainer(container, services) {
1295
+ services.forEach(function (service) {
1296
+ Object.entries(service).forEach(function (_ref) {
1297
+ var name = _ref[0],
1298
+ serviceClass = _ref[1];
1299
+ container.register(name, serviceClass);
1300
+ });
1301
+ });
1302
+ return container;
1303
+ }
1304
+ var AppContainer = /*#__PURE__*/awilix.createContainer({
1305
+ injectionMode: awilix.InjectionMode.PROXY
1306
+ });
1307
+ importContainer(AppContainer, [AppModule, ColorModule, ThemeModule]);
1622
1308
 
1623
1309
  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);
1310
+ return AppContainer.resolve('appService');
1648
1311
  }
1649
1312
 
1650
1313
  var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
@@ -1720,15 +1383,26 @@ VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
1720
1383
  VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
1721
1384
  VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
1722
1385
 
1386
+ exports.AppContainer = AppContainer;
1387
+ exports.AppModule = AppModule;
1388
+ exports.AppService = AppService;
1723
1389
  exports.ColorEntity = ColorEntity;
1390
+ exports.ColorManagerService = ColorManagerService;
1391
+ exports.ColorModule = ColorModule;
1392
+ exports.ColorService = ColorService;
1724
1393
  exports.ContrastCurve = ContrastCurve;
1725
1394
  exports.DynamicColor = DynamicColor;
1726
1395
  exports.SchemeEntity = SchemeEntity;
1396
+ exports.SchemeService = SchemeService;
1397
+ exports.ThemeModule = ThemeModule;
1398
+ exports.ThemeService = ThemeService;
1727
1399
  exports.ToneDeltaPair = ToneDeltaPair;
1728
1400
  exports.VariantEntity = VariantEntity;
1729
1401
  exports.VariantModel = VariantModel;
1402
+ exports.VariantService = VariantService;
1730
1403
  exports.defaultColors = defaultColors;
1731
1404
  exports.getRotatedHue = getRotatedHue;
1732
1405
  exports.highestSurface = highestSurface;
1406
+ exports.importContainer = importContainer;
1733
1407
  exports.main = main;
1734
1408
  //# sourceMappingURL=theme.cjs.development.js.map