@vicinae/api 0.13.2 → 0.13.4

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.
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActionPanel = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const image_1 = require("../image");
6
5
  const ActionPanelRoot = (props) => {
7
6
  const nativeProps = props;
8
7
  return (0, jsx_runtime_1.jsx)("action-panel", { ...nativeProps });
@@ -13,11 +12,8 @@ const ActionPanelSection = (props) => {
13
12
  };
14
13
  return ((0, jsx_runtime_1.jsx)("action-panel-section", { ...nativeProps, children: props.children }));
15
14
  };
16
- const ActionPannelSubmenu = ({ icon, children, onOpen, onSearchTextChange, ...props }) => {
17
- const nativeProps = props;
18
- if (icon)
19
- nativeProps.icon = (0, image_1.serializeImageLike)(icon);
20
- return ((0, jsx_runtime_1.jsx)("action-panel-submenu", { ...nativeProps, children: children }));
15
+ const ActionPannelSubmenu = ({ children, ...props }) => {
16
+ return ((0, jsx_runtime_1.jsx)("action-panel-submenu", { ...props, children: children }));
21
17
  };
22
18
  exports.ActionPanel = Object.assign(ActionPanelRoot, {
23
19
  Section: ActionPanelSection,
@@ -4,18 +4,11 @@ exports.Action = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const index_1 = require("../hooks/index");
6
6
  const clipboard_1 = require("../clipboard");
7
- const image_1 = require("../image");
8
7
  const utils_1 = require("../utils");
9
8
  const icon_1 = require("../icon");
10
9
  const controls_1 = require("../controls");
11
- const ActionRoot = ({ icon, ...props }) => {
12
- const nativeProps = {
13
- ...props,
14
- };
15
- if (icon) {
16
- nativeProps.icon = (0, image_1.serializeImageLike)(icon);
17
- }
18
- return (0, jsx_runtime_1.jsx)("action", { ...nativeProps });
10
+ const ActionRoot = (props) => {
11
+ return (0, jsx_runtime_1.jsx)("action", { ...props });
19
12
  };
20
13
  const CopyToClipboard = ({ title = "Copy to clipboard", icon = icon_1.Icon.CopyClipboard, content, concealed = false, onCopy, ...props }) => {
21
14
  return ((0, jsx_runtime_1.jsx)(ActionRoot, { title: title, ...props, icon: icon_1.Icon.CopyClipboard, onAction: async () => {
@@ -48,15 +41,12 @@ const Push = ({ target, ...props }) => {
48
41
  push(target);
49
42
  } }));
50
43
  };
51
- const SubmitForm = ({ icon, title = "Submit", ...props }) => {
44
+ const SubmitForm = ({ title = "Submit", ...props }) => {
52
45
  const nativeProps = {
53
46
  ...props,
54
47
  title,
55
48
  onAction: () => { }
56
49
  };
57
- if (icon) {
58
- nativeProps.icon = (0, image_1.serializeImageLike)(icon);
59
- }
60
50
  return (0, jsx_runtime_1.jsx)("action", { ...nativeProps });
61
51
  };
62
52
  exports.Action = Object.assign(ActionRoot, {
@@ -2,12 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Dropdown = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const image_1 = require("../image");
6
5
  const DropdownRoot = ({ children, ...props }) => {
7
6
  return ((0, jsx_runtime_1.jsx)("dropdown", { ...props, children: children }));
8
7
  };
9
8
  const Item = ({ title, value, icon }) => {
10
- return ((0, jsx_runtime_1.jsx)("dropdown-item", { title: title, value: value, icon: icon ? (0, image_1.serializeImageLike)(icon) : undefined }));
9
+ return ((0, jsx_runtime_1.jsx)("dropdown-item", { title: title, value: value, icon: icon }));
11
10
  };
12
11
  const Section = ({ title, children }) => {
13
12
  return (0, jsx_runtime_1.jsx)("dropdown-section", { title: title, children: children });
@@ -2,11 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EmptyView = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const image_1 = require("../image");
6
- const EmptyView = ({ icon, actions, ...props }) => {
7
- const nativeProps = props;
8
- if (icon)
9
- nativeProps.icon = (0, image_1.serializeImageLike)(icon);
10
- return (0, jsx_runtime_1.jsx)("empty-view", { ...nativeProps, children: actions });
5
+ const EmptyView = ({ actions, ...props }) => {
6
+ return (0, jsx_runtime_1.jsx)("empty-view", { ...props, children: actions });
11
7
  };
12
8
  exports.EmptyView = EmptyView;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Form = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const use_imperative_form_handle_1 = require("../hooks/use-imperative-form-handle");
6
- const image_1 = require("../image");
7
6
  const dropdown_1 = require("./dropdown");
8
7
  const wrapFormItemProps = (props) => {
9
8
  // TODO: pass the current value in the event
@@ -46,7 +45,7 @@ const TagPickerRoot = ({ children, ...props }) => {
46
45
  return ((0, jsx_runtime_1.jsx)("tag-picker-field", { ...wrapFormItemProps(props), children: children }));
47
46
  };
48
47
  const TagPickerItem = ({ icon, ...props }) => {
49
- return (0, jsx_runtime_1.jsx)("tag-picker-item", { ...props, icon: icon && (0, image_1.serializeImageLike)(icon) });
48
+ return (0, jsx_runtime_1.jsx)("tag-picker-item", { ...props, icon: icon });
50
49
  };
51
50
  const TagPicker = Object.assign(TagPickerRoot, {
52
51
  Item: TagPickerItem
@@ -6,25 +6,44 @@ declare enum GridInset {
6
6
  Medium = "medium",
7
7
  Large = "large"
8
8
  }
9
- type SectionConfig = {
10
- inset?: GridInset;
11
- columns?: number;
12
- fit?: GridFit;
13
- aspectRatio?: Grid.AspectRatio;
14
- };
15
9
  declare enum GridFit {
16
10
  Contain = "contain",
17
11
  Fill = "fill"
18
12
  }
19
13
  export declare namespace Grid {
20
- namespace Section {
21
- type Props = GridSectionProps;
14
+ type BaseSection = {
15
+ inset?: GridInset;
16
+ columns?: number;
17
+ fit?: GridFit;
18
+ aspectRatio?: Grid.AspectRatio;
19
+ };
20
+ export type Props = BaseSection & {
21
+ actions?: React.ReactNode;
22
+ children?: React.ReactNode;
23
+ filtering?: boolean;
24
+ /**
25
+ * @deprecated use filtering
26
+ */
27
+ enableFiltering?: boolean;
28
+ isLoading?: boolean;
29
+ searchText?: string;
30
+ searchBarPlaceholder?: string;
31
+ navigationTitle?: string;
32
+ searchBarAccessory?: ReactNode;
33
+ onSearchTextChange?: (text: string) => void;
34
+ onSelectionChange?: (id: string) => void;
35
+ };
36
+ export namespace Section {
37
+ type Props = BaseSection & {
38
+ title?: string;
39
+ subtitle?: string;
40
+ children?: ReactNode;
41
+ };
22
42
  }
23
- type Fit = GridFit;
24
- type Props = GridProps;
25
- type Inset = GridInset;
26
- type AspectRatio = "1" | "3/2" | "2/3" | "4/3" | "3/4" | "16/9" | "9/16" | '21/9' | '9/21' | '32/9' | '9/32';
27
- namespace Item {
43
+ export type Fit = GridFit;
44
+ export type Inset = GridInset;
45
+ export type AspectRatio = "1" | "3/2" | "2/3" | "4/3" | "3/4" | "16/9" | "9/16" | '21/9' | '9/21' | '32/9' | '9/32';
46
+ export namespace Item {
28
47
  export type Props = {
29
48
  title?: string;
30
49
  detail?: React.ReactNode;
@@ -59,31 +78,10 @@ export declare namespace Grid {
59
78
  };
60
79
  export {};
61
80
  }
81
+ export {};
62
82
  }
63
- type GridProps = SectionConfig & {
64
- actions?: React.ReactNode;
65
- children?: React.ReactNode;
66
- filtering?: boolean;
67
- /**
68
- * @deprecated use filtering
69
- */
70
- enableFiltering?: boolean;
71
- isLoading?: boolean;
72
- searchText?: string;
73
- searchBarPlaceholder?: string;
74
- navigationTitle?: string;
75
- searchBarAccessory?: ReactNode;
76
- onSearchTextChange?: (text: string) => void;
77
- onSelectionChange?: (id: string) => void;
78
- };
79
- type GridSectionProps = SectionConfig & {
80
- title?: string;
81
- subtitle?: string;
82
- children?: ReactNode;
83
- };
84
- export declare const GridAccessory: React.FC<Grid.Item.Accessory>;
85
- export declare const Grid: React.FC<GridProps> & {
86
- Section: React.FC<GridSectionProps>;
83
+ export declare const Grid: React.FC<Grid.Props> & {
84
+ Section: React.FC<Grid.Section.Props>;
87
85
  EmptyView: React.FC<import("./empty-view").EmptyViewProps>;
88
86
  Dropdown: React.FC<{
89
87
  tooltip?: string;
@@ -112,8 +110,6 @@ export declare const Grid: React.FC<GridProps> & {
112
110
  };
113
111
  Fit: typeof GridFit;
114
112
  Inset: typeof GridInset;
115
- Item: React.FC<Grid.Item.Props> & {
116
- Accessory: React.FC<Grid.Item.Accessory>;
117
- };
113
+ Item: React.FC<Grid.Item.Props>;
118
114
  };
119
115
  export {};
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Grid = exports.GridAccessory = void 0;
3
+ exports.Grid = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const image_1 = require("../image");
7
6
  const crypto_1 = require("crypto");
8
7
  const empty_view_1 = require("./empty-view");
9
8
  const dropdown_1 = require("./dropdown");
@@ -38,33 +37,9 @@ const GridRoot = ({ searchBarAccessory, children, actions, inset, fit = GridFit.
38
37
  }
39
38
  return ((0, jsx_runtime_1.jsxs)("grid", { fit: fit, inset: inset, aspectRatio: aspectRatioMap[aspectRatio], ...props, children: [searchBarAccessory, children, actions] }));
40
39
  };
41
- const GridItem = ({ detail, actions, keywords, ...props }) => {
40
+ const GridItem = ({ detail, actions, ...props }) => {
42
41
  const id = (0, react_1.useRef)(props.id ?? (0, crypto_1.randomUUID)());
43
- const nativeProps = {
44
- title: props.title,
45
- subtitle: props.subtitle,
46
- id: id.current,
47
- keywords,
48
- };
49
- const isColor = (content) => {
50
- return !!content["color"];
51
- };
52
- const isDataWithTooltip = (content) => {
53
- return !!content["value"];
54
- };
55
- if (isColor(props.content)) {
56
- nativeProps.content = { color: props.content.color };
57
- }
58
- else if (isDataWithTooltip(props.content)) {
59
- nativeProps.content = {
60
- value: (0, image_1.serializeImageLike)(props.content.value),
61
- tooltip: props.content.tooltip,
62
- };
63
- }
64
- else {
65
- nativeProps.content = (0, image_1.serializeImageLike)(props.content);
66
- }
67
- return ((0, jsx_runtime_1.jsxs)("grid-item", { ...nativeProps, children: [detail, actions] }));
42
+ return ((0, jsx_runtime_1.jsxs)("grid-item", { ...props, id: id.current, children: [detail, actions] }));
68
43
  };
69
44
  const GridSection = ({ fit, aspectRatio, inset, ...props }) => {
70
45
  const nativeProps = {
@@ -75,17 +50,11 @@ const GridSection = ({ fit, aspectRatio, inset, ...props }) => {
75
50
  };
76
51
  return (0, jsx_runtime_1.jsx)("grid-section", { ...nativeProps });
77
52
  };
78
- const GridAccessory = (props) => {
79
- return (0, jsx_runtime_1.jsx)("list-accessory", {});
80
- };
81
- exports.GridAccessory = GridAccessory;
82
53
  exports.Grid = Object.assign(GridRoot, {
83
54
  Section: GridSection,
84
55
  EmptyView: empty_view_1.EmptyView,
85
56
  Dropdown: dropdown_1.Dropdown,
86
57
  Fit: GridFit,
87
58
  Inset: GridInset,
88
- Item: Object.assign(GridItem, {
89
- Accessory: exports.GridAccessory,
90
- }),
59
+ Item: Object.assign(GridItem, {}),
91
60
  });
@@ -2,13 +2,54 @@ import React, { ReactNode } from "react";
2
2
  import { Image, ImageLike } from "../image";
3
3
  import { Color, ColorLike } from "../color";
4
4
  export declare namespace List {
5
+ type Props = {
6
+ actions?: React.ReactNode;
7
+ children?: React.ReactNode;
8
+ filtering?: boolean;
9
+ /**
10
+ * @deprecated use filtering
11
+ */
12
+ enableFiltering?: boolean;
13
+ isLoading?: boolean;
14
+ isShowingDetail?: boolean;
15
+ searchText?: string;
16
+ searchBarPlaceholder?: string;
17
+ navigationTitle?: string;
18
+ searchBarAccessory?: ReactNode;
19
+ onSearchTextChange?: (text: string) => void;
20
+ onSelectionChange?: (id: string) => void;
21
+ };
22
+ namespace Section {
23
+ type Props = {
24
+ title?: string;
25
+ subtitle?: string;
26
+ children?: ReactNode;
27
+ };
28
+ }
5
29
  namespace Item {
6
- type Props = ListItemProps;
7
- type Tag = string | Date | undefined | null | {
30
+ type Props = {
31
+ title: string;
32
+ keywords?: string[];
33
+ detail?: React.ReactNode;
34
+ icon?: ImageLike;
35
+ id?: string;
36
+ subtitle?: string;
37
+ actions?: ReactNode;
38
+ accessories?: List.Item.Accessory[];
39
+ };
40
+ namespace Detail {
41
+ type Props = {
42
+ isLoading?: boolean;
43
+ markdown?: string;
44
+ metadata?: React.ReactNode;
45
+ };
46
+ }
47
+ type AccessoryBase = string | Date | undefined | null;
48
+ type Tag = AccessoryBase | {
8
49
  color: ColorLike;
9
50
  value: string | Date | undefined | null;
10
51
  };
11
- type Text = string | Date | undefined | null | {
52
+ type Text = AccessoryBase | {
12
53
  color: Color;
13
54
  value: string | Date | undefined | null;
14
55
  };
@@ -22,46 +63,8 @@ export declare namespace List {
22
63
  };
23
64
  }
24
65
  }
25
- type ListProps = {
26
- actions?: React.ReactNode;
27
- children?: React.ReactNode;
28
- filtering?: boolean;
29
- /**
30
- * @deprecated use filtering
31
- */
32
- enableFiltering?: boolean;
33
- isLoading?: boolean;
34
- isShowingDetail?: boolean;
35
- searchText?: string;
36
- searchBarPlaceholder?: string;
37
- navigationTitle?: string;
38
- searchBarAccessory?: ReactNode;
39
- onSearchTextChange?: (text: string) => void;
40
- onSelectionChange?: (id: string) => void;
41
- };
42
- export type ListItemProps = {
43
- title: string;
44
- keywords?: string[];
45
- detail?: React.ReactNode;
46
- icon?: ImageLike;
47
- id?: string;
48
- subtitle?: string;
49
- actions?: ReactNode;
50
- accessories?: List.Item.Accessory[];
51
- };
52
- export type ListItemDetailProps = {
53
- isLoading?: boolean;
54
- markdown?: string;
55
- metadata?: React.ReactNode;
56
- };
57
- type ListSectionProps = {
58
- title?: string;
59
- subtitle?: string;
60
- children?: ReactNode;
61
- };
62
- export declare const ListAccessory: React.FC<List.Item.Accessory>;
63
- export declare const List: React.FC<ListProps> & {
64
- Section: React.FC<ListSectionProps>;
66
+ export declare const List: React.FC<List.Props> & {
67
+ Section: React.FC<List.Section.Props>;
65
68
  EmptyView: React.FC<import("./empty-view").EmptyViewProps>;
66
69
  Dropdown: React.FC<{
67
70
  tooltip?: string;
@@ -88,8 +91,8 @@ export declare const List: React.FC<ListProps> & {
88
91
  children?: ReactNode;
89
92
  }>;
90
93
  };
91
- Item: React.FC<ListItemProps> & {
92
- Detail: React.FC<ListItemDetailProps> & {
94
+ Item: React.FC<List.Item.Props> & {
95
+ Detail: React.FC<List.Item.Detail.Props> & {
93
96
  Metadata: React.FC<import("./metadata").MetadataProps> & {
94
97
  Label: React.FC<import("./metadata").ListItemDetailMetadataLabelProps>;
95
98
  Separator: React.FC<{}>;
@@ -103,7 +106,5 @@ export declare const List: React.FC<ListProps> & {
103
106
  }>;
104
107
  };
105
108
  };
106
- Accessory: React.FC<List.Item.Accessory>;
107
109
  };
108
110
  };
109
- export {};
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.List = exports.ListAccessory = void 0;
3
+ exports.List = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const image_1 = require("../image");
7
6
  const crypto_1 = require("crypto");
8
7
  const metadata_1 = require("./metadata");
9
8
  const empty_view_1 = require("./empty-view");
@@ -17,26 +16,14 @@ const ListRoot = ({ searchBarAccessory, children, actions, ...props }) => {
17
16
  };
18
17
  const ListItem = ({ detail, actions, ...props }) => {
19
18
  const id = (0, react_1.useRef)(props.id ?? (0, crypto_1.randomUUID)());
20
- const nativeProps = {
21
- title: props.title,
22
- subtitle: props.subtitle,
23
- id: id.current,
24
- };
25
- if (props.icon)
26
- nativeProps.icon = (0, image_1.serializeImageLike)(props.icon);
27
- return ((0, jsx_runtime_1.jsxs)("list-item", { ...nativeProps, children: [detail, actions] }));
19
+ return ((0, jsx_runtime_1.jsxs)("list-item", { ...props, id: id.current, children: [detail, actions] }));
28
20
  };
29
21
  const ListItemDetail = ({ metadata, ...props }) => {
30
22
  return (0, jsx_runtime_1.jsx)("list-item-detail", { ...props, children: metadata });
31
23
  };
32
24
  const ListSection = (props) => {
33
- const nativeProps = props;
34
- return (0, jsx_runtime_1.jsx)("list-section", { ...nativeProps });
25
+ return (0, jsx_runtime_1.jsx)("list-section", { ...props });
35
26
  };
36
- const ListAccessory = (props) => {
37
- return (0, jsx_runtime_1.jsx)("list-accessory", {});
38
- };
39
- exports.ListAccessory = ListAccessory;
40
27
  exports.List = Object.assign(ListRoot, {
41
28
  Section: ListSection,
42
29
  EmptyView: empty_view_1.EmptyView,
@@ -45,6 +32,5 @@ exports.List = Object.assign(ListRoot, {
45
32
  Detail: Object.assign(ListItemDetail, {
46
33
  Metadata: metadata_1.Metadata,
47
34
  }),
48
- Accessory: exports.ListAccessory,
49
35
  }),
50
36
  });
@@ -2,15 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Metadata = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const image_1 = require("../image");
6
5
  const tag_1 = require("./tag");
7
6
  const MetadataRoot = (props) => {
8
7
  return (0, jsx_runtime_1.jsx)("metadata", { ...props });
9
8
  };
10
- const MetadataLabel = ({ icon, ...props }) => {
11
- const nativeProps = props;
12
- if (icon)
13
- nativeProps.icon = (0, image_1.serializeImageLike)(icon);
9
+ const MetadataLabel = (props) => {
14
10
  return (0, jsx_runtime_1.jsx)("metadata-label", { ...props });
15
11
  };
16
12
  const MetadataSeparator = () => {
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TagList = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const image_1 = require("../image");
6
5
  const color_1 = require("../color");
7
6
  const TagListRoot = ({ title, children }) => {
8
7
  const nativeProps = {
@@ -11,15 +10,12 @@ const TagListRoot = ({ title, children }) => {
11
10
  };
12
11
  return (0, jsx_runtime_1.jsx)("tag-list", { ...nativeProps });
13
12
  };
14
- const TagItem = ({ color, icon, text, ...props }) => {
13
+ const TagItem = ({ color, ...props }) => {
15
14
  const nativeProps = {
16
15
  ...props,
17
- text,
18
16
  };
19
17
  if (color)
20
18
  nativeProps.color = (0, color_1.serializeColorLike)(color);
21
- if (icon)
22
- nativeProps.icon = (0, image_1.serializeImageLike)(icon);
23
19
  return (0, jsx_runtime_1.jsx)("tag-item", { ...nativeProps });
24
20
  };
25
21
  exports.TagList = Object.assign(TagListRoot, {
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.popToRoot = exports.getSelectedText = exports.clearSearchBar = exports.closeMainWindow = exports.showHUD = exports.PopToRootType = void 0;
37
37
  const bus_1 = require("./bus");
38
38
  const ui = __importStar(require("./proto/ui"));
39
+ //e
39
40
  var PopToRootType;
40
41
  (function (PopToRootType) {
41
42
  /**
@@ -1,11 +1,5 @@
1
1
  import { Color } from "./color";
2
2
  import * as ui from "./proto/ui";
3
- export type SerializedImageLike = Image | {
4
- fileIcon: string;
5
- } | {
6
- light: URL | Image.Asset;
7
- dark: URL | Image.Asset;
8
- };
9
3
  export type Image = {
10
4
  source: Image.Source;
11
5
  fallback?: Image.Fallback;
@@ -31,5 +25,4 @@ export declare namespace Image {
31
25
  RoundedRectangle = "roundedRectangle"
32
26
  }
33
27
  }
34
- export declare const serializeImageLike: (image: Image.ImageLike) => SerializedImageLike;
35
28
  export declare const serializeProtoImage: (image: ImageLike) => ui.Image;
package/dist/api/image.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.serializeProtoImage = exports.serializeImageLike = exports.Image = void 0;
36
+ exports.serializeProtoImage = exports.Image = void 0;
37
37
  const ui = __importStar(require("./proto/ui"));
38
38
  var Image;
39
39
  (function (Image) {
@@ -47,16 +47,6 @@ const maskMap = {
47
47
  [Image.Mask.Circle]: ui.ImageMask.Circle,
48
48
  [Image.Mask.RoundedRectangle]: ui.ImageMask.RoundedRectangle,
49
49
  };
50
- const serializeImageLike = (image) => {
51
- if (image instanceof URL) {
52
- return { source: image.toString() };
53
- }
54
- if (typeof image == "string") {
55
- return { source: image };
56
- }
57
- return image;
58
- };
59
- exports.serializeImageLike = serializeImageLike;
60
50
  const serializeProtoImage = (image) => {
61
51
  const serializeSource = (payload) => {
62
52
  if (typeof payload === "object") {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@vicinae/api",
3
- "version": "0.13.2",
3
+ "version": "0.13.4",
4
4
  "description": "TypeScript SDK to build Vicinae extensions",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
7
7
  "build": "tsc --outDir dist",
8
- "protogen": "mkdir ./src/api/proto && protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto -I../proto ../proto/*.proto --ts_proto_out ./src/api/proto",
8
+ "protogen": "mkdir -p ./src/api/proto && protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto -I../../proto ../../proto/*.proto --ts_proto_out ./src/api/proto",
9
9
  "pack": "npm run build && npm pack",
10
10
  "docgen-html": "typedoc src/api/index.ts",
11
11
  "docgen-md": "typedoc src/api/index.ts --disableSources --readme none --plugin typedoc-plugin-markdown --out ./docs"
package/types/jsx.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import * as React from "react";
2
2
 
3
3
  import type { ListItemDetailProps } from "../api/components/list";
4
- import { SerializedImageLike } from "../api/image";
4
+ import { ImageLike } from "../api/image";
5
5
  import { SerializedColorLike } from "../api/color";
6
6
  import { Keyboard } from "../api/keyboard";
7
7
  import { Grid } from "../api/components/grid";
8
8
 
9
9
  import 'react';
10
+ import { ImageLike, List } from "../src";
10
11
 
11
12
  type BaseFormField = {
12
13
  onBlur?: Function;
@@ -40,12 +41,12 @@ declare module "react" {
40
41
  title: string;
41
42
  id?: string;
42
43
  subtitle?: string;
43
- icon?: SerializedImageLike;
44
+ icon?: ImageLike;
44
45
  keywords?: string[];
46
+ children?: ReactNode;
45
47
  };
46
48
  "list-item-detail": ListItemDetailProps;
47
49
  "list-item-detail-metadata": any;
48
- "list-accessory": {};
49
50
 
50
51
  grid: {
51
52
  inset?: Grid.Inset;
@@ -76,14 +77,15 @@ declare module "react" {
76
77
  title?: string;
77
78
  id?: string;
78
79
  subtitle?: string;
79
- content?: SerializedImageLike | { color: ColorLike } | { value: SerializedImageLike, tooltip?: string };
80
+ content?: ImageLike | { color: ColorLike } | { value: ImageLike, tooltip?: string };
80
81
  keywords?: string[];
82
+ children?: ReactNode;
81
83
  };
82
84
 
83
85
  "empty-view": {
84
86
  description?: string;
85
87
  title?: string;
86
- icon?: SerializedImageLike;
88
+ icon?: ImageLike;
87
89
  };
88
90
  metadata: {
89
91
  children?: React.ReactNode;
@@ -91,7 +93,7 @@ declare module "react" {
91
93
  "metadata-label": {
92
94
  title: string;
93
95
  text: string;
94
- icon?: SerializedImageLike;
96
+ icon?: ImageLike;
95
97
  };
96
98
  "metadata-separator": {};
97
99
  "metadata-link": {
@@ -105,7 +107,7 @@ declare module "react" {
105
107
  };
106
108
  "action-panel-submenu": {
107
109
  title: string;
108
- icon?: SerializedImageLike;
110
+ icon?: ImageLike;
109
111
  onOpen?: () => void;
110
112
  onSearchTextChange?: (text: string) => void;
111
113
  children?: React.ReactNode;
@@ -119,7 +121,7 @@ declare module "react" {
119
121
  onAction: () => void;
120
122
  onSubmit?: Function;
121
123
  shortcut?: Keyboard.Shortcut;
122
- icon?: SerializedImageLike;
124
+ icon?: ImageLike;
123
125
  autoFocus?: boolean;
124
126
  };
125
127
  "tag-list": {
@@ -128,7 +130,7 @@ declare module "react" {
128
130
  };
129
131
  "tag-item": {
130
132
  color?: SerializedColorLike;
131
- icon?: SerializedImageLike;
133
+ icon?: ImageLike;
132
134
  text?: string;
133
135
  onAction?: () => void;
134
136
  };
@@ -143,7 +145,7 @@ declare module "react" {
143
145
  "tag-picker-item": {
144
146
  title: string;
145
147
  value: string;
146
- icon?: SerializedImageLike;
148
+ icon?: ImageLike;
147
149
  },
148
150
  "text-area-field": BaseFormField & {
149
151
  }
@@ -169,7 +171,7 @@ declare module "react" {
169
171
  "dropdown-item": {
170
172
  title: string;
171
173
  value: string;
172
- icon?: SerializedImageLike;
174
+ icon?: ImageLike;
173
175
  keywords?: string[];
174
176
  };
175
177
 
@@ -1,18 +0,0 @@
1
- import * as vicinae from '../../';
2
- export declare const ActionPanel: import("react").FC<vicinae.ActionPanelProps> & {
3
- Section: import("react").FC<import("react").PropsWithChildren<vicinae.ActionPanelSectionProps>>;
4
- Submenu: import("react").FC<vicinae.ActionPanelSubmenuProps>;
5
- } & {
6
- Item: import("react").FC<vicinae.ActionProps> & {
7
- CopyToClipboard: import("react").FC<vicinae.CopyToClipboardProps>;
8
- Push: import("react").FC<vicinae.ActionPushProps>;
9
- Open: import("react").FC<vicinae.ActionOpenProps>;
10
- Paste: import("react").FC<vicinae.ActionPasteProps>;
11
- SubmitForm: import("react").FC<vicinae.ActionSubmitFormProps>;
12
- OpenInBrowser: import("react").FC<vicinae.ActionOpenInBrowserProps>;
13
- Style: {
14
- Regular: "regular";
15
- Destructive: "destructive";
16
- };
17
- };
18
- };
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ActionPanel = void 0;
37
- const vicinae = __importStar(require("../../"));
38
- // older versions of the Raycast API had ActionPanel.Item
39
- exports.ActionPanel = Object.assign(vicinae.ActionPanel, {
40
- Item: vicinae.Action
41
- });
@@ -1,26 +0,0 @@
1
- /**
2
- * This entrypoint is used instead of the normal index.ts when we are
3
- * dealing with a Raycast extension, e.g an extension that makes use of
4
- * `@raycast/api` package instead of `@vicinae/api`.
5
- */
6
- export * from "../hooks/index.js";
7
- export * from "../context/index.js";
8
- export * from "../bus.js";
9
- export * from "../color.js";
10
- export * from "../keyboard.js";
11
- export * from "../image.js";
12
- export * from "../icon.js";
13
- export * from "../environment.js";
14
- export * from "../controls.js";
15
- export * from "../cache";
16
- export * from "../toast";
17
- export * from "../clipboard.js";
18
- export * from "../oauth.js";
19
- export * from "../alert.js";
20
- export * from "../preference.js";
21
- export * from "./system.js";
22
- export * from "./local-storage.js";
23
- export * from './window-management.js';
24
- export { randomId } from './utils.js';
25
- export { List, Grid, Form, Detail, Action } from '../components';
26
- export { ActionPanel } from "./components/action-panel.js";
@@ -1,50 +0,0 @@
1
- "use strict";
2
- /**
3
- * This entrypoint is used instead of the normal index.ts when we are
4
- * dealing with a Raycast extension, e.g an extension that makes use of
5
- * `@raycast/api` package instead of `@vicinae/api`.
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.ActionPanel = exports.Action = exports.Detail = exports.Form = exports.Grid = exports.List = exports.randomId = void 0;
23
- __exportStar(require("../hooks/index.js"), exports);
24
- __exportStar(require("../context/index.js"), exports);
25
- __exportStar(require("../bus.js"), exports);
26
- __exportStar(require("../color.js"), exports);
27
- __exportStar(require("../keyboard.js"), exports);
28
- __exportStar(require("../image.js"), exports);
29
- __exportStar(require("../icon.js"), exports);
30
- __exportStar(require("../environment.js"), exports);
31
- __exportStar(require("../controls.js"), exports);
32
- __exportStar(require("../cache"), exports);
33
- __exportStar(require("../toast"), exports);
34
- __exportStar(require("../clipboard.js"), exports);
35
- __exportStar(require("../oauth.js"), exports);
36
- __exportStar(require("../alert.js"), exports);
37
- __exportStar(require("../preference.js"), exports);
38
- __exportStar(require("./system.js"), exports);
39
- __exportStar(require("./local-storage.js"), exports);
40
- __exportStar(require("./window-management.js"), exports);
41
- var utils_js_1 = require("./utils.js");
42
- Object.defineProperty(exports, "randomId", { enumerable: true, get: function () { return utils_js_1.randomId; } });
43
- var components_1 = require("../components");
44
- Object.defineProperty(exports, "List", { enumerable: true, get: function () { return components_1.List; } });
45
- Object.defineProperty(exports, "Grid", { enumerable: true, get: function () { return components_1.Grid; } });
46
- Object.defineProperty(exports, "Form", { enumerable: true, get: function () { return components_1.Form; } });
47
- Object.defineProperty(exports, "Detail", { enumerable: true, get: function () { return components_1.Detail; } });
48
- Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return components_1.Action; } });
49
- var action_panel_js_1 = require("./components/action-panel.js");
50
- Object.defineProperty(exports, "ActionPanel", { enumerable: true, get: function () { return action_panel_js_1.ActionPanel; } });
@@ -1,9 +0,0 @@
1
- import { LocalStorage } from '../local-storage';
2
- export declare const allLocalStorageItems: typeof LocalStorage.allItems;
3
- export declare const getLocalStorageItem: typeof LocalStorage.getItem;
4
- export declare const setLocalStorageItem: typeof LocalStorage.setItem;
5
- export declare const removeLocalStorageItem: typeof LocalStorage.removeItem;
6
- export declare const clearLocalStorage: typeof LocalStorage.clear;
7
- export type LocalStorageValues = LocalStorage.Values;
8
- export type LocalStorageValue = LocalStorage.Value;
9
- export { LocalStorage } from '../local-storage';
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalStorage = exports.clearLocalStorage = exports.removeLocalStorageItem = exports.setLocalStorageItem = exports.getLocalStorageItem = exports.allLocalStorageItems = void 0;
4
- const local_storage_1 = require("../local-storage");
5
- // We support deprecated local storage methods:
6
- // https://developers.raycast.com/misc/migration/v1.28.0#storage
7
- exports.allLocalStorageItems = local_storage_1.LocalStorage.allItems;
8
- exports.getLocalStorageItem = local_storage_1.LocalStorage.getItem;
9
- exports.setLocalStorageItem = local_storage_1.LocalStorage.setItem;
10
- exports.removeLocalStorageItem = local_storage_1.LocalStorage.removeItem;
11
- exports.clearLocalStorage = local_storage_1.LocalStorage.clear;
12
- var local_storage_2 = require("../local-storage");
13
- Object.defineProperty(exports, "LocalStorage", { enumerable: true, get: function () { return local_storage_2.LocalStorage; } });
@@ -1,20 +0,0 @@
1
- import { PathLike } from 'fs';
2
- import * as vicinae from '..';
3
- export type RaycastApplication = {
4
- name: string;
5
- path: string;
6
- bundleId: string;
7
- localizedName: string;
8
- windowsAppId: string;
9
- };
10
- export declare const transformApp: (app: vicinae.Application) => RaycastApplication;
11
- export declare const getApplications: (path?: PathLike) => Promise<RaycastApplication[]>;
12
- export declare const getDefaultApplication: (path: PathLike) => Promise<RaycastApplication>;
13
- export declare const open: (target: string, app?: vicinae.Application | string) => Promise<void>;
14
- export declare const trash: (path: PathLike | PathLike[]) => Promise<void>;
15
- export declare const getFrontmostApplication: () => Promise<RaycastApplication>;
16
- export declare const captureException: (exception: unknown) => void;
17
- export declare const showInFinder: (path: PathLike) => Promise<void>;
18
- export declare const getSelectedFinderItems: () => Promise<{
19
- path: string;
20
- }[]>;
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getSelectedFinderItems = exports.showInFinder = exports.captureException = exports.getFrontmostApplication = exports.trash = exports.open = exports.getDefaultApplication = exports.getApplications = exports.transformApp = void 0;
37
- const vicinae = __importStar(require(".."));
38
- const transformApp = (app) => {
39
- return {
40
- bundleId: app.id,
41
- name: app.name,
42
- path: app.path,
43
- localizedName: app.name,
44
- windowsAppId: app.id,
45
- };
46
- };
47
- exports.transformApp = transformApp;
48
- const getApplications = async (path) => {
49
- const apps = await vicinae.getApplications(path?.toString());
50
- return apps.map(exports.transformApp);
51
- };
52
- exports.getApplications = getApplications;
53
- const getDefaultApplication = async (path) => {
54
- return (0, exports.transformApp)(await vicinae.getDefaultApplication(path.toString()));
55
- };
56
- exports.getDefaultApplication = getDefaultApplication;
57
- exports.open = vicinae.open;
58
- exports.trash = vicinae.trash;
59
- const getFrontmostApplication = async () => {
60
- return (0, exports.transformApp)(await vicinae.getFrontmostApplication());
61
- };
62
- exports.getFrontmostApplication = getFrontmostApplication;
63
- const captureException = (exception) => {
64
- // maybe one day, if we have a developer hub...
65
- console.error("captureException called on", exception);
66
- };
67
- exports.captureException = captureException;
68
- const showInFinder = (path) => vicinae.showInFileBrowser(path);
69
- exports.showInFinder = showInFinder;
70
- const getSelectedFinderItems = async () => {
71
- throw new Error('getSelectedFinderItems is not implemented');
72
- };
73
- exports.getSelectedFinderItems = getSelectedFinderItems;
@@ -1,2 +0,0 @@
1
- import { randomUUID } from "crypto";
2
- export declare const randomId: typeof randomUUID;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randomId = void 0;
4
- const crypto_1 = require("crypto");
5
- // legacy raycast util
6
- exports.randomId = crypto_1.randomUUID;
@@ -1,42 +0,0 @@
1
- import { RaycastApplication } from './system';
2
- type RaycastWindow = {
3
- active: boolean;
4
- bounds: {
5
- position: {
6
- x: number;
7
- y: number;
8
- };
9
- size: {
10
- height: number;
11
- width: number;
12
- };
13
- } | "fullscreen";
14
- desktopId: string;
15
- fullScreenSettable: boolean;
16
- id: string;
17
- positionable: boolean;
18
- resizable: boolean;
19
- application?: RaycastApplication;
20
- };
21
- declare enum DesktopType {
22
- User = 0,
23
- FullScreen = 1
24
- }
25
- type RaycastDesktop = {
26
- id: string;
27
- screenId: string;
28
- size: {
29
- height: number;
30
- width: number;
31
- };
32
- active: boolean;
33
- type: DesktopType;
34
- };
35
- declare class RaycastWindowManagement {
36
- getActiveWindow(): Promise<RaycastWindow>;
37
- getDesktops(): Promise<RaycastDesktop[]>;
38
- getWindowsOnActiveDesktop(): Promise<RaycastWindow[]>;
39
- constructor();
40
- }
41
- export declare const WindowManagement: RaycastWindowManagement;
42
- export {};
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.WindowManagement = void 0;
37
- const system_1 = require("./system");
38
- const vicinae = __importStar(require(".."));
39
- var DesktopType;
40
- (function (DesktopType) {
41
- DesktopType[DesktopType["User"] = 0] = "User";
42
- DesktopType[DesktopType["FullScreen"] = 1] = "FullScreen";
43
- })(DesktopType || (DesktopType = {}));
44
- ;
45
- const transformNativeDesktop = (win) => {
46
- return {
47
- id: win.id,
48
- screenId: win.monitorId,
49
- size: { width: 0, height: 0 }, // FIXME: implement
50
- active: win.active,
51
- type: DesktopType.User
52
- };
53
- };
54
- const transformNativeWindow = (win) => {
55
- return {
56
- id: win.id,
57
- fullScreenSettable: true,
58
- positionable: true,
59
- resizable: true,
60
- active: win.active,
61
- bounds: win.bounds,
62
- desktopId: win.workspaceId ?? '0',
63
- application: win.application && (0, system_1.transformApp)(win.application)
64
- };
65
- };
66
- class RaycastWindowManagement {
67
- async getActiveWindow() {
68
- const window = await vicinae.WindowManagement.getActiveWindow();
69
- return transformNativeWindow(window);
70
- }
71
- async getDesktops() {
72
- const workspaces = await vicinae.WindowManagement.getWorkspaces();
73
- return workspaces.map(transformNativeDesktop);
74
- }
75
- async getWindowsOnActiveDesktop() {
76
- const wins = await vicinae.WindowManagement.getWindowsOnActiveWorkspace();
77
- return wins.map(transformNativeWindow);
78
- }
79
- constructor() { }
80
- }
81
- ;
82
- exports.WindowManagement = new RaycastWindowManagement;