@udixio/theme 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 2.1.3 (2025-11-05)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **theme:** simplify tone calculation and enhance custom palette handling ([b7bb339](https://github.com/Udixio/UI/commit/b7bb339))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Joël VIGREUX
10
+
11
+ ## 2.1.2 (2025-10-17)
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - **theme, plugins-tailwind:** improve container caching and enhance debugging logs ([a8f955d](https://github.com/Udixio/UI/commit/a8f955d))
16
+
17
+ ### ❤️ Thank You
18
+
19
+ - Joël VIGREUX
20
+
1
21
  ## 2.1.1 (2025-10-17)
2
22
 
3
23
  ### 🩹 Fixes
@@ -1,4 +1,6 @@
1
- import { Resolver } from 'awilix';
1
+ import { AwilixContainer, Resolver } from 'awilix';
2
2
  export type Module = Record<string, Resolver<any>>;
3
- export declare const AppContainer: () => import('awilix').AwilixContainer<any>;
3
+ export declare const AppContainer: (options?: {
4
+ fresh?: boolean;
5
+ }) => AwilixContainer<any>;
4
6
  //# sourceMappingURL=app.container.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.container.d.ts","sourceRoot":"","sources":["../src/app.container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAOlE,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnD,eAAO,MAAM,YAAY,6CAuBxB,CAAC"}
1
+ {"version":3,"file":"app.container.d.ts","sourceRoot":"","sources":["../src/app.container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkC,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAOnF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAInD,eAAO,MAAM,YAAY,GAAI,UAAU;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,yBA4BzD,CAAC"}
package/dist/bin.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  const commander = require("commander");
3
3
  const chokidar = require("chokidar");
4
4
  const chalk = require("chalk");
5
- const loadFromPath = require("./load-from-path-Bvj18-eg.cjs");
5
+ const loadFromPath = require("./load-from-path-C3UAcZqv.cjs");
6
6
  const program = new commander.Command();
7
7
  async function runOnce(configPath) {
8
8
  try {
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Command } from "commander";
2
2
  import chokidar from "chokidar";
3
3
  import chalk from "chalk";
4
- import { l as loadFromPath } from "./load-from-path-CjLV8qqN.js";
4
+ import { l as loadFromPath } from "./load-from-path-BCh7ss_Z.js";
5
5
  const program = new Command();
6
6
  async function runOnce(configPath) {
7
7
  try {
package/dist/browser.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const loader = require("./loader-DuLiOKuW.cjs");
4
- const font_plugin = require("./font.plugin-Czq_-M7T.cjs");
3
+ const loader = require("./loader-BbjdPvAo.cjs");
4
+ const font_plugin = require("./font.plugin-CkYgSR9K.cjs");
5
5
  exports.API = loader.API;
6
6
  exports.AppContainer = loader.AppContainer;
7
7
  exports.AppModule = loader.AppModule;
package/dist/browser.js CHANGED
@@ -1,5 +1,5 @@
1
- import { A, a, b, h, i, C, j, k, e, f, o, n, q, D, P, r, s, v, u, V, z, c, d, m, F, g, w, x, l, p, G, B, t, y, E } from "./loader-Dy9GSe3X.js";
2
- import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-B2IbI3Qs.js";
1
+ import { A, a, b, h, i, C, j, k, e, f, o, n, q, D, P, r, s, v, u, V, z, c, d, m, F, g, w, x, l, p, G, B, t, y, E } from "./loader-C-8QkFag.js";
2
+ import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-BU5iUqHq.js";
3
3
  export {
4
4
  A as API,
5
5
  a as AppContainer,
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,GAAG,GAAG,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAEzB;;IAUP;;;;;;;;OAQG;IACH,MAAM,CAAC,iBAAiB,CAAC,CAAC,EACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAC5B;QAAE,MAAM,EAAE,CAAC,CAAC;QAAC,YAAY,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,CAAA;KAAE;IAsBjD,GAAG,CAAC,OAAO,EAAE,cAAc;IAqBpB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC;IA4B3C,OAAO,CAAC,UAAU;IAalB,IAAI,QAAQ,CAAC,MAAM,EAAE,OAAO,EAE3B;IACD,IAAI,MAAM,YAET;IAED,IAAI,aAAa,CAAC,aAAa,EAAE,MAAM,EAEtC;IACD,IAAI,aAAa,IAHgB,MAAM,CAKtC;IAED,IAAI,WAAW,CAAC,WAAW,EAAE,MAAM,EAElC;IACD,IAAI,WAAW,IAAI,GAAG,CAMrB;IAED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AE,MAAM,EAEtC;IACD,IAAI,aAAa,IAHgB,MAAM,CAKtC;IAED,IAAI,WAAW,CAAC,WAAW,EAAE,MAAM,EAElC;IACD,IAAI,WAAW,IAAI,GAAG,CAMrB;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAE3B;IACD,IAAI,OAAO,IAHU,OAAO,CAK3B;IAED,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC;IAW5D,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,KAAK,IAAI,GAAG,IAAI;CAG/D"}
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import "./loader-Dy9GSe3X.js";
4
+ import "./loader-C-8QkFag.js";
5
5
  class PluginAbstract {
6
6
  constructor(options) {
7
7
  __publicField(this, "options");
@@ -2,7 +2,7 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- require("./loader-DuLiOKuW.cjs");
5
+ require("./loader-BbjdPvAo.cjs");
6
6
  class PluginAbstract {
7
7
  constructor(options) {
8
8
  __publicField(this, "options");
@@ -1,4 +1,4 @@
1
- import { p as loader } from "./loader-Dy9GSe3X.js";
1
+ import { p as loader } from "./loader-C-8QkFag.js";
2
2
  import * as fs from "node:fs";
3
3
  async function resolveConfig(configPath = "./theme.config") {
4
4
  const { createJiti } = await import("jiti");
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
22
  mod
23
23
  ));
24
- const loader = require("./loader-DuLiOKuW.cjs");
24
+ const loader = require("./loader-BbjdPvAo.cjs");
25
25
  const fs = require("node:fs");
26
26
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
27
27
  function _interopNamespaceDefault(e) {
@@ -44,7 +44,7 @@ const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
44
44
  async function resolveConfig(configPath = "./theme.config") {
45
45
  const { createJiti } = await import("jiti");
46
46
  const { resolve } = await import("pathe");
47
- const jiti = createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("load-from-path-Bvj18-eg.cjs", document.baseURI).href, {
47
+ const jiti = createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("load-from-path-C3UAcZqv.cjs", document.baseURI).href, {
48
48
  debug: process.env.NODE_ENV === "development",
49
49
  fsCache: true,
50
50
  interopDefault: true
@@ -2526,8 +2526,7 @@ class Context {
2526
2526
  }
2527
2527
  set(options) {
2528
2528
  if (this._options) {
2529
- console.error(this._options);
2530
- throw new Error("Options already set");
2529
+ return this.update(options);
2531
2530
  }
2532
2531
  if (typeof options.sourceColor === "string") {
2533
2532
  options.sourceColor = Hct.fromInt(materialColorUtilities.argbFromHex(options.sourceColor));
@@ -2730,7 +2729,7 @@ class PaletteApi {
2730
2729
  Hct.fromInt(materialColorUtilities.argbFromHex(callback))
2731
2730
  );
2732
2731
  } else {
2733
- this.paletteManager.add(key, callback);
2732
+ this.paletteManager.addCustomPalette(key, callback);
2734
2733
  }
2735
2734
  });
2736
2735
  }
@@ -2760,8 +2759,13 @@ class PaletteManager {
2760
2759
  ...this._palettes
2761
2760
  };
2762
2761
  }
2763
- addCustomPalette(key, color) {
2764
- const palette = Palette.fromVariant(key, color, this.context);
2762
+ addCustomPalette(key, args) {
2763
+ let palette;
2764
+ if (args instanceof Hct) {
2765
+ palette = Palette.fromVariant(key, args, this.context);
2766
+ } else {
2767
+ palette = new Palette(key, args, this.context);
2768
+ }
2765
2769
  this.add(key, palette);
2766
2770
  this.colorApi.addFromCustomPalette(key);
2767
2771
  }
@@ -2797,7 +2801,14 @@ const PaletteModule = {
2797
2801
  paletteApi: awilix.asClass(PaletteApi).scoped(),
2798
2802
  paletteManager: awilix.asClass(PaletteManager).scoped()
2799
2803
  };
2800
- const AppContainer = () => {
2804
+ let cachedContainer = null;
2805
+ const AppContainer = (options) => {
2806
+ if (!(options == null ? void 0 : options.fresh) && cachedContainer) {
2807
+ return cachedContainer;
2808
+ }
2809
+ const container = awilix.createContainer({
2810
+ injectionMode: awilix.InjectionMode.PROXY
2811
+ });
2801
2812
  function registerModule(...modules) {
2802
2813
  modules.forEach((module2) => {
2803
2814
  Object.entries(module2).forEach(([name, moduleClass]) => {
@@ -2806,9 +2817,6 @@ const AppContainer = () => {
2806
2817
  });
2807
2818
  return AppContainer;
2808
2819
  }
2809
- const container = awilix.createContainer({
2810
- injectionMode: awilix.InjectionMode.PROXY
2811
- });
2812
2820
  registerModule(
2813
2821
  AppModule,
2814
2822
  PluginModule,
@@ -2816,6 +2824,7 @@ const AppContainer = () => {
2816
2824
  PaletteModule,
2817
2825
  ContextModule
2818
2826
  );
2827
+ cachedContainer = container;
2819
2828
  return container;
2820
2829
  };
2821
2830
  function bootstrap() {
@@ -3144,13 +3153,7 @@ const udixioVariant = variant({
3144
3153
  [colorKey]: {
3145
3154
  palette: () => palettes.get(colorKey),
3146
3155
  tone: () => {
3147
- if (ctx.variant.name === "neutral") {
3148
- return ctx.isDark ? tMinC(palettes.get(colorKey), 0, 98) : tMaxC(palettes.get(colorKey));
3149
- } else if (ctx.variant.name === "vibrant") {
3150
- return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
3151
- } else {
3152
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3153
- }
3156
+ return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3154
3157
  },
3155
3158
  isBackground: true,
3156
3159
  background: () => highestSurface(ctx, colors2),
@@ -2525,8 +2525,7 @@ class Context {
2525
2525
  }
2526
2526
  set(options) {
2527
2527
  if (this._options) {
2528
- console.error(this._options);
2529
- throw new Error("Options already set");
2528
+ return this.update(options);
2530
2529
  }
2531
2530
  if (typeof options.sourceColor === "string") {
2532
2531
  options.sourceColor = Hct.fromInt(argbFromHex(options.sourceColor));
@@ -2729,7 +2728,7 @@ class PaletteApi {
2729
2728
  Hct.fromInt(argbFromHex(callback))
2730
2729
  );
2731
2730
  } else {
2732
- this.paletteManager.add(key, callback);
2731
+ this.paletteManager.addCustomPalette(key, callback);
2733
2732
  }
2734
2733
  });
2735
2734
  }
@@ -2759,8 +2758,13 @@ class PaletteManager {
2759
2758
  ...this._palettes
2760
2759
  };
2761
2760
  }
2762
- addCustomPalette(key, color) {
2763
- const palette = Palette.fromVariant(key, color, this.context);
2761
+ addCustomPalette(key, args) {
2762
+ let palette;
2763
+ if (args instanceof Hct) {
2764
+ palette = Palette.fromVariant(key, args, this.context);
2765
+ } else {
2766
+ palette = new Palette(key, args, this.context);
2767
+ }
2764
2768
  this.add(key, palette);
2765
2769
  this.colorApi.addFromCustomPalette(key);
2766
2770
  }
@@ -2796,7 +2800,14 @@ const PaletteModule = {
2796
2800
  paletteApi: asClass(PaletteApi).scoped(),
2797
2801
  paletteManager: asClass(PaletteManager).scoped()
2798
2802
  };
2799
- const AppContainer = () => {
2803
+ let cachedContainer = null;
2804
+ const AppContainer = (options) => {
2805
+ if (!(options == null ? void 0 : options.fresh) && cachedContainer) {
2806
+ return cachedContainer;
2807
+ }
2808
+ const container = createContainer({
2809
+ injectionMode: InjectionMode.PROXY
2810
+ });
2800
2811
  function registerModule(...modules) {
2801
2812
  modules.forEach((module) => {
2802
2813
  Object.entries(module).forEach(([name, moduleClass]) => {
@@ -2805,9 +2816,6 @@ const AppContainer = () => {
2805
2816
  });
2806
2817
  return AppContainer;
2807
2818
  }
2808
- const container = createContainer({
2809
- injectionMode: InjectionMode.PROXY
2810
- });
2811
2819
  registerModule(
2812
2820
  AppModule,
2813
2821
  PluginModule,
@@ -2815,6 +2823,7 @@ const AppContainer = () => {
2815
2823
  PaletteModule,
2816
2824
  ContextModule
2817
2825
  );
2826
+ cachedContainer = container;
2818
2827
  return container;
2819
2828
  };
2820
2829
  function bootstrap() {
@@ -3143,13 +3152,7 @@ const udixioVariant = variant({
3143
3152
  [colorKey]: {
3144
3153
  palette: () => palettes.get(colorKey),
3145
3154
  tone: () => {
3146
- if (ctx.variant.name === "neutral") {
3147
- return ctx.isDark ? tMinC(palettes.get(colorKey), 0, 98) : tMaxC(palettes.get(colorKey));
3148
- } else if (ctx.variant.name === "vibrant") {
3149
- return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
3150
- } else {
3151
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3152
- }
3155
+ return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3153
3156
  },
3154
3157
  isBackground: true,
3155
3158
  background: () => highestSurface(ctx, colors2),
package/dist/node.cjs CHANGED
@@ -22,9 +22,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const loader = require("./loader-DuLiOKuW.cjs");
26
- const font_plugin = require("./font.plugin-Czq_-M7T.cjs");
27
- const loadFromPath = require("./load-from-path-Bvj18-eg.cjs");
25
+ const loader = require("./loader-BbjdPvAo.cjs");
26
+ const font_plugin = require("./font.plugin-CkYgSR9K.cjs");
27
+ const loadFromPath = require("./load-from-path-C3UAcZqv.cjs");
28
28
  let unpluginInstance = null;
29
29
  const createUnpluginTheme = async () => {
30
30
  if (unpluginInstance) {
package/dist/node.js CHANGED
@@ -1,7 +1,7 @@
1
- import { A, a, b, h, i, C, j, k, e, f, o, n, q, D, P, r, s, v, u, V, z, c, d, m, F, g, w, x, l, p, G, B, t, y, E } from "./loader-Dy9GSe3X.js";
2
- import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-B2IbI3Qs.js";
3
- import { l as loadFromPath } from "./load-from-path-CjLV8qqN.js";
4
- import { r as r2 } from "./load-from-path-CjLV8qqN.js";
1
+ import { A, a, b, h, i, C, j, k, e, f, o, n, q, D, P, r, s, v, u, V, z, c, d, m, F, g, w, x, l, p, G, B, t, y, E } from "./loader-C-8QkFag.js";
2
+ import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-BU5iUqHq.js";
3
+ import { l as loadFromPath } from "./load-from-path-BCh7ss_Z.js";
4
+ import { r as r2 } from "./load-from-path-BCh7ss_Z.js";
5
5
  let unpluginInstance = null;
6
6
  const createUnpluginTheme = async () => {
7
7
  if (unpluginInstance) {
@@ -11,7 +11,7 @@ export declare class PaletteManager {
11
11
  context: Context;
12
12
  colorApi: ColorApi;
13
13
  });
14
- addCustomPalette(key: string, color: Hct): void;
14
+ addCustomPalette(key: string, args: Hct | PaletteCallback): void;
15
15
  add(key: string, palette: PaletteCallback | Palette): void;
16
16
  get(key: 'primary' | 'secondary' | 'tertiary' | 'neutral' | 'neutralVariant' | 'error' | string): Palette;
17
17
  private set;
@@ -1 +1 @@
1
- {"version":3,"file":"palette.manager.d.ts","sourceRoot":"","sources":["../../src/palette/palette.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,M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AKhD;gBAEW,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE;IAW1D,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,eAAe,GAAG,IAAI;IAWhE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,GAAG,IAAI;IAS1D,GAAG,CACD,GAAG,EACC,SAAS,GACT,WAAW,GACX,UAAU,GACV,SAAS,GACT,gBAAgB,GAChB,OAAO,GACP,MAAM,GACT,OAAO;IAQV,OAAO,CAAC,GAAG;IAIX,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,GAAG,IAAI;CAS3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"udixio.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/udixio.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;AAuD9E,eAAO,MAAM,aAAa,EAAE,OAsxB1B,CAAC"}
1
+ {"version":3,"file":"udixio.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/udixio.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;AAuD9E,eAAO,MAAM,aAAa,EAAE,OA8wB1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udixio/theme",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "type": "module",
5
5
  "main": "./dist/node.js",
6
6
  "module": "./dist/node.js",
@@ -1,4 +1,4 @@
1
- import { createContainer, InjectionMode, Resolver } from 'awilix';
1
+ import { AwilixContainer, createContainer, InjectionMode, Resolver } from 'awilix';
2
2
  import { ColorModule } from './color';
3
3
  import { AppModule } from './app.module';
4
4
  import { PluginModule } from './plugin';
@@ -7,7 +7,17 @@ import { ContextModule } from './context';
7
7
 
8
8
  export type Module = Record<string, Resolver<any>>;
9
9
 
10
- export const AppContainer = () => {
10
+ let cachedContainer: AwilixContainer | null = null;
11
+
12
+ export const AppContainer = (options?: { fresh?: boolean }) => {
13
+ if (!options?.fresh && cachedContainer) {
14
+ return cachedContainer;
15
+ }
16
+
17
+ const container = createContainer({
18
+ injectionMode: InjectionMode.PROXY,
19
+ });
20
+
11
21
  function registerModule(...modules: Module[]) {
12
22
  modules.forEach((module) => {
13
23
  Object.entries(module).forEach(([name, moduleClass]) => {
@@ -17,10 +27,6 @@ export const AppContainer = () => {
17
27
  return AppContainer;
18
28
  }
19
29
 
20
- const container = createContainer({
21
- injectionMode: InjectionMode.PROXY,
22
- });
23
-
24
30
  registerModule(
25
31
  AppModule,
26
32
  PluginModule,
@@ -29,5 +35,6 @@ export const AppContainer = () => {
29
35
  ContextModule,
30
36
  );
31
37
 
38
+ cachedContainer = container;
32
39
  return container;
33
40
  };
@@ -60,8 +60,7 @@ export class Context {
60
60
 
61
61
  set(options: ContextOptions) {
62
62
  if (this._options) {
63
- console.error(this._options);
64
- throw new Error('Options already set');
63
+ return this.update(options);
65
64
  }
66
65
  if (typeof options.sourceColor === 'string') {
67
66
  options.sourceColor = Hct.fromInt(argbFromHex(options.sourceColor));
@@ -19,7 +19,7 @@ export class PaletteApi {
19
19
  Hct.fromInt(argbFromHex(callback)),
20
20
  );
21
21
  } else {
22
- this.paletteManager.add(key, callback);
22
+ this.paletteManager.addCustomPalette(key, callback);
23
23
  }
24
24
  });
25
25
  }
@@ -26,8 +26,13 @@ export class PaletteManager {
26
26
  );
27
27
  }
28
28
 
29
- addCustomPalette(key: string, color: Hct) {
30
- const palette = Palette.fromVariant(key, color, this.context);
29
+ addCustomPalette(key: string, args: Hct | PaletteCallback): void {
30
+ let palette: Palette;
31
+ if (args instanceof Hct) {
32
+ palette = Palette.fromVariant(key, args, this.context);
33
+ } else {
34
+ palette = new Palette(key, args, this.context);
35
+ }
31
36
  this.add(key, palette);
32
37
  this.colorApi.addFromCustomPalette(key);
33
38
  }
@@ -124,15 +124,7 @@ export const udixioVariant: Variant = variant({
124
124
  [colorKey]: {
125
125
  palette: () => palettes.get(colorKey),
126
126
  tone: () => {
127
- if (ctx.variant.name === 'neutral') {
128
- return ctx.isDark
129
- ? tMinC(palettes.get(colorKey), 0, 98)
130
- : tMaxC(palettes.get(colorKey));
131
- } else if (ctx.variant.name === 'vibrant') {
132
- return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
133
- } else {
134
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
135
- }
127
+ return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
136
128
  },
137
129
  isBackground: true,
138
130
  background: () => highestSurface(ctx, colors),