@civitai/blocks-react 0.25.0 → 0.27.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/README.md +70 -0
- package/dist/hooks/useImageUpload.d.ts +42 -4
- package/dist/hooks/useImageUpload.d.ts.map +1 -1
- package/dist/hooks/useImageUpload.js +124 -4
- package/dist/hooks/useImageUpload.js.map +1 -1
- package/dist/hooks/useViewer.d.ts +45 -0
- package/dist/hooks/useViewer.d.ts.map +1 -0
- package/dist/hooks/useViewer.js +70 -0
- package/dist/hooks/useViewer.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/iframeTransport.d.ts +7 -0
- package/dist/internal/iframeTransport.d.ts.map +1 -1
- package/dist/internal/iframeTransport.js +39 -0
- package/dist/internal/iframeTransport.js.map +1 -1
- package/dist/internal/inlineTransport.d.ts +1 -0
- package/dist/internal/inlineTransport.d.ts.map +1 -1
- package/dist/internal/inlineTransport.js +5 -0
- package/dist/internal/inlineTransport.js.map +1 -1
- package/dist/internal/liveHost.d.ts.map +1 -1
- package/dist/internal/liveHost.js +21 -0
- package/dist/internal/liveHost.js.map +1 -1
- package/dist/internal/mockHost.d.ts +46 -2
- package/dist/internal/mockHost.d.ts.map +1 -1
- package/dist/internal/mockHost.js +95 -3
- package/dist/internal/mockHost.js.map +1 -1
- package/dist/internal/transport.d.ts +21 -0
- package/dist/internal/transport.d.ts.map +1 -1
- package/dist/internal/transport.js +10 -0
- package/dist/internal/transport.js.map +1 -1
- package/dist/internal/validate.d.ts +58 -0
- package/dist/internal/validate.d.ts.map +1 -1
- package/dist/internal/validate.js +97 -2
- package/dist/internal/validate.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -223,6 +223,76 @@ if (!loading && balance) console.log(`Yellow: ${balance.yellow}`);
|
|
|
223
223
|
> `body.accountType` (`'blue' | 'green' | 'yellow'`) — a *preference* for which
|
|
224
224
|
> pool funds the generation; the host clamps it server-side.
|
|
225
225
|
|
|
226
|
+
### `useViewer()`
|
|
227
|
+
|
|
228
|
+
The signed-in viewer as an on-demand authoritative self-read (`{ id, username,
|
|
229
|
+
status, buzzBudget }`) — distinct from `useBlockContext().viewer`, the coarse
|
|
230
|
+
`BLOCK_INIT`-time snapshot. `status` is `'active' | 'muted'`; `username`
|
|
231
|
+
(`string | null`) and `buzzBudget` (`number | null`) are present-but-nullable, so
|
|
232
|
+
handle the null case. Host-mediated over `GET_VIEWER` → `VIEWER_RESULT` (the host
|
|
233
|
+
resolves the viewer from the block token via `blocks.getMyViewer`); an anonymous /
|
|
234
|
+
banned viewer comes back as `error`. Fetches on mount; `refetch` for on-demand
|
|
235
|
+
refreshes.
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
const { viewer, loading, error, refetch } = useViewer();
|
|
239
|
+
// `viewer` is null until the first successful fetch. An anon / banned viewer,
|
|
240
|
+
// missing scope, or host failure → `error`. `username`/`buzzBudget` may be null.
|
|
241
|
+
if (!loading && viewer) console.log(`${viewer.username ?? 'anon'} · budget ${viewer.buzzBudget ?? 0}`);
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### `useBuzzTransactions(params?)`
|
|
245
|
+
|
|
246
|
+
The signed-in viewer's Buzz-transaction ledger (a paged, host-projected read of
|
|
247
|
+
the Buzz dashboard). Returns `{ transactions, cursor, loading, error, refetch }`;
|
|
248
|
+
`transactions` rows are rehydrated so `date` is a `Date`. Pass the returned
|
|
249
|
+
`cursor` back as `params.cursor` to page forward. Requires the `buzz:read:self`
|
|
250
|
+
scope; host-mediated over `GET_BUZZ_TRANSACTIONS`.
|
|
251
|
+
|
|
252
|
+
```tsx
|
|
253
|
+
const { transactions, cursor, loading, error } = useBuzzTransactions({ type: 'Tip', limit: 20 });
|
|
254
|
+
if (!loading && transactions) transactions.forEach((t) => console.log(t.type, t.amount, t.date));
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### `useBuzzAccounts()`
|
|
258
|
+
|
|
259
|
+
The viewer's all-pool Buzz balances — the three spendable pools **plus** the
|
|
260
|
+
creator payout pools (`{ accountType, balance }[]`), a superset of
|
|
261
|
+
`useBuzzBalance`. Returns `{ accounts, loading, error, refetch }`. Requires
|
|
262
|
+
`buzz:read:self`; host-mediated over `GET_BUZZ_ACCOUNTS`.
|
|
263
|
+
|
|
264
|
+
```tsx
|
|
265
|
+
const { accounts, loading, error } = useBuzzAccounts();
|
|
266
|
+
if (!loading && accounts) accounts.forEach((a) => console.log(a.accountType, a.balance));
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### `useDailyCompensation(params)`
|
|
270
|
+
|
|
271
|
+
Per-modelVersion generation-compensation for the month containing `params.date`
|
|
272
|
+
(Buzz totals + cash totals in pennies). Returns `{ resources,
|
|
273
|
+
hasPublishedResources, loading, error, refetch }`. Requires `buzz:read:self`;
|
|
274
|
+
host-mediated over `GET_DAILY_COMPENSATION`.
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
const { resources, hasPublishedResources } = useDailyCompensation({ date: '2026-07-01' });
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### `useWildcardPack(modelVersionId)`
|
|
281
|
+
|
|
282
|
+
Import a wildcard pack's parsed prompt lists by model version — the host
|
|
283
|
+
resolves + fetches + unzips + parses it **in the user's own page session** (every
|
|
284
|
+
download gate enforced), so the untrusted iframe never sees the bytes. Returns
|
|
285
|
+
`{ pack, loading, error, refetch }`. On failure `error` is a `WildcardPackError`
|
|
286
|
+
with a discriminated `code` (`not-found` / `forbidden` / `too-large` /
|
|
287
|
+
`parse-failed` / `busy` — `busy` is retryable), not free text.
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
const { pack, loading, error, refetch } = useWildcardPack(modelVersionId);
|
|
291
|
+
// `error.code === 'busy'` is retryable — call refetch(); the other codes are terminal.
|
|
292
|
+
if (error instanceof WildcardPackError && error.code === 'busy') void refetch();
|
|
293
|
+
if (!loading && pack) console.log(Object.keys(pack.lists));
|
|
294
|
+
```
|
|
295
|
+
|
|
226
296
|
### `useAppStorage()`
|
|
227
297
|
|
|
228
298
|
Per-(block instance, viewer) KV datastore, host-mediated. 64 KB per value,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockGenerationSourceImageInfo, BlockUploadedImageInfo, BlockUploadPurpose } from '@civitai/app-sdk/blocks';
|
|
1
|
+
import type { BlockGenerationSourceImageInfo, BlockImageScanResult, BlockPendingImageInfo, BlockUploadedImageInfo, BlockUploadPurpose } from '@civitai/app-sdk/blocks';
|
|
2
2
|
/** Options for {@link useImageUpload}. */
|
|
3
3
|
export interface UseImageUploadOptions {
|
|
4
4
|
/**
|
|
@@ -10,6 +10,14 @@ export interface UseImageUploadOptions {
|
|
|
10
10
|
* (`{ url, width, height }`).
|
|
11
11
|
*/
|
|
12
12
|
purpose?: BlockUploadPurpose;
|
|
13
|
+
/**
|
|
14
|
+
* Opt in to the NON-BLOCKING `'display'` flow. When `true`, `open()` resolves
|
|
15
|
+
* EARLY (on persist) with a {@link BlockPendingImageInfo} and the scan verdict
|
|
16
|
+
* is delivered separately via `scanStatus()` (see the async overload). Only
|
|
17
|
+
* meaningful for `'display'`; ignored for `'generationSource'` (that path has
|
|
18
|
+
* no host-side scan). Absent/`false` keeps the legacy blocking behavior.
|
|
19
|
+
*/
|
|
20
|
+
asyncScan?: boolean;
|
|
13
21
|
}
|
|
14
22
|
/**
|
|
15
23
|
* Drives the platform-side image-upload flow for App Blocks (Design 1 —
|
|
@@ -18,12 +26,17 @@ export interface UseImageUploadOptions {
|
|
|
18
26
|
* routes through civitai's session-authed pipeline; the host is what decides
|
|
19
27
|
* how the image is scanned/returned based on the requested `purpose`.
|
|
20
28
|
*
|
|
21
|
-
* The RETURN of `open()` is typed by `purpose`:
|
|
22
|
-
* - default / `'display'` → resolves with a MODERATED
|
|
29
|
+
* The RETURN of `open()` is typed by `purpose` / `asyncScan`:
|
|
30
|
+
* - default / `'display'` (BLOCKING) → resolves with a MODERATED
|
|
23
31
|
* {@link BlockUploadedImageInfo} (imageId/nsfwLevel/contentRating/url), or
|
|
24
32
|
* `null` when the user dismissed the modal without a successful upload. The
|
|
25
33
|
* returned `url` is a Civitai-hosted image URL usable directly as a
|
|
26
34
|
* `WorkflowBody.sourceImage.url`.
|
|
35
|
+
* - `'display'` + `asyncScan: true` (NON-BLOCKING) → resolves EARLY (on persist)
|
|
36
|
+
* with a {@link BlockPendingImageInfo} (`status:'pending'`, imageId, url), or
|
|
37
|
+
* `null` on dismiss. The image is AUTHOR-PREVIEW-ONLY until the scan verdict —
|
|
38
|
+
* obtain it with `scanStatus(handle)`. Do NOT persist the image to a
|
|
39
|
+
* cross-user surface until `scanStatus` resolves `'scanned'`.
|
|
27
40
|
* - `'generationSource'` → resolves with the source
|
|
28
41
|
* {@link BlockGenerationSourceImageInfo} (`{ url, width, height }`, UNSCANNED —
|
|
29
42
|
* the orchestrator scans it at gen time), or `null` on dismiss. Feed it
|
|
@@ -38,7 +51,7 @@ export interface UseImageUploadOptions {
|
|
|
38
51
|
* purpose to `'display'`) behaves exactly as before.
|
|
39
52
|
*
|
|
40
53
|
* @example
|
|
41
|
-
* // display (moderated public image) — default
|
|
54
|
+
* // display (moderated public image) — default, BLOCKING
|
|
42
55
|
* const { open } = useImageUpload();
|
|
43
56
|
* const img = await open();
|
|
44
57
|
* if (!img) return; // user dismissed
|
|
@@ -46,6 +59,17 @@ export interface UseImageUploadOptions {
|
|
|
46
59
|
* sourceImage: { url: img.url, width: 1024, height: 1024 }, params: { prompt } });
|
|
47
60
|
*
|
|
48
61
|
* @example
|
|
62
|
+
* // display (NON-BLOCKING) — early handle now, scan verdict streamed
|
|
63
|
+
* const { open, scanStatus } = useImageUpload({ asyncScan: true });
|
|
64
|
+
* const handle = await open(); // BlockPendingImageInfo | null
|
|
65
|
+
* if (!handle) return;
|
|
66
|
+
* // …show the author their own preview immediately…
|
|
67
|
+
* const verdict = await scanStatus(handle);
|
|
68
|
+
* if (verdict.status === 'scanned') persistBackground(verdict.image); // clean
|
|
69
|
+
* else if (verdict.status === 'blocked') showRejected(verdict.reason); // terminal
|
|
70
|
+
* else retryLater(verdict.message); // transient — re-call scanStatus(handle)
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
49
73
|
* // generationSource (private img2img source, unscanned)
|
|
50
74
|
* const { open } = useImageUpload({ purpose: 'generationSource' });
|
|
51
75
|
* const src = await open(); // { url, width, height } | null
|
|
@@ -58,6 +82,20 @@ export declare function useImageUpload(options: {
|
|
|
58
82
|
}): {
|
|
59
83
|
open: () => Promise<BlockGenerationSourceImageInfo | null>;
|
|
60
84
|
};
|
|
85
|
+
export declare function useImageUpload(options: {
|
|
86
|
+
purpose?: 'display';
|
|
87
|
+
asyncScan: true;
|
|
88
|
+
}): {
|
|
89
|
+
/** Early-resolve handle (image persisted, NOT yet scanned) or `null` (dismissed). */
|
|
90
|
+
open: () => Promise<BlockPendingImageInfo | null>;
|
|
91
|
+
/**
|
|
92
|
+
* Resolve the async scan verdict for a handle returned by `open()`. Re-callable
|
|
93
|
+
* for retry: the host emits the verdict once and the hook buffers it, so a
|
|
94
|
+
* re-call after an `'error'`/timeout re-awaits (or immediately returns) the same
|
|
95
|
+
* verdict. An unknown/expired handle resolves to a retryable `'error'`.
|
|
96
|
+
*/
|
|
97
|
+
scanStatus: (handle: BlockPendingImageInfo) => Promise<BlockImageScanResult>;
|
|
98
|
+
};
|
|
61
99
|
export declare function useImageUpload(options?: {
|
|
62
100
|
purpose?: 'display';
|
|
63
101
|
}): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImageUpload.d.ts","sourceRoot":"","sources":["../../src/hooks/useImageUpload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"useImageUpload.d.ts","sourceRoot":"","sources":["../../src/hooks/useImageUpload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAejC,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,GAAG;IACxE,IAAI,EAAE,MAAM,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAAC;CAC5D,CAAC;AACF,wBAAgB,cAAc,CAAC,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAE,GAAG;IACjF,qFAAqF;IACrF,IAAI,EAAE,MAAM,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;IAClD;;;;;OAKG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC9E,CAAC;AACF,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IACjE,IAAI,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;CACpD,CAAC"}
|
|
@@ -1,10 +1,106 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { getTransport } from '../internal/singleton.js';
|
|
3
|
-
import { sendTypedRequest } from '../internal/transport.js';
|
|
3
|
+
import { sendTypedRequest, subscribeTyped } from '../internal/transport.js';
|
|
4
4
|
import { PICKER_REQUEST_TIMEOUT_MS } from './useCheckpointPicker.js';
|
|
5
|
+
/**
|
|
6
|
+
* Generous hook-side backstop for {@link BlockImageScanResult} delivery. The
|
|
7
|
+
* host-side scan POLL budget is authoritative and the consuming app applies its
|
|
8
|
+
* own (shorter) timeout; this only guards against a verdict that never arrives,
|
|
9
|
+
* resolving RETRYABLE so a later re-call can still pick up a late verdict from
|
|
10
|
+
* the buffer.
|
|
11
|
+
*/
|
|
12
|
+
const SCAN_STATUS_TIMEOUT_MS = PICKER_REQUEST_TIMEOUT_MS;
|
|
13
|
+
/**
|
|
14
|
+
* A verdict is TERMINAL when the host has reached a final answer (`scanned` /
|
|
15
|
+
* `blocked`) — the block will never poll it again. An `error` verdict is
|
|
16
|
+
* transient/retryable, so its entry is KEPT so `scanStatus()` can be re-called.
|
|
17
|
+
* Terminal entries are EVICTED from the tracking map once delivered (see below)
|
|
18
|
+
* so a long-lived block doing many uploads can't grow the map unbounded.
|
|
19
|
+
*/
|
|
20
|
+
function isTerminalVerdict(v) {
|
|
21
|
+
return v.status === 'scanned' || v.status === 'blocked';
|
|
22
|
+
}
|
|
5
23
|
export function useImageUpload(options) {
|
|
6
24
|
const purpose = options?.purpose;
|
|
25
|
+
const asyncScan = options?.asyncScan === true && purpose !== 'generationSource';
|
|
26
|
+
// Per-instance scan tracking, keyed by imageId. Persists across renders; a
|
|
27
|
+
// verdict is correlated back to its upload by imageId + the generated requestId.
|
|
28
|
+
const scansRef = useRef(new Map());
|
|
29
|
+
// Mount ONE listener for the host→block IMAGE_SCAN_RESOLVED push. The transport
|
|
30
|
+
// invokes this ONLY AFTER the message has cleared BOTH the origin allowlist and
|
|
31
|
+
// the payload validator (see IframeTransport.handleMessage), and we ADDITIONALLY
|
|
32
|
+
// honor a verdict only if it matches a request this hook instance originated
|
|
33
|
+
// (matching requestId + imageId), so concurrent instances coexist and a
|
|
34
|
+
// forged/replayed verdict is ignored.
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const scans = scansRef.current;
|
|
37
|
+
const unsubscribe = subscribeTyped(getTransport(), 'IMAGE_SCAN_RESOLVED', ({ requestId, imageId, result }) => {
|
|
38
|
+
const entry = scans.get(imageId);
|
|
39
|
+
if (!entry || entry.requestId !== requestId)
|
|
40
|
+
return; // not ours / forged
|
|
41
|
+
if (entry.verdict)
|
|
42
|
+
return; // host emits once — honor only the first
|
|
43
|
+
entry.verdict = result;
|
|
44
|
+
const hadWaiters = entry.waiters.length > 0;
|
|
45
|
+
for (const w of entry.waiters) {
|
|
46
|
+
clearTimeout(w.timeoutId);
|
|
47
|
+
w.resolve(result);
|
|
48
|
+
}
|
|
49
|
+
entry.waiters = [];
|
|
50
|
+
// Evict a TERMINAL verdict once it has been delivered to a live caller
|
|
51
|
+
// (bounded-memory: L1). If nobody was waiting yet (verdict arrived before
|
|
52
|
+
// scanStatus() was called), keep it BUFFERED so the eventual scanStatus()
|
|
53
|
+
// can still read it — that read then evicts it (see scanStatus below).
|
|
54
|
+
// `error` verdicts are always kept (retryable).
|
|
55
|
+
if (hadWaiters && isTerminalVerdict(result))
|
|
56
|
+
scans.delete(imageId);
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
unsubscribe();
|
|
60
|
+
for (const entry of scans.values()) {
|
|
61
|
+
for (const w of entry.waiters)
|
|
62
|
+
clearTimeout(w.timeoutId);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}, []);
|
|
7
66
|
const open = useCallback(async () => {
|
|
67
|
+
if (asyncScan) {
|
|
68
|
+
// Omit `purpose` (display byte-compat) but opt into the early-resolve flow.
|
|
69
|
+
const { requestId, selected } = await sendTypedRequest(getTransport(), { type: 'OPEN_IMAGE_UPLOAD', payload: { asyncScan: true } }, 'IMAGE_UPLOAD_RESULT', { timeoutMs: PICKER_REQUEST_TIMEOUT_MS });
|
|
70
|
+
if (!selected)
|
|
71
|
+
return null; // dismissed
|
|
72
|
+
// NEW host: an early-resolve pending handle. Track it and wait for the push.
|
|
73
|
+
if ('status' in selected && selected.status === 'pending') {
|
|
74
|
+
scansRef.current.set(selected.imageId, { requestId, waiters: [] });
|
|
75
|
+
const handle = {
|
|
76
|
+
status: 'pending',
|
|
77
|
+
imageId: selected.imageId,
|
|
78
|
+
url: selected.url,
|
|
79
|
+
};
|
|
80
|
+
return handle;
|
|
81
|
+
}
|
|
82
|
+
// OLD host (ignored asyncScan): it blocking-resolved a MODERATED image. Wrap
|
|
83
|
+
// it in a pending-shaped handle AND pre-buffer a `scanned` verdict so
|
|
84
|
+
// scanStatus() resolves immediately — no hang. (Compat matrix case 2.)
|
|
85
|
+
if ('imageId' in selected && typeof selected.imageId === 'number') {
|
|
86
|
+
const moderated = selected;
|
|
87
|
+
scansRef.current.set(moderated.imageId, {
|
|
88
|
+
requestId,
|
|
89
|
+
verdict: { status: 'scanned', image: moderated },
|
|
90
|
+
waiters: [],
|
|
91
|
+
});
|
|
92
|
+
const handle = {
|
|
93
|
+
status: 'pending',
|
|
94
|
+
imageId: moderated.imageId,
|
|
95
|
+
url: moderated.url,
|
|
96
|
+
};
|
|
97
|
+
return handle;
|
|
98
|
+
}
|
|
99
|
+
// Any other shape on a display request (e.g. an unexpected source-only
|
|
100
|
+
// payload) → treat as dismissed rather than fabricate a handle.
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
// ---- Existing BLOCKING behavior (unchanged) ----
|
|
8
104
|
// Omit `purpose` for the default/display mode so the wire stays
|
|
9
105
|
// byte-compatible with an older host that predates the field.
|
|
10
106
|
const payload = purpose === 'generationSource' ? { purpose } : {};
|
|
@@ -12,7 +108,31 @@ export function useImageUpload(options) {
|
|
|
12
108
|
// Normalize the "dismissed" case to an explicit null so callers can
|
|
13
109
|
// `if (!img) return;` without an `undefined` ambiguity.
|
|
14
110
|
return selected ?? null;
|
|
15
|
-
}, [purpose]);
|
|
16
|
-
|
|
111
|
+
}, [asyncScan, purpose]);
|
|
112
|
+
const scanStatus = useCallback((handle) => {
|
|
113
|
+
const entry = scansRef.current.get(handle.imageId);
|
|
114
|
+
if (!entry) {
|
|
115
|
+
// No tracked upload for this handle (a foreign/expired handle, or the
|
|
116
|
+
// hook remounted). Retryable rather than a hang.
|
|
117
|
+
return Promise.resolve({ status: 'error', message: 'unknown or expired upload handle' });
|
|
118
|
+
}
|
|
119
|
+
if (entry.verdict) {
|
|
120
|
+
const buffered = entry.verdict;
|
|
121
|
+
// A BUFFERED terminal verdict (the push arrived before this call) is
|
|
122
|
+
// consumed here — evict it so the map doesn't grow (L1). `error` stays
|
|
123
|
+
// (retryable). See isTerminalVerdict + the push handler above.
|
|
124
|
+
if (isTerminalVerdict(buffered))
|
|
125
|
+
scansRef.current.delete(handle.imageId);
|
|
126
|
+
return Promise.resolve(buffered);
|
|
127
|
+
}
|
|
128
|
+
return new Promise((resolve) => {
|
|
129
|
+
const timeoutId = setTimeout(() => {
|
|
130
|
+
entry.waiters = entry.waiters.filter((w) => w.timeoutId !== timeoutId);
|
|
131
|
+
resolve({ status: 'error', message: 'scan status timed out' });
|
|
132
|
+
}, SCAN_STATUS_TIMEOUT_MS);
|
|
133
|
+
entry.waiters.push({ resolve, timeoutId });
|
|
134
|
+
});
|
|
135
|
+
}, []);
|
|
136
|
+
return { open, scanStatus };
|
|
17
137
|
}
|
|
18
138
|
//# sourceMappingURL=useImageUpload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImageUpload.js","sourceRoot":"","sources":["../../src/hooks/useImageUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useImageUpload.js","sourceRoot":"","sources":["../../src/hooks/useImageUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,E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AAC,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BlockViewer } from '@civitai/app-sdk/blocks';
|
|
2
|
+
/**
|
|
3
|
+
* What {@link useViewer} returns.
|
|
4
|
+
*/
|
|
5
|
+
export interface UseViewer {
|
|
6
|
+
/** The signed-in viewer, or `null` until the first successful fetch. */
|
|
7
|
+
viewer: BlockViewer | null;
|
|
8
|
+
/** `true` while a fetch (initial or `refetch`) is in flight. */
|
|
9
|
+
loading: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The last fetch's failure — a host-reported error (anon / banned viewer /
|
|
12
|
+
* missing scope / host failure) or the transport timeout when the host never
|
|
13
|
+
* answers. Cleared at the start of the next fetch.
|
|
14
|
+
*/
|
|
15
|
+
error: Error | null;
|
|
16
|
+
/** Re-request the viewer. */
|
|
17
|
+
refetch: () => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read the signed-in viewer (id / username / status + optional buzzBudget)
|
|
21
|
+
* through the host-mediated `GET_VIEWER` → `VIEWER_RESULT` bridge. Token-bound:
|
|
22
|
+
* the host resolves the viewer from the block token and reads via its
|
|
23
|
+
* `blocks.getMyViewer` tRPC mutation — the block never touches the viewer API or
|
|
24
|
+
* credentials directly (same trust model as {@link useBuzzBalance}).
|
|
25
|
+
*
|
|
26
|
+
* Distinct from `useBlockContext().viewer`, which is the coarse BLOCK_INIT-time
|
|
27
|
+
* snapshot ({@link ViewerInfo}, `status` optional): `useViewer` is the on-demand
|
|
28
|
+
* authoritative self-read (`active`/`muted` status + the viewer's current
|
|
29
|
+
* `buzzBudget`). `username` and `buzzBudget` are surfaced as-is and may be `null`
|
|
30
|
+
* (a viewer with no handle / a token lacking the budget claim) — the block
|
|
31
|
+
* handles the null case.
|
|
32
|
+
*
|
|
33
|
+
* Fetches once on mount and exposes `refetch` for on-demand refreshes. A host
|
|
34
|
+
* that never answers surfaces as an `error` after the transport's request
|
|
35
|
+
* timeout — the hook never hangs. Late responses that arrive after unmount are
|
|
36
|
+
* ignored (no state update).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const { viewer, loading, error, refetch } = useViewer();
|
|
40
|
+
* if (loading) return <Spinner />;
|
|
41
|
+
* if (error) return <RetryButton onClick={refetch} />;
|
|
42
|
+
* return <span>{viewer?.username}</span>;
|
|
43
|
+
*/
|
|
44
|
+
export declare function useViewer(): UseViewer;
|
|
45
|
+
//# sourceMappingURL=useViewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useViewer.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,wEAAwE;IACxE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,IAAI,SAAS,CA0CrC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { getTransport } from '../internal/singleton.js';
|
|
3
|
+
import { sendTypedRequest } from '../internal/transport.js';
|
|
4
|
+
/**
|
|
5
|
+
* Read the signed-in viewer (id / username / status + optional buzzBudget)
|
|
6
|
+
* through the host-mediated `GET_VIEWER` → `VIEWER_RESULT` bridge. Token-bound:
|
|
7
|
+
* the host resolves the viewer from the block token and reads via its
|
|
8
|
+
* `blocks.getMyViewer` tRPC mutation — the block never touches the viewer API or
|
|
9
|
+
* credentials directly (same trust model as {@link useBuzzBalance}).
|
|
10
|
+
*
|
|
11
|
+
* Distinct from `useBlockContext().viewer`, which is the coarse BLOCK_INIT-time
|
|
12
|
+
* snapshot ({@link ViewerInfo}, `status` optional): `useViewer` is the on-demand
|
|
13
|
+
* authoritative self-read (`active`/`muted` status + the viewer's current
|
|
14
|
+
* `buzzBudget`). `username` and `buzzBudget` are surfaced as-is and may be `null`
|
|
15
|
+
* (a viewer with no handle / a token lacking the budget claim) — the block
|
|
16
|
+
* handles the null case.
|
|
17
|
+
*
|
|
18
|
+
* Fetches once on mount and exposes `refetch` for on-demand refreshes. A host
|
|
19
|
+
* that never answers surfaces as an `error` after the transport's request
|
|
20
|
+
* timeout — the hook never hangs. Late responses that arrive after unmount are
|
|
21
|
+
* ignored (no state update).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const { viewer, loading, error, refetch } = useViewer();
|
|
25
|
+
* if (loading) return <Spinner />;
|
|
26
|
+
* if (error) return <RetryButton onClick={refetch} />;
|
|
27
|
+
* return <span>{viewer?.username}</span>;
|
|
28
|
+
*/
|
|
29
|
+
export function useViewer() {
|
|
30
|
+
const [viewer, setViewer] = useState(null);
|
|
31
|
+
const [loading, setLoading] = useState(true);
|
|
32
|
+
const [error, setError] = useState(null);
|
|
33
|
+
// Guards against a late response resolving after the component unmounted
|
|
34
|
+
// (React would warn about a state update on an unmounted component, and the
|
|
35
|
+
// work is wasted anyway).
|
|
36
|
+
const mountedRef = useRef(true);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
mountedRef.current = true;
|
|
39
|
+
return () => {
|
|
40
|
+
mountedRef.current = false;
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
const refetch = useCallback(() => {
|
|
44
|
+
setLoading(true);
|
|
45
|
+
setError(null);
|
|
46
|
+
sendTypedRequest(getTransport(), { type: 'GET_VIEWER', payload: {} }, 'VIEWER_RESULT')
|
|
47
|
+
.then((result) => {
|
|
48
|
+
if (!mountedRef.current)
|
|
49
|
+
return;
|
|
50
|
+
if (result.error || !result.viewer) {
|
|
51
|
+
setError(new Error(result.error ?? 'failed to fetch viewer'));
|
|
52
|
+
setLoading(false);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
setViewer(result.viewer);
|
|
56
|
+
setLoading(false);
|
|
57
|
+
})
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
if (!mountedRef.current)
|
|
60
|
+
return;
|
|
61
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
62
|
+
setLoading(false);
|
|
63
|
+
});
|
|
64
|
+
}, []);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
refetch();
|
|
67
|
+
}, [refetch]);
|
|
68
|
+
return { viewer, loading, error, refetch };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=useViewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useViewer.js","sourceRoot":"","sources":["../../src/hooks/useViewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAoB5D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAqB,IAAI,CAAC,CAAC;IAC/D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IAEvD,yEA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EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC7C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export { useBlockResize } from './hooks/useBlockResize.js';
|
|
|
22
22
|
export { useBuzzPurchase } from './hooks/useBuzzPurchase.js';
|
|
23
23
|
export { useBuzzBalance } from './hooks/useBuzzBalance.js';
|
|
24
24
|
export type { BuzzBalance, UseBuzzBalance } from './hooks/useBuzzBalance.js';
|
|
25
|
+
export { useViewer } from './hooks/useViewer.js';
|
|
26
|
+
export type { UseViewer } from './hooks/useViewer.js';
|
|
25
27
|
export { useBuzzTransactions } from './hooks/useBuzzTransactions.js';
|
|
26
28
|
export type { BuzzTransaction, UseBuzzTransactions } from './hooks/useBuzzTransactions.js';
|
|
27
29
|
export { useBuzzAccounts } from './hooks/useBuzzAccounts.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,aAAa,EACb,c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gB,EAChB,8BAA8B,EAC9B,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export { useBuzzWorkflow } from './hooks/useBuzzWorkflow.js';
|
|
|
19
19
|
export { useBlockResize } from './hooks/useBlockResize.js';
|
|
20
20
|
export { useBuzzPurchase } from './hooks/useBuzzPurchase.js';
|
|
21
21
|
export { useBuzzBalance } from './hooks/useBuzzBalance.js';
|
|
22
|
+
export { useViewer } from './hooks/useViewer.js';
|
|
22
23
|
export { useBuzzTransactions } from './hooks/useBuzzTransactions.js';
|
|
23
24
|
export { useBuzzAccounts } from './hooks/useBuzzAccounts.js';
|
|
24
25
|
export { useDailyCompensation } from './hooks/useDailyCompensation.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAG3F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAO3D,QAAQ;AACR,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAA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AC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAOzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -29,6 +29,12 @@ export declare class IframeTransport implements BlockTransport {
|
|
|
29
29
|
/** Messages queued before `BLOCK_INIT` lands. Flushed in arrival order. */
|
|
30
30
|
private readonly outbound;
|
|
31
31
|
private readonly pending;
|
|
32
|
+
/**
|
|
33
|
+
* Handlers for UNSOLICITED parent→block pushes (e.g. `IMAGE_SCAN_RESOLVED`) —
|
|
34
|
+
* messages the host initiates on its own schedule, NOT replies to a pending
|
|
35
|
+
* `sendRequest`. Keyed by message type; each entry a set of subscribers.
|
|
36
|
+
*/
|
|
37
|
+
private readonly pushListeners;
|
|
32
38
|
private readonly initPromise;
|
|
33
39
|
private resolveInit;
|
|
34
40
|
private rejectInit;
|
|
@@ -61,6 +67,7 @@ export declare class IframeTransport implements BlockTransport {
|
|
|
61
67
|
sendRequest(request: OutboundRequest, responseType: ParentToBlockMessageType, opts?: {
|
|
62
68
|
timeoutMs?: number;
|
|
63
69
|
}): Promise<unknown>;
|
|
70
|
+
onMessage(type: ParentToBlockMessageType, handler: (payload: unknown) => void): () => void;
|
|
64
71
|
/** Test-only: tear down listeners + reject pending. */
|
|
65
72
|
dispose(): void;
|
|
66
73
|
private dispatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframeTransport.d.ts","sourceRoot":"","sources":["../../src/internal/iframeTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAEzB,KAAK,wBAAwB,EAC9B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AASxB,MAAM,WAAW,sBAAsB;IACrC;;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AAgB,CAAC;IAIxC,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAIhD,WAAW,CACT,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,wBAAwB,EACtC,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAChC,OAAO,CAAC,OAAO,CAAC;IAmBnB,SAAS,CACP,IAAI,EAAE,wBAAwB,EAC9B,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAClC,MAAM,IAAI;IAeb,uDAAuD;IACvD,OAAO,IAAI,IAAI;IAYf,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,aAAa;IA2GrB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,IAAI;CAGb"}
|
|
@@ -20,6 +20,12 @@ export class IframeTransport {
|
|
|
20
20
|
/** Messages queued before `BLOCK_INIT` lands. Flushed in arrival order. */
|
|
21
21
|
outbound = [];
|
|
22
22
|
pending = new Map();
|
|
23
|
+
/**
|
|
24
|
+
* Handlers for UNSOLICITED parent→block pushes (e.g. `IMAGE_SCAN_RESOLVED`) —
|
|
25
|
+
* messages the host initiates on its own schedule, NOT replies to a pending
|
|
26
|
+
* `sendRequest`. Keyed by message type; each entry a set of subscribers.
|
|
27
|
+
*/
|
|
28
|
+
pushListeners = new Map();
|
|
23
29
|
initPromise;
|
|
24
30
|
resolveInit;
|
|
25
31
|
rejectInit;
|
|
@@ -106,6 +112,22 @@ export class IframeTransport {
|
|
|
106
112
|
this.dispatch(request.type, { ...request.payload, requestId });
|
|
107
113
|
});
|
|
108
114
|
}
|
|
115
|
+
onMessage(type, handler) {
|
|
116
|
+
let set = this.pushListeners.get(type);
|
|
117
|
+
if (!set) {
|
|
118
|
+
set = new Set();
|
|
119
|
+
this.pushListeners.set(type, set);
|
|
120
|
+
}
|
|
121
|
+
set.add(handler);
|
|
122
|
+
return () => {
|
|
123
|
+
const s = this.pushListeners.get(type);
|
|
124
|
+
if (!s)
|
|
125
|
+
return;
|
|
126
|
+
s.delete(handler);
|
|
127
|
+
if (s.size === 0)
|
|
128
|
+
this.pushListeners.delete(type);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
109
131
|
/** Test-only: tear down listeners + reject pending. */
|
|
110
132
|
dispose() {
|
|
111
133
|
this.window.removeEventListener('message', this.messageListener);
|
|
@@ -116,6 +138,7 @@ export class IframeTransport {
|
|
|
116
138
|
}
|
|
117
139
|
this.pending.clear();
|
|
118
140
|
this.listeners.clear();
|
|
141
|
+
this.pushListeners.clear();
|
|
119
142
|
}
|
|
120
143
|
dispatch(type, payload) {
|
|
121
144
|
if (!this.parentOrigin) {
|
|
@@ -209,6 +232,22 @@ export class IframeTransport {
|
|
|
209
232
|
pending.resolve(payload);
|
|
210
233
|
return;
|
|
211
234
|
}
|
|
235
|
+
// Unsolicited parent→block push (not a reply to any pending request) — e.g.
|
|
236
|
+
// `IMAGE_SCAN_RESOLVED`. Deliver to any handlers registered via `onMessage`.
|
|
237
|
+
// This runs ONLY AFTER the message has already CLEARED both the origin
|
|
238
|
+
// allowlist (`this.originMatcher.matches`) and the payload validator
|
|
239
|
+
// (`payloadValidatorFor`) at the top of `handleMessage` — it does NOT and
|
|
240
|
+
// must NOT bypass them. Do not reorder this ahead of those gates: a push from
|
|
241
|
+
// a disallowed origin, or a malformed payload, is dropped before it can reach
|
|
242
|
+
// here (locked by the origin-drop regression test in iframe-transport.test.ts).
|
|
243
|
+
// Reply-type messages that arrive without a matching pending have no push
|
|
244
|
+
// listeners, so they fall through to the no-op tail below unchanged.
|
|
245
|
+
const handlers = this.pushListeners.get(data.type);
|
|
246
|
+
if (handlers && handlers.size > 0) {
|
|
247
|
+
for (const handler of [...handlers])
|
|
248
|
+
handler(data.payload);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
212
251
|
if (isMessage(data, 'SUSPEND')) {
|
|
213
252
|
// Reserved for future lifecycle hooks; no-op in v1.
|
|
214
253
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframeTransport.js","sourceRoot":"","sources":["../../src/internal/iframeTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAKV,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAuB1C;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACT,aAAa,CAAgB;IAC7B,MAAM,CAAS;IAExB,QAAQ,GAAkB,cAAc,CAAC;IAChC,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAEnD,yEAAyE;IACjE,YAAY,GAAkB,IAAI,CAAC;IAE3C,2EAA2E;IAC1D,QAAQ,GAA8C,EAAE,CAAC;IACzD,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"iframeTransport.js","sourceRoot":"","sources":["../../src/internal/iframeTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAKV,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAuB1C;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACT,aAAa,CAAgB;IAC7B,MAAM,CAAS;I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qEAAqE;QACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAClC,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,QAAQ,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3D,OAAO;QACT,CAAC;QAED,IAAI,SAAS,CAAkC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;YAChE,oDAAoD;YACpD,OAAO;QACT,CAAC;QACD,IAAI,SAAS,CAAiC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC9D,OAAO;QACT,CAAC;IACH,CAAC;IAEO,iBAAiB,CAAC,OAAqB;QAC7C,wEAAwE;QACxE,sEAAsE;QACtE,qEAAqE;QACrE,6CAA6C;QAC7C,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAEO,IAAI;QACV,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS;YAAE,QAAQ,EAAE,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -21,5 +21,6 @@ export declare class InlineTransport implements BlockTransport {
|
|
|
21
21
|
sendRequest(_request: OutboundRequest, _responseType: ParentToBlockMessageType, _opts?: {
|
|
22
22
|
timeoutMs?: number;
|
|
23
23
|
}): Promise<unknown>;
|
|
24
|
+
onMessage(_type: ParentToBlockMessageType, _handler: (payload: unknown) => void): () => void;
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=inlineTransport.d.ts.map
|