External input
Read text, URLs, files, and images passed by the OneScript action.
Import input from onescript/input to read values passed by the share-sheet action.
import { input } from "onescript/input"
for (const item of input.items) {
if (item.type === "text" || item.type === "url") {
console.log(item.value)
} else {
console.log(item.name, item.path, item.contentType)
}
}input.items is a read-only array in the order supplied by the host app. It is empty when a script runs without external input.
File and image items contain a temporary local path. Scripts can read these paths with node:fs. The temporary files are removed when execution finishes.
Action entry
The OneScript share-sheet action runs the same App entry as project cards on Home: entries.app in config.json at the project root, which refers to a script in package.json. Change it in the project's More Settings, or edit the file directly.
{
"entries": {
"app": "app"
}
}When no App entry is configured, OneScript uses package.main, then index.js, then index.ts. If the configured script isn't in package.json, or its file doesn't exist, the action reports an error instead of falling back.
OneScript registers one share-sheet action. Opening it displays the current projects, so projects created or renamed in the app appear without registering another extension.
How is this guide?
Last updated on