@civitai/app-sdk 0.89.0 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/messages.d.ts +35 -3
- package/dist/blocks/messages.js +2 -0
- package/dist/blocks/types.d.ts +120 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/schemas/app-block/v1.json +1 -1
package/README.md
CHANGED
|
@@ -183,7 +183,7 @@ interface BlockInitPayload {
|
|
|
183
183
|
| `isModelSlotContext(ctx)` / `isPageSlotContext(ctx)` | Runtime narrowing for the `slotId`-discriminated `BlockContext` union. Real checks on a value that crossed a `postMessage` boundary — they verify every field they assert, not just `slotId`. |
|
|
184
184
|
| `fetchNestedDocument(opts)` | Embed one of your OWN bundled documents as an iframe `srcdoc`, because a nested `<iframe src>` of your own content **cannot load** — see [Nested documents](#nested-documents) below. `NestedDocumentError` carries a `.code` of `'invalid-url' \| 'http-error' \| 'network-error'`. |
|
|
185
185
|
| `isSignedIn(viewer)` | **The sign-in gate.** `isSignedIn(useBlockContext().viewer)` — do not open-code it as `viewer !== null` or `viewer?.signedIn === true`. Which of those is correct has already changed once with the host contract, and this is the one place it is decided. It reads neither `viewer.id` nor `viewer.username` (both `@deprecated`), so nothing written through it changes when those are removed. Need the identity rather than the presence? `useViewer()` — scope-gated and audited per call. |
|
|
186
|
-
| types | `BlockManifestV1`, `ManifestSettings` (+ field types), `BlockContext`, `ModelSlotContext`, `BlockCheckpointInfo`, `ShowcaseImage`, `BlockToken`, `WrappedToken`, `BlockSettings`, `ViewerInfo`, `Theme`, `WorkflowBody`, `BlockTextToImageParams`, `WorkflowBodyCustomComfy` (+ its two arms `WorkflowBodyCustomComfyRecipe` / `WorkflowBodyCustomComfyInline`, and `InlineComfyNode`), `WorkflowBodyStep` / `WorkflowBodyPassThroughStep` (the two arms of `kind: 'step'`), `WorkflowBodyTraining` (+ `AiToolkitTrainingParams`, `BlockTrainingQuote`, `BlockTrainingDatasetItem`, `BlockTrainingDataImage`, `BlockTrainingDataUploadResult`, `BlockRunTrainingHostError` and the `BLOCK_TRAINING_*` bounds), `WorkflowBodyWorkflow` (+ `WorkflowBodyWorkflowStep`, `WorkflowStepRef`, `WithWorkflowStepRefs`, `BlockWorkflowStepSnapshot` and `BLOCK_WORKFLOW_MAX_STEPS`), `BlockStepQuote` / `BlockRunConfirmedStepHostError` (+ `BLOCK_CONFIRMED_STEP_MAX_BUZZ_PER_JOB`, `BLOCK_STEP_QUOTE_ID_REGEX`), `BlockModel3dOutput`, `BlockWorkflowSnapshot` (+ `BlockWorkflowEta`, `BlockWorkflowStepQueue` and `KnownBlockWorkflowQueueSupport` — queue position, ETA and progress, see below; + `BlockWorkflowOutput`, `BlockWorkflowAvailableOutput`, `BlockWorkflowRestrictedOutput`, `KnownBlockWorkflowOutputRating` and `KnownBlockWorkflowRestrictionReason` — restricted outputs, see below), `WorkflowStatus`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`. |
|
|
186
|
+
| types | `BlockManifestV1`, `ManifestSettings` (+ field types), `BlockContext`, `ModelSlotContext`, `BlockCheckpointInfo`, `ShowcaseImage`, `BlockToken`, `WrappedToken`, `BlockSettings`, `ViewerInfo`, `Theme`, `WorkflowBody`, `BlockTextToImageParams`, `WorkflowBodyCustomComfy` (+ its two arms `WorkflowBodyCustomComfyRecipe` / `WorkflowBodyCustomComfyInline`, and `InlineComfyNode`), `WorkflowBodyStep` / `WorkflowBodyPassThroughStep` (the two arms of `kind: 'step'`), `WorkflowBodyTraining` (+ `AiToolkitTrainingParams`, `BlockTrainingQuote`, `BlockTrainingDatasetItem`, `BlockTrainingDataImage`, `BlockTrainingDataUploadResult`, `BlockRunTrainingHostError` and the `BLOCK_TRAINING_*` bounds), `WorkflowBodyWorkflow` (+ `WorkflowBodyWorkflowStep`, `WorkflowStepRef`, `WithWorkflowStepRefs`, `BlockWorkflowStepSnapshot` and `BLOCK_WORKFLOW_MAX_STEPS`), `BlockStepQuote` / `BlockRunConfirmedStepHostError` (+ `BLOCK_CONFIRMED_STEP_MAX_BUZZ_PER_JOB`, `BLOCK_STEP_QUOTE_ID_REGEX`), `BlockModel3dOutput`, `BlockWorkflowSnapshot` (+ `BlockWorkflowEta`, `BlockWorkflowStepQueue` and `KnownBlockWorkflowQueueSupport` — queue position, ETA and progress, see below; + `BlockWorkflowOutput`, `BlockWorkflowAvailableOutput`, `BlockWorkflowRestrictedOutput`, `KnownBlockWorkflowOutputRating` and `KnownBlockWorkflowRestrictionReason` — restricted outputs, see below), `BlockOutputUnlockResult` / `KnownBlockOutputUnlockOutcome` (unlocking a restricted output; `useOutputUnlock` in `@civitai/blocks-react`), `WorkflowStatus`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`. |
|
|
187
187
|
|
|
188
188
|
**Restricted outputs.** `outputs` on a workflow snapshot (and on each of its
|
|
189
189
|
`steps`, and on an `AppWorkflow` row) lists every available output in order, with
|
|
@@ -392,7 +392,7 @@ confirms that price in Civitai's own dialog. A confirmed run may exceed the toke
|
|
|
392
392
|
budget, up to `BLOCK_TRAINING_MAX_BUZZ_PER_RUN` (5,000). Page apps only, `ai:write:budgeted`,
|
|
393
393
|
behind the host flag `app-blocks-training-kind` (off by default), and refused from development
|
|
394
394
|
and review sessions. The images are uploaded over `OPEN_IMAGE_UPLOAD { purpose: 'trainingData' }`,
|
|
395
|
-
which replies `IMAGE_UPLOAD_RESULT { selected: { images: [{
|
|
395
|
+
which replies `IMAGE_UPLOAD_RESULT { selected: { images: [{ air }] } }`, an AIR reference per image
|
|
396
396
|
(`BlockTrainingDataUploadResult`); the host refuses a run whose quote names a blob it did not
|
|
397
397
|
upload for the block, with the `BlockRunTrainingHostError` `training data not uploaded here`.
|
|
398
398
|
`PREPARE_TRAINING_DATASET` (the server-prepared dataset of civitai/civitai#5438) is removed from
|
package/dist/blocks/index.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
|
|
|
88
88
|
* in `types.ts` for which of the two it uses and why.
|
|
89
89
|
*/
|
|
90
90
|
export { isSignedIn } from './types.js';
|
|
91
|
-
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, 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, BlockWorkflowStepQueue, BlockWorkflowEta, KnownBlockWorkflowQueueSupport, BlockWorkflowOutput, BlockWorkflowAvailableOutput, BlockWorkflowRestrictedOutput, BlockWorkflowPendingOutput, BlockWorkflowBlockedOutput, KnownBlockWorkflowOutputRating, KnownBlockWorkflowRestrictionReason, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
|
|
91
|
+
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockUploadedGenerationSource, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkMethod, BlockShareLinkRequest, BlockShareLinkResult, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, BlockWorkflowStepQueue, BlockWorkflowEta, KnownBlockWorkflowQueueSupport, BlockWorkflowOutput, BlockWorkflowAvailableOutput, BlockWorkflowRestrictedOutput, BlockWorkflowPendingOutput, BlockWorkflowBlockedOutput, KnownBlockWorkflowOutputRating, KnownBlockWorkflowRestrictionReason, KnownBlockOutputUnlockOutcome, BlockOutputUnlockResult, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
|
|
92
92
|
/**
|
|
93
93
|
* Host bounds for an inline `customComfy` graph, mirrored from civitai/civitai —
|
|
94
94
|
* see `WorkflowBodyCustomComfyInline.workflow`.
|
|
@@ -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,
|
|
11
|
+
import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo, BlockUploadedGenerationSource, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkResult, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileErrorCode, AppWorkflow, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostResult, BlockTrainingDataUploadResult, WorkflowBodyTraining, WorkflowBodyPassThroughStep, BlockOutputUnlockResult } from './types.js';
|
|
12
12
|
import type { BlockAppReaction, BlockEntityReactionErrorCode, BlockEntityReactionResult, BlockEntityReactionsResult, BlockReactionEntityType } from './reactions.js';
|
|
13
13
|
/**
|
|
14
14
|
* Filter params for `GET_BUZZ_TRANSACTIONS`. All optional; the host validates
|
|
@@ -319,6 +319,8 @@ export type ParentToBlockMessage = {
|
|
|
319
319
|
type: 'ROUTE_CHANGED';
|
|
320
320
|
payload: {
|
|
321
321
|
subPath: string;
|
|
322
|
+
search?: string;
|
|
323
|
+
hash?: string;
|
|
322
324
|
};
|
|
323
325
|
} | {
|
|
324
326
|
type: 'CONSENT_UNAVAILABLE';
|
|
@@ -362,6 +364,13 @@ export type ParentToBlockMessage = {
|
|
|
362
364
|
purchased: boolean;
|
|
363
365
|
newBalance?: number;
|
|
364
366
|
};
|
|
367
|
+
} | {
|
|
368
|
+
type: 'OUTPUT_UNLOCK_RESULT';
|
|
369
|
+
payload: {
|
|
370
|
+
requestId: string;
|
|
371
|
+
result?: BlockOutputUnlockResult;
|
|
372
|
+
error?: string;
|
|
373
|
+
};
|
|
365
374
|
} | {
|
|
366
375
|
type: 'BUZZ_BALANCE_RESULT';
|
|
367
376
|
payload: {
|
|
@@ -449,6 +458,13 @@ export type ParentToBlockMessage = {
|
|
|
449
458
|
result?: BlockPersistedGenerationSource;
|
|
450
459
|
error?: string;
|
|
451
460
|
};
|
|
461
|
+
} | {
|
|
462
|
+
type: 'SHARE_LINK_RESULT';
|
|
463
|
+
payload: {
|
|
464
|
+
requestId: string;
|
|
465
|
+
result?: BlockShareLinkResult;
|
|
466
|
+
error?: string;
|
|
467
|
+
};
|
|
452
468
|
} | {
|
|
453
469
|
type: 'CREATE_POST_RESULT';
|
|
454
470
|
payload: {
|
|
@@ -527,7 +543,7 @@ export type ParentToBlockMessage = {
|
|
|
527
543
|
type: 'IMAGE_UPLOAD_RESULT';
|
|
528
544
|
payload: {
|
|
529
545
|
requestId: string;
|
|
530
|
-
selected?: BlockUploadedImageInfo |
|
|
546
|
+
selected?: BlockUploadedImageInfo | BlockUploadedGenerationSource | BlockPendingImageInfo | BlockTrainingDataUploadResult;
|
|
531
547
|
/** A `bytes` upload's refusal or failure: a host string or a forwarded server message. */
|
|
532
548
|
error?: string;
|
|
533
549
|
};
|
|
@@ -653,6 +669,13 @@ export type BlockToParentMessage = {
|
|
|
653
669
|
requestId: string;
|
|
654
670
|
suggestedAmount?: number;
|
|
655
671
|
};
|
|
672
|
+
} | {
|
|
673
|
+
type: 'REQUEST_OUTPUT_UNLOCK';
|
|
674
|
+
payload: {
|
|
675
|
+
requestId: string;
|
|
676
|
+
workflowId: string;
|
|
677
|
+
position: number;
|
|
678
|
+
};
|
|
656
679
|
} | {
|
|
657
680
|
type: 'GET_BUZZ_BALANCE';
|
|
658
681
|
payload: {
|
|
@@ -714,6 +737,14 @@ export type BlockToParentMessage = {
|
|
|
714
737
|
workflowId: string;
|
|
715
738
|
imageIndex: number;
|
|
716
739
|
};
|
|
740
|
+
} | {
|
|
741
|
+
type: 'SHARE_LINK';
|
|
742
|
+
payload: {
|
|
743
|
+
requestId: string;
|
|
744
|
+
subPath: string;
|
|
745
|
+
search?: string;
|
|
746
|
+
hash?: string;
|
|
747
|
+
};
|
|
717
748
|
} | {
|
|
718
749
|
type: 'CREATE_POST_FROM_APP';
|
|
719
750
|
payload: {
|
|
@@ -869,6 +900,7 @@ export type BlockToParentMessage = {
|
|
|
869
900
|
path: string;
|
|
870
901
|
scope?: BlockNavigateScope;
|
|
871
902
|
target: 'current' | 'new_tab';
|
|
903
|
+
replace?: boolean;
|
|
872
904
|
};
|
|
873
905
|
} | {
|
|
874
906
|
type: 'REQUEST_SIGN_IN';
|
|
@@ -983,7 +1015,7 @@ export type BlockToParentMessageType = BlockToParentMessage['type'];
|
|
|
983
1015
|
* it is a measurement, not an invariant, and civitai's own compile-time gate
|
|
984
1016
|
* (published SDK union ⊆ `keyof INVENTORY`) is what holds one direction of it.
|
|
985
1017
|
*/
|
|
986
|
-
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", "GET_RESOURCE_FILE", "QUERY_APP_WORKFLOWS", "PUBLISH_GENERATION_OUTPUTS", "PERSIST_GENERATION_SOURCE", "CREATE_POST_FROM_APP", "RUN_TRAINING", "RUN_CONFIRMED_STEP", "GET_IMAGES_BY_IDS", "CANCEL_APP_WORKFLOW", "OPEN_CHECKPOINT_PICKER", "OPEN_RESOURCE_PICKER", "OPEN_IMAGE_UPLOAD", "OPEN_IMAGE_PICKER", "OPEN_MEDIA_UPLOAD", "OPEN_MEDIA_UPLOAD_BATCH", "SET_USER_CHECKPOINT", "NAVIGATE", "REQUEST_SIGN_IN", "REQUEST_CONSENT", "TRACK_EVENT", "SAVE_IMAGE", "SET_COLLECTION_FOLLOW", "SET_ENTITY_REACTION", "GET_ENTITY_REACTIONS"];
|
|
1018
|
+
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", "REQUEST_OUTPUT_UNLOCK", "GET_BUZZ_BALANCE", "GET_VIEWER", "GET_BUZZ_TRANSACTIONS", "GET_BUZZ_ACCOUNTS", "GET_DAILY_COMPENSATION", "GET_WILDCARD_PACK", "GET_RESOURCE_FILE", "QUERY_APP_WORKFLOWS", "PUBLISH_GENERATION_OUTPUTS", "PERSIST_GENERATION_SOURCE", "SHARE_LINK", "CREATE_POST_FROM_APP", "RUN_TRAINING", "RUN_CONFIRMED_STEP", "GET_IMAGES_BY_IDS", "CANCEL_APP_WORKFLOW", "OPEN_CHECKPOINT_PICKER", "OPEN_RESOURCE_PICKER", "OPEN_IMAGE_UPLOAD", "OPEN_IMAGE_PICKER", "OPEN_MEDIA_UPLOAD", "OPEN_MEDIA_UPLOAD_BATCH", "SET_USER_CHECKPOINT", "NAVIGATE", "REQUEST_SIGN_IN", "REQUEST_CONSENT", "TRACK_EVENT", "SAVE_IMAGE", "SET_COLLECTION_FOLLOW", "SET_ENTITY_REACTION", "GET_ENTITY_REACTIONS"];
|
|
987
1019
|
/**
|
|
988
1020
|
* The bucket a message type falls into when the protocol does not declare it.
|
|
989
1021
|
*
|
package/dist/blocks/messages.js
CHANGED
|
@@ -61,6 +61,7 @@ export const BLOCK_TO_PARENT_MESSAGE_TYPES = [
|
|
|
61
61
|
'POLL_WORKFLOW',
|
|
62
62
|
'CANCEL_WORKFLOW',
|
|
63
63
|
'OPEN_BUZZ_PURCHASE',
|
|
64
|
+
'REQUEST_OUTPUT_UNLOCK',
|
|
64
65
|
'GET_BUZZ_BALANCE',
|
|
65
66
|
'GET_VIEWER',
|
|
66
67
|
'GET_BUZZ_TRANSACTIONS',
|
|
@@ -71,6 +72,7 @@ export const BLOCK_TO_PARENT_MESSAGE_TYPES = [
|
|
|
71
72
|
'QUERY_APP_WORKFLOWS',
|
|
72
73
|
'PUBLISH_GENERATION_OUTPUTS',
|
|
73
74
|
'PERSIST_GENERATION_SOURCE',
|
|
75
|
+
'SHARE_LINK',
|
|
74
76
|
'CREATE_POST_FROM_APP',
|
|
75
77
|
'RUN_TRAINING',
|
|
76
78
|
'RUN_CONFIRMED_STEP',
|
package/dist/blocks/types.d.ts
CHANGED
|
@@ -253,9 +253,10 @@ export type BlockImageScanResult = {
|
|
|
253
253
|
* routes through the session-authed scan pipeline (SFW + no-flag gate). The
|
|
254
254
|
* host returns a moderated {@link BlockUploadedImageInfo}.
|
|
255
255
|
* - `'generationSource'`: a PRIVATE generation INPUT (an img2img source image).
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
256
|
+
* The host returns the source shape ({@link BlockUploadedGenerationSource});
|
|
257
|
+
* no `nsfwLevel`/`contentRating` crosses back into the block. While the
|
|
258
|
+
* host's scanned-rows rule is on, the source is a private SCANNED row and
|
|
259
|
+
* the reply also carries its `imageId` and `ready`.
|
|
259
260
|
* - `'trainingData'`: PRIVATE training images for a `kind: 'training'` run
|
|
260
261
|
* (civitai/civitai#6461). The viewer picks up to
|
|
261
262
|
* {@link BLOCK_TRAINING_DATASET_MAX_ITEMS} PNG, JPEG or WebP files in a host
|
|
@@ -289,6 +290,37 @@ export type BlockUploadPurpose = 'display' | 'generationSource' | 'trainingData'
|
|
|
289
290
|
* are one request. Do not reintroduce punctuation semantics.
|
|
290
291
|
*/
|
|
291
292
|
export type BlockNavigateScope = 'app' | 'site';
|
|
293
|
+
/**
|
|
294
|
+
* How the host delivered a `SHARE_LINK` URL to the viewer:
|
|
295
|
+
* - `'clipboard'` — the host's clipboard write RESOLVED (`copied` is `true`);
|
|
296
|
+
* - `'share'` — the native share sheet completed (phones; `copied` is `false`);
|
|
297
|
+
* - `'none'` — nothing was delivered: the clipboard write was refused, there was no
|
|
298
|
+
* click to act on, the share sheet was cancelled, or no API was available. Show
|
|
299
|
+
* `url` as selectable text so the viewer can copy it by hand.
|
|
300
|
+
*/
|
|
301
|
+
export type BlockShareLinkMethod = 'clipboard' | 'share' | 'none';
|
|
302
|
+
/**
|
|
303
|
+
* The view a `SHARE_LINK` links to. Every field is RELATIVE to the app: the host
|
|
304
|
+
* builds the absolute `/apps/run/<slug>/<subPath><search><hash>` URL from its own
|
|
305
|
+
* origin and slug, and refuses anything that would leave it (`..`, `//host`, a
|
|
306
|
+
* scheme), and drops the host-owned `from` / `sl` / `src` pairs. `subPath` carries no `?` or `#`; `search` is `''` or starts with `?`;
|
|
307
|
+
* `hash` is `''` or starts with `#`; each at most 2048 chars.
|
|
308
|
+
*/
|
|
309
|
+
export interface BlockShareLinkRequest {
|
|
310
|
+
subPath?: string;
|
|
311
|
+
search?: string;
|
|
312
|
+
hash?: string;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* What the host did with a `SHARE_LINK`. 🔴 `copied` is `true` ONLY when the
|
|
316
|
+
* clipboard write resolved; `false` is a normal outcome, not an error.
|
|
317
|
+
*/
|
|
318
|
+
export interface BlockShareLinkResult {
|
|
319
|
+
/** The canonical absolute URL, e.g. `https://civitai.com/apps/run/<slug>/c/42?take=3`. */
|
|
320
|
+
url: string;
|
|
321
|
+
copied: boolean;
|
|
322
|
+
method: BlockShareLinkMethod;
|
|
323
|
+
}
|
|
292
324
|
/**
|
|
293
325
|
* The source-image result the host returns from `OPEN_IMAGE_UPLOAD` when the
|
|
294
326
|
* block requested `purpose: 'generationSource'` (`IMAGE_UPLOAD_RESULT.selected`)
|
|
@@ -305,6 +337,36 @@ export type BlockNavigateScope = 'app' | 'site';
|
|
|
305
337
|
* lockstep.
|
|
306
338
|
*/
|
|
307
339
|
export type BlockGenerationSourceImageInfo = BlockSourceImage;
|
|
340
|
+
/**
|
|
341
|
+
* What `useImageUpload({ purpose: 'generationSource' })` resolves with: a
|
|
342
|
+
* {@link BlockGenerationSourceImageInfo} (`{ url, width, height }`, straight into
|
|
343
|
+
* a `sourceImages` entry), plus `imageId` and `ready` when the host kept the
|
|
344
|
+
* picked file as a private, SCANNED `Image` row.
|
|
345
|
+
*
|
|
346
|
+
* The host does that while its `app-block-source-scanned-rows` rule is on: it
|
|
347
|
+
* then refuses a generation source that is not a scanned image on Civitai, so it
|
|
348
|
+
* copies the upload into a row owned by the viewer, never on the app's shared
|
|
349
|
+
* grid and not postable, and returns that row, as `PERSIST_GENERATION_SOURCE`
|
|
350
|
+
* does ({@link BlockPersistedGenerationSource}):
|
|
351
|
+
*
|
|
352
|
+
* - `imageId` is the row's id.
|
|
353
|
+
* - `ready` says whether the scan finished; the host waits up to about 30 s.
|
|
354
|
+
* `ready: false` means it is still running: a generation that uses the source
|
|
355
|
+
* is refused with the `source-scan-pending` error code until it finishes, so
|
|
356
|
+
* retry that generation later. A scan that refuses the image is an upload
|
|
357
|
+
* error, and `open()` never resolves with that image.
|
|
358
|
+
*
|
|
359
|
+
* Both are ABSENT when the rule is off, and from a host that predates it: the
|
|
360
|
+
* source is then an unscanned private upload the orchestrator scans when the
|
|
361
|
+
* workflow runs, usable at once.
|
|
362
|
+
*
|
|
363
|
+
* Mirrors the host's `BlockSourceImageInfo` in civitai/civitai's
|
|
364
|
+
* `src/components/AppBlocks/BlockGenerationSourceUploadModal.tsx`.
|
|
365
|
+
*/
|
|
366
|
+
export interface BlockUploadedGenerationSource extends BlockGenerationSourceImageInfo {
|
|
367
|
+
imageId?: number;
|
|
368
|
+
ready?: boolean;
|
|
369
|
+
}
|
|
308
370
|
/**
|
|
309
371
|
* What a block sends in `PERSIST_GENERATION_SOURCE`: ONE output of one of the
|
|
310
372
|
* calling app's OWN workflows, named by `workflowId` and `imageIndex` — the
|
|
@@ -350,10 +412,8 @@ export interface BlockPersistedGenerationSource extends BlockGenerationSourceIma
|
|
|
350
412
|
* `Image` row, so there is no `imageId`.
|
|
351
413
|
*/
|
|
352
414
|
export interface BlockTrainingDataImage {
|
|
353
|
-
/** The uploaded blob's url. Show it as the thumbnail; it is also accepted as an item's `air`. */
|
|
354
|
-
url: string;
|
|
355
415
|
/**
|
|
356
|
-
*
|
|
416
|
+
* An AIR reference to the uploaded image — pass it as {@link BlockTrainingDatasetItem.air}.
|
|
357
417
|
* Opaque. The host compares keys case-insensitively.
|
|
358
418
|
*/
|
|
359
419
|
air: string;
|
|
@@ -486,6 +546,10 @@ export interface BlockMediaUploadInfo {
|
|
|
486
546
|
height?: number;
|
|
487
547
|
/** Duration in milliseconds, for `'video'` / `'audio'` when known. Never set for `'image'`. */
|
|
488
548
|
durationMs?: number;
|
|
549
|
+
/** As on {@link BlockUploadedGenerationSource}, for a single `'image'` upload. */
|
|
550
|
+
imageId?: number;
|
|
551
|
+
/** As on {@link BlockUploadedGenerationSource}. */
|
|
552
|
+
ready?: boolean;
|
|
489
553
|
}
|
|
490
554
|
/**
|
|
491
555
|
* One item's answer in a batch media upload (`MEDIA_UPLOAD_BATCH_RESULT.results`,
|
|
@@ -614,6 +678,16 @@ export interface PageSlotContext {
|
|
|
614
678
|
* app's own index. Lets a page app route internally without owning history.
|
|
615
679
|
*/
|
|
616
680
|
subPath: string;
|
|
681
|
+
/**
|
|
682
|
+
* The query string of the host URL below the app route — `''` or starting with
|
|
683
|
+
* `?` (`'?take=3'`). The host strips the query pairs it owns (`from`, `sl`, `src`);
|
|
684
|
+
* every other pair arrives byte-for-byte, uncapped. Lets an app deep-link into its own STATE, not
|
|
685
|
+
* just a route. Absent from a host that predates the field; read it through
|
|
686
|
+
* `useCivitaiLocation()` (blocks-react), which reads absent as `''`.
|
|
687
|
+
*/
|
|
688
|
+
search?: string;
|
|
689
|
+
/** The fragment — `''` or starting with `#` (`'#top'`). Same source as `search`. */
|
|
690
|
+
hash?: string;
|
|
617
691
|
/** `null` for an anonymous viewer. */
|
|
618
692
|
viewerUserId: number | null;
|
|
619
693
|
/** Absent/`null` when the viewer has no handle. */
|
|
@@ -1903,7 +1977,7 @@ export type AiToolkitTrainingParams = AiToolkitTrainingParamsBase & ({
|
|
|
1903
1977
|
* 1. **Upload** — `useImageUpload({ purpose: 'trainingData' }).open()`
|
|
1904
1978
|
* (`OPEN_IMAGE_UPLOAD { purpose: 'trainingData' }`). The viewer picks up to
|
|
1905
1979
|
* {@link BLOCK_TRAINING_DATASET_MAX_ITEMS} images in a host modal; you get
|
|
1906
|
-
* `[{
|
|
1980
|
+
* `[{ air }]` ({@link BlockTrainingDataImage}), or `null` on cancel.
|
|
1907
1981
|
* Pair each `air` with your caption to build {@link WorkflowBodyTraining.items}.
|
|
1908
1982
|
* 2. **Quote** — `useBuzzWorkflow().estimate(body)` with this body, `quoteId`
|
|
1909
1983
|
* ABSENT. The reply's {@link BlockWorkflowSnapshot.trainingQuote} is the
|
|
@@ -2869,6 +2943,45 @@ export interface BlockWorkflowRestrictedOutput {
|
|
|
2869
2943
|
* ```
|
|
2870
2944
|
*/
|
|
2871
2945
|
export type BlockWorkflowOutput = BlockWorkflowAvailableOutput | BlockWorkflowRestrictedOutput | BlockWorkflowPendingOutput | BlockWorkflowBlockedOutput;
|
|
2946
|
+
/**
|
|
2947
|
+
* How an output unlock ended ({@link BlockOutputUnlockResult}). An unknown value is
|
|
2948
|
+
* possible; treat it like `'unavailable'`.
|
|
2949
|
+
*
|
|
2950
|
+
* - `'unlocked'` — the output now carries a url: read it from `snapshot.outputs` at
|
|
2951
|
+
* the position you asked about. The viewer paid for it in the host's own dialog.
|
|
2952
|
+
* - `'not-restricted'` — it already had a url (a retry after an unlock lands here).
|
|
2953
|
+
* Nothing was shown or charged; poll the workflow to read it.
|
|
2954
|
+
* - `'not-released'` — the unlock ran but the output is still above the viewer's
|
|
2955
|
+
* browsing level; `snapshot` shows it still restricted, `message` says why.
|
|
2956
|
+
* - `'refused'` — the viewer does not have enough yellow Buzz for the unlock;
|
|
2957
|
+
* nothing was charged. `message` says so.
|
|
2958
|
+
* - `'linked-out'` — the site your app runs on cannot show it, and the viewer opened
|
|
2959
|
+
* your app on civitai.red, at the same page, to see it there. Never charged.
|
|
2960
|
+
* - `'dismissed'` — the viewer closed the dialog without a completed unlock. If an
|
|
2961
|
+
* unlock attempt failed before they closed it, its charge state is unknown: poll
|
|
2962
|
+
* the workflow to see the output's current entry.
|
|
2963
|
+
* - `'unavailable'` — it cannot be unlocked here; `message` says why (for example,
|
|
2964
|
+
* the viewer's own mature content settings hide it).
|
|
2965
|
+
*/
|
|
2966
|
+
export type KnownBlockOutputUnlockOutcome = 'unlocked' | 'not-restricted' | 'not-released' | 'refused' | 'linked-out' | 'dismissed' | 'unavailable';
|
|
2967
|
+
/**
|
|
2968
|
+
* The outcome of asking the host to unlock ONE restricted output
|
|
2969
|
+
* (`REQUEST_OUTPUT_UNLOCK`, `@civitai/blocks-react`'s `useOutputUnlock`).
|
|
2970
|
+
*
|
|
2971
|
+
* The host decides what to offer from the live workflow, never from your app: an
|
|
2972
|
+
* output restricted for the paying Buzz pool (`reason: 'pool'`) can be unlocked with
|
|
2973
|
+
* yellow Buzz (the viewer confirms the price in the host's dialog). An unlock adds no
|
|
2974
|
+
* author share and counts against no spend limit: the original generation's spend
|
|
2975
|
+
* already did. One restricted for `'ceiling'` or `'unrated'` is never charged (the host
|
|
2976
|
+
* links to your app on civitai.red when that site could show it).
|
|
2977
|
+
*/
|
|
2978
|
+
export interface BlockOutputUnlockResult {
|
|
2979
|
+
outcome: KnownBlockOutputUnlockOutcome | (string & {});
|
|
2980
|
+
/** The re-read workflow, on `'unlocked'`, `'not-released'` and `'refused'`. */
|
|
2981
|
+
snapshot?: BlockWorkflowSnapshot;
|
|
2982
|
+
/** Why, on `'refused'`, `'not-released'` and `'unavailable'`. For display. */
|
|
2983
|
+
message?: string;
|
|
2984
|
+
}
|
|
2872
2985
|
/**
|
|
2873
2986
|
* One entry of {@link BlockWorkflowSnapshot.model3dOutputs} /
|
|
2874
2987
|
* {@link AppWorkflow.model3dOutputs} — the label for one 3D model url.
|
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
|
+
* 242 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 242 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
|
+
* 242 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 242 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
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"auth": {
|
|
73
73
|
"type": "string",
|
|
74
|
-
"description": "Which credential the host hands the block: \"block-token\" (default when omitted) is the block-scoped JWT; \"oauth\" asks for an opaque OAuth access token for the block's own OauthClient, which ordinary /api/v1 routes accept as a viewer bearer. Minting it
|
|
74
|
+
"description": "Which credential the host hands the block: \"block-token\" (default when omitted) is the block-scoped JWT; \"oauth\" asks for an opaque OAuth access token for the block's own OauthClient, which ordinary /api/v1 routes accept as a viewer bearer. Minting it requires OAuth minting to be switched on for the server, a signed-in viewer and a declared \"user:read:self\" scope; when any of those is unmet the host hands back a block JWT instead of failing, so branch on the token kind the host reports rather than on this field. An OAuth token is refused by the postMessage bridge procedures, which verify a block JWT only, and a manifest declaring \"oauth\" alongside \"apps:storage\" or any \"apps:storage:*\" scope is rejected by manifest validation.",
|
|
75
75
|
"enum": ["block-token", "oauth"]
|
|
76
76
|
},
|
|
77
77
|
"trustTier": {
|