@oxvo/ai-live-assist 7.5.27 → 7.5.29
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 +3 -1
- package/cjs/AiLiveAssist.js +24 -0
- package/cjs/client.d.ts +5 -0
- package/cjs/client.js +6 -0
- package/cjs/commerce/cartRecovery.d.ts +26 -0
- package/cjs/commerce/cartRecovery.js +96 -0
- package/cjs/commerce/cartSession.d.ts +7 -1
- package/cjs/commerce/cartSession.js +61 -5
- package/cjs/commerce/realtimeCommerce.d.ts +1 -0
- package/cjs/commerce/realtimeCommerce.js +1 -0
- package/cjs/commerce/shopifyCart.d.ts +3 -0
- package/cjs/commerce/shopifyCart.js +26 -0
- package/cjs/guideAdmission.d.ts +1 -0
- package/cjs/guideAdmission.js +3 -0
- package/cjs/guideMeasurement.d.ts +1 -1
- package/cjs/guideMeasurement.js +1 -1
- package/cjs/liveControlChannel.d.ts +1 -1
- package/cjs/liveGuideWidget.d.ts +2 -0
- package/cjs/liveGuideWidget.js +6 -0
- package/cjs/merchantPreviewAdmission.d.ts +1 -0
- package/cjs/merchantPreviewAdmission.js +2 -0
- package/cjs/merchantPreviewStorage.js +12 -0
- package/cjs/ui.d.ts +3 -1
- package/cjs/ui.js +7 -5
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/lib/AiLiveAssist.d.ts +3 -1
- package/lib/AiLiveAssist.js +24 -0
- package/lib/client.d.ts +5 -0
- package/lib/client.js +6 -0
- package/lib/commerce/cartRecovery.d.ts +26 -0
- package/lib/commerce/cartRecovery.js +93 -0
- package/lib/commerce/cartSession.d.ts +7 -1
- package/lib/commerce/cartSession.js +61 -5
- package/lib/commerce/realtimeCommerce.d.ts +1 -0
- package/lib/commerce/realtimeCommerce.js +1 -0
- package/lib/commerce/shopifyCart.d.ts +3 -0
- package/lib/commerce/shopifyCart.js +26 -0
- package/lib/guideAdmission.d.ts +1 -0
- package/lib/guideAdmission.js +3 -0
- package/lib/guideMeasurement.d.ts +1 -1
- package/lib/guideMeasurement.js +1 -1
- package/lib/liveControlChannel.d.ts +1 -1
- package/lib/liveGuideWidget.d.ts +2 -0
- package/lib/liveGuideWidget.js +6 -0
- package/lib/merchantPreviewAdmission.d.ts +1 -0
- package/lib/merchantPreviewAdmission.js +2 -0
- package/lib/merchantPreviewStorage.js +12 -0
- package/lib/ui.d.ts +3 -1
- package/lib/ui.js +7 -5
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/liveGuideWidget.js
CHANGED
|
@@ -66,6 +66,7 @@ export class LiveGuideWidget {
|
|
|
66
66
|
const publicAdmission = options.admission;
|
|
67
67
|
const live = new LiveGuideAdmission(publicAdmission.identity, publicAdmission.store, options.runtime, publicAdmission);
|
|
68
68
|
this.admission = {
|
|
69
|
+
cartRecovery: () => publicAdmission.cartRecovery(),
|
|
69
70
|
hasPendingLaunch: () => live.hasPendingLaunch(),
|
|
70
71
|
pendingLaunchId: () => live.pendingLaunchId(),
|
|
71
72
|
launch: (intent, signal) => live.launch({ ...intent, installKey: publicAdmission.identity.installKey }, signal),
|
|
@@ -115,6 +116,7 @@ export class LiveGuideWidget {
|
|
|
115
116
|
this.commerceCart = this.commerce?.cartEnabled && config.capabilities?.commerceCart === true ? new CartSession({
|
|
116
117
|
bootstrap: this.commerce, view: () => this.destroyed ? null : this.view,
|
|
117
118
|
current: () => this.currentCartSnapshot(),
|
|
119
|
+
...(this.admission.cartRecovery ? { recovery: this.admission.cartRecovery() } : {}),
|
|
118
120
|
transportSessionId: () => this.channel?.sessionId ?? null,
|
|
119
121
|
selection: (productRef, variantRef) => {
|
|
120
122
|
this.commerceContext?.refresh();
|
|
@@ -131,6 +133,7 @@ export class LiveGuideWidget {
|
|
|
131
133
|
},
|
|
132
134
|
}) : null;
|
|
133
135
|
this.commerceContext?.start();
|
|
136
|
+
this.commerceCart?.refreshControls();
|
|
134
137
|
if (this.admission.hasPendingLaunch()) {
|
|
135
138
|
if (this.acquireLock()) {
|
|
136
139
|
this.ownedLaunchId = this.admission.pendingLaunchId();
|
|
@@ -158,6 +161,7 @@ export class LiveGuideWidget {
|
|
|
158
161
|
this.requestIds.delete(this.requestIds.values().next().value);
|
|
159
162
|
}
|
|
160
163
|
this.view.open(input.mode ?? this.mode);
|
|
164
|
+
this.commerceCart?.refreshControls();
|
|
161
165
|
if (input.question) {
|
|
162
166
|
if (this.active)
|
|
163
167
|
this.submitText(input.question, true);
|
|
@@ -599,6 +603,7 @@ export class LiveGuideWidget {
|
|
|
599
603
|
this.view.showLaunchUnavailable(this.admission.endMessage);
|
|
600
604
|
else
|
|
601
605
|
this.view.showResumeStopped();
|
|
606
|
+
this.commerceCart?.refreshControls();
|
|
602
607
|
}
|
|
603
608
|
this.options.onState();
|
|
604
609
|
}).catch(error => {
|
|
@@ -667,6 +672,7 @@ export class LiveGuideWidget {
|
|
|
667
672
|
channel?.end();
|
|
668
673
|
this.operation?.abort();
|
|
669
674
|
this.operation = null;
|
|
675
|
+
this.commerceCart?.refreshControls();
|
|
670
676
|
}
|
|
671
677
|
destroy() {
|
|
672
678
|
if (this.destroyed)
|
|
@@ -9,6 +9,7 @@ export declare class MerchantPreviewAdmission implements LiveGuideSessionAdmissi
|
|
|
9
9
|
private readonly runtime;
|
|
10
10
|
private readonly storage;
|
|
11
11
|
readonly recoveryOnly: boolean;
|
|
12
|
+
cartRecovery(): import("./commerce/cartRecovery.js").CartRecovery;
|
|
12
13
|
readonly endMessage = "Preview ended. Return to Console to open another preview.";
|
|
13
14
|
private readonly store;
|
|
14
15
|
private readonly originalKey;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createCartRecovery } from './commerce/cartRecovery.js';
|
|
1
2
|
import { RuntimeClientError } from './client.js';
|
|
2
3
|
import { GuideSubjectStore } from './guideSubjectStore.js';
|
|
3
4
|
import { GUIDE_SUBJECT_CREDENTIAL_PATTERN, GUIDE_UUID_PATTERN } from './guideTypes.js';
|
|
@@ -5,6 +6,7 @@ import { merchantPreviewNamespace, merchantPreviewStorageKeys, saveMerchantPrevi
|
|
|
5
6
|
export { merchantPreviewNamespace } from './merchantPreviewStorage.js';
|
|
6
7
|
const unavailable = () => new RuntimeClientError('MERCHANT_PREVIEW_UNAVAILABLE', 'This preview is no longer available. Open a new preview from OXVO.', false, null, 409);
|
|
7
8
|
export class MerchantPreviewAdmission {
|
|
9
|
+
cartRecovery() { return createCartRecovery(this.runtime, this.bootstrap.installKey, this.store); }
|
|
8
10
|
constructor(preview, bootstrap, runtime, storage = sessionStorage, recoveryOnly = false) {
|
|
9
11
|
this.preview = preview;
|
|
10
12
|
this.bootstrap = bootstrap;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GUIDE_UUID_PATTERN } from './guideTypes.js';
|
|
2
|
+
import { parseCommerceBootstrap } from './commerce/contracts.js';
|
|
2
3
|
const invalid = () => new Error('The previous preview could not be recovered. Return to the original Console tab to check its status or wait for it to expire.');
|
|
3
4
|
const PREVIEW_FIELDS = ['previewId', 'projectId', 'guideId', 'configurationVersionId', 'configurationRevision',
|
|
4
5
|
'configurationChecksum', 'targetOrigin', 'targetPath', 'launchExpiresAt', 'expiresAt', 'runtimeUrl', 'widgetVersion'];
|
|
@@ -19,7 +20,15 @@ export function merchantPreviewStorageKeys(preview) {
|
|
|
19
20
|
const pick = (value, fields) => Object.fromEntries(fields.filter(key => key in value)
|
|
20
21
|
.map(key => [key, value[key]]));
|
|
21
22
|
export function saveMerchantPreviewRecovery(preview, bootstrap, storage) {
|
|
23
|
+
const commerce = bootstrap.commerce === undefined ? null
|
|
24
|
+
: parseCommerceBootstrap(bootstrap.commerce, preview.guideId, preview.targetOrigin);
|
|
25
|
+
if (bootstrap.commerce !== undefined && !commerce)
|
|
26
|
+
throw invalid();
|
|
22
27
|
const presentation = { ...pick(bootstrap, BOOTSTRAP_FIELDS),
|
|
28
|
+
...(commerce ? { commerce: { schemaVersion: commerce.schemaVersion, enabled: commerce.enabled,
|
|
29
|
+
guideId: commerce.guideId, cartEnabled: commerce.cartEnabled,
|
|
30
|
+
store: { provider: commerce.store.provider, storeRef: commerce.store.storeRef,
|
|
31
|
+
origin: commerce.store.origin, policyRevision: commerce.store.policyRevision } } } : {}),
|
|
23
32
|
...(bootstrap.appearance ? { appearance: pick(bootstrap.appearance, APPEARANCE_FIELDS) } : {}) };
|
|
24
33
|
const raw = JSON.stringify({ v: 1, preview: pick(preview, PREVIEW_FIELDS), bootstrap: presentation });
|
|
25
34
|
if (raw.length > 65536 || /"(?:previewGrant|admissionGrant|controlCredential|subjectCredential)"\s*:/.test(raw))
|
|
@@ -46,5 +55,8 @@ export function readMerchantPreviewRecovery(preview, storage) {
|
|
|
46
55
|
if (value?.v !== 1 || !value.preview || !value.bootstrap ||
|
|
47
56
|
JSON.stringify(value.preview) !== JSON.stringify(pick(preview, PREVIEW_FIELDS)))
|
|
48
57
|
throw invalid();
|
|
58
|
+
if (value.bootstrap.commerce !== undefined &&
|
|
59
|
+
!parseCommerceBootstrap(value.bootstrap.commerce, preview.guideId, preview.targetOrigin))
|
|
60
|
+
throw invalid();
|
|
49
61
|
return value.bootstrap;
|
|
50
62
|
}
|
package/lib/ui.d.ts
CHANGED
|
@@ -284,7 +284,9 @@ export declare class WidgetView {
|
|
|
284
284
|
setCommerceCartActionHandler(handler: CommerceAddHandler | null, canAdd?: CommerceCanAdd): void;
|
|
285
285
|
showCommerceCartConfirmation(value: CommerceCartConfirmationView, onDecision: (approved: boolean) => void): void;
|
|
286
286
|
clearCommerceCartConfirmation(operationId?: string): void;
|
|
287
|
-
setCommerceCartStatus(outcome: ShopifyCartOutcome, cartUrl: string, onCheck?: () => void | Promise<void
|
|
287
|
+
setCommerceCartStatus(outcome: ShopifyCartOutcome, cartUrl: string, onCheck?: () => void | Promise<void>, options?: {
|
|
288
|
+
readOnlyRecovery?: boolean;
|
|
289
|
+
}): void;
|
|
288
290
|
clearCommerceCartStatus(): void;
|
|
289
291
|
setAdvancedSessionControlsVisible(visible: boolean): void;
|
|
290
292
|
open(mode?: AssistMode): void;
|
package/lib/ui.js
CHANGED
|
@@ -4507,7 +4507,8 @@ export class WidgetView {
|
|
|
4507
4507
|
this.currentHandoffContextRequest !== null ||
|
|
4508
4508
|
this.currentPageAssistanceRequest !== null ||
|
|
4509
4509
|
this.panel.classList.contains("feedback-state") ||
|
|
4510
|
-
Math.abs(event.deltaY) < Math.abs(event.deltaX)
|
|
4510
|
+
Math.abs(event.deltaY) < Math.abs(event.deltaX) ||
|
|
4511
|
+
event.composedPath().some((target) => target instanceof Element && target.classList.contains("commerce-slot"))) {
|
|
4511
4512
|
return;
|
|
4512
4513
|
}
|
|
4513
4514
|
const maximum = Math.max(0, this.captions.scrollHeight - this.captions.clientHeight);
|
|
@@ -5778,9 +5779,10 @@ export class WidgetView {
|
|
|
5778
5779
|
if (current?.onDecision && (!operationId || current.actionId === operationId))
|
|
5779
5780
|
this.resolveConfirmation(false);
|
|
5780
5781
|
}
|
|
5781
|
-
setCommerceCartStatus(outcome, cartUrl, onCheck) {
|
|
5782
|
+
setCommerceCartStatus(outcome, cartUrl, onCheck, options = {}) {
|
|
5782
5783
|
this.clearCommerceCartStatus();
|
|
5783
|
-
|
|
5784
|
+
const available = () => !this.destroyed && (this.active || options.readOnlyRecovery === true);
|
|
5785
|
+
if (!available())
|
|
5784
5786
|
return;
|
|
5785
5787
|
if (this.semanticStatus === this.messages.commerceCartChecking && !this.currentConfirmation &&
|
|
5786
5788
|
!this.currentVisualRequest && !this.currentHandoffContextRequest && !this.currentPageAssistanceRequest) {
|
|
@@ -5812,7 +5814,7 @@ export class WidgetView {
|
|
|
5812
5814
|
check.type = "button";
|
|
5813
5815
|
check.textContent = this.messages.commerceCartRecheck;
|
|
5814
5816
|
check.addEventListener("click", async () => {
|
|
5815
|
-
if (check.disabled ||
|
|
5817
|
+
if (check.disabled || !available() || this.commerceCartStatus !== status)
|
|
5816
5818
|
return;
|
|
5817
5819
|
check.disabled = true;
|
|
5818
5820
|
check.setAttribute("aria-busy", "true");
|
|
@@ -5821,7 +5823,7 @@ export class WidgetView {
|
|
|
5821
5823
|
}
|
|
5822
5824
|
catch { /* Keep the uncertain result available for another read-only check. */ }
|
|
5823
5825
|
finally {
|
|
5824
|
-
if (this.commerceCartStatus === status && check.isConnected &&
|
|
5826
|
+
if (this.commerceCartStatus === status && check.isConnected && available()) {
|
|
5825
5827
|
check.disabled = false;
|
|
5826
5828
|
check.removeAttribute("aria-busy");
|
|
5827
5829
|
}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "7.5.
|
|
1
|
+
export declare const VERSION = "7.5.29";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '7.5.
|
|
1
|
+
export const VERSION = '7.5.29';
|