@qikbar/qikbar 0.1.0 → 0.2.1

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 (67) hide show
  1. package/README.md +30 -1
  2. package/bin/qikbar.mjs +203 -0
  3. package/dist/ai/embeddings.d.ts +51 -0
  4. package/dist/ai/index.d.ts +4 -0
  5. package/dist/ai/mcp.d.ts +84 -0
  6. package/dist/ai.js +27 -9
  7. package/dist/chunks/{bar-D5CSPT3U.js → bar-P3SCR4SJ.js} +684 -160
  8. package/dist/chunks/bar-P3SCR4SJ.js.map +7 -0
  9. package/dist/chunks/chunk-24EBWTCF.js +271 -0
  10. package/dist/chunks/chunk-24EBWTCF.js.map +7 -0
  11. package/dist/chunks/{chunk-I77YSUJN.js → chunk-INTEVQYK.js} +7 -3
  12. package/dist/chunks/{chunk-I77YSUJN.js.map → chunk-INTEVQYK.js.map} +2 -2
  13. package/dist/chunks/{chunk-VXTYD56F.js → chunk-JHQAIXM7.js} +9 -4
  14. package/dist/chunks/{chunk-VXTYD56F.js.map → chunk-JHQAIXM7.js.map} +2 -2
  15. package/dist/chunks/{chunk-2ADXL7KQ.js → chunk-MRHKJ2FZ.js} +63 -2
  16. package/dist/chunks/{chunk-2ADXL7KQ.js.map → chunk-MRHKJ2FZ.js.map} +3 -3
  17. package/dist/chunks/{chunk-IJ3WUM3T.js → chunk-R2AY6LRL.js} +35 -4
  18. package/dist/chunks/chunk-R2AY6LRL.js.map +7 -0
  19. package/dist/chunks/chunk-TIM4VBM4.js +98 -0
  20. package/dist/chunks/chunk-TIM4VBM4.js.map +7 -0
  21. package/dist/chunks/{chunk-HBBSETRF.js → chunk-WO6XXQ3H.js} +47 -6
  22. package/dist/chunks/chunk-WO6XXQ3H.js.map +7 -0
  23. package/dist/chunks/launcher-B5MGOPEQ.js +37 -0
  24. package/dist/chunks/launcher-B5MGOPEQ.js.map +7 -0
  25. package/dist/core/labels.d.ts +98 -0
  26. package/dist/core/launcher.d.ts +8 -0
  27. package/dist/core/lazy.d.ts +12 -0
  28. package/dist/core/types.d.ts +138 -2
  29. package/dist/element/index.d.ts +56 -0
  30. package/dist/element.js +145 -0
  31. package/dist/element.js.map +7 -0
  32. package/dist/extensions.js +1 -1
  33. package/dist/index.d.ts +4 -1
  34. package/dist/index.js +19 -7
  35. package/dist/locales/index.d.ts +24 -0
  36. package/dist/locales.js +812 -0
  37. package/dist/locales.js.map +7 -0
  38. package/dist/qikbar.global.js +68 -25
  39. package/dist/qikbar.global.js.map +4 -4
  40. package/dist/react.js +7 -6
  41. package/dist/react.js.map +2 -2
  42. package/dist/server/index.d.ts +19 -0
  43. package/dist/server.js +38 -2
  44. package/dist/server.js.map +2 -2
  45. package/dist/solid/index.d.ts +42 -0
  46. package/dist/solid.js +92 -0
  47. package/dist/solid.js.map +7 -0
  48. package/dist/styles.css +34 -3
  49. package/dist/svelte/index.d.ts +58 -0
  50. package/dist/svelte.js +54 -0
  51. package/dist/svelte.js.map +7 -0
  52. package/dist/theme.js +1 -1
  53. package/dist/ui/bar.d.ts +89 -3
  54. package/dist/ui/icons.d.ts +5 -0
  55. package/dist/ui/markdown.d.ts +3 -1
  56. package/dist/ui/views.d.ts +8 -0
  57. package/dist/ui/webmcp.d.ts +33 -0
  58. package/dist/utils.js +1 -1
  59. package/dist/vue/index.d.ts +74 -0
  60. package/dist/vue.js +121 -0
  61. package/dist/vue.js.map +7 -0
  62. package/package.json +45 -4
  63. package/dist/chunks/bar-D5CSPT3U.js.map +0 -7
  64. package/dist/chunks/chunk-6TC6G2C5.js +0 -107
  65. package/dist/chunks/chunk-6TC6G2C5.js.map +0 -7
  66. package/dist/chunks/chunk-HBBSETRF.js.map +0 -7
  67. package/dist/chunks/chunk-IJ3WUM3T.js.map +0 -7
