sia-reactor 0.0.48 → 0.0.49

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/dist/utils.cjs CHANGED
@@ -1201,29 +1201,29 @@ function cleanKeyCombo(combo, mods = KEYS_MODS) {
1201
1201
  };
1202
1202
  return Array.isArray(combo) ? combo.map(clean) : clean(combo);
1203
1203
  }
1204
- function matchKeys(required, actual, strict = false, clean = true) {
1204
+ function matchKeys(required, actual, strict = false, clean = true, allowedMods) {
1205
1205
  if (clean) actual = cleanKeyCombo(actual);
1206
1206
  const match = (req, actual2) => {
1207
1207
  req = cleanKeyCombo(req);
1208
1208
  if (strict) return req === actual2;
1209
1209
  const reqs = req.split("+"), reals = actual2.split("+");
1210
- for (const mod of KEYS_CMODS) if (reals.includes(mod) && !reqs.includes(mod)) return false;
1210
+ for (const mod of KEYS_CMODS) if (reals.includes(mod) && !reqs.includes(mod) && !allowedMods?.includes(mod)) return false;
1211
1211
  return reqs.every((k) => reals.includes(k));
1212
1212
  };
1213
1213
  return Array.isArray(required) ? required.some((req) => match(req, actual)) : match(required, actual);
1214
1214
  }
1215
1215
  function getTermsForKey(combo, settings) {
1216
- const terms = { override: false, block: false, whitelisted: false, action: null }, { overrides = [], shortcuts = {}, blocks = [], strictMatch: stm = false, rankedMatch: ram = true, whitelist = [] } = settings || {};
1216
+ const terms = { override: false, block: false, whitelisted: false, action: null }, { overrides = [], shortcuts = {}, blocks = [], strictMatch: stm = false, rankedMatch: ram = true, whitelist = [], moddedlist = [] } = settings || {};
1217
1217
  combo = cleanKeyCombo(combo);
1218
1218
  if (matchKeys(overrides, combo, stm, false)) terms.override = true;
1219
1219
  if (matchKeys(blocks, combo, stm, false)) terms.block = true;
1220
- if (matchKeys(whitelist, combo, false)) terms.whitelisted = true;
1221
- if (!ram) return terms.action = Object.keys(shortcuts).find((id) => shortcuts[id] && matchKeys(shortcuts[id], combo, stm, false)) || null, terms;
1220
+ if (whitelist.some((w) => matchKeys(w, combo, false, true, moddedlist.includes(cleanKeyCombo(w)) ? KEYS_CMODS : void 0))) terms.whitelisted = true;
1221
+ if (!ram) return terms.action = Object.keys(shortcuts).find((id) => shortcuts[id] && matchKeys(shortcuts[id], combo, stm, false, moddedlist.includes(id) ? KEYS_CMODS : void 0)) || null, terms;
1222
1222
  let bestA = null, bestE = false, bestL = 0;
1223
1223
  for (const id of Object.keys(shortcuts))
1224
1224
  for (const c of Array.isArray(shortcuts[id]) ? shortcuts[id] : [shortcuts[id]]) {
1225
1225
  const req = c && cleanKeyCombo(c), isE = req === combo, len = req ? req.split("+").length : 0;
1226
- if (c && matchKeys(req, combo, stm, false) && (!bestA || isE && !bestE || isE === bestE && len > bestL)) bestA = id, bestE = isE, bestL = len;
1226
+ if (c && matchKeys(req, combo, stm, false, moddedlist.includes(id) ? KEYS_CMODS : void 0) && (!bestA || isE && !bestE || isE === bestE && len > bestL)) bestA = id, bestE = isE, bestL = len;
1227
1227
  }
1228
1228
  return terms.action = bestA, terms;
1229
1229
  }