keycomfort 0.7.0 → 0.9.0

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/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # KEYCOMFORT
2
2
  Comfortable keyboard remaps for Karabiner.
3
3
 
4
+ > [!WARNING]
5
+ > Keycomfort is still in **beta**.
6
+ > There will be a lot of breaking changes until `v1.*`.
7
+
4
8
  ## Installation
5
9
  Keycomfort is a command line application.
6
10
  Install it via NPM with `-g` option.
@@ -11639,6 +11639,20 @@ var os=require$$0$2,fs=require$$3,fsp=require$$2,path=require$$3$1,node_stream=r
11639
11639
  */
11640
11640
  const isEmptyOrFalsey = isEmptyOrFalsy;
11641
11641
 
11642
+ /**
11643
+ * @class TypedArray
11644
+ */
11645
+ const TypedArray = Object.getPrototypeOf(Int8Array);
11646
+
11647
+ /**
11648
+ * Checks if the given value is an {@link TypedArray}.
11649
+ * @param {any} x
11650
+ * @return {boolean}
11651
+ */
11652
+ function isTypedArray(x) {
11653
+ return x instanceof TypedArray;
11654
+ }
11655
+
11642
11656
  /**
11643
11657
  * Removes "empty" values from the given object or array.
11644
11658
  * @param {object|any[]} x
@@ -11667,6 +11681,37 @@ var os=require$$0$2,fs=require$$3,fsp=require$$2,path=require$$3$1,node_stream=r
11667
11681
  return x;
11668
11682
  }
11669
11683
 
11684
+ /**
11685
+ * Recursively clones the given value (deep clone).
11686
+ * The given value won't be modified.
11687
+ * @param {any} x - Value to clone
11688
+ * @param {number} [recurse=8] - Recursion limit. Negative number means unlimited
11689
+ * @param {function} [fn] - Function to process each value. If nothing (or undefined) was returned by it, the value is handled normally
11690
+ * @return {any} Cloned value
11691
+ */
11692
+ function clone(x, recurse = 8, fn = undefined) {
11693
+ if (fn) {
11694
+ let r = fn(x);
11695
+ if (r !== undefined) return r;
11696
+ }
11697
+ if (x) {
11698
+ if (x instanceof TypedArray) {
11699
+ return x.subarray();
11700
+ }
11701
+ if (recurse) {
11702
+ if (Array.isArray(x)) {
11703
+ return x.map(it => clone(it, recurse - 1, fn));
11704
+ }
11705
+ if (typeof x == 'object') {
11706
+ let r = {};
11707
+ for (let k in x) r[k] = clone(x[k], recurse - 1, fn);
11708
+ return r;
11709
+ }
11710
+ }
11711
+ }
11712
+ return x;
11713
+ }
11714
+
11670
11715
  /**
11671
11716
  * Merges the 2nd object into the 1st object recursively (deep-merge). The 1st object will be modified.
11672
11717
  * @param {object} x - The 1st object
@@ -11743,7 +11788,7 @@ var os=require$$0$2,fs=require$$3,fsp=require$$2,path=require$$3$1,node_stream=r
11743
11788
  ? (_, m1) => (modifier(dig(data, m1), m1, data) || '')
11744
11789
  : (_, m1) => (dig(data, m1) || '')
11745
11790
  );
11746
- }var gen=/*#__PURE__*/Object.freeze({__proto__:null,arr:arr,clean:clean$1,dig:dig,is:is,isEmpty:isEmpty,isEmptyOrFalsey:isEmptyOrFalsey,isEmptyOrFalsy:isEmptyOrFalsy,merge:merge$1,subst:subst});/*!
11791
+ }var gen=/*#__PURE__*/Object.freeze({__proto__:null,TypedArray:TypedArray,arr:arr,clean:clean$1,clone:clone,dig:dig,is:is,isEmpty:isEmpty,isEmptyOrFalsey:isEmptyOrFalsey,isEmptyOrFalsy:isEmptyOrFalsy,isTypedArray:isTypedArray,merge:merge$1,subst:subst});/*!
11747
11792
  * === @amekusa/util.js/web === *
11748
11793
  * MIT License
11749
11794
  *
@@ -12190,14 +12235,7 @@ var os=require$$0$2,fs=require$$3,fsp=require$$2,path=require$$3$1,node_stream=r
12190
12235
  let {type, src} = item;
12191
12236
  let url;
12192
12237
 
12193
- if (!item.resolve) { // no resolution
12194
- url = src;
12195
- if (!type) type = typeMap[ext(src)] || 'asset';
12196
- console.log('---- File Link ----');
12197
- console.log(' type:', type);
12198
- console.log(' src:', src);
12199
-
12200
- } else { // needs resolution
12238
+ if (item.resolve) { // needs resolution
12201
12239
  let {dst:dstDir, as:dstFile} = item;
12202
12240
  let create = item.resolve == 'create'; // needs creation?
12203
12241
  if (create) {
@@ -12228,6 +12266,13 @@ var os=require$$0$2,fs=require$$3,fsp=require$$2,path=require$$3$1,node_stream=r
12228
12266
  console.log(' dst:', dst);
12229
12267
  tasks.push(fsp.copyFile(src, dst));
12230
12268
  }
12269
+
12270
+ } else { // no resolution
12271
+ url = src;
12272
+ if (!type) type = typeMap[ext(src)] || 'asset';
12273
+ console.log('---- File Link ----');
12274
+ console.log(' type:', type);
12275
+ console.log(' src:', src);
12231
12276
  }
12232
12277
 
12233
12278
  if (!item.private) {
@@ -12702,7 +12747,7 @@ var os=require$$0$2,fs=require$$3,fsp=require$$2,path=require$$3$1,node_stream=r
12702
12747
  }
12703
12748
  }
12704
12749
  });
12705
- }var test=/*#__PURE__*/Object.freeze({__proto__:null,InvalidTest:InvalidTest,assertEqual:assertEqual,assertProps:assertProps,assertType:assertType,testFn:testFn,testInstance:testInstance,testMethod:testMethod});amekusa_util.arr=arr;amekusa_util.clean=clean$1;amekusa_util.dig=dig;amekusa_util.gen=gen;amekusa_util.io=io;amekusa_util.is=is;amekusa_util.isEmpty=isEmpty;amekusa_util.isEmptyOrFalsey=isEmptyOrFalsey;amekusa_util.isEmptyOrFalsy=isEmptyOrFalsy;amekusa_util.merge=merge$1;amekusa_util.sh=sh;amekusa_util.subst=subst;amekusa_util.test=test;amekusa_util.time=time;amekusa_util.web=web;
12750
+ }var test=/*#__PURE__*/Object.freeze({__proto__:null,InvalidTest:InvalidTest,assertEqual:assertEqual,assertProps:assertProps,assertType:assertType,testFn:testFn,testInstance:testInstance,testMethod:testMethod});amekusa_util.TypedArray=TypedArray;amekusa_util.arr=arr;amekusa_util.clean=clean$1;amekusa_util.clone=clone;amekusa_util.dig=dig;amekusa_util.gen=gen;amekusa_util.io=io;amekusa_util.is=is;amekusa_util.isEmpty=isEmpty;amekusa_util.isEmptyOrFalsey=isEmptyOrFalsey;amekusa_util.isEmptyOrFalsy=isEmptyOrFalsy;amekusa_util.isTypedArray=isTypedArray;amekusa_util.merge=merge$1;amekusa_util.sh=sh;amekusa_util.subst=subst;amekusa_util.test=test;amekusa_util.time=time;amekusa_util.web=web;
12706
12751
  return amekusa_util;
