@oxvo/ai-live-assist 7.5.19 → 7.5.21
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/cjs/AiLiveAssist.d.ts +8 -1
- package/cjs/AiLiveAssist.js +113 -8
- package/cjs/client.d.ts +5 -3
- package/cjs/client.js +44 -5
- package/cjs/commerce/cartContracts.d.ts +158 -0
- package/cjs/commerce/cartContracts.js +228 -0
- package/cjs/commerce/cartSession.d.ts +86 -0
- package/cjs/commerce/cartSession.js +475 -0
- package/cjs/commerce/contracts.d.ts +152 -0
- package/cjs/commerce/contracts.js +322 -0
- package/cjs/commerce/pageContext.d.ts +50 -0
- package/cjs/commerce/pageContext.js +173 -0
- package/cjs/commerce/productPanel.d.ts +65 -0
- package/cjs/commerce/productPanel.js +662 -0
- package/cjs/commerce/realtimeCommerce.d.ts +73 -0
- package/cjs/commerce/realtimeCommerce.js +342 -0
- package/cjs/commerce/shopifyCart.d.ts +130 -0
- package/cjs/commerce/shopifyCart.js +1135 -0
- package/cjs/commerce/shopifyCartPresentation.d.ts +12 -0
- package/cjs/commerce/shopifyCartPresentation.js +379 -0
- package/cjs/commerce/shoppingNotes.d.ts +61 -0
- package/cjs/commerce/shoppingNotes.js +313 -0
- package/cjs/commerce/shoppingNotesView.d.ts +46 -0
- package/cjs/commerce/shoppingNotesView.js +269 -0
- package/cjs/control.d.ts +9 -1
- package/cjs/control.js +51 -1
- package/cjs/guideAdmission.d.ts +5 -2
- package/cjs/guideAdmission.js +21 -2
- package/cjs/guideInstaller.js +1 -1
- package/cjs/guideMeasurement.d.ts +5 -0
- package/cjs/guideMeasurement.js +29 -0
- package/cjs/guideSubjectStore.js +2 -0
- package/cjs/guideTypes.d.ts +18 -0
- package/cjs/liveControlChannel.d.ts +43 -1
- package/cjs/liveControlChannel.js +166 -14
- package/cjs/liveGuideAdmission.d.ts +3 -2
- package/cjs/liveGuideAdmission.js +10 -2
- package/cjs/liveGuideWidget.d.ts +18 -0
- package/cjs/liveGuideWidget.js +228 -23
- package/cjs/locales/resources.js +2240 -0
- package/cjs/messages.js +56 -0
- package/cjs/tabLock.d.ts +2 -0
- package/cjs/tabLock.js +11 -1
- package/cjs/types.d.ts +6 -2
- package/cjs/types.js +56 -0
- package/cjs/ui.d.ts +37 -0
- package/cjs/ui.js +261 -9
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/lib/AiLiveAssist.d.ts +8 -1
- package/lib/AiLiveAssist.js +113 -8
- package/lib/client.d.ts +5 -3
- package/lib/client.js +44 -5
- package/lib/commerce/cartContracts.d.ts +158 -0
- package/lib/commerce/cartContracts.js +221 -0
- package/lib/commerce/cartSession.d.ts +86 -0
- package/lib/commerce/cartSession.js +471 -0
- package/lib/commerce/contracts.d.ts +152 -0
- package/lib/commerce/contracts.js +300 -0
- package/lib/commerce/pageContext.d.ts +50 -0
- package/lib/commerce/pageContext.js +168 -0
- package/lib/commerce/productPanel.d.ts +65 -0
- package/lib/commerce/productPanel.js +657 -0
- package/lib/commerce/realtimeCommerce.d.ts +73 -0
- package/lib/commerce/realtimeCommerce.js +337 -0
- package/lib/commerce/shopifyCart.d.ts +130 -0
- package/lib/commerce/shopifyCart.js +1130 -0
- package/lib/commerce/shopifyCartPresentation.d.ts +12 -0
- package/lib/commerce/shopifyCartPresentation.js +376 -0
- package/lib/commerce/shoppingNotes.d.ts +61 -0
- package/lib/commerce/shoppingNotes.js +307 -0
- package/lib/commerce/shoppingNotesView.d.ts +46 -0
- package/lib/commerce/shoppingNotesView.js +265 -0
- package/lib/control.d.ts +9 -1
- package/lib/control.js +51 -1
- package/lib/guideAdmission.d.ts +5 -2
- package/lib/guideAdmission.js +21 -2
- package/lib/guideInstaller.js +1 -1
- package/lib/guideMeasurement.d.ts +5 -0
- package/lib/guideMeasurement.js +24 -0
- package/lib/guideSubjectStore.js +2 -0
- package/lib/guideTypes.d.ts +18 -0
- package/lib/liveControlChannel.d.ts +43 -1
- package/lib/liveControlChannel.js +166 -14
- package/lib/liveGuideAdmission.d.ts +3 -2
- package/lib/liveGuideAdmission.js +10 -2
- package/lib/liveGuideWidget.d.ts +18 -0
- package/lib/liveGuideWidget.js +228 -23
- package/lib/locales/resources.js +2240 -0
- package/lib/messages.js +56 -0
- package/lib/tabLock.d.ts +2 -0
- package/lib/tabLock.js +11 -1
- package/lib/types.d.ts +6 -2
- package/lib/types.js +56 -0
- package/lib/ui.d.ts +37 -0
- package/lib/ui.js +261 -9
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/ui.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { AudioLines, Captions, CaptionsOff, CircleStop, Eye, EyeOff, Grid2X2Plus, Hand, Maximize2, MessageSquareText, Mic, MicOff, Minus, Minimize2, Pause, Play, RotateCcw, Send, ShieldCheck, ShieldOff, UserRound, X, createElement as createLucideElement, } from "lucide";
|
|
2
2
|
import { normalizeAvatarUrl } from "./avatarUrl.js";
|
|
3
3
|
import { DialogFocusScope } from "./dialogFocusScope.js";
|
|
4
|
+
import { createShoppingNotesScope } from "./commerce/shoppingNotes.js";
|
|
5
|
+
import { ShoppingNotesView, SHOPPING_NOTES_STYLES } from "./commerce/shoppingNotesView.js";
|
|
4
6
|
import { CtaOfferCard, CTA_OFFER_STYLES, parseCtaOffer } from "./ctaOffer.js";
|
|
7
|
+
import { CommerceProductPanel, COMMERCE_PRODUCT_PANEL_STYLES, formatCommercePrice } from "./commerce/productPanel.js";
|
|
8
|
+
import { parseCommerceBootstrap, sameCommerceStore } from "./commerce/contracts.js";
|
|
5
9
|
import { resolveWidgetMessages, widgetLocaleAttributes, } from "./locales/index.js";
|
|
6
10
|
const PANEL_POSITION_KEY = "__oxvo_ai_live_assist_compact_voice_position_v2";
|
|
7
11
|
const LEGACY_PANEL_POSITION_KEY = "__oxvo_ai_live_assist_panel_position_v1";
|
|
@@ -4322,6 +4326,9 @@ const style = `
|
|
|
4322
4326
|
export class WidgetView {
|
|
4323
4327
|
constructor(config, overrides, callbacks, options = {}) {
|
|
4324
4328
|
this.callbacks = callbacks;
|
|
4329
|
+
this.shoppingNotes = null;
|
|
4330
|
+
this.commercePanel = null;
|
|
4331
|
+
this.commerceCartStatus = null;
|
|
4325
4332
|
this.ctaCard = null;
|
|
4326
4333
|
this.ctaSlot = null;
|
|
4327
4334
|
this.ambient = null;
|
|
@@ -4334,6 +4341,7 @@ export class WidgetView {
|
|
|
4334
4341
|
this.playbackAttempt = 0;
|
|
4335
4342
|
this.destroyed = false;
|
|
4336
4343
|
this.recordingConsent = false;
|
|
4344
|
+
this.commerceCartConsent = false;
|
|
4337
4345
|
this.mediaPlaybackActive = false;
|
|
4338
4346
|
this.remoteAudioContext = null;
|
|
4339
4347
|
this.remoteAudioContextStateListener = null;
|
|
@@ -4841,12 +4849,18 @@ export class WidgetView {
|
|
|
4841
4849
|
this.manualTurnsSupported = options.manualTurnsSupported === true;
|
|
4842
4850
|
this.semanticStatus = this.messages.ready;
|
|
4843
4851
|
this.host = document.createElement("div");
|
|
4852
|
+
// The shadow host is empty in light DOM; keep storefront :empty rules from hiding it.
|
|
4853
|
+
this.host.style.setProperty("display", "block", "important");
|
|
4844
4854
|
this.host.dataset.oxvoAiLiveAssistRoot = "true";
|
|
4845
4855
|
this.host.dataset.activity = this.activity;
|
|
4846
4856
|
this.host.setAttribute("aria-live", "off");
|
|
4847
4857
|
this.shadow = this.host.attachShadow({ mode: "closed" });
|
|
4848
4858
|
const sheet = document.createElement("style");
|
|
4849
|
-
sheet.textContent = style + CTA_OFFER_STYLES
|
|
4859
|
+
sheet.textContent = style + CTA_OFFER_STYLES + COMMERCE_PRODUCT_PANEL_STYLES + SHOPPING_NOTES_STYLES + `
|
|
4860
|
+
.panel:not(.compact) .conversation.commerce-active { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
|
|
4861
|
+
.commerce-slot { flex: 0 1 auto; min-height: 0; max-height: min(55dvh, 420px); overflow: auto; overscroll-behavior: contain; }
|
|
4862
|
+
.panel:not(.compact) .conversation.commerce-active .captions { flex: 1 1 80px; height: auto; min-height: 64px; }
|
|
4863
|
+
`;
|
|
4850
4864
|
this.shadow.append(sheet);
|
|
4851
4865
|
this.shadow.append(this.build());
|
|
4852
4866
|
document.documentElement.append(this.host);
|
|
@@ -5674,6 +5688,171 @@ export class WidgetView {
|
|
|
5674
5688
|
message(key) {
|
|
5675
5689
|
return this.messages[key];
|
|
5676
5690
|
}
|
|
5691
|
+
setCommerceCatalog(catalog, callbacks) {
|
|
5692
|
+
this.clearCommerceCatalog();
|
|
5693
|
+
if (this.destroyed)
|
|
5694
|
+
return;
|
|
5695
|
+
const notes = this.shoppingNotes;
|
|
5696
|
+
const notesMatch = notes && catalog.guideId === notes.scope.guideId &&
|
|
5697
|
+
sameCommerceStore(catalog.store, notes.scope.store);
|
|
5698
|
+
const panel = new CommerceProductPanel(key => this.message(key), {
|
|
5699
|
+
...callbacks,
|
|
5700
|
+
...(notesMatch ? { onShoppingNotes: () => { if (notes === this.shoppingNotes)
|
|
5701
|
+
this.openShoppingNotes(); },
|
|
5702
|
+
onSaveItem: (product) => { if (notes === this.shoppingNotes)
|
|
5703
|
+
this.openShoppingNotes(product); } } : {}),
|
|
5704
|
+
});
|
|
5705
|
+
this.commercePanel = panel;
|
|
5706
|
+
panel.element.classList.add("commerce-slot");
|
|
5707
|
+
this.conversation.classList.add("commerce-active");
|
|
5708
|
+
this.conversation.prepend(panel.element);
|
|
5709
|
+
panel.setCatalog(catalog);
|
|
5710
|
+
if (this.active && this.panel.classList.contains("open"))
|
|
5711
|
+
this.setCompact(false);
|
|
5712
|
+
requestAnimationFrame(() => { if (this.commercePanel === panel)
|
|
5713
|
+
panel.refreshVisibility(); });
|
|
5714
|
+
}
|
|
5715
|
+
clearCommerceCatalog() {
|
|
5716
|
+
this.commercePanel?.destroy();
|
|
5717
|
+
this.commercePanel = null;
|
|
5718
|
+
this.conversation?.classList.toggle("commerce-active", this.commerceCartStatus !== null);
|
|
5719
|
+
}
|
|
5720
|
+
configureShoppingNotes() {
|
|
5721
|
+
const scope = this.config.capabilities?.text === true ? createShoppingNotesScope(this.config) : null;
|
|
5722
|
+
if (JSON.stringify(scope) !== JSON.stringify(this.shoppingNotes?.scope ?? null)) {
|
|
5723
|
+
this.shoppingNotes?.destroy();
|
|
5724
|
+
this.shoppingNotes = scope ? new ShoppingNotesView(scope, key => this.message(key), this.dialogFocus, {
|
|
5725
|
+
active: () => this.active || this.endRequested || this.stagedLaunchMode !== null,
|
|
5726
|
+
start: question => this.start("text", question),
|
|
5727
|
+
changed: () => this.syncShoppingNotesEntry(),
|
|
5728
|
+
fallbackFocus: () => this.active ? this.dialogFallbackFocus() : this.require('[data-role="intro-text-input"]'),
|
|
5729
|
+
}) : null;
|
|
5730
|
+
if (this.shoppingNotes)
|
|
5731
|
+
this.shadow.append(this.shoppingNotes.element);
|
|
5732
|
+
}
|
|
5733
|
+
this.syncShoppingNotesEntry();
|
|
5734
|
+
}
|
|
5735
|
+
syncShoppingNotesEntry() {
|
|
5736
|
+
const button = this.shadow.querySelector('[data-role="shopping-notes-entry"]');
|
|
5737
|
+
if (!button)
|
|
5738
|
+
return;
|
|
5739
|
+
button.textContent = this.messages.shoppingNotesReview;
|
|
5740
|
+
button.hidden = this.active || !this.shoppingNotes?.hasSaved();
|
|
5741
|
+
}
|
|
5742
|
+
openShoppingNotes(product) {
|
|
5743
|
+
if (this.destroyed || this.currentConfirmation || this.currentVisualRequest ||
|
|
5744
|
+
this.currentHandoffContextRequest || this.currentPageAssistanceRequest ||
|
|
5745
|
+
!this.require('[data-role="legal-overlay"]').hidden)
|
|
5746
|
+
return;
|
|
5747
|
+
this.releaseActivePushToTalk();
|
|
5748
|
+
this.shoppingNotes?.open(product);
|
|
5749
|
+
}
|
|
5750
|
+
setCommerceBusy(busy) { this.commercePanel?.setBusy(busy); }
|
|
5751
|
+
setCommerceError() { this.commercePanel?.showError(); }
|
|
5752
|
+
setCommerceCartActionHandler(handler, canAdd) {
|
|
5753
|
+
this.commercePanel?.setCartActionHandler(handler, canAdd);
|
|
5754
|
+
}
|
|
5755
|
+
showCommerceCartConfirmation(value, onDecision) {
|
|
5756
|
+
if (this.destroyed || !this.active) {
|
|
5757
|
+
onDecision(false);
|
|
5758
|
+
return;
|
|
5759
|
+
}
|
|
5760
|
+
const price = formatCommercePrice(value.unitPrice.amount, value.unitPrice.currency, value.market.locale);
|
|
5761
|
+
const quantity = new Intl.NumberFormat(value.market.locale).format(value.quantity);
|
|
5762
|
+
this.showConfirmation({ actionId: value.operationId, proposalChecksum: value.proposalChecksum,
|
|
5763
|
+
action: this.messages.commerceAdd, targetLabel: value.title,
|
|
5764
|
+
reason: value.selectedOptions.map(option => `${option.name}: ${option.value}`).join(" · "),
|
|
5765
|
+
expectedEffect: `${quantity} × ${price} · ${new URL(value.store.origin).hostname}`,
|
|
5766
|
+
expiresAt: value.expiresAt, onDecision });
|
|
5767
|
+
}
|
|
5768
|
+
clearCommerceCartConfirmation(operationId) {
|
|
5769
|
+
const current = this.currentConfirmation;
|
|
5770
|
+
if (current?.onDecision && (!operationId || current.actionId === operationId))
|
|
5771
|
+
this.resolveConfirmation(false);
|
|
5772
|
+
}
|
|
5773
|
+
setCommerceCartStatus(outcome, cartUrl, onCheck) {
|
|
5774
|
+
this.clearCommerceCartStatus();
|
|
5775
|
+
if (this.destroyed || !this.active)
|
|
5776
|
+
return;
|
|
5777
|
+
if (this.semanticStatus === this.messages.commerceCartChecking && !this.currentConfirmation &&
|
|
5778
|
+
!this.currentVisualRequest && !this.currentHandoffContextRequest && !this.currentPageAssistanceRequest) {
|
|
5779
|
+
this.setStatus(this.muted && this.voiceActive ? this.messages.muted : this.assistantPresentationMessage());
|
|
5780
|
+
this.setActivity(this.assistantPresentationState());
|
|
5781
|
+
}
|
|
5782
|
+
const status = document.createElement("section");
|
|
5783
|
+
status.className = "commerce-panel commerce-slot commerce-cart-status";
|
|
5784
|
+
status.setAttribute("role", "status");
|
|
5785
|
+
status.setAttribute("aria-live", "polite");
|
|
5786
|
+
const summary = document.createElement("p");
|
|
5787
|
+
const key = outcome.status === "confirmed" && outcome.receipt
|
|
5788
|
+
? "commerceCartAdded" : outcome.status === "partial" && outcome.receipt ? "commerceCartPartial"
|
|
5789
|
+
: outcome.status === "conflict" ? "commerceCartChanged" : outcome.status === "unavailable"
|
|
5790
|
+
? "commerceCartUnavailable" : "commerceCartUncertain";
|
|
5791
|
+
summary.textContent = this.messages[key];
|
|
5792
|
+
status.append(summary);
|
|
5793
|
+
if (outcome.local.itemCount !== null && Number.isSafeInteger(outcome.local.itemCount) && outcome.local.itemCount >= 0) {
|
|
5794
|
+
const count = document.createElement("p");
|
|
5795
|
+
count.className = "commerce-product-note";
|
|
5796
|
+
count.textContent = this.messages.commerceCartCount.replace("{count}", new Intl.NumberFormat(this.host.lang || "en").format(outcome.local.itemCount));
|
|
5797
|
+
status.append(count);
|
|
5798
|
+
}
|
|
5799
|
+
const actions = document.createElement("div");
|
|
5800
|
+
actions.className = "commerce-panel-actions";
|
|
5801
|
+
if (onCheck && (outcome.status === "uncertain" ||
|
|
5802
|
+
((outcome.status === "confirmed" || outcome.status === "partial") && outcome.receipt))) {
|
|
5803
|
+
const check = document.createElement("button");
|
|
5804
|
+
check.type = "button";
|
|
5805
|
+
check.textContent = this.messages.commerceCartRecheck;
|
|
5806
|
+
check.addEventListener("click", async () => {
|
|
5807
|
+
if (check.disabled || this.destroyed || !this.active || this.commerceCartStatus !== status)
|
|
5808
|
+
return;
|
|
5809
|
+
check.disabled = true;
|
|
5810
|
+
check.setAttribute("aria-busy", "true");
|
|
5811
|
+
try {
|
|
5812
|
+
await onCheck();
|
|
5813
|
+
}
|
|
5814
|
+
catch { /* Keep the uncertain result available for another read-only check. */ }
|
|
5815
|
+
finally {
|
|
5816
|
+
if (this.commerceCartStatus === status && check.isConnected && !this.destroyed && this.active) {
|
|
5817
|
+
check.disabled = false;
|
|
5818
|
+
check.removeAttribute("aria-busy");
|
|
5819
|
+
}
|
|
5820
|
+
}
|
|
5821
|
+
});
|
|
5822
|
+
actions.append(check);
|
|
5823
|
+
}
|
|
5824
|
+
try {
|
|
5825
|
+
const url = new URL(cartUrl);
|
|
5826
|
+
if (url.protocol === "https:" && url.origin === window.location.origin && !url.username && !url.password &&
|
|
5827
|
+
/^\/(?:[a-z]{2,3}(?:-[a-z0-9]{2,8})*\/)?cart\/?$/iu.test(url.pathname) && !url.search && !url.hash) {
|
|
5828
|
+
const view = document.createElement("a");
|
|
5829
|
+
view.className = "commerce-product-link";
|
|
5830
|
+
view.href = url.href;
|
|
5831
|
+
view.textContent = this.messages.commerceViewCart;
|
|
5832
|
+
actions.append(view);
|
|
5833
|
+
}
|
|
5834
|
+
}
|
|
5835
|
+
catch { /* An invalid destination must not become a shopper link. */ }
|
|
5836
|
+
const keep = document.createElement("button");
|
|
5837
|
+
keep.type = "button";
|
|
5838
|
+
keep.textContent = this.messages.commerceKeepShopping;
|
|
5839
|
+
keep.addEventListener("click", () => {
|
|
5840
|
+
this.clearCommerceCartStatus();
|
|
5841
|
+
this.dialogFallbackFocus()?.focus();
|
|
5842
|
+
});
|
|
5843
|
+
actions.append(keep);
|
|
5844
|
+
status.append(actions);
|
|
5845
|
+
this.commerceCartStatus = status;
|
|
5846
|
+
this.conversation.prepend(status);
|
|
5847
|
+
this.conversation.classList.add("commerce-active");
|
|
5848
|
+
this.setCompact(false);
|
|
5849
|
+
this.openPanel();
|
|
5850
|
+
}
|
|
5851
|
+
clearCommerceCartStatus() {
|
|
5852
|
+
this.commerceCartStatus?.remove();
|
|
5853
|
+
this.commerceCartStatus = null;
|
|
5854
|
+
this.conversation?.classList.toggle("commerce-active", this.commercePanel !== null);
|
|
5855
|
+
}
|
|
5677
5856
|
setAdvancedSessionControlsVisible(visible) {
|
|
5678
5857
|
this.advancedSessionControlsVisible = visible;
|
|
5679
5858
|
this.syncAdvancedSessionControlsVisibility();
|
|
@@ -5717,6 +5896,7 @@ export class WidgetView {
|
|
|
5717
5896
|
return this.start(mode);
|
|
5718
5897
|
}
|
|
5719
5898
|
close() {
|
|
5899
|
+
this.shoppingNotes?.close(false);
|
|
5720
5900
|
if (this.panel.classList.contains("open"))
|
|
5721
5901
|
this.closePanel();
|
|
5722
5902
|
}
|
|
@@ -6178,7 +6358,7 @@ export class WidgetView {
|
|
|
6178
6358
|
return;
|
|
6179
6359
|
}
|
|
6180
6360
|
this.captions.querySelector('[data-role="empty"]')?.remove();
|
|
6181
|
-
const safe = text.slice(0, 16000);
|
|
6361
|
+
const safe = (role === "user" ? this.shoppingNotes?.captionText(text) ?? text : text).slice(0, 16000);
|
|
6182
6362
|
if (role === "assistant" && safe && !restored) {
|
|
6183
6363
|
this.assistantCaptionPhase = final ? "final" : "partial";
|
|
6184
6364
|
}
|
|
@@ -6752,7 +6932,8 @@ export class WidgetView {
|
|
|
6752
6932
|
showConfirmation(value) {
|
|
6753
6933
|
this.dismissHandoffRequestPreparing();
|
|
6754
6934
|
if (this.currentConfirmation?.actionId === value.actionId &&
|
|
6755
|
-
this.currentConfirmation.proposalChecksum === value.proposalChecksum
|
|
6935
|
+
this.currentConfirmation.proposalChecksum === value.proposalChecksum &&
|
|
6936
|
+
Boolean(this.currentConfirmation.onDecision) === Boolean(value.onDecision)) {
|
|
6756
6937
|
return;
|
|
6757
6938
|
}
|
|
6758
6939
|
if (this.currentPageAssistanceRequest) {
|
|
@@ -6782,6 +6963,7 @@ export class WidgetView {
|
|
|
6782
6963
|
this.setAmbientActive(true);
|
|
6783
6964
|
this.syncHeaderActions();
|
|
6784
6965
|
this.confirmation.scrollIntoView({ block: "nearest" });
|
|
6966
|
+
this.shoppingNotes?.close(false);
|
|
6785
6967
|
this.dialogFocus.present({
|
|
6786
6968
|
surface: this.confirmation,
|
|
6787
6969
|
initialFocus: () => this.require('[data-role="decline"]'),
|
|
@@ -7042,6 +7224,7 @@ export class WidgetView {
|
|
|
7042
7224
|
this.syncPageAssistanceFooter();
|
|
7043
7225
|
const overlay = this.syncPageAssistancePresentation();
|
|
7044
7226
|
this.syncHeaderActions();
|
|
7227
|
+
this.shoppingNotes?.close(false);
|
|
7045
7228
|
this.dialogFocus.present({
|
|
7046
7229
|
surface: overlay,
|
|
7047
7230
|
initialFocus: () => this.require('[data-role="page-assistance-decline"]'),
|
|
@@ -7660,6 +7843,8 @@ export class WidgetView {
|
|
|
7660
7843
|
true;
|
|
7661
7844
|
}
|
|
7662
7845
|
showError(message, retryable = false, sessionActive = this.active) {
|
|
7846
|
+
if (this.stagedLaunchMode !== null || this.assistantState === "connecting")
|
|
7847
|
+
this.shoppingNotes?.markLaunchFailed();
|
|
7663
7848
|
this.setActionStateRunning(false);
|
|
7664
7849
|
if (this.voiceActive || this.audio.srcObject) {
|
|
7665
7850
|
this.pauseRemotePlayback(true);
|
|
@@ -7716,6 +7901,8 @@ export class WidgetView {
|
|
|
7716
7901
|
]);
|
|
7717
7902
|
}
|
|
7718
7903
|
showEndingDetached(message) {
|
|
7904
|
+
this.clearCommerceCartStatus();
|
|
7905
|
+
this.clearCommerceCartConfirmation();
|
|
7719
7906
|
const continuingEndingPresentation = this.panel.classList.contains("ending-state");
|
|
7720
7907
|
if (!continuingEndingPresentation) {
|
|
7721
7908
|
this.endingPresentationDismissed = false;
|
|
@@ -7733,6 +7920,7 @@ export class WidgetView {
|
|
|
7733
7920
|
this.currentConfirmation = null;
|
|
7734
7921
|
this.currentVisualRequest = null;
|
|
7735
7922
|
this.currentHandoffContextRequest = null;
|
|
7923
|
+
this.shoppingNotes?.close(false);
|
|
7736
7924
|
this.dialogFocus.clear({ restore: false });
|
|
7737
7925
|
this.assistantCaptionPhase = "none";
|
|
7738
7926
|
this.clearPendingCaptions();
|
|
@@ -7792,6 +7980,7 @@ export class WidgetView {
|
|
|
7792
7980
|
this.currentConfirmation = null;
|
|
7793
7981
|
this.currentVisualRequest = null;
|
|
7794
7982
|
this.currentHandoffContextRequest = null;
|
|
7983
|
+
this.shoppingNotes?.close(false);
|
|
7795
7984
|
this.dialogFocus.clear({ restore: false });
|
|
7796
7985
|
this.assistantCaptionPhase = "none";
|
|
7797
7986
|
this.clearPendingCaptions();
|
|
@@ -7830,6 +8019,10 @@ export class WidgetView {
|
|
|
7830
8019
|
this.clearIntroTransition();
|
|
7831
8020
|
this.introMinimized = false;
|
|
7832
8021
|
this.syncIntroMinimizedState();
|
|
8022
|
+
if (this.shoppingNotes?.retry(question, message)) {
|
|
8023
|
+
this.setStatus(message);
|
|
8024
|
+
return;
|
|
8025
|
+
}
|
|
7833
8026
|
const input = this.require('[data-role="intro-text-input"]');
|
|
7834
8027
|
input.value = question.slice(0, INITIAL_QUESTION_MAX_LENGTH);
|
|
7835
8028
|
input.setAttribute("aria-invalid", "false");
|
|
@@ -7885,6 +8078,7 @@ export class WidgetView {
|
|
|
7885
8078
|
this.currentConfirmation = null;
|
|
7886
8079
|
this.currentVisualRequest = null;
|
|
7887
8080
|
this.currentHandoffContextRequest = null;
|
|
8081
|
+
this.shoppingNotes?.close(false);
|
|
7888
8082
|
this.dialogFocus.clear({ restore: false });
|
|
7889
8083
|
if (this.muted)
|
|
7890
8084
|
this.setMuted(false);
|
|
@@ -8228,6 +8422,11 @@ export class WidgetView {
|
|
|
8228
8422
|
});
|
|
8229
8423
|
}
|
|
8230
8424
|
destroy() {
|
|
8425
|
+
this.shoppingNotes?.destroy();
|
|
8426
|
+
this.shoppingNotes = null;
|
|
8427
|
+
this.clearCommerceCartConfirmation();
|
|
8428
|
+
this.clearCommerceCatalog();
|
|
8429
|
+
this.clearCommerceCartStatus();
|
|
8231
8430
|
this.clearCtaOffer();
|
|
8232
8431
|
if (this.destroyed)
|
|
8233
8432
|
return;
|
|
@@ -8303,7 +8502,9 @@ export class WidgetView {
|
|
|
8303
8502
|
<div class="status-card" data-role="availability" role="status" tabindex="-1"></div>
|
|
8304
8503
|
<div class="status-card" data-role="elsewhere" role="status" tabindex="-1"></div>
|
|
8305
8504
|
<div class="intro-entry" data-role="intro-entry" data-has-draft="false" aria-busy="false" hidden>
|
|
8505
|
+
<button type="button" class="shopping-notes-entry" data-role="shopping-notes-entry" hidden></button>
|
|
8306
8506
|
<label class="recording-consent" data-role="recording-consent" hidden><input type="checkbox" data-role="recording-consent-input"><span><strong data-role="recording-consent-label"></strong><small data-role="recording-consent-description"></small></span></label>
|
|
8507
|
+
<label class="recording-consent commerce-cart-consent" data-role="commerce-cart-consent" hidden><input type="checkbox" data-role="commerce-cart-consent-input"><span><strong data-role="commerce-cart-consent-label"></strong><small data-role="commerce-cart-consent-description"></small></span></label>
|
|
8307
8508
|
<div class="proactive-engagement" data-role="proactive-engagement" hidden>
|
|
8308
8509
|
<div class="proactive-rail" data-role="proactive-prompts" role="group"></div>
|
|
8309
8510
|
</div>
|
|
@@ -8391,6 +8592,7 @@ export class WidgetView {
|
|
|
8391
8592
|
<div class="boundary" data-role="boundary"></div>
|
|
8392
8593
|
<ul data-role="legal-scopes"></ul>
|
|
8393
8594
|
<label class="recording-consent" data-role="recording-consent" hidden><input type="checkbox" data-role="recording-consent-input"><span><strong data-role="recording-consent-label"></strong><small data-role="recording-consent-description"></small></span></label>
|
|
8595
|
+
<label class="recording-consent commerce-cart-consent" data-role="commerce-cart-consent" hidden><input type="checkbox" data-role="commerce-cart-consent-input"><span><strong data-role="commerce-cart-consent-label"></strong><small data-role="commerce-cart-consent-description"></small></span></label>
|
|
8394
8596
|
<div class="legal-links" data-role="legal-links"><a data-role="legal-privacy" target="_blank" rel="noopener noreferrer"></a><a data-role="legal-terms" target="_blank" rel="noopener noreferrer"></a></div>
|
|
8395
8597
|
<button type="button" class="secondary legal-revoke" data-role="page-assistance-revoke" hidden><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
|
|
8396
8598
|
</section>
|
|
@@ -8501,6 +8703,7 @@ export class WidgetView {
|
|
|
8501
8703
|
return fragment;
|
|
8502
8704
|
}
|
|
8503
8705
|
bind() {
|
|
8706
|
+
this.require('[data-role="shopping-notes-entry"]').addEventListener("click", () => this.openShoppingNotes());
|
|
8504
8707
|
this.panel.addEventListener("pointerdown", this.onPlaybackActivation, true);
|
|
8505
8708
|
this.panel.addEventListener("wheel", this.onPanelWheel, { passive: false });
|
|
8506
8709
|
this.captions.addEventListener("scroll", this.onCaptionsScroll, {
|
|
@@ -8869,6 +9072,7 @@ export class WidgetView {
|
|
|
8869
9072
|
window.visualViewport?.addEventListener("scroll", this.onHighlightViewportGeometryChange, { passive: true });
|
|
8870
9073
|
}
|
|
8871
9074
|
applyConfig() {
|
|
9075
|
+
this.configureShoppingNotes();
|
|
8872
9076
|
const appearance = this.config.appearance;
|
|
8873
9077
|
const anchor = appearance?.position === "left" || appearance?.position === "center"
|
|
8874
9078
|
? appearance.position
|
|
@@ -9103,6 +9307,7 @@ export class WidgetView {
|
|
|
9103
9307
|
this.messages.notResolved;
|
|
9104
9308
|
this.renderLegalScopes();
|
|
9105
9309
|
this.renderRecordingConsent();
|
|
9310
|
+
this.renderCommerceCartConsent();
|
|
9106
9311
|
const privacy = this.require('[data-role="privacy"]');
|
|
9107
9312
|
if (this.config.consent?.policyUrl)
|
|
9108
9313
|
privacy.href = this.config.consent.policyUrl;
|
|
@@ -9189,6 +9394,28 @@ export class WidgetView {
|
|
|
9189
9394
|
};
|
|
9190
9395
|
}
|
|
9191
9396
|
}
|
|
9397
|
+
commerceCartConsentOffered() {
|
|
9398
|
+
return this.config.schemaVersion === 3 && this.config.capabilities?.commerceCart === true &&
|
|
9399
|
+
this.config.consent?.optionalScopes.includes("commerce_cart") === true &&
|
|
9400
|
+
parseCommerceBootstrap(this.config.commerce, this.config.guideId, location.origin)?.cartEnabled === true;
|
|
9401
|
+
}
|
|
9402
|
+
renderCommerceCartConsent() {
|
|
9403
|
+
const offered = this.commerceCartConsentOffered();
|
|
9404
|
+
for (const row of this.shadow.querySelectorAll('[data-role="commerce-cart-consent"]')) {
|
|
9405
|
+
row.hidden = !offered || (this.introMinimized && row.closest('[data-role="intro-entry"]') !== null);
|
|
9406
|
+
row.querySelector('[data-role="commerce-cart-consent-label"]').textContent = this.messages.commerceCartConsent;
|
|
9407
|
+
row.querySelector('[data-role="commerce-cart-consent-description"]').textContent = this.messages.commerceCartConsentDescription;
|
|
9408
|
+
const input = row.querySelector('[data-role="commerce-cart-consent-input"]');
|
|
9409
|
+
input.checked = offered && this.commerceCartConsent;
|
|
9410
|
+
input.disabled = this.active || this.endRequested;
|
|
9411
|
+
input.onchange = () => {
|
|
9412
|
+
if (!this.destroyed && !this.active && !this.endRequested && this.commerceCartConsentOffered()) {
|
|
9413
|
+
this.commerceCartConsent = input.checked;
|
|
9414
|
+
}
|
|
9415
|
+
this.renderCommerceCartConsent();
|
|
9416
|
+
};
|
|
9417
|
+
}
|
|
9418
|
+
}
|
|
9192
9419
|
renderLegalScopes() {
|
|
9193
9420
|
const container = this.require('[data-role="legal-scopes"]');
|
|
9194
9421
|
container.replaceChildren();
|
|
@@ -9200,6 +9427,7 @@ export class WidgetView {
|
|
|
9200
9427
|
microphone: "microphoneConsent",
|
|
9201
9428
|
page_context: "pageConsent",
|
|
9202
9429
|
browser_control: "controlConsent",
|
|
9430
|
+
commerce_cart: "commerceCartConsentDescription",
|
|
9203
9431
|
visual_context: "visualConsent",
|
|
9204
9432
|
handoff_context: "handoffConsent",
|
|
9205
9433
|
retained_transcript: "retentionConsent",
|
|
@@ -9208,6 +9436,7 @@ export class WidgetView {
|
|
|
9208
9436
|
"microphone",
|
|
9209
9437
|
"page_context",
|
|
9210
9438
|
"browser_control",
|
|
9439
|
+
"commerce_cart",
|
|
9211
9440
|
"visual_context",
|
|
9212
9441
|
"handoff_context",
|
|
9213
9442
|
"retained_transcript",
|
|
@@ -9236,6 +9465,8 @@ export class WidgetView {
|
|
|
9236
9465
|
const scopes = ["ai_disclosure", "text"];
|
|
9237
9466
|
if (this.recordingConsentOffered() && this.recordingConsent)
|
|
9238
9467
|
scopes.push("session_recording");
|
|
9468
|
+
if (this.commerceCartConsentOffered() && this.commerceCartConsent)
|
|
9469
|
+
scopes.push("commerce_cart");
|
|
9239
9470
|
if (required.has("page_context") &&
|
|
9240
9471
|
this.config.capabilities?.pageContext === true) {
|
|
9241
9472
|
scopes.push("page_context");
|
|
@@ -9253,6 +9484,7 @@ export class WidgetView {
|
|
|
9253
9484
|
const shouldStageWelcome = mode === "text" && !initialQuestion && !this.welcomePresented;
|
|
9254
9485
|
if (shouldStageWelcome)
|
|
9255
9486
|
this.ensureWelcomeSkeleton();
|
|
9487
|
+
this.shoppingNotes?.prepareLaunch(initialQuestion);
|
|
9256
9488
|
const admitted = initialQuestion
|
|
9257
9489
|
? this.callbacks.onStart(mode, scopes, initialQuestion)
|
|
9258
9490
|
: this.callbacks.onStart(mode, scopes);
|
|
@@ -9385,6 +9617,7 @@ export class WidgetView {
|
|
|
9385
9617
|
this.focusIntroControl(this.config.capabilities?.text === true ? "text" : "voice");
|
|
9386
9618
|
}
|
|
9387
9619
|
syncIntroMinimizedState() {
|
|
9620
|
+
this.renderCommerceCartConsent();
|
|
9388
9621
|
const entry = this.require('[data-role="intro-entry"]');
|
|
9389
9622
|
const frame = this.require('[data-role="intro-composer"]');
|
|
9390
9623
|
const composer = this.require(".intro-composer");
|
|
@@ -9528,12 +9761,18 @@ export class WidgetView {
|
|
|
9528
9761
|
const value = this.currentConfirmation;
|
|
9529
9762
|
if (!value)
|
|
9530
9763
|
return false;
|
|
9531
|
-
if (Date.parse(value.expiresAt) <= Date.now()) {
|
|
9764
|
+
if (!Number.isFinite(Date.parse(value.expiresAt)) || Date.parse(value.expiresAt) <= Date.now()) {
|
|
9532
9765
|
this.confirmation.classList.remove("visible");
|
|
9533
9766
|
this.currentConfirmation = null;
|
|
9534
9767
|
this.dialogFocus.dismiss(this.confirmation);
|
|
9535
|
-
|
|
9536
|
-
|
|
9768
|
+
if (value.onDecision) {
|
|
9769
|
+
this.setStatus(this.muted && this.voiceActive ? this.messages.muted : this.assistantPresentationMessage());
|
|
9770
|
+
value.onDecision(false);
|
|
9771
|
+
}
|
|
9772
|
+
else {
|
|
9773
|
+
this.callbacks.onConfirmation(value.actionId, value.proposalChecksum, false);
|
|
9774
|
+
this.showActionState("failed");
|
|
9775
|
+
}
|
|
9537
9776
|
return true;
|
|
9538
9777
|
}
|
|
9539
9778
|
this.confirmation.classList.remove("visible");
|
|
@@ -9541,7 +9780,13 @@ export class WidgetView {
|
|
|
9541
9780
|
this.dialogFocus.dismiss(this.confirmation);
|
|
9542
9781
|
this.restoreVoicePresenceAfterPrompt();
|
|
9543
9782
|
this.syncHeaderActions();
|
|
9544
|
-
|
|
9783
|
+
if (value.onDecision) {
|
|
9784
|
+
this.setStatus(approved ? this.messages.commerceCartChecking :
|
|
9785
|
+
this.muted && this.voiceActive ? this.messages.muted : this.assistantPresentationMessage());
|
|
9786
|
+
value.onDecision(approved);
|
|
9787
|
+
}
|
|
9788
|
+
else
|
|
9789
|
+
this.callbacks.onConfirmation(value.actionId, value.proposalChecksum, approved);
|
|
9545
9790
|
return true;
|
|
9546
9791
|
}
|
|
9547
9792
|
restoreVoicePresenceAfterPrompt() {
|
|
@@ -9791,6 +10036,7 @@ export class WidgetView {
|
|
|
9791
10036
|
}
|
|
9792
10037
|
presentContextPermissionDialog() {
|
|
9793
10038
|
this.restoreContextPermissionDialogAttributes();
|
|
10039
|
+
this.shoppingNotes?.close(false);
|
|
9794
10040
|
this.dialogFocus.present({
|
|
9795
10041
|
surface: this.visualRequest,
|
|
9796
10042
|
initialFocus: () => this.require('[data-role="visual-decline"]'),
|
|
@@ -9832,7 +10078,7 @@ export class WidgetView {
|
|
|
9832
10078
|
currentSafetyIdentity(kind) {
|
|
9833
10079
|
if (kind === "confirmation") {
|
|
9834
10080
|
const value = this.currentConfirmation;
|
|
9835
|
-
return value ? `${value.actionId}:${value.proposalChecksum}` : null;
|
|
10081
|
+
return value ? `${value.onDecision ? "commerce" : "action"}:${value.actionId}:${value.proposalChecksum}` : null;
|
|
9836
10082
|
}
|
|
9837
10083
|
if (this.currentHandoffContextRequest) {
|
|
9838
10084
|
return `handoff:${this.currentHandoffContextRequest.requestId}:${this.currentHandoffContextRequest.requestChecksum}`;
|
|
@@ -10143,11 +10389,12 @@ export class WidgetView {
|
|
|
10143
10389
|
this.writePanelVisibility("open");
|
|
10144
10390
|
this.syncLauncherState();
|
|
10145
10391
|
this.syncHeaderActions();
|
|
10146
|
-
requestAnimationFrame(() => this.clampPanelPosition());
|
|
10392
|
+
requestAnimationFrame(() => { this.clampPanelPosition(); this.commercePanel?.refreshVisibility(); });
|
|
10147
10393
|
if (!wasOpen && notifyOpen)
|
|
10148
10394
|
this.callbacks.onOpenChange?.(true);
|
|
10149
10395
|
}
|
|
10150
10396
|
closePanel() {
|
|
10397
|
+
this.shoppingNotes?.close(false);
|
|
10151
10398
|
if (!this.panel.classList.contains("open"))
|
|
10152
10399
|
return;
|
|
10153
10400
|
if (this.panel.classList.contains("ending-state")) {
|
|
@@ -10296,6 +10543,7 @@ export class WidgetView {
|
|
|
10296
10543
|
if (!value)
|
|
10297
10544
|
this.panel.classList.remove("compact-text-arrived");
|
|
10298
10545
|
this.panel.classList.toggle("compact", this.compact);
|
|
10546
|
+
requestAnimationFrame(() => this.commercePanel?.refreshVisibility());
|
|
10299
10547
|
this.placeCtaOffer();
|
|
10300
10548
|
this.syncSurfaceEffectOwner();
|
|
10301
10549
|
if (persist && this.active && this.persistentState) {
|
|
@@ -11002,6 +11250,7 @@ export class WidgetView {
|
|
|
11002
11250
|
this.stagedLaunchMode = null;
|
|
11003
11251
|
this.initialQuestionStaged = false;
|
|
11004
11252
|
this.active = false;
|
|
11253
|
+
this.commerceCartConsent = false;
|
|
11005
11254
|
this.endRequested = false;
|
|
11006
11255
|
if (this.paused)
|
|
11007
11256
|
this.setPaused(false);
|
|
@@ -11088,6 +11337,7 @@ export class WidgetView {
|
|
|
11088
11337
|
}
|
|
11089
11338
|
const overlay = this.require('[data-role="legal-overlay"]');
|
|
11090
11339
|
overlay.hidden = false;
|
|
11340
|
+
this.shoppingNotes?.close(false);
|
|
11091
11341
|
this.dialogFocus.present({
|
|
11092
11342
|
surface: overlay,
|
|
11093
11343
|
initialFocus: () => this.require('[data-role="legal-close"]'),
|
|
@@ -11384,6 +11634,8 @@ export class WidgetView {
|
|
|
11384
11634
|
this.restorePanelPosition();
|
|
11385
11635
|
}
|
|
11386
11636
|
syncHeaderActions() {
|
|
11637
|
+
this.syncShoppingNotesEntry();
|
|
11638
|
+
this.renderCommerceCartConsent();
|
|
11387
11639
|
this.panel.classList.toggle("active-session", this.active);
|
|
11388
11640
|
this.syncSessionModeUi();
|
|
11389
11641
|
const errorState = this.panel.classList.contains("error-state");
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "7.5.
|
|
1
|
+
export declare const VERSION = "7.5.21";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '7.5.
|
|
1
|
+
export const VERSION = '7.5.21';
|