@vicinae/api 0.12.2 → 0.13.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.
@@ -21,11 +21,12 @@ export declare namespace Grid {
21
21
  namespace Section {
22
22
  type Props = GridSectionProps;
23
23
  }
24
+ type Fit = GridFit;
24
25
  type Props = GridProps;
25
26
  type Inset = GridInset;
26
27
  type AspectRatio = GridAspectRatio;
27
28
  namespace Item {
28
- type Props = {
29
+ export type Props = {
29
30
  title?: string;
30
31
  detail?: React.ReactNode;
31
32
  keywords?: string[];
@@ -49,7 +50,7 @@ export declare namespace Grid {
49
50
  color: Color;
50
51
  value: string | Date | undefined | null;
51
52
  };
52
- type Accessory = ({
53
+ export type Accessory = ({
53
54
  tag?: Tag;
54
55
  } | {
55
56
  text?: Text;
@@ -57,6 +58,7 @@ export declare namespace Grid {
57
58
  icon?: Image.ImageLike;
58
59
  tooltip?: string | null;
59
60
  };
61
+ export {};
60
62
  }
61
63
  }
62
64
  type GridProps = SectionConfig & {
@@ -109,6 +111,7 @@ export declare const Grid: React.FC<GridProps> & {
109
111
  children?: ReactNode;
110
112
  }>;
111
113
  };
114
+ Fit: typeof GridFit;
112
115
  Inset: typeof GridInset;
113
116
  Item: React.FC<Grid.Item.Props> & {
114
117
  Accessory: React.FC<Grid.Item.Accessory>;
@@ -13,6 +13,15 @@ var GridInset;
13
13
  GridInset["Medium"] = "medium";
14
14
  GridInset["Large"] = "large";
15
15
  })(GridInset || (GridInset = {}));
16
+ const aspectRatioMap = {
17
+ '1': 1,
18
+ '3/2': 3 / 2,
19
+ '2/3': 2 / 3,
20
+ '4/3': 4 / 3,
21
+ '3/4': 3 / 4,
22
+ '16/9': 16 / 9,
23
+ '9/16': 9 / 16
24
+ };
16
25
  var GridFit;
17
26
  (function (GridFit) {
18
27
  GridFit["Contain"] = "contain";
@@ -23,7 +32,7 @@ const GridRoot = ({ searchBarAccessory, children, actions, inset, fit = GridFit.
23
32
  typeof props.filtering === "undefined") {
24
33
  props.filtering = props.enableFiltering;
25
34
  }
26
- return ((0, jsx_runtime_1.jsxs)("grid", { fit: fit, inset: inset, aspectRatio: aspectRatio, ...props, children: [searchBarAccessory, children, actions] }));
35
+ return ((0, jsx_runtime_1.jsxs)("grid", { fit: fit, inset: inset, aspectRatio: aspectRatioMap[aspectRatio], ...props, children: [searchBarAccessory, children, actions] }));
27
36
  };
28
37
  const GridItem = ({ detail, actions, keywords, ...props }) => {
29
38
  const id = (0, react_1.useRef)(props.id ?? (0, crypto_1.randomUUID)());
@@ -53,10 +62,10 @@ const GridItem = ({ detail, actions, keywords, ...props }) => {
53
62
  }
54
63
  return ((0, jsx_runtime_1.jsxs)("grid-item", { ...nativeProps, children: [detail, actions] }));
55
64
  };
56
- const GridSection = ({ fit = GridFit.Contain, aspectRatio = "1", inset, ...props }) => {
65
+ const GridSection = ({ fit, aspectRatio, inset, ...props }) => {
57
66
  const nativeProps = {
58
67
  fit,
59
- aspectRatio,
68
+ aspectRatio: aspectRatio ? aspectRatioMap[aspectRatio] : aspectRatio,
60
69
  inset,
61
70
  ...props,
62
71
  };
@@ -70,6 +79,7 @@ exports.Grid = Object.assign(GridRoot, {
70
79
  Section: GridSection,
71
80
  EmptyView: empty_view_1.EmptyView,
72
81
  Dropdown: dropdown_1.Dropdown,
82
+ Fit: GridFit,
73
83
  Inset: GridInset,
74
84
  Item: Object.assign(GridItem, {
75
85
  Accessory: exports.GridAccessory,
@@ -1,6 +1,48 @@
1
- export declare const closeMainWindow: () => Promise<void>;
1
+ export declare enum PopToRootType {
2
+ /**
3
+ * Translates to Immediate or Suspended depending on the
4
+ * user configuration.
5
+ */
6
+ Default = "default",
7
+ /**
8
+ * Immediately pop to root
9
+ */
10
+ Immediate = "immediate",
11
+ /**
12
+ * Do not pop to root, preserve the navigation state as it is
13
+ */
14
+ Suspended = "suspended"
15
+ }
16
+ /**
17
+ * Close the window and show a small HUD where the window was previously opened.
18
+ * Note that the HUD may not be shown in some environments.
19
+ * Similarly to `closeWindow`, it is possible to override the pop to root behavior directly
20
+ * by passing options to this function.
21
+ *
22
+ * @see closeWindow
23
+ */
24
+ export declare const showHUD: (title: string, options?: {
25
+ clearRootSearch?: boolean;
26
+ popToRootType?: PopToRootType;
27
+ }) => Promise<void>;
28
+ /**
29
+ * Close the vicinae launcher window immediately.
30
+ * It is possible to override the `popToRoot` behavior defined in the settings using the options object.
31
+ */
32
+ export declare const closeMainWindow: (options?: {
33
+ clearRootSearch?: boolean;
34
+ popToRootType?: PopToRootType;
35
+ }) => Promise<void>;
2
36
  export declare const clearSearchBar: () => Promise<void>;
37
+ /**
38
+ * Get the text that is currently selected by the user.
39
+ * How this is implemented depends on the environment but all it does is usually
40
+ * read the clipboard's primary selection buffer.
41
+ */
3
42
  export declare const getSelectedText: () => Promise<string>;
43
+ /**
44
+ * Pop to the root of the navigation stack, optionally clearing the search bar.
45
+ */
4
46
  export declare const popToRoot: (options?: {
5
47
  clearSearchBar?: boolean;
6
48
  }) => Promise<void>;
@@ -1,15 +1,99 @@
1
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
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.popToRoot = exports.getSelectedText = exports.clearSearchBar = exports.closeMainWindow = void 0;
36
+ exports.popToRoot = exports.getSelectedText = exports.clearSearchBar = exports.closeMainWindow = exports.showHUD = exports.PopToRootType = void 0;
4
37
  const bus_1 = require("./bus");
5
- const closeMainWindow = async () => {
6
- await bus_1.bus.turboRequest("ui.closeMainWindow", {});
38
+ const ui = __importStar(require("./proto/ui"));
39
+ var PopToRootType;
40
+ (function (PopToRootType) {
41
+ /**
42
+ * Translates to Immediate or Suspended depending on the
43
+ * user configuration.
44
+ */
45
+ PopToRootType["Default"] = "default";
46
+ /**
47
+ * Immediately pop to root
48
+ */
49
+ PopToRootType["Immediate"] = "immediate";
50
+ /**
51
+ * Do not pop to root, preserve the navigation state as it is
52
+ */
53
+ PopToRootType["Suspended"] = "suspended";
54
+ })(PopToRootType || (exports.PopToRootType = PopToRootType = {}));
55
+ const popToRootProtoMap = {
56
+ [PopToRootType.Default]: ui.PopToRootType.PopToRootDefault,
57
+ [PopToRootType.Immediate]: ui.PopToRootType.PopToRootImmediate,
58
+ [PopToRootType.Suspended]: ui.PopToRootType.PopToRootSuspended,
59
+ };
60
+ /**
61
+ * Close the window and show a small HUD where the window was previously opened.
62
+ * Note that the HUD may not be shown in some environments.
63
+ * Similarly to `closeWindow`, it is possible to override the pop to root behavior directly
64
+ * by passing options to this function.
65
+ *
66
+ * @see closeWindow
67
+ */
68
+ const showHUD = async (title, options) => {
69
+ bus_1.bus.turboRequest('ui.showHud', {
70
+ text: title,
71
+ clearRootSearch: options?.clearRootSearch ?? false,
72
+ popToRoot: popToRootProtoMap[options?.popToRootType ?? PopToRootType.Default]
73
+ });
74
+ };
75
+ exports.showHUD = showHUD;
76
+ /**
77
+ * Close the vicinae launcher window immediately.
78
+ * It is possible to override the `popToRoot` behavior defined in the settings using the options object.
79
+ */
80
+ const closeMainWindow = async (options = {}) => {
81
+ const { clearRootSearch = false, popToRootType = PopToRootType.Default } = options;
82
+ await bus_1.bus.turboRequest("ui.closeMainWindow", {
83
+ clearRootSearch,
84
+ popToRoot: popToRootProtoMap[popToRootType]
85
+ });
7
86
  };
8
87
  exports.closeMainWindow = closeMainWindow;
9
88
  const clearSearchBar = async () => {
10
89
  await bus_1.bus.turboRequest("ui.setSearchText", { text: "" });
11
90
  };
12
91
  exports.clearSearchBar = clearSearchBar;
92
+ /**
93
+ * Get the text that is currently selected by the user.
94
+ * How this is implemented depends on the environment but all it does is usually
95
+ * read the clipboard's primary selection buffer.
96
+ */
13
97
  const getSelectedText = async () => {
14
98
  const response = await bus_1.bus.turboRequest("ui.getSelectedText", {});
15
99
  if (!response.ok) {
@@ -18,6 +102,9 @@ const getSelectedText = async () => {
18
102
  return response.value.text;
19
103
  };
20
104
  exports.getSelectedText = getSelectedText;
105
+ /**
106
+ * Pop to the root of the navigation stack, optionally clearing the search bar.
107
+ */
21
108
  const popToRoot = async (options) => {
22
109
  await bus_1.bus.turboRequest('ui.popToRoot', { clearSearchBar: options?.clearSearchBar ?? false });
23
110
  };
@@ -29,7 +29,7 @@ export interface ResponseData {
29
29
  export interface ManagerLoadCommand {
30
30
  mode: CommandMode;
31
31
  env: CommandEnv;
32
- extensionPath: string;
32
+ vicinaePath: string;
33
33
  /** javascript source file to execute */
34
34
  entrypoint: string;
35
35
  preferenceValues: {
@@ -40,6 +40,7 @@ export interface ManagerLoadCommand {
40
40
  };
41
41
  isRaycast: boolean;
42
42
  commandName: string;
43
+ extensionId: string;
43
44
  }
44
45
  export interface ManagerLoadCommand_PreferenceValuesEntry {
45
46
  key: string;
@@ -277,12 +277,13 @@ function createBaseManagerLoadCommand() {
277
277
  return {
278
278
  mode: 0,
279
279
  env: 0,
280
- extensionPath: "",
280
+ vicinaePath: "",
281
281
  entrypoint: "",
282
282
  preferenceValues: {},
283
283
  argumentValues: {},
284
284
  isRaycast: false,
285
285
  commandName: "",
286
+ extensionId: "",
286
287
  };
287
288
  }
288
289
  exports.ManagerLoadCommand = {
@@ -293,8 +294,8 @@ exports.ManagerLoadCommand = {
293
294
  if (message.env !== 0) {
294
295
  writer.uint32(16).int32(message.env);
295
296
  }
296
- if (message.extensionPath !== "") {
297
- writer.uint32(26).string(message.extensionPath);
297
+ if (message.vicinaePath !== "") {
298
+ writer.uint32(26).string(message.vicinaePath);
298
299
  }
299
300
  if (message.entrypoint !== "") {
300
301
  writer.uint32(34).string(message.entrypoint);
@@ -315,6 +316,9 @@ exports.ManagerLoadCommand = {
315
316
  if (message.commandName !== "") {
316
317
  writer.uint32(66).string(message.commandName);
317
318
  }
319
+ if (message.extensionId !== "") {
320
+ writer.uint32(74).string(message.extensionId);
321
+ }
318
322
  return writer;
319
323
  },
320
324
  decode(input, length) {
@@ -342,7 +346,7 @@ exports.ManagerLoadCommand = {
342
346
  if (tag !== 26) {
343
347
  break;
344
348
  }
345
- message.extensionPath = reader.string();
349
+ message.vicinaePath = reader.string();
346
350
  continue;
347
351
  }
348
352
  case 4: {
@@ -386,6 +390,13 @@ exports.ManagerLoadCommand = {
386
390
  message.commandName = reader.string();
387
391
  continue;
388
392
  }
393
+ case 9: {
394
+ if (tag !== 74) {
395
+ break;
396
+ }
397
+ message.extensionId = reader.string();
398
+ continue;
399
+ }
389
400
  }
390
401
  if ((tag & 7) === 4 || tag === 0) {
391
402
  break;
@@ -398,7 +409,7 @@ exports.ManagerLoadCommand = {
398
409
  return {
399
410
  mode: isSet(object.mode) ? commandModeFromJSON(object.mode) : 0,
400
411
  env: isSet(object.env) ? commandEnvFromJSON(object.env) : 0,
401
- extensionPath: isSet(object.extensionPath) ? globalThis.String(object.extensionPath) : "",
412
+ vicinaePath: isSet(object.vicinaePath) ? globalThis.String(object.vicinaePath) : "",
402
413
  entrypoint: isSet(object.entrypoint) ? globalThis.String(object.entrypoint) : "",
403
414
  preferenceValues: isObject(object.preferenceValues)
404
415
  ? Object.entries(object.preferenceValues).reduce((acc, [key, value]) => {
@@ -414,6 +425,7 @@ exports.ManagerLoadCommand = {
414
425
  : {},
415
426
  isRaycast: isSet(object.isRaycast) ? globalThis.Boolean(object.isRaycast) : false,
416
427
  commandName: isSet(object.commandName) ? globalThis.String(object.commandName) : "",
428
+ extensionId: isSet(object.extensionId) ? globalThis.String(object.extensionId) : "",
417
429
  };
418
430
  },
419
431
  toJSON(message) {
@@ -424,8 +436,8 @@ exports.ManagerLoadCommand = {
424
436
  if (message.env !== 0) {
425
437
  obj.env = commandEnvToJSON(message.env);
426
438
  }
427
- if (message.extensionPath !== "") {
428
- obj.extensionPath = message.extensionPath;
439
+ if (message.vicinaePath !== "") {
440
+ obj.vicinaePath = message.vicinaePath;
429
441
  }
430
442
  if (message.entrypoint !== "") {
431
443
  obj.entrypoint = message.entrypoint;
@@ -454,6 +466,9 @@ exports.ManagerLoadCommand = {
454
466
  if (message.commandName !== "") {
455
467
  obj.commandName = message.commandName;
456
468
  }
469
+ if (message.extensionId !== "") {
470
+ obj.extensionId = message.extensionId;
471
+ }
457
472
  return obj;
458
473
  },
459
474
  create(base) {
@@ -463,7 +478,7 @@ exports.ManagerLoadCommand = {
463
478
  const message = createBaseManagerLoadCommand();
464
479
  message.mode = object.mode ?? 0;
465
480
  message.env = object.env ?? 0;
466
- message.extensionPath = object.extensionPath ?? "";
481
+ message.vicinaePath = object.vicinaePath ?? "";
467
482
  message.entrypoint = object.entrypoint ?? "";
468
483
  message.preferenceValues = Object.entries(object.preferenceValues ?? {}).reduce((acc, [key, value]) => {
469
484
  if (value !== undefined) {
@@ -479,6 +494,7 @@ exports.ManagerLoadCommand = {
479
494
  }, {});
480
495
  message.isRaycast = object.isRaycast ?? false;
481
496
  message.commandName = object.commandName ?? "";
497
+ message.extensionId = object.extensionId ?? "";
482
498
  return message;
483
499
  },
484
500
  };
@@ -52,6 +52,8 @@ export interface PushViewRequest {
52
52
  export interface PopViewRequest {
53
53
  }
54
54
  export interface CloseMainWindowRequest {
55
+ clearRootSearch: boolean;
56
+ popToRoot: PopToRootType;
55
57
  }
56
58
  export interface ClearSearchBarRequest {
57
59
  }
@@ -456,10 +456,16 @@ exports.PopViewRequest = {
456
456
  },
457
457
  };
458
458
  function createBaseCloseMainWindowRequest() {
459
- return {};
459
+ return { clearRootSearch: false, popToRoot: 0 };
460
460
  }
461
461
  exports.CloseMainWindowRequest = {
462
- encode(_, writer = new wire_1.BinaryWriter()) {
462
+ encode(message, writer = new wire_1.BinaryWriter()) {
463
+ if (message.clearRootSearch !== false) {
464
+ writer.uint32(8).bool(message.clearRootSearch);
465
+ }
466
+ if (message.popToRoot !== 0) {
467
+ writer.uint32(16).int32(message.popToRoot);
468
+ }
463
469
  return writer;
464
470
  },
465
471
  decode(input, length) {
@@ -469,6 +475,20 @@ exports.CloseMainWindowRequest = {
469
475
  while (reader.pos < end) {
470
476
  const tag = reader.uint32();
471
477
  switch (tag >>> 3) {
478
+ case 1: {
479
+ if (tag !== 8) {
480
+ break;
481
+ }
482
+ message.clearRootSearch = reader.bool();
483
+ continue;
484
+ }
485
+ case 2: {
486
+ if (tag !== 16) {
487
+ break;
488
+ }
489
+ message.popToRoot = reader.int32();
490
+ continue;
491
+ }
472
492
  }
473
493
  if ((tag & 7) === 4 || tag === 0) {
474
494
  break;
@@ -477,18 +497,29 @@ exports.CloseMainWindowRequest = {
477
497
  }
478
498
  return message;
479
499
  },
480
- fromJSON(_) {
481
- return {};
500
+ fromJSON(object) {
501
+ return {
502
+ clearRootSearch: isSet(object.clearRootSearch) ? globalThis.Boolean(object.clearRootSearch) : false,
503
+ popToRoot: isSet(object.popToRoot) ? popToRootTypeFromJSON(object.popToRoot) : 0,
504
+ };
482
505
  },
483
- toJSON(_) {
506
+ toJSON(message) {
484
507
  const obj = {};
508
+ if (message.clearRootSearch !== false) {
509
+ obj.clearRootSearch = message.clearRootSearch;
510
+ }
511
+ if (message.popToRoot !== 0) {
512
+ obj.popToRoot = popToRootTypeToJSON(message.popToRoot);
513
+ }
485
514
  return obj;
486
515
  },
487
516
  create(base) {
488
517
  return exports.CloseMainWindowRequest.fromPartial(base ?? {});
489
518
  },
490
- fromPartial(_) {
519
+ fromPartial(object) {
491
520
  const message = createBaseCloseMainWindowRequest();
521
+ message.clearRootSearch = object.clearRootSearch ?? false;
522
+ message.popToRoot = object.popToRoot ?? 0;
492
523
  return message;
493
524
  },
494
525
  };
@@ -157,12 +157,3 @@ export declare interface ToastOptions extends Toast.Options {
157
157
  */
158
158
  export declare const ToastStyle: typeof Toast.Style;
159
159
  export declare const showToast: (init: Toast.Style | Toast.Options, title?: string, message?: string) => Promise<Toast>;
160
- export declare enum PopToRootType {
161
- Default = "default",
162
- Immediate = "immediate",
163
- Suspended = "suspended"
164
- }
165
- export declare const showHUD: (title: string, options?: {
166
- clearRootSearch?: boolean;
167
- popToRootType?: PopToRootType;
168
- }) => Promise<void>;
package/dist/api/toast.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.showHUD = exports.PopToRootType = exports.showToast = exports.Toast = void 0;
36
+ exports.showToast = exports.Toast = void 0;
37
37
  const crypto_1 = require("crypto");
38
38
  const bus_1 = require("./bus");
39
39
  const ui = __importStar(require("./proto/ui"));
@@ -200,22 +200,3 @@ const showToast = async (init, title = "", message) => {
200
200
  return toast;
201
201
  };
202
202
  exports.showToast = showToast;
203
- var PopToRootType;
204
- (function (PopToRootType) {
205
- PopToRootType["Default"] = "default";
206
- PopToRootType["Immediate"] = "immediate";
207
- PopToRootType["Suspended"] = "suspended";
208
- })(PopToRootType || (exports.PopToRootType = PopToRootType = {}));
209
- const popToRootProtoMap = {
210
- [PopToRootType.Default]: ui.PopToRootType.PopToRootDefault,
211
- [PopToRootType.Immediate]: ui.PopToRootType.PopToRootImmediate,
212
- [PopToRootType.Suspended]: ui.PopToRootType.PopToRootSuspended,
213
- };
214
- const showHUD = async (title, options) => {
215
- bus_1.bus.turboRequest('ui.showHud', {
216
- text: title,
217
- clearRootSearch: options?.clearRootSearch ?? false,
218
- popToRoot: popToRootProtoMap[options?.popToRootType ?? PopToRootType.Default]
219
- });
220
- };
221
- exports.showHUD = showHUD;
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@vicinae/api",
3
- "version": "0.12.2",
3
+ "version": "0.13.0",
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
9
  "pack": "npm run build && npm pack",
9
10
  "docgen-html": "typedoc src/api/index.ts",
10
- "docgen-md": "typedoc src/api/index.ts --readme none --plugin typedoc-plugin-markdown --out ./docs"
11
+ "docgen-md": "typedoc src/api/index.ts --disableSources --readme none --plugin typedoc-plugin-markdown --out ./docs"
11
12
  },
12
13
  "bin": {
13
14
  "vici": "./bin/run.js"
package/types/jsx.d.ts CHANGED
@@ -65,8 +65,8 @@ declare module "react" {
65
65
  "grid-section": {
66
66
  inset?: Grid.Inset;
67
67
  columns?: number;
68
- fit: Grid.Fit;
69
- aspectRatio: Grid.AspectRatio;
68
+ fit?: Grid.Fit;
69
+ aspectRatio?: Grid.AspectRatio;
70
70
 
71
71
  title?: string;
72
72
  subtitle?: string;