{"id":29698831,"url":"https://github.com/beyondjs/media","last_synced_at":"2025-07-23T10:39:16.102Z","repository":{"id":299750685,"uuid":"1003010385","full_name":"beyondjs/media","owner":"beyondjs","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-18T04:46:08.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-18T05:35:42.465Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beyondjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-16T13:38:09.000Z","updated_at":"2025-06-18T04:46:12.000Z","dependencies_parsed_at":"2025-06-18T05:47:13.388Z","dependency_job_id":null,"html_url":"https://github.com/beyondjs/media","commit_stats":null,"previous_names":["beyondjs/media"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/beyondjs/media","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fmedia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fmedia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fmedia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fmedia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beyondjs","download_url":"https://codeload.github.com/beyondjs/media/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fmedia/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266664320,"owners_count":23964934,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-07-23T10:39:15.616Z","updated_at":"2025-07-23T10:39:16.095Z","avatar_url":"https://github.com/beyondjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"````md\n# @beyond-js/media\n\n**`@beyond-js/media`** is a universal, modular, and reactive TypeScript library for managing files across environments like **Node.js**, **Web**, and future runtimes.  \nIt provides a unified API for reading, writing, streaming, parsing, and extending file operations — with first-class support for **JSON files**, **custom adapters**, and **reactive data flow**.\n\n---\n\n## 📦 Features\n\n- ✅ Reactive `File` object with event hooks (`read.completed`, `write.completed`, etc.)\n- ✅ Multi-environment support (Node.js, Web)\n- ✅ Pluggable adapters and parsers\n- ✅ JSON file abstraction with object-level interaction\n- ✅ Built-in streaming and chunk reading\n- ✅ Type-safe API using `TypeScript`\n- ✅ Designed for extensibility: uploaders, audio/video, and office file support\n\n---\n\n## 📁 Installation\n\n```bash\npnpm add @beyond-js/media\n# or\nnpm install @beyond-js/media\n````\n\n---\n\n## 🧠 Usage\n\n### 1. Create and write to a file (Node)\n\n```ts\nimport { File } from '@beyond-js/media/core/file';\nimport { encode } from '@beyond-js/media/utils/text-codec';\n\nconst file = new File({\n  name: 'example.txt',\n  size: 0,\n  type: 'text/plain',\n  last_modified: Date.now()\n});\n\nfile.on('write.completed', () =\u003e console.log('Write finished'));\nawait file.write(encode('Hello world!'));\n```\n\n---\n\n### 2. Create and manage a JSON file\n\n```ts\nimport { JsonFile } from '@beyond-js/media/entities/json-file';\n\nconst jsonFile = new JsonFile({\n  name: 'config.json',\n  size: 0,\n  type: 'application/json',\n  last_modified: Date.now()\n});\n\njsonFile.data = { enabled: true, version: 1 };\nawait jsonFile.load();\n\nconsole.log(jsonFile.data); // Output: { enabled: true, version: 1 }\n```\n\n---\n\n### 3. Stream a file in chunks\n\n```ts\nfor await (const chunk of file.stream({ chunk_size: 1024 })) {\n  console.log('Chunk', chunk.length);\n}\n```\n\n---\n\n## 🔄 Reactive Hooks\n\nAll `File` and `JsonFile` objects are reactive via `@beyond-js/reactive/model`. You can:\n\n* Subscribe to file lifecycle events:\n\n  ```ts\n  file.on('read.completed', data =\u003e console.log('File read', data));\n  file.on('meta.changed', meta =\u003e console.log('Metadata updated', meta));\n  ```\n\n* Integrate with UI or observable-based workflows.\n\n---\n\n## 🧩 Extending the Library\n\n### 📂 Add a new Adapter\n\nCreate a class implementing `IFileAdapter` and register it:\n\n```ts\nimport { File } from '@beyond-js/media/core/file';\n\nFile.registerAdapter(new MyCustomAdapter());\n```\n\n### 🧬 Add a new Parser\n\nImplement `IParser\u003cT\u003e` and use it to convert file content into structured data:\n\n```ts\nconst parser = new XmlParser();\nif (parser.canHandle(file)) {\n  const obj = await parser.parse(file);\n}\n```\n\n---\n\n## 🧱 Project Structure\n\n```\n@beyond-js/media/\n├─ core/           # Base File implementation\n├─ adapters/       # Node.js / Web adapters\n├─ entities/       # Specialized reactive files\n├─ parsers/        # File content parsers\n├─ types/          # Interfaces and typings\n└─ utils/          # Text codec, errors, etc.\n```\n\n---\n\n## 🚀 Roadmap\n\n* [x] JSON parsing\n* [x] Node + Web file reading/writing\n* [ ] File uploader module\n* [ ] Audio \u0026 video support\n* [ ] Office document integration\n* [ ] Caching and content hash APIs\n* [ ] WebSocket stream writer\n\n---\n\n## 📄 License\n\nMIT © 2025 — Maintained by the community.\n\n```\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondjs%2Fmedia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeyondjs%2Fmedia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondjs%2Fmedia/lists"}