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,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoreFileSystemSyncAccessHandle = void 0;
4
- const buffer_1 = require("../vendor/node/internal/buffer");
5
- const util_1 = require("./util");
6
- const constants_1 = require("../node/constants");
7
- /**
8
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle
9
- */
10
- class CoreFileSystemSyncAccessHandle {
11
- constructor(_core, _path, _ctx) {
12
- this._core = _core;
13
- this._path = _path;
14
- this._ctx = _ctx;
15
- this._fd = null;
16
- this._closed = false;
17
- this._ctx.locks.acquireLock(this._path);
18
- }
19
- _ensureOpen() {
20
- if (this._closed) {
21
- throw new DOMException('The file handle is closed.', 'InvalidStateError');
22
- }
23
- if (this._fd === null) {
24
- // Open file for read/write
25
- const flags = this._ctx.mode === 'readwrite' ? constants_1.FLAGS['r+'] : constants_1.FLAGS.r;
26
- this._fd = this._core.open(this._path, flags, 0o644);
27
- }
28
- return this._fd;
29
- }
30
- /**
31
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/close
32
- */
33
- async close() {
34
- if (this._fd !== null) {
35
- this._core.close(this._fd);
36
- this._fd = null;
37
- }
38
- this._closed = true;
39
- this._ctx.locks.releaseLock(this._path);
40
- }
41
- /**
42
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/flush
43
- */
44
- async flush() {
45
- const fd = this._ensureOpen();
46
- // Core doesn't have an explicit flush method, but we can try to sync if available
47
- // For now, this is a no-op as the core writes are synchronous
48
- }
49
- /**
50
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/getSize
51
- */
52
- async getSize() {
53
- try {
54
- const link = this._core.getResolvedLinkOrThrow(this._path);
55
- const node = link.getNode();
56
- return node.getSize();
57
- }
58
- catch (error) {
59
- if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
60
- throw (0, util_1.newNotAllowedError)();
61
- }
62
- throw error;
63
- }
64
- }
65
- /**
66
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/read
67
- */
68
- async read(buffer, options = {}) {
69
- const fd = this._ensureOpen();
70
- const { at: position = 0 } = options;
71
- const buf = buffer_1.Buffer.from(buffer);
72
- try {
73
- return this._core.read(fd, buf, 0, buf.length, position);
74
- }
75
- catch (error) {
76
- if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
77
- throw (0, util_1.newNotAllowedError)();
78
- }
79
- throw error;
80
- }
81
- }
82
- /**
83
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/truncate
84
- */
85
- async truncate(newSize) {
86
- if (this._ctx.mode !== 'readwrite') {
87
- throw (0, util_1.newNotAllowedError)();
88
- }
89
- try {
90
- const link = this._core.getResolvedLinkOrThrow(this._path);
91
- const node = link.getNode();
92
- node.truncate(newSize);
93
- }
94
- catch (error) {
95
- if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
96
- throw (0, util_1.newNotAllowedError)();
97
- }
98
- throw error;
99
- }
100
- }
101
- /**
102
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write
103
- */
104
- async write(buffer, options = {}) {
105
- if (this._ctx.mode !== 'readwrite') {
106
- throw (0, util_1.newNotAllowedError)();
107
- }
108
- const fd = this._ensureOpen();
109
- const { at: position = 0 } = options;
110
- const buf = buffer_1.Buffer.from(buffer);
111
- try {
112
- return this._core.write(fd, buf, 0, buf.length, position);
113
- }
114
- catch (error) {
115
- if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
116
- throw (0, util_1.newNotAllowedError)();
117
- }
118
- throw error;
119
- }
120
- }
121
- }
122
- exports.CoreFileSystemSyncAccessHandle = CoreFileSystemSyncAccessHandle;
123
- //# sourceMappingURL=CoreFileSystemSyncAccessHandle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CoreFileSystemSyncAccessHandle.js","sourceRoot":"","sources":["../../src/fsa/CoreFileSystemSyncAccessHandle.ts"],"names":[],"mappings":";;;AAEA,2DAAwD;AAExD,iCAA4C;AAC5C,iDAA0C;AAE1C;;GAEG;AACH,MAAa,8BAA8B;IAIzC,YACmB,KAAiB,EACjB,KAAa,EACb,IAAoB;QAFpB,UAAK,GAAL,KAAK,CAAY;QACjB,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAgB;QAN/B,QAAG,GAAkB,IAAI,CAAC;QAC1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WritableFileStream, FileSystemWritableFileStreamParams, Data, CoreFsaContext } from './types';
2
- import type { Superblock } from '../core/Superblock';
3
- declare const WS: typeof WritableStream;
4
- /**
5
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream
6
- */
7
- export declare class CoreFileSystemWritableFileStream extends WS implements IFileSystemWritableFileStream {
8
- private _fd;
9
- private _position;
10
- private _closed;
11
- private readonly _core;
12
- private readonly _path;
13
- private readonly _ctx;
14
- constructor(core: Superblock, path: string, keepExistingData: boolean | undefined, ctx: CoreFsaContext);
15
- /**
16
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/seek
17
- */
18
- seek(position: number): Promise<void>;
19
- /**
20
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/truncate
21
- */
22
- truncate(size: number): Promise<void>;
23
- /**
24
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/write
25
- */
26
- write(chunk: Data): Promise<void>;
27
- write(params: FileSystemWritableFileStreamParams): Promise<void>;
28
- private _write;
29
- private _isParams;
30
- private _dataToBuffer;
31
- }
32
- export {};
@@ -1,163 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoreFileSystemWritableFileStream = void 0;
4
- const buffer_1 = require("../vendor/node/internal/buffer");
5
- const util_1 = require("./util");
6
- const constants_1 = require("../node/constants");
7
- const WS = (typeof WritableStream === 'undefined' ? require('stream/web').WritableStream : WritableStream);
8
- /**
9
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream
10
- */
11
- class CoreFileSystemWritableFileStream extends WS {
12
- constructor(core, path, keepExistingData = false, ctx) {
13
- let fd;
14
- super({
15
- start: controller => {
16
- if (ctx.locks.isLocked(path)) {
17
- throw (0, util_1.newNoModificationAllowedError)();
18
- }
19
- ctx.locks.acquireLock(path);
20
- const flags = keepExistingData ? constants_1.FLAGS['r+'] : constants_1.FLAGS.w;
21
- try {
22
- fd = core.open(path, flags, 438 /* MODE.FILE */);
23
- }
24
- catch (error) {
25
- ctx.locks.releaseLock(path);
26
- if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
27
- throw (0, util_1.newNotAllowedError)();
28
- }
29
- throw error;
30
- }
31
- },
32
- write: async (chunk) => {
33
- await this._write(chunk);
34
- },
35
- close: async () => {
36
- if (!this._closed && this._fd !== undefined) {
37
- core.close(this._fd);
38
- this._closed = true;
39
- ctx.locks.releaseLock(path);
40
- }
41
- },
42
- abort: async () => {
43
- if (!this._closed && this._fd !== undefined) {
44
- core.close(this._fd);
45
- this._closed = true;
46
- ctx.locks.releaseLock(path);
47
- }
48
- },
49
- });
50
- this._position = 0;
51
- this._closed = false;
52
- this._core = core;
53
- this._path = path;
54
- this._fd = fd;
55
- this._ctx = ctx;
56
- }
57
- /**
58
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/seek
59
- */
60
- async seek(position) {
61
- if (this._closed) {
62
- throw new DOMException('The stream is closed.', 'InvalidStateError');
63
- }
64
- this._position = position;
65
- }
66
- /**
67
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/truncate
68
- */
69
- async truncate(size) {
70
- if (this._closed) {
71
- throw new DOMException('The stream is closed.', 'InvalidStateError');
72
- }
73
- try {
74
- const link = this._core.getResolvedLinkOrThrow(this._path);
75
- const node = link.getNode();
76
- node.truncate(size);
77
- }
78
- catch (error) {
79
- if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
80
- throw (0, util_1.newNotAllowedError)();
81
- }
82
- throw error;
83
- }
84
- }
85
- async write(chunkOrParams) {
86
- await this._write(chunkOrParams);
87
- }
88
- async _write(chunkOrParams) {
89
- if (this._closed) {
90
- throw new DOMException('The stream is closed.', 'InvalidStateError');
91
- }
92
- if (this._fd === undefined) {
93
- throw new DOMException('The stream is not ready.', 'InvalidStateError');
94
- }
95
- try {
96
- if (this._isParams(chunkOrParams)) {
97
- const params = chunkOrParams;
98
- switch (params.type) {
99
- case 'write': {
100
- if (params.data !== undefined) {
101
- const buffer = this._dataToBuffer(params.data);
102
- const position = params.position !== undefined ? params.position : this._position;
103
- const written = this._core.write(this._fd, buffer, 0, buffer.length, position);
104
- if (params.position === undefined) {
105
- this._position += written;
106
- }
107
- }
108
- break;
109
- }
110
- case 'seek': {
111
- if (params.position !== undefined) {
112
- this._position = params.position;
113
- }
114
- break;
115
- }
116
- case 'truncate': {
117
- if (params.size !== undefined) {
118
- await this.truncate(params.size);
119
- }
120
- break;
121
- }
122
- }
123
- }
124
- else {
125
- // Direct data write
126
- const buffer = this._dataToBuffer(chunkOrParams);
127
- const written = this._core.write(this._fd, buffer, 0, buffer.length, this._position);
128
- this._position += written;
129
- }
130
- }
131
- catch (error) {
132
- if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
133
- throw (0, util_1.newNotAllowedError)();
134
- }
135
- throw error;
136
- }
137
- }
138
- _isParams(chunk) {
139
- return !!(chunk && typeof chunk === 'object' && 'type' in chunk);
140
- }
141
- _dataToBuffer(data) {
142
- if (typeof data === 'string') {
143
- return buffer_1.Buffer.from(data, 'utf8');
144
- }
145
- if (data instanceof buffer_1.Buffer) {
146
- return data;
147
- }
148
- if (data instanceof ArrayBuffer) {
149
- return buffer_1.Buffer.from(data);
150
- }
151
- if (ArrayBuffer.isView(data)) {
152
- return buffer_1.Buffer.from(data.buffer, data.byteOffset, data.byteLength);
153
- }
154
- if (data instanceof Blob) {
155
- // For Blob, we would need to read it asynchronously
156
- // This is a simplified implementation
157
- throw new Error('Blob data type not fully supported in this implementation');
158
- }
159
- throw new Error('Unsupported data type');
160
- }
161
- }
162
- exports.CoreFileSystemWritableFileStream = CoreFileSystemWritableFileStream;
163
- //# sourceMappingURL=CoreFileSystemWritableFileStream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CoreFileSystemWritableFileStream.js","sourceRoot":"","sources":["../../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,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,qCAAsB,EAAE,CAAC;gBAC3E,MAAM,IAAA,yBAAkB,GAAE,CAAC;YAC7B,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,SAAS,CAAC,KAAgD;QAChE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC;IACnE,CAAC;IAEO,aAAa,CAAC,IAAU;QAC9B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,IAAI,YAAY,eAAM,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,IAAI,YAAY,WAAW,EAAE,CAAC;YAChC,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACpE,CAAC;QACD,IAAI,IAAI,YAAY,IAAI,EAAE,CAAC;YACzB,oDAAoD;YACpD,sCAAsC;YACtC,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;CACF;AAtKD,4EAsKC"}
@@ -1,9 +0,0 @@
1
- import type { IPermissionStatus } from './types';
2
- /**
3
- * @see https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus
4
- */
5
- export declare class CorePermissionStatus implements IPermissionStatus {
6
- readonly name: string;
7
- readonly state: 'granted' | 'denied' | 'prompt';
8
- constructor(state: 'granted' | 'denied' | 'prompt', name?: string);
9
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CorePermissionStatus = void 0;
4
- /**
5
- * @see https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus
6
- */
7
- class CorePermissionStatus {
8
- constructor(state, name = '') {
9
- this.name = name;
10
- this.state = state;
11
- }
12
- }
13
- exports.CorePermissionStatus = CorePermissionStatus;
14
- //# sourceMappingURL=CorePermissionStatus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CorePermissionStatus.js","sourceRoot":"","sources":["../../src/fsa/CorePermissionStatus.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,oBAAoB;IAI/B,YAAY,KAAsC,EAAE,OAAe,EAAE;QACnE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AARD,oDAQC"}
@@ -1,7 +0,0 @@
1
- export declare class FileLockManager {
2
- private locks;
3
- acquireLock(path: string): boolean;
4
- releaseLock(path: string): void;
5
- isLocked(path: string): boolean;
6
- clear(): void;
7
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileLockManager = void 0;
4
- class FileLockManager {
5
- constructor() {
6
- this.locks = new Map();
7
- }
8
- acquireLock(path) {
9
- if (this.locks.get(path)) {
10
- return false;
11
- }
12
- this.locks.set(path, true);
13
- return true;
14
- }
15
- releaseLock(path) {
16
- this.locks.delete(path);
17
- }
18
- isLocked(path) {
19
- return this.locks.get(path) ?? false;
20
- }
21
- clear() {
22
- this.locks.clear();
23
- }
24
- }
25
- exports.FileLockManager = FileLockManager;
26
- //# sourceMappingURL=FileLockManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileLockManager.js","sourceRoot":"","sources":["../../src/fsa/FileLockManager.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;IAA5B;QACU,UAAK,GAAyB,IAAI,GAAG,EAAE,CAAC;IAqBlD,CAAC;IAnBQ,WAAW,CAAC,IAAY;QAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,WAAW,CAAC,IAAY;QAC7B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEM,QAAQ,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;IACvC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AAtBD,0CAsBC"}
@@ -1,182 +0,0 @@
1
- import type { FileLockManager } from './FileLockManager';
2
- export interface IPermissionStatus {
3
- name: string;
4
- state: 'granted' | 'denied' | 'prompt';
5
- }
6
- export interface IFileSystemHandle {
7
- kind: 'file' | 'directory';
8
- name: string;
9
- isSameEntry(fileSystemHandle: IFileSystemHandle): boolean;
10
- queryPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): Promise<IPermissionStatus>;
11
- remove(options?: {
12
- recursive?: boolean;
13
- }): Promise<void>;
14
- requestPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): IPermissionStatus;
15
- }
16
- export interface FileSystemHandlePermissionDescriptor {
17
- mode: 'read' | 'readwrite';
18
- }
19
- export interface IFileSystemDirectoryHandle extends IFileSystemHandle {
20
- keys(): AsyncIterableIterator<string>;
21
- entries(): AsyncIterableIterator<[string, IFileSystemHandle]>;
22
- values(): AsyncIterableIterator<IFileSystemHandle>;
23
- getDirectoryHandle(name: string, options?: GetDirectoryHandleOptions): Promise<IFileSystemDirectoryHandle>;
24
- getFileHandle(name: string, options?: GetFileHandleOptions): Promise<IFileSystemFileHandle>;
25
- removeEntry(name: string, options?: RemoveEntryOptions): Promise<void>;
26
- resolve(possibleDescendant: IFileSystemHandle): Promise<string[] | null>;
27
- }
28
- /**
29
- * Context for Core FSA operations - similar to NodeFsaContext but for Superblock
30
- */
31
- export interface CoreFsaContext {
32
- separator: '/' | '\\';
33
- /** Whether synchronous file handles are allowed. */
34
- syncHandleAllowed: boolean;
35
- /** Whether writes are allowed, defaults to `read`. */
36
- mode: 'read' | 'readwrite';
37
- /** File lock manager for this context. */
38
- locks: FileLockManager;
39
- }
40
- export interface CreateWritableOptions {
41
- keepExistingData?: boolean;
42
- }
43
- export interface GetDirectoryHandleOptions {
44
- /**
45
- * A boolean value, which defaults to `false`. When set to `true` if the directory
46
- * is not found, one with the specified name will be created and returned.
47
- */
48
- create?: boolean;
49
- }
50
- export interface GetFileHandleOptions {
51
- /**
52
- * A Boolean. Default `false`. When set to `true` if the file is not found,
53
- * one with the specified name will be created and returned.
54
- */
55
- create?: boolean;
56
- }
57
- export interface RemoveEntryOptions {
58
- /**
59
- * A boolean value, which defaults to `false`. When set to true entries will
60
- * be removed recursively.
61
- */
62
- recursive?: boolean;
63
- }
64
- export interface IFileSystemFileHandle extends IFileSystemHandle {
65
- getFile(): Promise<File>;
66
- createSyncAccessHandle: undefined | (() => Promise<IFileSystemSyncAccessHandle>);
67
- createWritable(options?: CreateWritableOptions): Promise<IFileSystemWritableFileStream>;
68
- }
69
- export interface CreateWritableOptions {
70
- keepExistingData?: boolean;
71
- }
72
- export interface IFileSystemSyncAccessHandle {
73
- close(): Promise<void>;
74
- flush(): Promise<void>;
75
- getSize(): Promise<number>;
76
- read(buffer: ArrayBuffer | ArrayBufferView, options?: FileSystemReadWriteOptions): Promise<number>;
77
- truncate(newSize: number): Promise<void>;
78
- write(buffer: ArrayBuffer | ArrayBufferView | DataView, options?: FileSystemReadWriteOptions): Promise<number>;
79
- }
80
- export interface FileSystemReadWriteOptions {
81
- /**
82
- * A number representing the offset in bytes that the file should be read from.
83
- */
84
- at?: number;
85
- }
86
- export interface IFileSystemWritableFileStream extends WritableStream {
87
- seek(position: number): Promise<void>;
88
- truncate(size: number): Promise<void>;
89
- write(chunk: Data): Promise<void>;
90
- write(params: FileSystemWritableFileStreamParams): Promise<void>;
91
- }
92
- export interface FileSystemWritableFileStreamParams {
93
- type: 'write' | 'truncate' | 'seek';
94
- data?: Data;
95
- position?: number;
96
- size?: number;
97
- }
98
- export type Data = ArrayBuffer | ArrayBufferView | Uint8Array | Uint8ClampedArray | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array | BigUint64Array | BigInt64Array | DataView | Blob | string;
99
- /**
100
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord
101
- */
102
- export interface IFileSystemChangeRecord {
103
- /**
104
- * A reference to the file system handle that the change was observed on. This
105
- * property will be null for records with a "disappeared", "errored", or
106
- * "unknown" type.
107
- */
108
- changedHandle: IFileSystemHandle | IFileSystemSyncAccessHandle | IFileSystemDirectoryHandle | null;
109
- /**
110
- * An array containing the path components that make up the relative file path
111
- * from the `root` to the `changedHandle`, including the `changedHandle`
112
- * filename.
113
- */
114
- relativePathComponents: string[];
115
- /**
116
- * An array containing the path components that make up the relative file path
117
- * from the `root` to the `changedHandle`'s former location, in the case of
118
- * observations with a `"moved"` type. If the type is not `"moved"`, this
119
- * property will be `null`.
120
- */
121
- relativePathMovedFrom: string[] | null;
122
- /**
123
- * A reference to the root file system handle, that is, the one passed to the
124
- * `observe()` call that started the observation.
125
- */
126
- root: IFileSystemHandle | IFileSystemSyncAccessHandle | IFileSystemDirectoryHandle;
127
- /**
128
- * The type of change that occurred.
129
- */
130
- type: 'appeared'
131
- /**
132
- * The file or directory was deleted or moved out of the root file structure.
133
- * To find out which file or directory `disappeared`, you can query the
134
- * `relativePathComponents` property.
135
- */
136
- | 'disappeared'
137
- /** An error state occurred in the observed directory. */
138
- | 'errored'
139
- /** The file or directory was modified. */
140
- | 'modified'
141
- /**
142
- * The file or directory was moved within the root file structure.
143
- *
144
- * Chrome note: On Windows, "moved" observations aren't supported between
145
- * directories. They are reported as a "disappeared" observation in the
146
- * source directory and an "appeared" observation in the destination directory.
147
- */
148
- | 'moved'
149
- /**
150
- * Indicates that some observations were missed. If you wish to find out
151
- * information on what changed in the missed observations, you could fall
152
- * back to polling the observed directory.
153
- */
154
- | 'unknown';
155
- }
156
- export interface IFileSystemObserverObserveOptions {
157
- /** Whether to observe changes recursively in subdirectories. */
158
- recursive?: boolean;
159
- }
160
- /**
161
- * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemObserver
162
- */
163
- export interface IFileSystemObserver {
164
- /**
165
- * Start observing changes to a given file or directory.
166
- *
167
- * @param handle The file or directory handle to observe.
168
- * @param options Optional settings for the observation.
169
- */
170
- observe(handle: IFileSystemFileHandle | IFileSystemDirectoryHandle | IFileSystemSyncAccessHandle, options?: IFileSystemObserverObserveOptions): Promise<void>;
171
- /** Disconnect and stop all observations. */
172
- disconnect(): void;
173
- }
174
- export interface IFileSystemObserverConstructable {
175
- /**
176
- * Constructor for creating a FileSystemObserver.
177
- *
178
- * @param callback Function called with file system change records and the
179
- * observer instance
180
- */
181
- new (callback: (records: IFileSystemChangeRecord[], observer: IFileSystemObserver) => void): IFileSystemObserver;
182
- }
package/lib/fsa/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fsa/types.ts"],"names":[],"mappings":""}
package/lib/fsa/util.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import type { CoreFsaContext } from './types';
2
- /**
3
- * Creates a new {@link CoreFsaContext}.
4
- */
5
- export declare const ctx: (partial?: Partial<CoreFsaContext>) => CoreFsaContext;
6
- export declare const basename: (path: string, separator: string) => string;
7
- export declare const assertName: (name: string, method: string, klass: string) => void;
8
- export declare const assertCanWrite: (mode: "read" | "readwrite") => void;
9
- export declare const newNotFoundError: () => DOMException;
10
- export declare const newTypeMismatchError: () => DOMException;
11
- export declare const newNotAllowedError: () => DOMException;
12
- export declare const newNoModificationAllowedError: () => DOMException;
package/lib/fsa/util.js DELETED
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.newNoModificationAllowedError = exports.newNotAllowedError = exports.newTypeMismatchError = exports.newNotFoundError = exports.assertCanWrite = exports.assertName = exports.basename = exports.ctx = void 0;
4
- const FileLockManager_1 = require("./FileLockManager");
5
- /**
6
- * Creates a new {@link CoreFsaContext}.
7
- */
8
- const ctx = (partial = {}) => {
9
- return {
10
- separator: '/',
11
- syncHandleAllowed: false,
12
- mode: 'read',
13
- locks: new FileLockManager_1.FileLockManager(),
14
- ...partial,
15
- };
16
- };
17
- exports.ctx = ctx;
18
- const basename = (path, separator) => {
19
- if (path[path.length - 1] === separator)
20
- path = path.slice(0, -1);
21
- const lastSlashIndex = path.lastIndexOf(separator);
22
- return lastSlashIndex === -1 ? path : path.slice(lastSlashIndex + 1);
23
- };
24
- exports.basename = basename;
25
- const nameRegex = /^(\.{1,2})$|[\/\\]/;
26
- const assertName = (name, method, klass) => {
27
- const isInvalid = !name || nameRegex.test(name);
28
- if (isInvalid)
29
- throw new TypeError(`Failed to execute '${method}' on '${klass}': Name is not allowed.`);
30
- };
31
- exports.assertName = assertName;
32
- const assertCanWrite = (mode) => {
33
- if (mode !== 'readwrite')
34
- throw new DOMException('The request is not allowed by the user agent or the platform in the current context.', 'NotAllowedError');
35
- };
36
- exports.assertCanWrite = assertCanWrite;
37
- const newNotFoundError = () => new DOMException('A requested file or directory could not be found at the time an operation was processed.', 'NotFoundError');
38
- exports.newNotFoundError = newNotFoundError;
39
- const newTypeMismatchError = () => new DOMException('The path supplied exists, but was not an entry of requested type.', 'TypeMismatchError');
40
- exports.newTypeMismatchError = newTypeMismatchError;
41
- const newNotAllowedError = () => new DOMException('Permission not granted.', 'NotAllowedError');
42
- exports.newNotAllowedError = newNotAllowedError;
43
- const newNoModificationAllowedError = () => new DOMException('The file is locked and cannot be modified.', 'NoModificationAllowedError');
44
- exports.newNoModificationAllowedError = newNoModificationAllowedError;
45
- //# sourceMappingURL=util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/fsa/util.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAGpD;;GAEG;AACI,MAAM,GAAG,GAAG,CAAC,UAAmC,EAAE,EAAkB,EAAE;IAC3E,OAAO;QACL,SAAS,EAAE,GAAG;QACd,iBAAiB,EAAE,KAAK;QACxB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,IAAI,iCAAe,EAAE;QAC5B,GAAG,OAAO;KACX,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,GAAG,OAQd;AAEK,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,SAAiB,EAAE,EAAE;IAC1D,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS;QAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACnD,OAAO,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC;AAJW,QAAA,QAAQ,YAInB;AAEF,MAAM,SAAS,GAAG,oBAAoB,CAAC;AAEhC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;IACxE,MAAM,SAAS,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