@civitai/blocks-react 0.74.0 → 0.75.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 +112 -3
- package/dist/hooks/useReactions.d.ts +126 -0
- package/dist/hooks/useReactions.js +384 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/internal/liveHost.d.ts +6 -1
- package/dist/internal/liveHost.js +44 -1
- package/dist/internal/mockHost.d.ts +30 -2
- package/dist/internal/mockHost.js +35 -0
- package/dist/internal/mockHostReactions.d.ts +62 -0
- package/dist/internal/mockHostReactions.js +166 -0
- package/dist/testing.d.ts +1 -0
- package/dist/transport/requestTimeouts.js +6 -0
- package/dist/transport/validate.d.ts +24 -0
- package/dist/transport/validate.js +119 -0
- 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 +3 -3
|
@@ -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.
|
|
3
|
+
export const VERSION = "0.75.0";
|
|
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.
|
|
3
|
+
"version": "0.75.0",
|
|
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.13.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.",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"typescript": "^5.9.2",
|
|
59
59
|
"vite": "^8.0.14",
|
|
60
60
|
"vitest": "^4.1.11",
|
|
61
|
-
"@civitai/app-sdk": "^0.
|
|
61
|
+
"@civitai/app-sdk": "^0.74.0"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|