@@ -5,6 +5,8 @@
5
5
  * objects you can create in any framework (or none) and that an AI model can
6
6
  * reason about.
7
7
  */
8
+ import type { Labels } from './labels.js';
9
+ export type { Labels } from './labels.js';
8
10
  export type Awaitable<T> = T | Promise<T>;
9
11
  /**
10
12
  * What `run`, actions and form submissions may return:
@@ -80,13 +82,27 @@ export interface Context {
80
82
  confirm(options: ConfirmOptions | string): Promise<boolean>;
81
83
  /** Set the search text. */
82
84
  setQuery(query: string): void;
85
+ /** Items the user marked in a `multiSelect` list (empty otherwise). */
86
+ readonly selection: Item[];
87
+ /** The bar's labels (after `labels` overrides), for translated messages. */
88
+ readonly labels: Labels;
83
89
  }
84
90
  export interface ToastOptions {
85
91
  title: string;
86
92
  message?: string;
87
93
  style?: 'success' | 'failure' | 'loading' | 'info';
88
- /** Milliseconds before the toast hides. `0` keeps it. Default 2500 (loading toasts persist). */
94
+ /** Milliseconds before the toast hides. `0` keeps it. Default 2600, or 6000 with an action (loading toasts persist). */
89
95
  duration?: number;
96
+ /** A button in the toast, e.g. "View" or "Retry". */
97
+ action?: ToastAction;
98
+ /** Shorthand for an "Undo" action bound to ⌘Z / Ctrl+Z while the toast is visible. */
99
+ undo?: () => Awaitable<void>;
100
+ }
101
+ export interface ToastAction {
102
+ title: string;
103
+ /** Shortcut that triggers the action while the toast is visible, e.g. `"mod+z"`. */
104
+ shortcut?: string;
105
+ run(): Awaitable<void>;
90
106
  }
