DeviceMock

v0.3.1
app.devicemock/devicemock Checked 2 days ago Published 8 days ago

3D device mockups of your app, made by your coding agent from live pages or screenshots.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_devices List device models

Lists the device models: ids, names, types, sizes in mm (facing the camera, open, portrait), width/height ratios, body colors, the screenshot size that fits each screen with almost no crop (for landscape, swap its width and height), and the hinge range of foldables and laptops.

list_presets List presets

Lists canvas size presets and rotation presets with their tilt, turn, and spin. Each canvas preset has a group: general, app-store, or google-play. Store screenshot presets give the portrait size. rotates: true means landscape is also accepted, with width and height swapped. The feature graphic is always 1024 x 500.

new_mockup New mockup

Starts a new, empty mockup with a transparent background. It replaces the current mockup. The canvas is a preset's size, or width x height in px (each defaults to 1600 x 900); width and height override a preset's size. Store screenshot presets start in portrait. landscape: true swaps their width and height. The feature graphic is always 1024 x 500.

ParameterTypeDescription
heightinteger
landscapebooleanStore screenshot presets: true starts the canvas in landscape, with width and height swapped. Omit this parameter for the feature graphic.
presetstringCanvas preset id from list_presets, for example hero.
widthinteger

resize_canvas Resize the canvas

Changes the canvas to a preset's size or to width x height in px. Each device and text layer keeps its relative position on the canvas. Device sizes, text sizes, text widths, and shadows scale by the smaller of the width and height scale factors. A taller or wider canvas gets more empty space. Check the preview after resizing.

ParameterTypeDescription
heightinteger
landscapebooleanStore screenshot presets: true uses landscape, with width and height swapped. Omit this parameter for the feature graphic.
presetstringCanvas preset id from list_presets, for example iphone-6.9.
widthinteger

set_background Set the background

Sets the canvas background: none (transparent), a color, a linear gradient, or an image.

ParameterTypeDescription
type *string
anglenumberFor gradient: the direction in degrees, as in CSS: 0 is bottom to top, 90 left to right, 180 (the default) top to bottom.
colorstringFor color: #rrggbb.
fitstringFor image: fill (default) or fit.
fromstringFor gradient: the start color, #rrggbb.
imagestringFor image: a PNG, JPEG, or WebP file path, an image URL, or a web page URL to capture at the canvas size.
placementobjectWhere the image sits in its frame after the fit, as the editor's Adjust dialog does. Omitted fields keep their value. A new image starts centered.
tostringFor gradient: the end color, #rrggbb.

add_device Add a device

Adds a device in front of the others. By default it is centered, faces the camera, and is 0.7 of the canvas height in portrait (landscape keeps that scale). Returns the new device, with its id.

ParameterTypeDescription
model *stringDevice model id from list_devices, for example iphone-18-pro.
colorstringBody color: #rrggbb, or a color name of the model from list_devices.
coverFitstringFoldables only: the fit of the cover screen image.
coverPlacementobjectFoldables only: where the cover screen image sits, as placement does.
coverScreenshotstring | nullFoldables only: the image for the cover (outer) screen. A PNG, JPEG, or WebP file path, an image URL, or a web page URL to capture at the screen's size.
fitstringfill (default): crop the image to fill the screen. fit: show all of it, with black bars.
foldnumberFoldables and laptops: the hinge angle in degrees. 0 is closed. Foldables open to 180 (the default); laptops have their own default and largest angle in list_devices. A folding book keeps its right ha…
layerstringMoves the device in front of or behind all the others. New devices go in front.
namestringA name for the device. Tools also find it by name.
orientationstringPhones, tablets, and foldables: portrait (default) or landscape. Landscape turns the device a quarter turn counterclockwise (its top to the left) before tilt, turn, and spin, and shows a landscape scr…
perspectivenumberCamera field of view in degrees (default 20). Low values look flatter: for a laptop seen from the front, 5 to 10 keeps the base from looking much wider than the lid.
placementobjectWhere the image sits in its frame after the fit, as the editor's Adjust dialog does. Omitted fields keep their value. A new image starts centered.
rotationstringRotation preset id from list_presets, for example angled-right. tilt, turn, and spin change it.
screenshotstring | nullThe screen image. A PNG, JPEG, or WebP file path, an image URL, or a web page URL to capture at the screen's size. null removes the image (the screen is then black).
shadowbooleanSoft shadow under the device (default true).
sizenumberDevice height as a part of the canvas height (default 0.7), for the device facing the camera: the open height of a foldable or a flip, and the height of an open laptop seen from the front. In landscap…
spinnumberDegrees in the image plane. Positive turns counterclockwise.
statusBarbooleanPhones and foldables: a web page screenshot leaves room at the top for a status bar with the time, signal, and battery, in the page's top color (default true). In landscape, phones hide the status bar…
tiltnumberDegrees about the horizontal axis. Positive brings the top edge toward the viewer.
turnnumberDegrees about the vertical axis. Positive turns the device so its left side shows. 180 shows the back.
xnumberCenter of the device: 0 is the left edge of the canvas, 1 the right edge.
ynumberCenter of the device: 0 is the top edge of the canvas, 1 the bottom edge.

