dirvi-lib 0.4.0 → 0.6.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.
Files changed (119) hide show
  1. package/dist/domain/posix-node.d.ts +29 -0
  2. package/dist/domain/posix-node.d.ts.map +1 -0
  3. package/dist/domain/posix-node.js +20 -0
  4. package/dist/domain/unix-path.d.ts +1 -1
  5. package/dist/domain/unix-path.js +6 -9
  6. package/dist/index.d.ts +9 -14
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +8 -13
  9. package/dist/tree-surfer/cursor.d.ts +24 -0
  10. package/dist/tree-surfer/cursor.d.ts.map +1 -0
  11. package/dist/tree-surfer/cursor.js +65 -0
  12. package/dist/tree-surfer/fold-node/fold-node.impl.d.ts +5 -0
  13. package/dist/tree-surfer/fold-node/fold-node.impl.d.ts.map +1 -0
  14. package/dist/tree-surfer/fold-node/fold-node.impl.js +143 -0
  15. package/dist/tree-surfer/fold-node/fold-node.types.d.ts +70 -0
  16. package/dist/tree-surfer/fold-node/fold-node.types.d.ts.map +1 -0
  17. package/dist/tree-surfer/fold-node/fold-node.types.js +1 -0
  18. package/dist/tree-surfer/index.d.ts +9 -0
  19. package/dist/tree-surfer/index.d.ts.map +1 -0
  20. package/dist/tree-surfer/index.js +8 -0
  21. package/dist/tree-surfer/nav-node/nav-node.impl.d.ts +6 -0
  22. package/dist/tree-surfer/nav-node/nav-node.impl.d.ts.map +1 -0
  23. package/dist/tree-surfer/nav-node/nav-node.impl.js +191 -0
  24. package/dist/tree-surfer/nav-node/nav-node.types.d.ts +42 -0
  25. package/dist/tree-surfer/nav-node/nav-node.types.d.ts.map +1 -0
  26. package/dist/tree-surfer/nav-node/nav-node.types.js +3 -0
  27. package/dist/tree-surfer/state.d.ts +19 -0
  28. package/dist/tree-surfer/state.d.ts.map +1 -0
  29. package/dist/tree-surfer/state.js +109 -0
  30. package/dist/tree-surfer/tree-node/tree-node.arb.d.ts +31 -0
  31. package/dist/tree-surfer/tree-node/tree-node.arb.d.ts.map +1 -0
  32. package/dist/tree-surfer/tree-node/tree-node.arb.js +80 -0
  33. package/dist/tree-surfer/tree-node/tree-node.impl.d.ts +14 -0
  34. package/dist/tree-surfer/tree-node/tree-node.impl.d.ts.map +1 -0
  35. package/dist/tree-surfer/tree-node/tree-node.impl.js +89 -0
  36. package/dist/tree-surfer/tree-node/tree-node.test.d.ts +2 -0
  37. package/dist/tree-surfer/tree-node/tree-node.test.d.ts.map +1 -0
  38. package/dist/tree-surfer/tree-node/tree-node.test.js +117 -0
  39. package/dist/tree-surfer/tree-node/tree-node.types.d.ts +184 -0
  40. package/dist/tree-surfer/tree-node/tree-node.types.d.ts.map +1 -0
  41. package/dist/tree-surfer/tree-node/tree-node.types.js +12 -0
  42. package/dist/tree-surfer-ui/application/index.d.ts +3 -0
  43. package/dist/tree-surfer-ui/application/index.d.ts.map +1 -0
  44. package/dist/tree-surfer-ui/application/index.js +2 -0
  45. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.d.ts +2 -0
  46. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.d.ts.map +1 -0
  47. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.js +192 -0
  48. package/dist/tree-surfer-ui/application/intent-to-effect.d.ts +6 -0
  49. package/dist/tree-surfer-ui/application/intent-to-effect.d.ts.map +1 -0
  50. package/dist/tree-surfer-ui/application/intent-to-effect.js +139 -0
  51. package/dist/tree-surfer-ui/application/user-input-to-intent.d.ts +3 -0
  52. package/dist/tree-surfer-ui/application/user-input-to-intent.d.ts.map +1 -0
  53. package/dist/tree-surfer-ui/application/user-input-to-intent.js +98 -0
  54. package/dist/tree-surfer-ui/application/user-input-to-intent.test.d.ts +2 -0
  55. package/dist/tree-surfer-ui/application/user-input-to-intent.test.d.ts.map +1 -0
  56. package/dist/tree-surfer-ui/application/user-input-to-intent.test.js +118 -0
  57. package/dist/tree-surfer-ui/domain/effect.d.ts +35 -0
  58. package/dist/tree-surfer-ui/domain/effect.d.ts.map +1 -0
  59. package/dist/tree-surfer-ui/domain/index.d.ts +5 -0
  60. package/dist/tree-surfer-ui/domain/index.d.ts.map +1 -0
  61. package/dist/tree-surfer-ui/domain/index.js +4 -0
  62. package/dist/tree-surfer-ui/domain/input-state.d.ts +8 -0
  63. package/dist/tree-surfer-ui/domain/input-state.d.ts.map +1 -0
  64. package/dist/tree-surfer-ui/domain/intent.d.ts +25 -0
  65. package/dist/tree-surfer-ui/domain/intent.d.ts.map +1 -0
  66. package/dist/tree-surfer-ui/domain/user-input.d.ts +19 -0
  67. package/dist/tree-surfer-ui/domain/user-input.d.ts.map +1 -0
  68. package/package.json +3 -2
  69. package/dist/application/intent-to-effect-no-state.test.d.ts +0 -2
  70. package/dist/application/intent-to-effect-no-state.test.d.ts.map +0 -1
  71. package/dist/application/intent-to-effect-no-state.test.js +0 -178
  72. package/dist/application/intent-to-effect.d.ts +0 -8
  73. package/dist/application/intent-to-effect.d.ts.map +0 -1
  74. package/dist/application/intent-to-effect.js +0 -142
  75. package/dist/application/intent-to-effect.test-no-state.d.ts +0 -2
  76. package/dist/application/intent-to-effect.test-no-state.d.ts.map +0 -1
  77. package/dist/application/intent-to-effect.test-no-state.js +0 -178
  78. package/dist/application/user-input-to-intent.d.ts +0 -8
  79. package/dist/application/user-input-to-intent.d.ts.map +0 -1
  80. package/dist/application/user-input-to-intent.js +0 -98
  81. package/dist/application/user-input-to-intent.test.d.ts +0 -2
  82. package/dist/application/user-input-to-intent.test.d.ts.map +0 -1
  83. package/dist/application/user-input-to-intent.test.js +0 -125
  84. package/dist/domain/cursor.d.ts +0 -19
  85. package/dist/domain/cursor.d.ts.map +0 -1
  86. package/dist/domain/cursor.js +0 -46
  87. package/dist/domain/display-row.d.ts +0 -34
  88. package/dist/domain/display-row.d.ts.map +0 -1
  89. package/dist/domain/display-row.js +0 -33
  90. package/dist/domain/effect.d.ts +0 -48
  91. package/dist/domain/effect.d.ts.map +0 -1
  92. package/dist/domain/fold-node.d.ts +0 -25
  93. package/dist/domain/fold-node.d.ts.map +0 -1
  94. package/dist/domain/fold-node.js +0 -93
  95. package/dist/domain/input-state.d.ts +0 -10
  96. package/dist/domain/input-state.d.ts.map +0 -1
  97. package/dist/domain/intent.d.ts +0 -34
  98. package/dist/domain/intent.d.ts.map +0 -1
  99. package/dist/domain/navigation-node.d.ts +0 -58
  100. package/dist/domain/navigation-node.d.ts.map +0 -1
  101. package/dist/domain/navigation-node.js +0 -210
  102. package/dist/domain/state.d.ts +0 -12
  103. package/dist/domain/state.d.ts.map +0 -1
  104. package/dist/domain/state.js +0 -12
  105. package/dist/domain/unix-entry.d.ts +0 -44
  106. package/dist/domain/unix-entry.d.ts.map +0 -1
  107. package/dist/domain/unix-entry.js +0 -108
  108. package/dist/domain/user-input.d.ts +0 -27
  109. package/dist/domain/user-input.d.ts.map +0 -1
  110. package/dist/infrastructure/get-cwd.d.ts +0 -3
  111. package/dist/infrastructure/get-cwd.d.ts.map +0 -1
  112. package/dist/infrastructure/get-cwd.js +0 -15
  113. package/dist/infrastructure/get-dir-lazy-entries.d.ts +0 -6
  114. package/dist/infrastructure/get-dir-lazy-entries.d.ts.map +0 -1
  115. package/dist/infrastructure/get-dir-lazy-entries.js +0 -40
  116. /package/dist/{domain → tree-surfer-ui/domain}/effect.js +0 -0
  117. /package/dist/{domain → tree-surfer-ui/domain}/input-state.js +0 -0
  118. /package/dist/{domain → tree-surfer-ui/domain}/intent.js +0 -0
  119. /package/dist/{domain → tree-surfer-ui/domain}/user-input.js +0 -0
