@zenfs/dom 1.1.0 → 1.1.2

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/access.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { FileSystemMetadata } from '@zenfs/core';
1
+ import type { CreationOptions, FileSystemMetadata } from '@zenfs/core';
2
2
  import { FileSystem, PreloadFile, Stats } from '@zenfs/core';
3
3
  export interface WebAccessOptions {
4
4
  handle: FileSystemDirectoryHandle;
@@ -21,7 +21,7 @@ export declare class WebAccessFS extends WebAccessFS_base {
21
21
  unlink(path: string): Promise<void>;
22
22
  link(srcpath: string): Promise<void>;
23
23
  rmdir(path: string): Promise<void>;
24
- mkdir(path: string): Promise<void>;
24
+ mkdir(path: string, mode?: number, options?: CreationOptions): Promise<void>;
25
25
  readdir(path: string): Promise<string[]>;
26
26
  protected getHandle(path: string): Promise<FileSystemHandle | undefined>;
27
27
  }
package/dist/access.js CHANGED
@@ -24,6 +24,8 @@ export class WebAccessFS extends Async(FileSystem) {
24
24
  ...super.metadata(),
25
25
  name: 'WebAccess',
26
26
  noResizableBuffers: true,
27
+ // Not really, but we don't support opening directories so this prevent the VFS from trying
28
+ features: ['setid'],
27
29
  };
28
30
  }
