@spooky-sync/client-solid2 0.0.1-canary.263 → 0.0.1-canary.264

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/AGENTS.md CHANGED
@@ -46,7 +46,7 @@ Provider props are identical to client-solid: `config`, `fallback`, `preload` (a
46
46
  - Options: `enabled?: () => boolean`, `deregisterOnCleanup?: boolean`.
47
47
  - **`createSubmission(fn)`** — button pending/error state around a mutation: `submit()`, `pending()`, `error()`, `result()`, `clearError()`. There is deliberately no `action()` / `createOptimisticStore` layer (see `src/lib/create-submission.ts`).
48
48
  - **`useSyncActivity(options?)`** — `{ fetchingQueries, pendingMutations, isDownloading, isUploading }`. One subscription on the engine's aggregate fetch count plus the outbox depth; both are debounced ON by their delay (`downloadDelayMs` 200, `uploadDelayMs` 150) and off at once, and `isUploading()` additionally needs `pendingMutations() > uploadThreshold` (0, so any unacknowledged write counts). Drive a logo/traffic indicator off it; pair with `useSyncStatus().connection()` / `.isOffline()` to switch the same mark to a reconnecting or offline state and show the unsaved count.
49
- - **`createPreload`**, **`usePendingMutations`**, **`useSyncStatus`**, **`useImpersonation`**, **`useStorageStatus`**, **`useFeatureFlag`**, **`useAppRelease`**, **`useCrdtField`**, **`useFileUpload`**, **`useDownloadFile`** — same shapes as client-solid.
49
+ - **`createPreload`**, **`usePendingMutations`**, **`useSyncStatus`**, **`useImpersonation`** (`{ rendersBanner: true }` when the app draws its own banner), **`useStorageStatus`**, **`useFeatureFlag`**, **`useAppRelease`**, **`useCrdtField`**, **`useFileUpload`**, **`useDownloadFile`** — same shapes as client-solid.
50
50
  - **`conflate`**, **`fromSubscription`** — the async-iterable helpers the hooks are built on; useful for wrapping other engine subscriptions.
51
51
 
52
52
  ## Mutations
package/dist/index.cjs CHANGED
@@ -393,9 +393,12 @@ function useSyncStatus() {
393
393
  * such as hiding actions an admin should not take on someone's behalf.
394
394
  * Must be used within a `<Sp00kyProvider>`.
395
395
  */
396
- function useImpersonation() {
396
+ function useImpersonation(options = {}) {
397
397
  const db = useDb();
398
398
  const impersonation = fromSubscription((cb) => db.auth.subscribeImpersonation(cb), db.auth.impersonation);
399
+ (0, solid_js.createEffect)(() => {
400
+ if (options.rendersBanner && impersonation()) db.acknowledgeImpersonationBanner();
401
+ });
399
402
  return {
400
403
  impersonation,
401
404
  isImpersonating: () => impersonation() !== null,
@@ -1192,6 +1195,15 @@ var SyncedDb = class {
1192
1195
  await this.sp00ky.run(backend, path, unproxy(payload), options);
1193
1196
  }
1194
1197
  /**
1198
+ * Tell the client that this app's own impersonation banner is on screen.
1199
+ * Only needed with `impersonationBanner: { mode: 'custom' }`; the
1200
+ * `useImpersonation({ rendersBanner: true })` hook calls it for you.
1201
+ */
1202
+ acknowledgeImpersonationBanner() {
1203
+ if (!this.sp00ky) throw new Error("SyncedDb not initialized");
1204
+ this.sp00ky.acknowledgeImpersonationBanner();
1205
+ }
1206
+ /**
1195
1207
  * Sign out, clear session and local storage
1196
1208
  */
1197
1209
  async signOut() {