update_device Update a device

Changes a device. Only the given fields change. Returns the device. get_mockup returns the whole mockup.

ParameterTypeDescription
id *stringThe device id, or its name if no other device has that name.
colorstringBody color: #rrggbb, or a color name of the model from list_devices.
coverFitstringFoldables only: the fit of the cover screen image.
coverPlacementobjectFoldables only: where the cover screen image sits, as placement does.
coverScreenshotstring | nullFoldables only: the image for the cover (outer) screen. A PNG, JPEG, or WebP file path, an image URL, or a web page URL to capture at the screen's size.
fitstringfill (default): crop the image to fill the screen. fit: show all of it, with black bars.
foldnumberFoldables and laptops: the hinge angle in degrees. 0 is closed. Foldables open to 180 (the default); laptops have their own default and largest angle in list_devices. A folding book keeps its right ha…
layerstringMoves the device in front of or behind all the others. New devices go in front.
namestringA name for the device. Tools also find it by name.
orientationstringPhones, tablets, and foldables: portrait (default) or landscape. Landscape turns the device a quarter turn counterclockwise (its top to the left) before tilt, turn, and spin, and shows a landscape scr…
perspectivenumberCamera field of view in degrees (default 20). Low values look flatter: for a laptop seen from the front, 5 to 10 keeps the base from looking much wider than the lid.
placementobjectWhere the image sits in its frame after the fit, as the editor's Adjust dialog does. Omitted fields keep their value. A new image starts centered.
rotationstringRotation preset id from list_presets, for example angled-right. tilt, turn, and spin change it.
screenshotstring | nullThe screen image. A PNG, JPEG, or WebP file path, an image URL, or a web page URL to capture at the screen's size. null removes the image (the screen is then black).
shadowbooleanSoft shadow under the device (default true).
sizenumberDevice height as a part of the canvas height (default 0.7), for the device facing the camera: the open height of a foldable or a flip, and the height of an open laptop seen from the front. In landscap…
spinnumberDegrees in the image plane. Positive turns counterclockwise.
statusBarbooleanPhones and foldables: a web page screenshot leaves room at the top for a status bar with the time, signal, and battery, in the page's top color (default true). In landscape, phones hide the status bar…
tiltnumberDegrees about the horizontal axis. Positive brings the top edge toward the viewer.
turnnumberDegrees about the vertical axis. Positive turns the device so its left side shows. 180 shows the back.
xnumberCenter of the device: 0 is the left edge of the canvas, 1 the right edge.
ynumberCenter of the device: 0 is the top edge of the canvas, 1 the bottom edge.

remove_device Remove a device

Removes a device from the mockup.

ParameterTypeDescription
id *stringThe device id, or its name if no other device has that name.

list_fonts List fonts

Lists the fonts for text layers: their ids, names, weight ranges, and supported scripts. Arabic, Hebrew, Thai, and Devanagari text uses a matching Noto font when the chosen font lacks those letters. Chinese, Japanese, Korean, and emoji are not supported yet. add_text reports them as missing.

add_text Add text

Adds a text layer in front of all other layers, using the headline or subtitle preset or your own style. A headline goes at the top center. A subtitle goes below the topmost headline, smaller and lighter. Returns the text layer with its box and line count. missing lists characters that no font supports. Those characters are not drawn. For a fixed width, overflows reports whether any line is wider than the box. cutWords reports whether a line breaks inside a word wider than the box (use a wider box or a smaller size). offCanvas reports whether the text box extends past an edge of the canvas.

