@civitai/blocks-react 0.56.1 → 0.57.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 +32 -0
- package/dist/api/generationResources.d.ts +4 -3
- package/dist/hooks/returnTypeLedger.d.ts +2 -0
- package/dist/hooks/returnTypeLedger.js +2 -0
- package/dist/hooks/useAppStorage.js +2 -2
- package/dist/hooks/useAppWorkflows.d.ts +5 -2
- package/dist/hooks/useAppWorkflows.js +18 -7
- package/dist/hooks/useBlockAnalytics.d.ts +5 -3
- package/dist/hooks/useBlockAnalytics.js +1 -1
- package/dist/hooks/useBlockBreakpoint.d.ts +7 -1
- package/dist/hooks/useBlockContext.d.ts +13 -2
- package/dist/hooks/useBlockContext.js +1 -1
- package/dist/hooks/useBlockResize.d.ts +7 -1
- package/dist/hooks/useBlockResize.js +1 -1
- package/dist/hooks/useBlockSettings.d.ts +6 -1
- package/dist/hooks/useBlockTheme.d.ts +6 -1
- package/dist/hooks/useBlockToken.d.ts +8 -3
- package/dist/hooks/useBlockToken.js +2 -2
- package/dist/hooks/useBuzzAccounts.d.ts +3 -2
- package/dist/hooks/useBuzzAccounts.js +16 -15
- package/dist/hooks/useBuzzBalance.d.ts +3 -2
- package/dist/hooks/useBuzzBalance.js +16 -18
- package/dist/hooks/useBuzzPurchase.d.ts +8 -6
- package/dist/hooks/useBuzzPurchase.js +3 -3
- package/dist/hooks/useBuzzTransactions.d.ts +4 -2
- package/dist/hooks/useBuzzTransactions.js +16 -15
- package/dist/hooks/useBuzzWorkflow.d.ts +71 -28
- package/dist/hooks/useBuzzWorkflow.js +31 -17
- package/dist/hooks/useCheckpointPicker.d.ts +18 -16
- package/dist/hooks/useCheckpointPicker.js +3 -3
- package/dist/hooks/useCivitaiNavigate.d.ts +5 -3
- package/dist/hooks/useCivitaiNavigate.js +1 -1
- package/dist/hooks/useCollectionFollow.js +4 -4
- package/dist/hooks/useConsentUnavailable.js +2 -2
- package/dist/hooks/useCreatePostFromApp.js +4 -4
- package/dist/hooks/useDailyCompensation.d.ts +4 -2
- package/dist/hooks/useDailyCompensation.js +17 -15
- package/dist/hooks/useDirectLoad.d.ts +7 -1
- package/dist/hooks/useDirectLoad.js +1 -1
- package/dist/hooks/useDomainMaturity.d.ts +6 -2
- package/dist/hooks/useGatedImages.d.ts +8 -0
- package/dist/hooks/useGatedImages.js +10 -2
- package/dist/hooks/useGenerationResources.d.ts +5 -3
- package/dist/hooks/useHostOrigin.d.ts +7 -1
- package/dist/hooks/useHostOrigin.js +1 -1
- package/dist/hooks/useImageUpload.d.ts +44 -17
- package/dist/hooks/useImageUpload.js +24 -4
- package/dist/hooks/usePublishGenerationOutputs.js +4 -4
- package/dist/hooks/useRequestConsent.d.ts +7 -5
- package/dist/hooks/useRequestConsent.js +1 -1
- package/dist/hooks/useRequestSequencer.d.ts +71 -0
- package/dist/hooks/useRequestSequencer.js +28 -0
- package/dist/hooks/useRequestSignIn.d.ts +7 -5
- package/dist/hooks/useRequestSignIn.js +1 -1
- package/dist/hooks/useResourcePicker.d.ts +16 -14
- package/dist/hooks/useResourcePicker.js +3 -3
- package/dist/hooks/useSaveImage.js +2 -2
- package/dist/hooks/useSharedStorage.js +2 -2
- package/dist/hooks/useTip.js +1 -1
- package/dist/hooks/useTipAllowance.d.ts +13 -1
- package/dist/hooks/useTipAllowance.js +49 -11
- package/dist/hooks/useViewer.d.ts +3 -2
- package/dist/hooks/useViewer.js +16 -18
- package/dist/hooks/useWildcardPack.d.ts +3 -1
- package/dist/hooks/useWildcardPack.js +19 -14
- package/dist/index.d.ts +30 -14
- package/dist/index.js +7 -7
- package/dist/internal/consentRefusalLatch.d.ts +1 -1
- package/dist/internal/consentRefusalLatch.js +1 -1
- package/dist/internal/liveHost.d.ts +63 -11
- package/dist/internal/liveHost.js +240 -37
- package/dist/internal/mockHost.js +16 -15
- package/dist/internal/pickerOverlay.d.ts +52 -4
- package/dist/internal/pickerOverlay.js +14 -3
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/{internal → transport}/iframeTransport.d.ts +43 -5
- package/dist/{internal → transport}/iframeTransport.js +142 -12
- package/dist/transport/originMatcher.d.ts +92 -0
- package/dist/transport/originMatcher.js +222 -0
- package/dist/transport/requestId.d.ts +113 -0
- package/dist/transport/requestId.js +117 -0
- package/dist/{internal → transport}/validate.d.ts +34 -0
- package/dist/{internal → transport}/validate.js +189 -48
- package/dist/ui/BlockGate.js +1 -1
- package/dist/ui/SettingsForm.d.ts +8 -2
- package/dist/ui/SettingsForm.js +49 -3
- package/package.json +6 -4
- package/dist/api/generationResources.d.ts.map +0 -1
- package/dist/api/generationResources.js.map +0 -1
- package/dist/hooks/SfwGate.d.ts.map +0 -1
- package/dist/hooks/SfwGate.js.map +0 -1
- package/dist/hooks/useAppStorage.d.ts.map +0 -1
- package/dist/hooks/useAppStorage.js.map +0 -1
- package/dist/hooks/useAppWorkflows.d.ts.map +0 -1
- package/dist/hooks/useAppWorkflows.js.map +0 -1
- package/dist/hooks/useBlockAnalytics.d.ts.map +0 -1
- package/dist/hooks/useBlockAnalytics.js.map +0 -1
- package/dist/hooks/useBlockBreakpoint.d.ts.map +0 -1
- package/dist/hooks/useBlockBreakpoint.js.map +0 -1
- package/dist/hooks/useBlockContext.d.ts.map +0 -1
- package/dist/hooks/useBlockContext.js.map +0 -1
- package/dist/hooks/useBlockResize.d.ts.map +0 -1
- package/dist/hooks/useBlockResize.js.map +0 -1
- package/dist/hooks/useBlockSettings.d.ts.map +0 -1
- package/dist/hooks/useBlockSettings.js.map +0 -1
- package/dist/hooks/useBlockTheme.d.ts.map +0 -1
- package/dist/hooks/useBlockTheme.js.map +0 -1
- package/dist/hooks/useBlockToken.d.ts.map +0 -1
- package/dist/hooks/useBlockToken.js.map +0 -1
- package/dist/hooks/useBuzzAccounts.d.ts.map +0 -1
- package/dist/hooks/useBuzzAccounts.js.map +0 -1
- package/dist/hooks/useBuzzBalance.d.ts.map +0 -1
- package/dist/hooks/useBuzzBalance.js.map +0 -1
- package/dist/hooks/useBuzzPurchase.d.ts.map +0 -1
- package/dist/hooks/useBuzzPurchase.js.map +0 -1
- package/dist/hooks/useBuzzTransactions.d.ts.map +0 -1
- package/dist/hooks/useBuzzTransactions.js.map +0 -1
- package/dist/hooks/useBuzzWorkflow.d.ts.map +0 -1
- package/dist/hooks/useBuzzWorkflow.js.map +0 -1
- package/dist/hooks/useCheckpointPicker.d.ts.map +0 -1
- package/dist/hooks/useCheckpointPicker.js.map +0 -1
- package/dist/hooks/useCivitaiNavigate.d.ts.map +0 -1
- package/dist/hooks/useCivitaiNavigate.js.map +0 -1
- package/dist/hooks/useCollectionFollow.d.ts.map +0 -1
- package/dist/hooks/useCollectionFollow.js.map +0 -1
- package/dist/hooks/useConsentUnavailable.d.ts.map +0 -1
- package/dist/hooks/useConsentUnavailable.js.map +0 -1
- package/dist/hooks/useCreatePostFromApp.d.ts.map +0 -1
- package/dist/hooks/useCreatePostFromApp.js.map +0 -1
- package/dist/hooks/useDailyCompensation.d.ts.map +0 -1
- package/dist/hooks/useDailyCompensation.js.map +0 -1
- package/dist/hooks/useDirectLoad.d.ts.map +0 -1
- package/dist/hooks/useDirectLoad.js.map +0 -1
- package/dist/hooks/useDomainMaturity.d.ts.map +0 -1
- package/dist/hooks/useDomainMaturity.js.map +0 -1
- package/dist/hooks/useGatedImages.d.ts.map +0 -1
- package/dist/hooks/useGatedImages.js.map +0 -1
- package/dist/hooks/useGenerationResources.d.ts.map +0 -1
- package/dist/hooks/useGenerationResources.js.map +0 -1
- package/dist/hooks/useHostOrigin.d.ts.map +0 -1
- package/dist/hooks/useHostOrigin.js.map +0 -1
- package/dist/hooks/useImageUpload.d.ts.map +0 -1
- package/dist/hooks/useImageUpload.js.map +0 -1
- package/dist/hooks/usePublishGenerationOutputs.d.ts.map +0 -1
- package/dist/hooks/usePublishGenerationOutputs.js.map +0 -1
- package/dist/hooks/useRequestConsent.d.ts.map +0 -1
- package/dist/hooks/useRequestConsent.js.map +0 -1
- package/dist/hooks/useRequestSignIn.d.ts.map +0 -1
- package/dist/hooks/useRequestSignIn.js.map +0 -1
- package/dist/hooks/useResourcePicker.d.ts.map +0 -1
- package/dist/hooks/useResourcePicker.js.map +0 -1
- package/dist/hooks/useSaveImage.d.ts.map +0 -1
- package/dist/hooks/useSaveImage.js.map +0 -1
- package/dist/hooks/useSharedStorage.d.ts.map +0 -1
- package/dist/hooks/useSharedStorage.js.map +0 -1
- package/dist/hooks/useTip.d.ts.map +0 -1
- package/dist/hooks/useTip.js.map +0 -1
- package/dist/hooks/useTipAllowance.d.ts.map +0 -1
- package/dist/hooks/useTipAllowance.js.map +0 -1
- package/dist/hooks/useViewer.d.ts.map +0 -1
- package/dist/hooks/useViewer.js.map +0 -1
- package/dist/hooks/useWildcardPack.d.ts.map +0 -1
- package/dist/hooks/useWildcardPack.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/catalog.d.ts.map +0 -1
- package/dist/internal/catalog.js.map +0 -1
- package/dist/internal/consent.d.ts.map +0 -1
- package/dist/internal/consent.js.map +0 -1
- package/dist/internal/consentRefusalLatch.d.ts.map +0 -1
- package/dist/internal/consentRefusalLatch.js.map +0 -1
- package/dist/internal/detector.d.ts.map +0 -1
- package/dist/internal/detector.js.map +0 -1
- package/dist/internal/directLoad.d.ts.map +0 -1
- package/dist/internal/directLoad.js.map +0 -1
- package/dist/internal/iframeTransport.d.ts.map +0 -1
- package/dist/internal/iframeTransport.js.map +0 -1
- package/dist/internal/inlineTransport.d.ts.map +0 -1
- package/dist/internal/inlineTransport.js.map +0 -1
- package/dist/internal/liveHost.d.ts.map +0 -1
- package/dist/internal/liveHost.js.map +0 -1
- package/dist/internal/mockHost.d.ts.map +0 -1
- package/dist/internal/mockHost.js.map +0 -1
- package/dist/internal/originMatcher.d.ts +0 -28
- package/dist/internal/originMatcher.d.ts.map +0 -1
- package/dist/internal/originMatcher.js +0 -89
- package/dist/internal/originMatcher.js.map +0 -1
- package/dist/internal/pickerOverlay.d.ts.map +0 -1
- package/dist/internal/pickerOverlay.js.map +0 -1
- package/dist/internal/replyError.d.ts.map +0 -1
- package/dist/internal/replyError.js.map +0 -1
- package/dist/internal/requestTimeouts.d.ts.map +0 -1
- package/dist/internal/requestTimeouts.js.map +0 -1
- package/dist/internal/singleton.d.ts.map +0 -1
- package/dist/internal/singleton.js.map +0 -1
- package/dist/internal/transport.d.ts.map +0 -1
- package/dist/internal/transport.js.map +0 -1
- package/dist/internal/validate.d.ts.map +0 -1
- package/dist/internal/validate.js.map +0 -1
- package/dist/live.d.ts.map +0 -1
- package/dist/live.js.map +0 -1
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js.map +0 -1
- package/dist/ui/Alert.d.ts.map +0 -1
- package/dist/ui/Alert.js.map +0 -1
- package/dist/ui/Badge.d.ts.map +0 -1
- package/dist/ui/Badge.js.map +0 -1
- package/dist/ui/BlockGate.d.ts.map +0 -1
- package/dist/ui/BlockGate.js.map +0 -1
- package/dist/ui/Button.d.ts.map +0 -1
- package/dist/ui/Button.js.map +0 -1
- package/dist/ui/Card.d.ts.map +0 -1
- package/dist/ui/Card.js.map +0 -1
- package/dist/ui/Collapse.d.ts.map +0 -1
- package/dist/ui/Collapse.js.map +0 -1
- package/dist/ui/FollowButton.d.ts.map +0 -1
- package/dist/ui/FollowButton.js.map +0 -1
- package/dist/ui/Group.d.ts.map +0 -1
- package/dist/ui/Group.js.map +0 -1
- package/dist/ui/Loader.d.ts.map +0 -1
- package/dist/ui/Loader.js.map +0 -1
- package/dist/ui/Modal.d.ts.map +0 -1
- package/dist/ui/Modal.js.map +0 -1
- package/dist/ui/NumberInput.d.ts.map +0 -1
- package/dist/ui/NumberInput.js.map +0 -1
- package/dist/ui/ReportButton.d.ts.map +0 -1
- package/dist/ui/ReportButton.js.map +0 -1
- package/dist/ui/ResourceCard.d.ts.map +0 -1
- package/dist/ui/ResourceCard.js.map +0 -1
- package/dist/ui/SegmentedControl.d.ts.map +0 -1
- package/dist/ui/SegmentedControl.js.map +0 -1
- package/dist/ui/Select.d.ts.map +0 -1
- package/dist/ui/Select.js.map +0 -1
- package/dist/ui/SettingsForm.d.ts.map +0 -1
- package/dist/ui/SettingsForm.js.map +0 -1
- package/dist/ui/Slider.d.ts.map +0 -1
- package/dist/ui/Slider.js.map +0 -1
- package/dist/ui/Stack.d.ts.map +0 -1
- package/dist/ui/Stack.js.map +0 -1
- package/dist/ui/TextInput.d.ts.map +0 -1
- package/dist/ui/TextInput.js.map +0 -1
- package/dist/ui/Textarea.d.ts.map +0 -1
- package/dist/ui/Textarea.js.map +0 -1
- package/dist/ui/TipButton.d.ts.map +0 -1
- package/dist/ui/TipButton.js.map +0 -1
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/styles.d.ts.map +0 -1
- package/dist/ui/styles.js.map +0 -1
- /package/dist/{internal → transport}/detector.d.ts +0 -0
- /package/dist/{internal → transport}/detector.js +0 -0
- /package/dist/{internal → transport}/directLoad.d.ts +0 -0
- /package/dist/{internal → transport}/directLoad.js +0 -0
- /package/dist/{internal → transport}/inlineTransport.d.ts +0 -0
- /package/dist/{internal → transport}/inlineTransport.js +0 -0
- /package/dist/{internal → transport}/requestTimeouts.d.ts +0 -0
- /package/dist/{internal → transport}/requestTimeouts.js +0 -0
- /package/dist/{internal → transport}/singleton.d.ts +0 -0
- /package/dist/{internal → transport}/singleton.js +0 -0
- /package/dist/{internal → transport}/transport.d.ts +0 -0
- /package/dist/{internal → transport}/transport.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BlockWorkflowSnapshot, WorkflowBody, WorkflowStatus } from '@civitai/app-sdk/blocks';
|
|
2
2
|
/**
|
|
3
|
-
* Default orchestrator-side hold per {@link
|
|
3
|
+
* Default orchestrator-side hold per {@link UseBuzzWorkflow.watch} poll,
|
|
4
4
|
* in SECONDS.
|
|
5
5
|
*
|
|
6
6
|
* 🔴 THE UNIT IS SECONDS, matching the orchestrator's `?wait=` parameter — not
|
|
@@ -16,9 +16,15 @@ import type { BlockWorkflowSnapshot, WorkflowBody, WorkflowStatus } from '@civit
|
|
|
16
16
|
* its own ~12s ceiling, and the two are SEQUENTIAL — so the round trip's
|
|
17
17
|
* worst case is 15 + 12 = 27s, which must stay inside the host's own
|
|
18
18
|
* end-to-end response budget.
|
|
19
|
+
*
|
|
20
|
+
* 🔴 AND THE HOST ENFORCES THAT SAME 15 (#388) — `MAX_BLOCK_POLL_WAIT_SECONDS`
|
|
21
|
+
* in `civitai/civitai` @ `b0eb2820b5`. This default therefore sits exactly AT
|
|
22
|
+
* the host's cap, not under it: raising it here changes nothing on the wire,
|
|
23
|
+
* because the host clamps. See {@link WatchWorkflowOptions.waitSeconds} for the
|
|
24
|
+
* full measured contract, including the flooring.
|
|
19
25
|
*/
|
|
20
26
|
export declare const DEFAULT_WATCH_WAIT_SECONDS = 15;
|
|
21
|
-
/** Optional controls for {@link
|
|
27
|
+
/** Optional controls for {@link UseBuzzWorkflow.watch}. */
|
|
22
28
|
export interface WatchWorkflowOptions {
|
|
23
29
|
/**
|
|
24
30
|
* Called with EVERY snapshot the host returns, intermediate ones included, in
|
|
@@ -35,18 +41,48 @@ export interface WatchWorkflowOptions {
|
|
|
35
41
|
*
|
|
36
42
|
* 🔴 This does NOT cancel the workflow — it stops watching it. Buzz is already
|
|
37
43
|
* spent and the orchestrator keeps running. To actually stop the work, call
|
|
38
|
-
* {@link
|
|
44
|
+
* {@link UseBuzzWorkflow.cancel}.
|
|
39
45
|
*/
|
|
40
46
|
signal?: AbortSignal;
|
|
41
47
|
/**
|
|
42
48
|
* Orchestrator-side hold per poll, in **seconds**. Default
|
|
43
|
-
* {@link DEFAULT_WATCH_WAIT_SECONDS}.
|
|
44
|
-
*
|
|
49
|
+
* {@link DEFAULT_WATCH_WAIT_SECONDS}.
|
|
50
|
+
*
|
|
51
|
+
* 🔴 THE HOST HONOURS AND CLAMPS THIS — it is NOT advisory (#388). This
|
|
52
|
+
* docblock said "CURRENTLY ADVISORY … a host that does not yet read the field
|
|
53
|
+
* simply answers immediately, exactly as today", which was true when written
|
|
54
|
+
* and is not true of the deployed host. The contract, read off
|
|
55
|
+
* `civitai/civitai` at **`b0eb2820b5`** (5.1.120, `main`) — two files,
|
|
56
|
+
* because a constant that nothing calls is not a contract:
|
|
57
|
+
*
|
|
58
|
+
* - `src/server/services/blocks/workflow.service.ts:1263` declares
|
|
59
|
+
* `MAX_BLOCK_POLL_WAIT_SECONDS = 15`.
|
|
60
|
+
* - `:1286-1292` `resolveBlockPollWaitSeconds(waitSeconds?: number)` applies
|
|
61
|
+
* it, and `src/server/routers/blocks.router.ts:3965` is the call site.
|
|
45
62
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
63
|
+
* What that function does, in its own order:
|
|
64
|
+
* 1. a non-`number` or non-finite value → `undefined`, i.e. NO HOLD.
|
|
65
|
+
* 2. `Math.floor` FIRST. `0.9` is therefore not "a short hold" — it floors
|
|
66
|
+
* to `0` and becomes no hold at all, which the host's own comment calls
|
|
67
|
+
* out explicitly.
|
|
68
|
+
* 3. floored `<= 0` → `undefined` (no hold). So `0` — and any fraction
|
|
69
|
+
* below 1 — disables long polling and `watch` falls back to a plain read
|
|
70
|
+
* per `intervalMs`.
|
|
71
|
+
* 4. otherwise `Math.min(floored, 15)`. Asking for 60 gets you 15.
|
|
72
|
+
*
|
|
73
|
+
* Consequences worth planning for: only whole seconds are expressible, and no
|
|
74
|
+
* value above `MAX_BLOCK_POLL_WAIT_SECONDS` buys anything — `intervalMs` is
|
|
75
|
+
* still what bounds request rate, because a clamped hold returns sooner than
|
|
76
|
+
* the caller asked for.
|
|
77
|
+
*
|
|
78
|
+
* 🔴 THIS IS PROSE ABOUT ANOTHER REPO, AND NO GUARD IN THIS ONE CAN CHECK IT.
|
|
79
|
+
* The host checkout is not present in CI, so the honest check is a human
|
|
80
|
+
* reading the two files above at a named revision — which is why the sha is
|
|
81
|
+
* quoted rather than "as of today". A later reader comparing against a newer
|
|
82
|
+
* host should update the sha along with whatever moved. The `POLL_WORKFLOW`
|
|
83
|
+
* field's own note on `BlockToParentMessage` in `@civitai/app-sdk` covers the
|
|
84
|
+
* wire shape and the older-host case; this covers what the current host does
|
|
85
|
+
* with the value.
|
|
50
86
|
*/
|
|
51
87
|
waitSeconds?: number;
|
|
52
88
|
/**
|
|
@@ -72,7 +108,7 @@ export interface WatchWorkflowOptions {
|
|
|
72
108
|
maxRetries?: number;
|
|
73
109
|
}
|
|
74
110
|
/**
|
|
75
|
-
* Thrown by {@link
|
|
111
|
+
* Thrown by {@link UseBuzzWorkflow.estimate} when the host's reply does not
|
|
76
112
|
* carry a usable price — either because the estimate ERRORED, or because it came
|
|
77
113
|
* back without a numeric `cost.total`.
|
|
78
114
|
*
|
|
@@ -193,12 +229,12 @@ export declare class WorkflowEstimateError extends Error {
|
|
|
193
229
|
constructor(snapshot: BlockWorkflowSnapshot, code: 'failed' | 'no-cost');
|
|
194
230
|
}
|
|
195
231
|
/**
|
|
196
|
-
* Why {@link
|
|
232
|
+
* Why {@link UseBuzzWorkflow.submit} rejected. **The two differ on whether
|
|
197
233
|
* money may already have moved** — see {@link WorkflowSubmitError.code}.
|
|
198
234
|
*/
|
|
199
235
|
export type WorkflowSubmitErrorCode = 'exception' | 'workflow-failed';
|
|
200
236
|
/**
|
|
201
|
-
* Thrown by {@link
|
|
237
|
+
* Thrown by {@link UseBuzzWorkflow.submit} when the host's reply carries no
|
|
202
238
|
* usable workflow outcome — either the submit ERRORED before anything was queued,
|
|
203
239
|
* or a workflow-shaped reply came back already failed with no price.
|
|
204
240
|
*
|
|
@@ -334,7 +370,7 @@ export declare class WorkflowSubmitError extends Error {
|
|
|
334
370
|
* `'whatif'` lands here — correctly, because the cautious money reading still
|
|
335
371
|
* applies — but there is nothing to poll. Guard with
|
|
336
372
|
* `err.snapshot.workflowId !== 'whatif'` before calling
|
|
337
|
-
* {@link
|
|
373
|
+
* {@link UseBuzzWorkflow.watch} / {@link UseBuzzWorkflow.poll} to
|
|
338
374
|
* learn the workflow's actual fate before spending again.
|
|
339
375
|
*
|
|
340
376
|
* A union rather than a boolean so a future producer gets its own code without
|
|
@@ -372,7 +408,7 @@ export interface SubmitWorkflowOptions {
|
|
|
372
408
|
*/
|
|
373
409
|
idempotencyKey?: string;
|
|
374
410
|
}
|
|
375
|
-
interface
|
|
411
|
+
export interface UseBuzzWorkflow {
|
|
376
412
|
/**
|
|
377
413
|
* Price a workflow without queueing it. Resolves ONLY with a snapshot that
|
|
378
414
|
* carries a numeric `cost.total`.
|
|
@@ -436,7 +472,7 @@ interface UseBuzzWorkflowReturn {
|
|
|
436
472
|
submit: (body: WorkflowBody, options?: SubmitWorkflowOptions) => Promise<BlockWorkflowSnapshot>;
|
|
437
473
|
/**
|
|
438
474
|
* ONE host round-trip. The low-level pull primitive — you almost certainly
|
|
439
|
-
* want {@link
|
|
475
|
+
* want {@link UseBuzzWorkflow.watch} instead, which owns the loop.
|
|
440
476
|
*/
|
|
441
477
|
poll: (workflowId: string) => Promise<BlockWorkflowSnapshot>;
|
|
442
478
|
/**
|
|
@@ -444,7 +480,7 @@ interface UseBuzzWorkflowReturn {
|
|
|
444
480
|
* `onUpdate` with every intermediate snapshot along the way.
|
|
445
481
|
*
|
|
446
482
|
* This is the replacement for the `useEffect` + `setTimeout` backoff every
|
|
447
|
-
* block used to hand-write around {@link
|
|
483
|
+
* block used to hand-write around {@link UseBuzzWorkflow.poll}. The app
|
|
448
484
|
* consumes a promise and/or a callback; the loop lives here.
|
|
449
485
|
*
|
|
450
486
|
* 🔴 THE LOOP IS SEQUENTIAL AND NON-OVERLAPPING BY CONSTRUCTION — each poll is
|
|
@@ -507,16 +543,23 @@ interface UseBuzzWorkflowReturn {
|
|
|
507
543
|
* enabled.
|
|
508
544
|
*
|
|
509
545
|
* `estimate`/`submit` take a full {@link WorkflowBody} — the discriminated
|
|
510
|
-
* union keyed by `kind`,
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
546
|
+
* union keyed by `kind`, never a bare `{ prompt }`. The hook forwards the body
|
|
547
|
+
* to the host verbatim and never reads variant-specific fields, so every member
|
|
548
|
+
* flows through unchanged, including any member added later.
|
|
549
|
+
*
|
|
550
|
+
* 🔴 THIS COMMENT DELIBERATELY DOES NOT SAY HOW MANY MEMBERS THERE ARE, OR NAME
|
|
551
|
+
* THEM (#381). It used to open "with THREE members as of
|
|
552
|
+
* `@civitai/app-sdk@0.30.0`" and close by certifying the list "otherwise
|
|
553
|
+
* unchanged" — while the union had FOUR, `WorkflowBodyPassThroughStep` having
|
|
554
|
+
* arrived in 583e8ba (#310). The sentence whose only job was to vouch for the
|
|
555
|
+
* list was the sentence that went stale. `{@link WorkflowBody}`'s own docblock
|
|
556
|
+
* is the single description of the member set; the machine-checked copy is
|
|
557
|
+
* {@link WorkflowBodyArms} below, which fails `tsc` when the union changes in
|
|
558
|
+
* either direction. A count re-typed here could only ever repeat the defect.
|
|
517
559
|
*
|
|
518
560
|
* 🔴 `customComfy` IS ITSELF A UNION, on `mode` — an app CAN ship its own
|
|
519
|
-
* ComfyUI graph
|
|
561
|
+
* ComfyUI graph, which is a CAPABILITY claim, not a member count, and so is
|
|
562
|
+
* stated here. `WorkflowBodyCustomComfyRecipe` (`mode` omitted or `'recipe'`)
|
|
520
563
|
* names a server-registered recipe; `WorkflowBodyCustomComfyInline`
|
|
521
564
|
* (`mode: 'inline'`) carries the graph itself, plus its declared AIR
|
|
522
565
|
* `resources` and a `maxBuzz` bound. The inline arm is LIVE in production
|
|
@@ -524,8 +567,9 @@ interface UseBuzzWorkflowReturn {
|
|
|
524
567
|
* recipe-only `{ kind, recipe, params }` shape — written when that was true and
|
|
525
568
|
* never revisited once the arm shipped. A developer working against the live
|
|
526
569
|
* feature read the equivalent claim on the type, believed it over their own
|
|
527
|
-
* instinct, and concluded the capability did not exist.
|
|
528
|
-
*
|
|
570
|
+
* instinct, and concluded the capability did not exist. That is the SAME defect
|
|
571
|
+
* the paragraph above records, one member over: an incomplete description of a
|
|
572
|
+
* union, trusted because it read as authoritative.
|
|
529
573
|
*
|
|
530
574
|
* @returns `{ estimate, submit, poll, watch, cancel, status, result, error }`.
|
|
531
575
|
*
|
|
@@ -590,6 +634,5 @@ interface UseBuzzWorkflowReturn {
|
|
|
590
634
|
* }
|
|
591
635
|
* }
|
|
592
636
|
*/
|
|
593
|
-
export declare function useBuzzWorkflow():
|
|
594
|
-
export {};
|
|
637
|
+
export declare function useBuzzWorkflow(): UseBuzzWorkflow;
|
|
595
638
|
//# sourceMappingURL=useBuzzWorkflow.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react';
|
|
2
|
-
import { getTransport } from '../
|
|
3
|
-
import { generateIdempotencyKey, sendTypedRequest } from '../
|
|
2
|
+
import { getTransport } from '../transport/singleton.js';
|
|
3
|
+
import { generateIdempotencyKey, sendTypedRequest } from '../transport/transport.js';
|
|
4
4
|
/**
|
|
5
5
|
* Snapshot statuses that mean "no further polling is needed."
|
|
6
6
|
* Used by both `submit` (a host can return an instant-fail / cached result)
|
|
@@ -25,7 +25,7 @@ const TERMINAL_STATUSES = new Set([
|
|
|
25
25
|
*/
|
|
26
26
|
const WORKFLOW_REQUEST_TIMEOUT_MS = 120_000;
|
|
27
27
|
/**
|
|
28
|
-
* Default orchestrator-side hold per {@link
|
|
28
|
+
* Default orchestrator-side hold per {@link UseBuzzWorkflow.watch} poll,
|
|
29
29
|
* in SECONDS.
|
|
30
30
|
*
|
|
31
31
|
* 🔴 THE UNIT IS SECONDS, matching the orchestrator's `?wait=` parameter — not
|
|
@@ -41,6 +41,12 @@ const WORKFLOW_REQUEST_TIMEOUT_MS = 120_000;
|
|
|
41
41
|
* its own ~12s ceiling, and the two are SEQUENTIAL — so the round trip's
|
|
42
42
|
* worst case is 15 + 12 = 27s, which must stay inside the host's own
|
|
43
43
|
* end-to-end response budget.
|
|
44
|
+
*
|
|
45
|
+
* 🔴 AND THE HOST ENFORCES THAT SAME 15 (#388) — `MAX_BLOCK_POLL_WAIT_SECONDS`
|
|
46
|
+
* in `civitai/civitai` @ `b0eb2820b5`. This default therefore sits exactly AT
|
|
47
|
+
* the host's cap, not under it: raising it here changes nothing on the wire,
|
|
48
|
+
* because the host clamps. See {@link WatchWorkflowOptions.waitSeconds} for the
|
|
49
|
+
* full measured contract, including the flooring.
|
|
44
50
|
*/
|
|
45
51
|
export const DEFAULT_WATCH_WAIT_SECONDS = 15;
|
|
46
52
|
/** Gap between `watch` polls, in ms. See {@link WatchWorkflowOptions.intervalMs}. */
|
|
@@ -73,7 +79,7 @@ function sleep(ms, signal) {
|
|
|
73
79
|
});
|
|
74
80
|
}
|
|
75
81
|
/**
|
|
76
|
-
* Thrown by {@link
|
|
82
|
+
* Thrown by {@link UseBuzzWorkflow.estimate} when the host's reply does not
|
|
77
83
|
* carry a usable price — either because the estimate ERRORED, or because it came
|
|
78
84
|
* back without a numeric `cost.total`.
|
|
79
85
|
*
|
|
@@ -244,7 +250,7 @@ export class WorkflowEstimateError extends Error {
|
|
|
244
250
|
*/
|
|
245
251
|
const HOST_SYNTHESISED_WORKFLOW_ID = 'failed';
|
|
246
252
|
/**
|
|
247
|
-
* Thrown by {@link
|
|
253
|
+
* Thrown by {@link UseBuzzWorkflow.submit} when the host's reply carries no
|
|
248
254
|
* usable workflow outcome — either the submit ERRORED before anything was queued,
|
|
249
255
|
* or a workflow-shaped reply came back already failed with no price.
|
|
250
256
|
*
|
|
@@ -380,7 +386,7 @@ export class WorkflowSubmitError extends Error {
|
|
|
380
386
|
* `'whatif'` lands here — correctly, because the cautious money reading still
|
|
381
387
|
* applies — but there is nothing to poll. Guard with
|
|
382
388
|
* `err.snapshot.workflowId !== 'whatif'` before calling
|
|
383
|
-
* {@link
|
|
389
|
+
* {@link UseBuzzWorkflow.watch} / {@link UseBuzzWorkflow.poll} to
|
|
384
390
|
* learn the workflow's actual fate before spending again.
|
|
385
391
|
*
|
|
386
392
|
* A union rather than a boolean so a future producer gets its own code without
|
|
@@ -452,16 +458,23 @@ export class WorkflowSubmitError extends Error {
|
|
|
452
458
|
* enabled.
|
|
453
459
|
*
|
|
454
460
|
* `estimate`/`submit` take a full {@link WorkflowBody} — the discriminated
|
|
455
|
-
* union keyed by `kind`,
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
461
|
+
* union keyed by `kind`, never a bare `{ prompt }`. The hook forwards the body
|
|
462
|
+
* to the host verbatim and never reads variant-specific fields, so every member
|
|
463
|
+
* flows through unchanged, including any member added later.
|
|
464
|
+
*
|
|
465
|
+
* 🔴 THIS COMMENT DELIBERATELY DOES NOT SAY HOW MANY MEMBERS THERE ARE, OR NAME
|
|
466
|
+
* THEM (#381). It used to open "with THREE members as of
|
|
467
|
+
* `@civitai/app-sdk@0.30.0`" and close by certifying the list "otherwise
|
|
468
|
+
* unchanged" — while the union had FOUR, `WorkflowBodyPassThroughStep` having
|
|
469
|
+
* arrived in 583e8ba (#310). The sentence whose only job was to vouch for the
|
|
470
|
+
* list was the sentence that went stale. `{@link WorkflowBody}`'s own docblock
|
|
471
|
+
* is the single description of the member set; the machine-checked copy is
|
|
472
|
+
* {@link WorkflowBodyArms} below, which fails `tsc` when the union changes in
|
|
473
|
+
* either direction. A count re-typed here could only ever repeat the defect.
|
|
462
474
|
*
|
|
463
475
|
* 🔴 `customComfy` IS ITSELF A UNION, on `mode` — an app CAN ship its own
|
|
464
|
-
* ComfyUI graph
|
|
476
|
+
* ComfyUI graph, which is a CAPABILITY claim, not a member count, and so is
|
|
477
|
+
* stated here. `WorkflowBodyCustomComfyRecipe` (`mode` omitted or `'recipe'`)
|
|
465
478
|
* names a server-registered recipe; `WorkflowBodyCustomComfyInline`
|
|
466
479
|
* (`mode: 'inline'`) carries the graph itself, plus its declared AIR
|
|
467
480
|
* `resources` and a `maxBuzz` bound. The inline arm is LIVE in production
|
|
@@ -469,8 +482,9 @@ export class WorkflowSubmitError extends Error {
|
|
|
469
482
|
* recipe-only `{ kind, recipe, params }` shape — written when that was true and
|
|
470
483
|
* never revisited once the arm shipped. A developer working against the live
|
|
471
484
|
* feature read the equivalent claim on the type, believed it over their own
|
|
472
|
-
* instinct, and concluded the capability did not exist.
|
|
473
|
-
*
|
|
485
|
+
* instinct, and concluded the capability did not exist. That is the SAME defect
|
|
486
|
+
* the paragraph above records, one member over: an incomplete description of a
|
|
487
|
+
* union, trusted because it read as authoritative.
|
|
474
488
|
*
|
|
475
489
|
* @returns `{ estimate, submit, poll, watch, cancel, status, result, error }`.
|
|
476
490
|
*
|
|
@@ -669,7 +683,7 @@ export function useBuzzWorkflow() {
|
|
|
669
683
|
//
|
|
670
684
|
// 🔴 NOT CLAIMED TO BE REACHABLE THROUGH `IframeTransport`, WHICH ALREADY
|
|
671
685
|
// FAIL-CLOSES THIS. Its `payloadValidatorFor('WORKFLOW_STATUS')`
|
|
672
|
-
// (
|
|
686
|
+
// (transport/validate.ts) drops a reply whose `snapshot.status` is absent
|
|
673
687
|
// or outside the known set, so the request never resolves at all and
|
|
674
688
|
// times out instead. This guard covers the OTHER transports
|
|
675
689
|
// `sendTypedRequest` accepts (mock/test hosts, `dev:live`), and is kept as
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import type { BlockCheckpointInfo } from '@civitai/app-sdk/blocks';
|
|
2
|
+
/** What {@link useCheckpointPicker} returns. */
|
|
3
|
+
export interface UseCheckpointPicker {
|
|
4
|
+
open: (opts: {
|
|
5
|
+
/**
|
|
6
|
+
* Ecosystem key (e.g. 'Flux1', 'SDXL'). Get it from
|
|
7
|
+
* `useBlockContext().context.checkpoint?.baseModel` — but for the
|
|
8
|
+
* picker filter the host will collapse to the ecosystem family, so
|
|
9
|
+
* any baseModel in the family works as a hint.
|
|
10
|
+
*/
|
|
11
|
+
baseModelGroup: string;
|
|
12
|
+
/** Currently-selected versionId so the picker can pre-highlight it. */
|
|
13
|
+
currentVersionId?: number;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
selected?: BlockCheckpointInfo;
|
|
16
|
+
}>;
|
|
17
|
+
persist: (versionId: number | null) => Promise<void>;
|
|
18
|
+
}
|
|
2
19
|
/**
|
|
3
20
|
* Drives the platform-side Checkpoint picker and the persist-override flow.
|
|
4
21
|
*
|
|
@@ -20,20 +37,5 @@ import type { BlockCheckpointInfo } from '@civitai/app-sdk/blocks';
|
|
|
20
37
|
* const { selected } = await open({ baseModelGroup: 'SDXL', currentVersionId });
|
|
21
38
|
* if (selected) await persist(selected.versionId); // null clears the override
|
|
22
39
|
*/
|
|
23
|
-
export declare function useCheckpointPicker():
|
|
24
|
-
open: (opts: {
|
|
25
|
-
/**
|
|
26
|
-
* Ecosystem key (e.g. 'Flux1', 'SDXL'). Get it from
|
|
27
|
-
* `useBlockContext().context.checkpoint?.baseModel` — but for the
|
|
28
|
-
* picker filter the host will collapse to the ecosystem family, so
|
|
29
|
-
* any baseModel in the family works as a hint.
|
|
30
|
-
*/
|
|
31
|
-
baseModelGroup: string;
|
|
32
|
-
/** Currently-selected versionId so the picker can pre-highlight it. */
|
|
33
|
-
currentVersionId?: number;
|
|
34
|
-
}) => Promise<{
|
|
35
|
-
selected?: BlockCheckpointInfo;
|
|
36
|
-
}>;
|
|
37
|
-
persist: (versionId: number | null) => Promise<void>;
|
|
38
|
-
};
|
|
40
|
+
export declare function useCheckpointPicker(): UseCheckpointPicker;
|
|
39
41
|
//# sourceMappingURL=useCheckpointPicker.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import { HUMAN_INTERACTION_TIMEOUT_MS } from '../
|
|
2
|
+
import { HUMAN_INTERACTION_TIMEOUT_MS } from '../transport/requestTimeouts.js';
|
|
3
3
|
import { throwOnFailedReply } from '../internal/replyError.js';
|
|
4
|
-
import { getTransport } from '../
|
|
5
|
-
import { sendTypedRequest } from '../
|
|
4
|
+
import { getTransport } from '../transport/singleton.js';
|
|
5
|
+
import { sendTypedRequest } from '../transport/transport.js';
|
|
6
6
|
/**
|
|
7
7
|
* Drives the platform-side Checkpoint picker and the persist-override flow.
|
|
8
8
|
*
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** What {@link useCivitaiNavigate} returns. */
|
|
2
|
+
export interface UseCivitaiNavigate {
|
|
3
|
+
navigate: (path: string, target?: 'current' | 'new_tab') => void;
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* Requests a navigation within civitai.com. The host mediates — `target:
|
|
3
7
|
* "current"` navigates the parent frame; `"new_tab"` opens a new tab (which
|
|
@@ -9,7 +13,5 @@
|
|
|
9
13
|
* const { navigate } = useCivitaiNavigate();
|
|
10
14
|
* navigate('/models/12345', 'new_tab'); // 'new_tab' needs allow-popups* in the manifest sandbox
|
|
11
15
|
*/
|
|
12
|
-
export declare function useCivitaiNavigate():
|
|
13
|
-
navigate: (path: string, target?: 'current' | 'new_tab') => void;
|
|
14
|
-
};
|
|
16
|
+
export declare function useCivitaiNavigate(): UseCivitaiNavigate;
|
|
15
17
|
//# sourceMappingURL=useCivitaiNavigate.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import { getTransport } from '../
|
|
2
|
+
import { getTransport } from '../transport/singleton.js';
|
|
3
3
|
/**
|
|
4
4
|
* Requests a navigation within civitai.com. The host mediates — `target:
|
|
5
5
|
* "current"` navigates the parent frame; `"new_tab"` opens a new tab (which
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { HUMAN_INTERACTION_TIMEOUT_MS } from '../
|
|
3
|
-
import { getTransport } from '../
|
|
4
|
-
import { RequestTimeoutError, sendTypedRequest } from '../
|
|
2
|
+
import { HUMAN_INTERACTION_TIMEOUT_MS } from '../transport/requestTimeouts.js';
|
|
3
|
+
import { getTransport } from '../transport/singleton.js';
|
|
4
|
+
import { RequestTimeoutError, sendTypedRequest } from '../transport/transport.js';
|
|
5
5
|
/**
|
|
6
6
|
* The closed set of HOST refusal codes, as a runtime Set.
|
|
7
7
|
*
|
|
@@ -158,7 +158,7 @@ export function useCollectionFollow() {
|
|
|
158
158
|
type: 'SET_COLLECTION_FOLLOW',
|
|
159
159
|
payload: { collectionId: args.collectionId, follow: args.follow },
|
|
160
160
|
}, 'COLLECTION_FOLLOW_RESULT',
|
|
161
|
-
// See the `'human'` bucketing in `
|
|
161
|
+
// See the `'human'` bucketing in `transport/requestTimeouts.ts`: the
|
|
162
162
|
// host answers only when the viewer clicks or dismisses its confirm.
|
|
163
163
|
{ timeoutMs: HUMAN_INTERACTION_TIMEOUT_MS });
|
|
164
164
|
if (reply.error || !reply.result) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { armConsentRefusalLatch, clearConsentRefusalLatch, readConsentRefusalLatch, } from '../internal/consentRefusalLatch.js';
|
|
3
|
-
import { getTransport } from '../
|
|
4
|
-
import { subscribeTyped } from '../
|
|
3
|
+
import { getTransport } from '../transport/singleton.js';
|
|
4
|
+
import { subscribeTyped } from '../transport/transport.js';
|
|
5
5
|
/**
|
|
6
6
|
* Subscribe to the host's `CONSENT_UNAVAILABLE` push — the signal that a
|
|
7
7
|
* `REQUEST_CONSENT` this block sent can **never** be granted in this
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { HUMAN_INTERACTION_TIMEOUT_MS } from '../
|
|
3
|
-
import { getTransport } from '../
|
|
4
|
-
import { RequestTimeoutError, sendTypedRequest } from '../
|
|
2
|
+
import { HUMAN_INTERACTION_TIMEOUT_MS } from '../transport/requestTimeouts.js';
|
|
3
|
+
import { getTransport } from '../transport/singleton.js';
|
|
4
|
+
import { RequestTimeoutError, sendTypedRequest } from '../transport/transport.js';
|
|
5
5
|
/**
|
|
6
6
|
* The closed set of HOST refusal codes, as a runtime Set.
|
|
7
7
|
*
|
|
@@ -170,7 +170,7 @@ export function useCreatePostFromApp() {
|
|
|
170
170
|
: {}),
|
|
171
171
|
},
|
|
172
172
|
}, 'CREATE_POST_RESULT',
|
|
173
|
-
// See the `'human'` bucketing in `
|
|
173
|
+
// See the `'human'` bucketing in `transport/requestTimeouts.ts`: the
|
|
174
174
|
// host answers only when the viewer clicks or dismisses its confirm.
|
|
175
175
|
{ timeoutMs: HUMAN_INTERACTION_TIMEOUT_MS });
|
|
176
176
|
if (reply.error || !reply.result) {
|
|
@@ -34,8 +34,10 @@ export interface UseDailyCompensation {
|
|
|
34
34
|
* `blocks.getMyDailyCompensation` mutation (scope `buzz:read:self`).
|
|
35
35
|
*
|
|
36
36
|
* Fetches on mount and whenever `params` change (by value), and exposes `refetch`.
|
|
37
|
-
* A host that never answers surfaces as an `error` after the transport timeout
|
|
38
|
-
*
|
|
37
|
+
* A host that never answers surfaces as an `error` after the transport timeout.
|
|
38
|
+
* Only the LATEST request may write state: a reply superseded by a newer
|
|
39
|
+
* `refetch` / params change — or one that lands after unmount — is dropped
|
|
40
|
+
* (#392).
|
|
39
41
|
*
|
|
40
42
|
* @example
|
|
41
43
|
* const { resources, hasPublishedResources } = useDailyCompensation({ date: '2026-07-01' });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useCallback, useEffect,
|
|
2
|
-
import { getTransport } from '../
|
|
3
|
-
import { sendTypedRequest } from '../
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { getTransport } from '../transport/singleton.js';
|
|
3
|
+
import { sendTypedRequest } from '../transport/transport.js';
|
|
4
|
+
import { useRequestSequencer } from './useRequestSequencer.js';
|
|
4
5
|
/**
|
|
5
6
|
* Read the signed-in viewer's per-modelVersion generation compensation for the
|
|
6
7
|
* MONTH containing `params.date`, through the host-mediated
|
|
@@ -9,8 +10,10 @@ import { sendTypedRequest } from '../internal/transport.js';
|
|
|
9
10
|
* `blocks.getMyDailyCompensation` mutation (scope `buzz:read:self`).
|
|
10
11
|
*
|
|
11
12
|
* Fetches on mount and whenever `params` change (by value), and exposes `refetch`.
|
|
12
|
-
* A host that never answers surfaces as an `error` after the transport timeout
|
|
13
|
-
*
|
|
13
|
+
* A host that never answers surfaces as an `error` after the transport timeout.
|
|
14
|
+
* Only the LATEST request may write state: a reply superseded by a newer
|
|
15
|
+
* `refetch` / params change — or one that lands after unmount — is dropped
|
|
16
|
+
* (#392).
|
|
14
17
|
*
|
|
15
18
|
* @example
|
|
16
19
|
* const { resources, hasPublishedResources } = useDailyCompensation({ date: '2026-07-01' });
|
|
@@ -20,23 +23,22 @@ export function useDailyCompensation(params) {
|
|
|
20
23
|
const [hasPublishedResources, setHasPublishedResources] = useState(null);
|
|
21
24
|
const [loading, setLoading] = useState(true);
|
|
22
25
|
const [error, setError] = useState(null);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
}, []);
|
|
26
|
+
// Latest-wins + unmount guard in one predicate (#392): a reply may write state
|
|
27
|
+
// only if it answers the request this hook is CURRENTLY waiting for. A bare
|
|
28
|
+
// mount check would let a superseded request's slow reply overwrite newer
|
|
29
|
+
// state — nothing unmounted, so it passes.
|
|
30
|
+
const seq = useRequestSequencer();
|
|
30
31
|
// Stable params key so `refetch`'s identity only changes when the params VALUE
|
|
31
32
|
// changes; the callback re-parses it so it closes over nothing but the key.
|
|
32
33
|
const paramsKey = JSON.stringify(params);
|
|
33
34
|
const refetch = useCallback(() => {
|
|
35
|
+
const token = seq.begin();
|
|
34
36
|
setLoading(true);
|
|
35
37
|
setError(null);
|
|
36
38
|
const parsed = JSON.parse(paramsKey);
|
|
37
39
|
sendTypedRequest(getTransport(), { type: 'GET_DAILY_COMPENSATION', payload: { params: parsed } }, 'DAILY_COMPENSATION_RESULT')
|
|
38
40
|
.then((result) => {
|
|
39
|
-
if (!
|
|
41
|
+
if (!seq.isCurrent(token))
|
|
40
42
|
return;
|
|
41
43
|
if (result.error || !result.result) {
|
|
42
44
|
// `||`, not `??`: the reply validator gates `error` on SHAPE only, so a
|
|
@@ -51,12 +53,12 @@ export function useDailyCompensation(params) {
|
|
|
51
53
|
setLoading(false);
|
|
52
54
|
})
|
|
53
55
|
.catch((err) => {
|
|
54
|
-
if (!
|
|
56
|
+
if (!seq.isCurrent(token))
|
|
55
57
|
return;
|
|
56
58
|
setError(err instanceof Error ? err : new Error(String(err)));
|
|
57
59
|
setLoading(false);
|
|
58
60
|
});
|
|
59
|
-
}, [paramsKey]);
|
|
61
|
+
}, [paramsKey, seq]);
|
|
60
62
|
useEffect(() => {
|
|
61
63
|
refetch();
|
|
62
64
|
}, [refetch]);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What {@link useDirectLoad} returns: `true` once the block is known to be
|
|
3
|
+
* loaded directly rather than embedded. #380 — the options type has been
|
|
4
|
+
* exported since this hook shipped; the RETURN type had no name at all.
|
|
5
|
+
*/
|
|
6
|
+
export type UseDirectLoad = boolean;
|
|
1
7
|
export interface UseDirectLoadOptions {
|
|
2
8
|
/**
|
|
3
9
|
* Milliseconds to wait for `BLOCK_INIT` before treating a top-level load as a
|
|
@@ -28,5 +34,5 @@ export interface UseDirectLoadOptions {
|
|
|
28
34
|
* Once `ready` flips it stays authoritative: this can never return `true` while
|
|
29
35
|
* `ready` is `true`, so a late init can't leave a stuck fallback.
|
|
30
36
|
*/
|
|
31
|
-
export declare function useDirectLoad(options?: UseDirectLoadOptions):
|
|
37
|
+
export declare function useDirectLoad(options?: UseDirectLoadOptions): UseDirectLoad;
|
|
32
38
|
//# sourceMappingURL=useDirectLoad.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import { DIRECT_LOAD_TIMEOUT_MS } from '../
|
|
2
|
+
import { DIRECT_LOAD_TIMEOUT_MS } from '../transport/directLoad.js';
|
|
3
3
|
import { useTransportSnapshot } from './useBlockContext.js';
|
|
4
4
|
/**
|
|
5
5
|
* True iff the current window is the TOP-LEVEL browsing context — i.e. the
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { ColorDomain } from '@civitai/app-sdk/blocks';
|
|
2
2
|
/**
|
|
3
|
-
* What {@link useDomainMaturity} returns.
|
|
3
|
+
* What {@link useDomainMaturity} returns. An alias for the long-standing
|
|
4
|
+
* {@link DomainMaturity} name, which stays exported and unchanged — see
|
|
5
|
+
* `./returnTypeLedger.js`.
|
|
4
6
|
*/
|
|
7
|
+
export type UseDomainMaturity = DomainMaturity;
|
|
8
|
+
/** The domain/viewer maturity projection {@link useDomainMaturity} exposes. */
|
|
5
9
|
export interface DomainMaturity {
|
|
6
10
|
/**
|
|
7
11
|
* The color-domain the block is rendered inside (`green`|`blue`|`red`), or
|
|
@@ -92,5 +96,5 @@ export interface DomainMaturity {
|
|
|
92
96
|
* const { maxBrowsingLevel, effectiveBrowsingLevel } = useDomainMaturity();
|
|
93
97
|
* const hiddenByYourSettings = effectiveBrowsingLevel !== maxBrowsingLevel;
|
|
94
98
|
*/
|
|
95
|
-
export declare function useDomainMaturity():
|
|
99
|
+
export declare function useDomainMaturity(): UseDomainMaturity;
|
|
96
100
|
//# sourceMappingURL=useDomainMaturity.d.ts.map
|
|
@@ -43,6 +43,14 @@ export interface UseGatedImages {
|
|
|
43
43
|
* who can't see the image, and the block must render a placeholder for any
|
|
44
44
|
* `hidden` entry.
|
|
45
45
|
*
|
|
46
|
+
* 🔴 A `hidden` ENTRY IS NARROWED TO `{ imageId, status }` BEFORE IT REACHES
|
|
47
|
+
* HERE, and that is enforced in code rather than asserted in prose: the
|
|
48
|
+
* transport runs `projectInboundPayload` on every `IMAGES_RESULT` before
|
|
49
|
+
* delivery (`src/transport/validate.ts`), so a `previewUrl`, `src`, `imageUrl` or
|
|
50
|
+
* any other key a host attaches to a withheld image is DROPPED, not forwarded.
|
|
51
|
+
* Fields are dropped rather than the reply rejected so a future host-side field
|
|
52
|
+
* addition cannot hang this call — see `projectGatedImage`'s docblock.
|
|
53
|
+
*
|
|
46
54
|
* 🔴 `nsfwLevel` AND `contentRating` ARE OPTIONAL, AND A MISSING ONE IS NOT "G".
|
|
47
55
|
* They are absent exactly when `ratingPending` is present. Treating absent as a
|
|
48
56
|
* safe default is the bug this state exists to stop: an image published seconds
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import { getTransport } from '../
|
|
3
|
-
import { sendTypedRequest } from '../
|
|
2
|
+
import { getTransport } from '../transport/singleton.js';
|
|
3
|
+
import { sendTypedRequest } from '../transport/transport.js';
|
|
4
4
|
/**
|
|
5
5
|
* Read per-viewer gated display data for a list of image ids via the
|
|
6
6
|
* host-mediated `GET_IMAGES_BY_IDS` → `IMAGES_RESULT` bridge — the read side of
|
|
@@ -14,6 +14,14 @@ import { sendTypedRequest } from '../internal/transport.js';
|
|
|
14
14
|
* who can't see the image, and the block must render a placeholder for any
|
|
15
15
|
* `hidden` entry.
|
|
16
16
|
*
|
|
17
|
+
* 🔴 A `hidden` ENTRY IS NARROWED TO `{ imageId, status }` BEFORE IT REACHES
|
|
18
|
+
* HERE, and that is enforced in code rather than asserted in prose: the
|
|
19
|
+
* transport runs `projectInboundPayload` on every `IMAGES_RESULT` before
|
|
20
|
+
* delivery (`src/transport/validate.ts`), so a `previewUrl`, `src`, `imageUrl` or
|
|
21
|
+
* any other key a host attaches to a withheld image is DROPPED, not forwarded.
|
|
22
|
+
* Fields are dropped rather than the reply rejected so a future host-side field
|
|
23
|
+
* addition cannot hang this call — see `projectGatedImage`'s docblock.
|
|
24
|
+
*
|
|
17
25
|
* 🔴 `nsfwLevel` AND `contentRating` ARE OPTIONAL, AND A MISSING ONE IS NOT "G".
|
|
18
26
|
* They are absent exactly when `ratingPending` is present. Treating absent as a
|
|
19
27
|
* safe default is the bug this state exists to stop: an image published seconds
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { BlockResourceInfo } from '@civitai/app-sdk/blocks';
|
|
2
|
+
/** What {@link useGenerationResources} returns. */
|
|
3
|
+
export interface UseGenerationResources {
|
|
4
|
+
fetch: (versionIds: number[]) => Promise<BlockResourceInfo[]>;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Rehydrate a saved set of generation resources by version id, WITHOUT
|
|
4
8
|
* re-opening the resource picker. `fetch(versionIds)` GETs the block-token-gated
|
|
@@ -21,7 +25,5 @@ import type { BlockResourceInfo } from '@civitai/app-sdk/blocks';
|
|
|
21
25
|
* const resources = await fetch([691639, 666002]); // by saved versionIds
|
|
22
26
|
* // resources[0].strength / .minStrength / .maxStrength / .trainedWords / .clipSkip
|
|
23
27
|
*/
|
|
24
|
-
export declare function useGenerationResources():
|
|
25
|
-
fetch: (versionIds: number[]) => Promise<BlockResourceInfo[]>;
|
|
26
|
-
};
|
|
28
|
+
export declare function useGenerationResources(): UseGenerationResources;
|
|
27
29
|
//# sourceMappingURL=useGenerationResources.d.ts.map
|