@40rty/ams-sdk 0.5.9 → 0.5.11
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/dist/index.js +133 -20
- package/dist/types/sdk/src/host/host-modules.d.ts +12 -0
- package/dist/types/sdk/src/shell/conversation/use-conversation-page.d.ts +1 -1
- package/dist/types/sdk/src/verticals/commerce/cart/queued-discount-codes.d.ts +24 -0
- package/dist/types/sdk/src/verticals/commerce/index.d.ts +1 -0
- package/dist/types/spacestation/src/contracts/customer-account-session-header.d.ts +2 -0
- package/dist/types/spacestation/src/contracts/socket-ticket-param.d.ts +16 -0
- package/dist/types/spacestation/src/index.d.ts +2 -1
- package/dist/types/spacestation/src/space/connector.d.ts +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -76,6 +76,7 @@ __export(src_exports3, {
|
|
|
76
76
|
CONSENT_DISPOSITION: () => CONSENT_DISPOSITION,
|
|
77
77
|
CONTAINER_TYPES: () => CONTAINER_TYPES,
|
|
78
78
|
CONTINUATION_ENABLED: () => CONTINUATION_ENABLED,
|
|
79
|
+
CUSTOMER_ACCOUNT_SESSION_HEADER: () => CUSTOMER_ACCOUNT_SESSION_HEADER,
|
|
79
80
|
CanvasArrangementProvider: () => CanvasArrangementProvider,
|
|
80
81
|
CanvasMotionStyleProvider: () => CanvasMotionStyleProvider,
|
|
81
82
|
CanvasOutletProvider: () => CanvasOutletProvider,
|
|
@@ -216,6 +217,8 @@ __export(src_exports3, {
|
|
|
216
217
|
SDK_VERSION_PATTERN: () => SDK_VERSION_PATTERN,
|
|
217
218
|
SELECTION_ORIGIN_VISITOR: () => SELECTION_ORIGIN_VISITOR,
|
|
218
219
|
SIGNAL_PATCH_PREFIX: () => SIGNAL_PATCH_PREFIX,
|
|
220
|
+
SOCKET_BEARER_SUBPROTOCOL_PREFIX: () => SOCKET_BEARER_SUBPROTOCOL_PREFIX,
|
|
221
|
+
SOCKET_SUBPROTOCOL: () => SOCKET_SUBPROTOCOL,
|
|
219
222
|
SOCKET_TICKET_PARAM: () => SOCKET_TICKET_PARAM,
|
|
220
223
|
STRUCTURAL_BASELINE_CATALOG: () => STRUCTURAL_BASELINE_CATALOG,
|
|
221
224
|
STRUCTURAL_BASELINE_TYPES: () => STRUCTURAL_BASELINE_TYPES,
|
|
@@ -314,6 +317,7 @@ __export(src_exports3, {
|
|
|
314
317
|
arrivalToParams: () => arrivalToParams,
|
|
315
318
|
attachmentFailureOfStatus: () => attachmentFailureOfStatus,
|
|
316
319
|
bareComponentType: () => bareComponentType,
|
|
320
|
+
bearerFromSocketProtocols: () => bearerFromSocketProtocols,
|
|
317
321
|
buildBaseAttributesConfig: () => buildBaseAttributesConfig,
|
|
318
322
|
buildBucketLabelsConfig: () => buildBucketLabelsConfig,
|
|
319
323
|
buildComparisonRows: () => buildComparisonRows,
|
|
@@ -365,6 +369,7 @@ __export(src_exports3, {
|
|
|
365
369
|
createUnavailableProduct: () => createUnavailableProduct,
|
|
366
370
|
declaredSpaceLocaleOf: () => declaredSpaceLocaleOf,
|
|
367
371
|
defineEventKind: () => defineEventKind,
|
|
372
|
+
dequeueDiscountCode: () => dequeueDiscountCode,
|
|
368
373
|
derivePropsDoc: () => derivePropsDoc,
|
|
369
374
|
deriveSourceElement: () => deriveSourceElement,
|
|
370
375
|
deriveTurnChangeAnchor: () => deriveTurnChangeAnchor,
|
|
@@ -409,6 +414,7 @@ __export(src_exports3, {
|
|
|
409
414
|
isActiveDirective: () => isActiveDirective,
|
|
410
415
|
isAllowedAttachmentType: () => isAllowedAttachmentType,
|
|
411
416
|
isDegenerateLayout: () => isDegenerateLayout,
|
|
417
|
+
isDiscountCodeQueued: () => isDiscountCodeQueued,
|
|
412
418
|
isDraftSource: () => isDraftSource,
|
|
413
419
|
isElementUnfilled: () => isElementUnfilled,
|
|
414
420
|
isEmptyPropValue: () => isEmptyPropValue,
|
|
@@ -463,6 +469,7 @@ __export(src_exports3, {
|
|
|
463
469
|
prose: () => prose,
|
|
464
470
|
pruneFilterChips: () => pruneFilterChips,
|
|
465
471
|
publishClientState: () => publishClientState,
|
|
472
|
+
queueDiscountCode: () => queueDiscountCode,
|
|
466
473
|
raiseStanding: () => raiseStanding,
|
|
467
474
|
readBaseAttributesConfig: () => readBaseAttributesConfig,
|
|
468
475
|
readBucketLabelsConfig: () => readBucketLabelsConfig,
|
|
@@ -471,6 +478,7 @@ __export(src_exports3, {
|
|
|
471
478
|
readHosting: () => readHosting,
|
|
472
479
|
readOptionAxes: () => readOptionAxes,
|
|
473
480
|
readPdpCompanions: () => readPdpCompanions,
|
|
481
|
+
readQueuedDiscountCodes: () => readQueuedDiscountCodes,
|
|
474
482
|
recordCartActionFailure: () => recordCartActionFailure,
|
|
475
483
|
recordOptionSelections: () => recordOptionSelections,
|
|
476
484
|
recordVariantSelection: () => recordVariantSelection,
|
|
@@ -541,6 +549,7 @@ __export(src_exports3, {
|
|
|
541
549
|
settleArmedCheckoutHandoff: () => settleArmedCheckoutHandoff,
|
|
542
550
|
settledBlocks: () => settledBlocks,
|
|
543
551
|
settledCart: () => settledCart,
|
|
552
|
+
socketProtocolsFor: () => socketProtocolsFor,
|
|
544
553
|
spaceLocaleOf: () => spaceLocaleOf,
|
|
545
554
|
splitAnswer: () => splitAnswer,
|
|
546
555
|
splitSentences: () => splitSentences,
|
|
@@ -551,6 +560,7 @@ __export(src_exports3, {
|
|
|
551
560
|
subscribeServerState: () => subscribeServerState,
|
|
552
561
|
surfaceEmits: () => surfaceEmits,
|
|
553
562
|
surfaceSuppressionReason: () => surfaceSuppressionReason,
|
|
563
|
+
takeQueuedDiscountCodes: () => takeQueuedDiscountCodes,
|
|
554
564
|
text: () => text,
|
|
555
565
|
textDirectionOf: () => textDirectionOf,
|
|
556
566
|
threadRowAttrs: () => threadRowAttrs,
|
|
@@ -671,6 +681,7 @@ __export(src_exports3, {
|
|
|
671
681
|
useProducts: () => useProducts,
|
|
672
682
|
useProjection: () => useProjection,
|
|
673
683
|
usePromptComposer: () => usePromptComposer,
|
|
684
|
+
useQueuedDiscountCodes: () => useQueuedDiscountCodes,
|
|
674
685
|
useReasoning: () => useReasoning,
|
|
675
686
|
useReconcileDismissed: () => useReconcileDismissed,
|
|
676
687
|
useReconcileFlowSet: () => useReconcileFlowSet,
|
|
@@ -721,6 +732,7 @@ __export(src_exports3, {
|
|
|
721
732
|
wipeProfile: () => wipeProfile,
|
|
722
733
|
withCartActorOrigin: () => withCartActorOrigin,
|
|
723
734
|
withInteractionTracking: () => withInteractionTracking,
|
|
735
|
+
withQueuedDiscountCodes: () => withQueuedDiscountCodes,
|
|
724
736
|
withSignalTurn: () => withSignalTurn
|
|
725
737
|
});
|
|
726
738
|
|
|
@@ -1530,6 +1542,7 @@ __export(src_exports, {
|
|
|
1530
1542
|
COMPONENT_SOURCE_DEFAULT_THEME: () => COMPONENT_SOURCE_DEFAULT_THEME,
|
|
1531
1543
|
CONTAINER_TYPES: () => CONTAINER_TYPES,
|
|
1532
1544
|
CONTINUATION_ENABLED: () => CONTINUATION_ENABLED,
|
|
1545
|
+
CUSTOMER_ACCOUNT_SESSION_HEADER: () => CUSTOMER_ACCOUNT_SESSION_HEADER,
|
|
1533
1546
|
CartAddSignalPayloadSchema: () => CartAddSignalPayloadSchema,
|
|
1534
1547
|
CartRemoveSignalPayloadSchema: () => CartRemoveSignalPayloadSchema,
|
|
1535
1548
|
CartSnapshotLineSchema: () => CartSnapshotLineSchema,
|
|
@@ -1606,6 +1619,8 @@ __export(src_exports, {
|
|
|
1606
1619
|
SDK_VERSION_PATTERN: () => SDK_VERSION_PATTERN,
|
|
1607
1620
|
SELECTION_ORIGIN_VISITOR: () => SELECTION_ORIGIN_VISITOR,
|
|
1608
1621
|
SIGNAL_PATCH_PREFIX: () => SIGNAL_PATCH_PREFIX,
|
|
1622
|
+
SOCKET_BEARER_SUBPROTOCOL_PREFIX: () => SOCKET_BEARER_SUBPROTOCOL_PREFIX,
|
|
1623
|
+
SOCKET_SUBPROTOCOL: () => SOCKET_SUBPROTOCOL,
|
|
1609
1624
|
SOCKET_TICKET_PARAM: () => SOCKET_TICKET_PARAM,
|
|
1610
1625
|
STRUCTURAL_BASELINE_CATALOG: () => STRUCTURAL_BASELINE_CATALOG,
|
|
1611
1626
|
STRUCTURAL_BASELINE_TYPES: () => STRUCTURAL_BASELINE_TYPES,
|
|
@@ -1679,6 +1694,7 @@ __export(src_exports, {
|
|
|
1679
1694
|
arrivalToParams: () => arrivalToParams,
|
|
1680
1695
|
attachmentFailureOfStatus: () => attachmentFailureOfStatus,
|
|
1681
1696
|
bareComponentType: () => bareComponentType,
|
|
1697
|
+
bearerFromSocketProtocols: () => bearerFromSocketProtocols,
|
|
1682
1698
|
canonicalOptionValue: () => canonicalOptionValue,
|
|
1683
1699
|
carriesShapeToken: () => carriesShapeToken,
|
|
1684
1700
|
catalogFromWire: () => catalogFromWire,
|
|
@@ -1748,6 +1764,7 @@ __export(src_exports, {
|
|
|
1748
1764
|
sdkShimsFor: () => sdkShimsFor,
|
|
1749
1765
|
sdkWindowProblem: () => sdkWindowProblem,
|
|
1750
1766
|
settledBlocks: () => settledBlocks,
|
|
1767
|
+
socketProtocolsFor: () => socketProtocolsFor,
|
|
1751
1768
|
spaceLocaleOf: () => spaceLocaleOf,
|
|
1752
1769
|
splitSentences: () => splitSentences,
|
|
1753
1770
|
stateSnapshotSignal: () => stateSnapshotSignal,
|
|
@@ -3968,6 +3985,25 @@ function arrivalToParams(arrival, into) {
|
|
|
3968
3985
|
|
|
3969
3986
|
// ../spacestation/src/contracts/socket-ticket-param.ts
|
|
3970
3987
|
var SOCKET_TICKET_PARAM = "ticket";
|
|
3988
|
+
var SOCKET_SUBPROTOCOL = "fourty.v1";
|
|
3989
|
+
var SOCKET_BEARER_SUBPROTOCOL_PREFIX = "fourty.bearer.";
|
|
3990
|
+
function socketProtocolsFor(bearer) {
|
|
3991
|
+
return [SOCKET_SUBPROTOCOL, `${SOCKET_BEARER_SUBPROTOCOL_PREFIX}${bearer}`];
|
|
3992
|
+
}
|
|
3993
|
+
function bearerFromSocketProtocols(header) {
|
|
3994
|
+
if (header === void 0) return void 0;
|
|
3995
|
+
for (const offered of header.split(",")) {
|
|
3996
|
+
const protocol = offered.trim();
|
|
3997
|
+
if (protocol.startsWith(SOCKET_BEARER_SUBPROTOCOL_PREFIX)) {
|
|
3998
|
+
const bearer = protocol.slice(SOCKET_BEARER_SUBPROTOCOL_PREFIX.length);
|
|
3999
|
+
if (bearer.length > 0) return bearer;
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
return void 0;
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
// ../spacestation/src/contracts/customer-account-session-header.ts
|
|
4006
|
+
var CUSTOMER_ACCOUNT_SESSION_HEADER = "x-fourty-session";
|
|
3971
4007
|
|
|
3972
4008
|
// ../spacestation/src/contracts/wire-protocol.ts
|
|
3973
4009
|
var WIRE_PROTOCOL_VERSION = 1;
|
|
@@ -7055,6 +7091,7 @@ function openWebStorage(kind) {
|
|
|
7055
7091
|
let adapter;
|
|
7056
7092
|
try {
|
|
7057
7093
|
const storage3 = window[kind];
|
|
7094
|
+
if (storage3 === null) throw new Error(`window.${kind} is null (DOM storage disabled)`);
|
|
7058
7095
|
adapter = {
|
|
7059
7096
|
get: (key) => storage3.getItem(key),
|
|
7060
7097
|
set: (key, value) => storage3.setItem(key, value),
|
|
@@ -10029,10 +10066,10 @@ var ComponentErrorBoundary = class extends React36.Component {
|
|
|
10029
10066
|
};
|
|
10030
10067
|
|
|
10031
10068
|
// src/interaction/normalize-signals.ts
|
|
10032
|
-
function normalizeSignals(
|
|
10069
|
+
function normalizeSignals(queued2, prompt) {
|
|
10033
10070
|
const latestLayoutUpdate = /* @__PURE__ */ new Map();
|
|
10034
10071
|
const rest = [];
|
|
10035
|
-
for (const signal of
|
|
10072
|
+
for (const signal of queued2) {
|
|
10036
10073
|
if (signal.type === "layout_update") {
|
|
10037
10074
|
latestLayoutUpdate.set(signal.type, signal);
|
|
10038
10075
|
} else {
|
|
@@ -10586,17 +10623,17 @@ function SpacefrontPreviewProvider({ scene, onSend, children }) {
|
|
|
10586
10623
|
onSendRef.current = onSend;
|
|
10587
10624
|
const draft = React39.useMemo(() => {
|
|
10588
10625
|
let text2 = "";
|
|
10589
|
-
const
|
|
10626
|
+
const listeners13 = /* @__PURE__ */ new Set();
|
|
10590
10627
|
return {
|
|
10591
10628
|
store: { subscribe: (fn) => {
|
|
10592
|
-
|
|
10629
|
+
listeners13.add(fn);
|
|
10593
10630
|
return () => {
|
|
10594
|
-
|
|
10631
|
+
listeners13.delete(fn);
|
|
10595
10632
|
};
|
|
10596
10633
|
}, get: () => text2 },
|
|
10597
10634
|
set: (next) => {
|
|
10598
10635
|
text2 = next;
|
|
10599
|
-
|
|
10636
|
+
listeners13.forEach((fn) => fn());
|
|
10600
10637
|
}
|
|
10601
10638
|
};
|
|
10602
10639
|
}, []);
|
|
@@ -10695,12 +10732,14 @@ __export(commerce_exports, {
|
|
|
10695
10732
|
clearVariantChoice: () => clearVariantChoice,
|
|
10696
10733
|
closeCartDrawer: () => closeCartDrawer,
|
|
10697
10734
|
consumeArmedCheckoutHandoff: () => consumeArmedCheckoutHandoff,
|
|
10735
|
+
dequeueDiscountCode: () => dequeueDiscountCode,
|
|
10698
10736
|
disarmCheckoutHandoff: () => disarmCheckoutHandoff,
|
|
10699
10737
|
formatPrice: () => formatPrice,
|
|
10700
10738
|
formatProductPrice: () => formatProductPrice,
|
|
10701
10739
|
formatVariantValue: () => formatVariantValue,
|
|
10702
10740
|
getOptionSelections: () => getOptionSelections,
|
|
10703
10741
|
getVariantSelection: () => getVariantSelection,
|
|
10742
|
+
isDiscountCodeQueued: () => isDiscountCodeQueued,
|
|
10704
10743
|
isFunnelStep: () => isFunnelStep,
|
|
10705
10744
|
isOnSale: () => isOnSale,
|
|
10706
10745
|
isPendingCartLine: () => isPendingCartLine,
|
|
@@ -10714,8 +10753,10 @@ __export(commerce_exports, {
|
|
|
10714
10753
|
pickProductCardAction: () => pickProductCardAction,
|
|
10715
10754
|
preselectFromFacts: () => preselectFromFacts,
|
|
10716
10755
|
pruneFilterChips: () => pruneFilterChips,
|
|
10756
|
+
queueDiscountCode: () => queueDiscountCode,
|
|
10717
10757
|
readCartActionFailures: () => readCartActionFailures,
|
|
10718
10758
|
readCheckoutHandoff: () => readCheckoutHandoff,
|
|
10759
|
+
readQueuedDiscountCodes: () => readQueuedDiscountCodes,
|
|
10719
10760
|
recordCartActionFailure: () => recordCartActionFailure,
|
|
10720
10761
|
recordOptionSelections: () => recordOptionSelections,
|
|
10721
10762
|
recordVariantSelection: () => recordVariantSelection,
|
|
@@ -10726,6 +10767,7 @@ __export(commerce_exports, {
|
|
|
10726
10767
|
resolveSwatchColor: () => resolveSwatchColor,
|
|
10727
10768
|
settleArmedCheckoutHandoff: () => settleArmedCheckoutHandoff,
|
|
10728
10769
|
settledCart: () => settledCart,
|
|
10770
|
+
takeQueuedDiscountCodes: () => takeQueuedDiscountCodes,
|
|
10729
10771
|
toggleCartDrawer: () => toggleCartDrawer,
|
|
10730
10772
|
useAddToCart: () => useAddToCart,
|
|
10731
10773
|
useCart: () => useCart,
|
|
@@ -10750,12 +10792,14 @@ __export(commerce_exports, {
|
|
|
10750
10792
|
useProductGridFilter: () => useProductGridFilter,
|
|
10751
10793
|
useProductReviews: () => useProductReviews,
|
|
10752
10794
|
useProducts: () => useProducts,
|
|
10795
|
+
useQueuedDiscountCodes: () => useQueuedDiscountCodes,
|
|
10753
10796
|
useSafeCart: () => useSafeCart,
|
|
10754
10797
|
useToggleWishlist: () => useToggleWishlist,
|
|
10755
10798
|
useVariantSelections: () => useVariantSelections,
|
|
10756
10799
|
useWishlist: () => useWishlist,
|
|
10757
10800
|
useWishlistDrawer: () => useWishlistDrawer,
|
|
10758
|
-
variantForSelections: () => variantForSelections
|
|
10801
|
+
variantForSelections: () => variantForSelections,
|
|
10802
|
+
withQueuedDiscountCodes: () => withQueuedDiscountCodes
|
|
10759
10803
|
});
|
|
10760
10804
|
|
|
10761
10805
|
// src/verticals/commerce/chip-relevance.ts
|
|
@@ -11612,6 +11656,62 @@ function useCartDrawer() {
|
|
|
11612
11656
|
|
|
11613
11657
|
// src/verticals/commerce/cart/use-cart-view.ts
|
|
11614
11658
|
import React40 from "react";
|
|
11659
|
+
|
|
11660
|
+
// src/verticals/commerce/cart/queued-discount-codes.ts
|
|
11661
|
+
import { useSyncExternalStore as useSyncExternalStore11 } from "react";
|
|
11662
|
+
var queued = [];
|
|
11663
|
+
var listeners11 = /* @__PURE__ */ new Set();
|
|
11664
|
+
function notify11() {
|
|
11665
|
+
for (const listener of listeners11) listener();
|
|
11666
|
+
}
|
|
11667
|
+
function withQueuedDiscountCodes(cartCodes, held) {
|
|
11668
|
+
const extra = held.filter((h) => !cartCodes.some((c) => sameCode(c.code, h)));
|
|
11669
|
+
return [...cartCodes, ...extra.map((code) => ({ code, applicable: true }))];
|
|
11670
|
+
}
|
|
11671
|
+
function isDiscountCodeQueued(code) {
|
|
11672
|
+
return queued.some((c) => sameCode(c, code));
|
|
11673
|
+
}
|
|
11674
|
+
function dequeueDiscountCode(code) {
|
|
11675
|
+
const kept = queued.filter((c) => !sameCode(c, code));
|
|
11676
|
+
if (kept.length === queued.length) return;
|
|
11677
|
+
queued = kept;
|
|
11678
|
+
notify11();
|
|
11679
|
+
}
|
|
11680
|
+
function sameCode(a, b) {
|
|
11681
|
+
return a.toUpperCase() === b.toUpperCase();
|
|
11682
|
+
}
|
|
11683
|
+
function queueDiscountCode(code) {
|
|
11684
|
+
if (queued.some((c) => sameCode(c, code))) return;
|
|
11685
|
+
queued = [...queued, code];
|
|
11686
|
+
notify11();
|
|
11687
|
+
}
|
|
11688
|
+
function takeQueuedDiscountCodes() {
|
|
11689
|
+
const taken = queued;
|
|
11690
|
+
if (taken.length === 0) return taken;
|
|
11691
|
+
queued = [];
|
|
11692
|
+
notify11();
|
|
11693
|
+
return taken;
|
|
11694
|
+
}
|
|
11695
|
+
function readQueuedDiscountCodes() {
|
|
11696
|
+
return queued;
|
|
11697
|
+
}
|
|
11698
|
+
function subscribe9(listener) {
|
|
11699
|
+
listeners11.add(listener);
|
|
11700
|
+
return () => {
|
|
11701
|
+
listeners11.delete(listener);
|
|
11702
|
+
};
|
|
11703
|
+
}
|
|
11704
|
+
var NONE = [];
|
|
11705
|
+
function useQueuedDiscountCodes() {
|
|
11706
|
+
return useSyncExternalStore11(subscribe9, readQueuedDiscountCodes, () => NONE);
|
|
11707
|
+
}
|
|
11708
|
+
registerSessionScopedClear(() => {
|
|
11709
|
+
if (queued.length === 0) return;
|
|
11710
|
+
queued = [];
|
|
11711
|
+
notify11();
|
|
11712
|
+
});
|
|
11713
|
+
|
|
11714
|
+
// src/verticals/commerce/cart/use-cart-view.ts
|
|
11615
11715
|
function useCartView(cart, onCheckout) {
|
|
11616
11716
|
const analytics = useOptionalAnalyticsSink();
|
|
11617
11717
|
const [exitPending, setExitPending] = React40.useState(null);
|
|
@@ -11620,7 +11720,8 @@ function useCartView(cart, onCheckout) {
|
|
|
11620
11720
|
const totalsPending = lines.some((l) => isPendingCartLine(l));
|
|
11621
11721
|
const subtotal = cart === null ? 0 : cart.subtotal.amount;
|
|
11622
11722
|
const currency = cart === null ? "USD" : cart.subtotal.currencyCode;
|
|
11623
|
-
const
|
|
11723
|
+
const heldCodes = useQueuedDiscountCodes();
|
|
11724
|
+
const discountCodes = withQueuedDiscountCodes(cart === null ? [] : cart.discountCodes, heldCodes);
|
|
11624
11725
|
const backendTotal = cart !== null && cart.total !== void 0 ? cart.total.amount : void 0;
|
|
11625
11726
|
const discountAmount = backendTotal !== void 0 && backendTotal < subtotal ? subtotal - backendTotal : 0;
|
|
11626
11727
|
const effectiveTotal = backendTotal !== void 0 ? backendTotal : subtotal;
|
|
@@ -11685,13 +11786,13 @@ function useCartView(cart, onCheckout) {
|
|
|
11685
11786
|
}
|
|
11686
11787
|
|
|
11687
11788
|
// src/verticals/commerce/cart/cart-action-failures.ts
|
|
11688
|
-
import { useMemo as useMemo16, useSyncExternalStore as
|
|
11789
|
+
import { useMemo as useMemo16, useSyncExternalStore as useSyncExternalStore12 } from "react";
|
|
11689
11790
|
var FAILURE_TTL_MS = 2 * 6e4;
|
|
11690
11791
|
var FAILURE_CAP = 5;
|
|
11691
11792
|
var failures = [];
|
|
11692
|
-
var
|
|
11693
|
-
function
|
|
11694
|
-
for (const listener of
|
|
11793
|
+
var listeners12 = /* @__PURE__ */ new Set();
|
|
11794
|
+
function notify12() {
|
|
11795
|
+
for (const listener of listeners12) listener();
|
|
11695
11796
|
}
|
|
11696
11797
|
function pruneExpired(now) {
|
|
11697
11798
|
const kept = failures.filter((f) => now - f.at <= FAILURE_TTL_MS);
|
|
@@ -11709,13 +11810,13 @@ function recordCartActionFailure(action, subject, reason) {
|
|
|
11709
11810
|
pruneExpired(now);
|
|
11710
11811
|
const rest = failures.filter((f) => !(f.action === action && sameSubject(f, subject)));
|
|
11711
11812
|
failures = [...rest, { action, productId: subject.productId, code: subject.code, reason, at: now }].slice(-FAILURE_CAP);
|
|
11712
|
-
|
|
11813
|
+
notify12();
|
|
11713
11814
|
}
|
|
11714
11815
|
function clearCartActionFailures(subject) {
|
|
11715
11816
|
const kept = failures.filter((f) => !sameSubject(f, subject));
|
|
11716
11817
|
if (kept.length === failures.length) return;
|
|
11717
11818
|
failures = kept;
|
|
11718
|
-
|
|
11819
|
+
notify12();
|
|
11719
11820
|
}
|
|
11720
11821
|
function snapshot() {
|
|
11721
11822
|
return failures;
|
|
@@ -11724,15 +11825,15 @@ function readCartActionFailures() {
|
|
|
11724
11825
|
pruneExpired(Date.now());
|
|
11725
11826
|
return failures;
|
|
11726
11827
|
}
|
|
11727
|
-
function
|
|
11728
|
-
|
|
11828
|
+
function subscribe10(listener) {
|
|
11829
|
+
listeners12.add(listener);
|
|
11729
11830
|
return () => {
|
|
11730
|
-
|
|
11831
|
+
listeners12.delete(listener);
|
|
11731
11832
|
};
|
|
11732
11833
|
}
|
|
11733
11834
|
var NO_FAILURES = [];
|
|
11734
11835
|
function useCartActionFailures() {
|
|
11735
|
-
return
|
|
11836
|
+
return useSyncExternalStore12(subscribe10, snapshot, () => NO_FAILURES);
|
|
11736
11837
|
}
|
|
11737
11838
|
function useCartActionFailuresFor(productIdsInCart) {
|
|
11738
11839
|
const all = useCartActionFailures();
|
|
@@ -11745,7 +11846,7 @@ function useCartActionFailuresFor(productIdsInCart) {
|
|
|
11745
11846
|
registerSessionScopedClear(() => {
|
|
11746
11847
|
if (failures.length === 0) return;
|
|
11747
11848
|
failures = [];
|
|
11748
|
-
|
|
11849
|
+
notify12();
|
|
11749
11850
|
});
|
|
11750
11851
|
|
|
11751
11852
|
// src/verticals/commerce/cart/use-cart-line-row.ts
|
|
@@ -12533,7 +12634,7 @@ function useContentActions() {
|
|
|
12533
12634
|
import { useEffect as useEffect19, useState as useState18 } from "react";
|
|
12534
12635
|
|
|
12535
12636
|
// package.json
|
|
12536
|
-
var version = "0.5.
|
|
12637
|
+
var version = "0.5.11";
|
|
12537
12638
|
|
|
12538
12639
|
// src/host/host-modules.ts
|
|
12539
12640
|
import * as react from "react";
|
|
@@ -12688,6 +12789,7 @@ export {
|
|
|
12688
12789
|
CONSENT_DISPOSITION,
|
|
12689
12790
|
CONTAINER_TYPES,
|
|
12690
12791
|
CONTINUATION_ENABLED,
|
|
12792
|
+
CUSTOMER_ACCOUNT_SESSION_HEADER,
|
|
12691
12793
|
CanvasArrangementProvider,
|
|
12692
12794
|
CanvasMotionStyleProvider,
|
|
12693
12795
|
CanvasOutletProvider,
|
|
@@ -12830,6 +12932,8 @@ export {
|
|
|
12830
12932
|
SDK_VERSION_PATTERN,
|
|
12831
12933
|
SELECTION_ORIGIN_VISITOR,
|
|
12832
12934
|
SIGNAL_PATCH_PREFIX,
|
|
12935
|
+
SOCKET_BEARER_SUBPROTOCOL_PREFIX,
|
|
12936
|
+
SOCKET_SUBPROTOCOL,
|
|
12833
12937
|
SOCKET_TICKET_PARAM,
|
|
12834
12938
|
STRUCTURAL_BASELINE_CATALOG,
|
|
12835
12939
|
STRUCTURAL_BASELINE_TYPES,
|
|
@@ -12929,6 +13033,7 @@ export {
|
|
|
12929
13033
|
arrivalToParams,
|
|
12930
13034
|
attachmentFailureOfStatus,
|
|
12931
13035
|
bareComponentType,
|
|
13036
|
+
bearerFromSocketProtocols,
|
|
12932
13037
|
buildBaseAttributesConfig,
|
|
12933
13038
|
buildBucketLabelsConfig,
|
|
12934
13039
|
buildComparisonRows,
|
|
@@ -12980,6 +13085,7 @@ export {
|
|
|
12980
13085
|
createUnavailableProduct,
|
|
12981
13086
|
declaredSpaceLocaleOf,
|
|
12982
13087
|
defineEventKind,
|
|
13088
|
+
dequeueDiscountCode,
|
|
12983
13089
|
derivePropsDoc,
|
|
12984
13090
|
deriveSourceElement,
|
|
12985
13091
|
deriveTurnChangeAnchor,
|
|
@@ -13024,6 +13130,7 @@ export {
|
|
|
13024
13130
|
isActiveDirective,
|
|
13025
13131
|
isAllowedAttachmentType,
|
|
13026
13132
|
isDegenerateLayout,
|
|
13133
|
+
isDiscountCodeQueued,
|
|
13027
13134
|
isDraftSource,
|
|
13028
13135
|
isElementUnfilled,
|
|
13029
13136
|
isEmptyPropValue,
|
|
@@ -13079,6 +13186,7 @@ export {
|
|
|
13079
13186
|
prose,
|
|
13080
13187
|
pruneFilterChips,
|
|
13081
13188
|
publishClientState,
|
|
13189
|
+
queueDiscountCode,
|
|
13082
13190
|
raiseStanding,
|
|
13083
13191
|
readBaseAttributesConfig,
|
|
13084
13192
|
readBucketLabelsConfig,
|
|
@@ -13087,6 +13195,7 @@ export {
|
|
|
13087
13195
|
readHosting,
|
|
13088
13196
|
readOptionAxes,
|
|
13089
13197
|
readPdpCompanions,
|
|
13198
|
+
readQueuedDiscountCodes,
|
|
13090
13199
|
recordCartActionFailure,
|
|
13091
13200
|
recordOptionSelections,
|
|
13092
13201
|
recordVariantSelection,
|
|
@@ -13157,6 +13266,7 @@ export {
|
|
|
13157
13266
|
settleArmedCheckoutHandoff,
|
|
13158
13267
|
settledBlocks,
|
|
13159
13268
|
settledCart,
|
|
13269
|
+
socketProtocolsFor,
|
|
13160
13270
|
spaceLocaleOf,
|
|
13161
13271
|
splitAnswer,
|
|
13162
13272
|
splitSentences,
|
|
@@ -13167,6 +13277,7 @@ export {
|
|
|
13167
13277
|
subscribeServerState,
|
|
13168
13278
|
surfaceEmits,
|
|
13169
13279
|
surfaceSuppressionReason,
|
|
13280
|
+
takeQueuedDiscountCodes,
|
|
13170
13281
|
text,
|
|
13171
13282
|
textDirectionOf,
|
|
13172
13283
|
threadRowAttrs,
|
|
@@ -13287,6 +13398,7 @@ export {
|
|
|
13287
13398
|
useProducts,
|
|
13288
13399
|
useProjection,
|
|
13289
13400
|
usePromptComposer,
|
|
13401
|
+
useQueuedDiscountCodes,
|
|
13290
13402
|
useReasoning,
|
|
13291
13403
|
useReconcileDismissed,
|
|
13292
13404
|
useReconcileFlowSet,
|
|
@@ -13337,6 +13449,7 @@ export {
|
|
|
13337
13449
|
wipeProfile,
|
|
13338
13450
|
withCartActorOrigin,
|
|
13339
13451
|
withInteractionTracking,
|
|
13452
|
+
withQueuedDiscountCodes,
|
|
13340
13453
|
withSignalTurn,
|
|
13341
13454
|
z51 as z
|
|
13342
13455
|
};
|
|
@@ -378,6 +378,13 @@ export declare const HOST_MODULES: {
|
|
|
378
378
|
clearCartActionFailures: typeof sdk.clearCartActionFailures;
|
|
379
379
|
useCartActionFailures: typeof sdk.useCartActionFailures;
|
|
380
380
|
useCartActionFailuresFor: typeof sdk.useCartActionFailuresFor;
|
|
381
|
+
queueDiscountCode: typeof sdk.queueDiscountCode;
|
|
382
|
+
takeQueuedDiscountCodes: typeof sdk.takeQueuedDiscountCodes;
|
|
383
|
+
readQueuedDiscountCodes: typeof sdk.readQueuedDiscountCodes;
|
|
384
|
+
withQueuedDiscountCodes: typeof sdk.withQueuedDiscountCodes;
|
|
385
|
+
isDiscountCodeQueued: typeof sdk.isDiscountCodeQueued;
|
|
386
|
+
dequeueDiscountCode: typeof sdk.dequeueDiscountCode;
|
|
387
|
+
useQueuedDiscountCodes: typeof sdk.useQueuedDiscountCodes;
|
|
381
388
|
useCartLineRow: typeof sdk.useCartLineRow;
|
|
382
389
|
openCartDrawer: typeof sdk.openCartDrawer;
|
|
383
390
|
openCartDrawerFocusedOn: typeof sdk.openCartDrawerFocusedOn;
|
|
@@ -2454,6 +2461,11 @@ export declare const HOST_MODULES: {
|
|
|
2454
2461
|
arrivalFromParams: typeof spacestation.arrivalFromParams;
|
|
2455
2462
|
arrivalToParams: typeof spacestation.arrivalToParams;
|
|
2456
2463
|
SOCKET_TICKET_PARAM: "ticket";
|
|
2464
|
+
SOCKET_SUBPROTOCOL: "fourty.v1";
|
|
2465
|
+
SOCKET_BEARER_SUBPROTOCOL_PREFIX: "fourty.bearer.";
|
|
2466
|
+
socketProtocolsFor: typeof spacestation.socketProtocolsFor;
|
|
2467
|
+
bearerFromSocketProtocols: typeof spacestation.bearerFromSocketProtocols;
|
|
2468
|
+
CUSTOMER_ACCOUNT_SESSION_HEADER: "x-fourty-session";
|
|
2457
2469
|
WIRE_PROTOCOL_VERSION: 1;
|
|
2458
2470
|
MIN_WIRE_PROTOCOL_VERSION: 1;
|
|
2459
2471
|
WIRE_PROTOCOL_PARAM: "protocol";
|
|
@@ -65,7 +65,7 @@ export interface ConversationPage {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* The conversation as a PAGE — everything a shell needs to make each turn a
|
|
68
|
-
* page of its own (
|
|
68
|
+
* page of its own (conversational UI): which turn is shown and where it
|
|
69
69
|
* is in its life, the trail back through every page, the closing question
|
|
70
70
|
* and how to answer it, and the agent's presence. One hook; no markup — the
|
|
71
71
|
* brand draws every pixel.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The codes a cart surface shows: the cart's own, then any still held for an
|
|
3
|
+
* empty bag. A held code reads as applied — the visitor asked for it and it
|
|
4
|
+
* WILL be applied the moment an item lands, so the surface agrees with what the
|
|
5
|
+
* agent told them. Applicability is the backend's verdict and arrives with the
|
|
6
|
+
* real write; until then there is nothing to contradict.
|
|
7
|
+
*/
|
|
8
|
+
export declare function withQueuedDiscountCodes(cartCodes: readonly {
|
|
9
|
+
code: string;
|
|
10
|
+
applicable: boolean;
|
|
11
|
+
}[], held: readonly string[]): {
|
|
12
|
+
code: string;
|
|
13
|
+
applicable: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
export declare function isDiscountCodeQueued(code: string): boolean;
|
|
16
|
+
/** Drop one held code (the visitor removed it before it was ever applied). */
|
|
17
|
+
export declare function dequeueDiscountCode(code: string): void;
|
|
18
|
+
/** Hold a code until the cart can take it. Re-queueing the same code is a no-op. */
|
|
19
|
+
export declare function queueDiscountCode(code: string): void;
|
|
20
|
+
/** Remove and return every held code — the engine's flush, once a cart exists. */
|
|
21
|
+
export declare function takeQueuedDiscountCodes(): readonly string[];
|
|
22
|
+
export declare function readQueuedDiscountCodes(): readonly string[];
|
|
23
|
+
/** Reactive read — the codes waiting for an item. */
|
|
24
|
+
export declare function useQueuedDiscountCodes(): readonly string[];
|
|
@@ -16,6 +16,7 @@ export { useCartDrawer } from './cart/use-cart-drawer';
|
|
|
16
16
|
export { useCartView, type CartViewModel, type ExitPending } from './cart/use-cart-view';
|
|
17
17
|
export { useSafeCart, type SafeCart } from './cart/use-safe-cart';
|
|
18
18
|
export { recordCartActionFailure, readCartActionFailures, clearCartActionFailures, useCartActionFailures, useCartActionFailuresFor, type CartActionFailure, type CartActionSubject, } from './cart/cart-action-failures';
|
|
19
|
+
export { queueDiscountCode, takeQueuedDiscountCodes, readQueuedDiscountCodes, withQueuedDiscountCodes, isDiscountCodeQueued, dequeueDiscountCode, useQueuedDiscountCodes, } from './cart/queued-discount-codes';
|
|
19
20
|
export { useCartLineRow, type CartLineRowState, type CartLineInteraction, } from './cart/use-cart-line-row';
|
|
20
21
|
export { openCartDrawer, openCartDrawerFocusedOn, closeCartDrawer, toggleCartDrawer, useCartDrawerOpen, useCartDrawerFocus, type CartDrawerFocus, } from './cart/cart-drawer-store';
|
|
21
22
|
export { armCheckoutHandoff, refuseCheckoutHandoff, consumeArmedCheckoutHandoff, disarmCheckoutHandoff, settleArmedCheckoutHandoff, recordVisitorCheckoutExit, readCheckoutHandoff, useCheckoutHandoff, checkoutHandoffReasonFor, CHECKOUT_BLOCKED_REASON, CHECKOUT_NO_URL_REASON, CHECKOUT_EMPTY_CART_REASON, CHECKOUT_NO_LINK_REASON, type CheckoutHandoffOutcome, type CheckoutHandoffOrigin, type CheckoutHandoffState, } from './checkout/checkout-handoff-store';
|
|
@@ -7,3 +7,19 @@
|
|
|
7
7
|
* single-purpose and expires in seconds (`@fourty/platform/socket-ticket`).
|
|
8
8
|
*/
|
|
9
9
|
export declare const SOCKET_TICKET_PARAM = "ticket";
|
|
10
|
+
/**
|
|
11
|
+
* How a socket carries a BEARER — long-lived, so never on the URL: Cloud Run's
|
|
12
|
+
* request log records every full URL, whatever the app does.
|
|
13
|
+
*
|
|
14
|
+
* A browser WebSocket can set exactly one handshake header,
|
|
15
|
+
* `Sec-WebSocket-Protocol`, by offering subprotocols. The dialer offers
|
|
16
|
+
* `SOCKET_SUBPROTOCOL` first — the one the server echoes (`ws` selects the first
|
|
17
|
+
* offer), so the bearer never comes back in the response — then the bearer under
|
|
18
|
+
* `SOCKET_BEARER_SUBPROTOCOL_PREFIX`. A JWT's alphabet is all legal here.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SOCKET_SUBPROTOCOL = "fourty.v1";
|
|
21
|
+
export declare const SOCKET_BEARER_SUBPROTOCOL_PREFIX = "fourty.bearer.";
|
|
22
|
+
/** The second argument of `new WebSocket(url, …)` for a dial holding `bearer`. */
|
|
23
|
+
export declare function socketProtocolsFor(bearer: string): string[];
|
|
24
|
+
/** The bearer out of a `Sec-WebSocket-Protocol` header, if it offers one. */
|
|
25
|
+
export declare function bearerFromSocketProtocols(header: string | undefined): string | undefined;
|
|
@@ -43,7 +43,8 @@ export { MAX_ATTACHMENT_MB, AttachmentUploadError, attachmentFailureOfStatus, ty
|
|
|
43
43
|
export { ENTRY_CONTEXT_MAX_VALUE_CHARS, ENTRY_CONTEXT_MAX_KEYS, ENTRY_CONTEXT_MAX_NAMESPACES, ENTRY_CONTEXT_MAX_NAME_CHARS, EntryContextValueSchema, EntryContextNamespaceSchema, EntryContextSchema, type EntryContext, } from './contracts/entry-context';
|
|
44
44
|
export { ARRIVAL_MAX_VALUE_CHARS, SURFACES, SurfaceSchema, type Surface, CLICK_ID_KINDS, ClickIdKindSchema, type ClickIdKind, VISITOR_ID_DURABILITIES, VisitorIdDurabilitySchema, type VisitorIdDurability, TRAFFIC_BUCKETS, TrafficBucketSchema, type TrafficBucket, SessionArrivalSchema, type SessionArrival, type RecordedSessionArrival, } from './contracts/session-arrival';
|
|
45
45
|
export { ARRIVAL_PARAMS, REFERRER_HOST_PARAM, arrivalFromParams, arrivalToParams, type ArrivalEvidence, } from './contracts/session-arrival-params';
|
|
46
|
-
export { SOCKET_TICKET_PARAM } from './contracts/socket-ticket-param';
|
|
46
|
+
export { SOCKET_TICKET_PARAM, SOCKET_SUBPROTOCOL, SOCKET_BEARER_SUBPROTOCOL_PREFIX, socketProtocolsFor, bearerFromSocketProtocols, } from './contracts/socket-ticket-param';
|
|
47
|
+
export { CUSTOMER_ACCOUNT_SESSION_HEADER } from './contracts/customer-account-session-header';
|
|
47
48
|
export { WIRE_PROTOCOL_VERSION, MIN_WIRE_PROTOCOL_VERSION, WIRE_PROTOCOL_PARAM, WIRE_PROTOCOL_UNSUPPORTED_CLOSE, } from './contracts/wire-protocol';
|
|
48
49
|
export { type AttributeDef, type AttributeRegistry, type AttributeScopeBucket, type AttributeScopeConfig, AttributeDefSchema, AttributeScopeBucketSchema, AttributeScopeConfigSchema, EXTRAS_PREFIX, } from './catalog/attribute-registry';
|
|
49
50
|
export { resolveScope, normalizeAttributeField, scopedAttributeKey, scopeOfAttributeKey, } from './catalog/attribute-scope';
|
|
@@ -68,8 +68,9 @@ export interface ConnectorDescriptor {
|
|
|
68
68
|
*/
|
|
69
69
|
browserConfig: readonly string[];
|
|
70
70
|
/**
|
|
71
|
-
* The `config` keys that are server-only credentials. Each is held
|
|
72
|
-
*
|
|
71
|
+
* The `config` keys that are server-only credentials. Each is held
|
|
72
|
+
* encrypted by the api (`connector_secret_ciphertexts`), keyed by space,
|
|
73
|
+
* platform and key.
|
|
73
74
|
* Never also in `browserConfig`.
|
|
74
75
|
*/
|
|
75
76
|
vaultedConfig: readonly string[];
|