unroll.help(): quick start and methods by group, help(group) and help(method); version 0.9.5
Browse files- AGENTS.md +1 -0
- CHANGELOG.md +5 -0
- api.json +18 -2
- lib/api.js +19 -0
- lib/apispec.js +1 -0
- tests/api.mjs +3 -0
- version.json +2 -2
AGENTS.md
CHANGED
|
@@ -27,6 +27,7 @@ await unroll.version(); // { version, date, sha, api }
|
|
| 27 |
| Task | Call |
|
| 28 |
| --- | --- |
|
| 29 |
| Unroll to a position | `setUnroll(0.5)` then `waitFor('settled')` |
|
|
|
|
| 30 |
| Animate | `play(true)`, `play(false)` |
|
| 31 |
| Switch layer | `setLayer('xray' \| 'ink' \| 'overlay')` |
|
| 32 |
| Close-up of a winding | `focus('w047', { view: 'overlay' })`; close with `focus(null)` |
|
|
|
|
| 27 |
| Task | Call |
|
| 28 |
| --- | --- |
|
| 29 |
| Unroll to a position | `setUnroll(0.5)` then `waitFor('settled')` |
|
| 30 |
+
| Help and schema | `help()`, `help('destroy')`, `help('setLayer')`, `schema()` |
|
| 31 |
| Animate | `play(true)`, `play(false)` |
|
| 32 |
| Switch layer | `setLayer('xray' \| 'ink' \| 'overlay')` |
|
| 33 |
| Close-up of a winding | `focus('w047', { view: 'overlay' })`; close with `focus(null)` |
|
CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ The project is in the 0.9.x pre-release series: bump the patch version for each
|
|
| 5 |
`node tools/stamp_version.mjs patch` before you commit, then add an entry here.
|
| 6 |
v1.0.0 will be cut later as a release. Version 0.9.0 was reconstructed from the git log.
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
## 0.9.4 (2026-10-16)
|
| 9 |
|
| 10 |
Release preparation, merged from the release branch work (the notes below were first written as v1.0.0;
|
|
|
|
| 5 |
`node tools/stamp_version.mjs patch` before you commit, then add an entry here.
|
| 6 |
v1.0.0 will be cut later as a release. Version 0.9.0 was reconstructed from the git log.
|
| 7 |
|
| 8 |
+
## 0.9.5 (2026-10-16)
|
| 9 |
+
|
| 10 |
+
- `unroll.help()`: a short guide with a quick start and the methods by group; `help('destroy')` or `help('setLayer')`
|
| 11 |
+
narrows it. Also in the postMessage bridge, `api.json` and AGENTS.md.
|
| 12 |
+
|
| 13 |
## 0.9.4 (2026-10-16)
|
| 14 |
|
| 15 |
Release preparation, merged from the release branch work (the notes below were first written as v1.0.0;
|
api.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
{
|
| 2 |
"name": "Unroll",
|
| 3 |
"app": {
|
| 4 |
-
"version": "0.9.
|
| 5 |
"date": "2026-10-16",
|
| 6 |
-
"sha": "
|
| 7 |
},
|
| 8 |
"apiVersion": "1.0.0",
|
| 9 |
"docs": {
|
|
@@ -90,6 +90,22 @@
|
|
| 90 |
"params": [],
|
| 91 |
"returns": "Promise<{ ok: true, ... } | { ok: false, error: string, code: string }>"
|
| 92 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
"schema": {
|
| 94 |
"group": "meta",
|
| 95 |
"summary": "This API: version, every method with its parameters, events, URL parameters and keyboard actions.",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "Unroll",
|
| 3 |
"app": {
|
| 4 |
+
"version": "0.9.5",
|
| 5 |
"date": "2026-10-16",
|
| 6 |
+
"sha": "cc6b6d8"
|
| 7 |
},
|
| 8 |
"apiVersion": "1.0.0",
|
| 9 |
"docs": {
|
|
|
|
| 90 |
"params": [],
|
| 91 |
"returns": "Promise<{ ok: true, ... } | { ok: false, error: string, code: string }>"
|
| 92 |
},
|
| 93 |
+
"help": {
|
| 94 |
+
"group": "meta",
|
| 95 |
+
"summary": "A short guide: how calls work, a quick start and the methods by group. help(\"destroy\") narrows to a group, help(\"setLayer\") to one method.",
|
| 96 |
+
"call": "window.unroll.help(topic?)",
|
| 97 |
+
"params": [
|
| 98 |
+
{
|
| 99 |
+
"name": "topic",
|
| 100 |
+
"type": [
|
| 101 |
+
"string"
|
| 102 |
+
],
|
| 103 |
+
"required": false,
|
| 104 |
+
"description": "A method or group name"
|
| 105 |
+
}
|
| 106 |
+
],
|
| 107 |
+
"returns": "Promise<{ ok: true, ... } | { ok: false, error: string, code: string }>"
|
| 108 |
+
},
|
| 109 |
"schema": {
|
| 110 |
"group": "meta",
|
| 111 |
"summary": "This API: version, every method with its parameters, events, URL parameters and keyboard actions.",
|
lib/api.js
CHANGED
|
@@ -35,6 +35,25 @@ export function installAPI(impl, { stateFn, onTick }) {
|
|
| 35 |
events: EVENTS, urlParams: URL_PARAMS, keys: KEYS,
|
| 36 |
conventions: 'Every method returns a Promise of { ok: true, ... } or { ok: false, error, code }. Nothing throws. Screen coordinates are CSS pixels; scene coordinates are millimetres. Add-ons register more groups with unroll.register(group, methods, specs); they appear here with extension: true.',
|
| 37 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
impl.on = (event, cb) => {
|
| 39 |
if (typeof cb !== 'function') throw new ApiError('on: callback must be a function.');
|
| 40 |
const id = nextId++; subs.set(id, { event, cb }); return { id };
|
|
|
|
| 35 |
events: EVENTS, urlParams: URL_PARAMS, keys: KEYS,
|
| 36 |
conventions: 'Every method returns a Promise of { ok: true, ... } or { ok: false, error, code }. Nothing throws. Screen coordinates are CSS pixels; scene coordinates are millimetres. Add-ons register more groups with unroll.register(group, methods, specs); they appear here with extension: true.',
|
| 37 |
});
|
| 38 |
+
// help(): a short guide for agents; help('setLayer') or help('destroy') narrows it to a method or a group
|
| 39 |
+
impl.help = async (topic) => {
|
| 40 |
+
const all = { ...METHODS, ...ext };
|
| 41 |
+
const fmtM = (k, m) => ({ method: k, group: m.group, summary: m.summary, params: (m.params || []).map((p) => `${p.name}${p.required === false ? '?' : ''}: ${p.type}${p.desc ? ` (${p.desc})` : ''}`), call: `unroll.${k}(${(m.params || []).map((p) => p.name).join(', ')})` });
|
| 42 |
+
if (topic !== undefined) {
|
| 43 |
+
if (typeof topic !== 'string') throw new ApiError('help: topic must be a method name (e.g. "setLayer") or a group (e.g. "destroy").');
|
| 44 |
+
if (all[topic]) return fmtM(topic, all[topic]);
|
| 45 |
+
const g = Object.entries(all).filter(([, m]) => m.group === topic);
|
| 46 |
+
if (g.length) return { group: topic, methods: g.map(([k, m]) => fmtM(k, m)) };
|
| 47 |
+
throw new ApiError(`help: no method or group "${topic}". Groups: ${[...new Set(Object.values(all).map((m) => m.group))].join(', ')}.`, 'not_found');
|
| 48 |
+
}
|
| 49 |
+
return {
|
| 50 |
+
about: 'window.unroll drives every control of the Unroll scroll viewer. Every call returns a Promise of { ok: true, ... } or { ok: false, error, code }; nothing throws.',
|
| 51 |
+
start: ['await unroll.waitFor("ready")', 'await unroll.getState()', 'await unroll.setUnroll(0.5)', 'await unroll.setLayer("overlay")', 'await unroll.screenshot()'],
|
| 52 |
+
groups: Object.fromEntries([...new Set(Object.values(all).map((m) => m.group))].map((g) => [g, Object.keys(all).filter((k) => all[k].group === g)])),
|
| 53 |
+
more: 'unroll.help("destroy") for a group, unroll.help("setLayer") for one method, unroll.schema() for everything as JSON. Docs: /AGENTS.md, /llms.txt, /api.json, /docs/EMBED.md.',
|
| 54 |
+
version: window.UNROLL_VERSION || null,
|
| 55 |
+
};
|
| 56 |
+
};
|
| 57 |
impl.on = (event, cb) => {
|
| 58 |
if (typeof cb !== 'function') throw new ApiError('on: callback must be a function.');
|
| 59 |
const id = nextId++; subs.set(id, { event, cb }); return { id };
|
lib/apispec.js
CHANGED
|
@@ -14,6 +14,7 @@ const DRAG = obj('options', 'Optional { dx, dy, steps, ms }: drag vector in CSS
|
|
| 14 |
// every method returns a Promise of { ok: true, ... } or { ok: false, error, code }
|
| 15 |
export const METHODS = {
|
| 16 |
version: { group: 'meta', summary: 'The app version from version.json: { version (semver), date, sha, api }. Also in api.json and Bench export bundles.', params: [] },
|
|
|
|
| 17 |
schema: { group: 'meta', summary: 'This API: version, every method with its parameters, events, URL parameters and keyboard actions.', params: [] },
|
| 18 |
getState: { group: 'meta', summary: 'The whole page state as JSON: scroll, unroll position, layer, winding, close-up, panels, Destroy mode, camera, readout and a text description of the view.', params: [] },
|
| 19 |
describe: { group: 'meta', summary: 'A plain-text description of what is on screen now (the same text screen readers get).', params: [] },
|
|
|
|
| 14 |
// every method returns a Promise of { ok: true, ... } or { ok: false, error, code }
|
| 15 |
export const METHODS = {
|
| 16 |
version: { group: 'meta', summary: 'The app version from version.json: { version (semver), date, sha, api }. Also in api.json and Bench export bundles.', params: [] },
|
| 17 |
+
help: { group: 'meta', summary: 'A short guide: how calls work, a quick start and the methods by group. help("destroy") narrows to a group, help("setLayer") to one method.', params: [str('topic', 'A method or group name', { required: false })] },
|
| 18 |
schema: { group: 'meta', summary: 'This API: version, every method with its parameters, events, URL parameters and keyboard actions.', params: [] },
|
| 19 |
getState: { group: 'meta', summary: 'The whole page state as JSON: scroll, unroll position, layer, winding, close-up, panels, Destroy mode, camera, readout and a text description of the view.', params: [] },
|
| 20 |
describe: { group: 'meta', summary: 'A plain-text description of what is on screen now (the same text screen readers get).', params: [] },
|
tests/api.mjs
CHANGED
|
@@ -136,6 +136,9 @@ const live = await U(() => document.getElementById('liveState').textContent);
|
|
| 136 |
check('aria-live readout is filled', async () => (live.length > 10), live);
|
| 137 |
const desc = await U(() => document.getElementById('viewDesc').textContent);
|
| 138 |
check('text alternative describes the view', async () => (/winding/i.test(desc)), desc);
|
|
|
|
|
|
|
|
|
|
| 139 |
// open your own from bytes and from a URL
|
| 140 |
r = await U(async () => { const ex = await window.unroll.open.example(); const p = window.unroll.open.fromFiles([{ name: ex.name, data: ex.base64 }]); return { ex: ex.ok, size: ex.bytes }; });
|
| 141 |
check('open.example gives a zip', async () => (r.ex && r.size > 1000), r);
|
|
|
|
| 136 |
check('aria-live readout is filled', async () => (live.length > 10), live);
|
| 137 |
const desc = await U(() => document.getElementById('viewDesc').textContent);
|
| 138 |
check('text alternative describes the view', async () => (/winding/i.test(desc)), desc);
|
| 139 |
+
r = await U(() => window.unroll.help()); check('help() gives a guide with groups', async () => (r.ok && r.groups && r.groups.destroy && r.start.length > 2), r);
|
| 140 |
+
r = await U(() => window.unroll.help('setLayer')); check('help(method) describes one method', async () => (r.ok && r.method === 'setLayer' && r.call), r);
|
| 141 |
+
r = await U(() => window.unroll.help('nope')); check('help(unknown) fails clearly', async () => (!r.ok && r.code === 'not_found'), r);
|
| 142 |
// open your own from bytes and from a URL
|
| 143 |
r = await U(async () => { const ex = await window.unroll.open.example(); const p = window.unroll.open.fromFiles([{ name: ex.name, data: ex.base64 }]); return { ex: ex.ok, size: ex.bytes }; });
|
| 144 |
check('open.example gives a zip', async () => (r.ex && r.size > 1000), r);
|
version.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
{
|
| 2 |
"name": "unroll",
|
| 3 |
-
"version": "0.9.
|
| 4 |
"date": "2026-10-16",
|
| 5 |
-
"sha": "
|
| 6 |
"license": "Apache-2.0",
|
| 7 |
"data_license": "CC-BY-NC-4.0",
|
| 8 |
"shaNote": "Short SHA of the commit this build was stamped on (its parent, since a commit cannot contain its own hash). Run node tools/stamp_version.mjs patch before each push.",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "unroll",
|
| 3 |
+
"version": "0.9.5",
|
| 4 |
"date": "2026-10-16",
|
| 5 |
+
"sha": "cc6b6d8",
|
| 6 |
"license": "Apache-2.0",
|
| 7 |
"data_license": "CC-BY-NC-4.0",
|
| 8 |
"shaNote": "Short SHA of the commit this build was stamped on (its parent, since a commit cannot contain its own hash). Run node tools/stamp_version.mjs patch before each push.",
|