@cohostvip/cohost-react 0.1.9 → 0.1.10
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/context/CohostStartCheckoutContext.d.ts +5 -0
- package/dist/context/CohostStartCheckoutContext.d.ts.map +1 -0
- package/dist/context/CohostStartCheckoutContext.js +2 -0
- package/dist/hooks/useCohostStartCheckout.d.ts +1 -0
- package/dist/hooks/useCohostStartCheckout.d.ts.map +1 -0
- package/dist/hooks/useCohostStartCheckout.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/provider/CohostStartCheckoutProvider.d.ts +6 -0
- package/dist/provider/CohostStartCheckoutProvider.d.ts.map +1 -0
- package/dist/provider/CohostStartCheckoutProvider.js +29 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CohostStartCheckoutContext.d.ts","sourceRoot":"","sources":["../../src/context/CohostStartCheckoutContext.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B;eACxB,MAAM;sBACC,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;cACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=useCohostStartCheckout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCohostStartCheckout.d.ts","sourceRoot":"","sources":["../../src/hooks/useCohostStartCheckout.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { CohostCheckoutProvider, CohostCheckoutContext, useCohostCheckout } from
|
|
|
2
2
|
export { CohostEventProvider, useCohostEvent } from './context/CohostEventContext';
|
|
3
3
|
export { CohostProvider, type CohostProviderProps } from './context/CohostContext';
|
|
4
4
|
export { PaymentElementProvider, usePaymentElement } from './context/PaymentElementContext';
|
|
5
|
+
export { CohostStartCheckoutProvider } from './provider/CohostStartCheckoutProvider';
|
|
5
6
|
export { CreditCardInformation } from './lib/tokenizers/types';
|
|
6
7
|
export { useCohost } from './hooks/useCohost';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { CohostCheckoutProvider, CohostCheckoutContext, useCohostCheckout } from
|
|
|
2
2
|
export { CohostEventProvider, useCohostEvent } from './context/CohostEventContext';
|
|
3
3
|
export { CohostProvider } from './context/CohostContext';
|
|
4
4
|
export { PaymentElementProvider, usePaymentElement } from './context/PaymentElementContext';
|
|
5
|
+
export { CohostStartCheckoutProvider } from './provider/CohostStartCheckoutProvider';
|
|
5
6
|
export { useCohost } from './hooks/useCohost';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CohostStartCheckoutProvider.d.ts","sourceRoot":"","sources":["../../src/provider/CohostStartCheckoutProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B,CAiCA,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CohostStartCheckoutContext } from "../context/CohostStartCheckoutContext";
|
|
3
|
+
import { useCohostClient } from "../context/CohostContext";
|
|
4
|
+
export const CohostStartCheckoutProvider = ({ contextId, children }) => {
|
|
5
|
+
const { client } = useCohostClient();
|
|
6
|
+
const getCartSessionId = async () => {
|
|
7
|
+
const params = new URLSearchParams(window.location.search);
|
|
8
|
+
const tracking = {};
|
|
9
|
+
const forward = {};
|
|
10
|
+
for (const [key, value] of params.entries()) {
|
|
11
|
+
if (key.startsWith("utm_") || key.startsWith("ctm_")) {
|
|
12
|
+
tracking[key] = value;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
forward[key] = value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const cart = await client.cart.start({
|
|
19
|
+
contextId,
|
|
20
|
+
sessionContext: {
|
|
21
|
+
userAgent: navigator.userAgent,
|
|
22
|
+
tracking,
|
|
23
|
+
forward,
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return cart?.id ?? null;
|
|
27
|
+
};
|
|
28
|
+
return (_jsx(CohostStartCheckoutContext.Provider, { value: { contextId, getCartSessionId }, children: children }));
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cohostvip/cohost-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "React bindings for the Cohost API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@cohostvip/cohost-node": "0.1.
|
|
30
|
+
"@cohostvip/cohost-node": "0.1.10"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@testing-library/jest-dom": "6.6.3",
|