@pexip-engage-public/plugin-react 2.0.0-canary-20231025101109 → 2.0.1

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 CHANGED
@@ -1,16 +1,50 @@
1
1
  # @pexip-engage-public/plugin-react
2
2
 
3
- ## 2.0.0-canary-20231025101109
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5a13e9410]
8
+ - @pexip-engage-public/plugin@1.0.1
9
+
10
+ ## 2.0.0
4
11
 
5
12
  ### Major Changes
6
13
 
7
- - f94a30b50: feat: switch plugin packages to native node esm only
14
+ - 7412230be: feat: This package is ESM only starting from this release.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [7412230be]
19
+ - @pexip-engage-public/plugin@1.0.0
20
+
21
+ ## 1.1.0
22
+
23
+ ### Minor Changes
24
+
25
+ - 93c2a834b: (minor) prepare for legacy switch
8
26
 
9
27
  ### Patch Changes
10
28
 
11
- - Updated dependencies [f94a30b50]
12
- - @pexip-engage-public/plugin-configuration-parser@2.0.0-canary-20231025101109
13
- - @pexip-engage-public/plugin-instance@2.0.0-canary-20231025101109
29
+ - Updated dependencies [93c2a834b]
30
+ - @pexip-engage-public/plugin-configuration-parser@1.3.0
31
+ - @pexip-engage-public/plugin-instance@1.2.0
32
+
33
+ ## 1.0.57
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [0321f449c]
38
+ - @pexip-engage-public/plugin-configuration-parser@1.2.2
39
+ - @pexip-engage-public/plugin-instance@1.1.5
40
+
41
+ ## 1.0.56
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [c49c5a4aa]
46
+ - @pexip-engage-public/plugin-instance@1.1.4
47
+ - @pexip-engage-public/plugin-configuration-parser@1.2.1
14
48
 
15
49
  ## 1.0.55
16
50
 
@@ -1,11 +1,11 @@
1
- import type { JSConfig } from "@pexip-engage-public/plugin-configuration-parser";
1
+ import type { JSConfig } from "@pexip-engage-public/plugin/configuration-parser";
2
2
  export interface PexipEngagePluginContextProps extends NonNullable<JSConfig["config"]> {
3
- /**
4
- * The plugin entry point URL.
5
- * eg: `https://{ENTERPRISE_NAME}plugin.skedify.io/{ENTERPRISE_NAME}/pexip-engage-plugin.js`
6
- */
7
- scriptSrc?: string;
3
+ /**
4
+ * The plugin entry point URL.
5
+ * eg: `https://{ENTERPRISE_NAME}plugin.skedify.io/{ENTERPRISE_NAME}/pexip-engage-plugin.js`
6
+ */
7
+ scriptSrc?: string;
8
8
  }
9
9
  export declare function usePluginContext(): PexipEngagePluginContextProps;
10
10
  export declare const PexipEngagePluginProvider: import("react").Provider<PexipEngagePluginContextProps>;
