@impro.social/impro-plugin 0.0.24 → 0.0.25

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.
Files changed (3) hide show
  1. package/main.d.ts +11 -0
  2. package/main.js +17 -2
  3. package/package.json +3 -2
package/main.d.ts CHANGED
@@ -105,6 +105,8 @@ export class SimpleUUID {
105
105
  export class MenuItem {
106
106
  title: string;
107
107
  icon: string | VirtualEl | null;
108
+ /** @type {string | null} */
109
+ url: string | null;
108
110
  /** @internal */
109
111
  _callback: () => void;
110
112
  /**
@@ -120,6 +122,14 @@ export class MenuItem {
120
122
  * @returns {this}
121
123
  */
122
124
  setIcon(icon: string | VirtualEl): this;
125
+ /**
126
+ * Make the item a link that opens `url` in a new tab. The URL must match
127
+ * one of the `permissions.open` patterns in the plugin's manifest, or the
128
+ * host drops the item. Link items don't call their `onClick` handler.
129
+ * @param {string} url
130
+ * @returns {this}
131
+ */
132
+ setUrl(url: string): this;
123
133
  /**
124
134
  * Called when the user activates the item.
125
135
  * @param {() => void} callback
@@ -145,6 +155,7 @@ export class Menu {
145
155
  _serialize(): {
146
156
  title: string;
147
157
  icon: string | SerializedElement | null;
158
+ url: string | null;
148
159
  handlerId: number;
149
160
  }[];
150
161
  }
package/main.js CHANGED
@@ -170,6 +170,8 @@ export class MenuItem {
170
170
  constructor() {
171
171
  this.title = "";
172
172
  this.icon = null;
173
+ /** @type {string | null} */
174
+ this.url = null;
173
175
  /** @internal */
174
176
  this._callback = () => {};
175
177
  }
@@ -192,6 +194,17 @@ export class MenuItem {
192
194
  this.icon = icon;
193
195
  return this;
194
196
  }
197
+ /**
198
+ * Make the item a link that opens `url` in a new tab. The URL must match
199
+ * one of the `permissions.open` patterns in the plugin's manifest, or the
200
+ * host drops the item. Link items don't call their `onClick` handler.
201
+ * @param {string} url
202
+ * @returns {this}
203
+ */
204
+ setUrl(url) {
205
+ this.url = url;
206
+ return this;
207
+ }
195
208
  /**
196
209
  * Called when the user activates the item.
197
210
  * @param {() => void} callback
@@ -231,7 +244,7 @@ export class Menu {
231
244
  callHandlers.set(handlerId, item._callback);
232
245
  const icon =
233
246
  item.icon instanceof VirtualEl ? item.icon._serialize() : item.icon;
234
- return { title: item.title, icon, handlerId };
247
+ return { title: item.title, icon, url: item.url, handlerId };
235
248
  });
236
249
  }
237
250
  }
@@ -383,7 +396,9 @@ export class PluginData {
383
396
  * @returns {Promise<ListView | null>}
384
397
  */
385
398
  getList(uri) {
386
- return /** @type {Promise<ListView | null>} */ (hostCall("getList", { uri }));
399
+ return /** @type {Promise<ListView | null>} */ (
400
+ hostCall("getList", { uri })
401
+ );
387
402
  }
388
403
  /**
389
404
  * Fetch a feed generator view by AT-URI.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impro.social/impro-plugin",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "main": "main.js",
6
6
  "types": "./main.d.ts",
@@ -22,6 +22,7 @@
22
22
  ],
23
23
  "devDependencies": {
24
24
  "typedoc": "^0.28.20",
25
- "typedoc-plugin-markdown": "^4.12.0"
25
+ "typedoc-plugin-markdown": "^4.12.0",
26
+ "typescript": "^5.9.3"
26
27
  }
27
28
  }