dirvi-lib 0.3.0 → 0.5.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 (103) 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/index.d.ts +8 -8
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +8 -8
  7. package/dist/tree-surfer/cursor.d.ts +24 -0
  8. package/dist/tree-surfer/cursor.d.ts.map +1 -0
  9. package/dist/tree-surfer/cursor.js +65 -0
  10. package/dist/tree-surfer/fold-node/fold-node.impl.d.ts +5 -0
  11. package/dist/tree-surfer/fold-node/fold-node.impl.d.ts.map +1 -0
  12. package/dist/tree-surfer/fold-node/fold-node.impl.js +143 -0
  13. package/dist/tree-surfer/fold-node/fold-node.types.d.ts +70 -0
  14. package/dist/tree-surfer/fold-node/fold-node.types.d.ts.map +1 -0
  15. package/dist/tree-surfer/fold-node/fold-node.types.js +1 -0
  16. package/dist/tree-surfer/index.d.ts +9 -0
  17. package/dist/tree-surfer/index.d.ts.map +1 -0
  18. package/dist/tree-surfer/index.js +8 -0
  19. package/dist/tree-surfer/nav-node/nav-node.impl.d.ts +6 -0
  20. package/dist/tree-surfer/nav-node/nav-node.impl.d.ts.map +1 -0
  21. package/dist/tree-surfer/nav-node/nav-node.impl.js +191 -0
  22. package/dist/tree-surfer/nav-node/nav-node.types.d.ts +42 -0
  23. package/dist/tree-surfer/nav-node/nav-node.types.d.ts.map +1 -0
  24. package/dist/tree-surfer/nav-node/nav-node.types.js +3 -0
  25. package/dist/tree-surfer/state.d.ts +19 -0
  26. package/dist/tree-surfer/state.d.ts.map +1 -0
  27. package/dist/tree-surfer/state.js +109 -0
  28. package/dist/tree-surfer/tree-node/tree-node.arb.d.ts +31 -0
  29. package/dist/tree-surfer/tree-node/tree-node.arb.d.ts.map +1 -0
  30. package/dist/tree-surfer/tree-node/tree-node.arb.js +80 -0
  31. package/dist/tree-surfer/tree-node/tree-node.impl.d.ts +13 -0
  32. package/dist/tree-surfer/tree-node/tree-node.impl.d.ts.map +1 -0
  33. package/dist/tree-surfer/tree-node/tree-node.impl.js +87 -0
  34. package/dist/tree-surfer/tree-node/tree-node.test.d.ts +2 -0
  35. package/dist/tree-surfer/tree-node/tree-node.test.d.ts.map +1 -0
  36. package/dist/tree-surfer/tree-node/tree-node.test.js +117 -0
  37. package/dist/tree-surfer/tree-node/tree-node.types.d.ts +184 -0
  38. package/dist/tree-surfer/tree-node/tree-node.types.d.ts.map +1 -0
  39. package/dist/tree-surfer/tree-node/tree-node.types.js +12 -0
  40. package/dist/tree-surfer-ui/application/index.d.ts +3 -0
  41. package/dist/tree-surfer-ui/application/index.d.ts.map +1 -0
  42. package/dist/tree-surfer-ui/application/index.js +2 -0
  43. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.d.ts +2 -0
  44. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.d.ts.map +1 -0
  45. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.js +192 -0
  46. package/dist/tree-surfer-ui/application/intent-to-effect.d.ts +6 -0
  47. package/dist/tree-surfer-ui/application/intent-to-effect.d.ts.map +1 -0
  48. package/dist/tree-surfer-ui/application/intent-to-effect.js +137 -0
  49. package/dist/tree-surfer-ui/application/user-input-to-intent.d.ts +3 -0
  50. package/dist/tree-surfer-ui/application/user-input-to-intent.d.ts.map +1 -0
  51. package/dist/tree-surfer-ui/application/user-input-to-intent.js +98 -0
  52. package/dist/tree-surfer-ui/application/user-input-to-intent.test.d.ts +2 -0
  53. package/dist/tree-surfer-ui/application/user-input-to-intent.test.d.ts.map +1 -0
  54. package/dist/tree-surfer-ui/application/user-input-to-intent.test.js +118 -0
  55. package/dist/tree-surfer-ui/domain/effect.d.ts +36 -0
  56. package/dist/tree-surfer-ui/domain/effect.d.ts.map +1 -0
  57. package/dist/tree-surfer-ui/domain/effect.js +1 -0
  58. package/dist/tree-surfer-ui/domain/index.d.ts +5 -0
  59. package/dist/tree-surfer-ui/domain/index.d.ts.map +1 -0
  60. package/dist/tree-surfer-ui/domain/index.js +4 -0
  61. package/dist/tree-surfer-ui/domain/input-state.d.ts +8 -0
  62. package/dist/tree-surfer-ui/domain/input-state.d.ts.map +1 -0
  63. package/dist/tree-surfer-ui/domain/input-state.js +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/intent.js +1 -0
  67. package/dist/tree-surfer-ui/domain/user-input.d.ts +19 -0
  68. package/dist/tree-surfer-ui/domain/user-input.d.ts.map +1 -0
  69. package/dist/tree-surfer-ui/domain/user-input.js +1 -0
  70. package/package.json +6 -3
  71. package/dist/domain/cursor.d.ts +0 -17
  72. package/dist/domain/cursor.d.ts.map +0 -1
  73. package/dist/domain/cursor.js +0 -44
  74. package/dist/domain/display-row.d.ts +0 -29
  75. package/dist/domain/display-row.d.ts.map +0 -1
  76. package/dist/domain/display-row.js +0 -29
  77. package/dist/domain/fold-node.d.ts +0 -17
  78. package/dist/domain/fold-node.d.ts.map +0 -1
  79. package/dist/domain/fold-node.js +0 -81
  80. package/dist/domain/fold.d.ts +0 -10
  81. package/dist/domain/fold.d.ts.map +0 -1
  82. package/dist/domain/fold.js +0 -24
  83. package/dist/domain/navigation-entry.d.ts +0 -23
  84. package/dist/domain/navigation-entry.d.ts.map +0 -1
  85. package/dist/domain/navigation-entry.js +0 -52
  86. package/dist/domain/navigation-node.d.ts +0 -43
  87. package/dist/domain/navigation-node.d.ts.map +0 -1
  88. package/dist/domain/navigation-node.js +0 -198
  89. package/dist/domain/state.d.ts +0 -12
  90. package/dist/domain/state.d.ts.map +0 -1
  91. package/dist/domain/state.js +0 -12
  92. package/dist/domain/unix-entry.d.ts +0 -28
  93. package/dist/domain/unix-entry.d.ts.map +0 -1
  94. package/dist/domain/unix-entry.js +0 -96
  95. package/dist/domain/view.d.ts +0 -15
  96. package/dist/domain/view.d.ts.map +0 -1
  97. package/dist/domain/view.js +0 -12
  98. package/dist/infrastructure/get-cwd.d.ts +0 -3
  99. package/dist/infrastructure/get-cwd.d.ts.map +0 -1
  100. package/dist/infrastructure/get-cwd.js +0 -13
  101. package/dist/infrastructure/get-dir-lazy-entries.d.ts +0 -4
  102. package/dist/infrastructure/get-dir-lazy-entries.d.ts.map +0 -1
  103. package/dist/infrastructure/get-dir-lazy-entries.js +0 -34
