@civitai/blocks-react 0.74.0 → 0.74.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/ui/WorkflowPicker.js +14 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3166,9 +3166,11 @@ a backdrop click, and re-opens on the next render if `open` still says `true`.
|
|
|
3166
3166
|
- **Search is debounced** (300 ms), and a newer search cancels the one in
|
|
3167
3167
|
flight. A busy catalog (`429` / `503`, rate limit 150 requests per 10 s per
|
|
3168
3168
|
block) is retried after its `Retry-After`, twice, then offered as "Try again".
|
|
3169
|
-
- **An anonymous viewer** gets a sign-in message on the "mine" list
|
|
3170
|
-
|
|
3171
|
-
|
|
3169
|
+
- **An anonymous viewer** gets a sign-in message on the "mine" list as soon as
|
|
3170
|
+
the catalog answers `401`, with no `REQUEST_TOKEN` to the host first — the
|
|
3171
|
+
picker knows the viewer is anonymous from `useBlockContext()`. "All" works. An expired block token is not mistaken for
|
|
3172
|
+
that: for a signed-in viewer, or on "All", a `401` makes the picker mint a
|
|
3173
|
+
fresh token through `useBlockToken().refresh()` and retry once.
|
|
3172
3174
|
- **Before `BLOCK_INIT`** the picker says it is not connected yet, and lists as
|
|
3173
3175
|
soon as the host origin lands.
|
|
3174
3176
|
- **Under the mock host** there is no catalog to call. Pass canned results from
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createElement, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { blockTokenSource, defineCivitaiResourcePicker, ResourceSourceError, } from '@civitai/components/civitai-resource-picker';
|
|
3
|
+
import { isSignedIn } from '@civitai/app-sdk/blocks';
|
|
4
|
+
import { useBlockContext } from '../hooks/useBlockContext.js';
|
|
3
5
|
import { useBlockToken } from '../hooks/useBlockToken.js';
|
|
4
6
|
import { useHostOrigin } from '../hooks/useHostOrigin.js';
|
|
5
7
|
/** The two model types a posted workflow can have; `ComfyWorkflows` is the retired one. */
|
|
@@ -24,9 +26,17 @@ export function WorkflowPicker({ open, onPick, onDismiss, owner = 'any', heading
|
|
|
24
26
|
defineCivitaiResourcePicker();
|
|
25
27
|
const host = useHostOrigin();
|
|
26
28
|
const { raw, refresh } = useBlockToken();
|
|
29
|
+
const { ready, viewer } = useBlockContext();
|
|
27
30
|
// Read at each request, so a refreshed token is the one sent.
|
|
28
31
|
const token = useRef({ raw, refresh });
|
|
29
32
|
token.current = { raw, refresh };
|
|
33
|
+
// Defensive, and unreachable today: the live source exists only once
|
|
34
|
+
// `useHostOrigin()` is set, which happens at BLOCK_INIT — the same moment
|
|
35
|
+
// `ready` flips — so no search reads the `undefined` arm and no test covers
|
|
36
|
+
// it. It is here so that a pre-init `viewer: null` (also null) can never be
|
|
37
|
+
// read as anonymous if that ordering changes.
|
|
38
|
+
const signedIn = useRef(undefined);
|
|
39
|
+
signedIn.current = ready ? isSignedIn(viewer) : undefined;
|
|
30
40
|
const live = useMemo(() => host
|
|
31
41
|
? blockTokenSource({
|
|
32
42
|
origin: host,
|
|
@@ -36,6 +46,10 @@ export function WorkflowPicker({ open, onPick, onDismiss, owner = 'any', heading
|
|
|
36
46
|
getToken: (options) => options?.fresh
|
|
37
47
|
? token.current.refresh().then((fresh) => fresh.raw, () => token.current.raw)
|
|
38
48
|
: token.current.raw,
|
|
49
|
+
// An anonymous viewer's `mine` 401 is "sign in", not "expired":
|
|
50
|
+
// shown at once, without a REQUEST_TOKEN round trip to the host
|
|
51
|
+
// (which would only hand back the same anonymous token).
|
|
52
|
+
signedIn: () => signedIn.current,
|
|
39
53
|
})
|
|
40
54
|
: NOT_CONNECTED, [host]);
|
|
41
55
|
const ref = useRef(null);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/* AUTOGENERATED from package.json by scripts/gen-version.mjs. DO NOT EDIT. */
|
|
2
2
|
/** This package's version, reported to the host as `sdkVersion` in `BLOCK_READY`. */
|
|
3
|
-
export const VERSION = "0.74.
|
|
3
|
+
export const VERSION = "0.74.1";
|
|
4
4
|
//# sourceMappingURL=version.generated.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civitai/blocks-react",
|
|
3
|
-
"version": "0.74.
|
|
3
|
+
"version": "0.74.1",
|
|
4
4
|
"description": "React hooks and iframe transport for Civitai Apps. Pairs with @civitai/app-sdk/blocks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"node": ">=20"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@civitai/components": "^0.
|
|
40
|
+
"@civitai/components": "^0.12.0",
|
|
41
41
|
"@civitai/theme": "^0.5.2"
|
|
42
42
|
},
|
|
43
43
|
"comment-peerDependencies": "This floor is DERIVED, not chosen — the lowest published app-sdk that exports every symbol this package imports. Do not edit it without reading ./PEER_FLOOR.md (in-repo, unpublished) and tests/guards/blocks-react-peer-floor.test.mjs.",
|