@visitorquery/react 0.0.10 → 0.0.13
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.d.ts +1 -1
- package/dist/index.js +77 -110
- package/dist/provider.d.ts +1 -1
- package/package.json +44 -44
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './provider.tsx';
|
package/dist/index.js
CHANGED
|
@@ -1,122 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const domStatus = script?.getAttribute("data-status");
|
|
12
|
-
if (domStatus) {
|
|
13
|
-
setStatus(domStatus);
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import * as m from "react";
|
|
3
|
+
import { createContext as v, useState as y, useMemo as l, useEffect as S, useContext as p } from "react";
|
|
4
|
+
function w(t, i = {}) {
|
|
5
|
+
const [d, n] = m.useState("loading"), a = m.useRef(i);
|
|
6
|
+
return m.useEffect(() => {
|
|
7
|
+
let e = document.querySelector(`script[src="${t}"]`);
|
|
8
|
+
const s = e == null ? void 0 : e.getAttribute("data-status");
|
|
9
|
+
if (s) {
|
|
10
|
+
n(s);
|
|
14
11
|
return;
|
|
15
12
|
}
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
setStatus("ready");
|
|
25
|
-
removeEventListeners();
|
|
13
|
+
if (e === null) {
|
|
14
|
+
e = document.createElement("script"), e.src = t, e.async = !0, e.setAttribute("data-status", "loading"), document.body.appendChild(e);
|
|
15
|
+
const o = () => {
|
|
16
|
+
e == null || e.setAttribute("data-status", "ready"), n("ready"), u();
|
|
17
|
+
}, r = () => {
|
|
18
|
+
e == null || e.setAttribute("data-status", "error"), n("error"), u();
|
|
19
|
+
}, u = () => {
|
|
20
|
+
e == null || e.removeEventListener("load", o), e == null || e.removeEventListener("error", r);
|
|
26
21
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
setStatus("error");
|
|
30
|
-
removeEventListeners();
|
|
31
|
-
};
|
|
32
|
-
const removeEventListeners = () => {
|
|
33
|
-
script?.removeEventListener("load", handleScriptLoad);
|
|
34
|
-
script?.removeEventListener("error", handleScriptError);
|
|
35
|
-
};
|
|
36
|
-
script.addEventListener("load", handleScriptLoad);
|
|
37
|
-
script.addEventListener("error", handleScriptError);
|
|
38
|
-
const removeOnUnmount = optionsRef.current.removeOnUnmount;
|
|
22
|
+
e.addEventListener("load", o), e.addEventListener("error", r);
|
|
23
|
+
const c = a.current.removeOnUnmount;
|
|
39
24
|
return () => {
|
|
40
|
-
|
|
41
|
-
script?.remove();
|
|
42
|
-
removeEventListeners();
|
|
43
|
-
}
|
|
25
|
+
c === !0 && (e == null || e.remove(), u());
|
|
44
26
|
};
|
|
45
|
-
} else
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, [src]);
|
|
49
|
-
return status;
|
|
27
|
+
} else
|
|
28
|
+
n("unknown");
|
|
29
|
+
}, [t]), d;
|
|
50
30
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
sessionId,
|
|
58
|
-
endpoint,
|
|
59
|
-
children
|
|
31
|
+
const f = v(null);
|
|
32
|
+
function x({
|
|
33
|
+
apiKey: t,
|
|
34
|
+
sessionId: i,
|
|
35
|
+
endpoint: d,
|
|
36
|
+
children: n
|
|
60
37
|
}) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}, [params, clientScript]);
|
|
103
|
-
const contextValue = useMemo(() => ({
|
|
104
|
-
...state,
|
|
105
|
-
isLoading: clientScript === "loading"
|
|
106
|
-
}), [state, clientScript]);
|
|
107
|
-
return /* @__PURE__ */ jsxDEV(VisitorQueryContext.Provider, {
|
|
108
|
-
value: contextValue,
|
|
109
|
-
children
|
|
110
|
-
}, undefined, false, undefined, this);
|
|
38
|
+
const a = "main.check.visitorquery.com", e = w("https://cdn.visitorquery.com/visitorquery.js", {
|
|
39
|
+
removeOnUnmount: !1
|
|
40
|
+
}), [s, o] = y({
|
|
41
|
+
Started: !1,
|
|
42
|
+
Ended: !1
|
|
43
|
+
}), r = l(() => ({
|
|
44
|
+
ApiKey: t,
|
|
45
|
+
SessionId: i,
|
|
46
|
+
Endpoint: d || a
|
|
47
|
+
}), [t, i, d, a]);
|
|
48
|
+
S(() => {
|
|
49
|
+
typeof window.VisitorQuery < "u" && window.VisitorQuery.run({
|
|
50
|
+
ApiKey: r.ApiKey,
|
|
51
|
+
Endpoint: r.Endpoint,
|
|
52
|
+
SessionId: r.SessionId,
|
|
53
|
+
onOpen: () => {
|
|
54
|
+
o({
|
|
55
|
+
Started: !0,
|
|
56
|
+
Ended: !1
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
onClose: () => {
|
|
60
|
+
o({
|
|
61
|
+
Started: !0,
|
|
62
|
+
Ended: !0
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
onError: (c) => {
|
|
66
|
+
o({
|
|
67
|
+
Started: !0,
|
|
68
|
+
Ended: !0,
|
|
69
|
+
Errored: !0
|
|
70
|
+
}), console.error(c);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}, [r, e]);
|
|
74
|
+
const u = l(() => ({
|
|
75
|
+
...s,
|
|
76
|
+
isLoading: e === "loading"
|
|
77
|
+
}), [s, e]);
|
|
78
|
+
return /* @__PURE__ */ E(f.Provider, { value: u, children: n });
|
|
111
79
|
}
|
|
112
|
-
function
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
80
|
+
function A() {
|
|
81
|
+
const t = p(f);
|
|
82
|
+
if (!t)
|
|
115
83
|
throw new Error("useVisitorQuery must be used within a VisitorQueryProvider");
|
|
116
|
-
|
|
117
|
-
return context;
|
|
84
|
+
return t;
|
|
118
85
|
}
|
|
119
86
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
87
|
+
x as VisitorQueryProvider,
|
|
88
|
+
A as useVisitorQuery
|
|
122
89
|
};
|
package/dist/provider.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
2
|
+
"version": "0.0.13",
|
|
3
|
+
"name": "@visitorquery/react",
|
|
4
|
+
"module": "src/index.tsx",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
8
|
+
"vite": "^6.2.1",
|
|
9
|
+
"vite-plugin-dts": "^4.5.3"
|
|
10
|
+
},
|
|
11
|
+
"access": "public",
|
|
12
|
+
"main": "dist/index.ts",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@types/react": "^19.0.10",
|
|
16
|
+
"react": "^19.0.0",
|
|
17
|
+
"react-dom": "^19.0.0",
|
|
18
|
+
"typescript": "^5.0.0"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/visitorquery/react-hook.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"fraud",
|
|
26
|
+
"antifraud",
|
|
27
|
+
"chargeback",
|
|
28
|
+
"proxy",
|
|
29
|
+
"visitorquery",
|
|
30
|
+
"vpn",
|
|
31
|
+
"detect"
|
|
32
|
+
],
|
|
33
|
+
"author": "VisitorQuery",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"files": [
|
|
36
|
+
"dist/*.js",
|
|
37
|
+
"dist/*.jsx",
|
|
38
|
+
"dist/*.d.ts"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc --p ./tsconfig.build.json && vite build",
|
|
42
|
+
"push": "git fetch --tags -f && standard-version && git push --follow-tags origin master && pnpm publish --access public",
|
|
43
|
+
"release": "pnpm run build && pnpm run push"
|
|
44
|
+
}
|
|
45
|
+
}
|