91
107
  export interface ToastHandle {
92
108
  update(options: Partial<ToastOptions>): void;
@@ -114,6 +130,13 @@ export interface Action {
114
130
  */
115
131
  run(ctx: Context): Awaitable<RunResult>;
116
132
  keepOpen?: boolean;
133
+ /**
134
+ * Run the action on several items at once. When the user has marked items in a
135
+ * `multiSelect` list, only actions with `runMany` are offered.
136
+ */
137
+ runMany?(items: Item[], ctx: Context): Awaitable<RunResult>;
138
+ /** @internal Label used for the title of built-in actions, so `labels` can translate it. */
139
+ labelKey?: keyof Labels;
117
140
  }
118
141
  /** A row in a list or grid, or a command at the root. */
119
142
  export interface Item {
@@ -204,6 +227,11 @@ export interface ListView extends BaseView {
204
227
  emptyView?: EmptyView;
205
228
  /** Initial search text. */
206
229
  query?: string;
230
+ /**
231
+ * Let the user mark several items (Shift/⌘-click, Shift+↑↓, or "Select" in the
232
+ * action panel) and run an action with `runMany` on all of them.
233
+ */
234
+ multiSelect?: boolean;
207
235
  }
208
236
  export interface GridView extends Omit<ListView, 'type' | 'detail'> {
209
237
  type: 'grid';
@@ -522,10 +550,102 @@ export interface QikbarConfig {
522
550
  branding?: boolean;
523
551
  /** Footer hint shown at the left when idle. */
524
552
  footer?: string;
553
+ /** Translate or reword the UI. See `@qikbar/qikbar/locales` for ready-made translations. */
554
+ labels?: Partial<Labels>;
555
+ /** Let users pin commands to the top and give them aliases. Default true. */
556
+ personalize?: boolean;
557
+ /** Search by meaning as well as by spelling, with embeddings you provide. */
558
+ semantic?: SemanticOptions;
559
+ /** Touch-friendly layout: hides keyboard hints and enables long-press. Default `"auto"` (detects touch screens). */
560
+ touch?: boolean | 'auto';
561
+ /** A floating button that opens the bar, for touch devices and mouse users. */
562
+ launcher?: boolean | 'touch' | LauncherOptions;
563
+ /** Expose your commands to AI agents in the browser through WebMCP (`document.modelContext`). */
564
+ webmcp?: boolean | WebMCPOptions;
525
565
  onOpen?: () => void;
526
566
  onClose?: () => void;
527
567
  /** Called whenever an item or action runs. Useful for analytics. */
528
568
  onRun?: (item: Item, action: Action) => void;
569
+ /** Usage events (open, search, run, no results, …) for analytics. */
570
+ onEvent?: (event: QikbarEvent) => void;
571
+ }
572
+ export interface SemanticOptions {
573
+ /** Turn texts into embedding vectors. Use `openaiEmbeddings()`, `ollamaEmbeddings()` or your own. */
574
+ embed(texts: string[], options: {
575
+ signal: AbortSignal;
576
+ }): Promise<number[][]>;
577
+ /** Minimum cosine similarity for a result (0–1). Default 0.35. */
578
+ threshold?: number;
579
+ /** Maximum "Related" results. Default 5. */
580
+ limit?: number;
581
+ /** Minimum query length. Default 3. */
582
+ minQueryLength?: number;
583
+ /** Debounce in ms. Default 250. */
584
+ debounce?: number;
585
+ /** Also embed results from sources. Default false (only commands, routes and extension commands). */
586
+ sources?: boolean;
587
+ }
588
+ export interface LauncherOptions {
589
+ /** Default `"bottom-right"`. */
590
+ position?: 'bottom-right' | 'bottom-left';
591
+ /** Accessible label. Default `labels.openCommandBar`. */
592
+ label?: string;
593
+ /** Only show on touch devices. Default false. */
594
+ touchOnly?: boolean;
595
+ /** Icon name or SVG. Default `"search"`. */
596
+ icon?: string;
597
+ /** Distance from the edges in px. Default 20. */
598
+ offset?: number;
599
+ }
600
+ export interface WebMCPOptions {
601
+ /** Prefix for tool names. Default `"qikbar"`. */
602
+ prefix?: string;
603
+ /** Also expose `ai.tools` and extension tools. Default true. */
604
+ tools?: boolean;
605
+ /** Let agents run commands (otherwise only search/list). Default true. */
606
+ run?: boolean;
607
+ }
608
+ /** A usage event, for analytics. Item details are limited to id, title and section. */
609
+ export type QikbarEvent = {
610
+ type: 'open';
611
+ } | {
612
+ type: 'close';
613
+ } | {
614
+ type: 'search';
615
+ query: string;
616
+ results: number;
617
+ view: string;
618
+ } | {
619
+ type: 'no_results';
620
+ query: string;
621
+ view: string;
622
+ } | {
623
+ type: 'run';
624
+ item: EventItem;
625
+ action: string;
626
+ via: 'keyboard' | 'click' | 'shortcut' | 'panel' | 'ai' | 'agent';
627
+ count?: number;
628
+ } | {
629
+ type: 'ask_ai';
630
+ prompt: string;
631
+ } | {
632
+ type: 'pin' | 'unpin';
633
+ item: EventItem;
634
+ } | {
635
+ type: 'alias';
636
+ item: EventItem;
637
+ alias: string | null;
638
+ } | {
639
+ type: 'undo';
640
+ title: string;
641
+ } | {
642
+ type: 'error';
643
+ message: string;
644
+ };
645
+ export interface EventItem {
646
+ id: string;
647
+ title: string;
648
+ section?: string;
529
649
  }
530
650
  export interface AutoIndexOptions {
531
651
  /** CSS selector for links to index. Default `"nav a[href], header a[href], aside a[href], [data-qikbar-index] a[href]"`. */
@@ -549,6 +669,8 @@ export interface AIOptions {
549
669
  maxSteps?: number;
550
670
  /** Example prompts shown in an empty chat. */
551
671
  suggestions?: string[];
672
+ /** Remote tools from MCP servers, e.g. `[mcp({ url: '/api/mcp' })]`. */
673
+ mcp?: ToolProvider[];
552
674
  /** Let the AI read the current page's text when asked about it. Default true. */
553
675
  pageContext?: boolean;
554
676
  }
@@ -566,6 +688,13 @@ export interface QikbarEvents {
566
688
  item: Item;
567
689
  action: Action;
568
690
  };
691
+ event: QikbarEvent;
692
+ }
693
+ /** Something that supplies AI tools asynchronously, like an MCP server. */
694
+ export interface ToolProvider {
695
+ readonly name: string;
696
+ /** Load (or reload) the tools. Called before each chat turn; cache inside. */
697
+ tools(signal?: AbortSignal): Promise<Tool[]>;
569
698
  }
570
699
  export interface QikbarInstance {
571
700
  open(options?: {
@@ -596,6 +725,13 @@ export interface QikbarInstance {
596
725
  on<K extends keyof QikbarEvents>(event: K, handler: (payload: QikbarEvents[K]) => void): () => void;
597
726
  /** Load the UI ahead of time (it otherwise loads when the browser is idle). */
598
727
  preload(): Promise<void>;
728
+ /** Pinned item ids, most recent first. */
729
+ pins(): string[];
730
+ /** Pin or unpin an item by id. */
731
+ pin(id: string, pinned?: boolean): void;
732
+ /** Aliases, as `{ alias: itemId }`. */
733
+ aliases(): Record<string, string>;
734
+ /** Set (or with `null`, remove) the alias for an item. */
735
+ setAlias(id: string, alias: string | null): void;
599
736
  destroy(): void;
600
737
  }
601
- export {};
@@ -0,0 +1,56 @@
1
+ /**
2
+ * `<qik-bar>`: Qikbar as a custom element. Works in plain HTML, HTMX, Angular,
3
+ * Rails, Django, Laravel — anywhere you can write a tag.
4
+ *
5
+ * ```html
6
+ * <script type="module">import '@qikbar/qikbar/element'</script>
7
+ *
8
+ * <qik-bar placeholder="Search Acme…" launcher="touch">
9
+ * <qik-command href="/settings" section="Navigation" icon="settings">Settings</qik-command>
10
+ * <qik-command id="theme" shortcut="mod+shift+l">Toggle theme</qik-command>
11
+ * </qik-bar>
12
+ *
13
+ * <script>
14
+ * document.getElementById('theme').addEventListener('run', toggleTheme)
15
+ * </script>
16
+ * ```
17
+ *
18
+ * Set the `config` property for anything attributes can't express (sources,
19
+ * extensions, AI). Events: `qikbar-open`, `qikbar-close`, `qikbar-run`, `qikbar-event`.
20
+ */
21
+ import type { QikbarConfig, QikbarInstance } from '../core/types.js';
22
+ declare const Base: typeof HTMLElement;
23
+ export declare class QikbarElement extends Base {
24
+ static get observedAttributes(): ("placeholder" | "footer" | "touch" | "hotkey" | "theme" | "appearance" | "inline" | "namespace" | "launcher" | "webmcp")[];
25
+ private instance?;
26
+ private extra;
27
+ private unregister?;
28
+ private observer?;
29
+ private offs;
30
+ /** The Qikbar instance (created when the element connects). */
31
+ get bar(): QikbarInstance | undefined;
32
+ /** Extra configuration: sources, extensions, ai, navigate, … Merged over attributes. */
33
+ get config(): QikbarConfig;
34
+ set config(value: QikbarConfig);
35
+ private attrConfig;
36
+ private fullConfig;
37
+ /** Inline bars render into a child so `<qik-command>` markup is untouched. */
38
+ private mountPoint;
39
+ connectedCallback(): void;
40
+ disconnectedCallback(): void;
41
+ attributeChangedCallback(name: string, oldValue: string | null, value: string | null): void;
42
+ private remount;
43
+ private syncCommands;
44
+ open(options?: Parameters<QikbarInstance['open']>[0]): void;
45
+ close(): void;
46
+ toggle(): void;
47
+ ask(prompt?: string): void;
48
+ }
49
+ /** Register the element (done automatically on import with the default tag). */
50
+ export declare function defineQikbarElement(tag?: string): void;
51
+ declare global {
52
+ interface HTMLElementTagNameMap {
53
+ 'qik-bar': QikbarElement;
54
+ }
55
+ }
56
+ export {};
@@ -0,0 +1,145 @@
1
+ import {
2
+ createQikbar
3
+ } from "./chunks/chunk-WO6XXQ3H.js";
4
+ import "./chunks/chunk-24EBWTCF.js";
5
+ import "./chunks/chunk-N4Y2Z6YD.js";
6
+ import "./chunks/chunk-MRHKJ2FZ.js";
7
+ import "./chunks/chunk-INTEVQYK.js";
8
+ import "./chunks/chunk-YCVJQ7U3.js";
9
+ import "./chunks/chunk-PQEHV3D4.js";
10
+ import {
11
+ __publicField
12
+ } from "./chunks/chunk-MPTP2EWW.js";
13
+
14
+ // src/element/index.ts
15
+ var Base = typeof HTMLElement < "u" ? HTMLElement : class {
16
+ }, ATTRS = ["placeholder", "hotkey", "theme", "appearance", "inline", "namespace", "launcher", "touch", "webmcp", "footer"];
17
+ function readCommands(host) {
18
+ return [...host.querySelectorAll(":scope > qik-command, :scope > qik-commands > qik-command")].map((el, i) => {
19
+ let attr = (name) => el.getAttribute(name) ?? void 0, title = attr("title") ?? (el.textContent ?? "").replace(/\s+/g, " ").trim(), item = {
20
+ id: el.id || attr("command-id") || `el:${i}:${title}`,
21
+ title,
22
+ subtitle: attr("subtitle"),
23
+ description: attr("description"),
24
+ section: attr("section") ?? el.closest("qik-commands")?.getAttribute("section") ?? void 0,
25
+ icon: attr("icon"),
26
+ keywords: attr("keywords")?.split(",").map((k) => k.trim()).filter(Boolean),
27
+ shortcut: attr("shortcut"),
28
+ href: attr("href"),
29
+ url: attr("url")
30
+ };
31
+ return !item.href && !item.url && (item.run = () => {
32
+ let ev = new CustomEvent("run", { bubbles: !0, cancelable: !0, detail: { item } });
33
+ return el.dispatchEvent(ev), el.hasAttribute("keep-open") ? !1 : void 0;
34
+ }), item;
35
+ });
36
+ }
37
+ var QikbarElement = class extends Base {
38
+ constructor() {
39
+ super(...arguments);
40
+ __publicField(this, "instance");
41
+ __publicField(this, "extra", {});
42
+ __publicField(this, "unregister");
43
+ __publicField(this, "observer");
44
+ __publicField(this, "offs", []);
45
+ }
46
+ static get observedAttributes() {
47
+ return [...ATTRS];
48
+ }
49
+ /** The Qikbar instance (created when the element connects). */
50
+ get bar() {
51
+ return this.instance;
52
+ }
53
+ /** Extra configuration: sources, extensions, ai, navigate, … Merged over attributes. */
54
+ get config() {
55
+ return this.extra;
56
+ }
57
+ set config(value) {
58
+ let prev = this.extra;
59
+ if (this.extra = { ...value }, !this.instance) return;
60
+ let changed = {};
61
+ for (let key of /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(this.extra)]))
62
+ Object.is(prev[key], this.extra[key]) || (changed[key] = this.extra[key]);
63
+ "inline" in changed ? this.remount() : this.instance.configure(changed);
64
+ }
65
+ attrConfig() {
66
+ let a = (name) => this.getAttribute(name), flag = (name) => {
67
+ let v = a(name);
68
+ return v == null ? void 0 : v === "" || v === "true" ? !0 : v === "false" ? !1 : v;
69
+ }, out = {};
70
+ a("placeholder") != null && (out.placeholder = a("placeholder"));
71
+ let hotkey = a("hotkey");
72
+ hotkey != null && (out.hotkey = hotkey === "false" || hotkey === "none" ? !1 : hotkey.split(/\s*,\s*/)), a("theme") && (out.theme = a("theme")), a("appearance") && (out.appearance = a("appearance")), a("namespace") && (out.namespace = a("namespace")), a("footer") && (out.footer = a("footer"));
73
+ let launcher = flag("launcher");
74
+ launcher !== void 0 && (out.launcher = launcher === "touch" ? "touch" : !!launcher);
75
+ let touch = flag("touch");
76
+ touch !== void 0 && (out.touch = touch === "auto" ? "auto" : !!touch);
77
+ let webmcp = flag("webmcp");
78
+ return webmcp !== void 0 && (out.webmcp = !!webmcp), out;
79
+ }
80
+ fullConfig() {
81
+ let config = { ...this.attrConfig(), ...this.extra };
82
+ return this.hasAttribute("inline") && (config.inline = this.mountPoint()), config;
83
+ }
84
+ /** Inline bars render into a child so `<qik-command>` markup is untouched. */
85
+ mountPoint() {
86
+ let el = this.querySelector(":scope > [data-qikbar-mount]");
87
+ return el || (el = document.createElement("div"), el.dataset.qikbarMount = "", this.append(el)), el;
88
+ }
89
+ connectedCallback() {
90
+ if (this.instance) return;
91
+ this.hasAttribute("inline") || (this.style.display = "contents");
92
+ let bar = createQikbar(this.fullConfig());
93
+ this.instance = bar;
94
+ let fire = (type, detail) => this.dispatchEvent(new CustomEvent(type, { detail, bubbles: !0, composed: !0 }));
95
+ this.offs.push(
96
+ bar.on("open", () => fire("qikbar-open")),
97
+ bar.on("close", () => fire("qikbar-close")),
98
+ bar.on("run", (detail) => fire("qikbar-run", detail)),
99
+ bar.on("event", (detail) => fire("qikbar-event", detail))
100
+ ), this.syncCommands(), this.observer = new MutationObserver((records) => {
101
+ records.some((r) => !r.target.closest?.("[data-qikbar-mount], .qb-root")) && this.syncCommands();
102
+ }), this.observer.observe(this, { childList: !0, subtree: !0, attributes: !0, characterData: !0 });
103
+ }
104
+ disconnectedCallback() {
105
+ this.observer?.disconnect(), this.observer = void 0;
106
+ for (let off of this.offs) off();
107
+ this.offs = [], this.unregister?.(), this.unregister = void 0, this.instance?.destroy(), this.instance = void 0, this.querySelector(":scope > [data-qikbar-mount]")?.remove();
108
+ }
109
+ attributeChangedCallback(name, oldValue, value) {
110
+ if (!(!this.instance || oldValue === value)) {
111
+ if (name === "inline") return this.remount();
112
+ this.instance.configure(this.attrConfig());
113
+ }
114
+ }
115
+ remount() {
116
+ this.disconnectedCallback(), this.connectedCallback();
117
+ }
118
+ syncCommands() {
119
+ this.unregister?.();
120
+ let commands = readCommands(this);
121
+ this.unregister = commands.length ? this.instance?.register(commands) : void 0;
122
+ }
123
+ open(options) {
124
+ this.instance?.open(options);
125
+ }
126
+ close() {
127
+ this.instance?.close();
128
+ }
129
+ toggle() {
130
+ this.instance?.toggle();
131
+ }
132
+ ask(prompt) {
133
+ this.instance?.ask(prompt);
134
+ }
135
+ };
136
+ function defineQikbarElement(tag = "qik-bar") {
137
+ typeof customElements > "u" || customElements.get(tag) || customElements.define(tag, class extends QikbarElement {
138
+ });
139
+ }
140
+ defineQikbarElement();
141
+ export {
142
+ QikbarElement,
143
+ defineQikbarElement
144
+ };
145
+ //# sourceMappingURL=element.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/element/index.ts"],
4
+ "sourcesContent": ["/**\n * `<qik-bar>`: Qikbar as a custom element. Works in plain HTML, HTMX, Angular,\n * Rails, Django, Laravel \u2014 anywhere you can write a tag.\n *\n * ```html\n * <script type=\"module\">import '@qikbar/qikbar/element'</script>\n *\n * <qik-bar placeholder=\"Search Acme\u2026\" launcher=\"touch\">\n * <qik-command href=\"/settings\" section=\"Navigation\" icon=\"settings\">Settings</qik-command>\n * <qik-command id=\"theme\" shortcut=\"mod+shift+l\">Toggle theme</qik-command>\n * </qik-bar>\n *\n * <script>\n * document.getElementById('theme').addEventListener('run', toggleTheme)\n * </script>\n * ```\n *\n * Set the `config` property for anything attributes can't express (sources,\n * extensions, AI). Events: `qikbar-open`, `qikbar-close`, `qikbar-run`, `qikbar-event`.\n */\n\nimport { createQikbar } from '../index.js'\nimport type { Appearance, Item, QikbarConfig, QikbarInstance, ThemePresetName } from '../core/types.js'\n\nconst Base: typeof HTMLElement = typeof HTMLElement !== 'undefined' ? HTMLElement : (class {} as unknown as typeof HTMLElement)\n\nconst ATTRS = ['placeholder', 'hotkey', 'theme', 'appearance', 'inline', 'namespace', 'launcher', 'touch', 'webmcp', 'footer'] as const\n\n/** Read `<qik-command>` children into commands. */\nfunction readCommands(host: HTMLElement): Item[] {\n return [...host.querySelectorAll<HTMLElement>(':scope > qik-command, :scope > qik-commands > qik-command')].map((el, i) => {\n const attr = (name: string) => el.getAttribute(name) ?? undefined\n const title = attr('title') ?? (el.textContent ?? '').replace(/\\s+/g, ' ').trim()\n const item: Item = {\n id: el.id || attr('command-id') || `el:${i}:${title}`,\n title,\n subtitle: attr('subtitle'),\n description: attr('description'),\n section: attr('section') ?? el.closest('qik-commands')?.getAttribute('section') ?? undefined,\n icon: attr('icon'),\n keywords: attr('keywords')\n ?.split(',')\n .map((k) => k.trim())\n .filter(Boolean),\n shortcut: attr('shortcut'),\n href: attr('href'),\n url: attr('url'),\n }\n if (!item.href && !item.url) {\n item.run = () => {\n const ev = new CustomEvent('run', { bubbles: true, cancelable: true, detail: { item } })\n el.dispatchEvent(ev)\n return el.hasAttribute('keep-open') ? false : undefined\n }\n }\n return item\n })\n}\n\nexport class QikbarElement extends Base {\n static get observedAttributes() {\n return [...ATTRS]\n }\n\n private instance?: QikbarInstance\n private extra: QikbarConfig = {}\n private unregister?: () => void\n private observer?: MutationObserver\n private offs: (() => void)[] = []\n\n /** The Qikbar instance (created when the element connects). */\n get bar(): QikbarInstance | undefined {\n return this.instance\n }\n\n /** Extra configuration: sources, extensions, ai, navigate, \u2026 Merged over attributes. */\n get config(): QikbarConfig {\n return this.extra\n }\n set config(value: QikbarConfig) {\n const prev = this.extra\n this.extra = { ...value }\n if (!this.instance) return\n const changed: Partial<QikbarConfig> = {}\n for (const key of new Set([...Object.keys(prev), ...Object.keys(this.extra)]) as Set<keyof QikbarConfig>) {\n if (!Object.is(prev[key], this.extra[key])) (changed as any)[key] = this.extra[key]\n }\n if ('inline' in changed) this.remount()\n else this.instance.configure(changed)\n }\n\n private attrConfig(): QikbarConfig {\n const a = (name: string) => this.getAttribute(name)\n const flag = (name: string) => {\n const v = a(name)\n return v == null ? undefined : v === '' || v === 'true' ? true : v === 'false' ? false : v\n }\n const out: QikbarConfig = {}\n if (a('placeholder') != null) out.placeholder = a('placeholder')!\n const hotkey = a('hotkey')\n if (hotkey != null) out.hotkey = hotkey === 'false' || hotkey === 'none' ? false : hotkey.split(/\\s*,\\s*/)\n if (a('theme')) out.theme = a('theme') as ThemePresetName\n if (a('appearance')) out.appearance = a('appearance') as Appearance\n if (a('namespace')) out.namespace = a('namespace')!\n if (a('footer')) out.footer = a('footer')!\n const launcher = flag('launcher')\n if (launcher !== undefined) out.launcher = launcher === 'touch' ? 'touch' : !!launcher\n const touch = flag('touch')\n if (touch !== undefined) out.touch = touch === 'auto' ? 'auto' : !!touch\n const webmcp = flag('webmcp')\n if (webmcp !== undefined) out.webmcp = !!webmcp\n return out\n }\n\n private fullConfig(): QikbarConfig {\n const config: QikbarConfig = { ...this.attrConfig(), ...this.extra }\n if (this.hasAttribute('inline')) config.inline = this.mountPoint()\n return config\n }\n\n /** Inline bars render into a child so `<qik-command>` markup is untouched. */\n private mountPoint(): HTMLElement {\n let el = this.querySelector<HTMLElement>(':scope > [data-qikbar-mount]')\n if (!el) {\n el = document.createElement('div')\n el.dataset.qikbarMount = ''\n this.append(el)\n }\n return el\n }\n\n connectedCallback() {\n if (this.instance) return\n if (!this.hasAttribute('inline')) this.style.display = 'contents'\n const bar = createQikbar(this.fullConfig())\n this.instance = bar\n const fire = (type: string, detail?: unknown) => this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }))\n this.offs.push(\n bar.on('open', () => fire('qikbar-open')),\n bar.on('close', () => fire('qikbar-close')),\n bar.on('run', (detail) => fire('qikbar-run', detail)),\n bar.on('event', (detail) => fire('qikbar-event', detail)),\n )\n this.syncCommands()\n this.observer = new MutationObserver((records) => {\n if (records.some((r) => !(r.target as Element).closest?.('[data-qikbar-mount], .qb-root'))) this.syncCommands()\n })\n this.observer.observe(this, { childList: true, subtree: true, attributes: true, characterData: true })\n }\n\n disconnectedCallback() {\n this.observer?.disconnect()\n this.observer = undefined\n for (const off of this.offs) off()\n this.offs = []\n this.unregister?.()\n this.unregister = undefined\n this.instance?.destroy()\n this.instance = undefined\n this.querySelector(':scope > [data-qikbar-mount]')?.remove()\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, value: string | null) {\n if (!this.instance || oldValue === value) return\n if (name === 'inline') return this.remount()\n this.instance.configure(this.attrConfig())\n }\n\n private remount() {\n this.disconnectedCallback()\n this.connectedCallback()\n }\n\n private syncCommands() {\n this.unregister?.()\n const commands = readCommands(this)\n this.unregister = commands.length ? this.instance?.register(commands) : undefined\n }\n\n open(options?: Parameters<QikbarInstance['open']>[0]) {\n this.instance?.open(options)\n }\n close() {\n this.instance?.close()\n }\n toggle() {\n this.instance?.toggle()\n }\n ask(prompt?: string) {\n this.instance?.ask(prompt)\n }\n}\n\n/** Register the element (done automatically on import with the default tag). */\nexport function defineQikbarElement(tag = 'qik-bar') {\n if (typeof customElements === 'undefined' || customElements.get(tag)) return\n customElements.define(tag, class extends QikbarElement {})\n}\n\ndefineQikbarElement()\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qik-bar': QikbarElement\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAwBA,IAAM,OAA2B,OAAO,cAAgB,MAAc,cAAe,MAAM;AAAC,GAEtF,QAAQ,CAAC,eAAe,UAAU,SAA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AAA,EAAC,CAAC;AAC3D;AAEA,oBAAoB;",
6
+ "names": []
7
+ }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  action
3
- } from "./chunks/chunk-I77YSUJN.js";
3
+ } from "./chunks/chunk-INTEVQYK.js";
4
4
  import {
5
5
  formatHotkey,
6
6
  isMac
package/dist/index.d.ts CHANGED
@@ -24,4 +24,7 @@ export { formatHotkey, isMac, matchesHotkey, parseHotkey } from './core/hotkeys.
24
24
  export { memoryStorage } from './core/storage.js';
25
25
  export { anthropic, browserAI, byok, gemini, ollama, openai, openaiCompatible, proxy } from './ai/index.js';
26
26
  export type { AnthropicOptions, ByokOptions, GeminiOptions, OpenAIOptions, ProxyOptions } from './ai/index.js';
27
- export declare const version = "0.1.0";
27
+ export { mcp } from './ai/mcp.js';
28
+ export type { MCPOptions } from './ai/mcp.js';
29
+ export { cachedEmbeddings, geminiEmbeddings, ollamaEmbeddings, openaiEmbeddings, proxyEmbeddings } from './ai/embeddings.js';
30
+ export declare const version = "0.2.1";
package/dist/index.js CHANGED
@@ -1,20 +1,26 @@
1
1
  import {
2
2
  createQikbar,
3
3
  version
4
- } from "./chunks/chunk-HBBSETRF.js";
4
+ } from "./chunks/chunk-WO6XXQ3H.js";
5
5
  import {
6
- byok
7
- } from "./chunks/chunk-6TC6G2C5.js";
6
+ byok,
7
+ mcp
8
+ } from "./chunks/chunk-24EBWTCF.js";
9
+ import "./chunks/chunk-N4Y2Z6YD.js";
8
10
  import {
9
11
  anthropic,
10
12
  browserAI,
13
+ cachedEmbeddings,
11
14
  gemini,
15
+ geminiEmbeddings,
12
16
  ollama,
17
+ ollamaEmbeddings,
13
18
  openai,
14
19
  openaiCompatible,
15
- proxy
16
- } from "./chunks/chunk-2ADXL7KQ.js";
17
- import "./chunks/chunk-N4Y2Z6YD.js";
20
+ openaiEmbeddings,
21
+ proxy,
22
+ proxyEmbeddings
23
+ } from "./chunks/chunk-MRHKJ2FZ.js";
18
24
  import {
19
25
  action,
20
26
  chat,
@@ -26,7 +32,7 @@ import {
26
32
  form,
27
33
  grid,
28
34
  list
29
- } from "./chunks/chunk-I77YSUJN.js";
35
+ } from "./chunks/chunk-INTEVQYK.js";
30
36
  import {
31
37
  memoryStorage
32
38
  } from "./chunks/chunk-YCVJQ7U3.js";
