@molecule/app-settings-panel-react 1.0.5 → 1.0.7

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.
Files changed (2) hide show
  1. package/README.md +108 -108
  2. package/package.json +11 -11
package/README.md CHANGED
@@ -3,15 +3,11 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-08-04T01:52:38.141Z
6
+ Generated: 2026-10-24T04:27:27.710Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-settings-panel-react
10
10
 
11
- > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
- > It is written to be read by coding agents as much as by people, and is generated from this
13
- > package's source — edit `src/index.ts` JSDoc, not this file.
14
-
15
11
  `@molecule/app-settings-panel-react` — composable, batteries-included
16
12
  settings panel.
17
13
 
@@ -36,6 +32,10 @@ through hooks:
36
32
  Apps compose via JSX children — pick sections, order them, and interleave
37
33
  custom sections.
38
34
 
35
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
36
+ > It is written to be read by coding agents as much as by people, and is generated from this
37
+ > package's source — edit `src/index.ts` JSDoc, not this file.
38
+
39
39
  ## Quick Start
40
40
 
41
41
  ```tsx
@@ -97,15 +97,17 @@ interface Device {
97
97
  }
98
98
  ```
99
99
 
100
- #### `PushToggleDevice`
100
+ #### `SettingsPanelContextValue`
101
101
 
102
- Device row slice returned by `GET /api/devices`.
102
+ Context published by `<SettingsContainer>` to its children.
103
+
104
+ The container owns the dismiss-the-panel handler; sub-components
105
+ that need to close after an action (logout, delete account, email
106
+ error) read it from context rather than threading the prop down.
103
107
 
104
108
  ```typescript
105
- interface PushToggleDevice {
106
- id: string
107
- isCurrent?: boolean
108
- hasPushSubscription?: boolean
109
+ interface SettingsPanelContextValue {
110
+ onClose: () => void
109
111
  }
110
112
  ```
111
113
 
@@ -120,28 +122,26 @@ interface PushToggleHttp {
120
122
  }
121
123
  ```
122
124
 
123
- #### `PushToggleToken`
125
+ #### `PushToggleDevice`
124
126
 
125
- Push token slice returned by `@molecule/app-push` `register()`.
127
+ Device row slice returned by `GET /api/devices`.
126
128
 
127
129
  ```typescript
