@marinoscar/vault-web 0.0.0-bootstrap → 0.1.0-next.3
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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/agent/headless/agentActivity.d.ts +53 -0
- package/dist/agent/headless/agentActivity.js +58 -0
- package/dist/agent/headless/index.d.ts +2 -0
- package/dist/agent/headless/index.js +3 -0
- package/dist/agent/headless/useAgentActivity.d.ts +9 -0
- package/dist/agent/headless/useAgentActivity.js +30 -0
- package/dist/agent/ui/components/AgentActivityTable.d.ts +25 -0
- package/dist/agent/ui/components/AgentActivityTable.js +114 -0
- package/dist/agent/ui/index.d.ts +3 -0
- package/dist/agent/ui/index.js +4 -0
- package/dist/agent/ui/pages/AgentAccessSettingsPage.d.ts +7 -0
- package/dist/agent/ui/pages/AgentAccessSettingsPage.js +70 -0
- package/dist/agent/ui/pages/AgentActivityPage.d.ts +6 -0
- package/dist/agent/ui/pages/AgentActivityPage.js +61 -0
- package/dist/backups/headless/backupContents.d.ts +69 -0
- package/dist/backups/headless/backupContents.js +133 -0
- package/dist/backups/headless/backupPassword.d.ts +34 -0
- package/dist/backups/headless/backupPassword.js +80 -0
- package/dist/backups/headless/backupSchedule.d.ts +56 -0
- package/dist/backups/headless/backupSchedule.js +189 -0
- package/dist/backups/headless/index.d.ts +4 -0
- package/dist/backups/headless/index.js +5 -0
- package/dist/backups/headless/useBackupRunHistory.d.ts +36 -0
- package/dist/backups/headless/useBackupRunHistory.js +83 -0
- package/dist/backups/ui/components/AdminBackupDownloadDialog.d.ts +20 -0
- package/dist/backups/ui/components/AdminBackupDownloadDialog.js +65 -0
- package/dist/backups/ui/components/BackupContentsGroup.d.ts +17 -0
- package/dist/backups/ui/components/BackupContentsGroup.js +21 -0
- package/dist/backups/ui/components/BackupPasswordFields.d.ts +18 -0
- package/dist/backups/ui/components/BackupPasswordFields.js +40 -0
- package/dist/backups/ui/components/BackupRunsTable.d.ts +44 -0
- package/dist/backups/ui/components/BackupRunsTable.js +61 -0
- package/dist/backups/ui/components/DataBackup.d.ts +14 -0
- package/dist/backups/ui/components/DataBackup.js +169 -0
- package/dist/backups/ui/components/ScheduledBackups.d.ts +13 -0
- package/dist/backups/ui/components/ScheduledBackups.js +304 -0
- package/dist/backups/ui/index.d.ts +8 -0
- package/dist/backups/ui/index.js +9 -0
- package/dist/backups/ui/pages/BackupSettingsPage.d.ts +8 -0
- package/dist/backups/ui/pages/BackupSettingsPage.js +19 -0
- package/dist/backups/ui/pages/MyBackupsPage.d.ts +8 -0
- package/dist/backups/ui/pages/MyBackupsPage.js +19 -0
- package/dist/brand/BrandLockup.d.ts +14 -0
- package/dist/brand/BrandLockup.js +13 -0
- package/dist/brand/assets/vault-mark.png +0 -0
- package/dist/brand/contrast.d.ts +8 -0
- package/dist/brand/contrast.js +21 -0
- package/dist/brand/index.d.ts +7 -0
- package/dist/brand/index.js +8 -0
- package/dist/brand/mark.d.ts +6 -0
- package/dist/brand/mark.js +7 -0
- package/dist/brand/theme.d.ts +25 -0
- package/dist/brand/theme.js +84 -0
- package/dist/brand/tokens.d.ts +52 -0
- package/dist/brand/tokens.js +54 -0
- package/dist/cards/headless/cardExpiry.d.ts +57 -0
- package/dist/cards/headless/cardExpiry.js +138 -0
- package/dist/cards/headless/cardFormat.d.ts +60 -0
- package/dist/cards/headless/cardFormat.js +135 -0
- package/dist/cards/headless/cardImage.d.ts +293 -0
- package/dist/cards/headless/cardImage.js +518 -0
- package/dist/cards/headless/index.d.ts +6 -0
- package/dist/cards/headless/index.js +7 -0
- package/dist/cards/headless/useCardImport.d.ts +137 -0
- package/dist/cards/headless/useCardImport.js +391 -0
- package/dist/cards/headless/useCardRenewal.d.ts +102 -0
- package/dist/cards/headless/useCardRenewal.js +305 -0
- package/dist/cards/headless/useCards.d.ts +80 -0
- package/dist/cards/headless/useCards.js +114 -0
- package/dist/cards/ui/components/AiEgressNotice.d.ts +13 -0
- package/dist/cards/ui/components/AiEgressNotice.js +18 -0
- package/dist/cards/ui/components/CardCaptureStep.d.ts +59 -0
- package/dist/cards/ui/components/CardCaptureStep.js +96 -0
- package/dist/cards/ui/components/CardCropAdjuster.d.ts +43 -0
- package/dist/cards/ui/components/CardCropAdjuster.js +215 -0
- package/dist/cards/ui/components/CardCropReview.d.ts +51 -0
- package/dist/cards/ui/components/CardCropReview.js +88 -0
- package/dist/cards/ui/components/CardExpiryBadge.d.ts +8 -0
- package/dist/cards/ui/components/CardExpiryBadge.js +43 -0
- package/dist/cards/ui/components/CardFieldDiff.d.ts +37 -0
- package/dist/cards/ui/components/CardFieldDiff.js +66 -0
- package/dist/cards/ui/components/CardFlowStepper.d.ts +24 -0
- package/dist/cards/ui/components/CardFlowStepper.js +23 -0
- package/dist/cards/ui/components/CardReviewForm.d.ts +44 -0
- package/dist/cards/ui/components/CardReviewForm.js +102 -0
- package/dist/cards/ui/components/CardScanModelSection.d.ts +23 -0
- package/dist/cards/ui/components/CardScanModelSection.js +81 -0
- package/dist/cards/ui/components/CardTile.d.ts +40 -0
- package/dist/cards/ui/components/CardTile.js +94 -0
- package/dist/cards/ui/index.d.ts +15 -0
- package/dist/cards/ui/index.js +16 -0
- package/dist/cards/ui/pages/AiSettingsPage.d.ts +12 -0
- package/dist/cards/ui/pages/AiSettingsPage.js +24 -0
- package/dist/cards/ui/pages/CardsPage.d.ts +26 -0
- package/dist/cards/ui/pages/CardsPage.js +160 -0
- package/dist/cards/ui/pages/ImportCardPage.d.ts +24 -0
- package/dist/cards/ui/pages/ImportCardPage.js +343 -0
- package/dist/cards/ui/pages/RenewCardPage.d.ts +35 -0
- package/dist/cards/ui/pages/RenewCardPage.js +350 -0
- package/dist/core/headless/api.d.ts +272 -0
- package/dist/core/headless/api.js +425 -0
- package/dist/core/headless/cardScanAvailability.d.ts +20 -0
- package/dist/core/headless/cardScanAvailability.js +27 -0
- package/dist/core/headless/clipboard.d.ts +60 -0
- package/dist/core/headless/clipboard.js +101 -0
- package/dist/core/headless/http.d.ts +41 -0
- package/dist/core/headless/http.js +50 -0
- package/dist/core/headless/index.d.ts +12 -0
- package/dist/core/headless/index.js +13 -0
- package/dist/core/headless/relativeTime.d.ts +7 -0
- package/dist/core/headless/relativeTime.js +28 -0
- package/dist/core/headless/saveBlob.d.ts +6 -0
- package/dist/core/headless/saveBlob.js +21 -0
- package/dist/core/headless/types.d.ts +441 -0
- package/dist/core/headless/types.js +49 -0
- package/dist/core/headless/useAiStatus.d.ts +41 -0
- package/dist/core/headless/useAiStatus.js +42 -0
- package/dist/core/headless/useCopyToClipboard.d.ts +20 -0
- package/dist/core/headless/useCopyToClipboard.js +52 -0
- package/dist/core/headless/useDashboardResource.d.ts +22 -0
- package/dist/core/headless/useDashboardResource.js +52 -0
- package/dist/core/headless/useSystemSettings.d.ts +17 -0
- package/dist/core/headless/useSystemSettings.js +106 -0
- package/dist/core/headless/useUserSettings.d.ts +13 -0
- package/dist/core/headless/useUserSettings.js +103 -0
- package/dist/core/ui/ErrorBoundary.d.ts +15 -0
- package/dist/core/ui/ErrorBoundary.js +27 -0
- package/dist/core/ui/LoadingSpinner.d.ts +6 -0
- package/dist/core/ui/LoadingSpinner.js +14 -0
- package/dist/core/ui/SettingsPageFrame.d.ts +19 -0
- package/dist/core/ui/SettingsPageFrame.js +12 -0
- package/dist/core/ui/StorageSettingsLink.d.ts +19 -0
- package/dist/core/ui/StorageSettingsLink.js +26 -0
- package/dist/core/ui/index.d.ts +4 -0
- package/dist/core/ui/index.js +5 -0
- package/dist/home/headless/homeLinks.d.ts +24 -0
- package/dist/home/headless/homeLinks.js +24 -0
- package/dist/home/headless/index.d.ts +1 -0
- package/dist/home/headless/index.js +2 -0
- package/dist/home/ui/components/BackupStatusPanel.d.ts +28 -0
- package/dist/home/ui/components/BackupStatusPanel.js +99 -0
- package/dist/home/ui/components/DashboardPanel.d.ts +33 -0
- package/dist/home/ui/components/DashboardPanel.js +21 -0
- package/dist/home/ui/components/ExpiringCardsPanel.d.ts +31 -0
- package/dist/home/ui/components/ExpiringCardsPanel.js +35 -0
- package/dist/home/ui/components/FirstRunPanel.d.ts +7 -0
- package/dist/home/ui/components/FirstRunPanel.js +21 -0
- package/dist/home/ui/components/QuickActions.d.ts +14 -0
- package/dist/home/ui/components/QuickActions.js +40 -0
- package/dist/home/ui/components/RecentSecretsPanel.d.ts +19 -0
- package/dist/home/ui/components/RecentSecretsPanel.js +20 -0
- package/dist/home/ui/components/StatsRow.d.ts +19 -0
- package/dist/home/ui/components/StatsRow.js +46 -0
- package/dist/home/ui/components/WelcomeHeader.d.ts +11 -0
- package/dist/home/ui/components/WelcomeHeader.js +15 -0
- package/dist/home/ui/index.d.ts +9 -0
- package/dist/home/ui/index.js +10 -0
- package/dist/home/ui/pages/HomePage.d.ts +14 -0
- package/dist/home/ui/pages/HomePage.js +121 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/media/headless/index.d.ts +2 -0
- package/dist/media/headless/index.js +3 -0
- package/dist/media/headless/useMediaFiles.d.ts +20 -0
- package/dist/media/headless/useMediaFiles.js +82 -0
- package/dist/media/headless/useMediaFolders.d.ts +22 -0
- package/dist/media/headless/useMediaFolders.js +81 -0
- package/dist/media/ui/components/FolderList.d.ts +19 -0
- package/dist/media/ui/components/FolderList.js +36 -0
- package/dist/media/ui/components/MediaList.d.ts +20 -0
- package/dist/media/ui/components/MediaList.js +55 -0
- package/dist/media/ui/components/MediaPlayer.d.ts +7 -0
- package/dist/media/ui/components/MediaPlayer.js +361 -0
- package/dist/media/ui/index.d.ts +10 -0
- package/dist/media/ui/index.js +11 -0
- package/dist/media/ui/pages/CreateFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/CreateFolderPage.js +39 -0
- package/dist/media/ui/pages/EditFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/EditFolderPage.js +59 -0
- package/dist/media/ui/pages/MediaFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaFolderPage.js +68 -0
- package/dist/media/ui/pages/MediaFoldersPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaFoldersPage.js +58 -0
- package/dist/media/ui/pages/MediaPlayerPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaPlayerPage.js +76 -0
- package/dist/media/ui/pages/MediaUploadPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaUploadPage.js +88 -0
- package/dist/media/ui/pages/RenameMediaFilePage.d.ts +1 -0
- package/dist/media/ui/pages/RenameMediaFilePage.js +63 -0
- package/dist/navigation/destinations.d.ts +50 -0
- package/dist/navigation/destinations.js +109 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +4 -0
- package/dist/secrets/headless/fieldOptionsValidation.d.ts +45 -0
- package/dist/secrets/headless/fieldOptionsValidation.js +79 -0
- package/dist/secrets/headless/index.d.ts +6 -0
- package/dist/secrets/headless/index.js +7 -0
- package/dist/secrets/headless/secretFields.d.ts +86 -0
- package/dist/secrets/headless/secretFields.js +190 -0
- package/dist/secrets/headless/useSecretDetail.d.ts +33 -0
- package/dist/secrets/headless/useSecretDetail.js +87 -0
- package/dist/secrets/headless/useSecretTypes.d.ts +16 -0
- package/dist/secrets/headless/useSecretTypes.js +62 -0
- package/dist/secrets/headless/useSecrets.d.ts +24 -0
- package/dist/secrets/headless/useSecrets.js +59 -0
- package/dist/secrets/headless/useTotpCode.d.ts +24 -0
- package/dist/secrets/headless/useTotpCode.js +116 -0
- package/dist/secrets/ui/components/CardImages.d.ts +31 -0
- package/dist/secrets/ui/components/CardImages.js +208 -0
- package/dist/secrets/ui/components/DynamicSecretFields.d.ts +10 -0
- package/dist/secrets/ui/components/DynamicSecretFields.js +90 -0
- package/dist/secrets/ui/components/FieldDefinitionBuilder.d.ts +13 -0
- package/dist/secrets/ui/components/FieldDefinitionBuilder.js +114 -0
- package/dist/secrets/ui/components/FieldOptionsEditor.d.ts +15 -0
- package/dist/secrets/ui/components/FieldOptionsEditor.js +45 -0
- package/dist/secrets/ui/components/SecretAttachments.d.ts +15 -0
- package/dist/secrets/ui/components/SecretAttachments.js +106 -0
- package/dist/secrets/ui/components/SecretForm.d.ts +34 -0
- package/dist/secrets/ui/components/SecretForm.js +83 -0
- package/dist/secrets/ui/components/SecretFormDialog.d.ts +15 -0
- package/dist/secrets/ui/components/SecretFormDialog.js +95 -0
- package/dist/secrets/ui/components/SecretTypeFormDialog.d.ts +15 -0
- package/dist/secrets/ui/components/SecretTypeFormDialog.js +92 -0
- package/dist/secrets/ui/components/SecretTypeIcon.d.ts +8 -0
- package/dist/secrets/ui/components/SecretTypeIcon.js +16 -0
- package/dist/secrets/ui/components/SecretTypesList.d.ts +10 -0
- package/dist/secrets/ui/components/SecretTypesList.js +13 -0
- package/dist/secrets/ui/components/SecretValueField.d.ts +20 -0
- package/dist/secrets/ui/components/SecretValueField.js +52 -0
- package/dist/secrets/ui/components/SecretVersionDrawer.d.ts +22 -0
- package/dist/secrets/ui/components/SecretVersionDrawer.js +131 -0
- package/dist/secrets/ui/components/SecretsTable.d.ts +49 -0
- package/dist/secrets/ui/components/SecretsTable.js +174 -0
- package/dist/secrets/ui/components/TotpCodeCard.d.ts +8 -0
- package/dist/secrets/ui/components/TotpCodeCard.js +34 -0
- package/dist/secrets/ui/index.d.ts +20 -0
- package/dist/secrets/ui/index.js +21 -0
- package/dist/secrets/ui/pages/CreateSecretPage.d.ts +2 -0
- package/dist/secrets/ui/pages/CreateSecretPage.js +25 -0
- package/dist/secrets/ui/pages/CreateSecretTypePage.d.ts +1 -0
- package/dist/secrets/ui/pages/CreateSecretTypePage.js +62 -0
- package/dist/secrets/ui/pages/EditSecretPage.d.ts +5 -0
- package/dist/secrets/ui/pages/EditSecretPage.js +55 -0
- package/dist/secrets/ui/pages/EditSecretTypePage.d.ts +1 -0
- package/dist/secrets/ui/pages/EditSecretTypePage.js +88 -0
- package/dist/secrets/ui/pages/SecretDetailPage.d.ts +7 -0
- package/dist/secrets/ui/pages/SecretDetailPage.js +182 -0
- package/dist/secrets/ui/pages/SecretTypesPage.d.ts +1 -0
- package/dist/secrets/ui/pages/SecretTypesPage.js +23 -0
- package/dist/secrets/ui/pages/SecretsPage.d.ts +6 -0
- package/dist/secrets/ui/pages/SecretsPage.js +179 -0
- package/dist/settings/ui/components/FeatureFlagsList.d.ts +7 -0
- package/dist/settings/ui/components/FeatureFlagsList.js +46 -0
- package/dist/settings/ui/components/ImageUpload.d.ts +6 -0
- package/dist/settings/ui/components/ImageUpload.js +61 -0
- package/dist/settings/ui/components/ProfileSettings.d.ts +11 -0
- package/dist/settings/ui/components/ProfileSettings.js +55 -0
- package/dist/settings/ui/components/ThemeSettings.d.ts +7 -0
- package/dist/settings/ui/components/ThemeSettings.js +24 -0
- package/dist/settings/ui/components/UISettings.d.ts +9 -0
- package/dist/settings/ui/components/UISettings.js +25 -0
- package/dist/settings/ui/components/UserProfileCard.d.ts +1 -0
- package/dist/settings/ui/components/UserProfileCard.js +39 -0
- package/dist/settings/ui/components/UserSettingsSection.d.ts +23 -0
- package/dist/settings/ui/components/UserSettingsSection.js +29 -0
- package/dist/settings/ui/index.d.ts +10 -0
- package/dist/settings/ui/index.js +11 -0
- package/dist/settings/ui/pages/AppearanceSettingsPage.d.ts +6 -0
- package/dist/settings/ui/pages/AppearanceSettingsPage.js +11 -0
- package/dist/settings/ui/pages/GeneralSettingsPage.d.ts +9 -0
- package/dist/settings/ui/pages/GeneralSettingsPage.js +41 -0
- package/dist/settings/ui/pages/ProfileSettingsPage.d.ts +6 -0
- package/dist/settings/ui/pages/ProfileSettingsPage.js +11 -0
- package/package.json +146 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISO/IEC 7810 ID-1, the physical format every payment card uses:
|
|
3
|
+
* 85.60 mm x 53.98 mm, i.e. ~1.586:1.
|
|
4
|
+
*
|
|
5
|
+
* Locking the crop to this ratio is what lets the user frame a shot roughly and
|
|
6
|
+
* still hand the model a rectangle whose proportions match a real card.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CARD_ASPECT_RATIO: number;
|
|
9
|
+
/**
|
|
10
|
+
* Longest edge of the encoded image.
|
|
11
|
+
*
|
|
12
|
+
* Generous on purpose. An earlier 1400px cap assumed pixels past that point
|
|
13
|
+
* bought nothing, which proved false in practice: faint engraving (metal
|
|
14
|
+
* cards) photographed without filling the frame came out too small to read
|
|
15
|
+
* after crop + downscale. The provider downsizes internally anyway, so
|
|
16
|
+
* sending more pixels just lets IT decide what to keep — the only real cost
|
|
17
|
+
* is upload size, which the quality ladder below still bounds.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CARD_IMAGE_MAX_LONG_EDGE = 2048;
|
|
20
|
+
/** Starting JPEG quality. The ladder below drops from here only if it must. */
|
|
21
|
+
export declare const CARD_IMAGE_JPEG_QUALITY = 0.9;
|
|
22
|
+
/** Upper bound of the user-adjustable crop zoom (1 = the auto-fit rect). */
|
|
23
|
+
export declare const CARD_IMAGE_MAX_ZOOM = 4;
|
|
24
|
+
export declare const CARD_IMAGE_MIME_TYPE = "image/jpeg";
|
|
25
|
+
/**
|
|
26
|
+
* Largest data URL the API accepts, mirroring `MAX_IMAGE_DATA_URL_LENGTH` in
|
|
27
|
+
* `apps/api/src/ai/ai.constants.ts`. Measured in characters, not bytes, because
|
|
28
|
+
* that is what the server-side `.max()` checks.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MAX_IMAGE_DATA_URL_LENGTH = 6000000;
|
|
31
|
+
/**
|
|
32
|
+
* Longest edge of the FULL photo prepared for extraction.
|
|
33
|
+
*
|
|
34
|
+
* Higher than {@link CARD_IMAGE_MAX_LONG_EDGE} because the card typically
|
|
35
|
+
* occupies only part of the frame: after the model's box is cropped out, the
|
|
36
|
+
* card itself lands at a fraction of this. The photo is downscaled only when
|
|
37
|
+
* it exceeds this — never cropped, never rotated, aspect untouched — because
|
|
38
|
+
* the returned box is expressed in fractions of the image exactly as sent.
|
|
39
|
+
*/
|
|
40
|
+
export declare const CARD_PHOTO_MAX_LONG_EDGE = 3072;
|
|
41
|
+
/**
|
|
42
|
+
* Margin added around an AI-returned card box before cropping, as a fraction
|
|
43
|
+
* of the box's longer edge. A sliver of context absorbs a slightly-tight box
|
|
44
|
+
* without visibly shrinking the card in the stored attachment.
|
|
45
|
+
*/
|
|
46
|
+
export declare const CROP_BOX_MARGIN_FRACTION = 0.04;
|
|
47
|
+
export interface CropRect {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
}
|
|
53
|
+
export interface OutputSize {
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
/** Factor applied to the crop rect to reach the output size; never above 1. */
|
|
57
|
+
scale: number;
|
|
58
|
+
}
|
|
59
|
+
export interface CardCropPlan {
|
|
60
|
+
/**
|
|
61
|
+
* In EFFECTIVE source coordinates: the source frame after `quarterTurns`
|
|
62
|
+
* clockwise quarter-turns have been applied. For odd turn counts the
|
|
63
|
+
* effective width/height are the source's swapped.
|
|
64
|
+
*/
|
|
65
|
+
crop: CropRect;
|
|
66
|
+
output: OutputSize;
|
|
67
|
+
/** Clockwise quarter-turns (0-3) the renderer must apply at draw time. */
|
|
68
|
+
quarterTurns: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* User adjustments to the crop, all optional and all defaulting to the
|
|
72
|
+
* auto-fit behavior (zoom 1, no pan, no rotation).
|
|
73
|
+
*/
|
|
74
|
+
export interface CardAdjustments {
|
|
75
|
+
/** 1 = the auto-fit maximal rect; up to {@link CARD_IMAGE_MAX_ZOOM}. */
|
|
76
|
+
zoom?: number;
|
|
77
|
+
/** Pan offset from center, in effective source pixels. Clamped internally. */
|
|
78
|
+
panX?: number;
|
|
79
|
+
panY?: number;
|
|
80
|
+
/** Clockwise quarter-turns, 0-3. */
|
|
81
|
+
quarterTurns?: number;
|
|
82
|
+
}
|
|
83
|
+
export interface CardCropOptions extends CardAdjustments {
|
|
84
|
+
aspectRatio?: number;
|
|
85
|
+
maxLongEdge?: number;
|
|
86
|
+
}
|
|
87
|
+
/** Clamp `value` into `[min, max]`. Non-finite values clamp to `min`. */
|
|
88
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
89
|
+
/** Normalize any number (or undefined) of quarter-turns into 0..3. */
|
|
90
|
+
export declare function normalizeQuarterTurns(turns: number | undefined): number;
|
|
91
|
+
/**
|
|
92
|
+
* The source frame's dimensions AFTER rotation. An odd number of quarter-turns
|
|
93
|
+
* swaps width and height; the crop rect is always computed against these
|
|
94
|
+
* effective dimensions, never the raw ones.
|
|
95
|
+
*/
|
|
96
|
+
export declare function effectiveSourceSize(sourceWidth: number, sourceHeight: number, quarterTurns: number | undefined): {
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* The largest rectangle of `aspectRatio` that fits inside the source frame,
|
|
102
|
+
* centred.
|
|
103
|
+
*
|
|
104
|
+
* This is the STARTING point, not the final word: it is what the user sees at
|
|
105
|
+
* zoom 1 before adjusting. The centred maximal rect is right often enough to
|
|
106
|
+
* be a good default, but a card that does not fill the frame (or arrives
|
|
107
|
+
* rotated) is fixed by the user via {@link computeAdjustedCropRect} rather
|
|
108
|
+
* than by retaking the shot.
|
|
109
|
+
*
|
|
110
|
+
* Results are integers because they index pixels. Every value is clamped into
|
|
111
|
+
* the source frame so a rounding step can never produce a rect that hangs off
|
|
112
|
+
* the edge, and never a zero-width rect for a source only a few pixels across.
|
|
113
|
+
*/
|
|
114
|
+
export declare function computeCardCropRect(sourceWidth: number, sourceHeight: number, aspectRatio?: number): CropRect;
|
|
115
|
+
/**
|
|
116
|
+
* How far the crop rect can move from center, per axis, in effective source
|
|
117
|
+
* pixels, at a given zoom. Zero on an axis the crop already fills.
|
|
118
|
+
*
|
|
119
|
+
* The UI uses this to clamp the STORED pan as the user drags or zooms out, so
|
|
120
|
+
* pan offsets never silently accumulate past the edge of the frame.
|
|
121
|
+
*/
|
|
122
|
+
export declare function computeMaxPan(sourceWidth: number, sourceHeight: number, zoom: number, aspectRatio?: number): {
|
|
123
|
+
x: number;
|
|
124
|
+
y: number;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The user-adjusted crop rect: the auto-fit rect of
|
|
128
|
+
* {@link computeCardCropRect}, shrunk by `zoom` and moved by `(panX, panY)`
|
|
129
|
+
* from center.
|
|
130
|
+
*
|
|
131
|
+
* `zoom` is clamped into `[1, CARD_IMAGE_MAX_ZOOM]` and the rect is clamped so
|
|
132
|
+
* it never leaves the source frame, whatever pan is passed in. With
|
|
133
|
+
* `zoom = 1, panX = 0, panY = 0` this returns exactly the auto-fit rect.
|
|
134
|
+
*
|
|
135
|
+
* NOTE ON ROTATION: rotation is applied at draw time, not here. Callers
|
|
136
|
+
* cropping a rotated source must pass the EFFECTIVE dimensions (see
|
|
137
|
+
* {@link effectiveSourceSize}) — for odd quarter-turns width and height swap.
|
|
138
|
+
*/
|
|
139
|
+
export declare function computeAdjustedCropRect(sourceWidth: number, sourceHeight: number, zoom: number, panX: number, panY: number, aspectRatio?: number): CropRect;
|
|
140
|
+
/**
|
|
141
|
+
* A card's location within a photo, as the extraction API reports it.
|
|
142
|
+
*
|
|
143
|
+
* `x`/`y`/`width`/`height` are fractions (0-1) of the image EXACTLY as it was
|
|
144
|
+
* sent for extraction. Fractions survive uniform scaling, so they apply
|
|
145
|
+
* equally to the raw capture the prepared photo was downscaled from — which is
|
|
146
|
+
* what the crop is actually rendered from, at full resolution.
|
|
147
|
+
*/
|
|
148
|
+
export interface FractionalCropBox {
|
|
149
|
+
x: number;
|
|
150
|
+
y: number;
|
|
151
|
+
width: number;
|
|
152
|
+
height: number;
|
|
153
|
+
/** Clockwise quarter-turns (0-3) that make the card upright. */
|
|
154
|
+
quarterTurns?: number;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Convert an AI-returned fractional box into a pixel crop rect ready for
|
|
158
|
+
* {@link drawCardCrop}: fractions -> pixels, a small margin added, snapped to
|
|
159
|
+
* the card aspect ratio around the box centre, clamped inside the image.
|
|
160
|
+
*
|
|
161
|
+
* `imageWidth`/`imageHeight` are the RAW dimensions of the image the crop is
|
|
162
|
+
* rendered from. The returned rect is in EFFECTIVE coordinates — the frame
|
|
163
|
+
* after the box's `quarterTurns` have been applied (see
|
|
164
|
+
* {@link effectiveSourceSize}) — and must be paired with those same
|
|
165
|
+
* `quarterTurns` at draw time.
|
|
166
|
+
*
|
|
167
|
+
* The aspect snap only ever GROWS the box (the short axis is extended), so a
|
|
168
|
+
* tight box never cuts into the card; if growth would overflow the frame the
|
|
169
|
+
* rect is scaled down uniformly, preserving the aspect, and shifted inside.
|
|
170
|
+
*
|
|
171
|
+
* Throws `RangeError` for a degenerate box (no area inside the image), which
|
|
172
|
+
* callers treat as "no usable box" and fall back to the auto-fit crop.
|
|
173
|
+
*/
|
|
174
|
+
export declare function cropRectFromBox(imageWidth: number, imageHeight: number, box: FractionalCropBox, aspectRatio?: number, marginFraction?: number): CropRect;
|
|
175
|
+
/**
|
|
176
|
+
* Express an explicit crop rect (EFFECTIVE coordinates) in the adjuster's
|
|
177
|
+
* zoom/pan/turns model, so {@link computeAdjustedCropRect} reproduces it (up
|
|
178
|
+
* to rounding).
|
|
179
|
+
*
|
|
180
|
+
* `zoom` is the ratio of the auto-fit rect to this one, clamped into the
|
|
181
|
+
* adjuster's `[1, CARD_IMAGE_MAX_ZOOM]` range — a rect outside that range is
|
|
182
|
+
* approximated by the nearest representable framing. Pan is the offset of the
|
|
183
|
+
* rect's centre from the frame's centre.
|
|
184
|
+
*/
|
|
185
|
+
export declare function adjustmentsFromCropRect(sourceWidth: number, sourceHeight: number, crop: CropRect, quarterTurns: number | undefined, aspectRatio?: number): Required<CardAdjustments>;
|
|
186
|
+
/**
|
|
187
|
+
* Seed the adjuster from an AI-returned box: {@link cropRectFromBox} then
|
|
188
|
+
* {@link adjustmentsFromCropRect}, so the adjuster opens showing (as near as
|
|
189
|
+
* its model allows) exactly the crop the box produced.
|
|
190
|
+
*/
|
|
191
|
+
export declare function adjustmentsFromCropBox(sourceWidth: number, sourceHeight: number, box: FractionalCropBox, aspectRatio?: number): Required<CardAdjustments>;
|
|
192
|
+
/**
|
|
193
|
+
* Downscale the crop so its longest edge is at most `maxLongEdge`.
|
|
194
|
+
*
|
|
195
|
+
* Never upscales: a low-resolution capture stays low-resolution rather than
|
|
196
|
+
* being inflated into a bigger file that carries no extra detail.
|
|
197
|
+
*/
|
|
198
|
+
export declare function computeOutputSize(cropWidth: number, cropHeight: number, maxLongEdge?: number): OutputSize;
|
|
199
|
+
/**
|
|
200
|
+
* Crop rect plus the size it will be encoded at.
|
|
201
|
+
*
|
|
202
|
+
* With no adjustments in `options` this plans exactly the auto-fit centred
|
|
203
|
+
* crop it always has. With adjustments, the crop rect is computed against the
|
|
204
|
+
* ROTATED (effective) frame; the returned `quarterTurns` tells the renderer
|
|
205
|
+
* which rotation to apply at draw time so the rect lands where the user aimed.
|
|
206
|
+
*/
|
|
207
|
+
export declare function planCardCrop(sourceWidth: number, sourceHeight: number, options?: CardCropOptions): CardCropPlan;
|
|
208
|
+
/**
|
|
209
|
+
* Decode a base64 data URL into a Blob.
|
|
210
|
+
*
|
|
211
|
+
* Used instead of `canvas.toBlob` so the canvas is encoded exactly once: the
|
|
212
|
+
* data URL measured against the size cap and the file uploaded to storage are
|
|
213
|
+
* guaranteed to be the same bytes, not two encodes that merely look alike.
|
|
214
|
+
*/
|
|
215
|
+
export declare function dataUrlToBlob(dataUrl: string): Blob;
|
|
216
|
+
export interface CroppedCardImage {
|
|
217
|
+
/** JPEG data URL of the cropped card — the stored-attachment bytes. */
|
|
218
|
+
dataUrl: string;
|
|
219
|
+
/** The same bytes as a File, ready for the storage upload endpoint. */
|
|
220
|
+
file: File;
|
|
221
|
+
/** Object URL for on-screen preview. Callers must revoke it when done. */
|
|
222
|
+
previewUrl: string;
|
|
223
|
+
width: number;
|
|
224
|
+
height: number;
|
|
225
|
+
}
|
|
226
|
+
/** The full photo prepared for `POST /api/secrets/cards/extract`. */
|
|
227
|
+
export interface PreparedCardPhoto {
|
|
228
|
+
/** JPEG data URL of the FULL frame, exactly what the extraction call sends. */
|
|
229
|
+
dataUrl: string;
|
|
230
|
+
/**
|
|
231
|
+
* Dimensions of the encoded image. Box fractions in the extraction response
|
|
232
|
+
* apply to exactly this image (and, being fractions, equally to the raw
|
|
233
|
+
* capture it was scaled from).
|
|
234
|
+
*/
|
|
235
|
+
width: number;
|
|
236
|
+
height: number;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Draw a planned card crop onto a destination rectangle, applying the plan's
|
|
240
|
+
* rotation.
|
|
241
|
+
*
|
|
242
|
+
* Shared by the final encode in {@link cropImageFileToCard} and the live
|
|
243
|
+
* preview in the adjust UI, so what the user sees while adjusting is drawn by
|
|
244
|
+
* the same code as what gets encoded. `destWidth`/`destHeight` need not match
|
|
245
|
+
* `plan.output` — the preview draws at screen resolution.
|
|
246
|
+
*
|
|
247
|
+
* The unrotated path is the exact `drawImage` source-rect call this module has
|
|
248
|
+
* always made. The rotated paths compose translate/rotate so that a point
|
|
249
|
+
* `(u, v)` of the raw source lands where the effective (rotated) frame puts
|
|
250
|
+
* it, then shift/scale the crop rect onto the destination.
|
|
251
|
+
*/
|
|
252
|
+
export declare function drawCardCrop(context: CanvasRenderingContext2D, image: CanvasImageSource, sourceWidth: number, sourceHeight: number, plan: Pick<CardCropPlan, 'crop' | 'quarterTurns'>, destWidth: number, destHeight: number): void;
|
|
253
|
+
/**
|
|
254
|
+
* Prepare the FULL photo for extraction: decode, downscale only when the long
|
|
255
|
+
* edge exceeds {@link CARD_PHOTO_MAX_LONG_EDGE} — no crop, no aspect change,
|
|
256
|
+
* no rotation — and JPEG-encode under the API's size cap.
|
|
257
|
+
*
|
|
258
|
+
* The returned `dataUrl` is what goes to `POST /api/secrets/cards/extract`;
|
|
259
|
+
* the returned dimensions are the frame the response's box fractions apply to.
|
|
260
|
+
*
|
|
261
|
+
* Throws with a user-presentable message when the file is not decodable or
|
|
262
|
+
* cannot be squeezed under the cap.
|
|
263
|
+
*/
|
|
264
|
+
export declare function prepareCardPhoto(file: File): Promise<PreparedCardPhoto>;
|
|
265
|
+
/**
|
|
266
|
+
* Crop, downscale and JPEG-encode a captured file to the card rectangle.
|
|
267
|
+
*
|
|
268
|
+
* `options` may carry user adjustments (`zoom`, `panX`, `panY`,
|
|
269
|
+
* `quarterTurns`); with none supplied the behavior is the historical auto-fit
|
|
270
|
+
* centred crop, unchanged.
|
|
271
|
+
*
|
|
272
|
+
* Throws with a user-presentable message when the file is not decodable or
|
|
273
|
+
* cannot be squeezed under the API's size cap.
|
|
274
|
+
*/
|
|
275
|
+
export declare function cropImageFileToCard(file: File, options?: CardCropOptions & {
|
|
276
|
+
fileName?: string;
|
|
277
|
+
}): Promise<CroppedCardImage>;
|
|
278
|
+
/**
|
|
279
|
+
* Crop, downscale and JPEG-encode a captured file from an explicit fractional
|
|
280
|
+
* box — the AI-located card. The rect comes from {@link cropRectFromBox}
|
|
281
|
+
* (margin, aspect snap, clamping) and is rendered by the same
|
|
282
|
+
* {@link drawCardCrop} + quality-ladder path as every other crop.
|
|
283
|
+
*
|
|
284
|
+
* The crop is rendered from the RAW capture at full resolution: the box's
|
|
285
|
+
* fractions apply to the (possibly downscaled) prepared photo and to the raw
|
|
286
|
+
* frame alike, and the raw frame has more pixels to give.
|
|
287
|
+
*/
|
|
288
|
+
export declare function cropImageFileToBox(file: File, box: FractionalCropBox, options?: {
|
|
289
|
+
fileName?: string;
|
|
290
|
+
aspectRatio?: number;
|
|
291
|
+
marginFraction?: number;
|
|
292
|
+
maxLongEdge?: number;
|
|
293
|
+
}): Promise<CroppedCardImage>;
|