@qikbar/qikbar 0.0.25 → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/dist/ai/agent.d.ts +42 -0
- package/dist/ai/byok.d.ts +29 -0
- package/dist/ai/index.d.ts +8 -0
- package/dist/ai/providers.d.ts +82 -0
- package/dist/ai/sse.d.ts +9 -0
- package/dist/ai.js +36 -0
- package/dist/ai.js.map +7 -0
- package/dist/chunks/bar-D5CSPT3U.js +2031 -0
- package/dist/chunks/bar-D5CSPT3U.js.map +7 -0
- package/dist/chunks/chunk-2ADXL7KQ.js +358 -0
- package/dist/chunks/chunk-2ADXL7KQ.js.map +7 -0
- package/dist/chunks/chunk-6TC6G2C5.js +107 -0
- package/dist/chunks/chunk-6TC6G2C5.js.map +7 -0
- package/dist/chunks/chunk-HBBSETRF.js +153 -0
- package/dist/chunks/chunk-HBBSETRF.js.map +7 -0
- package/dist/chunks/chunk-I77YSUJN.js +104 -0
- package/dist/chunks/chunk-I77YSUJN.js.map +7 -0
- package/dist/chunks/chunk-IJ3WUM3T.js +544 -0
- package/dist/chunks/chunk-IJ3WUM3T.js.map +7 -0
- package/dist/chunks/chunk-MPTP2EWW.js +8 -0
- package/dist/chunks/chunk-MPTP2EWW.js.map +7 -0
- package/dist/chunks/chunk-N4Y2Z6YD.js +69 -0
- package/dist/chunks/chunk-N4Y2Z6YD.js.map +7 -0
- package/dist/chunks/chunk-PQEHV3D4.js +124 -0
- package/dist/chunks/chunk-PQEHV3D4.js.map +7 -0
- package/dist/chunks/chunk-VXTYD56F.js +453 -0
- package/dist/chunks/chunk-VXTYD56F.js.map +7 -0
- package/dist/chunks/chunk-YCVJQ7U3.js +52 -0
- package/dist/chunks/chunk-YCVJQ7U3.js.map +7 -0
- package/dist/core/define.d.ts +40 -0
- package/dist/core/frecency.d.ts +16 -0
- package/dist/core/hotkeys.d.ts +39 -0
- package/dist/core/lazy.d.ts +48 -0
- package/dist/core/search.d.ts +42 -0
- package/dist/core/storage.d.ts +5 -0
- package/dist/core/types.d.ts +601 -0
- package/dist/extensions/index.d.ts +30 -0
- package/dist/extensions/math.d.ts +14 -0
- package/dist/extensions.js +476 -0
- package/dist/extensions.js.map +7 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +7 -0
- package/dist/qikbar.global.js +259 -0
- package/dist/qikbar.global.js.map +7 -0
- package/dist/react/index.d.ts +66 -0
- package/dist/react.js +119 -0
- package/dist/react.js.map +7 -0
- package/dist/server/index.d.ts +47 -0
- package/dist/server.js +93 -0
- package/dist/server.js.map +7 -0
- package/dist/styles.css +222 -0
- package/dist/theme.d.ts +5 -0
- package/dist/theme.js +20 -0
- package/dist/theme.js.map +7 -0
- package/dist/ui/bar.d.ts +252 -0
- package/dist/ui/dom.d.ts +21 -0
- package/dist/ui/icons.d.ts +88 -0
- package/dist/ui/markdown.d.ts +8 -0
- package/dist/ui/nav.d.ts +8 -0
- package/dist/ui/styles.d.ts +6 -0
- package/dist/ui/themes.d.ts +27 -0
- package/dist/ui/views.d.ts +148 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.js +50 -0
- package/dist/utils.js.map +7 -0
- package/package.json +88 -43
- package/dist/qikbar.es.js +0 -8748
- package/dist/qikbar.umd.js +0 -113
- package/dist/types/boot.d.ts +0 -72
- package/dist/types/index.d.ts +0 -1
- package/dist/types/init.d.ts +0 -2
- package/dist/types/main.d.ts +0 -4
- package/dist/types/shared/AsyncRoot.d.ts +0 -5
- package/dist/types/shared/CommandFooter.d.ts +0 -5
- package/dist/types/shared/Crumbs.d.ts +0 -6
- package/dist/types/shared/Details.d.ts +0 -3
- package/dist/types/shared/ErrorBoundary.d.ts +0 -15
- package/dist/types/shared/Icon.d.ts +0 -4
- package/dist/types/shared/List.d.ts +0 -30
- package/dist/types/shared/Qikbar.d.ts +0 -5
- package/dist/types/shared/Root.d.ts +0 -4
- package/dist/types/shared/Search.d.ts +0 -1
- package/dist/types/shared/commandContext.d.ts +0 -8
- package/dist/types/shared/useDebounce.d.ts +0 -1
- package/dist/types/utils/liquid.d.ts +0 -4
- package/dist/types/vite-env.d.ts +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/core/storage.ts
|
|
2
|
+
function memoryStorage() {
|
|
3
|
+
let map = /* @__PURE__ */ new Map();
|
|
4
|
+
return {
|
|
5
|
+
getItem: (k) => map.get(k) ?? null,
|
|
6
|
+
setItem: (k, v) => {
|
|
7
|
+
map.set(k, v);
|
|
8
|
+
},
|
|
9
|
+
removeItem: (k) => {
|
|
10
|
+
map.delete(k);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function defaultStorage() {
|
|
15
|
+
try {
|
|
16
|
+
let ls = globalThis.localStorage, probe = "__qikbar__";
|
|
17
|
+
return ls.setItem(probe, "1"), ls.removeItem(probe), ls;
|
|
18
|
+
} catch {
|
|
19
|
+
return memoryStorage();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function scopedStorage(adapter, prefix) {
|
|
23
|
+
return {
|
|
24
|
+
get(key) {
|
|
25
|
+
try {
|
|
26
|
+
let raw = adapter.getItem(`${prefix}:${key}`);
|
|
27
|
+
return raw == null ? void 0 : JSON.parse(raw);
|
|
28
|
+
} catch {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
set(key, value) {
|
|
33
|
+
try {
|
|
34
|
+
value === void 0 ? adapter.removeItem(`${prefix}:${key}`) : adapter.setItem(`${prefix}:${key}`, JSON.stringify(value));
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
remove(key) {
|
|
39
|
+
try {
|
|
40
|
+
adapter.removeItem(`${prefix}:${key}`);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
memoryStorage,
|
|
49
|
+
defaultStorage,
|
|
50
|
+
scopedStorage
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chunk-YCVJQ7U3.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/core/storage.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ScopedStorage, StorageAdapter } from './types.js'\n\n/** In-memory storage, used during SSR or when localStorage is unavailable. */\nexport function memoryStorage(): StorageAdapter {\n const map = new Map<string, string>()\n return {\n getItem: (k) => map.get(k) ?? null,\n setItem: (k, v) => void map.set(k, v),\n removeItem: (k) => void map.delete(k),\n }\n}\n\nexport function defaultStorage(): StorageAdapter {\n try {\n const ls = globalThis.localStorage\n const probe = '__qikbar__'\n ls.setItem(probe, '1')\n ls.removeItem(probe)\n return ls\n } catch {\n return memoryStorage()\n }\n}\n\nexport function scopedStorage(adapter: StorageAdapter, prefix: string): ScopedStorage {\n return {\n get<T>(key: string): T | undefined {\n try {\n const raw = adapter.getItem(`${prefix}:${key}`)\n return raw == null ? undefined : (JSON.parse(raw) as T)\n } catch {\n return undefined\n }\n },\n set(key, value) {\n try {\n if (value === undefined) adapter.removeItem(`${prefix}:${key}`)\n else adapter.setItem(`${prefix}:${key}`, JSON.stringify(value))\n } catch {\n // Quota exceeded or storage disabled \u2014 ignore.\n }\n },\n remove(key) {\n try {\n adapter.removeItem(`${prefix}:${key}`)\n } catch {\n // ignore\n }\n },\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAGO,SAAS,gBAAgC;AAC9C,MAAM,MAAM,oBAAI,IAAoB;AACpC,SAAO;AAAA,IACL,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK;AAAA,IAC9B,SAAS,CAAC,GAAG,MAAG;AAAG,MAAK,IAAI,IAAI,GAAG,CAAC;AAAA;AAAA,IACpC,YAAY,CAAC,MAAG;AAAG,MAAK,IAAI,OAAO,CAAC;AAAA;AAAA,EACtC;AACF;AAEO,SAAS,iBAAiC;AAC/C,MAAI;AACF,QAAM,KAAK,WAAW,cAChB,QAAQ;AACd,cAAG,QAAQ,OAAO,GAAG,GACrB,GAAG,WAAW,KAAK,GACZ;AAAA,EACT,QAAQ;AACN,WAAO,cAAc;AAAA,EACvB;AACF;AAEO,SAAS,cAAc,SAAyB,QAA+B;AACpF,SAAO;AAAA,IACL,IAAO,KAA4B;AACjC,UAAI;AACF,YAAM,MAAM,QAAQ,QAAQ,GAAG,MAAM,IAAI,GAAG,EAAE;AAC9C,eAAO,OAAO,OAAO,SAAa,KAAK,MAAM,GAAG;AAAA,MAClD,QAAQ;AACN;AAAA,MACF;AAAA,IACF;AAAA,IACA,IAAI,KAAK,OAAO;AACd,UAAI;AACF,QAAI,UAAU,SAAW,QAAQ,WAAW,GAAG,MAAM,IAAI,GAAG,EAAE,IACzD,QAAQ,QAAQ,GAAG,MAAM,IAAI,GAAG,IAAI,KAAK,UAAU,KAAK,CAAC;AAAA,MAChE,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,IACA,OAAO,KAAK;AACV,UAAI;AACF,gBAAQ,WAAW,GAAG,MAAM,IAAI,GAAG,EAAE;AAAA,MACvC,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for building views, actions and extensions.
|
|
3
|
+
* They only add the `type` field and give you type inference — everything is plain data.
|
|
4
|
+
*/
|
|
5
|
+
import type { Action, ChatView, Command, Context, DetailView, Extension, FormView, GridView, ListView, Source, Tool, View } from './types.js';
|
|
6
|
+
type Without<T, K extends keyof T> = Omit<T, K>;
|
|
7
|
+
/** A searchable list of items. */
|
|
8
|
+
export declare function list(view: Without<ListView, 'type'>): ListView;
|
|
9
|
+
/** A grid of images. */
|
|
10
|
+
export declare function grid(view: Without<GridView, 'type'>): GridView;
|
|
11
|
+
/** A markdown document, optionally streamed. */
|
|
12
|
+
export declare function detail(view: Without<DetailView, 'type'>): DetailView;
|
|
13
|
+
/** A form. */
|
|
14
|
+
export declare function form(view: Without<FormView, 'type'>): FormView;
|
|
15
|
+
/** An AI chat. */
|
|
16
|
+
export declare function chat(view?: Without<ChatView, 'type'>): ChatView;
|
|
17
|
+
/** Ready-made actions. */
|
|
18
|
+
export declare const action: {
|
|
19
|
+
/** Copy text to the clipboard. */
|
|
20
|
+
copy(content: string | (() => string), options?: Partial<Action>): Action;
|
|
21
|
+
/** Open an external URL in a new tab. */
|
|
22
|
+
open(url: string, options?: Partial<Action>): Action;
|
|
23
|
+
/** Navigate within your app. */
|
|
24
|
+
navigate(href: string, options?: Partial<Action>): Action;
|
|
25
|
+
/** Navigate in a new tab. */
|
|
26
|
+
navigateNewTab(href: string, options?: Partial<Action>): Action;
|
|
27
|
+
/** Push a view. */
|
|
28
|
+
push(title: string, view: View | ((ctx: Context) => View | Promise<View>), options?: Partial<Action>): Action;
|
|
29
|
+
/** Ask the AI about something. */
|
|
30
|
+
ask(prompt: string, options?: Partial<Action>): Action;
|
|
31
|
+
};
|
|
32
|
+
/** Define an extension (identity function with type inference). */
|
|
33
|
+
export declare function defineExtension<T extends Extension>(extension: T): T;
|
|
34
|
+
/** Define a set of commands. */
|
|
35
|
+
export declare function defineCommands<T extends Command[]>(commands: T): T;
|
|
36
|
+
/** Define a search source. */
|
|
37
|
+
export declare function defineSource(source: Source): Source;
|
|
38
|
+
/** Define an AI tool. */
|
|
39
|
+
export declare function defineTool<Args = Record<string, unknown>>(tool: Tool<Args>): Tool<Args>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ScopedStorage } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tracks how often and how recently items are used, to rank them higher
|
|
4
|
+
* and show them as "Recent".
|
|
5
|
+
*/
|
|
6
|
+
export declare class Frecency {
|
|
7
|
+
private storage;
|
|
8
|
+
private entries;
|
|
9
|
+
constructor(storage: ScopedStorage);
|
|
10
|
+
record(id: string): void;
|
|
11
|
+
/** A score in [0, 1). */
|
|
12
|
+
score(id: string): number;
|
|
13
|
+
/** Ids sorted by score, best first. */
|
|
14
|
+
top(limit: number): string[];
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard shortcut parsing, matching and formatting.
|
|
3
|
+
*
|
|
4
|
+
* Syntax: modifiers joined with `+`, e.g. `"mod+k"`, `"shift+mod+p"`, `"alt+enter"`.
|
|
5
|
+
* `mod` is ⌘ on Apple platforms and Ctrl elsewhere.
|
|
6
|
+
* Sequences are space separated: `"g s"` means press G, then S.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isMac: boolean;
|
|
9
|
+
export interface KeyCombo {
|
|
10
|
+
key: string;
|
|
11
|
+
meta: boolean;
|
|
12
|
+
ctrl: boolean;
|
|
13
|
+
alt: boolean;
|
|
14
|
+
shift: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Parse `"mod+shift+k"` or a sequence `"g s"` into combos. */
|
|
17
|
+
export declare function parseHotkey(hotkey: string): KeyCombo[];
|
|
18
|
+
/** Does a keyboard event match a single combo? */
|
|
19
|
+
export declare function matchesCombo(event: KeyboardEvent, combo: KeyCombo): boolean;
|
|
20
|
+
/** Matches a single-combo hotkey (sequences never match here). */
|
|
21
|
+
export declare function matchesHotkey(event: KeyboardEvent, hotkey: string): boolean;
|
|
22
|
+
/** Format a hotkey as an array of key labels for display, e.g. `["⌘", "K"]`. */
|
|
23
|
+
export declare function formatHotkey(hotkey: string): string[][];
|
|
24
|
+
/** True if the event target is a text field (where single-key shortcuts must not fire). */
|
|
25
|
+
export declare function isEditable(target: EventTarget | null): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Tracks multi-key sequences ("g s") across keydown events.
|
|
28
|
+
*/
|
|
29
|
+
export declare class SequenceMatcher {
|
|
30
|
+
private timeout;
|
|
31
|
+
private buffer;
|
|
32
|
+
private timer;
|
|
33
|
+
constructor(timeout?: number);
|
|
34
|
+
/** Feed an event; returns the hotkeys (from `hotkeys`) that completed. */
|
|
35
|
+
feed(event: KeyboardEvent, hotkeys: string[]): string[];
|
|
36
|
+
reset(): void;
|
|
37
|
+
}
|
|
38
|
+
/** Whether a hotkey may fire while focus is in a text field (it must use a modifier). */
|
|
39
|
+
export declare function allowedInInput(hotkey: string): boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tiny shell that implements the full Qikbar API, listens for the hotkey and
|
|
3
|
+
* loads the UI chunk when the browser is idle (or immediately on first use).
|
|
4
|
+
* Calls made before the UI loads are queued and replayed in order.
|
|
5
|
+
*/
|
|
6
|
+
import type { Bar } from '../ui/bar.js';
|
|
7
|
+
import type { AIClient, Extension, Item, QikbarConfig, QikbarEvents, QikbarInstance, Source, ToastHandle, ToastOptions, View } from './types.js';
|
|
8
|
+
type Loader = () => Promise<{
|
|
9
|
+
Bar: typeof Bar;
|
|
10
|
+
}>;
|
|
11
|
+
export declare class LazyQikbar implements QikbarInstance {
|
|
12
|
+
private loader;
|
|
13
|
+
private bar?;
|
|
14
|
+
private loading?;
|
|
15
|
+
private queue;
|
|
16
|
+
private config;
|
|
17
|
+
private teardown;
|
|
18
|
+
private destroyed;
|
|
19
|
+
constructor(config: QikbarConfig, loader: Loader);
|
|
20
|
+
/** Load the UI now. Resolves when ready. */
|
|
21
|
+
preload(): Promise<void>;
|
|
22
|
+
private load;
|
|
23
|
+
private run;
|
|
24
|
+
/** Queue a call that returns a disposer; the disposer works before and after loading. */
|
|
25
|
+
private disposable;
|
|
26
|
+
get isOpen(): boolean;
|
|
27
|
+
get query(): string;
|
|
28
|
+
get ai(): AIClient | undefined;
|
|
29
|
+
open(options?: {
|
|
30
|
+
query?: string;
|
|
31
|
+
view?: View;
|
|
32
|
+
}): void;
|
|
33
|
+
close(): void;
|
|
34
|
+
toggle(): void;
|
|
35
|
+
register(commands: Item | Item[]): () => void;
|
|
36
|
+
addSource(source: Source): () => void;
|
|
37
|
+
use(extension: Extension, preferences?: Record<string, any>): () => void;
|
|
38
|
+
configure(config: Partial<QikbarConfig>): void;
|
|
39
|
+
push(view: View): void;
|
|
40
|
+
pop(): void;
|
|
41
|
+
setQuery(query: string): void;
|
|
42
|
+
ask(prompt?: string): void;
|
|
43
|
+
toast(options: ToastOptions | string): ToastHandle;
|
|
44
|
+
commands(): Item[];
|
|
45
|
+
on<K extends keyof QikbarEvents>(event: K, handler: (payload: QikbarEvents[K]) => void): () => void;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small, fast fuzzy matcher tuned for command palettes.
|
|
3
|
+
*
|
|
4
|
+
* It favours matches at word boundaries, camelCase humps and consecutive runs
|
|
5
|
+
* ("gs" → "**G**it **S**tatus", "set" → "**Set**tings"), runs in linear time
|
|
6
|
+
* per field and needs no index build step.
|
|
7
|
+
*/
|
|
8
|
+
import type { Item } from './types.js';
|
|
9
|
+
export interface FuzzyMatch {
|
|
10
|
+
/** 0 (bad) … 1 (exact). */
|
|
11
|
+
score: number;
|
|
12
|
+
/** Indices of matched characters in the target. */
|
|
13
|
+
positions: number[];
|
|
14
|
+
}
|
|
15
|
+
/** Lowercase and strip diacritics, keeping indices aligned with the original string. */
|
|
16
|
+
export declare function normalize(text: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Match `query` against `target`.
|
|
19
|
+
* `query` must already be normalized (see `normalize`); `targetNorm` defaults to `normalize(target)`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function fuzzyMatch(query: string, target: string, targetNorm?: string): FuzzyMatch | null;
|
|
22
|
+
export interface ItemMatch {
|
|
23
|
+
score: number;
|
|
24
|
+
/** Matched character indices in the title, for highlighting. */
|
|
25
|
+
positions: number[];
|
|
26
|
+
}
|
|
27
|
+
/** Score an item against a query. Returns null when it doesn't match. */
|
|
28
|
+
export declare function matchItem(item: Item, query: string): ItemMatch | null;
|
|
29
|
+
export interface RankedItem<T extends Item = Item> {
|
|
30
|
+
item: T;
|
|
31
|
+
score: number;
|
|
32
|
+
positions: number[];
|
|
33
|
+
}
|
|
34
|
+
export interface RankOptions {
|
|
35
|
+
/** Extra score per item (e.g. frecency), added after matching. */
|
|
36
|
+
boost?: (item: Item) => number;
|
|
37
|
+
limit?: number;
|
|
38
|
+
/** Drop matches below this score. Default 0.05. */
|
|
39
|
+
threshold?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Filter and sort items by relevance to `query`. Stable for equal scores. */
|
|
42
|
+
export declare function rank<T extends Item>(items: readonly T[], query: string, options?: RankOptions): RankedItem<T>[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ScopedStorage, StorageAdapter } from './types.js';
|
|
2
|
+
/** In-memory storage, used during SSR or when localStorage is unavailable. */
|
|
3
|
+
export declare function memoryStorage(): StorageAdapter;
|
|
4
|
+
export declare function defaultStorage(): StorageAdapter;
|
|
5
|
+
export declare function scopedStorage(adapter: StorageAdapter, prefix: string): ScopedStorage;
|