@pi-unipi/trajectory 2.10.0 → 2.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/index.ts +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,10 @@ Live, localhost-only UniPi trajectory inspector for the current Pi session.
|
|
|
11
11
|
/unipi:trajectory toggle # open when stopped, stop when running
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
Typing `/unipi:trajectory` followed by a space auto-completes the available
|
|
15
|
+
actions (`stop`, `off`, `toggle`), so the options are discoverable without
|
|
16
|
+
reading the docs. Running it with no argument opens or reuses the server.
|
|
17
|
+
|
|
14
18
|
The command starts or reuses an in-process server on `127.0.0.1:8176-8186` and opens it in the default browser. The page follows the active session every 500 ms. The server is owned by the current Pi process and is stopped on any Pi session shutdown/reload/resume/new/fork event.
|
|
15
19
|
|
|
16
20
|
## What it shows
|
package/index.ts
CHANGED
|
@@ -18,6 +18,28 @@ export default function trajectory(pi: ExtensionAPI): void {
|
|
|
18
18
|
|
|
19
19
|
pi.registerCommand("unipi:trajectory", {
|
|
20
20
|
description: "Open or manage UniPi's live trajectory for the current session",
|
|
21
|
+
getArgumentCompletions: (argumentPrefix: string) => {
|
|
22
|
+
const prefix = argumentPrefix.trim().toLowerCase();
|
|
23
|
+
const actions = [
|
|
24
|
+
{ value: "stop", label: "stop", description: "Stop this session's trajectory server" },
|
|
25
|
+
{ value: "off", label: "off", description: "Alias of stop" },
|
|
26
|
+
{ value: "toggle", label: "toggle", description: "Open when stopped, stop when running" },
|
|
27
|
+
];
|
|
28
|
+
const matches = prefix
|
|
29
|
+
? actions.filter((a) => a.value.startsWith(prefix) || a.label.startsWith(prefix))
|
|
30
|
+
: actions;
|
|
31
|
+
// With no prefix (or a matching one) also surface a hint that running bare
|
|
32
|
+
// opens/reuses the server, so users learn the default behavior exists.
|
|
33
|
+
const items = matches.map((a) => ({ value: a.value, label: a.label, description: a.description }));
|
|
34
|
+
if (!prefix) {
|
|
35
|
+
items.unshift({
|
|
36
|
+
value: "",
|
|
37
|
+
label: "(no argument)",
|
|
38
|
+
description: "Open or reuse the trajectory server in the browser",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return items;
|
|
42
|
+
},
|
|
21
43
|
handler: async (args, ctx) => {
|
|
22
44
|
const action = String(args ?? "").trim().toLowerCase();
|
|
23
45
|
const wantsStop = ["stop", "off", "--stop", "--off"].includes(action);
|