loyalty-protocol 1.0.0 → 1.0.2
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/README.md +31 -0
- package/index.js +1 -0
- package/package.json +9 -3
- package/src/hooks/useLoyaltyChannel.js +0 -17
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# loyalty-protocol
|
|
2
|
+
|
|
3
|
+
A React hook for communicating with the Loyalty Protocol iframe.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install loyalty-protocol
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { useLoyaltyChannel } from "loyalty-protocol";
|
|
15
|
+
|
|
16
|
+
const { sendInformationToLoyaltyProtocol } = useLoyaltyChannel();
|
|
17
|
+
|
|
18
|
+
sendInformationToLoyaltyProtocol({ url: "https://example.com" });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### useLoyaltyChannel
|
|
24
|
+
|
|
25
|
+
Returns an object with the following method:
|
|
26
|
+
|
|
27
|
+
- `sendInformationToLoyaltyProtocol({ url })`: Sends a message to the Loyalty Protocol iframe.
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
ISC
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loyalty-protocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js"
|
|
8
|
+
},
|
|
6
9
|
"scripts": {
|
|
7
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
11
|
},
|
|
9
12
|
"keywords": [],
|
|
10
13
|
"author": "",
|
|
11
14
|
"license": "ISC",
|
|
12
|
-
"type": "
|
|
13
|
-
"private": false
|
|
15
|
+
"type": "module",
|
|
16
|
+
"private": false,
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"loyalty-protocol": "^1.0.0"
|
|
19
|
+
}
|
|
14
20
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useCallback } from "react";
|
|
2
|
-
|
|
3
|
-
const useLoyaltyChannel = () => {
|
|
4
|
-
const sendInformationToLoyaltyProtocol = ({ url }) => {
|
|
5
|
-
/** @type {HTMLIFrameElement} */
|
|
6
|
-
const iframe = document.getElementById("loyalty-protocol");
|
|
7
|
-
|
|
8
|
-
if (!iframe || typeof iframe.contentWindow === "undefined")
|
|
9
|
-
throw new Error(`Element with ID: loyalty-protocol is not iframe window`);
|
|
10
|
-
|
|
11
|
-
iframe.contentWindow.postMessage(url, "https://stage.kstore.global/");
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return { sendInformationToLoyaltyProtocol };
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { useLoyaltyChannel };
|