maplibre-gl-geoagent 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{GeoAgentControl-J26MMwe5.cjs → GeoAgentControl-DdRAg6Nf.cjs} +167 -18
  2. package/dist/{GeoAgentControl-J26MMwe5.cjs.map → GeoAgentControl-DdRAg6Nf.cjs.map} +1 -1
  3. package/dist/{GeoAgentControl-BWSkl9b-.js → GeoAgentControl-ixWp8KFN.js} +167 -18
  4. package/dist/{GeoAgentControl-BWSkl9b-.js.map → GeoAgentControl-ixWp8KFN.js.map} +1 -1
  5. package/dist/{anthropic-D2xJ9IO4.cjs → anthropic-DN5bZZYl.cjs} +2 -2
  6. package/dist/{anthropic-D2xJ9IO4.cjs.map → anthropic-DN5bZZYl.cjs.map} +1 -1
  7. package/dist/{anthropic-DqtWmJMG.js → anthropic-fbFV8vsy.js} +2 -2
  8. package/dist/{anthropic-DqtWmJMG.js.map → anthropic-fbFV8vsy.js.map} +1 -1
  9. package/dist/{browser-DTYbc3Sp.js → browser-BdcLoQF1.js} +2 -2
  10. package/dist/{browser-DTYbc3Sp.js.map → browser-BdcLoQF1.js.map} +1 -1
  11. package/dist/{browser-ZyWGgIdV.cjs → browser-tB9M0iL7.cjs} +2 -2
  12. package/dist/{browser-ZyWGgIdV.cjs.map → browser-tB9M0iL7.cjs.map} +1 -1
  13. package/dist/{index-DnnohXIw.js → index-BHlW-XGv.js} +2 -2
  14. package/dist/{index-DnnohXIw.js.map → index-BHlW-XGv.js.map} +1 -1
  15. package/dist/{index-oSbeAq6a.js → index-CAfXh7NK.js} +2 -2
  16. package/dist/{index-oSbeAq6a.js.map → index-CAfXh7NK.js.map} +1 -1
  17. package/dist/{index-DHGV30Mr.cjs → index-CMusYhSC.cjs} +2 -2
  18. package/dist/{index-DHGV30Mr.cjs.map → index-CMusYhSC.cjs.map} +1 -1
  19. package/dist/{index-CRfykVWh.js → index-CXoyZ3E-.js} +2 -2
  20. package/dist/{index-CRfykVWh.js.map → index-CXoyZ3E-.js.map} +1 -1
  21. package/dist/{index-D7y77wpc.cjs → index-GeIdoDMK.cjs} +2 -2
  22. package/dist/{index-D7y77wpc.cjs.map → index-GeIdoDMK.cjs.map} +1 -1
  23. package/dist/{index-cO0gccGg.cjs → index-TSQ43SxX.cjs} +2 -2
  24. package/dist/{index-cO0gccGg.cjs.map → index-TSQ43SxX.cjs.map} +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.mjs +1 -1
  27. package/dist/maplibre-gl-geoagent.css +35 -0
  28. package/dist/react.cjs +1 -1
  29. package/dist/react.mjs +1 -1
  30. package/dist/types/lib/core/GeoAgentControl.d.ts +17 -0
  31. package/dist/types/lib/core/GeoAgentControl.d.ts.map +1 -1
  32. package/package.json +1 -1
@@ -3519,7 +3519,7 @@ class HttpProtocol extends SerdeContext {
3519
3519
  });
3520
3520
  }
