ronantakizawa/codereview-bench huggingface dataset:
Repository: penpot/penpot
File: render-wasm/src/main.rs (Rust)

Code before:
            }
        });
    });
}

#[no_mangle]
pub extern "C" fn clear_focus_mode() {
    with_state!(state, {
        state.clear_focus_mode();
    });
}

#[no_mangle]
pub extern "C" fn set_focus_mode() {
    let bytes = mem::bytes();

    let entries: Vec<Uuid> = bytes
        .chunks(16)
        .map(|bytes| {
            uuid_from_u32_quartet(
                u32::from_le_bytes([bytes[0], bytes[1], bytes[2], bytes[3]]),
                u32::from_le_bytes([bytes[4], bytes[5], bytes[6], bytes[7]]),
                u32::from_le_bytes([bytes[8], bytes[9], bytes[10], bytes[11]]),
                u32::from_le_bytes([bytes[12], bytes[13], bytes[14], bytes[15]]),
            )
        })
        .collect();
    with_state!(state, {
        state.set_focus_mode(entries);
    });
}

#[no_mangle]
pub extern "C" fn init_shapes_pool(capacity: usize) {
    with_state!(state, {
        state.init_shapes_pool(capacity);
    });
}

#[no_mangle]
pub extern "C" fn use_shape(a: u32, b: u32, c: u32, d: u32) {
    with_state!(state, {
        let id = uuid_from_u32_quartet(a, b, c, d);
        state.use_shape(id);
    });
}

#[no_mangle]
pub extern "C" fn set_parent(a: u32, b: u32, c: u32, d: u32) {
    with_current_shape!(state, |shape: &mut Shape| {
        let id = uuid_from_u32_quartet(a, b, c, d);

Review comment (suggestion):
Since these are UUIDs, we can benefit from the `from_bytes` method:

```suggestion
        .chunks(size_of::<<Uuid as SerializableResult>::BytesType>())
        .map(|data| Uuid::from_bytes(data.try_into().unwrap()))
```

Code after:
        });
    });
}

#[no_mangle]
pub extern "C" fn clear_focus_mode() {
    with_state!(state, {
        state.clear_focus_mode();
    });
}

#[no_mangle]
pub extern "C" fn set_focus_mode() {
    let bytes = mem::bytes();

    let entries: Vec<Uuid> = bytes
        .chunks(size_of::<<Uuid as SerializableResult>::BytesType>())
        .map(|data| Uuid::from_bytes(data.try_into().unwrap()))
        .collect();

    with_state!(state, {
        state.set_focus_mode(entries);
    });
}

#[no_mangle]
pub extern "C" fn init_shapes_pool(capacity: usize) {
    with_state!(state, {
        state.init_shapes_pool(capacity);
    });
}

#[no_mangle]
pub extern "C" fn use_shape(a: u32, b: u32, c: u32, d: u32) {
    with_state!(state, {
        let id = uuid_from_u32_quartet(a, b, c, d);
        state.use_shape(id);
    });
}

#[no_mangle]
pub extern "C" fn set_parent(a: u32, b: u32, c: u32, d: u32) {
    with_current_shape!(state, |shape: &mut Shape| {
        let id = uuid_from_u32_quartet(a, b, c, d);
        shape.set_parent(id);
    });
}