ParameterTypeDescription
text *stringThe text. \n starts a new line. At most 2,000 characters.
alignstringHow the lines align within the box: left, center (default), or right.
anchorstringThe point of the text box placed at x and y (default top-center). With top-center, the box stays centered and extends downward as it grows.
colorstringThe text color, #rrggbb.
directionstringauto (default) takes the direction from the text. ltr sets left-to-right direction. rtl sets right-to-left direction, for example when a right-to-left line starts with a Latin word.
fontstringA font id from list_fonts (default inter).
langstringA BCP 47 language tag, for example sr-Latn or th. Controls language-specific letter forms and Thai word breaks.
layerstringMoves the text in front of or behind all the other layers. New text goes in front.
letterSpacingnumberExtra space between characters, as a part of size, from -0.5 to 2 (default 0). Arabic letters stay joined.
lineHeightnumberThe line height as a multiple of size (the headline preset uses 1.1).
namestringA name for the layer. Without it, the layer's name follows its text.
opacitynumber0 to 1 (default 1).
presetstringheadline (default): large and bold. subtitle: smaller and lighter, below the topmost headline.
sizenumberThe text size as a part of the canvas height, for example 0.075 for a headline.
weightnumberThe font weight: 100 is thin, 900 is black. Use a value within the font's weight range from list_fonts.
widthnumber | nullA fixed width as a part of the canvas width. Text wraps to this width. null (default) makes the box as wide as its longest line.
xnumberThe anchor point across the canvas: 0 is the left edge, 1 the right edge (default 0.5).
ynumberThe anchor point down the canvas: 0 is the top edge, 1 the bottom edge.

update_text Update text

Changes a text layer. Only the given fields change. Returns the text layer with its box, line count, missing characters, overflow, breaks inside words, and whether its box extends past a canvas edge.

ParameterTypeDescription
id *stringThe text layer's id, or a name that identifies exactly one text layer.
alignstringHow the lines align within the box: left, center (default), or right.
anchorstringThe point of the text box placed at x and y (default top-center). With top-center, the box stays centered and extends downward as it grows.
colorstringThe text color, #rrggbb.
directionstringauto (default) takes the direction from the text. ltr sets left-to-right direction. rtl sets right-to-left direction, for example when a right-to-left line starts with a Latin word.
fontstringA font id from list_fonts (default inter).
langstringA BCP 47 language tag, for example sr-Latn or th. Controls language-specific letter forms and Thai word breaks.
layerstringMoves the text in front of or behind all the other layers. New text goes in front.
letterSpacingnumberExtra space between characters, as a part of size, from -0.5 to 2 (default 0). Arabic letters stay joined.
lineHeightnumberThe line height as a multiple of size (the headline preset uses 1.1).
namestringA name for the layer. Without it, the layer's name follows its text.
opacitynumber0 to 1 (default 1).
presetstringheadline (default): large and bold. subtitle: smaller and lighter, below the topmost headline.
sizenumberThe text size as a part of the canvas height, for example 0.075 for a headline.
textstringThe text. \n starts a new line. At most 2,000 characters.
weightnumberThe font weight: 100 is thin, 900 is black. Use a value within the font's weight range from list_fonts.
widthnumber | nullA fixed width as a part of the canvas width. Text wraps to this width. null (default) makes the box as wide as its longest line.
xnumberThe anchor point across the canvas: 0 is the left edge, 1 the right edge (default 0.5).
ynumberThe anchor point down the canvas: 0 is the top edge, 1 the bottom edge.

remove_layer Remove a layer

Removes a device or a text layer from the mockup. remove_device removes devices only.

ParameterTypeDescription
id *stringThe layer's id, or a name that identifies exactly one layer.

get_mockup Get the mockup

Returns the whole mockup: the canvas, the background, each device front to back, and each text layer front to back. Includes each text layer's box, line count, missing characters, overflow, breaks inside words, and whether its box extends past a canvas edge.

preview Preview the mockup

Renders the mockup as a small WebP image, so you can check it. A transparent background shows as transparent.

ParameterTypeDescription
maxSizeintegerLongest side of the preview in px (default 768).

export_mockup Export the mockup

Renders the mockup at full quality and writes it to a PNG or WebP file. The format comes from the file extension. Folders that do not exist are made, and an existing file is replaced. An export can have at most 16.7 megapixels. At an App Store or Google Play preset size (see list_presets), exports a PNG at exactly that size without transparency. A transparent background becomes white. Returns store checks as warnings for that size.

