pin
import pins from "fullstacked/pin";Pins projects on the device: their own icon, which opens them in FullStacked (see Pin a project), and reads open links. The shell's pin command and FullStacked Cloud both use it.
pin(link: string, options?: { name?: string; icon?: string | Uint8Array }): Promise<{ pin: Pin; message: string }>
unpin(linkOrProject: string): Promise<Pin>
list(): Promise<Pin[]>
resolve(link: string): Promise<Resolved>
open(link: string, options?: { execute?: (argv: string[]) => Promise<number> }): Promise<OpenResult>
runLink(link: string, directory: string, env?: Record<string, string>): Promise<{ ctx: number; resumed: boolean }>
parseOpenLink(link: string): OpenLink | null // { action: "open" | "run", project, query }
linkFor(project: string, query?: string, action?: "open" | "run"): stringpin
const { pin, message } = await pins.pin(
"fullstacked://open/dock-returns?dock=3",
{
name: "Dock returns",
icon: "./app-icon.png"
}
);
console.log(message); // what the device did, e.g. the steps to finish it on iOSAdds link to the device's pinned list and asks the host to create its launcher. A pin is its project and params, in any order: pinning the same link again replaces its pin (an open link replaces the run link of the same project and params, and the other way round), a link with other params adds another pin of the project.
name: the label. Default: the project's directory name. One line, 100 characters at most.icon: a square PNG, its path (relative to the working directory) or its bytes, 512×512 or larger (256×256 at least). Default: a monogram of the name.
It rejects a link that isn't an open link, a project that doesn't exist or isn't in this context's root, an invalid icon, and a host without launchers (the Node CLI): then nothing stays pinned.
unpin, list
unpin takes the pin's link, or its project ("dock-returns") when the project has one pin, removes it from the list and asks the host to remove its launcher where the OS lets it. list returns the pins of the projects in this context's root or under it, by name.
type Pin = {
key: string; // the pin's folder, stable for a project
project: string; // relative to the projects root, as in the link
directory: string; // relative to this context's root, for run ("/dock-returns")
link: string;
name: string;
icons: {
png: Record<number, string>;
adaptive: string;
ico: string;
icns: string;
}; // absolute paths
updated: number; // unix milliseconds
};resolve
type Resolved = {
action: "open" | "run"; // how the link starts its project
project: string;
query: string;
directory: string; // "" when the project isn't in this context's root
exists: boolean;
pin: Pin | null; // the link's own, else one of its project's (the one without params first)
};open
Opens a link the way the shell does, for a context that stands in for it (FullStacked Cloud in the shell's place):
| Result | When |
|---|---|
{ action: "ran", code } |
The project is pinned: the link's command ran, fullstacked -l <link> <directory> for an open link, run -l <link> <directory> for a run link (through execute, its argv command first; default the runtime's execute, or runLink). A project that runs already isn't started again: its window is focused and the link is handed to it |
{ action: "prompt", command } |
Anything else: a command to propose, never run |
{ action: "ignored" } |
Not an open link |
runLink
What run -l <link> <directory> does: runs the project as built, without a build, opens its window and hands it the link once its deeplink plugin registers. A pinned project that runs already is brought to the front and gets the link instead (resumed: true).
The link only reaches the target project. An open link from the OS opens a new shell window and reaches it alone (see plugin).
Where pins live
<projects>/.git/fullstacked/pins/<key>/: pin.json and the icon in every size the hosts use (icon-16.png to icon-1024.png, adaptive.png for Android, icon.ico, icon.icns), made by the core from the PNG you give.