@magicx-eng/ai-autocomplete-angular 0.5.7 → 0.6.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.
@@ -1,9 +1,10 @@
1
+ import { buildAttributionUrl, getFooterHint, AIAutocomplete, getCursorOffset, extractPlainText, renderEditableContent, plainTextLength, setCursorOffset, ModeController, buildSubmitResult } from '@magicx-eng/ai-autocomplete-vanilla';
2
+ export { buildSubmitResult, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
1
3
  import * as i1 from '@angular/common';
2
4
  import { CommonModule, isPlatformBrowser } from '@angular/common';
3
5
  import * as i0 from '@angular/core';
4
6
  import { Component, ChangeDetectionStrategy, ViewEncapsulation, Input, EventEmitter, Output, ViewChild, inject, ChangeDetectorRef, ElementRef, Renderer2, NgZone, Directive, PLATFORM_ID, forwardRef, NgModule } from '@angular/core';
5
7
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
6
- import { buildAttributionUrl, getFooterHint, AIAutocomplete, getCursorOffset, extractPlainText, renderEditableContent, plainTextLength, setCursorOffset, ModeController, buildQuery } from '@magicx-eng/ai-autocomplete-vanilla';
7
8
  import { BehaviorSubject, combineLatest, map as map$1, distinctUntilChanged, shareReplay, Subject, takeUntil } from 'rxjs';
8
9
  import { map } from 'rxjs/operators';
9
10
 
@@ -579,16 +580,21 @@ class AIAutocompleteController {
579
580
  // handed. The core notifies listeners synchronously, and some actions
580
581
  // trigger reentrant `store.set` calls (e.g. typing a non-matching char
581
582
  // during re-edit makes the core synchronously exit re-edit and kick off a
582
- // fetch). Reentrancy makes the outer set's listener loop continue with a
583
- // now-stale snapshot, so the listener can fire *out of order* — delivering
584
- // an older state (still in re-edit) after a newer one (re-edit exited).
585
- // Reading `getState()` at emission time collapses every notification onto
586
- // the true latest state, so a stale `editingParam` can't resurrect and
587
- // retrigger the editor's re-edit caret-park (which would yank the caret
588
- // back to where re-editing started). distinctUntilChanged downstream drops
589
- // the resulting duplicate emissions. React avoids this because it batches
590
- // renders and its caret effects are dependency-gated; our subscription is
591
- // synchronous, so we coalesce here instead.
583
+ // fetch).
584
+ //
585
+ // The core's store used to deliver such a nested set inline and then
586
+ // resume the outer listener loop, so a listener could be handed an older
587
+ // state (still in re-edit) *after* a newer one (re-edit exited) — which
588
+ // resurrected a stale `editingParam` and retriggered the editor's re-edit
589
+ // caret-park, yanking the caret back to where re-editing started. The
590
+ // store now queues notifications and drains them in order, so that
591
+ // out-of-order delivery can no longer happen at the source.
592
+ //
593
+ // Reading `getState()` at emission time is kept as belt-and-braces: it
594
+ // costs nothing (distinctUntilChanged downstream drops the duplicate
595
+ // emissions) and keeps this bridge correct for any future consumer that
596
+ // emits mid-cascade. React needs neither, since it batches renders and
597
+ // gates its caret effects on dependencies.
592
598
  this.unsubscribeCore = this.core.subscribe(() => {
593
599
  if (!this.isDestroyed)
594
600
  this.rawState$.next(this.core.getState());
@@ -602,6 +608,7 @@ class AIAutocompleteController {
602
608
  // works fine.
603
609
  this.text$ = deriveField(this.rawState$, (s) => s.text);
604
610
  this.completedParams$ = deriveField(this.rawState$, (s) => s.completedParams, arrEq);
611
+ this.skippedParams$ = deriveField(this.rawState$, (s) => s.skippedParams, arrEq);
605
612
  this.suggestionPills$ = deriveField(this.rawState$, (s) => s.actionableSuggestions, arrEq);
606
613
  this.segments$ = deriveField(this.rawState$, (s) => s.segments, arrEq);
607
614
  this.newParamId$ = deriveField(this.rawState$, (s) => s.newParamId);
@@ -809,6 +816,7 @@ function computeState(s) {
809
816
  return {
810
817
  text: s.text,
811
818
  completedParams: s.completedParams,
819
+ skippedParams: s.skippedParams,
812
820
  suggestionPills: s.actionableSuggestions,
813
821
  segments: s.segments,
814
822
  newParamId: s.newParamId,
@@ -1402,13 +1410,9 @@ class AIAutocompleteComponent {
1402
1410
  if (!editor)
1403
1411
  return;
1404
1412
  const text = extractPlainText(editor);
1405
- const params = (_b = this.completedParams) !== null && _b !== void 0 ? _b : this.controller.getState().completedParams;
1406
- const built = buildQuery(text, params);
1407
- this.submitted.emit({
1408
- query: text.trim(),
1409
- raw_query: built.rawQuery,
1410
- completed_params: built.completedParams,
1411
- });
1413
+ const state = this.controller.getState();
1414
+ const params = (_b = this.completedParams) !== null && _b !== void 0 ? _b : state.completedParams;
1415
+ this.submitted.emit(buildSubmitResult(text, params, state.skippedParams));
1412
1416
  this.controller.reset();
1413
1417
  }
1414
1418
  handleSubmitFromUserAction() {
@@ -1829,7 +1833,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1829
1833
  * planned export list. Only symbols re-exported here are considered part of
1830
1834
  * the package's public contract (TDB §19.2).
1831
1835
  */
1832
- // === Tier 1: Full component ===
1836
+ // === Submit-result builder (folds skipped params into completed_params) ===
1833
1837
 
1834
1838
  /**
1835
1839
  * Generated bundle index. Do not edit.