ParameterTypeDescription
path *stringOutput file, ending in .png or .webp. Absolute, ~/..., or relative to the server's working directory.
scalenumberOutput px per canvas px. The default is 2 (sharp on high-density screens), or less when 2 would make more than 16.7 megapixels.

export_store_sizes Export all store sizes

Writes the mockup at every App Store and Google Play preset size into a folder. The files are: app-store/iphone-6.9.png app-store/iphone-6.3.png app-store/iphone-6.5.png app-store/ipad-13.png google-play/phone.png google-play/tablet.png google-play/feature-graphic.png Fits a copy of the layout to each size using resize_canvas's rules. The current mockup stays unchanged. Exports PNGs without transparency. A transparent background becomes white. Replaces existing files. Returns each file's path, size, and store checks as warnings.

ParameterTypeDescription
folder *stringThe output folder: absolute, ~/..., or relative to the server's working directory. Creates missing folders.
landscapebooleantrue exports screenshot sizes in landscape with -landscape in each file name, for example iphone-6.9-landscape.png. The feature graphic stays 1024 x 500 and keeps its file name.

save_mockup Save the mockup

Saves the mockup in the project, so that `npx devicemock render` can make its images again from new screenshots, for example in CI after each deploy. The file is .devicemock/<name>.json at the project root (the folder with .git), and goes into the repo with the images. It has the scene, the source of each image (file paths, image URLs, and web page URLs with their status bar setting), and the outputs. The outputs are the files that export_mockup wrote since new_mockup or open_mockup, with their scales. Call export_mockup first. Image files and outputs must be in the project. The file has no im…

ParameterTypeDescription
namestringA name for the mockup, for example hero. Without it: the name that open_mockup or save_mockup used for this mockup, else the file name of the first export (public/hero.png gives hero).
replacebooleantrue replaces another saved mockup that has the same name. Without it, the save fails, so another mockup is not lost.

open_mockup Open a saved mockup

Opens a mockup that save_mockup saved (.devicemock/<name>.json at the project root). It replaces the current mockup. It reads each image again from its source: files are read again, and web pages are captured again. The outputs of the saved mockup stay, so save_mockup writes them back with the files that export_mockup writes after this. Returns the mockup, as get_mockup does, and its outputs.

ParameterTypeDescription
name *stringThe name of a saved mockup, for example hero.

list_projects List the projects

Lists projects and their mockups in the user's DeviceMock account by team, with the user's own team first. Each team includes own (true for the user's own team), role, plan (individual, team, or null), and canEdit (whether the user can edit that team's projects). When canEdit is false, the projects are read-only. If teams have the same name, use the team's id with the other tools. Each mockup's editorUrl opens it in the DeviceMock editor. open_from_project opens a mockup here, and save_to_project saves the current mockup to a project.

open_from_project Open a mockup from a project

Opens a mockup from a project in the user's DeviceMock account (see list_projects), including mockups made in the DeviceMock editor. The project can be in the user's own team or any team they joined. This replaces the current mockup and downloads its images. Edit it, export it with export_mockup, and save changes with save_to_project. Returns the mockup in the same format as get_mockup.

ParameterTypeDescription
mockup *stringThe name or id of the mockup in the project.
project *stringThe name or id of the project.
teamstringThe name or id of the project's team. Use it when projects in different teams have the same name. If omitted, all teams the user belongs to are searched.

save_to_project Save the mockup in a project

Saves the mockup and its images to a project in the user's DeviceMock account. The user can open it in the DeviceMock editor at editorUrl. A mockup opened with open_from_project is saved in place unless you give it another name. If no project matches the name, a new project is created in the specified team, or in the user's own team when no team is specified. The team's owner and members can open the project as their plan allows. To keep a mockup's images current with new screenshots, use save_mockup to save it in the repo.

ParameterTypeDescription
project *stringThe name or id of the project. When no project has this name, a new project with this name is made.
namestringThe name of the mockup in the project. Without it: the name of the mockup that open_from_project opened, else the name that save_mockup used, else the file name of the first export, else Untitled.
replacebooleantrue replaces another mockup of the project that has the same name. Without it, the save fails, so another mockup is not lost.
teamstringThe name or id of a team the user belongs to (see list_projects). Searches for the project in this team and creates any new project there. If omitted, all teams the user belongs to are searched, and a…