@mak-98/posix-fs-dirvi-app 0.11.0-beta.4 → 0.11.0-beta.7

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.
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import type { TreeNode, TreeNodeApi } from 'dirvi-lib';
2
+ import type { TreeNode, TreeMethods } from 'dirvi-lib';
3
3
  import { UnixPath } from './unix-path.js';
4
4
  /**
5
5
  * A JavaScript-string representation of a non-special POSIX filename.
@@ -24,7 +24,7 @@ export type PosixValue = Readonly<{
24
24
  }>;
25
25
  export type PosixTreeNode = TreeNode<PosixId, PosixValue>;
26
26
  export declare const posixValueSchema: z.ZodType<PosixValue>;
27
- export declare function createConstructors(posixTreeNodeApi: TreeNodeApi<PosixId, PosixValue>): {
27
+ export declare function createConstructors(treeMethods: TreeMethods<PosixId, PosixValue>): {
28
28
  readonly file: (name: PosixId) => PosixTreeNode;
29
29
  readonly symlink: (name: PosixId, target: UnixPath) => PosixTreeNode;
30
30
  readonly unloadedDirectory: (name: PosixId) => PosixTreeNode;
@@ -1 +1 @@
1
- {"version":3,"file":"posix-tree.d.ts","sourceRoot":"","sources":["../../src/domain/posix-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAEV,QAAQ,EACR,WAAW,EACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,QAAQ,EAAkB,MAAM,gBAAgB,CAAC;AAY1D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,aAU1B,CAAC;AAEP;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAY3D;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,QAAQ,CAAC;IACP,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,SAAS,CA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,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;CAClB,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC,CAAC;AAEP,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAuB1D,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAGlD,CAAC;AAMF,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC;0BAGhC,OAAO,KAAG,aAAa;6BAMpB,OAAO,UAAU,QAAQ,KAAG,aAAa;uCAO/B,OAAO,KAAG,aAAa;qCAOvC,OAAO,YACH,QAAQ,CAAC,aAAa,CAAC,KAChC,aAAa,GAAG,SAAS;IAQ5B;;;;;OAKG;6BACW,aAAa,KAAG,OAAO;IAcrC;;;;;;OAMG;wCAEK,aAAa,YACT,QAAQ,CAAC,aAAa,CAAC,KAChC,aAAa,GAAG,SAAS;IAQ5B;;;;OAIG;yCACuB,aAAa,KAAG,aAAa,GAAG,SAAS;EAQtE"}
@@ -40,26 +40,26 @@ export const posixValueSchema = z.discriminatedUnion('kind', [PosixFileEntrySche
40
40
  // -----------------------------------------------------------------------------
41
41
  // POSIX domain constructors
42
42
  // -----------------------------------------------------------------------------
43
- export function createConstructors(posixTreeNodeApi) {
43
+ export function createConstructors(treeMethods) {
44
44
  return {
45
45
  file(name) {
46
- return posixTreeNodeApi.createLeaf(name, {
46
+ return treeMethods.createLeaf(name, {
47
47
  kind: 'file',
48
48
  });
49
49
  },
50
50
  symlink(name, target) {
51
- return posixTreeNodeApi.createLeaf(name, {
51
+ return treeMethods.createLeaf(name, {
52
52
  kind: 'symlink',
53
53
  target,
54
54
  });
55
55
  },
56
56
  unloadedDirectory(name) {
57
- return posixTreeNodeApi.createUnloadedBranch(name, {
57
+ return treeMethods.createUnloadedBranch(name, {
58
58
  kind: 'directory',
59
59
  });
60
60
  },
61
61
  loadedDirectory(name, children) {
62
- return posixTreeNodeApi.createLoadedBranch(name, { kind: 'directory' }, children);
62
+ return treeMethods.createLoadedBranch(name, { kind: 'directory' }, children);
63
63
  },
64
64
  /**
65
65
  * Runtime domain invariant check.
@@ -68,8 +68,8 @@ export function createConstructors(posixTreeNodeApi) {
68
68
  * loaded or unloaded.
69
69
  */
