This template is a complete TypeScript showcase for the rewritten TimeLens widget runtime. It exposes buttons for the current WidgetClient APIs, legacy channel APIs, consent, local API access, and Gateway-mediated network/media methods.
manifest.json: widget metadata and v4 runtime declarationindex.ts: TypeScript ESM widget entry and API showcasedist/index.js: compiled entry loaded by TimeLenstypes.d.ts: TypeScript declarations describing the widget context APIpackage.json: build scripts; runnpm install && npm run buildto compileindex.tstodist/index.jstsconfig.json: TypeScript compiler options
{
"manifest_version": "v4",
"widget_type": "sample_hello",
"name": "Sample Hello Widget",
"publisher": "TimeLens Example",
"entry": "dist/index.js",
"runtime": { "language": "typescript", "version": "5.0", "entry": "dist/index.js" },
"ui": { "model": "web-sandbox" },
"capabilities": [
"screen-time:read",
"todo:read",
"todo:write",
"browser:read",
"settings:write",
"local-api:call",
"active-window:subscribe"
]
}In v4, capability strings are runtime scopes. The top-level entry must match
runtime.entry. This example declares all implemented scopes because it
demonstrates every available API. Network and media calls are mediated by the
Gateway and are subject to public-target, MIME, timeout, and response-size policy.
npm install
npm run build- Build the package so
dist/index.jsexists. - Copy this folder to your local TimeLens app data widgets directory:
widgets/sample_hello/
- Start TimeLens.
- Open Widget Center → Add Widgets.
- Add
Sample Hello Widgetand open it.
For faster iteration, use the Widget Dev Harness (dev mode only):
- Open Widget Center → "Dev Harness".
- Select this template folder.
- Toggle capabilities and reload instantly.
- Keep
widget_typeunique across all installed widgets. - The entry file must be valid ESM and export
createWidget()ormount(). - Use
context.client.query(...)for new Gateway-mediated data access. - Use
context.channel.localApiCall({ method, path, scopes })only for the compatibility API. Client queries/stateexercises all query namespaces, browser activity, and state APIs.Todo write lifecycleadds, toggles, reorders, and deletes a temporary todo.Legacy read channelexercises the compatibility read methods.Focus/settings writesandLocal API callrequire their declared scopes.Test network/mediaexercises the implemented Gateway providers. Requests remain subject to permission, target policy, timeout, content-type, and response-size checks, so a denied result is expected for an unapproved or unsuitable URL.- See
docs/WIDGETS_DEV_GUIDE.mdfor the current runtime guide anddocs/WIDGET_SDK_v2_MIGRATION.mdfor v1/v2 migration.