@molecule/app-svelte 3.7.1 → 3.7.2
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 +231 -24
- package/dist/hooks/useAIModels.d.ts +4 -1
- package/dist/hooks/useAIModels.d.ts.map +1 -1
- package/dist/hooks/useAIModels.js +8 -2
- package/dist/stores/auth.d.ts +2 -2
- package/package.json +2 -2
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-11-
|
|
6
|
+
Generated: 2026-11-18T16:22:02.310Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-svelte
|
|
@@ -160,55 +160,143 @@ interface AuthClient<
|
|
|
160
160
|
T = UserProfile,
|
|
161
161
|
TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
|
|
162
162
|
> {
|
|
163
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Returns the current authentication state snapshot.
|
|
165
|
+
*
|
|
166
|
+
* READING the state starts the client's one session restore when nobody has called
|
|
167
|
+
* {@link initialize} yet — lazily and exactly once, sharing the promise an explicit
|
|
168
|
+
* `initialize()` returns. A hook (`useAuth()`), a subscriber, `isAuthenticated()` and
|
|
169
|
+
* `getUser()` are reads too, so a client whose entry file dropped the template's
|
|
170
|
+
* `authClient.initialize()` line still restores instead of reporting `'loading'`
|
|
171
|
+
* forever.
|
|
172
|
+
*/
|
|
164
173
|
getState(): AuthState<T>
|
|
165
174
|
|
|
166
|
-
/**
|
|
175
|
+
/**
|
|
176
|
+
* Returns whether the user is currently authenticated.
|
|
177
|
+
*/
|
|
167
178
|
isAuthenticated(): boolean
|
|
168
179
|
|
|
169
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* Gets the current user.
|
|
182
|
+
*/
|
|
170
183
|
getUser(): T | null
|
|
171
184
|
|
|
172
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* Optional ownership marker for the current session. Compare values only within
|
|
187
|
+
* this client: replacing or ending a session changes it, including re-adopting
|
|
188
|
+
* the same token and user. Profile updates and same-session refreshes keep it.
|
|
189
|
+
* Consumers can use it to discard stale async work without treating editable
|
|
190
|
+
* user fields as an immutable account identifier. Providers without this
|
|
191
|
+
* capability require the consumer's own stable identity check.
|
|
192
|
+
*/
|
|
173
193
|
getSessionRevision?(): number
|
|
174
194
|
|
|
175
195
|
/** Updates the cached user object (state + persistent storage) without hitting the network. */
|
|
176
196
|
setUser(user: T | null): void
|
|
177
197
|
|
|
178
|
-
/**
|
|
198
|
+
/**
|
|
199
|
+
* Gets the current access token.
|
|
200
|
+
*/
|
|
179
201
|
getAccessToken(): string | null
|
|
180
202
|
|
|
181
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Stores the access token in the configured token storage adapter (in a
|
|
205
|
+
* browser, Web Storage; `'memory'` where no browser store exists). Use this
|
|
206
|
+
* to seed the token after an out-of-band exchange (e.g. the OAuth
|
|
207
|
+
* code→token redirect) instead of writing to `localStorage` directly,
|
|
208
|
+
* which would violate the storage contract and make a stored bearer token
|
|
209
|
+
* JS-readable (XSS-exfiltratable). Pass `null` to clear it.
|
|
210
|
+
*
|
|
211
|
+
* Passing `null` does not by itself sign a signed-in client out: use
|
|
212
|
+
* {@link logout} to end a session, or {@link setUser} with `null` for
|
|
213
|
+
* local-only sign-out. A non-null token on a client that is not signed in is
|
|
214
|
+
* the first or second half of the app's own sign-in pair: together with
|
|
215
|
+
* {@link setUser} it adopts the session (see there). Prefer {@link setSession}
|
|
216
|
+
* with the token and user, or {@link login} / {@link register} for a
|
|
217
|
+
* credential exchange.
|
|
218
|
+
*/
|
|
182
219
|
setAccessToken(token: string | null): void
|
|
183
220
|
|
|
184
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Adopts a session an out-of-band exchange already established: stores the
|
|
223
|
+
* access token (and the refresh token when given), caches the user, and
|
|
224
|
+
* sets the COMPLETE state — `initialized`, `authenticated`, `status:
|
|
225
|
+
* 'authenticated'`, no error — in one update, with one subscriber
|
|
226
|
+
* notification. Every hook reading the shared client sees the user as
|
|
227
|
+
* signed in immediately.
|
|
228
|
+
*
|
|
229
|
+
* This is the way to seed an OAuth/custom sign-in. The field-setter pair
|
|
230
|
+
* ({@link setAccessToken} then {@link setUser}, or the reverse) on a client
|
|
231
|
+
* that is not signed in adopts the session the same way.
|
|
232
|
+
*/
|
|
185
233
|
setSession(session: AuthSessionSeed<T>): void
|
|
186
234
|
|
|
187
|
-
/**
|
|
235
|
+
/**
|
|
236
|
+
* Gets the refresh token.
|
|
237
|
+
*/
|
|
188
238
|
getRefreshToken(): string | null
|
|
189
239
|
|
|
190
|
-
/**
|
|
240
|
+
/**
|
|
241
|
+
* Logs in with credentials.
|
|
242
|
+
*/
|
|
191
243
|
login(credentials: LoginCredentials): Promise<AuthResult<T>>
|
|
192
244
|
|
|
193
|
-
/**
|
|
245
|
+
/**
|
|
246
|
+
* Logs out the current user. The server request is best-effort: a missing
|
|
247
|
+
* logout route (404), any other HTTP failure, or a network error never makes
|
|
248
|
+
* this method reject. It always clears the access token, refresh token and
|
|
249
|
+
* cached user, stops automatic refresh, and publishes one settled
|
|
250
|
+
* `authenticated: false`, `status: 'unauthenticated'` transition. Every pending
|
|
251
|
+
* session operation loses ownership; a persistent marker prevents reload from
|
|
252
|
+
* restoring an older session, and late credentials are revoked best-effort.
|
|
253
|
+
*
|
|
254
|
+
* When the API has no logout route, set {@link AuthClientConfigOptions.logoutEndpoint}
|
|
255
|
+
* to `null` (or `''`) to skip the request. Local sign-out still happens.
|
|
256
|
+
*/
|
|
194
257
|
logout(): Promise<void>
|
|
195
258
|
|
|
196
|
-
/**
|
|
259
|
+
/**
|
|
260
|
+
* Registers a new user. Accepts the base fields plus the app's own fields
|
|
261
|
+
* (`TRegister`) at the top level — see {@link RegisterData}.
|
|
262
|
+
*/
|
|
197
263
|
register(data: RegisterData<TRegister>): Promise<AuthResult<T>>
|
|
198
264
|
|
|
199
|
-
/**
|
|
265
|
+
/**
|
|
266
|
+
* Exchanges a stored refresh token, or re-reads `currentUserEndpoint` with the
|
|
267
|
+
* existing access token/session cookie when the API has no refresh credential.
|
|
268
|
+
* That fallback maps, stores and publishes the server user without renewing
|
|
269
|
+
* the access token. Failures reject. A 401/403 ends the session, as does an
|
|
270
|
+
* additional {@link AuthClientConfigOptions.currentUserRejectionStatuses}
|
|
271
|
+
* code from the fallback. Transient failures retain it as unavailable. Use {@link updateProfile} for a profile
|
|
272
|
+
* save, or {@link setUser} with the canonical row from an app-owned mutation.
|
|
273
|
+
*/
|
|
200
274
|
refresh(): Promise<AuthResult<T>>
|
|
201
275
|
|
|
202
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* Requests a password reset.
|
|
278
|
+
*/
|
|
203
279
|
requestPasswordReset(data: PasswordResetRequest): Promise<void>
|
|
204
280
|
|
|
205
|
-
/**
|
|
281
|
+
/**
|
|
282
|
+
* Confirms a password reset.
|
|
283
|
+
*/
|
|
206
284
|
confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
|
|
207
285
|
|
|
208
|
-
/**
|
|
286
|
+
/**
|
|
287
|
+
* Updates the current user's profile.
|
|
288
|
+
* Returns the saved profile: the answer applied onto the signed-in user field
|
|
289
|
+
* by field, with or without an `id` — a field it carries replaces the value
|
|
290
|
+
* (`null` clears it), one it omits or leaves `undefined` is kept, so a field
|
|
291
|
+
* cleared by omission must arrive as `null`. A non-object answer is returned
|
|
292
|
+
* as it came. An answer for a replaced or ended session leaves the current one
|
|
293
|
+
* untouched.
|
|
294
|
+
*/
|
|
209
295
|
updateProfile(data: Partial<T>): Promise<T>
|
|
210
296
|
|
|
211
|
-
/**
|
|
297
|
+
/**
|
|
298
|
+
* Changes the current user's password.
|
|
299
|
+
*/
|
|
212
300
|
changePassword(oldPassword: string, newPassword: string): Promise<void>
|
|
213
301
|
|
|
214
302
|
/** Initializes auth state (e.g., from stored tokens). */
|
|
@@ -220,24 +308,48 @@ interface AuthClient<
|
|
|
220
308
|
/** Resolves when the session restore started by `initialize()` has settled — the point after which the client knows whether this visitor is signed in. */
|
|
221
309
|
whenRestored?(): Promise<void>
|
|
222
310
|
|
|
223
|
-
/**
|
|
311
|
+
/**
|
|
312
|
+
* Subscribes to auth state changes.
|
|
313
|
+
*/
|
|
224
314
|
subscribe(callback: (state: AuthState<T>) => void): () => void
|
|
225
315
|
|
|
226
|
-
/**
|
|
316
|
+
/**
|
|
317
|
+
* Subscribes to auth state changes (alias for subscribe).
|
|
318
|
+
*/
|
|
227
319
|
onAuthChange(callback: (state: AuthState<T>) => void): () => void
|
|
228
320
|
|
|
229
|
-
/**
|
|
321
|
+
/**
|
|
322
|
+
* Gets the current access token (alias for getAccessToken).
|
|
323
|
+
*/
|
|
230
324
|
getToken?(): string | null
|
|
231
325
|
|
|
232
|
-
/**
|
|
326
|
+
/**
|
|
327
|
+
* Adds an auth event listener.
|
|
328
|
+
*
|
|
329
|
+
* The listener is typed by this client's profile: one signature,
|
|
330
|
+
* `AuthEventListener<T>`, so an inline arrow is contextually typed and `event`
|
|
331
|
+
* is never implicitly `any`. A client whose profile extends
|
|
332
|
+
* {@link UserProfile} also accepts a default {@link AuthEventListener}: when
|
|
333
|
+
* `T` extends `UserProfile`, `AuthEvent<T>` is assignable to
|
|
334
|
+
* `AuthEvent<UserProfile>`, so a listener that takes the wider default event
|
|
335
|
+
* accepts every event this client emits and keeps compiling. (`UserProfile`
|
|
336
|
+
* is the wider type here — it has fewer required fields — and the assignable
|
|
337
|
+
* direction runs from the client's `AuthEvent<T>` to the listener's
|
|
338
|
+
* `AuthEvent<UserProfile>`.) A profile that does not extend `UserProfile`
|
|
339
|
+
* (no `id`) rejects the default listener: an `AuthEvent<UserProfile>` would
|
|
340
|
+
* promise an `id` the runtime user does not have, and the narrower-typed
|
|
341
|
+
* event is not assignable to it.
|
|
342
|
+
*/
|
|
233
343
|
addEventListener(listener: AuthEventListener<T>): () => void
|
|
234
344
|
|
|
235
|
-
/**
|
|
345
|
+
/**
|
|
346
|
+
* Destroys the auth client.
|
|
347
|
+
*/
|
|
236
348
|
destroy(): void
|
|
237
349
|
}
|
|
238
350
|
```
|
|
239
351
|
|
|
240
|
-
_(
|
|
352
|
+
_(The 4 longest member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-auth/dist/types.d.ts`.)_
|
|
241
353
|
|
|
242
354
|
#### `FormController`
|
|
243
355
|
|
|
@@ -424,6 +536,15 @@ interface FormOptions<T extends FormValuesConstraint<T>> {
|
|
|
424
536
|
HTTP client interface.
|
|
425
537
|
|
|
426
538
|
All HTTP providers must implement this interface.
|
|
539
|
+
An explicit text, blob or arraybuffer parser determines the data type even when
|
|
540
|
+
a JSON generic is supplied. Keep JSON as the default for mutations returning a
|
|
541
|
+
record. A successful DELETE with no body already resolves with null data.
|
|
542
|
+
|
|
543
|
+
Every verb also takes a URL alone, through a signature with the same three parameters on every
|
|
544
|
+
verb, so a verb chosen at runtime (`client[verb](url)`) type-checks and a wrapper can implement
|
|
545
|
+
a verb with an arrow (`get: (url, config) => inner.get(url, config)`). With a body or a config,
|
|
546
|
+
choose the verb through `request({ method, url, data })` instead: the second argument is the
|
|
547
|
+
body for post/put/patch but the config for get/delete, so one call cannot serve both.
|
|
427
548
|
|
|
428
549
|
```typescript
|
|
429
550
|
interface HttpClient {
|
|
@@ -441,11 +562,33 @@ interface HttpClient {
|
|
|
441
562
|
* Makes a generic HTTP request. `data` is a field of THIS config object — the same body
|
|
442
563
|
* `post(url, data, config)` takes as its second argument.
|
|
443
564
|
*/
|
|
565
|
+
request<T = unknown>(
|
|
566
|
+
config: FullRequestConfig & { responseType: 'text' },
|
|
567
|
+
): Promise<HttpResponse<string>>
|
|
568
|
+
request<T = unknown>(
|
|
569
|
+
config: FullRequestConfig & { responseType: 'blob' },
|
|
570
|
+
): Promise<HttpResponse<Blob>>
|
|
571
|
+
request<T = unknown>(
|
|
572
|
+
config: FullRequestConfig & { responseType: 'arraybuffer' },
|
|
573
|
+
): Promise<HttpResponse<ArrayBuffer>>
|
|
444
574
|
request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
|
|
445
575
|
|
|
446
576
|
/**
|
|
447
577
|
* Makes a GET request.
|
|
448
578
|
*/
|
|
579
|
+
get<T = unknown>(
|
|
580
|
+
url: string,
|
|
581
|
+
config: RequestConfig & { responseType: 'text' },
|
|
582
|
+
): Promise<HttpResponse<string>>
|
|
583
|
+
get<T = unknown>(
|
|
584
|
+
url: string,
|
|
585
|
+
config: RequestConfig & { responseType: 'blob' },
|
|
586
|
+
): Promise<HttpResponse<Blob>>
|
|
587
|
+
get<T = unknown>(
|
|
588
|
+
url: string,
|
|
589
|
+
config: RequestConfig & { responseType: 'arraybuffer' },
|
|
590
|
+
): Promise<HttpResponse<ArrayBuffer>>
|
|
591
|
+
get<T = unknown>(url: string, config?: undefined, unused?: undefined): Promise<HttpResponse<T>>
|
|
449
592
|
get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
450
593
|
|
|
451
594
|
/**
|
|
@@ -453,23 +596,84 @@ interface HttpClient {
|
|
|
453
596
|
* `data` itself, so `post(url, { data: body })` sends `{"data":body}` — pass `body` directly.
|
|
454
597
|
* A config (headers, params) is the THIRD argument.
|
|
455
598
|
*/
|
|
599
|
+
post<T = unknown>(
|
|
600
|
+
url: string,
|
|
601
|
+
data: unknown,
|
|
602
|
+
config: RequestConfig & { responseType: 'text' },
|
|
603
|
+
): Promise<HttpResponse<string>>
|
|
604
|
+
post<T = unknown>(
|
|
605
|
+
url: string,
|
|
606
|
+
data: unknown,
|
|
607
|
+
config: RequestConfig & { responseType: 'blob' },
|
|
608
|
+
): Promise<HttpResponse<Blob>>
|
|
609
|
+
post<T = unknown>(
|
|
610
|
+
url: string,
|
|
611
|
+
data: unknown,
|
|
612
|
+
config: RequestConfig & { responseType: 'arraybuffer' },
|
|
613
|
+
): Promise<HttpResponse<ArrayBuffer>>
|
|
614
|
+
post<T = unknown>(url: string, data?: undefined, config?: undefined): Promise<HttpResponse<T>>
|
|
456
615
|
post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
457
616
|
|
|
458
617
|
/**
|
|
459
618
|
* Makes a PUT request. `data` is the request BODY (second argument) — never `{ data: body }`,
|
|
460
619
|
* which sends `{"data":body}`; a config is the THIRD argument.
|
|
461
620
|
*/
|
|
621
|
+
put<T = unknown>(
|
|
622
|
+
url: string,
|
|
623
|
+
data: unknown,
|
|
624
|
+
config: RequestConfig & { responseType: 'text' },
|
|
625
|
+
): Promise<HttpResponse<string>>
|
|
626
|
+
put<T = unknown>(
|
|
627
|
+
url: string,
|
|
628
|
+
data: unknown,
|
|
629
|
+
config: RequestConfig & { responseType: 'blob' },
|
|
630
|
+
): Promise<HttpResponse<Blob>>
|
|
631
|
+
put<T = unknown>(
|
|
632
|
+
url: string,
|
|
633
|
+
data: unknown,
|
|
634
|
+
config: RequestConfig & { responseType: 'arraybuffer' },
|
|
635
|
+
): Promise<HttpResponse<ArrayBuffer>>
|
|
636
|
+
put<T = unknown>(url: string, data?: undefined, config?: undefined): Promise<HttpResponse<T>>
|
|
462
637
|
put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
463
638
|
|
|
464
639
|
/**
|
|
465
640
|
* Makes a PATCH request. `data` is the request BODY (second argument) — never `{ data: body }`,
|
|
466
641
|
* which sends `{"data":body}`; a config is the THIRD argument.
|
|
467
642
|
*/
|
|
643
|
+
patch<T = unknown>(
|
|
644
|
+
url: string,
|
|
645
|
+
data: unknown,
|
|
646
|
+
config: RequestConfig & { responseType: 'text' },
|
|
647
|
+
): Promise<HttpResponse<string>>
|
|
648
|
+
patch<T = unknown>(
|
|
649
|
+
url: string,
|
|
650
|
+
data: unknown,
|
|
651
|
+
config: RequestConfig & { responseType: 'blob' },
|
|
652
|
+
): Promise<HttpResponse<Blob>>
|
|
653
|
+
patch<T = unknown>(
|
|
654
|
+
url: string,
|
|
655
|
+
data: unknown,
|
|
656
|
+
config: RequestConfig & { responseType: 'arraybuffer' },
|
|
657
|
+
): Promise<HttpResponse<ArrayBuffer>>
|
|
658
|
+
patch<T = unknown>(url: string, data?: undefined, config?: undefined): Promise<HttpResponse<T>>
|
|
468
659
|
patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
469
660
|
|
|
470
661
|
/**
|
|
471
662
|
* Makes a DELETE request.
|
|
472
663
|
*/
|
|
664
|
+
delete<T = unknown>(
|
|
665
|
+
url: string,
|
|
666
|
+
config: RequestConfig & { responseType: 'text' },
|
|
667
|
+
): Promise<HttpResponse<string>>
|
|
668
|
+
delete<T = unknown>(
|
|
669
|
+
url: string,
|
|
670
|
+
config: RequestConfig & { responseType: 'blob' },
|
|
671
|
+
): Promise<HttpResponse<Blob>>
|
|
672
|
+
delete<T = unknown>(
|
|
673
|
+
url: string,
|
|
674
|
+
config: RequestConfig & { responseType: 'arraybuffer' },
|
|
675
|
+
): Promise<HttpResponse<ArrayBuffer>>
|
|
676
|
+
delete<T = unknown>(url: string, config?: undefined, unused?: undefined): Promise<HttpResponse<T>>
|
|
473
677
|
delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
474
678
|
|
|
475
679
|
/**
|
|
@@ -1224,7 +1428,10 @@ Result returned by `useAIModels`.
|
|
|
1224
1428
|
|
|
1225
1429
|
```typescript
|
|
1226
1430
|
interface UseAIModelsResult {
|
|
1227
|
-
/**
|
|
1431
|
+
/**
|
|
1432
|
+
* Available models, or an empty array while loading or after a failed fetch, as a readable store. The list
|
|
1433
|
+
* keeps its identity until the catalog changes, the empty one included.
|
|
1434
|
+
*/
|
|
1228
1435
|
models: Readable<AppModelDefinition[]>
|
|
1229
1436
|
/**
|
|
1230
1437
|
* Per-mode server default model ids for the requester's tier, or `undefined`
|
|
@@ -23,7 +23,10 @@ export declare function resetAIModelsCache(): void;
|
|
|
23
23
|
* Result returned by `useAIModels`.
|
|
24
24
|
*/
|
|
25
25
|
export interface UseAIModelsResult {
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Available models, or an empty array while loading or after a failed fetch, as a readable store. The list
|
|
28
|
+
* keeps its identity until the catalog changes, the empty one included.
|
|
29
|
+
*/
|
|
27
30
|
models: Readable<AppModelDefinition[]>;
|
|
28
31
|
/**
|
|
29
32
|
* Per-mode server default model ids for the requester's tier, or `undefined`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAIModels.d.ts","sourceRoot":"","sources":["../../src/hooks/useAIModels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAgB,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAMvF,OAAO,EAAE,KAAK,aAAa,EAAc,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"useAIModels.d.ts","sourceRoot":"","sources":["../../src/hooks/useAIModels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAgB,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAMvF,OAAO,EAAE,KAAK,aAAa,EAAc,MAAM,qBAAqB,CAAA;AAqGpE;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CASzC;AAWD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,EAAE,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAA;IACtC;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAA;IACpD,gEAAgE;IAChE,aAAa,EAAE,QAAQ,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAA;IACvD,mDAAmD;IACnD,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1B,+CAA+C;IAC/C,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,iBAAiB,CAuD5F"}
|
|
@@ -17,6 +17,12 @@ import { loadAIModelCatalog, pickFreeTierModel } from '@molecule/app-ai-models';
|
|
|
17
17
|
import { useHttpClient } from '../context.js';
|
|
18
18
|
import { fieldStore } from './live-store.js';
|
|
19
19
|
import { toReadable } from './maybe-readable.js';
|
|
20
|
+
/**
|
|
21
|
+
* The list returned while the catalog loads or after it fails. One module-level array, like the catalog's
|
|
22
|
+
* own lists, which every caller on a scope shares: a new `[]` per read would change the identity of an
|
|
23
|
+
* unchanged catalog.
|
|
24
|
+
*/
|
|
25
|
+
const NO_MODELS = [];
|
|
20
26
|
/** One cache entry per scope — `''` for the unscoped catalog, else the projectId. */
|
|
21
27
|
const caches = new Map();
|
|
22
28
|
/**
|
|
@@ -173,9 +179,9 @@ export function useAIModels(projectId) {
|
|
|
173
179
|
onDestroy(stopProjectId);
|
|
174
180
|
const loading = derived(snapshot, (current) => !current.models && !current.error);
|
|
175
181
|
return {
|
|
176
|
-
models: derived(snapshot, (current) => current.models ??
|
|
182
|
+
models: derived(snapshot, (current) => current.models ?? NO_MODELS),
|
|
177
183
|
defaults: fieldStore(snapshot, 'defaults'),
|
|
178
|
-
freeTierModel: derived(snapshot, (current) => pickFreeTierModel(current.models ??
|
|
184
|
+
freeTierModel: derived(snapshot, (current) => pickFreeTierModel(current.models ?? NO_MODELS)),
|
|
179
185
|
loading,
|
|
180
186
|
error: fieldStore(snapshot, 'error'),
|
|
181
187
|
};
|
package/dist/stores/auth.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ interface AuthStores<T, TRegister extends RegisterExtraShape<TRegister> = Record
|
|
|
18
18
|
* signed out, or unavailable. Gate a public page's first render on it
|
|
19
19
|
* (`{#if $sessionReady}`) so a handler that checks `user` never runs against a session
|
|
20
20
|
* restore still in flight. `'unavailable'` also becomes ready and may still have a
|
|
21
|
-
* null user.
|
|
22
|
-
* a request.
|
|
21
|
+
* null user. A stored token and cached user are ready synchronously. A visitor with
|
|
22
|
+
* no session candidate is ready synchronously without a request.
|
|
23
23
|
*/
|
|
24
24
|
sessionReady: Readable<boolean>;
|
|
25
25
|
error?: Readable<string | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-svelte",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.2",
|
|
4
4
|
"description": "Svelte framework bindings for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@molecule/app-ai-chat": "1.8.
|
|
70
|
+
"@molecule/app-ai-chat": "1.8.1",
|
|
71
71
|
"@molecule/app-ai-models": "1.4.4",
|
|
72
72
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
73
73
|
"@molecule/app-utilities": "1.0.7",
|