@qping/plugin-bus 0.3.0 → 0.4.0

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/dist/actions.d.ts CHANGED
@@ -152,26 +152,44 @@ export type DetailRequest = {
152
152
  title?: string;
153
153
  initialState?: unknown;
154
154
  };
155
- /**
156
- * The result of running an action. Every field is optional and they combine: opening an IDE and
157
- * closing the search window is `{ host: {...}, close: true }`.
158
- */
159
- export type ActionOutcome = {
160
- /** Run a host-side action (clipboard, process launch, browser, ...). */
161
- host?: HostActionRequest;
162
- /** Hand off to the detail page; arrives as `host.event.detailAction` with this payload. */
163
- web?: {
164
- payload?: unknown;
165
- };
166
- /** Open a web detail page. */
167
- detail?: DetailRequest;
155
+ export type ActionTarget =
156
+ /** Run one privileged host-side action (clipboard, process launch, browser, ...). */
157
+ {
158
+ kind: "host";
159
+ action: HostActionRequest;
160
+ }
161
+ /** Hand off to the currently active detail page as host.event.detailAction. */
162
+ | {
163
+ kind: "web";
164
+ payload?: unknown;
165
+ }
166
+ /** Open a new web detail page. */
167
+ | ({
168
+ kind: "detail";
169
+ } & DetailRequest);
170
+ export type ActionAfter = "keep" | "close" | "refresh";
171
+ type ActionOutcomeBase = {
168
172
  /** Status bar text. */
169
173
  message?: LocalizedText;
170
- /** Close the search window afterwards. Defaults to false. */
171
- close?: boolean;
172
- /** Refresh the current search results afterwards. Defaults to false. */
173
- refresh?: boolean;
174
174
  };
175
+ /**
176
+ * The result of running an action. An action selects at most one execution target. Host targets
177
+ * may choose a follow-up lifecycle action; web and detail targets keep their current surface alive.
178
+ */
179
+ export type ActionOutcome = ActionOutcomeBase & ({
180
+ target?: undefined;
181
+ after?: ActionAfter;
182
+ } | {
183
+ target: Extract<ActionTarget, {
184
+ kind: "host";
185
+ }>;
186
+ after?: ActionAfter;
187
+ } | {
188
+ target: Exclude<ActionTarget, {
189
+ kind: "host";
190
+ }>;
191
+ after?: "keep";
192
+ });
175
193
  /**
176
194
  * What an action sees when it runs. `item` is the original object returned by `search()`,
177
195
  * including fields the host never saw — the SDK keeps it so actions do not have to re-derive
@@ -202,3 +220,4 @@ export type ActionManifestEntry = {
202
220
  hotkey?: Hotkey;
203
221
  };
204
222
  export declare function toActionManifest(definition: ActionDefinition): ActionManifestEntry;
223
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qping/plugin-bus",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "v3 message-bus runtime for MyTools plugins (named-pipe transport).",
5
5
  "type": "module",
6
6
  "files": [
@@ -28,17 +28,17 @@
28
28
  "import": "./dist/webClient.mjs",
29
29
  "default": "./dist/webClient.mjs"
30
30
  },
31
- "./i18n": {
32
- "types": "./dist/i18n.d.ts",
33
- "import": "./dist/i18n.mjs",
34
- "default": "./dist/i18n.mjs"
35
- },
36
- "./search": {
37
- "types": "./dist/search.d.ts",
38
- "import": "./dist/search.mjs",
39
- "default": "./dist/search.mjs"
40
- },
41
- "./dev": {
31
+ "./i18n": {
32
+ "types": "./dist/i18n.d.ts",
33
+ "import": "./dist/i18n.mjs",
34
+ "default": "./dist/i18n.mjs"
35
+ },
36
+ "./search": {
37
+ "types": "./dist/search.d.ts",
38
+ "import": "./dist/search.mjs",
39
+ "default": "./dist/search.mjs"
40
+ },
41
+ "./dev": {
42
42
  "types": "./dist/dev.d.ts",
43
43
  "import": "./dist/dev.mjs",
44
44
  "default": "./dist/dev.mjs"
package/src/actions.ts CHANGED
@@ -89,31 +89,37 @@ export type HostActionRequest =
89
89
  | { kind: typeof HostAction.Run; command: RunSpec }
90
90
  | { kind: typeof HostAction.Kill; pid: number };
91
91
 
92
- /** Opens a web detail page. `page` defaults to the entry declared in plugin.json. */
93
- export type DetailRequest = {
94
- page?: string;
95
- title?: string;
96
- initialState?: unknown;
97
- };
98
-
99
- /**
100
- * The result of running an action. Every field is optional and they combine: opening an IDE and
101
- * closing the search window is `{ host: {...}, close: true }`.
102
- */
103
- export type ActionOutcome = {
104
- /** Run a host-side action (clipboard, process launch, browser, ...). */
105
- host?: HostActionRequest;
106
- /** Hand off to the detail page; arrives as `host.event.detailAction` with this payload. */
107
- web?: { payload?: unknown };
108
- /** Open a web detail page. */
109
- detail?: DetailRequest;
110
- /** Status bar text. */
111
- message?: LocalizedText;
112
- /** Close the search window afterwards. Defaults to false. */
113
- close?: boolean;
114
- /** Refresh the current search results afterwards. Defaults to false. */
115
- refresh?: boolean;
92
+ /** Opens a web detail page. `page` defaults to the entry declared in plugin.json. */
93
+ export type DetailRequest = {
94
+ page?: string;
95
+ title?: string;
96
+ initialState?: unknown;
97
+ };
98
+
99
+ export type ActionTarget =
100
+ /** Run one privileged host-side action (clipboard, process launch, browser, ...). */
101
+ | { kind: "host"; action: HostActionRequest }
102
+ /** Hand off to the currently active detail page as host.event.detailAction. */
103
+ | { kind: "web"; payload?: unknown }
104
+ /** Open a new web detail page. */
105
+ | ({ kind: "detail" } & DetailRequest);
106
+
107
+ export type ActionAfter = "keep" | "close" | "refresh";
108
+
109
+ type ActionOutcomeBase = {
110
+ /** Status bar text. */
111
+ message?: LocalizedText;
116
112
  };
113
+
114
+ /**
115
+ * The result of running an action. An action selects at most one execution target. Host targets
116
+ * may choose a follow-up lifecycle action; web and detail targets keep their current surface alive.
117
+ */
118
+ export type ActionOutcome = ActionOutcomeBase & (
119
+ | { target?: undefined; after?: ActionAfter }
120
+ | { target: Extract<ActionTarget, { kind: "host" }>; after?: ActionAfter }
121
+ | { target: Exclude<ActionTarget, { kind: "host" }>; after?: "keep" }
122
+ );
117
123
 
118
124
  /**
119
125
  * What an action sees when it runs. `item` is the original object returned by `search()`,