@@ -0,0 +1,3 @@
1
+ import { UserInput, InputState, Intent } from '../domain/index.js';
2
+ export declare function userInputToIntent(userInput: UserInput, inputState: InputState): Intent | undefined;
3
+ //# sourceMappingURL=user-input-to-intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-input-to-intent.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/application/user-input-to-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGnE,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,GACrB,MAAM,GAAG,SAAS,CAQpB"}
@@ -0,0 +1,98 @@
1
+ // Derive the intent from the user input and the current input state.
2
+ export function userInputToIntent(userInput, inputState) {
3
+ switch (inputState.inputMode) {
4
+ case 'normal':
5
+ return normalUserInputToIntent(userInput, inputState.normalBuffer);
6
+ case 'command':
7
+ return commandUserInputToIntent(userInput, inputState.commandLine);
8
+ }
9
+ }
10
+ function normalUserInputToIntent(userInput, normalBuffer) {
11
+ if (userInput.userInputType === 'esc') {
12
+ return {
13
+ intentType: 'setNormalBuffer',
14
+ normalBuffer: '',
15
+ };
16
+ }
17
+ if (userInput.userInputType === 'character') {
18
+ return normalCharacterToIntent(userInput.string, normalBuffer);
19
+ }
20
+ switch (userInput.userInputType) {
21
+ case 'rightArrow':
22
+ return {
23
+ intentType: 'normalRight',
24
+ };
25
+ case 'leftArrow':
26
+ return {
27
+ intentType: 'normalLeft',
28
+ };
29
+ case 'downArrow':
30
+ return {
31
+ intentType: 'normalDown',
32
+ };
33
+ case 'upArrow':
34
+ return {
35
+ intentType: 'normalUp',
36
+ };
37
+ }
38
+ }
39
+ function normalCharacterToIntent(character, normalBuffer) {
40
+ if (normalBuffer === '') {
41
+ switch (character) {
42
+ case 'l':
43
+ return {
44
+ intentType: 'normalRight',
45
+ };
46
+ case 'h':
47
+ return {
48
+ intentType: 'normalLeft',
49
+ };
50
+ case 'j':
51
+ return {
52
+ intentType: 'normalDown',
53
+ };
54
+ case 'k':
55
+ return {
56
+ intentType: 'normalUp',
57
+ };
58
+ case ':':
59
+ return {
60
+ intentType: 'enterCommandLineMode',
61
+ };
62
+ }
63
+ }
64
+ return {
65
+ intentType: 'setNormalBuffer',
66
+ normalBuffer: normalBuffer + character,
67
+ };
68
+ }
69
+ function commandUserInputToIntent(userInput, commandLine) {
70
+ if (userInput.userInputType === 'esc') {
71
+ return {
72
+ intentType: 'exitCommandLineMode',
73
+ };
74
+ }
75
+ if (userInput.userInputType === 'enter') {
76
+ return {
77
+ intentType: 'executeCommandLine',
78
+ commandLine: commandLine,
79
+ };
80
+ }
81
+ if (userInput.userInputType === 'backspace') {
82
+ if (commandLine.length < 2) {
83
+ return {
84
+ intentType: 'exitCommandLineMode',
85
+ };
86
+ }
87
+ return {
88
+ intentType: 'setCommandLine',
89
+ commandLine: commandLine.slice(0, -1),
90
+ };
91
+ }
92
+ if (userInput.userInputType === 'character') {
93
+ return {
94
+ intentType: 'setCommandLine',
95
+ commandLine: commandLine + userInput.string,
96
+ };
97
+ }
98
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=user-input-to-intent.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-input-to-intent.test.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/application/user-input-to-intent.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,118 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { userInputToIntent } from './user-input-to-intent.js';
3
+ function normalInputState(normalBuffer = '') {
4
+ return {
5
+ inputMode: 'normal',
6
+ normalBuffer,
7
+ };
8
+ }
9
+ function commandInputState(commandLine = ':') {
10
+ return {
11
+ inputMode: 'command',
12
+ commandLine,
13
+ };
14
+ }
15
+ describe('userInputToIntent', () => {
16
+ describe('normal mode', () => {
17
+ it.each([
18
+ ['l', { intentType: 'normalRight' }],
19
+ ['h', { intentType: 'normalLeft' }],
20
+ ['j', { intentType: 'normalDown' }],
21
+ ['k', { intentType: 'normalUp' }],
22
+ [':', { intentType: 'enterCommandLineMode' }],
23
+ ])('converts "%s" to the expected intent', (character, expected) => {
24
+ const userInput = {
25
+ userInputType: 'character',
26
+ string: character,
27
+ };
28
+ expect(userInputToIntent(userInput, normalInputState())).toEqual(expected);
29
+ });
30
+ it('adds an unrecognized character to the normal buffer', () => {
31
+ const userInput = {
32
+ userInputType: 'character',
33
+ string: 'g',
34
+ };
35
+ expect(userInputToIntent(userInput, normalInputState())).toEqual({
36
+ intentType: 'setNormalBuffer',
37
+ normalBuffer: 'g',
38
+ });
39
+ });
40
+ it('appends a character to an existing normal buffer', () => {
41
+ const userInput = {
42
+ userInputType: 'character',
43
+ string: 'g',
44
+ };
45
+ expect(userInputToIntent(userInput, normalInputState('2'))).toEqual({
46
+ intentType: 'setNormalBuffer',
47
+ normalBuffer: '2g',
48
+ });
49
+ });
50
+ it('clears the normal buffer when Escape is pressed', () => {
51
+ const userInput = {
52
+ userInputType: 'esc',
53
+ };
54
+ expect(userInputToIntent(userInput, normalInputState('gg'))).toEqual({
55
+ intentType: 'setNormalBuffer',
56
+ normalBuffer: '',
57
+ });
58
+ });
59
+ it.each([
60
+ ['rightArrow', 'normalRight'],
61
+ ['leftArrow', 'normalLeft'],
62
+ ['downArrow', 'normalDown'],
63
+ ['upArrow', 'normalUp'],
64
+ ])('converts %s to %s', (userInputType, intentType) => {
65
+ const userInput = {
66
+ userInputType,
67
+ };
68
+ expect(userInputToIntent(userInput, normalInputState())).toEqual({
69
+ intentType,
70
+ });
71
+ });
72
+ it('does not enter command-line mode when the normal buffer is non-empty', () => {
73
+ const userInput = {
74
+ userInputType: 'character',
75
+ string: ':',
76
+ };
77
+ expect(userInputToIntent(userInput, normalInputState('g'))).toEqual({
78
+ intentType: 'setNormalBuffer',
79
+ normalBuffer: 'g:',
80
+ });
81
+ });
82
+ });
83
+ describe('command-line mode', () => {
84
+ it('appends a character to the command line', () => {
85
+ const userInput = {
86
+ userInputType: 'character',
87
+ string: 'w',
88
+ };
89
+ expect(userInputToIntent(userInput, commandInputState(':'))).toEqual({
90
+ intentType: 'setCommandLine',
91
+ commandLine: ':w',
92
+ });
93
+ });
94
+ it('executes the command line when Enter is pressed', () => {
95
+ const userInput = {
96
+ userInputType: 'enter',
97
+ };
98
+ expect(userInputToIntent(userInput, commandInputState(':w'))).toEqual({
99
+ intentType: 'executeCommandLine',
100
+ commandLine: ':w',
101
+ });
102
+ });
103
+ it('exits command-line mode when Escape is pressed', () => {
104
+ const userInput = {
105
+ userInputType: 'esc',
106
+ };
107
+ expect(userInputToIntent(userInput, commandInputState(':w'))).toEqual({
108
+ intentType: 'exitCommandLineMode',
109
+ });
110
+ });
111
+ it.each(['rightArrow', 'leftArrow', 'downArrow', 'upArrow'])('ignores %s in command-line mode', (userInputType) => {
112
+ const userInput = {
113
+ userInputType,
114
+ };
115
+ expect(userInputToIntent(userInput, commandInputState())).toBeUndefined();
116
+ });
117
+ });
118
+ });
@@ -0,0 +1,35 @@
1
+ import type { InputState } from './input-state.js';
2
+ import { SerializableKey, TreeNode } from '../../tree-surfer/index.js';
3
+ export type Effect<Id extends SerializableKey, BufferNode extends TreeNode<Id, BufferNode>> = {
4
+ effectType: 'dispatchEffectAction';
5
+ action: EffectAction<Id, BufferNode>;
6
+ } | {
7
+ effectType: 'loadBranchEntries';
8
+ path: Id[];
9
+ } | {
10
+ effectType: 'emitVisibleLeavesPaths';
11
+ } | {
12
+ effectType: 'quit';
13
+ exitMessage: string;
14
+ } | {
15
+ effectType: 'setInputState';
16
+ inputState: InputState;
17
+ };
18
+ export type EffectAction<Id extends SerializableKey, BufferNode extends TreeNode<Id, BufferNode>> = {
19
+ effectActionType: 'nextEntry';
20
+ } | {
21
+ effectActionType: 'prevEntry';
22
+ } | {
23
+ effectActionType: 'setBranchEntries';
24
+ path: Id[];
25
+ entries: BufferNode[] | null;
26
+ } | {
27
+ effectActionType: 'navigateToParent';
28
+ } | {
29
+ effectActionType: 'fold';
30
+ } | {
31
+ effectActionType: 'unfold';
32
+ } | {
33
+ effectActionType: 'toggleFold';
34
+ };
35
+ //# sourceMappingURL=effect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/domain/effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,eAAe,EACf,QAAQ,EACT,MAAM,4BAA4B,CAAC;AAGpC,MAAM,MAAM,MAAM,CAChB,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,IAEzC;IACE,UAAU,EAAE,sBAAsB,CAAC;IACnC,MAAM,EAAE,YAAY,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;CACtC,GACD;IACE,UAAU,EAAE,mBAAmB,CAAC;IAChC,IAAI,EAAE,EAAE,EAAE,CAAC;CACZ,GACD;IACE,UAAU,EAAE,wBAAwB,CAAC;CACtC,GACD;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAGN,MAAM,MAAM,YAAY,CACtB,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,IAEzC;IACE,gBAAgB,EAAE,WAAW,CAAC;CAC/B,GACD;IACE,gBAAgB,EAAE,WAAW,CAAC;CAC/B,GACD;IACE,gBAAgB,EAAE,kBAAkB,CAAC;IACrC,IAAI,EAAE,EAAE,EAAE,CAAC;IACX,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;CAC9B,GACD;IACE,gBAAgB,EAAE,kBAAkB,CAAC;CACtC,GACD;IACE,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GACD;IACE,gBAAgB,EAAE,QAAQ,CAAC;CAC5B,GACD;IACE,gBAAgB,EAAE,YAAY,CAAC;CAChC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './effect.js';
2
+ export * from './input-state.js';
3
+ export * from './intent.js';
4
+ export * from './user-input.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/domain/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './effect.js';
2
+ export * from './input-state.js';
3
+ export * from './intent.js';
4
+ export * from './user-input.js';
@@ -0,0 +1,8 @@
1
+ export type InputState = {
2
+ inputMode: 'normal';
3
+ normalBuffer: string;
4
+ } | {
5
+ inputMode: 'command';
6
+ commandLine: string;
7
+ };
8
+ //# sourceMappingURL=input-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-state.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/domain/input-state.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB;IACE,SAAS,EAAE,QAAQ,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}
@@ -0,0 +1,25 @@
1
+ export type Intent = NormalModeIntent | CommandLineIntent;
2
+ export type NormalModeIntent = {
3
+ intentType: 'normalRight';
4
+ } | {
5
+ intentType: 'normalLeft';
6
+ } | {
7
+ intentType: 'normalDown';
8
+ } | {
9
+ intentType: 'normalUp';
10
+ } | {
11
+ intentType: 'setNormalBuffer';
12
+ normalBuffer: string;
13
+ };
14
+ export type CommandLineIntent = {
15
+ intentType: 'enterCommandLineMode';
16
+ } | {
17
+ intentType: 'setCommandLine';
18
+ commandLine: string;
19
+ } | {
20
+ intentType: 'executeCommandLine';
21
+ commandLine: string;
22
+ } | {
23
+ intentType: 'exitCommandLineMode';
24
+ };
25
+ //# sourceMappingURL=intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/domain/intent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GACxB;IACE,UAAU,EAAE,aAAa,CAAC;CAC3B,GACD;IACE,UAAU,EAAE,YAAY,CAAC;CAC1B,GACD;IACE,UAAU,EAAE,YAAY,CAAC;CAC1B,GACD;IACE,UAAU,EAAE,UAAU,CAAC;CACxB,GACD;IACE,UAAU,EAAE,iBAAiB,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN,MAAM,MAAM,iBAAiB,GACzB;IACE,UAAU,EAAE,sBAAsB,CAAC;CACpC,GACD;IACE,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,oBAAoB,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,qBAAqB,CAAC;CACnC,CAAC"}
@@ -0,0 +1,19 @@
1
+ export type UserInput = {
2
+ userInputType: 'character';
3
+ string: string;
4
+ } | {
5
+ userInputType: 'enter';
6
+ } | {
7
+ userInputType: 'backspace';
8
+ } | {
9
+ userInputType: 'esc';
10
+ } | {
11
+ userInputType: 'rightArrow';
12
+ } | {
13
+ userInputType: 'leftArrow';
14
+ } | {
15
+ userInputType: 'downArrow';
16
+ } | {
17
+ userInputType: 'upArrow';
18
+ };
19
+ //# sourceMappingURL=user-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-input.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/domain/user-input.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB;IACE,aAAa,EAAE,WAAW,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,aAAa,EAAE,OAAO,CAAC;CACxB,GACD;IACE,aAAa,EAAE,WAAW,CAAC;CAC5B,GACD;IACE,aAAa,EAAE,KAAK,CAAC;CACtB,GACD;IACE,aAAa,EAAE,YAAY,CAAC;CAC7B,GACD;IACE,aAAa,EAAE,WAAW,CAAC;CAC5B,GACD;IACE,aAAa,EAAE,WAAW,CAAC;CAC5B,GACD;IACE,aAAa,EAAE,SAAS,CAAC;CAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirvi-lib",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Dependency for dirvi apps.",
5
5
  "license": "LGPL-3.0-or-later",
6
6
  "type": "module",
@@ -17,7 +17,8 @@
17
17
  "typescript": "^5.0.0"
18
18
  },
