@civitai/blocks-react 0.6.0 → 0.7.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Civitai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,38 @@
1
+ import type { BlockResourceInfo, BlockResourcePickerType } from '@civitai/app-sdk/blocks';
2
+ /**
3
+ * Drives the platform-side resource picker for PAGE App Blocks (Design 1 —
4
+ * host-chrome). Generalizes {@link useCheckpointPicker} from Checkpoint-only to
5
+ * a typed allowlist (v1: `'Checkpoint' | 'LORA'`), so a page block can let the
6
+ * USER pick a checkpoint + LoRAs instead of the author hard-coding version IDs.
7
+ *
8
+ * `open` asks the host to open its OWN native resource modal filtered to the
9
+ * requested type (+ optional base-model family). The viewer searches in HOST
10
+ * chrome — the block never sees the catalog, a list, or any resource it didn't
11
+ * pick. Resolves with the chosen {@link BlockResourceInfo}, or `null` when the
12
+ * user dismissed without picking.
13
+ *
14
+ * DISCOVERY ONLY: the returned `versionId` is a hint, never an entitlement.
15
+ * Feed it into `body.modelVersionId` (Checkpoint) or
16
+ * `body.additionalResources` (LoRA) and submit — the host re-validates every id
17
+ * server-side at estimate/submit (the page gate + orchestrator belt). A block
18
+ * can POST any id regardless of what the picker showed; the spend path is the
19
+ * enforcement boundary, not the picker.
20
+ *
21
+ * Host-mediated, same trust model as `useCheckpointPicker` / `useBuzzWorkflow`:
22
+ * the block never touches the picker UI directly.
23
+ */
24
+ export declare function useResourcePicker(): {
25
+ open: (opts: {
26
+ /** Which resource type to pick. v1: `'Checkpoint' | 'LORA'` only — the
27
+ * host rejects any other type (the modal never opens). */
28
+ resourceType: BlockResourcePickerType;
29
+ /**
30
+ * Optional base-model family hint — an ecosystem key (e.g. 'Flux1', 'SDXL')
31
+ * OR a baseModel name (e.g. 'Flux.1 D'); the host collapses it to the
32
+ * ecosystem family. Use the chosen checkpoint's `baseModel` to constrain a
33
+ * LoRA pick to the same family. Omit for an unconstrained pick of the type.
34
+ */
35
+ baseModelGroup?: string;
36
+ }) => Promise<BlockResourceInfo | null>;
37
+ };
38
+ //# sourceMappingURL=useResourcePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResourcePicker.d.ts","sourceRoot":"","sources":["../../src/hooks/useResourcePicker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAK1F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,IAAI;IACnC,IAAI,EAAE,CAAC,IAAI,EAAE;QACX;kEAC0D;QAC1D,YAAY,EAAE,uBAAuB,CAAC;QACtC;;;;;WAKG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,KAAK,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CACzC,CAsBA"}
@@ -0,0 +1,41 @@
1
+ import { useCallback } from 'react';
2
+ import { getTransport } from '../internal/singleton.js';
3
+ import { sendTypedRequest } from '../internal/transport.js';
4
+ /**
5
+ * Drives the platform-side resource picker for PAGE App Blocks (Design 1 —
6
+ * host-chrome). Generalizes {@link useCheckpointPicker} from Checkpoint-only to
7
+ * a typed allowlist (v1: `'Checkpoint' | 'LORA'`), so a page block can let the
8
+ * USER pick a checkpoint + LoRAs instead of the author hard-coding version IDs.
9
+ *
10
+ * `open` asks the host to open its OWN native resource modal filtered to the
11
+ * requested type (+ optional base-model family). The viewer searches in HOST
12
+ * chrome — the block never sees the catalog, a list, or any resource it didn't
13
+ * pick. Resolves with the chosen {@link BlockResourceInfo}, or `null` when the
14
+ * user dismissed without picking.
15
+ *
16
+ * DISCOVERY ONLY: the returned `versionId` is a hint, never an entitlement.
17
+ * Feed it into `body.modelVersionId` (Checkpoint) or
18
+ * `body.additionalResources` (LoRA) and submit — the host re-validates every id
19
+ * server-side at estimate/submit (the page gate + orchestrator belt). A block
20
+ * can POST any id regardless of what the picker showed; the spend path is the
21
+ * enforcement boundary, not the picker.
22
+ *
23
+ * Host-mediated, same trust model as `useCheckpointPicker` / `useBuzzWorkflow`:
24
+ * the block never touches the picker UI directly.
25
+ */
26
+ export function useResourcePicker() {
27
+ const open = useCallback(async (opts) => {
28
+ const { selected } = await sendTypedRequest(getTransport(), {
29
+ type: 'OPEN_RESOURCE_PICKER',
30
+ payload: {
31
+ resourceType: opts.resourceType,
32
+ ...(opts.baseModelGroup != null ? { baseModelGroup: opts.baseModelGroup } : {}),
33
+ },
34
+ }, 'RESOURCE_PICKER_RESULT');
35
+ // Normalize the "dismissed" case to an explicit null so callers can
36
+ // `if (!picked) return;` without an `undefined` ambiguity.
37
+ return selected ?? null;
38
+ }, []);
39
+ return { open };
40
+ }
41
+ //# sourceMappingURL=useResourcePicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResourcePicker.js","sourceRoot":"","sources":["../../src/hooks/useResourcePicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIpC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB;IAc/B,MAAM,IAAI,GAAG,WAAW,CACtB,KAAK,EAAE,IAAwE,EAAE,EAAE;QACjF,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,CACzC,YAAY,EAAE,EACd;YACE,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChF;SACF,EACD,wBAAwB,CACzB,CAAC;QACF,oEAAoE;QACpE,2DAA2D;QAC3D,OAAO,QAAQ,IAAI,IAAI,CAAC;IAC1B,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export { useBuzzWorkflow } from './hooks/useBuzzWorkflow.js';
20
20
  export { useBlockResize } from './hooks/useBlockResize.js';
