@civitai/app-sdk 0.69.1 → 0.70.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/blocks/index.d.ts +1 -1
- package/dist/blocks/messages.d.ts +30 -2
- package/dist/blocks/messages.js +1 -0
- package/dist/blocks/types.d.ts +70 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/blocks/index.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
|
|
|
109
109
|
* in `types.ts` for which of the two it uses and why.
|
|
110
110
|
*/
|
|
111
111
|
export { isSignedIn } from './types.js';
|
|
112
|
-
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDatasetResult, BlockTrainingRejectionReason, BlockPrepareTrainingDatasetHostError, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
|
|
112
|
+
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDatasetResult, BlockTrainingRejectionReason, BlockPrepareTrainingDatasetHostError, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
|
|
113
113
|
/** Host bound for the App Blocks `kind: 'workflow'` body — see `WorkflowBodyWorkflow`. */
|
|
114
114
|
export { BLOCK_WORKFLOW_MAX_STEPS, BLOCK_WORKFLOW_REPEAT_MAX_ITERATIONS } from './types.js';
|
|
115
115
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Wire format: `window.postMessage({ type, payload }, targetOrigin)`.
|
|
9
9
|
*/
|
|
10
10
|
import type { ColorDomain } from './browsingLevel.js';
|
|
11
|
-
import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostResult, BlockTrainingDatasetItem, BlockTrainingDatasetResult, WorkflowBodyTraining, WorkflowBodyPassThroughStep } from './types.js';
|
|
11
|
+
import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostResult, BlockTrainingDatasetItem, BlockTrainingDatasetResult, WorkflowBodyTraining, WorkflowBodyPassThroughStep } from './types.js';
|
|
12
12
|
/**
|
|
13
13
|
* Filter params for `GET_BUZZ_TRANSACTIONS`. All optional; the host validates
|
|
14
14
|
* them server-side (they are NEVER trusted for auth — the account is self-bound
|
|
@@ -569,6 +569,14 @@ export type ParentToBlockMessage = {
|
|
|
569
569
|
imageId: number;
|
|
570
570
|
result: BlockImageScanResult;
|
|
571
571
|
};
|
|
572
|
+
} | {
|
|
573
|
+
type: 'IMAGE_PICKER_RESULT';
|
|
574
|
+
payload: {
|
|
575
|
+
requestId: string;
|
|
576
|
+
selected?: BlockPickedImageInfo;
|
|
577
|
+
selectedImages?: BlockPickedImageInfo[];
|
|
578
|
+
error?: string;
|
|
579
|
+
};
|
|
572
580
|
} | {
|
|
573
581
|
type: 'USER_CHECKPOINT_SET';
|
|
574
582
|
payload: {
|
|
@@ -911,6 +919,26 @@ export type BlockToParentMessage = {
|
|
|
911
919
|
/** Optional name for a `bytes` upload (host-sanitised). */
|
|
912
920
|
filename?: string;
|
|
913
921
|
};
|
|
922
|
+
} | {
|
|
923
|
+
type: 'OPEN_IMAGE_PICKER';
|
|
924
|
+
payload: {
|
|
925
|
+
requestId: string;
|
|
926
|
+
/**
|
|
927
|
+
* Which of the viewer's libraries to offer. OMIT the key for both. The
|
|
928
|
+
* host de-duplicates repeats and refuses an empty array or an unknown
|
|
929
|
+
* member.
|
|
930
|
+
*/
|
|
931
|
+
sources?: BlockImagePickerSource[];
|
|
932
|
+
/**
|
|
933
|
+
* Ask for SEVERAL images in one picker session. `max` is a whole
|
|
934
|
+
* number ≥ 1; the host clamps anything above 20 to 20. The reply is
|
|
935
|
+
* then `selectedImages`, not `selected`. OMIT the key for a single
|
|
936
|
+
* pick.
|
|
937
|
+
*/
|
|
938
|
+
multiple?: {
|
|
939
|
+
max: number;
|
|
940
|
+
};
|
|
941
|
+
};
|
|
914
942
|
} | {
|
|
915
943
|
type: 'SET_USER_CHECKPOINT';
|
|
916
944
|
payload: {
|
|
@@ -1108,7 +1136,7 @@ export type BlockToParentMessageType = BlockToParentMessage['type'];
|
|
|
1108
1136
|
* it is a measurement, not an invariant, and civitai's own compile-time gate
|
|
1109
1137
|
* (published SDK union ⊆ `keyof INVENTORY`) is what holds one direction of it.
|
|
1110
1138
|
*/
|
|
1111
|
-
export declare const BLOCK_TO_PARENT_MESSAGE_TYPES: readonly ["BLOCK_HELLO", "BLOCK_READY", "BLOCK_ERROR", "BLOCK_MESSAGE_REJECTED", "REQUEST_TOKEN", "RESIZE_IFRAME", "SUBMIT_WORKFLOW", "ESTIMATE_WORKFLOW", "ESTIMATE_WORKFLOW_BATCH", "POLL_WORKFLOW", "CANCEL_WORKFLOW", "OPEN_BUZZ_PURCHASE", "GET_BUZZ_BALANCE", "GET_VIEWER", "GET_BUZZ_TRANSACTIONS", "GET_BUZZ_ACCOUNTS", "GET_DAILY_COMPENSATION", "GET_WILDCARD_PACK", "QUERY_APP_WORKFLOWS", "PUBLISH_GENERATION_OUTPUTS", "CREATE_POST_FROM_APP", "PREPARE_TRAINING_DATASET", "RUN_TRAINING", "RUN_CONFIRMED_STEP", "GET_IMAGES_BY_IDS", "CANCEL_APP_WORKFLOW", "OPEN_CHECKPOINT_PICKER", "OPEN_RESOURCE_PICKER", "OPEN_IMAGE_UPLOAD", "SET_USER_CHECKPOINT", "NAVIGATE", "REQUEST_SIGN_IN", "REQUEST_CONSENT", "TRACK_EVENT", "APP_STORAGE_GET", "APP_STORAGE_SET", "APP_STORAGE_DELETE", "APP_STORAGE_LIST", "APP_STORAGE_QUOTA", "SHARED_LIST", "SHARED_GET_COUNT", "SHARED_GET_COUNTS", "SHARED_APPEND", "SHARED_VOTE", "SHARED_UNVOTE", "SHARED_WITHDRAW", "SHARED_UPDATE", "SHARED_GET", "SHARED_REPORT", "SAVE_IMAGE", "SET_COLLECTION_FOLLOW"];
|
|
1139
|
+
export declare const BLOCK_TO_PARENT_MESSAGE_TYPES: readonly ["BLOCK_HELLO", "BLOCK_READY", "BLOCK_ERROR", "BLOCK_MESSAGE_REJECTED", "REQUEST_TOKEN", "RESIZE_IFRAME", "SUBMIT_WORKFLOW", "ESTIMATE_WORKFLOW", "ESTIMATE_WORKFLOW_BATCH", "POLL_WORKFLOW", "CANCEL_WORKFLOW", "OPEN_BUZZ_PURCHASE", "GET_BUZZ_BALANCE", "GET_VIEWER", "GET_BUZZ_TRANSACTIONS", "GET_BUZZ_ACCOUNTS", "GET_DAILY_COMPENSATION", "GET_WILDCARD_PACK", "QUERY_APP_WORKFLOWS", "PUBLISH_GENERATION_OUTPUTS", "CREATE_POST_FROM_APP", "PREPARE_TRAINING_DATASET", "RUN_TRAINING", "RUN_CONFIRMED_STEP", "GET_IMAGES_BY_IDS", "CANCEL_APP_WORKFLOW", "OPEN_CHECKPOINT_PICKER", "OPEN_RESOURCE_PICKER", "OPEN_IMAGE_UPLOAD", "OPEN_IMAGE_PICKER", "SET_USER_CHECKPOINT", "NAVIGATE", "REQUEST_SIGN_IN", "REQUEST_CONSENT", "TRACK_EVENT", "APP_STORAGE_GET", "APP_STORAGE_SET", "APP_STORAGE_DELETE", "APP_STORAGE_LIST", "APP_STORAGE_QUOTA", "SHARED_LIST", "SHARED_GET_COUNT", "SHARED_GET_COUNTS", "SHARED_APPEND", "SHARED_VOTE", "SHARED_UNVOTE", "SHARED_WITHDRAW", "SHARED_UPDATE", "SHARED_GET", "SHARED_REPORT", "SAVE_IMAGE", "SET_COLLECTION_FOLLOW"];
|
|
1112
1140
|
/**
|
|
1113
1141
|
* The bucket a message type falls into when the protocol does not declare it.
|
|
1114
1142
|
*
|
package/dist/blocks/messages.js
CHANGED
package/dist/blocks/types.d.ts
CHANGED
|
@@ -296,6 +296,76 @@ export type BlockNavigateScope = 'app' | 'site';
|
|
|
296
296
|
* lockstep.
|
|
297
297
|
*/
|
|
298
298
|
export type BlockGenerationSourceImageInfo = BlockSourceImage;
|
|
299
|
+
/**
|
|
300
|
+
* Which of the viewer's own image libraries `OPEN_IMAGE_PICKER` (via
|
|
301
|
+
* `useImagePicker`) offers:
|
|
302
|
+
* - `'posted'` — images the viewer has posted to Civitai.
|
|
303
|
+
* - `'generated'` — outputs the viewer made with the Civitai generator.
|
|
304
|
+
*
|
|
305
|
+
* The request's `sources` narrows the picker to one of them; omitting it offers
|
|
306
|
+
* both. Images only — neither library offers video through this picker.
|
|
307
|
+
*/
|
|
308
|
+
export type BlockImagePickerSource = 'posted' | 'generated';
|
|
309
|
+
/**
|
|
310
|
+
* One image the viewer picked from their own Civitai images
|
|
311
|
+
* (`IMAGE_PICKER_RESULT.selected` / `.selectedImages`, via `useImagePicker`).
|
|
312
|
+
* The host lists and filters the library in its own chrome; the block receives
|
|
313
|
+
* only what the viewer picked.
|
|
314
|
+
*
|
|
315
|
+
* WHAT IS PICKABLE is decided by the host, never by the block:
|
|
316
|
+
* - `'posted'`: the viewer's own images that are in a published post, fully
|
|
317
|
+
* scanned, not flagged, and rated.
|
|
318
|
+
* - `'generated'`: the viewer's own succeeded generator outputs that carry a
|
|
319
|
+
* rating the host recognises.
|
|
320
|
+
* - Either way the image's rating has to be one the VIEWER'S OWN browsing
|
|
321
|
+
* level on the site allows: the viewer is offered what they can already
|
|
322
|
+
* browse. An unrated image is never pickable.
|
|
323
|
+
*
|
|
324
|
+
* 🔴 A PICK CAN BE A MATURE IMAGE. `nsfwLevel` is the image's rating and is
|
|
325
|
+
* never 0. The pick was offered to this viewer under this viewer's settings;
|
|
326
|
+
* nothing about it says anyone else may see it. An app that shows a pick to
|
|
327
|
+
* anybody other than the viewer who picked it has to gate that on `nsfwLevel`
|
|
328
|
+
* itself.
|
|
329
|
+
*
|
|
330
|
+
* WHAT `url`, `width` AND `height` ARE differs by library:
|
|
331
|
+
* - `'posted'`: `url` is a RESIZED RENDITION of the image, not the original
|
|
332
|
+
* file. `width` / `height` are the size that rendition is requested at, and
|
|
333
|
+
* the host picks one with both sides within 64–2048 (a small original is
|
|
334
|
+
* upscaled). The image CDN normally serves exactly that size; it can serve
|
|
335
|
+
* the original instead while a rendition is still being produced. A posted
|
|
336
|
+
* image with no rendition in that range (an extreme aspect ratio) is not
|
|
337
|
+
* pickable.
|
|
338
|
+
* - `'generated'`: `url` is the generator's own output URL, and `width` /
|
|
339
|
+
* `height` are the output's own size, which can exceed 2048. 🔴 That URL
|
|
340
|
+
* may be time-limited: use it promptly and do not store it.
|
|
341
|
+
*
|
|
342
|
+
* AS A GENERATION SOURCE: `url` is Civitai-hosted, so `{ url, width, height }`
|
|
343
|
+
* has the shape of a {@link BlockSourceImage} and passes the generation body's
|
|
344
|
+
* source-image URL check. That is all this type promises. The generation body
|
|
345
|
+
* still applies its own rules, including 64–2048 per side, which a generated
|
|
346
|
+
* pick can exceed.
|
|
347
|
+
*/
|
|
348
|
+
export interface BlockPickedImageInfo {
|
|
349
|
+
/** Which library the viewer picked it from. */
|
|
350
|
+
source: BlockImagePickerSource;
|
|
351
|
+
/** Civitai-hosted image URL. What it points at differs by `source`; see above. */
|
|
352
|
+
url: string;
|
|
353
|
+
/** Pixel width that goes with `url`; see above for each `source`. */
|
|
354
|
+
width: number;
|
|
355
|
+
/** Pixel height that goes with `url`; see above for each `source`. */
|
|
356
|
+
height: number;
|
|
357
|
+
/**
|
|
358
|
+
* The image's NSFW-level bitmask value (same scale as
|
|
359
|
+
* {@link BlockUploadedImageInfo.nsfwLevel}). Can be a mature level; never 0.
|
|
360
|
+
*/
|
|
361
|
+
nsfwLevel: number;
|
|
362
|
+
/**
|
|
363
|
+
* The `Image` row id. Present for `source: 'posted'`; ABSENT for
|
|
364
|
+
* `source: 'generated'` (a generator output that was never posted has no
|
|
365
|
+
* `Image` row).
|
|
366
|
+
*/
|
|
367
|
+
imageId?: number;
|
|
368
|
+
}
|
|
299
369
|
/**
|
|
300
370
|
* One of the model version's curated preview images, with the standard
|
|
301
371
|
* gen params extracted from its source meta. Block UIs use these to let
|
package/dist/index.d.ts
CHANGED
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
*
|
|
26
26
|
* - **`./blocks`** — importing it RUNS `./safe-storage` for its side effect
|
|
27
27
|
* (repairing `localStorage`/`sessionStorage` at an opaque origin). Folding
|
|
28
|
-
*
|
|
28
|
+
* 174 symbols and that side effect into the root would make every OAuth app
|
|
29
29
|
* that writes `import { exchangeCode } from '@civitai/app-sdk'` pay for the
|
|
30
30
|
* Civitai-Apps contract it does not use. Blocks and OAuth apps are disjoint
|
|
31
31
|
* audiences; see this package's README.
|
|
32
|
-
* 🔴 That
|
|
32
|
+
* 🔴 That 174 is ASSERTED, not merely quoted — by
|
|
33
33
|
* `packages/civitai-app-sdk/test/export-surface.test.ts`, which pins
|
|
34
34
|
* `surface.get('./blocks').size`. It said 119 here against a real 125 until
|
|
35
35
|
* 2026-10-04, because the existing checks pin the root as an exact union and
|
package/dist/index.js
CHANGED
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
*
|
|
26
26
|
* - **`./blocks`** — importing it RUNS `./safe-storage` for its side effect
|
|
27
27
|
* (repairing `localStorage`/`sessionStorage` at an opaque origin). Folding
|
|
28
|
-
*
|
|
28
|
+
* 174 symbols and that side effect into the root would make every OAuth app
|
|
29
29
|
* that writes `import { exchangeCode } from '@civitai/app-sdk'` pay for the
|
|
30
30
|
* Civitai-Apps contract it does not use. Blocks and OAuth apps are disjoint
|
|
31
31
|
* audiences; see this package's README.
|
|
32
|
-
* 🔴 That
|
|
32
|
+
* 🔴 That 174 is ASSERTED, not merely quoted — by
|
|
33
33
|
* `packages/civitai-app-sdk/test/export-surface.test.ts`, which pins
|
|
34
34
|
* `surface.get('./blocks').size`. It said 119 here against a real 125 until
|
|
35
35
|
* 2026-10-04, because the existing checks pin the root as an exact union and
|
package/package.json
CHANGED