personalize-connect-sdk 1.3.5 → 1.4.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/README.md +4 -4
- package/dist/index.js +4 -37
- package/dist/index.mjs +4 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Personalize Connect SDK
|
|
2
2
|
|
|
3
|
-
Runtime SDK for [Personalize Connect](https://github.com/Sitecore-Hackathon/2026-Team-Solo) — a zero-code bridge between
|
|
3
|
+
Runtime SDK for [Personalize Connect](https://github.com/Sitecore-Hackathon/2026-Team-Solo) — a zero-code bridge between SitecoreAI components and Sitecore Personalize Full Stack Interactive Experiences.
|
|
4
4
|
|
|
5
5
|
The SDK reads configuration authored by the Marketplace app (stored in the content tree), calls Personalize for a decision via the Edge proxy, resolves the matching datasource from Experience Edge, and swaps component content — with zero per-component code. In Page Builder, components with personalization get a visual indicator.
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ npm install personalize-connect-sdk
|
|
|
12
12
|
|
|
13
13
|
Peer dependency: `react` >= 18.
|
|
14
14
|
|
|
15
|
-
## Quick Start (
|
|
15
|
+
## Quick Start (SitecoreAI)
|
|
16
16
|
|
|
17
17
|
### 1. Wrap your app with `PersonalizeProvider`
|
|
18
18
|
|
|
@@ -81,12 +81,12 @@ function MyComponent({ rendering }) {
|
|
|
81
81
|
|
|
82
82
|
## Provider Props
|
|
83
83
|
|
|
84
|
-
###
|
|
84
|
+
### SitecoreAI (recommended)
|
|
85
85
|
|
|
86
86
|
| Prop | Required | Description |
|
|
87
87
|
|------|----------|-------------|
|
|
88
88
|
| `sitecoreEdgeContextId` | Yes | Edge Context ID — drives all Edge proxy calls |
|
|
89
|
-
| `siteName` | Yes |
|
|
89
|
+
| `siteName` | Yes | SitecoreAI site name |
|
|
90
90
|
| `sitecoreEdgeUrl` | No | Edge platform URL (defaults to `https://edge-platform.sitecorecloud.io`) |
|
|
91
91
|
|
|
92
92
|
### Legacy (direct credentials)
|
package/dist/index.js
CHANGED
|
@@ -760,7 +760,7 @@ var BAR_STYLE = {
|
|
|
760
760
|
fontSize: "12px",
|
|
761
761
|
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
762
762
|
fontWeight: 500,
|
|
763
|
-
borderRadius: "0 0
|
|
763
|
+
borderRadius: "6px 6px 0 0",
|
|
764
764
|
flexWrap: "wrap",
|
|
765
765
|
position: "relative",
|
|
766
766
|
zIndex: 1
|
|
@@ -842,19 +842,6 @@ function PreviewBar({
|
|
|
842
842
|
activeKey !== null && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: PREVIEW_LABEL, children: "preview only \u2014 switch to Original to edit" })
|
|
843
843
|
] });
|
|
844
844
|
}
|
|
845
|
-
var _marketplaceDetected = false;
|
|
846
|
-
var MARKETPLACE_MSG_TYPE = "personalize-connect-active";
|
|
847
|
-
if (typeof window !== "undefined") {
|
|
848
|
-
window.addEventListener("message", (e) => {
|
|
849
|
-
try {
|
|
850
|
-
const data = typeof e.data === "string" ? JSON.parse(e.data) : e.data;
|
|
851
|
-
if (data?.type === MARKETPLACE_MSG_TYPE) {
|
|
852
|
-
_marketplaceDetected = true;
|
|
853
|
-
}
|
|
854
|
-
} catch {
|
|
855
|
-
}
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
845
|
function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG) {
|
|
859
846
|
const componentName = WrappedComponent.displayName ?? WrappedComponent.name ?? "Component";
|
|
860
847
|
function PersonalizeConnectWrapper(props) {
|
|
@@ -863,7 +850,6 @@ function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG
|
|
|
863
850
|
const [previewKey, setPreviewKey] = (0, import_react2.useState)(null);
|
|
864
851
|
const [previewFields, setPreviewFields] = (0, import_react2.useState)(null);
|
|
865
852
|
const [previewLoading, setPreviewLoading] = (0, import_react2.useState)(false);
|
|
866
|
-
const [showBar, setShowBar] = (0, import_react2.useState)(_marketplaceDetected);
|
|
867
853
|
const mountedRef = (0, import_react2.useRef)(true);
|
|
868
854
|
const previewCacheRef = (0, import_react2.useRef)(/* @__PURE__ */ new Map());
|
|
869
855
|
let config = getConfig(props);
|
|
@@ -895,25 +881,6 @@ function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG
|
|
|
895
881
|
log(`[${componentName}] Config active:`, { friendlyId: config.friendlyId, defaultKey: config.defaultKey, keys: Object.keys(config.contentMap) });
|
|
896
882
|
}
|
|
897
883
|
const isEditing = context?.isEditing ?? false;
|
|
898
|
-
(0, import_react2.useEffect)(() => {
|
|
899
|
-
if (!isEditing || !config) return;
|
|
900
|
-
if (_marketplaceDetected) {
|
|
901
|
-
setShowBar(true);
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
const handler = (e) => {
|
|
905
|
-
try {
|
|
906
|
-
const data = typeof e.data === "string" ? JSON.parse(e.data) : e.data;
|
|
907
|
-
if (data?.type === MARKETPLACE_MSG_TYPE) {
|
|
908
|
-
_marketplaceDetected = true;
|
|
909
|
-
setShowBar(true);
|
|
910
|
-
}
|
|
911
|
-
} catch {
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
window.addEventListener("message", handler);
|
|
915
|
-
return () => window.removeEventListener("message", handler);
|
|
916
|
-
}, [isEditing, config]);
|
|
917
884
|
const handlePreviewSelect = (0, import_react2.useCallback)(async (key) => {
|
|
918
885
|
if (!config || !context) return;
|
|
919
886
|
setPreviewKey(key);
|
|
@@ -994,8 +961,7 @@ function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG
|
|
|
994
961
|
const isPreviewing = previewKey !== null && previewFields !== null;
|
|
995
962
|
const editingProps = isPreviewing ? { ...props, fields: previewFields } : props;
|
|
996
963
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.Fragment, { children: [
|
|
997
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
998
|
-
showBar && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
964
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
999
965
|
PreviewBar,
|
|
1000
966
|
{
|
|
1001
967
|
config,
|
|
@@ -1003,7 +969,8 @@ function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG
|
|
|
1003
969
|
isLoading: previewLoading,
|
|
1004
970
|
onSelect: handlePreviewSelect
|
|
1005
971
|
}
|
|
1006
|
-
)
|
|
972
|
+
),
|
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WrappedComponent, { ...editingProps })
|
|
1007
974
|
] });
|
|
1008
975
|
}
|
|
1009
976
|
const mergedProps = resolvedFields ? { ...props, fields: resolvedFields } : props;
|
package/dist/index.mjs
CHANGED
|
@@ -719,7 +719,7 @@ var BAR_STYLE = {
|
|
|
719
719
|
fontSize: "12px",
|
|
720
720
|
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
721
721
|
fontWeight: 500,
|
|
722
|
-
borderRadius: "0 0
|
|
722
|
+
borderRadius: "6px 6px 0 0",
|
|
723
723
|
flexWrap: "wrap",
|
|
724
724
|
position: "relative",
|
|
725
725
|
zIndex: 1
|
|
@@ -801,19 +801,6 @@ function PreviewBar({
|
|
|
801
801
|
activeKey !== null && !isLoading && /* @__PURE__ */ jsx2("span", { style: PREVIEW_LABEL, children: "preview only \u2014 switch to Original to edit" })
|
|
802
802
|
] });
|
|
803
803
|
}
|
|
804
|
-
var _marketplaceDetected = false;
|
|
805
|
-
var MARKETPLACE_MSG_TYPE = "personalize-connect-active";
|
|
806
|
-
if (typeof window !== "undefined") {
|
|
807
|
-
window.addEventListener("message", (e) => {
|
|
808
|
-
try {
|
|
809
|
-
const data = typeof e.data === "string" ? JSON.parse(e.data) : e.data;
|
|
810
|
-
if (data?.type === MARKETPLACE_MSG_TYPE) {
|
|
811
|
-
_marketplaceDetected = true;
|
|
812
|
-
}
|
|
813
|
-
} catch {
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
804
|
function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG) {
|
|
818
805
|
const componentName = WrappedComponent.displayName ?? WrappedComponent.name ?? "Component";
|
|
819
806
|
function PersonalizeConnectWrapper(props) {
|
|
@@ -822,7 +809,6 @@ function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG
|
|
|
822
809
|
const [previewKey, setPreviewKey] = useState2(null);
|
|
823
810
|
const [previewFields, setPreviewFields] = useState2(null);
|
|
824
811
|
const [previewLoading, setPreviewLoading] = useState2(false);
|
|
825
|
-
const [showBar, setShowBar] = useState2(_marketplaceDetected);
|
|
826
812
|
const mountedRef = useRef(true);
|
|
827
813
|
const previewCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
828
814
|
let config = getConfig(props);
|
|
@@ -854,25 +840,6 @@ function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG
|
|
|
854
840
|
log(`[${componentName}] Config active:`, { friendlyId: config.friendlyId, defaultKey: config.defaultKey, keys: Object.keys(config.contentMap) });
|
|
855
841
|
}
|
|
856
842
|
const isEditing = context?.isEditing ?? false;
|
|
857
|
-
useEffect2(() => {
|
|
858
|
-
if (!isEditing || !config) return;
|
|
859
|
-
if (_marketplaceDetected) {
|
|
860
|
-
setShowBar(true);
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
const handler = (e) => {
|
|
864
|
-
try {
|
|
865
|
-
const data = typeof e.data === "string" ? JSON.parse(e.data) : e.data;
|
|
866
|
-
if (data?.type === MARKETPLACE_MSG_TYPE) {
|
|
867
|
-
_marketplaceDetected = true;
|
|
868
|
-
setShowBar(true);
|
|
869
|
-
}
|
|
870
|
-
} catch {
|
|
871
|
-
}
|
|
872
|
-
};
|
|
873
|
-
window.addEventListener("message", handler);
|
|
874
|
-
return () => window.removeEventListener("message", handler);
|
|
875
|
-
}, [isEditing, config]);
|
|
876
843
|
const handlePreviewSelect = useCallback2(async (key) => {
|
|
877
844
|
if (!config || !context) return;
|
|
878
845
|
setPreviewKey(key);
|
|
@@ -953,8 +920,7 @@ function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG
|
|
|
953
920
|
const isPreviewing = previewKey !== null && previewFields !== null;
|
|
954
921
|
const editingProps = isPreviewing ? { ...props, fields: previewFields } : props;
|
|
955
922
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
956
|
-
/* @__PURE__ */ jsx2(
|
|
957
|
-
showBar && /* @__PURE__ */ jsx2(
|
|
923
|
+
/* @__PURE__ */ jsx2(
|
|
958
924
|
PreviewBar,
|
|
959
925
|
{
|
|
960
926
|
config,
|
|
@@ -962,7 +928,8 @@ function withPersonalizeConnect(WrappedComponent, getConfig = DEFAULT_GET_CONFIG
|
|
|
962
928
|
isLoading: previewLoading,
|
|
963
929
|
onSelect: handlePreviewSelect
|
|
964
930
|
}
|
|
965
|
-
)
|
|
931
|
+
),
|
|
932
|
+
/* @__PURE__ */ jsx2(WrappedComponent, { ...editingProps })
|
|
966
933
|
] });
|
|
967
934
|
}
|
|
968
935
|
const mergedProps = resolvedFields ? { ...props, fields: resolvedFields } : props;
|
package/package.json
CHANGED