@happyvertical/smrt-svelte 0.55.7 → 0.55.8
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/AGENTS.md +7 -44
- package/README.md +112 -1
- package/agents/browser-ai.md +47 -0
- package/agents/command-palette.md +85 -0
- package/agents/import-export.md +62 -0
- package/agents/overview-surfaces.md +255 -0
- package/agents/screens.md +57 -0
- package/dist/browser-ai/adapters/tts/browser-synthesis.d.ts +5 -0
- package/dist/browser-ai/adapters/tts/browser-synthesis.d.ts.map +1 -1
- package/dist/browser-ai/adapters/tts/browser-synthesis.js +83 -55
- package/dist/components/command-palette/CommandPalette.svelte +75 -0
- package/dist/components/command-palette/CommandPalette.svelte.d.ts +22 -0
- package/dist/components/command-palette/CommandPalette.svelte.d.ts.map +1 -0
- package/dist/components/command-palette/CommandPaletteDialog.svelte +406 -0
- package/dist/components/command-palette/CommandPaletteDialog.svelte.d.ts +18 -0
- package/dist/components/command-palette/CommandPaletteDialog.svelte.d.ts.map +1 -0
- package/dist/components/command-palette/CommandPaletteTrigger.svelte +91 -0
- package/dist/components/command-palette/CommandPaletteTrigger.svelte.d.ts +17 -0
- package/dist/components/command-palette/CommandPaletteTrigger.svelte.d.ts.map +1 -0
- package/dist/components/command-palette/context.d.ts +18 -0
- package/dist/components/command-palette/context.d.ts.map +1 -0
- package/dist/components/command-palette/context.js +38 -0
- package/dist/components/command-palette/controller.svelte.d.ts +70 -0
- package/dist/components/command-palette/controller.svelte.d.ts.map +1 -0
- package/dist/components/command-palette/controller.svelte.js +379 -0
- package/dist/components/command-palette/hotkeys.d.ts +30 -0
- package/dist/components/command-palette/hotkeys.d.ts.map +1 -0
- package/dist/components/command-palette/hotkeys.js +161 -0
- package/dist/components/command-palette/index.d.ts +19 -0
- package/dist/components/command-palette/index.d.ts.map +1 -0
- package/dist/components/command-palette/index.js +17 -0
- package/dist/components/command-palette/match.d.ts +38 -0
- package/dist/components/command-palette/match.d.ts.map +1 -0
- package/dist/components/command-palette/match.js +172 -0
- package/dist/components/command-palette/providers.d.ts +159 -0
- package/dist/components/command-palette/providers.d.ts.map +1 -0
- package/dist/components/command-palette/providers.js +345 -0
- package/dist/components/command-palette/rank.d.ts +20 -0
- package/dist/components/command-palette/rank.d.ts.map +1 -0
- package/dist/components/command-palette/rank.js +74 -0
- package/dist/components/command-palette/types.d.ts +119 -0
- package/dist/components/command-palette/types.d.ts.map +1 -0
- package/dist/components/command-palette/types.js +10 -0
- package/dist/components/command-palette/use-provider.svelte.d.ts +14 -0
- package/dist/components/command-palette/use-provider.svelte.d.ts.map +1 -0
- package/dist/components/command-palette/use-provider.svelte.js +23 -0
- package/dist/components/import-export/ImportExport.svelte +678 -0
- package/dist/components/import-export/ImportExport.svelte.d.ts +5 -0
- package/dist/components/import-export/ImportExport.svelte.d.ts.map +1 -0
- package/dist/components/import-export/collection-adapter.d.ts +35 -0
- package/dist/components/import-export/collection-adapter.d.ts.map +1 -0
- package/dist/components/import-export/collection-adapter.js +42 -0
- package/dist/components/import-export/csv.d.ts +60 -0
- package/dist/components/import-export/csv.d.ts.map +1 -0
- package/dist/components/import-export/csv.js +192 -0
- package/dist/components/import-export/download.d.ts +4 -0
- package/dist/components/import-export/download.d.ts.map +1 -0
- package/dist/components/import-export/download.js +17 -0
- package/dist/components/import-export/export.d.ts +25 -0
- package/dist/components/import-export/export.d.ts.map +1 -0
- package/dist/components/import-export/export.js +68 -0
- package/dist/components/import-export/fields.d.ts +48 -0
- package/dist/components/import-export/fields.d.ts.map +1 -0
- package/dist/components/import-export/fields.js +103 -0
- package/dist/components/import-export/index.d.ts +12 -0
- package/dist/components/import-export/index.d.ts.map +1 -0
- package/dist/components/import-export/index.js +9 -0
- package/dist/components/import-export/mapping.d.ts +12 -0
- package/dist/components/import-export/mapping.d.ts.map +1 -0
- package/dist/components/import-export/mapping.js +38 -0
- package/dist/components/import-export/props.d.ts +34 -0
- package/dist/components/import-export/props.d.ts.map +1 -0
- package/dist/components/import-export/props.js +1 -0
- package/dist/components/import-export/report.d.ts +13 -0
- package/dist/components/import-export/report.d.ts.map +1 -0
- package/dist/components/import-export/report.js +50 -0
- package/dist/components/import-export/runner.d.ts +17 -0
- package/dist/components/import-export/runner.d.ts.map +1 -0
- package/dist/components/import-export/runner.js +39 -0
- package/dist/components/import-export/types.d.ts +100 -0
- package/dist/components/import-export/types.d.ts.map +1 -0
- package/dist/components/import-export/types.js +6 -0
- package/dist/components/import-export/validate.d.ts +39 -0
- package/dist/components/import-export/validate.d.ts.map +1 -0
- package/dist/components/import-export/validate.js +268 -0
- package/dist/components/overview/OverviewGrid.svelte +579 -0
- package/dist/components/overview/OverviewGrid.svelte.d.ts +5 -0
- package/dist/components/overview/OverviewGrid.svelte.d.ts.map +1 -0
- package/dist/components/overview/WidgetOptionsForm.svelte +193 -0
- package/dist/components/overview/WidgetOptionsForm.svelte.d.ts +5 -0
- package/dist/components/overview/WidgetOptionsForm.svelte.d.ts.map +1 -0
- package/dist/components/overview/controller.svelte.d.ts +92 -0
- package/dist/components/overview/controller.svelte.d.ts.map +1 -0
- package/dist/components/overview/controller.svelte.js +336 -0
- package/dist/components/overview/format.d.ts +13 -0
- package/dist/components/overview/format.d.ts.map +1 -0
- package/dist/components/overview/format.js +45 -0
- package/dist/components/overview/grid-types.d.ts +52 -0
- package/dist/components/overview/grid-types.d.ts.map +1 -0
- package/dist/components/overview/grid-types.js +1 -0
- package/dist/components/overview/index.d.ts +24 -0
- package/dist/components/overview/index.d.ts.map +1 -0
- package/dist/components/overview/index.js +22 -0
- package/dist/components/overview/load.d.ts +30 -0
- package/dist/components/overview/load.d.ts.map +1 -0
- package/dist/components/overview/load.js +92 -0
- package/dist/components/overview/markdown.d.ts +53 -0
- package/dist/components/overview/markdown.d.ts.map +1 -0
- package/dist/components/overview/markdown.js +203 -0
- package/dist/components/overview/model.d.ts +100 -0
- package/dist/components/overview/model.d.ts.map +1 -0
- package/dist/components/overview/model.js +460 -0
- package/dist/components/overview/recipe-widgets.d.ts +77 -0
- package/dist/components/overview/recipe-widgets.d.ts.map +1 -0
- package/dist/components/overview/recipe-widgets.js +151 -0
- package/dist/components/overview/registry.d.ts +45 -0
- package/dist/components/overview/registry.d.ts.map +1 -0
- package/dist/components/overview/registry.js +112 -0
- package/dist/components/overview/resize.d.ts +25 -0
- package/dist/components/overview/resize.d.ts.map +1 -0
- package/dist/components/overview/resize.js +41 -0
- package/dist/components/overview/schema.d.ts +34 -0
- package/dist/components/overview/schema.d.ts.map +1 -0
- package/dist/components/overview/schema.js +180 -0
- package/dist/components/overview/server.d.ts +14 -0
- package/dist/components/overview/server.d.ts.map +1 -0
- package/dist/components/overview/server.js +13 -0
- package/dist/components/overview/types.d.ts +235 -0
- package/dist/components/overview/types.d.ts.map +1 -0
- package/dist/components/overview/types.js +17 -0
- package/dist/components/overview/widgets/ChartWidget.svelte +111 -0
- package/dist/components/overview/widgets/ChartWidget.svelte.d.ts +6 -0
- package/dist/components/overview/widgets/ChartWidget.svelte.d.ts.map +1 -0
- package/dist/components/overview/widgets/MetricWidget.svelte +86 -0
- package/dist/components/overview/widgets/MetricWidget.svelte.d.ts +6 -0
- package/dist/components/overview/widgets/MetricWidget.svelte.d.ts.map +1 -0
- package/dist/components/overview/widgets/NoteWidget.svelte +61 -0
- package/dist/components/overview/widgets/NoteWidget.svelte.d.ts +5 -0
- package/dist/components/overview/widgets/NoteWidget.svelte.d.ts.map +1 -0
- package/dist/components/overview/widgets/RecordListWidget.svelte +91 -0
- package/dist/components/overview/widgets/RecordListWidget.svelte.d.ts +6 -0
- package/dist/components/overview/widgets/RecordListWidget.svelte.d.ts.map +1 -0
- package/dist/components/overview/widgets/ShortcutsWidget.svelte +80 -0
- package/dist/components/overview/widgets/ShortcutsWidget.svelte.d.ts +6 -0
- package/dist/components/overview/widgets/ShortcutsWidget.svelte.d.ts.map +1 -0
- package/dist/components/overview/widgets/core.d.ts +44 -0
- package/dist/components/overview/widgets/core.d.ts.map +1 -0
- package/dist/components/overview/widgets/core.js +222 -0
- package/dist/components/overview/widgets/data.d.ts +76 -0
- package/dist/components/overview/widgets/data.d.ts.map +1 -0
- package/dist/components/overview/widgets/data.js +40 -0
- package/dist/components/screens/DetailScreen.svelte +220 -0
- package/dist/components/screens/DetailScreen.svelte.d.ts +5 -0
- package/dist/components/screens/DetailScreen.svelte.d.ts.map +1 -0
- package/dist/components/screens/EditForm.svelte +313 -0
- package/dist/components/screens/EditForm.svelte.d.ts +5 -0
- package/dist/components/screens/EditForm.svelte.d.ts.map +1 -0
- package/dist/components/screens/ListScreen.svelte +191 -0
- package/dist/components/screens/ListScreen.svelte.d.ts +5 -0
- package/dist/components/screens/ListScreen.svelte.d.ts.map +1 -0
- package/dist/components/screens/RecipeScreens.svelte +237 -0
- package/dist/components/screens/RecipeScreens.svelte.d.ts +5 -0
- package/dist/components/screens/RecipeScreens.svelte.d.ts.map +1 -0
- package/dist/components/screens/fields.d.ts +54 -0
- package/dist/components/screens/fields.d.ts.map +1 -0
- package/dist/components/screens/fields.js +229 -0
- package/dist/components/screens/index.d.ts +8 -0
- package/dist/components/screens/index.d.ts.map +1 -0
- package/dist/components/screens/index.js +6 -0
- package/dist/components/screens/types.d.ts +215 -0
- package/dist/components/screens/types.d.ts.map +1 -0
- package/dist/components/screens/types.js +1 -0
- package/dist/components/screens/values.d.ts +62 -0
- package/dist/components/screens/values.d.ts.map +1 -0
- package/dist/components/screens/values.js +289 -0
- package/dist/components/sortable/controller.svelte.d.ts +10 -0
- package/dist/components/sortable/controller.svelte.d.ts.map +1 -1
- package/dist/components/sortable/controller.svelte.js +29 -7
- package/dist/components/workspace/manifest-nav.d.ts +20 -0
- package/dist/components/workspace/manifest-nav.d.ts.map +1 -1
- package/dist/components/workspace/manifest-nav.js +42 -13
- package/dist/i18n/server.d.ts +6 -0
- package/dist/i18n/server.d.ts.map +1 -1
- package/dist/i18n/server.js +6 -0
- package/dist/i18n/strings.import-export.d.ts +88 -0
- package/dist/i18n/strings.import-export.d.ts.map +1 -0
- package/dist/i18n/strings.import-export.js +88 -0
- package/dist/i18n/strings.overview.d.ts +100 -0
- package/dist/i18n/strings.overview.d.ts.map +1 -0
- package/dist/i18n/strings.overview.js +107 -0
- package/dist/i18n/strings.palette.d.ts +18 -0
- package/dist/i18n/strings.palette.d.ts.map +1 -0
- package/dist/i18n/strings.palette.js +18 -0
- package/dist/i18n/strings.screens.d.ts +31 -0
- package/dist/i18n/strings.screens.d.ts.map +1 -0
- package/dist/i18n/strings.screens.js +31 -0
- package/package.json +45 -16
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PaletteItem, PaletteProvider, PaletteResult, PaletteSection } from './types.js';
|
|
2
|
+
/** Default rows per group. */
|
|
3
|
+
export declare const DEFAULT_MAX_PER_GROUP = 8;
|
|
4
|
+
export interface RankInput {
|
|
5
|
+
/** In registration order. */
|
|
6
|
+
providers: readonly PaletteProvider[];
|
|
7
|
+
/** `items()` output by provider id. */
|
|
8
|
+
local: Readonly<Record<string, readonly PaletteItem[]>>;
|
|
9
|
+
/** `search()` output by provider id (for the current or previous query). */
|
|
10
|
+
remote: Readonly<Record<string, readonly PaletteItem[]>>;
|
|
11
|
+
query: string;
|
|
12
|
+
maxPerGroup?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Providers by `order`, then registration order. */
|
|
15
|
+
export declare function orderProviders(providers: readonly PaletteProvider[]): PaletteProvider[];
|
|
16
|
+
/** Group, match and rank. A group with no rows is omitted. */
|
|
17
|
+
export declare function buildPaletteSections(input: RankInput): PaletteSection[];
|
|
18
|
+
/** The rows of `sections` in display order. */
|
|
19
|
+
export declare function flattenSections(sections: readonly PaletteSection[]): PaletteResult[];
|
|
20
|
+
//# sourceMappingURL=rank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rank.d.ts","sourceRoot":"","sources":["../../../src/components/command-palette/rank.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,WAAW,EACX,eAAe,EACf,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,8BAA8B;AAC9B,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,MAAM,WAAW,SAAS;IACxB,6BAA6B;IAC7B,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IACtC,uCAAuC;IACvC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC,CAAC;IACxD,4EAA4E;IAC5E,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC,CAAC;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAmBD,qDAAqD;AACrD,wBAAgB,cAAc,CAC5B,SAAS,EAAE,SAAS,eAAe,EAAE,GACpC,eAAe,EAAE,CAQnB;AAED,8DAA8D;AAC9D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,cAAc,EAAE,CA4DvE;AAED,+CAA+C;AAC/C,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,aAAa,EAAE,CAEjB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns provider output into the grouped, ranked rows the palette renders.
|
|
3
|
+
* Pure: the controller feeds it the current local items, remote results and
|
|
4
|
+
* query. No DOM, no Svelte.
|
|
5
|
+
*/
|
|
6
|
+
import { matchItem, matchText } from './match.js';
|
|
7
|
+
/** Default rows per group. */
|
|
8
|
+
export const DEFAULT_MAX_PER_GROUP = 8;
|
|
9
|
+
function resultFor(provider, item, score, titleRanges) {
|
|
10
|
+
return {
|
|
11
|
+
key: `${provider.id}:${item.id}`,
|
|
12
|
+
providerId: provider.id,
|
|
13
|
+
group: item.group ?? provider.label,
|
|
14
|
+
item,
|
|
15
|
+
score,
|
|
16
|
+
titleRanges,
|
|
17
|
+
selectable: !item.disabled,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Providers by `order`, then registration order. */
|
|
21
|
+
export function orderProviders(providers) {
|
|
22
|
+
return providers
|
|
23
|
+
.map((provider, index) => ({ provider, index }))
|
|
24
|
+
.sort((a, b) => (a.provider.order ?? 0) - (b.provider.order ?? 0) || a.index - b.index)
|
|
25
|
+
.map(({ provider }) => provider);
|
|
26
|
+
}
|
|
27
|
+
/** Group, match and rank. A group with no rows is omitted. */
|
|
28
|
+
export function buildPaletteSections(input) {
|
|
29
|
+
const query = input.query.trim();
|
|
30
|
+
const maxPerGroup = input.maxPerGroup ?? DEFAULT_MAX_PER_GROUP;
|
|
31
|
+
const sections = [];
|
|
32
|
+
const sectionFor = (label) => {
|
|
33
|
+
let section = sections.find((candidate) => candidate.id === label);
|
|
34
|
+
if (!section) {
|
|
35
|
+
section = { id: label, label, results: [] };
|
|
36
|
+
sections.push(section);
|
|
37
|
+
}
|
|
38
|
+
return section;
|
|
39
|
+
};
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
for (const provider of orderProviders(input.providers)) {
|
|
42
|
+
const limit = provider.limit ?? maxPerGroup;
|
|
43
|
+
const matched = [];
|
|
44
|
+
for (const item of input.local[provider.id] ?? []) {
|
|
45
|
+
const match = matchItem(query, item);
|
|
46
|
+
if (!match)
|
|
47
|
+
continue;
|
|
48
|
+
matched.push(resultFor(provider, item, match.score + (item.boost ?? 0), match.titleRanges));
|
|
49
|
+
}
|
|
50
|
+
// Stable: equal scores keep the provider's own order.
|
|
51
|
+
matched.sort((a, b) => b.score - a.score);
|
|
52
|
+
const searched = [];
|
|
53
|
+
if (query.length > 0) {
|
|
54
|
+
for (const item of input.remote[provider.id] ?? []) {
|
|
55
|
+
searched.push(resultFor(provider, item, item.boost ?? 0, matchText(query, item.title)?.ranges ?? []));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let taken = 0;
|
|
59
|
+
for (const result of [...matched, ...searched]) {
|
|
60
|
+
if (taken >= limit)
|
|
61
|
+
break;
|
|
62
|
+
if (seen.has(result.key))
|
|
63
|
+
continue;
|
|
64
|
+
seen.add(result.key);
|
|
65
|
+
sectionFor(result.group).results.push(result);
|
|
66
|
+
taken += 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return sections.filter((section) => section.results.length > 0);
|
|
70
|
+
}
|
|
71
|
+
/** The rows of `sections` in display order. */
|
|
72
|
+
export function flattenSections(sections) {
|
|
73
|
+
return sections.flatMap((section) => [...section.results]);
|
|
74
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command palette contracts (#3713).
|
|
3
|
+
*
|
|
4
|
+
* The palette is a thin shell over a *provider* contract: anything that wants
|
|
5
|
+
* to appear in "find anything" registers a {@link PaletteProvider}. The shell
|
|
6
|
+
* ships two (see `providers.ts`): navigation from the shell nav model, and a
|
|
7
|
+
* model-driven pair derived from the SMRT manifest. Packages and recipes add
|
|
8
|
+
* their own through the same contract.
|
|
9
|
+
*/
|
|
10
|
+
/** What an item does when chosen, for grouping hints and screen readers. */
|
|
11
|
+
export type PaletteItemKind = 'command' | 'navigation' | 'create' | 'record' | (string & {});
|
|
12
|
+
/** Passed to {@link PaletteItem.run}. */
|
|
13
|
+
export interface PaletteRunContext {
|
|
14
|
+
/** The text typed when the item was chosen. */
|
|
15
|
+
query: string;
|
|
16
|
+
/** The provider that owns the item. */
|
|
17
|
+
providerId: string;
|
|
18
|
+
/** Navigate with the palette's `navigate` seam (same as an `href` item). */
|
|
19
|
+
navigate: (href: string) => void | Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/** One selectable row. */
|
|
22
|
+
export interface PaletteItem {
|
|
23
|
+
/** Stable id, unique within its provider. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Primary text; matched against the query and highlighted. */
|
|
26
|
+
title: string;
|
|
27
|
+
/** Secondary line, e.g. the model an item belongs to. Matched at lower weight. */
|
|
28
|
+
subtitle?: string;
|
|
29
|
+
/** Extra match terms that are not shown ("invoice" for "Billing"). */
|
|
30
|
+
keywords?: readonly string[];
|
|
31
|
+
/** Overrides the provider's group heading for this item. */
|
|
32
|
+
group?: string;
|
|
33
|
+
/** A shell icon name (`SHELL_ICON_PATHS`); unknown names draw no icon. */
|
|
34
|
+
icon?: string;
|
|
35
|
+
/** Free-form tag, exposed as `data-kind` and read by assistants. */
|
|
36
|
+
kind?: PaletteItemKind;
|
|
37
|
+
/** Navigates here when chosen and no `run` is set. */
|
|
38
|
+
href?: string;
|
|
39
|
+
/** Runs when chosen. Takes precedence over `href`. */
|
|
40
|
+
run?: (context: PaletteRunContext) => void | Promise<void>;
|
|
41
|
+
/** A hotkey hint shown at the end of the row (display only), e.g. `Mod+N`. */
|
|
42
|
+
shortcut?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Shown but not selectable. A string is the reason, announced and shown as
|
|
45
|
+
* the row tooltip.
|
|
46
|
+
*/
|
|
47
|
+
disabled?: boolean | string;
|
|
48
|
+
/** Static ranking bias added to the match score (default 0). */
|
|
49
|
+
boost?: number;
|
|
50
|
+
}
|
|
51
|
+
/** Passed to {@link PaletteProvider.items}. */
|
|
52
|
+
export interface PaletteItemsContext {
|
|
53
|
+
/** Aborted when the palette closes before the items arrive. */
|
|
54
|
+
signal: AbortSignal;
|
|
55
|
+
}
|
|
56
|
+
/** Passed to {@link PaletteProvider.search}. */
|
|
57
|
+
export interface PaletteSearchContext {
|
|
58
|
+
/** Aborted when the query changes or the palette closes. */
|
|
59
|
+
signal: AbortSignal;
|
|
60
|
+
/** The most rows the palette will show for this provider. */
|
|
61
|
+
limit: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A source of palette rows. A provider offers either or both of:
|
|
65
|
+
*
|
|
66
|
+
* - `items` - a set the palette matches locally (commands, navigation). Read
|
|
67
|
+
* every time the palette opens, so it can follow app state.
|
|
68
|
+
* - `search` - results for a typed query, fetched by the provider (records).
|
|
69
|
+
* Called after a short debounce, with a signal that aborts on the next
|
|
70
|
+
* keystroke. Results are shown as returned; the palette does not re-filter.
|
|
71
|
+
*
|
|
72
|
+
* Authorization stays with the provider: return only what the user may see.
|
|
73
|
+
* The palette is not a security boundary.
|
|
74
|
+
*/
|
|
75
|
+
export interface PaletteProvider {
|
|
76
|
+
/** Stable id; registering the same id again replaces the earlier provider. */
|
|
77
|
+
id: string;
|
|
78
|
+
/** Group heading for this provider's rows. */
|
|
79
|
+
label: string;
|
|
80
|
+
/** Lower sorts first (default 0); ties keep registration order. */
|
|
81
|
+
order?: number;
|
|
82
|
+
items?(context: PaletteItemsContext): readonly PaletteItem[] | Promise<readonly PaletteItem[]>;
|
|
83
|
+
search?(query: string, context: PaletteSearchContext): readonly PaletteItem[] | Promise<readonly PaletteItem[]>;
|
|
84
|
+
/** Shortest trimmed query `search` is called with (default 2). */
|
|
85
|
+
minQueryLength?: number;
|
|
86
|
+
/** Rows shown for this provider (default: the palette's `maxPerGroup`). */
|
|
87
|
+
limit?: number;
|
|
88
|
+
}
|
|
89
|
+
/** A character range `[start, end)` in a string. */
|
|
90
|
+
export type MatchRange = readonly [start: number, end: number];
|
|
91
|
+
/** A row the palette renders. */
|
|
92
|
+
export interface PaletteResult {
|
|
93
|
+
/** `${providerId}:${item.id}`; unique in the palette. */
|
|
94
|
+
key: string;
|
|
95
|
+
providerId: string;
|
|
96
|
+
/** Group heading the row sits under. */
|
|
97
|
+
group: string;
|
|
98
|
+
item: PaletteItem;
|
|
99
|
+
/** Match score; higher is better. 0 for rows that were not text-matched. */
|
|
100
|
+
score: number;
|
|
101
|
+
/** Ranges of `item.title` that matched the query. */
|
|
102
|
+
titleRanges: readonly MatchRange[];
|
|
103
|
+
/** Whether the row can be chosen. */
|
|
104
|
+
selectable: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** A heading and its rows. */
|
|
107
|
+
export interface PaletteSection {
|
|
108
|
+
/** Stable: the group heading. */
|
|
109
|
+
id: string;
|
|
110
|
+
label: string;
|
|
111
|
+
results: readonly PaletteResult[];
|
|
112
|
+
}
|
|
113
|
+
/** Where an error came from. */
|
|
114
|
+
export interface PaletteErrorContext {
|
|
115
|
+
providerId: string;
|
|
116
|
+
phase: 'items' | 'search' | 'run';
|
|
117
|
+
item?: PaletteItem;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/command-palette/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command palette contracts (#3713).
|
|
3
|
+
*
|
|
4
|
+
* The palette is a thin shell over a *provider* contract: anything that wants
|
|
5
|
+
* to appear in "find anything" registers a {@link PaletteProvider}. The shell
|
|
6
|
+
* ships two (see `providers.ts`): navigation from the shell nav model, and a
|
|
7
|
+
* model-driven pair derived from the SMRT manifest. Packages and recipes add
|
|
8
|
+
* their own through the same contract.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandPaletteController } from './controller.svelte.js';
|
|
2
|
+
import type { PaletteProvider } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Register a palette provider for the calling component's lifetime. Pass a
|
|
5
|
+
* getter to follow reactive state: the provider re-registers (replacing the
|
|
6
|
+
* earlier one, same `id`) whenever what it reads changes. A silent no-op when
|
|
7
|
+
* there is no palette on context, so a recipe's component works with or
|
|
8
|
+
* without one. Call during component initialization.
|
|
9
|
+
*
|
|
10
|
+
* @param source The provider, or a function returning it (or null for none).
|
|
11
|
+
* @param controller Override the palette from context.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useCommandPaletteProvider(source: PaletteProvider | (() => PaletteProvider | null), controller?: CommandPaletteController | null): void;
|
|
14
|
+
//# sourceMappingURL=use-provider.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-provider.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/command-palette/use-provider.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,eAAe,GAAG,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,EACxD,UAAU,GAAE,wBAAwB,GAAG,IAA6B,GACnE,IAAI,CAQN"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { untrack } from 'svelte';
|
|
2
|
+
import { tryUseCommandPalette } from './context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Register a palette provider for the calling component's lifetime. Pass a
|
|
5
|
+
* getter to follow reactive state: the provider re-registers (replacing the
|
|
6
|
+
* earlier one, same `id`) whenever what it reads changes. A silent no-op when
|
|
7
|
+
* there is no palette on context, so a recipe's component works with or
|
|
8
|
+
* without one. Call during component initialization.
|
|
9
|
+
*
|
|
10
|
+
* @param source The provider, or a function returning it (or null for none).
|
|
11
|
+
* @param controller Override the palette from context.
|
|
12
|
+
*/
|
|
13
|
+
export function useCommandPaletteProvider(source, controller = tryUseCommandPalette()) {
|
|
14
|
+
if (!controller)
|
|
15
|
+
return;
|
|
16
|
+
$effect(() => {
|
|
17
|
+
const provider = typeof source === 'function' ? source() : source;
|
|
18
|
+
if (!provider)
|
|
19
|
+
return;
|
|
20
|
+
// Registering reads and writes the registry; keep that out of this effect.
|
|
21
|
+
return untrack(() => controller.registerProvider(provider));
|
|
22
|
+
});
|
|
23
|
+
}
|