memfs 4.55.0 → 4.56.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.
Files changed (285) hide show
  1. package/README.md +75 -2
  2. package/lib/fsa/index.d.ts +1 -33
  3. package/lib/fsa/index.js +1 -39
  4. package/lib/fsa/index.js.map +1 -1
  5. package/lib/fsa-to-node/index.d.ts +1 -2
  6. package/lib/fsa-to-node/index.js +2 -5
  7. package/lib/fsa-to-node/index.js.map +1 -1
  8. package/lib/index.d.ts +6 -7
  9. package/lib/index.js +10 -14
  10. package/lib/index.js.map +1 -1
  11. package/lib/node-to-fsa/index.d.ts +1 -7
  12. package/lib/node-to-fsa/index.js +1 -10
  13. package/lib/node-to-fsa/index.js.map +1 -1
  14. package/package.json +9 -3
  15. package/lib/constants.d.ts +0 -67
  16. package/lib/constants.js +0 -54
  17. package/lib/constants.js.map +0 -1
  18. package/lib/consts/AMODE.d.ts +0 -9
  19. package/lib/consts/AMODE.js +0 -3
  20. package/lib/consts/AMODE.js.map +0 -1
  21. package/lib/consts/FLAG.d.ts +0 -53
  22. package/lib/consts/FLAG.js +0 -36
  23. package/lib/consts/FLAG.js.map +0 -1
  24. package/lib/core/File.d.ts +0 -39
  25. package/lib/core/File.js +0 -72
  26. package/lib/core/File.js.map +0 -1
  27. package/lib/core/Link.d.ts +0 -38
  28. package/lib/core/Link.js +0 -105
  29. package/lib/core/Link.js.map +0 -1
  30. package/lib/core/Node.d.ts +0 -85
  31. package/lib/core/Node.js +0 -287
  32. package/lib/core/Node.js.map +0 -1
  33. package/lib/core/Superblock.d.ts +0 -92
  34. package/lib/core/Superblock.js +0 -689
  35. package/lib/core/Superblock.js.map +0 -1
  36. package/lib/core/constants.d.ts +0 -15
  37. package/lib/core/constants.js +0 -3
  38. package/lib/core/constants.js.map +0 -1
  39. package/lib/core/index.d.ts +0 -6
  40. package/lib/core/index.js +0 -15
  41. package/lib/core/index.js.map +0 -1
  42. package/lib/core/json.d.ts +0 -9
  43. package/lib/core/json.js +0 -35
  44. package/lib/core/json.js.map +0 -1
  45. package/lib/core/result.d.ts +0 -11
  46. package/lib/core/result.js +0 -11
  47. package/lib/core/result.js.map +0 -1
  48. package/lib/core/types.d.ts +0 -8
  49. package/lib/core/types.js +0 -3
  50. package/lib/core/types.js.map +0 -1
  51. package/lib/core/util.d.ts +0 -12
  52. package/lib/core/util.js +0 -74
  53. package/lib/core/util.js.map +0 -1
  54. package/lib/encoding.d.ts +0 -6
  55. package/lib/encoding.js +0 -20
  56. package/lib/encoding.js.map +0 -1
  57. package/lib/fsa/CoreFileSystemDirectoryHandle.d.ts +0 -73
  58. package/lib/fsa/CoreFileSystemDirectoryHandle.js +0 -265
  59. package/lib/fsa/CoreFileSystemDirectoryHandle.js.map +0 -1
  60. package/lib/fsa/CoreFileSystemFileHandle.d.ts +0 -25
  61. package/lib/fsa/CoreFileSystemFileHandle.js +0 -75
  62. package/lib/fsa/CoreFileSystemFileHandle.js.map +0 -1
  63. package/lib/fsa/CoreFileSystemHandle.d.ts +0 -34
  64. package/lib/fsa/CoreFileSystemHandle.js +0 -53
  65. package/lib/fsa/CoreFileSystemHandle.js.map +0 -1
  66. package/lib/fsa/CoreFileSystemObserver.d.ts +0 -10
  67. package/lib/fsa/CoreFileSystemObserver.js +0 -18
  68. package/lib/fsa/CoreFileSystemObserver.js.map +0 -1
  69. package/lib/fsa/CoreFileSystemSyncAccessHandle.d.ts +0 -38
  70. package/lib/fsa/CoreFileSystemSyncAccessHandle.js +0 -123
  71. package/lib/fsa/CoreFileSystemSyncAccessHandle.js.map +0 -1
  72. package/lib/fsa/CoreFileSystemWritableFileStream.d.ts +0 -32
  73. package/lib/fsa/CoreFileSystemWritableFileStream.js +0 -163
  74. package/lib/fsa/CoreFileSystemWritableFileStream.js.map +0 -1
  75. package/lib/fsa/CorePermissionStatus.d.ts +0 -9
  76. package/lib/fsa/CorePermissionStatus.js +0 -14
  77. package/lib/fsa/CorePermissionStatus.js.map +0 -1
  78. package/lib/fsa/FileLockManager.d.ts +0 -7
  79. package/lib/fsa/FileLockManager.js +0 -26
  80. package/lib/fsa/FileLockManager.js.map +0 -1
  81. package/lib/fsa/types.d.ts +0 -182
  82. package/lib/fsa/types.js +0 -3
  83. package/lib/fsa/types.js.map +0 -1
  84. package/lib/fsa/util.d.ts +0 -12
  85. package/lib/fsa/util.js +0 -45
  86. package/lib/fsa/util.js.map +0 -1
  87. package/lib/fsa-to-node/FsaNodeCore.d.ts +0 -33
  88. package/lib/fsa-to-node/FsaNodeCore.js +0 -191
  89. package/lib/fsa-to-node/FsaNodeCore.js.map +0 -1
  90. package/lib/fsa-to-node/FsaNodeDirent.d.ts +0 -19
  91. package/lib/fsa-to-node/FsaNodeDirent.js +0 -39
  92. package/lib/fsa-to-node/FsaNodeDirent.js.map +0 -1
  93. package/lib/fsa-to-node/FsaNodeFs.d.ts +0 -187
  94. package/lib/fsa-to-node/FsaNodeFs.js +0 -831
  95. package/lib/fsa-to-node/FsaNodeFs.js.map +0 -1
  96. package/lib/fsa-to-node/FsaNodeFsOpenFile.d.ts +0 -24
  97. package/lib/fsa-to-node/FsaNodeFsOpenFile.js +0 -37
  98. package/lib/fsa-to-node/FsaNodeFsOpenFile.js.map +0 -1
  99. package/lib/fsa-to-node/FsaNodeReadStream.d.ts +0 -23
  100. package/lib/fsa-to-node/FsaNodeReadStream.js +0 -92
  101. package/lib/fsa-to-node/FsaNodeReadStream.js.map +0 -1
  102. package/lib/fsa-to-node/FsaNodeStats.d.ts +0 -30
  103. package/lib/fsa-to-node/FsaNodeStats.js +0 -53
  104. package/lib/fsa-to-node/FsaNodeStats.js.map +0 -1
  105. package/lib/fsa-to-node/FsaNodeWriteStream.d.ts +0 -47
  106. package/lib/fsa-to-node/FsaNodeWriteStream.js +0 -150
  107. package/lib/fsa-to-node/FsaNodeWriteStream.js.map +0 -1
  108. package/lib/fsa-to-node/constants.d.ts +0 -3
  109. package/lib/fsa-to-node/constants.js +0 -3
  110. package/lib/fsa-to-node/constants.js.map +0 -1
  111. package/lib/fsa-to-node/json.d.ts +0 -2
  112. package/lib/fsa-to-node/json.js +0 -7
  113. package/lib/fsa-to-node/json.js.map +0 -1
  114. package/lib/fsa-to-node/types.d.ts +0 -37
  115. package/lib/fsa-to-node/types.js +0 -3
  116. package/lib/fsa-to-node/types.js.map +0 -1
  117. package/lib/fsa-to-node/util.d.ts +0 -4
  118. package/lib/fsa-to-node/util.js +0 -34
  119. package/lib/fsa-to-node/util.js.map +0 -1
  120. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.d.ts +0 -10
  121. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js +0 -62
  122. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js.map +0 -1
  123. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.d.ts +0 -20
  124. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js +0 -178
  125. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js.map +0 -1
  126. package/lib/fsa-to-node/worker/SyncMessenger.d.ts +0 -24
  127. package/lib/fsa-to-node/worker/SyncMessenger.js +0 -72
  128. package/lib/fsa-to-node/worker/SyncMessenger.js.map +0 -1
  129. package/lib/fsa-to-node/worker/constants.d.ts +0 -8
  130. package/lib/fsa-to-node/worker/constants.js +0 -3
  131. package/lib/fsa-to-node/worker/constants.js.map +0 -1
  132. package/lib/fsa-to-node/worker/types.d.ts +0 -17
  133. package/lib/fsa-to-node/worker/types.js +0 -3
  134. package/lib/fsa-to-node/worker/types.js.map +0 -1
  135. package/lib/node/Dir.d.ts +0 -26
  136. package/lib/node/Dir.js +0 -186
  137. package/lib/node/Dir.js.map +0 -1
  138. package/lib/node/Dirent.d.ts +0 -26
  139. package/lib/node/Dirent.js +0 -57
  140. package/lib/node/Dirent.js.map +0 -1
  141. package/lib/node/FileHandle.d.ts +0 -52
  142. package/lib/node/FileHandle.js +0 -189
  143. package/lib/node/FileHandle.js.map +0 -1
  144. package/lib/node/FsPromises.d.ts +0 -91
  145. package/lib/node/FsPromises.js +0 -161
  146. package/lib/node/FsPromises.js.map +0 -1
  147. package/lib/node/StatFs.d.ts +0 -19
  148. package/lib/node/StatFs.js +0 -34
  149. package/lib/node/StatFs.js.map +0 -1
  150. package/lib/node/Stats.d.ts +0 -41
  151. package/lib/node/Stats.js +0 -72
  152. package/lib/node/Stats.js.map +0 -1
  153. package/lib/node/constants.d.ts +0 -41
  154. package/lib/node/constants.js +0 -57
  155. package/lib/node/constants.js.map +0 -1
  156. package/lib/node/glob.d.ts +0 -5
  157. package/lib/node/glob.js +0 -94
  158. package/lib/node/glob.js.map +0 -1
  159. package/lib/node/lists/fsCallbackApiList.d.ts +0 -2
  160. package/lib/node/lists/fsCallbackApiList.js +0 -55
  161. package/lib/node/lists/fsCallbackApiList.js.map +0 -1
  162. package/lib/node/lists/fsCommonObjectsList.d.ts +0 -2
  163. package/lib/node/lists/fsCommonObjectsList.js +0 -19
  164. package/lib/node/lists/fsCommonObjectsList.js.map +0 -1
  165. package/lib/node/lists/fsSynchronousApiList.d.ts +0 -2
  166. package/lib/node/lists/fsSynchronousApiList.js +0 -49
  167. package/lib/node/lists/fsSynchronousApiList.js.map +0 -1
  168. package/lib/node/options.d.ts +0 -27
  169. package/lib/node/options.js +0 -112
  170. package/lib/node/options.js.map +0 -1
  171. package/lib/node/types/FsCallbackApi.d.ts +0 -143
  172. package/lib/node/types/FsCallbackApi.js +0 -3
  173. package/lib/node/types/FsCallbackApi.js.map +0 -1
  174. package/lib/node/types/FsCommonObjects.d.ts +0 -17
  175. package/lib/node/types/FsCommonObjects.js +0 -3
  176. package/lib/node/types/FsCommonObjects.js.map +0 -1
  177. package/lib/node/types/FsPromisesApi.d.ts +0 -41
  178. package/lib/node/types/FsPromisesApi.js +0 -3
  179. package/lib/node/types/FsPromisesApi.js.map +0 -1
  180. package/lib/node/types/FsSynchronousApi.d.ts +0 -114
  181. package/lib/node/types/FsSynchronousApi.js +0 -3
  182. package/lib/node/types/FsSynchronousApi.js.map +0 -1
  183. package/lib/node/types/index.d.ts +0 -7
  184. package/lib/node/types/index.js +0 -3
  185. package/lib/node/types/index.js.map +0 -1
  186. package/lib/node/types/misc.d.ts +0 -157
  187. package/lib/node/types/misc.js +0 -3
  188. package/lib/node/types/misc.js.map +0 -1
  189. package/lib/node/types/options.d.ts +0 -191
  190. package/lib/node/types/options.js +0 -3
  191. package/lib/node/types/options.js.map +0 -1
  192. package/lib/node/util.d.ts +0 -21
  193. package/lib/node/util.js +0 -297
  194. package/lib/node/util.js.map +0 -1
  195. package/lib/node/volume.d.ts +0 -395
  196. package/lib/node/volume.js +0 -1641
  197. package/lib/node/volume.js.map +0 -1
  198. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.d.ts +0 -72
  199. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js +0 -217
  200. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js.map +0 -1
  201. package/lib/node-to-fsa/NodeFileSystemFileHandle.d.ts +0 -28
  202. package/lib/node-to-fsa/NodeFileSystemFileHandle.js +0 -70
  203. package/lib/node-to-fsa/NodeFileSystemFileHandle.js.map +0 -1
  204. package/lib/node-to-fsa/NodeFileSystemHandle.d.ts +0 -37
  205. package/lib/node-to-fsa/NodeFileSystemHandle.js +0 -68
  206. package/lib/node-to-fsa/NodeFileSystemHandle.js.map +0 -1
  207. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.d.ts +0 -42
  208. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js +0 -97
  209. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js.map +0 -1
  210. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.d.ts +0 -56
  211. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js +0 -191
  212. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js.map +0 -1
  213. package/lib/node-to-fsa/NodePermissionStatus.d.ts +0 -8
  214. package/lib/node-to-fsa/NodePermissionStatus.js +0 -14
  215. package/lib/node-to-fsa/NodePermissionStatus.js.map +0 -1
  216. package/lib/node-to-fsa/types.d.ts +0 -18
  217. package/lib/node-to-fsa/types.js +0 -3
  218. package/lib/node-to-fsa/types.js.map +0 -1
  219. package/lib/node-to-fsa/util.d.ts +0 -12
  220. package/lib/node-to-fsa/util.js +0 -45
  221. package/lib/node-to-fsa/util.js.map +0 -1
  222. package/lib/node.d.ts +0 -3
  223. package/lib/node.js +0 -10
  224. package/lib/node.js.map +0 -1
  225. package/lib/print/index.d.ts +0 -9
  226. package/lib/print/index.js +0 -49
  227. package/lib/print/index.js.map +0 -1
  228. package/lib/process.d.ts +0 -11
  229. package/lib/process.js +0 -40
  230. package/lib/process.js.map +0 -1
  231. package/lib/queueMicrotask.d.ts +0 -2
  232. package/lib/queueMicrotask.js +0 -6
  233. package/lib/queueMicrotask.js.map +0 -1
  234. package/lib/snapshot/async.d.ts +0 -3
  235. package/lib/snapshot/async.js +0 -59
  236. package/lib/snapshot/async.js.map +0 -1
  237. package/lib/snapshot/binary.d.ts +0 -6
  238. package/lib/snapshot/binary.js +0 -31
  239. package/lib/snapshot/binary.js.map +0 -1
  240. package/lib/snapshot/constants.d.ts +0 -5
  241. package/lib/snapshot/constants.js +0 -3
  242. package/lib/snapshot/constants.js.map +0 -1
  243. package/lib/snapshot/index.d.ts +0 -5
  244. package/lib/snapshot/index.js +0 -8
  245. package/lib/snapshot/index.js.map +0 -1
  246. package/lib/snapshot/json.d.ts +0 -10
  247. package/lib/snapshot/json.js +0 -31
  248. package/lib/snapshot/json.js.map +0 -1
  249. package/lib/snapshot/shared.d.ts +0 -2
  250. package/lib/snapshot/shared.js +0 -6
  251. package/lib/snapshot/shared.js.map +0 -1
  252. package/lib/snapshot/sync.d.ts +0 -3
  253. package/lib/snapshot/sync.js +0 -59
  254. package/lib/snapshot/sync.js.map +0 -1
  255. package/lib/snapshot/types.d.ts +0 -30
  256. package/lib/snapshot/types.js +0 -3
  257. package/lib/snapshot/types.js.map +0 -1
  258. package/lib/vendor/node/buffer.d.ts +0 -1
  259. package/lib/vendor/node/buffer.js +0 -6
  260. package/lib/vendor/node/buffer.js.map +0 -1
  261. package/lib/vendor/node/events.d.ts +0 -1
  262. package/lib/vendor/node/events.js +0 -6
  263. package/lib/vendor/node/events.js.map +0 -1
  264. package/lib/vendor/node/fs.d.ts +0 -6
  265. package/lib/vendor/node/fs.js +0 -4
  266. package/lib/vendor/node/fs.js.map +0 -1
  267. package/lib/vendor/node/internal/buffer.d.ts +0 -9
  268. package/lib/vendor/node/internal/buffer.js +0 -13
  269. package/lib/vendor/node/internal/buffer.js.map +0 -1
  270. package/lib/vendor/node/internal/errors.d.ts +0 -31
  271. package/lib/vendor/node/internal/errors.js +0 -77
  272. package/lib/vendor/node/internal/errors.js.map +0 -1
  273. package/lib/vendor/node/path.d.ts +0 -1
  274. package/lib/vendor/node/path.js +0 -14
  275. package/lib/vendor/node/path.js.map +0 -1
  276. package/lib/vendor/node/stream.d.ts +0 -1
  277. package/lib/vendor/node/stream.js +0 -7
  278. package/lib/vendor/node/stream.js.map +0 -1
  279. package/lib/vendor/node/url.d.ts +0 -1
  280. package/lib/vendor/node/url.js +0 -6
  281. package/lib/vendor/node/url.js.map +0 -1
  282. package/lib/vendor/node/util.d.ts +0 -20
  283. package/lib/vendor/node/util.js +0 -112
  284. package/lib/vendor/node/util.js.map +0 -1
  285. package/src/node-to-fsa/README.md +0 -5