@@ -42,6 +48,7 @@ export {
42
48
  anthropic,
43
49
  browserAI,
44
50
  byok,
51
+ cachedEmbeddings,
45
52
  chat,
46
53
  createQikbar,
47
54
  defineCommands,
@@ -52,16 +59,21 @@ export {
52
59
  form,
53
60
  formatHotkey,
54
61
  gemini,
62
+ geminiEmbeddings,
55
63
  grid,
56
64
  isMac,
57
65
  list,
58
66
  matchesHotkey,
67
+ mcp,
59
68
  memoryStorage,
60
69
  ollama,
70
+ ollamaEmbeddings,
61
71
  openai,
62
72
  openaiCompatible,
73
+ openaiEmbeddings,
63
74
  parseHotkey,
64
75
  proxy,
76
+ proxyEmbeddings,
65
77
  version
66
78
  };
67
79
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Ready-made translations. Pass one as `labels`, or spread it and override:
3
+ *
4
+ * ```ts
5
+ * import { de } from '@qikbar/qikbar/locales'
6
+ * createQikbar({ labels: { ...de, placeholder: 'Suche in Acme…' } })
7
+ * ```
8
+ */
9
+ import { type Labels } from '../core/labels.js';
10
+ export type { Labels } from '../core/labels.js';
11
+ export { en, format } from '../core/labels.js';
12
+ export declare const es: Labels;
13
+ export declare const fr: Labels;
14
+ export declare const de: Labels;
15
+ export declare const pt: Labels;
16
+ export declare const it: Labels;
17
+ export declare const nl: Labels;
18
+ export declare const ja: Labels;
19
+ export declare const zh: Labels;
20
+ export declare const ko: Labels;
21
+ /** Every bundled locale, by language code. */
22
+ export declare const locales: Record<string, Labels>;
23
+ /** Pick the best bundled locale for a language tag (e.g. `navigator.language`). Falls back to English. */
24
+ export declare function localeFor(tag?: string | undefined): Labels;