aleman 1.8.0 → 1.9.1

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 CHANGED
@@ -1,3 +1,13 @@
1
+ 2025.09.14, v1.9.1
2
+
3
+ feature:
4
+ - f6f0d8d aleman: menu: add link fallback
5
+
6
+ 2025.09.14, v1.9.0
7
+
8
+ feature:
9
+ - cb8b8bc aleman: menu: add support of $, ^
10
+
1
11
  2025.09.14, v1.8.0
2
12
 
3
13
  feature:
package/README.md CHANGED
@@ -23,8 +23,9 @@ bun i aleman
23
23
  ## Rules and Addons
24
24
 
25
25
  Aleman supports two main concepts:
26
- - ✅addons - events;
27
- - ✅rules - 🐊**Putout** rules that changes HTML;
26
+
27
+ - ✅ addons - events;
28
+ - ✅ rules - 🐊**Putout** rules that changes HTML;
28
29
 
29
30
  All interaction with DOM made using rules, and we interact not with DOM directly, but with JSX AST.
30
31
  It makes testing simple, states predictable and independent.
@@ -34,16 +35,17 @@ It makes testing simple, states predictable and independent.
34
35
  Addon responsible for UI and interfaction with outer world: clicks, fetches and everything like this.
35
36
  Aleman supports next types of addons:
36
37
 