#[no_mangle]
pub extern "C" fn set_shape_masked_group(masked: bool) {
    with_current_shape!(state, |shape: &mut Shape| {
Repository: penpot/penpot
File: docker/images/build.sh (Shell)

Code before:
#!/usr/bin/env bash
set -x

IMAGE=${1:-backend}

OUTPUT="type=registry"

if [ "--local" = "$2" ]; then
    OUTPUT="type=docker"
fi

DOCKER_CLI_EXPERIMENTAL=enabled
ORG=${PENPOT_DOCKER_NAMESPACE:-penpotapp};
PLATFORM=${PENPOT_BUILD_PLATFORM:-linux/amd64,linux/arm64};
VERSION=${PENPOT_BUILD_VERSION:-latest}
DOCKER_IMAGE="$ORG/$IMAGE";
OPTIONS="-t $DOCKER_IMAGE:$VERSION";

IFS=", "
read -a TAGS <<< $PENPOT_BUILD_TAGS;

for element in "${TAGS[@]}"; do
    OPTIONS="$OPTIONS -t $DOCKER_IMAGE:$element";
done

docker buildx inspect penpot > /dev/null 2>&1;
docker run --privileged --rm tonistiigi/binfmt --install all > /dev/null;

if [ $? -eq 1 ]; then
    docker buildx create --name=penpot --use
    docker buildx inspect --bootstrap > /dev/null 2>&1;
else
    docker buildx use penpot;
    docker buildx inspect --bootstrap  > /dev/null 2>&1;
fi

unset IFS;

Review comment (suggestion):
This option (not sure if it's used in fact), but it seems to be deprecated; I suggest to remove it.
<img width="921" height="249" alt="image" src="https://github.com/user-attachments/assets/c799eedd-f025-4420-8daa-29463fd1d501" />


Code after:
#!/usr/bin/env bash
set -x

IMAGE=${1:-backend}

OUTPUT="type=registry"

if [ "--local" = "$2" ]; then
    OUTPUT="type=docker"
fi

ORG=${PENPOT_DOCKER_NAMESPACE:-penpotapp};
PLATFORM=${PENPOT_BUILD_PLATFORM:-linux/amd64,linux/arm64};
VERSION=${PENPOT_BUILD_VERSION:-latest}
DOCKER_IMAGE="$ORG/$IMAGE";
OPTIONS="-t $DOCKER_IMAGE:$VERSION";

IFS=", "
read -a TAGS <<< $PENPOT_BUILD_TAGS;

for element in "${TAGS[@]}"; do
    OPTIONS="$OPTIONS -t $DOCKER_IMAGE:$element";
done

docker buildx inspect penpot > /dev/null 2>&1;
docker run --privileged --rm tonistiigi/binfmt --install all > /dev/null;

if [ $? -eq 1 ]; then
    docker buildx create --name=penpot --use
    docker buildx inspect --bootstrap > /dev/null 2>&1;
else
    docker buildx use penpot;
    docker buildx inspect --bootstrap  > /dev/null 2>&1;
fi

unset IFS;
Repository: penpot/penpot
File: frontend/src/app/render_wasm/shape.cljs (ClojureScript)

Code before:
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC

(ns app.render-wasm.shape
  (:require
   [app.common.data :as d]
   [app.common.data.macros :as dm]
   [app.common.transit :as t]
   [app.common.types.shape :as shape]
   [app.common.types.shape.layout :as ctl]
   [app.render-wasm.api :as api]
   [beicon.v2.core :as rx]
   [clojure.core :as c]
   [cuerdas.core :as str]))

(declare ^:private impl-assoc)
(declare ^:private impl-conj)
(declare ^:private impl-dissoc)
(defonce ^:private current-page-object-ids #{})

(defn set-current-page-object-ids!
  [objects]
  (set! current-page-object-ids (set (keys objects))))

(defn shape-in-current-page?
  [shape-id]
  (contains? current-page-object-ids shape-id))

(defn map-entry
  [k v]
  (cljs.core/MapEntry. k v nil))

(deftype ShapeProxy [id type delegate]
  Object
  (toString [coll]
    (str "{" (str/join ", " (for [[k v] coll] (str k " " v))) "}"))

  (equiv [this other]
    (-equiv this other))

  ;; Marker protocol
  shape/IShape

  IWithMeta
  (-with-meta [_ meta]
    (ShapeProxy. id type (with-meta delegate meta)))

  IMeta

Review comment (suggestion):
This operation has more overhead than just having the whole map. So I suggest to put all the objects there and
rename the function to `set-current-page-objects!`

Code after:
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC

(ns app.render-wasm.shape
  (:require
   [app.common.data :as d]
   [app.common.data.macros :as dm]
   [app.common.transit :as t]
   [app.common.types.shape :as shape]
   [app.common.types.shape.layout :as ctl]
   [app.render-wasm.api :as api]
   [beicon.v2.core :as rx]
   [clojure.core :as c]
   [cuerdas.core :as str]))

(declare ^:private impl-assoc)
(declare ^:private impl-conj)
(declare ^:private impl-dissoc)
(defonce ^:private current-page-objects {})

(defn set-current-page-objects!
  [objects]
  (set! current-page-objects objects))

(defn shape-in-current-page?
  [shape-id]
  (contains? current-page-objects shape-id))

(defn map-entry
  [k v]
  (cljs.core/MapEntry. k v nil))

(deftype ShapeProxy [id type delegate]
  Object
  (toString [coll]
    (str "{" (str/join ", " (for [[k v] coll] (str k " " v))) "}"))

  (equiv [this other]
    (-equiv this other))

  ;; Marker protocol
  shape/IShape

  IWithMeta
  (-with-meta [_ meta]
    (ShapeProxy. id type (with-meta delegate meta)))

  IMeta
Repository: penpot/penpot
File: frontend/src/app/util/shape_icon.cljs (ClojureScript)

Code before:
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC

(ns app.util.shape-icon
  (:require
   [app.common.types.component :as ctk]
   [app.common.types.shape :as cts]
   [app.common.types.shape.layout :as ctl]))

(defn get-shape-icon*
  "Returns the icon for a shape based on its type and properties"
  [shape main-instance?]
  (let [flex-layout? (ctl/flex-layout? shape)
        col? (ctl/col? shape)
        row? (ctl/row? shape)
        grid-layout? (ctl/grid-layout? shape)
        has-images? (cts/has-images? shape)
        has-mask? (:masked-group shape)]
    (if (ctk/instance-head? shape)
      (if main-instance?
        (if (ctk/is-variant? shape)
          "variant"
          "component")
        "component-copy")
      (case (:type shape)
        :frame (cond
                 (ctk/is-variant-container? shape)
                 "component"

                 (and flex-layout? col?)
                 "flex-horizontal"

                 (and flex-layout? row?)
                 "flex-vertical"

                 grid-layout?
                 "flex-grid"

Review comment (suggestion):
The `main-instance?` can already be obtained from shape, so having it in an additional parameter looks strange

Code after:
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC

(ns app.util.shape-icon
  (:require
   [app.common.data.macros :as dm]
   [app.common.types.component :as ctk]
   [app.common.types.shape :as cts]
   [app.common.types.shape.layout :as ctl]))

(defn- get-bool-icon
  "Returns the icon for a boolean shape"
  [shape]
  (case (:bool-type shape)
    :difference   "boolean-difference"
    :exclude      "boolean-exclude"
    :intersection "boolean-intersection"
    nil))

(defn- get-frame-icon
  "Returns the icon for a frame shape"
  [shape]
  (cond
    (ctk/is-variant-container? shape)
    "component"

    (and (ctl/flex-layout? shape) (ctl/col? shape))
    "flex-horizontal"

    (and (ctl/flex-layout? shape) (ctl/row? shape))
    "flex-vertical"

    (ctl/grid-layout? shape)
    "flex-grid"

    :else
    "board"))
Repository: penpot/penpot
File: frontend/src/app/util/shape_icon.cljs (ClojureScript)

Code before:
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC

(ns app.util.shape-icon
  (:require
   [app.common.types.component :as ctk]
   [app.common.types.shape :as cts]
   [app.common.types.shape.layout :as ctl]))

(defn get-shape-icon*
  "Returns the icon for a shape based on its type and properties"
  [shape main-instance?]
  (let [flex-layout? (ctl/flex-layout? shape)
        col? (ctl/col? shape)
        row? (ctl/row? shape)
        grid-layout? (ctl/grid-layout? shape)
        has-images? (cts/has-images? shape)
        has-mask? (:masked-group shape)]
    (if (ctk/instance-head? shape)
      (if main-instance?
        (if (ctk/is-variant? shape)
          "variant"
          "component")
        "component-copy")
      (case (:type shape)
        :frame (cond
                 (ctk/is-variant-container? shape)
                 "component"

                 (and flex-layout? col?)
                 "flex-horizontal"

                 (and flex-layout? row?)
                 "flex-vertical"


Review comment (performance):
The `*` on the name usually indicates "private" or "low-level" version of a function. It is also used on component names. I think this case does not match that, so I suggest removing `*` from the function name.

Also, we can consider adding a lightweight cache, but i will done it myself once all suggested changes are addressed.

Code after:
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC

(ns app.util.shape-icon
  (:require
   [app.common.data.macros :as dm]
   [app.common.types.component :as ctk]
   [app.common.types.shape :as cts]
   [app.common.types.shape.layout :as ctl]))

(defn- get-bool-icon
  "Returns the icon for a boolean shape"
  [shape]
  (case (:bool-type shape)
    :difference   "boolean-difference"
    :exclude      "boolean-exclude"
    :intersection "boolean-intersection"
    nil))

(defn- get-frame-icon
  "Returns the icon for a frame shape"
  [shape]
  (cond
    (ctk/is-variant-container? shape)
    "component"

    (and (ctl/flex-layout? shape) (ctl/col? shape))
    "flex-horizontal"

    (and (ctl/flex-layout? shape) (ctl/row? shape))
    "flex-vertical"

    (ctl/grid-layout? shape)
    "flex-grid"
Repository: penpot/penpot
File: frontend/src/app/main/ui/components/search_bar.cljs (ClojureScript)

Code before:
        (mf/use-fn
         (mf/deps on-change)
         (fn [event]
           (let [value (dom/get-target-val event)]
             (on-change value event))))

        handle-clear
        (mf/use-fn
         (mf/deps on-clear on-change)
         (fn [event]
           (if on-clear
             (on-clear event)
             (on-change "" event))))

        handle-key-down
        (mf/use-fn
         (fn [event]
           (let [enter? (kbd/enter? event)
                 esc?   (kbd/esc? event)
                 node   (dom/get-target event)]
             (when ^boolean enter? (dom/blur! node))
             (when ^boolean esc? (dom/blur! node)))))]
    [:span {:class (stl/css-case :search-box true
                                 :has-children (some? children))}
     children
     [:div {:class (dm/str class " " (stl/css :search-input-wrapper))}
      (when icon-id
        [:> icon* {:icon-id icon-id
                   :size "s"
                   :class (stl/css :icon)}])
      [:input {:id id
               :on-change handle-change
               :value value
               :auto-focus auto-focus
               :auto-complete "off"
               :placeholder placeholder
               :on-key-down handle-key-down}]
      (when (not= "" value)
        [:button {:class (stl/css :clear-icon)
                  :on-click handle-clear}
         [:> icon* {:icon-id "delete-text"
                    :size "s"}]])]]))


Review comment (suggestion):
Minor enhancement: 

The class can be defined as `:class  [class (stl/css :search-input-wrapper)]` instead of explicit concat

Code after:
         (mf/deps on-change)
         (fn [event]
           (let [value (dom/get-target-val event)]
             (on-change value event))))

        handle-clear
        (mf/use-fn
         (mf/deps on-clear on-change)
         (fn [event]
           (if on-clear
             (on-clear event)
             (on-change "" event))))

        handle-key-down
        (mf/use-fn
         (fn [event]
           (let [enter? (kbd/enter? event)
                 esc?   (kbd/esc? event)
                 node   (dom/get-target event)]
             (when ^boolean enter? (dom/blur! node))
             (when ^boolean esc? (dom/blur! node)))))]
    [:span {:class (stl/css-case :search-box true
                                 :has-children (some? children))}
     children
     [:div {:class [class (stl/css :search-input-wrapper)]}
      (when icon-id
        [:> icon* {:icon-id icon-id
                   :size "s"
                   :class (stl/css :icon)}])
      [:input {:id id
               :on-change handle-change
               :value value
               :auto-focus auto-focus
               :auto-complete "off"
               :placeholder placeholder
               :on-key-down handle-key-down}]
      (when (not= "" value)
        [:button {:class (stl/css :clear-icon)
                  :on-click handle-clear}
         [:> icon* {:icon-id "delete-text"
                    :size "s"}]])]]))
Repository: penpot/penpot
File: frontend/text-editor/src/editor/controllers/SelectionController.js (JavaScript)

Code before:
      return this;
    }
    this.#selection.selectAllChildren(this.#textEditor.root);
    return this;
  }

  /**
   * Moves cursor to end.
   */
  cursorToEnd() {
    const range = document.createRange(); //Create a range (a range is a like the selection but invisible)
    range.selectNodeContents(this.#textEditor.element);
    range.collapse(false);
    this.#selection.removeAllRanges();
    this.#selection.addRange(range);
    return this;
  }

  /**
   * Collapses a selection.
   *
   * @param {Node} node
   * @param {number} offset
   */
  collapse(node, offset) {
    const nodeValue = node.nodeValue || "";
    const nodeOffset =
      node.nodeType === Node.TEXT_NODE && offset >= nodeValue.length
        ? nodeValue.length
        : offset;

    return this.setSelection(node, nodeOffset, node, nodeOffset);
  }

  /**
   * Sets base and extent.
   *
   * @param {Node} anchorNode
   * @param {number} anchorOffset
   * @param {Node} [focusNode=anchorNode]
   * @param {number} [focusOffset=anchorOffset]
   */
  setSelection(
    anchorNode,
    anchorOffset,
    focusNode = anchorNode,
    focusOffset = anchorOffset,
  ) {
    if (!anchorNode.isConnected) {
      throw new Error("Invalid anchorNode");
    }

Review comment (suggestion):
I think we could use the optional chaining operator `?.` (and the nullish coalescing `??`) in this case like this:

```javascript
const nodeValue = node?.nodeValue ?? "";
``` 

Code after:
      return this;
    }
    this.#selection.selectAllChildren(this.#textEditor.root);
    return this;
  }

  /**
   * Moves cursor to end.
   */
  cursorToEnd() {
    const range = document.createRange(); //Create a range (a range is a like the selection but invisible)
    range.selectNodeContents(this.#textEditor.element);
    range.collapse(false);
    this.#selection.removeAllRanges();
    this.#selection.addRange(range);
    return this;
  }

  /**
   * Collapses a selection.
   *
   * @param {Node} node
   * @param {number} offset
   */
  collapse(node, offset) {
    const nodeValue = node?.nodeValue ?? "";
    const nodeOffset =
      node.nodeType === Node.TEXT_NODE && offset >= nodeValue.length
        ? nodeValue.length
        : offset;

    return this.setSelection(node, nodeOffset, node, nodeOffset);
  }

  /**
   * Sets base and extent.
   *
   * @param {Node} anchorNode
   * @param {number} anchorOffset
   * @param {Node} [focusNode=anchorNode]
   * @param {number} [focusOffset=anchorOffset]
   */
  setSelection(
    anchorNode,
    anchorOffset,
    focusNode = anchorNode,
    focusOffset = anchorOffset,
  ) {
    if (!anchorNode.isConnected) {
      throw new Error("Invalid anchorNode");
    }
Repository: penpot/penpot
File: frontend/text-editor/src/editor/controllers/SelectionController.js (JavaScript)

Code before:
   *
   * @type {number}
   */
  get anchorOffset() {
    if (this.#savedSelection) {
      return this.#savedSelection.anchorOffset;
    }
    return this.#selection.anchorOffset;
  }

  /**
   * Indicates that the caret is at the start of the node.
   *
   * @type {boolean}
   */
  get anchorAtStart() {
    return this.anchorOffset === 0;
  }

  /**
   * Indicates that the caret is at the end of the node.
   *
   * @type {boolean}
   */
  get anchorAtEnd() {
    return this.anchorOffset === (this.anchorNode.nodeValue?.length || 0);
  }

  /**
   * Current or saved focus node.
   *
   * @type {Node}
   */
  get focusNode() {
    if (this.#savedSelection) {
      return this.#savedSelection.focusNode;
    }
    if (!this.#focusNode) console.trace("focusNode", this.#focusNode);
    return this.#focusNode;
  }

  /**
   * Current or saved focus offset.
   *
   * @type {number}
   */
  get focusOffset() {
    if (this.#savedSelection) {
      return this.#savedSelection.focusOffset;
    }
    return this.#focusOffset;

Review comment (suggestion):
Same here:

```javascript
    return this.anchorOffset === (this.anchorNode.nodeValue?.length ?? 0);
```

Code after:
   *
   * @type {number}
   */
  get anchorOffset() {
    if (this.#savedSelection) {
      return this.#savedSelection.anchorOffset;
    }
    return this.#selection.anchorOffset;
  }

  /**
   * Indicates that the caret is at the start of the node.
   *
   * @type {boolean}
   */
  get anchorAtStart() {
    return this.anchorOffset === 0;
  }

  /**
   * Indicates that the caret is at the end of the node.
   *
   * @type {boolean}
   */
  get anchorAtEnd() {
    return this.anchorOffset === (this.anchorNode.nodeValue?.length ?? 0);
  }

  /**
   * Current or saved focus node.
   *
   * @type {Node}
   */
  get focusNode() {
    if (this.#savedSelection) {
      return this.#savedSelection.focusNode;
    }
    if (!this.#focusNode) console.trace("focusNode", this.#focusNode);
    return this.#focusNode;
  }

  /**
   * Current or saved focus offset.
   *
   * @type {number}
   */
  get focusOffset() {
    if (this.#savedSelection) {
      return this.#savedSelection.focusOffset;
    }
    return this.#focusOffset;
Repository: penpot/penpot
File: frontend/src/app/main/ui/inspect/common/colors.cljs (ClojureScript)

Code before:

(ns app.main.ui.inspect.common.colors
  (:require
   [app.common.data.macros :as dm]
   [app.common.types.color :as cc]
   [app.main.store :as st]
   [okulary.core :as l]
   [rumext.v2 :as mf]))

(def file-colors-ref
  (l/derived (l/in [:viewer :file :data :colors]) st/state))

(defn make-colors-library-ref
  [libraries-place file-id]
  (let [get-library
        (fn [state]
          (get-in state [libraries-place file-id :data :colors]))]
    (l/derived get-library st/state)))

(defn use-colors-library
  [{:keys [ref-file] :as color}]
  (let [library (mf/with-memo [ref-file]
                  (make-colors-library-ref :files ref-file))]
    (mf/deref library)))

(defn color->color-space->css-format
  [color color-space]
  (let [color-value (:color color)
        color-opacity (or (:opacity color) 1)]
    (case color-space
      "hex"  color
      "rgba" (let [[r g b a] (cc/hex->rgba color-value color-opacity)]
               (dm/str "rgba(" (cc/format-rgba [r g b a]) ")"))
      "hsla" (let [[h s l a] (cc/hex->hsla color-value color-opacity)]
               (dm/str "hsla(" (cc/format-hsla [h s l a]) ")"))
      (:color color))))


Review comment (refactor):
I suggest simplify the name, it suggests it passes color to color-space y later to css-format and i think is not the case. My suggestion is `format-for-css`. We are already on color namespace so context is clear, and we going to format the color using css rules, using one of the provided color space.

Code after:
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC

(ns app.main.ui.inspect.common.colors
  (:require
   [app.main.store :as st]
   [okulary.core :as l]
   [rumext.v2 :as mf]))

(def file-colors-ref
  (l/derived (l/in [:viewer :file :data :colors]) st/state))

(defn make-colors-library-ref
  [libraries-place file-id]
  (let [get-library
        (fn [state]
          (get-in state [libraries-place file-id :data :colors]))]
    (l/derived get-library st/state)))

(defn use-colors-library
  [{:keys [ref-file] :as color}]
  (let [library (mf/with-memo [ref-file]
                  (make-colors-library-ref :files ref-file))]
    (mf/deref library)))