{"id":23508633,"url":"https://github.com/zen-fs/dom","last_synced_at":"2025-07-11T14:36:55.824Z","repository":{"id":200128264,"uuid":"704250729","full_name":"zen-fs/dom","owner":"zen-fs","description":"DOM backends for ZenFS","archived":false,"fork":false,"pushed_at":"2025-06-06T22:12:48.000Z","size":643,"stargazers_count":29,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-08T10:57:24.337Z","etag":null,"topics":["browserfs","zenfs"],"latest_commit_sha":null,"homepage":"https://zenfs.dev/dom/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zen-fs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/codeowners","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["james-pre"]}},"created_at":"2023-10-12T21:33:38.000Z","updated_at":"2025-06-06T22:12:52.000Z","dependencies_parsed_at":"2024-03-22T23:28:04.102Z","dependency_job_id":"2132761a-b3fb-475b-91ae-f1b911913ce1","html_url":"https://github.com/zen-fs/dom","commit_stats":{"total_commits":159,"total_committers":4,"mean_commits":39.75,"dds":0.4779874213836478,"last_synced_commit":"14eb1d899730d3e7c8ba0f3219950fac9fc62683"},"previous_names":["browser-fs/fs-dom","browser-fs/dom","zen-fs/dom"],"tags_count":46,"template":false,"template_full_name":null,"purl":"pkg:github/zen-fs/dom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zen-fs%2Fdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zen-fs%2Fdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zen-fs%2Fdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zen-fs%2Fdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zen-fs","download_url":"https://codeload.github.com/zen-fs/dom/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zen-fs%2Fdom/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264833288,"owners_count":23670617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browserfs","zenfs"],"created_at":"2024-12-25T11:24:56.746Z","updated_at":"2025-07-11T14:36:55.803Z","avatar_url":"https://github.com/zen-fs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/james-pre"],"categories":[],"sub_categories":[],"readme":"# ZenFS DOM Backends\n\n[ZenFS](https://github.com/zen-fs/core) backends for DOM APIs. DOM APIs are _only_ available natively in browsers.\n\nPlease read the ZenFS core documentation!\n\n## Backends\n\n- `WebStorage` stores files in a `Storage` object, like `localStorage` and `sessionStorage`.\n- `IndexedDB` stores files into an `IndexedDB` object database.\n- `WebAccess` uses the [File System Access API](https://developer.mozilla.org/Web/API/File_System_API).\n- `XML` uses an `XMLDocument` to store files, which can be appended to the DOM.\n\nFor more information, see the [API documentation](https://zen-fs.github.io/dom).\n\n## Usage\n\nYou can use the backends from `@zenfs/dom` just like the backends from `@zenfs/core`:\n\n```js\nimport { configure, fs } from '@zenfs/core';\nimport { WebStorage } from '@zenfs/dom';\n\nawait configureSingle({ backend: WebStorage, storage: localStorage });\n\nif (!fs.existsSync('/test.txt')) {\n\tfs.writeFileSync('/test.txt', 'This will persist across reloads!');\n}\n\nconst contents = fs.readFileSync('/test.txt', 'utf-8');\nconsole.log(contents);\n```\n\n#### `XML`\n\nThe `XML` backend can be used to create a file system which lives in the DOM:\n\n```html\n\u003c!-- ... --\u003e\n\u003cfs /\u003e\n\u003c!-- ... --\u003e\n```\n\n```js\nimport { configure, fs } from '@zenfs/core';\nimport { XML } from '@zenfs/dom';\n\nawait configureSingle({\n\tbackend: XML,\n\troot: document.querySelector('fs'), // root is optional\n});\n\nfs.writeFileSync('/test.txt', 'This is in the DOM!');\n```\n\nIf you choose to add the root element to the DOM by appending it, you will likely want to hide its contents (`display:none` works well).\n\nThe `root` option is not required. If you choose not to pass in a `root`, you can always append it to the DOM later:\n\n```js\nimport { configure, fs, mounts } from '@zenfs/core';\nimport { XML } from '@zenfs/dom';\n\nawait configureSingle({ backend: XML });\n\nconst { root } = mounts.get('/');\n\ndocument.body.append(root);\n```\n\nThis may disrupt use cases that involve saving the HTML file locally and loading it later, since a new element is created when configuring. In contrast, when using an existing element and passing in a `root`, the existing element's contents will be preserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzen-fs%2Fdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzen-fs%2Fdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzen-fs%2Fdom/lists"}