mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-02 20:18:38 -05:00
A plug-in at API level 2 with the new `events` permission can name any of `selection.changed`, `document.opened`, `document.saved` and `layer.changed` in its manifest's `events` list. Its `vc_event` export is then called with a small JSON event after each change of that kind has finished, outside any undo step. Changes between two deliveries are one event. The desktop app delivers twice a frame, after the work that finished in the background and at the end of the frame after the canvas, panels and dialogs ran; control-channel requests run in the desktop app and are delivered by the frame. vectorcraft-cli and headless MCP deliver after each request. A plug-in installed after a change is not given it, and a change made after an install reaches the new plug-in at the next delivery. - A handler only reads. It may call ten commands that read (dataset.list, graphicStyle.list, guide.list, image.info, object.blend.info, swatch.list, symbol.list, text.getRange, transparency.info and variable.list); any other call fails before it runs with an error naming the event. After each call every document with its selection, current layer and undo history, the active document, the paint defaults, the active Appearance row and the preferences are put back, and a call that changed a document is refused. - A handler gets 5 M instructions and 200 ms, shared by the module's start function, `vc_alloc` and `vc_event`. A handler that fails 3 times in a row gets no more events until VectorCraft starts again. - An event raised while a handler runs waits for the next delivery. - Events carry the document number and counts; selected ids (at most 2,048) only with `doc.read`. No paths or file contents. - A save that finishes after its document closed is still reported. - A document opened or created since the last delivery is compared with its state when the command that added it ended, so the first change made to it is an event. - A waiting event is dropped for a plug-in that was removed, so the same module installed again is not given it. - The desktop app delivers the events of a script in the frame the script ends in. plugin.list and plugin.info report `events`, `eventsOff` and `lastEventError`. Docs: docs/plugins.md (Events), docs/mcp.md and one progress line in docs/target-app-parity.md. The new plug-in messages, the status lines for a failed handler and the permission's words in Install Plug-in... have rows in every complete catalog.