Lolly
Lancarkan Aplikasi
  1. Automasi
  2. Cipta alat dan sistem reka bentuk

Assets and file utilities

An asset input lets people pick logos, photos and other brand imagery from the design system's library or their own uploads. A file input takes a person's own file into memory so a utility, such as a converter or a metadata stripper, can transform the bytes and hand them back.

asset - library or device upload

An asset input opens the host's asset picker and stores the chosen AssetRef, in the same form whether the asset came from the catalog or the person's device:

{
  "id": "logo",
  "type": "asset",
  "label": "Logo",
  "assetType": "image",    // vector | raster | image | video | audio | lottie | model | any - constrains the picker
  "allowUpload": true       // also let the user add an image from their device
}

assetType decides what the picker offers:

assetTypeThe picker offers
imageAny still image, raster or vector. The right choice for a picture slot, because people can also pick or upload SVGs.
rasterBitmaps only.
vectorSVG only, for logos you recolour inline.
video, audio, lottieThat kind of media; audiogram takes audio.
model3D models, as in 3d-studio.
anyEverything, including assets that are not images.

filter narrows the picker further: { "tags": [...], "namespace": "..." } is passed to host.assets.query().

Pictures the tool ships. An asset value, such as one an example look sets, can also name a picture in the tool's own assets/ folder by its served path: /tools/<tool-id>/assets/<file>. The file must sit directly in that folder and end in .svg, .png, .jpg or .webp. The web shell reads the file through its verified catalog fetch, and the CLI, the TUI and the MCP server read the file from the tool's folder. Example looks shows the value to write.

The Image row in the Filter tool - a thumbnail slot and a Choose asset button that opens the host's picker, with nothing about pickers in the manifest signed by Lollyvector SVG10 paths718 nodes18 groups13 KBCheck it yourselfDapatkan fail yang ditandatanganiThe Image row in the Filter tool - a thumbnail slot and a Choose asset button that opens the host's picker, with nothing about pickers in the manifest signed by Lollyvector SVG10 paths718 nodes18 groups13 KBCheck it yourselfDapatkan fail yang ditandatangani

Uploads from the person's device

With allowUpload: true, the picker offers the person's image library beside the catalog. The host stores uploaded bytes exactly as they arrived, because a silent re-encode would break a Content Credential's hard binding. The host offers to downscale only a very large file. Stripping metadata is a separate opt-in preference (Strip metadata from uploads, off by default).

The library has no limit on the number of images. The only limit is the device's storage, checked before each write. Every tool shares the library, and people manage the library in Settings → Storage → My images. SVG uploads are cleaned of scripts and event handlers on upload and stay vector.

These images stay on the device. Their AssetRef.source is "user", and their user/… id means something only on the device that holds the bytes, so they are left out of share links (URL Mode). Tools treat user and library assets the same, and no tool code takes part in the upload.

Every asset input also accepts a Lolly tool link pasted into the picker's search box: a share link copied from another tool (…/#/tool/qr-code?url=…) or an embed URL (…/tool/qr-code.svg?…). The person picks the render format and size, and the host renders that tool through host.compose and places the result in the slot. This is the person's counterpart to an authored composes. It needs no manifest declaration and works in every tool's image inputs.

The picker offers SVG and bitmap render formats for any image slot. SVG is the default: it stays crisp, goes into SVG and PDF exports as vector and rasterises cleanly for PNG. A vector slot offers SVG only. The asset's identity is the canonical embed URL, so the asset is kept in saved sessions and share links and renders again on load, like a library id. The picker accepts tool links wherever the shell can compose. The compose capability gates only authored composes.

file - the user's own file (on-device utilities)

A file input reads a file the person picks into memory and hands its raw bytes to the tool. Use it for content-transform utilities: strip metadata, crop, compress, convert.

Nota: Nothing is stored or uploaded

A file value lives only in memory on the device. It is never written into a link, never saved with a session and never uploaded. The rules below keep that privacy promise of an on-device utility.

With layout: "canvas" (layouts), a single file input becomes the working area, as in the drop zone strip-data opens with.

Lolly Strip Hidden Data's canvas - a drag-and-drop file zone with a Choose a file button and the note that nothing is uploaded signed by Lollyvector SVG9 paths~7.7k nodes10 groups87 KBCheck it yourselfDapatkan fail yang ditandatanganiLolly Strip Hidden Data's canvas - a drag-and-drop file zone with a Choose a file button and the note that nothing is uploaded signed by Lollyvector SVG9 paths~7.7k nodes10 groups87 KBCheck it yourselfDapatkan fail yang ditandatangani

{
  "id": "photo",
  "type": "file",
  "label": "Photo",
  "accept": ["image/jpeg", "image/png", ".jpg", ".png"],
  "maxSize": 52428800
}

The value is a FileRef: { __file: true, name, mime, size, bytes, url }. bytes is a Uint8Array the hook reads directly, with no host. call, because the portable host. surface has no file-read API. On the CLI a file parameter is a path the runner loads: --photo=./pic.jpg.

Producing output: the exportFile hook + privacy: "on-device"

A content-transform utility does not draw the canvas into an image. It produces a transformed file:

  • The person drops or picks a file. The bytes arrive in the file input's value, in memory.
  • Your exportFile hook transforms the bytes. It returns the new bytes, a MIME type and a file name.
  • The shell delivers the result. It wraps the bytes and hands them to host.export.file: a download on the web, the --output path on the CLI.

Declare the exportFile hook and mark the tool as an on-device utility:

{
  "status": "official",
  "privacy": "on-device",
  "render": { "width": 760, "height": 620, "formats": ["jpg"], "export": false, "actions": [] },
  "hooks": { "onInput": true, "exportFile": true }
}
function exportFile({ model }) {
  const inputs = Object.fromEntries(model.map(i => [i.id, i.value]));
  const f = inputs.photo;                       // the FileRef
  const cleaned = stripMetadata(f.bytes);       // your transform (pure bytes → bytes)
  return { bytes: cleaned, mime: f.mime, filename: f.name.replace(/(\.\w+)?$/, '-clean$1') };
}

In the template, a <button data-export-file>Download…</button> runs the hook. Use onInit and onInput to return extras the template shows, such as the metadata that was found. strip-data is the reference.