@molecule/app-svelte 1.0.5 → 2.0.1
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/README.md +114 -35
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ 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-10-
|
|
6
|
+
Generated: 2026-10-26T04:14:40.834Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-svelte
|
|
@@ -248,9 +248,12 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
|
|
|
248
248
|
confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
|
|
249
249
|
/**
|
|
250
250
|
* Updates the current user's profile.
|
|
251
|
-
* Returns the saved
|
|
252
|
-
*
|
|
253
|
-
*
|
|
251
|
+
* Returns the saved profile: the answer applied onto the signed-in user field
|
|
252
|
+
* by field, with or without an `id` — a field it carries replaces the value
|
|
253
|
+
* (`null` clears it), one it omits or leaves `undefined` is kept, so a field
|
|
254
|
+
* cleared by omission must arrive as `null`. A non-object answer is returned
|
|
255
|
+
* as it came. An answer for a replaced or ended session leaves the current one
|
|
256
|
+
* untouched.
|
|
254
257
|
*/
|
|
255
258
|
updateProfile(data: Partial<T>): Promise<T>;
|
|
256
259
|
/**
|
|
@@ -306,9 +309,6 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
|
|
|
306
309
|
* Resolves when the session restore started by `initialize()` has settled — the point
|
|
307
310
|
* after which the client knows whether this visitor is signed in.
|
|
308
311
|
*
|
|
309
|
-
* Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
|
|
310
|
-
* called, and after it has finished. A restore that failed resolves too (it settled the
|
|
311
|
-
* question), so an HTTP client can await this before every request without risking one
|
|
312
312
|
// … truncated — the full declaration is in node_modules/@molecule/app-svelte/dist
|
|
313
313
|
```
|
|
314
314
|
|
|
@@ -516,12 +516,50 @@ interface HttpClient {
|
|
|
516
516
|
addErrorInterceptor(interceptor: ErrorInterceptor): () => void
|
|
517
517
|
/**
|
|
518
518
|
* Sets the authorization token.
|
|
519
|
+
*
|
|
520
|
+
* A static token: every request carries it until the next `setAuthToken` call. A client
|
|
521
|
+
* that has a {@link HttpClient.setAuthTokenResolver | resolver} (registered through
|
|
522
|
+
* `@molecule/app-http`'s `setAuthTokenSource`) ignores this value when it assembles a
|
|
523
|
+
* request — the resolver IS the session, and reading it per request is what keeps a
|
|
524
|
+
* session adopted without an auth event from sending the previous account's bearer. Once
|
|
525
|
+
* the resolver is removed, the static token is sent again.
|
|
519
526
|
*/
|
|
520
527
|
setAuthToken(token: string | null): void
|
|
521
528
|
/**
|
|
522
|
-
* Returns the
|
|
529
|
+
* Returns the token the client applies to its next request: the resolver's answer when one
|
|
530
|
+
* is registered, else the static token from `setAuthToken`.
|
|
523
531
|
*/
|
|
524
532
|
getAuthToken(): string | null
|
|
533
|
+
/**
|
|
534
|
+
* Registers the LIVE token resolver every request of this client reads, or clears it with
|
|
535
|
+
* `null`.
|
|
536
|
+
*
|
|
537
|
+
* `@molecule/app-http`'s `setAuthTokenSource()` calls this on every client it bonds, and the
|
|
538
|
+
* client MUST consult the resolver again each time it assembles a request (and report it from
|
|
539
|
+
* `getAuthToken()`). A session can change with no auth event and no observable state change —
|
|
540
|
+
* `authClient.setSession()` with the same profile data, or the OAuth callback's
|
|
541
|
+
* `setAccessToken()` — so a token pushed only at bond time or on `login`/`logout` events
|
|
542
|
+
* leaves every later request carrying the PREVIOUS session's bearer while the UI shows the
|
|
543
|
+
* new one.
|
|
544
|
+
*
|
|
545
|
+
* The resolved token takes the static token's place, with the same precedence: an
|
|
546
|
+
* `Authorization` header passed per request or in the client's default headers wins over it
|
|
547
|
+
* exactly where it won over a static token in this transport.
|
|
548
|
+
*
|
|
549
|
+
* A resolver that returns `null` (or `undefined`) means "this session has no body token": the
|
|
550
|
+
* request carries no `Authorization` header of the client's own. A cookie-session API issues
|
|
551
|
+
* no bearer, and the server prefers the header over the fresh cookie, so a kept bearer
|
|
552
|
+
* authenticates as the prior — possibly deleted — session.
|
|
553
|
+
*
|
|
554
|
+
* Optional, so an implementation written against the previous interface still conforms.
|
|
555
|
+
* `setAuthTokenSource()` follows such a client through a request interceptor instead, pushing
|
|
556
|
+
* the source with `setAuthToken` before each request: that request carries the change only
|
|
557
|
+
* when the transport applies its token after running its interceptors, so a transport that
|
|
558
|
+
* applies it earlier sends a session adopted mid-page from the following request on.
|
|
559
|
+
*
|
|
560
|
+
* @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
|
|
561
|
+
*/
|
|
562
|
+
setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
|
|
525
563
|
/**
|
|
526
564
|
* Registers a handler for authentication errors (401).
|
|
527
565
|
*
|
|
@@ -662,6 +700,27 @@ interface I18nProvider {
|
|
|
662
700
|
* @returns An unsubscribe function.
|
|
663
701
|
*/
|
|
664
702
|
onLocaleChange(listener: (locale: string) => void): () => void
|
|
703
|
+
/**
|
|
704
|
+
* Gets a counter that advances for every change `onLocaleChange` announces:
|
|
705
|
+
* a locale switch, a locale-list change, or translations added for a locale
|
|
706
|
+
* `t()` reads (the active locale and the locales it falls back to — English
|
|
707
|
+
* for `createSimpleI18nProvider`). It does NOT advance for a re-registration
|
|
708
|
+
* that leaves every rendered string identical.
|
|
709
|
+
*
|
|
710
|
+
* **Optional — read it only when present.** A consumer that observes the
|
|
711
|
+
* provider through `useSyncExternalStore` (the React hooks do) compares this
|
|
712
|
+
* value across renders, so it also sees a change that happened before its
|
|
713
|
+
* listener existed: a notification fired from a child's or an earlier
|
|
714
|
+
* sibling's layout effect, or while React kept the tree hidden with its
|
|
715
|
+
* effects unmounted. Providers written before this method existed keep the
|
|
716
|
+
* listener-only behaviour; consumers must fall back to counting
|
|
717
|
+
* notifications.
|
|
718
|
+
*
|
|
719
|
+
* Reads must be side-effect free, and the value must never decrease.
|
|
720
|
+
*
|
|
721
|
+
* @returns The provider's current revision.
|
|
722
|
+
*/
|
|
723
|
+
getRevision?(): number
|
|
665
724
|
/**
|
|
666
725
|
* Gets the text direction for the current locale.
|
|
667
726
|
*
|
|
@@ -1313,7 +1372,7 @@ function setStateContext(provider: StateProvider): void
|
|
|
1313
1372
|
Sets the auth context.
|
|
1314
1373
|
|
|
1315
1374
|
```typescript
|
|
1316
|
-
function setAuthContext(client: AuthClient<T
|
|
1375
|
+
function setAuthContext<T>(client: AuthClient<T>): void
|
|
1317
1376
|
```
|
|
1318
1377
|
|
|
1319
1378
|
- `client` — The auth client to store in Svelte context.
|
|
@@ -1393,7 +1452,10 @@ function getStateProvider(): StateProvider
|
|
|
1393
1452
|
Gets the auth client from Svelte context.
|
|
1394
1453
|
|
|
1395
1454
|
```typescript
|
|
1396
|
-
function getAuthClient
|
|
1455
|
+
function getAuthClient<
|
|
1456
|
+
T = unknown,
|
|
1457
|
+
TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
|
|
1458
|
+
>(): AuthClient<T, TRegister>
|
|
1397
1459
|
```
|
|
1398
1460
|
|
|
1399
1461
|
**Returns:** The auth client instance.
|
|
@@ -1463,7 +1525,7 @@ function getLoggerProvider(): LoggerProvider
|
|
|
1463
1525
|
Creates a writable store with async-capable setState and extendState.
|
|
1464
1526
|
|
|
1465
1527
|
```typescript
|
|
1466
|
-
function createAsyncState(initialValue: T): AsyncStateStore<T>
|
|
1528
|
+
function createAsyncState<T>(initialValue: T): AsyncStateStore<T>
|
|
1467
1529
|
```
|
|
1468
1530
|
|
|
1469
1531
|
- `initialValue` — The initial state value
|
|
@@ -1475,7 +1537,12 @@ function createAsyncState(initialValue: T): AsyncStateStore<T>
|
|
|
1475
1537
|
Create auth stores from the auth client in context.
|
|
1476
1538
|
|
|
1477
1539
|
```typescript
|
|
1478
|
-
function createAuthStores
|
|
1540
|
+
function createAuthStores<
|
|
1541
|
+
T = unknown,
|
|
1542
|
+
TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
|
|
1543
|
+
>(): AuthStores<T, TRegister> & {
|
|
1544
|
+
error: Readable<string | null>
|
|
1545
|
+
}
|
|
1479
1546
|
```
|
|
1480
1547
|
|
|
1481
1548
|
**Returns:** Auth stores and actions
|
|
@@ -1487,7 +1554,10 @@ Create auth stores from a specific auth client.
|
|
|
1487
1554
|
Use this when you don't want to use context.
|
|
1488
1555
|
|
|
1489
1556
|
```typescript
|
|
1490
|
-
function createAuthStoresFromClient
|
|
1557
|
+
function createAuthStoresFromClient<
|
|
1558
|
+
T = unknown,
|
|
1559
|
+
TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
|
|
1560
|
+
>(client: AuthClient<T, TRegister>): AuthStores<T, TRegister>
|
|
1491
1561
|
```
|
|
1492
1562
|
|
|
1493
1563
|
- `client` — Auth client
|
|
@@ -1548,7 +1618,10 @@ function createDeviceStores(): {
|
|
|
1548
1618
|
Create form stores from a form provider and options.
|
|
1549
1619
|
|
|
1550
1620
|
```typescript
|
|
1551
|
-
function createFormStores
|
|
1621
|
+
function createFormStores<T extends Record<string, unknown>>(
|
|
1622
|
+
provider: FormProvider,
|
|
1623
|
+
options: FormOptions<T>,
|
|
1624
|
+
): FormStores<T>
|
|
1552
1625
|
```
|
|
1553
1626
|
|
|
1554
1627
|
- `provider` — Form provider instance
|
|
@@ -1561,7 +1634,10 @@ function createFormStores(provider: FormProvider, options: FormOptions<T>): Form
|
|
|
1561
1634
|
Create a readable store that tracks a single field's state.
|
|
1562
1635
|
|
|
1563
1636
|
```typescript
|
|
1564
|
-
function createFieldStore
|
|
1637
|
+
function createFieldStore<T extends Record<string, unknown>, K extends keyof T>(
|
|
1638
|
+
controller: FormController<T>,
|
|
1639
|
+
name: K,
|
|
1640
|
+
): Readable<FieldState<T[K]>>
|
|
1565
1641
|
```
|
|
1566
1642
|
|
|
1567
1643
|
- `controller` — Form controller
|
|
@@ -1574,7 +1650,10 @@ function createFieldStore(controller: FormController<T>, name: K): Readable<Fiel
|
|
|
1574
1650
|
Create a readable store that tracks a single field's value.
|
|
1575
1651
|
|
|
1576
1652
|
```typescript
|
|
1577
|
-
function createWatchStore
|
|
1653
|
+
function createWatchStore<T extends Record<string, unknown>, K extends keyof T>(
|
|
1654
|
+
controller: FormController<T>,
|
|
1655
|
+
name: K,
|
|
1656
|
+
): Readable<T[K]>
|
|
1578
1657
|
```
|
|
1579
1658
|
|
|
1580
1659
|
- `controller` — Form controller
|
|
@@ -1587,7 +1666,7 @@ function createWatchStore(controller: FormController<T>, name: K): Readable<T[K]
|
|
|
1587
1666
|
Create an HTTP request store.
|
|
1588
1667
|
|
|
1589
1668
|
```typescript
|
|
1590
|
-
function createHttpStore(
|
|
1669
|
+
function createHttpStore<T>(
|
|
1591
1670
|
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
|
|
1592
1671
|
url: string,
|
|
1593
1672
|
config?: RequestConfig,
|
|
@@ -1605,7 +1684,7 @@ function createHttpStore(
|
|
|
1605
1684
|
Creates a GET request store.
|
|
1606
1685
|
|
|
1607
1686
|
```typescript
|
|
1608
|
-
function createGetStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
1687
|
+
function createGetStore<T>(url: string, config?: RequestConfig): HttpStore<T>
|
|
1609
1688
|
```
|
|
1610
1689
|
|
|
1611
1690
|
- `url` — The request endpoint URL.
|
|
@@ -1618,7 +1697,7 @@ function createGetStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
|
1618
1697
|
Creates a POST request store.
|
|
1619
1698
|
|
|
1620
1699
|
```typescript
|
|
1621
|
-
function createPostStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
1700
|
+
function createPostStore<T>(url: string, config?: RequestConfig): HttpStore<T>
|
|
1622
1701
|
```
|
|
1623
1702
|
|
|
1624
1703
|
- `url` — The request endpoint URL.
|
|
@@ -1631,7 +1710,7 @@ function createPostStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
|
1631
1710
|
Creates a PUT request store.
|
|
1632
1711
|
|
|
1633
1712
|
```typescript
|
|
1634
|
-
function createPutStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
1713
|
+
function createPutStore<T>(url: string, config?: RequestConfig): HttpStore<T>
|
|
1635
1714
|
```
|
|
1636
1715
|
|
|
1637
1716
|
- `url` — The request endpoint URL.
|
|
@@ -1644,7 +1723,7 @@ function createPutStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
|
1644
1723
|
Creates a PATCH request store.
|
|
1645
1724
|
|
|
1646
1725
|
```typescript
|
|
1647
|
-
function createPatchStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
1726
|
+
function createPatchStore<T>(url: string, config?: RequestConfig): HttpStore<T>
|
|
1648
1727
|
```
|
|
1649
1728
|
|
|
1650
1729
|
- `url` — The request endpoint URL.
|
|
@@ -1657,7 +1736,7 @@ function createPatchStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
|
1657
1736
|
Creates a DELETE request store.
|
|
1658
1737
|
|
|
1659
1738
|
```typescript
|
|
1660
|
-
function createDeleteStore(url: string, config?: RequestConfig): HttpStore<T>
|
|
1739
|
+
function createDeleteStore<T>(url: string, config?: RequestConfig): HttpStore<T>
|
|
1661
1740
|
```
|
|
1662
1741
|
|
|
1663
1742
|
- `url` — The request endpoint URL.
|
|
@@ -1773,7 +1852,7 @@ function createLoggerHelpersFromProvider(provider: LoggerProvider): LoggerHelper
|
|
|
1773
1852
|
Creates a login store with async state tracking.
|
|
1774
1853
|
|
|
1775
1854
|
```typescript
|
|
1776
|
-
function createLoginStore(): LoginStore<T>
|
|
1855
|
+
function createLoginStore<T = unknown>(): LoginStore<T>
|
|
1777
1856
|
```
|
|
1778
1857
|
|
|
1779
1858
|
**Returns:** Login promise store
|
|
@@ -1838,7 +1917,9 @@ function createPlatformStores(): {
|
|
|
1838
1917
|
Creates a store that tracks async function state.
|
|
1839
1918
|
|
|
1840
1919
|
```typescript
|
|
1841
|
-
function createPromiseStore(
|
|
1920
|
+
function createPromiseStore<T extends (...args: any[]) => Promise<any>>(
|
|
1921
|
+
asyncFn: T,
|
|
1922
|
+
): PromiseStore<Awaited<ReturnType<T>>>
|
|
1842
1923
|
```
|
|
1843
1924
|
|
|
1844
1925
|
- `asyncFn` — The async function to track
|
|
@@ -1914,7 +1995,7 @@ function createRouterStoresFromRouter(router: Router): RouterStores
|
|
|
1914
1995
|
Creates a signup store with async state tracking.
|
|
1915
1996
|
|
|
1916
1997
|
```typescript
|
|
1917
|
-
function createSignupStore(): SignupStore<T>
|
|
1998
|
+
function createSignupStore<T = unknown>(): SignupStore<T>
|
|
1918
1999
|
```
|
|
1919
2000
|
|
|
1920
2001
|
**Returns:** Signup promise store
|
|
@@ -1924,7 +2005,7 @@ function createSignupStore(): SignupStore<T>
|
|
|
1924
2005
|
Create a readable Svelte store from a molecule store.
|
|
1925
2006
|
|
|
1926
2007
|
```typescript
|
|
1927
|
-
function createStoreReadable(store: MoleculeStore<T>): Readable<T>
|
|
2008
|
+
function createStoreReadable<T>(store: MoleculeStore<T>): Readable<T>
|
|
1928
2009
|
```
|
|
1929
2010
|
|
|
1930
2011
|
- `store` — The molecule store
|
|
@@ -1936,7 +2017,7 @@ function createStoreReadable(store: MoleculeStore<T>): Readable<T>
|
|
|
1936
2017
|
Create a derived Svelte store with a selector.
|
|
1937
2018
|
|
|
1938
2019
|
```typescript
|
|
1939
|
-
function createStoreSelector(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>
|
|
2020
|
+
function createStoreSelector<T, S>(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>
|
|
1940
2021
|
```
|
|
1941
2022
|
|
|
1942
2023
|
- `store` — The molecule store
|
|
@@ -1949,9 +2030,7 @@ function createStoreSelector(store: MoleculeStore<T>, selector: (state: T) => S)
|
|
|
1949
2030
|
Get the setState function from a molecule store.
|
|
1950
2031
|
|
|
1951
2032
|
```typescript
|
|
1952
|
-
function getSetStore(
|
|
1953
|
-
store: MoleculeStore<T>,
|
|
1954
|
-
): (partial: Partial<T> | ((state: T) => Partial<T>)) => void
|
|
2033
|
+
function getSetStore<T>(store: MoleculeStore<T>): MoleculeStore<T>['setState']
|
|
1955
2034
|
```
|
|
1956
2035
|
|
|
1957
2036
|
- `store` — The molecule store
|
|
@@ -1963,7 +2042,7 @@ function getSetStore(
|
|
|
1963
2042
|
Create a bound action for a store.
|
|
1964
2043
|
|
|
1965
2044
|
```typescript
|
|
1966
|
-
function createStoreAction(
|
|
2045
|
+
function createStoreAction<T, Args extends unknown[], R>(
|
|
1967
2046
|
store: MoleculeStore<T>,
|
|
1968
2047
|
action: (
|
|
1969
2048
|
setState: MoleculeStore<T>['setState'],
|
|
@@ -1982,7 +2061,7 @@ function createStoreAction(
|
|
|
1982
2061
|
Create a storage value store.
|
|
1983
2062
|
|
|
1984
2063
|
```typescript
|
|
1985
|
-
function createStorageStore(key: string, defaultValue?: T): StorageStore<T>
|
|
2064
|
+
function createStorageStore<T>(key: string, defaultValue?: T): StorageStore<T>
|
|
1986
2065
|
```
|
|
1987
2066
|
|
|
1988
2067
|
- `key` — Storage key
|
|
@@ -2005,7 +2084,7 @@ function createStorageHelpers(): StorageHelpers
|
|
|
2005
2084
|
Create storage store from a specific provider.
|
|
2006
2085
|
|
|
2007
2086
|
```typescript
|
|
2008
|
-
function createStorageStoreFromProvider(
|
|
2087
|
+
function createStorageStoreFromProvider<T>(
|
|
2009
2088
|
storage: StorageProvider,
|
|
2010
2089
|
key: string,
|
|
2011
2090
|
defaultValue?: T,
|
|
@@ -2033,7 +2112,7 @@ function createThemeStores(): ThemeStores & { colors: Readable<Theme['colors']>
|
|
|
2033
2112
|
Create a derived store that returns just the theme colors.
|
|
2034
2113
|
|
|
2035
2114
|
```typescript
|
|
2036
|
-
function createThemeColorsStore(theme: Readable<Theme>): Readable<
|
|
2115
|
+
function createThemeColorsStore(theme: Readable<Theme>): Readable<Theme['colors']>
|
|
2037
2116
|
```
|
|
2038
2117
|
|
|
2039
2118
|
- `theme` — A readable theme store (from createThemeStores or createThemeStoresFromProvider)
|
|
@@ -2079,7 +2158,7 @@ function createVersionStores(): {
|
|
|
2079
2158
|
|
|
2080
2159
|
Peer dependencies:
|
|
2081
2160
|
|
|
2082
|
-
- `@molecule/app-auth` ^
|
|
2161
|
+
- `@molecule/app-auth` ^3.0.0
|
|
2083
2162
|
- `@molecule/app-device` ^1.0.1
|
|
2084
2163
|
- `@molecule/app-forms` ^1.0.1
|
|
2085
2164
|
- `@molecule/app-http` ^1.0.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-svelte",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Svelte framework bindings for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@molecule/app-auth": "^
|
|
25
|
+
"@molecule/app-auth": "^3.0.0",
|
|
26
26
|
"@molecule/app-device": "^1.0.1",
|
|
27
27
|
"@molecule/app-forms": "^1.0.1",
|
|
28
28
|
"@molecule/app-http": "^1.0.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"svelte": "^4.0.0 || ^5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@molecule/app-utilities": "1.0.
|
|
43
|
+
"@molecule/app-utilities": "1.0.6",
|
|
44
44
|
"@types/node": "26.6.5",
|
|
45
45
|
"svelte": "5.57.2",
|
|
46
46
|
"typescript": "6.0.3",
|