12707
12752
  }var karabinerge = {};var hasRequiredKarabinerge;
12708
12753
 
@@ -14337,7 +14382,7 @@ function requireKarabinerge () {
14337
14382
  karabinerge.unless_var = unless_var;
14338
14383
  return karabinerge;
14339
14384
  }var name = "keycomfort";
14340
- var version = "0.7.0";
14385
+ var version = "0.9.0";
14341
14386
  var description = "Comfortable keyboard remaps for Karabiner/AutoHotKey";
14342
14387
  var require$$9 = {
14343
14388
  name: name,
@@ -14433,69 +14478,28 @@ function requireRules () {
14433
14478
  });
14434
14479
  },
14435
14480
 
14436
- 'prev/next word': {
14437
- apps: {
14438
- sonicpi(c, r) {
14439
- r.cond(modding)
14440
- .remap({
14441
- from: key(c.prev),
14442
- to: key('b', 'command')
14443
- })
14444
- .remap({
14445
- from: key(c.next),
14446
- to: key('f', 'command')
14447
- });
14448
- },
14449
- others(c, r) {
14450
- r.cond(modding)
14451
- .remap({
14452
- from: key(c.prev),
14453
- to: key('left_arrow', 'option')
14454
- })
14455
- .remap({
14456
- from: key(c.next),
14457
- to: key('right_arrow', 'option')
14458
- });
14459
- },
14460
- },
14481
+ 'prev/next word'(c, r) {
14482
+ r.cond(modding)
14483
+ .remap({
14484
+ from: key(c.prev),
14485
+ to: key(c.prev_to)
14486
+ })
14487
+ .remap({
14488
+ from: key(c.next),
14489
+ to: key(c.next_to)
14490
+ });
14461
14491
  },
14462
14492
 
14463
- 'line start/end': {
14464
- apps: {
14465
- terminal(c, r) {
14466
- r.cond(modding)
14467
- .remap({
14468
- from: key(c.start),
14469
- to: key('home')
14470
- })
14471
- .remap({
14472
- from: key(c.end),
14473
- to: key('end')
14474
- });
14475
- },
14476
- sonicpi(c, r) {
14477
- r.cond(modding)
14478
- .remap({
14479
- from: key(c.start),
14480
- to: key('a', 'control')
14481
- })
14482
- .remap({
14483
- from: key(c.end),
14484
- to: key('e', 'control')
14485
- });
14486
- },
14487
- others(c, r) {
14488
- r.cond(modding)
14489
- .remap({
14490
- from: key(c.start),
14491
- to: key('left_arrow', 'command')
14492
- })
14493
- .remap({
14494
- from: key(c.end),
14495
- to: key('right_arrow', 'command')
14496
- });
14497
- },
14498
- },
14493
+ 'line start/end'(c, r) {
14494
+ r.cond(modding)
14495
+ .remap({
14496
+ from: key(c.start),
14497
+ to: key(c.start_to)
14498
+ })
14499
+ .remap({
14500
+ from: key(c.end),
14501
+ to: key(c.end_to)
14502
+ });
14499
14503
  },
14500
14504
 
14501
14505
  'select'(c, r) {
@@ -14570,157 +14574,50 @@ function requireRules () {
14570
14574
  });
14571
14575
  },
14572
14576
 
14573
- 'delete line': {
14574
- apps: {
14575
- atom(c, r) {
14576
- r.cond(modding)
14577
- .remap({
14578
- from: key(c.key),
14579
- to: key('k', ['control', 'shift'])
14580
- });
14581
- },
14582
- vscode(c, r) {
14583
- r.cond(modding)
14584
- .remap({
14585
- from: key(c.key),
14586
- to: key('k', ['command', 'shift'])
14587
- });
14588
- },
14589
- eclipse(c, r) {
14590
- r.cond(modding)
14591
- .remap({
14592
- from: key(c.key),
14593
- to: key('d', 'command')
14594
- });
14595
- },
14596
- },
14597
- },
14598
-
14599
- 'insert line': {
14600
- apps: {
14601
- atom(c, r) {
14602
- r.cond(modding)
14603
- .remap({
14604
- from: key(c.key),
14605
- to: key('return_or_enter', 'command')
14606
- });
14607
- },
14608
- vscode(c, r) {
14609
- r.cond(modding)
14610
- .remap({
14611
- from: key(c.key),
14612
- to: key('return_or_enter', 'command')
14613
- });
14614
- },
14615
- eclipse(c, r) {
14616
- r.cond(modding)
14617
- .remap({
14618
- from: key(c.key),
14619
- to: key('return_or_enter', 'shift')
14620
- });
14621
- },
14622
- },
14623
- },
14624
-
14625
- 'move line': {
14626
- apps: {
14627
- atom(c, r) {
14628
- r.cond(modding)
14629
- .remap({
14630
- from: key(c.up),
14631
- to: key('up_arrow', ['command', 'control'])
14632
- })
14633
- .remap({
14634
- from: key(c.down),
14635
- to: key('down_arrow', ['command', 'control'])
14636
- });
14637
- },
14638
- vscode(c, r) {
14639
- r.cond(modding)
14640
- .remap({
14641
- from: key(c.up),
14642
- to: key('up_arrow', 'option')
14643
- })
14644
- .remap({
14645
- from: key(c.down),
14646
- to: key('down_arrow', 'option')
14647
- });
14648
- },
14649
- eclipse(c, r) {
14650
- r.cond(modding)
14651
- .remap({
14652
- from: key(c.up),
14653
- to: key('up_arrow', 'option')
14654
- })
14655
- .remap({
14656
- from: key(c.down),
14657
- to: key('down_arrow', 'option')
14658
- });
14659
- },
14660
- sonicpi(c, r) {
14661
- r.cond(modding)
14662
- .remap({
14663
- from: key(c.up),
14664
- to: key('p', ['command', 'control'])
14665
- })
14666
- .remap({
14667
- from: key(c.down),
14668
- to: key('n', ['command', 'control'])
14669
- });
14670
- },
14671
- },
14577
+ 'delete line'(c, r) {
14578
+ r.cond(modding)
14579
+ .remap({
14580
+ from: key(c.key),
14581
+ to: key(c.key_to)
14582
+ });
14672
14583
  },
14673
14584
 
14674
- 'left/right tab': {
14675
- apps: {
14676
- vscode(c, r) {
14677
- r.cond(modding)
14678
- .remap({
14679
- from: key(c.left),
14680
- to: key('left_arrow', ['command', 'option'])
14681
- })
14682
- .remap({
14683
- from: key(c.right),
14684
- to: key('right_arrow', ['command', 'option'])
14685
- });
14686
- },
14687
- eclipse(c, r) {
14688
- r.cond(modding)
14689
- .remap({
14690
- from: key(c.left),
14691
- to: key('page_up', 'control')
14692
- })
14693
- .remap({
14694
- from: key(c.right),
14695
- to: key('page_down', 'control')
14696
- });
14697
- },
14698
- others(c, r) {
14699
- r.cond(modding)
14700
- .remap({
14701
- from: key(c.left),
14702
- to: key('tab', ['control', 'shift'])
14703
- })
14704
- .remap({
14705
- from: key(c.right),
14706
- to: key('tab', 'control')
14707
- });
14708
- },
14709
- },
14585
+ 'insert line'(c, r) {
14586
+ r.cond(modding)
14587
+ .remap({
14588
+ from: key(c.key),
14589
+ to: key(c.key_to)
14590
+ });
14710
14591
  },
14711
14592
 
14712
- 'close/open tab'(c, r) {
14593
+ 'move line'(c, r) {
14713
14594
  r.cond(modding)
14714
14595
  .remap({
14715
- from: key(c.close),
14716
- to: key('w', 'command')
14596
+ from: key(c.up),
14597
+ to: key(c.up_to)
14717
14598
  })
14718
14599
  .remap({
14719
- from: key(c.open),
14720
- to: key('t', 'command')
14600
+ from: key(c.down),
14601
+ to: key(c.down_to)
14721
14602
  });
14722
14603
  },
14723
14604
 
14605
+ 'left/right tab'(c, r) {
14606
+ r.cond(modding);
14607
+ remap('left', 'left_to', c, r);
14608
+ remap('right', 'right_to', c, r);
14609
+ },
14610
+
14611
+ 'close/open tab'(c, r) {
14612
+ close_open_tab(c, r.cond(modding));
14613
+ },
14614
+
14615
+ 'go back/forward'(c, r) {
14616
+ r.cond(modding);
14617
+ remap('back', 'back_to', c, r);
14618
+ remap('forward', 'forward_to', c, r);
14619
+ },
14620
+
14724
14621
  'numpad'(c, r) {
14725
14622
  r.cond(modding)
14726
14623
  .remap({
@@ -14806,59 +14703,31 @@ function requireRules () {
14806
14703
  },
14807
14704
 
14808
14705
  'backslash'(c, r) {
14809
- r.cond(modding)
14810
- .remap({
14811
- from: key(c.from),
14812
- to: key(c.to)
14813
- });
14706
+ remap('from', 'to', c, r.cond(modding));
14814
14707
  },
14815
14708
 
14816
14709
  'backtick'(c, r) {
14817
- r.cond(modding)
14818
- .remap({
14819
- from: key(c.from),
14820
- to: key(c.to)
14821
- });
14710
+ remap('from', 'to', c, r.cond(modding));
14822
14711
  },
14823
14712
 
14824
14713
  'tilde'(c, r) {
14825
- r.cond(modding)
14826
- .remap({
14827
- from: key(c.from),
14828
- to: key(c.to)
14829
- });
14714
+ remap('from', 'to', c, r.cond(modding));
14830
14715
  },
14831
14716
 
14832
14717
  'pipe'(c, r) {
14833
- r.cond(modding)
14834
- .remap({
14835
- from: key(c.from),
14836
- to: key(c.to)
14837
- });
14718
+ remap('from', 'to', c, r.cond(modding));
14838
14719
  },
14839
14720
 
14840
14721
  'equal'(c, r) {
14841
- r.cond(modding)
14842
- .remap({
14843
- from: key(c.from),
14844
- to: key(c.to)
14845
- });
14722
+ remap('from', 'to', c, r.cond(modding));
14846
14723
  },
14847
14724
 
14848
14725
  'enter'(c, r) {
14849
- r.cond(modding)
14850
- .remap({
14851
- from: key(c.from),
14852
- to: key(c.to)
14853
- });
14726
+ remap('from', 'to', c, r.cond(modding));
14854
14727
  },
14855
14728
 
14856
14729
  'underscore'(c, r) {
14857
- r.cond(modding)
14858
- .remap({
14859
- from: key(c.from),
14860
- to: key(c.to)
14861
- });
14730
+ remap('from', 'to', c, r.cond(modding));
14862
14731
  },
14863
14732
 
14864
14733
  'custom'(c, r) {
@@ -14949,52 +14818,145 @@ function requireRules () {
14949
14818
  },
14950
14819
  },
14951
14820
 
14952
- 'mouse move'(c, r) {
14953
- r.cond(if_var(mouse_mode, 1))
14954
- .cond(if_touched(0));
14955
- mouse_move(c, r);
14821
+ 'mouse speed up/down': {
14822
+ 'mouse mode: on'(c, r) {
14823
+ if (c.touchpad) r.cond(if_touched(0));
14824
+ r.cond(if_var(mouse_mode, 1));
14825
+ mouse_speed(c, r);
14826
+ },
14827
+ 'thumb on touchpad'(c, r) {
14828
+ if (!c.touchpad) return false;
14829
+ r.cond(if_touched(1));
14830
+ mouse_speed(c, r);
14831
+ },
14956
14832
  },
14957
14833
 
14958
- 'mouse buttons'(c, r) {
14959
- r.cond(if_var(mouse_mode, 1))
14960
- .cond(if_touched(0));
14961
- mouse_buttons(c, r);
14834
+ 'mouse move': {
14835
+ 'mouse mode: on'(c, r) {
14836
+ if (c.touchpad) r.cond(if_touched(0));
14837
+ r.cond(if_var(mouse_mode, 1));
14838
+ mouse_move(c, r);
14839
+ },
14840
+ 'thumb on touchpad'(c, r) {
14841
+ if (!c.touchpad) return false;
14842
+ r.cond(if_touched(1));
14843
+ mouse_move(c, r);
14844
+ },
14962
14845
  },
14963
14846
 
14964
- 'mouse wheel up/down'(c, r) {
14965
- r.cond(if_var(mouse_mode, 1))
14966
- .cond(if_touched(0));
14967
- mouse_wheel_v(c, r);
14847
+ 'mouse buttons': {
14848
+ 'mouse mode: on'(c, r) {
14849
+ if (c.touchpad) r.cond(if_touched(0));
14850
+ r.cond(if_var(mouse_mode, 1));
14851
+ mouse_buttons(c, r);
14852
+ },
14853
+ 'thumb on touchpad'(c, r) {
14854
+ if (!c.touchpad) return false;
14855
+ r.cond(if_touched(1));
14856
+ mouse_buttons(c, r);
14857
+ },
14968
14858
  },
14969
14859
 
14970
- 'mouse wheel left/right'(c, r) {
14971
- r.cond(if_var(mouse_mode, 1))
14972
- .cond(if_touched(0));
14973
- mouse_wheel_h(c, r);
14860
+ 'mouse wheel up/down': {
14861
+ 'mouse mode: on'(c, r) {
14862
+ if (c.touchpad) r.cond(if_touched(0));
14863
+ r.cond(if_var(mouse_mode, 1));
14864
+ mouse_wheel_v(c, r);
14865
+ },
14866
+ 'thumb on touchpad'(c, r) {
14867
+ if (!c.touchpad) return false;
14868
+ r.cond(if_touched(1));
14869
+ mouse_wheel_v(c, r);
14870
+ },
14974
14871
  },
14975
14872
 
14976
- 'touch to mouse move'(c, r) {
14977
- r.cond(if_touched(1));
14978
- mouse_move(c, r);
14873
+ 'mouse wheel left/right': {
14874
+ 'mouse mode: on'(c, r) {
14875
+ if (c.touchpad) r.cond(if_touched(0));
14876
+ r.cond(if_var(mouse_mode, 1));
14877
+ mouse_wheel_h(c, r);
14878
+ },
14879
+ 'thumb on touchpad'(c, r) {
14880
+ if (!c.touchpad) return false;
14881
+ r.cond(if_touched(1));
14882
+ mouse_wheel_h(c, r);
14883
+ },
14979
14884
  },
14980
14885
 
14981
- 'touch to mouse buttons'(c, r) {
14982
- r.cond(if_touched(1));
14983
- mouse_buttons(c, r);
14886
+ 'mouse left/right tab': {
14887
+ 'mouse mode: on'(c, r) {
14888
+ if (c.touchpad) r.cond(if_touched(0));
14889
+ r.cond(if_var(mouse_mode, 1));
14890
+ remap('left', 'left_to', c, r);
14891
+ remap('right', 'right_to', c, r);
14892
+ },
14893
+ 'thumb on touchpad'(c, r) {
14894
+ if (!c.touchpad) return false;
14895
+ r.cond(if_touched(1));
14896
+ remap('left', 'left_to', c, r);
14897
+ remap('right', 'right_to', c, r);
14898
+ },
14984
14899
  },
14985
14900
 
14986
- 'touch to mouse wheel up/down'(c, r) {
14987
- r.cond(if_touched(1));
14988
- mouse_wheel_v(c, r);
14901
+ 'mouse close/open tab': {
14902
+ 'mouse mode: on'(c, r) {
14903
+ if (c.touchpad) r.cond(if_touched(0));
14904
+ r.cond(if_var(mouse_mode, 1));
14905
+ close_open_tab(c, r);
14906
+ },
14907
+ 'thumb on touchpad'(c, r) {
14908
+ if (!c.touchpad) return false;
14909
+ r.cond(if_touched(1));
14910
+ close_open_tab(c, r);
14911
+ },
14989
14912
  },
14990
14913
 
14991
- 'touch to mouse wheel left/right'(c, r) {
14992
- r.cond(if_touched(1));
14993
- mouse_wheel_h(c, r);
14914
+ 'mouse go back/forward': {
14915
+ 'mouse mode: on'(c, r) {
14916
+ if (c.touchpad) r.cond(if_touched(0));
14917
+ r.cond(if_var(mouse_mode, 1));
14918
+ remap('back', 'back_to', c, r);
14919
+ remap('forward', 'forward_to', c, r);
14920
+ },
14921
+ 'thumb on touchpad'(c, r) {
14922
+ if (!c.touchpad) return false;
14923
+ r.cond(if_touched(1));
14924
+ remap('back', 'back_to', c, r);
14925
+ remap('forward', 'forward_to', c, r);
14926
+ },
14994
14927
  },
14995
14928
 
14996
14929
  };
14997
14930
 
14931
+ function remap(from, to, c, r) {
14932
+ r.remap({
14933
+ from: key(c[from]),
14934
+ to: key(c[to])
14935
+ });
14936
+ }
14937
+
14938
+ function close_open_tab(c, r) {
14939
+ r.remap({
14940
+ from: key(c.close),
14941
+ to: key('w', 'command')
14942
+ })
14943
+ .remap({
14944
+ from: key(c.open),
14945
+ to: key('t', 'command')
14946
+ });
14947
+ }
14948
+
14949
+ function mouse_speed(c, r) {
14950
+ r.remap({
14951
+ from: key(c.up, any),
14952
+ to: {mouse_key: {speed_multiplier: c.up_to}}
14953
+ })
14954
+ .remap({
14955
+ from: key(c.down, any),
14956
+ to: {mouse_key: {speed_multiplier: c.down_to}}
14957
+ });
14958
+ }
14959
+
14998
14960
  function mouse_move(c, r) {
14999
14961
  let speed = Math.round(1536 * c.speed);
15000
14962
  r.remap({
@@ -15071,9 +15033,9 @@ function requireMain () {
15071
15033
 
15072
15034
  const {Command, Argument} = requireCommander();
15073
15035
  const yaml = require$$6;
15074
- const {io, merge, isEmpty} = requireAmekusa_util();
15036
+ const {io, clone, merge, isEmpty} = requireAmekusa_util();
15075
15037
  const {
15076
- RuleSet, Config,
15038
+ Rule, RuleSet, Config,
15077
15039
  if_app, unless_app,
15078
15040
  } = requireKarabinerge();
15079
15041
 
@@ -15108,7 +15070,7 @@ function requireMain () {
15108
15070
 
15109
15071
  const pkg = require$$9;
15110
15072
  const rules = requireRules();
15111
- const defaultsYML = "# === KEYCOMFORT CONFIG ===\n# NOTE:\n# 0 means \"No\"\n# 1 means \"Yes\"\n\npaths:\n karabiner:\n save_as: ~/.config/karabiner/assets/complex_modifications/keycomfort.json\n apply_to: ~/.config/karabiner/karabiner.json\n ahk:\n save_as: ~/Desktop/keycomfort.ahk\n apply_to:\n\nvim_like: 0 # prefer vim-like mappings?\n\nrules: # mapping rules\n\n modifier:\n desc: Use [key] as a special modifier key (Required)\n enable: 1\n key: spacebar\n alone: spacebar\n\n cancel modifier:\n desc: Cancel modifier (<modifier>) with [key]\n enable: 1\n key: left_shift\n\n disable modifier:\n desc: Disable modifier (<modifier>) with <modifier> + [key]\n enable: 1\n key: right_shift + escape\n\n enable modifier:\n desc: Enable modifier (<modifier>) with [key]\n enable: 1\n key: right_shift + escape\n\n arrows:\n desc: <modifier> + { [up] / [right] / [down] / [left] } = Up / Right / Down / Left\n enable: 1\n up: e\n right: f\n down: d\n left: s\n\n page up/down:\n desc: <modifier> + { [up] / [down] } = Page Up / Down\n enable: 1\n up: w\n down: r\n\n prev/next word:\n desc: <modifier> + { [prev] / [next] } = Prev / Next Word\n enable: 1\n prev: a\n next: g\n apps:\n sonicpi: 1\n others: 1\n\n line start/end:\n desc: <modifier> + { [start] / [end] } = Line Start / End\n enable: 1\n start: q\n end: t\n apps:\n terminal: 1\n sonicpi: 1\n others: 1\n\n select:\n desc: <modifier> + { [up] / [right] / [down] / [left] } = Select Up / Right / Down / Left\n enable: 1\n up: i\n right: l\n down: k\n left: j\n vim:\n left: h\n down: j\n up: k\n right: l\n\n indent/outdent:\n desc: <modifier> + { [indent] / [outdent] } = Indent / Outdent\n enable: 1\n indent: o\n outdent: u\n\n backspace/delete:\n desc: <modifier> + { [backspace] / [delete] } = Backspace / Delete\n enable: 1\n backspace: n\n delete: m\n\n delete word:\n desc: <modifier> + [key] = Delete Word\n enable: 1\n key: b\n\n edit:\n desc: <modifier> + { [undo] / [cut] / [copy] / [paste] } = Undo / Cut / Copy / Paste\n enable: 1\n undo: z\n cut: x\n copy: c\n paste: v\n\n delete line:\n desc: <modifier> + [key] = Delete Line\n enable: 1\n key: shift + m\n apps:\n atom: 1\n vscode: 1\n eclipse: 1\n\n insert line:\n desc: <modifier> + [key] = New Line Below\n enable: 1\n key: return_or_enter\n apps:\n atom: 1\n vscode: 1\n eclipse: 1\n\n move line:\n desc: <modifier> + { [up] / [down] } = Move Line Up / Down\n enable: 1\n up: shift + i\n down: shift + k\n vim:\n up: shift + k\n down: shift + j\n apps:\n atom: 1\n vscode: 1\n eclipse: 1\n sonicpi: 1\n\n left/right tab:\n desc: <modifier> + { [left] / [right] } = Left / Right Tab\n enable: 1\n left: 2\n right: 3\n apps:\n vscode: 1\n eclipse: 1\n others: 1\n\n close/open tab:\n desc: <modifier> + { [close] / [open] } = Close / Open Tab\n enable: 1\n close: 1\n open: 4\n\n numpad:\n desc: <modifier> + [trigger] = Numpad Mode ([num1]=1, [num5]=5, [num9]=9)\n enable: 1\n trigger: left_control\n\n num0: b\n num1: n\n num2: m\n num3: comma\n\n num4: j\n num5: k\n num6: l\n\n num7: u\n num8: i\n num9: o\n\n slash: 8\n asterisk: 9\n hyphen: 0\n plus: p\n\n enter: slash\n delete: semicolon\n backspace: h\n\n plus/minus:\n desc: <modifier> + { [plus] / [minus] } = Plus / Minus\n enable: 1\n plus: p\n minus: shift + p\n to:\n plus: shift + equal_sign\n minus: hyphen\n\n backslash:\n desc: <modifier> + [from] = Backslash\n enable: 1\n from: slash\n to: backslash\n\n backtick:\n desc: <modifier> + [from] = Backtick\n enable: 1\n from: quote\n to: grave_accent_and_tilde\n\n tilde:\n desc: <modifier> + [from] = Tilde\n enable: 1\n from: hyphen\n to: shift + grave_accent_and_tilde\n\n pipe:\n desc: <modifier> + [from] = Pipe\n enable: 1\n from: 7\n to: shift + backslash\n\n equal:\n desc: <modifier> + [from] = Equal Sign\n enable: 1\n from: semicolon\n to: equal_sign\n\n enter:\n desc: <modifier> + [from] = Enter\n enable: 1\n from: tab\n to: return_or_enter\n\n underscore:\n desc: <modifier> + [from] = Underscore\n enable: 1\n from: period\n to: shift + hyphen\n\n custom:\n desc: <modifier> + Custom Keys\n enable: 1\n rules:\n # Examples\n # - from: p\n # to: shift + equal_sign\n\n remap capslock:\n desc: Caps Lock = [to] / [alone]\n enable: 1\n to: left_control\n alone: escape\n\n remap l-control:\n desc: Left Control = [to] / [alone]\n enable: 1\n to: left_control\n alone: escape\n\n remap r-control:\n desc: Right Control = [to] / [alone]\n enable: 0\n to: right_control\n alone: escape\n\n remap l-command:\n desc: Left Command = [to] / [alone]\n enable: 0\n to: left_command\n alone: left_command\n\n remap r-command:\n desc: Right Command = [to] / [alone]\n enable: 0\n to: right_command\n alone: right_command\n\n remap l-shift:\n desc: Left Shift = [to] / [alone]\n enable: 0\n to: left_shift\n alone: left_shift\n\n remap r-shift:\n desc: Right Shift = [to] / [alone]\n enable: 0\n to: right_shift\n alone: right_shift\n\n mouse mode:\n desc: <modifier> + { [on] / [off] } = Mouse Mode On / Off\n enable: 1\n on: 9\n off: 0\n\n mouse move:\n desc: (Mouse Mode) [up] / [right] / [down] / [left] = Move Mouse Up / Right / Down / Left\n enable: 1\n up: e\n right: f\n down: d\n left: s\n speed: 1.0\n\n mouse buttons:\n desc: (Mouse Mode) [left] / [middle] / [right] = Mouse Buttons Left / Middle / Right\n enable: 1\n left: j\n middle: m\n right: l\n\n mouse wheel up/down:\n desc: (Mouse Mode) [up] / [down] = Mouse Wheel Up / Down\n enable: 1\n up: i\n down: k\n speed: 1.0\n\n mouse wheel left/right:\n desc: (Mouse Mode) [left] / [right] = Mouse Wheel Left / Right\n enable: 1\n left: h\n right: semicolon\n speed: 1.0\n\n touch to mouse move:\n desc: Touchpad + { [up] / [right] / [down] / [left] } = Move Mouse Up / Right / Down / Left\n enable: 1\n up: e\n right: f\n down: d\n left: s\n speed: 1.0\n\n touch to mouse buttons:\n desc: Touchpad + { [left] / [middle] / [right] } = Mouse Buttons Left / Middle / Right\n enable: 1\n left: j\n middle: m\n right: l\n\n touch to mouse wheel up/down:\n desc: Touchpad + { [up] / [down] } = Mouse Wheel Up / Down\n enable: 1\n up: i\n down: k\n speed: 1.0\n\n touch to mouse wheel left/right:\n desc: Touchpad + { [left] / [right] } = Mouse Wheel Left / Right\n enable: 1\n left: h\n right: semicolon\n speed: 1.0\n\n\napps:\n others:\n enable: 1\n\n login:\n enable: 1\n id:\n - com.apple.loginwindow\n\n terminal:\n enable: 1\n id:\n - com.apple.Terminal\n - com.googlecode.iterm2\n - org.alacritty\n exe:\n - cmd.exe\n\n vscode:\n enable: 0\n id:\n - com.microsoft.VSCode\n - com.vscodium\n exe:\n - Code.exe\n\n atom:\n enable: 0\n id:\n - com.github.atom\n - dev.pulsar-edit.pulsar\n\n eclipse:\n enable: 0\n id:\n - org.eclipse.platform.ide\n exe:\n - eclipse.exe\n\n sonicpi:\n enable: 0\n id:\n - net.sonic-pi.app\n\n\nkey_labels: # display names for key codes\n spacebar: Space\n return_or_enter: Enter\n grave_accent_and_tilde: Backtick\n button1: Left Click\n button2: Right Click\n button3: Middle Click\n japanese_eisuu: 英数\n japanese_kana: かな\n\n";
15073
+ const defaultsYML = "# === KEYCOMFORT CONFIG ===\n# NOTE:\n# 0 means \"No\"\n# 1 means \"Yes\"\n\npaths:\n karabiner:\n save_as: ~/.config/karabiner/assets/complex_modifications/keycomfort.json\n apply_to: ~/.config/karabiner/karabiner.json\n ahk:\n save_as: ~/Desktop/keycomfort.ahk\n apply_to:\n\nvim_like: 0 # prefer vim-like mappings?\n\nrules: # mapping rules\n\n modifier:\n desc: Use [key] as a special modifier key (Required)\n enable: 1\n key: spacebar\n alone: spacebar\n\n cancel modifier:\n desc: Cancel modifier (<modifier>) with [key]\n enable: 1\n key: left_shift\n\n disable modifier:\n desc: Disable modifier (<modifier>) with <modifier> + [key]\n enable: 1\n key: right_shift + escape\n\n enable modifier:\n desc: Enable modifier (<modifier>) with [key]\n enable: 1\n key: right_shift + escape\n\n arrows:\n desc: <modifier> + { [up] / [right] / [down] / [left] } = Up / Right / Down / Left\n enable: 1\n up: e\n right: f\n down: d\n left: s\n\n page up/down:\n desc: <modifier> + { [up] / [down] } = Page Up / Down\n enable: 1\n up: w\n down: r\n\n prev/next word:\n desc: <modifier> + { [prev] / [next] } = Prev / Next Word\n enable: 1\n prev: a\n next: g\n apps:\n sonicpi:\n prev_to: command + b\n next_to: command + f\n others:\n prev_to: option + left_arrow\n next_to: option + right_arrow\n\n line start/end:\n desc: <modifier> + { [start] / [end] } = Line Start / End\n enable: 1\n start: q\n end: t\n apps:\n terminal:\n start_to: home\n end_to: end\n sonicpi:\n start_to: control + a\n end_to: control + e\n others:\n start_to: command + left_arrow\n end_to: command + right_arrow\n\n select:\n desc: <modifier> + { [up] / [right] / [down] / [left] } = Select Up / Right / Down / Left\n enable: 1\n up: i\n right: l\n down: k\n left: j\n vim:\n left: h\n down: j\n up: k\n right: l\n\n indent/outdent:\n desc: <modifier> + { [indent] / [outdent] } = Indent / Outdent\n enable: 1\n indent: o\n outdent: u\n\n backspace/delete:\n desc: <modifier> + { [backspace] / [delete] } = Backspace / Delete\n enable: 1\n backspace: n\n delete: m\n\n delete word:\n desc: <modifier> + [key] = Delete Word\n enable: 1\n key: b\n\n edit:\n desc: <modifier> + { [undo] / [cut] / [copy] / [paste] } = Undo / Cut / Copy / Paste\n enable: 1\n undo: z\n cut: x\n copy: c\n paste: v\n\n delete line:\n desc: <modifier> + [key] = Delete Line\n enable: 1\n key: shift + m\n apps:\n atom:\n key_to: control + shift + k\n vscode:\n key_to: command + shift + k\n eclipse:\n key_to: command + d\n\n insert line:\n desc: <modifier> + [key] = New Line Below\n enable: 1\n key: return_or_enter\n apps:\n atom:\n key_to: command + return_or_enter\n vscode:\n key_to: command + return_or_enter\n eclipse:\n key_to: shift + return_or_enter\n\n move line:\n desc: <modifier> + { [up] / [down] } = Move Line Up / Down\n enable: 1\n up: shift + i\n down: shift + k\n vim:\n up: shift + k\n down: shift + j\n apps:\n atom:\n up_to: command + control + up_arrow\n down_to: command + control + down_arrow\n vscode:\n up_to: option + up_arrow\n down_to: option + down_arrow\n eclipse:\n up_to: option + up_arrow\n down_to: option + down_arrow\n sonicpi:\n up_to: command + control + p\n down_to: command + control + n\n\n left/right tab:\n desc: <modifier> + { [left] / [right] } = Left / Right Tab\n enable: 1\n left: 2\n right: 3\n apps:\n vscode:\n left_to: command + option + left_arrow\n right_to: command + option + right_arrow\n eclipse:\n left_to: control + page_up\n right_to: control + page_down\n sonicpi:\n left_to: command + shift + open_bracket\n right_to: command + shift + close_bracket\n others:\n left_to: control + shift + tab\n right_to: control + tab\n\n close/open tab:\n desc: <modifier> + { [close] / [open] } = Close / Open Tab\n enable: 1\n close: 1\n open: 4\n\n go back/forward:\n desc: <modifier> + { [back] / [forward] } = Go Back / Forward\n enable: 1\n back: control + q\n forward: control + w\n apps:\n filemanager:\n back_to: command + open_bracket\n forward_to: command + close_bracket\n browser:\n back_to: command + left_arrow\n forward_to: command + right_arrow\n\n numpad:\n desc: <modifier> + [trigger] = Numpad Mode ([num1]=1, [num5]=5, [num9]=9)\n enable: 1\n trigger: left_control\n\n num0: b\n num1: n\n num2: m\n num3: comma\n\n num4: j\n num5: k\n num6: l\n\n num7: u\n num8: i\n num9: o\n\n slash: 8\n asterisk: 9\n hyphen: 0\n plus: p\n\n enter: slash\n delete: semicolon\n backspace: h\n\n plus/minus:\n desc: <modifier> + { [plus] / [minus] } = Plus / Minus\n enable: 1\n plus: p\n minus: shift + p\n to:\n plus: shift + equal_sign\n minus: hyphen\n\n backslash:\n desc: <modifier> + [from] = Backslash\n enable: 1\n from: slash\n to: backslash\n\n backtick:\n desc: <modifier> + [from] = Backtick\n enable: 1\n from: quote\n to: grave_accent_and_tilde\n\n tilde:\n desc: <modifier> + [from] = Tilde\n enable: 1\n from: hyphen\n to: shift + grave_accent_and_tilde\n\n pipe:\n desc: <modifier> + [from] = Pipe\n enable: 1\n from: 7\n to: shift + backslash\n\n equal:\n desc: <modifier> + [from] = Equal Sign\n enable: 1\n from: semicolon\n to: equal_sign\n\n enter:\n desc: <modifier> + [from] = Enter\n enable: 1\n from: tab\n to: return_or_enter\n\n underscore:\n desc: <modifier> + [from] = Underscore\n enable: 1\n from: period\n to: shift + hyphen\n\n custom:\n desc: <modifier> + Custom Keys\n enable: 1\n rules:\n # Examples\n # - from: p\n # to: shift + equal_sign\n\n remap capslock:\n desc: Caps Lock = [to] / [alone]\n enable: 1\n to: left_control\n alone: escape\n\n remap l-control:\n desc: Left Control = [to] / [alone]\n enable: 1\n to: left_control\n alone: escape\n\n remap r-control:\n desc: Right Control = [to] / [alone]\n enable: 0\n to: right_control\n alone: escape\n\n remap l-command:\n desc: Left Command = [to] / [alone]\n enable: 0\n to: left_command\n alone: left_command\n\n remap r-command:\n desc: Right Command = [to] / [alone]\n enable: 0\n to: right_command\n alone: right_command\n\n remap l-shift:\n desc: Left Shift = [to] / [alone]\n enable: 0\n to: left_shift\n alone: left_shift\n\n remap r-shift:\n desc: Right Shift = [to] / [alone]\n enable: 0\n to: right_shift\n alone: right_shift\n\n mouse mode:\n desc: <modifier> + { [on] / [off] } = Mouse Mode On / Off\n enable: 1\n on: 9\n off: 0\n\n mouse speed up/down:\n desc: (Mouse) [up] / [down] = Mouse Speed Up / Down\n enable: 1\n touchpad: 1\n up: quote\n up_to: 1.5\n down: semicolon\n down_to: .5\n\n mouse move:\n desc: (Mouse) [up] / [right] / [down] / [left] = Move Mouse Up / Right / Down / Left\n enable: 1\n touchpad: 1\n up: e\n right: f\n down: d\n left: s\n speed: 1.0\n\n mouse buttons:\n desc: (Mouse) [left] / [middle] / [right] = Mouse Buttons Left / Middle / Right\n enable: 1\n touchpad: 1\n left: j\n middle: h\n right: l\n\n mouse wheel up/down:\n desc: (Mouse) [up] / [down] = Mouse Wheel Up / Down\n enable: 1\n touchpad: 1\n up: i\n down: k\n speed: 1.0\n\n mouse wheel left/right:\n desc: (Mouse) [left] / [right] = Mouse Wheel Left / Right\n enable: 1\n touchpad: 1\n left: u\n right: o\n speed: 1.0\n\n mouse left/right tab:\n desc: (Mouse) [left] / [right] = Left/Right Tab\n enable: 1\n touchpad: 1\n left: n\n right: m\n apps:\n vscode:\n left_to: command + option + left_arrow\n right_to: command + option + right_arrow\n eclipse:\n left_to: control + page_up\n right_to: control + page_down\n others:\n left_to: control + shift + tab\n right_to: control + tab\n\n mouse close/open tab:\n desc: (Mouse) [close] / [open] = Close / Open Tab\n enable: 1\n touchpad: 1\n close: b\n open: comma\n\n mouse go back/forward:\n desc: (Mouse) [back] / [forward] = Go Back / Forward\n enable: 1\n touchpad: 1\n back: y\n forward: p\n apps:\n filemanager:\n back_to: command + open_bracket\n forward_to: command + close_bracket\n browser:\n back_to: command + left_arrow\n forward_to: command + right_arrow\n\n\napps:\n others:\n enable: 1\n\n filemanager:\n enable: 1\n id:\n - com.apple.finder\n exe:\n - explorer.exe\n\n browser:\n enable: 1\n id:\n - org.mozilla.firefox\n - com.apple.Safari\n - org.chromium.Chromium\n - com.google.Chrome\n exe:\n - firefox.exe\n - msedge.exe\n - chromium.exe\n\n terminal:\n enable: 1\n id:\n - com.apple.Terminal\n - com.googlecode.iterm2\n - org.alacritty\n exe:\n - cmd.exe\n\n vscode:\n enable: 0\n id:\n - com.microsoft.VSCode\n - com.vscodium\n exe:\n - Code.exe\n\n atom:\n enable: 0\n id:\n - com.github.atom\n - dev.pulsar-edit.pulsar\n\n eclipse:\n enable: 0\n id:\n - org.eclipse.platform.ide\n exe:\n - eclipse.exe\n\n sonicpi:\n enable: 0\n id:\n - net.sonic-pi.app\n\n\nkey_labels: # display names for key codes\n spacebar: Space\n return_or_enter: Enter\n grave_accent_and_tilde: Backtick\n button1: Left Click\n button2: Right Click\n button3: Middle Click\n japanese_eisuu: 英数\n japanese_kana: かな\n\n";
15112
15074
  const defaults = yaml.parse(defaultsYML);
15113
15075
  const defaultConfig = loc(io.home, '.config', 'keycomfort', 'config.yml');
15114
15076
 
@@ -15295,9 +15257,21 @@ function requireMain () {
15295
15257
 
15296
15258
  let ruleSet = new RuleSet('KeyComfort');
15297
15259
 
15298
- function addRule(rule, rc, desc = undefined) {
15299
- // overwrite conf with vim-like mappings
15300
- if (vim && rc.vim) rc = merge(rc, rc.vim);
15260
+ /**
15261
+ * @param {function|object} rule - Rule definition
15262
+ * @param {object} rc - Rule config
15263
+ * @param {string} [desc] - Rule description
15264
+ * @param {function} [fn] - Rule modifier
15265
+ * @return {mixed} Forwards the return value of `rule` if it's a function
15266
+ */
15267
+ function addRule(rule, rc, desc = undefined, fn = undefined) {
15268
+ rc = clone(rc);
15269
+
15270
+ // override config with vim-like mappings
15271
+ if (rc.vim && vim) {
15272
+ rc = merge(rc, rc.vim);
15273
+ delete rc.vim;
15274
+ }
15301
15275
 
15302
15276
  // format rule description
15303
15277
  if (!desc) {
@@ -15306,48 +15280,59 @@ function requireMain () {
15306
15280
  });
15307
15281
  }
15308
15282
 
15309
- // apply rule
15310
- if (typeof rule == 'function') {
15311
- rule(rc, ruleSet.add(desc));
15312
- return;
15313
- }
15314
-
15315
- // apply app-specific rules
15316
- if (rule.apps) {
15317
- let newRule;
15283
+ // override config with app-specific mappings
15284
+ if (rc.apps) {
15318
15285
  let enabled = []; // enabled apps
15319
- for (let app in rule.apps) {
15320
- if (app == 'others') continue;
15321
- if (!apps[app]) continue; // uknown app
15322
- if (!apps[app].enable) continue; // globally disabled
15323
- if (!rc.apps[app]) continue; // disabled for this rule
15324
- if (isEmpty(apps[app].id)) continue; // no app-id
15325
- enabled = enabled.concat(apps[app].id);
15326
- newRule = ruleSet.add(desc + ` (${app})`);
15327
- newRule.cond(if_app(...apps[app].id));
15328
- rule.apps[app](rc, newRule);
15286
+ for (let k in rc.apps) {
15287
+ if (k == 'others') continue;
15288
+ let app = apps[k];
15289
+ if (!app || !app.enable || isEmpty(app.id)) continue;
15290
+ let v = rc.apps[k];
15291
+ if (!v) continue;
15292
+ let _rc = clone(rc); delete _rc.apps;
15293
+ let fn = newRule => newRule.cond(if_app(...app.id));
15294
+ let ret = addRule(rule, merge(_rc, v), `${desc} (app: ${k})`, fn); // #RECURSE
15295
+ if (ret !== false) {
15296
+ enabled = enabled.concat(app.id);
15297
+ }
15329
15298
  }
15330
15299
  if (apps.others.enable && rc.apps.others) {
15331
- newRule = ruleSet.add(desc);
15332
- if (enabled.length) newRule.cond(unless_app(...enabled));
15333
- rule.apps.others(rc, newRule);
15300
+ let _rc = clone(rc); delete _rc.apps;
15301
+ let fn;
15302
+ if (enabled.length) {
15303
+ fn = newRule => newRule.cond(unless_app(...enabled));
15304
+ desc = `${desc} (app: others)`;
15305
+ }
15306
+ addRule(rule, merge(_rc, rc.apps.others), desc, fn); // #RECURSE
15334
15307
  }
15335
- delete rule.apps;
15308
+ return;
15336
15309
  }
15337
15310
 
15338
- // apply branching rules
15339
- for (let k in rule) {
15340
- addRule(rule[k], rc, `${desc} :: ${k}`); // RECURSION
15311
+ switch (typeof rule) {
15312
+ case 'function': // apply rule
15313
+ let newRule = new Rule(desc);
15314
+ if (fn) newRule = fn(newRule);
15315
+ let ret = rule(rc, newRule);
15316
+ if (ret !== false) {
15317
+ ruleSet.add(newRule);
15318
+ }
15319
+ return ret;
15320
+
15321
+ case 'object': // branching rules
15322
+ for (let k in rule) {
15323
+ addRule(rule[k], rc, `${desc} (${k})`, fn); // #RECURSE
15324
+ }
15325
+ return;
15326
+
15327
+ default:
15328
+ throw new Error(`invalid rule definition`, {cause: rule});
15341
15329
  }
15342
15330
  }
15343
15331
 
15332
+ // add rules
15344
15333
  for (let i in rules) {
15345
- // rule config
15346
- let rc = config.rules[i];
15347
- if (!rc) continue;
15348
- if (!rc.enable) continue; // rule disabled
15349
-
15350
- addRule(rules[i], rc);
15334
+ let rc = config.rules[i]; // rule config
15335
+ if (rc && rc.enable) addRule(rules[i], rc);
15351
15336
  }
15352
15337
 
15353
15338
  let data = ruleSet.toJSON();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycomfort",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Comfortable keyboard remaps for Karabiner/AutoHotKey",
5
5
  "files": [
6
6
  "dist/keycomfort.js"
@@ -34,12 +34,12 @@
34
34
  "author": "Satoshi Soma (https://amekusa.com)",
35
35
  "license": "MIT",
36
36
  "devDependencies": {
37
- "@amekusa/util.js": "^2.2.0",
37
+ "@amekusa/util.js": "^2.3.0",
38
38
  "@rollup/plugin-commonjs": "^29.0.0",
39
39
  "@rollup/plugin-json": "^6.1.0",
40
40
  "@rollup/plugin-node-resolve": "^16.0.3",
41
41
  "@rollup/plugin-replace": "^6.0.3",
42
- "commander": "^14.0.2",
42
+ "commander": "^14.0.3",
43
43
  "karabinerge": "^2.2.1",
44
44
  "yaml": "^2.8.2"
45
45
  }