loyalty-protocol 1.0.7 → 1.0.8
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.cjs +22 -14
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +22 -14
- package/dist/theme.css +3 -0
- package/package.json +10 -4
- package/index.ts +0 -5
- package/tsconfig.json +0 -17
package/dist/index.cjs
CHANGED
|
@@ -26,20 +26,28 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// src/hooks/useLoyaltyChannel.ts
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var useLoyaltyChannel = ({ message }) => {
|
|
31
|
+
const iframeRef = (0, import_react.useRef)(null);
|
|
32
|
+
const sendInformationToLoyaltyProtocol = (0, import_react.useCallback)(
|
|
33
|
+
({ data, url }) => {
|
|
34
|
+
const iframe = iframeRef.current;
|
|
35
|
+
if (!iframe || typeof iframe.contentWindow === "undefined")
|
|
36
|
+
return void console.warn(
|
|
37
|
+
`Element with ID: loyalty-protocol is not iframe window`
|
|
38
|
+
);
|
|
39
|
+
iframe.contentWindow?.postMessage(data, url);
|
|
40
|
+
},
|
|
41
|
+
[iframeRef.current]
|
|
42
|
+
);
|
|
43
|
+
(0, import_react.useEffect)(() => {
|
|
44
|
+
window.addEventListener("message", ({ data }) => {
|
|
45
|
+
if (data?.eventName === "init-handshake") {
|
|
46
|
+
sendInformationToLoyaltyProtocol(message);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}, []);
|
|
50
|
+
return iframeRef;
|
|
43
51
|
};
|
|
44
52
|
|
|
45
53
|
// index.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
1
3
|
interface SendInformationArgs {
|
|
2
4
|
data: string;
|
|
3
5
|
url: string;
|
|
4
6
|
}
|
|
5
|
-
declare const useLoyaltyChannel: (
|
|
6
|
-
|
|
7
|
-
}
|
|
7
|
+
declare const useLoyaltyChannel: ({ message }: {
|
|
8
|
+
message: SendInformationArgs;
|
|
9
|
+
}) => react.RefObject<HTMLIFrameElement | null>;
|
|
8
10
|
|
|
9
11
|
export { useLoyaltyChannel as default, useLoyaltyChannel };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
1
3
|
interface SendInformationArgs {
|
|
2
4
|
data: string;
|
|
3
5
|
url: string;
|
|
4
6
|
}
|
|
5
|
-
declare const useLoyaltyChannel: (
|
|
6
|
-
|
|
7
|
-
}
|
|
7
|
+
declare const useLoyaltyChannel: ({ message }: {
|
|
8
|
+
message: SendInformationArgs;
|
|
9
|
+
}) => react.RefObject<HTMLIFrameElement | null>;
|
|
8
10
|
|
|
9
11
|
export { useLoyaltyChannel as default, useLoyaltyChannel };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
// src/hooks/useLoyaltyChannel.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
var useLoyaltyChannel = ({ message }) => {
|
|
4
|
+
const iframeRef = useRef(null);
|
|
5
|
+
const sendInformationToLoyaltyProtocol = useCallback(
|
|
6
|
+
({ data, url }) => {
|
|
7
|
+
const iframe = iframeRef.current;
|
|
8
|
+
if (!iframe || typeof iframe.contentWindow === "undefined")
|
|
9
|
+
return void console.warn(
|
|
10
|
+
`Element with ID: loyalty-protocol is not iframe window`
|
|
11
|
+
);
|
|
12
|
+
iframe.contentWindow?.postMessage(data, url);
|
|
13
|
+
},
|
|
14
|
+
[iframeRef.current]
|
|
15
|
+
);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
window.addEventListener("message", ({ data }) => {
|
|
18
|
+
if (data?.eventName === "init-handshake") {
|
|
19
|
+
sendInformationToLoyaltyProtocol(message);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}, []);
|
|
23
|
+
return iframeRef;
|
|
16
24
|
};
|
|
17
25
|
|
|
18
26
|
// index.ts
|
package/dist/theme.css
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loyalty-protocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
-
"build": "tsup index.ts --format esm,cjs --dts"
|
|
11
|
+
"build": "tsup index.ts --format esm,cjs --dts && cp src/theme/theme.css dist/theme.css"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [],
|
|
14
14
|
"author": "",
|
|
@@ -16,10 +16,16 @@
|
|
|
16
16
|
"type": "module",
|
|
17
17
|
"private": false,
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"loyalty-protocol": "^1.0.0"
|
|
19
|
+
"loyalty-protocol": "^1.0.0",
|
|
20
|
+
"react": "^19.1.1"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
23
|
+
"@types/react": "^19.1.12",
|
|
22
24
|
"tsup": "^8.5.0",
|
|
23
25
|
"typescript": "^5.9.2"
|
|
24
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"dist/theme.css"
|
|
30
|
+
]
|
|
25
31
|
}
|
package/index.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"outDir": "dist",
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"moduleResolution": "Node",
|
|
10
|
-
"jsx": "react-jsx",
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"strict": true,
|
|
13
|
-
"skipLibCheck": true
|
|
14
|
-
},
|
|
15
|
-
"include": ["src", "index.ts"],
|
|
16
|
-
"exclude": ["node_modules", "dist"]
|
|
17
|
-
}
|