@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.
@@ -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,3 +1,3 @@
1
1
  /** This package's version, reported to the host as `sdkVersion` in `BLOCK_READY`. */
2
- export declare const VERSION = "0.74.0";
2
+ export declare const VERSION = "0.75.0";
3
3
  //# sourceMappingURL=version.generated.d.ts.map
@@ -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.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.74.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.11.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.71.0"
61
+ "@civitai/app-sdk": "^0.74.0"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"