dirvi-lib 0.4.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.
- package/dist/domain/posix-node.d.ts +29 -0
- package/dist/domain/posix-node.d.ts.map +1 -0
- package/dist/domain/posix-node.js +20 -0
- package/dist/domain/unix-path.d.ts +1 -1
- package/dist/domain/unix-path.js +6 -9
- package/dist/index.d.ts +9 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -13
- package/dist/tree-surfer/cursor.d.ts +24 -0
- package/dist/tree-surfer/cursor.d.ts.map +1 -0
- package/dist/tree-surfer/cursor.js +65 -0
- package/dist/tree-surfer/fold-node/fold-node.impl.d.ts +5 -0
- package/dist/tree-surfer/fold-node/fold-node.impl.d.ts.map +1 -0
- package/dist/tree-surfer/fold-node/fold-node.impl.js +143 -0
- package/dist/tree-surfer/fold-node/fold-node.types.d.ts +70 -0
- package/dist/tree-surfer/fold-node/fold-node.types.d.ts.map +1 -0
- package/dist/tree-surfer/fold-node/fold-node.types.js +1 -0
- package/dist/tree-surfer/index.d.ts +9 -0
- package/dist/tree-surfer/index.d.ts.map +1 -0
- package/dist/tree-surfer/index.js +8 -0
- package/dist/tree-surfer/nav-node/nav-node.impl.d.ts +6 -0
- package/dist/tree-surfer/nav-node/nav-node.impl.d.ts.map +1 -0
- package/dist/tree-surfer/nav-node/nav-node.impl.js +191 -0
- package/dist/tree-surfer/nav-node/nav-node.types.d.ts +42 -0
- package/dist/tree-surfer/nav-node/nav-node.types.d.ts.map +1 -0
- package/dist/tree-surfer/nav-node/nav-node.types.js +3 -0
- package/dist/tree-surfer/state.d.ts +19 -0
- package/dist/tree-surfer/state.d.ts.map +1 -0
- package/dist/tree-surfer/state.js +109 -0
- package/dist/tree-surfer/tree-node/tree-node.arb.d.ts +31 -0
- package/dist/tree-surfer/tree-node/tree-node.arb.d.ts.map +1 -0
- package/dist/tree-surfer/tree-node/tree-node.arb.js +80 -0
- package/dist/tree-surfer/tree-node/tree-node.impl.d.ts +13 -0
- package/dist/tree-surfer/tree-node/tree-node.impl.d.ts.map +1 -0
- package/dist/tree-surfer/tree-node/tree-node.impl.js +87 -0
- package/dist/tree-surfer/tree-node/tree-node.test.d.ts +2 -0
- package/dist/tree-surfer/tree-node/tree-node.test.d.ts.map +1 -0
- package/dist/tree-surfer/tree-node/tree-node.test.js +117 -0
- package/dist/tree-surfer/tree-node/tree-node.types.d.ts +184 -0
- package/dist/tree-surfer/tree-node/tree-node.types.d.ts.map +1 -0
- package/dist/tree-surfer/tree-node/tree-node.types.js +12 -0
- package/dist/tree-surfer-ui/application/index.d.ts +3 -0
- package/dist/tree-surfer-ui/application/index.d.ts.map +1 -0
- package/dist/tree-surfer-ui/application/index.js +2 -0
- package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.d.ts +2 -0
- package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.d.ts.map +1 -0
- package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.js +192 -0
- package/dist/tree-surfer-ui/application/intent-to-effect.d.ts +6 -0
- package/dist/tree-surfer-ui/application/intent-to-effect.d.ts.map +1 -0
- package/dist/tree-surfer-ui/application/intent-to-effect.js +137 -0
- package/dist/tree-surfer-ui/application/user-input-to-intent.d.ts +3 -0
- package/dist/tree-surfer-ui/application/user-input-to-intent.d.ts.map +1 -0
- package/dist/tree-surfer-ui/application/user-input-to-intent.js +98 -0
- package/dist/tree-surfer-ui/application/user-input-to-intent.test.d.ts +2 -0
- package/dist/tree-surfer-ui/application/user-input-to-intent.test.d.ts.map +1 -0
- package/dist/tree-surfer-ui/application/user-input-to-intent.test.js +118 -0
- package/dist/tree-surfer-ui/domain/effect.d.ts +36 -0
- package/dist/tree-surfer-ui/domain/effect.d.ts.map +1 -0
- package/dist/tree-surfer-ui/domain/index.d.ts +5 -0
- package/dist/tree-surfer-ui/domain/index.d.ts.map +1 -0
- package/dist/tree-surfer-ui/domain/index.js +4 -0
- package/dist/tree-surfer-ui/domain/input-state.d.ts +8 -0
- package/dist/tree-surfer-ui/domain/input-state.d.ts.map +1 -0
- package/dist/tree-surfer-ui/domain/intent.d.ts +25 -0
- package/dist/tree-surfer-ui/domain/intent.d.ts.map +1 -0
- package/dist/tree-surfer-ui/domain/user-input.d.ts +19 -0
- package/dist/tree-surfer-ui/domain/user-input.d.ts.map +1 -0
- package/package.json +3 -2
- package/dist/application/intent-to-effect-no-state.test.d.ts +0 -2
- package/dist/application/intent-to-effect-no-state.test.d.ts.map +0 -1
- package/dist/application/intent-to-effect-no-state.test.js +0 -178
- package/dist/application/intent-to-effect.d.ts +0 -8
- package/dist/application/intent-to-effect.d.ts.map +0 -1
- package/dist/application/intent-to-effect.js +0 -142
- package/dist/application/intent-to-effect.test-no-state.d.ts +0 -2
- package/dist/application/intent-to-effect.test-no-state.d.ts.map +0 -1
- package/dist/application/intent-to-effect.test-no-state.js +0 -178
- package/dist/application/user-input-to-intent.d.ts +0 -8
- package/dist/application/user-input-to-intent.d.ts.map +0 -1
- package/dist/application/user-input-to-intent.js +0 -98
- package/dist/application/user-input-to-intent.test.d.ts +0 -2
- package/dist/application/user-input-to-intent.test.d.ts.map +0 -1
- package/dist/application/user-input-to-intent.test.js +0 -125
- package/dist/domain/cursor.d.ts +0 -19
- package/dist/domain/cursor.d.ts.map +0 -1
- package/dist/domain/cursor.js +0 -46
- package/dist/domain/display-row.d.ts +0 -34
- package/dist/domain/display-row.d.ts.map +0 -1
- package/dist/domain/display-row.js +0 -33
- package/dist/domain/effect.d.ts +0 -48
- package/dist/domain/effect.d.ts.map +0 -1
- package/dist/domain/fold-node.d.ts +0 -25
- package/dist/domain/fold-node.d.ts.map +0 -1
- package/dist/domain/fold-node.js +0 -93
- package/dist/domain/input-state.d.ts +0 -10
- package/dist/domain/input-state.d.ts.map +0 -1
- package/dist/domain/intent.d.ts +0 -34
- package/dist/domain/intent.d.ts.map +0 -1
- package/dist/domain/navigation-node.d.ts +0 -58
- package/dist/domain/navigation-node.d.ts.map +0 -1
- package/dist/domain/navigation-node.js +0 -210
- package/dist/domain/state.d.ts +0 -12
- package/dist/domain/state.d.ts.map +0 -1
- package/dist/domain/state.js +0 -12
- package/dist/domain/unix-entry.d.ts +0 -44
- package/dist/domain/unix-entry.d.ts.map +0 -1
- package/dist/domain/unix-entry.js +0 -108
- package/dist/domain/user-input.d.ts +0 -27
- package/dist/domain/user-input.d.ts.map +0 -1
- package/dist/infrastructure/get-cwd.d.ts +0 -3
- package/dist/infrastructure/get-cwd.d.ts.map +0 -1
- package/dist/infrastructure/get-cwd.js +0 -15
- package/dist/infrastructure/get-dir-lazy-entries.d.ts +0 -6
- package/dist/infrastructure/get-dir-lazy-entries.d.ts.map +0 -1
- package/dist/infrastructure/get-dir-lazy-entries.js +0 -40
- /package/dist/{domain → tree-surfer-ui/domain}/effect.js +0 -0
- /package/dist/{domain → tree-surfer-ui/domain}/input-state.js +0 -0
- /package/dist/{domain → tree-surfer-ui/domain}/intent.js +0 -0
- /package/dist/{domain → tree-surfer-ui/domain}/user-input.js +0 -0
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
// UNIX ENTRY
|
|
3
|
-
export const UnixEntryNameSchema = z
|
|
4
|
-
.string()
|
|
5
|
-
.min(1)
|
|
6
|
-
.refine((value) => !value.includes('/'), {
|
|
7
|
-
message: "Entry name must not contain '/'",
|
|
8
|
-
})
|
|
9
|
-
.refine((value) => value !== '.' && value !== '..', {
|
|
10
|
-
message: "Entry name cannot be '.' or '..'",
|
|
11
|
-
});
|
|
12
|
-
export function entryNamesEqual(left, right) {
|
|
13
|
-
return (
|
|
14
|
-
left.length === right.length &&
|
|
15
|
-
left.every((name, index) => name === right[index])
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
export const UnixEntry = {
|
|
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) {
|
|
28
|
-
return undefined;
|
|
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
|
-
);
|
|
67
|
-
}
|
|
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
|
-
},
|
|
97
|
-
};
|
|
98
|
-
export const UnixEntryPath = {
|
|
99
|
-
equal(left, right) {
|
|
100
|
-
return entryNamesEqual(left, right);
|
|
101
|
-
},
|
|
102
|
-
isStrictPathPrefix(prefix, path) {
|
|
103
|
-
if (path.length <= prefix.length) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
return prefix.every((name, index) => path[index] === name);
|
|
107
|
-
},
|
|
108
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-cwd.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-cwd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,wBAAgB,aAAa,IAAI,gBAAgB,CAgBhD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { UnixAbsolutePathSchema } from '../domain/unix-path.js';
|
|
2
|
-
export function getCwdAbsPath() {
|
|
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;
|
|
15
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { UnixAbsolutePath } from '../domain/unix-path.js';
|
|
2
|
-
import type { UnixEntry } from '../domain/unix-entry.js';
|
|
3
|
-
export declare function getDirLazyEntries(
|
|
4
|
-
address: UnixAbsolutePath,
|
|
5
|
-
): Promise<UnixEntry[]>;
|
|
6
|
-
//# sourceMappingURL=get-dir-lazy-entries.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-dir-lazy-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-dir-lazy-entries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGzD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC,CAyCtB"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { readdir, readlink } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { UnixPathSchema } from '../domain/unix-path.js';
|
|
4
|
-
import { UnixEntryNameSchema } from '../domain/unix-entry.js';
|
|
5
|
-
export async function getDirLazyEntries(address) {
|
|
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
|
-
);
|
|
40
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|