@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
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
const controls = /[\u0000-\u001f\u007f]/u;
|
|
2
|
+
export const commerceUuid = (value) => typeof value === 'string' &&
|
|
3
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(value);
|
|
4
|
+
export const commerceCount = (value) => Number.isSafeInteger(value) && Number(value) >= 0;
|
|
5
|
+
const text = (value, max, empty = false) => typeof value === 'string' &&
|
|
6
|
+
(empty || value.length > 0) && value.length <= max && value === value.trim() && !controls.test(value);
|
|
7
|
+
const reference = (value) => text(value, 256) && !/\s/u.test(value);
|
|
8
|
+
const pageIdentity = (value) => text(value, 128) && !/\s/u.test(value);
|
|
9
|
+
export const commerceObject = (value, keys) => !!value && typeof value === 'object' &&
|
|
10
|
+
!Array.isArray(value) && Object.keys(value).length === keys.length && Object.keys(value).every(key => keys.includes(key));
|
|
11
|
+
const https = (value) => {
|
|
12
|
+
if (!text(value, 2048) || /[\s\\]/u.test(value))
|
|
13
|
+
return false;
|
|
14
|
+
try {
|
|
15
|
+
const url = new URL(value);
|
|
16
|
+
return url.protocol === 'https:' && !url.username && !url.password && !!url.hostname;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export const isCommerceStore = (value) => commerceObject(value, ['provider', 'storeRef', 'origin', 'policyRevision']) &&
|
|
23
|
+
value.provider === 'shopify' && reference(value.storeRef) && https(value.origin) && new URL(value.origin).origin === value.origin &&
|
|
24
|
+
typeof value.policyRevision === 'string' && /^[a-f0-9]{64}$/u.test(value.policyRevision);
|
|
25
|
+
export function isCommerceMarket(value) {
|
|
26
|
+
if (!commerceObject(value, ['country', 'locale', 'currency']) || typeof value.country !== 'string' || !/^[A-Z]{2}$/u.test(value.country) ||
|
|
27
|
+
typeof value.currency !== 'string' || !/^[A-Z]{3}$/u.test(value.currency) || !text(value.locale, 35))
|
|
28
|
+
return false;
|
|
29
|
+
try {
|
|
30
|
+
return Intl.getCanonicalLocales(value.locale)[0] === value.locale;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const isCommerceOptions = (value) => Array.isArray(value) && value.length <= 3 && value.every(option => commerceObject(option, ['name', 'value']) && text(option.name, 64) && text(option.value, 128)) && new Set(value.map(option => option.name)).size === value.length;
|
|
37
|
+
export function parseCommerceBootstrap(value, guideId, origin) {
|
|
38
|
+
return commerceObject(value, ['schemaVersion', 'enabled', 'guideId', 'store', 'cartEnabled']) && value.schemaVersion === 1 && value.enabled === true &&
|
|
39
|
+
commerceUuid(value.guideId) && value.guideId === guideId && isCommerceStore(value.store) && value.store.origin === origin &&
|
|
40
|
+
typeof value.cartEnabled === 'boolean' ? value : null;
|
|
41
|
+
}
|
|
42
|
+
export function sameCommerceStore(left, right) {
|
|
43
|
+
return left.provider === right.provider && left.storeRef === right.storeRef && left.origin === right.origin && left.policyRevision === right.policyRevision;
|
|
44
|
+
}
|
|
45
|
+
export function sameCommerceMarket(left, right) {
|
|
46
|
+
return left.country === right.country && left.locale === right.locale && left.currency === right.currency;
|
|
47
|
+
}
|
|
48
|
+
/** Match the runtime's public path; queries and fragments stay private. */
|
|
49
|
+
export function isCommercePath(value) {
|
|
50
|
+
if (!text(value, 2048) || !value.startsWith('/') || value.startsWith('//') || /[?#\\\s]/u.test(value))
|
|
51
|
+
return false;
|
|
52
|
+
try {
|
|
53
|
+
return new URL(value, 'https://commerce.invalid').pathname === value;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function isCommerceContext(value) {
|
|
60
|
+
return boundedJson(value, 4096) &&
|
|
61
|
+
commerceObject(value, ['schemaVersion', 'contextRevision', 'pageId', 'origin', 'path', 'pageType', 'market', 'productRef', 'selectedOptions']) &&
|
|
62
|
+
value.schemaVersion === 1 && commerceCount(value.contextRevision) && pageIdentity(value.pageId) &&
|
|
63
|
+
https(value.origin) && new URL(value.origin).origin === value.origin && isCommercePath(value.path) &&
|
|
64
|
+
['product', 'listing', 'search', 'cart', 'help', 'unknown'].includes(String(value.pageType)) && isCommerceMarket(value.market) &&
|
|
65
|
+
(value.productRef === null || reference(value.productRef)) && isCommerceOptions(value.selectedOptions);
|
|
66
|
+
}
|
|
67
|
+
/** Validate JSON without invoking getters or toJSON; cap traversal before parsing. */
|
|
68
|
+
function boundedJson(value, maximum) {
|
|
69
|
+
let remaining = maximum;
|
|
70
|
+
const ancestors = new Set();
|
|
71
|
+
const encoder = new TextEncoder();
|
|
72
|
+
const spend = (amount) => { remaining -= amount; if (remaining < 0)
|
|
73
|
+
throw new Error('Commerce JSON exceeds its limit.'); };
|
|
74
|
+
const string = (item) => {
|
|
75
|
+
if (item.length > remaining)
|
|
76
|
+
throw new Error('Commerce text exceeds its limit.');
|
|
77
|
+
spend(encoder.encode(JSON.stringify(item)).length);
|
|
78
|
+
};
|
|
79
|
+
const visit = (item, depth) => {
|
|
80
|
+
if (depth > 10)
|
|
81
|
+
throw new Error('Commerce JSON is too deeply nested.');
|
|
82
|
+
if (typeof item === 'string') {
|
|
83
|
+
string(item);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (item === null) {
|
|
87
|
+
spend(4);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (typeof item === 'boolean') {
|
|
91
|
+
spend(item ? 4 : 5);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (typeof item === 'number' && Number.isFinite(item)) {
|
|
95
|
+
spend(String(item).length);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (!item || typeof item !== 'object' || ancestors.has(item))
|
|
99
|
+
throw new Error('Invalid commerce JSON.');
|
|
100
|
+
const array = Array.isArray(item);
|
|
101
|
+
if (!array && Object.getPrototypeOf(item) !== Object.prototype && Object.getPrototypeOf(item) !== null)
|
|
102
|
+
throw new Error('Invalid commerce object.');
|
|
103
|
+
ancestors.add(item);
|
|
104
|
+
spend(2);
|
|
105
|
+
if (array && item.length > (remaining + 1) / 2)
|
|
106
|
+
throw new Error('Commerce array exceeds its limit.');
|
|
107
|
+
const keys = Object.keys(item);
|
|
108
|
+
if (array && keys.length !== item.length)
|
|
109
|
+
throw new Error('Invalid commerce array.');
|
|
110
|
+
for (const [index, key] of keys.entries()) {
|
|
111
|
+
if (array && key !== String(index))
|
|
112
|
+
throw new Error('Invalid commerce array.');
|
|
113
|
+
if (index > 0)
|
|
114
|
+
spend(1);
|
|
115
|
+
if (!array) {
|
|
116
|
+
string(key);
|
|
117
|
+
spend(1);
|
|
118
|
+
}
|
|
119
|
+
const descriptor = Object.getOwnPropertyDescriptor(item, key);
|
|
120
|
+
if (!descriptor || !('value' in descriptor))
|
|
121
|
+
throw new Error('Invalid commerce property.');
|
|
122
|
+
visit(descriptor.value, depth + 1);
|
|
123
|
+
}
|
|
124
|
+
ancestors.delete(item);
|
|
125
|
+
};
|
|
126
|
+
try {
|
|
127
|
+
visit(value, 0);
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function timestamp(value) {
|
|
135
|
+
if (typeof value !== 'string' || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{1,3})?Z$/u.test(value))
|
|
136
|
+
return null;
|
|
137
|
+
const milliseconds = Date.parse(value);
|
|
138
|
+
if (!Number.isFinite(milliseconds))
|
|
139
|
+
return null;
|
|
140
|
+
const normalized = value.replace(/(?:\.(\d{1,3}))?Z$/u, (_, fraction) => `.${(fraction ?? '').padEnd(3, '0')}Z`);
|
|
141
|
+
return new Date(milliseconds).toISOString() === normalized ? milliseconds : null;
|
|
142
|
+
}
|
|
143
|
+
const positive = (value) => commerceCount(value) && value > 0;
|
|
144
|
+
function isVariant(value, currency) {
|
|
145
|
+
if (!commerceObject(value, ['variantRef', 'title', 'selectedOptions', 'price', 'available', 'requiresSellingPlan', 'quantityRule']) ||
|
|
146
|
+
!reference(value.variantRef) || !text(value.title, 256) || !isCommerceOptions(value.selectedOptions) ||
|
|
147
|
+
!commerceObject(value.price, ['amount', 'currency']) || value.price.currency !== currency || typeof value.price.amount !== 'string' ||
|
|
148
|
+
!/^(?:0|[1-9]\d{0,9})(?:\.\d{1,6})?$/u.test(value.price.amount) || typeof value.available !== 'boolean' ||
|
|
149
|
+
typeof value.requiresSellingPlan !== 'boolean' || !commerceObject(value.quantityRule, ['minimum', 'maximum', 'increment']))
|
|
150
|
+
return false;
|
|
151
|
+
const rule = value.quantityRule;
|
|
152
|
+
// Shopify QuantityRule requires both bounds to be multiples of increment.
|
|
153
|
+
// Invalid upstream rules are rejected; rounding would invent a permitted quantity.
|
|
154
|
+
return positive(rule.minimum) && positive(rule.increment) && rule.minimum % rule.increment === 0 &&
|
|
155
|
+
(rule.maximum === null || (positive(rule.maximum) && rule.maximum >= rule.minimum && rule.maximum % rule.increment === 0));
|
|
156
|
+
}
|
|
157
|
+
function isProduct(value, store, market) {
|
|
158
|
+
if (!commerceObject(value, ['productRef', 'title', 'url', 'image', 'description', 'options', 'variant']) || !reference(value.productRef) ||
|
|
159
|
+
!text(value.title, 256) || !https(value.url) || new URL(value.url).origin !== store.origin ||
|
|
160
|
+
typeof value.description !== 'string' || value.description.length > 2000 || !Array.isArray(value.options) || value.options.length > 3)
|
|
161
|
+
return false;
|
|
162
|
+
if (value.image !== null && (!commerceObject(value.image, ['url', 'alt']) || !https(value.image.url) ||
|
|
163
|
+
typeof value.image.alt !== 'string' || value.image.alt.length > 256 || controls.test(value.image.alt)))
|
|
164
|
+
return false;
|
|
165
|
+
if (!value.options.every(option => commerceObject(option, ['name', 'values', 'complete']) && text(option.name, 64) &&
|
|
166
|
+
typeof option.complete === 'boolean' && Array.isArray(option.values) && option.values.length <= 50 &&
|
|
167
|
+
(!option.complete || option.values.length > 0) && option.values.every(entry => text(entry, 128)) && new Set(option.values).size === option.values.length) ||
|
|
168
|
+
new Set(value.options.map(option => option.name)).size !== value.options.length)
|
|
169
|
+
return false;
|
|
170
|
+
if (value.variant === null)
|
|
171
|
+
return true;
|
|
172
|
+
if (!isVariant(value.variant, market.currency))
|
|
173
|
+
return false;
|
|
174
|
+
const choices = value.variant.selectedOptions;
|
|
175
|
+
return choices.length === value.options.length && value.options.every(option => choices.some(choice => choice.name === option.name && option.values.includes(choice.value)));
|
|
176
|
+
}
|
|
177
|
+
/** Browser reads are presentation only. Their store/market must still match the
|
|
178
|
+
* authenticated bootstrap and current page; a displayed card is never a cart grant. */
|
|
179
|
+
export function parseCommerceCatalog(value, authority, context, now = Date.now()) {
|
|
180
|
+
try {
|
|
181
|
+
if (!context || !Number.isFinite(now) || !isCommerceContext(context) ||
|
|
182
|
+
!parseCommerceBootstrap(authority, authority.guideId, context.origin) || !boundedJson(value, 12000) ||
|
|
183
|
+
!commerceObject(value, ['schemaVersion', 'type', 'resultSetId', 'guideId', 'store', 'market', 'fetchedAt', 'expiresAt', 'ranking', 'products']) ||
|
|
184
|
+
value.schemaVersion !== 1 || value.type !== 'commerce.catalog' || !commerceUuid(value.resultSetId) || value.guideId !== authority.guideId ||
|
|
185
|
+
!isCommerceStore(value.store) || !sameCommerceStore(value.store, authority.store) || value.store.origin !== context.origin ||
|
|
186
|
+
!isCommerceMarket(value.market) || !sameCommerceMarket(value.market, context.market) ||
|
|
187
|
+
!commerceObject(value.ranking, ['basis', 'period']) || value.ranking.period !== null ||
|
|
188
|
+
!['shopify_best_selling', 'relevance', 'price_ascending', 'catalog'].includes(String(value.ranking.basis)) ||
|
|
189
|
+
typeof value.fetchedAt !== 'string' || typeof value.expiresAt !== 'string' ||
|
|
190
|
+
![value.fetchedAt, value.expiresAt].every(stamp => /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{1,3})?Z$/u.test(stamp)) ||
|
|
191
|
+
!Array.isArray(value.products) || value.products.length > 3)
|
|
192
|
+
return null;
|
|
193
|
+
const fetched = timestamp(value.fetchedAt);
|
|
194
|
+
const expiry = timestamp(value.expiresAt);
|
|
195
|
+
if (fetched === null || expiry === null || fetched > now + 30000 || now - fetched > 300000 ||
|
|
196
|
+
expiry <= now || expiry <= fetched || expiry - fetched > 300000 || !value.products.every(product => isProduct(product, value.store, value.market)))
|
|
197
|
+
return null;
|
|
198
|
+
const products = value.products;
|
|
199
|
+
const variants = products.flatMap(product => product.variant ? [product.variant.variantRef] : []);
|
|
200
|
+
if (new Set(products.map(product => product.productRef)).size !== products.length || new Set(variants).size !== variants.length)
|
|
201
|
+
return null;
|
|
202
|
+
return value;
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export function displayedCommerceProducts(catalog) {
|
|
209
|
+
return catalog.products.map(product => ({ productRef: product.productRef, variantRef: product.variant?.variantRef ?? null }));
|
|
210
|
+
}
|
|
211
|
+
/** Visible cards may be a subset; receipts preserve the issued order and exact pairs. */
|
|
212
|
+
export function isDisplayedCommerceProducts(catalog, value) {
|
|
213
|
+
if (!boundedJson(value, 8192) || !Array.isArray(value) || value.length > catalog.products.length ||
|
|
214
|
+
(value.length === 0 && catalog.products.length !== 0))
|
|
215
|
+
return false;
|
|
216
|
+
let previous = -1;
|
|
217
|
+
for (const item of value) {
|
|
218
|
+
if (!commerceObject(item, ['productRef', 'variantRef']))
|
|
219
|
+
return false;
|
|
220
|
+
const index = catalog.products.findIndex(product => product.productRef === item.productRef &&
|
|
221
|
+
(product.variant?.variantRef ?? null) === item.variantRef);
|
|
222
|
+
if (index <= previous)
|
|
223
|
+
return false;
|
|
224
|
+
previous = index;
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
/** Copy only presentation fields; cart selections never become display receipts. */
|
|
229
|
+
export function liveCommerceDisplayedReceipt(event) {
|
|
230
|
+
return { schemaVersion: 1, taskId: event.taskId, inputEpoch: event.inputEpoch, contextRevision: event.contextRevision,
|
|
231
|
+
pageId: event.pageId, resultSetId: event.catalog.resultSetId, products: displayedCommerceProducts(event.catalog) };
|
|
232
|
+
}
|
|
233
|
+
export function realtimeCommerceDisplayedReceipt(event) {
|
|
234
|
+
return { schemaVersion: 1, executionId: event.executionId, functionCallId: event.functionCallId,
|
|
235
|
+
providerGenerationDigest: event.providerGenerationDigest, contextRevision: event.contextRevision, pageId: event.pageId,
|
|
236
|
+
resultSetId: event.catalog.resultSetId, products: displayedCommerceProducts(event.catalog) };
|
|
237
|
+
}
|
|
238
|
+
function catalogEnvelope(value, keys, options) {
|
|
239
|
+
// Catalog data keeps its separate 12 kB ceiling. The extension duplicates up to
|
|
240
|
+
// three bounded references; leave room for escaped JSON while bounding the frame.
|
|
241
|
+
if (!boundedJson(value, options.cartNegotiated === true ? 24576 : 13024))
|
|
242
|
+
return false;
|
|
243
|
+
return commerceObject(value, keys) || (options.cartNegotiated === true && commerceObject(value, [...keys, 'cartSelections']));
|
|
244
|
+
}
|
|
245
|
+
function validCartSelections(value, authority, catalog, options) {
|
|
246
|
+
if (!Object.prototype.hasOwnProperty.call(value, 'cartSelections'))
|
|
247
|
+
return true;
|
|
248
|
+
if (options.cartNegotiated !== true || authority.cartEnabled !== true || !Array.isArray(value.cartSelections) || value.cartSelections.length > 3)
|
|
249
|
+
return false;
|
|
250
|
+
let previous = -1;
|
|
251
|
+
const digests = new Set();
|
|
252
|
+
for (const selection of value.cartSelections) {
|
|
253
|
+
if (!commerceObject(selection, ['productRef', 'variantRef', 'selectionDigest']) || !reference(selection.productRef) ||
|
|
254
|
+
!reference(selection.variantRef) || typeof selection.selectionDigest !== 'string' || !/^[a-f0-9]{64}$/u.test(selection.selectionDigest) ||
|
|
255
|
+
digests.has(selection.selectionDigest))
|
|
256
|
+
return false;
|
|
257
|
+
const index = catalog.products.findIndex(product => product.productRef === selection.productRef &&
|
|
258
|
+
product.variant !== null && product.variant.variantRef === selection.variantRef);
|
|
259
|
+
if (index <= previous)
|
|
260
|
+
return false;
|
|
261
|
+
previous = index;
|
|
262
|
+
digests.add(selection.selectionDigest);
|
|
263
|
+
}
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
/** Use only after parsing the event against current context and negotiation.
|
|
267
|
+
* A selection identifies a displayed variant; it is not a cart operation grant. */
|
|
268
|
+
export function commerceCartSelection(event, productRef, variantRef) {
|
|
269
|
+
if (!event.catalog.products.some(product => product.productRef === productRef && product.variant?.variantRef === variantRef))
|
|
270
|
+
return null;
|
|
271
|
+
const selection = event.cartSelections?.find(value => value.productRef === productRef && value.variantRef === variantRef);
|
|
272
|
+
return selection ? { ...selection } : null;
|
|
273
|
+
}
|
|
274
|
+
/** The transport must first attest the current authenticated control connection.
|
|
275
|
+
* Optional expected IDs must come from independent task/provider state. */
|
|
276
|
+
export function parseLiveCommerceCatalog(value, authority, context, expected, now = Date.now(), options = { cartNegotiated: false }) {
|
|
277
|
+
if (!context || !catalogEnvelope(value, ['schemaVersion', 'taskId', 'inputEpoch', 'contextRevision', 'pageId', 'catalog'], options) ||
|
|
278
|
+
value.schemaVersion !== 1 || !commerceUuid(value.taskId) || !commerceCount(value.inputEpoch) ||
|
|
279
|
+
!commerceCount(value.contextRevision) || !pageIdentity(value.pageId) ||
|
|
280
|
+
value.contextRevision !== context.contextRevision || value.pageId !== context.pageId ||
|
|
281
|
+
(expected && (value.taskId !== expected.taskId || value.inputEpoch !== expected.inputEpoch)) ||
|
|
282
|
+
!parseCommerceCatalog(value.catalog, authority, context, now) ||
|
|
283
|
+
!validCartSelections(value, authority, value.catalog, options))
|
|
284
|
+
return null;
|
|
285
|
+
return value;
|
|
286
|
+
}
|
|
287
|
+
export function parseRealtimeCommerceCatalog(value, authority, context, expected, now = Date.now(), options = { cartNegotiated: false }) {
|
|
288
|
+
if (!context || !catalogEnvelope(value, ['schemaVersion', 'executionId', 'functionCallId', 'providerGenerationDigest', 'contextRevision', 'pageId', 'catalog'], options) ||
|
|
289
|
+
value.schemaVersion !== 1 || typeof value.executionId !== 'string' || !/^[a-f0-9]{64}$/u.test(value.executionId) ||
|
|
290
|
+
typeof value.functionCallId !== 'string' || value.functionCallId.length < 1 || value.functionCallId.length > 256 ||
|
|
291
|
+
typeof value.providerGenerationDigest !== 'string' || !/^[a-f0-9]{64}$/u.test(value.providerGenerationDigest) ||
|
|
292
|
+
!commerceCount(value.contextRevision) || !pageIdentity(value.pageId) ||
|
|
293
|
+
value.contextRevision !== context.contextRevision || value.pageId !== context.pageId ||
|
|
294
|
+
(expected && (value.executionId !== expected.executionId || value.functionCallId !== expected.functionCallId ||
|
|
295
|
+
value.providerGenerationDigest !== expected.providerGenerationDigest)) ||
|
|
296
|
+
!parseCommerceCatalog(value.catalog, authority, context, now) ||
|
|
297
|
+
!validCartSelections(value, authority, value.catalog, options))
|
|
298
|
+
return null;
|
|
299
|
+
return value;
|
|
300
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type CommerceContext, type CommerceContextClear } from './contracts.js';
|
|
2
|
+
type StorefrontWindow = Window & {
|
|
3
|
+
Shopify?: {
|
|
4
|
+
country?: unknown;
|
|
5
|
+
locale?: unknown;
|
|
6
|
+
currency?: {
|
|
7
|
+
active?: unknown;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
ShopifyAnalytics?: {
|
|
11
|
+
meta?: {
|
|
12
|
+
product?: {
|
|
13
|
+
id?: unknown;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/** Shopify's public market is a hint, verified again against Storefront API.
|
|
19
|
+
* No defaults turn an unknown visitor market into the merchant's own market. */
|
|
20
|
+
export declare function readShopifyCommerceContext(window: StorefrontWindow, identity: {
|
|
21
|
+
pageId: string;
|
|
22
|
+
contextRevision: number;
|
|
23
|
+
}, sharePage: boolean): CommerceContext | null;
|
|
24
|
+
export declare class CommercePageContext {
|
|
25
|
+
private readonly sharePage;
|
|
26
|
+
private readonly changed;
|
|
27
|
+
private pageId;
|
|
28
|
+
private revision;
|
|
29
|
+
private path;
|
|
30
|
+
private url;
|
|
31
|
+
private snapshot;
|
|
32
|
+
private observer;
|
|
33
|
+
private initialized;
|
|
34
|
+
private started;
|
|
35
|
+
private destroyed;
|
|
36
|
+
constructor(sharePage: () => boolean, changed: (context: CommerceContext | null) => void);
|
|
37
|
+
start(): void;
|
|
38
|
+
private onChange;
|
|
39
|
+
/** Call before sending a commerce request as SPA navigation need not emit DOM
|
|
40
|
+
* events. force creates a new revision after a session/privacy generation cut. */
|
|
41
|
+
refresh: (options?: {
|
|
42
|
+
force?: boolean;
|
|
43
|
+
}) => CommerceContext | null;
|
|
44
|
+
get current(): CommerceContext | null;
|
|
45
|
+
/** Remains available when current is null, so the transport can send a
|
|
46
|
+
* monotonic commerce.context.clear tombstone instead of retaining old hints. */
|
|
47
|
+
get identity(): CommerceContextClear;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { isCommerceContext, isCommerceMarket, isCommerceOptions, isCommercePath, } from './contracts.js';
|
|
2
|
+
const pageType = (path) => {
|
|
3
|
+
if (/\/(?:[^/]+\/)?products\//u.test(path))
|
|
4
|
+
return 'product';
|
|
5
|
+
if (/\/(?:[^/]+\/)?collections(?:\/|$)/u.test(path))
|
|
6
|
+
return 'listing';
|
|
7
|
+
if (/\/(?:[^/]+\/)?search(?:\/|$)/u.test(path))
|
|
8
|
+
return 'search';
|
|
9
|
+
if (/\/(?:[^/]+\/)?cart(?:\/|$)/u.test(path))
|
|
10
|
+
return 'cart';
|
|
11
|
+
if (/\/(?:policies\/|pages\/(?:help|faq|shipping|returns|contact))/u.test(path))
|
|
12
|
+
return 'help';
|
|
13
|
+
return 'unknown';
|
|
14
|
+
};
|
|
15
|
+
function productIdentifier(value) {
|
|
16
|
+
const id = typeof value === 'number' && Number.isSafeInteger(value) && value > 0 ? String(value) : value;
|
|
17
|
+
return typeof id === 'string' && /^[1-9]\d{0,19}$/u.test(id) &&
|
|
18
|
+
(id.length < 20 || id <= '18446744073709551615') ? id : null;
|
|
19
|
+
}
|
|
20
|
+
function productSelection(document, productId) {
|
|
21
|
+
if (!productId)
|
|
22
|
+
return [];
|
|
23
|
+
// Recommendation/quick-add forms must not contribute the current product's
|
|
24
|
+
// options. Prefer a form explicitly associated with the actual product ID.
|
|
25
|
+
const candidates = [];
|
|
26
|
+
const forms = document.querySelectorAll('form[action]');
|
|
27
|
+
if (forms.length > 100)
|
|
28
|
+
return [];
|
|
29
|
+
for (const form of Array.from(forms)) {
|
|
30
|
+
let action;
|
|
31
|
+
try {
|
|
32
|
+
action = new URL(form.action, document.location.href);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (action.origin !== document.location.origin || !/\/cart\/add\/?$/u.test(action.pathname))
|
|
38
|
+
continue;
|
|
39
|
+
const declared = form.getAttribute('data-product-id') ??
|
|
40
|
+
form.querySelector('input[name="product-id"],input[name="product_id"]')?.value ??
|
|
41
|
+
form.closest('[data-product-id]')?.getAttribute('data-product-id');
|
|
42
|
+
const id = productIdentifier(declared);
|
|
43
|
+
if (declared != null && id !== productId)
|
|
44
|
+
continue;
|
|
45
|
+
candidates.push({ form, productId: id });
|
|
46
|
+
}
|
|
47
|
+
const matches = candidates.filter(candidate => candidate.productId === productId);
|
|
48
|
+
const form = matches.length === 1 ? matches[0]?.form : matches.length === 0 && candidates.length === 1 ? candidates[0]?.form : undefined;
|
|
49
|
+
if (!form || form.elements.length > 256)
|
|
50
|
+
return [];
|
|
51
|
+
const choices = [];
|
|
52
|
+
// form.elements includes controls associated via form="..." outside the form.
|
|
53
|
+
for (const element of Array.from(form.elements)) {
|
|
54
|
+
if (element.tagName !== 'INPUT' && element.tagName !== 'SELECT')
|
|
55
|
+
continue;
|
|
56
|
+
const input = element;
|
|
57
|
+
const name = /^options\[([^\]]+)\]$/u.exec(input.name)?.[1];
|
|
58
|
+
if (!name || input.disabled)
|
|
59
|
+
continue;
|
|
60
|
+
if (input.tagName === 'INPUT' && (input.type !== 'radio' || !input.checked))
|
|
61
|
+
continue;
|
|
62
|
+
if (input.tagName === 'SELECT' && input.multiple)
|
|
63
|
+
return [];
|
|
64
|
+
choices.push({ name, value: input.value });
|
|
65
|
+
if (choices.length > 3)
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
return isCommerceOptions(choices) ? choices : [];
|
|
69
|
+
}
|
|
70
|
+
/** Shopify's public market is a hint, verified again against Storefront API.
|
|
71
|
+
* No defaults turn an unknown visitor market into the merchant's own market. */
|
|
72
|
+
export function readShopifyCommerceContext(window, identity, sharePage) {
|
|
73
|
+
const store = window.Shopify;
|
|
74
|
+
let locale;
|
|
75
|
+
try {
|
|
76
|
+
locale = typeof store?.locale === 'string' && store.locale.length <= 35 ? Intl.getCanonicalLocales(store.locale.replace(/_/gu, '-'))[0] : undefined;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const market = { country: store?.country, locale, currency: store?.currency?.active };
|
|
82
|
+
if (!isCommerceMarket(market) || window.location.protocol !== 'https:')
|
|
83
|
+
return null;
|
|
84
|
+
const path = sharePage ? window.location.pathname : '/';
|
|
85
|
+
if (!isCommercePath(path))
|
|
86
|
+
return null;
|
|
87
|
+
const type = sharePage ? pageType(path) : 'unknown';
|
|
88
|
+
const productId = type === 'product' ? productIdentifier(window.ShopifyAnalytics?.meta?.product?.id) : null;
|
|
89
|
+
const context = { schemaVersion: 1, ...identity, origin: window.location.origin, path, pageType: type,
|
|
90
|
+
market, productRef: productId ? `gid://shopify/Product/${productId}` : null,
|
|
91
|
+
selectedOptions: type === 'product' ? productSelection(window.document, productId) : [] };
|
|
92
|
+
return isCommerceContext(context) ? context : null;
|
|
93
|
+
}
|
|
94
|
+
export class CommercePageContext {
|
|
95
|
+
constructor(sharePage, changed) {
|
|
96
|
+
this.sharePage = sharePage;
|
|
97
|
+
this.changed = changed;
|
|
98
|
+
this.pageId = crypto.randomUUID();
|
|
99
|
+
this.revision = 0;
|
|
100
|
+
this.path = location.pathname;
|
|
101
|
+
this.url = location.href;
|
|
102
|
+
this.snapshot = null;
|
|
103
|
+
this.observer = null;
|
|
104
|
+
this.initialized = false;
|
|
105
|
+
this.started = false;
|
|
106
|
+
this.destroyed = false;
|
|
107
|
+
this.onChange = () => { this.refresh(); };
|
|
108
|
+
/** Call before sending a commerce request as SPA navigation need not emit DOM
|
|
109
|
+
* events. force creates a new revision after a session/privacy generation cut. */
|
|
110
|
+
this.refresh = (options = {}) => {
|
|
111
|
+
if (this.destroyed)
|
|
112
|
+
return null;
|
|
113
|
+
const navigated = location.pathname !== this.path;
|
|
114
|
+
if (navigated) {
|
|
115
|
+
this.path = location.pathname;
|
|
116
|
+
this.pageId = crypto.randomUUID();
|
|
117
|
+
}
|
|
118
|
+
this.url = location.href;
|
|
119
|
+
const next = readShopifyCommerceContext(window, this.identity, this.sharePage());
|
|
120
|
+
if (this.initialized && !navigated && !options.force && JSON.stringify(next) === JSON.stringify(this.snapshot))
|
|
121
|
+
return this.snapshot;
|
|
122
|
+
this.initialized = true;
|
|
123
|
+
if (this.revision === Number.MAX_SAFE_INTEGER) {
|
|
124
|
+
this.destroy();
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
this.revision += 1;
|
|
128
|
+
this.snapshot = next ? { ...next, contextRevision: this.revision } : null;
|
|
129
|
+
this.changed(this.snapshot);
|
|
130
|
+
return this.snapshot;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
start() {
|
|
134
|
+
if (this.started || this.destroyed)
|
|
135
|
+
return;
|
|
136
|
+
this.started = true;
|
|
137
|
+
window.addEventListener('popstate', this.onChange);
|
|
138
|
+
window.addEventListener('pageshow', this.onChange);
|
|
139
|
+
document.addEventListener('change', this.onChange, true);
|
|
140
|
+
document.addEventListener('variant:change', this.onChange);
|
|
141
|
+
this.observer = new MutationObserver(records => {
|
|
142
|
+
const controls = 'form,select,option,input[name^="options["],product-info,[data-product-id]';
|
|
143
|
+
if (location.href !== this.url || records.some(record => (record.target instanceof Element && record.target.matches(controls)) ||
|
|
144
|
+
Array.from(record.addedNodes).some(node => node instanceof Element && (node.matches(controls) || !!node.querySelector(controls)))))
|
|
145
|
+
this.refresh();
|
|
146
|
+
});
|
|
147
|
+
this.observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['checked', 'selected', 'value', 'data-product-id'] });
|
|
148
|
+
this.refresh();
|
|
149
|
+
}
|
|
150
|
+
get current() { return this.snapshot; }
|
|
151
|
+
/** Remains available when current is null, so the transport can send a
|
|
152
|
+
* monotonic commerce.context.clear tombstone instead of retaining old hints. */
|
|
153
|
+
get identity() {
|
|
154
|
+
return { schemaVersion: 1, contextRevision: this.revision, pageId: this.pageId };
|
|
155
|
+
}
|
|
156
|
+
destroy() {
|
|
157
|
+
if (this.destroyed)
|
|
158
|
+
return;
|
|
159
|
+
this.destroyed = true;
|
|
160
|
+
window.removeEventListener('popstate', this.onChange);
|
|
161
|
+
window.removeEventListener('pageshow', this.onChange);
|
|
162
|
+
document.removeEventListener('change', this.onChange, true);
|
|
163
|
+
document.removeEventListener('variant:change', this.onChange);
|
|
164
|
+
this.observer?.disconnect();
|
|
165
|
+
this.observer = null;
|
|
166
|
+
this.snapshot = null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { WidgetMessageKey } from "../types.js";
|
|
2
|
+
import type { ShoppingNotesProduct } from "./shoppingNotes.js";
|
|
3
|
+
import type { CommerceCatalog, CommerceDisplayedProducts, CommerceOption } from "./contracts.js";
|
|
4
|
+
export type CommerceMessage = (key: WidgetMessageKey) => string;
|
|
5
|
+
export type CommerceAddHandler = (productRef: string, variantRef: string, quantity: number) => void | Promise<void>;
|
|
6
|
+
export type CommerceCanAdd = (productRef: string, variantRef: string, quantity: number) => boolean;
|
|
7
|
+
export interface CommerceProductPanelCallbacks {
|
|
8
|
+
/** Partial receipts are used only with negotiated cart support. */
|
|
9
|
+
displayMode?: "all" | "visible";
|
|
10
|
+
onSelection: (productRef: string, options: CommerceOption[]) => void | Promise<void>;
|
|
11
|
+
onCompare: (productRefs: string[]) => void | Promise<void>;
|
|
12
|
+
onRefresh: () => void | Promise<void>;
|
|
13
|
+
onDisplayed?: (resultSetId: string, products: CommerceDisplayedProducts) => void;
|
|
14
|
+
onClose?: () => void;
|
|
15
|
+
onShoppingNotes?: () => void;
|
|
16
|
+
onSaveItem?: (product: ShoppingNotesProduct) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const COMMERCE_PRODUCT_PANEL_STYLES = "\n .commerce-panel { box-sizing: border-box; min-width: 0; max-width: 100%; padding: 12px; color: var(--assist-text, var(--voice-text)); background: var(--assist-surface, var(--voice-surface)); border: 1px solid var(--assist-border, var(--voice-border)); border-radius: 16px; font: 400 14px/1.45 system-ui, sans-serif; pointer-events: auto; }\n .commerce-panel *, .commerce-panel *::before, .commerce-panel *::after { box-sizing: border-box; }\n .commerce-panel[hidden], .commerce-panel [hidden] { display: none !important; }\n .commerce-panel-header, .commerce-panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }\n .commerce-panel-header { justify-content: space-between; }\n .commerce-panel h2, .commerce-panel h3, .commerce-panel p { margin: 0; }\n .commerce-panel h2 { flex: 1; font: 600 15px/1.4 system-ui, sans-serif; }\n .commerce-panel h3 { font: 600 14px/1.4 system-ui, sans-serif; overflow-wrap: anywhere; }\n .commerce-panel-status, .commerce-panel-ranking { margin-block: 8px !important; color: var(--assist-muted, var(--voice-muted)); font-size: 12px; }\n .commerce-panel-content { max-height: min(540px, 55dvh); overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 2px; }\n .commerce-panel-products { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); align-items: start; gap: 12px; }\n .commerce-panel[data-comparing=\"true\"] .commerce-panel-products { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }\n .commerce-product { display: grid; min-width: 0; gap: 10px; padding: 12px; border: 1px solid var(--assist-border, var(--voice-border)); border-radius: 12px; background: var(--assist-surface-muted, var(--voice-surface)); }\n .commerce-product-summary { display: grid; gap: 4px; }\n .commerce-product-image { display: block; width: 100%; height: 112px; object-fit: contain; border-radius: 8px; }\n .commerce-product-price { font-weight: 600; }\n .commerce-product-availability, .commerce-product-description, .commerce-product-note { font-size: 12px; overflow-wrap: anywhere; }\n .commerce-product-description { white-space: pre-line; }\n .commerce-product-note { color: var(--assist-muted, var(--voice-muted)); }\n .commerce-product-options { display: grid; min-width: 0; gap: 8px; border: 0; padding: 0; margin: 0; }\n .commerce-product-label { display: grid; min-width: 0; gap: 4px; font-size: 12px; }\n .commerce-product-compare { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: 12px; }\n .commerce-panel button, .commerce-panel select, .commerce-panel input[type=\"number\"], .commerce-product-link { min-height: 44px; max-width: 100%; padding: 8px 10px; border: 1px solid var(--assist-border, var(--voice-border)); border-radius: 8px; color: inherit; background: var(--assist-surface, var(--voice-surface)); font: inherit; }\n .commerce-panel select, .commerce-panel input[type=\"number\"] { width: 100%; min-width: 0; }\n .commerce-panel button { cursor: pointer; white-space: normal; overflow-wrap: anywhere; }\n .commerce-panel button:disabled, .commerce-panel select:disabled, .commerce-panel input:disabled { opacity: .55; cursor: default; }\n .commerce-panel :is(a, button, input, select):focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }\n .commerce-product-link { display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: underline; text-underline-offset: 3px; }\n .commerce-panel-actions { margin-block-start: 10px; }\n .commerce-panel-actions > button { flex: 1; }\n .commerce-panel-close { flex: none; font-size: 12px !important; }\n @media (forced-colors: active) { .commerce-panel, .commerce-product { color: CanvasText; background: Canvas; border-color: CanvasText; } .commerce-product-link { color: LinkText; } .commerce-panel :is(a, button, input, select):focus-visible { outline-color: Highlight; } }\n";
|
|
19
|
+
export declare const formatCommercePrice: (amount: string, currency: string, locale: string) => string;
|
|
20
|
+
export declare class CommerceProductPanel {
|
|
21
|
+
private readonly message;
|
|
22
|
+
private readonly callbacks;
|
|
23
|
+
readonly element: HTMLElement;
|
|
24
|
+
private readonly content;
|
|
25
|
+
private readonly products;
|
|
26
|
+
private readonly status;
|
|
27
|
+
private readonly ranking;
|
|
28
|
+
private readonly compareButton;
|
|
29
|
+
private readonly refreshButton;
|
|
30
|
+
private readonly backButton;
|
|
31
|
+
private catalog;
|
|
32
|
+
private states;
|
|
33
|
+
private comparison;
|
|
34
|
+
private seen;
|
|
35
|
+
private displayed;
|
|
36
|
+
private reported;
|
|
37
|
+
private busy;
|
|
38
|
+
private failed;
|
|
39
|
+
private errorMessage;
|
|
40
|
+
private destroyed;
|
|
41
|
+
private expiryTimer;
|
|
42
|
+
private visibilityFrame;
|
|
43
|
+
private observer;
|
|
44
|
+
private addHandler;
|
|
45
|
+
private canAdd;
|
|
46
|
+
constructor(message: CommerceMessage, callbacks: CommerceProductPanelCallbacks);
|
|
47
|
+
/** Input must already pass parseCommerceCatalog for the current binding/page. */
|
|
48
|
+
setCatalog(catalog: CommerceCatalog): void;
|
|
49
|
+
/** The parent supplies real operation authority; a catalog never enables cart writes. */
|
|
50
|
+
setCartActionHandler(handler: CommerceAddHandler | null, canAdd?: CommerceCanAdd): void;
|
|
51
|
+
setBusy(busy: boolean): void;
|
|
52
|
+
showError(message?: "commerceError" | "commerceCartUncertain" | "commerceCartChanged"): void;
|
|
53
|
+
clear(): void;
|
|
54
|
+
/** Call after opening/moving the widget; observers also cover clipping/scroll. */
|
|
55
|
+
readonly refreshVisibility: () => void;
|
|
56
|
+
destroy(): void;
|
|
57
|
+
private button;
|
|
58
|
+
private renderProduct;
|
|
59
|
+
private fresh;
|
|
60
|
+
private saveAllowed;
|
|
61
|
+
private addAllowed;
|
|
62
|
+
private update;
|
|
63
|
+
private compare;
|
|
64
|
+
private runAction;
|
|
65
|
+
}
|