power-compass 0.0.1-alpha.2 → 0.0.1-alpha.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { SearchResult, SourceDefinition } from './types';
2
+ /**
3
+ * Sorts matches by score.
4
+ * Sorts sources by best match's score and move them as per specified by their `insertSourceAtIndex` key.
5
+ *
6
+ * @param {*} sources all sources added to Spotnitro. See `app/javascript/packs/spotnitro.ts`
7
+ * @param {*} data GraphQL data
8
+ * @param {*} search user's input
9
+ * @see source-scores-spec.js
10
+ */
11
+ export declare function sortSearchResults<T>(results: SearchResult<T>[]): SearchResult<T>[];
12
+ type OnResultCallback = (result: SearchResult<unknown>) => void;
13
+ export declare function search(value: string, sources: SourceDefinition<unknown>[], abortController?: AbortController, onResult?: OnResultCallback): Promise<SearchResult<unknown>[]>;
14
+ export {};
@@ -0,0 +1 @@
1
+ export * from './useSearch';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { SourceDefinition } from './types';
2
+ export declare const sources: SourceDefinition<unknown>[];
3
+ type SourceDefinitionCreation<T> = Omit<SourceDefinition<T>, "open" | "display"> & Partial<Pick<SourceDefinition<T>, "open" | "display">>;
4
+ export declare function createCompassProviderSource(contextId: string | number | undefined, providerName: string, search: string, abortController?: AbortController): Promise<SourceDefinition<unknown> | null>;
5
+ export declare function getCompassProviders(contextId: string | number, abortController?: AbortController): Promise<string[]>;
6
+ export declare function createCompassSources(contextId: string | number | undefined, search: string, abortController?: AbortController): Promise<SourceDefinition<unknown>[]>;
7
+ export declare function createMenuSources(backends: string[], contextId: string): SourceDefinition<unknown>[];
8
+ export declare function createSource<T>(source: SourceDefinitionCreation<T>): void;
9
+ export {};
@@ -0,0 +1,32 @@
1
+ import { ComponentType } from 'react';
2
+ export type SourceDefinition<T> = {
3
+ label?: string;
4
+ tag?: string;
5
+ searchOptions?: Record<string, unknown>;
6
+ newTab?: boolean;
7
+ insertSourceAtIndex?: number;
8
+ maxEntries?: number;
9
+ display: ComponentType<ResultEntry<T>> | DisplayProps<T>;
10
+ fetch: (arg0: string, options?: RequestInit) => Promise<T[]>;
11
+ open: (arg0: T) => string | Promise<string> | void;
12
+ };
13
+ export type ResultEntry<T> = {
14
+ item: T;
15
+ score: number;
16
+ source: SourceDefinition<T>;
17
+ };
18
+ export type SearchResult<T> = {
19
+ source: SourceDefinition<T>;
20
+ entries: ResultEntry<T>[];
21
+ };
22
+ export interface SearchItem {
23
+ html?: string;
24
+ label?: string;
25
+ tag?: string;
26
+ url?: string;
27
+ }
28
+ export type DisplayProps<T> = {
29
+ label: (arg0: T) => Promise<string> | string;
30
+ category: (arg0: T) => Promise<string> | string;
31
+ tag: (arg0: T) => Promise<string> | string;
32
+ };
@@ -0,0 +1,4 @@
1
+ import { SearchResult } from './types';
2
+ type UseSpotnitroReturn = [SearchResult<unknown>[], boolean, boolean];
3
+ export declare function useSearch(value?: string): UseSpotnitroReturn;
4
+ export {};
@@ -0,0 +1 @@
1
+ export * from './useNotificationCenter';
@@ -0,0 +1,7 @@
1
+ export type Notification = {
2
+ id: string;
3
+ createdAt: string;
4
+ title: string;
5
+ body: string;
6
+ url?: string;
7
+ };
@@ -0,0 +1 @@
1
+ export declare const useLocalStorage: <T>(key: string, initialValue: T) => any[];
@@ -0,0 +1,11 @@
1
+ import { Notification } from './types';
2
+ interface Props {
3
+ contextId?: string | number;
4
+ }
5
+ interface UseNotificationCenterReturn {
6
+ notifications: Notification[];
7
+ loading: boolean;
8
+ error: Error | null;
9
+ }
10
+ export declare function useNotificationCenter({ contextId, }: Props): UseNotificationCenterReturn;
11
+ export {};
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "power-compass",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "type": "module",
5
5
  "main": "./dist/power-compass.cjs.js",
6
6
  "module": "./dist/power-compass.es.js",
7
+ "types": "./dist/types.d.ts",
7
8
  "exports": {
8
9
  ".": {
9
10
  "import": "./dist/power-compass.es.js",
10
- "require": "./dist/power-compass.cjs.js"
11
+ "require": "./dist/power-compass.cjs.js",
12
+ "types": "./dist/types.d.ts"
13
+ },
14
+ "./cjs": {
15
+ "require": "./dist/power-compass.cjs.js",
16
+ "types": "./dist/types.d.ts"
11
17
  }
12
18
  },
13
19
  "scripts": {
@@ -35,6 +41,7 @@
35
41
  "devDependencies": {
36
42
  "@powerhome/eslint-config": "0.3.0",
37
43
  "@testing-library/react-hooks": "^8.0.1",
44
+ "@types/lodash": "^4.17.23",
38
45
  "@types/react": "^19.2.9",
39
46
  "@typescript-eslint/eslint-plugin": "8.18.0",
40
47
  "@typescript-eslint/parser": "8.18.0",
@@ -1 +0,0 @@
1
- export {}