@aparte/plugin-model-selector 1.0.2 → 1.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/dist/aparte-model-selector.d.ts +3 -0
- package/dist/aparte-model-selector.d.ts.map +1 -1
- package/dist/custom-elements.json +19 -0
- package/dist/generated/element-attributes.d.ts +2 -0
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/generated/element.directives.d.ts +3 -1
- package/dist/generated/element.directives.d.ts.map +1 -1
- package/dist/generated/element.directives.js +5 -1
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -11,6 +11,7 @@ import { type AparteConfig, type AparteConfigAware } from '@aparte/core';
|
|
|
11
11
|
* and what a typed framework wrapper is written from.
|
|
12
12
|
*
|
|
13
13
|
* @element aparte-model-selector
|
|
14
|
+
* @attr {string} commands - `false` keeps `/model` out of `@aparte/plugin-triggers`' menu.
|
|
14
15
|
* @attr {boolean} auto-select - Selects the first model as soon as one is available.
|
|
15
16
|
* @attr {boolean} persist - Writes the selection into the config, which is what the next message is sent with.
|
|
16
17
|
* Without it the picker only fires `aparte-model-change`, and applying the choice is the app's. It does not
|
|
@@ -62,6 +63,8 @@ export declare class AparteModelSelector extends HTMLElement implements AparteCo
|
|
|
62
63
|
private _composer;
|
|
63
64
|
private _boundComposerChange;
|
|
64
65
|
static get observedAttributes(): string[];
|
|
66
|
+
/** Answers `@aparte/plugin-triggers`' menu with `/model`, unless `commands="false"`. */
|
|
67
|
+
private readonly _onCollectCommands;
|
|
65
68
|
connectedCallback(): Promise<void>;
|
|
66
69
|
/**
|
|
67
70
|
* The config's own selection when this element last read it. A change to IT is someone
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aparte-model-selector.d.ts","sourceRoot":"","sources":["../src/aparte-model-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,YAAY,EACjB,KAAK,iBAAiB,
|
|
1
|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A0E;IAC1E,OAAO,CAAC,YAAY;IAIpB,yFAAyF;IACzF,OAAO,CAAC,SAAS;IAUjB,oBAAoB,IAAI,IAAI;IAS5B;;;;;;;;OAQG;IACH,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAqB7C,wBAAwB,IAAI,IAAI;IAUhC,2BAA2B;IAC3B,IAAI,UAAU,IAAI,MAAM,GAAG,IAAI,CAE9B;IAED,wBAAwB;IACxB,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,0CAA0C;IAC1C,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAkBvD;;;;;OAKG;YACW,sBAAsB;IAmBpC;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;YAMT,SAAS;YAmDT,iBAAiB;IA2C/B,0EAA0E;IAC1E,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,WAAW;IAsInB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,WAAW;IAwBnB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,uBAAuB;CAWlC;AAUD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,uBAAuB,EAAE,mBAAmB,CAAC;KAChD;CACJ"}
|
|
@@ -171,6 +171,13 @@
|
|
|
171
171
|
"name": "_boundComposerChange",
|
|
172
172
|
"privacy": "private"
|
|
173
173
|
},
|
|
174
|
+
{
|
|
175
|
+
"kind": "field",
|
|
176
|
+
"name": "_onCollectCommands",
|
|
177
|
+
"privacy": "private",
|
|
178
|
+
"readonly": true,
|
|
179
|
+
"description": "Answers `@aparte/plugin-triggers`' menu with `/model`, unless `commands=\"false\"`."
|
|
180
|
+
},
|
|
174
181
|
{
|
|
175
182
|
"kind": "field",
|
|
176
183
|
"name": "_seenConfigSelection",
|
|
@@ -559,6 +566,13 @@
|
|
|
559
566
|
"text": "boolean"
|
|
560
567
|
},
|
|
561
568
|
"description": "Shows, under each model's name, its `description` and its `contextWindow` — the metadata a provider already declares. The trigger keeps the name alone; the filter searches the line too."
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
"type": {
|
|
572
|
+
"text": "string"
|
|
573
|
+
},
|
|
574
|
+
"description": "`false` keeps `/model` out of `@aparte/plugin-triggers`' menu.",
|
|
575
|
+
"name": "commands"
|
|
562
576
|
}
|
|
563
577
|
],
|
|
564
578
|
"superclass": {
|
|
@@ -739,6 +753,11 @@
|
|
|
739
753
|
"name": "details",
|
|
740
754
|
"description": "Shows, under each model's name, its `description` and its `contextWindow` — the metadata a provider already declares. The trigger keeps the name alone; the filter searches the line too."
|
|
741
755
|
},
|
|
756
|
+
{
|
|
757
|
+
"kind": "field",
|
|
758
|
+
"name": "commands",
|
|
759
|
+
"description": "`false` keeps `/model` out of `@aparte/plugin-triggers`' menu."
|
|
760
|
+
},
|
|
742
761
|
{
|
|
743
762
|
"kind": "field",
|
|
744
763
|
"name": "modelChange",
|
|
@@ -12,6 +12,8 @@ export interface AparteModelSelectorAttributes {
|
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
/** Shows, under each model's name, its `description` and its `contextWindow` — the metadata a provider already declares. The trigger keeps the name alone; the filter searches the line too. */
|
|
14
14
|
details?: boolean;
|
|
15
|
+
/** `false` keeps `/model` out of `@aparte/plugin-triggers`' menu. */
|
|
16
|
+
commands?: string;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Tag name to its attribute surface — the registry every wrapper maps over.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-attributes.d.ts","sourceRoot":"","sources":["../../src/generated/element-attributes.ts"],"names":[],"mappings":"AAIA,mRAAmR;AACnR,MAAM,WAAW,6BAA6B;IAC1C,0SAA0S;IAC1S,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yKAAyK;IACzK,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gMAAgM;IAChM,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACpC,uBAAuB,EAAE,6BAA6B,CAAC;CAC1D;AAED,2FAA2F;AAC3F,MAAM,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"element-attributes.d.ts","sourceRoot":"","sources":["../../src/generated/element-attributes.ts"],"names":[],"mappings":"AAIA,mRAAmR;AACnR,MAAM,WAAW,6BAA6B;IAC1C,0SAA0S;IAC1S,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yKAAyK;IACzK,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gMAAgM;IAChM,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACpC,uBAAuB,EAAE,6BAA6B,CAAC;CAC1D;AAED,2FAA2F;AAC3F,MAAM,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC"}
|
|
@@ -41,11 +41,13 @@ export declare class AparteModelSelectorDirective extends AparteElementBase {
|
|
|
41
41
|
set disabled(v: boolean);
|
|
42
42
|
/** Shows, under each model's name, its `description` and its `contextWindow` — the metadata a provider already declares. The trigger keeps the name alone; the filter searches the line too. */
|
|
43
43
|
set details(v: boolean);
|
|
44
|
+
/** `false` keeps `/model` out of `@aparte/plugin-triggers`' menu. */
|
|
45
|
+
set commands(v: string | undefined);
|
|
44
46
|
/** The provider or the model changed; carries both ids. */
|
|
45
47
|
readonly modelChange: EventEmitter<AparteModelChangeEventDetail>;
|
|
46
48
|
protected onModelChange(e: CustomEvent<AparteModelChangeEventDetail>): void;
|
|
47
49
|
static ɵfac: i0.ɵɵFactoryDeclaration<AparteModelSelectorDirective, never>;
|
|
48
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<AparteModelSelectorDirective, "aparte-model-selector", never, { "persist": { "alias": "persist"; "required": false; }; "autoSelect": { "alias": "autoSelect"; "required": false; }; "searchable": { "alias": "searchable"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "details": { "alias": "details"; "required": false; }; }, { "modelChange": "modelChange"; }, never, never, true, never>;
|
|
50
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AparteModelSelectorDirective, "aparte-model-selector", never, { "persist": { "alias": "persist"; "required": false; }; "autoSelect": { "alias": "autoSelect"; "required": false; }; "searchable": { "alias": "searchable"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "details": { "alias": "details"; "required": false; }; "commands": { "alias": "commands"; "required": false; }; }, { "modelChange": "modelChange"; }, never, never, true, never>;
|
|
49
51
|
static ngAcceptInputType_persist: unknown;
|
|
50
52
|
static ngAcceptInputType_autoSelect: unknown;
|
|
51
53
|
static ngAcceptInputType_searchable: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.directives.d.ts","sourceRoot":"","sources":["../../src/generated/element.directives.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,OAAO,EAEH,UAAU,EACV,YAAY,EAMf,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EACR,4BAA4B,EAC/B,MAAM,cAAc,CAAC;;AAEtB;;;;;;;GAO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IAA4C,UAAU,CAAC,CAAC,EAAE,OAAO,EAAmC;IACpG,wCAAwC;IACxC,IAA4C,UAAU,CAAC,CAAC,EAAE,OAAO,EAAkC;IACnG,0DAA0D;IAC1D,IAAa,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAmC;IACjF,yKAAyK;IACzK,IAA4C,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAgC;IAC/F,gMAAgM;IAChM,IAA4C,OAAO,CAAC,CAAC,EAAE,OAAO,EAA+B;IAC7F,qEAAqE;IACrE,IAAa,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAgC;IAE3E,2DAA2D;IACjD,QAAQ,CAAC,WAAW,6CAAoD;IAGlF,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,WAAW,CAAC,4BAA4B,CAAC,GAAG,IAAI;yCApBlE,4BAA4B;2CAA5B,4BAA4B;sCAiC4u6c,OAAQ;yCAAR,OAAQ;yCAAR,OAAQ;uCAAR,OAAQ;sCAAR,OAAQ;CAZ5x6c;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,gDAE5B,CAAC"}
|
|
@@ -49,11 +49,13 @@ export class AparteModelSelectorDirective extends AparteElementBase {
|
|
|
49
49
|
set disabled(v) { this.write('disabled', v); }
|
|
50
50
|
/** Shows, under each model's name, its `description` and its `contextWindow` — the metadata a provider already declares. The trigger keeps the name alone; the filter searches the line too. */
|
|
51
51
|
set details(v) { this.write('details', v); }
|
|
52
|
+
/** `false` keeps `/model` out of `@aparte/plugin-triggers`' menu. */
|
|
53
|
+
set commands(v) { this.write('commands', v); }
|
|
52
54
|
/** The provider or the model changed; carries both ids. */
|
|
53
55
|
modelChange = new EventEmitter();
|
|
54
56
|
onModelChange(e) { this.modelChange.emit(e.detail); }
|
|
55
57
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AparteModelSelectorDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
56
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.2.25", type: AparteModelSelectorDirective, isStandalone: true, selector: "aparte-model-selector", inputs: { persist: ["persist", "persist", booleanAttribute], autoSelect: ["autoSelect", "autoSelect", booleanAttribute], searchable: ["searchable", "searchable", booleanAttribute], placeholder: "placeholder", disabled: ["disabled", "disabled", booleanAttribute], details: ["details", "details", booleanAttribute] }, outputs: { modelChange: "modelChange" }, host: { listeners: { "aparte-model-change": "onModelChange($event)" } }, usesInheritance: true, ngImport: i0 });
|
|
58
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.2.25", type: AparteModelSelectorDirective, isStandalone: true, selector: "aparte-model-selector", inputs: { persist: ["persist", "persist", booleanAttribute], autoSelect: ["autoSelect", "autoSelect", booleanAttribute], searchable: ["searchable", "searchable", booleanAttribute], placeholder: "placeholder", disabled: ["disabled", "disabled", booleanAttribute], details: ["details", "details", booleanAttribute], commands: "commands" }, outputs: { modelChange: "modelChange" }, host: { listeners: { "aparte-model-change": "onModelChange($event)" } }, usesInheritance: true, ngImport: i0 });
|
|
57
59
|
}
|
|
58
60
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AparteModelSelectorDirective, decorators: [{
|
|
59
61
|
type: Directive,
|
|
@@ -75,6 +77,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
75
77
|
}], details: [{
|
|
76
78
|
type: Input,
|
|
77
79
|
args: [{ transform: booleanAttribute }]
|
|
80
|
+
}], commands: [{
|
|
81
|
+
type: Input
|
|
78
82
|
}], modelChange: [{
|
|
79
83
|
type: Output
|
|
80
84
|
}], onModelChange: [{
|
package/dist/index.js
CHANGED
|
@@ -42,8 +42,29 @@ class AparteModelSelector extends HTMLElement {
|
|
|
42
42
|
static get observedAttributes() {
|
|
43
43
|
return ["persist", "auto-select", "searchable", "placeholder", "disabled", "details"];
|
|
44
44
|
}
|
|
45
|
+
/** Answers `@aparte/plugin-triggers`' menu with `/model`, unless `commands="false"`. */
|
|
46
|
+
_onCollectCommands = (e) => {
|
|
47
|
+
const { detail } = e;
|
|
48
|
+
if (detail.config !== this._cfg || this.getAttribute("commands") === "false" || this._providerModels.length === 0 || this._isDisabled()) return;
|
|
49
|
+
const chat = this.closest("aparte-chat, [data-aparte-chat]");
|
|
50
|
+
if (this._composer ? this._composer !== detail.composer : chat && chat !== detail.chat) return;
|
|
51
|
+
const several = this._providerModels.length > 1;
|
|
52
|
+
const rows = (entry) => entry.models.map((model) => ({
|
|
53
|
+
id: `${entry.provider.id}::${model.id}`,
|
|
54
|
+
label: model.name || model.id,
|
|
55
|
+
...entry.provider.id === this._currentProviderId && model.id === this._currentModelId ? { icon: "check" } : {},
|
|
56
|
+
run: () => this.setSelection(entry.provider.id, model.id)
|
|
57
|
+
}));
|
|
58
|
+
detail.add({
|
|
59
|
+
id: "model",
|
|
60
|
+
order: 60,
|
|
61
|
+
description: this._cfg.t("triggersCommandModel"),
|
|
62
|
+
children: several ? this._providerModels.map((entry) => ({ id: entry.provider.id, label: entry.provider.getMetadata().name, children: rows(entry) })) : rows(this._providerModels[0])
|
|
63
|
+
});
|
|
64
|
+
};
|
|
45
65
|
async connectedCallback() {
|
|
46
66
|
this._cfg = resolveConfig(this);
|
|
67
|
+
window.addEventListener("aparte-collect-commands", this._onCollectCommands);
|
|
47
68
|
this._restartLoading();
|
|
48
69
|
this._providerModels = [];
|
|
49
70
|
this._setupEventListeners();
|
|
@@ -129,6 +150,7 @@ class AparteModelSelector extends HTMLElement {
|
|
|
129
150
|
return parts.join(" · ");
|
|
130
151
|
}
|
|
131
152
|
disconnectedCallback() {
|
|
153
|
+
window.removeEventListener("aparte-collect-commands", this._onCollectCommands);
|
|
132
154
|
this._aparteSelect?.removeEventListener("aparte-select-change", this._boundHandleChange);
|
|
133
155
|
this.removeEventListener("aparte-optgroup-toggle", this._handleOptgroupToggle);
|
|
134
156
|
this._composer?.removeEventListener("aparte-composer-change", this._boundComposerChange);
|
|
@@ -182,13 +204,15 @@ class AparteModelSelector extends HTMLElement {
|
|
|
182
204
|
}
|
|
183
205
|
/** Programmatically set the selection. */
|
|
184
206
|
setSelection(providerId, modelId) {
|
|
207
|
+
const previousProviderId = this._currentProviderId;
|
|
208
|
+
const previousModelId = this._currentModelId;
|
|
185
209
|
this._currentProviderId = providerId;
|
|
186
210
|
this._currentModelId = modelId;
|
|
187
211
|
const compositeValue = `${providerId}::${modelId}`;
|
|
188
212
|
if (this._aparteSelect) {
|
|
189
213
|
this._aparteSelect.value = compositeValue;
|
|
190
214
|
}
|
|
191
|
-
this._emitChange();
|
|
215
|
+
this._emitChange(previousProviderId, previousModelId);
|
|
192
216
|
}
|
|
193
217
|
// ─────────────────────────────────────────────────────────────────────────
|
|
194
218
|
// Data Loading
|
|
@@ -403,6 +427,7 @@ class AparteModelSelector extends HTMLElement {
|
|
|
403
427
|
const previousProviderId = this._currentProviderId;
|
|
404
428
|
const previousModelId = this._currentModelId;
|
|
405
429
|
const [providerId, modelId] = detail.value.split("::");
|
|
430
|
+
if (providerId === this._currentProviderId && modelId === this._currentModelId) return;
|
|
406
431
|
this._currentProviderId = providerId || null;
|
|
407
432
|
this._currentModelId = modelId || null;
|
|
408
433
|
this._emitChange(previousProviderId, previousModelId);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/aparte-model-selector.ts"],"sourcesContent":["import {\n aparteGlobalConfig,\n deferHydrationOf,\n escapeAttr,\n resolveConfig,\n type AparteConfig,\n type AparteConfigAware,\n AparteSelect,\n type AparteOptgroup,\n type AparteAIProvider,\n type AparteAIModel,\n type AparteModelChangeEventDetail,\n type AparteSelectChangeDetail,\n} from '@aparte/core';\n\ninterface ProviderModels {\n provider: AparteAIProvider;\n models: AparteAIModel[];\n}\n\n/**\n * Escape a value before it is interpolated into an HTML string (text node or\n * double-quoted attribute). Model names/ids come from a remote `/models`\n * endpoint and provider labels from consumer config — both hostile-by-default,\n * and both flow through `innerHTML` when the option list is (re)built.\n */\nfunction esc(value: unknown): string {\n // Coerce, then delegate: core owns the escaping. This local copy used to\n // inline it and, like two of its eight siblings across the scope, left the\n // apostrophe through — enough to break out of a single-quoted attribute.\n return escapeAttr(String(value ?? ''));\n}\n\n/**\n * Selects an AI provider and a model. Renders an `<aparte-select>` with providers\n * grouped into `<aparte-optgroup>`s — a single provider renders a flat list — which is\n * what makes the BYOK pattern possible without core knowing about any vendor.\n *\n * These tags sat at the top of the file, above the imports and a helper, so nothing\n * read them: TypeScript associates only the comment adjacent to the declaration. This\n * package ships no manifest of its own today (only `@aparte/core` runs `cem analyze`),\n * so the loss was invisible to tooling — but it is also what an editor shows on hover,\n * and what a typed framework wrapper is written from.\n *\n * @element aparte-model-selector\n * @attr {boolean} auto-select - Selects the first model as soon as one is available.\n * @attr {boolean} persist - Writes the selection into the config, which is what the next message is sent with.\n * Without it the picker only fires `aparte-model-change`, and applying the choice is the app's. It does not\n * outlive a reload on its own: that takes `setModelPreferenceProvider()` and `restoreModelPreference()`.\n * @attr {boolean} searchable - Adds the dropdown's filter field.\n * @attr {boolean} details - Shows, under each model's name, its `description` and its `contextWindow` — the metadata a provider already declares. The trigger keeps the name alone; the filter searches the line too.\n * @attr {string} placeholder - Overrides the text shown while nothing is selected.\n * @attr {boolean} disabled - Disables the picker. Inside an `<aparte-composer>` it also follows the\n * composer's own `disabled`, so a disabled composer does not leave its model picker operable.\n *\n * @fires {CustomEvent<AparteModelChangeEventDetail>} aparte-model-change - The provider or the model changed; carries both ids.\n *\n * @example\n * <!-- Mount it in the composer's toolbar; it reads the models the config already knows. -->\n * <aparte-composer-toolbar>\n * <aparte-model-selector searchable placeholder=\"Pick a model\"></aparte-model-selector>\n * </aparte-composer-toolbar>\n */\nexport class AparteModelSelector extends HTMLElement implements AparteConfigAware {\n private _currentProviderId: string | null = null;\n private _currentModelId: string | null = null;\n private _providerModels: ProviderModels[] = [];\n private _aparteSelect: AparteSelect | null = null;\n private _isLoading = false;\n private _isRendering = false;\n /** A load was asked for while one ran; the running one goes round again. */\n private _reloadQueued = false;\n /** Bumped by {@link _restartLoading}: a load of an older generation discards its result. */\n private _loadGeneration = 0;\n /** The providers the current list was built from, as {@link _providersKey} gives them. */\n private _loadedProvidersKey = '';\n private _expandedGroups: Set<string> = new Set();\n\n /**\n * Config governing THIS element — nearest instance boundary, else the global.\n *\n * Cached rather than resolved per call, because this element does not only\n * READ it: it holds a `subscribe()` registration keyed on the object. That\n * cache is only correct if something tells us when the boundary changes, and\n * under all four wrappers it does change after we connect —\n * `AparteChatHost.bind()` runs `attachConfig` from a post-mount hook. Hence\n * {@link AparteConfigAware}; without it this element served the global config's\n * providers to a chat that was given its own.\n */\n private _cfg: AparteConfig = aparteGlobalConfig;\n\n private _configUnsubscribe: (() => void) | null = null;\n\n // Bound handlers for cleanup\n private _boundHandleChange = this._handleChange.bind(this);\n private _handleOptgroupToggle = (e: Event): void => { void this._onOptgroupToggle(e); };\n /** The composer we sit in, if any — its `disabled` is ours too. */\n private _composer: Element | null = null;\n private _boundComposerChange = (): void => { this._syncDisabled(); };\n\n static get observedAttributes(): string[] {\n return ['persist', 'auto-select', 'searchable', 'placeholder', 'disabled', 'details'];\n }\n\n async connectedCallback(): Promise<void> {\n this._cfg = resolveConfig(this);\n // A fresh mount always does a full load, whatever a previous mount left running.\n this._restartLoading();\n this._providerModels = [];\n\n this._setupEventListeners();\n // The public event, not the composer's private bus: a disabled composer says so\n // through `aparte-composer-change`, and the picker inside it follows.\n this._composer = this.closest('aparte-composer');\n this._composer?.addEventListener('aparte-composer-change', this._boundComposerChange);\n\n // Seed selection from the resolved config first (handles race conditions)\n this._seenConfigSelection = this._configSelectionKey();\n const config = this._cfg.getModelConfig();\n if (config.defaultProvider && config.defaultModel) {\n this._currentProviderId = config.defaultProvider;\n this._currentModelId = config.defaultModel;\n } else {\n this._loadPersistedSelection();\n }\n\n // Subscribe BEFORE the first load, not after it. Importing this plugin defines the\n // element, and a tag already in the page connects right then — before the module\n // that imported it has run the rest of its body, which is where the providers get\n // registered. Subscribed after the `await`, that registration fired into nothing\n // and the picker stayed empty for the life of the page.\n this._subscribeToConfig();\n if (await this._loadAllProviderModels()) this._render();\n }\n\n /**\n * The config's own selection when this element last read it. A change to IT is someone\n * choosing a model (an onboarding flow, `setModelConfig`); every other config change — a\n * language, a provider, an icon — leaves the person's own pick alone. Compared with the\n * pick instead, a pick made without `persist` (which writes nothing to the config) was\n * put back to the config's default by the next unrelated change.\n */\n private _seenConfigSelection = '';\n\n private _configSelectionKey(): string {\n const c = this._cfg.getModelConfig();\n return `${c.defaultProvider ?? ''}::${c.defaultModel ?? ''}`;\n }\n\n /** The registered providers, as one comparable string: what the list was built from. */\n private _providersKey(): string {\n return this._cfg.getAIProviders().map(p => p.id).join('\\n');\n }\n\n /** Listen for configuration changes (e.g. from an onboarding flow). */\n private _subscribeToConfig(): void {\n this._configUnsubscribe?.();\n this._configUnsubscribe = this._cfg.subscribe(() => {\n void (async () => {\n // Guard: only react if the model config actually changed relative to what we\n // read — its selection, or the set of providers the list was built from\n // (an app that registers a provider once a key is typed in its settings).\n const selectionMoved = this._configSelectionKey() !== this._seenConfigSelection;\n if (!selectionMoved &&\n this._providerModels.length > 0 &&\n this._providersKey() === this._loadedProvidersKey) {\n // …but a config change is not only a MODEL change. A language\n // switch fires this subscription too, hit this guard, and left\n // the placeholder in the previous language — the one string this\n // element takes from the locale, and the only one a user sees\n // before opening the list.\n //\n // The guard stays: a full `_render()` re-loads every provider's\n // models asynchronously and would close an open dropdown and\n // discard a typed search. So the cheap path is a relabel — one\n // attribute, no rebuild — which is the same contract a segment\n // renderer's `relabel` works under.\n this._relabel();\n return;\n }\n\n if (selectionMoved) {\n this._seenConfigSelection = this._configSelectionKey();\n this._loadPersistedSelection();\n }\n if (await this._loadAllProviderModels()) this._render();\n })();\n });\n }\n\n /**\n * Re-apply the one string this element takes from the locale, in place.\n *\n * An explicit `placeholder` attribute still wins, exactly as it does at render\n * time: the app's own copy is not the locale's to overwrite.\n */\n private _relabel(): void {\n if (!this._aparteSelect) return;\n const fromLocale = this._cfg.getLocale()['modelSelectorPlaceholder'] || 'Select a model...';\n this._aparteSelect.setAttribute('placeholder', this.getAttribute('placeholder') || fromLocale);\n // The `details` lines are locale text too (\"{n} context\", the number's format): written\n // in place, so an open list and a typed search survive the language switch.\n if (!this.hasAttribute('details')) return;\n // One lookup of the options and one number format for the whole list: a catalogue\n // of hundreds of models is relabelled on every config change.\n const options = new Map(Array.from(this.querySelectorAll('aparte-option'), (o) => [o.getAttribute('value'), o]));\n const tokens = this._tokenFormat();\n for (const pm of this._providerModels) {\n for (const m of pm.models) {\n const line = options.get(`${pm.provider.id}::${m.id}`)?.querySelector('.aparte-option__meta');\n if (line) line.textContent = this._metaText(m, tokens);\n }\n }\n }\n\n /** How a token count is written in the locale's language: 128K, 128 k… */\n private _tokenFormat(): Intl.NumberFormat {\n return new Intl.NumberFormat(this._cfg.getLocale().tag || undefined, { notation: 'compact', maximumFractionDigits: 1 });\n }\n\n /** The line under a model's name with `details`: what its provider declares about it. */\n private _metaText(m: { description?: string; contextWindow?: number }, tokens: Intl.NumberFormat): string {\n const parts: string[] = [];\n if (m.description) parts.push(m.description);\n if (m.contextWindow && m.contextWindow > 0) {\n const size = tokens.format(m.contextWindow);\n parts.push((this._cfg.t('modelContextWindow') || '{n} context').replace('{n}', () => size));\n }\n return parts.join(' · ');\n }\n\n disconnectedCallback(): void {\n this._aparteSelect?.removeEventListener('aparte-select-change', this._boundHandleChange);\n this.removeEventListener('aparte-optgroup-toggle', this._handleOptgroupToggle);\n this._composer?.removeEventListener('aparte-composer-change', this._boundComposerChange);\n this._composer = null;\n this._configUnsubscribe?.();\n }\n\n /**\n * The boundary above us appeared or changed: move the subscription and reload,\n * because a different config means different providers and a different\n * selection.\n *\n * See {@link AparteConfigAware}. The element's own per-instance tests passed\n * before this existed only because they mount the boundary FIRST — the one\n * ordering no wrapper produces.\n */\n aparteConfigChanged(next: AparteConfig): void {\n this._configUnsubscribe?.();\n this._configUnsubscribe = null;\n this._cfg = next;\n if (!this.isConnected) return;\n void (async () => {\n this._restartLoading();\n this._providerModels = [];\n this._seenConfigSelection = this._configSelectionKey();\n const model = this._cfg.getModelConfig();\n if (model.defaultProvider && model.defaultModel) {\n this._currentProviderId = model.defaultProvider;\n this._currentModelId = model.defaultModel;\n } else {\n this._loadPersistedSelection();\n }\n this._subscribeToConfig();\n if (await this._loadAllProviderModels()) this._render();\n })();\n }\n\n attributeChangedCallback(): void {\n if (this.isConnected && !this._isLoading) {\n this._render();\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Public API\n // ─────────────────────────────────────────────────────────────────────────\n\n /** Current provider ID. */\n get providerId(): string | null {\n return this._currentProviderId;\n }\n\n /** Current model ID. */\n get modelId(): string | null {\n return this._currentModelId;\n }\n\n /** Programmatically set the selection. */\n setSelection(providerId: string, modelId: string): void {\n this._currentProviderId = providerId;\n this._currentModelId = modelId;\n\n const compositeValue = `${providerId}::${modelId}`;\n if (this._aparteSelect) {\n this._aparteSelect.value = compositeValue;\n }\n\n this._emitChange();\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Data Loading\n // ─────────────────────────────────────────────────────────────────────────\n\n /**\n * Load every provider's models. A call that arrives while a load runs does not start a\n * second one and does not vanish either: the running load goes round again, reading\n * what changed meanwhile, and answers `false` so its caller leaves the render to the\n * load that is still running.\n */\n private async _loadAllProviderModels(): Promise<boolean> {\n if (this._isLoading) {\n this._reloadQueued = true;\n return false;\n }\n const generation = this._loadGeneration;\n this._isLoading = true;\n try {\n do {\n this._reloadQueued = false;\n await this._loadOnce(generation);\n } while (this._reloadQueued && this.isConnected && generation === this._loadGeneration);\n } finally {\n // A restart already handed the flag to the load that replaced this one.\n if (generation === this._loadGeneration) this._isLoading = false;\n }\n return generation === this._loadGeneration;\n }\n\n /**\n * Start over: a mount, or a new config above us. A load still in flight from before\n * keeps running — its fetches cannot be called back — but it is now of an older\n * generation, so it discards what it brings back instead of writing it over the list\n * the new load builds. Under every wrapper this is the normal order: the element\n * connects on the global config, then `bind()` attaches the chat's own, and a slow\n * global `/models` used to land last and win.\n */\n private _restartLoading(): void {\n this._loadGeneration++;\n this._isLoading = false;\n this._reloadQueued = false;\n }\n\n private async _loadOnce(generation: number): Promise<void> {\n const providersKey = this._providersKey();\n const providers = this._cfg.getAIProviders();\n\n // Deduplicate providers by ID just in case\n const uniqueProviders = Array.from(new Map(providers.map(p => [p.id, p])).values());\n\n const config = this._cfg.getModelConfig();\n\n // Store in a temporary list to avoid mid-render state corruption.\n //\n // Indexed by REGISTRATION order, not filled by completion order. The\n // fetches run in parallel, so a `push` here ordered the dropdown — and\n // therefore what `auto-select` picks — by whichever /models endpoint\n // answered first. A cloud provider on a CDN beats a local server that\n // has to wake up, so an app registering `[OLLAMA, LMSTUDIO, OPENROUTER]`\n // could silently land on the paid one, and land on a different one on\n // the next reload. `auto-select` documents itself as \"the first model\";\n // first has to mean first, not fastest.\n const tempList: (ProviderModels | undefined)[] = new Array(uniqueProviders.length);\n\n // Fetch all providers in parallel\n await Promise.all(uniqueProviders.map(async (provider, i) => {\n try {\n // A provider with a fixed list has no `fetchModels`: its `getModels()` IS the\n // list, and `refreshProviderModels` answers `[]` for it.\n const models = provider.fetchModels\n ? await this._cfg.refreshProviderModels(provider.id)\n : provider.getModels();\n\n // Apply model filters if configured\n const filters = config.modelFilters?.[provider.id];\n const filteredModels = filters?.length\n ? models.filter(m => filters.includes(m.id))\n : models;\n\n if (filteredModels.length > 0) {\n tempList[i] = { provider, models: filteredModels };\n }\n } catch (error) {\n console.warn(`[AparteModelSelector] Failed to load models for ${provider.id}:`, error);\n }\n }));\n\n if (generation !== this._loadGeneration) return;\n // The holes are the providers that failed or returned nothing: dropped,\n // which keeps the order of the survivors.\n this._providerModels = tempList.filter((pm): pm is ProviderModels => pm !== undefined);\n this._loadedProvidersKey = providersKey;\n }\n\n private async _onOptgroupToggle(e: Event): Promise<void> {\n const detail = (e as CustomEvent).detail;\n\n // Track expansion state\n if (detail.collapsed) {\n this._expandedGroups.delete(detail.label);\n return;\n }\n\n this._expandedGroups.add(detail.label);\n\n // Find which provider this optgroup belongs to\n const pm = this._providerModels.find(p => p.provider.getMetadata().name === detail.label);\n if (!pm || !pm.provider.fetchModels) return;\n\n // Show a loading state on the optgroup while we lazily fetch its models\n const groupEl = e.target as HTMLElement;\n if (groupEl && groupEl.tagName === 'APARTE-OPTGROUP') {\n (groupEl as AparteOptgroup).loading = true;\n }\n\n try {\n // Retrieve latest models via Config (provider-agnostic)\n const freshModels = await this._cfg.refreshProviderModels(pm.provider.id);\n\n if (freshModels && freshModels.length > 0) {\n pm.models = freshModels;\n this._render(true);\n }\n } catch (error) {\n console.error(`[AparteModelSelector] Lazy fetch failed for ${pm.provider.id}:`, error);\n } finally {\n const el = e.target as HTMLElement;\n if (el && el.tagName === 'APARTE-OPTGROUP') {\n (el as AparteOptgroup).loading = false;\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Rendering\n // ─────────────────────────────────────────────────────────────────────────\n\n /** Our own attribute, or the disabled state of the composer we sit in. */\n private _isDisabled(): boolean {\n return this.hasAttribute('disabled') || (this._composer?.hasAttribute('disabled') ?? false);\n }\n\n private _syncDisabled(): void {\n this._aparteSelect?.toggleAttribute('disabled', this._isDisabled());\n }\n\n private _render(keepOpen = false): void {\n if (this._isRendering) return;\n this._isRendering = true;\n\n try {\n this._renderImpl(keepOpen);\n } finally {\n this._isRendering = false;\n }\n }\n\n private _renderImpl(keepOpen: boolean): void {\n // Attribute overrides locale\n const localePlaceholder = this._cfg.getLocale()['modelSelectorPlaceholder'] || 'Select a model...';\n const placeholder = this.getAttribute('placeholder') || localePlaceholder;\n const searchable = this.hasAttribute('searchable');\n // The line under a name: what the provider declares about the model, when asked for.\n const details = this.hasAttribute('details');\n const tokens = details ? this._tokenFormat() : null;\n const meta = (m: { description?: string; contextWindow?: number }): string => {\n const text = tokens ? this._metaText(m, tokens) : '';\n return text ? `<span class=\"aparte-option__meta\">${esc(text)}</span>` : '';\n };\n const autoSelect = this.hasAttribute('auto-select');\n\n // Capture current open state of aparte-select if it exists\n const wasOpen = keepOpen || this._aparteSelect?.hasAttribute('open');\n\n // Determine current value\n let currentValue = this._currentModelId ? `${this._currentProviderId}::${this._currentModelId}` : '';\n\n if (!currentValue && autoSelect) {\n const first = this._providerModels[0];\n const firstModel = first?.models[0];\n if (first && firstModel) {\n this._currentProviderId = first.provider.id;\n this._currentModelId = firstModel.id;\n currentValue = `${this._currentProviderId}::${this._currentModelId}`;\n // Emit the initial change once the element settles\n setTimeout(() => this._emitChange(), 0);\n }\n }\n\n // Build options HTML — single provider: flat list; multiple: grouped optgroups\n const only = this._providerModels[0];\n const singleProvider = this._providerModels.length === 1;\n const optionsHtml = singleProvider && only // safe-text: every value below goes through esc(); the tags are this file's own\n ? only.models.map(m => {\n const key = `${only.provider.id}::${m.id}`;\n return `<aparte-option value=\"${esc(key)}\">${esc(m.name)}${meta(m)}</aparte-option>`;\n }).join('')\n : this._providerModels.map(pm => {\n const label = pm.provider.getMetadata().name;\n const isCollapsed = !this._expandedGroups.has(label);\n return `\n <aparte-optgroup\n label=\"${esc(label)}\"\n collapsible\n ${isCollapsed ? 'collapsed' : ''}\n >\n ${pm.models.map(m => {\n const key = `${pm.provider.id}::${m.id}`;\n return `<aparte-option value=\"${esc(key)}\">${esc(m.name)}${meta(m)}</aparte-option>`;\n }).join('')}\n </aparte-optgroup>\n `;\n }).join('');\n\n if (this._aparteSelect) {\n // Non-destructive update of attributes\n this._aparteSelect.setAttribute('placeholder', placeholder);\n if (currentValue) this._aparteSelect.setAttribute('value', currentValue);\n else this._aparteSelect.removeAttribute('value');\n\n if (searchable) this._aparteSelect.setAttribute('searchable', '');\n else this._aparteSelect.removeAttribute('searchable');\n\n this._syncDisabled();\n\n if (wasOpen) this._aparteSelect.setAttribute('open', '');\n else this._aparteSelect.removeAttribute('open');\n\n // Update children cleanly: prefer direct container update if available\n const optionsContainer = this._aparteSelect.querySelector('.aparte-select-options');\n if (optionsContainer) {\n // Direct update (faster, skips the observer)\n optionsContainer.innerHTML = optionsHtml;\n\n // Force label re-evaluation: remove then re-set value so aparte-select\n // re-scans the newly injected options (setAttribute guard blocks same-value updates)\n if (currentValue) {\n this._aparteSelect.removeAttribute('value');\n this._aparteSelect.setAttribute('value', currentValue);\n }\n } else {\n // Fallback: self-healing mode\n const temp = document.createElement('div');\n temp.innerHTML = optionsHtml;\n const newChildren = Array.from(temp.children);\n\n const childrenToRemove = Array.from(this._aparteSelect.children).filter(c =>\n c.tagName === 'APARTE-OPTION' || c.tagName === 'APARTE-OPTGROUP'\n );\n childrenToRemove.forEach(c => c.remove());\n\n newChildren.forEach(c => this._aparteSelect?.appendChild(c));\n }\n\n // Critical: re-apply value after a microtask so AparteSelect has processed\n // the new options and can resolve the label.\n if (currentValue) {\n setTimeout(() => {\n if (this._aparteSelect) {\n this._aparteSelect.value = currentValue;\n }\n }, 0);\n }\n } else {\n // Full initial render.\n //\n // The select carries no class of ours: this element is already addressable\n // as `aparte-model-selector aparte-select`, which is what a consumer\n // restyling it writes. The `aparte-model-selector-select` that used to be\n // here carried no CSS and was queried by nothing — it named the element a\n // second time, and a class that neither styles nor selects is not a hook.\n this.innerHTML = `\n <aparte-select\n placeholder=\"${esc(placeholder)}\"\n ${currentValue ? `value=\"${esc(currentValue)}\"` : ''}\n ${searchable ? 'searchable' : ''}\n ${this._isDisabled() ? 'disabled' : ''}\n ${wasOpen ? 'open' : ''}\n >\n ${optionsHtml}\n </aparte-select>\n `;\n this._aparteSelect = this.querySelector('aparte-select');\n this._setupEventListeners();\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Event Handling\n // ─────────────────────────────────────────────────────────────────────────\n\n private _setupEventListeners(): void {\n this._aparteSelect?.addEventListener('aparte-select-change', this._boundHandleChange);\n this.addEventListener('aparte-optgroup-toggle', this._handleOptgroupToggle);\n }\n\n private _handleChange(e: Event): void {\n const detail = (e as CustomEvent<AparteSelectChangeDetail>).detail;\n const previousProviderId = this._currentProviderId;\n const previousModelId = this._currentModelId;\n\n // Parse composite value \"providerId::modelId\"\n const [providerId, modelId] = detail.value.split('::');\n\n this._currentProviderId = providerId || null;\n this._currentModelId = modelId || null;\n\n this._emitChange(previousProviderId, previousModelId);\n }\n\n private _emitChange(previousProviderId?: string | null, previousModelId?: string | null): void {\n const detail: AparteModelChangeEventDetail = {\n providerId: this._currentProviderId || undefined,\n modelId: this._currentModelId || '',\n previousProviderId: previousProviderId || undefined,\n previousModelId: previousModelId || undefined,\n };\n\n this.dispatchEvent(new CustomEvent<AparteModelChangeEventDetail>('aparte-model-change', {\n bubbles: true,\n composed: true,\n detail,\n }));\n\n // Persist if enabled\n if (this.hasAttribute('persist')) {\n this._persistSelection();\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Persistence (opt-in)\n // ─────────────────────────────────────────────────────────────────────────\n\n private _persistSelection(): void {\n if (!this._currentProviderId || !this._currentModelId) return;\n\n // Sync with the config — auto-save is handled by its setModelConfig()\n // if a AparteModelPreferenceProvider has been registered by the host app.\n const currentConfig = this._cfg.getModelConfig();\n if (currentConfig.defaultProvider === this._currentProviderId &&\n currentConfig.defaultModel === this._currentModelId) {\n return;\n }\n\n this._seenConfigSelection = `${this._currentProviderId}::${this._currentModelId}`;\n this._cfg.setModelConfig({\n defaultProvider: this._currentProviderId,\n defaultModel: this._currentModelId,\n });\n }\n\n private _loadPersistedSelection(): void {\n // The resolved config is the single source of truth. The host app is\n // responsible for restoring preferences into it (via restoreModelPreference())\n // before this component mounts.\n const config = this._cfg.getModelConfig();\n if (config.defaultProvider && config.defaultModel) {\n this._currentProviderId = config.defaultProvider;\n this._currentModelId = config.defaultModel;\n }\n // else: no-op — the config is empty\n }\n}\n\n// Register the custom element\nif (!customElements.get('aparte-model-selector')) {\n // Before defining, like core's own elements: in a server-rendered chat the tag waits\n // for the wrapper's release instead of drawing into the DOM the framework hydrates.\n deferHydrationOf(AparteModelSelector);\n customElements.define('aparte-model-selector', AparteModelSelector);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'aparte-model-selector': AparteModelSelector;\n }\n}\n"],"names":[],"mappings":";AA0BA,SAAS,IAAI,OAAwB;AAIjC,SAAO,WAAW,OAAO,SAAS,EAAE,CAAC;AACzC;AAgCO,MAAM,4BAA4B,YAAyC;AAAA,EACtE,qBAAoC;AAAA,EACpC,kBAAiC;AAAA,EACjC,kBAAoC,CAAA;AAAA,EACpC,gBAAqC;AAAA,EACrC,aAAa;AAAA,EACb,eAAe;AAAA;AAAA,EAEf,gBAAgB;AAAA;AAAA,EAEhB,kBAAkB;AAAA;AAAA,EAElB,sBAAsB;AAAA,EACtB,sCAAmC,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAanC,OAAqB;AAAA,EAErB,qBAA0C;AAAA;AAAA,EAG1C,qBAAqB,KAAK,cAAc,KAAK,IAAI;AAAA,EACjD,wBAAwB,CAAC,MAAmB;AAAE,SAAK,KAAK,kBAAkB,CAAC;AAAA,EAAG;AAAA;AAAA,EAE9E,YAA4B;AAAA,EAC5B,uBAAuB,MAAY;AAAE,SAAK,cAAA;AAAA,EAAiB;AAAA,EAEnE,WAAW,qBAA+B;AACtC,WAAO,CAAC,WAAW,eAAe,cAAc,eAAe,YAAY,SAAS;AAAA,EACxF;AAAA,EAEA,MAAM,oBAAmC;AACrC,SAAK,OAAO,cAAc,IAAI;AAE9B,SAAK,gBAAA;AACL,SAAK,kBAAkB,CAAA;AAEvB,SAAK,qBAAA;AAGL,SAAK,YAAY,KAAK,QAAQ,iBAAiB;AAC/C,SAAK,WAAW,iBAAiB,0BAA0B,KAAK,oBAAoB;AAGpF,SAAK,uBAAuB,KAAK,oBAAA;AACjC,UAAM,SAAS,KAAK,KA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AAS,GAAG;AAC9B,WAAK,kBAAA;AAAA,IACT;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAMQ,oBAA0B;AAC9B,QAAI,CAAC,KAAK,sBAAsB,CAAC,KAAK,gBAAiB;AAIvD,UAAM,gBAAgB,KAAK,KAAK,eAAA;AAChC,QAAI,cAAc,oBAAoB,KAAK,sBACvC,cAAc,iBAAiB,KAAK,iBAAiB;AACrD;AAAA,IACJ;AAEA,SAAK,uBAAuB,GAAG,KAAK,kBAAkB,KAAK,KAAK,eAAe;AAC/E,SAAK,KAAK,eAAe;AAAA,MACrB,iBAAiB,KAAK;AAAA,MACtB,cAAc,KAAK;AAAA,IAAA,CACtB;AAAA,EACL;AAAA,EAEQ,0BAAgC;AAIpC,UAAM,SAAS,KAAK,KAAK,eAAA;AACzB,QAAI,OAAO,mBAAmB,OAAO,cAAc;AAC/C,WAAK,qBAAqB,OAAO;AACjC,WAAK,kBAAkB,OAAO;AAAA,IAClC;AAAA,EAEJ;AACJ;AAGA,IAAI,CAAC,eAAe,IAAI,uBAAuB,GAAG;AAG9C,mBAAiB,mBAAmB;AACpC,iBAAe,OAAO,yBAAyB,mBAAmB;AACtE;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/aparte-model-selector.ts"],"sourcesContent":["import {\n aparteGlobalConfig,\n deferHydrationOf,\n escapeAttr,\n resolveConfig,\n type AparteConfig,\n type AparteConfigAware,\n AparteSelect,\n type AparteOptgroup,\n type AparteAIProvider,\n type AparteAIModel,\n type AparteModelChangeEventDetail,\n type AparteSelectChangeDetail,\n type AparteCollectCommandsEventDetail,\n} from '@aparte/core';\n\ninterface ProviderModels {\n provider: AparteAIProvider;\n models: AparteAIModel[];\n}\n\ninterface CommandRow {\n id: string;\n label: string;\n icon?: string;\n run?(): void;\n children?: CommandRow[];\n}\n\n/**\n * Escape a value before it is interpolated into an HTML string (text node or\n * double-quoted attribute). Model names/ids come from a remote `/models`\n * endpoint and provider labels from consumer config — both hostile-by-default,\n * and both flow through `innerHTML` when the option list is (re)built.\n */\nfunction esc(value: unknown): string {\n // Coerce, then delegate: core owns the escaping. This local copy used to\n // inline it and, like two of its eight siblings across the scope, left the\n // apostrophe through — enough to break out of a single-quoted attribute.\n return escapeAttr(String(value ?? ''));\n}\n\n/**\n * Selects an AI provider and a model. Renders an `<aparte-select>` with providers\n * grouped into `<aparte-optgroup>`s — a single provider renders a flat list — which is\n * what makes the BYOK pattern possible without core knowing about any vendor.\n *\n * These tags sat at the top of the file, above the imports and a helper, so nothing\n * read them: TypeScript associates only the comment adjacent to the declaration. This\n * package ships no manifest of its own today (only `@aparte/core` runs `cem analyze`),\n * so the loss was invisible to tooling — but it is also what an editor shows on hover,\n * and what a typed framework wrapper is written from.\n *\n * @element aparte-model-selector\n * @attr {string} commands - `false` keeps `/model` out of `@aparte/plugin-triggers`' menu.\n * @attr {boolean} auto-select - Selects the first model as soon as one is available.\n * @attr {boolean} persist - Writes the selection into the config, which is what the next message is sent with.\n * Without it the picker only fires `aparte-model-change`, and applying the choice is the app's. It does not\n * outlive a reload on its own: that takes `setModelPreferenceProvider()` and `restoreModelPreference()`.\n * @attr {boolean} searchable - Adds the dropdown's filter field.\n * @attr {boolean} details - Shows, under each model's name, its `description` and its `contextWindow` — the metadata a provider already declares. The trigger keeps the name alone; the filter searches the line too.\n * @attr {string} placeholder - Overrides the text shown while nothing is selected.\n * @attr {boolean} disabled - Disables the picker. Inside an `<aparte-composer>` it also follows the\n * composer's own `disabled`, so a disabled composer does not leave its model picker operable.\n *\n * @fires {CustomEvent<AparteModelChangeEventDetail>} aparte-model-change - The provider or the model changed; carries both ids.\n *\n * @example\n * <!-- Mount it in the composer's toolbar; it reads the models the config already knows. -->\n * <aparte-composer-toolbar>\n * <aparte-model-selector searchable placeholder=\"Pick a model\"></aparte-model-selector>\n * </aparte-composer-toolbar>\n */\nexport class AparteModelSelector extends HTMLElement implements AparteConfigAware {\n private _currentProviderId: string | null = null;\n private _currentModelId: string | null = null;\n private _providerModels: ProviderModels[] = [];\n private _aparteSelect: AparteSelect | null = null;\n private _isLoading = false;\n private _isRendering = false;\n /** A load was asked for while one ran; the running one goes round again. */\n private _reloadQueued = false;\n /** Bumped by {@link _restartLoading}: a load of an older generation discards its result. */\n private _loadGeneration = 0;\n /** The providers the current list was built from, as {@link _providersKey} gives them. */\n private _loadedProvidersKey = '';\n private _expandedGroups: Set<string> = new Set();\n\n /**\n * Config governing THIS element — nearest instance boundary, else the global.\n *\n * Cached rather than resolved per call, because this element does not only\n * READ it: it holds a `subscribe()` registration keyed on the object. That\n * cache is only correct if something tells us when the boundary changes, and\n * under all four wrappers it does change after we connect —\n * `AparteChatHost.bind()` runs `attachConfig` from a post-mount hook. Hence\n * {@link AparteConfigAware}; without it this element served the global config's\n * providers to a chat that was given its own.\n */\n private _cfg: AparteConfig = aparteGlobalConfig;\n\n private _configUnsubscribe: (() => void) | null = null;\n\n // Bound handlers for cleanup\n private _boundHandleChange = this._handleChange.bind(this);\n private _handleOptgroupToggle = (e: Event): void => { void this._onOptgroupToggle(e); };\n /** The composer we sit in, if any — its `disabled` is ours too. */\n private _composer: Element | null = null;\n private _boundComposerChange = (): void => { this._syncDisabled(); };\n\n static get observedAttributes(): string[] {\n return ['persist', 'auto-select', 'searchable', 'placeholder', 'disabled', 'details'];\n }\n\n /** Answers `@aparte/plugin-triggers`' menu with `/model`, unless `commands=\"false\"`. */\n private readonly _onCollectCommands = (e: Event): void => {\n const { detail } = e as CustomEvent<AparteCollectCommandsEventDetail>;\n if (detail.config !== this._cfg || this.getAttribute('commands') === 'false' || this._providerModels.length === 0 || this._isDisabled()) return;\n // Several chats can share a config: each selector answers for its own.\n const chat = this.closest('aparte-chat, [data-aparte-chat]');\n if (this._composer ? this._composer !== detail.composer : chat && chat !== detail.chat) return;\n const several = this._providerModels.length > 1;\n const rows = (entry: ProviderModels): CommandRow[] => entry.models.map((model) => ({\n id: `${entry.provider.id}::${model.id}`,\n label: model.name || model.id,\n ...(entry.provider.id === this._currentProviderId && model.id === this._currentModelId ? { icon: 'check' } : {}),\n run: () => this.setSelection(entry.provider.id, model.id),\n }));\n detail.add({\n id: 'model',\n order: 60,\n description: this._cfg.t('triggersCommandModel'),\n children: several\n ? this._providerModels.map((entry) => ({ id: entry.provider.id, label: entry.provider.getMetadata().name, children: rows(entry) }))\n : rows(this._providerModels[0]!),\n });\n };\n\n async connectedCallback(): Promise<void> {\n this._cfg = resolveConfig(this);\n window.addEventListener('aparte-collect-commands', this._onCollectCommands);\n // A fresh mount always does a full load, whatever a previous mount left running.\n this._restartLoading();\n this._providerModels = [];\n\n this._setupEventListeners();\n // The public event, not the composer's private bus: a disabled composer says so\n // through `aparte-composer-change`, and the picker inside it follows.\n this._composer = this.closest('aparte-composer');\n this._composer?.addEventListener('aparte-composer-change', this._boundComposerChange);\n\n // Seed selection from the resolved config first (handles race conditions)\n this._seenConfigSelection = this._configSelectionKey();\n const config = this._cfg.getModelConfig();\n if (config.defaultProvider && config.defaultModel) {\n this._currentProviderId = config.defaultProvider;\n this._currentModelId = config.defaultModel;\n } else {\n this._loadPersistedSelection();\n }\n\n // Subscribe BEFORE the first load, not after it. Importing this plugin defines the\n // element, and a tag already in the page connects right then — before the module\n // that imported it has run the rest of its body, which is where the providers get\n // registered. Subscribed after the `await`, that registration fired into nothing\n // and the picker stayed empty for the life of the page.\n this._subscribeToConfig();\n if (await this._loadAllProviderModels()) this._render();\n }\n\n /**\n * The config's own selection when this element last read it. A change to IT is someone\n * choosing a model (an onboarding flow, `setModelConfig`); every other config change — a\n * language, a provider, an icon — leaves the person's own pick alone. Compared with the\n * pick instead, a pick made without `persist` (which writes nothing to the config) was\n * put back to the config's default by the next unrelated change.\n */\n private _seenConfigSelection = '';\n\n private _configSelectionKey(): string {\n const c = this._cfg.getModelConfig();\n return `${c.defaultProvider ?? ''}::${c.defaultModel ?? ''}`;\n }\n\n /** The registered providers, as one comparable string: what the list was built from. */\n private _providersKey(): string {\n return this._cfg.getAIProviders().map(p => p.id).join('\\n');\n }\n\n /** Listen for configuration changes (e.g. from an onboarding flow). */\n private _subscribeToConfig(): void {\n this._configUnsubscribe?.();\n this._configUnsubscribe = this._cfg.subscribe(() => {\n void (async () => {\n // Guard: only react if the model config actually changed relative to what we\n // read — its selection, or the set of providers the list was built from\n // (an app that registers a provider once a key is typed in its settings).\n const selectionMoved = this._configSelectionKey() !== this._seenConfigSelection;\n if (!selectionMoved &&\n this._providerModels.length > 0 &&\n this._providersKey() === this._loadedProvidersKey) {\n // …but a config change is not only a MODEL change. A language\n // switch fires this subscription too, hit this guard, and left\n // the placeholder in the previous language — the one string this\n // element takes from the locale, and the only one a user sees\n // before opening the list.\n //\n // The guard stays: a full `_render()` re-loads every provider's\n // models asynchronously and would close an open dropdown and\n // discard a typed search. So the cheap path is a relabel — one\n // attribute, no rebuild — which is the same contract a segment\n // renderer's `relabel` works under.\n this._relabel();\n return;\n }\n\n if (selectionMoved) {\n this._seenConfigSelection = this._configSelectionKey();\n this._loadPersistedSelection();\n }\n if (await this._loadAllProviderModels()) this._render();\n })();\n });\n }\n\n /**\n * Re-apply the one string this element takes from the locale, in place.\n *\n * An explicit `placeholder` attribute still wins, exactly as it does at render\n * time: the app's own copy is not the locale's to overwrite.\n */\n private _relabel(): void {\n if (!this._aparteSelect) return;\n const fromLocale = this._cfg.getLocale()['modelSelectorPlaceholder'] || 'Select a model...';\n this._aparteSelect.setAttribute('placeholder', this.getAttribute('placeholder') || fromLocale);\n // The `details` lines are locale text too (\"{n} context\", the number's format): written\n // in place, so an open list and a typed search survive the language switch.\n if (!this.hasAttribute('details')) return;\n // One lookup of the options and one number format for the whole list: a catalogue\n // of hundreds of models is relabelled on every config change.\n const options = new Map(Array.from(this.querySelectorAll('aparte-option'), (o) => [o.getAttribute('value'), o]));\n const tokens = this._tokenFormat();\n for (const pm of this._providerModels) {\n for (const m of pm.models) {\n const line = options.get(`${pm.provider.id}::${m.id}`)?.querySelector('.aparte-option__meta');\n if (line) line.textContent = this._metaText(m, tokens);\n }\n }\n }\n\n /** How a token count is written in the locale's language: 128K, 128 k… */\n private _tokenFormat(): Intl.NumberFormat {\n return new Intl.NumberFormat(this._cfg.getLocale().tag || undefined, { notation: 'compact', maximumFractionDigits: 1 });\n }\n\n /** The line under a model's name with `details`: what its provider declares about it. */\n private _metaText(m: { description?: string; contextWindow?: number }, tokens: Intl.NumberFormat): string {\n const parts: string[] = [];\n if (m.description) parts.push(m.description);\n if (m.contextWindow && m.contextWindow > 0) {\n const size = tokens.format(m.contextWindow);\n parts.push((this._cfg.t('modelContextWindow') || '{n} context').replace('{n}', () => size));\n }\n return parts.join(' · ');\n }\n\n disconnectedCallback(): void {\n window.removeEventListener('aparte-collect-commands', this._onCollectCommands);\n this._aparteSelect?.removeEventListener('aparte-select-change', this._boundHandleChange);\n this.removeEventListener('aparte-optgroup-toggle', this._handleOptgroupToggle);\n this._composer?.removeEventListener('aparte-composer-change', this._boundComposerChange);\n this._composer = null;\n this._configUnsubscribe?.();\n }\n\n /**\n * The boundary above us appeared or changed: move the subscription and reload,\n * because a different config means different providers and a different\n * selection.\n *\n * See {@link AparteConfigAware}. The element's own per-instance tests passed\n * before this existed only because they mount the boundary FIRST — the one\n * ordering no wrapper produces.\n */\n aparteConfigChanged(next: AparteConfig): void {\n this._configUnsubscribe?.();\n this._configUnsubscribe = null;\n this._cfg = next;\n if (!this.isConnected) return;\n void (async () => {\n this._restartLoading();\n this._providerModels = [];\n this._seenConfigSelection = this._configSelectionKey();\n const model = this._cfg.getModelConfig();\n if (model.defaultProvider && model.defaultModel) {\n this._currentProviderId = model.defaultProvider;\n this._currentModelId = model.defaultModel;\n } else {\n this._loadPersistedSelection();\n }\n this._subscribeToConfig();\n if (await this._loadAllProviderModels()) this._render();\n })();\n }\n\n attributeChangedCallback(): void {\n if (this.isConnected && !this._isLoading) {\n this._render();\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Public API\n // ─────────────────────────────────────────────────────────────────────────\n\n /** Current provider ID. */\n get providerId(): string | null {\n return this._currentProviderId;\n }\n\n /** Current model ID. */\n get modelId(): string | null {\n return this._currentModelId;\n }\n\n /** Programmatically set the selection. */\n setSelection(providerId: string, modelId: string): void {\n const previousProviderId = this._currentProviderId;\n const previousModelId = this._currentModelId;\n this._currentProviderId = providerId;\n this._currentModelId = modelId;\n\n const compositeValue = `${providerId}::${modelId}`;\n if (this._aparteSelect) {\n this._aparteSelect.value = compositeValue;\n }\n\n this._emitChange(previousProviderId, previousModelId);\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Data Loading\n // ─────────────────────────────────────────────────────────────────────────\n\n /**\n * Load every provider's models. A call that arrives while a load runs does not start a\n * second one and does not vanish either: the running load goes round again, reading\n * what changed meanwhile, and answers `false` so its caller leaves the render to the\n * load that is still running.\n */\n private async _loadAllProviderModels(): Promise<boolean> {\n if (this._isLoading) {\n this._reloadQueued = true;\n return false;\n }\n const generation = this._loadGeneration;\n this._isLoading = true;\n try {\n do {\n this._reloadQueued = false;\n await this._loadOnce(generation);\n } while (this._reloadQueued && this.isConnected && generation === this._loadGeneration);\n } finally {\n // A restart already handed the flag to the load that replaced this one.\n if (generation === this._loadGeneration) this._isLoading = false;\n }\n return generation === this._loadGeneration;\n }\n\n /**\n * Start over: a mount, or a new config above us. A load still in flight from before\n * keeps running — its fetches cannot be called back — but it is now of an older\n * generation, so it discards what it brings back instead of writing it over the list\n * the new load builds. Under every wrapper this is the normal order: the element\n * connects on the global config, then `bind()` attaches the chat's own, and a slow\n * global `/models` used to land last and win.\n */\n private _restartLoading(): void {\n this._loadGeneration++;\n this._isLoading = false;\n this._reloadQueued = false;\n }\n\n private async _loadOnce(generation: number): Promise<void> {\n const providersKey = this._providersKey();\n const providers = this._cfg.getAIProviders();\n\n // Deduplicate providers by ID just in case\n const uniqueProviders = Array.from(new Map(providers.map(p => [p.id, p])).values());\n\n const config = this._cfg.getModelConfig();\n\n // Store in a temporary list to avoid mid-render state corruption.\n //\n // Indexed by REGISTRATION order, not filled by completion order. The\n // fetches run in parallel, so a `push` here ordered the dropdown — and\n // therefore what `auto-select` picks — by whichever /models endpoint\n // answered first. A cloud provider on a CDN beats a local server that\n // has to wake up, so an app registering `[OLLAMA, LMSTUDIO, OPENROUTER]`\n // could silently land on the paid one, and land on a different one on\n // the next reload. `auto-select` documents itself as \"the first model\";\n // first has to mean first, not fastest.\n const tempList: (ProviderModels | undefined)[] = new Array(uniqueProviders.length);\n\n // Fetch all providers in parallel\n await Promise.all(uniqueProviders.map(async (provider, i) => {\n try {\n // A provider with a fixed list has no `fetchModels`: its `getModels()` IS the\n // list, and `refreshProviderModels` answers `[]` for it.\n const models = provider.fetchModels\n ? await this._cfg.refreshProviderModels(provider.id)\n : provider.getModels();\n\n // Apply model filters if configured\n const filters = config.modelFilters?.[provider.id];\n const filteredModels = filters?.length\n ? models.filter(m => filters.includes(m.id))\n : models;\n\n if (filteredModels.length > 0) {\n tempList[i] = { provider, models: filteredModels };\n }\n } catch (error) {\n console.warn(`[AparteModelSelector] Failed to load models for ${provider.id}:`, error);\n }\n }));\n\n if (generation !== this._loadGeneration) return;\n // The holes are the providers that failed or returned nothing: dropped,\n // which keeps the order of the survivors.\n this._providerModels = tempList.filter((pm): pm is ProviderModels => pm !== undefined);\n this._loadedProvidersKey = providersKey;\n }\n\n private async _onOptgroupToggle(e: Event): Promise<void> {\n const detail = (e as CustomEvent).detail;\n\n // Track expansion state\n if (detail.collapsed) {\n this._expandedGroups.delete(detail.label);\n return;\n }\n\n this._expandedGroups.add(detail.label);\n\n // Find which provider this optgroup belongs to\n const pm = this._providerModels.find(p => p.provider.getMetadata().name === detail.label);\n if (!pm || !pm.provider.fetchModels) return;\n\n // Show a loading state on the optgroup while we lazily fetch its models\n const groupEl = e.target as HTMLElement;\n if (groupEl && groupEl.tagName === 'APARTE-OPTGROUP') {\n (groupEl as AparteOptgroup).loading = true;\n }\n\n try {\n // Retrieve latest models via Config (provider-agnostic)\n const freshModels = await this._cfg.refreshProviderModels(pm.provider.id);\n\n if (freshModels && freshModels.length > 0) {\n pm.models = freshModels;\n this._render(true);\n }\n } catch (error) {\n console.error(`[AparteModelSelector] Lazy fetch failed for ${pm.provider.id}:`, error);\n } finally {\n const el = e.target as HTMLElement;\n if (el && el.tagName === 'APARTE-OPTGROUP') {\n (el as AparteOptgroup).loading = false;\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Rendering\n // ─────────────────────────────────────────────────────────────────────────\n\n /** Our own attribute, or the disabled state of the composer we sit in. */\n private _isDisabled(): boolean {\n return this.hasAttribute('disabled') || (this._composer?.hasAttribute('disabled') ?? false);\n }\n\n private _syncDisabled(): void {\n this._aparteSelect?.toggleAttribute('disabled', this._isDisabled());\n }\n\n private _render(keepOpen = false): void {\n if (this._isRendering) return;\n this._isRendering = true;\n\n try {\n this._renderImpl(keepOpen);\n } finally {\n this._isRendering = false;\n }\n }\n\n private _renderImpl(keepOpen: boolean): void {\n // Attribute overrides locale\n const localePlaceholder = this._cfg.getLocale()['modelSelectorPlaceholder'] || 'Select a model...';\n const placeholder = this.getAttribute('placeholder') || localePlaceholder;\n const searchable = this.hasAttribute('searchable');\n // The line under a name: what the provider declares about the model, when asked for.\n const details = this.hasAttribute('details');\n const tokens = details ? this._tokenFormat() : null;\n const meta = (m: { description?: string; contextWindow?: number }): string => {\n const text = tokens ? this._metaText(m, tokens) : '';\n return text ? `<span class=\"aparte-option__meta\">${esc(text)}</span>` : '';\n };\n const autoSelect = this.hasAttribute('auto-select');\n\n // Capture current open state of aparte-select if it exists\n const wasOpen = keepOpen || this._aparteSelect?.hasAttribute('open');\n\n // Determine current value\n let currentValue = this._currentModelId ? `${this._currentProviderId}::${this._currentModelId}` : '';\n\n if (!currentValue && autoSelect) {\n const first = this._providerModels[0];\n const firstModel = first?.models[0];\n if (first && firstModel) {\n this._currentProviderId = first.provider.id;\n this._currentModelId = firstModel.id;\n currentValue = `${this._currentProviderId}::${this._currentModelId}`;\n // Emit the initial change once the element settles\n setTimeout(() => this._emitChange(), 0);\n }\n }\n\n // Build options HTML — single provider: flat list; multiple: grouped optgroups\n const only = this._providerModels[0];\n const singleProvider = this._providerModels.length === 1;\n const optionsHtml = singleProvider && only // safe-text: every value below goes through esc(); the tags are this file's own\n ? only.models.map(m => {\n const key = `${only.provider.id}::${m.id}`;\n return `<aparte-option value=\"${esc(key)}\">${esc(m.name)}${meta(m)}</aparte-option>`;\n }).join('')\n : this._providerModels.map(pm => {\n const label = pm.provider.getMetadata().name;\n const isCollapsed = !this._expandedGroups.has(label);\n return `\n <aparte-optgroup\n label=\"${esc(label)}\"\n collapsible\n ${isCollapsed ? 'collapsed' : ''}\n >\n ${pm.models.map(m => {\n const key = `${pm.provider.id}::${m.id}`;\n return `<aparte-option value=\"${esc(key)}\">${esc(m.name)}${meta(m)}</aparte-option>`;\n }).join('')}\n </aparte-optgroup>\n `;\n }).join('');\n\n if (this._aparteSelect) {\n // Non-destructive update of attributes\n this._aparteSelect.setAttribute('placeholder', placeholder);\n if (currentValue) this._aparteSelect.setAttribute('value', currentValue);\n else this._aparteSelect.removeAttribute('value');\n\n if (searchable) this._aparteSelect.setAttribute('searchable', '');\n else this._aparteSelect.removeAttribute('searchable');\n\n this._syncDisabled();\n\n if (wasOpen) this._aparteSelect.setAttribute('open', '');\n else this._aparteSelect.removeAttribute('open');\n\n // Update children cleanly: prefer direct container update if available\n const optionsContainer = this._aparteSelect.querySelector('.aparte-select-options');\n if (optionsContainer) {\n // Direct update (faster, skips the observer)\n optionsContainer.innerHTML = optionsHtml;\n\n // Force label re-evaluation: remove then re-set value so aparte-select\n // re-scans the newly injected options (setAttribute guard blocks same-value updates)\n if (currentValue) {\n this._aparteSelect.removeAttribute('value');\n this._aparteSelect.setAttribute('value', currentValue);\n }\n } else {\n // Fallback: self-healing mode\n const temp = document.createElement('div');\n temp.innerHTML = optionsHtml;\n const newChildren = Array.from(temp.children);\n\n const childrenToRemove = Array.from(this._aparteSelect.children).filter(c =>\n c.tagName === 'APARTE-OPTION' || c.tagName === 'APARTE-OPTGROUP'\n );\n childrenToRemove.forEach(c => c.remove());\n\n newChildren.forEach(c => this._aparteSelect?.appendChild(c));\n }\n\n // Critical: re-apply value after a microtask so AparteSelect has processed\n // the new options and can resolve the label.\n if (currentValue) {\n setTimeout(() => {\n if (this._aparteSelect) {\n this._aparteSelect.value = currentValue;\n }\n }, 0);\n }\n } else {\n // Full initial render.\n //\n // The select carries no class of ours: this element is already addressable\n // as `aparte-model-selector aparte-select`, which is what a consumer\n // restyling it writes. The `aparte-model-selector-select` that used to be\n // here carried no CSS and was queried by nothing — it named the element a\n // second time, and a class that neither styles nor selects is not a hook.\n this.innerHTML = `\n <aparte-select\n placeholder=\"${esc(placeholder)}\"\n ${currentValue ? `value=\"${esc(currentValue)}\"` : ''}\n ${searchable ? 'searchable' : ''}\n ${this._isDisabled() ? 'disabled' : ''}\n ${wasOpen ? 'open' : ''}\n >\n ${optionsHtml}\n </aparte-select>\n `;\n this._aparteSelect = this.querySelector('aparte-select');\n this._setupEventListeners();\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Event Handling\n // ─────────────────────────────────────────────────────────────────────────\n\n private _setupEventListeners(): void {\n this._aparteSelect?.addEventListener('aparte-select-change', this._boundHandleChange);\n this.addEventListener('aparte-optgroup-toggle', this._handleOptgroupToggle);\n }\n\n private _handleChange(e: Event): void {\n const detail = (e as CustomEvent<AparteSelectChangeDetail>).detail;\n const previousProviderId = this._currentProviderId;\n const previousModelId = this._currentModelId;\n\n // Parse composite value \"providerId::modelId\"\n const [providerId, modelId] = detail.value.split('::');\n // `setSelection` moved the select, and says so itself: once, with what it changed from.\n if (providerId === this._currentProviderId && modelId === this._currentModelId) return;\n\n this._currentProviderId = providerId || null;\n this._currentModelId = modelId || null;\n\n this._emitChange(previousProviderId, previousModelId);\n }\n\n private _emitChange(previousProviderId?: string | null, previousModelId?: string | null): void {\n const detail: AparteModelChangeEventDetail = {\n providerId: this._currentProviderId || undefined,\n modelId: this._currentModelId || '',\n previousProviderId: previousProviderId || undefined,\n previousModelId: previousModelId || undefined,\n };\n\n this.dispatchEvent(new CustomEvent<AparteModelChangeEventDetail>('aparte-model-change', {\n bubbles: true,\n composed: true,\n detail,\n }));\n\n // Persist if enabled\n if (this.hasAttribute('persist')) {\n this._persistSelection();\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Persistence (opt-in)\n // ─────────────────────────────────────────────────────────────────────────\n\n private _persistSelection(): void {\n if (!this._currentProviderId || !this._currentModelId) return;\n\n // Sync with the config — auto-save is handled by its setModelConfig()\n // if a AparteModelPreferenceProvider has been registered by the host app.\n const currentConfig = this._cfg.getModelConfig();\n if (currentConfig.defaultProvider === this._currentProviderId &&\n currentConfig.defaultModel === this._currentModelId) {\n return;\n }\n\n this._seenConfigSelection = `${this._currentProviderId}::${this._currentModelId}`;\n this._cfg.setModelConfig({\n defaultProvider: this._currentProviderId,\n defaultModel: this._currentModelId,\n });\n }\n\n private _loadPersistedSelection(): void {\n // The resolved config is the single source of truth. The host app is\n // responsible for restoring preferences into it (via restoreModelPreference())\n // before this component mounts.\n const config = this._cfg.getModelConfig();\n if (config.defaultProvider && config.defaultModel) {\n this._currentProviderId = config.defaultProvider;\n this._currentModelId = config.defaultModel;\n }\n // else: no-op — the config is empty\n }\n}\n\n// Register the custom element\nif (!customElements.get('aparte-model-selector')) {\n // Before defining, like core's own elements: in a server-rendered chat the tag waits\n // for the wrapper's release instead of drawing into the DOM the framework hydrates.\n deferHydrationOf(AparteModelSelector);\n customElements.define('aparte-model-selector', AparteModelSelector);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'aparte-model-selector': AparteModelSelector;\n }\n}\n"],"names":[],"mappings":";AAmCA,SAAS,IAAI,OAAwB;AAIjC,SAAO,WAAW,OAAO,SAAS,EAAE,CAAC;AACzC;AAiCO,MAAM,4BAA4B,YAAyC;AAAA,EACtE,qBAAoC;AAAA,EACpC,kBAAiC;AAAA,EACjC,kBAAoC,CAAA;AAAA,EACpC,gBAAqC;A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tB;AAAA,EACL;AAAA,EAEQ,0BAAgC;AAIpC,UAAM,SAAS,KAAK,KAAK,eAAA;AACzB,QAAI,OAAO,mBAAmB,OAAO,cAAc;AAC/C,WAAK,qBAAqB,OAAO;AACjC,WAAK,kBAAkB,OAAO;AAAA,IAClC;AAAA,EAEJ;AACJ;AAGA,IAAI,CAAC,eAAe,IAAI,uBAAuB,GAAG;AAG9C,mBAAiB,mBAAmB;AACpC,iBAAe,OAAO,yBAAyB,mBAAmB;AACtE;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aparte/plugin-model-selector",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"homepage": "https://apartejs.dev/components/model-selector/",
|
|
5
5
|
"description": "Provider + model selector web component (<aparte-model-selector>) for aparté — grouped dropdown, BYOK.",
|
|
6
6
|
"type": "module",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@angular/core": "^19.2.0 || ^20.0.0 || ^21.0.0",
|
|
73
|
-
"@aparte/core": ">=1.0
|
|
73
|
+
"@aparte/core": ">=1.1.0 <2.0.0",
|
|
74
74
|
"react": "^18.0.0 || ^19.0.0",
|
|
75
75
|
"svelte": "^4.0.0 || ^5.20.0",
|
|
76
76
|
"vue": "^3.5.0"
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"vite": "^6.0.0",
|
|
93
93
|
"vue": "^3.5.0",
|
|
94
94
|
"zone.js": "~0.15.0",
|
|
95
|
-
"@aparte/core": "1.0
|
|
95
|
+
"@aparte/core": "1.1.0"
|
|
96
96
|
},
|
|
97
97
|
"keywords": [
|
|
98
98
|
"aparte",
|