3521
3521
  async loadEventStreamCapability() {
3522
- const { EventStreamSerde } = await Promise.resolve().then(() => require("./index-cO0gccGg.cjs"));
3522
+ const { EventStreamSerde } = await Promise.resolve().then(() => require("./index-TSQ43SxX.cjs"));
3523
3523
  return new EventStreamSerde({
3524
3524
  marshaller: this.getEventStreamMarshaller(),
3525
3525
  serializer: this.serializer,
@@ -42665,7 +42665,7 @@ class EarthEngineService {
42665
42665
  }
42666
42666
  async loadEe() {
42667
42667
  if (!this.eePromise) {
42668
- this.eePromise = Promise.resolve().then(() => require("./browser-ZyWGgIdV.cjs")).then((n) => n.browser).then((module2) => {
42668
+ this.eePromise = Promise.resolve().then(() => require("./browser-tB9M0iL7.cjs")).then((n) => n.browser).then((module2) => {
42669
42669
  const imported = "default" in module2 ? module2.default : module2;
42670
42670
  const ee = imported;
42671
42671
  const scope2 = globalThis;
@@ -46073,6 +46073,15 @@ const _GeoAgentControl = class _GeoAgentControl {
46073
46073
  __publicField(this, "verifyToken", 0);
46074
46074
  __publicField(this, "configNoteTimer", null);
46075
46075
  __publicField(this, "modelListId", `geoagent-model-list-${_GeoAgentControl.instanceCount += 1}`);
46076
+ // Loaded model names backing the custom suggestion dropdown. A native
46077
+ // <datalist> is intentionally avoided: clicking the model field to open
46078
+ // Chrome's native datalist popup with a long list hangs the renderer.
46079
+ __publicField(this, "modelOptions", []);
46080
+ // Index of the highlighted suggestion (-1 = none), and the values currently
46081
+ // rendered in the dropdown (the filtered subset).
46082
+ __publicField(this, "activeSuggestion", -1);
46083
+ __publicField(this, "renderedSuggestions", []);
46084
+ __publicField(this, "suggestionBlurTimer", null);
46076
46085
  // Whether the agent was configured at the last control refresh, used to fold
46077
46086
  // the settings section away the first time setup completes.
46078
46087
  __publicField(this, "wasConfigured", false);
@@ -46159,6 +46168,10 @@ const _GeoAgentControl = class _GeoAgentControl {
46159
46168
  clearTimeout(this.configNoteTimer);
46160
46169
  this.configNoteTimer = null;
46161
46170
  }
46171
+ if (this.suggestionBlurTimer !== null) {
46172
+ clearTimeout(this.suggestionBlurTimer);
46173
+ this.suggestionBlurTimer = null;
46174
+ }
46162
46175
  this.verifyToken++;
46163
46176
  (_a3 = this.activeAbortController) == null ? void 0 : _a3.abort();
46164
46177
  (_b3 = this.agent) == null ? void 0 : _b3.cancel();
@@ -46387,10 +46400,10 @@ const _GeoAgentControl = class _GeoAgentControl {
46387
46400
  <label class="geoagent-model-cell">
46388
46401
  Model
46389
46402
  <div class="geoagent-model-row">
46390
- <input class="geoagent-model-id" list="${this.modelListId}" autocomplete="off" />
46403
+ <input class="geoagent-model-id" autocomplete="off" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-controls="${this.modelListId}" />
46391
46404
  <button class="geoagent-load-models secondary" type="button">Load models</button>
46392
46405
  </div>
46393
- <datalist class="geoagent-model-list" id="${this.modelListId}"></datalist>
46406
+ <ul class="geoagent-model-suggestions" id="${this.modelListId}" role="listbox" hidden></ul>
46394
46407
  </label>
46395
46408
  <div class="geoagent-config-note" aria-live="polite" hidden></div>
46396
46409
  </div>
@@ -46446,7 +46459,7 @@ const _GeoAgentControl = class _GeoAgentControl {
46446
46459
  baseUrlLabel: this.requiredElement(content, ".geoagent-base-url-row"),
46447
46460
  baseUrlInput: this.requiredElement(content, ".geoagent-base-url"),
46448
46461
  modelIdInput: this.requiredElement(content, ".geoagent-model-id"),
46449
- modelList: this.requiredElement(content, ".geoagent-model-list"),
46462
+ modelSuggestions: this.requiredElement(content, ".geoagent-model-suggestions"),
46450
46463
  loadModelsButton: this.requiredElement(content, ".geoagent-load-models"),
46451
46464
  configNote: this.requiredElement(content, ".geoagent-config-note"),
46452
46465
  bedrockRegionLabel: this.requiredElement(content, ".geoagent-bedrock-region-row"),
@@ -46615,6 +46628,29 @@ const _GeoAgentControl = class _GeoAgentControl {
46615
46628
  this.invalidateAgent();
46616
46629
  this.updateControls();
46617
46630
  this.emit("statechange");
46631
+ this.openModelSuggestions();
46632
+ });
46633
+ ui.modelIdInput.addEventListener(
46634
+ "focus",
46635
+ () => this.openModelSuggestions(false)
46636
+ );
46637
+ ui.modelIdInput.addEventListener(
46638
+ "keydown",
46639
+ (event) => this.handleModelKeydown(event)
46640
+ );
46641
+ ui.modelIdInput.addEventListener("blur", () => {
46642
+ this.suggestionBlurTimer = setTimeout(
46643
+ () => this.closeModelSuggestions(),
46644
+ 150
46645
+ );
46646
+ });
46647
+ ui.modelSuggestions.addEventListener("mousedown", (event) => {
46648
+ const item = event.target.closest("li[data-value]");
46649
+ if (!item) {
46650
+ return;
46651
+ }
46652
+ event.preventDefault();
46653
+ this.selectModelSuggestion(item.getAttribute("data-value") ?? "");
46618
46654
  });
46619
46655
  ui.bedrockRegionInput.addEventListener("input", () => {
46620
46656
  const region = ui.bedrockRegionInput.value.trim();
@@ -47231,16 +47267,125 @@ ${markdown.trim()}`;
47231
47267
  }
47232
47268
  }
47233
47269
  populateModelOptions(models) {
47270
+ this.modelOptions = models;
47271
+ if (this.ui && !this.ui.modelSuggestions.hidden) {
47272
+ this.openModelSuggestions(false);
47273
+ }
47274
+ }
47275
+ filterModelOptions(query) {
47276
+ const needle = query.trim().toLowerCase();
47277
+ const matches = needle ? this.modelOptions.filter(
47278
+ (model) => model.toLowerCase().includes(needle)
47279
+ ) : this.modelOptions;
47280
+ return matches.slice(0, _GeoAgentControl.MAX_SUGGESTIONS);
47281
+ }
47282
+ /**
47283
+ * Open (or refresh) the custom model suggestion dropdown. With `useFilter`
47284
+ * (typing) the list narrows to the current input value; without it (focus,
47285
+ * arrow keys) the full loaded list is shown so the user can browse even when
47286
+ * the field already holds the default model.
47287
+ */
47288
+ openModelSuggestions(useFilter = true) {
47234
47289
  if (!this.ui) {
47235
47290
  return;
47236
47291
  }
47237
- const list = this.ui.modelList;
47238
- list.replaceChildren();
47239
- for (const model of models) {
47240
- const option = document.createElement("option");
47241
- option.value = model;
47242
- list.appendChild(option);
47292
+ if (this.suggestionBlurTimer !== null) {
47293
+ clearTimeout(this.suggestionBlurTimer);
47294
+ this.suggestionBlurTimer = null;
47295
+ }
47296
+ const filtered = this.filterModelOptions(
47297
+ useFilter ? this.ui.modelIdInput.value : ""
47298
+ );
47299
+ if (filtered.length === 0) {
47300
+ this.closeModelSuggestions();
47301
+ return;
47302
+ }
47303
+ this.renderedSuggestions = filtered;
47304
+ this.activeSuggestion = -1;
47305
+ const list = this.ui.modelSuggestions;
47306
+ list.replaceChildren(
47307
+ ...filtered.map((model, index) => {
47308
+ const item = document.createElement("li");
47309
+ item.className = "geoagent-model-suggestion";
47310
+ item.setAttribute("role", "option");
47311
+ item.dataset.value = model;
47312
+ item.id = `${this.modelListId}-opt-${index}`;
47313
+ item.textContent = model;
47314
+ return item;
47315
+ })
47316
+ );
47317
+ list.hidden = false;
47318
+ this.ui.modelIdInput.setAttribute("aria-expanded", "true");
47319
+ }
47320
+ closeModelSuggestions() {
47321
+ if (this.suggestionBlurTimer !== null) {
47322
+ clearTimeout(this.suggestionBlurTimer);
47323
+ this.suggestionBlurTimer = null;
47324
+ }
47325
+ this.renderedSuggestions = [];
47326
+ this.activeSuggestion = -1;
47327
+ if (this.ui) {
47328
+ this.ui.modelSuggestions.hidden = true;
47329
+ this.ui.modelSuggestions.replaceChildren();
47330
+ this.ui.modelIdInput.setAttribute("aria-expanded", "false");
47331
+ this.ui.modelIdInput.removeAttribute("aria-activedescendant");
47332
+ }
47333
+ }
47334
+ selectModelSuggestion(value) {
47335
+ if (!this.ui || !value) {
47336
+ return;
47337
+ }
47338
+ this.ui.modelIdInput.value = value;
47339
+ this.ui.modelIdInput.dispatchEvent(new Event("input", { bubbles: true }));
47340
+ this.closeModelSuggestions();
47341
+ }
47342
+ handleModelKeydown(event) {
47343
+ if (!this.ui) {
47344
+ return;
47345
+ }
47346
+ if (event.key === "Escape") {
47347
+ if (!this.ui.modelSuggestions.hidden) {
47348
+ event.stopPropagation();
47349
+ this.closeModelSuggestions();
47350
+ }
47351
+ return;
47352
+ }
47353
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
47354
+ if (this.ui.modelSuggestions.hidden) {
47355
+ this.openModelSuggestions(false);
47356
+ if (this.ui.modelSuggestions.hidden) {
47357
+ return;
47358
+ }
47359
+ }
47360
+ event.preventDefault();
47361
+ const last = this.renderedSuggestions.length - 1;
47362
+ if (event.key === "ArrowDown") {
47363
+ this.activeSuggestion = this.activeSuggestion >= last ? 0 : this.activeSuggestion + 1;
47364
+ } else {
47365
+ this.activeSuggestion = this.activeSuggestion <= 0 ? last : this.activeSuggestion - 1;
47366
+ }
47367
+ this.highlightActiveSuggestion();
47368
+ return;
47243
47369
  }
47370
+ if (event.key === "Enter" && this.activeSuggestion >= 0) {
47371
+ event.preventDefault();
47372
+ this.selectModelSuggestion(this.renderedSuggestions[this.activeSuggestion]);
47373
+ }
47374
+ }
47375
+ highlightActiveSuggestion() {
47376
+ if (!this.ui) {
47377
+ return;
47378
+ }
47379
+ const items2 = this.ui.modelSuggestions.querySelectorAll("li");
47380
+ items2.forEach((item, index) => {
47381
+ var _a3;
47382
+ const active = index === this.activeSuggestion;
47383
+ item.classList.toggle("active", active);
47384
+ if (active) {
47385
+ item.scrollIntoView({ block: "nearest" });
47386
+ (_a3 = this.ui) == null ? void 0 : _a3.modelIdInput.setAttribute("aria-activedescendant", item.id);
47387
+ }
47388
+ });
47244
47389
  }
47245
47390
  normalizeBaseUrl(baseUrl) {
47246
47391
  return baseUrl.trim().replace(/\/+$/, "");
@@ -47377,7 +47522,7 @@ ${markdown.trim()}`;
47377
47522
  }
47378
47523
  async createProviderModel(providerId, modelId, apiKey, bedrockRegion, baseUrl) {
47379
47524
  if (providerId === "openai-responses" || providerId === "openai-chat") {
47380
- const { OpenAIModel } = await Promise.resolve().then(() => require("./index-D7y77wpc.cjs"));
47525
+ const { OpenAIModel } = await Promise.resolve().then(() => require("./index-GeIdoDMK.cjs"));
47381
47526
  return new OpenAIModel({
47382
47527
  api: providerId === "openai-responses" ? "responses" : "chat",
47383
47528
  modelId,
@@ -47388,7 +47533,7 @@ ${markdown.trim()}`;
47388
47533
  });
47389
47534
  }
47390
47535
  if (providerId === "openai-compatible") {
47391
- const { OpenAIModel } = await Promise.resolve().then(() => require("./index-D7y77wpc.cjs"));
47536
+ const { OpenAIModel } = await Promise.resolve().then(() => require("./index-GeIdoDMK.cjs"));
47392
47537
  return new OpenAIModel({
47393
47538
  api: "chat",
47394
47539
  modelId,
@@ -47400,7 +47545,7 @@ ${markdown.trim()}`;
47400
47545
  });
47401
47546
  }
47402
47547
  if (providerId === "anthropic") {
47403
- const { AnthropicModel } = await Promise.resolve().then(() => require("./anthropic-D2xJ9IO4.cjs"));
47548
+ const { AnthropicModel } = await Promise.resolve().then(() => require("./anthropic-DN5bZZYl.cjs"));
47404
47549
  return new AnthropicModel({
47405
47550
  modelId,
47406
47551
  apiKey,
@@ -47410,7 +47555,7 @@ ${markdown.trim()}`;
47410
47555
  });
47411
47556
  }
47412
47557
  if (providerId === "google") {
47413
- const { GoogleModel } = await Promise.resolve().then(() => require("./index-DHGV30Mr.cjs"));
47558
+ const { GoogleModel } = await Promise.resolve().then(() => require("./index-CMusYhSC.cjs"));
47414
47559
  return new GoogleModel({
47415
47560
  modelId,
47416
47561
  apiKey
@@ -47619,9 +47764,13 @@ ${BROWSER_MAPLIBRE_CODE_SYSTEM_PROMPT}` : BROWSER_MAPLIBRE_SYSTEM_PROMPT;
47619
47764
  }
47620
47765
  }
47621
47766
  };
47622
- // Unique per control instance so the model <input list> and its <datalist>
47623
- // pair up even when several controls share a page.
47767
+ // Unique per control instance so the model input's aria-controls points at its
47768
+ // own suggestion list even when several controls share a page.
47624
47769
  __publicField(_GeoAgentControl, "instanceCount", 0);
47770
+ // Cap on rendered suggestion rows. The dropdown filters as the user types, so
47771
+ // this only bounds the initial/unfiltered view and keeps a pathological model
47772
+ // list (thousands of fine-tunes) from building a huge DOM list.
47773
+ __publicField(_GeoAgentControl, "MAX_SUGGESTIONS", 100);
47625
47774
  let GeoAgentControl = _GeoAgentControl;
47626
47775
  exports.ContextWindowOverflowError = ContextWindowOverflowError;
47627
47776
  exports.DEFAULT_BASEMAPS = DEFAULT_BASEMAPS;
@@ -47649,4 +47798,4 @@ exports.toJsonValue = toJsonValue;
47649
47798
  exports.toMimeType = toMimeType;
47650
47799
  exports.toUtf8 = toUtf8;
47651
47800
  exports.warnOnce = warnOnce;
47652
- //# sourceMappingURL=GeoAgentControl-J26MMwe5.cjs.map
47801
+ //# sourceMappingURL=GeoAgentControl-DdRAg6Nf.cjs.map