dirvi-lib 0.3.0 → 0.4.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/dist/application/intent-to-effect-no-state.test.d.ts +2 -0
- package/dist/application/intent-to-effect-no-state.test.d.ts.map +1 -0
- package/dist/application/intent-to-effect-no-state.test.js +178 -0
- package/dist/application/intent-to-effect.d.ts +8 -0
- package/dist/application/intent-to-effect.d.ts.map +1 -0
- package/dist/application/intent-to-effect.js +142 -0
- package/dist/application/intent-to-effect.test-no-state.d.ts +2 -0
- package/dist/application/intent-to-effect.test-no-state.d.ts.map +1 -0
- package/dist/application/intent-to-effect.test-no-state.js +178 -0
- package/dist/application/user-input-to-intent.d.ts +8 -0
- package/dist/application/user-input-to-intent.d.ts.map +1 -0
- package/dist/application/user-input-to-intent.js +98 -0
- package/dist/application/user-input-to-intent.test.d.ts +2 -0
- package/dist/application/user-input-to-intent.test.d.ts.map +1 -0
- package/dist/application/user-input-to-intent.test.js +125 -0
- package/dist/domain/cursor.d.ts +15 -13
- package/dist/domain/cursor.js +43 -41
- package/dist/domain/display-row.d.ts +28 -23
- package/dist/domain/display-row.d.ts.map +1 -1
- package/dist/domain/display-row.js +26 -22
- package/dist/domain/effect.d.ts +48 -0
- package/dist/domain/effect.d.ts.map +1 -0
- package/dist/domain/effect.js +1 -0
- package/dist/domain/fold-node.d.ts +20 -12
- package/dist/domain/fold-node.js +82 -70
- package/dist/domain/input-state.d.ts +10 -0
- package/dist/domain/input-state.d.ts.map +1 -0
- package/dist/domain/input-state.js +1 -0
- package/dist/domain/intent.d.ts +34 -0
- package/dist/domain/intent.d.ts.map +1 -0
- package/dist/domain/intent.js +1 -0
- package/dist/domain/navigation-node.d.ts +47 -32
- package/dist/domain/navigation-node.js +201 -189
- package/dist/domain/state.d.ts +5 -5
- package/dist/domain/state.d.ts.map +1 -1
- package/dist/domain/state.js +7 -7
- package/dist/domain/unix-entry.d.ts +35 -19
- package/dist/domain/unix-entry.d.ts.map +1 -1
- package/dist/domain/unix-entry.js +94 -82
- package/dist/domain/unix-path.d.ts +1 -1
- package/dist/domain/unix-path.js +9 -6
- package/dist/domain/user-input.d.ts +27 -0
- package/dist/domain/user-input.d.ts.map +1 -0
- package/dist/domain/user-input.js +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/infrastructure/get-cwd.d.ts +1 -1
- package/dist/infrastructure/get-cwd.js +12 -10
- package/dist/infrastructure/get-dir-lazy-entries.d.ts +4 -2
- package/dist/infrastructure/get-dir-lazy-entries.js +34 -28
- package/package.json +4 -2
- package/dist/domain/fold.d.ts +0 -10
- package/dist/domain/fold.d.ts.map +0 -1
- package/dist/domain/fold.js +0 -24
- package/dist/domain/navigation-entry.d.ts +0 -23
- package/dist/domain/navigation-entry.d.ts.map +0 -1
- package/dist/domain/navigation-entry.js +0 -52
- package/dist/domain/view.d.ts +0 -15
- package/dist/domain/view.d.ts.map +0 -1
- package/dist/domain/view.js +0 -12
|
@@ -1,96 +1,108 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
// UNIX ENTRY
|
|
3
3
|
export const UnixEntryNameSchema = z
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
.string()
|
|
5
|
+
.min(1)
|
|
6
|
+
.refine((value) => !value.includes('/'), {
|
|
7
7
|
message: "Entry name must not contain '/'",
|
|
8
|
-
})
|
|
9
|
-
|
|
8
|
+
})
|
|
9
|
+
.refine((value) => value !== '.' && value !== '..', {
|
|
10
10
|
message: "Entry name cannot be '.' or '..'",
|
|
11
|
-
});
|
|
11
|
+
});
|
|
12
12
|
export function entryNamesEqual(left, right) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
return (
|
|
14
|
+
left.length === right.length &&
|
|
15
|
+
left.every((name, index) => name === right[index])
|
|
16
|
+
);
|
|
15
17
|
}
|
|
16
18
|
export const UnixEntry = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
if (index === path.length - 1) {
|
|
29
|
-
return entry;
|
|
30
|
-
}
|
|
31
|
-
if (entry.kind !== 'directory' || entry.entries === undefined) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
entries = entry.entries;
|
|
35
|
-
}
|
|
19
|
+
// Query-Like
|
|
20
|
+
getEntryAtPath(entries, path) {
|
|
21
|
+
if (path.length === 0) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
let entry;
|
|
25
|
+
for (const [index, name] of path.entries()) {
|
|
26
|
+
entry = entries.find((candidate) => candidate.name === name);
|
|
27
|
+
if (entry === undefined) {
|
|
36
28
|
return undefined;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
...entry,
|
|
77
|
-
entries: UnixEntry.setEntriesAtPath(entry.entries, remainingPath, newEntries),
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
if (!found) {
|
|
81
|
-
throw new Error(`Directory path does not contain entry "${currentName}"`);
|
|
29
|
+
}
|
|
30
|
+
if (index === path.length - 1) {
|
|
31
|
+
return entry;
|
|
32
|
+
}
|
|
33
|
+
if (entry.kind !== 'directory' || entry.entries === undefined) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
entries = entry.entries;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
},
|
|
40
|
+
getEntriesAtPath(entries, path) {
|
|
41
|
+
if (path.length === 0) {
|
|
42
|
+
return entries;
|
|
43
|
+
}
|
|
44
|
+
const entry = UnixEntry.getEntryAtPath(entries, path);
|
|
45
|
+
if (entry?.kind !== 'directory') {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return entry.entries;
|
|
49
|
+
},
|
|
50
|
+
// Command/Modifer-Like
|
|
51
|
+
setEntriesAtPath(entries, path, newEntries) {
|
|
52
|
+
const [currentName, ...remainingPath] = path;
|
|
53
|
+
if (currentName === undefined) {
|
|
54
|
+
throw new Error('Cannot update directory entries with an empty path');
|
|
55
|
+
}
|
|
56
|
+
let found = false;
|
|
57
|
+
const updatedEntries = entries.map((entry) => {
|
|
58
|
+
if (entry.name !== currentName) {
|
|
59
|
+
return entry;
|
|
60
|
+
}
|
|
61
|
+
found = true;
|
|
62
|
+
if (remainingPath.length === 0) {
|
|
63
|
+
if (entry.kind !== 'directory') {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`Cannot update entries for non-directory entry "${entry.name}"`,
|
|
66
|
+
);
|
|
82
67
|
}
|
|
83
|
-
return
|
|
84
|
-
|
|
68
|
+
return {
|
|
69
|
+
...entry,
|
|
70
|
+
entries: newEntries,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (entry.kind !== 'directory') {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Cannot descend through non-directory entry "${entry.name}"`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (entry.entries === undefined) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`Cannot descend into unexpanded directory "${entry.name}"`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
...entry,
|
|
85
|
+
entries: UnixEntry.setEntriesAtPath(
|
|
86
|
+
entry.entries,
|
|
87
|
+
remainingPath,
|
|
88
|
+
newEntries,
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
if (!found) {
|
|
93
|
+
throw new Error(`Directory path does not contain entry "${currentName}"`);
|
|
94
|
+
}
|
|
95
|
+
return updatedEntries;
|
|
96
|
+
},
|
|
85
97
|
};
|
|
86
98
|
export const UnixEntryPath = {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
return prefix.every((name, index) => path[index] === name);
|
|
99
|
+
equal(left, right) {
|
|
100
|
+
return entryNamesEqual(left, right);
|
|
101
|
+
},
|
|
102
|
+
isStrictPathPrefix(prefix, path) {
|
|
103
|
+
if (path.length <= prefix.length) {
|
|
104
|
+
return false;
|
|
95
105
|
}
|
|
106
|
+
return prefix.every((name, index) => path[index] === name);
|
|
107
|
+
},
|
|
96
108
|
};
|
|
@@ -3,4 +3,4 @@ export declare const UnixPathSchema: z.ZodString;
|
|
|
3
3
|
export type UnixPath = z.output<typeof UnixPathSchema>;
|
|
4
4
|
export declare const UnixAbsolutePathSchema: z.ZodString;
|
|
5
5
|
export type UnixAbsolutePath = z.output<typeof UnixAbsolutePathSchema>;
|
|
6
|
-
//# sourceMappingURL=unix-path.d.ts.map
|
|
6
|
+
//# sourceMappingURL=unix-path.d.ts.map
|
package/dist/domain/unix-path.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
// UNIX PATHS
|
|
3
3
|
export const UnixPathSchema = z
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
.string()
|
|
5
|
+
.min(1)
|
|
6
|
+
.refine((value) => !value.includes('\0'), {
|
|
7
7
|
message: 'Unix paths must not contain null bytes',
|
|
8
|
-
});
|
|
9
|
-
export const UnixAbsolutePathSchema = UnixPathSchema.refine(
|
|
8
|
+
});
|
|
9
|
+
export const UnixAbsolutePathSchema = UnixPathSchema.refine(
|
|
10
|
+
(value) => value.startsWith('/'),
|
|
11
|
+
{
|
|
10
12
|
message: 'Path must be an absolute Unix path',
|
|
11
|
-
}
|
|
13
|
+
},
|
|
14
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type UserInput =
|
|
2
|
+
| {
|
|
3
|
+
userInputType: 'character';
|
|
4
|
+
string: string;
|
|
5
|
+
}
|
|
6
|
+
| {
|
|
7
|
+
userInputType: 'enter';
|
|
8
|
+
}
|
|
9
|
+
| {
|
|
10
|
+
userInputType: 'backspace';
|
|
11
|
+
}
|
|
12
|
+
| {
|
|
13
|
+
userInputType: 'esc';
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
userInputType: 'rightArrow';
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
userInputType: 'leftArrow';
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
userInputType: 'downArrow';
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
userInputType: 'upArrow';
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=user-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-input.d.ts","sourceRoot":"","sources":["../../src/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/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
export * from './application/user-input-to-intent.js';
|
|
2
|
+
export * from './application/intent-to-effect.js';
|
|
1
3
|
export * from './domain/cursor.js';
|
|
2
4
|
export * from './domain/display-row.js';
|
|
5
|
+
export * from './domain/effect.js';
|
|
3
6
|
export * from './domain/fold-node.js';
|
|
7
|
+
export * from './domain/input-state.js';
|
|
4
8
|
export * from './domain/navigation-node.js';
|
|
5
9
|
export * from './domain/state.js';
|
|
6
10
|
export * from './domain/unix-entry.js';
|
|
7
11
|
export * from './domain/unix-path.js';
|
|
12
|
+
export * from './domain/user-input.js';
|
|
8
13
|
export * from './infrastructure/get-cwd.js';
|
|
9
14
|
export * from './infrastructure/get-dir-lazy-entries.js';
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAElD,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0CAA0C,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
export * from './application/user-input-to-intent.js';
|
|
2
|
+
export * from './application/intent-to-effect.js';
|
|
1
3
|
export * from './domain/cursor.js';
|
|
2
4
|
export * from './domain/display-row.js';
|
|
5
|
+
export * from './domain/effect.js';
|
|
3
6
|
export * from './domain/fold-node.js';
|
|
7
|
+
export * from './domain/input-state.js';
|
|
4
8
|
export * from './domain/navigation-node.js';
|
|
5
9
|
export * from './domain/state.js';
|
|
6
10
|
export * from './domain/unix-entry.js';
|
|
7
11
|
export * from './domain/unix-path.js';
|
|
12
|
+
export * from './domain/user-input.js';
|
|
8
13
|
export * from './infrastructure/get-cwd.js';
|
|
9
14
|
export * from './infrastructure/get-dir-lazy-entries.js';
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { UnixAbsolutePathSchema } from '../domain/unix-path.js';
|
|
2
2
|
export function getCwdAbsPath() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
const currentWorkingDirectory = process.cwd();
|
|
4
|
+
const result = UnixAbsolutePathSchema.safeParse(currentWorkingDirectory);
|
|
5
|
+
if (!result.success) {
|
|
6
|
+
const details = result.error.issues
|
|
7
|
+
.map((issue) => issue.message)
|
|
8
|
+
.join('; ');
|
|
9
|
+
throw new Error(
|
|
10
|
+
`Bad path for current working directory ` +
|
|
11
|
+
`"${currentWorkingDirectory}": ${details}`,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return result.data;
|
|
13
15
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { UnixAbsolutePath } from '../domain/unix-path.js';
|
|
2
2
|
import type { UnixEntry } from '../domain/unix-entry.js';
|
|
3
|
-
export declare function getDirLazyEntries(
|
|
4
|
-
|
|
3
|
+
export declare function getDirLazyEntries(
|
|
4
|
+
address: UnixAbsolutePath,
|
|
5
|
+
): Promise<UnixEntry[]>;
|
|
6
|
+
//# sourceMappingURL=get-dir-lazy-entries.d.ts.map
|
|
@@ -3,32 +3,38 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { UnixPathSchema } from '../domain/unix-path.js';
|
|
4
4
|
import { UnixEntryNameSchema } from '../domain/unix-entry.js';
|
|
5
5
|
export async function getDirLazyEntries(address) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
const directoryEntries = await readdir(address, {
|
|
7
|
+
withFileTypes: true,
|
|
8
|
+
});
|
|
9
|
+
return Promise.all(
|
|
10
|
+
directoryEntries.map(async (directoryEntry) => {
|
|
11
|
+
const name = UnixEntryNameSchema.parse(directoryEntry.name);
|
|
12
|
+
if (directoryEntry.isSymbolicLink()) {
|
|
13
|
+
const target = UnixPathSchema.parse(
|
|
14
|
+
await readlink(join(address, directoryEntry.name)),
|
|
15
|
+
);
|
|
16
|
+
return {
|
|
17
|
+
kind: 'symlink',
|
|
18
|
+
name,
|
|
19
|
+
target,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (directoryEntry.isDirectory()) {
|
|
23
|
+
return {
|
|
24
|
+
kind: 'directory',
|
|
25
|
+
name,
|
|
26
|
+
// Deliberately omitted: this directory has not been expanded.
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (directoryEntry.isFile()) {
|
|
30
|
+
return {
|
|
31
|
+
kind: 'file',
|
|
32
|
+
name,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Unsupported filesystem entry "${join(address, directoryEntry.name)}"`,
|
|
37
|
+
);
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
34
40
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirvi-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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
|
],
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
},
|
|
18
19
|
"scripts": {
|
|
19
20
|
"build": "tsc",
|
|
20
|
-
"typecheck": "tsc --noEmit"
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"format": "prettier . --write"
|
|
21
23
|
}
|
|
22
24
|
}
|
package/dist/domain/fold.d.ts
DELETED
|
@@ -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"}
|
package/dist/domain/fold.js
DELETED
|
@@ -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
|
-
}
|
package/dist/domain/view.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { UnixEntry } from './unix-entry.js';
|
|
2
|
-
import type { FoldNode } from './fold-node.js';
|
|
3
|
-
import { Cursor } from './cursor.js';
|
|
4
|
-
export type DirectoryBuffer = {
|
|
5
|
-
entries: UnixEntry[];
|
|
6
|
-
};
|
|
7
|
-
export type View = {
|
|
8
|
-
buffer: DirectoryBuffer;
|
|
9
|
-
folds: FoldNode;
|
|
10
|
-
cursor: Cursor;
|
|
11
|
-
};
|
|
12
|
-
export declare const View: {
|
|
13
|
-
getEntryAtCursor(view: View): UnixEntry | undefined;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/domain/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,IAAI;2BACQ,IAAI,GAAG,SAAS,GAAG,SAAS;CAUpD,CAAA"}
|
package/dist/domain/view.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { UnixEntry } from './unix-entry.js';
|
|
2
|
-
import { Cursor } from './cursor.js';
|
|
3
|
-
export const View = {
|
|
4
|
-
getEntryAtCursor(view) {
|
|
5
|
-
const path = Cursor.getPath(view.cursor);
|
|
6
|
-
// Nothing on folds
|
|
7
|
-
if (path === undefined) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
return UnixEntry.getEntryAtPath(view.buffer.entries, path);
|
|
11
|
-
}
|
|
12
|
-
};
|