@civitai/blocks-react 0.39.0 → 0.41.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 +132 -5
- package/dist/hooks/useBlockContext.d.ts +6 -0
- package/dist/hooks/useBlockContext.d.ts.map +1 -1
- package/dist/hooks/useBlockContext.js +6 -0
- package/dist/hooks/useBlockContext.js.map +1 -1
- package/dist/hooks/useBlockTheme.d.ts +39 -0
- package/dist/hooks/useBlockTheme.d.ts.map +1 -0
- package/dist/hooks/useBlockTheme.js +41 -0
- package/dist/hooks/useBlockTheme.js.map +1 -0
- package/dist/hooks/useBuzzWorkflow.d.ts +13 -1
- package/dist/hooks/useBuzzWorkflow.d.ts.map +1 -1
- package/dist/hooks/useBuzzWorkflow.js +13 -1
- package/dist/hooks/useBuzzWorkflow.js.map +1 -1
- package/dist/hooks/useConsentUnavailable.d.ts +92 -0
- package/dist/hooks/useConsentUnavailable.d.ts.map +1 -0
- package/dist/hooks/useConsentUnavailable.js +93 -0
- package/dist/hooks/useConsentUnavailable.js.map +1 -0
- package/dist/hooks/useRequestConsent.d.ts +21 -3
- package/dist/hooks/useRequestConsent.d.ts.map +1 -1
- package/dist/hooks/useRequestConsent.js +30 -4
- package/dist/hooks/useRequestConsent.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/consent.d.ts +71 -0
- package/dist/internal/consent.d.ts.map +1 -0
- package/dist/internal/consent.js +88 -0
- package/dist/internal/consent.js.map +1 -0
- package/dist/internal/consentRefusalLatch.d.ts +19 -0
- package/dist/internal/consentRefusalLatch.d.ts.map +1 -0
- package/dist/internal/consentRefusalLatch.js +38 -0
- package/dist/internal/consentRefusalLatch.js.map +1 -0
- package/dist/internal/iframeTransport.d.ts +25 -0
- package/dist/internal/iframeTransport.d.ts.map +1 -1
- package/dist/internal/iframeTransport.js +47 -0
- package/dist/internal/iframeTransport.js.map +1 -1
- package/dist/internal/liveHost.d.ts +8 -2
- package/dist/internal/liveHost.d.ts.map +1 -1
- package/dist/internal/liveHost.js +100 -6
- package/dist/internal/liveHost.js.map +1 -1
- package/dist/internal/mockHost.d.ts +57 -13
- package/dist/internal/mockHost.d.ts.map +1 -1
- package/dist/internal/mockHost.js +188 -29
- package/dist/internal/mockHost.js.map +1 -1
- package/dist/internal/transport.d.ts +58 -1
- package/dist/internal/transport.d.ts.map +1 -1
- package/dist/internal/transport.js +62 -0
- package/dist/internal/transport.js.map +1 -1
- package/dist/internal/validate.d.ts +73 -3
- package/dist/internal/validate.d.ts.map +1 -1
- package/dist/internal/validate.js +135 -3
- package/dist/internal/validate.js.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +41 -2
- package/dist/testing.js.map +1 -1
- package/package.json +4 -4
package/dist/testing.js
CHANGED
|
@@ -28,6 +28,45 @@ export { openPickerOverlay, } from './internal/pickerOverlay.js';
|
|
|
28
28
|
export function mockParentMessage(data, origin) {
|
|
29
29
|
return new MessageEvent('message', { data, origin, source: null });
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* What the harness chrome's `consent=` readout says, from the TWO INDEPENDENT
|
|
33
|
+
* booleans that describe consent in the mock host.
|
|
34
|
+
*
|
|
35
|
+
* 🔴 THIS IS NOT A BOOLEAN, AND TREATING IT AS ONE IS THE BUG THIS SDK CHANGE
|
|
36
|
+
* EXISTS TO FIX. `consentGranted` says whether the token already carries the
|
|
37
|
+
* gated scope; `consentGrantable` says whether a consent round-trip could EVER
|
|
38
|
+
* add it here. `?consent=ungrantable` sets only the second one and leaves the
|
|
39
|
+
* first `undefined`, so a two-state `consentGranted ? 'granted' : 'withheld'`
|
|
40
|
+
* reports **withheld** — which reads as *"not granted yet, try again"*, the
|
|
41
|
+
* precise message `CONSENT_UNAVAILABLE` was added to replace. A developer
|
|
42
|
+
* exercising the new refusal path would then see their block correctly say
|
|
43
|
+
* "unavailable" while the harness chrome next to it said "withheld", and the
|
|
44
|
+
* chrome is the surface they trust to describe the fake host.
|
|
45
|
+
*
|
|
46
|
+
* All four combinations are named rather than collapsed. `granted+ungrantable`
|
|
47
|
+
* is a real, tested configuration (`createMockHost({ consentGranted: true,
|
|
48
|
+
* consentGrantable: false })`) and it behaves differently from both neighbours:
|
|
49
|
+
* a request for the already-granted scope stays SILENT (nothing is un-grantable
|
|
50
|
+
* about it), while a request for anything else is refused. Collapsing it into
|
|
51
|
+
* either `granted` or `ungrantable` mis-describes one of those two paths.
|
|
52
|
+
*/
|
|
53
|
+
function harnessConsentLabel(opts) {
|
|
54
|
+
// Mirrors `createMockHost`'s own default (`options.consentGrantable ?? true`):
|
|
55
|
+
// absent means "this host can grant", i.e. today's behaviour.
|
|
56
|
+
const grantable = opts.consentGrantable ?? true;
|
|
57
|
+
const granted = !!opts.consentGranted;
|
|
58
|
+
if (grantable)
|
|
59
|
+
return granted ? 'granted' : 'withheld';
|
|
60
|
+
return granted ? 'granted+ungrantable' : 'ungrantable';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Chrome colour for the consent readout. An un-grantable host is the state a dev
|
|
64
|
+
* is least likely to have set on purpose (it can arrive from a URL toggle), so
|
|
65
|
+
* it is tinted amber rather than sharing the neutral accent of the other values.
|
|
66
|
+
*/
|
|
67
|
+
function consentColor(label) {
|
|
68
|
+
return label === 'ungrantable' || label === 'granted+ungrantable' ? '#e2c08d' : '#7fd9ff';
|
|
69
|
+
}
|
|
31
70
|
/**
|
|
32
71
|
* Thin React wrapper that installs a {@link createMockHost} on mount (and tears
|
|
33
72
|
* it down on unmount) so a block app renders against a fake civitai host for
|
|
@@ -74,12 +113,12 @@ export function Harness({ children, applyUrlToggles = true, showLog = true, ...o
|
|
|
74
113
|
const opts = optionsRef.current;
|
|
75
114
|
const anon = opts.viewer === null;
|
|
76
115
|
const theme = opts.theme ?? 'dark';
|
|
77
|
-
const consent = opts
|
|
116
|
+
const consent = harnessConsentLabel(opts);
|
|
78
117
|
return (_jsxs("div", { "data-harness": "true", style: { position: 'relative', width: '100vw', minHeight: '100dvh' }, children: [_jsx("main", { "data-harness-frame": "true", style: { width: '100%', minHeight: '100%', paddingBottom: showLog ? 56 : 0 }, children: children }), showLog && (
|
|
79
118
|
// pointerEvents:none on the wrapper so the badge's bounding box can't
|
|
80
119
|
// steal clicks from content beneath it; re-enabled on the interactive
|
|
81
120
|
// bits (summary toggles the log; pre is scrollable/selectable).
|
|
82
|
-
_jsxs("details", { style: harnessLogStyle, children: [_jsxs("summary", { style: harnessSummaryStyle, children: [_jsx("span", { style: { color: '#5ec8a0' }, children: "$" }), ' ', _jsx("span", { style: { color: '#9aa0aa' }, children: "DEV HARNESS" }), ' ', _jsx("span", { style: { color: '#5b626d' }, children: "\u00B7" }), " viewer=", _jsx("span", { style: { color: '#7fd9ff' }, children: anon ? 'anon' : 'dev-viewer' }), ' ', _jsx("span", { style: { color: '#5b626d' }, children: "\u00B7" }), " consent=", _jsx("span", { style: { color:
|
|
121
|
+
_jsxs("details", { style: harnessLogStyle, children: [_jsxs("summary", { style: harnessSummaryStyle, children: [_jsx("span", { style: { color: '#5ec8a0' }, children: "$" }), ' ', _jsx("span", { style: { color: '#9aa0aa' }, children: "DEV HARNESS" }), ' ', _jsx("span", { style: { color: '#5b626d' }, children: "\u00B7" }), " viewer=", _jsx("span", { style: { color: '#7fd9ff' }, children: anon ? 'anon' : 'dev-viewer' }), ' ', _jsx("span", { style: { color: '#5b626d' }, children: "\u00B7" }), " consent=", _jsx("span", { "data-harness-consent": consent, style: { color: consentColor(consent) }, children: consent }), ' ', _jsx("span", { style: { color: '#5b626d' }, children: "\u00B7" }), " theme=", _jsx("span", { style: { color: '#7fd9ff' }, children: theme }), ' ', _jsx("span", { style: { color: '#5b626d' }, children: "\u00B7" }), " outbound:", _jsx("span", { style: { color: '#e2c08d' }, children: outbound.length })] }), _jsx("pre", { style: harnessPreStyle, children: outbound.length === 0
|
|
83
122
|
? '// no outbound messages yet'
|
|
84
123
|
: outbound
|
|
85
124
|
.map((m, i) => `${i + 1}. ${m.type} ${JSON.stringify(m.payload ?? {})}`)
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,cAAc,EACd,sBAAsB,GAEvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,IAAI,cAAc,EAAE,CAAC;AAE9C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,sBAAsB,GAgBvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,cAAc,EACd,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,eAAe,EACf,YAAY,EACZ,WAAW,EACX,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,GAMd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,iBAAiB,GAIlB,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa,EAAE,MAAc;IAC7D,OAAO,IAAI,YAAY,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AACrE,CAAC;
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAEpE,OAAO,E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AAE,MAAM;IACjB,UAAU,EAAE,MAAM;CACV,CAAC;AAEX,MAAM,eAAe,GAAG;IACtB,MAAM,EAAE,SAAS;IACjB,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,kCAAkC;IAC7C,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,SAAS;IAChB,aAAa,EAAE,MAAM;CACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civitai/blocks-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.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",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"node": ">=20"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@civitai/
|
|
35
|
-
"@civitai/
|
|
34
|
+
"@civitai/components": "0.3.1",
|
|
35
|
+
"@civitai/theme": "0.2.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@civitai/app-sdk": ">=0.29.0 <1.0.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"react-dom": "^19.0.0",
|
|
51
51
|
"typescript": "^5.9.2",
|
|
52
52
|
"vitest": "^4.1.7",
|
|
53
|
-
"@civitai/app-sdk": "^0.
|
|
53
|
+
"@civitai/app-sdk": "^0.33.0"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|