Skip to content

Latest commit

 

History

History
85 lines (71 loc) · 2.81 KB

File metadata and controls

85 lines (71 loc) · 2.81 KB

MyHub Plugin API (v0)

Small and stabilizing. Breaking changes only on a major version bump. v0 supports view plugins only (more extension points later).

Anatomy

plugins/<plugin-id>/
  manifest.json   # metadata
  main.js         # ES module, default-exports the plugin object
  styles.css?     # optional (not auto-loaded yet)

manifest.json

field required notes
id unique id
name display name
version semver
type "view" (only type in v0)
entry JS file, usually main.js
icon emoji or text shown in the sidebar
author, description shown in the plugin list
minAppVersion minimum host version

main.js (default export)

export default {
  onLoad(ctx) {},          // optional, called once
  views: [{
    key: "my-view",
    label: "My View",
    icon: "✨",
    render(container, ctx) {},   // build your UI into container
    destroy() {}                 // optional cleanup
  }],
  onUnload() {}            // optional
};

ctx — the stable host API

// data (the relational store)
ctx.data.query({ tag?, status? })            // -> Item[]
ctx.data.getTags()                           // -> [{tag, count}]
ctx.data.getRelations()                      // -> [{from_item, to_item, rel}]
ctx.data.addTag(itemIds[], tag)
ctx.data.untag(itemId, tag)
ctx.data.setStatus(itemId, status)           // "" clears
ctx.data.addRelation(fromId, toId, rel)      // part_of | after | related | ...

// ui
ctx.ui.toast(message)
ctx.ui.refresh()                             // re-render the current view
ctx.ui.radial(event, frame)                  // open a radial menu (see below)

// actions (standard item operations — recommended)
ctx.actions.itemMenu(event, item)            // radial: status / tags / relations / open
ctx.actions.openItem(item)                   // open the item's folder in the OS

// libs
ctx.libs.d3 / ctx.libs.marked

Radial menu frame

{ title, items: [ { ic, label, onClick? , submenu?: frame | () => frame } ] }

Most plugins should just call ctx.actions.itemMenu(e, item) on click/contextmenu.

Item shape

{ "id": 1, "kind": "folder|file|note", "path": "C:\\...", "title": "", "tags": [""], "status": "進行中|…|null" }

Data model (the relational core)

  • items — anything you track (file, folder, or a pathless logical note).
  • tagskey(/value) attached to an item. A plain tag is key=tag; lifecycle is key=status.
  • relations — directed from → to with a rel (part_of, after, related…).

Views are just queries over this store + a way to draw them.

Security (v0)

Plugins run in the page. Only install plugins you trust. A vetted gallery / sandboxing is planned for a later version.