{"action":"created","issue":{"url":"https://api.github.com/repos/dat-land/dat-desktop/issues/505","repository_url":"https://api.github.com/repos/dat-land/dat-desktop","labels_url":"https://api.github.com/repos/dat-land/dat-desktop/issues/505/labels{/name}","comments_url":"https://api.github.com/repos/dat-land/dat-desktop/issues/505/comments","events_url":"https://api.github.com/repos/dat-land/dat-desktop/issues/505/events","html_url":"https://github.com/dat-land/dat-desktop/issues/505","id":294685147,"number":505,"title":"Viewer plugin architecture","user":{"login":"juliangruber","id":10247,"avatar_url":"https://avatars2.githubusercontent.com/u/10247?v=4","gravatar_id":"","url":"https://api.github.com/users/juliangruber","html_url":"https://github.com/juliangruber","followers_url":"https://api.github.com/users/juliangruber/followers","following_url":"https://api.github.com/users/juliangruber/following{/other_user}","gists_url":"https://api.github.com/users/juliangruber/gists{/gist_id}","starred_url":"https://api.github.com/users/juliangruber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliangruber/subscriptions","organizations_url":"https://api.github.com/users/juliangruber/orgs","repos_url":"https://api.github.com/users/juliangruber/repos","events_url":"https://api.github.com/users/juliangruber/events{/privacy}","received_events_url":"https://api.github.com/users/juliangruber/received_events","type":"User","site_admin":false},"labels":[{"id":543567207,"url":"https://api.github.com/repos/dat-land/dat-desktop/labels/Priority:%20High","name":"Priority: High","color":"d93f0b","default":false},{"id":504878009,"url":"https://api.github.com/repos/dat-land/dat-desktop/labels/Type:%20Enhancement","name":"Type: Enhancement","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-06T09:22:01Z","updated_at":"2018-02-06T09:51:49Z","closed_at":null,"author_association":"MEMBER","body":"This is a proposal for an architecture that allows us and users to add Dat viewer plugins which let you view and preview a dat's file contents. The viewers should not require the whole file to exist on disk and instead seek inside the hyperdrive which means a file can be viewed before it has been completely downloaded. For this reason, a Viewer plugin is also sometimes referred to as a Preview. There will be viewers that ship with Dat Desktop, as well as the option to add more from the userland.\r\n\r\n## Security\r\n\r\nEach viewer lives in its own electron [&lt;webview&gt;](https://electronjs.org/docs/api/webview-tag), so is completely decoupled from the main process and only interfaces through an asynchronous API. Not having access to any native apis like the `fs` module, they shouldn't be able to behave harmfully, except potentially using up all CPU.\r\n\r\n## Formats\r\n\r\n- raw text\r\n- json\r\n- csv\r\n- source code\r\n- 3d map data\r\n- what else?\r\n- images\r\n\r\n## Plugin structure\r\n\r\n### plugin.zip\r\n\r\nAll files as listed below will be bundled into a `zip` archive and then imported through Dat Desktop's plugin panel. Another option for this is to use npm and simply point Dat Desktop to a npm/github path for installing the plugin.\r\n\r\n### index.js\r\n\r\nThe main JavaScript file, executed in a sandboxed renderer process. Therefore, no node module use is possible, and if multiple files need to be included, use a bundler like browserify or webpack.\r\n\r\nDat Desktop might expose an API like this to the plugin, for interfacing with the underlying data:\r\n\r\n```js\r\nwindow.seek(from, to, (err, buf) => { ... })\r\ndocument.body.appendChild(myElement)\r\n```\r\n\r\nAll data access will be _read only_. A plugin like a csv viewer might for example subscribe to its dom's `onscroll` event and fetch more data accordingly, while an image viewer will progressively load bit information in a different pattern.\r\n\r\n### package.json\r\n\r\nWhile most file formats map one file to one plugin instance, like csv for example, some formats will map a set of files or folders to a plugin instance, like some point cloud data formats. The plugin therefore needs to be able to register which files and how it wants to register itself, most likely through a `package.json` field.\r\n\r\nFor a javascript viewer:\r\n\r\n```json\r\n\"viewer\": {\r\n  \"extensions\": \"*.js*\"\r\n}\r\n```\r\n\r\nFor a point cloud viewer:\r\n\r\n```json\r\n\"viewer\": {\r\n  \"extensions\": \"*.pcd\",\r\n  \"group\": \"pc-data/*.pcd\"\r\n}\r\n```\r\n\r\nThe above might very likely change as we find out more about those formats. We can start with the single file formats now already though.\r\n\r\nIn case multiple plugins register for the same file format, we should prompt the user for which plugin to choose.\r\n\r\n### index.html\r\n\r\nAs dom can be inserted through JavaScript, for now we'll just provide a `document.body` with a `<main>` inside."},"comment":{"url":"https://api.github.com/repos/dat-land/dat-desktop/issues/comments/363369127","html_url":"https://github.com/dat-land/dat-desktop/issues/505#issuecomment-363369127","issue_url":"https://api.github.com/repos/dat-land/dat-desktop/issues/505","id":363369127,"user":{"login":"aks-","id":8316625,"avatar_url":"https://avatars0.githubusercontent.com/u/8316625?v=4","gravatar_id":"","url":"https://api.github.com/users/aks-","html_url":"https://github.com/aks-","followers_url":"https://api.github.com/users/aks-/followers","following_url":"https://api.github.com/users/aks-/following{/other_user}","gists_url":"https://api.github.com/users/aks-/gists{/gist_id}","starred_url":"https://api.github.com/users/aks-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aks-/subscriptions","organizations_url":"https://api.github.com/users/aks-/orgs","repos_url":"https://api.github.com/users/aks-/repos","events_url":"https://api.github.com/users/aks-/events{/privacy}","received_events_url":"https://api.github.com/users/aks-/received_events","type":"User","site_admin":false},"created_at":"2018-02-06T09:51:49Z","updated_at":"2018-02-06T09:51:49Z","author_association":"COLLABORATOR","body":"I like the idea of installing the plugin by pointing Dat Desktop to a npm/github path"}}
{"actor":{"display_login":"aks-"}}