-
Notifications
You must be signed in to change notification settings - Fork 52
Add Camera API type definitions #3597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2026-01-rc
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/ui-extensions': minor | ||
| --- | ||
|
|
||
| Add Camera API types |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import {ScannerApi} from '../scanner-api/scanner-api'; | ||
| import {StandardApi} from '../standard/standard-api'; | ||
| import {CameraApi} from '../camera-api/camera-api'; | ||
|
|
||
| export type ActionTargetApi<T> = {[key: string]: any} & { | ||
| extensionPoint: T; | ||
| } & StandardApi<T> & | ||
| ScannerApi; | ||
| ScannerApi & | ||
| CameraApi; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| export interface CameraMediaOptions { | ||
| /** | ||
| * The camera that will be active when the camera interface first opens. | ||
| * - `'user'`: The front-facing camera | ||
| * - `'environment'`: The rear-facing camera | ||
| * @defaultValue 'environment' | ||
| */ | ||
| facingMode?: 'user' | 'environment'; | ||
| /** | ||
| * The maximum width (0 to 1080) of the image in pixels. Resizes the image to this width if it is larger. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be What happens when users put a value of 0? |
||
| * @defaultValue 1080 | ||
| */ | ||
| maxWidth?: number; | ||
| /** | ||
| * The maximum height (0 to 1080) of the image in pixels. Resizes the image to this height if it is larger. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| * @defaultValue 1080 | ||
| */ | ||
| maxHeight?: number; | ||
| /** | ||
| * The quality of the image returned. Percentile value between 0 and 1. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, whats 0 quality do? |
||
| * @defaultValue 0.9 | ||
| */ | ||
| quality?: number; | ||
| } | ||
|
|
||
| export interface CameraMediaResponse { | ||
| /** The image data as base64 string. */ | ||
| base64: string; | ||
| /** The width of the image in pixels. */ | ||
| width: number; | ||
| /** The height of the image in pixels. */ | ||
| height: number; | ||
| /** The file size of the image in bytes. */ | ||
| fileSize: number; | ||
| /** The MIME type of the image. */ | ||
| type: string; | ||
| } | ||
|
|
||
| export interface CameraApiContent { | ||
| /** | ||
| * Launch the device's camera to take a photo. | ||
| * | ||
| * @param options the options for the camera media. | ||
| * @returns Promise<CameraMediaResponse> that resolves when the POS has necessary permissions to access the camera and the media is captured. | ||
| */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be clear on the promise reject reasons? Maybe something like: |
||
| takePhoto: (options?: CameraMediaOptions) => Promise<CameraMediaResponse>; | ||
| } | ||
|
|
||
| export interface CameraApi { | ||
| camera: CameraApiContent; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I missed it but we only want to allow the camera to be triggered from action targets? Is there a reason why we don't want the api accessible from tiles or blocks?