@rpg-engine/long-bow 0.5.90 → 0.5.92

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.
@@ -14793,6 +14793,9 @@ var CraftBook = function CraftBook(_ref) {
14793
14793
  var _useState3 = React.useState(),
14794
14794
  size = _useState3[0],
14795
14795
  setSize = _useState3[1];
14796
+ var _useState4 = React.useState(false),
14797
+ isCraftingDisabled = _useState4[0],
14798
+ setIsCraftingDisabled = _useState4[1];
14796
14799
  React.useEffect(function () {
14797
14800
  var handleResize = function handleResize() {
14798
14801
  if (window.innerWidth < 500 && (size == null ? void 0 : size.width) !== mobilePortrait.width && (!scale || scale < 1)) {
@@ -14897,10 +14900,15 @@ var CraftBook = function CraftBook(_ref) {
14897
14900
  buttonType: exports.ButtonTypes.RPGUIButton,
14898
14901
  onPointerDown: onClose
14899
14902
  }, "Cancel"), React__default.createElement(Button, {
14900
- disabled: !craftItemKey,
14903
+ disabled: !craftItemKey || isCraftingDisabled,
14901
14904
  buttonType: exports.ButtonTypes.RPGUIButton,
14902
14905
  onPointerDown: function onPointerDown() {
14903
- return onCraftItem(craftItemKey);
14906
+ if (!craftItemKey || isCraftingDisabled) return;
14907
+ onCraftItem(craftItemKey);
14908
+ setIsCraftingDisabled(true);
14909
+ setTimeout(function () {
14910
+ setIsCraftingDisabled(false);
14911
+ }, 2000);
14904
14912
  }
14905
14913
  }, "Craft"))));
14906
14914
  };
@@ -18169,25 +18177,33 @@ var Shortcuts = function Shortcuts(_ref) {
18169
18177
  var _useShortcutCooldown = useShortcutCooldown(onShortcutCast),
18170
18178
  handleShortcutCast = _useShortcutCooldown.handleShortcutCast,
18171
18179
  shortcutCooldown = _useShortcutCooldown.shortcutCooldown;
18180
+ var handleKeyDown = React.useCallback(function (e) {
18181
+ if (isBlockedCastingByKeyboard) return;
18182
+ var shortcutIndex = Number(e.key) - 1;
18183
+ if (shortcutIndex >= 0 && shortcutIndex <= 11) {
18184
+ var _shortcutsRefs$curren;
18185
+ handleShortcutCast(shortcutIndex);
18186
+ (_shortcutsRefs$curren = shortcutsRefs.current[shortcutIndex]) == null ? void 0 : _shortcutsRefs$curren.classList.add('active');
18187
+ var timeoutId = setTimeout(function () {
18188
+ var _shortcutsRefs$curren2;
18189
+ (_shortcutsRefs$curren2 = shortcutsRefs.current[shortcutIndex]) == null ? void 0 : _shortcutsRefs$curren2.classList.remove('active');
18190
+ }, 150);
18191
+ // Store timeoutId for later cleanup
18192
+ timeoutIds.current.push(timeoutId);
18193
+ }
18194
+ }, [isBlockedCastingByKeyboard, handleShortcutCast]);
18195
+ // Initialize a ref to store the timeout ids
18196
+ var timeoutIds = React.useRef([]);
18172
18197
  React.useEffect(function () {
18173
- var handleKeyDown = function handleKeyDown(e) {
18174
- if (isBlockedCastingByKeyboard) return;
18175
- var shortcutIndex = Number(e.key) - 1;
18176
- if (shortcutIndex >= 0 && shortcutIndex <= 11) {
18177
- var _shortcutsRefs$curren;
18178
- handleShortcutCast(shortcutIndex);
18179
- (_shortcutsRefs$curren = shortcutsRefs.current[shortcutIndex]) == null ? void 0 : _shortcutsRefs$curren.classList.add('active');
18180
- setTimeout(function () {
18181
- var _shortcutsRefs$curren2;
18182
- (_shortcutsRefs$curren2 = shortcutsRefs.current[shortcutIndex]) == null ? void 0 : _shortcutsRefs$curren2.classList.remove('active');
18183
- }, 150);
18184
- }
18185
- };
18186
18198
  window.addEventListener('keydown', handleKeyDown);
18187
18199
  return function () {
18188
18200
  window.removeEventListener('keydown', handleKeyDown);
18201
+ // Clear all timeouts when the component unmounts
18202
+ timeoutIds.current.forEach(function (id) {
18203
+ return clearTimeout(id);
18204
+ });
18189
18205
  };
18190
- }, [shortcuts, isBlockedCastingByKeyboard, shortcutCooldown]);
18206
+ }, [handleKeyDown]);
18191
18207
  return React__default.createElement(List$1, null, Array.from({
18192
18208
  length: 12
18193
18209
  }).map(function (_, i) {