@civitai/app-sdk 0.12.0 → 0.13.1
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 +1 -1
- package/dist/blocks/browsingLevel.d.ts +86 -0
- package/dist/blocks/browsingLevel.d.ts.map +1 -0
- package/dist/blocks/browsingLevel.js +90 -0
- package/dist/blocks/browsingLevel.js.map +1 -0
- package/dist/blocks/index.d.ts +2 -0
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +1 -0
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/messages.d.ts +22 -0
- package/dist/blocks/messages.d.ts.map +1 -1
- package/dist/blocks/messages.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ pnpm add @civitai/app-sdk
|
|
|
18
18
|
| `scopes/*` — `TokenScope`, `TokenScopePresets`, `bitmaskFromScopes`, `scopesFromBitmask`, `hasScope`, `getScopeLabel` | Civitai scopes are stored as bitmasks. These helpers let you compose scope sets from named flags rather than magic numbers. |
|
|
19
19
|
| `cookies/*` — `sealCookie`, `unsealCookie`, `buildSetCookieHeader`, `readCookie` | AES-256-CTR encrypted cookie crypto. Use to seal a session blob (refresh token, expiry, scope) into an `httpOnly` cookie with zero external session store. |
|
|
20
20
|
| `orchestrator/*` — `createOrchestratorClient`, `estimateWorkflow`, `submitWorkflow`, `getWorkflow`, `pollWorkflow`, `buildTextToImageBody`, `buildImageGenBody`, `buildWorkflowBody`, `WORKFLOW_STEP_TYPES`, `IMAGE_GEN_ENGINES`, `isTerminal`, `extractImageUrls`, `OrchestratorError`, `WorkflowSnapshot`, `GenerateInput`, `ImageGenInput`, `WorkflowStepType`, `ImageGenEngine`, `DEFAULT_MODEL_AIR` | Orchestrator workflow glue — types, body builders, raw HTTP, and long-poll helper. Client + server safe (fetch-only). `estimateWorkflow` calls `?whatif=true` to preview Buzz cost without spending. `pollWorkflow` long-polls to terminal status. `WORKFLOW_STEP_TYPES` is the catalog of every step `$type` the orchestrator accepts. |
|
|
21
|
-
| `blocks/*` — `defineBlock`, `BlockManifestError`, `BLOCK_SCOPES`, `BLOCK_SCOPE_PATTERN`, `isMessage`, types (`BlockManifestV1`, `BlockContext`, `BlockToken`, `BlockSettings`, `ViewerInfo`, `ThemeInfo`, `BlockWorkflowSnapshot`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`, …) | Framework-agnostic contract for [Civitai App Blocks](https://
|
|
21
|
+
| `blocks/*` — `defineBlock`, `BlockManifestError`, `BLOCK_SCOPES`, `BLOCK_SCOPE_PATTERN`, `isMessage`, types (`BlockManifestV1`, `BlockContext`, `BlockToken`, `BlockSettings`, `ViewerInfo`, `ThemeInfo`, `BlockWorkflowSnapshot`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`, …) | Framework-agnostic contract for [Civitai App Blocks](https://github.com/civitai/civitai-app-starters/blob/main/docs/build-your-first-app-block.md). `defineBlock(config)` validates a `BlockManifestV1` at startup so authoring mistakes surface in `pnpm dev` instead of at `civitai app validate`/submit. Ships the JSON Schema (draft-07) at the `./schemas/app-block/v1.json` subpath for offline validation. Runtime-agnostic — no React or DOM types. Hooks and the iframe transport live in a separate package. |
|
|
22
22
|
|
|
23
23
|
## Subpath imports
|
|
24
24
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browsing-level bit constants + ceiling helpers for App Blocks.
|
|
3
|
+
*
|
|
4
|
+
* The host (civitai/civitai) projects an authoritative `maxBrowsingLevel`
|
|
5
|
+
* BITMASK into `BLOCK_INIT` — the max NSFW levels the surrounding color-domain
|
|
6
|
+
* allows (computed server-side from `domainBrowsingCeiling(color)`). A block
|
|
7
|
+
* reads it via `useDomainMaturity()` to decide whether to surface mature
|
|
8
|
+
* affordances.
|
|
9
|
+
*
|
|
10
|
+
* The per-level bit VALUES below mirror civitai/civitai's server `NsfwLevel`
|
|
11
|
+
* enum. They are STABLE wire values (a level's bit never changes), so it is
|
|
12
|
+
* safe to hardcode them in the SDK. What is NOT encoded here is the green/blue/
|
|
13
|
+
* red → ceiling POLICY: that lives server-side (the host computes the mask and
|
|
14
|
+
* sends it), so the SDK derives "is this domain SFW?" from the BITMASK, never
|
|
15
|
+
* from the `domain` string. If the platform ever flips blue's policy, this SDK
|
|
16
|
+
* keeps working with no change.
|
|
17
|
+
*
|
|
18
|
+
* @see civitai/civitai `src/shared/constants/browsingLevel.constants.ts`
|
|
19
|
+
* (`NsfwLevel`) and `domainBrowsingCeiling`.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Per-level NSFW bit values. Mirrors the server `NsfwLevel` enum — stable wire
|
|
23
|
+
* values, not the green/blue/red policy.
|
|
24
|
+
*/
|
|
25
|
+
export declare const BrowsingLevel: {
|
|
26
|
+
readonly PG: 1;
|
|
27
|
+
readonly PG13: 2;
|
|
28
|
+
readonly R: 4;
|
|
29
|
+
readonly X: 8;
|
|
30
|
+
readonly XXX: 16;
|
|
31
|
+
readonly Blocked: 32;
|
|
32
|
+
};
|
|
33
|
+
export type BrowsingLevelKey = keyof typeof BrowsingLevel;
|
|
34
|
+
export type BrowsingLevelBit = (typeof BrowsingLevel)[BrowsingLevelKey];
|
|
35
|
+
/**
|
|
36
|
+
* The levels considered "safe for work" — PG + PG13. A ceiling that contains
|
|
37
|
+
* ONLY these bits (or none) is an SFW domain.
|
|
38
|
+
*/
|
|
39
|
+
export declare const SFW_LEVELS: number;
|
|
40
|
+
/**
|
|
41
|
+
* The NSFW levels — R + X + XXX. (`Blocked` is excluded: it is never an
|
|
42
|
+
* "allowed" browsing level, it marks content removed from view.) A ceiling
|
|
43
|
+
* that contains ANY of these bits is a mature domain.
|
|
44
|
+
*/
|
|
45
|
+
export declare const NSFW_LEVELS: number;
|
|
46
|
+
/**
|
|
47
|
+
* True when the domain's browsing-level ceiling permits NO NSFW content.
|
|
48
|
+
*
|
|
49
|
+
* Derived purely from the BITMASK: SFW ⇔ the ceiling has no NSFW bits set.
|
|
50
|
+
*
|
|
51
|
+
* **Fail-closed SFW.** A missing / null / non-finite mask (e.g. before
|
|
52
|
+
* `BLOCK_INIT` lands, or a host that predates PR #2670 and doesn't send the
|
|
53
|
+
* field) returns `true` — matching the server's fail-closed-SFW default. A
|
|
54
|
+
* block must therefore treat "unknown" as SFW and hide mature affordances
|
|
55
|
+
* until proven otherwise.
|
|
56
|
+
*
|
|
57
|
+
* @param maxBrowsingLevel the domain ceiling bitmask from `BLOCK_INIT`.
|
|
58
|
+
* @example
|
|
59
|
+
* isSfwCeiling(BrowsingLevel.PG | BrowsingLevel.PG13); // true (green/blue)
|
|
60
|
+
* isSfwCeiling(BrowsingLevel.PG | BrowsingLevel.X); // false (mature)
|
|
61
|
+
* isSfwCeiling(undefined); // true (fail-closed)
|
|
62
|
+
*/
|
|
63
|
+
export declare function isSfwCeiling(maxBrowsingLevel?: number | null): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* True when a specific browsing `level` bit is permitted by the domain ceiling.
|
|
66
|
+
*
|
|
67
|
+
* **Fail-closed.** A missing / null / non-finite ceiling permits ONLY SFW
|
|
68
|
+
* levels (PG / PG13) — same fail-closed posture as {@link isSfwCeiling}. A
|
|
69
|
+
* non-finite / non-positive `level` returns `false`.
|
|
70
|
+
*
|
|
71
|
+
* @param level a single `BrowsingLevel` bit (e.g. `BrowsingLevel.R`).
|
|
72
|
+
* @param maxBrowsingLevel the domain ceiling bitmask from `BLOCK_INIT`.
|
|
73
|
+
* @example
|
|
74
|
+
* isLevelAllowed(BrowsingLevel.R, BrowsingLevel.PG | BrowsingLevel.PG13); // false
|
|
75
|
+
* isLevelAllowed(BrowsingLevel.PG13, undefined); // true
|
|
76
|
+
* isLevelAllowed(BrowsingLevel.X, undefined); // false
|
|
77
|
+
*/
|
|
78
|
+
export declare function isLevelAllowed(level: number, maxBrowsingLevel?: number | null): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The color-domain a block is rendered inside, as projected by the host. The
|
|
81
|
+
* SFW policy is NOT derived from this — use {@link isSfwCeiling} on the
|
|
82
|
+
* accompanying `maxBrowsingLevel` mask instead. `null` / absent means the host
|
|
83
|
+
* did not project a domain (treat as unknown ⇒ fail-closed SFW).
|
|
84
|
+
*/
|
|
85
|
+
export type ColorDomain = 'green' | 'blue' | 'red';
|
|
86
|
+
//# sourceMappingURL=browsingLevel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browsingLevel.d.ts","sourceRoot":"","sources":["../../src/blocks/browsingLevel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,aAAa,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,gBAAgB,CAAC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAwC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAwD,CAAC;AAEjF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAKtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CASvF;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browsing-level bit constants + ceiling helpers for App Blocks.
|
|
3
|
+
*
|
|
4
|
+
* The host (civitai/civitai) projects an authoritative `maxBrowsingLevel`
|
|
5
|
+
* BITMASK into `BLOCK_INIT` — the max NSFW levels the surrounding color-domain
|
|
6
|
+
* allows (computed server-side from `domainBrowsingCeiling(color)`). A block
|
|
7
|
+
* reads it via `useDomainMaturity()` to decide whether to surface mature
|
|
8
|
+
* affordances.
|
|
9
|
+
*
|
|
10
|
+
* The per-level bit VALUES below mirror civitai/civitai's server `NsfwLevel`
|
|
11
|
+
* enum. They are STABLE wire values (a level's bit never changes), so it is
|
|
12
|
+
* safe to hardcode them in the SDK. What is NOT encoded here is the green/blue/
|
|
13
|
+
* red → ceiling POLICY: that lives server-side (the host computes the mask and
|
|
14
|
+
* sends it), so the SDK derives "is this domain SFW?" from the BITMASK, never
|
|
15
|
+
* from the `domain` string. If the platform ever flips blue's policy, this SDK
|
|
16
|
+
* keeps working with no change.
|
|
17
|
+
*
|
|
18
|
+
* @see civitai/civitai `src/shared/constants/browsingLevel.constants.ts`
|
|
19
|
+
* (`NsfwLevel`) and `domainBrowsingCeiling`.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Per-level NSFW bit values. Mirrors the server `NsfwLevel` enum — stable wire
|
|
23
|
+
* values, not the green/blue/red policy.
|
|
24
|
+
*/
|
|
25
|
+
export const BrowsingLevel = {
|
|
26
|
+
PG: 1,
|
|
27
|
+
PG13: 2,
|
|
28
|
+
R: 4,
|
|
29
|
+
X: 8,
|
|
30
|
+
XXX: 16,
|
|
31
|
+
Blocked: 32,
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The levels considered "safe for work" — PG + PG13. A ceiling that contains
|
|
35
|
+
* ONLY these bits (or none) is an SFW domain.
|
|
36
|
+
*/
|
|
37
|
+
export const SFW_LEVELS = BrowsingLevel.PG | BrowsingLevel.PG13;
|
|
38
|
+
/**
|
|
39
|
+
* The NSFW levels — R + X + XXX. (`Blocked` is excluded: it is never an
|
|
40
|
+
* "allowed" browsing level, it marks content removed from view.) A ceiling
|
|
41
|
+
* that contains ANY of these bits is a mature domain.
|
|
42
|
+
*/
|
|
43
|
+
export const NSFW_LEVELS = BrowsingLevel.R | BrowsingLevel.X | BrowsingLevel.XXX;
|
|
44
|
+
/**
|
|
45
|
+
* True when the domain's browsing-level ceiling permits NO NSFW content.
|
|
46
|
+
*
|
|
47
|
+
* Derived purely from the BITMASK: SFW ⇔ the ceiling has no NSFW bits set.
|
|
48
|
+
*
|
|
49
|
+
* **Fail-closed SFW.** A missing / null / non-finite mask (e.g. before
|
|
50
|
+
* `BLOCK_INIT` lands, or a host that predates PR #2670 and doesn't send the
|
|
51
|
+
* field) returns `true` — matching the server's fail-closed-SFW default. A
|
|
52
|
+
* block must therefore treat "unknown" as SFW and hide mature affordances
|
|
53
|
+
* until proven otherwise.
|
|
54
|
+
*
|
|
55
|
+
* @param maxBrowsingLevel the domain ceiling bitmask from `BLOCK_INIT`.
|
|
56
|
+
* @example
|
|
57
|
+
* isSfwCeiling(BrowsingLevel.PG | BrowsingLevel.PG13); // true (green/blue)
|
|
58
|
+
* isSfwCeiling(BrowsingLevel.PG | BrowsingLevel.X); // false (mature)
|
|
59
|
+
* isSfwCeiling(undefined); // true (fail-closed)
|
|
60
|
+
*/
|
|
61
|
+
export function isSfwCeiling(maxBrowsingLevel) {
|
|
62
|
+
if (typeof maxBrowsingLevel !== 'number' || !Number.isFinite(maxBrowsingLevel)) {
|
|
63
|
+
return true; // fail-closed: unknown ceiling ⇒ SFW
|
|
64
|
+
}
|
|
65
|
+
return (maxBrowsingLevel & NSFW_LEVELS) === 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* True when a specific browsing `level` bit is permitted by the domain ceiling.
|
|
69
|
+
*
|
|
70
|
+
* **Fail-closed.** A missing / null / non-finite ceiling permits ONLY SFW
|
|
71
|
+
* levels (PG / PG13) — same fail-closed posture as {@link isSfwCeiling}. A
|
|
72
|
+
* non-finite / non-positive `level` returns `false`.
|
|
73
|
+
*
|
|
74
|
+
* @param level a single `BrowsingLevel` bit (e.g. `BrowsingLevel.R`).
|
|
75
|
+
* @param maxBrowsingLevel the domain ceiling bitmask from `BLOCK_INIT`.
|
|
76
|
+
* @example
|
|
77
|
+
* isLevelAllowed(BrowsingLevel.R, BrowsingLevel.PG | BrowsingLevel.PG13); // false
|
|
78
|
+
* isLevelAllowed(BrowsingLevel.PG13, undefined); // true
|
|
79
|
+
* isLevelAllowed(BrowsingLevel.X, undefined); // false
|
|
80
|
+
*/
|
|
81
|
+
export function isLevelAllowed(level, maxBrowsingLevel) {
|
|
82
|
+
if (typeof level !== 'number' || !Number.isFinite(level) || level <= 0) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
const ceiling = typeof maxBrowsingLevel === 'number' && Number.isFinite(maxBrowsingLevel)
|
|
86
|
+
? maxBrowsingLevel
|
|
87
|
+
: SFW_LEVELS; // fail-closed: unknown ceiling ⇒ SFW-only
|
|
88
|
+
return (ceiling & level) === level;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=browsingLevel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browsingLevel.js","sourceRoot":"","sources":["../../src/blocks/browsingLevel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,EAAE,EAAE,CAAC;IACL,IAAI,EAAE,CAAC;IACP,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;CACH,CAAC;AAKX;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC;AAEhE;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC;AAEjF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,gBAAgC;IAC3D,IAAI,OAAO,gBAAgB,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC/E,OAAO,IAAI,CAAC,CAAC,qCAAqC;IACpD,CAAC;IACD,OAAO,CAAC,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,gBAAgC;IAC5E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACvE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,OAAO,GACX,OAAO,gBAAgB,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QACvE,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,UAAU,CAAC,CAAC,0CAA0C;IAC5D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,KAAK,CAAC;AACrC,CAAC"}
|
package/dist/blocks/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export { defineBlock, BlockManifestError } from './defineBlock.js';
|
|
|
10
10
|
export type { DefineBlockConfig } from './defineBlock.js';
|
|
11
11
|
export { BLOCK_SCOPES, BLOCK_SCOPE_PATTERN } from './scopes.js';
|
|
12
12
|
export type { BlockScope, BlockScopeKey } from './scopes.js';
|
|
13
|
+
export { BrowsingLevel, SFW_LEVELS, NSFW_LEVELS, isSfwCeiling, isLevelAllowed, } from './browsingLevel.js';
|
|
14
|
+
export type { BrowsingLevelKey, BrowsingLevelBit, ColorDomain } from './browsingLevel.js';
|
|
13
15
|
export { isMessage } from './messages.js';
|
|
14
16
|
export type { BlockInitPayload, BlockToParentMessage, BlockToParentMessageType, ParentToBlockMessage, ParentToBlockMessageType, WrappedToken, } from './messages.js';
|
|
15
17
|
export type { BlockContext, BlockManifest, BlockManifestV1, BlockSettings, BlockToken, ContentRating, ManifestAsset, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockTextToImageParams, BlockWorkflowSnapshot, ShowcaseImage, WorkflowBody, WorkflowStatus, } from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,aAAa,EACb,UAAU,EACV,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,KAAK,EACL,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,aAAa,EACb,UAAU,EACV,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,KAAK,EACL,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/blocks/index.js
CHANGED
|
@@ -8,5 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { defineBlock, BlockManifestError } from './defineBlock.js';
|
|
10
10
|
export { BLOCK_SCOPES, BLOCK_SCOPE_PATTERN } from './scopes.js';
|
|
11
|
+
export { BrowsingLevel, SFW_LEVELS, NSFW_LEVELS, isSfwCeiling, isLevelAllowed, } from './browsingLevel.js';
|
|
11
12
|
export { isMessage } from './messages.js';
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/dist/blocks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Wire format: `window.postMessage({ type, payload }, targetOrigin)`.
|
|
9
9
|
*/
|
|
10
|
+
import type { ColorDomain } from './browsingLevel.js';
|
|
10
11
|
import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot } from './types.js';
|
|
11
12
|
/**
|
|
12
13
|
* The wrapped token shape the host sends to the block. `raw` is the JWT;
|
|
@@ -45,6 +46,27 @@ export interface BlockInitPayload {
|
|
|
45
46
|
viewer: ViewerInfo | null;
|
|
46
47
|
theme: Theme;
|
|
47
48
|
renderMode: 'iframe' | 'inline';
|
|
49
|
+
/**
|
|
50
|
+
* The color-domain the block is rendered inside (`green` | `blue` | `red`),
|
|
51
|
+
* or `null` when the host did not resolve one. Informational ONLY — the SFW
|
|
52
|
+
* policy is server-side; derive "is this SFW?" from {@link maxBrowsingLevel}
|
|
53
|
+
* (via `isSfwCeiling` / `useDomainMaturity`), never from this string.
|
|
54
|
+
*
|
|
55
|
+
* Sent by civitai/civitai PR #2670. A host that predates it omits this field
|
|
56
|
+
* (reads `undefined`).
|
|
57
|
+
*/
|
|
58
|
+
domain?: ColorDomain | null;
|
|
59
|
+
/**
|
|
60
|
+
* Authoritative browsing-level BITMASK = the max NSFW levels the domain
|
|
61
|
+
* allows, computed server-side from `domainBrowsingCeiling(color)` (green/
|
|
62
|
+
* blue → SFW, red → all). Bits mirror the server `NsfwLevel` (see
|
|
63
|
+
* `browsingLevel.ts`). A block reads this to decide whether to surface mature
|
|
64
|
+
* affordances — `isSfwCeiling(maxBrowsingLevel)` is the canonical test.
|
|
65
|
+
*
|
|
66
|
+
* Sent by civitai/civitai PR #2670. A host that predates it omits this field
|
|
67
|
+
* (reads `undefined`); the SDK fail-closes to SFW when it is absent.
|
|
68
|
+
*/
|
|
69
|
+
maxBrowsingLevel?: number;
|
|
48
70
|
}
|
|
49
71
|
export type ParentToBlockMessage = {
|
|
50
72
|
type: 'BLOCK_INIT';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/blocks/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,KAAK,EACL,UAAU,EACV,YAAY,EACZ,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAMpB;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE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,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAClG,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,CAAC,GACN,IAAI,IAAI,OAAO,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAOjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/blocks/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/blocks/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqTH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CACvB,IAAa,EACb,IAAO;IAEP,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,MAAM,IAAI,IAAI;QACb,IAA0B,CAAC,IAAI,KAAK,IAAI,CAC1C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED