@pexip-engage-public/plugin-react 2.0.16 → 2.0.18
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/CHANGELOG.md +15 -0
- package/dist/PexipEngageContext.d.ts +2 -2
- package/dist/PexipEngageContext.d.ts.map +1 -1
- package/dist/PexipEngagePlugin.js +1 -1
- package/dist/PexipEngagePlugin.js.map +1 -1
- package/dist/usePexipEngagePlugin.d.ts.map +1 -1
- package/dist/usePexipEngagePlugin.js +8 -19
- package/dist/usePexipEngagePlugin.js.map +1 -1
- package/package.json +3 -3
- package/src/PexipEngageContext.ts +2 -2
- package/src/PexipEngagePlugin.tsx +1 -1
- package/src/usePexipEngagePlugin.ts +9 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @pexip-engage-public/plugin-react
|
|
2
2
|
|
|
3
|
+
## 2.0.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e914e44: feat: use loader script in react version as well.
|
|
8
|
+
- Updated dependencies [6ec81a1]
|
|
9
|
+
- @pexip-engage-public/plugin@1.0.18
|
|
10
|
+
|
|
11
|
+
## 2.0.17
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [b7a5179]
|
|
16
|
+
- @pexip-engage-public/plugin@1.0.17
|
|
17
|
+
|
|
3
18
|
## 2.0.16
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { JSConfig } from "@pexip-engage-public/plugin/configuration-parser";
|
|
2
|
-
export interface PexipEngagePluginContextProps extends NonNullable<JSConfig["config"]
|
|
2
|
+
export interface PexipEngagePluginContextProps extends Partial<NonNullable<JSConfig["config"]>> {
|
|
3
3
|
/**
|
|
4
4
|
* The plugin entry point URL.
|
|
5
|
-
* eg: `https://
|
|
5
|
+
* eg: `https://plugin.pexipengage.com/{ENTERPRISE_NAME}/pexip-engage-plugin.js`
|
|
6
6
|
*/
|
|
7
7
|
scriptSrc?: string;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PexipEngageContext.d.ts","sourceRoot":"","sources":["../src/PexipEngageContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kDAAkD,CAAC;AAEjF,MAAM,WAAW,6BAA8B,SAAQ,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"PexipEngageContext.d.ts","sourceRoot":"","sources":["../src/PexipEngageContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kDAAkD,CAAC;AAEjF,MAAM,WAAW,6BAA8B,SAAQ,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7F;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,wBAAgB,gBAAgB,kCAI/B;AACD,eAAO,MAAM,yBAAyB,yDAAoC,CAAC"}
|
|
@@ -18,7 +18,7 @@ export function PexipEngagePlugin({ className, fallback, id, onInstanceChange, s
|
|
|
18
18
|
}
|
|
19
19
|
}, [Plugin, options]);
|
|
20
20
|
useEffect(() => {
|
|
21
|
-
onInstanceChange
|
|
21
|
+
onInstanceChange?.(instance);
|
|
22
22
|
}, [instance, onInstanceChange]);
|
|
23
23
|
if (status === "failed" && isValidElement(fallback)) {
|
|
24
24
|
return fallback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PexipEngagePlugin.js","sourceRoot":"","sources":["../src/PexipEngagePlugin.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;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
-
{"version":3,"file":"usePexipEngagePlugin.d.ts","sourceRoot":"","sources":["../src/usePexipEngagePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,YAAY,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"usePexipEngagePlugin.d.ts","sourceRoot":"","sources":["../src/usePexipEngagePlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAc5F,UAAU,eAAe;IACvB,MAAM,EAAE,OAAO,YAAY,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;CAC1C;AAgBD,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,mBAgDtD"}
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import { useEffect, useReducer } from "react";
|
|
2
2
|
import { usePluginContext } from "./PexipEngageContext.js";
|
|
3
3
|
import { PEXIP_ENGAGE_PLUGIN_EVENT } from "./utils.js";
|
|
4
|
-
function createPlugin({
|
|
5
|
-
|
|
6
|
-
if (!scriptEl) {
|
|
4
|
+
function createPlugin({ src }) {
|
|
5
|
+
if (!window.PexipEngage) {
|
|
7
6
|
const script = document.createElement("script");
|
|
8
|
-
script.
|
|
9
|
-
script.async = true;
|
|
10
|
-
script.defer = true;
|
|
11
|
-
script.id = src;
|
|
12
|
-
script.onerror = () => {
|
|
13
|
-
script.setAttribute("data-status", "error");
|
|
14
|
-
onError();
|
|
15
|
-
};
|
|
7
|
+
script.innerHTML = `(function(e,r,s){if(typeof r>"u")return;let n="PexipEngage",a="script";e[n]=e[n]||function(){e[n].q=e[n].q||[];let g=arguments;if(g[0]==="init"){if(e[n].loaded)return;let i=r.getElementsByTagName(a)[0],t=r.createElement(a);t.defer=!0,t.async=!0,t.src=s,e[n].loaded=!0,i?.parentNode?.insertBefore(t,i);return}return new Promise((i,t)=>e[n].q.push([g,i,t]))};})(window,document,"${src}");window.PexipEngage("init");`;
|
|
16
8
|
document.body.appendChild(script);
|
|
17
9
|
}
|
|
18
|
-
else if (scriptEl.getAttribute("data-status") === "error") {
|
|
19
|
-
onError();
|
|
20
|
-
}
|
|
21
10
|
}
|
|
22
11
|
const initialState = { Plugin: null, status: "pending" };
|
|
23
12
|
function reducer(state, action) {
|
|
@@ -43,7 +32,7 @@ export function usePexipEngagePlugin(scriptSrc) {
|
|
|
43
32
|
if (window && document) {
|
|
44
33
|
// only load entry code once
|
|
45
34
|
if (window.PexipEngage?.Plugin) {
|
|
46
|
-
// If
|
|
35
|
+
// If PexipEngage.Plugin is already available, use that instance.
|
|
47
36
|
dispatch({ type: "success", instance: window.PexipEngage.Plugin });
|
|
48
37
|
}
|
|
49
38
|
else {
|
|
@@ -51,18 +40,18 @@ export function usePexipEngagePlugin(scriptSrc) {
|
|
|
51
40
|
const pluginEvent = event;
|
|
52
41
|
if (!window.PexipEngage)
|
|
53
42
|
return;
|
|
54
|
-
if (pluginEvent.detail.type === window.PexipEngage.Plugin
|
|
43
|
+
if (pluginEvent.detail.type === window.PexipEngage.Plugin?.EVENT_INIT) {
|
|
55
44
|
dispatch({ type: "success", instance: window.PexipEngage.Plugin });
|
|
56
45
|
}
|
|
57
|
-
else if (pluginEvent.detail.type === window.PexipEngage?.Plugin
|
|
46
|
+
else if (pluginEvent.detail.type === window.PexipEngage?.Plugin?.EVENT_MISCONFIGURED) {
|
|
58
47
|
dispatch({ type: "failed" });
|
|
59
48
|
}
|
|
60
|
-
else if (pluginEvent.detail.type === window.PexipEngage?.Plugin
|
|
49
|
+
else if (pluginEvent.detail.type === window.PexipEngage?.Plugin?.EVENT_ERROR) {
|
|
61
50
|
dispatch({ type: "failed" });
|
|
62
51
|
}
|
|
63
52
|
}
|
|
64
53
|
document.addEventListener(PEXIP_ENGAGE_PLUGIN_EVENT, listener);
|
|
65
|
-
createPlugin({ src
|
|
54
|
+
createPlugin({ src });
|
|
66
55
|
return () => document.removeEventListener(PEXIP_ENGAGE_PLUGIN_EVENT, listener);
|
|
67
56
|
}
|
|
68
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePexipEngagePlugin.js","sourceRoot":"","sources":["../src/usePexipEngagePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,SAAS,YAAY,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"usePexipEngagePlugin.js","sourceRoot":"","sources":["../src/usePexipEngagePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,SAAS,YAAY,CAAC,EAAE,GAAG,EAAmB;IAC5C,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,SAAS,GAAG,4XAA4X,GAAG,gCAAgC,CAAC;QAEnb,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAOD,MAAM,YAAY,GAAoB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAG1E,SAAS,OAAO,CAAC,KAA0B,EAAE,MAAc;IACzD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QACxD,KAAK,QAAQ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IAAI,KAAK,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;wBACvF,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;oBAC/B,CAAC;yBAAM,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;wBAC/E,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;gBAED,QAAQ,CAAC,gBAAgB,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;gBAE/D,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;gBAEtB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pexip-engage-public/plugin-react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18",
|
|
4
4
|
"description": "React wrapper component for the Pexip Engage Plugin",
|
|
5
5
|
"homepage": "https://github.com/skedify/frontend-mono/tree/develop/apps/plugin-remix/packages/plugin-react#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"deepmerge": "^4.3.1",
|
|
35
|
-
"@pexip-engage-public/plugin": "1.0.
|
|
35
|
+
"@pexip-engage-public/plugin": "1.0.18"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@pexip-engage/tsconfig": "0.1.1",
|
|
39
|
-
"eslint-config-pexip-engage": "0.1.
|
|
39
|
+
"eslint-config-pexip-engage": "0.1.9"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import type { JSConfig } from "@pexip-engage-public/plugin/configuration-parser";
|
|
3
3
|
|
|
4
|
-
export interface PexipEngagePluginContextProps extends NonNullable<JSConfig["config"]
|
|
4
|
+
export interface PexipEngagePluginContextProps extends Partial<NonNullable<JSConfig["config"]>> {
|
|
5
5
|
/**
|
|
6
6
|
* The plugin entry point URL.
|
|
7
|
-
* eg: `https://
|
|
7
|
+
* eg: `https://plugin.pexipengage.com/{ENTERPRISE_NAME}/pexip-engage-plugin.js`
|
|
8
8
|
*/
|
|
9
9
|
scriptSrc?: string;
|
|
10
10
|
}
|
|
@@ -39,7 +39,7 @@ export function PexipEngagePlugin({
|
|
|
39
39
|
}, [Plugin, options]);
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
|
-
onInstanceChange
|
|
42
|
+
onInstanceChange?.(instance);
|
|
43
43
|
}, [instance, onInstanceChange]);
|
|
44
44
|
|
|
45
45
|
if (status === "failed" && isValidElement(fallback)) {
|
|
@@ -4,22 +4,12 @@ import type { PluginCustomEvent, PluginStatic } from "@pexip-engage-public/plugi
|
|
|
4
4
|
import { usePluginContext } from "./PexipEngageContext.js";
|
|
5
5
|
import { PEXIP_ENGAGE_PLUGIN_EVENT } from "./utils.js";
|
|
6
6
|
|
|
7
|
-
function createPlugin({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!scriptEl) {
|
|
7
|
+
function createPlugin({ src }: { src: string }) {
|
|
8
|
+
if (!window.PexipEngage) {
|
|
11
9
|
const script = document.createElement("script");
|
|
12
|
-
script.
|
|
13
|
-
|
|
14
|
-
script.defer = true;
|
|
15
|
-
script.id = src;
|
|
16
|
-
script.onerror = () => {
|
|
17
|
-
script.setAttribute("data-status", "error");
|
|
18
|
-
onError();
|
|
19
|
-
};
|
|
10
|
+
script.innerHTML = `(function(e,r,s){if(typeof r>"u")return;let n="PexipEngage",a="script";e[n]=e[n]||function(){e[n].q=e[n].q||[];let g=arguments;if(g[0]==="init"){if(e[n].loaded)return;let i=r.getElementsByTagName(a)[0],t=r.createElement(a);t.defer=!0,t.async=!0,t.src=s,e[n].loaded=!0,i?.parentNode?.insertBefore(t,i);return}return new Promise((i,t)=>e[n].q.push([g,i,t]))};})(window,document,"${src}");window.PexipEngage("init");`;
|
|
11
|
+
|
|
20
12
|
document.body.appendChild(script);
|
|
21
|
-
} else if (scriptEl.getAttribute("data-status") === "error") {
|
|
22
|
-
onError();
|
|
23
13
|
}
|
|
24
14
|
}
|
|
25
15
|
|
|
@@ -63,7 +53,7 @@ export function usePexipEngagePlugin(scriptSrc?: string) {
|
|
|
63
53
|
// only load entry code once
|
|
64
54
|
|
|
65
55
|
if (window.PexipEngage?.Plugin) {
|
|
66
|
-
// If
|
|
56
|
+
// If PexipEngage.Plugin is already available, use that instance.
|
|
67
57
|
dispatch({ type: "success", instance: window.PexipEngage.Plugin });
|
|
68
58
|
} else {
|
|
69
59
|
function listener(event: Event) {
|
|
@@ -71,18 +61,18 @@ export function usePexipEngagePlugin(scriptSrc?: string) {
|
|
|
71
61
|
|
|
72
62
|
if (!window.PexipEngage) return;
|
|
73
63
|
|
|
74
|
-
if (pluginEvent.detail.type === window.PexipEngage.Plugin
|
|
64
|
+
if (pluginEvent.detail.type === window.PexipEngage.Plugin?.EVENT_INIT) {
|
|
75
65
|
dispatch({ type: "success", instance: window.PexipEngage.Plugin });
|
|
76
|
-
} else if (pluginEvent.detail.type === window.PexipEngage?.Plugin
|
|
66
|
+
} else if (pluginEvent.detail.type === window.PexipEngage?.Plugin?.EVENT_MISCONFIGURED) {
|
|
77
67
|
dispatch({ type: "failed" });
|
|
78
|
-
} else if (pluginEvent.detail.type === window.PexipEngage?.Plugin
|
|
68
|
+
} else if (pluginEvent.detail.type === window.PexipEngage?.Plugin?.EVENT_ERROR) {
|
|
79
69
|
dispatch({ type: "failed" });
|
|
80
70
|
}
|
|
81
71
|
}
|
|
82
72
|
|
|
83
73
|
document.addEventListener(PEXIP_ENGAGE_PLUGIN_EVENT, listener);
|
|
84
74
|
|
|
85
|
-
createPlugin({ src
|
|
75
|
+
createPlugin({ src });
|
|
86
76
|
|
|
87
77
|
return () => document.removeEventListener(PEXIP_ENGAGE_PLUGIN_EVENT, listener);
|
|
88
78
|
}
|