Add the versioned plugin SDK package and its release script
The new package packages/plugin-sdk (@runestone/plugin-sdk) is the one source of the public plugin types. It contains PluginApi and its members, the manifest type, API_VERSION, and feature checks (hasFeature, requireFeature, requireFeatures, missingFeatures). It also contains the action icons and the tooltip helper as DOM functions, because RuneStone has no API for them. Menus stay host-drawn through api.ui.showActionMenu, so the SDK contains only the menu types. The SDK uses the Apache License 2.0. The host imports the SDK with relative paths in src/lib/plugins/sdk.ts, src/lib/ui/actionIcons.ts, and src/lib/ui/tooltip.ts. The completion, Git, background, and contribution contract files export the SDK types. The menu files keep their types, because the Terminal plugin keeps copies of them. A unit test makes sure that those types and the SDK types are the same. The menu inventory now scans the SDK source. pnpm sdk:build compiles the SDK to dist/. pnpm release:sdk --version <v> builds it, then commits and tags v<v> in a local clone of the public repository. It never pushes, and it prints the push commands. It stops before a change in these conditions: - The clone is missing, has changes, or is not on a branch. - The tag exists, or the version is not greater than the current version. - The package has no LICENSE file, or the SDK source has changes that are not committed. A failed attempt restores the version and the clone. pnpm check type checks the SDK and the example plugin. The example plugin now has JSDoc types from the SDK. pnpm test covers the feature checks, the host and SDK parity, and the release script with temporary Git repositories. The plugin development, release, development, and completion guides describe the SDK.
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
// The action icons of RuneStone. Menus, commands, and plugin controls use the same artwork.
|
||||
// Stroke icons share the same 24px grid and weight as the host icon buttons.
|
||||
// The host styles the `action-icon` class: size, stroke, and color. Outside RuneStone, add your own style.
|
||||
export const actionIcons = {
|
||||
play: '<path d="m7 4 14 8-14 8Z"/>',
|
||||
pause: '<path d="M7 4v16M17 4v16"/>',
|
||||
'skip-forward': '<path d="m4 4 12 8-12 8ZM20 4v16"/>',
|
||||
eye: '<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/>',
|
||||
'eye-off': '<path d="m3 3 18 18M10.6 5.1 12 5c6.5 0 10 7 10 7a18 18 0 0 1-3.1 3.8M6.2 6.2A21 21 0 0 0 2 12s3.5 7 10 7a13 13 0 0 0 5.8-1.4M9.9 9.9a3 3 0 0 0 4.2 4.2"/>',
|
||||
image: '<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8" cy="8" r="1.5"/><path d="m21 15-5-5L5 21"/>',
|
||||
settings: '<path d="M4 7h16M4 17h16"/><circle cx="9" cy="7" r="3"/><circle cx="15" cy="17" r="3"/>',
|
||||
archive: '<path d="M4 8v12h16V8M3 3h18v5H3zM9 12h6"/>',
|
||||
save: '<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><path d="M17 21v-8H7v8M7 3v5h8"/>',
|
||||
refresh: '<path d="M20 7v5h-5M4 17v-5h5M6 7a7 7 0 0 1 12-1l2 3M4 15l2 3a7 7 0 0 0 12-1"/>',
|
||||
'arrow-left': '<path d="M20 12H4m6-6-6 6 6 6"/>',
|
||||
'arrow-right': '<path d="M4 12h16m-6-6 6 6-6 6"/>',
|
||||
terminal: '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="m6 8 4 4-4 4m6 0h6"/>',
|
||||
undo: '<path d="M3 10h11a7 7 0 0 1 0 14" transform="translate(0 -4)"/><path d="m7 2-4 4 4 4"/>',
|
||||
redo: '<path d="M21 6H10a7 7 0 0 0 0 14"/><path d="m17 2 4 4-4 4"/>',
|
||||
git: '<circle cx="7" cy="5" r="2"/><circle cx="7" cy="19" r="2"/><circle cx="17" cy="6" r="2"/><path d="M7 7v10m0-5h4a6 6 0 0 0 6-6"/>',
|
||||
globe: '<circle cx="12" cy="12" r="9"/><ellipse cx="12" cy="12" rx="4" ry="9"/><path d="M3 12h18"/>',
|
||||
puzzle: '<path d="M9 3H4v6a3 3 0 1 1 0 6v5h6a3 3 0 1 1 6 0h4v-6a3 3 0 1 0 0-6V3h-5a3 3 0 1 1-6 0Z"/>',
|
||||
'split-right': '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M12 4v16m3-11 3 3-3 3"/>',
|
||||
'split-down': '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 12h18m-12 3 3 3 3-3"/>',
|
||||
kanban: '<rect x="3" y="4" width="5" height="16" rx="1"/><rect x="10" y="4" width="5" height="11" rx="1"/><rect x="17" y="4" width="4" height="7" rx="1"/>',
|
||||
bookmark: '<path d="M6 4h12v16l-6-3-6 3z"/>',
|
||||
'file-plus': '<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6M12 18v-6M9 15h6"/>',
|
||||
'folder-plus': '<path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.7-.9L9.2 3.9A2 2 0 0 0 7.5 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2zM12 10v6M9 13h6"/>',
|
||||
|
||||
pin: '<path d="m16 3 5 5-4 1-3 3 1 4-2 2-7-7 2-2 4 1 3-3ZM8 16l-5 5"/>',
|
||||
book: '<path d="M12 6v15M3 3h5a4 4 0 0 1 4 3 4 4 0 0 1 4-3h5v15h-5a4 4 0 0 0-4 3 4 4 0 0 0-4-3H3Z"/>',
|
||||
folder: '<path d="M3 7V4h6l3 3h9v13H3Z"/>',
|
||||
rename: '<path d="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"/>',
|
||||
'zoom-in': '<circle cx="10" cy="10" r="7"/><path d="m15 15 6 6M7 10h6M10 7v6"/>',
|
||||
'zoom-out': '<circle cx="10" cy="10" r="7"/><path d="m15 15 6 6M7 10h6"/>',
|
||||
close: '<path d="m6 6 12 12M6 18 18 6"/>',
|
||||
swap: '<path d="M3 7h18m-4-4 4 4-4 4M21 17H3m4-4-4 4 4 4"/>',
|
||||
bullet: '<path d="M9 5h12M9 12h12M9 19h12"/><circle cx="3" cy="5" r="1"/><circle cx="3" cy="12" r="1"/><circle cx="3" cy="19" r="1"/>',
|
||||
number: '<path d="M10 5h11M10 12h11M10 19h11M3 3h2v6M3 9h4M3 14c4-3 5 1 2 3l-2 3h4"/>',
|
||||
task: '<path d="M20 12v8H4V4h10M9 10l4 4 8-11"/>',
|
||||
heading: '<path d="M5 4v16M19 4v16M5 12h14"/>',
|
||||
quote: '<path d="M3 4h7v9c0 4-2 6-6 7v-3c2-1 3-2 3-4H3ZM14 4h7v9c0 4-2 6-6 7v-3c2-1 3-2 3-4h-4Z"/>',
|
||||
table: '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M3 15h18M9 3v18M15 3v18"/>',
|
||||
rule: '<path d="M4 12h16"/>',
|
||||
footnote: '<path d="M4 4h9v16H4ZM7 8h3M7 12h3M16 4l2-1v6M16 9h4"/>',
|
||||
cut: '<circle cx="6" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="m8 8 12 12M8 16 20 4"/>',
|
||||
copy: '<rect x="8" y="8" width="12" height="13" rx="2"/><path d="M16 8V3H3v13h5"/>',
|
||||
paste: '<rect x="5" y="5" width="14" height="16" rx="2"/><rect x="9" y="2" width="6" height="5" rx="1"/><path d="m9 14 2 2 4-4"/>',
|
||||
'paste-text': '<rect x="5" y="5" width="14" height="16" rx="2"/><path d="M9 5V2h6v3M8 11h8M12 11v7"/>',
|
||||
format: '<path d="m14 3 7 7-10 10H4v-7ZM11 6l7 7M3 21h18"/>',
|
||||
bold: '<path d="M6 4h7a4 4 0 0 1 0 8H6zm0 8h8a4 4 0 0 1 0 8H6z"/>',
|
||||
italic: '<path d="M10 4h10M4 20h10M15 4 9 20"/>',
|
||||
strike: '<path d="M17 5c-2-3-10-3-10 2 0 2 2 3 5 4M7 19c3 3 10 2 10-2 0-2-2-3-5-4M3 12h18"/>',
|
||||
highlight: '<path d="m15 3 6 6-9 9-6-6ZM6 12l-3 6 3 3 6-3M3 21h12"/>',
|
||||
code: '<path d="m7 6-5 6 5 6m10-12 5 6-5 6M14 3l-4 18"/>',
|
||||
math: '<path d="M19 4H5l7 8-7 8h14"/>',
|
||||
comment: '<circle cx="6" cy="6" r="3"/><circle cx="18" cy="18" r="3"/><path d="M4 20 20 4"/>',
|
||||
clear: '<path d="m14 3 7 7-11 11H6l-5-5ZM7 10l7 7M13 21h9"/>',
|
||||
left: '<path d="M3 5h18M3 10h12M3 15h18M3 20h12"/>',
|
||||
center: '<path d="M3 5h18M6 10h12M3 15h18M6 20h12"/>',
|
||||
right: '<path d="M3 5h18M9 10h12M3 15h18M9 20h12"/>',
|
||||
row: '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M3 15h18M9 3v18M15 3v18"/><path d="M4 10h16v4H4Z" fill="currentColor" opacity=".25"/>',
|
||||
column: '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M3 15h18M9 3v18M15 3v18"/><path d="M10 4h4v16h-4Z" fill="currentColor" opacity=".25"/>',
|
||||
'row-before': '<rect x="3" y="10" width="18" height="11" rx="2"/><path d="M3 15h18M12 2v6M9 5h6"/>',
|
||||
'row-after': '<rect x="3" y="3" width="18" height="11" rx="2"/><path d="M3 8h18M12 16v6M9 19h6"/>',
|
||||
'column-before': '<rect x="10" y="3" width="11" height="18" rx="2"/><path d="M15 3v18M2 12h6M5 9v6"/>',
|
||||
'column-after': '<rect x="3" y="3" width="11" height="18" rx="2"/><path d="M8 3v18M16 12h6M19 9v6"/>',
|
||||
up: '<path d="M12 21V3m-7 7 7-7 7 7"/>',
|
||||
down: '<path d="M12 3v18m-7-7 7 7 7-7"/>',
|
||||
'move-left': '<path d="M21 12H3m7-7-7 7 7 7"/>',
|
||||
'move-right': '<path d="M3 12h18m-7-7 7 7-7 7"/>',
|
||||
trash: '<path d="M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7M14 10v7"/>',
|
||||
'sort-asc': '<path d="M5 3v18m-3-3 3 3 3-3M12 4h4M12 9h6M12 14h8M12 19h10"/>',
|
||||
'sort-desc': '<path d="M5 3v18m-3-3 3 3 3-3M12 4h10M12 9h8M12 14h6M12 19h4"/>',
|
||||
link: '<path d="m10 13 4-4M8 16l-2 2a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0m2 1 2-2a4 4 0 0 1 6 6l-5 5a4 4 0 0 1-6 0" transform="translate(1 0)"/>',
|
||||
external: '<path d="M14 3h7v7M10 14 21 3M10 5H4v16h16v-7"/>',
|
||||
search: '<circle cx="10" cy="10" r="7"/><path d="m15 15 6 6"/>',
|
||||
filter: '<path d="M3 4h18l-7 8v7l-4 2v-9Z"/>',
|
||||
extract: '<path d="M11 4H4v16h16v-7M14 3h7v7M11 13 21 3"/><path d="M7 8h2M7 12h2M7 16h7"/>',
|
||||
select: '<path d="M8 3H3v5M16 3h5v5M21 16v5h-5M8 21H3v-5M3 11v2M21 11v2M11 3h2M11 21h2"/>',
|
||||
paragraph: '<path d="M13 21V3h-3a5 5 0 0 0 0 10h3M18 3v18M10 3h12"/>',
|
||||
insert: '<path d="M3 5h18M3 11h8M3 17h8M17 11v10M12 16h10"/>',
|
||||
chevron: '<path d="m9 5 7 7-7 7"/>',
|
||||
plus: '<path d="M12 5v14M5 12h14"/>',
|
||||
grip: '<circle cx="8" cy="5" r="1"/><circle cx="16" cy="5" r="1"/><circle cx="8" cy="12" r="1"/><circle cx="16" cy="12" r="1"/><circle cx="8" cy="19" r="1"/><circle cx="16" cy="19" r="1"/>',
|
||||
} as const;
|
||||
export type ActionIcon = keyof typeof actionIcons;
|
||||
|
||||
/** Makes a new SVG element for an action icon. The element has `aria-hidden`, so give its control an accessible name. */
|
||||
export function actionIcon(name: ActionIcon): SVGSVGElement {
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
svg.setAttribute("viewBox", "0 0 24 24"); svg.setAttribute("aria-hidden", "true");
|
||||
svg.classList.add("action-icon"); svg.innerHTML = actionIcons[name];
|
||||
return svg;
|
||||
}
|
||||
Reference in New Issue
Block a user