70
70
  isValid(node) {
71
- const entry = posixTreeNodeApi.value(node);
72
- const treeKind = posixTreeNodeApi.kind(node);
71
+ const entry = treeMethods.value(node);
72
+ const treeKind = treeMethods.kind(node);
73
73
  switch (entry.kind) {
74
74
  case 'file':
75
75
  case 'symlink':
@@ -86,10 +86,10 @@ export function createConstructors(posixTreeNodeApi) {
86
86
  * - siblings have duplicate names.
87
87
  */
88
88
  withLoadedChildren(node, children) {
89
- if (posixTreeNodeApi.value(node).kind !== 'directory') {
89
+ if (treeMethods.value(node).kind !== 'directory') {
90
90
  return undefined;
91
91
  }
92
- return posixTreeNodeApi.withLoadedChildren(node, children);
92
+ return treeMethods.withLoadedChildren(node, children);
93
93
  },
94
94
  /**
95
95
  * Converts a directory to an unloaded directory.
@@ -97,10 +97,10 @@ export function createConstructors(posixTreeNodeApi) {
97
97
  * Files and symlinks cannot be converted to branches through this POSIX API.
98
98
  */
99
99
  toUnloadedDirectory(node) {
100
- if (posixTreeNodeApi.value(node).kind !== 'directory') {
100
+ if (treeMethods.value(node).kind !== 'directory') {
101
101
  return undefined;
102
102
  }
103
- return posixTreeNodeApi.toUnloadedBranch(node);
103
+ return treeMethods.toUnloadedBranch(node);
104
104
  },
105
105
  };
106
106
  }
@@ -1,5 +1,5 @@
1
- import type { TreeNode, TreeNodeApi } from 'dirvi-lib';
2
- import { type PosixValue, type PosixId } from '../domain/posix-tree.js';
1
+ import type { AppChild } from 'dirvi-apis';
2
+ import { type PosixId, type PosixValue } from '../domain/posix-tree.js';
3
3
  import { type UnixAbsolutePath } from '../domain/unix-path.js';
4
- export declare function getDirEntries(treeNodeApi: TreeNodeApi<PosixId, PosixValue>, address: UnixAbsolutePath): Promise<TreeNode<PosixId, PosixValue>[]>;
4
+ export declare function getDirEntries(address: UnixAbsolutePath): Promise<readonly AppChild<PosixId, PosixValue>[]>;
5
5
  //# sourceMappingURL=get-dir-entries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-dir-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-dir-entries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EAIb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,gBAAgB,EAAkB,MAAM,wBAAwB,CAAC;AAE/E,wBAAsB,aAAa,CACjC,WAAW,EAAE,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,EAC7C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,CA+B1C"}
1
+ {"version":3,"file":"get-dir-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-dir-entries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,UAAU,EAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,gBAAgB,EAAkB,MAAM,wBAAwB,CAAC;AAE/E,wBAAsB,aAAa,CACjC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,CAoCnD"}
@@ -1,24 +1,27 @@
1
1
  import { readdir, readlink } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
- import { posixFilenameSchema, createConstructors, } from '../domain/posix-tree.js';
3
+ import { posixFilenameSchema, } from '../domain/posix-tree.js';
4
4
  import { UnixPathSchema } from '../domain/unix-path.js';
5
- export async function getDirEntries(treeNodeApi, address) {
5
+ export async function getDirEntries(address) {
6
6
  const directoryEntries = await readdir(address, {
7
7
  withFileTypes: true,
8
8
  });
9
- const constructors = createConstructors(treeNodeApi);
10
- return Promise.all(directoryEntries.map(async (directoryEntry) => {
11
- const id = posixFilenameSchema.parse(directoryEntry.name);
12
- if (directoryEntry.isSymbolicLink()) {
13
- const target = UnixPathSchema.parse(await readlink(join(address, directoryEntry.name)));
14
- return constructors.symlink(id, target);
9
+ return Promise.all(directoryEntries.map(async (entry) => {
10
+ const id = posixFilenameSchema.parse(entry.name);
11
+ if (entry.isSymbolicLink()) {
12
+ const target = UnixPathSchema.parse(await readlink(join(address, entry.name)));
13
+ return { id, kind: 'leaf', value: { kind: 'symlink', target } };
15
14
  }
16
- if (directoryEntry.isDirectory()) {
17
- return constructors.unloadedDirectory(id);
15
+ if (entry.isDirectory()) {
16
+ return {
17
+ id,
18
+ kind: 'unloaded-branch',
19
+ value: { kind: 'directory' },
20
+ };
18
21
  }
19
- if (directoryEntry.isFile()) {
20
- return constructors.file(id);
22
+ if (entry.isFile()) {
23
+ return { id, kind: 'leaf', value: { kind: 'file' } };
21
24
  }
22
- throw new Error(`Unsupported filesystem entry "${join(address, directoryEntry.name)}"`);
25
+ throw new Error(`Unsupported filesystem entry "${join(address, entry.name)}"`);
23
26
  }));
24
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"posix-fs-dirvi-app.d.ts","sourceRoot":"","sources":["../src/posix-fs-dirvi-app.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAa5C;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,SAwD5B,CAAC"}
1
+ {"version":3,"file":"posix-fs-dirvi-app.d.ts","sourceRoot":"","sources":["../src/posix-fs-dirvi-app.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAW5C;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,SAgD5B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { basename, join } from 'node:path';
2
- import { posixFilenameSchema, posixValueSchema, createConstructors, } from './domain/posix-tree.js';
2
+ import { posixFilenameSchema, posixValueSchema, } from './domain/posix-tree.js';
3
3
  import { createFsResyncSubscription } from './infrastructure/load-node-posix-app-api.js';
4
4
  import { getUnixAbsPath } from './infrastructure/get-unix-abs-path.js';
5
5
  import { getDirEntries } from './infrastructure/get-dir-entries.js';
@@ -12,25 +12,26 @@ export const posixAppPlugin = {
12
12
  createAppDefinitionApplicator: (input) => {
13
13
  const unixAbsPath = getUnixAbsPath(input ?? process.cwd());
14
14
  const rootId = posixFilenameSchema.parse(basename(unixAbsPath));
15
- function loadDirectoryEntries(treeNodeApi, path) {
15
+ function loadDirectoryEntries(path) {
16
16
  const address = join(unixAbsPath, ...path);
17
- return getDirEntries(treeNodeApi, address);
17
+ return getDirEntries(address);
18
18
  }
19
19
  const appDefinition = {
20
20
  displayName: `POSIX: ${input}`,
21
- rootId,
21
+ semanticOrder: false,
22
22
  idSchema: posixFilenameSchema,
23
23
  valueSchema: posixValueSchema,
24
- createRoot: async (treeNodeApi) => {
25
- // Start with root branches already loaded
26
- const rootBranches = await loadDirectoryEntries(treeNodeApi, []);
27
- const root = createConstructors(treeNodeApi).loadedDirectory(rootId, rootBranches);
28
- if (root === undefined) {
29
- throw new Error('Cannot create POSIX root: duplicate directory entry names');
30
- }
31
- return root;
24
+ loadChildren: (path) => loadDirectoryEntries(path),
25
+ loadRoot: async () => ({
26
+ id: rootId,
27
+ value: { kind: 'directory' },
28
+ }),
29
+ presentNode: (id, isBranch) => {
30
+ return {
31
+ content: id,
32
+ highlight: isBranch ? 'directory' : 'leaf',
33
+ };
32
34
  },
33
- loadChildren: (treeNodeApi, path) => loadDirectoryEntries(treeNodeApi, path),
34
35
  subscribeToResync: createFsResyncSubscription(join(unixAbsPath)),
35
36
  createNavNodeApiOptions: {
36
37
  compareSiblings: (left, right) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mak-98/posix-fs-dirvi-app",
3
- "version": "0.11.0-beta.4",
3
+ "version": "0.11.0-beta.7",
4
4
  "description": "POSIX filesystem app for dirvi.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",
@@ -19,12 +19,12 @@
19
19
  "node": ">=22"
20
20
  },
21
21
  "dependencies": {
22
- "dirvi-apis": "0.11.0-beta.4",
22
+ "dirvi-apis": "0.11.0-beta.7",
23
23
  "zod": "^4.4.3",
24
24
  "env-paths": "^4.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "dirvi-lib": "0.11.0-beta.4",
27
+ "dirvi-lib": "0.11.0-beta.7",
28
28
  "@types/node": "^22.0.0",
29
29
  "typescript": "^5.0.0"
30
30
  },