@tristan2828/ui-foundation 4.134.0 → 4.135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/conventions/docs/reminders.md +18 -0
- package/package.json +1 -1
- package/vite/index.d.ts +17 -0
- package/vite/pwa.js +23 -0
|
@@ -54,6 +54,24 @@ there is no push at all, so `usePushPermission` says `needs-install` and
|
|
|
54
54
|
`AllowReminders` shows the steps. `pwa()`'s manifest (`display:
|
|
55
55
|
standalone`) is what makes the Home Screen app an app.
|
|
56
56
|
|
|
57
|
+
## Home-screen shortcuts
|
|
58
|
+
|
|
59
|
+
`pwa({ name, shortcuts: [{ name: 'Add To-Do', url: '/todo/add' }] })` writes
|
|
60
|
+
the manifest's `shortcuts`: actions on the installed icon that open the
|
|
61
|
+
app at a path. `url` is a path inside the app (it gets the Vite `base`);
|
|
62
|
+
`shortName` and a square `icon` PNG (192×192 or more) are optional. Left
|
|
63
|
+
out, the manifest is unchanged.
|
|
64
|
+
|
|
65
|
+
| Platform | What it does with them |
|
|
66
|
+
|---|---|
|
|
67
|
+
| Android (Chrome, installed app) | Long-press the icon: the shortcuts list above it, and can be dragged to the Home Screen. Most launchers show about four |
|
|
68
|
+
| Desktop Chrome and Edge | Right-click the installed app's icon (taskbar, dock or Start menu) |
|
|
69
|
+
| iPhone and iPad | Ignored: the Home Screen app's long-press menu has none from the manifest. Safari supports `shortcuts` only on macOS (since 17.4), per [firt.dev's iOS PWA compatibility notes](https://firt.dev/notes/pwa-ios/), updated October 2026. Give the action somewhere in the app too |
|
|
70
|
+
|
|
71
|
+
Treat a shortcut as a convenience, never the only way to an action. A
|
|
72
|
+
phone caches the manifest, so a changed list can take a reinstall or a day
|
|
73
|
+
to show.
|
|
74
|
+
|
|
57
75
|
## A reminder is the app's own row
|
|
58
76
|
|
|
59
77
|
The reference backend has a `reminders` table and the job that sends it;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.135.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/vite/index.d.ts
CHANGED
|
@@ -48,6 +48,23 @@ export type PwaOptions = {
|
|
|
48
48
|
* root). Replaces the generated ones everywhere.
|
|
49
49
|
*/
|
|
50
50
|
icon?: string
|
|
51
|
+
/**
|
|
52
|
+
* Home-screen shortcuts: actions offered when the installed icon is
|
|
53
|
+
* long-pressed (Android, Chrome and Edge on desktop). Left out, the manifest
|
|
54
|
+
* has none. iOS and iPadOS ignore them.
|
|
55
|
+
*/
|
|
56
|
+
shortcuts?: PwaShortcut[]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type PwaShortcut = {
|
|
60
|
+
/** The action's label, e.g. "Add To-Do". */
|
|
61
|
+
name: string
|
|
62
|
+
/** A shorter label where space is tight. */
|
|
63
|
+
shortName?: string
|
|
64
|
+
/** A path inside the app, starting with `/`, e.g. `/todo/add`. Prefixed with the base. */
|
|
65
|
+
url: string
|
|
66
|
+
/** A square PNG of at least 192×192 (path from the Vite root). Without one the OS uses the app's icon. */
|
|
67
|
+
icon?: string
|
|
51
68
|
}
|
|
52
69
|
|
|
53
70
|
/**
|
package/vite/pwa.js
CHANGED
|
@@ -188,6 +188,28 @@ export function pwaFiles(options, base = '/', root = process.cwd()) {
|
|
|
188
188
|
]
|
|
189
189
|
touchIcon = 'icons/apple-touch-icon.png'
|
|
190
190
|
}
|
|
191
|
+
const shortcuts = (options.shortcuts ?? []).map((shortcut, index) => {
|
|
192
|
+
const label = shortcut?.name?.trim()
|
|
193
|
+
const url = shortcut?.url?.trim()
|
|
194
|
+
if (!label) throw new Error(`pwa: shortcuts[${index}] needs a \`name\`.`)
|
|
195
|
+
if (!url?.startsWith('/') || url.startsWith('//')) {
|
|
196
|
+
throw new Error(`pwa: shortcuts[${index}].url must be a path inside the app, starting with "/" (got "${shortcut?.url}").`)
|
|
197
|
+
}
|
|
198
|
+
let icon
|
|
199
|
+
if (shortcut.icon) {
|
|
200
|
+
const own = path.resolve(root, shortcut.icon)
|
|
201
|
+
if (!own.endsWith('.png') || !fs.existsSync(own)) throw new Error(`pwa: shortcuts[${index}].icon must be a PNG file; ${own} isn't one.`)
|
|
202
|
+
const file = `icons/shortcut-${index}.png`
|
|
203
|
+
files.set(file, { type: 'image/png', source: fs.readFileSync(own) })
|
|
204
|
+
icon = [{ src: at(file), sizes: '192x192', type: 'image/png' }]
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
name: label,
|
|
208
|
+
...(shortcut.shortName?.trim() ? { short_name: shortcut.shortName.trim() } : {}),
|
|
209
|
+
url: `${base.replace(/\/$/, '')}${url}`,
|
|
210
|
+
...(icon ? { icons: icon } : {}),
|
|
211
|
+
}
|
|
212
|
+
})
|
|
191
213
|
const manifest = {
|
|
192
214
|
name,
|
|
193
215
|
short_name: shortName,
|
|
@@ -198,6 +220,7 @@ export function pwaFiles(options, base = '/', root = process.cwd()) {
|
|
|
198
220
|
theme_color: theme,
|
|
199
221
|
background_color: background,
|
|
200
222
|
icons,
|
|
223
|
+
...(shortcuts.length ? { shortcuts } : {}),
|
|
201
224
|
}
|
|
202
225
|
files.set('manifest.webmanifest', {
|
|
203
226
|
type: 'application/manifest+json',
|