{"id":15314973,"url":"https://github.com/himself65/rich-data","last_synced_at":"2025-06-12T19:33:01.230Z","repository":{"id":101156501,"uuid":"584591201","full_name":"himself65/rich-data","owner":"himself65","description":"Data Viewer","archived":false,"fork":false,"pushed_at":"2023-10-17T01:37:03.000Z","size":4404,"stargazers_count":146,"open_issues_count":5,"forks_count":11,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T01:42:11.951Z","etag":null,"topics":["react","typescript"],"latest_commit_sha":null,"homepage":"https://rich-data.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/himself65.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-01-03T02:12:46.000Z","updated_at":"2025-01-05T12:14:32.000Z","dependencies_parsed_at":"2023-10-17T07:11:50.677Z","dependency_job_id":null,"html_url":"https://github.com/himself65/rich-data","commit_stats":null,"previous_names":["himself65/data-viewer"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/himself65%2Frich-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/himself65%2Frich-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/himself65%2Frich-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/himself65%2Frich-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/himself65","download_url":"https://codeload.github.com/himself65/rich-data/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235039185,"owners_count":18926301,"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":["react","typescript"],"created_at":"2024-10-01T08:48:22.609Z","updated_at":"2025-01-22T00:13:57.722Z","avatar_url":"https://github.com/himself65.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rich Data\n\n\u003e v3 version is heavily under development. Please use v2 as the current stable version.\n\n[![npm version](https://badgen.net/npm/v/@rich-data/viewer/latest)](https://www.npmjs.com/package/@rich-data/viewer)\n[![npm version](https://badgen.net/npm/v/@rich-data/viewer/nightly)](https://www.npmjs.com/package/@rich-data/viewer)\n[![minified size](https://badgen.net/bundlephobia/minzip/@rich-data/viewer)](https://bundlephobia.com/package/@rich-data/viewer@nightly)\n\n\u003e Rich Data provides a powerful and flexible way to display \"raw\" data in your React UI.\n\n- Minimal core (3Kb), full featured (20Kb)\n- Rich data structure preview support (object, JSON, JSX, `Y.Doc`...)\n- Supports React 18 Suspense\n- Offers a \"headless UI\"\n- Customizable UI / Logic\n- 100% Strongly typed\n\n## Demos and Examples\n\nSee the [rich-data.dev website](https://rich-data.dev/) for running demos and code examples.\n\n## Core Concepts\n\n### Viewer\n\nThe `Viewer` component is the core of Rich Data. \nIt is a React component that can render any data structure you provide.\n\n```tsx\nconst {\n  Viewer,\n  useContext,\n  Provider,\n} = createViewerHook({\n  plugins: [\n    // ...\n  ]\n})\n```\n\n### Plugin\n\nPlugin is the basic unit of Rich Data that connects the Viewer to your data structure, applying UI and logic. \n\nYou can inject arbitrary functionality into the Viewer by using `middleware`.\n  \n```tsx\nconst TestPlugin = defineMiddleware({\n  id: 'my-plugin',\n  middleware: (_store) =\u003e {\n    return {\n      ping: () =\u003e {\n        console.log('ping')\n      }\n    }\n  }\n})\n\nconst data = {/* your data here */}\n\nconst Component = () =\u003e {\n  const context = useContext()\n\n  return (\n    \u003c\u003e\n      \u003cbutton onClick={() =\u003e context.ping()}\u003e\n        Ping\n      \u003c/button\u003e\n      \u003cViewer\n        data={data}\n      /\u003e\n    \u003c/\u003e\n  )\n}\n\nconst App = () =\u003e {\n  return (\n    \u003cProvider\u003e\n      \u003cComponent /\u003e\n    \u003c/Provider\u003e\n  )\n}\n```\n\nOr you can render your own data structure as you like,\nby using a `defineBlock` helper function.\n\n```tsx\nconst MyImageBlock = defineBlock(\n  'my_image',\n  (value): value is string =\u003e value.startsWith('http'),\n  function MyImage ({ value }) {\n    const { data } = useSWR(value, {\n      fetcher: url =\u003e fetch(url).then(res =\u003e res.blob()),\n      suspense: true\n    })\n    const url = data ? URL.createObjectURL(data) : ''\n    return (\n      \u003cimg alt={value} height={50} width={50} src={url}/\u003e\n    )\n  }\n)\n```\n\n## Ecosystem\n\nRich Data provides a number of builtin plugins.\n\n### JSON\n\n```tsx\nimport { createJsonPlugins } from '@rich-data/json-plugin'\n\nconst {\n  Viewer,\n  useContext,\n  Provider,\n} = createViewerHook({\n  plugins: [\n    ...createJsonPlugins()\n  ]\n})\n```\n\n### JSX (🚧)\n\n### `Y.Doc` (🚧)\n\n## LICENSE\n\nThe MPL 2.0 License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhimself65%2Frich-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhimself65%2Frich-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhimself65%2Frich-data/lists"}