@raycast/api 1.71.4 → 1.72.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/types/index.d.ts +83 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raycast/api",
3
- "version": "1.71.4",
3
+ "version": "1.72.0",
4
4
  "description": "Build extensions for Raycast with React and Node.js.",
5
5
  "author": "Raycast Technologies Ltd.",
6
6
  "homepage": "https://developers.raycast.com",
package/types/index.d.ts CHANGED
@@ -649,6 +649,89 @@ export declare interface ArgumentsLaunchProps {
649
649
  arguments?: Arguments;
650
650
  }
651
651
 
652
+ export declare namespace BrowserExtension {
653
+
654
+ /**
655
+ * Get the content of the active tab.
656
+ *
657
+ * @returns A Promise that resolves with the content.
658
+ *
659
+ * @example
660
+ * ```typescript
661
+ * import { BrowserExtension } from "@raycast/api";
662
+ *
663
+ * export default async () => {
664
+ * const html = await BrowserExtension.getContent({ format: "html" });
665
+ * console.log(html);
666
+ * };
667
+ * ```
668
+ */
669
+ export function getContent(options?: GetContentOptions): Promise<string>;
670
+ export type GetContentOptions = {
671
+ /**
672
+ * The format of the content.
673
+ *
674
+ * - `html`: `document.documentElement.outerHTML`
675
+ * - `text`: `document.body.innerText`
676
+ * - `markdown`: A heuristic to get the "content" of the document and convert it to markdown. Think of it as the "reader mode" of a browser.
677
+ *
678
+ * @defaultValue `html`
679
+ */
680
+ format?: "html" | "text" | "markdown";
681
+ /**
682
+ * Only returns the content of the element that matches the [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors).
683
+ *
684
+ * If the selector matches multiple elements, only the first one is returned.
685
+ * If the selector doesn't match any element, an empty string is returned.
686
+ *
687
+ * When using a CSS selector, the `format` option can not be `markdown`.
688
+ */
689
+ cssSelector?: string;
690
+ /**
691
+ * The ID of the tab to get the content from. If not specified, the content of the active tab of the focused window is returned.
692
+ */
693
+ tabId?: number;
694
+ };
695
+ export interface Tab {
696
+ /**
697
+ * The ID of the tab. Tab IDs are unique within a browser session.
698
+ */
699
+ id: number;
700
+ /**
701
+ * The URL the tab is displaying.
702
+ */
703
+ url: string;
704
+ /**
705
+ * The title of the tab. It may also be `undefined` if the tab is loading.
706
+ */
707
+ title?: string;
708
+ /**
709
+ * The URL of the tab's [favicon](https://developer.mozilla.org/en-US/docs/Glossary/Favicon). It may also be `undefined` if the tab is loading.
710
+ */
711
+ favicon?: string;
712
+ /**
713
+ * Whether the tab is active in its window.
714
+ * There can only be one active tab per window but if there are multiple browser windows, there can be multiple active tabs.
715
+ */
716
+ active: boolean;
717
+ }
718
+ /**
719
+ * Get the list of browser tabs.
720
+ * @returns A Promise that resolves with the list of tabs.
721
+ *
722
+ * @example
723
+ * ```typescript
724
+ * import { BrowserExtension } from "@raycast/api";
725
+ *
726
+ * export default async () => {
727
+ * const tabs = await BrowserExtension.getTabs();
728
+ * console.log(tabs);
729
+ * };
730
+ * ```
731
+ */
732
+ export function getTabs(): Promise<Tab[]>;
733
+ }
734
+
652
735
  /**
653
736
  * Caching abstraction that stores data on disk and supports LRU (least recently used) access.
654
737
  * Since extensions can only consume up to a max. heap memory size, the cache only maintains a lightweight index in memory