@zenfs/dom 1.1.1 → 1.1.3

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
@@ -1,6 +1,5 @@
1
- import { Async, Errno, ErrnoError, FileSystem, InMemory, PreloadFile, Stats } from '@zenfs/core';
2
- import { S_IFDIR, S_IFREG } from '@zenfs/core/emulation/constants.js';
3
- import { basename, dirname, join } from '@zenfs/core/emulation/path.js';
1
+ import { Async, constants, Errno, ErrnoError, FileSystem, InMemory, PreloadFile, Stats } from '@zenfs/core';
2
+ import { basename, dirname, join } from '@zenfs/core/vfs/path.js';
4
3
  import { convertException } from './utils.js';
5
4
  function isResizable(buffer) {
6
5
  if (buffer instanceof ArrayBuffer)
@@ -24,6 +23,8 @@ export class WebAccessFS extends Async(FileSystem) {
24
23
  ...super.metadata(),
25
24
  name: 'WebAccess',
26
25
  noResizableBuffers: true,
26
+ // Not really, but we don't support opening directories so this prevent the VFS from trying
27
+ features: ['setid'],
27
28
  };
28
29
  }
29
30
  async sync(path, data) {
@@ -84,11 +85,11 @@ export class WebAccessFS extends Async(FileSystem) {
84
85
  throw ErrnoError.With('ENOENT', path, 'stat');
85
86
  }
86
87
  if (handle instanceof FileSystemDirectoryHandle) {
87
- return new Stats({ mode: 0o777 | S_IFDIR, size: 4096 });
88
+ return new Stats({ mode: 0o777 | constants.S_IFDIR, size: 4096 });
88
89
  }
89
90
  if (handle instanceof FileSystemFileHandle) {
90
91
  const { lastModified, size } = await handle.getFile();
91
- return new Stats({ mode: 0o777 | S_IFREG, size, mtimeMs: lastModified });
92
+ return new Stats({ mode: 0o777 | constants.S_IFREG, size, mtimeMs: lastModified });
92
93
  }
93
94
  throw new ErrnoError(Errno.EBADE, 'Handle is not a directory or file', path, 'stat');
94
95
  }
@@ -101,7 +102,7 @@ export class WebAccessFS extends Async(FileSystem) {
101
102
  throw convertException(ex, path, 'openFile');
102
103
  });
103
104
  const data = new Uint8Array(await file.arrayBuffer());
104
- const stats = new Stats({ mode: 0o777 | S_IFREG, size: file.size, mtimeMs: file.lastModified });
105
+ const stats = new Stats({ mode: 0o777 | constants.S_IFREG, size: file.size, mtimeMs: file.lastModified });
105
106
  return new PreloadFile(this, path, flag, stats, data);
106
107
  }
107
108
  async unlink(path) {
@@ -120,7 +121,7 @@ export class WebAccessFS extends Async(FileSystem) {
120
121
  async rmdir(path) {
121
122
  return this.unlink(path);
122
123
  }
123
- async mkdir(path) {
124
+ async mkdir(path, mode, options) {
124
125
  const existingHandle = await this.getHandle(path).catch((ex) => {
125
126
  if (ex.code != 'ENOENT') {
126
127
  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,5 @@
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';
1
+ import { constants, decodeRaw, encodeRaw, Errno, ErrnoError, FileSystem, PreloadFile, Stats, Sync } from '@zenfs/core';
2
+ import { basename, dirname } from '@zenfs/core/vfs/path.js';
4
3
  const statsLikeKeys = ['size', 'mode', 'atimeMs', 'mtimeMs', 'ctimeMs', 'birthtimeMs', 'uid', 'gid', 'ino', 'nlink'];
5
4
  function get_stats(node) {
6
5
  const stats = {};
@@ -37,7 +36,7 @@ export class XMLFS extends Sync(FileSystem) {
37
36
  super();
38
37
  this.root = root;
39
38
  try {
40
- this.mkdirSync('/', 0o777);
39
+ this.mkdirSync('/', 0o777, { uid: 0, gid: 0 });
41
40
  }
42
41
  catch (e) {
43
42
  const error = e;
@@ -45,6 +44,9 @@ export class XMLFS extends Sync(FileSystem) {
45
44
  throw error;
46
45
  }
47
46
  }
47
+ metadata() {
48
+ return { ...super.metadata(), features: ['setid'] };
49
+ }
48
50
  renameSync(oldPath, newPath) {
49
51
  const node = this.get('rename', oldPath);
50
52
  this.remove('rename', node, oldPath);
@@ -57,8 +59,13 @@ export class XMLFS extends Sync(FileSystem) {
57
59
  const node = this.get('openFile', path);
58
60
  return new PreloadFile(this, path, flag, get_stats(node), encodeRaw(node.textContent));
59
61
  }
60
- createFileSync(path, flag, mode) {
61
- const stats = new Stats({ mode: mode | S_IFREG });
62
+ createFileSync(path, flag, mode, { uid, gid }) {
63
+ const parent = this.statSync(dirname(path));
64
+ const stats = new Stats({
65
+ mode: mode | constants.S_IFREG,
66
+ uid: parent.mode & constants.S_ISUID ? parent.uid : uid,
67
+ gid: parent.mode & constants.S_ISGID ? parent.gid : gid,
68
+ });
62
69
  this.create('createFile', path, stats);
63
70
  return new PreloadFile(this, path, flag, stats);
64
71
  }
@@ -76,8 +83,13 @@ export class XMLFS extends Sync(FileSystem) {
76
83
  throw ErrnoError.With('ENOTDIR', path, 'rmdir');
77
84
  this.remove('rmdir', node, path);
78
85
  }
79
- mkdirSync(path, mode) {
80
- const node = this.create('mkdir', path, { mode: mode | S_IFDIR });
86
+ mkdirSync(path, mode, { uid, gid }) {
87
+ const parent = this.statSync(dirname(path));
88
+ const node = this.create('mkdir', path, {
89
+ mode: mode | constants.S_IFDIR,
90
+ uid: parent.mode & constants.S_ISUID ? parent.uid : uid,
91
+ gid: parent.mode & constants.S_ISGID ? parent.gid : gid,
92
+ });
81
93
  node.textContent = '[]';
82
94
  }
83
95
  readdirSync(path) {
@@ -113,12 +125,15 @@ export class XMLFS extends Sync(FileSystem) {
113
125
  }
114
126
  throw ErrnoError.With('ENOENT', path, syscall);
115
127
  }
116
- create(syscall, path, stats = {}) {
128
+ create(syscall, path, stats) {
117
129
  if (this.existsSync(path))
118
130
  throw ErrnoError.With('EEXIST', path, syscall);
119
131
  const node = document.createElement('file');
120
132
  this.add(syscall, node, path);
121
- set_stats(node, new Stats(stats));
133
+ set_stats(node, new Stats({
134
+ ...stats,
135
+ uid: stats.mode,
136
+ }));
122
137
  this.root.append(node);
123
138
  return node;
124
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/dom",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
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
  },
@@ -57,7 +61,7 @@
57
61
  "typescript-eslint": "^8.8.1"
58
62
  },
59
63
  "peerDependencies": {
60
- "@zenfs/core": "^1.6.4"
64
+ "@zenfs/core": "^1.7.0"
61
65
  },
62
66
  "keywords": [
63
67
  "filesystem",