11
- //# sourceMappingURL=PexipEngageContext.d.ts.map
11
+ //# sourceMappingURL=PexipEngageContext.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext } from "react";
2
- const PexipEngagePluginContext = createContext({});
2
+ const PexipEngagePluginContext = createContext({ version: "1.0.0" });
3
3
  export function usePluginContext() {
4
4
  const ctx = useContext(PexipEngagePluginContext);
5
5
  return ctx;
@@ -1,20 +1,12 @@
1
- import type { PluginInstance } from "@pexip-engage-public/plugin-instance";
1
+ import type { PluginInstance } from "@pexip-engage-public/plugin/instance";
2
2
  import { type PexipEngagePluginContextProps } from "./PexipEngageContext.js";
3
3
  interface PexipEngagePluginProps extends PexipEngagePluginContextProps {
4
- onInstanceChange?: (instance: PluginInstance | null) => unknown;
5
- fallback?: React.ReactElement<unknown, string | React.FunctionComponent> | null;
6
- className?: string;
7
- id?: string;
8
- style?: React.CSSProperties;
4
+ onInstanceChange?: (instance: PluginInstance | null) => unknown;
5
+ fallback?: React.ReactElement<unknown, string | React.FunctionComponent> | null;
6
+ className?: string;
7
+ id?: string;
8
+ style?: React.CSSProperties;
9
9
  }
10
- export declare function PexipEngagePlugin({
11
- className,
12
- fallback,
13
- id,
14
- onInstanceChange,
15
- scriptSrc,
16
- style,
17
- ...config
18
- }: PexipEngagePluginProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function PexipEngagePlugin({ className, fallback, id, onInstanceChange, scriptSrc, style, ...config }: PexipEngagePluginProps): import("react/jsx-runtime").JSX.Element;
19
11
  export {};
20
- //# sourceMappingURL=PexipEngagePlugin.d.ts.map
12
+ //# sourceMappingURL=PexipEngagePlugin.d.ts.map
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@ export type { PexipEngagePluginContextProps } from "./PexipEngageContext.js";
2
2
  export { PexipEngagePluginProvider } from "./PexipEngageContext.js";
3
3
  export { PexipEngagePlugin } from "./PexipEngagePlugin.js";
4
4
  export { usePexipEngagePlugin } from "./usePexipEngagePlugin.js";
5
- export type { PluginInstance } from "@pexip-engage-public/plugin-instance";
6
- export { PEXIP_ENGAGE_PLUGIN_EVENT } from "@pexip-engage-public/plugin-instance";
7
- //# sourceMappingURL=index.d.ts.map
5
+ export type { PluginInstance } from "@pexip-engage-public/plugin/instance";
6
+ export { PEXIP_ENGAGE_PLUGIN_EVENT } from "@pexip-engage-public/plugin/instance";
7
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { PexipEngagePluginProvider } from "./PexipEngageContext.js";
2
2
  export { PexipEngagePlugin } from "./PexipEngagePlugin.js";
3
3
  export { usePexipEngagePlugin } from "./usePexipEngagePlugin.js";
4
- export { PEXIP_ENGAGE_PLUGIN_EVENT } from "@pexip-engage-public/plugin-instance";
4
+ export { PEXIP_ENGAGE_PLUGIN_EVENT } from "@pexip-engage-public/plugin/instance";
@@ -1,8 +1,8 @@
1
- import { PluginStatic } from "@pexip-engage-public/plugin-instance";
1
+ import { PluginStatic } from "@pexip-engage-public/plugin/instance";
2
2
  interface UsePluginResult {
3
- Plugin: typeof PluginStatic | null;
4
- status: "pending" | "success" | "failed";
3
+ Plugin: typeof PluginStatic | null;
4
+ status: "pending" | "success" | "failed";
5
5
  }
6
6
  export declare function usePexipEngagePlugin(scriptSrc?: string): UsePluginResult;
7
7
  export {};
8
- //# sourceMappingURL=usePexipEngagePlugin.d.ts.map
8
+ //# sourceMappingURL=usePexipEngagePlugin.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useReducer } from "react";
2
- import { PEXIP_ENGAGE_PLUGIN_EVENT, PluginStatic, } from "@pexip-engage-public/plugin-instance";
2
+ import { PEXIP_ENGAGE_PLUGIN_EVENT, PluginStatic, } from "@pexip-engage-public/plugin/instance";
3
3
  import { usePluginContext } from "./PexipEngageContext.js";
4
4
  function createPlugin({ onError, src }) {
5
5
  const scriptEl = document.getElementById(src);
@@ -1,5 +1,3 @@
1
1
  import { type PexipEngagePluginContextProps } from "./PexipEngageContext.js";
2
- export declare function usePluginConfiguration(
3
- overrideConfiguration: PexipEngagePluginContextProps,
4
- ): PexipEngagePluginContextProps;
5
- //# sourceMappingURL=usePluginConfiguration.d.ts.map
2
+ export declare function usePluginConfiguration(overrideConfiguration: PexipEngagePluginContextProps): PexipEngagePluginContextProps;
3
+ //# sourceMappingURL=usePluginConfiguration.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pexip-engage-public/plugin-react",
3
- "version": "2.0.0-canary-20231025101109",
3
+ "version": "2.0.1",
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": {
@@ -20,9 +20,7 @@
20
20
  "sideEffects": false,
21
21
  "type": "module",
22
22
  "exports": {
23
- ".": {
24
- "import": "./dist/index.js"
25
- },
23
+ ".": "./dist/index.js",
26
24
  "./src/index.tsx": {
27
25
  "import": "./src/index.tsx"
28
26
  }
@@ -34,13 +32,12 @@
34
32
  ],
35
33
  "dependencies": {
36
34
  "deepmerge": "^4.3.1",
37
- "@pexip-engage-public/plugin-instance": "2.0.0-canary-20231025101109",
38
- "@pexip-engage-public/plugin-configuration-parser": "2.0.0-canary-20231025101109"
35
+ "@pexip-engage-public/plugin": "1.0.1"
39
36
  },
40
37
  "devDependencies": {
41
38
  "@eslint/eslintrc": "^2.1.2",
42
- "eslint-config-pexip-engage": "0.0.41-canary-20231025101109",
43
- "@pexip-engage/tsconfig": "0.0.10-canary-20231025101109"
39
+ "@pexip-engage/tsconfig": "0.1.0",
40
+ "eslint-config-pexip-engage": "0.1.0"
44
41
  },
45
42
  "peerDependencies": {
46
43
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext } from "react";
2
- import type { JSConfig } from "@pexip-engage-public/plugin-configuration-parser";
2
+ import type { JSConfig } from "@pexip-engage-public/plugin/configuration-parser";
3
3
 
4
4
  export interface PexipEngagePluginContextProps extends NonNullable<JSConfig["config"]> {
5
5
  /**
@@ -9,7 +9,7 @@ export interface PexipEngagePluginContextProps extends NonNullable<JSConfig["con
9
9
  scriptSrc?: string;
10
10
  }
11
11
 
12
- const PexipEngagePluginContext = createContext<PexipEngagePluginContextProps>({});
12
+ const PexipEngagePluginContext = createContext<PexipEngagePluginContextProps>({ version: "1.0.0" });
13
13
 
14
14
  export function usePluginContext() {
15
15
  const ctx = useContext(PexipEngagePluginContext);
@@ -1,5 +1,5 @@
1
1
  import { isValidElement, useEffect, useRef, useState } from "react";
2
- import type { PluginInstance } from "@pexip-engage-public/plugin-instance";
2
+ import type { PluginInstance } from "@pexip-engage-public/plugin/instance";
3
3
 
4
4
  import { type PexipEngagePluginContextProps } from "./PexipEngageContext.js";
5
5
  import { usePexipEngagePlugin } from "./usePexipEngagePlugin.js";
package/src/index.tsx CHANGED
@@ -2,5 +2,5 @@ export type { PexipEngagePluginContextProps } from "./PexipEngageContext.js";
2
2
  export { PexipEngagePluginProvider } from "./PexipEngageContext.js";
3
3
  export { PexipEngagePlugin } from "./PexipEngagePlugin.js";
4
4
  export { usePexipEngagePlugin } from "./usePexipEngagePlugin.js";
5
- export type { PluginInstance } from "@pexip-engage-public/plugin-instance";
6
- export { PEXIP_ENGAGE_PLUGIN_EVENT } from "@pexip-engage-public/plugin-instance";
5
+ export type { PluginInstance } from "@pexip-engage-public/plugin/instance";
6
+ export { PEXIP_ENGAGE_PLUGIN_EVENT } from "@pexip-engage-public/plugin/instance";
@@ -3,7 +3,7 @@ import {
3
3
  PEXIP_ENGAGE_PLUGIN_EVENT,
4
4
  type PluginCustomEvent,
5
5
  PluginStatic,
6
- } from "@pexip-engage-public/plugin-instance";
6
+ } from "@pexip-engage-public/plugin/instance";
7
7
 
8
8
  import { usePluginContext } from "./PexipEngageContext.js";
9
9
 
package/dist/index.mjs DELETED
@@ -1,187 +0,0 @@
1
- // src/PexipEngageContext.ts
2
- import { createContext, useContext } from "react";
3
- var PexipEngagePluginContext = createContext({});
4
- function usePluginContext() {
5
- const ctx = useContext(PexipEngagePluginContext);
6
- return ctx;
7
- }
8
- var PexipEngagePluginProvider = PexipEngagePluginContext.Provider;
9
-
10
- // src/PexipEngagePlugin.tsx
11
- import { isValidElement, useEffect as useEffect3, useRef as useRef2, useState } from "react";
12
-
13
- // src/usePexipEngagePlugin.ts
14
- import { useEffect, useReducer } from "react";
15
- import { PEXIP_ENGAGE_PLUGIN_EVENT } from "@pexip-engage-public/plugin-instance";
16
- function createPlugin({ onError, src }) {
17
- const scriptEl = document.getElementById(src);
18
- if (!scriptEl) {
19
- const script = document.createElement("script");
20
- script.src = src;
21
- script.async = true;
22
- script.defer = true;
23
- script.id = src;
24
- script.onerror = () => {
25
- script.setAttribute("data-status", "error");
26
- onError();
27
- };
28
- document.body.appendChild(script);
29
- } else if (scriptEl.getAttribute("data-status") === "error") {
30
- onError();
31
- }
32
- }
33
- var initialState = { Plugin: null, status: "pending" };
34
- function reducer(state, action) {
35
- switch (action.type) {
36
- case "success":
37
- return { Plugin: action.instance, status: "success" };
38
- case "failed":
39
- return { Plugin: null, status: "failed" };
40
- default:
41
- throw new Error();
42
- }
43
- }
44
- function usePexipEngagePlugin(scriptSrc) {
45
- const ctx = usePluginContext();
46
- const [state, dispatch] = useReducer(reducer, initialState);
47
- const src = scriptSrc ?? ctx.scriptSrc;
48
- useEffect(() => {
49
- if (!src) {
50
- console.warn(
51
- "No scriptSrc was provided to PexipEngagePluginContext, or as prop to <PexipEngagePlugin />, skipping plugin initialization...",
52
- );
53
- dispatch({ type: "failed" });
54
- return;
55
- }
56
- if (window && document) {
57
- if (window.PexipEngage?.Plugin) {
58
- dispatch({ type: "success", instance: window.PexipEngage.Plugin });
59
- } else {
60
- let listener2 = function (event) {
61
- const pluginEvent = event;
62
- if (!window.PexipEngage) return;
63
- if (pluginEvent.detail.type === window.PexipEngage.Plugin.EVENT_INIT) {
64
- dispatch({ type: "success", instance: window.PexipEngage.Plugin });
65
- } else if (pluginEvent.detail.type === window.PexipEngage?.Plugin.EVENT_MISCONFIGURED) {
66
- dispatch({ type: "failed" });
67
- } else if (pluginEvent.detail.type === window.PexipEngage?.Plugin.EVENT_ERROR) {
68
- dispatch({ type: "failed" });
69
- }
70
- };
71
- var listener = listener2;
72
- document.addEventListener(PEXIP_ENGAGE_PLUGIN_EVENT, listener2);
73
- createPlugin({ src, onError: () => dispatch({ type: "failed" }) });
74
- return () => document.removeEventListener(PEXIP_ENGAGE_PLUGIN_EVENT, listener2);
75
- }
76
- }
77
- }, [src]);
78
- return state;
79
- }
80
-
81
- // src/usePluginConfiguration.ts
82
- import { useEffect as useEffect2, useRef } from "react";
83
- import deepmerge from "deepmerge";
84
- function usePluginConfiguration(overrideConfiguration) {
85
- const defaultConfiguration = usePluginContext();
86
- const resolvedConfiguration = deepmerge(defaultConfiguration, overrideConfiguration);
87
- return useMemoizedObject(resolvedConfiguration);
88
- }
89
- function useMemoizedObject(currentObj) {
90
- const prevResult = useRef(currentObj);
91
- const memoizedObj = replaceEqualDeep(prevResult.current, currentObj);
92
- useEffect2(() => {
93
- prevResult.current = memoizedObj;
94
- });
95
- return memoizedObj;
96
- }
97
- function replaceEqualDeep(a, b) {
98
- if (a === b) {
99
- return a;
100
- }
101
- const array = Array.isArray(a) && Array.isArray(b);
102
- if (array || (isPlainObject(a) && isPlainObject(b))) {
103
- const aSize = array ? a.length : Object.keys(a).length;
104
- const bItems = array ? b : Object.keys(b);
105
- const bSize = bItems.length;
106
- const copy = array ? [] : {};
107
- let equalItems = 0;
108
- for (let i = 0; i < bSize; i++) {
109
- const key = array ? i : bItems[i];
110
- copy[key] = replaceEqualDeep(a[key], b[key]);
111
- if (copy[key] === a[key]) {
112
- equalItems++;
113
- }
114
- }
115
- return aSize === bSize && equalItems === aSize ? a : copy;
116
- }
117
- return b;
118
- }
119
- function isPlainObject(o) {
120
- if (!hasObjectPrototype(o)) {
121
- return false;
122
- }
123
- const ctor = o.constructor;
124
- if (typeof ctor === "undefined") {
125
- return true;
126
- }
127
- const prot = ctor.prototype;
128
- if (!hasObjectPrototype(prot)) {
129
- return false;
130
- }
131
- if (!prot.hasOwnProperty("isPrototypeOf")) {
132
- return false;
133
- }
134
- return true;
135
- }
136
- function hasObjectPrototype(o) {
137
- return Object.prototype.toString.call(o) === "[object Object]";
138
- }
139
-
140
- // src/PexipEngagePlugin.tsx
141
- import { jsx } from "react/jsx-runtime";
142
- function PexipEngagePlugin({
143
- className,
144
- fallback,
145
- id,
146
- onInstanceChange,
147
- scriptSrc,
148
- style,
149
- ...config
150
- }) {
151
- const { Plugin, status } = usePexipEngagePlugin(scriptSrc);
152
- const options = usePluginConfiguration(config);
153
- const containerRef = useRef2(null);
154
- const [instance, setInstance] = useState(null);
155
- useEffect3(() => {
156
- if (Plugin && containerRef.current) {
157
- const instance2 = new Plugin(containerRef.current, { config: options });
158
- setInstance(instance2);
159
- return () => {
160
- instance2.dispose();
161
- setInstance(null);
162
- };
163
- }
164
- }, [Plugin, options]);
165
- useEffect3(() => {
166
- onInstanceChange && onInstanceChange(instance);
167
- }, [instance, onInstanceChange]);
168
- if (status === "failed" && isValidElement(fallback)) {
169
- return fallback;
170
- }
171
- return /* @__PURE__ */ jsx("div", {
172
- className,
173
- "data-pexip-auto-init": "false",
174
- id,
175
- ref: containerRef,
176
- style,
177
- });
178
- }
179
-
180
- // src/index.tsx
181
- import { PEXIP_ENGAGE_PLUGIN_EVENT as PEXIP_ENGAGE_PLUGIN_EVENT2 } from "@pexip-engage-public/plugin-instance";
182
- export {
183
- PEXIP_ENGAGE_PLUGIN_EVENT2 as PEXIP_ENGAGE_PLUGIN_EVENT,
184
- PexipEngagePlugin,
185
- PexipEngagePluginProvider,
186
- usePexipEngagePlugin,
187
- };