@@ -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,36 @@
1
+ import type { InputState } from './input-state.js';
2
+ import { SerializableKey, TreeNode } from '../../tree-surfer/tree-node/tree-node.types.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: 'emitPath';
11
+ path: Id[];
12
+ } | {
13
+ effectType: 'quit';
14
+ exitMessage: string;
15
+ } | {
16
+ effectType: 'setInputState';
17
+ inputState: InputState;
18
+ };
19
+ export type EffectAction<Id extends SerializableKey, BufferNode extends TreeNode<Id, BufferNode>> = {
20
+ effectActionType: 'nextEntry';
21
+ } | {
22
+ effectActionType: 'prevEntry';
23
+ } | {
24
+ effectActionType: 'setBranchEntries';
25
+ path: Id[];
26
+ entries: BufferNode[] | null;
27
+ } | {
28
+ effectActionType: 'navigateToParent';
29
+ } | {
30
+ effectActionType: 'fold';
31
+ } | {
32
+ effectActionType: 'unfold';
33
+ } | {
34
+ effectActionType: 'toggleFold';
35
+ };
36
+ //# 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,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAG3F,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,UAAU,CAAC;IACvB,IAAI,EAAE,EAAE,EAAE,CAAC;CACZ,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 @@
1
+ export {};
@@ -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 @@
1
+ export {};
@@ -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 @@
1
+ export {};
@@ -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"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "dirvi-lib",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Dependency for dirvi apps.",
5
5
  "license": "LGPL-3.0-or-later",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
