@snaptrude/plugin-core 0.9.8 → 0.9.10

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.
@@ -10,13 +10,16 @@ import { PluginApiReturn } from "../../types"
10
10
  * Teams are **read-only** here (no create/invite/delete in v1, a deliberate
11
11
  * safety decision); there are no folders in v1. A `projectId` is the project's
12
12
  * floorkey. Plan limits are enforced by the backend — a limit rejection surfaces
13
- * as a normal host error. It also carries the workspace-level mode switch for
13
+ * as a normal host error. It also carries the workspace-level mode switches for
14
14
  * Present mode ({@linkcode PluginWorkspaceApi.openPresentMode} /
15
- * {@linkcode PluginWorkspaceApi.closePresentMode}).
15
+ * {@linkcode PluginWorkspaceApi.closePresentMode}) and Program mode
16
+ * ({@linkcode PluginWorkspaceApi.openProgramMode} /
17
+ * {@linkcode PluginWorkspaceApi.closeProgramMode}).
16
18
  *
17
19
  * - {@linkcode PluginWorkspaceApi.projects} — Create, copy, list, read & rename projects
18
20
  * - {@linkcode PluginWorkspaceApi.teams} — Read teams and their members
19
21
  * - {@linkcode PluginWorkspaceApi.openPresentMode} / {@linkcode PluginWorkspaceApi.closePresentMode} — Open/close the Present-mode documentation editor
22
+ * - {@linkcode PluginWorkspaceApi.openProgramMode} / {@linkcode PluginWorkspaceApi.closeProgramMode} — Open/close the Program tab (the spreadsheet the `program.spreadsheet.*` calls run in)
20
23
  */
21
24
  export abstract class PluginWorkspaceApi {
22
25
  /** Projects — create, copy, list, read & rename. See {@linkcode PluginWorkspaceProjectsApi}. */
@@ -68,6 +71,52 @@ export abstract class PluginWorkspaceApi {
68
71
  */
69
72
  public abstract closePresentMode(): PluginApiReturn<void>
70
73
 
74
+ /**
75
+ * Open Program mode — the Program tab the `program.spreadsheet.*` calls run in.
76
+ *
77
+ * Runs the top bar's own Program-button sequence (remember the preference,
78
+ * open or re-link the paired Program window) and resolves only once that tab
79
+ * has connected to the editor over its channel, so a `program.spreadsheet.*`
80
+ * call issued right after this resolves finds the tab open. The open happens
81
+ * outside a user gesture, so the browser may block the pop-up; the editor
82
+ * then shows its "Allow pop-up to continue" modal and this call keeps waiting
83
+ * (up to ~90s) for the user to confirm. Idempotent — resolves immediately
84
+ * when the Program tab is already connected, and is a no-op when the plugin is
85
+ * itself running in the Program tab. Write-gated.
86
+ *
87
+ * @throws `PRECONDITION_FAILED` if the user dismisses the pop-up modal or the
88
+ * Program tab does not connect within the timeout.
89
+ *
90
+ * @examplePrompt Open program mode
91
+ * @examplePrompt Open the Program tab so I can build a custom sheet
92
+ * @examplePrompt Switch to the program spreadsheet
93
+ *
94
+ * # Example
95
+ * ```ts
96
+ * await snaptrude.workspace.openProgramMode()
97
+ * const { sheets } = await snaptrude.program.spreadsheet.listSheets()
98
+ * ```
99
+ */
100
+ public abstract openProgramMode(): PluginApiReturn<void>
101
+
102
+ /**
103
+ * Close the Program tab.
104
+ *
105
+ * Idempotent — a no-op when no Program tab is connected. Write-gated, like
106
+ * {@linkcode PluginWorkspaceApi.openProgramMode}.
107
+ *
108
+ * @throws `PRECONDITION_FAILED` if the tab is still connected after ~15s.
109
+ *
110
+ * @examplePrompt Close program mode
111
+ * @examplePrompt Close the Program tab
112
+ *
113
+ * # Example
114
+ * ```ts
115
+ * await snaptrude.workspace.closeProgramMode()
116
+ * ```
117
+ */
118
+ public abstract closeProgramMode(): PluginApiReturn<void>
119
+
71
120
  constructor() {}
72
121
  }
73
122