@tokenoftrust/storefront-runner 7.3.0 → 7.3.1
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.
|
@@ -43,7 +43,10 @@
|
|
|
43
43
|
* same-origin session endpoint (an HttpOnly cookie the browser cannot read) and
|
|
44
44
|
* is applied in the loader's `onLoad`, before the drawer reads its own cookie.
|
|
45
45
|
* Cart links get the same id on the URL. If the session cannot be opened, the
|
|
46
|
-
* cart is not followed.
|
|
46
|
+
* cart is not followed. An add opens a new provider session holding the cart
|
|
47
|
+
* (cartSession.ts), so the confirmation it raises carries that session on its
|
|
48
|
+
* cart link; the loader adopts it, and a drawer already up switches to it through
|
|
49
|
+
* Foxy's own `FC.session.reset`, which re-renders the drawer from that session.
|
|
47
50
|
*
|
|
48
51
|
* On a store that is not public (`storeNotPublic`), a managed add-to-cart is
|
|
49
52
|
* checked before it leaves the page: the checkout route refuses a viewer admitted
|
|
@@ -57,6 +60,7 @@
|
|
|
57
60
|
*/
|
|
58
61
|
import { CHECKOUT_NAVIGATION_REFERRER_POLICY } from "@tot/public-runtime";
|
|
59
62
|
import { CART_UNAVAILABLE_MESSAGE } from "@/lib/checkout/commerce/cartSession";
|
|
63
|
+
import { CART_ADDED_EVENT } from "./cartState";
|
|
60
64
|
|
|
61
65
|
export const LAZY_CHECKOUT_LOADER_IDLE_MS = 8000;
|
|
62
66
|
|
|
@@ -227,8 +231,8 @@ export function lazyCheckoutLoaderJs(options: LazyCheckoutLoaderOptions): string
|
|
|
227
231
|
sessionPromise = null;
|
|
228
232
|
return null;
|
|
229
233
|
}
|
|
230
|
-
sessionId = id;
|
|
231
|
-
return
|
|
234
|
+
if (!sessionId) sessionId = id;
|
|
235
|
+
return sessionId;
|
|
232
236
|
}, function () {
|
|
233
237
|
sessionPromise = null;
|
|
234
238
|
return null;
|
|
@@ -325,7 +329,7 @@ export function lazyCheckoutLoaderJs(options: LazyCheckoutLoaderOptions): string
|
|
|
325
329
|
window.FC = window.FC || {};
|
|
326
330
|
window.FC.onLoad = function () {
|
|
327
331
|
window.FC.settings = window.FC.settings || {};
|
|
328
|
-
window.FC.settings.session_id = id;
|
|
332
|
+
window.FC.settings.session_id = sessionId || id;
|
|
329
333
|
window.FC.settings.cookiepath = cookiePath;
|
|
330
334
|
window.FC.settings.sitedomain = location.hostname;
|
|
331
335
|
};
|
|
@@ -378,6 +382,21 @@ export function lazyCheckoutLoaderJs(options: LazyCheckoutLoaderOptions): string
|
|
|
378
382
|
function arm() { setTimeout(start, ${LAZY_CHECKOUT_LOADER_IDLE_MS}); }
|
|
379
383
|
if (document.readyState === 'complete') arm();
|
|
380
384
|
else window.addEventListener('load', arm);
|
|
385
|
+
window.addEventListener(${literal(CART_ADDED_EVENT)}, function (event) {
|
|
386
|
+
var detail = event.detail || {};
|
|
387
|
+
if (detail.status !== 'added' || typeof detail.cartHref !== 'string') return;
|
|
388
|
+
var id = '';
|
|
389
|
+
try {
|
|
390
|
+
var href = new URL(detail.cartHref);
|
|
391
|
+
if (href.origin === cartOrigin) id = href.searchParams.get('fcsid') || '';
|
|
392
|
+
} catch (e) {}
|
|
393
|
+
if (!/^[a-z0-9]{10,64}$/.test(id) || id === sessionId) return;
|
|
394
|
+
sessionId = id;
|
|
395
|
+
var fc = window.FC;
|
|
396
|
+
if (fc && fc.session && typeof fc.session.reset === 'function' && fc.settings) {
|
|
397
|
+
try { fc.session.reset(id); } catch (e) {}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
381
400
|
function stampAnchor(anchor) {
|
|
382
401
|
if (!sessionId) return;
|
|
383
402
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|