This guide explains how to build third-party JavaScript widgets for TimeLens v0.8.0 widget registry prototype.
- Local directory loading only (
manifest.json+ JS entry) - Runtime registry discovery from app data
widgetsdirectory - Render contract:
createWidget()ormount()export - Data channel (current): read-focused APIs
Not included yet:
- Remote marketplace
- Signature verification
- Cloud distribution
Each third-party widget lives in its own folder under the app data widgets directory.
widgets/
my-widget/
manifest.json
index.js
assets/
Minimal manifest example:
{
"widget_type": "sample_hello",
"name": "Sample Hello Widget",
"description": "Minimal third-party widget example",
"entry": "index.js",
"default_size": {
"width": 360,
"height": 240
},
"permissions": [
"screen-time:read",
"active-window:subscribe"
]
}widget_type: unique widget type identifier ([a-zA-Z0-9_-])name: display name in registryentry: entry JS file relative to manifest folder
descriptionicondefault_size.width/default_size.heightpermissions
TimeLens loads your entry as an ESM module.
Supported exports:
createWidget()returning an object withmount()and optionalunmount()- direct
mount()export with optionalunmount()export
export function createWidget() {
let root;
return {
mount(container, context) {
root = document.createElement("div");
root.textContent = `Hello from ${context.widgetType}`;
container.appendChild(root);
},
unmount() {
root?.remove();
root = null;
}
};
}mount(container, context) receives:
context.widgetIdcontext.widgetTypecontext.channel
Current channel methods:
getTodayAppTotals()getAppTotalsInRange(startDate, endDate)getCategoryTotalsInRange(startDate, endDate)onActiveWindowChanged(callback)
Manifest permissions are discoverable in registry metadata. In this milestone, permission strings are not fully enforced yet; they are designed for upcoming install-time authorization UI.
Recommended strings:
screen-time:readactive-window:subscribetodo:readtodo:writesettings:write
- Build or copy your widget folder to app data
widgetsdirectory. - Start TimeLens in dev mode.
- Open Widget Center and switch to Add Widgets.
- Find your third-party entry and click Add.
- Open created widget instance.
- Registry entry missing:
- check
manifest.jsonparse errors - verify
widget_typeformat - ensure
entryfile exists
- check
- Widget window opens but nothing renders:
- ensure module exports
createWidget()ormount() - check browser console for dynamic import errors
- ensure module exports
- Unknown widget type on create:
- registry load failed or duplicate
widget_type
- registry load failed or duplicate