29
31
  async sync(path, data) {
@@ -120,7 +122,7 @@ export class WebAccessFS extends Async(FileSystem) {
120
122
  async rmdir(path) {
121
123
  return this.unlink(path);
122
124
  }
123
- async mkdir(path) {
125
+ async mkdir(path, mode, options) {
124
126
  const existingHandle = await this.getHandle(path).catch((ex) => {
125
127
  if (ex.code != 'ENOENT') {
126
128
  throw ex;
package/dist/xml.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { File, StatsLike } from '@zenfs/core';
1
+ import type { CreationOptions, File, FileSystemMetadata, StatsLike } from '@zenfs/core';
2
2
  import { FileSystem, Stats } from '@zenfs/core';
3
3
  export interface XMLOptions {
4
4
  /**
@@ -6,7 +6,7 @@ export interface XMLOptions {
6
6
  */
7
7
  root?: Element;
8
8
  }
9
- declare const XMLFS_base: import("@zenfs/core").Mixin<typeof FileSystem, import("utilium").ExtractProperties<FileSystem, (...args: any[]) => Promise<unknown>>>;
9
+ declare const XMLFS_base: import("@zenfs/core").Mixin<typeof FileSystem, import("@zenfs/core").AsyncFSMethods>;
10
10
  export declare class XMLFS extends XMLFS_base {
11
11
  /**
12
12
  * @inheritdoc XMLOptions.root
@@ -17,19 +17,20 @@ export declare class XMLFS extends XMLFS_base {
17
17
  * @inheritdoc XMLOptions.root
18
18
  */
19
19
  root?: Element);
20
+ metadata(): FileSystemMetadata;
20
21
  renameSync(oldPath: string, newPath: string): void;
21
22
  statSync(path: string): Stats;
22
23
  openFileSync(path: string, flag: string): File;
23
- createFileSync(path: string, flag: string, mode: number): File;
24
+ createFileSync(path: string, flag: string, mode: number, { uid, gid }: CreationOptions): File;
24
25
  unlinkSync(path: string): void;
25
26
  rmdirSync(path: string): void;
26
- mkdirSync(path: string, mode: number): void;
27
+ mkdirSync(path: string, mode: number, { uid, gid }: CreationOptions): void;
27
28
  readdirSync(path: string): string[];
28
29
  linkSync(target: string, link: string): void;
29
30
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
30
31
  toString(): string;
31
32
  protected get(syscall: string, path: string): Element;
32
- protected create(syscall: string, path: string, stats?: Partial<StatsLike<number>>): Element;
33
+ protected create(syscall: string, path: string, stats: Partial<StatsLike<number>> & Pick<StatsLike, 'mode'>): Element;
33
34
  protected add(syscall: string, node: Element, path: string, contents?: boolean): void;
34
35
  protected remove(syscall: string, node: Element, path: string, contents?: boolean): void;
35
36
  }
package/dist/xml.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { decodeRaw, encodeRaw, Errno, ErrnoError, FileSystem, PreloadFile, Stats, Sync } from '@zenfs/core';
2
- import { S_IFDIR, S_IFREG } from '@zenfs/core/emulation/constants.js';
3
- import { basename, dirname } from '@zenfs/core/path';
2
+ import { S_IFDIR, S_IFREG, S_ISGID, S_ISUID } from '@zenfs/core/emulation/constants.js';
3
+ import { basename, dirname } from '@zenfs/core/emulation/path.js';
4
4
  const statsLikeKeys = ['size', 'mode', 'atimeMs', 'mtimeMs', 'ctimeMs', 'birthtimeMs', 'uid', 'gid', 'ino', 'nlink'];
5
5
  function get_stats(node) {
6
6
  const stats = {};
@@ -37,7 +37,7 @@ export class XMLFS extends Sync(FileSystem) {
37
37
  super();
38
38
  this.root = root;
39
39
  try {
40
- this.mkdirSync('/', 0o777);
40
+ this.mkdirSync('/', 0o777, { uid: 0, gid: 0 });
41
41
  }
42
42
  catch (e) {
43
43
  const error = e;
@@ -45,6 +45,9 @@ export class XMLFS extends Sync(FileSystem) {
45
45
  throw error;
46
46
  }
47
47
  }
48
+ metadata() {
49
+ return { ...super.metadata(), features: ['setid'] };
50
+ }
48
51
  renameSync(oldPath, newPath) {
49
52
  const node = this.get('rename', oldPath);
50
53
  this.remove('rename', node, oldPath);
@@ -57,8 +60,13 @@ export class XMLFS extends Sync(FileSystem) {
57
60
  const node = this.get('openFile', path);
58
61
  return new PreloadFile(this, path, flag, get_stats(node), encodeRaw(node.textContent));
59
62
  }
60
- createFileSync(path, flag, mode) {
61
- const stats = new Stats({ mode: mode | S_IFREG });
63
+ createFileSync(path, flag, mode, { uid, gid }) {
64
+ const parent = this.statSync(dirname(path));
65
+ const stats = new Stats({
66
+ mode: mode | S_IFREG,
67
+ uid: parent.mode & S_ISUID ? parent.uid : uid,
68
+ gid: parent.mode & S_ISGID ? parent.gid : gid,
69
+ });
62
70
  this.create('createFile', path, stats);
63
71
  return new PreloadFile(this, path, flag, stats);
64
72
  }
@@ -76,8 +84,13 @@ export class XMLFS extends Sync(FileSystem) {
76
84
  throw ErrnoError.With('ENOTDIR', path, 'rmdir');
77
85
  this.remove('rmdir', node, path);
78
86
  }
79
- mkdirSync(path, mode) {
80
- const node = this.create('mkdir', path, { mode: mode | S_IFDIR });
87
+ mkdirSync(path, mode, { uid, gid }) {
88
+ const parent = this.statSync(dirname(path));
89
+ const node = this.create('mkdir', path, {
90
+ mode: mode | S_IFDIR,
91
+ uid: parent.mode & S_ISUID ? parent.uid : uid,
92
+ gid: parent.mode & S_ISGID ? parent.gid : gid,
93
+ });
81
94
  node.textContent = '[]';
82
95
  }
83
96
  readdirSync(path) {
@@ -113,12 +126,15 @@ export class XMLFS extends Sync(FileSystem) {
113
126
  }
114
127
  throw ErrnoError.With('ENOENT', path, syscall);
115
128
  }
116
- create(syscall, path, stats = {}) {
129
+ create(syscall, path, stats) {
117
130
  if (this.existsSync(path))
118
131
  throw ErrnoError.With('EEXIST', path, syscall);
119
132
  const node = document.createElement('file');
120
133
  this.add(syscall, node, path);
121
- set_stats(node, new Stats(stats));
134
+ set_stats(node, new Stats({
135
+ ...stats,
136
+ uid: stats.mode,
137
+ }));
122
138
  this.root.append(node);
123
139
  return node;
124
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/dom",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "DOM backends for ZenFS",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -19,6 +19,10 @@
19
19
  "type": "git",
20
20
  "url": "git+https://github.com/zen-fs/dom.git"
21
21
  },
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "provenance": true
25
+ },
22
26
  "bugs": {
23
27
  "url": "https://github.com/zen-fs/dom/issues"
24
28
  },
@@ -47,6 +51,8 @@
47
51
  "devDependencies": {
48
52
  "@eslint/js": "^9.12.0",
49
53
  "eslint": "^9.12.0",
54
+ "fake-indexeddb": "^6.0.0",
55
+ "file-system-access": "^1.0.4",
50
56
  "globals": "^15.10.0",
51
57
  "prettier": "^3.2.5",
52
58
  "tsx": "^4.19.2",
@@ -55,11 +61,7 @@
55
61
  "typescript-eslint": "^8.8.1"
56
62
  },
57
63
  "peerDependencies": {
58
- "@zenfs/core": "^1.6.4"
59
- },
60
- "optionalDependencies": {
61
- "fake-indexeddb": "^6.0.0",
62
- "file-system-access": "^1.0.4"
64
+ "@zenfs/core": "^1.7.0"
63
65
  },
64
66
  "keywords": [
65
67
  "filesystem",
package/readme.md CHANGED
@@ -6,9 +6,10 @@ Please read the ZenFS core documentation!
6
6
 
7
7
  ## Backends
8
8
 
9
- - `WebStorage`: Stores files in a `Storage` object, like `localStorage` and `sessionStorage`.
10
- - `IndexedDB`: Stores files into an `IndexedDB` object database.
11
- - `WebAccess`: Store files using the [File System Access API](https://developer.mozilla.org/Web/API/File_System_API).
9
+ - `WebStorage` stores files in a `Storage` object, like `localStorage` and `sessionStorage`.
10
+ - `IndexedDB` stores files into an `IndexedDB` object database.
11
+ - `WebAccess` uses the [File System Access API](https://developer.mozilla.org/Web/API/File_System_API).
12
+ - `XML` uses an `XMLDocument` to store files, which can be appended to the DOM.
12
13
 
13
14
  For more information, see the [API documentation](https://zen-fs.github.io/dom).
14
15