128
- interface PushToggleToken {
129
- value: string
130
- platform: 'web' | 'ios' | 'android'
130
+ interface PushToggleDevice {
131
+ id: string
132
+ isCurrent?: boolean
133
+ hasPushSubscription?: boolean
131
134
  }
132
135
  ```
133
136
 
134
- #### `SettingsPanelContextValue`
135
-
136
- Context published by `<SettingsContainer>` to its children.
137
+ #### `PushToggleToken`
137
138
 
138
- The container owns the dismiss-the-panel handler; sub-components
139
- that need to close after an action (logout, delete account, email
140
- error) read it from context rather than threading the prop down.
139
+ Push token slice returned by `@molecule/app-push` `register()`.
141
140
 
142
141
  ```typescript
143
- interface SettingsPanelContextValue {
144
- onClose: () => void
142
+ interface PushToggleToken {
143
+ value: string
144
+ platform: 'web' | 'ios' | 'android'
145
145
  }
146
146
  ```
147
147
 
@@ -267,62 +267,6 @@ function DevicesSection({
267
267
  }): JSX.Element
268
268
  ```
269
269
 
270
- #### `disablePushOnCurrentDevice(deps)`
271
-
272
- Disables push: unsubscribes the browser (best-effort — a dev build without
273
- a service worker has nothing to unsubscribe) and ALWAYS clears the server
274
- state so no further pushes target this device.
275
-
276
- ```typescript
277
- function disablePushOnCurrentDevice(deps: {
278
- http: PushToggleHttp
279
- unregister: () => Promise<void>
280
- }): Promise<PushToggleResult>
281
- ```
282
-
283
- - `deps` — The http client + push action from `usePush()`.
284
- - `deps.http` — Authenticated http client (`useHttpClient()`).
285
- - `deps.unregister` — `usePush().unregister`.
286
-
287
- **Returns:** `{ ok: true }` or a typed failure (server state not cleared).
288
-
289
- #### `enablePushOnCurrentDevice(deps)`
290
-
291
- Runs the full enable chain: browser permission → runtime VAPID public key
292
- (`GET /api/devices/push/public-key`) → `register({ vapidPublicKey })` →
293
- persist the subscription on the current device row.
294
-
295
- Every failure is returned as a typed reason (never thrown) so the UI can
296
- show an honest, specific message instead of hanging or silently reverting.
297
-
298
- ```typescript
299
- function enablePushOnCurrentDevice(deps: {
300
- http: PushToggleHttp
301
- requestPermission: () => Promise<string>
302
- register: (options?: { vapidPublicKey?: string }) => Promise<PushToggleToken>
303
- }): Promise<PushToggleResult>
304
- ```
305
-
306
- - `deps` — The http client + push actions from `usePush()`.
307
- - `deps.http` — Authenticated http client (`useHttpClient()`).
308
- - `deps.requestPermission` — `usePush().requestPermission`.
309
- - `deps.register` — `usePush().register`.
310
-
311
- **Returns:** `{ ok: true }` or a typed failure.
312
-
313
- #### `findCurrentDevice(devices)`
314
-
315
- Picks the caller's own device row: the api flags the session device
316
- `isCurrent`; fall back to the first row for sessions predating the flag.
317
-
318
- ```typescript
319
- function findCurrentDevice(devices: PushToggleDevice[] | undefined): PushToggleDevice | undefined
320
- ```
321
-
322
- - `devices` — Rows from `GET /api/devices`.
323
-
324
- **Returns:** The current device row, or `undefined` when the user has none.
325
-
326
270
  #### `LogOutDeleteSection()`
327
271
 
328
272
  Bottom actions section — Log out + Delete account.
@@ -354,19 +298,6 @@ hanging the switch.
354
298
  function NotificationsSection(): JSX.Element
355
299
  ```
356
300
 
357
- #### `readCurrentDevicePushEnabled(http)`
358
-
359
- Reads whether push is currently enabled for THIS device (server truth:
360
- the current device row's `hasPushSubscription`).
361
-
362
- ```typescript
363
- function readCurrentDevicePushEnabled(http: PushToggleHttp): Promise<boolean>
364
- ```
365
-
366
- - `http` — Authenticated http client (`useHttpClient()`).
367
-
368
- **Returns:** `true` when the current device has a stored subscription.
369
-
370
301
  #### `SettingsContainer(props)`
371
302
 
372
303
  Outer settings-panel layout: padded vertical stack that hosts the
@@ -384,20 +315,6 @@ function SettingsContainer({
384
315
  }): ReactElement<unknown, string | JSXElementConstructor<any>>
385
316
  ```
386
317
 
387
- #### `subscriptionFromToken(token)`
388
-
389
- Converts an `@molecule/app-push` token into the device resource's
390
- `pushSubscription` shape (web PushSubscription JSON, FCM registration for
391
- Android, APNs registration for iOS).
392
-
393
- ```typescript
394
- function subscriptionFromToken(token: PushToggleToken): unknown
395
- ```
396
-
397
- - `token` — The push token returned by `register()`.
398
-
399
- **Returns:** The `pushSubscription` value to PATCH onto the device row.
400
-
401
318
  #### `ThisDeviceSection()`
402
319
 
403
320
  "This device" detail strip — OS, browser, online/offline.
@@ -435,6 +352,89 @@ Throws if used outside the container so component misuse is loud.
435
352
  function useSettingsPanelContext(): SettingsPanelContextValue
436
353
  ```
437
354
 
355
+ #### `findCurrentDevice(devices)`
356
+
357
+ Picks the caller's own device row: the api flags the session device
358
+ `isCurrent`; fall back to the first row for sessions predating the flag.
359
+
360
+ ```typescript
361
+ function findCurrentDevice(devices: PushToggleDevice[] | undefined): PushToggleDevice | undefined
362
+ ```
363
+
364
+ - `devices` — Rows from `GET /api/devices`.
365
+
366
+ **Returns:** The current device row, or `undefined` when the user has none.
367
+
368
+ #### `subscriptionFromToken(token)`
369
+
370
+ Converts an `@molecule/app-push` token into the device resource's
371
+ `pushSubscription` shape (web PushSubscription JSON, FCM registration for
372
+ Android, APNs registration for iOS).
373
+
374
+ ```typescript
375
+ function subscriptionFromToken(token: PushToggleToken): unknown
376
+ ```
377
+
378
+ - `token` — The push token returned by `register()`.
379
+
380
+ **Returns:** The `pushSubscription` value to PATCH onto the device row.
381
+
382
+ #### `enablePushOnCurrentDevice(deps)`
383
+
384
+ Runs the full enable chain: browser permission → runtime VAPID public key
385
+ (`GET /api/devices/push/public-key`) → `register({ vapidPublicKey })` →
386
+ persist the subscription on the current device row.
387
+
388
+ Every failure is returned as a typed reason (never thrown) so the UI can
389
+ show an honest, specific message instead of hanging or silently reverting.
390
+
391
+ ```typescript
392
+ function enablePushOnCurrentDevice(deps: {
393
+ http: PushToggleHttp
394
+ requestPermission: () => Promise<string>
395
+ register: (options?: { vapidPublicKey?: string }) => Promise<PushToggleToken>
396
+ }): Promise<PushToggleResult>
397
+ ```
398
+
399
+ - `deps` — The http client + push actions from `usePush()`.
400
+ - `deps.http` — Authenticated http client (`useHttpClient()`).
401
+ - `deps.requestPermission` — `usePush().requestPermission`.
402
+ - `deps.register` — `usePush().register`.
403
+
404
+ **Returns:** `{ ok: true }` or a typed failure.
405
+
406
+ #### `disablePushOnCurrentDevice(deps)`
407
+
408
+ Disables push: unsubscribes the browser (best-effort — a dev build without
409
+ a service worker has nothing to unsubscribe) and ALWAYS clears the server
410
+ state so no further pushes target this device.
411
+
412
+ ```typescript
413
+ function disablePushOnCurrentDevice(deps: {
414
+ http: PushToggleHttp
415
+ unregister: () => Promise<void>
416
+ }): Promise<PushToggleResult>
417
+ ```
418
+
419
+ - `deps` — The http client + push action from `usePush()`.
420
+ - `deps.http` — Authenticated http client (`useHttpClient()`).
421
+ - `deps.unregister` — `usePush().unregister`.
422
+
423
+ **Returns:** `{ ok: true }` or a typed failure (server state not cleared).
424
+
425
+ #### `readCurrentDevicePushEnabled(http)`
426
+
427
+ Reads whether push is currently enabled for THIS device (server truth:
428
+ the current device row's `hasPushSubscription`).
429
+
430
+ ```typescript
431
+ function readCurrentDevicePushEnabled(http: PushToggleHttp): Promise<boolean>
432
+ ```
433
+
434
+ - `http` — Authenticated http client (`useHttpClient()`).
435
+
436
+ **Returns:** `true` when the current device has a stored subscription.
437
+
438
438
  ### Constants
439
439
 
440
440
  #### `SettingsPanelContext`
@@ -451,7 +451,7 @@ const SettingsPanelContext: Context<SettingsPanelContextValue | null>
451
451
 
452
452
  Peer dependencies:
453
453
 
454
- - `@molecule/app-auth` ^1.0.1
454
+ - `@molecule/app-auth` ^1.0.1 || ^2.0.0
455
455
  - `@molecule/app-react` ^1.0.1
456
456
  - `@molecule/app-ui` ^1.0.1
457
457
  - `@molecule/app-ui-react` ^1.0.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-settings-panel-react",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Composable settings panel — a SettingsContainer + family of section sub-components (Account, Auth, Notifications, Billing, Devices, ThisDevice, LogOutDelete). Apps compose via JSX children, picking which sections to include and what order.",
5
5
  "homepage": "https://www.molecule.dev/packages/app-settings-panel-react",
6
6
  "type": "module",
@@ -34,19 +34,19 @@
34
34
  "directory": "packages/app/features/settings-panel-react"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "26.1.2",
37
+ "@types/node": "26.6.5",
38
38
  "typescript": "6.0.3",
39
- "vitest": "4.1.11",
40
- "@molecule/app-auth": "1.1.2",
41
- "@molecule/app-react": "1.6.0",
42
- "@molecule/app-ui": "1.3.4",
43
- "@molecule/app-ui-react": "1.3.0",
44
- "@types/react": "19.2.17",
45
- "react": "19.2.8",
46
- "react-router": "8.3.0"
39
+ "vitest": "4.1.12",
40
+ "@molecule/app-auth": "2.0.0",
41
+ "@molecule/app-react": "1.10.2",
42
+ "@molecule/app-ui": "1.3.8",
43
+ "@molecule/app-ui-react": "1.3.6",
44
+ "@types/react": "19.3.0",
45
+ "react": "19.3.1",
46
+ "react-router": "8.5.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@molecule/app-auth": "^1.0.1",
49
+ "@molecule/app-auth": "^1.0.1 || ^2.0.0",
50
50
  "@molecule/app-react": "^1.0.1",
51
51
  "@molecule/app-ui": "^1.0.1",
52
52
  "@molecule/app-ui-react": "^1.0.1",