37
- - Global
38
- - Events
39
- - Keys
40
- - Vim
38
+ - ✅ [Global](#globals);
39
+ - ✅ [Events](#events);
40
+ - ✅ [Keys](#keys);
41
+ - ✅ [Vim](#vim);
41
42
 
42
43
  When you need to filter out events according to `state` use `filter`:
43
44
 
44
45
  ```js
45
46
  export const filter = ({state}) => state.command === 'show';
46
47
  ```
48
+
47
49
  #### Global
48
50
 
49
51
  Any browser event you need to listen globally:
@@ -63,7 +65,7 @@ export const listener = () => ({
63
65
  Any browser event you need to listen according to element with `data-name="hello":
64
66
 
65
67
  ```js
66
- export const name = 'hello'
68
+ export const name = 'hello';
67
69
  export const events = ['click'];
68
70
  export const listener = () => ({
69
71
  command: 'hide',
@@ -84,7 +86,7 @@ export const listener = ({state, options}) => {
84
86
  command: 'hide',
85
87
  showSubmenu: false,
86
88
  index: -1,
87
- }
89
+ };
88
90
  };
89
91
  ```
90
92
 
@@ -101,7 +103,7 @@ export function listener({state, options}) {
101
103
  index,
102
104
  submenuIndex,
103
105
  } = state;
104
-
106
+
105
107
  const newState = {
106
108
  ...state,
107
109
  index: insideSubmenu ? index : 1,
package/aleman/vim.js CHANGED
@@ -1,7 +1,11 @@
1
1
  const isNumber = (a) => !Number.isNaN(a) && typeof a === 'number';
2
2
 
3
- export const createVimParser = (buffer = []) => (event) => {
4
- const {key} = event;
3
+ export const createVimParser = (buffer = []) => ({key}) => {
4
+ if (key === '^')
5
+ return ['^'];
6
+
7
+ if (key === '$')
8
+ return ['$'];
5
9
 
6
10
  if (!buffer.length && key === 'g') {
7
11
  buffer.push('g');
package/menu/README.md CHANGED
@@ -11,6 +11,19 @@
11
11
  - ✅[`submenu`](https://putout.cloudcmd.io/#/gist/b0a3b64d14f3497869a345e7e438d66e/feb671c4a59a555ff408af92fab602bae3a94e2f);
12
12
  - ✅[`hide-submenu`](https://putout.cloudcmd.io/#/gist/fdf6cf60a7fdfa2bae64279eda2ab023/ce0d5e24dc5e0b3436b7e87585c62e8a5132a9ab);
13
13
 
14
+ ## Hot Keys
15
+
16
+ | Key | Operation |
17
+ |:-------------|:------------------------|
18
+ | `F9` | open |
19
+ | `Esc` | close |
20
+ | `Up`, `j` | move cursor up |
21
+ | `Down`, `k` | move cursor down |
22
+ | `Left`, `h` | close submenu |
23
+ | `Right`, `l` | open submenu |
24
+ | `G` or `$` | navigate to bottom file |
25
+ | `gg` or `^` | navigate to top file |
26
+
14
27
  ## License
15
28
 
16
29
  MIT
package/menu/addons/gg.js CHANGED
@@ -1,7 +1,10 @@
1
1
  import * as up from './up.js';
2
2
 
3
3
  export const {filter} = up;
4
- export const commands = ['gg'];
4
+ export const commands = [
5
+ 'gg',
6
+ '^',
7
+ ];
5
8
 
6
9
  export function listener({state, options}) {
7
10
  const {
@@ -21,4 +24,3 @@ export function listener({state, options}) {
21
24
  options,
22
25
  });
23
26
  }
24
-
package/menu/addons/j.js CHANGED
@@ -37,4 +37,3 @@ export function listener({count, state, options}) {
37
37
  options,
38
38
  });
39
39
  }
40
-
package/menu/addons/k.js CHANGED
@@ -30,4 +30,3 @@ export function listener({count, state, options}) {
30
30
  options,
31
31
  });
32
32
  }
33
-
@@ -1,6 +1,9 @@
1
1
  import {getSubmenu} from './submenu/index.js';
2
2
 
3
- export const keys = ['G'];
3
+ export const keys = [
4
+ 'G',
5
+ '$',
6
+ ];
4
7
 
5
8
  export const preventDefault = true;
6
9
 
package/menu/menu.js CHANGED
@@ -7,7 +7,7 @@ export const createMenu = async (elementName, options, menu) => {
7
7
  const hydrateElement = createHydrate(name);
8
8
 
9
9
  await createMap();
10
- await createLink();
10
+ await loadStyle();
11
11
 
12
12
  createStateElement(name);
13
13
  const {hydrateMenu} = await import('./hydrate-menu.js');
@@ -19,21 +19,40 @@ export const createMenu = async (elementName, options, menu) => {
19
19
  });
20
20
  };
21
21
 
22
- async function createLink() {
22
+ async function loadStyle() {
23
23
  const name = 'aleman-menu-style';
24
24
 
25
25
  if (findByName(name))
26
26
  return;
27
27
 
28
- const style = document.createElement('style');
28
+ const [error] = await tryToCatch(importCSS);
29
29
 
30
- style.dataset.name = name;
30
+ if (!error)
31
+ return;
32
+
33
+ createLink();
34
+ }
35
+
36
+ function createLink() {
37
+ const href = new URL('menu.css', import.meta.url).pathname;
38
+ const link = document.createElement('link');
39
+
40
+ link.rel = 'stylesheet';
41
+ link.href = href;
42
+ document.head.appendChild(link);
43
+ }
44
+
45
+ async function importCSS() {
31
46
  const content = await import('./menu.css', {
32
47
  with: {
33
48
  type: 'css',
34
49
  },
35
50
  });
36
51
 
52
+ const style = document.createElement('style');
53
+
54
+ style.dataset.name = name;
55
+
37
56
  for (const rule of content.default.cssRules) {
38
57
  style.innerHTML += rule.cssText;
39
58
  }
@@ -89,3 +108,12 @@ async function createMap() {
89
108
  function findByName(name) {
90
109
  return document.querySelector(`[data-name=${name}]`);
91
110
  }
111
+
112
+ async function tryToCatch(fn, args) {
113
+ try {
114
+ return [null, await fn(...args)];
115
+ } catch(error) {
116
+ return [error];
117
+ }
118
+ }
119
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aleman",
3
- "version": "1.8.0",
3
+ "version": "1.9.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",
@@ -29,7 +29,8 @@
29
29
  "html-escaper": "^3.0.3",
30
30
  "jessy": "^4.1.0",
31
31
  "once": "^1.4.0",
32
- "putout": "^40.5.1"
32
+ "putout": "^40.5.1",
33
+ "try-to-catch": "^3.0.1"
33
34
  },
34
35
  "keywords": [
35
36
  "putout",