21
21
  export { useBuzzPurchase } from './hooks/useBuzzPurchase.js';
22
22
  export { useCheckpointPicker } from './hooks/useCheckpointPicker.js';
23
+ export { useResourcePicker } from './hooks/useResourcePicker.js';
23
24
  export { useCivitaiNavigate } from './hooks/useCivitaiNavigate.js';
24
25
  export { useRequestSignIn } from './hooks/useRequestSignIn.js';
25
26
  export { useRequestConsent } from './hooks/useRequestConsent.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceR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AAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,aAAa,GACd,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ export { useBuzzWorkflow } from './hooks/useBuzzWorkflow.js';
18
18
  export { useBlockResize } from './hooks/useBlockResize.js';
19
19
  export { useBuzzPurchase } from './hooks/useBuzzPurchase.js';
20
20
  export { useCheckpointPicker } from './hooks/useCheckpointPicker.js';
21
+ export { useResourcePicker } from './hooks/useResourcePicker.js';
21
22
  export { useCivitaiNavigate } from './hooks/useCivitaiNavigate.js';
22
23
  export { useRequestSignIn } from './hooks/useRequestSignIn.js';
23
24
  export { useRequestConsent } from './hooks/useRequestConsent.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,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,M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AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/blocks-react",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "React hooks and iframe transport for Civitai App Blocks. Pairs with @civitai/app-sdk/blocks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,21 +24,14 @@
24
24
  "dist",
25
25
  "README.md"
26
26
  ],
27
- "scripts": {
28
- "build": "tsc -p tsconfig.json",
29
- "typecheck": "tsc -p tsconfig.json --noEmit",
30
- "test": "vitest run",
31
- "test:watch": "vitest"
32
- },
33
27
  "engines": {
34
28
  "node": ">=20"
35
29
  },
36
30
  "peerDependencies": {
37
- "@civitai/app-sdk": ">=0.7.0 <1",
31
+ "@civitai/app-sdk": ">=0.10.0",
38
32
  "react": "^18.0.0 || ^19.0.0"
39
33
  },
40
34
  "devDependencies": {
41
- "@civitai/app-sdk": "workspace:^",
42
35
  "@testing-library/react": "^16.0.0",
43
36
  "@types/node": "^25.9.1",
44
37
  "@types/react": "^19.2.15",
@@ -46,7 +39,8 @@
46
39
  "react": "^19.0.0",
47
40
  "react-dom": "^19.0.0",
48
41
  "typescript": "^5.9.2",
49
- "vitest": "^4.1.7"
42
+ "vitest": "^4.1.7",
43
+ "@civitai/app-sdk": "^0.11.0"
50
44
  },
51
45
  "publishConfig": {
52
46
  "access": "public"
@@ -65,5 +59,11 @@
65
59
  "type": "git",
66
60
  "url": "git+https://github.com/civitai/civitai-app-starters.git",
67
61
  "directory": "packages/civitai-blocks-react"
62
+ },
63
+ "scripts": {
64
+ "build": "tsc -p tsconfig.json",
65
+ "typecheck": "tsc -p tsconfig.json --noEmit",
66
+ "test": "vitest run",
67
+ "test:watch": "vitest"
68
68
  }
69
- }
69
+ }