19
19
  "scripts": {
20
- "build": "tsc",
20
+ "clean": "rm -rf dist",
21
+ "build": "pnpm clean && tsc",
21
22
  "typecheck": "tsc --noEmit",
22
23
  "format": "prettier . --write"
23
24
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=intent-to-effect-no-state.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intent-to-effect-no-state.test.d.ts","sourceRoot":"","sources":["../../src/application/intent-to-effect-no-state.test.ts"],"names":[],"mappings":""}
@@ -1,178 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { intentToEffect } from './intent-to-effect.js';
3
- const state = {};
4
- describe('intentToEffectNoState', () => {
5
- describe('normal mode buffer', () => {
6
- it('stores z as a possible command prefix', () => {
7
- expect(
8
- intentToEffect(
9
- {
10
- intentType: 'setNormalBuffer',
11
- normalBuffer: 'z',
12
- },
13
- state,
14
- ),
15
- ).toEqual({
16
- effectType: 'setInputState',
17
- inputState: {
18
- inputMode: 'normal',
19
- normalBuffer: 'z',
20
- },
21
- });
22
- });
23
- it.each([
24
- ['za', 'toggleFold'],
25
- ['zc', 'fold'],
26
- ['zo', 'unfold'],
27
- ])(
28
- 'converts %s into a %s effect action',
29
- (normalBuffer, effectActionType) => {
30
- expect(
31
- intentToEffect(
32
- {
33
- intentType: 'setNormalBuffer',
34
- normalBuffer,
35
- },
36
- state,
37
- ),
38
- ).toEqual({
39
- effectType: 'dispatchEffectAction',
40
- action: {
41
- effectActionType,
42
- },
43
- });
44
- },
45
- );
46
- it('clears the normal buffer when the input is not a known command', () => {
47
- expect(
48
- intentToEffect(
49
- {
50
- intentType: 'setNormalBuffer',
51
- normalBuffer: 'x',
52
- },
53
- state,
54
- ),
55
- ).toEqual({
56
- effectType: 'setInputState',
57
- inputState: {
58
- inputMode: 'normal',
59
- normalBuffer: '',
60
- },
61
- });
62
- });
63
- });
64
- describe('normal mode navigation', () => {
65
- it('moves to the next entry', () => {
66
- expect(
67
- intentToEffect(
68
- {
69
- intentType: 'normalDown',
70
- },
71
- state,
72
- ),
73
- ).toEqual({
74
- effectType: 'dispatchEffectAction',
75
- action: {
76
- effectActionType: 'nextEntry',
77
- },
78
- });
79
- });
80
- it('moves to the previous entry', () => {
81
- expect(
82
- intentToEffect(
83
- {
84
- intentType: 'normalUp',
85
- },
86
- state,
87
- ),
88
- ).toEqual({
89
- effectType: 'dispatchEffectAction',
90
- action: {
91
- effectActionType: 'prevEntry',
92
- },
93
- });
94
- });
95
- });
96
- describe('command-line mode', () => {
97
- it('enters command-line mode', () => {
98
- expect(
99
- intentToEffect(
100
- {
101
- intentType: 'enterCommandLineMode',
102
- },
103
- state,
104
- ),
105
- ).toEqual({
106
- effectType: 'setInputState',
107
- inputState: {
108
- inputMode: 'command',
109
- commandLine: ':',
110
- },
111
- });
112
- });
113
- it('updates the command line', () => {
114
- expect(
115
- intentToEffect(
116
- {
117
- intentType: 'setCommandLine',
118
- commandLine: ':w',
119
- },
120
- state,
121
- ),
122
- ).toEqual({
123
- effectType: 'setInputState',
124
- inputState: {
125
- inputMode: 'command',
126
- commandLine: ':w',
127
- },
128
- });
129
- });
130
- it('exits command-line mode', () => {
131
- expect(
132
- intentToEffect(
133
- {
134
- intentType: 'exitCommandLineMode',
135
- },
136
- state,
137
- ),
138
- ).toEqual({
139
- effectType: 'setInputState',
140
- inputState: {
141
- inputMode: 'normal',
142
- normalBuffer: '',
143
- },
144
- });
145
- });
146
- it('returns to normal mode after executing a gibberish command line', () => {
147
- expect(
148
- intentToEffect(
149
- {
150
- intentType: 'executeCommandLine',
151
- commandLine: ':sijbas',
152
- },
153
- state,
154
- ),
155
- ).toEqual({
156
- effectType: 'setInputState',
157
- inputState: {
158
- inputMode: 'normal',
159
- normalBuffer: '',
160
- },
161
- });
162
- });
163
- it('quits when the :q command is executed', () => {
164
- expect(
165
- intentToEffect(
166
- {
167
- intentType: 'executeCommandLine',
168
- commandLine: ':q',
169
- },
170
- state,
171
- ),
172
- ).toEqual({
173
- effectType: 'quit',
174
- exitMessage: '',
175
- });
176
- });
177
- });
178
- });
@@ -1,8 +0,0 @@
1
- import { Effect } from '../domain/effect.js';
2
- import { State } from '../domain/state.js';
3
- import { Intent } from '../domain/intent.js';
4
- export declare function intentToEffect(
5
- intent: Intent,
6
- state: State,
7
- ): Effect | undefined;
8
- //# sourceMappingURL=intent-to-effect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intent-to-effect.d.ts","sourceRoot":"","sources":["../../src/application/intent-to-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAQ,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACX,MAAM,GAAG,SAAS,CAgEpB"}