@civitai/blocks-react 0.7.0 → 0.9.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/dist/hooks/SfwGate.d.ts +44 -0
- package/dist/hooks/SfwGate.d.ts.map +1 -0
- package/dist/hooks/SfwGate.js +33 -0
- package/dist/hooks/SfwGate.js.map +1 -0
- package/dist/hooks/useDomainMaturity.d.ts +56 -0
- package/dist/hooks/useDomainMaturity.d.ts.map +1 -0
- package/dist/hooks/useDomainMaturity.js +35 -0
- package/dist/hooks/useDomainMaturity.js.map +1 -0
- package/dist/index.d.ts +4 -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/mockHost.d.ts +152 -0
- package/dist/internal/mockHost.d.ts.map +1 -0
- package/dist/internal/mockHost.js +361 -0
- package/dist/internal/mockHost.js.map +1 -0
- package/dist/internal/transport.d.ts +14 -1
- package/dist/internal/transport.d.ts.map +1 -1
- package/dist/internal/transport.js +2 -0
- package/dist/internal/transport.js.map +1 -1
- package/dist/internal/validate.d.ts.map +1 -1
- package/dist/internal/validate.js +15 -0
- package/dist/internal/validate.js.map +1 -1
- package/dist/testing.d.ts +56 -2
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +82 -2
- package/dist/testing.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for {@link SfwGate}.
|
|
4
|
+
*/
|
|
5
|
+
export interface SfwGateProps {
|
|
6
|
+
/** Rendered only when the gate is open (domain is SFW, or `level` allowed). */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* When set, gate on `isLevelAllowed(level)` (a single `BrowsingLevel` bit)
|
|
10
|
+
* instead of the coarse `isSfw`. Lets a block reveal a level-specific
|
|
11
|
+
* affordance (e.g. an R-rated toggle) only when the domain permits that level.
|
|
12
|
+
*/
|
|
13
|
+
level?: number;
|
|
14
|
+
/** Rendered when the gate is closed. Defaults to `null` (render nothing). */
|
|
15
|
+
fallback?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convenience wrapper that renders `children` only when the surrounding
|
|
19
|
+
* color-domain permits it, else `fallback` — so a block can hide/blur mature
|
|
20
|
+
* affordances on a SFW domain without wiring {@link useDomainMaturity} by hand.
|
|
21
|
+
*
|
|
22
|
+
* Gating:
|
|
23
|
+
* - no `level` prop → renders `children` when the domain is SFW (`isSfw`).
|
|
24
|
+
* - `level` prop set → renders `children` when that browsing-level bit is
|
|
25
|
+
* allowed by the domain ceiling (`isLevelAllowed(level)`).
|
|
26
|
+
*
|
|
27
|
+
* **Fail-closed SFW**: before `BLOCK_INIT` lands, and against a host that
|
|
28
|
+
* predates civitai #2670 (no ceiling field), the gate is treated as SFW —
|
|
29
|
+
* `children` show only for SFW content, mature content shows `fallback`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Hide a mature-only carousel on a SFW domain:
|
|
33
|
+
* <SfwGate fallback={<SafePlaceholder />}>
|
|
34
|
+
* <MatureCarousel />
|
|
35
|
+
* </SfwGate>
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Reveal an R-rated control only when the domain allows R:
|
|
39
|
+
* <SfwGate level={BrowsingLevel.R}>
|
|
40
|
+
* <RRatedToggle />
|
|
41
|
+
* </SfwGate>
|
|
42
|
+
*/
|
|
43
|
+
export declare function SfwGate({ children, level, fallback }: SfwGateProps): ReactNode;
|
|
44
|
+
//# sourceMappingURL=SfwGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SfwGate.d.ts","sourceRoot":"","sources":["../../src/hooks/SfwGate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAe,EAAE,EAAE,YAAY,GAAG,SAAS,CAIrF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useDomainMaturity } from './useDomainMaturity.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convenience wrapper that renders `children` only when the surrounding
|
|
4
|
+
* color-domain permits it, else `fallback` — so a block can hide/blur mature
|
|
5
|
+
* affordances on a SFW domain without wiring {@link useDomainMaturity} by hand.
|
|
6
|
+
*
|
|
7
|
+
* Gating:
|
|
8
|
+
* - no `level` prop → renders `children` when the domain is SFW (`isSfw`).
|
|
9
|
+
* - `level` prop set → renders `children` when that browsing-level bit is
|
|
10
|
+
* allowed by the domain ceiling (`isLevelAllowed(level)`).
|
|
11
|
+
*
|
|
12
|
+
* **Fail-closed SFW**: before `BLOCK_INIT` lands, and against a host that
|
|
13
|
+
* predates civitai #2670 (no ceiling field), the gate is treated as SFW —
|
|
14
|
+
* `children` show only for SFW content, mature content shows `fallback`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Hide a mature-only carousel on a SFW domain:
|
|
18
|
+
* <SfwGate fallback={<SafePlaceholder />}>
|
|
19
|
+
* <MatureCarousel />
|
|
20
|
+
* </SfwGate>
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Reveal an R-rated control only when the domain allows R:
|
|
24
|
+
* <SfwGate level={BrowsingLevel.R}>
|
|
25
|
+
* <RRatedToggle />
|
|
26
|
+
* </SfwGate>
|
|
27
|
+
*/
|
|
28
|
+
export function SfwGate({ children, level, fallback = null }) {
|
|
29
|
+
const { isSfw, isLevelAllowed } = useDomainMaturity();
|
|
30
|
+
const open = level === undefined ? isSfw : isLevelAllowed(level);
|
|
31
|
+
return open ? children : fallback;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=SfwGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SfwGate.js","sourceRoot":"","sources":["../../src/hooks/SfwGate.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAkB3D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAgB;IACxE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,iBAAiB,EAAE,CAAC;IACtD,MAAM,IAAI,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ColorDomain } from '@civitai/app-sdk/blocks';
|
|
2
|
+
/**
|
|
3
|
+
* What {@link useDomainMaturity} returns.
|
|
4
|
+
*/
|
|
5
|
+
export interface DomainMaturity {
|
|
6
|
+
/**
|
|
7
|
+
* The color-domain the block is rendered inside (`green`|`blue`|`red`), or
|
|
8
|
+
* `null`/`undefined` when the host didn't project one (anon read, or a host
|
|
9
|
+
* that predates civitai #2670). Informational ONLY — gate UI on {@link isSfw}
|
|
10
|
+
* / {@link isLevelAllowed}, not on this string.
|
|
11
|
+
*/
|
|
12
|
+
domain?: ColorDomain | null;
|
|
13
|
+
/**
|
|
14
|
+
* Authoritative browsing-level ceiling BITMASK from `BLOCK_INIT`
|
|
15
|
+
* (`undefined` before init / when the host doesn't send it). The bits mirror
|
|
16
|
+
* the server `NsfwLevel` (see `BrowsingLevel` in `@civitai/app-sdk/blocks`).
|
|
17
|
+
*/
|
|
18
|
+
maxBrowsingLevel?: number;
|
|
19
|
+
/**
|
|
20
|
+
* `true` when the surrounding domain permits NO NSFW content — derived from
|
|
21
|
+
* the {@link maxBrowsingLevel} bitmask (NOT the `domain` string, so the policy
|
|
22
|
+
* stays server-side). **Fail-closed SFW**: `true` before `BLOCK_INIT` lands
|
|
23
|
+
* and whenever the ceiling is absent/non-finite.
|
|
24
|
+
*/
|
|
25
|
+
isSfw: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* `true` when a specific browsing-level bit (e.g. `BrowsingLevel.R`) is
|
|
28
|
+
* permitted by the domain ceiling. Fail-closed to SFW-only when the ceiling
|
|
29
|
+
* is absent.
|
|
30
|
+
*/
|
|
31
|
+
isLevelAllowed: (level: number) => boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Read the surrounding color-domain's maturity ceiling that the host projects
|
|
35
|
+
* into `BLOCK_INIT` (civitai #2670), so a block can hide/blur mature
|
|
36
|
+
* affordances on a SFW domain.
|
|
37
|
+
*
|
|
38
|
+
* Reads from the SAME init state as {@link useBlockContext} (the singleton
|
|
39
|
+
* transport snapshot), so it re-renders when `BLOCK_INIT` lands.
|
|
40
|
+
*
|
|
41
|
+
* The SFW decision is derived from the `maxBrowsingLevel` BITMASK — never from
|
|
42
|
+
* the `domain` string — so the policy stays server-side and the SDK won't rot
|
|
43
|
+
* if a domain's policy flips. **Fail-closed SFW**: until `BLOCK_INIT` arrives,
|
|
44
|
+
* or against a host that predates #2670 (fields read `undefined`), `isSfw` is
|
|
45
|
+
* `true` and only SFW levels are allowed.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const { isSfw } = useDomainMaturity();
|
|
49
|
+
* return isSfw ? <SafeUI /> : <MatureUI />;
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const { isLevelAllowed } = useDomainMaturity();
|
|
53
|
+
* if (isLevelAllowed(BrowsingLevel.R)) showRSlider();
|
|
54
|
+
*/
|
|
55
|
+
export declare function useDomainMaturity(): DomainMaturity;
|
|
56
|
+
//# sourceMappingURL=useDomainMaturity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDomainMaturity.d.ts","sourceRoot":"","sources":["../../src/hooks/useDomainMaturity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAI3D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CASlD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isSfwCeiling, isLevelAllowed as isLevelAllowedCeiling } from '@civitai/app-sdk/blocks';
|
|
2
|
+
import { useTransportSnapshot } from './useBlockContext.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read the surrounding color-domain's maturity ceiling that the host projects
|
|
5
|
+
* into `BLOCK_INIT` (civitai #2670), so a block can hide/blur mature
|
|
6
|
+
* affordances on a SFW domain.
|
|
7
|
+
*
|
|
8
|
+
* Reads from the SAME init state as {@link useBlockContext} (the singleton
|
|
9
|
+
* transport snapshot), so it re-renders when `BLOCK_INIT` lands.
|
|
10
|
+
*
|
|
11
|
+
* The SFW decision is derived from the `maxBrowsingLevel` BITMASK — never from
|
|
12
|
+
* the `domain` string — so the policy stays server-side and the SDK won't rot
|
|
13
|
+
* if a domain's policy flips. **Fail-closed SFW**: until `BLOCK_INIT` arrives,
|
|
14
|
+
* or against a host that predates #2670 (fields read `undefined`), `isSfw` is
|
|
15
|
+
* `true` and only SFW levels are allowed.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const { isSfw } = useDomainMaturity();
|
|
19
|
+
* return isSfw ? <SafeUI /> : <MatureUI />;
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const { isLevelAllowed } = useDomainMaturity();
|
|
23
|
+
* if (isLevelAllowed(BrowsingLevel.R)) showRSlider();
|
|
24
|
+
*/
|
|
25
|
+
export function useDomainMaturity() {
|
|
26
|
+
const snap = useTransportSnapshot();
|
|
27
|
+
const maxBrowsingLevel = snap.maxBrowsingLevel;
|
|
28
|
+
return {
|
|
29
|
+
domain: snap.domain,
|
|
30
|
+
maxBrowsingLevel,
|
|
31
|
+
isSfw: isSfwCeiling(maxBrowsingLevel),
|
|
32
|
+
isLevelAllowed: (level) => isLevelAllowedCeiling(level, maxBrowsingLevel),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=useDomainMaturity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDomainMaturity.js","sourceRoot":"","sources":["../../src/hooks/useDomainMaturity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAkC5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,IAAI,GAAG,oBAAoB,EAAE,CAAC;IACpC,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAC/C,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,gBAAgB;QAChB,KAAK,EAAE,YAAY,CAAC,gBAAgB,CAAC;QACrC,cAAc,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,CAAC;KAClF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export { useCivitaiNavigate } from './hooks/useCivitaiNavigate.js';
|
|
|
25
25
|
export { useRequestSignIn } from './hooks/useRequestSignIn.js';
|
|
26
26
|
export { useRequestConsent } from './hooks/useRequestConsent.js';
|
|
27
27
|
export { useBlockAnalytics } from './hooks/useBlockAnalytics.js';
|
|
28
|
+
export { useDomainMaturity } from './hooks/useDomainMaturity.js';
|
|
29
|
+
export type { DomainMaturity } from './hooks/useDomainMaturity.js';
|
|
30
|
+
export { SfwGate } from './hooks/SfwGate.js';
|
|
31
|
+
export type { SfwGateProps } from './hooks/SfwGate.js';
|
|
28
32
|
export { useAppStorage } from './hooks/useAppStorage.js';
|
|
29
33
|
export type { AppStorageKeyEntry, AppStorageListResult, AppStorageQuota, UseAppStorage, } from './hooks/useAppStorage.js';
|
|
30
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAA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B,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,yBAAyB,CAAC;AAGjC,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,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,aAAa,GACd,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,5 +23,7 @@ export { useCivitaiNavigate } from './hooks/useCivitaiNavigate.js';
|
|
|
23
23
|
export { useRequestSignIn } from './hooks/useRequestSignIn.js';
|
|
24
24
|
export { useRequestConsent } from './hooks/useRequestConsent.js';
|
|
25
25
|
export { useBlockAnalytics } from './hooks/useBlockAnalytics.js';
|
|
26
|
+
export { useDomainMaturity } from './hooks/useDomainMaturity.js';
|
|
27
|
+
export { SfwGate } from './hooks/SfwGate.js';
|
|
26
28
|
export { useAppStorage } from './hooks/useAppStorage.js';
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
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,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC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E,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createMockHost` — a framework-agnostic, test-and-dev-only fake of the
|
|
3
|
+
* civitai.com embedding host.
|
|
4
|
+
*
|
|
5
|
+
* The real host (civitai/civitai `IframeHost.tsx` / `PageBlockHost.tsx`) mounts
|
|
6
|
+
* a block in a cross-origin iframe and answers its `postMessage` protocol:
|
|
7
|
+
* mints a token, runs the lazy-consent round-trip, brokers the orchestrator
|
|
8
|
+
* money path (estimate → submit → poll), opens the native Buzz-purchase and
|
|
9
|
+
* resource-picker modals. Locally — in a `vitest` test OR a starter's dev
|
|
10
|
+
* harness — there is no host, so this plays one.
|
|
11
|
+
*
|
|
12
|
+
* It is the portable core that the React `<Harness>` (a.k.a. `<MockHostProvider>`
|
|
13
|
+
* in `../testing`) wraps. Every block app used to hand-roll ~250 lines of this;
|
|
14
|
+
* now they configure it with {@link MockHostOptions} instead.
|
|
15
|
+
*
|
|
16
|
+
* Mechanism (mirrors the gen-matrix reference Harness):
|
|
17
|
+
* 1. Patches `window.parent.postMessage` via `Object.defineProperty(window,
|
|
18
|
+
* 'parent', …)` so the block's OUTBOUND messages are intercepted.
|
|
19
|
+
* 2. Replies as `MessageEvent`s fired from `window.location.origin` — the SDK
|
|
20
|
+
* `IframeTransport` DROPS any inbound message whose `origin` ≠ the allowed
|
|
21
|
+
* parent origin, so a block using this in dev MUST allow
|
|
22
|
+
* `window.location.origin` (the React `<Harness>` is documented for that).
|
|
23
|
+
* 3. Dispatches a configurable `BLOCK_INIT`, then answers the full protocol.
|
|
24
|
+
*
|
|
25
|
+
* NOT a real RS256 JWT, NO real Buzz, NO orchestrator — only the bridge
|
|
26
|
+
* round-trips are exercised. Never import this from production code.
|
|
27
|
+
*/
|
|
28
|
+
import { type BlockContext, type BlockResourceInfo, type BlockResourcePickerType, type ColorDomain, type Theme, type ViewerInfo } from '@civitai/app-sdk/blocks';
|
|
29
|
+
/**
|
|
30
|
+
* How submits resolve. `'none'` = everything succeeds; `'all'` /
|
|
31
|
+
* `'insufficient'` = every submit returns an insufficient-Buzz `failed`
|
|
32
|
+
* snapshot (exercises the per-cell Top-Up CTA); `'some'` = ~1 in 3 submits
|
|
33
|
+
* fail (a mixed grid).
|
|
34
|
+
*/
|
|
35
|
+
export type MockHostFailMode = 'none' | 'some' | 'all' | 'insufficient';
|
|
36
|
+
/**
|
|
37
|
+
* A canned resource the mock host "returns" from `OPEN_RESOURCE_PICKER`.
|
|
38
|
+
* Mirrors the host's narrow `BlockResourceInfo` projection (versionId/modelId/
|
|
39
|
+
* names/baseModel/modelType). Returning `undefined`/`null` simulates a
|
|
40
|
+
* user-dismissed picker (→ `RESOURCE_PICKER_RESULT` with no `selected`).
|
|
41
|
+
*/
|
|
42
|
+
export type CannedPick = BlockResourceInfo;
|
|
43
|
+
/**
|
|
44
|
+
* Drives `createMockHost`. Every field is optional with a sensible default so
|
|
45
|
+
* `createMockHost()` works out of the box. Each block configures SCENARIOS
|
|
46
|
+
* here instead of forking the host code.
|
|
47
|
+
*/
|
|
48
|
+
export interface MockHostOptions {
|
|
49
|
+
/**
|
|
50
|
+
* The signed-in viewer, or `null` for anonymous (→ sign-in CTA). Defaults to
|
|
51
|
+
* a `dev-viewer`. Pass `null` to exercise the anon path.
|
|
52
|
+
*/
|
|
53
|
+
viewer?: ViewerInfo | null;
|
|
54
|
+
/**
|
|
55
|
+
* Start WITH the consent-gated `ai:write:budgeted` scope already granted. The
|
|
56
|
+
* real mint WITHHOLDS it until the viewer consents, so this defaults to
|
|
57
|
+
* `false` — the first token carries NO budgeted scope, and `REQUEST_CONSENT`
|
|
58
|
+
* grants it + pushes a `TOKEN_REFRESH` (the lazy-consent round-trip).
|
|
59
|
+
*/
|
|
60
|
+
consentGranted?: boolean;
|
|
61
|
+
/** How submits resolve. Default `'none'` (all succeed). */
|
|
62
|
+
failMode?: MockHostFailMode;
|
|
63
|
+
/**
|
|
64
|
+
* Canned picks keyed by requested resource type, returned from
|
|
65
|
+
* `OPEN_RESOURCE_PICKER`. A `null`/absent entry simulates a dismissed picker
|
|
66
|
+
* for that type. Defaults to a curated Checkpoint + LoRA pick.
|
|
67
|
+
*/
|
|
68
|
+
cannedPicks?: Partial<Record<BlockResourcePickerType, CannedPick | null>>;
|
|
69
|
+
/** Number of `POLL_WORKFLOW` round-trips before a workflow succeeds. Default 2. */
|
|
70
|
+
pollsUntilDone?: number;
|
|
71
|
+
/** The `cost.total` reported on estimate + succeeded snapshots. Default 8. */
|
|
72
|
+
cost?: number;
|
|
73
|
+
/** The Buzz budget reported on a granted token. Default 200. */
|
|
74
|
+
buzzBudget?: number;
|
|
75
|
+
/** Host theme delivered in `BLOCK_INIT` + context. Default `'dark'`. */
|
|
76
|
+
theme?: Theme;
|
|
77
|
+
/**
|
|
78
|
+
* The `BLOCK_INIT` context. Defaults to a PAGE context
|
|
79
|
+
* (`{ slotId: 'app.page' }`). Pass a `ModelSlotContext` for a model-slot
|
|
80
|
+
* block. `theme` is merged in from {@link MockHostOptions.theme}.
|
|
81
|
+
*/
|
|
82
|
+
context?: BlockContext;
|
|
83
|
+
/**
|
|
84
|
+
* The color-domain the host projects into `BLOCK_INIT` (civitai #2670),
|
|
85
|
+
* surfaced on the top-level `domain` field. When set WITHOUT an explicit
|
|
86
|
+
* {@link MockHostOptions.maxBrowsingLevel}, the mock host derives a matching
|
|
87
|
+
* ceiling: `green`/`blue` → SFW (`SFW_LEVELS`), `red` → all levels — so
|
|
88
|
+
* `useDomainMaturity()`/`<SfwGate>` are exercisable. Omit for a host that
|
|
89
|
+
* predates #2670 (neither field is emitted → the hook fail-closes to SFW).
|
|
90
|
+
*/
|
|
91
|
+
domain?: ColorDomain;
|
|
92
|
+
/**
|
|
93
|
+
* The authoritative browsing-level ceiling BITMASK emitted on `BLOCK_INIT`
|
|
94
|
+
* (`maxBrowsingLevel`). Overrides whatever {@link MockHostOptions.domain} /
|
|
95
|
+
* {@link MockHostOptions.maturity} would derive. Use `BrowsingLevel` bits
|
|
96
|
+
* from `@civitai/app-sdk/blocks` to compose one.
|
|
97
|
+
*/
|
|
98
|
+
maxBrowsingLevel?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Convenience for the common case: `'sfw'` → an SFW ceiling (`SFW_LEVELS`),
|
|
101
|
+
* `'mature'` → an all-levels ceiling. Lower precedence than an explicit
|
|
102
|
+
* {@link MockHostOptions.maxBrowsingLevel}, higher than the
|
|
103
|
+
* {@link MockHostOptions.domain}-derived default.
|
|
104
|
+
*/
|
|
105
|
+
maturity?: 'sfw' | 'mature';
|
|
106
|
+
/** Identity fields delivered in `BLOCK_INIT`. Sensible dev defaults. */
|
|
107
|
+
blockInstanceId?: string;
|
|
108
|
+
blockId?: string;
|
|
109
|
+
appId?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Called with every intercepted OUTBOUND message (`{ type, payload }`) — the
|
|
112
|
+
* React `<Harness>` uses this to render its on-screen message log. RESIZE
|
|
113
|
+
* messages are included; filter them out in the callback if undesired.
|
|
114
|
+
*/
|
|
115
|
+
onOutbound?: (msg: {
|
|
116
|
+
type: string;
|
|
117
|
+
payload?: unknown;
|
|
118
|
+
}) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Override `window`. Defaults to `globalThis.window`. Tests pass happy-dom's
|
|
121
|
+
* window; the dev harness uses the default.
|
|
122
|
+
*/
|
|
123
|
+
window?: Window & typeof globalThis;
|
|
124
|
+
}
|
|
125
|
+
/** Handle returned by {@link createMockHost}. Call `install()` to patch the
|
|
126
|
+
* host in; it returns the `uninstall()` that restores `window.parent` and
|
|
127
|
+
* removes timers. Idempotent — calling `install()` twice returns the same
|
|
128
|
+
* teardown; `uninstall()` is safe to call more than once. */
|
|
129
|
+
export interface MockHost {
|
|
130
|
+
install: () => () => void;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Reads the URL query toggles the gen-matrix dev harness uses, so a starter's
|
|
134
|
+
* dev harness keeps working with `?viewer/?consent/?fail/?theme/?pick/?pickCkpt`.
|
|
135
|
+
* Returns a partial overlay applied ON TOP of explicit {@link MockHostOptions}
|
|
136
|
+
* (URL wins — it's the interactive dev knob). No-op outside a browser.
|
|
137
|
+
*/
|
|
138
|
+
export declare function readMockHostUrlOptions(win?: (Window & typeof globalThis) | undefined): Partial<MockHostOptions>;
|
|
139
|
+
/**
|
|
140
|
+
* Create a framework-agnostic mock host. Call the returned `install()` to patch
|
|
141
|
+
* `window.parent` + start answering the block's protocol; it returns an
|
|
142
|
+
* `uninstall()` teardown (restores `window.parent`, clears timers). Safe to use
|
|
143
|
+
* from a node/jsdom/happy-dom test OR a browser dev harness.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* const host = createMockHost({ failMode: 'some', pollsUntilDone: 1 });
|
|
147
|
+
* const uninstall = host.install();
|
|
148
|
+
* // … drive the block / assertions …
|
|
149
|
+
* uninstall();
|
|
150
|
+
*/
|
|
151
|
+
export declare function createMockHost(options?: MockHostOptions): MockHost;
|
|
152
|
+
//# sourceMappingURL=mockHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockHost.d.ts","sourceRoot":"","sources":["../../src/internal/mockHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAGL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,UAAU,EAEhB,MAAM,yBAAyB,CAAC;AAajC;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,cAAc,CAAC;AAExE;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;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ED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAmRtE"}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createMockHost` — a framework-agnostic, test-and-dev-only fake of the
|
|
3
|
+
* civitai.com embedding host.
|
|
4
|
+
*
|
|
5
|
+
* The real host (civitai/civitai `IframeHost.tsx` / `PageBlockHost.tsx`) mounts
|
|
6
|
+
* a block in a cross-origin iframe and answers its `postMessage` protocol:
|
|
7
|
+
* mints a token, runs the lazy-consent round-trip, brokers the orchestrator
|
|
8
|
+
* money path (estimate → submit → poll), opens the native Buzz-purchase and
|
|
9
|
+
* resource-picker modals. Locally — in a `vitest` test OR a starter's dev
|
|
10
|
+
* harness — there is no host, so this plays one.
|
|
11
|
+
*
|
|
12
|
+
* It is the portable core that the React `<Harness>` (a.k.a. `<MockHostProvider>`
|
|
13
|
+
* in `../testing`) wraps. Every block app used to hand-roll ~250 lines of this;
|
|
14
|
+
* now they configure it with {@link MockHostOptions} instead.
|
|
15
|
+
*
|
|
16
|
+
* Mechanism (mirrors the gen-matrix reference Harness):
|
|
17
|
+
* 1. Patches `window.parent.postMessage` via `Object.defineProperty(window,
|
|
18
|
+
* 'parent', …)` so the block's OUTBOUND messages are intercepted.
|
|
19
|
+
* 2. Replies as `MessageEvent`s fired from `window.location.origin` — the SDK
|
|
20
|
+
* `IframeTransport` DROPS any inbound message whose `origin` ≠ the allowed
|
|
21
|
+
* parent origin, so a block using this in dev MUST allow
|
|
22
|
+
* `window.location.origin` (the React `<Harness>` is documented for that).
|
|
23
|
+
* 3. Dispatches a configurable `BLOCK_INIT`, then answers the full protocol.
|
|
24
|
+
*
|
|
25
|
+
* NOT a real RS256 JWT, NO real Buzz, NO orchestrator — only the bridge
|
|
26
|
+
* round-trips are exercised. Never import this from production code.
|
|
27
|
+
*/
|
|
28
|
+
import { BrowsingLevel, SFW_LEVELS, } from '@civitai/app-sdk/blocks';
|
|
29
|
+
/** The full all-levels ceiling a `red` domain projects (mirrors the server). */
|
|
30
|
+
const ALL_LEVELS = BrowsingLevel.PG |
|
|
31
|
+
BrowsingLevel.PG13 |
|
|
32
|
+
BrowsingLevel.R |
|
|
33
|
+
BrowsingLevel.X |
|
|
34
|
+
BrowsingLevel.XXX;
|
|
35
|
+
const DEV_TOKEN = 'dev.mockhost.mock.jwt.NOT.A.REAL.RS256';
|
|
36
|
+
const BUDGETED_SCOPE = 'ai:write:budgeted';
|
|
37
|
+
const DEFAULT_CHECKPOINT_PICK = {
|
|
38
|
+
versionId: 691639,
|
|
39
|
+
modelId: 618692,
|
|
40
|
+
modelName: 'FLUX.1 [dev]',
|
|
41
|
+
versionName: 'fp8',
|
|
42
|
+
baseModel: 'Flux.1 D',
|
|
43
|
+
modelType: 'Checkpoint',
|
|
44
|
+
};
|
|
45
|
+
const DEFAULT_LORA_PICK = {
|
|
46
|
+
versionId: 666002,
|
|
47
|
+
modelId: 555002,
|
|
48
|
+
modelName: 'Sinfully Stylish',
|
|
49
|
+
versionName: 'v2.0',
|
|
50
|
+
baseModel: 'SDXL 1.0',
|
|
51
|
+
modelType: 'LORA',
|
|
52
|
+
};
|
|
53
|
+
const DEFAULT_VIEWER = { id: 2, username: 'dev-viewer', status: 'active' };
|
|
54
|
+
/**
|
|
55
|
+
* Reads the URL query toggles the gen-matrix dev harness uses, so a starter's
|
|
56
|
+
* dev harness keeps working with `?viewer/?consent/?fail/?theme/?pick/?pickCkpt`.
|
|
57
|
+
* Returns a partial overlay applied ON TOP of explicit {@link MockHostOptions}
|
|
58
|
+
* (URL wins — it's the interactive dev knob). No-op outside a browser.
|
|
59
|
+
*/
|
|
60
|
+
export function readMockHostUrlOptions(win = globalThis
|
|
61
|
+
.window) {
|
|
62
|
+
if (!win?.location?.search)
|
|
63
|
+
return {};
|
|
64
|
+
const params = new URLSearchParams(win.location.search);
|
|
65
|
+
const out = {};
|
|
66
|
+
if (params.get('viewer') === 'anon')
|
|
67
|
+
out.viewer = null;
|
|
68
|
+
if (params.get('consent') === 'granted')
|
|
69
|
+
out.consentGranted = true;
|
|
70
|
+
const fail = params.get('fail');
|
|
71
|
+
if (fail === 'insufficient' || fail === 'some' || fail === 'all' || fail === 'none') {
|
|
72
|
+
out.failMode = fail;
|
|
73
|
+
}
|
|
74
|
+
if (params.get('theme') === 'light')
|
|
75
|
+
out.theme = 'light';
|
|
76
|
+
else if (params.get('theme') === 'dark')
|
|
77
|
+
out.theme = 'dark';
|
|
78
|
+
// ?domain=green|blue|red projects a color-domain (and its derived ceiling);
|
|
79
|
+
// ?maturity=sfw|mature sets the ceiling directly.
|
|
80
|
+
const domain = params.get('domain');
|
|
81
|
+
if (domain === 'green' || domain === 'blue' || domain === 'red')
|
|
82
|
+
out.domain = domain;
|
|
83
|
+
const maturity = params.get('maturity');
|
|
84
|
+
if (maturity === 'sfw' || maturity === 'mature')
|
|
85
|
+
out.maturity = maturity;
|
|
86
|
+
// ?pick (LoRA) / ?pickCkpt (Checkpoint): 'cancel' → dismissed; 'pony' → an
|
|
87
|
+
// incompatible Pony LoRA; any other value → the default curated pick.
|
|
88
|
+
const pick = params.get('pick');
|
|
89
|
+
const pickCkpt = params.get('pickCkpt');
|
|
90
|
+
if (pick || pickCkpt) {
|
|
91
|
+
const cannedPicks = {};
|
|
92
|
+
if (pick === 'cancel')
|
|
93
|
+
cannedPicks.LORA = null;
|
|
94
|
+
else if (pick === 'pony')
|
|
95
|
+
cannedPicks.LORA = {
|
|
96
|
+
versionId: 555001,
|
|
97
|
+
modelId: 444001,
|
|
98
|
+
modelName: 'Incompatible Pony LoRA',
|
|
99
|
+
versionName: 'v1.0',
|
|
100
|
+
baseModel: 'Pony',
|
|
101
|
+
modelType: 'LORA',
|
|
102
|
+
};
|
|
103
|
+
else if (pick)
|
|
104
|
+
cannedPicks.LORA = DEFAULT_LORA_PICK;
|
|
105
|
+
if (pickCkpt === 'cancel')
|
|
106
|
+
cannedPicks.Checkpoint = null;
|
|
107
|
+
else if (pickCkpt)
|
|
108
|
+
cannedPicks.Checkpoint = DEFAULT_CHECKPOINT_PICK;
|
|
109
|
+
out.cannedPicks = cannedPicks;
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create a framework-agnostic mock host. Call the returned `install()` to patch
|
|
115
|
+
* `window.parent` + start answering the block's protocol; it returns an
|
|
116
|
+
* `uninstall()` teardown (restores `window.parent`, clears timers). Safe to use
|
|
117
|
+
* from a node/jsdom/happy-dom test OR a browser dev harness.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* const host = createMockHost({ failMode: 'some', pollsUntilDone: 1 });
|
|
121
|
+
* const uninstall = host.install();
|
|
122
|
+
* // … drive the block / assertions …
|
|
123
|
+
* uninstall();
|
|
124
|
+
*/
|
|
125
|
+
export function createMockHost(options = {}) {
|
|
126
|
+
const maybeWin = options.window ?? globalThis.window;
|
|
127
|
+
if (!maybeWin) {
|
|
128
|
+
throw new Error('createMockHost: no window available (call from a DOM environment).');
|
|
129
|
+
}
|
|
130
|
+
// Bind to a non-nullable local so the `install()` closure keeps the narrowing.
|
|
131
|
+
const win = maybeWin;
|
|
132
|
+
const viewer = options.viewer === undefined ? DEFAULT_VIEWER : options.viewer;
|
|
133
|
+
const failMode = options.failMode ?? 'none';
|
|
134
|
+
const pollsUntilDone = options.pollsUntilDone ?? 2;
|
|
135
|
+
const cost = options.cost ?? 8;
|
|
136
|
+
const buzzBudget = options.buzzBudget ?? 200;
|
|
137
|
+
const theme = options.theme ?? 'dark';
|
|
138
|
+
const cannedPicks = options.cannedPicks ?? { Checkpoint: DEFAULT_CHECKPOINT_PICK, LORA: DEFAULT_LORA_PICK };
|
|
139
|
+
const blockInstanceId = options.blockInstanceId ?? 'page_mock';
|
|
140
|
+
const blockId = options.blockId ?? 'mock-block';
|
|
141
|
+
const appId = options.appId ?? 'app_dev';
|
|
142
|
+
let installed = false;
|
|
143
|
+
let teardown = () => { };
|
|
144
|
+
function install() {
|
|
145
|
+
if (installed)
|
|
146
|
+
return teardown;
|
|
147
|
+
installed = true;
|
|
148
|
+
const parentOrigin = win.location.origin;
|
|
149
|
+
const originalParent = win.parent;
|
|
150
|
+
let consentGranted = !!options.consentGranted;
|
|
151
|
+
let tokenSerial = 0;
|
|
152
|
+
let submitCount = 0;
|
|
153
|
+
const workflows = new Map();
|
|
154
|
+
const timers = new Set();
|
|
155
|
+
const dispatchToBlock = (data) => {
|
|
156
|
+
win.dispatchEvent(new MessageEvent('message', { data, origin: parentOrigin }));
|
|
157
|
+
};
|
|
158
|
+
const nextToken = () => {
|
|
159
|
+
tokenSerial += 1;
|
|
160
|
+
return {
|
|
161
|
+
raw: `${DEV_TOKEN}.${tokenSerial}`,
|
|
162
|
+
scopes: consentGranted ? [BUDGETED_SCOPE] : [],
|
|
163
|
+
expiresAt: new Date(Date.now() + 15 * 60_000).toISOString(),
|
|
164
|
+
...(consentGranted ? { buzzBudget } : {}),
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
const succeededSnapshot = (workflowId) => ({
|
|
168
|
+
workflowId,
|
|
169
|
+
status: 'succeeded',
|
|
170
|
+
cost: { total: cost },
|
|
171
|
+
imageUrls: [
|
|
172
|
+
`https://placehold.co/512x512/1971c2/ffffff/png?text=${encodeURIComponent(workflowId.slice(-4))}`,
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
const parentMock = {
|
|
176
|
+
postMessage: (msg) => {
|
|
177
|
+
if (typeof msg !== 'object' ||
|
|
178
|
+
msg === null ||
|
|
179
|
+
typeof msg.type !== 'string') {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const typed = msg;
|
|
183
|
+
options.onOutbound?.({ type: typed.type, payload: typed.payload });
|
|
184
|
+
const requestId = typed.payload?.requestId;
|
|
185
|
+
switch (typed.type) {
|
|
186
|
+
case 'REQUEST_TOKEN':
|
|
187
|
+
dispatchToBlock({
|
|
188
|
+
type: 'TOKEN_REFRESH_RESPONSE',
|
|
189
|
+
payload: { ...(requestId ? { requestId } : {}), token: nextToken() },
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
case 'REQUEST_CONSENT': {
|
|
193
|
+
// Lazy-consent round-trip: grant the scope, then push a
|
|
194
|
+
// host-initiated TOKEN_REFRESH carrying it (the App's auto-resume
|
|
195
|
+
// depends on seeing the new scope on its token).
|
|
196
|
+
consentGranted = true;
|
|
197
|
+
const t = setTimeout(() => {
|
|
198
|
+
dispatchToBlock({ type: 'TOKEN_REFRESH', payload: { token: nextToken() } });
|
|
199
|
+
}, 0);
|
|
200
|
+
timers.add(t);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
case 'REQUEST_SIGN_IN':
|
|
204
|
+
// The real host opens its login UI; nothing to reply.
|
|
205
|
+
return;
|
|
206
|
+
case 'ESTIMATE_WORKFLOW':
|
|
207
|
+
dispatchToBlock({
|
|
208
|
+
type: 'ESTIMATE_RESULT',
|
|
209
|
+
payload: {
|
|
210
|
+
requestId,
|
|
211
|
+
snapshot: { workflowId: 'wf_estimate', status: 'pending', cost: { total: cost } },
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
return;
|
|
215
|
+
case 'SUBMIT_WORKFLOW': {
|
|
216
|
+
submitCount += 1;
|
|
217
|
+
const failThis = failMode === 'all' ||
|
|
218
|
+
failMode === 'insufficient' ||
|
|
219
|
+
(failMode === 'some' && submitCount % 3 === 0);
|
|
220
|
+
if (failThis) {
|
|
221
|
+
dispatchToBlock({
|
|
222
|
+
type: 'WORKFLOW_SUBMITTED',
|
|
223
|
+
payload: {
|
|
224
|
+
requestId,
|
|
225
|
+
snapshot: {
|
|
226
|
+
workflowId: `wf_fail_${submitCount}`,
|
|
227
|
+
status: 'failed',
|
|
228
|
+
error: 'Insufficient Buzz to run this generation.',
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const workflowId = `wf_${submitCount}_${Date.now()}`;
|
|
235
|
+
workflows.set(workflowId, { polls: 0 });
|
|
236
|
+
dispatchToBlock({
|
|
237
|
+
type: 'WORKFLOW_SUBMITTED',
|
|
238
|
+
payload: { requestId, snapshot: { workflowId, status: 'pending' } },
|
|
239
|
+
});
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
case 'POLL_WORKFLOW': {
|
|
243
|
+
const workflowId = typed.payload?.workflowId ?? '';
|
|
244
|
+
const wf = workflows.get(workflowId);
|
|
245
|
+
const polls = (wf?.polls ?? 0) + 1;
|
|
246
|
+
if (wf)
|
|
247
|
+
wf.polls = polls;
|
|
248
|
+
const snapshot = polls >= pollsUntilDone
|
|
249
|
+
? succeededSnapshot(workflowId)
|
|
250
|
+
: { workflowId, status: 'processing' };
|
|
251
|
+
dispatchToBlock({ type: 'WORKFLOW_STATUS', payload: { requestId, snapshot } });
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
case 'CANCEL_WORKFLOW': {
|
|
255
|
+
const workflowId = typed.payload?.workflowId ?? '';
|
|
256
|
+
workflows.delete(workflowId);
|
|
257
|
+
dispatchToBlock({
|
|
258
|
+
type: 'WORKFLOW_CANCELED',
|
|
259
|
+
payload: { requestId, snapshot: { workflowId, status: 'canceled' } },
|
|
260
|
+
});
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
case 'OPEN_BUZZ_PURCHASE':
|
|
264
|
+
dispatchToBlock({
|
|
265
|
+
type: 'BUZZ_PURCHASE_RESULT',
|
|
266
|
+
payload: { requestId, purchased: true, newBalance: 1000 },
|
|
267
|
+
});
|
|
268
|
+
return;
|
|
269
|
+
case 'OPEN_CHECKPOINT_PICKER': {
|
|
270
|
+
const selected = cannedPicks.Checkpoint;
|
|
271
|
+
dispatchToBlock({
|
|
272
|
+
type: 'CHECKPOINT_PICKER_RESULT',
|
|
273
|
+
payload: {
|
|
274
|
+
requestId,
|
|
275
|
+
...(selected
|
|
276
|
+
? {
|
|
277
|
+
selected: {
|
|
278
|
+
versionId: selected.versionId,
|
|
279
|
+
modelId: selected.modelId,
|
|
280
|
+
modelName: selected.modelName,
|
|
281
|
+
versionName: selected.versionName,
|
|
282
|
+
baseModel: selected.baseModel,
|
|
283
|
+
},
|
|
284
|
+
}
|
|
285
|
+
: {}),
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
case 'OPEN_RESOURCE_PICKER': {
|
|
291
|
+
const rtype = typed.payload?.resourceType;
|
|
292
|
+
const selected = rtype ? cannedPicks[rtype] : undefined;
|
|
293
|
+
dispatchToBlock({
|
|
294
|
+
type: 'RESOURCE_PICKER_RESULT',
|
|
295
|
+
payload: { requestId, ...(selected ? { selected } : {}) },
|
|
296
|
+
});
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
default:
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
Object.defineProperty(win, 'parent', {
|
|
305
|
+
value: parentMock,
|
|
306
|
+
configurable: true,
|
|
307
|
+
writable: true,
|
|
308
|
+
});
|
|
309
|
+
// Merge theme into the init context.
|
|
310
|
+
const baseContext = options.context ?? { slotId: 'app.page' };
|
|
311
|
+
const context = { ...baseContext, theme };
|
|
312
|
+
// Color-domain maturity (civitai #2670). Resolve the ceiling by precedence:
|
|
313
|
+
// explicit maxBrowsingLevel > maturity convenience > domain-derived. Only
|
|
314
|
+
// EMIT a field when the corresponding option was set, so the default mock
|
|
315
|
+
// host stays a #2670-predating host (the hook fail-closes to SFW).
|
|
316
|
+
const resolvedCeiling = options.maxBrowsingLevel !== undefined
|
|
317
|
+
? options.maxBrowsingLevel
|
|
318
|
+
: options.maturity === 'sfw'
|
|
319
|
+
? SFW_LEVELS
|
|
320
|
+
: options.maturity === 'mature'
|
|
321
|
+
? ALL_LEVELS
|
|
322
|
+
: options.domain !== undefined
|
|
323
|
+
? options.domain === 'red'
|
|
324
|
+
? ALL_LEVELS
|
|
325
|
+
: SFW_LEVELS
|
|
326
|
+
: undefined;
|
|
327
|
+
const initPayload = {
|
|
328
|
+
blockInstanceId,
|
|
329
|
+
blockId,
|
|
330
|
+
appId,
|
|
331
|
+
token: nextToken(),
|
|
332
|
+
context,
|
|
333
|
+
settings: { publisherSettings: {}, userSettings: {} },
|
|
334
|
+
viewer,
|
|
335
|
+
theme,
|
|
336
|
+
renderMode: 'iframe',
|
|
337
|
+
...(options.domain !== undefined ? { domain: options.domain } : {}),
|
|
338
|
+
...(resolvedCeiling !== undefined ? { maxBrowsingLevel: resolvedCeiling } : {}),
|
|
339
|
+
};
|
|
340
|
+
const initTimer = setTimeout(() => dispatchToBlock({ type: 'BLOCK_INIT', payload: initPayload }), 0);
|
|
341
|
+
timers.add(initTimer);
|
|
342
|
+
let torn = false;
|
|
343
|
+
teardown = () => {
|
|
344
|
+
if (torn)
|
|
345
|
+
return;
|
|
346
|
+
torn = true;
|
|
347
|
+
installed = false;
|
|
348
|
+
for (const t of timers)
|
|
349
|
+
clearTimeout(t);
|
|
350
|
+
timers.clear();
|
|
351
|
+
Object.defineProperty(win, 'parent', {
|
|
352
|
+
value: originalParent,
|
|
353
|
+
configurable: true,
|
|
354
|
+
writable: true,
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
return teardown;
|
|
358
|
+
}
|
|
359
|
+
return { install };
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=mockHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockHost.js","sourceRoot":"","sources":["../../src/internal/mockHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,aAAa,EACb,UAAU,GASX,MAAM,yBAAyB,CAAC;AAEjC,gFAAgF;AAChF,MAAM,UAAU,GACd,aAAa,CAAC,EAAE;IAChB,aAAa,CAAC,IAAI;IAClB,aAAa,CAAC,CAAC;IACf,aA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,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEtB,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,QAAQ,GAAG,GAAG,EAAE;YACd,IAAI,IAAI;gBAAE,OAAO;YACjB,IAAI,GAAG,IAAI,CAAC;YACZ,SAAS,GAAG,KAAK,CAAC;YAClB,KAAK,MAAM,CAAC,IAAI,MAAM;gBAAE,YAAY,CAAC,CAAC,CAAC,CAAC;YACxC,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE;gBACnC,KAAK,EAAE,cAAc;gBACrB,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;QACL,CAAC,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockContext, BlockInitPayload, BlockSettings, BlockToken, Theme, ViewerInfo, WrappedToken, ParentToBlockMessage, ParentToBlockMessageType, BlockToParentMessage, BlockToParentMessageType } from '@civitai/app-sdk/blocks';
|
|
1
|
+
import type { BlockContext, BlockInitPayload, BlockSettings, BlockToken, ColorDomain, Theme, ViewerInfo, WrappedToken, ParentToBlockMessage, ParentToBlockMessageType, BlockToParentMessage, BlockToParentMessageType } from '@civitai/app-sdk/blocks';
|
|
2
2
|
/**
|
|
3
3
|
* Synchronous snapshot the hooks read via `useSyncExternalStore`.
|
|
4
4
|
*
|
|
@@ -19,6 +19,19 @@ export interface BlockSnapshot {
|
|
|
19
19
|
blockInstanceId: string;
|
|
20
20
|
blockId: string;
|
|
21
21
|
appId: string;
|
|
22
|
+
/**
|
|
23
|
+
* The color-domain the host projected at init (`green`|`blue`|`red`), or
|
|
24
|
+
* `null`/`undefined` when absent (anon read, or a host predating PR #2670).
|
|
25
|
+
* Informational only — `useDomainMaturity` derives SFW from
|
|
26
|
+
* `maxBrowsingLevel`, not this. Sentinel-`undefined` before `BLOCK_INIT`.
|
|
27
|
+
*/
|
|
28
|
+
domain?: ColorDomain | null;
|
|
29
|
+
/**
|
|
30
|
+
* Authoritative domain browsing-level ceiling bitmask from `BLOCK_INIT`.
|
|
31
|
+
* `undefined` before init / when the host doesn't send it → consumers
|
|
32
|
+
* fail-closed to SFW.
|
|
33
|
+
*/
|
|
34
|
+
maxBrowsingLevel?: number;
|
|
22
35
|
}
|
|
23
36
|
/**
|
|
24
37
|
* Outbound message shape, without the auto-assigned `requestId` field.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/internal/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,KAAK,EACL,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAChC,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,aAAa,CAAC;IACxB,wEAAwE;IACxE,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/internal/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,wBAA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AE,oBAAoB,GAAG,IAAI,CAAC;IACjD,yEAAyE;IACzE,WAAW,CACT,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,wBAAwB,EACtC,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5B,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,SAAS,wBAAwB,EAC1E,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,IAAI,EAClB,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5B,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAInE;AAED,eAAO,MAAM,cAAc,EAAE,aAW5B,CAAC;AAEF,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAezE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,CAOlE;AAGD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAGtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/internal/transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/internal/transport.ts"],"names":[],"mappings":"AAgGA;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAAyB,EACzB,OAAwB,EACxB,YAAkB,EAClB,IAA6B;IAE7B,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACzE,+FAA+F;IAC/F,OAAO,OAAc,CAAC;AACxB,C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,UAAU;KAC/B,CAAC;AACJ,CAAC;AAED,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACzB;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,gBAAgB,IAAI,CAAC,CAAC;IACtB,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,gBAAgB,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/internal/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACb,MAAM,yBAAyB,CAAC;AAejC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,YAAY,CAQjE;AAED,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,gBAAgB,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/internal/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACb,MAAM,yBAAyB,CAAC;AAejC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,YAAY,CAQjE;AAED,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,gBAAgB,CA2DzE;AAcD,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,qBAAqB,CA4B9E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,CAI9B;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAKlD;AAED,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI;IAAE,QAAQ,EAAE,qBAAqB,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAK9D;AAED,wBAAgB,yBAAyB,CACvC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAMtE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GACX,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,IAAI,CAuBxC"}
|
|
@@ -86,6 +86,21 @@ export function isValidBlockInitPayload(p) {
|
|
|
86
86
|
}
|
|
87
87
|
if (p.theme !== 'light' && p.theme !== 'dark')
|
|
88
88
|
return false;
|
|
89
|
+
// Color-domain maturity (civitai #2670). Both OPTIONAL + additive: a host
|
|
90
|
+
// that predates #2670 omits them (still valid). When present, shape-check so
|
|
91
|
+
// a malformed value drops rather than poisoning `useDomainMaturity`. `domain`
|
|
92
|
+
// is informational; the SFW decision is derived from `maxBrowsingLevel`.
|
|
93
|
+
if (p.domain !== undefined &&
|
|
94
|
+
p.domain !== null &&
|
|
95
|
+
p.domain !== 'green' &&
|
|
96
|
+
p.domain !== 'blue' &&
|
|
97
|
+
p.domain !== 'red') {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (p.maxBrowsingLevel !== undefined &&
|
|
101
|
+
(typeof p.maxBrowsingLevel !== 'number' || !Number.isFinite(p.maxBrowsingLevel))) {
|
|
102
|
+
return false;
|
|
103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ED,MAAM,UAAU,yBAAyB,CACvC,CAAU;IAEV,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/B,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACnD,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACjF,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC/E,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY;IAEZ,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,uBAAuB,CAAC;QACjC,KAAK,eAAe;YAClB,OAAO,mBAAmB,CAAC;QAC7B,KAAK,wBAAwB;YAC3B,OAAO,2BAA2B,CAAC;QACrC,KAAK,iBAAiB,CAAC;QACvB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,iBAAiB,CAAC;QACvB,KAAK,mBAAmB;YACtB,OAAO,oBAAoB,CAAC;QAC9B,KAAK,sBAAsB;YACzB,OAAO,yBAAyB,CAAC;QACnC,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC;QACd;YACE,oEAAoE;YACpE,gDAAgD;YAChD,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,14 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Test-only helpers for `@civitai/blocks-react`. Not part of the runtime
|
|
3
|
-
* surface — block apps should never import from here
|
|
3
|
+
* surface — block apps should never import from here in production code (the
|
|
4
|
+
* `./testing` subpath keeps accidental prod imports visible in review).
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
+
* Exposes:
|
|
7
|
+
* - `resetTransport` / `mockParentMessage` — low-level test primitives.
|
|
8
|
+
* - `createMockHost` — a framework-agnostic fake of the civitai.com embedding
|
|
9
|
+
* host (usable from node/jsdom/happy-dom tests AND a dev harness).
|
|
10
|
+
* - `<Harness>` / `<MockHostProvider>` — a thin React wrapper that installs a
|
|
11
|
+
* mock host for local dev, with an optional on-screen message log.
|
|
12
|
+
*
|
|
13
|
+
* These replace the ~250-line per-block hand-rolled harness.
|
|
6
14
|
*/
|
|
15
|
+
import { type ReactNode } from 'react';
|
|
7
16
|
import { __resetTransport } from './internal/singleton.js';
|
|
17
|
+
import { type MockHostOptions } from './internal/mockHost.js';
|
|
8
18
|
export { __resetTransport as resetTransport };
|
|
19
|
+
export { createMockHost, readMockHostUrlOptions, type MockHost, type MockHostOptions, type MockHostFailMode, type CannedPick, } from './internal/mockHost.js';
|
|
9
20
|
/**
|
|
10
21
|
* Builds a `MessageEvent` that mimics a parent-frame postMessage so tests can
|
|
11
22
|
* exercise `IframeTransport.handleMessage` without a real cross-frame setup.
|
|
12
23
|
*/
|
|
13
24
|
export declare function mockParentMessage(data: unknown, origin: string): MessageEvent;
|
|
25
|
+
/**
|
|
26
|
+
* Props for the dev `<Harness>` (a.k.a. {@link MockHostProvider}).
|
|
27
|
+
*/
|
|
28
|
+
export interface HarnessProps extends MockHostOptions {
|
|
29
|
+
/** The block app to render inside the mocked host. */
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Read the gen-matrix URL toggles (`?viewer/?consent/?fail/?theme/?pick/
|
|
33
|
+
* ?pickCkpt`) and apply them ON TOP of the props (URL wins). Default `true`
|
|
34
|
+
* so a dev harness stays interactive. Pass `false` in a deterministic test.
|
|
35
|
+
*/
|
|
36
|
+
applyUrlToggles?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Render the on-screen outbound-message log panel (bottom-right). Default
|
|
39
|
+
* `true`. Set `false` to mount the mock host with no chrome.
|
|
40
|
+
*/
|
|
41
|
+
showLog?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Thin React wrapper that installs a {@link createMockHost} on mount (and tears
|
|
45
|
+
* it down on unmount) so a block app renders against a fake civitai host for
|
|
46
|
+
* local dev — no real platform, no real Buzz.
|
|
47
|
+
*
|
|
48
|
+
* IMPORTANT: the SDK transport DROPS inbound host messages whose origin isn't
|
|
49
|
+
* in its allowlist, and the mock host fires from `window.location.origin`. So
|
|
50
|
+
* a block app using `<Harness>` in dev MUST include its OWN origin in the
|
|
51
|
+
* transport allowlist, e.g.:
|
|
52
|
+
*
|
|
53
|
+
* VITE_BLOCK_ALLOWED_PARENT_ORIGINS=http://localhost:5173
|
|
54
|
+
*
|
|
55
|
+
* (or pass it to `getTransport({ allowedParentOrigins: [window.location.origin] })`
|
|
56
|
+
* in the harness entrypoint). Otherwise BLOCK_INIT never lands.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* createRoot(el).render(
|
|
60
|
+
* <Harness failMode="some">
|
|
61
|
+
* <App />
|
|
62
|
+
* </Harness>,
|
|
63
|
+
* );
|
|
64
|
+
*/
|
|
65
|
+
export declare function Harness({ children, applyUrlToggles, showLog, ...options }: HarnessProps): import("react/jsx-runtime").JSX.Element;
|
|
66
|
+
/** Alias of {@link Harness} — same component, clearer name when used as a context provider. */
|
|
67
|
+
export declare const MockHostProvider: typeof Harness;
|
|
14
68
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,IAAI,cAAc,EAAE,CAAC;AAE9C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,wBAAwB,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAE7E;AAOD;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,sDAAsD;IACtD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,eAAsB,EACtB,OAAc,EACd,GAAG,OAAO,EACX,EAAE,YAAY,2CAiDd;AAED,+FAA+F;AAC/F,eAAO,MAAM,gBAAgB,gBAAU,CAAC"}
|
package/dist/testing.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
/**
|
|
2
3
|
* Test-only helpers for `@civitai/blocks-react`. Not part of the runtime
|
|
3
|
-
* surface — block apps should never import from here
|
|
4
|
+
* surface — block apps should never import from here in production code (the
|
|
5
|
+
* `./testing` subpath keeps accidental prod imports visible in review).
|
|
4
6
|
*
|
|
5
|
-
*
|
|
7
|
+
* Exposes:
|
|
8
|
+
* - `resetTransport` / `mockParentMessage` — low-level test primitives.
|
|
9
|
+
* - `createMockHost` — a framework-agnostic fake of the civitai.com embedding
|
|
10
|
+
* host (usable from node/jsdom/happy-dom tests AND a dev harness).
|
|
11
|
+
* - `<Harness>` / `<MockHostProvider>` — a thin React wrapper that installs a
|
|
12
|
+
* mock host for local dev, with an optional on-screen message log.
|
|
13
|
+
*
|
|
14
|
+
* These replace the ~250-line per-block hand-rolled harness.
|
|
6
15
|
*/
|
|
16
|
+
import { useEffect, useRef, useState } from 'react';
|
|
7
17
|
import { __resetTransport } from './internal/singleton.js';
|
|
18
|
+
import { createMockHost, readMockHostUrlOptions, } from './internal/mockHost.js';
|
|
8
19
|
export { __resetTransport as resetTransport };
|
|
20
|
+
export { createMockHost, readMockHostUrlOptions, } from './internal/mockHost.js';
|
|
9
21
|
/**
|
|
10
22
|
* Builds a `MessageEvent` that mimics a parent-frame postMessage so tests can
|
|
11
23
|
* exercise `IframeTransport.handleMessage` without a real cross-frame setup.
|
|
@@ -13,4 +25,72 @@ export { __resetTransport as resetTransport };
|
|
|
13
25
|
export function mockParentMessage(data, origin) {
|
|
14
26
|
return new MessageEvent('message', { data, origin, source: null });
|
|
15
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Thin React wrapper that installs a {@link createMockHost} on mount (and tears
|
|
30
|
+
* it down on unmount) so a block app renders against a fake civitai host for
|
|
31
|
+
* local dev — no real platform, no real Buzz.
|
|
32
|
+
*
|
|
33
|
+
* IMPORTANT: the SDK transport DROPS inbound host messages whose origin isn't
|
|
34
|
+
* in its allowlist, and the mock host fires from `window.location.origin`. So
|
|
35
|
+
* a block app using `<Harness>` in dev MUST include its OWN origin in the
|
|
36
|
+
* transport allowlist, e.g.:
|
|
37
|
+
*
|
|
38
|
+
* VITE_BLOCK_ALLOWED_PARENT_ORIGINS=http://localhost:5173
|
|
39
|
+
*
|
|
40
|
+
* (or pass it to `getTransport({ allowedParentOrigins: [window.location.origin] })`
|
|
41
|
+
* in the harness entrypoint). Otherwise BLOCK_INIT never lands.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* createRoot(el).render(
|
|
45
|
+
* <Harness failMode="some">
|
|
46
|
+
* <App />
|
|
47
|
+
* </Harness>,
|
|
48
|
+
* );
|
|
49
|
+
*/
|
|
50
|
+
export function Harness({ children, applyUrlToggles = true, showLog = true, ...options }) {
|
|
51
|
+
const [outbound, setOutbound] = useState([]);
|
|
52
|
+
// Snapshot the merged options once per mount so the effect's identity is
|
|
53
|
+
// stable (avoids re-installing the host on every render).
|
|
54
|
+
const optionsRef = useRef(null);
|
|
55
|
+
if (optionsRef.current === null) {
|
|
56
|
+
const urlOverlay = applyUrlToggles ? readMockHostUrlOptions() : {};
|
|
57
|
+
optionsRef.current = { ...options, ...urlOverlay };
|
|
58
|
+
}
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const host = createMockHost({
|
|
61
|
+
...optionsRef.current,
|
|
62
|
+
onOutbound: (msg) => {
|
|
63
|
+
optionsRef.current.onOutbound?.(msg);
|
|
64
|
+
if (msg.type === 'RESIZE_IFRAME')
|
|
65
|
+
return; // noise; skip the log
|
|
66
|
+
queueMicrotask(() => setOutbound((prev) => [...prev, msg]));
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return host.install();
|
|
70
|
+
}, []);
|
|
71
|
+
const opts = optionsRef.current;
|
|
72
|
+
const anon = opts.viewer === null;
|
|
73
|
+
const theme = opts.theme ?? 'dark';
|
|
74
|
+
const consent = opts.consentGranted ? 'granted' : 'withheld';
|
|
75
|
+
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%' }, children: children }), showLog && (_jsxs("details", { style: harnessLogStyle, children: [_jsxs("summary", { style: { cursor: 'pointer' }, children: ["DEV HARNESS \u00B7 viewer=", anon ? 'anon' : 'dev-viewer', " \u00B7 consent=", consent, " \u00B7 theme=", theme, " \u00B7 outbound:", outbound.length] }), _jsx("pre", { style: { margin: 0, maxHeight: 200, overflow: 'auto' }, children: outbound.length === 0
|
|
76
|
+
? '// no outbound messages yet'
|
|
77
|
+
: outbound
|
|
78
|
+
.map((m, i) => `${i + 1}. ${m.type} ${JSON.stringify(m.payload ?? {})}`)
|
|
79
|
+
.join('\n') })] }))] }));
|
|
80
|
+
}
|
|
81
|
+
/** Alias of {@link Harness} — same component, clearer name when used as a context provider. */
|
|
82
|
+
export const MockHostProvider = Harness;
|
|
83
|
+
const harnessLogStyle = {
|
|
84
|
+
position: 'fixed',
|
|
85
|
+
bottom: 8,
|
|
86
|
+
right: 8,
|
|
87
|
+
zIndex: 9999,
|
|
88
|
+
maxWidth: 520,
|
|
89
|
+
background: 'rgba(17,17,17,0.92)',
|
|
90
|
+
color: '#7fc',
|
|
91
|
+
fontSize: 11,
|
|
92
|
+
fontFamily: 'ui-monospace, SFMono-Regular, monospace',
|
|
93
|
+
padding: '6px 10px',
|
|
94
|
+
borderRadius: 6,
|
|
95
|
+
};
|
|
16
96
|
//# sourceMappingURL=testing.js.map
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.
|
|
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,GAKvB,MAAM,wBAAwB,CAAC;AAEhC;;;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;AA0BD;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ACb,UAAU,EAAE,qBAAqB;IACjC,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,yCAAyC;IACrD,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,CAAC;CACP,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civitai/blocks-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"node": ">=20"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@civitai/app-sdk": ">=0.
|
|
31
|
+
"@civitai/app-sdk": ">=0.13.0",
|
|
32
32
|
"react": "^18.0.0 || ^19.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"react-dom": "^19.0.0",
|
|
41
41
|
"typescript": "^5.9.2",
|
|
42
42
|
"vitest": "^4.1.7",
|
|
43
|
-
"@civitai/app-sdk": "^0.
|
|
43
|
+
"@civitai/app-sdk": "^0.13.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|