{"_id":"file-system-access","_rev":"7-3bd3ba456f81b58127d0bd1846bb2d3c","time":{"1.0.0":"2021-09-04T16:04:55.319Z","created":"2021-09-05T17:12:51.353Z","1.0.1":"2021-09-05T17:12:51.545Z","modified":"2022-11-29T07:12:44.001Z","1.0.2":"2021-11-12T10:32:27.892Z","1.0.3":"2022-11-20T06:09:13.743Z","1.0.4":"2022-11-29T07:12:43.888Z"},"name":"file-system-access","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.1":{"name":"file-system-access","version":"1.0.1","description":"File System Access API implementation (ponyfill) with pluggable storage adapters via IndexedDB, Cache API, in-memory etc.","browser":"./lib/es2018.js","main":"./lib/node.js","module":"./lib/node.js","types":"./lib/node.d.ts","directories":{"example":"example"},"type":"module","scripts":{"test":"npm run check-no-top-level-await && npm run test-node","test-node":"npm run build && cd test && node test-node.js","test-deno":"npm run build && cd test && deno run --allow-read --allow-net --allow-write test-deno.js","prepare":"npm run build","build":"rm -rf lib && tsc -p . && node copy-polyfill.js","check-no-top-level-await":"tsc -p . --noEmit --target es2016","watch":"tsc -w -p .","deploy-gh-pages":"npm run build && rm -rf gh-dist && mkdir gh-dist && cp -r lib test example README.md gh-dist/ && gh-pages -d gh-dist -m 'Deploy gh-pages [ci skip]'"},"repository":{"type":"git","url":"git+https://github.com/use-strict/file-system-access.git"},"keywords":["filesystem","file","blob","stream","fs","read","write","delete","file system access","spec"],"author":{"name":"Alexandru Ciuca"},"license":"MIT","bugs":{"url":"https://github.com/use-strict/file-system-access/issues"},"homepage":"https://github.com/use-strict/file-system-access#readme","optionalDependencies":{"web-streams-polyfill":"^3.1.0"},"dependencies":{"@types/wicg-file-system-access":"^2020.9.2","fetch-blob":"^3.0.0","node-domexception":"^1.0.0","web-streams-polyfill":"^3.1.0"},"devDependencies":{"@types/filesystem":"0.0.32","@types/node":"^14.17.11","gh-pages":"^3.2.3","standard":"^16.0.3","tape":"^5.2.2","typescript":"^4.3.5"},"engines":{"node":">=14"},"gitHead":"ddfd98f34fa7972229e0ed7c2da84afd765acead","_id":"file-system-access@1.0.1","_nodeVersion":"13.14.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-MaGOyaHDj1qJdgsy1/8ZI5/jdiFJe7IbAP1TfZwybyyfZmzJtuIXuIGNPn1t5vtzNQQ8Bl9/CqTbugJGU3habw==","shasum":"8171499f9b776283456d8d9ae67dbe05aa476b46","tarball":"https://registry.npmjs.org/file-system-access/-/file-system-access-1.0.1.tgz","fileCount":94,"unpackedSize":479003,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhNPqTCRA9TVsSAnZWagAAB/YP/jAqC8wnworVXkY8cAvN\nLrMZ0tiCT7RdcV0jhxj+vXg1ffJLkXgNjr2BQvrd/q87DOwfUkiSLG3rcJMh\nEQ/d9+6UY8MS/t4i1JOAFth7M9w2MFPT64piI5Tk5cmTCSY37wqN7LhufmJq\n75J32tCLKfOowYUmUERztTFtBjdl56brvdovD/ivcrx2jDG31chQkvMKpjdV\nZfWObEzxW1N4co9sL3HlQHc8Z0GIMZ4v/+qf9KGwMvCZUImUnvTcXA6YFnK/\nmeCfF6NceR3mE4pbiQ0E5sorNUWT6o/sB50YCBXuLDAwy9qEfaxgtjE2ATij\nxspBkUtQaVXXjjSjIRDk8KlvlciALW4/FJTmBc/3iBCbNNXNjY37RkDxCwZQ\nSCGD2FbQQIQFiqrGbO/Rw8kQQWOX90zp3v7KMr3sH+BFtiOlwgFW+yWA0jrM\n8qjj9RkXCff9EZ36c2BWTKq17WkEYfYeMd3z+v1qsfXAr2lTMC5IAjFRdtqC\ngk3koTGCcMKijUoIwAxLrBhPzp/3QPNaFgeEpoVXt5BFgtCrVqOAF/p1idyh\ngmFvajGC908vfWtXOPJtXkzZn+/jPLc6PyPa4yN0hVotR8B5nkWAJxEOf/2G\nIccyPBbYDk/5vYQxsaDoPLRYP8IwaeLoJI6xX2A7zdAmdG576vHk2bHpcH4p\nke+r\r\n=Rd4e\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZtSTZVFiDp3bSA1jtzSyhI8BpB49RsI30sYA800+u2wIhALTGolLzAFg3ZtpCYf8MEZbU2Pj+KCHtMhSOIUeyo8XU"}]},"_npmUser":{"name":"usestrict","email":"alex@ciuca.dev"},"maintainers":[{"name":"usestrict","email":"alex@ciuca.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-system-access_1.0.1_1630861971353_0.16110035933007905"},"_hasShrinkwrap":false},"1.0.2":{"name":"file-system-access","version":"1.0.2","description":"File System Access API implementation (ponyfill) with pluggable storage adapters via IndexedDB, Cache API, in-memory etc.","browser":"./lib/es2018.js","main":"./lib/node.js","module":"./lib/node.js","types":"./lib/node.d.ts","directories":{"example":"example"},"type":"module","scripts":{"test":"npm run check-no-top-level-await && npm run test-node","test-node":"npm run build && cd test && node test-node.js","test-deno":"npm run build && cd test && deno run --allow-read --allow-net --allow-write test-deno.js","prepare":"npm run build","build":"rm -rf lib && tsc -p . && node copy-polyfill.js","check-no-top-level-await":"tsc -p . --noEmit --target es2016","watch":"tsc -w -p .","deploy-gh-pages":"npm run build && rm -rf gh-dist && mkdir gh-dist && cp -r lib test example README.md gh-dist/ && gh-pages -d gh-dist -m 'Deploy gh-pages [ci skip]'"},"repository":{"type":"git","url":"git+https://github.com/use-strict/file-system-access.git"},"keywords":["filesystem","file","blob","stream","fs","read","write","delete","file system access","spec"],"author":{"name":"Alexandru Ciuca"},"license":"MIT","bugs":{"url":"https://github.com/use-strict/file-system-access/issues"},"homepage":"https://github.com/use-strict/file-system-access#readme","optionalDependencies":{"web-streams-polyfill":"^3.1.0"},"dependencies":{"@types/wicg-file-system-access":"^2020.9.2","fetch-blob":"^3.0.0","node-domexception":"^1.0.0","web-streams-polyfill":"^3.1.0"},"devDependencies":{"@types/filesystem":"0.0.32","@types/node":"^14.17.11","gh-pages":"^3.2.3","standard":"^16.0.3","tape":"^5.2.2","typescript":"^4.3.5"},"engines":{"node":">=14"},"gitHead":"d5101505c24bb2f429715d85e3db0d85c9e1cfa7","_id":"file-system-access@1.0.2","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-Jcz6/xdjxon8SydmCajn67WjZm2VM7vgqt3C52Jeeqpv6SndZ7gKIwSS5+ie6V6XaiFZqlXBbJ1/Pzf+Y3/7cA==","shasum":"637a4f46cc79924218cf3453ea4c438d45c4ade8","tarball":"https://registry.npmjs.org/file-system-access/-/file-system-access-1.0.2.tgz","fileCount":94,"unpackedSize":479365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2rBNCRA9TVsSAnZWagAAB5sP/j2SIrARpiyOUHr6fEEV\n9epo1lLnAcxR9L/fWUB4me374/Os6ycN98Go4RDXctMym5iNKcs7fyWz9/uH\nJisoUmw1nfczHYsHhn157jqUq1PXy8yo3ct22+4jyHar8TXz88LUkmtgYRw3\nn471u8bi5IVc4OgrdA1WOCMGIA/dY6HVZ5oz0Z081CWoRZRO9h+gOgrIpHq5\nQgJl1ssEfqmTlQwOT2RhN84CQ2pjxnyEmjjRLBwzi3OBYh9dQmQeziufXr/M\ngrrCUCiI0dqMhqVHeZ06/1pARjj/IYmM5bvXxJ9no5h4PwqTDbl3dQk8P3J1\nRBFQDKVJ8L7GsrC9nZXSzghb2VUtvTxgJofA/YA26yopRWCjVQRo0Lna+TnY\n2v4RTuhx3C/SXe0y6hFFhxFf8njUF2u7SUZIw7Xi0dXeSis/RmdE2BwMPCnv\nNGy5F3bk/evVP2wiubUJmq/RdjpL3smVuigwaAx41qSuRijWZmUCZ3YpL+6n\n2REdNPIHHpLgyzkafstMRHb2v9xm1T3cNKQ7D25u/AY4y/AR5s+3Hta7GbBB\n+NOabeen77izQ/Iyc4mnBL5jvEkJwoxNkz40GhPJdMhL5rG3sjOYlyJcfySc\nFuvKWjAnDdslPqkwQfW9uoZPIz+IKb5ovv7fS9XeTATyLRSA4nWWTm9VXU7Y\n/oKe\r\n=NeiY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCuP7tyW3jqo12FS9fS6ZMjOLfn5ZWnQC7WyYsbiObzGwIhAJkFqQvhOV9LJPGALER/ywx0lY1fx/ZVNYYsrZPJCiUd"}]},"_npmUser":{"name":"usestrict","email":"alex@ciuca.dev"},"maintainers":[{"name":"usestrict","email":"alex@ciuca.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-system-access_1.0.2_1636713147705_0.08534113831235968"},"_hasShrinkwrap":false},"1.0.3":{"name":"file-system-access","version":"1.0.3","description":"File System Access API implementation (ponyfill) with pluggable storage adapters via IndexedDB, Cache API, in-memory etc.","browser":"./lib/es2018.js","main":"./lib/node.js","module":"./lib/node.js","types":"./lib/node.d.ts","directories":{"example":"example"},"type":"module","scripts":{"test":"npm run check-no-top-level-await && npm run test-node","test-node":"npm run build && cd test && node test-node.js","test-deno":"npm run build && cd test && deno run --allow-read --allow-net --allow-write test-deno.js","prepare":"npm run build","build":"rm -rf lib && tsc -p . && node copy-polyfill.js","check-no-top-level-await":"tsc -p . --noEmit --target es2016","watch":"tsc -w -p .","deploy-gh-pages":"npm run build && rm -rf gh-dist && mkdir gh-dist && cp -r lib test example README.md gh-dist/ && gh-pages -d gh-dist -m 'Deploy gh-pages [ci skip]'"},"repository":{"type":"git","url":"git+https://github.com/use-strict/file-system-access.git"},"keywords":["filesystem","file","blob","stream","fs","read","write","delete","file system access","spec"],"author":{"name":"Alexandru Ciuca"},"license":"MIT","bugs":{"url":"https://github.com/use-strict/file-system-access/issues"},"homepage":"https://github.com/use-strict/file-system-access#readme","optionalDependencies":{"web-streams-polyfill":"^3.1.0"},"dependencies":{"@types/wicg-file-system-access":"^2020.9.2","fetch-blob":"^3.0.0","node-domexception":"^1.0.0","web-streams-polyfill":"^3.1.0"},"devDependencies":{"@types/filesystem":"0.0.32","@types/node":"^14.17.11","gh-pages":"^3.2.3","standard":"^16.0.3","tape":"^5.2.2","typescript":"^4.3.5"},"engines":{"node":">=14"},"gitHead":"c3f4fc19c2fb46e2c39b23ea1f3bfa4de3a5df3c","_id":"file-system-access@1.0.3","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-BIx2snw0cvxamMIwD0acKuIDwSxYpzy91ZN8wt0PduNvpZfGARJ330aBzFoU7OuygoN0TrpQdU8UdfJ/ZVjhiA==","shasum":"1f370daf563443ccd0b1e2c5d4422b15b63f785e","tarball":"https://registry.npmjs.org/file-system-access/-/file-system-access-1.0.3.tgz","fileCount":94,"unpackedSize":482374,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDjIVHmTZVlyiZ/jAnXVGfktDM60/5+0oUTXqb6RmGvMAiEAzEgMutHYejePQaQ1szOXmg09G25QuomY03aHlc4mP4c="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjecSJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo/dg//d99W+MkSe8CIkbWxkcqQlxSS0hbUSDbRf4jnj7b48mWU18dN\r\n1TYJ9pByk1g7JqHi+G9CBYnoKL1HFIPa72mFt4LWEQcpSgks8Sw0yU+iQhOz\r\nwqK0Rhrgpy/VCUUemO8QCIXzJ1hBwKwQEr9KE8ghDVrcvS3+x+t12xPzmq41\r\nIGkRyoMcoAA0twkiVv+8zIz+Yiw6hBO6fd/Zy4Is9cLh9qPKeT8HDVsCfUsb\r\nDrbMTjjyoOHgh1YVUMrpG71KXZCsxE+n/KC1koFgilgwpRogJsnTfMUc9fBr\r\niR/BmV9KuHJBRAU5cW2rTREMcEZ42Ls2HjXkJ0aD4NWyHQrJ8q+1VTAsIGNG\r\n0FrBNjgPmT69ihh/ujmbfoUeVkI9Ik1o+/pxFBBtP2AoPEPK53+xle5AKrg6\r\neSE0lIVG2ye+a4Y7o+re+Wz88XomVhAtEcViTlXOxQ27/Ak+lekEy0+pPpbg\r\nKGpi8ZZiq8YWGfg5nedLBO3QTQQ7phU7WzT4PMvJ+8Pauq/5qQA3Ug7bN9hO\r\nbhs0+9AnDdqQ+xEDMs77MGWqrxRlYWGA0qPb6K74WInMz7ApPzRWgnY/bdt8\r\nPXBLhN2BUpAESvQ7lp5TV8IkoXhckX0VS7PHpGfLgyFpY0SntW6cHql0dkK3\r\nRw8Pufwf6l2up/jrt1WhrQUO2nfP5wrbRhc=\r\n=XL6G\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"usestrict","email":"alex@ciuca.dev"},"maintainers":[{"name":"usestrict","email":"alex@ciuca.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-system-access_1.0.3_1668924553550_0.46804057024824086"},"_hasShrinkwrap":false},"1.0.4":{"name":"file-system-access","version":"1.0.4","description":"File System Access API implementation (ponyfill) with pluggable storage adapters via IndexedDB, Cache API, in-memory etc.","browser":"./lib/es2018.js","main":"./lib/node.js","module":"./lib/node.js","types":"./lib/node.d.ts","directories":{"example":"example"},"type":"module","scripts":{"test":"npm run check-no-top-level-await && npm run test-node","test-node":"npm run build && cd test && node test-node.js","test-deno":"npm run build && cd test && deno run --allow-read --allow-net --allow-write test-deno.js","prepare":"npm run build","build":"rm -rf lib && tsc -p . && node copy-polyfill.js","check-no-top-level-await":"tsc -p . --noEmit --target es2016","watch":"tsc -w -p .","deploy-gh-pages":"npm run build && rm -rf gh-dist && mkdir gh-dist && cp -r lib test example README.md gh-dist/ && gh-pages -d gh-dist -m 'Deploy gh-pages [ci skip]'"},"repository":{"type":"git","url":"git+https://github.com/use-strict/file-system-access.git"},"keywords":["filesystem","file","blob","stream","fs","read","write","delete","file system access","spec"],"author":{"name":"Alexandru Ciuca"},"license":"MIT","bugs":{"url":"https://github.com/use-strict/file-system-access/issues"},"homepage":"https://github.com/use-strict/file-system-access#readme","optionalDependencies":{"web-streams-polyfill":"^3.1.0"},"dependencies":{"@types/wicg-file-system-access":"^2020.9.2","fetch-blob":"^3.0.0","node-domexception":"^1.0.0","web-streams-polyfill":"^3.1.0"},"devDependencies":{"@types/filesystem":"0.0.32","@types/node":"^14.17.11","gh-pages":"^3.2.3","standard":"^16.0.3","tape":"^5.2.2","typescript":"^4.3.5"},"engines":{"node":">=14"},"gitHead":"dbb52654687478ec02112360735360b31a0ad116","_id":"file-system-access@1.0.4","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-JDlhH+gJfZu/oExmtN4/6VX+q1etlrbJbR5uzoBa4BzfTRQbEXGFuGIBRk3ZcPocko3WdEclZSu+d/SByjG6Rg==","shasum":"73e6621bbd787cd14516e59f8332f1d5a8499f6e","tarball":"https://registry.npmjs.org/file-system-access/-/file-system-access-1.0.4.tgz","fileCount":94,"unpackedSize":483240,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFHRkuIe6nnpFHR59Y/cUxq4Z8Kj368nIcQZaN/j5nzmAiEA+lle3QTHeMWzXOEiAro3C82eFV4z5moUHlM47kgz5eY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjhbDrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrtOg//YPYBxFwOj/x6K9gpbJ9SZdDH/subt0Al4dcFWmp8HyjaTX19\r\nV4u6xguEIrnloNp67fxEpoy7RXrRb0wPygshEIb5q97j1witLoyESqgTY040\r\nOvEytGzamIv3vehMWEUcTymDeBhPJ/c0M2+PMTuxOw5NzPVPsNNQfuh4nFY3\r\nA3czqFnr6vuzByscgNN4cE8/4QKVP7ByU0/HgzIIlsCwEwFWg7LcGMOXDypH\r\ntDLs3nc+eExt/OdsdZTnVLTWB4ErUNoDKGzPTFawpkA/x+mGjwjkSrAu006t\r\nH9Cj/P5V+NHKC4SQ1zYqUccmcZrcqbkgTtHaPIy3iNzPz/ehrxcRWPubfSDE\r\nMN9k2jIpzfef885+K1pwDpuo+8cXkA56wOiM3Hdj+K1fcpUUOFdV1zKfgJPD\r\nDEELeFsbyKLKxY+JJuQuViZgRCZIYPnkvBwvGdyBjvdZ6ggFQn7Vdmoq2bRC\r\nHkJ7HDydBiONshi9/Os6juvH2IJSH2jm8kGKa2d8fJczFscE+SXpeFG1UDiX\r\n+ORt/xD8KBE5ZlGJUdY7J/knBuegEC0S1DXfux83skhdB+q+/lHvHaUoRfCi\r\ny/W/rG3GtfVFf569y4j2sF2YX+AtwcoRaWiLhLMIflb/7jWhpKXZgZGPw5/w\r\nuUs4PJ6DppNVqfv/DIUFRRn1X51KbVMuVds=\r\n=vur2\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"usestrict","email":"alex@ciuca.dev"},"maintainers":[{"name":"usestrict","email":"alex@ciuca.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-system-access_1.0.4_1669705963694_0.37198104714730484"},"_hasShrinkwrap":false}},"maintainers":[{"name":"usestrict","email":"alex@ciuca.dev"}],"description":"File System Access API implementation (ponyfill) with pluggable storage adapters via IndexedDB, Cache API, in-memory etc.","homepage":"https://github.com/use-strict/file-system-access#readme","keywords":["filesystem","file","blob","stream","fs","read","write","delete","file system access","spec"],"repository":{"type":"git","url":"git+https://github.com/use-strict/file-system-access.git"},"author":{"name":"Alexandru Ciuca"},"bugs":{"url":"https://github.com/use-strict/file-system-access/issues"},"license":"MIT","readme":"# File System Access API (ponyfill)\r\n\r\n## Introduction\r\n\r\nThis is an implementation of the [File System Access](https://wicg.github.io/file-system-access/) specification. It is a ponyfill that uses the native browser implementation when available and falls back to a custom one otherwise. It also includes several storage adapters which can be used in the browser, but also in other environments, such as NodeJS or Deno.\r\n\r\nThe library roughly contains the following:\r\n\r\n1. Ponyfills for `showDirectoryPicker`, `showOpenFilePicker` and `showSaveFilePicker`, with fallbacks to regular input elements.\r\n2. Ponyfills for `FileSystemFileHandle` and `FileSystemDirectoryHandle` interfaces.\r\n3. Ponyfill for `FileSystemWritableFileStream` to truncate and write data.\r\n4. An implementation of `navigator.storage.getDirectory()` (`getOriginPrivateDirectory`) which can read & write data to and from several sources called adapters, not just the browser sandboxed file system\r\n5. An optional polyfill for `DataTransferItem.prototype.getAsFileSystemHandle()`\r\n\r\nThis package builds upon [native-file-system-adapter](https://github.com/jimmywarting/native-file-system-adapter), adding several bug fixes, updates for compliance with the latest spec, browser support improvements (especially Safari), support for bundlers, stricter error handling and more. It is fully rewritten in TypeScript and provides type-safe declarations out-of-the-box.\r\n\r\n## File system adapters\r\n\r\nWhen `getOriginPrivateDirectory` is called with no arguments, the browser's native sandboxed file system is used, just like calling `navigator.storage.getDirectory()`.\r\n\r\nOptionally, a file system backend adapter can be provided as an argument. This ponyfill ships with a few backends built in:\r\n\r\n* `node`: Uses NodeJS's `fs` module\r\n* `deno`: Interact with filesystem using Deno\r\n* `sandbox` (deprecated): Uses [requestFileSystem](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestFileSystem). Only supported in Chromium-based browsers using the `Blink` engine.\r\n* `indexeddb`: Stores files into the browser's `IndexedDB` object database.\r\n* `memory`: Stores files in-memory. Thus, it is a temporary file store that clears when the user navigates away.\r\n* `cache`: Stores files with the browser's [Cache API](https://web.dev/cache-api-quick-guide/) in request/response pairs.\r\n\r\nYou can even load in your own underlying adapter and get the same set of API's by implementing the [FileSystemFileHandleAdapter](./src/interfaces.ts) and [FileSystemFolderHandleAdapter](./src/interfaces.ts) interfaces\r\n\r\nThe API is designed in such a way that it can work with or without the ponyfill if you choose to remove or add this.<br>\r\nIt's not trying to interfere with the changing spec by using other properties that may conflict with the feature changes to the spec.\r\n\r\n## Basic usage\r\n\r\n### ES import in browser\r\n\r\nYou can directly import the module using an absolute URL:\r\n\r\n```html\r\n<script type=\"module\">\r\nimport { getOriginPrivateDirectory } from 'https://cdn.jsdelivr.net/npm/file-system-access/lib/es2018.js'\r\n\r\n// Get a directory handle for a sandboxed virtual file system\r\n// same as calling navigator.storage.getDirectory()\r\nconst dirHandle1 = await getOriginPrivateDirectory()\r\n\r\n// or use an adapter (see adapters table above for a list of available adapters)\r\nconst dirHandle2 = await getOriginPrivateDirectory(import('https://cdn.jsdelivr.net/npm/file-system-access/lib/adapters/<adapterName>.js'))\r\n</script>\r\n```\r\n\r\n### Install via NPM\r\n\r\nWorks in Node.JS v14.8+ or in the browser, with a module bundler such as Webpack.\r\n\r\n```\r\nnpm i file-system-access\r\n```\r\n\r\n```js\r\nimport { getOriginPrivateDirectory } from 'file-system-access'\r\nimport indexedDbAdapter from 'file-system-access/lib/adapters/indexeddb.js'\r\nimport nodeAdapter from 'file-system-access/lib/adapters/node.js'\r\n\r\nconst dirHandle = await getOriginPrivateDirectory(indexedDbAdapter)\r\nconst nodeDirHandle = await getOriginPrivateDirectory(nodeAdapter, './real-dir')\r\n```\r\n\r\n## Examples\r\n\r\n### File system sandbox\r\n\r\nYou can get a directory handle to a sandboxed virtual file system using the `getOriginPrivateDirectory` function.\r\nThis is a legacy name introduced by an older `Native File System` specification and is kept for simplicity.\r\nIt is equivalent to the `navigator.storage.getDirectory()` method introduced by the later [File System Access](https://wicg.github.io/file-system-access/) spec.\r\n\r\n```js\r\nimport { getOriginPrivateDirectory, support } from 'file-system-access'\r\n\r\n// Uses only native implementation - same as calling navigator.storage.getDirectory()\r\nif (support.adapter.native) {\r\n  handle = await getOriginPrivateDirectory()\r\n}\r\n// Blinks old sandboxed api\r\nif (support.adapter.sandbox) {\r\n  handle = await getOriginPrivateDirectory(import('file-system-access/lib/adapters/sandbox.js'))\r\n}\r\n// fast in-memory file system\r\nhandle = await getOriginPrivateDirectory(import('file-system-access/lib/adapters/memory.js'))\r\n// Using indexDB\r\nhandle = await getOriginPrivateDirectory(import('file-system-access/lib/adapters/indexeddb.js'))\r\n// Store things in the new Cache API as request/responses (bad at mutating data)\r\nif (support.adapter.cache) {\r\n  handle = await getOriginPrivateDirectory(import('file-system-access/lib/adapters/cache.js'))\r\n}\r\n\r\n// Node only variant:\r\nhandle = await getOriginPrivateDirectory(import('file-system-access/lib/adapters/memory.js'))\r\nhandle = await getOriginPrivateDirectory(import('file-system-access/lib/adapters/node.js'), './starting-path')\r\n\r\n// Deno only variant:\r\nhandle = await getOriginPrivateDirectory(import('file-system-access/src/adapters/memory.js'))\r\nhandle = await getOriginPrivateDirectory(import('file-system-access/src/adapters/deno.js'), './starting-path')\r\n```\r\n\r\n### File and directory pickers\r\n\r\n```js\r\nimport { showDirectoryPicker, showOpenFilePicker } from 'file-system-access'\r\n\r\n// The polyfilled (file input) version will turn into a memory adapter\r\n// You will have read & write permission on the memory adapter,\r\n// you might want to transfer (copy) the handle to another adapter\r\nconst [fileHandle] = await showOpenFilePicker({_preferPolyfill: boolean, ...sameOpts})\r\nconst dirHandle = await showDirectoryPicker({_preferPolyfill: boolean, ...sameOpts})\r\n```\r\n\r\n### Drag and drop\r\n\r\n```js\r\n// Apply polyfill for DataTransferItem.prototype.getAsFileSystemHandle()\r\n\r\nimport { polyfillDataTransferItem } from 'file-system-access'\r\nawait polyfillDataTransferItem();\r\n\r\n// or just use a static import\r\n\r\nimport 'file-system-access/lib/polyfillDataTransferItem.js'\r\n\r\nwindow.ondrop = async evt => {\r\n  evt.preventDefault()\r\n  for (let item of evt.dataTransfer.items) {\r\n    const handle = await item.getAsFileSystemHandle()\r\n    console.log(handle)\r\n  }\r\n}\r\n```\r\n\r\n### Copy file handles to sandboxed file system\r\n\r\n```js\r\nimport { showOpenFilePicker, getOriginPrivateDirectory } from 'file-system-access'\r\n\r\n// request user to select a file\r\nconst [fileHandle] = await showOpenFilePicker({\r\n  types: [], // default\r\n  multiple: false, // default\r\n  excludeAcceptAllOption: false, // default\r\n  _preferPolyfill: false // default\r\n})\r\n\r\n// returns a File Instance\r\nconst file = await fileHandle.getFile()\r\n\r\n// copy the file over to a another place\r\nconst rootHandle = await getOriginPrivateDirectory()\r\nconst fileHandle = await rootHandle.getFileHandle(file.name, { create: true })\r\nconst writable = await fileHandle.createWritable()\r\nawait writable.write(file)\r\nawait writable.close()\r\n```\r\n\r\n### Save / download a file\r\n\r\n```js\r\nimport { showSaveFilePicker } from 'file-system-access'\r\n\r\nconst fileHandle = await showSaveFilePicker({\r\n  _preferPolyfill: false,\r\n  suggestedName: 'Untitled.png',\r\n  types: [\r\n    { accept: { \"image/png\": [ \".png\" ] } },\r\n    { accept: { \"image/jpg\": [ \".jpg\" ] } },\r\n    { accept: { \"image/webp\": [ \".webp\" ] } }\r\n  ],\r\n  excludeAcceptAllOption: false // default\r\n})\r\n\r\n// Look at what extension they have chosen\r\nconst extensionChosen = fileHandle.name.split('.').pop()\r\n\r\nconst blob = {\r\n  jpg: generateCanvasBlob({ type: 'blob', format: 'jpg' }),\r\n  png: generateCanvasBlob({ type: 'blob', format: 'png' }),\r\n  webp: generateCanvasBlob({ type: 'blob', format: 'webp' })\r\n}[extensionChosen]\r\n\r\nawait blob.stream().pipeTo(fileHandle.createWritable())\r\n// or\r\nvar writer = fileHandle.getWritable()\r\nawait writer.write(blob)\r\nawait writer.close()\r\n```\r\n\r\n## Supported browsers\r\n\r\nWhen importing as an ES module, browsers that support [dynamic imports](https://caniuse.com/es6-module-dynamic-import) and ES2018 features are a minimum requirement. When using a bundler, this restriction is no longer applicable.\r\n\r\nWhen the directory picker falls back to `input` elements, the browser must support [webkitdirectory](https://caniuse.com/mdn-api_htmlinputelement_webkitdirectory) and [webkitRelativePath](https://caniuse.com/mdn-api_file_webkitrelativepath). Because of this, support for picking directories is generally poor on Mobile browsers.\r\n\r\nFor drag and drop, the `getAsFileSystemHandle()` polyfill depends on the `File and Directory Entries API` support, more specifically [FileSystemDirectoryEntry](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry), [FileSystemFileEntry](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry) and [webkitGetAsEntry](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry).\r\n\r\n## Limitations\r\n\r\n- Storing a file handle in IndexedDB or sharing it with postMessage isn't currently possible unless you use native.\r\n- `showDirectoryPicker` and `showOpenFilePicker` will not throw any `AbortError`s (e.g. user cancellations) when using a fallback input element\r\n- `showDirectoryPicker` will return a flat hierarchy when a fallback `input` element is used and `webkitRelativePath` is not supported (e.g. mobile Safari). This can be detected by checking if the `name` attribute of the root directory handle is an empty string.\r\n- `showSaveFilePicker` may not actually show any prompt when using a fallback input (e.g. on Chrome the file is auto-saved to the browser's preferred download folder)\r\n- Cache adapter only works in secure (HTTPS) contexts\r\n- IndexedDB adapter may not work in some browsers in Private mode\r\n- Mobile Safari scrambles original file names\r\n\r\n## A note when downloading with the polyfilled version\r\n\r\nSaving/downloading a file is borrowing some of ideas from [StreamSaver.js](https://github.com/jimmywarting/StreamSaver.js).\r\nThe difference is:\r\n - Using service worker is optional choice with this adapter.\r\n - It does not rely on some man-in-the-middle or external hosted service worker.\r\n - If you want to stream large data to the disk directly instead of taking up much RAM you need to set up a service worker yourself.<br>(note that it requires https - but again worker is optional)\r\n\r\nto set up a service worker you have to basically copy [the example](./example/sw.js) and register it:\r\n\r\n```js\r\nnavigator.serviceWorker.register('sw.js')\r\n```\r\n\r\nWithout service worker you are going to write all data to the memory and download it once it closes.\r\n\r\nSeeking and truncating won't do anything. You should be writing all data in sequential order when using the polyfilled version.\r\n\r\n## Testing\r\n\r\n- In project folder, run `npx http-server -p 3000 .`\r\n- For browser tests, open `http://localhost:3000/example/test.html` in your browser.\r\n- For node: `npm run test-node`\r\n- For deno: `npm run test-deno`\r\n\r\n## Resources\r\n\r\nI recommend to follow up on this links for you to learn more about the API and how it works\r\n\r\n- https://web.dev/file-system-access/\r\n- https://wicg.github.io/file-system-access/\r\n- https://github.com/WICG/file-system-access\r\n\r\n## Alternatives\r\n- [native-file-system-adapter](https://github.com/jimmywarting/native-file-system-adapter): The original implementation in vanilla JavaScript by [@jimmywarting](https://github.com//jimmywarting).\r\n- [browser-fs-access](https://github.com/GoogleChromeLabs/browser-fs-access) by [@tomayac](https://github.com/tomayac): A similar, more like a shim (without `getSystemDirectory`).\r\n- [StreamSaver](https://github.com/jimmywarting/StreamSaver.js) by [@jimmywarting](https://github.com/jimmywarting): A way to save large data to the disk directly with a writable stream <br><small>(same technique can be achieved if service worker are setup properly)</small>\r\n- [FileSaver](https://github.com/eligrey/FileSaver.js) by [@eligrey](https://github.com/eligrey): One among the first libs to save blobs to the disk\r\n\r\n## License\r\n\r\nfile-system-access is licensed under the MIT License. See `LICENSE` for details.\r\n","readmeFilename":"README.md"}