8
9
  "files": [
9
10
  "dist"
10
11
  ],
@@ -16,7 +17,9 @@
16
17
  "typescript": "^5.0.0"
17
18
  },
18
19
  "scripts": {
19
- "build": "tsc",
20
- "typecheck": "tsc --noEmit"
20
+ "clean": "rm -rf dist",
21
+ "build": "pnpm clean && tsc",
22
+ "typecheck": "tsc --noEmit",
23
+ "format": "prettier . --write"
21
24
  }
22
25
  }
@@ -1,17 +0,0 @@
1
- import { UnixEntryName, UnixEntryPath } from './unix-entry.js';
2
- import { DisplayRow } from './display-row.js';
3
- export type Cursor = {
4
- kind: 'entry';
5
- parentPath: UnixEntryPath;
6
- entryName: UnixEntryName;
7
- } | {
8
- kind: 'fold';
9
- parentPath: UnixEntryPath;
10
- };
11
- export declare const Cursor: {
12
- equal(left: Cursor, right: Cursor): boolean;
13
- matchesDisplayRow(cursor: Cursor, row: DisplayRow): boolean;
14
- fromDisplayRow(row: DisplayRow): Cursor;
15
- getPath(cursor: Cursor): UnixEntryPath | undefined;
16
- };
17
- //# sourceMappingURL=cursor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/domain/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,MAAM,MAAM,GACd;IACE,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,aAAa,CAAC;IAC1B,SAAS,EAAE,aAAa,CAAC;CAC1B,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,CAAC;CAC3B,CAAC;AAEN,eAAO,MAAM,MAAM;gBACL,MAAM,SAAS,MAAM,GAAG,OAAO;8BAgBjB,MAAM,OAAO,UAAU,GAAG,OAAO;wBAevC,UAAU,GAAG,MAAM;oBAevB,MAAM,GAAG,aAAa,GAAG,SAAS;CAOnD,CAAC"}
@@ -1,44 +0,0 @@
1
- import { UnixEntryPath } from './unix-entry.js';
2
- export const Cursor = {
3
- equal(left, right) {
4
- if (left.kind !== right.kind) {
5
- return false;
6
- }
7
- if (!UnixEntryPath.equal(left.parentPath, right.parentPath)) {
8
- return false;
9
- }
10
- if (left.kind === 'entry' && right.kind === 'entry') {
11
- return left.entryName === right.entryName;
12
- }
13
- return true;
14
- },
15
- matchesDisplayRow(cursor, row) {
16
- if (cursor.kind === 'entry' && row.kind === 'entry') {
17
- return (UnixEntryPath.equal(cursor.parentPath, row.parentPath) &&
18
- cursor.entryName === row.entry.name);
19
- }
20
- if (cursor.kind === 'fold' && row.kind === 'fold') {
21
- return UnixEntryPath.equal(cursor.parentPath, row.parentPath);
22
- }
23
- return false;
24
- },
25
- fromDisplayRow(row) {
26
- if (row.kind === 'entry') {
27
- return {
28
- kind: 'entry',
29
- parentPath: row.parentPath,
30
- entryName: row.entry.name,
31
- };
32
- }
33
- return {
34
- kind: 'fold',
35
- parentPath: row.parentPath,
36
- };
37
- },
38
- getPath(cursor) {
39
- if (cursor.kind === 'fold') {
40
- return undefined;
41
- }
42
- return [...cursor.parentPath, cursor.entryName];
43
- },
44
- };
@@ -1,29 +0,0 @@
1
- import { UnixEntry, UnixEntryName, UnixEntryPath } from './unix-entry.js';
2
- import type { UnixPath } from './unix-path.js';
3
- export type DisplayEntry = {
4
- kind: 'file';
5
- name: UnixEntryName;
6
- } | {
7
- kind: 'symlink';
8
- name: UnixEntryName;
9
- target: UnixPath;
10
- } | {
11
- kind: 'directory';
12
- name: UnixEntryName;
13
- };
14
- export declare const DisplayEntry: {
15
- fromUnixEntry(entry: UnixEntry): DisplayEntry;
16
- };
17
- export type DisplayRow = {
18
- kind: 'entry';
19
- parentPath: UnixEntryPath;
20
- entry: DisplayEntry;
21
- } | {
22
- kind: 'fold';
23
- parentPath: UnixEntryPath;
24
- entryNames: UnixEntryName[];
25
- };
26
- export declare const DisplayRow: {
27
- equal(firstRow: DisplayRow, secondRow: DisplayRow): boolean;
28
- };
29
- //# sourceMappingURL=display-row.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"display-row.d.ts","sourceRoot":"","sources":["../../src/domain/display-row.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;CACrB,CAAC;AAEN,eAAO,MAAM,YAAY;yBACF,SAAS,GAAG,YAAY;CAU9C,CAAA;AAED,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,aAAa,CAAC;IAC1B,KAAK,EAAE,YAAY,CAAC;CACrB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B,CAAC;AAEN,eAAO,MAAM,UAAU;oBACL,UAAU,aAAa,UAAU,GAAG,OAAO;CAqB5D,CAAC"}
@@ -1,29 +0,0 @@
1
- import { UnixEntryPath } from './unix-entry.js';
2
- import { entryNamesEqual } from './unix-entry.js';
3
- export const DisplayEntry = {
4
- fromUnixEntry(entry) {
5
- if (entry.kind === 'directory') {
6
- return {
7
- kind: 'directory',
8
- name: entry.name,
9
- };
10
- }
11
- return entry;
12
- }
13
- };
14
- export const DisplayRow = {
15
- equal(firstRow, secondRow) {
16
- if (firstRow.kind !== secondRow.kind) {
17
- return false;
18
- }
19
- if (firstRow.kind === 'fold' && secondRow.kind === 'fold') {
20
- return (UnixEntryPath.equal(firstRow.parentPath, secondRow.parentPath) &&
21
- entryNamesEqual(firstRow.entryNames, secondRow.entryNames));
22
- }
23
- if (firstRow.kind === 'entry' && secondRow.kind === 'entry') {
24
- return (UnixEntryPath.equal(firstRow.parentPath, secondRow.parentPath) &&
25
- firstRow.entry.name === secondRow.entry.name);
26
- }
27
- return false;
28
- },
29
- };
@@ -1,17 +0,0 @@
1
- import { UnixEntry, UnixEntryName, UnixEntryPath } from './unix-entry.js';
2
- export type FoldNode = {
3
- children: Record<UnixEntryName, FoldNode>;
4
- folds: UnixEntryName[];
5
- };
6
- export declare const FoldNode: {
7
- getAtPath(rootNode: FoldNode, path: UnixEntryPath): FoldNode | undefined;
8
- getIfEntryFolded(node: FoldNode | undefined, entry: UnixEntry): boolean;
9
- modifyAtPath(rootNode: FoldNode, path: UnixEntryName[], modifier: (targetNode: FoldNode) => FoldNode): FoldNode;
10
- addFoldedEntry(node: FoldNode, entry: UnixEntry): FoldNode;
11
- addFoldedEntryAtPath(rootNode: FoldNode, path: UnixEntryName[], entry: UnixEntry): FoldNode;
12
- createEmpty(): FoldNode;
13
- setFoldedEntries(node: FoldNode, entries: UnixEntry[]): FoldNode;
14
- removeFoldedEntry(node: FoldNode, entry: UnixEntry): FoldNode;
15
- clearFoldedEntries(node: FoldNode): FoldNode;
16
- };
17
- //# sourceMappingURL=fold-node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fold-node.d.ts","sourceRoot":"","sources":["../../src/domain/fold-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAC1C,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,QAAQ;wBAEC,QAAQ,QAAQ,aAAa,GAAG,QAAQ,GAAG,SAAS;2BAgBjD,QAAQ,GAAG,SAAS,SAAS,SAAS,GAAG,OAAO;2BAM3D,QAAQ,QACZ,aAAa,EAAE,YACX,CAAC,UAAU,EAAE,QAAQ,KAAK,QAAQ,GAC3C,QAAQ;yBAwBU,QAAQ,SAAS,SAAS,GAAG,QAAQ;mCAU9C,QAAQ,QACZ,aAAa,EAAE,SACd,SAAS,GACf,QAAQ;mBAMI,QAAQ;2BAOA,QAAQ,WAAW,SAAS,EAAE,GAAG,QAAQ;4BAOxC,QAAQ,SAAS,SAAS,GAAG,QAAQ;6BAWpC,QAAQ,GAAG,QAAQ;CAO7C,CAAC"}
@@ -1,81 +0,0 @@
1
- export const FoldNode = {
2
- // Query-Like
3
- getAtPath(rootNode, path) {
4
- const [currentName, ...remainingPath] = path;
5
- if (currentName === undefined) {
6
- return rootNode;
7
- }
8
- const childNode = rootNode.children[currentName];
9
- if (childNode === undefined) {
10
- return undefined;
11
- }
12
- return FoldNode.getAtPath(childNode, remainingPath);
13
- },
14
- getIfEntryFolded(node, entry) {
15
- return node !== undefined && hasFoldedEntryNamed(node, entry.name);
16
- },
17
- // Command/Modifer-Like
18
- modifyAtPath(rootNode, path, modifier) {
19
- const [currentName, ...remainingPath] = path;
20
- // Base case
21
- if (currentName === undefined) {
22
- return modifier(rootNode);
23
- }
24
- // Create childNode to create path in tree to the needed node
25
- const childNode = rootNode.children[currentName] ?? FoldNode.createEmpty();
26
- return {
27
- ...rootNode,
28
- children: {
29
- ...rootNode.children,
30
- [currentName]: FoldNode.modifyAtPath(childNode, remainingPath, modifier),
31
- },
32
- };
33
- },
34
- addFoldedEntry(node, entry) {
35
- // Avoid duplicates
36
- if (hasFoldedEntryNamed(node, entry.name)) {
37
- return node;
38
- }
39
- return setFoldedEntriesNamed(node, [...node.folds, entry.name]);
40
- },
41
- addFoldedEntryAtPath(rootNode, path, entry) {
42
- return FoldNode.modifyAtPath(rootNode, path, (node) => FoldNode.addFoldedEntry(node, entry));
43
- },
44
- createEmpty() {
45
- return {
46
- children: Object.create(null),
47
- folds: [],
48
- };
49
- },
50
- setFoldedEntries(node, entries) {
51
- return setFoldedEntriesNamed(node, entries.map((entry) => entry.name));
52
- },
53
- removeFoldedEntry(node, entry) {
54
- if (!hasFoldedEntryNamed(node, entry.name)) {
55
- return node;
56
- }
57
- return setFoldedEntriesNamed(node, node.folds.filter((entryName) => entryName !== entry.name));
58
- },
59
- clearFoldedEntries(node) {
60
- if (node.folds.length === 0) {
61
- return node;
62
- }
63
- return setFoldedEntriesNamed(node, []);
64
- },
65
- };
66
- // PRIVATE HELPERS
67
- // Queries
68
- function hasFoldedEntryNamed(node, entryName) {
69
- return node.folds.includes(entryName);
70
- }
71
- function uniqueEntryNames(entryNames) {
72
- return [...new Set(entryNames)];
73
- }
74
- // Adding
75
- function setFoldedEntriesNamed(node, entryNames) {
76
- const uniqueNames = uniqueEntryNames(entryNames);
77
- return {
78
- ...node,
79
- folds: uniqueNames,
80
- };
81
- }
@@ -1,10 +0,0 @@
1
- import type { UnixEntryName } from './unix-entry.js';
2
- export type FoldNode = {
3
- children: Record<UnixEntryName, FoldNode>;
4
- folds: UnixEntryName[];
5
- };
6
- export declare const FoldNode: {
7
- createEmpty(): FoldNode;
8
- updateAtPath(rootNode: FoldNode, path: UnixEntryName[], update: (targetNode: FoldNode) => FoldNode): FoldNode;
9
- };
10
- //# sourceMappingURL=fold.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/domain/fold.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAC1C,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,QAAQ;mBACJ,QAAQ;2BAQX,QAAQ,QACZ,aAAa,EAAE,UACb,CAAC,UAAU,EAAE,QAAQ,KAAK,QAAQ,GACzC,QAAQ;CAmBZ,CAAC"}
@@ -1,24 +0,0 @@
1
- export const FoldNode = {
2
- createEmpty() {
3
- return {
4
- children: Object.create(null),
5
- folds: [],
6
- };
7
- },
8
- updateAtPath(rootNode, path, update) {
9
- const [currentName, ...remainingPath] = path;
10
- // Base case
11
- if (currentName === undefined) {
12
- return update(rootNode);
13
- }
14
- // Create childNode to create path in tree to the needed node
15
- const childNode = rootNode.children[currentName] ?? FoldNode.createEmpty();
16
- return {
17
- ...rootNode,
18
- children: {
19
- ...rootNode.children,
20
- [currentName]: FoldNode.updateAtPath(childNode, remainingPath, update),
21
- },
22
- };
23
- }
24
- };
@@ -1,23 +0,0 @@
1
- import { UnixEntryName } from './unix-entry.js';
2
- import { UnixPath } from './unix-path.js';
3
- import { State } from './state.js';
4
- export type NavigationEntry = {
5
- kind: 'file';
6
- name: UnixEntryName;
7
- } | {
8
- kind: 'symlink';
9
- name: UnixEntryName;
10
- target: UnixPath;
11
- } | {
12
- kind: 'directory';
13
- name: UnixEntryName;
14
- node?: NavigationNode;
15
- };
16
- export type NavigationNode = {
17
- entries: NavigationEntry[];
18
- foldedEntries: NavigationEntry[];
19
- };
20
- export declare const NavigationNode: {
21
- derive(state: State): NavigationNode;
22
- };
23
- //# sourceMappingURL=navigation-entry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation-entry.d.ts","sourceRoot":"","sources":["../../src/domain/navigation-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,aAAa,EAAE,eAAe,EAAE,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,cAAc;kBACX,KAAK,GAAG,cAAc;CAGrC,CAAC"}
@@ -1,52 +0,0 @@
1
- export const NavigationNode = {
2
- derive(state) {
3
- return deriveNode(state.buffer.entries, state.folds);
4
- },
5
- };
6
- function deriveNode(entries, foldNode) {
7
- if (entries === undefined) {
8
- return {
9
- entries: [],
10
- foldedEntries: [],
11
- };
12
- }
13
- const foldedNames = new Set(foldNode?.folds ?? []);
14
- const visibleEntries = [];
15
- const foldedEntries = [];
16
- for (const entry of entries) {
17
- const navigationEntry = deriveEntry(entry, foldNode?.children[entry.name]);
18
- if (foldedNames.has(entry.name)) {
19
- foldedEntries.push(navigationEntry);
20
- }
21
- else {
22
- visibleEntries.push(navigationEntry);
23
- }
24
- }
25
- return {
26
- entries: visibleEntries,
27
- foldedEntries,
28
- };
29
- }
30
- function deriveEntry(entry, foldNode) {
31
- switch (entry.kind) {
32
- case 'file':
33
- return {
34
- kind: 'file',
35
- name: entry.name,
36
- };
37
- case 'symlink':
38
- return {
39
- kind: 'symlink',
40
- name: entry.name,
41
- target: entry.target,
42
- };
43
- case 'directory':
44
- return {
45
- kind: 'directory',
46
- name: entry.name,
47
- node: entry.entries === undefined
48
- ? undefined
49
- : deriveNode(entry.entries, foldNode),
50
- };
51
- }
52
- }