@@ -1,265 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoreFileSystemDirectoryHandle = void 0;
4
- const CoreFileSystemHandle_1 = require("./CoreFileSystemHandle");
5
- const util_1 = require("./util");
6
- const CoreFileSystemFileHandle_1 = require("./CoreFileSystemFileHandle");
7
- const buffer_1 = require("../vendor/node/internal/buffer");
8
- const constants_1 = require("../node/constants");
9
- /**
10
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle
11
- */
12
- class CoreFileSystemDirectoryHandle extends CoreFileSystemHandle_1.CoreFileSystemHandle {
13
- constructor(_core, path, ctx = {}) {
14
- const fullCtx = (0, util_1.ctx)(ctx);
15
- super('directory', (0, util_1.basename)(path, fullCtx.separator), fullCtx);
16
- this._core = _core;
17
- this.ctx = fullCtx;
18
- this.__path = path[path.length - 1] === this.ctx.separator ? path : path + this.ctx.separator;
19
- }
20
- /**
21
- * Returns a new array iterator containing the keys for each item in
22
- * {@link CoreFileSystemDirectoryHandle} object.
23
- *
24
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/keys
25
- */
26
- async *keys() {
27
- try {
28
- const link = this._core.getResolvedLinkOrThrow(this.__path);
29
- const children = link.children;
30
- for (const [name] of children) {
31
- if (name !== '.' && name !== '..') {
32
- yield name;
33
- }
34
- }
35
- }
36
- catch (error) {
37
- this._handleError(error, 'keys');
38
- }
39
- }
40
- /**
41
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries
42
- */
43
- async *entries() {
44
- const { __path: path, _core, ctx } = this;
45
- try {
46
- const link = _core.getResolvedLinkOrThrow(path);
47
- const children = link.children;
48
- for (const [name, childLink] of children) {
49
- if (name !== '.' && name !== '..' && childLink) {
50
- const childPath = path + name;
51
- const node = childLink.getNode();
52
- if (node.isDirectory()) {
53
- yield [name, new CoreFileSystemDirectoryHandle(_core, childPath, ctx)];
54
- }
55
- else if (node.isFile()) {
56
- yield [name, new CoreFileSystemFileHandle_1.CoreFileSystemFileHandle(_core, childPath, ctx)];
57
- }
58
- }
59
- }
60
- }
61
- catch (error) {
62
- this._handleError(error, 'entries');
63
- }
64
- }
65
- /**
66
- * Returns a new array iterator containing the values for each index in the
67
- * {@link FileSystemDirectoryHandle} object.
68
- *
69
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/values
70
- */
71
- async *values() {
72
- for await (const [, value] of this.entries())
73
- yield value;
74
- }
75
- /**
76
- * Returns a {@link CoreFileSystemDirectoryHandle} for a subdirectory with the specified
77
- * name within the directory handle on which the method is called.
78
- *
79
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle
80
- * @param name A string representing the {@link CoreFileSystemHandle} name of
81
- * the subdirectory you wish to retrieve.
82
- * @param options An optional object containing options for the retrieved
83
- * subdirectory.
84
- */
85
- async getDirectoryHandle(name, options) {
86
- (0, util_1.assertName)(name, 'getDirectoryHandle', 'FileSystemDirectoryHandle');
87
- const filename = this.__path + name;
88
- try {
89
- const link = this._core.getResolvedLink(filename);
90
- if (link) {
91
- const node = link.getNode();
92
- if (!node.isDirectory())
93
- throw (0, util_1.newTypeMismatchError)();
94
- return new CoreFileSystemDirectoryHandle(this._core, filename, this.ctx);
95
- }
96
- else {
97
- throw new Error('ENOENT'); // Simulate error for consistency with catch block
98
- }
99
- }
100
- catch (error) {
101
- if (error instanceof DOMException)
102
- throw error;
103
- if (error && typeof error === 'object') {
104
- if (error.code === "ENOENT" /* ERROR_CODE.ENOENT */ || error.message === 'ENOENT') {
105
- if (options?.create) {
106
- (0, util_1.assertCanWrite)(this.ctx.mode);
107
- try {
108
- this._core.mkdir(filename, 0o755);
109
- return new CoreFileSystemDirectoryHandle(this._core, filename, this.ctx);
110
- }
111
- catch (createError) {
112
- if (createError && typeof createError === 'object' && createError.code === "EACCES" /* ERROR_CODE.EACCES */) {
113
- throw (0, util_1.newNotAllowedError)();
114
- }
115
- throw createError;
116
- }
117
- }
118
- throw (0, util_1.newNotFoundError)();
119
- }
120
- if (error.code === "EACCES" /* ERROR_CODE.EACCES */) {
121
- throw (0, util_1.newNotAllowedError)();
122
- }
123
- }
124
- throw error;
125
- }
126
- }
127
- /**
128
- * Returns a {@link CoreFileSystemFileHandle} for a file with the specified name,
129
- * within the directory the method is called.
130
- *
131
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getFileHandle
132
- * @param name A string representing the {@link CoreFileSystemHandle} name of
133
- * the file you wish to retrieve.
134
- * @param options An optional object containing options for the retrieved file.
135
- */
136
- async getFileHandle(name, options) {
137
- (0, util_1.assertName)(name, 'getFileHandle', 'FileSystemDirectoryHandle');
138
- const filename = this.__path + name;
139
- try {
140
- const link = this._core.getResolvedLink(filename);
141
- if (link) {
142
- const node = link.getNode();
143
- if (!node.isFile())
144
- throw (0, util_1.newTypeMismatchError)();
145
- return new CoreFileSystemFileHandle_1.CoreFileSystemFileHandle(this._core, filename, this.ctx);
146
- }
147
- else {
148
- throw new Error('ENOENT'); // Simulate error for consistency with catch block
149
- }
150
- }
151
- catch (error) {
152
- if (error instanceof DOMException)
153
- throw error;
154
- if (error && typeof error === 'object') {
155
- if (error.code === "ENOENT" /* ERROR_CODE.ENOENT */ || error.message === 'ENOENT') {
156
- if (options?.create) {
157
- (0, util_1.assertCanWrite)(this.ctx.mode);
158
- try {
159
- this._core.writeFile(filename, buffer_1.Buffer.alloc(0), constants_1.FLAGS.w, 438 /* MODE.FILE */);
160
- return new CoreFileSystemFileHandle_1.CoreFileSystemFileHandle(this._core, filename, this.ctx);
161
- }
162
- catch (createError) {
163
- if (createError && typeof createError === 'object' && createError.code === "EACCES" /* ERROR_CODE.EACCES */) {
164
- throw (0, util_1.newNotAllowedError)();
165
- }
166
- throw createError;
167
- }
168
- }
169
- throw (0, util_1.newNotFoundError)();
170
- }
171
- if (error.code === "EACCES" /* ERROR_CODE.EACCES */) {
172
- throw (0, util_1.newNotAllowedError)();
173
- }
174
- }
175
- throw error;
176
- }
177
- }
178
- /**
179
- * Attempts to remove an entry if the directory handle contains a file or
180
- * directory called the name specified.
181
- *
182
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/removeEntry
183
- * @param name A string representing the {@link CoreFileSystemHandle} name of the
184
- * entry you wish to remove.
185
- * @param options An optional object containing options.
186
- */
187
- async removeEntry(name, { recursive = false } = {}) {
188
- (0, util_1.assertCanWrite)(this.ctx.mode);
189
- (0, util_1.assertName)(name, 'removeEntry', 'FileSystemDirectoryHandle');
190
- const filename = this.__path + name;
191
- try {
192
- const link = this._core.getResolvedLinkOrThrow(filename);
193
- const node = link.getNode();
194
- if (node.isFile()) {
195
- this._core.unlink(filename);
196
- }
197
- else if (node.isDirectory()) {
198
- this._core.rmdir(filename, recursive);
199
- }
200
- else {
201
- throw (0, util_1.newTypeMismatchError)();
202
- }
203
- }
204
- catch (error) {
205
- if (error instanceof DOMException)
206
- throw error;
207
- if (error && typeof error === 'object') {
208
- switch (error.code) {
209
- case "ENOENT" /* ERROR_CODE.ENOENT */: {
210
- throw (0, util_1.newNotFoundError)();
211
- }
212
- case "EACCES" /* ERROR_CODE.EACCES */:
213
- throw (0, util_1.newNotAllowedError)();
214
- case "ENOTEMPTY" /* ERROR_CODE.ENOTEMPTY */:
215
- throw new DOMException('The object can not be modified in this way.', 'InvalidModificationError');
216
- }
217
- }
218
- throw error;
219
- }
220
- }
221
- /**
222
- * The `resolve()` method of the {@link FileSystemDirectoryHandle} interface
223
- * returns an {@link Array} of directory names from the parent handle to the specified
224
- * child entry, with the name of the child entry as the last array item.
225
- *
226
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/resolve
227
- * @param possibleDescendant The {@link CoreFileSystemHandle} from which
228
- * to return the relative path.
229
- */
230
- async resolve(possibleDescendant) {
231
- if (possibleDescendant instanceof CoreFileSystemDirectoryHandle ||
232
- possibleDescendant instanceof CoreFileSystemFileHandle_1.CoreFileSystemFileHandle) {
233
- // First check if they are from the same core instance
234
- if (possibleDescendant._core !== this._core)
235
- return null;
236
- const path = this.__path;
237
- const childPath = possibleDescendant.__path;
238
- if (!childPath.startsWith(path))
239
- return null;
240
- let relative = childPath.slice(path.length);
241
- if (relative === '')
242
- return [];
243
- const separator = this.ctx.separator;
244
- if (relative[0] === separator)
245
- relative = relative.slice(1);
246
- return relative.split(separator);
247
- }
248
- return null;
249
- }
250
- _handleError(error, method) {
251
- if (error instanceof DOMException)
252
- throw error;
253
- if (error && typeof error === 'object') {
254
- switch (error.code) {
255
- case "ENOENT" /* ERROR_CODE.ENOENT */:
256
- throw (0, util_1.newNotFoundError)();
257
- case "EACCES" /* ERROR_CODE.EACCES */:
258
- throw (0, util_1.newNotAllowedError)();
259
- }
260
- }
261
- throw error;
262
- }
263
- }
264
- exports.CoreFileSystemDirectoryHandle = CoreFileSystemDirectoryHandle;
265
- //# sourceMappingURL=CoreFileSystemDirectoryHandle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CoreFileSystemDirectoryHandle.js","sourceRoot":"","sources":["../../src/fsa/CoreFileSystemDirectoryHandle.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAC9D,iCAQgB;AAChB,yEAAsE;AAatE,2DAAwD;AACxD,iDAAgD;AAEhD;;GAEG;AACH,MAAa,6BAA8B,SAAQ,2CAAoB;IAKrE,YACqB,KAAiB,EACpC,IAAY,EACZ,MAA+B,EAAE;QAEjC,MAAM,OAAO,GAAG,IAAA,UAAS,EAAC,GAAG,CAAC,CAAC;QAC/B,KAAK,CAAC,WAAW,EAAE,IAAA,eAAQ,EAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;QAL5C,UAAK,GAAL,KAAK,CAAY;QAMpC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;IAChG,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,CAAC,IAAI;QAChB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC/B,KAA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emWritableFileStream } from './CoreFileSystemWritableFileStream';
3
- import type { CoreFsaContext, CreateWritableOptions, IFileSystemFileHandle, IFileSystemSyncAccessHandle } from './types';
4
- import type { Superblock } from '../core/Superblock';
5
- export declare class CoreFileSystemFileHandle extends CoreFileSystemHandle implements IFileSystemFileHandle {
6
- protected readonly _core: Superblock;
7
- readonly __path: string;
8
- protected readonly ctx: CoreFsaContext;
9
- constructor(_core: Superblock, __path: string, ctx?: Partial<CoreFsaContext>);
10
- /**
11
- * Returns a {@link Promise} which resolves to a {@link File} object
12
- * representing the state on disk of the entry represented by the handle.
13
- *
14
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/getFile
15
- */
16
- getFile(): Promise<File>;
17
- /**
18
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle
19
- */
20
- get createSyncAccessHandle(): undefined | (() => Promise<IFileSystemSyncAccessHandle>);
21
- /**
22
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable
23
- */
24
- createWritable({ keepExistingData }?: CreateWritableOptions): Promise<CoreFileSystemWritableFileStream>;
25
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoreFileSystemFileHandle = void 0;
4
- const CoreFileSystemHandle_1 = require("./CoreFileSystemHandle");
5
- const CoreFileSystemSyncAccessHandle_1 = require("./CoreFileSystemSyncAccessHandle");
6
- const util_1 = require("./util");
7
- const CoreFileSystemWritableFileStream_1 = require("./CoreFileSystemWritableFileStream");
8
- class CoreFileSystemFileHandle extends CoreFileSystemHandle_1.CoreFileSystemHandle {
9
- constructor(_core, __path, ctx = {}) {
10
- const fullCtx = (0, util_1.ctx)(ctx);
11
- super('file', (0, util_1.basename)(__path, fullCtx.separator), fullCtx);
12
- this._core = _core;
13
- this.__path = __path;
14
- this.ctx = fullCtx;
15
- }
16
- /**
17
- * Returns a {@link Promise} which resolves to a {@link File} object
18
- * representing the state on disk of the entry represented by the handle.
19
- *
20
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/getFile
21
- */
22
- async getFile() {
23
- try {
24
- const path = this.__path;
25
- const link = this._core.getResolvedLinkOrThrow(path);
26
- const node = link.getNode();
27
- if (!node.isFile()) {
28
- throw new Error('Not a file');
29
- }
30
- // Get file stats for lastModified
31
- const lastModified = node.mtime ? node.mtime.getTime() : Date.now();
32
- // Read file content
33
- const buffer = node.getBuffer();
34
- const data = new Uint8Array(buffer);
35
- const file = new File([data], this.name, { lastModified });
36
- return file;
37
- }
38
- catch (error) {
39
- if (error instanceof DOMException)
40
- throw error;
41
- if (error && typeof error === 'object') {
42
- switch (error.code) {
43
- case "EACCES" /* ERROR_CODE.EACCES */:
44
- throw (0, util_1.newNotAllowedError)();
45
- }
46
- }
47
- throw error;
48
- }
49
- }
50
- /**
51
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle
52
- */
53
- get createSyncAccessHandle() {
54
- if (!this.ctx.syncHandleAllowed)
55
- return undefined;
56
- return async () => {
57
- if (this.ctx.locks.isLocked(this.__path)) {
58
- throw (0, util_1.newNoModificationAllowedError)();
59
- }
60
- return new CoreFileSystemSyncAccessHandle_1.CoreFileSystemSyncAccessHandle(this._core, this.__path, this.ctx);
61
- };
62
- }
63
- /**
64
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable
65
- */
66
- async createWritable({ keepExistingData = false } = { keepExistingData: false }) {
67
- (0, util_1.assertCanWrite)(this.ctx.mode);
68
- if (this.ctx.locks.isLocked(this.__path)) {
69
- throw (0, util_1.newNoModificationAllowedError)();
70
- }
71
- return new CoreFileSystemWritableFileStream_1.CoreFileSystemWritableFileStream(this._core, this.__path, keepExistingData, this.ctx);
72
- }
73
- }
74
- exports.CoreFileSystemFileHandle = CoreFileSystemFileHandle;
75
- //# sourceMappingURL=CoreFileSystemFileHandle.js.map
@@ -1 +0,0 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,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACnG,CAAC;CACF;AA3ED,4DA2EC"}
@@ -1,34 +0,0 @@
1
- import { CorePermissionStatus } from './CorePermissionStatus';
2
- import type { IFileSystemHandle, FileSystemHandlePermissionDescriptor, CoreFsaContext } from './types';
3
- /**
4
- * Represents a File System Access API file handle `FileSystemHandle` object,
5
- * which was created from a core `Superblock`.
6
- *
7
- * @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle)
8
- */
9
- export declare abstract class CoreFileSystemHandle implements IFileSystemHandle {
10
- readonly kind: 'file' | 'directory';
11
- readonly name: string;
12
- protected readonly ctx: CoreFsaContext;
13
- constructor(kind: 'file' | 'directory', name: string, ctx: CoreFsaContext);
14
- /**
15
- * Compares two handles to see if the associated entries (either a file or directory) match.
16
- *
17
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/isSameEntry
18
- */
19
- isSameEntry(fileSystemHandle: CoreFileSystemHandle): boolean;
20
- /**
21
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/queryPermission
22
- */
23
- queryPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): Promise<CorePermissionStatus>;
24
- /**
25
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/remove
26
- */
27
- remove({ recursive }?: {
28
- recursive?: boolean;
29
- }): Promise<void>;
30
- /**
31
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/requestPermission
32
- */
33
- requestPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): CorePermissionStatus;
34
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoreFileSystemHandle = void 0;
4
- const CorePermissionStatus_1 = require("./CorePermissionStatus");
5
- /**
6
- * Represents a File System Access API file handle `FileSystemHandle` object,
7
- * which was created from a core `Superblock`.
8
- *
9
- * @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle)
10
- */
11
- class CoreFileSystemHandle {
12
- constructor(kind, name, ctx) {
13
- this.kind = kind;
14
- this.name = name;
15
- this.ctx = ctx;
16
- }
17
- /**
18
- * Compares two handles to see if the associated entries (either a file or directory) match.
19
- *
20
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/isSameEntry
21
- */
22
- isSameEntry(fileSystemHandle) {
23
- return (this.constructor === fileSystemHandle.constructor && this.__path === fileSystemHandle.__path);
24
- }
25
- /**
26
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/queryPermission
27
- */
28
- async queryPermission(fileSystemHandlePermissionDescriptor) {
29
- // Check if the requested mode is compatible with the context mode
30
- const requestedMode = fileSystemHandlePermissionDescriptor.mode;
31
- const contextMode = this.ctx.mode;
32
- // If requesting readwrite but context only allows read, deny
33
- if (requestedMode === 'readwrite' && contextMode === 'read') {
34
- return new CorePermissionStatus_1.CorePermissionStatus('denied', requestedMode);
35
- }
36
- // Otherwise grant the permission
37
- return new CorePermissionStatus_1.CorePermissionStatus('granted', requestedMode);
38
- }
39
- /**
40
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/remove
41
- */
42
- async remove({ recursive } = { recursive: false }) {
43
- throw new Error('Not implemented');
44
- }
45
- /**
46
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/requestPermission
47
- */
48
- requestPermission(fileSystemHandlePermissionDescriptor) {
49
- throw new Error('Not implemented');
50
- }
51
- }
52
- exports.CoreFileSystemHandle = CoreFileSystemHandle;
53
- //# sourceMappingURL=CoreFileSystemHandle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CoreFileSystemHandle.js","sourceRoot":"","sources":["../../src/fsa/CoreFileSystemHandle.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAG9D;;;;;GAKG;AACH,MAAsB,oBAAoB;IAGxC,YACkB,IAA0B,EAC1B,IAAY,EAC5B,GAAmB;QAFH,SAAI,GAAJ,IAAI,CAAsB;QAC1B,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,gBAAsC;QACvD,OAAO,CACL,IAAI,CAAC,WAAW,KAAK,gBAAgB,CAAC,WAAW,IAAK,IAAY,CAAC,MAAM,KAAM,gBAAwB,CAAC,MAAM,CAC/G,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,eAAe,CAC1B,oCAA0E;QAE1E,kEAAkE;QAClE,MAAM,aAAa,GAAG,oCAAoC,CAAC,IAAI,CAAC;QAChE,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QAElC,6DAA6D;QAC7D,IAAI,aAAa,KAAK,WAAW,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;YAC5D,OAAO,IAAI,2CAAoB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QAC3D,CAAC;QAED,iCAAiC;QACjC,OAAO,IAAI,2CAAoB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,KAA8B,EAAE,SAAS,EAAE,KAAK,EAAE;QAC/E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,iBAAiB,CACtB,oCAA0E;QAE1E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF;AAxDD,oDAwDC"}
@@ -1,10 +0,0 @@
1
- import type { IFileSystemChangeRecord, IFileSystemDirectoryHandle, IFileSystemFileHandle, IFileSystemObserver, IFileSystemObserverObserveOptions, IFileSystemSyncAccessHandle } from './types';
2
- import type { Superblock } from '../core';
3
- export declare class CoreFileSystemObserver implements IFileSystemObserver {
4
- protected readonly _core: Superblock;
5
- protected readonly callback: (records: IFileSystemChangeRecord[], observer: IFileSystemObserver) => void;
6
- constructor(_core: Superblock, callback: (records: IFileSystemChangeRecord[], observer: IFileSystemObserver) => void);
7
- observe(handle: IFileSystemFileHandle | IFileSystemDirectoryHandle | IFileSystemSyncAccessHandle, options?: IFileSystemObserverObserveOptions): Promise<void>;
8
- /** Disconnect and stop all observations. */
9
- disconnect(): void;
10
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoreFileSystemObserver = void 0;
4
- class CoreFileSystemObserver {
5
- constructor(_core, callback) {
6
- this._core = _core;
7
- this.callback = callback;
8
- }
9
- async observe(handle, options) {
10
- throw new Error('Method not implemented.');
11
- }
12
- /** Disconnect and stop all observations. */
13
- disconnect() {
14
- throw new Error('Method not implemented.');
15
- }
16
- }
17
- exports.CoreFileSystemObserver = CoreFileSystemObserver;
18
- //# sourceMappingURL=CoreFileSystemObserver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CoreFileSystemObserver.js","sourceRoot":"","sources":["../../src/fsa/CoreFileSystemObserver.ts"],"names":[],"mappings":";;;AAUA,MAAa,sBAAsB;IACjC,YACqB,KAAiB,EACjB,QAAqF;QADrF,UAAK,GAAL,KAAK,CAAY;QACjB,aAAQ,GAAR,QAAQ,CAA6E;IACvG,CAAC;IAEG,KAAK,CAAC,OAAO,CAClB,MAAwF,EACxF,OAA2C;QAE3C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,4CAA4C;IACrC,UAAU;QACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF;AAjBD,wDAiBC"}
@@ -1,38 +0,0 @@
1
- import type { IFileSystemSyncAccessHandle, FileSystemReadWriteOptions, CoreFsaContext } from './types';
2
- import type { Superblock } from '../core/Superblock';
3
- /**
4
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle
5
- */
6
- export declare class CoreFileSystemSyncAccessHandle implements IFileSystemSyncAccessHandle {
7
- private readonly _core;
8
- private readonly _path;
9
- private readonly _ctx;
10
- private _fd;
11
- private _closed;
12
- constructor(_core: Superblock, _path: string, _ctx: CoreFsaContext);
13
- private _ensureOpen;
14
- /**
15
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/close
16
- */
17
- close(): Promise<void>;
18
- /**
19
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/flush
20
- */
21
- flush(): Promise<void>;
22
- /**
23
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/getSize
24
- */
25
- getSize(): Promise<number>;
26
- /**
27
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/read
28
- */
29
- read(buffer: ArrayBuffer | ArrayBufferView, options?: FileSystemReadWriteOptions): Promise<number>;
30
- /**
31
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/truncate
32
- */
33
- truncate(newSize: number): Promise<void>;
34
- /**
35
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write
36
- */
37
- write(buffer: ArrayBuffer | ArrayBufferView | DataView, options?: FileSystemReadWriteOptions): Promise<number>;
38
- }