pb-sxp-ui 1.16.18 → 1.16.19
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 +21 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +21 -17
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/LikeButton/index.js +11 -11
- package/es/core/context/SxpDataSourceProvider.d.ts +4 -12
- package/es/core/context/SxpDataSourceProvider.js +11 -5
- package/lib/core/components/SxpPageRender/LikeButton/index.js +11 -11
- package/lib/core/context/SxpDataSourceProvider.d.ts +4 -12
- package/lib/core/context/SxpDataSourceProvider.js +11 -5
- package/package.json +1 -1
@@ -13,10 +13,10 @@ const LikeButton = (_a) => {
|
|
13
13
|
const likeIcon = useIconLink(defaultLikeIconPath);
|
14
14
|
const unlikeIcon = useIconLink(defaultUnLikeIconPath);
|
15
15
|
const handleClick = debounce(() => __awaiter(void 0, void 0, void 0, function* () {
|
16
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
16
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
17
17
|
if (state) {
|
18
18
|
setState(false);
|
19
|
-
const result = (_e = (yield (mutateUnlike === null || mutateUnlike === void 0 ? void 0 : mutateUnlike({
|
19
|
+
const result = (_e = (yield (mutateUnlike === null || mutateUnlike === void 0 ? void 0 : mutateUnlike({ itemId: (_d = (_c = recData === null || recData === void 0 ? void 0 : recData.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '' })))) !== null && _e !== void 0 ? _e : false;
|
20
20
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
21
21
|
eventInfo: {
|
22
22
|
eventSubject: 'favoriteContentCanceled',
|
@@ -45,30 +45,30 @@ const LikeButton = (_a) => {
|
|
45
45
|
}
|
46
46
|
else {
|
47
47
|
setState(true);
|
48
|
-
const result = (
|
48
|
+
const result = (_v = (yield (mutateLike === null || mutateLike === void 0 ? void 0 : mutateLike({ content: JSON.stringify(recData), itemId: (_u = (_t = recData === null || recData === void 0 ? void 0 : recData.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '' })))) !== null && _v !== void 0 ? _v : false;
|
49
49
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
50
50
|
eventInfo: {
|
51
51
|
eventSubject: 'favoriteContent',
|
52
52
|
eventDescription: 'This content was favorite by the user',
|
53
|
-
contentId: (
|
54
|
-
sceneId: (
|
55
|
-
contentName: (
|
56
|
-
contentTags: JSON.stringify((
|
53
|
+
contentId: (_x = (_w = recData === null || recData === void 0 ? void 0 : recData.video) === null || _w === void 0 ? void 0 : _w.itemId) !== null && _x !== void 0 ? _x : '',
|
54
|
+
sceneId: (_0 = (_z = (_y = recData === null || recData === void 0 ? void 0 : recData.video) === null || _y === void 0 ? void 0 : _y.scene) === null || _z === void 0 ? void 0 : _z.sceneId) !== null && _0 !== void 0 ? _0 : '',
|
55
|
+
contentName: (_2 = (_1 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _1 === void 0 ? void 0 : _1.title) !== null && _2 !== void 0 ? _2 : '',
|
56
|
+
contentTags: JSON.stringify((_4 = (_3 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _3 === void 0 ? void 0 : _3.tags) !== null && _4 !== void 0 ? _4 : []),
|
57
57
|
position: position + '',
|
58
|
-
contentFormat: ((
|
59
|
-
traceInfo: (
|
58
|
+
contentFormat: ((_5 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _5 === void 0 ? void 0 : _5.url) ? 'video' : 'image',
|
59
|
+
traceInfo: (_6 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _6 === void 0 ? void 0 : _6.traceInfo
|
60
60
|
}
|
61
61
|
});
|
62
62
|
if (!result) {
|
63
63
|
setState(false);
|
64
64
|
}
|
65
65
|
else {
|
66
|
-
const nRtcList = (
|
66
|
+
const nRtcList = (_7 = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList.map((item, index) => {
|
67
67
|
if (index === position) {
|
68
68
|
item.isCollected = true;
|
69
69
|
}
|
70
70
|
return item;
|
71
|
-
})) !== null &&
|
71
|
+
})) !== null && _7 !== void 0 ? _7 : [];
|
72
72
|
setCacheRtcList === null || setCacheRtcList === void 0 ? void 0 : setCacheRtcList(nRtcList);
|
73
73
|
}
|
74
74
|
}
|
@@ -21,12 +21,8 @@ export interface ISxpDataSourceContext {
|
|
21
21
|
value: string;
|
22
22
|
}>;
|
23
23
|
}) => Promise<boolean | undefined>;
|
24
|
-
mutateUnlike?: (body:
|
25
|
-
|
26
|
-
}) => Promise<boolean>;
|
27
|
-
mutateLike?: (body: {
|
28
|
-
content: string;
|
29
|
-
}) => Promise<boolean>;
|
24
|
+
mutateUnlike?: (body: Record<string, any>) => Promise<boolean>;
|
25
|
+
mutateLike?: (body: Record<string, any>) => Promise<boolean>;
|
30
26
|
popupDetailData?: RecItemType;
|
31
27
|
setPopupDetailData?: React.Dispatch<React.SetStateAction<any | null>>;
|
32
28
|
loadVideos?: (page: number) => Promise<RecommendVideoResultType | undefined>;
|
@@ -107,12 +103,8 @@ export interface SxpDataSourceProviderProps {
|
|
107
103
|
value: string;
|
108
104
|
}>;
|
109
105
|
}) => Promise<boolean | undefined>;
|
110
|
-
mutateUnlike: (body:
|
111
|
-
|
112
|
-
}) => Promise<boolean>;
|
113
|
-
mutateLike: (body: {
|
114
|
-
content: string;
|
115
|
-
}) => Promise<boolean>;
|
106
|
+
mutateUnlike: (body: Record<string, any>) => Promise<boolean>;
|
107
|
+
mutateLike: (body: Record<string, any>) => Promise<boolean>;
|
116
108
|
pageData?: PageData;
|
117
109
|
}) => ReactNode;
|
118
110
|
utmVal?: string;
|
@@ -122,8 +122,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
122
122
|
const value = val.split('=')[1];
|
123
123
|
params[key] = value;
|
124
124
|
});
|
125
|
+
options.body = Object.assign(Object.assign({}, options.body), { productUserId: fakeUserId });
|
125
126
|
return window
|
126
|
-
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId,
|
127
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId, 'tenant-id': (_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id'] }, bffDataSource.headers), method: options.method, body: options.type === 'beacon' && isBota
|
127
128
|
? JSON.stringify({
|
128
129
|
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
129
130
|
})
|
@@ -425,7 +426,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
425
426
|
return;
|
426
427
|
}
|
427
428
|
if (!userInfo) {
|
428
|
-
userInfo = {
|
429
|
+
userInfo = {
|
430
|
+
productUserId: fakeUserId
|
431
|
+
};
|
429
432
|
}
|
430
433
|
const sessionID = storeAndLoadFeSessionId();
|
431
434
|
const params = {};
|
@@ -458,7 +461,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
458
461
|
layoutVariantId,
|
459
462
|
globalConfig,
|
460
463
|
playbookType,
|
461
|
-
bffDataSource
|
464
|
+
bffDataSource,
|
465
|
+
fakeUserId
|
462
466
|
]);
|
463
467
|
const getEventParamsByJson = useCallback((json, product) => {
|
464
468
|
var _a, _b, _c;
|
@@ -588,13 +592,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
588
592
|
}
|
589
593
|
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
|
590
594
|
const bffMutateLike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
595
|
+
body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
|
591
596
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
|
592
597
|
return res === null || res === void 0 ? void 0 : res.success;
|
593
|
-
}), [bffFetch]);
|
598
|
+
}), [bffFetch, fakeUserId]);
|
594
599
|
const bffMutateUnlike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
600
|
+
body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
|
595
601
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/unlike', { method: 'POST', body }));
|
596
602
|
return res === null || res === void 0 ? void 0 : res.success;
|
597
|
-
}), [bffFetch]);
|
603
|
+
}), [bffFetch, fakeUserId]);
|
598
604
|
const bffSubmitForm = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
599
605
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/customform', { method: 'POST', body }));
|
600
606
|
return res === null || res === void 0 ? void 0 : res.success;
|
@@ -15,10 +15,10 @@ const LikeButton = (_a) => {
|
|
15
15
|
const likeIcon = (0, useIconLink_1.useIconLink)(defaultLikeIconPath);
|
16
16
|
const unlikeIcon = (0, useIconLink_1.useIconLink)(defaultUnLikeIconPath);
|
17
17
|
const handleClick = (0, lodash_1.debounce)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
18
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
18
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
19
19
|
if (state) {
|
20
20
|
setState(false);
|
21
|
-
const result = (_e = (yield (mutateUnlike === null || mutateUnlike === void 0 ? void 0 : mutateUnlike({
|
21
|
+
const result = (_e = (yield (mutateUnlike === null || mutateUnlike === void 0 ? void 0 : mutateUnlike({ itemId: (_d = (_c = recData === null || recData === void 0 ? void 0 : recData.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '' })))) !== null && _e !== void 0 ? _e : false;
|
22
22
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
23
23
|
eventInfo: {
|
24
24
|
eventSubject: 'favoriteContentCanceled',
|
@@ -47,30 +47,30 @@ const LikeButton = (_a) => {
|
|
47
47
|
}
|
48
48
|
else {
|
49
49
|
setState(true);
|
50
|
-
const result = (
|
50
|
+
const result = (_v = (yield (mutateLike === null || mutateLike === void 0 ? void 0 : mutateLike({ content: JSON.stringify(recData), itemId: (_u = (_t = recData === null || recData === void 0 ? void 0 : recData.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '' })))) !== null && _v !== void 0 ? _v : false;
|
51
51
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
52
52
|
eventInfo: {
|
53
53
|
eventSubject: 'favoriteContent',
|
54
54
|
eventDescription: 'This content was favorite by the user',
|
55
|
-
contentId: (
|
56
|
-
sceneId: (
|
57
|
-
contentName: (
|
58
|
-
contentTags: JSON.stringify((
|
55
|
+
contentId: (_x = (_w = recData === null || recData === void 0 ? void 0 : recData.video) === null || _w === void 0 ? void 0 : _w.itemId) !== null && _x !== void 0 ? _x : '',
|
56
|
+
sceneId: (_0 = (_z = (_y = recData === null || recData === void 0 ? void 0 : recData.video) === null || _y === void 0 ? void 0 : _y.scene) === null || _z === void 0 ? void 0 : _z.sceneId) !== null && _0 !== void 0 ? _0 : '',
|
57
|
+
contentName: (_2 = (_1 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _1 === void 0 ? void 0 : _1.title) !== null && _2 !== void 0 ? _2 : '',
|
58
|
+
contentTags: JSON.stringify((_4 = (_3 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _3 === void 0 ? void 0 : _3.tags) !== null && _4 !== void 0 ? _4 : []),
|
59
59
|
position: position + '',
|
60
|
-
contentFormat: ((
|
61
|
-
traceInfo: (
|
60
|
+
contentFormat: ((_5 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _5 === void 0 ? void 0 : _5.url) ? 'video' : 'image',
|
61
|
+
traceInfo: (_6 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _6 === void 0 ? void 0 : _6.traceInfo
|
62
62
|
}
|
63
63
|
});
|
64
64
|
if (!result) {
|
65
65
|
setState(false);
|
66
66
|
}
|
67
67
|
else {
|
68
|
-
const nRtcList = (
|
68
|
+
const nRtcList = (_7 = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList.map((item, index) => {
|
69
69
|
if (index === position) {
|
70
70
|
item.isCollected = true;
|
71
71
|
}
|
72
72
|
return item;
|
73
|
-
})) !== null &&
|
73
|
+
})) !== null && _7 !== void 0 ? _7 : [];
|
74
74
|
setCacheRtcList === null || setCacheRtcList === void 0 ? void 0 : setCacheRtcList(nRtcList);
|
75
75
|
}
|
76
76
|
}
|
@@ -21,12 +21,8 @@ export interface ISxpDataSourceContext {
|
|
21
21
|
value: string;
|
22
22
|
}>;
|
23
23
|
}) => Promise<boolean | undefined>;
|
24
|
-
mutateUnlike?: (body:
|
25
|
-
|
26
|
-
}) => Promise<boolean>;
|
27
|
-
mutateLike?: (body: {
|
28
|
-
content: string;
|
29
|
-
}) => Promise<boolean>;
|
24
|
+
mutateUnlike?: (body: Record<string, any>) => Promise<boolean>;
|
25
|
+
mutateLike?: (body: Record<string, any>) => Promise<boolean>;
|
30
26
|
popupDetailData?: RecItemType;
|
31
27
|
setPopupDetailData?: React.Dispatch<React.SetStateAction<any | null>>;
|
32
28
|
loadVideos?: (page: number) => Promise<RecommendVideoResultType | undefined>;
|
@@ -107,12 +103,8 @@ export interface SxpDataSourceProviderProps {
|
|
107
103
|
value: string;
|
108
104
|
}>;
|
109
105
|
}) => Promise<boolean | undefined>;
|
110
|
-
mutateUnlike: (body:
|
111
|
-
|
112
|
-
}) => Promise<boolean>;
|
113
|
-
mutateLike: (body: {
|
114
|
-
content: string;
|
115
|
-
}) => Promise<boolean>;
|
106
|
+
mutateUnlike: (body: Record<string, any>) => Promise<boolean>;
|
107
|
+
mutateLike: (body: Record<string, any>) => Promise<boolean>;
|
116
108
|
pageData?: PageData;
|
117
109
|
}) => ReactNode;
|
118
110
|
utmVal?: string;
|
@@ -125,8 +125,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
125
125
|
const value = val.split('=')[1];
|
126
126
|
params[key] = value;
|
127
127
|
});
|
128
|
+
options.body = Object.assign(Object.assign({}, options.body), { productUserId: fakeUserId });
|
128
129
|
return window
|
129
|
-
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId,
|
130
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId, 'tenant-id': (_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id'] }, bffDataSource.headers), method: options.method, body: options.type === 'beacon' && isBota
|
130
131
|
? JSON.stringify({
|
131
132
|
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
132
133
|
})
|
@@ -428,7 +429,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
428
429
|
return;
|
429
430
|
}
|
430
431
|
if (!userInfo) {
|
431
|
-
userInfo = {
|
432
|
+
userInfo = {
|
433
|
+
productUserId: fakeUserId
|
434
|
+
};
|
432
435
|
}
|
433
436
|
const sessionID = (0, sessionStore_1.storeAndLoadFeSessionId)();
|
434
437
|
const params = {};
|
@@ -461,7 +464,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
461
464
|
layoutVariantId,
|
462
465
|
globalConfig,
|
463
466
|
playbookType,
|
464
|
-
bffDataSource
|
467
|
+
bffDataSource,
|
468
|
+
fakeUserId
|
465
469
|
]);
|
466
470
|
const getEventParamsByJson = (0, react_1.useCallback)((json, product) => {
|
467
471
|
var _a, _b, _c;
|
@@ -591,13 +595,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
591
595
|
}
|
592
596
|
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
|
593
597
|
const bffMutateLike = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
598
|
+
body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
|
594
599
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
|
595
600
|
return res === null || res === void 0 ? void 0 : res.success;
|
596
|
-
}), [bffFetch]);
|
601
|
+
}), [bffFetch, fakeUserId]);
|
597
602
|
const bffMutateUnlike = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
603
|
+
body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
|
598
604
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/unlike', { method: 'POST', body }));
|
599
605
|
return res === null || res === void 0 ? void 0 : res.success;
|
600
|
-
}), [bffFetch]);
|
606
|
+
}), [bffFetch, fakeUserId]);
|
601
607
|
const bffSubmitForm = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
602
608
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/customform', { method: 'POST', body }));
|
603
609
|
return res === null || res === void 0 ? void 0 : res.success;
|